@theokit/sdk 5.0.0-next.1 → 5.0.0-next.3

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 (111) hide show
  1. package/CHANGELOG.md +195 -0
  2. package/dist/{agent-XMKRP27S.js → agent-2KJ3IGRA.js} +10 -10
  3. package/dist/{agent-XMKRP27S.js.map → agent-2KJ3IGRA.js.map} +1 -1
  4. package/dist/{agent-CgNzshyV.d.cts → agent-C3KO5LKm.d.cts} +49 -3
  5. package/dist/{agent-CdYJfKr6.d.ts → agent-CvmTR9uf.d.ts} +49 -3
  6. package/dist/{agent-2E7DI47Y.cjs → agent-V6YLX3W6.cjs} +11 -11
  7. package/dist/{agent-2E7DI47Y.cjs.map → agent-V6YLX3W6.cjs.map} +1 -1
  8. package/dist/{chunk-WFC26L6Y.js → chunk-2XRAWOZZ.js} +25 -2
  9. package/dist/chunk-2XRAWOZZ.js.map +1 -0
  10. package/dist/{chunk-XCCGNU3D.js → chunk-4S5TWFIZ.js} +5 -5
  11. package/dist/chunk-4S5TWFIZ.js.map +1 -0
  12. package/dist/{chunk-JTZ74HFD.js → chunk-67ADYSTW.js} +29 -9
  13. package/dist/chunk-67ADYSTW.js.map +1 -0
  14. package/dist/{chunk-2ZLVT7H3.js → chunk-CYKKYNOT.js} +3 -3
  15. package/dist/{chunk-2ZLVT7H3.js.map → chunk-CYKKYNOT.js.map} +1 -1
  16. package/dist/{chunk-WJXOICRC.js → chunk-DX4RUWOK.js} +3 -3
  17. package/dist/{chunk-WJXOICRC.js.map → chunk-DX4RUWOK.js.map} +1 -1
  18. package/dist/{chunk-CEILSTWB.cjs → chunk-GGZ5GPE3.cjs} +29 -8
  19. package/dist/chunk-GGZ5GPE3.cjs.map +1 -0
  20. package/dist/{chunk-7ZK4DJD7.cjs → chunk-GJKMSGZ7.cjs} +4 -4
  21. package/dist/{chunk-7ZK4DJD7.cjs.map → chunk-GJKMSGZ7.cjs.map} +1 -1
  22. package/dist/{chunk-NCGWJ3HS.js → chunk-GO5QW4YL.js} +74 -35
  23. package/dist/chunk-GO5QW4YL.js.map +1 -0
  24. package/dist/{chunk-HWSALKOR.cjs → chunk-H6YM3PV6.cjs} +5 -5
  25. package/dist/chunk-H6YM3PV6.cjs.map +1 -0
  26. package/dist/{chunk-RHZ6HP23.cjs → chunk-IU5N5224.cjs} +8 -8
  27. package/dist/{chunk-RHZ6HP23.cjs.map → chunk-IU5N5224.cjs.map} +1 -1
  28. package/dist/{chunk-UNK4HNJH.js → chunk-J2SH3PNH.js} +3 -3
  29. package/dist/{chunk-UNK4HNJH.js.map → chunk-J2SH3PNH.js.map} +1 -1
  30. package/dist/{chunk-WMH2MSOP.cjs → chunk-K6VDRJ6I.cjs} +114 -75
  31. package/dist/chunk-K6VDRJ6I.cjs.map +1 -0
  32. package/dist/{chunk-2NE7DTOK.cjs → chunk-KBXADFBJ.cjs} +15 -15
  33. package/dist/{chunk-2NE7DTOK.cjs.map → chunk-KBXADFBJ.cjs.map} +1 -1
  34. package/dist/{chunk-6HIACV34.js → chunk-L4RPP6ZC.js} +3 -3
  35. package/dist/{chunk-6HIACV34.js.map → chunk-L4RPP6ZC.js.map} +1 -1
  36. package/dist/{chunk-LKFET5A3.cjs → chunk-LOHMT36V.cjs} +25 -2
  37. package/dist/chunk-LOHMT36V.cjs.map +1 -0
  38. package/dist/{chunk-ILGZ2ZZV.js → chunk-N6OOOYFZ.js} +3 -3
  39. package/dist/{chunk-ILGZ2ZZV.js.map → chunk-N6OOOYFZ.js.map} +1 -1
  40. package/dist/{chunk-LHSWHYF3.cjs → chunk-RXZSVNDG.cjs} +5 -5
  41. package/dist/{chunk-LHSWHYF3.cjs.map → chunk-RXZSVNDG.cjs.map} +1 -1
  42. package/dist/{chunk-G4ZGYKJG.cjs → chunk-SYVWE64W.cjs} +6 -6
  43. package/dist/chunk-SYVWE64W.cjs.map +1 -0
  44. package/dist/{chunk-V6ZY4AX6.cjs → chunk-VNDJS6I3.cjs} +8 -8
  45. package/dist/{chunk-V6ZY4AX6.cjs.map → chunk-VNDJS6I3.cjs.map} +1 -1
  46. package/dist/{chunk-IJM7UGS5.js → chunk-XJZEBGXD.js} +5 -5
  47. package/dist/chunk-XJZEBGXD.js.map +1 -0
  48. package/dist/context/index.cjs +7 -7
  49. package/dist/context/index.js +3 -3
  50. package/dist/{context-74SBFD27.cjs → context-NI33FS2R.cjs} +7 -7
  51. package/dist/{context-74SBFD27.cjs.map → context-NI33FS2R.cjs.map} +1 -1
  52. package/dist/context-Y7B7SI5X.js +6 -0
  53. package/dist/{context-NZ2AC6S7.js.map → context-Y7B7SI5X.js.map} +1 -1
  54. package/dist/{cron-Bw6mSgD4.d.cts → cron-C3PhZED0.d.cts} +1 -1
  55. package/dist/{cron-DJv9oXSZ.d.ts → cron-crfMMdAw.d.ts} +1 -1
  56. package/dist/cron.cjs +10 -10
  57. package/dist/cron.d.cts +3 -3
  58. package/dist/cron.d.ts +3 -3
  59. package/dist/cron.js +9 -9
  60. package/dist/eval.cjs +9 -9
  61. package/dist/eval.js +8 -8
  62. package/dist/{index-manager-QH6OXEV5.js → index-manager-E56WW5RO.js} +5 -5
  63. package/dist/{index-manager-QH6OXEV5.js.map → index-manager-E56WW5RO.js.map} +1 -1
  64. package/dist/{index-manager-DXR2RSFI.cjs → index-manager-OL6HTYAO.cjs} +6 -6
  65. package/dist/{index-manager-DXR2RSFI.cjs.map → index-manager-OL6HTYAO.cjs.map} +1 -1
  66. package/dist/index.cjs +31 -31
  67. package/dist/index.d.cts +5 -5
  68. package/dist/index.d.ts +5 -5
  69. package/dist/index.js +13 -13
  70. package/dist/internal/memory/storage/index.cjs +31 -31
  71. package/dist/internal/memory/storage/index.js +3 -3
  72. package/dist/internal/persistence/index.cjs +4 -4
  73. package/dist/internal/persistence/index.js +1 -1
  74. package/dist/internal/persistence/paths.d.cts +25 -12
  75. package/dist/internal/persistence/paths.d.ts +25 -12
  76. package/dist/internal/runtime/compat/compat-config-file.d.ts +31 -0
  77. package/dist/internal/runtime/compat/foreign-config-sources.d.ts +31 -1
  78. package/dist/internal/runtime/hooks/hooks-executor.d.ts +2 -1
  79. package/dist/internal/runtime/plugin-loader/plugin-bundles.d.ts +2 -1
  80. package/dist/project.cjs +3 -3
  81. package/dist/project.js +1 -1
  82. package/dist/{sdk-agent-Dxjb0IfM.d.cts → sdk-agent-BOiKqOgL.d.cts} +28 -1
  83. package/dist/{sdk-agent-ldzpyAaF.d.ts → sdk-agent-D4a_BR_6.d.ts} +28 -1
  84. package/dist/subagents-loader-TPZLTXYZ.cjs +16 -0
  85. package/dist/{subagents-loader-YWFE7KYE.cjs.map → subagents-loader-TPZLTXYZ.cjs.map} +1 -1
  86. package/dist/subagents-loader-Y6JFYXAY.js +7 -0
  87. package/dist/{subagents-loader-LSKM2UIK.js.map → subagents-loader-Y6JFYXAY.js.map} +1 -1
  88. package/dist/subagents-loader.cjs +3 -3
  89. package/dist/subagents-loader.d.cts +2 -2
  90. package/dist/subagents-loader.d.ts +2 -2
  91. package/dist/subagents-loader.js +2 -2
  92. package/dist/types/agent.d.ts +47 -1
  93. package/dist/types/sdk-agent.d.ts +28 -1
  94. package/dist/workflow.d.cts +1 -1
  95. package/dist/workflow.d.ts +1 -1
  96. package/docs/error-codes.md +21 -21
  97. package/docs/harness-capability-map.md +3 -1
  98. package/package.json +1 -1
  99. package/dist/chunk-CEILSTWB.cjs.map +0 -1
  100. package/dist/chunk-G4ZGYKJG.cjs.map +0 -1
  101. package/dist/chunk-HWSALKOR.cjs.map +0 -1
  102. package/dist/chunk-IJM7UGS5.js.map +0 -1
  103. package/dist/chunk-JTZ74HFD.js.map +0 -1
  104. package/dist/chunk-LKFET5A3.cjs.map +0 -1
  105. package/dist/chunk-NCGWJ3HS.js.map +0 -1
  106. package/dist/chunk-WFC26L6Y.js.map +0 -1
  107. package/dist/chunk-WMH2MSOP.cjs.map +0 -1
  108. package/dist/chunk-XCCGNU3D.js.map +0 -1
  109. package/dist/context-NZ2AC6S7.js +0 -6
  110. package/dist/subagents-loader-LSKM2UIK.js +0 -7
  111. package/dist/subagents-loader-YWFE7KYE.cjs +0 -16
package/CHANGELOG.md CHANGED
@@ -1,5 +1,200 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.0.0-next.3
4
+
5
+ ### Minor Changes
6
+
7
+ - ae2a720: `THEO.md` now works at the project root, the way `AGENTS.md`, `GEMINI.md` and `CLAUDE.md` already
8
+ do — found from the root, and reachable by walking up from any subdirectory.
9
+
10
+ Before this, `THEO.md` was the only context file this SDK knows about that had to live inside
11
+ `.theokit/` and could not be found from a subdirectory. The miss was silent: a well-formed
12
+ `THEO.md` at the project root was simply never read, with no warning that it had been ignored.
13
+
14
+ ```
15
+ project/
16
+ ├── THEO.md ← now read, walking up from any subdirectory
17
+ └── .theokit/
18
+ └── THEO.md ← still works exactly as before
19
+ ```
20
+
21
+ A new `DEFAULT_DISCOVERY_SPECS` entry (`THEO.md.root`, priority 55) is added alongside the
22
+ existing one — nothing about `.theokit/THEO.md` changes, so a project already using it keeps
23
+ working unchanged. When both exist, `.theokit/THEO.md` is the later, winning source on conflict —
24
+ the precedence usetheokit/theokit-sdk#531 asked for.
25
+
26
+ The new entry sets `followImports: true`, unlike `.theokit/THEO.md` (`false`) and unlike
27
+ `AGENTS.md`. This is deliberate, not an inconsistency: a root-level `THEO.md` is edited by the same
28
+ people, in the same place, as `CLAUDE.md`/`GEMINI.md` — the two other root-level files, both
29
+ `followImports: true` — so it belongs in their category rather than `AGENTS.md`'s vendor-neutral,
30
+ import-free one. Flagged as an open decision in the issue; resolved here because adding a new spec
31
+ rather than reusing the existing one meant it could be decided on its own merits, with zero
32
+ behaviour change for existing `.theokit/THEO.md` files either way.
33
+
34
+ Closes usetheokit/theokit-sdk#531.
35
+
36
+ ## 5.0.0-next.2
37
+
38
+ ### Minor Changes
39
+
40
+ - 88e87d0: A foreign configuration source can now be admitted to some surfaces and not others.
41
+
42
+ `compatSources: ["claude-code"]` was all-or-nothing: declaring it admitted `.claude/` to hooks,
43
+ plugins, skills AND subagents at once. The four carry very different risk — a skill is text that
44
+ enters the system prompt, a plugin is code loading, a hook is command execution — so a consumer who
45
+ wanted to reuse the skills they had already written was handed arbitrary command execution along
46
+ with them, and had no way to say otherwise.
47
+
48
+ ```ts
49
+ local: {
50
+ compatSources: [{ kind: "claude-code", import: ["skills", "subagents"] }],
51
+ }
52
+ ```
53
+
54
+ Hooks and plugins then resolve `.theokit/` alone. `CompatSurface` and `CompatSourceAdapter` are
55
+ exported.
56
+
57
+ Three rules, each failing closed:
58
+
59
+ - **The bare `"claude-code"` string still admits every surface.** It is what `5.0.0-next.1`
60
+ published, and narrowing it silently would turn a working opt-in into a no-op that says nothing —
61
+ the defect this option exists to fix, one level up.
62
+ - **An adapter with no `import` list admits nothing.** Safe to apply strictly because the object
63
+ form is new and nobody can be relying on it yet.
64
+ - **An unrecognised surface name is dropped**, exactly as an unrecognised `kind` already is. A typo
65
+ must narrow access, never widen it.
66
+
67
+ The `plugins` surface governs reading a foreign plugin directory even when the caller wants the
68
+ SKILLS a bundle carries: a bundle is code, and its skills arrive attached to it, so admitting
69
+ `skills` alone must not reach inside one. Otherwise the narrower permission would silently grant
70
+ the wider one.
71
+
72
+ Closes the per-surface half of usetheokit/theokit-sdk#524. The visibility half — skills, subagents
73
+ and plugins carrying the root they came from, the way hooks already carry `sourcePath` — and the
74
+ declarative `.theokit/config.toml` form are not in this change.
75
+ - 33aa170: A project can now declare its foreign compat sources in `.theokit/config.json`, instead of only in
76
+ code.
77
+
78
+ ```json
79
+ {
80
+ "compat": {
81
+ "adapters": [{ "kind": "claude-code", "import": ["skills", "subagents"] }]
82
+ }
83
+ }
84
+ ```
85
+
86
+ The DECLARATIVE half usetheokit/theokit-sdk#524 asked for, in a `## Sketch` written against TOML.
87
+ It ships as JSON: this SDK already reads JSON everywhere a project declares something
88
+ (`settings.json`, `mcp.json`, `context.json`) and carries no TOML parser or dependency for one —
89
+ adding one for a single optional section would be the opposite of what #522/#524 are about, reading
90
+ in a new format nobody asked this SDK to speak. The shape is unchanged: `compat.adapters` accepts
91
+ exactly what `local.compatSources` already does in code — a bare kind string, or `{ kind, import }`.
92
+
93
+ **Precedence, decided here because the issue does not state it:** explicit `local.compatSources` in
94
+ code wins over the file. The file is the default for a caller who declared nothing. A test or a
95
+ one-off script can therefore always override the file without editing or deleting it.
96
+
97
+ Read with `readFileSync`, not this package's usual async reader: the caller is `Agent`'s
98
+ synchronous constructor, which resolves `compatSources` before any submanager exists to await a
99
+ promise. `existsSync` already runs in the same constructor for the same reason.
100
+
101
+ One resolver, `resolveCompatSources(options, cwd)`, replaces five call sites that each wrote
102
+ `options.local?.compatSources ?? []` by hand — the same duplication `theokitConfigRoot` closed one
103
+ layer down, closed here one layer up, so the file form reaches all four surfaces (hooks, skills,
104
+ plugins, subagents) through the one place rather than needing five separate edits that could drift.
105
+
106
+ Closes the declarative half of #524. `#524` itself stays open until it is verified in an installed
107
+ release, per this project's issue-lifecycle convention.
108
+ - e7cf2dd: A skill, subagent or plugin now says which directory it was read from.
109
+
110
+ usetheokit/theokit-sdk#524 asks for it in one line — *"whatever is imported should be reportable […]
111
+ silent inheritance is what made this take a debugging session to notice"* — and a consumer listing
112
+ its own skills could not tell that one had arrived from `.claude/skills/` rather than the project's
113
+ own directory.
114
+
115
+ What is new is not the data. It existed on all three and did not reach the caller:
116
+
117
+ - `Skill.source` was already the absolute path to the `SKILL.md`, and the projection that builds
118
+ `agent.skills` mapped it away along with the body. The projection is right to drop the BODY —
119
+ that is what `get()` is for — and dropping the PATH with it answered a question nobody asked.
120
+ - `agent.plugins.list()` has always returned `source` at runtime; the internal type's own docblock
121
+ says it carries provenance "so callers can audit where the plugin came from". `SDKPluginMetadata`
122
+ simply never declared it, so the caller received the field and the compiler denied it existed.
123
+ - `readSubagentsFrom` computes the file path on the line it reads the file, then dropped it.
124
+ `AgentDefinition.source` keeps it.
125
+
126
+ `source` is optional on all three, and absence means something specific: declared in code, not read
127
+ from disk. A subagent passed through `AgentOptions.subagents` has no file and `source` is absent.
128
+ An inline `createSkill` skill has no file either, but already carried the synthetic `inline://<name>`
129
+ marker before this change (`create-skill.ts`) — so a skill's `source` is now populated for every
130
+ entry `list()` returns, either a disk path or that marker, and a first version of this fix wrongly
131
+ described it as absent for that case. An existing regression test (`agent-skills-get.test.ts`,
132
+ SE21) asserted `list()` must NOT carry `source` at all; it predates #524 and is updated here to
133
+ assert the marker instead, while still proving the skill's body and references never leak.
134
+
135
+ `SkillsHandle.list` is now typed as the public `SystemPromptSkillRef` instead of restating
136
+ `{ name; description }` inline. The two had drifted, and an internal handle declaring a narrower
137
+ shape than the contract it serves silently deletes fields the projection produces — which is exactly
138
+ how `source` reached the caller at runtime while not existing to the compiler.
139
+
140
+ Closes the visibility half of #524. The declarative `.theokit/config.toml` form is not in this
141
+ change.
142
+
143
+ ### Patch Changes
144
+
145
+ - 070ee92: A foreign plugin's entry file is now checked against the root it was actually discovered under.
146
+
147
+ `refresh()` iterates every root a compat source admits — `.theokit/plugins`, and `.claude/plugins`
148
+ once `compatSources` names the `plugins` surface — and checks each plugin's declared `entry` file
149
+ exists. That check reconstructed the plugin's directory as `.theokit/plugins/<folder>`
150
+ unconditionally, regardless of which root the plugin was actually found under.
151
+
152
+ A plugin discovered at `.claude/plugins/my-plugin/` was therefore checked against
153
+ `.theokit/plugins/my-plugin/` — a directory it never lived in. With nothing there, a legitimate
154
+ foreign plugin was refused as "entry file is missing." Had a same-named folder existed under
155
+ `.theokit/plugins/` instead, its entry file would have been read in place of the real one — a path
156
+ confusion the ADR D79-D80 traversal guard this check calls does not catch, because the guard runs
157
+ against the wrong root rather than against none.
158
+
159
+ This was reachable through the bare `compatSources: ["claude-code"]` form, which has always admitted
160
+ the `plugins` surface — not something the per-surface work landing alongside this introduced.
161
+
162
+ Found while testing the per-surface admission work for usetheokit/theokit-sdk#524.
163
+ - 131ab8b: A foreign plugin's `source` field is now a real relative path instead of a single character.
164
+
165
+ Both manifest loaders (Claude Code's `.claude-plugin/plugin.json` form and this SDK's own
166
+ `PLUGIN.md`/`plugin.json`) built `source` by searching the manifest path for the literal substring
167
+ `.theokit/` and slicing from there. A manifest read from `.claude/plugins/<name>/…` contains no such
168
+ substring: `indexOf` returns `-1`, and `.slice(-1)` silently returned the manifest path's LAST
169
+ CHARACTER — `"n"` from `.json`, `"d"` from `PLUGIN.md` — instead of a path.
170
+
171
+ `source` is exactly the audit trail the visibility half of usetheokit/theokit-sdk#524 exists to
172
+ provide, and this was broken for precisely the case that matters most: a plugin admitted from a
173
+ foreign root. Replaced the substring search with `path.relative(cwd, manifestPath)` — the stdlib
174
+ does this correctly, and it is what the substring search was trying to approximate.
175
+
176
+ Found alongside the entry-file root confusion, testing the same per-surface admission work.
177
+ - 7b4063b: One resolver now answers "where does this project's configuration live?" — `theokitConfigRoot(cwd)`,
178
+ in `internal/persistence/paths.ts`, semver-exempt.
179
+
180
+ Five readers hand-rolled `join(cwd, ".theokit", ...)` independently: `mcp.json`, the context
181
+ directory + `context.json`, the hooks-root fallback check, `registry.json`, and the personality
182
+ `PROJECT_SUBDIR`. `projectConfigRoots` (hooks/skills/subagents/plugins, per usetheokit/theokit-sdk#524)
183
+ already resolved its native root the same way, inline, making six independent copies of one
184
+ constant.
185
+
186
+ No filename, format or resulting path changes — this is a pure consolidation, and the project's own
187
+ lint gate (`no-hardcoded-theokit-path.test.ts`, ratcheted 23 → 14) is the proof: every literal this
188
+ change removed was already flagged as migration debt, and the full suite is unchanged.
189
+
190
+ Deliberately does NOT touch homedir-anchored state (sessions, credentials, the personality
191
+ `USER_SUBDIR`, provider discovery) — those follow `getTheokitHome`/`THEOKIT_HOME` by design, and
192
+ folding them into this resolver would be the exact silent behaviour change
193
+ `theokitConfigRoot`'s own docblock warns against: a project's committed configuration must never
194
+ follow an operator's relocated state directory. A regression test pins this — swapping the
195
+ resolver's body for `getTheokitHome`'s would move all six readers under `THEOKIT_HOME` at once, in
196
+ one line, with no caller-side signal.
197
+
3
198
  ## 5.0.0-next.1
4
199
 
5
200
  ### Major Changes
@@ -1,14 +1,14 @@
1
- export { Agent } from './chunk-NCGWJ3HS.js';
1
+ export { Agent } from './chunk-GO5QW4YL.js';
2
2
  import './chunk-K2VMFZQ5.js';
3
3
  import './chunk-AWINL3ZC.js';
4
4
  import './chunk-K2BQQ445.js';
5
- import './chunk-2ZLVT7H3.js';
6
- import './chunk-IJM7UGS5.js';
5
+ import './chunk-CYKKYNOT.js';
6
+ import './chunk-XJZEBGXD.js';
7
7
  import './chunk-2SFBB54R.js';
8
8
  import './chunk-55GB6JYQ.js';
9
9
  import './chunk-H73MEMQB.js';
10
10
  import './chunk-OR6XIWLB.js';
11
- import './chunk-UNK4HNJH.js';
11
+ import './chunk-J2SH3PNH.js';
12
12
  import './chunk-AAEZSPTC.js';
13
13
  import './chunk-K3NH62DG.js';
14
14
  import './chunk-UBR5PWD7.js';
@@ -17,7 +17,7 @@ import './chunk-XB4GI5RZ.js';
17
17
  import './chunk-24MGQDK3.js';
18
18
  import './chunk-2WXHA33T.js';
19
19
  import './chunk-HKCKOAIO.js';
20
- import './chunk-ILGZ2ZZV.js';
20
+ import './chunk-N6OOOYFZ.js';
21
21
  import './chunk-KVNWIAO4.js';
22
22
  import './chunk-SVQIW5RJ.js';
23
23
  import './chunk-FD2UT76F.js';
@@ -27,7 +27,7 @@ import './chunk-NAF4L3T6.js';
27
27
  import './chunk-6WAKKTBO.js';
28
28
  import './chunk-6X6ID4MO.js';
29
29
  import './chunk-XDANGA2C.js';
30
- import './chunk-WFC26L6Y.js';
30
+ import './chunk-2XRAWOZZ.js';
31
31
  import './chunk-SAGRF4IB.js';
32
32
  import './chunk-EH6XD3FY.js';
33
33
  import './chunk-UKMBRMGT.js';
@@ -41,8 +41,8 @@ import './chunk-TA3K7SBK.js';
41
41
  import './chunk-Q5EWJPRY.js';
42
42
  import './chunk-EIQFAOFD.js';
43
43
  import './chunk-3JHIFQ4I.js';
44
- import './chunk-XCCGNU3D.js';
45
- import './chunk-JTZ74HFD.js';
44
+ import './chunk-4S5TWFIZ.js';
45
+ import './chunk-67ADYSTW.js';
46
46
  import './chunk-JNAA4G4H.js';
47
47
  import './chunk-6M2OIS4Y.js';
48
48
  import './chunk-R7WIIPUR.js';
@@ -54,5 +54,5 @@ import './chunk-V22DZIXO.js';
54
54
  import './chunk-NJWYQWDL.js';
55
55
  import './chunk-ALUN2B4W.js';
56
56
  import './chunk-CZJ6Q7CW.js';
57
- //# sourceMappingURL=agent-XMKRP27S.js.map
58
- //# sourceMappingURL=agent-XMKRP27S.js.map
57
+ //# sourceMappingURL=agent-2KJ3IGRA.js.map
58
+ //# sourceMappingURL=agent-2KJ3IGRA.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-XMKRP27S.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-2KJ3IGRA.js"}
@@ -1,4 +1,4 @@
1
- import { n as MemoryFact, k as MemoryAdapter, m as MemoryContext, E as SystemPromptSkillRef, C as ContextSettings, P as ProviderRoutingSettings, a as PluginsSettings, S as SDKAgent } from './sdk-agent-Dxjb0IfM.cjs';
1
+ import { n as MemoryFact, k as MemoryAdapter, m as MemoryContext, E as SystemPromptSkillRef, C as ContextSettings, P as ProviderRoutingSettings, a as PluginsSettings, S as SDKAgent } from './sdk-agent-BOiKqOgL.cjs';
2
2
  import { M as ModelSelection, C as CustomTool, c as PermissionMode, a as McpServerConfig, P as Processor } from './run-CTAdRU3U.cjs';
3
3
 
4
4
  /**
@@ -952,7 +952,39 @@ type SettingSource = "project" | "user" | "team" | "mdm" | "plugins" | "all";
952
952
  *
953
953
  * @public
954
954
  */
955
- type CompatSource = "claude-code";
955
+ type CompatSource = "claude-code" | CompatSourceAdapter;
956
+ /**
957
+ * A surface a foreign configuration source may be admitted to.
958
+ *
959
+ * They are named separately because they carry very different risk. A skill is TEXT that enters the
960
+ * system prompt; a subagent is a definition; a plugin is CODE LOADING; a hook is COMMAND EXECUTION.
961
+ * Reusing the skills you already wrote for another product is a reasonable thing to want, and it is
962
+ * not a reason to hand that product's directory the right to run commands.
963
+ *
964
+ * @public
965
+ */
966
+ type CompatSurface = "hooks" | "plugins" | "skills" | "subagents";
967
+ /**
968
+ * A foreign source admitted to named surfaces only.
969
+ *
970
+ * ```ts
971
+ * local: { compatSources: [{ kind: "claude-code", import: ["skills", "subagents"] }] }
972
+ * ```
973
+ *
974
+ * `import` is not optional in spirit even though it is in the type: an adapter that omits it
975
+ * imports NOTHING. That is deliberate and it is the fail-closed rule this whole option exists to
976
+ * serve — a typo in a surface name must narrow access, never widen it.
977
+ *
978
+ * The bare `"claude-code"` string keeps meaning every surface. It is what `5.0.0-next.1` published,
979
+ * and silently narrowing it would turn a working opt-in into a no-op that says nothing — which is
980
+ * the defect usetheokit/theokit-sdk#524 reports, one level up.
981
+ *
982
+ * @public
983
+ */
984
+ interface CompatSourceAdapter {
985
+ readonly kind: "claude-code";
986
+ readonly import?: readonly CompatSurface[];
987
+ }
956
988
  /**
957
989
  * A tool the SDK declares to the model on its own initiative — not one the consumer passed in
958
990
  * {@link AgentOptions.tools}, and not one an MCP server exposed.
@@ -1098,6 +1130,20 @@ interface CloudOptions {
1098
1130
  interface AgentDefinition {
1099
1131
  description: string;
1100
1132
  prompt: string;
1133
+ /**
1134
+ * Absolute path to the `.md` this subagent was read from, when it came from disk.
1135
+ *
1136
+ * ABSENT for a subagent declared in code through {@link AgentOptions.subagents} — "you passed
1137
+ * this one in" is a different fact from "read from disk", and one value for both would trade one
1138
+ * silence for another.
1139
+ *
1140
+ * It exists so a listing can answer which root a subagent came from, which
1141
+ * usetheokit/theokit-sdk#524 asks for by name: a consumer could not tell that an agent arrived
1142
+ * from `.claude/agents/` rather than its own directory, and silent inheritance is what made that
1143
+ * take a debugging session to notice. `HookCommand.sourcePath` and `Skill.source` already
1144
+ * answered it for the other two surfaces.
1145
+ */
1146
+ source?: string;
1101
1147
  model?: ModelSelection | "inherit";
1102
1148
  mcpServers?: Array<string | Record<string, McpServerConfig>>;
1103
1149
  /**
@@ -1822,4 +1868,4 @@ interface ListResult<T> {
1822
1868
  nextCursor?: string;
1823
1869
  }
1824
1870
 
1825
- export { type SkillsResolver as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type MemoryProviderHandle as D, type MemoryProviderInitOptions as E, type PluginContext as F, type GetAgentOptions as G, type HookName as H, type InlineSkill as I, type PluginHookDisposer as J, type PostAssistantReplyContext as K, type LocalOptions as L, type MemorySettings as M, type PostToolCallContext as N, type PreToolCallContext as O, type Plugin as P, type PreUserSendContext as Q, type PreUserSendResult as R, type SystemPromptResolver as S, type ProviderTransform as T, type ProviderTransformContext as U, type RecordSessionSummaryArgs as V, type SessionLifecycleContext as W, type SessionRecord as X, type SessionStore as Y, type SettingSource as Z, Skill as _, type AgentDefinition as a, type SkillsResolverContext as a0, type SystemPromptContext as a1, type SystemPromptMemoryFact as a2, type TelemetrySettings as a3, type ToolCallSummary as a4, type ToolResultTransformContext as a5, type TransformContext as a6, type SkillsSettings as b, type ListAgentsOptions as c, type ListResult as d, type SDKAgentInfo as e, type ListRunsOptions as f, type GetRunOptions as g, type AgentOperationOptions as h, type AgentDescription as i, type ProviderProfile as j, type MemoryProvider as k, type PreToolCallDecision as l, type ActiveMemoryPassArgs as m, type ActiveMemoryPassResult as n, type AgentSubagentDescription as o, type AgentToolDescription as p, type BudgetCheck as q, type BudgetTotal as r, type BudgetUsageEvent as s, type BuiltinToolName as t, type CloudEnv as u, type CloudRepo as v, type CompatSource as w, type CreateSkillSpec as x, type MemoryProviderAgentRef as y, type MemoryProviderFactory as z };
1871
+ export { type SettingSource as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type MemoryProviderAgentRef as D, type MemoryProviderFactory as E, type MemoryProviderHandle as F, type GetAgentOptions as G, type HookName as H, type InlineSkill as I, type MemoryProviderInitOptions as J, type PluginContext as K, type LocalOptions as L, type MemorySettings as M, type PluginHookDisposer as N, type PostAssistantReplyContext as O, type Plugin as P, type PostToolCallContext as Q, type PreToolCallContext as R, type SystemPromptResolver as S, type PreUserSendContext as T, type PreUserSendResult as U, type ProviderTransform as V, type ProviderTransformContext as W, type RecordSessionSummaryArgs as X, type SessionLifecycleContext as Y, type SessionRecord as Z, type SessionStore as _, type AgentDefinition as a, Skill as a0, type SkillsResolver as a1, type SkillsResolverContext as a2, type SystemPromptContext as a3, type SystemPromptMemoryFact as a4, type TelemetrySettings as a5, type ToolCallSummary as a6, type ToolResultTransformContext as a7, type TransformContext as a8, type SkillsSettings as b, type ListAgentsOptions as c, type ListResult as d, type SDKAgentInfo as e, type ListRunsOptions as f, type GetRunOptions as g, type AgentOperationOptions as h, type AgentDescription as i, type ProviderProfile as j, type MemoryProvider as k, type PreToolCallDecision as l, type ActiveMemoryPassArgs as m, type ActiveMemoryPassResult as n, type AgentSubagentDescription as o, type AgentToolDescription as p, type BudgetCheck as q, type BudgetTotal as r, type BudgetUsageEvent as s, type BuiltinToolName as t, type CloudEnv as u, type CloudRepo as v, type CompatSource as w, type CompatSourceAdapter as x, type CompatSurface as y, type CreateSkillSpec as z };
@@ -1,4 +1,4 @@
1
- import { n as MemoryFact, k as MemoryAdapter, m as MemoryContext, E as SystemPromptSkillRef, C as ContextSettings, P as ProviderRoutingSettings, a as PluginsSettings, S as SDKAgent } from './sdk-agent-ldzpyAaF.js';
1
+ import { n as MemoryFact, k as MemoryAdapter, m as MemoryContext, E as SystemPromptSkillRef, C as ContextSettings, P as ProviderRoutingSettings, a as PluginsSettings, S as SDKAgent } from './sdk-agent-D4a_BR_6.js';
2
2
  import { M as ModelSelection, C as CustomTool, c as PermissionMode, a as McpServerConfig, P as Processor } from './run-CTAdRU3U.js';
3
3
 
4
4
  /**
@@ -952,7 +952,39 @@ type SettingSource = "project" | "user" | "team" | "mdm" | "plugins" | "all";
952
952
  *
953
953
  * @public
954
954
  */
955
- type CompatSource = "claude-code";
955
+ type CompatSource = "claude-code" | CompatSourceAdapter;
956
+ /**
957
+ * A surface a foreign configuration source may be admitted to.
958
+ *
959
+ * They are named separately because they carry very different risk. A skill is TEXT that enters the
960
+ * system prompt; a subagent is a definition; a plugin is CODE LOADING; a hook is COMMAND EXECUTION.
961
+ * Reusing the skills you already wrote for another product is a reasonable thing to want, and it is
962
+ * not a reason to hand that product's directory the right to run commands.
963
+ *
964
+ * @public
965
+ */
966
+ type CompatSurface = "hooks" | "plugins" | "skills" | "subagents";
967
+ /**
968
+ * A foreign source admitted to named surfaces only.
969
+ *
970
+ * ```ts
971
+ * local: { compatSources: [{ kind: "claude-code", import: ["skills", "subagents"] }] }
972
+ * ```
973
+ *
974
+ * `import` is not optional in spirit even though it is in the type: an adapter that omits it
975
+ * imports NOTHING. That is deliberate and it is the fail-closed rule this whole option exists to
976
+ * serve — a typo in a surface name must narrow access, never widen it.
977
+ *
978
+ * The bare `"claude-code"` string keeps meaning every surface. It is what `5.0.0-next.1` published,
979
+ * and silently narrowing it would turn a working opt-in into a no-op that says nothing — which is
980
+ * the defect usetheokit/theokit-sdk#524 reports, one level up.
981
+ *
982
+ * @public
983
+ */
984
+ interface CompatSourceAdapter {
985
+ readonly kind: "claude-code";
986
+ readonly import?: readonly CompatSurface[];
987
+ }
956
988
  /**
957
989
  * A tool the SDK declares to the model on its own initiative — not one the consumer passed in
958
990
  * {@link AgentOptions.tools}, and not one an MCP server exposed.
@@ -1098,6 +1130,20 @@ interface CloudOptions {
1098
1130
  interface AgentDefinition {
1099
1131
  description: string;
1100
1132
  prompt: string;
1133
+ /**
1134
+ * Absolute path to the `.md` this subagent was read from, when it came from disk.
1135
+ *
1136
+ * ABSENT for a subagent declared in code through {@link AgentOptions.subagents} — "you passed
1137
+ * this one in" is a different fact from "read from disk", and one value for both would trade one
1138
+ * silence for another.
1139
+ *
1140
+ * It exists so a listing can answer which root a subagent came from, which
1141
+ * usetheokit/theokit-sdk#524 asks for by name: a consumer could not tell that an agent arrived
1142
+ * from `.claude/agents/` rather than its own directory, and silent inheritance is what made that
1143
+ * take a debugging session to notice. `HookCommand.sourcePath` and `Skill.source` already
1144
+ * answered it for the other two surfaces.
1145
+ */
1146
+ source?: string;
1101
1147
  model?: ModelSelection | "inherit";
1102
1148
  mcpServers?: Array<string | Record<string, McpServerConfig>>;
1103
1149
  /**
@@ -1822,4 +1868,4 @@ interface ListResult<T> {
1822
1868
  nextCursor?: string;
1823
1869
  }
1824
1870
 
1825
- export { type SkillsResolver as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type MemoryProviderHandle as D, type MemoryProviderInitOptions as E, type PluginContext as F, type GetAgentOptions as G, type HookName as H, type InlineSkill as I, type PluginHookDisposer as J, type PostAssistantReplyContext as K, type LocalOptions as L, type MemorySettings as M, type PostToolCallContext as N, type PreToolCallContext as O, type Plugin as P, type PreUserSendContext as Q, type PreUserSendResult as R, type SystemPromptResolver as S, type ProviderTransform as T, type ProviderTransformContext as U, type RecordSessionSummaryArgs as V, type SessionLifecycleContext as W, type SessionRecord as X, type SessionStore as Y, type SettingSource as Z, Skill as _, type AgentDefinition as a, type SkillsResolverContext as a0, type SystemPromptContext as a1, type SystemPromptMemoryFact as a2, type TelemetrySettings as a3, type ToolCallSummary as a4, type ToolResultTransformContext as a5, type TransformContext as a6, type SkillsSettings as b, type ListAgentsOptions as c, type ListResult as d, type SDKAgentInfo as e, type ListRunsOptions as f, type GetRunOptions as g, type AgentOperationOptions as h, type AgentDescription as i, type ProviderProfile as j, type MemoryProvider as k, type PreToolCallDecision as l, type ActiveMemoryPassArgs as m, type ActiveMemoryPassResult as n, type AgentSubagentDescription as o, type AgentToolDescription as p, type BudgetCheck as q, type BudgetTotal as r, type BudgetUsageEvent as s, type BuiltinToolName as t, type CloudEnv as u, type CloudRepo as v, type CompatSource as w, type CreateSkillSpec as x, type MemoryProviderAgentRef as y, type MemoryProviderFactory as z };
1871
+ export { type SettingSource as $, type AgentOptions as A, type BudgetTracker as B, type CloudOptions as C, type MemoryProviderAgentRef as D, type MemoryProviderFactory as E, type MemoryProviderHandle as F, type GetAgentOptions as G, type HookName as H, type InlineSkill as I, type MemoryProviderInitOptions as J, type PluginContext as K, type LocalOptions as L, type MemorySettings as M, type PluginHookDisposer as N, type PostAssistantReplyContext as O, type Plugin as P, type PostToolCallContext as Q, type PreToolCallContext as R, type SystemPromptResolver as S, type PreUserSendContext as T, type PreUserSendResult as U, type ProviderTransform as V, type ProviderTransformContext as W, type RecordSessionSummaryArgs as X, type SessionLifecycleContext as Y, type SessionRecord as Z, type SessionStore as _, type AgentDefinition as a, Skill as a0, type SkillsResolver as a1, type SkillsResolverContext as a2, type SystemPromptContext as a3, type SystemPromptMemoryFact as a4, type TelemetrySettings as a5, type ToolCallSummary as a6, type ToolResultTransformContext as a7, type TransformContext as a8, type SkillsSettings as b, type ListAgentsOptions as c, type ListResult as d, type SDKAgentInfo as e, type ListRunsOptions as f, type GetRunOptions as g, type AgentOperationOptions as h, type AgentDescription as i, type ProviderProfile as j, type MemoryProvider as k, type PreToolCallDecision as l, type ActiveMemoryPassArgs as m, type ActiveMemoryPassResult as n, type AgentSubagentDescription as o, type AgentToolDescription as p, type BudgetCheck as q, type BudgetTotal as r, type BudgetUsageEvent as s, type BuiltinToolName as t, type CloudEnv as u, type CloudRepo as v, type CompatSource as w, type CompatSourceAdapter as x, type CompatSurface as y, type CreateSkillSpec as z };
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkWMH2MSOP_cjs = require('./chunk-WMH2MSOP.cjs');
3
+ var chunkK6VDRJ6I_cjs = require('./chunk-K6VDRJ6I.cjs');
4
4
  require('./chunk-KVSAY6NZ.cjs');
5
5
  require('./chunk-Y2KYR2ED.cjs');
6
6
  require('./chunk-BUUUWQMB.cjs');
7
- require('./chunk-2NE7DTOK.cjs');
8
- require('./chunk-HWSALKOR.cjs');
7
+ require('./chunk-KBXADFBJ.cjs');
8
+ require('./chunk-H6YM3PV6.cjs');
9
9
  require('./chunk-BV2MWEMV.cjs');
10
10
  require('./chunk-D6POWE7E.cjs');
11
11
  require('./chunk-GHX4P3V2.cjs');
12
12
  require('./chunk-TMKTSYDS.cjs');
13
- require('./chunk-LHSWHYF3.cjs');
13
+ require('./chunk-RXZSVNDG.cjs');
14
14
  require('./chunk-7FDKWDA2.cjs');
15
15
  require('./chunk-2HPNT6HH.cjs');
16
16
  require('./chunk-FUSDYC2B.cjs');
@@ -19,7 +19,7 @@ require('./chunk-24SYBZPL.cjs');
19
19
  require('./chunk-QOGNZMHD.cjs');
20
20
  require('./chunk-YIFFF23U.cjs');
21
21
  require('./chunk-2ZPEDVLM.cjs');
22
- require('./chunk-RHZ6HP23.cjs');
22
+ require('./chunk-IU5N5224.cjs');
23
23
  require('./chunk-KRD3GQAA.cjs');
24
24
  require('./chunk-RQMCOFAI.cjs');
25
25
  require('./chunk-MUUQ2WFJ.cjs');
@@ -29,7 +29,7 @@ require('./chunk-FRITRLZQ.cjs');
29
29
  require('./chunk-QME6FDFG.cjs');
30
30
  require('./chunk-NINIJCHU.cjs');
31
31
  require('./chunk-UGRS7ZA7.cjs');
32
- require('./chunk-LKFET5A3.cjs');
32
+ require('./chunk-LOHMT36V.cjs');
33
33
  require('./chunk-IJ7M6GOG.cjs');
34
34
  require('./chunk-7A6535RA.cjs');
35
35
  require('./chunk-SA6K24NB.cjs');
@@ -43,8 +43,8 @@ require('./chunk-BJUJT5ED.cjs');
43
43
  require('./chunk-ZF2LDKQQ.cjs');
44
44
  require('./chunk-HCT4HPCL.cjs');
45
45
  require('./chunk-JLRLCBJ4.cjs');
46
- require('./chunk-G4ZGYKJG.cjs');
47
- require('./chunk-CEILSTWB.cjs');
46
+ require('./chunk-SYVWE64W.cjs');
47
+ require('./chunk-GGZ5GPE3.cjs');
48
48
  require('./chunk-HW7SEELD.cjs');
49
49
  require('./chunk-ATT276RD.cjs');
50
50
  require('./chunk-3EE6LVWT.cjs');
@@ -61,7 +61,7 @@ require('./chunk-6LHQPOMI.cjs');
61
61
 
62
62
  Object.defineProperty(exports, "Agent", {
63
63
  enumerable: true,
64
- get: function () { return chunkWMH2MSOP_cjs.Agent; }
64
+ get: function () { return chunkK6VDRJ6I_cjs.Agent; }
65
65
  });
66
- //# sourceMappingURL=agent-2E7DI47Y.cjs.map
67
- //# sourceMappingURL=agent-2E7DI47Y.cjs.map
66
+ //# sourceMappingURL=agent-V6YLX3W6.cjs.map
67
+ //# sourceMappingURL=agent-V6YLX3W6.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-2E7DI47Y.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"agent-V6YLX3W6.cjs"}
@@ -73,6 +73,29 @@ var DEFAULT_DISCOVERY_SPECS = [
73
73
  followImports: false,
74
74
  priority: 50
75
75
  },
76
+ {
77
+ // usetheokit/theokit-sdk#531 — THEO.md was the only context file that could not live at the
78
+ // project root: every sibling here is `git-root-walk`, and this one was `cwd-only` pointed
79
+ // at `.theokit/THEO.md` specifically, with no warning that a root THEO.md was inert.
80
+ //
81
+ // ADDED rather than moving the existing entry below: a project already using
82
+ // `.theokit/THEO.md` keeps working unchanged. 55 sits between `theokit-context` (50) and the
83
+ // existing `THEO.md` (60), leaving room on both sides — the numbering discipline
84
+ // `claude-rules` (47) already established for this array.
85
+ //
86
+ // `followImports: true`, unlike the existing entry (`false`) and unlike `AGENTS.md`. This is
87
+ // a DELIBERATE divergence between the two THEO.md specs, not an inconsistency: a root-level
88
+ // file is edited by the same people, in the same place, as CLAUDE.md/GEMINI.md — the two
89
+ // other root-level, human-facing files that both carry `followImports: true` — so it belongs
90
+ // in their category rather than AGENTS.md's vendor-neutral, import-free one. Because this is a
91
+ // NEW spec, choosing `true` here changes nothing for `.theokit/THEO.md`, which keeps `false`.
92
+ id: "THEO.md.root",
93
+ pattern: "THEO.md",
94
+ scope: "git-root-walk",
95
+ parser: "plain-markdown",
96
+ followImports: true,
97
+ priority: 55
98
+ },
76
99
  {
77
100
  id: "THEO.md",
78
101
  pattern: ".theokit/THEO.md",
@@ -145,5 +168,5 @@ async function walkUpForGlob(cwd, pattern) {
145
168
  }
146
169
 
147
170
  export { DEFAULT_DISCOVERY_SPECS, findGitRoot, isSafePattern, walkUpForFile, walkUpForGlob };
148
- //# sourceMappingURL=chunk-WFC26L6Y.js.map
149
- //# sourceMappingURL=chunk-WFC26L6Y.js.map
171
+ //# sourceMappingURL=chunk-2XRAWOZZ.js.map
172
+ //# sourceMappingURL=chunk-2XRAWOZZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internal/runtime/context/context-discovery.ts"],"names":[],"mappings":";;;;;AAsFO,IAAM,uBAAA,GAAwD;AAAA,EACnE;AAAA,IACE,EAAA,EAAI,WAAA;AAAA,IACJ,OAAA,EAAS,WAAA;AAAA,IACT,KAAA,EAAO,eAAA;AAAA,IACP,MAAA,EAAQ,gBAAA;AAAA,IACR,aAAA,EAAe,KAAA;AAAA,IACf,QAAA,EAAU;AAAA,GACZ;AAAA,EACA;AAAA,IACE,EAAA,EAAI,WAAA;AAAA,IACJ,OAAA,EAAS,WAAA;AAAA,IACT,KAAA,EAAO,eAAA;AAAA,IACP,MAAA,EAAQ,gBAAA;AAAA,IACR,aAAA,EAAe,IAAA;AAAA,IACf,QAAA,EAAU;AAAA,GACZ;AAAA,EACA;AAAA,IACE,EAAA,EAAI,WAAA;AAAA,IACJ,OAAA,EAAS,WAAA;AAAA,IACT,KAAA,EAAO,eAAA;AAAA,IACP,MAAA,EAAQ,gBAAA;AAAA,IACR,aAAA,EAAe,IAAA;AAAA,IACf,QAAA,EAAU;AAAA,GACZ;AAAA,EACA;AAAA,IACE,EAAA,EAAI,cAAA;AAAA,IACJ,OAAA,EAAS,qBAAA;AAAA,IACT,KAAA,EAAO,SAAA;AAAA,IACP,MAAA,EAAQ,KAAA;AAAA,IACR,aAAA,EAAe,KAAA;AAAA,IACf,QAAA,EAAU;AAAA,GACZ;AAAA,EACA;AAAA,IACE,EAAA,EAAI,eAAA;AAAA,IACJ,OAAA,EAAS,qBAAA;AAAA,IACT,K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":["/**\n * Context file discovery (T1.1, ADRs D150 / D151).\n *\n * Discovers context files via three scopes:\n * - `cwd-only` — single dir, single path lookup\n * - `git-root-walk` — walk cwd → git-root, collect every directory's match\n * (nearest-first ordering)\n * - `globbed` — glob pattern relative to cwd (e.g. `.cursor/rules/*.mdc`)\n *\n * Pure `existsSync` checks — **no `.gitignore` parsing** (EC-A, KISS) and\n * **no invented `.theokitignore`** (EC-B). Paths normalized via\n * `realpath` to dedup symlink chains pointing to the same physical file\n * (EC-F). Git worktrees work transparently because `.git` exists as a\n * file in that case (EC-N).\n *\n * @internal\n */\n\nimport { existsSync, realpathSync } from \"node:fs\";\nimport { glob } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, resolve } from \"node:path\";\n\n/** Single filename (\"AGENTS.md\") or relative glob (\".cursor/rules/*.mdc\"). */\nexport type DiscoveryScope = \"cwd-only\" | \"git-root-walk\" | \"globbed\";\n\n/** Parser to apply once file is read. */\nexport type DiscoveryParser = \"plain-markdown\" | \"mdc\" | \"frontmatter-zod\" | \"rules-frontmatter\";\n\n/**\n * One kind of context file the runner knows how to find and read. The shipped registry is\n * `DEFAULT_DISCOVERY_SPECS`; a caller supplies its own array to change the set.\n *\n * `scope` decides how `pattern` is used and how many files a single spec can yield:\n * `cwd-only` looks for one path and stops, `git-root-walk` collects a match in every directory\n * from `cwd` up to the git root (nearest first), and `globbed` expands `pattern` as a glob\n * relative to `cwd`. So `pattern` is a filename for the first two and a glob for the third —\n * putting a glob on a walk scope silently finds nothing.\n *\n * `priority` orders the merged prompt, ascending, and is a plain number rather than an index, so\n * a new spec can be slotted between two existing ones. Lower means earlier and therefore more\n * general; later content wins on conflict.\n *\n * `parser` must match the file format — `plain-markdown` reads the whole file, `mdc` and\n * `rules-frontmatter` parse frontmatter and can DECLINE the file when its activation conditions\n * do not hold, and `frontmatter-zod` is the legacy path the runner currently skips entirely.\n *\n * `followImports` is honored only by `plain-markdown`, and turns `@path` directives in the body\n * into inlined content bounded by the import root. Setting it on a frontmatter parser does\n * nothing.\n *\n * `id` names the source in `<source name=\"\">` and in telemetry. When one spec matches files in\n * several directories, the runner suffixes it with the path relative to the git root to keep them\n * apart.\n *\n * @public — re-exported from `@theokit/sdk/context`, and therefore under semver.\n */\nexport interface DiscoverySpec {\n /** Stable identifier — used as `<source name=\"\">` and telemetry key. */\n readonly id: string;\n /** Priority for merge (lower = earlier in prompt). */\n readonly priority: number;\n /** Filename (cwd-only/git-root-walk) or glob (globbed). */\n readonly pattern: string;\n readonly scope: DiscoveryScope;\n readonly parser: DiscoveryParser;\n /** Whether to follow `@path` import directives (CLAUDE.md / GEMINI.md). */\n readonly followImports: boolean;\n}\n\n/**\n * The context files theokit looks for out of the box, in the order they are concatenated.\n *\n * Two things follow from the ordering. `AGENTS.md` comes first at priority 10 and `THEO.md` last,\n * so theokit-specific instruction wins over the vendor-neutral file on conflict. And the array is\n * consumed in the order written — the runner does not re-sort it — so a caller passing its own\n * array is responsible for keeping `priority` and array position consistent.\n *\n * `CLAUDE.md` and `GEMINI.md` are the only two entries with `followImports: true`, which means\n * they are the only files whose `@path` directives pull other files into the prompt. Those\n * imports cannot escape the import root.\n *\n * Frozen only by type: `ReadonlyArray` is a compile-time constraint, and the array and its\n * elements are not deep-frozen at runtime. Build a new array rather than mutating this one.\n *\n * @public — re-exported from `@theokit/sdk/context`, and therefore under semver.\n */\nexport const DEFAULT_DISCOVERY_SPECS: ReadonlyArray<DiscoverySpec> = [\n {\n id: \"AGENTS.md\",\n pattern: \"AGENTS.md\",\n scope: \"git-root-walk\",\n parser: \"plain-markdown\",\n followImports: false,\n priority: 10,\n },\n {\n id: \"GEMINI.md\",\n pattern: \"GEMINI.md\",\n scope: \"git-root-walk\",\n parser: \"plain-markdown\",\n followImports: true,\n priority: 20,\n },\n {\n id: \"CLAUDE.md\",\n pattern: \"CLAUDE.md\",\n scope: \"git-root-walk\",\n parser: \"plain-markdown\",\n followImports: true,\n priority: 30,\n },\n {\n id: \"cursor-rules\",\n pattern: \".cursor/rules/*.mdc\",\n scope: \"globbed\",\n parser: \"mdc\",\n followImports: false,\n priority: 40,\n },\n {\n id: \"theokit-rules\",\n pattern: \".theokit/rules/*.md\",\n scope: \"globbed\",\n parser: \"rules-frontmatter\",\n followImports: false,\n priority: 45,\n },\n {\n // Rules written for the Claude Code CLI. Measured 2026-08-26 over this repository's 32 rule\n // files: none carries frontmatter, and `rules-frontmatter` already reads a file without it as\n // `alwaysApply: true` — the format needed nothing, only a spec pointing at the directory.\n //\n // 47, not 46. Specs sort ascending and a context budget drops the tail first, so it must land\n // AFTER `.theokit/rules` (45) — the explicit namespace should survive a squeeze the borrowed one\n // does not. It must also leave a slot on BOTH sides: B-127 makes these numbers a public contract\n // precisely so a consumer can place its own source between two defaults, and 46 would have left\n // no room between 45 and itself. 47 keeps 46 free below and 48–49 free above.\n //\n // The reckoning B-127's docblock asks for: no published priority MOVES, so a consumer that chose\n // 46, 48 or 49 is unaffected. A consumer that had chosen 47 now collides — that is the cost of\n // an eighth default, paid once and recorded here rather than discovered later.\n id: \"claude-rules\",\n pattern: \".claude/rules/*.md\",\n scope: \"globbed\",\n parser: \"rules-frontmatter\",\n followImports: false,\n priority: 47,\n },\n {\n id: \"theokit-context\",\n pattern: \".theokit/context/*.md\",\n scope: \"globbed\",\n parser: \"frontmatter-zod\",\n followImports: false,\n priority: 50,\n },\n {\n // usetheokit/theokit-sdk#531 — THEO.md was the only context file that could not live at the\n // project root: every sibling here is `git-root-walk`, and this one was `cwd-only` pointed\n // at `.theokit/THEO.md` specifically, with no warning that a root THEO.md was inert.\n //\n // ADDED rather than moving the existing entry below: a project already using\n // `.theokit/THEO.md` keeps working unchanged. 55 sits between `theokit-context` (50) and the\n // existing `THEO.md` (60), leaving room on both sides — the numbering discipline\n // `claude-rules` (47) already established for this array.\n //\n // `followImports: true`, unlike the existing entry (`false`) and unlike `AGENTS.md`. This is\n // a DELIBERATE divergence between the two THEO.md specs, not an inconsistency: a root-level\n // file is edited by the same people, in the same place, as CLAUDE.md/GEMINI.md — the two\n // other root-level, human-facing files that both carry `followImports: true` — so it belongs\n // in their category rather than AGENTS.md's vendor-neutral, import-free one. Because this is a\n // NEW spec, choosing `true` here changes nothing for `.theokit/THEO.md`, which keeps `false`.\n id: \"THEO.md.root\",\n pattern: \"THEO.md\",\n scope: \"git-root-walk\",\n parser: \"plain-markdown\",\n followImports: true,\n priority: 55,\n },\n {\n id: \"THEO.md\",\n pattern: \".theokit/THEO.md\",\n scope: \"cwd-only\",\n parser: \"plain-markdown\",\n followImports: false,\n priority: 60,\n },\n];\n\nconst SAFE_FILENAME = /^[a-zA-Z0-9_.\\-/*]+$/;\nconst TRAVERSAL_RE = /(^|\\/)\\.\\.(\\/|$)/;\n\n/**\n * Reject patterns that contain path traversal (`..`) or non-allowed\n * characters (D81 parity, EC-4).\n *\n * @internal\n */\nexport function isSafePattern(pattern: string): boolean {\n if (typeof pattern !== \"string\" || pattern.length === 0) return false;\n if (TRAVERSAL_RE.test(pattern)) return false;\n if (isAbsolute(pattern)) return false;\n return SAFE_FILENAME.test(pattern);\n}\n\n/**\n * Walk upward from `cwd` looking for the closest directory containing\n * a `.git` entry (file OR directory — worktrees use a `.git` FILE,\n * EC-N). Returns the absolute path of that directory, or `undefined`\n * when no git root exists at or above `cwd`.\n *\n * @internal\n */\nexport function findGitRoot(cwd: string): string | undefined {\n if (typeof cwd !== \"string\" || cwd.length === 0) return undefined;\n let current = resolve(cwd);\n // Guard against infinite loops on weird filesystems.\n for (let i = 0; i < 64; i += 1) {\n if (existsSync(join(current, \".git\"))) return current;\n const parent = dirname(current);\n if (parent === current) return undefined;\n current = parent;\n }\n return undefined;\n}\n\n/**\n * Walk `cwd` upward to `stopDir` (inclusive) collecting every existing\n * occurrence of `filename`. Returns absolute, realpath-deduped paths in\n * nearest-first order (innermost dir first).\n *\n * No `.gitignore` parsing (EC-A). Realpath collapses symlink chains\n * pointing to the same physical file (EC-F). Filesystem races (file\n * deleted mid-walk) are skipped silently (EC-5).\n *\n * @internal\n */\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: walk-up loop combines validation + realpath dedup + FS-race handling + stopDir guard in a single bounded loop; splitting fragments the dedup invariant.\nexport function walkUpForFile(\n cwd: string,\n filename: string,\n stopDir: string | undefined,\n): string[] {\n if (!isSafePattern(filename)) {\n return [];\n }\n const start = resolve(cwd);\n const stop = stopDir !== undefined ? resolve(stopDir) : undefined;\n const found: string[] = [];\n const seenReal = new Set<string>();\n let current = start;\n // 64-level depth cap.\n for (let i = 0; i < 64; i += 1) {\n const candidate = join(current, filename);\n if (existsSync(candidate)) {\n let real: string;\n try {\n real = realpathSync(candidate);\n } catch {\n // FS race (deleted mid-walk) — skip.\n real = candidate;\n }\n if (!seenReal.has(real)) {\n seenReal.add(real);\n found.push(real);\n }\n }\n if (stop !== undefined && current === stop) break;\n const parent = dirname(current);\n if (parent === current) break;\n current = parent;\n }\n return found;\n}\n\n/**\n * Glob-style discovery under `cwd` (e.g. `.cursor/rules/*.mdc`, `.theokit/rules/**\\/*.md`).\n * Returns absolute, lex-sorted paths.\n *\n * `*` matches within one path segment and `**` spans any depth, including zero — so\n * `.theokit/rules/**\\/*.md` finds `rules/top.md` as well as `rules/deep/nested/inner.md`, while\n * `.theokit/rules/*.md` keeps its flat meaning and finds only the first. That distinction is the\n * compatibility contract: every existing spec uses a single `*`, and widening it would silently\n * start absorbing nested files nobody chose to expose.\n *\n * ## Why this used to be flat, and what changed (B-119)\n *\n * The previous implementation split the pattern at its LAST `/`, treated the prefix as a literal\n * directory and did one `readdir` — documented as \"nested directories deferred to v2\" (EC-R). The\n * deferral was deliberate; what made it a defect was measured from a consumer. TheoCode's own rule\n * loader descends recursively, so migrating it onto the `theokit-rules` spec would have silently\n * dropped every nested rule — on the path that decides whether a repository's hooks execute. And a\n * pattern written to say so, `.theokit/rules/**\\/*.md`, resolved its directory part to a literal\n * `**` and matched NOTHING, not even the top-level file it matched before the globstar was added.\n *\n * ## Why the stdlib rather than a walker\n *\n * `fs.promises.glob` (Node ≥ 22, and this package requires ≥ 22.12) implements exactly these\n * semantics, verified against a fixture before adoption: `**\\/*.md` returns all three depths,\n * `*.md` returns one, and it emits no experimental warning. Writing a recursive walker here would\n * have been a third implementation of matching inside one package — the same duplication that let\n * the enumerator and the compiler in `context-glob.ts` disagree in the first place. `globToRegex`\n * stays where it belongs: deciding whether a rule APPLIES to a set of paths, which is a different\n * question from which files exist.\n *\n * `isSafePattern` still runs first and is unchanged, so `..` is refused before any I/O.\n *\n * @internal\n */\nexport async function walkUpForGlob(cwd: string, pattern: string): Promise<string[]> {\n if (!isSafePattern(pattern)) return [];\n const found: string[] = [];\n try {\n for await (const entry of glob(pattern, { cwd })) {\n found.push(resolve(cwd, entry));\n }\n } catch {\n // A pattern whose directory does not exist is the ordinary case — most projects have no\n // `.cursor/rules/`. Same outcome as matching nothing.\n return [];\n }\n // Sorted, because discovery order becomes prompt order and must not vary with the filesystem.\n //\n // The comparator is explicit and deliberately NOT `localeCompare`, which is the usual suggestion\n // for a bare `.sort()`. `localeCompare` orders by the machine's locale, so the same tree would\n // assemble a different prompt on a differently-configured machine — trading one source of\n // non-determinism for a subtler one. Code-unit ordering is what a bare `.sort()` already does for\n // strings; writing it out states the intent and keeps the result machine-independent.\n return found.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { pluginBundleRoots, projectConfigRoots } from './chunk-JTZ74HFD.js';
1
+ import { pluginBundleRoots, projectConfigRoots } from './chunk-67ADYSTW.js';
2
2
  import { readWorkspaceDir, parseSimpleYaml } from './chunk-JNAA4G4H.js';
3
3
  import { ConfigurationError } from './chunk-ALUN2B4W.js';
4
4
  import { diag } from './chunk-CZJ6Q7CW.js';
@@ -39,7 +39,7 @@ async function loadSubagents(cwd, settingSourcesIncludeProject, inline, compatSo
39
39
  }
40
40
  async function readProjectSubagents(cwd, compatSources) {
41
41
  const subagents = {};
42
- for (const configRoot of projectConfigRoots(cwd, compatSources)) {
42
+ for (const configRoot of projectConfigRoots(cwd, compatSources, "subagents")) {
43
43
  await readSubagentsFrom(join(configRoot, "agents"), subagents);
44
44
  }
45
45
  for (const bundle of await pluginBundleDirs(cwd, compatSources)) {
@@ -59,7 +59,7 @@ async function readSubagentsFrom(root, subagents) {
59
59
  }
60
60
  const definition = parseSubagentMarkdown(raw, entry.name);
61
61
  if (subagents[definition.name] === void 0) {
62
- subagents[definition.name] = definition.definition;
62
+ subagents[definition.name] = { ...definition.definition, source: path };
63
63
  }
64
64
  }
65
65
  }
@@ -165,5 +165,5 @@ function parseFrontmatterFields(frontmatter) {
165
165
  }
166
166
 
167
167
  export { loadSubagents, pluginBundleDirs };
168
- //# sourceMappingURL=chunk-XCCGNU3D.js.map
169
- //# sourceMappingURL=chunk-XCCGNU3D.js.map
168
+ //# sourceMappingURL=chunk-4S5TWFIZ.js.map
169
+ //# sourceMappingURL=chunk-4S5TWFIZ.js.map