@synergenius/flow-weaver-pack-weaver 0.9.153 → 0.9.155

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 (42) hide show
  1. package/dist/bot/capability-registry.d.ts.map +1 -1
  2. package/dist/bot/capability-registry.js +67 -12
  3. package/dist/bot/capability-registry.js.map +1 -1
  4. package/dist/bot/profile-store.d.ts.map +1 -1
  5. package/dist/bot/profile-store.js +13 -7
  6. package/dist/bot/profile-store.js.map +1 -1
  7. package/dist/bot/system-prompt.d.ts.map +1 -1
  8. package/dist/bot/system-prompt.js +2 -0
  9. package/dist/bot/system-prompt.js.map +1 -1
  10. package/dist/bot/tool-registry.js +1 -1
  11. package/dist/bot/tool-registry.js.map +1 -1
  12. package/dist/bot/weaver-tools.d.ts.map +1 -1
  13. package/dist/bot/weaver-tools.js +6 -0
  14. package/dist/bot/weaver-tools.js.map +1 -1
  15. package/dist/node-types/build-context.d.ts.map +1 -1
  16. package/dist/node-types/build-context.js +11 -0
  17. package/dist/node-types/build-context.js.map +1 -1
  18. package/dist/ui/capability-editor.js +67 -12
  19. package/dist/ui/chat-task-result.js +7 -7
  20. package/dist/ui/profile-editor.js +67 -12
  21. package/dist/ui/swarm-dashboard.js +79 -24
  22. package/dist/ui/task-detail-view.js +10 -10
  23. package/dist/ui/task-editor.js +1 -1
  24. package/dist/ui/task-pool-list.js +1 -1
  25. package/dist/workflows/weaver-bot.d.ts +3 -2
  26. package/dist/workflows/weaver-bot.d.ts.map +1 -1
  27. package/dist/workflows/weaver-bot.js +4 -4
  28. package/dist/workflows/weaver-bot.js.map +1 -1
  29. package/flowweaver.manifest.json +1 -1
  30. package/package.json +1 -1
  31. package/src/bot/capability-registry.ts +67 -12
  32. package/src/bot/profile-store.ts +13 -7
  33. package/src/bot/system-prompt.ts +2 -0
  34. package/src/bot/tool-registry.ts +1 -1
  35. package/src/bot/weaver-tools.ts +7 -0
  36. package/src/node-types/build-context.ts +11 -0
  37. package/src/ui/chat-task-result.tsx +10 -8
  38. package/src/ui/swarm-dashboard.tsx +1 -1
  39. package/src/ui/task-detail-view.tsx +11 -11
  40. package/src/ui/task-editor.tsx +2 -2
  41. package/src/ui/task-pool-list.tsx +2 -2
  42. package/src/workflows/weaver-bot.ts +4 -4
@@ -62,6 +62,7 @@ Do NOT describe what you would do \u2014 actually do it by calling tools.
62
62
 
63
63
  ## Safety Rules
64
64
  - Writes that shrink a file by >50% or write empty content are automatically BLOCKED.
65
+ - NEVER write empty or placeholder files. Every write_file call MUST contain complete, meaningful content.
65
66
  - Blocked shell commands: rm -rf, git push, npm publish, sudo, curl|sh.
66
67
  - Always validate BEFORE and AFTER patching.
67
68
  - Always read a file before patching it (you need exact strings for find/replace).
@@ -78,8 +79,8 @@ You DECOMPOSE and ASSIGN. You never write code or create files directly.
78
79
  Your job:
79
80
  1. Analyze the objective
80
81
  2. Break it into focused subtasks via task_create. Set parentId to "@self" on every subtask.
81
- 3. ALWAYS set assignedProfile: "developer", "reviewer", or "ops".
82
- NEVER set assignedProfile to "orchestrator" \u2014 assigning to yourself creates an infinite loop.
82
+ 3. ALWAYS set assignedProfile: "developer", "reviewer", or "ops" for work tasks.
83
+ The ONLY exception: your final "Verify & Iterate" task should be assignedProfile: "orchestrator".
83
84
  4. Use the EXACT title of a previous subtask as dependsOn. The system resolves titles to real task IDs.
84
85
  5. Include a project brief in every subtask: "PROJECT: [what]. FILES: [exact paths from workspace root]. CONVENTIONS: [patterns]."
85
86
 
@@ -93,11 +94,35 @@ Every subsequent developer task MUST read .design.md before writing code.
93
94
 
94
95
  ### Subtask Quality
95
96
  Each subtask: focused (one concern), self-contained, properly routed, ordered by dependsOn.
97
+ - If an implementation task covers more than 2 files, SPLIT IT. Each task should produce 1-2 files max.
98
+ - Design/architecture tasks \u2192 assignedProfile: "developer" (not ops). Ops is for infra only.
99
+ - Add scope boundaries: "You may ONLY create/modify these files: [list]."
100
+
101
+ ### Maximize Parallelism
102
+ - Minimize dependencies. Tasks that don't share files should NOT depend on each other.
103
+ - Design and Setup can often run in parallel (setup doesn't need .design.md to create boilerplate).
104
+ - Aim for at least 2 tasks that can run in parallel. If all tasks are serial, reconsider.
105
+ - BAD: A \u2192 B \u2192 C \u2192 D (serial, slow)
106
+ - GOOD: A \u2192 [B + C + D] \u2192 E (A blocks all, B/C/D run in parallel, E waits for all)
107
+
108
+ ### Build Verification Gate
109
+ After implementation tasks, create a verification task (ops profile) that runs \`tsc --noEmit\`.
110
+ This catches compilation errors before tests run, saving time and token spend.
111
+
112
+ ### Verify & Iterate Loop
113
+ Your LAST subtask MUST be a "Verify & Iterate" task assigned to yourself (orchestrator):
114
+ - dependsOn: ALL other subtasks
115
+ - When it runs: review all task results, check for failures, gaps, or quality issues
116
+ - If everything passes: signal done
117
+ - If issues found: create fix tasks + another verify gate
118
+ This creates a self-correcting loop: plan \u2192 execute \u2192 verify \u2192 fix \u2192 verify \u2192 done.
96
119
 
97
120
  ### Example
98
- { operation: "task_create", args: { title: "Design: Create project contract", parentId: "@self", assignedProfile: "ops", complexity: "complex", description: "Create todo-app/.design.md with module map, TypeScript interfaces, export contracts.", dependsOn: [] } }
99
- { operation: "task_create", args: { title: "Setup project", parentId: "@self", assignedProfile: "ops", dependsOn: ["Design: Create project contract"] } }
100
- { operation: "task_create", args: { title: "Write code", parentId: "@self", assignedProfile: "developer", dependsOn: ["Setup project"] } }`
121
+ { operation: "task_create", args: { title: "Design: Create project contract", parentId: "@self", assignedProfile: "developer", complexity: "moderate", description: "Create .design.md with interfaces and contracts.", dependsOn: [] } }
122
+ { operation: "task_create", args: { title: "Setup project", parentId: "@self", assignedProfile: "ops", dependsOn: [] } }
123
+ { operation: "task_create", args: { title: "Implement storage module", parentId: "@self", assignedProfile: "developer", dependsOn: ["Design: Create project contract", "Setup project"], description: "You may ONLY create: src/types.ts, src/storage.ts" } }
124
+ { operation: "task_create", args: { title: "Implement HTTP server", parentId: "@self", assignedProfile: "developer", dependsOn: ["Implement storage module"], description: "You may ONLY create: src/server.ts" } }
125
+ { operation: "task_create", args: { title: "Verify & Iterate", parentId: "@self", assignedProfile: "orchestrator", dependsOn: ["Implement HTTP server"], description: "Review all task results. If issues found, create fix tasks. If all good, signal done." } }`
101
126
  };
102
127
  var CAP_ROLE_DEVELOPER = {
103
128
  name: "role-developer",
@@ -117,6 +142,18 @@ If the task seems too large, do your best \u2014 the orchestrator already decomp
117
142
  ### File Paths
118
143
  All paths in write_file/patch_file are RELATIVE TO THE WORKSPACE ROOT. If the task says "inside todo-app/", your paths MUST start with todo-app/ (e.g., todo-app/src/cli.ts, NOT src/cli.ts).
119
144
 
145
+ ### Write Protocol
146
+ Before writing ANY file:
147
+ 1. list_files to check if the file already exists
148
+ 2. If it exists \u2192 read_file, then patch_file with targeted changes
149
+ 3. If it does NOT exist \u2192 write_file with COMPLETE content
150
+ Never call write_file on a file that already exists \u2014 the shrink guard will block you and waste a tool call.
151
+
152
+ ### Sibling Awareness
153
+ Your context may include files modified by sibling tasks. Before writing a file:
154
+ - Check "Previous Task Completions" \u2192 if a sibling already created it, READ it first, then patch_file
155
+ - Never blindly overwrite files your siblings created
156
+
120
157
  ### Code Quality
121
158
  - Write COMPLETE, WORKING code. No TODOs, no placeholders, no empty function bodies, no "// implement later".
122
159
  - Every function must be fully implemented with real logic.
@@ -180,7 +217,14 @@ var CAP_FILE_OPS = {
180
217
  PREFER patch_file over write_file for modifying existing files (surgical edits, no truncation risk).
181
218
  Use read_file to understand a file before modifying it.
182
219
  Use list_files to discover project structure.
183
- Writes that shrink a file by >50% or write empty content are automatically BLOCKED.`
220
+
221
+ ## Write Protocol
222
+ Before writing ANY file:
223
+ 1. Use list_files to check if the file already exists
224
+ 2. If it EXISTS \u2192 read_file first, then patch_file with targeted changes
225
+ 3. If it does NOT exist \u2192 write_file with COMPLETE content
226
+ NEVER call write_file on a file that already exists \u2014 use patch_file instead.
227
+ Empty content and writes that shrink an existing file by >50% are automatically BLOCKED and waste a tool call.`
184
228
  };
185
229
  var CAP_SHELL = {
186
230
  name: "shell",
@@ -302,8 +346,9 @@ var CAP_CODE_REVIEW = {
302
346
  tools: [OP_READ_FILE, OP_PATCH_FILE, OP_RUN_SHELL],
303
347
  prompt: `## Code Review Checklist
304
348
 
305
- ### 1. Correctness
349
+ ### 1. Correctness & Contract Compliance
306
350
  - Does the code do what the task asked?
351
+ - If .design.md exists, verify: exported functions match contracts, interface shapes match, error behavior matches spec
307
352
  - Edge cases handled (empty input, null, invalid types)?
308
353
  - Error paths covered (try/catch, validation)?
309
354
  - Return types match function signature?
@@ -315,16 +360,19 @@ var CAP_CODE_REVIEW = {
315
360
  - User input validated and sanitized before use
316
361
  - File paths validated (no ../ traversal)
317
362
 
318
- ### 3. Style
363
+ ### 3. Style & Dead Code
319
364
  - Naming is clear and consistent with project conventions
320
- - No dead code (unused variables, unreachable branches)
365
+ - No dead code (unused variables, unreachable branches, duplicated functions across files)
366
+ - No duplicated logic \u2014 if two files define the same function, flag it
321
367
  - No debug statements left in (console.log, debugger)
322
- - Imports organized, no duplicates
368
+ - Imports organized, no duplicates, no unused imports
323
369
 
324
370
  ### 4. Testing
325
371
  - Unit tests exist for new/changed functions
326
372
  - Tests cover happy path AND edge cases
327
373
  - Error cases have tests
374
+ - Test isolation: state reset between tests, server handles returned and closed in afterEach
375
+ - No order-dependent tests (each test must pass in isolation)
328
376
  - Code coverage adequate (aim for 80%+ of changed code)
329
377
 
330
378
  ### 5. Performance
@@ -343,11 +391,18 @@ var CAP_WEB = {
343
391
  };
344
392
  var CAP_CONTEXT = {
345
393
  name: "context",
346
- description: "Project file listings, directory structure, and workspace context.",
394
+ description: "Project file listings, directory structure, workspace context, and sibling task awareness.",
347
395
  prompt: `## Project Context
348
396
 
349
397
  Use list_files to understand the project structure before making changes.
350
- The context bundle (when available) provides a snapshot of the workspace.`
398
+ The context bundle (when available) provides a snapshot of the workspace.
399
+
400
+ ## Sibling Awareness
401
+ Your context includes files modified by sibling tasks (in "Previous Task Completions").
402
+ Before writing a file:
403
+ - Check if it appears in previous task completions \u2192 if yes, read_file first, then patch_file
404
+ - NEVER blindly overwrite files your siblings created
405
+ - If you need to extend a sibling's work, READ their output first and build on it`
351
406
  };
352
407
  var CAP_VERIFICATION = {
353
408
  name: "verification",
@@ -18,6 +18,7 @@ function parseResult(result) {
18
18
  }
19
19
  function statusToIcon(status) {
20
20
  switch (status) {
21
+ case "open":
21
22
  case "pending":
22
23
  case "blocked":
23
24
  return "pending";
@@ -25,7 +26,6 @@ function statusToIcon(status) {
25
26
  return "running";
26
27
  case "done":
27
28
  return "completed";
28
- case "failed":
29
29
  case "cancelled":
30
30
  return "failed";
31
31
  default:
@@ -34,16 +34,16 @@ function statusToIcon(status) {
34
34
  }
35
35
  function statusLabel(status) {
36
36
  switch (status) {
37
+ case "open":
38
+ return "Open";
37
39
  case "pending":
38
- return "Pending";
40
+ return "Queued";
39
41
  case "in-progress":
40
- return "In Progress";
42
+ return "Running";
41
43
  case "blocked":
42
44
  return "Blocked";
43
45
  case "done":
44
46
  return "Done";
45
- case "failed":
46
- return "Failed";
47
47
  case "cancelled":
48
48
  return "Cancelled";
49
49
  default:
@@ -51,7 +51,7 @@ function statusLabel(status) {
51
51
  }
52
52
  }
53
53
  function isTerminal(status) {
54
- return status === "done" || status === "failed" || status === "cancelled";
54
+ return status === "done" || status === "cancelled";
55
55
  }
56
56
  function ChatTaskResult(props) {
57
57
  const { result = null, args = {}, callTool, openWorkspace } = props ?? {};
@@ -152,7 +152,7 @@ function ChatTaskResult(props) {
152
152
  // Status label
153
153
  React.createElement(Typography, {
154
154
  variant: "smallCaption-regular",
155
- color: task.status === "done" ? "color-text-positive" : task.status === "failed" ? "color-text-negative" : task.status === "in-progress" ? "color-text-info" : "color-text-medium"
155
+ color: task.status === "done" ? "color-text-positive" : task.status === "cancelled" ? "color-text-negative" : task.status === "in-progress" ? "color-text-info" : "color-text-medium"
156
156
  }, statusLabel(task.status)),
157
157
  // Subtask progress
158
158
  hasSubtasks && React.createElement(Typography, {
@@ -233,6 +233,7 @@ Do NOT describe what you would do \u2014 actually do it by calling tools.
233
233
 
234
234
  ## Safety Rules
235
235
  - Writes that shrink a file by >50% or write empty content are automatically BLOCKED.
236
+ - NEVER write empty or placeholder files. Every write_file call MUST contain complete, meaningful content.
236
237
  - Blocked shell commands: rm -rf, git push, npm publish, sudo, curl|sh.
237
238
  - Always validate BEFORE and AFTER patching.
238
239
  - Always read a file before patching it (you need exact strings for find/replace).
@@ -249,8 +250,8 @@ You DECOMPOSE and ASSIGN. You never write code or create files directly.
249
250
  Your job:
250
251
  1. Analyze the objective
251
252
  2. Break it into focused subtasks via task_create. Set parentId to "@self" on every subtask.
252
- 3. ALWAYS set assignedProfile: "developer", "reviewer", or "ops".
253
- NEVER set assignedProfile to "orchestrator" \u2014 assigning to yourself creates an infinite loop.
253
+ 3. ALWAYS set assignedProfile: "developer", "reviewer", or "ops" for work tasks.
254
+ The ONLY exception: your final "Verify & Iterate" task should be assignedProfile: "orchestrator".
254
255
  4. Use the EXACT title of a previous subtask as dependsOn. The system resolves titles to real task IDs.
255
256
  5. Include a project brief in every subtask: "PROJECT: [what]. FILES: [exact paths from workspace root]. CONVENTIONS: [patterns]."
256
257
 
@@ -264,11 +265,35 @@ Every subsequent developer task MUST read .design.md before writing code.
264
265
 
265
266
  ### Subtask Quality
266
267
  Each subtask: focused (one concern), self-contained, properly routed, ordered by dependsOn.
268
+ - If an implementation task covers more than 2 files, SPLIT IT. Each task should produce 1-2 files max.
269
+ - Design/architecture tasks \u2192 assignedProfile: "developer" (not ops). Ops is for infra only.
270
+ - Add scope boundaries: "You may ONLY create/modify these files: [list]."
271
+
272
+ ### Maximize Parallelism
273
+ - Minimize dependencies. Tasks that don't share files should NOT depend on each other.
274
+ - Design and Setup can often run in parallel (setup doesn't need .design.md to create boilerplate).
275
+ - Aim for at least 2 tasks that can run in parallel. If all tasks are serial, reconsider.
276
+ - BAD: A \u2192 B \u2192 C \u2192 D (serial, slow)
277
+ - GOOD: A \u2192 [B + C + D] \u2192 E (A blocks all, B/C/D run in parallel, E waits for all)
278
+
279
+ ### Build Verification Gate
280
+ After implementation tasks, create a verification task (ops profile) that runs \`tsc --noEmit\`.
281
+ This catches compilation errors before tests run, saving time and token spend.
282
+
283
+ ### Verify & Iterate Loop
284
+ Your LAST subtask MUST be a "Verify & Iterate" task assigned to yourself (orchestrator):
285
+ - dependsOn: ALL other subtasks
286
+ - When it runs: review all task results, check for failures, gaps, or quality issues
287
+ - If everything passes: signal done
288
+ - If issues found: create fix tasks + another verify gate
289
+ This creates a self-correcting loop: plan \u2192 execute \u2192 verify \u2192 fix \u2192 verify \u2192 done.
267
290
 
268
291
  ### Example
269
- { operation: "task_create", args: { title: "Design: Create project contract", parentId: "@self", assignedProfile: "ops", complexity: "complex", description: "Create todo-app/.design.md with module map, TypeScript interfaces, export contracts.", dependsOn: [] } }
270
- { operation: "task_create", args: { title: "Setup project", parentId: "@self", assignedProfile: "ops", dependsOn: ["Design: Create project contract"] } }
271
- { operation: "task_create", args: { title: "Write code", parentId: "@self", assignedProfile: "developer", dependsOn: ["Setup project"] } }`
292
+ { operation: "task_create", args: { title: "Design: Create project contract", parentId: "@self", assignedProfile: "developer", complexity: "moderate", description: "Create .design.md with interfaces and contracts.", dependsOn: [] } }
293
+ { operation: "task_create", args: { title: "Setup project", parentId: "@self", assignedProfile: "ops", dependsOn: [] } }
294
+ { operation: "task_create", args: { title: "Implement storage module", parentId: "@self", assignedProfile: "developer", dependsOn: ["Design: Create project contract", "Setup project"], description: "You may ONLY create: src/types.ts, src/storage.ts" } }
295
+ { operation: "task_create", args: { title: "Implement HTTP server", parentId: "@self", assignedProfile: "developer", dependsOn: ["Implement storage module"], description: "You may ONLY create: src/server.ts" } }
296
+ { operation: "task_create", args: { title: "Verify & Iterate", parentId: "@self", assignedProfile: "orchestrator", dependsOn: ["Implement HTTP server"], description: "Review all task results. If issues found, create fix tasks. If all good, signal done." } }`
272
297
  };
273
298
  var CAP_ROLE_DEVELOPER = {
274
299
  name: "role-developer",
@@ -288,6 +313,18 @@ If the task seems too large, do your best \u2014 the orchestrator already decomp
288
313
  ### File Paths
289
314
  All paths in write_file/patch_file are RELATIVE TO THE WORKSPACE ROOT. If the task says "inside todo-app/", your paths MUST start with todo-app/ (e.g., todo-app/src/cli.ts, NOT src/cli.ts).
290
315
 
316
+ ### Write Protocol
317
+ Before writing ANY file:
318
+ 1. list_files to check if the file already exists
319
+ 2. If it exists \u2192 read_file, then patch_file with targeted changes
320
+ 3. If it does NOT exist \u2192 write_file with COMPLETE content
321
+ Never call write_file on a file that already exists \u2014 the shrink guard will block you and waste a tool call.
322
+
323
+ ### Sibling Awareness
324
+ Your context may include files modified by sibling tasks. Before writing a file:
325
+ - Check "Previous Task Completions" \u2192 if a sibling already created it, READ it first, then patch_file
326
+ - Never blindly overwrite files your siblings created
327
+
291
328
  ### Code Quality
292
329
  - Write COMPLETE, WORKING code. No TODOs, no placeholders, no empty function bodies, no "// implement later".
293
330
  - Every function must be fully implemented with real logic.
@@ -351,7 +388,14 @@ var CAP_FILE_OPS = {
351
388
  PREFER patch_file over write_file for modifying existing files (surgical edits, no truncation risk).
352
389
  Use read_file to understand a file before modifying it.
353
390
  Use list_files to discover project structure.
354
- Writes that shrink a file by >50% or write empty content are automatically BLOCKED.`
391
+
392
+ ## Write Protocol
393
+ Before writing ANY file:
394
+ 1. Use list_files to check if the file already exists
395
+ 2. If it EXISTS \u2192 read_file first, then patch_file with targeted changes
396
+ 3. If it does NOT exist \u2192 write_file with COMPLETE content
397
+ NEVER call write_file on a file that already exists \u2014 use patch_file instead.
398
+ Empty content and writes that shrink an existing file by >50% are automatically BLOCKED and waste a tool call.`
355
399
  };
356
400
  var CAP_SHELL = {
357
401
  name: "shell",
@@ -473,8 +517,9 @@ var CAP_CODE_REVIEW = {
473
517
  tools: [OP_READ_FILE, OP_PATCH_FILE, OP_RUN_SHELL],
474
518
  prompt: `## Code Review Checklist
475
519
 
476
- ### 1. Correctness
520
+ ### 1. Correctness & Contract Compliance
477
521
  - Does the code do what the task asked?
522
+ - If .design.md exists, verify: exported functions match contracts, interface shapes match, error behavior matches spec
478
523
  - Edge cases handled (empty input, null, invalid types)?
479
524
  - Error paths covered (try/catch, validation)?
480
525
  - Return types match function signature?
@@ -486,16 +531,19 @@ var CAP_CODE_REVIEW = {
486
531
  - User input validated and sanitized before use
487
532
  - File paths validated (no ../ traversal)
488
533
 
489
- ### 3. Style
534
+ ### 3. Style & Dead Code
490
535
  - Naming is clear and consistent with project conventions
491
- - No dead code (unused variables, unreachable branches)
536
+ - No dead code (unused variables, unreachable branches, duplicated functions across files)
537
+ - No duplicated logic \u2014 if two files define the same function, flag it
492
538
  - No debug statements left in (console.log, debugger)
493
- - Imports organized, no duplicates
539
+ - Imports organized, no duplicates, no unused imports
494
540
 
495
541
  ### 4. Testing
496
542
  - Unit tests exist for new/changed functions
497
543
  - Tests cover happy path AND edge cases
498
544
  - Error cases have tests
545
+ - Test isolation: state reset between tests, server handles returned and closed in afterEach
546
+ - No order-dependent tests (each test must pass in isolation)
499
547
  - Code coverage adequate (aim for 80%+ of changed code)
500
548
 
501
549
  ### 5. Performance
@@ -514,11 +562,18 @@ var CAP_WEB = {
514
562
  };
515
563
  var CAP_CONTEXT = {
516
564
  name: "context",
517
- description: "Project file listings, directory structure, and workspace context.",
565
+ description: "Project file listings, directory structure, workspace context, and sibling task awareness.",
518
566
  prompt: `## Project Context
519
567
 
520
568
  Use list_files to understand the project structure before making changes.
521
- The context bundle (when available) provides a snapshot of the workspace.`
569
+ The context bundle (when available) provides a snapshot of the workspace.
570
+
571
+ ## Sibling Awareness
572
+ Your context includes files modified by sibling tasks (in "Previous Task Completions").
573
+ Before writing a file:
574
+ - Check if it appears in previous task completions \u2192 if yes, read_file first, then patch_file
575
+ - NEVER blindly overwrite files your siblings created
576
+ - If you need to extend a sibling's work, READ their output first and build on it`
522
577
  };
523
578
  var CAP_VERIFICATION = {
524
579
  name: "verification",
@@ -403,10 +403,10 @@ var React4 = require("react");
403
403
  var { useState: useState2 } = React4;
404
404
  var { Flex: Flex4, Typography: Typography4, Icon: Icon2, StatusIcon: StatusIcon2, Chip, ScrollArea, Badge, EmptyState } = require("@fw/plugin-ui-kit");
405
405
  var statusToIcon = {
406
+ "open": "pending",
406
407
  "pending": "pending",
407
408
  "in-progress": "running",
408
409
  "done": "completed",
409
- "failed": "failed",
410
410
  "blocked": "pending",
411
411
  "cancelled": "failed"
412
412
  };
@@ -854,18 +854,18 @@ var {
854
854
  useEventStream
855
855
  } = require("@fw/plugin-ui-kit");
856
856
  var statusToIcon2 = {
857
+ "open": "pending",
857
858
  "pending": "pending",
858
859
  "in-progress": "running",
859
860
  "done": "completed",
860
- "failed": "failed",
861
861
  "blocked": "pending",
862
862
  "cancelled": "failed"
863
863
  };
864
864
  var statusToLabel2 = {
865
- "pending": "Pending",
866
- "in-progress": "In Progress",
865
+ "open": "Open",
866
+ "pending": "Queued",
867
+ "in-progress": "Running",
867
868
  "done": "Done",
868
- "failed": "Failed",
869
869
  "blocked": "Blocked",
870
870
  "cancelled": "Cancelled"
871
871
  };
@@ -1272,9 +1272,9 @@ function TaskDetailView({ taskId, onBack, onEdit }) {
1272
1272
  Flex5,
1273
1273
  { variant: "row-center-start-wrap-6" },
1274
1274
  React6.createElement(Chip2, {
1275
- label: statusToLabel2[task.status] || task.status || "pending",
1275
+ label: statusToLabel2[task.status] || task.status || "open",
1276
1276
  size: "small",
1277
- color: task.status === "done" ? "color-status-positive" : task.status === "failed" ? "color-status-negative" : task.status === "in-progress" ? "color-status-info" : task.status === "blocked" ? "color-status-caution" : "color-brand-alt"
1277
+ color: task.status === "done" ? "color-status-positive" : task.status === "cancelled" ? "color-status-negative" : task.status === "in-progress" ? "color-status-info" : task.status === "blocked" ? "color-status-caution" : "color-brand-alt"
1278
1278
  }),
1279
1279
  task.assignedProfile && React6.createElement(Chip2, { key: `profile-${task.assignedProfile}`, label: task.assignedProfile, size: "small", color: "color-status-info" }),
1280
1280
  task.priority > 0 && React6.createElement(Chip2, {
@@ -1282,10 +1282,10 @@ function TaskDetailView({ taskId, onBack, onEdit }) {
1282
1282
  size: "small",
1283
1283
  color: task.priority >= 3 ? "color-status-caution" : "color-status-info"
1284
1284
  }),
1285
- task.attempt != null && task.maxAttempts != null && React6.createElement(Typography5, {
1285
+ task.maxAttempts != null && task.maxAttempts > 1 && React6.createElement(Typography5, {
1286
1286
  variant: "smallCaption-regular",
1287
1287
  color: "color-text-subtle"
1288
- }, `Attempt ${task.attempt}/${task.maxAttempts}`)
1288
+ }, `${task.runs?.length ?? 0}/${task.maxAttempts} runs`)
1289
1289
  ),
1290
1290
  // Description
1291
1291
  task.description && React6.createElement(Typography5, {
@@ -1400,7 +1400,7 @@ function TaskDetailView({ taskId, onBack, onEdit }) {
1400
1400
  React6.createElement(
1401
1401
  Flex5,
1402
1402
  { variant: "row-center-start-nowrap-6" },
1403
- (task.status === "failed" || task.status === "open" && task.attempt >= task.maxAttempts) && React6.createElement(Button2, {
1403
+ task.status === "open" && (task.attempt ?? 0) > 0 && React6.createElement(Button2, {
1404
1404
  size: "xs",
1405
1405
  variant: "fill",
1406
1406
  color: "primary",
@@ -1408,7 +1408,7 @@ function TaskDetailView({ taskId, onBack, onEdit }) {
1408
1408
  loading: actionLoading === "retry",
1409
1409
  disabled: !!actionLoading
1410
1410
  }, "Retry Task"),
1411
- (task.status === "pending" || task.status === "in-progress" || task.status === "blocked") && React6.createElement(Button2, {
1411
+ (task.status === "open" || task.status === "pending" || task.status === "in-progress" || task.status === "blocked") && React6.createElement(Button2, {
1412
1412
  size: "xs",
1413
1413
  variant: "outlined",
1414
1414
  color: "danger",
@@ -1663,11 +1663,11 @@ var COMPLEXITY_OPTIONS = [
1663
1663
  { id: "complex", label: "Complex" }
1664
1664
  ];
1665
1665
  var STATUS_COLOR = {
1666
+ "open": "color-brand-alt",
1666
1667
  "pending": "color-brand-alt",
1667
1668
  "in-progress": "color-status-info",
1668
1669
  "blocked": "color-status-caution",
1669
1670
  "done": "color-status-positive",
1670
- "failed": "color-status-negative",
1671
1671
  "cancelled": "color-status-negative"
1672
1672
  };
1673
1673
  function TaskEditor({ mode, taskId, onSave, onCancel, onDelete }) {
@@ -2744,6 +2744,7 @@ Do NOT describe what you would do \u2014 actually do it by calling tools.
2744
2744
 
2745
2745
  ## Safety Rules
2746
2746
  - Writes that shrink a file by >50% or write empty content are automatically BLOCKED.
2747
+ - NEVER write empty or placeholder files. Every write_file call MUST contain complete, meaningful content.
2747
2748
  - Blocked shell commands: rm -rf, git push, npm publish, sudo, curl|sh.
2748
2749
  - Always validate BEFORE and AFTER patching.
2749
2750
  - Always read a file before patching it (you need exact strings for find/replace).
@@ -2760,8 +2761,8 @@ You DECOMPOSE and ASSIGN. You never write code or create files directly.
2760
2761
  Your job:
2761
2762
  1. Analyze the objective
2762
2763
  2. Break it into focused subtasks via task_create. Set parentId to "@self" on every subtask.
2763
- 3. ALWAYS set assignedProfile: "developer", "reviewer", or "ops".
2764
- NEVER set assignedProfile to "orchestrator" \u2014 assigning to yourself creates an infinite loop.
2764
+ 3. ALWAYS set assignedProfile: "developer", "reviewer", or "ops" for work tasks.
2765
+ The ONLY exception: your final "Verify & Iterate" task should be assignedProfile: "orchestrator".
2765
2766
  4. Use the EXACT title of a previous subtask as dependsOn. The system resolves titles to real task IDs.
2766
2767
  5. Include a project brief in every subtask: "PROJECT: [what]. FILES: [exact paths from workspace root]. CONVENTIONS: [patterns]."
2767
2768
 
@@ -2775,11 +2776,35 @@ Every subsequent developer task MUST read .design.md before writing code.
2775
2776
 
2776
2777
  ### Subtask Quality
2777
2778
  Each subtask: focused (one concern), self-contained, properly routed, ordered by dependsOn.
2779
+ - If an implementation task covers more than 2 files, SPLIT IT. Each task should produce 1-2 files max.
2780
+ - Design/architecture tasks \u2192 assignedProfile: "developer" (not ops). Ops is for infra only.
2781
+ - Add scope boundaries: "You may ONLY create/modify these files: [list]."
2782
+
2783
+ ### Maximize Parallelism
2784
+ - Minimize dependencies. Tasks that don't share files should NOT depend on each other.
2785
+ - Design and Setup can often run in parallel (setup doesn't need .design.md to create boilerplate).
2786
+ - Aim for at least 2 tasks that can run in parallel. If all tasks are serial, reconsider.
2787
+ - BAD: A \u2192 B \u2192 C \u2192 D (serial, slow)
2788
+ - GOOD: A \u2192 [B + C + D] \u2192 E (A blocks all, B/C/D run in parallel, E waits for all)
2789
+
2790
+ ### Build Verification Gate
2791
+ After implementation tasks, create a verification task (ops profile) that runs \`tsc --noEmit\`.
2792
+ This catches compilation errors before tests run, saving time and token spend.
2793
+
2794
+ ### Verify & Iterate Loop
2795
+ Your LAST subtask MUST be a "Verify & Iterate" task assigned to yourself (orchestrator):
2796
+ - dependsOn: ALL other subtasks
2797
+ - When it runs: review all task results, check for failures, gaps, or quality issues
2798
+ - If everything passes: signal done
2799
+ - If issues found: create fix tasks + another verify gate
2800
+ This creates a self-correcting loop: plan \u2192 execute \u2192 verify \u2192 fix \u2192 verify \u2192 done.
2778
2801
 
2779
2802
  ### Example
2780
- { operation: "task_create", args: { title: "Design: Create project contract", parentId: "@self", assignedProfile: "ops", complexity: "complex", description: "Create todo-app/.design.md with module map, TypeScript interfaces, export contracts.", dependsOn: [] } }
2781
- { operation: "task_create", args: { title: "Setup project", parentId: "@self", assignedProfile: "ops", dependsOn: ["Design: Create project contract"] } }
2782
- { operation: "task_create", args: { title: "Write code", parentId: "@self", assignedProfile: "developer", dependsOn: ["Setup project"] } }`
2803
+ { operation: "task_create", args: { title: "Design: Create project contract", parentId: "@self", assignedProfile: "developer", complexity: "moderate", description: "Create .design.md with interfaces and contracts.", dependsOn: [] } }
2804
+ { operation: "task_create", args: { title: "Setup project", parentId: "@self", assignedProfile: "ops", dependsOn: [] } }
2805
+ { operation: "task_create", args: { title: "Implement storage module", parentId: "@self", assignedProfile: "developer", dependsOn: ["Design: Create project contract", "Setup project"], description: "You may ONLY create: src/types.ts, src/storage.ts" } }
2806
+ { operation: "task_create", args: { title: "Implement HTTP server", parentId: "@self", assignedProfile: "developer", dependsOn: ["Implement storage module"], description: "You may ONLY create: src/server.ts" } }
2807
+ { operation: "task_create", args: { title: "Verify & Iterate", parentId: "@self", assignedProfile: "orchestrator", dependsOn: ["Implement HTTP server"], description: "Review all task results. If issues found, create fix tasks. If all good, signal done." } }`
2783
2808
  };
2784
2809
  var CAP_ROLE_DEVELOPER = {
2785
2810
  name: "role-developer",
@@ -2799,6 +2824,18 @@ If the task seems too large, do your best \u2014 the orchestrator already decomp
2799
2824
  ### File Paths
2800
2825
  All paths in write_file/patch_file are RELATIVE TO THE WORKSPACE ROOT. If the task says "inside todo-app/", your paths MUST start with todo-app/ (e.g., todo-app/src/cli.ts, NOT src/cli.ts).
2801
2826
 
2827
+ ### Write Protocol
2828
+ Before writing ANY file:
2829
+ 1. list_files to check if the file already exists
2830
+ 2. If it exists \u2192 read_file, then patch_file with targeted changes
2831
+ 3. If it does NOT exist \u2192 write_file with COMPLETE content
2832
+ Never call write_file on a file that already exists \u2014 the shrink guard will block you and waste a tool call.
2833
+
2834
+ ### Sibling Awareness
2835
+ Your context may include files modified by sibling tasks. Before writing a file:
2836
+ - Check "Previous Task Completions" \u2192 if a sibling already created it, READ it first, then patch_file
2837
+ - Never blindly overwrite files your siblings created
2838
+
2802
2839
  ### Code Quality
2803
2840
  - Write COMPLETE, WORKING code. No TODOs, no placeholders, no empty function bodies, no "// implement later".
2804
2841
  - Every function must be fully implemented with real logic.
@@ -2862,7 +2899,14 @@ var CAP_FILE_OPS = {
2862
2899
  PREFER patch_file over write_file for modifying existing files (surgical edits, no truncation risk).
2863
2900
  Use read_file to understand a file before modifying it.
2864
2901
  Use list_files to discover project structure.
2865
- Writes that shrink a file by >50% or write empty content are automatically BLOCKED.`
2902
+
2903
+ ## Write Protocol
2904
+ Before writing ANY file:
2905
+ 1. Use list_files to check if the file already exists
2906
+ 2. If it EXISTS \u2192 read_file first, then patch_file with targeted changes
2907
+ 3. If it does NOT exist \u2192 write_file with COMPLETE content
2908
+ NEVER call write_file on a file that already exists \u2014 use patch_file instead.
2909
+ Empty content and writes that shrink an existing file by >50% are automatically BLOCKED and waste a tool call.`
2866
2910
  };
2867
2911
  var CAP_SHELL = {
2868
2912
  name: "shell",
@@ -2984,8 +3028,9 @@ var CAP_CODE_REVIEW = {
2984
3028
  tools: [OP_READ_FILE, OP_PATCH_FILE, OP_RUN_SHELL],
2985
3029
  prompt: `## Code Review Checklist
2986
3030
 
2987
- ### 1. Correctness
3031
+ ### 1. Correctness & Contract Compliance
2988
3032
  - Does the code do what the task asked?
3033
+ - If .design.md exists, verify: exported functions match contracts, interface shapes match, error behavior matches spec
2989
3034
  - Edge cases handled (empty input, null, invalid types)?
2990
3035
  - Error paths covered (try/catch, validation)?
2991
3036
  - Return types match function signature?
@@ -2997,16 +3042,19 @@ var CAP_CODE_REVIEW = {
2997
3042
  - User input validated and sanitized before use
2998
3043
  - File paths validated (no ../ traversal)
2999
3044
 
3000
- ### 3. Style
3045
+ ### 3. Style & Dead Code
3001
3046
  - Naming is clear and consistent with project conventions
3002
- - No dead code (unused variables, unreachable branches)
3047
+ - No dead code (unused variables, unreachable branches, duplicated functions across files)
3048
+ - No duplicated logic \u2014 if two files define the same function, flag it
3003
3049
  - No debug statements left in (console.log, debugger)
3004
- - Imports organized, no duplicates
3050
+ - Imports organized, no duplicates, no unused imports
3005
3051
 
3006
3052
  ### 4. Testing
3007
3053
  - Unit tests exist for new/changed functions
3008
3054
  - Tests cover happy path AND edge cases
3009
3055
  - Error cases have tests
3056
+ - Test isolation: state reset between tests, server handles returned and closed in afterEach
3057
+ - No order-dependent tests (each test must pass in isolation)
3010
3058
  - Code coverage adequate (aim for 80%+ of changed code)
3011
3059
 
3012
3060
  ### 5. Performance
@@ -3025,11 +3073,18 @@ var CAP_WEB = {
3025
3073
  };
3026
3074
  var CAP_CONTEXT = {
3027
3075
  name: "context",
3028
- description: "Project file listings, directory structure, and workspace context.",
3076
+ description: "Project file listings, directory structure, workspace context, and sibling task awareness.",
3029
3077
  prompt: `## Project Context
3030
3078
 
3031
3079
  Use list_files to understand the project structure before making changes.
3032
- The context bundle (when available) provides a snapshot of the workspace.`
3080
+ The context bundle (when available) provides a snapshot of the workspace.
3081
+
3082
+ ## Sibling Awareness
3083
+ Your context includes files modified by sibling tasks (in "Previous Task Completions").
3084
+ Before writing a file:
3085
+ - Check if it appears in previous task completions \u2192 if yes, read_file first, then patch_file
3086
+ - NEVER blindly overwrite files your siblings created
3087
+ - If you need to extend a sibling's work, READ their output first and build on it`
3033
3088
  };
3034
3089
  var CAP_VERIFICATION = {
3035
3090
  name: "verification",
@@ -348,18 +348,18 @@ var {
348
348
  useEventStream
349
349
  } = require("@fw/plugin-ui-kit");
350
350
  var statusToIcon = {
351
+ "open": "pending",
351
352
  "pending": "pending",
352
353
  "in-progress": "running",
353
354
  "done": "completed",
354
- "failed": "failed",
355
355
  "blocked": "pending",
356
356
  "cancelled": "failed"
357
357
  };
358
358
  var statusToLabel = {
359
- "pending": "Pending",
360
- "in-progress": "In Progress",
359
+ "open": "Open",
360
+ "pending": "Queued",
361
+ "in-progress": "Running",
361
362
  "done": "Done",
362
- "failed": "Failed",
363
363
  "blocked": "Blocked",
364
364
  "cancelled": "Cancelled"
365
365
  };
@@ -766,9 +766,9 @@ function TaskDetailView({ taskId, onBack, onEdit }) {
766
766
  Flex,
767
767
  { variant: "row-center-start-wrap-6" },
768
768
  React2.createElement(Chip, {
769
- label: statusToLabel[task.status] || task.status || "pending",
769
+ label: statusToLabel[task.status] || task.status || "open",
770
770
  size: "small",
771
- color: task.status === "done" ? "color-status-positive" : task.status === "failed" ? "color-status-negative" : task.status === "in-progress" ? "color-status-info" : task.status === "blocked" ? "color-status-caution" : "color-brand-alt"
771
+ color: task.status === "done" ? "color-status-positive" : task.status === "cancelled" ? "color-status-negative" : task.status === "in-progress" ? "color-status-info" : task.status === "blocked" ? "color-status-caution" : "color-brand-alt"
772
772
  }),
773
773
  task.assignedProfile && React2.createElement(Chip, { key: `profile-${task.assignedProfile}`, label: task.assignedProfile, size: "small", color: "color-status-info" }),
774
774
  task.priority > 0 && React2.createElement(Chip, {
@@ -776,10 +776,10 @@ function TaskDetailView({ taskId, onBack, onEdit }) {
776
776
  size: "small",
777
777
  color: task.priority >= 3 ? "color-status-caution" : "color-status-info"
778
778
  }),
779
- task.attempt != null && task.maxAttempts != null && React2.createElement(Typography, {
779
+ task.maxAttempts != null && task.maxAttempts > 1 && React2.createElement(Typography, {
780
780
  variant: "smallCaption-regular",
781
781
  color: "color-text-subtle"
782
- }, `Attempt ${task.attempt}/${task.maxAttempts}`)
782
+ }, `${task.runs?.length ?? 0}/${task.maxAttempts} runs`)
783
783
  ),
784
784
  // Description
785
785
  task.description && React2.createElement(Typography, {
@@ -894,7 +894,7 @@ function TaskDetailView({ taskId, onBack, onEdit }) {
894
894
  React2.createElement(
895
895
  Flex,
896
896
  { variant: "row-center-start-nowrap-6" },
897
- (task.status === "failed" || task.status === "open" && task.attempt >= task.maxAttempts) && React2.createElement(Button, {
897
+ task.status === "open" && (task.attempt ?? 0) > 0 && React2.createElement(Button, {
898
898
  size: "xs",
899
899
  variant: "fill",
900
900
  color: "primary",
@@ -902,7 +902,7 @@ function TaskDetailView({ taskId, onBack, onEdit }) {
902
902
  loading: actionLoading === "retry",
903
903
  disabled: !!actionLoading
904
904
  }, "Retry Task"),
905
- (task.status === "pending" || task.status === "in-progress" || task.status === "blocked") && React2.createElement(Button, {
905
+ (task.status === "open" || task.status === "pending" || task.status === "in-progress" || task.status === "blocked") && React2.createElement(Button, {
906
906
  size: "xs",
907
907
  variant: "outlined",
908
908
  color: "danger",