brainclaw 0.28.0 ā 1.5.3
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/README.md +193 -170
- package/dist/brainclaw-vscode.vsix +0 -0
- package/dist/cli.js +683 -23
- package/dist/commands/accept.js +3 -0
- package/dist/commands/add-step.js +11 -26
- package/dist/commands/agent-board.js +70 -3
- package/dist/commands/audit.js +19 -0
- package/dist/commands/check-policy.js +54 -0
- package/dist/commands/check-security-mcp.js +145 -0
- package/dist/commands/check-security.js +106 -0
- package/dist/commands/claim-resource.js +1 -0
- package/dist/commands/codev.js +672 -0
- package/dist/commands/compact.js +74 -0
- package/dist/commands/complete-step.js +16 -26
- package/dist/commands/constraint.js +8 -20
- package/dist/commands/decision.js +9 -20
- package/dist/commands/delete-plan.js +10 -12
- package/dist/commands/delete-step.js +16 -0
- package/dist/commands/dispatch.js +163 -0
- package/dist/commands/doctor.js +1122 -49
- package/dist/commands/enable-agent.js +1 -0
- package/dist/commands/export.js +280 -22
- package/dist/commands/handoff.js +33 -0
- package/dist/commands/harvest.js +189 -0
- package/dist/commands/hooks.js +82 -25
- package/dist/commands/inbox.js +169 -0
- package/dist/commands/init.js +38 -31
- package/dist/commands/install-hooks.js +71 -44
- package/dist/commands/link.js +89 -0
- package/dist/commands/list-claims.js +48 -3
- package/dist/commands/list-plans.js +129 -25
- package/dist/commands/loops-handlers.js +409 -0
- package/dist/commands/mcp-read-handlers.js +1628 -0
- package/dist/commands/mcp-schemas.generated.js +74 -0
- package/dist/commands/mcp.js +4244 -1475
- package/dist/commands/plan-resource.js +64 -0
- package/dist/commands/plan.js +12 -26
- package/dist/commands/prune.js +37 -2
- package/dist/commands/reflect.js +20 -7
- package/dist/commands/release-claim.js +11 -6
- package/dist/commands/release-notes.js +170 -0
- package/dist/commands/repair.js +210 -0
- package/dist/commands/run-profile.js +57 -0
- package/dist/commands/sequence.js +113 -0
- package/dist/commands/session-end.js +423 -14
- package/dist/commands/session-start.js +214 -41
- package/dist/commands/setup-security.js +103 -0
- package/dist/commands/setup.js +42 -4
- package/dist/commands/stale.js +109 -0
- package/dist/commands/switch.js +131 -10
- package/dist/commands/trap.js +14 -31
- package/dist/commands/update-handoff.js +63 -4
- package/dist/commands/update-plan.js +21 -28
- package/dist/commands/update-step.js +37 -0
- package/dist/commands/upgrade.js +313 -6
- package/dist/commands/usage.js +102 -0
- package/dist/commands/version.js +20 -0
- package/dist/commands/who.js +124 -0
- package/dist/commands/worktree.js +105 -0
- package/dist/core/actions.js +315 -0
- package/dist/core/agent-capability.js +610 -17
- package/dist/core/agent-context.js +7 -1
- package/dist/core/agent-files.js +1169 -85
- package/dist/core/agent-integrations.js +160 -5
- package/dist/core/agent-inventory.js +2 -0
- package/dist/core/agent-profiles.js +93 -0
- package/dist/core/agent-registry.js +162 -30
- package/dist/core/agentrun-reconciler.js +345 -0
- package/dist/core/agentruns.js +424 -0
- package/dist/core/ai-agent-detection.js +31 -10
- package/dist/core/archival.js +77 -0
- package/dist/core/assignment-sweeper.js +82 -0
- package/dist/core/assignments.js +367 -0
- package/dist/core/audit.js +30 -0
- package/dist/core/bootstrap.js +61 -10
- package/dist/core/brainclaw-version.js +94 -2
- package/dist/core/candidates.js +93 -2
- package/dist/core/claims.js +419 -0
- package/dist/core/codev-metrics.js +77 -0
- package/dist/core/codev-personas.js +31 -0
- package/dist/core/codev-plan-gen.js +35 -0
- package/dist/core/codev-prompts.js +74 -0
- package/dist/core/codev-responses.js +62 -0
- package/dist/core/codev-rounds.js +218 -0
- package/dist/core/config.js +4 -0
- package/dist/core/context.js +454 -34
- package/dist/core/coordination.js +201 -6
- package/dist/core/cross-project.js +230 -16
- package/dist/core/default-profiles/doctor.yaml +11 -0
- package/dist/core/default-profiles/janitor.yaml +11 -0
- package/dist/core/default-profiles/onboarder.yaml +11 -0
- package/dist/core/default-profiles/reviewer.yaml +13 -0
- package/dist/core/dispatcher.js +1189 -0
- package/dist/core/duplicates.js +2 -2
- package/dist/core/entity-operations.js +450 -0
- package/dist/core/entity-registry.js +344 -0
- package/dist/core/event-log.js +1 -0
- package/dist/core/events.js +106 -2
- package/dist/core/execution-adapters.js +154 -0
- package/dist/core/execution-context.js +63 -0
- package/dist/core/execution-profile.js +270 -0
- package/dist/core/execution.js +255 -0
- package/dist/core/facade-schema.js +81 -0
- package/dist/core/federation-cloud.js +99 -0
- package/dist/core/federation-message.js +52 -0
- package/dist/core/federation-transport.js +65 -0
- package/dist/core/gc-semantic.js +482 -0
- package/dist/core/governance.js +247 -0
- package/dist/core/guards.js +19 -0
- package/dist/core/ideation.js +72 -0
- package/dist/core/identity.js +252 -28
- package/dist/core/ids.js +6 -0
- package/dist/core/input-validation.js +2 -2
- package/dist/core/instruction-templates.js +344 -136
- package/dist/core/io.js +90 -11
- package/dist/core/lock.js +6 -2
- package/dist/core/loops/brief-assembly.js +213 -0
- package/dist/core/loops/facade-schema.js +148 -0
- package/dist/core/loops/index.js +7 -0
- package/dist/core/loops/iteration-engine.js +139 -0
- package/dist/core/loops/lock.js +385 -0
- package/dist/core/loops/store.js +201 -0
- package/dist/core/loops/types.js +403 -0
- package/dist/core/loops/verbs.js +534 -0
- package/dist/core/markdown.js +15 -3
- package/dist/core/memory-compactor.js +432 -0
- package/dist/core/memory-git.js +152 -8
- package/dist/core/messaging.js +278 -0
- package/dist/core/migration.js +32 -1
- package/dist/core/mutation-pipeline.js +4 -2
- package/dist/core/operations/memory-mutation.js +129 -0
- package/dist/core/operations/memory-write.js +78 -0
- package/dist/core/operations/plan.js +190 -0
- package/dist/core/policy.js +169 -0
- package/dist/core/repo-analysis.js +67 -0
- package/dist/core/reputation.js +9 -3
- package/dist/core/schema.js +546 -21
- package/dist/core/search.js +21 -2
- package/dist/core/security-cache.js +71 -0
- package/dist/core/security-guard.js +152 -0
- package/dist/core/security-scoring.js +86 -0
- package/dist/core/sequence.js +130 -0
- package/dist/core/socket-client.js +113 -0
- package/dist/core/staleness.js +246 -0
- package/dist/core/state.js +98 -22
- package/dist/core/store-resolution.js +54 -12
- package/dist/core/toml-writer.js +76 -0
- package/dist/core/upgrades/backup.js +232 -0
- package/dist/core/upgrades/health-check.js +169 -0
- package/dist/core/upgrades/patches/candidate-archive.js +145 -0
- package/dist/core/upgrades/patches/handoff-review-strip.js +128 -0
- package/dist/core/upgrades/patches/provenance-rollout.js +136 -0
- package/dist/core/upgrades/schema-version.js +97 -0
- package/dist/core/worktree.js +606 -0
- package/dist/facts.js +114 -0
- package/dist/facts.json +111 -0
- package/docs/architecture/project-refs.md +5 -1
- package/docs/cli.md +690 -43
- package/docs/concepts/ideation-loop.md +317 -0
- package/docs/concepts/loop-engine.md +456 -0
- package/docs/concepts/mcp-governance.md +268 -0
- package/docs/concepts/memory-staleness.md +122 -0
- package/docs/concepts/multi-agent-workflows.md +166 -0
- package/docs/concepts/plans-and-claims.md +31 -6
- package/docs/concepts/project-md-convention.md +35 -0
- package/docs/concepts/troubleshooting.md +220 -0
- package/docs/concepts/upgrade-cli.md +202 -0
- package/docs/concepts/upgrade-dogfood-procedure.md +114 -0
- package/docs/context-format-changelog.md +2 -2
- package/docs/context-format.md +2 -2
- package/docs/index.md +68 -0
- package/docs/integrations/agents.md +15 -16
- package/docs/integrations/cline.md +88 -0
- package/docs/integrations/codex.md +75 -23
- package/docs/integrations/continue.md +60 -0
- package/docs/integrations/copilot.md +67 -9
- package/docs/integrations/kilocode.md +72 -0
- package/docs/integrations/mcp.md +304 -21
- package/docs/integrations/mistral-vibe.md +122 -0
- package/docs/integrations/opencode.md +84 -0
- package/docs/integrations/overview.md +23 -8
- package/docs/integrations/roo.md +74 -0
- package/docs/integrations/windsurf.md +83 -0
- package/docs/mcp-schema-changelog.md +191 -1
- package/docs/playbooks/integration/index.md +121 -0
- package/docs/playbooks/productivity/index.md +102 -0
- package/docs/playbooks/team/index.md +122 -0
- package/docs/product/agent-first-model.md +184 -0
- package/docs/product/entity-model-audit.md +462 -0
- package/docs/quickstart-existing-project.md +135 -0
- package/docs/quickstart.md +124 -37
- package/docs/release-maintenance.md +79 -0
- package/docs/review.md +2 -0
- package/docs/server-operations.md +118 -0
- package/package.json +20 -12
- package/dist/commands/claude-desktop-extension.js +0 -18
- package/dist/commands/diff.js +0 -99
- package/dist/core/claude-desktop-extension.js +0 -224
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: brainclaw compact
|
|
3
|
+
*
|
|
4
|
+
* LLM-driven semantic memory compaction ā assess pressure or archive old items.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { memoryExists } from '../core/io.js';
|
|
9
|
+
import { compact as gcCompact, assessMemoryPressure, buildCompactionTemplate } from '../core/gc-semantic.js';
|
|
10
|
+
export function runCompact(options = {}) {
|
|
11
|
+
if (!memoryExists(process.cwd())) {
|
|
12
|
+
console.error('Project memory not initialized. Run `brainclaw init` first.');
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
// --assess mode: show pressure assessment and template only, no archiving
|
|
16
|
+
if (options.assess) {
|
|
17
|
+
const assessment = assessMemoryPressure();
|
|
18
|
+
const maxItems = options.maxItems ?? 20;
|
|
19
|
+
const selected = assessment.eligible_items.slice(0, maxItems);
|
|
20
|
+
console.log(`Memory pressure: ${assessment.pressure ? 'YES' : 'no'}`);
|
|
21
|
+
console.log(` Done plans: ${assessment.done_plans} (threshold: ${assessment.thresholds.plans})`);
|
|
22
|
+
console.log(` Closed handoffs: ${assessment.closed_handoffs} (threshold: ${assessment.thresholds.handoffs})`);
|
|
23
|
+
console.log(` Eligible items: ${assessment.eligible_items.length}`);
|
|
24
|
+
if (selected.length > 0) {
|
|
25
|
+
console.log('');
|
|
26
|
+
console.log(buildCompactionTemplate(selected));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
console.log('No items eligible for compaction.');
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
// Default mode: compact (archive eligible items)
|
|
34
|
+
const result = gcCompact({
|
|
35
|
+
dryRun: options.dryRun,
|
|
36
|
+
maxItems: options.maxItems,
|
|
37
|
+
minAgeDays: options.minAge,
|
|
38
|
+
dedupHandoffs: !options.noDedupHandoffs,
|
|
39
|
+
purgeReleasedClaims: !options.noPurgeClaims,
|
|
40
|
+
purgeSessionNotes: !options.noPurgeSessionNotes,
|
|
41
|
+
});
|
|
42
|
+
if (result.dry_run) {
|
|
43
|
+
console.log(`š Dry run ā ${result.eligible_count} plan/handoff item(s) eligible for compaction.`);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
console.log(`ā Compacted ${result.archived_count}/${result.eligible_count} plan/handoff item(s).`);
|
|
47
|
+
if (result.backup_path) {
|
|
48
|
+
console.log(`Backup: ${result.backup_path}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Post-v1 extension summaries (pln#436)
|
|
52
|
+
const extras = [];
|
|
53
|
+
if ((result.claims_archived ?? 0) > 0) {
|
|
54
|
+
extras.push(`${result.claims_archived} released claim(s)`);
|
|
55
|
+
}
|
|
56
|
+
if ((result.session_notes_archived ?? 0) > 0) {
|
|
57
|
+
extras.push(`${result.session_notes_archived} session runtime_note(s)`);
|
|
58
|
+
}
|
|
59
|
+
if ((result.handoffs_deduped ?? 0) > 0) {
|
|
60
|
+
extras.push(`${result.handoffs_deduped} duplicate handoff(s)`);
|
|
61
|
+
}
|
|
62
|
+
if (extras.length > 0) {
|
|
63
|
+
const verb = result.dry_run ? 'eligible' : 'archived';
|
|
64
|
+
console.log(` ⢠${verb}: ${extras.join(', ')}`);
|
|
65
|
+
}
|
|
66
|
+
if (result.template) {
|
|
67
|
+
console.log('');
|
|
68
|
+
console.log(result.template);
|
|
69
|
+
}
|
|
70
|
+
else if (result.eligible_count === 0 && extras.length === 0) {
|
|
71
|
+
console.log('No items eligible for compaction.');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=compact.js.map
|
|
@@ -1,32 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { nowISO } from '../core/ids.js';
|
|
1
|
+
import { requireInitialized } from '../core/guards.js';
|
|
2
|
+
import { completeStep } from '../core/operations/plan.js';
|
|
4
3
|
export function runCompleteStep(planId, stepId) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
requireInitialized(process.cwd());
|
|
5
|
+
try {
|
|
6
|
+
const result = completeStep({ planId, stepId });
|
|
7
|
+
console.log(`ā Step completed: [${result.stepId}]`);
|
|
8
|
+
console.log(` Plan [${result.planId}] progress: ${result.doneSteps}/${result.totalSteps} steps done`);
|
|
9
|
+
if (result.planAutoCompleted) {
|
|
10
|
+
console.log(` All steps done ā plan auto-completed.`);
|
|
11
|
+
}
|
|
12
|
+
else if (result.doneSteps === result.totalSteps) {
|
|
13
|
+
console.log(` All steps done ā consider: brainclaw update-plan ${result.planId} --status done`);
|
|
14
|
+
}
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
console.error(`Error:
|
|
16
|
+
catch (error) {
|
|
17
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
18
|
+
console.error(`Error: ${msg}`);
|
|
18
19
|
process.exit(1);
|
|
19
20
|
}
|
|
20
|
-
step.status = 'done';
|
|
21
|
-
step.updated_at = nowISO();
|
|
22
|
-
plan.updated_at = nowISO();
|
|
23
|
-
persistState(state);
|
|
24
|
-
const total = plan.steps.length;
|
|
25
|
-
const done = plan.steps.filter((s) => s.status === 'done').length;
|
|
26
|
-
console.log(`ā Step completed: [${step.id}] ${step.text}`);
|
|
27
|
-
console.log(` Plan [${plan.id}] progress: ${done}/${total} steps done`);
|
|
28
|
-
if (done === total) {
|
|
29
|
-
console.log(` All steps done ā consider: brainclaw update-plan ${plan.id} --status done`);
|
|
30
|
-
}
|
|
31
21
|
}
|
|
32
22
|
//# sourceMappingURL=complete-step.js.map
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import { loadState, persistState } from '../core/state.js';
|
|
2
1
|
import { resolveCurrentAgentName } from '../core/agent-registry.js';
|
|
3
2
|
import { loadConfig } from '../core/config.js';
|
|
4
|
-
import { generateIdWithLabel, nowISO } from '../core/ids.js';
|
|
5
3
|
import { scanText } from '../core/security.js';
|
|
6
|
-
import {
|
|
4
|
+
import { requireInitialized } from '../core/guards.js';
|
|
7
5
|
import { validateCliInput } from '../core/input-validation.js';
|
|
8
6
|
import { resolveTargetStore } from '../core/store-resolution.js';
|
|
7
|
+
import { createConstraint } from '../core/operations/memory-write.js';
|
|
9
8
|
export function runConstraint(text, options = {}) {
|
|
10
9
|
const cwd = resolveTargetStore(options.cwd ?? process.cwd(), options.store ?? 'local');
|
|
11
|
-
|
|
12
|
-
console.error('Error: .brainclaw/ not found. Run `brainclaw init` first.');
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
10
|
+
requireInitialized(cwd);
|
|
15
11
|
validateCliInput(text, options.tag);
|
|
16
12
|
const config = loadConfig(cwd);
|
|
17
13
|
const warnings = scanText(text, config);
|
|
@@ -22,21 +18,13 @@ export function runConstraint(text, options = {}) {
|
|
|
22
18
|
process.exit(1);
|
|
23
19
|
}
|
|
24
20
|
}
|
|
25
|
-
const
|
|
26
|
-
const { id, short_label } = generateIdWithLabel('active_constraints');
|
|
27
|
-
const entry = {
|
|
28
|
-
id,
|
|
29
|
-
short_label,
|
|
21
|
+
const result = createConstraint({
|
|
30
22
|
text,
|
|
31
|
-
created_at: nowISO(),
|
|
32
23
|
author: options.author ?? resolveCurrentAgentName(cwd),
|
|
33
|
-
status: 'active',
|
|
34
24
|
category: options.category,
|
|
35
|
-
tags: options.tag
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
persistState(state, cwd);
|
|
40
|
-
console.log(`ā Constraint added: [${id}] ${text}`);
|
|
25
|
+
tags: options.tag,
|
|
26
|
+
relatedPaths: options.path,
|
|
27
|
+
}, cwd);
|
|
28
|
+
console.log(`ā Constraint added: [${result.id}] ${text}`);
|
|
41
29
|
}
|
|
42
30
|
//# sourceMappingURL=constraint.js.map
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import { loadState, persistState } from '../core/state.js';
|
|
2
1
|
import { resolveCurrentAgentName } from '../core/agent-registry.js';
|
|
3
2
|
import { loadConfig } from '../core/config.js';
|
|
4
|
-
import { generateIdWithLabel, nowISO } from '../core/ids.js';
|
|
5
3
|
import { scanText } from '../core/security.js';
|
|
6
|
-
import {
|
|
4
|
+
import { requireInitialized } from '../core/guards.js';
|
|
7
5
|
import { validateCliInput } from '../core/input-validation.js';
|
|
8
6
|
import { resolveTargetStore } from '../core/store-resolution.js';
|
|
7
|
+
import { createDecision } from '../core/operations/memory-write.js';
|
|
9
8
|
export function runDecision(text, options = {}) {
|
|
10
9
|
const cwd = resolveTargetStore(options.cwd ?? process.cwd(), options.store ?? 'local');
|
|
11
|
-
|
|
12
|
-
console.error('Error: .brainclaw/ not found. Run `brainclaw init` first.');
|
|
13
|
-
process.exit(1);
|
|
14
|
-
}
|
|
10
|
+
requireInitialized(cwd);
|
|
15
11
|
validateCliInput(text, options.tag);
|
|
16
12
|
const config = loadConfig(cwd);
|
|
17
13
|
const warnings = scanText(text, config);
|
|
@@ -22,21 +18,14 @@ export function runDecision(text, options = {}) {
|
|
|
22
18
|
process.exit(1);
|
|
23
19
|
}
|
|
24
20
|
}
|
|
25
|
-
const
|
|
26
|
-
const { id, short_label } = generateIdWithLabel('recent_decisions');
|
|
27
|
-
const entry = {
|
|
28
|
-
id,
|
|
29
|
-
short_label,
|
|
21
|
+
const result = createDecision({
|
|
30
22
|
text,
|
|
31
|
-
created_at: nowISO(),
|
|
32
23
|
author: options.author ?? resolveCurrentAgentName(cwd),
|
|
33
24
|
outcome: options.outcome,
|
|
34
|
-
tags: options.tag
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
persistState(state, cwd);
|
|
40
|
-
console.log(`ā Decision added: [${id}] ${text}`);
|
|
25
|
+
tags: options.tag,
|
|
26
|
+
relatedPaths: options.path,
|
|
27
|
+
planId: options.plan,
|
|
28
|
+
}, cwd);
|
|
29
|
+
console.log(`ā Decision added: [${result.id}] ${text}`);
|
|
41
30
|
}
|
|
42
31
|
//# sourceMappingURL=decision.js.map
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { requireInitialized } from '../core/guards.js';
|
|
2
|
+
import { deletePlan } from '../core/operations/plan.js';
|
|
3
3
|
export function runDeletePlan(id, options = {}) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const cwd = options.cwd ?? process.cwd();
|
|
5
|
+
requireInitialized(cwd);
|
|
6
|
+
try {
|
|
7
|
+
const result = deletePlan(id, cwd);
|
|
8
|
+
console.log(`ā Plan item deleted: [${result.id}] ${result.text}`);
|
|
7
9
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
console.error(`Error: Plan item '${id}' not found.`);
|
|
10
|
+
catch (error) {
|
|
11
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
12
|
+
console.error(`Error: ${msg}`);
|
|
12
13
|
process.exit(1);
|
|
13
14
|
}
|
|
14
|
-
const [plan] = state.plan_items.splice(index, 1);
|
|
15
|
-
persistState(state, options.cwd);
|
|
16
|
-
console.log(`ā Plan item deleted: [${plan.id}] ${plan.text}`);
|
|
17
15
|
}
|
|
18
16
|
//# sourceMappingURL=delete-plan.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { requireInitialized } from '../core/guards.js';
|
|
2
|
+
import { deleteStep } from '../core/operations/plan.js';
|
|
3
|
+
export function runDeleteStep(planId, stepId) {
|
|
4
|
+
requireInitialized(process.cwd());
|
|
5
|
+
try {
|
|
6
|
+
const result = deleteStep({ planId, stepId });
|
|
7
|
+
console.log(`ā Step deleted: [${result.stepId}]`);
|
|
8
|
+
console.log(` Plan [${result.planId}]: ${result.totalSteps} step(s) remaining (${result.doneSteps} done)`);
|
|
9
|
+
}
|
|
10
|
+
catch (error) {
|
|
11
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
12
|
+
console.error(`Error: ${msg}`);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=delete-step.js.map
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI command: brainclaw dispatch
|
|
3
|
+
*
|
|
4
|
+
* Subcommands:
|
|
5
|
+
* brainclaw dispatch analysis ā show lane status
|
|
6
|
+
* brainclaw dispatch run ā send assignments to available agents
|
|
7
|
+
* brainclaw dispatch run --dry ā preview assignments without sending
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
import { memoryExists } from '../core/io.js';
|
|
12
|
+
import { analyzeSequence, dispatch, dispatchReview } from '../core/dispatcher.js';
|
|
13
|
+
import { resolveCurrentAgentName } from '../core/agent-registry.js';
|
|
14
|
+
export function runDispatchAnalysis(options) {
|
|
15
|
+
const cwd = options.cwd;
|
|
16
|
+
if (!memoryExists(cwd)) {
|
|
17
|
+
console.error('Error: .brainclaw/ not found. Run `brainclaw init` first.');
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
const analysis = analyzeSequence(cwd ?? process.cwd());
|
|
21
|
+
if (!analysis) {
|
|
22
|
+
console.log('No active sequence found.');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (options.json) {
|
|
26
|
+
console.log(JSON.stringify(analysis, null, 2));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
console.log(`\nDispatch Analysis ā ${analysis.sequence.name}\n`);
|
|
30
|
+
// Ready
|
|
31
|
+
console.log(`š¢ Ready (${analysis.ready.length}):`);
|
|
32
|
+
for (const r of analysis.ready) {
|
|
33
|
+
const lane = r.lane ? ` [${r.lane}]` : '';
|
|
34
|
+
const assignee = r.plan.assignee ? ` ā ${r.plan.assignee}` : '';
|
|
35
|
+
console.log(` ${r.plan.short_label ?? r.plan.id}${lane}${assignee}`);
|
|
36
|
+
console.log(` ${r.plan.text.slice(0, 100)}`);
|
|
37
|
+
console.log(` ${r.reason}`);
|
|
38
|
+
}
|
|
39
|
+
// Active
|
|
40
|
+
if (analysis.active.length > 0) {
|
|
41
|
+
console.log(`\nšµ Active (${analysis.active.length}):`);
|
|
42
|
+
for (const a of analysis.active) {
|
|
43
|
+
const lane = a.lane ? ` [${a.lane}]` : '';
|
|
44
|
+
// Codex r1 finding: on the dispatch surface, `young` is NOT a no-alarm
|
|
45
|
+
// state ā it means the coordinator claim exists but no worker session
|
|
46
|
+
// has adopted it yet. "agent working" would mislead the operator into
|
|
47
|
+
// thinking the lane is actively progressing.
|
|
48
|
+
let status = 'working';
|
|
49
|
+
let livenessTag = '';
|
|
50
|
+
if (a.liveness === 'young' && !a.claim.session_id) {
|
|
51
|
+
status = 'pending adoption';
|
|
52
|
+
}
|
|
53
|
+
else if (a.liveness && a.liveness !== 'live' && a.liveness !== 'young') {
|
|
54
|
+
livenessTag = ` [${a.liveness.toUpperCase()}]`;
|
|
55
|
+
}
|
|
56
|
+
console.log(` ${a.plan.short_label ?? a.plan.id}${lane} ā ${a.agent} ${status}${livenessTag}`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Blocked
|
|
60
|
+
if (analysis.blocked.length > 0) {
|
|
61
|
+
console.log(`\nš“ Blocked (${analysis.blocked.length}):`);
|
|
62
|
+
for (const b of analysis.blocked) {
|
|
63
|
+
const lane = b.lane ? ` [${b.lane}]` : '';
|
|
64
|
+
console.log(` ${b.item.planId}${lane} ā ${b.reason}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Done
|
|
68
|
+
if (analysis.done.length > 0) {
|
|
69
|
+
console.log(`\nā
Done (${analysis.done.length})`);
|
|
70
|
+
}
|
|
71
|
+
// Available agents
|
|
72
|
+
console.log(`\nAvailable agents: ${analysis.available_agents.length > 0 ? analysis.available_agents.join(', ') : '(none)'}`);
|
|
73
|
+
console.log('');
|
|
74
|
+
}
|
|
75
|
+
export async function runDispatch(options) {
|
|
76
|
+
const cwd = options.cwd;
|
|
77
|
+
if (!memoryExists(cwd)) {
|
|
78
|
+
console.error('Error: .brainclaw/ not found. Run `brainclaw init` first.');
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
const effectiveCwd = cwd ?? process.cwd();
|
|
82
|
+
const dispatcherAgent = options.agent ?? resolveCurrentAgentName(effectiveCwd) ?? 'brainclaw';
|
|
83
|
+
const result = await dispatch({
|
|
84
|
+
agents: options.agents?.split(',').map(a => a.trim()),
|
|
85
|
+
lanes: options.lanes?.split(',').map(l => l.trim()),
|
|
86
|
+
maxAssignments: options.max,
|
|
87
|
+
dryRun: options.dry,
|
|
88
|
+
dispatcherAgent,
|
|
89
|
+
autoExecute: options.spawn,
|
|
90
|
+
}, effectiveCwd);
|
|
91
|
+
if (!result) {
|
|
92
|
+
console.log('No active sequence found.');
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (options.json) {
|
|
96
|
+
console.log(JSON.stringify(result, null, 2));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const { analysis, result: dispatchResult } = result;
|
|
100
|
+
if (options.dry) {
|
|
101
|
+
console.log(`\nš Dispatch dry run ā ${analysis.sequence.name}\n`);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
console.log(`\nā Dispatch complete ā ${analysis.sequence.name}\n`);
|
|
105
|
+
}
|
|
106
|
+
console.log(` Ready: ${analysis.ready.length} | Active: ${analysis.active.length} | Blocked: ${analysis.blocked.length} | Done: ${analysis.done.length}`);
|
|
107
|
+
if (dispatchResult.messages_sent.length > 0) {
|
|
108
|
+
console.log(`\n ${options.dry ? 'Would assign' : 'Assigned'}:`);
|
|
109
|
+
for (const msg of dispatchResult.messages_sent) {
|
|
110
|
+
const lane = msg.lane ? ` (lane: ${msg.lane})` : '';
|
|
111
|
+
const exec = msg.execution_status ? ` [${msg.execution_status}]` : ' [inbox]';
|
|
112
|
+
console.log(` ā ${msg.agent}: ${msg.plan_id}${lane}${exec}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (dispatchResult.skipped.length > 0) {
|
|
116
|
+
console.log('\n Skipped:');
|
|
117
|
+
for (const skip of dispatchResult.skipped) {
|
|
118
|
+
console.log(` - ${skip.plan_id}: ${skip.reason}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
console.log('');
|
|
122
|
+
}
|
|
123
|
+
export function runDispatchReview(options) {
|
|
124
|
+
const cwd = options.cwd;
|
|
125
|
+
if (!memoryExists(cwd)) {
|
|
126
|
+
console.error('Error: .brainclaw/ not found. Run `brainclaw init` first.');
|
|
127
|
+
process.exit(1);
|
|
128
|
+
}
|
|
129
|
+
const effectiveCwd = cwd ?? process.cwd();
|
|
130
|
+
const dispatcherAgent = options.agent ?? resolveCurrentAgentName(effectiveCwd) ?? 'brainclaw';
|
|
131
|
+
const result = dispatchReview({
|
|
132
|
+
handoffId: options.handoff,
|
|
133
|
+
reviewer: options.reviewer,
|
|
134
|
+
dryRun: options.dry,
|
|
135
|
+
dispatcherAgent,
|
|
136
|
+
}, effectiveCwd);
|
|
137
|
+
if (options.json) {
|
|
138
|
+
console.log(JSON.stringify(result, null, 2));
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (options.dry) {
|
|
142
|
+
console.log('\nš Review dispatch dry run\n');
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
console.log('\nā Review dispatch complete\n');
|
|
146
|
+
}
|
|
147
|
+
if (result.reviews_sent.length > 0) {
|
|
148
|
+
for (const r of result.reviews_sent) {
|
|
149
|
+
console.log(` ā ${r.reviewer} reviewing ${r.handoff_id}${r.plan_id ? ` (${r.plan_id})` : ''} [inbox]`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
console.log(' No handoffs ready for review.');
|
|
154
|
+
}
|
|
155
|
+
if (result.skipped.length > 0) {
|
|
156
|
+
console.log('\n Skipped:');
|
|
157
|
+
for (const s of result.skipped) {
|
|
158
|
+
console.log(` - ${s.handoff_id}: ${s.reason}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
console.log('');
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=dispatch.js.map
|