@linxiraos/pi-messenger 1.1.0 → 1.3.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 (66) hide show
  1. package/CHANGELOG.md +741 -676
  2. package/LICENSE +45 -0
  3. package/README.md +424 -424
  4. package/THIRD-PARTY-NOTICES.txt +22951 -0
  5. package/config-overlay.ts +175 -171
  6. package/config.ts +221 -209
  7. package/crew/agents/crew-plan-sync.md +66 -64
  8. package/crew/agents/crew-planner.md +173 -172
  9. package/crew/agents/crew-reviewer.md +58 -58
  10. package/crew/agents/crew-worker.md +130 -129
  11. package/crew/agents.ts +507 -434
  12. package/crew/handlers/coordination.ts +350 -332
  13. package/crew/handlers/plan.ts +988 -906
  14. package/crew/handlers/review.ts +354 -333
  15. package/crew/handlers/revise.ts +400 -376
  16. package/crew/handlers/status.ts +303 -295
  17. package/crew/handlers/sync.ts +237 -233
  18. package/crew/handlers/task.ts +820 -792
  19. package/crew/handlers/team.ts +294 -235
  20. package/crew/handlers/work.ts +467 -425
  21. package/crew/id-allocator.ts +30 -30
  22. package/crew/index.ts +297 -257
  23. package/crew/live-progress.ts +58 -58
  24. package/crew/lobby.ts +504 -473
  25. package/crew/prompt.ts +262 -252
  26. package/crew/registry.ts +114 -114
  27. package/crew/spawn.ts +135 -111
  28. package/crew/state-autonomous.ts +163 -164
  29. package/crew/state-planning.ts +264 -263
  30. package/crew/state.ts +20 -20
  31. package/crew/store.ts +646 -642
  32. package/crew/task-actions.ts +162 -131
  33. package/crew/team/store.ts +572 -479
  34. package/crew/team/subagent-roles.ts +105 -87
  35. package/crew/team/types.ts +50 -50
  36. package/crew/types.ts +194 -194
  37. package/crew/utils/artifacts.ts +57 -62
  38. package/crew/utils/config.ts +158 -156
  39. package/crew/utils/discover.ts +221 -219
  40. package/crew/utils/install.ts +94 -85
  41. package/crew/utils/migrations.ts +126 -0
  42. package/crew/utils/progress.ts +191 -187
  43. package/crew/utils/result.ts +16 -16
  44. package/crew/utils/risk-labels.ts +5 -7
  45. package/crew/utils/task-format.ts +14 -14
  46. package/crew/utils/team-roles.ts +44 -28
  47. package/crew/utils/truncate.ts +76 -79
  48. package/crew/utils/verdict.ts +55 -55
  49. package/editor-binary.ts +150 -0
  50. package/editor-command.ts +107 -0
  51. package/editor-target.ts +40 -0
  52. package/feed.ts +321 -268
  53. package/handlers.ts +1041 -1107
  54. package/index.ts +1314 -1206
  55. package/install.mjs +187 -189
  56. package/lib.ts +587 -467
  57. package/overlay-actions.ts +519 -511
  58. package/overlay-coordinator.ts +150 -150
  59. package/overlay-render.ts +770 -676
  60. package/overlay.ts +872 -830
  61. package/package.json +64 -60
  62. package/paths.ts +60 -0
  63. package/skills/pi-messenger-crew/SKILL.md +375 -347
  64. package/store.ts +1147 -1139
  65. package/teamagent-command.ts +321 -0
  66. package/vitest.config.ts +10 -10
package/crew/types.ts CHANGED
@@ -1,194 +1,194 @@
1
- /**
2
- * Crew - Type Definitions
3
- *
4
- * Simplified PRD-based workflow types.
5
- */
6
-
7
- import type { MaxOutputConfig } from "./utils/truncate.ts";
8
- import type { AgentProgress } from "./utils/progress.ts";
9
- import type { CrewAgentConfig } from "./utils/discover.ts";
10
-
11
- // =============================================================================
12
- // Plan Types
13
- // =============================================================================
14
-
15
- export interface Plan {
16
- prd: string; // Path to PRD file (relative to cwd)
17
- prompt?: string; // Inline prompt text (when no PRD file)
18
- created_at: string; // ISO timestamp
19
- updated_at: string; // ISO timestamp
20
- task_count: number; // Total tasks
21
- completed_count: number; // Completed tasks
22
- }
23
-
24
- // =============================================================================
25
- // Task Types
26
- // =============================================================================
27
-
28
- export type TaskStatus = "todo" | "in_progress" | "done" | "blocked";
29
-
30
- export interface TaskEvidence {
31
- commits?: string[]; // Commit SHAs
32
- tests?: string[]; // Test commands/files run
33
- prs?: string[]; // PR URLs
34
- }
35
-
36
- export type TaskApprovalDecisionStatus = "pending" | "approved" | "rejected";
37
- export type TaskApprovalStatus = "not_required" | TaskApprovalDecisionStatus;
38
-
39
- interface TaskApprovalMetadata {
40
- plan?: string;
41
- feedback?: string;
42
- decided_by?: string;
43
- decided_at?: string;
44
- }
45
-
46
- export type TaskApproval =
47
- | ({ required: false; status: "not_required" } & TaskApprovalMetadata)
48
- | ({ required: true; status: TaskApprovalDecisionStatus } & TaskApprovalMetadata);
49
-
50
- export interface Task {
51
- id: string; // task-N format
52
- title: string;
53
- status: TaskStatus;
54
- milestone?: boolean;
55
- model?: string;
56
- role?: string; // Team role assignment
57
- risk_labels?: string[]; // Team risk labels for approval policy
58
- approval?: TaskApproval; // Team lead approval state
59
- depends_on: string[]; // Task IDs this depends on
60
- skills?: string[]; // Skill names from planner
61
- created_at: string; // ISO timestamp
62
- updated_at: string; // ISO timestamp
63
- started_at?: string; // When task.start was called
64
- completed_at?: string; // When task.done was called
65
- base_commit?: string; // Git commit SHA at task.start
66
- assigned_to?: string; // Agent name currently working on it
67
- summary?: string; // Completion summary from task.done
68
- evidence?: TaskEvidence; // Evidence from task.done
69
- blocked_reason?: string; // Reason from task.block
70
- attempt_count: number; // How many times attempted (for auto-block)
71
- review_count?: number; // How many times reviewed
72
- last_review?: ReviewFeedback; // Feedback from last review (for retry)
73
- }
74
-
75
- export interface ReviewFeedback {
76
- verdict: ReviewVerdict;
77
- summary: string;
78
- issues: string[];
79
- suggestions: string[];
80
- reviewed_at: string; // ISO timestamp
81
- }
82
-
83
- // =============================================================================
84
- // Crew Params (Tool Parameters)
85
- // =============================================================================
86
-
87
- export interface CrewParams {
88
- // Action
89
- action?: string;
90
-
91
- // Plan
92
- prd?: string; // PRD file path for plan action
93
-
94
- // Task IDs
95
- id?: string; // Task ID (task-N)
96
- taskId?: string; // Swarm task ID (for claim/unclaim/complete)
97
-
98
- // Creation
99
- title?: string;
100
- dependsOn?: string[];
101
- role?: string;
102
- riskLabels?: string[];
103
- approval?: TaskApproval;
104
-
105
- // Completion
106
- summary?: string;
107
- evidence?: TaskEvidence;
108
-
109
- // Content
110
- content?: string; // Task description/spec content
111
- count?: number;
112
- subtasks?: { title: string; content?: string }[];
113
-
114
- // Review / Team memory
115
- target?: string; // Task ID to review
116
- type?: "plan" | "impl" | "decision" | "interface" | "risk" | "handoff";
117
-
118
- // Plan options
119
- autoWork?: boolean;
120
-
121
- // Work options
122
- autonomous?: boolean;
123
- concurrency?: number;
124
- model?: string;
125
-
126
- // Task reset
127
- cascade?: boolean;
128
-
129
- // Revision
130
- prompt?: string;
131
-
132
- // Feed
133
- limit?: number;
134
-
135
- // Coordination
136
- spec?: string;
137
- to?: string | string[];
138
- message?: string;
139
- replyTo?: string;
140
- paths?: string[];
141
- reason?: string;
142
- name?: string;
143
- notes?: string;
144
- autoRegisterPath?: "add" | "remove" | "list";
145
- }
146
-
147
- // =============================================================================
148
- // Review Types
149
- // =============================================================================
150
-
151
- export type ReviewVerdict = "SHIP" | "NEEDS_WORK" | "MAJOR_RETHINK";
152
-
153
- export interface ReviewResult {
154
- verdict: ReviewVerdict;
155
- summary: string;
156
- issues?: string[];
157
- suggestions?: string[];
158
- }
159
-
160
- // =============================================================================
161
- // Agent Spawning Types
162
- // =============================================================================
163
-
164
- export interface AgentTask {
165
- agent: string;
166
- task: string;
167
- taskId?: string;
168
- modelOverride?: string;
169
- maxOutput?: MaxOutputConfig;
170
- }
171
-
172
- export interface AgentResult {
173
- agent: string;
174
- exitCode: number;
175
- output: string;
176
- truncated: boolean;
177
- progress: AgentProgress;
178
- config?: CrewAgentConfig;
179
- taskId?: string;
180
- wasGracefullyShutdown?: boolean;
181
- error?: string;
182
- artifactPaths?: {
183
- input: string;
184
- output: string;
185
- jsonl: string;
186
- metadata: string;
187
- };
188
- }
189
-
190
- // =============================================================================
191
- // Callback Types
192
- // =============================================================================
193
-
194
- export type AppendEntryFn = (type: string, data: unknown) => void;
1
+ /**
2
+ * Crew - Type Definitions
3
+ *
4
+ * Simplified PRD-based workflow types.
5
+ */
6
+
7
+ import type { MaxOutputConfig } from "./utils/truncate.ts";
8
+ import type { AgentProgress } from "./utils/progress.ts";
9
+ import type { CrewAgentConfig } from "./utils/discover.ts";
10
+
11
+ // =============================================================================
12
+ // Plan Types
13
+ // =============================================================================
14
+
15
+ export interface Plan {
16
+ prd: string; // Path to PRD file (relative to cwd)
17
+ prompt?: string; // Inline prompt text (when no PRD file)
18
+ created_at: string; // ISO timestamp
19
+ updated_at: string; // ISO timestamp
20
+ task_count: number; // Total tasks
21
+ completed_count: number; // Completed tasks
22
+ }
23
+
24
+ // =============================================================================
25
+ // Task Types
26
+ // =============================================================================
27
+
28
+ export type TaskStatus = "todo" | "in_progress" | "done" | "blocked";
29
+
30
+ export interface TaskEvidence {
31
+ commits?: string[]; // Commit SHAs
32
+ tests?: string[]; // Test commands/files run
33
+ prs?: string[]; // PR URLs
34
+ }
35
+
36
+ export type TaskApprovalDecisionStatus = "pending" | "approved" | "rejected";
37
+ export type TaskApprovalStatus = "not_required" | TaskApprovalDecisionStatus;
38
+
39
+ interface TaskApprovalMetadata {
40
+ plan?: string;
41
+ feedback?: string;
42
+ decided_by?: string;
43
+ decided_at?: string;
44
+ }
45
+
46
+ export type TaskApproval =
47
+ | ({ required: false; status: "not_required" } & TaskApprovalMetadata)
48
+ | ({ required: true; status: TaskApprovalDecisionStatus } & TaskApprovalMetadata);
49
+
50
+ export interface Task {
51
+ id: string; // task-N format
52
+ title: string;
53
+ status: TaskStatus;
54
+ milestone?: boolean;
55
+ model?: string;
56
+ role?: string; // Team role assignment
57
+ risk_labels?: string[]; // Team risk labels for approval policy
58
+ approval?: TaskApproval; // Team lead approval state
59
+ depends_on: string[]; // Task IDs this depends on
60
+ skills?: string[]; // Skill names from planner
61
+ created_at: string; // ISO timestamp
62
+ updated_at: string; // ISO timestamp
63
+ started_at?: string; // When task.start was called
64
+ completed_at?: string; // When task.done was called
65
+ base_commit?: string; // Git commit SHA at task.start
66
+ assigned_to?: string; // Agent name currently working on it
67
+ summary?: string; // Completion summary from task.done
68
+ evidence?: TaskEvidence; // Evidence from task.done
69
+ blocked_reason?: string; // Reason from task.block
70
+ attempt_count: number; // How many times attempted (for auto-block)
71
+ review_count?: number; // How many times reviewed
72
+ last_review?: ReviewFeedback; // Feedback from last review (for retry)
73
+ }
74
+
75
+ export interface ReviewFeedback {
76
+ verdict: ReviewVerdict;
77
+ summary: string;
78
+ issues: string[];
79
+ suggestions: string[];
80
+ reviewed_at: string; // ISO timestamp
81
+ }
82
+
83
+ // =============================================================================
84
+ // Crew Params (Tool Parameters)
85
+ // =============================================================================
86
+
87
+ export interface CrewParams {
88
+ // Action
89
+ action?: string;
90
+
91
+ // Plan
92
+ prd?: string; // PRD file path for plan action
93
+
94
+ // Task IDs
95
+ id?: string; // Task ID (task-N)
96
+ taskId?: string; // Swarm task ID (for claim/unclaim/complete)
97
+
98
+ // Creation
99
+ title?: string;
100
+ dependsOn?: string[];
101
+ role?: string;
102
+ riskLabels?: string[];
103
+ approval?: TaskApproval;
104
+
105
+ // Completion
106
+ summary?: string;
107
+ evidence?: TaskEvidence;
108
+
109
+ // Content
110
+ content?: string; // Task description/spec content
111
+ count?: number;
112
+ subtasks?: { title: string; content?: string }[];
113
+
114
+ // Review / Team memory
115
+ target?: string; // Task ID to review
116
+ type?: "plan" | "impl" | "decision" | "interface" | "risk" | "handoff";
117
+
118
+ // Plan options
119
+ autoWork?: boolean;
120
+
121
+ // Work options
122
+ autonomous?: boolean;
123
+ concurrency?: number;
124
+ model?: string;
125
+
126
+ // Task reset
127
+ cascade?: boolean;
128
+
129
+ // Revision
130
+ prompt?: string;
131
+
132
+ // Feed
133
+ limit?: number;
134
+
135
+ // Coordination
136
+ spec?: string;
137
+ to?: string | string[];
138
+ message?: string;
139
+ replyTo?: string;
140
+ paths?: string[];
141
+ reason?: string;
142
+ name?: string;
143
+ notes?: string;
144
+ autoRegisterPath?: "add" | "remove" | "list";
145
+ }
146
+
147
+ // =============================================================================
148
+ // Review Types
149
+ // =============================================================================
150
+
151
+ export type ReviewVerdict = "SHIP" | "NEEDS_WORK" | "MAJOR_RETHINK";
152
+
153
+ export interface ReviewResult {
154
+ verdict: ReviewVerdict;
155
+ summary: string;
156
+ issues?: string[];
157
+ suggestions?: string[];
158
+ }
159
+
160
+ // =============================================================================
161
+ // Agent Spawning Types
162
+ // =============================================================================
163
+
164
+ export interface AgentTask {
165
+ agent: string;
166
+ task: string;
167
+ taskId?: string;
168
+ modelOverride?: string;
169
+ maxOutput?: MaxOutputConfig;
170
+ }
171
+
172
+ export interface AgentResult {
173
+ agent: string;
174
+ exitCode: number;
175
+ output: string;
176
+ truncated: boolean;
177
+ progress: AgentProgress;
178
+ config?: CrewAgentConfig;
179
+ taskId?: string;
180
+ wasGracefullyShutdown?: boolean;
181
+ error?: string;
182
+ artifactPaths?: {
183
+ input: string;
184
+ output: string;
185
+ jsonl: string;
186
+ metadata: string;
187
+ };
188
+ }
189
+
190
+ // =============================================================================
191
+ // Callback Types
192
+ // =============================================================================
193
+
194
+ export type AppendEntryFn = (type: string, data: unknown) => void;
@@ -1,62 +1,57 @@
1
- /**
2
- * Crew - Debug Artifacts
3
- *
4
- * Writes debug files for troubleshooting agent failures.
5
- */
6
-
7
- import * as fs from "node:fs";
8
- import * as path from "node:path";
9
-
10
- export interface ArtifactPaths {
11
- inputPath: string;
12
- outputPath: string;
13
- jsonlPath: string;
14
- metadataPath: string;
15
- }
16
-
17
- export function getArtifactPaths(
18
- artifactsDir: string,
19
- runId: string,
20
- agent: string,
21
- index?: number
22
- ): ArtifactPaths {
23
- const suffix = index !== undefined ? `_${index}` : "";
24
- const safeAgent = agent.replace(/[^\w.-]/g, "_");
25
- const base = `${runId}_${safeAgent}${suffix}`;
26
-
27
- return {
28
- inputPath: path.join(artifactsDir, `${base}_input.md`),
29
- outputPath: path.join(artifactsDir, `${base}_output.md`),
30
- jsonlPath: path.join(artifactsDir, `${base}.jsonl`),
31
- metadataPath: path.join(artifactsDir, `${base}_meta.json`),
32
- };
33
- }
34
-
35
- export function ensureArtifactsDir(dir: string, cleanupDays?: number): void {
36
- fs.mkdirSync(dir, { recursive: true });
37
- if (cleanupDays === undefined || cleanupDays <= 0) return;
38
-
39
- const cutoff = Date.now() - cleanupDays * 24 * 60 * 60 * 1000;
40
- for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
41
- if (!entry.isFile()) continue;
42
- const filePath = path.join(dir, entry.name);
43
- try {
44
- if (fs.statSync(filePath).mtimeMs < cutoff) fs.rmSync(filePath, { force: true });
45
- } catch {}
46
- }
47
- }
48
-
49
- export function writeArtifact(filePath: string, content: string): void {
50
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
51
- fs.writeFileSync(filePath, content, "utf-8");
52
- }
53
-
54
- export function writeMetadata(filePath: string, metadata: object): void {
55
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
56
- fs.writeFileSync(filePath, JSON.stringify(metadata, null, 2), "utf-8");
57
- }
58
-
59
- export function appendJsonl(filePath: string, line: string): void {
60
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
61
- fs.appendFileSync(filePath, `${line}\n`);
62
- }
1
+ /**
2
+ * Crew - Debug Artifacts
3
+ *
4
+ * Writes debug files for troubleshooting agent failures.
5
+ */
6
+
7
+ import * as fs from "node:fs";
8
+ import * as path from "node:path";
9
+
10
+ export interface ArtifactPaths {
11
+ inputPath: string;
12
+ outputPath: string;
13
+ jsonlPath: string;
14
+ metadataPath: string;
15
+ }
16
+
17
+ export function getArtifactPaths(artifactsDir: string, runId: string, agent: string, index?: number): ArtifactPaths {
18
+ const suffix = index !== undefined ? `_${index}` : "";
19
+ const safeAgent = agent.replace(/[^\w.-]/g, "_");
20
+ const base = `${runId}_${safeAgent}${suffix}`;
21
+
22
+ return {
23
+ inputPath: path.join(artifactsDir, `${base}_input.md`),
24
+ outputPath: path.join(artifactsDir, `${base}_output.md`),
25
+ jsonlPath: path.join(artifactsDir, `${base}.jsonl`),
26
+ metadataPath: path.join(artifactsDir, `${base}_meta.json`),
27
+ };
28
+ }
29
+
30
+ export function ensureArtifactsDir(dir: string, cleanupDays?: number): void {
31
+ fs.mkdirSync(dir, { recursive: true });
32
+ if (cleanupDays === undefined || cleanupDays <= 0) return;
33
+
34
+ const cutoff = Date.now() - cleanupDays * 24 * 60 * 60 * 1000;
35
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
36
+ if (!entry.isFile()) continue;
37
+ const filePath = path.join(dir, entry.name);
38
+ try {
39
+ if (fs.statSync(filePath).mtimeMs < cutoff) fs.rmSync(filePath, { force: true });
40
+ } catch {}
41
+ }
42
+ }
43
+
44
+ export function writeArtifact(filePath: string, content: string): void {
45
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
46
+ fs.writeFileSync(filePath, content, "utf-8");
47
+ }
48
+
49
+ export function writeMetadata(filePath: string, metadata: object): void {
50
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
51
+ fs.writeFileSync(filePath, JSON.stringify(metadata, null, 2), "utf-8");
52
+ }
53
+
54
+ export function appendJsonl(filePath: string, line: string): void {
55
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
56
+ fs.appendFileSync(filePath, `${line}\n`);
57
+ }