mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-13 04:03:30 +00:00
Field test: the model received a bare '@niulai/' and guessed a user mention — the guidance section was present but said only that @-prefixed paths are files, never covering the trailing-slash directory form, the workspace-relative root, or the quoted spelling. Rewrite the section to name all three; the section's presence conditions and every consumer pin the constant, so nothing else moves.
64 lines
2.3 KiB
TypeScript
64 lines
2.3 KiB
TypeScript
/**
|
|
* File-reference discovery seam shared by host-backed user interfaces.
|
|
*
|
|
* @module @deepseek-ai/dsh-file-reference
|
|
*/
|
|
|
|
import type { Context } from '@deepseek-ai/cordis'
|
|
import type { Agent } from '@deepseek-ai/dsh-agent'
|
|
import { Remote, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol'
|
|
|
|
import type { FileReferenceCandidate } from './types.ts'
|
|
|
|
export { activeAtToken, formatFileMention } from './grammar.ts'
|
|
export type { ActiveAtToken } from './grammar.ts'
|
|
export type { FileReferenceCandidate } from './types.ts'
|
|
|
|
/** Model guidance for path-only references selected by a user interface. */
|
|
export const FILE_REFERENCE_PROMPT = 'Tokens prefixed with @ are workspace paths the user explicitly referenced, relative to the workspace root. A trailing slash marks a directory: list it when its contents matter. Anything else is a file: use the read tool when its contents are needed, and do not claim to have inspected it before reading. @"..." quotes a path containing spaces.'
|
|
|
|
declare module '@deepseek-ai/cordis' {
|
|
interface Context {
|
|
fileReferences: FileReferenceService
|
|
}
|
|
}
|
|
|
|
/** Host capability for cancellable file-reference discovery. */
|
|
export abstract class FileReferenceService extends TypertRemoteService {
|
|
constructor(ctx: Context) {
|
|
super(ctx, 'fileReferences')
|
|
}
|
|
|
|
/**
|
|
* List file and directory candidates for one agent's working directory.
|
|
* @param agent - target agent whose session cwd bounds discovery.
|
|
* @param query - path text following `@` or `@"`.
|
|
* @param signal - caller cancellation.
|
|
* @returns deterministic path-only candidates.
|
|
*/
|
|
abstract list(
|
|
agent: Agent,
|
|
query: string,
|
|
signal: AbortSignal,
|
|
): Promise<FileReferenceCandidate[]>
|
|
|
|
/**
|
|
* Remote face of {@link list}; the decorator cannot mark the abstract
|
|
* member, so this concrete adapter carries the identical contract.
|
|
* @param agent - target agent whose session cwd bounds discovery.
|
|
* @param query - path text following `@` or `@"`.
|
|
* @param signal - caller cancellation.
|
|
* @returns deterministic path-only candidates.
|
|
*/
|
|
@Remote('list')
|
|
remoteExportList(
|
|
agent: Agent,
|
|
query: string,
|
|
signal: AbortSignal,
|
|
): Promise<FileReferenceCandidate[]> {
|
|
return this.list(agent, query, signal)
|
|
}
|
|
}
|
|
|
|
export default FileReferenceService
|