thoth-agents 0.3.11 → 0.4.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 (74) hide show
  1. package/README.md +182 -389
  2. package/dist/agents/prompt-dialects.d.ts +4 -1
  3. package/dist/agents/prompt-sections.d.ts +2 -1
  4. package/dist/{chunk-CB3EBA7H.js → chunk-5EBXGMOK.js} +1 -1
  5. package/dist/chunk-62L3ORXN.js +30 -0
  6. package/dist/{chunk-GIUU6FNE.js → chunk-Q6SDM4KP.js} +208 -106
  7. package/dist/chunk-SECDI3TL.js +312 -0
  8. package/dist/{chunk-ZEAAWBF2.js → chunk-WJ2YMM2E.js} +2877 -290
  9. package/dist/cli/codex-plugin-install.d.ts +16 -2
  10. package/dist/cli/index.js +188 -15
  11. package/dist/cli/install-completion.d.ts +13 -0
  12. package/dist/cli/install-ledger.d.ts +1 -1
  13. package/dist/cli/install.d.ts +11 -1
  14. package/dist/cli/operations/pi.d.ts +43 -0
  15. package/dist/cli/owned-skills.d.ts +17 -0
  16. package/dist/cli/pi-effort.d.ts +10 -0
  17. package/dist/cli/pi-install.d.ts +131 -0
  18. package/dist/cli/pi-migration.d.ts +12 -0
  19. package/dist/cli/pi-native-probe.d.ts +34 -0
  20. package/dist/cli/pi-package-receipt.d.ts +59 -0
  21. package/dist/cli/pi-paths.d.ts +20 -0
  22. package/dist/cli/pi-resources.d.ts +15 -0
  23. package/dist/cli/skills.d.ts +1 -1
  24. package/dist/cli/tui/index.js +12 -4
  25. package/dist/cli/tui/operations.d.ts +1 -0
  26. package/dist/cli/types.d.ts +4 -2
  27. package/dist/harness/adapters/pi.d.ts +8 -0
  28. package/dist/harness/core/agent-pack.d.ts +26 -6
  29. package/dist/harness/core/sdd.d.ts +27 -15
  30. package/dist/harness/pi-specialists.d.ts +6 -0
  31. package/dist/harness/types.d.ts +2 -2
  32. package/dist/harness/writers/codex-plugin-package.d.ts +1 -0
  33. package/dist/harness/writers/pi-agent.d.ts +16 -0
  34. package/dist/index.js +6 -4
  35. package/dist/pi.d.ts +11 -0
  36. package/dist/pi.js +46 -0
  37. package/package.json +17 -6
  38. package/pi/.thoth-agents-assets.json +12 -0
  39. package/pi/agents/thoth-deep.md +81 -0
  40. package/pi/agents/thoth-designer.md +81 -0
  41. package/pi/agents/thoth-explorer.md +81 -0
  42. package/pi/agents/thoth-librarian.md +83 -0
  43. package/pi/agents/thoth-oracle.md +83 -0
  44. package/pi/agents/thoth-quick.md +81 -0
  45. package/plugin/.claude-plugin/.thoth-agents-plugin-assets.json +2 -2
  46. package/plugin/.claude-plugin/plugin.json +1 -1
  47. package/plugin/.codex-plugin/plugin.json +1 -1
  48. package/plugin/agents/oracle.md +3 -3
  49. package/plugin/agents/orchestrator.md +35 -30
  50. package/plugin/skills/plan-reviewer/SKILL.md +54 -15
  51. package/plugin/skills/thoth-archive/SKILL.md +5 -0
  52. package/plugin/skills/thoth-constitution/SKILL.md +5 -0
  53. package/plugin/skills/thoth-constitution/templates/constitution.md +19 -2
  54. package/plugin/skills/thoth-init/SKILL.md +5 -0
  55. package/plugin/skills/thoth-sdd/SKILL.md +35 -10
  56. package/plugin/skills/thoth-sdd/references/phases/implement.md +13 -2
  57. package/plugin/skills/thoth-sdd/references/phases/tasks.md +23 -2
  58. package/plugin/skills/thoth-sdd/references/phases/verify.md +7 -5
  59. package/plugin/skills/thoth-sdd/scripts/validate.mjs +263 -30
  60. package/plugin/skills/thoth-sdd/templates/tasks.md +18 -2
  61. package/skills/README.md +2 -1
  62. package/skills/plan-reviewer/SKILL.md +54 -15
  63. package/skills/thoth-archive/SKILL.md +5 -0
  64. package/skills/thoth-constitution/SKILL.md +5 -0
  65. package/skills/thoth-constitution/templates/constitution.md +19 -2
  66. package/skills/thoth-init/SKILL.md +5 -0
  67. package/skills/thoth-sdd/SKILL.md +35 -10
  68. package/skills/thoth-sdd/references/phases/implement.md +13 -2
  69. package/skills/thoth-sdd/references/phases/tasks.md +23 -2
  70. package/skills/thoth-sdd/references/phases/verify.md +7 -5
  71. package/skills/thoth-sdd/scripts/validate.mjs +263 -30
  72. package/skills/thoth-sdd/templates/tasks.md +18 -2
  73. package/.agents/plugins/marketplace.json +0 -20
  74. package/.claude-plugin/marketplace.json +0 -21
@@ -15,8 +15,9 @@ export interface ToolNomenclature {
15
15
  delegationTool: string;
16
16
  backgroundDelegationTool?: string;
17
17
  backgroundStatusTool?: string;
18
+ backgroundWaitInstruction?: string;
18
19
  userQuestionTool: string;
19
- progressTool: string;
20
+ progressTool?: string;
20
21
  hostStatusSurface?: string;
21
22
  lifecycle: LifecycleNomenclature;
22
23
  roleReference(role: AgentPromptRole): string;
@@ -34,6 +35,7 @@ export interface HarnessPromptDialect {
34
35
  }
35
36
  export declare const CODEX_PROMPT_CAPABILITIES: HarnessCapabilities;
36
37
  export declare const CLAUDE_CODE_PROMPT_CAPABILITIES: HarnessCapabilities;
38
+ export declare const PI_PROMPT_CAPABILITIES: HarnessCapabilities;
37
39
  export declare const OPENCODE_PROMPT_DIALECT: HarnessPromptDialect;
38
40
  export declare const CODEX_PROMPT_DIALECT: HarnessPromptDialect;
39
41
  /**
@@ -44,5 +46,6 @@ export declare const CODEX_PROMPT_DIALECT: HarnessPromptDialect;
44
46
  export declare const CLAUDE_CODE_SUBAGENT_NAMESPACE = "thoth-agents";
45
47
  export declare function claudeCodeSubagentType(role: AgentPromptRole): string;
46
48
  export declare const CLAUDE_CODE_PROMPT_DIALECT: HarnessPromptDialect;
49
+ export declare const PI_PROMPT_DIALECT: HarnessPromptDialect;
47
50
  export declare function getPromptDialect(harness: HarnessId): HarnessPromptDialect;
48
51
  export declare function getPromptDialect(harness: string): HarnessPromptDialect;
@@ -8,6 +8,7 @@ export type WriteCapableAgentRole = 'designer' | 'quick' | 'deep';
8
8
  export interface QuestionProtocolSection {
9
9
  kind: 'question-protocol';
10
10
  toolConcept: 'userQuestion';
11
+ audience: 'root' | 'child';
11
12
  }
12
13
  export interface SubagentRulesSection {
13
14
  kind: 'subagent-rules';
@@ -39,7 +40,7 @@ export type RolePromptSection = PromptSection;
39
40
  export interface PromptSectionRenderer<TSection extends PromptSection> {
40
41
  render(section: TSection, dialect: HarnessPromptDialect): string;
41
42
  }
42
- export declare function createQuestionProtocolSection(): QuestionProtocolSection;
43
+ export declare function createQuestionProtocolSection(audience?: 'root' | 'child'): QuestionProtocolSection;
43
44
  export declare function createSubagentRulesSection(memoryAccess?: SemanticMemoryAccess): SubagentRulesSection;
44
45
  export declare function createReasoningDisciplineSection(): ReasoningDisciplineSection;
45
46
  export declare function createResponseBudgetSection(): ResponseBudgetSection;
@@ -16,7 +16,7 @@ import {
16
16
  loadAgentPrompt,
17
17
  renderAgentRoutingDescription,
18
18
  renderRolePrompt
19
- } from "./chunk-GIUU6FNE.js";
19
+ } from "./chunk-Q6SDM4KP.js";
20
20
 
21
21
  // src/agents/deep.ts
22
22
  var DEEP_PROMPT = renderRolePrompt(
@@ -0,0 +1,30 @@
1
+ // src/mcp/context7.ts
2
+ var CONTEXT7_MCP_URL = "https://mcp.context7.com/mcp";
3
+ var context7 = {
4
+ type: "remote",
5
+ url: CONTEXT7_MCP_URL,
6
+ headers: process.env.CONTEXT7_API_KEY ? { CONTEXT7_API_KEY: process.env.CONTEXT7_API_KEY } : void 0,
7
+ oauth: false
8
+ };
9
+
10
+ // src/mcp/exa.ts
11
+ var exa = {
12
+ type: "local",
13
+ command: ["npx", "-y", "exa-mcp-server"]
14
+ };
15
+
16
+ // src/mcp/grep-app.ts
17
+ var GREP_APP_MCP_URL = "https://mcp.grep.app";
18
+ var grep_app = {
19
+ type: "remote",
20
+ url: GREP_APP_MCP_URL,
21
+ oauth: false
22
+ };
23
+
24
+ export {
25
+ CONTEXT7_MCP_URL,
26
+ context7,
27
+ exa,
28
+ GREP_APP_MCP_URL,
29
+ grep_app
30
+ };
@@ -1,22 +1,3 @@
1
- // src/config/loader.ts
2
- import * as fs from "fs";
3
- import * as path from "path";
4
-
5
- // src/cli/config-io.ts
6
- import {
7
- copyFileSync,
8
- existsSync as existsSync3,
9
- readFileSync as readFileSync2,
10
- renameSync,
11
- statSync,
12
- writeFileSync
13
- } from "fs";
14
-
15
- // src/cli/package-version.ts
16
- import { readFileSync } from "fs";
17
- import { dirname as dirname2, join as join2 } from "path";
18
- import { fileURLToPath } from "url";
19
-
20
1
  // src/cli/package-root.ts
21
2
  import { existsSync } from "fs";
22
3
  import { dirname, join, parse } from "path";
@@ -38,7 +19,24 @@ function findPackageRoot(startDir) {
38
19
  }
39
20
  }
40
21
 
22
+ // src/config/loader.ts
23
+ import * as fs from "fs";
24
+ import * as path from "path";
25
+
26
+ // src/cli/config-io.ts
27
+ import {
28
+ copyFileSync,
29
+ existsSync as existsSync3,
30
+ readFileSync as readFileSync2,
31
+ renameSync,
32
+ statSync,
33
+ writeFileSync
34
+ } from "fs";
35
+
41
36
  // src/cli/package-version.ts
37
+ import { readFileSync } from "fs";
38
+ import { dirname as dirname2, join as join2 } from "path";
39
+ import { fileURLToPath } from "url";
42
40
  var EXPECTED_PACKAGE_NAME = "thoth-agents";
43
41
  var SEMVER_PATTERN = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;
44
42
  function isValidPackageVersion(version) {
@@ -743,24 +741,27 @@ var AGENT_ROLES = [
743
741
  dispatch: "root-coordinator",
744
742
  canMutateWorkspace: true,
745
743
  scope: "requirements, SDD coordination, routing, bounded implementation, decisions, and synthesis",
746
- responsibility: "Keep requirements, decisions, sequential SDD coordination, and final synthesis in the root thread; evaluate implementation ownership independently in every route and implement directly or delegate according to explicit user direction and demonstrated net gain.",
744
+ responsibility: "Keep requirements, decisions, sequential SDD coordination, and final synthesis in the root thread; evaluate implementation ownership independently in every route, implement directly or delegate by demonstrated net gain, and run focused verification for trivial deterministic Direct work.",
747
745
  useWhen: [
748
746
  "Coordinate requirements, governed artifacts, routing, and synthesis.",
749
747
  "Implement an accepted mutable surface in any route when accumulated context and continuity outweigh delegation overhead."
750
748
  ],
751
- doNotUseWhen: ["Not for independent plan review or final verification."],
749
+ doNotUseWhen: [
750
+ "Not for independent plan review or Oracle-required final verification."
751
+ ],
752
752
  escalateWhen: [
753
753
  "Delegate implementation when specialization, context isolation, or independent bounded work creates a demonstrated net gain; then select designer, quick, or deep by task shape."
754
754
  ],
755
755
  toolGovernance: [
756
- "may inspect and edit the accepted bounded implementation surface in every route, but every verification is delegated to oracle",
756
+ "may inspect and edit the accepted bounded implementation surface in every route and may verify trivial deterministic Direct work without self-approval",
757
757
  "loads the matching thoth-sdd phase contract on demand instead of carrying every phase protocol in its prompt",
758
758
  "owns governed coordination writes under openspec/ and uses append-only tasks.md updates during convergence",
759
759
  "delegates independent or specialist work only when it produces a net gain",
760
760
  "keeps requirements, decisions, and final synthesis in the root thread"
761
761
  ],
762
762
  verification: [
763
- "delegates selected plan-review and every verify phase to oracle; plan review stays optional and final verification stays mandatory",
763
+ "runs focused checks for trivial deterministic Direct work while final verification remains mandatory",
764
+ "delegates selected plan review plus Accelerated, Full, and material-risk Direct final verification to a fresh oracle",
764
765
  "consolidates summarized evidence returned by child agents"
765
766
  ]
766
767
  },
@@ -804,9 +805,9 @@ var AGENT_ROLES = [
804
805
  dispatch: "synchronous-task-only",
805
806
  canMutateWorkspace: false,
806
807
  scope: "diagnosis, architecture, optional plan review, and independent verification",
807
- responsibility: "Independently review plans when the user requests it and perform every implementation verification, exposing correctness risks and judging whether results satisfy their contracts.",
808
+ responsibility: "Independently review plans when the user requests it and provide independent judgment for artifact-backed or material-risk final verification, exposing correctness risks and judging whether results satisfy their contracts.",
808
809
  useWhen: [
809
- "Selected plan review, diagnosis, or final verification needs independent judgment."
810
+ "Selected plan review, persistent diagnosis, material architecture or security risk, contradictory evidence, high failure cost, or artifact-backed final verification needs independent judgment."
810
811
  ],
811
812
  doNotUseWhen: [
812
813
  "Not for implementation, mutation, persistence, or self-review."
@@ -909,6 +910,34 @@ var ORCHESTRATION_POLICY = {
909
910
  "cheaper model price without end-to-end evidence"
910
911
  ]
911
912
  },
913
+ taskShaping: {
914
+ steps: [
915
+ "bound-work",
916
+ "map-dependencies",
917
+ "assign-ownership",
918
+ "select-specialists",
919
+ "mark-ready-and-blocked",
920
+ "dispatch-ready-wave",
921
+ "wait-for-terminal-evidence",
922
+ "reconcile-and-verify"
923
+ ],
924
+ nativeAuthority: true,
925
+ boundedWidth: true,
926
+ decisions: {
927
+ dependency: "block a lane until every concrete upstream output exists",
928
+ ownershipConflict: "serialize overlapping mutable surfaces or assign one writer",
929
+ readyWave: "dispatch all independent conflict-free ready lanes before waiting",
930
+ terminalEvidence: "silence, timeout, and malformed status remain nonterminal",
931
+ degradation: "report an unavailable native primitive and use a truthful sequential fallback"
932
+ }
933
+ },
934
+ specialistDirectory: AGENT_ROLES.filter(
935
+ (role) => role.name !== "orchestrator"
936
+ ).map((role) => ({
937
+ role: role.name,
938
+ selectWhen: role.useWhen.join(" "),
939
+ rejectWhen: role.doNotUseWhen.join(" ")
940
+ })),
912
941
  rules: [
913
942
  "Direct, Accelerated, Full, and no-artifact execution govern artifacts and gates, not implementation ownership.",
914
943
  "Root or a specialist may implement in every route; delegate only when specialization, context isolation, independent bounded work, or safe parallelism creates a demonstrated quality, latency, or total-cost net gain.",
@@ -919,6 +948,7 @@ var ORCHESTRATION_POLICY = {
919
948
  "A fresh subagent instance is the default when the objective, SDD phase, mutable surface, or independent judgment changes.",
920
949
  "Continue an existing subagent only to steer, complete, or clarify the same bounded assignment; completed agents are not a reusable role pool.",
921
950
  "Every Oracle plan review, verification round, and approval or PASS judgment uses a fresh Oracle instance; reuse is limited to clarifying current findings.",
951
+ "Final verification is mandatory: root owns trivial deterministic Direct checks; a fresh Oracle owns Accelerated, Full, and material-risk Direct judgment.",
922
952
  "Wait and status operations collect only the active nonterminal assignment and do not authorize later reuse.",
923
953
  "Child agents return distilled evidence instead of raw logs or file dumps."
924
954
  ]
@@ -991,6 +1021,16 @@ function getAgentPackContract() {
991
1021
  ...AGENT_PACK_CONTRACT.orchestrationPolicy.implementationOwnership.insufficientSignals
992
1022
  ]
993
1023
  },
1024
+ taskShaping: {
1025
+ ...AGENT_PACK_CONTRACT.orchestrationPolicy.taskShaping,
1026
+ steps: [...AGENT_PACK_CONTRACT.orchestrationPolicy.taskShaping.steps],
1027
+ decisions: {
1028
+ ...AGENT_PACK_CONTRACT.orchestrationPolicy.taskShaping.decisions
1029
+ }
1030
+ },
1031
+ specialistDirectory: AGENT_PACK_CONTRACT.orchestrationPolicy.specialistDirectory.map(
1032
+ (decision) => ({ ...decision })
1033
+ ),
994
1034
  rules: [...AGENT_PACK_CONTRACT.orchestrationPolicy.rules]
995
1035
  },
996
1036
  returnContract: [...AGENT_PACK_CONTRACT.returnContract],
@@ -998,6 +1038,22 @@ function getAgentPackContract() {
998
1038
  };
999
1039
  }
1000
1040
 
1041
+ // src/harness/pi-specialists.ts
1042
+ var PI_SPECIALIST_ROLES = [
1043
+ "explorer",
1044
+ "librarian",
1045
+ "oracle",
1046
+ "designer",
1047
+ "quick",
1048
+ "deep"
1049
+ ];
1050
+ function isPiSpecialistRole(role) {
1051
+ return PI_SPECIALIST_ROLES.some((candidate) => candidate === role);
1052
+ }
1053
+ function piSpecialistName(role) {
1054
+ return `thoth-${role}`;
1055
+ }
1056
+
1001
1057
  // src/agents/prompt-dialects.ts
1002
1058
  var OPENCODE_CAPABILITIES = {
1003
1059
  agentDefinitions: "supported",
@@ -1032,6 +1088,17 @@ var CLAUDE_CODE_PROMPT_CAPABILITIES = {
1032
1088
  parentContextInjection: "supported",
1033
1089
  memoryGovernanceEnforcement: "instruction-only"
1034
1090
  };
1091
+ var PI_PROMPT_CAPABILITIES = {
1092
+ agentDefinitions: "supported",
1093
+ delegatedExecution: "supported",
1094
+ parallelDelegation: "supported",
1095
+ runtimeHooks: "conditional",
1096
+ mcpConfiguration: "adapter-backed",
1097
+ skillPackaging: "supported",
1098
+ rolePermissions: "supported",
1099
+ parentContextInjection: "supported",
1100
+ memoryGovernanceEnforcement: "instruction-only"
1101
+ };
1035
1102
  function supportedCapabilityProfile(capabilities) {
1036
1103
  return {
1037
1104
  capabilities,
@@ -1055,6 +1122,11 @@ function claudeCodeCapabilityDisclosure(capability) {
1055
1122
  }
1056
1123
  return `${capability}: ${status} in Claude Code; installed provider guidance owns provider-dependent enforcement and mechanics.`;
1057
1124
  }
1125
+ function piCapabilityDisclosure(capability) {
1126
+ const status = PI_PROMPT_CAPABILITIES[capability];
1127
+ if (status === "supported") return void 0;
1128
+ return `${capability}: ${status} in Pi; Pi extensions run with the invoking user's system permissions, and child tool allowlists are role controls rather than an OS, filesystem, process, network, or credential sandbox.`;
1129
+ }
1058
1130
  var OPENCODE_PROMPT_DIALECT = {
1059
1131
  harness: "opencode",
1060
1132
  tools: {
@@ -1173,6 +1245,45 @@ var CLAUDE_CODE_PROMPT_DIALECT = {
1173
1245
  return role === "orchestrator" ? "main-thread orchestrator" : claudeCodeSubagentType(role);
1174
1246
  }
1175
1247
  };
1248
+ var PI_PROMPT_DIALECT = {
1249
+ harness: "pi",
1250
+ tools: {
1251
+ delegationTool: "subagent_run",
1252
+ backgroundDelegationTool: "subagent_run",
1253
+ backgroundStatusTool: "subagent_status / subagent_result / subagent_list_tasks",
1254
+ backgroundWaitInstruction: "For background tasks, respond and wait for the automatic completion notification. Do not sleep, poll status, or fetch results merely to wait; use `subagent_status`, `subagent_result`, or `subagent_list_tasks` only for an explicitly needed intermediate status or stored result.",
1255
+ userQuestionTool: "ask_user_question",
1256
+ progressTool: "todo",
1257
+ hostStatusSurface: "subagent_list_tasks",
1258
+ lifecycle: {
1259
+ freshDelegation: "`subagent_run` with one exact canonical `agent` and no deprecated batch input",
1260
+ sameAssignmentContinuation: "`subagent_status`, `subagent_result`, or `subagent_list_tasks`; use `subagent_send_message` only when the active SDK confirms live steering, and `subagent_continue` only when continuation is explicitly enabled",
1261
+ independentContext: "a new objective, phase, mutable surface, or independent judgment starts a fresh `subagent_run` task",
1262
+ statusAction: "inspect status, collect terminal results, or cancel",
1263
+ terminalState: "a terminal completion notification or terminal subagent_result outcome",
1264
+ nonterminalState: "running, queued, timed-out, malformed, or merely message-accepted state",
1265
+ sameSessionProbe: "subagent_status for the current parent-owned task ID",
1266
+ enforcement: "runtime-supported"
1267
+ },
1268
+ roleReference: (role) => role === "orchestrator" ? "the ambient Pi root" : `subagent_run(agent: "${piSpecialistName(role)}")`
1269
+ },
1270
+ capabilities: {
1271
+ capabilities: PI_PROMPT_CAPABILITIES,
1272
+ renderCapabilityDisclosure: piCapabilityDisclosure
1273
+ },
1274
+ dispatchLabel(method) {
1275
+ switch (method) {
1276
+ case "root-coordinator":
1277
+ return "ambient Pi root session coordinator";
1278
+ case "task":
1279
+ case "synchronous-task-only":
1280
+ return "single-agent subagent_run";
1281
+ }
1282
+ },
1283
+ renderRoleInvocation(role) {
1284
+ return role === "orchestrator" ? "ambient Pi root" : `subagent_run(agent: "${piSpecialistName(role)}")`;
1285
+ }
1286
+ };
1176
1287
 
1177
1288
  // src/harness/core/sdd.ts
1178
1289
  var SDD_PHASES = [
@@ -1260,8 +1371,8 @@ var SDD_PHASES = [
1260
1371
  producesArtifact: true,
1261
1372
  defaultAgentRole: "oracle",
1262
1373
  eligibleAgentRoles: ["oracle"],
1263
- reason: "Offer independent blocker-only plan review when the user selects it after planning passes ready.",
1264
- condition: "Activate only after ready when the user chooses Review plan with Oracle (Recommended)."
1374
+ reason: "Offer independent blocker-only plan review after explicit or bounded recommended-default selection once planning passes ready.",
1375
+ condition: "Activate after ready when review is selected explicitly or by the bounded recommended default after three answerless attempts."
1265
1376
  },
1266
1377
  {
1267
1378
  id: "implement",
@@ -1283,9 +1394,9 @@ var SDD_PHASES = [
1283
1394
  activation: "required",
1284
1395
  prerequisites: ["implement"],
1285
1396
  producesArtifact: true,
1286
- defaultAgentRole: "oracle",
1287
- eligibleAgentRoles: ["oracle"],
1288
- reason: "Independently judge the result against requirements, contracts, and focused checks."
1397
+ defaultAgentRole: "adaptive-verification",
1398
+ eligibleAgentRoles: ["orchestrator", "oracle"],
1399
+ reason: "Keep verification mandatory while selecting root for trivial deterministic Direct checks and a fresh Oracle for material-risk Direct or artifact-backed judgment."
1289
1400
  },
1290
1401
  {
1291
1402
  id: "converge",
@@ -1347,25 +1458,25 @@ var SDD_WORKFLOW_CONTRACT = {
1347
1458
  validationGates: [...policy.validationGates]
1348
1459
  })),
1349
1460
  routingRules: [
1350
- "The root recommends direct, accelerated, or full from risk evidence, but the user selects the route; an explicitly requested route already counts as selection.",
1461
+ "The root summarizes context and recommends direct, accelerated, or full from risk evidence; an explicit answer wins, while the third answerless route question selects the displayed recommendation, and an explicitly requested route already counts as selection.",
1351
1462
  "Direct work is the default for clear, bounded, low-risk changes; documentation and mechanical work may remain direct across multiple files.",
1352
1463
  "Accelerated SDD is used for multi-surface behavior, architecture, partial clarity, moderate risk, or broad non-behavioral coordination.",
1353
- "Accelerated planning fast-forwards specify, plan, and tasks without pauses between those artifacts, then offers the user optional oracle plan review after ready.",
1464
+ "Accelerated planning fast-forwards specify, plan, and tasks without pauses between those artifacts, then offers optional oracle plan review after ready; an explicit answer wins and the third answerless review question selects Review plan with Oracle (Recommended).",
1354
1465
  "Full SDD is used for unresolved scope, cross-cutting behavior or architecture, high contract risk, or high failure cost.",
1355
1466
  "Use architectural-grilling before specification only when the user explicitly requests it or material product or architecture decisions remain human-owned and unresolved; never require it merely because the route is Full.",
1356
- "Route selection and the post-ready plan-review choice are explicit user decisions; other input is requested only when a material unresolved decision changes the result."
1467
+ "Route selection and the post-ready plan-review choice resolve through an explicit answer or their bounded recommended fallback; other input is requested only when a material unresolved decision changes the result."
1357
1468
  ],
1358
1469
  artifactRules: [
1359
1470
  "Spec Kit artifact semantics are preserved inside the governed openspec store.",
1360
1471
  "Accelerated and full routes require spec.md, plan.md, tasks.md, verify-report.md, and archive-report.md.",
1361
1472
  "Research, data model, contracts, quickstart, requirements checklist, and plan-review.md are optional and created only when useful or selected.",
1362
- "The adaptive root writes coordination artifacts after loading the matching bundled phase contract; Accelerated and Full implementation selects designer, quick, or deep, while Direct permits one isolated low-risk root micro-action.",
1473
+ "The adaptive root writes coordination artifacts after loading the matching bundled phase contract; every route selects root, designer, quick, or deep from task shape, explicit direction, and demonstrated net gain.",
1363
1474
  "After oracle PASS, archive transactionally synchronizes only explicitly declared durable ADDED, MODIFIED, REMOVED, and RENAMED requirement deltas into openspec/specs; INTERNAL requirements and undeclared prose never update permanent specifications.",
1364
1475
  "Archive stages and backs up writes so handled failures roll back within the active process; forced process or operating-system termination is not crash-atomic."
1365
1476
  ],
1366
1477
  verificationRules: [
1367
- "Every route delegates focused verification to read-only oracle; the implementation writer never verifies its own work.",
1368
- "Accelerated and Full offer read-only oracle plan review after ready; it runs only when the user selects it and never replaces final verification.",
1478
+ "Every route requires final verification; trivial deterministic Direct checks are root-owned, while materially risky Direct and every Accelerated or Full final verification use a fresh read-only oracle, and no implementation writer self-approves.",
1479
+ "Accelerated and Full offer read-only oracle plan review after ready; it runs when selected explicitly or by the bounded recommended fallback and never replaces final verification.",
1369
1480
  "Accelerated and full verification persists verify-report.md with a pass or fail verdict and requirement compliance matrix.",
1370
1481
  "An artifact-backed fail verdict routes through append-only convergence, implementation, and verification again; direct work returns straight to implementation.",
1371
1482
  "A pass verdict is required before accelerated or full work can archive."
@@ -1448,8 +1559,8 @@ function getRequiredSddPhaseOrder(route) {
1448
1559
  }
1449
1560
 
1450
1561
  // src/agents/prompt-sections.ts
1451
- function createQuestionProtocolSection() {
1452
- return { kind: "question-protocol", toolConcept: "userQuestion" };
1562
+ function createQuestionProtocolSection(audience = "root") {
1563
+ return { kind: "question-protocol", toolConcept: "userQuestion", audience };
1453
1564
  }
1454
1565
  function createSubagentRulesSection(memoryAccess = "dispatch-scoped") {
1455
1566
  return {
@@ -1508,12 +1619,20 @@ function renderImplementationOwnershipPolicy(policy) {
1508
1619
  - Only after deciding delegation creates net gain: use ${roleTemplate("designer")} for UI/UX, ${roleTemplate("quick")} for known narrow low-risk work, and ${roleTemplate("deep")} for coupled or high-risk work.
1509
1620
  </implementation-ownership>`;
1510
1621
  }
1511
- function renderRoleDirectory() {
1512
- return [
1513
- `- ${roleTemplate("explorer")}: uncertain local discovery; read-only.`,
1514
- `- ${roleTemplate("librarian")}: external evidence; read-only.`,
1515
- `- ${roleTemplate("oracle")}: review/verify; read-only, never implementer.`
1516
- ].join("\n");
1622
+ function renderRoleDirectory(directory) {
1623
+ return directory.map(
1624
+ ({ role, selectWhen, rejectWhen }) => `- ${roleTemplate(role)}: Select when ${selectWhen} Reject when ${rejectWhen}`
1625
+ ).join("\n");
1626
+ }
1627
+ function renderTaskShapingPolicy(policy) {
1628
+ return `<task-shaping>
1629
+ ${policy.steps.join(" -> ")}
1630
+ - ${policy.decisions.dependency}; bind each lane to output, mutable ownership, specialist fit, and verification input.
1631
+ - ${policy.decisions.ownershipConflict}; avoid duplicate evidence work.
1632
+ - ${policy.decisions.readyWave} through \`{{backgroundDelegationTool}}\` within native capacity{{backgroundWaitInstruction}}
1633
+ - Fan in only from {{lifecycleTerminalState}}; {{lifecycleNonterminalState}}, ${policy.decisions.terminalEvidence}.
1634
+ - Reconcile against intent, dependencies, ownership, conflicts, and verification before synthesis; native execution remains authoritative; ${policy.decisions.degradation}.
1635
+ </task-shaping>`;
1517
1636
  }
1518
1637
  function createOrchestratorPromptSections() {
1519
1638
  const workflow = getSddWorkflowContract();
@@ -1526,13 +1645,13 @@ You are the adaptive root for thoth-agents. Keep requirements, decisions, owners
1526
1645
  </role>
1527
1646
 
1528
1647
  <operating-model>
1529
- - Handle bounded implementation directly in any route when continuity outweighs delegation overhead; never self-verify.
1648
+ - Handle bounded implementation directly in any route when continuity outweighs delegation overhead; never self-approve.
1530
1649
  - The maximum delegation depth is ${policy.maxDelegationDepth}; children never delegate.
1531
1650
  - Keep one writer per mutable surface; parallelize only non-overlapping work.
1532
1651
  - Keep prompts bounded; request distilled evidence, not raw logs or full files.
1533
1652
  - Preserve unrelated changes; report changed files, evidence, risks, and capability gaps.
1534
1653
  - Use \`{{userQuestionTool}}\` only when a material unresolved choice changes the result. Continue all safe non-blocked work first.
1535
- - Use \`{{progressTool}}\` only when the work genuinely has multiple dependent steps.
1654
+ - {{progressInstruction}}
1536
1655
  </operating-model>
1537
1656
 
1538
1657
  <delegation-lifecycle>
@@ -1544,51 +1663,46 @@ You are the adaptive root for thoth-agents. Keep requirements, decisions, owners
1544
1663
  </delegation-lifecycle>
1545
1664
 
1546
1665
  <routing>
1547
- ${renderRoleDirectory()}
1666
+ ${renderRoleDirectory(policy.specialistDirectory)}
1548
1667
  </routing>
1549
1668
 
1550
1669
  ${renderImplementationOwnershipPolicy(policy.implementationOwnership)}
1551
1670
 
1671
+ ${renderTaskShapingPolicy(policy.taskShaping)}
1672
+
1552
1673
  <sdd-routing>
1553
- - An explicitly requested route wins: no duplicate route-selection prompt. Otherwise assess and recommend one route, ask with \`{{userQuestionTool}}\`, and wait for the user to select Direct, Accelerated, or Full. The recommendation is not the decision. The user's selected route wins; explain risk without overriding it. A generic SDD request sets Accelerated as the minimum unless Full risk applies.
1554
- - Direct: clear, bounded, low-risk work. ${renderSddRoute("direct")}.
1555
- - Documentation or mechanical work may remain Direct across multiple files when it is clear and low risk.
1556
- - Accelerated SDD: multi-surface behavior, architecture, partial clarity, or moderate risk. ${renderSddRoute("accelerated")}.
1557
- - For Accelerated, run specify -> plan -> tasks in one uninterrupted root pass. Do not pause between those planning artifacts; ask only for a material unresolved decision.
1558
- - Its thoth-sdd validator gates are ${accelerated.validationGates.join(" -> ")}; optional artifacts are off by default.
1559
- - Full SDD: uncertain scope, cross-cutting behavior or architecture, high contract risk, or high failure cost. ${renderSddRoute("full")}.
1560
- - Full gates are ${full.validationGates.join(" -> ")}; checklist remains conditional.
1561
- - After \`ready\` on Accelerated/Full, ask with \`{{userQuestionTool}}\`: \`Review plan with Oracle (Recommended)\` or \`Proceed without review\`. Skipping plan review means no pre-implementation Oracle review. If selected, load \`plan-reviewer\`, delegate read-only review, and accept only \`[OKAY]\` or \`[REJECT]\` with at most 3 actionable blockers. After \`[OKAY]\`, summarize and ask whether to implement or stop. Plan review never replaces mandatory final Oracle verify.
1674
+ - An explicitly requested route wins: no duplicate route-selection prompt. Otherwise assess and recommend one route; summarize the relevant request context, assessed scope, clarity, risk, and why the recommendation fits before asking with \`{{userQuestionTool}}\` for Direct, Accelerated, or Full. On an answerless result, make at most three total attempts. After the third answerless result, treat the recommended route as selected. Any explicit user answer wins. A generic SDD request sets Accelerated as the minimum unless Full risk applies.
1675
+ - Direct is clear, bounded, low-risk: ${renderSddRoute("direct")}. Documentation or mechanical work may remain Direct across multiple files when clear and low risk.
1676
+ - Accelerated SDD covers multi-surface behavior, architecture, partial clarity, or moderate risk: ${renderSddRoute("accelerated")}; run specify -> plan -> tasks in one uninterrupted root pass. Do not pause between those planning artifacts except for a material unresolved decision. Gates: ${accelerated.validationGates.join(" -> ")}.
1677
+ - Full SDD covers uncertainty, cross-cutting behavior/architecture, high contract risk, or high failure cost: ${renderSddRoute("full")}. Gates: ${full.validationGates.join(" -> ")}; checklist conditional.
1678
+ - After \`ready\` on Accelerated/Full, ask with \`{{userQuestionTool}}\`: \`Review plan with Oracle (Recommended)\` or \`Proceed without review\`. Any explicit \`Proceed without review\` answer wins. If the review question returns answerless, retry to that limit. After the third answerless result, treat \`Review plan with Oracle (Recommended)\` as selected. For review, load \`plan-reviewer\`; accept only \`[OKAY]\`/\`[REJECT]\` with at most 3 actionable blockers. On \`[REJECT]\`, repair same-intent planning artifacts, revalidate affected gates, and use fresh Oracle rounds until \`[OKAY]\` or a human-owned blocker. On \`[OKAY]\`, summarize the approved scope, approach, ownership, verification, and material risks before asking with \`{{userQuestionTool}}\`: \`Implement (Recommended)\` or \`Stop\`. Reuse the answerless limit. After the third answerless result, treat implementation as selected. Any explicit \`Stop\` answer wins; \`[OKAY]\` alone does not authorize implementation. Plan review never replaces mandatory final Oracle verify.
1679
+ - Bounded fallbacks are only for route, plan-review, and implementation questions; never for secrets, destructive/security-sensitive actions, or material human-owned decisions.
1562
1680
  - Happy path: verify -> archive. Artifact-backed failure loop: verify fail -> converge -> implement -> verify. Direct failure loop: verify fail -> implement -> verify.
1563
- - Conditional phases: clarify for material ambiguity; checklist for requirement risk; plan-review by user choice; converge for verification defects.
1564
- - When implementation discoveries refine the same intent, update the canonical artifact and revalidate only affected downstream artifacts. Split a new change when the intent changes.
1565
- - Load the bundled \`thoth-sdd\` skill only after selecting Accelerated or Full, then read only the reference for the current phase.
1566
- - Root owns specify, clarify, plan, checklist, tasks, converge, and archive coordination; these phases are not delegated merely to change prompts.
1567
- - Record owner, net-gain rationale, surface, requirements, and checks before implement or dispatch.
1568
- - Delegate each user-selected plan review and every verify phase to ${roleTemplate("oracle")}. The implementation writer must never review itself.
1681
+ - Same-intent discoveries update the artifact and revalidate only affected downstream artifacts; new intent starts a change.
1682
+ - After Accelerated/Full selection, load the bundled \`thoth-sdd\` skill and read only the reference for the current phase. Run thoth-sdd validator. Root owns specify, clarify, plan, checklist, tasks, converge, and archive; do not delegate just to change prompts. Record owner, rationale, surface, requirements, and checks before implementation.
1683
+ - Final verification is mandatory. Use a fresh ${roleTemplate("oracle")} for Accelerated/Full and materially risky Direct work. Root may run focused verification only for trivial deterministic Direct work; no implementation writer may approve its own work.
1569
1684
  </sdd-routing>
1570
1685
 
1571
1686
  <external-skills>
1572
1687
  - Use bundled \`thoth-constitution\` for constitution lifecycle and \`thoth-archive\` for verified artifact-backed closeout.
1573
1688
  - Use the installed mandatory \`tdd\` skill for behavior changes and \`simplify\` after implementation without changing behavior.
1574
- - During an SDD, never invoke the thoth-agents CLI, \`npx skills add\`, or a network fetch. A missing local contract means incomplete installation.
1689
+ - During SDD, never invoke the thoth-agents CLI, \`npx skills add\`, or network; a missing contract means incomplete installation.
1575
1690
  - Use progressive-context-router only for repository instruction or context-router work.
1576
1691
  - Use architectural-grilling before specification only when the user explicitly asks to be grilled or material human-owned product or architecture decisions remain unresolved.
1577
- - Do not invoke it merely because the route is Full. While grilling, ask one material question per turn and await explicit closure.
1578
- - Feed accepted decisions forward; spec.md and plan.md remain canonical instead of creating a duplicate blueprint artifact by default.
1692
+ - Do not invoke it merely because the route is Full; while grilling, ask one material question per turn.
1693
+ - Feed decisions forward; spec.md and plan.md remain canonical, without a duplicate blueprint by default.
1579
1694
  </external-skills>
1580
1695
 
1581
1696
  <memory>
1582
- - Load the installed \`thoth-mem\` skill for resume or prior work; never invent its protocol.
1583
- - Preserve a durable decision, root cause, convention, or discovery only when reusable. Root owns the stable root session ID, project, lifecycle, real-user intent, and authorization.
1584
- - Follow the skill at verified compaction or a meaningful semantic boundary; children receive only bounded MEMORY and never own root lifecycle.
1585
- - \`openspec/\` remains canonical; do not mirror SDD phase artifacts. A memory failure does not block unrelated work.
1697
+ - For resume/prior work, load the installed \`thoth-mem\` skill; never invent its protocol.
1698
+ - Preserve only a reusable decision, root cause, convention, or discovery. Root owns the stable root session ID, project, lifecycle, real-user intent, and authorization.
1699
+ - Follow it at verified compaction or a meaningful semantic boundary; children get bounded MEMORY, never root lifecycle.
1700
+ - \`openspec/\` remains canonical; do not mirror SDD artifacts. A memory failure does not block unrelated work.
1586
1701
  </memory>
1587
1702
 
1588
1703
  <artifacts>
1589
- - In ${workflow.artifactRoot}, Accelerated and Full require spec.md, plan.md, tasks.md, verify-report.md, and archive-report.md.
1590
- - Root owns openspec/ gates and task state, moves [~] -> [x] after evidence, and keeps one product writer.
1591
- - ${roleTemplate("oracle")} returns read-only findings; root persists verification and archives declared durable deltas after PASS.
1704
+ - Accelerated/Full require ${workflow.artifactRoot}{spec.md,plan.md,tasks.md,verify-report.md,archive-report.md}.
1705
+ - Root owns gates/task state, moves [~] -> [x] on evidence, and keeps one product writer. ${roleTemplate("oracle")} returns read-only findings; root persists verification and archives declared deltas after PASS.
1592
1706
  </artifacts>
1593
1707
 
1594
1708
  <delegation>
@@ -1667,7 +1781,7 @@ ${role.responsibility}
1667
1781
  - ${ROLE_SPECIFIC_RULES[roleName].join("\n- ")}
1668
1782
  </rules>`),
1669
1783
  createSubagentRulesSection(),
1670
- createQuestionProtocolSection(),
1784
+ createQuestionProtocolSection("child"),
1671
1785
  roleText(`<return-contract>
1672
1786
  Return a compact result with these fields:
1673
1787
  - conclusion
@@ -1700,14 +1814,19 @@ function createRolePromptSections(role) {
1700
1814
  );
1701
1815
  }
1702
1816
  }
1703
- function renderQuestionProtocol(_section, dialect) {
1817
+ function renderQuestionProtocol(section, dialect) {
1818
+ if (section.audience === "child" && dialect.harness === "pi") {
1819
+ return `<questions>
1820
+ Do not open a user dialog. Continue safe non-blocked work, then escalate the unresolved question to the root through openQuestions with the material choices and a recommended default.
1821
+ </questions>`;
1822
+ }
1704
1823
  return `<questions>
1705
1824
  Use \`${dialect.tools.userQuestionTool}\` only for a blocking material choice, destructive or security-sensitive action, or missing secret. Do safe non-blocked work first and ask one targeted question with a recommended default.
1706
1825
  </questions>`;
1707
1826
  }
1708
1827
  function renderSubagentRules(section, dialect) {
1709
1828
  const rules = [
1710
- `- Do not delegate further or call \`${dialect.tools.progressTool}\`; root owns progress.`,
1829
+ dialect.tools.progressTool ? `- Do not delegate further or call \`${dialect.tools.progressTool}\`; root owns progress.` : "- Do not delegate further; root owns progress.",
1711
1830
  "- Use terminating checks; avoid watch processes and indefinite waits.",
1712
1831
  "- Never discard or overwrite unrelated working-tree changes."
1713
1832
  ];
@@ -1765,13 +1884,19 @@ function renderModelFamily(section) {
1765
1884
  </model-profile>`;
1766
1885
  }
1767
1886
  function renderRoleText(section, dialect) {
1768
- return section.template.replaceAll("{{delegationTool}}", dialect.tools.delegationTool).replaceAll(
1887
+ return section.template.replaceAll(
1888
+ "{{backgroundWaitInstruction}}",
1889
+ dialect.tools.backgroundWaitInstruction ? `. ${dialect.tools.backgroundWaitInstruction}` : ", then use `{{backgroundStatusTool}}`."
1890
+ ).replaceAll("{{delegationTool}}", dialect.tools.delegationTool).replaceAll(
1769
1891
  "{{backgroundDelegationTool}}",
1770
1892
  dialect.tools.backgroundDelegationTool ?? dialect.tools.delegationTool
1771
1893
  ).replaceAll(
1772
1894
  "{{backgroundStatusTool}}",
1773
1895
  dialect.tools.backgroundStatusTool ?? dialect.tools.hostStatusSurface ?? ""
1774
- ).replaceAll("{{userQuestionTool}}", dialect.tools.userQuestionTool).replaceAll("{{progressTool}}", dialect.tools.progressTool).replaceAll(
1896
+ ).replaceAll("{{userQuestionTool}}", dialect.tools.userQuestionTool).replaceAll(
1897
+ "{{progressInstruction}}",
1898
+ dialect.tools.progressTool ? `Use \`${dialect.tools.progressTool}\` only when the work genuinely has multiple dependent steps.` : "Keep written progress notes when the work genuinely has multiple dependent steps; no native planning tool is configured."
1899
+ ).replaceAll(
1775
1900
  "{{lifecycleStatusAction}}",
1776
1901
  dialect.tools.lifecycle.statusAction
1777
1902
  ).replaceAll(
@@ -1880,29 +2005,6 @@ function composeAgentPrompt({
1880
2005
  );
1881
2006
  }
1882
2007
 
1883
- // src/mcp/context7.ts
1884
- var CONTEXT7_MCP_URL = "https://mcp.context7.com/mcp";
1885
- var context7 = {
1886
- type: "remote",
1887
- url: CONTEXT7_MCP_URL,
1888
- headers: process.env.CONTEXT7_API_KEY ? { CONTEXT7_API_KEY: process.env.CONTEXT7_API_KEY } : void 0,
1889
- oauth: false
1890
- };
1891
-
1892
- // src/mcp/exa.ts
1893
- var exa = {
1894
- type: "local",
1895
- command: ["npx", "-y", "exa-mcp-server"]
1896
- };
1897
-
1898
- // src/mcp/grep-app.ts
1899
- var GREP_APP_MCP_URL = "https://mcp.grep.app";
1900
- var grep_app = {
1901
- type: "remote",
1902
- url: GREP_APP_MCP_URL,
1903
- oauth: false
1904
- };
1905
-
1906
2008
  export {
1907
2009
  SUBAGENT_NAMES,
1908
2010
  ALL_AGENT_NAMES,
@@ -1934,11 +2036,16 @@ export {
1934
2036
  getAgentRole,
1935
2037
  renderAgentRoutingDescription,
1936
2038
  getAgentPackContract,
2039
+ PI_SPECIALIST_ROLES,
2040
+ isPiSpecialistRole,
2041
+ piSpecialistName,
2042
+ PI_PROMPT_CAPABILITIES,
1937
2043
  OPENCODE_PROMPT_DIALECT,
1938
2044
  CODEX_PROMPT_DIALECT,
1939
2045
  CLAUDE_CODE_SUBAGENT_NAMESPACE,
1940
2046
  claudeCodeSubagentType,
1941
2047
  CLAUDE_CODE_PROMPT_DIALECT,
2048
+ PI_PROMPT_DIALECT,
1942
2049
  createStepBudgetSection,
1943
2050
  createModelFamilySection,
1944
2051
  createOrchestratorPromptSections,
@@ -1950,10 +2057,5 @@ export {
1950
2057
  appendPromptSections,
1951
2058
  getStepBudgetPromptSection,
1952
2059
  getModelFamilyPromptSection,
1953
- composeAgentPrompt,
1954
- CONTEXT7_MCP_URL,
1955
- context7,
1956
- exa,
1957
- GREP_APP_MCP_URL,
1958
- grep_app
2060
+ composeAgentPrompt
1959
2061
  };