summaryrefslogtreecommitdiffhomepage
path: root/packages/system-prompt/src/types.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-23 23:04:30 +0900
committerAdam Malczewski <[email protected]>2026-06-23 23:04:30 +0900
commit674853d87d54dba1cd83c4e51fce5411602f4d5d (patch)
tree07455f9753a09a5ca66f8cb885a37ba3c0cb7787 /packages/system-prompt/src/types.ts
parent4158e699e3c8ff556684fe2fc7a39ffab040623e (diff)
downloaddispatch-674853d87d54dba1cd83c4e51fce5411602f4d5d.tar.gz
dispatch-674853d87d54dba1cd83c4e51fce5411602f4d5d.zip
feat(system-prompt): template-based system prompt builder extension
New @dispatch/system-prompt extension (standard tier): - Pure parser: [type:name] variables, [if]/[else]/[endif] conditionals, negated [if !...], nested blocks, unmatched-tag pass-through. - Variable resolver (injected adapters): system:time/date/os/hostname, prompt:cwd/model/conversation_id, git:branch/status, file:<path> (dynamic). - Service handle: construct (resolve+persist) + get (cached, cache-safe). - Default template: persona + AGENTS.md if exists + cwd. - 52 tests (parser 29, resolver 12, catalog 3, service 8). transport-contract 0.17.0→0.18.0: SystemPromptTemplateResponse, SetSystemPromptTemplateRequest, SystemPromptVariable, SystemPromptVariablesResponse. Design: notes/system-prompt-design.md (caching constraint, compaction integration, wave plan). 1384 vitest pass.
Diffstat (limited to 'packages/system-prompt/src/types.ts')
-rw-r--r--packages/system-prompt/src/types.ts39
1 files changed, 39 insertions, 0 deletions
diff --git a/packages/system-prompt/src/types.ts b/packages/system-prompt/src/types.ts
new file mode 100644
index 0000000..9e87512
--- /dev/null
+++ b/packages/system-prompt/src/types.ts
@@ -0,0 +1,39 @@
+/**
+ * System-prompt service handle + interface.
+ *
+ * The service is the single-responder anchor the session-orchestrator obtains
+ * (lazily, via `host.getService(systemPromptHandle)`) to construct and read the
+ * per-conversation resolved system prompt.
+ */
+import { defineService, type ServiceHandle } from "@dispatch/kernel";
+
+/**
+ * The system-prompt service.
+ *
+ * `construct` resolves the template once (first turn / compaction) and persists
+ * the result; `get` reads the persisted result on subsequent turns (cache-safe —
+ * no per-turn reconstruction).
+ */
+export interface SystemPromptService {
+ /**
+ * Resolve the template against the current environment and persist the
+ * result under `resolved:<conversationId>`. Returns the resolved string.
+ * When no template is stored, the built-in default template is used. An
+ * empty template yields an empty string.
+ */
+ construct(
+ conversationId: string,
+ cwd: string,
+ context?: { readonly model?: string },
+ ): Promise<string>;
+
+ /** Read the persisted resolved system prompt, or `null` if never constructed. */
+ get(conversationId: string): Promise<string | null>;
+}
+
+/**
+ * Typed handle anchoring the system-prompt service. The single symbol the
+ * session-orchestrator imports to reach the builder — no string-keyed lookup.
+ */
+export const systemPromptHandle: ServiceHandle<SystemPromptService> =
+ defineService<SystemPromptService>("system-prompt");