pi-crew 0.1.30 → 0.1.32

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 (159) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +80 -27
  3. package/agents/analyst.md +11 -11
  4. package/agents/critic.md +11 -11
  5. package/agents/executor.md +11 -11
  6. package/agents/explorer.md +11 -11
  7. package/agents/planner.md +11 -11
  8. package/agents/reviewer.md +11 -11
  9. package/agents/security-reviewer.md +11 -11
  10. package/agents/test-engineer.md +11 -11
  11. package/agents/verifier.md +11 -11
  12. package/agents/writer.md +11 -11
  13. package/docs/architecture.md +173 -164
  14. package/docs/refactor-tasks-phase3.md +394 -394
  15. package/docs/refactor-tasks-phase4.md +564 -564
  16. package/docs/refactor-tasks-phase5.md +402 -402
  17. package/docs/refactor-tasks-phase6.md +662 -662
  18. package/docs/research-extension-examples.md +297 -0
  19. package/docs/research-extension-system.md +324 -0
  20. package/docs/research-optimization-plan.md +548 -0
  21. package/docs/research-pi-coding-agent.md +357 -0
  22. package/docs/resource-formats.md +4 -3
  23. package/docs/runtime-flow.md +148 -148
  24. package/docs/source-runtime-refactor-map.md +83 -83
  25. package/docs/usage.md +3 -3
  26. package/index.ts +6 -6
  27. package/package.json +1 -1
  28. package/schema.json +53 -1
  29. package/skills/git-master/SKILL.md +24 -19
  30. package/skills/read-only-explorer/SKILL.md +26 -21
  31. package/skills/safe-bash/SKILL.md +21 -16
  32. package/skills/task-packet/SKILL.md +28 -23
  33. package/skills/verify-evidence/SKILL.md +27 -22
  34. package/src/agents/agent-serializer.ts +34 -34
  35. package/src/agents/discover-agents.ts +102 -102
  36. package/src/config/config.ts +14 -1
  37. package/src/config/defaults.ts +3 -2
  38. package/src/extension/cross-extension-rpc.ts +82 -82
  39. package/src/extension/import-index.ts +4 -3
  40. package/src/extension/management.ts +2 -2
  41. package/src/extension/project-init.ts +9 -7
  42. package/src/extension/register.ts +63 -0
  43. package/src/extension/registration/artifact-cleanup.ts +15 -14
  44. package/src/extension/registration/commands.ts +208 -208
  45. package/src/extension/registration/compaction-guard.ts +125 -0
  46. package/src/extension/registration/subagent-tools.ts +27 -8
  47. package/src/extension/registration/team-tool.ts +61 -44
  48. package/src/extension/result-watcher.ts +98 -98
  49. package/src/extension/run-import.ts +4 -4
  50. package/src/extension/run-index.ts +14 -14
  51. package/src/extension/run-maintenance.ts +24 -24
  52. package/src/extension/team-tool/api.ts +3 -0
  53. package/src/extension/team-tool/cancel.ts +31 -31
  54. package/src/extension/team-tool/doctor.ts +179 -178
  55. package/src/extension/team-tool/inspect.ts +41 -41
  56. package/src/extension/team-tool/lifecycle-actions.ts +79 -79
  57. package/src/extension/team-tool/plan.ts +19 -19
  58. package/src/extension/team-tool/status.ts +73 -73
  59. package/src/prompt/prompt-runtime.ts +68 -68
  60. package/src/runtime/agent-control.ts +64 -64
  61. package/src/runtime/agent-memory.ts +72 -72
  62. package/src/runtime/agent-observability.ts +113 -113
  63. package/src/runtime/async-marker.ts +26 -26
  64. package/src/runtime/background-runner.ts +53 -53
  65. package/src/runtime/crew-agent-runtime.ts +58 -58
  66. package/src/runtime/direct-run.ts +35 -35
  67. package/src/runtime/foreground-control.ts +82 -82
  68. package/src/runtime/green-contract.ts +46 -46
  69. package/src/runtime/group-join.ts +88 -88
  70. package/src/runtime/live-agent-control.ts +78 -78
  71. package/src/runtime/live-agent-manager.ts +85 -85
  72. package/src/runtime/live-control-realtime.ts +36 -36
  73. package/src/runtime/live-session-runtime.ts +299 -299
  74. package/src/runtime/manifest-cache.ts +212 -214
  75. package/src/runtime/model-fallback.ts +261 -261
  76. package/src/runtime/parallel-research.ts +44 -44
  77. package/src/runtime/parallel-utils.ts +99 -99
  78. package/src/runtime/pi-json-output.ts +111 -111
  79. package/src/runtime/pi-spawn.ts +96 -96
  80. package/src/runtime/policy-engine.ts +78 -78
  81. package/src/runtime/post-exit-stdio-guard.ts +86 -86
  82. package/src/runtime/process-status.ts +56 -56
  83. package/src/runtime/progress-event-coalescer.ts +43 -43
  84. package/src/runtime/recovery-recipes.ts +74 -74
  85. package/src/runtime/role-permission.ts +39 -39
  86. package/src/runtime/session-usage.ts +79 -79
  87. package/src/runtime/sidechain-output.ts +28 -28
  88. package/src/runtime/subagent-manager.ts +29 -2
  89. package/src/runtime/task-display.ts +38 -38
  90. package/src/runtime/task-output-context.ts +106 -106
  91. package/src/runtime/task-packet.ts +84 -84
  92. package/src/runtime/task-runner/live-executor.ts +98 -98
  93. package/src/runtime/task-runner/progress.ts +111 -111
  94. package/src/runtime/task-runner/prompt-builder.ts +72 -72
  95. package/src/runtime/task-runner/result-utils.ts +14 -14
  96. package/src/runtime/task-runner/state-helpers.ts +22 -22
  97. package/src/runtime/worker-heartbeat.ts +21 -21
  98. package/src/runtime/worker-startup.ts +57 -57
  99. package/src/schema/config-schema.ts +12 -0
  100. package/src/schema/team-tool-schema.ts +100 -100
  101. package/src/state/artifact-store.ts +108 -108
  102. package/src/state/contracts.ts +105 -105
  103. package/src/state/jsonl-writer.ts +77 -77
  104. package/src/state/state-store.ts +8 -9
  105. package/src/state/task-claims.ts +42 -42
  106. package/src/state/types.ts +180 -180
  107. package/src/state/usage.ts +29 -29
  108. package/src/subagents/async-entry.ts +1 -1
  109. package/src/subagents/index.ts +3 -3
  110. package/src/subagents/live/control.ts +1 -1
  111. package/src/subagents/live/manager.ts +1 -1
  112. package/src/subagents/live/realtime.ts +1 -1
  113. package/src/subagents/live/session-runtime.ts +1 -1
  114. package/src/subagents/manager.ts +1 -1
  115. package/src/subagents/spawn.ts +1 -1
  116. package/src/teams/discover-teams.ts +2 -2
  117. package/src/teams/team-serializer.ts +36 -36
  118. package/src/types/diff.d.ts +18 -0
  119. package/src/ui/crew-footer.ts +101 -101
  120. package/src/ui/crew-select-list.ts +111 -111
  121. package/src/ui/crew-widget.ts +285 -285
  122. package/src/ui/dynamic-border.ts +25 -25
  123. package/src/ui/layout-primitives.ts +106 -106
  124. package/src/ui/loaders.ts +158 -158
  125. package/src/ui/mascot.ts +441 -441
  126. package/src/ui/powerbar-publisher.ts +94 -94
  127. package/src/ui/render-diff.ts +119 -119
  128. package/src/ui/run-dashboard.ts +372 -372
  129. package/src/ui/status-colors.ts +54 -54
  130. package/src/ui/syntax-highlight.ts +116 -116
  131. package/src/ui/transcript-viewer.ts +302 -302
  132. package/src/utils/completion-dedupe.ts +63 -63
  133. package/src/utils/file-coalescer.ts +84 -84
  134. package/src/utils/frontmatter.ts +36 -36
  135. package/src/utils/fs-watch.ts +31 -31
  136. package/src/utils/git.ts +262 -262
  137. package/src/utils/ids.ts +12 -12
  138. package/src/utils/names.ts +26 -26
  139. package/src/utils/paths.ts +34 -7
  140. package/src/utils/sleep.ts +32 -32
  141. package/src/utils/timings.ts +31 -31
  142. package/src/utils/visual.ts +159 -159
  143. package/src/workflows/discover-workflows.ts +2 -2
  144. package/src/workflows/validate-workflow.ts +40 -40
  145. package/src/worktree/branch-freshness.ts +45 -45
  146. package/src/worktree/cleanup.ts +71 -69
  147. package/src/worktree/worktree-manager.ts +3 -1
  148. package/teams/default.team.md +12 -12
  149. package/teams/fast-fix.team.md +11 -11
  150. package/teams/implementation.team.md +18 -18
  151. package/teams/parallel-research.team.md +14 -14
  152. package/teams/research.team.md +11 -11
  153. package/teams/review.team.md +12 -12
  154. package/workflows/default.workflow.md +29 -29
  155. package/workflows/fast-fix.workflow.md +22 -22
  156. package/workflows/implementation.workflow.md +38 -38
  157. package/workflows/parallel-research.workflow.md +46 -46
  158. package/workflows/research.workflow.md +22 -22
  159. package/workflows/review.workflow.md +30 -30
@@ -1,85 +1,85 @@
1
- import type { CrewAgentRecord } from "./crew-agent-runtime.ts";
2
-
3
- type LiveSessionHandle = {
4
- steer?: (text: string) => Promise<void>;
5
- prompt?: (text: string, options?: Record<string, unknown>) => Promise<void>;
6
- abort?: () => Promise<void> | void;
7
- };
8
-
9
- export interface LiveAgentHandle {
10
- agentId: string;
11
- taskId: string;
12
- runId: string;
13
- session: LiveSessionHandle;
14
- createdAt: string;
15
- updatedAt: string;
16
- status: CrewAgentRecord["status"];
17
- pendingSteers: string[];
18
- }
19
-
20
- const liveAgents = new Map<string, LiveAgentHandle>();
21
-
22
- export function registerLiveAgent(input: Omit<LiveAgentHandle, "createdAt" | "updatedAt" | "pendingSteers">): LiveAgentHandle {
23
- const now = new Date().toISOString();
24
- const existing = liveAgents.get(input.agentId);
25
- const handle: LiveAgentHandle = { ...input, createdAt: existing?.createdAt ?? now, updatedAt: now, pendingSteers: existing?.pendingSteers ?? [] };
26
- liveAgents.set(input.agentId, handle);
27
- if (handle.pendingSteers.length && typeof handle.session.steer === "function") {
28
- const pending = [...handle.pendingSteers];
29
- handle.pendingSteers.length = 0;
30
- for (const message of pending) void handle.session.steer(message).catch(() => {});
31
- }
32
- return handle;
33
- }
34
-
35
- export function updateLiveAgentStatus(agentId: string, status: CrewAgentRecord["status"]): void {
36
- const handle = liveAgents.get(agentId);
37
- if (!handle) return;
38
- handle.status = status;
39
- handle.updatedAt = new Date().toISOString();
40
- }
41
-
42
- export function getLiveAgent(agentIdOrTaskId: string): LiveAgentHandle | undefined {
43
- return liveAgents.get(agentIdOrTaskId) ?? [...liveAgents.values()].find((entry) => entry.taskId === agentIdOrTaskId);
44
- }
45
-
46
- export function listLiveAgents(): LiveAgentHandle[] {
47
- return [...liveAgents.values()].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
48
- }
49
-
50
- export async function steerLiveAgent(agentIdOrTaskId: string, message: string): Promise<LiveAgentHandle> {
51
- const handle = getLiveAgent(agentIdOrTaskId);
52
- if (!handle) throw new Error(`Live agent '${agentIdOrTaskId}' is not registered in this process.`);
53
- if (typeof handle.session.steer !== "function") {
54
- handle.pendingSteers.push(message);
55
- return handle;
56
- }
57
- await handle.session.steer(message);
58
- handle.updatedAt = new Date().toISOString();
59
- return handle;
60
- }
61
-
62
- export async function stopLiveAgent(agentIdOrTaskId: string): Promise<LiveAgentHandle> {
63
- const handle = getLiveAgent(agentIdOrTaskId);
64
- if (!handle) throw new Error(`Live agent '${agentIdOrTaskId}' is not registered in this process.`);
65
- if (typeof handle.session.abort !== "function") throw new Error(`Live agent '${agentIdOrTaskId}' does not expose abort().`);
66
- await handle.session.abort();
67
- handle.status = "stopped";
68
- handle.updatedAt = new Date().toISOString();
69
- return handle;
70
- }
71
-
72
- export async function resumeLiveAgent(agentIdOrTaskId: string, prompt: string): Promise<LiveAgentHandle> {
73
- const handle = getLiveAgent(agentIdOrTaskId);
74
- if (!handle) throw new Error(`Live agent '${agentIdOrTaskId}' is not registered in this process.`);
75
- if (typeof handle.session.prompt !== "function") throw new Error(`Live agent '${agentIdOrTaskId}' does not expose prompt().`);
76
- handle.status = "running";
77
- await handle.session.prompt(prompt, { source: "api", expandPromptTemplates: false });
78
- handle.status = "completed";
79
- handle.updatedAt = new Date().toISOString();
80
- return handle;
81
- }
82
-
83
- export function clearLiveAgentsForTest(): void {
84
- liveAgents.clear();
85
- }
1
+ import type { CrewAgentRecord } from "./crew-agent-runtime.ts";
2
+
3
+ type LiveSessionHandle = {
4
+ steer?: (text: string) => Promise<void>;
5
+ prompt?: (text: string, options?: Record<string, unknown>) => Promise<void>;
6
+ abort?: () => Promise<void> | void;
7
+ };
8
+
9
+ export interface LiveAgentHandle {
10
+ agentId: string;
11
+ taskId: string;
12
+ runId: string;
13
+ session: LiveSessionHandle;
14
+ createdAt: string;
15
+ updatedAt: string;
16
+ status: CrewAgentRecord["status"];
17
+ pendingSteers: string[];
18
+ }
19
+
20
+ const liveAgents = new Map<string, LiveAgentHandle>();
21
+
22
+ export function registerLiveAgent(input: Omit<LiveAgentHandle, "createdAt" | "updatedAt" | "pendingSteers">): LiveAgentHandle {
23
+ const now = new Date().toISOString();
24
+ const existing = liveAgents.get(input.agentId);
25
+ const handle: LiveAgentHandle = { ...input, createdAt: existing?.createdAt ?? now, updatedAt: now, pendingSteers: existing?.pendingSteers ?? [] };
26
+ liveAgents.set(input.agentId, handle);
27
+ if (handle.pendingSteers.length && typeof handle.session.steer === "function") {
28
+ const pending = [...handle.pendingSteers];
29
+ handle.pendingSteers.length = 0;
30
+ for (const message of pending) void handle.session.steer(message).catch(() => {});
31
+ }
32
+ return handle;
33
+ }
34
+
35
+ export function updateLiveAgentStatus(agentId: string, status: CrewAgentRecord["status"]): void {
36
+ const handle = liveAgents.get(agentId);
37
+ if (!handle) return;
38
+ handle.status = status;
39
+ handle.updatedAt = new Date().toISOString();
40
+ }
41
+
42
+ export function getLiveAgent(agentIdOrTaskId: string): LiveAgentHandle | undefined {
43
+ return liveAgents.get(agentIdOrTaskId) ?? [...liveAgents.values()].find((entry) => entry.taskId === agentIdOrTaskId);
44
+ }
45
+
46
+ export function listLiveAgents(): LiveAgentHandle[] {
47
+ return [...liveAgents.values()].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
48
+ }
49
+
50
+ export async function steerLiveAgent(agentIdOrTaskId: string, message: string): Promise<LiveAgentHandle> {
51
+ const handle = getLiveAgent(agentIdOrTaskId);
52
+ if (!handle) throw new Error(`Live agent '${agentIdOrTaskId}' is not registered in this process.`);
53
+ if (typeof handle.session.steer !== "function") {
54
+ handle.pendingSteers.push(message);
55
+ return handle;
56
+ }
57
+ await handle.session.steer(message);
58
+ handle.updatedAt = new Date().toISOString();
59
+ return handle;
60
+ }
61
+
62
+ export async function stopLiveAgent(agentIdOrTaskId: string): Promise<LiveAgentHandle> {
63
+ const handle = getLiveAgent(agentIdOrTaskId);
64
+ if (!handle) throw new Error(`Live agent '${agentIdOrTaskId}' is not registered in this process.`);
65
+ if (typeof handle.session.abort !== "function") throw new Error(`Live agent '${agentIdOrTaskId}' does not expose abort().`);
66
+ await handle.session.abort();
67
+ handle.status = "stopped";
68
+ handle.updatedAt = new Date().toISOString();
69
+ return handle;
70
+ }
71
+
72
+ export async function resumeLiveAgent(agentIdOrTaskId: string, prompt: string): Promise<LiveAgentHandle> {
73
+ const handle = getLiveAgent(agentIdOrTaskId);
74
+ if (!handle) throw new Error(`Live agent '${agentIdOrTaskId}' is not registered in this process.`);
75
+ if (typeof handle.session.prompt !== "function") throw new Error(`Live agent '${agentIdOrTaskId}' does not expose prompt().`);
76
+ handle.status = "running";
77
+ await handle.session.prompt(prompt, { source: "api", expandPromptTemplates: false });
78
+ handle.status = "completed";
79
+ handle.updatedAt = new Date().toISOString();
80
+ return handle;
81
+ }
82
+
83
+ export function clearLiveAgentsForTest(): void {
84
+ liveAgents.clear();
85
+ }
@@ -1,36 +1,36 @@
1
- import type { LiveAgentControlRequest } from "./live-agent-control.ts";
2
-
3
- export interface LiveControlRealtimeMessage {
4
- type: "live-control";
5
- version: 1;
6
- request: LiveAgentControlRequest;
7
- }
8
-
9
- type Listener = (request: LiveAgentControlRequest) => void | Promise<void>;
10
-
11
- const listeners = new Set<Listener>();
12
-
13
- export function publishLiveControlRealtime(request: LiveAgentControlRequest): void {
14
- for (const listener of [...listeners]) void listener(request);
15
- }
16
-
17
- export function subscribeLiveControlRealtime(listener: Listener): () => void {
18
- listeners.add(listener);
19
- return () => listeners.delete(listener);
20
- }
21
-
22
- export function liveControlRealtimeMessage(request: LiveAgentControlRequest): LiveControlRealtimeMessage {
23
- return { type: "live-control", version: 1, request };
24
- }
25
-
26
- export function parseLiveControlRealtimeMessage(raw: unknown): LiveAgentControlRequest | undefined {
27
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) return undefined;
28
- const message = raw as { type?: unknown; version?: unknown; request?: unknown };
29
- if (message.type !== "live-control" || message.version !== 1 || !message.request || typeof message.request !== "object" || Array.isArray(message.request)) return undefined;
30
- const request = message.request as Partial<LiveAgentControlRequest>;
31
- return typeof request.id === "string" && typeof request.runId === "string" && typeof request.taskId === "string" && (request.operation === "steer" || request.operation === "stop" || request.operation === "resume") && typeof request.createdAt === "string" ? request as LiveAgentControlRequest : undefined;
32
- }
33
-
34
- export function clearLiveControlRealtimeForTest(): void {
35
- listeners.clear();
36
- }
1
+ import type { LiveAgentControlRequest } from "./live-agent-control.ts";
2
+
3
+ export interface LiveControlRealtimeMessage {
4
+ type: "live-control";
5
+ version: 1;
6
+ request: LiveAgentControlRequest;
7
+ }
8
+
9
+ type Listener = (request: LiveAgentControlRequest) => void | Promise<void>;
10
+
11
+ const listeners = new Set<Listener>();
12
+
13
+ export function publishLiveControlRealtime(request: LiveAgentControlRequest): void {
14
+ for (const listener of [...listeners]) void listener(request);
15
+ }
16
+
17
+ export function subscribeLiveControlRealtime(listener: Listener): () => void {
18
+ listeners.add(listener);
19
+ return () => listeners.delete(listener);
20
+ }
21
+
22
+ export function liveControlRealtimeMessage(request: LiveAgentControlRequest): LiveControlRealtimeMessage {
23
+ return { type: "live-control", version: 1, request };
24
+ }
25
+
26
+ export function parseLiveControlRealtimeMessage(raw: unknown): LiveAgentControlRequest | undefined {
27
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return undefined;
28
+ const message = raw as { type?: unknown; version?: unknown; request?: unknown };
29
+ if (message.type !== "live-control" || message.version !== 1 || !message.request || typeof message.request !== "object" || Array.isArray(message.request)) return undefined;
30
+ const request = message.request as Partial<LiveAgentControlRequest>;
31
+ return typeof request.id === "string" && typeof request.runId === "string" && typeof request.taskId === "string" && (request.operation === "steer" || request.operation === "stop" || request.operation === "resume") && typeof request.createdAt === "string" ? request as LiveAgentControlRequest : undefined;
32
+ }
33
+
34
+ export function clearLiveControlRealtimeForTest(): void {
35
+ listeners.clear();
36
+ }