@massu/core 0.1.2 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/_shared-preamble.md +76 -0
- package/commands/massu-audit-deps.md +211 -0
- package/commands/massu-changelog.md +174 -0
- package/commands/massu-cleanup.md +315 -0
- package/commands/massu-commit.md +481 -0
- package/commands/massu-create-plan.md +752 -0
- package/commands/massu-dead-code.md +131 -0
- package/commands/massu-debug.md +484 -0
- package/commands/massu-deploy.md +91 -0
- package/commands/massu-deps.md +374 -0
- package/commands/massu-doc-gen.md +279 -0
- package/commands/massu-docs.md +364 -0
- package/commands/massu-estimate.md +313 -0
- package/commands/massu-golden-path.md +973 -0
- package/commands/massu-guide.md +167 -0
- package/commands/massu-hotfix.md +480 -0
- package/commands/massu-loop-playwright.md +837 -0
- package/commands/massu-loop.md +775 -0
- package/commands/massu-new-feature.md +511 -0
- package/commands/massu-parity.md +214 -0
- package/commands/massu-plan.md +456 -0
- package/commands/massu-push-light.md +207 -0
- package/commands/massu-push.md +434 -0
- package/commands/massu-refactor.md +410 -0
- package/commands/massu-release.md +363 -0
- package/commands/massu-review.md +238 -0
- package/commands/massu-simplify.md +281 -0
- package/commands/massu-status.md +278 -0
- package/commands/massu-tdd.md +201 -0
- package/commands/massu-test.md +516 -0
- package/commands/massu-verify-playwright.md +281 -0
- package/commands/massu-verify.md +667 -0
- package/dist/cli.js +12521 -0
- package/dist/hooks/cost-tracker.js +80 -5
- package/dist/hooks/post-edit-context.js +72 -6
- package/dist/hooks/post-tool-use.js +234 -57
- package/dist/hooks/pre-compact.js +144 -5
- package/dist/hooks/pre-delete-check.js +141 -11
- package/dist/hooks/quality-event.js +80 -5
- package/dist/hooks/security-gate.js +29 -0
- package/dist/hooks/session-end.js +83 -8
- package/dist/hooks/session-start.js +153 -7
- package/dist/hooks/user-prompt.js +166 -5
- package/package.json +6 -5
- package/src/backfill-sessions.ts +5 -4
- package/src/cli.ts +6 -1
- package/src/commands/doctor.ts +193 -6
- package/src/commands/init.ts +235 -6
- package/src/commands/install-commands.ts +137 -0
- package/src/config.ts +68 -2
- package/src/db.ts +115 -2
- package/src/docs-tools.ts +8 -6
- package/src/hooks/post-edit-context.ts +1 -1
- package/src/hooks/post-tool-use.ts +130 -0
- package/src/hooks/pre-compact.ts +23 -1
- package/src/hooks/pre-delete-check.ts +92 -4
- package/src/hooks/security-gate.ts +32 -0
- package/src/hooks/session-start.ts +97 -4
- package/src/hooks/user-prompt.ts +46 -1
- package/src/import-resolver.ts +2 -1
- package/src/knowledge-db.ts +169 -0
- package/src/knowledge-indexer.ts +704 -0
- package/src/knowledge-tools.ts +1413 -0
- package/src/license.ts +482 -0
- package/src/memory-db.ts +14 -1
- package/src/observation-extractor.ts +11 -4
- package/src/page-deps.ts +3 -2
- package/src/python/coupling-detector.ts +124 -0
- package/src/python/domain-enforcer.ts +83 -0
- package/src/python/impact-analyzer.ts +95 -0
- package/src/python/import-parser.ts +244 -0
- package/src/python/import-resolver.ts +135 -0
- package/src/python/migration-indexer.ts +115 -0
- package/src/python/migration-parser.ts +332 -0
- package/src/python/model-indexer.ts +70 -0
- package/src/python/model-parser.ts +279 -0
- package/src/python/route-indexer.ts +58 -0
- package/src/python/route-parser.ts +317 -0
- package/src/python-tools.ts +629 -0
- package/src/sentinel-db.ts +2 -1
- package/src/server.ts +29 -6
- package/src/session-archiver.ts +4 -5
- package/src/tools.ts +283 -31
- package/README.md +0 -40
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: massu-guide
|
|
3
|
+
description: Interactive onboarding walkthrough for the Massu codebase and .claude/ infrastructure
|
|
4
|
+
allowed-tools: Bash(*), Read(*), Grep(*), Glob(*)
|
|
5
|
+
---
|
|
6
|
+
name: massu-guide
|
|
7
|
+
|
|
8
|
+
# Massu Guide: Codebase Onboarding Walkthrough
|
|
9
|
+
|
|
10
|
+
## Objective
|
|
11
|
+
|
|
12
|
+
Provide a guided orientation for new developers (or fresh AI sessions) to understand Massu -- its architecture, .claude/ infrastructure, workflows, and common gotchas. Read-only exploration, no modifications.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## WALKTHROUGH (5 Sections)
|
|
17
|
+
|
|
18
|
+
### Section 1: Project Overview
|
|
19
|
+
|
|
20
|
+
Read and present:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Tech stack from package.json
|
|
24
|
+
cat packages/core/package.json | jq '{name, version, scripts: (.scripts | keys | length), dependencies: (.dependencies | keys | length), devDependencies: (.devDependencies | keys | length)}'
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Read `.claude/CLAUDE.md` first 30 lines -- Project Overview and Architecture.
|
|
28
|
+
|
|
29
|
+
Count key entities:
|
|
30
|
+
```bash
|
|
31
|
+
ls packages/core/src/*.ts 2>/dev/null | wc -l # Source modules
|
|
32
|
+
ls packages/core/src/__tests__/*.test.ts 2>/dev/null | wc -l # Tests
|
|
33
|
+
ls packages/core/src/hooks/*.ts 2>/dev/null | wc -l # Hooks
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Output: "Massu: TypeScript MCP Server + Claude Code Plugin with N source modules, N tests, N hooks."
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### Section 2: Architecture Map
|
|
41
|
+
|
|
42
|
+
Count manually:
|
|
43
|
+
```bash
|
|
44
|
+
echo "=== ARCHITECTURE MAP ==="
|
|
45
|
+
echo "Source modules: $(ls packages/core/src/*.ts 2>/dev/null | wc -l)"
|
|
46
|
+
echo "Test files: $(ls packages/core/src/__tests__/*.test.ts 2>/dev/null | wc -l)"
|
|
47
|
+
echo "Hook files: $(ls packages/core/src/hooks/*.ts 2>/dev/null | wc -l)"
|
|
48
|
+
echo "Scripts: $(ls scripts/*.sh 2>/dev/null | wc -l)"
|
|
49
|
+
echo "Commands: $(ls .claude/commands/*.md 2>/dev/null | wc -l)"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Highlight key files:
|
|
53
|
+
- `packages/core/src/tools.ts` -- Tool definitions & routing (central hub)
|
|
54
|
+
- `packages/core/src/config.ts` -- Config loader (massu.config.yaml)
|
|
55
|
+
- `packages/core/src/server.ts` -- MCP server entry point
|
|
56
|
+
- `packages/core/src/db.ts` -- Database connections (CodeGraph + Data)
|
|
57
|
+
- `packages/core/src/memory-db.ts` -- Memory database (session, analytics, audit)
|
|
58
|
+
- `massu.config.yaml` -- Single source of project-specific data
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### Section 3: Infrastructure Tour
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
echo "=== .CLAUDE/ INFRASTRUCTURE ==="
|
|
66
|
+
echo "Commands: $(ls .claude/commands/*.md 2>/dev/null | wc -l)"
|
|
67
|
+
echo "CR Rules: $(grep -c '^| CR-' .claude/CLAUDE.md 2>/dev/null)"
|
|
68
|
+
echo "VR Types: $(grep -c '^| VR-' .claude/CLAUDE.md 2>/dev/null)"
|
|
69
|
+
echo "Scripts: $(ls scripts/*.sh 2>/dev/null | wc -l)"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
List top 10 most-used commands:
|
|
73
|
+
- `/massu-loop` -- Main implementation loop with verification
|
|
74
|
+
- `/massu-create-plan` -- Plan generation from requirements
|
|
75
|
+
- `/massu-plan` -- Plan audit and improvement
|
|
76
|
+
- `/massu-commit` -- Pre-commit verification gate
|
|
77
|
+
- `/massu-push` -- Pre-push full verification
|
|
78
|
+
- `/massu-verify` -- Run all VR-* checks
|
|
79
|
+
- `/massu-test` -- Test coverage audit
|
|
80
|
+
- `/massu-tdd` -- Test-driven development cycle
|
|
81
|
+
- `/massu-hotfix` -- Emergency fix protocol
|
|
82
|
+
- `/massu-debug` -- Systematic debugging
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
### Section 4: Key Workflows
|
|
87
|
+
|
|
88
|
+
Present the standard development workflow:
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
/massu-create-plan -> /massu-plan -> /massu-loop -> /massu-commit -> /massu-push
|
|
92
|
+
(CREATE) (AUDIT) (IMPLEMENT) (COMMIT) (PUSH)
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Explain the verification system:
|
|
96
|
+
- **VR-BUILD**: `npm run build` must exit 0
|
|
97
|
+
- **VR-TYPE**: `cd packages/core && npx tsc --noEmit` must have 0 errors
|
|
98
|
+
- **VR-TEST**: `npm test` must pass (MANDATORY)
|
|
99
|
+
- **VR-PATTERN**: `bash scripts/massu-pattern-scanner.sh` must exit 0
|
|
100
|
+
- **VR-NEGATIVE**: grep returns 0 matches for removed code
|
|
101
|
+
|
|
102
|
+
Explain the audit commands:
|
|
103
|
+
- `/massu-internal-codebase-audit` -- Full quality assessment
|
|
104
|
+
- `/massu-internal-security-scan` -- Security-focused audit
|
|
105
|
+
- `/massu-internal-db-audit` -- Database schema audit
|
|
106
|
+
- `/massu-dead-code` -- Unused code detection
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
### Section 5: Common Gotchas
|
|
111
|
+
|
|
112
|
+
Extract from CLAUDE.md:
|
|
113
|
+
|
|
114
|
+
**Config Rules**:
|
|
115
|
+
- Use `getConfig()` NOT direct YAML parsing
|
|
116
|
+
- Use `massu.config.yaml` for ALL project-specific data
|
|
117
|
+
- Tool prefix is configurable (`massu_` default)
|
|
118
|
+
|
|
119
|
+
**Build Rules**:
|
|
120
|
+
- ESM imports require `.ts` extension: `import { x } from './y.ts'`
|
|
121
|
+
- Hooks MUST compile with esbuild: `cd packages/core && npm run build:hooks`
|
|
122
|
+
- All 3 databases have different access patterns (CodeGraph=read-only)
|
|
123
|
+
|
|
124
|
+
**Tool Registration Rules**:
|
|
125
|
+
- Every new tool MUST be wired in `tools.ts` (CR-11)
|
|
126
|
+
- Preferred: 3-function pattern (getDefs + isTool + handleCall)
|
|
127
|
+
- Legacy: 2-function + inline routing
|
|
128
|
+
|
|
129
|
+
**Database Rules**:
|
|
130
|
+
- `getCodeGraphDb()` -- NEVER write to this (read-only)
|
|
131
|
+
- `getDataDb()` -- Import edges, tRPC, sentinel
|
|
132
|
+
- `getMemoryDb()` -- Session memory (ALWAYS close after use)
|
|
133
|
+
|
|
134
|
+
**Known Patterns**:
|
|
135
|
+
|
|
136
|
+
| Pattern | Correct | Error if Wrong |
|
|
137
|
+
|---------|---------|----------------|
|
|
138
|
+
| ESM imports | `import { x } from './y.ts'` | Pattern scanner fails |
|
|
139
|
+
| Config access | `getConfig().toolPrefix` | Direct YAML parse bypasses caching |
|
|
140
|
+
| Tool prefix | `p('tool_name')` helper | Hardcoded prefix breaks portability |
|
|
141
|
+
| memDb lifecycle | `try { ... } finally { memDb.close(); }` | DB connection leak |
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## OUTPUT FORMAT
|
|
146
|
+
|
|
147
|
+
Present each section with a clear header and structured output. After all 5 sections, provide:
|
|
148
|
+
|
|
149
|
+
```markdown
|
|
150
|
+
## ORIENTATION COMPLETE
|
|
151
|
+
|
|
152
|
+
You are now oriented with:
|
|
153
|
+
- [X] Project tech stack and scale
|
|
154
|
+
- [X] Architecture map with key files
|
|
155
|
+
- [X] .claude/ infrastructure (commands, scripts, rules)
|
|
156
|
+
- [X] Standard workflows and verification system
|
|
157
|
+
- [X] Common gotchas and patterns
|
|
158
|
+
|
|
159
|
+
**Ready to start work. Recommended next steps:**
|
|
160
|
+
1. Read the plan file if one exists
|
|
161
|
+
2. Run `/massu-create-plan` for new features
|
|
162
|
+
3. Use `/massu-verify` to check current state
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
**This is a read-only command. It explores and presents -- it does not modify any files.**
|
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: massu-hotfix
|
|
3
|
+
description: Quick scoped fix workflow with branch, test, commit, push, and PR creation
|
|
4
|
+
allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*)
|
|
5
|
+
---
|
|
6
|
+
name: massu-hotfix
|
|
7
|
+
|
|
8
|
+
> **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9, CR-35 enforced.
|
|
9
|
+
|
|
10
|
+
# CS Hotfix: Quick Scoped Fix Workflow
|
|
11
|
+
|
|
12
|
+
## Objective
|
|
13
|
+
|
|
14
|
+
Apply **minimal, targeted fixes** for production issues with fast verification and safe deployment. Fix the bug, nothing more.
|
|
15
|
+
|
|
16
|
+
**Usage**: `/massu-hotfix [description of the fix]`
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## NON-NEGOTIABLE RULES
|
|
21
|
+
|
|
22
|
+
- **Minimal change** - Fix only the bug, no refactoring
|
|
23
|
+
- **Fast verification** - Streamlined checks for speed
|
|
24
|
+
- **Pattern compliance** - Even hotfixes follow CLAUDE.md
|
|
25
|
+
- **Rollback ready** - Know how to undo before applying
|
|
26
|
+
- **No secrets** - Security rules still apply
|
|
27
|
+
- **Document everything** - Full audit trail
|
|
28
|
+
- **FIX ALL INSTANCES (CR-9)** - If the bug exists in multiple files, fix ALL of them. Search codebase for the same pattern.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## ZERO-GAP AUDIT LOOP
|
|
33
|
+
|
|
34
|
+
**Even hotfixes do NOT complete until a SINGLE COMPLETE VERIFICATION finds ZERO issues.**
|
|
35
|
+
|
|
36
|
+
### The Rule
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
HOTFIX VERIFICATION LOOP:
|
|
40
|
+
1. Apply minimal fix
|
|
41
|
+
2. Run verification checks (patterns, types, tests)
|
|
42
|
+
3. Count issues found
|
|
43
|
+
4. IF issues > 0:
|
|
44
|
+
- Fix ALL issues
|
|
45
|
+
- Re-run ENTIRE verification from Step 2
|
|
46
|
+
5. IF issues == 0:
|
|
47
|
+
- HOTFIX VERIFIED
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Completion Requirement
|
|
51
|
+
|
|
52
|
+
| Scenario | Action |
|
|
53
|
+
|----------|--------|
|
|
54
|
+
| Fix introduces type error | Fix it, re-verify ENTIRELY |
|
|
55
|
+
| Re-verify finds pattern violation | Fix it, re-verify ENTIRELY |
|
|
56
|
+
| Re-verify finds 0 issues | **NOW** hotfix verified |
|
|
57
|
+
|
|
58
|
+
**Partial verification is NOT valid. ALL checks must pass in a SINGLE run.**
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## HOTFIX SEVERITY LEVELS
|
|
63
|
+
|
|
64
|
+
| Level | Definition | Response Time |
|
|
65
|
+
|-------|------------|---------------|
|
|
66
|
+
| **P0** | Core functionality broken, data loss, security breach | Immediate |
|
|
67
|
+
| **P1** | Feature broken, no workaround | Within 1 hour |
|
|
68
|
+
| **P2** | Feature degraded, workaround exists | Within 4 hours |
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## SCOPE GUARD (MANDATORY)
|
|
73
|
+
|
|
74
|
+
**This command is for SMALL fixes only. If ANY of these are true, ABORT and suggest `/massu-create-plan` instead:**
|
|
75
|
+
|
|
76
|
+
| Condition | Why It's Too Big |
|
|
77
|
+
|-----------|-----------------|
|
|
78
|
+
| Fix touches > 5 files | Needs a plan |
|
|
79
|
+
| Fix adds new MCP tools | Needs tool registration verification |
|
|
80
|
+
| Fix changes database schema | Needs migration plan |
|
|
81
|
+
| Fix changes config interface | Needs blast radius analysis |
|
|
82
|
+
| Fix requires new dependencies | Needs dependency review |
|
|
83
|
+
| Fix is unclear or ambiguous | Needs requirements clarification |
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
IF scope_check_fails:
|
|
87
|
+
OUTPUT: "This fix is too large for /massu-hotfix. Use /massu-create-plan instead."
|
|
88
|
+
ABORT
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## DOMAIN-SPECIFIC PATTERN LOADING
|
|
94
|
+
|
|
95
|
+
Based on the hotfix area, load relevant patterns from CLAUDE.md:
|
|
96
|
+
|
|
97
|
+
| Domain | Section | Load When |
|
|
98
|
+
|--------|---------|-----------|
|
|
99
|
+
| Tool modules | Tool Registration Pattern | Tool handler/registration bugs |
|
|
100
|
+
| Config | Config Access Pattern | Config parsing/access bugs |
|
|
101
|
+
| Hooks | Hook stdin/stdout Pattern | Hook compilation/runtime bugs |
|
|
102
|
+
| Database | SQLite Database Pattern | DB access/schema bugs |
|
|
103
|
+
| Build | Build & Test Commands | Build/compilation issues |
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## PHASE 1: TRIAGE (5 minutes max)
|
|
108
|
+
|
|
109
|
+
### 1.1 Document the Issue
|
|
110
|
+
```markdown
|
|
111
|
+
## HOTFIX TRIAGE
|
|
112
|
+
|
|
113
|
+
### Issue
|
|
114
|
+
- **Severity**: P0/P1/P2
|
|
115
|
+
- **Symptom**: [What's broken]
|
|
116
|
+
- **Impact**: [Who/what is affected]
|
|
117
|
+
- **Reported**: [When/by whom]
|
|
118
|
+
|
|
119
|
+
### Immediate Questions
|
|
120
|
+
1. Is the MCP server crashing? YES/NO
|
|
121
|
+
2. Is data at risk? YES/NO
|
|
122
|
+
3. Is it a security issue? YES/NO
|
|
123
|
+
4. Is there a workaround? YES/NO
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 1.2 Quick Investigation
|
|
127
|
+
```bash
|
|
128
|
+
# Recent commits
|
|
129
|
+
git log --oneline -10
|
|
130
|
+
|
|
131
|
+
# Recent changes to affected area
|
|
132
|
+
git log --oneline -5 -- [affected_path]
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### 1.3 Identify Root Cause
|
|
136
|
+
```markdown
|
|
137
|
+
### Root Cause (Quick Assessment)
|
|
138
|
+
- **File**: [path]
|
|
139
|
+
- **Line**: [approximate]
|
|
140
|
+
- **Cause**: [brief description]
|
|
141
|
+
- **Confidence**: HIGH/MEDIUM/LOW
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## PHASE 2: FIX DESIGN (5 minutes max)
|
|
147
|
+
|
|
148
|
+
### 2.1 Minimal Fix Plan
|
|
149
|
+
```markdown
|
|
150
|
+
### Hotfix Plan
|
|
151
|
+
|
|
152
|
+
#### Change 1
|
|
153
|
+
- **File**: [path]
|
|
154
|
+
- **Line**: [N]
|
|
155
|
+
- **Current**: [what exists]
|
|
156
|
+
- **Fix**: [what to change]
|
|
157
|
+
- **Why**: [brief reason]
|
|
158
|
+
|
|
159
|
+
#### Rollback
|
|
160
|
+
- **Command**: `git revert [hash]`
|
|
161
|
+
- **Alternative**: [manual steps if needed]
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### 2.2 Pattern Check (Quick)
|
|
165
|
+
Before implementing, verify fix follows CLAUDE.md:
|
|
166
|
+
- [ ] Uses ESM imports (not require())
|
|
167
|
+
- [ ] Uses getConfig() (not direct YAML parse)
|
|
168
|
+
- [ ] Tool handlers follow 3-function pattern
|
|
169
|
+
- [ ] memDb closed in try/finally
|
|
170
|
+
- [ ] No hardcoded secrets
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## PHASE 3: IMPLEMENT (10 minutes max)
|
|
175
|
+
|
|
176
|
+
### 3.1 Create Hotfix Branch
|
|
177
|
+
```bash
|
|
178
|
+
# Ensure clean working tree
|
|
179
|
+
git status --short
|
|
180
|
+
|
|
181
|
+
# From main branch
|
|
182
|
+
git checkout main
|
|
183
|
+
git pull origin main
|
|
184
|
+
git checkout -b hotfix/[issue-name]
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**If working tree is dirty:**
|
|
188
|
+
1. Ask user if changes should be stashed
|
|
189
|
+
2. Do NOT proceed with dirty working tree
|
|
190
|
+
|
|
191
|
+
### 3.2 Apply Minimal Fix
|
|
192
|
+
- Make ONLY the change needed to fix the bug
|
|
193
|
+
- Do NOT refactor surrounding code
|
|
194
|
+
- Do NOT fix "while we're at it" issues
|
|
195
|
+
- Add comment if fix is non-obvious
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## PHASE 4: FAST VERIFICATION (5 minutes)
|
|
200
|
+
|
|
201
|
+
### 4.1 Essential Checks
|
|
202
|
+
```bash
|
|
203
|
+
# Type safety
|
|
204
|
+
cd packages/core && npx tsc --noEmit
|
|
205
|
+
|
|
206
|
+
# Pattern scanner
|
|
207
|
+
bash scripts/massu-pattern-scanner.sh
|
|
208
|
+
|
|
209
|
+
# Run tests
|
|
210
|
+
npm test
|
|
211
|
+
|
|
212
|
+
# Hook build (if hooks modified)
|
|
213
|
+
cd packages/core && npm run build:hooks
|
|
214
|
+
|
|
215
|
+
# Security check
|
|
216
|
+
git diff --cached --name-only | grep -E '\.(env|pem|key)' && echo "FAIL" || echo "PASS"
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### 4.2 Verification Matrix
|
|
220
|
+
```markdown
|
|
221
|
+
### Hotfix Verification
|
|
222
|
+
|
|
223
|
+
| Check | Command | Result | Status |
|
|
224
|
+
|-------|---------|--------|--------|
|
|
225
|
+
| Types | npx tsc --noEmit | 0 errors | PASS |
|
|
226
|
+
| Patterns | massu-pattern-scanner.sh | Exit 0 | PASS |
|
|
227
|
+
| Tests | npm test | All pass | PASS |
|
|
228
|
+
| Secrets | git diff check | 0 files | PASS |
|
|
229
|
+
|
|
230
|
+
**ALL CRITICAL CHECKS: PASS/FAIL**
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**If ANY check fails:**
|
|
234
|
+
1. Fix the issue
|
|
235
|
+
2. Re-run ALL checks (zero-gap loop)
|
|
236
|
+
3. Repeat until clean
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## PHASE 5: COMMIT & PUSH
|
|
241
|
+
|
|
242
|
+
### 5.1 Commit with Hotfix Format
|
|
243
|
+
```bash
|
|
244
|
+
git add [specific files only]
|
|
245
|
+
|
|
246
|
+
git commit -m "$(cat <<'EOF'
|
|
247
|
+
hotfix: [brief description]
|
|
248
|
+
|
|
249
|
+
Fixes: [issue description]
|
|
250
|
+
Root cause: [what was wrong]
|
|
251
|
+
Fix: [what was changed]
|
|
252
|
+
|
|
253
|
+
Severity: P0/P1/P2
|
|
254
|
+
Verified: types, patterns, tests
|
|
255
|
+
|
|
256
|
+
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
257
|
+
EOF
|
|
258
|
+
)"
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### 5.2 Create PR (If Required)
|
|
262
|
+
|
|
263
|
+
Ask user before pushing:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
git push -u origin hotfix/[issue-name]
|
|
267
|
+
|
|
268
|
+
gh pr create --title "hotfix: [description]" --body "$(cat <<'EOF'
|
|
269
|
+
## Hotfix
|
|
270
|
+
|
|
271
|
+
### Issue
|
|
272
|
+
[Description of the issue]
|
|
273
|
+
|
|
274
|
+
### Root Cause
|
|
275
|
+
[What was wrong]
|
|
276
|
+
|
|
277
|
+
### Fix
|
|
278
|
+
[What was changed]
|
|
279
|
+
|
|
280
|
+
### Verification
|
|
281
|
+
- [ ] Types pass
|
|
282
|
+
- [ ] Pattern scanner passes
|
|
283
|
+
- [ ] All tests pass
|
|
284
|
+
- [ ] Tested fix locally
|
|
285
|
+
|
|
286
|
+
### Rollback Plan
|
|
287
|
+
`git revert [commit-hash]`
|
|
288
|
+
EOF
|
|
289
|
+
)"
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
---
|
|
293
|
+
|
|
294
|
+
## ROLLBACK PROCEDURE
|
|
295
|
+
|
|
296
|
+
If hotfix causes problems:
|
|
297
|
+
|
|
298
|
+
### Immediate Rollback
|
|
299
|
+
```bash
|
|
300
|
+
# Revert the commit
|
|
301
|
+
git revert [hotfix-commit-hash] --no-edit
|
|
302
|
+
git push origin main
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### Verify Rollback
|
|
306
|
+
```bash
|
|
307
|
+
# Confirm no new issues from hotfix revert
|
|
308
|
+
npm test
|
|
309
|
+
cd packages/core && npx tsc --noEmit
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## ABORT CONDITIONS
|
|
315
|
+
|
|
316
|
+
If at ANY point during the hotfix:
|
|
317
|
+
|
|
318
|
+
| Condition | Action |
|
|
319
|
+
|-----------|--------|
|
|
320
|
+
| Fix is more complex than expected | Abort, suggest /massu-create-plan |
|
|
321
|
+
| Tests fail in unrelated areas | Abort, investigate first |
|
|
322
|
+
| Fix would break other functionality | Abort, needs broader analysis |
|
|
323
|
+
| Merge conflicts with main | Abort, rebase first |
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
# Abort protocol
|
|
327
|
+
git checkout main
|
|
328
|
+
git branch -D hotfix/[short-description]
|
|
329
|
+
echo "Hotfix aborted. Reason: [reason]"
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
## QUICK REFERENCE
|
|
335
|
+
|
|
336
|
+
### P0 Checklist (Core Broken)
|
|
337
|
+
1. [ ] Identify symptom
|
|
338
|
+
2. [ ] Check recent commits
|
|
339
|
+
3. [ ] Find root cause
|
|
340
|
+
4. [ ] Apply minimal fix
|
|
341
|
+
5. [ ] Type check + tests
|
|
342
|
+
6. [ ] Commit and push
|
|
343
|
+
7. [ ] Verify fix
|
|
344
|
+
8. [ ] Document
|
|
345
|
+
|
|
346
|
+
### P1 Checklist (Feature Broken)
|
|
347
|
+
1. [ ] Document issue
|
|
348
|
+
2. [ ] Investigate cause
|
|
349
|
+
3. [ ] Design minimal fix
|
|
350
|
+
4. [ ] Verify patterns
|
|
351
|
+
5. [ ] Full verification
|
|
352
|
+
6. [ ] PR + review
|
|
353
|
+
7. [ ] Push
|
|
354
|
+
8. [ ] Verify + document
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
## START NOW
|
|
359
|
+
|
|
360
|
+
**Step 0: Write AUTHORIZED_COMMAND to session state (CR-35)**
|
|
361
|
+
|
|
362
|
+
Update `session-state/CURRENT.md` to include `AUTHORIZED_COMMAND: massu-hotfix`.
|
|
363
|
+
|
|
364
|
+
Then:
|
|
365
|
+
1. Triage: Assess severity and impact
|
|
366
|
+
2. Investigate: Find root cause quickly
|
|
367
|
+
3. Plan: Design minimal fix with rollback
|
|
368
|
+
4. Implement: Make only the necessary change
|
|
369
|
+
5. Verify: Run essential checks
|
|
370
|
+
6. Commit: Commit and push
|
|
371
|
+
7. Document: Update session state and report
|
|
372
|
+
|
|
373
|
+
**Remember: Fix the bug, only the bug, nothing but the bug.**
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## MANDATORY PLAN DOCUMENT UPDATE (If Hotfix From Plan)
|
|
378
|
+
|
|
379
|
+
**If hotfix was derived from a plan document, update the plan with completion status.**
|
|
380
|
+
|
|
381
|
+
```markdown
|
|
382
|
+
# IMPLEMENTATION STATUS
|
|
383
|
+
|
|
384
|
+
**Plan**: [Plan Name]
|
|
385
|
+
**Status**: HOTFIX APPLIED
|
|
386
|
+
**Last Updated**: [YYYY-MM-DD HH:MM]
|
|
387
|
+
|
|
388
|
+
## Hotfix Applied
|
|
389
|
+
|
|
390
|
+
| # | Fix Description | Status | Verification | Date |
|
|
391
|
+
|---|-----------------|--------|--------------|------|
|
|
392
|
+
| 1 | [Hotfix description] | COMPLETE | VR-TEST: Pass | [date] |
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
---
|
|
396
|
+
|
|
397
|
+
## SESSION STATE UPDATE
|
|
398
|
+
|
|
399
|
+
After hotfix, update `session-state/CURRENT.md`:
|
|
400
|
+
|
|
401
|
+
```markdown
|
|
402
|
+
## HOTFIX SESSION
|
|
403
|
+
|
|
404
|
+
### Issue
|
|
405
|
+
- **Severity**: P0/P1/P2
|
|
406
|
+
- **Symptom**: [description]
|
|
407
|
+
|
|
408
|
+
### Fix
|
|
409
|
+
- **File**: [path]
|
|
410
|
+
- **Change**: [description]
|
|
411
|
+
- **Commit**: [hash]
|
|
412
|
+
|
|
413
|
+
### Status
|
|
414
|
+
- Applied: YES
|
|
415
|
+
- Verified: YES
|
|
416
|
+
|
|
417
|
+
### Follow-up
|
|
418
|
+
[Any additional work needed]
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
---
|
|
422
|
+
|
|
423
|
+
## AUTO-LEARNING PROTOCOL (MANDATORY after every hotfix)
|
|
424
|
+
|
|
425
|
+
**Every hotfix represents a failure that MUST be recorded so the system learns.**
|
|
426
|
+
|
|
427
|
+
### After Fix is Verified:
|
|
428
|
+
|
|
429
|
+
1. **Record in session state**: Update `.claude/session-state/CURRENT.md` with the wrong pattern and correct pattern
|
|
430
|
+
2. **Add to pattern scanner**: If the bad pattern is grep-able, add detection to `scripts/massu-pattern-scanner.sh`
|
|
431
|
+
3. **Search codebase-wide**: `grep -rn "[bad_pattern]" packages/core/src/ --include="*.ts"` and fix ALL instances (CR-9)
|
|
432
|
+
4. **Consider new CR rule**: If this is a class of bug (not one-off), propose a new CR rule for CLAUDE.md
|
|
433
|
+
|
|
434
|
+
**Hotfixes without learning are wasted crises. Every failure teaches something -- capture it.**
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
## COMPLETION REPORT
|
|
439
|
+
|
|
440
|
+
```markdown
|
|
441
|
+
## CS HOTFIX COMPLETE
|
|
442
|
+
|
|
443
|
+
### Summary
|
|
444
|
+
- **Date**: [timestamp]
|
|
445
|
+
- **Severity**: P0/P1/P2
|
|
446
|
+
- **Time to Fix**: [duration]
|
|
447
|
+
- **Status**: RESOLVED
|
|
448
|
+
|
|
449
|
+
### Issue
|
|
450
|
+
- **Symptom**: [what was broken]
|
|
451
|
+
- **Impact**: [what was affected]
|
|
452
|
+
- **Root Cause**: [technical cause]
|
|
453
|
+
|
|
454
|
+
### Fix Applied
|
|
455
|
+
- **File(s)**: [paths]
|
|
456
|
+
- **Change**: [description]
|
|
457
|
+
- **Branch**: hotfix/[description]
|
|
458
|
+
- **Commit**: [hash]
|
|
459
|
+
|
|
460
|
+
### Verification
|
|
461
|
+
| Check | Status |
|
|
462
|
+
|-------|--------|
|
|
463
|
+
| Type Safety | PASS |
|
|
464
|
+
| Pattern Scanner | PASS |
|
|
465
|
+
| Tests | PASS ([N] passed) |
|
|
466
|
+
|
|
467
|
+
### Rollback Plan
|
|
468
|
+
git revert [commit-hash]
|
|
469
|
+
|
|
470
|
+
### PR (if created)
|
|
471
|
+
- **URL**: [PR URL]
|
|
472
|
+
- **Status**: Open
|
|
473
|
+
|
|
474
|
+
### Follow-up Required
|
|
475
|
+
- [ ] Add test coverage for the bug
|
|
476
|
+
- [ ] Review related code
|
|
477
|
+
- [ ] Root cause analysis
|
|
478
|
+
|
|
479
|
+
**HOTFIX COMPLETE**
|
|
480
|
+
```
|