@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,195 +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, afterEach } from 'vitest';
5
- import { writeFileSync, unlinkSync, existsSync } from 'fs';
6
- import { resolve } from 'path';
7
- import {
8
- parseTranscript,
9
- extractUserMessages,
10
- extractAssistantMessages,
11
- extractToolCalls,
12
- extractFileOperations,
13
- extractVerificationCommands,
14
- extractDecisions,
15
- extractFailedAttempts,
16
- estimateTokens,
17
- getLastAssistantMessage,
18
- } from '../transcript-parser.ts';
19
-
20
- // P7-002: Transcript Parser Tests
21
-
22
- const TEST_JSONL = resolve(__dirname, '../test-transcript.jsonl');
23
-
24
- function writeTestTranscript(entries: Record<string, unknown>[]): void {
25
- const content = entries.map(e => JSON.stringify(e)).join('\n');
26
- writeFileSync(TEST_JSONL, content, 'utf-8');
27
- }
28
-
29
- function cleanup(): void {
30
- if (existsSync(TEST_JSONL)) unlinkSync(TEST_JSONL);
31
- }
32
-
33
- describe('Transcript Parser', () => {
34
- afterEach(cleanup);
35
-
36
- describe('parseTranscript', () => {
37
- it('parses JSONL entries', async () => {
38
- writeTestTranscript([
39
- { type: 'user', sessionId: 'sess-1', message: { role: 'user', content: [{ type: 'text', text: 'Hello' }] } },
40
- { type: 'assistant', sessionId: 'sess-1', message: { role: 'assistant', content: [{ type: 'text', text: 'Hi there' }] } },
41
- ]);
42
-
43
- const entries = await parseTranscript(TEST_JSONL);
44
- expect(entries.length).toBe(2);
45
- expect(entries[0].type).toBe('user');
46
- expect(entries[1].type).toBe('assistant');
47
- });
48
-
49
- it('handles malformed lines gracefully', async () => {
50
- writeFileSync(TEST_JSONL, '{"type":"user","message":{"role":"user","content":[{"type":"text","text":"valid"}]}}\n{invalid json\n', 'utf-8');
51
- const entries = await parseTranscript(TEST_JSONL);
52
- expect(entries.length).toBe(1);
53
- });
54
-
55
- it('handles file-history-snapshot entries', async () => {
56
- writeTestTranscript([
57
- { type: 'file-history-snapshot', snapshot: {} },
58
- { type: 'user', message: { role: 'user', content: [{ type: 'text', text: 'Hello' }] } },
59
- ]);
60
- const entries = await parseTranscript(TEST_JSONL);
61
- expect(entries.length).toBe(2);
62
- expect(entries[0].type).toBe('file-history-snapshot');
63
- });
64
- });
65
-
66
- describe('extractUserMessages', () => {
67
- it('extracts user messages, skipping meta', async () => {
68
- writeTestTranscript([
69
- { type: 'user', isMeta: true, message: { role: 'user', content: [{ type: 'text', text: 'meta msg' }] } },
70
- { type: 'user', message: { role: 'user', content: [{ type: 'text', text: 'real message' }] } },
71
- ]);
72
- const entries = await parseTranscript(TEST_JSONL);
73
- const messages = extractUserMessages(entries);
74
- expect(messages.length).toBe(1);
75
- expect(messages[0].text).toBe('real message');
76
- });
77
- });
78
-
79
- describe('extractToolCalls', () => {
80
- it('extracts tool_use and tool_result', async () => {
81
- writeTestTranscript([
82
- {
83
- type: 'assistant',
84
- message: {
85
- role: 'assistant',
86
- content: [
87
- { type: 'tool_use', id: 'tool-1', name: 'Bash', input: { command: 'npm test' } },
88
- ],
89
- },
90
- },
91
- {
92
- type: 'user',
93
- message: {
94
- role: 'user',
95
- content: [
96
- { type: 'tool_result', tool_use_id: 'tool-1', content: 'All tests passed', is_error: false },
97
- ],
98
- },
99
- },
100
- ]);
101
- const entries = await parseTranscript(TEST_JSONL);
102
- const toolCalls = extractToolCalls(entries);
103
- expect(toolCalls.length).toBe(1);
104
- expect(toolCalls[0].toolName).toBe('Bash');
105
- expect(toolCalls[0].result).toBe('All tests passed');
106
- expect(toolCalls[0].isError).toBe(false);
107
- });
108
- });
109
-
110
- describe('extractFileOperations', () => {
111
- it('extracts file operations from tool calls', () => {
112
- const ops = extractFileOperations([
113
- { toolName: 'Read', toolUseId: '1', input: { file_path: '/path/file.ts' } },
114
- { toolName: 'Write', toolUseId: '2', input: { file_path: '/path/new.ts' } },
115
- { toolName: 'Edit', toolUseId: '3', input: { file_path: '/path/edit.ts' } },
116
- { toolName: 'Glob', toolUseId: '4', input: { pattern: '**/*.ts' } },
117
- ]);
118
- expect(ops.length).toBe(4);
119
- expect(ops[0].type).toBe('read');
120
- expect(ops[1].type).toBe('write');
121
- expect(ops[2].type).toBe('edit');
122
- expect(ops[3].type).toBe('glob');
123
- });
124
- });
125
-
126
- describe('extractVerificationCommands', () => {
127
- it('detects verification commands', () => {
128
- const verifications = extractVerificationCommands([
129
- { toolName: 'Bash', toolUseId: '1', input: { command: 'npm run build' }, result: 'Build succeeded' },
130
- { toolName: 'Bash', toolUseId: '2', input: { command: 'npm test' }, result: 'All passed', isError: false },
131
- { toolName: 'Bash', toolUseId: '3', input: { command: './scripts/pattern-scanner.sh' }, result: 'PASS' },
132
- ]);
133
- expect(verifications.length).toBe(3);
134
- expect(verifications[0].vrType).toBe('VR-BUILD');
135
- expect(verifications[0].passed).toBe(true);
136
- expect(verifications[1].vrType).toBe('VR-TEST');
137
- expect(verifications[2].vrType).toBe('VR-PATTERN');
138
- });
139
- });
140
-
141
- describe('extractDecisions', () => {
142
- it('extracts decision-like text', async () => {
143
- writeTestTranscript([
144
- {
145
- type: 'assistant',
146
- message: {
147
- role: 'assistant',
148
- content: [{ type: 'text', text: 'I decided to use esbuild instead of tsc for better performance.' }],
149
- },
150
- },
151
- ]);
152
- const entries = await parseTranscript(TEST_JSONL);
153
- const decisions = extractDecisions(entries);
154
- expect(decisions.length).toBeGreaterThan(0);
155
- expect(decisions[0].text).toContain('decided');
156
- });
157
- });
158
-
159
- describe('extractFailedAttempts', () => {
160
- it('extracts failure-like text', async () => {
161
- writeTestTranscript([
162
- {
163
- type: 'assistant',
164
- message: {
165
- role: 'assistant',
166
- content: [{ type: 'text', text: 'The regex approach failed because it cannot handle nested braces properly.' }],
167
- },
168
- },
169
- ]);
170
- const entries = await parseTranscript(TEST_JSONL);
171
- const failures = extractFailedAttempts(entries);
172
- expect(failures.length).toBeGreaterThan(0);
173
- expect(failures[0].text).toContain('failed');
174
- });
175
- });
176
-
177
- describe('estimateTokens', () => {
178
- it('approximates tokens as chars/4', () => {
179
- expect(estimateTokens('hello')).toBe(2); // 5/4 = 1.25 -> ceil = 2
180
- expect(estimateTokens('a'.repeat(100))).toBe(25);
181
- });
182
- });
183
-
184
- describe('getLastAssistantMessage', () => {
185
- it('returns last assistant text', async () => {
186
- writeTestTranscript([
187
- { type: 'assistant', message: { role: 'assistant', content: [{ type: 'text', text: 'First response' }] } },
188
- { type: 'assistant', message: { role: 'assistant', content: [{ type: 'text', text: 'Final response' }] } },
189
- ]);
190
- const entries = await parseTranscript(TEST_JSONL);
191
- const last = getLastAssistantMessage(entries);
192
- expect(last).toBe('Final response');
193
- });
194
- });
195
- });
@@ -1,25 +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 } from 'vitest';
5
- import { extractProcedures } from '../trpc-index.ts';
6
-
7
- describe('extractProcedures', () => {
8
- // This test requires actual router files to exist.
9
- // We test the function's behavior with a known router.
10
- it('extracts procedures from the orders router if it exists', () => {
11
- const procs = extractProcedures('src/server/api/routers/orders.ts');
12
- // If the file exists, we should get some procedures
13
- if (procs.length > 0) {
14
- expect(procs[0]).toHaveProperty('name');
15
- expect(procs[0]).toHaveProperty('type');
16
- expect(procs[0]).toHaveProperty('isProtected');
17
- expect(['query', 'mutation']).toContain(procs[0].type);
18
- }
19
- });
20
-
21
- it('returns empty array for non-existent file', () => {
22
- const procs = extractProcedures('src/server/api/routers/nonexistent-router-xyzzy.ts');
23
- expect(procs).toEqual([]);
24
- });
25
- });