@lmzhen/dsh-evolution-core 0.48.0 → 0.50.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 (97) hide show
  1. package/lib/authority-plugin.js +2 -1
  2. package/lib/citations-CZKTUGQF.js +198 -0
  3. package/lib/composition/index.js +2 -2
  4. package/lib/{composition-Cqjbho0t.js → composition-DA8XPfMc.js} +1 -1
  5. package/lib/connection-DAJy7Xjm.js +28 -0
  6. package/lib/{ensure-CAjLGd9f.js → ensure-Bx4ksgJk.js} +15 -5
  7. package/lib/errors.js +2 -0
  8. package/lib/extract-plan-Bru3c9ec.js +271 -0
  9. package/lib/extract.js +240 -0
  10. package/lib/http-routes.js +27 -7
  11. package/lib/index.js +41 -822
  12. package/lib/{numeric-D8js3sqC.js → limits-C9jfvxBl.js} +1 -43
  13. package/lib/{mutation-authority-l57R626O.js → mutation-authority-DQfpXs1O.js} +2 -54
  14. package/lib/numeric-Dc53KQoe.js +43 -0
  15. package/lib/platform/index.js +4 -3
  16. package/lib/platform-DyHnHUmQ.js +251 -0
  17. package/lib/policy.js +3 -2
  18. package/lib/quality-WAU6YatF.js +554 -0
  19. package/lib/restrictor.js +1 -1
  20. package/lib/result.js +33 -0
  21. package/lib/runtime/plugin.js +97 -43
  22. package/lib/{session-projection-DSXnUNZG.js → session-projection-ByNxQi9O.js} +2 -198
  23. package/lib/skill-health-Bl-MdXZ4.js +1409 -0
  24. package/lib/skills.js +7 -4
  25. package/lib/state-store-Jpa-iYIZ.js +54 -0
  26. package/lib/subagent/index.js +214 -176
  27. package/lib/{tools-DzcNFex2.js → tools-BrUswg8v.js} +3 -1
  28. package/lib/types/composition/ensure.js +21 -7
  29. package/lib/types/extract-plan.d.ts +2 -0
  30. package/lib/types/extract.d.ts +12 -0
  31. package/lib/types/extract.js +12 -0
  32. package/lib/types/http-routes.js +32 -9
  33. package/lib/types/index.d.ts +0 -3
  34. package/lib/types/index.js +0 -3
  35. package/lib/types/long-runs.d.ts +0 -5
  36. package/lib/types/long-runs.js +0 -7
  37. package/lib/types/opt-in.js +4 -3
  38. package/lib/types/params.js +2 -1
  39. package/lib/types/platform/agents.d.ts +32 -0
  40. package/lib/types/platform/agents.js +26 -0
  41. package/lib/types/platform/commands.d.ts +14 -0
  42. package/lib/types/platform/commands.js +9 -0
  43. package/lib/types/platform/connection.d.ts +26 -0
  44. package/lib/types/platform/connection.js +27 -0
  45. package/lib/types/platform/index.d.ts +26 -0
  46. package/lib/types/platform/index.js +13 -0
  47. package/lib/types/platform/llm.d.ts +3 -1
  48. package/lib/types/platform/llm.js +1 -0
  49. package/lib/types/platform/platformView.d.ts +21 -0
  50. package/lib/types/platform/platformView.js +29 -0
  51. package/lib/types/platform/profileContext.d.ts +16 -0
  52. package/lib/types/platform/profileContext.js +14 -0
  53. package/lib/types/platform/sessionQuery.d.ts +14 -0
  54. package/lib/types/platform/sessionQuery.js +9 -0
  55. package/lib/types/platform/settings.d.ts +22 -0
  56. package/lib/types/platform/settings.js +14 -0
  57. package/lib/types/platform/skills.d.ts +16 -0
  58. package/lib/types/platform/skills.js +9 -0
  59. package/lib/types/platform/storageDomain.d.ts +13 -0
  60. package/lib/types/platform/storageDomain.js +9 -0
  61. package/lib/types/platform/subagents.d.ts +25 -0
  62. package/lib/types/platform/subagents.js +17 -0
  63. package/lib/types/platform/systemPrompt.d.ts +16 -0
  64. package/lib/types/platform/systemPrompt.js +13 -0
  65. package/lib/types/platform/tools.d.ts +4 -0
  66. package/lib/types/platform/tools.js +2 -0
  67. package/lib/types/platform/userQuestions.d.ts +33 -0
  68. package/lib/types/platform/userQuestions.js +9 -0
  69. package/lib/types/platform/workingDirectory.d.ts +14 -0
  70. package/lib/types/platform/workingDirectory.js +9 -0
  71. package/lib/types/platform-line.generated.d.ts +5 -5
  72. package/lib/types/platform-line.generated.js +5 -5
  73. package/lib/types/platform-services.js +3 -0
  74. package/lib/types/result.d.ts +35 -0
  75. package/lib/types/result.js +25 -0
  76. package/lib/types/runtime/llm.d.ts +2 -2
  77. package/lib/types/runtime/llm.js +5 -8
  78. package/lib/types/runtime/platform.d.ts +37 -4
  79. package/lib/types/runtime/platform.js +40 -5
  80. package/lib/types/runtime/projections.d.ts +9 -4
  81. package/lib/types/runtime/projections.js +64 -28
  82. package/lib/types/subagent/channel.d.ts +1 -3
  83. package/lib/types/subagent/channel.js +2 -332
  84. package/lib/types/subagent/index.d.ts +2 -0
  85. package/lib/types/subagent/index.js +2 -0
  86. package/lib/types/subagent/kernel.d.ts +4 -0
  87. package/lib/types/subagent/kernel.js +234 -0
  88. package/lib/types/subagent/readiness.js +5 -7
  89. package/lib/types/subagent/run.d.ts +53 -0
  90. package/lib/types/subagent/run.js +125 -0
  91. package/lib/types/subagent/types.d.ts +2 -2
  92. package/lib/types/write-inventory.d.ts +0 -11
  93. package/lib/types/write-inventory.js +0 -16
  94. package/lib/usage-DdjIBAkm.js +1252 -0
  95. package/package.json +37 -25
  96. package/lib/platform-Cc9cNt5j.js +0 -111
  97. package/lib/skill-health-DP8z9TPf.js +0 -2923
@@ -1,7 +1,8 @@
1
- import { a as evolutionSignalsProjection, i as evolutionReadsProjection, n as evolutionEvidenceProjection, r as evolutionProjectionHistoryProjection, t as evolutionActivityProjection } from "../session-projection-DSXnUNZG.js";
1
+ import { a as evolutionSignalsProjection, i as evolutionReadsProjection, n as evolutionEvidenceProjection, r as evolutionProjectionHistoryProjection, t as evolutionActivityProjection } from "../session-projection-ByNxQi9O.js";
2
+ import { t as connectionPort } from "../connection-DAJy7Xjm.js";
3
+ import { C as workingDirectoryPort, D as profileContextPort, E as pluginManagerPort, O as commandsPort, S as skillsPort, T as pluginInventoryPort, _ as agentsPort, b as storageDomainPort, d as EvolutionLlmError, f as llmPort, g as subagentsPort, h as userQuestionsPort, m as projectionPort, p as modelRoute, v as systemPromptPort, w as configEditorPort, x as sessionQueryPort, y as settingsPort } from "../platform-DyHnHUmQ.js";
2
4
  import { t as presetsPort } from "../presets-C8vuCuNA.js";
3
- import { d as EvolutionLlmError, f as llmPort, m as projectionPort, p as modelRoute } from "../platform-Cc9cNt5j.js";
4
- import { n as toolsPort } from "../tools-DzcNFex2.js";
5
+ import { n as toolsPort } from "../tools-BrUswg8v.js";
5
6
  import { Service } from "@deepseek-ai/cordis";
6
7
  //#region lib/types/runtime/llm.js
7
8
  /**
@@ -11,18 +12,16 @@ import { Service } from "@deepseek-ai/cordis";
11
12
  /** Domain service for every auxiliary LLM request in the family. */
12
13
  var EvolutionLlm = class extends Service {
13
14
  static inject = [];
14
- port;
15
15
  constructor(ctx) {
16
16
  super(ctx, "evolutionLlm");
17
17
  }
18
- [Service.init]() {
19
- const platform = this.ctx.get("evolutionPlatform");
20
- this.port = platform?.ports.llm;
21
- if (this.port === void 0) this.ctx.logger.warn("evolution-core-runtime: llm service unavailable; model calls fail with llm-unavailable");
18
+ /** Resolve the port per call so a late-mounted llm service is usable. */
19
+ port() {
20
+ return this.ctx.get("evolutionPlatform")?.ports.llm;
22
21
  }
23
22
  /** Whether the platform llm service is mounted. */
24
23
  available() {
25
- return this.port !== void 0;
24
+ return this.port() !== void 0;
26
25
  }
27
26
  /** One assembled text response. */
28
27
  async text(input) {
@@ -43,7 +42,7 @@ var EvolutionLlm = class extends Service {
43
42
  }
44
43
  }
45
44
  prepare(input) {
46
- const port = this.port;
45
+ const port = this.port();
47
46
  if (port === void 0) throw new EvolutionLlmError("model-unavailable", "llm-unavailable: no llm service is mounted");
48
47
  const route = input.route ?? modelRoute(this.ctx, input.agent, input.session);
49
48
  if (route === void 0) throw new EvolutionLlmError("no-route", "llm-unavailable: no model route is configured");
@@ -75,71 +74,78 @@ var EvolutionLlm = class extends Service {
75
74
  * The family's host capability service: one place that resolves the platform
76
75
  * ports and reports which halves are available. Feature code reads ports from
77
76
  * this service; the port modules remain the only @deepseek-ai/dsh-* importers.
77
+ *
78
+ * The table is resolved on every read. A missing optional service is not a
79
+ * permanent capability loss: it may mount after this service initializes, and
80
+ * the next read must see it.
78
81
  */
79
82
  /** Domain service owning the host port table. */
80
83
  var EvolutionPlatform = class extends Service {
81
84
  static inject = [];
82
- resolved;
83
85
  constructor(ctx) {
84
86
  super(ctx, "evolutionPlatform");
85
87
  }
86
88
  /**
87
- * Resolve the host ports on first use and keep that answer for the service
88
- * lifetime. Consumers read this one table; they never fall back to a direct
89
- * platform import (the second resolution D7 removed).
89
+ * Resolve the host ports now. Consumers read this one table; they never fall
90
+ * back to a direct platform import (the second resolution D7 removed).
91
+ * Deliberately uncached: `ctx.get` is the capability lifecycle.
90
92
  */
91
93
  get ports() {
92
- return this.resolved ??= {
94
+ return {
95
+ agents: agentsPort(this.ctx),
96
+ connection: connectionPort(this.ctx),
97
+ settings: settingsPort(this.ctx),
98
+ storageDomain: storageDomainPort(this.ctx),
99
+ workingDirectory: workingDirectoryPort(this.ctx),
100
+ pluginManager: pluginManagerPort(this.ctx),
101
+ pluginInventory: pluginInventoryPort(this.ctx),
102
+ configEditor: configEditorPort(this.ctx),
103
+ profileContext: profileContextPort(this.ctx),
104
+ skills: skillsPort(this.ctx),
105
+ sessionQuery: sessionQueryPort(this.ctx),
106
+ commands: commandsPort(this.ctx),
107
+ systemPrompt: systemPromptPort(this.ctx),
108
+ subagents: subagentsPort(this.ctx),
109
+ userQuestions: userQuestionsPort(this.ctx),
93
110
  projections: projectionPort(this.ctx),
94
111
  llm: llmPort(this.ctx),
95
112
  tools: toolsPort(this.ctx),
96
113
  presets: presetsPort(this.ctx)
97
114
  };
98
115
  }
116
+ /** Whether an exact live root agent is available for this id. */
117
+ isRootAgent(agent) {
118
+ return this.ports.agents?.isRoot(agent) === true;
119
+ }
99
120
  };
100
121
  //#endregion
101
122
  //#region lib/types/runtime/projections.js
102
123
  /**
103
- * The family's projection runtime: register the five host-only units once and
104
- * expose typed reads to the pure readers. Missing registry or a registration
105
- * failure degrades to undefined (the existing fail-open posture), never throws
106
- * into the host.
124
+ * The family's projection runtime: register the five host-only units and expose
125
+ * typed reads to the pure readers. Registration follows the projection service
126
+ * lifecycle: if `sessionProjections` mounts later (or is replaced), the units
127
+ * attach then; a missing registry is not a permanent capability loss.
107
128
  */
108
129
  /** Domain service owning the family's projection registrations. */
109
130
  var EvolutionProjections = class extends Service {
110
131
  static inject = [];
111
132
  handles;
112
133
  degradedReason;
134
+ generation = 0;
113
135
  constructor(ctx) {
114
136
  super(ctx, "evolutionProjections");
115
137
  }
116
138
  async [Service.init]() {
117
- const port = this.ctx.get("evolutionPlatform")?.ports.projections;
118
- if (port === void 0) {
119
- this.markDegraded("sessionProjections service unavailable");
139
+ if (this.ctx.get("sessionProjections") !== void 0) {
140
+ await this.attach(this.ctx);
120
141
  return;
121
142
  }
122
- const partial = {};
123
- try {
124
- partial.activity = await port.register(evolutionActivityProjection);
125
- partial.evidence = await port.register(evolutionEvidenceProjection);
126
- partial.reads = await port.register(evolutionReadsProjection);
127
- partial.history = await port.register(evolutionProjectionHistoryProjection);
128
- partial.signals = await port.register(evolutionSignalsProjection);
129
- if (port.shape === "unrecognised") {
130
- for (const handle of Object.values(partial).reverse()) try {
131
- await handle.dispose();
132
- } catch {}
133
- this.markDegraded("projection port shape not recognised: " + (port.reason ?? "no reason reported"));
134
- return;
135
- }
136
- this.handles = partial;
137
- } catch (error) {
138
- for (const handle of Object.values(partial).reverse()) try {
139
- await handle.dispose();
140
- } catch {}
141
- this.markDegraded("projection registration failed: " + (error instanceof Error ? error.message : String(error)));
142
- }
143
+ this.ctx.inject(["evolutionPlatform", "sessionProjections"], (scope) => {
144
+ this.attach(scope);
145
+ return () => {
146
+ this.detach();
147
+ };
148
+ });
143
149
  }
144
150
  /** Whether the five units are registered and readable. */
145
151
  status() {
@@ -164,6 +170,54 @@ var EvolutionProjections = class extends Service {
164
170
  signals(session) {
165
171
  return this.handles?.signals.stateOf(session);
166
172
  }
173
+ async attach(scope) {
174
+ const generation = ++this.generation;
175
+ await this.detachHandles();
176
+ const port = scope.get("evolutionPlatform")?.ports.projections;
177
+ if (port === void 0) {
178
+ this.markDegraded("sessionProjections service unavailable");
179
+ return;
180
+ }
181
+ const partial = {};
182
+ try {
183
+ partial.activity = await port.register(evolutionActivityProjection);
184
+ partial.evidence = await port.register(evolutionEvidenceProjection);
185
+ partial.reads = await port.register(evolutionReadsProjection);
186
+ partial.history = await port.register(evolutionProjectionHistoryProjection);
187
+ partial.signals = await port.register(evolutionSignalsProjection);
188
+ if (generation !== this.generation) {
189
+ await this.disposePartial(partial);
190
+ return;
191
+ }
192
+ if (port.shape === "unrecognised") {
193
+ await this.disposePartial(partial);
194
+ this.markDegraded("projection port shape not recognised: " + (port.reason ?? "no reason reported"));
195
+ return;
196
+ }
197
+ this.handles = partial;
198
+ this.degradedReason = void 0;
199
+ } catch (error) {
200
+ await this.disposePartial(partial);
201
+ this.markDegraded("projection registration failed: " + (error instanceof Error ? error.message : String(error)));
202
+ }
203
+ }
204
+ async detach() {
205
+ this.generation += 1;
206
+ await this.detachHandles();
207
+ }
208
+ async detachHandles() {
209
+ const handles = this.handles;
210
+ this.handles = void 0;
211
+ if (handles === void 0) return;
212
+ for (const handle of Object.values(handles).reverse()) try {
213
+ await handle.dispose();
214
+ } catch {}
215
+ }
216
+ async disposePartial(partial) {
217
+ for (const handle of Object.values(partial).reverse()) try {
218
+ await handle.dispose();
219
+ } catch {}
220
+ }
167
221
  markDegraded(reason) {
168
222
  this.degradedReason = reason;
169
223
  this.ctx.logger.warn("evolution-core-runtime: %s; projection reads degrade to undefined", reason);
@@ -1,201 +1,5 @@
1
+ import { t as CITATION_SUPPORT_DIRS } from "./citations-CZKTUGQF.js";
1
2
  import { z } from "zod";
2
- //#region lib/types/citations.js
3
- /**
4
- * Citation resolution for skill bodies and support files (design §5.2).
5
- *
6
- * WHY this exists beside `supportRefs` (skill-store.ts): that scanner answers
7
- * "does this text contain a path-shaped token", which is the right question
8
- * when a package is being ARCHIVED — every such path may dangle — and the wrong
9
- * one when a section is only being MOVED, where nothing leaves and the only
10
- * thing that changes is the directory a citation is read from. Measured false
11
- * positives of the token scan: a URL tail (`https://host/references/x.md`), a
12
- * category path the original Hermes documents as legitimate
13
- * (`skills/scripts/foo.py`), and a prose command line
14
- * (`npm run scripts/build.mjs`).
15
- *
16
- * CONTRACT: a token whose path STARTS WITH a support directory is a citation of
17
- * this skill and is resolved from the SKILL ROOT, in whichever file it is
18
- * written. A token that merely contains a support directory further along its
19
- * path belongs to something else: it is reported as `foreign` and never
20
- * resolved.
21
- *
22
- * PURE: existence is decided against the caller's file list, so identical
23
- * inputs always answer the same report.
24
- */
25
- /** Support directories that make a path a citation of the owning skill. */
26
- const CITATION_SUPPORT_DIRS = [
27
- "references",
28
- "templates",
29
- "scripts",
30
- "assets"
31
- ];
32
- /** Scan budget: bounded so a pathological body cannot stall a maintenance run. */
33
- const DEFAULT_CITATION_REF_BUDGET = 500;
34
- /** Words that introduce an executable command rather than a citation. */
35
- const PROSE_COMMAND_PREFIXES = [
36
- "npm",
37
- "pnpm",
38
- "yarn",
39
- "npx",
40
- "node",
41
- "python",
42
- "python3",
43
- "bash",
44
- "sh",
45
- "git",
46
- "gh",
47
- "run"
48
- ];
49
- const TOKEN_RE = /(?:references|templates|scripts|assets)\/[A-Za-z0-9._/-]+/g;
50
- const TOKEN_CHAR_RE = /[A-Za-z0-9._/-]/;
51
- const FENCE_RE = /^\s*(`{3,}|~{3,})/;
52
- const TRAILING_PUNCT_RE = /[.,;:]+$/;
53
- /** A citation's final segment must look like \u0060name.ext\u0060: a bare \u0060.\u0060 or a dotless
54
- * segment is a directory mention, not a file. */
55
- const FILE_SEGMENT_RE = /^[^.].*\.[^.]+$/;
56
- const FRAGMENT_RE = /^#([A-Za-z0-9._-]+)/;
57
- /** Whether the token starting at `start` is the argument of a shell command. */
58
- function isProseCommand(line, start) {
59
- const head = line.slice(0, start).trimEnd();
60
- if (head === "") return false;
61
- const word = head.split(/\s+/).pop() ?? "";
62
- return PROSE_COMMAND_PREFIXES.includes(word);
63
- }
64
- /** The token's final path segment (`references/a/b.md` -> `b.md`). */
65
- function lastSegmentOf(target) {
66
- return target.slice(target.lastIndexOf("/") + 1);
67
- }
68
- /** The token's parent directory within the skill (`references/a/b.md` -> `references/a`). */
69
- function parentDirOf(target) {
70
- const cut = target.lastIndexOf("/");
71
- return cut <= 0 ? "" : target.slice(0, cut);
72
- }
73
- /** Classify one token by its first path segment. */
74
- function classifyToken(token) {
75
- const head = token.split("/")[0] ?? "";
76
- return CITATION_SUPPORT_DIRS.includes(head) ? "citation" : "foreign";
77
- }
78
- /**
79
- * Resolve every path-shaped token in `content`.
80
- * @param input - content, the skill-root-relative path of its owner, the skill's
81
- * file list, and an optional scan budget.
82
- * @returns the refs plus the dangling and foreign subsets; `truncated` marks a
83
- * report that stopped at the budget.
84
- */
85
- function resolveCitations(input) {
86
- const budget = input.budget ?? 500;
87
- const files = new Set(input.files.map((path) => path.replace(/\\/g, "/")));
88
- const refs = [];
89
- const seen = /* @__PURE__ */ new Set();
90
- let truncated = false;
91
- let fence = null;
92
- const lines = input.content.split("\n");
93
- for (let index = 0; index < lines.length && !truncated; index += 1) {
94
- const rawLine = lines[index] ?? "";
95
- const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
96
- const fenceMark = FENCE_RE.exec(line);
97
- if (fenceMark) {
98
- const marker = fenceMark[1] ?? "";
99
- fence = fence === null ? marker.slice(0, 1) : null;
100
- continue;
101
- }
102
- for (const match of line.matchAll(TOKEN_RE)) {
103
- const matched = match[0];
104
- const matchedAt = match.index;
105
- let start = matchedAt;
106
- while (start > 0 && TOKEN_CHAR_RE.test(line[start - 1] ?? "")) start -= 1;
107
- const prefix = line.slice(0, start);
108
- const tail = line.slice(matchedAt + matched.length);
109
- const fragment = FRAGMENT_RE.exec(tail)?.[1];
110
- const token = matched.replace(TRAILING_PUNCT_RE, "");
111
- const scanned = line.slice(start, matchedAt + matched.length);
112
- const classified = fence !== null ? "fence" : prefix.endsWith(":") && line.slice(start, start + 2) === "//" ? "url" : isProseCommand(line, start) ? "prose" : classifyToken(scanned);
113
- const namesFile = !scanned.split("/").includes("..") && (FILE_SEGMENT_RE.test(lastSegmentOf(scanned)) || files.has(token));
114
- const kind = classified === "citation" && !namesFile ? "prose" : classified;
115
- const target = kind === "citation" ? token : null;
116
- const key = `${index}|${kind}|${target ?? token}`;
117
- if (seen.has(key)) continue;
118
- seen.add(key);
119
- refs.push({
120
- raw: token,
121
- line: index + 1,
122
- target,
123
- base: "root",
124
- kind,
125
- exists: target !== null && files.has(target),
126
- ...fragment === void 0 ? {} : { fragment }
127
- });
128
- if (refs.length >= budget) {
129
- truncated = true;
130
- break;
131
- }
132
- }
133
- }
134
- const citations = refs.filter((ref) => ref.kind === "citation");
135
- const undecidable = (ref) => {
136
- const target = ref.target;
137
- return target !== null && !ref.exists && files.has(parentDirOf(target));
138
- };
139
- return {
140
- refs,
141
- dangling: citations.filter((ref) => !ref.exists && !undecidable(ref)),
142
- unverified: citations.filter(undecidable),
143
- foreign: refs.filter((ref) => ref.kind !== "citation"),
144
- truncated
145
- };
146
- }
147
- /** The sanctioned body hook (design §5.6): a list item whose payload is
148
- * exactly one support-file path, so the file stays discoverable in the body. */
149
- const HOOK_LINE_RE = /^- [^\n]{1,60} → ((?:references|templates|scripts|assets)\/[a-z0-9][a-z0-9._/-]*)$/;
150
- /** The retirement escape hatch (design §5.6): a standalone body comment that
151
- * names the support file it exempts and the reason it must survive. The path
152
- * is part of the marker because the proposal list is per FILE, and a reason is
153
- * required — an unexplained exemption is what this hook exists to prevent. */
154
- const KEEP_LINE_RE = /^<!--\s*keep:\s*((?:references|templates|scripts|assets)\/[a-z0-9][a-z0-9._/-]*)\s+(\S[^>]*?)\s*-->$/;
155
- /** Whether a skill-relative path names a FILE rather than a directory: the same
156
- * rule the scanner applies to a token's final segment (`name.ext`). The support
157
- * listing is one level deep and includes directory entries (a real library has
158
- * `references/archive`), which no pointer or retirement list may treat as a file.
159
- * @param path - a skill-root-relative support path.
160
- * @returns true when the final segment is file-shaped.
161
- */
162
- function isFileShapedPath(path) {
163
- return FILE_SEGMENT_RE.test(path.slice(path.lastIndexOf("/") + 1));
164
- }
165
- /**
166
- * Scan a body for sanctioned hooks and `keep` markers.
167
- * @param content - the SKILL.md body (frontmatter included).
168
- * @returns hook targets plus the `keep` reasons keyed by target.
169
- */
170
- function scanBodyHooks(content) {
171
- const targets = [];
172
- const seen = /* @__PURE__ */ new Set();
173
- const kept = /* @__PURE__ */ new Map();
174
- let fence = null;
175
- for (const rawLine of content.split("\n")) {
176
- const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
177
- const fenceMark = FENCE_RE.exec(line);
178
- if (fenceMark) {
179
- fence = fence === null ? (fenceMark[1] ?? "").slice(0, 1) : null;
180
- continue;
181
- }
182
- if (fence !== null) continue;
183
- const keep = KEEP_LINE_RE.exec(line);
184
- if (keep?.[1] !== void 0) {
185
- kept.set(keep[1], (keep[2] ?? "").trim());
186
- continue;
187
- }
188
- const target = HOOK_LINE_RE.exec(line)?.[1];
189
- if (target === void 0 || seen.has(target)) continue;
190
- seen.add(target);
191
- targets.push(target);
192
- }
193
- return {
194
- targets,
195
- kept
196
- };
197
- }
198
- //#endregion
199
3
  //#region lib/types/tool-dispatch.js
200
4
  /**
201
5
  * The family's ONE reader of platform tool-dispatch events.
@@ -1229,4 +1033,4 @@ function sessionEvidenceIndex(ctx, session) {
1229
1033
  return { has: (seq) => Number.isInteger(seq) && seq >= 0 && seq <= through && !bookkeeping.includes(seq) };
1230
1034
  }
1231
1035
  //#endregion
1232
- export { dispatchKeyOf as A, CITATION_SUPPORT_DIRS as B, PTC_DISPATCH_EVENT as C, assertDispatchPayload as D, ToolDispatchPayloadError as E, isSkillToolName as F, resolveCitations as G, HOOK_LINE_RE as H, readDispatchSignal as I, scanBodyHooks as K, skillReadNameOf as L, dispatchStepOf as M, foldToolDispatches as N, collectReadSkillNames as O, isSkillReadToolName as P, supportFileReadFromPath as R, NATIVE_RESULT_EVENT as S, ToolDispatchNormalizer as T, KEEP_LINE_RE as U, DEFAULT_CITATION_REF_BUDGET as V, isFileShapedPath as W, isBookkeepingFrame as _, evolutionSignalsProjection as a, MODEL_SESSION_EVENT_TYPES as b, sessionLastEventTime as c, advanceReview as d, foldTurnEvent as f, evidenceKindIndex as g, observeEvent as h, evolutionReadsProjection as i, dispatchPathOf as j, collectReadSupportFiles as k, sessionReadNames as l, initialTurnFold as m, evolutionEvidenceProjection as n, isProjectableSession as o, foldTurnEvents as p, evolutionProjectionHistoryProjection as r, sessionEvidenceIndex as s, evolutionActivityProjection as t, sessionTurnSignals as u, DEFAULT_SUPPORT_READ_TOOL_NAMES as v, PTC_DISPATCH_START_EVENT as w, NATIVE_CALL_EVENT as x, DISPATCH_EVENT_TYPES as y, supportFileReadOf as z };
1036
+ export { dispatchKeyOf as A, PTC_DISPATCH_EVENT as C, assertDispatchPayload as D, ToolDispatchPayloadError as E, isSkillToolName as F, readDispatchSignal as I, skillReadNameOf as L, dispatchStepOf as M, foldToolDispatches as N, collectReadSkillNames as O, isSkillReadToolName as P, supportFileReadFromPath as R, NATIVE_RESULT_EVENT as S, ToolDispatchNormalizer as T, isBookkeepingFrame as _, evolutionSignalsProjection as a, MODEL_SESSION_EVENT_TYPES as b, sessionLastEventTime as c, advanceReview as d, foldTurnEvent as f, evidenceKindIndex as g, observeEvent as h, evolutionReadsProjection as i, dispatchPathOf as j, collectReadSupportFiles as k, sessionReadNames as l, initialTurnFold as m, evolutionEvidenceProjection as n, isProjectableSession as o, foldTurnEvents as p, evolutionProjectionHistoryProjection as r, sessionEvidenceIndex as s, evolutionActivityProjection as t, sessionTurnSignals as u, DEFAULT_SUPPORT_READ_TOOL_NAMES as v, PTC_DISPATCH_START_EVENT as w, NATIVE_CALL_EVENT as x, DISPATCH_EVENT_TYPES as y, supportFileReadOf as z };