@thebassclef/lite 0.0.1 → 0.1.2

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 (289) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +85 -4
  3. package/dist/cli.cjs +1612 -0
  4. package/dist/cli.js +1589 -0
  5. package/dist/index.cjs +4 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +4 -0
  8. package/package.json +51 -3
  9. package/substrate/.bassclef/lite-manifest.json +2701 -0
  10. package/substrate/.claude/agents/architect.md +70 -0
  11. package/substrate/.claude/agents/builder.md +114 -0
  12. package/substrate/.claude/agents/designer.md +156 -0
  13. package/substrate/.claude/agents/reviewer.md +88 -0
  14. package/substrate/.claude/hooks/artifact-ingestion-gate.sh +357 -0
  15. package/substrate/.claude/hooks/assert-verify-steering.sh +77 -0
  16. package/substrate/.claude/hooks/bassclef-source-config-validate.sh +215 -0
  17. package/substrate/.claude/hooks/bassclef-sync.sh +634 -0
  18. package/substrate/.claude/hooks/compound-noun-scrub.sh +292 -0
  19. package/substrate/.claude/hooks/kiss-expansion-inject.sh +69 -0
  20. package/substrate/.claude/hooks/longrun-prep-compounding-axis-check.sh +492 -0
  21. package/substrate/.claude/hooks/longrun-prep-compounding-sequence-check.sh +492 -0
  22. package/substrate/.claude/hooks/plain-english-steering.sh +156 -0
  23. package/substrate/.claude/hooks/post-skill-friction-check.sh +177 -0
  24. package/substrate/.claude/hooks/post-skill-telemetry.sh +62 -0
  25. package/substrate/.claude/hooks/pre-build-gate.sh +511 -0
  26. package/substrate/.claude/hooks/pre-commit-gate.sh +451 -0
  27. package/substrate/.claude/hooks/session-end.sh +433 -0
  28. package/substrate/.claude/hooks/session-reflection.sh +303 -0
  29. package/substrate/.claude/hooks/skill-body-grade-gate.sh +219 -0
  30. package/substrate/.claude/hooks/skill-body-intent-drift.sh +107 -0
  31. package/substrate/.claude/hooks/skill-step-list-check.sh +171 -0
  32. package/substrate/.claude/hooks/state-validate.sh +271 -0
  33. package/substrate/.claude/hooks/substrate-clarity-gate.sh +1110 -0
  34. package/substrate/.claude/hooks/temperance-gate.sh +147 -0
  35. package/substrate/.claude/hooks/testing-tier-enforce.sh +233 -0
  36. package/substrate/.claude/hooks/turn-prose-grade-measure.sh +219 -0
  37. package/substrate/.claude/hooks/turn-prose-kiss-check.sh +463 -0
  38. package/substrate/.claude/hooks/vocabulary-migration-check.sh +171 -0
  39. package/substrate/.claude/hooks/whereami-utc-gate.sh +142 -0
  40. package/substrate/.claude/luminaries/alan-cooper.md +170 -0
  41. package/substrate/.claude/luminaries/alistair-cockburn.md +140 -0
  42. package/substrate/.claude/luminaries/amazon-pr-faq.md +34 -0
  43. package/substrate/.claude/luminaries/ash-maurya.md +121 -0
  44. package/substrate/.claude/luminaries/bill-buxton.md +210 -0
  45. package/substrate/.claude/luminaries/charles-sanders-peirce.md +150 -0
  46. package/substrate/.claude/luminaries/david-ogilvy.md +192 -0
  47. package/substrate/.claude/luminaries/don-norman.md +173 -0
  48. package/substrate/.claude/luminaries/edward-tufte.md +179 -0
  49. package/substrate/.claude/luminaries/eric-evans.md +160 -0
  50. package/substrate/.claude/luminaries/frederick-brooks.md +50 -0
  51. package/substrate/.claude/luminaries/gang-of-four.md +157 -0
  52. package/substrate/.claude/luminaries/glenford-myers.md +230 -0
  53. package/substrate/.claude/luminaries/hunt-thomas.md +115 -0
  54. package/substrate/.claude/luminaries/hyrum-wright.md +94 -0
  55. package/substrate/.claude/luminaries/jason-fried-dhh.md +46 -0
  56. package/substrate/.claude/luminaries/jesse-james-garrett.md +154 -0
  57. package/substrate/.claude/luminaries/john-ousterhout.md +94 -0
  58. package/substrate/.claude/luminaries/karl-popper.md +132 -0
  59. package/substrate/.claude/luminaries/kent-beck.md +168 -0
  60. package/substrate/.claude/luminaries/linus-torvalds.md +218 -0
  61. package/substrate/.claude/luminaries/martin-fowler.md +164 -0
  62. package/substrate/.claude/luminaries/michael-feathers.md +125 -0
  63. package/substrate/.claude/luminaries/michael-nygard.md +118 -0
  64. package/substrate/.claude/luminaries/robert-c-martin.md +164 -0
  65. package/substrate/.claude/luminaries/saltzer-schroeder.md +194 -0
  66. package/substrate/.claude/luminaries/sophia-prater.md +193 -0
  67. package/substrate/.claude/luminaries/stephen-toulmin.md +131 -0
  68. package/substrate/.claude/luminaries/tony-hoare.md +170 -0
  69. package/substrate/.claude/luminaries/vaughn-vernon.md +50 -0
  70. package/substrate/.claude/luminaries/w-edwards-deming.md +158 -0
  71. package/substrate/.claude/rules/accessor-library-discipline.md +138 -0
  72. package/substrate/.claude/rules/adr-discipline.md +120 -0
  73. package/substrate/.claude/rules/api-conventions.md +125 -0
  74. package/substrate/.claude/rules/artifact-ingestion.md +179 -0
  75. package/substrate/.claude/rules/assert-only-after-verify.md +137 -0
  76. package/substrate/.claude/rules/blocked-items.md +146 -0
  77. package/substrate/.claude/rules/bootstrap-pair-discipline.md +141 -0
  78. package/substrate/.claude/rules/branching.md +28 -0
  79. package/substrate/.claude/rules/cold-adopter-harness-discipline.md +129 -0
  80. package/substrate/.claude/rules/commit-conventions.md +22 -0
  81. package/substrate/.claude/rules/compounding-axis-fresh-analysis.md +188 -0
  82. package/substrate/.claude/rules/compounding-sequence-fresh-analysis.md +188 -0
  83. package/substrate/.claude/rules/context-engineering.md +202 -0
  84. package/substrate/.claude/rules/context-management.md +85 -0
  85. package/substrate/.claude/rules/defensive-bash.md +68 -0
  86. package/substrate/.claude/rules/deferred-actions.md +233 -0
  87. package/substrate/.claude/rules/destructive-operations.md +69 -0
  88. package/substrate/.claude/rules/diagnosis.md +38 -0
  89. package/substrate/.claude/rules/github-issue-flash-tweet.md +156 -0
  90. package/substrate/.claude/rules/guardrails.md +73 -0
  91. package/substrate/.claude/rules/hook-wire-on-author.md +103 -0
  92. package/substrate/.claude/rules/identifier-leak-prevention.md +104 -0
  93. package/substrate/.claude/rules/iteration-bet-brief-completeness.md +54 -0
  94. package/substrate/.claude/rules/lite-manifest-schema-change-discipline.md +98 -0
  95. package/substrate/.claude/rules/longrun-prep-plan-doc-compression.md +89 -0
  96. package/substrate/.claude/rules/loop-discipline.md +81 -0
  97. package/substrate/.claude/rules/manual-prod-approval.md +100 -0
  98. package/substrate/.claude/rules/marker-enrichment-discipline.md +99 -0
  99. package/substrate/.claude/rules/mobile-ephemeral-session.md +109 -0
  100. package/substrate/.claude/rules/new-dependency-check.md +51 -0
  101. package/substrate/.claude/rules/oo-ad-entry-point.md +117 -0
  102. package/substrate/.claude/rules/operator-facing-prose.md +196 -0
  103. package/substrate/.claude/rules/option-label-discipline.md +108 -0
  104. package/substrate/.claude/rules/pattern-annotation.md +100 -0
  105. package/substrate/.claude/rules/plain-english-discipline.md +156 -0
  106. package/substrate/.claude/rules/plan-enumeration-needs-value-props.md +211 -0
  107. package/substrate/.claude/rules/pr-body-shape.md +317 -0
  108. package/substrate/.claude/rules/pr-strategy.md +167 -0
  109. package/substrate/.claude/rules/pr-title-shape.md +161 -0
  110. package/substrate/.claude/rules/prototype-workflow.md +65 -0
  111. package/substrate/.claude/rules/reserved-skill-names.md +123 -0
  112. package/substrate/.claude/rules/schema-management.md +49 -0
  113. package/substrate/.claude/rules/sdlc-gates.md +149 -0
  114. package/substrate/.claude/rules/security.md +37 -0
  115. package/substrate/.claude/rules/session-artifacts.md +236 -0
  116. package/substrate/.claude/rules/skill-composition-declarations.md +124 -0
  117. package/substrate/.claude/rules/skill-description-clarity.md +247 -0
  118. package/substrate/.claude/rules/skill-procedure-step-list.md +137 -0
  119. package/substrate/.claude/rules/state-schema-validation.md +162 -0
  120. package/substrate/.claude/rules/stuck-signal-diagnostic.md +140 -0
  121. package/substrate/.claude/rules/substrate-config-schema.md +98 -0
  122. package/substrate/.claude/rules/test-list-discipline.md +175 -0
  123. package/substrate/.claude/rules/test-sufficiency.md +210 -0
  124. package/substrate/.claude/rules/testing-tier-config.md +145 -0
  125. package/substrate/.claude/rules/testing.md +38 -0
  126. package/substrate/.claude/rules/turn-estimate-grounding.md +134 -0
  127. package/substrate/.claude/rules/visual-hierarchy.md +437 -0
  128. package/substrate/.claude/rules/we-dont-break-adopters.md +126 -0
  129. package/substrate/.claude/rules/whereami-load-bearing.md +202 -0
  130. package/substrate/.claude/rules/writing-craft-discipline.md +92 -0
  131. package/substrate/.claude/rules/wu-sequencing-compounds.md +145 -0
  132. package/substrate/.claude/skills/build/SKILL.md +640 -0
  133. package/substrate/.claude/skills/chronicle/SKILL.md +55 -0
  134. package/substrate/.claude/skills/clean-artifacts/SKILL.md +249 -0
  135. package/substrate/.claude/skills/decompose/SKILL.md +280 -0
  136. package/substrate/.claude/skills/diagnose/SKILL.md +297 -0
  137. package/substrate/.claude/skills/feynman/SKILL.md +90 -0
  138. package/substrate/.claude/skills/howdoi/SKILL.md +105 -0
  139. package/substrate/.claude/skills/ia-model/SKILL.md +108 -0
  140. package/substrate/.claude/skills/interaction-design/SKILL.md +112 -0
  141. package/substrate/.claude/skills/interpret-input/SKILL.md +180 -0
  142. package/substrate/.claude/skills/journal/SKILL.md +209 -0
  143. package/substrate/.claude/skills/kiss/SKILL.md +449 -0
  144. package/substrate/.claude/skills/launch/SKILL.md +915 -0
  145. package/substrate/.claude/skills/lean-canvas/SKILL.md +332 -0
  146. package/substrate/.claude/skills/longrun/SKILL.md +463 -0
  147. package/substrate/.claude/skills/luminary/SKILL.md +481 -0
  148. package/substrate/.claude/skills/ogilvy-writing-audit/SKILL.md +177 -0
  149. package/substrate/.claude/skills/onboard-repo/SKILL.md +1624 -0
  150. package/substrate/.claude/skills/pattern-review/SKILL.md +99 -0
  151. package/substrate/.claude/skills/personas/SKILL.md +207 -0
  152. package/substrate/.claude/skills/promote/SKILL.md +283 -0
  153. package/substrate/.claude/skills/requirement/SKILL.md +98 -0
  154. package/substrate/.claude/skills/retro/SKILL.md +117 -0
  155. package/substrate/.claude/skills/riff/SKILL.md +114 -0
  156. package/substrate/.claude/skills/roadmap-reconcile/SKILL.md +163 -0
  157. package/substrate/.claude/skills/session-end/SKILL.md +309 -0
  158. package/substrate/.claude/skills/session-log/SKILL.md +299 -0
  159. package/substrate/.claude/skills/skills/SKILL.md +228 -0
  160. package/substrate/.claude/skills/spec/SKILL.md +105 -0
  161. package/substrate/.claude/skills/sprint/SKILL.md +392 -0
  162. package/substrate/.claude/skills/stage/SKILL.md +384 -0
  163. package/substrate/.claude/skills/state-a-problem/SKILL.md +185 -0
  164. package/substrate/.claude/skills/temperance/SKILL.md +108 -0
  165. package/substrate/.claude/skills/use-case/SKILL.md +417 -0
  166. package/substrate/.claude/skills/user-stories/SKILL.md +268 -0
  167. package/substrate/.claude/skills/value-prop/SKILL.md +251 -0
  168. package/substrate/.claude/skills/verify/SKILL.md +160 -0
  169. package/substrate/.claude/skills/visual-review/SKILL.md +503 -0
  170. package/substrate/.claude/skills/whats-the-plan/SKILL.md +202 -0
  171. package/substrate/.claude/skills/whereami/SKILL.md +307 -0
  172. package/substrate/AGENTS.md +79 -0
  173. package/substrate/CLAUDE-lite.md +85 -0
  174. package/substrate/CODE_OF_CONDUCT.md +28 -0
  175. package/substrate/CONTRIBUTING.md +177 -0
  176. package/substrate/README.md +173 -0
  177. package/substrate/SECURITY.md +19 -0
  178. package/substrate/architecture/decisions/ADR-029-release-pipeline.md +79 -0
  179. package/substrate/architecture/decisions/ADR-031-non-breaking-changes-adopter-discipline.md +139 -0
  180. package/substrate/architecture/decisions/ADR-032-adopter-sync-dispatcher-architecture.md +192 -0
  181. package/substrate/architecture/decisions/ADR-039-release-tagging-scheme.md +145 -0
  182. package/substrate/architecture/decisions/ADR-040-planning-skill-vocabulary-and-lite-profile.md +155 -0
  183. package/substrate/architecture/decisions/ADR-044-unified-skill-body-template.md +162 -0
  184. package/substrate/lib/clean-artifacts-sweep.sh +112 -0
  185. package/substrate/lib/code-comment-discipline.sh +144 -0
  186. package/substrate/lib/composer-preflight.sh +459 -0
  187. package/substrate/lib/hook-inject.sh +255 -0
  188. package/substrate/lib/luminary-pick.sh +96 -0
  189. package/substrate/lib/output-discipline.sh +143 -0
  190. package/substrate/lib/prose-scan-boundary.sh +171 -0
  191. package/substrate/lib/rewrite-check.sh +214 -0
  192. package/substrate/lib/state.sh +1372 -0
  193. package/substrate/lib/telemetry.sh +205 -0
  194. package/substrate/lib/tier-check.sh +187 -0
  195. package/substrate/lib/tier-dependency-audit.sh +1088 -0
  196. package/substrate/presence/install/bassclef-hook-connect.sh +178 -0
  197. package/substrate/presence/install/bassclef-sync.dispatcher.template.sh +841 -0
  198. package/substrate/presence/install/bassclef-sync.template.sh +2076 -0
  199. package/substrate/presence/install/schedule-auto-save.cron.sh +88 -0
  200. package/substrate/presence/install/schedule-auto-save.taskscheduler.md +122 -0
  201. package/substrate/scripts/aggregate-telemetry.sh +217 -0
  202. package/substrate/scripts/analyze-tier-dependencies.sh +239 -0
  203. package/substrate/scripts/generate-lite-manifest.sh +505 -0
  204. package/substrate/scripts/generate-tier-manifest.sh +28 -0
  205. package/substrate/scripts/intent-drift-check.sh +456 -0
  206. package/substrate/scripts/lite-manifest-drift-check.sh +146 -0
  207. package/substrate/scripts/render-lite-manifest-doc.sh +150 -0
  208. package/substrate/standards/adr-template.md +86 -0
  209. package/substrate/standards/api-conventions/nextjs.md +84 -0
  210. package/substrate/standards/artifact-composition.md +209 -0
  211. package/substrate/standards/bash-hook-safety.md +246 -0
  212. package/substrate/standards/bassclef-configs-schema.md +232 -0
  213. package/substrate/standards/bassclef-evolution.md +143 -0
  214. package/substrate/standards/bassclef-internal-jargon.md +244 -0
  215. package/substrate/standards/bassclef-managed-sentinel.md +96 -0
  216. package/substrate/standards/bassclef-source-config.md +228 -0
  217. package/substrate/standards/branch-stacking.md +408 -0
  218. package/substrate/standards/code-safety-principles.md +176 -0
  219. package/substrate/standards/composer-prerequisites.md +155 -0
  220. package/substrate/standards/deferred-actions-schema.md +204 -0
  221. package/substrate/standards/dependency-discipline/cargo.md +39 -0
  222. package/substrate/standards/dependency-discipline/gem.md +43 -0
  223. package/substrate/standards/dependency-discipline/go-mod.md +41 -0
  224. package/substrate/standards/dependency-discipline/npm.md +42 -0
  225. package/substrate/standards/dependency-discipline/pip.md +42 -0
  226. package/substrate/standards/deployment-topology/ec2-tailscale.md +225 -0
  227. package/substrate/standards/deployment-topology.md +69 -0
  228. package/substrate/standards/docs-sync-allowlist.md +76 -0
  229. package/substrate/standards/domain-and-dns.md +145 -0
  230. package/substrate/standards/frontend-stack.md +67 -0
  231. package/substrate/standards/frontmatter-schema.md +154 -0
  232. package/substrate/standards/graceful-exit.md +227 -0
  233. package/substrate/standards/hook-idempotency.md +102 -0
  234. package/substrate/standards/hook-injection-discipline.md +202 -0
  235. package/substrate/standards/hook-install-class.md +215 -0
  236. package/substrate/standards/input-handler-interface.md +152 -0
  237. package/substrate/standards/lite-manifest-schema-changes.md +135 -0
  238. package/substrate/standards/luminary-matching.md +105 -0
  239. package/substrate/standards/luminary-problem-patterns.md +481 -0
  240. package/substrate/standards/migration-discipline/active-record.md +50 -0
  241. package/substrate/standards/migration-discipline/alembic.md +43 -0
  242. package/substrate/standards/migration-discipline/gorm.md +50 -0
  243. package/substrate/standards/migration-discipline/prisma.md +53 -0
  244. package/substrate/standards/migration-discipline/sqlalchemy.md +51 -0
  245. package/substrate/standards/mobile-ephemeral-session.md +167 -0
  246. package/substrate/standards/model-routing-discipline.md +160 -0
  247. package/substrate/standards/ogilvy-writing-rules.md +225 -0
  248. package/substrate/standards/opener-discipline.md +96 -0
  249. package/substrate/standards/operator-facing-prose-discipline.md +201 -0
  250. package/substrate/standards/persona-schema.md +229 -0
  251. package/substrate/standards/pluggable-luminaries.md +323 -0
  252. package/substrate/standards/pr-body-discipline.md +115 -0
  253. package/substrate/standards/preview-state-schema.md +189 -0
  254. package/substrate/standards/project-directory-layout.md +276 -0
  255. package/substrate/standards/release-tagging.md +137 -0
  256. package/substrate/standards/reserved-skill-names.md +120 -0
  257. package/substrate/standards/scannable-multi-option-output.md +261 -0
  258. package/substrate/standards/sdlc-compliance.md +286 -0
  259. package/substrate/standards/sdlc-gates/typescript.md +57 -0
  260. package/substrate/standards/secrets-lifecycle.md +210 -0
  261. package/substrate/standards/security-scanner-adapter.md +145 -0
  262. package/substrate/standards/session-board.md +256 -0
  263. package/substrate/standards/skill-output-discipline.md +90 -0
  264. package/substrate/standards/state-spine-contract.md +255 -0
  265. package/substrate/standards/state-spine.md +511 -0
  266. package/substrate/standards/steering-hints/kiss-words.md +11 -0
  267. package/substrate/standards/substrate-config-schema.md +267 -0
  268. package/substrate/standards/tech-stack-config.md +109 -0
  269. package/substrate/standards/tier-dependency-analysis.md +167 -0
  270. package/substrate/standards/tier-runtime-deps/lite.md +57 -0
  271. package/substrate/standards/tier-tag-schema.md +155 -0
  272. package/substrate/standards/two-layer-config.md +99 -0
  273. package/substrate/standards/use-case-format.md +292 -0
  274. package/substrate/standards/user-story-invest.md +268 -0
  275. package/substrate/standards/velocity-and-appetite.md +229 -0
  276. package/substrate/standards/voice-input-pattern.md +119 -0
  277. package/substrate/standards/whereami-schema.md +301 -0
  278. package/substrate/standards/worktree-management.md +211 -0
  279. package/substrate/standards/writing-guide.md +213 -0
  280. package/substrate/templates/chronicle-template.md +75 -0
  281. package/substrate/templates/deferred-action-template.md +45 -0
  282. package/substrate/templates/memory-proposal-template.md +77 -0
  283. package/substrate/templates/persona-template.md +200 -0
  284. package/substrate/templates/pr-faq.md +45 -0
  285. package/substrate/templates/secret-rotation-template.md +162 -0
  286. package/substrate/templates/spec-template.md +131 -0
  287. package/substrate/templates/use-case-template.md +194 -0
  288. package/substrate/templates/user-story-template.md +107 -0
  289. package/substrate/templates/whereami-template.md +101 -0
@@ -0,0 +1,214 @@
1
+ #!/bin/bash
2
+ # tier: lite
3
+ # rewrite-check.sh — six heuristic checks for /kiss REWRITE mode (goal 25d Step 5).
4
+ #
5
+ # Grounded in four public sources:
6
+ # - UK ONS Style Guide — Plain English section
7
+ # - Nielsen Norman Group — Plain Language for Experts (2018)
8
+ # - US Federal Plain Language Guidelines (plainlanguage.gov)
9
+ # - Hemingway Editor heuristics (public rules — passive, adverbs, long sentences)
10
+ #
11
+ # The six checks are HEURISTIC not perfect NLP. They surface CANDIDATES for
12
+ # human review. Not a gate. Not a blocking check. Exit 0 always.
13
+ #
14
+ # Sister to lib/output-discipline.sh (classifier for /kiss dispatch presence)
15
+ # and lib/code-comment-discipline.sh (classifier for header comment jargon).
16
+ # Same Ousterhout deep-module shape — small interface, shared implementation.
17
+ #
18
+ # Per bassclef-upstream#859 Iteration D + goal 25d Step 5.
19
+ # Bash 3.2+ compatible.
20
+ #
21
+ # Usage — sourced by /kiss words --rewrite mode:
22
+ # source lib/rewrite-check.sh
23
+ # check_passive_voice <file> # prints lines with passive-voice patterns
24
+ # check_hyphen_words <file> # prints hyphenated compound words flagged
25
+ # check_sentence_length <file> [N] # prints sentences over N words (default 25)
26
+ # check_svo <file> # prints sentences NOT starting with subject
27
+ # check_noun_stack <file> # prints 3+ noun runs without verb
28
+ # check_adverb_density <file> # prints density note if >5% -ly adverbs
29
+ # run_rewrite_checks <file> # runs all six; prints findings table
30
+
31
+ set -o pipefail
32
+
33
+ # === Standard tech hyphens allow-list ===
34
+ # Common tech compound words that should NOT be flagged as jargon.
35
+ # Grep-alternation shape (pipe-separated).
36
+ REWRITE_TECH_HYPHENS='pre-commit|pre-push|post-commit|post-push|real-time|data-driven|end-to-end|non-blocking|read-only|copy-on-write|test-driven|type-safe|open-source|self-hosted|cross-platform|multi-tenant|single-tenant|full-stack|front-end|back-end|no-op|no-code|low-code|check-in|check-out|log-in|log-out|sign-in|sign-out|drop-down|pop-up|pull-request|merge-request|feature-branch|main-branch|no-fast-forward|off-the-shelf|out-of-the-box'
37
+
38
+ # === Passive voice check ===
39
+ # Pattern per Hemingway Editor: "to be" + past participle + optional "by".
40
+ # Common shapes:
41
+ # was <verb-ed> by
42
+ # were <verb-ed> by
43
+ # has been <verb-ed>
44
+ # have been <verb-ed>
45
+ # had been <verb-ed>
46
+ # is being <verb-ed>
47
+ # was <verb-ed>
48
+ # Returns matching lines. Exit 0 always.
49
+ check_passive_voice() {
50
+ local file="$1"
51
+ [ -f "$file" ] || return 0
52
+ grep -niE '\b(was|were|has been|have been|had been|is being|are being|will be) [a-z]+(ed|en) (by|to)\b|\b(was|were|has been|have been|had been) [a-z]+(ed|en)\b' "$file" 2>/dev/null
53
+ return 0
54
+ }
55
+
56
+ # === Hyphen-word check ===
57
+ # Flag hyphenated compounds that are NOT in the standard tech allow-list.
58
+ # Per operator-facing-prose.md — hyphen words like X-side, N-layer X, X-as-Y
59
+ # should be rewritten to plain description.
60
+ check_hyphen_words() {
61
+ local file="$1"
62
+ [ -f "$file" ] || return 0
63
+ # Extract hyphenated words (letters-letters); filter to those NOT in the allow-list
64
+ # AND that look like adjective compounds (letters-letters where both parts are 2+ chars).
65
+ grep -oE '\b[a-z]{2,}-[a-z]{2,}\b' "$file" 2>/dev/null \
66
+ | sort -u \
67
+ | grep -vwE "$REWRITE_TECH_HYPHENS" \
68
+ | head -20
69
+ return 0
70
+ }
71
+
72
+ # === Sentence length check ===
73
+ # Flag sentences over N words (default 25 per Hemingway + Federal Plain
74
+ # Language recommendation). Very-long sentences (>30) get the strong flag.
75
+ check_sentence_length() {
76
+ local file="$1"
77
+ local ceiling="${2:-25}"
78
+ [ -f "$file" ] || return 0
79
+ # Split on sentence-ending punctuation, count words per sentence.
80
+ # awk splits, counts words, flags any over ceiling.
81
+ awk -v CEIL="$ceiling" '
82
+ BEGIN { RS = "[.!?][[:space:]]+" }
83
+ {
84
+ # Count words (whitespace-separated tokens)
85
+ n = split($0, words, /[[:space:]]+/)
86
+ if (n > CEIL) {
87
+ # Trim + print first 60 chars for context
88
+ sample = substr($0, 1, 60)
89
+ gsub(/\n/, " ", sample)
90
+ printf "SENTENCE: %d words — %s...\n", n, sample
91
+ }
92
+ }
93
+ ' "$file" 2>/dev/null
94
+ return 0
95
+ }
96
+
97
+ # === SVO check ===
98
+ # Heuristic: flag sentences that START with a preposition or subordinating
99
+ # conjunction rather than a subject. Common non-SVO openers:
100
+ # Because, Although, While, When, If, Since, Unless, Whereas, After, Before
101
+ # In X, On X, At X, With X, Under X, Without X, Despite X, Given X
102
+ # This catches the most common non-SVO shapes. False positives happen on
103
+ # legitimate variety; the check surfaces candidates for review.
104
+ check_svo() {
105
+ local file="$1"
106
+ [ -f "$file" ] || return 0
107
+ # Grep for lines starting with (after optional whitespace/quote) a non-SVO opener.
108
+ grep -niE '^[[:space:]]*(Because|Although|While|When|If|Since|Unless|Whereas|After|Before|In [A-Z]|On [A-Z]|At [A-Z]|With [A-Z]|Under [A-Z]|Without [A-Z]|Despite|Given)\b' "$file" 2>/dev/null
109
+ return 0
110
+ }
111
+
112
+ # === Noun-stack check ===
113
+ # Per operator-facing-prose.md: no more than 2 nouns in a row without a verb.
114
+ # Heuristic: look for 3+ consecutive words that end in common noun suffixes
115
+ # OR that are capitalized (proper nouns). Approximate.
116
+ #
117
+ # The heuristic flags runs of 3+ words that look like nouns (no verb-form
118
+ # suffix like -ed, -ing, -es, -s at verb pattern). Bash regex is limited;
119
+ # we use a simple approximation:
120
+ # - 3+ consecutive words each 4+ chars long
121
+ # - none ending in -ed, -ing, -ly, -s (verb / adverb / plural marker)
122
+ # - separated by single space (not by "the", "a", "an", "and", "or", "of")
123
+ # Approximation: words separated only by spaces (no articles/verbs between).
124
+ check_noun_stack() {
125
+ local file="$1"
126
+ [ -f "$file" ] || return 0
127
+ # Simple heuristic: match "word word word word" with no small connector.
128
+ # Look for runs of 4+ non-tiny words in a row.
129
+ awk '
130
+ {
131
+ # Split into words, find runs of 3+ nouny-looking tokens
132
+ n = split($0, w, /[[:space:]]+/)
133
+ run = 0
134
+ run_words = ""
135
+ for (i = 1; i <= n; i++) {
136
+ word = w[i]
137
+ # Strip punctuation for the check
138
+ clean = word
139
+ gsub(/[^A-Za-z]/, "", clean)
140
+ # Nouny heuristic: 4+ chars, not a verb/adverb marker, not a small word
141
+ if (length(clean) >= 4 \
142
+ && clean !~ /^(the|and|for|with|from|that|this|when|where|which|been|were|have|will|would|could|should|about|because|through|these|those)$/ \
143
+ && clean !~ /(ing|ed|ly)$/) {
144
+ run++
145
+ run_words = run_words " " clean
146
+ } else {
147
+ if (run >= 3) {
148
+ printf "NOUN-STACK: %d nouns —%s\n", run, run_words
149
+ }
150
+ run = 0
151
+ run_words = ""
152
+ }
153
+ }
154
+ if (run >= 3) {
155
+ printf "NOUN-STACK: %d nouns —%s\n", run, run_words
156
+ }
157
+ }
158
+ ' "$file" 2>/dev/null
159
+ return 0
160
+ }
161
+
162
+ # === Adverb density check ===
163
+ # Per Hemingway Editor: -ly adverbs above 1 per 20 words signal weak verbs.
164
+ # Federal Plain Language: prefer strong verbs over adverbs.
165
+ # Threshold: >5% (equivalent to 1 per 20 words).
166
+ check_adverb_density() {
167
+ local file="$1"
168
+ [ -f "$file" ] || return 0
169
+ local total_words adverb_count percent
170
+ # Count total words
171
+ total_words=$(tr -s '[:space:]' '\n' < "$file" | grep -cE '^[A-Za-z]+' 2>/dev/null || echo 0)
172
+ # Count -ly adverbs (word ending -ly, excluding common -ly words that aren't adverbs)
173
+ adverb_count=$(grep -oiE '\b[a-z]{3,}ly\b' "$file" 2>/dev/null \
174
+ | grep -viwE 'only|early|ally|belly|silly|fully|jolly|holy|really|apply|comply|imply|reply|supply|family|reply' \
175
+ | wc -l | tr -d ' ')
176
+ if [ "$total_words" -eq 0 ]; then
177
+ return 0
178
+ fi
179
+ # Compute percent (integer math * 1000 for one decimal)
180
+ percent=$((adverb_count * 1000 / total_words))
181
+ # Threshold: 50 = 5.0%
182
+ if [ "$percent" -gt 50 ]; then
183
+ printf "ADVERB density: %d/%d words = %d.%d%%\n" \
184
+ "$adverb_count" "$total_words" "$((percent / 10))" "$((percent % 10))"
185
+ fi
186
+ return 0
187
+ }
188
+
189
+ # === Composite check ===
190
+ # Runs all six checks against a file. Prints a findings table.
191
+ # Exit 0 always (informational, not a gate).
192
+ run_rewrite_checks() {
193
+ local file="$1"
194
+ [ -f "$file" ] || return 0
195
+ local passive hyphens length svo nouns adverbs
196
+ passive=$(check_passive_voice "$file")
197
+ hyphens=$(check_hyphen_words "$file")
198
+ length=$(check_sentence_length "$file")
199
+ svo=$(check_svo "$file")
200
+ nouns=$(check_noun_stack "$file")
201
+ adverbs=$(check_adverb_density "$file")
202
+
203
+ echo "=== REWRITE check findings: $file ==="
204
+ [ -n "$passive" ] && { echo "-- passive voice --"; echo "$passive"; }
205
+ [ -n "$hyphens" ] && { echo "-- hyphen compounds --"; echo "$hyphens"; }
206
+ [ -n "$length" ] && { echo "-- long sentences --"; echo "$length"; }
207
+ [ -n "$svo" ] && { echo "-- non-SVO openers --"; echo "$svo"; }
208
+ [ -n "$nouns" ] && { echo "-- noun stacks --"; echo "$nouns"; }
209
+ [ -n "$adverbs" ] && { echo "-- adverb density --"; echo "$adverbs"; }
210
+ if [ -z "$passive$hyphens$length$svo$nouns$adverbs" ]; then
211
+ echo "CLEAN — no rewrite findings"
212
+ fi
213
+ return 0
214
+ }