@claude-flow/cli 3.29.0 → 3.30.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.
- package/.claude/helpers/.helpers-version +1 -1
- package/.claude/helpers/helpers.manifest.json +3 -3
- package/.claude/helpers/hook-handler.cjs +104 -0
- package/catalog-manifest.json +2 -2
- package/dist/src/commands/announcements.d.ts +17 -0
- package/dist/src/commands/announcements.js +0 -0
- package/dist/src/commands/funnel.d.ts +10 -7
- package/dist/src/commands/funnel.js +100 -9
- package/dist/src/commands/index.js +4 -0
- package/dist/src/commands/spinner.d.ts +16 -0
- package/dist/src/commands/spinner.js +329 -0
- package/dist/src/funnel/consent.js +3 -0
- package/dist/src/funnel/index.d.ts +1 -0
- package/dist/src/funnel/index.js +1 -0
- package/dist/src/funnel/payout.d.ts +40 -0
- package/dist/src/funnel/payout.js +60 -0
- package/dist/src/funnel/types.d.ts +13 -1
- package/dist/src/init/helper-refresh.js +17 -0
- package/dist/src/init/statusline-generator.js +11 -5
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.29.0
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest": {
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.30.0",
|
|
4
4
|
"files": {
|
|
5
5
|
"auto-memory-hook.mjs": "e3e1033b24704992ddef6b31c7fa9dd7fcd9e1af7935dd77ef73402b916b31e6",
|
|
6
|
-
"hook-handler.cjs": "
|
|
6
|
+
"hook-handler.cjs": "dc926a1a585abac85941347894632a800a9c4394e99166726017643e5b3c5950",
|
|
7
7
|
"intelligence.cjs": "5a55d979cb7ba5c8c4f27f3b2e6d686fbb1045d180023b803da672a37e05b915",
|
|
8
8
|
"statusline.cjs": "8416172e504b03f9ec2266a47bba048578c3b1e30c5c7c97a0a8261460cd601d"
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
|
-
"signature": "
|
|
11
|
+
"signature": "V62Co3JaEVPFyVi0Miuo0+CdhriygvtceQlJiMKu7sBysvVUOObrueDW9j3hJ7ShWQYwLppMpndTt3EBiI9QDA==",
|
|
12
12
|
"algorithm": "ed25519"
|
|
13
13
|
}
|
|
@@ -98,6 +98,105 @@ function spawnDetachedFunnelRefresh() {
|
|
|
98
98
|
spawnDetachedHookRefresh('refresh-funnel');
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
// ADR-318/319: first-run auto-enable of spinner verbs (default ON) +
|
|
102
|
+
// announcements (default OFF, explicit opt-in). Fires ONCE per install
|
|
103
|
+
// (marker at ~/.ruflo/first-run-enabled.json), then never again —
|
|
104
|
+
// subsequent sessions see the marker and skip.
|
|
105
|
+
//
|
|
106
|
+
// Split posture rationale:
|
|
107
|
+
// - Spinner verbs = low-intrusion (per-spin flash, append-mode mix
|
|
108
|
+
// with Claude Code defaults, moderate visibility over time). Default ON.
|
|
109
|
+
// Disclosure notification + one-command disable satisfies the ethical bar.
|
|
110
|
+
// - Announcements = higher-intrusion (prominent line at every Claude Code
|
|
111
|
+
// startup, more attention per view). Default OFF; opt-in via
|
|
112
|
+
// RUFLO_AUTO_ENABLE_ANNOUNCEMENTS=1 or explicit `ruflo announcements enable`.
|
|
113
|
+
//
|
|
114
|
+
// Gates (spinner is default-on unless any is TRUE):
|
|
115
|
+
// - RUFLO_NO_AUTO_ENABLE truthy (master opt-out — kills both)
|
|
116
|
+
// - RUFLO_NO_AUTO_ENABLE_SPINNER truthy (spinner-only opt-out)
|
|
117
|
+
// - CI / GITHUB_ACTIONS truthy
|
|
118
|
+
// - stdout is not a TTY (piped, non-interactive)
|
|
119
|
+
// - Marker file already exists
|
|
120
|
+
//
|
|
121
|
+
// Announcements needs the same gates PLUS RUFLO_AUTO_ENABLE_ANNOUNCEMENTS=1.
|
|
122
|
+
//
|
|
123
|
+
// Marker is written even if the spawns fail — auto-enable is a "we tried once"
|
|
124
|
+
// contract, not "keep trying until success." Users can run enable manually.
|
|
125
|
+
function firstRunAutoEnableIfEligible() {
|
|
126
|
+
try {
|
|
127
|
+
const path = require('path');
|
|
128
|
+
const fs = require('fs');
|
|
129
|
+
const os = require('os');
|
|
130
|
+
const truthy = (v) => v && !/^(0|false|off|no)$/i.test(String(v));
|
|
131
|
+
if (truthy(process.env.RUFLO_NO_AUTO_ENABLE)) return;
|
|
132
|
+
if (process.env.CI || process.env.GITHUB_ACTIONS) return;
|
|
133
|
+
if (process.stdout && process.stdout.isTTY === false) return;
|
|
134
|
+
const markerPath = path.join(os.homedir(), '.ruflo', 'first-run-enabled.json');
|
|
135
|
+
if (fs.existsSync(markerPath)) return;
|
|
136
|
+
|
|
137
|
+
const enableSpinner = !truthy(process.env.RUFLO_NO_AUTO_ENABLE_SPINNER);
|
|
138
|
+
const enableAnnouncements = truthy(process.env.RUFLO_AUTO_ENABLE_ANNOUNCEMENTS);
|
|
139
|
+
|
|
140
|
+
// Nothing to do — user opted out of both. Skip marker write so if they
|
|
141
|
+
// change their mind and re-enable env vars later, first-run still fires.
|
|
142
|
+
if (!enableSpinner && !enableAnnouncements) return;
|
|
143
|
+
|
|
144
|
+
// Spawn the enable commands detached + non-blocking. Any failure
|
|
145
|
+
// (missing CLI, refused state, etc.) is silent — auto-enable is
|
|
146
|
+
// best-effort and MUST NOT block session-restore. Uses execPath +
|
|
147
|
+
// resolved cli.js directly rather than spawnDetachedHookRefresh
|
|
148
|
+
// because that helper hardcodes 'hooks' as the top-level command.
|
|
149
|
+
const { spawn } = require('child_process');
|
|
150
|
+
const cliBin = resolveCliBinForHook();
|
|
151
|
+
const runDetached = (args) => {
|
|
152
|
+
try {
|
|
153
|
+
const spawnArgs = cliBin
|
|
154
|
+
? [process.execPath, [cliBin, ...args]]
|
|
155
|
+
: [process.platform === 'win32' ? 'npx.cmd' : 'npx',
|
|
156
|
+
['--prefer-offline', '@claude-flow/cli', ...args]];
|
|
157
|
+
const child = spawn(spawnArgs[0], spawnArgs[1], {
|
|
158
|
+
detached: true, stdio: 'ignore', env: process.env, windowsHide: true,
|
|
159
|
+
});
|
|
160
|
+
child.unref();
|
|
161
|
+
} catch { /* best-effort */ }
|
|
162
|
+
};
|
|
163
|
+
if (enableSpinner) runDetached(['spinner', 'enable', '--yes']);
|
|
164
|
+
if (enableAnnouncements) runDetached(['announcements', 'enable', '--yes']);
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
fs.mkdirSync(path.dirname(markerPath), { recursive: true, mode: 0o700 });
|
|
168
|
+
fs.writeFileSync(
|
|
169
|
+
markerPath,
|
|
170
|
+
JSON.stringify({
|
|
171
|
+
_ts: Date.now(),
|
|
172
|
+
source: 'session-restore-hook',
|
|
173
|
+
enabled: { spinner: enableSpinner, announcements: enableAnnouncements },
|
|
174
|
+
}, null, 2),
|
|
175
|
+
{ encoding: 'utf-8', mode: 0o600 }
|
|
176
|
+
);
|
|
177
|
+
} catch { /* ignore — best effort */ }
|
|
178
|
+
|
|
179
|
+
// Notification tells user exactly what happened. stderr so it doesn't
|
|
180
|
+
// corrupt any downstream JSON stdout consumer.
|
|
181
|
+
try {
|
|
182
|
+
const parts = [];
|
|
183
|
+
if (enableSpinner) parts.push('spinner verbs');
|
|
184
|
+
if (enableAnnouncements) parts.push('startup announcements');
|
|
185
|
+
const disableCmds = [];
|
|
186
|
+
if (enableSpinner) disableCmds.push('`ruflo spinner disable`');
|
|
187
|
+
if (enableAnnouncements) disableCmds.push('`ruflo announcements disable`');
|
|
188
|
+
process.stderr.write(
|
|
189
|
+
'[ruflo] First-run: enabled ' + parts.join(' + ') + '. ' +
|
|
190
|
+
'Disable anytime with ' + disableCmds.join(' / ') + '. ' +
|
|
191
|
+
(enableSpinner && !enableAnnouncements
|
|
192
|
+
? 'Announcements stay opt-in — set RUFLO_AUTO_ENABLE_ANNOUNCEMENTS=1 to enable those too. '
|
|
193
|
+
: '') +
|
|
194
|
+
'Restart Claude Code once to see the changes take effect.\n'
|
|
195
|
+
);
|
|
196
|
+
} catch { /* ignore */ }
|
|
197
|
+
} catch { /* auto-enable must never break session-restore */ }
|
|
198
|
+
}
|
|
199
|
+
|
|
101
200
|
// Same fallback-aware pattern as spawnDetachedFunnelRefresh() above, for
|
|
102
201
|
// ADR-316's co-pilot advisor tip. Safe to call on EVERY session-restore:
|
|
103
202
|
// refresh-advisor's own action checks consent + a 24h TTL BEFORE spending
|
|
@@ -345,6 +444,11 @@ const handlers = {
|
|
|
345
444
|
},
|
|
346
445
|
|
|
347
446
|
'session-restore': async () => {
|
|
447
|
+
// ADR-318/319 first-run auto-enable — fire once per install, never
|
|
448
|
+
// re-fires after user disables. Respects RUFLO_NO_AUTO_ENABLE + CI.
|
|
449
|
+
// Fully non-blocking (detached spawn) so session-restore latency
|
|
450
|
+
// is unchanged.
|
|
451
|
+
firstRunAutoEnableIfEligible();
|
|
348
452
|
if (session) {
|
|
349
453
|
// Try restore first, fall back to start
|
|
350
454
|
const existing = session.restore && session.restore();
|
package/catalog-manifest.json
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ruflo announcements` — manage ruflo entries in Claude Code's
|
|
3
|
+
* companyAnnouncements settings (ADR-319).
|
|
4
|
+
*
|
|
5
|
+
* Claude Code exposes `companyAnnouncements: string[]` in
|
|
6
|
+
* ~/.claude/settings.json. The array is shown at Claude Code startup,
|
|
7
|
+
* cycled at random if multiple entries exist. Higher-attention than
|
|
8
|
+
* the spinner row (once per session, prominently rendered) and
|
|
9
|
+
* lower-frequency (once per Claude Code launch vs. every processing pause).
|
|
10
|
+
*
|
|
11
|
+
* Same architectural guarantees as ADR-318 (spinner): append-only,
|
|
12
|
+
* backup-first, ZWJ-marker-tagged for clean removal.
|
|
13
|
+
*/
|
|
14
|
+
import type { Command } from '../types.js';
|
|
15
|
+
export declare const announcementsCommand: Command;
|
|
16
|
+
export default announcementsCommand;
|
|
17
|
+
//# sourceMappingURL=announcements.d.ts.map
|
|
Binary file
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `ruflo funnel` — user control surface for the Cognitum lifecycle funnel
|
|
3
|
-
* (ADR-301/305/309).
|
|
3
|
+
* (ADR-301/305/309/317).
|
|
4
4
|
*
|
|
5
|
-
* funnel status
|
|
6
|
-
* funnel disable
|
|
7
|
-
* funnel enable
|
|
8
|
-
* funnel accept
|
|
9
|
-
* funnel open
|
|
10
|
-
* funnel
|
|
5
|
+
* funnel status effective state and which precedence source decided it
|
|
6
|
+
* funnel disable user-level opt-out (all surfaces) + delete funnel data
|
|
7
|
+
* funnel enable re-enable at the user tier (cannot override env/enterprise)
|
|
8
|
+
* funnel accept acknowledge the disclosure so rotation starts immediately
|
|
9
|
+
* funnel open open the currently-shown promo URL in the default browser
|
|
10
|
+
* funnel enroll opt in to the 50/50 revenue share on Cognitum sponsor spend (ADR-317)
|
|
11
|
+
* funnel earnings show accrued and paid revenue-share balance
|
|
12
|
+
* funnel unenroll revoke local enrollment (funnel itself stays enabled)
|
|
13
|
+
* funnel id print the pseudonymous funnel ID, if one exists
|
|
11
14
|
*/
|
|
12
15
|
import type { Command } from '../types.js';
|
|
13
16
|
export declare const funnelCommand: Command;
|
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `ruflo funnel` — user control surface for the Cognitum lifecycle funnel
|
|
3
|
-
* (ADR-301/305/309).
|
|
3
|
+
* (ADR-301/305/309/317).
|
|
4
4
|
*
|
|
5
|
-
* funnel status
|
|
6
|
-
* funnel disable
|
|
7
|
-
* funnel enable
|
|
8
|
-
* funnel accept
|
|
9
|
-
* funnel open
|
|
10
|
-
* funnel
|
|
5
|
+
* funnel status effective state and which precedence source decided it
|
|
6
|
+
* funnel disable user-level opt-out (all surfaces) + delete funnel data
|
|
7
|
+
* funnel enable re-enable at the user tier (cannot override env/enterprise)
|
|
8
|
+
* funnel accept acknowledge the disclosure so rotation starts immediately
|
|
9
|
+
* funnel open open the currently-shown promo URL in the default browser
|
|
10
|
+
* funnel enroll opt in to the 50/50 revenue share on Cognitum sponsor spend (ADR-317)
|
|
11
|
+
* funnel earnings show accrued and paid revenue-share balance
|
|
12
|
+
* funnel unenroll revoke local enrollment (funnel itself stays enabled)
|
|
13
|
+
* funnel id print the pseudonymous funnel ID, if one exists
|
|
11
14
|
*/
|
|
12
15
|
import { execFile } from 'node:child_process';
|
|
13
16
|
import * as fs from 'node:fs';
|
|
14
17
|
import * as os from 'node:os';
|
|
15
18
|
import * as path from 'node:path';
|
|
16
19
|
import { output } from '../output.js';
|
|
17
|
-
import { deleteFunnelData, funnelStateDir, getDisclosure, getFunnelId, promoEligible, readConsents, recordDisclosureAccepted, recordDisclosureDeclined, recordDisclosureReenabled, resolveFunnelEnabled, } from '../funnel/index.js';
|
|
20
|
+
import { deleteEnrollment, deleteFunnelData, funnelStateDir, getDisclosure, getEnrollment, getFunnelId, isEarningEligible, promoEligible, readConsents, recordDisclosureAccepted, recordDisclosureDeclined, recordDisclosureReenabled, resolveFunnelEnabled, } from '../funnel/index.js';
|
|
21
|
+
import { hasConsent, recordConsent } from '../funnel/consent.js';
|
|
18
22
|
import { readStateJson, writeStateJson } from '../funnel/state.js';
|
|
19
23
|
function setUserConfigEnabled(enabled) {
|
|
20
24
|
const cfg = readStateJson('funnel.json') ?? {};
|
|
@@ -181,6 +185,91 @@ const openSub = {
|
|
|
181
185
|
}
|
|
182
186
|
},
|
|
183
187
|
};
|
|
188
|
+
// ─── ADR-317: developer revenue-share subcommands ─────────────────────────
|
|
189
|
+
const ENROLL_URL = 'https://funnel.ruv.io/enroll';
|
|
190
|
+
const enrollSub = {
|
|
191
|
+
name: 'enroll',
|
|
192
|
+
description: 'Opt in to the 50/50 revenue share on Cognitum sponsor spend (ADR-317, Phase 0)',
|
|
193
|
+
action: async () => {
|
|
194
|
+
const decision = resolveFunnelEnabled();
|
|
195
|
+
if (!decision.enabled) {
|
|
196
|
+
output.printWarning(`Funnel is currently disabled by: ${decision.decidedBy}. Enable it (ruflo funnel enable) before enrolling — there's nothing to earn from until the funnel is on.`);
|
|
197
|
+
return { success: false, data: decision };
|
|
198
|
+
}
|
|
199
|
+
const disclosure = getDisclosure();
|
|
200
|
+
if (disclosure.state !== 'disclosed_enabled') {
|
|
201
|
+
output.printWarning("The Cognitum disclosure hasn't been shown/accepted yet. Run 'ruflo funnel accept' first, then re-run enroll.");
|
|
202
|
+
return { success: false, data: disclosure };
|
|
203
|
+
}
|
|
204
|
+
// Phase 0: record local consent so downstream attribution knows the user
|
|
205
|
+
// WANTS to enroll, but the backend endpoint that returns a real token is
|
|
206
|
+
// not live yet — this ADR ships in a version before the payout backend.
|
|
207
|
+
recordConsent('rev-share-payout', true, 'cli-funnel-enroll');
|
|
208
|
+
output.writeln('Consent recorded for rev-share-payout.');
|
|
209
|
+
output.writeln('');
|
|
210
|
+
output.writeln('The backend enrollment endpoint (Stripe Connect + KYC) is not yet live.');
|
|
211
|
+
output.writeln('When it ships, this command will open your browser to:');
|
|
212
|
+
output.writeln('');
|
|
213
|
+
output.writeln(` ${ENROLL_URL}`);
|
|
214
|
+
output.writeln('');
|
|
215
|
+
output.writeln("Meanwhile, your consent is on file. Track the rollout at ADR-317 (v3/docs/adr/).");
|
|
216
|
+
return { success: true, data: { consent: 'granted', enrollment: 'pending-backend' } };
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
const earningsSub = {
|
|
220
|
+
name: 'earnings',
|
|
221
|
+
description: 'Show accrued and paid revenue-share balance (ADR-317)',
|
|
222
|
+
options: [
|
|
223
|
+
{ name: 'json', description: 'Output as JSON', type: 'boolean', default: false },
|
|
224
|
+
],
|
|
225
|
+
action: async (ctx) => {
|
|
226
|
+
const consented = hasConsent('rev-share-payout');
|
|
227
|
+
const rec = getEnrollment();
|
|
228
|
+
const eligible = isEarningEligible();
|
|
229
|
+
const summary = {
|
|
230
|
+
consent: consented ? 'granted' : 'not-granted',
|
|
231
|
+
enrollment: rec ? { kyc_status: rec.kyc_status, enrolled_at: rec.enrolled_at, payout_account_last4: rec.payout_account_last4 } : null,
|
|
232
|
+
earning_eligible: eligible,
|
|
233
|
+
note: rec
|
|
234
|
+
? 'Earnings endpoint (funnel.ruv.io/v1/earnings) is not yet live — see ADR-317 Phase 1.'
|
|
235
|
+
: 'Not enrolled. Run `ruflo funnel enroll` to opt in.',
|
|
236
|
+
};
|
|
237
|
+
if (ctx.flags.json) {
|
|
238
|
+
output.printJson(summary);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
output.writeln(`Consent: ${summary.consent}`);
|
|
242
|
+
output.writeln(`Enrolled: ${rec ? 'yes' : 'no'}`);
|
|
243
|
+
if (rec) {
|
|
244
|
+
output.writeln(` KYC: ${rec.kyc_status}`);
|
|
245
|
+
output.writeln(` Payout account: ****${rec.payout_account_last4}`);
|
|
246
|
+
output.writeln(` Since: ${rec.enrolled_at}`);
|
|
247
|
+
}
|
|
248
|
+
output.writeln(`Earning: ${eligible ? 'yes' : 'no'}`);
|
|
249
|
+
output.writeln('');
|
|
250
|
+
output.writeln(summary.note);
|
|
251
|
+
}
|
|
252
|
+
return { success: true, data: summary };
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
const unenrollSub = {
|
|
256
|
+
name: 'unenroll',
|
|
257
|
+
description: 'Revoke rev-share enrollment locally (funnel itself stays enabled)',
|
|
258
|
+
action: async () => {
|
|
259
|
+
const hadEnrollment = !!getEnrollment();
|
|
260
|
+
const hadConsent = hasConsent('rev-share-payout');
|
|
261
|
+
recordConsent('rev-share-payout', false, 'cli-funnel-unenroll');
|
|
262
|
+
deleteEnrollment();
|
|
263
|
+
if (hadEnrollment || hadConsent) {
|
|
264
|
+
output.printSuccess('Unenrolled locally. Funnel messages still render; your install just no longer earns.');
|
|
265
|
+
output.writeln('Note: server-side revocation happens on next contact with funnel.ruv.io — the backend endpoint is not yet live (ADR-317 Phase 1).');
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
output.writeln('Nothing to unenroll — no local enrollment record and no rev-share consent was set.');
|
|
269
|
+
}
|
|
270
|
+
return { success: true, data: { previouslyEnrolled: hadEnrollment, previouslyConsented: hadConsent } };
|
|
271
|
+
},
|
|
272
|
+
};
|
|
184
273
|
const idSub = {
|
|
185
274
|
name: 'id',
|
|
186
275
|
description: 'Print the pseudonymous funnel ID (exists only with telemetry consent)',
|
|
@@ -198,11 +287,13 @@ const idSub = {
|
|
|
198
287
|
export const funnelCommand = {
|
|
199
288
|
name: 'funnel',
|
|
200
289
|
description: 'Control the Cognitum lifecycle funnel surfaces (tips, enrollment, notices)',
|
|
201
|
-
subcommands: [statusSub, disableSub, enableSub, acceptSub, openSub, idSub],
|
|
290
|
+
subcommands: [statusSub, disableSub, enableSub, acceptSub, openSub, enrollSub, earningsSub, unenrollSub, idSub],
|
|
202
291
|
examples: [
|
|
203
292
|
{ command: 'ruflo funnel status', description: 'Effective state + deciding source' },
|
|
204
293
|
{ command: 'ruflo funnel accept', description: 'Skip the 24h grace so rotation starts now' },
|
|
205
294
|
{ command: 'ruflo funnel open', description: 'Open the current promo URL in the browser' },
|
|
295
|
+
{ command: 'ruflo funnel enroll', description: 'Opt in to 50/50 rev share (ADR-317)' },
|
|
296
|
+
{ command: 'ruflo funnel earnings', description: 'Show accrued and paid balance' },
|
|
206
297
|
{ command: 'ruflo funnel disable', description: 'Turn off every funnel surface' },
|
|
207
298
|
],
|
|
208
299
|
action: statusSub.action,
|
|
@@ -83,6 +83,10 @@ const commandLoaders = {
|
|
|
83
83
|
proxy: () => import('./proxy.js'),
|
|
84
84
|
// Fable co-pilot advisor tip in the statusline insight ticker (ADR-316)
|
|
85
85
|
advisor: () => import('./advisor.js'),
|
|
86
|
+
// Ruflo verbs in Claude Code's spinnerVerbs rotation (ADR-318)
|
|
87
|
+
spinner: () => import('./spinner.js'),
|
|
88
|
+
// Ruflo entries in Claude Code's companyAnnouncements startup rotation (ADR-319)
|
|
89
|
+
announcements: () => import('./announcements.js'),
|
|
86
90
|
};
|
|
87
91
|
// Cache for loaded commands
|
|
88
92
|
const loadedCommands = new Map();
|
|
@@ -0,0 +1,16 @@
|
|
|
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 type { Command } from '../types.js';
|
|
14
|
+
export declare const spinnerCommand: Command;
|
|
15
|
+
export default spinnerCommand;
|
|
16
|
+
//# sourceMappingURL=spinner.d.ts.map
|
|
@@ -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
|
|
@@ -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';
|
package/dist/src/funnel/index.js
CHANGED
|
@@ -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 {
|
|
@@ -121,12 +121,18 @@ const CONFIG = {
|
|
|
121
121
|
const CWD = process.cwd();
|
|
122
122
|
|
|
123
123
|
// ─── Delegation cache ───────────────────────────────────────────
|
|
124
|
-
// Cache the CLI JSON result
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
//
|
|
124
|
+
// Cache the CLI JSON result so rapid prompt re-renders (Claude Code
|
|
125
|
+
// refreshes the statusline several times a second while streaming) don't
|
|
126
|
+
// re-invoke the CLI each time.
|
|
127
|
+
// #2337 bumped 10s → 60s.
|
|
128
|
+
// Followup for anthropics/claude-code#70200 (Windows console-flash bug —
|
|
129
|
+
// claude.exe spawns hook/statusline subprocesses without CREATE_NO_WINDOW,
|
|
130
|
+
// producing a visible cmd flash on every render): bumped 60s → 300s to
|
|
131
|
+
// reduce the flash rate 5x on Windows until the upstream fix ships.
|
|
132
|
+
// Tradeoff: stat/git counters update every 5min instead of every 1min;
|
|
133
|
+
// promo/insight row still rotates on its own tighter 20s promoFresh clock.
|
|
128
134
|
const CACHE_FILE = path.join(os.tmpdir(), 'ruflo-statusline-cache-' + require('crypto').createHash('md5').update(CWD).digest('hex').slice(0, 8) + '.json');
|
|
129
|
-
const CACHE_TTL_MS =
|
|
135
|
+
const CACHE_TTL_MS = 300000;
|
|
130
136
|
|
|
131
137
|
// The promo/insight row is designed to rotate on a 20s cadence (funnel/
|
|
132
138
|
// rotation.ts's ROTATION_SLOT_MS / funnel/promo.ts's insight-slot check —
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@claude-flow/cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.30.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Ruflo CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
|
|
6
6
|
"main": "dist/src/index.js",
|