@cmodjs/core 5.6.0 → 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/docs/commands.md +7 -5
  2. package/docs/dependencies.md +2 -2
  3. package/docs/install-steps.md +1 -1
  4. package/docs/mod.md +1 -1
  5. package/docs/ui.md +5 -3
  6. package/package.json +2 -2
  7. package/records.d.ts +15 -2
  8. package/records.d.ts.map +1 -1
  9. package/records.js +15 -3
  10. package/register.d.ts +3 -0
  11. package/register.d.ts.map +1 -1
  12. package/register.js +25 -15
  13. package/runtime/before.d.ts +3 -0
  14. package/runtime/before.d.ts.map +1 -1
  15. package/runtime/before.js +66 -31
  16. package/runtime/conversations.d.ts.map +1 -1
  17. package/runtime/conversations.js +29 -9
  18. package/runtime/lifecycle.d.ts +24 -2
  19. package/runtime/lifecycle.d.ts.map +1 -1
  20. package/runtime/lifecycle.js +36 -31
  21. package/runtime/pages.d.ts +2 -1
  22. package/runtime/pages.d.ts.map +1 -1
  23. package/runtime/pages.js +3 -6
  24. package/runtime/programs.d.ts +1 -0
  25. package/runtime/programs.d.ts.map +1 -1
  26. package/runtime/programs.js +8 -1
  27. package/runtime/router.d.ts +4 -2
  28. package/runtime/router.d.ts.map +1 -1
  29. package/runtime/router.js +10 -8
  30. package/runtime/toaster.d.ts.map +1 -1
  31. package/runtime/toaster.js +15 -7
  32. package/runtime/ui.d.ts.map +1 -1
  33. package/runtime/ui.js +27 -24
  34. package/src/records.ts +17 -3
  35. package/src/register.ts +29 -13
  36. package/src/runtime/before.ts +71 -34
  37. package/src/runtime/conversations.ts +26 -8
  38. package/src/runtime/lifecycle.ts +61 -43
  39. package/src/runtime/pages.ts +4 -3
  40. package/src/runtime/programs.ts +12 -1
  41. package/src/runtime/router.ts +11 -9
  42. package/src/runtime/toaster.ts +15 -7
  43. package/src/runtime/ui.ts +24 -21
  44. package/src/testing/fake-elements.ts +15 -3
  45. package/src/testing.ts +6 -3
  46. package/testing/fake-elements.js +15 -3
  47. package/testing.d.ts.map +1 -1
  48. package/testing.js +6 -3
  49. package/vendor-markdown.js +4 -8698
  50. package/vendor.js +7 -3384
package/testing.js CHANGED
@@ -7,6 +7,7 @@ import { keepClaudeCode } from './testing/claude-code.js';
7
7
  import { createRouter } from './runtime/router.js';
8
8
  import { toolInputOf } from './runtime/tool-calls.js';
9
9
  import { createLifecycle } from './runtime/lifecycle.js';
10
+ import { serveCmodPlugin } from './register.js';
10
11
  import { MissingOptions } from './runtime/options.js';
11
12
  import { conversationMethods, pickedColor } from './runtime/sessions.js';
12
13
  import { deviceNote } from './session/context/turn/device.js';
@@ -192,7 +193,8 @@ export function testMod(definition, options = {}) {
192
193
  };
193
194
  const cmodClaude = { ...fake.claude, cmod: { call: async (input) => (input.to === name ? callMod(input.method, input.input) : fake.claude.cmod.call(input)) } };
194
195
  const reportPart = (_id, message, error) => fake.claude.ui.log(`cmod: ${message}: ${messageOf(error)}`, { to: 'debug' });
195
- const parts = drawnParts({ claude: cmodClaude, report: reportPart, press: (_mod, input) => void pressPart(input).catch((error) => fake.claude.ui.log(`cmod: ${name} did not take the press: ${messageOf(error)}`, { to: 'debug' })) });
196
+ const tellRefusedPress = (_mod, error) => fake.claude.ui.log(`cmod: ${name} did not take the press: ${messageOf(error)}`, { to: 'debug' });
197
+ const parts = drawnParts({ claude: cmodClaude, report: reportPart, press: (mod, input) => void pressPart(input).catch((error) => tellRefusedPress(mod, error)) });
196
198
  const servedWidgets = async () => {
197
199
  const own = name === cmodPluginName && lifecycle.mod !== undefined ? engineOf(lifecycle.mod).widgets : undefined;
198
200
  if (own !== undefined)
@@ -209,7 +211,7 @@ export function testMod(definition, options = {}) {
209
211
  };
210
212
  const widgetsOf = () => (widgets ??= servedWidgets());
211
213
  const cmodBeneath = createRouter();
212
- const pages = servePages({ claude: cmodClaude, router: cmodBeneath, report: reportPart, widgets: { update: (mod, update) => void widgetsOf().then((served) => served.update(mod, update)) }, parts, tellStylers: () => undefined });
214
+ const pages = servePages({ claude: cmodClaude, router: cmodBeneath, report: reportPart, tellRefusedPress, widgets: { update: (mod, update) => void widgetsOf().then((served) => served.update(mod, update)) }, parts, tellStylers: () => undefined });
213
215
  pages.apply((_mod, requests) => applyRequests(requests));
214
216
  const dependencies = fakeDependencies(name, options.dependencies ?? {}, conversations);
215
217
  fake.fakes.cmod.call = async (call) => {
@@ -286,7 +288,7 @@ export function testMod(definition, options = {}) {
286
288
  const starting = options.state;
287
289
  const declared = Object.entries(definition.state ?? {});
288
290
  const state = Object.fromEntries(declared.map(([lifetime, values]) => [lifetime, { ...values, ...starting?.[lifetime] }]));
289
- const lifecycle = createLifecycle({ ...definition, state }, () => permissionRoutes, (options.options ?? {}), false);
291
+ const lifecycle = createLifecycle({ ...definition, state }, () => permissionRoutes, (options.options ?? {}), false, definition.name === cmodPluginName ? serveCmodPlugin : undefined);
290
292
  let started;
291
293
  let isColorTold = false;
292
294
  let deviceNoted;
@@ -345,6 +347,7 @@ export function testMod(definition, options = {}) {
345
347
  place: async () => conversations.place(),
346
348
  wants: async (event) => conversations.wants(name, event),
347
349
  fold: decide,
350
+ failedBefore: () => undefined,
348
351
  },
349
352
  });
350
353
  const route = async (event, input, below, signal) => {