@claude-flow/cli 3.25.5 → 3.26.0

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 (83) hide show
  1. package/.claude/.proven-config-version +1 -0
  2. package/.claude/helpers/.helpers-version +1 -1
  3. package/.claude/helpers/helpers.manifest.json +5 -4
  4. package/.claude/helpers/hook-handler.cjs +129 -0
  5. package/.claude/helpers/statusline.cjs +771 -505
  6. package/.claude/proven-config.json +42 -0
  7. package/catalog-manifest.json +12 -0
  8. package/dist/src/commands/advisor.d.ts +15 -0
  9. package/dist/src/commands/advisor.js +94 -0
  10. package/dist/src/commands/doctor.js +151 -32
  11. package/dist/src/commands/funnel.d.ts +13 -0
  12. package/dist/src/commands/funnel.js +103 -0
  13. package/dist/src/commands/hooks.js +112 -46
  14. package/dist/src/commands/index.js +10 -0
  15. package/dist/src/commands/init.js +44 -0
  16. package/dist/src/commands/proxy.d.ts +21 -0
  17. package/dist/src/commands/proxy.js +310 -0
  18. package/dist/src/commands/security.js +29 -0
  19. package/dist/src/commands/settings.d.ts +19 -0
  20. package/dist/src/commands/settings.js +180 -0
  21. package/dist/src/commands/version.d.ts +42 -0
  22. package/dist/src/commands/version.js +106 -0
  23. package/dist/src/funnel/advisor-tip.d.ts +58 -0
  24. package/dist/src/funnel/advisor-tip.js +92 -0
  25. package/dist/src/funnel/attribution.d.ts +37 -0
  26. package/dist/src/funnel/attribution.js +101 -0
  27. package/dist/src/funnel/consent.d.ts +22 -0
  28. package/dist/src/funnel/consent.js +55 -0
  29. package/dist/src/funnel/credit-errors.d.ts +31 -0
  30. package/dist/src/funnel/credit-errors.js +88 -0
  31. package/dist/src/funnel/credit-notifier.d.ts +44 -0
  32. package/dist/src/funnel/credit-notifier.js +74 -0
  33. package/dist/src/funnel/disclosure.d.ts +46 -0
  34. package/dist/src/funnel/disclosure.js +97 -0
  35. package/dist/src/funnel/enrollment.d.ts +36 -0
  36. package/dist/src/funnel/enrollment.js +64 -0
  37. package/dist/src/funnel/environment.d.ts +17 -0
  38. package/dist/src/funnel/environment.js +39 -0
  39. package/dist/src/funnel/event-transport.d.ts +51 -0
  40. package/dist/src/funnel/event-transport.js +199 -0
  41. package/dist/src/funnel/events.d.ts +42 -0
  42. package/dist/src/funnel/events.js +150 -0
  43. package/dist/src/funnel/index.d.ts +20 -0
  44. package/dist/src/funnel/index.js +20 -0
  45. package/dist/src/funnel/insights.d.ts +49 -0
  46. package/dist/src/funnel/insights.js +120 -0
  47. package/dist/src/funnel/local-signals.d.ts +15 -0
  48. package/dist/src/funnel/local-signals.js +68 -0
  49. package/dist/src/funnel/message-transport.d.ts +51 -0
  50. package/dist/src/funnel/message-transport.js +149 -0
  51. package/dist/src/funnel/messages.d.ts +55 -0
  52. package/dist/src/funnel/messages.js +160 -0
  53. package/dist/src/funnel/power-saver-notifier.d.ts +44 -0
  54. package/dist/src/funnel/power-saver-notifier.js +92 -0
  55. package/dist/src/funnel/precedence.d.ts +16 -0
  56. package/dist/src/funnel/precedence.js +85 -0
  57. package/dist/src/funnel/promo.d.ts +41 -0
  58. package/dist/src/funnel/promo.js +144 -0
  59. package/dist/src/funnel/rate-limit-notifier.d.ts +55 -0
  60. package/dist/src/funnel/rate-limit-notifier.js +102 -0
  61. package/dist/src/funnel/rotation.d.ts +19 -0
  62. package/dist/src/funnel/rotation.js +70 -0
  63. package/dist/src/funnel/state.d.ts +13 -0
  64. package/dist/src/funnel/state.js +52 -0
  65. package/dist/src/funnel/toggle-cooldown.d.ts +17 -0
  66. package/dist/src/funnel/toggle-cooldown.js +32 -0
  67. package/dist/src/funnel/types.d.ts +86 -0
  68. package/dist/src/funnel/types.js +26 -0
  69. package/dist/src/init/executor.js +25 -19
  70. package/dist/src/init/helper-refresh.d.ts +33 -2
  71. package/dist/src/init/helper-refresh.js +102 -12
  72. package/dist/src/init/helpers-generator.js +52 -0
  73. package/dist/src/init/mcp-generator.js +11 -6
  74. package/dist/src/init/statusline-generator.js +282 -116
  75. package/dist/src/services/daemon-autostart.js +28 -5
  76. package/dist/src/services/fable-harness.d.ts +39 -0
  77. package/dist/src/services/fable-harness.js +41 -0
  78. package/package.json +16 -4
  79. package/plugins/ruflo-metaharness/scripts/smoke.sh +18 -5
  80. package/dist/src/ruvector/lattice-wasm.d.ts +0 -14
  81. package/dist/src/ruvector/lattice-wasm.js +0 -144
  82. package/plugins/ruflo-metaharness/.claude-flow/data/pending-insights.jsonl +0 -5
  83. package/plugins/ruflo-metaharness/.claude-flow/neural/stats.json +0 -6
@@ -0,0 +1 @@
1
+ sha256:6141a8ea990c5063b77e090ae8f37f9c539d8aa8f58dcceb30f3a82f97e57319
@@ -1 +1 @@
1
- 3.23.0
1
+ 3.25.6
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "manifest": {
3
- "version": "3.25.4",
3
+ "version": "3.26.0",
4
4
  "files": {
5
5
  "auto-memory-hook.mjs": "68be7e9a9eba7bf9c4e8a230db7bf61a243b965639f8504842799d6c6ca28762",
6
- "hook-handler.cjs": "bc4d2d26823d49b3ab1dded2946b66369f1f67bd76b4c30dca9f3b6df3cca8f0",
7
- "intelligence.cjs": "bd1f8e4b034944aee1df0391dc47ac2e8cc4b3aa542c65407a59d49620bbf76b"
6
+ "hook-handler.cjs": "2a18a761f0dc4839df8b6eeadf8f0ceb6badcc5bf14414c91555711a5e9d4bdc",
7
+ "intelligence.cjs": "bd1f8e4b034944aee1df0391dc47ac2e8cc4b3aa542c65407a59d49620bbf76b",
8
+ "statusline.cjs": "ac6be4ed31b30cef7b325c15d0feb77f3a8a26a69f7186907ba0340d332f2d05"
8
9
  }
9
10
  },
10
- "signature": "F3TIRoNcQTCkNeMEk5Isah5CWkV/zddUKR/6pieOlAWoYgI2BEUO7avQj8B8UP4vhvgT9TSgbYsis2UnnnQyBg==",
11
+ "signature": "htvyWBS+UYspE4SIyoVj+S4HdaJymRlQGYQSMSP5PCang0CelajiGJKyaY3c0vzBUn7DAMxbXDl9jLlSe+j/DA==",
11
12
  "algorithm": "ed25519"
12
13
  }
@@ -15,9 +15,79 @@
15
15
 
16
16
  const path = require('path');
17
17
  const fs = require('fs');
18
+ const os = require('os');
18
19
 
19
20
  const helpersDir = __dirname;
20
21
 
22
+ // Resolve an installed @claude-flow/cli (or ruflo) bin — mirrors
23
+ // statusline-generator.ts's resolveCliBin() candidate list. Used only to
24
+ // spawn the detached funnel-refresh helper below; failures are silent (no
25
+ // candidate found just means the refresh never fires this session).
26
+ function resolveCliBinForHook() {
27
+ try {
28
+ const home = os.homedir();
29
+ const cwd = process.cwd();
30
+ const candidates = [
31
+ path.join(home, '.claude', 'plugins', 'marketplaces', 'ruflo', 'bin', 'cli.js'),
32
+ path.join(cwd, 'node_modules', '@claude-flow', 'cli', 'bin', 'cli.js'),
33
+ path.join(cwd, 'node_modules', 'ruflo', 'bin', 'cli.js'),
34
+ path.join(cwd, 'v3', '@claude-flow', 'cli', 'bin', 'cli.js'),
35
+ // helpersDir is .claude/helpers/ inside the package itself when this
36
+ // file is running from a real @claude-flow/cli install (not a project
37
+ // that merely copied the helper) — its bin/ is two levels up.
38
+ path.join(helpersDir, '..', '..', 'bin', 'cli.js'),
39
+ ];
40
+ for (const p of candidates) {
41
+ if (fs.existsSync(p)) return p;
42
+ }
43
+ } catch (e) { /* ignore */ }
44
+ return null;
45
+ }
46
+
47
+ // Fire-and-forget doesn't work when the CALLER is itself a short-lived
48
+ // subprocess (confirmed live: two consecutive statusline renders 5s apart
49
+ // both saw an empty funnel-messages-cache, because the async HTTPS fetch
50
+ // inside a `void refreshRemoteMessages()` call gets killed when the spawning
51
+ // process exits before the request completes). Spawning fully DETACHED +
52
+ // unref'd decouples the refresh's lifetime from this hook's — it keeps
53
+ // running (up to message-transport.ts's own 4s fetch timeout) even after
54
+ // session-restore's own process has already exited, so it actually gets a
55
+ // chance to write the cache. Never awaited here — must not add to
56
+ // SessionStart's own timeout budget.
57
+ function spawnDetachedFunnelRefresh() {
58
+ try {
59
+ const cliBin = resolveCliBinForHook();
60
+ if (!cliBin) return;
61
+ const { spawn } = require('child_process');
62
+ const child = spawn(process.execPath, [cliBin, 'hooks', 'refresh-funnel', '--quiet'], {
63
+ detached: true,
64
+ stdio: 'ignore',
65
+ env: process.env,
66
+ });
67
+ child.unref();
68
+ } catch (e) { /* best-effort only */ }
69
+ }
70
+
71
+ // Same detached/unref'd pattern as spawnDetachedFunnelRefresh() above, for
72
+ // ADR-316's co-pilot advisor tip. Safe to call on EVERY session-restore:
73
+ // refresh-advisor's own action checks consent + a 24h TTL BEFORE spending
74
+ // anything, so an unconsented or already-fresh install is a fast no-op file
75
+ // read, never a network call. Never awaited here — must not add to
76
+ // SessionStart's own timeout budget.
77
+ function spawnDetachedAdvisorRefresh() {
78
+ try {
79
+ const cliBin = resolveCliBinForHook();
80
+ if (!cliBin) return;
81
+ const { spawn } = require('child_process');
82
+ const child = spawn(process.execPath, [cliBin, 'hooks', 'refresh-advisor', '--quiet'], {
83
+ detached: true,
84
+ stdio: 'ignore',
85
+ env: process.env,
86
+ });
87
+ child.unref();
88
+ } catch (e) { /* best-effort only */ }
89
+ }
90
+
21
91
  // Safe require with stdout suppression - the helper modules have CLI
22
92
  // sections that run unconditionally on require(), so we mute console
23
93
  // during the require to prevent noisy output.
@@ -168,6 +238,57 @@ const handlers = {
168
238
  } else {
169
239
  console.log('[INFO] Router not available, using default routing');
170
240
  }
241
+
242
+ // Rate-limit -> sponsored-capacity nudge (ADR-312/313). Fires here,
243
+ // client-side, BEFORE the API call this prompt would make — so it still
244
+ // reaches the transcript even if that call then fails from the rate
245
+ // limit. Cheap local file reads only; never a network call or a child
246
+ // process, so it cannot add latency to prompt submission.
247
+ try {
248
+ const rlFunnelEnv = process.env.RUFLO_FUNNEL;
249
+ const rlDisabledByEnv = rlFunnelEnv !== undefined && /^(0|false|off|no)$/i.test(String(rlFunnelEnv).trim());
250
+ const rlCiVars = ['CI', 'GITHUB_ACTIONS', 'GITLAB_CI', 'CIRCLECI', 'TRAVIS', 'BUILDKITE', 'JENKINS_URL', 'TEAMCITY_VERSION', 'TF_BUILD'];
251
+ const rlIsCi = rlCiVars.some((v) => {
252
+ const val = process.env[v];
253
+ return val !== undefined && val !== '' && val !== '0' && String(val).toLowerCase() !== 'false';
254
+ });
255
+ const rlHome = path.join(os.homedir(), '.ruflo');
256
+ let rlUserDisabled = false;
257
+ try {
258
+ const rlUserCfg = JSON.parse(fs.readFileSync(path.join(rlHome, 'funnel.json'), 'utf8'));
259
+ rlUserDisabled = !!(rlUserCfg && rlUserCfg.enabled === false);
260
+ } catch (e) { /* absent/malformed = not disabled */ }
261
+ let rlProjectDisabled = false;
262
+ try {
263
+ const rlProjCfg = JSON.parse(fs.readFileSync(path.join(process.cwd(), 'claude-flow.config.json'), 'utf8'));
264
+ rlProjectDisabled = !!(rlProjCfg && rlProjCfg.funnel && rlProjCfg.funnel.enabled === false);
265
+ } catch (e) { /* absent/malformed = not disabled */ }
266
+
267
+ if (!rlDisabledByEnv && !rlIsCi && !rlUserDisabled && !rlProjectDisabled) {
268
+ let rlStatus = null;
269
+ try { rlStatus = JSON.parse(fs.readFileSync(path.join(rlHome, 'rate-limit-status.json'), 'utf8')); } catch (e) { /* not flagged */ }
270
+ let rlIsLimited = false;
271
+ if (rlStatus && rlStatus.limited) {
272
+ if (rlStatus.since) {
273
+ const rlSinceMs = Date.parse(rlStatus.since);
274
+ rlIsLimited = isNaN(rlSinceMs) ? true : (Date.now() - rlSinceMs) < 6 * 60 * 60 * 1000;
275
+ } else {
276
+ rlIsLimited = true;
277
+ }
278
+ }
279
+ if (rlIsLimited) {
280
+ let rlConsented = false;
281
+ try {
282
+ const rlConsentFile = JSON.parse(fs.readFileSync(path.join(rlHome, 'consent.json'), 'utf8'));
283
+ const rlReceipt = rlConsentFile && rlConsentFile['sponsored-downtime'];
284
+ rlConsented = !!(rlReceipt && rlReceipt.granted === true && rlReceipt.at !== null && rlReceipt.policyVersion === 1);
285
+ } catch (e) { /* not consented */ }
286
+ if (!rlConsented) {
287
+ console.log('[COGNITUM] Hit your Claude usage limit? Free sponsored capacity is available at cognitum.one/meta-llm — run: ruflo proxy sponsor-enable --yes');
288
+ }
289
+ }
290
+ }
291
+ } catch (e) { /* nudge must never break the hook */ }
171
292
  },
172
293
 
173
294
  'pre-bash': () => {
@@ -234,6 +355,14 @@ const handlers = {
234
355
  console.log(`[INTELLIGENCE] Loaded ${initResult.nodes} patterns, ${initResult.edges} edges`);
235
356
  }
236
357
  }
358
+ // Warm the funnel message cache once per session (see
359
+ // spawnDetachedFunnelRefresh's doc comment for why this must happen
360
+ // here, detached, rather than as the statusline's own fire-and-forget).
361
+ spawnDetachedFunnelRefresh();
362
+ // ADR-316 co-pilot advisor tip — same detached pattern; cheap no-op
363
+ // when not consented or still within the 24h TTL (see refresh-advisor's
364
+ // own doc comment).
365
+ spawnDetachedAdvisorRefresh();
237
366
  },
238
367
 
239
368
  'session-end': async () => {