@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
package/dist/main.js CHANGED
@@ -1,12 +1,15 @@
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';
4
+ import { commandFlags, detailsBlock, isCommand, usageBlock } from './commands.js';
3
5
  import { runLogin, runLogout, runWhoami } from './core/auth-commands.js';
4
6
  import { runDoctor } from './core/doctor.js';
5
7
  import { runEdit } from './core/edit.js';
6
8
  import { runEnvCommand } from './core/env-command.js';
7
9
  import { PlatformError, WizardAbort } from './core/errors.js';
8
- import { runInstallHooks, sessionConfigDir } from './core/install-hooks.js';
9
- import { flagBool, flagValue, hasFlag, parseArgs } from './core/flags.js';
10
+ import { runInstallCodexHooks, runInstallHooks, sessionConfigDir } from './core/install-hooks.js';
11
+ import { parseRedactionPacks } from './core/redaction.js';
12
+ import { parseArgs } from './core/flags.js';
10
13
  import { color } from './core/format.js';
11
14
  import { promptAdapters } from './core/prompts.js';
12
15
  import { runStatus } from './core/status.js';
@@ -15,7 +18,6 @@ import { VERSION } from './core/version.js';
15
18
  import { runVerify } from './core/verify.js';
16
19
  import { runRemove } from './core/remove.js';
17
20
  import { runSetup, runSkillsOnly } from './core/wizard.js';
18
- export { VERSION };
19
21
  const printHelp = () => {
20
22
  const list = adapterNames()
21
23
  .map((n) => ` ${n}`)
@@ -23,57 +25,10 @@ const printHelp = () => {
23
25
  console.log(`mainwave-cli — Mainwave AI setup wizard
24
26
 
25
27
  Usage:
26
- mainwave-cli login [--password] [--device] [--no-browser] [--api-url <u>] [--json]
27
- sign in to Mainwave: shows a code and opens the app to
28
- approve it. --password uses email + password instead
29
- (MAINWAVE_EMAIL / MAINWAVE_PASSWORD drive it
30
- non-interactively); --device forces the browser flow
31
- without a terminal (coding agents); --no-browser
32
- prints the URL
33
- mainwave-cli logout forget the stored session
34
- mainwave-cli whoami [--json] print the signed-in user, org, and endpoints
35
- mainwave-cli setup [<adapter>...] run the interactive setup wizard; with no adapter,
36
- every detected tool is configured and the rest are
37
- offered, and with several, configure them all in
38
- one pass. Always writes user-global config
39
- mainwave-cli verify [--ucid <id|url>] [--no-sample] [--timeout <s>] [--json]
40
- push a sample trace and wait for it to land, then
41
- print where your activity appears
42
- mainwave-cli status [<adapter>] [--json]
43
- show current on-disk config for all (or one) adapter
44
- mainwave-cli edit <adapter> [--local|--global]
45
- open a settings file in $EDITOR (interactive picker by default;
46
- flag is required in non-TTY)
47
- mainwave-cli doctor <adapter> [--validate] [--json]
48
- show settings hierarchy and run health checks
49
- mainwave-cli env <adapter> print export lines for shell-sourceable adapters
50
- (usage: \`eval "$(mainwave-cli env <adapter>)"\`)
51
- mainwave-cli install-hooks [--quiet] install or refresh the Mainwave hook entry and the
52
- latest release's hook scripts, with no prompts or
53
- sign-in (run at session start by an org's managed
54
- settings, and by setup's own session-start hook)
28
+ ${usageBlock()}
55
29
  mainwave-cli --help show this message
56
30
 
57
- Setup flags (every prompt has one, so scripts and coding agents can drive it):
58
- --api-key <k> --collector-url <u> --api-url <u>
59
- --ucid <id|url> --use-case <name> pin every tool to one use case (by default none
60
- is written: each tool's activity is attributed at ingest
61
- from your identity). A pin survives later default runs;
62
- --no-use-case removes it
63
- --email <e> --new-key
64
- --invite <token> redeem an account-less developer invite: no login, no key
65
- to paste — the token brings its own key, collector, and
66
- identity (mutually exclusive with --api-key/--ucid/--use-case)
67
- --opt-in prompts,tool-details,tool-content,repository|all|none content capture
68
- (default: all on — "--opt-in none" sends metadata only;
69
- repository = repository names on Claude Code telemetry)
70
- --no-markers skip the Mainwave hooks (installed by default): the ticket
71
- & PR markers and, for Claude Code, the plan snapshot
72
- --yes --json --no-verify --verify-timeout <seconds>
73
- --skills / --no-skills install the agent skills payload (default: ask, or on in scripts)
74
- --skills-only install only the skills, touching no telemetry config
75
- --remove take this CLI's config for the named tools back off this
76
- machine (Kiro: its hooks file entries and kiro.env)
31
+ ${detailsBlock()}
77
32
  mainwave-cli --version print version
78
33
 
79
34
  Available adapters:
@@ -128,38 +83,55 @@ const detectedAdapters = () => {
128
83
  return found;
129
84
  };
130
85
  const setupOptions = (parsed) => {
131
- if (hasFlag(parsed, 'scope')) {
86
+ const flags = commandFlags('setup', parsed);
87
+ if (flags.has('scope')) {
132
88
  throw new WizardAbort('--scope was removed: setup writes user-global config only. Drop the flag.');
133
89
  }
134
- const invite = flagValue(parsed, 'invite');
135
- if (hasFlag(parsed, 'invite') && invite === undefined) {
90
+ const invite = flags.value('invite');
91
+ if (flags.has('invite') && invite === undefined) {
136
92
  throw new WizardAbort('--invite requires a token, e.g. --invite <token>');
137
93
  }
138
94
  if (invite !== undefined) {
139
95
  for (const conflicting of ['api-key', 'ucid', 'use-case']) {
140
- if (hasFlag(parsed, conflicting)) {
96
+ if (flags.has(conflicting)) {
141
97
  throw new WizardAbort(`--invite cannot be combined with --${conflicting}`);
142
98
  }
143
99
  }
144
100
  }
101
+ const redactionFile = flags.value('redaction-file');
102
+ if (flags.has('redaction-file') && (redactionFile === undefined || redactionFile === '')) {
103
+ throw new WizardAbort('--redaction-file requires a path, e.g. --redaction-file ./redaction.json');
104
+ }
105
+ const noRedaction = flags.bool('redaction') === false;
106
+ if (redactionFile !== undefined && noRedaction) {
107
+ throw new WizardAbort('--redaction-file and --no-redaction cannot be combined');
108
+ }
109
+ const redactSecrets = flags.bool('redact-secrets');
110
+ if ((redactionFile !== undefined || noRedaction || redactSecrets !== undefined) &&
111
+ flags.bool('skills-only') === true) {
112
+ throw new WizardAbort('--skills-only touches no telemetry config, so redaction flags do not apply');
113
+ }
145
114
  return {
146
115
  invite,
147
- apiKey: flagValue(parsed, 'api-key'),
148
- collectorUrl: flagValue(parsed, 'collector-url'),
149
- apiUrl: flagValue(parsed, 'api-url'),
150
- ucid: flagValue(parsed, 'ucid'),
151
- useCaseName: flagValue(parsed, 'use-case'),
152
- skipUseCase: flagBool(parsed, 'use-case') === false,
153
- userEmail: flagValue(parsed, 'email'),
154
- optIns: parseOptIns(flagValue(parsed, 'opt-in')),
155
- markers: flagBool(parsed, 'markers'),
156
- skills: flagBool(parsed, 'skills'),
157
- skillsOnly: flagBool(parsed, 'skills-only') === true,
158
- newKey: flagBool(parsed, 'new-key') === true,
159
- yes: flagBool(parsed, 'yes') === true,
160
- json: flagBool(parsed, 'json') === true,
161
- skipVerify: flagBool(parsed, 'verify') === false,
162
- verifyTimeoutMs: seconds(flagValue(parsed, 'verify-timeout')),
116
+ redactionFile,
117
+ noRedaction,
118
+ redactSecrets,
119
+ apiKey: flags.value('api-key'),
120
+ collectorUrl: flags.value('collector-url'),
121
+ apiUrl: flags.value('api-url'),
122
+ ucid: flags.value('ucid'),
123
+ useCaseName: flags.value('use-case'),
124
+ skipUseCase: flags.bool('use-case') === false,
125
+ userEmail: flags.value('email'),
126
+ optIns: parseOptIns(flags.value('opt-in')),
127
+ markers: flags.bool('markers'),
128
+ skills: flags.bool('skills'),
129
+ skillsOnly: flags.bool('skills-only') === true,
130
+ newKey: flags.bool('new-key') === true,
131
+ yes: flags.bool('yes') === true,
132
+ json: flags.bool('json') === true,
133
+ skipVerify: flags.bool('verify') === false,
134
+ verifyTimeoutMs: seconds(flags.value('verify-timeout')),
163
135
  };
164
136
  };
165
137
  const reportCommandError = (err) => {
@@ -179,56 +151,56 @@ const reportCommandError = (err) => {
179
151
  printError(err instanceof Error ? err.message : String(err));
180
152
  return 1;
181
153
  };
182
- export const main = async (argv) => {
183
- const args = argv.slice(2);
184
- const cmd = args[0];
185
- if (cmd === undefined || cmd === '--help' || cmd === '-h' || cmd === 'help') {
186
- printHelp();
187
- return 0;
188
- }
189
- if (cmd === '--version' || cmd === '-v') {
190
- console.log(VERSION);
191
- return 0;
192
- }
193
- const AUTH_COMMANDS = ['login', 'logout', 'whoami'];
194
- if (cmd !== 'setup' &&
195
- cmd !== 'doctor' &&
196
- cmd !== 'env' &&
197
- cmd !== 'status' &&
198
- cmd !== 'edit' &&
199
- cmd !== 'verify' &&
200
- cmd !== 'install-hooks' &&
201
- !AUTH_COMMANDS.includes(cmd)) {
202
- printError(`unknown command: ${cmd}`);
203
- printHelp();
204
- return 1;
154
+ const resolveAdapters = (names) => {
155
+ const named = [];
156
+ for (const name of names) {
157
+ const resolved = resolveAdapter(name);
158
+ if (typeof resolved === 'number')
159
+ return resolved;
160
+ named.push(resolved);
205
161
  }
206
- if (AUTH_COMMANDS.includes(cmd)) {
207
- const parsed = parseArgs(args.slice(1));
208
- const json = flagBool(parsed, 'json') === true;
162
+ return named;
163
+ };
164
+ const HANDLERS = {
165
+ login: async (args) => {
166
+ const flags = commandFlags('login', parseArgs(args));
209
167
  try {
210
- if (cmd === 'login') {
211
- return await runLogin({
212
- email: flagValue(parsed, 'email'),
213
- usePassword: flagBool(parsed, 'password') === true,
214
- useDevice: flagBool(parsed, 'device') === true,
215
- noBrowser: flagBool(parsed, 'browser') === false,
216
- deviceTimeoutMs: seconds(flagValue(parsed, 'device-timeout')),
217
- apiUrl: flagValue(parsed, 'api-url'),
218
- force: flagBool(parsed, 'force') === true,
219
- json,
220
- });
221
- }
222
- if (cmd === 'logout')
223
- return await runLogout({ json });
224
- return await runWhoami({ apiUrl: flagValue(parsed, 'api-url'), json });
168
+ return await runLogin({
169
+ email: flags.value('email'),
170
+ usePassword: flags.bool('password') === true,
171
+ useDevice: flags.bool('device') === true,
172
+ noBrowser: flags.bool('browser') === false,
173
+ deviceTimeoutMs: seconds(flags.value('device-timeout')),
174
+ apiUrl: flags.value('api-url'),
175
+ force: flags.bool('force') === true,
176
+ json: flags.bool('json') === true,
177
+ });
225
178
  }
226
179
  catch (err) {
227
180
  return reportCommandError(err);
228
181
  }
229
- }
230
- if (cmd === 'status') {
231
- const parsed = parseArgs(args.slice(1));
182
+ },
183
+ logout: async (args) => {
184
+ const flags = commandFlags('logout', parseArgs(args));
185
+ try {
186
+ return await runLogout({ json: flags.bool('json') === true });
187
+ }
188
+ catch (err) {
189
+ return reportCommandError(err);
190
+ }
191
+ },
192
+ whoami: async (args) => {
193
+ const flags = commandFlags('whoami', parseArgs(args));
194
+ try {
195
+ return await runWhoami({ apiUrl: flags.value('api-url'), json: flags.bool('json') === true });
196
+ }
197
+ catch (err) {
198
+ return reportCommandError(err);
199
+ }
200
+ },
201
+ status: async (args) => {
202
+ const parsed = parseArgs(args);
203
+ const flags = commandFlags('status', parsed);
232
204
  const name = parsed.positionals[0];
233
205
  let target;
234
206
  if (name !== undefined) {
@@ -238,55 +210,70 @@ export const main = async (argv) => {
238
210
  target = resolved;
239
211
  }
240
212
  try {
241
- return await runStatus(target, { json: flagBool(parsed, 'json') === true });
213
+ return await runStatus(target, { json: flags.bool('json') === true });
242
214
  }
243
215
  catch (err) {
244
216
  printError(err instanceof Error ? err.message : String(err));
245
217
  return 1;
246
218
  }
247
- }
248
- if (cmd === 'verify') {
249
- const parsed = parseArgs(args.slice(1));
219
+ },
220
+ verify: async (args) => {
221
+ const flags = commandFlags('verify', parseArgs(args));
250
222
  try {
251
223
  return await runVerify({
252
- ucid: flagValue(parsed, 'ucid'),
253
- noSample: flagBool(parsed, 'sample') === false,
254
- timeoutMs: seconds(flagValue(parsed, 'timeout')),
255
- apiUrl: flagValue(parsed, 'api-url'),
256
- collectorUrl: flagValue(parsed, 'collector-url'),
257
- apiKey: flagValue(parsed, 'api-key'),
258
- json: flagBool(parsed, 'json') === true,
224
+ ucid: flags.value('ucid'),
225
+ noSample: flags.bool('sample') === false,
226
+ timeoutMs: seconds(flags.value('timeout')),
227
+ apiUrl: flags.value('api-url'),
228
+ collectorUrl: flags.value('collector-url'),
229
+ apiKey: flags.value('api-key'),
230
+ json: flags.bool('json') === true,
259
231
  });
260
232
  }
261
233
  catch (err) {
262
234
  return reportCommandError(err);
263
235
  }
264
- }
265
- if (cmd === 'install-hooks') {
266
- const parsed = parseArgs(args.slice(1));
236
+ },
237
+ 'install-hooks': async (args) => {
238
+ const flags = commandFlags('install-hooks', parseArgs(args));
239
+ let redactionPacks;
240
+ if (flags.has('redaction-packs')) {
241
+ try {
242
+ redactionPacks = parseRedactionPacks(flags.value('redaction-packs'));
243
+ }
244
+ catch (err) {
245
+ process.stderr.write(`mainwave-cli install-hooks: ${err instanceof Error ? err.message : String(err)}\n`);
246
+ return 1;
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
+ }
267
257
  const dir = await sessionConfigDir();
268
258
  return runInstallHooks(dir === undefined ? undefined : claudeCodeFor(dir), {
269
- quiet: flagBool(parsed, 'quiet') === true,
259
+ quiet: flags.bool('quiet') === true,
260
+ ...(redactionPacks === undefined ? {} : { redactionPacks }),
270
261
  });
271
- }
272
- if (cmd === 'setup') {
273
- const parsed = parseArgs(args.slice(1));
274
- const requested = parsed.positionals;
275
- const named = [];
276
- for (const name of requested) {
277
- const resolved = resolveAdapter(name);
278
- if (typeof resolved === 'number')
279
- return resolved;
280
- named.push(resolved);
281
- }
262
+ },
263
+ setup: async (args) => {
264
+ const parsed = parseArgs(args);
265
+ const flags = commandFlags('setup', parsed);
266
+ const named = resolveAdapters(parsed.positionals);
267
+ if (typeof named === 'number')
268
+ return named;
282
269
  try {
283
- if (flagBool(parsed, 'remove') === true) {
270
+ if (flags.bool('remove') === true) {
284
271
  if (named.length === 0) {
285
272
  throw new WizardAbort('--remove needs the tools to remove, e.g. `setup kiro-ide --remove`');
286
273
  }
287
274
  return await runRemove(named, {
288
- yes: flagBool(parsed, 'yes') === true,
289
- json: flagBool(parsed, 'json') === true,
275
+ yes: flags.bool('yes') === true,
276
+ json: flags.bool('json') === true,
290
277
  });
291
278
  }
292
279
  const opts = setupOptions(parsed);
@@ -304,16 +291,17 @@ export const main = async (argv) => {
304
291
  catch (err) {
305
292
  return reportCommandError(err);
306
293
  }
307
- }
308
- const adapter = resolveAdapter(args[1]);
309
- if (typeof adapter === 'number')
310
- return adapter;
311
- if (cmd === 'edit') {
312
- const flags = args.slice(2);
313
- const local = flags.includes('--local');
314
- const global = flags.includes('--global');
294
+ },
295
+ edit: async (args) => {
296
+ const adapter = resolveAdapter(args[0]);
297
+ if (typeof adapter === 'number')
298
+ return adapter;
299
+ const flags = commandFlags('edit', parseArgs(args.slice(1)));
315
300
  try {
316
- return await runEdit(adapter, { local, global });
301
+ return await runEdit(adapter, {
302
+ local: flags.bool('local') === true,
303
+ global: flags.bool('global') === true,
304
+ });
317
305
  }
318
306
  catch (err) {
319
307
  if (err instanceof WizardAbort) {
@@ -323,21 +311,27 @@ export const main = async (argv) => {
323
311
  printError(err instanceof Error ? err.message : String(err));
324
312
  return 1;
325
313
  }
326
- }
327
- if (cmd === 'doctor') {
328
- const parsed = parseArgs(args.slice(2));
314
+ },
315
+ doctor: async (args) => {
316
+ const adapter = resolveAdapter(args[0]);
317
+ if (typeof adapter === 'number')
318
+ return adapter;
319
+ const flags = commandFlags('doctor', parseArgs(args.slice(1)));
329
320
  try {
330
321
  return await runDoctor(adapter, {
331
- validate: flagBool(parsed, 'validate') === true,
332
- json: flagBool(parsed, 'json') === true,
322
+ validate: flags.bool('validate') === true,
323
+ json: flags.bool('json') === true,
333
324
  });
334
325
  }
335
326
  catch (err) {
336
327
  printError(err instanceof Error ? err.message : String(err));
337
328
  return 1;
338
329
  }
339
- }
340
- if (cmd === 'env') {
330
+ },
331
+ env: async (args) => {
332
+ const adapter = resolveAdapter(args[0]);
333
+ if (typeof adapter === 'number')
334
+ return adapter;
341
335
  try {
342
336
  return await runEnvCommand(adapter);
343
337
  }
@@ -345,7 +339,23 @@ export const main = async (argv) => {
345
339
  printError(err instanceof Error ? err.message : String(err));
346
340
  return 1;
347
341
  }
342
+ },
343
+ };
344
+ export const main = async (argv) => {
345
+ const args = argv.slice(2);
346
+ const cmd = args[0];
347
+ if (cmd === undefined || cmd === '--help' || cmd === '-h' || cmd === 'help') {
348
+ printHelp();
349
+ return 0;
348
350
  }
349
- printError(`unknown command: ${cmd}`);
350
- return 1;
351
+ if (cmd === '--version' || cmd === '-v') {
352
+ console.log(VERSION);
353
+ return 0;
354
+ }
355
+ if (!isCommand(cmd)) {
356
+ printError(`unknown command: ${cmd}`);
357
+ printHelp();
358
+ return 1;
359
+ }
360
+ return HANDLERS[cmd](args.slice(1));
351
361
  };