@cmodjs/core 5.2.1 → 5.3.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.
Files changed (69) hide show
  1. package/docs/commands.md +2 -2
  2. package/docs/install-steps.md +2 -0
  3. package/docs/jobs.md +1 -1
  4. package/docs/state.md +1 -1
  5. package/docs/testing.md +1 -1
  6. package/docs/ui.md +1 -1
  7. package/jobs/program.d.ts.map +1 -1
  8. package/jobs/program.js +55 -4
  9. package/package.json +1 -1
  10. package/records.d.ts +2 -2
  11. package/records.js +2 -2
  12. package/register.d.ts.map +1 -1
  13. package/register.js +23 -3
  14. package/runtime/claude.d.ts +2 -0
  15. package/runtime/claude.d.ts.map +1 -1
  16. package/runtime/conversations.js +8 -8
  17. package/runtime/deadline.d.ts +2 -0
  18. package/runtime/deadline.d.ts.map +1 -1
  19. package/runtime/deadline.js +17 -0
  20. package/runtime/engine.d.ts +2 -0
  21. package/runtime/engine.d.ts.map +1 -1
  22. package/runtime/hooks.js +2 -2
  23. package/runtime/hotkeys.js +1 -1
  24. package/runtime/installer.js +1 -1
  25. package/runtime/lifecycle.d.ts.map +1 -1
  26. package/runtime/lifecycle.js +102 -74
  27. package/runtime/metadata.js +1 -1
  28. package/runtime/options.js +1 -1
  29. package/runtime/pages.js +3 -3
  30. package/runtime/programs.d.ts +1 -0
  31. package/runtime/programs.d.ts.map +1 -1
  32. package/runtime/programs.js +6 -0
  33. package/runtime/sessions.js +1 -1
  34. package/runtime/state.d.ts +1 -0
  35. package/runtime/state.d.ts.map +1 -1
  36. package/runtime/state.js +6 -3
  37. package/runtime/toaster.d.ts +5 -0
  38. package/runtime/toaster.d.ts.map +1 -1
  39. package/runtime/toaster.js +27 -11
  40. package/runtime/ui.d.ts +1 -0
  41. package/runtime/ui.d.ts.map +1 -1
  42. package/runtime/ui.js +6 -6
  43. package/runtime/widgets.js +1 -1
  44. package/src/jobs/program.ts +60 -4
  45. package/src/records.ts +2 -2
  46. package/src/register.ts +25 -3
  47. package/src/runtime/claude.ts +2 -0
  48. package/src/runtime/conversations.ts +8 -8
  49. package/src/runtime/deadline.ts +16 -0
  50. package/src/runtime/engine.ts +2 -0
  51. package/src/runtime/hooks.ts +2 -2
  52. package/src/runtime/hotkeys.ts +1 -1
  53. package/src/runtime/installer.ts +1 -1
  54. package/src/runtime/lifecycle.ts +93 -66
  55. package/src/runtime/metadata.ts +1 -1
  56. package/src/runtime/options.ts +1 -1
  57. package/src/runtime/pages.ts +3 -3
  58. package/src/runtime/programs.ts +7 -0
  59. package/src/runtime/sessions.ts +1 -1
  60. package/src/runtime/state.ts +7 -3
  61. package/src/runtime/toaster.ts +47 -12
  62. package/src/runtime/ui.ts +6 -6
  63. package/src/runtime/widgets.ts +1 -1
  64. package/src/testing/fake-claude.ts +2 -0
  65. package/src/testing.ts +6 -2
  66. package/testing/fake-claude.d.ts.map +1 -1
  67. package/testing/fake-claude.js +2 -0
  68. package/testing.d.ts.map +1 -1
  69. package/testing.js +7 -2
@@ -7,7 +7,7 @@ import { dataFolder, finishStepsMethod, isAtLeast, isProgramNewer, oldestCmodVer
7
7
  import { homePrefix, ifMissing, relativePath } from '../utils/paths.js'
8
8
  import { firstLine, formatExit, messageOf } from '../utils/text.js'
9
9
  import type { Claude } from './claude.js'
10
- import { beforeDeadline } from './deadline.js'
10
+ import { beforeDeadline, settledAfterAbort } from './deadline.js'
11
11
  import { announcementMs, announcementOf } from './announce.js'
12
12
  import { bind } from './bound.js'
13
13
  import { serveConversations } from './conversations.js'
@@ -299,7 +299,7 @@ export function createLifecycle<State extends object, Declared extends Options =
299
299
 
300
300
  const record = () => {
301
301
  recording ??= recordThroughCmod()
302
- .catch((error: unknown) => claude().ui.log(`${definition.name} has no cmod record yet: ${messageOf(error)}`, { to: 'debug' }))
302
+ .catch((error: unknown) => claude().ui.warn('record', `${definition.name} has no cmod record yet: ${messageOf(error)}`))
303
303
  .finally(() => {
304
304
  recording = undefined
305
305
  })
@@ -414,10 +414,10 @@ export function createLifecycle<State extends object, Declared extends Options =
414
414
  const { additionalContext, ...unread } = answer as { readonly additionalContext?: readonly string[] } & Record<string, unknown>
415
415
  for (const text of additionalContext ?? []) {
416
416
  const added = await claude().session.append({ message: { type: 'user', content: [{ type: 'text', text }] } })
417
- if (added.deny !== undefined) claude().ui.log(`${definition.name}: Claude Code refused its SessionStart note: ${added.deny}`, { to: 'debug' })
417
+ if (added.deny !== undefined) claude().ui.warn('session-start:note', `${definition.name}: Claude Code refused its SessionStart note: ${added.deny}`)
418
418
  }
419
419
  if (Object.keys(unread).length > 0) {
420
- claude().ui.log(`${definition.name} started after Claude Code's SessionStart, so Claude Code did not read ${Object.keys(unread).join(', ')} from its SessionStart hooks.`, { to: 'debug' })
420
+ claude().ui.warn('session-start:late', `${definition.name} started after Claude Code's SessionStart, so Claude Code did not read ${Object.keys(unread).join(', ')} from its SessionStart hooks.`)
421
421
  }
422
422
  }
423
423
 
@@ -550,11 +550,12 @@ export function createLifecycle<State extends object, Declared extends Options =
550
550
  }
551
551
  let recordCheck: Timer | undefined
552
552
  let checking: Promise<void> | undefined
553
+ let startingSession: string | undefined
553
554
  const watchRecord = () => {
554
555
  recordCheck ??= claude().clock.every(recordCheckMs, () => {
555
556
  checking ??= recover()
556
557
  .then(() => undefined)
557
- .catch((error: unknown) => claude().ui.log(`${definition.name} could not read whether another cmod installed it: ${messageOf(error)}`, { to: 'debug' }))
558
+ .catch((error: unknown) => claude().ui.warn('record:watch', `${definition.name} could not read whether another cmod installed it: ${messageOf(error)}`))
558
559
  .finally(() => {
559
560
  checking = undefined
560
561
  })
@@ -570,17 +571,79 @@ export function createLifecycle<State extends object, Declared extends Options =
570
571
  if (activation !== undefined && phase !== 'active') await activation
571
572
  }
572
573
 
573
- const holdUntilStarted = (): Promise<void> =>
574
+ const held = (work: Promise<void>, signal: AbortSignal | undefined): Promise<void> =>
574
575
  runtime === undefined
575
- ? startSettled.then(whenActive)
576
+ ? work
576
577
  : new Promise<void>((resolve) => {
577
578
  const limit = claude().clock.after(startHoldMs, resolve)
578
- void startSettled.then(whenActive).then(() => {
579
+ if (signal?.aborted === true) resolve()
580
+ signal?.addEventListener('abort', () => resolve(), { once: true })
581
+ void work.then(() => {
579
582
  limit.cancel()
580
583
  resolve()
581
584
  })
582
585
  })
583
586
 
587
+ const holdUntilStarted = (signal?: AbortSignal): Promise<void> => held(startSettled.then(whenActive), signal)
588
+
589
+ const holdUntilActive = (signal: AbortSignal | undefined): Promise<void> => {
590
+ const activating = whenActive()
591
+ return activation !== undefined && phase !== 'active' ? held(activating, signal) : activating
592
+ }
593
+
594
+ const routed = async <N extends RoutedEvent>(event: N, e: Frozen<Args<N>>, next: RouterNext<N>, signal?: AbortSignal): Promise<EventResult<N>> => {
595
+ if (imports !== undefined) bind(imports)
596
+ const asked = e as Frozen<Args<'cmod.call'>> & { readonly caller?: string }
597
+ if (event === 'cmod.call' && asked.to === definition.name && asked.caller === cmodPluginName) {
598
+ if (asked.method === partMethods.shown) installer.hear(asked.input as ShownPages)
599
+ const answered = installer.answer(asked.method, asked.input)
600
+ if (answered !== undefined) return (await answered.catch((error: unknown) => ({ deny: `${definition.name}: ${messageOf(error)}` }))) as EventResult<N>
601
+ if (asked.method === partMethods.shown && phase !== 'active') return { value: null } as EventResult<N>
602
+ }
603
+ if (event === 'classic.SessionStart') {
604
+ missedSessionStart = undefined
605
+ hasHeardSessionStart = true
606
+ }
607
+ if (event === 'classic.SessionStart' && runtime === undefined) {
608
+ missedSessionStart = e as Frozen<Args<'classic.SessionStart'>>
609
+ return next(e)
610
+ }
611
+ if (shouldRecord && event === 'classic.UserPromptSubmit') record()
612
+ if (event === 'classic.UserPromptSubmit' || event === 'classic.SessionStart') await recover().catch((error: unknown) => claude().ui.warn('recover', `${definition.name} stays stopped: ${messageOf(error)}`))
613
+ const tool = (e as { readonly tool?: unknown }).tool
614
+ const isCallToThisMod = (event === 'cmod.call' && (e as Frozen<Args<'cmod.call'>>).to === definition.name) || (event === 'tool.call' && typeof tool === 'string' && tool.startsWith(`mcp__${definition.name}__`))
615
+ if (event === 'cmod.call' && !isCallToThisMod) return next(e)
616
+ await (event === 'classic.SessionStart' || event === 'session.append' || isCallToThisMod ? holdUntilStarted(signal) : holdUntilActive(signal))
617
+ if (event === 'classic.SessionStart' && phase !== 'active') {
618
+ missedSessionStart = e as Frozen<Args<'classic.SessionStart'>>
619
+ return next(e)
620
+ }
621
+ if (isCallToThisMod && phase !== 'active') {
622
+ if (event === 'cmod.call' && listenMethods.includes(asked.method)) {
623
+ heldListens.set(`${asked.caller}\n${asked.method}\n${String((asked.input as { readonly session?: unknown }).session)}`, asked)
624
+ return { value: null } as EventResult<N>
625
+ }
626
+ return { deny: phase === 'failed' ? notSetUp() : `${definition.name} is installing. Try again when it's ready.` } as EventResult<N>
627
+ }
628
+ const call = e as Frozen<Args<'cmod.call'>>
629
+ if (event === 'cmod.call' && call.to === definition.name && mod !== undefined) {
630
+ if (call.method === pendingStepsMethod) return { value: await pendingSteps(mod) } as EventResult<N>
631
+ if (call.method === finishStepsMethod) {
632
+ const active = mod
633
+ const opened = await installer.collect(() => Promise.race([runSteps(active).catch((error: unknown) => void toastFailure({ id: 'cmod:steps', message: 'Could not finish the setup', error, isCritical: true })), installer.shown()]))
634
+ return { value: opened } as EventResult<N>
635
+ }
636
+ }
637
+ if (event === 'classic.UserPromptSubmit' && phase === 'active' && !hasHeardSessionStart) {
638
+ const { session_id, transcript_path, cwd } = e as Frozen<Args<'classic.UserPromptSubmit'>>
639
+ await replaySessionStart({ session_id, transcript_path, cwd, hook_event_name: 'SessionStart', source: 'resume' })
640
+ }
641
+ const answer = router.dispatch(event, e, next, signal)
642
+ const render = e as Frozen<Args<'ui.render'>>
643
+ if (event !== 'ui.render' || render.component !== 'AbovePrompt' || runtime === undefined) return answer
644
+ return runtime.toaster.draw((await answer) as EventResult<'ui.render'>, runtime.claude.ui.resolve(render), render.props, render.requestId) as EventResult<N>
645
+ }
646
+
584
647
  return {
585
648
  get phase() {
586
649
  return phase
@@ -601,9 +664,14 @@ export function createLifecycle<State extends object, Declared extends Options =
601
664
  },
602
665
  async start(claudeCalls, read) {
603
666
  if (runtime !== undefined) return
604
- programs = locatingPrograms(claudeCalls)
605
- const callingCmod: Claude = {
667
+ const naming: Claude = {
606
668
  ...claudeCalls,
669
+ ui: { ...claudeCalls.ui, warn: (id, text) => (runtime === undefined ? claudeCalls.ui.warn(id, text) : runtime.toaster.warn(id, text)) },
670
+ session: { ...claudeCalls.session, id: async () => startingSession ?? claudeCalls.session.id() },
671
+ }
672
+ programs = locatingPrograms(naming)
673
+ const callingCmod: Claude = {
674
+ ...naming,
607
675
  cmod: {
608
676
  async call(input) {
609
677
  if (input.to === definition.name) await holdUntilStarted()
@@ -622,56 +690,14 @@ export function createLifecycle<State extends object, Declared extends Options =
622
690
  }
623
691
  },
624
692
  async route<N extends RoutedEvent>(event: N, e: Frozen<Args<N>>, next: RouterNext<N>, signal?: AbortSignal): Promise<EventResult<N>> {
625
- if (imports !== undefined) bind(imports)
626
- const asked = e as Frozen<Args<'cmod.call'>> & { readonly caller?: string }
627
- if (event === 'cmod.call' && asked.to === definition.name && asked.caller === cmodPluginName) {
628
- if (asked.method === partMethods.shown) installer.hear(asked.input as ShownPages)
629
- const answered = installer.answer(asked.method, asked.input)
630
- if (answered !== undefined) return (await answered.catch((error: unknown) => ({ deny: `${definition.name}: ${messageOf(error)}` }))) as EventResult<N>
631
- if (asked.method === partMethods.shown && phase !== 'active') return { value: null } as EventResult<N>
632
- }
633
- if (event === 'classic.SessionStart') {
634
- missedSessionStart = undefined
635
- hasHeardSessionStart = true
636
- }
637
- if (event === 'classic.SessionStart' && runtime === undefined) {
638
- missedSessionStart = e as Frozen<Args<'classic.SessionStart'>>
639
- return next(e)
640
- }
641
- if (shouldRecord && event === 'classic.UserPromptSubmit') record()
642
- if (event === 'classic.UserPromptSubmit' || event === 'classic.SessionStart') await recover().catch((error: unknown) => claude().ui.log(`${definition.name} stays stopped: ${messageOf(error)}`, { to: 'debug' }))
643
- const tool = (e as { readonly tool?: unknown }).tool
644
- const isCallToThisMod = (event === 'cmod.call' && (e as Frozen<Args<'cmod.call'>>).to === definition.name) || (event === 'tool.call' && typeof tool === 'string' && tool.startsWith(`mcp__${definition.name}__`))
645
- if (event === 'cmod.call' && !isCallToThisMod) return next(e)
646
- await (event === 'classic.SessionStart' || event === 'session.append' || isCallToThisMod ? holdUntilStarted() : whenActive())
647
- if (event === 'classic.SessionStart' && phase !== 'active') {
648
- missedSessionStart = e as Frozen<Args<'classic.SessionStart'>>
649
- return next(e)
650
- }
651
- if (isCallToThisMod && phase !== 'active') {
652
- if (event === 'cmod.call' && listenMethods.includes(asked.method)) {
653
- heldListens.set(`${asked.caller}\n${asked.method}\n${String((asked.input as { readonly session?: unknown }).session)}`, asked)
654
- return { value: null } as EventResult<N>
655
- }
656
- return { deny: phase === 'failed' ? notSetUp() : `${definition.name} is installing. Try again when it's ready.` } as EventResult<N>
657
- }
658
- const call = e as Frozen<Args<'cmod.call'>>
659
- if (event === 'cmod.call' && call.to === definition.name && mod !== undefined) {
660
- if (call.method === pendingStepsMethod) return { value: await pendingSteps(mod) } as EventResult<N>
661
- if (call.method === finishStepsMethod) {
662
- const active = mod
663
- const opened = await installer.collect(() => Promise.race([runSteps(active).catch((error: unknown) => void toastFailure({ id: 'cmod:steps', message: 'Could not finish the setup', error, isCritical: true })), installer.shown()]))
664
- return { value: opened } as EventResult<N>
665
- }
666
- }
667
- if (event === 'classic.UserPromptSubmit' && phase === 'active' && !hasHeardSessionStart) {
668
- const { session_id, transcript_path, cwd } = e as Frozen<Args<'classic.UserPromptSubmit'>>
669
- await replaySessionStart({ session_id, transcript_path, cwd, hook_event_name: 'SessionStart', source: 'resume' })
693
+ if (event !== 'classic.SessionStart') return settledAfterAbort(routed(event, e, next, signal), signal)
694
+ const started = (e as Frozen<Args<'classic.SessionStart'>>).session_id
695
+ startingSession = started
696
+ try {
697
+ return await settledAfterAbort(routed(event, e, next, signal), signal)
698
+ } finally {
699
+ if (startingSession === started) startingSession = undefined
670
700
  }
671
- const answer = router.dispatch(event, e, next, signal)
672
- const render = e as Frozen<Args<'ui.render'>>
673
- if (event !== 'ui.render' || render.component !== 'AbovePrompt' || runtime === undefined) return answer
674
- return runtime.toaster.draw((await answer) as EventResult<'ui.render'>, runtime.claude.ui.resolve(render), render.props, render.requestId) as EventResult<N>
675
701
  },
676
702
  async caught<N extends RoutedEvent>(event: N, e: Frozen<Args<N>>, next: RouterNext<N>, { error: { kind, message }, called }: Caught): Promise<EventResult<N>> {
677
703
  const call = e as Frozen<Args<'cmod.call'>>
@@ -719,7 +745,7 @@ async function createMod<State extends object, Declared extends Options>(definit
719
745
  const parent = await claude.cmod.call({ to: cmodPluginName, method: 'forkParent', input: null })
720
746
  return typeof parent === 'string' ? parent : undefined
721
747
  } catch (error) {
722
- claude.ui.log(`${definition.name} starts without the session values of the conversation it was forked from: ${messageOf(error)}`, { to: 'debug' })
748
+ claude.ui.warn('fork:values', `${definition.name} starts without the session values of the conversation it was forked from: ${messageOf(error)}`)
723
749
  return undefined
724
750
  }
725
751
  }
@@ -921,8 +947,8 @@ async function createMod<State extends object, Declared extends Options>(definit
921
947
  report({ id: 'cmod:follow', message: `Keeps the state of ${modState.root} until the next prompt or folder move`, error })
922
948
  }
923
949
  }
924
- const followCurrent = async (title: string | undefined) => {
925
- const [id, model, usage] = await Promise.all([claude.session.id(), claude.session.model(), claude.session.usage()])
950
+ const followCurrent = async (id: string, title: string | undefined) => {
951
+ const [model, usage] = await Promise.all([claude.session.model(), claude.session.usage()])
926
952
  followed = { id, title: title ?? '', project: modState.root, cwd, model, startedAt: new Date(usage.startedAt).toISOString(), ...(forkedFrom === undefined ? {} : { forkedFrom }), ...(agentType === undefined ? {} : { agentType }) }
927
953
  client.follow(followed)
928
954
  }
@@ -935,17 +961,17 @@ async function createMod<State extends object, Declared extends Options>(definit
935
961
  parentAsked = undefined
936
962
  }
937
963
  hasEarlierPrompts = e.source !== 'startup' && e.source !== 'clear'
964
+ await followCurrent(e.session_id, e.session_title).catch((error: unknown) => report({ id: 'cmod:current', message: 'Kept the details of the session from before', error }))
938
965
  await modState.switchSession(e.session_id, e.source, e.transcript_path).catch((error: unknown) => {
939
966
  report({ id: 'cmod:session', message: `Kept its session values from before the ${e.source}`, error })
940
967
  })
941
- await followCurrent(e.session_title).catch((error: unknown) => report({ id: 'cmod:current', message: 'Kept the details of the session from before', error }))
942
968
  return next(e)
943
969
  })
944
970
  router.add('classic.UserPromptSubmit', async (e, next) => {
945
971
  staleCwd = undefined
946
972
  await followSession()
947
973
  const isPerson = e.source === undefined || e.source === 'user' || e.source === 'sdk'
948
- await followCurrent(e.session_title || (isPerson && !hasEarlierPrompts && client.sessions.current.title === '' ? firstLine(e.prompt) : undefined)).catch((error: unknown) => report({ id: 'cmod:current', message: 'Kept the details of the session from before', error }))
974
+ await followCurrent(e.session_id, e.session_title || (isPerson && !hasEarlierPrompts && client.sessions.current.title === '' ? firstLine(e.prompt) : undefined)).catch((error: unknown) => report({ id: 'cmod:current', message: 'Kept the details of the session from before', error }))
949
975
  return next(e)
950
976
  })
951
977
  for (const event of ['classic.PostToolUse', 'classic.PostToolUseFailure'] as const) {
@@ -979,7 +1005,7 @@ async function createMod<State extends object, Declared extends Options>(definit
979
1005
  pages = widgets === undefined ? undefined : servePages({ claude, router, report: reportPart, widgets, parts, tellStylers: area.restyled })
980
1006
  const tellColor = (to: string, told: SessionColor) => {
981
1007
  if (told.session === '' || to === cmodPluginName) return
982
- claude.clock.after(0, () => void claude.cmod.call({ to, method: conversationMethods.sessionColor, input: told }).catch((error: unknown) => claude.ui.log(`cmod: ${to} did not hear the session's color: ${messageOf(error)}`, { to: 'debug' })))
1008
+ claude.clock.after(0, () => void claude.cmod.call({ to, method: conversationMethods.sessionColor, input: told }).catch((error: unknown) => claude.ui.warn('color:tell', `cmod: ${to} did not hear the session's color: ${messageOf(error)}`)))
983
1009
  }
984
1010
  conversations?.onColor((told) => {
985
1011
  client.recolor(told)
@@ -1025,6 +1051,7 @@ async function createMod<State extends object, Declared extends Options>(definit
1025
1051
  hasPermissionCheck: () => runtime.permissionRoutes() !== undefined,
1026
1052
  answerInput: area.answerInput,
1027
1053
  spawnCmod: (args, env) => spawnCmod(claude, args, session, env),
1054
+ watches,
1028
1055
  ...(widgets === undefined ? {} : { widgets }),
1029
1056
  ...(pages === undefined ? {} : { pages }),
1030
1057
  })
@@ -1039,7 +1066,7 @@ async function createMod<State extends object, Declared extends Options>(definit
1039
1066
  await failsAs('its options did not load', () => modOptions.load(root))
1040
1067
  const missing = modOptions.missing
1041
1068
  if (missing.length > 0) throw new MissingOptions(missing, missing.map((key) => definition.options?.[key]?.title ?? key))
1042
- await failsAs('the details of its session did not load', () => followCurrent(undefined))
1069
+ await failsAs('the details of its session did not load', () => followCurrent(session, undefined))
1043
1070
  const returned = await failsAs('its setup function threw', () => definition.setup(mod))
1044
1071
  api = apiOf(definition.name, returned)
1045
1072
  await failsAs('its open panes did not load', () => area.restorePanes())
@@ -71,7 +71,7 @@ export function createModFiles({
71
71
  const skipped = <Value>(path: string, value: Value) => (error: unknown): Value => {
72
72
  if (isMissing(error)) return value
73
73
  const reason = `${name}: fs.find skipped ${path}: ${messageOf(error)}`
74
- if (!logged.has(reason)) claude.ui.log(reason, { to: 'debug' })
74
+ if (!logged.has(reason)) claude.ui.warn('fs:find', reason)
75
75
  logged.add(reason)
76
76
  return value
77
77
  }
@@ -44,7 +44,7 @@ export function createOptions({
44
44
  const readLocked = async () => {
45
45
  if (Object.keys(declared).length === 0) return new Set<string>()
46
46
  const rows = await claude.config.list().catch((error: unknown) => {
47
- claude.ui.log(`${name} could not read /config, so a project's options.json may override a value your organization set: ${messageOf(error)}`, { to: 'debug' })
47
+ claude.ui.warn('options:config', `${name} could not read /config, so a project's options.json may override a value your organization set: ${messageOf(error)}`)
48
48
  return []
49
49
  })
50
50
  return new Set(rows.filter((row) => row.isLocked && row.key.startsWith(`${name}.`)).map((row) => row.key.slice(name.length + 1)))
@@ -90,7 +90,7 @@ export function servePages({
90
90
  .call({ to: mod, method: partMethods.list, input: null })
91
91
  .then(
92
92
  (parts) => void declared.set(mod, pagesOf(parts)),
93
- (error: unknown) => claude.ui.log(`cmod: ${mod} did not list its pages: ${messageOf(error)}`, { to: 'debug' }),
93
+ (error: unknown) => claude.ui.warn(`pages:list:${mod}`, `cmod: ${mod} did not list its pages: ${messageOf(error)}`),
94
94
  )
95
95
  .finally(() => asking.delete(mod))
96
96
  asking.set(mod, pending)
@@ -104,7 +104,7 @@ export function servePages({
104
104
  const listed = [...stylers]
105
105
  tellStylers(listed)
106
106
  for (const told of declared.keys()) {
107
- if (told !== cmodPluginName) void claude.cmod.call({ to: told, method: partMethods.stylers, input: listed }).catch((error: unknown) => claude.ui.log(`cmod: ${told} did not hear which mods style markdown: ${messageOf(error)}`, { to: 'debug' }))
107
+ if (told !== cmodPluginName) void claude.cmod.call({ to: told, method: partMethods.stylers, input: listed }).catch((error: unknown) => claude.ui.warn(`pages:stylers:${told}`, `cmod: ${told} did not hear which mods style markdown: ${messageOf(error)}`))
108
108
  }
109
109
  }
110
110
 
@@ -162,7 +162,7 @@ export function servePages({
162
162
  press,
163
163
  update,
164
164
  tell(mod, shown) {
165
- void claude.cmod.call({ to: mod, method: partMethods.shown, input: plain(shown) }).catch((error: unknown) => claude.ui.log(`cmod: ${mod} did not hear which of its pages show: ${messageOf(error)}`, { to: 'debug' }))
165
+ void claude.cmod.call({ to: mod, method: partMethods.shown, input: plain(shown) }).catch((error: unknown) => claude.ui.warn(`pages:shown:${mod}`, `cmod: ${mod} did not hear which of its pages show: ${messageOf(error)}`))
166
166
  },
167
167
  apply(listener) {
168
168
  applyTo = listener
@@ -39,6 +39,13 @@ export function spawnCmod(claude: Claude, args: readonly string[], session: stri
39
39
  return claude.process.spawn({ argv: ['cmod', ...args], env: { ...env, CLAUDE_CODE_SESSION_ID: session } })
40
40
  }
41
41
 
42
+ export async function isHeld(claude: Claude, lock: string, staleMs: number): Promise<boolean> {
43
+ const now = await claude.clock.now()
44
+ const holders = await claude.fs.list(lock).catch(ifMissing([]))
45
+ const touched = await Promise.all(holders.map(async ({ name }) => (await claude.fs.stat(`${lock}/${name}`).catch(ifMissing(undefined)))?.mtimeMs ?? 0))
46
+ return touched.some((at) => now - at < staleMs)
47
+ }
48
+
42
49
  export async function runCmod(claude: Claude, args: readonly string[], session: string): Promise<string> {
43
50
  const lines: string[] = []
44
51
  const { code, lastError } = await readLines(spawnCmod(claude, args, session), (line) => void lines.push(line))
@@ -204,7 +204,7 @@ export function createSessionsClient({ name, claude, report, hookOn, routeOn, pe
204
204
  parents.get(session)?.set(change.task.id, change.task.parent)
205
205
  void readingParents.get(session)?.then(
206
206
  (tree) => tree.set(change.task.id, change.task.parent),
207
- (error: unknown) => claude.ui.log(`${name}: the tasks of ${session} stay unread until the next change: ${messageOf(error)}`, { to: 'debug' }),
207
+ (error: unknown) => claude.ui.warn('tasks:read', `${name}: the tasks of ${session} stay unread until the next change: ${messageOf(error)}`),
208
208
  )
209
209
  }
210
210
 
@@ -42,8 +42,12 @@ export function onStateChange(state: object, listener: () => void): Subscription
42
42
  return { remove: () => void own.delete(listener) }
43
43
  }
44
44
 
45
+ export function sessionKeyOf(name: string, key: string, session: string): string {
46
+ return `${name}.${key}.sessions.${session}`
47
+ }
48
+
45
49
  export async function sessionsWith(claude: Pick<Claude, 'store'>, name: string, key: string, value: unknown): Promise<string[]> {
46
- const prefix = `${name}.${key}.sessions.`
50
+ const prefix = sessionKeyOf(name, key, '')
47
51
  const found: string[] = []
48
52
  for (const stored of (await claude.store.keys()).filter((each) => each.startsWith(prefix))) {
49
53
  if ((await claude.store.get(stored)) === value) found.push(stored.slice(prefix.length))
@@ -68,7 +72,7 @@ export function createState<State extends object>({ name, initial, session, root
68
72
  return run
69
73
  }
70
74
 
71
- const ownersKey = (lifetime: Exclude<SavedLifetime, 'global'>, key: string) => `${name}.${key}.${lifetime === 'project' ? 'projects' : 'sessions'}.`
75
+ const ownersKey = (lifetime: Exclude<SavedLifetime, 'global'>, key: string) => (lifetime === 'project' ? `${name}.${key}.projects.` : sessionKeyOf(name, key, ''))
72
76
 
73
77
  const storeKey = (lifetime: SavedLifetime, key: string, owner: string) => (lifetime === 'global' ? `${name}.${key}` : `${ownersKey(lifetime, key)}${owner}`)
74
78
 
@@ -131,7 +135,7 @@ export function createState<State extends object>({ name, initial, session, root
131
135
  if (lifetime !== 'memory') {
132
136
  const owner = lifetime === 'project' ? projectRoot : sessionId
133
137
  inTurn(() => write(lifetime, key, value, owner)).catch((error: unknown) => {
134
- report({ id: `state:${lifetime}.${key}`, message: `Could not keep state.${lifetime}.${key}. Keep only JSON data in mod.state`, error })
138
+ report({ id: `state:${lifetime}.${key}`, message: `Could not keep state.${lifetime}.${key}`, error })
135
139
  })
136
140
  }
137
141
  changed()
@@ -11,7 +11,21 @@ export type ShownToast = { readonly type: ToastType; readonly message: string; r
11
11
 
12
12
  export type Failure = { readonly id: string; readonly message: string; readonly error?: unknown; readonly description?: string; readonly retry?: () => unknown; readonly isCritical?: boolean }
13
13
 
14
- export type LoggedFailure = { readonly mod: string; readonly id: string; readonly message: string; readonly details: string; readonly at: string; readonly isCritical: boolean; readonly root: string; readonly contact?: Contact }
14
+ export type LogLevel = 'error' | 'warning'
15
+
16
+ export type LoggedFailure = {
17
+ readonly mod: string
18
+ readonly id: string
19
+ readonly message: string
20
+ readonly details: string
21
+ readonly at: string
22
+ readonly isCritical: boolean
23
+ readonly root: string
24
+ readonly contact?: Contact
25
+ readonly level?: LogLevel
26
+ readonly version?: string
27
+ readonly core?: string
28
+ }
15
29
 
16
30
  export const failedMethod = 'cmod:failed'
17
31
 
@@ -19,6 +33,7 @@ export type Toaster = {
19
33
  readonly toast: Toast
20
34
  copy(text: string): Promise<void>
21
35
  fail(failure: Failure): ToastId
36
+ warn(id: string, text: string): void
22
37
  readonly shown: readonly ShownToast[]
23
38
  draw(drawn: RenderElement, table: ElementTable, band: RenderPropsOf['AbovePrompt'], bandId: string): RenderElement
24
39
  }
@@ -75,7 +90,7 @@ export function createToaster(claude: Claude, name: string, version: () => strin
75
90
  if (typeof saved !== 'object' || saved === null) return
76
91
  for (const [id, hides] of Object.entries(saved)) if (typeof hides === 'string' && !hidden.has(id)) hidden.set(id, hides)
77
92
  },
78
- (error: unknown) => claude.ui.log(`${name}: could not read the failures you hid: ${messageOf(error)}`, { to: 'debug' }),
93
+ (error: unknown) => warn('hidden:read', `${name}: could not read the failures you hid: ${messageOf(error)}`),
79
94
  )
80
95
  let lastId = 0
81
96
  let frame = 0
@@ -157,7 +172,7 @@ export function createToaster(claude: Claude, name: string, version: () => strin
157
172
  dismiss(entry.id)
158
173
  if (entry.hides === undefined) return
159
174
  hidden.set(String(entry.id), entry.hides)
160
- void claude.store.set(hiddenKey, Object.fromEntries(hidden)).catch((error: unknown) => claude.ui.log(`${name}: could not remember the failure you hid: ${messageOf(error)}`, { to: 'debug' }))
175
+ void claude.store.set(hiddenKey, Object.fromEntries(hidden)).catch((error: unknown) => warn('hidden:write', `${name}: could not remember the failure you hid: ${messageOf(error)}`))
161
176
  }
162
177
 
163
178
  const toast: Toast = Object.assign(show('default'), {
@@ -198,6 +213,30 @@ export function createToaster(claude: Claude, name: string, version: () => strin
198
213
 
199
214
  const logFailure = (failure: LoggedFailure) => claude.cmod.call({ to: cmodPluginName, method: failedMethod, input: failure })
200
215
 
216
+ const modVersion = () =>
217
+ claude.fs
218
+ .read(`${claude.plugin.root}/.claude-plugin/plugin.json`)
219
+ .then((text) => String((JSON.parse(text) as { version?: unknown }).version))
220
+ .catch((failure: unknown) => `unknown (${messageOf(failure)})`)
221
+
222
+ const detailsOf = (version: string, at: Date, text: string) => `${name} ${version}, @cmodjs/core ${coreVersion}, at ${at.toISOString()}\n${text}`
223
+
224
+ const warned = new Map<string, string>()
225
+
226
+ const warn = (id: string, text: string) => {
227
+ claude.ui.log(text, { to: 'debug' })
228
+ const at = new Date()
229
+ const repeat = `${text}\n${at.toISOString().slice(0, 16)}`
230
+ if (warned.get(id) === repeat) return
231
+ warned.set(id, repeat)
232
+ claude.clock.after(0, () => {
233
+ void (async () => {
234
+ const version = await modVersion()
235
+ await logFailure({ mod: name, id, message: text, details: detailsOf(version, at, text), at: at.toISOString(), isCritical: false, root: claude.plugin.root, level: 'warning', version, core: coreVersion })
236
+ })().catch(() => undefined)
237
+ })
238
+ }
239
+
201
240
  const showsToast = async (failure: LoggedFailure, isShown: boolean): Promise<boolean | undefined> => {
202
241
  try {
203
242
  const logged = logFailure(failure)
@@ -217,16 +256,11 @@ export function createToaster(claude: Claude, name: string, version: () => strin
217
256
  if (sent.get(id) === repeat) return id
218
257
  sent.set(id, repeat)
219
258
  const stack = error instanceof Error && error.stack !== undefined ? `\n\n${error.stack}` : ''
220
- const details = async (failedAt: Date) => {
221
- const modVersion = await claude.fs
222
- .read(`${claude.plugin.root}/.claude-plugin/plugin.json`)
223
- .then((text) => String((JSON.parse(text) as { version?: unknown }).version))
224
- .catch((failure: unknown) => `unknown (${messageOf(failure)})`)
225
- return `${name} ${modVersion}, @cmodjs/core ${coreVersion}, at ${failedAt.toISOString()}\n${message}${description === undefined ? '' : `\n${description}`}${stack}`
226
- }
259
+ const details = async (failedAt: Date) => detailsOf(await modVersion(), failedAt, `${message}${description === undefined ? '' : `\n${description}`}${stack}`)
227
260
  const logged = async () => {
228
261
  const contact = await contactOf(claude)
229
- const failure: LoggedFailure = { mod: name, id, message, details: await details(at), at: at.toISOString(), isCritical, root: claude.plugin.root, ...(contact === undefined ? {} : { contact }) }
262
+ const version = await modVersion()
263
+ const failure: LoggedFailure = { mod: name, id, message, details: detailsOf(version, at, `${message}${description === undefined ? '' : `\n${description}`}${stack}`), at: at.toISOString(), isCritical, root: claude.plugin.root, ...(contact === undefined ? {} : { contact }), level: 'error', version, core: coreVersion }
230
264
  const shows = await showsToast(failure, isCritical)
231
265
  if (isCritical) return
232
266
  if (shows !== false) return show()
@@ -253,7 +287,7 @@ export function createToaster(claude: Claude, name: string, version: () => strin
253
287
  changed()
254
288
  if (bandId === undefined) return
255
289
  const focused = await claude.ui.focus({ requestId: bandId, key: `toast:${id}:ask-claude` })
256
- if ('deny' in focused) claude.ui.log(`${name}: the Report choices did not take the keys: ${String(focused.deny)}`, { to: 'debug' })
290
+ if ('deny' in focused) warn('report:focus', `${name}: the Report choices did not take the keys: ${String(focused.deny)}`)
257
291
  }
258
292
  const tryAgain = async () => {
259
293
  const shown = entries.get(id)
@@ -346,6 +380,7 @@ export function createToaster(claude: Claude, name: string, version: () => strin
346
380
  toast,
347
381
  copy,
348
382
  fail,
383
+ warn,
349
384
  get shown() {
350
385
  return [...entries.values()].map(({ type, message, options }) => ({ type, message, ...(typeof options.description === 'string' ? { description: options.description } : {}) }))
351
386
  },
package/src/runtime/ui.ts CHANGED
@@ -204,7 +204,7 @@ export type UiArea<State extends object> = {
204
204
  restorePanes(): Promise<void>
205
205
  }
206
206
 
207
- const keptDrawInputs = 200
207
+ export const keptDrawInputs = 200
208
208
 
209
209
  export function createUi<State extends object>({ name, claude, router, report, announce, mod, borrowed, nextDraw }: UiOptions<State>): UiArea<State> {
210
210
  const panes = new Map<string, AddedPane<State>>()
@@ -221,7 +221,7 @@ export function createUi<State extends object>({ name, claude, router, report, a
221
221
  else paneStates.set(id, { isShown: open.isShown, isFocused: open.isFocused })
222
222
  }
223
223
  }
224
- const readPanes = () => syncPanes().catch((error: unknown) => claude.ui.log(`${name} keeps its panes' open, shown, and focused state from before: ${messageOf(error)}`, { to: 'debug' }))
224
+ const readPanes = () => syncPanes().catch((error: unknown) => claude.ui.warn('panes:read', `${name} keeps its panes' open, shown, and focused state from before: ${messageOf(error)}`))
225
225
  const requestedSizes = new Map<string, PaneSize>()
226
226
  const styles = new Set<string>()
227
227
  const markdownRenders = new Map<string, MarkdownRender>()
@@ -273,7 +273,7 @@ export function createUi<State extends object>({ name, claude, router, report, a
273
273
  try {
274
274
  if (JSON.stringify(treeOf(sent.render, handlers)) !== sent.tree) return true
275
275
  } catch (error) {
276
- claude.ui.log(`${name}: the ${key} drawing threw, so the cmod plugin asks for it again: ${messageOf(error)}`, { to: 'debug' })
276
+ claude.ui.warn(`drawing:${key}`, `${name}: the ${key} drawing threw, so the cmod plugin asks for it again: ${messageOf(error)}`)
277
277
  return true
278
278
  }
279
279
  const latest = sent.draws.at(-1)
@@ -302,7 +302,7 @@ export function createUi<State extends object>({ name, claude, router, report, a
302
302
  if (isAsked && input.requests !== undefined && !(isObject(answer) && answer['isHeld'] === true)) unheldRequests += 1
303
303
  if (isObject(answer) && name !== cmodPluginName) hear(answer['stylers'], false)
304
304
  },
305
- (error: unknown) => claude.ui.log(`${name}: the cmod plugin did not hear about its pages and widgets: ${messageOf(error)}`, { to: 'debug' }),
305
+ (error: unknown) => claude.ui.warn('parts:tell', `${name}: the cmod plugin did not hear about its pages and widgets: ${messageOf(error)}`),
306
306
  )
307
307
  }
308
308
  if (!isAsked) return Promise.resolve().then(tell)
@@ -436,7 +436,7 @@ export function createUi<State extends object>({ name, claude, router, report, a
436
436
  if (requested?.columns === size.columns && requested?.rows === size.rows) return
437
437
  await openAt(pane, size)
438
438
  } catch (error) {
439
- claude.ui.log(`${name}: the ${pane.title} pane kept its size: ${messageOf(error)}`, { to: 'debug' })
439
+ claude.ui.warn(`pane:resize:${pane.id}`, `${name}: the ${pane.title} pane kept its size: ${messageOf(error)}`)
440
440
  }
441
441
  }
442
442
 
@@ -531,7 +531,7 @@ export function createUi<State extends object>({ name, claude, router, report, a
531
531
  if (panes.get(init.id) !== added) return
532
532
  panes.delete(init.id)
533
533
  paneLogs.delete(init.id)
534
- if (openPanes.has(init.id)) void claude.ui.close({ id: init.id }).catch((error: unknown) => claude.ui.log(`${name}: the ${init.title} pane stayed open: ${messageOf(error)}`, { to: 'debug' }))
534
+ if (openPanes.has(init.id)) void claude.ui.close({ id: init.id }).catch((error: unknown) => claude.ui.warn(`pane:close:${init.id}`, `${name}: the ${init.title} pane stayed open: ${messageOf(error)}`))
535
535
  openPanes.delete(init.id)
536
536
  paneStates.delete(init.id)
537
537
  },
@@ -183,7 +183,7 @@ export function serveWidgets({
183
183
  declared.set(mod, declarationsOf(await claude.cmod.call({ to: mod, method: partMethods.list, input: null })))
184
184
  } catch (error) {
185
185
  declared.delete(mod)
186
- claude.ui.log(`cmod: ${mod} did not list its widgets: ${messageOf(error)}`, { to: 'debug' })
186
+ claude.ui.warn(`widgets:list:${mod}`, `cmod: ${mod} did not list its widgets: ${messageOf(error)}`)
187
187
  }
188
188
  }
189
189
 
@@ -132,6 +132,7 @@ export function fakeClaude(plugin: { readonly name: string; readonly root: strin
132
132
  const lines = options?.to === 'debug' ? shown.debug : shown.logs
133
133
  lines.push(text)
134
134
  },
135
+ warn: (_id, text) => void shown.debug.push(text),
135
136
  notice: () => undefined,
136
137
  toast: (...args) => void calls.push({ call: 'ui.toast', args }),
137
138
  invalidate: (event) => void calls.push({ call: 'ui.invalidate', args: [event] }),
@@ -206,6 +207,7 @@ export function fakeClaude(plugin: { readonly name: string; readonly root: strin
206
207
  model: async () => 'test-model',
207
208
  usage: () => fakes.session.usage?.() ?? Promise.resolve({ startedAt: Date.parse('2026-01-01T00:00:00.000Z'), context: { window: 200000 }, rateLimits: [], cost: { usd: 0 } }),
208
209
  surfaces: () => fakes.session.surfaces?.() ?? Promise.resolve(['terminal']),
210
+ version: async () => '2.1.317',
209
211
  messages: rejected('session.messages', () => fakes.session.messages as ((args?: unknown) => Promise<unknown>) | undefined) as Claude['session']['messages'],
210
212
  append: rejected('session.append', () => fakes.session.append ?? appendNote),
211
213
  send: rejected('session.send', () => fakes.session.send ?? (async () => ({ isDelivered: true as const }))),
package/src/testing.ts CHANGED
@@ -166,9 +166,10 @@ export function testMod<State extends object, Declared extends Options = Options
166
166
  let cwd = options.cwd ?? projectRoot
167
167
  let cwdAfterPrompt: string | undefined
168
168
  let sessionId = 'test-session'
169
+ let answeredId = sessionId
169
170
  let toolUses = 0
170
171
  let slotDraws = 0
171
- fake.claude.session.id = async () => sessionId
172
+ fake.claude.session.id = async () => answeredId
172
173
  fake.claude.session.root = async () => projectRoot
173
174
  fake.claude.session.cwd = async () => cwd
174
175
  const conversations = fakeSessions({
@@ -551,9 +552,12 @@ export function testMod<State extends object, Declared extends Options = Options
551
552
  if (event === 'SessionStart') {
552
553
  const source = (input as { readonly source?: string }).source
553
554
  const isStartNote = source === 'startup' && !hasSessionStarted
555
+ const startedAs = sessionId
554
556
  hasSessionStarted = true
557
+ if (source !== 'resume') answeredId = startedAs
555
558
  const noted = start().then(() => (isStartNote ? undefined : noteDevice()))
556
- const started = 'transcript_path' in input ? noted.then(() => route('classic.SessionStart', filled, below)) : Promise.all([noted, files.write(transcript, '')]).then(() => route('classic.SessionStart', filled, below))
559
+ const routed = 'transcript_path' in input ? noted.then(() => route('classic.SessionStart', filled, below)) : Promise.all([noted, files.write(transcript, '')]).then(() => route('classic.SessionStart', filled, below))
560
+ const started = routed.then((answer) => ((answeredId = startedAs), answer))
557
561
  return source === 'startup' || source === 'clear' ? started : started.then(async (answer) => (await tellHeldColor(), answer))
558
562
  }
559
563
  if (event !== 'PreToolUse') return route(`classic.${event}` as RoutedEvent, filled, below, signal)
@@ -1 +1 @@
1
- {"version":3,"file":"fake-claude.d.ts","sourceRoot":"","sources":["../src/testing/fake-claude.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAS,MAAM,aAAa,CAAA;AAErD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAQlD,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,KAAK,GAAG;IAClB,OAAO,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC,SAAS,CAA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