@mainwave/cli 0.3.2 → 0.4.0-rc.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 +94 -10
- package/dist/adapters/claude-code.js +3 -0
- package/dist/adapters/claude-code.js.map +1 -1
- package/dist/adapters/codex-cli.js +10 -1
- package/dist/adapters/codex-cli.js.map +1 -1
- package/dist/adapters/copilot-chat.js +13 -0
- package/dist/adapters/copilot-chat.js.map +1 -1
- package/dist/adapters/copilot-cli.js +2 -0
- package/dist/adapters/copilot-cli.js.map +1 -1
- package/dist/adapters/cursor-enterprise.js +146 -0
- package/dist/adapters/cursor-enterprise.js.map +1 -0
- package/dist/adapters/cursor.js +197 -0
- package/dist/adapters/cursor.js.map +1 -0
- package/dist/adapters/index.js +4 -0
- package/dist/adapters/index.js.map +1 -1
- package/dist/api/index.js +3 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/types.gen.js +3 -0
- package/dist/api/types.gen.js.map +1 -0
- package/dist/core/apply.js +258 -0
- package/dist/core/apply.js.map +1 -0
- package/dist/core/auth-commands.js +157 -0
- package/dist/core/auth-commands.js.map +1 -0
- package/dist/core/behaviour-hooks.js +101 -0
- package/dist/core/behaviour-hooks.js.map +1 -0
- package/dist/core/browser.js +41 -0
- package/dist/core/browser.js.map +1 -0
- package/dist/core/codecs/cursor-hooks-json.js +90 -0
- package/dist/core/codecs/cursor-hooks-json.js.map +1 -0
- package/dist/core/detect.js +52 -0
- package/dist/core/detect.js.map +1 -0
- package/dist/core/device-login.js +76 -0
- package/dist/core/device-login.js.map +1 -0
- package/dist/core/doctor.js +51 -2
- package/dist/core/doctor.js.map +1 -1
- package/dist/core/errors.js +23 -0
- package/dist/core/errors.js.map +1 -1
- package/dist/core/flags.js +57 -0
- package/dist/core/flags.js.map +1 -0
- package/dist/core/headers.js +15 -1
- package/dist/core/headers.js.map +1 -1
- package/dist/core/interview.js +198 -0
- package/dist/core/interview.js.map +1 -0
- package/dist/core/keys.js +41 -0
- package/dist/core/keys.js.map +1 -0
- package/dist/core/markers.js +5 -1
- package/dist/core/markers.js.map +1 -1
- package/dist/core/platform.js +152 -0
- package/dist/core/platform.js.map +1 -0
- package/dist/core/prompts.js +68 -22
- package/dist/core/prompts.js.map +1 -1
- package/dist/core/status.js +25 -1
- package/dist/core/status.js.map +1 -1
- package/dist/core/store.js +118 -0
- package/dist/core/store.js.map +1 -0
- package/dist/core/tty.js +6 -0
- package/dist/core/tty.js.map +1 -1
- package/dist/core/ucid.js +25 -0
- package/dist/core/ucid.js.map +1 -0
- package/dist/core/ui.js +26 -0
- package/dist/core/ui.js.map +1 -0
- package/dist/core/use-case.js +99 -0
- package/dist/core/use-case.js.map +1 -0
- package/dist/core/validate.js +22 -0
- package/dist/core/validate.js.map +1 -1
- package/dist/core/verify.js +154 -0
- package/dist/core/verify.js.map +1 -0
- package/dist/core/wizard.js +148 -278
- package/dist/core/wizard.js.map +1 -1
- package/dist/main.js +185 -29
- package/dist/main.js.map +1 -1
- package/hooks/cursor-otlp.mjs +244 -0
- package/hooks/github-pr-marker.mjs +30 -10
- package/hooks/jira-ticket-marker.mjs +69 -17
- package/hooks/linear-ticket-marker.mjs +68 -12
- package/hooks/marker-core.mjs +5 -0
- package/hooks/vocabulary.d.mts +35 -0
- package/hooks/vocabulary.mjs +109 -0
- package/package.json +6 -3
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { cursorHooksJsonCodec } from '../core/codecs/cursor-hooks-json.js';
|
|
4
|
+
import { envFileCodec } from '../core/codecs/env-file.js';
|
|
5
|
+
import { hasBinary, hasPath } from '../core/detect.js';
|
|
6
|
+
import { buildHeaders, HEADER_NAME, headerBearerToken, kvPairsHeaders } from '../core/headers.js';
|
|
7
|
+
import { buildHookCommand, installedHooksDir } from '../core/markers.js';
|
|
8
|
+
import { VERSION } from '../core/version.js';
|
|
9
|
+
/**
|
|
10
|
+
* Cursor agent hooks adapter (MAI-1433).
|
|
11
|
+
*
|
|
12
|
+
* Cursor has no native OTLP exporter on non-Enterprise plans (its native
|
|
13
|
+
* OpenTelemetry Export is Enterprise-beta and carries cost/tokens, not
|
|
14
|
+
* per-session behaviour). Its hooks system is the only way to instrument it on
|
|
15
|
+
* any plan, so this adapter has a two-surface shape:
|
|
16
|
+
*
|
|
17
|
+
* 1. A managed env file (`~/.mainwave/cursor.env`, mode 0600) holds the OTLP
|
|
18
|
+
* endpoint + tenancy headers — the config the hook script reads at runtime.
|
|
19
|
+
* Cursor exposes no config file of its own for the hook to read this back
|
|
20
|
+
* out of (unlike Claude Code's settings.json / Codex's config.toml), so we
|
|
21
|
+
* own the file. This is the PRIMARY write surface (envFileCodec).
|
|
22
|
+
* 2. `hooks.json` registers our `cursor-otlp.mjs` script for the agent
|
|
23
|
+
* lifecycle events. This is an `additionalWrites` entry through
|
|
24
|
+
* `cursorHooksJsonCodec`, whose merge preserves any hooks the user or an
|
|
25
|
+
* enterprise policy already registered on the same events.
|
|
26
|
+
*
|
|
27
|
+
* The hook script maps each Cursor event to one OTLP span tagged
|
|
28
|
+
* `mainwave.source = coding_agent.cursor` and posts it to the collector.
|
|
29
|
+
* Tenancy (ucid, source) comes from the env file; the developer identity
|
|
30
|
+
* (`user_email`) rides in on Cursor's own per-event payload.
|
|
31
|
+
*
|
|
32
|
+
* What this buys: sessions, tool calls, MCP usage, file edits and stop reasons —
|
|
33
|
+
* enough for trajectories and use-case attribution, on ANY Cursor plan. What it
|
|
34
|
+
* does NOT buy: tokens or cost. Those stay behind the Enterprise Admin API
|
|
35
|
+
* (MAI-1434) and the native OTel export (MAI-1432).
|
|
36
|
+
*/
|
|
37
|
+
const SOURCE_VALUE = 'coding_agent.cursor';
|
|
38
|
+
// OTLP config surface — the env file the hook reads. Mirrors the Copilot CLI
|
|
39
|
+
// adapter: endpoint + tenancy headers, tenancy carried on `X-Mainwave-*`.
|
|
40
|
+
const CONFIG_MANAGED_KEYS = ['OTEL_EXPORTER_OTLP_ENDPOINT', 'OTEL_EXPORTER_OTLP_HEADERS'];
|
|
41
|
+
const CONFIG_GLOBAL = join(homedir(), '.mainwave', 'cursor.env');
|
|
42
|
+
const CONFIG_LOCAL = join('.mainwave', 'cursor.env');
|
|
43
|
+
const HOOKS_GLOBAL = join(homedir(), '.cursor', 'hooks.json');
|
|
44
|
+
const HOOKS_LOCAL = join('.cursor', 'hooks.json');
|
|
45
|
+
// Cursor's enterprise/managed hooks file — highest precedence, and the tier the
|
|
46
|
+
// wizard can't write (admin-owned). Platform-specific per Cursor's docs.
|
|
47
|
+
const HOOKS_ENTERPRISE = process.platform === 'win32'
|
|
48
|
+
? 'C:\\ProgramData\\Cursor\\hooks.json'
|
|
49
|
+
: process.platform === 'darwin'
|
|
50
|
+
? '/Library/Application Support/Cursor/hooks.json'
|
|
51
|
+
: '/etc/cursor/hooks.json';
|
|
52
|
+
// Every hooks.json layer doctor inspects for our behaviour hook, highest→lowest
|
|
53
|
+
// precedence (Enterprise → Project → User), matching Cursor's own resolution.
|
|
54
|
+
const HOOKS_LAYERS = [
|
|
55
|
+
{ id: 'managed', label: 'Enterprise (managed)', path: HOOKS_ENTERPRISE, kind: 'file' },
|
|
56
|
+
{ id: 'project', label: 'Project', path: HOOKS_LOCAL, kind: 'file' },
|
|
57
|
+
{ id: 'user', label: 'User (global)', path: HOOKS_GLOBAL, kind: 'file' },
|
|
58
|
+
];
|
|
59
|
+
// Cursor agent-lifecycle events always instrumented, plus the prompt event that
|
|
60
|
+
// is registered only under the prompt opt-in. The hook command is identical for
|
|
61
|
+
// every event (cursor-otlp.mjs dispatches on `hook_event_name` from stdin).
|
|
62
|
+
const ALWAYS_EVENTS = [
|
|
63
|
+
'sessionStart',
|
|
64
|
+
'postToolUse',
|
|
65
|
+
'beforeMCPExecution',
|
|
66
|
+
'afterFileEdit',
|
|
67
|
+
'stop',
|
|
68
|
+
];
|
|
69
|
+
const PROMPT_EVENT = 'beforeSubmitPrompt';
|
|
70
|
+
const hookKey = (event) => `hooks.${event}`;
|
|
71
|
+
/** Every hooks.json key this adapter can emit — cleared on re-run so opting the
|
|
72
|
+
* prompt event out removes it while foreign hooks on other events survive. */
|
|
73
|
+
const HOOKS_MANAGED_KEYS = [...ALWAYS_EVENTS, PROMPT_EVENT].map(hookKey);
|
|
74
|
+
const hookCommand = () => buildHookCommand(join(installedHooksDir(), 'cursor-otlp.mjs'), VERSION);
|
|
75
|
+
const stripTrailingSlash = (url) => url.replace(/\/+$/, '');
|
|
76
|
+
const buildHeadersValue = (apiKey, ucid) => kvPairsHeaders.encode(buildHeaders({ apiKey, ucid, source: SOURCE_VALUE }));
|
|
77
|
+
const parseHeaders = (raw) => kvPairsHeaders.decode(raw) ?? {};
|
|
78
|
+
const buildEnv = ({ ucid, collectorUrl, apiKey }) => ({
|
|
79
|
+
OTEL_EXPORTER_OTLP_ENDPOINT: stripTrailingSlash(collectorUrl),
|
|
80
|
+
OTEL_EXPORTER_OTLP_HEADERS: buildHeadersValue(apiKey, ucid),
|
|
81
|
+
});
|
|
82
|
+
const parseEnv = (env) => {
|
|
83
|
+
const hasAnyManaged = CONFIG_MANAGED_KEYS.some((k) => k in env);
|
|
84
|
+
if (!hasAnyManaged)
|
|
85
|
+
return {};
|
|
86
|
+
const out = {};
|
|
87
|
+
const endpoint = env.OTEL_EXPORTER_OTLP_ENDPOINT;
|
|
88
|
+
if (endpoint)
|
|
89
|
+
out.collectorUrl = stripTrailingSlash(endpoint);
|
|
90
|
+
const raw = env.OTEL_EXPORTER_OTLP_HEADERS;
|
|
91
|
+
if (raw) {
|
|
92
|
+
const headers = parseHeaders(raw);
|
|
93
|
+
const token = headerBearerToken(headers[HEADER_NAME.authorization]);
|
|
94
|
+
if (token)
|
|
95
|
+
out.apiKey = token;
|
|
96
|
+
const ucid = headers[HEADER_NAME.ucid];
|
|
97
|
+
if (ucid)
|
|
98
|
+
out.ucid = ucid;
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
};
|
|
102
|
+
const normalizeForGenericChecks = (env) => {
|
|
103
|
+
const endpoint = env.OTEL_EXPORTER_OTLP_ENDPOINT;
|
|
104
|
+
const raw = env.OTEL_EXPORTER_OTLP_HEADERS;
|
|
105
|
+
let auth;
|
|
106
|
+
let ucid;
|
|
107
|
+
if (raw) {
|
|
108
|
+
const headers = parseHeaders(raw);
|
|
109
|
+
auth = headers[HEADER_NAME.authorization];
|
|
110
|
+
ucid = headers[HEADER_NAME.ucid];
|
|
111
|
+
}
|
|
112
|
+
return { endpoint, auth, ucid };
|
|
113
|
+
};
|
|
114
|
+
const collectChecks = () => [
|
|
115
|
+
{
|
|
116
|
+
level: 'info',
|
|
117
|
+
message: 'Cursor hooks carry behaviour telemetry only (sessions, tool calls, MCP, file edits) — ' +
|
|
118
|
+
'no tokens or cost. Cursor keeps those behind its Enterprise plan (native OTel export / ' +
|
|
119
|
+
'Admin API); this adapter works on any plan.',
|
|
120
|
+
},
|
|
121
|
+
];
|
|
122
|
+
/**
|
|
123
|
+
* The hooks.json registration. Its build/parse operate on the flat
|
|
124
|
+
* `hooks.<event>` → command keys the Cursor hooks codec round-trips. The prompt
|
|
125
|
+
* event is included only under the prompt opt-in; the codec clears it on a
|
|
126
|
+
* re-run that opts back out.
|
|
127
|
+
*/
|
|
128
|
+
const hooksWrite = {
|
|
129
|
+
id: 'hooks-json',
|
|
130
|
+
label: 'Cursor hooks',
|
|
131
|
+
codec: cursorHooksJsonCodec,
|
|
132
|
+
path: HOOKS_GLOBAL,
|
|
133
|
+
localPath: HOOKS_LOCAL,
|
|
134
|
+
managedKeys: HOOKS_MANAGED_KEYS,
|
|
135
|
+
build: ({ optIns }) => {
|
|
136
|
+
const command = hookCommand();
|
|
137
|
+
const events = [...ALWAYS_EVENTS];
|
|
138
|
+
if (optIns.userPrompts)
|
|
139
|
+
events.push(PROMPT_EVENT);
|
|
140
|
+
return Object.fromEntries(events.map((e) => [hookKey(e), command]));
|
|
141
|
+
},
|
|
142
|
+
parse: (env) => {
|
|
143
|
+
if (!HOOKS_MANAGED_KEYS.some((k) => k in env))
|
|
144
|
+
return {};
|
|
145
|
+
// The only opt-in Cursor gates is prompt content, witnessed by whether the
|
|
146
|
+
// prompt event is registered. Tool telemetry is always on, so its opt-ins
|
|
147
|
+
// read back as enabled.
|
|
148
|
+
return {
|
|
149
|
+
optIns: {
|
|
150
|
+
userPrompts: hookKey(PROMPT_EVENT) in env,
|
|
151
|
+
toolDetails: true,
|
|
152
|
+
toolContent: true,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
// Doctor's read surface for the generic OTLP checks (endpoint/auth/ucid) is the
|
|
158
|
+
// managed env file, read through the primary envFileCodec. The hooks.json layers
|
|
159
|
+
// (enterprise/project/user) are a separate, differently-shaped surface; their
|
|
160
|
+
// inspection is tracked as a follow-up.
|
|
161
|
+
const HIERARCHY = [
|
|
162
|
+
{ id: 'projectLocal', label: 'Project (local)', path: CONFIG_LOCAL, kind: 'file' },
|
|
163
|
+
{ id: 'user', label: 'User (global)', path: CONFIG_GLOBAL, kind: 'file' },
|
|
164
|
+
];
|
|
165
|
+
export const cursor = {
|
|
166
|
+
name: 'cursor',
|
|
167
|
+
displayName: 'Cursor',
|
|
168
|
+
paths: {
|
|
169
|
+
local: CONFIG_LOCAL,
|
|
170
|
+
global: CONFIG_GLOBAL,
|
|
171
|
+
},
|
|
172
|
+
// A Cursor session with an empty UCID never surfaces on the Use Cases page, so
|
|
173
|
+
// mint one at setup when the user gives none — the runs land as an unbound
|
|
174
|
+
// UCID they can assign to a use case (same rationale as Codex, MAI-1382).
|
|
175
|
+
autoUcid: true,
|
|
176
|
+
runInstruction: 'cursor (restart any open window so the hooks reload)',
|
|
177
|
+
detect: () => hasPath(join(homedir(), '.cursor')) || hasBinary('cursor'),
|
|
178
|
+
codec: envFileCodec,
|
|
179
|
+
managedEnvKeys: CONFIG_MANAGED_KEYS,
|
|
180
|
+
hierarchy: HIERARCHY,
|
|
181
|
+
buildEnv,
|
|
182
|
+
parseEnv,
|
|
183
|
+
collectChecks,
|
|
184
|
+
normalizeForGenericChecks,
|
|
185
|
+
additionalWrites: [hooksWrite],
|
|
186
|
+
// Hook scripts copied to ~/.mainwave/hooks/ before the hooks.json write, so the
|
|
187
|
+
// registered command never points at a script that isn't there yet.
|
|
188
|
+
bundledHookScripts: ['marker-core.mjs', 'vocabulary.mjs', 'cursor-otlp.mjs'],
|
|
189
|
+
// Doctor's read surface for the hook registration — every hooks.json layer,
|
|
190
|
+
// including the enterprise tier the wizard never writes.
|
|
191
|
+
behaviourHooks: {
|
|
192
|
+
layers: HOOKS_LAYERS,
|
|
193
|
+
codec: cursorHooksJsonCodec,
|
|
194
|
+
script: 'cursor-otlp.mjs',
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
//# sourceMappingURL=cursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor.js","sourceRoot":"","sources":["../../src/adapters/cursor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACjG,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAW5C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,MAAM,YAAY,GAAG,qBAAqB,CAAA;AAE1C,6EAA6E;A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;AAED,MAAM,CAAC,MAAM,MAAM,GAAY;IAC7B,IAAI,EAAE,QAAQ;IACd,WAAW,EAAE,QAAQ;IACrB,KAAK,EAAE;QACL,KAAK,EAAE,YAAY;QACnB,MAAM,EAAE,aAAa;KACtB;IACD,+EAA+E;IAC/E,2EAA2E;IAC3E,0EAA0E;IAC1E,QAAQ,EAAE,IAAI;IACd,cAAc,EAAE,sDAAsD;IACtE,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC;IACxE,KAAK,EAAE,YAAY;IACnB,cAAc,EAAE,mBAAmB;IACnC,SAAS,EAAE,SAAS;IACpB,QAAQ;IACR,QAAQ;IACR,aAAa;IACb,yBAAyB;IACzB,gBAAgB,EAAE,CAAC,UAAU,CAAC;IAC9B,gFAAgF;IAChF,oEAAoE;IACpE,kBAAkB,EAAE,CAAC,iBAAiB,EAAE,gBAAgB,EAAE,iBAAiB,CAAC;IAC5E,4EAA4E;IAC5E,yDAAyD;IACzD,cAAc,EAAE;QACd,MAAM,EAAE,YAAY;QACpB,KAAK,EAAE,oBAAoB;QAC3B,MAAM,EAAE,iBAAiB;KAC1B;CACF,CAAA"}
|
package/dist/adapters/index.js
CHANGED
|
@@ -3,12 +3,16 @@ import { claudeDesktop } from './claude-desktop.js';
|
|
|
3
3
|
import { codexCli } from './codex-cli.js';
|
|
4
4
|
import { copilotChat } from './copilot-chat.js';
|
|
5
5
|
import { copilotCli } from './copilot-cli.js';
|
|
6
|
+
import { cursor } from './cursor.js';
|
|
7
|
+
import { cursorEnterprise } from './cursor-enterprise.js';
|
|
6
8
|
export const adapters = {
|
|
7
9
|
[claudeCode.name]: claudeCode,
|
|
8
10
|
[claudeDesktop.name]: claudeDesktop,
|
|
9
11
|
[codexCli.name]: codexCli,
|
|
10
12
|
[copilotChat.name]: copilotChat,
|
|
11
13
|
[copilotCli.name]: copilotCli,
|
|
14
|
+
[cursor.name]: cursor,
|
|
15
|
+
[cursorEnterprise.name]: cursorEnterprise,
|
|
12
16
|
};
|
|
13
17
|
export const adapterNames = () => Object.keys(adapters).sort();
|
|
14
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAIzD,MAAM,CAAC,MAAM,QAAQ,GAA4B;IAC/C,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,UAAU;IAC7B,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,aAAa;IACnC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ;IACzB,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,WAAW;IAC/B,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,UAAU;IAC7B,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM;IACrB,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,gBAAgB;CAC1C,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,GAAa,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,qDAAqD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.gen.js","sourceRoot":"","sources":["../../src/api/types.gen.ts"],"names":[],"mappings":"AAAA,qDAAqD"}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { color, renderDiff } from './format.js';
|
|
4
|
+
import { buildHookGroups, copyHookScripts, describeMarkersPlan, hookScriptFiles, planMarkers, prepareMarkersFile, readPackagedMatchers, scanForMarkers, } from './markers.js';
|
|
5
|
+
import { applyUpdate, prepareUpdate, readExistingEnv } from './settings.js';
|
|
6
|
+
import { say } from './ui.js';
|
|
7
|
+
import { VERSION } from './version.js';
|
|
8
|
+
/**
|
|
9
|
+
* Everything between "the developer has answered" and "the files are on disk".
|
|
10
|
+
*
|
|
11
|
+
* Split out of the wizard in MAI-1422 so one interview can drive several tools:
|
|
12
|
+
* the wizard collects answers once, then calls `planAdapter` per selected
|
|
13
|
+
* adapter, previews every plan, takes ONE confirmation, and writes them all.
|
|
14
|
+
* Nothing here prompts.
|
|
15
|
+
*/
|
|
16
|
+
const hasAnyChange = (diff) => diff.added.length > 0 || diff.changed.length > 0 || diff.removed.length > 0;
|
|
17
|
+
const writeTargets = (adapter, scope) => ({
|
|
18
|
+
primary: scope === 'local' ? adapter.paths.local : adapter.paths.global,
|
|
19
|
+
additional: (adapter.additionalWrites ?? []).map((aw) => ({
|
|
20
|
+
aw,
|
|
21
|
+
path: scope === 'local' ? (aw.localPath ?? aw.path) : aw.path,
|
|
22
|
+
})),
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Values already on disk for this adapter, used to pre-fill prompts on a re-run.
|
|
26
|
+
*
|
|
27
|
+
* Reads the primary file plus every `additionalWrites` file — copilot-chat keeps
|
|
28
|
+
* collectorUrl + optIns in settings.json but apiKey/UCID only in its env file, so
|
|
29
|
+
* reading just the primary would re-prompt for them on every re-run. Primary wins
|
|
30
|
+
* on conflict; additionals fill gaps.
|
|
31
|
+
*/
|
|
32
|
+
export const readPrefill = async (adapter, scope) => {
|
|
33
|
+
const { primary, additional } = writeTargets(adapter, scope);
|
|
34
|
+
const primaryEnv = await readExistingEnv(primary, adapter.codec);
|
|
35
|
+
const values = primaryEnv ? adapter.parseEnv(primaryEnv) : {};
|
|
36
|
+
const foundIn = primaryEnv ? [primary] : [];
|
|
37
|
+
for (const { aw, path } of additional) {
|
|
38
|
+
const awEnv = await readExistingEnv(path, aw.codec);
|
|
39
|
+
if (!awEnv)
|
|
40
|
+
continue;
|
|
41
|
+
const parsed = aw.parse(awEnv);
|
|
42
|
+
let usedAny = false;
|
|
43
|
+
for (const key of ['ucid', 'collectorUrl', 'apiKey', 'optIns', 'userEmail']) {
|
|
44
|
+
if (values[key] === undefined && parsed[key] !== undefined) {
|
|
45
|
+
// Each field is independently optional, and the union of the two shapes
|
|
46
|
+
// is wider than any single key's type — assign through a narrowed alias.
|
|
47
|
+
Object.assign(values, { [key]: parsed[key] });
|
|
48
|
+
usedAny = true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (usedAny)
|
|
52
|
+
foundIn.push(path);
|
|
53
|
+
}
|
|
54
|
+
return { values, foundIn };
|
|
55
|
+
};
|
|
56
|
+
/** Merge of every selected adapter's on-disk values; earlier adapters win. */
|
|
57
|
+
export const mergePrefills = (prefills) => {
|
|
58
|
+
const values = {};
|
|
59
|
+
const foundIn = [];
|
|
60
|
+
for (const p of prefills) {
|
|
61
|
+
for (const [key, value] of Object.entries(p.values)) {
|
|
62
|
+
if (value !== undefined && values[key] === undefined) {
|
|
63
|
+
Object.assign(values, { [key]: value });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
foundIn.push(...p.foundIn);
|
|
67
|
+
}
|
|
68
|
+
return { values, foundIn };
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* The UCID this adapter should be configured with. `autoUcid` adapters are
|
|
72
|
+
* invisible without one (an empty UCID never surfaces on the Use Cases page), so
|
|
73
|
+
* they fall back to the run's generated id — one id shared by every such adapter
|
|
74
|
+
* in the pass, so a machine's tools land on a single unbound UCID rather than one
|
|
75
|
+
* each (MAI-1382).
|
|
76
|
+
*/
|
|
77
|
+
const ucidFor = (adapter, answers) => answers.ucid ?? (adapter.autoUcid ? answers.generatedUcid : undefined);
|
|
78
|
+
/** A UCID for the `autoUcid` adapters in this pass, minted only if one is needed. */
|
|
79
|
+
export const mintUcidIfNeeded = (adapters, ucid) => ucid === undefined && adapters.some((a) => a.autoUcid) ? randomUUID() : undefined;
|
|
80
|
+
/**
|
|
81
|
+
* Builds every file write this adapter needs, without touching disk. Marker
|
|
82
|
+
* hooks are folded in here: remove everything the CLI owns (any prior shape),
|
|
83
|
+
* then append fresh groups from the packaged matchers — or nothing, when opted
|
|
84
|
+
* out. Claude Code co-locates hooks in its settings file (spliced into the
|
|
85
|
+
* primary write); Codex loads them from a sibling hooks.json, which gets its own.
|
|
86
|
+
*/
|
|
87
|
+
export const planAdapter = async (adapter, answers) => {
|
|
88
|
+
const { scope } = answers;
|
|
89
|
+
const { primary, additional } = writeTargets(adapter, scope);
|
|
90
|
+
const input = {
|
|
91
|
+
ucid: ucidFor(adapter, answers),
|
|
92
|
+
collectorUrl: answers.collectorUrl,
|
|
93
|
+
apiKey: answers.apiKey,
|
|
94
|
+
optIns: answers.optIns,
|
|
95
|
+
userEmail: adapter.injectsIdentity ? answers.userEmail : undefined,
|
|
96
|
+
};
|
|
97
|
+
const primaryUpdate = await prepareUpdate({
|
|
98
|
+
path: primary,
|
|
99
|
+
newEnv: adapter.buildEnv(input),
|
|
100
|
+
managedKeys: adapter.managedEnvKeys,
|
|
101
|
+
codec: adapter.codec,
|
|
102
|
+
});
|
|
103
|
+
const markersOn = adapter.markers ? answers.markers : null;
|
|
104
|
+
let markersPlan = null;
|
|
105
|
+
let hookFiles = [];
|
|
106
|
+
let separateMarkersUpdate = null;
|
|
107
|
+
let markersCarrier = null;
|
|
108
|
+
if (markersOn !== null) {
|
|
109
|
+
const matchers = await readPackagedMatchers();
|
|
110
|
+
hookFiles = hookScriptFiles(matchers);
|
|
111
|
+
const groups = markersOn
|
|
112
|
+
? buildHookGroups(matchers, VERSION, undefined, undefined, adapter.markers?.runtimeTool)
|
|
113
|
+
: [];
|
|
114
|
+
const hooksFile = adapter.markers?.hooksFile;
|
|
115
|
+
if (hooksFile) {
|
|
116
|
+
const hooksPath = scope === 'local' ? (hooksFile.localPath ?? hooksFile.path) : hooksFile.path;
|
|
117
|
+
const prepared = await prepareMarkersFile(hooksPath, hooksFile.codec, groups);
|
|
118
|
+
markersPlan = prepared.plan;
|
|
119
|
+
separateMarkersUpdate = prepared.update;
|
|
120
|
+
markersCarrier = prepared.update;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
markersPlan = planMarkers(primaryUpdate.next, groups);
|
|
124
|
+
primaryUpdate.next = markersPlan.next;
|
|
125
|
+
markersCarrier = primaryUpdate;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const additionalUpdates = await Promise.all(additional.map(({ aw, path }) => prepareUpdate({
|
|
129
|
+
path,
|
|
130
|
+
newEnv: aw.build(input),
|
|
131
|
+
managedKeys: aw.managedKeys,
|
|
132
|
+
codec: aw.codec,
|
|
133
|
+
mode: aw.mode,
|
|
134
|
+
})));
|
|
135
|
+
const labeled = [
|
|
136
|
+
{ label: primary, update: primaryUpdate },
|
|
137
|
+
...(separateMarkersUpdate
|
|
138
|
+
? [{ label: separateMarkersUpdate.path, update: separateMarkersUpdate }]
|
|
139
|
+
: []),
|
|
140
|
+
...additionalUpdates.map((update, i) => ({
|
|
141
|
+
label: `${additional[i].aw.label} (${update.path})`,
|
|
142
|
+
update,
|
|
143
|
+
})),
|
|
144
|
+
];
|
|
145
|
+
const markersChanged = markersPlan?.changed ?? false;
|
|
146
|
+
const changed = labeled.filter(({ update }) => hasAnyChange(update.diff) || (update === markersCarrier && markersChanged));
|
|
147
|
+
return {
|
|
148
|
+
adapter,
|
|
149
|
+
primaryPath: primary,
|
|
150
|
+
input,
|
|
151
|
+
changed,
|
|
152
|
+
markersOn,
|
|
153
|
+
markersPlan,
|
|
154
|
+
markersCarrier,
|
|
155
|
+
hookFiles,
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
/** The masked preview for one adapter's plan. Prints nothing when nothing changes. */
|
|
159
|
+
export const renderPlan = (plan) => {
|
|
160
|
+
if (plan.changed.length === 0) {
|
|
161
|
+
say('');
|
|
162
|
+
say(color.dim(`${plan.adapter.displayName}: no changes needed in ${plan.primaryPath}.`));
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
for (const { label, update } of plan.changed) {
|
|
166
|
+
say('');
|
|
167
|
+
say(color.bold(`Changes to ${label}:`));
|
|
168
|
+
const body = renderDiff(update.diff);
|
|
169
|
+
if (body)
|
|
170
|
+
say(body);
|
|
171
|
+
if (update === plan.markersCarrier && plan.markersPlan?.changed) {
|
|
172
|
+
for (const line of describeMarkersPlan(plan.markersPlan)) {
|
|
173
|
+
const painted = line.startsWith('+')
|
|
174
|
+
? color.green(line)
|
|
175
|
+
: line.startsWith('-')
|
|
176
|
+
? color.red(line)
|
|
177
|
+
: color.dim(line);
|
|
178
|
+
say(painted);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
export const planHasChanges = (plans) => plans.some((p) => p.changed.length > 0);
|
|
184
|
+
/**
|
|
185
|
+
* Writes one adapter's plan. Hook scripts land before the settings that
|
|
186
|
+
* reference them, so a registered command never points at a missing script; a
|
|
187
|
+
* failed copy aborts before any settings write. A failed secondary write stops
|
|
188
|
+
* the chain and reports — no rollback of the primary (the user can re-run, and
|
|
189
|
+
* the partial state is visible in the output).
|
|
190
|
+
*/
|
|
191
|
+
export const writePlan = async (plan) => {
|
|
192
|
+
const scripts = [
|
|
193
|
+
...(plan.markersOn ? plan.hookFiles : []),
|
|
194
|
+
...(plan.adapter.bundledHookScripts ?? []),
|
|
195
|
+
];
|
|
196
|
+
if (scripts.length > 0) {
|
|
197
|
+
const dest = await copyHookScripts(scripts);
|
|
198
|
+
say('');
|
|
199
|
+
say(plan.changed.length === 0
|
|
200
|
+
? color.dim(`Hook scripts refreshed in ${dest}.`)
|
|
201
|
+
: color.green(`✓ Hook scripts installed to ${dest}`));
|
|
202
|
+
}
|
|
203
|
+
for (const { update } of plan.changed) {
|
|
204
|
+
const result = await applyUpdate(update);
|
|
205
|
+
say('');
|
|
206
|
+
say(color.green(`✓ Wrote ${result.written}`));
|
|
207
|
+
if (result.backupPath) {
|
|
208
|
+
say(color.dim(` backup: ${result.backupPath}`));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* After a markers decision, look at every OTHER settings layer for marker
|
|
214
|
+
* hooks and say what their coexistence means. Claude Code merges hooks across
|
|
215
|
+
* layers and dedupes identical handlers, so a CLI install at both scopes is
|
|
216
|
+
* fine (identical commands run once) — but the internal installer's commands
|
|
217
|
+
* differ, so those DO double-fire, and a managed-tier install can't be removed
|
|
218
|
+
* without sudo. Detection + a plain warning is the honest ceiling here.
|
|
219
|
+
*/
|
|
220
|
+
export const printMarkerCoexistenceNotes = async (adapter, targetPath) => {
|
|
221
|
+
const scans = await scanForMarkers(adapter.hierarchy);
|
|
222
|
+
const others = scans.filter((s) => resolve(s.path) !== resolve(targetPath));
|
|
223
|
+
for (const s of others) {
|
|
224
|
+
const hasInternal = s.groups.some((g) => g.ownership === 'internal');
|
|
225
|
+
const hasCli = s.groups.some((g) => g.ownership === 'cli');
|
|
226
|
+
if (hasInternal) {
|
|
227
|
+
say('');
|
|
228
|
+
say(color.yellow(`Warning: ${s.path} also installs marker hooks (internal installer). Its commands\n` +
|
|
229
|
+
"differ from the CLI's, so every ticket/PR marker emits TWICE and is\n" +
|
|
230
|
+
'double-counted. Remove that install (tools/claude-managed-settings README\n' +
|
|
231
|
+
'§ Uninstall) before relying on the counts.'));
|
|
232
|
+
}
|
|
233
|
+
else if (hasCli) {
|
|
234
|
+
say('');
|
|
235
|
+
say(color.dim(`Note: ${s.path} also carries CLI-managed marker hooks. Identical handlers run\n` +
|
|
236
|
+
'once, so counts stay correct; `mainwave-cli doctor` flags them if they drift.'));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* The closing "what do I do now" block for one adapter: its own instructions
|
|
242
|
+
* snippet when it has one, otherwise its `runInstruction`. An adapter with
|
|
243
|
+
* neither prints nothing — before MAI-1422 the fallback told every user to run
|
|
244
|
+
* `claude`, which is wrong after a Codex or Copilot setup.
|
|
245
|
+
*/
|
|
246
|
+
export const printPostSetup = (plan, scope) => {
|
|
247
|
+
const snippet = plan.adapter.printPostSetupInstructions?.(plan.input, scope);
|
|
248
|
+
if (snippet) {
|
|
249
|
+
say('');
|
|
250
|
+
say(snippet);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (plan.adapter.runInstruction) {
|
|
254
|
+
say('');
|
|
255
|
+
say(`Next for ${plan.adapter.displayName}: run ${color.bold(plan.adapter.runInstruction)}.`);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
//# sourceMappingURL=apply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../src/core/apply.ts"],"names":[],"mappings":"A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