@serviceme/devtools-core 2.0.0 → 2.0.2

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 (82) hide show
  1. package/dist/auth-Bzss8zOv.mjs +995 -0
  2. package/dist/auth-Bzss8zOv.mjs.map +1 -0
  3. package/dist/auth-DXam3c4S.js +1078 -0
  4. package/dist/auth-DXam3c4S.js.map +1 -0
  5. package/dist/auth.d.mts +2 -2
  6. package/dist/auth.d.ts +2 -2
  7. package/dist/auth.js +14 -1029
  8. package/dist/auth.mjs +2 -991
  9. package/dist/device-CDDcwDY6.mjs +758 -0
  10. package/dist/device-CDDcwDY6.mjs.map +1 -0
  11. package/dist/device-DuAYH8bk.js +839 -0
  12. package/dist/device-DuAYH8bk.js.map +1 -0
  13. package/dist/device.d.mts +2 -455
  14. package/dist/device.d.ts +2 -455
  15. package/dist/device.js +15 -728
  16. package/dist/device.mjs +2 -679
  17. package/dist/index-2rX86yMq.d.mts +331 -0
  18. package/dist/index-BI11AfMH.d.mts +377 -0
  19. package/dist/index-BI11AfMH.d.ts +377 -0
  20. package/dist/index-CoA6y0MP.d.mts +498 -0
  21. package/dist/index-CoA6y0MP.d.ts +498 -0
  22. package/dist/index-DaW7IYA-.d.mts +185 -0
  23. package/dist/index-DaW7IYA-.d.ts +185 -0
  24. package/dist/index-Dp6FwWKh.d.ts +331 -0
  25. package/dist/index.d.mts +2340 -2101
  26. package/dist/index.d.ts +2340 -2101
  27. package/dist/index.js +8117 -10538
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +7895 -10318
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/rolldown-runtime-VH7oDXx4.js +28 -0
  32. package/dist/skill-linker.d.mts +82 -81
  33. package/dist/skill-linker.d.ts +82 -81
  34. package/dist/skill-linker.js +359 -402
  35. package/dist/skill-linker.js.map +1 -1
  36. package/dist/skill-linker.mjs +345 -357
  37. package/dist/skill-linker.mjs.map +1 -1
  38. package/dist/skill-store-Bym2yinU.mjs +388 -0
  39. package/dist/skill-store-Bym2yinU.mjs.map +1 -0
  40. package/dist/skill-store-CJdYyyxu.js +408 -0
  41. package/dist/skill-store-CJdYyyxu.js.map +1 -0
  42. package/dist/skill-store.d.mts +41 -42
  43. package/dist/skill-store.d.ts +41 -42
  44. package/dist/skill-store.js +5 -338
  45. package/dist/skill-store.mjs +2 -301
  46. package/dist/submit-Cg7wSa3x.mjs +84 -0
  47. package/dist/submit-Cg7wSa3x.mjs.map +1 -0
  48. package/dist/submit-CltE6YOZ.js +98 -0
  49. package/dist/submit-CltE6YOZ.js.map +1 -0
  50. package/dist/submit.d.mts +2 -3
  51. package/dist/submit.d.ts +2 -3
  52. package/dist/submit.js +4 -166
  53. package/dist/submit.mjs +2 -130
  54. package/dist/toolbox-CbfxpNg-.mjs +540 -0
  55. package/dist/toolbox-CbfxpNg-.mjs.map +1 -0
  56. package/dist/toolbox-CxnOr-FY.js +614 -0
  57. package/dist/toolbox-CxnOr-FY.js.map +1 -0
  58. package/dist/toolbox.d.mts +2 -244
  59. package/dist/toolbox.d.ts +2 -244
  60. package/dist/toolbox.js +14 -584
  61. package/dist/toolbox.mjs +2 -536
  62. package/dist/{types-B9gk3dXH.d.ts → types-BCV3IedE.d.mts} +25 -23
  63. package/dist/{types-B9gk3dXH.d.mts → types-BCV3IedE.d.ts} +25 -23
  64. package/dist/userHome-BquDeFVE.js +526 -0
  65. package/dist/userHome-BquDeFVE.js.map +1 -0
  66. package/dist/userHome-CcnAQPG1.mjs +212 -0
  67. package/dist/userHome-CcnAQPG1.mjs.map +1 -0
  68. package/package.json +10 -10
  69. package/dist/auth.js.map +0 -1
  70. package/dist/auth.mjs.map +0 -1
  71. package/dist/device.js.map +0 -1
  72. package/dist/device.mjs.map +0 -1
  73. package/dist/index-BMk4tqIT.d.mts +0 -328
  74. package/dist/index-CymN0x9Z.d.ts +0 -328
  75. package/dist/index-PD135hlB.d.mts +0 -626
  76. package/dist/index-PD135hlB.d.ts +0 -626
  77. package/dist/skill-store.js.map +0 -1
  78. package/dist/skill-store.mjs.map +0 -1
  79. package/dist/submit.js.map +0 -1
  80. package/dist/submit.mjs.map +0 -1
  81. package/dist/toolbox.js.map +0 -1
  82. package/dist/toolbox.mjs.map +0 -1
@@ -0,0 +1,408 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-VH7oDXx4.js");
2
+ let node_fs_promises = require("node:fs/promises");
3
+ node_fs_promises = require_rolldown_runtime.__toESM(node_fs_promises);
4
+ let node_path = require("node:path");
5
+ node_path = require_rolldown_runtime.__toESM(node_path);
6
+ //#region src/repo-layout/index.ts
7
+ /**
8
+ * Spec §12 — Repo layout descriptor.
9
+ *
10
+ * Some third-party repos (awesome-copilot, composio) use a
11
+ * non-default layout that mixes prompts / instructions / agents /
12
+ * hooks / plugins at the root. The default SkillStore scan
13
+ * (see ../skill-store/index.ts) only picks up directories that
14
+ * contain a `SKILL.md` or `AGENT.md` manifest, so prompts stored
15
+ * as `<subdir>/<name>.md` (no manifest) get missed.
16
+ *
17
+ * This module is the loader for the optional `.serviceme-repo.json`
18
+ * marker file a repo author can drop in at the repo root to opt
19
+ * into a wider scan. The schema:
20
+ *
21
+ * {
22
+ * "schema": 1,
23
+ * "include": ["prompts", "instructions"], // subdirs to treat as "skill dirs"
24
+ * "exclude": ["hooks", "plugins"], // subdirs to skip
25
+ * "treatFilesAsSkills": true // inside an included subdir, each .md file is a skill
26
+ * }
27
+ *
28
+ * All four fields are optional. The defaults match the v0.2
29
+ * walkForEntries behaviour (manifest-based, no marker, no
30
+ * extensions), so adding the file is purely additive.
31
+ *
32
+ * @see docs/architecture/skill-agent-v2-repo.md §12
33
+ */
34
+ const MARKER_FILENAME = ".serviceme-repo.json";
35
+ const SUPPORTED_SCHEMA = 1;
36
+ /**
37
+ * Default descriptor used when no `.serviceme-repo.json` is
38
+ * present. The shape is the same as what an empty marker would
39
+ * produce, so callers don't have to special-case the "no marker"
40
+ * branch.
41
+ */
42
+ const DEFAULT_REPO_LAYOUT = {
43
+ schema: SUPPORTED_SCHEMA,
44
+ include: [],
45
+ exclude: [],
46
+ treatFilesAsSkills: false
47
+ };
48
+ /**
49
+ * Try to load a `.serviceme-repo.json` from the given repo root.
50
+ * Returns `DEFAULT_REPO_LAYOUT` (not undefined) when the file is
51
+ * absent — callers branch on `include.length` / `treatFilesAsSkills`
52
+ * to decide whether to widen the scan.
53
+ *
54
+ * Malformed markers (bad JSON, wrong schema) are surfaced as
55
+ * `null` so callers can warn the user instead of silently
56
+ * treating them as the default.
57
+ */
58
+ async function loadRepoLayout(repoRoot) {
59
+ const markerPath = node_path.join(repoRoot, MARKER_FILENAME);
60
+ let raw;
61
+ try {
62
+ raw = await node_fs_promises.readFile(markerPath, "utf8");
63
+ } catch {
64
+ return DEFAULT_REPO_LAYOUT;
65
+ }
66
+ let parsed;
67
+ try {
68
+ parsed = JSON.parse(raw);
69
+ } catch {
70
+ return null;
71
+ }
72
+ if (!parsed || typeof parsed !== "object") return null;
73
+ const obj = parsed;
74
+ if (obj.schema !== SUPPORTED_SCHEMA) return null;
75
+ if (!Array.isArray(obj.include) || obj.include.some((s) => typeof s !== "string")) return null;
76
+ if (!Array.isArray(obj.exclude) || obj.exclude.some((s) => typeof s !== "string")) return null;
77
+ if (typeof obj.treatFilesAsSkills !== "boolean") return null;
78
+ return {
79
+ schema: SUPPORTED_SCHEMA,
80
+ include: obj.include,
81
+ exclude: obj.exclude,
82
+ treatFilesAsSkills: obj.treatFilesAsSkills
83
+ };
84
+ }
85
+ //#endregion
86
+ //#region src/skill-store/types.ts
87
+ /** Sentinel error for store lookups that miss. */
88
+ var SkillNotFoundError = class extends Error {
89
+ constructor(repoId, skillName) {
90
+ super(`skill/agent not found: ${repoId}/${skillName}`);
91
+ this.repoId = repoId;
92
+ this.skillName = skillName;
93
+ this.name = "SkillNotFoundError";
94
+ }
95
+ };
96
+ //#endregion
97
+ //#region src/skill-store/index.ts
98
+ /**
99
+ * Minimal frontmatter reader — same shape as the extension's
100
+ * `WorkspaceSkillsInitializationService.extractFrontmatter`. We avoid
101
+ * pulling a YAML dep into core; SKILL.md / AGENT.md in the wild use
102
+ * a strict subset (top-level `key: value` pairs delimited by `---`).
103
+ * Multi-line block scalars (`>`, `|-`, `|`) are folded into a single
104
+ * string value — the very common `description: >` form would
105
+ * otherwise surface the bare `>` indicator as the whole description.
106
+ */
107
+ function extractFrontmatter(raw) {
108
+ if (typeof raw !== "string") return null;
109
+ const match = raw.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
110
+ if (!match) return null;
111
+ const yamlBody = match[1] ?? "";
112
+ const body = match[2] ?? "";
113
+ const data = {};
114
+ const lines = yamlBody.split(/\r?\n/);
115
+ for (let i = 0; i < lines.length; i++) {
116
+ const line = lines[i] ?? "";
117
+ if (line.trim().length === 0) continue;
118
+ if (line.trim().startsWith("#")) continue;
119
+ const kv = line.match(/^([a-zA-Z_][\w-]*)\s*:\s*(.*)$/);
120
+ if (!kv?.[1]) continue;
121
+ let value = (kv[2] ?? "").trim();
122
+ if (typeof value === "string" && /^[>|][+-]?$/.test(value)) {
123
+ const folded = [];
124
+ let j = i + 1;
125
+ for (; j < lines.length; j++) {
126
+ const next = lines[j] ?? "";
127
+ if (next.trim().length === 0) {
128
+ const after = lines[j + 1];
129
+ if (after !== void 0 && /^[ \t]/.test(after)) {
130
+ folded.push("");
131
+ continue;
132
+ }
133
+ break;
134
+ }
135
+ if (!/^[ \t]/.test(next)) break;
136
+ folded.push(next.trim());
137
+ }
138
+ i = j - 1;
139
+ value = folded.join(" ").replace(/\s+/g, " ").trim();
140
+ data[kv[1]] = value;
141
+ continue;
142
+ }
143
+ if (typeof value === "string") {
144
+ if (value.startsWith("\"") && value.endsWith("\"") || value.startsWith("'") && value.endsWith("'")) value = value.slice(1, -1);
145
+ }
146
+ data[kv[1]] = value;
147
+ }
148
+ return {
149
+ data,
150
+ body
151
+ };
152
+ }
153
+ var SkillStore = class {
154
+ constructor(opts) {
155
+ this.entriesMemo = /* @__PURE__ */ new Map();
156
+ this.repoRoots = /* @__PURE__ */ new Map();
157
+ for (const r of opts.repos) this.repoRoots.set(r.id, r.rootPath);
158
+ }
159
+ /** All skills + agents across all registered repos. Repos are walked
160
+ * concurrently — one slow checkout no longer stretches the total. */
161
+ async listAll() {
162
+ return (await Promise.all([...this.repoRoots.keys()].map((repoId) => this.listByRepo(repoId)))).flat();
163
+ }
164
+ /** All skills + agents under a single repo. */
165
+ async listByRepo(repoId) {
166
+ return [...await this.listByRepoCached(repoId)];
167
+ }
168
+ /** Single entry detail (manifest + all files inside its dir). */
169
+ async get(repoId, name) {
170
+ const found = (await this.listByRepoCached(repoId)).find((e) => e.name === name);
171
+ if (!found) throw new SkillNotFoundError(repoId, name);
172
+ const files = await collectEntryFiles(found);
173
+ return {
174
+ ...found,
175
+ files
176
+ };
177
+ }
178
+ /** All files inside a single entry's directory (manifest + extras). */
179
+ async getFiles(repoId, name) {
180
+ const found = (await this.listByRepoCached(repoId)).find((e) => e.name === name);
181
+ if (!found) throw new SkillNotFoundError(repoId, name);
182
+ return collectEntryFiles(found);
183
+ }
184
+ /**
185
+ * Memoized walk. Sharing the promise collapses concurrent list/get
186
+ * calls over the same repo into a single traversal; a rejected walk
187
+ * is dropped so the next call retries from disk.
188
+ */
189
+ listByRepoCached(repoId) {
190
+ const memoized = this.entriesMemo.get(repoId);
191
+ if (memoized) return memoized;
192
+ const walk = this.walkRepo(repoId).catch((error) => {
193
+ this.entriesMemo.delete(repoId);
194
+ throw error;
195
+ });
196
+ this.entriesMemo.set(repoId, walk);
197
+ return walk;
198
+ }
199
+ async walkRepo(repoId) {
200
+ const root = this.repoRoots.get(repoId);
201
+ if (!root) return [];
202
+ const layout = await loadRepoLayout(root) ?? DEFAULT_REPO_LAYOUT;
203
+ const entries = [];
204
+ await walkForEntries(root, repoId, entries, layout);
205
+ return entries;
206
+ }
207
+ };
208
+ /** All files inside a single entry (manifest first, then alphabetical). */
209
+ async function collectEntryFiles(found) {
210
+ const out = [];
211
+ if (found.dir === found.manifestPath) {
212
+ const content = await node_fs_promises.readFile(found.manifestPath, "utf8");
213
+ return [{
214
+ path: node_path.basename(found.manifestPath),
215
+ content
216
+ }];
217
+ }
218
+ await collectFilesRecursive(found.dir, found.dir, out);
219
+ out.sort((a, b) => {
220
+ const aIsManifest = a.path === "SKILL.md" || a.path === "AGENT.md";
221
+ const bIsManifest = b.path === "SKILL.md" || b.path === "AGENT.md";
222
+ if (aIsManifest && !bIsManifest) return -1;
223
+ if (bIsManifest && !aIsManifest) return 1;
224
+ return a.path.localeCompare(b.path);
225
+ });
226
+ return out;
227
+ }
228
+ const SKIP_DIRS = /* @__PURE__ */ new Set([
229
+ ".git",
230
+ "node_modules",
231
+ ".vscode",
232
+ "dist",
233
+ "build",
234
+ "out"
235
+ ]);
236
+ /**
237
+ * Directories that are never treated as candidate skill/agent parents
238
+ * during the top-level catalog walk. `plugins/` is a distinct concept
239
+ * from the skill/agent catalog itself — a plugin bundle
240
+ * (`plugins/<scope>/<plugin-name>/{skills,agents}/...`) re-packages
241
+ * ALREADY-cataloged official skills/agents (see the plugin's own
242
+ * `catalog.json`, which lists them by name) purely for discovery
243
+ * grouping. Walking into it produces duplicate `SkillEntry` values
244
+ * with the SAME `repoId`+`name` as their real, top-level counterpart
245
+ * (e.g. `skills/official/acreadiness-assess` AND
246
+ * `plugins/official/acreadiness-cockpit/skills/acreadiness-assess`),
247
+ * which breaks anything keyed on `repoId/name` (React list rendering,
248
+ * the "installed" lookup, `SkillStore.get()`'s `.find()`).
249
+ *
250
+ * Scoped separately from `SKIP_DIRS` (used by both this walk AND
251
+ * `collectFilesRecursive`) so an actual skill that happens to ship its
252
+ * own `plugins/` asset folder still has that folder listed in its own
253
+ * file detail view.
254
+ */
255
+ const SKIP_TOP_LEVEL_SCAN_DIRS = /* @__PURE__ */ new Set([...SKIP_DIRS, "plugins"]);
256
+ /** Suffix that marks a standalone file as a flat agent manifest (no wrapping dir). */
257
+ const FLAT_AGENT_FILE_SUFFIX = ".agent.md";
258
+ /**
259
+ * Recursive walk that yields SkillEntry values for any directory
260
+ * containing a SKILL.md or AGENT.md file, PLUS any standalone
261
+ * `<name>.agent.md` file (see class doc, layout style 4). The dir
262
+ * itself is the "entry root" for directory-based entries; the
263
+ * manifest file itself is the "entry root" for flat agent files.
264
+ *
265
+ * The optional `layout` descriptor (from `.serviceme-repo.json`)
266
+ * widens the scan: included subdirs are walked even without a
267
+ * manifest at the top level, and `treatFilesAsSkills` surfaces
268
+ * `<name>.md` files inside them as skills (frontmatter parsed
269
+ * from the file body).
270
+ */
271
+ async function walkForEntries(rootDir, repoId, out, layout = DEFAULT_REPO_LAYOUT) {
272
+ let dirents;
273
+ try {
274
+ dirents = await node_fs_promises.readdir(rootDir, { withFileTypes: true });
275
+ } catch {
276
+ return;
277
+ }
278
+ for (const d of dirents) {
279
+ if (d.isFile() && d.name.endsWith(FLAT_AGENT_FILE_SUFFIX)) {
280
+ const filePath = node_path.join(rootDir, d.name);
281
+ const stat = await node_fs_promises.stat(filePath);
282
+ const parsed = extractFrontmatter(await node_fs_promises.readFile(filePath, "utf8"));
283
+ out.push({
284
+ repoId,
285
+ name: d.name.slice(0, -9),
286
+ kind: "agent",
287
+ manifestPath: filePath,
288
+ dir: filePath,
289
+ frontmatter: parsed?.data ?? {},
290
+ modifiedAt: stat.mtime.toISOString()
291
+ });
292
+ continue;
293
+ }
294
+ if (!d.isDirectory()) continue;
295
+ if (SKIP_TOP_LEVEL_SCAN_DIRS.has(d.name)) continue;
296
+ if (layout.exclude.includes(d.name)) continue;
297
+ const childDir = node_path.join(rootDir, d.name);
298
+ const kind = await detectKind(childDir);
299
+ if (kind) {
300
+ const manifestFilename = kind === "skill" ? "SKILL.md" : "AGENT.md";
301
+ const manifestPath = node_path.join(childDir, manifestFilename);
302
+ const stat = await node_fs_promises.stat(manifestPath);
303
+ const parsed = extractFrontmatter(await node_fs_promises.readFile(manifestPath, "utf8"));
304
+ out.push({
305
+ repoId,
306
+ name: d.name,
307
+ kind,
308
+ manifestPath,
309
+ dir: childDir,
310
+ frontmatter: parsed?.data ?? {},
311
+ modifiedAt: stat.mtime.toISOString()
312
+ });
313
+ continue;
314
+ }
315
+ await walkForEntries(childDir, repoId, out, layout);
316
+ if (layout.treatFilesAsSkills && layout.include.includes(d.name)) await surfaceFilesAsSkills(childDir, d.name, repoId, out);
317
+ }
318
+ }
319
+ /**
320
+ * Walk `<includedSubdir>/<file>.md` and register each as a skill.
321
+ * The `.md` file itself is the manifest — frontmatter (if any) is
322
+ * parsed and surfaced. This is the awesome-copilot style: a
323
+ * `prompts/` dir full of `<name>.md` files, no SKILL.md anywhere.
324
+ */
325
+ async function surfaceFilesAsSkills(absDir, relName, repoId, out) {
326
+ let dirents;
327
+ try {
328
+ dirents = await node_fs_promises.readdir(absDir, { withFileTypes: true });
329
+ } catch {
330
+ return;
331
+ }
332
+ for (const d of dirents) {
333
+ if (!d.isFile()) continue;
334
+ if (!d.name.endsWith(".md")) continue;
335
+ const filePath = node_path.join(absDir, d.name);
336
+ const stat = await node_fs_promises.stat(filePath);
337
+ const parsed = extractFrontmatter(await node_fs_promises.readFile(filePath, "utf8"));
338
+ const entryName = `${relName}/${d.name.replace(/\.md$/, "")}`;
339
+ out.push({
340
+ repoId,
341
+ name: entryName,
342
+ kind: "skill",
343
+ manifestPath: filePath,
344
+ dir: absDir,
345
+ frontmatter: parsed?.data ?? {},
346
+ modifiedAt: stat.mtime.toISOString()
347
+ });
348
+ }
349
+ }
350
+ /**
351
+ * Returns the SkillKind of a directory if it contains a manifest file,
352
+ * or `null` if it doesn't. Manifest precedence: SKILL.md wins if both
353
+ * are present (defensive — the spec separates skills and agents into
354
+ * different subdir trees, so this collision shouldn't happen in
355
+ * well-formed repos).
356
+ */
357
+ async function detectKind(dir) {
358
+ const [hasSkill, hasAgent] = await Promise.all([node_fs_promises.access(node_path.join(dir, "SKILL.md")).then(() => true).catch(() => false), node_fs_promises.access(node_path.join(dir, "AGENT.md")).then(() => true).catch(() => false)]);
359
+ if (hasSkill) return "skill";
360
+ if (hasAgent) return "agent";
361
+ return null;
362
+ }
363
+ /**
364
+ * Walk a skill/agent directory recursively, pushing every file into
365
+ * `out` with its path RELATIVE to the entry root. Skips `.git/`,
366
+ * `node_modules/`, and the SKIP_DIRS set.
367
+ */
368
+ async function collectFilesRecursive(absDir, entryRoot, out) {
369
+ let dirents;
370
+ try {
371
+ dirents = await node_fs_promises.readdir(absDir, { withFileTypes: true });
372
+ } catch {
373
+ return;
374
+ }
375
+ for (const d of dirents) {
376
+ if (SKIP_DIRS.has(d.name)) continue;
377
+ const full = node_path.join(absDir, d.name);
378
+ if (d.isDirectory()) await collectFilesRecursive(full, entryRoot, out);
379
+ else if (d.isFile()) {
380
+ const content = await node_fs_promises.readFile(full, "utf8");
381
+ out.push({
382
+ path: node_path.relative(entryRoot, full),
383
+ content
384
+ });
385
+ }
386
+ }
387
+ }
388
+ //#endregion
389
+ Object.defineProperty(exports, "SkillNotFoundError", {
390
+ enumerable: true,
391
+ get: function() {
392
+ return SkillNotFoundError;
393
+ }
394
+ });
395
+ Object.defineProperty(exports, "SkillStore", {
396
+ enumerable: true,
397
+ get: function() {
398
+ return SkillStore;
399
+ }
400
+ });
401
+ Object.defineProperty(exports, "extractFrontmatter", {
402
+ enumerable: true,
403
+ get: function() {
404
+ return extractFrontmatter;
405
+ }
406
+ });
407
+
408
+ //# sourceMappingURL=skill-store-CJdYyyxu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skill-store-CJdYyyxu.js","names":["path","fs","fs","path"],"sources":["../src/repo-layout/index.ts","../src/skill-store/types.ts","../src/skill-store/index.ts"],"sourcesContent":["/**\n * Spec §12 — Repo layout descriptor.\n *\n * Some third-party repos (awesome-copilot, composio) use a\n * non-default layout that mixes prompts / instructions / agents /\n * hooks / plugins at the root. The default SkillStore scan\n * (see ../skill-store/index.ts) only picks up directories that\n * contain a `SKILL.md` or `AGENT.md` manifest, so prompts stored\n * as `<subdir>/<name>.md` (no manifest) get missed.\n *\n * This module is the loader for the optional `.serviceme-repo.json`\n * marker file a repo author can drop in at the repo root to opt\n * into a wider scan. The schema:\n *\n * {\n * \"schema\": 1,\n * \"include\": [\"prompts\", \"instructions\"], // subdirs to treat as \"skill dirs\"\n * \"exclude\": [\"hooks\", \"plugins\"], // subdirs to skip\n * \"treatFilesAsSkills\": true // inside an included subdir, each .md file is a skill\n * }\n *\n * All four fields are optional. The defaults match the v0.2\n * walkForEntries behaviour (manifest-based, no marker, no\n * extensions), so adding the file is purely additive.\n *\n * @see docs/architecture/skill-agent-v2-repo.md §12\n */\n\nimport * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nconst MARKER_FILENAME = \".serviceme-repo.json\";\nconst SUPPORTED_SCHEMA = 1;\n\nexport interface RepoLayoutDescriptor {\n\t/** Schema version. Currently always 1. */\n\tschema: number;\n\t/** Subdirs (relative to repo root) to walk for entries. */\n\tinclude: string[];\n\t/** Subdirs (relative to repo root) to skip, even if a parent is included. */\n\texclude: string[];\n\t/**\n\t * When true, an included subdir's `<name>.md` files are\n\t * surfaced as skills (frontmatter is parsed from each file as\n\t * a stand-in for SKILL.md). When false (default), the\n\t * include list only widens the recursion — the manifest rule\n\t * still applies.\n\t */\n\ttreatFilesAsSkills: boolean;\n}\n\n/**\n * Default descriptor used when no `.serviceme-repo.json` is\n * present. The shape is the same as what an empty marker would\n * produce, so callers don't have to special-case the \"no marker\"\n * branch.\n */\nexport const DEFAULT_REPO_LAYOUT: RepoLayoutDescriptor = {\n\tschema: SUPPORTED_SCHEMA,\n\tinclude: [],\n\texclude: [],\n\ttreatFilesAsSkills: false,\n};\n\n/**\n * Try to load a `.serviceme-repo.json` from the given repo root.\n * Returns `DEFAULT_REPO_LAYOUT` (not undefined) when the file is\n * absent — callers branch on `include.length` / `treatFilesAsSkills`\n * to decide whether to widen the scan.\n *\n * Malformed markers (bad JSON, wrong schema) are surfaced as\n * `null` so callers can warn the user instead of silently\n * treating them as the default.\n */\nexport async function loadRepoLayout(repoRoot: string): Promise<RepoLayoutDescriptor | null> {\n\tconst markerPath = path.join(repoRoot, MARKER_FILENAME);\n\tlet raw: string;\n\ttry {\n\t\traw = await fs.readFile(markerPath, \"utf8\");\n\t} catch {\n\t\treturn DEFAULT_REPO_LAYOUT;\n\t}\n\n\tlet parsed: unknown;\n\ttry {\n\t\tparsed = JSON.parse(raw);\n\t} catch {\n\t\treturn null;\n\t}\n\tif (!parsed || typeof parsed !== \"object\") return null;\n\tconst obj = parsed as Record<string, unknown>;\n\n\tif (obj.schema !== SUPPORTED_SCHEMA) return null;\n\tif (!Array.isArray(obj.include) || obj.include.some((s) => typeof s !== \"string\")) {\n\t\treturn null;\n\t}\n\tif (!Array.isArray(obj.exclude) || obj.exclude.some((s) => typeof s !== \"string\")) {\n\t\treturn null;\n\t}\n\tif (typeof obj.treatFilesAsSkills !== \"boolean\") return null;\n\n\treturn {\n\t\tschema: SUPPORTED_SCHEMA,\n\t\tinclude: obj.include as string[],\n\t\texclude: obj.exclude as string[],\n\t\ttreatFilesAsSkills: obj.treatFilesAsSkills,\n\t};\n}\n\n/** Subdir name → entry kind override (rarely needed; default = manifest-driven). */\nexport type KindOverride = Map<string, \"skill\" | \"agent\">;\n","/**\n * Skill & Agent v2 — SkillStore Types\n *\n * SkillStore scans the local `~/.serviceme/repos/<id>/` tree to produce\n * a unified list of skills + agents. The store is the single source of\n * truth for \"what's available right now\" — the UI reads it; SubmitClient\n * reads it; install flows read it.\n *\n * Three repo layouts are supported in v1 (per spec §12):\n * 1. **Default** (`medalsoftchina-ms-skills`): `skills/<name>/SKILL.md`\n * + `agents/<name>/AGENT.md`.\n * 2. **Anthropic-style flat** (`anthropics/skills`): each subdir of\n * the repo root IS a skill — `<name>/SKILL.md` (no `skills/`\n * intermediate).\n * 3. **awesome-copilot style** (`github/awesome-copilot`): mixed\n * prompts/instructions/agents at the root.\n *\n * Normalization rule (spec §12): for every directory under the repo\n * root, peek for a `SKILL.md` or `AGENT.md` file. If present, register\n * it as a skill or agent respectively. This is more permissive than\n * guessing from the directory name and works for all three styles.\n *\n * The store is local-only and pure — no git, no network. Tests\n * construct a fixture repo tree and pass the root in directly.\n */\n\n/** What's available at this entry: a skill or an agent. */\nexport type SkillKind = \"skill\" | \"agent\";\n\n/** Top-level summary of a discovered skill/agent entry. */\nexport interface SkillEntry {\n\t/** Repository the entry was found in. */\n\trepoId: string;\n\t/** Skill or agent name (the directory name under the repo). */\n\tname: string;\n\tkind: SkillKind;\n\t/** Absolute path to the SKILL.md / AGENT.md file. */\n\tmanifestPath: string;\n\t/** Absolute path to the directory containing the entry's files. */\n\tdir: string;\n\t/** Parsed frontmatter (best-effort; raw key/value map). */\n\tfrontmatter: Record<string, unknown>;\n\t/** ISO timestamp of the manifest file's mtime. */\n\tmodifiedAt: string;\n}\n\n/** Full detail of an entry: summary + all the files inside the dir. */\nexport interface SkillDetail extends SkillEntry {\n\tfiles: SkillFile[];\n}\n\n/** A single file inside a skill / agent directory. */\nexport interface SkillFile {\n\t/** Path relative to the entry's directory. */\n\tpath: string;\n\t/** UTF-8 content. */\n\tcontent: string;\n}\n\n/** Sentinel error for store lookups that miss. */\nexport class SkillNotFoundError extends Error {\n\tconstructor(\n\t\tpublic readonly repoId: string,\n\t\tpublic readonly skillName: string\n\t) {\n\t\tsuper(`skill/agent not found: ${repoId}/${skillName}`);\n\t\tthis.name = \"SkillNotFoundError\";\n\t}\n}\n","import * as fs from \"node:fs/promises\";\nimport * as path from \"node:path\";\nimport { DEFAULT_REPO_LAYOUT, loadRepoLayout, type RepoLayoutDescriptor } from \"../repo-layout\";\nimport type { SkillDetail, SkillEntry, SkillFile, SkillKind } from \"./types\";\nimport { SkillNotFoundError } from \"./types\";\n\n/**\n * Minimal frontmatter reader — same shape as the extension's\n * `WorkspaceSkillsInitializationService.extractFrontmatter`. We avoid\n * pulling a YAML dep into core; SKILL.md / AGENT.md in the wild use\n * a strict subset (top-level `key: value` pairs delimited by `---`).\n * Multi-line block scalars (`>`, `|-`, `|`) are folded into a single\n * string value — the very common `description: >` form would\n * otherwise surface the bare `>` indicator as the whole description.\n */\nexport function extractFrontmatter(\n\traw: string\n): { data: Record<string, unknown>; body: string } | null {\n\tif (typeof raw !== \"string\") return null;\n\tconst match = raw.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?([\\s\\S]*)$/);\n\tif (!match) return null;\n\tconst yamlBody = match[1] ?? \"\";\n\tconst body = match[2] ?? \"\";\n\tconst data: Record<string, unknown> = {};\n\tconst lines = yamlBody.split(/\\r?\\n/);\n\tfor (let i = 0; i < lines.length; i++) {\n\t\tconst line = lines[i] ?? \"\";\n\t\tif (line.trim().length === 0) continue;\n\t\tif (line.trim().startsWith(\"#\")) continue;\n\t\tconst kv = line.match(/^([a-zA-Z_][\\w-]*)\\s*:\\s*(.*)$/);\n\t\tif (!kv?.[1]) continue;\n\t\tlet value: unknown = (kv[2] ?? \"\").trim();\n\t\t// Block scalar indicators: fold the following more-indented\n\t\t// lines into one value (blank separators become newlines for\n\t\t// `|`, spaces for `>`; we keep it simple and always fold with\n\t\t// spaces, which is right for descriptions).\n\t\tif (typeof value === \"string\" && /^[>|][+-]?$/.test(value)) {\n\t\t\tconst folded: string[] = [];\n\t\t\tlet j = i + 1;\n\t\t\tfor (; j < lines.length; j++) {\n\t\t\t\tconst next = lines[j] ?? \"\";\n\t\t\t\tif (next.trim().length === 0) {\n\t\t\t\t\t// A blank line only belongs to the scalar if a later\n\t\t\t\t\t// more-indented line follows; otherwise it ends it.\n\t\t\t\t\tconst after = lines[j + 1];\n\t\t\t\t\tif (after !== undefined && /^[ \\t]/.test(after)) {\n\t\t\t\t\t\tfolded.push(\"\");\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (!/^[ \\t]/.test(next)) break; // dedent ends the scalar\n\t\t\t\tfolded.push(next.trim());\n\t\t\t}\n\t\t\ti = j - 1;\n\t\t\t// Collapse whitespace runs so blank separators don't leave\n\t\t\t// double spaces (display text, not YAML fidelity).\n\t\t\tvalue = folded.join(\" \").replace(/\\s+/g, \" \").trim();\n\t\t\tdata[kv[1]] = value;\n\t\t\tcontinue;\n\t\t}\n\t\tif (typeof value === \"string\") {\n\t\t\tif (\n\t\t\t\t(value.startsWith('\"') && value.endsWith('\"')) ||\n\t\t\t\t(value.startsWith(\"'\") && value.endsWith(\"'\"))\n\t\t\t) {\n\t\t\t\tvalue = value.slice(1, -1);\n\t\t\t}\n\t\t}\n\t\tdata[kv[1]] = value;\n\t}\n\treturn { data, body };\n}\n\nexport type { SkillDetail, SkillEntry, SkillFile, SkillKind } from \"./types\";\n/**\n * Skill & Agent v2 — SkillStore (M4)\n *\n * Scans the local `~/.serviceme/repos/<id>/` tree to produce a unified\n * list of skills + agents. Local-only — no git, no network. Spec §5.5.\n *\n * Layout normalization (spec §12):\n * 1. **Standard layout** — `skills/<name>/SKILL.md` or\n * `agents/<name>/AGENT.md` under the repo root.\n * 2. **Anthropic flat layout** — `<name>/SKILL.md` directly under\n * the repo root (the `skills/` prefix is omitted).\n * 3. **awesome-copilot style** — root contains README + subdirs\n * that are skills/agents/instructions; we ignore README and\n * any dir without a manifest file.\n * 4. **Flat agent files** — a directory (commonly `agents/` or\n * `agents/official/`) full of `<name>.agent.md` files, one per\n * agent, with NO per-agent subdirectory. This is the prevailing\n * real-world convention (VS Code custom chat agents, GitHub's\n * awesome-copilot, and our own official ms-skills repo all ship\n * agents this way) — unlike skills, agents in the wild are\n * essentially never a `<name>/AGENT.md` directory pair. Detected\n * unconditionally, no `.serviceme-repo.json` opt-in required.\n *\n * Implementation: walk every directory under the repo root, check for\n * SKILL.md or AGENT.md, register if present. We skip the repo root\n * itself (no manifest lives at the top), `.git/`, and `node_modules/`.\n * Flat `*.agent.md` files are checked alongside directories at every\n * level of the walk.\n */\n// Re-export the error class + shared types so callers can\n// `import { SkillNotFoundError, SkillFile } from \"...\"`.\nexport { SkillNotFoundError } from \"./types\";\n\nexport class SkillStore {\n\tprivate readonly repoRoots: Map<string, string>;\n\t/**\n\t * Per-instance memo of repo walks. The catalog walk is a recursive\n\t * readdir over the whole checkout — the dominant cost of every\n\t * list/get — so results (and the in-flight promise) are reused for\n\t * the store's lifetime. The handler that owns long-lived stores\n\t * bounds staleness by rebuilding the store on a short TTL; within\n\t * one store instance the tree is treated as immutable.\n\t */\n\tprivate readonly entriesMemo = new Map<string, Promise<SkillEntry[]>>();\n\n\tconstructor(opts: {\n\t\trepos: ReadonlyArray<{ id: string; rootPath: string }>;\n\t}) {\n\t\tthis.repoRoots = new Map();\n\t\tfor (const r of opts.repos) this.repoRoots.set(r.id, r.rootPath);\n\t}\n\n\t/** All skills + agents across all registered repos. Repos are walked\n\t * concurrently — one slow checkout no longer stretches the total. */\n\tasync listAll(): Promise<SkillEntry[]> {\n\t\tconst perRepo = await Promise.all(\n\t\t\t[...this.repoRoots.keys()].map((repoId) => this.listByRepo(repoId))\n\t\t);\n\t\treturn perRepo.flat();\n\t}\n\n\t/** All skills + agents under a single repo. */\n\tasync listByRepo(repoId: string): Promise<SkillEntry[]> {\n\t\tconst entries = await this.listByRepoCached(repoId);\n\t\t// Copy so memoized state can't be corrupted by caller mutations.\n\t\treturn [...entries];\n\t}\n\n\t/** Single entry detail (manifest + all files inside its dir). */\n\tasync get(repoId: string, name: string): Promise<SkillDetail> {\n\t\tconst entries = await this.listByRepoCached(repoId);\n\t\tconst found = entries.find((e) => e.name === name);\n\t\tif (!found) throw new SkillNotFoundError(repoId, name);\n\t\tconst files = await collectEntryFiles(found);\n\t\treturn { ...found, files };\n\t}\n\n\t/** All files inside a single entry's directory (manifest + extras). */\n\tasync getFiles(repoId: string, name: string): Promise<SkillFile[]> {\n\t\tconst entries = await this.listByRepoCached(repoId);\n\t\tconst found = entries.find((e) => e.name === name);\n\t\tif (!found) throw new SkillNotFoundError(repoId, name);\n\t\treturn collectEntryFiles(found);\n\t}\n\n\t/**\n\t * Memoized walk. Sharing the promise collapses concurrent list/get\n\t * calls over the same repo into a single traversal; a rejected walk\n\t * is dropped so the next call retries from disk.\n\t */\n\tprivate listByRepoCached(repoId: string): Promise<SkillEntry[]> {\n\t\tconst memoized = this.entriesMemo.get(repoId);\n\t\tif (memoized) return memoized;\n\t\tconst walk = this.walkRepo(repoId).catch((error: unknown) => {\n\t\t\tthis.entriesMemo.delete(repoId);\n\t\t\tthrow error;\n\t\t});\n\t\tthis.entriesMemo.set(repoId, walk);\n\t\treturn walk;\n\t}\n\n\tprivate async walkRepo(repoId: string): Promise<SkillEntry[]> {\n\t\tconst root = this.repoRoots.get(repoId);\n\t\tif (!root) return [];\n\t\tconst layout = (await loadRepoLayout(root)) ?? DEFAULT_REPO_LAYOUT;\n\t\tconst entries: SkillEntry[] = [];\n\t\tawait walkForEntries(root, repoId, entries, layout);\n\t\treturn entries;\n\t}\n}\n\n/** All files inside a single entry (manifest first, then alphabetical). */\nasync function collectEntryFiles(found: SkillEntry): Promise<SkillFile[]> {\n\tconst out: SkillFile[] = [];\n\t// Flat single-file entries (e.g. `agents/foo.agent.md`) have `dir`\n\t// pointing at the manifest file itself, not a directory — there's\n\t// no sibling files to collect, just the one manifest.\n\tif (found.dir === found.manifestPath) {\n\t\tconst content = await fs.readFile(found.manifestPath, \"utf8\");\n\t\treturn [{ path: path.basename(found.manifestPath), content }];\n\t}\n\tawait collectFilesRecursive(found.dir, found.dir, out);\n\t// Sort for determinism (manifest first, then alphabetical)\n\tout.sort((a, b) => {\n\t\tconst aIsManifest = a.path === \"SKILL.md\" || a.path === \"AGENT.md\";\n\t\tconst bIsManifest = b.path === \"SKILL.md\" || b.path === \"AGENT.md\";\n\t\tif (aIsManifest && !bIsManifest) return -1;\n\t\tif (bIsManifest && !aIsManifest) return 1;\n\t\treturn a.path.localeCompare(b.path);\n\t});\n\treturn out;\n}\n\n// ─────────────────────────────────────────────────────────────────────\n// Internals\n// ─────────────────────────────────────────────────────────────────────\n\nconst SKIP_DIRS = new Set([\".git\", \"node_modules\", \".vscode\", \"dist\", \"build\", \"out\"]);\n\n/**\n * Directories that are never treated as candidate skill/agent parents\n * during the top-level catalog walk. `plugins/` is a distinct concept\n * from the skill/agent catalog itself — a plugin bundle\n * (`plugins/<scope>/<plugin-name>/{skills,agents}/...`) re-packages\n * ALREADY-cataloged official skills/agents (see the plugin's own\n * `catalog.json`, which lists them by name) purely for discovery\n * grouping. Walking into it produces duplicate `SkillEntry` values\n * with the SAME `repoId`+`name` as their real, top-level counterpart\n * (e.g. `skills/official/acreadiness-assess` AND\n * `plugins/official/acreadiness-cockpit/skills/acreadiness-assess`),\n * which breaks anything keyed on `repoId/name` (React list rendering,\n * the \"installed\" lookup, `SkillStore.get()`'s `.find()`).\n *\n * Scoped separately from `SKIP_DIRS` (used by both this walk AND\n * `collectFilesRecursive`) so an actual skill that happens to ship its\n * own `plugins/` asset folder still has that folder listed in its own\n * file detail view.\n */\nconst SKIP_TOP_LEVEL_SCAN_DIRS = new Set([...SKIP_DIRS, \"plugins\"]);\n\n/** Suffix that marks a standalone file as a flat agent manifest (no wrapping dir). */\nconst FLAT_AGENT_FILE_SUFFIX = \".agent.md\";\n\n/**\n * Recursive walk that yields SkillEntry values for any directory\n * containing a SKILL.md or AGENT.md file, PLUS any standalone\n * `<name>.agent.md` file (see class doc, layout style 4). The dir\n * itself is the \"entry root\" for directory-based entries; the\n * manifest file itself is the \"entry root\" for flat agent files.\n *\n * The optional `layout` descriptor (from `.serviceme-repo.json`)\n * widens the scan: included subdirs are walked even without a\n * manifest at the top level, and `treatFilesAsSkills` surfaces\n * `<name>.md` files inside them as skills (frontmatter parsed\n * from the file body).\n */\nasync function walkForEntries(\n\trootDir: string,\n\trepoId: string,\n\tout: SkillEntry[],\n\tlayout: RepoLayoutDescriptor = DEFAULT_REPO_LAYOUT\n): Promise<void> {\n\tlet dirents: import(\"node:fs\").Dirent[];\n\ttry {\n\t\tdirents = await fs.readdir(rootDir, { withFileTypes: true });\n\t} catch {\n\t\treturn;\n\t}\n\n\tfor (const d of dirents) {\n\t\tif (d.isFile() && d.name.endsWith(FLAT_AGENT_FILE_SUFFIX)) {\n\t\t\tconst filePath = path.join(rootDir, d.name);\n\t\t\tconst stat = await fs.stat(filePath);\n\t\t\tconst content = await fs.readFile(filePath, \"utf8\");\n\t\t\tconst parsed = extractFrontmatter(content);\n\t\t\tout.push({\n\t\t\t\trepoId,\n\t\t\t\tname: d.name.slice(0, -FLAT_AGENT_FILE_SUFFIX.length),\n\t\t\t\tkind: \"agent\",\n\t\t\t\tmanifestPath: filePath,\n\t\t\t\t// Sentinel: `dir === manifestPath` marks a flat single-file\n\t\t\t\t// entry (no directory of its own — see getFiles()).\n\t\t\t\tdir: filePath,\n\t\t\t\tfrontmatter: parsed?.data ?? {},\n\t\t\t\tmodifiedAt: stat.mtime.toISOString(),\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tif (!d.isDirectory()) continue;\n\t\tif (SKIP_TOP_LEVEL_SCAN_DIRS.has(d.name)) continue;\n\t\tif (layout.exclude.includes(d.name)) continue;\n\t\tconst childDir = path.join(rootDir, d.name);\n\t\tconst kind = await detectKind(childDir);\n\t\tif (kind) {\n\t\t\tconst manifestFilename = kind === \"skill\" ? \"SKILL.md\" : \"AGENT.md\";\n\t\t\tconst manifestPath = path.join(childDir, manifestFilename);\n\t\t\tconst stat = await fs.stat(manifestPath);\n\t\t\tconst content = await fs.readFile(manifestPath, \"utf8\");\n\t\t\tconst parsed = extractFrontmatter(content);\n\t\t\tout.push({\n\t\t\t\trepoId,\n\t\t\t\tname: d.name,\n\t\t\t\tkind,\n\t\t\t\tmanifestPath,\n\t\t\t\tdir: childDir,\n\t\t\t\tfrontmatter: parsed?.data ?? {},\n\t\t\t\tmodifiedAt: stat.mtime.toISOString(),\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\t// No manifest at the top — recurse, but ALSO check whether\n\t\t// the layout descriptor wants this subdir widened.\n\t\tawait walkForEntries(childDir, repoId, out, layout);\n\t\tif (layout.treatFilesAsSkills && layout.include.includes(d.name)) {\n\t\t\tawait surfaceFilesAsSkills(childDir, d.name, repoId, out);\n\t\t}\n\t}\n}\n\n/**\n * Walk `<includedSubdir>/<file>.md` and register each as a skill.\n * The `.md` file itself is the manifest — frontmatter (if any) is\n * parsed and surfaced. This is the awesome-copilot style: a\n * `prompts/` dir full of `<name>.md` files, no SKILL.md anywhere.\n */\nasync function surfaceFilesAsSkills(\n\tabsDir: string,\n\trelName: string,\n\trepoId: string,\n\tout: SkillEntry[]\n): Promise<void> {\n\tlet dirents: import(\"node:fs\").Dirent[];\n\ttry {\n\t\tdirents = await fs.readdir(absDir, { withFileTypes: true });\n\t} catch {\n\t\treturn;\n\t}\n\tfor (const d of dirents) {\n\t\tif (!d.isFile()) continue;\n\t\tif (!d.name.endsWith(\".md\")) continue;\n\t\tconst filePath = path.join(absDir, d.name);\n\t\tconst stat = await fs.stat(filePath);\n\t\tconst content = await fs.readFile(filePath, \"utf8\");\n\t\tconst parsed = extractFrontmatter(content);\n\t\t// Entry name = \"<subdir>/<file>\" (with the .md stripped) so it\n\t\t// stays unique even when two included subdirs share filenames.\n\t\tconst entryName = `${relName}/${d.name.replace(/\\.md$/, \"\")}`;\n\t\tout.push({\n\t\t\trepoId,\n\t\t\tname: entryName,\n\t\t\tkind: \"skill\",\n\t\t\tmanifestPath: filePath,\n\t\t\tdir: absDir,\n\t\t\tfrontmatter: parsed?.data ?? {},\n\t\t\tmodifiedAt: stat.mtime.toISOString(),\n\t\t});\n\t}\n}\n\n/**\n * Returns the SkillKind of a directory if it contains a manifest file,\n * or `null` if it doesn't. Manifest precedence: SKILL.md wins if both\n * are present (defensive — the spec separates skills and agents into\n * different subdir trees, so this collision shouldn't happen in\n * well-formed repos).\n */\nasync function detectKind(dir: string): Promise<SkillKind | null> {\n\tconst [hasSkill, hasAgent] = await Promise.all([\n\t\tfs\n\t\t\t.access(path.join(dir, \"SKILL.md\"))\n\t\t\t.then(() => true)\n\t\t\t.catch(() => false),\n\t\tfs\n\t\t\t.access(path.join(dir, \"AGENT.md\"))\n\t\t\t.then(() => true)\n\t\t\t.catch(() => false),\n\t]);\n\tif (hasSkill) return \"skill\";\n\tif (hasAgent) return \"agent\";\n\treturn null;\n}\n\n/**\n * Walk a skill/agent directory recursively, pushing every file into\n * `out` with its path RELATIVE to the entry root. Skips `.git/`,\n * `node_modules/`, and the SKIP_DIRS set.\n */\nasync function collectFilesRecursive(\n\tabsDir: string,\n\tentryRoot: string,\n\tout: SkillFile[]\n): Promise<void> {\n\tlet dirents: import(\"node:fs\").Dirent[];\n\ttry {\n\t\tdirents = await fs.readdir(absDir, { withFileTypes: true });\n\t} catch {\n\t\treturn;\n\t}\n\tfor (const d of dirents) {\n\t\tif (SKIP_DIRS.has(d.name)) continue;\n\t\tconst full = path.join(absDir, d.name);\n\t\tif (d.isDirectory()) {\n\t\t\tawait collectFilesRecursive(full, entryRoot, out);\n\t\t} else if (d.isFile()) {\n\t\t\tconst content = await fs.readFile(full, \"utf8\");\n\t\t\tout.push({ path: path.relative(entryRoot, full), content });\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAM,kBAAkB;AACxB,MAAM,mBAAmB;;;;;;;AAyBzB,MAAa,sBAA4C;CACxD,QAAQ;CACR,SAAS,CAAC;CACV,SAAS,CAAC;CACV,oBAAoB;AACrB;;;;;;;;;;;AAYA,eAAsB,eAAe,UAAwD;CAC5F,MAAM,aAAaA,UAAK,KAAK,UAAU,eAAe;CACtD,IAAI;CACJ,IAAI;EACH,MAAM,MAAMC,iBAAG,SAAS,YAAY,MAAM;CAC3C,QAAQ;EACP,OAAO;CACR;CAEA,IAAI;CACJ,IAAI;EACH,SAAS,KAAK,MAAM,GAAG;CACxB,QAAQ;EACP,OAAO;CACR;CACA,IAAI,CAAC,UAAU,OAAO,WAAW,UAAU,OAAO;CAClD,MAAM,MAAM;CAEZ,IAAI,IAAI,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AM,QAAQ,IAAI,CAC9CA,iBACE,OAAOC,UAAK,KAAK,KAAK,UAAU,CAAC,CAAC,CAClC,WAAW,IAAI,CAAC,CAChB,YAAY,KAAK,GACnBD,iBACE,OAAOC,UAAK,KAAK,KAAK,UAAU,CAAC,CAAC,CAClC,WAAW,IAAI,CAAC,CAChB,YAAY,KAAK,CACpB,CAAC;CACD,IAAI,UAAU,OAAO;CACrB,IAAI,UAAU,OAAO;CACrB,OAAO;AACR;;;;;;AAOA,eAAe,sBACd,QACA,WACA,KACgB;CAChB,IAAI;CACJ,IAAI;EACH,UAAU,MAAMD,iBAAG,QAAQ,QAAQ,EAAE,eAAe,KAAK,CAAC;CAC3D,QAAQ;EACP;CACD;CACA,KAAK,MAAM,KAAK,SAAS;EACxB,IAAI,UAAU,IAAI,EAAE,IAAI,GAAG;EAC3B,MAAM,OAAOC,UAAK,KAAK,QAAQ,EAAE,IAAI;EACrC,IAAI,EAAE,YAAY,GACjB,MAAM,sBAAsB,MAAM,WAAW,GAAG;OAC1C,IAAI,EAAE,OAAO,GAAG;GACtB,MAAM,UAAU,MAAMD,iBAAG,SAAS,MAAM,MAAM;GAC9C,IAAI,KAAK;IAAE,MAAMC,UAAK,SAAS,WAAW,IAAI;IAAG;GAAQ,CAAC;EAC3D;CACD;AACD"}
@@ -1,6 +1,5 @@
1
- import { S as SkillEntry, a as SkillDetail, b as SkillFile } from './types-B9gk3dXH.mjs';
2
- export { c as SkillKind, d as SkillNotFoundError } from './types-B9gk3dXH.mjs';
3
-
1
+ import { a as SkillNotFoundError, i as SkillKind, n as SkillEntry, r as SkillFile, t as SkillDetail } from "./types-BCV3IedE.mjs";
2
+ //#region src/skill-store/index.d.ts
4
3
  /**
5
4
  * Minimal frontmatter reader — same shape as the extension's
6
5
  * `WorkspaceSkillsInitializationService.extractFrontmatter`. We avoid
@@ -10,44 +9,44 @@ export { c as SkillKind, d as SkillNotFoundError } from './types-B9gk3dXH.mjs';
10
9
  * string value — the very common `description: >` form would
11
10
  * otherwise surface the bare `>` indicator as the whole description.
12
11
  */
13
- declare function extractFrontmatter(raw: string): {
14
- data: Record<string, unknown>;
15
- body: string;
12
+ export declare function extractFrontmatter(raw: string): {
13
+ data: Record<string, unknown>;
14
+ body: string;
16
15
  } | null;
17
-
18
- declare class SkillStore {
19
- private readonly repoRoots;
20
- /**
21
- * Per-instance memo of repo walks. The catalog walk is a recursive
22
- * readdir over the whole checkout the dominant cost of every
23
- * list/get so results (and the in-flight promise) are reused for
24
- * the store's lifetime. The handler that owns long-lived stores
25
- * bounds staleness by rebuilding the store on a short TTL; within
26
- * one store instance the tree is treated as immutable.
27
- */
28
- private readonly entriesMemo;
29
- constructor(opts: {
30
- repos: ReadonlyArray<{
31
- id: string;
32
- rootPath: string;
33
- }>;
34
- });
35
- /** All skills + agents across all registered repos. Repos are walked
36
- * concurrently — one slow checkout no longer stretches the total. */
37
- listAll(): Promise<SkillEntry[]>;
38
- /** All skills + agents under a single repo. */
39
- listByRepo(repoId: string): Promise<SkillEntry[]>;
40
- /** Single entry detail (manifest + all files inside its dir). */
41
- get(repoId: string, name: string): Promise<SkillDetail>;
42
- /** All files inside a single entry's directory (manifest + extras). */
43
- getFiles(repoId: string, name: string): Promise<SkillFile[]>;
44
- /**
45
- * Memoized walk. Sharing the promise collapses concurrent list/get
46
- * calls over the same repo into a single traversal; a rejected walk
47
- * is dropped so the next call retries from disk.
48
- */
49
- private listByRepoCached;
50
- private walkRepo;
16
+ export declare class SkillStore {
17
+ private readonly repoRoots;
18
+ /**
19
+ * Per-instance memo of repo walks. The catalog walk is a recursive
20
+ * readdir over the whole checkout the dominant cost of every
21
+ * list/get so results (and the in-flight promise) are reused for
22
+ * the store's lifetime. The handler that owns long-lived stores
23
+ * bounds staleness by rebuilding the store on a short TTL; within
24
+ * one store instance the tree is treated as immutable.
25
+ */
26
+ private readonly entriesMemo;
27
+ constructor(opts: {
28
+ repos: ReadonlyArray<{
29
+ id: string;
30
+ rootPath: string;
31
+ }>;
32
+ });
33
+ /** All skills + agents across all registered repos. Repos are walked
34
+ * concurrently one slow checkout no longer stretches the total. */
35
+ listAll(): Promise<SkillEntry[]>;
36
+ /** All skills + agents under a single repo. */
37
+ listByRepo(repoId: string): Promise<SkillEntry[]>;
38
+ /** Single entry detail (manifest + all files inside its dir). */
39
+ get(repoId: string, name: string): Promise<SkillDetail>;
40
+ /** All files inside a single entry's directory (manifest + extras). */
41
+ getFiles(repoId: string, name: string): Promise<SkillFile[]>;
42
+ /**
43
+ * Memoized walk. Sharing the promise collapses concurrent list/get
44
+ * calls over the same repo into a single traversal; a rejected walk
45
+ * is dropped so the next call retries from disk.
46
+ */
47
+ private listByRepoCached;
48
+ private walkRepo;
51
49
  }
52
-
53
- export { SkillDetail, SkillEntry, SkillFile, SkillStore, extractFrontmatter };
50
+ //#endregion
51
+ export { type SkillDetail, type SkillEntry, type SkillFile, type SkillKind, SkillNotFoundError };
52
+ //# sourceMappingURL=skill-store.d.mts.map