@synergenius/flow-weaver-pack-weaver 0.9.140 → 0.9.144
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bot/assistant-tools.d.ts.map +1 -1
- package/dist/bot/assistant-tools.js +5 -11
- package/dist/bot/assistant-tools.js.map +1 -1
- package/dist/bot/behavior-defaults.d.ts +2 -2
- package/dist/bot/behavior-defaults.d.ts.map +1 -1
- package/dist/bot/behavior-defaults.js +11 -6
- package/dist/bot/behavior-defaults.js.map +1 -1
- package/dist/bot/capability-registry.d.ts +2 -0
- package/dist/bot/capability-registry.d.ts.map +1 -1
- package/dist/bot/capability-registry.js +282 -15
- package/dist/bot/capability-registry.js.map +1 -1
- package/dist/bot/dashboard.js +3 -3
- package/dist/bot/dashboard.js.map +1 -1
- package/dist/bot/hierarchy-event-log.d.ts +37 -0
- package/dist/bot/hierarchy-event-log.d.ts.map +1 -0
- package/dist/bot/hierarchy-event-log.js +58 -0
- package/dist/bot/hierarchy-event-log.js.map +1 -0
- package/dist/bot/operations.d.ts +2 -0
- package/dist/bot/operations.d.ts.map +1 -1
- package/dist/bot/operations.js +5 -0
- package/dist/bot/operations.js.map +1 -1
- package/dist/bot/profile-store.d.ts.map +1 -1
- package/dist/bot/profile-store.js +46 -0
- package/dist/bot/profile-store.js.map +1 -1
- package/dist/bot/runner.d.ts.map +1 -1
- package/dist/bot/runner.js +51 -16
- package/dist/bot/runner.js.map +1 -1
- package/dist/bot/step-executor.d.ts.map +1 -1
- package/dist/bot/step-executor.js +36 -1
- package/dist/bot/step-executor.js.map +1 -1
- package/dist/bot/swarm-controller.d.ts +1 -0
- package/dist/bot/swarm-controller.d.ts.map +1 -1
- package/dist/bot/swarm-controller.js +64 -6
- package/dist/bot/swarm-controller.js.map +1 -1
- package/dist/bot/task-store.d.ts +1 -1
- package/dist/bot/task-store.d.ts.map +1 -1
- package/dist/bot/task-store.js +21 -36
- package/dist/bot/task-store.js.map +1 -1
- package/dist/bot/task-types.d.ts +5 -1
- package/dist/bot/task-types.d.ts.map +1 -1
- package/dist/bot/types.d.ts +4 -0
- package/dist/bot/types.d.ts.map +1 -1
- package/dist/node-types/bot-report.d.ts +3 -1
- package/dist/node-types/bot-report.d.ts.map +1 -1
- package/dist/node-types/bot-report.js +62 -11
- package/dist/node-types/bot-report.js.map +1 -1
- package/dist/node-types/build-context.d.ts.map +1 -1
- package/dist/node-types/build-context.js +32 -0
- package/dist/node-types/build-context.js.map +1 -1
- package/dist/node-types/report.d.ts +2 -0
- package/dist/node-types/report.d.ts.map +1 -1
- package/dist/node-types/report.js +61 -7
- package/dist/node-types/report.js.map +1 -1
- package/dist/ui/capability-editor.js +268 -15
- package/dist/ui/profile-editor.js +271 -18
- package/dist/ui/swarm-dashboard.js +340 -51
- package/dist/ui/task-detail-view.js +69 -33
- package/dist/ui/trace-to-timeline.d.ts +2 -0
- package/dist/ui/trace-to-timeline.d.ts.map +1 -1
- package/dist/ui/trace-to-timeline.js.map +1 -1
- package/dist/ui/use-stream-timeline.d.ts +2 -0
- package/dist/ui/use-stream-timeline.d.ts.map +1 -1
- package/dist/ui/use-stream-timeline.js +76 -34
- package/dist/ui/use-stream-timeline.js.map +1 -1
- package/flowweaver.manifest.json +1 -1
- package/package.json +1 -1
- package/src/bot/assistant-tools.ts +5 -11
- package/src/bot/behavior-defaults.ts +12 -5
- package/src/bot/capability-registry.ts +300 -18
- package/src/bot/dashboard.ts +3 -3
- package/src/bot/hierarchy-event-log.ts +64 -0
- package/src/bot/operations.ts +7 -0
- package/src/bot/profile-store.ts +46 -0
- package/src/bot/runner.ts +51 -16
- package/src/bot/step-executor.ts +32 -1
- package/src/bot/swarm-controller.ts +67 -6
- package/src/bot/task-store.ts +22 -38
- package/src/bot/task-types.ts +7 -1
- package/src/bot/types.ts +4 -0
- package/src/node-types/bot-report.ts +63 -12
- package/src/node-types/build-context.ts +32 -0
- package/src/node-types/report.ts +60 -8
- package/src/ui/task-detail-view.tsx +3 -0
- package/src/ui/trace-to-timeline.ts +2 -0
- package/src/ui/use-stream-timeline.ts +81 -38
|
@@ -556,6 +556,7 @@ function useStreamTimeline(events, isDone) {
|
|
|
556
556
|
const entries = [];
|
|
557
557
|
const nodeEntryIndex = /* @__PURE__ */ new Map();
|
|
558
558
|
const nodeStarts = /* @__PURE__ */ new Map();
|
|
559
|
+
const completedNodes = /* @__PURE__ */ new Set();
|
|
559
560
|
let idCounter = 0;
|
|
560
561
|
for (const event of events) {
|
|
561
562
|
const d = event.data ?? {};
|
|
@@ -572,6 +573,11 @@ function useStreamTimeline(events, isDone) {
|
|
|
572
573
|
case "node-start": {
|
|
573
574
|
const nodeId = d.nodeId;
|
|
574
575
|
if (nodeId) nodeStarts.set(nodeId, event.timestamp);
|
|
576
|
+
const existingStartIdx = nodeEntryIndex.get(nodeId);
|
|
577
|
+
if (existingStartIdx != null && entries[existingStartIdx]?.type === "node-started") {
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
completedNodes.delete(nodeId);
|
|
575
581
|
const idx = entries.length;
|
|
576
582
|
nodeEntryIndex.set(nodeId, idx);
|
|
577
583
|
entries.push({
|
|
@@ -587,54 +593,79 @@ function useStreamTimeline(events, isDone) {
|
|
|
587
593
|
}
|
|
588
594
|
case "node-complete": {
|
|
589
595
|
const nodeId = d.nodeId;
|
|
596
|
+
if (completedNodes.has(nodeId)) break;
|
|
590
597
|
const startTs = nodeStarts.get(nodeId);
|
|
591
598
|
const duration = d.durationMs ?? (startTs ? event.timestamp - startTs : void 0);
|
|
592
599
|
if (nodeId) nodeStarts.delete(nodeId);
|
|
593
|
-
|
|
594
|
-
const completed = {
|
|
595
|
-
id: `s-${idCounter++}`,
|
|
596
|
-
timestamp: new Date(startTs ?? event.timestamp),
|
|
597
|
-
type: "node-completed",
|
|
598
|
-
nodeId,
|
|
599
|
-
label: d.label ?? d.nodeType ?? nodeId ?? "Node",
|
|
600
|
-
duration,
|
|
601
|
-
color: d.color,
|
|
602
|
-
icon: d.icon,
|
|
603
|
-
outputs: rawOutputs && rawOutputs.length > 0 ? rawOutputs : void 0
|
|
604
|
-
};
|
|
600
|
+
completedNodes.add(nodeId);
|
|
605
601
|
const existingIdx = nodeEntryIndex.get(nodeId);
|
|
606
602
|
if (existingIdx != null && entries[existingIdx]) {
|
|
607
|
-
|
|
603
|
+
const rawOutputs = d.outputs;
|
|
604
|
+
entries[existingIdx] = {
|
|
605
|
+
id: entries[existingIdx].id,
|
|
606
|
+
timestamp: new Date(startTs ?? event.timestamp),
|
|
607
|
+
type: "node-completed",
|
|
608
|
+
nodeId,
|
|
609
|
+
label: d.label ?? d.nodeType ?? nodeId ?? "Node",
|
|
610
|
+
duration,
|
|
611
|
+
color: d.color,
|
|
612
|
+
icon: d.icon,
|
|
613
|
+
outputs: rawOutputs && rawOutputs.length > 0 ? rawOutputs : void 0
|
|
614
|
+
};
|
|
608
615
|
nodeEntryIndex.delete(nodeId);
|
|
609
616
|
} else {
|
|
610
|
-
|
|
617
|
+
const rawOutputs = d.outputs;
|
|
618
|
+
entries.push({
|
|
619
|
+
id: `s-${idCounter++}`,
|
|
620
|
+
timestamp: new Date(startTs ?? event.timestamp),
|
|
621
|
+
type: "node-completed",
|
|
622
|
+
nodeId,
|
|
623
|
+
label: d.label ?? d.nodeType ?? nodeId ?? "Node",
|
|
624
|
+
duration,
|
|
625
|
+
color: d.color,
|
|
626
|
+
icon: d.icon,
|
|
627
|
+
outputs: rawOutputs && rawOutputs.length > 0 ? rawOutputs : void 0
|
|
628
|
+
});
|
|
611
629
|
}
|
|
612
630
|
break;
|
|
613
631
|
}
|
|
614
632
|
case "node-error": {
|
|
615
633
|
const nodeId = d.nodeId;
|
|
634
|
+
if (completedNodes.has(nodeId)) break;
|
|
616
635
|
const startTs = nodeStarts.get(nodeId);
|
|
617
636
|
const duration = d.durationMs ?? (startTs ? event.timestamp - startTs : void 0);
|
|
618
637
|
if (nodeId) nodeStarts.delete(nodeId);
|
|
619
|
-
|
|
620
|
-
const failed = {
|
|
621
|
-
id: `s-${idCounter++}`,
|
|
622
|
-
timestamp: new Date(startTs ?? event.timestamp),
|
|
623
|
-
type: "node-failed",
|
|
624
|
-
nodeId,
|
|
625
|
-
label: d.label ?? d.nodeType ?? nodeId ?? "Node",
|
|
626
|
-
detail: d.error,
|
|
627
|
-
duration,
|
|
628
|
-
color: d.color,
|
|
629
|
-
icon: d.icon,
|
|
630
|
-
outputs: rawOutputs && rawOutputs.length > 0 ? rawOutputs : void 0
|
|
631
|
-
};
|
|
638
|
+
completedNodes.add(nodeId);
|
|
632
639
|
const existingIdx = nodeEntryIndex.get(nodeId);
|
|
633
640
|
if (existingIdx != null && entries[existingIdx]) {
|
|
634
|
-
|
|
641
|
+
const rawOutputs = d.outputs;
|
|
642
|
+
entries[existingIdx] = {
|
|
643
|
+
id: entries[existingIdx].id,
|
|
644
|
+
timestamp: new Date(startTs ?? event.timestamp),
|
|
645
|
+
type: "node-failed",
|
|
646
|
+
nodeId,
|
|
647
|
+
label: d.label ?? d.nodeType ?? nodeId ?? "Node",
|
|
648
|
+
detail: d.error,
|
|
649
|
+
duration,
|
|
650
|
+
color: d.color,
|
|
651
|
+
icon: d.icon,
|
|
652
|
+
outputs: rawOutputs && rawOutputs.length > 0 ? rawOutputs : void 0
|
|
653
|
+
};
|
|
635
654
|
nodeEntryIndex.delete(nodeId);
|
|
636
655
|
} else {
|
|
637
|
-
|
|
656
|
+
const rawOutputs = d.outputs;
|
|
657
|
+
entries.push({
|
|
658
|
+
id: `s-${idCounter++}`,
|
|
659
|
+
timestamp: new Date(startTs ?? event.timestamp),
|
|
660
|
+
type: "node-failed",
|
|
661
|
+
nodeId,
|
|
662
|
+
label: d.label ?? d.nodeType ?? nodeId ?? "Node",
|
|
663
|
+
detail: d.error,
|
|
664
|
+
duration,
|
|
665
|
+
color: d.color,
|
|
666
|
+
icon: d.icon,
|
|
667
|
+
outputs: rawOutputs && rawOutputs.length > 0 ? rawOutputs : void 0
|
|
668
|
+
});
|
|
638
669
|
}
|
|
639
670
|
break;
|
|
640
671
|
}
|
|
@@ -663,12 +694,13 @@ function useStreamTimeline(events, isDone) {
|
|
|
663
694
|
}
|
|
664
695
|
return entries;
|
|
665
696
|
}, [events]);
|
|
666
|
-
const { phase, instruction, cost, plan, awaitingApproval } = useMemo(() => {
|
|
697
|
+
const { phase, instruction, cost, plan, awaitingApproval, report } = useMemo(() => {
|
|
667
698
|
let phase2 = "idle";
|
|
668
699
|
let instruction2 = null;
|
|
669
700
|
let cost2 = null;
|
|
670
701
|
let plan2 = null;
|
|
671
702
|
let awaitingApproval2 = false;
|
|
703
|
+
let report2 = null;
|
|
672
704
|
for (const event of events) {
|
|
673
705
|
const d = event.data ?? {};
|
|
674
706
|
if (event.type === "bot-started") {
|
|
@@ -678,6 +710,7 @@ function useStreamTimeline(events, isDone) {
|
|
|
678
710
|
phase2 = "executing";
|
|
679
711
|
} else if (event.type === "bot-completed") {
|
|
680
712
|
phase2 = d.success ? "completed" : "failed";
|
|
713
|
+
if (typeof d.report === "string") report2 = d.report;
|
|
681
714
|
} else if (event.type === "bot-failed") {
|
|
682
715
|
phase2 = "failed";
|
|
683
716
|
} else if (event.type === "cost-update") {
|
|
@@ -698,9 +731,9 @@ function useStreamTimeline(events, isDone) {
|
|
|
698
731
|
if (isDone && phase2 !== "completed" && phase2 !== "failed") {
|
|
699
732
|
phase2 = "completed";
|
|
700
733
|
}
|
|
701
|
-
return { phase: phase2, instruction: instruction2, cost: cost2, plan: plan2, awaitingApproval: awaitingApproval2 };
|
|
734
|
+
return { phase: phase2, instruction: instruction2, cost: cost2, plan: plan2, awaitingApproval: awaitingApproval2, report: report2 };
|
|
702
735
|
}, [events, isDone]);
|
|
703
|
-
return { timeline, phase, instruction, elapsed, cost, plan, awaitingApproval };
|
|
736
|
+
return { timeline, phase, instruction, elapsed, cost, plan, awaitingApproval, report };
|
|
704
737
|
}
|
|
705
738
|
|
|
706
739
|
// src/ui/trace-to-timeline.ts
|
|
@@ -957,7 +990,8 @@ function TaskDetailView({ taskId, onBack, onEdit }) {
|
|
|
957
990
|
elapsed,
|
|
958
991
|
cost: liveCost,
|
|
959
992
|
plan,
|
|
960
|
-
awaitingApproval
|
|
993
|
+
awaitingApproval,
|
|
994
|
+
report: liveReport
|
|
961
995
|
} = useStreamTimeline(stream.events, stream.isDone);
|
|
962
996
|
const currentRunId = task?.currentRunId;
|
|
963
997
|
const isLive = task?.status === "in-progress" && !!currentRunId;
|
|
@@ -1285,6 +1319,7 @@ function TaskDetailView({ taskId, onBack, onEdit }) {
|
|
|
1285
1319
|
state: isSuccess ? "completed" : "failed",
|
|
1286
1320
|
instruction: extractInstruction(run),
|
|
1287
1321
|
timeline: runTimeline,
|
|
1322
|
+
report: run.report ?? null,
|
|
1288
1323
|
cost: typeof run.cost === "number" ? run.cost : run.costDetail?.totalCost ?? null,
|
|
1289
1324
|
plan: run.plan,
|
|
1290
1325
|
startedAt: run.startedAt,
|
|
@@ -1299,6 +1334,7 @@ function TaskDetailView({ taskId, onBack, onEdit }) {
|
|
|
1299
1334
|
state: "running",
|
|
1300
1335
|
instruction: liveInstruction ?? task.title,
|
|
1301
1336
|
timeline: liveTimeline,
|
|
1337
|
+
report: liveReport,
|
|
1302
1338
|
phase: livePhase,
|
|
1303
1339
|
elapsed,
|
|
1304
1340
|
cost: liveCost,
|
|
@@ -2672,6 +2708,8 @@ var OP_VALIDATE = "validate";
|
|
|
2672
2708
|
var OP_TSC_CHECK = "tsc_check";
|
|
2673
2709
|
var OP_RUN_TESTS = "run_tests";
|
|
2674
2710
|
var OP_TASK_CREATE = "task_create";
|
|
2711
|
+
var OP_REMEMBER = "remember";
|
|
2712
|
+
var OP_RECALL = "recall";
|
|
2675
2713
|
|
|
2676
2714
|
// src/bot/capability-registry.ts
|
|
2677
2715
|
var CAP_CORE = {
|
|
@@ -2692,6 +2730,84 @@ Do NOT describe what you would do \u2014 actually do it by calling tools.
|
|
|
2692
2730
|
- Use patch_file for modifications, write_file only for new files.
|
|
2693
2731
|
- Be concise \u2014 let tool results speak.`
|
|
2694
2732
|
};
|
|
2733
|
+
var CAP_ROLE_ORCHESTRATOR = {
|
|
2734
|
+
name: "role-orchestrator",
|
|
2735
|
+
description: "Orchestrator role: decomposes objectives into tasks, assigns profiles, creates project briefs.",
|
|
2736
|
+
tools: [OP_TASK_CREATE, OP_LIST_FILES, OP_READ_FILE],
|
|
2737
|
+
prompt: `## YOUR ROLE: Orchestrator
|
|
2738
|
+
You DECOMPOSE and ASSIGN. You never write code or create files directly.
|
|
2739
|
+
|
|
2740
|
+
Your job:
|
|
2741
|
+
1. Analyze the objective and understand the project scope
|
|
2742
|
+
2. Create a PROJECT BRIEF (a concise description of what we're building, how pieces connect, conventions to follow)
|
|
2743
|
+
3. Break the objective into focused subtasks using task_create
|
|
2744
|
+
4. ALWAYS set assignedProfile on every subtask:
|
|
2745
|
+
- Code writing, file creation \u2192 "developer"
|
|
2746
|
+
- Code review, quality checks \u2192 "reviewer"
|
|
2747
|
+
- Project setup, dependencies, config \u2192 "ops"
|
|
2748
|
+
5. Set dependencies so tasks execute in the right order
|
|
2749
|
+
6. Include the project brief in every subtask's description
|
|
2750
|
+
|
|
2751
|
+
You do NOT have write_file, patch_file, or run_shell. You cannot execute \u2014 only plan and delegate.
|
|
2752
|
+
|
|
2753
|
+
### Project Brief Format
|
|
2754
|
+
Include this at the TOP of every subtask description:
|
|
2755
|
+
"PROJECT: [what we're building]. STRUCTURE: [file layout]. CONVENTIONS: [naming, patterns, exports]."
|
|
2756
|
+
|
|
2757
|
+
### Subtask Quality
|
|
2758
|
+
Each subtask must be:
|
|
2759
|
+
- Focused (one file or one concern)
|
|
2760
|
+
- Self-contained (has enough context to execute independently)
|
|
2761
|
+
- Properly routed (assignedProfile is set)
|
|
2762
|
+
- Ordered (dependsOn reflects real dependencies)`
|
|
2763
|
+
};
|
|
2764
|
+
var CAP_ROLE_DEVELOPER = {
|
|
2765
|
+
name: "role-developer",
|
|
2766
|
+
description: "Developer role: writes code, creates files, runs commands. Executes directly, never decomposes.",
|
|
2767
|
+
prompt: `## YOUR ROLE: Developer
|
|
2768
|
+
You WRITE CODE. Execute the task directly using write_file, patch_file, and run_shell.
|
|
2769
|
+
|
|
2770
|
+
Your job:
|
|
2771
|
+
1. Read the task description (including the project brief)
|
|
2772
|
+
2. Create a plan with CONCRETE file operations (write_file, patch_file, run_shell)
|
|
2773
|
+
3. Execute every step \u2014 produce actual files on disk
|
|
2774
|
+
4. Verify your work compiles and is correct
|
|
2775
|
+
|
|
2776
|
+
You do NOT have task_create. You cannot create subtasks or delegate.
|
|
2777
|
+
If the task seems too large, do your best \u2014 the orchestrator already decomposed it for you.
|
|
2778
|
+
|
|
2779
|
+
### Output Requirements
|
|
2780
|
+
Your plan MUST include at least one write_file, patch_file, or run_shell step.
|
|
2781
|
+
A plan with only "respond" steps is a FAILURE \u2014 you must produce artifacts.`
|
|
2782
|
+
};
|
|
2783
|
+
var CAP_ROLE_REVIEWER = {
|
|
2784
|
+
name: "role-reviewer",
|
|
2785
|
+
description: "Reviewer role: reads and evaluates code quality, security, correctness.",
|
|
2786
|
+
prompt: `## YOUR ROLE: Reviewer
|
|
2787
|
+
You READ and EVALUATE code. Check quality, security, correctness, and consistency.
|
|
2788
|
+
|
|
2789
|
+
Your job:
|
|
2790
|
+
1. Read the files that were created/modified
|
|
2791
|
+
2. Check against the task description and project conventions
|
|
2792
|
+
3. Report findings with file:line and severity
|
|
2793
|
+
4. Use patch_file to fix minor issues directly
|
|
2794
|
+
5. For major issues, document them clearly in your report
|
|
2795
|
+
|
|
2796
|
+
You do NOT have task_create or write_file. You can only read and patch.`
|
|
2797
|
+
};
|
|
2798
|
+
var CAP_ROLE_OPS = {
|
|
2799
|
+
name: "role-ops",
|
|
2800
|
+
description: "Ops role: sets up project infrastructure, configs, dependencies.",
|
|
2801
|
+
prompt: `## YOUR ROLE: Ops
|
|
2802
|
+
You SET UP infrastructure \u2014 package.json, tsconfig.json, directory structure, dependencies.
|
|
2803
|
+
|
|
2804
|
+
Your job:
|
|
2805
|
+
1. Initialize project structure (create config files, directories)
|
|
2806
|
+
2. Install dependencies with run_shell
|
|
2807
|
+
3. Ensure the project builds and tests can run
|
|
2808
|
+
|
|
2809
|
+
You do NOT have task_create. You execute infrastructure tasks directly.`
|
|
2810
|
+
};
|
|
2695
2811
|
var CAP_FILE_OPS = {
|
|
2696
2812
|
name: "file-ops",
|
|
2697
2813
|
description: "File read/write/patch operations and best practices for file manipulation.",
|
|
@@ -2721,13 +2837,31 @@ Use run_shell for running tests (npx vitest), validation (flow-weaver validate),
|
|
|
2721
2837
|
};
|
|
2722
2838
|
var CAP_TASK_MGMT = {
|
|
2723
2839
|
name: "task-mgmt",
|
|
2724
|
-
description: "Create and manage swarm subtasks for parallel execution.",
|
|
2840
|
+
description: "Create and manage swarm subtasks for parallel execution, with decomposition and review nudges.",
|
|
2725
2841
|
tools: [OP_TASK_CREATE],
|
|
2726
|
-
prompt: `## Task Management
|
|
2727
|
-
|
|
2728
|
-
-
|
|
2842
|
+
prompt: `## Task Management & Decomposition
|
|
2843
|
+
|
|
2844
|
+
- task_create: Create swarm subtasks. args: { title, description, complexity, subtasks[], dependsOn[], assignedProfile? }
|
|
2729
2845
|
|
|
2730
|
-
|
|
2846
|
+
### Decomposition
|
|
2847
|
+
When you encounter a broad objective (multi-file, multi-concern), decompose into subtasks:
|
|
2848
|
+
- If the task is bigger than a single file change, create subtasks instead of doing it all yourself.
|
|
2849
|
+
- Minimize dependencies between subtasks to maximize parallel execution.
|
|
2850
|
+
- Set complexity per subtask: trivial | simple | moderate | complex.
|
|
2851
|
+
- Use dependsOn to express blocking relationships (e.g., setup before code, code before tests).
|
|
2852
|
+
|
|
2853
|
+
### Review Task Creation
|
|
2854
|
+
After creating or modifying multiple files, create a review task:
|
|
2855
|
+
- title: "Review: [what was changed]"
|
|
2856
|
+
- description: List the files modified and what to check
|
|
2857
|
+
- assignedProfile: "reviewer"
|
|
2858
|
+
- complexity: "simple"
|
|
2859
|
+
Skip review for trivial single-file tasks.
|
|
2860
|
+
|
|
2861
|
+
### Dependency Guidelines
|
|
2862
|
+
- BAD: A \u2192 B \u2192 C \u2192 D (serial, slow)
|
|
2863
|
+
- GOOD: A \u2192 [B + C + D] (A blocks all, but B/C/D run in parallel)
|
|
2864
|
+
Structure as: setup \u2192 independent implementations \u2192 integration/testing.`
|
|
2731
2865
|
};
|
|
2732
2866
|
var CAP_FW_GRAMMAR = {
|
|
2733
2867
|
name: "fw-grammar",
|
|
@@ -2805,17 +2939,41 @@ Note: compile, validate, modify, diff, diagram, and describe operations are avai
|
|
|
2805
2939
|
};
|
|
2806
2940
|
var CAP_CODE_REVIEW = {
|
|
2807
2941
|
name: "code-review",
|
|
2808
|
-
description: "
|
|
2809
|
-
|
|
2942
|
+
description: "Comprehensive code review with correctness, security, style, testing, and performance checks.",
|
|
2943
|
+
tools: [OP_READ_FILE, OP_PATCH_FILE, OP_RUN_SHELL],
|
|
2944
|
+
prompt: `## Code Review Checklist
|
|
2945
|
+
|
|
2946
|
+
### 1. Correctness
|
|
2947
|
+
- Does the code do what the task asked?
|
|
2948
|
+
- Edge cases handled (empty input, null, invalid types)?
|
|
2949
|
+
- Error paths covered (try/catch, validation)?
|
|
2950
|
+
- Return types match function signature?
|
|
2951
|
+
|
|
2952
|
+
### 2. Security
|
|
2953
|
+
- NO hardcoded API keys, passwords, or tokens (use env vars)
|
|
2954
|
+
- NO shell: true in child_process (command injection risk)
|
|
2955
|
+
- NO eval() or Function() with untrusted input
|
|
2956
|
+
- User input validated and sanitized before use
|
|
2957
|
+
- File paths validated (no ../ traversal)
|
|
2810
2958
|
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
5. Performance: No unnecessary loops, no blocking calls in async code
|
|
2959
|
+
### 3. Style
|
|
2960
|
+
- Naming is clear and consistent with project conventions
|
|
2961
|
+
- No dead code (unused variables, unreachable branches)
|
|
2962
|
+
- No debug statements left in (console.log, debugger)
|
|
2963
|
+
- Imports organized, no duplicates
|
|
2817
2964
|
|
|
2818
|
-
|
|
2965
|
+
### 4. Testing
|
|
2966
|
+
- Unit tests exist for new/changed functions
|
|
2967
|
+
- Tests cover happy path AND edge cases
|
|
2968
|
+
- Error cases have tests
|
|
2969
|
+
- Code coverage adequate (aim for 80%+ of changed code)
|
|
2970
|
+
|
|
2971
|
+
### 5. Performance
|
|
2972
|
+
- No O(n\xB2) loops where O(n) is possible
|
|
2973
|
+
- No blocking I/O in async code
|
|
2974
|
+
- No memory leaks (listeners removed, timers cleared)
|
|
2975
|
+
|
|
2976
|
+
Report findings as: FILE:LINE | SEVERITY (critical/high/medium/low) | ISSUE \u2192 Fix suggestion`
|
|
2819
2977
|
};
|
|
2820
2978
|
var CAP_WEB = {
|
|
2821
2979
|
name: "web",
|
|
@@ -2832,8 +2990,131 @@ var CAP_CONTEXT = {
|
|
|
2832
2990
|
Use list_files to understand the project structure before making changes.
|
|
2833
2991
|
The context bundle (when available) provides a snapshot of the workspace.`
|
|
2834
2992
|
};
|
|
2993
|
+
var CAP_VERIFICATION = {
|
|
2994
|
+
name: "verification",
|
|
2995
|
+
description: "Post-write verification: run tsc and tests to catch errors before delivery.",
|
|
2996
|
+
tools: [OP_RUN_SHELL],
|
|
2997
|
+
prompt: `## Verification
|
|
2998
|
+
|
|
2999
|
+
After writing or patching code, ALWAYS verify your work:
|
|
3000
|
+
1. Run \`npx tsc --noEmit\` in the project root to catch TypeScript errors
|
|
3001
|
+
2. If package.json has a "test" script, run \`npm test\` to validate functionality
|
|
3002
|
+
3. If verification fails, read the errors, fix the code, and re-verify
|
|
3003
|
+
|
|
3004
|
+
Include verification as explicit steps in your plan. Verification is NOT optional.
|
|
3005
|
+
Do NOT deliver code that hasn't been verified.`
|
|
3006
|
+
};
|
|
3007
|
+
var CAP_CROSS_FILE_CHECK = {
|
|
3008
|
+
name: "cross-file-check",
|
|
3009
|
+
description: "Verify imports, exports, module paths, and cross-file dependencies.",
|
|
3010
|
+
tools: [OP_READ_FILE, OP_LIST_FILES, OP_RUN_SHELL],
|
|
3011
|
+
prompt: `## Cross-File Dependency Checks
|
|
3012
|
+
|
|
3013
|
+
When modifying code that affects multiple files:
|
|
3014
|
+
1. If you rename an export, grep for all imports of it and update them
|
|
3015
|
+
2. Verify relative import paths resolve correctly (../types vs ./types)
|
|
3016
|
+
3. Check for circular dependencies (A imports B imports A)
|
|
3017
|
+
4. If you change a function signature, update all callers
|
|
3018
|
+
5. Use \`run_shell\` with grep to search: grep -r "functionName" src/
|
|
3019
|
+
|
|
3020
|
+
Do NOT move or rename exports without verifying all dependents.`
|
|
3021
|
+
};
|
|
3022
|
+
var CAP_PROJECT_SETUP = {
|
|
3023
|
+
name: "project-setup",
|
|
3024
|
+
description: "Initialize new projects with correct structure, config, and dependencies.",
|
|
3025
|
+
tools: [OP_WRITE_FILE, OP_RUN_SHELL],
|
|
3026
|
+
prompt: `## Project Setup
|
|
3027
|
+
|
|
3028
|
+
When initializing a project:
|
|
3029
|
+
1. Create package.json with name, type: "module", main, scripts (build, test)
|
|
3030
|
+
2. Create tsconfig.json with strict: true, module: "esnext", target: "ES2020"
|
|
3031
|
+
3. Create standard directories: src/, tests/
|
|
3032
|
+
4. Install dependencies with run_shell: npm install <deps>
|
|
3033
|
+
5. Create .gitignore excluding node_modules/, dist/
|
|
3034
|
+
6. Verify setup: run tsc --noEmit to ensure TypeScript compiles`
|
|
3035
|
+
};
|
|
3036
|
+
var CAP_SECURITY = {
|
|
3037
|
+
name: "security",
|
|
3038
|
+
description: "Audit code for vulnerabilities, secrets, and security best practices.",
|
|
3039
|
+
tools: [OP_READ_FILE, OP_LIST_FILES, OP_RUN_SHELL],
|
|
3040
|
+
prompt: `## Security Audit
|
|
3041
|
+
|
|
3042
|
+
Check for:
|
|
3043
|
+
1. **Secrets**: NO hardcoded API keys, passwords, tokens. Use env vars.
|
|
3044
|
+
grep -r "password\\|secret\\|apiKey\\|token" src/ to find leaks.
|
|
3045
|
+
2. **Injection**: NO string concatenation in SQL. NO shell: true in child_process. NO eval().
|
|
3046
|
+
3. **Dependencies**: Run npm audit to check for known CVEs.
|
|
3047
|
+
4. **File paths**: Validate paths to prevent ../ traversal attacks.
|
|
3048
|
+
5. **Data handling**: Validate user input (type, length, format). Sanitize before logging.
|
|
3049
|
+
|
|
3050
|
+
Report findings with severity: critical | high | medium | low.`
|
|
3051
|
+
};
|
|
3052
|
+
var CAP_DECOMPOSITION = {
|
|
3053
|
+
name: "decomposition",
|
|
3054
|
+
description: "Break complex objectives into subtask DAGs with dependencies for parallel execution.",
|
|
3055
|
+
tools: [OP_TASK_CREATE],
|
|
3056
|
+
prompt: `## Task Decomposition
|
|
3057
|
+
|
|
3058
|
+
When given a large objective, break it into smaller subtasks:
|
|
3059
|
+
1. Identify all work items (files, features, tests)
|
|
3060
|
+
2. Group by dependency: what must happen first?
|
|
3061
|
+
3. Create subtasks with task_create, each focused on one responsibility
|
|
3062
|
+
4. Set dependencies with dependsOn to model blocking relationships
|
|
3063
|
+
5. Minimize dependencies to maximize parallel execution
|
|
3064
|
+
6. Estimate complexity per subtask: trivial | simple | moderate | complex
|
|
3065
|
+
|
|
3066
|
+
Example: "Implement auth module"
|
|
3067
|
+
- Task A: Extract shared auth types (simple)
|
|
3068
|
+
- Task B: Rewrite login endpoint (moderate, depends on A)
|
|
3069
|
+
- Task C: Add login tests (moderate, depends on B)
|
|
3070
|
+
- Task D: Update auth docs (simple, independent \u2014 runs in parallel with B)
|
|
3071
|
+
|
|
3072
|
+
Assign profiles: code tasks \u2192 developer, review tasks \u2192 reviewer, infra \u2192 ops.`
|
|
3073
|
+
};
|
|
3074
|
+
var CAP_ROUTING = {
|
|
3075
|
+
name: "routing",
|
|
3076
|
+
description: "Route tasks to appropriate bot profiles based on capabilities and complexity.",
|
|
3077
|
+
tools: [OP_TASK_CREATE],
|
|
3078
|
+
prompt: `## Task Routing
|
|
3079
|
+
|
|
3080
|
+
When creating subtasks, assign the right profile:
|
|
3081
|
+
- Code writing, file creation, bug fixes \u2192 developer profile
|
|
3082
|
+
- Code review, quality checks \u2192 reviewer profile
|
|
3083
|
+
- Shell commands, project setup, infrastructure \u2192 ops profile
|
|
3084
|
+
- Leave assignedProfile empty for auto-triage when unsure
|
|
3085
|
+
|
|
3086
|
+
Match complexity to profile capabilities:
|
|
3087
|
+
- trivial/simple tasks: any profile (prefer cheapest)
|
|
3088
|
+
- moderate tasks: specialist profiles
|
|
3089
|
+
- complex tasks: profiles with full capability sets`
|
|
3090
|
+
};
|
|
3091
|
+
var CAP_MEMORY = {
|
|
3092
|
+
name: "memory",
|
|
3093
|
+
description: "Remember and recall project conventions for continuity across sessions.",
|
|
3094
|
+
tools: [OP_REMEMBER, OP_RECALL],
|
|
3095
|
+
prompt: `## Project Memory
|
|
3096
|
+
|
|
3097
|
+
Persist project conventions for future sessions:
|
|
3098
|
+
- remember: Save a convention. args: { key: "naming", value: "kebab-case for files" }
|
|
3099
|
+
- recall: Load all saved conventions. args: {} \u2014 returns project memory.
|
|
3100
|
+
|
|
3101
|
+
What to remember:
|
|
3102
|
+
- Naming conventions (file names, variable names)
|
|
3103
|
+
- Architecture decisions (Result pattern, Zod for validation)
|
|
3104
|
+
- Test patterns (where tests go, what framework)
|
|
3105
|
+
- Common dependencies and their usage
|
|
3106
|
+
|
|
3107
|
+
Before planning, recall project memory to follow established patterns.
|
|
3108
|
+
When you discover a new convention, remember it for future bots.`
|
|
3109
|
+
};
|
|
2835
3110
|
var BUILT_IN_CAPABILITIES = [
|
|
2836
3111
|
CAP_CORE,
|
|
3112
|
+
// Role capabilities
|
|
3113
|
+
CAP_ROLE_ORCHESTRATOR,
|
|
3114
|
+
CAP_ROLE_DEVELOPER,
|
|
3115
|
+
CAP_ROLE_REVIEWER,
|
|
3116
|
+
CAP_ROLE_OPS,
|
|
3117
|
+
// Tool capabilities
|
|
2837
3118
|
CAP_FILE_OPS,
|
|
2838
3119
|
CAP_SHELL,
|
|
2839
3120
|
CAP_TASK_MGMT,
|
|
@@ -2843,7 +3124,15 @@ var BUILT_IN_CAPABILITIES = [
|
|
|
2843
3124
|
CAP_FW_CLI,
|
|
2844
3125
|
CAP_CODE_REVIEW,
|
|
2845
3126
|
CAP_WEB,
|
|
2846
|
-
CAP_CONTEXT
|
|
3127
|
+
CAP_CONTEXT,
|
|
3128
|
+
// Swarm improvement capabilities
|
|
3129
|
+
CAP_VERIFICATION,
|
|
3130
|
+
CAP_CROSS_FILE_CHECK,
|
|
3131
|
+
CAP_PROJECT_SETUP,
|
|
3132
|
+
CAP_SECURITY,
|
|
3133
|
+
CAP_DECOMPOSITION,
|
|
3134
|
+
CAP_ROUTING,
|
|
3135
|
+
CAP_MEMORY
|
|
2847
3136
|
];
|
|
2848
3137
|
var capabilityMap = new Map(
|
|
2849
3138
|
BUILT_IN_CAPABILITIES.map((c) => [c.name, c])
|
|
@@ -2851,9 +3140,9 @@ var capabilityMap = new Map(
|
|
|
2851
3140
|
|
|
2852
3141
|
// src/bot/behavior-defaults.ts
|
|
2853
3142
|
var STRATEGY_CAPABILITIES = {
|
|
2854
|
-
frugal: ["core", "file-ops", "shell", "context"],
|
|
2855
|
-
balanced: ["core", "
|
|
2856
|
-
performance: ["core", "
|
|
3143
|
+
frugal: ["core", "role-developer", "file-ops", "shell", "context"],
|
|
3144
|
+
balanced: ["core", "role-developer", "file-ops", "shell", "fw-grammar", "fw-validate", "context"],
|
|
3145
|
+
performance: ["core", "role-developer", "file-ops", "shell", "fw-grammar", "fw-validate", "fw-genesis", "fw-cli", "code-review", "web", "context"]
|
|
2857
3146
|
};
|
|
2858
3147
|
var STRATEGY_BUDGETS = {
|
|
2859
3148
|
frugal: 0.1,
|