claude-flow 3.56.9 → 3.56.10

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 (70) hide show
  1. package/.claude/.proven-config-version +1 -0
  2. package/.claude/helpers/intelligence.cjs +51 -9
  3. package/.claude/proven-config.json +42 -0
  4. package/.claude/skills/verification-quality/SKILL.md +14 -11
  5. package/README.md +1 -1
  6. package/node_modules/@claude-flow/codex/dist/cli.js +0 -0
  7. package/node_modules/@claude-flow/plugin-agent-federation/dist/bin.js +0 -0
  8. package/node_modules/@claude-flow/security/dist/input-validator.d.ts +6 -6
  9. package/package.json +2 -2
  10. package/v3/@claude-flow/cli/dist/src/autopilot-state.d.ts +2 -0
  11. package/v3/@claude-flow/cli/dist/src/autopilot-state.js +36 -8
  12. package/v3/@claude-flow/cli/dist/src/command-resolution.d.ts +15 -0
  13. package/v3/@claude-flow/cli/dist/src/command-resolution.js +25 -0
  14. package/v3/@claude-flow/cli/dist/src/commands/agent.js +17 -17
  15. package/v3/@claude-flow/cli/dist/src/commands/claims.js +6 -8
  16. package/v3/@claude-flow/cli/dist/src/commands/daemon.js +86 -31
  17. package/v3/@claude-flow/cli/dist/src/commands/memory.js +14 -2
  18. package/v3/@claude-flow/cli/dist/src/commands/security-code-patterns.d.ts +2 -2
  19. package/v3/@claude-flow/cli/dist/src/commands/security-code-patterns.js +61 -3
  20. package/v3/@claude-flow/cli/dist/src/commands/security.d.ts +24 -0
  21. package/v3/@claude-flow/cli/dist/src/commands/security.js +81 -35
  22. package/v3/@claude-flow/cli/dist/src/commands/tui.d.ts +9 -0
  23. package/v3/@claude-flow/cli/dist/src/commands/tui.js +29 -3
  24. package/v3/@claude-flow/cli/dist/src/config/proven-config-refresh.d.ts +9 -0
  25. package/v3/@claude-flow/cli/dist/src/config/proven-config-refresh.js +24 -3
  26. package/v3/@claude-flow/cli/dist/src/funnel/local-signals.js +2 -1
  27. package/v3/@claude-flow/cli/dist/src/index.js +6 -42
  28. package/v3/@claude-flow/cli/dist/src/init/types.js +1 -1
  29. package/v3/@claude-flow/cli/dist/src/mcp-tools/agent-execute-core.d.ts +2 -0
  30. package/v3/@claude-flow/cli/dist/src/mcp-tools/agent-execute-core.js +15 -0
  31. package/v3/@claude-flow/cli/dist/src/mcp-tools/agent-health-metrics.d.ts +22 -0
  32. package/v3/@claude-flow/cli/dist/src/mcp-tools/agent-health-metrics.js +33 -0
  33. package/v3/@claude-flow/cli/dist/src/mcp-tools/agent-tools.js +45 -22
  34. package/v3/@claude-flow/cli/dist/src/mcp-tools/agentbbs-federation.d.ts +1 -1
  35. package/v3/@claude-flow/cli/dist/src/mcp-tools/agentbbs-federation.js +7 -2
  36. package/v3/@claude-flow/cli/dist/src/mcp-tools/agentdb-tools.js +25 -2
  37. package/v3/@claude-flow/cli/dist/src/mcp-tools/aidefence-known-misses.d.ts +22 -0
  38. package/v3/@claude-flow/cli/dist/src/mcp-tools/aidefence-known-misses.js +57 -0
  39. package/v3/@claude-flow/cli/dist/src/mcp-tools/analyze-tools.js +10 -11
  40. package/v3/@claude-flow/cli/dist/src/mcp-tools/autopilot-tools.js +2 -2
  41. package/v3/@claude-flow/cli/dist/src/mcp-tools/browser-intent-tools.js +6 -2
  42. package/v3/@claude-flow/cli/dist/src/mcp-tools/embeddings-tools.js +29 -7
  43. package/v3/@claude-flow/cli/dist/src/mcp-tools/hooks-tools.js +4 -0
  44. package/v3/@claude-flow/cli/dist/src/mcp-tools/memory-tools.js +70 -20
  45. package/v3/@claude-flow/cli/dist/src/mcp-tools/neural-tools.js +28 -4
  46. package/v3/@claude-flow/cli/dist/src/mcp-tools/ruvllm-tools.js +6 -0
  47. package/v3/@claude-flow/cli/dist/src/mcp-tools/security-tools.js +55 -17
  48. package/v3/@claude-flow/cli/dist/src/mcp-tools/workflow-tools.js +66 -17
  49. package/v3/@claude-flow/cli/dist/src/memory/intelligence.d.ts +5 -1
  50. package/v3/@claude-flow/cli/dist/src/memory/intelligence.js +105 -29
  51. package/v3/@claude-flow/cli/dist/src/memory/memory-bridge.js +10 -3
  52. package/v3/@claude-flow/cli/dist/src/memory/memory-initializer.js +2 -1
  53. package/v3/@claude-flow/cli/dist/src/memory/search-defaults.d.ts +54 -0
  54. package/v3/@claude-flow/cli/dist/src/memory/search-defaults.js +37 -0
  55. package/v3/@claude-flow/cli/dist/src/memory/sona-optimizer.d.ts +28 -0
  56. package/v3/@claude-flow/cli/dist/src/memory/sona-optimizer.js +59 -2
  57. package/v3/@claude-flow/cli/dist/src/mods/command-registry/schema.d.ts +24 -24
  58. package/v3/@claude-flow/cli/dist/src/ruvector/agent-wasm.d.ts +10 -0
  59. package/v3/@claude-flow/cli/dist/src/ruvector/agent-wasm.js +27 -1
  60. package/v3/@claude-flow/cli/dist/src/ruvector/diff-classifier.d.ts +2 -4
  61. package/v3/@claude-flow/cli/dist/src/ruvector/diff-classifier.js +202 -69
  62. package/v3/@claude-flow/cli/dist/src/ruvector/ruvllm-wasm.d.ts +4 -0
  63. package/v3/@claude-flow/cli/dist/src/ruvector/ruvllm-wasm.js +12 -1
  64. package/v3/@claude-flow/cli/dist/src/services/policy-runtime.d.ts +1 -1
  65. package/v3/@claude-flow/cli/dist/src/services/policy-runtime.js +7 -1
  66. package/v3/@claude-flow/cli/dist/src/services/worker-daemon.d.ts +11 -0
  67. package/v3/@claude-flow/cli/dist/src/services/worker-daemon.js +37 -0
  68. package/v3/@claude-flow/cli/dist/src/transfer/store/discovery.js +16 -17
  69. package/v3/@claude-flow/cli/dist/src/transfer/store/types.d.ts +4 -0
  70. package/v3/@claude-flow/cli/package.json +4 -4
@@ -0,0 +1 @@
1
+ sha256:6141a8ea990c5063b77e090ae8f37f9c539d8aa8f58dcceb30f3a82f97e57319
@@ -739,27 +739,69 @@ function appendRecall(detailed, meta) {
739
739
  * getContext(prompt) — Called from route. Budget: <15ms.
740
740
  * Matches prompt to ranked entries, returns top-5 formatted context.
741
741
  */
742
+ /**
743
+ * Inflection variants of a prompt term (plural, -ed, -ing, -ion and their
744
+ * stems), so "migrations" finds an entry that says "migration" and "deploying"
745
+ * finds "deploy". Exact term matching alone lost what the old trigram overlap
746
+ * caught (#4136). The stem keeps at least 4 characters so short words stay exact.
747
+ */
748
+ function termVariants(word) {
749
+ const out = new Set([word]);
750
+ for (const suffix of ['s', 'es', 'ed', 'ing', 'ion', 'ions']) out.add(word + suffix);
751
+ for (const suffix of ['ions', 'ion', 'ing', 'ed', 'es', 's']) {
752
+ if (word.length - suffix.length >= 4 && word.endsWith(suffix)) {
753
+ const stem = word.slice(0, -suffix.length);
754
+ out.add(stem); out.add(stem + 'e'); out.add(stem + 's');
755
+ }
756
+ }
757
+ return [...out];
758
+ }
759
+
742
760
  function getContextDetailed(prompt) {
743
761
  if (!prompt) return null;
744
762
 
745
763
  const ranked = readJSON(RANKED_PATH);
746
764
  if (!ranked || !ranked.entries || ranked.entries.length === 0) return null;
747
765
 
748
- const promptWords = tokenize(prompt);
766
+ const promptWords = [...new Set(tokenize(prompt))];
749
767
  if (promptWords.length === 0) return null;
750
- const promptTrigrams = trigrams(promptWords);
751
768
 
752
- const ALPHA = 0.6; // content match weight
753
- const MIN_THRESHOLD = 0.05;
769
+ // Query coverage is independent of entry length: a short diagnostic prompt
770
+ // must still find its exact terms inside a long memory section (#4136).
771
+ // IDF downweights generic terms shared by many entries. Terms absent from
772
+ // every entry still count against coverage, so two incidental words cannot
773
+ // hide the rest of an unrelated prompt.
774
+ const candidates = ranked.entries.map(entry => ({ entry, words: new Set(entry.words || []) }));
775
+ const variants = promptWords.map(termVariants);
776
+ const hasTerm = (words, i) => variants[i].some(v => words.has(v));
777
+ const weights = promptWords.map((word, i) => {
778
+ const frequency = candidates.reduce((count, candidate) => count + Number(hasTerm(candidate.words, i)), 0);
779
+ return Math.log1p((candidates.length - frequency + 0.5) / (frequency + 0.5));
780
+ });
781
+ const totalWeight = weights.reduce((sum, weight) => sum + weight, 0);
782
+ if (totalWeight === 0) return null;
783
+
784
+ const MIN_COVERAGE = 0.15;
754
785
  const TOP_K = 5;
755
786
 
756
787
  // Score each entry
757
788
  const scored = [];
758
- for (const entry of ranked.entries) {
759
- const entryTrigrams = trigrams(entry.words || []);
760
- const contentMatch = jaccardSimilarity(promptTrigrams, entryTrigrams);
761
- const score = ALPHA * contentMatch + (1 - ALPHA) * (entry.pageRank || 0);
762
- if (score >= MIN_THRESHOLD) {
789
+ for (const { entry, words } of candidates) {
790
+ let matchedWeight = 0;
791
+ let matchedTerms = 0;
792
+ for (let i = 0; i < promptWords.length; i++) {
793
+ if (weights[i] > 0 && hasTerm(words, i)) {
794
+ matchedWeight += weights[i];
795
+ matchedTerms++;
796
+ }
797
+ }
798
+ // A single common word in a long prompt is not evidence of relevance;
799
+ // PageRank can order relevant entries but cannot make one relevant.
800
+ if (matchedTerms < Math.min(2, promptWords.length)) continue;
801
+ const coverage = matchedWeight / totalWeight;
802
+ if (coverage >= MIN_COVERAGE) {
803
+ const pageRank = Math.max(0, Math.min(1, Number(entry.pageRank) || 0));
804
+ const score = 0.9 * coverage + 0.1 * pageRank;
763
805
  scored.push({ ...entry, score });
764
806
  }
765
807
  }
@@ -0,0 +1,42 @@
1
+ {
2
+ "adoptedAt": 1791993312855,
3
+ "championId": "sha256:6141a8ea990c5063b77e090ae8f37f9c539d8aa8f58dcceb30f3a82f97e57319",
4
+ "manifest": {
5
+ "schema": "ruflo.proven-config/v1",
6
+ "policy": {
7
+ "ref": "sha256:6141a8ea990c5063b77e090ae8f37f9c539d8aa8f58dcceb30f3a82f97e57319",
8
+ "value": {
9
+ "alpha": 0.3,
10
+ "subjectWeight": 1,
11
+ "mmrLambda": 0.5,
12
+ "bodyWeight": 1.5,
13
+ "typePenaltyFactor": 0.5
14
+ }
15
+ },
16
+ "layer": "framework/node-cli",
17
+ "compatibility": {
18
+ "ruflo": ">=3.24.0"
19
+ },
20
+ "benchmark": {
21
+ "corpus": "ADR-081-labelled-v1",
22
+ "corpusHash": "sha256:2f700b5c363e20a3bd88ce2bc9b87bbbbaa61732c6177894c6ec37890f888982"
23
+ },
24
+ "receipt": {
25
+ "heldOutDelta": 0.07381404928570845,
26
+ "redblue": "PASS",
27
+ "drift": 0,
28
+ "canary": {
29
+ "rollbackRate": 0,
30
+ "latencyP95": 244.612458000076,
31
+ "costPerTask": 0
32
+ },
33
+ "receiptCoverage": 1
34
+ },
35
+ "platform": [
36
+ "linux",
37
+ "macOS",
38
+ "windows"
39
+ ]
40
+ },
41
+ "previous": ""
42
+ }
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: "Verification & Quality Assurance"
3
3
  description: |
4
- Comprehensive truth scoring, code quality verification, and automatic rollback system with 0.95 accuracy threshold for ensuring high-quality agent outputs and codebase reliability.
4
+ Check code quality and change risk with ruflo's shipped analysis commands (analyze diff, analyze complexity, analyze code), and run or extend ruflo's own CI regression guards. Use when assessing a change's risk, finding complexity hot spots, or adding a regression guard to ruflo. The truth-scoring and auto-rollback commands described later in this file are design notes, not shipped CLI commands.
5
5
  ---
6
6
 
7
7
  # Verification & Quality Assurance Skill
@@ -62,31 +62,34 @@ node plugins/ruflo-core/scripts/witness/history.mjs --history verification/macos
62
62
 
63
63
  ## Prerequisites
64
64
 
65
- - Ruflo installed (`npx ruflo@alpha`)
65
+ - Ruflo installed (`npx ruflo@latest`)
66
66
  - Git repository (for rollback features)
67
67
  - Node.js 18+ (for dashboard features)
68
68
  - `@noble/ed25519` (for the witness verifier — a single runtime dep, `npm i @noble/ed25519`)
69
69
 
70
70
  ## Quick Start
71
71
 
72
- ```bash
73
- # View current truth scores
74
- npx ruflo@alpha truth
72
+ These commands ship in the current CLI:
75
73
 
76
- # Run verification check
77
- npx ruflo@alpha verify check
74
+ ```bash
75
+ # Change risk since HEAD~1 (without --risk it also shows classification and reviewers)
76
+ npx ruflo@latest analyze diff HEAD~1 --risk
78
77
 
79
- # Verify specific file with custom threshold
80
- npx ruflo@alpha verify check --file src/app.js --threshold 0.98
78
+ # Complexity hot spots in a directory
79
+ npx ruflo@latest analyze complexity src/ --threshold 15
81
80
 
82
- # Rollback last failed verification
83
- npx ruflo@alpha verify rollback --last-good
81
+ # Size, functions and TODOs per file
82
+ npx ruflo@latest analyze code -p ./src
84
83
  ```
85
84
 
85
+ There is no truth-scoring, `verify check` or `verify rollback` command (`ruflo verify` only checks an installed ruflo package against its signed witness manifest). To verify agent output, run the project's own tests, linters and type checks, and roll back with git (`git restore <file>`, `git revert <commit>`). Inside the ruflo repo, run the guards in [Run the guards locally](#run-the-guards-locally).
86
+
86
87
  ---
87
88
 
88
89
  ## Complete Guide
89
90
 
91
+ > **Design notes, not shipped.** Everything below describes a planned truth-scoring, verification and rollback surface. `ruflo truth`, `ruflo verify check` and `ruflo verify rollback` are not commands in the current CLI, so do not run the examples below; use the commands in [Quick Start](#quick-start) instead.
92
+
90
93
  ### Truth Scoring System
91
94
 
92
95
  #### View Truth Metrics
package/README.md CHANGED
@@ -51,7 +51,7 @@ MCP exposes Ruflo tools to your client. The console and mods above are Claude Co
51
51
 
52
52
  <img src="docs/assets/readme/icons/terminal.svg" width="28" height="28" alt=""> **Prefer a plain terminal? Optional.** The console also runs on its own, with no Claude Code: `npx ruflo tui` (add `--plain` to print one frame for scripts). It shows Overview, Cost, Swarm, Events and Missions, plus an optional AI page. [Terminal UI guide](docs/USERGUIDE.md#terminal-ui-optional)
53
53
 
54
- <p align="center"><img src="docs/assets/ruflo-tui-compact.svg" width="640" alt="Looping recording of the optional ruflo terminal UI cycling through Overview, Cost, Swarm, Events and Missions in a sample project"></p>
54
+ <p align="center"><img src="docs/assets/ruflo-tui-compact.svg" width="640" alt="Looping recording of the optional ruflo terminal UI with its pictures: Overview in the Classic BBS look, the Orbital look with its moving globe, and the Swarm graph, in a sample project"></p>
55
55
 
56
56
  [Compare install paths](#quick-start) · [Open the console](#console-walkthrough) · [User guide](docs/USERGUIDE.md)
57
57
 
File without changes
@@ -159,14 +159,14 @@ export declare const SpawnAgentSchema: z.ZodObject<{
159
159
  timeout: z.ZodOptional<z.ZodNumber>;
160
160
  }, "strip", z.ZodTypeAny, {
161
161
  type: "coder" | "reviewer" | "tester" | "planner" | "researcher" | "security-architect" | "security-auditor" | "memory-specialist" | "swarm-specialist" | "integration-architect" | "performance-engineer" | "core-architect" | "test-architect" | "queen-coordinator" | "project-coordinator";
162
+ id?: string | undefined;
162
163
  config?: Record<string, unknown> | undefined;
163
164
  timeout?: number | undefined;
164
- id?: string | undefined;
165
165
  }, {
166
166
  type: "coder" | "reviewer" | "tester" | "planner" | "researcher" | "security-architect" | "security-auditor" | "memory-specialist" | "swarm-specialist" | "integration-architect" | "performance-engineer" | "core-architect" | "test-architect" | "queen-coordinator" | "project-coordinator";
167
+ id?: string | undefined;
167
168
  config?: Record<string, unknown> | undefined;
168
169
  timeout?: number | undefined;
169
- id?: string | undefined;
170
170
  }>;
171
171
  /**
172
172
  * Task input schema
@@ -181,13 +181,13 @@ export declare const TaskInputSchema: z.ZodObject<{
181
181
  taskId: string;
182
182
  content: string;
183
183
  agentType: "coder" | "reviewer" | "tester" | "planner" | "researcher" | "security-architect" | "security-auditor" | "memory-specialist" | "swarm-specialist" | "integration-architect" | "performance-engineer" | "core-architect" | "test-architect" | "queen-coordinator" | "project-coordinator";
184
- priority?: "critical" | "high" | "medium" | "low" | undefined;
184
+ priority?: "low" | "medium" | "high" | "critical" | undefined;
185
185
  metadata?: Record<string, unknown> | undefined;
186
186
  }, {
187
187
  taskId: string;
188
188
  content: string;
189
189
  agentType: "coder" | "reviewer" | "tester" | "planner" | "researcher" | "security-architect" | "security-auditor" | "memory-specialist" | "swarm-specialist" | "integration-architect" | "performance-engineer" | "core-architect" | "test-architect" | "queen-coordinator" | "project-coordinator";
190
- priority?: "critical" | "high" | "medium" | "low" | undefined;
190
+ priority?: "low" | "medium" | "high" | "critical" | undefined;
191
191
  metadata?: Record<string, unknown> | undefined;
192
192
  }>;
193
193
  /**
@@ -234,16 +234,16 @@ export declare const ExecutorConfigSchema: z.ZodObject<{
234
234
  cwd: z.ZodOptional<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>>;
235
235
  allowSudo: z.ZodDefault<z.ZodBoolean>;
236
236
  }, "strip", z.ZodTypeAny, {
237
- allowedCommands: string[];
238
237
  timeout: number;
238
+ allowedCommands: string[];
239
239
  maxBuffer: number;
240
240
  allowSudo: boolean;
241
241
  blockedPatterns?: string[] | undefined;
242
242
  cwd?: string | undefined;
243
243
  }, {
244
244
  allowedCommands: string[];
245
- blockedPatterns?: string[] | undefined;
246
245
  timeout?: number | undefined;
246
+ blockedPatterns?: string[] | undefined;
247
247
  maxBuffer?: number | undefined;
248
248
  cwd?: string | undefined;
249
249
  allowSudo?: boolean | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-flow",
3
- "version": "3.56.9",
3
+ "version": "3.56.10",
4
4
  "workspaces": [
5
5
  "v3/@claude-flow/codex",
6
6
  "v3/@claude-flow/mcp",
@@ -68,7 +68,7 @@
68
68
  "v3:security": "npm run security:audit && npm run security:test"
69
69
  },
70
70
  "dependencies": {
71
- "@claude-flow/cli-core": "3.7.2",
71
+ "@claude-flow/cli-core": "3.7.3",
72
72
  "@claude-flow/codex": "3.0.5",
73
73
  "@claude-flow/mcp": "3.1.1",
74
74
  "@claude-flow/neural": "3.0.0",
@@ -80,6 +80,8 @@ export declare function discoverTasks(sources: string[]): TaskInfo[];
80
80
  export declare function isTerminal(status: string): boolean;
81
81
  export declare function getProgress(tasks: TaskInfo[]): TaskProgress;
82
82
  export declare function calculateReward(iterations: number, durationMs: number): number;
83
+ /** Why the last tryLoadLearning() returned null (null when it succeeded or was never called). */
84
+ export declare function getLearningLoadError(): string | null;
83
85
  export declare function tryLoadLearning(): Promise<{
84
86
  initialize: () => Promise<boolean>;
85
87
  [key: string]: unknown;
@@ -9,7 +9,9 @@
9
9
  */
10
10
  import { randomUUID } from 'node:crypto';
11
11
  import { existsSync, readFileSync, mkdirSync, readdirSync } from 'node:fs';
12
- import { resolve, join } from 'node:path';
12
+ import { resolve, join, dirname } from 'node:path';
13
+ import { createRequire } from 'node:module';
14
+ import { pathToFileURL } from 'node:url';
13
15
  import { homedir } from 'node:os';
14
16
  import { writeFileAtomic } from './fs-secure.js';
15
17
  // ── Constants ─────────────────────────────────────────────────
@@ -288,17 +290,43 @@ export function calculateReward(iterations, durationMs) {
288
290
  return Math.round((iterFactor + timeFactor) * 100) / 100;
289
291
  }
290
292
  // ── Learning Integration ──────────────────────────────────────
293
+ let lastLearningLoadError = null;
294
+ /** Why the last tryLoadLearning() returned null (null when it succeeded or was never called). */
295
+ export function getLearningLoadError() {
296
+ return lastLearningLoadError;
297
+ }
298
+ /**
299
+ * agentic-flow's `exports` map does not expose dist/coordination/*, so a bare
300
+ * specifier import throws ERR_PACKAGE_PATH_NOT_EXPORTED (#4146). Resolve the
301
+ * package root through its exported entry point and import the file by URL.
302
+ */
303
+ function resolveAutopilotLearningUrl() {
304
+ const req = createRequire(import.meta.url);
305
+ let dir = dirname(req.resolve('agentic-flow'));
306
+ for (let i = 0; i < 6; i++) {
307
+ if (existsSync(join(dir, 'package.json')) && existsSync(join(dir, 'dist', 'coordination', 'autopilot-learning.js'))) {
308
+ return pathToFileURL(join(dir, 'dist', 'coordination', 'autopilot-learning.js')).href;
309
+ }
310
+ dir = dirname(dir);
311
+ }
312
+ throw new Error('agentic-flow does not ship dist/coordination/autopilot-learning.js');
313
+ }
291
314
  export async function tryLoadLearning() {
315
+ lastLearningLoadError = null;
292
316
  try {
293
- const modPath = 'agentic-flow/dist/coordination/autopilot-learning.js';
294
- const mod = await import(/* webpackIgnore: true */ modPath).catch(() => null);
295
- if (mod?.AutopilotLearning) {
296
- const instance = new mod.AutopilotLearning();
297
- if (await instance.initialize())
298
- return instance;
317
+ const mod = await import(/* webpackIgnore: true */ resolveAutopilotLearningUrl());
318
+ if (!mod?.AutopilotLearning) {
319
+ lastLearningLoadError = 'agentic-flow autopilot-learning module has no AutopilotLearning export';
320
+ return null;
299
321
  }
322
+ const instance = new mod.AutopilotLearning();
323
+ if (await instance.initialize())
324
+ return instance;
325
+ lastLearningLoadError = 'AutopilotLearning.initialize() returned false (AgentDB not initialized)';
326
+ }
327
+ catch (e) {
328
+ lastLearningLoadError = `Could not load agentic-flow autopilot learning: ${e instanceof Error ? e.message : String(e)}`;
300
329
  }
301
- catch { /* not available */ }
302
330
  return null;
303
331
  }
304
332
  //# sourceMappingURL=autopilot-state.js.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Resolve which (sub)command an invocation targets.
3
+ *
4
+ * The parser reports the matched command path (for example
5
+ * ['hooks', 'transfer', 'store', 'search']) and the remaining positional arguments.
6
+ * Resolution walks the whole path through each command's `subcommands`, so a command
7
+ * can sit at any depth. #4157: it used to stop two levels below the top-level command,
8
+ * so `hooks transfer store search` ran the `store` help instead of `search`.
9
+ */
10
+ import type { Command } from './types.js';
11
+ export declare function resolveTargetCommand(command: Command, commandPath: string[], positional: string[]): {
12
+ target: Command;
13
+ args: string[];
14
+ };
15
+ //# sourceMappingURL=command-resolution.d.ts.map
@@ -0,0 +1,25 @@
1
+ const matches = (sc, name) => sc.name === name || !!sc.aliases?.includes(name);
2
+ export function resolveTargetCommand(command, commandPath, positional) {
3
+ let target = command;
4
+ if (commandPath.length > 1 && command.subcommands) {
5
+ // The parser already removed the path from `positional`.
6
+ for (const name of commandPath.slice(1)) {
7
+ const next = target.subcommands?.find((sc) => matches(sc, name));
8
+ if (!next)
9
+ break;
10
+ target = next;
11
+ }
12
+ return { target, args: positional };
13
+ }
14
+ // Positional form: the path only named the top-level command.
15
+ let args = positional;
16
+ while (args.length > 0 && target.subcommands) {
17
+ const next = target.subcommands.find((sc) => matches(sc, args[0]));
18
+ if (!next)
19
+ break;
20
+ target = next;
21
+ args = args.slice(1);
22
+ }
23
+ return { target, args };
24
+ }
25
+ //# sourceMappingURL=command-resolution.js.map
@@ -736,15 +736,16 @@ const healthCommand = {
736
736
  output.writeln(output.bold('Agent Health'));
737
737
  output.writeln();
738
738
  // Overall summary with null checks
739
- const overall = result.overall ?? { healthy: 0, degraded: 0, unhealthy: 0, avgCpu: 0, avgMemory: 0 };
740
- const avgCpu = overall.avgCpu ?? 0;
741
- const avgMemory = overall.avgMemory ?? 0;
739
+ const overall = result.overall ?? { healthy: 0, degraded: 0, unhealthy: 0, unknown: 0 };
740
+ const avgCpu = overall.avgCpu ?? overall.cpu;
741
+ const avgMemory = overall.avgMemory ?? overall.memory;
742
742
  output.printBox([
743
743
  `Healthy: ${output.success(String(overall.healthy ?? 0))}`,
744
744
  `Degraded: ${output.warning(String(overall.degraded ?? 0))}`,
745
745
  `Unhealthy: ${output.error(String(overall.unhealthy ?? 0))}`,
746
- `Avg CPU: ${avgCpu.toFixed(1)}%`,
747
- `Avg Memory: ${(avgMemory * 100).toFixed(1)}%`
746
+ `Unknown: ${String(overall.unknown ?? 0)}`,
747
+ `Avg CPU: ${typeof avgCpu === 'number' ? `${avgCpu.toFixed(1)}%` : 'n/a'}`,
748
+ `Avg Memory: ${typeof avgMemory === 'number' ? `${(avgMemory * 100).toFixed(1)}%` : 'n/a'}`
748
749
  ].join(' | '), 'Overall Status');
749
750
  const healthAgents = result.agents ?? [];
750
751
  output.writeln();
@@ -753,14 +754,14 @@ const healthCommand = {
753
754
  { key: 'id', header: 'Agent ID', width: 18 },
754
755
  { key: 'type', header: 'Type', width: 12 },
755
756
  { key: 'health', header: 'Health', width: 10, format: formatHealthStatus },
756
- { key: 'cpu', header: 'CPU %', width: 8, align: 'right', format: (v) => `${Number(v ?? 0).toFixed(1)}%` },
757
+ { key: 'cpu', header: 'CPU %', width: 8, align: 'right', format: (v) => typeof v === 'number' ? `${v.toFixed(1)}%` : 'n/a' },
757
758
  { key: 'memory', header: 'Memory', width: 10, align: 'right', format: (v) => {
758
759
  const mem = v;
759
- if (!mem)
760
- return '0%';
760
+ if (!mem || !mem.limit)
761
+ return 'n/a';
761
762
  return `${(mem.used / mem.limit * 100).toFixed(0)}%`;
762
763
  } },
763
- { key: 'tasks', header: 'Tasks', width: 12, align: 'right', format: (v) => {
764
+ { key: 'tasks', header: 'Calls', width: 12, align: 'right', format: (v) => {
764
765
  const t = v;
765
766
  if (!t)
766
767
  return '0/0';
@@ -775,15 +776,14 @@ const healthCommand = {
775
776
  for (const agent of healthAgents) {
776
777
  output.writeln();
777
778
  output.writeln(output.highlight(agent.id));
778
- const uptime = agent.uptime ?? 0;
779
- const latency = agent.latency ?? { avg: 0, p99: 0 };
780
- const tasks = agent.tasks ?? { completed: 0, failed: 0, queued: 0 };
781
- const errors = agent.errors ?? { count: 0 };
779
+ const latency = agent.latency;
780
+ const tasks = agent.tasks;
781
+ const errors = agent.errors;
782
782
  output.printList([
783
- `Uptime: ${(uptime / 1000 / 60).toFixed(1)} min`,
784
- `Latency: avg ${(latency.avg ?? 0).toFixed(1)}ms, p99 ${(latency.p99 ?? 0).toFixed(1)}ms`,
785
- `Tasks: ${tasks.completed ?? 0} completed, ${tasks.failed ?? 0} failed, ${tasks.queued ?? 0} queued`,
786
- `Errors: ${errors.count ?? 0}${errors.lastError ? ` (${errors.lastError})` : ''}`
783
+ `Registry age: ${typeof agent.registryAgeMs === 'number' ? `${(agent.registryAgeMs / 1000 / 60).toFixed(1)} min` : 'n/a'}`,
784
+ `Latency: p50 ${typeof latency?.p50 === 'number' ? `${latency.p50.toFixed(1)}ms` : 'n/a'}, p95 ${typeof latency?.p95 === 'number' ? `${latency.p95.toFixed(1)}ms` : 'n/a'}`,
785
+ `Observed provider calls (last 20): ${tasks?.completed ?? 0} API-success, ${tasks?.failed ?? 0} error`,
786
+ `Errors: ${errors?.count ?? 0}${errors?.lastError ? ` (${errors.lastError})` : ''}`
787
787
  ]);
788
788
  }
789
789
  }
@@ -5,7 +5,8 @@
5
5
  * Created with ❤️ by ruv.io
6
6
  */
7
7
  import { existsSync, readFileSync, writeFileSync, mkdirSync, renameSync } from 'node:fs';
8
- import { resolve, dirname } from 'node:path';
8
+ import { resolve, dirname, join } from 'node:path';
9
+ import { homedir } from 'node:os';
9
10
  import { output } from '../output.js';
10
11
  const CLAIMS_CONFIG_PATHS = [
11
12
  '.claude-flow/claims.json',
@@ -15,7 +16,9 @@ function getClaimsConfigPaths() {
15
16
  return [
16
17
  resolve(CLAIMS_CONFIG_PATHS[0]),
17
18
  resolve(CLAIMS_CONFIG_PATHS[1]),
18
- resolve(process.env.HOME || '~', '.config/claude-flow/claims.json'),
19
+ // os.homedir(), not $HOME: HOME is normally unset on Windows, and the old
20
+ // `process.env.HOME || '~'` fallback resolved to a literal <cwd>/~ folder.
21
+ join(homedir(), '.config', 'claude-flow', 'claims.json'),
19
22
  ];
20
23
  }
21
24
  function loadClaimsConfig() {
@@ -152,18 +155,13 @@ const checkCommand = {
152
155
  const spinner = output.createSpinner({ text: 'Evaluating claim...', spinner: 'dots' });
153
156
  spinner.start();
154
157
  const fs = await import('fs');
155
- const path = await import('path');
156
158
  // Real claims evaluation from config file
157
159
  let isGranted = false;
158
160
  let reason = 'Claim not found in policy';
159
161
  let policySource = 'default';
160
162
  try {
161
163
  // Check for claims config file
162
- const claimsConfigPaths = [
163
- path.resolve('.claude-flow/claims.json'),
164
- path.resolve('claude-flow.claims.json'),
165
- path.resolve(process.env.HOME || '~', '.config/claude-flow/claims.json'),
166
- ];
164
+ const claimsConfigPaths = getClaimsConfigPaths();
167
165
  let claimsConfig = {
168
166
  // Default policy - allows basic operations
169
167
  roles: {