@ethlete/agent-rules 0.1.0-next.5 → 0.1.0-next.51

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 (242) hide show
  1. package/AGENTS.md +28 -0
  2. package/CHANGELOG.md +759 -0
  3. package/CLAUDE.md +1 -0
  4. package/README.md +434 -25
  5. package/THIRD-PARTY-LICENSES.md +35 -0
  6. package/content/defaults.json +1 -1
  7. package/content/git-hooks/post-checkout.sh +10 -0
  8. package/content/git-hooks/pre-push.sh +5 -0
  9. package/content/hooks/away-mode.py +327 -0
  10. package/content/hooks/background-design-commands.py +228 -0
  11. package/content/hooks/builder-idle-check.py +397 -0
  12. package/content/hooks/context-warning.py +694 -134
  13. package/content/hooks/design-live-check.py +136 -0
  14. package/content/hooks/git-safety.py +213 -0
  15. package/content/hooks/human-wait-check.py +167 -0
  16. package/content/hooks/subagent-model-policy.py +261 -0
  17. package/content/mods/.claude-plugin/marketplace.json +26 -0
  18. package/content/mods/plugins/codex-runs/.claude-plugin/plugin.json +6 -0
  19. package/content/mods/plugins/codex-runs/hooks/hooks.json +1 -0
  20. package/content/mods/plugins/codex-runs/hooks/progress.ts +130 -0
  21. package/content/mods/plugins/codex-runs/hooks/register.tsx +103 -0
  22. package/content/mods/plugins/codex-runs/tsconfig.json +4 -0
  23. package/content/mods/plugins/codex-runs/types/index.d.ts +19 -0
  24. package/content/mods/plugins/e2e-progress/.claude-plugin/plugin.json +6 -0
  25. package/content/mods/plugins/e2e-progress/hooks/hooks.json +1 -0
  26. package/content/mods/plugins/e2e-progress/hooks/progress.ts +160 -0
  27. package/content/mods/plugins/e2e-progress/hooks/register.tsx +442 -0
  28. package/content/mods/plugins/e2e-progress/tsconfig.json +3 -0
  29. package/content/mods/plugins/e2e-progress/types/index.d.ts +26 -0
  30. package/content/mods/plugins/status-line/.claude-plugin/plugin.json +6 -0
  31. package/content/mods/plugins/status-line/hooks/hooks.json +1 -0
  32. package/content/mods/plugins/status-line/hooks/line.ts +74 -0
  33. package/content/mods/plugins/status-line/hooks/register.tsx +141 -0
  34. package/content/mods/plugins/status-line/types/index.d.ts +5 -0
  35. package/content/mods/plugins/usage-line/.claude-plugin/plugin.json +6 -0
  36. package/content/mods/plugins/usage-line/hooks/codex.ts +52 -0
  37. package/content/mods/plugins/usage-line/hooks/format.ts +24 -0
  38. package/content/mods/plugins/usage-line/hooks/hooks.json +1 -0
  39. package/content/mods/plugins/usage-line/hooks/register.tsx +67 -0
  40. package/content/mods/plugins/usage-line/tsconfig.json +4 -0
  41. package/content/mods/plugins/usage-line/types/index.d.ts +5 -0
  42. package/content/output-styles/ste-clarity.md +131 -0
  43. package/content/rules/agent-sessions-wake-up.md +11 -0
  44. package/content/rules/app-styling.md +66 -0
  45. package/content/rules/comments.md +4 -1
  46. package/content/rules/lint-and-format.md +7 -5
  47. package/content/rules/nx-layout.md +53 -0
  48. package/content/rules/reactive-state.md +1 -1
  49. package/content/rules/styling.md +19 -10
  50. package/content/rules/subagent-models.md +42 -0
  51. package/content/rules/waiting-on-the-human.md +17 -0
  52. package/content/skills/agent-sessions/SKILL.md +100 -0
  53. package/content/skills/agent-sessions/agent-sessions.mjs +1420 -0
  54. package/content/skills/angular-patterns/SKILL.md +31 -7
  55. package/content/skills/api-source/SKILL.md +156 -0
  56. package/content/skills/app-testing/SKILL.md +141 -0
  57. package/content/skills/codex-subagent/SKILL.md +96 -0
  58. package/content/skills/codex-subagent/codex-agent.mjs +229 -0
  59. package/content/skills/codex-subagent/codex-limit.mjs +106 -0
  60. package/content/skills/design-exploration/SKILL.md +203 -0
  61. package/content/skills/design-exploration/check-story.mjs +139 -0
  62. package/content/skills/design-exploration/reference-check-and-notes.md +101 -0
  63. package/content/skills/design-exploration/reference-flows.md +38 -0
  64. package/content/skills/design-exploration/reference-inbox-and-mcp.md +54 -0
  65. package/content/skills/design-exploration/reference-order-and-design-system.md +120 -0
  66. package/content/skills/design-exploration/reference-products-and-sketches.md +250 -0
  67. package/content/skills/design-exploration/reference-shots.md +25 -0
  68. package/content/skills/design-exploration/shoot-template.mjs +61 -0
  69. package/content/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  70. package/content/skills/domain-modeling/SKILL.md +71 -0
  71. package/content/skills/e2e-triage/SKILL.md +80 -0
  72. package/content/skills/figma-export/SKILL.md +16 -18
  73. package/content/skills/git-commit/SKILL.md +21 -7
  74. package/content/skills/git-flow/SKILL.md +87 -0
  75. package/content/skills/grill-with-docs/SKILL.md +13 -0
  76. package/content/skills/grilling/SKILL.md +52 -0
  77. package/content/skills/handoff/SKILL.md +29 -69
  78. package/content/skills/handoff/save.md +187 -0
  79. package/content/skills/query/SKILL.md +165 -70
  80. package/content/skills/report/SKILL.md +26 -0
  81. package/content/skills/rxjs-signals/SKILL.md +33 -4
  82. package/content/skills/sdk-docs/SKILL.md +50 -14
  83. package/content/skills/sdk-local-build/SKILL.md +26 -8
  84. package/content/skills/sdk-local-build/sdk-local-baseline.mjs +64 -0
  85. package/content/skills/sdk-source/SKILL.md +37 -34
  86. package/content/skills/sdk-update/SKILL.md +103 -0
  87. package/content/skills/story-styling/SKILL.md +12 -10
  88. package/content/skills/styleguide/SKILL.md +13 -8
  89. package/content/skills/styleguide/assets.md +54 -0
  90. package/content/skills/styleguide/changesets.md +17 -0
  91. package/content/skills/styleguide/file-structure.md +73 -0
  92. package/content/skills/styleguide/lint-rule-lookup.md +52 -0
  93. package/content/skills/styleguide/storybook-structure.md +25 -0
  94. package/content/skills/theming/SKILL.md +76 -49
  95. package/content/skills/timetrack/SKILL.md +324 -0
  96. package/content/skills/verify-in-app/SKILL.md +107 -0
  97. package/content/skills/verify-in-storybook/SKILL.md +1 -1
  98. package/migrations/list-state-query-form.md +20 -0
  99. package/migrations/nx-layout.md +29 -0
  100. package/migrations/sdk-components-over-hand-built-ui.md +27 -0
  101. package/migrations/search-query-field.md +52 -0
  102. package/migrations.json +39 -0
  103. package/package.json +19 -3
  104. package/src/index.js +99 -32
  105. package/src/index.js.map +1 -1
  106. package/src/lib/cli-args.d.ts +9 -0
  107. package/src/lib/cli-args.js +48 -0
  108. package/src/lib/cli-args.js.map +1 -0
  109. package/src/lib/commitlint.d.ts +10 -0
  110. package/src/lib/commitlint.js +51 -0
  111. package/src/lib/commitlint.js.map +1 -0
  112. package/src/lib/config.d.ts +68 -6
  113. package/src/lib/config.js +141 -11
  114. package/src/lib/config.js.map +1 -1
  115. package/src/lib/filter.d.ts +2 -0
  116. package/src/lib/filter.js +4 -4
  117. package/src/lib/filter.js.map +1 -1
  118. package/src/lib/frontmatter.d.ts +2 -0
  119. package/src/lib/frontmatter.js +33 -5
  120. package/src/lib/frontmatter.js.map +1 -1
  121. package/src/lib/git-flow/build.d.ts +35 -0
  122. package/src/lib/git-flow/build.js +24 -0
  123. package/src/lib/git-flow/build.js.map +1 -0
  124. package/src/lib/git-flow/config.d.ts +59 -0
  125. package/src/lib/git-flow/config.js +50 -0
  126. package/src/lib/git-flow/config.js.map +1 -0
  127. package/src/lib/git-flow/index.d.ts +6 -0
  128. package/src/lib/git-flow/index.js +23 -0
  129. package/src/lib/git-flow/index.js.map +1 -0
  130. package/src/lib/git-flow/parse.d.ts +49 -0
  131. package/src/lib/git-flow/parse.js +300 -0
  132. package/src/lib/git-flow/parse.js.map +1 -0
  133. package/src/lib/git-flow/rename.d.ts +24 -0
  134. package/src/lib/git-flow/rename.js +70 -0
  135. package/src/lib/git-flow/rename.js.map +1 -0
  136. package/src/lib/git-flow/start.d.ts +49 -0
  137. package/src/lib/git-flow/start.js +57 -0
  138. package/src/lib/git-flow/start.js.map +1 -0
  139. package/src/lib/git-flow/validate.d.ts +34 -0
  140. package/src/lib/git-flow/validate.js +72 -0
  141. package/src/lib/git-flow/validate.js.map +1 -0
  142. package/src/lib/git-flow-command.d.ts +4 -0
  143. package/src/lib/git-flow-command.js +165 -0
  144. package/src/lib/git-flow-command.js.map +1 -0
  145. package/src/lib/git-flow-repair.d.ts +17 -0
  146. package/src/lib/git-flow-repair.js +165 -0
  147. package/src/lib/git-flow-repair.js.map +1 -0
  148. package/src/lib/git-flow-start.d.ts +20 -0
  149. package/src/lib/git-flow-start.js +140 -0
  150. package/src/lib/git-flow-start.js.map +1 -0
  151. package/src/lib/git-test-env.fixtures.d.ts +11 -0
  152. package/src/lib/git-test-env.fixtures.js +31 -0
  153. package/src/lib/git-test-env.fixtures.js.map +1 -0
  154. package/src/lib/git.d.ts +64 -0
  155. package/src/lib/git.js +131 -0
  156. package/src/lib/git.js.map +1 -0
  157. package/src/lib/gitlab.d.ts +35 -0
  158. package/src/lib/gitlab.js +116 -0
  159. package/src/lib/gitlab.js.map +1 -0
  160. package/src/lib/index.d.ts +2 -0
  161. package/src/lib/index.js +26 -11
  162. package/src/lib/index.js.map +1 -1
  163. package/src/lib/migrate.js +8 -2
  164. package/src/lib/migrate.js.map +1 -1
  165. package/src/lib/output-style-command.d.ts +3 -0
  166. package/src/lib/output-style-command.js +69 -0
  167. package/src/lib/output-style-command.js.map +1 -0
  168. package/src/lib/output-style.d.ts +38 -0
  169. package/src/lib/output-style.js +134 -0
  170. package/src/lib/output-style.js.map +1 -0
  171. package/src/lib/owned-paths.js +8 -2
  172. package/src/lib/owned-paths.js.map +1 -1
  173. package/src/lib/package-runner.d.ts +4 -0
  174. package/src/lib/package-runner.js +86 -0
  175. package/src/lib/package-runner.js.map +1 -0
  176. package/src/lib/peer-path.d.ts +12 -0
  177. package/src/lib/peer-path.js +39 -0
  178. package/src/lib/peer-path.js.map +1 -0
  179. package/src/lib/plain-text.d.ts +9 -0
  180. package/src/lib/plain-text.js +22 -0
  181. package/src/lib/plain-text.js.map +1 -0
  182. package/src/lib/plan.d.ts +6 -6
  183. package/src/lib/plan.js +167 -39
  184. package/src/lib/plan.js.map +1 -1
  185. package/src/lib/prettier.d.ts +21 -0
  186. package/src/lib/prettier.js +51 -0
  187. package/src/lib/prettier.js.map +1 -0
  188. package/src/lib/prompt.d.ts +8 -0
  189. package/src/lib/prompt.js +35 -0
  190. package/src/lib/prompt.js.map +1 -0
  191. package/src/lib/render.d.ts +26 -2
  192. package/src/lib/render.js +45 -10
  193. package/src/lib/render.js.map +1 -1
  194. package/src/lib/report-command.d.ts +34 -0
  195. package/src/lib/report-command.js +316 -0
  196. package/src/lib/report-command.js.map +1 -0
  197. package/src/lib/sessions-command.d.ts +4 -0
  198. package/src/lib/sessions-command.js +16 -0
  199. package/src/lib/sessions-command.js.map +1 -0
  200. package/src/lib/sync.d.ts +1 -2
  201. package/src/lib/sync.js +37 -17
  202. package/src/lib/sync.js.map +1 -1
  203. package/src/lib/targets/agents-skills.js +1 -1
  204. package/src/lib/targets/agents-skills.js.map +1 -1
  205. package/src/lib/targets/claude-hooks.d.ts +5 -0
  206. package/src/lib/targets/claude-hooks.js +27 -4
  207. package/src/lib/targets/claude-hooks.js.map +1 -1
  208. package/src/lib/targets/claude-mods.d.ts +20 -0
  209. package/src/lib/targets/claude-mods.js +47 -0
  210. package/src/lib/targets/claude-mods.js.map +1 -0
  211. package/src/lib/targets/claude.js +2 -3
  212. package/src/lib/targets/claude.js.map +1 -1
  213. package/src/lib/targets/codex-hooks.js +4 -2
  214. package/src/lib/targets/codex-hooks.js.map +1 -1
  215. package/src/lib/targets/codex.js +4 -4
  216. package/src/lib/targets/codex.js.map +1 -1
  217. package/src/lib/targets/copilot.js +4 -4
  218. package/src/lib/targets/copilot.js.map +1 -1
  219. package/src/lib/targets/cursor.js +3 -3
  220. package/src/lib/targets/cursor.js.map +1 -1
  221. package/src/lib/targets/git-hooks.d.ts +25 -0
  222. package/src/lib/targets/git-hooks.js +71 -0
  223. package/src/lib/targets/git-hooks.js.map +1 -0
  224. package/src/lib/targets/hooks-shared.d.ts +29 -5
  225. package/src/lib/targets/hooks-shared.js +130 -36
  226. package/src/lib/targets/hooks-shared.js.map +1 -1
  227. package/src/lib/targets/mcp.d.ts +16 -0
  228. package/src/lib/targets/mcp.js +72 -0
  229. package/src/lib/targets/mcp.js.map +1 -0
  230. package/src/lib/targets/shared.d.ts +1 -9
  231. package/src/lib/targets/shared.js +4 -8
  232. package/src/lib/targets/shared.js.map +1 -1
  233. package/src/lib/timetrack-command.d.ts +11 -0
  234. package/src/lib/timetrack-command.js +1262 -0
  235. package/src/lib/timetrack-command.js.map +1 -0
  236. package/src/lib/timetrack-snapshot.d.ts +66 -0
  237. package/src/lib/timetrack-snapshot.js +146 -0
  238. package/src/lib/timetrack-snapshot.js.map +1 -0
  239. package/src/lib/timetrack.d.ts +607 -0
  240. package/src/lib/timetrack.js +285 -0
  241. package/src/lib/timetrack.js.map +1 -0
  242. package/content/skills/styleguide/STYLEGUIDE.md +0 -520
@@ -0,0 +1,20 @@
1
+ export declare const MOD_MARKETPLACE = "ethlete";
2
+ /**
3
+ * Claude Code mods a repo can opt into via the config's `mods` array. A mod runs code in every
4
+ * Claude Code session of the repo, so like the hooks it is never enabled by default.
5
+ */
6
+ export declare const KNOWN_MODS: string[];
7
+ export declare const assertKnownMods: (mods: string[]) => void;
8
+ /** Relative to the repo root. The settings file is committed, and an absolute path breaks on other machines. */
9
+ export declare const modMarketplacePath: (options: {
10
+ sdkProfile: boolean;
11
+ }) => "./libs/agent-rules/content/mods" | "./node_modules/@ethlete/agent-rules/content/mods";
12
+ /**
13
+ * Owns the `ethlete` marketplace entry and every `<mod>@ethlete` plugin entry: they are dropped and
14
+ * the configured mods re-added, so removing a mod from the config also disables it.
15
+ */
16
+ export declare const mergeModSettings: (options: {
17
+ existing: string;
18
+ mods: string[];
19
+ marketplacePath: string;
20
+ }) => string;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeModSettings = exports.modMarketplacePath = exports.assertKnownMods = exports.KNOWN_MODS = exports.MOD_MARKETPLACE = void 0;
4
+ exports.MOD_MARKETPLACE = 'ethlete';
5
+ /**
6
+ * Claude Code mods a repo can opt into via the config's `mods` array. A mod runs code in every
7
+ * Claude Code session of the repo, so like the hooks it is never enabled by default.
8
+ */
9
+ exports.KNOWN_MODS = ['codex-runs', 'e2e-progress', 'status-line', 'usage-line'];
10
+ const assertKnownMods = (mods) => {
11
+ const unknown = mods.filter((name) => !exports.KNOWN_MODS.includes(name));
12
+ if (unknown.length > 0) {
13
+ throw new Error(`Unknown mod(s): ${unknown.join(', ')}. Known mods: ${exports.KNOWN_MODS.join(', ')}.`);
14
+ }
15
+ };
16
+ exports.assertKnownMods = assertKnownMods;
17
+ /** Relative to the repo root. The settings file is committed, and an absolute path breaks on other machines. */
18
+ const modMarketplacePath = (options) => options.sdkProfile ? './libs/agent-rules/content/mods' : './node_modules/@ethlete/agent-rules/content/mods';
19
+ exports.modMarketplacePath = modMarketplacePath;
20
+ /**
21
+ * Owns the `ethlete` marketplace entry and every `<mod>@ethlete` plugin entry: they are dropped and
22
+ * the configured mods re-added, so removing a mod from the config also disables it.
23
+ */
24
+ const mergeModSettings = (options) => {
25
+ var _a, _b;
26
+ const { existing, mods, marketplacePath } = options;
27
+ const settings = JSON.parse(existing.trim() || '{}');
28
+ const marketplaces = Object.assign({}, ((_a = settings.extraKnownMarketplaces) !== null && _a !== void 0 ? _a : {}));
29
+ const plugins = Object.fromEntries(Object.entries((_b = settings.enabledPlugins) !== null && _b !== void 0 ? _b : {}).filter(([id]) => !id.endsWith(`@${exports.MOD_MARKETPLACE}`)));
30
+ delete marketplaces[exports.MOD_MARKETPLACE];
31
+ if (mods.length > 0) {
32
+ marketplaces[exports.MOD_MARKETPLACE] = { source: { source: 'directory', path: marketplacePath } };
33
+ for (const mod of mods)
34
+ plugins[`${mod}@${exports.MOD_MARKETPLACE}`] = true;
35
+ }
36
+ if (Object.keys(marketplaces).length > 0)
37
+ settings.extraKnownMarketplaces = marketplaces;
38
+ else
39
+ delete settings.extraKnownMarketplaces;
40
+ if (Object.keys(plugins).length > 0)
41
+ settings.enabledPlugins = plugins;
42
+ else
43
+ delete settings.enabledPlugins;
44
+ return `${JSON.stringify(settings, null, 2)}\n`;
45
+ };
46
+ exports.mergeModSettings = mergeModSettings;
47
+ //# sourceMappingURL=claude-mods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-mods.js","sourceRoot":"","sources":["../../../../../../libs/agent-rules/src/lib/targets/claude-mods.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,SAAS,CAAC;AAEzC;;;GAGG;AACU,QAAA,UAAU,GAAG,CAAC,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;AAE/E,MAAM,eAAe,GAAG,CAAC,IAAc,EAAE,EAAE;IAChD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,kBAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAElE,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,mBAAmB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,kBAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClG,CAAC;AACH,CAAC,CAAC;AANW,QAAA,eAAe,mBAM1B;AAEF,gHAAgH;AACzG,MAAM,kBAAkB,GAAG,CAAC,OAAgC,EAAE,EAAE,CACrE,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,kDAAkD,CAAC;AADjG,QAAA,kBAAkB,sBAC+E;AAO9G;;;GAGG;AACI,MAAM,gBAAgB,GAAG,CAAC,OAAsE,EAAE,EAAE;;IACzG,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,IAAI,CAAgB,CAAC;IACpE,MAAM,YAAY,qBAAQ,CAAC,MAAA,QAAQ,CAAC,sBAAsB,mCAAI,EAAE,CAAC,CAAE,CAAC;IACpE,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAChC,MAAM,CAAC,OAAO,CAAC,MAAA,QAAQ,CAAC,cAAc,mCAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,uBAAe,EAAE,CAAC,CAAC,CACpG,CAAC;IAEF,OAAO,YAAY,CAAC,uBAAe,CAAC,CAAC;IAErC,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,YAAY,CAAC,uBAAe,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,CAAC;QAE3F,KAAK,MAAM,GAAG,IAAI,IAAI;YAAE,OAAO,CAAC,GAAG,GAAG,IAAI,uBAAe,EAAE,CAAC,GAAG,IAAI,CAAC;IACtE,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,GAAG,CAAC;QAAE,QAAQ,CAAC,sBAAsB,GAAG,YAAY,CAAC;;QACpF,OAAO,QAAQ,CAAC,sBAAsB,CAAC;IAE5C,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC;QAAE,QAAQ,CAAC,cAAc,GAAG,OAAO,CAAC;;QAClE,OAAO,QAAQ,CAAC,cAAc,CAAC;IAEpC,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;AAClD,CAAC,CAAC;AAvBW,QAAA,gBAAgB,oBAuB3B"}
@@ -13,9 +13,8 @@ const quoteList = (values) => values.map((value) => ` - '${value}'`).join('\n')
13
13
  * rules directory is skipped entirely rather than loading everything twice.
14
14
  */
15
15
  const emitClaude = (context) => {
16
- const banner = (0, render_1.buildBanner)(context.version);
16
+ const fileBanner = (0, render_1.banner)((0, render_1.packageRunnerVar)(context.vars));
17
17
  const links = (0, shared_1.makeLinks)({
18
- context,
19
18
  skill: (name) => `the **\`ethlete-${name}\`** skill`,
20
19
  resource: (target) => `\`${target.fileName}\` (bundled next to this skill)`,
21
20
  });
@@ -26,7 +25,7 @@ const emitClaude = (context) => {
26
25
  const frontmatter = paths.length > 0 ? `---\npaths:\n${quoteList(paths)}\n---` : '';
27
26
  files.push({
28
27
  path: `.claude/rules/ethlete/${name}.md`,
29
- contents: (0, shared_1.document)([frontmatter, banner, (0, shared_1.body)({ item, context, links })]),
28
+ contents: (0, shared_1.document)([frontmatter, fileBanner, (0, shared_1.body)({ item, context, links })]),
30
29
  });
31
30
  }
32
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"claude.js","sourceRoot":"","sources":["../../../../../../libs/agent-rules/src/lib/targets/claude.ts"],"names":[],"mappings":";;;AAAA,sCAAwC;AACxC,qCAA4F;AAE5F,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,0BAA0B,IAAI,EAAE,CAAC;AAEpE,MAAM,SAAS,GAAG,CAAC,MAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAE3F;;;;;;GAMG;AACI,MAAM,UAAU,GAAG,CAAC,OAAoB,EAAiB,EAAE;IAChE,MAAM,MAAM,GAAG,IAAA,oBAAW,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,IAAA,kBAAS,EAAC;QACtB,OAAO;QACP,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,mBAAmB,IAAI,YAAY;QACpD,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,MAAM,CAAC,QAAQ,iCAAiC;KAC5E,CAAC,CAAC;IACH,MAAM,KAAK,GAAkB,EAAE,CAAC;IAEh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WAAW,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAC7F,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAzBW,QAAA,UAAU,cAyBrB"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.emitCodexHooks = exports.CODEX_HOOKS_FILE = void 0;
4
+ const render_1 = require("../render");
4
5
  const hooks_shared_1 = require("./hooks-shared");
5
6
  exports.CODEX_HOOKS_FILE = '.codex/hooks.json';
6
7
  const HOOKS_DIR = '.codex/hooks/ethlete';
@@ -16,10 +17,11 @@ const commandFor = (file) => `python3 "$(git rev-parse --show-toplevel)/${HOOKS_
16
17
  */
17
18
  const emitCodexHooks = (options) => {
18
19
  const { context, codexTarget, existingHooks } = options;
19
- const hooks = codexTarget ? context.hooks : [];
20
+ const hooks = codexTarget ? (0, hooks_shared_1.hooksForAgent)({ hooks: context.hooks, agent: 'codex' }) : [];
20
21
  return [
21
- ...(0, hooks_shared_1.emitHookScripts)({ hooks, hooksDir: HOOKS_DIR, version: context.version }),
22
+ ...(0, hooks_shared_1.emitHookScripts)({ hooks, hooksDir: HOOKS_DIR, runner: (0, render_1.packageRunnerVar)(context.vars) }),
22
23
  ...(0, hooks_shared_1.emitHookSettings)({
24
+ agent: 'codex',
23
25
  path: exports.CODEX_HOOKS_FILE,
24
26
  existing: existingHooks,
25
27
  hooks,
@@ -1 +1 @@
1
- {"version":3,"file":"codex-hooks.js","sourceRoot":"","sources":["../../../../../../libs/agent-rules/src/lib/targets/codex-hooks.ts"],"names":[],"mappings":";;;AACA,iDAAmE;AAEtD,QAAA,gBAAgB,GAAG,mBAAmB,CAAC;AAEpD,MAAM,SAAS,GAAG,sBAAsB,CAAC;AAEzC;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,6CAA6C,SAAS,IAAI,IAAI,iBAAiB,CAAC;AAErH;;;;G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AA,8BAAe,EAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,IAAA,yBAAgB,EAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1F,GAAG,IAAA,+BAAgB,EAAC;YAClB,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,wBAAgB;YACtB,QAAQ,EAAE,aAAa;YACvB,KAAK;YACL,QAAQ,EAAE,SAAS;YACnB,UAAU;YACV,eAAe,EAAE,KAAK;SACvB,CAAC;KACH,CAAC;AACJ,CAAC,CAAC;AApBW,QAAA,cAAc,kBAoBzB"}
@@ -13,15 +13,15 @@ exports.CODEX_FILE = 'AGENTS.md';
13
13
  */
14
14
  const emitCodex = (options) => {
15
15
  const { context, existing } = options;
16
- const sections = context.rules.map((item) => (0, shared_1.body)({ item, context, links: (0, shared_1.agentsSkillsLinks)(context) }));
16
+ const sections = context.rules.map((item) => (0, shared_1.body)({ item, context, links: (0, shared_1.agentsSkillsLinks)() }));
17
17
  if (context.skills.length > 0) {
18
18
  sections.push([
19
19
  '## Ethlete skills',
20
- "On-demand guides live in `.agents/skills/ethlete-*/SKILL.md`; each one's frontmatter says when to read it. If your agent does not discover skills on its own, list that directory and read the matching guide before starting that kind of work — do not work from memory.",
20
+ "On-demand package guides live in `.agents/skills/ethlete-*/SKILL.md`; `ethlete-agents sync` owns and updates them. Third-party skills may be tracked separately in `skills-lock.json`, while repository-authored skills are maintained by the repository. Each skill's frontmatter says when to read it. If your agent does not discover skills on its own, list the directory and read the matching guide before starting that kind of work — do not work from memory.",
21
21
  ].join('\n\n'));
22
22
  }
23
- const block = (0, shared_1.document)([(0, render_1.buildBanner)(context.version), ...sections]).trimEnd();
24
- return [{ path: exports.CODEX_FILE, contents: (0, render_1.replaceMarkedBlock)({ existing, block }) }];
23
+ const block = (0, shared_1.document)([(0, render_1.banner)((0, render_1.packageRunnerVar)(context.vars)), ...sections]).trimEnd();
24
+ return [{ path: exports.CODEX_FILE, contents: (0, render_1.replaceMarkedBlock)({ existing, block, file: exports.CODEX_FILE }) }];
25
25
  };
26
26
  exports.emitCodex = emitCodex;
27
27
  //# sourceMappingURL=codex.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"codex.js","sourceRoot":"","sources":["../../../../../../libs/agent-rules/src/lib/targets/codex.ts"],"names":[],"mappings":";;;AAAA,sCAA4D;AAC5D,qCAAuF;AAE1E,QAAA,UAAU,GAAG,WAAW,CAAC;AAEtC;;;;;;GAMG;AACI,MAAM,SAAS,GAAG,CAAC,OAAmD,EAAiB,EAAE;IAC9F,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,aAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAA,0BAAiB,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IAEzG,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,QAAQ,CAAC,IAAI,CACX;YACE,mBAAmB;YACnB,4QAA4Q;SAC7Q,CAAC,IAAI,CAAC,MAAM,CAAC,CACf,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,IAAA,iBAAQ,EAAC,CAAC,IAAA,oBAAW,EAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAE9E,OAAO,CAAC,EAAE,IAAI,EAAE,kBAAU,EAAE,QAAQ,EAAE,IAAA,2BAAkB,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;AACnF,CAAC,CAAC;AAhBW,QAAA,SAAS,aAgBpB"}
1
+ {"version":3,"file":"codex.js","sourceRoot":"","sources":["../../../../../../libs/agent-rules/src/lib/targets/codex.ts"],"names":[],"mappings":";;;AAAA,sCAAyE;AACzE,qCAAuF;AAE1E,QAAA,UAAU,GAAG,WAAW,CAAC;AAEtC;;;;;;GAMG;AACI,MAAM,SAAS,GAAG,CAAC,OAAmD,EAAiB,EAAE;IAC9F,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,aAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAA,0BAAiB,GAAE,EAAE,CAAC,CAAC,CAAC;IAElG,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,QAAQ,CAAC,IAAI,CACX;YACE,mBAAmB;YACnB,ycAAyc;SAC1c,CAAC,IAAI,CAAC,MAAM,CAAC,CACf,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,GAAG,IAAA,iBAAQ,EAAC,CAAC,IAAA,eAAM,EAAC,IAAA,yBAAgB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAExF,OAAO,CAAC,EAAE,IAAI,EAAE,kBAAU,EAAE,QAAQ,EAAE,IAAA,2BAAkB,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,kBAAU,EAAE,CAAC,EAAE,CAAC,CAAC;AACrG,CAAC,CAAC;AAhBW,QAAA,SAAS,aAgBpB"}
@@ -11,10 +11,10 @@ exports.COPILOT_FILE = '.github/copilot-instructions.md';
11
11
  */
12
12
  const emitCopilot = (options) => {
13
13
  const { context, existing } = options;
14
- const banner = (0, render_1.buildBanner)(context.version);
15
- const sections = context.rules.map((item) => (0, shared_1.body)({ item, context, links: (0, shared_1.agentsSkillsLinks)(context) }));
16
- const block = (0, shared_1.document)([banner, ...sections]).trimEnd();
17
- return [{ path: exports.COPILOT_FILE, contents: (0, render_1.replaceMarkedBlock)({ existing, block }) }];
14
+ const fileBanner = (0, render_1.banner)((0, render_1.packageRunnerVar)(context.vars));
15
+ const sections = context.rules.map((item) => (0, shared_1.body)({ item, context, links: (0, shared_1.agentsSkillsLinks)() }));
16
+ const block = (0, shared_1.document)([fileBanner, ...sections]).trimEnd();
17
+ return [{ path: exports.COPILOT_FILE, contents: (0, render_1.replaceMarkedBlock)({ existing, block, file: exports.COPILOT_FILE }) }];
18
18
  };
19
19
  exports.emitCopilot = emitCopilot;
20
20
  //# sourceMappingURL=copilot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"copilot.js","sourceRoot":"","sources":["../../../../../../libs/agent-rules/src/lib/targets/copilot.ts"],"names":[],"mappings":";;;AAAA,sCAA4D;AAC5D,qCAAuF;AAE1E,QAAA,YAAY,GAAG,iCAAiC,CAAC;AAE9D;;;;GAIG;AACI,MAAM,WAAW,GAAG,CAAC,OAAmD,EAAiB,EAAE;IAChG,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACtC,MAAM,MAAM,GAAG,IAAA,oBAAW,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,aAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAA,0BAAiB,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IACzG,MAAM,KAAK,GAAG,IAAA,iBAAQ,EAAC,CAAC,MAAM,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAExD,OAAO,CAAC,EAAE,IAAI,EAAE,oBAAY,EAAE,QAAQ,EAAE,IAAA,2BAAkB,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;AACrF,CAAC,CAAC;AAPW,QAAA,WAAW,eAOtB"}
1
+ {"version":3,"file":"copilot.js","sourceRoot":"","sources":["../../../../../../libs/agent-rules/src/lib/targets/copilot.ts"],"names":[],"mappings":";;;AAAA,sCAAyE;AACzE,qCAAuF;AAE1E,QAAA,YAAY,GAAG,iCAAiC,CAAC;AAE9D;;;;GAIG;AACI,MAAM,WAAW,GAAG,CAAC,OAAmD,EAAiB,EAAE;IAChG,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IACtC,MAAM,UAAU,GAAG,IAAA,eAAM,EAAC,IAAA,yBAAgB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1D,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,aAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,IAAA,0BAAiB,GAAE,EAAE,CAAC,CAAC,CAAC;IAClG,MAAM,KAAK,GAAG,IAAA,iBAAQ,EAAC,CAAC,UAAU,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAE5D,OAAO,CAAC,EAAE,IAAI,EAAE,oBAAY,EAAE,QAAQ,EAAE,IAAA,2BAAkB,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,oBAAY,EAAE,CAAC,EAAE,CAAC,CAAC;AACzG,CAAC,CAAC;AAPW,QAAA,WAAW,eAOtB"}
@@ -9,8 +9,8 @@ const shared_1 = require("./shared");
9
9
  * agentskills.io-aware tool.
10
10
  */
11
11
  const emitCursor = (context) => {
12
- const banner = (0, render_1.buildBanner)(context.version);
13
- const links = (0, shared_1.agentsSkillsLinks)(context);
12
+ const fileBanner = (0, render_1.banner)((0, render_1.packageRunnerVar)(context.vars));
13
+ const links = (0, shared_1.agentsSkillsLinks)();
14
14
  return context.rules.map((item) => {
15
15
  const { name, paths } = item.frontmatter;
16
16
  const frontmatter = [
@@ -22,7 +22,7 @@ const emitCursor = (context) => {
22
22
  ].join('\n');
23
23
  return {
24
24
  path: `.cursor/rules/ethlete-${name}.mdc`,
25
- contents: (0, shared_1.document)([frontmatter, banner, (0, shared_1.body)({ item, context, links })]),
25
+ contents: (0, shared_1.document)([frontmatter, fileBanner, (0, shared_1.body)({ item, context, links })]),
26
26
  };
27
27
  });
28
28
  };
@@ -1 +1 @@
1
- {"version":3,"file":"cursor.js","sourceRoot":"","sources":["../../../../../../libs/agent-rules/src/lib/targets/cursor.ts"],"names":[],"mappings":";;;AAAA,sCAAwC;AACxC,qCAAgH;AAEhH;;;;GAIG;AACI,MAAM,UAAU,GAAG,CAAC,OAAoB,EAAiB,EAAE;IAChE,MAAM,MAAM,GAAG,IAAA,oBAAW,EAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,IAAA,0BAAiB,EAAC,OAAO,CAAC,CAAC;IAEzC,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAChC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC;QACzC,MAAM,WAAW,GAAG;YAClB,KAAK;YACL,gBAAgB,IAAA,mBAAU,EAAC,IAAA,oBAAW,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE;YAC5D,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ;YACzD,mBAAmB;YACnB,KAAK;SACN,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEb,OAAO;YACL,IAAI,EAAE,yBAAyB,IAAI,MAAM;YACzC,QAAQ,EAAE,IAAA,iBAAQ,EAAC,CAAC,WAAW,EAAE,MAAM,EAAE,IAAA,aAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;SAC1E,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAnBW,QAAA,UAAU,cAmBrB"}
1
+ {"version":3,"file":"cursor.js","sourceRoot":"","sources":["../../../../../../libs/agent-rules/src/lib/targets/cursor.ts"],"names":[],"mappings":";;;AAAA,sCAAqD;AACrD,qCAAgH;AAEhH;;;;GAIG;AACI,MAAM,UAAU,GAAG,CAAC,OAAoB,EAAiB,EAAE;IAChE,MAAM,UAAU,GAAG,IAAA,eAAM,EAAC,IAAA,yBAAgB,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,IAAA,0BAAiB,GAAE,CAAC;IAElC,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAChC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC;QACzC,MAAM,WAAW,GAAG;YAClB,KAAK;YACL,gBAAgB,IAAA,mBAAU,EAAC,IAAA,oBAAW,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE;YAC5D,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ;YACzD,mBAAmB;YACnB,KAAK;SACN,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEb,OAAO;YACL,IAAI,EAAE,yBAAyB,IAAI,MAAM;YACzC,QAAQ,EAAE,IAAA,iBAAQ,EAAC,CAAC,WAAW,EAAE,UAAU,EAAE,IAAA,aAAI,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;SAC9E,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAnBW,QAAA,UAAU,cAmBrB"}
@@ -0,0 +1,25 @@
1
+ import { EmittedFile } from './shared';
2
+ export declare const HUSKY_DIR = ".husky";
3
+ export declare const START_MARKER = "# ethlete:git-flow:start";
4
+ export declare const END_MARKER = "# ethlete:git-flow:end";
5
+ /**
6
+ * Git hooks a repo can opt into via the config's `gitHooks` array. Like the agent hooks these never
7
+ * default: a generated block that can reject a developer's push is a higher-stakes artifact than a
8
+ * markdown one, so a repo asks for it.
9
+ */
10
+ export declare const KNOWN_GIT_HOOKS: Record<string, {
11
+ file: string;
12
+ }>;
13
+ export declare const assertKnownGitHooks: (hooks: string[]) => void;
14
+ export declare const huskyHookPath: (name: string) => string;
15
+ /**
16
+ * Appends the check to whatever the repo already has in `.husky/<name>`, between markers — those
17
+ * files routinely hold a git-lfs hook that must keep running and must keep reading stdin first,
18
+ * which is why the appended block never consumes it.
19
+ */
20
+ export declare const emitGitHooks: (options: {
21
+ gitHooks: string[];
22
+ huskyExists: boolean;
23
+ existing: Record<string, string>;
24
+ runner?: string;
25
+ }) => EmittedFile[];
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.emitGitHooks = exports.huskyHookPath = exports.assertKnownGitHooks = exports.KNOWN_GIT_HOOKS = exports.END_MARKER = exports.START_MARKER = exports.HUSKY_DIR = void 0;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ const load_content_1 = require("../load-content");
7
+ const render_1 = require("../render");
8
+ exports.HUSKY_DIR = '.husky';
9
+ exports.START_MARKER = '# ethlete:git-flow:start';
10
+ exports.END_MARKER = '# ethlete:git-flow:end';
11
+ /**
12
+ * Git hooks a repo can opt into via the config's `gitHooks` array. Like the agent hooks these never
13
+ * default: a generated block that can reject a developer's push is a higher-stakes artifact than a
14
+ * markdown one, so a repo asks for it.
15
+ */
16
+ exports.KNOWN_GIT_HOOKS = {
17
+ 'pre-push': { file: 'pre-push.sh' },
18
+ 'post-checkout': { file: 'post-checkout.sh' },
19
+ };
20
+ const assertKnownGitHooks = (hooks) => {
21
+ const unknown = hooks.filter((name) => !Object.prototype.hasOwnProperty.call(exports.KNOWN_GIT_HOOKS, name));
22
+ if (unknown.length > 0) {
23
+ throw new Error(`Unknown git hook(s): ${unknown.join(', ')}. Known git hooks: ${Object.keys(exports.KNOWN_GIT_HOOKS).join(', ')}.`);
24
+ }
25
+ };
26
+ exports.assertKnownGitHooks = assertKnownGitHooks;
27
+ const huskyHookPath = (name) => `${exports.HUSKY_DIR}/${name}`;
28
+ exports.huskyHookPath = huskyHookPath;
29
+ const SHEBANG = '#!/bin/sh\n';
30
+ const block = (options) => {
31
+ const { file, runner = 'npx' } = options;
32
+ const body = (0, fs_1.readFileSync)((0, path_1.join)((0, load_content_1.resolveContentRoot)(), 'git-hooks', file), 'utf8');
33
+ return [
34
+ `# Generated by @ethlete/agent-rules — DO NOT EDIT between the markers. Run \`${runner} ethlete-agents sync\`.`,
35
+ '# Set ETHLETE_GIT_FLOW_SKIP=1 to silence it on this machine.',
36
+ body.trimEnd(),
37
+ ].join('\n');
38
+ };
39
+ /**
40
+ * Appends the check to whatever the repo already has in `.husky/<name>`, between markers — those
41
+ * files routinely hold a git-lfs hook that must keep running and must keep reading stdin first,
42
+ * which is why the appended block never consumes it.
43
+ */
44
+ const emitGitHooks = (options) => {
45
+ const { gitHooks, huskyExists, existing, runner } = options;
46
+ if (!huskyExists)
47
+ return [];
48
+ return Object.entries(exports.KNOWN_GIT_HOOKS).flatMap(([name, definition]) => {
49
+ var _a;
50
+ const path = (0, exports.huskyHookPath)(name);
51
+ const current = (_a = existing[name]) !== null && _a !== void 0 ? _a : '';
52
+ if (!gitHooks.includes(name)) {
53
+ const stripped = (0, render_1.removeMarkedBlock)({ existing: current, startMarker: exports.START_MARKER, endMarker: exports.END_MARKER });
54
+ return stripped === current ? [] : [{ path, contents: stripped.trim().length > 0 ? stripped : SHEBANG }];
55
+ }
56
+ return [
57
+ {
58
+ path,
59
+ contents: (0, render_1.replaceMarkedBlock)({
60
+ existing: current.trim().length > 0 ? current : SHEBANG,
61
+ block: block({ file: definition.file, runner }),
62
+ file: path,
63
+ startMarker: exports.START_MARKER,
64
+ endMarker: exports.END_MARKER,
65
+ }),
66
+ },
67
+ ];
68
+ });
69
+ };
70
+ exports.emitGitHooks = emitGitHooks;
71
+ //# sourceMappingURL=git-hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-hooks.js","sourceRoot":"","sources":["../../../../../../libs/agent-rules/src/lib/targets/git-hooks.ts"],"names":[],"mappings":";;;AAAA,2BAAkC;AAClC,+BAA4B;AAC5B,kDAAqD;AACrD,sCAAkE;AAGrD,QAAA,SAAS,GAAG,QAAQ,CAAC;AAErB,QAAA,YAAY,GAAG,0BAA0B,CAAC;AAC1C,QAAA,UAAU,GAAG,wBAAwB,CAAC;AAEnD;;;;GAIG;AACU,QAAA,eAAe,GAAqC;IAC/D,UAAU,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE;IACnC,eAAe,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE;CAC9C,CAAC;AAEK,MAAM,mBAAmB,GAAG,CAAC,KAAe,EAAE,EAAE;IACrD,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,uBAAe,EAAE,IAAI,CAAC,CAAC,CAAC;IAErG,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,wBAAwB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,MAAM,CAAC,IAAI,CAAC,uBAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC3G,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AARW,QAAA,mBAAmB,uBAQ9B;AAEK,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,iBAAS,IAAI,IAAI,EAAE,CAAC;AAAzD,QAAA,a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QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QAC3G,CAAC;QAED,OAAO;YACL;gBACE,IAAI;gBACJ,QAAQ,EAAE,IAAA,2BAAkB,EAAC;oBAC3B,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO;oBACvD,KAAK,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;oBAC/C,IAAI,EAAE,IAAI;oBACV,WAAW,EAAE,oBAAY;oBACzB,SAAS,EAAE,kBAAU;iBACtB,CAAC;aACH;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAjCW,QAAA,YAAY,gBAiCvB"}
@@ -1,21 +1,43 @@
1
1
  import { EmittedFile } from './shared';
2
- type HookDefinition = {
2
+ type HookRegistration = {
3
3
  event: string;
4
+ /** Tool-name pattern for a tool-scoped event, so the script is not run on every tool call. */
5
+ matcher?: string;
6
+ /** Agents that have this event. Empty means every target that registers the hook gets it. */
7
+ agents?: string[];
8
+ };
9
+ type HookDefinition = {
10
+ events: HookRegistration[];
4
11
  file: string;
5
12
  timeout: number;
13
+ /** Agents that have the hook at all. Empty means every target registers it. */
14
+ agents?: string[];
15
+ /** Other hook scripts this one imports, emitted next to it without a registration of their own. */
16
+ libraries?: string[];
6
17
  };
7
18
  /**
8
19
  * Hooks a repo can opt into via the config's `hooks` array. Hooks run arbitrary commands on the
9
20
  * developer's machine, so unlike rules and skills they are never emitted by default.
10
21
  */
11
22
  export declare const KNOWN_HOOKS: Record<string, HookDefinition>;
23
+ /** Drops the hooks whose event the agent does not have, so neither script nor entry is emitted. */
24
+ export declare const hooksForAgent: (options: {
25
+ hooks: string[];
26
+ agent: string;
27
+ }) => string[];
28
+ /** The registrations of one hook that the given agent has the event for. */
29
+ export declare const eventsForAgent: (options: {
30
+ hook: string;
31
+ agent: string;
32
+ }) => HookRegistration[];
12
33
  export declare const assertKnownHooks: (hooks: string[]) => void;
13
34
  /**
14
- * Rewrites the generated entries declaratively: every entry whose command points into the
15
- * agent's `hooks/ethlete/` directory is dropped and the currently enabled hooks are re-added, so
16
- * disabling a hook in the config also unregisters it. Everything else in the file is untouched.
35
+ * Rewrites the generated entries declaratively: entries whose command points into the agent's
36
+ * `hooks/ethlete/` directory are updated in place, removed when the hook is disabled, and appended
37
+ * when new. Event and entry order of everything else in the file is untouched.
17
38
  */
18
39
  export declare const mergeHookSettings: (options: {
40
+ agent: string;
19
41
  existing: string;
20
42
  hooks: string[];
21
43
  hooksDir: string;
@@ -24,15 +46,17 @@ export declare const mergeHookSettings: (options: {
24
46
  export declare const emitHookScripts: (options: {
25
47
  hooks: string[];
26
48
  hooksDir: string;
27
- version: string;
49
+ runner?: string;
28
50
  }) => EmittedFile[];
29
51
  /** Only planned when the parsed content actually changes; an unparseable file is left alone. */
30
52
  export declare const emitHookSettings: (options: {
53
+ agent: string;
31
54
  path: string;
32
55
  existing: string;
33
56
  hooks: string[];
34
57
  hooksDir: string;
35
58
  commandFor: (file: string) => string;
36
59
  createWhenEmpty: boolean;
60
+ mergeExtra?: (merged: string) => string;
37
61
  }) => EmittedFile[];
38
62
  export {};
@@ -1,62 +1,153 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.emitHookSettings = exports.emitHookScripts = exports.mergeHookSettings = exports.assertKnownHooks = exports.KNOWN_HOOKS = void 0;
3
+ exports.emitHookSettings = exports.emitHookScripts = exports.mergeHookSettings = exports.assertKnownHooks = exports.eventsForAgent = exports.hooksForAgent = exports.KNOWN_HOOKS = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const path_1 = require("path");
6
6
  const load_content_1 = require("../load-content");
7
+ const render_1 = require("../render");
7
8
  /**
8
9
  * Hooks a repo can opt into via the config's `hooks` array. Hooks run arbitrary commands on the
9
10
  * developer's machine, so unlike rules and skills they are never emitted by default.
10
11
  */
11
12
  exports.KNOWN_HOOKS = {
12
- 'context-warning': { event: 'UserPromptSubmit', file: 'context-warning.py', timeout: 10 },
13
+ 'context-warning': {
14
+ events: [
15
+ { event: 'UserPromptSubmit' },
16
+ // Codex has none of the three below, so its registration stays prompt-only.
17
+ { event: 'SessionStart', agents: ['claude'] },
18
+ // The only event between an agent's own model requests, and the only way a warning
19
+ // reaches a long autonomous run before the user sends a message.
20
+ { event: 'PostToolBatch', agents: ['claude'] },
21
+ { event: 'Stop', agents: ['claude'] },
22
+ { event: 'SubagentStop', agents: ['claude'] },
23
+ ],
24
+ file: 'context-warning.py',
25
+ timeout: 10,
26
+ },
27
+ 'subagent-model-policy': {
28
+ events: [{ event: 'PreToolUse', matcher: 'Task|Agent' }],
29
+ file: 'subagent-model-policy.py',
30
+ timeout: 10,
31
+ agents: ['claude'],
32
+ },
33
+ 'away-mode': {
34
+ events: [{ event: 'UserPromptSubmit' }, { event: 'PostToolUse', matcher: 'Skill' }],
35
+ file: 'away-mode.py',
36
+ timeout: 10,
37
+ agents: ['claude'],
38
+ },
39
+ 'background-design-commands': {
40
+ events: [{ event: 'PreToolUse', matcher: 'Bash' }],
41
+ file: 'background-design-commands.py',
42
+ timeout: 10,
43
+ agents: ['claude'],
44
+ },
45
+ 'design-live-check': {
46
+ events: [{ event: 'PostToolUse', matcher: 'Edit|Write|MultiEdit' }],
47
+ file: 'design-live-check.py',
48
+ timeout: 60,
49
+ agents: ['claude'],
50
+ },
51
+ 'builder-idle-check': {
52
+ events: [{ event: 'Stop' }],
53
+ file: 'builder-idle-check.py',
54
+ timeout: 10,
55
+ agents: ['claude'],
56
+ },
57
+ 'human-wait-check': {
58
+ events: [{ event: 'Stop' }],
59
+ file: 'human-wait-check.py',
60
+ timeout: 10,
61
+ agents: ['claude'],
62
+ libraries: ['builder-idle-check.py'],
63
+ },
64
+ 'git-safety': {
65
+ events: [{ event: 'PreToolUse', matcher: 'Bash' }],
66
+ file: 'git-safety.py',
67
+ timeout: 10,
68
+ agents: ['claude'],
69
+ },
13
70
  };
71
+ /** Drops the hooks whose event the agent does not have, so neither script nor entry is emitted. */
72
+ const hooksForAgent = (options) => options.hooks.filter((name) => {
73
+ var _a, _b;
74
+ const agents = (_b = (_a = exports.KNOWN_HOOKS[name]) === null || _a === void 0 ? void 0 : _a.agents) !== null && _b !== void 0 ? _b : [];
75
+ return agents.length === 0 || agents.includes(options.agent);
76
+ });
77
+ exports.hooksForAgent = hooksForAgent;
78
+ /** The registrations of one hook that the given agent has the event for. */
79
+ const eventsForAgent = (options) => {
80
+ var _a, _b;
81
+ return ((_b = (_a = exports.KNOWN_HOOKS[options.hook]) === null || _a === void 0 ? void 0 : _a.events) !== null && _b !== void 0 ? _b : []).filter((registration) => { var _a, _b; return ((_a = registration.agents) !== null && _a !== void 0 ? _a : []).length === 0 || ((_b = registration.agents) === null || _b === void 0 ? void 0 : _b.includes(options.agent)); });
82
+ };
83
+ exports.eventsForAgent = eventsForAgent;
14
84
  const assertKnownHooks = (hooks) => {
15
- const unknown = hooks.filter((name) => !(name in exports.KNOWN_HOOKS));
85
+ const unknown = hooks.filter((name) => !Object.prototype.hasOwnProperty.call(exports.KNOWN_HOOKS, name));
16
86
  if (unknown.length > 0) {
17
87
  throw new Error(`Unknown hook(s): ${unknown.join(', ')}. Known hooks: ${Object.keys(exports.KNOWN_HOOKS).join(', ')}.`);
18
88
  }
19
89
  };
20
90
  exports.assertKnownHooks = assertKnownHooks;
21
- /** `#` comment instead of the HTML banner, placed after the shebang so the file stays runnable. */
22
- const withBanner = (raw, version) => {
91
+ /** Placed after the shebang so the file stays runnable. */
92
+ const withBanner = (raw, runner) => {
23
93
  var _a;
24
- const banner = `# Generated by @ethlete/agent-rules v${version} — DO NOT EDIT. Run \`npx ethlete-agents sync\`.`;
25
94
  const lines = raw.split('\n');
26
95
  if ((_a = lines[0]) === null || _a === void 0 ? void 0 : _a.startsWith('#!'))
27
- return [lines[0], banner, ...lines.slice(1)].join('\n');
28
- return `${banner}\n${raw}`;
96
+ return [lines[0], (0, render_1.shellBanner)(runner), ...lines.slice(1)].join('\n');
97
+ return `${(0, render_1.shellBanner)(runner)}\n${raw}`;
29
98
  };
30
99
  /**
31
- * Rewrites the generated entries declaratively: every entry whose command points into the
32
- * agent's `hooks/ethlete/` directory is dropped and the currently enabled hooks are re-added, so
33
- * disabling a hook in the config also unregisters it. Everything else in the file is untouched.
100
+ * Rewrites the generated entries declaratively: entries whose command points into the agent's
101
+ * `hooks/ethlete/` directory are updated in place, removed when the hook is disabled, and appended
102
+ * when new. Event and entry order of everything else in the file is untouched.
34
103
  */
35
104
  const mergeHookSettings = (options) => {
36
- var _a, _b;
37
- const { existing, hooks, hooksDir, commandFor } = options;
105
+ var _a, _b, _c, _d, _e, _f;
106
+ var _g;
107
+ const { agent, existing, hooks, hooksDir, commandFor } = options;
38
108
  const settings = JSON.parse(existing.trim() || '{}');
39
109
  const events = Object.assign({}, ((_a = settings.hooks) !== null && _a !== void 0 ? _a : {}));
110
+ const desired = {};
111
+ for (const name of hooks) {
112
+ const definition = exports.KNOWN_HOOKS[name];
113
+ if (!definition)
114
+ continue;
115
+ for (const registration of (0, exports.eventsForAgent)({ hook: name, agent })) {
116
+ const command = commandFor(definition.file);
117
+ ((_b = desired[_g = registration.event]) !== null && _b !== void 0 ? _b : (desired[_g] = new Map())).set(command, Object.assign(Object.assign({}, (registration.matcher ? { matcher: registration.matcher } : {})), { hooks: [{ type: 'command', command, timeout: definition.timeout }] }));
118
+ }
119
+ }
120
+ const isManaged = (hook) => { var _a; return ((_a = hook.command) !== null && _a !== void 0 ? _a : '').includes(`${hooksDir}/`); };
40
121
  for (const [event, groups] of Object.entries(events)) {
41
- const kept = groups
42
- .map((group) => {
43
- var _a;
44
- return (Object.assign(Object.assign({}, group), { hooks: ((_a = group.hooks) !== null && _a !== void 0 ? _a : []).filter((hook) => { var _a; return !((_a = hook.command) !== null && _a !== void 0 ? _a : '').includes(hooksDir); }) }));
45
- })
46
- .filter((group) => group.hooks.length > 0);
122
+ const wanted = (_c = desired[event]) !== null && _c !== void 0 ? _c : new Map();
123
+ const kept = [];
124
+ for (const group of groups) {
125
+ const all = (_d = group.hooks) !== null && _d !== void 0 ? _d : [];
126
+ const managed = all.filter(isManaged);
127
+ if (managed.length === 0) {
128
+ kept.push(group);
129
+ continue;
130
+ }
131
+ const rest = all.filter((hook) => !isManaged(hook));
132
+ if (rest.length > 0)
133
+ kept.push(Object.assign(Object.assign({}, group), { hooks: rest }));
134
+ const command = (_f = (_e = managed[0]) === null || _e === void 0 ? void 0 : _e.command) !== null && _f !== void 0 ? _f : '';
135
+ const replacement = wanted.get(command);
136
+ if (replacement && rest.length === 0) {
137
+ kept.push(replacement);
138
+ wanted.delete(command);
139
+ }
140
+ }
141
+ kept.push(...wanted.values());
142
+ delete desired[event];
47
143
  if (kept.length > 0)
48
144
  events[event] = kept;
49
145
  else
50
146
  delete events[event];
51
147
  }
52
- for (const name of hooks) {
53
- const definition = exports.KNOWN_HOOKS[name];
54
- if (!definition)
55
- continue;
56
- events[definition.event] = [
57
- ...((_b = events[definition.event]) !== null && _b !== void 0 ? _b : []),
58
- { hooks: [{ type: 'command', command: commandFor(definition.file), timeout: definition.timeout }] },
59
- ];
148
+ for (const [event, wanted] of Object.entries(desired)) {
149
+ if (wanted.size > 0)
150
+ events[event] = [...wanted.values()];
60
151
  }
61
152
  if (Object.keys(events).length > 0)
62
153
  settings.hooks = events;
@@ -66,23 +157,26 @@ const mergeHookSettings = (options) => {
66
157
  };
67
158
  exports.mergeHookSettings = mergeHookSettings;
68
159
  const emitHookScripts = (options) => {
69
- const { hooks, hooksDir, version } = options;
70
- return hooks.flatMap((name) => {
160
+ const { hooks, hooksDir, runner } = options;
161
+ const files = new Set(hooks.flatMap((name) => {
162
+ var _a;
71
163
  const definition = exports.KNOWN_HOOKS[name];
72
- if (!definition)
73
- return [];
74
- const raw = (0, fs_1.readFileSync)((0, path_1.join)((0, load_content_1.resolveContentRoot)(), 'hooks', definition.file), 'utf8');
75
- return [{ path: `${hooksDir}/${definition.file}`, contents: withBanner(raw, version) }];
76
- });
164
+ return definition ? [definition.file, ...((_a = definition.libraries) !== null && _a !== void 0 ? _a : [])] : [];
165
+ }));
166
+ return [...files].map((file) => ({
167
+ path: `${hooksDir}/${file}`,
168
+ contents: withBanner((0, fs_1.readFileSync)((0, path_1.join)((0, load_content_1.resolveContentRoot)(), 'hooks', file), 'utf8'), runner),
169
+ }));
77
170
  };
78
171
  exports.emitHookScripts = emitHookScripts;
79
172
  /** Only planned when the parsed content actually changes; an unparseable file is left alone. */
80
173
  const emitHookSettings = (options) => {
81
- const { path, existing, hooks, hooksDir, commandFor, createWhenEmpty } = options;
174
+ const { agent, path, existing, hooks, hooksDir, commandFor, createWhenEmpty, mergeExtra } = options;
82
175
  if (existing.trim().length === 0 && hooks.length === 0 && !createWhenEmpty)
83
176
  return [];
84
177
  try {
85
- const merged = (0, exports.mergeHookSettings)({ existing, hooks, hooksDir, commandFor });
178
+ const hookMerged = (0, exports.mergeHookSettings)({ agent, existing, hooks, hooksDir, commandFor });
179
+ const merged = mergeExtra ? mergeExtra(hookMerged) : hookMerged;
86
180
  if (JSON.stringify(JSON.parse(existing.trim() || '{}')) === JSON.stringify(JSON.parse(merged)))
87
181
  return [];
88
182
  return [{ path, contents: merged }];