agentfootprint 16.0.1 → 16.1.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 (44) hide show
  1. package/CAPABILITIES.md +1 -0
  2. package/dist/core/runRecorders.js +2 -0
  3. package/dist/core/runRecorders.js.map +1 -1
  4. package/dist/esm/core/runRecorders.js +2 -0
  5. package/dist/esm/core/runRecorders.js.map +1 -1
  6. package/dist/esm/hosting/stream.d.ts +8 -0
  7. package/dist/esm/hosting/stream.js +101 -35
  8. package/dist/esm/hosting/stream.js.map +1 -1
  9. package/dist/esm/injection-engine/skillsFromDir/frontmatter.d.ts +40 -0
  10. package/dist/esm/injection-engine/skillsFromDir/frontmatter.js +272 -0
  11. package/dist/esm/injection-engine/skillsFromDir/frontmatter.js.map +1 -0
  12. package/dist/esm/injection-engine/skillsFromDir.js +2 -270
  13. package/dist/esm/injection-engine/skillsFromDir.js.map +1 -1
  14. package/dist/esm/injection-engine/skillsFromDirRoutes.d.ts +1 -1
  15. package/dist/esm/injection-engine/skillsFromDirRoutes.js +1 -1
  16. package/dist/esm/lib/humanizeLLMError.d.ts +1 -1
  17. package/dist/esm/lib/humanizeLLMError.js +4 -1
  18. package/dist/esm/lib/humanizeLLMError.js.map +1 -1
  19. package/dist/esm/recorders/core/ErrorBridge.d.ts +3 -0
  20. package/dist/esm/recorders/core/ErrorBridge.js +3 -1
  21. package/dist/esm/recorders/core/ErrorBridge.js.map +1 -1
  22. package/dist/hosting/stream.js +101 -35
  23. package/dist/hosting/stream.js.map +1 -1
  24. package/dist/injection-engine/skillsFromDir/frontmatter.js +275 -0
  25. package/dist/injection-engine/skillsFromDir/frontmatter.js.map +1 -0
  26. package/dist/injection-engine/skillsFromDir.js +2 -270
  27. package/dist/injection-engine/skillsFromDir.js.map +1 -1
  28. package/dist/injection-engine/skillsFromDirRoutes.js +1 -1
  29. package/dist/lib/humanizeLLMError.js +4 -1
  30. package/dist/lib/humanizeLLMError.js.map +1 -1
  31. package/dist/recorders/core/ErrorBridge.js +3 -1
  32. package/dist/recorders/core/ErrorBridge.js.map +1 -1
  33. package/dist/types/core/runRecorders.d.ts.map +1 -1
  34. package/dist/types/hosting/stream.d.ts +8 -0
  35. package/dist/types/hosting/stream.d.ts.map +1 -1
  36. package/dist/types/injection-engine/skillsFromDir/frontmatter.d.ts +41 -0
  37. package/dist/types/injection-engine/skillsFromDir/frontmatter.d.ts.map +1 -0
  38. package/dist/types/injection-engine/skillsFromDir.d.ts.map +1 -1
  39. package/dist/types/injection-engine/skillsFromDirRoutes.d.ts +1 -1
  40. package/dist/types/lib/humanizeLLMError.d.ts +1 -1
  41. package/dist/types/lib/humanizeLLMError.d.ts.map +1 -1
  42. package/dist/types/recorders/core/ErrorBridge.d.ts +3 -0
  43. package/dist/types/recorders/core/ErrorBridge.d.ts.map +1 -1
  44. package/package.json +1 -1
package/CAPABILITIES.md CHANGED
@@ -202,6 +202,7 @@ not in this table, search `src/index.ts` for the nearest noun before writing cod
202
202
  | experimental, not yet validated in real use: additive saved-record shapes for scoped historical verification observations; paired checkpoint readers and writers validate retained evidence and counters without judging old observations again, and native continuation refuses an unarmed evidence carrier; protocol only — no runtime verifier, model declaration parser or answer badge is enabled | `FindingsRow` + optional `AgentRunCheckpoint.claimVerification` | `src/core/` | 10.2.0 |
203
203
  | an AG-UI frontend (`@ag-ui/client`, CopilotKit, the AG-UI Dojo) reading an agentfootprint run with no glue code — the run's served events translated into AG-UI 1.0 events: streamed text, tool calls with arguments and results, reasoning, ReAct iterations and compositions as steps, a nested agent (a `Sequence` step, a `Parallel` branch) as a sub-agent with its parent links, a pause as an interrupt, a failure as `RUN_ERROR` in the record's words (an answer `.answerValidation()` withheld as `RUN_ERROR { code: 'ERR_ANSWER_VALIDATION' }`, a refusal not a crash — `RunSettlement.refusal` / `RunRefusal`); `CUSTOM` an allow-list of events with projected fields (`AG_UI_CUSTOM_EVENTS`), reasoning only on request; ids minted from the record's address under the request's run id (unique across a thread when branches reuse a provider's tool-call id); nothing a redaction policy hides on the wire, at any depth; framed by the official `@ag-ui/encoder` (optional peer, loaded only when a framing is built) | `agUiSerializer` + `agUiSse` + `AG_UI_CUSTOM_EVENTS` (`agentfootprint/ag-ui`) + `RunTranslation` / `RunSettlement` (the port, `agentfootprint/hosting`) | `src/ag-ui/` | 10.4.0 |
204
204
  | writing a run's Server-Sent Events in a different frame shape — the framing is a strategy: `toSSE({ framing })`, default the frames it always wrote | `SseFraming` + `agentfootprintSse` (`agentfootprint/observe`) | `src/hosting/stream.ts` | 10.4.0 |
205
+ | close a full or text SSE stream after its own invocation succeeds, fails, or pauses. Start after subscribing and drain all admitted events in order. Text streams of compositions carry the admitted token transcript | `toSSE` + `ToSSEOptions.start` (`agentfootprint/observe`) | `src/hosting/stream.ts` | 16.1.0 |
205
206
 
206
207
  **Maintaining this table:** a new public capability adds a row, in the same
207
208
  change that adds the capability. `test/docs/capability-index.test.ts` fails if a
@@ -6,6 +6,7 @@ const ContextRecordedRecorder_js_1 = require("../recorders/core/ContextRecordedR
6
6
  const StreamRecorder_js_1 = require("../recorders/core/StreamRecorder.js");
7
7
  const AgentRecorder_js_1 = require("../recorders/core/AgentRecorder.js");
8
8
  const CompositionRecorder_js_1 = require("../recorders/core/CompositionRecorder.js");
9
+ const ErrorBridge_js_1 = require("../recorders/core/ErrorBridge.js");
9
10
  /** Composition-native recorder wiring; all retain the captured invocation. */
10
11
  function compositionRecorders(dispatcher, getRunContext, redaction, extra, attached) {
11
12
  return [
@@ -15,6 +16,7 @@ function compositionRecorders(dispatcher, getRunContext, redaction, extra, attac
15
16
  (0, StreamRecorder_js_1.streamRecorder)({ dispatcher, getRunContext }),
16
17
  (0, AgentRecorder_js_1.agentRecorder)({ dispatcher, getRunContext }),
17
18
  (0, CompositionRecorder_js_1.compositionRecorder)({ dispatcher, getRunContext }),
19
+ (0, ErrorBridge_js_1.errorBridge)({ dispatcher, getRunContext, fallback: 'run' }),
18
20
  ...extra,
19
21
  ...attached,
20
22
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"runRecorders.js","sourceRoot":"","sources":["../../src/core/runRecorders.ts"],"names":[],"mappings":";;;AAIA,6EAAuE;AACvE,6FAAuF;AACvF,2EAAqE;AACrE,yEAAmE;AACnE,qFAA+E;AAE/E,8EAA8E;AAC9E,SAAgB,oBAAoB,CAClC,UAA2B,EAC3B,aAA+B,EAC/B,SAAuB,EACvB,KAAkC,EAClC,QAAqC;IAErC,OAAO;QACL,GAAG,SAAS,CAAC,SAAS;QACtB,IAAA,oDAAuB,EAAC,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;QACtD,IAAI,oCAAe,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;QACzE,IAAA,kCAAc,EAAC,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;QAC7C,IAAA,gCAAa,EAAC,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;QAC5C,IAAA,4CAAmB,EAAC,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;QAClD,GAAG,KAAK;QACR,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC;AAjBD,oDAiBC"}
1
+ {"version":3,"file":"runRecorders.js","sourceRoot":"","sources":["../../src/core/runRecorders.ts"],"names":[],"mappings":";;;AAIA,6EAAuE;AACvE,6FAAuF;AACvF,2EAAqE;AACrE,yEAAmE;AACnE,qFAA+E;AAC/E,qEAA+D;AAE/D,8EAA8E;AAC9E,SAAgB,oBAAoB,CAClC,UAA2B,EAC3B,aAA+B,EAC/B,SAAuB,EACvB,KAAkC,EAClC,QAAqC;IAErC,OAAO;QACL,GAAG,SAAS,CAAC,SAAS;QACtB,IAAA,oDAAuB,EAAC,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;QACtD,IAAI,oCAAe,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;QACzE,IAAA,kCAAc,EAAC,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;QAC7C,IAAA,gCAAa,EAAC,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;QAC5C,IAAA,4CAAmB,EAAC,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;QAClD,IAAA,4BAAW,EAAC,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QAC3D,GAAG,KAAK;QACR,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC;AAlBD,oDAkBC"}
@@ -3,6 +3,7 @@ import { contextRecordedRecorder } from '../recorders/core/ContextRecordedRecord
3
3
  import { streamRecorder } from '../recorders/core/StreamRecorder.js';
4
4
  import { agentRecorder } from '../recorders/core/AgentRecorder.js';
5
5
  import { compositionRecorder } from '../recorders/core/CompositionRecorder.js';
6
+ import { errorBridge } from '../recorders/core/ErrorBridge.js';
6
7
  /** Composition-native recorder wiring; all retain the captured invocation. */
7
8
  export function compositionRecorders(dispatcher, getRunContext, redaction, extra, attached) {
8
9
  return [
@@ -12,6 +13,7 @@ export function compositionRecorders(dispatcher, getRunContext, redaction, extra
12
13
  streamRecorder({ dispatcher, getRunContext }),
13
14
  agentRecorder({ dispatcher, getRunContext }),
14
15
  compositionRecorder({ dispatcher, getRunContext }),
16
+ errorBridge({ dispatcher, getRunContext, fallback: 'run' }),
15
17
  ...extra,
16
18
  ...attached,
17
19
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"runRecorders.js","sourceRoot":"","sources":["../../../src/core/runRecorders.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAE/E,8EAA8E;AAC9E,MA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AC7C,aAAa,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;QAC5C,mBAAmB,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;QAClD,WAAW,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QAC3D,GAAG,KAAK;QACR,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC"}
@@ -88,6 +88,14 @@ export interface ToSSEOptions {
88
88
  * default framing only) and with `format: 'text'` (which writes no frames).
89
89
  */
90
90
  readonly framing?: SseFraming<AgentfootprintEvent>;
91
+ /**
92
+ * Start one invocation on this event source, once iteration begins and the
93
+ * subscription is ready. Both formats end when its promise settles and all
94
+ * admitted events have drained. Capture the promise to read the outcome or
95
+ * rejection. A pause ends this stream, so open another stream for `resume()`.
96
+ * A composition's text stream writes the transcript of admitted served tokens.
97
+ */
98
+ readonly start?: () => PromiseLike<unknown>;
91
99
  }
92
100
  /**
93
101
  * How ONE event becomes ONE Server-Sent Events frame — the framing strategy.
@@ -33,13 +33,16 @@ export async function* toSSE(runner, options = {}) {
33
33
  const format = options.format ?? 'full';
34
34
  const heartbeatMs = options.heartbeatMs ?? 0;
35
35
  const framing = framingOf(options);
36
- // Both formats use native turn ownership. Only text reads real event values.
36
+ const start = options.start;
37
+ // A composition's bound transcript reads the served record.
37
38
  const native = runnerLive(runner);
38
39
  const ownsTurn = native?.turn !== undefined;
39
- // Bounded queue: events drained as the consumer iterates.
40
+ const transcript = start !== undefined && format === 'text' && !ownsTurn;
41
+ // Events wait in arrival order until the consumer reads them.
40
42
  const queue = [];
41
43
  let waiter = null;
42
44
  let done = false;
45
+ let accepting = start === undefined;
43
46
  const wakeup = () => {
44
47
  if (waiter) {
45
48
  const w = waiter;
@@ -59,10 +62,12 @@ export async function* toSSE(runner, options = {}) {
59
62
  // same `turn_end` event, paired by the stage that ended the turn. A runner
60
63
  // that is not a RunnerBase has no redaction and no live taps: its events
61
64
  // are the record and the reply at once.
62
- const live = format === 'text' ? native : undefined;
65
+ const live = format === 'text' && !transcript ? native : undefined;
63
66
  const replies = new Map();
64
67
  const answers = new Map();
65
68
  const offReplies = live?.onRealEvent((event) => {
69
+ if (!accepting)
70
+ return;
66
71
  if (event.type === 'agentfootprint.agent.turn_end') {
67
72
  answers.set(event.meta?.runtimeStageId ?? '', unrefusedAnswerOf(event));
68
73
  return;
@@ -108,9 +113,12 @@ export async function* toSSE(runner, options = {}) {
108
113
  let closesOnPause = false;
109
114
  const innerTurns = [];
110
115
  const listener = (event) => {
116
+ if (!accepting)
117
+ return;
111
118
  const mounted = ownsTurn && event.meta?.mountedTurn === true;
112
119
  // These boundaries establish scope even when the output filter drops them.
113
- if ((ownsTurn || format === 'text') &&
120
+ if (!transcript &&
121
+ (ownsTurn || format === 'text') &&
114
122
  !mounted &&
115
123
  event.type === 'agentfootprint.agent.turn_start') {
116
124
  const path = pathOf(event);
@@ -119,33 +127,43 @@ export async function* toSSE(runner, options = {}) {
119
127
  else if (!ownsTurn)
120
128
  innerTurns.push(path);
121
129
  }
122
- if (event.type === 'agentfootprint.pause.resume' && ownsTurn && !rootTurnOpen) {
123
- // A stream opened on resume closes again if that leg pauses.
124
- closesOnPause = true;
125
- }
126
130
  const turnEnd = event.type === 'agentfootprint.agent.turn_end';
127
131
  const rootEnd = turnEnd && event.meta?.rootTurn === true;
128
- // Completion follows the run boundary even when no output is admitted.
129
- const fatal = event.type === 'agentfootprint.error.fatal';
130
- const terminal = fatal ||
131
- (ownsTurn ? rootEnd : turnEnd) ||
132
- (closesOnPause && event.type === 'agentfootprint.pause.request');
133
- if (terminal) {
134
- done = true;
135
- wakeup();
132
+ if (start === undefined) {
133
+ if (event.type === 'agentfootprint.pause.resume' && ownsTurn && !rootTurnOpen) {
134
+ // A stream opened on resume closes again if that leg pauses.
135
+ closesOnPause = true;
136
+ }
137
+ const terminal = event.type === 'agentfootprint.error.fatal' ||
138
+ (ownsTurn ? rootEnd : turnEnd) ||
139
+ (closesOnPause && event.type === 'agentfootprint.pause.request');
140
+ // The output filter can omit a terminal event without keeping the stream open.
141
+ if (terminal) {
142
+ done = true;
143
+ wakeup();
144
+ }
136
145
  }
137
146
  // Consume paired values before applying either output filter.
138
- const reply = live !== undefined && event.type === 'agentfootprint.stream.token'
139
- ? replyFor(event)
140
- : undefined;
141
- const answer = format === 'text' && turnEnd ? answerFor(event, rootEnd, mounted) : undefined;
147
+ let reply;
148
+ if (event.type === 'agentfootprint.stream.token') {
149
+ if (live !== undefined)
150
+ reply = replyFor(event);
151
+ else if (transcript)
152
+ reply = event.payload?.content;
153
+ }
154
+ const answer = format === 'text' && !transcript && turnEnd ? answerFor(event, rootEnd, mounted) : undefined;
142
155
  if (filter && !filter(event))
143
156
  return;
144
157
  // Mounted call boundaries leave the root answer's streamed prefix intact.
145
158
  if (format === 'text' && mounted)
146
159
  return;
160
+ if (transcript && typeof reply !== 'string')
161
+ return;
147
162
  queue.push(reply !== undefined
148
- ? { type: event.type, payload: { content: reply } }
163
+ ? {
164
+ type: transcript ? 'agentfootprint.stream.token' : event.type,
165
+ payload: { content: reply },
166
+ }
149
167
  : format === 'text' && turnEnd
150
168
  ? {
151
169
  type: event.type,
@@ -154,23 +172,51 @@ export async function* toSSE(runner, options = {}) {
154
172
  : event);
155
173
  wakeup();
156
174
  };
157
- const offRecord = runner.on('*', listener);
158
- const unsub = () => {
159
- offRecord();
160
- offReplies?.();
161
- };
175
+ let offRecord;
162
176
  let heartbeat;
163
- if (heartbeatMs > 0) {
164
- heartbeat = setInterval(() => {
165
- queue.push({ type: '__heartbeat' });
166
- wakeup();
167
- }, heartbeatMs);
168
- }
177
+ const release = () => {
178
+ if (heartbeat !== undefined)
179
+ clearInterval(heartbeat);
180
+ replies.clear();
181
+ answers.clear();
182
+ try {
183
+ offRecord?.();
184
+ }
185
+ finally {
186
+ offReplies?.();
187
+ }
188
+ };
189
+ const finish = () => {
190
+ if (done)
191
+ return;
192
+ accepting = false;
193
+ done = true;
194
+ wakeup();
195
+ try {
196
+ release();
197
+ }
198
+ catch {
199
+ // A foreign unsubscribe cannot reopen a settled invocation.
200
+ }
201
+ };
169
202
  /** Frames written to THIS stream so far — the {@link SseFramePosition} of the next one. */
170
203
  let written = 0;
171
204
  /** 'text': what this stream wrote since the last `llm_start`; `undefined` = nothing. */
172
205
  let streamed;
173
206
  try {
207
+ offRecord = runner.on('*', listener);
208
+ if (heartbeatMs > 0) {
209
+ heartbeat = setInterval(() => {
210
+ if (!accepting)
211
+ return;
212
+ queue.push({ type: '__heartbeat' });
213
+ wakeup();
214
+ }, heartbeatMs);
215
+ }
216
+ if (start !== undefined) {
217
+ accepting = true;
218
+ observeSettlement(start, finish);
219
+ }
174
220
  while (!done || queue.length > 0) {
175
221
  while (queue.length > 0) {
176
222
  // queue.length > 0 guards the shift; result is defined.
@@ -212,10 +258,30 @@ export async function* toSSE(runner, options = {}) {
212
258
  }
213
259
  }
214
260
  finally {
215
- unsub();
216
- if (heartbeat)
217
- clearInterval(heartbeat);
261
+ if (start === undefined) {
262
+ release();
263
+ }
264
+ else {
265
+ finish();
266
+ // An early reader exit may still have admitted events it will never read.
267
+ queue.length = 0;
268
+ }
269
+ }
270
+ }
271
+ /** Observe either outcome without reading its value or replacing the caller's promise. */
272
+ function observeSettlement(start, finish) {
273
+ try {
274
+ const pending = start();
275
+ const then = pending?.then;
276
+ if (typeof then === 'function') {
277
+ void then.call(pending, finish, finish);
278
+ return;
279
+ }
280
+ }
281
+ catch {
282
+ // A synchronous failure stops the stream without producing a frame.
218
283
  }
284
+ finish();
219
285
  }
220
286
  /**
221
287
  * Class form for consumers who prefer `new SSEFormatter(runner).stream()`.
@@ -1 +1 @@
1
- {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../src/hosting/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAA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AS,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,SAAS,YAAY,CAAC,KAA0B;IAC9C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAoE,CAAC;IAC3F,OAAO;QACL,KAAK,CAAC,IAAI,EAAE,cAAc,IAAI,EAAE;QAChC,MAAM,CAAC,OAAO,EAAE,SAAS,IAAI,EAAE,CAAC;QAChC,MAAM,CAAC,OAAO,EAAE,UAAU,IAAI,EAAE,CAAC;KAClC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACnB,CAAC"}
@@ -0,0 +1,40 @@
1
+ import type { OnSkipPolicy, SkillStep } from '../skillSteps.js';
2
+ import { type DeclaredRoute } from '../skillsFromDirRoutes.js';
3
+ /**
4
+ * What a parsed `SKILL.md` yielded, before it becomes an Injection. Kept
5
+ * separate from the Injection so collision reporting can name the FILE each
6
+ * offending skill came from, not just the id.
7
+ */
8
+ interface ParsedSkillFile {
9
+ readonly name: string;
10
+ readonly description: string;
11
+ readonly body: string;
12
+ /** Tool NAMES the file declared, in declaration order. Absent when the file
13
+ * declared no `tools:` key at all — which is not the same as an empty list
14
+ * (that is refused). */
15
+ readonly toolNames?: readonly string[];
16
+ /** Steps as data, already shaped like `defineSkill`'s `steps`. */
17
+ readonly steps?: readonly SkillStep[];
18
+ readonly onSkip?: OnSkipPolicy;
19
+ /** The ROUTING this file declared (9.43.0) — target ids + data guards, still
20
+ * unresolved: a file cannot know what the rest of the directory carries.
21
+ * Absent when the file declared no `routes:` key, which is what every file
22
+ * written before this release does. */
23
+ readonly routes?: readonly DeclaredRoute[];
24
+ /** Absolute-ish path as given to the reader — what error messages quote. */
25
+ readonly file: string;
26
+ }
27
+ /**
28
+ * Parse one `SKILL.md`. Every refusal names the file — a loader that says
29
+ * "malformed frontmatter" over a directory of forty files has told you nothing.
30
+ *
31
+ * The grammar is deliberately small: an opening `---` line, `key: value` lines
32
+ * (`#` comments and blank lines skipped, single/double quotes stripped), a
33
+ * closing `---` line, then the body. A key with NOTHING after the colon opens a
34
+ * block list, whose items are the following `- …` lines. Keys other than the
35
+ * five known ones are IGNORED rather than rejected, so a file carrying extra
36
+ * frontmatter for another tool still loads here.
37
+ */
38
+ declare function parseSkillFile(raw: string, file: string): ParsedSkillFile;
39
+ export { parseSkillFile };
40
+ export type { ParsedSkillFile };
@@ -0,0 +1,272 @@
1
+ import { readDeclaredRoutes } from '../skillsFromDirRoutes.js';
2
+ /**
3
+ * Skill ids ride into `read_skill`'s `enum` and into the skill-graph's node
4
+ * ids. The house tool-name charset keeps them quotable in a prompt, comparable
5
+ * as plain strings, and safe as an object key.
6
+ */
7
+ const SKILL_NAME_RE = /^[a-zA-Z0-9_-]{1,64}$/;
8
+ /**
9
+ * Parse one `SKILL.md`. Every refusal names the file — a loader that says
10
+ * "malformed frontmatter" over a directory of forty files has told you nothing.
11
+ *
12
+ * The grammar is deliberately small: an opening `---` line, `key: value` lines
13
+ * (`#` comments and blank lines skipped, single/double quotes stripped), a
14
+ * closing `---` line, then the body. A key with NOTHING after the colon opens a
15
+ * block list, whose items are the following `- …` lines. Keys other than the
16
+ * five known ones are IGNORED rather than rejected, so a file carrying extra
17
+ * frontmatter for another tool still loads here.
18
+ */
19
+ function parseSkillFile(raw, file) {
20
+ // Strip a UTF-8 BOM — an editor artifact, not the author's intent.
21
+ const text = raw.charCodeAt(0) === 0xfeff ? raw.slice(1) : raw;
22
+ const lines = text.split(/\r?\n/);
23
+ if (lines[0]?.trim() !== '---') {
24
+ throw new Error(`skillsFromDir: '${file}' does not start with a '---' frontmatter block. ` +
25
+ `Expected:\n---\nname: my-skill\ndescription: When to use it.\n---\n<the body>`);
26
+ }
27
+ const closingIndex = lines.findIndex((line, i) => i > 0 && line.trim() === '---');
28
+ if (closingIndex === -1) {
29
+ throw new Error(`skillsFromDir: '${file}' opens a '---' frontmatter block that is never closed. ` +
30
+ `Add a '---' line after the last frontmatter key.`);
31
+ }
32
+ const fields = parseFrontmatterFields(lines, closingIndex, file);
33
+ const name = readScalar(fields, 'name', file);
34
+ const description = readScalar(fields, 'description', file);
35
+ const body = lines
36
+ .slice(closingIndex + 1)
37
+ .join('\n')
38
+ .trim();
39
+ if (name.length === 0) {
40
+ throw new Error(`skillsFromDir: '${file}' frontmatter is missing 'name'. It becomes the skill id the ` +
41
+ `model passes to read_skill.`);
42
+ }
43
+ if (!SKILL_NAME_RE.test(name)) {
44
+ throw new Error(`skillsFromDir: '${file}' frontmatter name '${name}' must match ` +
45
+ `/^[a-zA-Z0-9_-]{1,64}$/ — it is the id the model passes to read_skill.`);
46
+ }
47
+ if (description.length === 0) {
48
+ throw new Error(`skillsFromDir: '${file}' frontmatter is missing 'description'. It is the ONLY thing ` +
49
+ `the model reads when deciding whether to open this skill.`);
50
+ }
51
+ if (body.length === 0) {
52
+ throw new Error(`skillsFromDir: '${file}' has no body after the closing '---'. The body is what the ` +
53
+ `model reads once it activates the skill.`);
54
+ }
55
+ const toolNames = readToolNames(fields, file);
56
+ const steps = readSteps(fields, file, toolNames);
57
+ const onSkip = readOnSkip(fields, file, steps);
58
+ const routes = readRoutes(fields, file, toolNames);
59
+ return {
60
+ name,
61
+ description,
62
+ body,
63
+ ...(toolNames !== undefined && { toolNames }),
64
+ ...(steps !== undefined && { steps }),
65
+ ...(onSkip !== undefined && { onSkip }),
66
+ ...(routes !== undefined && { routes }),
67
+ file,
68
+ };
69
+ }
70
+ /**
71
+ * The frontmatter lines → `key → value` map.
72
+ *
73
+ * A `- …` line is an ITEM only while a list is open (the line above it was a
74
+ * key with an empty value). Anywhere else it falls through to the `key: value`
75
+ * rule exactly as it always did — so a stray dash in somebody's unknown key
76
+ * keeps loading, and only a deliberate block list is read as one.
77
+ */
78
+ function parseFrontmatterFields(lines, closingIndex, file) {
79
+ const fields = new Map();
80
+ let openList;
81
+ for (let i = 1; i < closingIndex; i++) {
82
+ const line = lines[i] ?? '';
83
+ const trimmed = line.trim();
84
+ if (trimmed.length === 0 || trimmed.startsWith('#'))
85
+ continue;
86
+ if (openList !== undefined && (trimmed === '-' || trimmed.startsWith('- '))) {
87
+ const item = trimmed === '-' ? '' : trimmed.slice(2).trim();
88
+ const separator = item.indexOf(':');
89
+ openList.push(separator === -1
90
+ ? { key: item, line: i + 1 }
91
+ : {
92
+ key: item.slice(0, separator).trim(),
93
+ value: unquote(item.slice(separator + 1).trim()),
94
+ line: i + 1,
95
+ });
96
+ continue;
97
+ }
98
+ const separator = line.indexOf(':');
99
+ if (separator === -1) {
100
+ throw new Error(`skillsFromDir: '${file}' frontmatter line ${i + 1} is not 'key: value' — got ` +
101
+ `${JSON.stringify(line)}.`);
102
+ }
103
+ const key = line.slice(0, separator).trim();
104
+ if (key.length === 0) {
105
+ throw new Error(`skillsFromDir: '${file}' frontmatter line ${i + 1} has an empty key — got ` +
106
+ `${JSON.stringify(line)}.`);
107
+ }
108
+ const value = unquote(line.slice(separator + 1).trim());
109
+ if (value.length === 0) {
110
+ // An empty value OPENS a list. With no items after it the field stays an
111
+ // empty list, which every reader below treats exactly as the empty string
112
+ // it used to be — so `name:` with nothing after it still says "missing
113
+ // 'name'", not something new about lists.
114
+ const items = [];
115
+ openList = items;
116
+ fields.set(key, { kind: 'list', items });
117
+ }
118
+ else {
119
+ openList = undefined;
120
+ fields.set(key, { kind: 'scalar', text: value });
121
+ }
122
+ }
123
+ return fields;
124
+ }
125
+ /** A single-valued key, as it always read. An empty block list reads as '' — a
126
+ * key with nothing under it never carried a value in the first place. */
127
+ function readScalar(fields, key, file) {
128
+ const field = fields.get(key);
129
+ if (field === undefined)
130
+ return '';
131
+ if (field.kind === 'scalar')
132
+ return field.text;
133
+ if (field.items.length === 0)
134
+ return '';
135
+ throw new Error(`skillsFromDir: '${file}' frontmatter '${key}' is a list, and '${key}' takes one value. ` +
136
+ `Write it as '${key}: <value>' on one line.`);
137
+ }
138
+ /**
139
+ * `tools:` → the declared names, or undefined when the key is absent.
140
+ *
141
+ * Two spellings, because both read naturally at the size they are for:
142
+ * `tools: a, b` for the two-tool skill, and a block list once there are six.
143
+ */
144
+ function readToolNames(fields, file) {
145
+ const field = fields.get('tools');
146
+ if (field === undefined)
147
+ return undefined;
148
+ const names = field.kind === 'scalar'
149
+ ? field.text
150
+ .split(',')
151
+ .map((n) => unquote(n.trim()))
152
+ .filter((n) => n.length > 0)
153
+ : field.items.map((item) => {
154
+ if (item.value !== undefined) {
155
+ throw new Error(`skillsFromDir: '${file}' line ${item.line}: a 'tools' item is a NAME, not a ` +
156
+ `pair — write '- ${item.key}'. (Did you mean to put this under 'steps', where ` +
157
+ `each item is '- <tool>: <why>'?)`);
158
+ }
159
+ return item.key;
160
+ });
161
+ if (names.length === 0) {
162
+ throw new Error(`skillsFromDir: '${file}' declares 'tools' with no names. Say what you mean and omit ` +
163
+ `the key — a skill with no tools is exactly what this loader has always produced. ` +
164
+ `Otherwise: 'tools: lookup_order, issue_refund', or a '- <name>' block list.`);
165
+ }
166
+ const seen = new Set();
167
+ for (const name of names) {
168
+ if (seen.has(name)) {
169
+ throw new Error(`skillsFromDir: '${file}' lists the tool '${name}' twice in 'tools'. Each tool ` +
170
+ `belongs to a skill once (a skill's tools must be unique within itself); repeat it ` +
171
+ `in 'steps' instead if the procedure runs it twice.`);
172
+ }
173
+ seen.add(name);
174
+ }
175
+ return names;
176
+ }
177
+ /**
178
+ * `steps:` → the procedure, as data.
179
+ *
180
+ * Validated against the file's OWN `tools` here, ahead of `defineSkill`'s
181
+ * identical check, for one reason: this message can name the FILE and the LINE.
182
+ * `defineSkill` sees a skill id and cannot.
183
+ */
184
+ function readSteps(fields, file, toolNames) {
185
+ const field = fields.get('steps');
186
+ if (field === undefined)
187
+ return undefined;
188
+ if (field.kind === 'scalar') {
189
+ throw new Error(`skillsFromDir: '${file}' writes 'steps' on one line, and a procedure is an ORDERED ` +
190
+ `list of pairs. Write it as a block:\nsteps:\n - lookup_order: look up the order ` +
191
+ `first\n - issue_refund: refund only what the lookup found`);
192
+ }
193
+ if (field.items.length === 0) {
194
+ throw new Error(`skillsFromDir: '${file}' declares 'steps' with no items. Say what you mean and omit ` +
195
+ `the key — a skill without steps is byte-identical to one that never heard of them.`);
196
+ }
197
+ if (toolNames === undefined) {
198
+ throw new Error(`skillsFromDir: '${file}' declares 'steps' but no 'tools'. Every step runs one of the ` +
199
+ `skill's own tools, so a sequence with nothing to sequence can never engage. Add ` +
200
+ `'tools: …', or drop 'steps'.`);
201
+ }
202
+ const declared = new Set(toolNames);
203
+ return field.items.map((item) => {
204
+ if (item.value === undefined || item.value.length === 0) {
205
+ throw new Error(`skillsFromDir: '${file}' line ${item.line}: every step is '- <tool>: <why>' and ` +
206
+ `this one has no why. The note is the sentence the model reads about why the step ` +
207
+ `exists — a step without one is a force-march instruction, and the note is the ` +
208
+ `whole point.`);
209
+ }
210
+ if (item.key.length === 0) {
211
+ throw new Error(`skillsFromDir: '${file}' line ${item.line}: this step names no tool. Every step is ` +
212
+ `'- <tool>: <why>'.`);
213
+ }
214
+ if (!declared.has(item.key)) {
215
+ throw new Error(`skillsFromDir: '${file}' line ${item.line}: step '${item.key}' is not in this ` +
216
+ `file's 'tools' (${toolNames.join(', ')}). Steps may only sequence the skill's own ` +
217
+ `tools — add it to 'tools', or fix the name. Everything else the agent has stays ` +
218
+ `available as an escape hatch, unsequenced.`);
219
+ }
220
+ return { tool: item.key, note: item.value };
221
+ });
222
+ }
223
+ /**
224
+ * `routes:` → the edges out of this skill (9.43.0), as data.
225
+ *
226
+ * A block list, like `steps:` and for the same reason: routing is an ordered
227
+ * list of pairs (a target and its guard), and one line cannot carry that
228
+ * without a separator soup. The grammar itself — and every refusal in it —
229
+ * lives in `skillsFromDirRoutes.ts`; this reader only decides that the key is
230
+ * present and shaped like a list.
231
+ */
232
+ function readRoutes(fields, file, toolNames) {
233
+ const field = fields.get('routes');
234
+ if (field === undefined)
235
+ return undefined;
236
+ if (field.kind === 'scalar') {
237
+ throw new Error(`skillsFromDir: '${file}' writes 'routes' on one line, and routing is a LIST of edges ` +
238
+ `(each with its own guard). Write it as a block:\nroutes:\n - escalation: on ` +
239
+ `issue_refund status=denied\n - receipts: on issue_refund`);
240
+ }
241
+ return readDeclaredRoutes(field.items, file, toolNames);
242
+ }
243
+ /** `onSkip:` → the skip policy. Refused here rather than at `defineSkill` so
244
+ * the message can name the file the author has to open. */
245
+ function readOnSkip(fields, file, steps) {
246
+ if (fields.get('onSkip') === undefined)
247
+ return undefined;
248
+ const raw = readScalar(fields, 'onSkip', file);
249
+ if (steps === undefined) {
250
+ throw new Error(`skillsFromDir: '${file}' declares 'onSkip' with no 'steps'. It says what a SKIPPED ` +
251
+ `step does, and this file declares no steps. Add 'steps:', or drop 'onSkip'.`);
252
+ }
253
+ if (raw !== 'advance' && raw !== 'hold') {
254
+ throw new Error(`skillsFromDir: '${file}' declares onSkip '${raw}', which is not a policy this ` +
255
+ `library has. The two are 'advance' (record the skip and move on — the default) and ` +
256
+ `'hold' (record the skip and keep the step current).`);
257
+ }
258
+ return raw;
259
+ }
260
+ /** Strip one layer of matching single or double quotes from a YAML-ish scalar. */
261
+ function unquote(value) {
262
+ if (value.length >= 2) {
263
+ const first = value[0];
264
+ const last = value[value.length - 1];
265
+ if ((first === '"' && last === '"') || (first === "'" && last === "'")) {
266
+ return value.slice(1, -1);
267
+ }
268
+ }
269
+ return value;
270
+ }
271
+ export { parseSkillFile };
272
+ //# sourceMappingURL=frontmatter.js.map