Files
deepseek-harness/packages/context/file-reference/src/index.ts
T

52 lines
1.7 KiB
TypeScript

/**
* File-reference discovery seam shared by host-backed user interfaces.
*
* @module @deepseek-ai/dsh-file-reference
*/
import { Service } from 'cordis'
import type { Context } from 'cordis'
import type { Agent } from '@deepseek-ai/dsh-agent'
export { activeAtToken, formatFileMention } from './grammar.ts'
export type { ActiveAtToken } from './grammar.ts'
/** Model guidance for path-only references selected by a user interface. */
export const FILE_REFERENCE_PROMPT = 'Paths prefixed with @ are files explicitly referenced by the user. Use the read tool when their contents are needed; do not claim to have inspected a file before reading it.'
/** One path-only completion candidate inside the target session cwd. */
export interface FileReferenceCandidate {
/** User-facing path accepted by normal prompts and filesystem tools. */
path: string
/** Directories keep completion open; files finish the mention. */
kind: 'file' | 'directory'
}
declare module 'cordis' {
interface Context {
fileReferences: FileReferenceService
}
}
/** Host capability for cancellable file-reference discovery. */
export abstract class FileReferenceService extends Service {
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[]>
}
export default FileReferenceService