summaryrefslogtreecommitdiffhomepage
path: root/packages/system-prompt/src/catalog.test.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/catalog.test.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/catalog.test.ts')
-rw-r--r--packages/system-prompt/src/catalog.test.ts31
1 files changed, 31 insertions, 0 deletions
diff --git a/packages/system-prompt/src/catalog.test.ts b/packages/system-prompt/src/catalog.test.ts
new file mode 100644
index 0000000..406455b
--- /dev/null
+++ b/packages/system-prompt/src/catalog.test.ts
@@ -0,0 +1,31 @@
+import { describe, expect, it } from "vitest";
+import { getVariableCatalog } from "./catalog.js";
+
+describe("catalog", () => {
+ it("lists all fixed variables", () => {
+ const catalog = getVariableCatalog();
+ const keys = catalog.map((v) => `${v.type}:${v.name}`);
+
+ expect(keys).toContain("system:time");
+ expect(keys).toContain("system:date");
+ expect(keys).toContain("system:os");
+ expect(keys).toContain("system:hostname");
+ expect(keys).toContain("prompt:cwd");
+ expect(keys).toContain("prompt:model");
+ expect(keys).toContain("prompt:conversation_id");
+ expect(keys).toContain("git:branch");
+ expect(keys).toContain("git:status");
+ });
+
+ it("marks the file type as dynamic", () => {
+ const fileVar = getVariableCatalog().find((v) => v.type === "file");
+ expect(fileVar).toBeDefined();
+ expect(fileVar?.dynamic).toBe(true);
+ });
+
+ it("every entry has a description", () => {
+ for (const v of getVariableCatalog()) {
+ expect(v.description.length).toBeGreaterThan(0);
+ }
+ });
+});