@leing2021/super-pi 0.22.1 → 0.23.1
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/README.md +66 -293
- package/extensions/ce-core/index.ts +276 -48
- package/extensions/ce-core/tools/parallel-subagent.ts +3 -3
- package/extensions/ce-core/tools/subagent.ts +2 -2
- package/package.json +4 -20
- package/rules/common/naming.md +154 -0
- package/skills/01-brainstorm/SKILL.md +42 -79
- package/skills/01-brainstorm/references/ce-brainstorm-mode.md +47 -0
- package/skills/02-plan/SKILL.md +43 -61
- package/skills/02-plan/references/solution-search.md +46 -0
- package/skills/03-work/SKILL.md +34 -52
- package/skills/03-work/references/completion-report.md +51 -0
- package/skills/04-review/SKILL.md +44 -51
- package/skills/04-review/references/solution-search.md +46 -0
- package/skills/06-next/SKILL.md +35 -20
- package/skills/06-next/references/recommendation-logic.md +47 -2
- package/skills/07-worktree/SKILL.md +21 -20
- package/skills/08-help/SKILL.md +46 -0
- package/skills/08-help/references/workflow-sequence.md +135 -0
- package/skills/references/language-detection.md +44 -0
- package/LICENSE +0 -21
- package/THIRD-PARTY-NOTICES.md +0 -35
- package/extensions/subagent/__tests__/async-job-tracker.test.ts +0 -21
- package/extensions/subagent/__tests__/execution-activity.test.ts +0 -15
- package/extensions/subagent/__tests__/parallel-render-stress.test.ts +0 -82
- package/extensions/subagent/__tests__/render-dedup.test.ts +0 -98
- package/extensions/subagent/__tests__/render-widget.test.ts +0 -28
- package/extensions/subagent/__tests__/throttle.test.ts +0 -90
- package/extensions/subagent/agent-management.ts +0 -596
- package/extensions/subagent/agent-manager-chain-detail.ts +0 -163
- package/extensions/subagent/agent-manager-detail.ts +0 -232
- package/extensions/subagent/agent-manager-edit.ts +0 -391
- package/extensions/subagent/agent-manager-list.ts +0 -279
- package/extensions/subagent/agent-manager-parallel.ts +0 -305
- package/extensions/subagent/agent-manager.ts +0 -706
- package/extensions/subagent/agent-scope.ts +0 -9
- package/extensions/subagent/agent-selection.ts +0 -26
- package/extensions/subagent/agent-serializer.ts +0 -124
- package/extensions/subagent/agent-templates.ts +0 -63
- package/extensions/subagent/agents/context-builder.md +0 -37
- package/extensions/subagent/agents/delegate.md +0 -9
- package/extensions/subagent/agents/oracle.md +0 -73
- package/extensions/subagent/agents/planner.md +0 -52
- package/extensions/subagent/agents/researcher.md +0 -50
- package/extensions/subagent/agents/reviewer.md +0 -38
- package/extensions/subagent/agents/scout.md +0 -48
- package/extensions/subagent/agents/worker.md +0 -52
- package/extensions/subagent/agents.ts +0 -762
- package/extensions/subagent/artifacts.ts +0 -101
- package/extensions/subagent/async-execution.ts +0 -521
- package/extensions/subagent/async-job-tracker.ts +0 -240
- package/extensions/subagent/async-status.ts +0 -242
- package/extensions/subagent/chain-clarify.ts +0 -1365
- package/extensions/subagent/chain-execution.ts +0 -854
- package/extensions/subagent/chain-serializer.ts +0 -127
- package/extensions/subagent/completion-dedupe.ts +0 -66
- package/extensions/subagent/doctor.ts +0 -201
- package/extensions/subagent/execution.ts +0 -748
- package/extensions/subagent/file-coalescer.ts +0 -43
- package/extensions/subagent/fork-context.ts +0 -64
- package/extensions/subagent/formatters.ts +0 -123
- package/extensions/subagent/frontmatter.ts +0 -32
- package/extensions/subagent/index.ts +0 -586
- package/extensions/subagent/intercom-bridge.ts +0 -241
- package/extensions/subagent/jsonl-writer.ts +0 -84
- package/extensions/subagent/model-fallback.ts +0 -109
- package/extensions/subagent/notify.ts +0 -111
- package/extensions/subagent/parallel-utils.ts +0 -109
- package/extensions/subagent/pi-args.ts +0 -139
- package/extensions/subagent/pi-spawn.ts +0 -101
- package/extensions/subagent/post-exit-stdio-guard.ts +0 -88
- package/extensions/subagent/prompt-template-bridge.ts +0 -400
- package/extensions/subagent/prompts/gather-context-and-clarify.md +0 -13
- package/extensions/subagent/prompts/parallel-cleanup.md +0 -42
- package/extensions/subagent/prompts/parallel-research.md +0 -50
- package/extensions/subagent/prompts/parallel-review.md +0 -40
- package/extensions/subagent/render-helpers.ts +0 -83
- package/extensions/subagent/render.ts +0 -908
- package/extensions/subagent/result-intercom.ts +0 -238
- package/extensions/subagent/result-watcher.ts +0 -172
- package/extensions/subagent/run-history.ts +0 -58
- package/extensions/subagent/run-status.ts +0 -137
- package/extensions/subagent/schemas.ts +0 -165
- package/extensions/subagent/session-tokens.ts +0 -51
- package/extensions/subagent/settings.ts +0 -368
- package/extensions/subagent/single-output.ts +0 -98
- package/extensions/subagent/skills.ts +0 -627
- package/extensions/subagent/slash-bridge.ts +0 -177
- package/extensions/subagent/slash-commands.ts +0 -304
- package/extensions/subagent/slash-live-state.ts +0 -295
- package/extensions/subagent/subagent-control.ts +0 -151
- package/extensions/subagent/subagent-executor.ts +0 -1915
- package/extensions/subagent/subagent-prompt-runtime.ts +0 -76
- package/extensions/subagent/subagent-runner.ts +0 -1471
- package/extensions/subagent/subagents-status.ts +0 -473
- package/extensions/subagent/text-editor.ts +0 -273
- package/extensions/subagent/throttle.ts +0 -77
- package/extensions/subagent/top-level-async.ts +0 -16
- package/extensions/subagent/types.ts +0 -624
- package/extensions/subagent/utils.ts +0 -457
- package/extensions/subagent/worktree.ts +0 -580
- package/extensions/super-pi-extension/agents/ce-oracle.md +0 -109
- package/extensions/super-pi-extension/agents/ce-planner.md +0 -116
- package/extensions/super-pi-extension/agents/ce-reviewer.md +0 -99
- package/extensions/super-pi-extension/agents/ce-scout.md +0 -80
- package/extensions/super-pi-extension/agents/ce-worker.md +0 -78
- package/extensions/super-pi-extension/chains/ce-parallel-review.chain.md +0 -34
- package/extensions/super-pi-extension/chains/ce-review-only.chain.md +0 -12
- package/extensions/super-pi-extension/chains/ce-standard.chain.md +0 -28
- package/extensions/super-pi-extension/index.ts +0 -129
- package/extensions/super-pi-extension/model-sync.ts +0 -204
- package/skills/08-status/SKILL.md +0 -41
- package/skills/08-status/references/artifact-locations.md +0 -10
- package/skills/09-help/SKILL.md +0 -37
- package/skills/09-help/references/workflow-sequence.md +0 -9
- package/skills/10-rules/SKILL.md +0 -76
- package/skills/pi-subagents/SKILL.md +0 -566
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: 2025 Nico Bailon
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Source: https://github.com/nicobailon/pi-subagents
|
|
4
|
-
interface TimerApi {
|
|
5
|
-
setTimeout(handler: () => void, delayMs: number): unknown;
|
|
6
|
-
clearTimeout(handle: unknown): void;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
interface FileCoalescer {
|
|
10
|
-
schedule(file: string, delayMs?: number): boolean;
|
|
11
|
-
clear(): void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const defaultTimerApi: TimerApi = {
|
|
15
|
-
setTimeout: (handler, delayMs) => setTimeout(handler, delayMs),
|
|
16
|
-
clearTimeout: (handle) => clearTimeout(handle as ReturnType<typeof setTimeout>),
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export function createFileCoalescer(
|
|
20
|
-
handler: (file: string) => void,
|
|
21
|
-
defaultDelayMs: number,
|
|
22
|
-
timerApi: TimerApi = defaultTimerApi,
|
|
23
|
-
): FileCoalescer {
|
|
24
|
-
const pending = new Map<string, unknown>();
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
schedule(file: string, delayMs = defaultDelayMs): boolean {
|
|
28
|
-
if (pending.has(file)) return false;
|
|
29
|
-
const timer = timerApi.setTimeout(() => {
|
|
30
|
-
pending.delete(file);
|
|
31
|
-
handler(file);
|
|
32
|
-
}, delayMs);
|
|
33
|
-
pending.set(file, timer);
|
|
34
|
-
return true;
|
|
35
|
-
},
|
|
36
|
-
clear(): void {
|
|
37
|
-
for (const timer of pending.values()) {
|
|
38
|
-
timerApi.clearTimeout(timer);
|
|
39
|
-
}
|
|
40
|
-
pending.clear();
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: 2025 Nico Bailon
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Source: https://github.com/nicobailon/pi-subagents
|
|
4
|
-
export type SubagentExecutionContext = "fresh" | "fork";
|
|
5
|
-
|
|
6
|
-
interface ForkableSessionManagerStatic {
|
|
7
|
-
open(path: string): { createBranchedSession(leafId: string): string | undefined };
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface ForkableSessionManager {
|
|
11
|
-
getSessionFile(): string | undefined;
|
|
12
|
-
getLeafId(): string | null;
|
|
13
|
-
constructor: ForkableSessionManagerStatic;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface ForkContextResolver {
|
|
17
|
-
sessionFileForIndex(index?: number): string | undefined;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function resolveSubagentContext(value: unknown): SubagentExecutionContext {
|
|
21
|
-
return value === "fork" ? "fork" : "fresh";
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function createForkContextResolver(
|
|
25
|
-
sessionManager: ForkableSessionManager,
|
|
26
|
-
requestedContext: unknown,
|
|
27
|
-
): ForkContextResolver {
|
|
28
|
-
if (resolveSubagentContext(requestedContext) !== "fork") {
|
|
29
|
-
return {
|
|
30
|
-
sessionFileForIndex: () => undefined,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const parentSessionFile = sessionManager.getSessionFile();
|
|
35
|
-
if (!parentSessionFile) {
|
|
36
|
-
throw new Error("Forked subagent context requires a persisted parent session.");
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const leafId = sessionManager.getLeafId();
|
|
40
|
-
if (!leafId) {
|
|
41
|
-
throw new Error("Forked subagent context requires a current leaf to fork from.");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const cachedSessionFiles = new Map<number, string>();
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
sessionFileForIndex(index = 0): string | undefined {
|
|
48
|
-
const cached = cachedSessionFiles.get(index);
|
|
49
|
-
if (cached) return cached;
|
|
50
|
-
try {
|
|
51
|
-
const sourceManager = sessionManager.constructor.open(parentSessionFile);
|
|
52
|
-
const sessionFile = sourceManager.createBranchedSession(leafId);
|
|
53
|
-
if (!sessionFile) {
|
|
54
|
-
throw new Error("Session manager did not return a session file.");
|
|
55
|
-
}
|
|
56
|
-
cachedSessionFiles.set(index, sessionFile);
|
|
57
|
-
return sessionFile;
|
|
58
|
-
} catch (error) {
|
|
59
|
-
const cause = error instanceof Error ? error : new Error(String(error));
|
|
60
|
-
throw new Error(`Failed to create forked subagent session: ${cause.message}`, { cause });
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: 2025 Nico Bailon
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Source: https://github.com/nicobailon/pi-subagents
|
|
4
|
-
/**
|
|
5
|
-
* Formatting utilities for display output
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import * as fs from "node:fs";
|
|
9
|
-
import * as path from "node:path";
|
|
10
|
-
import type { Usage, SingleResult } from "./types.ts";
|
|
11
|
-
import type { ChainStep } from "./settings.ts";
|
|
12
|
-
import { isParallelStep } from "./settings.ts";
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Format token count with k suffix for large numbers
|
|
16
|
-
*/
|
|
17
|
-
export function formatTokens(n: number): string {
|
|
18
|
-
return n < 1000 ? String(n) : n < 10000 ? `${(n / 1000).toFixed(1)}k` : `${Math.round(n / 1000)}k`;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Format usage statistics into a compact string
|
|
23
|
-
*/
|
|
24
|
-
export function formatUsage(u: Usage, model?: string): string {
|
|
25
|
-
const parts: string[] = [];
|
|
26
|
-
if (u.turns) parts.push(`${u.turns} turn${u.turns > 1 ? "s" : ""}`);
|
|
27
|
-
if (u.input) parts.push(`in:${formatTokens(u.input)}`);
|
|
28
|
-
if (u.output) parts.push(`out:${formatTokens(u.output)}`);
|
|
29
|
-
if (u.cacheRead) parts.push(`R${formatTokens(u.cacheRead)}`);
|
|
30
|
-
if (u.cacheWrite) parts.push(`W${formatTokens(u.cacheWrite)}`);
|
|
31
|
-
if (u.cost) parts.push(`$${u.cost.toFixed(4)}`);
|
|
32
|
-
if (model) parts.push(model);
|
|
33
|
-
return parts.join(" ");
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Format duration in human-readable form
|
|
38
|
-
*/
|
|
39
|
-
export function formatDuration(ms: number): string {
|
|
40
|
-
if (ms < 1000) return `${ms}ms`;
|
|
41
|
-
if (ms < 60000) return `${(ms / 1000).toFixed(1)}s`;
|
|
42
|
-
return `${Math.floor(ms / 60000)}m${Math.floor((ms % 60000) / 1000)}s`;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Build a summary string for a completed/failed chain
|
|
47
|
-
*/
|
|
48
|
-
export function buildChainSummary(
|
|
49
|
-
steps: ChainStep[],
|
|
50
|
-
results: SingleResult[],
|
|
51
|
-
chainDir: string,
|
|
52
|
-
status: "completed" | "failed",
|
|
53
|
-
failedStep?: { index: number; error: string },
|
|
54
|
-
): string {
|
|
55
|
-
const stepNames = steps
|
|
56
|
-
.map((step) => (isParallelStep(step) ? `parallel[${step.parallel.length}]` : step.agent))
|
|
57
|
-
.join(" → ");
|
|
58
|
-
|
|
59
|
-
const totalDuration = results.reduce((sum, r) => sum + (r.progress?.durationMs || 0), 0);
|
|
60
|
-
const durationStr = formatDuration(totalDuration);
|
|
61
|
-
|
|
62
|
-
const progressPath = path.join(chainDir, "progress.md");
|
|
63
|
-
const hasProgress = fs.existsSync(progressPath);
|
|
64
|
-
const allSkills = new Set<string>();
|
|
65
|
-
for (const r of results) {
|
|
66
|
-
if (r.skills) r.skills.forEach((s) => allSkills.add(s));
|
|
67
|
-
}
|
|
68
|
-
const skillsLine = allSkills.size > 0 ? `🔧 Skills: ${[...allSkills].join(", ")}` : "";
|
|
69
|
-
|
|
70
|
-
if (status === "completed") {
|
|
71
|
-
const stepWord = results.length === 1 ? "step" : "steps";
|
|
72
|
-
return `✅ Chain completed: ${stepNames} (${results.length} ${stepWord}, ${durationStr})${skillsLine ? `\n${skillsLine}` : ""}
|
|
73
|
-
|
|
74
|
-
📋 Progress: ${hasProgress ? progressPath : "(none)"}
|
|
75
|
-
📁 Artifacts: ${chainDir}`;
|
|
76
|
-
} else {
|
|
77
|
-
const stepInfo = failedStep ? ` at step ${failedStep.index + 1}` : "";
|
|
78
|
-
const errorInfo = failedStep?.error ? `: ${failedStep.error}` : "";
|
|
79
|
-
return `❌ Chain failed${stepInfo}${errorInfo}${skillsLine ? `\n${skillsLine}` : ""}
|
|
80
|
-
|
|
81
|
-
📋 Progress: ${hasProgress ? progressPath : "(none)"}
|
|
82
|
-
📁 Artifacts: ${chainDir}`;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Format a tool call for display
|
|
88
|
-
*/
|
|
89
|
-
export function formatToolCall(name: string, args: Record<string, unknown>, expanded = false): string {
|
|
90
|
-
switch (name) {
|
|
91
|
-
case "bash": {
|
|
92
|
-
const command = typeof args.command === "string" ? args.command : "";
|
|
93
|
-
const maxLength = expanded ? 240 : 60;
|
|
94
|
-
return `$ ${command.slice(0, maxLength)}${command.length > maxLength ? "..." : ""}`;
|
|
95
|
-
}
|
|
96
|
-
case "read":
|
|
97
|
-
case "write":
|
|
98
|
-
case "edit": {
|
|
99
|
-
const target = typeof args.path === "string"
|
|
100
|
-
? args.path
|
|
101
|
-
: typeof args.file_path === "string"
|
|
102
|
-
? args.file_path
|
|
103
|
-
: "";
|
|
104
|
-
return `${name} ${shortenPath(target)}`;
|
|
105
|
-
}
|
|
106
|
-
default: {
|
|
107
|
-
const s = JSON.stringify(args);
|
|
108
|
-
const maxLength = expanded ? 160 : 40;
|
|
109
|
-
return `${name} ${s.slice(0, maxLength)}${s.length > maxLength ? "..." : ""}`;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Shorten a path by replacing home directory with ~
|
|
116
|
-
*/
|
|
117
|
-
export function shortenPath(p: string): string {
|
|
118
|
-
const home = process.env.HOME;
|
|
119
|
-
if (home && p.startsWith(home)) {
|
|
120
|
-
return `~${p.slice(home.length)}`;
|
|
121
|
-
}
|
|
122
|
-
return p;
|
|
123
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// SPDX-FileCopyrightText: 2025 Nico Bailon
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Source: https://github.com/nicobailon/pi-subagents
|
|
4
|
-
export function parseFrontmatter(content: string): { frontmatter: Record<string, string>; body: string } {
|
|
5
|
-
const frontmatter: Record<string, string> = {};
|
|
6
|
-
const normalized = content.replace(/\r\n/g, "\n");
|
|
7
|
-
|
|
8
|
-
if (!normalized.startsWith("---")) {
|
|
9
|
-
return { frontmatter, body: normalized };
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const endIndex = normalized.indexOf("\n---", 3);
|
|
13
|
-
if (endIndex === -1) {
|
|
14
|
-
return { frontmatter, body: normalized };
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const frontmatterBlock = normalized.slice(4, endIndex);
|
|
18
|
-
const body = normalized.slice(endIndex + 4).trim();
|
|
19
|
-
|
|
20
|
-
for (const line of frontmatterBlock.split("\n")) {
|
|
21
|
-
const match = line.match(/^([\w-]+):\s*(.*)$/);
|
|
22
|
-
if (match) {
|
|
23
|
-
let value = match[2].trim();
|
|
24
|
-
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
|
25
|
-
value = value.slice(1, -1);
|
|
26
|
-
}
|
|
27
|
-
frontmatter[match[1]] = value;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return { frontmatter, body };
|
|
32
|
-
}
|