self-evolving-workflow 0.0.0-stage → 0.1.4

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 (375) hide show
  1. package/LICENSE +27 -0
  2. package/README.md +195 -2
  3. package/dist/agent-memory-prompts.d.ts +13 -0
  4. package/dist/agent-memory-prompts.js +55 -0
  5. package/dist/cli.d.ts +2 -0
  6. package/dist/cli.js +6 -0
  7. package/dist/closeout.d.ts +105 -0
  8. package/dist/closeout.js +473 -0
  9. package/dist/code.d.ts +39 -0
  10. package/dist/code.js +124 -0
  11. package/dist/codex-memory.d.ts +24 -0
  12. package/dist/codex-memory.js +217 -0
  13. package/dist/common.d.ts +16 -0
  14. package/dist/common.js +52 -0
  15. package/dist/context-envelope.d.ts +59 -0
  16. package/dist/context-envelope.js +23 -0
  17. package/dist/host-adapters.d.ts +34 -0
  18. package/dist/host-adapters.js +151 -0
  19. package/dist/http.d.ts +3 -0
  20. package/dist/http.js +90 -0
  21. package/dist/index.d.ts +16 -0
  22. package/dist/index.js +13 -0
  23. package/dist/knowledge-cli.d.ts +198 -0
  24. package/dist/knowledge-cli.js +761 -0
  25. package/dist/knowledge-reads.d.ts +72 -0
  26. package/dist/knowledge-reads.js +201 -0
  27. package/dist/memory-config.d.ts +44 -0
  28. package/dist/memory-config.js +204 -0
  29. package/dist/memory-evidence.d.ts +13 -0
  30. package/dist/memory-evidence.js +40 -0
  31. package/dist/memory-history.d.ts +46 -0
  32. package/dist/memory-history.js +432 -0
  33. package/dist/memory.d.ts +96 -0
  34. package/dist/memory.js +362 -0
  35. package/dist/retrospective.d.ts +57 -0
  36. package/dist/retrospective.js +240 -0
  37. package/dist/search.d.ts +36 -0
  38. package/dist/search.js +112 -0
  39. package/dist/skill-addition.d.ts +25 -0
  40. package/dist/skill-addition.js +89 -0
  41. package/dist/skill-design.d.ts +96 -0
  42. package/dist/skill-design.js +226 -0
  43. package/dist/skill-replay.d.ts +55 -0
  44. package/dist/skill-replay.js +448 -0
  45. package/dist/skill-route.d.ts +30 -0
  46. package/dist/skill-route.js +75 -0
  47. package/dist/transcript-evidence.d.ts +3 -0
  48. package/dist/transcript-evidence.js +58 -0
  49. package/dist/upstream/chunker.d.ts +24 -0
  50. package/dist/upstream/chunker.js +96 -0
  51. package/dist/upstream/file-protocol.d.ts +45 -0
  52. package/dist/upstream/file-protocol.js +117 -0
  53. package/dist/upstream/frontmatter.d.ts +47 -0
  54. package/dist/upstream/frontmatter.js +86 -0
  55. package/dist/upstream/graph-search.d.ts +33 -0
  56. package/dist/upstream/graph-search.js +67 -0
  57. package/dist/upstream/l1-extraction.d.ts +26 -0
  58. package/dist/upstream/l1-extraction.js +405 -0
  59. package/dist/upstream/llm.d.ts +8 -0
  60. package/dist/upstream/llm.js +1 -0
  61. package/dist/upstream/merge.d.ts +50 -0
  62. package/dist/upstream/merge.js +153 -0
  63. package/dist/upstream/prompts.d.ts +53 -0
  64. package/dist/upstream/prompts.js +181 -0
  65. package/dist/upstream/search-utils.d.ts +34 -0
  66. package/dist/upstream/search-utils.js +55 -0
  67. package/dist/upstream/slug.d.ts +26 -0
  68. package/dist/upstream/slug.js +103 -0
  69. package/dist/upstream/template.d.ts +29 -0
  70. package/dist/upstream/template.js +80 -0
  71. package/dist/upstream/tokenize.d.ts +4 -0
  72. package/dist/upstream/tokenize.js +29 -0
  73. package/dist/wiki-change.d.ts +76 -0
  74. package/dist/wiki-change.js +299 -0
  75. package/dist/wiki-entry.d.ts +26 -0
  76. package/dist/wiki-entry.js +93 -0
  77. package/dist/wiki-ingest.d.ts +12 -0
  78. package/dist/wiki-ingest.js +126 -0
  79. package/dist/wiki-migration.d.ts +16 -0
  80. package/dist/wiki-migration.js +268 -0
  81. package/dist/wiki-tokens.d.ts +1 -0
  82. package/dist/wiki-tokens.js +46 -0
  83. package/dist/wiki.d.ts +103 -0
  84. package/dist/wiki.js +330 -0
  85. package/dist/workflow-cli.d.ts +2 -0
  86. package/dist/workflow-cli.js +319 -0
  87. package/dist/workflow-install.d.ts +37 -0
  88. package/dist/workflow-install.js +148 -0
  89. package/dist/workflow-knowledge.d.ts +18 -0
  90. package/dist/workflow-knowledge.js +32 -0
  91. package/dist/workflow-mcp.d.ts +2 -0
  92. package/dist/workflow-mcp.js +137 -0
  93. package/dist/workflow-names.d.ts +4 -0
  94. package/dist/workflow-names.js +31 -0
  95. package/dist/workflow-runtime.d.ts +735 -0
  96. package/dist/workflow-runtime.js +747 -0
  97. package/dist/workflow-skills.d.ts +48 -0
  98. package/dist/workflow-skills.js +141 -0
  99. package/docs/images/impeccable-skill.png +0 -0
  100. package/docs/images/workflow-overview.png +0 -0
  101. package/docs/images/workflow-skills.png +0 -0
  102. package/package.json +77 -4
  103. package/skills/ew-impeccable/LICENSE +191 -0
  104. package/skills/ew-impeccable/NOTICE.md +19 -0
  105. package/skills/ew-impeccable/SKILL.md +91 -0
  106. package/skills/ew-impeccable/UPSTREAM.md +23 -0
  107. package/skills/ew-impeccable/reference/adapt.md +314 -0
  108. package/skills/ew-impeccable/reference/adapt.native.md +60 -0
  109. package/skills/ew-impeccable/reference/android.md +46 -0
  110. package/skills/ew-impeccable/reference/animate.md +91 -0
  111. package/skills/ew-impeccable/reference/audit.md +138 -0
  112. package/skills/ew-impeccable/reference/audit.native.md +141 -0
  113. package/skills/ew-impeccable/reference/bolder.md +35 -0
  114. package/skills/ew-impeccable/reference/clarify.md +96 -0
  115. package/skills/ew-impeccable/reference/colorize.md +88 -0
  116. package/skills/ew-impeccable/reference/craft-floor.md +44 -0
  117. package/skills/ew-impeccable/reference/craft.md +5 -0
  118. package/skills/ew-impeccable/reference/critique.md +808 -0
  119. package/skills/ew-impeccable/reference/degraded/asset-producer.md +36 -0
  120. package/skills/ew-impeccable/reference/degraded/documenter.md +23 -0
  121. package/skills/ew-impeccable/reference/degraded/finish-reviewer.md +72 -0
  122. package/skills/ew-impeccable/reference/degraded/manual-edit-applier.md +91 -0
  123. package/skills/ew-impeccable/reference/delight.md +72 -0
  124. package/skills/ew-impeccable/reference/distill.md +113 -0
  125. package/skills/ew-impeccable/reference/doctor.md +56 -0
  126. package/skills/ew-impeccable/reference/document.md +418 -0
  127. package/skills/ew-impeccable/reference/extract.md +68 -0
  128. package/skills/ew-impeccable/reference/harden.md +338 -0
  129. package/skills/ew-impeccable/reference/hooks.md +113 -0
  130. package/skills/ew-impeccable/reference/init.md +133 -0
  131. package/skills/ew-impeccable/reference/ios.md +51 -0
  132. package/skills/ew-impeccable/reference/layout.md +86 -0
  133. package/skills/ew-impeccable/reference/live-setup.md +102 -0
  134. package/skills/ew-impeccable/reference/live.md +326 -0
  135. package/skills/ew-impeccable/reference/new-work.md +209 -0
  136. package/skills/ew-impeccable/reference/onboard.md +236 -0
  137. package/skills/ew-impeccable/reference/operate.md +61 -0
  138. package/skills/ew-impeccable/reference/optimize.md +260 -0
  139. package/skills/ew-impeccable/reference/overdrive.md +127 -0
  140. package/skills/ew-impeccable/reference/polish.md +105 -0
  141. package/skills/ew-impeccable/reference/quieter.md +101 -0
  142. package/skills/ew-impeccable/reference/routing.md +20 -0
  143. package/skills/ew-impeccable/reference/shape.md +59 -0
  144. package/skills/ew-impeccable/reference/typeset.md +82 -0
  145. package/skills/ew-impeccable/reference/visualize.md +46 -0
  146. package/skills/ew-impeccable/scripts/build-phase.mjs +1022 -0
  147. package/skills/ew-impeccable/scripts/command-metadata.json +94 -0
  148. package/skills/ew-impeccable/scripts/comp-diff.mjs +391 -0
  149. package/skills/ew-impeccable/scripts/comp-spec.mjs +513 -0
  150. package/skills/ew-impeccable/scripts/concept-seed.mjs +814 -0
  151. package/skills/ew-impeccable/scripts/context-signals.mjs +325 -0
  152. package/skills/ew-impeccable/scripts/context.mjs +1521 -0
  153. package/skills/ew-impeccable/scripts/critique-storage.mjs +473 -0
  154. package/skills/ew-impeccable/scripts/data/font-index-failures.json +121 -0
  155. package/skills/ew-impeccable/scripts/data/font-index.json +1 -0
  156. package/skills/ew-impeccable/scripts/detect-csp.mjs +246 -0
  157. package/skills/ew-impeccable/scripts/detect.mjs +30 -0
  158. package/skills/ew-impeccable/scripts/detector/browser/injected/index.mjs +2580 -0
  159. package/skills/ew-impeccable/scripts/detector/cli/main.mjs +498 -0
  160. package/skills/ew-impeccable/scripts/detector/design-system.mjs +1311 -0
  161. package/skills/ew-impeccable/scripts/detector/detect-antipatterns-browser.js +9486 -0
  162. package/skills/ew-impeccable/scripts/detector/detect-antipatterns.mjs +51 -0
  163. package/skills/ew-impeccable/scripts/detector/engines/browser/detect-url.mjs +434 -0
  164. package/skills/ew-impeccable/scripts/detector/engines/regex/detect-text.mjs +1439 -0
  165. package/skills/ew-impeccable/scripts/detector/engines/static-html/css-cascade.mjs +1242 -0
  166. package/skills/ew-impeccable/scripts/detector/engines/static-html/detect-html.mjs +263 -0
  167. package/skills/ew-impeccable/scripts/detector/engines/visual/screenshot-contrast.mjs +189 -0
  168. package/skills/ew-impeccable/scripts/detector/findings.mjs +23 -0
  169. package/skills/ew-impeccable/scripts/detector/node/file-system.mjs +225 -0
  170. package/skills/ew-impeccable/scripts/detector/profile/profiler.mjs +166 -0
  171. package/skills/ew-impeccable/scripts/detector/registry/antipatterns.mjs +636 -0
  172. package/skills/ew-impeccable/scripts/detector/rules/checks.mjs +5750 -0
  173. package/skills/ew-impeccable/scripts/detector/shared/color.mjs +596 -0
  174. package/skills/ew-impeccable/scripts/detector/shared/constants.mjs +127 -0
  175. package/skills/ew-impeccable/scripts/detector/shared/fonts.mjs +30 -0
  176. package/skills/ew-impeccable/scripts/detector/shared/inline-ignores.mjs +148 -0
  177. package/skills/ew-impeccable/scripts/detector/shared/page.mjs +7 -0
  178. package/skills/ew-impeccable/scripts/detector/vendor/MDN-DATA-LICENSE +116 -0
  179. package/skills/ew-impeccable/scripts/detector/vendor/THIRD_PARTY_LICENSES.md +227 -0
  180. package/skills/ew-impeccable/scripts/detector/vendor/static-html-parser.build-entry.txt +11 -0
  181. package/skills/ew-impeccable/scripts/detector/vendor/static-html-parser.bundle.mjs +9121 -0
  182. package/skills/ew-impeccable/scripts/doctor.mjs +330 -0
  183. package/skills/ew-impeccable/scripts/embed-prompt.mjs +166 -0
  184. package/skills/ew-impeccable/scripts/font-match.mjs +457 -0
  185. package/skills/ew-impeccable/scripts/generate-image.mjs +447 -0
  186. package/skills/ew-impeccable/scripts/hook-admin.mjs +829 -0
  187. package/skills/ew-impeccable/scripts/hook-before-edit.mjs +538 -0
  188. package/skills/ew-impeccable/scripts/hook-lib.mjs +2493 -0
  189. package/skills/ew-impeccable/scripts/hook.mjs +79 -0
  190. package/skills/ew-impeccable/scripts/lib/artifact-schema.mjs +93 -0
  191. package/skills/ew-impeccable/scripts/lib/composition-catalog.mjs +200 -0
  192. package/skills/ew-impeccable/scripts/lib/concept-catalog.mjs +395 -0
  193. package/skills/ew-impeccable/scripts/lib/design-parser.mjs +880 -0
  194. package/skills/ew-impeccable/scripts/lib/font-fingerprint.mjs +564 -0
  195. package/skills/ew-impeccable/scripts/lib/font-index.mjs +130 -0
  196. package/skills/ew-impeccable/scripts/lib/hero-checks.mjs +246 -0
  197. package/skills/ew-impeccable/scripts/lib/image-metrics.mjs +306 -0
  198. package/skills/ew-impeccable/scripts/lib/impeccable-config.mjs +640 -0
  199. package/skills/ew-impeccable/scripts/lib/impeccable-paths.mjs +137 -0
  200. package/skills/ew-impeccable/scripts/lib/is-generated.mjs +72 -0
  201. package/skills/ew-impeccable/scripts/lib/live-path-globs.mjs +37 -0
  202. package/skills/ew-impeccable/scripts/lib/open-system-browser.mjs +26 -0
  203. package/skills/ew-impeccable/scripts/lib/png.mjs +281 -0
  204. package/skills/ew-impeccable/scripts/lib/provider.mjs +5 -0
  205. package/skills/ew-impeccable/scripts/lib/raster.mjs +194 -0
  206. package/skills/ew-impeccable/scripts/lib/roll-selection.mjs +369 -0
  207. package/skills/ew-impeccable/scripts/lib/staleness-deep.mjs +491 -0
  208. package/skills/ew-impeccable/scripts/lib/staleness-notice.mjs +169 -0
  209. package/skills/ew-impeccable/scripts/lib/staleness.mjs +532 -0
  210. package/skills/ew-impeccable/scripts/lib/surface-briefs.mjs +149 -0
  211. package/skills/ew-impeccable/scripts/lib/target-args.mjs +42 -0
  212. package/skills/ew-impeccable/scripts/lib/target-slug.mjs +33 -0
  213. package/skills/ew-impeccable/scripts/lib/template-extensions.mjs +146 -0
  214. package/skills/ew-impeccable/scripts/live/accept-css.mjs +617 -0
  215. package/skills/ew-impeccable/scripts/live/accept-verify.mjs +60 -0
  216. package/skills/ew-impeccable/scripts/live/browser-script-parts.mjs +84 -0
  217. package/skills/ew-impeccable/scripts/live/completion.mjs +28 -0
  218. package/skills/ew-impeccable/scripts/live/event-validation.mjs +199 -0
  219. package/skills/ew-impeccable/scripts/live/frameworks/astro.mjs +47 -0
  220. package/skills/ew-impeccable/scripts/live/frameworks/detect-utils.mjs +73 -0
  221. package/skills/ew-impeccable/scripts/live/frameworks/index.mjs +143 -0
  222. package/skills/ew-impeccable/scripts/live/frameworks/journal.mjs +197 -0
  223. package/skills/ew-impeccable/scripts/live/frameworks/nextjs.mjs +49 -0
  224. package/skills/ew-impeccable/scripts/live/frameworks/nuxt.mjs +161 -0
  225. package/skills/ew-impeccable/scripts/live/frameworks/script-src.mjs +17 -0
  226. package/skills/ew-impeccable/scripts/live/frameworks/static-html.mjs +26 -0
  227. package/skills/ew-impeccable/scripts/live/frameworks/sveltekit.mjs +71 -0
  228. package/skills/ew-impeccable/scripts/live/frameworks/tag-strategy.mjs +247 -0
  229. package/skills/ew-impeccable/scripts/live/frameworks/tanstack-start.mjs +70 -0
  230. package/skills/ew-impeccable/scripts/live/frameworks/vite-generic.mjs +42 -0
  231. package/skills/ew-impeccable/scripts/live/generation-preflight.mjs +149 -0
  232. package/skills/ew-impeccable/scripts/live/insert-ui.mjs +458 -0
  233. package/skills/ew-impeccable/scripts/live/instructions.mjs +142 -0
  234. package/skills/ew-impeccable/scripts/live/manual-apply.mjs +939 -0
  235. package/skills/ew-impeccable/scripts/live/manual-edit-routes.mjs +357 -0
  236. package/skills/ew-impeccable/scripts/live/manual-edits-buffer.mjs +152 -0
  237. package/skills/ew-impeccable/scripts/live/poll-lanes.mjs +14 -0
  238. package/skills/ew-impeccable/scripts/live/project-ignores.mjs +139 -0
  239. package/skills/ew-impeccable/scripts/live/roots.mjs +508 -0
  240. package/skills/ew-impeccable/scripts/live/session-store.mjs +563 -0
  241. package/skills/ew-impeccable/scripts/live/source-lock.mjs +105 -0
  242. package/skills/ew-impeccable/scripts/live/source-search.mjs +105 -0
  243. package/skills/ew-impeccable/scripts/live/svelte-ast.mjs +969 -0
  244. package/skills/ew-impeccable/scripts/live/svelte-component.mjs +1366 -0
  245. package/skills/ew-impeccable/scripts/live/sveltekit-adapter.mjs +304 -0
  246. package/skills/ew-impeccable/scripts/live/tanstack-adapter.mjs +259 -0
  247. package/skills/ew-impeccable/scripts/live/ui-surfaces.mjs +75 -0
  248. package/skills/ew-impeccable/scripts/live/vocabulary.mjs +171 -0
  249. package/skills/ew-impeccable/scripts/live-accept.mjs +938 -0
  250. package/skills/ew-impeccable/scripts/live-browser-dom.js +167 -0
  251. package/skills/ew-impeccable/scripts/live-browser-ignores.js +242 -0
  252. package/skills/ew-impeccable/scripts/live-browser-session.js +144 -0
  253. package/skills/ew-impeccable/scripts/live-browser.js +12851 -0
  254. package/skills/ew-impeccable/scripts/live-commit-manual-edits.mjs +1200 -0
  255. package/skills/ew-impeccable/scripts/live-complete.mjs +107 -0
  256. package/skills/ew-impeccable/scripts/live-copy-edit-agent.mjs +800 -0
  257. package/skills/ew-impeccable/scripts/live-discard-manual-edits.mjs +51 -0
  258. package/skills/ew-impeccable/scripts/live-inject.mjs +463 -0
  259. package/skills/ew-impeccable/scripts/live-insert.mjs +292 -0
  260. package/skills/ew-impeccable/scripts/live-manual-edit-evidence.mjs +368 -0
  261. package/skills/ew-impeccable/scripts/live-poll.mjs +430 -0
  262. package/skills/ew-impeccable/scripts/live-resume.mjs +123 -0
  263. package/skills/ew-impeccable/scripts/live-server.mjs +1698 -0
  264. package/skills/ew-impeccable/scripts/live-status.mjs +71 -0
  265. package/skills/ew-impeccable/scripts/live-target.mjs +30 -0
  266. package/skills/ew-impeccable/scripts/live-wrap.mjs +927 -0
  267. package/skills/ew-impeccable/scripts/live.mjs +334 -0
  268. package/skills/ew-impeccable/scripts/modern-screenshot.umd.js +14 -0
  269. package/skills/ew-impeccable/scripts/palette.mjs +628 -0
  270. package/skills/ew-impeccable/scripts/pin.mjs +352 -0
  271. package/skills/ew-impeccable/scripts/serve-question.mjs +1783 -0
  272. package/skills/ew-impeccable/scripts/surface-brief.mjs +74 -0
  273. package/skills/ew-knowledge/SKILL.md +35 -0
  274. package/skills/ew-knowledge/references/closeout-protocol.md +68 -0
  275. package/skills/ew-knowledge/references/knowledge-route.md +73 -0
  276. package/skills/ew-knowledge/references/wiki-maintenance.md +27 -0
  277. package/skills/ew-odyssey/SKILL.md +106 -0
  278. package/skills/ew-odyssey/references/audit-artifacts.md +7 -0
  279. package/skills/ew-odyssey/references/odyssey-base.md +104 -0
  280. package/skills/ew-odyssey/references/odyssey-debug.md +264 -0
  281. package/skills/ew-odyssey/references/odyssey-defensive.md +351 -0
  282. package/skills/ew-odyssey/references/odyssey-improve.md +230 -0
  283. package/skills/ew-odyssey/references/odyssey-planex.md +294 -0
  284. package/skills/ew-odyssey/references/odyssey-review.md +233 -0
  285. package/skills/ew-odyssey/references/odyssey-security.md +231 -0
  286. package/skills/ew-odyssey/references/odyssey-ui.md +232 -0
  287. package/skills/ew-odyssey/references/prepare/odyssey-debug.md +102 -0
  288. package/skills/ew-odyssey/references/prepare/odyssey-defensive.md +117 -0
  289. package/skills/ew-odyssey/references/prepare/odyssey-improve.md +95 -0
  290. package/skills/ew-odyssey/references/prepare/odyssey-planex.md +105 -0
  291. package/skills/ew-odyssey/references/prepare/odyssey-review.md +105 -0
  292. package/skills/ew-odyssey/references/prepare/odyssey-security.md +91 -0
  293. package/skills/ew-odyssey/references/prepare/odyssey-ui.md +88 -0
  294. package/skills/ew-odyssey/references/runtime-adapters.md +31 -0
  295. package/skills/ew-orchestrate/SKILL.md +89 -0
  296. package/skills/ew-orchestrate/references/auto-policy.md +66 -0
  297. package/skills/ew-orchestrate/references/boundary-grill.md +51 -0
  298. package/skills/ew-orchestrate/references/companion-route.md +40 -0
  299. package/skills/ew-orchestrate/references/ew-orchestrate.md +44 -0
  300. package/skills/ew-orchestrate/references/goal.md +51 -0
  301. package/skills/ew-orchestrate/references/orchestrator-run-loop.md +33 -0
  302. package/skills/ew-orchestrate/references/planning.md +54 -0
  303. package/skills/ew-orchestrate/steps/ew-analyze/SKILL.md +70 -0
  304. package/skills/ew-orchestrate/steps/ew-analyze/references/issue-gaps-analyze.md +24 -0
  305. package/skills/ew-orchestrate/steps/ew-analyze/references/prepare.md +8 -0
  306. package/skills/ew-orchestrate/steps/ew-analyze/references/workflow.md +138 -0
  307. package/skills/ew-orchestrate/steps/ew-auto-test/SKILL.md +80 -0
  308. package/skills/ew-orchestrate/steps/ew-auto-test/references/prepare.md +23 -0
  309. package/skills/ew-orchestrate/steps/ew-auto-test/references/workflow.md +31 -0
  310. package/skills/ew-orchestrate/steps/ew-blueprint/SKILL.md +122 -0
  311. package/skills/ew-orchestrate/steps/ew-blueprint/references/prepare.md +21 -0
  312. package/skills/ew-orchestrate/steps/ew-blueprint/references/workflow.md +28 -0
  313. package/skills/ew-orchestrate/steps/ew-brainstorm/SKILL.md +49 -0
  314. package/skills/ew-orchestrate/steps/ew-companion/SKILL.md +50 -0
  315. package/skills/ew-orchestrate/steps/ew-debug/SKILL.md +85 -0
  316. package/skills/ew-orchestrate/steps/ew-debug/references/prepare.md +27 -0
  317. package/skills/ew-orchestrate/steps/ew-debug/references/workflow.md +31 -0
  318. package/skills/ew-orchestrate/steps/ew-execute/SKILL.md +74 -0
  319. package/skills/ew-orchestrate/steps/ew-execute/references/prepare.md +27 -0
  320. package/skills/ew-orchestrate/steps/ew-execute/references/workflow.md +87 -0
  321. package/skills/ew-orchestrate/steps/ew-grill/SKILL.md +62 -0
  322. package/skills/ew-orchestrate/steps/ew-grill/references/prepare.md +26 -0
  323. package/skills/ew-orchestrate/steps/ew-grill/references/workflow.md +31 -0
  324. package/skills/ew-orchestrate/steps/ew-init/SKILL.md +56 -0
  325. package/skills/ew-orchestrate/steps/ew-init/references/prepare.md +25 -0
  326. package/skills/ew-orchestrate/steps/ew-init/references/workflow.md +28 -0
  327. package/skills/ew-orchestrate/steps/ew-plan/SKILL.md +131 -0
  328. package/skills/ew-orchestrate/steps/ew-plan/references/prepare.md +8 -0
  329. package/skills/ew-orchestrate/steps/ew-plan/references/tdd.md +53 -0
  330. package/skills/ew-orchestrate/steps/ew-plan/references/workflow.md +100 -0
  331. package/skills/ew-orchestrate/steps/ew-retrospective/SKILL.md +68 -0
  332. package/skills/ew-orchestrate/steps/ew-retrospective/references/prepare.md +18 -0
  333. package/skills/ew-orchestrate/steps/ew-retrospective/references/workflow.md +34 -0
  334. package/skills/ew-orchestrate/steps/ew-review/SKILL.md +45 -0
  335. package/skills/ew-orchestrate/steps/ew-review/references/prepare.md +17 -0
  336. package/skills/ew-orchestrate/steps/ew-review/references/workflow.md +116 -0
  337. package/skills/ew-orchestrate/steps/ew-roadmap/SKILL.md +62 -0
  338. package/skills/ew-orchestrate/steps/ew-roadmap/references/prepare.md +27 -0
  339. package/skills/ew-orchestrate/steps/ew-roadmap/references/workflow.md +28 -0
  340. package/skills/ew-orchestrate/steps/ew-test/SKILL.md +99 -0
  341. package/skills/ew-orchestrate/steps/ew-test/references/prepare.md +23 -0
  342. package/skills/ew-orchestrate/steps/ew-test/references/workflow.md +23 -0
  343. package/skills/ew-orchestrate/steps/ew-verify/SKILL.md +73 -0
  344. package/skills/ew-orchestrate/steps/ew-verify/references/prepare.md +21 -0
  345. package/skills/ew-orchestrate/steps/ew-verify/references/workflow.md +29 -0
  346. package/skills/ew-skill-design/SKILL.md +30 -0
  347. package/skills/ew-skill-design/references/package-contract.md +40 -0
  348. package/skills/ew-skill-design/references/validation.md +21 -0
  349. package/skills/team-swarm/SKILL.md +68 -0
  350. package/skills/team-swarm/references/mcp-coordination.md +14 -0
  351. package/skills/team-swarm/roles/analyst/role.md +181 -0
  352. package/skills/team-swarm/roles/ant/role.md +149 -0
  353. package/skills/team-swarm/roles/coordinator/commands/converge.md +112 -0
  354. package/skills/team-swarm/roles/coordinator/commands/init-swarm.md +136 -0
  355. package/skills/team-swarm/roles/coordinator/commands/iterate.md +171 -0
  356. package/skills/team-swarm/roles/coordinator/role.md +170 -0
  357. package/skills/team-swarm/roles/scorer/role.md +150 -0
  358. package/skills/team-swarm/scripts/aco.py +646 -0
  359. package/skills/team-swarm/scripts/pheromone.py +144 -0
  360. package/skills/team-swarm/scripts/scoring.py +111 -0
  361. package/skills/team-swarm/scripts/test_aco.py +606 -0
  362. package/skills/team-swarm/specs/ant-output-schema.md +127 -0
  363. package/skills/team-swarm/specs/convergence-criteria.md +108 -0
  364. package/skills/team-swarm/specs/pheromone-schema.md +125 -0
  365. package/skills/team-swarm/specs/swarm-config-template.json +71 -0
  366. package/skills/team-swarm/specs/swarm-protocol.md +119 -0
  367. package/skills/workflow-evolve/SKILL.md +64 -0
  368. package/skills/workflow-evolve/references/agy-gate.md +27 -0
  369. package/skills/workflow-evolve/references/auto-loop.md +23 -0
  370. package/skills/workflow-evolve/references/history-review.md +15 -0
  371. package/skills/workflow-evolve/scripts/codex-memory-replay.mjs +86 -0
  372. package/skills/workflow-evolve/scripts/codex-replay.mjs +1 -0
  373. package/skills/workflow-evolve/scripts/evolve-loop.mjs +260 -0
  374. package/skills/workflow-evolve/scripts/memory-codex-mcp.mjs +124 -0
  375. package/workflows/index.json +33 -0
@@ -0,0 +1,538 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Impeccable design hook — Cursor preToolUse write gate.
4
+ *
5
+ * Cursor's stop hook is not consistently dispatched by the headless agent, so
6
+ * this hook checks proposed Write/Edit content before it lands. It only denies
7
+ * writes when the real detector finds an issue in the proposed UI content.
8
+ *
9
+ * Contract: never break a turn accidentally. On malformed input or internal
10
+ * errors, allow the tool and exit 0.
11
+ */
12
+
13
+ import fs from 'node:fs';
14
+ import os from 'node:os';
15
+ import path from 'node:path';
16
+
17
+ import {
18
+ ALLOWED_EXTS,
19
+ DEFAULT_CONFIG,
20
+ EDIT_COUNT_THRESHOLD,
21
+ GENERATED_PATH,
22
+ SENSITIVE_PATH,
23
+ appendDesignSystemNoteOnce,
24
+ commitFooterShown,
25
+ designNoteReserve,
26
+ designSystemOptions,
27
+ footerModeForSession,
28
+ filterFindings,
29
+ isNativePlatform,
30
+ isScanTargetInsideProject,
31
+ loadDetector,
32
+ matchConfiguredExtension,
33
+ matchesAnyGlob,
34
+ persistCache,
35
+ readCache,
36
+ readConfig,
37
+ renderTemplate,
38
+ resolveCacheCwd,
39
+ resolveProjectCwd,
40
+ resolveProjectPlatform,
41
+ truthy,
42
+ writeAuditLog,
43
+ } from './hook-lib.mjs';
44
+
45
+ async function readStdin() {
46
+ if (process.stdin.isTTY) return '';
47
+ const chunks = [];
48
+ for await (const chunk of process.stdin) chunks.push(chunk);
49
+ return Buffer.concat(chunks).toString('utf-8');
50
+ }
51
+
52
+ function done(payload = null) {
53
+ if (payload) process.stdout.write(JSON.stringify(payload));
54
+ process.exit(0);
55
+ }
56
+
57
+ function allow(extra = {}, payload = {}) {
58
+ writeAuditLog(process.env, {
59
+ ts: new Date().toISOString(),
60
+ event: 'preToolUse',
61
+ ...extra,
62
+ });
63
+ return done({ permission: 'allow', ...payload });
64
+ }
65
+
66
+ function deny(message, audit) {
67
+ writeAuditLog(process.env, {
68
+ ts: new Date().toISOString(),
69
+ event: 'preToolUse',
70
+ blocked: true,
71
+ ...audit,
72
+ });
73
+ return done({
74
+ permission: 'deny',
75
+ user_message: message,
76
+ agent_message: message,
77
+ });
78
+ }
79
+
80
+ function toolInput(event) {
81
+ return event?.tool_input && typeof event.tool_input === 'object' ? event.tool_input : {};
82
+ }
83
+
84
+ function proposedFilePath(event, cwd) {
85
+ const input = toolInput(event);
86
+ const raw = input.file_path || input.path || input.target_file || event?.file_path;
87
+ const candidate = typeof raw === 'string' && raw.trim()
88
+ ? raw
89
+ : shellWriteDestination(shellCommand(input));
90
+ if (typeof candidate !== 'string' || !candidate.trim()) return '';
91
+ return path.isAbsolute(candidate) ? candidate : path.resolve(cwd, candidate);
92
+ }
93
+
94
+ function proposedContent(event, cwd, filePath) {
95
+ const input = toolInput(event);
96
+ for (const key of ['content', 'streamContent', 'text']) {
97
+ if (typeof input[key] === 'string') return input[key];
98
+ }
99
+
100
+ const editProjection = projectedEditContent(input, filePath, cwd);
101
+ if (editProjection !== undefined) return editProjection;
102
+
103
+ if (hasFragmentEditContent(input)) {
104
+ return { skipped: 'fragment-only-edit' };
105
+ }
106
+
107
+ const command = shellCommand(input);
108
+ const pythonContent = shellPythonWriteContent(command);
109
+ if (pythonContent) return pythonContent;
110
+ const shellContent = shellHereDocContent(command);
111
+ if (shellContent) return shellContent;
112
+ const copiedContent = shellCopiedFileContent(command, cwd);
113
+ if (copiedContent) return copiedContent;
114
+ return '';
115
+ }
116
+
117
+ function hasFragmentEditContent(input) {
118
+ if (!input || typeof input !== 'object') return false;
119
+ if (typeof input.new_string === 'string' || typeof input.newString === 'string' || typeof input.new_str === 'string' || typeof input.replacement === 'string') {
120
+ return true;
121
+ }
122
+ return Array.isArray(input.edits) && input.edits.some((edit) => edit && typeof edit === 'object');
123
+ }
124
+
125
+ function projectedEditContent(input, filePath, cwd) {
126
+ if (!filePath) return undefined;
127
+ const singleOld = firstString(input, ['old_string', 'oldString', 'old_str', 'target']);
128
+ const singleNew = firstString(input, ['new_string', 'newString', 'new_str', 'replacement']);
129
+ if (singleOld !== undefined || singleNew !== undefined) {
130
+ if (singleOld === undefined || singleNew === undefined) return { skipped: 'fragment-only-edit' };
131
+ const original = readExistingProjectFile(filePath, cwd);
132
+ if (original === null) return { skipped: 'edit-original-unreadable' };
133
+ const projected = replaceOnce(original, singleOld, singleNew);
134
+ return projected === null ? { skipped: 'edit-old-string-missing' } : projected;
135
+ }
136
+
137
+ if (!Array.isArray(input.edits)) return undefined;
138
+ const original = readExistingProjectFile(filePath, cwd);
139
+ if (original === null) return { skipped: 'edit-original-unreadable' };
140
+
141
+ let projected = original;
142
+ for (const edit of input.edits) {
143
+ if (!edit || typeof edit !== 'object') return { skipped: 'fragment-only-edit' };
144
+ const oldString = firstString(edit, ['old_string', 'oldString', 'old_str', 'target']);
145
+ const newString = firstString(edit, ['new_string', 'newString', 'new_str', 'replacement']);
146
+ if (oldString === undefined || newString === undefined) return { skipped: 'fragment-only-edit' };
147
+ const next = replaceOnce(projected, oldString, newString);
148
+ if (next === null) return { skipped: 'edit-old-string-missing' };
149
+ projected = next;
150
+ }
151
+ return projected;
152
+ }
153
+
154
+ function firstString(obj, keys) {
155
+ for (const key of keys) {
156
+ if (typeof obj?.[key] === 'string') return obj[key];
157
+ }
158
+ return undefined;
159
+ }
160
+
161
+ function replaceOnce(original, oldString, newString) {
162
+ if (oldString === '') return null;
163
+ const index = original.indexOf(oldString);
164
+ if (index === -1) return null;
165
+ return `${original.slice(0, index)}${newString}${original.slice(index + oldString.length)}`;
166
+ }
167
+
168
+ function readExistingProjectFile(filePath, cwd) {
169
+ if (!isScanTargetInsideProject(filePath, cwd)) return null;
170
+ if (SENSITIVE_PATH.test(filePath) || GENERATED_PATH.test(filePath)) return null;
171
+ try {
172
+ const stat = fs.statSync(filePath);
173
+ if (!stat.isFile() || stat.size > 1024 * 1024) return null;
174
+ return fs.readFileSync(filePath, 'utf-8');
175
+ } catch {
176
+ return null;
177
+ }
178
+ }
179
+
180
+ function shellCommand(input) {
181
+ if (typeof input.command === 'string') return input.command;
182
+ if (input.args && typeof input.args.command === 'string') return input.args.command;
183
+ return '';
184
+ }
185
+
186
+ function shellRedirectPath(command) {
187
+ if (!command || typeof command !== 'string') return '';
188
+ const match = command.match(/(?:^|[\s;&|])(?:>>?|1>>?)\s*(?:"([^"]+)"|'([^']+)'|([^<>\s]+))/);
189
+ return (match?.[1] || match?.[2] || match?.[3] || '').trim();
190
+ }
191
+
192
+ function shellWriteDestination(command) {
193
+ return shellRedirectPath(command) || shellTeeDestination(command) || shellCopyPaths(command)?.dest || shellPythonWriteDestination(command) || '';
194
+ }
195
+
196
+ function shellPythonWriteDestination(command) {
197
+ if (!/\bpython(?:3)?\b/.test(command || '')) return '';
198
+ const directPath = firstMatch(command, /(?:^|[^\w.])(?:pathlib\.)?Path\(\s*(["'])(.*?)\1\s*\)\s*\.write_text\s*\(/);
199
+ if (directPath) return directPath;
200
+
201
+ const pathsByVar = new Map();
202
+ const assignmentRe = /\b([A-Za-z_]\w*)\s*=\s*(?:pathlib\.)?Path\(\s*(["'])(.*?)\2\s*\)/g;
203
+ let assignment;
204
+ while ((assignment = assignmentRe.exec(command))) {
205
+ pathsByVar.set(assignment[1], assignment[3]);
206
+ }
207
+
208
+ const writeVarRe = /\b([A-Za-z_]\w*)\.write_text\s*\(/g;
209
+ let writeVar;
210
+ while ((writeVar = writeVarRe.exec(command))) {
211
+ const candidate = pathsByVar.get(writeVar[1]);
212
+ if (candidate) return candidate;
213
+ }
214
+
215
+ return firstMatch(command, /\bopen\(\s*(["'])(.*?)\1\s*,\s*(["'])[wax](?:\+)?b?\3/);
216
+ }
217
+
218
+ function firstMatch(value, re) {
219
+ const match = String(value || '').match(re);
220
+ return (match?.[2] || '').trim();
221
+ }
222
+
223
+ function shellTeeDestination(command) {
224
+ const words = shellWords(command);
225
+ const teeIndex = words.findIndex((word) => path.basename(word) === 'tee');
226
+ if (teeIndex === -1) return '';
227
+ for (const word of words.slice(teeIndex + 1)) {
228
+ if (['&&', '||', ';', '|'].includes(word)) break;
229
+ if (word === '--') continue;
230
+ if (word.startsWith('-')) continue;
231
+ return word;
232
+ }
233
+ return '';
234
+ }
235
+
236
+ function shellCopiedFileContent(command, cwd) {
237
+ const source = shellCopyPaths(command)?.source;
238
+ if (!source) return '';
239
+ const sourcePath = path.isAbsolute(source) ? source : path.resolve(cwd, source);
240
+ if (!isScanTargetInsideProject(sourcePath, cwd)) return '';
241
+ if (SENSITIVE_PATH.test(sourcePath) || GENERATED_PATH.test(sourcePath)) return '';
242
+ try {
243
+ const stat = fs.statSync(sourcePath);
244
+ if (!stat.isFile() || stat.size > 1024 * 1024) return '';
245
+ return fs.readFileSync(sourcePath, 'utf-8');
246
+ } catch {
247
+ return '';
248
+ }
249
+ }
250
+
251
+ function shellCopyPaths(command) {
252
+ const words = shellWords(command);
253
+ if (words.length < 3 || path.basename(words[0]) !== 'cp') return null;
254
+ const args = [];
255
+ for (const word of words.slice(1)) {
256
+ if (['&&', '||', ';', '|'].includes(word)) break;
257
+ if (word === '--') continue;
258
+ if (word.startsWith('-')) continue;
259
+ args.push(word);
260
+ }
261
+ if (args.length < 2) return null;
262
+ return { source: args[args.length - 2], dest: args[args.length - 1] };
263
+ }
264
+
265
+ function shellWords(command) {
266
+ if (!command || typeof command !== 'string') return [];
267
+ const words = [];
268
+ const re = /"((?:\\"|[^"])*)"|'((?:\\'|[^'])*)'|([^\s]+)/g;
269
+ let match;
270
+ while ((match = re.exec(command))) {
271
+ words.push((match[1] ?? match[2] ?? match[3] ?? '').replace(/\\(["'])/g, '$1'));
272
+ }
273
+ return words;
274
+ }
275
+
276
+ function shellHereDocContent(command) {
277
+ if (!command || typeof command !== 'string') return '';
278
+ const markerMatch = command.match(/<<-?\s*['"]?([A-Za-z0-9_.-]+)['"]?[^\r\n]*\r?\n/);
279
+ if (!markerMatch) return '';
280
+ const marker = markerMatch[1];
281
+ const start = (markerMatch.index || 0) + markerMatch[0].length;
282
+ const rest = command.slice(start);
283
+ const endRe = new RegExp(`\\r?\\n${escapeRegExp(marker)}(?:\\r?\\n|$)`);
284
+ const end = rest.search(endRe);
285
+ return end >= 0 ? rest.slice(0, end) : '';
286
+ }
287
+
288
+ function shellPythonWriteContent(command) {
289
+ if (!/\bpython(?:3)?\b/.test(command || '')) return '';
290
+ const script = shellHereDocContent(command) || command;
291
+ return pythonStringArg(script, /\.write_text\s*\(\s*/g) || pythonStringArg(script, /\.write\s*\(\s*/g);
292
+ }
293
+
294
+ function pythonStringArg(script, prefixRe) {
295
+ let prefix;
296
+ while ((prefix = prefixRe.exec(script))) {
297
+ const start = prefixRe.lastIndex;
298
+ const triple = script.slice(start, start + 3);
299
+ if (triple === "'''" || triple === '"""') {
300
+ const end = script.indexOf(triple, start + 3);
301
+ if (end !== -1) return script.slice(start + 3, end);
302
+ continue;
303
+ }
304
+ const quote = script[start];
305
+ if (quote !== '"' && quote !== "'") continue;
306
+ let out = '';
307
+ for (let i = start + 1; i < script.length; i++) {
308
+ const ch = script[i];
309
+ if (ch === '\\') {
310
+ out += script[i + 1] || '';
311
+ i += 1;
312
+ } else if (ch === quote) {
313
+ return out;
314
+ } else {
315
+ out += ch;
316
+ }
317
+ }
318
+ }
319
+ return '';
320
+ }
321
+
322
+ function escapeRegExp(value) {
323
+ return String(value).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
324
+ }
325
+
326
+ function relativePath(filePath, cwd) {
327
+ try {
328
+ const rel = path.relative(cwd, filePath);
329
+ if (!rel || rel.startsWith('..') || path.isAbsolute(rel)) return filePath;
330
+ return rel.split(path.sep).join('/');
331
+ } catch {
332
+ return filePath;
333
+ }
334
+ }
335
+
336
+ // The static HTML engine reads its input from disk, but preToolUse only has
337
+ // the proposed content. Stage it in a temp file so html-engine targets get the
338
+ // same DOM-structural rules pre-write that runHook applies post-edit.
339
+ async function detectProposedHtml(detector, content, filePath, scanOptions) {
340
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'impeccable-pre-'));
341
+ const tmpFile = path.join(dir, path.basename(filePath));
342
+ try {
343
+ fs.writeFileSync(tmpFile, content);
344
+ const findings = await detector.detectHtml(tmpFile, scanOptions);
345
+ // Findings carry the temp path; remap so file-scoped ignores still match.
346
+ return (findings || []).map((f) => (f && typeof f === 'object' ? { ...f, file: filePath } : f));
347
+ } finally {
348
+ fs.rmSync(dir, { recursive: true, force: true });
349
+ }
350
+ }
351
+
352
+ // Cursor caps deny messages around 4000 chars. The cap feeds through the
353
+ // renderer's clamp, which preserves the policy footer, rather than tail-
354
+ // slicing the rendered text, which cut the footer off any message the
355
+ // default 8000-char budget let past 4000.
356
+ const CURSOR_DENY_LIMIT = 4000;
357
+ const BLOCK_PREFIX = 'Impeccable design hook blocked this write before it landed. ';
358
+
359
+ function cursorBlockMessage(findings, filePath, config, cwd, footerMode, reserveChars) {
360
+ const limits = config?.limits || DEFAULT_CONFIG.limits;
361
+ // Charge the prefix via reserveChars, not by subtracting from maxChars:
362
+ // renderTemplate's 500-char floor re-raises any maxChars pushed below it,
363
+ // un-charging a prefix subtracted from maxChars (Greptile P1 on PR #508).
364
+ // reserveChars comes off after the floor, so the prefix is charged at every
365
+ // config tier and the final prefixed message plus a pending staleness note
366
+ // fits the binding limit. Default-config output is byte-identical.
367
+ const budget = Math.min(
368
+ limits.maxChars || DEFAULT_CONFIG.limits.maxChars,
369
+ CURSOR_DENY_LIMIT,
370
+ );
371
+ const rendered = renderTemplate(findings, filePath,
372
+ { ...config, limits: { ...limits, maxChars: budget } },
373
+ { cwd, footer: footerMode, reserveChars: (reserveChars || 0) + BLOCK_PREFIX.length });
374
+ return rendered.replace(
375
+ '[impeccable@1] Design hook findings requiring review',
376
+ `[impeccable@1] ${BLOCK_PREFIX}Design hook findings requiring review`,
377
+ );
378
+ }
379
+
380
+ function findingSignature(findings) {
381
+ return findings
382
+ .map((finding) => `${finding.antipattern || 'unknown'}:${finding.line || 0}`)
383
+ .sort()
384
+ .join('|');
385
+ }
386
+
387
+ function bumpCursorDenial(cache, sessionId, filePath, findings) {
388
+ const session = cache.sessions[sessionId] || { updatedAt: Date.now(), files: {} };
389
+ cache.sessions[sessionId] = session;
390
+ session.updatedAt = Date.now();
391
+ const fileEntry = session.files[filePath] || { editCount: 0, findings: [] };
392
+ session.files[filePath] = fileEntry;
393
+ const key = findingSignature(findings);
394
+ fileEntry.cursorDenials = fileEntry.cursorDenials && typeof fileEntry.cursorDenials === 'object'
395
+ ? fileEntry.cursorDenials
396
+ : {};
397
+ fileEntry.cursorDenials[key] = (fileEntry.cursorDenials[key] || 0) + 1;
398
+ return { key, count: fileEntry.cursorDenials[key] };
399
+ }
400
+
401
+ async function main() {
402
+ if (truthy(process.env.IMPECCABLE_HOOK_DISABLED)) {
403
+ return allow({ skipped: 'env-disabled' });
404
+ }
405
+
406
+ let event = null;
407
+ try {
408
+ const raw = await readStdin();
409
+ if (raw) event = JSON.parse(raw);
410
+ } catch {
411
+ return allow({ skipped: 'stdin-malformed' });
412
+ }
413
+
414
+ if (!event || typeof event !== 'object') {
415
+ return allow({ skipped: 'stdin-empty' });
416
+ }
417
+
418
+ const sessionCwd = resolveProjectCwd(event);
419
+ const started = Date.now();
420
+ const filePath = proposedFilePath(event, sessionCwd);
421
+ // Re-key config/cache to the edited file's project root when the session
422
+ // was launched from a non-project umbrella directory (issue #305).
423
+ const cwd = resolveCacheCwd(filePath, sessionCwd);
424
+ const audit = {
425
+ harness: 'cursor',
426
+ cwd,
427
+ tool: event.tool_name || null,
428
+ file: filePath || null,
429
+ };
430
+
431
+ if (!filePath) return allow({ ...audit, skipped: 'no-file-path', durationMs: Date.now() - started });
432
+ if (!isScanTargetInsideProject(filePath, cwd)) return allow({ ...audit, skipped: 'outside-project', durationMs: Date.now() - started });
433
+ if (SENSITIVE_PATH.test(filePath)) return allow({ ...audit, skipped: 'sensitive', durationMs: Date.now() - started });
434
+ if (GENERATED_PATH.test(filePath)) return allow({ ...audit, skipped: 'generated', durationMs: Date.now() - started });
435
+
436
+ // Config is read before the extension gate so `detector.extensions` entries
437
+ // (e.g. `.blade.php` template files, issue #316) can widen it.
438
+ const config = readConfig(cwd);
439
+ const ext = path.extname(filePath).toLowerCase();
440
+ const configuredExt = matchConfiguredExtension(filePath, config.extensions);
441
+ audit.ext = configuredExt ? configuredExt.ext : ext;
442
+ if (!ALLOWED_EXTS.has(ext) && !configuredExt) return allow({ ...audit, skipped: 'extension', durationMs: Date.now() - started });
443
+
444
+ const contentResult = proposedContent(event, cwd, filePath);
445
+ if (contentResult && typeof contentResult === 'object' && contentResult.skipped) {
446
+ return allow({ ...audit, skipped: contentResult.skipped, durationMs: Date.now() - started });
447
+ }
448
+ const content = typeof contentResult === 'string' ? contentResult : '';
449
+ if (!content) return allow({ ...audit, skipped: 'no-proposed-content', durationMs: Date.now() - started });
450
+
451
+ if (config.enabled === false) return allow({ ...audit, skipped: 'config-disabled', durationMs: Date.now() - started });
452
+
453
+ // Web rule engine, native project: stand aside (see resolveProjectPlatform).
454
+ const platform = resolveProjectPlatform(cwd);
455
+ if (isNativePlatform(platform)) {
456
+ return allow({ ...audit, skipped: 'native-platform', platform, durationMs: Date.now() - started });
457
+ }
458
+
459
+ const rel = relativePath(filePath, cwd);
460
+ if (matchesAnyGlob(rel, config.ignoreFiles) || matchesAnyGlob(filePath, config.ignoreFiles)) {
461
+ return allow({ ...audit, skipped: 'config-ignore-file', durationMs: Date.now() - started });
462
+ }
463
+
464
+ const detector = await loadDetector();
465
+ if (!detector || typeof detector.detectText !== 'function') {
466
+ return allow({ ...audit, skipped: 'detector-missing', durationMs: Date.now() - started });
467
+ }
468
+ const scanOptions = designSystemOptions(config, detector, cwd);
469
+
470
+ // Mirror runHook's engine routing so template issues the HTML engine catches
471
+ // post-edit cannot slip past the pre-write gate.
472
+ const useHtmlEngine = configuredExt
473
+ ? configuredExt.engine === 'html'
474
+ : (ext === '.html' || ext === '.htm');
475
+ let findings = [];
476
+ try {
477
+ findings = useHtmlEngine && typeof detector.detectHtml === 'function'
478
+ ? await detectProposedHtml(detector, content, filePath, scanOptions)
479
+ : await detector.detectText(content, filePath, scanOptions);
480
+ } catch {
481
+ return allow({ ...audit, error: 'detector-threw', durationMs: Date.now() - started });
482
+ }
483
+
484
+ const filtered = filterFindings(findings || [], content, ext, config);
485
+ if (filtered.length === 0) {
486
+ return allow({
487
+ ...audit,
488
+ findings: (findings || []).length,
489
+ blockedFindings: 0,
490
+ durationMs: Date.now() - started,
491
+ });
492
+ }
493
+
494
+ const sessionId = event.session_id || event.conversation_id || 'unknown';
495
+ const cache = readCache(cwd);
496
+ // Repeated denials for the same session repeat the findings, not the
497
+ // policy: the full footer emits once per session, the short form after.
498
+ const footerMode = footerModeForSession(cache, sessionId);
499
+ const message = appendDesignSystemNoteOnce(
500
+ cursorBlockMessage(filtered, filePath, config, cwd, footerMode, designNoteReserve(scanOptions, cache, sessionId)),
501
+ scanOptions, cache, sessionId, config,
502
+ );
503
+ commitFooterShown(cache, sessionId, message);
504
+ const denial = bumpCursorDenial(cache, sessionId, filePath, filtered);
505
+ persistCache(cwd, cache);
506
+ if (denial.count > EDIT_COUNT_THRESHOLD) {
507
+ const warning = `${message}\n\nThis is the ${denial.count}th repeated denial for the same file and finding signature, so Impeccable is allowing this write to avoid a loop. Reconsider the issue immediately after the tool runs.`;
508
+ return allow({
509
+ ...audit,
510
+ findings: (findings || []).length,
511
+ blockedFindings: filtered.length,
512
+ cursorDenialKey: denial.key,
513
+ cursorDenialCount: denial.count,
514
+ downgraded: true,
515
+ chars: warning.length,
516
+ durationMs: Date.now() - started,
517
+ }, {
518
+ user_message: warning,
519
+ agent_message: warning,
520
+ });
521
+ }
522
+ return deny(message, {
523
+ ...audit,
524
+ findings: (findings || []).length,
525
+ blockedFindings: filtered.length,
526
+ cursorDenialKey: denial.key,
527
+ cursorDenialCount: denial.count,
528
+ chars: message.length,
529
+ durationMs: Date.now() - started,
530
+ });
531
+ }
532
+
533
+ main().catch((err) => {
534
+ if (process.env.IMPECCABLE_HOOK_DEBUG) {
535
+ process.stderr.write(`[impeccable-hook-before-edit] ${err}\n`);
536
+ }
537
+ done({ permission: 'allow' });
538
+ });