@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
@@ -1,16 +1,19 @@
1
1
  import { spawnSync } from 'node:child_process';
2
2
  import { platform as osPlatform } from 'node:os';
3
- import { isAbsolute } from 'node:path';
3
+ import { dirname, isAbsolute, join, resolve } from 'node:path';
4
4
  import { envFileCodec } from './codecs/env-file.js';
5
+ import { countTrust, readCodexTrust } from './codex-trust.js';
5
6
  import { activeHierarchy, computeEffective, effectiveFrom, flattenEffective, nativeIdentityReason, } from './effective-settings.js';
6
7
  import { ValidateError } from './errors.js';
7
8
  import { color, maskForDisplay } from './format.js';
8
- import { collectBehaviourHookIssues } from './behaviour-hooks.js';
9
+ import { collectBehaviourHookIssues, scanBehaviourHooks } from './behaviour-hooks.js';
9
10
  import { isManagedIdentityConfig, isManagedLayer, policyState } from './layer-policy.js';
10
11
  import { collectMarkerIssues, DEFAULT_MARKER_TOOL, managedHooksDir, matchersForTool, readPackagedMatchers, scanForMarkers, } from './markers.js';
12
+ import { flatCopyIssues } from './hook-copies.js';
11
13
  import { readExistingEnv } from './settings.js';
12
14
  import { hookShellMissingFor, teamUcidStanding } from './apply.js';
13
15
  import { adapterEffective, primaryCarries } from './status.js';
16
+ import { hasRulesFile, redactionLines, redactionView, sendsUnredactedContent, uncoveredNotice, } from './redaction.js';
14
17
  import { readSettings } from './store.js';
15
18
  import { emitJson } from './ui.js';
16
19
  import { validateCollector } from './validate.js';
@@ -418,6 +421,19 @@ const collectIssues = (effective, adapter, secondary = {}) => {
418
421
  });
419
422
  }
420
423
  }
424
+ const retiredKeys = adapter.retiredEnvKeys ?? [];
425
+ const userScans = effective.scans.filter((s) => s.layer.id === 'user');
426
+ const retired = userScans.flatMap((scan) => retiredKeys.filter((key) => key in scan.env).map((key) => ({ key, path: scan.path })));
427
+ if (retired.length > 0) {
428
+ const many = retired.length > 1;
429
+ issues.push({
430
+ level: 'warn',
431
+ message: `${retired.map((e) => e.key).join(', ')} ${many ? 'are' : 'is'} in ` +
432
+ `${[...new Set(retired.map((e) => e.path))].join(', ')}, but ${adapter.displayName} ` +
433
+ `ignores ${many ? 'them' : 'it'} and reports them as unrecognized settings at start. ` +
434
+ `Re-run \`mainwave-cli setup ${adapter.name}\` to remove ${many ? 'them' : 'it'}.`,
435
+ });
436
+ }
421
437
  if (adapter.collectChecks) {
422
438
  issues.push(...adapter.collectChecks(flattenEffective(effective)));
423
439
  }
@@ -463,6 +479,55 @@ const renderChecks = (issues) => {
463
479
  console.log(`${prefix} ${issue.message}`);
464
480
  }
465
481
  };
482
+ const hooksInstalled = async (adapter) => {
483
+ if (adapter.behaviourHooks !== undefined) {
484
+ return (await scanBehaviourHooks(adapter.behaviourHooks)).some((s) => s.status === 'present');
485
+ }
486
+ if (adapter.markers !== undefined) {
487
+ return (await scanForMarkers(await markerLayers(adapter))).some((s) => s.groups.length > 0);
488
+ }
489
+ return false;
490
+ };
491
+ const redactionScope = (adapter) => adapter.name === 'claude-code' ? { configDir: dirname(adapter.paths.global) } : {};
492
+ const redactionIssues = async (adapter, effective, view) => {
493
+ const installed = await hooksInstalled(adapter);
494
+ if (view.state === 'off') {
495
+ return installed
496
+ ? [
497
+ {
498
+ level: 'warn',
499
+ message: `Credential redaction is off, so the ${adapter.displayName} hooks send API keys, tokens and private keys ` +
500
+ 'in the spans they send as they are. Run setup with --redact-secrets to turn the default back on.',
501
+ },
502
+ ]
503
+ : [];
504
+ }
505
+ const copies = installed
506
+ ? await flatCopyIssues(hasRulesFile(view), undefined, view.org !== undefined)
507
+ : [];
508
+ if (view.state === 'error') {
509
+ return installed
510
+ ? [
511
+ {
512
+ level: 'error',
513
+ message: view.cause === 'org'
514
+ ? `Your organization's redaction packs can't be loaded, so the ${adapter.displayName} hooks send nothing: ` +
515
+ `${view.reason}. Update mainwave-cli, then start a new Claude Code session to refresh the hooks.`
516
+ : `Redaction rules file is unusable, so the ${adapter.displayName} hooks send nothing: ` +
517
+ `${view.reason}. Fix the file, or run setup with --redaction-file <path> or --no-redaction.`,
518
+ },
519
+ ...copies,
520
+ ]
521
+ : [];
522
+ }
523
+ const shape = adapter.parseEnv(flattenEffective(effective));
524
+ const uncovered = !hasRulesFile(view) ||
525
+ shape.collectorUrl === undefined ||
526
+ !sendsUnredactedContent(adapter, shape.optIns)
527
+ ? []
528
+ : [{ level: 'warn', message: uncoveredNotice([adapter]) }];
529
+ return [...uncovered, ...copies];
530
+ };
466
531
  const markerMatchers = (adapter, matchers) => matchersForTool(matchers, adapter.markers?.runtimeTool ?? DEFAULT_MARKER_TOOL);
467
532
  const hookChoices = async (adapter) => {
468
533
  const { hooks } = await readSettings();
@@ -479,12 +544,68 @@ const markerLayers = async (adapter) => {
479
544
  { id: 'user', label: 'User hooks file', path: hooksFile.path, kind: 'file' },
480
545
  ];
481
546
  };
482
- const markerIssuesFor = async (adapter, effective) => adapter.markers
483
- ? collectMarkerIssues(await scanForMarkers(await markerLayers(adapter)), VERSION, markerMatchers(adapter, await readPackagedMatchers()), await skippedMarkerScans(effective), await hookChoices(adapter), adapter.markers.runtimeTool ?? DEFAULT_MARKER_TOOL, {
484
- managedDir: managedHooksDir(),
485
- hookShellMissing: await hookShellMissingFor(adapter, () => flattenEffective(effective)),
486
- })
547
+ const markerIssuesFor = async (adapter, effective, redaction) => adapter.markers
548
+ ? [
549
+ ...(await collectMarkerIssues(await scanForMarkers(await markerLayers(adapter)), VERSION, markerMatchers(adapter, await readPackagedMatchers()), await skippedMarkerScans(effective), await hookChoices(adapter), adapter.markers.runtimeTool ?? DEFAULT_MARKER_TOOL, {
550
+ managedDir: managedHooksDir(),
551
+ hookShellMissing: await hookShellMissingFor(adapter, () => flattenEffective(effective)),
552
+ redaction: redaction.state === 'off' ? 'off' : hasRulesFile(redaction) ? 'file' : 'default',
553
+ })),
554
+ ...codexTrustIssues(adapter),
555
+ ]
487
556
  : [];
557
+ const codexTrustIssues = (adapter) => {
558
+ const hooksFile = adapter.markers?.hooksFile;
559
+ if (hooksFile === undefined || adapter.markers?.runtimeTool !== 'codex')
560
+ return [];
561
+ const codexHome = process.env.CODEX_HOME;
562
+ if (codexHome !== undefined &&
563
+ codexHome !== '' &&
564
+ resolve(codexHome) !== dirname(resolve(hooksFile.path))) {
565
+ return [
566
+ {
567
+ level: 'warn',
568
+ message: `CODEX_HOME is set to ${codexHome}, so Codex reads its hooks from ${join(codexHome, 'hooks.json')}, ` +
569
+ `not ${hooksFile.path}, where setup wrote the Mainwave hooks. None of them run, and trusting them in /hooks ` +
570
+ "won't change that: setup doesn't follow CODEX_HOME yet.",
571
+ },
572
+ ];
573
+ }
574
+ const reading = readCodexTrust(hooksFile.path, adapter.paths.global);
575
+ if (reading.state === 'no-hooks')
576
+ return [];
577
+ if (reading.state === 'unreadable') {
578
+ return [
579
+ {
580
+ level: 'info',
581
+ message: `Can't tell whether Codex trusts the Mainwave hooks: ${reading.reason}. Open /hooks in Codex to check.`,
582
+ },
583
+ ];
584
+ }
585
+ const n = countTrust(reading.hooks);
586
+ if (n.trusted === n.total) {
587
+ return [
588
+ {
589
+ level: 'info',
590
+ message: `Codex trusts all ${n.total} Mainwave hooks in ${hooksFile.path}.`,
591
+ },
592
+ ];
593
+ }
594
+ const parts = [
595
+ n.untrusted > 0 ? `${n.untrusted} with no approval on record` : '',
596
+ n.modified > 0 ? `${n.modified} whose approval doesn't match the hook as it is now` : '',
597
+ n.disabled > 0 ? `${n.disabled} turned off in /hooks` : '',
598
+ ].filter((p) => p !== '');
599
+ return [
600
+ {
601
+ level: 'warn',
602
+ message: `Codex skips ${n.total - n.trusted} of ${n.total} Mainwave hooks in ${hooksFile.path} (${parts.join(', ')}), ` +
603
+ 'so they send nothing. Start Codex and choose "Trust all" at the "Hooks need review" prompt, or open /hooks and trust each one. ' +
604
+ 'Every change to a Mainwave hook needs a new approval, such as setup adding a route or a release changing a command. ' +
605
+ '`codex exec` skips them too unless it runs with --dangerously-bypass-hook-trust.',
606
+ },
607
+ ];
608
+ };
488
609
  const skippedMarkerScans = async (effective) => {
489
610
  const out = [];
490
611
  for (const { layer, reason } of effective.skipped ?? []) {
@@ -523,7 +644,7 @@ const runValidate = async (effective, adapter) => {
523
644
  throw err;
524
645
  }
525
646
  };
526
- const doctorJson = async (adapter, effective, issues, validation) => ({
647
+ const doctorJson = async (adapter, effective, issues, validation, redaction) => ({
527
648
  adapter: adapter.name,
528
649
  displayName: adapter.displayName,
529
650
  files: effective.scans.map((scan) => ({
@@ -539,6 +660,7 @@ const doctorJson = async (adapter, effective, issues, validation) => ({
539
660
  value: maskForDisplay(entry.key, entry.value),
540
661
  layer: entry.source.layer.id,
541
662
  })),
663
+ redaction,
542
664
  issues: issues.map((issue) => ({ level: issue.level, message: issue.message })),
543
665
  validation,
544
666
  });
@@ -556,9 +678,17 @@ export const runDoctor = async (adapter, options = {}) => {
556
678
  }
557
679
  renderEffectiveEnv(effective, adapter);
558
680
  console.log();
559
- const issues = collectIssues(effective, adapter, await attributionContext(adapter, effective));
681
+ const redaction = redactionView(redactionScope(adapter));
682
+ console.log(color.bold('Redaction:'));
683
+ for (const line of redactionLines(redaction, ' '))
684
+ console.log(line);
685
+ console.log();
686
+ const issues = [
687
+ ...collectIssues(effective, adapter, await attributionContext(adapter, effective)),
688
+ ...(await redactionIssues(adapter, effective, redaction)),
689
+ ];
560
690
  const shellEnvIssues = await checkShellEnv(adapter);
561
- const markerIssues = await markerIssuesFor(adapter, effective);
691
+ const markerIssues = await markerIssuesFor(adapter, effective, redaction);
562
692
  const behaviourHookIssues = adapter.behaviourHooks
563
693
  ? await collectBehaviourHookIssues(adapter.behaviourHooks, VERSION)
564
694
  : [];
@@ -581,15 +711,17 @@ export const runDoctor = async (adapter, options = {}) => {
581
711
  };
582
712
  const runDoctorJson = async (adapter, options) => {
583
713
  const effective = await computeEffective(adapter);
714
+ const redaction = redactionView(redactionScope(adapter));
584
715
  const issues = [
585
716
  ...collectIssues(effective, adapter, await attributionContext(adapter, effective)),
717
+ ...(await redactionIssues(adapter, effective, redaction)),
586
718
  ...(await checkShellEnv(adapter)),
587
- ...(await markerIssuesFor(adapter, effective)),
719
+ ...(await markerIssuesFor(adapter, effective, redaction)),
588
720
  ...(adapter.behaviourHooks
589
721
  ? await collectBehaviourHookIssues(adapter.behaviourHooks, VERSION)
590
722
  : []),
591
723
  ];
592
724
  const validation = options.validate ? await runValidate(effective, adapter) : undefined;
593
- emitJson(await doctorJson(adapter, effective, issues, validation));
725
+ emitJson(await doctorJson(adapter, effective, issues, validation, redaction));
594
726
  return issues.some((i) => i.level === 'error') || validation?.ok === false ? 1 : 0;
595
727
  };
@@ -2,8 +2,7 @@ export const HOOK_ENTRY_SCRIPT = 'mainwave-hook.sh';
2
2
  export const HOOK_DISPATCHER_SCRIPT = 'mainwave-hook.mjs';
3
3
  export const HOOK_NODE_ENTRY_SCRIPT = 'mainwave-hook-node.mjs';
4
4
  export const ORG_DELIVERED_MARK = 'org-delivered';
5
- export const HOOK_ENTRY_MARK = 'mainwave hook entry v2';
6
- export const ENTRY_HOSTS = ['claude-code', 'codex'];
5
+ const HOOK_ENTRY_MARK = 'mainwave hook entry v2';
7
6
  export const CODEX_BASH_FILTER = [
8
7
  '*pr*create*',
9
8
  '*mr*create*',
@@ -11,7 +10,7 @@ export const CODEX_BASH_FILTER = [
11
10
  '*merge_requests*',
12
11
  '*git*commit*',
13
12
  ];
14
- export const entryRouteKey = ({ host, event, route }) => `${host}/${event}/${route ?? ''}`;
13
+ const entryRouteKey = ({ host, event, route }) => `${host}/${event}/${route ?? ''}`;
15
14
  const SAFE_TOKEN = /^[A-Za-z0-9._+-]+$/;
16
15
  const shQuote = (value) => `'${value.replace(/'/g, `'\\''`)}'`;
17
16
  export const renderHookEntry = ({ versionId, version, nodePath, routes, }) => {
@@ -25,7 +25,6 @@ const maskHeaderCollection = (value) => {
25
25
  return redacted;
26
26
  return hasCredentialShape(value) ? UNREADABLE : value;
27
27
  };
28
- export const maskAuthHeader = (value) => maskHeaderCollection(value);
29
28
  export const maskForDisplay = (envKey, value) => {
30
29
  if (isBearerValue(value))
31
30
  return maskBearerValue(value);
@@ -0,0 +1,157 @@
1
+ import { existsSync, promises as fs } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { pathToFileURL } from 'node:url';
4
+ import { adapters } from '../adapters/index.js';
5
+ import { ORG_PACKS_SUPPORT } from '../../hooks/redaction.mjs';
6
+ import { copyHookScripts, managedHooksDir, installedHooksDir, packagedHooksDir, readPackagedMatchers, REDACTION_HOOK_MODULES, releaseBeforeRedaction, syncManagedHooks, } from './markers.js';
7
+ import { VERSION } from './version.js';
8
+ export const FLAT_SHARED_HOOK_MODULES = [
9
+ ...REDACTION_HOOK_MODULES,
10
+ 'vocabulary.mjs',
11
+ 'marker-core.mjs',
12
+ ];
13
+ const SHARED_PATTERN = new Set(FLAT_SHARED_HOOK_MODULES);
14
+ const IMPORTED_MODULES = ['marker-core.mjs', 'vocabulary.mjs'];
15
+ const flatScripts = async (dir) => (await fs.readdir(dir).catch(() => []))
16
+ .filter((f) => f.endsWith('.mjs') && !SHARED_PATTERN.has(f))
17
+ .sort();
18
+ const bundledScriptNames = () => [
19
+ ...new Set(Object.values(adapters)
20
+ .flatMap((a) => a.bundledHookScripts ?? [])
21
+ .filter((f) => !SHARED_PATTERN.has(f))),
22
+ ];
23
+ const IMPORT_FROM = /\b(?:import|export)\s*\{([^}]*)\}\s*from\s*['"]\.\/(marker-core|vocabulary)\.mjs['"]/g;
24
+ const importedNames = (source) => {
25
+ const found = new Map();
26
+ for (const [, list, module] of source.matchAll(IMPORT_FROM)) {
27
+ const names = found.get(`${module}.mjs`) ?? new Set();
28
+ for (const part of list.replace(/\/\/.*$/gm, '').split(',')) {
29
+ const name = part.trim().split(/\s+as\s+/)[0];
30
+ if (name)
31
+ names.add(name);
32
+ }
33
+ found.set(`${module}.mjs`, names);
34
+ }
35
+ return found;
36
+ };
37
+ export const describeBreaks = (breaks) => breaks.map((b) => `${b.script} ${b.reason}`).join('; ');
38
+ const incompatibilities = async (flatDir, srcDir, replaced) => {
39
+ const exported = new Map();
40
+ for (const module of IMPORTED_MODULES) {
41
+ const loaded = await import(pathToFileURL(join(srcDir, module)).href);
42
+ exported.set(module, new Set(Object.keys(loaded)));
43
+ }
44
+ const problems = [];
45
+ for (const script of (await flatScripts(flatDir)).filter((f) => !replaced.has(f))) {
46
+ const source = await fs.readFile(join(flatDir, script), 'utf8').catch(() => '');
47
+ for (const [module, names] of importedNames(source)) {
48
+ const missing = [...names].filter((n) => !exported.get(module)?.has(n));
49
+ if (missing.length > 0) {
50
+ problems.push({ script, reason: `imports ${missing.join(', ')} from ${module}` });
51
+ }
52
+ }
53
+ }
54
+ return problems;
55
+ };
56
+ const replacedScripts = (flatDir) => new Set(bundledScriptNames().filter((f) => existsSync(join(flatDir, f))));
57
+ export const flatRefreshBreaks = async (flatDir, srcDir = packagedHooksDir()) => {
58
+ if (!existsSync(join(flatDir, 'marker-core.mjs')))
59
+ return [];
60
+ return incompatibilities(flatDir, srcDir, replacedScripts(flatDir)).catch(() => []);
61
+ };
62
+ const breakAdvice = (breaks, flatDir) => `Setup leaves ${flatDir} as it is while ${describeBreaks(breaks)}, which this release no longer provides. ` +
63
+ `Remove ${breaks.map((b) => b.script).join(', ')} from it, then re-run setup.`;
64
+ const reasonOf = (err) => (err instanceof Error ? err.message : String(err));
65
+ const refreshFlatCopies = async (flatDir, srcDir) => {
66
+ if (!existsSync(join(flatDir, 'marker-core.mjs')))
67
+ return { flat: [] };
68
+ try {
69
+ const problems = await incompatibilities(flatDir, srcDir, replacedScripts(flatDir));
70
+ if (problems.length > 0)
71
+ return { flat: [], skipped: problems };
72
+ const files = [...FLAT_SHARED_HOOK_MODULES, ...replacedScripts(flatDir)];
73
+ await copyHookScripts(files, srcDir, flatDir);
74
+ return { flat: files };
75
+ }
76
+ catch (err) {
77
+ return { flat: [], failed: `the hook scripts in ${flatDir}: ${reasonOf(err)}` };
78
+ }
79
+ };
80
+ const appliesOrgPacks = (text) => text.includes(ORG_PACKS_SUPPORT);
81
+ export const refreshFlatCopiesForOrgPacks = async (flatDir = installedHooksDir(), srcDir = packagedHooksDir()) => {
82
+ const text = await fs.readFile(join(flatDir, 'redaction.mjs'), 'utf8').catch(() => '');
83
+ if (appliesOrgPacks(text))
84
+ return { flat: [] };
85
+ return refreshFlatCopies(flatDir, srcDir);
86
+ };
87
+ export const refreshInstalledHooks = async (passStaged, dirs, srcDir = packagedHooksDir()) => {
88
+ const flat = await refreshFlatCopies(dirs.flatDir, srcDir);
89
+ const result = {
90
+ flat: flat.flat,
91
+ ...(flat.skipped === undefined ? {} : { skipped: flat.skipped }),
92
+ staged: false,
93
+ };
94
+ const failures = flat.failed === undefined ? [] : [flat.failed];
95
+ if (!passStaged && (await releaseBeforeRedaction(dirs.managedDir)) !== undefined) {
96
+ try {
97
+ await syncManagedHooks(await readPackagedMatchers(srcDir), srcDir, dirs.managedDir, VERSION);
98
+ result.staged = true;
99
+ }
100
+ catch (err) {
101
+ failures.push(`the managed hooks in ${dirs.managedDir}: ${reasonOf(err)}`);
102
+ }
103
+ }
104
+ if (failures.length > 0)
105
+ result.failed = failures.join('; ');
106
+ return result;
107
+ };
108
+ export const copyAdvice = (copy) => copy.blockedBy === undefined
109
+ ? 'Re-run setup for any tool, which refreshes every hook copy on this machine.'
110
+ : breakAdvice(copy.blockedBy, copy.path);
111
+ const appliesRedaction = (text) => /['"]\.\/redaction\.mjs['"]/.test(text);
112
+ const unredactedFlatCopies = async (flatDir = installedHooksDir(), orgRecorded = false) => {
113
+ const text = await fs.readFile(join(flatDir, 'marker-core.mjs'), 'utf8').catch(() => null);
114
+ if (text === null)
115
+ return [];
116
+ let orgOnly = false;
117
+ if (appliesRedaction(text)) {
118
+ if (!orgRecorded)
119
+ return [];
120
+ const rules = await fs.readFile(join(flatDir, 'redaction.mjs'), 'utf8').catch(() => null);
121
+ if (rules === null || appliesOrgPacks(rules))
122
+ return [];
123
+ orgOnly = true;
124
+ }
125
+ const scripts = await flatScripts(flatDir);
126
+ if (scripts.length === 0)
127
+ return [];
128
+ const blockedBy = await flatRefreshBreaks(flatDir);
129
+ return [
130
+ {
131
+ path: flatDir,
132
+ what: `the hook scripts ${scripts.join(', ')}`,
133
+ ...(blockedBy.length > 0 ? { blockedBy } : {}),
134
+ ...(orgOnly ? { orgPacks: true } : {}),
135
+ },
136
+ ];
137
+ };
138
+ export const unredactedHookCopies = async (dirs = { managedDir: managedHooksDir(), flatDir: installedHooksDir() }, orgRecorded = false) => {
139
+ const release = await releaseBeforeRedaction(dirs.managedDir);
140
+ return [
141
+ ...(release === undefined
142
+ ? []
143
+ : [{ path: release.dir, what: `the hooks of managed release ${release.id}` }]),
144
+ ...(await unredactedFlatCopies(dirs.flatDir, orgRecorded)),
145
+ ];
146
+ };
147
+ export const flatCopyIssues = async (rulesFile, flatDir = installedHooksDir(), orgRecorded = false) => (await unredactedFlatCopies(flatDir, orgRecorded)).map((copy) => copy.orgPacks === true
148
+ ? {
149
+ level: 'error',
150
+ message: `Your organization's redaction packs are set, but ${copy.what} in ${copy.path} predate them (its redaction.mjs does not read them), ` +
151
+ `so they send spans without the packs. ${copyAdvice(copy)}`,
152
+ }
153
+ : {
154
+ level: rulesFile ? 'error' : 'warn',
155
+ message: `${rulesFile ? 'Redaction rules are set' : 'Credential redaction is on by default'}, but ${copy.what} in ${copy.path} predate redaction (its marker-core.mjs does not load them), ` +
156
+ `so they send spans without applying redaction rules. ${copyAdvice(copy)}`,
157
+ });