@mainwave/cli 0.8.0 → 0.10.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 (42) hide show
  1. package/README.md +169 -42
  2. package/dist/adapters/claude-code.js +23 -4
  3. package/dist/adapters/codex-cli.js +1 -1
  4. package/dist/adapters/cursor.js +4 -2
  5. package/dist/adapters/index.js +3 -0
  6. package/dist/adapters/kiro.js +361 -0
  7. package/dist/core/apply.js +161 -46
  8. package/dist/core/behaviour-hooks.js +7 -7
  9. package/dist/core/codecs/kiro-hooks-json.js +76 -0
  10. package/dist/core/doctor.js +27 -9
  11. package/dist/core/effective-settings.js +10 -0
  12. package/dist/core/entry-script.js +90 -0
  13. package/dist/core/git-bash.js +40 -0
  14. package/dist/core/install-hooks.js +126 -43
  15. package/dist/core/interview.js +114 -16
  16. package/dist/core/markers.js +678 -140
  17. package/dist/core/remove.js +67 -0
  18. package/dist/core/settings.js +32 -6
  19. package/dist/core/skills.js +47 -1
  20. package/dist/core/status.js +2 -1
  21. package/dist/core/wizard.js +64 -3
  22. package/dist/main.js +28 -9
  23. package/hooks/cursor-otlp.mjs +4 -27
  24. package/hooks/github-pr-marker.mjs +35 -22
  25. package/hooks/glab-mr-marker.mjs +795 -0
  26. package/hooks/jira-ticket-marker.mjs +27 -15
  27. package/hooks/kiro-otlp.mjs +570 -0
  28. package/hooks/linear-ticket-marker.mjs +27 -15
  29. package/hooks/mainwave-hook-node.mjs +42 -0
  30. package/hooks/mainwave-hook.mjs +301 -0
  31. package/hooks/marker-core.mjs +368 -41
  32. package/hooks/matchers.json +82 -6
  33. package/hooks/plan-snapshot.mjs +529 -0
  34. package/hooks/stop-failure.mjs +43 -0
  35. package/hooks/vocabulary.d.mts +49 -0
  36. package/hooks/vocabulary.mjs +188 -0
  37. package/package.json +5 -5
  38. package/skills/mainwave-instrument/SKILL.md +21 -7
  39. package/skills/mainwave-instrument/reference/api.md +29 -10
  40. package/skills/mainwave-instrument/reference/frameworks.md +3 -3
  41. package/skills/mainwave-instrument/reference/troubleshooting.md +12 -5
  42. package/skills/mainwave-setup/SKILL.md +47 -12
@@ -1,3 +1,4 @@
1
+ import { effectiveOptIns, managedSnapshotDelivery, planSnapshotBlocked } from './apply.js';
1
2
  import { WizardAbort } from './errors.js';
2
3
  import { color } from './format.js';
3
4
  import { nativeIdentityReason } from './effective-settings.js';
@@ -46,17 +47,50 @@ const resolveCollectorUrl = async (input) => {
46
47
  return fallback;
47
48
  return promptCollectorUrl(fallback);
48
49
  };
49
- const resolveIdentity = async (input, identityAdapters) => {
50
- if (input.overrides.userEmail)
51
- return input.overrides.userEmail;
50
+ const resolveIdentity = async (input, identityAdapters, toolEmail) => {
51
+ if (input.overrides.userEmail) {
52
+ return {
53
+ email: input.overrides.userEmail,
54
+ source: input.overrides.userEmailFromInvite ? 'invite' : 'flag',
55
+ };
56
+ }
52
57
  if (identityAdapters.length === 0)
53
- return undefined;
58
+ return {};
54
59
  if (input.session)
55
- return input.session.email;
56
- const fallback = input.prefill.userEmail ?? input.settings.email ?? detectGitEmail();
60
+ return { email: input.session.email, source: 'session' };
61
+ const onDisk = input.prefill.userEmail ?? input.settings.email;
62
+ const fallback = onDisk ?? detectGitEmail();
63
+ const source = onDisk !== undefined ? 'prefill' : fallback !== undefined ? 'git' : undefined;
64
+ if (toolEmail !== undefined && identityAdapters.every((a) => a.detectIdentityEmail)) {
65
+ return { email: fallback, source };
66
+ }
57
67
  if (!input.interactive)
58
- return fallback;
59
- return promptUserEmail(fallback);
68
+ return { email: fallback, source };
69
+ const typed = await promptUserEmail(fallback);
70
+ return { email: typed, source: typed === fallback ? source : 'prompt' };
71
+ };
72
+ const resolveAdapterEmails = async (input, identityAdapters, general, toolEmail) => {
73
+ const tools = identityAdapters.filter((a) => a.detectIdentityEmail);
74
+ if (tools.length === 0 || general.source === 'flag' || toolEmail === undefined)
75
+ return {};
76
+ let chosen = toolEmail;
77
+ const given = general.source === 'session' || general.source === 'invite' || general.source === 'prompt'
78
+ ? general.email
79
+ : undefined;
80
+ const sessionEmail = given;
81
+ if (sessionEmail !== undefined && sessionEmail.toLowerCase() !== toolEmail.toLowerCase()) {
82
+ const names = tools.map((a) => a.displayName).join(', ');
83
+ if (input.interactive) {
84
+ say(`${names} is signed in as ${toolEmail}; this run's email is ${sessionEmail}.`);
85
+ say(color.dim(` ${names} activity is matched to the tool's own usage export by this email, so it should be the tool's.`));
86
+ chosen = (await promptUserEmail(toolEmail)) ?? toolEmail;
87
+ }
88
+ else {
89
+ say(color.yellow(`${names}: stamping the tool's sign-in ${toolEmail}, not ${sessionEmail}, ` +
90
+ "so its activity matches the tool's own usage export. Pass --email to choose."));
91
+ }
92
+ }
93
+ return Object.fromEntries(tools.map((a) => [a.name, chosen]));
60
94
  };
61
95
  export const noIdentityWarning = (headerTools, nonOauth) => {
62
96
  const names = [
@@ -70,12 +104,44 @@ export const noIdentityWarning = (headerTools, nonOauth) => {
70
104
  ' Fix: re-run setup with `--email you@company.com`, or sign in first (`mainwave-cli login`).' +
71
105
  (nonOauth.length > 0 ? ' For Claude Code, signing in with a Claude account also fixes it.' : ''));
72
106
  };
73
- const resolveOptIns = (input) => input.overrides.optIns ?? { userPrompts: true, toolDetails: true, toolContent: true };
107
+ const resolveOptIns = (input) => input.overrides.optIns ?? {
108
+ userPrompts: true,
109
+ toolDetails: true,
110
+ toolContent: true,
111
+ repository: true,
112
+ };
74
113
  const resolveMarkers = (input, capable) => {
75
114
  if (input.overrides.markers !== undefined)
76
115
  return input.overrides.markers;
77
116
  return capable.length > 0;
78
117
  };
118
+ const sayPlanSnapshotNotice = (adapters, markers, blocked = new Map(), orgSends = []) => {
119
+ const hosts = adapters.filter((a) => a.markers?.planSnapshotDisclosure !== undefined);
120
+ if (hosts.length === 0)
121
+ return;
122
+ if (!markers) {
123
+ for (const a of hosts) {
124
+ say(orgSends.includes(a)
125
+ ? color.yellow(`Claude plan snapshot is ON for ${a.displayName}: --no-markers installs no Mainwave hooks, ` +
126
+ "but your organization's managed settings send it; only your Claude admin can remove it.")
127
+ : color.dim(`Claude plan snapshot is off for ${a.displayName}: --no-markers installs no Mainwave hooks.`));
128
+ }
129
+ return;
130
+ }
131
+ for (const a of hosts) {
132
+ const why = blocked.get(a);
133
+ if (why) {
134
+ say(color.yellow(`Claude plan snapshot can't run for ${a.displayName}: ${why.reason}. ` +
135
+ (why.notInstalled
136
+ ? 'Setup installs no Mainwave hooks there, so nothing is sent. '
137
+ : "Setup installs it in your user settings, but Claude Code won't run it there, so nothing is sent. ") +
138
+ why.fix));
139
+ continue;
140
+ }
141
+ say(color.yellow(`Claude plan snapshot is ON for ${a.displayName}. ${a.markers.planSnapshotDisclosure}\n` +
142
+ '`--no-markers` installs no Mainwave hooks, this included.'));
143
+ }
144
+ };
79
145
  const resolveUseCaseStep = async (input) => {
80
146
  const context = input.session ? { apiUrl: input.apiUrl, token: input.session.token } : undefined;
81
147
  const { useCase } = await resolveUseCase({
@@ -85,14 +151,24 @@ const resolveUseCaseStep = async (input) => {
85
151
  }, context);
86
152
  return useCase;
87
153
  };
88
- const sayCaptureNotice = (optIns, adapters) => {
154
+ const sayCaptureNotice = (optIns, adapters, explicit) => {
155
+ const withoutPrompts = adapters.filter((a) => !effectiveOptIns(a, optIns, explicit).userPrompts);
156
+ const promptsAnywhere = withoutPrompts.length < adapters.length && optIns.userPrompts;
89
157
  const on = [
90
- optIns.userPrompts ? 'prompt text' : undefined,
158
+ promptsAnywhere
159
+ ? withoutPrompts.length > 0
160
+ ? `prompt text (not for ${withoutPrompts.map((a) => a.displayName).join(', ')}, which ` +
161
+ 'keep it off unless `--opt-in prompts` is given)'
162
+ : 'prompt text'
163
+ : undefined,
91
164
  optIns.userPrompts && adapters.some((a) => a.name === 'claude-desktop')
92
165
  ? 'assistant responses'
93
166
  : undefined,
94
167
  optIns.toolDetails ? 'shell commands and file paths' : undefined,
95
168
  optIns.toolContent ? 'tool result bodies' : undefined,
169
+ optIns.repository && adapters.some((a) => a.name === 'claude-code')
170
+ ? 'repository names (Claude Code)'
171
+ : undefined,
96
172
  ].filter((s) => s !== undefined);
97
173
  const codex = adapters.some((a) => a.name === 'codex');
98
174
  const codexToolsOff = codex && !optIns.toolDetails && !optIns.toolContent;
@@ -102,7 +178,7 @@ const sayCaptureNotice = (optIns, adapters) => {
102
178
  else {
103
179
  say(color.yellow(`Content capture is ON: ${on.join(', ')} will be sent to your collector.\n` +
104
180
  'Turn it off with `--opt-in none`, or pick what you want with\n' +
105
- '`--opt-in prompts,tool-details,tool-content`.' +
181
+ '`--opt-in prompts,tool-details,tool-content,repository`.' +
106
182
  (codex
107
183
  ? '\nFor Codex, keep `--opt-in tool-details` at minimum — without it Codex\n' +
108
184
  'reports no tool names, success or approvals.'
@@ -120,19 +196,31 @@ export const runInterview = async (input) => {
120
196
  const collectorUrl = await resolveCollectorUrl(input);
121
197
  const useCase = await resolveUseCaseStep(input);
122
198
  const identityAdapters = input.adapters.filter((a) => a.injectsIdentity || a.stampsIdentityAttr);
123
- const userEmail = await resolveIdentity(input, identityAdapters);
199
+ const toolEmail = input.overrides.userEmail && !input.overrides.userEmailFromInvite
200
+ ? undefined
201
+ : identityAdapters.map((a) => a.detectIdentityEmail?.()).find((e) => e !== undefined);
202
+ const general = await resolveIdentity(input, identityAdapters, toolEmail);
203
+ const userEmail = general.email;
204
+ const adapterEmails = await resolveAdapterEmails(input, identityAdapters, general, toolEmail);
124
205
  if (!userEmail) {
125
206
  const nonOauth = (await Promise.all(identityAdapters
126
207
  .filter((a) => a.stampsIdentityAttr)
127
208
  .map(async (adapter) => ({ adapter, reason: await nativeIdentityReason(adapter) })))).filter((x) => x.reason !== undefined);
128
- const warning = noIdentityWarning(identityAdapters.filter((a) => a.injectsIdentity), nonOauth);
209
+ const warning = noIdentityWarning(identityAdapters.filter((a) => a.injectsIdentity && adapterEmails[a.name] === undefined), nonOauth);
129
210
  if (warning)
130
211
  say(color.yellow(warning));
131
212
  }
132
213
  const optIns = resolveOptIns(input);
133
- sayCaptureNotice(optIns, input.adapters);
214
+ sayCaptureNotice(optIns, input.adapters, input.overrides.optIns !== undefined);
134
215
  const capable = input.adapters.filter((a) => a.markers);
135
216
  const markers = resolveMarkers(input, capable);
217
+ const blocked = new Map(markers
218
+ ? (await Promise.all(input.adapters.map(async (a) => [a, await planSnapshotBlocked(a)]))).flatMap(([a, why]) => (why ? [[a, why]] : []))
219
+ : []);
220
+ const orgSends = markers
221
+ ? []
222
+ : (await Promise.all(input.adapters.map(async (a) => [a, await managedSnapshotDelivery(a)]))).flatMap(([a, sends]) => (sends ? [a] : []));
223
+ sayPlanSnapshotNotice(input.adapters, markers, blocked, orgSends);
136
224
  const markerless = input.adapters.filter((a) => !a.markers);
137
225
  if (markerless.length > 0) {
138
226
  say(color.dim(`Ticket & PR markers aren't available for ${markerless
@@ -141,7 +229,17 @@ export const runInterview = async (input) => {
141
229
  'mechanism the CLI can attach to, so "tickets filed" / "PRs created" stay empty.'));
142
230
  }
143
231
  return {
144
- answers: { apiKey, collectorUrl, ucid: useCase?.id, optIns, userEmail, markers },
232
+ answers: {
233
+ apiKey,
234
+ collectorUrl,
235
+ ucid: useCase?.id,
236
+ optIns,
237
+ userEmail,
238
+ userEmailSource: general.source,
239
+ adapterEmails,
240
+ optInsExplicit: input.overrides.optIns !== undefined,
241
+ markers,
242
+ },
145
243
  useCase,
146
244
  };
147
245
  };