@mainwave/cli 0.14.0 → 0.15.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/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { claudeCodeFor } from './adapters/claude-code.js';
2
- import { codexCliFor, homeTarget, parseProfileName, profileTarget } from './adapters/codex-cli.js';
2
+ import { CODEX_ADAPTER_NAME, codexCliFor, homeTarget, parseProfileName, profileTarget, } from './adapters/codex-cli.js';
3
3
  import { adapterNames, adapters } from './adapters/index.js';
4
4
  import { commandFlags, detailsBlock, isCommand, usageBlock } from './commands.js';
5
5
  import { runLogin, runLogout, runWhoami } from './core/auth-commands.js';
@@ -300,10 +300,16 @@ const HANDLERS = {
300
300
  if (named.length === 0) {
301
301
  throw new WizardAbort('--remove needs the tools to remove, e.g. `setup kiro-ide --remove`');
302
302
  }
303
+ let targets = named;
303
304
  if (flags.has('profile')) {
304
- throw new WizardAbort('--profile does not combine with --remove');
305
+ const profile = parseProfileName(flags.value('profile'));
306
+ if (!named.some((a) => a.name === CODEX_ADAPTER_NAME)) {
307
+ throw new WizardAbort('--profile applies to Codex only: name codex among the tools, e.g. ' +
308
+ `\`setup codex --remove --profile ${profile}\``);
309
+ }
310
+ targets = named.map((a) => a.name === CODEX_ADAPTER_NAME ? codexCliFor(profileTarget(profile)) : a);
305
311
  }
306
- return await runRemove(named, {
312
+ return await runRemove(targets, {
307
313
  yes: flags.bool('yes') === true,
308
314
  json: flags.bool('json') === true,
309
315
  });
@@ -15,7 +15,7 @@
15
15
  // across inserts, so each span is sent once, when it ends, with the times the
16
16
  // hook process read. A small per-session state file under
17
17
  // `~/.mainwave/state/codex-turns/` holds what is open between events; it is
18
- // deleted once nothing is open.
18
+ // deleted once nothing is open and no abandoned turn awaits a late Stop.
19
19
  //
20
20
  // Sent: session, turn and agent ids, agent type, working directory, a tool
21
21
  // name for a permission wait, and times. Never the prompt, the assistant
@@ -53,6 +53,7 @@ import {
53
53
  markerResourceAttrs,
54
54
  markerTool,
55
55
  opaqueIdExact,
56
+ stampActivity,
56
57
  stringAttr,
57
58
  } from './marker-core.mjs'
58
59
  import {
@@ -79,6 +80,12 @@ export const STATE_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000
79
80
 
80
81
  const LOCK_WAIT_MS = 1500
81
82
  const LOCK_STALE_MS = 10_000
83
+ /** A main SessionStart abandons an open turn only when the turn started at
84
+ * least this long before it. Codex fires SessionStart with the run's first
85
+ * prompt, and their hooks lock in either order milliseconds apart. It is
86
+ * also how long after the abandoning event a Stop or Interrupt for the
87
+ * abandoned turn may read its clock and still end it (§ `applyEvent`). */
88
+ export const SESSION_START_STALE_MS = 5000
82
89
 
83
90
  /** Codex runs the Stop and Interrupt groups synchronously (`codex exec` exits
84
91
  * without waiting for an async hook), so it waits for this feature at the
@@ -100,7 +107,8 @@ export const stateDir = (argv) =>
100
107
 
101
108
  /** `abandoned` is the last turn a new prompt or session start abandoned, kept
102
109
  * so a Stop or Interrupt for it that locks late can still end it (§
103
- * `applyEvent`). It does not keep the state file alive (§ `isEmptyState`). */
110
+ * `applyEvent`). It keeps the state file until that Stop or a later turn's
111
+ * own end clears it (§ `isEmptyState`). */
104
112
  export const emptyState = () => ({ v: 1, turn: null, subagents: {}, waits: {}, abandoned: null })
105
113
 
106
114
  /** A well-formed state read back from disk, else an empty one. */
@@ -125,6 +133,17 @@ export const parseState = (text) => {
125
133
  const OPAQUE_NAME_RE = /^[A-Za-z0-9_.:/ -]{1,128}$/
126
134
  const opaqueName = (v) => (typeof v === 'string' && OPAQUE_NAME_RE.test(v) ? v : undefined)
127
135
 
136
+ /** SessionStart's `source` values this feature knows; any other reads as none. */
137
+ const SESSION_SOURCES = new Set(['startup', 'resume', 'clear', 'compact', 'fork'])
138
+
139
+ /** Sources whose SessionStart abandons nothing. A `startup`, `fork` or
140
+ * `clear` session id is new (a fork records its parent thread, and `/clear`
141
+ * starts a new chat), so its state holds only this run's events, which may
142
+ * have locked first. A `compact` start keeps the id inside the same running
143
+ * process, so the open turn is live. Only `resume` (or no known source) can
144
+ * find a killed run's leftovers. */
145
+ const ABANDONS_NOTHING = new Set(['startup', 'fork', 'clear', 'compact'])
146
+
128
147
  /** The only fields of the hook input this feature reads. */
129
148
  export const readInput = (payload, event) => ({
130
149
  event,
@@ -133,6 +152,7 @@ export const readInput = (payload, event) => ({
133
152
  agentId: opaqueIdExact(payload?.agent_id),
134
153
  agentType: opaqueName(payload?.agent_type),
135
154
  toolName: opaqueName(payload?.tool_name),
155
+ source: SESSION_SOURCES.has(payload?.source) ? payload.source : undefined,
136
156
  cwd:
137
157
  typeof payload?.cwd === 'string' && isAbsolute(payload.cwd) && payload.cwd.length <= 4096
138
158
  ? payload.cwd
@@ -147,16 +167,28 @@ export const readInput = (payload, event) => ({
147
167
  * What closes what (the contract with the collector):
148
168
  *
149
169
  * - Only an event with no `agent_id` opens or closes a main turn. A new
150
- * UserPromptSubmit or a SessionStart finds a turn still open and abandons
151
- * it, ending it at the last event it saw, so a killed Codex never stretches
152
- * a turn across the developer's absence; one that saw no later event is
153
- * dropped.
170
+ * UserPromptSubmit finds a turn still open and abandons it, ending it at the
171
+ * last event it saw, so a killed Codex never stretches a turn across the
172
+ * developer's absence; one that saw no later event is dropped. A main
173
+ * SessionStart whose `source` is `startup`, `fork`, `clear` or `compact`
174
+ * abandons nothing: the session id is new, or (`compact`) the same running
175
+ * process, so whatever is open is this run's own. Any other main
176
+ * SessionStart (`resume`, or none) abandons the same way
177
+ * only a turn that started more than `SESSION_START_STALE_MS` before it:
178
+ * Codex fires it together with the run's first UserPromptSubmit, so a turn
179
+ * just opened may be that prompt's own, and the prompt abandons a stale
180
+ * one anyway.
181
+ * - A main event whose turn id names another turn than the open one belongs
182
+ * to the next run, locking before that run's prompt. It neither extends
183
+ * the open turn's last event nor ends a wait under it, and as a
184
+ * PermissionRequest it opens no wait.
154
185
  * - A permission wait ends at the first later PostToolUse, PreModelRequest,
155
- * PermissionRequest, Stop, Interrupt, SubagentStop or SessionStart of the
156
- * same session and agent (a main SessionStart ends a main wait by abandoning
157
- * its turn). PreToolUse is not one: Codex runs it before the approval, so it
158
- * never ends that call's wait. PostModelRequest is not one either, because
159
- * the PreModelRequest before it already did.
186
+ * PermissionRequest, Stop, Interrupt or SubagentStop of the same session
187
+ * and agent, or a subagent's own SessionStart (a main SessionStart ends a
188
+ * main wait by abandoning its stale turn). PreToolUse is not one: Codex
189
+ * runs it before the approval, so it never ends that call's wait.
190
+ * PostModelRequest is not one either, because the PreModelRequest before it
191
+ * already did.
160
192
  * - A turn that ends takes its open waits (end = the turn's end) and any
161
193
  * subagent still open (abandoned, end = its last event) with it.
162
194
  * - Hooks read the clock before they take the state lock, so events can reach
@@ -166,14 +198,18 @@ export const readInput = (payload, event) => ({
166
198
  * that turn's Stop. The reverse, an async UserPromptSubmit locking after its
167
199
  * own synchronous Stop, needs a turn that finishes faster than Node starts.
168
200
  * These guards cover the reorderings seen or reviewed, not every possible
169
- * one: a SessionStart or UserPromptSubmit abandons only a turn or subagent
170
- * that started earlier; a Stop or Interrupt without a turn id closes only a
171
- * turn that started no later than itself; one whose turn id names the turn
172
- * last abandoned sends that turn again with its real end reason and end (the
173
- * span ids are the same, so the row replaces the abandoned one); a
174
- * PermissionRequest or SubagentStart older than the open turn, or with none
175
- * open, is dropped; and an event ends only a wait that started no later than
176
- * itself, except that a turn's or subagent's own end takes its waits.
201
+ * one: a UserPromptSubmit abandons only a turn that started earlier; a
202
+ * `startup`, `fork`, `clear` or `compact` SessionStart abandons nothing,
203
+ * and any other only a subagent that started earlier or a turn that
204
+ * started well before; a Stop or Interrupt without a turn id closes only a
205
+ * turn that started no later than itself; a Stop or Interrupt whose turn id names
206
+ * the turn last abandoned, and that read its clock no more than
207
+ * `SESSION_START_STALE_MS` after the abandoning event, sends that turn
208
+ * again with its real end reason and end (the span ids are the same, so
209
+ * the row replaces the abandoned one); a PermissionRequest or SubagentStart
210
+ * older than the open turn, or with none open, is dropped; and an event ends only a wait that started no
211
+ * later than itself, except that a turn's or subagent's own end takes its
212
+ * waits.
177
213
  */
178
214
  export const applyEvent = (state, input, now) => {
179
215
  const st = structuredClone(state)
@@ -230,8 +266,12 @@ export const applyEvent = (state, input, now) => {
230
266
  }
231
267
  st.turn = null
232
268
  if (reason === 'abandoned') {
233
- st.abandoned = { turnId: t.turnId, startMs: t.startMs, cwd: t.cwd }
269
+ st.abandoned = { turnId: t.turnId, startMs: t.startMs, cwd: t.cwd, atMs: now }
234
270
  if (t.lastMs <= t.startMs) return
271
+ } else {
272
+ // A later turn ended normally, so the abandoned one's Stop, which fires
273
+ // before that turn's prompt, is long past.
274
+ st.abandoned = null
235
275
  }
236
276
  out.push({
237
277
  kind: 'turn',
@@ -244,10 +284,17 @@ export const applyEvent = (state, input, now) => {
244
284
  })
245
285
  }
246
286
 
287
+ // A main event naming another turn is the next run's, locking before that
288
+ // run's prompt: it is no work inside the open turn and ends none of its
289
+ // waits.
290
+ const mismatched = () =>
291
+ st.turn !== null && agentId === undefined && turnId !== undefined && turnId !== st.turn.turnId
292
+ const ofOpenTurn = () => st.turn !== null && !mismatched()
293
+
247
294
  // A subagent's event is also work inside the open main turn, so a turn
248
295
  // abandoned after a kill ends at its subagents' last event too.
249
296
  const touch = () => {
250
- if (st.turn !== null) st.turn.lastMs = Math.max(st.turn.lastMs, now)
297
+ if (ofOpenTurn()) st.turn.lastMs = Math.max(st.turn.lastMs, now)
251
298
  if (agentId !== undefined && st.subagents[agentId] !== undefined) {
252
299
  st.subagents[agentId].lastMs = Math.max(st.subagents[agentId].lastMs, now)
253
300
  }
@@ -282,8 +329,21 @@ export const applyEvent = (state, input, now) => {
282
329
  // With no turn id, only a turn that started no later than this event
283
330
  // can be the one it ends.
284
331
  if (st.turn.startMs <= now) closeTurn(now, reason, event)
285
- } else if (a !== null && turnId === a.turnId && a.startMs <= now) {
332
+ } else if (
333
+ a !== null &&
334
+ turnId === a.turnId &&
335
+ a.startMs <= now &&
336
+ // A record written by an earlier release has no `atMs`; its late
337
+ // Stop is refused, so the abandoned row stays.
338
+ Number.isFinite(a.atMs) &&
339
+ now <= a.atMs + SESSION_START_STALE_MS
340
+ ) {
286
341
  // The turn a queued prompt abandoned before this event took the lock.
342
+ // Codex submits that prompt the moment the turn ends, so the two
343
+ // read their clocks within a Node start of each other. A later one
344
+ // would stretch the turn across a gap, so the abandoned row stays.
345
+ // A Stop that Codex replayed right after a resume would still pass;
346
+ // no replay has been seen, and no clock tells the two apart.
287
347
  st.abandoned = null
288
348
  out.push({
289
349
  kind: 'turn',
@@ -300,8 +360,9 @@ export const applyEvent = (state, input, now) => {
300
360
  case 'PermissionRequest':
301
361
  touch()
302
362
  // None open, or one that started after this request: the request
303
- // belongs to an earlier turn.
304
- if (st.turn === null || now < st.turn.startMs) break
363
+ // belongs to an earlier turn. A main request naming another turn
364
+ // belongs to a later one whose prompt has not locked yet.
365
+ if (!ofOpenTurn() || now < st.turn.startMs) break
305
366
  if (st.waits[key] !== undefined && now < st.waits[key].startMs) break
306
367
  closeWait(key, now, event)
307
368
  st.waits[key] = {
@@ -315,7 +376,7 @@ export const applyEvent = (state, input, now) => {
315
376
  case 'PostToolUse':
316
377
  case 'PreModelRequest':
317
378
  touch()
318
- closeWait(key, now, event)
379
+ if (!mismatched()) closeWait(key, now, event)
319
380
  break
320
381
  case 'SubagentStart':
321
382
  if (agentId === undefined) break
@@ -349,17 +410,27 @@ export const applyEvent = (state, input, now) => {
349
410
  closeWait(key, now, event)
350
411
  break
351
412
  }
352
- // Only what started before this SessionStart belongs to an earlier run.
353
- if (st.turn !== null && st.turn.startMs < now) {
413
+ // A startup, fork or clear session id is new, and a compact start is
414
+ // the same running process, so everything in its state came from this
415
+ // run's own events, which may have locked first: nothing is left over
416
+ // to abandon, whatever the clocks say.
417
+ if (ABANDONS_NOTHING.has(input.source)) break
418
+ // Codex fires SessionStart with the run's first prompt, both hooks
419
+ // async, and either may read the clock first, so a turn that started
420
+ // just before may be this run's own new one: it is left to the next
421
+ // UserPromptSubmit, which abandons it if it is an earlier run's. One
422
+ // that started well before is an earlier run's.
423
+ if (st.turn !== null && st.turn.startMs < now - SESSION_START_STALE_MS) {
354
424
  closeTurn(st.turn.lastMs, 'abandoned', event)
355
425
  }
426
+ if (st.turn !== null) break
356
427
  for (const id of Object.keys(st.subagents)) {
357
428
  if (st.subagents[id].startMs < now) {
358
429
  closeSubagent(id, st.subagents[id].lastMs, 'abandoned', event)
359
430
  }
360
431
  }
361
432
  // Waits live only inside a turn; with none open, any left are stale.
362
- if (st.turn === null) st.waits = {}
433
+ st.waits = {}
363
434
  break
364
435
  default:
365
436
  break
@@ -490,9 +561,13 @@ const writeAtomic = (file, text) => {
490
561
  renameSync(tmp, file)
491
562
  }
492
563
 
493
- /** Nothing open: the state file can go (no file reads back as this). */
564
+ /** Nothing open and no abandoned turn a late Stop may still end: the state
565
+ * file can go (no file reads back as this). */
494
566
  export const isEmptyState = (s) =>
495
- s.turn === null && Object.keys(s.subagents).length === 0 && Object.keys(s.waits).length === 0
567
+ s.turn === null &&
568
+ s.abandoned === null &&
569
+ Object.keys(s.subagents).length === 0 &&
570
+ Object.keys(s.waits).length === 0
496
571
 
497
572
  /** Delete every state file nobody has touched for STATE_MAX_AGE_MS. */
498
573
  export const sweepStale = (dir, nowMs) => {
@@ -538,6 +613,7 @@ export const handle = async (
538
613
 
539
614
  const sync = Object.hasOwn(SYNC_CAPS, name) ? SYNC_CAPS[name] : undefined
540
615
  let closed = []
616
+ let abandonedId
541
617
  const locked = await withLock(
542
618
  file,
543
619
  () => {
@@ -549,6 +625,7 @@ export const handle = async (
549
625
  }
550
626
  const next = applyEvent(before, input, t)
551
627
  closed = next.closed
628
+ abandonedId = next.state.abandoned?.turnId
552
629
  if (isEmptyState(next.state)) {
553
630
  try {
554
631
  unlinkSync(file)
@@ -566,6 +643,20 @@ export const handle = async (
566
643
  return
567
644
  }
568
645
  if (name === 'SessionStart') sweepStale(dir, t)
646
+ // A main Stop or Interrupt that names a turn and found none to end can
647
+ // mean a turn went unsent: log it, so a lost turn leaves a trace. One with
648
+ // no turn id may belong to a turn this run already sent, and one that names
649
+ // the turn just recorded as abandoned has had that turn sent, so neither
650
+ // logs.
651
+ if (
652
+ (name === 'Stop' || name === 'Interrupt') &&
653
+ input.agentId === undefined &&
654
+ input.turnId !== undefined &&
655
+ input.turnId !== abandonedId &&
656
+ !closed.some((c) => c.kind === 'turn')
657
+ ) {
658
+ log(`skip ${name}: no open turn`)
659
+ }
569
660
  if (closed.length === 0) return
570
661
 
571
662
  const tool = markerTool(argv)
@@ -583,7 +674,7 @@ export const handle = async (
583
674
  log(`skip ${closed.length} codex span(s): no Mainwave collector in ${where}`)
584
675
  return
585
676
  }
586
- await emit({
677
+ const status = await emit({
587
678
  endpoint,
588
679
  bearer,
589
680
  body: buildBody(closed, resourceAttrs),
@@ -591,4 +682,6 @@ export const handle = async (
591
682
  log,
592
683
  ...(sync ? { timeoutMs: sync.postTimeoutMs } : {}),
593
684
  })
685
+ // The log also takes skips, so only this sidecar says a turn was delivered.
686
+ stampActivity(status, argv, CODEX_TURNS_LOG)
594
687
  }
@@ -44,17 +44,16 @@ import { dirname, join, resolve } from 'node:path'
44
44
  import { fileURLToPath, pathToFileURL } from 'node:url'
45
45
 
46
46
  import {
47
+ activityMarkerPath,
47
48
  bearerFromHeaders,
48
49
  buildMarkerPayload,
49
50
  emitMarker,
50
- ensureLogDir,
51
51
  hookFlag,
52
- isOkStatus,
53
52
  markerLog,
54
- markerLogPath,
55
53
  parseEnvFile,
56
54
  parseKv,
57
55
  redactForSend,
56
+ stampActivity,
58
57
  } from './marker-core.mjs'
59
58
 
60
59
  const LOG_NAME = 'kiro.log'
@@ -317,17 +316,7 @@ export const spanForPayload = (payload, config, { argv = [], env = process.env }
317
316
  }
318
317
 
319
318
  /** The sidecar whose mtime is the last delivered span — doctor reads it. */
320
- export const activityPath = (argv) => `${markerLogPath(argv, LOG_NAME)}.ok`
321
-
322
- const markDelivered = (argv) => {
323
- try {
324
- const p = activityPath(argv)
325
- ensureLogDir(p)
326
- writeFileSync(p, `${new Date().toISOString()}\n`, { mode: 0o600 })
327
- } catch {
328
- // best-effort, like every log write
329
- }
330
- }
319
+ export const activityPath = (argv) => activityMarkerPath(argv, LOG_NAME)
331
320
 
332
321
  /**
333
322
  * Read stdin up to `max` bytes, keeping the first `head` bytes of a payload
@@ -559,7 +548,7 @@ export const send = async (argv = process.argv) => {
559
548
  // Redacted when it was spooled; one spooled with no rules is checked now.
560
549
  redacted: spooled.redacted === true,
561
550
  })
562
- if (isOkStatus(status)) markDelivered(argv)
551
+ stampActivity(status, argv, LOG_NAME)
563
552
  }
564
553
 
565
554
  // Run only as a script, not when imported by tests.
@@ -112,6 +112,27 @@ export const markerLogPath = (argv, defaultName) =>
112
112
  export const markerLog = (argv, defaultName, maxBytes = LOG_MAX_BYTES) =>
113
113
  makeLog(markerLogPath(argv, defaultName), maxBytes)
114
114
 
115
+ /** The activity sidecar beside a hook's log: `<log>.ok`, one timestamp line a
116
+ * 2xx post rewrites, never appended to. Its mtime is the last successful
117
+ * send, which `doctor` reports as activity; the log's own mtime also moves on
118
+ * a skip or a failure, so it can't say whether anything was delivered. */
119
+ export const activityMarkerPath = (argv, defaultName) => `${markerLogPath(argv, defaultName)}.ok`
120
+
121
+ /** Rewrite the activity sidecar (§ `activityMarkerPath`) when `status` is a
122
+ * 2xx; anything else, no response or a non-2xx, leaves it alone. Best-effort
123
+ * like the log: true when it was written. */
124
+ export const stampActivity = (status, argv, defaultName, now = new Date()) => {
125
+ if (!isOkStatus(status)) return false
126
+ try {
127
+ const path = activityMarkerPath(argv, defaultName)
128
+ ensureLogDir(path)
129
+ writeFileSync(path, `${now.toISOString()}\n`, { mode: 0o600 })
130
+ return true
131
+ } catch {
132
+ return false
133
+ }
134
+ }
135
+
115
136
  /**
116
137
  * The project root whose `.claude/` settings Claude Code loaded for this
117
138
  * session: `CLAUDE_PROJECT_DIR`, which Claude Code sets for every hook. Not the
@@ -202,6 +202,6 @@
202
202
  "optOut": "markers",
203
203
  "hosts": ["codex"],
204
204
  "dataClasses": ["session id, turn id and agent id", "working directory", "start and end times"],
205
- "why": "Closes a turn that was still open when the session started, resumed or forked: the turn is sent ending at the last event it saw, never at the new start, so a killed Codex can't stretch a turn across the developer's absence. It also deletes turn state older than 7 days. It takes no matcher, so it runs for every source (the session-start refresh is a separate group that runs for `startup|resume|fork` only). Async."
205
+ "why": "Closes a turn an earlier run left open when the session resumed (a startup's, fork's or clear's session id is new, and a compaction is the same run, so those close nothing): the turn is sent ending at the last event it saw, never at the new start, so a killed Codex can't stretch a turn across the developer's absence. It also deletes turn state older than 7 days. It takes no matcher, so it runs for every source (the session-start refresh is a separate group that runs for `startup|resume|fork` only). Async."
206
206
  }
207
207
  ]
@@ -55,21 +55,19 @@
55
55
  // so a send that hasn't finished when such a run ends is lost.
56
56
 
57
57
  import { createHash } from 'node:crypto'
58
- import { readFileSync, writeFileSync } from 'node:fs'
58
+ import { readFileSync } from 'node:fs'
59
59
 
60
60
  import {
61
+ activityMarkerPath,
61
62
  boolAttr,
62
63
  buildMarkerPayload,
63
64
  doubleAttr,
64
65
  emitMarker,
65
66
  hookFlag,
66
67
  intAttr,
67
- isOkStatus,
68
68
  loadOtelConfig,
69
- ensureLogDir,
70
69
  markerHostSource,
71
70
  markerLog,
72
- markerLogPath,
73
71
  markerManagedDir,
74
72
  markerOauthAccountPath,
75
73
  markerProjectDir,
@@ -78,6 +76,7 @@ import {
78
76
  oauthAccountFromRecord,
79
77
  onceReaders,
80
78
  parseTraceparent,
79
+ stampActivity,
81
80
  stringAttr,
82
81
  trimmedOrUndefined,
83
82
  } from './marker-core.mjs'
@@ -124,24 +123,12 @@ const LOG_NAME = 'plan-snapshot.log'
124
123
  * `logOk`); it stamps the success sidecar instead (§ `stampSuccess`). */
125
124
  const snapshotLog = (argv) => markerLog(argv, LOG_NAME)
126
125
 
127
- /** The sidecar a 2xx post rewrites: `<log>.ok`, one timestamp line, never
128
- * appended to, so it stays one line however many prompts run. Its mtime is
129
- * the last successful send — what `doctor` reports as activity. */
130
- export const successMarkerPath = (argv) => `${markerLogPath(argv, LOG_NAME)}.ok`
126
+ /** The activity sidecar (§ marker-core `activityMarkerPath`). */
127
+ export const successMarkerPath = (argv) => activityMarkerPath(argv, LOG_NAME)
131
128
 
132
- /** Rewrite the success sidecar when `status` is a 2xx; anything else — no
133
- * response, a non-2xx — never counts as activity. Best-effort, like the log. */
134
- export const stampSuccess = (status, argv = process.argv, now = new Date()) => {
135
- if (!isOkStatus(status)) return false
136
- try {
137
- const path = successMarkerPath(argv)
138
- ensureLogDir(path)
139
- writeFileSync(path, `${now.toISOString()}\n`, { mode: 0o600 })
140
- return true
141
- } catch {
142
- return false
143
- }
144
- }
129
+ /** Rewrite the sidecar on a 2xx (§ marker-core `stampActivity`). */
130
+ export const stampSuccess = (status, argv = process.argv, now = new Date()) =>
131
+ stampActivity(status, argv, LOG_NAME, now)
145
132
 
146
133
  // Non-coding source/service, as for the ticket and PR markers: the span is
147
134
  // about the Anthropic account, not a stretch of coding work.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mainwave/cli",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "description": "Setup wizard for connecting third-party coding tools to Mainwave AI.",
5
5
  "type": "module",
6
6
  "bin": {