@mainwave/cli 0.9.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.
- package/README.md +32 -1
- package/dist/adapters/cursor.js +2 -0
- package/dist/adapters/index.js +3 -0
- package/dist/adapters/kiro.js +361 -0
- package/dist/core/apply.js +10 -5
- package/dist/core/behaviour-hooks.js +7 -7
- package/dist/core/codecs/kiro-hooks-json.js +76 -0
- package/dist/core/doctor.js +1 -1
- package/dist/core/interview.js +62 -14
- package/dist/core/remove.js +67 -0
- package/dist/core/settings.js +17 -2
- package/dist/core/skills.js +47 -1
- package/dist/core/wizard.js +18 -2
- package/dist/main.js +12 -0
- package/hooks/cursor-otlp.mjs +3 -26
- package/hooks/kiro-otlp.mjs +570 -0
- package/hooks/marker-core.mjs +95 -1
- package/hooks/vocabulary.d.mts +1 -0
- package/hooks/vocabulary.mjs +7 -0
- package/package.json +1 -1
package/dist/core/interview.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { managedSnapshotDelivery, planSnapshotBlocked } from './apply.js';
|
|
1
|
+
import { effectiveOptIns, managedSnapshotDelivery, planSnapshotBlocked } from './apply.js';
|
|
2
2
|
import { WizardAbort } from './errors.js';
|
|
3
3
|
import { color } from './format.js';
|
|
4
4
|
import { nativeIdentityReason } from './effective-settings.js';
|
|
@@ -47,17 +47,50 @@ const resolveCollectorUrl = async (input) => {
|
|
|
47
47
|
return fallback;
|
|
48
48
|
return promptCollectorUrl(fallback);
|
|
49
49
|
};
|
|
50
|
-
const resolveIdentity = async (input, identityAdapters) => {
|
|
51
|
-
if (input.overrides.userEmail)
|
|
52
|
-
return
|
|
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
|
+
}
|
|
53
57
|
if (identityAdapters.length === 0)
|
|
54
|
-
return
|
|
58
|
+
return {};
|
|
55
59
|
if (input.session)
|
|
56
|
-
return input.session.email;
|
|
57
|
-
const
|
|
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
|
+
}
|
|
58
67
|
if (!input.interactive)
|
|
59
|
-
return fallback;
|
|
60
|
-
|
|
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]));
|
|
61
94
|
};
|
|
62
95
|
export const noIdentityWarning = (headerTools, nonOauth) => {
|
|
63
96
|
const names = [
|
|
@@ -118,9 +151,16 @@ const resolveUseCaseStep = async (input) => {
|
|
|
118
151
|
}, context);
|
|
119
152
|
return useCase;
|
|
120
153
|
};
|
|
121
|
-
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;
|
|
122
157
|
const on = [
|
|
123
|
-
|
|
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,
|
|
124
164
|
optIns.userPrompts && adapters.some((a) => a.name === 'claude-desktop')
|
|
125
165
|
? 'assistant responses'
|
|
126
166
|
: undefined,
|
|
@@ -156,17 +196,22 @@ export const runInterview = async (input) => {
|
|
|
156
196
|
const collectorUrl = await resolveCollectorUrl(input);
|
|
157
197
|
const useCase = await resolveUseCaseStep(input);
|
|
158
198
|
const identityAdapters = input.adapters.filter((a) => a.injectsIdentity || a.stampsIdentityAttr);
|
|
159
|
-
const
|
|
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);
|
|
160
205
|
if (!userEmail) {
|
|
161
206
|
const nonOauth = (await Promise.all(identityAdapters
|
|
162
207
|
.filter((a) => a.stampsIdentityAttr)
|
|
163
208
|
.map(async (adapter) => ({ adapter, reason: await nativeIdentityReason(adapter) })))).filter((x) => x.reason !== undefined);
|
|
164
|
-
const warning = noIdentityWarning(identityAdapters.filter((a) => a.injectsIdentity), nonOauth);
|
|
209
|
+
const warning = noIdentityWarning(identityAdapters.filter((a) => a.injectsIdentity && adapterEmails[a.name] === undefined), nonOauth);
|
|
165
210
|
if (warning)
|
|
166
211
|
say(color.yellow(warning));
|
|
167
212
|
}
|
|
168
213
|
const optIns = resolveOptIns(input);
|
|
169
|
-
sayCaptureNotice(optIns, input.adapters);
|
|
214
|
+
sayCaptureNotice(optIns, input.adapters, input.overrides.optIns !== undefined);
|
|
170
215
|
const capable = input.adapters.filter((a) => a.markers);
|
|
171
216
|
const markers = resolveMarkers(input, capable);
|
|
172
217
|
const blocked = new Map(markers
|
|
@@ -190,6 +235,9 @@ export const runInterview = async (input) => {
|
|
|
190
235
|
ucid: useCase?.id,
|
|
191
236
|
optIns,
|
|
192
237
|
userEmail,
|
|
238
|
+
userEmailSource: general.source,
|
|
239
|
+
adapterEmails,
|
|
240
|
+
optInsExplicit: input.overrides.optIns !== undefined,
|
|
193
241
|
markers,
|
|
194
242
|
},
|
|
195
243
|
useCase,
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { WizardAbort } from './errors.js';
|
|
2
|
+
import { color } from './format.js';
|
|
3
|
+
import { promptConfirmWrite } from './prompts.js';
|
|
4
|
+
import { applyUpdate, removeSettingsFile } from './settings.js';
|
|
5
|
+
import { isInteractive } from './tty.js';
|
|
6
|
+
import { emitJson, say, setJsonMode } from './ui.js';
|
|
7
|
+
export const runRemove = async (adapters, options = {}) => {
|
|
8
|
+
setJsonMode(options.json === true);
|
|
9
|
+
const unsupported = adapters.filter((a) => !a.removal);
|
|
10
|
+
if (unsupported.length > 0) {
|
|
11
|
+
throw new WizardAbort(`--remove isn't available for ${unsupported.map((a) => a.name).join(', ')}`);
|
|
12
|
+
}
|
|
13
|
+
say(color.bold(`mainwave-cli — remove ${adapters.map((a) => a.displayName).join(', ')}`));
|
|
14
|
+
const groups = new Map();
|
|
15
|
+
for (const a of adapters)
|
|
16
|
+
groups.set(a.removal.group, [...(groups.get(a.removal.group) ?? []), a]);
|
|
17
|
+
const steps = [];
|
|
18
|
+
for (const members of groups.values()) {
|
|
19
|
+
steps.push(...(await members[0].removal.plan(members.map((a) => a.name))));
|
|
20
|
+
}
|
|
21
|
+
const notes = steps.filter((s) => s.kind === 'note');
|
|
22
|
+
const actions = steps.filter((s) => s.kind !== 'note');
|
|
23
|
+
for (const n of notes)
|
|
24
|
+
say(color.dim(n.note));
|
|
25
|
+
if (actions.length === 0) {
|
|
26
|
+
if (notes.length === 0) {
|
|
27
|
+
say(color.dim('Nothing to remove: no Mainwave config for these tools is on disk.'));
|
|
28
|
+
}
|
|
29
|
+
if (options.json)
|
|
30
|
+
emitJson({ status: 'nothing-to-remove', tools: adapters.map((a) => a.name) });
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
33
|
+
say('');
|
|
34
|
+
for (const step of actions)
|
|
35
|
+
say(` ${step.kind === 'delete' ? '-' : '~'} ${step.note}`);
|
|
36
|
+
if (!options.yes) {
|
|
37
|
+
if (!isInteractive())
|
|
38
|
+
throw new WizardAbort('refusing to remove without confirmation — pass --yes');
|
|
39
|
+
say('');
|
|
40
|
+
if (!(await promptConfirmWrite()))
|
|
41
|
+
throw new WizardAbort();
|
|
42
|
+
}
|
|
43
|
+
const done = [];
|
|
44
|
+
for (const step of actions) {
|
|
45
|
+
if (step.kind === 'update') {
|
|
46
|
+
const result = await applyUpdate(step.update);
|
|
47
|
+
done.push({ path: result.written, action: 'updated', backup: result.backupPath });
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
done.push({
|
|
51
|
+
path: step.path,
|
|
52
|
+
action: 'deleted',
|
|
53
|
+
backup: await removeSettingsFile(step.path, { backup: step.backup !== false }),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
say('');
|
|
58
|
+
for (const d of done) {
|
|
59
|
+
say(color.green(`✓ ${d.action === 'deleted' ? 'Removed' : 'Updated'} ${d.path}`));
|
|
60
|
+
if (d.backup)
|
|
61
|
+
say(color.dim(` backup: ${d.backup}`));
|
|
62
|
+
}
|
|
63
|
+
say(color.dim('Restart open sessions of these tools so they stop loading the hooks.'));
|
|
64
|
+
if (options.json)
|
|
65
|
+
emitJson({ status: 'removed', tools: adapters.map((a) => a.name), files: done });
|
|
66
|
+
return 0;
|
|
67
|
+
};
|
package/dist/core/settings.js
CHANGED
|
@@ -81,8 +81,23 @@ export const prepareUpdate = async (args) => {
|
|
|
81
81
|
const diff = diffEnv(baseEnv, newEnv, managedKeys);
|
|
82
82
|
return { path, exists, codec, next, diff, mode };
|
|
83
83
|
};
|
|
84
|
+
export const removeSettingsFile = async (path, { backup = true } = {}) => {
|
|
85
|
+
let body;
|
|
86
|
+
try {
|
|
87
|
+
body = await fs.readFile(path);
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
if (isErrnoCode(err, 'ENOENT'))
|
|
91
|
+
return null;
|
|
92
|
+
throw err;
|
|
93
|
+
}
|
|
94
|
+
const mode = (await fs.stat(path)).mode & 0o777;
|
|
95
|
+
const backupPath = backup ? await writeBackup(path, body, mode) : null;
|
|
96
|
+
await fs.rm(path, { force: true });
|
|
97
|
+
return backupPath;
|
|
98
|
+
};
|
|
84
99
|
export const applyUpdate = async (update) => {
|
|
85
|
-
const { path, exists, next, codec, mode } = update;
|
|
100
|
+
const { path, exists, next, codec, mode, backup = true } = update;
|
|
86
101
|
const fileMode = mode ?? 0o600;
|
|
87
102
|
await fs.mkdir(dirname(path), { recursive: true });
|
|
88
103
|
const target = exists ? await fs.realpath(path).catch(() => path) : path;
|
|
@@ -91,7 +106,7 @@ export const applyUpdate = async (update) => {
|
|
|
91
106
|
let backupPath = null;
|
|
92
107
|
try {
|
|
93
108
|
await fs.access(dirname(target), fsConstants.W_OK);
|
|
94
|
-
if (exists)
|
|
109
|
+
if (exists && backup)
|
|
95
110
|
backupPath = await writeBackup(path, await fs.readFile(path), fileMode);
|
|
96
111
|
try {
|
|
97
112
|
await fs.rename(tmpPath, target);
|
package/dist/core/skills.js
CHANGED
|
@@ -2,6 +2,7 @@ import { promises as fs } from 'node:fs';
|
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { isErrnoCode } from './settings.js';
|
|
5
6
|
export const BLOCK_OPEN = '<!-- mainwave:skills managed-by @mainwave/cli';
|
|
6
7
|
export const BLOCK_CLOSE = '<!-- /mainwave:skills -->';
|
|
7
8
|
export const SKILL_NAMES = [
|
|
@@ -56,7 +57,7 @@ export const renderBlock = (version, skillsDir, names = SKILL_NAMES) => {
|
|
|
56
57
|
];
|
|
57
58
|
return lines.join('\n');
|
|
58
59
|
};
|
|
59
|
-
const isBlockOpen = (line) => line.startsWith(BLOCK_OPEN);
|
|
60
|
+
export const isBlockOpen = (line) => line.startsWith(BLOCK_OPEN);
|
|
60
61
|
export const installedBlockVersion = (body) => {
|
|
61
62
|
for (const line of body.split('\n')) {
|
|
62
63
|
if (!isBlockOpen(line))
|
|
@@ -86,6 +87,51 @@ export const applyBlock = (existing, block) => {
|
|
|
86
87
|
const kept = stripBlocks(existing).replace(/\s+$/, '');
|
|
87
88
|
return kept.length === 0 ? `${block}\n` : `${kept}\n\n${block}\n`;
|
|
88
89
|
};
|
|
90
|
+
const textCodec = {
|
|
91
|
+
format: 'text',
|
|
92
|
+
parse: (body) => body,
|
|
93
|
+
serialize: (doc) => String(doc),
|
|
94
|
+
empty: () => '',
|
|
95
|
+
readEnv: () => ({}),
|
|
96
|
+
applyEnv: (doc) => doc,
|
|
97
|
+
};
|
|
98
|
+
export const planBlockRemoval = async (path) => {
|
|
99
|
+
let body;
|
|
100
|
+
try {
|
|
101
|
+
body = await fs.readFile(path, 'utf8');
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
if (isErrnoCode(err, 'ENOENT'))
|
|
105
|
+
return undefined;
|
|
106
|
+
throw err;
|
|
107
|
+
}
|
|
108
|
+
if (!body.split('\n').some(isBlockOpen))
|
|
109
|
+
return undefined;
|
|
110
|
+
const kept = stripBlocks(body)
|
|
111
|
+
.replace(/^(?:[ \t]*\r?\n)+/, '')
|
|
112
|
+
.replace(/\s+$/, '');
|
|
113
|
+
if (kept.length === 0) {
|
|
114
|
+
return {
|
|
115
|
+
kind: 'delete',
|
|
116
|
+
path,
|
|
117
|
+
backup: false,
|
|
118
|
+
note: `${path}: delete (only Mainwave's instructions in it)`,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
kind: 'update',
|
|
123
|
+
update: {
|
|
124
|
+
path,
|
|
125
|
+
exists: true,
|
|
126
|
+
codec: textCodec,
|
|
127
|
+
next: `${kept}${body.includes('\r\n') ? '\r\n' : '\n'}`,
|
|
128
|
+
diff: { added: [], changed: [], removed: [], unchanged: 0 },
|
|
129
|
+
mode: (await fs.stat(path)).mode & 0o777,
|
|
130
|
+
backup: false,
|
|
131
|
+
},
|
|
132
|
+
note: `${path}: remove Mainwave's instructions, keep the rest`,
|
|
133
|
+
};
|
|
134
|
+
};
|
|
89
135
|
export const installToSurface = async (adapterName, surface, scope, version, srcRoot = packagedSkillsDir(), installedRoot = installedSkillsDir(), names = SKILL_NAMES) => {
|
|
90
136
|
const target = scope === 'local' ? surface.local : surface.global;
|
|
91
137
|
if (surface.kind === 'skill-dir') {
|
package/dist/core/wizard.js
CHANGED
|
@@ -109,6 +109,10 @@ export const ucidRemovalNotice = (plan, onDisk) => onDisk !== undefined && plan.
|
|
|
109
109
|
? `${plan.adapter.displayName}: removing UCID ${onDisk} an earlier setup wrote; activity will ` +
|
|
110
110
|
`now be attributed from your identity. Pass --ucid ${onDisk} to keep it.`
|
|
111
111
|
: null;
|
|
112
|
+
export const ucidIgnoredNotice = (adapter, explicitUcid) => adapter.carriesNoUcid && explicitUcid !== undefined
|
|
113
|
+
? `${adapter.displayName}: its hooks send no use-case id, so --ucid / --use-case don't apply; ` +
|
|
114
|
+
'its activity is attributed from your email.'
|
|
115
|
+
: null;
|
|
112
116
|
export const teamUcidNotice = (plan) => {
|
|
113
117
|
const decision = plan.teamUcid;
|
|
114
118
|
if (!decision)
|
|
@@ -230,6 +234,7 @@ export const redeemInviteToOverrides = async (token, apiUrl, options) => {
|
|
|
230
234
|
rememberKeyAs: creds.key_label,
|
|
231
235
|
collectorUrl: creds.collector_url,
|
|
232
236
|
userEmail: creds.email,
|
|
237
|
+
userEmailFromInvite: true,
|
|
233
238
|
};
|
|
234
239
|
};
|
|
235
240
|
export const runSetup = async (adapters, rawOptions = {}) => {
|
|
@@ -282,6 +287,7 @@ export const runSetup = async (adapters, rawOptions = {}) => {
|
|
|
282
287
|
onDisk: prefills[i]?.values,
|
|
283
288
|
storedUseCase: settings.useCase,
|
|
284
289
|
unpin: options.skipUseCase === true,
|
|
290
|
+
pass: adapters.map((a) => a.name),
|
|
285
291
|
})));
|
|
286
292
|
for (const plan of plans)
|
|
287
293
|
renderPlan(plan);
|
|
@@ -292,6 +298,11 @@ export const runSetup = async (adapters, rawOptions = {}) => {
|
|
|
292
298
|
say('');
|
|
293
299
|
say(color.yellow(note));
|
|
294
300
|
}
|
|
301
|
+
const ignored = ucidIgnoredNotice(plan.adapter, answers.ucid);
|
|
302
|
+
if (ignored) {
|
|
303
|
+
say('');
|
|
304
|
+
say(color.yellow(ignored));
|
|
305
|
+
}
|
|
295
306
|
const team = teamUcidNotice(plan);
|
|
296
307
|
if (team) {
|
|
297
308
|
say('');
|
|
@@ -323,7 +334,9 @@ export const runSetup = async (adapters, rawOptions = {}) => {
|
|
|
323
334
|
createdAt: new Date().toISOString(),
|
|
324
335
|
});
|
|
325
336
|
}
|
|
326
|
-
const developerPin = useCase && adapters.some((a) => !a.teamUcid
|
|
337
|
+
const developerPin = useCase && adapters.some((a) => !a.teamUcid && !a.carriesNoUcid)
|
|
338
|
+
? { ...useCase, pinned: true }
|
|
339
|
+
: undefined;
|
|
327
340
|
const markerTools = plans.filter((p) => p.markersOn !== null);
|
|
328
341
|
const hooks = { ...settings.hooks };
|
|
329
342
|
if (markerTools.length > 0) {
|
|
@@ -350,7 +363,9 @@ export const runSetup = async (adapters, rawOptions = {}) => {
|
|
|
350
363
|
orgId: identity.orgId ?? settings.orgId,
|
|
351
364
|
useCase: options.skipUseCase ? null : developerPin,
|
|
352
365
|
});
|
|
353
|
-
const passPin =
|
|
366
|
+
const passPin = adapters.some((a) => !a.carriesNoUcid)
|
|
367
|
+
? (useCase ?? plans.find((p) => p.keptPin)?.keptPin)
|
|
368
|
+
: undefined;
|
|
354
369
|
for (const plan of plans) {
|
|
355
370
|
if (plan.markersOn !== null) {
|
|
356
371
|
await printMarkerCoexistenceNotes(plan.adapter, plan.primaryPath, plan.markersOn);
|
|
@@ -388,6 +403,7 @@ export const runSetup = async (adapters, rawOptions = {}) => {
|
|
|
388
403
|
}, p.adapter),
|
|
389
404
|
]))),
|
|
390
405
|
optIns: answers.optIns,
|
|
406
|
+
optInsByTool: Object.fromEntries(plans.map((p) => [p.adapter.name, p.input.optIns])),
|
|
391
407
|
markers: answers.markers,
|
|
392
408
|
...planSnapshotReport(plans, await blockedSnapshots(plans)),
|
|
393
409
|
verified,
|
package/dist/main.js
CHANGED
|
@@ -13,6 +13,7 @@ import { runStatus } from './core/status.js';
|
|
|
13
13
|
import { ensureTty, isInteractive } from './core/tty.js';
|
|
14
14
|
import { VERSION } from './core/version.js';
|
|
15
15
|
import { runVerify } from './core/verify.js';
|
|
16
|
+
import { runRemove } from './core/remove.js';
|
|
16
17
|
import { runSetup, runSkillsOnly } from './core/wizard.js';
|
|
17
18
|
export { VERSION };
|
|
18
19
|
const printHelp = () => {
|
|
@@ -71,6 +72,8 @@ Setup flags (every prompt has one, so scripts and coding agents can drive it):
|
|
|
71
72
|
--yes --json --no-verify --verify-timeout <seconds>
|
|
72
73
|
--skills / --no-skills install the agent skills payload (default: ask, or on in scripts)
|
|
73
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)
|
|
74
77
|
mainwave-cli --version print version
|
|
75
78
|
|
|
76
79
|
Available adapters:
|
|
@@ -277,6 +280,15 @@ export const main = async (argv) => {
|
|
|
277
280
|
named.push(resolved);
|
|
278
281
|
}
|
|
279
282
|
try {
|
|
283
|
+
if (flagBool(parsed, 'remove') === true) {
|
|
284
|
+
if (named.length === 0) {
|
|
285
|
+
throw new WizardAbort('--remove needs the tools to remove, e.g. `setup kiro-ide --remove`');
|
|
286
|
+
}
|
|
287
|
+
return await runRemove(named, {
|
|
288
|
+
yes: flagBool(parsed, 'yes') === true,
|
|
289
|
+
json: flagBool(parsed, 'json') === true,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
280
292
|
const opts = setupOptions(parsed);
|
|
281
293
|
const targets = named.length > 0
|
|
282
294
|
? named
|
package/hooks/cursor-otlp.mjs
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
buildMarkerPayload,
|
|
34
34
|
emitMarker,
|
|
35
35
|
markerLog,
|
|
36
|
+
parseEnvFile,
|
|
36
37
|
parseKv,
|
|
37
38
|
readStdin,
|
|
38
39
|
} from './marker-core.mjs'
|
|
@@ -51,32 +52,8 @@ const SERVICE_NAME = 'cursor'
|
|
|
51
52
|
// Config resolution — the managed env file this script's OTLP target lives in.
|
|
52
53
|
// ---------------------------------------------------------------------------
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const v = raw.trim()
|
|
57
|
-
if (v.startsWith('"') && v.endsWith('"') && v.length >= 2) {
|
|
58
|
-
return v.slice(1, -1).replace(/\\n/g, '\n').replace(/\\"/g, '"').replace(/\\\\/g, '\\')
|
|
59
|
-
}
|
|
60
|
-
if (v.startsWith("'") && v.endsWith("'") && v.length >= 2) return v.slice(1, -1)
|
|
61
|
-
return v
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** Parse a `KEY="value"` env file into a flat record; {} on any error. */
|
|
65
|
-
export const parseEnvFile = (text) => {
|
|
66
|
-
const out = {}
|
|
67
|
-
for (const line of (text ?? '').split('\n')) {
|
|
68
|
-
const trimmed = line.trim()
|
|
69
|
-
if (trimmed === '' || trimmed.startsWith('#')) continue
|
|
70
|
-
let rest = trimmed
|
|
71
|
-
if (rest.startsWith('export ')) rest = rest.slice('export '.length).trimStart()
|
|
72
|
-
const eq = rest.indexOf('=')
|
|
73
|
-
if (eq < 0) continue
|
|
74
|
-
const key = rest.slice(0, eq).trim()
|
|
75
|
-
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) continue
|
|
76
|
-
out[key] = unquote(rest.slice(eq + 1))
|
|
77
|
-
}
|
|
78
|
-
return out
|
|
79
|
-
}
|
|
55
|
+
// Re-exported: the parse moved to marker-core.mjs so the Kiro hook shares it.
|
|
56
|
+
export { parseEnvFile }
|
|
80
57
|
|
|
81
58
|
const readFileSafe = (path) => {
|
|
82
59
|
try {
|