Files
deepseek-harness/website/zh-CN/api/harness/system-prompt.md
T

67 lines
2.7 KiB
Markdown
Raw Normal View History

<!-- Generated by scripts/gen-website-api.ts — do not edit by hand. Run `pnpm run gen-website-api` to regenerate. -->
# ctx.systemPrompt
`SystemPrompt` — provided by `@deepseek-ai/dsh-system-prompt`.
2026-07-16 21:36:43 +08:00
Registry service for the prompt inputs assembled before each model step.
2026-07-16 21:36:43 +08:00
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/core/system-prompt/src/index.ts#L209)
### ctx.systemPrompt.section(section)
```ts website-api
section(section: PromptSection): () => void
```
2026-07-16 21:36:43 +08:00
Register an ordered prompt section in the calling context's scope. A scoped section shadows a global section with the same name; duplicates within one layer and non-finite orders throw. Registration and disposal emit `system-prompt/change`.
2026-07-16 21:36:43 +08:00
- `section` — the section to register.
2026-07-16 21:36:43 +08:00
**Returns** the exact Cordis effect disposer.
2026-07-16 21:36:43 +08:00
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/core/system-prompt/src/index.ts#L250)
### ctx.systemPrompt.tools(provider)
```ts website-api
2026-07-16 21:36:43 +08:00
tools(provider: (context: AssembleContext) => ToolProviderResult): () => void
```
2026-07-16 21:36:43 +08:00
Register a tool-schema provider in the calling context's scope. Global and matching scoped providers both contribute; returning the reserved TOOL_ORDER_REST name makes assembly fail.
2026-07-16 21:36:43 +08:00
- `provider` — evaluated for each assembly with its context.
2026-07-16 21:36:43 +08:00
**Returns** the exact Cordis effect disposer.
2026-07-16 21:36:43 +08:00
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/core/system-prompt/src/index.ts#L291)
### ctx.systemPrompt.variable(name, provider)
```ts website-api
variable(name: string, provider: (context: AssembleContext) => string | undefined): () => void
```
2026-07-16 21:36:43 +08:00
Register a prompt variable in the calling context's scope. Scoped values shadow globals; invalid or duplicate names throw. A provider may return `undefined`, but rendering a section that references that value then fails.
2026-07-16 21:36:43 +08:00
- `name` — the `[a-z][a-z0-9_]*` reference name.
- `provider` — evaluated for each assembly.
2026-07-16 21:36:43 +08:00
**Returns** the exact Cordis effect disposer.
2026-07-16 21:36:43 +08:00
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/core/system-prompt/src/index.ts#L325)
### ctx.systemPrompt.assemble(context?)
```ts website-api
async assemble(context: AssembleContext = {}): Promise<PromptAssembly>
```
2026-07-16 21:36:43 +08:00
Assemble global and scoped providers, detach tool parameters, apply canonical ordering, then run the assembly waterfall. Scoped sections and variables shadow globals; the returned waterfall value is authoritative.
2026-07-16 21:36:43 +08:00
- `context` — the optional scope and plugin-defined assembly fields.
2026-07-16 21:36:43 +08:00
**Returns** the authoritative post-waterfall assembly.
2026-07-16 21:36:43 +08:00
[Source](https://github.com/deepseek-harness/deepseek-harness/blob/master/packages/core/system-prompt/src/index.ts#L365)