pi-cohort 2.0.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 (92) hide show
  1. package/CHANGELOG.md +1151 -0
  2. package/LICENSE +22 -0
  3. package/README.md +1220 -0
  4. package/agents/context-builder.md +45 -0
  5. package/agents/delegate.md +12 -0
  6. package/agents/oracle.md +73 -0
  7. package/agents/planner.md +55 -0
  8. package/agents/reviewer.md +91 -0
  9. package/agents/scout.md +50 -0
  10. package/agents/worker.md +67 -0
  11. package/package.json +87 -0
  12. package/prompts/gather-context-and-clarify.md +13 -0
  13. package/prompts/parallel-cleanup.md +59 -0
  14. package/prompts/parallel-context-build.md +55 -0
  15. package/prompts/parallel-handoff-plan.md +61 -0
  16. package/prompts/parallel-review.md +54 -0
  17. package/prompts/review-loop.md +41 -0
  18. package/skills/pi-cohort/SKILL.md +818 -0
  19. package/src/agents/agent-management.ts +685 -0
  20. package/src/agents/agent-scope.ts +6 -0
  21. package/src/agents/agent-selection.ts +23 -0
  22. package/src/agents/agent-serializer.ts +83 -0
  23. package/src/agents/agents.ts +1141 -0
  24. package/src/agents/chain-serializer.ts +251 -0
  25. package/src/agents/frontmatter.ts +29 -0
  26. package/src/agents/identity.ts +30 -0
  27. package/src/agents/skills.ts +632 -0
  28. package/src/extension/config.ts +16 -0
  29. package/src/extension/control-notices.ts +92 -0
  30. package/src/extension/doctor.ts +236 -0
  31. package/src/extension/fanout-child.ts +170 -0
  32. package/src/extension/grand-total.ts +109 -0
  33. package/src/extension/index.ts +630 -0
  34. package/src/extension/schemas.ts +306 -0
  35. package/src/intercom/intercom-bridge.ts +379 -0
  36. package/src/intercom/result-intercom.ts +377 -0
  37. package/src/runs/background/async-execution.ts +796 -0
  38. package/src/runs/background/async-job-tracker.ts +320 -0
  39. package/src/runs/background/async-resume.ts +345 -0
  40. package/src/runs/background/async-status.ts +335 -0
  41. package/src/runs/background/completion-dedupe.ts +63 -0
  42. package/src/runs/background/notify.ts +108 -0
  43. package/src/runs/background/parallel-groups.ts +45 -0
  44. package/src/runs/background/result-watcher.ts +307 -0
  45. package/src/runs/background/run-id-resolver.ts +83 -0
  46. package/src/runs/background/run-status.ts +272 -0
  47. package/src/runs/background/stale-run-reconciler.ts +336 -0
  48. package/src/runs/background/subagent-runner.ts +2326 -0
  49. package/src/runs/background/top-level-async.ts +13 -0
  50. package/src/runs/foreground/chain-clarify.ts +1333 -0
  51. package/src/runs/foreground/chain-execution.ts +1187 -0
  52. package/src/runs/foreground/execution.ts +1028 -0
  53. package/src/runs/foreground/subagent-executor.ts +2580 -0
  54. package/src/runs/shared/acceptance.ts +605 -0
  55. package/src/runs/shared/chain-outputs.ts +101 -0
  56. package/src/runs/shared/completion-guard.ts +143 -0
  57. package/src/runs/shared/dynamic-fanout.ts +293 -0
  58. package/src/runs/shared/long-running-guard.ts +175 -0
  59. package/src/runs/shared/model-fallback.ts +103 -0
  60. package/src/runs/shared/nested-events.ts +822 -0
  61. package/src/runs/shared/nested-path.ts +52 -0
  62. package/src/runs/shared/nested-render.ts +115 -0
  63. package/src/runs/shared/parallel-utils.ts +136 -0
  64. package/src/runs/shared/pi-args.ts +221 -0
  65. package/src/runs/shared/pi-spawn.ts +115 -0
  66. package/src/runs/shared/run-history.ts +60 -0
  67. package/src/runs/shared/single-output.ts +164 -0
  68. package/src/runs/shared/structured-output.ts +77 -0
  69. package/src/runs/shared/subagent-control.ts +287 -0
  70. package/src/runs/shared/subagent-prompt-runtime.ts +220 -0
  71. package/src/runs/shared/workflow-graph.ts +206 -0
  72. package/src/runs/shared/worktree.ts +577 -0
  73. package/src/shared/artifacts.ts +98 -0
  74. package/src/shared/atomic-json.ts +16 -0
  75. package/src/shared/file-coalescer.ts +40 -0
  76. package/src/shared/fork-context.ts +76 -0
  77. package/src/shared/formatters.ts +133 -0
  78. package/src/shared/jsonl-writer.ts +81 -0
  79. package/src/shared/model-info.ts +78 -0
  80. package/src/shared/post-exit-stdio-guard.ts +85 -0
  81. package/src/shared/session-identity.ts +10 -0
  82. package/src/shared/session-tokens.ts +46 -0
  83. package/src/shared/settings.ts +447 -0
  84. package/src/shared/status-format.ts +59 -0
  85. package/src/shared/types.ts +1072 -0
  86. package/src/shared/utils.ts +451 -0
  87. package/src/slash/prompt-template-bridge.ts +397 -0
  88. package/src/slash/slash-bridge.ts +174 -0
  89. package/src/slash/slash-commands.ts +567 -0
  90. package/src/slash/slash-live-state.ts +292 -0
  91. package/src/tui/render-helpers.ts +80 -0
  92. package/src/tui/render.ts +1476 -0
@@ -0,0 +1,6 @@
1
+ import type { AgentScope } from "./agents.ts";
2
+
3
+ export function resolveExecutionAgentScope(scope: unknown): AgentScope {
4
+ if (scope === "user" || scope === "project" || scope === "both") return scope;
5
+ return "both";
6
+ }
@@ -0,0 +1,23 @@
1
+ import type { AgentScope, AgentConfig } from "./agents.ts";
2
+
3
+ export function mergeAgentsForScope(
4
+ scope: AgentScope,
5
+ userAgents: AgentConfig[],
6
+ projectAgents: AgentConfig[],
7
+ builtinAgents: AgentConfig[] = [],
8
+ ): AgentConfig[] {
9
+ const agentMap = new Map<string, AgentConfig>();
10
+
11
+ for (const agent of builtinAgents) agentMap.set(agent.name, agent);
12
+
13
+ if (scope === "both") {
14
+ for (const agent of userAgents) agentMap.set(agent.name, agent);
15
+ for (const agent of projectAgents) agentMap.set(agent.name, agent);
16
+ } else if (scope === "user") {
17
+ for (const agent of userAgents) agentMap.set(agent.name, agent);
18
+ } else {
19
+ for (const agent of projectAgents) agentMap.set(agent.name, agent);
20
+ }
21
+
22
+ return Array.from(agentMap.values());
23
+ }
@@ -0,0 +1,83 @@
1
+ import type { AgentConfig } from "./agents.ts";
2
+ import { frontmatterNameForConfig } from "./identity.ts";
3
+
4
+ export const KNOWN_FIELDS = new Set([
5
+ "name",
6
+ "package",
7
+ "description",
8
+ "tools",
9
+ "model",
10
+ "fallbackModels",
11
+ "thinking",
12
+ "systemPromptMode",
13
+ "inheritProjectContext",
14
+ "inheritSkills",
15
+ "defaultContext",
16
+ "skill",
17
+ "skills",
18
+ "extensions",
19
+ "output",
20
+ "defaultReads",
21
+ "defaultProgress",
22
+ "interactive",
23
+ "maxSubagentDepth",
24
+ "completionGuard",
25
+ ]);
26
+
27
+ function joinComma(values: string[] | undefined): string | undefined {
28
+ if (!values || values.length === 0) return undefined;
29
+ return values.join(", ");
30
+ }
31
+
32
+ export function serializeAgent(config: AgentConfig): string {
33
+ const lines: string[] = [];
34
+ lines.push("---");
35
+ lines.push(`name: ${frontmatterNameForConfig(config)}`);
36
+ if (config.packageName) lines.push(`package: ${config.packageName}`);
37
+ lines.push(`description: ${config.description}`);
38
+
39
+ const toolsValue = joinComma(config.tools ?? []);
40
+ if (toolsValue) lines.push(`tools: ${toolsValue}`);
41
+
42
+ if (config.model) lines.push(`model: ${config.model}`);
43
+ const fallbackModelsValue = joinComma(config.fallbackModels);
44
+ if (fallbackModelsValue) lines.push(`fallbackModels: ${fallbackModelsValue}`);
45
+ if (config.thinking && config.thinking !== "off") lines.push(`thinking: ${config.thinking}`);
46
+ lines.push(`systemPromptMode: ${config.systemPromptMode}`);
47
+ lines.push(`inheritProjectContext: ${config.inheritProjectContext ? "true" : "false"}`);
48
+ lines.push(`inheritSkills: ${config.inheritSkills ? "true" : "false"}`);
49
+ if (config.defaultContext) lines.push(`defaultContext: ${config.defaultContext}`);
50
+
51
+ const skillsValue = joinComma(config.skills);
52
+ if (skillsValue) lines.push(`skills: ${skillsValue}`);
53
+
54
+ if (config.extensions !== undefined) {
55
+ const extensionsValue = joinComma(config.extensions);
56
+ lines.push(`extensions: ${extensionsValue ?? ""}`);
57
+ }
58
+
59
+ if (config.output) lines.push(`output: ${config.output}`);
60
+
61
+ const readsValue = joinComma(config.defaultReads);
62
+ if (readsValue) lines.push(`defaultReads: ${readsValue}`);
63
+
64
+ if (config.defaultProgress) lines.push("defaultProgress: true");
65
+ if (config.interactive) lines.push("interactive: true");
66
+ const maxSubagentDepth = config.maxSubagentDepth;
67
+ if (typeof maxSubagentDepth === "number" && Number.isInteger(maxSubagentDepth) && maxSubagentDepth >= 0) {
68
+ lines.push(`maxSubagentDepth: ${maxSubagentDepth}`);
69
+ }
70
+ if (config.completionGuard === false) lines.push("completionGuard: false");
71
+
72
+ if (config.extraFields) {
73
+ for (const [key, value] of Object.entries(config.extraFields)) {
74
+ if (KNOWN_FIELDS.has(key)) continue;
75
+ lines.push(`${key}: ${value}`);
76
+ }
77
+ }
78
+
79
+ lines.push("---");
80
+
81
+ const body = config.systemPrompt ?? "";
82
+ return `${lines.join("\n")}\n\n${body}\n`;
83
+ }