@cohortapp/agent-sdk 2.12.0 → 2.13.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 (127) hide show
  1. package/bin/maestro.mjs +6 -2
  2. package/docs/guides/front-door-session.md +49 -0
  3. package/lib/cli/design.mjs +185 -0
  4. package/lib/cli/design.test.mjs +270 -0
  5. package/lib/cli/global-setup-extras.mjs +44 -0
  6. package/lib/cli/global-setup-extras.test.mjs +95 -0
  7. package/lib/cli/session.mjs +11 -1
  8. package/lib/cli/session.test.mjs +17 -6
  9. package/lib/collective/global-config.mjs +5 -0
  10. package/lib/collective/global-config.test.mjs +5 -0
  11. package/lib/collective/vendor-skills.mjs +305 -0
  12. package/lib/collective/vendor-skills.test.mjs +306 -0
  13. package/lib/design/design-md.mjs +793 -0
  14. package/lib/design/design-md.test.mjs +318 -0
  15. package/lib/design/fixtures/DESIGN.golden.md +238 -0
  16. package/lib/design/fixtures/PRODUCT.golden.md +67 -0
  17. package/lib/design/fixtures/foundation.json +133 -0
  18. package/lib/design/refresh-gate.mjs +154 -0
  19. package/lib/design/refresh-gate.test.mjs +144 -0
  20. package/lib/design/write.mjs +275 -0
  21. package/lib/design/write.test.mjs +241 -0
  22. package/lib/prompts/parallelism.mjs +79 -0
  23. package/lib/prompts/parallelism.test.mjs +177 -0
  24. package/package.json +1 -1
  25. package/plugins/maestro-skills/plugin.json +4 -0
  26. package/plugins/maestro-skills/skills/cohort-design.md +153 -0
  27. package/plugins/maestro-skills/vendor/emilkowalski/LICENSE +21 -0
  28. package/plugins/maestro-skills/vendor/emilkowalski/UPSTREAM.json +70 -0
  29. package/plugins/maestro-skills/vendor/emilkowalski/skills/animate/RECIPES.md +324 -0
  30. package/plugins/maestro-skills/vendor/emilkowalski/skills/animate/SKILL.md +199 -0
  31. package/plugins/maestro-skills/vendor/emilkowalski/skills/animation-vocabulary/SKILL.md +173 -0
  32. package/plugins/maestro-skills/vendor/emilkowalski/skills/apple-design/SKILL.md +282 -0
  33. package/plugins/maestro-skills/vendor/emilkowalski/skills/emil-design-eng/SKILL.md +674 -0
  34. package/plugins/maestro-skills/vendor/emilkowalski/skills/find-animation-opportunities/SKILL.md +132 -0
  35. package/plugins/maestro-skills/vendor/emilkowalski/skills/improve-animations/AUDIT.md +115 -0
  36. package/plugins/maestro-skills/vendor/emilkowalski/skills/improve-animations/PLAN-TEMPLATE.md +73 -0
  37. package/plugins/maestro-skills/vendor/emilkowalski/skills/improve-animations/SKILL.md +101 -0
  38. package/plugins/maestro-skills/vendor/emilkowalski/skills/prototype/PICKER.md +197 -0
  39. package/plugins/maestro-skills/vendor/emilkowalski/skills/prototype/SKILL.md +90 -0
  40. package/plugins/maestro-skills/vendor/emilkowalski/skills/review-animations/SKILL.md +112 -0
  41. package/plugins/maestro-skills/vendor/emilkowalski/skills/review-animations/STANDARDS.md +187 -0
  42. package/plugins/maestro-skills/vendor/impeccable/LICENSE +191 -0
  43. package/plugins/maestro-skills/vendor/impeccable/NOTICE.md +11 -0
  44. package/plugins/maestro-skills/vendor/impeccable/SKILL.md +86 -0
  45. package/plugins/maestro-skills/vendor/impeccable/UPSTREAM.json +201 -0
  46. package/plugins/maestro-skills/vendor/impeccable/agents/impeccable-asset-producer.md +42 -0
  47. package/plugins/maestro-skills/vendor/impeccable/agents/impeccable-documenter.md +29 -0
  48. package/plugins/maestro-skills/vendor/impeccable/agents/impeccable-finish-reviewer.md +43 -0
  49. package/plugins/maestro-skills/vendor/impeccable/agents/impeccable-manual-edit-applier.md +97 -0
  50. package/plugins/maestro-skills/vendor/impeccable/reference/adapt.md +312 -0
  51. package/plugins/maestro-skills/vendor/impeccable/reference/adapt.native.md +58 -0
  52. package/plugins/maestro-skills/vendor/impeccable/reference/android.md +46 -0
  53. package/plugins/maestro-skills/vendor/impeccable/reference/animate.md +89 -0
  54. package/plugins/maestro-skills/vendor/impeccable/reference/audit.md +136 -0
  55. package/plugins/maestro-skills/vendor/impeccable/reference/audit.native.md +139 -0
  56. package/plugins/maestro-skills/vendor/impeccable/reference/bolder.md +33 -0
  57. package/plugins/maestro-skills/vendor/impeccable/reference/clarify.md +94 -0
  58. package/plugins/maestro-skills/vendor/impeccable/reference/colorize.md +86 -0
  59. package/plugins/maestro-skills/vendor/impeccable/reference/craft-floor.md +44 -0
  60. package/plugins/maestro-skills/vendor/impeccable/reference/craft.md +5 -0
  61. package/plugins/maestro-skills/vendor/impeccable/reference/critique.md +806 -0
  62. package/plugins/maestro-skills/vendor/impeccable/reference/degraded/asset-producer.md +37 -0
  63. package/plugins/maestro-skills/vendor/impeccable/reference/degraded/documenter.md +24 -0
  64. package/plugins/maestro-skills/vendor/impeccable/reference/degraded/finish-reviewer.md +38 -0
  65. package/plugins/maestro-skills/vendor/impeccable/reference/degraded/manual-edit-applier.md +92 -0
  66. package/plugins/maestro-skills/vendor/impeccable/reference/delight.md +70 -0
  67. package/plugins/maestro-skills/vendor/impeccable/reference/distill.md +111 -0
  68. package/plugins/maestro-skills/vendor/impeccable/reference/doctor.md +54 -0
  69. package/plugins/maestro-skills/vendor/impeccable/reference/document.md +416 -0
  70. package/plugins/maestro-skills/vendor/impeccable/reference/extract.md +69 -0
  71. package/plugins/maestro-skills/vendor/impeccable/reference/harden.md +336 -0
  72. package/plugins/maestro-skills/vendor/impeccable/reference/hooks.md +111 -0
  73. package/plugins/maestro-skills/vendor/impeccable/reference/init.md +131 -0
  74. package/plugins/maestro-skills/vendor/impeccable/reference/ios.md +51 -0
  75. package/plugins/maestro-skills/vendor/impeccable/reference/layout.md +84 -0
  76. package/plugins/maestro-skills/vendor/impeccable/reference/live-setup.md +104 -0
  77. package/plugins/maestro-skills/vendor/impeccable/reference/live.md +325 -0
  78. package/plugins/maestro-skills/vendor/impeccable/reference/new-work.md +147 -0
  79. package/plugins/maestro-skills/vendor/impeccable/reference/onboard.md +234 -0
  80. package/plugins/maestro-skills/vendor/impeccable/reference/operate.md +61 -0
  81. package/plugins/maestro-skills/vendor/impeccable/reference/optimize.md +258 -0
  82. package/plugins/maestro-skills/vendor/impeccable/reference/overdrive.md +127 -0
  83. package/plugins/maestro-skills/vendor/impeccable/reference/polish.md +105 -0
  84. package/plugins/maestro-skills/vendor/impeccable/reference/quieter.md +99 -0
  85. package/plugins/maestro-skills/vendor/impeccable/reference/routing.md +24 -0
  86. package/plugins/maestro-skills/vendor/impeccable/reference/shape.md +59 -0
  87. package/plugins/maestro-skills/vendor/impeccable/reference/typeset.md +80 -0
  88. package/plugins/maestro-skills/vendor/impeccable/reference/visualize.md +46 -0
  89. package/plugins/maestro-skills/vendor/taste-skill/LICENSE +21 -0
  90. package/plugins/maestro-skills/vendor/taste-skill/UPSTREAM.json +37 -0
  91. package/plugins/maestro-skills/vendor/taste-skill/skills/minimalist-skill/SKILL.md +85 -0
  92. package/plugins/maestro-skills/vendor/taste-skill/skills/redesign-skill/SKILL.md +178 -0
  93. package/plugins/maestro-skills/vendor/taste-skill/skills/soft-skill/SKILL.md +98 -0
  94. package/plugins/maestro-skills/vendor/taste-skill/skills/taste-skill/SKILL.md +1206 -0
  95. package/plugins/maestro-skills/vendor/unlazy/LICENSE +21 -0
  96. package/plugins/maestro-skills/vendor/unlazy/SECURITY.md +72 -0
  97. package/plugins/maestro-skills/vendor/unlazy/SKILL.md +104 -0
  98. package/plugins/maestro-skills/vendor/unlazy/UPSTREAM.json +94 -0
  99. package/plugins/maestro-skills/vendor/unlazy/references/dispatch.md +82 -0
  100. package/plugins/maestro-skills/vendor/unlazy/references/gates.md +149 -0
  101. package/plugins/maestro-skills/vendor/unlazy/references/method.md +49 -0
  102. package/plugins/maestro-skills/vendor/unlazy/references/orchestration.md +107 -0
  103. package/plugins/maestro-skills/vendor/unlazy/references/parallel.md +133 -0
  104. package/plugins/maestro-skills/vendor/unlazy/references/token-economy.md +48 -0
  105. package/plugins/maestro-skills/vendor/unlazy/scripts/dispatch-check.mjs +139 -0
  106. package/plugins/maestro-skills/vendor/unlazy/scripts/gate-check.mjs +960 -0
  107. package/plugins/maestro-skills/vendor/unlazy/scripts/gate-lint.mjs +245 -0
  108. package/plugins/maestro-skills/vendor/unlazy/scripts/lib/check-supervisor.mjs +46 -0
  109. package/plugins/maestro-skills/vendor/unlazy/scripts/lib/dispatch.mjs +293 -0
  110. package/plugins/maestro-skills/vendor/unlazy/scripts/lib/gates.mjs +953 -0
  111. package/plugins/maestro-skills/vendor/unlazy/scripts/lib/process-tree.mjs +161 -0
  112. package/plugins/maestro-skills/vendor/unlazy/scripts/lib/regex-worker.mjs +9 -0
  113. package/plugins/maestro-skills/vendor/unlazy/templates/PLAN.md +116 -0
  114. package/plugins/maestro-skills/vendor/unlazy/templates/gates-leaf.md +51 -0
  115. package/plugins/maestro-skills/vendor/unlazy/templates/gates-node.md +51 -0
  116. package/scripts/ci/check-skill-packs.mjs +388 -0
  117. package/scripts/ci/check-skill-packs.test.mjs +495 -0
  118. package/scripts/ci/check.mjs +3 -0
  119. package/scripts/daemon/agent-daemon-design.test.mjs +238 -0
  120. package/scripts/daemon/agent-daemon.mjs +108 -0
  121. package/scripts/daemon/cadence-consumer-frontdoor.test.mjs +61 -2
  122. package/scripts/daemon/cadence-consumer.mjs +46 -22
  123. package/scripts/daemon/prompt-builder.mjs +19 -3
  124. package/scripts/local-triggers/autoupdate.test.mjs +33 -3
  125. package/scripts/vendor/skill-packs.mjs +354 -0
  126. package/scripts/vendor/sync-skill-packs.mjs +242 -0
  127. package/scripts/vendor/sync-skill-packs.test.mjs +103 -0
@@ -26,6 +26,26 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
26
26
  const SCRIPT = join(__dirname, "autoupdate.sh");
27
27
  const scriptSrc = readFileSync(SCRIPT, "utf8");
28
28
 
29
+ /**
30
+ * Today, in the SAME basis the code under test uses: `date +%Y-%m-%d`, which is
31
+ * LOCAL. Both log files this suite fabricates are read back by shell that names
32
+ * them that way — `autoupdate.sh` for its own log, and for the daemon log the
33
+ * health gate tails (which `scripts/daemon/launchd-wrapper.sh` also writes with
34
+ * local `date`).
35
+ *
36
+ * This used to be `new Date().toISOString().slice(0, 10)` — UTC — and the two
37
+ * agree for exactly as long as the machine sits at or west of Greenwich. On a
38
+ * UTC+4 developer machine they diverge from 20:00 to midnight local, so the
39
+ * fixture wrote `daemon-<yesterday>.log`, the health gate looked for
40
+ * `daemon-<today>.log`, found nothing, and all twelve upgrade cases failed with
41
+ * "UNHEALTHY … ROLLBACK" — a four-hour window each evening in which a green
42
+ * suite turned red with no code change. Keep the basis matched to the shell.
43
+ */
44
+ function localDay(d = new Date()) {
45
+ const p = (n) => String(n).padStart(2, "0");
46
+ return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}`;
47
+ }
48
+
29
49
  function stub(bin, name, body) {
30
50
  writeFileSync(join(bin, name), `#!/bin/bash\n${body}\n`);
31
51
  chmodSync(join(bin, name), 0o755);
@@ -49,7 +69,7 @@ function fixture({ latest = "2.0.0", healthy = true, supervisorAlive = true, ses
49
69
 
50
70
  writeFileSync(join(agent, "node_modules", "@cohortapp", "agent-sdk", "package.json"), JSON.stringify({ version: "1.0.0" }));
51
71
  writeFileSync(join(agent, "node_modules", "@cohortapp", "agent-sdk", "bin", "maestro.mjs"), "process.exit(0);\n");
52
- const day = new Date().toISOString().slice(0, 10);
72
+ const day = localDay();
53
73
  writeFileSync(join(agent, "logs", "daemon", `daemon-${day}.log`), "[daemon] Running\n");
54
74
  writeFileSync(join(home, "Library", "LaunchAgents", "ai.maestro.ivy-daemon.plist"), "<plist/>");
55
75
  if (installedSessionPlist) writeFileSync(join(home, "Library", "LaunchAgents", "ai.maestro.ivy-session.plist"), "<plist/>");
@@ -108,6 +128,14 @@ function run(fx, extraEnv) {
108
128
  // The script prepends the standard tool dirs to PATH; this prefix wins
109
129
  // over them so the stubs — never the real npm/launchctl — are reached.
110
130
  MAESTRO_AUTOUPDATE_PATH_PREFIX: fx.bin,
131
+ // The child shell names its log files with `date +%Y-%m-%d` and this
132
+ // suite fabricates those names with `localDay()`. `env` here is an
133
+ // explicit whitelist, so without this line the shell inherits NO TZ and
134
+ // falls back to the system zone while Node honours the ambient one — the
135
+ // two then disagree whenever a run sets TZ (e.g. `TZ=UTC npm test` on a
136
+ // UTC+4 machine), and every upgrade case fails on a log file neither
137
+ // side is wrong about. Pass the zone through so both agree by construction.
138
+ ...(process.env.TZ ? { TZ: process.env.TZ } : {}),
111
139
  MAESTRO_AUTOUPDATE_JITTER_MAX: "0",
112
140
  MAESTRO_AUTOUPDATE_HEALTH_WAIT: "0",
113
141
  MAESTRO_AUTOUPDATE_RETRY_SLEEP: "0",
@@ -125,7 +153,7 @@ const lastPath = (fx) => join(fx.agent, "state", "autoupdate", "last.json");
125
153
  const readLast = (fx) => JSON.parse(readFileSync(lastPath(fx), "utf8"));
126
154
  const scriptLog = (fx) => {
127
155
  const dir = join(fx.agent, "logs", "autoupdate");
128
- try { return readFileSync(join(dir, `${new Date().toISOString().slice(0, 10)}.log`), "utf8"); } catch { return ""; }
156
+ try { return readFileSync(join(dir, `${localDay()}.log`), "utf8"); } catch { return ""; }
129
157
  };
130
158
 
131
159
  test("a healthy upgrade writes state/session/upgrade-notice.json {from,to,at} and never touches the session job", () => {
@@ -478,7 +506,9 @@ test("the /tmp re-exec copy removes itself on exit (and a run with MAESTRO_AUTOU
478
506
  const tmp = join(fx.root, "tmp"); mkdirSync(tmp, { recursive: true });
479
507
  const r = spawnSync("/bin/bash", [join(fx.agent, "scripts", "local-triggers", "autoupdate.sh")], {
480
508
  encoding: "utf8",
481
- env: { HOME: fx.home, AGENT_ROOT: fx.agent, TMPDIR: tmp, PATH: `${fx.bin}:${dirname(process.execPath)}:/usr/bin:/bin`, MAESTRO_AUTOUPDATE_PATH_PREFIX: fx.bin, MAESTRO_AUTOUPDATE_JITTER_MAX: "0", MAESTRO_AUTOUPDATE_HEALTH_WAIT: "0", MAESTRO_AUTOUPDATE_RETRY_SLEEP: "0", MAESTRO_SKIP_GLOBAL_INSTALL: "1" },
509
+ // This case spawns directly rather than through `run()`, so it needs the
510
+ // same TZ passthrough for the same reason — see the note in `run()`.
511
+ env: { HOME: fx.home, AGENT_ROOT: fx.agent, TMPDIR: tmp, PATH: `${fx.bin}:${dirname(process.execPath)}:/usr/bin:/bin`, ...(process.env.TZ ? { TZ: process.env.TZ } : {}), MAESTRO_AUTOUPDATE_PATH_PREFIX: fx.bin, MAESTRO_AUTOUPDATE_JITTER_MAX: "0", MAESTRO_AUTOUPDATE_HEALTH_WAIT: "0", MAESTRO_AUTOUPDATE_RETRY_SLEEP: "0", MAESTRO_SKIP_GLOBAL_INSTALL: "1" },
482
512
  });
483
513
  assert.equal(r.status, 0, r.stderr);
484
514
  assert.match(scriptLog(fx), /up to date \(1\.0\.0\)/, "the re-exec'd copy ran the script");
@@ -0,0 +1,354 @@
1
+ /**
2
+ * scripts/vendor/skill-packs.mjs — the pinned registry of vendored design
3
+ * skill packs, and the pure helpers both the syncer and the CI guard share.
4
+ *
5
+ * WP-M7 vendors four upstream Claude Code design skill packs into
6
+ * `plugins/maestro-skills/vendor/<pack>/` so that every seat gets them from the
7
+ * npm tarball. Two properties matter more than convenience and are enforced by
8
+ * `scripts/ci/check-skill-packs.mjs`:
9
+ *
10
+ * 1. **Pinned and verifiable.** Each pack is a single upstream commit; every
11
+ * vendored byte is recorded in `UPSTREAM.json` as a sha256. The SDK never
12
+ * fetches skill content at install or run time on a seat — vendoring is a
13
+ * reviewed commit, and the guard is what makes "reviewed" mean something.
14
+ * 2. **Markdown, not machinery.** The allow-list below takes skill prose and
15
+ * its reference files. It deliberately leaves behind every executable
16
+ * seam an upstream pack carries: hook manifests, launchers that download a
17
+ * binary on first run, browser-automation bundles and font-index data.
18
+ * Nothing in a vendored tree is ever executed by maestro.
19
+ *
20
+ * The allow-list is expressed as *rules* (one file, or one directory filtered
21
+ * by a regex) rather than a flat path list, because the syncer must be able to
22
+ * re-derive the tree from a fresh upstream checkout AND the guard must be able
23
+ * to decide, with no network, whether a path that exists on disk was allowed.
24
+ * {@link isAllowedDest} is that second half.
25
+ *
26
+ * Pure, dependency-light: Node builtins only, no I/O in this module.
27
+ *
28
+ * @module scripts/vendor/skill-packs
29
+ */
30
+
31
+ "use strict";
32
+
33
+ import { createHash } from "node:crypto";
34
+
35
+ /** @param {string} text */
36
+ function sha256Hex(text) {
37
+ return createHash("sha256").update(text).digest("hex");
38
+ }
39
+
40
+ /**
41
+ * @typedef {object} PackRule
42
+ * @property {"file"|"dir"} type
43
+ * @property {string} from path in the upstream tree (POSIX, repo-relative)
44
+ * @property {string} to path in the vendored pack (POSIX, pack-relative); "" = pack root
45
+ * @property {RegExp} [match] for `dir`: which basenames to take
46
+ * @property {boolean} [recursive] for `dir`: descend into subdirectories
47
+ */
48
+
49
+ /**
50
+ * @typedef {object} SkillPack
51
+ * @property {string} id directory under plugins/maestro-skills/vendor/
52
+ * @property {string} repo "<owner>/<name>" on github.com
53
+ * @property {string} sha the pinned commit
54
+ * @property {string} date the pinned commit's date (ISO, informational)
55
+ * @property {string} license SPDX id
56
+ * @property {PackRule[]} rules the allow-list
57
+ * @property {string[]} omitted what upstream carries that we deliberately drop
58
+ * @property {string[]} skillRoots pack-relative dirs that each hold one SKILL.md
59
+ * @property {string[]} [execAllowed] pack-relative dir prefixes where a file may carry an executable bit
60
+ * @property {string} notes
61
+ * @property {string} [contentSha256] {@link manifestDigest} of the vendored file list
62
+ * @property {Acknowledgement[]} [acknowledged] the supply-chain tokens this pack's prose is known to carry
63
+ */
64
+
65
+ /**
66
+ * One reviewed supply-chain token. Vendored prose is not code we run, but it IS
67
+ * read as instructions, and "fetch this and run it" is the same capability
68
+ * whether it arrives as `curl | sh`, `npx some-package`, or a CDN script tag in
69
+ * markup the reader is told to emit. The guard extracts a token for each such
70
+ * instruction it finds; a token with no entry here fails the build, which is
71
+ * how a re-sync that pulls in a NEW one stops rather than shipping.
72
+ *
73
+ * `covered` is the literal that must appear in
74
+ * `plugins/maestro-skills/skills/cohort-design.md`. Acknowledging a capability
75
+ * without telling a reader what to do instead is not a review, so the guard
76
+ * checks the prose too.
77
+ *
78
+ * @typedef {object} Acknowledgement
79
+ * @property {string} token
80
+ * @property {string} why
81
+ * @property {string} covered
82
+ */
83
+
84
+ /** Hosts a vendored file may legitimately point a fetch instruction at. */
85
+ export const FETCH_HOST_ALLOWLIST = Object.freeze([
86
+ "github.com",
87
+ "www.github.com",
88
+ "raw.githubusercontent.com",
89
+ "objects.githubusercontent.com",
90
+ "codeload.github.com",
91
+ "gist.github.com",
92
+ "api.github.com",
93
+ ]);
94
+
95
+ /**
96
+ * Basenames that ARE the hook machinery, wherever a pack keeps them. A vendored
97
+ * tree must never contain one: `install-hooks.mjs` writes a Stop hook into a
98
+ * settings file (its `--global` flag writes the one every session on the
99
+ * machine reads), and `stop-hook.mjs` is the body that hook runs. Stripping the
100
+ * executable bit is cosmetic — `node <file>` does not consult it — so the only
101
+ * honest neutralisation is absence.
102
+ */
103
+ export const HOOK_SCRIPT_BASENAMES = Object.freeze([
104
+ "install-hooks.mjs", "stop-hook.mjs", "install-hook.mjs", "hooks.mjs", "hook.mjs",
105
+ ]);
106
+
107
+ /**
108
+ * The digest of a manifest's file list — sha256 over `"<path> <sha256>"` lines,
109
+ * sorted, newline-terminated.
110
+ *
111
+ * This is what makes the allow-list a ratchet rather than a description. A
112
+ * per-file sha256 recorded in `UPSTREAM.json` proves only that the manifest and
113
+ * the tree agree with each other, so a single commit that adds a file AND its
114
+ * hash — a poisoned re-sync, a hand-edit with cover — is self-consistent and
115
+ * passes. Pinning this digest in THIS module, which nothing in a vendored tree
116
+ * can reach, means such a change must also edit a reviewed source file whose
117
+ * diff says "the vendored bytes changed" in one line.
118
+ *
119
+ * @param {Array<{path:string, sha256:string}>} files
120
+ * @returns {string}
121
+ */
122
+ export function manifestDigest(files) {
123
+ const lines = (files || [])
124
+ .map((f) => `${posix(f && f.path)} ${String((f && f.sha256) || "")}`)
125
+ .sort();
126
+ return sha256Hex(`${lines.join("\n")}\n`);
127
+ }
128
+
129
+ /** Every pack, in install order. @type {SkillPack[]} */
130
+ export const PACKS = Object.freeze([
131
+ {
132
+ id: "impeccable",
133
+ contentSha256: "0185da328c829c1d2265e3c61c608afc415103e07912a1e09cf05c6825c272f5",
134
+ repo: "pbakaus/impeccable",
135
+ sha: "cd12f8660e2dde57b9615c8a6b8ea674101f9cfc",
136
+ date: "2026-09-09",
137
+ license: "Apache-2.0",
138
+ skillRoots: ["."],
139
+ rules: [
140
+ { type: "file", from: ".claude/skills/impeccable/SKILL.md", to: "SKILL.md" },
141
+ { type: "dir", from: ".claude/skills/impeccable/reference", to: "reference", match: /\.md$/, recursive: true },
142
+ { type: "dir", from: ".claude/agents", to: "agents", match: /^impeccable-[a-z0-9-]+\.md$/, recursive: false },
143
+ { type: "file", from: "LICENSE", to: "LICENSE" },
144
+ { type: "file", from: "NOTICE.md", to: "NOTICE.md" },
145
+ ],
146
+ omitted: [
147
+ "hooks (plugin/hooks/hooks.json, .claude/settings.json) — maestro installs no hook from a vendored pack",
148
+ "skill scripts/ — the `impeccable` launcher downloads and runs a self-contained binary on first use; never run it on a seat",
149
+ "scripts/data/ (font-index.json, font-index-failures.json) — data for that launcher, ~20 MB",
150
+ "live-browser*.js, modern-screenshot.umd.js — live browser-automation mode, out of scope on a seat",
151
+ ".claude-plugin/ and the other per-agent manifest trees (.cursor/, .gemini/, plugin/, …)",
152
+ "crates/, cli/, extension/, browser-bundle/, tests/, docs/ — the engine repo around the skill",
153
+ ],
154
+ acknowledged: [
155
+ {
156
+ token: "npx:impeccable",
157
+ why: "reference/doctor.md and reference/hooks.md offer `npx impeccable update|detect|ignores` as the recovery path when the launcher is missing — which on a seat it always is, because scripts/ is not vendored. That is a registry fetch-and-execute and is exactly what vendoring exists to avoid.",
158
+ covered: "npx impeccable",
159
+ },
160
+ {
161
+ token: "hook-install-doc",
162
+ why: "reference/hooks.md is a full guide to writing the impeccable hook into .claude/settings.local.json, .codex/hooks.json, .cursor/hooks.json and .github/hooks/impeccable.json. The file is prose, not a manifest, so the no-manifest rule cannot see it.",
163
+ covered: "no hook from any of these packs is installed, and none should be",
164
+ },
165
+ ],
166
+ notes: "Skill 4.3.1, Apache-2.0. Markdown only: SKILL.md, reference/**.md and the four impeccable-* subordinate briefs. The SKILL text still describes its launcher; the cohort-design harmoniser overrides that — never run it, and never use live mode on a seat.",
167
+ },
168
+ {
169
+ id: "emilkowalski",
170
+ contentSha256: "2c8397c22777f6cd71f7ea91e729799ef4128932a39be0f6f8068c8c1dbb5b92",
171
+ repo: "emilkowalski/skills",
172
+ sha: "d23d7f88a2e21c9e4b1418c7abe420f5c1052ba7",
173
+ date: "2026-08-21",
174
+ license: "MIT",
175
+ skillRoots: [
176
+ "skills/emil-design-eng",
177
+ "skills/animate",
178
+ "skills/animation-vocabulary",
179
+ "skills/apple-design",
180
+ "skills/find-animation-opportunities",
181
+ "skills/improve-animations",
182
+ "skills/review-animations",
183
+ "skills/prototype",
184
+ ],
185
+ rules: [
186
+ { type: "dir", from: "skills/emil-design-eng", to: "skills/emil-design-eng", match: /\.md$/, recursive: false },
187
+ { type: "dir", from: "skills/animate", to: "skills/animate", match: /\.md$/, recursive: false },
188
+ { type: "dir", from: "skills/animation-vocabulary", to: "skills/animation-vocabulary", match: /\.md$/, recursive: false },
189
+ { type: "dir", from: "skills/apple-design", to: "skills/apple-design", match: /\.md$/, recursive: false },
190
+ { type: "dir", from: "skills/find-animation-opportunities", to: "skills/find-animation-opportunities", match: /\.md$/, recursive: false },
191
+ { type: "dir", from: "skills/improve-animations", to: "skills/improve-animations", match: /\.md$/, recursive: false },
192
+ { type: "dir", from: "skills/review-animations", to: "skills/review-animations", match: /\.md$/, recursive: false },
193
+ { type: "dir", from: "skills/prototype", to: "skills/prototype", match: /\.md$/, recursive: false },
194
+ { type: "file", from: "LICENSE", to: "LICENSE" },
195
+ ],
196
+ omitted: [
197
+ "skills/pick-ui-library — library choice is Cohort's, settled in the product repo",
198
+ "skills/ask-sonner — a single third-party toast library's API",
199
+ "skills/write-swift, skills/animate-expo — native platforms this fleet does not ship",
200
+ ],
201
+ acknowledged: [],
202
+ notes: "MIT. Motion and design-engineering craft. Precedence sits below Cohort's DESIGN.md for tokens and type; these govern easing, duration and restraint.",
203
+ },
204
+ {
205
+ id: "taste-skill",
206
+ contentSha256: "e63fea105e36e4418bf625cb091bc10a316b35f588ad146a38fce15f4a749c5e",
207
+ repo: "Leonxlnx/taste-skill",
208
+ sha: "ccbc15639c97057cbfcf32ecebc38ef716e4bb37",
209
+ date: "2026-08-24",
210
+ license: "MIT",
211
+ skillRoots: [
212
+ "skills/taste-skill",
213
+ "skills/redesign-skill",
214
+ "skills/soft-skill",
215
+ "skills/minimalist-skill",
216
+ ],
217
+ rules: [
218
+ { type: "dir", from: "skills/taste-skill", to: "skills/taste-skill", match: /\.md$/, recursive: false },
219
+ { type: "dir", from: "skills/redesign-skill", to: "skills/redesign-skill", match: /\.md$/, recursive: false },
220
+ { type: "dir", from: "skills/soft-skill", to: "skills/soft-skill", match: /\.md$/, recursive: false },
221
+ { type: "dir", from: "skills/minimalist-skill", to: "skills/minimalist-skill", match: /\.md$/, recursive: false },
222
+ { type: "file", from: "LICENSE", to: "LICENSE" },
223
+ ],
224
+ omitted: [
225
+ "skills/imagegen-frontend-web, skills/imagegen-frontend-mobile — image generation belongs to cohort-mcp design_generate_image",
226
+ "skills/brandkit — brand tokens are DESIGN.md's, never a skill's",
227
+ "skills/gpt-tasteskill, skills/stitch-skill — other vendors' model/tooling wrappers",
228
+ "skills/taste-skill-v1 — superseded by skills/taste-skill",
229
+ "skills/brutalist-skill, skills/output-skill, skills/image-to-code-skill — styles and behaviours outside the four the design ruling admitted",
230
+ "assets/, examples/, research/, scripts/, skill.sh, .claude-plugin/",
231
+ ],
232
+ acknowledged: [
233
+ {
234
+ token: "npx:shadcn@latest",
235
+ why: "skills/taste-skill/SKILL.md tells the reader to run `npx shadcn@latest init|add` to pull components. Registry fetch-and-execute; Cohort's component grammar comes from DESIGN.md.",
236
+ covered: "npx shadcn",
237
+ },
238
+ {
239
+ token: "pkg-install",
240
+ why: "skills/taste-skill/SKILL.md carries ~10 `npm install` lines for design-system packages (@material/web, @fluentui/*, @carbon/*, @radix-ui/themes, @primer/*, govuk-frontend, uswds, bootstrap). Adding a dependency is a decision the product repo makes, not a skill.",
241
+ covered: "Adding a dependency is the product repo's decision",
242
+ },
243
+ {
244
+ token: "remote-asset:cdn.shopify.com",
245
+ why: "skills/taste-skill/SKILL.md shows a <script src=\"https://cdn.shopify.com/shopifycloud/polaris.js\"> tag as sample markup. A third-party CDN script in shipped output is a supply-chain edge, not a design choice.",
246
+ covered: "never a remote script tag",
247
+ },
248
+ {
249
+ token: "template-url:picsum.photos",
250
+ why: "skills/taste-skill, skills/redesign-skill and skills/minimalist-skill all instruct hotlinking https://picsum.photos/seed/{...} placeholder photography into generated markup.",
251
+ covered: "picsum.photos",
252
+ },
253
+ {
254
+ token: "template-url:cdn.simpleicons.org",
255
+ why: "skills/taste-skill/SKILL.md instructs hotlinking https://cdn.simpleicons.org/{slug}/ffffff for brand icons. The asset kit is design_export_kit's.",
256
+ covered: "cdn.simpleicons.org",
257
+ },
258
+ ],
259
+ notes: "MIT. Marketing and site pages ONLY — these skills self-declare out of scope for dashboards, data tables, forms and product UI. Directory names differ from the frontmatter names: taste-skill=design-taste-frontend, redesign-skill=redesign-existing-projects, soft-skill=high-end-visual-design, minimalist-skill=minimalist-ui. Their em-dash ban does NOT apply to Cohort copy.",
260
+ },
261
+ {
262
+ id: "unlazy",
263
+ contentSha256: "07829533954d1c1aebc318fb8748adb262b4b25c56b9bea76ec1b5bb1b3ddd05",
264
+ repo: "Leonxlnx/unlazy",
265
+ sha: "16671491f6679ad9378f52604d3bc2415b4120c7",
266
+ date: "2026-09-03",
267
+ license: "MIT",
268
+ skillRoots: ["."],
269
+ execAllowed: ["scripts/"],
270
+ rules: [
271
+ { type: "file", from: "SKILL.md", to: "SKILL.md" },
272
+ { type: "file", from: "SECURITY.md", to: "SECURITY.md" },
273
+ { type: "file", from: "LICENSE", to: "LICENSE" },
274
+ { type: "dir", from: "references", to: "references", match: /\.md$/, recursive: false },
275
+ { type: "dir", from: "templates", to: "templates", match: /\.md$/, recursive: false },
276
+ // The gate checker and its library, and NOT the hook machinery: see
277
+ // HOOK_SCRIPT_BASENAMES below for why those two names are excluded here
278
+ // rather than merely discouraged in prose.
279
+ { type: "dir", from: "scripts", to: "scripts", match: /^(?!install-hooks\.mjs$|stop-hook\.mjs$)[\w.-]+\.mjs$/, recursive: true },
280
+ ],
281
+ omitted: [
282
+ "scripts/install-hooks.mjs and scripts/stop-hook.mjs — the Stop hook MACHINERY is not vendored at all, so it never reaches a seat; `node install-hooks.mjs --global` would have written a Stop hook into ~/.claude/settings.json for every session on the machine, and stripping an executable bit does not stop `node` from running a file",
283
+ "README.md, CHANGELOG.md, CONTRIBUTING.md, package.json, agents/openai.yaml",
284
+ "research/, tests/, .github/",
285
+ ],
286
+ acknowledged: [
287
+ {
288
+ token: "hook-install-doc",
289
+ why: "SKILL.md and SECURITY.md still describe unlazy's Stop hook and the settings files it would be written into. The two scripts that install and implement it are NOT vendored (see omitted[]), so the instruction has nothing to run — but the prose reaches the seat, and a reader who reconstructs the hook by hand gets the same fleet-wide blast radius.",
290
+ covered: "Never install unlazy's Stop hook",
291
+ },
292
+ ],
293
+ notes: "MIT. Completion gates for substantial work. scripts/ is vendored so the gate checker can be read and run deliberately by a person who chose to; nothing here is wired into a hook. The two files that INSTALL and IMPLEMENT unlazy's Stop hook (scripts/install-hooks.mjs, scripts/stop-hook.mjs) are deliberately absent from the vendored tree: a prohibition in prose does not survive a reader who takes SKILL.md's own install line at face value, so the machinery is simply not on the seat. SKILL.md still describes it; the cohort-design harmoniser forbids reconstructing it.",
294
+ },
295
+ ]);
296
+
297
+ /** @param {string} id @returns {SkillPack|null} */
298
+ export function findPack(id) {
299
+ return PACKS.find((p) => p.id === id) || null;
300
+ }
301
+
302
+ /** Normalise a path to POSIX separators with no leading "./". @param {string} p */
303
+ export function posix(p) {
304
+ return String(p == null ? "" : p).split("\\").join("/").replace(/^\.\//, "");
305
+ }
306
+
307
+ /**
308
+ * Is `dest` (pack-relative) a path this pack's allow-list admits? This is the
309
+ * half the CI guard needs: it answers with no upstream tree in hand, so a file
310
+ * someone dropped into a vendored directory by mistake — or on purpose — fails
311
+ * the build even though its sha256 would happily be recomputed.
312
+ *
313
+ * `UPSTREAM.json` is always allowed: it IS the manifest.
314
+ *
315
+ * @param {SkillPack} pack
316
+ * @param {string} dest
317
+ * @returns {boolean}
318
+ */
319
+ export function isAllowedDest(pack, dest) {
320
+ const d = posix(dest);
321
+ if (!d || d.startsWith("../") || d.includes("/../")) return false;
322
+ if (d === "UPSTREAM.json") return true;
323
+ for (const rule of (pack && pack.rules) || []) {
324
+ if (rule.type === "file") {
325
+ if (d === posix(rule.to)) return true;
326
+ continue;
327
+ }
328
+ const prefix = posix(rule.to);
329
+ const base = prefix ? `${prefix}/` : "";
330
+ if (!d.startsWith(base)) continue;
331
+ const rest = d.slice(base.length);
332
+ if (!rest) continue;
333
+ if (!rule.recursive && rest.includes("/")) continue;
334
+ const name = rest.slice(rest.lastIndexOf("/") + 1);
335
+ if (rule.match && !rule.match.test(name)) continue;
336
+ return true;
337
+ }
338
+ return false;
339
+ }
340
+
341
+ /**
342
+ * May `dest` carry an executable bit? Only where a pack declares it (unlazy's
343
+ * `scripts/`, whose upstream files are 0644 today but need not stay that way).
344
+ * @param {SkillPack} pack @param {string} dest
345
+ */
346
+ export function isExecAllowed(pack, dest) {
347
+ const d = posix(dest);
348
+ return ((pack && pack.execAllowed) || []).some((p) => d.startsWith(posix(p)));
349
+ }
350
+
351
+ export default {
352
+ PACKS, findPack, isAllowedDest, isExecAllowed, posix,
353
+ FETCH_HOST_ALLOWLIST, HOOK_SCRIPT_BASENAMES, manifestDigest,
354
+ };
@@ -0,0 +1,242 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * sync-skill-packs.mjs — re-vendor a pinned upstream design skill pack.
4
+ *
5
+ * Usage:
6
+ * node scripts/vendor/sync-skill-packs.mjs <pack>[ <pack> …] re-fetch and rewrite
7
+ * node scripts/vendor/sync-skill-packs.mjs --all
8
+ * node scripts/vendor/sync-skill-packs.mjs --list
9
+ * node scripts/vendor/sync-skill-packs.mjs <pack> --dry-run report, write nothing
10
+ * node scripts/vendor/sync-skill-packs.mjs --all --dry-run RE-VERIFY every
11
+ * pack against its pinned upstream commit. This is the only thing that
12
+ * establishes provenance: `check-skill-packs.mjs` runs offline and can
13
+ * only prove the vendored trees have not moved since review, never that
14
+ * they came from upstream. Run this when auditing, not on every commit.
15
+ *
16
+ * What it does, for each pack in `scripts/vendor/skill-packs.mjs`:
17
+ * 1. downloads `https://codeload.github.com/<repo>/tar.gz/<sha>` — the PINNED
18
+ * commit, never a branch — into a temp dir and extracts it with `tar`;
19
+ * 2. copies ONLY the paths the pack's allow-list admits into
20
+ * `plugins/maestro-skills/vendor/<pack>/`, deleting anything already there
21
+ * that the allow-list no longer admits;
22
+ * 3. rewrites `UPSTREAM.json` with `{repo, sha, date, license, files:[{path,
23
+ * sha256}], omitted, notes}`, sorted, so the diff of a re-sync is readable.
24
+ *
25
+ * This is a MAINTAINER tool. It is the only place in the SDK that fetches skill
26
+ * content, it runs on a developer's machine before a commit, and nothing on a
27
+ * seat ever calls it: seats get the reviewed bytes from the npm tarball. It
28
+ * never executes anything out of the downloaded tree.
29
+ *
30
+ * Node builtins only (plus the system `tar`, which macOS and Linux both ship).
31
+ *
32
+ * @module scripts/vendor/sync-skill-packs
33
+ */
34
+
35
+ "use strict";
36
+
37
+ import { createHash } from "node:crypto";
38
+ import { execFileSync } from "node:child_process";
39
+ import {
40
+ mkdtempSync, mkdirSync, rmSync, readdirSync, readFileSync, writeFileSync, statSync, existsSync, copyFileSync,
41
+ } from "node:fs";
42
+ import { tmpdir } from "node:os";
43
+ import path from "node:path";
44
+ import { fileURLToPath } from "node:url";
45
+ import { PACKS, findPack, posix, isAllowedDest, manifestDigest } from "./skill-packs.mjs";
46
+
47
+ const REPO_ROOT = path.resolve(fileURLToPath(new URL(".", import.meta.url)), "..", "..");
48
+
49
+ /** Where vendored packs live, relative to the repo root. */
50
+ export const VENDOR_REL = path.join("plugins", "maestro-skills", "vendor");
51
+
52
+ /** @param {string} p @returns {string} */
53
+ export function sha256File(p) {
54
+ return createHash("sha256").update(readFileSync(p)).digest("hex");
55
+ }
56
+
57
+ /** Recursively list files under `dir`, as paths relative to it (POSIX). */
58
+ export function listFiles(dir, prefix = "") {
59
+ let out = [];
60
+ let entries;
61
+ try {
62
+ entries = readdirSync(dir, { withFileTypes: true });
63
+ } catch {
64
+ return out; // an absent directory is an empty one for our purposes
65
+ }
66
+ for (const e of entries.sort((a, b) => (a.name < b.name ? -1 : 1))) {
67
+ const rel = prefix ? `${prefix}/${e.name}` : e.name;
68
+ if (e.isDirectory()) out = out.concat(listFiles(path.join(dir, e.name), rel));
69
+ else if (e.isFile()) out.push(rel);
70
+ }
71
+ return out;
72
+ }
73
+
74
+ /**
75
+ * Expand a pack's rules against a real upstream tree into {from, to} pairs.
76
+ * Pure over the injected lister so the planner is testable without a download.
77
+ *
78
+ * @param {import("./skill-packs.mjs").SkillPack} pack
79
+ * @param {string} srcRoot
80
+ * @param {{list?:(dir:string)=>string[], exists?:(p:string)=>boolean}} [deps]
81
+ * @returns {{ pairs: Array<{from:string,to:string}>, missing: string[] }}
82
+ */
83
+ export function planPack(pack, srcRoot, deps = {}) {
84
+ const list = deps.list || ((d) => listFiles(d));
85
+ const exists = deps.exists || existsSync;
86
+ const pairs = [];
87
+ const missing = [];
88
+ for (const rule of pack.rules) {
89
+ if (rule.type === "file") {
90
+ const abs = path.join(srcRoot, rule.from);
91
+ if (!exists(abs)) { missing.push(rule.from); continue; }
92
+ pairs.push({ from: rule.from, to: posix(rule.to) });
93
+ continue;
94
+ }
95
+ const absDir = path.join(srcRoot, rule.from);
96
+ if (!exists(absDir)) { missing.push(`${rule.from}/`); continue; }
97
+ let taken = 0;
98
+ for (const rel of list(absDir)) {
99
+ if (!rule.recursive && rel.includes("/")) continue;
100
+ const name = rel.slice(rel.lastIndexOf("/") + 1);
101
+ if (rule.match && !rule.match.test(name)) continue;
102
+ pairs.push({ from: `${rule.from}/${rel}`, to: posix(rule.to ? `${rule.to}/${rel}` : rel) });
103
+ taken += 1;
104
+ }
105
+ if (taken === 0) missing.push(`${rule.from}/ (matched nothing)`);
106
+ }
107
+ // A rule that produced a path the guard would reject is a registry bug, not a
108
+ // vendoring accident — say so loudly rather than writing an unverifiable tree.
109
+ for (const p of pairs) {
110
+ if (!isAllowedDest(pack, p.to)) throw new Error(`rule produced a path its own allow-list rejects: ${p.to}`);
111
+ }
112
+ pairs.sort((a, b) => (a.to < b.to ? -1 : a.to > b.to ? 1 : 0));
113
+ return { pairs, missing };
114
+ }
115
+
116
+ /** Download the pinned tarball and extract it; returns the extracted repo root. */
117
+ function fetchTree(pack, workDir) {
118
+ const url = `https://codeload.github.com/${pack.repo}/tar.gz/${pack.sha}`;
119
+ const tgz = path.join(workDir, "pack.tar.gz");
120
+ execFileSync("curl", ["-sSLf", "--max-time", "300", "-o", tgz, url], { stdio: ["ignore", "ignore", "pipe"] });
121
+ const outDir = path.join(workDir, "tree");
122
+ mkdirSync(outDir, { recursive: true });
123
+ execFileSync("tar", ["-xzf", tgz, "-C", outDir], { stdio: ["ignore", "ignore", "pipe"] });
124
+ const roots = readdirSync(outDir, { withFileTypes: true }).filter((e) => e.isDirectory());
125
+ if (roots.length !== 1) throw new Error(`unexpected tarball layout for ${pack.repo}: ${roots.length} top-level dirs`);
126
+ return path.join(outDir, roots[0].name);
127
+ }
128
+
129
+ /** Build the UPSTREAM.json body for a vendored pack. Pure. */
130
+ export function buildManifest(pack, files) {
131
+ return {
132
+ repo: pack.repo,
133
+ sha: pack.sha,
134
+ date: pack.date,
135
+ license: pack.license,
136
+ files: files.slice().sort((a, b) => (a.path < b.path ? -1 : 1)),
137
+ omitted: pack.omitted.slice(),
138
+ notes: pack.notes,
139
+ };
140
+ }
141
+
142
+ /**
143
+ * Re-vendor one pack. Returns a summary; throws only on a defect (no network,
144
+ * a moved upstream path, a rule that contradicts the allow-list).
145
+ * @param {string} id @param {{repoRoot?:string, dryRun?:boolean, log?:Function}} [o]
146
+ */
147
+ export function syncPack(id, o = {}) {
148
+ const pack = findPack(id);
149
+ if (!pack) throw new Error(`unknown pack "${id}" (known: ${PACKS.map((p) => p.id).join(", ")})`);
150
+ const repoRoot = o.repoRoot || REPO_ROOT;
151
+ const log = o.log || (() => {});
152
+ const destRoot = path.join(repoRoot, VENDOR_REL, pack.id);
153
+ const work = mkdtempSync(path.join(tmpdir(), `maestro-vendor-${pack.id}-`));
154
+ try {
155
+ const srcRoot = fetchTree(pack, work);
156
+ const { pairs, missing } = planPack(pack, srcRoot);
157
+ if (missing.length) throw new Error(`${pack.id}: upstream paths absent at ${pack.sha}: ${missing.join(", ")}`);
158
+ const wanted = new Set(pairs.map((p) => p.to));
159
+ const existingFiles = listFiles(destRoot);
160
+ const removed = existingFiles.filter((f) => f !== "UPSTREAM.json" && !wanted.has(f));
161
+ if (!o.dryRun) {
162
+ for (const rel of removed) rmSync(path.join(destRoot, rel), { force: true });
163
+ for (const p of pairs) {
164
+ const dest = path.join(destRoot, p.to);
165
+ mkdirSync(path.dirname(dest), { recursive: true });
166
+ copyFileSync(path.join(srcRoot, p.from), dest);
167
+ // Vendored content is data. Strip any executable bit the upstream tree
168
+ // carried unless the pack explicitly allows one there.
169
+ const mode = statSync(dest).mode & 0o777;
170
+ const want = 0o644;
171
+ if (mode !== want) execFileSync("chmod", ["644", dest]);
172
+ }
173
+ pruneEmptyDirs(destRoot);
174
+ }
175
+ const files = pairs.map((p) => ({
176
+ path: p.to,
177
+ sha256: o.dryRun ? sha256File(path.join(srcRoot, p.from)) : sha256File(path.join(destRoot, p.to)),
178
+ }));
179
+ const manifest = buildManifest(pack, files);
180
+ const manifestPath = path.join(destRoot, "UPSTREAM.json");
181
+ if (!o.dryRun) {
182
+ mkdirSync(destRoot, { recursive: true });
183
+ writeFileSync(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
184
+ }
185
+ // The content pin. `UPSTREAM.json` is written from the bytes it records, so
186
+ // it can only ever agree with itself; the digest below lives in
187
+ // skill-packs.mjs, a reviewed source file no vendored tree can reach, and is
188
+ // what makes a change to the vendored file list show up in a diff as one
189
+ // line rather than as a data blob nobody reads. A re-sync that shifts it is
190
+ // a real upstream change and wants a real look — hence the loud line.
191
+ const contentSha256 = manifestDigest(files);
192
+ const pinned = pack.contentSha256 || null;
193
+ if (pinned && pinned !== contentSha256) {
194
+ log(`${pack.id}: CONTENT CHANGED — review the diff, then set contentSha256: "${contentSha256}" in scripts/vendor/skill-packs.mjs (was ${pinned})`);
195
+ } else if (!pinned) {
196
+ log(`${pack.id}: set contentSha256: "${contentSha256}" in scripts/vendor/skill-packs.mjs`);
197
+ }
198
+ log(`${pack.id}: ${files.length} file(s) from ${pack.repo}@${pack.sha.slice(0, 12)}${removed.length ? `, ${removed.length} removed` : ""}${o.dryRun ? " (dry-run)" : ""}`);
199
+ return { pack: pack.id, files, removed, contentSha256, pinned, dryRun: !!o.dryRun };
200
+ } finally {
201
+ rmSync(work, { recursive: true, force: true });
202
+ }
203
+ }
204
+
205
+ /** Remove directories left empty after a prune. */
206
+ function pruneEmptyDirs(root) {
207
+ let entries;
208
+ try { entries = readdirSync(root, { withFileTypes: true }); } catch { return; }
209
+ for (const e of entries) {
210
+ if (!e.isDirectory()) continue;
211
+ const child = path.join(root, e.name);
212
+ pruneEmptyDirs(child);
213
+ try { if (readdirSync(child).length === 0) rmSync(child, { recursive: true, force: true }); } catch { /* a racing reader is not our problem */ }
214
+ }
215
+ }
216
+
217
+ async function main(argv) {
218
+ const args = argv.slice(2);
219
+ if (args.includes("--list") || args.length === 0) {
220
+ for (const p of PACKS) console.log(`${p.id.padEnd(14)} ${p.repo}@${p.sha.slice(0, 12)} ${p.license}`);
221
+ if (args.length === 0) console.log("\nusage: node scripts/vendor/sync-skill-packs.mjs <pack>|--all [--dry-run]");
222
+ return 0;
223
+ }
224
+ const dryRun = args.includes("--dry-run");
225
+ const ids = args.includes("--all") ? PACKS.map((p) => p.id) : args.filter((a) => !a.startsWith("--"));
226
+ let code = 0;
227
+ for (const id of ids) {
228
+ try {
229
+ syncPack(id, { dryRun, log: (m) => console.log(`sync-skill-packs: ${m}`) });
230
+ } catch (err) {
231
+ console.error(`sync-skill-packs: ${id} FAILED — ${err && err.message ? err.message : err}`);
232
+ code = 1;
233
+ }
234
+ }
235
+ return code;
236
+ }
237
+
238
+ if (import.meta.url === `file://${process.argv[1]}`) {
239
+ main(process.argv).then((c) => process.exit(c)).catch((e) => { console.error("sync-skill-packs: ERROR", e && e.message ? e.message : e); process.exit(2); });
240
+ }
241
+
242
+ export default { syncPack, planPack, buildManifest, listFiles, sha256File, VENDOR_REL };