claude-comms 1.0.45 → 1.0.46

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 (49) hide show
  1. package/.agents/tools/agent-job/__pycache__/agent_monitor.cpython-312.pyc +0 -0
  2. package/.agents/tools/agent-job/agent_job.py +71 -1
  3. package/.agents/tools/workflow/CONSUMER_SETUP.md +114 -0
  4. package/.agents/tools/workflow/ONBOARD.md +167 -0
  5. package/.agents/tools/workflow/README.md +169 -0
  6. package/.agents/tools/workflow/cli.ts +726 -0
  7. package/.agents/tools/workflow/config.example.json +16 -0
  8. package/.agents/tools/workflow/init.ts +76 -0
  9. package/.agents/tools/workflow/lib/file-tracker.test.ts +81 -0
  10. package/.agents/tools/workflow/lib/file-tracker.ts +387 -0
  11. package/.agents/tools/workflow/lib/harness-executor.ts +649 -0
  12. package/.agents/tools/workflow/lib/prompts.scenario.test.ts +262 -0
  13. package/.agents/tools/workflow/lib/prompts.ts +548 -0
  14. package/.agents/tools/workflow/lib/streams.test.ts +140 -0
  15. package/.agents/tools/workflow/lib/streams.ts +254 -0
  16. package/.agents/tools/workflow/runner.ts +994 -0
  17. package/.agents/tools/workflow/templates/document.md +42 -0
  18. package/.agents/tools/workflow/templates/implement.md +117 -0
  19. package/.agents/tools/workflow/templates/plan.md +54 -0
  20. package/.agents/tools/workflow/templates/pm.md +84 -0
  21. package/.agents/tools/workflow/templates/product-owner.md +211 -0
  22. package/.agents/tools/workflow/templates/review.md +56 -0
  23. package/.agents/tools/workflow/templates/uat.md +71 -0
  24. package/.claude/agents/core/engineer.md +2 -13
  25. package/.claude/commands/action-feedback-item.md +14 -9
  26. package/.claude/hooks/comms/__pycache__/register_subagent.cpython-312.pyc +0 -0
  27. package/.claude/hooks/comms/__pycache__/update_subagent_completion.cpython-312.pyc +0 -0
  28. package/.claude/hooks/utils/__pycache__/server_config.cpython-312.pyc +0 -0
  29. package/.claude/settings.local.json +46 -0
  30. package/CLAUDE.md +1 -1
  31. package/bin/claude-setup.js +3 -4
  32. package/package.json +1 -1
  33. package/src/orchestrator/installer.js +5 -63
  34. package/.claude/agents/core/architect.md +0 -316
  35. package/.claude/agents/core/consultants/codex.md +0 -39
  36. package/.claude/agents/core/consultants/gemini.md +0 -39
  37. package/.claude/agents/core/designer.md +0 -181
  38. package/.claude/agents/core/planner.md +0 -251
  39. package/.claude/agents/core/uat.md +0 -147
  40. package/.claude/agents/util/feedback-executor.md +0 -29
  41. package/.claude/agents/util/meta-agent-builder.md +0 -309
  42. package/.claude/agents/util/session-review.md +0 -228
  43. package/.claude/commands/analyse-document.md +0 -10
  44. package/.claude/commands/await-feedback-orchestrator.md +0 -12
  45. package/.claude/commands/await-feedback.md +0 -21
  46. package/.claude/commands/cook.md +0 -119
  47. package/.claude/commands/feedback.md +0 -140
  48. package/.claude/commands/hello-world.md +0 -1
  49. package/.claude/commands/uat-refine.md +0 -121
@@ -0,0 +1,254 @@
1
+ /**
2
+ * Stream Handlers for different AI harnesses
3
+ *
4
+ * Parses JSON stream output from Claude, Codex, and Gemini CLIs.
5
+ * Extracts text results, completion status, and session IDs.
6
+ */
7
+
8
+ // ============================================================================
9
+ // Types
10
+ // ============================================================================
11
+
12
+ export interface StreamHandler {
13
+ /** Process a JSON event from the harness output stream */
14
+ onEvent(event: Record<string, unknown>): void;
15
+ /** Get accumulated result text */
16
+ getResult(): string;
17
+ /** Check if the stream indicates successful completion */
18
+ isComplete(): boolean;
19
+ /** Get session ID for resume functionality (Claude only) */
20
+ getSessionId(): string | null;
21
+ /** Get a failure reason if a terminal error was observed */
22
+ getFailureReason(): string | null;
23
+ }
24
+
25
+ export interface CommandOptions {
26
+ /** Session ID for Claude session resume */
27
+ sessionId?: string;
28
+ }
29
+
30
+ export interface CommandResult {
31
+ cmd: string;
32
+ args: string[];
33
+ }
34
+
35
+ // ============================================================================
36
+ // Claude Stream Handler
37
+ // ============================================================================
38
+
39
+ export class ClaudeStreamHandler implements StreamHandler {
40
+ private textChunks: string[] = [];
41
+ private finalResult: string | null = null;
42
+ private complete = false;
43
+ private success = false;
44
+ private sessionId: string | null = null;
45
+ private failureReason: string | null = null;
46
+
47
+ onEvent(event: Record<string, unknown>): void {
48
+ const type = event.type as string;
49
+
50
+ // Capture assistant text messages
51
+ if (type === "assistant" && event.message) {
52
+ const msg = event.message as {
53
+ content?: Array<{ type?: string; text?: string }>;
54
+ };
55
+ if (msg.content) {
56
+ for (const block of msg.content) {
57
+ if (block.type === "text" && block.text) {
58
+ this.textChunks.push(block.text);
59
+ }
60
+ }
61
+ }
62
+ }
63
+
64
+ // Capture final result and session_id
65
+ if (type === "result") {
66
+ this.complete = true;
67
+ const subtype = event.subtype as string | undefined;
68
+ const isError = Boolean(event.is_error);
69
+ this.success = subtype === "success" && !isError;
70
+ if (event.result) {
71
+ this.finalResult = String(event.result);
72
+ }
73
+ // Capture session_id for resume functionality
74
+ if (event.session_id) {
75
+ this.sessionId = String(event.session_id);
76
+ }
77
+ if (!this.success) {
78
+ const reason = subtype || "error";
79
+ this.failureReason = `claude_result_${reason}`;
80
+ }
81
+ }
82
+ }
83
+
84
+ getResult(): string {
85
+ // Prefer the final result field, fall back to accumulated text
86
+ return this.finalResult || this.textChunks.join("\n\n");
87
+ }
88
+
89
+ isComplete(): boolean {
90
+ return this.complete && this.success;
91
+ }
92
+
93
+ getSessionId(): string | null {
94
+ return this.sessionId;
95
+ }
96
+
97
+ getFailureReason(): string | null {
98
+ return this.failureReason;
99
+ }
100
+ }
101
+
102
+ // ============================================================================
103
+ // Codex Stream Handler
104
+ // ============================================================================
105
+
106
+ export class CodexStreamHandler implements StreamHandler {
107
+ private messages: string[] = [];
108
+ private complete = false;
109
+
110
+ onEvent(event: Record<string, unknown>): void {
111
+ const type = event.type as string;
112
+
113
+ if (type === "item.completed") {
114
+ const item = event.item as { type?: string; text?: string } | undefined;
115
+ if (item?.type === "agent_message" && item.text) {
116
+ this.messages.push(item.text);
117
+ }
118
+ }
119
+
120
+ if (type === "turn.completed") {
121
+ this.complete = true;
122
+ }
123
+ }
124
+
125
+ getResult(): string {
126
+ return this.messages.join("\n\n");
127
+ }
128
+
129
+ isComplete(): boolean {
130
+ return this.complete;
131
+ }
132
+
133
+ getSessionId(): string | null {
134
+ return null; // Codex doesn't support session resume
135
+ }
136
+
137
+ getFailureReason(): string | null {
138
+ return null;
139
+ }
140
+ }
141
+
142
+ // ============================================================================
143
+ // Gemini Stream Handler
144
+ // ============================================================================
145
+
146
+ export class GeminiStreamHandler implements StreamHandler {
147
+ private buffer = "";
148
+ private complete = false;
149
+ private failureReason: string | null = null;
150
+
151
+ onEvent(event: Record<string, unknown>): void {
152
+ const type = event.type as string;
153
+
154
+ if (type === "message" && event.role === "assistant") {
155
+ const content = event.content as string | undefined;
156
+ if (content) this.buffer += content;
157
+ }
158
+
159
+ if (type === "result") {
160
+ this.complete = true;
161
+ const status = event.status as string | undefined;
162
+ if (status && status !== "success") {
163
+ this.failureReason = `gemini_result_${status}`;
164
+ }
165
+ }
166
+ }
167
+
168
+ getResult(): string {
169
+ return this.buffer;
170
+ }
171
+
172
+ isComplete(): boolean {
173
+ return this.complete;
174
+ }
175
+
176
+ getSessionId(): string | null {
177
+ return null; // Gemini doesn't support session resume
178
+ }
179
+
180
+ getFailureReason(): string | null {
181
+ return this.failureReason;
182
+ }
183
+ }
184
+
185
+ // ============================================================================
186
+ // Factory Function
187
+ // ============================================================================
188
+
189
+ /**
190
+ * Create appropriate stream handler for the given harness
191
+ */
192
+ export function createStreamHandler(harness: string): StreamHandler {
193
+ switch (harness) {
194
+ case "claude":
195
+ return new ClaudeStreamHandler();
196
+ case "codex":
197
+ return new CodexStreamHandler();
198
+ case "gemini":
199
+ return new GeminiStreamHandler();
200
+ default:
201
+ return new ClaudeStreamHandler();
202
+ }
203
+ }
204
+
205
+ // ============================================================================
206
+ // Command Building
207
+ // ============================================================================
208
+
209
+ /**
210
+ * Build command and arguments for spawning a harness process
211
+ */
212
+ export function buildCommand(
213
+ harness: string,
214
+ prompt: string,
215
+ options: CommandOptions = {}
216
+ ): CommandResult {
217
+ switch (harness) {
218
+ case "claude": {
219
+ const args = [
220
+ "--dangerously-skip-permissions",
221
+ "--verbose",
222
+ "--output-format",
223
+ "stream-json",
224
+ ];
225
+
226
+ // Add --resume flag for session continuity
227
+ if (options.sessionId) {
228
+ args.push("--resume", options.sessionId);
229
+ }
230
+
231
+ args.push("-p", prompt);
232
+ return { cmd: "claude", args };
233
+ }
234
+ case "codex":
235
+ return {
236
+ cmd: "codex",
237
+ args: ["--yolo", "e", prompt, "--json"],
238
+ };
239
+ case "gemini":
240
+ return {
241
+ cmd: "gemini",
242
+ args: [
243
+ "--yolo",
244
+ "-m",
245
+ "gemini-2.5-pro",
246
+ "--output-format",
247
+ "stream-json",
248
+ prompt,
249
+ ],
250
+ };
251
+ default:
252
+ throw new Error(`Unknown harness: ${harness}`);
253
+ }
254
+ }