thoth-agents 0.1.18 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +55 -12
  2. package/dist/agents/prompt-dialects.d.ts +9 -0
  3. package/dist/{chunk-6K3ZXIMC.js → chunk-3NOVCFN7.js} +88 -29
  4. package/dist/chunk-4WYCZ5Z7.js +698 -0
  5. package/dist/{chunk-SOT5ZY53.js → chunk-WH3F3GWE.js} +1498 -350
  6. package/dist/cli/claude-code-install.d.ts +53 -0
  7. package/dist/cli/claude-code-paths.d.ts +31 -0
  8. package/dist/cli/codex-install.d.ts +1 -5
  9. package/dist/cli/commands.d.ts +1 -1
  10. package/dist/cli/index.js +85 -27
  11. package/dist/cli/managed-state-io.d.ts +16 -0
  12. package/dist/cli/operations/claude-code.d.ts +21 -0
  13. package/dist/cli/tui/index.js +87 -9
  14. package/dist/cli/tui/operations.d.ts +2 -0
  15. package/dist/cli/types.d.ts +3 -3
  16. package/dist/config/index.d.ts +1 -1
  17. package/dist/config/schema.d.ts +11 -0
  18. package/dist/config/utils.d.ts +5 -0
  19. package/dist/harness/adapters/claude-code.d.ts +24 -0
  20. package/dist/harness/core/memory-governance.d.ts +39 -4
  21. package/dist/harness/core/package-version.d.ts +7 -0
  22. package/dist/harness/types.d.ts +1 -1
  23. package/dist/harness/writers/claude-code-plugin-package.d.ts +32 -0
  24. package/dist/harness/writers/claude-code-skill-layout.d.ts +16 -0
  25. package/dist/harness/writers/claude-code-subagent.d.ts +26 -0
  26. package/dist/harness/writers/fs-skill-collect.d.ts +7 -0
  27. package/dist/hooks/phase-reminder/index.d.ts +2 -0
  28. package/dist/hooks/thoth-mem/protocol.d.ts +2 -2
  29. package/dist/index.js +54 -512
  30. package/package.json +1 -1
  31. package/src/skills/_shared/persistence-contract.md +18 -14
  32. package/src/skills/_shared/thoth-mem-convention.md +18 -18
  33. package/src/skills/executing-plans/SKILL.md +6 -4
  34. package/src/skills/plan-reviewer/SKILL.md +4 -2
  35. package/src/skills/thoth-mem-agents/SKILL.md +3 -0
  36. package/thoth-agents.schema.json +16 -0
  37. package/dist/chunk-DYGVRAMS.js +0 -182
package/README.md CHANGED
@@ -15,14 +15,16 @@
15
15
 
16
16
  thoth-agents is a delegate-first agent system for coding harnesses. It started
17
17
  as an OpenCode plugin and now provides a shared seven-agent workflow for
18
- OpenCode and Codex, with each harness getting the integration surface that fits
19
- it best.
18
+ OpenCode, Codex, and Claude Code, with each harness getting the integration
19
+ surface that fits it best.
20
20
 
21
21
  OpenCode remains the stable default path: native plugin install, native `task`
22
22
  delegation, optional tmux monitoring, and generated config. Codex is supported
23
23
  through an explicit agent-pack and Personal plugin setup path, with documented
24
24
  trust review and instruction-level governance caveats where Codex does not
25
- provide the same hard runtime controls.
25
+ provide the same hard runtime controls. Claude Code is a first-class path: a
26
+ single auto-discovered plugin package with native subagents, harness-enforced
27
+ hooks, MCP, skills, and per-agent tool permissions.
26
28
 
27
29
  ## What It Is
28
30
 
@@ -52,6 +54,7 @@ provide the same hard runtime controls.
52
54
  | --- | --- | --- | --- |
53
55
  | OpenCode | Stable default | `npx thoth-agents@latest install` or `npx thoth-agents@latest install --agent=opencode` | Native plugin config, native `task` delegation, optional tmux panes, OpenCode provider auth. |
54
56
  | Codex | Supported explicit path | `npx thoth-agents@latest install --agent=codex` | Installs ambient/root guidance, six role subagents, and a Personal plugin source. Requires `/plugins` and `/hooks` trust review. Some governance remains instruction-level. |
57
+ | Claude Code | Supported first-class path | `npx thoth-agents@latest install --agent=claude` | Installs one Claude Code plugin: six specialist subagents (`Task(subagent_type: ...)`), an `orchestrator` agent activated as the main thread via `settings.json`, `.mcp.json`, and bundled skills. Role permissions are enforced by subagent `tools`. |
55
58
 
56
59
  OpenCode can load the plugin with:
57
60
 
@@ -123,6 +126,35 @@ Codex install does not create a selectable orchestrator TOML, does not bypass
123
126
  trust review, and does not make role permissions or memory governance hard
124
127
  runtime guarantees unless Codex exposes those controls.
125
128
 
129
+ ### Claude Code
130
+
131
+ Preview, then install the plugin package:
132
+
133
+ ```bash
134
+ npx thoth-agents@latest install --agent=claude --dry-run
135
+ npx thoth-agents@latest install --agent=claude
136
+ ```
137
+
138
+ This writes a single Claude Code **skills-directory plugin** under
139
+ `~/.claude/skills/thoth-agents`: `.claude-plugin/plugin.json`, seven
140
+ auto-discovered agents in `agents/` (six specialists + an `orchestrator`), an
141
+ `.mcp.json` server map, bundled `skills/`, and a plugin-root `settings.json`
142
+ with `{ "agent": "orchestrator" }`. That `agent` key activates the orchestrator
143
+ as the **main thread** — replacing the default system prompt — so the session
144
+ starts in delegate-first mode and bootstraps thoth-mem on its first turn. It
145
+ auto-loads as `thoth-agents@skills-dir` on the next session (no marketplace or
146
+ install step); restart Claude Code or run `/reload-plugins` to activate it
147
+ (confirm in `/plugin` → Installed). The orchestrator delegates to specialists
148
+ with `Task(subagent_type: explorer|librarian|oracle|designer|quick|deep)`. Role
149
+ permissions are enforced through each specialist's frontmatter `tools` allowlist.
150
+ You can also emit the package without installing it:
151
+
152
+ ```bash
153
+ npx thoth-agents@latest generate --harness=claude --dry-run
154
+ ```
155
+
156
+ See [docs/claude-code-plugin-packaging.md](docs/claude-code-plugin-packaging.md).
157
+
126
158
  ### Reset Generated Config
127
159
 
128
160
  ```bash
@@ -301,9 +333,20 @@ Artifacts can be persisted in four modes:
301
333
  Thoth-mem is the local memory MCP used for durable observations, architectural
302
334
  decisions, SDD artifacts, and session summaries. The core retrieval pattern is:
303
335
 
304
- 1. `mem_search` for compact candidate records
305
- 2. `mem_timeline` for chronological context
306
- 3. `mem_get_observation` for the full selected record
336
+ 1. `mem_recall(mode="compact")` for compact candidate records
337
+ 2. `mem_recall(mode="context")` for expanded retrieved context
338
+ 3. `mem_get(...)` for the full selected record; use
339
+ `mem_get(include_timeline=true)` when chronology matters
340
+
341
+ Use HyDE/fused hybrid recall (sentence + chunk vectors, FTS, KG enrichment) for
342
+ semantic or ambiguous searches; set `mem_recall` `limit` from 1 to 20; narrow
343
+ with `topic_key`, `type`, `time_from`, `time_to`, `scope`, `project`, and
344
+ `session_id` filters. Use `mem_get` with `kind="observation"|"prompt"`,
345
+ `include_timeline=true` plus `before`/`after`, and `offset`/`max_length` for
346
+ large content. Use bounded `mem_context(recall_query=...)` or
347
+ `mem_project(action="graph"|"topics"|"topic")` for supplemental project
348
+ context; `mem_project(action="graph")` relations are `HAS_TYPE`, `IN_PROJECT`,
349
+ `HAS_TOPIC_KEY`, `HAS_WHAT`, `HAS_WHY`, `HAS_WHERE`, and `HAS_LEARNED`.
307
350
 
308
351
  ## Skills And MCPs
309
352
 
@@ -312,12 +355,12 @@ planning/execution, verification, and archiving. It also registers MCP servers
312
355
  for docs research, public code search, and local memory where the harness
313
356
  supports that delivery surface.
314
357
 
315
- | Surface | Shared concept | OpenCode binding | Codex binding |
316
- | --- | --- | --- | --- |
317
- | Skills | Requirements, SDD, review, execution workflows | Copied into the OpenCode skills directory when `--skills=yes` | Packaged as plugin-bundled skills for the Personal plugin source |
318
- | MCPs | `exa`, `context7`, `grep_app`, `thoth_mem` | Registered by generated OpenCode plugin config | Packaged/configured only on validated Codex surfaces |
319
- | Delegation | Seven-role specialist workflow | Native `task` tool | Custom agents plus prompt/plugin guidance |
320
- | Blocking choices | Use a structured question surface | OpenCode `question` tool | `request_user_input` when enabled and available |
358
+ | Surface | Shared concept | OpenCode binding | Codex binding | Claude Code binding |
359
+ | --- | --- | --- | --- | --- |
360
+ | Skills | Requirements, SDD, review, execution workflows | Copied into the OpenCode skills directory when `--skills=yes` | Packaged as plugin-bundled skills for the Personal plugin source | Bundled in the plugin `skills/` directory |
361
+ | MCPs | `exa`, `context7`, `grep_app`, `thoth_mem` | Registered by generated OpenCode plugin config | Packaged/configured only on validated Codex surfaces | Bundled in the plugin `.mcp.json` (`type: "http"` for URL servers) |
362
+ | Delegation | Seven-role specialist workflow | Native `task` tool | Custom agents plus prompt/plugin guidance | Native `Task(subagent_type: ...)` over auto-discovered subagents |
363
+ | Blocking choices | Use a structured question surface | OpenCode `question` tool | `request_user_input` when enabled and available | `AskUserQuestion` tool |
321
364
 
322
365
  See [docs/skills-and-mcps.md](docs/skills-and-mcps.md) for the detailed matrix.
323
366
 
@@ -22,7 +22,16 @@ export interface HarnessPromptDialect {
22
22
  renderRoleInvocation(role: AgentPromptRole): string;
23
23
  }
24
24
  export declare const CODEX_PROMPT_CAPABILITIES: HarnessCapabilities;
25
+ export declare const CLAUDE_CODE_PROMPT_CAPABILITIES: HarnessCapabilities;
25
26
  export declare const OPENCODE_PROMPT_DIALECT: HarnessPromptDialect;
26
27
  export declare const CODEX_PROMPT_DIALECT: HarnessPromptDialect;
28
+ /**
29
+ * Claude Code registers plugin subagents under the plugin name as a namespace,
30
+ * so the `subagent_type` for delegation is `thoth-agents:<role>`, not the bare
31
+ * role name. This must match the plugin manifest `name`.
32
+ */
33
+ export declare const CLAUDE_CODE_SUBAGENT_NAMESPACE = "thoth-agents";
34
+ export declare function claudeCodeSubagentType(role: AgentPromptRole): string;
35
+ export declare const CLAUDE_CODE_PROMPT_DIALECT: HarnessPromptDialect;
27
36
  export declare function getPromptDialect(harness: HarnessId): HarnessPromptDialect;
28
37
  export declare function getPromptDialect(harness: string): HarnessPromptDialect;
@@ -459,6 +459,11 @@ var CodexGenerationConfigSchema = z.object({
459
459
  outputRoot: z.string().optional(),
460
460
  dryRun: z.boolean().default(true)
461
461
  });
462
+ var ClaudeCodeGenerationConfigSchema = z.object({
463
+ enabled: z.boolean().default(false),
464
+ outputRoot: z.string().optional(),
465
+ dryRun: z.boolean().default(true)
466
+ });
462
467
  var FailoverConfigSchema = z.object({
463
468
  enabled: z.boolean().default(true),
464
469
  timeoutMs: z.number().min(0).default(15e3),
@@ -479,7 +484,8 @@ var PluginConfigSchema = z.object({
479
484
  fallback: FailoverConfigSchema.optional(),
480
485
  thoth: ThothConfigSchema.optional(),
481
486
  artifactStore: ArtifactStoreConfigSchema.optional(),
482
- codex: CodexGenerationConfigSchema.optional()
487
+ codex: CodexGenerationConfigSchema.optional(),
488
+ claudeCode: ClaudeCodeGenerationConfigSchema.optional()
483
489
  });
484
490
 
485
491
  // src/config/loader.ts
@@ -653,6 +659,13 @@ function getAgentOverride(config, name) {
653
659
  const overrides = config?.agents ?? {};
654
660
  return overrides[name] ?? overrides[Object.keys(AGENT_ALIASES).find((k) => AGENT_ALIASES[k] === name) ?? ""];
655
661
  }
662
+ function getPrimaryModelId(model) {
663
+ if (Array.isArray(model)) {
664
+ const first = model[0];
665
+ return typeof first === "string" ? first : first?.id;
666
+ }
667
+ return model;
668
+ }
656
669
 
657
670
  // src/agents/prompt-dialects.ts
658
671
  var OPENCODE_CAPABILITIES = {
@@ -677,6 +690,17 @@ var CODEX_PROMPT_CAPABILITIES = {
677
690
  parentContextInjection: "instruction-only",
678
691
  memoryGovernanceEnforcement: "instruction-only"
679
692
  };
693
+ var CLAUDE_CODE_PROMPT_CAPABILITIES = {
694
+ agentDefinitions: "supported",
695
+ delegatedExecution: "supported",
696
+ parallelDelegation: "supported",
697
+ runtimeHooks: "supported",
698
+ mcpConfiguration: "supported",
699
+ skillPackaging: "supported",
700
+ rolePermissions: "supported",
701
+ parentContextInjection: "supported",
702
+ memoryGovernanceEnforcement: "supported"
703
+ };
680
704
  function supportedCapabilityProfile(capabilities) {
681
705
  return {
682
706
  capabilities,
@@ -748,6 +772,36 @@ var CODEX_PROMPT_DIALECT = {
748
772
  return role === "orchestrator" ? "orchestrator role agent" : `${role} subagent`;
749
773
  }
750
774
  };
775
+ var CLAUDE_CODE_SUBAGENT_NAMESPACE = "thoth-agents";
776
+ function claudeCodeSubagentType(role) {
777
+ return `${CLAUDE_CODE_SUBAGENT_NAMESPACE}:${role}`;
778
+ }
779
+ var CLAUDE_CODE_PROMPT_DIALECT = {
780
+ harness: "claude",
781
+ tools: {
782
+ delegationTool: "Task",
783
+ backgroundDelegationTool: "Task(run_in_background=true)",
784
+ backgroundStatusTool: "TaskOutput",
785
+ userQuestionTool: "AskUserQuestion",
786
+ progressTool: "TodoWrite",
787
+ hostStatusSurface: "TodoWrite",
788
+ roleReference: (role) => role === "orchestrator" ? "the main-thread orchestrator" : `Task(subagent_type: ${claudeCodeSubagentType(role)})`
789
+ },
790
+ capabilities: supportedCapabilityProfile(CLAUDE_CODE_PROMPT_CAPABILITIES),
791
+ dispatchLabel(method) {
792
+ switch (method) {
793
+ case "root-coordinator":
794
+ return "main-session coordinator";
795
+ case "task":
796
+ return "Task tool";
797
+ case "synchronous-task-only":
798
+ return "synchronous Task only";
799
+ }
800
+ },
801
+ renderRoleInvocation(role) {
802
+ return role === "orchestrator" ? "main-thread orchestrator" : claudeCodeSubagentType(role);
803
+ }
804
+ };
751
805
 
752
806
  // src/harness/core/sdd.ts
753
807
  var SDD_PHASES = [
@@ -954,7 +1008,7 @@ function createStepBudgetSection(steps) {
954
1008
  return { kind: "step-budget", steps };
955
1009
  }
956
1010
  function detectModelFamilyFromModel(model) {
957
- const id = getPrimaryModelId(model)?.toLowerCase();
1011
+ const id = getPrimaryModelId2(model)?.toLowerCase();
958
1012
  if (!id) {
959
1013
  return void 0;
960
1014
  }
@@ -1098,9 +1152,9 @@ Push back when context, risk, or assumptions are weak. Avoid verbosity.
1098
1152
  </epistemic-rigor>
1099
1153
 
1100
1154
  <session-bootstrap>
1101
- - At the start of a new root session, when thoth-mem tools are available, load \`thoth-mem-agents\` and \`requirements-interview\`, call \`mem_session_start\` with the current project and session identity, then save the real user prompt with \`mem_save_prompt\`.
1102
- - Save only the real user request with \`mem_save_prompt\`; never save generated sub-agent prompts, handoffs, summaries, or tool scaffolding as user intent.
1103
- - If thoth-mem tools or required session/project identity are unavailable, disclose that memory bootstrap could not run and continue without pretending memory was saved.
1155
+ - At the start of a new root session, when thoth-mem tools and session/project identity are available, load \`thoth-mem-agents\` and \`requirements-interview\`, then call \`mem_session(action="start")\` as step 0 before any other thoth-mem call.
1156
+ - Save only the real user request with \`mem_save(kind="prompt")\`; never save generated sub-agent prompts, handoffs, summaries, or tool scaffolding as user intent.
1157
+ - If thoth-mem tools or required session/project identity are unavailable, disclose that memory bootstrap could not run and continue without claiming memory was saved.
1104
1158
  </session-bootstrap>
1105
1159
 
1106
1160
  <routing>
@@ -1136,9 +1190,9 @@ Before dispatching {{role.designer}}, {{role.quick}}, or {{role.deep}} after dis
1136
1190
 
1137
1191
  Internal handoff fields: Goal, Decision, Evidence, Scope, Steps, Verification, Uncertainty, relevant files or symbols, suggested skills when applicable, constraints, non-goals, escalation conditions, and next focus.
1138
1192
 
1139
- When thoth-mem session-summary tooling and parent session/project identity are available, save or refresh that handoff body with root-owned \`mem_session_summary\` before dispatch. If the tooling or identity is unavailable, disclose that root-owned compaction could not be persisted and continue with explicit task instructions and local context; do not invent a fallback session or ask a sub-agent to create one.
1193
+ When thoth-mem summary persistence and parent session/project identity are available, save or refresh that handoff body with root-owned \`mem_session(action="summary")\` or \`mem_save(kind="session_summary")\` before dispatch. If tooling or identity is unavailable, disclose that root-owned compaction could not be persisted and continue with explicit task instructions and local context; do not invent a fallback session or ask a sub-agent to create one.
1140
1194
 
1141
- The delegated prompt carries task instructions plus handoff recovery instructions only: parent \`session_id\`, project, persistence mode, memory permissions, bounded 3-layer recall steps, non-goals, escalation conditions, and redaction requirements. It must not include the handoff body, raw transcripts, file dumps, secrets, credentials, irrelevant context, or generated sub-agent prompts as memory source material.
1195
+ The delegated prompt carries task instructions plus handoff recovery instructions only: parent \`session_id\`, project, persistence mode, memory permissions, the recall funnel \`mem_recall(mode="compact")\` -> \`mem_recall(mode="context")\` -> \`mem_get(...)\`, optional bounded \`mem_context(recall_query=...)\`/\`mem_project(...)\` guidance when permitted, non-goals, escalation conditions, and redaction requirements. It must not include the handoff body, raw transcripts, file dumps, secrets, credentials, irrelevant context, or generated sub-agent prompts as memory source material.
1142
1196
 
1143
1197
  Never mention internal handoff preparation to the user, ask the user to prepare it, or present handoff preparation as the recommended next step. Describe the actual work instead.
1144
1198
 
@@ -1199,12 +1253,15 @@ Post-execution: delegate sdd-verify, then sdd-archive when verification passes.
1199
1253
  <progress-memory>
1200
1254
  - Keep {{progressTool}} top-level and lean for multi-step work.
1201
1255
  - When SDD is active, update both {{progressTool}} and openspec/changes/{change-name}/tasks.md before dispatch and after results.
1202
- - Root-session memory is yours: search before repeated work; save durable decisions, discoveries, bugs, patterns, constraints, and session summaries.
1203
- - Durable \`mem_save\`: save durable decisions, bug root causes, discoveries, conventions, config changes, and preferences. Use stable topic keys; keep general observations outside \`sdd/*\`.
1204
- - Targeted 3-layer recall protocol: \`mem_search\` compact -> \`mem_timeline\` -> \`mem_get_observation\` only for records needed in full.
1256
+ - Root-session memory is yours: recall repeated work; save durable decisions, discoveries, bugs, patterns, constraints, summaries.
1257
+ - Use \`mem_save(kind="observation")\` for decisions, bugs, discoveries, conventions, preferences; stable topics; observations outside \`sdd/*\`.
1258
+ - Targeted recall funnel: \`mem_recall(mode="compact")\` -> \`mem_recall(mode="context")\` -> \`mem_get(...)\`; use \`mem_get(include_timeline=true)\` for time context.
1259
+ - Use HyDE/fused recall; set \`mem_recall\` \`limit\` from 1 to 20; narrow with \`topic_key\`, \`type\`, \`time_from\`/\`time_to\`, \`scope\`, \`project\`, \`session_id\`.
1260
+ - \`mem_get\`: \`kind="observation"|"prompt"\`, \`include_timeline=true\`, \`before\`/\`after\`, \`offset\`/\`max_length\`; supplement with bounded \`mem_context(recall_query=...)\` or \`mem_project(action="graph"|"topics"|"topic")\`.
1261
+ - Graph relations: HAS_TYPE, IN_PROJECT, HAS_TOPIC_KEY, HAS_WHAT, HAS_WHY, HAS_WHERE, HAS_LEARNED.
1205
1262
  - SDD memory artifacts use deterministic topic keys only in thoth-mem or hybrid persistence modes: \`sdd/{change}/{artifact}\`.
1206
- - Before ending the root session, call \`mem_session_summary\` with a concise Goal, Instructions, Discoveries, Accomplished, Next Steps, and Relevant Files summary. Do not claim memory was saved unless the tool call succeeded.
1207
- - After compaction, first preserve the compacted summary with \`mem_session_summary\`, then recover recent context and use the 3-layer recall protocol before continuing work.
1263
+ - Before ending the root session, call \`mem_session(action="summary")\` or root-owned \`mem_save(kind="session_summary")\` with a concise Goal, Instructions, Discoveries, Accomplished, Next Steps, and Relevant Files summary. Do not claim memory was saved unless the tool call succeeded.
1264
+ - After compaction, first preserve the compacted summary with \`mem_session(action="summary")\`, then call \`mem_context(recall_query=...)\` and use the recall funnel before continuing work.
1208
1265
  </progress-memory>
1209
1266
 
1210
1267
  <communication>
@@ -1355,7 +1412,7 @@ For non-SDD work: summary + files changed + verification results + edge cases co
1355
1412
  - Target: under 40 lines total.`
1356
1413
  });
1357
1414
  }
1358
- function getPrimaryModelId(model) {
1415
+ function getPrimaryModelId2(model) {
1359
1416
  if (Array.isArray(model)) {
1360
1417
  const first = model[0];
1361
1418
  return typeof first === "string" ? first : first?.id;
@@ -1376,32 +1433,30 @@ function renderSubagentRules(section, dialect) {
1376
1433
  ];
1377
1434
  if (section.memoryAccess === "readonly") {
1378
1435
  rules.push(
1379
- "- Use read-only thoth-mem only when dispatch gives parent session_id/project and handoff recovery instructions: `mem_search` -> `mem_timeline` -> `mem_get_observation`.",
1380
- "- The canonical recall path remains `mem_search` -> `mem_timeline` -> `mem_get_observation`; use bounded context tools only as supplemental context when explicitly allowed.",
1381
- "- If either parent session_id or project is missing, do NOT call thoth-mem; rely on explicit task instructions and local evidence.",
1382
- "- Recover the parent-session handoff summary through bounded 3-layer recall before treating memory as source material.",
1436
+ "- Use read-only thoth-mem only when dispatch gives parent session_id/project and handoff recovery instructions.",
1437
+ "- Parent-scoped reads: `mem_recall`, `mem_context`, `mem_get`, bounded `mem_project`; do not call `mem_save` or own any `mem_session(...)` lifecycle action.",
1438
+ "- If either parent session_id or project is missing, do NOT call thoth-mem; rely on task instructions and local evidence.",
1439
+ '- Recover the parent-session handoff summary through the recall funnel `mem_recall(mode="compact")` -> `mem_recall(mode="context")` -> `mem_get(...)` before using memory.',
1440
+ '- Use `mem_recall` `limit` from 1 to 20; use `mem_get` with `kind="observation"|"prompt"`, `include_timeline=true`, `before`/`after`, and `offset`/`max_length`.',
1383
1441
  "- Report when recalled context is missing, stale, contradictory, or insufficient.",
1384
- "- Use project-scoped read tools (`mem_context`, `mem_project_summary`, `mem_project_graph`, `mem_topic_keys`) only when explicitly allowed by the delegated task instructions and bounded to the parent session/project scope.",
1385
- "- Never call `mem_session_start`, `mem_session_summary`, or `mem_save_prompt`; those tools are orchestrator-owned.",
1386
- "- Never save generated subagent prompts as user intent.",
1387
- "- Never write memory; memory writes are orchestrator-owned."
1442
+ '- Supplemental `mem_context(recall_query=...)` and bounded `mem_project(action="graph"|"topics"|"topic")` do not replace the recall funnel and require explicit delegated permission. Graph relations: `HAS_TYPE`, `IN_PROJECT`, `HAS_TOPIC_KEY`, `HAS_WHAT`, `HAS_WHY`, `HAS_WHERE`, `HAS_LEARNED`.',
1443
+ "- Never save prompts, generated subagent prompts, session summaries, or durable memory."
1388
1444
  );
1389
1445
  }
1390
1446
  if (section.memoryAccess === "writable") {
1391
1447
  rules.push(
1392
- "- Use delegated thoth-mem tools only (mem_save, mem_search, mem_get_observation, mem_timeline, mem_context, mem_project_summary, mem_project_graph, mem_topic_keys, mem_suggest_topic_key).",
1393
- "- Never call `mem_session_start`, `mem_session_summary`, or `mem_save_prompt`; those tools are orchestrator-owned.",
1448
+ "- Use delegated thoth-mem tools only: `mem_save`, `mem_recall`, `mem_context`, `mem_get`, `mem_project`, `mem_session`.",
1394
1449
  "- Always use the parent session_id/project from dispatch for every thoth-mem call.",
1395
1450
  "- If either is missing, do NOT call thoth-mem.",
1396
1451
  "- Follow handoff recovery instructions from the delegated task before using persisted memory.",
1397
- "- For reads, use only `mem_search` -> `mem_timeline` -> `mem_get_observation` and recover the parent-session handoff summary before treating memory as source material.",
1398
- "- Keep 3-layer recall canonical; use `mem_context`, `mem_project_summary`, `mem_project_graph`, and `mem_topic_keys` only as bounded supplemental context when the dispatch explicitly permits project-scoped reads.",
1452
+ '- For reads, use the recall funnel `mem_recall(mode="compact")` -> `mem_recall(mode="context")` -> `mem_get(...)` and recover the parent-session handoff summary before treating memory as source material.',
1453
+ '- Use `mem_recall` `limit` from 1 to 20; use `mem_get` with `kind="observation"|"prompt"`, `include_timeline=true`, `before`/`after`, and `offset`/`max_length`.',
1454
+ '- Keep the recall funnel canonical; use `mem_context(recall_query=...)` and bounded `mem_project(action="graph"|"topics"|"topic")` only with explicit project-read permission. Graph relations: `HAS_TYPE`, `IN_PROJECT`, `HAS_TOPIC_KEY`, `HAS_WHAT`, `HAS_WHY`, `HAS_WHERE`, `HAS_LEARNED`.',
1399
1455
  "- Report when recalled context is missing, stale, contradictory, or insufficient.",
1400
- "- Use project-scoped read tools only when explicitly allowed by the delegated task instructions and bounded to the parent session/project scope.",
1401
- "- `mem_save` is allowed only for delegated durable implementation observations or assigned SDD artifacts/apply-progress under the parent session/project.",
1456
+ '- `mem_save(kind="observation")` is allowed only for delegated durable implementation observations or assigned deterministic SDD artifacts/apply-progress under the parent session/project.',
1457
+ '- Never own `mem_session(action="start"|"checkpoint"|"summary")`, save prompts, or save generated subagent prompts as user intent.',
1402
1458
  "- Protect the `sdd/*` namespace: deterministic SDD artifacts use `sdd/{change}/{artifact}`; general durable observations must stay outside `sdd/*`.",
1403
- "- Never save generated subagent prompts as user intent.",
1404
- "- You do not own durable memory of your own; `mem_save` writes under the orchestrator's session/project only."
1459
+ '- You do not own durable memory of your own; permitted `mem_save(kind="observation")` writes under the orchestrator\'s session/project only.'
1405
1460
  );
1406
1461
  }
1407
1462
  return rules.join("\n");
@@ -2125,8 +2180,12 @@ export {
2125
2180
  loadPluginConfig,
2126
2181
  loadAgentPrompt,
2127
2182
  getAgentOverride,
2183
+ getPrimaryModelId,
2128
2184
  OPENCODE_PROMPT_DIALECT,
2129
2185
  CODEX_PROMPT_DIALECT,
2186
+ CLAUDE_CODE_SUBAGENT_NAMESPACE,
2187
+ claudeCodeSubagentType,
2188
+ CLAUDE_CODE_PROMPT_DIALECT,
2130
2189
  createStepBudgetSection,
2131
2190
  createModelFamilySection,
2132
2191
  createOrchestratorPromptSections,