@mainwave/cli 0.12.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -3
- package/dist/adapters/codex-cli.js +64 -23
- package/dist/commands.js +4 -2
- package/dist/core/apply.js +44 -5
- package/dist/core/codex-trust.js +178 -0
- package/dist/core/doctor.js +61 -5
- package/dist/core/install-hooks.js +55 -1
- package/dist/core/interview.js +28 -14
- package/dist/core/markers.js +126 -25
- package/dist/core/redaction.js +10 -1
- package/dist/core/wizard.js +6 -0
- package/dist/main.js +10 -1
- package/hooks/codex-turns.mjs +584 -0
- package/hooks/mainwave-hook.mjs +16 -2
- package/hooks/marker-core.mjs +29 -8
- package/hooks/matchers.json +97 -0
- package/hooks/redaction-data.mjs +8 -0
- package/hooks/vocabulary.mjs +41 -2
- package/package.json +5 -2
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { promises as fs } from 'node:fs';
|
|
1
2
|
import { basename, dirname, isAbsolute, resolve } from 'node:path';
|
|
2
3
|
import { claudeConfigDir } from '../adapters/claude-code.js';
|
|
3
4
|
import { hasPath } from './detect.js';
|
|
4
5
|
import { activeHierarchy } from './effective-settings.js';
|
|
5
6
|
import { refreshFlatCopiesForOrgPacks } from './hook-copies.js';
|
|
6
7
|
import { isManagedLayer } from './layer-policy.js';
|
|
7
|
-
import { BOOTSTRAP_KEY, bootstrapGroup, buildHookGroups, DEFAULT_MARKER_TOOL, groupEvent, isBootstrapCommand, installedHooksDir, isDelivered, managedDeliversEntry, managedHooksDir, managedMarkerDeliveries, managedRedactionPacks, managedRunsBootstrap, matchersForTool, packagedHooksDir, prepareMarkersFile, readEntryVersion, readPackagedMatchers, routeKeyOf, scanForMarkers, syncManagedHooks, syncOrgDelivered, userHookGroups, } from './markers.js';
|
|
8
|
+
import { BOOTSTRAP_KEY, bootstrapGroup, buildHookGroups, DEFAULT_MARKER_TOOL, groupEvent, isBootstrapCommand, installedHooksDir, isDelivered, managedDeliversEntry, managedHooksDir, managedMarkerDeliveries, managedRedactionPacks, managedRunsBootstrap, matchersForTool, ownedGroupsInDoc, packagedHooksDir, prepareMarkersFile, readEntryVersion, readPackagedMatchers, routeKeyOf, scanForMarkers, syncManagedHooks, syncOrgDelivered, userHookGroups, } from './markers.js';
|
|
8
9
|
import { REDACTION_PACKS } from '../../hooks/redaction.mjs';
|
|
9
10
|
import { applyUpdate } from './settings.js';
|
|
10
11
|
import { KEEP_ORG_PACKS, hasOrgEntry, readSettings, settingsPath, syncOrgRedaction, } from './store.js';
|
|
@@ -140,6 +141,59 @@ export const installHooks = async (adapter, paths = defaultPaths(), { redactionP
|
|
|
140
141
|
orgRedaction,
|
|
141
142
|
};
|
|
142
143
|
};
|
|
144
|
+
export const installCodexHooks = async (adapter, paths = defaultPaths()) => {
|
|
145
|
+
const hooksFile = adapter.markers?.hooksFile;
|
|
146
|
+
if (hooksFile === undefined)
|
|
147
|
+
throw new Error(`${adapter.name} has no hooks file`);
|
|
148
|
+
const all = await readPackagedMatchers(paths.srcDir);
|
|
149
|
+
const updated = await syncManagedHooks(all, paths.srcDir, paths.destDir, paths.version ?? VERSION, paths.nodePath);
|
|
150
|
+
const stored = paths.stored ?? (await readSettings().catch(() => ({}))).hooks ?? {};
|
|
151
|
+
const disclosed = stored.events?.[adapter.name]?.[hooksFile.path];
|
|
152
|
+
if (disclosed === undefined || !hasPath(hooksFile.path)) {
|
|
153
|
+
return { updated, destDir: paths.destDir, addedToUser: 0, userSettings: undefined };
|
|
154
|
+
}
|
|
155
|
+
const disclosedRoutes = stored.routes?.[adapter.name]?.[hooksFile.path] ?? ROUTES_BEFORE_RECORD;
|
|
156
|
+
const wanted = userHookGroups(matchersForTool(all, adapter.markers?.runtimeTool ?? DEFAULT_MARKER_TOOL), { markers: stored.markers?.[adapter.name] ?? true }, new Set(), adapter.markers?.runtimeTool).filter((g) => disclosed.includes(groupEvent(g)) &&
|
|
157
|
+
g.hooks.every((h) => {
|
|
158
|
+
const key = routeKeyOf(h.command, adapter.markers?.runtimeTool);
|
|
159
|
+
return key === undefined || disclosedRoutes.includes(key);
|
|
160
|
+
}));
|
|
161
|
+
const body = await fs.readFile(hooksFile.path, 'utf8');
|
|
162
|
+
const present = new Set(ownedGroupsInDoc(hooksFile.codec.parse(body, hooksFile.path))
|
|
163
|
+
.filter((g) => g.ownership === 'cli')
|
|
164
|
+
.map((g) => routeKeyOf(g.command, adapter.markers?.runtimeTool)));
|
|
165
|
+
const missing = wanted.filter((g) => !present.has(routeKeyOf(g.hooks[0]?.command ?? '', adapter.markers?.runtimeTool)));
|
|
166
|
+
let addedToUser = 0;
|
|
167
|
+
if (missing.length > 0) {
|
|
168
|
+
const { update, plan } = await prepareMarkersFile(hooksFile.path, hooksFile.codec, missing, 0o600, () => false);
|
|
169
|
+
if (plan.changed) {
|
|
170
|
+
await applyUpdate(update);
|
|
171
|
+
addedToUser = plan.added.length;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return { updated, destDir: paths.destDir, addedToUser, userSettings: hooksFile.path };
|
|
175
|
+
};
|
|
176
|
+
export const runInstallCodexHooks = async (adapter, options = {}, paths) => {
|
|
177
|
+
let result;
|
|
178
|
+
try {
|
|
179
|
+
result = await installCodexHooks(adapter, paths);
|
|
180
|
+
}
|
|
181
|
+
catch (err) {
|
|
182
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
183
|
+
process.stderr.write(`mainwave-cli install-hooks: ${reason}\n`);
|
|
184
|
+
return 1;
|
|
185
|
+
}
|
|
186
|
+
if (options.quiet)
|
|
187
|
+
return 0;
|
|
188
|
+
console.log(result.updated.length > 0
|
|
189
|
+
? `Installed Mainwave hook scripts in ${result.destDir}: ${result.updated.join(', ')}`
|
|
190
|
+
: `Mainwave hook scripts in ${result.destDir} are already current.`);
|
|
191
|
+
if (result.addedToUser > 0) {
|
|
192
|
+
console.log(`Added ${result.addedToUser} Mainwave hook${result.addedToUser === 1 ? '' : 's'} to ${result.userSettings}. ` +
|
|
193
|
+
'Codex skips them until you approve them in /hooks.');
|
|
194
|
+
}
|
|
195
|
+
return 0;
|
|
196
|
+
};
|
|
143
197
|
export const runInstallHooks = async (adapter, options = {}, paths) => {
|
|
144
198
|
let result;
|
|
145
199
|
try {
|
package/dist/core/interview.js
CHANGED
|
@@ -154,6 +154,17 @@ const resolveUseCaseStep = async (input) => {
|
|
|
154
154
|
const sayCaptureNotice = (optIns, adapters, explicit) => {
|
|
155
155
|
const withoutPrompts = adapters.filter((a) => !effectiveOptIns(a, optIns, explicit).userPrompts);
|
|
156
156
|
const promptsAnywhere = withoutPrompts.length < adapters.length && optIns.userPrompts;
|
|
157
|
+
const sent = adapters.map((a) => effectiveOptIns(a, optIns, explicit));
|
|
158
|
+
const alwaysOnFor = (key) => {
|
|
159
|
+
if (optIns[key])
|
|
160
|
+
return undefined;
|
|
161
|
+
const names = adapters.filter((_, i) => sent[i][key]).map((a) => a.displayName);
|
|
162
|
+
return names.length > 0 ? names.join(', ') : undefined;
|
|
163
|
+
};
|
|
164
|
+
const detailsFixed = alwaysOnFor('toolDetails');
|
|
165
|
+
const contentFixed = alwaysOnFor('toolContent');
|
|
166
|
+
const toolDetails = optIns.toolDetails || detailsFixed !== undefined;
|
|
167
|
+
const toolContent = optIns.toolContent || contentFixed !== undefined;
|
|
157
168
|
const on = [
|
|
158
169
|
promptsAnywhere
|
|
159
170
|
? withoutPrompts.length > 0
|
|
@@ -164,8 +175,10 @@ const sayCaptureNotice = (optIns, adapters, explicit) => {
|
|
|
164
175
|
optIns.userPrompts && adapters.some((a) => a.name === 'claude-desktop')
|
|
165
176
|
? 'assistant responses'
|
|
166
177
|
: undefined,
|
|
167
|
-
|
|
168
|
-
|
|
178
|
+
toolDetails
|
|
179
|
+
? `shell commands and file paths${detailsFixed ? ` (${detailsFixed})` : ''}`
|
|
180
|
+
: undefined,
|
|
181
|
+
toolContent ? `tool result bodies${contentFixed ? ` (${contentFixed})` : ''}` : undefined,
|
|
169
182
|
optIns.userPrompts &&
|
|
170
183
|
optIns.toolDetails &&
|
|
171
184
|
optIns.toolContent &&
|
|
@@ -177,23 +190,24 @@ const sayCaptureNotice = (optIns, adapters, explicit) => {
|
|
|
177
190
|
: undefined,
|
|
178
191
|
].filter((s) => s !== undefined);
|
|
179
192
|
const codex = adapters.some((a) => a.name === 'codex');
|
|
180
|
-
const codexToolsOff = codex && !optIns.toolDetails && !optIns.toolContent;
|
|
181
193
|
if (on.length === 0) {
|
|
182
194
|
say(color.dim('Content capture is off — only metadata (tool names, tokens, cost) is sent.'));
|
|
183
195
|
}
|
|
184
196
|
else {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
197
|
+
const onlyFixed = !optIns.userPrompts &&
|
|
198
|
+
!optIns.repository &&
|
|
199
|
+
(!optIns.toolDetails || detailsFixed !== undefined) &&
|
|
200
|
+
(!optIns.toolContent || contentFixed !== undefined);
|
|
201
|
+
say(color.yellow(`Content capture is ON: ${on.join(', ')} will be sent to your collector.` +
|
|
202
|
+
(onlyFixed
|
|
203
|
+
? ''
|
|
204
|
+
: '\nTurn it off with `--opt-in none`, or pick what you want with\n' +
|
|
205
|
+
'`--opt-in prompts,tool-details,tool-content,repository`.')));
|
|
192
206
|
}
|
|
193
|
-
if (
|
|
194
|
-
say(color.yellow('Codex
|
|
195
|
-
'
|
|
196
|
-
'
|
|
207
|
+
if (codex) {
|
|
208
|
+
say(color.yellow('Codex sends its tool commands and results whatever `--opt-in` says: its config has\n' +
|
|
209
|
+
'no switch for them, so `--opt-in` changes only whether it sends prompt text.\n' +
|
|
210
|
+
'Codex caps each tool result at 2,048 bytes by default (`[otel.tool_result] max_bytes`).'));
|
|
197
211
|
}
|
|
198
212
|
};
|
|
199
213
|
export const resolveApiKeyForTest = resolveApiKey;
|
package/dist/core/markers.js
CHANGED
|
@@ -35,12 +35,25 @@ const INSTALLED_HOOK_EVENTS = [
|
|
|
35
35
|
'UserPromptSubmit',
|
|
36
36
|
'PostToolUse',
|
|
37
37
|
'StopFailure',
|
|
38
|
+
'Stop',
|
|
39
|
+
'Interrupt',
|
|
40
|
+
'PermissionRequest',
|
|
41
|
+
'PreModelRequest',
|
|
42
|
+
'SubagentStart',
|
|
43
|
+
'SubagentStop',
|
|
38
44
|
];
|
|
39
45
|
const MARKER_HOOK_EVENTS = INSTALLED_HOOK_EVENTS;
|
|
40
46
|
const ENTRY_EVENTS = [
|
|
41
47
|
'UserPromptSubmit',
|
|
42
48
|
'PostToolUse',
|
|
43
49
|
'StopFailure',
|
|
50
|
+
'SessionStart',
|
|
51
|
+
'Stop',
|
|
52
|
+
'Interrupt',
|
|
53
|
+
'PermissionRequest',
|
|
54
|
+
'PreModelRequest',
|
|
55
|
+
'SubagentStart',
|
|
56
|
+
'SubagentStop',
|
|
44
57
|
];
|
|
45
58
|
const MATCHER_EVENTS = new Set(['PostToolUse', 'SessionStart']);
|
|
46
59
|
const TOOL_EVENTS = new Set(['PostToolUse']);
|
|
@@ -64,12 +77,17 @@ export const shellHome = (plat = process.platform, env = process.env, dirExists
|
|
|
64
77
|
return drivePath;
|
|
65
78
|
return env.USERPROFILE || homedir();
|
|
66
79
|
};
|
|
67
|
-
export const installHooksCommand = (version, { quiet = true, redactionPacks = [], } = {}) => `cd "$HOME" && npx -y --registry=https://registry.npmjs.org ` +
|
|
80
|
+
export const installHooksCommand = (version, { quiet = true, redactionPacks = [], host = DEFAULT_MARKER_TOOL, } = {}) => `cd "$HOME" && npx -y --registry=https://registry.npmjs.org ` +
|
|
68
81
|
`@mainwave/cli@${version} install-hooks${quiet ? ' --quiet' : ''}` +
|
|
82
|
+
(host === 'codex' ? ' --host codex' : '') +
|
|
69
83
|
(redactionPacks.length > 0
|
|
70
84
|
? ` ${REDACTION_PACKS_FLAG} ${canonicalPacks(redactionPacks).join(',')}`
|
|
71
85
|
: '');
|
|
72
86
|
export const bootstrapCommand = (version, redactionPacks = []) => `{ ${installHooksCommand(version, { redactionPacks })}; } >/dev/null 2>&1; exit 0`;
|
|
87
|
+
export const codexBootstrapCommand = (version, plat = process.platform) => plat === 'win32'
|
|
88
|
+
? `(cd /d "%USERPROFILE%" && npx -y --registry=https://registry.npmjs.org ` +
|
|
89
|
+
`@mainwave/cli@${version} install-hooks --quiet --host codex) >NUL 2>&1 & exit /b 0`
|
|
90
|
+
: `{ ${installHooksCommand(version, { host: 'codex' })}; } >/dev/null 2>&1; exit 0`;
|
|
73
91
|
const REDACTION_PACKS_FLAG = '--redaction-packs';
|
|
74
92
|
export const redactionPacksIn = (command) => {
|
|
75
93
|
const args = /\binstall-hooks\b([^;}]*)/.exec(command)?.[1];
|
|
@@ -83,11 +101,17 @@ export const redactionPacksIn = (command) => {
|
|
|
83
101
|
};
|
|
84
102
|
export const BOOTSTRAP_MATCHER = 'startup|resume|fork';
|
|
85
103
|
export const BOOTSTRAP_KEY = 'SessionStart:bootstrap';
|
|
86
|
-
export const bootstrapGroup = (redactionPacks = []) => ({
|
|
104
|
+
export const bootstrapGroup = (redactionPacks = [], host = DEFAULT_MARKER_TOOL) => ({
|
|
87
105
|
event: 'SessionStart',
|
|
88
106
|
matcher: BOOTSTRAP_MATCHER,
|
|
89
107
|
hooks: [
|
|
90
|
-
{
|
|
108
|
+
{
|
|
109
|
+
type: 'command',
|
|
110
|
+
command: host === 'codex'
|
|
111
|
+
? codexBootstrapCommand(PAYLOAD_CLI_SPEC)
|
|
112
|
+
: bootstrapCommand(PAYLOAD_CLI_SPEC, redactionPacks),
|
|
113
|
+
async: true,
|
|
114
|
+
},
|
|
91
115
|
],
|
|
92
116
|
});
|
|
93
117
|
const SAFE_ROUTE = /^[a-z][a-z0-9-]*$/;
|
|
@@ -475,12 +499,20 @@ export const scriptPathFromCommand = (command) => {
|
|
|
475
499
|
const m = /^(?:\$\{HOME\}|\$HOME)(?=\/)/.exec(raw);
|
|
476
500
|
return m ? shellHome() + raw.slice(m[0].length) : raw;
|
|
477
501
|
};
|
|
478
|
-
export const hookShape = (
|
|
502
|
+
export const hookShape = (event, host = DEFAULT_MARKER_TOOL) => {
|
|
503
|
+
if (host === 'codex' && event === 'Stop')
|
|
504
|
+
return { timeout: CODEX_STOP_TIMEOUT_SEC };
|
|
505
|
+
if (host === 'codex' && event === 'Interrupt')
|
|
506
|
+
return { timeout: CODEX_INTERRUPT_TIMEOUT_SEC };
|
|
507
|
+
return { async: true };
|
|
508
|
+
};
|
|
509
|
+
const CODEX_STOP_TIMEOUT_SEC = 5;
|
|
510
|
+
const CODEX_INTERRUPT_TIMEOUT_SEC = 2;
|
|
479
511
|
const groupFor = (m, host) => {
|
|
480
512
|
const hook = {
|
|
481
513
|
type: 'command',
|
|
482
514
|
command: buildHookCommand(host, m.event, m.route),
|
|
483
|
-
...hookShape(host),
|
|
515
|
+
...hookShape(m.event, host),
|
|
484
516
|
};
|
|
485
517
|
if (m.if !== undefined && host !== 'codex')
|
|
486
518
|
hook.if = m.if;
|
|
@@ -491,11 +523,11 @@ const groupFor = (m, host) => {
|
|
|
491
523
|
};
|
|
492
524
|
};
|
|
493
525
|
export const buildHookGroups = (matchers, host = DEFAULT_MARKER_TOOL) => matchers.map((m) => groupFor(m, host));
|
|
494
|
-
export const hostRunsBootstrap = (host) => host === DEFAULT_MARKER_TOOL;
|
|
526
|
+
export const hostRunsBootstrap = (host) => host === DEFAULT_MARKER_TOOL || host === 'codex';
|
|
495
527
|
export const userHookGroups = (hosted, on, delivered, host = DEFAULT_MARKER_TOOL) => {
|
|
496
528
|
const selected = selectHookMatchers(hosted, on);
|
|
497
529
|
const groups = [
|
|
498
|
-
...(hostRunsBootstrap(host) && selected.length > 0 ? [bootstrapGroup()] : []),
|
|
530
|
+
...(hostRunsBootstrap(host) && selected.length > 0 ? [bootstrapGroup([], host)] : []),
|
|
499
531
|
...buildHookGroups(selected, host),
|
|
500
532
|
];
|
|
501
533
|
return groups.filter((g) => {
|
|
@@ -555,6 +587,14 @@ const sameGroup = (before, after) => before.event === groupEvent(after) &&
|
|
|
555
587
|
before.timeout === after.hooks[0]?.timeout &&
|
|
556
588
|
(before.async === true) === (after.hooks[0]?.async === true) &&
|
|
557
589
|
before.if === after.hooks[0]?.if;
|
|
590
|
+
const sameRoute = (before, after) => {
|
|
591
|
+
const command = after.hooks[0]?.command;
|
|
592
|
+
if (command === undefined || before.event !== groupEvent(after))
|
|
593
|
+
return false;
|
|
594
|
+
const host = parseEntryCommand(command)?.host ?? DEFAULT_MARKER_TOOL;
|
|
595
|
+
const key = routeKeyOf(command, host);
|
|
596
|
+
return key !== undefined && key === routeKeyOf(before.command, host);
|
|
597
|
+
};
|
|
558
598
|
export const planMarkers = (doc, groups, remove = () => true) => {
|
|
559
599
|
if (!isPlainObject(doc))
|
|
560
600
|
throw new Error('expected the settings document to be a JSON object');
|
|
@@ -574,25 +614,53 @@ export const planMarkers = (doc, groups, remove = () => true) => {
|
|
|
574
614
|
skippedEvents.push({ event, message: malformedEventMessage(event) });
|
|
575
615
|
}
|
|
576
616
|
const writable = groups.filter((g) => !skipped.has(groupEvent(g)));
|
|
577
|
-
const
|
|
617
|
+
const identical = new Set();
|
|
618
|
+
const placed = new Set();
|
|
578
619
|
let pruned = false;
|
|
620
|
+
const removedInfo = [];
|
|
579
621
|
for (const event of MARKER_HOOK_EVENTS) {
|
|
580
622
|
if (skipped.has(event))
|
|
581
623
|
continue;
|
|
582
|
-
const current = hooks[event];
|
|
583
|
-
|
|
584
|
-
const kept = (current ?? []).filter((g) => {
|
|
624
|
+
const current = hooks[event] ?? [];
|
|
625
|
+
const owned = current.map((g) => {
|
|
585
626
|
const o = groupOwnership(g);
|
|
586
627
|
if (o === null || !isPlainObject(g))
|
|
587
|
-
return
|
|
628
|
+
return null;
|
|
588
629
|
const info = ownedGroupInfo(g, o, event);
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
630
|
+
return remove(o, info) ? info : null;
|
|
631
|
+
});
|
|
632
|
+
const keep = owned.map((info) => {
|
|
633
|
+
if (info === null)
|
|
634
|
+
return false;
|
|
635
|
+
const same = writable.find((a) => !identical.has(a) && sameGroup(info, a));
|
|
636
|
+
if (same === undefined)
|
|
637
|
+
return false;
|
|
638
|
+
identical.add(same);
|
|
639
|
+
return true;
|
|
640
|
+
});
|
|
641
|
+
let removedHere = 0;
|
|
642
|
+
const kept = [];
|
|
643
|
+
current.forEach((g, i) => {
|
|
644
|
+
const info = owned[i];
|
|
645
|
+
if (info === null || info === undefined || keep[i]) {
|
|
646
|
+
kept.push(g);
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
removedInfo.push(info);
|
|
650
|
+
const slot = writable.find((a) => !identical.has(a) && !placed.has(a) && sameRoute(info, a));
|
|
651
|
+
if (slot === undefined) {
|
|
652
|
+
removedHere++;
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
placed.add(slot);
|
|
656
|
+
kept.push(writtenGroup(slot));
|
|
594
657
|
});
|
|
595
|
-
const next = [
|
|
658
|
+
const next = [
|
|
659
|
+
...kept,
|
|
660
|
+
...writable
|
|
661
|
+
.filter((g) => groupEvent(g) === event && !identical.has(g) && !placed.has(g))
|
|
662
|
+
.map(writtenGroup),
|
|
663
|
+
];
|
|
596
664
|
if (next.length > 0)
|
|
597
665
|
hooks[event] = next;
|
|
598
666
|
else if (removedHere > 0) {
|
|
@@ -605,9 +673,9 @@ export const planMarkers = (doc, groups, remove = () => true) => {
|
|
|
605
673
|
next.hooks = hooks;
|
|
606
674
|
else
|
|
607
675
|
delete next.hooks;
|
|
608
|
-
const unchanged =
|
|
609
|
-
const removed =
|
|
610
|
-
const added = writable.filter((a) => !
|
|
676
|
+
const unchanged = identical.size;
|
|
677
|
+
const removed = removedInfo;
|
|
678
|
+
const added = writable.filter((a) => !identical.has(a));
|
|
611
679
|
return {
|
|
612
680
|
next,
|
|
613
681
|
removed,
|
|
@@ -846,6 +914,15 @@ export const routeLabel = (key) => {
|
|
|
846
914
|
'PostToolUse:linear': 'the Linear ticket marker',
|
|
847
915
|
'PostToolUse:jira': 'the Jira ticket marker',
|
|
848
916
|
StopFailure: 'the Claude turn-error span',
|
|
917
|
+
'UserPromptSubmit:turns': 'the Codex turn start',
|
|
918
|
+
'Stop:turns': 'the Codex turn end',
|
|
919
|
+
'Interrupt:turns': 'the Codex interrupt',
|
|
920
|
+
'PermissionRequest:turns': 'the Codex permission wait',
|
|
921
|
+
'PostToolUse:turns': 'the Codex tool-call tracker',
|
|
922
|
+
'PreModelRequest:turns': 'the Codex model-request tracker',
|
|
923
|
+
'SubagentStart:turns': 'the Codex subagent start',
|
|
924
|
+
'SubagentStop:turns': 'the Codex subagent end',
|
|
925
|
+
'SessionStart:turns': 'the Codex session-start turn cleanup',
|
|
849
926
|
};
|
|
850
927
|
return labels[key] ?? key;
|
|
851
928
|
};
|
|
@@ -1046,12 +1123,28 @@ export const collectMarkerIssues = async (scans, currentVersion, matchers, skipp
|
|
|
1046
1123
|
}
|
|
1047
1124
|
continue;
|
|
1048
1125
|
}
|
|
1049
|
-
|
|
1126
|
+
const want = generation === 'bootstrap' ? { async: true } : hookShape(g.event, host);
|
|
1127
|
+
if (want.async !== true && (g.async === true || g.timeout !== want.timeout)) {
|
|
1050
1128
|
issues.push({
|
|
1051
1129
|
level: 'warn',
|
|
1052
|
-
message: `The Mainwave hook ${shortCommand(g.command)} under ${g.event} in ${g.path}
|
|
1053
|
-
`
|
|
1054
|
-
|
|
1130
|
+
message: `The Mainwave hook ${shortCommand(g.command)} under ${g.event} in ${g.path} should be synchronous with ` +
|
|
1131
|
+
`a ${want.timeout} s timeout` +
|
|
1132
|
+
(g.async === true
|
|
1133
|
+
? ', but it runs in the background, so `codex exec` can exit before it sends the last turn. '
|
|
1134
|
+
: `, but it has ${g.timeout === undefined ? 'no timeout' : `a ${g.timeout} s timeout`}. `) +
|
|
1135
|
+
fixFor(g.managed, 'Re-run `mainwave-cli setup codex` to rewrite it, then approve the changed hooks in /hooks.'),
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
else if (want.async === true && g.async !== true) {
|
|
1139
|
+
const tool = host === 'codex' ? 'Codex' : 'Claude Code';
|
|
1140
|
+
issues.push({
|
|
1141
|
+
level: 'warn',
|
|
1142
|
+
message: `The Mainwave hook ${shortCommand(g.command)} under ${g.event} in ${g.path} is not async` +
|
|
1143
|
+
(g.timeout === undefined ? '' : ` (it still has the ${g.timeout} s timeout form)`) +
|
|
1144
|
+
`, so ${tool} waits for it on every ${g.event === 'PostToolUse' ? 'matching tool call' : g.event}. ` +
|
|
1145
|
+
fixFor(g.managed, host === 'codex'
|
|
1146
|
+
? 'Re-run `mainwave-cli setup codex` to rewrite it, then approve the changed hooks in /hooks.'
|
|
1147
|
+
: 'Re-run setup to rewrite it.'),
|
|
1055
1148
|
});
|
|
1056
1149
|
}
|
|
1057
1150
|
if (generation === 'bootstrap') {
|
|
@@ -1133,6 +1226,14 @@ export const collectMarkerIssues = async (scans, currentVersion, matchers, skipp
|
|
|
1133
1226
|
const managedCurrent = cli.some((g) => g.managed && commandGeneration(g.command) === 'entry');
|
|
1134
1227
|
const wanted = managedCurrent ? matchers : selected;
|
|
1135
1228
|
const missing = wanted.filter((m) => !seenRoutes.has(deliveryKey(m.event, m.route)));
|
|
1229
|
+
if (host === 'codex' && selected.length > 0 && !seenRoutes.has(BOOTSTRAP_KEY)) {
|
|
1230
|
+
issues.push({
|
|
1231
|
+
level: 'warn',
|
|
1232
|
+
message: `The Mainwave session-start refresh (install-hooks) is missing from Codex's hooks file, so a new release's hook scripts ` +
|
|
1233
|
+
'and routes reach this machine only when you re-run setup. ' +
|
|
1234
|
+
'Re-run `mainwave-cli setup codex`, then approve the new hook in /hooks.',
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1136
1237
|
if (missing.length > 0) {
|
|
1137
1238
|
issues.push({
|
|
1138
1239
|
level: managedCurrent ? 'info' : 'warn',
|
package/dist/core/redaction.js
CHANGED
|
@@ -162,7 +162,10 @@ export const sendsUnredactedContent = (adapter, optIns) => {
|
|
|
162
162
|
const list = (names) => names.length <= 2 ? names.join(' and ') : `${names.slice(0, -1).join(', ')} and ${names.at(-1)}`;
|
|
163
163
|
export const uncoveredNotice = (uncovered) => {
|
|
164
164
|
const names = uncovered.map((a) => a.displayName);
|
|
165
|
-
const
|
|
165
|
+
const partial = uncovered.filter((a) => carriesOptIns(a) && a.alwaysOnOptIns !== undefined);
|
|
166
|
+
const switchable = uncovered
|
|
167
|
+
.filter((a) => carriesOptIns(a) && a.alwaysOnOptIns === undefined)
|
|
168
|
+
.map((a) => a.displayName);
|
|
166
169
|
const fixed = uncovered.filter((a) => !carriesOptIns(a)).map((a) => a.displayName);
|
|
167
170
|
return [
|
|
168
171
|
`Redaction covers the spans mainwave-cli's hooks send. ${list(names)} ` +
|
|
@@ -172,6 +175,12 @@ export const uncoveredNotice = (uncovered) => {
|
|
|
172
175
|
...(switchable.length > 0
|
|
173
176
|
? [`Run setup with --opt-in none to stop ${list(switchable)} sending content.`]
|
|
174
177
|
: []),
|
|
178
|
+
...(partial.length > 0
|
|
179
|
+
? [
|
|
180
|
+
`${list(partial.map((a) => a.displayName))}: --opt-in none stops only prompt text; ` +
|
|
181
|
+
'its tool commands and results are exported whatever --opt-in says.',
|
|
182
|
+
]
|
|
183
|
+
: []),
|
|
175
184
|
...(fixed.length > 0
|
|
176
185
|
? [`${list(fixed)}: what it exports is set where its export is configured, not by --opt-in.`]
|
|
177
186
|
: []),
|
package/dist/core/wizard.js
CHANGED
|
@@ -19,6 +19,7 @@ import { VERSION } from './version.js';
|
|
|
19
19
|
import { emitJson, say, setJsonMode } from './ui.js';
|
|
20
20
|
import { validateCollector } from './validate.js';
|
|
21
21
|
import { runVerify } from './verify.js';
|
|
22
|
+
import { codexCli, codexHomeIssues } from '../adapters/codex-cli.js';
|
|
22
23
|
const validateWithRetry = async (initialUrl, initialKey, interactive) => {
|
|
23
24
|
let url = initialUrl;
|
|
24
25
|
let key = initialKey;
|
|
@@ -255,6 +256,11 @@ export const runSetup = async (adapters, rawOptions = {}) => {
|
|
|
255
256
|
let credentials = await readCredentials();
|
|
256
257
|
let session = activeSession(credentials, endpoints.apiUrl);
|
|
257
258
|
say(color.bold(`mainwave-cli — setup ${adapters.map((a) => a.displayName).join(', ')}`));
|
|
259
|
+
if (adapters.some((a) => a.name === codexCli.name)) {
|
|
260
|
+
for (const issue of codexHomeIssues()) {
|
|
261
|
+
say(issue.level === 'warn' ? color.yellow(`⚠ ${issue.message}`) : color.dim(issue.message));
|
|
262
|
+
}
|
|
263
|
+
}
|
|
258
264
|
const options = rawOptions.invite
|
|
259
265
|
? await redeemInviteToOverrides(rawOptions.invite, endpoints.apiUrl, rawOptions)
|
|
260
266
|
: rawOptions;
|
package/dist/main.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { claudeCodeFor } from './adapters/claude-code.js';
|
|
2
|
+
import { codexCli } from './adapters/codex-cli.js';
|
|
2
3
|
import { adapterNames, adapters } from './adapters/index.js';
|
|
3
4
|
import { commandFlags, detailsBlock, isCommand, usageBlock } from './commands.js';
|
|
4
5
|
import { runLogin, runLogout, runWhoami } from './core/auth-commands.js';
|
|
@@ -6,7 +7,7 @@ import { runDoctor } from './core/doctor.js';
|
|
|
6
7
|
import { runEdit } from './core/edit.js';
|
|
7
8
|
import { runEnvCommand } from './core/env-command.js';
|
|
8
9
|
import { PlatformError, WizardAbort } from './core/errors.js';
|
|
9
|
-
import { runInstallHooks, sessionConfigDir } from './core/install-hooks.js';
|
|
10
|
+
import { runInstallCodexHooks, runInstallHooks, sessionConfigDir } from './core/install-hooks.js';
|
|
10
11
|
import { parseRedactionPacks } from './core/redaction.js';
|
|
11
12
|
import { parseArgs } from './core/flags.js';
|
|
12
13
|
import { color } from './core/format.js';
|
|
@@ -245,6 +246,14 @@ const HANDLERS = {
|
|
|
245
246
|
return 1;
|
|
246
247
|
}
|
|
247
248
|
}
|
|
249
|
+
const host = flags.has('host') ? flags.value('host') : undefined;
|
|
250
|
+
if (host !== undefined && host !== 'codex') {
|
|
251
|
+
process.stderr.write(`mainwave-cli install-hooks: --host takes \`codex\`, not "${host}"\n`);
|
|
252
|
+
return 1;
|
|
253
|
+
}
|
|
254
|
+
if (host === 'codex') {
|
|
255
|
+
return runInstallCodexHooks(codexCli, { quiet: flags.bool('quiet') === true });
|
|
256
|
+
}
|
|
248
257
|
const dir = await sessionConfigDir();
|
|
249
258
|
return runInstallHooks(dir === undefined ? undefined : claudeCodeFor(dir), {
|
|
250
259
|
quiet: flags.bool('quiet') === true,
|