@event4u/agent-config 6.1.0 → 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1537) hide show
  1. package/.claude-plugin/marketplace.json +35 -3
  2. package/AGENTS.md +8 -7
  3. package/CHANGELOG.md +408 -0
  4. package/CONTRIBUTING.md +1 -1
  5. package/README.md +17 -15
  6. package/dist/agent-src/commands/agent-status.md +2 -2
  7. package/dist/agent-src/commands/agents/audit.md +3 -3
  8. package/dist/agent-src/commands/agents/init.md +1 -1
  9. package/dist/agent-src/commands/agents/optimize.md +4 -4
  10. package/dist/agent-src/commands/analyze/decision.md +108 -0
  11. package/dist/agent-src/commands/analyze/incident.md +120 -0
  12. package/dist/agent-src/commands/analyze/near-miss.md +113 -0
  13. package/dist/agent-src/commands/analyze/postmortem.md +130 -0
  14. package/dist/agent-src/commands/analyze/premortem.md +104 -0
  15. package/dist/agent-src/commands/analyze.md +124 -0
  16. package/dist/agent-src/commands/brand/identity.md +27 -0
  17. package/dist/agent-src/commands/brand/review.md +27 -0
  18. package/dist/agent-src/commands/brand/strategy.md +27 -0
  19. package/dist/agent-src/commands/brand/tokens.md +28 -0
  20. package/dist/agent-src/commands/brand/voice.md +27 -0
  21. package/dist/agent-src/commands/brand.md +58 -0
  22. package/dist/agent-src/commands/check-current-md.md +3 -3
  23. package/dist/agent-src/commands/condense.md +2 -2
  24. package/dist/agent-src/commands/council/debate.md +2 -2
  25. package/dist/agent-src/commands/council/default.md +45 -18
  26. package/dist/agent-src/commands/fix/portability.md +3 -3
  27. package/dist/agent-src/commands/fix/refs.md +3 -3
  28. package/dist/agent-src/commands/implement-ticket.md +36 -6
  29. package/dist/agent-src/commands/knowledge/cross-repo.md +1 -1
  30. package/dist/agent-src/commands/memory/add.md +1 -1
  31. package/dist/agent-src/commands/mission/upgrade.md +182 -0
  32. package/dist/agent-src/commands/optimize/skills.md +2 -2
  33. package/dist/agent-src/commands/orchestrate.md +1 -1
  34. package/dist/agent-src/commands/pr/create.md +6 -4
  35. package/dist/agent-src/commands/review-changes.md +8 -0
  36. package/dist/agent-src/commands/roadmap/materialize.md +73 -0
  37. package/dist/agent-src/commands/skill/preview.md +1 -1
  38. package/dist/agent-src/commands/skills/discover.md +1 -1
  39. package/dist/agent-src/commands/threat-model.md +4 -4
  40. package/dist/agent-src/commands/upstream-contribute.md +3 -3
  41. package/dist/agent-src/commands/video/from-script.md +2 -2
  42. package/dist/agent-src/commands/video/from-song.md +3 -3
  43. package/dist/agent-src/commands/video/scene.md +1 -1
  44. package/dist/agent-src/commands/video/storyboard.md +1 -1
  45. package/dist/agent-src/commands/video.md +3 -3
  46. package/dist/agent-src/contexts/communication/rules-auto/source-of-truth-mechanics.md +3 -3
  47. package/dist/agent-src/contexts/communication/rules-auto/user-interaction-mechanics.md +1 -1
  48. package/dist/agent-src/contexts/execution/evidence-discipline.md +153 -0
  49. package/dist/agent-src/contexts/execution/project-intelligence.md +264 -0
  50. package/dist/agent-src/contexts/execution/roadmap-process-loop.md +2 -1
  51. package/dist/agent-src/personas/ai-video-technical-director.md +1 -1
  52. package/dist/agent-src/personas/brand-strategist.md +74 -0
  53. package/dist/agent-src/personas/design-director.md +74 -0
  54. package/dist/agent-src/rules/brand-consistency.md +77 -0
  55. package/dist/agent-src/rules/brand-source-of-truth.md +57 -0
  56. package/dist/agent-src/rules/direct-answers.md +2 -0
  57. package/dist/agent-src/rules/domain-safety-disclaimer.md +2 -0
  58. package/dist/agent-src/rules/git-history-discipline.md +1 -0
  59. package/dist/agent-src/rules/icon-consistency.md +53 -0
  60. package/dist/agent-src/rules/image-likeness-and-rights.md +67 -0
  61. package/dist/agent-src/rules/lethal-trifecta-guard.md +1 -1
  62. package/dist/agent-src/rules/persona-governance.md +2 -2
  63. package/dist/agent-src/rules/provider-lifecycle-discipline.md +3 -1
  64. package/dist/agent-src/rules/roadmap-progress-sync.md +10 -0
  65. package/dist/agent-src/rules/security-sensitive-stop.md +9 -3
  66. package/dist/agent-src/rules/size-enforcement.md +1 -1
  67. package/dist/agent-src/rules/source-confidentiality.md +3 -3
  68. package/dist/agent-src/rules/source-discovery-gate.md +98 -0
  69. package/dist/agent-src/rules/think-before-action.md +1 -0
  70. package/dist/agent-src/rules/ui-audit-gate.md +2 -0
  71. package/dist/agent-src/rules/untrusted-input-defense.md +1 -1
  72. package/dist/agent-src/rules/user-interaction.md +1 -1
  73. package/dist/agent-src/scripts/archive_completed_roadmaps.ts +392 -0
  74. package/dist/agent-src/scripts/update_roadmap_progress.ts +824 -0
  75. package/dist/agent-src/skills/adr-create/SKILL.md +5 -5
  76. package/dist/agent-src/skills/agent-security-review/evals/triggers.json +1 -0
  77. package/dist/agent-src/skills/agents-md-thin-root/SKILL.md +1 -1
  78. package/dist/agent-src/skills/ai-council/SKILL.md +1 -1
  79. package/dist/agent-src/skills/analysis-autonomous-mode/SKILL.md +9 -13
  80. package/dist/agent-src/skills/blade-ui/SKILL.md +12 -5
  81. package/dist/agent-src/skills/blameless-post-mortem/SKILL.md +199 -0
  82. package/dist/agent-src/skills/brand/ATTRIBUTION.md +38 -0
  83. package/dist/agent-src/skills/brand/SKILL.md +115 -0
  84. package/dist/agent-src/skills/brand/data/archetypes.csv +13 -0
  85. package/dist/agent-src/skills/brand/data/color-psychology.csv +14 -0
  86. package/dist/agent-src/skills/brand/data/logo-style-fit.csv +13 -0
  87. package/dist/agent-src/skills/brand/data/manifest.json +226 -0
  88. package/dist/agent-src/skills/brand/data/messaging-frameworks.csv +13 -0
  89. package/dist/agent-src/skills/brand/data/naming-patterns.csv +13 -0
  90. package/dist/agent-src/skills/brand/data/typography-principles.csv +13 -0
  91. package/dist/agent-src/skills/brand/data/voice-tone.csv +13 -0
  92. package/dist/agent-src/skills/brand/evals/triggers.json +17 -0
  93. package/dist/agent-src/skills/brand-asset-generation/SKILL.md +89 -0
  94. package/dist/agent-src/skills/brand-asset-generation/evals/triggers.json +17 -0
  95. package/dist/agent-src/skills/brand-audit/SKILL.md +67 -0
  96. package/dist/agent-src/skills/brand-audit/evals/triggers.json +17 -0
  97. package/dist/agent-src/skills/brand-identity/SKILL.md +101 -0
  98. package/dist/agent-src/skills/brand-identity/evals/triggers.json +17 -0
  99. package/dist/agent-src/skills/brand-strategy/SKILL.md +83 -0
  100. package/dist/agent-src/skills/brand-strategy/evals/triggers.json +17 -0
  101. package/dist/agent-src/skills/brand-to-tokens/SKILL.md +102 -0
  102. package/dist/agent-src/skills/brand-to-tokens/evals/triggers.json +17 -0
  103. package/dist/agent-src/skills/brand-to-tokens/templates/marp-brand-deck.md.example +46 -0
  104. package/dist/agent-src/skills/brand-to-tokens/templates/reveal-brand-deck.yaml +32 -0
  105. package/dist/agent-src/skills/canvas-design/evals/triggers.json +1 -0
  106. package/dist/agent-src/skills/check-refs/SKILL.md +5 -5
  107. package/dist/agent-src/skills/code-review/SKILL.md +6 -15
  108. package/dist/agent-src/skills/command-writing/SKILL.md +2 -2
  109. package/dist/agent-src/skills/complexity-first-planning/evals/triggers.json +1 -0
  110. package/dist/agent-src/skills/context-authoring/SKILL.md +2 -2
  111. package/dist/agent-src/skills/context-document/SKILL.md +35 -2
  112. package/dist/agent-src/skills/corpus-grounding/evals/triggers.json +1 -0
  113. package/dist/agent-src/skills/corpus-grounding/scripts/bm25_search.ts +482 -0
  114. package/dist/agent-src/skills/corpus-grounding/scripts/decision_engine.ts +803 -0
  115. package/dist/agent-src/skills/corpus-grounding/scripts/ground.ts +541 -0
  116. package/dist/agent-src/skills/corpus-grounding/scripts/schema_validator.ts +309 -0
  117. package/dist/agent-src/skills/database/SKILL.md +26 -4
  118. package/dist/agent-src/skills/decision-record/SKILL.md +1 -1
  119. package/dist/agent-src/skills/decision-record/evals/triggers.json +17 -0
  120. package/dist/agent-src/skills/decision-review/SKILL.md +179 -0
  121. package/dist/agent-src/skills/description-assist/SKILL.md +1 -1
  122. package/dist/agent-src/skills/design-intelligence/SKILL.md +1 -1
  123. package/dist/agent-src/skills/design-intelligence/data/manifest.json +23 -6
  124. package/dist/agent-src/skills/design-intelligence/evals/triggers.json +1 -0
  125. package/dist/agent-src/skills/design-tokens/evals/triggers.json +1 -0
  126. package/dist/agent-src/skills/design-tokens/scripts/tokens.ts +888 -0
  127. package/dist/agent-src/skills/doc-coauthoring/evals/triggers.json +1 -0
  128. package/dist/agent-src/skills/eloquent/evals/triggers.json +1 -0
  129. package/dist/agent-src/skills/emit-tickets/SKILL.md +198 -0
  130. package/dist/agent-src/skills/estimate-ticket/evals/triggers.json +1 -0
  131. package/dist/agent-src/skills/git-workflow/SKILL.md +33 -0
  132. package/dist/agent-src/skills/guideline-writing/SKILL.md +2 -2
  133. package/dist/agent-src/skills/iconography/SKILL.md +88 -0
  134. package/dist/agent-src/skills/iconography/evals/triggers.json +17 -0
  135. package/dist/agent-src/skills/image-analyser/evals/triggers.json +1 -0
  136. package/dist/agent-src/skills/image-creator/evals/triggers.json +1 -0
  137. package/dist/agent-src/skills/image-editing/SKILL.md +100 -0
  138. package/dist/agent-src/skills/image-editing/evals/triggers.json +17 -0
  139. package/dist/agent-src/skills/image-generation/SKILL.md +95 -0
  140. package/dist/agent-src/skills/image-generation/evals/triggers.json +17 -0
  141. package/dist/agent-src/skills/image-provider-routing/SKILL.md +96 -0
  142. package/dist/agent-src/skills/image-provider-routing/evals/triggers.json +17 -0
  143. package/dist/agent-src/skills/launch-readiness/SKILL.md +21 -0
  144. package/dist/agent-src/skills/learning-to-rule-or-skill/SKILL.md +12 -8
  145. package/dist/agent-src/skills/lint-skills/SKILL.md +5 -5
  146. package/dist/agent-src/skills/logo-generation/SKILL.md +98 -0
  147. package/dist/agent-src/skills/logo-generation/evals/triggers.json +17 -0
  148. package/dist/agent-src/skills/markitdown/SKILL.md +1 -1
  149. package/dist/agent-src/skills/md-language-check/SKILL.md +1 -1
  150. package/dist/agent-src/skills/motion-choreographer/SKILL.md +1 -1
  151. package/dist/agent-src/skills/php-coder/evals/triggers.json +1 -0
  152. package/dist/agent-src/skills/prediction-pool-optimizer/evals/triggers.json +1 -0
  153. package/dist/agent-src/skills/premortem/SKILL.md +137 -0
  154. package/dist/agent-src/skills/prompt-engineering-image/SKILL.md +115 -0
  155. package/dist/agent-src/skills/prompt-engineering-image/evals/triggers.json +17 -0
  156. package/dist/agent-src/skills/prompt-validator/evals/triggers.json +1 -0
  157. package/dist/agent-src/skills/react-shadcn-ui/SKILL.md +12 -5
  158. package/dist/agent-src/skills/react-shadcn-ui/scripts/shadcn_add.ts +388 -0
  159. package/dist/agent-src/skills/reasoning-orchestrator/SKILL.md +1 -1
  160. package/dist/agent-src/skills/reasoning-orchestrator/evals/triggers.json +1 -0
  161. package/dist/agent-src/skills/refine-ticket/evals/triggers.json +1 -0
  162. package/dist/agent-src/skills/roadmap-management/SKILL.md +16 -3
  163. package/dist/agent-src/skills/roadmap-writing/SKILL.md +76 -0
  164. package/dist/agent-src/skills/root-cause-frameworks/SKILL.md +146 -0
  165. package/dist/agent-src/skills/rule-refactor/SKILL.md +9 -9
  166. package/dist/agent-src/skills/rule-writing/SKILL.md +7 -7
  167. package/dist/agent-src/skills/script-writing/SKILL.md +2 -2
  168. package/dist/agent-src/skills/security-audit/SKILL.md +5 -0
  169. package/dist/agent-src/skills/skill-improvement-pipeline/SKILL.md +19 -3
  170. package/dist/agent-src/skills/skill-management/SKILL.md +3 -3
  171. package/dist/agent-src/skills/skill-reviewer/SKILL.md +1 -1
  172. package/dist/agent-src/skills/skill-writing/SKILL.md +5 -5
  173. package/dist/agent-src/skills/skill-writing/evals/triggers.json +1 -0
  174. package/dist/agent-src/skills/source-discovery/SKILL.md +182 -0
  175. package/dist/agent-src/skills/standards-from-config/SKILL.md +93 -0
  176. package/dist/agent-src/skills/systematic-debugging/SKILL.md +7 -0
  177. package/dist/agent-src/skills/tailwind-engineer/scripts/tailwind_config_gen.ts +561 -0
  178. package/dist/agent-src/skills/threat-modeling/SKILL.md +1 -0
  179. package/dist/agent-src/skills/typography-system/SKILL.md +138 -0
  180. package/dist/agent-src/skills/typography-system/evals/triggers.json +17 -0
  181. package/dist/agent-src/skills/upstream-contribute/SKILL.md +3 -3
  182. package/dist/agent-src/skills/verify-repair-loop/SKILL.md +209 -0
  183. package/dist/agent-src/skills/verify-repair-loop/evals/output-schema.yml +20 -0
  184. package/dist/agent-src/skills/verify-repair-loop/evals/triggers.json +17 -0
  185. package/dist/agent-src/templates/agent-settings.md +7 -0
  186. package/dist/agent-src/templates/contexts/knowledge-card.md +69 -0
  187. package/dist/agent-src/templates/contexts/lesson-card.md +73 -0
  188. package/dist/agent-src/templates/roadmaps.md +29 -1
  189. package/dist/agent-src/templates/scripts/README.md +6 -6
  190. package/dist/agent-src/templates/scripts/check_memory.ts +640 -0
  191. package/dist/agent-src/templates/scripts/check_memory_proposal.ts +351 -0
  192. package/dist/agent-src/templates/scripts/implement_ticket/__main__.ts +27 -0
  193. package/dist/agent-src/templates/scripts/memory_hash.ts +333 -0
  194. package/dist/agent-src/templates/scripts/memory_lookup.ts +1067 -0
  195. package/dist/agent-src/templates/scripts/memory_report.ts +846 -0
  196. package/dist/agent-src/templates/scripts/memory_signal.ts +422 -0
  197. package/dist/agent-src/templates/scripts/memory_status.ts +191 -0
  198. package/dist/agent-src/templates/scripts/pr_review_routing.ts +523 -0
  199. package/dist/agent-src/templates/scripts/pr_risk_review.ts +0 -0
  200. package/dist/agent-src/templates/scripts/telemetry/aggregator.ts +0 -0
  201. package/dist/agent-src/templates/scripts/telemetry/boundary.ts +164 -0
  202. package/dist/agent-src/templates/scripts/telemetry/engagement.ts +479 -0
  203. package/dist/agent-src/templates/scripts/telemetry/report_renderer.ts +394 -0
  204. package/dist/agent-src/templates/scripts/telemetry/settings.ts +210 -0
  205. package/dist/agent-src/templates/scripts/telemetry_record.ts +255 -0
  206. package/dist/agent-src/templates/scripts/telemetry_report.ts +189 -0
  207. package/dist/agent-src/templates/scripts/telemetry_status.ts +312 -0
  208. package/dist/agent-src/templates/scripts/tier_usage_report.ts +597 -0
  209. package/dist/agent-src/templates/scripts/work_engine/__main__.ts +14 -0
  210. package/dist/agent-src/templates/scripts/work_engine/_lib/agent_settings.ts +1118 -0
  211. package/dist/agent-src/templates/scripts/work_engine/_lib/user_global_paths.ts +329 -0
  212. package/dist/agent-src/templates/scripts/work_engine/cli.ts +206 -0
  213. package/dist/agent-src/templates/scripts/work_engine/cli_args.ts +249 -0
  214. package/dist/agent-src/templates/scripts/work_engine/delivery_state.ts +225 -0
  215. package/dist/agent-src/templates/scripts/work_engine/directives/backend/analyze.ts +125 -0
  216. package/dist/agent-src/templates/scripts/work_engine/directives/backend/implement.ts +189 -0
  217. package/dist/agent-src/templates/scripts/work_engine/directives/backend/index.ts +94 -0
  218. package/dist/agent-src/templates/scripts/work_engine/directives/backend/memory.ts +193 -0
  219. package/dist/agent-src/templates/scripts/work_engine/directives/backend/plan.ts +267 -0
  220. package/dist/agent-src/templates/scripts/work_engine/directives/backend/refine.ts +518 -0
  221. package/dist/agent-src/templates/scripts/work_engine/directives/backend/report.ts +379 -0
  222. package/dist/agent-src/templates/scripts/work_engine/directives/backend/test.ts +268 -0
  223. package/dist/agent-src/templates/scripts/work_engine/directives/backend/verify.ts +258 -0
  224. package/dist/agent-src/templates/scripts/work_engine/directives/index.ts +32 -0
  225. package/dist/agent-src/templates/scripts/work_engine/directives/mixed/contract.ts +243 -0
  226. package/dist/agent-src/templates/scripts/work_engine/directives/mixed/index.ts +108 -0
  227. package/dist/agent-src/templates/scripts/work_engine/directives/mixed/stitch.ts +259 -0
  228. package/dist/agent-src/templates/scripts/work_engine/directives/mixed/ui.ts +216 -0
  229. package/dist/agent-src/templates/scripts/work_engine/directives/ui/_passthrough.ts +40 -0
  230. package/dist/agent-src/templates/scripts/work_engine/directives/ui/app_spec.ts +241 -0
  231. package/dist/agent-src/templates/scripts/work_engine/directives/ui/apply.ts +216 -0
  232. package/dist/agent-src/templates/scripts/work_engine/directives/ui/audit.ts +506 -0
  233. package/dist/agent-src/templates/scripts/work_engine/directives/ui/design.ts +325 -0
  234. package/dist/agent-src/templates/scripts/work_engine/directives/ui/index.ts +102 -0
  235. package/dist/agent-src/templates/scripts/work_engine/directives/ui/polish.ts +462 -0
  236. package/dist/agent-src/templates/scripts/work_engine/directives/ui/review.ts +474 -0
  237. package/dist/agent-src/templates/scripts/work_engine/directives/ui/scaffold.ts +352 -0
  238. package/dist/agent-src/templates/scripts/work_engine/directives/ui_trivial/_skipped.ts +33 -0
  239. package/dist/agent-src/templates/scripts/work_engine/directives/ui_trivial/apply.ts +213 -0
  240. package/dist/agent-src/templates/scripts/work_engine/directives/ui_trivial/index.ts +111 -0
  241. package/dist/agent-src/templates/scripts/work_engine/directives/ui_trivial/refine.ts +126 -0
  242. package/dist/agent-src/templates/scripts/work_engine/directives/ui_trivial/report.ts +112 -0
  243. package/dist/agent-src/templates/scripts/work_engine/directives/ui_trivial/test.ts +164 -0
  244. package/dist/agent-src/templates/scripts/work_engine/dispatcher.ts +515 -0
  245. package/dist/agent-src/templates/scripts/work_engine/emitters.ts +119 -0
  246. package/dist/agent-src/templates/scripts/work_engine/errors.ts +24 -0
  247. package/dist/agent-src/templates/scripts/work_engine/hook_bootstrap.ts +104 -0
  248. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/_chat_history_base.ts +176 -0
  249. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/chat_history_append.ts +41 -0
  250. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/chat_history_halt_append.ts +89 -0
  251. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/decision_gate.ts +193 -0
  252. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/decision_trace.ts +304 -0
  253. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/directive_set_guard.ts +110 -0
  254. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/halt_surface_audit.ts +118 -0
  255. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/index.ts +17 -0
  256. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/memory_visibility.ts +161 -0
  257. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/state_shape_validation.ts +45 -0
  258. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/trace.ts +134 -0
  259. package/dist/agent-src/templates/scripts/work_engine/hooks/context.ts +94 -0
  260. package/dist/agent-src/templates/scripts/work_engine/hooks/events.ts +58 -0
  261. package/dist/agent-src/templates/scripts/work_engine/hooks/exceptions.ts +85 -0
  262. package/dist/agent-src/templates/scripts/work_engine/hooks/index.ts +27 -0
  263. package/dist/agent-src/templates/scripts/work_engine/hooks/registry.ts +66 -0
  264. package/dist/agent-src/templates/scripts/work_engine/hooks/runner.ts +90 -0
  265. package/dist/agent-src/templates/scripts/work_engine/hooks/settings.ts +260 -0
  266. package/dist/agent-src/templates/scripts/work_engine/input_builders.ts +260 -0
  267. package/dist/agent-src/templates/scripts/work_engine/intent/classify.ts +466 -0
  268. package/dist/agent-src/templates/scripts/work_engine/migration/v0_to_v1.ts +531 -0
  269. package/dist/agent-src/templates/scripts/work_engine/orchestration.ts +366 -0
  270. package/dist/agent-src/templates/scripts/work_engine/persona_policy.ts +97 -0
  271. package/dist/agent-src/templates/scripts/work_engine/resolvers/diff.ts +135 -0
  272. package/dist/agent-src/templates/scripts/work_engine/resolvers/file.ts +175 -0
  273. package/dist/agent-src/templates/scripts/work_engine/resolvers/prompt.ts +115 -0
  274. package/dist/agent-src/templates/scripts/work_engine/scoring/confidence.ts +415 -0
  275. package/dist/agent-src/templates/scripts/work_engine/scoring/decision_engine.ts +466 -0
  276. package/dist/agent-src/templates/scripts/work_engine/scoring/decision_trace.ts +298 -0
  277. package/dist/agent-src/templates/scripts/work_engine/scoring/memory_visibility.ts +444 -0
  278. package/dist/agent-src/templates/scripts/work_engine/stack/detect.ts +252 -0
  279. package/dist/agent-src/templates/scripts/work_engine/stack/runner.ts +745 -0
  280. package/dist/agent-src/templates/scripts/work_engine/state.ts +1151 -0
  281. package/dist/agent-src/templates/scripts/work_engine/state_io.ts +413 -0
  282. package/dist/agent-src/templates/tickets.md +120 -0
  283. package/dist/cli/commands/commands.js +2 -2
  284. package/dist/cli/commands/commands.js.map +1 -1
  285. package/dist/cli/commands/doctorShell.js +4 -22
  286. package/dist/cli/commands/doctorShell.js.map +1 -1
  287. package/dist/cli/commands/packs.js +1 -1
  288. package/dist/cli/commands/packs.js.map +1 -1
  289. package/dist/cli/commands/recordTriggerEval.js +179 -0
  290. package/dist/cli/commands/recordTriggerEval.js.map +1 -0
  291. package/dist/cli/commands/recordTriggerEval.test.js +113 -0
  292. package/dist/cli/commands/recordTriggerEval.test.js.map +1 -0
  293. package/dist/cli/commands/workspaces.js +1 -1
  294. package/dist/cli/commands/workspaces.js.map +1 -1
  295. package/dist/cli/main.js +22 -1
  296. package/dist/cli/main.js.map +1 -1
  297. package/dist/cli/python/knowledge_ingest.js +1048 -0
  298. package/dist/cli/python/knowledge_ingest.js.map +1 -0
  299. package/dist/cli/python/workspace_analytics.js +1085 -0
  300. package/dist/cli/python/workspace_analytics.js.map +1 -0
  301. package/dist/cli/python/workspace_crypto.js +544 -0
  302. package/dist/cli/python/workspace_crypto.js.map +1 -0
  303. package/dist/cli/python/workspace_documents.js +1216 -0
  304. package/dist/cli/python/workspace_documents.js.map +1 -0
  305. package/dist/cli/python/workspace_drive.js +574 -0
  306. package/dist/cli/python/workspace_drive.js.map +1 -0
  307. package/dist/cli/python/workspace_drive_health.js +628 -0
  308. package/dist/cli/python/workspace_drive_health.js.map +1 -0
  309. package/dist/cli/python/workspace_explain.js +765 -0
  310. package/dist/cli/python/workspace_explain.js.map +1 -0
  311. package/dist/cli/python/workspace_hosts.js +349 -0
  312. package/dist/cli/python/workspace_hosts.js.map +1 -0
  313. package/dist/cli/python/workspace_inbox.js +692 -0
  314. package/dist/cli/python/workspace_inbox.js.map +1 -0
  315. package/dist/cli/python/workspace_render.js +816 -0
  316. package/dist/cli/python/workspace_render.js.map +1 -0
  317. package/dist/cli/python/workspace_roles.js +487 -0
  318. package/dist/cli/python/workspace_roles.js.map +1 -0
  319. package/dist/cli/python/workspace_secrets.js +180 -0
  320. package/dist/cli/python/workspace_secrets.js.map +1 -0
  321. package/dist/cli/python/workspace_sessions.js +1079 -0
  322. package/dist/cli/python/workspace_sessions.js.map +1 -0
  323. package/dist/cli/python/workspace_skills.js +417 -0
  324. package/dist/cli/python/workspace_skills.js.map +1 -0
  325. package/dist/cli/registry.js +2 -0
  326. package/dist/cli/registry.js.map +1 -1
  327. package/dist/discovery/deprecation-report.md +1 -1
  328. package/dist/discovery/discovery-manifest.json +1174 -123
  329. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  330. package/dist/discovery/discovery-manifest.summary.md +9 -6
  331. package/dist/discovery/orphan-report.md +1 -1
  332. package/dist/discovery/packs.json +163 -15
  333. package/dist/discovery/trust-report.md +4 -4
  334. package/dist/discovery/workspaces.json +73 -12
  335. package/dist/install/install.mjs +13934 -0
  336. package/dist/mcp/registry-manifest.json +4 -4
  337. package/dist/router.json +1 -1
  338. package/dist/server/routes/wizard.js +50 -21
  339. package/dist/server/routes/wizard.js.map +1 -1
  340. package/dist/server/routes/workspace.js +44 -25
  341. package/dist/server/routes/workspace.js.map +1 -1
  342. package/dist/server/schemas/settings.js +15 -0
  343. package/dist/server/schemas/settings.js.map +1 -1
  344. package/docs/SKILL_CENSUS.md +344 -0
  345. package/docs/architecture/augment-projection.md +1 -1
  346. package/docs/architecture/multi-tool-projection.md +3 -3
  347. package/docs/architecture.md +37 -6
  348. package/docs/benchmark.md +24 -27
  349. package/docs/capability-matrix.md +32 -0
  350. package/docs/catalog.md +50 -9
  351. package/docs/command-naming-audit.md +60 -0
  352. package/docs/contracts/STABILITY.md +32 -0
  353. package/docs/contracts/agents-md-tech-stack.md +1 -1
  354. package/docs/contracts/ai-council-config.md +22 -22
  355. package/docs/contracts/analysis-memory-loop.md +149 -0
  356. package/docs/contracts/benchmark-ab-contract.md +3 -3
  357. package/docs/contracts/branch-protection-policy.md +27 -0
  358. package/docs/contracts/brand-token-consumption.md +69 -0
  359. package/docs/contracts/command-clusters.md +2 -1
  360. package/docs/contracts/command-surface-tiers.md +13 -0
  361. package/docs/contracts/discovery-manifest.schema.json +24 -5
  362. package/docs/contracts/implement-ticket-flow.md +9 -9
  363. package/docs/contracts/install-layout.md +249 -0
  364. package/docs/contracts/kernel-membership.md +1 -1
  365. package/docs/contracts/linear-ai-rules-inclusion.md +2 -2
  366. package/docs/contracts/linter-structural-model.md +1 -1
  367. package/docs/contracts/mcp-discovery-phase-notice.md +1 -1
  368. package/docs/contracts/multi-tool-projection-fidelity.md +1 -1
  369. package/docs/contracts/namespace.md +2 -2
  370. package/docs/contracts/no-runtime-boundary.md +56 -0
  371. package/docs/contracts/package-self-orientation.md +24 -0
  372. package/docs/contracts/provider-lifecycle.md +3 -3
  373. package/docs/contracts/reasoning-discipline-protocol.md +83 -0
  374. package/docs/contracts/rule-classification.md +3 -3
  375. package/docs/contracts/skill-domains.md +1 -1
  376. package/docs/contracts/smoke-contracts.md +1 -1
  377. package/docs/contracts/surface-tiers.md +81 -0
  378. package/docs/contracts/ticket-bundle-format.md +228 -0
  379. package/docs/cookbook.md +152 -0
  380. package/docs/customization.md +12 -1
  381. package/docs/decisions/ADR-013-discovery-frontmatter-contract.md +16 -0
  382. package/docs/decisions/ADR-056-unvalidated-video-adapters-disposition.md +1 -1
  383. package/docs/decisions/ADR-059-render-resume-filesystem-as-state.md +1 -1
  384. package/docs/decisions/ADR-060-comfyui-sandbox-model.md +1 -1
  385. package/docs/decisions/ADR-061-corpus-grounding-layer.md +48 -1
  386. package/docs/decisions/ADR-096-analysis-workbench.md +110 -0
  387. package/docs/decisions/ADR-097-mission-recipe-privilege-boundary.md +121 -0
  388. package/docs/decisions/ADR-098-evidence-first-structure-discovery.md +154 -0
  389. package/docs/decisions/ADR-099-file-first-pattern-library.md +87 -0
  390. package/docs/decisions/ADR-100-global-knowledge-card-sharing.md +133 -0
  391. package/docs/decisions/ADR-101-ticket-bundle-emission.md +109 -0
  392. package/docs/decisions/ADR-102-ticket-handoff-paste-and-mcp.md +72 -0
  393. package/docs/decisions/ADR-103-global-knowledge-default-off-until-measured.md +92 -0
  394. package/docs/decisions/ADR-200-python-to-typescript-migration.md +193 -0
  395. package/docs/decisions/INDEX.md +9 -0
  396. package/docs/distribution/mcp-submission-checklist.md +3 -3
  397. package/docs/featured-commands.md +1 -1
  398. package/docs/featured-skills.md +1 -1
  399. package/docs/getting-started-by-role.md +2 -0
  400. package/docs/getting-started.md +2 -2
  401. package/docs/guidelines/agent-infra/failure-signatures.md +35 -0
  402. package/docs/guidelines/agent-infra/frontier-reasoning-operating-profile.md +5 -0
  403. package/docs/guidelines/agent-infra/size-and-scope.md +17 -0
  404. package/docs/guidelines/agent-infra/skill-quality-checklist.md +2 -2
  405. package/docs/guides/frontend-design-corpus-refresh.md +83 -0
  406. package/docs/guides/skill-preview.md +1 -1
  407. package/docs/hook-payload-capture.md +4 -4
  408. package/docs/mcp.md +1 -1
  409. package/docs/migration/consumer-template-consumption-model.md +145 -0
  410. package/docs/migration/divergences/README.md +55 -0
  411. package/docs/migration/divergences/_template.md +50 -0
  412. package/docs/migration/divergences/bench-stats-float-precision.md +72 -0
  413. package/docs/migration/divergences/mcp-telemetry-node-sqlite.md +61 -0
  414. package/docs/migration/divergences/pack-mcp-content-gzip-body.md +53 -0
  415. package/docs/migration/divergences/src-scripts-build_cloud_bundle.md +63 -0
  416. package/docs/migration/divergences/src-scripts-check_memory.md +91 -0
  417. package/docs/migration/divergences/src-scripts-inventory_abstraction_budget.md +65 -0
  418. package/docs/migration/divergences/src-scripts-lint_marketplace.md +57 -0
  419. package/docs/migration/divergences/src-scripts-lint_mcp_registry_manifest.md +70 -0
  420. package/docs/migration/divergences/src-scripts-spotcheck_thin_root.md +60 -0
  421. package/docs/migration/divergences/src-scripts-validate_agent_settings.md +58 -0
  422. package/docs/migration/node-floor.md +86 -0
  423. package/docs/migration/yaml-roundtrip-spike.md +163 -0
  424. package/docs/personas.md +6 -1
  425. package/docs/role-experiences.md +19 -0
  426. package/docs/setup/per-ide/windsurf.md +1 -1
  427. package/docs/skills-catalog.md +24 -3
  428. package/docs/threat-model.md +28 -0
  429. package/llms.txt +23 -2
  430. package/package.json +10 -15
  431. package/src/config/agent-settings.template.yml +64 -1
  432. package/src/config/discovery/packs.yml +31 -0
  433. package/src/config/discovery/unassigned-artefacts.yml +6 -0
  434. package/src/config/discovery/workspaces.yml +2 -2
  435. package/src/config/gitignore-block.txt +7 -0
  436. package/src/scripts/_cli/cmd_doctor.ts +2306 -0
  437. package/src/scripts/_cli/cmd_explain.ts +748 -0
  438. package/src/scripts/_cli/cmd_export.ts +375 -0
  439. package/src/scripts/_cli/cmd_migrate.ts +951 -0
  440. package/src/scripts/_cli/cmd_prune.ts +610 -0
  441. package/src/scripts/_cli/cmd_refresh.ts +530 -0
  442. package/src/scripts/_cli/cmd_settings_check.ts +407 -0
  443. package/src/scripts/_cli/cmd_settings_migrate.ts +344 -0
  444. package/src/scripts/_cli/cmd_sync.ts +381 -0
  445. package/src/scripts/_cli/cmd_uninstall.ts +833 -0
  446. package/src/scripts/_cli/cmd_update.ts +585 -0
  447. package/src/scripts/_cli/cmd_upgrade.ts +390 -0
  448. package/src/scripts/_cli/cmd_validate.ts +394 -0
  449. package/src/scripts/_cli/cmd_versions.ts +492 -0
  450. package/src/scripts/_cli/explain_last/assumptions.ts +114 -0
  451. package/src/scripts/_cli/explain_last/council.ts +197 -0
  452. package/src/scripts/_cli/explain_last/halt.ts +73 -0
  453. package/src/scripts/_cli/explain_last/index.ts +155 -0
  454. package/src/scripts/_cli/explain_last/inputs.ts +211 -0
  455. package/src/scripts/_cli/explain_last/memory.ts +231 -0
  456. package/src/scripts/_cli/explain_last/provider.ts +82 -0
  457. package/src/scripts/_cli/explain_last/render.ts +54 -0
  458. package/src/scripts/_cli/explain_last/route.ts +70 -0
  459. package/src/scripts/_cli/explain_last/scrubber.ts +138 -0
  460. package/src/scripts/_cli/explain_last/sections/assumptions.ts +51 -0
  461. package/src/scripts/_cli/explain_last/sections/council.ts +56 -0
  462. package/src/scripts/_cli/explain_last/sections/halt.ts +60 -0
  463. package/src/scripts/_cli/explain_last/sections/header.ts +50 -0
  464. package/src/scripts/_cli/explain_last/sections/index.ts +21 -0
  465. package/src/scripts/_cli/explain_last/sections/inputs.ts +63 -0
  466. package/src/scripts/_cli/explain_last/sections/memory.ts +124 -0
  467. package/src/scripts/_cli/explain_last/sections/pack.ts +42 -0
  468. package/src/scripts/_cli/explain_last/sections/provider.ts +51 -0
  469. package/src/scripts/_cli/explain_last/sections/route.ts +48 -0
  470. package/src/scripts/_cli/explain_last/state_loader.ts +119 -0
  471. package/src/scripts/_dispatch.bash +179 -163
  472. package/src/scripts/_lib/agent_settings.ts +1123 -0
  473. package/src/scripts/_lib/agent_src.ts +654 -0
  474. package/src/scripts/_lib/agents_overlay.ts +183 -0
  475. package/src/scripts/_lib/bench_ab_cache.ts +399 -0
  476. package/src/scripts/_lib/bench_ab_scoring.ts +352 -0
  477. package/src/scripts/_lib/bench_ab_scoring_v2.ts +751 -0
  478. package/src/scripts/_lib/bench_cost.ts +396 -0
  479. package/src/scripts/_lib/bench_quality.ts +237 -0
  480. package/src/scripts/_lib/bench_report.ts +255 -0
  481. package/src/scripts/_lib/bench_telegraph.ts +516 -0
  482. package/src/scripts/_lib/bench_telegraph_report.ts +272 -0
  483. package/src/scripts/_lib/changelog_eras.ts +398 -0
  484. package/src/scripts/_lib/claude_desktop_bundler.ts +324 -0
  485. package/src/scripts/_lib/cli_wrapper.ts +89 -0
  486. package/src/scripts/_lib/fs_atomic.ts +172 -0
  487. package/src/scripts/_lib/global_deploy_inventory.ts +639 -0
  488. package/src/scripts/_lib/install_layout.ts +87 -0
  489. package/src/scripts/_lib/install_regenerator.ts +157 -0
  490. package/src/scripts/_lib/installed_lock.ts +451 -0
  491. package/src/scripts/_lib/installed_tools.ts +518 -0
  492. package/src/scripts/_lib/json_pointers.ts +388 -0
  493. package/src/scripts/_lib/knowledge_global.ts +770 -0
  494. package/src/scripts/_lib/knowledge_global_promote.ts +453 -0
  495. package/src/scripts/_lib/knowledge_global_redaction.ts +448 -0
  496. package/src/scripts/_lib/link_crypto.ts +325 -0
  497. package/src/scripts/_lib/linked_projects.ts +613 -0
  498. package/src/scripts/_lib/model_tier.ts +65 -0
  499. package/src/scripts/_lib/module_detection.ts +275 -0
  500. package/src/scripts/_lib/node_sqlite.d.ts +32 -0
  501. package/src/scripts/_lib/pin_resolver.ts +264 -0
  502. package/src/scripts/_lib/py_random.ts +212 -0
  503. package/src/scripts/_lib/script_output.ts +147 -0
  504. package/src/scripts/_lib/security_lint.ts +623 -0
  505. package/src/scripts/_lib/surface_tiers.ts +127 -0
  506. package/src/scripts/_lib/token_count.ts +126 -0
  507. package/src/scripts/_lib/update_check.ts +297 -0
  508. package/src/scripts/_lib/user_global_paths.ts +329 -0
  509. package/src/scripts/_lib/value_ladder.ts +882 -0
  510. package/src/scripts/_lib/value_report.ts +617 -0
  511. package/src/scripts/_lib/zip_min.ts +175 -0
  512. package/src/scripts/adoption_report.ts +357 -0
  513. package/src/scripts/adoption_snapshot.ts +392 -0
  514. package/src/scripts/adoption_status.ts +424 -0
  515. package/src/scripts/adr/regenerate_index.ts +257 -0
  516. package/src/scripts/ai-image/adapters/flux.sh +45 -0
  517. package/src/scripts/ai-image/adapters/gemini-image.sh +45 -0
  518. package/src/scripts/ai-image/adapters/ideogram.sh +45 -0
  519. package/src/scripts/ai-image/adapters/recraft.sh +47 -0
  520. package/src/scripts/ai-video/adapters/comfyui.sh +3 -3
  521. package/src/scripts/ai-video/adapters/fal.sh +3 -3
  522. package/src/scripts/ai-video/adapters/gemini-veo.sh +3 -3
  523. package/src/scripts/ai-video/adapters/higgsfield.sh +3 -3
  524. package/src/scripts/ai-video/adapters/kling.sh +3 -3
  525. package/src/scripts/ai-video/adapters/musetalk.sh +2 -2
  526. package/src/scripts/ai-video/adapters/openai-images.sh +3 -3
  527. package/src/scripts/ai-video/adapters/replicate.sh +3 -3
  528. package/src/scripts/ai-video/adapters/sora.sh +3 -3
  529. package/src/scripts/ai-video/adapters/syncso.sh +3 -3
  530. package/src/scripts/ai-video/audio-adapters/allin1.sh +2 -2
  531. package/src/scripts/ai-video/audio-adapters/whisperx.sh +2 -2
  532. package/src/scripts/ai-video/lib/audio-adapter-contract.md +1 -1
  533. package/src/scripts/ai-video/lib/embed-provenance.sh +2 -2
  534. package/src/scripts/ai-video/lib/ingest-song.sh +2 -2
  535. package/src/scripts/ai-video/lib/parse-blueprint.sh +1 -1
  536. package/src/scripts/ai-video/lib/resume-scan.sh +2 -2
  537. package/src/scripts/ai-video/smoke-trace.sh +16 -7
  538. package/src/scripts/ai-video/stitch.sh +2 -2
  539. package/src/scripts/ai_council/_default_prices.ts +73 -0
  540. package/src/scripts/ai_council/advisors.ts +244 -0
  541. package/src/scripts/ai_council/airgap.ts +249 -0
  542. package/src/scripts/ai_council/budget_guard.ts +492 -0
  543. package/src/scripts/ai_council/bundler.ts +376 -0
  544. package/src/scripts/ai_council/cli_hints.ts +120 -0
  545. package/src/scripts/ai_council/clients.ts +2214 -0
  546. package/src/scripts/ai_council/compile_corpus.ts +681 -0
  547. package/src/scripts/ai_council/confidence_gate.ts +230 -0
  548. package/src/scripts/ai_council/config.ts +1729 -0
  549. package/src/scripts/ai_council/consensus.ts +551 -0
  550. package/src/scripts/ai_council/events_log.ts +327 -0
  551. package/src/scripts/ai_council/learn_low_impact_preview.ts +317 -0
  552. package/src/scripts/ai_council/low_impact.ts +1069 -0
  553. package/src/scripts/ai_council/low_impact_corpus.ts +662 -0
  554. package/src/scripts/ai_council/low_impact_intake.ts +222 -0
  555. package/src/scripts/ai_council/modes.ts +169 -0
  556. package/src/scripts/ai_council/necessity.ts +933 -0
  557. package/src/scripts/ai_council/orchestrator.ts +1689 -0
  558. package/src/scripts/ai_council/pricing.ts +267 -0
  559. package/src/scripts/ai_council/probation_gate.ts +282 -0
  560. package/src/scripts/ai_council/project_context.ts +308 -0
  561. package/src/scripts/ai_council/prompts.ts +600 -0
  562. package/src/scripts/ai_council/redact_low_impact_entry.ts +291 -0
  563. package/src/scripts/ai_council/replay.ts +314 -0
  564. package/src/scripts/ai_council/session.ts +558 -0
  565. package/src/scripts/ai_council/shadow_dispatch.ts +509 -0
  566. package/src/scripts/ai_council/solo_dispatch.ts +281 -0
  567. package/src/scripts/analysis_freshness.ts +343 -0
  568. package/src/scripts/annotate_discovery.ts +288 -0
  569. package/src/scripts/apply_modules_config.ts +537 -0
  570. package/src/scripts/audit_adr_coverage.ts +357 -0
  571. package/src/scripts/audit_auto_rules.ts +415 -0
  572. package/src/scripts/audit_cloud_compatibility.ts +608 -0
  573. package/src/scripts/audit_command_surface.ts +1227 -0
  574. package/src/scripts/audit_initial_context.ts +694 -0
  575. package/src/scripts/audit_likelihood.ts +434 -0
  576. package/src/scripts/audit_mcp_tools.ts +252 -0
  577. package/src/scripts/audit_overlap.ts +421 -0
  578. package/src/scripts/audit_skill_descriptions.ts +402 -0
  579. package/src/scripts/audit_skill_overlap.ts +576 -0
  580. package/src/scripts/audit_user_type_axis.ts +264 -0
  581. package/src/scripts/backfill_model_tier.ts +349 -0
  582. package/src/scripts/bench_ab_cache_dispatch.ts +126 -0
  583. package/src/scripts/bench_ab_clone.ts +610 -0
  584. package/src/scripts/bench_ab_diff.ts +609 -0
  585. package/src/scripts/bench_ab_integrity.ts +261 -0
  586. package/src/scripts/bench_ab_run.ts +417 -0
  587. package/src/scripts/bench_ab_task_runner.ts +1382 -0
  588. package/src/scripts/bench_ab_tracka_run.ts +436 -0
  589. package/src/scripts/bench_ab_v2_run.ts +585 -0
  590. package/src/scripts/bench_ab_v2_stats.ts +1018 -0
  591. package/src/scripts/bench_baseline_ready.ts +326 -0
  592. package/src/scripts/bench_condense_memory.ts +479 -0
  593. package/src/scripts/bench_drift_check.ts +503 -0
  594. package/src/scripts/bench_per_tool.ts +591 -0
  595. package/src/scripts/bench_rtk_savings.ts +710 -0
  596. package/src/scripts/bench_run.ts +509 -0
  597. package/src/scripts/bench_runner.ts +519 -0
  598. package/src/scripts/build_cloud_bundle.ts +692 -0
  599. package/src/scripts/build_discovery_manifest.ts +1371 -0
  600. package/src/scripts/build_linear_digest.ts +368 -0
  601. package/src/scripts/build_mcp_registry_manifest.ts +351 -0
  602. package/src/scripts/build_rule_trigger_matrix.ts +469 -0
  603. package/src/scripts/capture_showcase_session.ts +735 -0
  604. package/src/scripts/chat_history.ts +2301 -0
  605. package/src/scripts/check_always_budget.ts +694 -0
  606. package/src/scripts/check_artefact_checksums.ts +281 -0
  607. package/src/scripts/check_augment_description_cap.ts +133 -0
  608. package/src/scripts/check_augmentignore.ts +108 -0
  609. package/src/scripts/check_beta_review_markers.ts +234 -0
  610. package/src/scripts/check_bite_sized_granularity.ts +116 -0
  611. package/src/scripts/check_cluster_patterns.ts +285 -0
  612. package/src/scripts/check_command_count_messaging.ts +224 -0
  613. package/src/scripts/check_condensation.ts +900 -0
  614. package/src/scripts/check_condensed_paths.ts +414 -0
  615. package/src/scripts/check_context_paths.ts +388 -0
  616. package/src/scripts/check_council_config_location.ts +260 -0
  617. package/src/scripts/check_council_layout.ts +180 -0
  618. package/src/scripts/check_council_references.ts +345 -0
  619. package/src/scripts/check_discovery_determinism.ts +124 -0
  620. package/src/scripts/check_gate_paths.ts +230 -0
  621. package/src/scripts/check_iron_law_prominence.ts +298 -0
  622. package/src/scripts/check_kernel_rule_bundle.ts +242 -0
  623. package/src/scripts/check_knowledge_cards.ts +759 -0
  624. package/src/scripts/check_md_language.ts +291 -0
  625. package/src/scripts/check_memory.ts +845 -0
  626. package/src/scripts/check_memory_proposal.ts +351 -0
  627. package/src/scripts/check_module_management_neutral.ts +238 -0
  628. package/src/scripts/check_no_conflict_markers.ts +298 -0
  629. package/src/scripts/check_no_conflict_markers_allowlist.json +4 -0
  630. package/src/scripts/check_no_external_sources.ts +351 -0
  631. package/src/scripts/check_no_local_settings_committed.ts +69 -0
  632. package/src/scripts/check_no_new_legacy_path.ts +188 -0
  633. package/src/scripts/check_no_roadmap_refs.ts +304 -0
  634. package/src/scripts/check_one_off_location.ts +165 -0
  635. package/src/scripts/check_overlay_cascade_subdirs.ts +188 -0
  636. package/src/scripts/check_portability.ts +860 -0
  637. package/src/scripts/check_proposal.ts +0 -0
  638. package/src/scripts/check_public_catalog_links.ts +204 -0
  639. package/src/scripts/check_public_links.ts +357 -0
  640. package/src/scripts/check_references.ts +963 -0
  641. package/src/scripts/check_release_includes_discovery.ts +94 -0
  642. package/src/scripts/check_release_pr_shape.ts +222 -0
  643. package/src/scripts/check_release_published.ts +235 -0
  644. package/src/scripts/check_release_trunk_sync.ts +203 -0
  645. package/src/scripts/check_reply_consistency.ts +359 -0
  646. package/src/scripts/check_roadmap_trackable.ts +268 -0
  647. package/src/scripts/check_role_doc_links.ts +187 -0
  648. package/src/scripts/check_safety_floor_untouched.ts +160 -0
  649. package/src/scripts/check_skill_requires.ts +205 -0
  650. package/src/scripts/check_structural_breaking.ts +170 -0
  651. package/src/scripts/check_surface_tiers.ts +567 -0
  652. package/src/scripts/check_template_pin_drift.ts +222 -0
  653. package/src/scripts/check_test_coverage_diff.ts +235 -0
  654. package/src/scripts/check_token_optimizer_freshness.ts +183 -0
  655. package/src/scripts/check_trigger_evals.ts +375 -0
  656. package/src/scripts/check_update_banner.ts +143 -0
  657. package/src/scripts/ci_status.ts +0 -0
  658. package/src/scripts/ci_summary.ts +235 -0
  659. package/src/scripts/ci_time_ratio.ts +526 -0
  660. package/src/scripts/command_suggester/cooldown.ts +176 -0
  661. package/src/scripts/command_suggester/index.ts +41 -0
  662. package/src/scripts/command_suggester/loader.ts +205 -0
  663. package/src/scripts/command_suggester/match.ts +294 -0
  664. package/src/scripts/command_suggester/rank.ts +201 -0
  665. package/src/scripts/command_suggester/render.ts +122 -0
  666. package/src/scripts/command_suggester/sanitize.ts +114 -0
  667. package/src/scripts/command_suggester/settings.ts +186 -0
  668. package/src/scripts/command_suggester/types.ts +0 -0
  669. package/src/scripts/compile_router.ts +297 -0
  670. package/src/scripts/condense.sh +7 -1
  671. package/src/scripts/condense.ts +2035 -0
  672. package/src/scripts/condense_memory.ts +334 -0
  673. package/src/scripts/config/index.ts +15 -0
  674. package/src/scripts/config/packs.ts +310 -0
  675. package/src/scripts/config/presets.ts +369 -0
  676. package/src/scripts/config/profile_explain.ts +114 -0
  677. package/src/scripts/config/profiles.ts +277 -0
  678. package/src/scripts/config/session_profiles.ts +1064 -0
  679. package/src/scripts/context_hygiene_hook.ts +272 -0
  680. package/src/scripts/cost_by_conversation.ts +444 -0
  681. package/src/scripts/cost_summary.ts +407 -0
  682. package/src/scripts/council_cli.ts +2827 -0
  683. package/src/scripts/council_prune.ts +153 -0
  684. package/src/scripts/cross_repo_retrieve.ts +694 -0
  685. package/src/scripts/discovery_stats.ts +218 -0
  686. package/src/scripts/evidence_report.ts +580 -0
  687. package/src/scripts/external_sources_denylist.json +1 -0
  688. package/src/scripts/extract_audit_patterns.ts +394 -0
  689. package/src/scripts/first_run_gate_hook.ts +246 -0
  690. package/src/scripts/gen_discovery_baseline.ts +297 -0
  691. package/src/scripts/generate_capabilities_index.ts +496 -0
  692. package/src/scripts/generate_capability_matrix.ts +430 -0
  693. package/src/scripts/generate_catalog.ts +178 -0
  694. package/src/scripts/generate_command_flows.ts +316 -0
  695. package/src/scripts/generate_cookbook.ts +302 -0
  696. package/src/scripts/generate_index.ts +500 -0
  697. package/src/scripts/generate_ownership_matrix.ts +646 -0
  698. package/src/scripts/generate_pack_manifests.ts +1025 -0
  699. package/src/scripts/generate_role_experiences_catalog.ts +265 -0
  700. package/src/scripts/hermetic-install.sh +22 -11
  701. package/src/scripts/hook_manifest.yaml +24 -10
  702. package/src/scripts/hooks/augment-chat-history.sh +3 -10
  703. package/src/scripts/hooks/augment-context-hygiene.sh +3 -10
  704. package/src/scripts/hooks/augment-dispatcher.sh +3 -10
  705. package/src/scripts/hooks/augment-onboarding-gate.sh +3 -10
  706. package/src/scripts/hooks/augment-roadmap-progress.sh +3 -10
  707. package/src/scripts/hooks/block_no_verify.ts +413 -0
  708. package/src/scripts/hooks/cline-dispatcher.sh +3 -10
  709. package/src/scripts/hooks/cowork-dispatcher.sh +3 -14
  710. package/src/scripts/hooks/cursor-dispatcher.sh +3 -10
  711. package/src/scripts/hooks/dispatch_hook.ts +851 -0
  712. package/src/scripts/hooks/dispatch_issues.ts +226 -0
  713. package/src/scripts/hooks/envelope.ts +140 -0
  714. package/src/scripts/hooks/gemini-dispatcher.sh +3 -8
  715. package/src/scripts/hooks/replay_hook.ts +364 -0
  716. package/src/scripts/hooks/state_io.ts +293 -0
  717. package/src/scripts/hooks/windsurf-dispatcher.sh +3 -9
  718. package/src/scripts/hooks_doctor.ts +418 -0
  719. package/src/scripts/hooks_status.ts +292 -0
  720. package/src/scripts/injection_scan_hook.ts +285 -0
  721. package/src/scripts/install +36 -22
  722. package/src/scripts/install-hooks.sh +20 -14
  723. package/src/scripts/install.sh +38 -14
  724. package/src/scripts/install.ts +4515 -0
  725. package/src/scripts/inventory_abstraction_budget.ts +1104 -0
  726. package/src/scripts/inventory_frontmatter.ts +320 -0
  727. package/src/scripts/inventory_meta_layers.ts +516 -0
  728. package/src/scripts/iron_law_sha.ts +233 -0
  729. package/src/scripts/knowledge_global_cli.ts +1105 -0
  730. package/src/scripts/linked_projects_list.ts +310 -0
  731. package/src/scripts/lint_agent_security.ts +224 -0
  732. package/src/scripts/lint_agent_skill_names.ts +241 -0
  733. package/src/scripts/lint_agents_layout.ts +205 -0
  734. package/src/scripts/lint_agents_md.ts +294 -0
  735. package/src/scripts/lint_archived_skills.ts +309 -0
  736. package/src/scripts/lint_artefact_frontmatter.ts +359 -0
  737. package/src/scripts/lint_bench_ab.ts +319 -0
  738. package/src/scripts/lint_bench_corpus.ts +421 -0
  739. package/src/scripts/lint_command_flow_coverage.ts +231 -0
  740. package/src/scripts/lint_command_routing.ts +377 -0
  741. package/src/scripts/lint_command_tiers.ts +345 -0
  742. package/src/scripts/lint_command_verbs.ts +379 -0
  743. package/src/scripts/lint_commit_subjects.ts +243 -0
  744. package/src/scripts/lint_context_spine_usage.ts +198 -0
  745. package/src/scripts/lint_discovery_manifest.ts +540 -0
  746. package/src/scripts/lint_discovery_vocabulary.ts +393 -0
  747. package/src/scripts/lint_empty_roadmaps.ts +147 -0
  748. package/src/scripts/lint_eval_freshness.ts +335 -0
  749. package/src/scripts/lint_examples.ts +183 -0
  750. package/src/scripts/lint_explain_trace.ts +381 -0
  751. package/src/scripts/lint_featured_skills.ts +0 -0
  752. package/src/scripts/lint_flows.ts +701 -0
  753. package/src/scripts/lint_framework_leakage.ts +497 -0
  754. package/src/scripts/lint_framework_leakage_allowlist.json +8 -1
  755. package/src/scripts/lint_frontmatter_boilerplate.ts +356 -0
  756. package/src/scripts/lint_ghostwriter_source.ts +389 -0
  757. package/src/scripts/lint_global_paths.ts +420 -0
  758. package/src/scripts/lint_handoffs.ts +362 -0
  759. package/src/scripts/lint_hidden_unicode.ts +350 -0
  760. package/src/scripts/lint_hook_concern_budget.ts +319 -0
  761. package/src/scripts/lint_hook_manifest.ts +354 -0
  762. package/src/scripts/lint_instruction_smuggling.ts +173 -0
  763. package/src/scripts/lint_load_context.ts +371 -0
  764. package/src/scripts/lint_marketplace.ts +286 -0
  765. package/src/scripts/lint_marketplace_install_completeness.ts +309 -0
  766. package/src/scripts/lint_mcp_config_security.ts +225 -0
  767. package/src/scripts/lint_mcp_registry_manifest.ts +350 -0
  768. package/src/scripts/lint_media_policy_linkage.ts +224 -0
  769. package/src/scripts/lint_missions.ts +774 -0
  770. package/src/scripts/lint_model_tier_coverage.ts +151 -0
  771. package/src/scripts/lint_namespace.ts +295 -0
  772. package/src/scripts/lint_namespace_collisions.ts +203 -0
  773. package/src/scripts/lint_new_skill_gate.ts +462 -0
  774. package/src/scripts/lint_no_new_atomic_commands.ts +342 -0
  775. package/src/scripts/lint_one_off_age.ts +348 -0
  776. package/src/scripts/lint_orchestration_dsl.ts +377 -0
  777. package/src/scripts/lint_orchestrator_auto_detect.ts +177 -0
  778. package/src/scripts/lint_pack_boundaries.ts +366 -0
  779. package/src/scripts/lint_pack_dependencies.ts +541 -0
  780. package/src/scripts/lint_pack_first_win.ts +202 -0
  781. package/src/scripts/lint_persona_governance.ts +292 -0
  782. package/src/scripts/lint_positioning.ts +257 -0
  783. package/src/scripts/lint_profile_overlay_set_only.ts +324 -0
  784. package/src/scripts/lint_readme_jargon.ts +189 -0
  785. package/src/scripts/lint_readme_size.ts +73 -0
  786. package/src/scripts/lint_regression.ts +497 -0
  787. package/src/scripts/lint_roadmap_ci_steps.ts +252 -0
  788. package/src/scripts/lint_roadmap_complexity.ts +295 -0
  789. package/src/scripts/lint_roadmap_later_disposition.ts +357 -0
  790. package/src/scripts/lint_role_experiences.ts +410 -0
  791. package/src/scripts/lint_rule_interactions.ts +281 -0
  792. package/src/scripts/lint_rule_tiers.ts +169 -0
  793. package/src/scripts/lint_showcase_sessions.ts +254 -0
  794. package/src/scripts/lint_skill_frontmatter_safety.ts +279 -0
  795. package/src/scripts/lint_skill_originality.ts +586 -0
  796. package/src/scripts/lint_skill_originality_allowlist.json +20 -0
  797. package/src/scripts/lint_skill_tools.ts +320 -0
  798. package/src/scripts/lint_ticket_buildable.ts +1027 -0
  799. package/src/scripts/lint_topics_yaml.ts +203 -0
  800. package/src/scripts/lint_trust_coherence.ts +377 -0
  801. package/src/scripts/lint_value_dashboard.ts +314 -0
  802. package/src/scripts/lint_workflow_security.ts +637 -0
  803. package/src/scripts/lint_workflow_security_allowlist.json +20 -0
  804. package/src/scripts/lint_workspace_boundary.ts +248 -0
  805. package/src/scripts/mcp_parity_smoke.ts +638 -0
  806. package/src/scripts/mcp_render.ts +346 -0
  807. package/src/scripts/mcp_server/__main__.ts +28 -0
  808. package/src/scripts/mcp_server/catalog.ts +154 -0
  809. package/src/scripts/mcp_server/index.ts +24 -0
  810. package/src/scripts/mcp_server/metadata.ts +83 -0
  811. package/src/scripts/mcp_server/prompts.ts +711 -0
  812. package/src/scripts/mcp_server/resources.ts +343 -0
  813. package/src/scripts/mcp_server/server.ts +439 -0
  814. package/src/scripts/mcp_server/telemetry.ts +154 -0
  815. package/src/scripts/mcp_server/tools.ts +1031 -0
  816. package/src/scripts/mcp_setup.sh +25 -52
  817. package/src/scripts/mcp_telemetry_health.ts +362 -0
  818. package/src/scripts/mcp_telemetry_query.ts +371 -0
  819. package/src/scripts/mcp_telemetry_store.ts +422 -0
  820. package/src/scripts/measure_augment_budget.ts +453 -0
  821. package/src/scripts/measure_density.ts +618 -0
  822. package/src/scripts/measure_frugality_savings.ts +353 -0
  823. package/src/scripts/measure_markitdown_lift.ts +299 -0
  824. package/src/scripts/measure_patterns.ts +682 -0
  825. package/src/scripts/measure_projection_bytes.ts +425 -0
  826. package/src/scripts/measure_rule_budget.ts +627 -0
  827. package/src/scripts/measure_skill_reduction.ts +442 -0
  828. package/src/scripts/media/lib/adapter-common.sh +247 -0
  829. package/src/scripts/media/lib/adapter-contract.md +329 -0
  830. package/src/scripts/media/lib/fixtures/comfyui/result.json +1 -0
  831. package/src/scripts/media/lib/fixtures/fal/result.json +1 -0
  832. package/src/scripts/media/lib/fixtures/flux/asset-0001.png +0 -0
  833. package/src/scripts/media/lib/fixtures/flux/result.json +1 -0
  834. package/src/scripts/media/lib/fixtures/gemini-image/asset-0001.png +0 -0
  835. package/src/scripts/media/lib/fixtures/gemini-image/result.json +1 -0
  836. package/src/scripts/media/lib/fixtures/gemini-veo/result.json +1 -0
  837. package/src/scripts/media/lib/fixtures/higgsfield/result.json +1 -0
  838. package/src/scripts/media/lib/fixtures/ideogram/asset-0001.png +0 -0
  839. package/src/scripts/media/lib/fixtures/ideogram/result.json +1 -0
  840. package/src/scripts/media/lib/fixtures/kling/result.json +1 -0
  841. package/src/scripts/media/lib/fixtures/musetalk/result.json +1 -0
  842. package/src/scripts/media/lib/fixtures/openai-images/result.json +1 -0
  843. package/src/scripts/media/lib/fixtures/recraft/asset-0001.svg +1 -0
  844. package/src/scripts/media/lib/fixtures/recraft/result.json +1 -0
  845. package/src/scripts/media/lib/fixtures/replicate/result.json +1 -0
  846. package/src/scripts/media/lib/fixtures/sora/result.json +1 -0
  847. package/src/scripts/media/lib/fixtures/syncso/result.json +1 -0
  848. package/src/scripts/media/lib/load-config.sh +180 -0
  849. package/src/scripts/media/lib/redact.sh +85 -0
  850. package/src/scripts/memory_hash.ts +331 -0
  851. package/src/scripts/memory_lookup.ts +1278 -0
  852. package/src/scripts/memory_report.ts +845 -0
  853. package/src/scripts/memory_signal.ts +417 -0
  854. package/src/scripts/memory_status.ts +189 -0
  855. package/src/scripts/migrate_command_suggestions.ts +341 -0
  856. package/src/scripts/migrate_frontmatter_defaults.ts +539 -0
  857. package/src/scripts/migration_status.ts +301 -0
  858. package/src/scripts/mine_session.ts +645 -0
  859. package/src/scripts/minimal_safe_diff_hook.ts +355 -0
  860. package/src/scripts/move_artefact.ts +869 -0
  861. package/src/scripts/new_skill.ts +404 -0
  862. package/src/scripts/onboarding_gate_hook.ts +224 -0
  863. package/src/scripts/pack_dependency_allowlist.json +1 -1
  864. package/src/scripts/pack_mcp_content.ts +552 -0
  865. package/src/scripts/parity/README.md +140 -0
  866. package/src/scripts/parity/compare.ts +189 -0
  867. package/src/scripts/parity/coverage_diff.ts +199 -0
  868. package/src/scripts/parity/phase-manifest.json +93 -0
  869. package/src/scripts/parity/phase_gate.ts +270 -0
  870. package/src/scripts/parity/replay.ts +320 -0
  871. package/src/scripts/pattern_share.ts +363 -0
  872. package/src/scripts/plan_physical_move.ts +605 -0
  873. package/src/scripts/prediction-pool/poisson_sim.ts +537 -0
  874. package/src/scripts/prediction-pool/pool_winsim.ts +677 -0
  875. package/src/scripts/prediction-pool/score_ev.ts +546 -0
  876. package/src/scripts/print_required_checks.ts +249 -0
  877. package/src/scripts/probe_projection_fidelity.ts +468 -0
  878. package/src/scripts/probe_skill_registration.ts +787 -0
  879. package/src/scripts/profile_staleness_hook.ts +169 -0
  880. package/src/scripts/profile_use.ts +227 -0
  881. package/src/scripts/project_thin_rules.ts +387 -0
  882. package/src/scripts/propose_modules_config.ts +311 -0
  883. package/src/scripts/prototype_lint_contradictions.ts +414 -0
  884. package/src/scripts/prove_pack_extractable.ts +388 -0
  885. package/src/scripts/readme_linter.ts +913 -0
  886. package/src/scripts/redact_hook_capture.ts +325 -0
  887. package/src/scripts/refine_ticket_detect.ts +703 -0
  888. package/src/scripts/release.ts +1697 -0
  889. package/src/scripts/render_benchmark_md.ts +664 -0
  890. package/src/scripts/render_value_md.ts +506 -0
  891. package/src/scripts/repro/repro_marketplace_install_gap.sh +1 -1
  892. package/src/scripts/roadmap_progress_hook.ts +410 -0
  893. package/src/scripts/router_telemetry.ts +972 -0
  894. package/src/scripts/run.ts +98 -0
  895. package/src/scripts/run_skill_evals.ts +477 -0
  896. package/src/scripts/runtime_dispatcher.ts +586 -0
  897. package/src/scripts/runtime_handler.ts +231 -0
  898. package/src/scripts/runtime_registry.ts +394 -0
  899. package/src/scripts/schemas/command.schema.json +3 -2
  900. package/src/scripts/schemas/mission-catalog.schema.json +112 -0
  901. package/src/scripts/schemas/mission.schema.json +87 -0
  902. package/src/scripts/schemas/pack.schema.json +6 -0
  903. package/src/scripts/schemas/rule.schema.json +1 -0
  904. package/src/scripts/schemas/skill.schema.json +1 -0
  905. package/src/scripts/schemas/ticket-manifest.schema.json +35 -0
  906. package/src/scripts/schemas/ticket.schema.json +60 -0
  907. package/src/scripts/score_skill_selection.ts +570 -0
  908. package/src/scripts/security_audit_config.ts +423 -0
  909. package/src/scripts/skill_collision_clusters.ts +448 -0
  910. package/src/scripts/skill_discovery.ts +690 -0
  911. package/src/scripts/skill_linter.ts +4276 -0
  912. package/src/scripts/skill_overlap.ts +414 -0
  913. package/src/scripts/skill_preview.ts +548 -0
  914. package/src/scripts/skill_tools/audit_persona_coverage.ts +427 -0
  915. package/src/scripts/skill_tools/audit_user_type_coverage.ts +507 -0
  916. package/src/scripts/skill_tools/index.ts +28 -0
  917. package/src/scripts/skill_tools/run_block_d_eval.ts +373 -0
  918. package/src/scripts/skill_tools/score_skill_relevance.ts +475 -0
  919. package/src/scripts/skill_tools/suggest_skill_for_task.ts +288 -0
  920. package/src/scripts/skill_trigger_eval.ts +1046 -0
  921. package/src/scripts/skill_usage_collect.ts +465 -0
  922. package/src/scripts/skill_usage_report.ts +364 -0
  923. package/src/scripts/smoke/kernel.sh +4 -5
  924. package/src/scripts/smoke/router.sh +76 -76
  925. package/src/scripts/smoke/schema.sh +2 -2
  926. package/src/scripts/smoke/skills.sh +73 -52
  927. package/src/scripts/smoke_path_resolution.ts +194 -0
  928. package/src/scripts/smoke_quickstart.ts +224 -0
  929. package/src/scripts/snapshot_agent_outputs.ts +375 -0
  930. package/src/scripts/spotcheck_thin_root.ts +247 -0
  931. package/src/scripts/surface-tiers.yml +68 -0
  932. package/src/scripts/sync_agent_settings.ts +763 -0
  933. package/src/scripts/sync_github_metadata.ts +550 -0
  934. package/src/scripts/sync_gitignore.ts +630 -0
  935. package/src/scripts/sync_yaml_rt.ts +910 -0
  936. package/src/scripts/telegraph_stats.ts +447 -0
  937. package/src/scripts/tool_registry.ts +330 -0
  938. package/src/scripts/tools/adapter_errors.ts +93 -0
  939. package/src/scripts/tools/base_adapter.ts +147 -0
  940. package/src/scripts/tools/github_adapter.ts +229 -0
  941. package/src/scripts/tools/jira_adapter.ts +196 -0
  942. package/src/scripts/trigger_coverage.ts +251 -0
  943. package/src/scripts/update_counts.ts +284 -0
  944. package/src/scripts/update_prices.ts +219 -0
  945. package/src/scripts/validate_agent_settings.ts +265 -0
  946. package/src/scripts/validate_decision_engine.ts +366 -0
  947. package/src/scripts/validate_discovery_manifest.ts +160 -0
  948. package/src/scripts/validate_frontmatter.ts +1030 -0
  949. package/src/scripts/validate_pack_yaml.ts +0 -0
  950. package/src/scripts/validate_safe_paths.ts +164 -0
  951. package/src/scripts/validate_telegraph_carveouts.ts +485 -0
  952. package/src/scripts/verify_before_complete_hook.ts +306 -0
  953. package/src/scripts/verify_physical_move.ts +411 -0
  954. package/src/scripts/wrapper_freshness_hook.ts +179 -0
  955. package/dist/agent-src/scripts/archive_completed_roadmaps.py +0 -171
  956. package/dist/agent-src/scripts/update_roadmap_progress.py +0 -537
  957. package/dist/agent-src/skills/corpus-grounding/scripts/bm25_search.py +0 -212
  958. package/dist/agent-src/skills/corpus-grounding/scripts/decision_engine.py +0 -438
  959. package/dist/agent-src/skills/corpus-grounding/scripts/ground.py +0 -166
  960. package/dist/agent-src/skills/corpus-grounding/scripts/schema_validator.py +0 -160
  961. package/dist/agent-src/skills/design-tokens/scripts/tokens.py +0 -296
  962. package/dist/agent-src/skills/react-shadcn-ui/scripts/shadcn_add.py +0 -299
  963. package/dist/agent-src/skills/tailwind-engineer/scripts/tailwind_config_gen.py +0 -463
  964. package/dist/agent-src/templates/scripts/check_memory.py +0 -282
  965. package/dist/agent-src/templates/scripts/check_memory_proposal.py +0 -180
  966. package/dist/agent-src/templates/scripts/implement_ticket/__init__.py +0 -94
  967. package/dist/agent-src/templates/scripts/implement_ticket/__main__.py +0 -15
  968. package/dist/agent-src/templates/scripts/memory_hash.py +0 -75
  969. package/dist/agent-src/templates/scripts/memory_lookup.py +0 -436
  970. package/dist/agent-src/templates/scripts/memory_report.py +0 -314
  971. package/dist/agent-src/templates/scripts/memory_signal.py +0 -165
  972. package/dist/agent-src/templates/scripts/memory_status.py +0 -76
  973. package/dist/agent-src/templates/scripts/pr_review_routing.py +0 -340
  974. package/dist/agent-src/templates/scripts/pr_risk_review.py +0 -211
  975. package/dist/agent-src/templates/scripts/telemetry/__init__.py +0 -42
  976. package/dist/agent-src/templates/scripts/telemetry/aggregator.py +0 -169
  977. package/dist/agent-src/templates/scripts/telemetry/boundary.py +0 -171
  978. package/dist/agent-src/templates/scripts/telemetry/engagement.py +0 -297
  979. package/dist/agent-src/templates/scripts/telemetry/report_renderer.py +0 -197
  980. package/dist/agent-src/templates/scripts/telemetry/settings.py +0 -177
  981. package/dist/agent-src/templates/scripts/telemetry_record.py +0 -179
  982. package/dist/agent-src/templates/scripts/telemetry_report.py +0 -161
  983. package/dist/agent-src/templates/scripts/telemetry_status.py +0 -142
  984. package/dist/agent-src/templates/scripts/tier_usage_report.py +0 -183
  985. package/dist/agent-src/templates/scripts/work_engine/__init__.py +0 -58
  986. package/dist/agent-src/templates/scripts/work_engine/__main__.py +0 -9
  987. package/dist/agent-src/templates/scripts/work_engine/_lib/__init__.py +0 -7
  988. package/dist/agent-src/templates/scripts/work_engine/_lib/agent_settings.py +0 -840
  989. package/dist/agent-src/templates/scripts/work_engine/_lib/user_global_paths.py +0 -249
  990. package/dist/agent-src/templates/scripts/work_engine/cli.py +0 -195
  991. package/dist/agent-src/templates/scripts/work_engine/cli_args.py +0 -116
  992. package/dist/agent-src/templates/scripts/work_engine/delivery_state.py +0 -137
  993. package/dist/agent-src/templates/scripts/work_engine/directives/__init__.py +0 -33
  994. package/dist/agent-src/templates/scripts/work_engine/directives/backend/__init__.py +0 -98
  995. package/dist/agent-src/templates/scripts/work_engine/directives/backend/analyze.py +0 -98
  996. package/dist/agent-src/templates/scripts/work_engine/directives/backend/implement.py +0 -145
  997. package/dist/agent-src/templates/scripts/work_engine/directives/backend/memory.py +0 -136
  998. package/dist/agent-src/templates/scripts/work_engine/directives/backend/plan.py +0 -175
  999. package/dist/agent-src/templates/scripts/work_engine/directives/backend/refine.py +0 -396
  1000. package/dist/agent-src/templates/scripts/work_engine/directives/backend/report.py +0 -227
  1001. package/dist/agent-src/templates/scripts/work_engine/directives/backend/test.py +0 -180
  1002. package/dist/agent-src/templates/scripts/work_engine/directives/backend/verify.py +0 -170
  1003. package/dist/agent-src/templates/scripts/work_engine/directives/mixed/__init__.py +0 -116
  1004. package/dist/agent-src/templates/scripts/work_engine/directives/mixed/contract.py +0 -254
  1005. package/dist/agent-src/templates/scripts/work_engine/directives/mixed/stitch.py +0 -229
  1006. package/dist/agent-src/templates/scripts/work_engine/directives/mixed/ui.py +0 -231
  1007. package/dist/agent-src/templates/scripts/work_engine/directives/ui/__init__.py +0 -113
  1008. package/dist/agent-src/templates/scripts/work_engine/directives/ui/_passthrough.py +0 -44
  1009. package/dist/agent-src/templates/scripts/work_engine/directives/ui/apply.py +0 -241
  1010. package/dist/agent-src/templates/scripts/work_engine/directives/ui/audit.py +0 -414
  1011. package/dist/agent-src/templates/scripts/work_engine/directives/ui/design.py +0 -335
  1012. package/dist/agent-src/templates/scripts/work_engine/directives/ui/polish.py +0 -513
  1013. package/dist/agent-src/templates/scripts/work_engine/directives/ui/review.py +0 -471
  1014. package/dist/agent-src/templates/scripts/work_engine/directives/ui_trivial/__init__.py +0 -119
  1015. package/dist/agent-src/templates/scripts/work_engine/directives/ui_trivial/_skipped.py +0 -37
  1016. package/dist/agent-src/templates/scripts/work_engine/directives/ui_trivial/apply.py +0 -165
  1017. package/dist/agent-src/templates/scripts/work_engine/directives/ui_trivial/refine.py +0 -66
  1018. package/dist/agent-src/templates/scripts/work_engine/directives/ui_trivial/report.py +0 -62
  1019. package/dist/agent-src/templates/scripts/work_engine/directives/ui_trivial/test.py +0 -115
  1020. package/dist/agent-src/templates/scripts/work_engine/dispatcher.py +0 -331
  1021. package/dist/agent-src/templates/scripts/work_engine/emitters.py +0 -68
  1022. package/dist/agent-src/templates/scripts/work_engine/errors.py +0 -19
  1023. package/dist/agent-src/templates/scripts/work_engine/hook_bootstrap.py +0 -91
  1024. package/dist/agent-src/templates/scripts/work_engine/hooks/__init__.py +0 -54
  1025. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/__init__.py +0 -35
  1026. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/_chat_history_base.py +0 -59
  1027. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/chat_history_append.py +0 -43
  1028. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/chat_history_halt_append.py +0 -41
  1029. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/decision_gate.py +0 -162
  1030. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/decision_trace.py +0 -163
  1031. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/directive_set_guard.py +0 -53
  1032. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/halt_surface_audit.py +0 -50
  1033. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/memory_visibility.py +0 -141
  1034. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/state_shape_validation.py +0 -52
  1035. package/dist/agent-src/templates/scripts/work_engine/hooks/builtin/trace.py +0 -84
  1036. package/dist/agent-src/templates/scripts/work_engine/hooks/context.py +0 -66
  1037. package/dist/agent-src/templates/scripts/work_engine/hooks/events.py +0 -44
  1038. package/dist/agent-src/templates/scripts/work_engine/hooks/exceptions.py +0 -79
  1039. package/dist/agent-src/templates/scripts/work_engine/hooks/registry.py +0 -60
  1040. package/dist/agent-src/templates/scripts/work_engine/hooks/runner.py +0 -73
  1041. package/dist/agent-src/templates/scripts/work_engine/hooks/settings.py +0 -196
  1042. package/dist/agent-src/templates/scripts/work_engine/input_builders.py +0 -163
  1043. package/dist/agent-src/templates/scripts/work_engine/intent/__init__.py +0 -47
  1044. package/dist/agent-src/templates/scripts/work_engine/intent/classify.py +0 -280
  1045. package/dist/agent-src/templates/scripts/work_engine/migration/__init__.py +0 -8
  1046. package/dist/agent-src/templates/scripts/work_engine/migration/v0_to_v1.py +0 -231
  1047. package/dist/agent-src/templates/scripts/work_engine/orchestration.py +0 -193
  1048. package/dist/agent-src/templates/scripts/work_engine/persona_policy.py +0 -85
  1049. package/dist/agent-src/templates/scripts/work_engine/resolvers/__init__.py +0 -22
  1050. package/dist/agent-src/templates/scripts/work_engine/resolvers/diff.py +0 -106
  1051. package/dist/agent-src/templates/scripts/work_engine/resolvers/file.py +0 -113
  1052. package/dist/agent-src/templates/scripts/work_engine/resolvers/prompt.py +0 -90
  1053. package/dist/agent-src/templates/scripts/work_engine/scoring/__init__.py +0 -14
  1054. package/dist/agent-src/templates/scripts/work_engine/scoring/confidence.py +0 -300
  1055. package/dist/agent-src/templates/scripts/work_engine/scoring/decision_engine.py +0 -351
  1056. package/dist/agent-src/templates/scripts/work_engine/scoring/decision_trace.py +0 -141
  1057. package/dist/agent-src/templates/scripts/work_engine/scoring/memory_visibility.py +0 -283
  1058. package/dist/agent-src/templates/scripts/work_engine/stack/__init__.py +0 -31
  1059. package/dist/agent-src/templates/scripts/work_engine/stack/detect.py +0 -187
  1060. package/dist/agent-src/templates/scripts/work_engine/stack/runner.py +0 -481
  1061. package/dist/agent-src/templates/scripts/work_engine/state.py +0 -694
  1062. package/dist/agent-src/templates/scripts/work_engine/state_io.py +0 -202
  1063. package/dist/cli/python/resolvePython.js +0 -38
  1064. package/dist/cli/python/resolvePython.js.map +0 -1
  1065. package/src/scripts/__pycache__/validate_frontmatter.cpython-312.pyc +0 -0
  1066. package/src/scripts/_archive/_backfill_skill_domains.py +0 -140
  1067. package/src/scripts/_archive/_bootstrap_tier_frontmatter.py +0 -151
  1068. package/src/scripts/_archive/_p43_bodies.py +0 -235
  1069. package/src/scripts/_archive/_p43_condense.py +0 -118
  1070. package/src/scripts/_archive/_p4_migrate.py +0 -199
  1071. package/src/scripts/_archive/_phase2_shim_helper.py +0 -109
  1072. package/src/scripts/_archive/_pilot_council_question.py +0 -57
  1073. package/src/scripts/_cli/__init__.py +0 -0
  1074. package/src/scripts/_cli/cmd_doctor.py +0 -1669
  1075. package/src/scripts/_cli/cmd_explain.py +0 -355
  1076. package/src/scripts/_cli/cmd_export.py +0 -157
  1077. package/src/scripts/_cli/cmd_migrate.py +0 -524
  1078. package/src/scripts/_cli/cmd_prune.py +0 -322
  1079. package/src/scripts/_cli/cmd_refresh.py +0 -179
  1080. package/src/scripts/_cli/cmd_settings_check.py +0 -171
  1081. package/src/scripts/_cli/cmd_settings_migrate.py +0 -147
  1082. package/src/scripts/_cli/cmd_sync.py +0 -166
  1083. package/src/scripts/_cli/cmd_uninstall.py +0 -476
  1084. package/src/scripts/_cli/cmd_update.py +0 -279
  1085. package/src/scripts/_cli/cmd_upgrade.py +0 -172
  1086. package/src/scripts/_cli/cmd_validate.py +0 -177
  1087. package/src/scripts/_cli/cmd_versions.py +0 -160
  1088. package/src/scripts/_cli/explain_last/__init__.py +0 -122
  1089. package/src/scripts/_cli/explain_last/assumptions.py +0 -59
  1090. package/src/scripts/_cli/explain_last/council.py +0 -105
  1091. package/src/scripts/_cli/explain_last/halt.py +0 -44
  1092. package/src/scripts/_cli/explain_last/inputs.py +0 -128
  1093. package/src/scripts/_cli/explain_last/memory.py +0 -94
  1094. package/src/scripts/_cli/explain_last/provider.py +0 -52
  1095. package/src/scripts/_cli/explain_last/render.py +0 -52
  1096. package/src/scripts/_cli/explain_last/route.py +0 -59
  1097. package/src/scripts/_cli/explain_last/scrubber.py +0 -105
  1098. package/src/scripts/_cli/explain_last/sections/__init__.py +0 -35
  1099. package/src/scripts/_cli/explain_last/sections/assumptions.py +0 -21
  1100. package/src/scripts/_cli/explain_last/sections/council.py +0 -27
  1101. package/src/scripts/_cli/explain_last/sections/halt.py +0 -31
  1102. package/src/scripts/_cli/explain_last/sections/header.py +0 -24
  1103. package/src/scripts/_cli/explain_last/sections/inputs.py +0 -27
  1104. package/src/scripts/_cli/explain_last/sections/memory.py +0 -21
  1105. package/src/scripts/_cli/explain_last/sections/pack.py +0 -16
  1106. package/src/scripts/_cli/explain_last/sections/provider.py +0 -26
  1107. package/src/scripts/_cli/explain_last/sections/route.py +0 -22
  1108. package/src/scripts/_cli/explain_last/state_loader.py +0 -76
  1109. package/src/scripts/_emit_domain_table.py +0 -35
  1110. package/src/scripts/_lib/__init__.py +0 -5
  1111. package/src/scripts/_lib/__pycache__/__init__.cpython-312.pyc +0 -0
  1112. package/src/scripts/_lib/__pycache__/agent_src.cpython-312.pyc +0 -0
  1113. package/src/scripts/_lib/agent_settings.py +0 -840
  1114. package/src/scripts/_lib/agent_src.py +0 -491
  1115. package/src/scripts/_lib/agents_overlay.py +0 -120
  1116. package/src/scripts/_lib/bench_ab_cache.py +0 -162
  1117. package/src/scripts/_lib/bench_ab_scoring.py +0 -209
  1118. package/src/scripts/_lib/bench_ab_scoring_v2.py +0 -227
  1119. package/src/scripts/_lib/bench_cost.py +0 -138
  1120. package/src/scripts/_lib/bench_quality.py +0 -118
  1121. package/src/scripts/_lib/bench_report.py +0 -149
  1122. package/src/scripts/_lib/bench_telegraph.py +0 -273
  1123. package/src/scripts/_lib/bench_telegraph_report.py +0 -151
  1124. package/src/scripts/_lib/changelog_eras.py +0 -330
  1125. package/src/scripts/_lib/claude_desktop_bundler.py +0 -238
  1126. package/src/scripts/_lib/cli_wrapper.py +0 -64
  1127. package/src/scripts/_lib/fs_atomic.py +0 -116
  1128. package/src/scripts/_lib/global_deploy_inventory.py +0 -312
  1129. package/src/scripts/_lib/install_regenerator.py +0 -134
  1130. package/src/scripts/_lib/installed_lock.py +0 -256
  1131. package/src/scripts/_lib/installed_tools.py +0 -381
  1132. package/src/scripts/_lib/json_pointers.py +0 -260
  1133. package/src/scripts/_lib/link_crypto.py +0 -206
  1134. package/src/scripts/_lib/linked_projects.py +0 -238
  1135. package/src/scripts/_lib/model_tier.py +0 -52
  1136. package/src/scripts/_lib/module_detection.py +0 -223
  1137. package/src/scripts/_lib/pin_resolver.py +0 -152
  1138. package/src/scripts/_lib/script_output.py +0 -144
  1139. package/src/scripts/_lib/security_lint.py +0 -228
  1140. package/src/scripts/_lib/token_count.py +0 -95
  1141. package/src/scripts/_lib/update_check.py +0 -207
  1142. package/src/scripts/_lib/user_global_paths.py +0 -249
  1143. package/src/scripts/_lib/value_ladder.py +0 -696
  1144. package/src/scripts/_lib/value_report.py +0 -455
  1145. package/src/scripts/_phase4_bucket.py +0 -210
  1146. package/src/scripts/_pilot_measure.py +0 -53
  1147. package/src/scripts/_tmp_scan_framework_leakage.py +0 -119
  1148. package/src/scripts/adoption_report.py +0 -195
  1149. package/src/scripts/adoption_snapshot.py +0 -219
  1150. package/src/scripts/adoption_status.py +0 -166
  1151. package/src/scripts/adr/regenerate_index.py +0 -79
  1152. package/src/scripts/ai-video/lib/adapter-common.sh +0 -231
  1153. package/src/scripts/ai-video/lib/adapter-contract.md +0 -329
  1154. package/src/scripts/ai-video/lib/fixtures/comfyui/result.json +0 -1
  1155. package/src/scripts/ai-video/lib/fixtures/fal/result.json +0 -1
  1156. package/src/scripts/ai-video/lib/fixtures/gemini-veo/result.json +0 -1
  1157. package/src/scripts/ai-video/lib/fixtures/higgsfield/result.json +0 -1
  1158. package/src/scripts/ai-video/lib/fixtures/kling/result.json +0 -1
  1159. package/src/scripts/ai-video/lib/fixtures/musetalk/result.json +0 -1
  1160. package/src/scripts/ai-video/lib/fixtures/openai-images/result.json +0 -1
  1161. package/src/scripts/ai-video/lib/fixtures/replicate/result.json +0 -1
  1162. package/src/scripts/ai-video/lib/fixtures/sora/result.json +0 -1
  1163. package/src/scripts/ai-video/lib/fixtures/syncso/result.json +0 -1
  1164. package/src/scripts/ai-video/lib/load-config.sh +0 -180
  1165. package/src/scripts/ai-video/lib/redact.sh +0 -85
  1166. package/src/scripts/ai_council/__init__.py +0 -40
  1167. package/src/scripts/ai_council/_default_prices.py +0 -50
  1168. package/src/scripts/ai_council/advisors.py +0 -148
  1169. package/src/scripts/ai_council/airgap.py +0 -165
  1170. package/src/scripts/ai_council/budget_guard.py +0 -202
  1171. package/src/scripts/ai_council/bundler.py +0 -263
  1172. package/src/scripts/ai_council/cli_hints.py +0 -123
  1173. package/src/scripts/ai_council/clients.py +0 -1385
  1174. package/src/scripts/ai_council/compile_corpus.py +0 -179
  1175. package/src/scripts/ai_council/confidence_gate.py +0 -156
  1176. package/src/scripts/ai_council/config.py +0 -1419
  1177. package/src/scripts/ai_council/consensus.py +0 -329
  1178. package/src/scripts/ai_council/events_log.py +0 -141
  1179. package/src/scripts/ai_council/learn_low_impact_preview.py +0 -252
  1180. package/src/scripts/ai_council/low_impact.py +0 -714
  1181. package/src/scripts/ai_council/low_impact_corpus.py +0 -466
  1182. package/src/scripts/ai_council/low_impact_intake.py +0 -163
  1183. package/src/scripts/ai_council/modes.py +0 -131
  1184. package/src/scripts/ai_council/necessity.py +0 -782
  1185. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_2a4_acceptance.py +0 -208
  1186. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_add_quiet.py +0 -149
  1187. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_budget_v2_audit.py +0 -206
  1188. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_context_layer_v1_estimate.py +0 -67
  1189. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_context_layer_v1_review.py +0 -292
  1190. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_followups_review.py +0 -259
  1191. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_inject_quiet_flag.py +0 -33
  1192. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_measure_v2.sh +0 -36
  1193. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_measure_verbosity.sh +0 -26
  1194. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_nondestructive_inline_audit.py +0 -209
  1195. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_per_task.sh +0 -41
  1196. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_phase4_dispatch_latency.py +0 -108
  1197. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_phase6_trigger_jaccard.py +0 -92
  1198. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_phase_2a_budget_rebalance.py +0 -257
  1199. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_phase_2a_post_revert.py +0 -197
  1200. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_rebalancing_audit.py +0 -149
  1201. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_roundtrip.py +0 -111
  1202. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_rule_hardening_v1.py +0 -251
  1203. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_silent_taskfiles.py +0 -98
  1204. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_structural_open_questions.py +0 -232
  1205. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_structural_optimization.py +0 -144
  1206. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_structural_v3_gaps.py +0 -252
  1207. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_structural_v3_review.py +0 -240
  1208. package/src/scripts/ai_council/one_off_archive/2026-05/_one_off_tier_retrofit.py +0 -180
  1209. package/src/scripts/ai_council/orchestrator.py +0 -1206
  1210. package/src/scripts/ai_council/pricing.py +0 -215
  1211. package/src/scripts/ai_council/probation_gate.py +0 -152
  1212. package/src/scripts/ai_council/project_context.py +0 -159
  1213. package/src/scripts/ai_council/prompts.py +0 -567
  1214. package/src/scripts/ai_council/redact_low_impact_entry.py +0 -155
  1215. package/src/scripts/ai_council/replay.py +0 -155
  1216. package/src/scripts/ai_council/session.py +0 -366
  1217. package/src/scripts/ai_council/shadow_dispatch.py +0 -235
  1218. package/src/scripts/ai_council/solo_dispatch.py +0 -226
  1219. package/src/scripts/annotate_discovery.py +0 -149
  1220. package/src/scripts/apply_modules_config.py +0 -290
  1221. package/src/scripts/audit_adr_coverage.py +0 -173
  1222. package/src/scripts/audit_auto_rules.py +0 -175
  1223. package/src/scripts/audit_cloud_compatibility.py +0 -362
  1224. package/src/scripts/audit_command_surface.py +0 -682
  1225. package/src/scripts/audit_initial_context.py +0 -237
  1226. package/src/scripts/audit_likelihood.py +0 -148
  1227. package/src/scripts/audit_mcp_tools.py +0 -146
  1228. package/src/scripts/audit_overlap.py +0 -145
  1229. package/src/scripts/audit_skill_descriptions.py +0 -180
  1230. package/src/scripts/audit_skill_overlap.py +0 -207
  1231. package/src/scripts/audit_user_type_axis.py +0 -140
  1232. package/src/scripts/backfill_model_tier.py +0 -184
  1233. package/src/scripts/bench_ab_cache_dispatch.py +0 -68
  1234. package/src/scripts/bench_ab_clone.py +0 -220
  1235. package/src/scripts/bench_ab_diff.py +0 -220
  1236. package/src/scripts/bench_ab_integrity.py +0 -143
  1237. package/src/scripts/bench_ab_run.py +0 -235
  1238. package/src/scripts/bench_ab_task_runner.py +0 -814
  1239. package/src/scripts/bench_ab_tracka_run.py +0 -202
  1240. package/src/scripts/bench_ab_v2_run.py +0 -247
  1241. package/src/scripts/bench_ab_v2_stats.py +0 -347
  1242. package/src/scripts/bench_baseline_ready.py +0 -108
  1243. package/src/scripts/bench_condense_memory.py +0 -168
  1244. package/src/scripts/bench_drift_check.py +0 -151
  1245. package/src/scripts/bench_per_tool.py +0 -216
  1246. package/src/scripts/bench_rtk_savings.py +0 -320
  1247. package/src/scripts/bench_run.py +0 -272
  1248. package/src/scripts/bench_runner.py +0 -158
  1249. package/src/scripts/build_cloud_bundle.py +0 -458
  1250. package/src/scripts/build_discovery_manifest.py +0 -757
  1251. package/src/scripts/build_linear_digest.py +0 -260
  1252. package/src/scripts/build_mcp_registry_manifest.py +0 -181
  1253. package/src/scripts/build_rule_trigger_matrix.py +0 -350
  1254. package/src/scripts/capture_showcase_session.py +0 -361
  1255. package/src/scripts/chat_history.py +0 -1799
  1256. package/src/scripts/check_always_budget.py +0 -532
  1257. package/src/scripts/check_artefact_checksums.py +0 -111
  1258. package/src/scripts/check_augment_description_cap.py +0 -79
  1259. package/src/scripts/check_augmentignore.py +0 -72
  1260. package/src/scripts/check_beta_review_markers.py +0 -127
  1261. package/src/scripts/check_bite_sized_granularity.py +0 -98
  1262. package/src/scripts/check_cluster_patterns.py +0 -206
  1263. package/src/scripts/check_command_count_messaging.py +0 -152
  1264. package/src/scripts/check_condensation.py +0 -375
  1265. package/src/scripts/check_condensed_paths.py +0 -231
  1266. package/src/scripts/check_context_paths.py +0 -202
  1267. package/src/scripts/check_council_layout.py +0 -125
  1268. package/src/scripts/check_council_references.py +0 -228
  1269. package/src/scripts/check_discovery_determinism.py +0 -70
  1270. package/src/scripts/check_gate_paths.py +0 -128
  1271. package/src/scripts/check_iron_law_prominence.py +0 -145
  1272. package/src/scripts/check_kernel_rule_bundle.py +0 -151
  1273. package/src/scripts/check_md_language.py +0 -161
  1274. package/src/scripts/check_memory.py +0 -429
  1275. package/src/scripts/check_memory_proposal.py +0 -182
  1276. package/src/scripts/check_module_management_neutral.py +0 -147
  1277. package/src/scripts/check_no_external_sources.py +0 -101
  1278. package/src/scripts/check_no_local_settings_committed.py +0 -51
  1279. package/src/scripts/check_no_new_legacy_path.py +0 -100
  1280. package/src/scripts/check_no_roadmap_refs.py +0 -155
  1281. package/src/scripts/check_one_off_location.py +0 -81
  1282. package/src/scripts/check_overlay_cascade_subdirs.py +0 -129
  1283. package/src/scripts/check_portability.py +0 -574
  1284. package/src/scripts/check_proposal.py +0 -269
  1285. package/src/scripts/check_public_catalog_links.py +0 -125
  1286. package/src/scripts/check_public_links.py +0 -185
  1287. package/src/scripts/check_references.py +0 -559
  1288. package/src/scripts/check_release_includes_discovery.py +0 -61
  1289. package/src/scripts/check_release_pr_shape.py +0 -123
  1290. package/src/scripts/check_release_published.py +0 -145
  1291. package/src/scripts/check_release_trunk_sync.py +0 -152
  1292. package/src/scripts/check_reply_consistency.py +0 -169
  1293. package/src/scripts/check_roadmap_trackable.py +0 -114
  1294. package/src/scripts/check_role_doc_links.py +0 -110
  1295. package/src/scripts/check_safety_floor_untouched.py +0 -125
  1296. package/src/scripts/check_skill_requires.py +0 -147
  1297. package/src/scripts/check_template_pin_drift.py +0 -129
  1298. package/src/scripts/check_test_coverage_diff.py +0 -180
  1299. package/src/scripts/check_token_optimizer_freshness.py +0 -146
  1300. package/src/scripts/check_update_banner.py +0 -86
  1301. package/src/scripts/ci_status.py +0 -301
  1302. package/src/scripts/ci_summary.py +0 -131
  1303. package/src/scripts/ci_time_ratio.py +0 -168
  1304. package/src/scripts/command_suggester/__init__.py +0 -51
  1305. package/src/scripts/command_suggester/cooldown.py +0 -132
  1306. package/src/scripts/command_suggester/loader.py +0 -73
  1307. package/src/scripts/command_suggester/match.py +0 -180
  1308. package/src/scripts/command_suggester/rank.py +0 -120
  1309. package/src/scripts/command_suggester/render.py +0 -86
  1310. package/src/scripts/command_suggester/sanitize.py +0 -113
  1311. package/src/scripts/command_suggester/settings.py +0 -127
  1312. package/src/scripts/command_suggester/types.py +0 -78
  1313. package/src/scripts/compile_router.py +0 -232
  1314. package/src/scripts/condense.py +0 -1919
  1315. package/src/scripts/condense_memory.py +0 -178
  1316. package/src/scripts/config/__init__.py +0 -9
  1317. package/src/scripts/config/packs.py +0 -157
  1318. package/src/scripts/config/presets.py +0 -224
  1319. package/src/scripts/config/profile_explain.py +0 -89
  1320. package/src/scripts/config/profiles.py +0 -191
  1321. package/src/scripts/config/session_profiles.py +0 -542
  1322. package/src/scripts/context_hygiene_hook.py +0 -181
  1323. package/src/scripts/cost_by_conversation.py +0 -78
  1324. package/src/scripts/cost_summary.py +0 -97
  1325. package/src/scripts/council_cli.py +0 -2571
  1326. package/src/scripts/council_prune.py +0 -81
  1327. package/src/scripts/cross_repo_retrieve.py +0 -172
  1328. package/src/scripts/discovery_stats.py +0 -70
  1329. package/src/scripts/extract_audit_patterns.py +0 -202
  1330. package/src/scripts/first_run_gate_hook.py +0 -179
  1331. package/src/scripts/gen_discovery_baseline.py +0 -127
  1332. package/src/scripts/generate_catalog.py +0 -116
  1333. package/src/scripts/generate_command_flows.py +0 -191
  1334. package/src/scripts/generate_index.py +0 -303
  1335. package/src/scripts/generate_ownership_matrix.py +0 -378
  1336. package/src/scripts/generate_pack_manifests.py +0 -340
  1337. package/src/scripts/hooks/__init__.py +0 -1
  1338. package/src/scripts/hooks/dispatch_hook.py +0 -461
  1339. package/src/scripts/hooks/dispatch_issues.py +0 -136
  1340. package/src/scripts/hooks/envelope.py +0 -98
  1341. package/src/scripts/hooks/replay_hook.py +0 -144
  1342. package/src/scripts/hooks/state_io.py +0 -145
  1343. package/src/scripts/hooks_doctor.py +0 -223
  1344. package/src/scripts/hooks_status.py +0 -157
  1345. package/src/scripts/injection_scan_hook.py +0 -145
  1346. package/src/scripts/install.py +0 -5258
  1347. package/src/scripts/inventory_abstraction_budget.py +0 -622
  1348. package/src/scripts/inventory_frontmatter.py +0 -164
  1349. package/src/scripts/inventory_meta_layers.py +0 -288
  1350. package/src/scripts/iron_law_sha.py +0 -107
  1351. package/src/scripts/linked_projects_list.py +0 -91
  1352. package/src/scripts/lint_agent_security.py +0 -112
  1353. package/src/scripts/lint_agent_skill_names.py +0 -150
  1354. package/src/scripts/lint_agents_layout.py +0 -197
  1355. package/src/scripts/lint_agents_md.py +0 -210
  1356. package/src/scripts/lint_archived_skills.py +0 -159
  1357. package/src/scripts/lint_artefact_frontmatter.py +0 -188
  1358. package/src/scripts/lint_bench_ab.py +0 -173
  1359. package/src/scripts/lint_bench_corpus.py +0 -255
  1360. package/src/scripts/lint_command_flow_coverage.py +0 -132
  1361. package/src/scripts/lint_command_routing.py +0 -160
  1362. package/src/scripts/lint_command_tiers.py +0 -216
  1363. package/src/scripts/lint_command_verbs.py +0 -206
  1364. package/src/scripts/lint_commit_subjects.py +0 -139
  1365. package/src/scripts/lint_context_spine_usage.py +0 -137
  1366. package/src/scripts/lint_discovery_manifest.py +0 -176
  1367. package/src/scripts/lint_discovery_vocabulary.py +0 -222
  1368. package/src/scripts/lint_empty_roadmaps.py +0 -80
  1369. package/src/scripts/lint_examples.py +0 -102
  1370. package/src/scripts/lint_explain_trace.py +0 -80
  1371. package/src/scripts/lint_featured_skills.py +0 -144
  1372. package/src/scripts/lint_flows.py +0 -215
  1373. package/src/scripts/lint_framework_leakage.py +0 -375
  1374. package/src/scripts/lint_frontmatter_boilerplate.py +0 -77
  1375. package/src/scripts/lint_ghostwriter_source.py +0 -242
  1376. package/src/scripts/lint_global_paths.py +0 -148
  1377. package/src/scripts/lint_handoffs.py +0 -217
  1378. package/src/scripts/lint_hidden_unicode.py +0 -132
  1379. package/src/scripts/lint_hook_concern_budget.py +0 -207
  1380. package/src/scripts/lint_hook_manifest.py +0 -217
  1381. package/src/scripts/lint_instruction_smuggling.py +0 -107
  1382. package/src/scripts/lint_load_context.py +0 -196
  1383. package/src/scripts/lint_marketplace.py +0 -180
  1384. package/src/scripts/lint_marketplace_install_completeness.py +0 -198
  1385. package/src/scripts/lint_mcp_config_security.py +0 -124
  1386. package/src/scripts/lint_mcp_registry_manifest.py +0 -69
  1387. package/src/scripts/lint_media_policy_linkage.py +0 -140
  1388. package/src/scripts/lint_model_tier_coverage.py +0 -73
  1389. package/src/scripts/lint_namespace.py +0 -135
  1390. package/src/scripts/lint_namespace_collisions.py +0 -103
  1391. package/src/scripts/lint_new_skill_gate.py +0 -144
  1392. package/src/scripts/lint_no_new_atomic_commands.py +0 -180
  1393. package/src/scripts/lint_one_off_age.py +0 -184
  1394. package/src/scripts/lint_orchestration_dsl.py +0 -217
  1395. package/src/scripts/lint_orchestrator_auto_detect.py +0 -111
  1396. package/src/scripts/lint_pack_boundaries.py +0 -147
  1397. package/src/scripts/lint_pack_dependencies.py +0 -137
  1398. package/src/scripts/lint_pack_first_win.py +0 -121
  1399. package/src/scripts/lint_persona_governance.py +0 -164
  1400. package/src/scripts/lint_positioning.py +0 -143
  1401. package/src/scripts/lint_profile_overlay_set_only.py +0 -179
  1402. package/src/scripts/lint_readme_jargon.py +0 -131
  1403. package/src/scripts/lint_readme_size.py +0 -33
  1404. package/src/scripts/lint_regression.py +0 -251
  1405. package/src/scripts/lint_roadmap_ci_steps.py +0 -186
  1406. package/src/scripts/lint_roadmap_complexity.py +0 -220
  1407. package/src/scripts/lint_role_experiences.py +0 -255
  1408. package/src/scripts/lint_rule_interactions.py +0 -170
  1409. package/src/scripts/lint_rule_tiers.py +0 -90
  1410. package/src/scripts/lint_showcase_sessions.py +0 -148
  1411. package/src/scripts/lint_skill_frontmatter_safety.py +0 -144
  1412. package/src/scripts/lint_skill_tools.py +0 -168
  1413. package/src/scripts/lint_topics_yaml.py +0 -89
  1414. package/src/scripts/lint_trust_coherence.py +0 -212
  1415. package/src/scripts/lint_value_dashboard.py +0 -218
  1416. package/src/scripts/lint_workspace_boundary.py +0 -122
  1417. package/src/scripts/mcp_parity_smoke.py +0 -316
  1418. package/src/scripts/mcp_render.py +0 -173
  1419. package/src/scripts/mcp_server/__init__.py +0 -19
  1420. package/src/scripts/mcp_server/__main__.py +0 -12
  1421. package/src/scripts/mcp_server/catalog.py +0 -125
  1422. package/src/scripts/mcp_server/metadata.py +0 -75
  1423. package/src/scripts/mcp_server/prompts.py +0 -442
  1424. package/src/scripts/mcp_server/requirements.txt +0 -4
  1425. package/src/scripts/mcp_server/resources.py +0 -201
  1426. package/src/scripts/mcp_server/server.py +0 -270
  1427. package/src/scripts/mcp_server/telemetry.py +0 -128
  1428. package/src/scripts/mcp_server/tools.py +0 -926
  1429. package/src/scripts/mcp_telemetry_health.py +0 -214
  1430. package/src/scripts/mcp_telemetry_query.py +0 -203
  1431. package/src/scripts/mcp_telemetry_store.py +0 -211
  1432. package/src/scripts/measure_augment_budget.py +0 -214
  1433. package/src/scripts/measure_density.py +0 -232
  1434. package/src/scripts/measure_frugality_savings.py +0 -164
  1435. package/src/scripts/measure_markitdown_lift.py +0 -127
  1436. package/src/scripts/measure_patterns.py +0 -376
  1437. package/src/scripts/measure_projection_bytes.py +0 -159
  1438. package/src/scripts/measure_rule_budget.py +0 -347
  1439. package/src/scripts/measure_skill_reduction.py +0 -102
  1440. package/src/scripts/memory_hash.py +0 -75
  1441. package/src/scripts/memory_lookup.py +0 -436
  1442. package/src/scripts/memory_report.py +0 -314
  1443. package/src/scripts/memory_signal.py +0 -165
  1444. package/src/scripts/memory_status.py +0 -76
  1445. package/src/scripts/migrate_command_suggestions.py +0 -151
  1446. package/src/scripts/migrate_frontmatter_defaults.py +0 -245
  1447. package/src/scripts/mine_session.py +0 -356
  1448. package/src/scripts/minimal_safe_diff_hook.py +0 -245
  1449. package/src/scripts/move_artefact.py +0 -143
  1450. package/src/scripts/new_skill.py +0 -148
  1451. package/src/scripts/onboarding_gate_hook.py +0 -142
  1452. package/src/scripts/pack_mcp_content.py +0 -293
  1453. package/src/scripts/plan_physical_move.py +0 -353
  1454. package/src/scripts/prediction-pool/poisson_sim.py +0 -167
  1455. package/src/scripts/prediction-pool/pool_winsim.py +0 -236
  1456. package/src/scripts/prediction-pool/score_ev.py +0 -188
  1457. package/src/scripts/print_required_checks.py +0 -196
  1458. package/src/scripts/probe_projection_fidelity.py +0 -202
  1459. package/src/scripts/probe_skill_registration.py +0 -413
  1460. package/src/scripts/profile_staleness_hook.py +0 -69
  1461. package/src/scripts/profile_use.py +0 -164
  1462. package/src/scripts/project_thin_rules.py +0 -168
  1463. package/src/scripts/propose_modules_config.py +0 -145
  1464. package/src/scripts/prototype_lint_contradictions.py +0 -150
  1465. package/src/scripts/prove_pack_extractable.py +0 -187
  1466. package/src/scripts/readme_linter.py +0 -589
  1467. package/src/scripts/redact_hook_capture.py +0 -148
  1468. package/src/scripts/refine_ticket_detect.py +0 -646
  1469. package/src/scripts/release.py +0 -1091
  1470. package/src/scripts/render_benchmark_md.py +0 -401
  1471. package/src/scripts/render_value_md.py +0 -347
  1472. package/src/scripts/requirements-evals.txt +0 -8
  1473. package/src/scripts/roadmap_progress_hook.py +0 -274
  1474. package/src/scripts/router_telemetry.py +0 -470
  1475. package/src/scripts/run_skill_evals.py +0 -185
  1476. package/src/scripts/runtime_dispatcher.py +0 -276
  1477. package/src/scripts/runtime_handler.py +0 -148
  1478. package/src/scripts/runtime_registry.py +0 -166
  1479. package/src/scripts/score_skill_selection.py +0 -198
  1480. package/src/scripts/security_audit_config.py +0 -153
  1481. package/src/scripts/setup_eval_venv.sh +0 -58
  1482. package/src/scripts/skill_collision_clusters.py +0 -162
  1483. package/src/scripts/skill_discovery.py +0 -254
  1484. package/src/scripts/skill_linter.py +0 -3694
  1485. package/src/scripts/skill_overlap.py +0 -204
  1486. package/src/scripts/skill_preview.py +0 -179
  1487. package/src/scripts/skill_tools/__init__.py +0 -22
  1488. package/src/scripts/skill_tools/audit_persona_coverage.py +0 -147
  1489. package/src/scripts/skill_tools/audit_user_type_coverage.py +0 -148
  1490. package/src/scripts/skill_tools/run_block_d_eval.py +0 -129
  1491. package/src/scripts/skill_tools/score_skill_relevance.py +0 -169
  1492. package/src/scripts/skill_tools/suggest_skill_for_task.py +0 -113
  1493. package/src/scripts/skill_trigger_eval.py +0 -682
  1494. package/src/scripts/skill_usage_collect.py +0 -191
  1495. package/src/scripts/skill_usage_report.py +0 -162
  1496. package/src/scripts/smoke_path_resolution.py +0 -93
  1497. package/src/scripts/smoke_quickstart.py +0 -144
  1498. package/src/scripts/snapshot_agent_outputs.py +0 -144
  1499. package/src/scripts/spotcheck_thin_root.py +0 -134
  1500. package/src/scripts/sync_agent_settings.py +0 -180
  1501. package/src/scripts/sync_github_metadata.py +0 -147
  1502. package/src/scripts/sync_gitignore.py +0 -291
  1503. package/src/scripts/sync_yaml_rt.py +0 -734
  1504. package/src/scripts/telegraph_stats.py +0 -119
  1505. package/src/scripts/tool_registry.py +0 -146
  1506. package/src/scripts/tools/__init__.py +0 -1
  1507. package/src/scripts/tools/adapter_errors.py +0 -63
  1508. package/src/scripts/tools/base_adapter.py +0 -91
  1509. package/src/scripts/tools/github_adapter.py +0 -128
  1510. package/src/scripts/tools/jira_adapter.py +0 -115
  1511. package/src/scripts/trigger_coverage.py +0 -129
  1512. package/src/scripts/update_counts.py +0 -199
  1513. package/src/scripts/update_prices.py +0 -125
  1514. package/src/scripts/validate_agent_settings.py +0 -124
  1515. package/src/scripts/validate_decision_engine.py +0 -136
  1516. package/src/scripts/validate_discovery_manifest.py +0 -94
  1517. package/src/scripts/validate_frontmatter.py +0 -647
  1518. package/src/scripts/validate_pack_yaml.py +0 -179
  1519. package/src/scripts/validate_safe_paths.py +0 -118
  1520. package/src/scripts/validate_telegraph_carveouts.py +0 -129
  1521. package/src/scripts/verify_before_complete_hook.py +0 -216
  1522. package/src/scripts/verify_physical_move.py +0 -185
  1523. package/src/scripts/wrapper_freshness_hook.py +0 -86
  1524. /package/dist/agent-src/skills/design-intelligence/data/{typography.csv → font-pairings-reference.csv} +0 -0
  1525. /package/src/scripts/{ai-video → media}/lib/fixtures/allin1/analysis.json +0 -0
  1526. /package/src/scripts/{ai-video → media}/lib/fixtures/comfyui/scene-0001.mp4 +0 -0
  1527. /package/src/scripts/{ai-video → media}/lib/fixtures/fal/scene-0001.mp4 +0 -0
  1528. /package/src/scripts/{ai-video → media}/lib/fixtures/gemini-veo/scene-0001.mp4 +0 -0
  1529. /package/src/scripts/{ai-video → media}/lib/fixtures/higgsfield/scene-0001.mp4 +0 -0
  1530. /package/src/scripts/{ai-video → media}/lib/fixtures/kling/scene-0001.mp4 +0 -0
  1531. /package/src/scripts/{ai-video → media}/lib/fixtures/musetalk/lipsync-0001.mp4 +0 -0
  1532. /package/src/scripts/{ai-video → media}/lib/fixtures/openai-images/scene-0001.png +0 -0
  1533. /package/src/scripts/{ai-video → media}/lib/fixtures/replicate/scene-0001.mp4 +0 -0
  1534. /package/src/scripts/{ai-video → media}/lib/fixtures/sora/scene-0001.mp4 +0 -0
  1535. /package/src/scripts/{ai-video → media}/lib/fixtures/syncso/lipsync-0001.mp4 +0 -0
  1536. /package/src/scripts/{ai-video → media}/lib/fixtures/whisperx/transcript.json +0 -0
  1537. /package/src/scripts/{ai-video → media}/lib/telemetry.sh +0 -0
@@ -1,3694 +0,0 @@
1
- #!/usr/bin/env python3
2
- """
3
- Minimal skill/rule linter for agent-config repositories.
4
-
5
- MVP checks:
6
- - Detect skill vs rule
7
- - Required skill sections
8
- - Basic rule validation
9
- - Vague validation detection
10
- - Output format presence
11
- - Gotchas / Do NOT presence
12
- - Single file, --all, --changed
13
- - Text and JSON output
14
-
15
- Exit codes:
16
- 0 = pass
17
- 1 = warnings only
18
- 2 = errors
19
- 3 = internal error
20
- """
21
-
22
- from __future__ import annotations
23
-
24
- import argparse
25
- import json
26
- import re
27
- import subprocess
28
- import sys
29
- from dataclasses import dataclass, asdict
30
- from pathlib import Path
31
- from typing import Iterable, List, Literal, Optional
32
-
33
- # Sibling module — stdlib-only frontmatter schema validator.
34
- sys.path.insert(0, str(Path(__file__).resolve().parent))
35
- from validate_frontmatter import ( # noqa: E402
36
- apply_schema_defaults,
37
- parse_frontmatter as parse_frontmatter_for_schema,
38
- load_schema,
39
- validate as validate_against_schema,
40
- )
41
- from _lib.agent_src import artefact_roots, resolve_logical # noqa: E402
42
-
43
- Severity = Literal["error", "warning", "info"]
44
- ArtifactType = Literal["skill", "rule", "command", "guideline", "persona", "user-type", "unknown"]
45
-
46
- REQUIRED_PERSONA_SECTIONS_CORE = [
47
- "Focus",
48
- "Mindset",
49
- "Unique Questions",
50
- "Output Expectations",
51
- "Anti-Patterns",
52
- ]
53
- REQUIRED_PERSONA_SECTIONS_SPECIALIST = REQUIRED_PERSONA_SECTIONS_CORE + [
54
- "Critical Rules",
55
- "Workflows",
56
- ]
57
- # Back-compat alias — used by tier-agnostic callers; defaults to the core spine.
58
- REQUIRED_PERSONA_SECTIONS = REQUIRED_PERSONA_SECTIONS_CORE
59
- VALID_PERSONA_TIERS = {"core", "specialist"}
60
- # Locked in docs/contracts/persona-schema.md § 4: core ≤ 120, specialist ≤ 100.
61
- PERSONA_LINE_BUDGETS = {"core": 120, "specialist": 100}
62
-
63
- # User-type spine — locked in docs/contracts/user-type-schema.md § 3.
64
- # Runtime end-user simulation lens (sister axis to personas — methodology vs
65
- # end-user). Single tier in v1 (no core/specialist split).
66
- REQUIRED_USERTYPE_SECTIONS = [
67
- "Focus",
68
- "Daily Workflow",
69
- "Vocabulary",
70
- "Operational Constraints",
71
- "Unique Questions",
72
- "Ticket Red Flags",
73
- "Anti-Patterns",
74
- ]
75
- USERTYPE_LINE_BUDGET = 120
76
- # Wing-scoped overrides — Wing-3 (GTM) and Wing-4 (Money/Strategy/Ops) carry
77
- # denser cognition (funnel × channel × lifecycle, or finance × org × strategy)
78
- # than Wing-1/2 specialists, so the line cap rises to keep the seven-section
79
- # spine intact without amputating workflows. Persona-schema.md § 4 wing matrix.
80
- VALID_PERSONA_WINGS = {1, 2, 3, 4}
81
- PERSONA_LINE_BUDGETS_BY_WING = {
82
- ("specialist", 3): 140,
83
- ("specialist", 4): 140,
84
- }
85
-
86
-
87
- REQUIRED_SKILL_SECTIONS = [
88
- "When to use",
89
- "Gotcha",
90
- "Procedure",
91
- "Output format",
92
- "Do NOT",
93
- ]
94
-
95
- # Aliases: linter accepts any of these as matching the required section
96
- SECTION_ALIASES = {
97
- "Gotcha": {"Gotcha", "Gotchas"},
98
- "Procedure": set(), # prefix-matched separately
99
- "Do NOT": {"Do NOT", "Do not", "Anti-patterns"},
100
- "Output format": {"Output format", "Output"},
101
- }
102
-
103
- RECOMMENDED_SKILL_SECTIONS: list[str] = []
104
-
105
- RULE_BAD_SIGNS = [
106
- "## Procedure",
107
- "## Output format",
108
- "## Gotchas",
109
- ]
110
-
111
- # --- Frugality charter validator (see road-to-token-frugality Phase 0.4) ---
112
- # Layer 1 = writer-cite check (every writer skill carries the section + link).
113
- # Layer 2 = charter index integrity (the four canonical rules referenced by
114
- # the charter resolve to real H2/H3 anchors in the rule files).
115
-
116
- FRUGALITY_WRITER_SKILLS = {
117
- "skill-writing", "rule-writing", "command-writing",
118
- "guideline-writing", "context-authoring", "agent-docs-writing",
119
- "conventional-commits-writing", "readme-writing",
120
- "readme-writing-package", "adr-create",
121
- "persona-writing", "roadmap-writing", "script-writing",
122
- }
123
- FRUGALITY_CHARTER_RELPATH = "contexts/communication/frugality-charter.md"
124
- FRUGALITY_CHARTER_INDEX_RULES = {
125
- "direct-answers.md": "iron-law-3",
126
- "user-interaction.md": "iron-law-1",
127
- "no-cheap-questions.md": "pre-send-self-check",
128
- "token-efficiency.md": "the-iron-laws",
129
- }
130
-
131
- VAGUE_VALIDATION_PATTERNS = [
132
- r"\bcheck if it works\b",
133
- r"\bverify it works\b",
134
- r"\btest manually\b",
135
- r"\bcheck manually\b",
136
- r"\bmake sure it works\b",
137
- ]
138
-
139
- TRIGGER_WARNING_PATTERNS = [
140
- r"\bgeneral helper\b",
141
- r"\blaravel skill\b",
142
- r"\bgeneral coding\b",
143
- r"\beverything about\b",
144
- ]
145
-
146
- ORDERED_STEP_PATTERN = re.compile(r"^(?:\s*|\#{1,4}\s*)(\d+)\.\s+", re.MULTILINE)
147
- SECTION_PATTERN = re.compile(r"^##\s+(.+?)\s*$", re.MULTILINE)
148
- FRONTMATTER_PATTERN = re.compile(r"^---\n(.*?)\n---\n", re.DOTALL)
149
- DESCRIPTION_PATTERN = re.compile(r'^description:\s*"?(.*?)"?\s*$', re.MULTILINE)
150
- TYPE_PATTERN = re.compile(r'^type:\s*"?(always|auto|manual)"?\s*$', re.MULTILINE)
151
- SOURCE_PATTERN = re.compile(r'^source:\s*"?(package|project)"?\s*$', re.MULTILINE)
152
- STATUS_PATTERN = re.compile(r'^status:\s*"?(active|deprecated|superseded)"?\s*$', re.MULTILINE)
153
- REPLACED_BY_PATTERN = re.compile(r'^replaced_by:\s*"?([\w-]+)"?\s*$', re.MULTILINE)
154
- TIER_PATTERN = re.compile(r'^tier:\s*"?([\w-]+)"?\s*$', re.MULTILINE)
155
-
156
- # --- Senior-tier required-block patterns (skill-quality.md § Senior-Tier Required Structure) ---
157
- # Heading-only checks; detail-shape lives in skill-quality-mechanics.md.
158
- SENIOR_RELATED_SKILLS_PATTERN = re.compile(r"^##\s+Related Skills\s*$", re.MULTILINE)
159
- SENIOR_RELATED_WHEN_PATTERN = re.compile(r"\*\*WHEN to use this\*\*", re.IGNORECASE)
160
- SENIOR_RELATED_WHEN_NOT_PATTERN = re.compile(r"\*\*WHEN NOT to use this\*\*", re.IGNORECASE)
161
- SENIOR_PROACTIVE_PATTERN = re.compile(
162
- r"^##\s+When the agent should load this\s*$", re.MULTILINE
163
- )
164
- SENIOR_OUTPUT_PATTERN = re.compile(r"^##\s+Output\s*$", re.MULTILINE)
165
- H1_PATTERN = re.compile(r"^# .+", re.MULTILINE)
166
- DOUBLE_BLANK_PATTERN = re.compile(r"\n{3,}")
167
-
168
- VALID_RULE_TYPES = {"always", "auto", "manual"}
169
- VALID_RULE_SOURCES = {"package", "project"}
170
- VALID_STATUSES = {"active", "deprecated", "superseded"}
171
-
172
- # --- Router schema (docs/contracts/rule-router.md) ---
173
- ROUTER_ALLOWED_TRIGGER_KEYS = {"keyword", "phrase", "intent", "file_pattern",
174
- "path_prefix", "command"}
175
- ROUTER_ALLOWED_PROFILES = {"minimal", "balanced", "full"}
176
- KERNEL_RULE_IDS: set[str] = {
177
- "agent-authority", "ask-when-uncertain", "commit-policy",
178
- "direct-answers", "language-and-tone", "no-cheap-questions",
179
- "non-destructive-by-default", "scope-control",
180
- "verify-before-complete",
181
- }
182
-
183
- # --- Runtime execution metadata constants ---
184
- VALID_EXECUTION_TYPES = {"manual", "assisted", "automated"}
185
- VALID_EXECUTION_HANDLERS = {"none", "shell", "php", "node", "internal"}
186
- VALID_EXECUTION_SAFETY_MODES = {"strict"}
187
- VALID_EXECUTION_FIELDS = {"type", "handler", "timeout_seconds", "safety_mode", "allowed_tools", "command"}
188
-
189
- # --- Wing-3 GTM cognition-boundary patterns (council Q7 / iter-2 OQ3) ---
190
- # Triggered only when a skill's context_spine declares a Wing-3 slot.
191
- # See docs/contracts/adr-gtm-context-spine.md and
192
- # agents/roadmaps/road-to-gtm-and-growth.md § G2.
193
- WING3_SPINE_SLOTS = {"channel-stage", "funnel-stage", "customer-segment"}
194
-
195
- CONTEXT_SPINE_INLINE_PATTERN = re.compile(
196
- r'^context_spine:\s*\[(.*?)\]\s*$', re.MULTILINE
197
- )
198
-
199
- # agent-operability: external SaaS URLs the agent would have to auth against
200
- WING3_SAAS_URL_PATTERN = re.compile(
201
- r"https?://[\w.-]*\.(salesforce|hubspot|marketo|pardot|mailchimp|"
202
- r"intercom|amplitude|mixpanel|segment|klaviyo|sendgrid|mailgun|"
203
- r"pendo|gong|outreach|salesloft|apollo)\.(com|io)\b",
204
- re.IGNORECASE,
205
- )
206
-
207
- # vendor-independence: brand / SDK / platform slugs that lock cognition
208
- WING3_VENDOR_BLACKLIST = re.compile(
209
- r"\b(salesforce|hubspot|marketo|pardot|mailchimp|intercom|drift|"
210
- r"klaviyo|sendgrid|mailgun|amplitude|mixpanel|pendo|gong|"
211
- r"outreach\.io|salesloft|apollo\.io|zendesk|freshworks)\b",
212
- re.IGNORECASE,
213
- )
214
-
215
- # transferability: stack-locked tooling instructions
216
- WING3_STACK_LOCKED_PATTERN = re.compile(
217
- r"\b(npm install|pip install|composer require|gem install|"
218
- r"cargo add|yarn add|pnpm add|bundle add)\s+[\w@/.-]+",
219
- re.IGNORECASE,
220
- )
221
-
222
- # channel-agnosticism: channel-specific tactical prescriptions
223
- WING3_CHANNEL_TACTIC_PATTERN = re.compile(
224
- r"\b(email subject line|tweet length|linkedin (post|ad)|"
225
- r"facebook ad|google ads?|tiktok (post|video)|instagram (post|reel)|"
226
- r"sms character limit|cold email template)\b",
227
- re.IGNORECASE,
228
- )
229
-
230
- # --- Wing-4 Money/Strategy/Ops cognition-boundary patterns (council Q7 / J2) ---
231
- # Triggered only when a skill's context_spine declares a Wing-4 slot.
232
- # See docs/contracts/adr-wing4-context-spine.md and
233
- # agents/roadmaps/road-to-money-strategy-ops.md § J2.
234
- WING4_SPINE_SLOTS = {"fiscal-period", "org-stage", "regulatory-regime"}
235
-
236
- # agent-operability: external finance / HR / legal SaaS URLs
237
- WING4_SAAS_URL_PATTERN = re.compile(
238
- r"https?://[\w.-]*\.(quickbooks|intuit|netsuite|xero|sage|"
239
- r"carta|pulley|gusto|bamboohr|lattice|15five|justworks|"
240
- r"docusign|ironclad|onetrust|rippling|workday|deel|"
241
- r"namely|adp|paychex|trinet|hibob|cultureamp)\.(com|io|co)\b",
242
- re.IGNORECASE,
243
- )
244
-
245
- # vendor-independence: finance / HR / legal brand / SDK slugs
246
- WING4_VENDOR_BLACKLIST = re.compile(
247
- r"\b(quickbooks|netsuite|xero|sage intacct|"
248
- r"carta|pulley|gusto|bamboohr|lattice|15five|justworks|"
249
- r"docusign|ironclad|onetrust|rippling|workday|deel|"
250
- r"namely|adp|paychex|trinet|hibob|culture amp)\b",
251
- re.IGNORECASE,
252
- )
253
-
254
- # stage-agnosticism: prescriptive stage-specific thresholds that lock cognition
255
- # Catches hardcoded runway / ARR / burn / team-size prescriptions tied to a
256
- # specific funding stage. Framework-style framing ("read the org-stage slot",
257
- # "applies across seed and public") passes; hard prescriptions ("18 months of
258
- # runway", "Series A teams must hire") fire.
259
- WING4_STAGE_AGNOSTIC_PATTERN = re.compile(
260
- r"(?:"
261
- r"\b\d+\s+months?\s+of\s+runway\b"
262
- r"|\brunway\s+of\s+at\s+least\s+\d+\s+months?\b"
263
- r"|\bminimum\s+runway\s+of\s+\d+\b"
264
- r"|\b(?:seed|series\s+[a-d]|growth|pre-?ipo|post-?ipo)[-\s]stage\s+"
265
- r"(?:companies|startups|teams|founders|orgs)\s+(?:must|should|always|never)\b"
266
- r"|\bteam\s+of\s+\d+\s+(?:or\s+more|or\s+fewer)\b"
267
- r"|\b(?:arr|mrr|burn\s+rate)\s+(?:of|over|under|above|below)\s+\$\d+"
268
- r")",
269
- re.IGNORECASE,
270
- )
271
-
272
-
273
- @dataclass
274
- class Issue:
275
- severity: Severity
276
- code: str
277
- message: str
278
-
279
-
280
- @dataclass
281
- class LintResult:
282
- file: str
283
- artifact_type: ArtifactType
284
- status: Literal["pass", "pass_with_warnings", "fail"]
285
- issues: List[Issue]
286
- suggestions: List[str]
287
-
288
-
289
- def read_text(path: Path) -> str:
290
- return path.read_text(encoding="utf-8")
291
-
292
-
293
- # --- Role-contract anchor cache (see road-to-role-modes Phase 1) ---
294
- # Populated lazily so the linter stays fast when the guideline is absent.
295
- _ROLE_CONTRACT_CANDIDATES = (
296
- Path("docs/guidelines/agent-infra/role-contracts.md"),
297
- )
298
- _ROLE_CONTRACT_SLUGS_CACHE: Optional[set[str]] = None
299
-
300
-
301
- def _load_role_contract_slugs() -> set[str]:
302
- """Return the set of H3 mode slugs defined in role-contracts.md.
303
-
304
- Empty set if the guideline cannot be found — callers MUST treat an
305
- empty cache as "no data" and skip the check rather than flagging
306
- every reference as broken.
307
- """
308
- global _ROLE_CONTRACT_SLUGS_CACHE
309
- if _ROLE_CONTRACT_SLUGS_CACHE is not None:
310
- return _ROLE_CONTRACT_SLUGS_CACHE
311
- slugs: set[str] = set()
312
- for candidate in _ROLE_CONTRACT_CANDIDATES:
313
- if not candidate.exists():
314
- continue
315
- try:
316
- text = candidate.read_text(encoding="utf-8")
317
- except OSError:
318
- continue
319
- in_skeletons = False
320
- for line in text.splitlines():
321
- if line.startswith("## "):
322
- in_skeletons = line.strip().lower().startswith(
323
- "## contract skeletons"
324
- )
325
- continue
326
- if in_skeletons and line.startswith("### "):
327
- name = line[4:].strip().lower()
328
- slugs.add(re.sub(r"[^a-z0-9]+", "-", name).strip("-"))
329
- if slugs:
330
- break
331
- _ROLE_CONTRACT_SLUGS_CACHE = slugs
332
- return slugs
333
-
334
-
335
- _ROLE_CONTRACT_REF_PATTERN = re.compile(
336
- r"role-contracts\.md#([a-z0-9][a-z0-9-]*)", re.IGNORECASE
337
- )
338
-
339
-
340
- def lint_role_contract_refs(text: str) -> List[Issue]:
341
- """Warn if a file references `role-contracts.md#<slug>` for a mode
342
- that does not exist as an H3 heading in the guideline. No-op when
343
- the guideline is missing or declares no modes (bootstrap safety).
344
- """
345
- slugs = _load_role_contract_slugs()
346
- if not slugs:
347
- return []
348
- issues: List[Issue] = []
349
- seen: set[str] = set()
350
- for match in _ROLE_CONTRACT_REF_PATTERN.finditer(text):
351
- slug = match.group(1).lower()
352
- if slug in seen:
353
- continue
354
- seen.add(slug)
355
- if slug not in slugs:
356
- issues.append(Issue(
357
- "warning", "unknown_role_contract",
358
- f"References role-contracts.md#{slug} but no such "
359
- f"mode is defined in the guideline (known: "
360
- f"{', '.join(sorted(slugs))})",
361
- ))
362
- return issues
363
-
364
-
365
- def extract_sections(text: str) -> set[str]:
366
- return {match.group(1).strip() for match in SECTION_PATTERN.finditer(text)}
367
-
368
-
369
- def _count_code_blocks(text: str) -> int:
370
- """Return the number of fenced code blocks (``` … ```) in *text*."""
371
- fence_count = 0
372
- for line in text.splitlines():
373
- stripped = line.lstrip()
374
- if stripped.startswith("```"):
375
- fence_count += 1
376
- return fence_count // 2
377
-
378
-
379
- def _fenced_content_ratio(text: str) -> float:
380
- """Return the fraction of non-empty lines that sit inside fenced blocks.
381
-
382
- Retained as a helper for backwards compatibility; the size gates use
383
- :func:`_density_score` from the structural model instead (Phase 3 of
384
- road-to-structural-linter-reform).
385
- """
386
- inside = False
387
- fenced_lines = 0
388
- non_empty = 0
389
- for line in text.splitlines():
390
- stripped = line.strip()
391
- if stripped.startswith("```"):
392
- inside = not inside
393
- if stripped:
394
- non_empty += 1
395
- continue
396
- if stripped:
397
- non_empty += 1
398
- if inside:
399
- fenced_lines += 1
400
- if non_empty == 0:
401
- return 0.0
402
- return fenced_lines / non_empty
403
-
404
-
405
- # --- Structural-density model (docs/contracts/linter-structural-model.md) ---
406
- # Replaces the raw line/word/fenced-ratio gates with four primitives that
407
- # distinguish complexity from bloat. Calibrated 2026-05-08 against the full
408
- # 310-artefact corpus (agents/runtime/density/snapshot.jsonl).
409
-
410
- PROCEDURE_HEADING_PATTERN = re.compile(
411
- r"^##\s+Procedure(\s*[:\u2014\-].*)?\s*$", re.MULTILINE
412
- )
413
- COMMAND_FRONTMATTER_DELEGATION_KEYS = ("cluster:", "routes_to:")
414
- MD_LINK_PATTERN = re.compile(r"\[[^\]]+\]\(([^)]+\.md[^)]*)\)")
415
-
416
-
417
- def _density_score(text: str) -> float:
418
- """Return structural density 0.0–1.0 — see docs/contracts/linter-structural-model.md.
419
-
420
- density = structured_lines / non_blank_lines, where structured_lines =
421
- fenced + table + bullet + numbered + heading. Higher = more structured
422
- (catalogue, table, code, list); lower = prose-dominant.
423
- """
424
- inside_fence = False
425
- structured = 0
426
- non_blank = 0
427
- for raw in text.splitlines():
428
- stripped = raw.strip()
429
- if not stripped:
430
- continue
431
- non_blank += 1
432
- if stripped.startswith("```"):
433
- inside_fence = not inside_fence
434
- structured += 1
435
- continue
436
- if inside_fence:
437
- structured += 1
438
- continue
439
- if stripped.startswith("#"):
440
- structured += 1
441
- continue
442
- if stripped.startswith("|") and stripped.endswith("|"):
443
- structured += 1
444
- continue
445
- if stripped.startswith(("- ", "* ", "+ ")):
446
- structured += 1
447
- continue
448
- if re.match(r"^\d+\.\s", stripped):
449
- structured += 1
450
- continue
451
- if non_blank == 0:
452
- return 0.0
453
- return round(structured / non_blank, 3)
454
-
455
-
456
- def _count_procedure_sections(text: str) -> int:
457
- """Count `## Procedure` (or `## Procedure: <name>`) blocks in *text*."""
458
- return len(PROCEDURE_HEADING_PATTERN.findall(text))
459
-
460
-
461
- def _command_delegation_signal(text: str, frontmatter: Optional[str]) -> bool:
462
- """Return True when a command has a delegation signal.
463
-
464
- Signals: frontmatter declares ``cluster:`` or ``routes_to:`` — OR — the
465
- body contains ≥ 3 markdown links to other ``.md`` files. Either signal
466
- is sufficient (council review 2026-05-08).
467
- """
468
- if frontmatter:
469
- for key in COMMAND_FRONTMATTER_DELEGATION_KEYS:
470
- if re.search(rf"^{re.escape(key)}", frontmatter, re.MULTILINE):
471
- return True
472
- if len(MD_LINK_PATTERN.findall(text)) >= 3:
473
- return True
474
- return False
475
-
476
-
477
- def _strip_markdown_for_check(text: str) -> str:
478
- """Strip fenced code, inline code spans, and markdown links so heuristic
479
- regex matches operate on prose only.
480
-
481
- Used by rule-body heuristics whose targets (e.g. ``procedural_rule``)
482
- must not flip on legitimate skill pointers like ``[git-workflow](…)``
483
- or ``` `skill:symfony-workflow` ```. Frontmatter is handled by the
484
- caller via ``text.split("---", 2)[-1]``.
485
- """
486
- text = re.sub(r"```[^\n]*\n.*?```", "", text, flags=re.DOTALL)
487
- text = re.sub(r"`[^`\n]+`", "", text)
488
- text = re.sub(r"\[[^\]]*\]\([^)]*\)", "", text)
489
- return text
490
-
491
-
492
- def _iron_law_blocks(text: str) -> int:
493
- """Count fenced blocks that look like verbatim Iron-Law imperatives.
494
-
495
- Heuristic: fenced block whose body has ≥ 30 alphabetical chars and
496
- ≥ 60 % uppercase across ≥ 1 non-empty line. The 30-char floor filters
497
- short ALL-CAPS markers (``OK``, ``WIP``); the 60 %-uppercase floor
498
- catches verbatim imperatives (``NEVER COMMIT.``).
499
- """
500
- blocks = 0
501
- inside = False
502
- body: list[str] = []
503
- for raw in text.splitlines():
504
- if raw.strip().startswith("```"):
505
- if inside and body:
506
- non_empty = [b for b in body if b.strip()]
507
- letters = "".join(non_empty)
508
- upper = sum(1 for c in letters if c.isalpha() and c.isupper())
509
- total = sum(1 for c in letters if c.isalpha())
510
- if total >= 30 and upper / total >= 0.6 and non_empty:
511
- blocks += 1
512
- inside = not inside
513
- body = []
514
- continue
515
- if inside:
516
- body.append(raw)
517
- return blocks
518
-
519
-
520
- def extract_description(text: str) -> Optional[str]:
521
- frontmatter = FRONTMATTER_PATTERN.search(text)
522
- if not frontmatter:
523
- return None
524
- description = DESCRIPTION_PATTERN.search(frontmatter.group(1))
525
- return description.group(1).strip() if description else None
526
-
527
-
528
- NAME_PATTERN = re.compile(r'^name:\s*"?(.*?)"?\s*$', re.MULTILINE)
529
- DISABLE_MODEL_PATTERN = re.compile(r'^disable-model-invocation:\s*"?(true|false)"?\s*$', re.MULTILINE)
530
-
531
-
532
- def detect_artifact_type(path: Path, text: str) -> ArtifactType:
533
- path_str = str(path).lower()
534
- has_skill_heading = "## When to use" in text and "## Procedure" in text
535
-
536
- # A file inside a /commands/ tree is a command — the commands tree wins,
537
- # even for a cluster head literally named `skill.md` or a sub-command under
538
- # a `skills/` cluster dir (e.g. /commands/skills/discover.md). The only
539
- # /commands/ file that is NOT a command is a nested skill body, which is
540
- # always `SKILL.md` (case-sensitive — command files are lowercase).
541
- if "/commands/" in path_str and path.name != "SKILL.md":
542
- return "command"
543
- # Skills: a SKILL.md body, or anything under a /skills/ tree.
544
- if path.name.lower() == "skill.md" or "/skills/" in path_str:
545
- return "skill"
546
- if "/rules/" in path_str:
547
- return "rule"
548
- if "/guidelines/" in path_str:
549
- return "guideline"
550
- if "/personas/" in path_str:
551
- return "persona"
552
- if "/user-types/" in path_str:
553
- return "user-type"
554
- if has_skill_heading:
555
- return "skill"
556
- return "unknown"
557
-
558
-
559
- def classify_status(issues: List[Issue]) -> Literal["pass", "pass_with_warnings", "fail"]:
560
- severities = {issue.severity for issue in issues}
561
- if "error" in severities:
562
- return "fail"
563
- if "warning" in severities:
564
- return "pass_with_warnings"
565
- return "pass"
566
-
567
-
568
-
569
- def extract_section_block(text: str, section_name: str) -> str:
570
- pattern = re.compile(
571
- rf"^##\s+{re.escape(section_name)}\s*$" r"(.*?)(?=^##\s+|\Z)",
572
- re.MULTILINE | re.DOTALL,
573
- )
574
- match = pattern.search(text)
575
- return match.group(1).strip() if match else ""
576
-
577
-
578
- def parse_ordered_list_items(text: str) -> list[str]:
579
- return [line.strip() for line in text.splitlines() if re.match(r"^\s*\d+\.\s+", line)]
580
-
581
-
582
- def count_bullets(text: str) -> int:
583
- return sum(1 for line in text.splitlines() if re.match(r"^\s*[*-]\s+", line))
584
-
585
-
586
- def has_validation_step(procedure_block: str) -> bool:
587
- lowered = procedure_block.lower()
588
- if "validate" in lowered or "validation" in lowered:
589
- return True
590
- good_signals = [
591
- "expected", "status code", "no errors", "appears in", "exact check", "concrete checks",
592
- "verify", "confirm", "must pass", "must fail", "assert", "check that", "ensure",
593
- "run test", "run phpstan", "run ecs", "run rector", "lint", "passes",
594
- "exit code", "should return", "should contain", "must contain", "must return",
595
- ]
596
- return any(signal in lowered for signal in good_signals)
597
-
598
-
599
- _INSPECT_VERB_PATTERN = re.compile(
600
- r"\b(?:"
601
- # Direct inspection
602
- r"inspect|examine|audit|survey"
603
- # Read / look
604
- r"|read|look\s+at"
605
- # Check (word-boundary — matches "check that", "check current", "check what")
606
- r"|check"
607
- # Review (broad — matches "review existing", "review the failures")
608
- r"|review"
609
- # Comprehension / orientation
610
- r"|understand|identify|analyze|analyse"
611
- # Discovery
612
- r"|detect|gather|discover"
613
- r")\b",
614
- re.IGNORECASE,
615
- )
616
-
617
-
618
- def has_inspect_step(procedure_block: str) -> bool:
619
- """Return True if the procedure block opens with an inspect / read step.
620
-
621
- Corpus-driven verb list (see docs/contracts/linter-structural-model.md):
622
- the first ordered step in a skill procedure should orient the agent in
623
- the live system — read existing code, examine current state, detect
624
- stack — before mutating anything. Regex uses word boundaries to avoid
625
- substring matches inside unrelated words (e.g. ``read`` inside
626
- ``already``).
627
- """
628
- return bool(_INSPECT_VERB_PATTERN.search(procedure_block))
629
-
630
-
631
- def find_vague_validation(text: str) -> list[str]:
632
- hits: list[str] = []
633
- for pattern in VAGUE_VALIDATION_PATTERNS:
634
- for match in re.finditer(pattern, text, re.IGNORECASE):
635
- hits.append(match.group(0))
636
- return hits
637
-
638
-
639
- def is_probably_too_broad(text: str, description: Optional[str]) -> bool:
640
- # Only check description and "When to use" for broad signals — not the entire text
641
- haystacks: list[str] = []
642
- if description:
643
- haystacks.append(description.lower())
644
- when_block = extract_section_block(text, "When to use")
645
- if when_block:
646
- haystacks.append(when_block.lower())
647
- if not haystacks:
648
- return False
649
- combined = "\n".join(haystacks)
650
- broad_signals = ["everything about", "general purpose", "general-purpose", "all markdown", "helper for everything"]
651
- return any(signal in combined for signal in broad_signals)
652
-
653
-
654
- def dedupe_preserve_order(items: Iterable[str]) -> list[str]:
655
- seen: set[str] = set()
656
- result: list[str] = []
657
- for item in items:
658
- if item not in seen:
659
- seen.add(item)
660
- result.append(item)
661
- return result
662
-
663
-
664
- def section_matches(required: str, sections: set[str]) -> bool:
665
- """Check if a required section name matches any extracted section, supporting aliases and prefix matching."""
666
- # Direct match
667
- if required in sections:
668
- return True
669
- # Alias match (e.g. "Gotcha" matches "Gotchas")
670
- aliases = SECTION_ALIASES.get(required, set())
671
- if aliases & sections:
672
- return True
673
- # Prefix match (e.g. "Procedure" matches "Procedure: Create X")
674
- for s in sections:
675
- if s.startswith(required + ":") or s.startswith(required + " "):
676
- return True
677
- return False
678
-
679
-
680
- def find_procedure_block(text: str) -> Optional[str]:
681
- """Find the procedure section block, supporting prefix-named variants."""
682
- block = extract_section_block(text, "Procedure")
683
- if block:
684
- return block
685
- # Try prefix match: find "## Procedure: ..." or "## Procedure " headings
686
- match = re.search(r"^##\s+Procedure[:\s]", text, re.MULTILINE)
687
- if match:
688
- # Extract from this heading to the next ## heading
689
- start = match.end()
690
- next_heading = re.search(r"^##\s+", text[start:], re.MULTILINE)
691
- if next_heading:
692
- return text[start:start + next_heading.start()].strip()
693
- return text[start:].strip()
694
- return None
695
-
696
-
697
- def lint_skill(path: Path, text: str) -> LintResult:
698
- issues: List[Issue] = []
699
- suggestions: List[str] = []
700
-
701
- sections = extract_sections(text)
702
- description = extract_description(text)
703
-
704
- for section in REQUIRED_SKILL_SECTIONS:
705
- if not section_matches(section, sections):
706
- issues.append(Issue("error", "missing_section", f"Missing required section: {section}"))
707
-
708
- for section in RECOMMENDED_SKILL_SECTIONS:
709
- if not section_matches(section, sections):
710
- issues.append(Issue("warning", "missing_recommended_section", f"Missing recommended section: {section}"))
711
-
712
- if description:
713
- if len(description) > 200:
714
- issues.append(Issue("error", "description_too_long",
715
- f"Description is {len(description)} chars (hard cap: 200) — see road-to-governance-cleanup F6"))
716
- for pattern in TRIGGER_WARNING_PATTERNS:
717
- if re.search(pattern, description, re.IGNORECASE):
718
- issues.append(Issue("warning", "weak_trigger", f"Description looks too generic: {description}"))
719
- break
720
- else:
721
- issues.append(Issue("warning", "missing_description", "Frontmatter description is missing or unreadable"))
722
-
723
- # --- Bare-noun name check ---
724
- skill_name = path.parent.name if path.name == "SKILL.md" else path.stem
725
- if skill_name and "-" not in skill_name and len(skill_name) >= 3:
726
- # Single word without qualifier — likely too generic
727
- ALLOWED_BARE_NOUNS = {"database", "devcontainer", "docker", "eloquent", "flux", "forecasting",
728
- "grafana", "laravel", "livewire", "markitdown", "mcp", "openapi",
729
- "performance", "security", "terraform", "terragrunt", "traefik",
730
- "websocket"}
731
- if skill_name.lower() not in ALLOWED_BARE_NOUNS:
732
- issues.append(Issue("warning", "bare_noun_name",
733
- f"Bare-noun skill name `{skill_name}` — consider adding a qualifier (e.g., `{skill_name}-management`)"))
734
-
735
- # --- Status lifecycle check ---
736
- frontmatter = extract_frontmatter(text)
737
- if frontmatter:
738
- status_match = STATUS_PATTERN.search(frontmatter)
739
- if status_match:
740
- status = status_match.group(1)
741
- if status == "deprecated":
742
- replaced_by = extract_frontmatter_field(frontmatter, REPLACED_BY_PATTERN)
743
- msg = f"Skill is deprecated"
744
- if replaced_by:
745
- msg += f" (replaced by: {replaced_by})"
746
- issues.append(Issue("warning", "deprecated_skill", msg))
747
- elif status == "superseded":
748
- replaced_by = extract_frontmatter_field(frontmatter, REPLACED_BY_PATTERN)
749
- msg = f"Skill is superseded — should be removed"
750
- if replaced_by:
751
- msg += f" (replaced by: {replaced_by})"
752
- issues.append(Issue("warning", "superseded_skill", msg))
753
-
754
- # --- Execution metadata check ---
755
- execution = parse_execution_block(frontmatter)
756
- if execution is not None:
757
- issues.extend(lint_execution_metadata(execution))
758
-
759
- # --- Senior-tier required-block check (skill-quality.md § Senior-Tier Required Structure) ---
760
- tier_match = TIER_PATTERN.search(frontmatter)
761
- if tier_match and tier_match.group(1) == "senior":
762
- issues.extend(lint_senior_tier_blocks(text))
763
-
764
- # --- Wing-3 GTM cognition-boundary check (council Q7 / adr-gtm-context-spine.md) ---
765
- spine_slots = parse_context_spine(frontmatter)
766
- if spine_slots and any(s in WING3_SPINE_SLOTS for s in spine_slots):
767
- issues.extend(lint_wing3_boundaries(text))
768
-
769
- # --- Wing-4 Money/Strategy/Ops cognition-boundary check (council Q7 / J2) ---
770
- if spine_slots and any(s in WING4_SPINE_SLOTS for s in spine_slots):
771
- issues.extend(lint_wing4_boundaries(text))
772
-
773
- procedure_block = find_procedure_block(text)
774
- if procedure_block is not None:
775
- if not procedure_block:
776
- issues.append(Issue("error", "empty_procedure", "Procedure section is empty"))
777
- else:
778
- # Check for ordered steps OR sub-headings as structural indicators
779
- has_ordered = ORDERED_STEP_PATTERN.search(procedure_block)
780
- has_subheadings = bool(re.search(r"^###\s+", procedure_block, re.MULTILINE))
781
- if not has_ordered and not has_subheadings:
782
- issues.append(Issue("error", "unordered_procedure", "Procedure has no ordered steps or sub-headings"))
783
- meaningful_steps = len(ORDERED_STEP_PATTERN.findall(procedure_block))
784
- if meaningful_steps < 3:
785
- issues.append(Issue("warning", "short_procedure", "Procedure has fewer than 3 ordered steps"))
786
- # Check validation in procedure block OR in the full skill text
787
- # (some skills have ### Validate under a sibling ## section)
788
- if not has_validation_step(procedure_block) and not has_validation_step(text):
789
- issues.append(Issue("error", "missing_validation", "Skill lacks a concrete validation step"))
790
- vague_hits = find_vague_validation(procedure_block)
791
- for hit in vague_hits:
792
- issues.append(Issue("error", "vague_validation", f"Vague validation detected: {hit}"))
793
- if not has_inspect_step(procedure_block):
794
- issues.append(Issue("warning", "missing_inspect_step", "Procedure has no explicit inspect/check step"))
795
-
796
- if "## Output format" in text:
797
- output_block = extract_section_block(text, "Output format")
798
- if not output_block or len(parse_ordered_list_items(output_block)) < 2:
799
- issues.append(Issue("warning", "weak_output_format", "Output format should contain at least 2 ordered requirements"))
800
- suggestions.append("Add 2-4 ordered output requirements")
801
- else:
802
- suggestions.append("Add an Output format section with ordered response constraints")
803
-
804
- # Check Gotcha/Gotchas section (alias support)
805
- gotcha_block = extract_section_block(text, "Gotchas") or extract_section_block(text, "Gotcha")
806
- if gotcha_block:
807
- if count_bullets(gotcha_block) < 1:
808
- issues.append(Issue("warning", "weak_gotchas", "Gotchas should contain at least one realistic failure mode"))
809
- else:
810
- suggestions.append("Add at least one realistic failure pattern to Gotchas")
811
-
812
- if "## Do NOT" in text:
813
- do_not_block = extract_section_block(text, "Do NOT")
814
- if count_bullets(do_not_block) < 1:
815
- issues.append(Issue("warning", "weak_do_not", "Do NOT should contain at least one enforceable constraint"))
816
- else:
817
- suggestions.append("Add at least one enforceable Do NOT constraint")
818
-
819
- if is_probably_too_broad(text, description):
820
- issues.append(Issue("warning", "broad_scope", "Skill scope appears broad and may need splitting"))
821
- suggestions.append("Narrow the trigger or split unrelated workflows")
822
-
823
- # --- Developer judgment check for assisted skills ---
824
- fm = extract_frontmatter(text)
825
- exec_block = parse_execution_block(fm) if fm else None
826
- exec_type = exec_block.get("type", "") if exec_block else ""
827
- if exec_type == "assisted" and procedure_block:
828
- validation_terms = ["validat", "check", "verify", "confirm", "challenge",
829
- "existing", "duplicate", "contradict", "fit", "misfit"]
830
- has_validation = any(term in procedure_block.lower() for term in validation_terms)
831
- if not has_validation:
832
- issues.append(Issue("warning", "missing_validation_step",
833
- "Assisted skill has no validation/challenge step in procedure"))
834
- suggestions.append("Add a requirement-checking or validation step before implementation")
835
-
836
- # --- Size check (docs/contracts/linter-structural-model.md) ---
837
- # Structural-density gate replaces raw line count (Phase 3 of
838
- # road-to-structural-linter-reform, 2026-05-08): warn only when the skill
839
- # is *both* large AND prose-dominant OR ships ≥ 2 independently invocable
840
- # procedures. Reference catalogues (quality-tools 411 L / density 0.83)
841
- # pass; multi-procedure skills are flagged for split.
842
- #
843
- # Frontmatter opt-out: `meta_skill: true` exempts a skill from the size
844
- # warn when the skill's purpose *is* breadth (skill-writing, agent-docs-
845
- # writing, skill-reviewer, etc.). Meta-skills inherently bundle multiple
846
- # procedures and inline examples.
847
- total_lines = len(text.splitlines())
848
- is_meta_skill = bool(fm) and re.search(r"^meta_skill:\s*true\s*$", fm, re.MULTILINE)
849
- if total_lines > 400 and not is_meta_skill:
850
- density = _density_score(text)
851
- procedures = _count_procedure_sections(text)
852
- if density < 0.6 or procedures >= 2:
853
- reason = (
854
- f"density {density:.2f} < 0.60"
855
- if density < 0.6
856
- else f"{procedures} ## Procedure blocks (≥ 2)"
857
- )
858
- issues.append(Issue(
859
- "warning",
860
- "skill_too_large",
861
- f"Skill has {total_lines} lines and {reason}; review for split "
862
- f"(see linter-structural-model contract)",
863
- ))
864
-
865
- # --- Pointer-only / guideline-dependent skill detection ---
866
- if procedure_block:
867
- proc_lines = [line.strip() for line in procedure_block.splitlines() if line.strip()]
868
-
869
- # Delegation patterns: references to external docs instead of own workflow
870
- delegation_patterns = re.findall(
871
- r"(?:see|read|check|follow|refer\s+to|consult|per|apply\s+.*from)\s+.*"
872
- r"(?:guideline|skill|rule|doc|documentation)",
873
- procedure_block, re.IGNORECASE)
874
- delegation_count = len(delegation_patterns)
875
-
876
- # Action verbs that indicate the skill has its own operational workflow
877
- action_verbs = re.findall(
878
- r"\b(?:run|execute|create|write|validate|verify|inspect|check|ensure|test|build|"
879
- r"generate|compare|extract|parse|detect|fix|update|add|remove|install|configure|"
880
- r"deploy|trace|review|map|resolve|measure|confirm)\b",
881
- procedure_block, re.IGNORECASE)
882
- action_count = len(set(v.lower() for v in action_verbs))
883
-
884
- # Count actual ordered steps
885
- meaningful_steps = len(ORDERED_STEP_PATTERN.findall(procedure_block))
886
-
887
- # Thin procedure: few steps AND few lines
888
- has_thin_procedure = meaningful_steps < 3 and len(proc_lines) < 8
889
-
890
- # Error: effectively a pointer, not a real skill
891
- if delegation_count >= 3 and action_count <= 1 and has_thin_procedure:
892
- issues.append(Issue("error", "guideline_dependent_skill",
893
- f"Skill is effectively a pointer to guidelines/docs "
894
- f"({delegation_count} delegations, {action_count} action verbs, "
895
- f"{meaningful_steps} steps) — not an executable workflow"))
896
- suggestions.append("Add concrete steps, decision points, and validation directly into the skill")
897
- # Warning: likely too dependent on external guidance
898
- elif delegation_count >= 2 and action_count <= 2 and has_thin_procedure:
899
- issues.append(Issue("warning", "pointer_only_skill",
900
- f"Skill appears too guideline-dependent "
901
- f"({delegation_count} delegations, {action_count} action verbs, "
902
- f"{meaningful_steps} steps) — may lack its own executable workflow"))
903
- suggestions.append("Expand the skill so it remains executable without opening a guideline")
904
-
905
- # --- evals.json schema validator ---
906
- # When a skill ships sibling `evals/evals.json` (quantitative behavior
907
- # eval per skill-writing § 7), validate its shape. Triggers.json is a
908
- # separate concern handled elsewhere. All issues here are WARN.
909
- issues.extend(validate_evals_json(path))
910
-
911
- return LintResult(
912
- file=str(path),
913
- artifact_type="skill",
914
- status=classify_status(issues),
915
- issues=issues,
916
- suggestions=dedupe_preserve_order(suggestions),
917
- )
918
-
919
-
920
- def validate_evals_json(skill_path: Path) -> list[Issue]:
921
- """Validate `{skill_dir}/evals/evals.json` against the schema declared
922
- in `skill-writing` § 7. Returns WARN-level issues only; never blocks.
923
- Skipped entirely when the file is absent."""
924
- evals_path = skill_path.parent / "evals" / "evals.json"
925
- if not evals_path.is_file():
926
- return []
927
- issues: list[Issue] = []
928
- try:
929
- data = json.loads(evals_path.read_text(encoding="utf-8"))
930
- except (OSError, json.JSONDecodeError) as exc:
931
- return [Issue("warning", "evals_json_unreadable",
932
- f"evals/evals.json could not be parsed: {exc}")]
933
- if not isinstance(data, dict):
934
- return [Issue("warning", "evals_json_shape",
935
- "evals/evals.json root must be an object")]
936
- if "skill" not in data or not isinstance(data["skill"], str):
937
- issues.append(Issue("warning", "evals_json_missing_skill",
938
- "evals/evals.json must declare top-level 'skill' (string)"))
939
- scenarios = data.get("scenarios")
940
- if not isinstance(scenarios, list) or len(scenarios) < 1:
941
- issues.append(Issue("warning", "evals_json_no_scenarios",
942
- "evals/evals.json must declare 'scenarios' (non-empty array)"))
943
- return issues
944
- valid_kinds = {"contains", "file_exists", "rubric"}
945
- for idx, scenario in enumerate(scenarios):
946
- loc = f"scenarios[{idx}]"
947
- if not isinstance(scenario, dict):
948
- issues.append(Issue("warning", "evals_json_scenario_shape",
949
- f"{loc} must be an object"))
950
- continue
951
- for key in ("id", "prompt"):
952
- if key not in scenario or not isinstance(scenario[key], str) or not scenario[key].strip():
953
- issues.append(Issue("warning", "evals_json_scenario_missing_field",
954
- f"{loc} missing required string field '{key}'"))
955
- assertions = scenario.get("assertions")
956
- if not isinstance(assertions, list) or len(assertions) < 1:
957
- issues.append(Issue("warning", "evals_json_scenario_no_assertions",
958
- f"{loc}.assertions must be a non-empty array"))
959
- continue
960
- for a_idx, assertion in enumerate(assertions):
961
- a_loc = f"{loc}.assertions[{a_idx}]"
962
- if not isinstance(assertion, dict):
963
- issues.append(Issue("warning", "evals_json_assertion_shape",
964
- f"{a_loc} must be an object"))
965
- continue
966
- kind = assertion.get("kind")
967
- if kind not in valid_kinds:
968
- issues.append(Issue("warning", "evals_json_assertion_kind",
969
- f"{a_loc}.kind must be one of {sorted(valid_kinds)}, got {kind!r}"))
970
- continue
971
- required_field = {"contains": "value", "file_exists": "path", "rubric": "criterion"}[kind]
972
- if required_field not in assertion or not isinstance(assertion[required_field], str):
973
- issues.append(Issue("warning", "evals_json_assertion_missing_field",
974
- f"{a_loc} (kind={kind}) missing required string field '{required_field}'"))
975
- return issues
976
-
977
-
978
- def extract_frontmatter(text: str) -> Optional[str]:
979
- match = FRONTMATTER_PATTERN.search(text)
980
- return match.group(1) if match else None
981
-
982
-
983
- def _parse_trust_level(frontmatter: str) -> Optional[str]:
984
- """Parse `trust.level:` from the nested `trust:` mapping in frontmatter.
985
-
986
- Returns the level string (e.g. ``"core"``, ``"advisory"``) or ``None``
987
- if absent. Stdlib-only — mirrors the line-walking approach of
988
- ``_parse_yaml_list`` so the linter stays pyyaml-free.
989
- """
990
- lines = frontmatter.splitlines()
991
- in_block = False
992
- for line in lines:
993
- if not in_block:
994
- if line.startswith("trust:"):
995
- rhs = line[len("trust:"):].strip()
996
- if rhs == "":
997
- in_block = True
998
- continue
999
- if line.startswith(" level:"):
1000
- return line[len(" level:"):].strip().strip('"').strip("'")
1001
- if line.startswith(" "):
1002
- continue
1003
- break
1004
- return None
1005
-
1006
-
1007
- def _parse_yaml_list(frontmatter: str, key: str) -> Optional[list]:
1008
- """Parse a simple top-level YAML list `key:` from frontmatter.
1009
-
1010
- Supports the two shapes we emit in rule frontmatter:
1011
- triggers:
1012
- - keyword: "foo"
1013
- - phrase: "bar baz"
1014
- routes_to:
1015
- - skill:php-coder
1016
- - guideline:agent-infra/asking-and-brevity-examples
1017
-
1018
- Returns ``None`` if the key is absent (so the caller can distinguish
1019
- "missing" from "empty"); returns ``[]`` for an explicitly empty list.
1020
- """
1021
- lines = frontmatter.splitlines()
1022
- out: list = []
1023
- in_block = False
1024
- for line in lines:
1025
- if not in_block:
1026
- if line.startswith(f"{key}:"):
1027
- rhs = line[len(key) + 1:].strip()
1028
- if rhs in ("", "[]"):
1029
- if rhs == "[]":
1030
- return []
1031
- in_block = True
1032
- else:
1033
- return None # unexpected scalar shape
1034
- continue
1035
- if line.startswith(" - "):
1036
- item = line[4:].strip()
1037
- if ":" in item and not item.startswith(("'", '"')):
1038
- k, _, v = item.partition(":")
1039
- out.append({k.strip(): v.strip().strip('"').strip("'")})
1040
- else:
1041
- out.append(item.strip('"').strip("'"))
1042
- elif line.strip() == "" or line.startswith(" "):
1043
- continue
1044
- else:
1045
- break
1046
- return out if in_block else None
1047
-
1048
-
1049
- def lint_router_frontmatter(rule_id: str, frontmatter: str,
1050
- rule_type: Optional[str]) -> List[Issue]:
1051
- """Validate `triggers:` / `routes_to:` per docs/contracts/rule-router.md.
1052
-
1053
- Strict checks (always errors): kernel rules MUST NOT carry router fields;
1054
- `triggers:` items must use one allowed key; `routes_to:` items must
1055
- follow `kind:id` with kind ∈ {skill, guideline} and the target file
1056
- must exist on disk.
1057
-
1058
- Lenient checks (info-level until Phase 4 migrations land): non-kernel
1059
- rules without `triggers:` / `routes_to:` get an informational note,
1060
- not an error — the existing description-matching path still works.
1061
-
1062
- Trust-tier carve-out: rules with ``trust.level: core`` are exempt from
1063
- the ``router_routes_to_missing`` migration hint — they are authoritative
1064
- by design and their body legitimately lives inline.
1065
- """
1066
- issues: List[Issue] = []
1067
- triggers = _parse_yaml_list(frontmatter, "triggers")
1068
- routes_to = _parse_yaml_list(frontmatter, "routes_to")
1069
-
1070
- # Manual rules are reference-only — not auto-injected, not router-routed
1071
- # (ADR-004). Skip router validation so legacy triggers/routes_to fields
1072
- # remain documented in the rule body without forcing maintenance.
1073
- if rule_type == "manual":
1074
- return issues
1075
-
1076
- is_kernel = rule_id in KERNEL_RULE_IDS or rule_type == "always"
1077
-
1078
- if is_kernel:
1079
- if triggers is not None:
1080
- issues.append(Issue("error", "kernel_has_triggers",
1081
- "Kernel rules MUST NOT declare triggers: (kernel is unconditional)"))
1082
- if routes_to is not None:
1083
- issues.append(Issue("error", "kernel_has_routes_to",
1084
- "Kernel rules MUST NOT declare routes_to: (kernel body stays inline)"))
1085
- return issues
1086
-
1087
- # Non-kernel rule path
1088
- if triggers is None:
1089
- issues.append(Issue("info", "router_triggers_missing",
1090
- "Non-kernel rule has no triggers: — falls back to description matching "
1091
- "until Phase 4 migration lands"))
1092
- else:
1093
- for idx, item in enumerate(triggers):
1094
- if not isinstance(item, dict) or len(item) != 1:
1095
- issues.append(Issue("error", "trigger_shape_invalid",
1096
- f"triggers[{idx}] must be a single-key mapping"))
1097
- continue
1098
- (k,) = item.keys()
1099
- if k not in ROUTER_ALLOWED_TRIGGER_KEYS:
1100
- allowed = ", ".join(sorted(ROUTER_ALLOWED_TRIGGER_KEYS))
1101
- issues.append(Issue("error", "trigger_key_unknown",
1102
- f"triggers[{idx}] key '{k}' not in allowed set ({allowed})"))
1103
-
1104
- if routes_to is None:
1105
- # Trust-tier carve-out: rules pinned at trust.level: core are
1106
- # authoritative — their body IS the behavior and may legitimately
1107
- # live inline without a routes_to: delegation. The Phase 4
1108
- # migration hint applies only to lower-trust rules.
1109
- trust_level = _parse_trust_level(frontmatter)
1110
- if trust_level != "core":
1111
- issues.append(Issue("info", "router_routes_to_missing",
1112
- "Non-kernel rule has no routes_to: — body should migrate to skill / "
1113
- "guideline in Phase 4"))
1114
- else:
1115
- repo_root = Path(__file__).resolve().parent.parent.parent
1116
- for idx, item in enumerate(routes_to):
1117
- if not isinstance(item, str) or ":" not in item:
1118
- issues.append(Issue("error", "route_shape_invalid",
1119
- f"routes_to[{idx}] must be 'kind:id'"))
1120
- continue
1121
- kind, _, target_id = item.partition(":")
1122
- # Multi-root aware (ADR-017): resolve logical paths via every
1123
- # source root so kernel rules keep routing to skills/commands
1124
- # that moved into packages/*/.
1125
- target: Optional[Path] = None
1126
- if kind == "skill":
1127
- target = resolve_logical(f"skills/{target_id}/SKILL.md")
1128
- elif kind == "guideline":
1129
- gpath = repo_root / "docs" / "guidelines" / f"{target_id}.md"
1130
- target = gpath if gpath.exists() else None
1131
- elif kind == "command":
1132
- target = resolve_logical(f"commands/{target_id}.md")
1133
- elif kind == "contract":
1134
- # Contracts live in two places: stable host docs in
1135
- # docs/contracts/ and load-bearing flows under
1136
- # contexts/contracts/ inside any source root (road-to-path-fixes
1137
- # P4 / Council R2). Try both before failing.
1138
- cpath = repo_root / "docs" / "contracts" / f"{target_id}.md"
1139
- if cpath.exists():
1140
- target = cpath
1141
- else:
1142
- target = resolve_logical(f"contexts/contracts/{target_id}.md")
1143
- else:
1144
- issues.append(Issue("error", "route_kind_unknown",
1145
- f"routes_to[{idx}] kind '{kind}' must be 'skill', 'guideline', 'command', or 'contract'"))
1146
- continue
1147
- if target is None or not target.exists():
1148
- issues.append(Issue("error", "route_target_missing",
1149
- f"routes_to[{idx}] target '{item}' not found under any artefact root"))
1150
- return issues
1151
-
1152
-
1153
- def extract_frontmatter_field(frontmatter: str, pattern: re.Pattern[str]) -> Optional[str]:
1154
- match = pattern.search(frontmatter)
1155
- return match.group(1).strip() if match else None
1156
-
1157
-
1158
- def parse_execution_block(frontmatter: str) -> Optional[dict]:
1159
- """Parse the execution block from YAML frontmatter.
1160
-
1161
- Uses simple line-based parsing to avoid requiring PyYAML.
1162
- Returns None if no execution block is present.
1163
- """
1164
- lines = frontmatter.splitlines()
1165
- exec_start = None
1166
- for i, line in enumerate(lines):
1167
- if re.match(r'^execution:\s*$', line):
1168
- exec_start = i
1169
- break
1170
- if exec_start is None:
1171
- return None
1172
-
1173
- result: dict = {}
1174
- for line in lines[exec_start + 1:]:
1175
- # Stop at next top-level key (no indentation)
1176
- if line and not line[0].isspace():
1177
- break
1178
- stripped = line.strip()
1179
- if not stripped or stripped.startswith('#'):
1180
- continue
1181
- # Handle list items (for allowed_tools)
1182
- if stripped.startswith('- '):
1183
- if '_current_list' in result:
1184
- result[result['_current_list']].append(stripped[2:].strip().strip('"').strip("'"))
1185
- continue
1186
- # Handle key: value pairs
1187
- match = re.match(r'^(\w+):\s*(.*?)\s*$', stripped)
1188
- if match:
1189
- key = match.group(1)
1190
- value = match.group(2).strip('"').strip("'")
1191
- if value == '[]':
1192
- result[key] = []
1193
- result['_current_list'] = key
1194
- elif re.match(r'^\[.*\]$', value):
1195
- # Inline YAML/JSON array like [github] or ["github", "jira"]
1196
- inner = value[1:-1].strip()
1197
- if inner:
1198
- items = [item.strip().strip('"').strip("'") for item in inner.split(',')]
1199
- result[key] = items
1200
- else:
1201
- result[key] = []
1202
- result['_current_list'] = key
1203
- elif value == '':
1204
- # Could be a list starting on next line
1205
- result[key] = []
1206
- result['_current_list'] = key
1207
- else:
1208
- # Try to parse as int
1209
- try:
1210
- result[key] = int(value)
1211
- except ValueError:
1212
- result[key] = value
1213
- result.pop('_current_list', None)
1214
-
1215
- result.pop('_current_list', None)
1216
- return result
1217
-
1218
-
1219
- def lint_senior_tier_blocks(text: str) -> List[Issue]:
1220
- """Validate the four required blocks for `tier: senior` skills.
1221
-
1222
- Per .agent-src.uncondensed/rules/skill-quality.md § Senior-Tier
1223
- Required Structure: Context-First lead (description), Related Skills
1224
- (with WHEN / WHEN NOT lists), Proactive Triggers, Output Artifacts.
1225
-
1226
- The Context-First lead is checked structurally via description length
1227
- + content; here we enforce the three section blocks and the WHEN /
1228
- WHEN NOT two-list pattern inside Related Skills.
1229
- """
1230
- issues: List[Issue] = []
1231
-
1232
- if not SENIOR_RELATED_SKILLS_PATTERN.search(text):
1233
- issues.append(Issue(
1234
- "error",
1235
- "missing_senior_related_skills",
1236
- "Senior-tier skill missing `## Related Skills` block (skill-quality.md § Senior-Tier Required Structure)",
1237
- ))
1238
- else:
1239
- related_block = extract_section_block(text, "Related Skills") or ""
1240
- if not SENIOR_RELATED_WHEN_PATTERN.search(related_block):
1241
- issues.append(Issue(
1242
- "error",
1243
- "missing_senior_related_when",
1244
- "Senior-tier `## Related Skills` block missing `**WHEN to use this**` list",
1245
- ))
1246
- if not SENIOR_RELATED_WHEN_NOT_PATTERN.search(related_block):
1247
- issues.append(Issue(
1248
- "error",
1249
- "missing_senior_related_when_not",
1250
- "Senior-tier `## Related Skills` block missing `**WHEN NOT to use this**` list",
1251
- ))
1252
-
1253
- if not SENIOR_PROACTIVE_PATTERN.search(text):
1254
- issues.append(Issue(
1255
- "error",
1256
- "missing_senior_proactive_triggers",
1257
- "Senior-tier skill missing `## When the agent should load this` block",
1258
- ))
1259
-
1260
- if not SENIOR_OUTPUT_PATTERN.search(text):
1261
- issues.append(Issue(
1262
- "error",
1263
- "missing_senior_output_artifacts",
1264
- "Senior-tier skill missing `## Output` block declaring artifact name + shape",
1265
- ))
1266
-
1267
- return issues
1268
-
1269
-
1270
- def parse_context_spine(frontmatter: str) -> Optional[List[str]]:
1271
- """Parse `context_spine:` from frontmatter.
1272
-
1273
- Supports the inline form `context_spine: [a, b, c]` (most skills) and
1274
- the block form via `_parse_yaml_list`. Returns the slot list, ``[]``
1275
- for an explicitly empty array, or ``None`` if the key is absent.
1276
- """
1277
- match = CONTEXT_SPINE_INLINE_PATTERN.search(frontmatter)
1278
- if match is not None:
1279
- inner = match.group(1).strip()
1280
- if not inner:
1281
- return []
1282
- return [s.strip().strip('"').strip("'") for s in inner.split(",") if s.strip()]
1283
- block = _parse_yaml_list(frontmatter, "context_spine")
1284
- return block
1285
-
1286
-
1287
- def _strip_wing3_carve_outs(text: str) -> str:
1288
- """Remove fenced code, inline backticks, the ``## Do NOT`` block, and
1289
- ``**WHEN NOT to use this**`` bullets so legitimate citations of vendor
1290
- names (as off-scope examples) do not trip Wing-3 boundary checks.
1291
- """
1292
- text = re.sub(r"```[^\n]*\n.*?```", "", text, flags=re.DOTALL)
1293
- text = re.sub(r"`[^`]+`", "", text)
1294
- text = re.sub(
1295
- r"^##\s+Do NOT\s*$.*?(?=^##\s+|\Z)",
1296
- "", text, flags=re.MULTILINE | re.DOTALL,
1297
- )
1298
- text = re.sub(
1299
- r"\*\*WHEN NOT to use this\*\*.*?(?=\*\*WHEN|^##\s+|\Z)",
1300
- "", text, flags=re.DOTALL | re.IGNORECASE,
1301
- )
1302
- return text
1303
-
1304
-
1305
- def lint_wing3_boundaries(text: str) -> List[Issue]:
1306
- """Four Wing-3 GTM cognition-boundary checks.
1307
-
1308
- Triggered when a skill's ``context_spine`` declares at least one
1309
- Wing-3 slot (channel-stage, funnel-stage, customer-segment). Enforces
1310
- council Q7 / iter-2 OQ3 verdict that GTM cognition stays:
1311
-
1312
- - **agent-operability** — no external SaaS URLs the agent would auth against.
1313
- - **vendor-independence** — no platform / SDK / brand slugs.
1314
- - **transferability** — no stack-locked tooling instructions.
1315
- - **channel-agnosticism** — no channel-specific tactical prescriptions.
1316
-
1317
- Carve-outs: fenced code, inline backticks, the ``## Do NOT`` block,
1318
- and ``**WHEN NOT to use this**`` lists — so authors can cite a vendor
1319
- as off-scope without tripping the linter.
1320
- """
1321
- issues: List[Issue] = []
1322
- body = _strip_wing3_carve_outs(text)
1323
-
1324
- match = WING3_SAAS_URL_PATTERN.search(body)
1325
- if match:
1326
- issues.append(Issue(
1327
- "warning", "wing3_agent_operability",
1328
- f"Wing-3 skill cites external SaaS URL `{match.group(0)}` outside "
1329
- f"carve-outs — cognition skills must operate without SaaS auth "
1330
- f"(council Q7 boundary)",
1331
- ))
1332
-
1333
- match = WING3_VENDOR_BLACKLIST.search(body)
1334
- if match:
1335
- issues.append(Issue(
1336
- "warning", "wing3_vendor_independence",
1337
- f"Wing-3 skill names vendor `{match.group(0)}` outside carve-outs "
1338
- f"— keep cognition vendor-agnostic (council Q7 boundary)",
1339
- ))
1340
-
1341
- match = WING3_STACK_LOCKED_PATTERN.search(body)
1342
- if match:
1343
- issues.append(Issue(
1344
- "warning", "wing3_transferability",
1345
- f"Wing-3 skill includes stack-locked instruction `{match.group(0)}` "
1346
- f"outside carve-outs — cognition should transfer across stacks "
1347
- f"(council Q7 boundary)",
1348
- ))
1349
-
1350
- match = WING3_CHANNEL_TACTIC_PATTERN.search(body)
1351
- if match:
1352
- issues.append(Issue(
1353
- "warning", "wing3_channel_agnosticism",
1354
- f"Wing-3 skill prescribes channel-specific tactic "
1355
- f"`{match.group(0)}` outside carve-outs — keep cognition "
1356
- f"channel-agnostic (council Q7 boundary)",
1357
- ))
1358
-
1359
- return issues
1360
-
1361
-
1362
- def lint_wing4_boundaries(text: str) -> List[Issue]:
1363
- """Four Wing-4 Money/Strategy/Ops cognition-boundary checks.
1364
-
1365
- Triggered when a skill's ``context_spine`` declares at least one
1366
- Wing-4 slot (fiscal-period, org-stage, regulatory-regime). Enforces
1367
- council Q7 / J2 verdict that Money/Strategy/Ops cognition stays:
1368
-
1369
- - **agent-operability** — no external finance/HR/legal SaaS URLs.
1370
- - **vendor-independence** — no QuickBooks/Carta/Gusto-class brand slugs.
1371
- - **transferability** — no stack-locked tooling instructions.
1372
- - **stage-agnosticism** — no prescriptive stage-specific thresholds.
1373
-
1374
- Carve-outs are identical to Wing-3: fenced code, inline backticks,
1375
- the ``## Do NOT`` block, and ``**WHEN NOT to use this**`` lists.
1376
- Regulatory regime names (GDPR / HIPAA / SOC2 / PCI / CCPA) are
1377
- cognition-relevant constraints, not vendors — they pass.
1378
- """
1379
- issues: List[Issue] = []
1380
- body = _strip_wing3_carve_outs(text)
1381
-
1382
- match = WING4_SAAS_URL_PATTERN.search(body)
1383
- if match:
1384
- issues.append(Issue(
1385
- "warning", "wing4_agent_operability",
1386
- f"Wing-4 skill cites external SaaS URL `{match.group(0)}` outside "
1387
- f"carve-outs — cognition skills must operate without SaaS auth "
1388
- f"(council Q7 boundary)",
1389
- ))
1390
-
1391
- match = WING4_VENDOR_BLACKLIST.search(body)
1392
- if match:
1393
- issues.append(Issue(
1394
- "warning", "wing4_vendor_independence",
1395
- f"Wing-4 skill names vendor `{match.group(0)}` outside carve-outs "
1396
- f"— keep cognition vendor-agnostic (council Q7 boundary)",
1397
- ))
1398
-
1399
- match = WING3_STACK_LOCKED_PATTERN.search(body)
1400
- if match:
1401
- issues.append(Issue(
1402
- "warning", "wing4_transferability",
1403
- f"Wing-4 skill includes stack-locked instruction `{match.group(0)}` "
1404
- f"outside carve-outs — cognition should transfer across stacks "
1405
- f"(council Q7 boundary)",
1406
- ))
1407
-
1408
- match = WING4_STAGE_AGNOSTIC_PATTERN.search(body)
1409
- if match:
1410
- issues.append(Issue(
1411
- "warning", "wing4_stage_agnosticism",
1412
- f"Wing-4 skill prescribes stage-locked threshold "
1413
- f"`{match.group(0)}` outside carve-outs — cognition must "
1414
- f"transfer across seed and public (council Q7 boundary)",
1415
- ))
1416
-
1417
- return issues
1418
-
1419
-
1420
- def lint_execution_metadata(execution: dict) -> List[Issue]:
1421
- """Validate the execution block of a skill."""
1422
- issues: List[Issue] = []
1423
-
1424
- # Validate type
1425
- exec_type = execution.get("type")
1426
- if exec_type is not None:
1427
- if exec_type not in VALID_EXECUTION_TYPES:
1428
- issues.append(Issue("error", "invalid_execution_type",
1429
- f"Invalid execution.type '{exec_type}'; "
1430
- f"must be one of: {', '.join(sorted(VALID_EXECUTION_TYPES))}"))
1431
- else:
1432
- issues.append(Issue("error", "missing_execution_type",
1433
- "Execution block present but missing 'type' field"))
1434
-
1435
- # Validate handler
1436
- handler = execution.get("handler")
1437
- if handler is not None:
1438
- if handler not in VALID_EXECUTION_HANDLERS:
1439
- issues.append(Issue("error", "invalid_execution_handler",
1440
- f"Invalid execution.handler '{handler}'; "
1441
- f"must be one of: {', '.join(sorted(VALID_EXECUTION_HANDLERS))}"))
1442
-
1443
- # Automated-specific checks
1444
- if exec_type == "automated":
1445
- if handler is None or handler == "none":
1446
- issues.append(Issue("error", "automated_missing_handler",
1447
- "Automated execution requires a handler other than 'none'"))
1448
- safety_mode = execution.get("safety_mode")
1449
- if safety_mode is None:
1450
- issues.append(Issue("error", "automated_missing_safety_mode",
1451
- "Automated execution requires 'safety_mode: strict'"))
1452
- elif safety_mode not in VALID_EXECUTION_SAFETY_MODES:
1453
- issues.append(Issue("error", "invalid_safety_mode",
1454
- f"Invalid safety_mode '{safety_mode}'; must be 'strict'"))
1455
- if "allowed_tools" not in execution:
1456
- issues.append(Issue("warning", "automated_missing_allowed_tools",
1457
- "Automated execution should declare 'allowed_tools' (use [] for none)"))
1458
-
1459
- # Validate safety_mode if present (even for non-automated)
1460
- safety_mode = execution.get("safety_mode")
1461
- if safety_mode is not None and safety_mode not in VALID_EXECUTION_SAFETY_MODES:
1462
- issues.append(Issue("error", "invalid_safety_mode",
1463
- f"Invalid safety_mode '{safety_mode}'; must be 'strict'"))
1464
-
1465
- # Validate timeout_seconds
1466
- timeout = execution.get("timeout_seconds")
1467
- if timeout is not None:
1468
- if not isinstance(timeout, int) or timeout <= 0:
1469
- issues.append(Issue("warning", "invalid_timeout",
1470
- f"timeout_seconds should be a positive integer, got '{timeout}'"))
1471
-
1472
- # Validate allowed_tools is a list of strings
1473
- allowed_tools = execution.get("allowed_tools")
1474
- if allowed_tools is not None:
1475
- if not isinstance(allowed_tools, list):
1476
- issues.append(Issue("error", "invalid_allowed_tools",
1477
- "allowed_tools must be a list"))
1478
- elif not all(isinstance(t, str) for t in allowed_tools):
1479
- issues.append(Issue("error", "invalid_allowed_tools_entries",
1480
- "All entries in allowed_tools must be strings"))
1481
-
1482
- # Validate command shape if present. Skills that declare `command` are
1483
- # runtime-executable; skills without it stay in proposal-only mode.
1484
- command = execution.get("command")
1485
- if command is not None:
1486
- if not isinstance(command, list) or not all(isinstance(c, str) for c in command):
1487
- issues.append(Issue("error", "invalid_command",
1488
- "command must be a list of strings (argv form)"))
1489
- elif len(command) == 0:
1490
- issues.append(Issue("error", "empty_command",
1491
- "command must not be empty"))
1492
-
1493
- # Check for unknown fields
1494
- known_fields = VALID_EXECUTION_FIELDS
1495
- unknown = set(execution.keys()) - known_fields
1496
- for field in sorted(unknown):
1497
- issues.append(Issue("warning", "unknown_execution_field",
1498
- f"Unknown field in execution block: '{field}'"))
1499
-
1500
- return issues
1501
-
1502
-
1503
- def lint_rule(path: Path, text: str) -> LintResult:
1504
- issues: List[Issue] = []
1505
- suggestions: List[str] = []
1506
-
1507
- # --- Frontmatter checks ---
1508
- frontmatter = extract_frontmatter(text)
1509
- if frontmatter is None:
1510
- issues.append(Issue("error", "missing_frontmatter", "Rule is missing YAML frontmatter (--- block)"))
1511
- else:
1512
- # type field
1513
- rule_type = extract_frontmatter_field(frontmatter, TYPE_PATTERN)
1514
- if rule_type is None:
1515
- issues.append(Issue("error", "missing_type", "Frontmatter missing 'type' field (must be 'always', 'auto', or 'manual')"))
1516
- elif rule_type not in VALID_RULE_TYPES:
1517
- issues.append(Issue("error", "invalid_type", f"Invalid type '{rule_type}'; must be 'always', 'auto', or 'manual'"))
1518
-
1519
- # source field — optional (schema default `package` injected at read);
1520
- # validate the value only when present.
1521
- rule_source = extract_frontmatter_field(frontmatter, SOURCE_PATTERN)
1522
- if rule_source is not None and rule_source not in VALID_RULE_SOURCES:
1523
- issues.append(Issue("error", "invalid_source", f"Invalid source '{rule_source}'; must be 'package' or 'project'"))
1524
-
1525
- # description required for auto rules
1526
- if rule_type == "auto":
1527
- description = extract_description(text)
1528
- if not description:
1529
- issues.append(Issue("error", "auto_missing_description", "Auto rules require a 'description' field for matching"))
1530
-
1531
- # description length cap (F6 — 200-char hard cap, see road-to-governance-cleanup)
1532
- rule_description = extract_description(text)
1533
- if rule_description and len(rule_description) > 200:
1534
- issues.append(Issue("error", "description_too_long",
1535
- f"Description is {len(rule_description)} chars (hard cap: 200) — see road-to-governance-cleanup F6"))
1536
-
1537
- # always-rules that look like auto candidates (rule-type-governance check)
1538
- if rule_type == "always":
1539
- description = extract_description(text) or ""
1540
- # If description contains topic-specific keywords, it might be an auto candidate
1541
- topic_keywords = re.findall(
1542
- r"\b(?:PHP|Laravel|Docker|Git|E2E|Playwright|SQL|Blade|Livewire|"
1543
- r"Terraform|Jira|Sentry|translations|i18n)\b",
1544
- description, re.IGNORECASE)
1545
- if len(topic_keywords) >= 2:
1546
- issues.append(Issue("info", "always_auto_candidate",
1547
- f"Always-rule with topic-specific description ({', '.join(topic_keywords)}) — "
1548
- f"consider auto type per rule-type-governance"))
1549
-
1550
- # Router schema validation (docs/contracts/rule-router.md, Phase 3.3).
1551
- issues.extend(lint_router_frontmatter(path.stem, frontmatter, rule_type))
1552
-
1553
- # --- Structure checks ---
1554
- # H1 heading
1555
- if not H1_PATTERN.search(text):
1556
- issues.append(Issue("error", "missing_h1", "Rule is missing an H1 heading (# Title)"))
1557
-
1558
- # File must end with exactly one newline
1559
- if not text.endswith("\n"):
1560
- issues.append(Issue("error", "no_trailing_newline", "File must end with exactly one newline"))
1561
- elif text.endswith("\n\n"):
1562
- issues.append(Issue("warning", "extra_trailing_newlines", "File ends with multiple newlines; should be exactly one"))
1563
-
1564
- # No double/triple blank lines in content
1565
- if DOUBLE_BLANK_PATTERN.search(text):
1566
- issues.append(Issue("warning", "double_blank_lines", "File contains double or triple blank lines"))
1567
-
1568
- # --- Content checks (docs/contracts/linter-structural-model.md) ---
1569
- # Structural-density gate replaces fenced-ratio + dual-threshold (Phase 3
1570
- # of road-to-structural-linter-reform, 2026-05-08): warn only when the
1571
- # rule is long, prose-dominant, AND ships no Iron-Law block. Hard error
1572
- # at 200 lines stays unconditional.
1573
- line_count = len([line for line in text.splitlines() if line.strip()])
1574
- total_lines = len(text.splitlines())
1575
- if total_lines > 200:
1576
- issues.append(Issue("error", "rule_too_large", f"Rule has {total_lines} lines (hard limit: 200); must split or move to guideline"))
1577
- elif line_count > 60:
1578
- density = _density_score(text)
1579
- iron_blocks = _iron_law_blocks(text)
1580
- if density < 0.5 and iron_blocks == 0:
1581
- issues.append(Issue(
1582
- "warning",
1583
- "long_rule",
1584
- f"Rule has {line_count} non-empty lines, density {density:.2f} < 0.50, "
1585
- f"no Iron-Law block; rules should be concise "
1586
- f"(see linter-structural-model contract)",
1587
- ))
1588
-
1589
- for bad_sign in RULE_BAD_SIGNS:
1590
- if bad_sign in text:
1591
- issues.append(Issue("error", "rule_looks_like_skill", f"Rule contains skill-like section: {bad_sign}"))
1592
-
1593
- # Procedural-rule heuristic: a rule "looks procedural" only when its own
1594
- # prose AND its own structure both signal a procedure. We:
1595
- # 1. Exclude frontmatter (may contain "type", path strings, etc.).
1596
- # 2. Strip code spans, fenced blocks, and markdown links — so legitimate
1597
- # pointers to procedural skills (e.g. `skill:git-workflow`,
1598
- # [symfony-workflow](…)) do not flip the keyword count.
1599
- # 3. Require ≥ 2 keyword occurrences in stripped prose AND ≥ 3 ordered
1600
- # steps AND no Iron-Law block — that combination distinguishes a
1601
- # mis-classified procedure from a rule that merely references one.
1602
- body = text.split("---", 2)[-1] if frontmatter else text
1603
- stripped_body = _strip_markdown_for_check(body)
1604
- kw_count = len(re.findall(r"\b(procedure|workflow)\b", stripped_body, re.IGNORECASE))
1605
- ordered_steps = len(re.findall(r"^\s*\d+\.\s+", body, re.MULTILINE))
1606
- if kw_count >= 2 and ordered_steps >= 3 and _iron_law_blocks(text) == 0:
1607
- issues.append(Issue("warning", "procedural_rule", "Rule looks procedural; consider a skill instead"))
1608
-
1609
- return LintResult(
1610
- file=str(path),
1611
- artifact_type="rule",
1612
- status=classify_status(issues),
1613
- issues=issues,
1614
- suggestions=dedupe_preserve_order(suggestions),
1615
- )
1616
-
1617
-
1618
- def _lint_command_suggestion_block(text: str) -> List[Issue]:
1619
- """Validate the suggestion frontmatter block (road-to-context-aware-command-suggestion).
1620
-
1621
- Schema-shape is enforced upstream by validate_frontmatter; this function adds the
1622
- *conditional* content rules that JSON Schema (Draft-07 subset used here) cannot
1623
- express: trigger fields must be non-empty when eligible, rationale must be
1624
- non-empty when ineligible.
1625
- """
1626
- issues: List[Issue] = []
1627
- data, _offset = parse_frontmatter_for_schema(text)
1628
- if data is None:
1629
- return issues
1630
- suggestion = data.get("suggestion")
1631
- if suggestion is None:
1632
- issues.append(Issue(
1633
- "error", "missing_suggestion_block",
1634
- "Command frontmatter is missing the 'suggestion' block — required by "
1635
- "road-to-context-aware-command-suggestion Phase 2.",
1636
- ))
1637
- return issues
1638
- if not isinstance(suggestion, dict):
1639
- issues.append(Issue("error", "invalid_suggestion_block", "'suggestion' must be a mapping"))
1640
- return issues
1641
- eligible = suggestion.get("eligible")
1642
- if eligible is True:
1643
- td = (suggestion.get("trigger_description") or "").strip()
1644
- tc = (suggestion.get("trigger_context") or "").strip()
1645
- if not td:
1646
- issues.append(Issue(
1647
- "error", "missing_trigger_description",
1648
- "suggestion.eligible=true requires a non-empty 'trigger_description'.",
1649
- ))
1650
- elif len(td) < 10:
1651
- issues.append(Issue(
1652
- "warning", "trigger_description_too_short",
1653
- "suggestion.trigger_description is suspiciously short (<10 chars); "
1654
- "linter rejects empty or overly generic patterns.",
1655
- ))
1656
- if not tc:
1657
- issues.append(Issue(
1658
- "error", "missing_trigger_context",
1659
- "suggestion.eligible=true requires a non-empty 'trigger_context'.",
1660
- ))
1661
- elif len(tc) < 10:
1662
- issues.append(Issue(
1663
- "warning", "trigger_context_too_short",
1664
- "suggestion.trigger_context is suspiciously short (<10 chars); "
1665
- "linter rejects empty or overly generic patterns.",
1666
- ))
1667
- elif eligible is False:
1668
- rationale = (suggestion.get("rationale") or "").strip()
1669
- if not rationale:
1670
- issues.append(Issue(
1671
- "error", "missing_suggestion_rationale",
1672
- "suggestion.eligible=false requires a non-empty 'rationale'.",
1673
- ))
1674
- else:
1675
- issues.append(Issue(
1676
- "error", "invalid_suggestion_eligible",
1677
- "suggestion.eligible must be true or false.",
1678
- ))
1679
- return issues
1680
-
1681
-
1682
- def lint_command(path: Path, text: str) -> LintResult:
1683
- issues: List[Issue] = []
1684
- suggestions: List[str] = []
1685
-
1686
- # --- Frontmatter checks ---
1687
- frontmatter = extract_frontmatter(text)
1688
- if frontmatter is None:
1689
- issues.append(Issue("error", "missing_frontmatter", "Command is missing YAML frontmatter (--- block)"))
1690
- else:
1691
- # name field
1692
- name_match = NAME_PATTERN.search(frontmatter)
1693
- if not name_match or not name_match.group(1).strip():
1694
- issues.append(Issue("error", "missing_name", "Frontmatter missing 'name' field"))
1695
-
1696
- # disable-model-invocation field — optional (schema default `true`
1697
- # injected at read); validate the value only when present.
1698
- dmi_match = DISABLE_MODEL_PATTERN.search(frontmatter)
1699
- if dmi_match and dmi_match.group(1) != "true":
1700
- issues.append(Issue("warning", "disable_model_invocation_false",
1701
- "disable-model-invocation should be 'true' for commands"))
1702
-
1703
- # description field
1704
- description = extract_description(text)
1705
- if not description:
1706
- issues.append(Issue("warning", "missing_description", "Frontmatter description is missing"))
1707
- elif len(description) > 200:
1708
- issues.append(Issue("error", "description_too_long",
1709
- f"Description is {len(description)} chars (hard cap: 200) — see road-to-governance-cleanup F6"))
1710
-
1711
- # suggestion block (road-to-context-aware-command-suggestion Phase 2)
1712
- issues.extend(_lint_command_suggestion_block(text))
1713
-
1714
- # deprecation-shim warning line (P0.8b — command-clusters contract)
1715
- if "superseded_by:" in frontmatter:
1716
- shim_warning = re.search(
1717
- r"⚠️\s+/[a-z][a-z0-9-]*\s+is deprecated;\s+use\s+/[a-z][a-z0-9 -]+\s+instead",
1718
- text,
1719
- )
1720
- if not shim_warning:
1721
- issues.append(Issue(
1722
- "error", "shim_missing_warning",
1723
- "Deprecation shim must contain a one-line warning matching "
1724
- "'⚠️ /<old-name> is deprecated; use /<cluster> <sub> instead.'"
1725
- " (or '/<cluster> --<flag>' for flag-clusters)"
1726
- " (see docs/contracts/command-clusters.md § Deprecation shim contract)"
1727
- ))
1728
-
1729
- # --- Structure checks ---
1730
- if not H1_PATTERN.search(text):
1731
- issues.append(Issue("error", "missing_h1", "Command is missing an H1 heading (# Title)"))
1732
-
1733
- # Must have at least one ## section with steps. Cluster-head and
1734
- # router-style commands (frontmatter cluster:/routes_to: or ≥ 3 .md
1735
- # links) are exempt — they delegate procedure to sub-commands or
1736
- # skills (road-to-feedback-followups P2.1).
1737
- sections = extract_sections(text)
1738
- has_steps = any(s.lower().startswith("step") for s in sections)
1739
- # Accept both ``## 1.`` / ``### 1.`` numbered headings AND
1740
- # ``### Step N`` / ``## Step N`` step-prefixed sub-headings.
1741
- has_numbered = bool(re.search(r"^###?\s+(?:\d+\.|step\s+\d+)\s+", text, re.MULTILINE | re.IGNORECASE))
1742
- if not has_steps and not has_numbered:
1743
- delegated = _command_delegation_signal(text, frontmatter)
1744
- if not delegated:
1745
- issues.append(Issue("warning", "no_steps", "Command has no Steps section or numbered sub-headings"))
1746
-
1747
- # --- Size check (docs/contracts/linter-structural-model.md) ---
1748
- # Structural-density gate replaces sub-section + code-block heuristic
1749
- # (Phase 3 of road-to-structural-linter-reform, 2026-05-08): warn only
1750
- # when the command is large, lacks a delegation signal (frontmatter
1751
- # cluster:/routes_to: OR ≥ 3 markdown links to other .md files), AND
1752
- # has density < 0.65.
1753
- word_count = len(text.split())
1754
- if word_count > 1000:
1755
- density = _density_score(text)
1756
- delegated = _command_delegation_signal(text, frontmatter)
1757
- if not delegated and density < 0.65:
1758
- issues.append(Issue(
1759
- "warning",
1760
- "large_command",
1761
- f"Command has {word_count} words, density {density:.2f} < 0.65, "
1762
- f"no delegation signal (frontmatter cluster:/routes_to: or "
1763
- f"≥ 3 .md links); review for split or delegation "
1764
- f"(see linter-structural-model contract)",
1765
- ))
1766
-
1767
- # File must end with exactly one newline
1768
- if not text.endswith("\n"):
1769
- issues.append(Issue("error", "no_trailing_newline", "File must end with exactly one newline"))
1770
- elif text.endswith("\n\n"):
1771
- issues.append(Issue("warning", "extra_trailing_newlines", "File ends with multiple newlines; should be exactly one"))
1772
-
1773
- # Role-contract anchor validity (road-to-role-modes Phase 1).
1774
- issues.extend(lint_role_contract_refs(text))
1775
-
1776
- return LintResult(
1777
- file=str(path),
1778
- artifact_type="command",
1779
- status=classify_status(issues),
1780
- issues=issues,
1781
- suggestions=dedupe_preserve_order(suggestions),
1782
- )
1783
-
1784
-
1785
- def lint_unknown(path: Path, text: str) -> LintResult:
1786
- issues = [Issue("error", "unknown_artifact", "Could not detect whether file is a skill, rule, or command")]
1787
- return LintResult(
1788
- file=str(path),
1789
- artifact_type="unknown",
1790
- status="fail",
1791
- issues=issues,
1792
- suggestions=["Move the file into a recognized skills/, rules/, or commands/ path"],
1793
- )
1794
-
1795
-
1796
- def lint_guideline(path: Path, text: str) -> LintResult:
1797
- """Lint a guideline .md file (size + structure checks)."""
1798
- issues: List[Issue] = []
1799
-
1800
- # H1 heading
1801
- if not H1_PATTERN.search(text):
1802
- issues.append(Issue("warning", "missing_h1", "Guideline is missing an H1 heading"))
1803
-
1804
- # Size check (guidelines/agent-infra/size-and-scope.md: target 400-1500 words)
1805
- word_count = len(text.split())
1806
- if word_count > 1500:
1807
- issues.append(Issue("info", "large_guideline", f"Guideline has {word_count} words (target: 400-1500)"))
1808
-
1809
- # Trailing newline
1810
- if not text.endswith("\n"):
1811
- issues.append(Issue("warning", "no_trailing_newline", "File must end with exactly one newline"))
1812
-
1813
- return LintResult(
1814
- file=str(path),
1815
- artifact_type="guideline",
1816
- status=classify_status(issues),
1817
- issues=issues,
1818
- suggestions=[],
1819
- )
1820
-
1821
-
1822
- def lint_persona(path: Path, text: str) -> LintResult:
1823
- """Lint a persona .md file (frontmatter schema + required sections + size)."""
1824
- issues: List[Issue] = []
1825
-
1826
- # Frontmatter required
1827
- frontmatter = extract_frontmatter(text)
1828
- if not frontmatter:
1829
- issues.append(Issue("error", "missing_frontmatter", "Persona requires YAML frontmatter"))
1830
- return LintResult(
1831
- file=str(path),
1832
- artifact_type="persona",
1833
- status="fail",
1834
- issues=issues,
1835
- suggestions=["See .agent-src.uncondensed/templates/persona.md for the schema"],
1836
- )
1837
-
1838
- # Required frontmatter fields
1839
- required = {
1840
- "id": re.compile(r'^id:\s*"?([\w-]+)"?\s*$', re.MULTILINE),
1841
- "role": re.compile(r'^role:\s*"?(.+?)"?\s*$', re.MULTILINE),
1842
- "description": re.compile(r'^description:\s*"?(.+?)"?\s*$', re.MULTILINE),
1843
- "tier": re.compile(r'^tier:\s*"?(\w+)"?\s*$', re.MULTILINE),
1844
- }
1845
- # `version` (default "1.0") and `source` (default "package") carry schema
1846
- # defaults — they are injected at read time, so omitting them is valid.
1847
- # Validate the value only when present; never require presence.
1848
- optional_defaulted = {
1849
- "version": re.compile(r'^version:\s*"?(.+?)"?\s*$', re.MULTILINE),
1850
- "source": re.compile(r'^source:\s*"?(package|project)"?\s*$', re.MULTILINE),
1851
- }
1852
- parsed: dict = {}
1853
- for field, pattern in required.items():
1854
- value = extract_frontmatter_field(frontmatter, pattern)
1855
- if not value:
1856
- issues.append(Issue("error", f"missing_{field}", f"Persona frontmatter must declare `{field}`"))
1857
- else:
1858
- parsed[field] = value
1859
- for field, pattern in optional_defaulted.items():
1860
- value = extract_frontmatter_field(frontmatter, pattern)
1861
- if value:
1862
- parsed[field] = value
1863
-
1864
- # id matches filename stem
1865
- if "id" in parsed and parsed["id"] != path.stem:
1866
- issues.append(Issue(
1867
- "error",
1868
- "id_filename_mismatch",
1869
- f"Persona id `{parsed['id']}` must match filename stem `{path.stem}`",
1870
- ))
1871
-
1872
- # tier in valid set
1873
- if "tier" in parsed and parsed["tier"] not in VALID_PERSONA_TIERS:
1874
- issues.append(Issue(
1875
- "error",
1876
- "invalid_tier",
1877
- f"Persona tier `{parsed['tier']}` must be one of {sorted(VALID_PERSONA_TIERS)}",
1878
- ))
1879
-
1880
- # wing — optional; when present must be one of {1,2,3,4} (per
1881
- # docs/contracts/package-self-orientation.md § The four wings).
1882
- wing_match = re.search(r'^wing:\s*"?(\d+)"?\s*$', frontmatter, re.MULTILINE)
1883
- if wing_match:
1884
- try:
1885
- wing_value = int(wing_match.group(1))
1886
- if wing_value in VALID_PERSONA_WINGS:
1887
- parsed["wing"] = wing_value
1888
- else:
1889
- issues.append(Issue(
1890
- "error",
1891
- "invalid_wing",
1892
- f"Persona wing `{wing_value}` must be one of {sorted(VALID_PERSONA_WINGS)}",
1893
- ))
1894
- except ValueError:
1895
- issues.append(Issue(
1896
- "error",
1897
- "invalid_wing",
1898
- f"Persona wing `{wing_match.group(1)}` must be an integer 1–4",
1899
- ))
1900
-
1901
- # description length
1902
- if "description" in parsed and len(parsed["description"]) > 160:
1903
- issues.append(Issue(
1904
- "warning",
1905
- "long_description",
1906
- f"Persona description is {len(parsed['description'])} chars (target ≤ 160)",
1907
- ))
1908
-
1909
- # Required sections — tier-aware (per docs/contracts/persona-schema.md § 3).
1910
- # Core: 5 sections. Specialist: Core-5 + Critical Rules + Workflows.
1911
- sections = extract_sections(text)
1912
- tier = parsed.get("tier")
1913
- if tier == "specialist":
1914
- required_sections = REQUIRED_PERSONA_SECTIONS_SPECIALIST
1915
- else:
1916
- # Default to core sections when tier is missing or invalid; the
1917
- # tier-enum check above already raised an error in that case.
1918
- required_sections = REQUIRED_PERSONA_SECTIONS_CORE
1919
- for required_section in required_sections:
1920
- if required_section not in sections:
1921
- issues.append(Issue(
1922
- "error",
1923
- "missing_section",
1924
- f"Persona is missing required section `## {required_section}`",
1925
- ))
1926
-
1927
- # Unique Questions must have ≥ 3 bullet items
1928
- uq_block = extract_section_block(text, "Unique Questions")
1929
- if uq_block:
1930
- bullet_count = len(re.findall(r"^\s*[-*]\s+", uq_block, re.MULTILINE))
1931
- if bullet_count < 3:
1932
- issues.append(Issue(
1933
- "warning",
1934
- "too_few_unique_questions",
1935
- f"Persona has {bullet_count} unique questions (target ≥ 3)",
1936
- ))
1937
-
1938
- # Size budget by tier — wing-overrides apply when the persona declares a
1939
- # `wing:` field; defaults to the tier baseline otherwise.
1940
- if "tier" in parsed and parsed["tier"] in PERSONA_LINE_BUDGETS:
1941
- tier_value = parsed["tier"]
1942
- wing_value = parsed.get("wing")
1943
- budget = PERSONA_LINE_BUDGETS_BY_WING.get(
1944
- (tier_value, wing_value), PERSONA_LINE_BUDGETS[tier_value]
1945
- )
1946
- line_count = len(text.splitlines())
1947
- if line_count > budget:
1948
- scope = f"{tier_value}" if wing_value is None else f"{tier_value}, wing {wing_value}"
1949
- issues.append(Issue(
1950
- "warning",
1951
- "size_budget",
1952
- f"Persona has {line_count} lines ({scope} budget ≤ {budget})",
1953
- ))
1954
-
1955
- # H1 heading
1956
- if not H1_PATTERN.search(text):
1957
- issues.append(Issue("warning", "missing_h1", "Persona is missing an H1 heading"))
1958
-
1959
- # Trailing newline
1960
- if not text.endswith("\n"):
1961
- issues.append(Issue("warning", "no_trailing_newline", "File must end with exactly one newline"))
1962
-
1963
- return LintResult(
1964
- file=str(path),
1965
- artifact_type="persona",
1966
- status=classify_status(issues),
1967
- issues=issues,
1968
- suggestions=[],
1969
- )
1970
-
1971
-
1972
- def lint_usertype(path: Path, text: str) -> LintResult:
1973
- """Lint a user-type .md file (frontmatter schema + required sections + size).
1974
-
1975
- User-types are the runtime end-user simulation lens (sister axis to
1976
- personas — methodology vs end-user). Contract:
1977
- docs/contracts/user-type-schema.md.
1978
- """
1979
- issues: List[Issue] = []
1980
-
1981
- frontmatter = extract_frontmatter(text)
1982
- if not frontmatter:
1983
- issues.append(Issue("error", "missing_frontmatter", "User-type requires YAML frontmatter"))
1984
- return LintResult(
1985
- file=str(path),
1986
- artifact_type="user-type",
1987
- status="fail",
1988
- issues=issues,
1989
- suggestions=[".agent-src.uncondensed/user-types/_template/user-type.md"],
1990
- )
1991
-
1992
- # Required keys per docs/contracts/user-type-schema.md § 1.
1993
- required = {
1994
- "id": re.compile(r'^id:\s*"?([\w-]+)"?\s*$', re.MULTILINE),
1995
- "kind": re.compile(r'^kind:\s*"?([\w-]+)"?\s*$', re.MULTILINE),
1996
- "description": re.compile(r'^description:\s*"?([^"\n]+?)"?\s*$', re.MULTILINE),
1997
- "version": re.compile(r'^version:\s*"?([\d.]+)"?\s*$', re.MULTILINE),
1998
- "source": re.compile(r'^source:\s*"?(package|project)"?\s*$', re.MULTILINE),
1999
- }
2000
- parsed: dict = {}
2001
- for field, pattern in required.items():
2002
- value = extract_frontmatter_field(frontmatter, pattern)
2003
- if not value:
2004
- issues.append(Issue("error", f"missing_{field}", f"User-type frontmatter must declare `{field}`"))
2005
- else:
2006
- parsed[field] = value
2007
-
2008
- if "id" in parsed and parsed["id"] != path.stem:
2009
- issues.append(Issue(
2010
- "error",
2011
- "id_filename_mismatch",
2012
- f"User-type id `{parsed['id']}` must match filename stem `{path.stem}`",
2013
- ))
2014
-
2015
- if "kind" in parsed and parsed["kind"] != "user-type":
2016
- issues.append(Issue(
2017
- "error",
2018
- "invalid_kind",
2019
- f"User-type kind must be `user-type` (got `{parsed['kind']}`)",
2020
- ))
2021
-
2022
- if "description" in parsed and len(parsed["description"]) > 160:
2023
- issues.append(Issue(
2024
- "warning",
2025
- "long_description",
2026
- f"User-type description is {len(parsed['description'])} chars (target ≤ 160)",
2027
- ))
2028
-
2029
- sections = extract_sections(text)
2030
- for required_section in REQUIRED_USERTYPE_SECTIONS:
2031
- if required_section not in sections:
2032
- issues.append(Issue(
2033
- "error",
2034
- "missing_section",
2035
- f"User-type is missing required section `## {required_section}`",
2036
- ))
2037
-
2038
- # Anti-Generic Quality Bar: ≥ 3 Unique Questions
2039
- uq_block = extract_section_block(text, "Unique Questions")
2040
- if uq_block:
2041
- bullet_count = len(re.findall(r"^\s*[-*]\s+", uq_block, re.MULTILINE))
2042
- if bullet_count < 3:
2043
- issues.append(Issue(
2044
- "warning",
2045
- "too_few_unique_questions",
2046
- f"User-type has {bullet_count} unique questions (target ≥ 3)",
2047
- ))
2048
-
2049
- line_count = len(text.splitlines())
2050
- if line_count > USERTYPE_LINE_BUDGET:
2051
- issues.append(Issue(
2052
- "warning",
2053
- "size_budget",
2054
- f"User-type has {line_count} lines (budget ≤ {USERTYPE_LINE_BUDGET})",
2055
- ))
2056
-
2057
- if not H1_PATTERN.search(text):
2058
- issues.append(Issue("warning", "missing_h1", "User-type is missing an H1 heading"))
2059
-
2060
- if not text.endswith("\n"):
2061
- issues.append(Issue("warning", "no_trailing_newline", "File must end with exactly one newline"))
2062
-
2063
- return LintResult(
2064
- file=str(path),
2065
- artifact_type="user-type",
2066
- status=classify_status(issues),
2067
- issues=issues,
2068
- suggestions=[],
2069
- )
2070
-
2071
-
2072
- def gather_all_candidate_files(root: Path) -> list[Path]:
2073
- """Gather all lintable files across every source root (ADR-017 multi-root).
2074
-
2075
- Walks ``artefact_roots()`` (legacy ``.agent-src.uncondensed/`` plus every
2076
- ``packages/*/.agent-src.uncondensed/``). Falls back to ``dist/agent-src/``
2077
- only when no source root exists. Skips symlinks to avoid double-counting.
2078
- Deduplicates on logical relpath \u2014 first root wins per the agent_src
2079
- contract.
2080
- """
2081
- candidates: list[Path] = []
2082
- seen_logical: set[str] = set()
2083
-
2084
- def _add(file: Path, source_root: Path) -> None:
2085
- if file.is_symlink() or not file.is_file():
2086
- return
2087
- try:
2088
- logical = file.relative_to(source_root).as_posix()
2089
- except ValueError:
2090
- logical = file.name
2091
- # Namespace by artefact-kind subdir so the same skill name across
2092
- # packs would still dedupe (but the agent_src layout guarantees
2093
- # each logical path lives in exactly one root post-move).
2094
- if logical in seen_logical:
2095
- return
2096
- seen_logical.add(logical)
2097
- candidates.append(file)
2098
-
2099
- sources = artefact_roots()
2100
- if sources:
2101
- for src_root in sources:
2102
- for f in (src_root / "skills").rglob("SKILL.md") if (src_root / "skills").exists() else []:
2103
- _add(f, src_root)
2104
- for sub in ("rules", "commands", "guidelines"):
2105
- base = src_root / sub
2106
- if base.exists():
2107
- for f in base.rglob("*.md"):
2108
- _add(f, src_root)
2109
- for sub in ("personas", "user-types"):
2110
- base = src_root / sub
2111
- if base.exists():
2112
- for f in base.glob("*.md"):
2113
- if f.name.lower() == "readme.md":
2114
- continue
2115
- _add(f, src_root)
2116
- charter = src_root / FRUGALITY_CHARTER_RELPATH
2117
- if charter.exists() and not charter.is_symlink():
2118
- _add(charter, src_root)
2119
- else:
2120
- # Pure-condensed fallback (dist/agent-src/ only). Used by consumer
2121
- # projects that vendor the condensed tree without sources.
2122
- augment_root = root / "dist/agent-src"
2123
- if augment_root.exists():
2124
- for sub_pattern in (
2125
- ("skills", "SKILL.md"),
2126
- ("rules", "*.md"),
2127
- ("commands", "*.md"),
2128
- ("guidelines", "*.md"),
2129
- ):
2130
- base = augment_root / sub_pattern[0]
2131
- if base.exists():
2132
- for f in base.rglob(sub_pattern[1]):
2133
- _add(f, augment_root)
2134
- for sub in ("personas", "user-types"):
2135
- base = augment_root / sub
2136
- if base.exists():
2137
- for f in base.glob("*.md"):
2138
- if f.name.lower() == "readme.md":
2139
- continue
2140
- _add(f, augment_root)
2141
- charter = augment_root / FRUGALITY_CHARTER_RELPATH
2142
- if charter.exists() and not charter.is_symlink():
2143
- _add(charter, augment_root)
2144
-
2145
- return sorted(set(candidates))
2146
-
2147
-
2148
- def gather_candidate_files_under(src_root: Path) -> list[Path]:
2149
- """Gather lintable files under an arbitrary source root.
2150
-
2151
- Mirrors the per-root walk used by ``gather_all_candidate_files`` but
2152
- scoped to a single directory \u2014 e.g. ``packages/pack-laravel/.agent-src.uncondensed/``
2153
- so CI can lint a single pack in parallel (ADR-017 Phase 4.4).
2154
- Skips symlinks and ``README.md`` siblings under ``personas/`` /
2155
- ``user-types/``.
2156
- """
2157
- out: list[Path] = []
2158
- if not src_root.is_dir():
2159
- return out
2160
- seen: set[Path] = set()
2161
-
2162
- def _push(file: Path) -> None:
2163
- if file.is_symlink() or not file.is_file():
2164
- return
2165
- resolved = file.resolve()
2166
- if resolved in seen:
2167
- return
2168
- seen.add(resolved)
2169
- out.append(file)
2170
-
2171
- skills_dir = src_root / "skills"
2172
- if skills_dir.exists():
2173
- for f in skills_dir.rglob("SKILL.md"):
2174
- _push(f)
2175
- for sub in ("rules", "commands", "guidelines"):
2176
- base = src_root / sub
2177
- if base.exists():
2178
- for f in base.rglob("*.md"):
2179
- _push(f)
2180
- for sub in ("personas", "user-types"):
2181
- base = src_root / sub
2182
- if base.exists():
2183
- for f in base.glob("*.md"):
2184
- if f.name.lower() == "readme.md":
2185
- continue
2186
- _push(f)
2187
- charter = src_root / FRUGALITY_CHARTER_RELPATH
2188
- if charter.exists() and not charter.is_symlink():
2189
- _push(charter)
2190
- return sorted(set(out))
2191
-
2192
-
2193
- def gather_changed_candidate_files(root: Path) -> list[Path]:
2194
- """Find changed skill/rule files using git diff.
2195
-
2196
- Tries multiple strategies:
2197
- 1. CI: diff against origin/main (PR changes)
2198
- 2. Local: staged changes (git diff --cached)
2199
- 3. Fallback: unstaged changes (git diff HEAD)
2200
- """
2201
- diff_commands = [
2202
- ["git", "diff", "--name-only", "origin/main...HEAD"],
2203
- ["git", "diff", "--name-only", "--cached", "HEAD"],
2204
- ["git", "diff", "--name-only", "HEAD"],
2205
- ]
2206
- try:
2207
- raw_lines: list[str] = []
2208
- for cmd in diff_commands:
2209
- result = subprocess.run(
2210
- cmd, cwd=root, text=True, capture_output=True, check=False,
2211
- )
2212
- if result.returncode == 0 and result.stdout.strip():
2213
- raw_lines = result.stdout.splitlines()
2214
- break
2215
-
2216
- files = []
2217
- for raw in raw_lines:
2218
- raw = raw.strip()
2219
- if not raw:
2220
- continue
2221
- path = root / raw
2222
- if not path.exists():
2223
- continue
2224
- # Skip symlinks to avoid double-counting (e.g. .claude/skills/ → dist/agent-src/commands/)
2225
- if path.is_symlink():
2226
- continue
2227
- norm = raw.replace("\\", "/")
2228
- # Only lint source-of-truth and source-mirror dirs. Projection
2229
- # dirs (.windsurf/, .cursor/, .clinerules/, .claude/) use
2230
- # tool-native frontmatter (e.g. Windsurf's trigger/globs) that
2231
- # the linter does not validate — they regenerate from source.
2232
- # ADR-017: accept legacy flat layout AND
2233
- # packages/*/.agent-src.uncondensed/ paths.
2234
- in_source = (
2235
- norm.startswith(".agent-src.uncondensed/")
2236
- or norm.startswith("dist/agent-src/")
2237
- or "/.agent-src.uncondensed/" in norm
2238
- or "/dist/agent-src/" in norm
2239
- )
2240
- if not in_source:
2241
- continue
2242
- # Only .md artefacts are lintable. Skip data sidecars under
2243
- # `evals/` (e.g. commands/evals/<stem>.json routing evals, 6.0.0-C)
2244
- # — they are not commands/rules and have no frontmatter/H1.
2245
- is_md = path.suffix == ".md"
2246
- in_evals = "/evals/" in norm
2247
- if not in_evals and (
2248
- path.name == "SKILL.md"
2249
- or (is_md and ("/rules/" in norm or "/commands/" in norm))
2250
- ):
2251
- files.append(path)
2252
- return sorted(set(files))
2253
- except Exception:
2254
- return []
2255
-
2256
-
2257
- # --- Interaction quality checks (keyword-based, for meta/interaction artifacts only) ---
2258
-
2259
- # File name patterns that indicate an interaction/meta artifact (strict — avoids false positives)
2260
- _INTERACTION_NAME_PATTERNS = re.compile(
2261
- r"skill-router|handoff|analysis-skill|skill-writing|skill-reviewer|"
2262
- r"model-recommendation|developer-like-execution|universal-project-analysis|"
2263
- r"interaction|autonomous-mode|feature-planning",
2264
- re.IGNORECASE,
2265
- )
2266
- _INTERACTION_CONTENT_KEYWORDS = {"handoff", "model switch", "clarification", "ask the user", "framework choice", "requirements are unclear"}
2267
-
2268
-
2269
- def _is_interaction_artifact(path: Path, text: str) -> bool:
2270
- """Check if file is an interaction/meta artifact that should get question-quality checks."""
2271
- name = str(path).lower()
2272
- # Strict name match — only truly interaction-focused artifacts
2273
- if _INTERACTION_NAME_PATTERNS.search(name):
2274
- return True
2275
- # Content match needs 3+ keywords to avoid false positives on analysis/coding skills
2276
- text_lower = text.lower()
2277
- matches = sum(1 for kw in _INTERACTION_CONTENT_KEYWORDS if kw in text_lower)
2278
- return matches >= 3
2279
-
2280
-
2281
- def lint_interaction_quality(path: Path, text: str) -> List[Issue]:
2282
- """Check interaction/meta artifacts for question strategy, handoff order, etc."""
2283
- if not _is_interaction_artifact(path, text):
2284
- return []
2285
-
2286
- issues: List[Issue] = []
2287
- text_lower = text.lower()
2288
-
2289
- # Only check files that explicitly discuss user questioning strategy
2290
- has_question_context = any(kw in text_lower for kw in (
2291
- "ask the user", "ask clarification", "numbered options", "present options",
2292
- "question strategy", "ask before",
2293
- ))
2294
-
2295
- # Check 1: Question strategy — distinguishes simple grouped vs complex sequential
2296
- if has_question_context:
2297
- has_simple = any(kw in text_lower for kw in ("simple", "binary", "independent"))
2298
- has_complex = any(kw in text_lower for kw in ("complex", "one at a time", "one question"))
2299
- if not (has_simple and has_complex):
2300
- issues.append(Issue("warning", "question_strategy_missing",
2301
- "Interaction guidance does not distinguish simple grouped questions "
2302
- "from complex sequential questions"))
2303
-
2304
- # Check 2: Handoff ordering — handoff/model-switch questions should come last
2305
- has_handoff = any(kw in text_lower for kw in ("handoff", "model switch", "model-switch"))
2306
- if has_handoff:
2307
- has_ordering = any(kw in text_lower for kw in (
2308
- "last", "after context", "after clarification", "after all",
2309
- ))
2310
- if not has_ordering:
2311
- issues.append(Issue("warning", "handoff_order_missing",
2312
- "Handoff/model-switch guidance does not specify asking handoff "
2313
- "questions AFTER context/domain questions"))
2314
-
2315
- # Check 3: Framework choice guard — only when file explicitly discusses choosing between systems
2316
- has_impl = any(kw in text_lower for kw in ("implement", "component", "ui component", "ui framework"))
2317
- has_multi = any(kw in text_lower for kw in ("multiple frameworks", "multiple systems", "competing", "which framework"))
2318
- if has_impl and has_multi:
2319
- has_guard = any(kw in text_lower for kw in (
2320
- "ask which", "ask before", "do not implement blindly", "analyze what exists",
2321
- "do not pick", "clarif",
2322
- ))
2323
- if not has_guard:
2324
- issues.append(Issue("warning", "framework_choice_guard_missing",
2325
- "Discusses implementation choices but does not require clarification "
2326
- "when multiple frameworks/patterns exist"))
2327
-
2328
- # Check 4: Clarification guard — only for files with explicit interaction/execution guidance
2329
- has_execution_guidance = any(kw in text_lower for kw in ("procedure", "workflow", "step 1", "### 1."))
2330
- if has_execution_guidance:
2331
- has_clarification = any(kw in text_lower for kw in (
2332
- "requirements are unclear", "ask clarification", "do not assume",
2333
- "clarification question", "missing instructions", "incomplete",
2334
- ))
2335
- if not has_clarification:
2336
- issues.append(Issue("info", "clarification_guard_missing",
2337
- "Contains action guidance but no explicit clarification behavior "
2338
- "for incomplete requirements"))
2339
-
2340
- # Check 5: Feedback learning — meta/reviewer artifacts should support learning
2341
- is_meta = any(kw in str(path).lower() for kw in ("review", "improve", "learn", "audit", "optim"))
2342
- if is_meta:
2343
- has_learning = any(kw in text_lower for kw in (
2344
- "learning", "feedback", "frustration", "capture", "improve the system",
2345
- "rule / skill", "rule/skill",
2346
- ))
2347
- if not has_learning:
2348
- issues.append(Issue("info", "feedback_learning_missing",
2349
- "Meta/reviewer artifact does not mention learning from negative "
2350
- "feedback or converting failures into system improvements"))
2351
-
2352
- return issues
2353
-
2354
-
2355
- # --- Execution quality checks ---
2356
-
2357
- # File name signals for execution-oriented artifacts
2358
- _EXEC_FILE_SIGNALS = (
2359
- "execution", "debug", "implement", "developer", "action",
2360
- "validation", "testing", "coder", "bug", "fix",
2361
- )
2362
-
2363
- # Content signals that indicate execution-oriented artifact
2364
- _EXEC_CONTENT_SIGNALS = (
2365
- "implement", "debug", "refactor", "modify", "fix",
2366
- "verify", "validate", "runtime", "test", "coding",
2367
- "before acting", "before coding", "before changing",
2368
- )
2369
-
2370
-
2371
- def _is_execution_artifact(path: Path, text: str) -> bool:
2372
- """Detect if artifact is execution/implementation oriented.
2373
-
2374
- Only skills and rules qualify — commands and guidelines are excluded
2375
- because commands are workflows (not execution guidance) and guidelines
2376
- are coding patterns (not developer workflow enforcement).
2377
- """
2378
- path_lower = str(path).lower()
2379
- text_lower = text.lower()
2380
-
2381
- # Exclude commands, guidelines, personas, user-types — not execution-oriented
2382
- if (
2383
- "/commands/" in path_lower
2384
- or "/guidelines/" in path_lower
2385
- or "/personas/" in path_lower
2386
- or "/user-types/" in path_lower
2387
- ):
2388
- return False
2389
-
2390
- # File name match — strong signal
2391
- if any(sig in path_lower for sig in _EXEC_FILE_SIGNALS):
2392
- return True
2393
-
2394
- # Content match — need at least 5 signals to avoid false positives
2395
- # (many artifacts mention "implement" or "fix" without being execution-focused)
2396
- matches = sum(1 for sig in _EXEC_CONTENT_SIGNALS if sig in text_lower)
2397
- return matches >= 5
2398
-
2399
-
2400
- def lint_execution_quality(path: Path, text: str) -> List[Issue]:
2401
- """Check execution-oriented artifacts for developer workflow quality."""
2402
- if not _is_execution_artifact(path, text):
2403
- return []
2404
-
2405
- issues: List[Issue] = []
2406
- text_lower = text.lower()
2407
- path_lower = str(path).lower()
2408
-
2409
- # Strong match = file name signal; weak match = content-only signal
2410
- is_strong_match = any(sig in path_lower for sig in _EXEC_FILE_SIGNALS)
2411
-
2412
- # --- Signal groups ---
2413
- # Each group uses broad synonyms to reduce false negatives.
2414
- # Skills often express analysis/verification concepts without using
2415
- # the exact words "analyze" or "verify".
2416
- analysis_signals = (
2417
- "analyze", "inspect", "understand", "read relevant",
2418
- "review existing", "trace flow", "read affected",
2419
- "check current", "before acting", "before coding",
2420
- # Synonyms added in Phase 2b
2421
- "examine", "study", "investigate", "check existing",
2422
- "gather context", "read project", "read the changelog",
2423
- "identify break", "assess", "before upgrading",
2424
- "before changing", "before creating", "before modifying",
2425
- "read docs", "read module", "read agents",
2426
- )
2427
-
2428
- verification_signals = (
2429
- "verify", "validate", "test", "real execution",
2430
- "run endpoint", "playwright", "curl", "postman",
2431
- "debugger", "run tests", "hit the endpoint",
2432
- # Synonyms added in Phase 2b
2433
- "confirm", "assert", "check result", "observe",
2434
- "run phpstan", "run rector", "build and verify",
2435
- "must pass", "response shape",
2436
- )
2437
-
2438
- verification_tool_signals = (
2439
- "playwright", "curl", "postman", "xdebug",
2440
- "browser", "http::fake",
2441
- # Synonyms added in Phase 2b
2442
- "phpstan", "rector", "phpunit", "pest",
2443
- "devcontainer build",
2444
- )
2445
-
2446
- debug_runtime_signals = (
2447
- "debugger", "xdebug", "mcp debugger", "runtime inspection",
2448
- "trace execution", "breakpoint", "step through",
2449
- # Synonyms added in Phase 2b
2450
- "runtime", "stack trace", "dump", "dd(",
2451
- )
2452
-
2453
- efficient_tooling_signals = (
2454
- "jq", " rg ", "grep", "filter", "selective",
2455
- "extract", "targeted", "--json", "--filter",
2456
- # Synonyms added in Phase 2b
2457
- "narrow", "scoped", "specific field", "only relevant",
2458
- )
2459
-
2460
- anti_bruteforce_signals = (
2461
- "avoid retr", "do not brute", "do not guess",
2462
- "do not retry blind", "analyze before retry",
2463
- "blind retr", "trial-and-error", "trial and error",
2464
- "max 2 retries", "stop and rethink",
2465
- # Synonyms added in Phase 2b
2466
- "diagnose", "root cause", "targeted fix",
2467
- "do not blindly", "never guess",
2468
- )
2469
-
2470
- clarification_signals = (
2471
- "ask", "clarif", "unclear", "missing information",
2472
- "do not assume", "don't assume", "instead of assuming",
2473
- # Synonyms added in Phase 2b
2474
- "confirm with user", "verify requirement", "ambiguous",
2475
- "if unsure", "when in doubt",
2476
- )
2477
-
2478
- # Helper
2479
- def has_any(signals: tuple[str, ...]) -> bool:
2480
- return any(s in text_lower for s in signals)
2481
-
2482
- # --- Section-based detection (complement to keyword matching) ---
2483
- # Detects structural signals: sections whose names imply analysis or verification.
2484
- import re
2485
- section_headers = re.findall(r'^#{1,4}\s+(.+)$', text, re.MULTILINE)
2486
- section_headers_lower = [h.lower() for h in section_headers]
2487
-
2488
- # Section names that imply analysis-before-action
2489
- has_analysis_section = any(
2490
- any(kw in h for kw in ("understand", "analyze", "assess", "context", "review",
2491
- "current setup", "current state", "before"))
2492
- for h in section_headers_lower
2493
- )
2494
-
2495
- # Section names that imply verification
2496
- has_verification_section = any(
2497
- any(kw in h for kw in ("verify", "validat", "test", "acceptance", "quality gate"))
2498
- for h in section_headers_lower
2499
- )
2500
-
2501
- # Section names that imply anti-patterns / gotchas
2502
- has_antipattern_section = any(
2503
- any(kw in h for kw in ("do not", "don't", "gotcha", "anti-pattern", "avoid"))
2504
- for h in section_headers_lower
2505
- )
2506
-
2507
- # Detect implementation/change language
2508
- change_signals = ("implement", "modify", "fix", "refactor", "change", "update", "code")
2509
- has_change_language = any(s in text_lower for s in change_signals)
2510
-
2511
- # Combine keyword + section signals
2512
- has_analysis = has_any(analysis_signals) or has_analysis_section
2513
- has_verification = has_any(verification_signals) or has_verification_section
2514
-
2515
- # --- Check 1: Missing analysis-before-action (ERROR, skills only) ---
2516
- # Rules describe constraints, not workflows — they don't need analysis sections
2517
- is_skill = "/skills/" in str(path).lower()
2518
- if is_skill and has_change_language and not has_analysis:
2519
- issues.append(Issue("error", "missing_analysis_before_action",
2520
- "Execution-oriented skill encourages implementation "
2521
- "without requiring prior analysis of existing system"))
2522
-
2523
- # --- Check 2: Missing real verification (ERROR, skills with strong match) ---
2524
- if is_skill and is_strong_match and has_change_language and not has_verification:
2525
- issues.append(Issue("error", "missing_real_verification",
2526
- "Implementation/debugging skill does not require "
2527
- "real verification after changes"))
2528
-
2529
- # Checks 3-7 only apply to strong matches (file name signal) to avoid noise
2530
- # on generic skills that happen to mention "implement" or "fix"
2531
- if is_strong_match:
2532
- # --- Check 3: Missing verification tool mapping (WARNING) ---
2533
- if has_any(verification_signals) and not has_any(verification_tool_signals):
2534
- issues.append(Issue("warning", "missing_verification_tool_mapping",
2535
- "Verification is generic — does not reference concrete "
2536
- "tools (Playwright, curl, Postman, Xdebug)"))
2537
-
2538
- # --- Check 4: Missing runtime debug guidance (WARNING) ---
2539
- debug_context = any(s in text_lower for s in ("debug", "execution flow", "trace", "unexpected behavior"))
2540
- if debug_context and not has_any(debug_runtime_signals):
2541
- issues.append(Issue("warning", "missing_runtime_debug_guidance",
2542
- "Debugging/execution artifact does not mention "
2543
- "runtime debug tools (Xdebug, debugger, breakpoints)"))
2544
-
2545
- # --- Check 5: Missing efficient tooling guidance (WARNING) ---
2546
- data_context = any(s in text_lower for s in ("api", "log", "json", "response", "output", "data"))
2547
- if data_context and not has_any(efficient_tooling_signals):
2548
- issues.append(Issue("warning", "missing_efficient_tooling_guidance",
2549
- "Artifact does not encourage targeted filtering tools "
2550
- "(jq, rg, grep) for reducing output"))
2551
-
2552
- # --- Check 6: Missing anti-bruteforce guidance (WARNING, skills only) ---
2553
- if is_skill and has_change_language and not has_any(anti_bruteforce_signals):
2554
- issues.append(Issue("warning", "missing_anti_bruteforce_guidance",
2555
- "Execution guidance lacks explicit anti-retry / "
2556
- "anti-bruteforce behavior"))
2557
-
2558
- # --- Check 7: Missing clarification guard (WARNING, skills only) ---
2559
- if is_skill and has_change_language and not has_any(clarification_signals):
2560
- issues.append(Issue("warning", "missing_clarification_guard",
2561
- "Implementation guidance does not require clarification "
2562
- "when requirements are incomplete"))
2563
-
2564
- return issues
2565
-
2566
-
2567
- # --- Type boundary checks ---
2568
-
2569
-
2570
- def lint_type_boundaries(path: Path, text: str, artifact_type: str) -> List[Issue]:
2571
- """Check that artifacts respect their type boundaries.
2572
-
2573
- - Guidelines should not contain executable procedures
2574
- - Commands should reference skills
2575
- - Skills should have concrete validation (not vague)
2576
- """
2577
- issues: List[Issue] = []
2578
- text_lower = text.lower()
2579
- import re
2580
-
2581
- # --- Guideline: should not have executable procedures ---
2582
- if artifact_type == "guideline":
2583
- # Count numbered steps (1. 2. 3. etc.) — guidelines shouldn't have >5
2584
- numbered_steps = re.findall(r'^\d+\.\s+\*?\*?(?:Step|Run|Create|Execute|Implement)',
2585
- text, re.MULTILINE | re.IGNORECASE)
2586
- if len(numbered_steps) >= 5:
2587
- issues.append(Issue("warning", "guideline_contains_executable_procedure",
2588
- f"Guideline has {len(numbered_steps)} executable numbered steps — "
2589
- "consider extracting into a skill or command"))
2590
-
2591
- # --- Command: should reference skills ---
2592
- if artifact_type == "command":
2593
- # Check frontmatter skills field
2594
- frontmatter = extract_frontmatter(text)
2595
- has_skills_field = False
2596
- # Commands tagged `type: orchestrator` aggregate other commands /
2597
- # routers — they intentionally do not declare a `skills:` list and
2598
- # are exempt from the no-skill-reference check. The tag is the
2599
- # contract; no hard-coded path list.
2600
- is_orchestrator = False
2601
- if frontmatter:
2602
- skills_match = re.search(r'skills:\s*\[(.+)\]', frontmatter)
2603
- has_skills_field = bool(skills_match and skills_match.group(1).strip())
2604
- type_match = re.search(r'^type:\s*[\'"]?orchestrator[\'"]?\s*$',
2605
- frontmatter, re.MULTILINE)
2606
- is_orchestrator = bool(type_match)
2607
-
2608
- # Also check body for skill references
2609
- has_skill_ref = bool(re.search(r'skill|SKILL\.md', text))
2610
-
2611
- if not has_skills_field and not has_skill_ref and not is_orchestrator:
2612
- issues.append(Issue("warning", "command_missing_skill_references",
2613
- "Command does not reference any skills — "
2614
- "commands should orchestrate skills, not contain domain logic "
2615
- "(use `type: orchestrator` in frontmatter to exempt routers)"))
2616
-
2617
- # --- Skill: validation should be concrete, not vague ---
2618
- if artifact_type == "skill":
2619
- # Find validation/verify sections
2620
- validation_section = re.search(
2621
- r'(?:^#{1,4}\s+(?:Validat|Verif|Quality|Accept).+?\n)((?:.*\n)*?)(?=^#{1,4}\s|\Z)',
2622
- text, re.MULTILINE | re.IGNORECASE
2623
- )
2624
- if validation_section:
2625
- validation_text = validation_section.group(1).lower()
2626
- vague_patterns = ("check if it works", "make sure it's correct",
2627
- "verify it works", "should work", "looks correct")
2628
- concrete_patterns = ("run ", "curl ", "phpstan", "rector", "pest",
2629
- "playwright", "assert", "exit code", "must pass",
2630
- "0 fail", "0 error")
2631
- has_vague = any(p in validation_text for p in vague_patterns)
2632
- has_concrete = any(p in validation_text for p in concrete_patterns)
2633
- if has_vague and not has_concrete:
2634
- issues.append(Issue("warning", "skill_validation_too_generic",
2635
- "Validation section uses vague language — "
2636
- "add concrete checks (commands, expected output, conditions)"))
2637
-
2638
- return issues
2639
-
2640
-
2641
- # --- Verification maturity checks ---
2642
-
2643
- # Task type detection signals
2644
- _TASK_TYPE_SIGNALS = {
2645
- "backend": ("api", "endpoint", "controller", "route", "service", "repository",
2646
- "eloquent", "migration", "artisan", "middleware", "job", "queue"),
2647
- "frontend": ("blade", "livewire", "component", "view", "ui", "frontend",
2648
- "tailwind", "flux", "css", "template"),
2649
- "cli": ("artisan command", "cli", "console", "schedule", "cron"),
2650
- "database": ("migration", "database", "schema", "index", "query", "sql",
2651
- "mariadb", "mysql", "seeder"),
2652
- "debugging": ("debug", "xdebug", "error", "exception", "sentry", "trace",
2653
- "breakpoint", "log"),
2654
- }
2655
-
2656
- # Expected verification tools per task type
2657
- _VERIFICATION_TOOLS = {
2658
- "backend": ("curl", "postman", "http::fake", "actingas", "api/"),
2659
- "frontend": ("playwright", "browser", "screenshot", "snapshot", "livewire test"),
2660
- "cli": ("exit code", "command output", "artisan test", "expectsoutput"),
2661
- "database": ("query", "assertdatabase", "migration", "seedandassert", "table"),
2662
- "debugging": ("xdebug", "breakpoint", "dump", "dd(", "stack trace", "log"),
2663
- }
2664
-
2665
-
2666
- def lint_verification_maturity(path: Path, text: str, artifact_type: str) -> List[Issue]:
2667
- """Check that verification matches the skill's task type."""
2668
- if artifact_type != "skill":
2669
- return []
2670
-
2671
- # Only check skills with strong execution signals
2672
- path_lower = str(path).lower()
2673
- if not any(sig in path_lower for sig in _EXEC_FILE_SIGNALS):
2674
- return []
2675
-
2676
- issues: List[Issue] = []
2677
- text_lower = text.lower()
2678
-
2679
- # Detect task types present in the skill
2680
- detected_types: list[str] = []
2681
- for task_type, signals in _TASK_TYPE_SIGNALS.items():
2682
- matches = sum(1 for s in signals if s in text_lower)
2683
- if matches >= 2: # Need at least 2 signals to classify
2684
- detected_types.append(task_type)
2685
-
2686
- if not detected_types:
2687
- return []
2688
-
2689
- # Check if appropriate verification tools are mentioned
2690
- for task_type in detected_types:
2691
- tools = _VERIFICATION_TOOLS.get(task_type, ())
2692
- has_tool = any(t in text_lower for t in tools)
2693
- if not has_tool:
2694
- issues.append(Issue("warning", f"missing_{task_type}_verification_example",
2695
- f"Skill covers {task_type} tasks but does not mention "
2696
- f"verification tools for that context "
2697
- f"(e.g. {', '.join(tools[:3])})"))
2698
-
2699
- return issues
2700
-
2701
-
2702
- # --- Governance & packaging checks ---
2703
-
2704
-
2705
- # --- Frugality validator helpers + Layers 1 & 2 ---
2706
-
2707
- def _heading_to_slug(heading: str) -> str:
2708
- """Slugify a markdown heading using GitHub's algorithm: lowercase,
2709
- drop punctuation (em-dash, period, etc.), spaces -> hyphens,
2710
- preserve adjacent hyphens (so `Iron Law 3 — Brevity` becomes
2711
- `iron-law-3--brevity`, matching the anchor GitHub renders)."""
2712
- s = heading.strip().lower()
2713
- s = re.sub(r"[^a-z0-9 \-]", "", s)
2714
- s = s.replace(" ", "-")
2715
- return s.strip("-")
2716
-
2717
-
2718
- def _extract_heading_slugs(text: str) -> set[str]:
2719
- """Return the set of slugs for every H2/H3 heading in a markdown body."""
2720
- slugs: set[str] = set()
2721
- for line in text.splitlines():
2722
- if line.startswith("## ") or line.startswith("### "):
2723
- heading = line.split(" ", 1)[1].strip()
2724
- slugs.add(_heading_to_slug(heading))
2725
- return slugs
2726
-
2727
-
2728
- def _skill_id_from_path(path: Path) -> Optional[str]:
2729
- """Extract the writer-skill id from a SKILL.md path. Returns the
2730
- parent-directory name, or None if the file is not a SKILL.md."""
2731
- if path.name.lower() != "skill.md":
2732
- return None
2733
- return path.parent.name
2734
-
2735
-
2736
- def _is_frugality_charter(path: Path) -> bool:
2737
- """True iff the path ends in the canonical charter relpath, regardless
2738
- of whether it lives under dist/agent-src/ or .agent-src.uncondensed/."""
2739
- norm = str(path).replace("\\", "/")
2740
- return norm.endswith("/" + FRUGALITY_CHARTER_RELPATH)
2741
-
2742
-
2743
- # Section header recognised by Layer 1. Literal H2 only — sub-headings
2744
- # inside the section do not count as the section itself.
2745
- _FRUGALITY_STANDARDS_PATTERN = re.compile(
2746
- r"^##\s+Frugality Standards\s*$", re.MULTILINE
2747
- )
2748
- _FRUGALITY_CHARTER_LINK_PATTERN = re.compile(
2749
- r"\]\([^)]*frugality-charter\.md[^)]*\)"
2750
- )
2751
-
2752
-
2753
- def lint_frugality_writer_cite(path: Path, text: str,
2754
- artifact_type: str) -> List[Issue]:
2755
- """Layer 1 — every writer skill must carry a `## Frugality Standards`
2756
- section that links to the charter. No-op for non-writer skills and
2757
- non-skill artifacts."""
2758
- if artifact_type != "skill":
2759
- return []
2760
- skill_id = _skill_id_from_path(path)
2761
- if skill_id is None or skill_id not in FRUGALITY_WRITER_SKILLS:
2762
- return []
2763
- issues: List[Issue] = []
2764
- section_match = _FRUGALITY_STANDARDS_PATTERN.search(text)
2765
- if not section_match:
2766
- issues.append(Issue(
2767
- "error", "frugality_section_missing",
2768
- "Writer skill must carry a `## Frugality Standards` section "
2769
- "(road-to-token-frugality Phase 0.4 Layer 1)",
2770
- ))
2771
- return issues
2772
- # Section body = from match-end to next H2 or EOF.
2773
- body_start = section_match.end()
2774
- next_h2 = re.search(r"^##\s+", text[body_start:], re.MULTILINE)
2775
- body_end = body_start + next_h2.start() if next_h2 else len(text)
2776
- body = text[body_start:body_end]
2777
- if not _FRUGALITY_CHARTER_LINK_PATTERN.search(body):
2778
- issues.append(Issue(
2779
- "error", "frugality_charter_cite_missing",
2780
- "`## Frugality Standards` section must link to "
2781
- "`frugality-charter.md` (road-to-token-frugality Phase 0.4 "
2782
- "Layer 1)",
2783
- ))
2784
- return issues
2785
-
2786
-
2787
- # Markdown link pattern: [text](path#anchor) — anchor optional.
2788
- _MD_LINK_PATTERN = re.compile(
2789
- r"\[[^\]]+\]\(([^)#]+)(?:#([^)]+))?\)"
2790
- )
2791
-
2792
-
2793
- def lint_frugality_charter_index(path: Path, text: str) -> List[Issue]:
2794
- """Layer 2 — every cited anchor must resolve to a real H2/H3 heading
2795
- in the target rule file, AND each of the four canonical rules must
2796
- be cited at least once with the required canonical anchor substring.
2797
- Additional citations to the same rule (net-new sections referencing
2798
- other anchors) are validated for resolution but do not need the
2799
- canonical substring."""
2800
- if not _is_frugality_charter(path):
2801
- return []
2802
- issues: List[Issue] = []
2803
- rules_dir = path.parent.parent.parent / "rules"
2804
- rule_slugs_cache: dict[str, set[str]] = {}
2805
- canonical_satisfied: set[str] = set()
2806
- for link_match in _MD_LINK_PATTERN.finditer(text):
2807
- link_path, link_anchor = link_match.group(1), link_match.group(2)
2808
- rule_name = Path(link_path).name
2809
- if rule_name not in FRUGALITY_CHARTER_INDEX_RULES:
2810
- continue
2811
- if link_anchor is None:
2812
- continue
2813
- anchor_lc = link_anchor.lower()
2814
- required_substr = FRUGALITY_CHARTER_INDEX_RULES[rule_name]
2815
- if required_substr in anchor_lc:
2816
- canonical_satisfied.add(rule_name)
2817
- if rule_name not in rule_slugs_cache:
2818
- rule_file = rules_dir / rule_name
2819
- if not rule_file.exists():
2820
- issues.append(Issue(
2821
- "error", "frugality_charter_rule_missing",
2822
- f"Charter cites {rule_name} but the rule file does "
2823
- f"not exist at {rule_file}",
2824
- ))
2825
- rule_slugs_cache[rule_name] = set()
2826
- continue
2827
- try:
2828
- rule_text = rule_file.read_text(encoding="utf-8")
2829
- except OSError as e:
2830
- issues.append(Issue(
2831
- "error", "frugality_charter_rule_unreadable",
2832
- f"Cannot read {rule_name}: {e}",
2833
- ))
2834
- rule_slugs_cache[rule_name] = set()
2835
- continue
2836
- rule_slugs_cache[rule_name] = _extract_heading_slugs(rule_text)
2837
- if anchor_lc not in rule_slugs_cache[rule_name]:
2838
- issues.append(Issue(
2839
- "error", "frugality_charter_anchor_unresolved",
2840
- f"Charter cites {rule_name}#{link_anchor} but no H2/H3 "
2841
- f"heading with that slug exists in the rule file",
2842
- ))
2843
- missing = set(FRUGALITY_CHARTER_INDEX_RULES) - canonical_satisfied
2844
- for rule_name in sorted(missing):
2845
- required_substr = FRUGALITY_CHARTER_INDEX_RULES[rule_name]
2846
- issues.append(Issue(
2847
- "error", "frugality_charter_canonical_missing",
2848
- f"Charter index lacks a canonical citation of {rule_name} "
2849
- f"with anchor containing '{required_substr}' "
2850
- f"(road-to-token-frugality Phase 0.4 Layer 2)",
2851
- ))
2852
- return issues
2853
-
2854
-
2855
- def lint_governance(path: Path, text: str, artifact_type: str, repo_root: Path | None = None) -> List[Issue]:
2856
- """Check governance and packaging consistency.
2857
-
2858
- - Condensed/uncondensed pairs must exist
2859
- - No duplicate skill names
2860
- - Files must be in correct location for their type
2861
- """
2862
- issues: List[Issue] = []
2863
- if repo_root is None:
2864
- return issues
2865
-
2866
- path_str = str(path)
2867
- path_relative = path_str
2868
-
2869
- # Determine if this is a condensed or uncondensed artifact
2870
- is_condensed = "/dist/agent-src/" in path_str and "/.agent-src.uncondensed/" not in path_str
2871
- is_uncondensed = "/.agent-src.uncondensed/" in path_str
2872
-
2873
- if not is_condensed and not is_uncondensed:
2874
- return issues
2875
-
2876
- # --- Check: condensed/uncondensed pair exists ---
2877
- # ADR-017: sources live under packages/*/.agent-src.uncondensed/ but
2878
- # all packs project into the single repo-root dist/agent-src/ tree. The
2879
- # pair-check now resolves via logical relpath, not a path-swap.
2880
- from _lib.agent_src import strip_source_prefix as _strip
2881
- norm = path_str.replace("\\", "/")
2882
- if is_uncondensed:
2883
- # Compute logical path then map to dist/agent-src/ at repo root.
2884
- # Try direct strip first; fall back to substring split for absolute paths.
2885
- logical = _strip(norm)
2886
- if logical is None:
2887
- marker = "/.agent-src.uncondensed/"
2888
- idx = norm.rfind(marker)
2889
- logical = norm[idx + len(marker):] if idx != -1 else None
2890
- if logical:
2891
- condensed_path = repo_root / "dist/agent-src" / logical
2892
- if not condensed_path.exists():
2893
- issues.append(Issue("warning", "condensed_variant_missing",
2894
- f"Uncondensed file exists but condensed variant missing: "
2895
- f"{condensed_path.name}"))
2896
- elif is_condensed:
2897
- # Condensed lives at repo-root dist/agent-src/<logical>. Source could
2898
- # be at any source root \u2014 resolve via artefact_roots.
2899
- marker = "/dist/agent-src/"
2900
- idx = norm.rfind(marker)
2901
- logical = norm[idx + len(marker):] if idx != -1 else None
2902
- if logical:
2903
- uncondensed_path = resolve_logical(logical)
2904
- if uncondensed_path is None or not uncondensed_path.exists():
2905
- issues.append(Issue("warning", "uncondensed_variant_missing",
2906
- f"Condensed file exists but uncondensed source missing: "
2907
- f"{Path(logical).name}"))
2908
-
2909
- # --- Check: file in correct location for type ---
2910
- location_map = {
2911
- "skill": "/skills/",
2912
- "rule": "/rules/",
2913
- "command": "/commands/",
2914
- "guideline": "/guidelines/",
2915
- }
2916
- expected_loc = location_map.get(artifact_type)
2917
- if expected_loc and expected_loc not in path_str:
2918
- issues.append(Issue("warning", "invalid_location_for_type",
2919
- f"Artifact detected as '{artifact_type}' but not in "
2920
- f"expected location ({expected_loc})"))
2921
-
2922
- return issues
2923
-
2924
-
2925
- # --- Structural malice check (see road-to-suite-closure Phase 5) ---
2926
- #
2927
- # Five regex patterns scan skill / rule / command bodies for **structural**
2928
- # (not semantic) malice. Findings surface as ``Issue("error",
2929
- # "malice:<pattern>", "<line>:<matched>")`` so ``compute_exit_code`` can
2930
- # emit exit code 3 (security-failure), distinct from 2 (build-failure).
2931
- # Semantic checks (PII leakage, prompt injection) are deferred to v2.
2932
-
2933
- # (a) credential exfil — curl|wget piping ${TOKEN}/${KEY}/${SECRET}/...
2934
- # env vars or hitting ~/.aws/ ~/.ssh/ secrets.
2935
- _MALICE_CRED_EXFIL = re.compile(
2936
- r"\b(?:curl|wget)\b[^\n]*"
2937
- r"(?:\$\{?[A-Z_]*(?:TOKEN|KEY|SECRET|PASSWORD|CREDENTIAL|API)[A-Z_]*\}?"
2938
- r"|~/\.(?:aws|ssh)/)"
2939
- )
2940
- # (b) arbitrary execution — eval/exec over a network-fetched payload, or
2941
- # `bash <(curl ...)` / `sh <(wget ...)` style remote-execution.
2942
- _MALICE_REMOTE_EXEC = re.compile(
2943
- r"(?:\b(?:eval|exec)\s*\([^)]*(?:curl|wget|requests\.get|urllib)"
2944
- r"|\b(?:bash|sh|zsh)\s*<\s*\(\s*(?:curl|wget))"
2945
- )
2946
- # (c) force-push to a protected ref.
2947
- _MALICE_FORCE_PUSH = re.compile(
2948
- r"\bgit\s+push\b[^\n]*--force(?:-with-lease)?\b[^\n]*"
2949
- r"\b(?:main|master|prod|production|release)\b"
2950
- )
2951
- # (d) world-readable secrets — chmod 0?[4567]xx on .pem/.key/.env files.
2952
- _MALICE_CHMOD_SECRETS = re.compile(
2953
- r"\bchmod\s+0?[4567]\d{2}\s+[^\n]*\.(?:pem|key|env)\b"
2954
- )
2955
- # (e) unbounded subprocess shell injection — shell=True interpolating ${VAR}.
2956
- _MALICE_SHELL_INJECT = re.compile(
2957
- r"\bsubprocess\.[A-Za-z_]+\s*\([^)]*shell\s*=\s*True[^)]*\$\{"
2958
- )
2959
-
2960
- _MALICE_PATTERNS: list[tuple[str, re.Pattern[str]]] = [
2961
- ("cred_exfil", _MALICE_CRED_EXFIL),
2962
- ("remote_exec", _MALICE_REMOTE_EXEC),
2963
- ("force_push_protected", _MALICE_FORCE_PUSH),
2964
- ("chmod_secrets", _MALICE_CHMOD_SECRETS),
2965
- ("shell_injection", _MALICE_SHELL_INJECT),
2966
- ]
2967
-
2968
-
2969
- def check_structural_malice(text: str) -> List[Issue]:
2970
- """Return one Issue per malice match. Empty list when clean.
2971
-
2972
- Issue shape: ``Issue("error", f"malice:{name}", f"{line}:{matched}")``.
2973
- The ``format_text`` renderer special-cases the ``malice:`` code prefix
2974
- to emit ``<path>:<line>:malice:<pattern>:<matched>`` per Phase 5.2.
2975
- """
2976
- issues: List[Issue] = []
2977
- for lineno, raw in enumerate(text.splitlines(), start=1):
2978
- for name, pattern in _MALICE_PATTERNS:
2979
- match = pattern.search(raw)
2980
- if match:
2981
- issues.append(Issue(
2982
- severity="error",
2983
- code=f"malice:{name}",
2984
- message=f"{lineno}:{match.group(0).strip()}",
2985
- ))
2986
- return issues
2987
-
2988
-
2989
- # --- Output-schema check (see road-to-trigger-evals Phase 3.5) ---
2990
- #
2991
- # Skills that freeze an output shape (`refine-ticket`, `estimate-ticket`)
2992
- # ship an optional `evals/output-schema.yml` listing the `##`-headers
2993
- # their output template MUST carry. The linter fails if a header drifts.
2994
-
2995
- _OUTPUT_SCHEMA_KEY_PATTERN = re.compile(r'^(\w+):\s*(.*?)\s*$')
2996
-
2997
-
2998
- def parse_output_schema(text: str) -> dict:
2999
- """Tiny YAML-like parser for ``evals/output-schema.yml`` — no PyYAML dep.
3000
-
3001
- Supported shape::
3002
-
3003
- version: 1
3004
- required_headers:
3005
- - "Refined ticket"
3006
- - "Top-5 risks"
3007
-
3008
- Unknown keys are preserved but ignored by :func:`lint_output_schema`.
3009
- """
3010
- result: dict = {}
3011
- current_list: Optional[str] = None
3012
- for raw in text.splitlines():
3013
- stripped = raw.strip()
3014
- if not stripped or stripped.startswith("#"):
3015
- continue
3016
- if stripped.startswith("- "):
3017
- if current_list is None:
3018
- continue
3019
- value = stripped[2:].strip().strip('"').strip("'")
3020
- result[current_list].append(value)
3021
- continue
3022
- match = _OUTPUT_SCHEMA_KEY_PATTERN.match(stripped)
3023
- if not match:
3024
- continue
3025
- key, value = match.group(1), match.group(2).strip('"').strip("'")
3026
- if value == "":
3027
- result[key] = []
3028
- current_list = key
3029
- else:
3030
- current_list = None
3031
- try:
3032
- result[key] = int(value)
3033
- except ValueError:
3034
- result[key] = value
3035
- return result
3036
-
3037
-
3038
- def load_output_schema(skill_path: Path) -> Optional[dict]:
3039
- """Return the parsed schema sibling to ``skill_path`` or ``None``.
3040
-
3041
- Lookup: ``<skill-dir>/evals/output-schema.yml``. Callers MUST use the
3042
- real path (not the repo-relative display path) so the sibling lookup
3043
- hits the actual directory.
3044
- """
3045
- if skill_path.name != "SKILL.md":
3046
- return None
3047
- schema_path = skill_path.parent / "evals" / "output-schema.yml"
3048
- if not schema_path.exists():
3049
- return None
3050
- try:
3051
- return parse_output_schema(schema_path.read_text(encoding="utf-8"))
3052
- except OSError:
3053
- return None
3054
-
3055
-
3056
- def lint_output_schema(path: Path, text: str) -> List[Issue]:
3057
- """Fail if any required header declared in the sibling schema is
3058
- missing from the skill's output template.
3059
-
3060
- No-op when the schema file does not exist or declares no
3061
- ``required_headers`` — keeps the check opt-in per skill.
3062
- """
3063
- schema = load_output_schema(path)
3064
- if schema is None:
3065
- return []
3066
- required = schema.get("required_headers") or []
3067
- if not isinstance(required, list) or not required:
3068
- return []
3069
- issues: List[Issue] = []
3070
- # Scan the whole skill text. Template headers live inside a fenced
3071
- # code block, but the `^## <header>$` line still matches — a drift
3072
- # (rename/removal) makes the line disappear from the file entirely.
3073
- for header in required:
3074
- if not isinstance(header, str) or not header.strip():
3075
- continue
3076
- pattern = re.compile(
3077
- rf"^##\s+{re.escape(header.strip())}\s*$", re.MULTILINE,
3078
- )
3079
- if not pattern.search(text):
3080
- issues.append(Issue(
3081
- "error", "output_schema_drift",
3082
- f"Output template is missing required header "
3083
- f"`## {header}` (declared in evals/output-schema.yml)",
3084
- ))
3085
- return issues
3086
-
3087
-
3088
- # Artefact types that carry a JSON-Schema contract for their frontmatter.
3089
- _SCHEMA_ARTEFACT_TYPES = {"skill", "rule", "command", "persona", "user-type"}
3090
-
3091
-
3092
- def lint_frontmatter_schema(path: Path, text: str, artifact_type: str) -> List[Issue]:
3093
- """Validate the frontmatter of an artefact against its JSON-Schema.
3094
-
3095
- Schemas live in ``scripts/schemas/``. One schema per artefact type;
3096
- see ``agents/reference/docs/frontmatter-contract.md`` for the human-readable
3097
- contract the schemas encode. Guidelines have no frontmatter and are
3098
- skipped.
3099
- """
3100
- if artifact_type not in _SCHEMA_ARTEFACT_TYPES:
3101
- return []
3102
- try:
3103
- schema = load_schema(artifact_type)
3104
- except FileNotFoundError:
3105
- return []
3106
-
3107
- data, _ = parse_frontmatter_for_schema(text)
3108
- if data is None:
3109
- # Other linter checks already emit a missing-frontmatter error for
3110
- # rules/commands/personas; avoid double-reporting here.
3111
- return []
3112
-
3113
- # Inject schema defaults before validating so artefacts that omit a field
3114
- # equal to its default (post abstraction-reduction migration) still satisfy
3115
- # `required` — mirrors validate_frontmatter's own loader path.
3116
- apply_schema_defaults(data, schema)
3117
-
3118
- issues: List[Issue] = []
3119
- for error in validate_against_schema(data, schema):
3120
- code = f"schema_{error.rule}"
3121
- message = f"{error.path} – {error.message}"
3122
- issues.append(Issue("error", code, message))
3123
- return issues
3124
-
3125
-
3126
- def lint_file(path: Path, repo_root: Path | None = None) -> LintResult:
3127
- # Skip README files — they are not lintable artifacts
3128
- if path.name.lower() == "readme.md":
3129
- return LintResult(
3130
- file=str(path),
3131
- artifact_type="unknown",
3132
- status="pass",
3133
- issues=[],
3134
- suggestions=[],
3135
- )
3136
- text = read_text(path)
3137
- artifact_type = detect_artifact_type(path, text)
3138
- # Use relative path for output if repo_root is provided
3139
- display_path = path
3140
- if repo_root:
3141
- try:
3142
- display_path = path.relative_to(repo_root)
3143
- except ValueError:
3144
- pass
3145
- if artifact_type == "skill":
3146
- result = lint_skill(display_path, text)
3147
- elif artifact_type == "rule":
3148
- result = lint_rule(display_path, text)
3149
- elif artifact_type == "command":
3150
- result = lint_command(display_path, text)
3151
- elif artifact_type == "guideline":
3152
- result = lint_guideline(display_path, text)
3153
- elif artifact_type == "persona":
3154
- result = lint_persona(display_path, text)
3155
- elif artifact_type == "user-type":
3156
- result = lint_usertype(display_path, text)
3157
- else:
3158
- # Frugality charter lives in contexts/ (artifact_type == unknown)
3159
- # but still needs Layer 2 index-integrity validation.
3160
- if _is_frugality_charter(path):
3161
- charter_issues = lint_frugality_charter_index(path, text)
3162
- return LintResult(
3163
- file=str(display_path),
3164
- artifact_type="unknown",
3165
- status=classify_status(charter_issues),
3166
- issues=charter_issues,
3167
- suggestions=[],
3168
- )
3169
- return lint_unknown(display_path, text)
3170
-
3171
- # Post-processing: frontmatter schema validation (errors). Runs first
3172
- # so schema failures surface before the softer quality checks below.
3173
- schema_issues = lint_frontmatter_schema(display_path, text, artifact_type)
3174
- if schema_issues:
3175
- result.issues.extend(schema_issues)
3176
- result.status = classify_status(result.issues)
3177
-
3178
- # Post-processing: interaction quality checks (warnings/info only)
3179
- interaction_issues = lint_interaction_quality(display_path, text)
3180
- if interaction_issues:
3181
- result.issues.extend(interaction_issues)
3182
- result.status = classify_status(result.issues)
3183
-
3184
- # Post-processing: execution quality checks (errors/warnings)
3185
- execution_issues = lint_execution_quality(display_path, text)
3186
- if execution_issues:
3187
- result.issues.extend(execution_issues)
3188
- result.status = classify_status(result.issues)
3189
-
3190
- # Post-processing: type boundary checks (warnings)
3191
- boundary_issues = lint_type_boundaries(display_path, text, artifact_type)
3192
- if boundary_issues:
3193
- result.issues.extend(boundary_issues)
3194
- result.status = classify_status(result.issues)
3195
-
3196
- # Post-processing: verification maturity checks (warnings)
3197
- maturity_issues = lint_verification_maturity(display_path, text, artifact_type)
3198
- if maturity_issues:
3199
- result.issues.extend(maturity_issues)
3200
- result.status = classify_status(result.issues)
3201
-
3202
- # Post-processing: governance and packaging checks (warnings)
3203
- governance_issues = lint_governance(path, text, artifact_type, repo_root)
3204
- if governance_issues:
3205
- result.issues.extend(governance_issues)
3206
- result.status = classify_status(result.issues)
3207
-
3208
- # Post-processing: output-schema drift (errors). Skills only — schema
3209
- # lookup walks a sibling `evals/` directory off the real SKILL.md.
3210
- if artifact_type == "skill":
3211
- schema_issues = lint_output_schema(path, text)
3212
- if schema_issues:
3213
- result.issues.extend(schema_issues)
3214
- result.status = classify_status(result.issues)
3215
-
3216
- # Post-processing: structural malice scan (errors). Skills, rules,
3217
- # and commands carry executable patterns; guidelines/personas are
3218
- # prose-only and skipped to keep noise low.
3219
- if artifact_type in ("skill", "rule", "command"):
3220
- malice_issues = check_structural_malice(text)
3221
- if malice_issues:
3222
- result.issues.extend(malice_issues)
3223
- result.status = classify_status(result.issues)
3224
-
3225
- # Post-processing: frugality validator Layer 1 (writer-cite). Errors
3226
- # if a writer skill lacks the `## Frugality Standards` section or its
3227
- # link to the charter.
3228
- frugality_issues = lint_frugality_writer_cite(
3229
- display_path, text, artifact_type
3230
- )
3231
- if frugality_issues:
3232
- result.issues.extend(frugality_issues)
3233
- result.status = classify_status(result.issues)
3234
-
3235
- return result
3236
-
3237
-
3238
- def format_text(results: list[LintResult], quiet: bool = False) -> str:
3239
- lines: list[str] = []
3240
- # Phase 5.2: malice findings render in the spec shape
3241
- # ``<path>:<line>:malice:<pattern>:<matched>`` ahead of the badge
3242
- # block so security-failures are grep-able from the top.
3243
- malice_total = 0
3244
- for result in results:
3245
- for issue in result.issues:
3246
- if issue.code.startswith("malice:"):
3247
- pattern_name = issue.code.split(":", 1)[1]
3248
- lineno, _, matched = issue.message.partition(":")
3249
- lines.append(
3250
- f"{result.file}:{lineno}:malice:{pattern_name}:{matched}"
3251
- )
3252
- malice_total += 1
3253
- if malice_total:
3254
- lines.append("")
3255
-
3256
- # P10.5: quiet mode skips PASS-without-issues; malice + WARN/FAIL still rendered.
3257
- for result in results:
3258
- if quiet and result.status == "pass" and not result.issues and not result.suggestions:
3259
- continue
3260
- badge = {"pass": "[PASS]", "pass_with_warnings": "[WARN]", "fail": "[FAIL]"}[result.status]
3261
- lines.append(f"{badge} {result.file} ({result.artifact_type})")
3262
- if result.issues:
3263
- for issue in result.issues:
3264
- lines.append(f" - {issue.severity.upper()} {issue.code}: {issue.message}")
3265
- else:
3266
- lines.append(" - No issues found")
3267
- if result.suggestions:
3268
- lines.append(" Suggested fixes:")
3269
- for suggestion in result.suggestions:
3270
- lines.append(f" - {suggestion}")
3271
- lines.append("")
3272
-
3273
- total = len(results)
3274
- fails = sum(1 for r in results if r.status == "fail")
3275
- warns = sum(1 for r in results if r.status == "pass_with_warnings")
3276
- passes = sum(1 for r in results if r.status == "pass")
3277
- suffix = f", {malice_total} malice" if malice_total else ""
3278
- lines.append(f"Summary: {passes} pass, {warns} warn, {fails} fail, {total} total{suffix}")
3279
- return "\n".join(lines)
3280
-
3281
-
3282
- def format_json(results: list[LintResult]) -> str:
3283
- payload = {
3284
- "summary": {
3285
- "pass": sum(1 for r in results if r.status == "pass"),
3286
- "pass_with_warnings": sum(1 for r in results if r.status == "pass_with_warnings"),
3287
- "fail": sum(1 for r in results if r.status == "fail"),
3288
- "total": len(results),
3289
- },
3290
- "results": [
3291
- {
3292
- "file": r.file,
3293
- "artifact_type": r.artifact_type,
3294
- "status": r.status,
3295
- "issues": [asdict(issue) for issue in r.issues],
3296
- "suggestions": r.suggestions,
3297
- }
3298
- for r in results
3299
- ],
3300
- }
3301
- return json.dumps(payload, indent=2, ensure_ascii=False)
3302
-
3303
-
3304
- def check_condensation_pairs(root: Path) -> list[LintResult]:
3305
- """Check that every uncondensed skill/rule/command has a condensed counterpart and vice versa."""
3306
- results: list[LintResult] = []
3307
-
3308
- pairs = [
3309
- ("skills", "SKILL.md", True), # (subdir, filename, is_nested)
3310
- ("rules", "*.md", False),
3311
- ("commands", "*.md", False),
3312
- ]
3313
-
3314
- for subdir, pattern, is_nested in pairs:
3315
- # ADR-017: union across every source root.
3316
- condensed_dir = root / "dist/agent-src" / subdir
3317
- uncondensed_names: set[str] = set()
3318
- any_source = False
3319
- for src_root in artefact_roots():
3320
- uncondensed_dir = src_root / subdir
3321
- if not uncondensed_dir.exists():
3322
- continue
3323
- any_source = True
3324
- if is_nested:
3325
- uncondensed_names |= {d.name for d in uncondensed_dir.iterdir() if d.is_dir() and (d / pattern).exists()}
3326
- else:
3327
- uncondensed_names |= {f.name for f in uncondensed_dir.glob(pattern) if f.is_file()}
3328
-
3329
- if not any_source:
3330
- continue
3331
-
3332
- # Collect names from condensed
3333
- if condensed_dir.exists():
3334
- if is_nested:
3335
- condensed_names = {d.name for d in condensed_dir.iterdir() if d.is_dir() and (d / pattern).exists()}
3336
- else:
3337
- condensed_names = {f.name for f in condensed_dir.glob(pattern) if f.is_file()}
3338
- else:
3339
- condensed_names = set()
3340
-
3341
- # Missing condensed
3342
- for name in sorted(uncondensed_names - condensed_names):
3343
- path_str = f"dist/agent-src/{subdir}/{name}/{pattern}" if is_nested else f"dist/agent-src/{subdir}/{name}"
3344
- results.append(LintResult(
3345
- file=path_str,
3346
- artifact_type=subdir.rstrip("s"),
3347
- status="fail",
3348
- issues=[Issue("error", "missing_condensed", f"Uncondensed exists but condensed version is missing")],
3349
- suggestions=[f"Run /condense to generate dist/agent-src/{subdir}/{name}"],
3350
- ))
3351
-
3352
- # Orphaned condensed (no source)
3353
- for name in sorted(condensed_names - uncondensed_names):
3354
- path_str = f"dist/agent-src/{subdir}/{name}/{pattern}" if is_nested else f"dist/agent-src/{subdir}/{name}"
3355
- results.append(LintResult(
3356
- file=path_str,
3357
- artifact_type=subdir.rstrip("s"),
3358
- status="fail",
3359
- issues=[Issue("error", "orphaned_condensed", f"Condensed exists but uncondensed source is missing")],
3360
- suggestions=[f"Delete orphaned file or restore uncondensed source"],
3361
- ))
3362
-
3363
- return results
3364
-
3365
-
3366
- def check_condensation_quality(root: Path) -> list[LintResult]:
3367
- """Check that condensed skills preserve key content from their uncondensed source."""
3368
- results: list[LintResult] = []
3369
- condensed_dir = root / "dist/agent-src" / "skills"
3370
- if not condensed_dir.exists():
3371
- return results
3372
-
3373
- # ADR-017: collect skill dirs from every source root.
3374
- skill_sources: list[Path] = []
3375
- for src_root in artefact_roots():
3376
- uncondensed_dir = src_root / "skills"
3377
- if uncondensed_dir.exists():
3378
- skill_sources.extend(sorted(uncondensed_dir.iterdir()))
3379
- if not skill_sources:
3380
- return results
3381
-
3382
- # Sections that MUST exist in condensed if they exist in uncondensed
3383
- preserved_sections = ["When to use", "Procedure", "Gotcha", "Gotchas", "Do NOT", "Output format", "Output"]
3384
-
3385
- for skill_dir in skill_sources:
3386
- src = skill_dir / "SKILL.md"
3387
- dst = condensed_dir / skill_dir.name / "SKILL.md"
3388
- if not src.exists() or not dst.exists():
3389
- continue
3390
-
3391
- src_text = read_text(src)
3392
- dst_text = read_text(dst)
3393
- src_sections = extract_sections(src_text)
3394
- dst_sections = extract_sections(dst_text)
3395
-
3396
- issues: list[Issue] = []
3397
- suggestions: list[str] = []
3398
-
3399
- # Check required sections survived condensation
3400
- for section in preserved_sections:
3401
- if section_matches(section, src_sections) and not section_matches(section, dst_sections):
3402
- issues.append(Issue("warning", "condensation_lost_section",
3403
- f"Condensed version lost '{section}' section"))
3404
-
3405
- # Check validation keywords survived
3406
- src_proc = find_procedure_block(src_text) or ""
3407
- dst_proc = find_procedure_block(dst_text) or ""
3408
- validation_patterns = [r"\bverif", r"\bcheck\b", r"\bconfirm\b", r"\bvalidat", r"\binspect"]
3409
- src_has_validation = any(re.search(p, src_proc, re.IGNORECASE) for p in validation_patterns)
3410
- dst_has_validation = any(re.search(p, dst_proc, re.IGNORECASE) for p in validation_patterns)
3411
- if src_has_validation and not dst_has_validation:
3412
- issues.append(Issue("warning", "condensation_lost_validation",
3413
- "Condensed procedure lost validation keywords present in uncondensed"))
3414
-
3415
- # Check code blocks / examples survived
3416
- src_code_blocks = len(re.findall(r"```", src_text)) # pairs of ``` = blocks
3417
- dst_code_blocks = len(re.findall(r"```", dst_text))
3418
- if src_code_blocks > 0 and dst_code_blocks < src_code_blocks // 2:
3419
- issues.append(Issue("warning", "condensation_lost_example",
3420
- f"Condensed version has fewer code blocks "
3421
- f"({dst_code_blocks // 2} vs {src_code_blocks // 2} in source)"))
3422
-
3423
- # Check anti-pattern / "Do NOT" bullets survived
3424
- src_donot = len(re.findall(r"(?:Do NOT|NEVER|MUST NOT)\b", src_text))
3425
- dst_donot = len(re.findall(r"(?:Do NOT|NEVER|MUST NOT)\b", dst_text))
3426
- if src_donot > 0 and dst_donot < src_donot // 2:
3427
- issues.append(Issue("warning", "condensation_lost_antipattern",
3428
- f"Condensed version lost anti-pattern constraints "
3429
- f"({dst_donot} vs {src_donot} in source)"))
3430
-
3431
- if issues:
3432
- rel_path = f"dist/agent-src/skills/{skill_dir.name}/SKILL.md"
3433
- results.append(LintResult(
3434
- file=rel_path,
3435
- artifact_type="skill",
3436
- status="pass_with_warnings",
3437
- issues=issues,
3438
- suggestions=suggestions or ["Re-condense to preserve lost content"],
3439
- ))
3440
-
3441
- return results
3442
-
3443
-
3444
- def check_duplication(root: Path) -> list[LintResult]:
3445
- """Detect skills with highly similar names or descriptions."""
3446
- results: list[LintResult] = []
3447
- # ADR-017: collect skill dirs across every source root, dedup by name.
3448
- skill_dirs: list[Path] = []
3449
- seen: set[str] = set()
3450
- for src_root in artefact_roots():
3451
- sd = src_root / "skills"
3452
- if not sd.exists():
3453
- continue
3454
- for d in sorted(sd.iterdir()):
3455
- if d.is_dir() and d.name not in seen:
3456
- seen.add(d.name)
3457
- skill_dirs.append(d)
3458
- if not skill_dirs:
3459
- return results
3460
-
3461
- # Collect all skill names and descriptions
3462
- skill_data: list[tuple[str, str, Path]] = []
3463
- for skill_dir in skill_dirs:
3464
- skill_file = skill_dir / "SKILL.md"
3465
- if not skill_file.exists():
3466
- continue
3467
- text = read_text(skill_file)
3468
- desc = extract_description(text) or ""
3469
- skill_data.append((skill_dir.name, desc.lower(), skill_file))
3470
-
3471
- # Check for name prefix overlap (e.g. "laravel" and "laravel-validation")
3472
- # Only flag if descriptions are also similar
3473
- for i, (name_a, desc_a, path_a) in enumerate(skill_data):
3474
- for name_b, desc_b, path_b in skill_data[i + 1:]:
3475
- # Skip known patterns: skill-X and skill-X-subtype is intentional
3476
- if name_a == name_b:
3477
- continue
3478
- # Check description word overlap
3479
- if desc_a and desc_b:
3480
- words_a = set(desc_a.split())
3481
- words_b = set(desc_b.split())
3482
- if len(words_a) > 3 and len(words_b) > 3:
3483
- overlap = len(words_a & words_b) / min(len(words_a), len(words_b))
3484
- if overlap > 0.7:
3485
- rel_a = f".agent-src.uncondensed/skills/{name_a}/SKILL.md"
3486
- results.append(LintResult(
3487
- file=rel_a,
3488
- artifact_type="skill",
3489
- status="pass_with_warnings",
3490
- issues=[Issue("warning", "similar_description",
3491
- f"Description highly similar to '{name_b}' ({overlap:.0%} word overlap)")],
3492
- suggestions=[f"Consider merging with '{name_b}' or differentiating descriptions"],
3493
- ))
3494
-
3495
- return results
3496
-
3497
-
3498
- def compute_exit_code(results: list[LintResult], strict_warnings: bool) -> int:
3499
- # Phase 5.2: structural-malice findings emit exit code 3 (security-
3500
- # failure), distinct from 2 (build-failure) so CI surfaces can split.
3501
- for r in results:
3502
- if any(issue.code.startswith("malice:") for issue in r.issues):
3503
- return 3
3504
- if any(r.status == "fail" for r in results):
3505
- return 2
3506
- if any(r.status == "pass_with_warnings" for r in results) and strict_warnings:
3507
- return 1
3508
- return 0
3509
-
3510
-
3511
- def parse_args() -> argparse.Namespace:
3512
- parser = argparse.ArgumentParser(description="Lint skills and rules.")
3513
- parser.add_argument("paths", nargs="*", help="Files to lint")
3514
- parser.add_argument("--all", action="store_true", help="Lint all skills/rules in the repo")
3515
- parser.add_argument("--changed", action="store_true", help="Lint changed skills/rules")
3516
- parser.add_argument("--format", choices=["text", "json"], default="text", help="Output format")
3517
- parser.add_argument("--pairs", action="store_true", help="Check condensation pairs (uncondensed vs condensed)")
3518
- parser.add_argument("--duplicates", action="store_true", help="Detect skills with similar descriptions")
3519
- parser.add_argument("--condensation-quality", action="store_true", help="Check condensed skills preserve key content")
3520
- parser.add_argument("--strict-warnings", action="store_true", help="Return non-zero on warnings")
3521
- parser.add_argument("--report", action="store_true", help="Output quality score report")
3522
- parser.add_argument("--repo-root", default=".", help="Repository root")
3523
- parser.add_argument("--quiet", action="store_true",
3524
- help="suppress per-file PASS lines; keep malice + WARN/FAIL + summary (P10.5)")
3525
- return parser.parse_args()
3526
-
3527
-
3528
- def format_report(results: list[LintResult]) -> str:
3529
- """Generate a quality score report grouped by artifact type."""
3530
- lines = ["# Quality Report", ""]
3531
-
3532
- # Group by artifact type
3533
- by_type: dict[str, list[LintResult]] = {}
3534
- for r in results:
3535
- by_type.setdefault(r.artifact_type, []).append(r)
3536
-
3537
- # Summary table
3538
- lines.append("| Type | Total | Pass | Warn | Fail | Score |")
3539
- lines.append("|---|---|---|---|---|---|")
3540
- total_score = 0.0
3541
- total_count = 0
3542
- for atype in sorted(by_type):
3543
- items = by_type[atype]
3544
- n = len(items)
3545
- n_pass = sum(1 for r in items if r.status == "pass")
3546
- n_warn = sum(1 for r in items if r.status in ("warn", "pass_with_warnings"))
3547
- n_fail = sum(1 for r in items if r.status == "fail")
3548
- # Score: pass=10, warn=8, fail=3
3549
- type_score = (n_pass * 10 + n_warn * 8 + n_fail * 3) / max(n, 1)
3550
- total_score += type_score * n
3551
- total_count += n
3552
- lines.append(f"| {atype} | {n} | {n_pass} | {n_warn} | {n_fail} | {type_score:.1f}/10 |")
3553
- overall = total_score / max(total_count, 1)
3554
- lines.append(f"| **TOTAL** | **{total_count}** | | | | **{overall:.1f}/10** |")
3555
-
3556
- # Top issues
3557
- issue_counts: dict[str, int] = {}
3558
- for r in results:
3559
- for i in r.issues:
3560
- issue_counts[i.code] = issue_counts.get(i.code, 0) + 1
3561
- if issue_counts:
3562
- lines.extend(["", "## Top Issues", ""])
3563
- lines.append("| Issue | Count | Severity |")
3564
- lines.append("|---|---|---|")
3565
- for code, count in sorted(issue_counts.items(), key=lambda x: -x[1])[:15]:
3566
- # Find severity from first occurrence
3567
- sev = "?"
3568
- for r in results:
3569
- for i in r.issues:
3570
- if i.code == code:
3571
- sev = i.severity
3572
- break
3573
- if sev != "?":
3574
- break
3575
- lines.append(f"| `{code}` | {count} | {sev} |")
3576
-
3577
- # Files with most issues (top 10)
3578
- files_with_issues = [
3579
- (r.file, len(r.issues), r.status)
3580
- for r in results
3581
- if r.issues
3582
- ]
3583
- files_with_issues.sort(key=lambda x: -x[1])
3584
- if files_with_issues:
3585
- lines.extend(["", "## Files with Most Issues (Top 10)", ""])
3586
- lines.append("| File | Issues | Status |")
3587
- lines.append("|---|---|---|")
3588
- for fpath, count, status in files_with_issues[:10]:
3589
- short = fpath.replace(".agent-src.uncondensed/", "")
3590
- lines.append(f"| `{short}` | {count} | {status} |")
3591
-
3592
- # Per-file quality breakdown (skills only)
3593
- skill_results = [r for r in results if r.artifact_type == "skill" and "/pair-check/" not in r.file]
3594
- if skill_results:
3595
- lines.extend(["", "## Per-File Quality (Skills)", ""])
3596
- lines.append("| Skill | Structure | Validation | Scope | Dependency | Lines |")
3597
- lines.append("|---|---|---|---|---|---|")
3598
- for r in sorted(skill_results, key=lambda x: x.file):
3599
- short = r.file.replace(".agent-src.uncondensed/skills/", "").replace("dist/agent-src/skills/", "").replace("/SKILL.md", "")
3600
- codes = {i.code for i in r.issues}
3601
-
3602
- # Structure: fail if missing required sections
3603
- struct = "❌" if codes & {"missing_section", "empty_procedure", "unordered_procedure"} else "✅"
3604
-
3605
- # Validation: weak if missing or vague
3606
- if codes & {"missing_validation", "vague_validation"}:
3607
- valid = "❌ weak"
3608
- elif codes & {"missing_inspect_step"}:
3609
- valid = "⚠️ partial"
3610
- else:
3611
- valid = "✅ strong"
3612
-
3613
- # Scope: broad if flagged
3614
- scope = "⚠️ broad" if "broad_scope" in codes else "✅ focused"
3615
-
3616
- # Guideline dependency
3617
- if "guideline_dependent_skill" in codes:
3618
- dep = "❌ high"
3619
- elif "pointer_only_skill" in codes:
3620
- dep = "⚠️ medium"
3621
- else:
3622
- dep = "✅ low"
3623
-
3624
- # Line count
3625
- total_lines = 0
3626
- try:
3627
- total_lines = Path(r.file).read_text(encoding="utf-8").count("\n")
3628
- except OSError:
3629
- pass
3630
-
3631
- lines.append(f"| `{short}` | {struct} | {valid} | {scope} | {dep} | {total_lines} |")
3632
-
3633
- return "\n".join(lines)
3634
-
3635
-
3636
- def main() -> int:
3637
- args = parse_args()
3638
- root = Path(args.repo_root).resolve()
3639
-
3640
- try:
3641
- paths: list[Path] = []
3642
- if args.all or args.report:
3643
- paths.extend(gather_all_candidate_files(root))
3644
- if args.changed:
3645
- paths.extend(gather_changed_candidate_files(root))
3646
- for raw in args.paths:
3647
- path = (root / raw).resolve() if not Path(raw).is_absolute() else Path(raw)
3648
- if not path.exists():
3649
- continue
3650
- if path.is_dir():
3651
- # Walk the directory like a source root so callers can pass
3652
- # `packages/pack-laravel/.agent-src.uncondensed/` (ADR-017 Phase 4.4).
3653
- paths.extend(gather_candidate_files_under(path))
3654
- else:
3655
- paths.append(path)
3656
-
3657
- paths = sorted(set(paths))
3658
- if not paths:
3659
- # Emit a valid empty payload when a structured format was requested
3660
- # so downstream parsers (e.g. PR-summary workflows) don't fail on an
3661
- # empty stdout. stderr keeps the human-readable note.
3662
- if args.report:
3663
- print(format_report([]))
3664
- elif args.format == "json":
3665
- print(format_json([]))
3666
- print("No matching skill/rule files found.", file=sys.stderr)
3667
- return 0
3668
-
3669
- results = [lint_file(path, repo_root=root) for path in paths]
3670
-
3671
- # Additional checks
3672
- if args.pairs or args.report:
3673
- results.extend(check_condensation_pairs(root))
3674
- if args.duplicates:
3675
- results.extend(check_duplication(root))
3676
- if args.condensation_quality or args.report:
3677
- results.extend(check_condensation_quality(root))
3678
-
3679
- if args.report:
3680
- print(format_report(results))
3681
- elif args.format == "json":
3682
- print(format_json(results))
3683
- else:
3684
- print(format_text(results, quiet=args.quiet))
3685
-
3686
- return compute_exit_code(results, strict_warnings=args.strict_warnings)
3687
-
3688
- except Exception as exc: # noqa: BLE001
3689
- print(f"Internal error: {exc}", file=sys.stderr)
3690
- return 3
3691
-
3692
-
3693
- if __name__ == "__main__":
3694
- raise SystemExit(main())