@mainwave/cli 0.11.0 → 0.13.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 (43) hide show
  1. package/README.md +203 -16
  2. package/dist/adapters/claude-code.js +3 -3
  3. package/dist/adapters/claude-desktop.js +35 -1
  4. package/dist/adapters/codex-cli.js +16 -16
  5. package/dist/adapters/cursor.js +7 -2
  6. package/dist/adapters/kiro.js +13 -8
  7. package/dist/commands.js +219 -0
  8. package/dist/core/apply.js +47 -8
  9. package/dist/core/auth-commands.js +2 -1
  10. package/dist/core/codecs/kiro-hooks-json.js +1 -1
  11. package/dist/core/codex-trust.js +178 -0
  12. package/dist/core/doctor.js +144 -12
  13. package/dist/core/entry-script.js +2 -3
  14. package/dist/core/format.js +0 -1
  15. package/dist/core/hook-copies.js +157 -0
  16. package/dist/core/install-hooks.js +198 -15
  17. package/dist/core/interview.js +36 -16
  18. package/dist/core/markers.js +209 -44
  19. package/dist/core/redaction.js +188 -0
  20. package/dist/core/skills.js +3 -11
  21. package/dist/core/status.js +21 -1
  22. package/dist/core/store.js +254 -4
  23. package/dist/core/wizard.js +91 -6
  24. package/dist/main.js +173 -163
  25. package/hooks/codex-turns.mjs +584 -0
  26. package/hooks/kiro-otlp.mjs +10 -1
  27. package/hooks/mainwave-hook.mjs +27 -3
  28. package/hooks/marker-core.mjs +66 -8
  29. package/hooks/matchers.json +98 -1
  30. package/hooks/redaction-data.mjs +209 -0
  31. package/hooks/redaction-json.mjs +215 -0
  32. package/hooks/redaction-pattern.mjs +503 -0
  33. package/hooks/redaction.d.mts +84 -0
  34. package/hooks/redaction.mjs +701 -0
  35. package/hooks/vocabulary.mjs +41 -2
  36. package/package.json +3 -1
  37. package/skills/mainwave-instrument/SKILL.md +24 -6
  38. package/skills/mainwave-instrument/reference/frameworks.md +4 -2
  39. package/skills/mainwave-instrument/reference/troubleshooting.md +4 -0
  40. package/skills/mainwave-instrument-node/SKILL.md +83 -38
  41. package/skills/mainwave-instrument-node/reference/api.md +16 -16
  42. package/skills/mainwave-instrument-node/reference/frameworks.md +42 -27
  43. package/skills/mainwave-instrument-node/reference/troubleshooting.md +11 -7
@@ -4,6 +4,8 @@ import { adapterNames, adapters } from '../adapters/index.js';
4
4
  import { color, maskSecret } from './format.js';
5
5
  import { nativeIdentityReason } from './effective-settings.js';
6
6
  import { tildify } from './post-setup.js';
7
+ import { copyAdvice, unredactedHookCopies } from './hook-copies.js';
8
+ import { hasRulesFile, redactionLines, redactionView } from './redaction.js';
7
9
  import { ignoredKeysAt, policyState } from './layer-policy.js';
8
10
  import { readExistingEnv } from './settings.js';
9
11
  import { emitJson } from './ui.js';
@@ -260,11 +262,29 @@ const statusJsonFor = async (adapter) => {
260
262
  };
261
263
  export const runStatus = async (adapter, options = {}) => {
262
264
  const targets = adapter !== undefined ? [adapter] : adapterNames().map((n) => adapters[n]);
265
+ const redaction = redactionView();
266
+ const unredacted = redaction.state === 'off'
267
+ ? []
268
+ : await unredactedHookCopies(undefined, redaction.org !== undefined);
263
269
  if (options.json) {
264
- emitJson({ adapters: await Promise.all(targets.map(statusJsonFor)) });
270
+ emitJson({
271
+ redaction: redaction.state === 'off' ? redaction : { ...redaction, unredactedHooks: unredacted },
272
+ adapters: await Promise.all(targets.map(statusJsonFor)),
273
+ });
265
274
  return 0;
266
275
  }
267
276
  console.log(color.bold('mainwave-cli — current configuration'));
277
+ const [state, ...detail] = redactionLines(redaction);
278
+ console.log('');
279
+ console.log(`${color.bold('Redaction:')} ${state}`);
280
+ for (const line of detail)
281
+ console.log(color.dim(line));
282
+ for (const copy of unredacted) {
283
+ const serious = hasRulesFile(redaction) || copy.orgPacks === true;
284
+ console.log((serious ? color.red : color.yellow)(copy.orgPacks === true
285
+ ? ` ✗ ${copy.what} in ${tildify(copy.path)} predate your organization's redaction packs and send spans without them. ${copyAdvice(copy)}`
286
+ : ` ${serious ? '✗' : '!'} ${copy.what} in ${tildify(copy.path)} predate redaction and send spans without it. ${copyAdvice(copy)}`));
287
+ }
268
288
  for (const a of targets) {
269
289
  for (const line of await renderAdapter(a)) {
270
290
  console.log(line);
@@ -1,9 +1,10 @@
1
+ import { randomBytes } from 'node:crypto';
1
2
  import { promises as fs } from 'node:fs';
2
3
  import { homedir } from 'node:os';
3
- import { dirname, join } from 'node:path';
4
+ import { dirname, isAbsolute, join } from 'node:path';
4
5
  import { isErrnoCode } from './settings.js';
5
6
  import { trimSlash } from './url.js';
6
- export const mainwaveDir = () => join(homedir(), '.mainwave');
7
+ const mainwaveDir = () => join(homedir(), '.mainwave');
7
8
  export const settingsPath = () => join(mainwaveDir(), 'settings.json');
8
9
  export const credentialsPath = () => join(mainwaveDir(), 'credentials.json');
9
10
  export const DEFAULTS = {
@@ -12,6 +13,7 @@ export const DEFAULTS = {
12
13
  collectorUrl: 'https://collector.mainwave.com',
13
14
  };
14
15
  const FILE_MODE = 0o600;
16
+ const isPlainObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
15
17
  const readJson = async (path) => {
16
18
  let body;
17
19
  try {
@@ -24,7 +26,7 @@ const readJson = async (path) => {
24
26
  }
25
27
  try {
26
28
  const parsed = JSON.parse(body);
27
- return typeof parsed === 'object' && parsed !== null ? parsed : null;
29
+ return isPlainObject(parsed) ? parsed : null;
28
30
  }
29
31
  catch {
30
32
  return null;
@@ -42,8 +44,120 @@ const writeJson = async (path, value) => {
42
44
  throw err;
43
45
  }
44
46
  };
47
+ const LOCK_WAIT_MS = 15_000;
48
+ const LOCK_STALE_MS = 10_000;
49
+ const LOCK_RETRY_MS = 25;
50
+ const sleep = (ms) => new Promise((done) => setTimeout(done, ms));
51
+ const lockNonce = () => `${process.pid}.${randomBytes(8).toString('hex')}`;
52
+ const readLockOwner = async (lock) => {
53
+ try {
54
+ return await fs.readFile(lock, 'utf8');
55
+ }
56
+ catch (err) {
57
+ if (isErrnoCode(err, 'ENOENT'))
58
+ return undefined;
59
+ throw err;
60
+ }
61
+ };
62
+ const takeOverStaleLock = async (lock, owner) => {
63
+ const taken = `${lock}.stale.${process.pid}.${Date.now()}`;
64
+ await fs.rename(lock, taken);
65
+ try {
66
+ if ((await readLockOwner(taken)) !== owner) {
67
+ await fs.link(taken, lock).catch((err) => {
68
+ if (!isErrnoCode(err, 'EEXIST'))
69
+ throw err;
70
+ });
71
+ }
72
+ }
73
+ finally {
74
+ await fs.rm(taken, { force: true });
75
+ }
76
+ };
77
+ export const withFileLock = async (path, work) => {
78
+ const lock = `${path}.lock`;
79
+ await fs.mkdir(dirname(path), { recursive: true, mode: 0o700 });
80
+ const nonce = lockNonce();
81
+ const started = Date.now();
82
+ const deadline = started + LOCK_WAIT_MS;
83
+ for (;;) {
84
+ try {
85
+ const handle = await fs.open(lock, 'wx', FILE_MODE);
86
+ try {
87
+ await handle.writeFile(nonce);
88
+ }
89
+ finally {
90
+ await handle.close();
91
+ }
92
+ break;
93
+ }
94
+ catch (err) {
95
+ if (!isErrnoCode(err, 'EEXIST'))
96
+ throw err;
97
+ }
98
+ try {
99
+ const owner = await readLockOwner(lock);
100
+ if (owner === undefined)
101
+ continue;
102
+ const { mtimeMs } = await fs.stat(lock);
103
+ const age = Date.now() - mtimeMs;
104
+ if (age > LOCK_STALE_MS || (age < 0 && Date.now() - started > LOCK_STALE_MS)) {
105
+ await takeOverStaleLock(lock, owner);
106
+ continue;
107
+ }
108
+ }
109
+ catch (err) {
110
+ if (isErrnoCode(err, 'ENOENT'))
111
+ continue;
112
+ throw err;
113
+ }
114
+ if (Date.now() >= deadline) {
115
+ throw new Error(`${path} is being written by another mainwave-cli run (${lock} is held). ` +
116
+ 'Run the command again; if no other run is active, remove that file.');
117
+ }
118
+ await sleep(LOCK_RETRY_MS);
119
+ }
120
+ try {
121
+ return await work();
122
+ }
123
+ finally {
124
+ if ((await readLockOwner(lock).catch(() => undefined)) === nonce) {
125
+ await fs.rm(lock, { force: true });
126
+ }
127
+ }
128
+ };
45
129
  export const readSettings = async () => (await readJson(settingsPath())) ?? {};
46
- export const updateSettings = async (patch) => {
130
+ export class SettingsFileError extends Error {
131
+ path;
132
+ constructor(path) {
133
+ super(`${path} is not valid JSON, but it mentions "redaction", so the CLI will not overwrite it ` +
134
+ 'and risk dropping your redaction setting. Fix the file, or remove it, then run the command again.');
135
+ this.name = 'SettingsFileError';
136
+ this.path = path;
137
+ }
138
+ }
139
+ export const assertSettingsWritable = async () => {
140
+ const path = settingsPath();
141
+ let body;
142
+ try {
143
+ body = await fs.readFile(path, 'utf8');
144
+ }
145
+ catch (err) {
146
+ if (isErrnoCode(err, 'ENOENT') || isErrnoCode(err, 'ENOTDIR'))
147
+ return;
148
+ throw err;
149
+ }
150
+ try {
151
+ if (isPlainObject(JSON.parse(body)))
152
+ return;
153
+ }
154
+ catch {
155
+ }
156
+ if (body.includes('"redaction"'))
157
+ throw new SettingsFileError(path);
158
+ };
159
+ export const updateSettings = async (patch) => withFileLock(settingsPath(), async () => {
160
+ await assertSettingsWritable();
47
161
  const current = await readSettings();
48
162
  const next = { ...current };
49
163
  for (const [key, value] of Object.entries(patch)) {
@@ -52,8 +166,144 @@ export const updateSettings = async (patch) => {
52
166
  else if (value !== undefined)
53
167
  Object.assign(next, { [key]: value });
54
168
  }
169
+ if (patch.redaction !== undefined && isPlainObject(current.redaction)) {
170
+ const { org } = current.redaction;
171
+ if (org !== undefined)
172
+ next.redaction = { ...next.redaction, org };
173
+ }
55
174
  await writeJson(settingsPath(), next);
56
175
  return next;
176
+ });
177
+ export const KEEP_ORG_PACKS = 'keep';
178
+ export const hasOrgEntry = async (configDir, path) => orgDirsIn(await readSettingsText(path)).includes(configDir);
179
+ const sameList = (a, b) => a.length === b.length && a.every((v, i) => v === b[i]);
180
+ const dirIsGone = async (dir) => {
181
+ try {
182
+ await fs.stat(dir);
183
+ return false;
184
+ }
185
+ catch (err) {
186
+ if (!isErrnoCode(err, 'ENOENT') && !isErrnoCode(err, 'ENOTDIR'))
187
+ return false;
188
+ }
189
+ try {
190
+ return (await fs.stat(dirname(dir))).isDirectory();
191
+ }
192
+ catch {
193
+ return false;
194
+ }
195
+ };
196
+ const goneEntries = async (dirs, configDir) => {
197
+ const gone = [];
198
+ for (const dir of dirs) {
199
+ if (dir !== configDir && isAbsolute(dir) && (await dirIsGone(dir)))
200
+ gone.push(dir);
201
+ }
202
+ return gone;
203
+ };
204
+ const readSettingsText = async (path) => {
205
+ try {
206
+ return await fs.readFile(path, 'utf8');
207
+ }
208
+ catch (err) {
209
+ if (!isErrnoCode(err, 'ENOENT') && !isErrnoCode(err, 'ENOTDIR'))
210
+ throw err;
211
+ return undefined;
212
+ }
213
+ };
214
+ const orgDirsIn = (body) => {
215
+ if (body === undefined)
216
+ return [];
217
+ try {
218
+ const redaction = JSON.parse(body)?.redaction;
219
+ const org = isPlainObject(redaction) ? redaction.org : undefined;
220
+ return isPlainObject(org) ? Object.keys(org) : [];
221
+ }
222
+ catch {
223
+ return [];
224
+ }
225
+ };
226
+ const planOrgSync = (body, path, configDir, packs, gone) => {
227
+ const keep = packs === KEEP_ORG_PACKS;
228
+ const set = keep ? undefined : packs;
229
+ let doc = {};
230
+ if (body !== undefined) {
231
+ let parsed;
232
+ try {
233
+ parsed = JSON.parse(body);
234
+ }
235
+ catch {
236
+ parsed = undefined;
237
+ }
238
+ if (isPlainObject(parsed))
239
+ doc = parsed;
240
+ else {
241
+ if (set === undefined)
242
+ return { result: 'unchanged' };
243
+ if (body.includes('"redaction"'))
244
+ throw new SettingsFileError(path);
245
+ }
246
+ }
247
+ const redaction = doc.redaction;
248
+ if (redaction !== undefined && !isPlainObject(redaction)) {
249
+ if (set === undefined)
250
+ return { result: 'unchanged' };
251
+ throw new Error(`${path}: redaction is not an object, so your organization's redaction packs cannot be recorded. ` +
252
+ 'Fix the file, then start a new session.');
253
+ }
254
+ const current = (redaction ?? {});
255
+ const org = isPlainObject(current.org) ? current.org : {};
256
+ const entry = org[configDir];
257
+ const recorded = isPlainObject(entry) && Array.isArray(entry.packs)
258
+ ? entry.packs
259
+ : undefined;
260
+ const malformed = !keep && current.org !== undefined && !isPlainObject(current.org);
261
+ const goneNow = gone.filter((dir) => dir !== configDir && Object.hasOwn(org, dir));
262
+ const sameEntry = keep
263
+ ? true
264
+ : set === undefined
265
+ ? entry === undefined
266
+ : recorded !== undefined && sameList(recorded, set);
267
+ if (sameEntry && !malformed && goneNow.length === 0)
268
+ return { result: 'unchanged' };
269
+ const nextOrg = { ...org };
270
+ for (const dir of goneNow)
271
+ delete nextOrg[dir];
272
+ if (set === undefined) {
273
+ if (!keep)
274
+ delete nextOrg[configDir];
275
+ }
276
+ else
277
+ nextOrg[configDir] = { packs: [...set] };
278
+ const nextRedaction = { ...current };
279
+ if (Object.keys(nextOrg).length === 0)
280
+ delete nextRedaction.org;
281
+ else
282
+ nextRedaction.org = nextOrg;
283
+ const next = { ...doc };
284
+ if (Object.keys(nextRedaction).length === 0)
285
+ delete next.redaction;
286
+ else
287
+ next.redaction = nextRedaction;
288
+ return {
289
+ result: sameEntry && !malformed ? 'pruned' : set === undefined ? 'cleared' : 'set',
290
+ next,
291
+ };
292
+ };
293
+ export const syncOrgRedaction = async (configDir, packs, path = settingsPath()) => {
294
+ const first = await readSettingsText(path);
295
+ const candidates = await goneEntries(orgDirsIn(first), configDir);
296
+ if (planOrgSync(first, path, configDir, packs, candidates).result === 'unchanged') {
297
+ return 'unchanged';
298
+ }
299
+ return withFileLock(path, async () => {
300
+ const body = await readSettingsText(path);
301
+ const plan = planOrgSync(body, path, configDir, packs, await goneEntries(candidates, configDir));
302
+ if (plan.result === 'unchanged')
303
+ return 'unchanged';
304
+ await writeJson(path, plan.next);
305
+ return plan.result;
306
+ });
57
307
  };
58
308
  export const readCredentials = async () => (await readJson(credentialsPath())) ?? {};
59
309
  export const writeCredentials = async (credentials) => {
@@ -1,5 +1,5 @@
1
1
  import { select } from '@inquirer/prompts';
2
- import { mergePrefills, planAdapter, planHasChanges, planSnapshotBlocked, printMarkerCoexistenceNotes, printPostSetup, readPrefill, renderPlan, userHooksPath, writePlan, } from './apply.js';
2
+ import { defaultHookDirs, mergePrefills, planAdapter, planHasChanges, planSnapshotBlocked, printMarkerCoexistenceNotes, printPostSetup, readPrefill, renderPlan, userHooksPath, writePlan, } from './apply.js';
3
3
  import { runLogin } from './auth-commands.js';
4
4
  import { computeEffective, isManagedUnitDrop, nativeIdentityReason } from './effective-settings.js';
5
5
  import { isManagedIdentityConfig, isManagedLayer } from './layer-policy.js';
@@ -8,9 +8,11 @@ import { color } from './format.js';
8
8
  import { runInterview } from './interview.js';
9
9
  import { redeemInvite } from './platform.js';
10
10
  import { promptApiKey, promptCollectorUrl, promptConfirmWrite, promptSkills } from './prompts.js';
11
+ import { checkRedactionFile, hasRulesFile, nextRedactionChoice, redactionLines, redactionView, sendsUnredactedContent, uncoveredNotice, } from './redaction.js';
12
+ import { describeBreaks, flatRefreshBreaks, refreshInstalledHooks } from './hook-copies.js';
11
13
  import { installSkillsPayload } from './skills.js';
12
14
  import { adapterEffective, attributionOf, primaryCarries } from './status.js';
13
- import { activeSession, readCredentials, readSettings, rememberKey, resolveEndpoints, updateSettings, } from './store.js';
15
+ import { activeSession, assertSettingsWritable, readCredentials, readSettings, rememberKey, resolveEndpoints, updateSettings, } from './store.js';
14
16
  import { isInteractive } from './tty.js';
15
17
  import { trimSlash } from './url.js';
16
18
  import { VERSION } from './version.js';
@@ -110,7 +112,7 @@ export const ucidRemovalNotice = (plan, onDisk) => onDisk !== undefined && plan.
110
112
  ? `${plan.adapter.displayName}: removing UCID ${onDisk} an earlier setup wrote; activity will ` +
111
113
  `now be attributed from your identity. Pass --ucid ${onDisk} to keep it.`
112
114
  : null;
113
- export const ucidIgnoredNotice = (adapter, explicitUcid) => adapter.carriesNoUcid && explicitUcid !== undefined
115
+ const ucidIgnoredNotice = (adapter, explicitUcid) => adapter.carriesNoUcid && explicitUcid !== undefined
114
116
  ? `${adapter.displayName}: its hooks send no use-case id, so --ucid / --use-case don't apply; ` +
115
117
  'its activity is attributed from your email.'
116
118
  : null;
@@ -241,6 +243,10 @@ export const redeemInviteToOverrides = async (token, apiUrl, options) => {
241
243
  export const runSetup = async (adapters, rawOptions = {}) => {
242
244
  setJsonMode(rawOptions.json === true);
243
245
  const interactive = isInteractive();
246
+ const redactionFile = rawOptions.redactionFile === undefined
247
+ ? undefined
248
+ : checkRedactionFile(rawOptions.redactionFile);
249
+ await assertSettingsWritable();
244
250
  const settings = await readSettings();
245
251
  const endpoints = resolveEndpoints(settings, {
246
252
  apiUrl: rawOptions.apiUrl,
@@ -325,8 +331,23 @@ export const runSetup = async (adapters, rawOptions = {}) => {
325
331
  if (!ok)
326
332
  throw new WizardAbort();
327
333
  }
334
+ const redactionChoice = nextRedactionChoice((await readSettings()).redaction, {
335
+ file: redactionFile,
336
+ noRedaction: options.noRedaction,
337
+ secrets: options.redactSecrets,
338
+ });
339
+ if (redactionChoice !== undefined)
340
+ await updateSettings({ redaction: redactionChoice });
341
+ const redaction = redactionView();
342
+ const hookDirs = defaultHookDirs();
343
+ const holdFlat = redaction.state !== 'off' && (await flatRefreshBreaks(hookDirs.flatDir)).length > 0;
328
344
  for (const plan of plans)
329
- await writePlan(plan);
345
+ await writePlan(plan, hookDirs, holdFlat);
346
+ const hookCopies = redaction.state === 'off'
347
+ ? undefined
348
+ : await refreshInstalledHooks(plans.some((p) => p.stageHooks), hookDirs);
349
+ if (hookCopies !== undefined)
350
+ printHookRefresh(hookCopies, holdFlat);
330
351
  for (const plan of plans)
331
352
  await warnIfShadowed(plan);
332
353
  if (options.rememberKeyAs && identity.orgId) {
@@ -382,6 +403,7 @@ export const runSetup = async (adapters, rawOptions = {}) => {
382
403
  }
383
404
  for (const plan of plans)
384
405
  printPostSetup(plan);
406
+ const unredacted = printRedactionNotes(redaction, plans, options);
385
407
  printRestartNotice(adapters);
386
408
  printPostSetupTips(adapters);
387
409
  const skills = await maybeInstallSkills(adapters, options, interactive);
@@ -414,6 +436,11 @@ export const runSetup = async (adapters, rawOptions = {}) => {
414
436
  optIns: answers.optIns,
415
437
  optInsByTool: Object.fromEntries(plans.map((p) => [p.adapter.name, p.input.optIns])),
416
438
  markers: answers.markers,
439
+ redaction: {
440
+ ...redaction,
441
+ uncovered: unredacted.map((a) => a.name),
442
+ ...(hookCopies === undefined ? {} : { hookCopies }),
443
+ },
417
444
  ...planSnapshotReport(plans, await blockedSnapshots(plans)),
418
445
  verified,
419
446
  skills: skills
@@ -424,10 +451,68 @@ export const runSetup = async (adapters, rawOptions = {}) => {
424
451
  }
425
452
  return 0;
426
453
  };
454
+ const printHookRefresh = (refresh, held) => {
455
+ if (refresh.skipped !== undefined) {
456
+ const scripts = refresh.skipped.map((b) => b.script).join(', ');
457
+ say('');
458
+ say(color.yellow(`Redaction is on, but the hook scripts in ~/.mainwave/hooks/ were ${held ? 'not copied or refreshed' : 'left as they are'}: ` +
459
+ `${describeBreaks(refresh.skipped)}, which this release no longer provides. ` +
460
+ 'The scripts there send spans without applying redaction rules until then; ' +
461
+ `remove ${scripts} from ~/.mainwave/hooks/ and re-run setup. Doctor reports them.`));
462
+ }
463
+ else if (refresh.flat.length > 0) {
464
+ say('');
465
+ say(color.dim(`Hook scripts in ~/.mainwave/hooks/ refreshed so they apply redaction.`));
466
+ }
467
+ if (refresh.staged) {
468
+ say('');
469
+ say(color.dim('Managed hook scripts refreshed so they apply redaction.'));
470
+ }
471
+ if (refresh.failed !== undefined) {
472
+ say('');
473
+ say(color.yellow(`Redaction is on, but refreshing the older hook copies failed (${refresh.failed}). ` +
474
+ 'Those copies send spans without applying redaction rules until a re-run of setup succeeds; doctor reports them.'));
475
+ }
476
+ };
477
+ const printRedactionNotes = (view, plans, options) => {
478
+ if (options.noRedaction) {
479
+ say('');
480
+ say(color.dim(view.state === 'on'
481
+ ? 'Rules file removed: the hooks still strip credentials by default.'
482
+ : 'Rules file removed.'));
483
+ }
484
+ if (view.state === 'error') {
485
+ say('');
486
+ say(color.yellow(`Redaction is on but its rules file can't be used, so the Mainwave hooks send nothing:\n` +
487
+ `${redactionLines(view, ' ').slice(1).join('\n')}\n` +
488
+ ' Fix the file, or run setup with --redaction-file <path> or --no-redaction.'));
489
+ }
490
+ if (view.state === 'off') {
491
+ say('');
492
+ say(color.yellow('Credential redaction is off: the hooks send API keys, tokens and private keys as they are. ' +
493
+ 'Run setup with --redact-secrets to turn the default back on.'));
494
+ }
495
+ if (view.state !== 'on')
496
+ return [];
497
+ say('');
498
+ say(color.bold('Redaction:'));
499
+ for (const line of redactionLines(view, ' '))
500
+ say(line);
501
+ if (!hasRulesFile(view))
502
+ return [];
503
+ const unredacted = plans
504
+ .filter((p) => sendsUnredactedContent(p.adapter, p.input.optIns))
505
+ .map((p) => p.adapter);
506
+ if (unredacted.length > 0) {
507
+ say('');
508
+ say(color.yellow(uncoveredNotice(unredacted)));
509
+ }
510
+ return unredacted;
511
+ };
427
512
  const blockedSnapshots = async (plans) => new Map((await Promise.all(plans
428
513
  .filter((p) => p.planSnapshotOn === true)
429
514
  .map(async (p) => [p.adapter.name, await planSnapshotBlocked(p.adapter)]))).flatMap(([name, why]) => (why ? [[name, why]] : [])));
430
- export const planSnapshotReport = (plans, blocked = new Map()) => {
515
+ const planSnapshotReport = (plans, blocked = new Map()) => {
431
516
  const hosts = plans.filter((p) => p.planSnapshotOn !== null);
432
517
  if (hosts.length === 0) {
433
518
  return { planSnapshot: false, planSnapshotReason: 'not-hosted' };
@@ -470,7 +555,7 @@ const maybeVerify = async (options, signedIn, ucid, apiUrl, teamOnly) => {
470
555
  return { verified: false, printed: undefined };
471
556
  }
472
557
  };
473
- export const printAttribution = (plans, context) => {
558
+ const printAttribution = (plans, context) => {
474
559
  const { pin, appUrl, verifyPrinted, accountless } = context;
475
560
  const lines = [];
476
561
  const pinned = pin ? plans.filter((p) => p.input.ucid === pin.id && !p.teamUcid) : [];