@claude-flow/cli 3.29.0 → 3.30.1

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.
@@ -0,0 +1,329 @@
1
+ /**
2
+ * `ruflo spinner` — manage ruflo verbs in Claude Code's spinnerVerbs
3
+ * settings (ADR-318).
4
+ *
5
+ * Claude Code exposes `spinnerVerbs.mode` + `spinnerVerbs.verbs[]` in
6
+ * ~/.claude/settings.json. This command appends a curated ruflo pool to
7
+ * that array, tagged with a zero-width joiner marker so `disable` can
8
+ * strip only ruflo verbs without touching user-authored ones.
9
+ *
10
+ * NEVER replaces — always appends (see ADR-318 §Guarantees). Always backs
11
+ * up ~/.claude/settings.json before write.
12
+ */
13
+ import * as fs from 'node:fs';
14
+ import * as os from 'node:os';
15
+ import * as path from 'node:path';
16
+ import { output } from '../output.js';
17
+ import { hasConsent, recordConsent, revokeConsent } from '../funnel/consent.js';
18
+ // Zero-width joiner triple — invisible in every terminal that renders it,
19
+ // takes zero display cells, and is exceedingly unlikely to appear in a
20
+ // user-authored verb. Used to tag ruflo-managed entries so `disable`
21
+ // removes ONLY ours.
22
+ const RUFLO_MARKER = '‍‍‍';
23
+ const SETTINGS_PATH = path.join(os.homedir(), '.claude', 'settings.json');
24
+ // v0 baked pool (see ADR-318 for the v1 remote-served plan). Mix of neutral
25
+ // and Cognitum-tagged verbs, all validated (some word ends in -ing, ≤ 30 chars).
26
+ //
27
+ // Ratio target: ~15% Cognitum-tagged, ~85% neutral — sponsor is visible but
28
+ // doesn't dominate. With append mode + ~50 Claude Code default verbs, this
29
+ // gives roughly a 40% chance any spin is a ruflo verb, and ~6% of ALL spins
30
+ // show a Cognitum-tagged verb.
31
+ const RUFLO_VERB_POOL_V0 = [
32
+ // Memory & retrieval (7)
33
+ 'Consulting the memory graph',
34
+ 'Warming the HNSW index',
35
+ 'Recalling similar patterns',
36
+ 'Searching semantic memory',
37
+ 'Reranking with MMR',
38
+ 'Traversing knowledge graph',
39
+ 'Loading trajectory context',
40
+ // Optimization (6)
41
+ 'Optimizing your prompt',
42
+ 'Sharpening the plan',
43
+ 'Compacting the context',
44
+ 'Distilling the trajectory',
45
+ 'Reducing token spend',
46
+ 'Compressing the working set',
47
+ // Learning & intelligence (6)
48
+ 'Learning from the trajectory',
49
+ 'Training the router',
50
+ 'Judging past verdicts',
51
+ 'Consolidating memories',
52
+ 'Reasoning through the graph',
53
+ 'Predicting the next step',
54
+ // Security & audit (4)
55
+ 'Auditing for CVEs',
56
+ 'Scanning dependencies',
57
+ 'Verifying signatures',
58
+ 'Guarding against injection',
59
+ // Agents & swarm (4)
60
+ 'Spawning subagents',
61
+ 'Coordinating the swarm',
62
+ 'Reaching consensus',
63
+ 'Balancing the workload',
64
+ // Workflow (4)
65
+ 'Routing to the best model',
66
+ 'Warming background workers',
67
+ 'Analyzing the diff',
68
+ 'Sharpening the review',
69
+ // Cognitum-tagged (6)
70
+ 'Consulting Cognitum',
71
+ 'Checking Cognitum credits',
72
+ 'Routing via Cognitum',
73
+ 'Fetching a Cognitum tip',
74
+ 'Warming Cognitum cache',
75
+ 'Weighing Cognitum options',
76
+ ];
77
+ // Reject anything that violates the ADR-318 §Guarantees ingest rules.
78
+ function isValidVerb(v) {
79
+ if (typeof v !== 'string')
80
+ return false;
81
+ const stripped = v.replace(RUFLO_MARKER, '');
82
+ if (stripped.length === 0 || stripped.length > 30)
83
+ return false;
84
+ // Claude Code's spinnerVerbs takes present participles. Traditionally
85
+ // one word ("Thinking"), but multi-word phrases work too as long as
86
+ // some word ends in "-ing". Was `/ing$/i.test(stripped)` which required
87
+ // the whole STRING end in "ing" — that rejected every multi-word verb
88
+ // in the pool ("Optimizing your prompt" ends in "prompt", not "ing").
89
+ const words = stripped.split(/\s+/).filter(Boolean);
90
+ if (!words.some(w => /ing$/i.test(w)))
91
+ return false;
92
+ // Per-code-point iteration (not regex) — a naive `/[…]/` char class
93
+ // parsed as raw UTF-8 bytes matches bytes INSIDE multi-byte sequences
94
+ // of legit emoji. Today's pool is pure ASCII so the old regex worked
95
+ // by accident; this is the defensive fix ahead of any future emoji verb.
96
+ // Same pattern as commands/announcements.ts.
97
+ for (const ch of stripped) {
98
+ const cp = ch.codePointAt(0);
99
+ if (cp < 0x20)
100
+ return false;
101
+ if (cp === 0x7f)
102
+ return false;
103
+ if (cp >= 0x80 && cp <= 0x9f)
104
+ return false;
105
+ if (cp >= 0x202a && cp <= 0x202e)
106
+ return false;
107
+ if (cp >= 0x2066 && cp <= 0x2069)
108
+ return false;
109
+ }
110
+ if (/https?:\/\//i.test(stripped))
111
+ return false;
112
+ return true;
113
+ }
114
+ function markVerb(v) {
115
+ return v + RUFLO_MARKER;
116
+ }
117
+ function isRufloVerb(v) {
118
+ return typeof v === 'string' && v.includes(RUFLO_MARKER);
119
+ }
120
+ function readSettings() {
121
+ try {
122
+ const raw = fs.readFileSync(SETTINGS_PATH, 'utf-8');
123
+ return { data: JSON.parse(raw), raw };
124
+ }
125
+ catch {
126
+ return { data: {}, raw: null };
127
+ }
128
+ }
129
+ function backupSettings(raw) {
130
+ const ts = new Date().toISOString().replace(/[:.]/g, '-');
131
+ const backupPath = SETTINGS_PATH + '.bak-' + ts;
132
+ fs.writeFileSync(backupPath, raw, 'utf-8');
133
+ return backupPath;
134
+ }
135
+ function findMostRecentBackup() {
136
+ try {
137
+ const dir = path.dirname(SETTINGS_PATH);
138
+ const base = path.basename(SETTINGS_PATH);
139
+ const entries = fs.readdirSync(dir)
140
+ .filter(f => f.startsWith(base + '.bak-'))
141
+ .sort()
142
+ .reverse();
143
+ return entries.length > 0 ? path.join(dir, entries[0]) : null;
144
+ }
145
+ catch {
146
+ return null;
147
+ }
148
+ }
149
+ function writeSettings(data) {
150
+ // Ensure the .claude directory exists (fresh install case).
151
+ fs.mkdirSync(path.dirname(SETTINGS_PATH), { recursive: true });
152
+ // Atomic write: write to sibling temp file, rename over.
153
+ const tmp = SETTINGS_PATH + '.tmp-' + process.pid;
154
+ fs.writeFileSync(tmp, JSON.stringify(data, null, 2) + '\n', 'utf-8');
155
+ fs.renameSync(tmp, SETTINGS_PATH);
156
+ }
157
+ const enableSub = {
158
+ name: 'enable',
159
+ description: "Add ruflo's curated verb pool to Claude Code's spinner rotation",
160
+ options: [
161
+ { name: 'yes', description: 'Skip the confirmation prompt', type: 'boolean', default: false },
162
+ ],
163
+ action: async (ctx) => {
164
+ const validVerbs = RUFLO_VERB_POOL_V0.filter(isValidVerb);
165
+ if (validVerbs.length === 0) {
166
+ output.printError('Verb pool is empty after validation — refusing to write nothing.');
167
+ return { success: false };
168
+ }
169
+ // Disclosure moment (per ADR-318 §Full mix). Print the pool including
170
+ // Cognitum-tagged entries so the user sees what they're opting in to.
171
+ output.writeln('The following verbs will be appended to Claude Code\'s spinner rotation:');
172
+ output.writeln('');
173
+ for (const v of validVerbs)
174
+ output.writeln(' • ' + v);
175
+ output.writeln('');
176
+ output.writeln('Some verbs mention Cognitum, Ruflo\'s sponsor. This is opt-in and reversible via');
177
+ output.writeln("`ruflo spinner disable`. Claude Code's default verbs are preserved (append-only).");
178
+ if (!ctx.flags.yes) {
179
+ output.writeln('');
180
+ output.printWarning('Re-run with --yes to confirm.');
181
+ return { success: false, data: { previewedVerbs: validVerbs.length } };
182
+ }
183
+ // Read current settings, back up, merge.
184
+ const { data, raw } = readSettings();
185
+ let backupPath = null;
186
+ if (raw)
187
+ backupPath = backupSettings(raw);
188
+ const currentBlock = data.spinnerVerbs ?? {};
189
+ if (currentBlock.mode === 'replace') {
190
+ output.printError('settings.json has spinnerVerbs.mode = "replace" — refusing to append (would silently be inert). ' +
191
+ 'Either change your mode to "append" manually and re-run, or accept ruflo\'s pool as your entire set via manual edit.');
192
+ return { success: false, data: { currentMode: 'replace' } };
193
+ }
194
+ const currentVerbs = Array.isArray(currentBlock.verbs) ? currentBlock.verbs : [];
195
+ // Strip any prior ruflo entries so re-running enable is idempotent
196
+ // instead of duplicating our pool every time.
197
+ const preservedUserVerbs = currentVerbs.filter(v => !isRufloVerb(v));
198
+ const newVerbs = validVerbs.map(markVerb);
199
+ data.spinnerVerbs = {
200
+ mode: 'append',
201
+ verbs: [...preservedUserVerbs, ...newVerbs],
202
+ };
203
+ writeSettings(data);
204
+ recordConsent('spinner-verbs', true, 'cli-spinner-enable');
205
+ output.printSuccess(`Enabled — appended ${newVerbs.length} verbs to spinnerVerbs.`);
206
+ if (backupPath)
207
+ output.writeln(`Backup: ${backupPath}`);
208
+ return {
209
+ success: true,
210
+ data: {
211
+ appended: newVerbs.length,
212
+ preservedUserVerbs: preservedUserVerbs.length,
213
+ backup: backupPath,
214
+ },
215
+ };
216
+ },
217
+ };
218
+ const disableSub = {
219
+ name: 'disable',
220
+ description: 'Remove ruflo verbs from Claude Code\'s spinner rotation (user-authored verbs preserved)',
221
+ action: async () => {
222
+ const { data, raw } = readSettings();
223
+ if (!raw || !data.spinnerVerbs?.verbs?.length) {
224
+ revokeConsent('spinner-verbs', 'cli-spinner-disable');
225
+ output.writeln('Nothing to disable — no spinnerVerbs block found in settings.json.');
226
+ return { success: true, data: { removed: 0 } };
227
+ }
228
+ const backupPath = backupSettings(raw);
229
+ const before = data.spinnerVerbs.verbs.length;
230
+ data.spinnerVerbs.verbs = data.spinnerVerbs.verbs.filter(v => !isRufloVerb(v));
231
+ const after = data.spinnerVerbs.verbs.length;
232
+ // If we removed everything and the block is now empty, drop the block
233
+ // entirely so Claude Code falls straight back to its defaults.
234
+ if (data.spinnerVerbs.verbs.length === 0)
235
+ delete data.spinnerVerbs;
236
+ writeSettings(data);
237
+ revokeConsent('spinner-verbs', 'cli-spinner-disable');
238
+ output.printSuccess(`Disabled — removed ${before - after} ruflo verbs (kept ${after} user-authored).`);
239
+ output.writeln(`Backup: ${backupPath}`);
240
+ return { success: true, data: { removed: before - after, kept: after, backup: backupPath } };
241
+ },
242
+ };
243
+ const listSub = {
244
+ name: 'list',
245
+ description: 'Show ruflo\'s verb pool and which verbs are currently installed',
246
+ options: [
247
+ { name: 'json', description: 'Output as JSON', type: 'boolean', default: false },
248
+ ],
249
+ action: async (ctx) => {
250
+ const { data } = readSettings();
251
+ const installed = data.spinnerVerbs?.verbs ?? [];
252
+ const installedRuflo = installed.filter(isRufloVerb).map(v => v.replace(RUFLO_MARKER, ''));
253
+ const installedUser = installed.filter(v => !isRufloVerb(v));
254
+ const pool = RUFLO_VERB_POOL_V0.filter(isValidVerb);
255
+ const summary = {
256
+ consent: hasConsent('spinner-verbs') ? 'granted' : 'not-granted',
257
+ mode: data.spinnerVerbs?.mode ?? '(none)',
258
+ pool_available: pool,
259
+ installed_ruflo: installedRuflo,
260
+ installed_user_authored: installedUser,
261
+ };
262
+ if (ctx.flags.json) {
263
+ output.printJson(summary);
264
+ }
265
+ else {
266
+ output.writeln(`Consent: ${summary.consent}`);
267
+ output.writeln(`spinnerVerbs.mode in settings.json: ${summary.mode}`);
268
+ output.writeln('');
269
+ output.writeln(`Ruflo pool (${pool.length} verbs, available):`);
270
+ for (const v of pool)
271
+ output.writeln(' • ' + v);
272
+ output.writeln('');
273
+ output.writeln(`Currently installed ruflo verbs (${installedRuflo.length}):`);
274
+ if (installedRuflo.length === 0)
275
+ output.writeln(' (none — run `ruflo spinner enable --yes` to install)');
276
+ else
277
+ for (const v of installedRuflo)
278
+ output.writeln(' • ' + v);
279
+ output.writeln('');
280
+ output.writeln(`User-authored verbs (${installedUser.length}, untouched by ruflo):`);
281
+ for (const v of installedUser)
282
+ output.writeln(' • ' + v);
283
+ }
284
+ return { success: true, data: summary };
285
+ },
286
+ };
287
+ const resetSub = {
288
+ name: 'reset',
289
+ description: 'Restore the most recent settings.json backup (destructive)',
290
+ options: [
291
+ { name: 'yes', description: 'Skip the confirmation prompt', type: 'boolean', default: false },
292
+ ],
293
+ action: async (ctx) => {
294
+ const backup = findMostRecentBackup();
295
+ if (!backup) {
296
+ output.printWarning('No settings.json backup found — nothing to restore.');
297
+ return { success: false };
298
+ }
299
+ if (!ctx.flags.yes) {
300
+ output.writeln(`Would restore: ${backup}`);
301
+ output.writeln(`Over: ${SETTINGS_PATH}`);
302
+ output.writeln('');
303
+ output.printWarning('Re-run with --yes to confirm.');
304
+ return { success: false, data: { wouldRestore: backup } };
305
+ }
306
+ // Backup the CURRENT file too before overwriting, so reset is itself reversible.
307
+ const { raw } = readSettings();
308
+ if (raw)
309
+ backupSettings(raw);
310
+ fs.copyFileSync(backup, SETTINGS_PATH);
311
+ revokeConsent('spinner-verbs', 'cli-spinner-reset');
312
+ output.printSuccess(`Restored settings.json from ${backup}`);
313
+ return { success: true, data: { restoredFrom: backup } };
314
+ },
315
+ };
316
+ export const spinnerCommand = {
317
+ name: 'spinner',
318
+ description: 'Manage ruflo verbs in Claude Code\'s spinnerVerbs rotation (ADR-318)',
319
+ subcommands: [enableSub, disableSub, listSub, resetSub],
320
+ examples: [
321
+ { command: 'ruflo spinner list', description: 'Show the ruflo pool + what\'s currently installed' },
322
+ { command: 'ruflo spinner enable --yes', description: 'Append ruflo\'s verb pool to settings.json' },
323
+ { command: 'ruflo spinner disable', description: 'Remove ruflo verbs, keep user-authored ones' },
324
+ { command: 'ruflo spinner reset --yes', description: 'Restore the most recent settings.json backup' },
325
+ ],
326
+ action: listSub.action,
327
+ };
328
+ export default spinnerCommand;
329
+ //# sourceMappingURL=spinner.js.map
@@ -20,6 +20,9 @@ export const CONSENT_DOMAINS = [
20
20
  'power-saver',
21
21
  'training-data-sharing',
22
22
  'advisor-tips',
23
+ 'rev-share-payout',
24
+ 'spinner-verbs',
25
+ 'company-announcements',
23
26
  ];
24
27
  export function readConsents() {
25
28
  return readStateJson(CONSENT_FILE) ?? {};
@@ -14,6 +14,7 @@ export { PROMO_REPEAT_CAP_MS, PROMO_SLOT_MODULO, ROTATION_SLOT_MS, selectMessage
14
14
  export { CREDIT_RECOVERY_HINT, classifyCreditError, renderCreditRecovery, shouldShowCreditRecovery, type CreditPromptSession, type ProviderErrorLike, } from './credit-errors.js';
15
15
  export { deleteFunnelData, getFunnelId, lastRecordedEvent, recordFunnelEvent } from './events.js';
16
16
  export { getFunnelPromo, type PromoContext } from './promo.js';
17
+ export { PAYOUT_POLICY_VERSION, deleteEnrollment, getAttributionToken, getEnrollment, isEarningEligible, recordEnrollment, } from './payout.js';
17
18
  export { RATE_LIMIT_TTL_MS, clearRateLimitStatus, markRateLimited, rateLimitNotice, readRateLimitStatus, type RateLimitStatus, } from './rate-limit-notifier.js';
18
19
  export { QUOTA_LOW_TTL_MS, clearQuotaLowStatus, markQuotaLow, quotaLowNotice, readQuotaLowStatus, type QuotaLowStatus, } from './power-saver-notifier.js';
19
20
  export { TOGGLE_COOLDOWN_MS, cooldownActive, cooldownRemainingMin } from './toggle-cooldown.js';
@@ -14,6 +14,7 @@ export { PROMO_REPEAT_CAP_MS, PROMO_SLOT_MODULO, ROTATION_SLOT_MS, selectMessage
14
14
  export { CREDIT_RECOVERY_HINT, classifyCreditError, renderCreditRecovery, shouldShowCreditRecovery, } from './credit-errors.js';
15
15
  export { deleteFunnelData, getFunnelId, lastRecordedEvent, recordFunnelEvent } from './events.js';
16
16
  export { getFunnelPromo } from './promo.js';
17
+ export { PAYOUT_POLICY_VERSION, deleteEnrollment, getAttributionToken, getEnrollment, isEarningEligible, recordEnrollment, } from './payout.js';
17
18
  export { RATE_LIMIT_TTL_MS, clearRateLimitStatus, markRateLimited, rateLimitNotice, readRateLimitStatus, } from './rate-limit-notifier.js';
18
19
  export { QUOTA_LOW_TTL_MS, clearQuotaLowStatus, markQuotaLow, quotaLowNotice, readQuotaLowStatus, } from './power-saver-notifier.js';
19
20
  export { TOGGLE_COOLDOWN_MS, cooldownActive, cooldownRemainingMin } from './toggle-cooldown.js';
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Developer revenue-share enrollment state — ADR-317, Phase 0.
3
+ *
4
+ * Stores an opaque enrollment token issued by the funnel.ruv.io backend
5
+ * after the user completes browser-side KYC + Stripe Connect. The client
6
+ * never introspects the token; it just includes it in attribution events
7
+ * so the backend can credit the correct payout account.
8
+ *
9
+ * Consent for the `rev-share-payout` domain is a PRECONDITION for
10
+ * enrollment (see ADR-317 §1). Consent alone does not mean earning —
11
+ * an enrollment token is also required, and KYC can fail after consent
12
+ * is granted for reasons outside the user's control. Callers should
13
+ * check both when deciding whether to enrich attribution.
14
+ */
15
+ import type { PayoutEnrollment, PayoutEnrollmentPolicyVersion } from './types.js';
16
+ /** Bump when the payout policy changes materially (e.g., 50/50 → other split). */
17
+ export declare const PAYOUT_POLICY_VERSION: PayoutEnrollmentPolicyVersion;
18
+ export declare function getEnrollment(): PayoutEnrollment | null;
19
+ /**
20
+ * Whether attribution events should be enriched with the user's enrollment
21
+ * token. True only when BOTH consent is granted AND a verified token exists —
22
+ * either alone means "not yet earning."
23
+ */
24
+ export declare function isEarningEligible(): boolean;
25
+ /** Opaque token safe to include in attribution events. Null when not eligible. */
26
+ export declare function getAttributionToken(): string | null;
27
+ /**
28
+ * Record a successful enrollment (called by the CLI subcommand after the
29
+ * browser-side flow returns via device-code callback). Never called from
30
+ * hot paths — this is a rare, user-initiated write.
31
+ */
32
+ export declare function recordEnrollment(rec: Omit<PayoutEnrollment, 'policy_version'>): PayoutEnrollment;
33
+ /**
34
+ * Delete local enrollment state. Called by `ruflo funnel unenroll`. The
35
+ * server-side revoke is separate — this only removes the local token so
36
+ * subsequent attribution events stop being enriched. Idempotent — deleting
37
+ * a missing enrollment is a no-op success.
38
+ */
39
+ export declare function deleteEnrollment(): boolean;
40
+ //# sourceMappingURL=payout.d.ts.map
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Developer revenue-share enrollment state — ADR-317, Phase 0.
3
+ *
4
+ * Stores an opaque enrollment token issued by the funnel.ruv.io backend
5
+ * after the user completes browser-side KYC + Stripe Connect. The client
6
+ * never introspects the token; it just includes it in attribution events
7
+ * so the backend can credit the correct payout account.
8
+ *
9
+ * Consent for the `rev-share-payout` domain is a PRECONDITION for
10
+ * enrollment (see ADR-317 §1). Consent alone does not mean earning —
11
+ * an enrollment token is also required, and KYC can fail after consent
12
+ * is granted for reasons outside the user's control. Callers should
13
+ * check both when deciding whether to enrich attribution.
14
+ */
15
+ import { readStateJson, writeStateJson } from './state.js';
16
+ import { hasConsent } from './consent.js';
17
+ const PAYOUT_FILE = 'funnel-payout.json';
18
+ /** Bump when the payout policy changes materially (e.g., 50/50 → other split). */
19
+ export const PAYOUT_POLICY_VERSION = 1;
20
+ export function getEnrollment() {
21
+ return readStateJson(PAYOUT_FILE);
22
+ }
23
+ /**
24
+ * Whether attribution events should be enriched with the user's enrollment
25
+ * token. True only when BOTH consent is granted AND a verified token exists —
26
+ * either alone means "not yet earning."
27
+ */
28
+ export function isEarningEligible() {
29
+ if (!hasConsent('rev-share-payout'))
30
+ return false;
31
+ const rec = getEnrollment();
32
+ return !!rec && rec.kyc_status === 'verified' && !!rec.enrollment_token;
33
+ }
34
+ /** Opaque token safe to include in attribution events. Null when not eligible. */
35
+ export function getAttributionToken() {
36
+ if (!isEarningEligible())
37
+ return null;
38
+ const rec = getEnrollment();
39
+ return rec?.enrollment_token ?? null;
40
+ }
41
+ /**
42
+ * Record a successful enrollment (called by the CLI subcommand after the
43
+ * browser-side flow returns via device-code callback). Never called from
44
+ * hot paths — this is a rare, user-initiated write.
45
+ */
46
+ export function recordEnrollment(rec) {
47
+ const full = { ...rec, policy_version: PAYOUT_POLICY_VERSION };
48
+ writeStateJson(PAYOUT_FILE, full);
49
+ return full;
50
+ }
51
+ /**
52
+ * Delete local enrollment state. Called by `ruflo funnel unenroll`. The
53
+ * server-side revoke is separate — this only removes the local token so
54
+ * subsequent attribution events stop being enriched. Idempotent — deleting
55
+ * a missing enrollment is a no-op success.
56
+ */
57
+ export function deleteEnrollment() {
58
+ return writeStateJson(PAYOUT_FILE, null);
59
+ }
60
+ //# sourceMappingURL=payout.js.map
@@ -32,7 +32,7 @@ export interface PromoRow {
32
32
  kind: 'disclosure' | FunnelMessageClass | 'insight';
33
33
  url?: string;
34
34
  }
35
- export type ConsentDomain = 'account' | 'proxy-install' | 'telemetry' | 'cloud-routing' | 'hosted-memory' | 'sponsored-downtime' | 'power-saver' | 'training-data-sharing' | 'advisor-tips';
35
+ export type ConsentDomain = 'account' | 'proxy-install' | 'telemetry' | 'cloud-routing' | 'hosted-memory' | 'sponsored-downtime' | 'power-saver' | 'training-data-sharing' | 'advisor-tips' | 'rev-share-payout' | 'spinner-verbs' | 'company-announcements';
36
36
  export interface ConsentReceipt {
37
37
  granted: boolean;
38
38
  policyVersion: number;
@@ -43,6 +43,18 @@ export interface ConsentReceipt {
43
43
  export type ConsentFile = Partial<Record<ConsentDomain, ConsentReceipt>>;
44
44
  /** Bump when the meaning of a consent domain changes materially (ADR-302). */
45
45
  export declare const CONSENT_POLICY_VERSION = 1;
46
+ export type PayoutEnrollmentPolicyVersion = 1;
47
+ /**
48
+ * Local mirror of enrollment state issued by the funnel.ruv.io backend.
49
+ * The `enrollment_token` is opaque — the client never introspects it.
50
+ */
51
+ export interface PayoutEnrollment {
52
+ enrollment_token: string;
53
+ enrolled_at: string;
54
+ payout_account_last4: string;
55
+ kyc_status: 'verified' | 'pending' | 'failed';
56
+ policy_version: PayoutEnrollmentPolicyVersion;
57
+ }
46
58
  export type FunnelDecisionSource = 'env' | 'enterprise-policy' | 'user-config' | 'project-config' | 'package-default' | 'remote-policy' | 'disclosure-declined';
47
59
  export interface FunnelEnabledDecision {
48
60
  enabled: boolean;
@@ -235,6 +235,23 @@ export async function autoRefreshHelpersIfStale(cwd, opts = {}) {
235
235
  const helpersDir = path.join(cwd, '.claude', 'helpers');
236
236
  if (!fs.existsSync(path.join(helpersDir, 'hook-handler.cjs')))
237
237
  return { refreshed: false };
238
+ // .LOCKED marker: users developing ruflo itself (or any project with
239
+ // hand-maintained helpers) can place a `.LOCKED` file at
240
+ // `.claude/helpers/.LOCKED` to opt this project out of auto-refresh
241
+ // entirely. Fixes the observed-live concurrent-session clobber where a
242
+ // sibling Claude Code session running a stale cached CLI would overwrite
243
+ // hand-edited helpers on this repo (CLAUDE.md "Concurrent-session helper
244
+ // corruption"). Existing semver.gte guard below still fires for normal
245
+ // installs — this is the escape hatch for the small set of users editing
246
+ // helpers directly. Delete the file to re-enable refresh.
247
+ if (fs.existsSync(path.join(helpersDir, '.LOCKED'))) {
248
+ return { refreshed: false, blocked: '.LOCKED marker present — refresh skipped (delete to re-enable)' };
249
+ }
250
+ // Also honor an env-level opt-out for CI / release-time scripting that
251
+ // knows it doesn't want any writes to helpers this run.
252
+ if (/^(1|true|on|yes)$/i.test(String(process.env.RUFLO_HELPERS_LOCKED || ''))) {
253
+ return { refreshed: false, blocked: 'RUFLO_HELPERS_LOCKED env — refresh skipped' };
254
+ }
238
255
  const version = opts.versionOverride ?? getInstalledCliVersion();
239
256
  let stamped = '';
240
257
  try {