@hivehub/rulebook 5.3.3 → 5.4.1

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 (492) hide show
  1. package/.claude/commands/analysis.md +35 -35
  2. package/.claude/commands/continue.md +33 -33
  3. package/.claude/commands/ralph-config.md +112 -112
  4. package/.claude/commands/ralph-history.md +110 -110
  5. package/.claude/commands/ralph-init.md +72 -72
  6. package/.claude/commands/ralph-pause-resume.md +105 -105
  7. package/.claude/commands/ralph-run.md +101 -101
  8. package/.claude/commands/ralph-status.md +76 -76
  9. package/.claude/commands/rulebook-decision-create.md +55 -55
  10. package/.claude/commands/rulebook-decision-list.md +15 -15
  11. package/.claude/commands/rulebook-knowledge-add.md +41 -41
  12. package/.claude/commands/rulebook-knowledge-list.md +15 -15
  13. package/.claude/commands/rulebook-learn-capture.md +48 -48
  14. package/.claude/commands/rulebook-learn-list.md +13 -13
  15. package/.claude/commands/rulebook-memory-save.md +48 -48
  16. package/.claude/commands/rulebook-memory-search.md +47 -47
  17. package/.claude/commands/rulebook-task-apply.md +67 -67
  18. package/.claude/commands/rulebook-task-archive.md +94 -94
  19. package/.claude/commands/rulebook-task-create.md +93 -93
  20. package/.claude/commands/rulebook-task-list.md +42 -42
  21. package/.claude/commands/rulebook-task-show.md +52 -52
  22. package/.claude/commands/rulebook-task-validate.md +53 -53
  23. package/.claude-plugin/marketplace.json +28 -28
  24. package/.claude-plugin/plugin.json +8 -8
  25. package/LICENSE +191 -191
  26. package/README.md +42 -3
  27. package/dist/cli/commands/compress.d.ts +18 -0
  28. package/dist/cli/commands/compress.d.ts.map +1 -0
  29. package/dist/cli/commands/compress.js +100 -0
  30. package/dist/cli/commands/compress.js.map +1 -0
  31. package/dist/cli/commands/index.d.ts +1 -0
  32. package/dist/cli/commands/index.d.ts.map +1 -1
  33. package/dist/cli/commands/index.js +1 -0
  34. package/dist/cli/commands/index.js.map +1 -1
  35. package/dist/cli/commands/init.d.ts.map +1 -1
  36. package/dist/cli/commands/init.js +2 -0
  37. package/dist/cli/commands/init.js.map +1 -1
  38. package/dist/cli/commands/update.d.ts.map +1 -1
  39. package/dist/cli/commands/update.js +2 -0
  40. package/dist/cli/commands/update.js.map +1 -1
  41. package/dist/core/claude-settings-manager.d.ts +7 -0
  42. package/dist/core/claude-settings-manager.d.ts.map +1 -1
  43. package/dist/core/claude-settings-manager.js +31 -14
  44. package/dist/core/claude-settings-manager.js.map +1 -1
  45. package/dist/core/compress/compressor.d.ts +60 -0
  46. package/dist/core/compress/compressor.d.ts.map +1 -0
  47. package/dist/core/compress/compressor.js +232 -0
  48. package/dist/core/compress/compressor.js.map +1 -0
  49. package/dist/core/compress/discover.d.ts +19 -0
  50. package/dist/core/compress/discover.d.ts.map +1 -0
  51. package/dist/core/compress/discover.js +100 -0
  52. package/dist/core/compress/discover.js.map +1 -0
  53. package/dist/core/compress/validator.d.ts +47 -0
  54. package/dist/core/compress/validator.d.ts.map +1 -0
  55. package/dist/core/compress/validator.js +131 -0
  56. package/dist/core/compress/validator.js.map +1 -0
  57. package/dist/core/doctor.d.ts.map +1 -1
  58. package/dist/core/doctor.js +66 -0
  59. package/dist/core/doctor.js.map +1 -1
  60. package/dist/core/generator.d.ts +16 -0
  61. package/dist/core/generator.d.ts.map +1 -1
  62. package/dist/core/generator.js +36 -11
  63. package/dist/core/generator.js.map +1 -1
  64. package/dist/hooks/safe-flag-io.d.ts +77 -0
  65. package/dist/hooks/safe-flag-io.d.ts.map +1 -0
  66. package/dist/hooks/safe-flag-io.js +169 -0
  67. package/dist/hooks/safe-flag-io.js.map +1 -0
  68. package/dist/index.js +11 -1
  69. package/dist/index.js.map +1 -1
  70. package/dist/mcp/rulebook-server.d.ts.map +1 -1
  71. package/dist/mcp/rulebook-server.js +236 -0
  72. package/dist/mcp/rulebook-server.js.map +1 -1
  73. package/dist/types.d.ts +4 -0
  74. package/dist/types.d.ts.map +1 -1
  75. package/package.json +23 -21
  76. package/templates/agents/accessibility-reviewer.md +43 -43
  77. package/templates/agents/api-designer.md +42 -42
  78. package/templates/agents/architect.md +51 -51
  79. package/templates/agents/build-engineer.md +36 -36
  80. package/templates/agents/code-reviewer.md +47 -47
  81. package/templates/agents/compiler/codegen-debugger.md +34 -34
  82. package/templates/agents/compiler/stdlib-engineer.md +28 -28
  83. package/templates/agents/compiler/test-coverage-guardian.md +31 -31
  84. package/templates/agents/context-intelligence.md +52 -52
  85. package/templates/agents/database-architect.md +41 -41
  86. package/templates/agents/devops-engineer.md +42 -42
  87. package/templates/agents/docs-writer.md +38 -38
  88. package/templates/agents/game-engine/cpp-core-expert.md +35 -35
  89. package/templates/agents/game-engine/render-engineer.md +22 -22
  90. package/templates/agents/game-engine/shader-engineer.md +38 -38
  91. package/templates/agents/game-engine/systems-integration.md +43 -43
  92. package/templates/agents/generic/code-reviewer.md +41 -41
  93. package/templates/agents/generic/docs-writer.md +25 -25
  94. package/templates/agents/generic/project-manager.md +36 -36
  95. package/templates/agents/generic/researcher.md +34 -34
  96. package/templates/agents/generic/test-engineer.md +41 -41
  97. package/templates/agents/i18n-engineer.md +42 -42
  98. package/templates/agents/implementer.md +42 -42
  99. package/templates/agents/migration-engineer.md +42 -42
  100. package/templates/agents/mobile/platform-specialist.md +22 -22
  101. package/templates/agents/mobile/ui-engineer.md +22 -22
  102. package/templates/agents/performance-engineer.md +49 -49
  103. package/templates/agents/refactoring-agent.md +41 -41
  104. package/templates/agents/researcher.md +38 -38
  105. package/templates/agents/security-reviewer.md +40 -40
  106. package/templates/agents/team-lead.md +37 -37
  107. package/templates/agents/tester.md +48 -48
  108. package/templates/agents/ux-reviewer.md +43 -43
  109. package/templates/agents/web-app/api-designer.md +22 -22
  110. package/templates/agents/web-app/backend-engineer.md +30 -30
  111. package/templates/agents/web-app/database-engineer.md +22 -22
  112. package/templates/agents/web-app/frontend-engineer.md +29 -29
  113. package/templates/agents/web-app/security-reviewer.md +32 -32
  114. package/templates/ci/rulebook-review.yml +26 -26
  115. package/templates/cli/AIDER.md +49 -49
  116. package/templates/cli/AMAZON_Q.md +25 -25
  117. package/templates/cli/AUGGIE.md +32 -32
  118. package/templates/cli/CLAUDE.md +117 -117
  119. package/templates/cli/CLINE.md +99 -99
  120. package/templates/cli/CODEBUDDY.md +20 -20
  121. package/templates/cli/CODEIUM.md +20 -20
  122. package/templates/cli/CODEX.md +21 -21
  123. package/templates/cli/CONTINUE.md +34 -34
  124. package/templates/cli/CURSOR_CLI.md +62 -62
  125. package/templates/cli/FACTORY.md +18 -18
  126. package/templates/cli/GEMINI.md +35 -35
  127. package/templates/cli/KILOCODE.md +18 -18
  128. package/templates/cli/OPENCODE.md +18 -18
  129. package/templates/cli/_GENERIC_TEMPLATE.md +29 -29
  130. package/templates/cli/gemini-extension.json +77 -77
  131. package/templates/commands/rulebook-decision-create.md +55 -55
  132. package/templates/commands/rulebook-decision-list.md +15 -15
  133. package/templates/commands/rulebook-knowledge-add.md +41 -41
  134. package/templates/commands/rulebook-knowledge-list.md +15 -15
  135. package/templates/commands/rulebook-learn-capture.md +48 -48
  136. package/templates/commands/rulebook-learn-list.md +13 -13
  137. package/templates/commands/rulebook-memory-save.md +48 -48
  138. package/templates/commands/rulebook-memory-search.md +47 -47
  139. package/templates/commands/rulebook-task-apply.md +67 -67
  140. package/templates/commands/rulebook-task-archive.md +94 -94
  141. package/templates/commands/rulebook-task-create.md +93 -93
  142. package/templates/commands/rulebook-task-list.md +42 -42
  143. package/templates/commands/rulebook-task-show.md +52 -52
  144. package/templates/commands/rulebook-task-validate.md +53 -53
  145. package/templates/compact-context/_default.md +23 -23
  146. package/templates/compact-context/cpp.md +26 -26
  147. package/templates/compact-context/go.md +26 -26
  148. package/templates/compact-context/python.md +26 -26
  149. package/templates/compact-context/rust.md +28 -28
  150. package/templates/compact-context/typescript.md +29 -29
  151. package/templates/core/AGENTS_OVERRIDE.md +16 -16
  152. package/templates/core/AGENT_AUTOMATION.md +296 -296
  153. package/templates/core/CLAUDE_MD_v2.md +71 -71
  154. package/templates/core/DAG.md +304 -304
  155. package/templates/core/DECISIONS.md +38 -38
  156. package/templates/core/DOCUMENTATION_RULES.md +36 -36
  157. package/templates/core/KNOWLEDGE.md +49 -49
  158. package/templates/core/MULTI_AGENT.md +74 -74
  159. package/templates/core/PLANS.md +28 -28
  160. package/templates/core/QUALITY_ENFORCEMENT.md +68 -68
  161. package/templates/core/RALPH.md +471 -471
  162. package/templates/core/RULEBOOK.md +1947 -1947
  163. package/templates/core/TIER1_PROHIBITIONS.md +154 -154
  164. package/templates/core/TOKEN_OPTIMIZATION.md +49 -49
  165. package/templates/core/WORKSPACE.md +69 -69
  166. package/templates/frameworks/ANGULAR.md +36 -36
  167. package/templates/frameworks/DJANGO.md +83 -83
  168. package/templates/frameworks/ELECTRON.md +147 -147
  169. package/templates/frameworks/FLASK.md +38 -38
  170. package/templates/frameworks/FLUTTER.md +55 -55
  171. package/templates/frameworks/JQUERY.md +32 -32
  172. package/templates/frameworks/LARAVEL.md +38 -38
  173. package/templates/frameworks/NESTJS.md +43 -43
  174. package/templates/frameworks/NEXTJS.md +127 -127
  175. package/templates/frameworks/NUXT.md +40 -40
  176. package/templates/frameworks/RAILS.md +66 -66
  177. package/templates/frameworks/REACT.md +38 -38
  178. package/templates/frameworks/REACT_NATIVE.md +47 -47
  179. package/templates/frameworks/SPRING.md +39 -39
  180. package/templates/frameworks/SYMFONY.md +36 -36
  181. package/templates/frameworks/VUE.md +36 -36
  182. package/templates/frameworks/ZEND.md +35 -35
  183. package/templates/git/CI_CD_PATTERNS.md +661 -661
  184. package/templates/git/GITHUB_ACTIONS.md +728 -728
  185. package/templates/git/GITLAB_CI.md +730 -730
  186. package/templates/git/GIT_WORKFLOW.md +1192 -1192
  187. package/templates/git/SECRETS_MANAGEMENT.md +585 -585
  188. package/templates/hooks/COMMIT_MSG.md +530 -530
  189. package/templates/hooks/POST_CHECKOUT.md +546 -546
  190. package/templates/hooks/PREPARE_COMMIT_MSG.md +619 -619
  191. package/templates/hooks/PRE_COMMIT.md +414 -414
  192. package/templates/hooks/PRE_PUSH.md +601 -601
  193. package/templates/hooks/check-context-and-handoff.ps1 +58 -58
  194. package/templates/hooks/check-context-and-handoff.sh +76 -76
  195. package/templates/hooks/enforce-team-for-background-agents.ps1 +63 -63
  196. package/templates/hooks/enforce-team-for-background-agents.sh +55 -55
  197. package/templates/hooks/on-compact-reinject.sh +34 -34
  198. package/templates/hooks/resume-from-handoff.ps1 +40 -40
  199. package/templates/hooks/resume-from-handoff.sh +61 -61
  200. package/templates/hooks/terse-activate.ps1 +143 -0
  201. package/templates/hooks/terse-activate.sh +197 -0
  202. package/templates/hooks/terse-mode-tracker.ps1 +153 -0
  203. package/templates/hooks/terse-mode-tracker.sh +187 -0
  204. package/templates/ides/CONTINUE_RULES.md +16 -16
  205. package/templates/ides/COPILOT.md +37 -37
  206. package/templates/ides/COPILOT_INSTRUCTIONS.md +23 -23
  207. package/templates/ides/CURSOR.md +43 -43
  208. package/templates/ides/GEMINI_RULES.md +17 -17
  209. package/templates/ides/JETBRAINS_AI.md +35 -35
  210. package/templates/ides/REPLIT.md +36 -36
  211. package/templates/ides/TABNINE.md +29 -29
  212. package/templates/ides/VSCODE.md +40 -40
  213. package/templates/ides/WINDSURF.md +36 -36
  214. package/templates/ides/WINDSURF_RULES.md +14 -14
  215. package/templates/ides/ZED.md +32 -32
  216. package/templates/ides/cursor-mdc/go.mdc +24 -24
  217. package/templates/ides/cursor-mdc/python.mdc +24 -24
  218. package/templates/ides/cursor-mdc/quality.mdc +25 -25
  219. package/templates/ides/cursor-mdc/ralph.mdc +39 -39
  220. package/templates/ides/cursor-mdc/rulebook.mdc +38 -38
  221. package/templates/ides/cursor-mdc/rust.mdc +24 -24
  222. package/templates/ides/cursor-mdc/typescript.mdc +25 -25
  223. package/templates/languages/C.md +333 -333
  224. package/templates/languages/CPP.md +743 -743
  225. package/templates/languages/CSHARP.md +417 -417
  226. package/templates/languages/ELIXIR.md +454 -454
  227. package/templates/languages/ERLANG.md +361 -361
  228. package/templates/languages/GO.md +645 -645
  229. package/templates/languages/HASKELL.md +177 -177
  230. package/templates/languages/JAVA.md +607 -607
  231. package/templates/languages/JAVASCRIPT.md +631 -631
  232. package/templates/languages/JULIA.md +97 -97
  233. package/templates/languages/KOTLIN.md +511 -511
  234. package/templates/languages/LISP.md +100 -100
  235. package/templates/languages/LUA.md +74 -74
  236. package/templates/languages/OBJECTIVEC.md +90 -90
  237. package/templates/languages/PHP.md +416 -416
  238. package/templates/languages/PYTHON.md +682 -682
  239. package/templates/languages/RUBY.md +421 -421
  240. package/templates/languages/RUST.md +477 -477
  241. package/templates/languages/SAS.md +73 -73
  242. package/templates/languages/SCALA.md +348 -348
  243. package/templates/languages/SOLIDITY.md +580 -580
  244. package/templates/languages/SQL.md +137 -137
  245. package/templates/languages/SWIFT.md +466 -466
  246. package/templates/languages/TYPESCRIPT.md +591 -591
  247. package/templates/languages/ZIG.md +265 -265
  248. package/templates/modules/ATLASSIAN.md +255 -255
  249. package/templates/modules/CONTEXT7.md +54 -54
  250. package/templates/modules/FIGMA.md +267 -267
  251. package/templates/modules/GITHUB_MCP.md +64 -64
  252. package/templates/modules/GRAFANA.md +328 -328
  253. package/templates/modules/MEMORY.md +126 -126
  254. package/templates/modules/NOTION.md +247 -247
  255. package/templates/modules/PLAYWRIGHT.md +90 -90
  256. package/templates/modules/RULEBOOK_MCP.md +208 -156
  257. package/templates/modules/SERENA.md +337 -337
  258. package/templates/modules/SUPABASE.md +223 -223
  259. package/templates/modules/SYNAP.md +69 -69
  260. package/templates/modules/VECTORIZER.md +63 -63
  261. package/templates/modules/sequential-thinking.md +42 -42
  262. package/templates/ralph/ralph-history.bat +4 -4
  263. package/templates/ralph/ralph-history.sh +5 -5
  264. package/templates/ralph/ralph-init.bat +5 -5
  265. package/templates/ralph/ralph-init.sh +5 -5
  266. package/templates/ralph/ralph-pause.bat +5 -5
  267. package/templates/ralph/ralph-pause.sh +5 -5
  268. package/templates/ralph/ralph-run.bat +5 -5
  269. package/templates/ralph/ralph-run.sh +5 -5
  270. package/templates/ralph/ralph-status.bat +4 -4
  271. package/templates/ralph/ralph-status.sh +5 -5
  272. package/templates/rules/consult-analysis-before-implementing.md +23 -23
  273. package/templates/rules/cpp.md +46 -46
  274. package/templates/rules/csharp.md +44 -44
  275. package/templates/rules/diagnostic-first.md +39 -39
  276. package/templates/rules/fail-twice-escalate.md +46 -46
  277. package/templates/rules/follow-task-sequence.md +36 -36
  278. package/templates/rules/git-safety.md +29 -29
  279. package/templates/rules/go.md +40 -40
  280. package/templates/rules/incremental-implementation.md +56 -56
  281. package/templates/rules/incremental-tests.md +29 -29
  282. package/templates/rules/java.md +43 -43
  283. package/templates/rules/javascript.md +39 -39
  284. package/templates/rules/knowledge-base-usage.md +41 -41
  285. package/templates/rules/multi-agent-teams.md +75 -75
  286. package/templates/rules/no-deferred.md +31 -31
  287. package/templates/rules/no-shortcuts.md +30 -30
  288. package/templates/rules/python.md +43 -43
  289. package/templates/rules/research-first.md +30 -30
  290. package/templates/rules/respect-handoff-trigger.md +41 -41
  291. package/templates/rules/rust.md +40 -40
  292. package/templates/rules/sequential-editing.md +21 -21
  293. package/templates/rules/session-workflow.md +24 -24
  294. package/templates/rules/task-decomposition.md +32 -32
  295. package/templates/rules/typescript.md +40 -40
  296. package/templates/services/AZURE_BLOB.md +184 -184
  297. package/templates/services/CASSANDRA.md +239 -239
  298. package/templates/services/DATADOG.md +26 -26
  299. package/templates/services/DOCKER.md +124 -124
  300. package/templates/services/DOCKER_COMPOSE.md +168 -168
  301. package/templates/services/DYNAMODB.md +308 -308
  302. package/templates/services/ELASTICSEARCH.md +347 -347
  303. package/templates/services/GCS.md +178 -178
  304. package/templates/services/HELM.md +194 -194
  305. package/templates/services/INFLUXDB.md +265 -265
  306. package/templates/services/KAFKA.md +341 -341
  307. package/templates/services/KUBERNETES.md +208 -208
  308. package/templates/services/MARIADB.md +183 -183
  309. package/templates/services/MEMCACHED.md +242 -242
  310. package/templates/services/MINIO.md +201 -201
  311. package/templates/services/MONGODB.md +268 -268
  312. package/templates/services/MYSQL.md +358 -358
  313. package/templates/services/NEO4J.md +247 -247
  314. package/templates/services/OPENTELEMETRY.md +25 -25
  315. package/templates/services/ORACLE.md +290 -290
  316. package/templates/services/PINO.md +24 -24
  317. package/templates/services/POSTGRESQL.md +326 -326
  318. package/templates/services/PROMETHEUS.md +33 -33
  319. package/templates/services/RABBITMQ.md +286 -286
  320. package/templates/services/REDIS.md +292 -292
  321. package/templates/services/S3.md +298 -298
  322. package/templates/services/SENTRY.md +23 -23
  323. package/templates/services/SQLITE.md +294 -294
  324. package/templates/services/SQLSERVER.md +294 -294
  325. package/templates/services/WINSTON.md +30 -30
  326. package/templates/skills/cli/aider/SKILL.md +59 -59
  327. package/templates/skills/cli/amazon-q/SKILL.md +35 -35
  328. package/templates/skills/cli/auggie/SKILL.md +42 -42
  329. package/templates/skills/cli/claude/SKILL.md +42 -42
  330. package/templates/skills/cli/cline/SKILL.md +42 -42
  331. package/templates/skills/cli/codebuddy/SKILL.md +30 -30
  332. package/templates/skills/cli/codeium/SKILL.md +30 -30
  333. package/templates/skills/cli/codex/SKILL.md +31 -31
  334. package/templates/skills/cli/continue/SKILL.md +44 -44
  335. package/templates/skills/cli/cursor-cli/SKILL.md +38 -38
  336. package/templates/skills/cli/factory/SKILL.md +28 -28
  337. package/templates/skills/cli/gemini/SKILL.md +45 -45
  338. package/templates/skills/cli/kilocode/SKILL.md +28 -28
  339. package/templates/skills/cli/opencode/SKILL.md +28 -28
  340. package/templates/skills/core/agent-automation/SKILL.md +194 -194
  341. package/templates/skills/core/dag/SKILL.md +314 -314
  342. package/templates/skills/core/documentation-rules/SKILL.md +46 -46
  343. package/templates/skills/core/quality-enforcement/SKILL.md +78 -78
  344. package/templates/skills/core/rulebook/SKILL.md +176 -176
  345. package/templates/skills/core/rulebook-terse/SKILL.md +116 -0
  346. package/templates/skills/core/rulebook-terse-commit/SKILL.md +96 -0
  347. package/templates/skills/core/rulebook-terse-review/SKILL.md +112 -0
  348. package/templates/skills/dev/accessibility/SKILL.md +17 -17
  349. package/templates/skills/dev/analysis/SKILL.md +19 -19
  350. package/templates/skills/dev/api-design/SKILL.md +15 -15
  351. package/templates/skills/dev/architect/SKILL.md +17 -17
  352. package/templates/skills/dev/build-fix/SKILL.md +17 -17
  353. package/templates/skills/dev/db-design/SKILL.md +15 -15
  354. package/templates/skills/dev/debug/SKILL.md +16 -16
  355. package/templates/skills/dev/deploy/SKILL.md +17 -17
  356. package/templates/skills/dev/docs/SKILL.md +17 -17
  357. package/templates/skills/dev/handoff/SKILL.md +27 -27
  358. package/templates/skills/dev/migrate/SKILL.md +15 -15
  359. package/templates/skills/dev/perf/SKILL.md +17 -17
  360. package/templates/skills/dev/refactor/SKILL.md +17 -17
  361. package/templates/skills/dev/research/SKILL.md +14 -14
  362. package/templates/skills/dev/review/SKILL.md +18 -18
  363. package/templates/skills/dev/security-audit/SKILL.md +17 -17
  364. package/templates/skills/frameworks/angular/SKILL.md +46 -46
  365. package/templates/skills/frameworks/django/SKILL.md +93 -93
  366. package/templates/skills/frameworks/electron/SKILL.md +157 -157
  367. package/templates/skills/frameworks/flask/SKILL.md +48 -48
  368. package/templates/skills/frameworks/flutter/SKILL.md +65 -65
  369. package/templates/skills/frameworks/jquery/SKILL.md +42 -42
  370. package/templates/skills/frameworks/laravel/SKILL.md +48 -48
  371. package/templates/skills/frameworks/nestjs/SKILL.md +53 -53
  372. package/templates/skills/frameworks/nextjs/SKILL.md +137 -137
  373. package/templates/skills/frameworks/nuxt/SKILL.md +50 -50
  374. package/templates/skills/frameworks/rails/SKILL.md +76 -76
  375. package/templates/skills/frameworks/react/SKILL.md +48 -48
  376. package/templates/skills/frameworks/react-native/SKILL.md +57 -57
  377. package/templates/skills/frameworks/spring/SKILL.md +49 -49
  378. package/templates/skills/frameworks/symfony/SKILL.md +46 -46
  379. package/templates/skills/frameworks/vue/SKILL.md +46 -46
  380. package/templates/skills/frameworks/zend/SKILL.md +45 -45
  381. package/templates/skills/ides/copilot/SKILL.md +47 -47
  382. package/templates/skills/ides/cursor/SKILL.md +53 -53
  383. package/templates/skills/ides/jetbrains-ai/SKILL.md +45 -45
  384. package/templates/skills/ides/replit/SKILL.md +46 -46
  385. package/templates/skills/ides/tabnine/SKILL.md +39 -39
  386. package/templates/skills/ides/vscode/SKILL.md +50 -50
  387. package/templates/skills/ides/windsurf/SKILL.md +46 -46
  388. package/templates/skills/ides/zed/SKILL.md +42 -42
  389. package/templates/skills/languages/c/SKILL.md +343 -343
  390. package/templates/skills/languages/cpp/SKILL.md +753 -753
  391. package/templates/skills/languages/csharp/SKILL.md +427 -427
  392. package/templates/skills/languages/elixir/SKILL.md +464 -464
  393. package/templates/skills/languages/erlang/SKILL.md +371 -371
  394. package/templates/skills/languages/go/SKILL.md +655 -655
  395. package/templates/skills/languages/haskell/SKILL.md +187 -187
  396. package/templates/skills/languages/java/SKILL.md +617 -617
  397. package/templates/skills/languages/javascript/SKILL.md +641 -641
  398. package/templates/skills/languages/julia/SKILL.md +107 -107
  399. package/templates/skills/languages/kotlin/SKILL.md +521 -521
  400. package/templates/skills/languages/lisp/SKILL.md +110 -110
  401. package/templates/skills/languages/lua/SKILL.md +84 -84
  402. package/templates/skills/languages/objectivec/SKILL.md +100 -100
  403. package/templates/skills/languages/php/SKILL.md +426 -426
  404. package/templates/skills/languages/python/SKILL.md +692 -692
  405. package/templates/skills/languages/ruby/SKILL.md +431 -431
  406. package/templates/skills/languages/rust/SKILL.md +487 -487
  407. package/templates/skills/languages/sas/SKILL.md +83 -83
  408. package/templates/skills/languages/scala/SKILL.md +358 -358
  409. package/templates/skills/languages/solidity/SKILL.md +590 -590
  410. package/templates/skills/languages/sql/SKILL.md +147 -147
  411. package/templates/skills/languages/swift/SKILL.md +476 -476
  412. package/templates/skills/languages/typescript/SKILL.md +302 -302
  413. package/templates/skills/languages/zig/SKILL.md +275 -275
  414. package/templates/skills/modules/atlassian/SKILL.md +265 -265
  415. package/templates/skills/modules/context7/SKILL.md +64 -64
  416. package/templates/skills/modules/figma/SKILL.md +277 -277
  417. package/templates/skills/modules/github-mcp/SKILL.md +74 -74
  418. package/templates/skills/modules/grafana/SKILL.md +338 -338
  419. package/templates/skills/modules/memory/SKILL.md +73 -73
  420. package/templates/skills/modules/notion/SKILL.md +257 -257
  421. package/templates/skills/modules/playwright/SKILL.md +100 -100
  422. package/templates/skills/modules/rulebook-mcp/SKILL.md +166 -166
  423. package/templates/skills/modules/serena/SKILL.md +347 -347
  424. package/templates/skills/modules/supabase/SKILL.md +233 -233
  425. package/templates/skills/modules/synap/SKILL.md +79 -79
  426. package/templates/skills/modules/vectorizer/SKILL.md +73 -73
  427. package/templates/skills/services/azure-blob/SKILL.md +194 -194
  428. package/templates/skills/services/cassandra/SKILL.md +249 -249
  429. package/templates/skills/services/dynamodb/SKILL.md +318 -318
  430. package/templates/skills/services/elasticsearch/SKILL.md +357 -357
  431. package/templates/skills/services/gcs/SKILL.md +188 -188
  432. package/templates/skills/services/influxdb/SKILL.md +275 -275
  433. package/templates/skills/services/kafka/SKILL.md +351 -351
  434. package/templates/skills/services/mariadb/SKILL.md +193 -193
  435. package/templates/skills/services/memcached/SKILL.md +252 -252
  436. package/templates/skills/services/minio/SKILL.md +211 -211
  437. package/templates/skills/services/mongodb/SKILL.md +278 -278
  438. package/templates/skills/services/mysql/SKILL.md +368 -368
  439. package/templates/skills/services/neo4j/SKILL.md +257 -257
  440. package/templates/skills/services/oracle/SKILL.md +300 -300
  441. package/templates/skills/services/postgresql/SKILL.md +336 -336
  442. package/templates/skills/services/rabbitmq/SKILL.md +296 -296
  443. package/templates/skills/services/redis/SKILL.md +302 -302
  444. package/templates/skills/services/s3/SKILL.md +308 -308
  445. package/templates/skills/services/sqlite/SKILL.md +304 -304
  446. package/templates/skills/services/sqlserver/SKILL.md +304 -304
  447. package/templates/skills/workflows/ralph/SKILL.md +309 -309
  448. package/templates/skills/workflows/ralph/install.sh +87 -87
  449. package/templates/skills/workflows/ralph/manifest.json +158 -158
  450. package/templates/workflows/codespell.yml +31 -31
  451. package/templates/workflows/cpp-lint.yml +47 -47
  452. package/templates/workflows/cpp-publish.yml +119 -119
  453. package/templates/workflows/cpp-test.yml +77 -77
  454. package/templates/workflows/dotnet-lint.yml +29 -29
  455. package/templates/workflows/dotnet-publish.yml +40 -40
  456. package/templates/workflows/dotnet-test.yml +41 -41
  457. package/templates/workflows/elixir-lint.yml +45 -45
  458. package/templates/workflows/elixir-publish.yml +49 -49
  459. package/templates/workflows/elixir-test.yml +54 -54
  460. package/templates/workflows/erlang-lint.yml +47 -47
  461. package/templates/workflows/erlang-test.yml +62 -62
  462. package/templates/workflows/go-lint.yml +39 -39
  463. package/templates/workflows/go-publish.yml +95 -95
  464. package/templates/workflows/go-test.yml +59 -59
  465. package/templates/workflows/java-lint.yml +60 -60
  466. package/templates/workflows/java-publish.yml +120 -120
  467. package/templates/workflows/java-test.yml +85 -85
  468. package/templates/workflows/kotlin-lint.yml +34 -34
  469. package/templates/workflows/kotlin-publish.yml +56 -56
  470. package/templates/workflows/kotlin-test.yml +48 -48
  471. package/templates/workflows/php-lint.yml +39 -39
  472. package/templates/workflows/php-publish.yml +50 -50
  473. package/templates/workflows/php-test.yml +54 -54
  474. package/templates/workflows/python-lint.yml +47 -47
  475. package/templates/workflows/python-publish.yml +91 -91
  476. package/templates/workflows/python-test.yml +59 -59
  477. package/templates/workflows/rust-lint.yml +54 -54
  478. package/templates/workflows/rust-publish.yml +66 -66
  479. package/templates/workflows/rust-test.yml +75 -75
  480. package/templates/workflows/solidity-lint.yml +41 -41
  481. package/templates/workflows/solidity-test.yml +47 -47
  482. package/templates/workflows/swift-lint.yml +32 -32
  483. package/templates/workflows/swift-publish.yml +58 -58
  484. package/templates/workflows/swift-test.yml +44 -44
  485. package/templates/workflows/typescript-publish.yml +60 -60
  486. package/templates/workflows/typescript-test.yml +73 -73
  487. package/templates/workflows/zig-lint.yml +27 -27
  488. package/templates/workflows/zig-test.yml +40 -40
  489. package/dist/cli/commands.d.ts +0 -225
  490. package/dist/cli/commands.d.ts.map +0 -1
  491. package/dist/cli/commands.js +0 -3984
  492. package/dist/cli/commands.js.map +0 -1
@@ -0,0 +1,232 @@
1
+ /**
2
+ * Deterministic prose compressor for `rulebook compress`.
3
+ *
4
+ * Applies only SAFE transformations — filler-word removal, pleasantry
5
+ * stripping, and redundant-phrase replacement. Never restructures
6
+ * sentences, never touches code, URLs, paths, commands, dates, or
7
+ * version numbers. That conservative scope is what makes the
8
+ * validator in `validator.ts` a sufficient safety net.
9
+ *
10
+ * When richer compression is wanted (useMemo → stabilize, "implement
11
+ * a solution for" → "fix"), the user can layer Claude-powered
12
+ * rewriting on top of this module. The validator contract is
13
+ * orthogonal to the rewriter — any future LLM-backed compressor gets
14
+ * graded against the same invariants.
15
+ *
16
+ * Grounded in `.rulebook/specs/RULEBOOK_TERSE.md` §Compression
17
+ * companion.
18
+ */
19
+ import { extractors, validate } from './validator.js';
20
+ // ── Transformation rules — order matters (phrase replacements first) ──
21
+ /** Redundant phrases → shorter synonym. Applied to prose only. */
22
+ const PHRASE_REPLACEMENTS = [
23
+ [/\bin order to\b/gi, 'to'],
24
+ [/\bmake sure to\b/gi, 'ensure'],
25
+ [/\bmake sure that\b/gi, 'ensure'],
26
+ [/\bthe reason is because\b/gi, 'because'],
27
+ [/\bthe reason why\b/gi, 'why'],
28
+ [/\bat this point in time\b/gi, 'now'],
29
+ [/\bwith regard to\b/gi, 'on'],
30
+ [/\bwith respect to\b/gi, 'on'],
31
+ [/\bdue to the fact that\b/gi, 'because'],
32
+ [/\ba number of\b/gi, 'several'],
33
+ [/\bfor the purpose of\b/gi, 'to'],
34
+ [/\bit is important to note that\b/gi, ''],
35
+ [/\bit should be noted that\b/gi, ''],
36
+ ];
37
+ /** Leading pleasantries to strip from prose segments. */
38
+ const PLEASANTRY_PREFIXES = [
39
+ /^\s*(sure|certainly|of course)[,!.]?\s+/i,
40
+ /^\s*(happy to help|great question|good point)[,!.]?\s+/i,
41
+ /^\s*(i'd|i would) be happy to[^.]*\.\s+/i,
42
+ /^\s*(let me)[^.]*\.\s+/i,
43
+ ];
44
+ /** Filler words removed when they appear between word-boundaries. */
45
+ const FILLER_WORDS = [
46
+ 'just',
47
+ 'really',
48
+ 'basically',
49
+ 'actually',
50
+ 'simply',
51
+ 'essentially',
52
+ 'generally',
53
+ 'frankly',
54
+ 'honestly',
55
+ 'literally',
56
+ 'very',
57
+ 'quite',
58
+ 'perhaps',
59
+ 'maybe',
60
+ ];
61
+ /** Hedging phrases to remove. */
62
+ const HEDGING_PATTERNS = [
63
+ /\bit might be worth\b/gi,
64
+ /\byou could consider\b/gi,
65
+ /\byou (?:may|might) want to\b/gi,
66
+ /\bi (?:think|believe|feel) that\b/gi,
67
+ // Lookahead uses `\s*\w` to tolerate whitespace collapsed by earlier
68
+ // substitutions (e.g. "I think consider" after a "you might want to"
69
+ // strip leaves a double space before the next word).
70
+ /\bi (?:think|believe|feel)\s+(?=\w)/gi,
71
+ /\bin my opinion,?\s*/gi,
72
+ ];
73
+ /**
74
+ * Split input into protected and prose segments.
75
+ * Protected: fenced code blocks, inline code, URLs.
76
+ * Everything else is prose.
77
+ */
78
+ function segment(input) {
79
+ const segments = [];
80
+ // Layered matches: fenced code, inline code, URLs. First we build a
81
+ // mask of protected character ranges; prose is the complement.
82
+ const mask = new Array(input.length).fill(false);
83
+ const markRanges = (re) => {
84
+ const matches = input.matchAll(re);
85
+ for (const m of matches) {
86
+ if (m.index === undefined)
87
+ continue;
88
+ for (let i = m.index; i < m.index + m[0].length; i++)
89
+ mask[i] = true;
90
+ }
91
+ };
92
+ // Capture fenced code FIRST so inline-code inside ``` blocks doesn't
93
+ // get double-marked (it's already inside a fenced region).
94
+ markRanges(extractors.FENCED_CODE_RE);
95
+ // Inline code — recomputed on a version where fenced blocks are
96
+ // masked out so we don't match inside them.
97
+ const stripped = input
98
+ .split('')
99
+ .map((c, i) => (mask[i] ? ' ' : c))
100
+ .join('');
101
+ const inlineMatches = stripped.matchAll(extractors.INLINE_CODE_RE);
102
+ for (const m of inlineMatches) {
103
+ if (m.index === undefined)
104
+ continue;
105
+ for (let i = m.index; i < m.index + m[0].length; i++)
106
+ mask[i] = true;
107
+ }
108
+ markRanges(extractors.URL_RE);
109
+ markRanges(extractors.PATH_RE);
110
+ markRanges(extractors.DATE_RE);
111
+ markRanges(extractors.VERSION_RE);
112
+ // Now scan the mask to build contiguous segments.
113
+ let i = 0;
114
+ while (i < input.length) {
115
+ const isProtected = mask[i];
116
+ let j = i;
117
+ while (j < input.length && mask[j] === isProtected)
118
+ j++;
119
+ segments.push({ protected: isProtected, text: input.slice(i, j) });
120
+ i = j;
121
+ }
122
+ return segments;
123
+ }
124
+ // ── Prose rewriter ────────────────────────────────────────────────────
125
+ function stripFillerWord(text, word) {
126
+ // Remove ", just," / " just " / " just." patterns but preserve
127
+ // sentence boundaries. Matches word only when surrounded by word
128
+ // boundaries and whitespace, not at the start of a capitalized
129
+ // sentence (where removal changes meaning more aggressively).
130
+ const pattern = new RegExp(`(?<=\\s|^)${word}\\s+(?=[a-zA-Z])`, 'gi');
131
+ return text.replace(pattern, '');
132
+ }
133
+ function compressProse(prose) {
134
+ let out = prose;
135
+ // 1. Strip leading pleasantries.
136
+ for (const re of PLEASANTRY_PREFIXES) {
137
+ out = out.replace(re, '');
138
+ }
139
+ // 2. Remove hedging phrases.
140
+ for (const re of HEDGING_PATTERNS) {
141
+ out = out.replace(re, '');
142
+ }
143
+ // 3. Apply phrase replacements.
144
+ for (const [re, repl] of PHRASE_REPLACEMENTS) {
145
+ out = out.replace(re, repl);
146
+ }
147
+ // 4. Remove filler words (as standalone mid-sentence tokens).
148
+ for (const word of FILLER_WORDS) {
149
+ out = stripFillerWord(out, word);
150
+ }
151
+ // 5. Normalize whitespace artifacts introduced by deletions.
152
+ out = out
153
+ .replace(/\s+([,.;:!?])/g, '$1') // collapse space-before-punct
154
+ .replace(/[ \t]{2,}/g, ' ') // collapse multiple spaces
155
+ .replace(/\n[ \t]+\n/g, '\n\n'); // trim trailing whitespace on blank lines
156
+ return out;
157
+ }
158
+ /**
159
+ * Compress `input` using the deterministic rewriter. Returns the
160
+ * compressed output along with the validation result and retry count.
161
+ *
162
+ * The retry loop is defensive: on this conservative algorithm we
163
+ * should never produce a validation failure (we only touch prose
164
+ * segments), so a failure means either (a) a prose segment
165
+ * contained a protected pattern we missed, or (b) an unusual edge
166
+ * case in the splitter. Retries progressively disable classes of
167
+ * transformations to preserve as much safety as possible.
168
+ */
169
+ export function compress(input, options = {}) {
170
+ const maxRetries = options.maxRetries ?? 2;
171
+ let retries = 0;
172
+ let output = applyCompression(input, {
173
+ pleasantries: true,
174
+ hedging: true,
175
+ phraseReplacements: true,
176
+ fillerWords: true,
177
+ });
178
+ let validation = validate(input, output);
179
+ while (!validation.ok && retries < maxRetries) {
180
+ retries++;
181
+ // On retry 1 → disable filler words (most aggressive class).
182
+ // On retry 2 → also disable hedging.
183
+ // If still failing, fall through and return the failure state.
184
+ output = applyCompression(input, {
185
+ pleasantries: true,
186
+ hedging: retries < 2,
187
+ phraseReplacements: true,
188
+ fillerWords: false,
189
+ });
190
+ validation = validate(input, output);
191
+ }
192
+ return { output, retries, validation };
193
+ }
194
+ function applyCompression(input, enabled) {
195
+ const segs = segment(input);
196
+ const pieces = [];
197
+ for (const s of segs) {
198
+ if (s.protected) {
199
+ // Protected segments MUST pass through byte-identically.
200
+ // No whitespace normalization, no substitutions.
201
+ pieces.push(s.text);
202
+ continue;
203
+ }
204
+ let rewritten = s.text;
205
+ if (enabled.pleasantries) {
206
+ for (const re of PLEASANTRY_PREFIXES)
207
+ rewritten = rewritten.replace(re, '');
208
+ }
209
+ if (enabled.hedging) {
210
+ for (const re of HEDGING_PATTERNS)
211
+ rewritten = rewritten.replace(re, '');
212
+ }
213
+ if (enabled.phraseReplacements) {
214
+ for (const [re, repl] of PHRASE_REPLACEMENTS)
215
+ rewritten = rewritten.replace(re, repl);
216
+ }
217
+ if (enabled.fillerWords) {
218
+ for (const word of FILLER_WORDS)
219
+ rewritten = stripFillerWord(rewritten, word);
220
+ }
221
+ // Whitespace normalization INSIDE prose segments only. Keep
222
+ // inter-paragraph blank lines (don't collapse \n\n → \n).
223
+ rewritten = rewritten.replace(/ +([,.;:!?])/g, '$1').replace(/[ \t]{2,}/g, ' ');
224
+ pieces.push(rewritten);
225
+ }
226
+ return pieces.join('');
227
+ }
228
+ /**
229
+ * Exported for tests.
230
+ */
231
+ export const __test__ = { compressProse, segment };
232
+ //# sourceMappingURL=compressor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compressor.js","sourceRoot":"","sources":["../../../src/core/compress/compressor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAyB,MAAM,gBAAgB,CAAC;AAa7E,yEAAyE;AAEzE,kEAAkE;AAClE,MAAM,mBAAmB,GAAoC;IAC3D,CAAC,mBAAmB,EAAE,IAAI,CAAC;IAC3B,CAAC,oBAAoB,EAAE,QAAQ,CAAC;IAChC,CAAC,sBAAsB,EAAE,QAAQ,CAAC;IAClC,CAAC,6BAA6B,EAAE,SAAS,CAAC;IAC1C,CAAC,sBAAsB,EAAE,KAAK,CAAC;IAC/B,CAAC,6BAA6B,EAAE,KAAK,CAAC;IACtC,CAAC,sBAAsB,EAAE,IAAI,CAAC;IAC9B,CAAC,uBAAuB,EAAE,IAAI,CAAC;IAC/B,CAAC,4BAA4B,EAAE,SAAS,CAAC;IACzC,CAAC,mBAAmB,EAAE,SAAS,CAAC;IAChC,CAAC,0BAA0B,EAAE,IAAI,CAAC;IAClC,CAAC,oCAAoC,EAAE,EAAE,CAAC;IAC1C,CAAC,+BAA+B,EAAE,EAAE,CAAC;CACtC,CAAC;AAEF,yDAAyD;AACzD,MAAM,mBAAmB,GAA0B;IACjD,0CAA0C;IAC1C,yDAAyD;IACzD,0CAA0C;IAC1C,yBAAyB;CAC1B,CAAC;AAEF,qEAAq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,GAAG,CAAC,CAAC,IAAI,CAAC;QACvB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;YACzB,KAAK,MAAM,EAAE,IAAI,mBAAmB;gBAAE,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9E,CAAC;QACD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,KAAK,MAAM,EAAE,IAAI,gBAAgB;gBAAE,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC3E,CAAC;QACD,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;YAC/B,KAAK,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,mBAAmB;gBAAE,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QACxF,CAAC;QACD,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;YACxB,KAAK,MAAM,IAAI,IAAI,YAAY;gBAAE,SAAS,GAAG,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAChF,CAAC;QACD,4DAA4D;QAC5D,0DAA0D;QAC1D,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;QAChF,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Discover candidate markdown memory files in a project.
3
+ *
4
+ * Caveman-compress is advertised as a tool for the files the model
5
+ * READS on every session, so this helper surfaces the same class of
6
+ * files: project-root memory markdown (`CLAUDE.md`, `AGENTS.md`,
7
+ * `AGENTS.override.md`) plus long-lived `.rulebook/` notes and
8
+ * knowledge/learning entries.
9
+ */
10
+ export interface Candidate {
11
+ relPath: string;
12
+ absPath: string;
13
+ bytes: number;
14
+ hasBackup: boolean;
15
+ backupBytes?: number;
16
+ backupRatio?: number;
17
+ }
18
+ export declare function listCompressCandidates(projectRoot: string): Promise<Candidate[]>;
19
+ //# sourceMappingURL=discover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../../src/core/compress/discover.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA0CD,wBAAsB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAmDtF"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Discover candidate markdown memory files in a project.
3
+ *
4
+ * Caveman-compress is advertised as a tool for the files the model
5
+ * READS on every session, so this helper surfaces the same class of
6
+ * files: project-root memory markdown (`CLAUDE.md`, `AGENTS.md`,
7
+ * `AGENTS.override.md`) plus long-lived `.rulebook/` notes and
8
+ * knowledge/learning entries.
9
+ */
10
+ import { readdir, stat } from 'node:fs/promises';
11
+ import { join } from 'node:path';
12
+ const ROOT_FILE_GLOB = ['CLAUDE.md', 'CLAUDE.local.md', 'AGENTS.md', 'AGENTS.override.md'];
13
+ const RULEBOOK_SUBPATHS = [
14
+ '.rulebook/PLANS.md',
15
+ '.rulebook/STATE.md',
16
+ '.rulebook/knowledge',
17
+ '.rulebook/learnings',
18
+ ];
19
+ async function safeStat(path) {
20
+ try {
21
+ const s = await stat(path);
22
+ return { exists: true, size: s.size };
23
+ }
24
+ catch {
25
+ return { exists: false, size: 0 };
26
+ }
27
+ }
28
+ function backupPathFor(filePath) {
29
+ return filePath.replace(/\.md$/i, '.original.md');
30
+ }
31
+ async function walkMarkdown(dir, out) {
32
+ let entries;
33
+ try {
34
+ entries = await readdir(dir, { withFileTypes: true });
35
+ }
36
+ catch {
37
+ return;
38
+ }
39
+ for (const e of entries) {
40
+ if (e.name.startsWith('.'))
41
+ continue;
42
+ const full = join(dir, e.name);
43
+ if (e.isDirectory()) {
44
+ await walkMarkdown(full, out);
45
+ }
46
+ else if (e.name.endsWith('.md') && !e.name.endsWith('.original.md')) {
47
+ out.push(full);
48
+ }
49
+ }
50
+ }
51
+ export async function listCompressCandidates(projectRoot) {
52
+ const found = [];
53
+ for (const name of ROOT_FILE_GLOB) {
54
+ const p = join(projectRoot, name);
55
+ if ((await safeStat(p)).exists)
56
+ found.push(p);
57
+ }
58
+ for (const sub of RULEBOOK_SUBPATHS) {
59
+ const p = join(projectRoot, sub);
60
+ const s = await safeStat(p);
61
+ if (!s.exists)
62
+ continue;
63
+ try {
64
+ const statRes = await stat(p);
65
+ if (statRes.isDirectory()) {
66
+ await walkMarkdown(p, found);
67
+ }
68
+ else {
69
+ found.push(p);
70
+ }
71
+ }
72
+ catch {
73
+ /* ignore */
74
+ }
75
+ }
76
+ const candidates = [];
77
+ for (const abs of found) {
78
+ const fileStat = await safeStat(abs);
79
+ const backupPath = backupPathFor(abs);
80
+ const backupStat = await safeStat(backupPath);
81
+ const relPath = abs.startsWith(projectRoot)
82
+ ? abs.slice(projectRoot.length).replace(/^[\\/]/, '')
83
+ : abs;
84
+ const candidate = {
85
+ relPath,
86
+ absPath: abs,
87
+ bytes: fileStat.size,
88
+ hasBackup: backupStat.exists,
89
+ };
90
+ if (backupStat.exists && backupStat.size > 0) {
91
+ candidate.backupBytes = backupStat.size;
92
+ candidate.backupRatio = fileStat.size / backupStat.size;
93
+ }
94
+ candidates.push(candidate);
95
+ }
96
+ // Sort by largest first so the caller sees the biggest win targets.
97
+ candidates.sort((a, b) => b.bytes - a.bytes);
98
+ return candidates;
99
+ }
100
+ //# sourceMappingURL=discover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discover.js","sourceRoot":"","sources":["../../../src/core/compress/discover.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAWjC,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,iBAAiB,EAAE,WAAW,EAAE,oBAAoB,CAAC,CAAC;AAE3F,MAAM,iBAAiB,GAAsB;IAC3C,oBAAoB;IACpB,oBAAoB;IACpB,qBAAqB;IACrB,qBAAqB;CACtB,CAAC;AAEF,KAAK,UAAU,QAAQ,CAAC,IAAY;IAClC,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACxC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IACpC,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB;IACrC,OAAO,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;AACpD,CAAC;AAED,KAAK,UAAU,YAAY,CAAC,GAAW,EAAE,GAAa;IACpD,IAAI,OAAO,CAAC;IACZ,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;IACT,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACxB,IA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2
+ * Validator for `rulebook compress`.
3
+ *
4
+ * The compressor may only rewrite prose. Everything that carries
5
+ * technical substance MUST round-trip byte-identically between the
6
+ * original file and the compressed output. This module defines the
7
+ * protected-region extractors and the diff-checker that compares
8
+ * them.
9
+ *
10
+ * Grounded in `.rulebook/specs/RULEBOOK_TERSE.md` §Compression
11
+ * companion and `docs/analysis/caveman/02-skill-design.md`.
12
+ */
13
+ export type ViolationKind = 'heading-missing' | 'heading-text-changed' | 'fenced-code-changed' | 'inline-code-changed' | 'url-changed' | 'path-changed' | 'command-changed' | 'date-changed' | 'version-changed';
14
+ export interface Violation {
15
+ kind: ViolationKind;
16
+ detail: string;
17
+ }
18
+ export interface ValidationResult {
19
+ ok: boolean;
20
+ violations: Violation[];
21
+ stats: {
22
+ originalBytes: number;
23
+ compressedBytes: number;
24
+ ratio: number;
25
+ };
26
+ }
27
+ /** Extract atomic markdown heading entries as "level\ttext" strings. */
28
+ declare function extractHeadings(source: string): string[];
29
+ /** Extract inline-code bodies (the text inside backticks). */
30
+ declare function extractInlineCode(source: string): string[];
31
+ export declare function validate(original: string, compressed: string): ValidationResult;
32
+ /**
33
+ * Exposed for tests and the compressor's retry logic.
34
+ */
35
+ export declare const extractors: {
36
+ FENCED_CODE_RE: RegExp;
37
+ INLINE_CODE_RE: RegExp;
38
+ URL_RE: RegExp;
39
+ DATE_RE: RegExp;
40
+ VERSION_RE: RegExp;
41
+ HEADING_RE: RegExp;
42
+ PATH_RE: RegExp;
43
+ extractHeadings: typeof extractHeadings;
44
+ extractInlineCode: typeof extractInlineCode;
45
+ };
46
+ export {};
47
+ //# sourceMappingURL=validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../src/core/compress/validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,MAAM,aAAa,GACrB,iBAAiB,GACjB,sBAAsB,GACtB,qBAAqB,GACrB,qBAAqB,GACrB,aAAa,GACb,cAAc,GACd,iBAAiB,GACjB,cAAc,GACd,iBAAiB,CAAC;AAEtB,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,OAAO,CAAC;IACZ,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,KAAK,EAAE;QACL,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;QACxB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AA8BD,wEAAwE;AACxE,iBAAS,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAKjD;AAED,8DAA8D;AAC9D,iBAAS,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAOnD;AAsCD,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,gBAAgB,CAoD/E;AAED;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;CAUtB,CAAC"}
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Validator for `rulebook compress`.
3
+ *
4
+ * The compressor may only rewrite prose. Everything that carries
5
+ * technical substance MUST round-trip byte-identically between the
6
+ * original file and the compressed output. This module defines the
7
+ * protected-region extractors and the diff-checker that compares
8
+ * them.
9
+ *
10
+ * Grounded in `.rulebook/specs/RULEBOOK_TERSE.md` §Compression
11
+ * companion and `docs/analysis/caveman/02-skill-design.md`.
12
+ */
13
+ // ── Regex patterns — all non-greedy, multiline where needed ───────────
14
+ const FENCED_CODE_RE = /```[\s\S]*?```/g;
15
+ const INLINE_CODE_RE = /(?<!`)`([^`\n]+)`(?!`)/g;
16
+ // URL must not consume trailing sentence-ending punctuation (. , ; : ! ?).
17
+ const URL_RE = /\bhttps?:\/\/[^\s)>\]"'`]*[^\s)>\]"'`.,;:!?]/g;
18
+ const DATE_RE = /\b\d{4}-\d{2}-\d{2}\b/g;
19
+ // Version numbers: optional `v`, then X.Y or X.Y.Z(-suffix).
20
+ const VERSION_RE = /\bv?\d+\.\d+(?:\.\d+)?(?:-[\w.]+)?\b/g;
21
+ // ATX-style markdown headings.
22
+ const HEADING_RE = /^(#{1,6})\s+(.+?)\s*$/gm;
23
+ // File paths. Three alternatives:
24
+ // relative: `./foo/bar` or `../baz`
25
+ // Windows : `C:\Users\...`
26
+ // absolute Unix: `/usr/local/bin/node` — requires start-of-line or whitespace/paren prefix.
27
+ const PATH_RE = /(?:\.{1,2}\/[\w./\\-]+|[A-Za-z]:\\[\w./\\-]+|(?<=^|[\s(])\/[a-zA-Z][\w./\\-]+)/gm;
28
+ function normalize(arr) {
29
+ return arr.slice().sort();
30
+ }
31
+ function extract(source, re) {
32
+ const out = [];
33
+ const matches = source.matchAll(re);
34
+ for (const m of matches)
35
+ out.push(m[0]);
36
+ return out;
37
+ }
38
+ /** Extract atomic markdown heading entries as "level\ttext" strings. */
39
+ function extractHeadings(source) {
40
+ const out = [];
41
+ const matches = source.matchAll(HEADING_RE);
42
+ for (const m of matches)
43
+ out.push(`${m[1].length}\t${m[2]}`);
44
+ return out;
45
+ }
46
+ /** Extract inline-code bodies (the text inside backticks). */
47
+ function extractInlineCode(source) {
48
+ const out = [];
49
+ // Strip fenced blocks first so we don't double-count code inside ```.
50
+ const scrubbed = source.replace(FENCED_CODE_RE, '');
51
+ const matches = scrubbed.matchAll(INLINE_CODE_RE);
52
+ for (const m of matches)
53
+ out.push(m[1]);
54
+ return out;
55
+ }
56
+ function diff(label, original, compressed) {
57
+ const violations = [];
58
+ const normalOrig = normalize(original);
59
+ const normalComp = normalize(compressed);
60
+ // Everything in original must appear in compressed, same count.
61
+ const compCount = new Map();
62
+ for (const v of normalComp)
63
+ compCount.set(v, (compCount.get(v) ?? 0) + 1);
64
+ for (const v of normalOrig) {
65
+ const n = compCount.get(v) ?? 0;
66
+ if (n === 0) {
67
+ violations.push({
68
+ kind: label,
69
+ detail: `missing from compressed output: ${JSON.stringify(v).slice(0, 120)}`,
70
+ });
71
+ }
72
+ else {
73
+ compCount.set(v, n - 1);
74
+ }
75
+ }
76
+ // Anything LEFT in compCount that came from compressed but wasn't in
77
+ // original means the compressor introduced a new protected item (for
78
+ // example by mistranscribing a URL). That is also a violation.
79
+ for (const [v, n] of compCount) {
80
+ if (n > 0) {
81
+ violations.push({
82
+ kind: label,
83
+ detail: `introduced in compressed output: ${JSON.stringify(v).slice(0, 120)}`,
84
+ });
85
+ }
86
+ }
87
+ return violations;
88
+ }
89
+ export function validate(original, compressed) {
90
+ const violations = [];
91
+ // Heading structure (level + text) must match exactly.
92
+ violations.push(...diff('heading-missing', extractHeadings(original), extractHeadings(compressed)));
93
+ // Fenced code blocks — byte-for-byte, ordered.
94
+ violations.push(...diff('fenced-code-changed', extract(original, FENCED_CODE_RE), extract(compressed, FENCED_CODE_RE)));
95
+ // Inline code bodies.
96
+ violations.push(...diff('inline-code-changed', extractInlineCode(original), extractInlineCode(compressed)));
97
+ // URLs.
98
+ violations.push(...diff('url-changed', extract(original, URL_RE), extract(compressed, URL_RE)));
99
+ // File paths.
100
+ violations.push(...diff('path-changed', extract(original, PATH_RE), extract(compressed, PATH_RE)));
101
+ // Dates.
102
+ violations.push(...diff('date-changed', extract(original, DATE_RE), extract(compressed, DATE_RE)));
103
+ // Version numbers.
104
+ violations.push(...diff('version-changed', extract(original, VERSION_RE), extract(compressed, VERSION_RE)));
105
+ const originalBytes = Buffer.byteLength(original, 'utf8');
106
+ const compressedBytes = Buffer.byteLength(compressed, 'utf8');
107
+ return {
108
+ ok: violations.length === 0,
109
+ violations,
110
+ stats: {
111
+ originalBytes,
112
+ compressedBytes,
113
+ ratio: originalBytes > 0 ? compressedBytes / originalBytes : 1,
114
+ },
115
+ };
116
+ }
117
+ /**
118
+ * Exposed for tests and the compressor's retry logic.
119
+ */
120
+ export const extractors = {
121
+ FENCED_CODE_RE,
122
+ INLINE_CODE_RE,
123
+ URL_RE,
124
+ DATE_RE,
125
+ VERSION_RE,
126
+ HEADING_RE,
127
+ PATH_RE,
128
+ extractHeadings,
129
+ extractInlineCode,
130
+ };
131
+ //# sourceMappingURL=validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../src/core/compress/validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA4BH,yEAAyE;AAEzE,MAAM,cAAc,GAAG,iBAAiB,CAAC;AACzC,MAAM,cAAc,GAAG,yBAAyB,CAAC;AACjD,2EAA2E;AAC3E,MAAM,MAAM,GAAG,+CAA+C,CAAC;AAC/D,MAAM,OAAO,GAAG,wBAAwB,CAAC;AACzC,6DAA6D;AAC7D,MAAM,UAAU,GAAG,uCAAuC,CAAC;AAC3D,+BAA+B;AAC/B,MAAM,UAAU,GAAG,yBAAyB,CAAC;AAC7C,kCAAkC;AAClC,sCAAsC;AACtC,6BAA6B;AAC7B,8FAA8F;AAC9F,MAAM,OAAO,GAAG,kFAAkF,CAAC;AAEnG,SAAS,SAAS,CAAC,GAAa;IAC9B,OAAO,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC;AAC5B,CAAC;AAED,SAAS,OAAO,CAAC,MAAc,EAAE,EAAU;IACzC,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACpC,KAAK,MAAM,CAAC,IAAI,OAAO;QAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,OAAO,GAAG,CAAC;AACb,CAAC;AAED,wEAAwE;AACxE,SAAS,eAAe,CAAC,MAAc;IACrC,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,OAAO;QAAE,GAAG,CAAC,IAAI,CAA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"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAKD,wBAAsB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAiB1E"}
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/core/doctor.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACjC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAKD,wBAAsB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAmB1E"}
@@ -11,6 +11,8 @@ export async function runDoctor(projectRoot) {
11
11
  await checkOrphanedRules(projectRoot, checks);
12
12
  await checkOverrideConflicts(projectRoot, checks);
13
13
  await checkMissingFiles(projectRoot, checks);
14
+ await checkCompressionBackups(projectRoot, checks);
15
+ await checkEvalsFreshness(projectRoot, checks);
14
16
  return {
15
17
  checks,
16
18
  passCount: checks.filter((c) => c.status === 'pass').length,
@@ -160,4 +162,68 @@ async function checkMissingFiles(root, checks) {
160
162
  });
161
163
  }
162
164
  }
165
+ async function checkCompressionBackups(root, checks) {
166
+ // Find every *.original.md in the project — these are compression
167
+ // backups produced by `rulebook compress`. Report unhealthy ratios
168
+ // (close to 1.0 = no real savings) which usually mean a compression
169
+ // was applied but the target was already terse.
170
+ const { listCompressCandidates } = await import('./compress/discover.js');
171
+ const candidates = await listCompressCandidates(root);
172
+ const withBackups = candidates.filter((c) => c.hasBackup && c.backupRatio !== undefined);
173
+ if (withBackups.length === 0) {
174
+ checks.push({
175
+ name: 'Compression backups',
176
+ status: 'pass',
177
+ message: 'No compression backups present (nothing to verify)',
178
+ });
179
+ return;
180
+ }
181
+ const unhealthy = withBackups.filter((c) => (c.backupRatio ?? 1) >= 0.9);
182
+ if (unhealthy.length > 0) {
183
+ const detail = unhealthy
184
+ .map((c) => `${c.relPath} (${Math.round(((c.backupRatio ?? 1) - 0) * 100)}%)`)
185
+ .join(', ');
186
+ checks.push({
187
+ name: 'Compression backups',
188
+ status: 'warn',
189
+ message: `${unhealthy.length} compression(s) with < 10% savings — consider restoring: ${detail}`,
190
+ });
191
+ }
192
+ else {
193
+ checks.push({
194
+ name: 'Compression backups',
195
+ status: 'pass',
196
+ message: `${withBackups.length} healthy compression(s) present`,
197
+ });
198
+ }
199
+ }
200
+ async function checkEvalsFreshness(root, checks) {
201
+ const snapshotPath = path.join(root, 'evals', 'snapshots', 'results.json');
202
+ if (!(await fileExists(snapshotPath))) {
203
+ checks.push({
204
+ name: 'Terse evals',
205
+ status: 'pass',
206
+ message: 'No evals/ directory (not required for downstream projects)',
207
+ });
208
+ return;
209
+ }
210
+ const { promises: fs } = await import('fs');
211
+ const stat = await fs.stat(snapshotPath);
212
+ const ageDays = (Date.now() - stat.mtimeMs) / (1000 * 60 * 60 * 24);
213
+ const MAX_AGE = 30;
214
+ if (ageDays > MAX_AGE) {
215
+ checks.push({
216
+ name: 'Terse evals',
217
+ status: 'warn',
218
+ message: `evals/snapshots/results.json is ${Math.floor(ageDays)} days old (threshold ${MAX_AGE}). Regenerate with evals-snapshot workflow.`,
219
+ });
220
+ }
221
+ else {
222
+ checks.push({
223
+ name: 'Terse evals',
224
+ status: 'pass',
225
+ message: `evals snapshot is fresh (${Math.floor(ageDays)} days old)`,
226
+ });
227
+ }
228
+ }
163
229
  //# sourceMappingURL=doctor.js.map