@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
@@ -1,359 +0,0 @@
1
- // Copyright (c) 2026 Massu. All rights reserved.
2
- // Licensed under BSL 1.1 - see LICENSE file for details.
3
-
4
- import { describe, it, expect, beforeEach, afterEach } from 'vitest';
5
- import { writeFileSync, mkdirSync, rmSync, existsSync } from 'fs';
6
- import { resolve } from 'path';
7
- import { getConfig, resetConfig } from '../config.ts';
8
-
9
- /**
10
- * PP0-003: Config parsing tests for new analytics, governance,
11
- * security, team, and regression sections.
12
- */
13
-
14
- const TEST_DIR = resolve(__dirname, '../test-config-tmp');
15
- const CONFIG_PATH = resolve(TEST_DIR, 'massu.config.yaml');
16
-
17
- function writeConfig(yaml: string) {
18
- if (!existsSync(TEST_DIR)) mkdirSync(TEST_DIR, { recursive: true });
19
- writeFileSync(CONFIG_PATH, yaml, 'utf-8');
20
- }
21
-
22
- describe('Config Section Parsing', () => {
23
- const originalCwd = process.cwd();
24
-
25
- beforeEach(() => {
26
- resetConfig();
27
- if (!existsSync(TEST_DIR)) mkdirSync(TEST_DIR, { recursive: true });
28
- process.chdir(TEST_DIR);
29
- });
30
-
31
- afterEach(() => {
32
- process.chdir(originalCwd);
33
- resetConfig();
34
- if (existsSync(TEST_DIR)) rmSync(TEST_DIR, { recursive: true, force: true });
35
- });
36
-
37
- describe('Minimal config (no optional sections)', () => {
38
- it('returns undefined for all optional sections when absent', () => {
39
- writeConfig(`
40
- project:
41
- name: test-project
42
- toolPrefix: tp
43
- `);
44
- const config = getConfig();
45
- expect(config.project.name).toBe('test-project');
46
- expect(config.toolPrefix).toBe('tp');
47
- expect(config.analytics).toBeUndefined();
48
- expect(config.governance).toBeUndefined();
49
- expect(config.security).toBeUndefined();
50
- expect(config.team).toBeUndefined();
51
- expect(config.regression).toBeUndefined();
52
- });
53
- });
54
-
55
- describe('Analytics config', () => {
56
- it('parses quality weights', () => {
57
- writeConfig(`
58
- project:
59
- name: test
60
- analytics:
61
- quality:
62
- weights:
63
- bug_found: -10
64
- clean_commit: 8
65
- categories:
66
- - security
67
- - tests
68
- `);
69
- const config = getConfig();
70
- expect(config.analytics).toBeDefined();
71
- expect(config.analytics!.quality!.weights!.bug_found).toBe(-10);
72
- expect(config.analytics!.quality!.weights!.clean_commit).toBe(8);
73
- expect(config.analytics!.quality!.categories).toEqual(['security', 'tests']);
74
- });
75
-
76
- it('parses cost model pricing', () => {
77
- writeConfig(`
78
- project:
79
- name: test
80
- analytics:
81
- cost:
82
- models:
83
- gpt-4:
84
- input_per_million: 30
85
- output_per_million: 60
86
- currency: EUR
87
- `);
88
- const config = getConfig();
89
- expect(config.analytics!.cost!.models!['gpt-4'].input_per_million).toBe(30);
90
- expect(config.analytics!.cost!.currency).toBe('EUR');
91
- });
92
-
93
- it('parses prompt effectiveness indicators', () => {
94
- writeConfig(`
95
- project:
96
- name: test
97
- analytics:
98
- prompts:
99
- success_indicators:
100
- - approved
101
- - merged
102
- failure_indicators:
103
- - revert
104
- max_turns_for_success: 3
105
- `);
106
- const config = getConfig();
107
- expect(config.analytics!.prompts!.success_indicators).toEqual(['approved', 'merged']);
108
- expect(config.analytics!.prompts!.failure_indicators).toEqual(['revert']);
109
- expect(config.analytics!.prompts!.max_turns_for_success).toBe(3);
110
- });
111
- });
112
-
113
- describe('Governance config', () => {
114
- it('parses audit settings', () => {
115
- writeConfig(`
116
- project:
117
- name: test
118
- governance:
119
- audit:
120
- formats:
121
- - summary
122
- - soc2
123
- retention_days: 730
124
- auto_log:
125
- code_changes: true
126
- approvals: false
127
- `);
128
- const config = getConfig();
129
- expect(config.governance!.audit!.formats).toEqual(['summary', 'soc2']);
130
- expect(config.governance!.audit!.retention_days).toBe(730);
131
- expect(config.governance!.audit!.auto_log!.approvals).toBe(false);
132
- });
133
-
134
- it('parses validation checks', () => {
135
- writeConfig(`
136
- project:
137
- name: test
138
- governance:
139
- validation:
140
- realtime: false
141
- checks:
142
- rule_compliance: true
143
- import_existence: false
144
- custom_patterns:
145
- - pattern: 'console\\.log'
146
- severity: warning
147
- message: Remove console.log
148
- `);
149
- const config = getConfig();
150
- expect(config.governance!.validation!.realtime).toBe(false);
151
- expect(config.governance!.validation!.checks!.import_existence).toBe(false);
152
- expect(config.governance!.validation!.custom_patterns!.length).toBe(1);
153
- expect(config.governance!.validation!.custom_patterns![0].pattern).toBe('console\\.log');
154
- });
155
-
156
- it('parses ADR detection phrases', () => {
157
- writeConfig(`
158
- project:
159
- name: test
160
- governance:
161
- adr:
162
- detection_phrases:
163
- - chose
164
- - decided
165
- - opted for
166
- storage: filesystem
167
- output_dir: docs/decisions
168
- `);
169
- const config = getConfig();
170
- expect(config.governance!.adr!.detection_phrases).toContain('opted for');
171
- expect(config.governance!.adr!.storage).toBe('filesystem');
172
- expect(config.governance!.adr!.output_dir).toBe('docs/decisions');
173
- });
174
- });
175
-
176
- describe('Security config', () => {
177
- it('parses severity weights', () => {
178
- writeConfig(`
179
- project:
180
- name: test
181
- security:
182
- severity_weights:
183
- critical: 30
184
- high: 20
185
- medium: 10
186
- low: 5
187
- `);
188
- const config = getConfig();
189
- expect(config.security!.severity_weights!.critical).toBe(30);
190
- expect(config.security!.severity_weights!.low).toBe(5);
191
- });
192
-
193
- it('parses restrictive licenses', () => {
194
- writeConfig(`
195
- project:
196
- name: test
197
- security:
198
- restrictive_licenses:
199
- - GPL
200
- - AGPL
201
- - SSPL
202
- - EUPL
203
- `);
204
- const config = getConfig();
205
- expect(config.security!.restrictive_licenses).toContain('EUPL');
206
- expect(config.security!.restrictive_licenses!.length).toBe(4);
207
- });
208
-
209
- it('parses dependency alternatives', () => {
210
- writeConfig(`
211
- project:
212
- name: test
213
- security:
214
- dep_alternatives:
215
- moment:
216
- - date-fns
217
- - dayjs
218
- lodash:
219
- - radash
220
- `);
221
- const config = getConfig();
222
- expect(config.security!.dep_alternatives!.moment).toEqual(['date-fns', 'dayjs']);
223
- expect(config.security!.dep_alternatives!.lodash).toEqual(['radash']);
224
- });
225
-
226
- it('parses dependency management', () => {
227
- writeConfig(`
228
- project:
229
- name: test
230
- security:
231
- auto_score_on_edit: false
232
- score_threshold_alert: 75
233
- dependencies:
234
- package_manager: pnpm
235
- blocked_packages:
236
- - event-stream
237
- max_bundle_size_kb: 200
238
- `);
239
- const config = getConfig();
240
- expect(config.security!.auto_score_on_edit).toBe(false);
241
- expect(config.security!.score_threshold_alert).toBe(75);
242
- expect(config.security!.dependencies!.package_manager).toBe('pnpm');
243
- expect(config.security!.dependencies!.blocked_packages).toEqual(['event-stream']);
244
- });
245
- });
246
-
247
- describe('Team config', () => {
248
- it('parses team settings with expertise weights', () => {
249
- writeConfig(`
250
- project:
251
- name: test
252
- team:
253
- enabled: true
254
- sync_backend: supabase
255
- developer_id: dev-123
256
- share_by_default: true
257
- expertise_weights:
258
- session: 30
259
- observation: 15
260
- privacy:
261
- share_file_paths: true
262
- share_code_snippets: true
263
- share_observations: false
264
- `);
265
- const config = getConfig();
266
- expect(config.team!.enabled).toBe(true);
267
- expect(config.team!.sync_backend).toBe('supabase');
268
- expect(config.team!.developer_id).toBe('dev-123');
269
- expect(config.team!.expertise_weights!.session).toBe(30);
270
- expect(config.team!.expertise_weights!.observation).toBe(15);
271
- expect(config.team!.privacy!.share_code_snippets).toBe(true);
272
- expect(config.team!.privacy!.share_observations).toBe(false);
273
- });
274
-
275
- it('returns defaults for minimal team config', () => {
276
- writeConfig(`
277
- project:
278
- name: test
279
- team:
280
- enabled: true
281
- `);
282
- const config = getConfig();
283
- expect(config.team!.enabled).toBe(true);
284
- expect(config.team!.sync_backend).toBe('local');
285
- expect(config.team!.developer_id).toBe('auto');
286
- expect(config.team!.share_by_default).toBe(false);
287
- expect(config.team!.expertise_weights).toBeUndefined();
288
- expect(config.team!.privacy).toBeUndefined();
289
- });
290
- });
291
-
292
- describe('Regression config', () => {
293
- it('parses health thresholds', () => {
294
- writeConfig(`
295
- project:
296
- name: test
297
- regression:
298
- test_runner: vitest
299
- test_patterns:
300
- - "**/*.test.ts"
301
- health_thresholds:
302
- healthy: 90
303
- warning: 60
304
- `);
305
- const config = getConfig();
306
- expect(config.regression!.test_runner).toBe('vitest');
307
- expect(config.regression!.test_patterns).toEqual(['**/*.test.ts']);
308
- expect(config.regression!.health_thresholds!.healthy).toBe(90);
309
- expect(config.regression!.health_thresholds!.warning).toBe(60);
310
- });
311
-
312
- it('returns defaults for minimal regression config', () => {
313
- writeConfig(`
314
- project:
315
- name: test
316
- regression:
317
- test_runner: jest
318
- `);
319
- const config = getConfig();
320
- expect(config.regression!.test_runner).toBe('jest');
321
- expect(config.regression!.test_patterns).toBeDefined();
322
- expect(config.regression!.test_patterns!.length).toBeGreaterThan(0);
323
- expect(config.regression!.health_thresholds).toBeUndefined();
324
- });
325
- });
326
-
327
- describe('Full config (all sections)', () => {
328
- it('parses complete config with all optional sections', () => {
329
- writeConfig(`
330
- project:
331
- name: full-test
332
- toolPrefix: ft
333
- analytics:
334
- quality:
335
- weights:
336
- bug: -5
337
- governance:
338
- audit:
339
- formats:
340
- - summary
341
- security:
342
- severity_weights:
343
- critical: 25
344
- team:
345
- enabled: true
346
- regression:
347
- test_runner: npm test
348
- `);
349
- const config = getConfig();
350
- expect(config.project.name).toBe('full-test');
351
- expect(config.toolPrefix).toBe('ft');
352
- expect(config.analytics).toBeDefined();
353
- expect(config.governance).toBeDefined();
354
- expect(config.security).toBeDefined();
355
- expect(config.team).toBeDefined();
356
- expect(config.regression).toBeDefined();
357
- });
358
- });
359
- });