@mainwave/cli 0.7.0 → 0.8.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 +10 -4
- package/dist/adapters/claude-code.js +10 -3
- package/dist/adapters/claude-desktop.js +0 -1
- package/dist/adapters/codex-cli.js +0 -1
- package/dist/adapters/copilot-chat.js +0 -1
- package/dist/adapters/copilot-cli.js +0 -1
- package/dist/adapters/cursor-enterprise.js +0 -1
- package/dist/adapters/cursor.js +13 -2
- package/dist/adapters/index.js +0 -1
- package/dist/adapters/types.js +0 -1
- package/dist/api/index.js +0 -1
- package/dist/api/types.gen.js +0 -1
- package/dist/cli.js +0 -1
- package/dist/core/apply.js +0 -1
- package/dist/core/auth-commands.js +0 -1
- package/dist/core/behaviour-hooks.js +0 -1
- package/dist/core/browser.js +0 -1
- package/dist/core/codecs/cursor-hooks-json.js +0 -1
- package/dist/core/codecs/env-file.js +0 -1
- package/dist/core/codecs/json-env.js +0 -1
- package/dist/core/codecs/json-flat.js +0 -1
- package/dist/core/codecs/json-managed.js +0 -1
- package/dist/core/codecs/toml-otel.js +0 -1
- package/dist/core/codecs/types.js +0 -1
- package/dist/core/detect.js +0 -1
- package/dist/core/device-login.js +0 -1
- package/dist/core/doctor.js +19 -1
- package/dist/core/edit.js +9 -5
- package/dist/core/effective-settings.js +61 -20
- package/dist/core/env-command.js +0 -1
- package/dist/core/errors.js +0 -1
- package/dist/core/flags.js +0 -1
- package/dist/core/format.js +0 -1
- package/dist/core/git.js +0 -1
- package/dist/core/headers.js +0 -1
- package/dist/core/install-hooks.js +6 -6
- package/dist/core/interview.js +0 -1
- package/dist/core/keys.js +0 -1
- package/dist/core/layer-policy.js +2 -1
- package/dist/core/markers.js +173 -17
- package/dist/core/pinned-use-case.js +0 -1
- package/dist/core/platform.js +0 -1
- package/dist/core/post-setup.js +0 -1
- package/dist/core/prompts.js +0 -1
- package/dist/core/settings.js +16 -3
- package/dist/core/skills.js +5 -2
- package/dist/core/status.js +5 -4
- package/dist/core/store.js +0 -1
- package/dist/core/tty.js +0 -1
- package/dist/core/ucid.js +0 -1
- package/dist/core/ui.js +0 -1
- package/dist/core/use-case.js +0 -1
- package/dist/core/validate.js +0 -1
- package/dist/core/verify.js +0 -1
- package/dist/core/version.js +0 -1
- package/dist/core/wizard.js +3 -7
- package/dist/main.js +0 -1
- package/hooks/cursor-otlp.mjs +13 -15
- package/hooks/github-pr-marker.mjs +22 -11
- package/hooks/jira-ticket-marker.mjs +9 -9
- package/hooks/linear-ticket-marker.mjs +9 -7
- package/hooks/managed-entry.mjs +42 -0
- package/hooks/marker-core.mjs +123 -29
- package/package.json +4 -3
- package/skills/mainwave-instrument-node/SKILL.md +420 -0
- package/skills/mainwave-instrument-node/reference/api.md +96 -0
- package/skills/mainwave-instrument-node/reference/frameworks.md +82 -0
- package/skills/mainwave-instrument-node/reference/troubleshooting.md +152 -0
- package/dist/adapters/claude-code.js.map +0 -1
- package/dist/adapters/claude-desktop.js.map +0 -1
- package/dist/adapters/codex-cli.js.map +0 -1
- package/dist/adapters/copilot-chat.js.map +0 -1
- package/dist/adapters/copilot-cli.js.map +0 -1
- package/dist/adapters/cursor-enterprise.js.map +0 -1
- package/dist/adapters/cursor.js.map +0 -1
- package/dist/adapters/index.js.map +0 -1
- package/dist/adapters/types.js.map +0 -1
- package/dist/api/index.js.map +0 -1
- package/dist/api/types.gen.js.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/core/apply.js.map +0 -1
- package/dist/core/auth-commands.js.map +0 -1
- package/dist/core/behaviour-hooks.js.map +0 -1
- package/dist/core/browser.js.map +0 -1
- package/dist/core/codecs/cursor-hooks-json.js.map +0 -1
- package/dist/core/codecs/env-file.js.map +0 -1
- package/dist/core/codecs/json-env.js.map +0 -1
- package/dist/core/codecs/json-flat.js.map +0 -1
- package/dist/core/codecs/json-managed.js.map +0 -1
- package/dist/core/codecs/toml-otel.js.map +0 -1
- package/dist/core/codecs/types.js.map +0 -1
- package/dist/core/detect.js.map +0 -1
- package/dist/core/device-login.js.map +0 -1
- package/dist/core/doctor.js.map +0 -1
- package/dist/core/edit.js.map +0 -1
- package/dist/core/effective-settings.js.map +0 -1
- package/dist/core/env-command.js.map +0 -1
- package/dist/core/errors.js.map +0 -1
- package/dist/core/flags.js.map +0 -1
- package/dist/core/format.js.map +0 -1
- package/dist/core/git.js.map +0 -1
- package/dist/core/headers.js.map +0 -1
- package/dist/core/install-hooks.js.map +0 -1
- package/dist/core/interview.js.map +0 -1
- package/dist/core/keys.js.map +0 -1
- package/dist/core/layer-policy.js.map +0 -1
- package/dist/core/markers.js.map +0 -1
- package/dist/core/pinned-use-case.js.map +0 -1
- package/dist/core/platform.js.map +0 -1
- package/dist/core/post-setup.js.map +0 -1
- package/dist/core/prompts.js.map +0 -1
- package/dist/core/settings.js.map +0 -1
- package/dist/core/skills.js.map +0 -1
- package/dist/core/status.js.map +0 -1
- package/dist/core/store.js.map +0 -1
- package/dist/core/tty.js.map +0 -1
- package/dist/core/ucid.js.map +0 -1
- package/dist/core/ui.js.map +0 -1
- package/dist/core/use-case.js.map +0 -1
- package/dist/core/validate.js.map +0 -1
- package/dist/core/verify.js.map +0 -1
- package/dist/core/version.js.map +0 -1
- package/dist/core/wizard.js.map +0 -1
- package/dist/main.js.map +0 -1
package/dist/core/markers.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
1
2
|
import { existsSync, promises as fs } from 'node:fs';
|
|
2
3
|
import { homedir } from 'node:os';
|
|
3
|
-
import { basename, join, resolve } from 'node:path';
|
|
4
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
4
5
|
import { fileURLToPath } from 'node:url';
|
|
5
6
|
import { dropInNames } from './effective-settings.js';
|
|
6
|
-
import { isManagedLayer } from './layer-policy.js';
|
|
7
|
+
import { isManagedLayer, isPolicyKey } from './layer-policy.js';
|
|
7
8
|
export const MANAGED_BY = '--managed-by @mainwave/cli';
|
|
9
|
+
export const PAYLOAD_CLI_SPEC = 'latest';
|
|
8
10
|
const OWNED_CLI_MARKERS = [MANAGED_BY, '.mainwave/hooks', '.mainwave\\hooks'];
|
|
9
11
|
const OWNED_INTERNAL_MARKERS = [
|
|
10
12
|
'clients/cli/hooks',
|
|
@@ -60,21 +62,167 @@ export const copyHookScripts = async (files, srcDir = packagedHooksDir(), destDi
|
|
|
60
62
|
}
|
|
61
63
|
return destDir;
|
|
62
64
|
};
|
|
63
|
-
export const
|
|
64
|
-
|
|
65
|
+
export const MANAGED_POINTER = 'current.json';
|
|
66
|
+
export const MANAGED_VERSIONS_DIR = 'versions';
|
|
67
|
+
export const MANAGED_ENTRY_SCRIPT = 'managed-entry.mjs';
|
|
68
|
+
const MANAGED_ENTRY_MARK = 'mainwave managed hook entry';
|
|
69
|
+
const RETIRED_GRACE_MS = 10 * 60 * 1000;
|
|
70
|
+
const VERSION_DIR_RE = /^[A-Za-z0-9][A-Za-z0-9._+-]*$/;
|
|
71
|
+
const versionDirName = (version, files, bodies) => {
|
|
72
|
+
const hash = createHash('sha256');
|
|
73
|
+
files.forEach((f, i) => hash.update(f).update('\0').update(bodies[i]).update('\0'));
|
|
74
|
+
const safe = version.replace(/[^A-Za-z0-9._+-]/g, '_').replace(/^[^A-Za-z0-9]+/, '');
|
|
75
|
+
return `${safe || 'v'}-${hash.digest('hex').slice(0, 12)}`;
|
|
76
|
+
};
|
|
77
|
+
const holdsFiles = async (dir, files, bodies) => {
|
|
78
|
+
for (const [i, f] of files.entries()) {
|
|
79
|
+
const current = await fs.readFile(join(dir, f)).catch(() => null);
|
|
80
|
+
if (current === null || !current.equals(bodies[i]))
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
};
|
|
85
|
+
const writeAtomic = async (path, body, mode = 0o644) => {
|
|
86
|
+
const tmp = `${path}.tmp.${process.pid}.${Math.random().toString(36).slice(2)}`;
|
|
87
|
+
await fs.writeFile(tmp, body, { mode });
|
|
88
|
+
await fs.rename(tmp, path);
|
|
89
|
+
};
|
|
90
|
+
export const readManagedPointer = async (destDir) => {
|
|
91
|
+
try {
|
|
92
|
+
const { dir } = JSON.parse(await fs.readFile(join(destDir, MANAGED_POINTER), 'utf8'));
|
|
93
|
+
return typeof dir === 'string' && VERSION_DIR_RE.test(dir) ? dir : undefined;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
export const stageManagedVersion = async (files, srcDir, destDir, version) => {
|
|
100
|
+
const bodies = await Promise.all(files.map((f) => fs.readFile(join(srcDir, f))));
|
|
101
|
+
const id = versionDirName(version, files, bodies);
|
|
102
|
+
const versionsDir = join(destDir, MANAGED_VERSIONS_DIR);
|
|
103
|
+
await fs.mkdir(versionsDir, { recursive: true });
|
|
104
|
+
const final = join(versionsDir, id);
|
|
105
|
+
const staged = { id, version, files, bodies };
|
|
106
|
+
if (await holdsFiles(final, files, bodies)) {
|
|
107
|
+
if ((await readManagedPointer(destDir)) !== id) {
|
|
108
|
+
const now = new Date();
|
|
109
|
+
await fs.utimes(final, now, now).catch(() => undefined);
|
|
110
|
+
}
|
|
111
|
+
return { ...staged, written: false };
|
|
112
|
+
}
|
|
113
|
+
const tmp = await fs.mkdtemp(join(versionsDir, `.staging-${id}-`));
|
|
114
|
+
try {
|
|
115
|
+
for (const [i, f] of files.entries()) {
|
|
116
|
+
await fs.writeFile(join(tmp, f), bodies[i], { mode: 0o644 });
|
|
117
|
+
}
|
|
118
|
+
await fs.chmod(tmp, 0o755);
|
|
119
|
+
try {
|
|
120
|
+
await fs.rename(tmp, final);
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
if (await holdsFiles(final, files, bodies)) {
|
|
124
|
+
await fs.rm(tmp, { recursive: true, force: true });
|
|
125
|
+
return { ...staged, written: false };
|
|
126
|
+
}
|
|
127
|
+
if (!(await moveAside(versionsDir, id)))
|
|
128
|
+
throw err;
|
|
129
|
+
await fs.rename(tmp, final);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch (err) {
|
|
133
|
+
await fs.rm(tmp, { recursive: true, force: true });
|
|
134
|
+
if (await holdsFiles(final, files, bodies))
|
|
135
|
+
return { ...staged, written: false };
|
|
136
|
+
throw err;
|
|
137
|
+
}
|
|
138
|
+
return { ...staged, written: true };
|
|
139
|
+
};
|
|
140
|
+
const moveAside = async (versionsDir, id) => {
|
|
141
|
+
const aside = join(versionsDir, `.stale-${id}-${Math.random().toString(36).slice(2)}`);
|
|
142
|
+
try {
|
|
143
|
+
await fs.rename(join(versionsDir, id), aside);
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
return isMissing(err);
|
|
147
|
+
}
|
|
148
|
+
const now = new Date();
|
|
149
|
+
await fs.utimes(aside, now, now).catch(() => undefined);
|
|
150
|
+
return true;
|
|
151
|
+
};
|
|
152
|
+
const isMissing = (err) => err?.code === 'ENOENT';
|
|
153
|
+
const stagedIntact = async (destDir, staged) => holdsFiles(join(destDir, MANAGED_VERSIONS_DIR, staged.id), staged.files, staged.bodies);
|
|
154
|
+
export const commitManagedVersion = async (staged, hookNames, srcDir, destDir) => {
|
|
65
155
|
const updated = [];
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
156
|
+
const previous = await readManagedPointer(destDir);
|
|
157
|
+
if (previous !== staged.id) {
|
|
158
|
+
await writeAtomic(join(destDir, MANAGED_POINTER), `${JSON.stringify({ dir: staged.id, version: staged.version })}\n`);
|
|
159
|
+
updated.push(MANAGED_POINTER);
|
|
160
|
+
if (previous !== undefined) {
|
|
161
|
+
const now = new Date();
|
|
162
|
+
await fs
|
|
163
|
+
.utimes(join(destDir, MANAGED_VERSIONS_DIR, previous), now, now)
|
|
164
|
+
.catch(() => undefined);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const entry = await fs.readFile(join(srcDir, MANAGED_ENTRY_SCRIPT));
|
|
168
|
+
for (const name of hookNames) {
|
|
169
|
+
const current = await fs.readFile(join(destDir, name)).catch(() => null);
|
|
170
|
+
if (current !== null && current.equals(entry))
|
|
70
171
|
continue;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
await fs.rename(tmp, join(destDir, f));
|
|
74
|
-
updated.push(f);
|
|
172
|
+
await writeAtomic(join(destDir, name), entry);
|
|
173
|
+
updated.push(name);
|
|
75
174
|
}
|
|
76
175
|
return updated;
|
|
77
176
|
};
|
|
177
|
+
const pruneManagedVersions = async (destDir, keep) => {
|
|
178
|
+
const versionsDir = join(destDir, MANAGED_VERSIONS_DIR);
|
|
179
|
+
const current = await readManagedPointer(destDir);
|
|
180
|
+
const entries = await fs.readdir(versionsDir).catch(() => []);
|
|
181
|
+
const now = Date.now();
|
|
182
|
+
for (const name of entries) {
|
|
183
|
+
if (name === current || name === keep)
|
|
184
|
+
continue;
|
|
185
|
+
const path = join(versionsDir, name);
|
|
186
|
+
const stat = await fs.stat(path).catch(() => null);
|
|
187
|
+
if (stat === null || now - stat.mtimeMs < RETIRED_GRACE_MS)
|
|
188
|
+
continue;
|
|
189
|
+
if ((await readManagedPointer(destDir)) === name)
|
|
190
|
+
continue;
|
|
191
|
+
await fs.rm(path, { recursive: true, force: true }).catch(() => undefined);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
export const syncManagedHooks = async (matchers, srcDir, destDir, version) => {
|
|
195
|
+
const files = hookScriptFiles(matchers);
|
|
196
|
+
const hookNames = matchers.map((m) => m.hook);
|
|
197
|
+
const staged = await stageManagedVersion(files, srcDir, destDir, version);
|
|
198
|
+
const updated = await commitManagedVersion(staged, hookNames, srcDir, destDir);
|
|
199
|
+
if (!(await stagedIntact(destDir, staged))) {
|
|
200
|
+
const again = await stageManagedVersion(files, srcDir, destDir, version);
|
|
201
|
+
updated.push(...(await commitManagedVersion(again, hookNames, srcDir, destDir)));
|
|
202
|
+
if (!(await stagedIntact(destDir, again))) {
|
|
203
|
+
throw new Error(`could not install a complete set of hook scripts in ${destDir}`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
await pruneManagedVersions(destDir, staged.id);
|
|
207
|
+
return [
|
|
208
|
+
...new Set([
|
|
209
|
+
...(staged.written ? files.map((f) => `${MANAGED_VERSIONS_DIR}/${staged.id}/${f}`) : []),
|
|
210
|
+
...updated,
|
|
211
|
+
]),
|
|
212
|
+
];
|
|
213
|
+
};
|
|
214
|
+
export const resolveManagedScript = async (script) => {
|
|
215
|
+
const body = await fs.readFile(script, 'utf8').catch(() => null);
|
|
216
|
+
if (body === null)
|
|
217
|
+
return undefined;
|
|
218
|
+
if (!body.includes(MANAGED_ENTRY_MARK))
|
|
219
|
+
return script;
|
|
220
|
+
const dir = await readManagedPointer(dirname(script));
|
|
221
|
+
if (dir === undefined)
|
|
222
|
+
return undefined;
|
|
223
|
+
const target = join(dirname(script), MANAGED_VERSIONS_DIR, dir, basename(script));
|
|
224
|
+
return existsSync(target) ? target : undefined;
|
|
225
|
+
};
|
|
78
226
|
export const buildHookCommand = (scriptPath, version, plat = process.platform, runtimeTool) => {
|
|
79
227
|
const toolArg = runtimeTool ? ` --tool ${runtimeTool}` : '';
|
|
80
228
|
return plat === 'win32'
|
|
@@ -223,7 +371,6 @@ export const markerLogFiles = () => [
|
|
|
223
371
|
{ label: 'Jira tickets', path: join(homedir(), '.mainwave-jira-ticket-marker.log') },
|
|
224
372
|
{ label: 'PRs', path: join(homedir(), '.mainwave-pr-marker.log') },
|
|
225
373
|
];
|
|
226
|
-
const NON_POLICY_KEYS = new Set(['wslInheritsWindowsSettings', 'managedSourcesBehavior']);
|
|
227
374
|
const managedLockValue = (v) => {
|
|
228
375
|
if (v === undefined || v === null)
|
|
229
376
|
return undefined;
|
|
@@ -257,7 +404,7 @@ export const scanForMarkers = async (layers) => {
|
|
|
257
404
|
layerId: layer.id,
|
|
258
405
|
label: layer.label ?? layer.id,
|
|
259
406
|
groups: ownedGroupsInDoc(doc),
|
|
260
|
-
hasPolicyKey: Object.keys(doc).some(
|
|
407
|
+
hasPolicyKey: Object.keys(doc).some(isPolicyKey),
|
|
261
408
|
managed: isManagedLayer(layer),
|
|
262
409
|
managedSource: layer.managedSource,
|
|
263
410
|
mergeSources: doc.managedSourcesBehavior === 'merge',
|
|
@@ -405,7 +552,7 @@ export const collectMarkerIssues = async (scans, currentVersion, matchers, skipp
|
|
|
405
552
|
}
|
|
406
553
|
for (const g of cli) {
|
|
407
554
|
const version = parseManagedByVersion(g.command);
|
|
408
|
-
if (!g.managed && version !== undefined && version !== currentVersion) {
|
|
555
|
+
if (!g.managed && version !== undefined && /^\d/.test(version) && version !== currentVersion) {
|
|
409
556
|
issues.push({
|
|
410
557
|
level: 'warn',
|
|
411
558
|
message: `Marker hook [${g.matcher}] was written by @mainwave/cli@${version}; you are running ${currentVersion}. ` +
|
|
@@ -416,6 +563,16 @@ export const collectMarkerIssues = async (scans, currentVersion, matchers, skipp
|
|
|
416
563
|
if (script !== undefined) {
|
|
417
564
|
try {
|
|
418
565
|
await fs.access(script);
|
|
566
|
+
if (g.managed && (await resolveManagedScript(script)) === undefined) {
|
|
567
|
+
issues.push({
|
|
568
|
+
level: 'error',
|
|
569
|
+
message: `Marker hook ${basename(script)} in ${dirname(script)} names no installed release ` +
|
|
570
|
+
`(${MANAGED_POINTER} is missing, or its release lacks the script), so it sends nothing. ` +
|
|
571
|
+
'Start a new Claude Code session, or ' +
|
|
572
|
+
(process.platform === 'win32' ? 'in Git Bash run ' : 'run ') +
|
|
573
|
+
`\`${installHooksCommand(version ?? PAYLOAD_CLI_SPEC, { quiet: false })}\`.`,
|
|
574
|
+
});
|
|
575
|
+
}
|
|
419
576
|
}
|
|
420
577
|
catch {
|
|
421
578
|
issues.push({
|
|
@@ -424,7 +581,7 @@ export const collectMarkerIssues = async (scans, currentVersion, matchers, skipp
|
|
|
424
581
|
(g.managed
|
|
425
582
|
? 'Start a new Claude Code session (the managed settings install it at startup), or ' +
|
|
426
583
|
(process.platform === 'win32' ? 'in Git Bash run ' : 'run ') +
|
|
427
|
-
`\`${installHooksCommand(version ??
|
|
584
|
+
`\`${installHooksCommand(version ?? PAYLOAD_CLI_SPEC, { quiet: false })}\`.`
|
|
428
585
|
: 'Re-run setup.'),
|
|
429
586
|
});
|
|
430
587
|
}
|
|
@@ -460,4 +617,3 @@ export const collectMarkerIssues = async (scans, currentVersion, matchers, skipp
|
|
|
460
617
|
}
|
|
461
618
|
return issues;
|
|
462
619
|
};
|
|
463
|
-
//# sourceMappingURL=markers.js.map
|
|
@@ -8,4 +8,3 @@ export const pinnedUseCase = async (settings, targets = adapterNames().map((n) =
|
|
|
8
8
|
const effective = await Promise.all(developerTools.map(adapterEffective));
|
|
9
9
|
return effective.some((e) => e.ucid === stored.id) ? stored : undefined;
|
|
10
10
|
};
|
|
11
|
-
//# sourceMappingURL=pinned-use-case.js.map
|
package/dist/core/platform.js
CHANGED
package/dist/core/post-setup.js
CHANGED
package/dist/core/prompts.js
CHANGED
package/dist/core/settings.js
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
|
-
import { constants as fsConstants, promises as fs } from 'node:fs';
|
|
2
|
-
import { dirname } from 'node:path';
|
|
1
|
+
import { constants as fsConstants, promises as fs, realpathSync } from 'node:fs';
|
|
2
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
3
|
+
const realOrResolved = (path) => {
|
|
4
|
+
try {
|
|
5
|
+
return realpathSync(path);
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
try {
|
|
9
|
+
return join(realpathSync(dirname(path)), basename(path));
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return resolve(path);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export const isSamePath = (a, b) => realOrResolved(a) === realOrResolved(b);
|
|
3
17
|
export const isErrnoCode = (err, code) => typeof err === 'object' && err !== null && err.code === code;
|
|
4
18
|
const readFileOrNull = async (path) => {
|
|
5
19
|
try {
|
|
@@ -84,4 +98,3 @@ export const applyUpdate = async (update) => {
|
|
|
84
98
|
}
|
|
85
99
|
return { backupPath, written: path };
|
|
86
100
|
};
|
|
87
|
-
//# sourceMappingURL=settings.js.map
|
package/dist/core/skills.js
CHANGED
|
@@ -4,7 +4,11 @@ import { dirname, join } from 'node:path';
|
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
export const BLOCK_OPEN = '<!-- mainwave:skills managed-by @mainwave/cli';
|
|
6
6
|
export const BLOCK_CLOSE = '<!-- /mainwave:skills -->';
|
|
7
|
-
export const SKILL_NAMES = [
|
|
7
|
+
export const SKILL_NAMES = [
|
|
8
|
+
'mainwave-setup',
|
|
9
|
+
'mainwave-instrument',
|
|
10
|
+
'mainwave-instrument-node',
|
|
11
|
+
];
|
|
8
12
|
export const packagedSkillsDir = () => fileURLToPath(new URL('../../skills/', import.meta.url));
|
|
9
13
|
export const installedSkillsDir = () => join(homedir(), '.mainwave', 'skills');
|
|
10
14
|
export const copySkillBundle = async (name, srcRoot = packagedSkillsDir(), destRoot = installedSkillsDir()) => {
|
|
@@ -125,4 +129,3 @@ export const installSkillsPayload = async (adapters, version, srcRoot = packaged
|
|
|
125
129
|
}
|
|
126
130
|
return { installs, noOps, bundleDir: join(installedRoot) };
|
|
127
131
|
};
|
|
128
|
-
//# sourceMappingURL=skills.js.map
|
package/dist/core/status.js
CHANGED
|
@@ -40,7 +40,9 @@ const fileRowsFor = (adapter) => {
|
|
|
40
40
|
: adapter.hierarchy.find((l) => l.path === adapter.paths.local)?.id;
|
|
41
41
|
const rows = [
|
|
42
42
|
{ label: 'Global', path: adapter.paths.global, codec: adapter.codec, parse: primaryParse },
|
|
43
|
-
|
|
43
|
+
];
|
|
44
|
+
if (adapter.paths.localIgnored === undefined) {
|
|
45
|
+
rows.push({
|
|
44
46
|
label: 'Local',
|
|
45
47
|
path: adapter.paths.local,
|
|
46
48
|
codec: adapter.codec,
|
|
@@ -54,8 +56,8 @@ const fileRowsFor = (adapter) => {
|
|
|
54
56
|
},
|
|
55
57
|
}
|
|
56
58
|
: {}),
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
+
});
|
|
60
|
+
}
|
|
59
61
|
for (const aw of adapter.additionalWrites ?? []) {
|
|
60
62
|
rows.push(...additionalRowsFor(aw));
|
|
61
63
|
}
|
|
@@ -269,4 +271,3 @@ export const runStatus = async (adapter, options = {}) => {
|
|
|
269
271
|
}
|
|
270
272
|
return 0;
|
|
271
273
|
};
|
|
272
|
-
//# sourceMappingURL=status.js.map
|
package/dist/core/store.js
CHANGED
package/dist/core/tty.js
CHANGED
package/dist/core/ucid.js
CHANGED
package/dist/core/ui.js
CHANGED
package/dist/core/use-case.js
CHANGED
package/dist/core/validate.js
CHANGED
package/dist/core/verify.js
CHANGED
package/dist/core/version.js
CHANGED
|
@@ -2,4 +2,3 @@ import { readFileSync } from 'node:fs';
|
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
const pkgPath = fileURLToPath(new URL('../../package.json', import.meta.url));
|
|
4
4
|
export const VERSION = JSON.parse(readFileSync(pkgPath, 'utf8')).version;
|
|
5
|
-
//# sourceMappingURL=version.js.map
|
package/dist/core/wizard.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { select } from '@inquirer/prompts';
|
|
2
2
|
import { mergePrefills, planAdapter, planHasChanges, printMarkerCoexistenceNotes, printPostSetup, readPrefill, renderPlan, writePlan, } from './apply.js';
|
|
3
3
|
import { runLogin } from './auth-commands.js';
|
|
4
|
-
import { computeEffective, nativeIdentityReason } from './effective-settings.js';
|
|
4
|
+
import { computeEffective, isManagedUnitDrop, nativeIdentityReason } from './effective-settings.js';
|
|
5
5
|
import { isManagedIdentityConfig, isManagedLayer } from './layer-policy.js';
|
|
6
6
|
import { PlatformError, ValidateError, WizardAbort } from './errors.js';
|
|
7
7
|
import { color } from './format.js';
|
|
@@ -62,12 +62,9 @@ export const shadowWarning = (effective, plan, surfaceUcid) => {
|
|
|
62
62
|
return null;
|
|
63
63
|
const writtenEnv = adapter.buildEnv(plan.input);
|
|
64
64
|
const applied = (s) => Object.fromEntries(Object.entries(s.env).filter(([k]) => !(effective.policy === 'active' &&
|
|
65
|
-
effective.ignored.some((i) => i.scan === s && i.keys.includes(k))) &&
|
|
66
|
-
!(effective.unitSource !== undefined &&
|
|
67
|
-
adapter.managedUnitKey?.(k) === true &&
|
|
68
|
-
s.layer.managedSource !== effective.unitSource)));
|
|
65
|
+
effective.ignored.some((i) => i.scan === s && i.keys.includes(k))) && !isManagedUnitDrop(adapter, effective, s, k)));
|
|
69
66
|
const unlocked = (s) => adapter.managedLock && isManagedLayer(s.layer)
|
|
70
|
-
? Object.fromEntries(Object.entries(writtenEnv).filter(([k]) => !adapter.managedLock(k, applied(s))))
|
|
67
|
+
? Object.fromEntries(Object.entries(writtenEnv).filter(([k]) => !adapter.managedLock(k, applied(s), effective.unitClaim?.lands ? effective.unitClaim.setting : undefined)))
|
|
71
68
|
: writtenEnv;
|
|
72
69
|
const writtenIdx = effective.scans.findIndex((s) => s.path === plan.primaryPath);
|
|
73
70
|
const above = effective.scans.slice(0, writtenIdx < 0 ? 0 : writtenIdx);
|
|
@@ -463,4 +460,3 @@ const printPostSetupTips = (adapters) => {
|
|
|
463
460
|
' invocations have time to flush spans before exit.'));
|
|
464
461
|
}
|
|
465
462
|
};
|
|
466
|
-
//# sourceMappingURL=wizard.js.map
|
package/dist/main.js
CHANGED
package/hooks/cursor-otlp.mjs
CHANGED
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
// Unlike the Claude Code / Codex marker hooks, Cursor exposes no config file we
|
|
13
13
|
// can read the collector endpoint + auth back out of — so setup writes a
|
|
14
14
|
// managed env file (`~/.mainwave/cursor.env`, mode 0600) and this script reads
|
|
15
|
-
// its OTLP config from there
|
|
15
|
+
// its OTLP config from there. Only from there: a `.mainwave/cursor.env` in the
|
|
16
|
+
// workspace comes with the repository, and a repository mustn't choose where
|
|
17
|
+
// the developer's key is sent.
|
|
16
18
|
// Tenancy (ucid, source) comes from that file; the developer identity
|
|
17
19
|
// (`user_email`) rides in on Cursor's own per-event payload.
|
|
18
20
|
//
|
|
@@ -30,13 +32,13 @@ import {
|
|
|
30
32
|
bearerFromHeaders,
|
|
31
33
|
buildMarkerPayload,
|
|
32
34
|
emitMarker,
|
|
33
|
-
|
|
35
|
+
markerLog,
|
|
34
36
|
parseKv,
|
|
35
37
|
readStdin,
|
|
36
38
|
} from './marker-core.mjs'
|
|
37
39
|
import { ATTR_CODE_FILE_PATH } from './vocabulary.mjs'
|
|
38
40
|
|
|
39
|
-
const log =
|
|
41
|
+
const log = markerLog(process.argv, '.mainwave-cursor.log')
|
|
40
42
|
|
|
41
43
|
// Classified by the collector as a coding agent via `mainwave.source`; the
|
|
42
44
|
// service name matches Cursor's own native-export resource (`service.name=cursor`)
|
|
@@ -85,18 +87,14 @@ const readFileSafe = (path) => {
|
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
/**
|
|
88
|
-
* OTLP config from the
|
|
89
|
-
*
|
|
90
|
-
*
|
|
90
|
+
* OTLP config from the developer's own `~/.mainwave/cursor.env`. A workspace's
|
|
91
|
+
* `.mainwave/cursor.env` is never read: merged over this one key by key, a
|
|
92
|
+
* repository that set only the endpoint would receive the developer's real
|
|
93
|
+
* key. Missing values → undefined and the emit is skipped (fail-open), never a
|
|
94
|
+
* broken post.
|
|
91
95
|
*/
|
|
92
|
-
export const loadCursorConfig = (
|
|
93
|
-
const merged =
|
|
94
|
-
for (const p of [
|
|
95
|
-
join(homedir(), '.mainwave', 'cursor.env'),
|
|
96
|
-
join(cwd, '.mainwave', 'cursor.env'),
|
|
97
|
-
]) {
|
|
98
|
-
Object.assign(merged, parseEnvFile(readFile(p)))
|
|
99
|
-
}
|
|
96
|
+
export const loadCursorConfig = (readFile = readFileSafe) => {
|
|
97
|
+
const merged = parseEnvFile(readFile(join(homedir(), '.mainwave', 'cursor.env')))
|
|
100
98
|
const headers = parseKv(merged.OTEL_EXPORTER_OTLP_HEADERS)
|
|
101
99
|
const ucid = headers['X-Mainwave-UCID']
|
|
102
100
|
// The hook POSTs tenancy on the span RESOURCE, not as X-Mainwave-* headers, so
|
|
@@ -206,7 +204,7 @@ const main = async () => {
|
|
|
206
204
|
process.exit(0)
|
|
207
205
|
}
|
|
208
206
|
|
|
209
|
-
const config = loadCursorConfig(
|
|
207
|
+
const config = loadCursorConfig()
|
|
210
208
|
if (!config.endpoint || !config.bearer) {
|
|
211
209
|
log(`skip ${payload?.hook_event_name}: no endpoint/auth in ~/.mainwave/cursor.env`)
|
|
212
210
|
process.exit(0)
|
|
@@ -18,20 +18,21 @@
|
|
|
18
18
|
// fast otherwise, so it can never block or slow the session.
|
|
19
19
|
|
|
20
20
|
import { execFile } from 'node:child_process'
|
|
21
|
-
import { homedir } from 'node:os'
|
|
22
|
-
import { join } from 'node:path'
|
|
23
21
|
import { pathToFileURL } from 'node:url'
|
|
24
22
|
|
|
25
23
|
import {
|
|
26
24
|
buildMarkerPayload,
|
|
27
25
|
markerOauthAccount,
|
|
26
|
+
markerSessionEnv,
|
|
28
27
|
emitMarker,
|
|
28
|
+
hookFlag,
|
|
29
29
|
loadOtelConfig,
|
|
30
30
|
markerCallContext,
|
|
31
31
|
markerHostSource,
|
|
32
32
|
markerManagedDir,
|
|
33
|
+
markerProjectDir,
|
|
33
34
|
markerTool,
|
|
34
|
-
|
|
35
|
+
markerLog,
|
|
35
36
|
payloadShape,
|
|
36
37
|
readStdin,
|
|
37
38
|
toolOutput,
|
|
@@ -51,7 +52,7 @@ import {
|
|
|
51
52
|
// Re-export the shared output-reading helpers so the tests can import them here.
|
|
52
53
|
export { payloadShape, toolOutput } from './marker-core.mjs'
|
|
53
54
|
|
|
54
|
-
const log =
|
|
55
|
+
const log = markerLog(process.argv, '.mainwave-pr-marker.log')
|
|
55
56
|
|
|
56
57
|
// Non-coding source/service so the marker lands as an ordinary span and stays
|
|
57
58
|
// out of the coding-work segmentation, same as the ticket marker.
|
|
@@ -112,13 +113,15 @@ export const parsePrStats = (stdout) => {
|
|
|
112
113
|
* The opened PR's aggregate diff counts, via `gh pr view <number> --json ...`.
|
|
113
114
|
* Fail-open: resolves `{}` on any error (gh absent, unauthenticated, timeout,
|
|
114
115
|
* bad output) so a marker still emits without the stats — never blocks the
|
|
115
|
-
* session. `
|
|
116
|
-
*
|
|
116
|
+
* session. `bin` replaces `gh`; `main` takes it only from the hook's own
|
|
117
|
+
* `--gh-bin` flag (tests pass a stub), never from the environment, because a
|
|
118
|
+
* repository's project settings `env` reaches the hook and this runs with the
|
|
119
|
+
* repository as its working directory (§ `hookFlag`). Only the three integer
|
|
120
|
+
* counts are read — never the diff.
|
|
117
121
|
*/
|
|
118
|
-
export const fetchPrStats = (number, { cwd, timeoutMs = 5000 } = {}) =>
|
|
122
|
+
export const fetchPrStats = (number, { cwd, bin = 'gh', timeoutMs = 5000 } = {}) =>
|
|
119
123
|
new Promise((resolve) => {
|
|
120
124
|
if (!number) return resolve({})
|
|
121
|
-
const bin = process.env.MAINWAVE_GH_BIN || 'gh'
|
|
122
125
|
execFile(
|
|
123
126
|
bin,
|
|
124
127
|
['pr', 'view', String(number), '--json', 'changedFiles,additions,deletions'],
|
|
@@ -197,9 +200,11 @@ const main = async () => {
|
|
|
197
200
|
const title = extractPrTitle(command)
|
|
198
201
|
|
|
199
202
|
const cwd = payload.cwd || process.cwd()
|
|
203
|
+
const projectDir = markerProjectDir(payload)
|
|
200
204
|
const tool = markerTool(process.argv)
|
|
201
205
|
const managedDir = markerManagedDir(process.argv)
|
|
202
|
-
const
|
|
206
|
+
const env = markerSessionEnv(tool, payload)
|
|
207
|
+
const { endpoint, bearer, resourceAttrs } = loadOtelConfig(projectDir, env, tool, managedDir)
|
|
203
208
|
log(
|
|
204
209
|
`pr=${number} endpoint=${endpoint ? 'set' : 'MISSING'} ` +
|
|
205
210
|
`bearer=${bearer ? 'set' : 'MISSING'} ucid=${resourceAttrs['mainwave.ucid'] || 'MISSING'}`,
|
|
@@ -210,13 +215,19 @@ const main = async () => {
|
|
|
210
215
|
}
|
|
211
216
|
// Read only once the emit is certain: `.claude.json` can run to megabytes.
|
|
212
217
|
const { email: userEmail, accountUuid: userAccountUuid } = markerOauthAccount(tool, {
|
|
213
|
-
cwd,
|
|
218
|
+
cwd: projectDir,
|
|
219
|
+
env,
|
|
214
220
|
managedDir,
|
|
215
221
|
})
|
|
216
222
|
|
|
217
223
|
// Diff counts are best-effort: the marker still emits (with the link) if gh is
|
|
218
224
|
// unavailable or the fetch fails, so this never blocks the PR from surfacing.
|
|
219
|
-
|
|
225
|
+
// gh runs where the agent ran `gh pr create`: that directory names the PR's
|
|
226
|
+
// repository.
|
|
227
|
+
const { changedFiles, additions, deletions } = await fetchPrStats(number, {
|
|
228
|
+
cwd,
|
|
229
|
+
bin: hookFlag(process.argv, '--gh-bin'),
|
|
230
|
+
})
|
|
220
231
|
log(
|
|
221
232
|
`stats changed_files=${changedFiles ?? 'na'} additions=${additions ?? 'na'} ` +
|
|
222
233
|
`deletions=${deletions ?? 'na'}`,
|
|
@@ -27,20 +27,20 @@
|
|
|
27
27
|
// wrongly assuming a hook couldn't produce it). Fails open and fast so a
|
|
28
28
|
// telemetry hiccup can never block or slow the session.
|
|
29
29
|
|
|
30
|
-
import { homedir } from 'node:os'
|
|
31
|
-
import { join } from 'node:path'
|
|
32
30
|
import { pathToFileURL } from 'node:url'
|
|
33
31
|
|
|
34
32
|
import {
|
|
35
33
|
buildMarkerPayload,
|
|
36
34
|
markerOauthAccount,
|
|
35
|
+
markerSessionEnv,
|
|
37
36
|
emitMarker,
|
|
38
37
|
loadOtelConfig,
|
|
39
38
|
markerCallContext,
|
|
40
39
|
markerHostSource,
|
|
41
40
|
markerManagedDir,
|
|
41
|
+
markerProjectDir,
|
|
42
42
|
markerTool,
|
|
43
|
-
|
|
43
|
+
markerLog,
|
|
44
44
|
payloadShape,
|
|
45
45
|
readStdin,
|
|
46
46
|
toolOutput,
|
|
@@ -58,9 +58,7 @@ import {
|
|
|
58
58
|
WORK_OP_UPDATED,
|
|
59
59
|
} from './vocabulary.mjs'
|
|
60
60
|
|
|
61
|
-
const log =
|
|
62
|
-
process.env.MAINWAVE_HOOK_LOG || join(homedir(), '.mainwave-jira-ticket-marker.log'),
|
|
63
|
-
)
|
|
61
|
+
const log = markerLog(process.argv, '.mainwave-jira-ticket-marker.log')
|
|
64
62
|
|
|
65
63
|
// The same non-coding source/service the Linear ticket hook stamps, so a Jira
|
|
66
64
|
// marker is classified identically to a Linear one: an ordinary ("other") span
|
|
@@ -215,10 +213,11 @@ const main = async () => {
|
|
|
215
213
|
const instance = extractInstance(output)
|
|
216
214
|
const op = detectOp(payload.tool_name)
|
|
217
215
|
|
|
218
|
-
const
|
|
216
|
+
const projectDir = markerProjectDir(payload)
|
|
219
217
|
const tool = markerTool(process.argv)
|
|
220
218
|
const managedDir = markerManagedDir(process.argv)
|
|
221
|
-
const
|
|
219
|
+
const env = markerSessionEnv(tool, payload)
|
|
220
|
+
const { endpoint, bearer, resourceAttrs } = loadOtelConfig(projectDir, env, tool, managedDir)
|
|
222
221
|
log(
|
|
223
222
|
`issue=${issueKey} op=${op} endpoint=${endpoint ? 'set' : 'MISSING'} ` +
|
|
224
223
|
`bearer=${bearer ? 'set' : 'MISSING'} ucid=${resourceAttrs['mainwave.ucid'] || 'MISSING'}`,
|
|
@@ -229,7 +228,8 @@ const main = async () => {
|
|
|
229
228
|
}
|
|
230
229
|
// Read only once the emit is certain: `.claude.json` can run to megabytes.
|
|
231
230
|
const { email: userEmail, accountUuid: userAccountUuid } = markerOauthAccount(tool, {
|
|
232
|
-
cwd,
|
|
231
|
+
cwd: projectDir,
|
|
232
|
+
env,
|
|
233
233
|
managedDir,
|
|
234
234
|
})
|
|
235
235
|
|