summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-24 01:23:55 +0900
committerAdam Malczewski <[email protected]>2026-06-24 01:23:55 +0900
commit3a688edee373cbbc291a149e50e1d2802e2e29a4 (patch)
tree95ce88628426cf6ba79fdf3a276b040617353034 /packages
parentb9abc1f8d8815f57e7b958b871ad85db205a9257 (diff)
downloaddispatch-3a688edee373cbbc291a149e50e1d2802e2e29a4.tar.gz
dispatch-3a688edee373cbbc291a149e50e1d2802e2e29a4.zip
feat(system-prompt): add prompt:workspace_id variable
Lets the AI know which workspace it's in — especially useful when summoning agents. Wired through the construct context in both the regular turn flow and the compaction flow.
Diffstat (limited to 'packages')
-rw-r--r--packages/session-orchestrator/src/orchestrator.ts3
-rw-r--r--packages/system-prompt/src/catalog.ts1
-rw-r--r--packages/system-prompt/src/resolver.ts2
-rw-r--r--packages/system-prompt/src/service.ts9
-rw-r--r--packages/system-prompt/src/types.ts2
5 files changed, 12 insertions, 5 deletions
diff --git a/packages/session-orchestrator/src/orchestrator.ts b/packages/session-orchestrator/src/orchestrator.ts
index 5398867..7599a0c 100644
--- a/packages/session-orchestrator/src/orchestrator.ts
+++ b/packages/session-orchestrator/src/orchestrator.ts
@@ -489,6 +489,7 @@ export function createSessionOrchestrator(
effectiveCwd ?? process.cwd(),
{
...(modelName !== undefined ? { model: modelName } : {}),
+ ...(workspaceId !== undefined ? { workspaceId } : {}),
},
);
} else {
@@ -952,8 +953,10 @@ export function createCompactionService(
let compactionSystemPrompt: string;
if (systemPromptService !== undefined) {
const cwd = (await deps.conversationStore.getEffectiveCwd(conversationId)) ?? process.cwd();
+ const workspaceId = await deps.conversationStore.getWorkspaceId(conversationId);
const constructed = await systemPromptService.construct(conversationId, cwd, {
...(opts?.modelName !== undefined ? { model: opts.modelName } : {}),
+ workspaceId,
});
compactionSystemPrompt = `${constructed}\n\n${COMPACTION_SYSTEM_PROMPT}`;
} else {
diff --git a/packages/system-prompt/src/catalog.ts b/packages/system-prompt/src/catalog.ts
index cfa3bb1..1c825ab 100644
--- a/packages/system-prompt/src/catalog.ts
+++ b/packages/system-prompt/src/catalog.ts
@@ -16,6 +16,7 @@ export function getVariableCatalog(): SystemPromptVariable[] {
{ type: "prompt", name: "cwd", description: "Conversation working directory" },
{ type: "prompt", name: "model", description: "Current model name" },
{ type: "prompt", name: "conversation_id", description: "Conversation identifier" },
+ { type: "prompt", name: "workspace_id", description: "Workspace identifier" },
{ type: "git", name: "branch", description: "Current git branch" },
{ type: "git", name: "status", description: "Short git status" },
{
diff --git a/packages/system-prompt/src/resolver.ts b/packages/system-prompt/src/resolver.ts
index eed7bcb..1ef9028 100644
--- a/packages/system-prompt/src/resolver.ts
+++ b/packages/system-prompt/src/resolver.ts
@@ -55,6 +55,7 @@ export interface ResolverAdapters {
export interface ResolverContext {
readonly model?: string;
readonly conversationId?: string;
+ readonly workspaceId?: string;
}
export interface ResolveOptions {
@@ -116,6 +117,7 @@ export async function resolveVariables(
vars.set("prompt:cwd", cwd);
vars.set("prompt:model", ctx?.model ?? null);
vars.set("prompt:conversation_id", ctx?.conversationId ?? null);
+ vars.set("prompt:workspace_id", ctx?.workspaceId ?? null);
// ── git:* ────────────────────────────────────────────────────────────────
// branch is a single value — trim fully; status keeps its leading status
diff --git a/packages/system-prompt/src/service.ts b/packages/system-prompt/src/service.ts
index 4b4436f..6fdae51 100644
--- a/packages/system-prompt/src/service.ts
+++ b/packages/system-prompt/src/service.ts
@@ -46,10 +46,11 @@ export function createSystemPromptService(deps: SystemPromptServiceDeps): System
if (template === null) template = DEFAULT_TEMPLATE;
const referencedKeys = extractVariables(template);
- const resolverContext: ResolverContext =
- context?.model !== undefined
- ? { model: context.model, conversationId }
- : { conversationId };
+ const resolverContext: ResolverContext = {
+ conversationId,
+ ...(context?.model !== undefined ? { model: context.model } : {}),
+ ...(context?.workspaceId !== undefined ? { workspaceId: context.workspaceId } : {}),
+ };
const vars = await resolveVariables(cwd, deps.adapters, {
context: resolverContext,
referencedKeys,
diff --git a/packages/system-prompt/src/types.ts b/packages/system-prompt/src/types.ts
index dd6aa69..2690355 100644
--- a/packages/system-prompt/src/types.ts
+++ b/packages/system-prompt/src/types.ts
@@ -24,7 +24,7 @@ export interface SystemPromptService {
construct(
conversationId: string,
cwd: string,
- context?: { readonly model?: string },
+ context?: { readonly model?: string; readonly workspaceId?: string },
): Promise<string>;
/** Read the persisted resolved system prompt, or `null` if never constructed. */