maestro-agent-sdk 0.1.32 → 0.1.34

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 (61) hide show
  1. package/README.md +19 -10
  2. package/dist/index.d.ts +2 -8
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +2 -9
  5. package/dist/index.js.map +1 -1
  6. package/dist/provider.d.ts +0 -62
  7. package/dist/provider.d.ts.map +1 -1
  8. package/dist/provider.js +23 -167
  9. package/dist/provider.js.map +1 -1
  10. package/dist/session-store.d.ts +0 -12
  11. package/dist/session-store.d.ts.map +1 -1
  12. package/dist/session-store.js +0 -10
  13. package/dist/session-store.js.map +1 -1
  14. package/dist/sub-agent/runner.d.ts +14 -6
  15. package/dist/sub-agent/runner.d.ts.map +1 -1
  16. package/dist/sub-agent/runner.js +16 -13
  17. package/dist/sub-agent/runner.js.map +1 -1
  18. package/dist/tools/builtin/agent.d.ts +8 -7
  19. package/dist/tools/builtin/agent.d.ts.map +1 -1
  20. package/dist/tools/builtin/agent.js +6 -6
  21. package/dist/tools/builtin/agent.js.map +1 -1
  22. package/dist/tools/index.d.ts +0 -2
  23. package/dist/tools/index.d.ts.map +1 -1
  24. package/dist/tools/index.js +0 -2
  25. package/dist/tools/index.js.map +1 -1
  26. package/dist/tools/registry.d.ts +9 -0
  27. package/dist/tools/registry.d.ts.map +1 -1
  28. package/dist/tools/registry.js +11 -0
  29. package/dist/tools/registry.js.map +1 -1
  30. package/dist/types.d.ts +25 -39
  31. package/dist/types.d.ts.map +1 -1
  32. package/dist/types.js.map +1 -1
  33. package/package.json +1 -1
  34. package/dist/skills/curator.d.ts +0 -106
  35. package/dist/skills/curator.d.ts.map +0 -1
  36. package/dist/skills/curator.js +0 -168
  37. package/dist/skills/curator.js.map +0 -1
  38. package/dist/skills/index-builder.d.ts +0 -41
  39. package/dist/skills/index-builder.d.ts.map +0 -1
  40. package/dist/skills/index-builder.js +0 -93
  41. package/dist/skills/index-builder.js.map +0 -1
  42. package/dist/skills/loader.d.ts +0 -132
  43. package/dist/skills/loader.d.ts.map +0 -1
  44. package/dist/skills/loader.js +0 -331
  45. package/dist/skills/loader.js.map +0 -1
  46. package/dist/skills/preprocess.d.ts +0 -45
  47. package/dist/skills/preprocess.d.ts.map +0 -1
  48. package/dist/skills/preprocess.js +0 -126
  49. package/dist/skills/preprocess.js.map +0 -1
  50. package/dist/skills/usage.d.ts +0 -76
  51. package/dist/skills/usage.d.ts.map +0 -1
  52. package/dist/skills/usage.js +0 -147
  53. package/dist/skills/usage.js.map +0 -1
  54. package/dist/tools/builtin/skill_view.d.ts +0 -37
  55. package/dist/tools/builtin/skill_view.d.ts.map +0 -1
  56. package/dist/tools/builtin/skill_view.js +0 -82
  57. package/dist/tools/builtin/skill_view.js.map +0 -1
  58. package/dist/tools/builtin/skill_write.d.ts +0 -53
  59. package/dist/tools/builtin/skill_write.d.ts.map +0 -1
  60. package/dist/tools/builtin/skill_write.js +0 -264
  61. package/dist/tools/builtin/skill_write.js.map +0 -1
@@ -1,331 +0,0 @@
1
- import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
2
- import { basename, join, sep } from "node:path";
3
- import { logger } from "../platform/logger.js";
4
- /** Sub-directory names we never descend into. Mirrors upstream
5
- * `scan_skill_commands` skip set. */
6
- const SKIP_DIRS = new Set([".git", ".github", ".hub", ".archive", "node_modules"]);
7
- /** Description length cap for the rendered index. Raised from 60 → 300 in
8
- * v0.1.5 because the original 60-char ceiling truncated the "trigger
9
- * keywords" line that clawgram-style skills rely on for activation —
10
- * hosts intentionally pack a comma-separated list of search terms into
11
- * the description, and chopping it at 60 chars regularly lost half the
12
- * keywords. 300 is generous enough that every real-world description we
13
- * audited fits intact, while still keeping the per-skill system-prompt
14
- * footprint bounded if a runaway author writes a 5KB description. The
15
- * full description still ships with `skill_view` for the body view. */
16
- export const SKILL_INDEX_DESCRIPTION_CAP = 300;
17
- /**
18
- * Walk `rootDir` recursively and return one `SkillEntry` per SKILL.md found,
19
- * subject to platform compatibility + the skip-dir filter.
20
- *
21
- * Errors per-file (unreadable, malformed) are logged at debug and the file
22
- * is dropped — one bad SKILL.md never aborts the whole scan, same stance as
23
- * upstream `scan_skill_commands`.
24
- */
25
- export function loadSkills(rootDir) {
26
- if (!existsSync(rootDir)) {
27
- logger.debug({ rootDir }, "maestro skills: rootDir missing — returning empty");
28
- return [];
29
- }
30
- const out = [];
31
- const seenNames = new Set();
32
- walk(rootDir, rootDir, out, seenNames);
33
- // Deterministic ordering for cache-friendly system-prompt rendering: by
34
- // category then by name. Without this, readdir's filesystem-dependent
35
- // ordering would shuffle entries between runs and break prefix caching.
36
- out.sort((a, b) => {
37
- if (a.category !== b.category)
38
- return a.category.localeCompare(b.category);
39
- return a.name.localeCompare(b.name);
40
- });
41
- return out;
42
- }
43
- /** Filenames recognized as skill manifests. SKILL.md is upstream v0.13.0;
44
- * skill.md is the clawgram convention. Both are accepted at the same
45
- * layout position, and if a directory somehow contains both (mixed-style
46
- * hand-edit), SKILL.md wins because it's the original format and we
47
- * don't want a silent semantic shift if a host migrates incrementally. */
48
- const SKILL_FILENAMES = ["SKILL.md", "skill.md"];
49
- function walk(root, dir, out, seenNames) {
50
- let entries;
51
- try {
52
- entries = readdirSync(dir);
53
- }
54
- catch (err) {
55
- logger.debug({ err, dir }, "maestro skills: readdir failed, skipping subtree");
56
- return;
57
- }
58
- for (const name of entries) {
59
- if (SKIP_DIRS.has(name))
60
- continue;
61
- const path = join(dir, name);
62
- let stat;
63
- try {
64
- stat = statSync(path);
65
- }
66
- catch {
67
- continue;
68
- }
69
- if (stat.isDirectory()) {
70
- walk(root, path, out, seenNames);
71
- continue;
72
- }
73
- if (!stat.isFile())
74
- continue;
75
- const base = basename(path);
76
- if (!SKILL_FILENAMES.includes(base))
77
- continue;
78
- const entry = parseSkillFile(root, path);
79
- if (!entry)
80
- continue;
81
- // De-duplicate by skill name. Upstream scans local dir first, then
82
- // external dirs; we follow the same precedence by walking in readdir
83
- // order from a single root — the first occurrence wins.
84
- if (seenNames.has(entry.name))
85
- continue;
86
- if (!matchesPlatform(entry.frontmatter))
87
- continue;
88
- seenNames.add(entry.name);
89
- out.push(entry);
90
- }
91
- }
92
- function parseSkillFile(root, mdPath) {
93
- let raw;
94
- try {
95
- raw = readFileSync(mdPath, "utf8");
96
- }
97
- catch (err) {
98
- logger.debug({ err, mdPath }, "maestro skills: read failed, skipping");
99
- return null;
100
- }
101
- const { frontmatter, body } = parseFrontmatter(raw);
102
- // Strip the trailing skill-file basename to recover the skill's directory,
103
- // regardless of which casing was used (SKILL.md vs skill.md).
104
- const skillDir = mdPath.slice(0, -`/${basename(mdPath)}`.length);
105
- const dirName = basename(skillDir);
106
- const name = (frontmatter.name ?? dirName).trim();
107
- if (!name)
108
- return null;
109
- // Category = directory bucket relative to root. e.g. root/apple/foo/SKILL.md → "apple".
110
- // Root-level skills get "general" to match upstream behavior.
111
- const rel = skillDir.slice(root.length).replace(/^[/\\]+/, "");
112
- const parts = rel.split(sep).filter(Boolean);
113
- const category = parts.length > 1 ? parts.slice(0, -1).join("/") : "general";
114
- // Description resolution order:
115
- // 1. YAML frontmatter `description:` (upstream v0.13.0 convention)
116
- // 2. `> **Description**: ...` blockquote anywhere in the body
117
- // (clawgram body-based convention — single line, optional bold,
118
- // case-insensitive label)
119
- // 3. First non-blank, non-heading, non-blockquote line of the body
120
- // (last-resort fallback so a SKILL.md without either still surfaces
121
- // something useful in the index)
122
- // Empty string is valid — index-builder renders without the `: ...` suffix.
123
- let description = (frontmatter.description ?? "").trim();
124
- if (!description)
125
- description = extractBlockquoteDescription(body);
126
- if (!description) {
127
- for (const line of body.split("\n")) {
128
- const t = line.trim();
129
- if (!t || t.startsWith("#") || t.startsWith(">"))
130
- continue;
131
- description = t;
132
- break;
133
- }
134
- }
135
- // Strip surrounding quotes (YAML scalars are often written as quoted strings).
136
- description = description.replace(/^["']|["']$/g, "");
137
- return {
138
- name,
139
- description,
140
- category,
141
- skillDir,
142
- mdPath,
143
- raw,
144
- frontmatter,
145
- };
146
- }
147
- /**
148
- * Pull a `> **Description**: ...` (or `> Description: ...`) blockquote out
149
- * of a markdown body. Matches the clawgram convention where a single-line
150
- * blockquote near the top of the file carries the trigger keywords.
151
- *
152
- * Case-insensitive on the label, tolerant of either `**Description**` or
153
- * plain `Description`. Only the first match is returned — multi-line
154
- * blockquotes get joined into one line by trimming trailing whitespace and
155
- * collapsing inner newlines.
156
- *
157
- * Returns "" when no blockquote matches, so the caller can decide whether
158
- * to fall back to a different source.
159
- */
160
- export function extractBlockquoteDescription(body) {
161
- // ^> +(\*\*)?Description(\*\*)?:?\s*(rest of line)
162
- const re = /^[ \t]*>[ \t]*(?:\*\*)?\s*description\s*(?:\*\*)?[ \t]*:?[ \t]*(.+)$/im;
163
- const m = re.exec(body);
164
- if (!m)
165
- return "";
166
- return m[1].replace(/\s+/g, " ").trim();
167
- }
168
- /**
169
- * Parse a `---\n...\n---\n` YAML frontmatter block into a flat string map.
170
- *
171
- * Supports the SKILL.md surface that matters in v0.13.0:
172
- * - `key: value` scalars (with optional surrounding quotes)
173
- * - `key: [a, b, c]` flow-list literals (joined with "," for storage)
174
- * - Nested blocks (`metadata:\n maestro:\n tags: [...]`) are flattened
175
- * by ignoring indented lines — we only need top-level keys for the
176
- * index + platform filter.
177
- *
178
- * Lines that don't fit the `key: value` shape are dropped silently. This
179
- * matches the upstream "fallback" parser; the full YAML parser is omitted
180
- * because every real-world SKILL.md in v0.13.0 round-trips cleanly through
181
- * this subset.
182
- *
183
- * Returns `body` as the post-frontmatter text. If no frontmatter is
184
- * present, `frontmatter` is empty and `body` is the original input.
185
- */
186
- export function parseFrontmatter(content) {
187
- const frontmatter = {};
188
- if (!content.startsWith("---"))
189
- return { frontmatter, body: content };
190
- // Find the closing `---` (must be on its own line, after the opening).
191
- const closeMatch = /\n---[ \t]*(?:\n|$)/.exec(content.slice(3));
192
- if (!closeMatch)
193
- return { frontmatter, body: content };
194
- const yamlBlock = content.slice(3, closeMatch.index + 3);
195
- const body = content.slice(closeMatch.index + 3 + closeMatch[0].length);
196
- for (const rawLine of yamlBlock.split("\n")) {
197
- // Skip blanks, comments, and indented (nested) entries.
198
- const line = rawLine.replace(/[\r]+$/, "");
199
- if (!line.trim() || line.trim().startsWith("#"))
200
- continue;
201
- if (/^\s/.test(line))
202
- continue;
203
- const idx = line.indexOf(":");
204
- if (idx < 0)
205
- continue;
206
- const key = line.slice(0, idx).trim();
207
- let value = line.slice(idx + 1).trim();
208
- if (!key)
209
- continue;
210
- // Flow-list literal → CSV of unwrapped scalars.
211
- if (value.startsWith("[") && value.endsWith("]")) {
212
- value = value
213
- .slice(1, -1)
214
- .split(",")
215
- .map((s) => s.trim().replace(/^["']|["']$/g, ""))
216
- .filter(Boolean)
217
- .join(",");
218
- }
219
- else {
220
- // Strip surrounding quotes if present.
221
- value = value.replace(/^["']|["']$/g, "");
222
- }
223
- frontmatter[key] = value;
224
- }
225
- return { frontmatter, body };
226
- }
227
- /** Map `process.platform` to the upstream platform tokens used in SKILL.md
228
- * `platforms:` lists. */
229
- const PLATFORM_ALIASES = {
230
- macos: "darwin",
231
- osx: "darwin",
232
- mac: "darwin",
233
- linux: "linux",
234
- win: "win32",
235
- windows: "win32",
236
- };
237
- /**
238
- * Return true if the skill's `platforms:` list contains the current OS, or
239
- * if the field is missing/empty (skill claims cross-platform).
240
- *
241
- * Match logic is upstream-compatible: any listed platform whose mapped
242
- * runtime prefix is a prefix of `process.platform` counts as a hit (so
243
- * `darwin` matches `darwin23.6.0`).
244
- */
245
- export function matchesPlatform(frontmatter, platform = process.platform) {
246
- const raw = frontmatter.platforms;
247
- if (!raw)
248
- return true;
249
- const list = raw
250
- .split(",")
251
- .map((s) => s.trim().toLowerCase())
252
- .filter(Boolean);
253
- if (list.length === 0)
254
- return true;
255
- for (const p of list) {
256
- const mapped = PLATFORM_ALIASES[p] ?? p;
257
- if (platform.startsWith(mapped))
258
- return true;
259
- }
260
- return false;
261
- }
262
- let cachedSkills = null;
263
- const DEFAULT_CACHE_TTL_MS = 30_000;
264
- function cacheTtlMs() {
265
- const raw = process.env.MAESTRO_SKILL_CACHE_TTL_MS;
266
- if (raw === undefined)
267
- return DEFAULT_CACHE_TTL_MS;
268
- const n = Number(raw);
269
- if (!Number.isFinite(n) || n < 0)
270
- return DEFAULT_CACHE_TTL_MS;
271
- return n;
272
- }
273
- function safeRootMtime(rootDir) {
274
- try {
275
- return statSync(rootDir).mtimeMs;
276
- }
277
- catch {
278
- return 0;
279
- }
280
- }
281
- /**
282
- * Cached variant of `loadSkills` — same return shape, but memoizes on the
283
- * (rootDir, rootDir-mtime) pair with a TTL backstop. Use this from any hot
284
- * path (per-turn callers, per-iteration callers). Tests or operators that
285
- * need a guaranteed fresh load can call `invalidateSkillsCache()` first.
286
- */
287
- export function loadSkillsCached(rootDir) {
288
- const ttl = cacheTtlMs();
289
- if (ttl === 0)
290
- return loadSkills(rootDir);
291
- const now = Date.now();
292
- if (cachedSkills && cachedSkills.rootDir === rootDir) {
293
- const rootMtimeMs = safeRootMtime(rootDir);
294
- const fresh = now - cachedSkills.builtAtMs < ttl;
295
- const sameRoot = rootMtimeMs === cachedSkills.rootMtimeMs;
296
- if (fresh && sameRoot)
297
- return cachedSkills.entries;
298
- }
299
- const entries = loadSkills(rootDir);
300
- cachedSkills = {
301
- rootDir,
302
- entries,
303
- builtAtMs: now,
304
- rootMtimeMs: safeRootMtime(rootDir),
305
- };
306
- return entries;
307
- }
308
- /** Drop the in-memory cache so the next `loadSkillsCached` call rebuilds.
309
- * Call after writing a new SKILL.md to disk, or between tests. */
310
- export function invalidateSkillsCache() {
311
- cachedSkills = null;
312
- }
313
- /** Find a single skill by name. Used by `skill_view`. Returns null if the
314
- * name doesn't resolve to a loaded entry. */
315
- export function findSkillByName(skills, name) {
316
- const wanted = name.trim();
317
- if (!wanted)
318
- return null;
319
- for (const s of skills) {
320
- if (s.name === wanted)
321
- return s;
322
- }
323
- // Case-insensitive fallback — model occasionally lowercases identifiers.
324
- const lower = wanted.toLowerCase();
325
- for (const s of skills) {
326
- if (s.name.toLowerCase() === lower)
327
- return s;
328
- }
329
- return null;
330
- }
331
- //# sourceMappingURL=loader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/skills/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AA0D3C;sCACsC;AACtC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,cAAc,CAAC,CAAC,CAAC;AAEnF;;;;;;;;wEAQwE;AACxE,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAE/C;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,EAAE,mDAAmD,CAAC,CAAC;QAC/E,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,GAAG,GAAiB,EAAE,CAAC;IAC7B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IACpC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;IACvC,wEAAwE;IACxE,sEAAsE;IACtE,wEAAwE;IACxE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QAChB,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ;YAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CA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AAM,CAAC,WAAW,EAAE,CAAC;IACnC,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,KAAK;YAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,45 +0,0 @@
1
- export interface PreprocessOptions {
2
- /** Absolute path passed to `${MAESTRO_SKILL_DIR}` (`null` keeps the token literal). */
3
- skillDir?: string | null;
4
- /** Maestro session UUID for `${MAESTRO_SESSION_ID}` (`null` keeps the token literal). */
5
- sessionId?: string | null;
6
- /** Run `!`cmd`` snippets at preprocess time. Default `false` (matches upstream). */
7
- inlineShell?: boolean;
8
- /** Per-snippet timeout in seconds when `inlineShell: true`. */
9
- inlineShellTimeoutS?: number;
10
- }
11
- /**
12
- * Replace `${MAESTRO_SKILL_DIR}` / `${MAESTRO_SESSION_ID}` in `content`.
13
- *
14
- * Tokens for which the corresponding option value is missing are left in
15
- * place — the author can then see "oh, this skill was loaded without a
16
- * session id" instead of getting silent empty strings.
17
- */
18
- export declare function substituteTemplateVars(content: string, opts: {
19
- skillDir?: string | null;
20
- sessionId?: string | null;
21
- }): string;
22
- /**
23
- * Run one inline-shell snippet. Failures return a short `[inline-shell ...]`
24
- * marker rather than throwing so a single bad snippet can't break the whole
25
- * skill load.
26
- *
27
- * `cwd` is set to the skill directory so relative paths in the snippet
28
- * resolve where the author expected them to.
29
- */
30
- export declare function runInlineShell(command: string, cwd: string | null | undefined, timeoutS: number): string;
31
- /** Expand every `` !`cmd` `` snippet in `content` with its stdout. No-op
32
- * when the content has no `!`` marker (cheap fast path). */
33
- export declare function expandInlineShell(content: string, cwd: string | null | undefined, timeoutS: number): string;
34
- /**
35
- * Single-call entry point used by `skill_view`. Applies template-var
36
- * substitution unconditionally and inline-shell only when explicitly
37
- * opted in.
38
- *
39
- * Returns the input unchanged when it's empty (defensive — upstream's
40
- * `preprocess_skill_content` returns `""` for empty inputs).
41
- */
42
- export declare function preprocessSkillContent(content: string, opts: PreprocessOptions): string;
43
- export declare const __INLINE_SHELL_MAX_OUTPUT = 4000;
44
- export declare const __INLINE_SHELL_DEFAULT_TIMEOUT_S = 10;
45
- //# sourceMappingURL=preprocess.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preprocess.d.ts","sourceRoot":"","sources":["../../src/skills/preprocess.ts"],"names":[],"mappings":"AA4CA,MAAM,WAAW,iBAAiB;IAChC,uFAAuF;IACvF,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,oFAAoF;IACpF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,+DAA+D;IAC/D,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAC5D,MAAM,CAOR;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9B,QAAQ,EAAE,MAAM,GACf,MAAM,CAyBR;AAED;6DAC6D;AAC7D,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9B,QAAQ,EAAE,MAAM,GACf,MAAM,CAOR;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,MAAM,CAQvF;AAGD,eAAO,MAAM,yBAAyB,OAA0B,CAAC;AACjE,eAAO,MAAM,gCAAgC,KAAiC,CAAC"}
@@ -1,126 +0,0 @@
1
- import { spawnSync } from "node:child_process";
2
- /**
3
- * SKILL.md content preprocessing for the Maestro TS port.
4
- *
5
- * Two transforms, both lifted from upstream `agent/skill_preprocessing.py`:
6
- *
7
- * 1. Template variable substitution — `${MAESTRO_SKILL_DIR}` and
8
- * `${MAESTRO_SESSION_ID}` get replaced with the active skill's absolute
9
- * directory and the current Maestro session id, respectively. Skill
10
- * authors rely on this to reference bundled scripts:
11
- *
12
- * Run `bash ${MAESTRO_SKILL_DIR}/scripts/setup.sh` before continuing.
13
- *
14
- * Tokens whose value isn't supplied stay literal — the author can spot
15
- * the unresolved placeholder when reading the model's output.
16
- *
17
- * 2. Inline shell snippets — `` !`<cmd>` `` runs the command at load time
18
- * and is replaced with its stdout (capped). Off by default (matches
19
- * upstream's `skills.inline_shell: false` default) because it runs
20
- * arbitrary code at preprocessing time; opt-in via the `inlineShell`
21
- * flag for trusted skills that need dynamic state (e.g. current
22
- * git branch).
23
- *
24
- * Both are applied at `skill_view`-time, **after** the SKILL.md body has been
25
- * loaded and **before** the body is handed to the model. The model sees a
26
- * fully-resolved skill, never a raw template token.
27
- */
28
- /** Matches `${MAESTRO_SKILL_DIR}` / `${MAESTRO_SESSION_ID}`. Unknown tokens are
29
- * left intact for debugability. */
30
- const TEMPLATE_TOKEN_RE = /\$\{(MAESTRO_SKILL_DIR|MAESTRO_SESSION_ID)\}/g;
31
- /** Inline shell shape: `` !`single-line-cmd` ``. No newlines inside the
32
- * backticks (matches upstream — multi-line shell goes in a code fence). */
33
- const INLINE_SHELL_RE = /!`([^`\n]+)`/g;
34
- /** Hard cap on stdout from a single inline-shell snippet so a runaway
35
- * command can't blow out the model's context window. */
36
- const INLINE_SHELL_MAX_OUTPUT = 4000;
37
- /** Default per-snippet timeout (seconds). Upstream uses 10s. */
38
- const INLINE_SHELL_DEFAULT_TIMEOUT_S = 10;
39
- /**
40
- * Replace `${MAESTRO_SKILL_DIR}` / `${MAESTRO_SESSION_ID}` in `content`.
41
- *
42
- * Tokens for which the corresponding option value is missing are left in
43
- * place — the author can then see "oh, this skill was loaded without a
44
- * session id" instead of getting silent empty strings.
45
- */
46
- export function substituteTemplateVars(content, opts) {
47
- if (!content)
48
- return content;
49
- return content.replace(TEMPLATE_TOKEN_RE, (full, token) => {
50
- if (token === "MAESTRO_SKILL_DIR" && opts.skillDir)
51
- return opts.skillDir;
52
- if (token === "MAESTRO_SESSION_ID" && opts.sessionId)
53
- return opts.sessionId;
54
- return full;
55
- });
56
- }
57
- /**
58
- * Run one inline-shell snippet. Failures return a short `[inline-shell ...]`
59
- * marker rather than throwing so a single bad snippet can't break the whole
60
- * skill load.
61
- *
62
- * `cwd` is set to the skill directory so relative paths in the snippet
63
- * resolve where the author expected them to.
64
- */
65
- export function runInlineShell(command, cwd, timeoutS) {
66
- const cleanedTimeout = Number.isFinite(timeoutS) && timeoutS > 0 ? Math.floor(timeoutS) : 1;
67
- try {
68
- const result = spawnSync("bash", ["-c", command], {
69
- cwd: cwd ?? undefined,
70
- encoding: "utf-8",
71
- timeout: cleanedTimeout * 1000,
72
- maxBuffer: INLINE_SHELL_MAX_OUTPUT * 4,
73
- });
74
- if (result.error) {
75
- const err = result.error;
76
- if (err.code === "ETIMEDOUT") {
77
- return `[inline-shell timeout after ${cleanedTimeout}s: ${command}]`;
78
- }
79
- return `[inline-shell error: ${err.message}]`;
80
- }
81
- let output = (result.stdout ?? "").replace(/\n+$/, "");
82
- if (!output && result.stderr)
83
- output = result.stderr.replace(/\n+$/, "");
84
- if (output.length > INLINE_SHELL_MAX_OUTPUT) {
85
- output = `${output.slice(0, INLINE_SHELL_MAX_OUTPUT)}...[truncated]`;
86
- }
87
- return output;
88
- }
89
- catch (err) {
90
- return `[inline-shell error: ${err.message}]`;
91
- }
92
- }
93
- /** Expand every `` !`cmd` `` snippet in `content` with its stdout. No-op
94
- * when the content has no `!`` marker (cheap fast path). */
95
- export function expandInlineShell(content, cwd, timeoutS) {
96
- if (!content.includes("!`"))
97
- return content;
98
- return content.replace(INLINE_SHELL_RE, (_full, cmd) => {
99
- const trimmed = String(cmd).trim();
100
- if (!trimmed)
101
- return "";
102
- return runInlineShell(trimmed, cwd, timeoutS);
103
- });
104
- }
105
- /**
106
- * Single-call entry point used by `skill_view`. Applies template-var
107
- * substitution unconditionally and inline-shell only when explicitly
108
- * opted in.
109
- *
110
- * Returns the input unchanged when it's empty (defensive — upstream's
111
- * `preprocess_skill_content` returns `""` for empty inputs).
112
- */
113
- export function preprocessSkillContent(content, opts) {
114
- if (!content)
115
- return content;
116
- let out = substituteTemplateVars(content, { skillDir: opts.skillDir, sessionId: opts.sessionId });
117
- if (opts.inlineShell) {
118
- const timeout = opts.inlineShellTimeoutS ?? INLINE_SHELL_DEFAULT_TIMEOUT_S;
119
- out = expandInlineShell(out, opts.skillDir, timeout);
120
- }
121
- return out;
122
- }
123
- // Expose internal constants for tests.
124
- export const __INLINE_SHELL_MAX_OUTPUT = INLINE_SHELL_MAX_OUTPUT;
125
- export const __INLINE_SHELL_DEFAULT_TIMEOUT_S = INLINE_SHELL_DEFAULT_TIMEOUT_S;
126
- //# sourceMappingURL=preprocess.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preprocess.js","sourceRoot":"","sources":["../../src/skills/preprocess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;oCACoC;AACpC,MAAM,iBAAiB,GAAG,+CAA+C,CAAC;AAE1E;4EAC4E;AAC5E,MAAM,eAAe,GAAG,eAAe,CAAC;AAExC;yDACyD;AACzD,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC,gEAAgE;AAChE,MAAM,8BAA8B,GAAG,EAAE,CAAC;AAa1C;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAe,EACf,IAA6D;IAE7D,IAAI,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC;I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AAC,mBAAmB,IAAI,8BAA8B,CAAC;QAC3E,GAAG,GAAG,iBAAiB,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,uCAAuC;AACvC,MAAM,CAAC,MAAM,yBAAyB,GAAG,uBAAuB,CAAC;AACjE,MAAM,CAAC,MAAM,gCAAgC,GAAG,8BAA8B,CAAC"}
@@ -1,76 +0,0 @@
1
- /**
2
- * Skill usage sidecar — process-local persistent counters.
3
- *
4
- * Each skill the catalog ever surfaces accumulates three counters:
5
- *
6
- * - viewCount: bumped when `skill_view(name)` returns its body. Direct
7
- * signal that the model thought this skill was worth pulling
8
- * the full SKILL.md for.
9
- * - useCount: bumped by callers when one of the skill's recommended
10
- * commands actually ran. Optional today (no auto-detector
11
- * for "did the bash call use a skill-suggested invocation");
12
- * kept in the schema so future instrumentation can land
13
- * without a migration.
14
- * - patchCount: bumped on skill edits (future `skill_edit` builtin).
15
- *
16
- * Storage: a single JSON file at `${DATA_DIR}/agents/maestro/skills/usage.json`.
17
- * Process-local — the SDK targets single-process embedders, so a per-skill
18
- * sidecar would over-shard the disk for no gain. Atomic-write via tmp +
19
- * rename guards against the rare `writeFileSync` interrupted-write race.
20
- *
21
- * Concurrency: serialized via an in-process mutex chain (Promises). Two
22
- * `bumpView` calls during the same tick (e.g. a model that views two skills
23
- * in one assistant turn) queue cleanly instead of one clobbering the other.
24
- * Inter-process locking is intentionally NOT implemented — production has
25
- * one bun process; tests use `__resetForTests` to avoid cross-test leak.
26
- *
27
- * Read path is non-blocking (synchronous read of the at-rest JSON). Write
28
- * path is async (await the mutex, then sync-write the tmp + rename). Both
29
- * tolerate ENOENT — first-ever bump creates the file fresh.
30
- *
31
- * Schema mirrors the upstream skill-usage tracker (similar fields); the
32
- * SDK collapses upstream's per-skill `.usage.json` directory pattern into
33
- * one central JSON so the skill catalog itself stays read-only and a host
34
- * can rsync / version-control the SKILL.md tree without dragging mutated
35
- * counter files along.
36
- */
37
- export interface SkillCounters {
38
- viewCount: number;
39
- useCount: number;
40
- patchCount: number;
41
- /** ISO timestamp of the most recent bump on any counter. */
42
- lastTouchedTs: string;
43
- /** ISO timestamp of the first time this skill appeared in the file.
44
- * Used by the Curator to weight new vs long-stale skills. */
45
- firstSeenTs: string;
46
- }
47
- export interface SkillUsageFile {
48
- schemaVersion: 1;
49
- skills: Record<string, SkillCounters>;
50
- }
51
- /** Default sidecar path. Overridable via `MAESTRO_SKILL_USAGE_PATH` for tests
52
- * and operators that prefer a different on-disk location. */
53
- export declare function defaultUsagePath(): string;
54
- /**
55
- * Read the usage file synchronously. Returns an empty (in-memory) file on
56
- * ENOENT / parse failure — callers that need to disambiguate can call
57
- * `existsSync(defaultUsagePath())` themselves. Logged at debug so a missing
58
- * file is not noise on every read.
59
- */
60
- export declare function loadUsage(path?: string): SkillUsageFile;
61
- /** Get counters for a single skill. Never returns undefined — synthesizes
62
- * zeroed counters for unseen skills so callers can compute deltas without
63
- * null-checks. */
64
- export declare function getCounters(name: string, path?: string): SkillCounters;
65
- /** Bump `viewCount` for `name`. Called from `skill_view` after a successful body load. */
66
- export declare function bumpView(name: string, path?: string): Promise<SkillCounters>;
67
- /** Bump `useCount` for `name`. Reserved for future call-site instrumentation. */
68
- export declare function bumpUse(name: string, path?: string): Promise<SkillCounters>;
69
- /** Bump `patchCount` for `name`. Reserved for the future `skill_edit` builtin. */
70
- export declare function bumpPatch(name: string, path?: string): Promise<SkillCounters>;
71
- /** Test-only: drop the in-memory mutex queue + write-through cache. Disk
72
- * file is NOT erased — tests that need filesystem isolation should point
73
- * `MAESTRO_SKILL_USAGE_PATH` at a tmp file via `process.env` and remove it
74
- * themselves. */
75
- export declare function __resetForTests(): void;
76
- //# sourceMappingURL=usage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/skills/usage.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,aAAa,EAAE,MAAM,CAAC;IACtB;kEAC8D;IAC9D,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,CAAC,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;CACvC;AAID;8DAC8D;AAC9D,wBAAgB,gBAAgB,IAAI,MAAM,CAKzC;AAmCD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,GAAE,MAA2B,GAAG,cAAc,CAM3E;AA2BD;;mBAEmB;AACnB,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAA2B,GAAG,aAAa,CAG1F;AAmDD,0FAA0F;AAC1F,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAE5E;AAED,iFAAiF;AACjF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAE3E;AAED,kFAAkF;AAClF,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAE7E;AAED;;;kBAGkB;AAClB,wBAAgB,eAAe,IAAI,IAAI,CAGtC"}