@massu/core 0.1.1 → 0.4.0

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 (151) 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 +7772 -3140
  34. package/dist/hooks/cost-tracker.js +103 -40
  35. package/dist/hooks/post-edit-context.js +74 -8
  36. package/dist/hooks/post-tool-use.js +268 -106
  37. package/dist/hooks/pre-compact.js +167 -43
  38. package/dist/hooks/pre-delete-check.js +159 -42
  39. package/dist/hooks/quality-event.js +103 -40
  40. package/dist/hooks/security-gate.js +29 -0
  41. package/dist/hooks/session-end.js +143 -84
  42. package/dist/hooks/session-start.js +186 -49
  43. package/dist/hooks/user-prompt.js +189 -43
  44. package/package.json +10 -15
  45. package/src/adr-generator.ts +9 -2
  46. package/src/analytics.ts +9 -3
  47. package/src/audit-trail.ts +10 -3
  48. package/src/backfill-sessions.ts +5 -4
  49. package/src/cli.ts +6 -0
  50. package/src/cloud-sync.ts +14 -18
  51. package/src/commands/doctor.ts +193 -6
  52. package/src/commands/init.ts +230 -5
  53. package/src/commands/install-commands.ts +137 -0
  54. package/src/config.ts +68 -2
  55. package/src/cost-tracker.ts +11 -6
  56. package/src/db.ts +115 -2
  57. package/src/dependency-scorer.ts +9 -2
  58. package/src/docs-tools.ts +21 -16
  59. package/src/hooks/post-edit-context.ts +4 -4
  60. package/src/hooks/post-tool-use.ts +130 -0
  61. package/src/hooks/pre-compact.ts +23 -1
  62. package/src/hooks/pre-delete-check.ts +92 -4
  63. package/src/hooks/security-gate.ts +32 -0
  64. package/src/hooks/session-end.ts +3 -3
  65. package/src/hooks/session-start.ts +99 -6
  66. package/src/hooks/user-prompt.ts +46 -1
  67. package/src/import-resolver.ts +2 -1
  68. package/src/knowledge-db.ts +169 -0
  69. package/src/knowledge-indexer.ts +704 -0
  70. package/src/knowledge-tools.ts +1413 -0
  71. package/src/license.ts +482 -0
  72. package/src/memory-db.ts +1364 -23
  73. package/src/memory-tools.ts +14 -15
  74. package/src/observability-tools.ts +13 -2
  75. package/src/observation-extractor.ts +11 -4
  76. package/src/page-deps.ts +3 -2
  77. package/src/prompt-analyzer.ts +9 -2
  78. package/src/python/coupling-detector.ts +124 -0
  79. package/src/python/domain-enforcer.ts +83 -0
  80. package/src/python/impact-analyzer.ts +95 -0
  81. package/src/python/import-parser.ts +244 -0
  82. package/src/python/import-resolver.ts +135 -0
  83. package/src/python/migration-indexer.ts +115 -0
  84. package/src/python/migration-parser.ts +332 -0
  85. package/src/python/model-indexer.ts +70 -0
  86. package/src/python/model-parser.ts +279 -0
  87. package/src/python/route-indexer.ts +58 -0
  88. package/src/python/route-parser.ts +317 -0
  89. package/src/python-tools.ts +629 -0
  90. package/src/regression-detector.ts +9 -3
  91. package/src/security-scorer.ts +9 -2
  92. package/src/sentinel-db.ts +45 -89
  93. package/src/sentinel-tools.ts +8 -11
  94. package/src/server.ts +29 -7
  95. package/src/session-archiver.ts +4 -5
  96. package/src/team-knowledge.ts +9 -2
  97. package/src/tools.ts +1032 -44
  98. package/src/validate-features-runner.ts +0 -1
  99. package/src/validation-engine.ts +9 -2
  100. package/README.md +0 -40
  101. package/dist/server.js +0 -7008
  102. package/src/__tests__/adr-generator.test.ts +0 -260
  103. package/src/__tests__/analytics.test.ts +0 -282
  104. package/src/__tests__/audit-trail.test.ts +0 -382
  105. package/src/__tests__/backfill-sessions.test.ts +0 -690
  106. package/src/__tests__/cli.test.ts +0 -290
  107. package/src/__tests__/cloud-sync.test.ts +0 -261
  108. package/src/__tests__/config-sections.test.ts +0 -359
  109. package/src/__tests__/config.test.ts +0 -732
  110. package/src/__tests__/cost-tracker.test.ts +0 -348
  111. package/src/__tests__/db.test.ts +0 -177
  112. package/src/__tests__/dependency-scorer.test.ts +0 -325
  113. package/src/__tests__/docs-integration.test.ts +0 -178
  114. package/src/__tests__/docs-tools.test.ts +0 -199
  115. package/src/__tests__/domains.test.ts +0 -236
  116. package/src/__tests__/hooks.test.ts +0 -221
  117. package/src/__tests__/import-resolver.test.ts +0 -95
  118. package/src/__tests__/integration/path-traversal.test.ts +0 -134
  119. package/src/__tests__/integration/pricing-consistency.test.ts +0 -88
  120. package/src/__tests__/integration/tool-registration.test.ts +0 -146
  121. package/src/__tests__/memory-db.test.ts +0 -404
  122. package/src/__tests__/memory-enhancements.test.ts +0 -316
  123. package/src/__tests__/memory-tools.test.ts +0 -199
  124. package/src/__tests__/middleware-tree.test.ts +0 -177
  125. package/src/__tests__/observability-tools.test.ts +0 -595
  126. package/src/__tests__/observability.test.ts +0 -437
  127. package/src/__tests__/observation-extractor.test.ts +0 -167
  128. package/src/__tests__/page-deps.test.ts +0 -60
  129. package/src/__tests__/prompt-analyzer.test.ts +0 -298
  130. package/src/__tests__/regression-detector.test.ts +0 -295
  131. package/src/__tests__/rules.test.ts +0 -87
  132. package/src/__tests__/schema-mapper.test.ts +0 -29
  133. package/src/__tests__/security-scorer.test.ts +0 -238
  134. package/src/__tests__/security-utils.test.ts +0 -175
  135. package/src/__tests__/sentinel-db.test.ts +0 -491
  136. package/src/__tests__/sentinel-scanner.test.ts +0 -750
  137. package/src/__tests__/sentinel-tools.test.ts +0 -324
  138. package/src/__tests__/sentinel-types.test.ts +0 -750
  139. package/src/__tests__/server.test.ts +0 -452
  140. package/src/__tests__/session-archiver.test.ts +0 -524
  141. package/src/__tests__/session-state-generator.test.ts +0 -900
  142. package/src/__tests__/team-knowledge.test.ts +0 -327
  143. package/src/__tests__/tools.test.ts +0 -340
  144. package/src/__tests__/transcript-parser.test.ts +0 -195
  145. package/src/__tests__/trpc-index.test.ts +0 -25
  146. package/src/__tests__/validate-features-runner.test.ts +0 -517
  147. package/src/__tests__/validation-engine.test.ts +0 -300
  148. package/src/core-tools.ts +0 -685
  149. package/src/memory-queries.ts +0 -804
  150. package/src/memory-schema.ts +0 -546
  151. package/src/tool-helpers.ts +0 -41
@@ -0,0 +1,281 @@
1
+ ---
2
+ name: massu-simplify
3
+ description: Enhanced code simplification with parallel efficiency, reuse, and pattern compliance analysis
4
+ allowed-tools: Bash(*), Read(*), Write(*), Edit(*), Grep(*), Glob(*)
5
+ ---
6
+ name: massu-simplify
7
+
8
+ # Massu Simplify: Enhanced Code Quality Analysis
9
+
10
+ > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9 enforced.
11
+
12
+ ---
13
+
14
+ ## Workflow Position
15
+
16
+ ```
17
+ Code changes → /massu-simplify → /massu-commit → /massu-push
18
+ OR
19
+ /massu-loop → /massu-simplify → /massu-commit → /massu-push
20
+ OR
21
+ /massu-batch → /massu-simplify → /massu-commit → /massu-push
22
+ ```
23
+
24
+ **This command is SUPPLEMENTAL — it runs AFTER implementation, BEFORE commit.**
25
+ **It is NOT a replacement for /massu-verify or /massu-commit. It adds efficiency, reuse, and semantic pattern analysis that those commands don't cover.**
26
+
27
+ ---
28
+
29
+ ## What This Command Catches (That Existing Tools Don't)
30
+
31
+ | Category | Example | Caught By Existing Tools? |
32
+ |----------|---------|--------------------------|
33
+ | Unnecessary async | `async` on functions with no `await` | NO |
34
+ | Redundant type assertions | `as T` when type is already inferred | NO |
35
+ | Code duplication | Inline `parseTier()` when `packages/core/src/` exports it | Partially (pattern-scanner) |
36
+ | Inefficient collections | `Array.find()` in a loop instead of building a Map | NO |
37
+ | Config hardcoding | Literal values instead of `getConfig()` | NO |
38
+ | Missing type exports | Types defined but not exported from barrel | NO |
39
+ | Unnecessary Map/Set | Using Map/Set where a plain object suffices | NO |
40
+ | Dead parameters | Function parameters that are never read | NO |
41
+
42
+ ---
43
+
44
+ ## EXECUTION PROTOCOL
45
+
46
+ ### Step 1: Identify Changed Files
47
+
48
+ ```bash
49
+ # Check for unstaged changes
50
+ git diff --name-only HEAD
51
+
52
+ # Check for staged changes
53
+ git diff --name-only --cached
54
+
55
+ # If no uncommitted changes, check last commit
56
+ git diff --name-only HEAD~1
57
+ ```
58
+
59
+ **If no changes found**: Output "No changes detected. Make code changes first, then run /massu-simplify." and STOP.
60
+
61
+ Filter to only `.ts`, `.tsx`, `.js`, `.jsx` files. Exclude `node_modules/`, `.next/`, `dist/`.
62
+
63
+ ### Step 2: Fast Gate — Pattern Scanner
64
+
65
+ ```bash
66
+ bash scripts/massu-pattern-scanner.sh
67
+ ```
68
+
69
+ If violations found: **Fix them ALL before proceeding.** Pattern scanner violations are syntactic anti-patterns that should be resolved before semantic analysis begins.
70
+
71
+ ### Step 3: Parallel Review Phase (Principle #20 — One Task Per Agent)
72
+
73
+ Spawn 3 review agents **IN PARALLEL**. Each gets the list of changed files and a focused concern.
74
+
75
+ ```
76
+ CHANGED_FILES = [list from Step 1]
77
+
78
+ efficiency_result = Agent(subagent_type="general-purpose", model="haiku", prompt="
79
+ You are an EFFICIENCY REVIEWER for the Massu codebase (npm package).
80
+
81
+ Review ONLY these changed files: {CHANGED_FILES}
82
+
83
+ Check for these specific inefficiency patterns:
84
+
85
+ 1. UNNECESSARY ASYNC/AWAIT
86
+ - async functions with no await (should be synchronous)
87
+ - await on non-Promise values
88
+ - Unnecessary Promise.resolve() wrapping synchronous values
89
+ - Sequential awaits that could be Promise.all()
90
+
91
+ 2. REDUNDANT TYPE ASSERTIONS
92
+ - `as T` when TypeScript already infers the correct type
93
+ - Double assertions (`as unknown as T`) that indicate a design problem
94
+ - Non-null assertions (`!`) on values that are already narrowed
95
+ - Type assertions that could be replaced with type guards
96
+
97
+ 3. ALGORITHMIC INEFFICIENCY
98
+ - O(n^2) patterns (nested loops, repeated .find() in .map())
99
+ - Repeated string concatenation in loops (use array + join)
100
+ - Sorting or filtering the same array multiple times
101
+ - Using Array.find() in a loop instead of building a Map/Set lookup
102
+
103
+ 4. INEFFICIENT MAP/SET USAGE
104
+ - Map<string, T> where a plain Record<string, T> suffices
105
+ - Creating a Map/Set for single-use lookups
106
+ - Not using Map when doing repeated key lookups on arrays
107
+
108
+ 5. GENERAL INEFFICIENCY
109
+ - Loading full objects when only a subset of fields is needed
110
+ - Repeated computation that could be cached in a local variable
111
+ - Unnecessary spread/destructure creating shallow copies for no reason
112
+
113
+ For each finding, return:
114
+ FILE: [path]
115
+ LINE: [number]
116
+ SEVERITY: CRITICAL | HIGH | MEDIUM | LOW
117
+ PATTERN: [which pattern from above]
118
+ CURRENT: [the inefficient code]
119
+ SUGGESTED: [the efficient replacement]
120
+
121
+ If no findings: return EFFICIENCY_FINDINGS: 0
122
+ Otherwise: return EFFICIENCY_FINDINGS: [count]
123
+ ")
124
+
125
+ reuse_result = Agent(subagent_type="general-purpose", model="haiku", prompt="
126
+ You are a REUSE REVIEWER for the Massu codebase (npm package).
127
+
128
+ Review ONLY these changed files: {CHANGED_FILES}
129
+
130
+ Search the codebase for existing utilities that the changed code should use instead of inline implementations. Check for:
131
+
132
+ 1. KNOWN UTILITIES (check if changed code duplicates these)
133
+ - getConfig() → for config-driven values (never hardcode)
134
+ - parseTier() → for tier string parsing
135
+ - formatDuration() → for time/duration formatting
136
+ - validateSchema() → for schema validation
137
+
138
+ 2. COMPONENT DUPLICATION
139
+ - Search packages/core/src/ for existing modules
140
+ that do the same thing as newly created modules
141
+ - Check if a new utility duplicates an existing pattern
142
+
143
+ 3. PATTERN DUPLICATION
144
+ - Same data transformation pattern written in multiple new files
145
+ - Same validation logic duplicated
146
+ - Same error handling pattern repeated
147
+ - Same config access pattern inlined instead of using getConfig()
148
+
149
+ For each finding, return:
150
+ FILE: [path]
151
+ LINE: [number]
152
+ SEVERITY: HIGH | MEDIUM | LOW
153
+ EXISTING_UTILITY: [import path and function name]
154
+ CURRENT: [the duplicated code]
155
+ SUGGESTED: [how to use the existing utility instead]
156
+
157
+ If no findings: return REUSE_FINDINGS: 0
158
+ Otherwise: return REUSE_FINDINGS: [count]
159
+ ")
160
+
161
+ pattern_result = Agent(subagent_type="general-purpose", model="haiku", prompt="
162
+ You are a PATTERN COMPLIANCE REVIEWER for the Massu codebase (npm package).
163
+
164
+ Review ONLY these changed files: {CHANGED_FILES}
165
+
166
+ Check for SEMANTIC pattern violations that the pattern-scanner (grep-based) cannot catch:
167
+
168
+ 1. ESM IMPORT COMPLIANCE
169
+ - Using require() instead of ESM import (except in config files)
170
+ - Missing file extensions in relative imports where required
171
+ - Default exports where named exports should be used
172
+ - Circular import chains between modules
173
+
174
+ 2. CONFIG-DRIVEN PATTERN VIOLATIONS
175
+ - Hardcoded values that should come from getConfig()
176
+ - Magic numbers/strings without named constants
177
+ - Environment-specific logic not gated by config
178
+ - Missing fallback defaults for config lookups
179
+
180
+ 3. TYPESCRIPT STRICT MODE VIOLATIONS
181
+ - Implicit any types (missing type annotations on public APIs)
182
+ - Using any when a proper type exists
183
+ - Missing return type annotations on exported functions
184
+ - Non-exhaustive switch/case on union types (missing default or case)
185
+
186
+ 4. TYPE EXPORT PATTERN VIOLATIONS
187
+ - Types defined in a module but not exported from barrel index
188
+ - Re-exporting types without using `export type` (isolatedModules)
189
+ - Internal types leaked through public API surface
190
+ - Missing JSDoc on exported types/interfaces
191
+
192
+ 5. SECURITY PATTERN VIOLATIONS
193
+ - Unsanitized user input passed to dangerous operations
194
+ - Missing input validation on public-facing functions
195
+ - Secrets or credentials hardcoded in source
196
+
197
+ 6. ARCHITECTURAL VIOLATIONS
198
+ - Cross-package imports bypassing barrel exports
199
+ - Tight coupling between modules that should be independent
200
+ - Side effects in module-level scope (top-level await, global mutations)
201
+
202
+ For each finding, return:
203
+ FILE: [path]
204
+ LINE: [number]
205
+ SEVERITY: CRITICAL | HIGH | MEDIUM | LOW
206
+ RULE: [CR-XX or pattern name]
207
+ CURRENT: [the violating code]
208
+ SUGGESTED: [the compliant code]
209
+
210
+ If no findings: return PATTERN_FINDINGS: 0
211
+ Otherwise: return PATTERN_FINDINGS: [count]
212
+ ")
213
+ ```
214
+
215
+ ### Step 4: Collect and Apply
216
+
217
+ 1. Parse all 3 agent results
218
+ 2. Combine findings into a single list, sorted by SEVERITY (CRITICAL first)
219
+ 3. Apply ALL fixes:
220
+ - CRITICAL and HIGH: Fix immediately
221
+ - MEDIUM: Fix immediately
222
+ - LOW: Fix immediately (CR-9: fix ALL issues encountered)
223
+ 4. Show each fix applied with before/after
224
+
225
+ ### Step 5: Re-verify
226
+
227
+ ```bash
228
+ bash scripts/massu-pattern-scanner.sh
229
+ ```
230
+
231
+ Confirm no new violations were introduced by the fixes.
232
+
233
+ ### Step 6: Output Structured Result
234
+
235
+ ```markdown
236
+ ## /massu-simplify Results
237
+
238
+ **Files analyzed**: N
239
+ **Time**: Xs
240
+
241
+ | Dimension | Findings | Fixed | Remaining |
242
+ |-----------|----------|-------|-----------|
243
+ | Efficiency | N | N | 0 |
244
+ | Reuse | N | N | 0 |
245
+ | Pattern Compliance | N | N | 0 |
246
+ | Pattern Scanner | N | N | 0 |
247
+ | **Total** | **N** | **N** | **0** |
248
+
249
+ SIMPLIFY_GATE: PASS
250
+
251
+ ### Changes Applied
252
+ - [file:line] — [description of fix]
253
+ - [file:line] — [description of fix]
254
+ ...
255
+
256
+ ### Next Steps
257
+ Run /massu-commit to commit verified code.
258
+ ```
259
+
260
+ If any findings could NOT be fixed automatically:
261
+
262
+ ```
263
+ SIMPLIFY_GATE: FAIL — N issues require manual resolution
264
+
265
+ ### Manual Resolution Needed
266
+ - [file:line] — [why it couldn't be auto-fixed]
267
+ ```
268
+
269
+ ---
270
+
271
+ ## RELATIONSHIP WITH OTHER COMMANDS
272
+
273
+ | Command | When | What |
274
+ |---------|------|------|
275
+ | `/massu-simplify` | After code changes, before commit | Efficiency + reuse + semantic patterns |
276
+ | `/massu-verify` | During /massu-loop audit phase | Full VR-* verification with plan coverage |
277
+ | `/massu-commit` | Before committing | Fast blocking gates (types, build, scanner) |
278
+ | `/massu-push` | Before pushing | Full tests + regression |
279
+ | `massu-pattern-scanner.sh` | Auto-runs in /massu-commit | Syntactic anti-pattern grep |
280
+
281
+ **Key distinction**: `/massu-simplify` catches SEMANTIC issues (inefficient algorithms, missed reuse opportunities, architectural anti-patterns) while `massu-pattern-scanner.sh` catches SYNTACTIC issues (forbidden imports, known bad patterns, deprecated APIs).
@@ -0,0 +1,278 @@
1
+ ---
2
+ name: massu-status
3
+ description: Read-only project health dashboard with 14 health checks
4
+ allowed-tools: Bash(*), Read(*), Grep(*), Glob(*)
5
+ ---
6
+ name: massu-status
7
+
8
+ > **Shared rules apply.** Read `.claude/commands/_shared-preamble.md` before proceeding. CR-9, CR-35 enforced.
9
+
10
+ # CS Status: Project Health Dashboard
11
+
12
+ ## Objective
13
+
14
+ Provide a comprehensive READ-ONLY snapshot of the project's health across all dimensions. No files are modified. This is purely diagnostic.
15
+
16
+ ---
17
+
18
+ ## NON-NEGOTIABLE RULES
19
+
20
+ - Do NOT modify any files
21
+ - Do NOT fix any issues found
22
+ - Report ALL findings with clear status indicators
23
+ - Run ALL checks even if early ones fail
24
+
25
+ ---
26
+
27
+ ## HEALTH CHECKS
28
+
29
+ ### 1. Test Suite Health
30
+
31
+ ```bash
32
+ npm test 2>&1
33
+ ```
34
+
35
+ | Metric | Value | Status |
36
+ |--------|-------|--------|
37
+ | Total tests | [N] | - |
38
+ | Passing | [N] | PASS/FAIL |
39
+ | Failing | [N] | - |
40
+ | Skipped | [N] | - |
41
+
42
+ ### 2. Type Safety
43
+
44
+ ```bash
45
+ cd packages/core && npx tsc --noEmit 2>&1
46
+ ```
47
+
48
+ | Metric | Value | Status |
49
+ |--------|-------|--------|
50
+ | Type errors | [N] | PASS/FAIL |
51
+
52
+ ### 3. Hook Compilation
53
+
54
+ ```bash
55
+ cd packages/core && npm run build:hooks 2>&1
56
+ ```
57
+
58
+ | Metric | Value | Status |
59
+ |--------|-------|--------|
60
+ | Hook build | Exit [N] | PASS/FAIL |
61
+ | Hooks compiled | [N] | - |
62
+
63
+ ### 4. Pattern Scanner
64
+
65
+ ```bash
66
+ bash scripts/massu-pattern-scanner.sh 2>&1
67
+ ```
68
+
69
+ | Metric | Value | Status |
70
+ |--------|-------|--------|
71
+ | Violations | [N] | PASS/FAIL |
72
+
73
+ ### 5. Dependency Health
74
+
75
+ ```bash
76
+ npm audit --audit-level=high 2>&1 || true
77
+ npm outdated 2>&1 || true
78
+ ```
79
+
80
+ | Metric | Value | Status |
81
+ |--------|-------|--------|
82
+ | High/Critical vulns | [N] | PASS/FAIL |
83
+ | Outdated packages | [N] | INFO |
84
+
85
+ ### 6. Git State
86
+
87
+ ```bash
88
+ git status --short
89
+ git log -5 --oneline
90
+ git branch -v
91
+ ```
92
+
93
+ | Metric | Value |
94
+ |--------|-------|
95
+ | Branch | [name] |
96
+ | Clean working tree | YES/NO |
97
+ | Uncommitted changes | [N] files |
98
+ | Last commit | [hash] [message] |
99
+ | Ahead/behind origin | [N]/[N] |
100
+
101
+ ### 7. Tool Inventory
102
+
103
+ ```bash
104
+ # Count registered tools
105
+ grep -c "name:" packages/core/src/tools.ts
106
+
107
+ # Count tool modules (3-function pattern)
108
+ grep -c "isTool\b" packages/core/src/tools.ts
109
+
110
+ # Count tool modules (legacy pattern)
111
+ grep -c "startsWith" packages/core/src/tools.ts
112
+ ```
113
+
114
+ | Metric | Value |
115
+ |--------|-------|
116
+ | Total MCP tools | [N] |
117
+ | Tool modules (3-func) | [N] |
118
+ | Tool modules (legacy) | [N] |
119
+
120
+ ### 8. Code Metrics
121
+
122
+ ```bash
123
+ # Source line counts
124
+ find packages/core/src -name "*.ts" -not -path "*/__tests__/*" -not -path "*/node_modules/*" | xargs wc -l | tail -1
125
+ find packages/core/src/__tests__ -name "*.test.ts" | xargs wc -l | tail -1
126
+
127
+ # File counts
128
+ find packages/core/src -name "*.ts" -not -path "*/__tests__/*" -not -path "*/node_modules/*" | wc -l
129
+ find packages/core/src/__tests__ -name "*.test.ts" | wc -l
130
+ ```
131
+
132
+ | Metric | Value |
133
+ |--------|-------|
134
+ | Source files | [N] |
135
+ | Source LOC | [N] |
136
+ | Test files | [N] |
137
+ | Test LOC | [N] |
138
+ | Test:Source ratio | [X]:1 |
139
+
140
+ ### 9. Website Health (if website/ exists)
141
+
142
+ ```bash
143
+ if [ -d "website" ]; then
144
+ cd website && npx tsc --noEmit 2>&1 | tail -5
145
+ echo "---"
146
+ ls -la src/app/ 2>/dev/null | wc -l
147
+ fi
148
+ ```
149
+
150
+ | Metric | Value | Status |
151
+ |--------|-------|--------|
152
+ | Website type check | [N] errors | PASS/FAIL/N/A |
153
+ | Website pages | [N] | - |
154
+
155
+ ### 10. Test Coverage Gaps
156
+
157
+ ```bash
158
+ # List source modules without test files
159
+ for f in packages/core/src/*.ts; do
160
+ base=$(basename "$f" .ts)
161
+ test_file="packages/core/src/__tests__/${base}.test.ts"
162
+ if [ ! -f "$test_file" ]; then
163
+ echo "MISSING: $base"
164
+ fi
165
+ done
166
+ ```
167
+
168
+ | Metric | Value | Status |
169
+ |--------|-------|--------|
170
+ | Modules with tests | [N] | - |
171
+ | Modules without tests | [N] | - |
172
+ | Coverage percentage | [N]% | PASS (>=80%) / WARN (50-79%) / FAIL (<50%) |
173
+
174
+ ### 11. Bundle Size (if website/ exists)
175
+
176
+ ```bash
177
+ if [ -d "website/.next" ]; then
178
+ cd website && npx next build 2>&1 | grep "Route"
179
+ fi
180
+ ```
181
+
182
+ | Metric | Value | Status |
183
+ |--------|-------|--------|
184
+ | Routes < 150KB | [N] | - |
185
+ | Routes 150-250KB | [N] | WARN |
186
+ | Routes > 250KB | [N] | FAIL |
187
+ | Status | - | PASS/WARN/FAIL |
188
+
189
+ ### 12. Migration Health (if website/supabase/migrations/ exists)
190
+
191
+ ```bash
192
+ if [ -d "website/supabase/migrations" ]; then
193
+ ls website/supabase/migrations/*.sql 2>/dev/null | wc -l
194
+ # Check sequential numbering
195
+ # Check RLS coverage for each CREATE TABLE
196
+ fi
197
+ ```
198
+
199
+ | Metric | Value | Status |
200
+ |--------|-------|--------|
201
+ | Total migrations | [N] | - |
202
+ | Sequential numbering | YES/NO | PASS/FAIL |
203
+ | Tables with RLS | [N]/[N] | - |
204
+ | RLS coverage | [N]% | PASS (100%) / FAIL (<100%) |
205
+
206
+ ### 13. API Endpoint Inventory (if website/src/app/api/ exists)
207
+
208
+ ```bash
209
+ if [ -d "website/src/app/api" ]; then
210
+ find website/src/app/api -name "route.ts" | while read f; do
211
+ has_auth=$(grep -l 'createServerSupabaseClient\|authenticateApiKey' "$f" 2>/dev/null)
212
+ if [ -z "$has_auth" ]; then
213
+ echo "NO AUTH: $f"
214
+ fi
215
+ done
216
+ fi
217
+ ```
218
+
219
+ | Metric | Value | Status |
220
+ |--------|-------|--------|
221
+ | Total API endpoints | [N] | - |
222
+ | Endpoints with auth | [N] | - |
223
+ | Auth coverage | [N]% | PASS (100%) / WARN (>=80%) / FAIL (<80%) |
224
+
225
+ ### 14. Edge Function Inventory (if website/supabase/functions/ exists)
226
+
227
+ ```bash
228
+ if [ -d "website/supabase/functions" ]; then
229
+ for d in website/supabase/functions/*/; do
230
+ name=$(basename "$d")
231
+ size=$(wc -c < "$d/index.ts" 2>/dev/null || echo "N/A")
232
+ echo "$name: $size bytes"
233
+ done
234
+ fi
235
+ ```
236
+
237
+ | Metric | Value | Status |
238
+ |--------|-------|--------|
239
+ | Total edge functions | [N] | INFO |
240
+ | Largest function size | [N] bytes | INFO |
241
+
242
+ ---
243
+
244
+ ## HEALTH SUMMARY
245
+
246
+ ```markdown
247
+ ## PROJECT HEALTH DASHBOARD
248
+
249
+ ### Overall Status: HEALTHY / DEGRADED / UNHEALTHY
250
+
251
+ | # | Dimension | Status | Details |
252
+ |---|-----------|--------|---------|
253
+ | 1 | Tests | PASS/FAIL | [N]/[N] passing |
254
+ | 2 | Types | PASS/FAIL | [N] errors |
255
+ | 3 | Hooks | PASS/FAIL | [N] compiled |
256
+ | 4 | Patterns | PASS/FAIL | [N] violations |
257
+ | 5 | Security | PASS/FAIL | [N] high/critical vulns |
258
+ | 6 | Git | CLEAN/DIRTY | [details] |
259
+ | 7 | Tool Inventory | INFO | [N] tools |
260
+ | 8 | Code Metrics | INFO | [N] LOC |
261
+ | 9 | Website | PASS/FAIL/N/A | [N] errors |
262
+ | 10 | Test Coverage | PASS/WARN/FAIL | [N]% modules covered |
263
+ | 11 | Bundle Size | PASS/WARN/FAIL/N/A | [N] routes over threshold |
264
+ | 12 | Migration Health | PASS/FAIL/N/A | [N]% RLS coverage |
265
+ | 13 | API Endpoints | PASS/WARN/FAIL/N/A | [N]% auth coverage |
266
+ | 14 | Edge Functions | INFO/N/A | [N] functions |
267
+
268
+ ### Classification
269
+ - **HEALTHY**: All checks pass, clean git state
270
+ - **DEGRADED**: Minor issues (outdated deps, warnings)
271
+ - **UNHEALTHY**: Failing tests, type errors, or security vulns
272
+
273
+ ### Quick Fix Commands (if degraded/unhealthy)
274
+ - Tests failing: `npm test` to see failures, then fix
275
+ - Type errors: `cd packages/core && npx tsc --noEmit` for details
276
+ - Pattern violations: `bash scripts/massu-pattern-scanner.sh` for details
277
+ - Vulnerabilities: `npm audit` for details, `/massu-audit-deps` for full audit
278
+ ```