safeword 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/.claude/commands/arch-review.md +32 -0
  2. package/.claude/commands/lint.md +6 -0
  3. package/.claude/commands/quality-review.md +13 -0
  4. package/.claude/commands/setup-linting.md +6 -0
  5. package/.claude/hooks/auto-lint.sh +6 -0
  6. package/.claude/hooks/auto-quality-review.sh +170 -0
  7. package/.claude/hooks/check-linting-sync.sh +17 -0
  8. package/.claude/hooks/inject-timestamp.sh +6 -0
  9. package/.claude/hooks/question-protocol.sh +12 -0
  10. package/.claude/hooks/run-linters.sh +8 -0
  11. package/.claude/hooks/run-quality-review.sh +76 -0
  12. package/.claude/hooks/version-check.sh +10 -0
  13. package/.claude/mcp/README.md +96 -0
  14. package/.claude/mcp/arcade.sample.json +9 -0
  15. package/.claude/mcp/context7.sample.json +7 -0
  16. package/.claude/mcp/playwright.sample.json +7 -0
  17. package/.claude/settings.json +62 -0
  18. package/.claude/skills/quality-reviewer/SKILL.md +190 -0
  19. package/.claude/skills/safeword-quality-reviewer/SKILL.md +13 -0
  20. package/.env.arcade.example +4 -0
  21. package/.env.example +11 -0
  22. package/.gitmodules +4 -0
  23. package/.safeword/SAFEWORD.md +33 -0
  24. package/.safeword/eslint/eslint-base.mjs +101 -0
  25. package/.safeword/guides/architecture-guide.md +404 -0
  26. package/.safeword/guides/code-philosophy.md +174 -0
  27. package/.safeword/guides/context-files-guide.md +405 -0
  28. package/.safeword/guides/data-architecture-guide.md +183 -0
  29. package/.safeword/guides/design-doc-guide.md +165 -0
  30. package/.safeword/guides/learning-extraction.md +515 -0
  31. package/.safeword/guides/llm-instruction-design.md +239 -0
  32. package/.safeword/guides/llm-prompting.md +95 -0
  33. package/.safeword/guides/tdd-best-practices.md +570 -0
  34. package/.safeword/guides/test-definitions-guide.md +243 -0
  35. package/.safeword/guides/testing-methodology.md +573 -0
  36. package/.safeword/guides/user-story-guide.md +237 -0
  37. package/.safeword/guides/zombie-process-cleanup.md +214 -0
  38. package/{templates → .safeword}/hooks/agents-md-check.sh +0 -0
  39. package/{templates → .safeword}/hooks/post-tool.sh +0 -0
  40. package/{templates → .safeword}/hooks/pre-commit.sh +0 -0
  41. package/.safeword/planning/002-user-story-quality-evaluation.md +1840 -0
  42. package/.safeword/planning/003-langsmith-eval-setup-prompt.md +363 -0
  43. package/.safeword/planning/004-llm-eval-test-cases.md +3226 -0
  44. package/.safeword/planning/005-architecture-enforcement-system.md +169 -0
  45. package/.safeword/planning/006-reactive-fix-prevention-research.md +135 -0
  46. package/.safeword/planning/011-cli-ux-vision.md +330 -0
  47. package/.safeword/planning/012-project-structure-cleanup.md +154 -0
  48. package/.safeword/planning/README.md +39 -0
  49. package/.safeword/planning/automation-plan-v2.md +1225 -0
  50. package/.safeword/planning/automation-plan-v3.md +1291 -0
  51. package/.safeword/planning/automation-plan.md +3058 -0
  52. package/.safeword/planning/design/005-cli-implementation.md +343 -0
  53. package/.safeword/planning/design/013-cli-self-contained-templates.md +596 -0
  54. package/.safeword/planning/design/013a-eslint-plugin-suite.md +256 -0
  55. package/.safeword/planning/design/013b-implementation-snippets.md +385 -0
  56. package/.safeword/planning/design/013c-config-isolation-strategy.md +242 -0
  57. package/.safeword/planning/design/code-philosophy-improvements.md +60 -0
  58. package/.safeword/planning/mcp-analysis.md +545 -0
  59. package/.safeword/planning/phase2-subagents-vs-skills-analysis.md +451 -0
  60. package/.safeword/planning/settings-improvements.md +970 -0
  61. package/.safeword/planning/test-definitions/005-cli-implementation.md +1301 -0
  62. package/.safeword/planning/test-definitions/cli-self-contained-templates.md +205 -0
  63. package/.safeword/planning/user-stories/001-guides-review-user-stories.md +1381 -0
  64. package/.safeword/planning/user-stories/003-reactive-fix-prevention.md +132 -0
  65. package/.safeword/planning/user-stories/004-technical-constraints.md +86 -0
  66. package/.safeword/planning/user-stories/005-cli-implementation.md +311 -0
  67. package/.safeword/planning/user-stories/cli-self-contained-templates.md +172 -0
  68. package/.safeword/planning/versioned-distribution.md +740 -0
  69. package/.safeword/prompts/arch-review.md +43 -0
  70. package/.safeword/prompts/quality-review.md +11 -0
  71. package/.safeword/scripts/arch-review.sh +235 -0
  72. package/.safeword/scripts/check-linting-sync.sh +58 -0
  73. package/.safeword/scripts/setup-linting.sh +559 -0
  74. package/.safeword/templates/architecture-template.md +136 -0
  75. package/.safeword/templates/ci/architecture-check.yml +79 -0
  76. package/.safeword/templates/design-doc-template.md +127 -0
  77. package/.safeword/templates/test-definitions-feature.md +100 -0
  78. package/.safeword/templates/ticket-template.md +74 -0
  79. package/.safeword/templates/user-stories-template.md +82 -0
  80. package/.safeword/tickets/001-guides-review-user-stories.md +83 -0
  81. package/.safeword/tickets/002-architecture-enforcement.md +211 -0
  82. package/.safeword/tickets/003-reactive-fix-prevention.md +57 -0
  83. package/.safeword/tickets/004-technical-constraints-in-user-stories.md +39 -0
  84. package/.safeword/tickets/005-cli-implementation.md +248 -0
  85. package/.safeword/tickets/006-flesh-out-skills.md +43 -0
  86. package/.safeword/tickets/007-flesh-out-questioning.md +44 -0
  87. package/.safeword/tickets/008-upgrade-questioning.md +58 -0
  88. package/.safeword/tickets/009-naming-conventions.md +41 -0
  89. package/.safeword/tickets/010-safeword-md-cleanup.md +34 -0
  90. package/.safeword/tickets/011-cursor-setup.md +86 -0
  91. package/.safeword/tickets/README.md +73 -0
  92. package/.safeword/version +1 -0
  93. package/AGENTS.md +59 -0
  94. package/CLAUDE.md +12 -0
  95. package/README.md +347 -0
  96. package/docs/001-cli-implementation-plan.md +856 -0
  97. package/docs/elite-dx-implementation-plan.md +1034 -0
  98. package/framework/README.md +131 -0
  99. package/framework/mcp/README.md +96 -0
  100. package/framework/mcp/arcade.sample.json +8 -0
  101. package/framework/mcp/context7.sample.json +6 -0
  102. package/framework/mcp/playwright.sample.json +6 -0
  103. package/framework/scripts/arch-review.sh +235 -0
  104. package/framework/scripts/check-linting-sync.sh +58 -0
  105. package/framework/scripts/load-env.sh +49 -0
  106. package/framework/scripts/setup-claude.sh +223 -0
  107. package/framework/scripts/setup-linting.sh +559 -0
  108. package/framework/scripts/setup-quality.sh +477 -0
  109. package/framework/scripts/setup-safeword.sh +550 -0
  110. package/framework/templates/ci/architecture-check.yml +78 -0
  111. package/learnings/ai-sdk-v5-breaking-changes.md +178 -0
  112. package/learnings/e2e-test-zombie-processes.md +231 -0
  113. package/learnings/milkdown-crepe-editor-property.md +96 -0
  114. package/learnings/prosemirror-fragment-traversal.md +119 -0
  115. package/package.json +19 -43
  116. package/packages/cli/AGENTS.md +1 -0
  117. package/packages/cli/ARCHITECTURE.md +279 -0
  118. package/packages/cli/package.json +51 -0
  119. package/packages/cli/src/cli.ts +63 -0
  120. package/packages/cli/src/commands/check.ts +166 -0
  121. package/packages/cli/src/commands/diff.ts +209 -0
  122. package/packages/cli/src/commands/reset.ts +190 -0
  123. package/packages/cli/src/commands/setup.ts +325 -0
  124. package/packages/cli/src/commands/upgrade.ts +163 -0
  125. package/packages/cli/src/index.ts +3 -0
  126. package/packages/cli/src/templates/config.ts +58 -0
  127. package/packages/cli/src/templates/content.ts +18 -0
  128. package/packages/cli/src/templates/index.ts +12 -0
  129. package/packages/cli/src/utils/agents-md.ts +66 -0
  130. package/packages/cli/src/utils/fs.ts +179 -0
  131. package/packages/cli/src/utils/git.ts +124 -0
  132. package/packages/cli/src/utils/hooks.ts +29 -0
  133. package/packages/cli/src/utils/output.ts +60 -0
  134. package/packages/cli/src/utils/project-detector.test.ts +185 -0
  135. package/packages/cli/src/utils/project-detector.ts +44 -0
  136. package/packages/cli/src/utils/version.ts +28 -0
  137. package/packages/cli/src/version.ts +6 -0
  138. package/packages/cli/templates/SAFEWORD.md +776 -0
  139. package/packages/cli/templates/doc-templates/architecture-template.md +136 -0
  140. package/packages/cli/templates/doc-templates/design-doc-template.md +134 -0
  141. package/packages/cli/templates/doc-templates/test-definitions-feature.md +131 -0
  142. package/packages/cli/templates/doc-templates/ticket-template.md +82 -0
  143. package/packages/cli/templates/doc-templates/user-stories-template.md +92 -0
  144. package/packages/cli/templates/guides/architecture-guide.md +423 -0
  145. package/packages/cli/templates/guides/code-philosophy.md +195 -0
  146. package/packages/cli/templates/guides/context-files-guide.md +457 -0
  147. package/packages/cli/templates/guides/data-architecture-guide.md +200 -0
  148. package/packages/cli/templates/guides/design-doc-guide.md +171 -0
  149. package/packages/cli/templates/guides/learning-extraction.md +552 -0
  150. package/packages/cli/templates/guides/llm-instruction-design.md +248 -0
  151. package/packages/cli/templates/guides/llm-prompting.md +102 -0
  152. package/packages/cli/templates/guides/tdd-best-practices.md +615 -0
  153. package/packages/cli/templates/guides/test-definitions-guide.md +334 -0
  154. package/packages/cli/templates/guides/testing-methodology.md +618 -0
  155. package/packages/cli/templates/guides/user-story-guide.md +256 -0
  156. package/packages/cli/templates/guides/zombie-process-cleanup.md +219 -0
  157. package/packages/cli/templates/hooks/agents-md-check.sh +27 -0
  158. package/packages/cli/templates/hooks/post-tool.sh +4 -0
  159. package/packages/cli/templates/hooks/pre-commit.sh +10 -0
  160. package/packages/cli/templates/prompts/arch-review.md +43 -0
  161. package/packages/cli/templates/prompts/quality-review.md +10 -0
  162. package/packages/cli/templates/skills/safeword-quality-reviewer/SKILL.md +207 -0
  163. package/packages/cli/tests/commands/check.test.ts +129 -0
  164. package/packages/cli/tests/commands/cli.test.ts +89 -0
  165. package/packages/cli/tests/commands/diff.test.ts +115 -0
  166. package/packages/cli/tests/commands/reset.test.ts +310 -0
  167. package/packages/cli/tests/commands/self-healing.test.ts +170 -0
  168. package/packages/cli/tests/commands/setup-blocking.test.ts +71 -0
  169. package/packages/cli/tests/commands/setup-core.test.ts +135 -0
  170. package/packages/cli/tests/commands/setup-git.test.ts +139 -0
  171. package/packages/cli/tests/commands/setup-hooks.test.ts +334 -0
  172. package/packages/cli/tests/commands/setup-linting.test.ts +189 -0
  173. package/packages/cli/tests/commands/setup-noninteractive.test.ts +80 -0
  174. package/packages/cli/tests/commands/setup-templates.test.ts +181 -0
  175. package/packages/cli/tests/commands/upgrade.test.ts +215 -0
  176. package/packages/cli/tests/helpers.ts +243 -0
  177. package/packages/cli/tests/npm-package.test.ts +83 -0
  178. package/packages/cli/tests/technical-constraints.test.ts +96 -0
  179. package/packages/cli/tsconfig.json +25 -0
  180. package/packages/cli/tsup.config.ts +11 -0
  181. package/packages/cli/vitest.config.ts +23 -0
  182. package/promptfoo.yaml +3270 -0
  183. package/dist/check-M73LGONJ.js +0 -129
  184. package/dist/check-M73LGONJ.js.map +0 -1
  185. package/dist/chunk-2XWIUEQK.js +0 -190
  186. package/dist/chunk-2XWIUEQK.js.map +0 -1
  187. package/dist/chunk-GZRQL3SX.js +0 -146
  188. package/dist/chunk-GZRQL3SX.js.map +0 -1
  189. package/dist/chunk-V5G6BGOK.js +0 -26
  190. package/dist/chunk-V5G6BGOK.js.map +0 -1
  191. package/dist/chunk-W66Z3C5H.js +0 -21
  192. package/dist/chunk-W66Z3C5H.js.map +0 -1
  193. package/dist/cli.d.ts +0 -1
  194. package/dist/cli.js +0 -34
  195. package/dist/cli.js.map +0 -1
  196. package/dist/diff-FSFDCBL5.js +0 -166
  197. package/dist/diff-FSFDCBL5.js.map +0 -1
  198. package/dist/index.d.ts +0 -11
  199. package/dist/index.js +0 -7
  200. package/dist/index.js.map +0 -1
  201. package/dist/reset-3ACTIYYE.js +0 -143
  202. package/dist/reset-3ACTIYYE.js.map +0 -1
  203. package/dist/setup-MKVVQTVA.js +0 -266
  204. package/dist/setup-MKVVQTVA.js.map +0 -1
  205. package/dist/upgrade-FQOL6AF5.js +0 -134
  206. package/dist/upgrade-FQOL6AF5.js.map +0 -1
  207. /package/{templates → framework}/SAFEWORD.md +0 -0
  208. /package/{templates → framework}/guides/architecture-guide.md +0 -0
  209. /package/{templates → framework}/guides/code-philosophy.md +0 -0
  210. /package/{templates → framework}/guides/context-files-guide.md +0 -0
  211. /package/{templates → framework}/guides/data-architecture-guide.md +0 -0
  212. /package/{templates → framework}/guides/design-doc-guide.md +0 -0
  213. /package/{templates → framework}/guides/learning-extraction.md +0 -0
  214. /package/{templates → framework}/guides/llm-instruction-design.md +0 -0
  215. /package/{templates → framework}/guides/llm-prompting.md +0 -0
  216. /package/{templates → framework}/guides/tdd-best-practices.md +0 -0
  217. /package/{templates → framework}/guides/test-definitions-guide.md +0 -0
  218. /package/{templates → framework}/guides/testing-methodology.md +0 -0
  219. /package/{templates → framework}/guides/user-story-guide.md +0 -0
  220. /package/{templates → framework}/guides/zombie-process-cleanup.md +0 -0
  221. /package/{templates → framework}/prompts/arch-review.md +0 -0
  222. /package/{templates → framework}/prompts/quality-review.md +0 -0
  223. /package/{templates/skills/safeword-quality-reviewer → framework/skills/quality-reviewer}/SKILL.md +0 -0
  224. /package/{templates/doc-templates → framework/templates}/architecture-template.md +0 -0
  225. /package/{templates/doc-templates → framework/templates}/design-doc-template.md +0 -0
  226. /package/{templates/doc-templates → framework/templates}/test-definitions-feature.md +0 -0
  227. /package/{templates/doc-templates → framework/templates}/ticket-template.md +0 -0
  228. /package/{templates/doc-templates → framework/templates}/user-stories-template.md +0 -0
  229. /package/{templates → packages/cli/templates}/commands/arch-review.md +0 -0
  230. /package/{templates → packages/cli/templates}/commands/lint.md +0 -0
  231. /package/{templates → packages/cli/templates}/commands/quality-review.md +0 -0
  232. /package/{templates → packages/cli/templates}/hooks/inject-timestamp.sh +0 -0
  233. /package/{templates → packages/cli/templates}/lib/common.sh +0 -0
  234. /package/{templates → packages/cli/templates}/lib/jq-fallback.sh +0 -0
  235. /package/{templates → packages/cli/templates}/markdownlint.jsonc +0 -0
@@ -0,0 +1,740 @@
1
+ # Versioned Distribution Plan (Project-Local SAFEWORD)
2
+
3
+ **Goal:** Make the setup scripts distributable with proper versioning, zero global dependencies, and minimal bloat using project-local SAFEWORD.
4
+
5
+ **Status:** Planning
6
+ **Created:** 2025-11-22
7
+
8
+ ---
9
+
10
+ ## Problem Statement
11
+
12
+ **Current state (to eliminate):**
13
+
14
+ - Quality review hooks referenced from a global location
15
+ - Projects reference absolute paths
16
+ - External users rely on a global folder
17
+ - No versioning system
18
+ - Linting setup works (self-contained via heredocs), quality review doesn't
19
+
20
+ **Requirements:**
21
+
22
+ 1. External users can download and use without ANY global .agents folder
23
+ 2. All projects are 100% self-contained (no global dependencies, no shared folders)
24
+ 3. Setup scripts contain ALL code inline (heredocs only, no external file references)
25
+ 4. Versioned releases using git tags
26
+ 5. Each project knows what version generated its files
27
+ 6. Simple upgrade path (re-run setup script)
28
+ 7. Zero bloat (no CLI, no lock files, no package managers, no global folders)
29
+
30
+ ---
31
+
32
+ ## Architecture
33
+
34
+ ### Development (You)
35
+
36
+ ```
37
+ framework/scripts/ # Project-local setup scripts
38
+ ├── setup-linting.sh # ✅ Self-contained (all code inline via heredocs)
39
+ ├── setup-quality.sh # ✅ Self-contained (all code inline)
40
+ └── ../guides/ # Reference docs copied into projects
41
+ ```
42
+
43
+ **Key principle:** Setup scripts ARE the source of truth. They contain all code inline using heredocs. No external file dependencies.
44
+
45
+ ### Distribution (External Users)
46
+
47
+ ```bash
48
+ # Users run ONE command per feature (project-local only, no global folder needed):
49
+ curl https://raw.githubusercontent.com/YOU/agents/v1.0.0/setup-linting.sh | bash -s -- --biome
50
+ curl https://raw.githubusercontent.com/YOU/safeword/v1.0.0/framework/scripts/setup-quality.sh | bash
51
+
52
+ # Creates in their project (100% self-contained):
53
+ project/.claude/
54
+ ├── hooks/
55
+ │ ├── auto-lint.sh # Generated from heredoc in setup-linting.sh
56
+ │ ├── run-linters.sh # Generated from heredoc in setup-linting.sh
57
+ │ ├── auto-quality-review.sh # Generated from heredoc in setup-quality.sh
58
+ │ └── run-quality-review.sh # Generated from heredoc in setup-quality.sh
59
+ ├── commands/
60
+ │ ├── lint.md # Generated from heredoc in setup-linting.sh
61
+ │ └── quality-review.md # Generated from heredoc in setup-quality.sh
62
+ └── settings.json # Merged by both scripts
63
+ ```
64
+
65
+ **Key principles:**
66
+
67
+ - No global folders
68
+ - Everything generated from inline heredocs in setup scripts
69
+ - Setup scripts are self-contained (can be distributed as single files)
70
+ - Zero external dependencies
71
+
72
+ ---
73
+
74
+ ## Implementation Tasks
75
+
76
+ ### Task 1: Create `setup-quality.sh`
77
+
78
+ **Status:** Not started
79
+ **Analogous to:** `setup-linting.sh`
80
+
81
+ **What it does:**
82
+
83
+ 1. Checks for dependencies (jq, bash)
84
+ 2. Creates `.claude/hooks/` directory
85
+ 3. **Generates** `auto-quality-review.sh` from inline heredoc (no external file)
86
+ 4. **Generates** `run-quality-review.sh` from inline heredoc (no external file)
87
+ 5. Creates `.claude/commands/quality-review.md` from inline heredoc
88
+ 6. Updates `.claude/settings.json` (adds Stop hook with LOCAL path)
89
+ 7. Adds version comment to all generated files
90
+
91
+ **Source of code:**
92
+
93
+ - Inline heredocs embedded directly inside `setup-quality.sh`
94
+ - Add `chmod +x` for generated hooks
95
+ - Result: setup-quality.sh is 100% self-contained
96
+
97
+ **Script structure:**
98
+
99
+ ```bash
100
+ #!/bin/bash
101
+ # setup-quality.sh
102
+
103
+ VERSION="v1.0.0" # Updated by git tag
104
+ PROJECT_ROOT="$(pwd)"
105
+
106
+ echo "================================="
107
+ echo "Claude Code Quality Review Setup"
108
+ echo "Version: $VERSION"
109
+ echo "================================="
110
+
111
+ # Step 1: Check dependencies
112
+ # Step 2: Create directories
113
+ # Step 3: Copy hooks (inline heredoc, not file copy)
114
+ # Step 4: Create slash command
115
+ # Step 5: Update settings.json (merge, don't overwrite)
116
+ # Step 6: Print success message
117
+ ```
118
+
119
+ **Files to generate:**
120
+
121
+ 1. `.claude/hooks/auto-quality-review.sh`
122
+
123
+ ```bash
124
+ #!/bin/bash
125
+ # Generated by https://github.com/YOU/agents v1.0.0
126
+ # To update: curl https://raw.../v1.0.0/framework/scripts/setup-quality.sh | bash
127
+
128
+ # [inline copy of current auto-quality-review.sh]
129
+ ```
130
+
131
+ 2. `.claude/hooks/run-quality-review.sh`
132
+
133
+ ```bash
134
+ #!/bin/bash
135
+ # Generated by https://github.com/YOU/agents v1.0.0
136
+ # To update: curl https://raw.../v1.0.0/framework/scripts/setup-quality.sh | bash
137
+
138
+ # [inline copy of current run-quality-review.sh]
139
+ ```
140
+
141
+ 3. `.claude/commands/quality-review.md`
142
+
143
+ ````markdown
144
+ Trigger a quality review to double-check your work.
145
+
146
+ Execute:
147
+
148
+ ```bash
149
+ bash .claude/hooks/run-quality-review.sh
150
+ ```
151
+ ````
152
+
153
+ ```
154
+
155
+ ```
156
+
157
+ 4. `.claude/settings.json` (merge with existing)
158
+ ```json
159
+ {
160
+ "hooks": {
161
+ "Stop": [
162
+ {
163
+ "hooks": [
164
+ {
165
+ "type": "command",
166
+ "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/auto-quality-review.sh"
167
+ }
168
+ ]
169
+ }
170
+ ]
171
+ }
172
+ }
173
+ ```
174
+
175
+ **Critical:**
176
+
177
+ - Use `$CLAUDE_PROJECT_DIR/.claude/hooks/...` (project-local)
178
+ - All code must be inline via heredocs (no external file references)
179
+ - Script must work without any global folder existing
180
+
181
+ ---
182
+
183
+ ### Task 2: Ensure setup-linting.sh Creates Slash Command
184
+
185
+ **Status:** Not started
186
+ **Modify:** `framework/scripts/setup-linting.sh`
187
+
188
+ **Problem:** setup-linting.sh doesn't create `.claude/commands/lint.md` (currently manual)
189
+
190
+ **Changes:**
191
+
192
+ 1. Add command directory creation
193
+ 2. Generate `lint.md` from inline heredoc
194
+
195
+ **Code to add:**
196
+
197
+ ````bash
198
+ # Add after hooks creation
199
+ mkdir -p .claude/commands
200
+
201
+ cat > .claude/commands/lint.md << 'EOF'
202
+ Run linting on all project files.
203
+
204
+ Execute:
205
+ ```bash
206
+ bash .claude/hooks/run-linters.sh .
207
+ ````
208
+
209
+ EOF
210
+
211
+ ````
212
+
213
+ ---
214
+
215
+ ### Task 3: Add Version Comments to `setup-linting.sh`
216
+ **Status:** Not started
217
+ **Modify:** `framework/scripts/setup-linting.sh`
218
+
219
+ **Changes:**
220
+ 1. Add VERSION variable at top (hardcoded, updated manually before each release)
221
+ 2. Add version comment to all generated files
222
+
223
+ **Example:**
224
+ ```bash
225
+ # At top of setup-linting.sh
226
+ VERSION="v1.0.0" # UPDATE THIS MANUALLY BEFORE EACH RELEASE
227
+
228
+ # In heredoc for auto-lint.sh
229
+ cat > .claude/hooks/auto-lint.sh << EOF
230
+ #!/bin/bash
231
+ # Generated by https://github.com/YOU/agents $VERSION
232
+ # To upgrade: curl https://raw.githubusercontent.com/YOU/agents/v1.1.0/coding/setup-linting.sh | bash -s -- --biome
233
+
234
+ [rest of file]
235
+ EOF
236
+ ````
237
+
238
+ **Important:** VERSION must be manually updated before tagging. Add to release checklist.
239
+
240
+ **Apply to these files:**
241
+
242
+ - `.claude/hooks/auto-lint.sh`
243
+ - `.claude/hooks/run-linters.sh`
244
+ - `.claude/commands/lint.md`
245
+ - `eslint.config.mjs` / `biome.jsonc`
246
+
247
+ ---
248
+
249
+ ### Task 4: Handle `settings.json` Merging
250
+
251
+ **Status:** Not started
252
+ **Problem:** Both `setup-linting.sh` and `setup-quality.sh` write to `.claude/settings.json`
253
+
254
+ **Current behavior:** setup-linting.sh OVERWRITES entire file (breaks quality review if already installed)
255
+
256
+ **Solution: Order-independent merging using jq**
257
+
258
+ - UPDATE setup-linting.sh to use jq merging (not cat overwrite)
259
+ - Implement same pattern in setup-quality.sh
260
+
261
+ ```bash
262
+ # Both scripts use this pattern:
263
+
264
+ # 1. Create base structure if file doesn't exist
265
+ if [ ! -f .claude/settings.json ]; then
266
+ echo '{"hooks": {}}' > .claude/settings.json
267
+ fi
268
+
269
+ # 2. Merge using jq (order-independent)
270
+ # setup-linting.sh adds PostToolUse:
271
+ jq '.hooks.PostToolUse = [{"matcher": "Write|Edit|MultiEdit|NotebookEdit", "hooks": [{"type": "command", "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/auto-lint.sh", "timeout": 15}]}]' \
272
+ .claude/settings.json > .claude/settings.json.tmp
273
+ mv .claude/settings.json.tmp .claude/settings.json
274
+
275
+ # setup-quality.sh adds Stop:
276
+ jq '.hooks.Stop = [{"hooks": [{"type": "command", "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/auto-quality-review.sh"}]}]' \
277
+ .claude/settings.json > .claude/settings.json.tmp
278
+ mv .claude/settings.json.tmp .claude/settings.json
279
+ ```
280
+
281
+ **Critical: Make jq REQUIRED**
282
+
283
+ ```bash
284
+ # Check for jq (both scripts)
285
+ if ! command -v jq &> /dev/null; then
286
+ echo "ERROR: jq is required for settings.json merging."
287
+ echo "Install it:"
288
+ echo " • macOS: brew install jq"
289
+ echo " • Ubuntu/Debian: sudo apt-get install jq"
290
+ echo " • Other: https://jqlang.github.io/jq/download/"
291
+ exit 1 # FAIL if missing (not a warning)
292
+ fi
293
+ ```
294
+
295
+ **Benefit:** Scripts can run in ANY order, settings.json always merges correctly
296
+
297
+ ---
298
+
299
+ ### Task 5: Git Tagging and Release Process
300
+
301
+ **Status:** Not started
302
+
303
+ **Process:**
304
+
305
+ 1. Make changes in this repo
306
+ 2. Test in a project
307
+ 3. Commit changes
308
+ 4. Tag release with semver
309
+ 5. Push tags
310
+
311
+ **Commands:**
312
+
313
+ ```bash
314
+ cd /Users/alex/projects/safeword
315
+
316
+ # Make changes
317
+ git add .
318
+ git commit -m "Add biome support to setup-linting.sh"
319
+
320
+ # Tag release
321
+ git tag v1.0.0 -m "Initial release"
322
+ git tag v1.1.0 -m "Add biome support"
323
+ git tag v1.1.1 -m "Fix quality review bug"
324
+
325
+ # Push
326
+ git push origin main --tags
327
+ ```
328
+
329
+ **Versioning scheme:**
330
+
331
+ - `v1.0.0` - Initial release
332
+ - `v1.1.0` - New features (backward compatible)
333
+ - `v1.1.1` - Bug fixes
334
+ - `v2.0.0` - Breaking changes
335
+
336
+ **Release Checklist:**
337
+
338
+ ```bash
339
+ # 1. Update VERSION in both scripts
340
+ vim framework/scripts/setup-linting.sh # Change VERSION="v1.1.0"
341
+ vim framework/scripts/setup-quality.sh # Change VERSION="v1.1.0"
342
+
343
+ # 2. Test scripts
344
+ cd /tmp/test-project
345
+ bash ./framework/scripts/setup-linting.sh --biome
346
+ bash ./framework/scripts/setup-quality.sh
347
+ # Verify generated files have correct version
348
+
349
+ # 3. Commit, tag, push
350
+ git commit -am "Release v1.1.0"
351
+ git tag v1.1.0 -m "Add biome support"
352
+ git push origin main --tags
353
+ ```
354
+
355
+ ---
356
+
357
+ ### Task 6: Update Existing Projects
358
+
359
+ **Status:** Not started
360
+ **Projects to update:**
361
+
362
+ - `~/projects/soulless-monorepo`
363
+ - `~/projects/chat`
364
+
365
+ **Current state:**
366
+ Both have:
367
+
368
+ - ✅ `.claude/hooks/auto-lint.sh` (project-local, good)
369
+ - ✅ `.claude/hooks/run-linters.sh` (project-local, good)
370
+ - ❌ `.claude/settings.json` referencing `/Users/alex/.agents/hooks/auto-quality-review.sh` (global, bad)
371
+
372
+ **Migration steps:**
373
+
374
+ 1. Run `setup-quality.sh` in each project
375
+ 2. Verify `.claude/hooks/auto-quality-review.sh` is copied locally
376
+ 3. Verify `.claude/settings.json` uses `$CLAUDE_PROJECT_DIR/.claude/hooks/...`
377
+ 4. Delete any old global references
378
+
379
+ ---
380
+
381
+ ### Task 7: Delete hooks/ Directory (After Migration)
382
+
383
+ **Status:** Not started
384
+ **Decision:** Rely only on project-local generated hooks (no global hooks directory)
385
+
386
+ **Reasoning:**
387
+
388
+ - ✅ Single source of truth (setup scripts with inline heredocs)
389
+ - ✅ No drift between hooks/\*.sh and heredocs
390
+ - ✅ Cleaner architecture
391
+ - ❌ Slightly less convenient to edit (but syntax highlighting still works in heredocs)
392
+
393
+ **Steps:**
394
+
395
+ 1. Create setup-quality.sh with inline heredocs (Task 1)
396
+ 2. Migrate existing projects to local hooks (Task 6)
397
+ 3. Verify no projects reference a global hooks directory
398
+
399
+ **Alternative:** Keep as deprecated examples
400
+
401
+ - Mark with README: "DEPRECATED - Use setup scripts instead"
402
+ - Risk: Confuses new users, two sources of truth
403
+
404
+ **Recommendation:** Delete. Setup scripts are sufficient.
405
+
406
+ ---
407
+
408
+ ### Task 8: Add SessionStart Version Check Hook
409
+
410
+ **Status:** Not started
411
+ **Modify:** Both `setup-linting.sh` and `setup-quality.sh`
412
+
413
+ **What it does:**
414
+
415
+ - Checks for newer version of agents (once per 24 hours)
416
+ - Shows upgrade command if update available
417
+ - Fails silently if offline/network issues
418
+ - Can be disabled by creating `.agents-no-check` file
419
+
420
+ **Implementation:**
421
+
422
+ 1. **Both setup scripts generate `.claude/hooks/session-start.sh`:**
423
+
424
+ ```bash
425
+ cat > .claude/hooks/session-start.sh << 'EOF'
426
+ #!/bin/bash
427
+ # Generated by https://github.com/YOU/agents $VERSION
428
+ # Session start hook - checks for updates
429
+
430
+ # Skip if disabled
431
+ [ -f .agents-no-check ] && exit 0
432
+
433
+ # Extract installed version from generated file
434
+ INSTALLED_VERSION=$(grep -m1 "# Generated by.*agents v" .claude/hooks/auto-lint.sh 2>/dev/null | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' || echo "")
435
+
436
+ # Skip if can't determine version
437
+ [ -z "$INSTALLED_VERSION" ] && exit 0
438
+
439
+ # Use cache to avoid checking too frequently
440
+ CACHE_FILE=".claude/.version-cache"
441
+ CACHE_MAX_AGE=86400 # 24 hours
442
+
443
+ # Check if cache is fresh
444
+ if [ -f "$CACHE_FILE" ]; then
445
+ CACHE_AGE=$(($(date +%s) - $(stat -f %m "$CACHE_FILE" 2>/dev/null || stat -c %Y "$CACHE_FILE" 2>/dev/null || echo 0)))
446
+ if [ $CACHE_AGE -lt $CACHE_MAX_AGE ]; then
447
+ LATEST=$(cat "$CACHE_FILE" 2>/dev/null)
448
+ fi
449
+ fi
450
+
451
+ # If no cached value, check GitHub (with timeout)
452
+ if [ -z "$LATEST" ]; then
453
+ LATEST=$(timeout 2 curl -sf https://api.github.com/repos/USER/agents/releases/latest 2>/dev/null | jq -r '.tag_name' 2>/dev/null || echo "")
454
+
455
+ # Cache the result (even if empty)
456
+ echo "$LATEST" > "$CACHE_FILE" 2>/dev/null
457
+ fi
458
+
459
+ # Compare versions and notify
460
+ if [ -n "$LATEST" ] && [ "$LATEST" != "$INSTALLED_VERSION" ]; then
461
+ echo "📦 Agents update available: $INSTALLED_VERSION → $LATEST"
462
+ echo " Upgrade linting: curl https://raw.githubusercontent.com/YOU/safeword/$LATEST/framework/scripts/setup-linting.sh | bash -s -- --biome"
463
+ echo " Upgrade quality: curl https://raw.githubusercontent.com/YOU/safeword/$LATEST/framework/scripts/setup-quality.sh | bash"
464
+ echo ""
465
+ fi
466
+ EOF
467
+
468
+ chmod +x .claude/hooks/session-start.sh
469
+ ```
470
+
471
+ 2. **Both setup scripts add SessionStart to settings.json:**
472
+ ```bash
473
+ # Use jq to add SessionStart hook
474
+ jq '.hooks.SessionStart = [{"hooks": [{"type": "command", "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/session-start.sh"}]}]' \
475
+ .claude/settings.json > .claude/settings.json.tmp
476
+ mv .claude/settings.json.tmp .claude/settings.json
477
+ ```
478
+
479
+ **Features:**
480
+
481
+ - ✅ Cached (24hr) - won't spam API
482
+ - ✅ Fast (2s timeout) - won't hang
483
+ - ✅ Fails silently - works offline
484
+ - ✅ Helpful - shows exact upgrade commands
485
+ - ✅ Opt-out - create `.agents-no-check` to disable
486
+
487
+ **Edge cases handled:**
488
+
489
+ - Offline → skips silently
490
+ - GitHub down → uses cached value
491
+ - Rate limited → uses cached value
492
+ - Can't parse version → skips silently
493
+
494
+ ---
495
+
496
+ ### Task 9: Documentation
497
+
498
+ **Status:** Not started
499
+
500
+ **Create/Update:**
501
+
502
+ 1. **README.md** (project-local)
503
+
504
+ ````markdown
505
+ # Claude Code Agents
506
+
507
+ Automated linting and quality review for Claude Code projects.
508
+
509
+ ## Quick Start
510
+
511
+ ### Linting Setup
512
+
513
+ ```bash
514
+ curl https://raw.githubusercontent.com/YOU/safeword/v1.0.0/framework/scripts/setup-linting.sh | bash -s -- --biome
515
+ ```
516
+ ````
517
+
518
+ ### Quality Review Setup
519
+
520
+ ```bash
521
+ curl https://raw.githubusercontent.com/YOU/safeword/v1.0.0/framework/scripts/setup-quality.sh | bash
522
+ ```
523
+
524
+ ## Versioning
525
+
526
+ Use git tags to pin versions:
527
+ - Latest: Replace `v1.0.0` with `main` in URLs (rolling release)
528
+ - Stable: Use specific tag like `v1.0.0`
529
+
530
+ ## Upgrading
531
+
532
+ Re-run setup scripts with new version:
533
+
534
+ ```bash
535
+ curl https://raw.githubusercontent.com/YOU/safeword/v1.1.0/framework/scripts/setup-linting.sh | bash -s -- --biome
536
+ ```
537
+
538
+ ```
539
+
540
+ ```
541
+
542
+ 2. **Update consolidated setup guide (framework/README.md)**
543
+ - Add "Installation" section with curl commands
544
+ - Add "Versioning" section explaining git tags
545
+ - Add "Upgrading" section
546
+ - Add "Auto-update check" section (explain SessionStart hook, how to disable)
547
+ - Add "Requirements" section (bash, jq, npm, git, curl, timeout)
548
+ - Add security note: inspect scripts before piping to bash
549
+ - Add note about version controlling .claude directory
550
+
551
+ ---
552
+
553
+ ## Success Criteria
554
+
555
+ **Distribution:**
556
+
557
+ - [ ] External user can run single curl command to set up linting (no global folder needed)
558
+ - [ ] External user can run single curl command to set up quality review (no global folder needed)
559
+ - [ ] Setup scripts are 100% self-contained (all code inline via heredocs)
560
+ - [ ] Scripts work on machine with zero global .agents folder
561
+ - [ ] Can specify version via URL: `v1.0.0`, `v1.1.0`, `main`
562
+
563
+ **Generated Files:**
564
+
565
+ - [ ] All hooks are project-local (no global references)
566
+ - [ ] Generated files have version comments with upgrade instructions
567
+ - [ ] setup-linting.sh creates `.claude/commands/lint.md` automatically
568
+ - [ ] setup-quality.sh creates `.claude/commands/quality-review.md` automatically
569
+ - [ ] Both setup scripts create `.claude/hooks/session-start.sh` with version check
570
+ - [ ] SessionStart hook added to settings.json
571
+
572
+ **Robustness:**
573
+
574
+ - [ ] Scripts work in ANY order (settings.json merging via jq)
575
+ - [ ] Scripts fail gracefully with clear error if jq is missing
576
+ - [ ] jq is REQUIRED dependency (not optional)
577
+ - [ ] Version check fails silently if offline/network issues
578
+ - [ ] Version check cached (24hr) to avoid API spam
579
+ - [ ] Version check can be disabled (create `.agents-no-check`)
580
+
581
+ **Migration:**
582
+
583
+ - [ ] Projects migrated to project-local hooks
584
+ - [ ] No projects reference global paths
585
+
586
+ **Documentation:**
587
+
588
+ - [ ] README explains installation and upgrading
589
+ - [ ] Release checklist documents VERSION update process
590
+ - [ ] Documentation explains jq requirement
591
+
592
+ ---
593
+
594
+ ## Non-Goals (Avoiding Bloat)
595
+
596
+ - ❌ CLI wrapper (`agents` command)
597
+ - ❌ Lock files (`.agents.lock`)
598
+ - ❌ Global installation (`~/.agents` for external users)
599
+ - ❌ Global shared folder for hooks
600
+ - ❌ Package manager (npm, homebrew)
601
+ - ❌ PATH modifications
602
+ - ❌ Automatic updates
603
+ - ❌ Migration scripts
604
+ - ❌ Dependency management beyond jq/bash/git
605
+ - ❌ External file references (everything inline via heredocs)
606
+
607
+ ---
608
+
609
+ ## Rollout Plan
610
+
611
+ ### Phase 1: Development (Week 1)
612
+
613
+ 1. Create `setup-quality.sh`
614
+ 2. Add version comments to `setup-linting.sh`
615
+ 3. Test both scripts in clean directory
616
+ 4. Tag `v1.0.0`
617
+
618
+ ### Phase 2: Migration (Week 1)
619
+
620
+ 1. Run both setup scripts in `soulless-monorepo`
621
+ 2. Run both setup scripts in `chat`
622
+ 3. Verify no references to any global absolute paths
623
+ 4. Delete global hooks if no longer needed
624
+
625
+ ### Phase 3: Documentation (Week 1)
626
+
627
+ 1. Create `README.md` in `coding/`
628
+ 2. Update `framework/README.md`
629
+ 3. Create release notes for v1.0.0
630
+
631
+ ### Phase 4: Distribution (Week 2)
632
+
633
+ 1. Push to GitHub with tags
634
+ 2. Test installation from clean machine
635
+ 3. Share with external users
636
+
637
+ ---
638
+
639
+ ## Open Questions
640
+
641
+ 1. **Settings.json merging:** ~~Use jq or document script order?~~
642
+ - **RESOLVED:** Use jq for order-independent merging, make jq REQUIRED
643
+
644
+ 2. **Global hooks directory:** ~~Keep global hooks or delete?~~
645
+ - **RESOLVED:** Delete after migration (Task 7) - DONE
646
+ - Setup scripts (with inline heredocs) are the ONLY source of truth
647
+ - Simpler, no drift, cleaner architecture
648
+
649
+ 3. **Chat repo uses Biome via ultracite:** Should setup-quality.sh work with both?
650
+ - **Recommendation:** Yes, quality review is independent of linting
651
+
652
+ 4. **Version in script:** ~~Hardcoded or extract from git?~~
653
+ - **RESOLVED:** Hardcoded, update manually on release (see Task 5 checklist)
654
+ - Accept manual step, not a burden for 2 files
655
+
656
+ 5. **GitHub repo:** Public or private?
657
+ - **MUST BE PUBLIC** - SessionStart version check uses GitHub API (requires public repo)
658
+ - If private: version check won't work (API requires auth)
659
+ - Alternative: Host version file elsewhere for private repos
660
+
661
+ ---
662
+
663
+ ## Risks and Mitigations
664
+
665
+ ### Risk: Breaking changes in hooks
666
+
667
+ **Impact:** External users' projects break on upgrade
668
+ **Mitigation:**
669
+
670
+ - Follow semver strictly
671
+ - Test upgrades before tagging
672
+ - Document breaking changes in release notes
673
+
674
+ ### Risk: Settings.json conflicts
675
+
676
+ **Impact:** One setup overwrites another's hooks
677
+ **Mitigation:**
678
+
679
+ - Document script order
680
+ - Use jq to merge instead of overwrite
681
+ - Test both scripts together
682
+
683
+ ### Risk: Users run wrong version
684
+
685
+ **Impact:** Mismatched hook versions in same project
686
+ **Mitigation:**
687
+
688
+ - Version comment in every file
689
+ - Document "upgrade all at once"
690
+
691
+ ---
692
+
693
+ ## Timeline
694
+
695
+ **Target completion:** 1 week
696
+
697
+ - **Day 1:** Create `setup-quality.sh` (Task 1)
698
+ - **Day 2:** Fix setup-linting.sh (Tasks 2, 3, 4, 8)
699
+ - **Day 3:** Test both scripts together, verify settings.json merging, test version check
700
+ - **Day 4:** Migrate `soulless-monorepo` and `chat` (Task 6)
701
+ - **Day 5:** Delete hooks/ directory (Task 7), write documentation (Task 9)
702
+ - **Day 6:** Tag v1.0.0, push to GitHub (Task 5)
703
+ - **Day 7:** Test installation from clean machine, verify success criteria
704
+
705
+ ---
706
+
707
+ ## Implementation Order
708
+
709
+ **Critical path:**
710
+
711
+ 1. Task 1: Create setup-quality.sh (enables migration)
712
+ 2. Task 2: Fix setup-linting.sh command creation
713
+ 3. Task 3: Add version comments to setup-linting.sh
714
+ 4. Task 4: Implement settings.json merging (both scripts)
715
+ 5. Task 8: Add SessionStart version check (both scripts)
716
+ 6. Task 6: Migrate existing projects
717
+ 7. Task 7: Delete hooks/ directory
718
+ 8. Task 9: Documentation
719
+ 9. Task 5: Tag and release
720
+
721
+ **Dependencies:**
722
+
723
+ - Tasks 2, 3, 4, 8 can be done in parallel after Task 1
724
+ - Task 6 requires Tasks 1-4, 8 complete
725
+ - Task 7 requires Task 6 complete
726
+ - Task 9 can be done in parallel with Task 7
727
+ - Task 5 (release) requires all tasks complete
728
+
729
+ ---
730
+
731
+ ## Next Actions
732
+
733
+ 1. ✅ Review this plan
734
+ 2. Answer remaining open question (#5: GitHub public/private?)
735
+ 3. Approve approach
736
+ 4. Begin implementation (start with Task 1)
737
+
738
+ ---
739
+
740
+ **End of Plan**