notesoup 0.47.0 → 0.48.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 (78) hide show
  1. package/README.md +1 -1
  2. package/dist/src/boot/render.d.ts +14 -7
  3. package/dist/src/boot/render.js +29 -16
  4. package/dist/src/boot/text.d.ts +25 -4
  5. package/dist/src/boot/text.js +59 -11
  6. package/dist/src/budget/text.d.ts +29 -9
  7. package/dist/src/budget/text.js +51 -10
  8. package/dist/src/claude/helper.d.ts +2 -3
  9. package/dist/src/claude/helper.js +45 -11
  10. package/dist/src/claude/history.d.ts +9 -0
  11. package/dist/src/claude/history.js +271 -0
  12. package/dist/src/dsh/engine.d.ts +2 -1
  13. package/dist/src/dsh/engine.js +18 -9
  14. package/dist/src/dsh/index.js +9 -4
  15. package/dist/src/dsh/window.d.ts +2 -1
  16. package/dist/src/dsh/window.js +14 -8
  17. package/dist/src/history/query.js +59 -81
  18. package/dist/src/notes/address.d.ts +5 -0
  19. package/dist/src/notes/address.js +20 -21
  20. package/dist/src/notes/store.js +12 -19
  21. package/dist/src/pi/boot.d.ts +1 -1
  22. package/dist/src/pi/boot.js +28 -5
  23. package/dist/src/pi/budget.d.ts +0 -2
  24. package/dist/src/pi/budget.js +13 -53
  25. package/dist/src/pi/entries.d.ts +0 -1
  26. package/dist/src/pi/entries.js +0 -1
  27. package/dist/src/pi/history.d.ts +3 -0
  28. package/dist/src/pi/history.js +4 -0
  29. package/dist/src/pi/reset/artifacts.d.ts +7 -2
  30. package/dist/src/pi/reset/artifacts.js +16 -14
  31. package/dist/src/pi/reset/lifecycle.d.ts +21 -25
  32. package/dist/src/pi/reset/lifecycle.js +49 -73
  33. package/dist/src/pi/runtime.js +19 -18
  34. package/dist/src/pi/window.d.ts +12 -6
  35. package/dist/src/pi/window.js +7 -0
  36. package/dist/test/agent-loop.test.js +65 -42
  37. package/dist/test/boot.integration.test.js +119 -16
  38. package/dist/test/budget-settings.integration.test.js +4 -2
  39. package/dist/test/claude-history.test.d.ts +1 -0
  40. package/dist/test/claude-history.test.js +184 -0
  41. package/dist/test/claude-mod.test.js +243 -49
  42. package/dist/test/dsh.test.js +79 -2
  43. package/dist/test/helpers/extension.d.ts +3 -0
  44. package/dist/test/helpers/extension.js +33 -5
  45. package/dist/test/history.integration.test.js +66 -0
  46. package/dist/test/host-neutral.test.js +1 -1
  47. package/dist/test/model-facing-text.test.d.ts +1 -0
  48. package/dist/test/model-facing-text.test.js +181 -0
  49. package/dist/test/notes.integration.test.js +16 -18
  50. package/dist/test/reset-lifecycle.test.js +202 -47
  51. package/docs/architecture.md +3 -3
  52. package/docs/claude-code-mod.md +15 -3
  53. package/docs/dsh.md +1 -1
  54. package/docs/reset-lifecycle.md +32 -20
  55. package/docs/skills.md +1 -1
  56. package/mods/notesoup/.claude-plugin/plugin.json +1 -1
  57. package/mods/notesoup/dist/claude/helper.js +836 -92
  58. package/mods/notesoup/hooks/register.ts +154 -52
  59. package/package.json +1 -1
  60. package/src/boot/render.ts +41 -23
  61. package/src/boot/text.ts +68 -11
  62. package/src/budget/text.ts +61 -10
  63. package/src/claude/helper.ts +53 -22
  64. package/src/claude/history.ts +228 -0
  65. package/src/dsh/engine.ts +16 -9
  66. package/src/dsh/index.ts +8 -3
  67. package/src/dsh/window.ts +15 -9
  68. package/src/history/query.ts +57 -82
  69. package/src/notes/address.ts +19 -16
  70. package/src/notes/store.ts +9 -14
  71. package/src/pi/boot.ts +27 -5
  72. package/src/pi/budget.ts +13 -50
  73. package/src/pi/entries.ts +0 -1
  74. package/src/pi/history.ts +7 -2
  75. package/src/pi/reset/artifacts.ts +17 -14
  76. package/src/pi/reset/lifecycle.ts +57 -80
  77. package/src/pi/runtime.ts +19 -18
  78. package/src/pi/window.ts +11 -1
package/src/pi/window.ts CHANGED
@@ -3,9 +3,11 @@ import { getCurrentSystemMessage } from "@earendil-works/pi-ai";
3
3
  import { estimateContextTokens } from "./estimate.js";
4
4
  import { convertToLlm, type CustomEntry, type ExtensionContext, type SessionEntry } from "@earendil-works/pi-coding-agent";
5
5
  import { BOOT_TYPE, RESET_MARKER_TYPE } from "./entries.js";
6
+ import type { ResetOrigin } from "../budget/text.js";
6
7
  import type { SessionReader } from "./session-reader.js";
7
8
 
8
- export type WindowMarker = CustomEntry<{ windowId: string }> & { data: { windowId: string } };
9
+ export type WindowMarkerData = { readonly windowId: string; readonly origin?: ResetOrigin };
10
+ export type WindowMarker = CustomEntry<WindowMarkerData> & { data: WindowMarkerData };
9
11
 
10
12
  export function isWindowMarker(entry: SessionEntry): entry is WindowMarker {
11
13
  return entry.type === "custom" && entry.customType === RESET_MARKER_TYPE &&
@@ -14,6 +16,14 @@ export function isWindowMarker(entry: SessionEntry): entry is WindowMarker {
14
16
  (entry.data as { windowId: string }).windowId.length > 0;
15
17
  }
16
18
 
19
+ /**
20
+ * The origin a marker records for missing-tail repair. A marker written before the fact was
21
+ * carried, or with an unreadable one, was the model's own reset.
22
+ */
23
+ export function markerResetOrigin(marker: WindowMarker): ResetOrigin {
24
+ return marker.data.origin === "forced" ? "forced" : "normal";
25
+ }
26
+
17
27
  /** Only the active branch can supply a window boundary. */
18
28
  export function currentReset(ctx: SessionReader): WindowMarker | undefined {
19
29
  const branch = ctx.sessionManager.getBranch();