safeword 0.6.9 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/{check-OYYSYHFP.js → check-JWMAZLUO.js} +73 -57
  2. package/dist/check-JWMAZLUO.js.map +1 -0
  3. package/dist/{chunk-ZS3Z3Q37.js → chunk-CO3LARDH.js} +297 -65
  4. package/dist/chunk-CO3LARDH.js.map +1 -0
  5. package/dist/{chunk-LNSEDZIW.js → chunk-R4SBJKFJ.js} +159 -152
  6. package/dist/chunk-R4SBJKFJ.js.map +1 -0
  7. package/dist/{sync-BFMXZEHM.js → chunk-YNVT2S3D.js} +11 -40
  8. package/dist/chunk-YNVT2S3D.js.map +1 -0
  9. package/dist/cli.js +6 -6
  10. package/dist/{diff-325TIZ63.js → diff-2XITKG3T.js} +51 -53
  11. package/dist/diff-2XITKG3T.js.map +1 -0
  12. package/dist/index.d.ts +1 -0
  13. package/dist/{reset-ZGJIKMUW.js → reset-DOGYUFAG.js} +3 -3
  14. package/dist/{setup-GAMXTFM2.js → setup-UHSXXN6I.js} +17 -20
  15. package/dist/setup-UHSXXN6I.js.map +1 -0
  16. package/dist/sync-QPNODJBJ.js +9 -0
  17. package/dist/sync-QPNODJBJ.js.map +1 -0
  18. package/dist/{upgrade-X4GREJXN.js → upgrade-GTY3MG6A.js} +10 -7
  19. package/dist/upgrade-GTY3MG6A.js.map +1 -0
  20. package/package.json +1 -1
  21. package/templates/SAFEWORD.md +52 -15
  22. package/templates/commands/architecture.md +1 -1
  23. package/templates/commands/lint.md +1 -0
  24. package/templates/commands/quality-review.md +1 -1
  25. package/templates/cursor/rules/safeword-core.mdc +5 -0
  26. package/templates/doc-templates/architecture-template.md +1 -1
  27. package/templates/doc-templates/task-spec-template.md +151 -0
  28. package/templates/doc-templates/ticket-template.md +2 -4
  29. package/templates/guides/architecture-guide.md +2 -2
  30. package/templates/guides/code-philosophy.md +1 -1
  31. package/templates/guides/context-files-guide.md +3 -3
  32. package/templates/guides/design-doc-guide.md +2 -2
  33. package/templates/guides/development-workflow.md +2 -2
  34. package/templates/guides/learning-extraction.md +9 -9
  35. package/templates/guides/tdd-best-practices.md +39 -38
  36. package/templates/guides/test-definitions-guide.md +15 -14
  37. package/templates/hooks/cursor/after-file-edit.sh +66 -0
  38. package/templates/hooks/cursor/stop.sh +50 -0
  39. package/templates/hooks/post-tool-lint.sh +19 -5
  40. package/templates/hooks/prompt-questions.sh +1 -1
  41. package/templates/hooks/session-lint-check.sh +1 -1
  42. package/templates/hooks/session-verify-agents.sh +1 -1
  43. package/templates/hooks/session-version.sh +1 -1
  44. package/templates/hooks/stop-quality.sh +1 -1
  45. package/templates/markdownlint-cli2.jsonc +18 -19
  46. package/templates/scripts/bisect-test-pollution.sh +87 -0
  47. package/templates/scripts/bisect-zombie-processes.sh +129 -0
  48. package/templates/scripts/lint-md.sh +16 -0
  49. package/templates/skills/safeword-quality-reviewer/SKILL.md +3 -3
  50. package/templates/skills/safeword-systematic-debugger/SKILL.md +246 -0
  51. package/templates/skills/safeword-tdd-enforcer/SKILL.md +221 -0
  52. package/dist/check-OYYSYHFP.js.map +0 -1
  53. package/dist/chunk-LNSEDZIW.js.map +0 -1
  54. package/dist/chunk-ZS3Z3Q37.js.map +0 -1
  55. package/dist/diff-325TIZ63.js.map +0 -1
  56. package/dist/setup-GAMXTFM2.js.map +0 -1
  57. package/dist/sync-BFMXZEHM.js.map +0 -1
  58. package/dist/upgrade-X4GREJXN.js.map +0 -1
  59. /package/dist/{reset-ZGJIKMUW.js.map → reset-DOGYUFAG.js.map} +0 -0
@@ -69,6 +69,7 @@ Training data is stale. Follow this sequence:
69
69
  | Trigger | Template |
70
70
  | ---------------------------------------------------------- | -------------------------------------------------- |
71
71
  | User asks for user story OR planning new feature scope | @./.safeword/templates/user-stories-template.md |
72
+ | Bug, improvement, refactor, or internal task | @./.safeword/templates/task-spec-template.md |
72
73
  | Need test definitions for a feature OR acceptance criteria | @./.safeword/templates/test-definitions-feature.md |
73
74
  | Feature spans 3+ components OR needs technical spec | @./.safeword/templates/design-doc-template.md |
74
75
  | Making decision with long-term impact OR trade-offs | @./.safeword/templates/architecture-template.md |
@@ -80,12 +81,20 @@ Training data is stale. Follow this sequence:
80
81
 
81
82
  **Location:** `.safeword/planning/` at project root
82
83
 
83
- | Type | Path |
84
- | ---------------- | -------------------------------------- |
85
- | User stories | `.safeword/planning/user-stories/` |
86
- | Test definitions | `.safeword/planning/test-definitions/` |
87
- | Design docs | `.safeword/planning/design/` |
88
- | Issues | `.safeword/planning/issues/` |
84
+ | Type | Path | Contents |
85
+ | ---------------- | -------------------------------------- | --------------------------------- |
86
+ | Specs | `.safeword/planning/specs/` | `feature-*.md` and `task-*.md` |
87
+ | Test definitions | `.safeword/planning/test-definitions/` | `feature-*.md` (L2 features only) |
88
+ | Design docs | `.safeword/planning/design/` | Complex features (3+ components) |
89
+ | Issues | `.safeword/planning/issues/` | Issue tracking |
90
+
91
+ **Artifact Levels:**
92
+
93
+ | Level | Artifacts | Test Location |
94
+ | ------ | ---------------------------------------------------- | ------------------- |
95
+ | **L2** | Feature Spec + Test Definitions (+ Design Doc if 3+) | `test-definitions/` |
96
+ | **L1** | Task Spec | Inline in spec |
97
+ | **L0** | Task Spec (minimal) | Existing tests |
89
98
 
90
99
  **Archive:** Move completed docs to `archive/` subfolder within each.
91
100
 
@@ -136,22 +145,31 @@ status: in_progress
136
145
 
137
146
  ## Feature Development
138
147
 
139
- **Follow this order:**
148
+ **Triage first - answer IN ORDER, stop at first match:**
149
+
150
+ | Question | Level | Artifacts |
151
+ | ---------------------------------------- | -------------- | ---------------------------- |
152
+ | User-facing feature with business value? | **L2 Feature** | Spec + Test Defs (+ Design) |
153
+ | Bug, improvement, internal, or refactor? | **L1 Task** | Spec with inline tests |
154
+ | Typo, config, or trivial change? | **L0 Micro** | Minimal spec, existing tests |
155
+
156
+ **Then follow this order:**
140
157
 
141
158
  1. **Check/create ticket** if context-loss risk exists (see decision tree above)
142
- 2. **Read user stories** (`.safeword/planning/user-stories/`)
143
- 3. **Read test definitions** (`.safeword/planning/test-definitions/`)
144
- 4. **Read design doc** if complex (>3 components OR 2+ user stories)
159
+ 2. **Read/create spec** (`.safeword/planning/specs/`)
160
+ 3. **Read/create test definitions** (L2 only: `.safeword/planning/test-definitions/`)
161
+ 4. **Read/create design doc** if complex (3+ components)
145
162
  5. **TDD: RED → GREEN → REFACTOR**
146
163
  6. **Update ticket** with progress, ask user to confirm completion
147
164
 
148
165
  **Edge cases:**
149
166
 
150
- | Situation | Action |
151
- | ----------------------------------- | --------------------------------- |
152
- | User stories exist, test defs don't | Create test defs first |
153
- | Test defs exist, user stories don't | Ask if user stories needed |
154
- | Neither exist | Create both before implementation |
167
+ | Situation | Action |
168
+ | ------------------------- | ----------------------- |
169
+ | Spec exists, no test defs | Create test defs (L2) |
170
+ | Test defs exist, no spec | Create spec first |
171
+ | Neither exist | Create spec, then tests |
172
+ | L0/L1 task | Inline tests in spec |
155
173
 
156
174
  ---
157
175
 
@@ -207,6 +225,25 @@ Commit after: GREEN phase, before/after refactoring, when switching tasks.
207
225
 
208
226
  ---
209
227
 
228
+ ## Code Fence Languages (MD040)
229
+
230
+ When markdown lint reports MD040 (missing language), choose:
231
+
232
+ | Content Type | Language Hint |
233
+ | ------------------------ | ---------------------------- |
234
+ | TypeScript/JavaScript | `typescript` or `javascript` |
235
+ | Shell commands | `bash` |
236
+ | JSON, YAML, TOML configs | `json`, `yaml`, `toml` |
237
+ | SQL queries | `sql` |
238
+ | Directory trees | `plaintext` |
239
+ | Templates, pseudocode | `text` |
240
+ | Command output, logs | `text` |
241
+ | Truly ambiguous | `text` |
242
+
243
+ **Why this matters:** Language hints help LLMs understand code context. Use real languages for real code, `text` for everything else.
244
+
245
+ ---
246
+
210
247
  ## Learning Extraction
211
248
 
212
249
  **Suggest extraction when ANY apply:**
@@ -20,7 +20,7 @@ When the user invokes this command:
20
20
 
21
21
  ## Example Usage
22
22
 
23
- ```
23
+ ```text
24
24
  /architecture
25
25
  ```
26
26
 
@@ -27,6 +27,7 @@ npm run lint:md 2>&1 || true
27
27
  ## Summary
28
28
 
29
29
  After running, report:
30
+
30
31
  1. Any ESLint errors that couldn't be auto-fixed
31
32
  2. Any formatting issues
32
33
  3. Type errors (if TypeScript)
@@ -23,7 +23,7 @@ When the user invokes this command:
23
23
 
24
24
  ## Example Usage
25
25
 
26
- ```
26
+ ```text
27
27
  /quality-review
28
28
  ```
29
29
 
@@ -0,0 +1,5 @@
1
+ ---
2
+ alwaysApply: true
3
+ ---
4
+
5
+ @.safeword/SAFEWORD.md
@@ -76,7 +76,7 @@ Boundaries enforced via `eslint-plugin-boundaries`. See `.safeword/guides/archit
76
76
 
77
77
  ### Relationships
78
78
 
79
- ```
79
+ ```text
80
80
  [Entity A] 1──n [Entity B]
81
81
  [Entity B] n──n [Entity C]
82
82
  ```
@@ -0,0 +1,151 @@
1
+ # Task: [Name]
2
+
3
+ **Guide**: `@./.safeword/guides/development-workflow.md`
4
+ **Template**: `@./.safeword/templates/task-spec-template.md`
5
+
6
+ ---
7
+
8
+ ## Standard Task (L1)
9
+
10
+ Use for: bugs, improvements, internal work, refactors.
11
+
12
+ ```markdown
13
+ # Task: [Name]
14
+
15
+ **Type:** Bug | Improvement | Internal | Refactor
16
+
17
+ **Scope:** [1-2 sentences describing what this task accomplishes]
18
+
19
+ **Out of Scope:** [Explicit boundaries - what this task does NOT include]
20
+
21
+ **Done When:**
22
+
23
+ - [ ] [Observable outcome 1]
24
+ - [ ] [Observable outcome 2]
25
+
26
+ **Tests:**
27
+
28
+ - [ ] [Test scenario 1 - what behavior to verify]
29
+ - [ ] [Test scenario 2 - edge case or secondary behavior]
30
+ ```
31
+
32
+ **Location:** `.safeword/planning/specs/task-[name].md`
33
+
34
+ ---
35
+
36
+ ## Micro Task (L0)
37
+
38
+ Use for: typos, config changes, trivial fixes. Still scoped to prevent creep.
39
+
40
+ ```markdown
41
+ # Task: [Name]
42
+
43
+ **Type:** Micro
44
+
45
+ **Scope:** [One sentence - exactly what is changing]
46
+
47
+ **Out of Scope:** [Boundaries - prevents "while I'm here" expansion]
48
+
49
+ **Done When:**
50
+
51
+ - [ ] [Single observable outcome]
52
+
53
+ **Tests:**
54
+
55
+ - [ ] Existing tests pass (no new test needed)
56
+ ```
57
+
58
+ **Location:** `.safeword/planning/specs/task-[name].md`
59
+
60
+ ---
61
+
62
+ ## Examples
63
+
64
+ ### L1: Bug Fix
65
+
66
+ ```markdown
67
+ # Task: Fix login timeout after 30 minutes
68
+
69
+ **Type:** Bug
70
+
71
+ **Scope:** Session refresh logic in auth middleware. User stays logged in if active.
72
+
73
+ **Out of Scope:** Session duration settings, auth flow changes, UI modifications.
74
+
75
+ **Done When:**
76
+
77
+ - [ ] User stays logged in if active within session window
78
+ - [ ] Session refreshes on API calls
79
+
80
+ **Tests:**
81
+
82
+ - [ ] Unit: session refresh extends expiry timestamp
83
+ - [ ] Unit: inactive session expires correctly after timeout
84
+ ```
85
+
86
+ ### L1: Improvement
87
+
88
+ ```markdown
89
+ # Task: Add retry logic to API client
90
+
91
+ **Type:** Improvement
92
+
93
+ **Scope:** Add exponential backoff retry for failed API requests in http client.
94
+
95
+ **Out of Scope:** Circuit breaker, rate limiting, request queuing, UI loading states.
96
+
97
+ **Done When:**
98
+
99
+ - [ ] Failed requests retry up to 3 times with exponential backoff
100
+ - [ ] Permanent failures (4xx) do not retry
101
+
102
+ **Tests:**
103
+
104
+ - [ ] Unit: retries on 5xx errors with backoff
105
+ - [ ] Unit: does not retry on 4xx errors
106
+ - [ ] Unit: gives up after max retries
107
+ ```
108
+
109
+ ### L0: Micro
110
+
111
+ ```markdown
112
+ # Task: Fix typo in auth error message
113
+
114
+ **Type:** Micro
115
+
116
+ **Scope:** Typo in login error ("authetication" → "authentication").
117
+
118
+ **Out of Scope:** Error handling logic, other error messages, refactoring.
119
+
120
+ **Done When:**
121
+
122
+ - [ ] Typo fixed in error message string
123
+
124
+ **Tests:**
125
+
126
+ - [ ] Existing auth tests pass
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Why L0 Needs Scope
132
+
133
+ Even trivial tasks need boundaries. Without explicit "Out of Scope":
134
+
135
+ - "Fix typo" becomes "improve all error messages"
136
+ - "Update config" becomes "refactor config system"
137
+ - "Rename variable" becomes "rename all related functions"
138
+
139
+ The spec takes 30 seconds to write and prevents hours of scope creep.
140
+
141
+ ---
142
+
143
+ ## Relationship to Feature Specs
144
+
145
+ | Type | Use When | Artifacts |
146
+ | --------------------- | --------------------------------------- | ------------------------------------ |
147
+ | **Feature Spec (L2)** | User-facing feature with business value | Feature spec + test definitions file |
148
+ | **Task Spec (L1)** | Bug, improvement, internal, refactor | Task spec with inline tests |
149
+ | **Task Spec (L0)** | Typo, config, trivial | Minimal task spec, existing tests |
150
+
151
+ For L2 features, use: `@./.safeword/templates/user-stories-template.md`
@@ -30,7 +30,7 @@ last_modified: YYYY-MM-DDTHH:MM:SSZ
30
30
 
31
31
  **Examples:**
32
32
 
33
- ```
33
+ ```text
34
34
  - 2025-11-24T18:50:00Z Started: Changing button background to red
35
35
  - 2025-11-24T18:51:30Z Tried: Added `background: red` to Button.css
36
36
  - 2025-11-24T18:52:00Z Found: Button now has white text on red (unreadable)
@@ -62,9 +62,7 @@ last_modified: YYYY-MM-DDTHH:MM:SSZ
62
62
 
63
63
  **In scope:**
64
64
 
65
- -
66
-
67
- **Out of scope:**
65
+ - **Out of scope:**
68
66
 
69
67
  -
70
68
 
@@ -99,7 +99,7 @@ Answer **IN ORDER**. Stop at the first "Yes":
99
99
 
100
100
  **✅ GOOD:**
101
101
 
102
- ```
102
+ ```plaintext
103
103
  project/
104
104
  ├── ARCHITECTURE.md
105
105
  └── docs/design/
@@ -273,7 +273,7 @@ Answer **IN ORDER**:
273
273
 
274
274
  ## File Organization
275
275
 
276
- ```
276
+ ```plaintext
277
277
  project/
278
278
  ├── ARCHITECTURE.md # Single comprehensive doc
279
279
  ├── .safeword/planning/
@@ -192,7 +192,7 @@ Before completing any work, verify:
192
192
  - Use descriptive commit messages
193
193
  - Make atomic commits (one logical change per commit)
194
194
 
195
- ```
195
+ ```text
196
196
  # ❌ Bad: "misc fixes"
197
197
  # ✅ Good: "fix: login button not responding to clicks"
198
198
  ```
@@ -61,7 +61,7 @@ Read it BEFORE working on any task in this project.
61
61
 
62
62
  **Example:**
63
63
 
64
- ```
64
+ ```text
65
65
  Working in: /project/src/feature/
66
66
  Loaded context:
67
67
  ✓ /project/CLAUDE.md (Claude-specific guidance)
@@ -96,7 +96,7 @@ See root AGENTS.md for TDD workflow. This file covers test-specific patterns.
96
96
 
97
97
  ## File Structure Pattern
98
98
 
99
- ```
99
+ ```plaintext
100
100
  project/
101
101
  ├─ SAFEWORD.md # Project context (references guides)
102
102
  ├─ CLAUDE.md # Claude-specific context
@@ -106,7 +106,7 @@ project/
106
106
 
107
107
  **Modular Approach (Recommended):**
108
108
 
109
- ```
109
+ ```plaintext
110
110
  project/
111
111
  ├─ AGENTS.md / CLAUDE.md # 50 lines: imports + structure
112
112
  ├─ docs/architecture.md # 100 lines: architecture decisions
@@ -137,14 +137,14 @@
137
137
 
138
138
  **Creating design doc:**
139
139
 
140
- ```
140
+ ```text
141
141
  User: "Create design doc for three-pane layout"
142
142
  You: [Read user stories and test definitions, then create design doc]
143
143
  ```
144
144
 
145
145
  **Updating design doc:**
146
146
 
147
- ```
147
+ ```text
148
148
  User: "Update design doc to add error handling section"
149
149
  You: [Read existing design doc, add Implementation Notes section with error handling]
150
150
  ```
@@ -46,7 +46,7 @@ Tests are the specification. When a test fails, the implementation is wrong—no
46
46
 
47
47
  ### Test Speed Hierarchy (Fast → Slow)
48
48
 
49
- ```
49
+ ```text
50
50
  Unit (milliseconds) ← Pure functions, no I/O
51
51
 
52
52
  Integration (seconds) ← Multiple modules, database, API calls
@@ -186,7 +186,7 @@ function calculateTotal(amount: number, taxRate: number): number {
186
186
 
187
187
  Answer these questions in order to choose the test type. Questions are mutually exclusive - stop at the first match. If multiple seem to apply, use the tie-breaking rule (line 19): choose the faster one.
188
188
 
189
- ```
189
+ ```text
190
190
  1. Does this test AI-generated content quality (tone, reasoning, creativity)?
191
191
  └─ YES → LLM Evaluation
192
192
  Examples: Narrative quality, prompt effectiveness, conversational naturalness
@@ -103,7 +103,7 @@ ls ./.safeword/learnings/*keyword*.md
103
103
 
104
104
  **Found existing learning** → Read and apply it:
105
105
 
106
- ```
106
+ ```text
107
107
  "I found an existing learning about [concept] at [path]. Let me read it and apply to your case..."
108
108
  [Read the file]
109
109
  "Based on the learning, here's how to handle this: [specific guidance from learning]"
@@ -113,7 +113,7 @@ ls ./.safeword/learnings/*keyword*.md
113
113
 
114
114
  **Similar but different** → Reference and note difference:
115
115
 
116
- ```
116
+ ```text
117
117
  "This is similar to the [existing learning] at [path], but differs in [specific way].
118
118
  The existing learning covers [X], but your case involves [Y]."
119
119
  ```
@@ -122,7 +122,7 @@ The existing learning covers [X], but your case involves [Y]."
122
122
 
123
123
  **Scenario 1: Found relevant learning**
124
124
 
125
- ```
125
+ ```text
126
126
  User: "I'm getting an async state update error with React hooks"
127
127
  → Check: ls .safeword/learnings/*react*.md *hooks*.md *async*.md
128
128
  → Found: react-hooks-async.md
@@ -133,7 +133,7 @@ User: "I'm getting an async state update error with React hooks"
133
133
 
134
134
  **Scenario 2: No existing learning**
135
135
 
136
- ```
136
+ ```text
137
137
  User: "IndexedDB quota is behaving strangely in Safari"
138
138
  → Check: ls .safeword/learnings/*indexeddb*.md *safari*.md *quota*.md
139
139
  → Not found
@@ -142,7 +142,7 @@ User: "IndexedDB quota is behaving strangely in Safari"
142
142
 
143
143
  **Scenario 3: Update existing learning**
144
144
 
145
- ```
145
+ ```text
146
146
  User: Debugging for 6 cycles, discovers new IndexedDB quirk
147
147
  → Suggest extraction
148
148
  → Check: ls .safeword/learnings/*indexeddb*.md
@@ -162,7 +162,7 @@ User: Debugging for 6 cycles, discovers new IndexedDB quirk
162
162
 
163
163
  ## Decision Tree
164
164
 
165
- ```
165
+ ```text
166
166
  Just learned something valuable
167
167
 
168
168
  ├─ Forward-looking? (useful on FUTURE work, not just this bug)
@@ -260,7 +260,7 @@ Actual: [What happened]
260
260
 
261
261
  [One-sentence takeaway]
262
262
 
263
- ````
263
+ ````text
264
264
 
265
265
  ---
266
266
 
@@ -481,7 +481,7 @@ Project-specific gotchas in `.safeword/learnings/`:
481
481
 
482
482
  ## Directory Structure
483
483
 
484
- ```
484
+ ```plaintext
485
485
  # Global learnings (all projects)
486
486
  .safeword/learnings/
487
487
  ├── react-state-async.md
@@ -506,7 +506,7 @@ Project-specific gotchas in `.safeword/learnings/`:
506
506
 
507
507
  **When to Split**:
508
508
 
509
- ```
509
+ ```text
510
510
  # TOO BIG (250 lines covering 3 separate concepts)
511
511
  .safeword/learnings/electron-gotchas.md
512
512