@pi-agents/orchid 0.1.0-beta.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 +41 -0
- package/LICENSE +21 -0
- package/README.md +246 -0
- package/agents/AGENTS-MANIFEST.md +42 -0
- package/agents/brain.md +42 -0
- package/agents/context-builder.md +46 -0
- package/agents/delegate.md +12 -0
- package/agents/dev-1.md +42 -0
- package/agents/oracle.md +73 -0
- package/agents/planner.md +55 -0
- package/agents/researcher.md +52 -0
- package/agents/reviewer.md +79 -0
- package/agents/scout.md +50 -0
- package/agents/tester.md +45 -0
- package/agents/worker.md +55 -0
- package/extensions/ralph.ts +1 -0
- package/extensions/reviewer-extension.ts +125 -0
- package/extensions/task-orchestrator.ts +28 -0
- package/package.json +63 -0
- package/prompts/gather-context-and-clarify.md +13 -0
- package/prompts/parallel-cleanup.md +59 -0
- package/prompts/parallel-context-build.md +53 -0
- package/prompts/parallel-handoff-plan.md +59 -0
- package/prompts/parallel-research.md +50 -0
- package/prompts/parallel-review.md +54 -0
- package/prompts/review-loop.md +41 -0
- package/skills/orchid/SKILL.md +214 -0
- package/skills/orchid/orchid-cleanup/SKILL.md +122 -0
- package/skills/orchid/orchid-converge/SKILL.md +124 -0
- package/skills/orchid/orchid-decompose/SKILL.md +201 -0
- package/skills/orchid/orchid-doctor/SKILL.md +162 -0
- package/skills/orchid/orchid-investigate/SKILL.md +102 -0
- package/skills/orchid/orchid-launch/SKILL.md +147 -0
- package/skills/ralph/SKILL.md +73 -0
- package/skills/subagents/pi-subagents/SKILL.md +813 -0
- package/src/index.ts +7 -0
- package/src/orchestrator/abort.ts +534 -0
- package/src/orchestrator/agent-bridge-extension.ts +1020 -0
- package/src/orchestrator/agent-host.ts +954 -0
- package/src/orchestrator/cleanup.ts +776 -0
- package/src/orchestrator/config-loader.ts +1412 -0
- package/src/orchestrator/config-schema.ts +690 -0
- package/src/orchestrator/config.ts +81 -0
- package/src/orchestrator/context-window.ts +66 -0
- package/src/orchestrator/diagnostic-reports.ts +475 -0
- package/src/orchestrator/diagnostics.ts +394 -0
- package/src/orchestrator/discovery.ts +1833 -0
- package/src/orchestrator/engine-worker.ts +415 -0
- package/src/orchestrator/engine.ts +5940 -0
- package/src/orchestrator/execution.ts +3104 -0
- package/src/orchestrator/extension.ts +5934 -0
- package/src/orchestrator/formatting.ts +785 -0
- package/src/orchestrator/git.ts +88 -0
- package/src/orchestrator/index.ts +28 -0
- package/src/orchestrator/lane-runner.ts +1787 -0
- package/src/orchestrator/mailbox.ts +780 -0
- package/src/orchestrator/merge.ts +3414 -0
- package/src/orchestrator/messages.ts +1062 -0
- package/src/orchestrator/migrations.ts +278 -0
- package/src/orchestrator/naming.ts +117 -0
- package/src/orchestrator/path-resolver.ts +275 -0
- package/src/orchestrator/persistence.ts +2625 -0
- package/src/orchestrator/process-registry.ts +452 -0
- package/src/orchestrator/quality-gate.ts +1085 -0
- package/src/orchestrator/resume.ts +3488 -0
- package/src/orchestrator/sessions.ts +57 -0
- package/src/orchestrator/settings-loader.ts +136 -0
- package/src/orchestrator/settings-tui.ts +2208 -0
- package/src/orchestrator/sidecar-telemetry.ts +267 -0
- package/src/orchestrator/supervisor.ts +4548 -0
- package/src/orchestrator/task-executor-core.ts +675 -0
- package/src/orchestrator/tmux-compat.ts +37 -0
- package/src/orchestrator/tool-allowlist-constants.ts +37 -0
- package/src/orchestrator/types.ts +4465 -0
- package/src/orchestrator/verification.ts +547 -0
- package/src/orchestrator/waves.ts +1564 -0
- package/src/orchestrator/workspace.ts +707 -0
- package/src/orchestrator/worktree.ts +2725 -0
- package/src/ralph/index.ts +825 -0
- package/src/subagents/agents/agent-management.ts +648 -0
- package/src/subagents/agents/agent-scope.ts +6 -0
- package/src/subagents/agents/agent-selection.ts +23 -0
- package/src/subagents/agents/agent-serializer.ts +86 -0
- package/src/subagents/agents/agents.ts +832 -0
- package/src/subagents/agents/chain-serializer.ts +137 -0
- package/src/subagents/agents/frontmatter.ts +29 -0
- package/src/subagents/agents/identity.ts +30 -0
- package/src/subagents/agents/skills.ts +632 -0
- package/src/subagents/extension/config.ts +16 -0
- package/src/subagents/extension/control-notices.ts +92 -0
- package/src/subagents/extension/doctor.ts +199 -0
- package/src/subagents/extension/fanout-child.ts +170 -0
- package/src/subagents/extension/index.ts +573 -0
- package/src/subagents/extension/schemas.ts +168 -0
- package/src/subagents/intercom/intercom-bridge.ts +379 -0
- package/src/subagents/intercom/result-intercom.ts +377 -0
- package/src/subagents/runs/background/async-execution.ts +712 -0
- package/src/subagents/runs/background/async-job-tracker.ts +310 -0
- package/src/subagents/runs/background/async-resume.ts +345 -0
- package/src/subagents/runs/background/async-status.ts +325 -0
- package/src/subagents/runs/background/completion-dedupe.ts +63 -0
- package/src/subagents/runs/background/notify.ts +108 -0
- package/src/subagents/runs/background/parallel-groups.ts +45 -0
- package/src/subagents/runs/background/result-watcher.ts +307 -0
- package/src/subagents/runs/background/run-id-resolver.ts +83 -0
- package/src/subagents/runs/background/run-status.ts +269 -0
- package/src/subagents/runs/background/stale-run-reconciler.ts +336 -0
- package/src/subagents/runs/background/subagent-runner.ts +1808 -0
- package/src/subagents/runs/background/top-level-async.ts +13 -0
- package/src/subagents/runs/foreground/chain-clarify.ts +1333 -0
- package/src/subagents/runs/foreground/chain-execution.ts +938 -0
- package/src/subagents/runs/foreground/execution.ts +918 -0
- package/src/subagents/runs/foreground/subagent-executor.ts +2527 -0
- package/src/subagents/runs/shared/completion-guard.ts +147 -0
- package/src/subagents/runs/shared/long-running-guard.ts +175 -0
- package/src/subagents/runs/shared/mcp-direct-tool-allowlist.ts +365 -0
- package/src/subagents/runs/shared/model-fallback.ts +103 -0
- package/src/subagents/runs/shared/nested-events.ts +819 -0
- package/src/subagents/runs/shared/nested-path.ts +52 -0
- package/src/subagents/runs/shared/nested-render.ts +115 -0
- package/src/subagents/runs/shared/parallel-utils.ts +109 -0
- package/src/subagents/runs/shared/pi-args.ts +220 -0
- package/src/subagents/runs/shared/pi-spawn.ts +115 -0
- package/src/subagents/runs/shared/run-history.ts +60 -0
- package/src/subagents/runs/shared/single-output.ts +164 -0
- package/src/subagents/runs/shared/subagent-control.ts +226 -0
- package/src/subagents/runs/shared/subagent-prompt-runtime.ts +170 -0
- package/src/subagents/runs/shared/worktree.ts +577 -0
- package/src/subagents/shared/artifacts.ts +98 -0
- package/src/subagents/shared/atomic-json.ts +16 -0
- package/src/subagents/shared/file-coalescer.ts +40 -0
- package/src/subagents/shared/fork-context.ts +76 -0
- package/src/subagents/shared/formatters.ts +133 -0
- package/src/subagents/shared/jsonl-writer.ts +81 -0
- package/src/subagents/shared/model-info.ts +78 -0
- package/src/subagents/shared/post-exit-stdio-guard.ts +85 -0
- package/src/subagents/shared/session-identity.ts +10 -0
- package/src/subagents/shared/session-tokens.ts +44 -0
- package/src/subagents/shared/settings.ts +397 -0
- package/src/subagents/shared/status-format.ts +49 -0
- package/src/subagents/shared/types.ts +822 -0
- package/src/subagents/shared/utils.ts +450 -0
- package/src/subagents/slash/prompt-template-bridge.ts +397 -0
- package/src/subagents/slash/slash-bridge.ts +174 -0
- package/src/subagents/slash/slash-commands.ts +528 -0
- package/src/subagents/slash/slash-live-state.ts +292 -0
- package/src/subagents/tui/render-helpers.ts +80 -0
- package/src/subagents/tui/render.ts +1358 -0
- package/templates/agents/local/supervisor.md +33 -0
- package/templates/agents/local/task-merger.md +27 -0
- package/templates/agents/local/task-reviewer.md +30 -0
- package/templates/agents/local/task-worker.md +34 -0
- package/templates/agents/supervisor-routing.md +92 -0
- package/templates/agents/supervisor.md +229 -0
- package/templates/agents/task-merger.md +214 -0
- package/templates/agents/task-reviewer.md +260 -0
- package/templates/agents/task-worker-segment.md +44 -0
- package/templates/agents/task-worker.md +557 -0
- package/templates/tasks/CONTEXT.md +30 -0
- package/templates/tasks/EXAMPLE-001-hello-world/PROMPT.md +98 -0
- package/templates/tasks/EXAMPLE-001-hello-world/STATUS.md +73 -0
- package/templates/tasks/EXAMPLE-002-parallel-smoke/PROMPT.md +97 -0
- package/templates/tasks/EXAMPLE-002-parallel-smoke/STATUS.md +73 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { ChainConfig, ChainStepConfig } from "./agents.ts";
|
|
2
|
+
import { buildRuntimeName, frontmatterNameForConfig, parsePackageName } from "./identity.ts";
|
|
3
|
+
import { parseFrontmatter } from "./frontmatter.ts";
|
|
4
|
+
|
|
5
|
+
function parseStepBody(agent: string, sectionBody: string): ChainStepConfig {
|
|
6
|
+
const lines = sectionBody.split("\n");
|
|
7
|
+
const blankIndex = lines.findIndex((line) => line.trim() === "");
|
|
8
|
+
const configLines = blankIndex === -1 ? lines : lines.slice(0, blankIndex);
|
|
9
|
+
const task = (blankIndex === -1 ? "" : lines.slice(blankIndex + 1).join("\n")).trim();
|
|
10
|
+
|
|
11
|
+
const step: ChainStepConfig = { agent, task };
|
|
12
|
+
for (const line of configLines) {
|
|
13
|
+
const match = line.match(/^([\w-]+):\s*(.*)$/);
|
|
14
|
+
if (!match) continue;
|
|
15
|
+
const key = match[1].trim().toLowerCase();
|
|
16
|
+
const rawValue = match[2].trim();
|
|
17
|
+
|
|
18
|
+
if (key === "output") {
|
|
19
|
+
if (rawValue === "false") step.output = false;
|
|
20
|
+
else if (rawValue) step.output = rawValue;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (key === "outputmode") {
|
|
24
|
+
if (rawValue === "inline" || rawValue === "file-only") step.outputMode = rawValue;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (key === "reads") {
|
|
28
|
+
if (rawValue === "false") {
|
|
29
|
+
step.reads = false;
|
|
30
|
+
} else {
|
|
31
|
+
const reads = rawValue
|
|
32
|
+
.split(",")
|
|
33
|
+
.map((v) => v.trim())
|
|
34
|
+
.filter(Boolean);
|
|
35
|
+
step.reads = reads.length > 0 ? reads : false;
|
|
36
|
+
}
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (key === "model") {
|
|
40
|
+
if (rawValue) step.model = rawValue;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (key === "skills") {
|
|
44
|
+
if (rawValue === "false") {
|
|
45
|
+
step.skills = false;
|
|
46
|
+
} else {
|
|
47
|
+
const skills = rawValue
|
|
48
|
+
.split(",")
|
|
49
|
+
.map((v) => v.trim())
|
|
50
|
+
.filter(Boolean);
|
|
51
|
+
step.skills = skills.length > 0 ? skills : false;
|
|
52
|
+
}
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (key === "progress") {
|
|
56
|
+
if (rawValue === "true") step.progress = true;
|
|
57
|
+
else if (rawValue === "false") step.progress = false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return step;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function parseChain(content: string, source: "user" | "project", filePath: string): ChainConfig {
|
|
65
|
+
const { frontmatter, body } = parseFrontmatter(content);
|
|
66
|
+
if (!frontmatter.name || !frontmatter.description) {
|
|
67
|
+
throw new Error("Chain frontmatter must include name and description");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const matches = [...body.matchAll(/^##\s+(.+)[^\S\n]*$/gm)];
|
|
71
|
+
const steps: ChainStepConfig[] = [];
|
|
72
|
+
|
|
73
|
+
for (let i = 0; i < matches.length; i++) {
|
|
74
|
+
const match = matches[i]!;
|
|
75
|
+
const agent = match[1]!.trim();
|
|
76
|
+
const lineEndOffset = body[match.index! + match[0].length] === "\n" ? 1 : 0;
|
|
77
|
+
const sectionStart = match.index! + match[0].length + lineEndOffset;
|
|
78
|
+
const sectionEnd = i + 1 < matches.length ? matches[i + 1]!.index! : body.length;
|
|
79
|
+
const sectionBody = body.slice(sectionStart, sectionEnd).trimEnd();
|
|
80
|
+
steps.push(parseStepBody(agent, sectionBody));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const localName = frontmatter.name;
|
|
84
|
+
const parsedPackage = parsePackageName(frontmatter.package, `Chain '${localName}' package`);
|
|
85
|
+
if (parsedPackage.error) throw new Error(parsedPackage.error);
|
|
86
|
+
const packageName = parsedPackage.packageName;
|
|
87
|
+
const extraFields: Record<string, string> = {};
|
|
88
|
+
for (const [key, value] of Object.entries(frontmatter)) {
|
|
89
|
+
if (key === "name" || key === "package" || key === "description") continue;
|
|
90
|
+
extraFields[key] = value;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
name: buildRuntimeName(localName, packageName),
|
|
95
|
+
localName,
|
|
96
|
+
packageName,
|
|
97
|
+
description: frontmatter.description,
|
|
98
|
+
source,
|
|
99
|
+
filePath,
|
|
100
|
+
steps,
|
|
101
|
+
extraFields: Object.keys(extraFields).length > 0 ? extraFields : undefined,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function serializeChain(config: ChainConfig): string {
|
|
106
|
+
const lines: string[] = [];
|
|
107
|
+
lines.push("---");
|
|
108
|
+
lines.push(`name: ${frontmatterNameForConfig(config)}`);
|
|
109
|
+
if (config.packageName) lines.push(`package: ${config.packageName}`);
|
|
110
|
+
lines.push(`description: ${config.description}`);
|
|
111
|
+
if (config.extraFields) {
|
|
112
|
+
for (const [key, value] of Object.entries(config.extraFields)) {
|
|
113
|
+
lines.push(`${key}: ${value}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
lines.push("---");
|
|
117
|
+
lines.push("");
|
|
118
|
+
|
|
119
|
+
for (let i = 0; i < config.steps.length; i++) {
|
|
120
|
+
const step = config.steps[i]!;
|
|
121
|
+
lines.push(`## ${step.agent}`);
|
|
122
|
+
if (step.output === false) lines.push("output: false");
|
|
123
|
+
else if (step.output) lines.push(`output: ${step.output}`);
|
|
124
|
+
if (step.outputMode) lines.push(`outputMode: ${step.outputMode}`);
|
|
125
|
+
if (step.reads === false) lines.push("reads: false");
|
|
126
|
+
else if (Array.isArray(step.reads) && step.reads.length > 0) lines.push(`reads: ${step.reads.join(", ")}`);
|
|
127
|
+
if (step.model) lines.push(`model: ${step.model}`);
|
|
128
|
+
if (step.skills === false) lines.push("skills: false");
|
|
129
|
+
else if (Array.isArray(step.skills) && step.skills.length > 0) lines.push(`skills: ${step.skills.join(", ")}`);
|
|
130
|
+
if (step.progress !== undefined) lines.push(`progress: ${step.progress ? "true" : "false"}`);
|
|
131
|
+
lines.push("");
|
|
132
|
+
lines.push(step.task ?? "");
|
|
133
|
+
if (i < config.steps.length - 1) lines.push("");
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return `${lines.join("\n")}\n`;
|
|
137
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function parseFrontmatter(content: string): { frontmatter: Record<string, string>; body: string } {
|
|
2
|
+
const frontmatter: Record<string, string> = {};
|
|
3
|
+
const normalized = content.replace(/\r\n/g, "\n");
|
|
4
|
+
|
|
5
|
+
if (!normalized.startsWith("---")) {
|
|
6
|
+
return { frontmatter, body: normalized };
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const endIndex = normalized.indexOf("\n---", 3);
|
|
10
|
+
if (endIndex === -1) {
|
|
11
|
+
return { frontmatter, body: normalized };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const frontmatterBlock = normalized.slice(4, endIndex);
|
|
15
|
+
const body = normalized.slice(endIndex + 4).trim();
|
|
16
|
+
|
|
17
|
+
for (const line of frontmatterBlock.split("\n")) {
|
|
18
|
+
const match = line.match(/^([\w-]+):\s*(.*)$/);
|
|
19
|
+
if (match) {
|
|
20
|
+
let value = match[2].trim();
|
|
21
|
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
|
22
|
+
value = value.slice(1, -1);
|
|
23
|
+
}
|
|
24
|
+
frontmatter[match[1]] = value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return { frontmatter, body };
|
|
29
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AgentConfig, ChainConfig } from "./agents.ts";
|
|
2
|
+
|
|
3
|
+
const IDENTIFIER_PATTERN = /^[a-z0-9][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)*$/;
|
|
4
|
+
|
|
5
|
+
function normalizePackageName(value: string | undefined): string | undefined {
|
|
6
|
+
const trimmed = value?.trim();
|
|
7
|
+
if (!trimmed) return undefined;
|
|
8
|
+
return trimmed.toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9.-]/g, "").replace(/-+/g, "-").replace(/\.+/g, ".").replace(/(?:^[-.]+|[-.]+$)/g, "");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function parsePackageName(value: unknown, label = "package"): { packageName?: string; error?: string } {
|
|
12
|
+
if (value === undefined || value === false || value === "") return { packageName: undefined };
|
|
13
|
+
if (typeof value !== "string") return { error: `${label} must be a string or false when provided.` };
|
|
14
|
+
const packageName = normalizePackageName(value);
|
|
15
|
+
if (!packageName || !IDENTIFIER_PATTERN.test(packageName)) return { error: `${label} is invalid after sanitization.` };
|
|
16
|
+
return { packageName };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function buildRuntimeName(localName: string, packageName?: string): string {
|
|
20
|
+
const trimmedPackage = packageName?.trim();
|
|
21
|
+
return trimmedPackage ? `${trimmedPackage}.${localName}` : localName;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function frontmatterNameForConfig(config: Pick<AgentConfig | ChainConfig, "name" | "localName" | "packageName">): string {
|
|
25
|
+
if (config.localName) return config.localName;
|
|
26
|
+
if (config.packageName && config.name.startsWith(`${config.packageName}.`)) {
|
|
27
|
+
return config.name.slice(config.packageName.length + 1);
|
|
28
|
+
}
|
|
29
|
+
return config.name;
|
|
30
|
+
}
|