@mainwave/cli 0.6.1 → 0.7.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 +94 -18
- package/dist/adapters/claude-code.js +258 -38
- package/dist/adapters/claude-code.js.map +1 -1
- package/dist/adapters/claude-desktop.js +0 -87
- package/dist/adapters/claude-desktop.js.map +1 -1
- package/dist/adapters/codex-cli.js +0 -65
- package/dist/adapters/codex-cli.js.map +1 -1
- package/dist/adapters/copilot-chat.js +7 -42
- package/dist/adapters/copilot-chat.js.map +1 -1
- package/dist/adapters/copilot-cli.js +7 -32
- package/dist/adapters/copilot-cli.js.map +1 -1
- package/dist/adapters/cursor-enterprise.js +4 -53
- package/dist/adapters/cursor-enterprise.js.map +1 -1
- package/dist/adapters/cursor.js +0 -62
- package/dist/adapters/cursor.js.map +1 -1
- package/dist/api/index.js +0 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/types.gen.js +0 -1
- package/dist/api/types.gen.js.map +1 -1
- package/dist/core/apply.js +73 -97
- package/dist/core/apply.js.map +1 -1
- package/dist/core/auth-commands.js +5 -20
- package/dist/core/auth-commands.js.map +1 -1
- package/dist/core/behaviour-hooks.js +0 -7
- package/dist/core/behaviour-hooks.js.map +1 -1
- package/dist/core/browser.js +0 -18
- package/dist/core/browser.js.map +1 -1
- package/dist/core/codecs/cursor-hooks-json.js +0 -8
- package/dist/core/codecs/cursor-hooks-json.js.map +1 -1
- package/dist/core/codecs/json-flat.js +0 -28
- package/dist/core/codecs/json-flat.js.map +1 -1
- package/dist/core/codecs/json-managed.js +0 -30
- package/dist/core/codecs/json-managed.js.map +1 -1
- package/dist/core/codecs/toml-otel.js +0 -39
- package/dist/core/codecs/toml-otel.js.map +1 -1
- package/dist/core/detect.js +0 -29
- package/dist/core/detect.js.map +1 -1
- package/dist/core/device-login.js +0 -22
- package/dist/core/device-login.js.map +1 -1
- package/dist/core/doctor.js +209 -48
- package/dist/core/doctor.js.map +1 -1
- package/dist/core/edit.js +18 -0
- package/dist/core/edit.js.map +1 -1
- package/dist/core/effective-settings.js +107 -10
- package/dist/core/effective-settings.js.map +1 -1
- package/dist/core/env-command.js +0 -9
- package/dist/core/env-command.js.map +1 -1
- package/dist/core/errors.js +0 -12
- package/dist/core/errors.js.map +1 -1
- package/dist/core/flags.js +0 -13
- package/dist/core/flags.js.map +1 -1
- package/dist/core/format.js +0 -56
- package/dist/core/format.js.map +1 -1
- package/dist/core/git.js +0 -9
- package/dist/core/git.js.map +1 -1
- package/dist/core/headers.js +4 -97
- package/dist/core/headers.js.map +1 -1
- package/dist/core/install-hooks.js +81 -0
- package/dist/core/install-hooks.js.map +1 -0
- package/dist/core/interview.js +25 -151
- package/dist/core/interview.js.map +1 -1
- package/dist/core/keys.js +0 -18
- package/dist/core/keys.js.map +1 -1
- package/dist/core/layer-policy.js +34 -0
- package/dist/core/layer-policy.js.map +1 -0
- package/dist/core/markers.js +219 -117
- package/dist/core/markers.js.map +1 -1
- package/dist/core/pinned-use-case.js +11 -0
- package/dist/core/pinned-use-case.js.map +1 -0
- package/dist/core/platform.js +5 -47
- package/dist/core/platform.js.map +1 -1
- package/dist/core/post-setup.js +7 -18
- package/dist/core/post-setup.js.map +1 -1
- package/dist/core/prompts.js +0 -59
- package/dist/core/prompts.js.map +1 -1
- package/dist/core/settings.js +20 -16
- package/dist/core/settings.js.map +1 -1
- package/dist/core/skills.js +0 -75
- package/dist/core/skills.js.map +1 -1
- package/dist/core/status.js +97 -45
- package/dist/core/status.js.map +1 -1
- package/dist/core/store.js +4 -34
- package/dist/core/store.js.map +1 -1
- package/dist/core/tty.js +0 -9
- package/dist/core/tty.js.map +1 -1
- package/dist/core/ucid.js +0 -13
- package/dist/core/ucid.js.map +1 -1
- package/dist/core/ui.js +0 -11
- package/dist/core/ui.js.map +1 -1
- package/dist/core/use-case.js +3 -49
- package/dist/core/use-case.js.map +1 -1
- package/dist/core/validate.js +0 -5
- package/dist/core/validate.js.map +1 -1
- package/dist/core/verify.js +51 -33
- package/dist/core/verify.js.map +1 -1
- package/dist/core/version.js +0 -3
- package/dist/core/version.js.map +1 -1
- package/dist/core/wizard.js +172 -128
- package/dist/core/wizard.js.map +1 -1
- package/dist/main.js +16 -38
- package/dist/main.js.map +1 -1
- package/hooks/cursor-otlp.mjs +4 -4
- package/hooks/github-pr-marker.mjs +31 -12
- package/hooks/jira-ticket-marker.mjs +46 -27
- package/hooks/linear-ticket-marker.mjs +58 -37
- package/hooks/marker-core.mjs +671 -59
- package/hooks/matchers.json +1 -1
- package/hooks/vocabulary.d.mts +9 -1
- package/hooks/vocabulary.mjs +73 -23
- package/package.json +3 -3
- package/skills/mainwave-instrument/SKILL.md +6 -5
- package/skills/mainwave-instrument/reference/frameworks.md +33 -22
- package/skills/mainwave-instrument/reference/troubleshooting.md +13 -4
- package/skills/mainwave-setup/SKILL.md +22 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Claude Code PostToolUse hook for Linear issue saves
|
|
2
|
+
// Claude Code PostToolUse hook for Linear issue saves.
|
|
3
3
|
//
|
|
4
4
|
// Matches any Linear MCP's issue-save tool. The tool name is `save_issue` on both
|
|
5
5
|
// integrations seen so far; what differs is the server prefix (`mcp__linear__` vs
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
// platform then counts distinct issue keys for a true "tickets filed" number
|
|
16
16
|
// instead of a call count.
|
|
17
17
|
//
|
|
18
|
-
// Shared OTLP plumbing (config resolution,
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
18
|
+
// Shared OTLP plumbing (config resolution, source neutralization, payload
|
|
19
|
+
// build, fail-open emit) lives in ./marker-core.mjs; this file keeps only the
|
|
20
|
+
// ticket-specific extraction and main(). Emits the v2 work-item vocabulary —
|
|
21
|
+
// the issue key (work.item.id, e.g. "ENG-123"), vendor (work.vendor=linear),
|
|
22
|
+
// issue url, operation (the typed event name work.item.created / .updated),
|
|
23
|
+
// and work.instance (the Linear team UUID from the save_issue result's teamId
|
|
24
|
+
// / team.id) — never the ticket title or body. work.instance is best-effort:
|
|
25
|
+
// present when the MCP result carries the team id, omitted when it doesn't.
|
|
26
|
+
// It matches the value the connector emits, so a marker span can reconcile
|
|
27
|
+
// against connector events on a shared instance id (this was first deferred,
|
|
28
|
+
// wrongly assuming a hook couldn't produce it).
|
|
29
29
|
// Fails open and fast so a telemetry hiccup can never block the session.
|
|
30
30
|
|
|
31
31
|
import { homedir } from 'node:os'
|
|
@@ -34,8 +34,12 @@ import { pathToFileURL } from 'node:url'
|
|
|
34
34
|
|
|
35
35
|
import {
|
|
36
36
|
buildMarkerPayload,
|
|
37
|
+
markerOauthAccount,
|
|
37
38
|
emitMarker,
|
|
38
39
|
loadOtelConfig,
|
|
40
|
+
markerCallContext,
|
|
41
|
+
markerHostSource,
|
|
42
|
+
markerManagedDir,
|
|
39
43
|
markerTool,
|
|
40
44
|
makeLog,
|
|
41
45
|
markerResourceAttrs as coreMarkerResourceAttrs,
|
|
@@ -70,13 +74,13 @@ const log = makeLog(process.env.MAINWAVE_HOOK_LOG || join(homedir(), '.mainwave-
|
|
|
70
74
|
|
|
71
75
|
// A source tag the collector does NOT classify as a coding agent, and a service
|
|
72
76
|
// name outside its coding-agent `service.name` allow-list, so the marker lands
|
|
73
|
-
// as an ordinary ("other") span rather than a Claude Code one
|
|
77
|
+
// as an ordinary ("other") span rather than a Claude Code one.
|
|
74
78
|
const MARKER_SOURCE = 'hook.linear'
|
|
75
79
|
const MARKER_SERVICE = 'mainwave.ticket-hook'
|
|
76
80
|
|
|
77
81
|
const KEY = '[A-Z][A-Z0-9]+-\\d+'
|
|
78
82
|
|
|
79
|
-
/** True when `v` is exactly an issue key ("
|
|
83
|
+
/** True when `v` is exactly an issue key ("ENG-123"). Case-insensitive, but the
|
|
80
84
|
* full-string anchor rejects a UUID `id` ("9ca7…" starts non-alpha; a UUID that
|
|
81
85
|
* starts with a letter still fails on the `-\d+$` tail) — so trusting `obj.id`
|
|
82
86
|
* is safe on MCPs that return the UUID there instead of the identifier. */
|
|
@@ -103,7 +107,7 @@ const resultObject = (toolResult) => {
|
|
|
103
107
|
// MCP tool-result wrapper: `{content: [{type:'text', text:'<json>'}], isError}`.
|
|
104
108
|
// Codex returns save_issue this way (Claude Code hands the bare array); unwrap
|
|
105
109
|
// to the content array so the issue JSON inside `text` is parsed, not the
|
|
106
|
-
// wrapper — which carries neither `id` nor `url
|
|
110
|
+
// wrapper — which carries neither `id` nor `url`.
|
|
107
111
|
if (v && typeof v === 'object' && !Array.isArray(v) && Array.isArray(v.content)) {
|
|
108
112
|
v = v.content
|
|
109
113
|
}
|
|
@@ -119,16 +123,16 @@ const resultObject = (toolResult) => {
|
|
|
119
123
|
}
|
|
120
124
|
|
|
121
125
|
/**
|
|
122
|
-
* Pull the Linear issue key (e.g. "
|
|
126
|
+
* Pull the Linear issue key (e.g. "ENG-123") out of a save_issue tool result.
|
|
123
127
|
* For a JSON result object, reads ONLY the authoritative structured fields —
|
|
124
128
|
* `identifier` / `issueIdentifier` / `id`, then the top-level `url`'s issue
|
|
125
129
|
* segment — never the free-text body: a ticket's `description` can reference
|
|
126
|
-
* *other*
|
|
130
|
+
* *other* ENG-XXX tickets (Linear serializes those as `…/issue/ENG-XXX/…`
|
|
127
131
|
* links) and, appearing before the canonical `url`, an earlier blind text scan
|
|
128
|
-
* matched a body reference instead of the ticket actually saved
|
|
129
|
-
* The plain-string fallback ("Issue
|
|
130
|
-
* `issue`-qualified key so a bare token like a model name ("GPT-5") is
|
|
131
|
-
* Returns undefined if none is found.
|
|
132
|
+
* matched a body reference instead of the ticket actually saved.
|
|
133
|
+
* The plain-string fallback ("Issue ENG-123 created") still scans, but requires
|
|
134
|
+
* an `issue`-qualified key so a bare token like a model name ("GPT-5") is
|
|
135
|
+
* ignored. Returns undefined if none is found.
|
|
132
136
|
*/
|
|
133
137
|
export const extractIssueKey = (toolResult) => {
|
|
134
138
|
const obj = resultObject(toolResult)
|
|
@@ -145,10 +149,11 @@ export const extractIssueKey = (toolResult) => {
|
|
|
145
149
|
/**
|
|
146
150
|
* The canonical Linear issue URL from a save_issue result — the top-level `url`
|
|
147
151
|
* field when it points at an issue. Emitted so the platform can link a ticket key
|
|
148
|
-
* out without knowing the workspace slug
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
+
* out without knowing the workspace slug. A URL is not sensitive the way a title
|
|
153
|
+
* or body is, so this keeps the marker's ids-only privacy stance. Reads only the
|
|
154
|
+
* canonical `url` (never the body, which links to *other* tickets — the
|
|
155
|
+
* body-scan trap noted above). Undefined for a non-JSON result or a url that
|
|
156
|
+
* isn't an issue link.
|
|
152
157
|
*/
|
|
153
158
|
export const extractIssueUrl = (toolResult) => {
|
|
154
159
|
const obj = resultObject(toolResult)
|
|
@@ -159,7 +164,7 @@ export const extractIssueUrl = (toolResult) => {
|
|
|
159
164
|
/**
|
|
160
165
|
* The Linear team UUID (work.instance) from a save_issue result — the immutable
|
|
161
166
|
* instance-global id the connector also emits, so a marker span and a connector
|
|
162
|
-
* event on the same team reconcile
|
|
167
|
+
* event on the same team reconcile. The linear-server MCP puts it at
|
|
163
168
|
* top-level `teamId`; some other Linear MCPs nest it at `team.id` — read either.
|
|
164
169
|
* Best-effort: undefined for a non-JSON result or one carrying neither, so the
|
|
165
170
|
* attr is dropped rather than fabricated (the result's `id` is the display KEY,
|
|
@@ -188,16 +193,17 @@ export const detectOp = (toolName, toolInput) => {
|
|
|
188
193
|
return toolInput && toolInput.id ? WORK_OP_UPDATED : WORK_OP_CREATED
|
|
189
194
|
}
|
|
190
195
|
|
|
191
|
-
/** Marker resource attrs with the ticket hook's non-coding source/service
|
|
192
|
-
|
|
193
|
-
|
|
196
|
+
/** Marker resource attrs with the ticket hook's non-coding source/service
|
|
197
|
+
* and, when known, the host tool's source tag. */
|
|
198
|
+
export const markerResourceAttrs = (resourceAttrs, hostSource) =>
|
|
199
|
+
coreMarkerResourceAttrs(resourceAttrs, MARKER_SOURCE, MARKER_SERVICE, hostSource)
|
|
194
200
|
|
|
195
201
|
/** Build the OTLP/JSON payload for one ticket-marker span. The v2 event NAME
|
|
196
202
|
* encodes the operation (work.item.created / work.item.updated); the span
|
|
197
203
|
* self-declares `mainwave.source = hook.linear`, honored verbatim by the
|
|
198
|
-
* collector
|
|
204
|
+
* collector. It stays out of coding-activity segmentation because
|
|
199
205
|
* `hook.*` is outside the CODING_TOOL_SOURCES allowlist and markers are admitted
|
|
200
|
-
* by span NAME
|
|
206
|
+
* by span NAME — not because of the old `other` fallback. `issueUrl`
|
|
201
207
|
* and `instance` are dropped by `buildMarkerPayload` when absent (an older
|
|
202
208
|
* result with no url, or one that carries no team id). */
|
|
203
209
|
export const buildTracePayload = ({
|
|
@@ -206,7 +212,11 @@ export const buildTracePayload = ({
|
|
|
206
212
|
instance,
|
|
207
213
|
op,
|
|
208
214
|
sessionId,
|
|
215
|
+
userEmail,
|
|
216
|
+
userAccountUuid,
|
|
209
217
|
resourceAttrs,
|
|
218
|
+
hostSource,
|
|
219
|
+
callContext,
|
|
210
220
|
nowNs,
|
|
211
221
|
}) =>
|
|
212
222
|
buildMarkerPayload({
|
|
@@ -220,9 +230,13 @@ export const buildTracePayload = ({
|
|
|
220
230
|
[ATTR_WORK_INSTANCE]: instance,
|
|
221
231
|
},
|
|
222
232
|
sessionId,
|
|
233
|
+
userEmail,
|
|
234
|
+
userAccountUuid,
|
|
223
235
|
resourceAttrs,
|
|
224
236
|
source: MARKER_SOURCE,
|
|
225
237
|
service: MARKER_SERVICE,
|
|
238
|
+
hostSource,
|
|
239
|
+
callContext,
|
|
226
240
|
nowNs,
|
|
227
241
|
})
|
|
228
242
|
|
|
@@ -246,11 +260,9 @@ const main = async () => {
|
|
|
246
260
|
const op = detectOp(payload.tool_name, payload.tool_input)
|
|
247
261
|
|
|
248
262
|
const cwd = payload.cwd || process.cwd()
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
markerTool(process.argv),
|
|
253
|
-
)
|
|
263
|
+
const tool = markerTool(process.argv)
|
|
264
|
+
const managedDir = markerManagedDir(process.argv)
|
|
265
|
+
const { endpoint, bearer, resourceAttrs } = loadOtelConfig(cwd, process.env, tool, managedDir)
|
|
254
266
|
log(
|
|
255
267
|
`issue=${issueKey} op=${op} endpoint=${endpoint ? 'set' : 'MISSING'} ` +
|
|
256
268
|
`bearer=${bearer ? 'set' : 'MISSING'} ucid=${resourceAttrs['mainwave.ucid'] || 'MISSING'}`,
|
|
@@ -259,6 +271,11 @@ const main = async () => {
|
|
|
259
271
|
log('skip: collector endpoint/bearer not found in settings or env')
|
|
260
272
|
return
|
|
261
273
|
}
|
|
274
|
+
// Read only once the emit is certain: `.claude.json` can run to megabytes.
|
|
275
|
+
const { email: userEmail, accountUuid: userAccountUuid } = markerOauthAccount(tool, {
|
|
276
|
+
cwd,
|
|
277
|
+
managedDir,
|
|
278
|
+
})
|
|
262
279
|
|
|
263
280
|
const body = buildTracePayload({
|
|
264
281
|
issueKey,
|
|
@@ -266,7 +283,11 @@ const main = async () => {
|
|
|
266
283
|
instance,
|
|
267
284
|
op,
|
|
268
285
|
sessionId: payload.session_id,
|
|
286
|
+
userEmail,
|
|
287
|
+
userAccountUuid,
|
|
269
288
|
resourceAttrs,
|
|
289
|
+
hostSource: markerHostSource(tool),
|
|
290
|
+
callContext: markerCallContext(tool, payload),
|
|
270
291
|
nowNs: BigInt(Date.now()) * 1_000_000n,
|
|
271
292
|
})
|
|
272
293
|
await emitMarker({ endpoint, bearer, body, label: issueKey, log })
|
|
@@ -276,7 +297,7 @@ const main = async () => {
|
|
|
276
297
|
// Use pathToFileURL so a script path with characters that percent-encode in a
|
|
277
298
|
// file URL (e.g. the space in the managed install dir "/Library/Application
|
|
278
299
|
// Support/…") still matches import.meta.url — a raw `file://${argv[1]}` template
|
|
279
|
-
// keeps the literal space, never matches, and silently skips main().
|
|
300
|
+
// keeps the literal space, never matches, and silently skips main().
|
|
280
301
|
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
281
302
|
await main()
|
|
282
303
|
}
|