@event4u/agent-config 9.11.0 → 9.12.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 (77) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +52 -0
  3. package/README.md +8 -1
  4. package/dist/agent-src/commands/fix/ci.md +29 -0
  5. package/dist/agent-src/commands/pr/create.md +60 -0
  6. package/dist/agent-src/contexts/authority/kernel-rule-edits.md +18 -2
  7. package/dist/agent-src/rules/design-fidelity.md +1 -1
  8. package/dist/agent-src/skills/ai-code-blindspots/SKILL.md +1 -0
  9. package/dist/agent-src/skills/design-intelligence/SKILL.md +27 -1
  10. package/dist/agent-src/skills/design-intelligence/data/font-pairings-reference.csv +74 -74
  11. package/dist/agent-src/skills/design-intelligence/data/manifest.json +2 -0
  12. package/dist/agent-src/skills/design-tokens/scripts/tokens.ts +0 -7
  13. package/dist/agent-src/skills/typography-system/SKILL.md +55 -11
  14. package/dist/agent-src/skills/ui-apply-generic/SKILL.md +180 -0
  15. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  16. package/dist/agent-src/templates/scripts/work_engine/directives/ui/apply.ts +9 -5
  17. package/dist/agent-src/templates/scripts/work_engine/directives/ui/polish.ts +9 -6
  18. package/dist/agent-src/templates/scripts/work_engine/directives/ui/review.ts +9 -5
  19. package/dist/agent-src/templates/scripts/work_engine/directives/ui/stack_bundles.ts +182 -29
  20. package/dist/agent-src/templates/scripts/work_engine/stack/detect.ts +311 -24
  21. package/dist/cli-delegate/chunk-523HCFYO.js +90 -0
  22. package/dist/cli-delegate/{chunk-IR7P7JWA.js → chunk-A3HJ6NTI.js} +271 -59
  23. package/dist/cli-delegate/chunk-EJYIGZ3T.js +125 -0
  24. package/dist/cli-delegate/{chunk-RDGRHAAB.js → chunk-HYWSRNUX.js} +6 -86
  25. package/dist/cli-delegate/{chunk-YMFO6FDN.js → chunk-QFKQLQ7X.js} +313 -81
  26. package/dist/cli-delegate/{chunk-4SV3XGFA.js → chunk-TEGJU2JX.js} +7 -9
  27. package/dist/cli-delegate/chunk-TJIAM5FW.js +133 -0
  28. package/dist/cli-delegate/cmd_conformance.js +4 -7
  29. package/dist/cli-delegate/cmd_doctor.js +3 -5
  30. package/dist/cli-delegate/cmd_explain.js +153 -85
  31. package/dist/cli-delegate/cmd_export.js +5 -3
  32. package/dist/cli-delegate/cmd_fleet.js +2 -1
  33. package/dist/cli-delegate/cmd_preflight.js +6 -123
  34. package/dist/cli-delegate/cmd_prune.js +5 -3
  35. package/dist/cli-delegate/cmd_settings_migrate.js +5 -3
  36. package/dist/cli-delegate/cmd_sync.js +5 -3
  37. package/dist/cli-delegate/cmd_uninstall.js +6 -5
  38. package/dist/cli-delegate/cmd_validate.js +5 -3
  39. package/dist/discovery/deprecation-report.md +1 -1
  40. package/dist/discovery/discovery-manifest.json +36 -14
  41. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  42. package/dist/discovery/discovery-manifest.summary.md +3 -3
  43. package/dist/discovery/orphan-report.md +1 -1
  44. package/dist/discovery/packs.json +6 -5
  45. package/dist/discovery/trust-report.md +2 -2
  46. package/dist/discovery/workspaces.json +5 -4
  47. package/dist/install/install.mjs +605 -412
  48. package/dist/install/ruleInScope.js +123 -0
  49. package/dist/install/ruleInScope.js.map +1 -0
  50. package/dist/install/rule_scope.js +2 -2
  51. package/dist/install/rule_scope.js.map +1 -1
  52. package/dist/install/wizard-plan.js +10 -1
  53. package/dist/install/wizard-plan.js.map +1 -1
  54. package/dist/mcp/registry-manifest.json +3 -3
  55. package/dist/mcp/server.json +2 -2
  56. package/dist/mcp/server.mjs +405 -2429
  57. package/dist/scripts/condense.js +6 -22
  58. package/dist/scripts/condense.js.map +1 -1
  59. package/docs/guidelines/design-fidelity-mechanics.md +14 -0
  60. package/package.json +1 -1
  61. package/src/agent-src/templates/scripts/work_engine/directives/ui/apply.ts +9 -5
  62. package/src/agent-src/templates/scripts/work_engine/directives/ui/polish.ts +9 -6
  63. package/src/agent-src/templates/scripts/work_engine/directives/ui/review.ts +9 -5
  64. package/src/agent-src/templates/scripts/work_engine/directives/ui/stack_bundles.ts +182 -29
  65. package/src/agent-src/templates/scripts/work_engine/stack/detect.ts +311 -24
  66. package/src/install/ruleInScope.ts +133 -0
  67. package/src/install/rule_scope.ts +2 -2
  68. package/src/install/wizard-plan.ts +11 -1
  69. package/src/scripts/_lib/global_deploy_inventory.ts +38 -2
  70. package/src/scripts/check_installer_import_purity.ts +295 -0
  71. package/src/scripts/condense.ts +7 -28
  72. package/src/scripts/install-hooks.sh +36 -4
  73. package/src/scripts/install.ts +210 -5
  74. package/src/scripts/lint_ui_stack_bundles.ts +31 -0
  75. package/dist/cli-delegate/chunk-7DSAMZFU.js +0 -356
  76. package/dist/cli-delegate/chunk-BJGXZNPM.js +0 -266
  77. package/dist/cli-delegate/chunk-TFG57JJM.js +0 -1969
@@ -1,356 +0,0 @@
1
- import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
2
- import {
3
- require_dist
4
- } from "./chunk-OY53J6II.js";
5
- import {
6
- __toESM
7
- } from "./chunk-J55WI3RR.js";
8
-
9
- // src/install/atomic.ts
10
- import {
11
- closeSync,
12
- fsyncSync,
13
- mkdirSync,
14
- openSync,
15
- readFileSync,
16
- renameSync,
17
- unlinkSync,
18
- writeSync
19
- } from "node:fs";
20
- import { dirname, join } from "node:path";
21
- function atomicWriteFile(target, data, options = {}) {
22
- const mode = options.mode ?? 420;
23
- const parent = dirname(target);
24
- mkdirSync(parent, { recursive: true });
25
- const tmp = join(parent, `.tmp.${process.pid}.${randSuffix()}`);
26
- let fd = null;
27
- try {
28
- fd = openSync(tmp, "w", mode);
29
- const buf = typeof data === "string" ? Buffer.from(data, "utf8") : data;
30
- writeSync(fd, buf, 0, buf.length, 0);
31
- fsyncSync(fd);
32
- closeSync(fd);
33
- fd = null;
34
- renameSync(tmp, target);
35
- } catch (err) {
36
- if (fd !== null) {
37
- try {
38
- closeSync(fd);
39
- } catch {
40
- }
41
- }
42
- try {
43
- unlinkSync(tmp);
44
- } catch {
45
- }
46
- throw err;
47
- }
48
- }
49
- function atomicAppendLine(target, line) {
50
- let existing = "";
51
- try {
52
- existing = readFileSync(target, "utf8");
53
- } catch {
54
- existing = "";
55
- }
56
- const sep = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
57
- atomicWriteFile(target, `${existing}${sep}${line}
58
- `);
59
- }
60
- function randSuffix() {
61
- return Math.floor(Math.random() * 281474976710655).toString(16).padStart(12, "0");
62
- }
63
-
64
- // src/scripts/_lib/claude_settings_hooks.ts
65
- var YAML = __toESM(require_dist(), 1);
66
- import * as fs from "node:fs";
67
- import * as path from "node:path";
68
- function _yaml_parse(text) {
69
- return YAML.parse(text);
70
- }
71
- var MANAGED_SIGNATURE = "dispatch:hook --platform claude";
72
- var CorruptSettingsError = class extends Error {
73
- constructor(file, cause) {
74
- super(
75
- `${file} exists but is not valid JSON (${cause}). Refusing to overwrite a user-owned settings file \u2014 fix or remove it, then re-run.`
76
- );
77
- this.name = "CorruptSettingsError";
78
- }
79
- };
80
- var SettingsLockError = class extends Error {
81
- constructor(lockPath) {
82
- super(
83
- `settings lock ${lockPath} is held by another process. Re-run when the concurrent install finishes (stale lock: delete the file).`
84
- );
85
- this.name = "SettingsLockError";
86
- }
87
- };
88
- function build_claude_hook_matrix(manifest_path) {
89
- const raw = fs.readFileSync(manifest_path, "utf8");
90
- const manifest = _yaml_parse(raw) ?? {};
91
- const hook_spec = manifest["schema_version"] ?? 1;
92
- const platforms = manifest["platforms"] ?? {};
93
- const claude_events = (platforms["claude"] ?? {}) || {};
94
- const aliasesAll = manifest["native_event_aliases"] ?? {};
95
- const aliases = (aliasesAll["claude"] ?? {}) || {};
96
- const ac_to_native = {};
97
- for (const [native, ac] of Object.entries(aliases)) {
98
- ac_to_native[String(ac)] = native;
99
- }
100
- const matrix = {};
101
- for (const [ac_event, concerns] of Object.entries(claude_events)) {
102
- if (!concerns || Array.isArray(concerns) && concerns.length === 0) continue;
103
- const native = ac_to_native[ac_event];
104
- if (native === void 0) continue;
105
- matrix[native] = `BIN="$CLAUDE_PROJECT_DIR/agent-config"; [ -x "$BIN" ] || BIN=agent-config; command -v "$BIN" >/dev/null 2>&1 || exit 0; "$BIN" dispatch:hook --platform claude --event ${ac_event} --native-event ${native} --project-dir "$CLAUDE_PROJECT_DIR" --min-version ${String(hook_spec)}`;
106
- }
107
- return matrix;
108
- }
109
- function _is_managed_group(group) {
110
- if (typeof group !== "object" || group === null || Array.isArray(group)) return false;
111
- const hooks = group.hooks;
112
- if (!Array.isArray(hooks)) return false;
113
- return hooks.some(
114
- (h) => typeof h === "object" && h !== null && typeof h.command === "string" && h.command.includes(MANAGED_SIGNATURE)
115
- );
116
- }
117
- function _read_settings(settings_path) {
118
- if (!fs.existsSync(settings_path)) return {};
119
- const raw = fs.readFileSync(settings_path, "utf8");
120
- if (raw.trim() === "") return {};
121
- let parsed;
122
- try {
123
- parsed = JSON.parse(raw);
124
- } catch (e) {
125
- throw new CorruptSettingsError(settings_path, e.message);
126
- }
127
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
128
- throw new CorruptSettingsError(settings_path, "top level is not an object");
129
- }
130
- return parsed;
131
- }
132
- function _with_lock(settings_path, fn) {
133
- const lockPath = settings_path + ".agent-config.lock";
134
- fs.mkdirSync(path.dirname(lockPath), { recursive: true });
135
- let fd;
136
- try {
137
- fd = fs.openSync(lockPath, "wx");
138
- } catch {
139
- throw new SettingsLockError(lockPath);
140
- }
141
- try {
142
- return fn();
143
- } finally {
144
- fs.closeSync(fd);
145
- fs.rmSync(lockPath, { force: true });
146
- }
147
- }
148
- function ensure_managed_hooks(settings_path, matrix) {
149
- return _with_lock(settings_path, () => {
150
- const settings = _read_settings(settings_path);
151
- const before = JSON.stringify(settings);
152
- const hooks = (settings["hooks"] ?? {}) || {};
153
- const touched = [];
154
- for (const [native, command] of Object.entries(matrix)) {
155
- const existing = Array.isArray(hooks[native]) ? hooks[native] : [];
156
- const user_groups = existing.filter((g) => !_is_managed_group(g));
157
- const managed_group = {
158
- hooks: [{ type: "command", command }]
159
- };
160
- const next = [...user_groups, managed_group];
161
- if (JSON.stringify(next) !== JSON.stringify(existing)) touched.push(native);
162
- hooks[native] = next;
163
- }
164
- settings["hooks"] = hooks;
165
- const after = JSON.stringify(settings);
166
- if (after === before) {
167
- return { changed: false, events: [] };
168
- }
169
- atomicWriteFile(settings_path, JSON.stringify(settings, null, 2) + "\n");
170
- return { changed: true, events: touched };
171
- });
172
- }
173
- function remove_managed_hooks(settings_path) {
174
- if (!fs.existsSync(settings_path)) return { changed: false, events: [] };
175
- return _with_lock(settings_path, () => {
176
- const settings = _read_settings(settings_path);
177
- const hooks = settings["hooks"];
178
- if (typeof hooks !== "object" || hooks === null || Array.isArray(hooks)) {
179
- return { changed: false, events: [] };
180
- }
181
- const hooksRec = hooks;
182
- const touched = [];
183
- for (const [native, groups] of Object.entries(hooksRec)) {
184
- if (!Array.isArray(groups)) continue;
185
- const kept = groups.filter((g) => !_is_managed_group(g));
186
- if (kept.length !== groups.length) {
187
- touched.push(native);
188
- if (kept.length === 0) {
189
- delete hooksRec[native];
190
- } else {
191
- hooksRec[native] = kept;
192
- }
193
- }
194
- }
195
- if (touched.length === 0) return { changed: false, events: [] };
196
- if (Object.keys(hooksRec).length === 0) {
197
- delete settings["hooks"];
198
- }
199
- atomicWriteFile(settings_path, JSON.stringify(settings, null, 2) + "\n");
200
- return { changed: true, events: touched };
201
- });
202
- }
203
-
204
- // src/scripts/_lib/claude_builtin_names.ts
205
- var _CURRENT = [
206
- "add-dir",
207
- "advisor",
208
- "agents",
209
- "autofix-pr",
210
- "background",
211
- "batch",
212
- "branch",
213
- "btw",
214
- "cd",
215
- "chrome",
216
- "claude-api",
217
- "clear",
218
- "code-review",
219
- "color",
220
- "compact",
221
- "config",
222
- "context",
223
- "copy",
224
- "cost",
225
- "dataviz",
226
- "debug",
227
- "deep-research",
228
- "design-login",
229
- "design-sync",
230
- "desktop",
231
- "diff",
232
- "doctor",
233
- "effort",
234
- "exit",
235
- "export",
236
- "fast",
237
- "feedback",
238
- "fewer-permission-prompts",
239
- "focus",
240
- "fork",
241
- "goal",
242
- "heapdump",
243
- "help",
244
- "hooks",
245
- "ide",
246
- "init",
247
- "insights",
248
- "install-github-app",
249
- "install-slack-app",
250
- "keybindings",
251
- "login",
252
- "logout",
253
- "loop",
254
- "mcp",
255
- "memory",
256
- "mobile",
257
- "model",
258
- "passes",
259
- "permissions",
260
- "plan",
261
- "plugin",
262
- "powerup",
263
- "pr-comments",
264
- "privacy-settings",
265
- "radio",
266
- "recap",
267
- "release-notes",
268
- "reload-plugins",
269
- "reload-skills",
270
- "remote-control",
271
- "remote-env",
272
- "rename",
273
- "resume",
274
- "review",
275
- "rewind",
276
- "run",
277
- "run-skill-generator",
278
- "sandbox",
279
- "schedule",
280
- "scroll-speed",
281
- "security-review",
282
- "setup-bedrock",
283
- "setup-vertex",
284
- "simplify",
285
- "skills",
286
- "stats",
287
- "status",
288
- "statusline",
289
- "stickers",
290
- "teleport",
291
- "thinking",
292
- "trust",
293
- "upgrade",
294
- "usage",
295
- "verify",
296
- "vim",
297
- "web",
298
- "whats-new",
299
- "workflow",
300
- "workflows",
301
- "worktree"
302
- ];
303
- var _LEGACY = [
304
- "bashes",
305
- "bug",
306
- "migrate-installer",
307
- "output-style",
308
- "terminal-setup",
309
- "theme",
310
- "todos"
311
- ];
312
- var CLAUDE_CODE_BUILTIN_NAMES = /* @__PURE__ */ new Set([
313
- ..._CURRENT,
314
- ..._LEGACY
315
- ]);
316
- function is_claude_builtin_name(slug) {
317
- return CLAUDE_CODE_BUILTIN_NAMES.has(slug.toLowerCase());
318
- }
319
-
320
- // src/scripts/_lib/model_tier.ts
321
- import fs2 from "node:fs";
322
- var TIER_TO_CLAUDE_MODEL = {
323
- high: "opus",
324
- medium: "sonnet",
325
- lite: "haiku"
326
- };
327
- var MODEL_TIER_RE = /^model_tier:\s*"?([a-z]+)"?\s*$/m;
328
- function read_model_tier(skill_md) {
329
- if (!fs2.existsSync(skill_md)) return null;
330
- const text = fs2.readFileSync(skill_md).toString("utf-8");
331
- if (!text.startsWith("---\n")) return null;
332
- const end = text.indexOf("\n---\n", 4);
333
- if (end === -1) return null;
334
- const m = MODEL_TIER_RE.exec(text.slice(4, end));
335
- return m ? m[1] : null;
336
- }
337
- function render_native_model_md(text, tier) {
338
- const model = TIER_TO_CLAUDE_MODEL[tier];
339
- if (model === void 0) {
340
- throw new Error(`'${tier}'`);
341
- }
342
- return text.replace(MODEL_TIER_RE, `model: ${model}`);
343
- }
344
-
345
- export {
346
- atomicAppendLine,
347
- MANAGED_SIGNATURE,
348
- build_claude_hook_matrix,
349
- ensure_managed_hooks,
350
- remove_managed_hooks,
351
- is_claude_builtin_name,
352
- TIER_TO_CLAUDE_MODEL,
353
- MODEL_TIER_RE,
354
- read_model_tier,
355
- render_native_model_md
356
- };
@@ -1,266 +0,0 @@
1
- import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
2
-
3
- // src/scripts/_lib/agent_src.ts
4
- import * as fs from "node:fs";
5
- import * as path from "node:path";
6
- import { fileURLToPath } from "node:url";
7
- var _HERE = path.dirname(fileURLToPath(import.meta.url));
8
- var _DEFAULT_ROOT = path.resolve(_HERE, "..", "..", "..");
9
- function _deriveRoots(root) {
10
- const packages = path.join(root, "packages");
11
- const src = path.join(root, "src");
12
- return {
13
- ROOT: root,
14
- LEGACY_SRC: path.join(root, ".agent-src.uncondensed"),
15
- PACKAGES: packages,
16
- PACKAGE_CORE: path.join(packages, "core"),
17
- SRC: src,
18
- SRC_SKILLS: path.join(src, "skills"),
19
- SRC_RULES: path.join(src, "rules"),
20
- SRC_AGENT: path.join(src, "agent-src"),
21
- SRC_DOMAINS: path.join(src, "domains")
22
- };
23
- }
24
- var _roots = _deriveRoots(_DEFAULT_ROOT);
25
- var _SRC_DOMAINS_PREFIX = "src/domains/";
26
- function _isDir(p) {
27
- try {
28
- return fs.statSync(p).isDirectory();
29
- } catch {
30
- return false;
31
- }
32
- }
33
- function _isFile(p) {
34
- try {
35
- return fs.statSync(p).isFile();
36
- } catch {
37
- return false;
38
- }
39
- }
40
- function _exists(p) {
41
- try {
42
- fs.statSync(p);
43
- return true;
44
- } catch {
45
- return false;
46
- }
47
- }
48
- function _iterdirSorted(p) {
49
- let names;
50
- try {
51
- names = fs.readdirSync(p);
52
- } catch {
53
- return [];
54
- }
55
- names.sort();
56
- return names.map((name) => path.join(p, name));
57
- }
58
- function _rglobSorted(root, pattern) {
59
- const out = [];
60
- const suffix = pattern === "*" ? null : pattern.slice(1);
61
- const walk = (dir) => {
62
- let entries;
63
- try {
64
- entries = fs.readdirSync(dir, { withFileTypes: true });
65
- } catch {
66
- return;
67
- }
68
- for (const ent of entries) {
69
- const full = path.join(dir, ent.name);
70
- const matches = suffix === null ? true : ent.name.endsWith(suffix);
71
- if (matches) {
72
- out.push(full);
73
- }
74
- if (ent.isDirectory() || ent.isSymbolicLink() && _isDir(full)) {
75
- walk(full);
76
- }
77
- }
78
- };
79
- walk(root);
80
- out.sort();
81
- return out;
82
- }
83
- function _relativeToPosix(child, root) {
84
- const rel = path.relative(root, child);
85
- return rel.split(path.sep).join("/");
86
- }
87
- function _isUnder(child, root) {
88
- const rel = path.relative(root, child);
89
- return rel !== "" && !rel.startsWith("..") && !path.isAbsolute(rel);
90
- }
91
- function _domains_command_logical(p) {
92
- const dom = _roots.SRC_DOMAINS;
93
- if (p !== dom && !_isUnder(p, dom)) {
94
- return null;
95
- }
96
- const rel = _relativeToPosix(p, dom);
97
- const parts = rel.split("/");
98
- if (parts.length < 3 || parts[parts.length - 1] !== "command.md") {
99
- return null;
100
- }
101
- const subpath = parts.slice(1, -1).join("/");
102
- return `commands/${subpath}.md`;
103
- }
104
- function* _iter_domains_commands() {
105
- const dom = _roots.SRC_DOMAINS;
106
- if (!_isDir(dom)) {
107
- return;
108
- }
109
- for (const p of _rglobSorted(dom, "command.md")) {
110
- if (!_isFile(p)) {
111
- continue;
112
- }
113
- const logical = _domains_command_logical(p);
114
- if (logical !== null) {
115
- yield [p, logical];
116
- }
117
- }
118
- }
119
- var _LEGACY_PREFIX = ".agent-src.uncondensed/";
120
- var _PACKAGE_SUFFIX = "/.agent-src.uncondensed/";
121
- var _SRC_SKILLS_PREFIX = "src/skills/";
122
- var _SRC_RULES_PREFIX = "src/rules/";
123
- function _root_specs() {
124
- const specs = [];
125
- if (_exists(_roots.LEGACY_SRC)) {
126
- specs.push([_roots.LEGACY_SRC, ""]);
127
- }
128
- if (_exists(_roots.PACKAGES)) {
129
- for (const pkg of _iterdirSorted(_roots.PACKAGES)) {
130
- const sub = path.join(pkg, ".agent-src.uncondensed");
131
- if (_isDir(sub)) {
132
- specs.push([sub, ""]);
133
- }
134
- }
135
- }
136
- if (_isDir(_roots.SRC_AGENT)) {
137
- specs.push([_roots.SRC_AGENT, ""]);
138
- }
139
- if (_isDir(_roots.SRC_SKILLS)) {
140
- specs.push([_roots.SRC_SKILLS, "skills/"]);
141
- }
142
- if (_isDir(_roots.SRC_RULES)) {
143
- specs.push([_roots.SRC_RULES, "rules/"]);
144
- }
145
- const seen = /* @__PURE__ */ new Map();
146
- for (const [physical, prefix] of specs) {
147
- if (!prefix) {
148
- continue;
149
- }
150
- const claimedBy = seen.get(prefix);
151
- if (claimedBy !== void 0) {
152
- throw new Error(
153
- `source-root logical-prefix collision: ${JSON.stringify(prefix)} claimed by both ${claimedBy} and ${physical}`
154
- );
155
- }
156
- seen.set(prefix, physical);
157
- }
158
- return specs;
159
- }
160
- function artefact_roots() {
161
- const roots = [];
162
- if (_exists(_roots.LEGACY_SRC)) {
163
- roots.push(_roots.LEGACY_SRC);
164
- }
165
- if (_exists(_roots.PACKAGES)) {
166
- for (const pkg of _iterdirSorted(_roots.PACKAGES)) {
167
- const sub = path.join(pkg, ".agent-src.uncondensed");
168
- if (_isDir(sub)) {
169
- roots.push(sub);
170
- }
171
- }
172
- }
173
- if (_isDir(_roots.SRC_AGENT)) {
174
- roots.push(_roots.SRC_AGENT);
175
- }
176
- if (_isDir(_roots.SRC_SKILLS) || _isDir(_roots.SRC_RULES)) {
177
- roots.push(_roots.SRC);
178
- }
179
- return roots;
180
- }
181
- function* iter_all_sources() {
182
- const seen = /* @__PURE__ */ new Set();
183
- for (const [root, prefix] of _root_specs()) {
184
- for (const p of _rglobSorted(root, "*")) {
185
- if (!_isFile(p)) {
186
- continue;
187
- }
188
- if (p !== root && !_isUnder(p, root)) {
189
- continue;
190
- }
191
- const rel = prefix + _relativeToPosix(p, root);
192
- if (seen.has(rel)) {
193
- continue;
194
- }
195
- seen.add(rel);
196
- yield [p, rel];
197
- }
198
- }
199
- for (const [p, rel] of _iter_domains_commands()) {
200
- if (seen.has(rel)) {
201
- continue;
202
- }
203
- seen.add(rel);
204
- yield [p, rel];
205
- }
206
- }
207
- function resolve_logical(logical_rel) {
208
- const rel = logical_rel.replaceAll("\\", "/").replace(/^\/+/, "");
209
- for (const [root, prefix] of _root_specs()) {
210
- let p;
211
- if (prefix) {
212
- if (!rel.startsWith(prefix)) {
213
- continue;
214
- }
215
- p = path.join(root, rel.slice(prefix.length));
216
- } else {
217
- p = path.join(root, rel);
218
- }
219
- if (_exists(p)) {
220
- return p;
221
- }
222
- }
223
- if (rel.startsWith("commands/") && rel.endsWith(".md") && _isDir(_roots.SRC_DOMAINS)) {
224
- const subpath = rel.slice("commands/".length, rel.length - ".md".length);
225
- for (const packDir of _iterdirSorted(_roots.SRC_DOMAINS)) {
226
- const cand = path.join(packDir, subpath, "command.md");
227
- if (_isFile(cand)) {
228
- return cand;
229
- }
230
- }
231
- }
232
- return null;
233
- }
234
- function strip_source_prefix(rel) {
235
- const posix = rel.replaceAll("\\", "/");
236
- if (posix.startsWith(_LEGACY_PREFIX)) {
237
- return posix.slice(_LEGACY_PREFIX.length);
238
- }
239
- if (posix.startsWith("packages/")) {
240
- const idx = posix.indexOf(_PACKAGE_SUFFIX);
241
- if (idx !== -1) {
242
- return posix.slice(idx + _PACKAGE_SUFFIX.length);
243
- }
244
- }
245
- if (posix.startsWith(_SRC_SKILLS_PREFIX)) {
246
- return `skills/${posix.slice(_SRC_SKILLS_PREFIX.length)}`;
247
- }
248
- if (posix.startsWith(_SRC_RULES_PREFIX)) {
249
- return `rules/${posix.slice(_SRC_RULES_PREFIX.length)}`;
250
- }
251
- if (posix.startsWith(_SRC_DOMAINS_PREFIX) && posix.endsWith("/command.md")) {
252
- const rest = posix.slice(_SRC_DOMAINS_PREFIX.length);
253
- const parts = rest.split("/");
254
- if (parts.length >= 3) {
255
- return `commands/${parts.slice(1, -1).join("/")}.md`;
256
- }
257
- }
258
- return null;
259
- }
260
-
261
- export {
262
- artefact_roots,
263
- iter_all_sources,
264
- resolve_logical,
265
- strip_source_prefix
266
- };