@theokit/sdk 4.57.0 → 4.59.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 (101) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/dist/{agent-ZIYCVEZL.js → agent-ST27RIJE.js} +10 -9
  3. package/dist/{agent-ZIYCVEZL.js.map → agent-ST27RIJE.js.map} +1 -1
  4. package/dist/{agent-2T2EJIP6.cjs → agent-VHRX7XGW.cjs} +11 -10
  5. package/dist/{agent-2T2EJIP6.cjs.map → agent-VHRX7XGW.cjs.map} +1 -1
  6. package/dist/{chunk-E7JHD6QJ.cjs → chunk-554J7UQH.cjs} +44 -27
  7. package/dist/chunk-554J7UQH.cjs.map +1 -0
  8. package/dist/{chunk-E3WZ6Y4H.cjs → chunk-7BG5UH3T.cjs} +8 -8
  9. package/dist/{chunk-E3WZ6Y4H.cjs.map → chunk-7BG5UH3T.cjs.map} +1 -1
  10. package/dist/{chunk-X7O4255I.cjs → chunk-7GUIET73.cjs} +4 -4
  11. package/dist/{chunk-X7O4255I.cjs.map → chunk-7GUIET73.cjs.map} +1 -1
  12. package/dist/{chunk-7TCRNXNK.js → chunk-7LOIUIQZ.js} +69 -29
  13. package/dist/chunk-7LOIUIQZ.js.map +1 -0
  14. package/dist/chunk-AQO3NSRG.cjs +41 -0
  15. package/dist/chunk-AQO3NSRG.cjs.map +1 -0
  16. package/dist/{chunk-LEM2GOMI.js → chunk-D5NWEOCO.js} +3 -3
  17. package/dist/{chunk-LEM2GOMI.js.map → chunk-D5NWEOCO.js.map} +1 -1
  18. package/dist/{chunk-U2AC6JUP.cjs → chunk-J2UROOIG.cjs} +2 -27
  19. package/dist/chunk-J2UROOIG.cjs.map +1 -0
  20. package/dist/{chunk-ZNW6V4Y6.cjs → chunk-LKFET5A3.cjs} +23 -2
  21. package/dist/chunk-LKFET5A3.cjs.map +1 -0
  22. package/dist/{chunk-YMA4S2WO.js → chunk-MZ2FGBLZ.js} +33 -11
  23. package/dist/chunk-MZ2FGBLZ.js.map +1 -0
  24. package/dist/{chunk-53CBTBWO.cjs → chunk-P6H23T43.cjs} +33 -11
  25. package/dist/chunk-P6H23T43.cjs.map +1 -0
  26. package/dist/{chunk-7FHZ4VQX.js → chunk-SAVIWMZB.js} +3 -3
  27. package/dist/{chunk-7FHZ4VQX.js.map → chunk-SAVIWMZB.js.map} +1 -1
  28. package/dist/{chunk-M2JWHKO6.cjs → chunk-SMUAG2DY.cjs} +103 -63
  29. package/dist/chunk-SMUAG2DY.cjs.map +1 -0
  30. package/dist/{chunk-UPRJR6IP.js → chunk-UCBJBJ27.js} +3 -25
  31. package/dist/chunk-UCBJBJ27.js.map +1 -0
  32. package/dist/chunk-UFLD2HEV.js +35 -0
  33. package/dist/chunk-UFLD2HEV.js.map +1 -0
  34. package/dist/{chunk-GTKFV7O5.js → chunk-WFC26L6Y.js} +23 -2
  35. package/dist/chunk-WFC26L6Y.js.map +1 -0
  36. package/dist/{chunk-HJBMA5MB.cjs → chunk-WNTAPVU5.cjs} +47 -6
  37. package/dist/chunk-WNTAPVU5.cjs.map +1 -0
  38. package/dist/{chunk-G6EEYRDD.js → chunk-ZA255A62.js} +43 -26
  39. package/dist/chunk-ZA255A62.js.map +1 -0
  40. package/dist/{chunk-2QKTVKH3.js → chunk-ZHPWGIUX.js} +48 -8
  41. package/dist/chunk-ZHPWGIUX.js.map +1 -0
  42. package/dist/context/index.cjs +7 -7
  43. package/dist/context/index.js +3 -3
  44. package/dist/{context-VMIE4BMD.cjs → context-LCKNH2XI.cjs} +7 -6
  45. package/dist/{context-VMIE4BMD.cjs.map → context-LCKNH2XI.cjs.map} +1 -1
  46. package/dist/context-MZSKGKYR.js +7 -0
  47. package/dist/{context-FDOON2DB.js.map → context-MZSKGKYR.js.map} +1 -1
  48. package/dist/cron.cjs +10 -9
  49. package/dist/cron.js +9 -8
  50. package/dist/eval.cjs +9 -8
  51. package/dist/eval.cjs.map +1 -1
  52. package/dist/eval.js +8 -7
  53. package/dist/eval.js.map +1 -1
  54. package/dist/{index-manager-AO4LJQZ4.cjs → index-manager-A3XPHAWF.cjs} +5 -4
  55. package/dist/{index-manager-AO4LJQZ4.cjs.map → index-manager-A3XPHAWF.cjs.map} +1 -1
  56. package/dist/{index-manager-QDPIYIGV.js → index-manager-A64I7KYV.js} +4 -3
  57. package/dist/{index-manager-QDPIYIGV.js.map → index-manager-A64I7KYV.js.map} +1 -1
  58. package/dist/index.cjs +32 -33
  59. package/dist/index.cjs.map +1 -1
  60. package/dist/index.d.cts +1 -1
  61. package/dist/index.d.ts +1 -1
  62. package/dist/index.js +12 -13
  63. package/dist/index.js.map +1 -1
  64. package/dist/internal/memory/storage/markdown-store.d.ts +34 -4
  65. package/dist/internal/persistence/index.cjs +17 -16
  66. package/dist/internal/persistence/index.cjs.map +1 -1
  67. package/dist/internal/persistence/index.js +2 -1
  68. package/dist/internal/persistence/index.js.map +1 -1
  69. package/dist/internal/persistence/paths.d.cts +42 -0
  70. package/dist/internal/persistence/paths.d.ts +42 -0
  71. package/dist/internal/persistence/session-dir.d.cts +15 -0
  72. package/dist/internal/persistence/session-dir.d.ts +15 -0
  73. package/dist/internal/runtime/memory/memory-store.d.ts +2 -2
  74. package/dist/internal/runtime/plugins/plugin-bundles.d.ts +19 -0
  75. package/dist/project.cjs +3 -3
  76. package/dist/project.js +1 -1
  77. package/dist/subagents-loader-6ATCDEKN.js +8 -0
  78. package/dist/{subagents-loader-J54ESLDV.js.map → subagents-loader-6ATCDEKN.js.map} +1 -1
  79. package/dist/subagents-loader-X5QKODCL.cjs +17 -0
  80. package/dist/{subagents-loader-AZIXJ7D3.cjs.map → subagents-loader-X5QKODCL.cjs.map} +1 -1
  81. package/dist/subagents-loader.cjs +3 -2
  82. package/dist/subagents-loader.cjs.map +1 -1
  83. package/dist/subagents-loader.js +2 -1
  84. package/dist/subagents-loader.js.map +1 -1
  85. package/docs/error-codes.md +15 -15
  86. package/package.json +1 -1
  87. package/dist/chunk-2QKTVKH3.js.map +0 -1
  88. package/dist/chunk-53CBTBWO.cjs.map +0 -1
  89. package/dist/chunk-7TCRNXNK.js.map +0 -1
  90. package/dist/chunk-E7JHD6QJ.cjs.map +0 -1
  91. package/dist/chunk-G6EEYRDD.js.map +0 -1
  92. package/dist/chunk-GTKFV7O5.js.map +0 -1
  93. package/dist/chunk-HJBMA5MB.cjs.map +0 -1
  94. package/dist/chunk-M2JWHKO6.cjs.map +0 -1
  95. package/dist/chunk-U2AC6JUP.cjs.map +0 -1
  96. package/dist/chunk-UPRJR6IP.js.map +0 -1
  97. package/dist/chunk-YMA4S2WO.js.map +0 -1
  98. package/dist/chunk-ZNW6V4Y6.cjs.map +0 -1
  99. package/dist/context-FDOON2DB.js +0 -6
  100. package/dist/subagents-loader-AZIXJ7D3.cjs +0 -16
  101. package/dist/subagents-loader-J54ESLDV.js +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,125 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.59.0
4
+
5
+ ### Minor Changes
6
+
7
+ - bd44344: Memories this SDK records can now land where the Claude Code CLI reads them, closing the direction
8
+ that was missing: the CLI's memories were already visible here, but everything this SDK wrote went to
9
+ `<cwd>/.theokit/memory`, invisible to the CLI in the same project.
10
+
11
+ `local.sessionDir` is the switch, because it is already the option this project documents for that
12
+ interop — point it at `~/.claude` and the CLI can `--continue` a session your agent wrote. A consumer
13
+ who set it has said they share state with that CLI, and memory following is what that sentence
14
+ already implied. There is no new option, and **nothing moves for anyone who never set it**.
15
+
16
+ The rule that makes this safe is **write one, read all**. Reads cover the project store, the
17
+ configured session home, and the CLI's own default location, so a consumer whose new facts move keeps
18
+ every fact they already had. The change relocates where the next one lands; it orphans nothing.
19
+
20
+ The `MEMORY.md` index is written beside the files it lists rather than in the project store — an
21
+ index in one directory naming memories in another points at files that are not there, and that index
22
+ is what the CLI reads.
23
+
24
+ ## 4.58.0
25
+
26
+ ### Minor Changes
27
+
28
+ - b39bb5f: A plugin written for the Claude Code CLI now works instead of merely parsing.
29
+
30
+ Measured 2026-08-26 against an installed one: a CLI plugin is a BUNDLE — its manifest sits at
31
+ `<plugin>/.claude-plugin/plugin.json`, and what it exists to contribute are the `skills/` and
32
+ `agents/` directories beside it. This SDK's plugin concept is a JS `entry` point, so such a manifest
33
+ already parsed (zod strips the keys it does not know) and then did nothing at all: `name` and
34
+ `version` survived while the seven agents and three skills the plugin provides stayed invisible.
35
+
36
+ The manifest agreeing was never the point. Plugin folders under `.theokit/plugins` and
37
+ `.claude/plugins` now contribute their skills and agents, and the CLI's manifest location is read
38
+ without the deprecation warning that belongs to this SDK's own superseded `plugin.json` form —
39
+ telling someone to migrate a file that is canonical where it came from would be wrong.
40
+
41
+ Bundles are read AFTER the project's own directories, so a project can shadow a skill or an agent a
42
+ plugin ships without editing the plugin.
43
+
44
+ Project-scoped deliberately. The CLI also keeps plugins under `~/.claude/plugins/cache`, behind its
45
+ own installer and enable/disable state; reproducing that is an installation system rather than
46
+ reading a project's configuration, and guessing at someone's enablement would run code they had
47
+ turned off.
48
+
49
+ - cb1ad68: A project set up for the Claude Code CLI now works without being converted: `.claude/agents`,
50
+ `.claude/skills`, `.claude/hooks.json` and the CLI's own `settings.json` / `settings.local.json` are
51
+ read alongside `.theokit`.
52
+
53
+ The formats already agreed — only the directory did not. Measured 2026-08-26: `SkillFrontmatter`
54
+ requires exactly the `name` and `description` the CLI writes into every `SKILL.md`; the hook config
55
+ this SDK parses is documented as, and is, the CLI's `settings.json` hooks shape; and 59 of the CLI's
56
+ agent declarations parse here unchanged.
57
+
58
+ `.theokit` is searched first and nothing about it changes. Two rules, and the difference between
59
+ them is deliberate:
60
+
61
+ - **Named declarations collide, so the first wins.** Two files declaring an agent or a skill called
62
+ `foo` are one name claimed twice, and the explicit namespace should win.
63
+ - **Hooks accumulate.** They are unnamed lists — two files declaring `PreToolUse` are two sets of
64
+ commands an operator wrote, and keeping one would drop the other in silence.
65
+
66
+ `THEOKIT_HOME` deliberately does not move these directories. It relocates cwd-anchored SDK _state_;
67
+ a project's _configuration_ belongs to the repository, and following the override here would change
68
+ where a project's agents come from under the cover of a refactor.
69
+
70
+ Known limitation: `SessionStart` and `PreCompact` have no firing point in this runtime, so hooks
71
+ declared for them are skipped with a warn rather than silently accepted. Four CLI events map:
72
+ `PreToolUse`, `PostToolUse`, `UserPromptSubmit`, `Stop`.
73
+
74
+ - ad0c320: Rules and memories written for the Claude Code CLI are now read.
75
+
76
+ **Rules** — `.claude/rules/*.md` joins the discovery specs at priority 47. The format needed
77
+ nothing: measured over this repository's 32 rule files, none carries frontmatter, and the
78
+ `rules-frontmatter` parser already reads a file without it as `alwaysApply: true`. There was simply
79
+ no spec pointing at the directory.
80
+
81
+ 47 rather than 46 because B-127 makes these numbers a public contract with room between adjacent
82
+ pairs for a consumer's own source. No published priority moves; a consumer that had chosen 47
83
+ collides, and that is the cost of an eighth default, recorded here rather than discovered later.
84
+
85
+ **Memories** — the CLI keeps a project's memories at `<claudeHome>/projects/<encoded-cwd>/memory/`,
86
+ the same encoding the transcripts use. `markdown-store`'s own header named that path as the target;
87
+ #389 converged the format and the ability to reach the directory was never built, so a memory the
88
+ CLI recorded was invisible to an agent working in the same repository. Both stores are read now,
89
+ `.theokit` first. `CLAUDE_CONFIG_DIR` names the home when set.
90
+
91
+ Reading only — writes still go to `.theokit/memory`. Writing elsewhere by default would relocate
92
+ every existing consumer's memories, which is the one thing an additive change must not do.
93
+
94
+ One fidelity fix came with it: a memory's BODY is the fact, and `description` is the one-line recall
95
+ aid. This SDK writes both the same, so nothing it wrote changes — but the CLI writes a summary above
96
+ the substance, and reading only the summary dropped the fact itself.
97
+
98
+ - 78bff6c: `THEOKIT_DIR_NAME` no longer appears in `SOVEREIGN_ENV_KEYS`. It was documented there as naming the project config directory, and nothing ever read it — setting it did nothing. If you want the SDK to read configuration from `.claude` alongside `.theokit`, that now happens by default and needs no variable. `SOVEREIGN_ENV_KEYS` is public, so a consumer narrowing a type to it gains one fewer member.
99
+
100
+ ### Patch Changes
101
+
102
+ - 5f3b1da: Agent files written for the Claude Code CLI now load.
103
+
104
+ Two defects, both measured against the 64 agent-directory files on one machine (a project
105
+ `.claude/agents` plus every installed plugin):
106
+
107
+ - **`color` made the file a load error.** It appeared in 38 of the 59 agent declarations — it is the
108
+ CLI's label colour and changes nothing about what an agent may do, but the loader rejects unknown
109
+ frontmatter fields, so a majority of real agent files could not be loaded at all.
110
+ - **One README stopped every agent in the directory.** A markdown file with no frontmatter threw
111
+ `subagent_missing_frontmatter`, aborting the whole directory read. `.claude/agents/README.md` is a
112
+ real file in this repository, cited by its own cycle rules.
113
+
114
+ The strict-field check is NOT loosened — its reason is sound, and stated where it lives: a dropped
115
+ `sandbox` that an operator wrote believing it confines the child is a silent gate. Fields known to be
116
+ inert for this runtime are now named explicitly, which is the difference between "we know this one
117
+ and it does nothing" and "we have never heard of this". A field that could change behaviour still
118
+ fails loudly, and a file that HAS frontmatter and gets it wrong is still a broken agent. Only the
119
+ no-frontmatter case is skipped, with a warn naming the file.
120
+
121
+ Measured after: 64 files in, 59 agents loaded, 5 documentation files skipped. Before: zero.
122
+
3
123
  ## 4.57.0
4
124
 
5
125
  ### Minor Changes
@@ -1,7 +1,7 @@
1
- export { Agent } from './chunk-7TCRNXNK.js';
1
+ export { Agent } from './chunk-7LOIUIQZ.js';
2
2
  import './chunk-WG7R5W6R.js';
3
- import './chunk-G6EEYRDD.js';
4
- import './chunk-YMA4S2WO.js';
3
+ import './chunk-ZA255A62.js';
4
+ import './chunk-MZ2FGBLZ.js';
5
5
  import './chunk-2SFBB54R.js';
6
6
  import './chunk-SUKXXLWD.js';
7
7
  import './chunk-K2BQQ445.js';
@@ -14,9 +14,9 @@ import './chunk-WTMU7J4U.js';
14
14
  import './chunk-5JLFFPCH.js';
15
15
  import './chunk-G24KZRSA.js';
16
16
  import './chunk-HKCKOAIO.js';
17
- import './chunk-7FHZ4VQX.js';
17
+ import './chunk-SAVIWMZB.js';
18
18
  import './chunk-KVNWIAO4.js';
19
- import './chunk-UPRJR6IP.js';
19
+ import './chunk-UCBJBJ27.js';
20
20
  import './chunk-FD2UT76F.js';
21
21
  import './chunk-4VPXM6UU.js';
22
22
  import './chunk-U54XCYG3.js';
@@ -24,7 +24,7 @@ import './chunk-NAF4L3T6.js';
24
24
  import './chunk-RNB4APBZ.js';
25
25
  import './chunk-6X6ID4MO.js';
26
26
  import './chunk-4ERPXIVB.js';
27
- import './chunk-GTKFV7O5.js';
27
+ import './chunk-WFC26L6Y.js';
28
28
  import './chunk-7AD3ZTZL.js';
29
29
  import './chunk-QARJGQSA.js';
30
30
  import './chunk-RIAM53CP.js';
@@ -37,7 +37,8 @@ import './chunk-CV7XMBHP.js';
37
37
  import './chunk-Q5EWJPRY.js';
38
38
  import './chunk-RUDY2GTT.js';
39
39
  import './chunk-VF7EWVDG.js';
40
- import './chunk-2QKTVKH3.js';
40
+ import './chunk-ZHPWGIUX.js';
41
+ import './chunk-UFLD2HEV.js';
41
42
  import './chunk-AG5JPQIY.js';
42
43
  import './chunk-F7AQV62G.js';
43
44
  import './chunk-R7WIIPUR.js';
@@ -49,5 +50,5 @@ import './chunk-3OR54XG4.js';
49
50
  import './chunk-IDCKSLYH.js';
50
51
  import './chunk-T7XEKOVW.js';
51
52
  import './chunk-T7O6K6PX.js';
52
- //# sourceMappingURL=agent-ZIYCVEZL.js.map
53
- //# sourceMappingURL=agent-ZIYCVEZL.js.map
53
+ //# sourceMappingURL=agent-ST27RIJE.js.map
54
+ //# sourceMappingURL=agent-ST27RIJE.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-ZIYCVEZL.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-ST27RIJE.js"}
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkM2JWHKO6_cjs = require('./chunk-M2JWHKO6.cjs');
3
+ var chunkSMUAG2DY_cjs = require('./chunk-SMUAG2DY.cjs');
4
4
  require('./chunk-KKK3FZ4A.cjs');
5
- require('./chunk-E7JHD6QJ.cjs');
6
- require('./chunk-53CBTBWO.cjs');
5
+ require('./chunk-554J7UQH.cjs');
6
+ require('./chunk-P6H23T43.cjs');
7
7
  require('./chunk-BV2MWEMV.cjs');
8
8
  require('./chunk-NGESVVJN.cjs');
9
9
  require('./chunk-BUUUWQMB.cjs');
@@ -16,9 +16,9 @@ require('./chunk-4OTIXDMU.cjs');
16
16
  require('./chunk-DQKERTND.cjs');
17
17
  require('./chunk-Z4BCLVTI.cjs');
18
18
  require('./chunk-2ZPEDVLM.cjs');
19
- require('./chunk-E3WZ6Y4H.cjs');
19
+ require('./chunk-7BG5UH3T.cjs');
20
20
  require('./chunk-KRD3GQAA.cjs');
21
- require('./chunk-U2AC6JUP.cjs');
21
+ require('./chunk-J2UROOIG.cjs');
22
22
  require('./chunk-MUUQ2WFJ.cjs');
23
23
  require('./chunk-WJVHMTKB.cjs');
24
24
  require('./chunk-6JSIEDKL.cjs');
@@ -26,7 +26,7 @@ require('./chunk-FRITRLZQ.cjs');
26
26
  require('./chunk-4O5TGQBW.cjs');
27
27
  require('./chunk-NINIJCHU.cjs');
28
28
  require('./chunk-3YJNUKYN.cjs');
29
- require('./chunk-ZNW6V4Y6.cjs');
29
+ require('./chunk-LKFET5A3.cjs');
30
30
  require('./chunk-VJ26EKGJ.cjs');
31
31
  require('./chunk-R3UPQFKK.cjs');
32
32
  require('./chunk-VKJ7V7EB.cjs');
@@ -39,7 +39,8 @@ require('./chunk-2ADR2GSO.cjs');
39
39
  require('./chunk-ZF2LDKQQ.cjs');
40
40
  require('./chunk-2C72DXQF.cjs');
41
41
  require('./chunk-I6TGFUCO.cjs');
42
- require('./chunk-HJBMA5MB.cjs');
42
+ require('./chunk-WNTAPVU5.cjs');
43
+ require('./chunk-AQO3NSRG.cjs');
43
44
  require('./chunk-IWBGCBR6.cjs');
44
45
  require('./chunk-XSX2UU6Y.cjs');
45
46
  require('./chunk-3EE6LVWT.cjs');
@@ -56,7 +57,7 @@ require('./chunk-NUKRL3I6.cjs');
56
57
 
57
58
  Object.defineProperty(exports, "Agent", {
58
59
  enumerable: true,
59
- get: function () { return chunkM2JWHKO6_cjs.Agent; }
60
+ get: function () { return chunkSMUAG2DY_cjs.Agent; }
60
61
  });
61
- //# sourceMappingURL=agent-2T2EJIP6.cjs.map
62
- //# sourceMappingURL=agent-2T2EJIP6.cjs.map
62
+ //# sourceMappingURL=agent-VHRX7XGW.cjs.map
63
+ //# sourceMappingURL=agent-VHRX7XGW.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-2T2EJIP6.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-VHRX7XGW.cjs"}
@@ -3,6 +3,7 @@
3
3
  var chunkGHX4P3V2_cjs = require('./chunk-GHX4P3V2.cjs');
4
4
  var chunkKRD3GQAA_cjs = require('./chunk-KRD3GQAA.cjs');
5
5
  var chunkR3UPQFKK_cjs = require('./chunk-R3UPQFKK.cjs');
6
+ var chunkBUIK7GUA_cjs = require('./chunk-BUIK7GUA.cjs');
6
7
  var chunkSKXBJ2NU_cjs = require('./chunk-SKXBJ2NU.cjs');
7
8
  var chunkZF2LDKQQ_cjs = require('./chunk-ZF2LDKQQ.cjs');
8
9
  var chunkI6TGFUCO_cjs = require('./chunk-I6TGFUCO.cjs');
@@ -13,6 +14,7 @@ var promises = require('fs/promises');
13
14
  var path = require('path');
14
15
  var fs = require('fs');
15
16
  var module$1 = require('module');
17
+ var os = require('os');
16
18
 
17
19
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
18
20
  // src/internal/memory/escape-like-pattern.ts
@@ -78,7 +80,7 @@ function defaultIndexPath(cwd) {
78
80
  }
79
81
  function requireLance() {
80
82
  try {
81
- const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-E7JHD6QJ.cjs', document.baseURI).href)));
83
+ const r = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-554J7UQH.cjs', document.baseURI).href)));
82
84
  return r("@lancedb/lancedb");
83
85
  } catch (cause) {
84
86
  throw new chunkK3FW2XZD_cjs.ConfigurationError(
@@ -366,23 +368,37 @@ var FACTS_HEADING = "## Facts";
366
368
  function memoryDir(cwd) {
367
369
  return path.join(cwd, ".theokit", "memory");
368
370
  }
371
+ function memoryWriteDir(cwd, sessionDir) {
372
+ if (sessionDir === void 0 || sessionDir.trim().length === 0) return memoryDir(cwd);
373
+ return path.join(sessionDir, "projects", chunkBUIK7GUA_cjs.encodeProjectDir(cwd), "memory");
374
+ }
375
+ function claudeProjectMemoryDir(cwd) {
376
+ const home = process.env.CLAUDE_CONFIG_DIR?.trim();
377
+ const root = home !== void 0 && home.length > 0 ? home : path.join(os.homedir(), ".claude");
378
+ return path.join(root, "projects", chunkBUIK7GUA_cjs.encodeProjectDir(cwd), "memory");
379
+ }
369
380
  function memoryMdPath(cwd) {
370
381
  return path.join(memoryDir(cwd), "MEMORY.md");
371
382
  }
372
383
  function notesDir(cwd) {
373
384
  return path.join(memoryDir(cwd), "notes");
374
385
  }
375
- async function readFactsFromMarkdown(cwd) {
376
- let entries;
377
- try {
378
- entries = await promises.readdir(memoryDir(cwd));
379
- } catch {
380
- return [];
381
- }
386
+ async function readFactsFromMarkdown(cwd, sessionDir) {
382
387
  const facts = [];
383
- for (const entry of entries.sort()) {
384
- const fact = await readMemoryFileAt(cwd, entry);
385
- if (fact !== void 0) facts.push(fact);
388
+ const roots = [
389
+ .../* @__PURE__ */ new Set([memoryDir(cwd), memoryWriteDir(cwd, sessionDir), claudeProjectMemoryDir(cwd)])
390
+ ];
391
+ for (const dir of roots) {
392
+ let entries;
393
+ try {
394
+ entries = await promises.readdir(dir);
395
+ } catch {
396
+ continue;
397
+ }
398
+ for (const entry of entries.sort()) {
399
+ const fact = await readMemoryFileIn(dir, entry);
400
+ if (fact !== void 0) facts.push(fact);
401
+ }
386
402
  }
387
403
  try {
388
404
  facts.push(...parseFactsSection(await promises.readFile(memoryMdPath(cwd), "utf8")));
@@ -390,24 +406,25 @@ async function readFactsFromMarkdown(cwd) {
390
406
  }
391
407
  return facts;
392
408
  }
393
- async function readMemoryFileAt(cwd, entry) {
409
+ async function readMemoryFileIn(dir, entry) {
394
410
  if (!entry.endsWith(".md") || entry === "MEMORY.md") return void 0;
395
411
  let raw;
396
412
  try {
397
- raw = await promises.readFile(path.join(memoryDir(cwd), entry), "utf8");
413
+ raw = await promises.readFile(path.join(dir, entry), "utf8");
398
414
  } catch {
399
415
  return void 0;
400
416
  }
401
417
  const parsed = parseMemoryFile(raw);
402
418
  if (parsed === void 0) return void 0;
419
+ const body = parsed.body.trim();
403
420
  return {
404
- text: parsed.description,
421
+ text: body.length > 0 ? body : parsed.description,
405
422
  ...parsed.kind !== void 0 ? { kind: parsed.kind } : {},
406
423
  ...parsed.modified !== void 0 ? { modified: parsed.modified } : {}
407
424
  };
408
425
  }
409
- function appendFactToMarkdown(cwd, fact) {
410
- return chunkZF2LDKQQ_cjs.withCwdMutex(memoryDir(cwd), async () => {
426
+ function appendFactToMarkdown(cwd, fact, targetDir = memoryDir(cwd)) {
427
+ return chunkZF2LDKQQ_cjs.withCwdMutex(targetDir, async () => {
411
428
  if (fact.kind !== void 0 && !MEMORY_KINDS.includes(fact.kind)) {
412
429
  throw new chunkK3FW2XZD_cjs.ConfigurationError(
413
430
  `Unknown memory fact kind "${fact.kind}". Expected one of: ${MEMORY_KINDS.join(", ")}.`,
@@ -416,9 +433,9 @@ function appendFactToMarkdown(cwd, fact) {
416
433
  }
417
434
  const text = chunkJTB5Q42C_cjs.redactSecrets(fact.text);
418
435
  const name = slugForFact(text);
419
- await promises.mkdir(memoryDir(cwd), { recursive: true });
436
+ await promises.mkdir(targetDir, { recursive: true });
420
437
  await chunkI6TGFUCO_cjs.replaceFileAtomic(
421
- path.join(memoryDir(cwd), `${name}.md`),
438
+ path.join(targetDir, `${name}.md`),
422
439
  renderMemoryFile({
423
440
  name,
424
441
  description: text,
@@ -427,13 +444,13 @@ function appendFactToMarkdown(cwd, fact) {
427
444
  body: text
428
445
  })
429
446
  );
430
- await chunkI6TGFUCO_cjs.replaceFileAtomic(memoryMdPath(cwd), await nextIndex(cwd, text, name));
447
+ await chunkI6TGFUCO_cjs.replaceFileAtomic(path.join(targetDir, "MEMORY.md"), await nextIndex(targetDir, text, name));
431
448
  });
432
449
  }
433
- async function nextIndex(cwd, text, name) {
450
+ async function nextIndex(dir, text, name) {
434
451
  let existing = "";
435
452
  try {
436
- existing = await promises.readFile(memoryMdPath(cwd), "utf8");
453
+ existing = await promises.readFile(path.join(dir, "MEMORY.md"), "utf8");
437
454
  } catch {
438
455
  existing = "";
439
456
  }
@@ -454,13 +471,13 @@ function parseFactsSection(raw) {
454
471
  const block = nextHeading === -1 ? tail : tail.slice(0, nextHeading);
455
472
  return block.split("\n").map((line) => line.trim()).filter((line) => line.startsWith("- ")).map((line) => line.slice(2).trim()).filter((body) => !INDEX_ENTRY.test(body)).map((body) => ({ text: body }));
456
473
  }
457
- async function readFacts(cwd, config) {
474
+ async function readFacts(cwd, config, memoryHome) {
458
475
  if (!config.enabled) return [];
459
- return readFactsFromMarkdown(cwd);
476
+ return readFactsFromMarkdown(cwd, memoryHome);
460
477
  }
461
- async function appendFact(cwd, config, fact) {
478
+ async function appendFact(cwd, config, fact, memoryHome) {
462
479
  if (!config.enabled) return;
463
- await appendFactToMarkdown(cwd, fact);
480
+ await appendFactToMarkdown(cwd, fact, memoryWriteDir(cwd, memoryHome));
464
481
  }
465
482
  var MAX_TURN_CHARS = 2e3;
466
483
  function sessionsDir(cwd) {
@@ -1061,5 +1078,5 @@ exports.openMemoryDb = openMemoryDb;
1061
1078
  exports.readFacts = readFacts;
1062
1079
  exports.readFactsFromMarkdown = readFactsFromMarkdown;
1063
1080
  exports.writeSessionSummary = writeSessionSummary;
1064
- //# sourceMappingURL=chunk-E7JHD6QJ.cjs.map
1065
- //# sourceMappingURL=chunk-E7JHD6QJ.cjs.map
1081
+ //# sourceMappingURL=chunk-554J7UQH.cjs.map
1082
+ //# sourceMappingURL=chunk-554J7UQH.cjs.map