@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.
Files changed (84) hide show
  1. package/commands/_shared-preamble.md +76 -0
  2. package/commands/massu-audit-deps.md +211 -0
  3. package/commands/massu-changelog.md +174 -0
  4. package/commands/massu-cleanup.md +315 -0
  5. package/commands/massu-commit.md +481 -0
  6. package/commands/massu-create-plan.md +752 -0
  7. package/commands/massu-dead-code.md +131 -0
  8. package/commands/massu-debug.md +484 -0
  9. package/commands/massu-deploy.md +91 -0
  10. package/commands/massu-deps.md +374 -0
  11. package/commands/massu-doc-gen.md +279 -0
  12. package/commands/massu-docs.md +364 -0
  13. package/commands/massu-estimate.md +313 -0
  14. package/commands/massu-golden-path.md +973 -0
  15. package/commands/massu-guide.md +167 -0
  16. package/commands/massu-hotfix.md +480 -0
  17. package/commands/massu-loop-playwright.md +837 -0
  18. package/commands/massu-loop.md +775 -0
  19. package/commands/massu-new-feature.md +511 -0
  20. package/commands/massu-parity.md +214 -0
  21. package/commands/massu-plan.md +456 -0
  22. package/commands/massu-push-light.md +207 -0
  23. package/commands/massu-push.md +434 -0
  24. package/commands/massu-refactor.md +410 -0
  25. package/commands/massu-release.md +363 -0
  26. package/commands/massu-review.md +238 -0
  27. package/commands/massu-simplify.md +281 -0
  28. package/commands/massu-status.md +278 -0
  29. package/commands/massu-tdd.md +201 -0
  30. package/commands/massu-test.md +516 -0
  31. package/commands/massu-verify-playwright.md +281 -0
  32. package/commands/massu-verify.md +667 -0
  33. package/dist/cli.js +12521 -0
  34. package/dist/hooks/cost-tracker.js +80 -5
  35. package/dist/hooks/post-edit-context.js +72 -6
  36. package/dist/hooks/post-tool-use.js +234 -57
  37. package/dist/hooks/pre-compact.js +144 -5
  38. package/dist/hooks/pre-delete-check.js +141 -11
  39. package/dist/hooks/quality-event.js +80 -5
  40. package/dist/hooks/security-gate.js +29 -0
  41. package/dist/hooks/session-end.js +83 -8
  42. package/dist/hooks/session-start.js +153 -7
  43. package/dist/hooks/user-prompt.js +166 -5
  44. package/package.json +6 -5
  45. package/src/backfill-sessions.ts +5 -4
  46. package/src/cli.ts +6 -1
  47. package/src/commands/doctor.ts +193 -6
  48. package/src/commands/init.ts +235 -6
  49. package/src/commands/install-commands.ts +137 -0
  50. package/src/config.ts +68 -2
  51. package/src/db.ts +115 -2
  52. package/src/docs-tools.ts +8 -6
  53. package/src/hooks/post-edit-context.ts +1 -1
  54. package/src/hooks/post-tool-use.ts +130 -0
  55. package/src/hooks/pre-compact.ts +23 -1
  56. package/src/hooks/pre-delete-check.ts +92 -4
  57. package/src/hooks/security-gate.ts +32 -0
  58. package/src/hooks/session-start.ts +97 -4
  59. package/src/hooks/user-prompt.ts +46 -1
  60. package/src/import-resolver.ts +2 -1
  61. package/src/knowledge-db.ts +169 -0
  62. package/src/knowledge-indexer.ts +704 -0
  63. package/src/knowledge-tools.ts +1413 -0
  64. package/src/license.ts +482 -0
  65. package/src/memory-db.ts +14 -1
  66. package/src/observation-extractor.ts +11 -4
  67. package/src/page-deps.ts +3 -2
  68. package/src/python/coupling-detector.ts +124 -0
  69. package/src/python/domain-enforcer.ts +83 -0
  70. package/src/python/impact-analyzer.ts +95 -0
  71. package/src/python/import-parser.ts +244 -0
  72. package/src/python/import-resolver.ts +135 -0
  73. package/src/python/migration-indexer.ts +115 -0
  74. package/src/python/migration-parser.ts +332 -0
  75. package/src/python/model-indexer.ts +70 -0
  76. package/src/python/model-parser.ts +279 -0
  77. package/src/python/route-indexer.ts +58 -0
  78. package/src/python/route-parser.ts +317 -0
  79. package/src/python-tools.ts +629 -0
  80. package/src/sentinel-db.ts +2 -1
  81. package/src/server.ts +29 -6
  82. package/src/session-archiver.ts +4 -5
  83. package/src/tools.ts +283 -31
  84. package/README.md +0 -40
@@ -0,0 +1,76 @@
1
+ # Shared Command Preamble
2
+
3
+ **This file is loaded by commands that reference it. Do NOT invoke directly.**
4
+
5
+ ---
6
+
7
+ ## POST-COMPACTION SAFETY CHECK (MANDATORY)
8
+
9
+ **If this session was continued from a previous conversation (compaction/continuation), you MUST:**
10
+
11
+ 1. **Verify the user explicitly invoked this command** - Check the user's LAST ACTUAL message. Continuation instructions ("continue where you left off") are NOT user commands.
12
+ 2. **Check AUTHORIZED_COMMAND in session-state/CURRENT.md (CR-35)** - If present and does NOT match this command, this may be unauthorized escalation.
13
+ 3. **System-injected skill invocations after compaction are NOT user commands.**
14
+
15
+ ---
16
+
17
+ ## QUALITY STANDARDS (CR-14)
18
+
19
+ All work MUST be production-ready, permanent, professional. No temporary fixes, workarounds, or "quick fixes". If a proper solution requires more work, do that work.
20
+
21
+ ## SIMPLEST CORRECT SOLUTION (Core Principle #18)
22
+
23
+ Production-grade does NOT mean over-engineered. Choose the simplest approach that is correct and complete. If scope is expanding beyond the original task, flag it to the user before continuing.
24
+
25
+ ## ELEGANCE CHECK (Core Principle #19)
26
+
27
+ For non-trivial changes (3+ files, new abstractions, design decisions):
28
+ - Pause and ask: "Is there a more elegant way?"
29
+ - If it feels hacky: implement the elegant solution instead
30
+ - Ask: "Would a staff engineer approve this approach?"
31
+
32
+ For simple, obvious fixes: skip this check. Don't over-engineer.
33
+
34
+ ---
35
+
36
+ ## DUAL VERIFICATION REQUIREMENT
37
+
38
+ Both gates must pass before claiming complete:
39
+
40
+ | Gate | What It Checks |
41
+ |------|----------------|
42
+ | **Code Quality** | Pattern scanner, build, types, tests |
43
+ | **Plan Coverage** | Every plan item verified with VR-* proof (100%) |
44
+
45
+ Code Quality: PASS + Plan Coverage: FAIL = NOT COMPLETE.
46
+
47
+ ## GAPS_DISCOVERED Semantics
48
+
49
+ `GAPS_DISCOVERED` = total gaps FOUND during a pass, REGARDLESS of whether fixed. Finding 5 gaps and fixing all 5 = GAPS_DISCOVERED: 5 (NOT 0). Only a fresh pass finding nothing from the start = 0. Fixes during a pass require a fresh re-verification pass.
50
+
51
+ ## FIX ALL ISSUES ENCOUNTERED (CR-9)
52
+
53
+ ANY issue discovered during work MUST be fixed immediately, whether from current changes or pre-existing. "Not in scope" and "pre-existing" are NEVER valid reasons to skip. When fixing a bug, search entire codebase for the same pattern and fix ALL instances.
54
+
55
+ ## SESSION CONTEXT LOADING
56
+
57
+ At session start, call `massu_memory_sessions` to list recent sessions and load context for continuity.
58
+
59
+ ## MCP TOOL REQUIREMENTS (CR-11, CR-34)
60
+
61
+ **CR-34 Auto-Learning** -- After every bug fix:
62
+ 1. Call `mcp__massu__massu_memory_ingest` with `type: "bugfix"`, affected files, root cause, and fix description
63
+ 2. Add wrong-vs-correct pattern to `MEMORY.md`
64
+ 3. Search codebase-wide for same bad pattern (CR-9) and fix all instances
65
+
66
+ **CR-11 Sentinel Registration** -- After completing any feature:
67
+ 1. Call `mcp__massu__massu_sentinel_register` with feature name, file list, domain, and test status
68
+ 2. This is REQUIRED before claiming any feature complete (VR-TOOL-REG)
69
+
70
+ ## AUTO-LEARNING PROTOCOL
71
+
72
+ After every bug fix or issue resolution:
73
+ 1. Record the pattern - What went wrong and how it was fixed
74
+ 2. Check if pattern scanner should be updated - Can the check be automated?
75
+ 3. Update session state - Record in `.claude/session-state/CURRENT.md`
76
+ 4. Search codebase-wide for same bad pattern (CR-9) and fix all instances
@@ -0,0 +1,211 @@
1
+ ---
2
+ name: massu-audit-deps
3
+ description: Comprehensive dependency audit (vulnerabilities, outdated, licenses, unused, bundle size)
4
+ allowed-tools: Bash(*), Read(*), Grep(*), Glob(*)
5
+ ---
6
+ name: massu-audit-deps
7
+
8
+ > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9, CR-35 enforced.
9
+
10
+ # CS Audit Deps: Comprehensive Dependency Audit
11
+
12
+ ## Objective
13
+
14
+ Run a multi-phase dependency audit covering security vulnerabilities, outdated packages, license compliance, unused dependencies, and bundle size analysis. This is a READ-ONLY audit - no packages are modified.
15
+
16
+ ## Workflow Position
17
+
18
+ Dependency audit is a diagnostic command. Produces a report of vulnerabilities, license issues, and unused packages.
19
+
20
+ ```
21
+ /massu-audit-deps -> dependency report -> /massu-create-plan (if updates needed)
22
+ ```
23
+
24
+ ---
25
+
26
+ ## NON-NEGOTIABLE RULES
27
+
28
+ - Do NOT install, update, or remove any packages
29
+ - Do NOT modify package.json or package-lock.json
30
+ - Report ALL findings with severity classification
31
+ - License compliance checks MUST account for BSL 1.1 compatibility
32
+ - Bundle size analysis applies to hooks (esbuild output)
33
+
34
+ ---
35
+
36
+ ## PHASE 1: VULNERABILITY SCAN
37
+
38
+ ```bash
39
+ # Run npm audit with full detail
40
+ npm audit 2>&1
41
+
42
+ # Separate by severity
43
+ npm audit --audit-level=critical 2>&1 || true
44
+ npm audit --audit-level=high 2>&1 || true
45
+ ```
46
+
47
+ ### Vulnerability Classification
48
+
49
+ | Severity | Action Required | Blocks Push? |
50
+ |----------|----------------|--------------|
51
+ | Critical | MUST fix before any deployment | YES |
52
+ | High | MUST fix before push | YES |
53
+ | Moderate | Document, create fix plan | NO |
54
+ | Low | Informational only | NO |
55
+
56
+ ### For Each Vulnerability
57
+
58
+ ```markdown
59
+ | Package | Severity | CVE | Affects Production? | Fix Available? | Action |
60
+ |---------|----------|-----|---------------------|----------------|--------|
61
+ | [pkg] | [sev] | [cve] | YES/NO (dev-only) | YES/NO | [action] |
62
+ ```
63
+
64
+ **Key distinction**: Dev-only vulnerabilities (in devDependencies, build tooling) are lower priority than production runtime vulnerabilities.
65
+
66
+ ---
67
+
68
+ ## PHASE 2: OUTDATED PACKAGES
69
+
70
+ ```bash
71
+ # Check for outdated packages
72
+ npm outdated 2>&1 || true
73
+
74
+ # Check in website directory if it exists
75
+ ls website/package.json 2>/dev/null && (cd website && npm outdated 2>&1 || true)
76
+ ```
77
+
78
+ ### Outdated Classification
79
+
80
+ | Update Type | Risk | Recommendation |
81
+ |-------------|------|----------------|
82
+ | Patch (1.2.3 -> 1.2.4) | Low | Update in next commit |
83
+ | Minor (1.2.3 -> 1.3.0) | Medium | Review changelog, then update |
84
+ | Major (1.2.3 -> 2.0.0) | High | Plan migration, check breaking changes |
85
+
86
+ ```markdown
87
+ ### Outdated Packages
88
+
89
+ | Package | Current | Wanted | Latest | Type | Risk |
90
+ |---------|---------|--------|--------|------|------|
91
+ | [pkg] | [ver] | [ver] | [ver] | patch/minor/major | Low/Med/High |
92
+ ```
93
+
94
+ ---
95
+
96
+ ## PHASE 3: LICENSE COMPLIANCE
97
+
98
+ **Massu uses BSL 1.1 license. Dependencies must be compatible.**
99
+
100
+ ```bash
101
+ # List all production dependency licenses
102
+ npx license-checker --production --summary 2>/dev/null || \
103
+ npm ls --all --production 2>/dev/null | head -50
104
+
105
+ # Check for known problematic licenses
106
+ npx license-checker --production --failOn "GPL-2.0;GPL-3.0;AGPL-3.0;AGPL-1.0;SSPL-1.0" 2>/dev/null || \
107
+ echo "license-checker not installed - manual review needed"
108
+ ```
109
+
110
+ ### License Compatibility Matrix
111
+
112
+ | License | Compatible with BSL 1.1? | Action |
113
+ |---------|-------------------------|--------|
114
+ | MIT | YES | No action |
115
+ | Apache-2.0 | YES | No action |
116
+ | BSD-2-Clause | YES | No action |
117
+ | BSD-3-Clause | YES | No action |
118
+ | ISC | YES | No action |
119
+ | GPL-2.0 | INCOMPATIBLE | Must replace |
120
+ | GPL-3.0 | INCOMPATIBLE | Must replace |
121
+ | AGPL-3.0 | INCOMPATIBLE | Must replace |
122
+ | SSPL-1.0 | INCOMPATIBLE | Must replace |
123
+ | LGPL-2.1 | REVIEW | Check usage pattern |
124
+
125
+ **If license-checker is not installed**, manually check:
126
+ ```bash
127
+ # For each production dependency, check license field
128
+ cat package.json | node -e "
129
+ const pkg = require('./package.json');
130
+ const deps = Object.keys(pkg.dependencies || {});
131
+ deps.forEach(d => {
132
+ try {
133
+ const p = require(d + '/package.json');
134
+ console.log(d + ': ' + (p.license || 'UNKNOWN'));
135
+ } catch(e) { console.log(d + ': CHECK MANUALLY'); }
136
+ });
137
+ "
138
+ ```
139
+
140
+ ---
141
+
142
+ ## PHASE 4: UNUSED DEPENDENCY DETECTION
143
+
144
+ ```bash
145
+ # Check if each dependency is actually imported in source
146
+ for dep in $(node -e "const p=require('./package.json'); Object.keys(p.dependencies||{}).forEach(d=>console.log(d))"); do
147
+ count=$(grep -rn "from ['\"]$dep" packages/core/src/ --include="*.ts" 2>/dev/null | wc -l | tr -d ' ')
148
+ count2=$(grep -rn "require(['\"]$dep" packages/core/src/ --include="*.ts" 2>/dev/null | wc -l | tr -d ' ')
149
+ total=$((count + count2))
150
+ if [ "$total" -eq 0 ]; then
151
+ echo "UNUSED: $dep (0 imports found)"
152
+ fi
153
+ done
154
+ ```
155
+
156
+ ```markdown
157
+ ### Unused Dependencies
158
+
159
+ | Package | In package.json | Imports Found | Recommendation |
160
+ |---------|----------------|---------------|----------------|
161
+ | [pkg] | dependencies | 0 | Remove or verify indirect usage |
162
+ ```
163
+
164
+ **Note**: Some packages may be used indirectly (peer deps, plugin systems). Flag but don't auto-remove.
165
+
166
+ ---
167
+
168
+ ## PHASE 5: BUNDLE SIZE ANALYSIS (Hooks)
169
+
170
+ ```bash
171
+ # Check compiled hook sizes
172
+ ls -la packages/core/dist/hooks/*.js 2>/dev/null
173
+
174
+ # Check total hook bundle size
175
+ du -sh packages/core/dist/hooks/ 2>/dev/null || echo "Hooks not compiled - run: cd packages/core && npm run build:hooks"
176
+ ```
177
+
178
+ ### Hook Size Thresholds
179
+
180
+ | Metric | Threshold | Status |
181
+ |--------|-----------|--------|
182
+ | Individual hook | < 50 KB | PASS/FAIL |
183
+ | Total hooks dir | < 500 KB | PASS/FAIL |
184
+
185
+ ---
186
+
187
+ ## COMPLETION REPORT
188
+
189
+ ```markdown
190
+ ## CS AUDIT DEPS COMPLETE
191
+
192
+ ### Summary
193
+ | Phase | Findings | Critical? |
194
+ |-------|----------|-----------|
195
+ | Vulnerabilities | [N] total ([N] high/critical) | YES/NO |
196
+ | Outdated | [N] packages ([N] major) | NO |
197
+ | License | [N] incompatible | YES/NO |
198
+ | Unused | [N] potentially unused | NO |
199
+ | Bundle Size | [size] total hooks | PASS/FAIL |
200
+
201
+ ### Action Items (Priority Order)
202
+ 1. [Critical/High vulnerabilities to fix]
203
+ 2. [Incompatible licenses to replace]
204
+ 3. [Major version updates to plan]
205
+ 4. [Unused deps to investigate]
206
+
207
+ ### Overall Health
208
+ - **Vulnerability Score**: CLEAN / MODERATE / AT RISK
209
+ - **Freshness Score**: CURRENT / STALE / OUTDATED
210
+ - **License Compliance**: COMPLIANT / REVIEW NEEDED / NON-COMPLIANT
211
+ ```
@@ -0,0 +1,174 @@
1
+ ---
2
+ name: massu-changelog
3
+ description: Generate changelog entries from conventional commits
4
+ allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*)
5
+ ---
6
+ name: massu-changelog
7
+
8
+ > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9, CR-35 enforced.
9
+
10
+ # CS Changelog: Generate Changelog from Commits
11
+
12
+ ## Objective
13
+
14
+ Parse conventional commits since the last release/tag and generate structured changelog entries. Updates `CHANGELOG.md` with properly categorized changes.
15
+
16
+ **Usage**: `/massu-changelog` (since last tag) or `/massu-changelog [since-ref]`
17
+
18
+ ---
19
+
20
+ ## STEP 1: DETERMINE RANGE
21
+
22
+ ```bash
23
+ # Find the last tag
24
+ LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
25
+
26
+ # If no tags, use first commit
27
+ if [ -z "$LAST_TAG" ]; then
28
+ SINCE=$(git rev-list --max-parents=0 HEAD)
29
+ echo "No tags found, generating from first commit"
30
+ else
31
+ SINCE="$LAST_TAG"
32
+ echo "Generating changelog since $LAST_TAG"
33
+ fi
34
+
35
+ # If argument provided, use that as the since reference
36
+ # SINCE=$ARGUMENTS (if provided)
37
+
38
+ # Get commit log
39
+ git log $SINCE..HEAD --pretty=format:"%H|%s|%an|%ad" --date=short
40
+ ```
41
+
42
+ ---
43
+
44
+ ## STEP 2: PARSE CONVENTIONAL COMMITS
45
+
46
+ Parse each commit message using conventional commit format: `type(scope): description`
47
+
48
+ ### Commit Type Mapping
49
+
50
+ | Type | Changelog Section | Emoji |
51
+ |------|------------------|-------|
52
+ | feat | Added | - |
53
+ | fix | Fixed | - |
54
+ | perf | Performance | - |
55
+ | refactor | Changed | - |
56
+ | docs | Documentation | - |
57
+ | test | Tests | - |
58
+ | build | Build | - |
59
+ | ci | CI/CD | - |
60
+ | chore | Maintenance | - |
61
+ | security | Security | - |
62
+ | revert | Reverted | - |
63
+ | BREAKING CHANGE | Breaking Changes | - |
64
+
65
+ ### Parsing Rules
66
+ - Commits not following conventional format go under "Other"
67
+ - Scope (if present) is included in parentheses
68
+ - Multi-line commit bodies are included as sub-bullets
69
+ - Co-authored-by lines are stripped from display
70
+
71
+ ---
72
+
73
+ ## STEP 3: GROUP AND FORMAT
74
+
75
+ ```markdown
76
+ ## [Unreleased]
77
+
78
+ ### Breaking Changes
79
+ - [breaking changes, if any]
80
+
81
+ ### Added
82
+ - [feat commits]
83
+
84
+ ### Changed
85
+ - [refactor commits]
86
+
87
+ ### Fixed
88
+ - [fix commits]
89
+
90
+ ### Performance
91
+ - [perf commits]
92
+
93
+ ### Security
94
+ - [security-related commits]
95
+
96
+ ### Documentation
97
+ - [docs commits]
98
+
99
+ ### Tests
100
+ - [test commits]
101
+
102
+ ### Build & CI
103
+ - [build/ci commits]
104
+
105
+ ### Maintenance
106
+ - [chore commits]
107
+ ```
108
+
109
+ **Empty sections are omitted.**
110
+
111
+ ---
112
+
113
+ ## STEP 4: UPDATE CHANGELOG.md
114
+
115
+ 1. Read existing `CHANGELOG.md`
116
+ 2. Insert new entries under `## [Unreleased]` section
117
+ 3. If entries already exist under `[Unreleased]`, merge (don't duplicate)
118
+
119
+ ```bash
120
+ # Read current changelog
121
+ cat CHANGELOG.md
122
+ ```
123
+
124
+ **Merge strategy:**
125
+ - If `## [Unreleased]` exists, replace its content with new entries
126
+ - If no `## [Unreleased]`, insert after the header
127
+ - Preserve all previous released sections unchanged
128
+
129
+ ---
130
+
131
+ ## STEP 5: OPTIONAL TAG CREATION
132
+
133
+ Ask the user if they want to create a release tag:
134
+
135
+ ```markdown
136
+ ### Changelog generated. Create a release tag?
137
+
138
+ If yes, provide:
139
+ - Version number (semver): e.g., 0.2.0
140
+ - This will:
141
+ 1. Replace `## [Unreleased]` with `## [0.2.0] - YYYY-MM-DD`
142
+ 2. Add a new empty `## [Unreleased]` section above
143
+ 3. Create git tag `v0.2.0`
144
+ ```
145
+
146
+ ---
147
+
148
+ ## COMPLETION REPORT
149
+
150
+ ```markdown
151
+ ## CS CHANGELOG COMPLETE
152
+
153
+ ### Summary
154
+ - **Range**: [since]..HEAD
155
+ - **Commits parsed**: [N]
156
+ - **Sections updated**: [list]
157
+
158
+ ### Changes by Type
159
+ | Type | Count |
160
+ |------|-------|
161
+ | feat | [N] |
162
+ | fix | [N] |
163
+ | refactor | [N] |
164
+ | docs | [N] |
165
+ | other | [N] |
166
+
167
+ ### File Updated
168
+ - `CHANGELOG.md`
169
+
170
+ ### Next Steps
171
+ - Review the changelog entries
172
+ - Run `/massu-commit` to commit the changelog update
173
+ - Optionally create a release tag
174
+ ```