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.
- package/CHANGELOG.md +1151 -0
- package/LICENSE +22 -0
- package/README.md +1220 -0
- package/agents/context-builder.md +45 -0
- package/agents/delegate.md +12 -0
- package/agents/oracle.md +73 -0
- package/agents/planner.md +55 -0
- package/agents/reviewer.md +91 -0
- package/agents/scout.md +50 -0
- package/agents/worker.md +67 -0
- package/package.json +87 -0
- package/prompts/gather-context-and-clarify.md +13 -0
- package/prompts/parallel-cleanup.md +59 -0
- package/prompts/parallel-context-build.md +55 -0
- package/prompts/parallel-handoff-plan.md +61 -0
- package/prompts/parallel-review.md +54 -0
- package/prompts/review-loop.md +41 -0
- package/skills/pi-cohort/SKILL.md +818 -0
- package/src/agents/agent-management.ts +685 -0
- package/src/agents/agent-scope.ts +6 -0
- package/src/agents/agent-selection.ts +23 -0
- package/src/agents/agent-serializer.ts +83 -0
- package/src/agents/agents.ts +1141 -0
- package/src/agents/chain-serializer.ts +251 -0
- package/src/agents/frontmatter.ts +29 -0
- package/src/agents/identity.ts +30 -0
- package/src/agents/skills.ts +632 -0
- package/src/extension/config.ts +16 -0
- package/src/extension/control-notices.ts +92 -0
- package/src/extension/doctor.ts +236 -0
- package/src/extension/fanout-child.ts +170 -0
- package/src/extension/grand-total.ts +109 -0
- package/src/extension/index.ts +630 -0
- package/src/extension/schemas.ts +306 -0
- package/src/intercom/intercom-bridge.ts +379 -0
- package/src/intercom/result-intercom.ts +377 -0
- package/src/runs/background/async-execution.ts +796 -0
- package/src/runs/background/async-job-tracker.ts +320 -0
- package/src/runs/background/async-resume.ts +345 -0
- package/src/runs/background/async-status.ts +335 -0
- package/src/runs/background/completion-dedupe.ts +63 -0
- package/src/runs/background/notify.ts +108 -0
- package/src/runs/background/parallel-groups.ts +45 -0
- package/src/runs/background/result-watcher.ts +307 -0
- package/src/runs/background/run-id-resolver.ts +83 -0
- package/src/runs/background/run-status.ts +272 -0
- package/src/runs/background/stale-run-reconciler.ts +336 -0
- package/src/runs/background/subagent-runner.ts +2326 -0
- package/src/runs/background/top-level-async.ts +13 -0
- package/src/runs/foreground/chain-clarify.ts +1333 -0
- package/src/runs/foreground/chain-execution.ts +1187 -0
- package/src/runs/foreground/execution.ts +1028 -0
- package/src/runs/foreground/subagent-executor.ts +2580 -0
- package/src/runs/shared/acceptance.ts +605 -0
- package/src/runs/shared/chain-outputs.ts +101 -0
- package/src/runs/shared/completion-guard.ts +143 -0
- package/src/runs/shared/dynamic-fanout.ts +293 -0
- package/src/runs/shared/long-running-guard.ts +175 -0
- package/src/runs/shared/model-fallback.ts +103 -0
- package/src/runs/shared/nested-events.ts +822 -0
- package/src/runs/shared/nested-path.ts +52 -0
- package/src/runs/shared/nested-render.ts +115 -0
- package/src/runs/shared/parallel-utils.ts +136 -0
- package/src/runs/shared/pi-args.ts +221 -0
- package/src/runs/shared/pi-spawn.ts +115 -0
- package/src/runs/shared/run-history.ts +60 -0
- package/src/runs/shared/single-output.ts +164 -0
- package/src/runs/shared/structured-output.ts +77 -0
- package/src/runs/shared/subagent-control.ts +287 -0
- package/src/runs/shared/subagent-prompt-runtime.ts +220 -0
- package/src/runs/shared/workflow-graph.ts +206 -0
- package/src/runs/shared/worktree.ts +577 -0
- package/src/shared/artifacts.ts +98 -0
- package/src/shared/atomic-json.ts +16 -0
- package/src/shared/file-coalescer.ts +40 -0
- package/src/shared/fork-context.ts +76 -0
- package/src/shared/formatters.ts +133 -0
- package/src/shared/jsonl-writer.ts +81 -0
- package/src/shared/model-info.ts +78 -0
- package/src/shared/post-exit-stdio-guard.ts +85 -0
- package/src/shared/session-identity.ts +10 -0
- package/src/shared/session-tokens.ts +46 -0
- package/src/shared/settings.ts +447 -0
- package/src/shared/status-format.ts +59 -0
- package/src/shared/types.ts +1072 -0
- package/src/shared/utils.ts +451 -0
- package/src/slash/prompt-template-bridge.ts +397 -0
- package/src/slash/slash-bridge.ts +174 -0
- package/src/slash/slash-commands.ts +567 -0
- package/src/slash/slash-live-state.ts +292 -0
- package/src/tui/render-helpers.ts +80 -0
- package/src/tui/render.ts +1476 -0
|
@@ -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
|
+
}
|