milens 0.6.3 → 0.6.4
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/.agents/skills/adapters/SKILL.md +31 -0
- package/.agents/skills/analyzer/SKILL.md +55 -0
- package/.agents/skills/apps/SKILL.md +42 -0
- package/.agents/skills/docs/SKILL.md +46 -0
- package/.agents/skills/milens/SKILL.md +168 -0
- package/.agents/skills/milens-code-review/SKILL.md +186 -0
- package/.agents/skills/milens-eval/SKILL.md +221 -0
- package/.agents/skills/milens-plan/SKILL.md +227 -0
- package/.agents/skills/milens-refactor-clean/SKILL.md +209 -0
- package/.agents/skills/milens-security-review/SKILL.md +224 -0
- package/.agents/skills/milens-tdd/SKILL.md +156 -0
- package/.agents/skills/parser/SKILL.md +60 -0
- package/.agents/skills/root/SKILL.md +64 -0
- package/.agents/skills/scripts/SKILL.md +27 -0
- package/.agents/skills/security/SKILL.md +44 -0
- package/.agents/skills/server/SKILL.md +46 -0
- package/.agents/skills/store/SKILL.md +53 -0
- package/.agents/skills/test/SKILL.md +73 -0
- package/LICENSE +75 -75
- package/README.md +508 -432
- package/adapters/README.md +107 -0
- package/adapters/claude-code/.claude/mcp.json +9 -0
- package/adapters/claude-code/CLAUDE.md +58 -0
- package/adapters/codex/.codex/codex.md +52 -0
- package/adapters/copilot/.github/copilot-instructions.md +62 -0
- package/adapters/cursor/.cursorrules +9 -0
- package/adapters/gemini/.gemini/context.md +58 -0
- package/adapters/opencode/.opencode/config.json +9 -0
- package/adapters/opencode/AGENTS.md +58 -0
- package/adapters/zed/.zed/settings.json +8 -0
- package/dist/agents-md.d.ts +3 -0
- package/dist/agents-md.d.ts.map +1 -0
- package/dist/agents-md.js +112 -0
- package/dist/agents-md.js.map +1 -0
- package/dist/analyzer/engine.js +1 -1
- package/dist/analyzer/engine.js.map +1 -1
- package/dist/cli.js +1190 -401
- package/dist/cli.js.map +1 -1
- package/dist/metrics.d.ts +51 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +64 -0
- package/dist/metrics.js.map +1 -0
- package/dist/parser/lang-go.js +47 -47
- package/dist/parser/lang-java.js +29 -29
- package/dist/parser/lang-js.js +105 -105
- package/dist/parser/lang-php.js +38 -38
- package/dist/parser/lang-py.js +34 -34
- package/dist/parser/lang-ruby.js +14 -14
- package/dist/parser/lang-rust.js +30 -30
- package/dist/parser/lang-ts.js +191 -191
- package/dist/security/deps.d.ts +38 -0
- package/dist/security/deps.d.ts.map +1 -0
- package/dist/security/deps.js +685 -0
- package/dist/security/deps.js.map +1 -0
- package/dist/security/rules.d.ts +42 -0
- package/dist/security/rules.d.ts.map +1 -0
- package/dist/security/rules.js +940 -0
- package/dist/security/rules.js.map +1 -0
- package/dist/server/hooks.d.ts +26 -0
- package/dist/server/hooks.d.ts.map +1 -0
- package/dist/server/hooks.js +253 -0
- package/dist/server/hooks.js.map +1 -0
- package/dist/server/mcp-prompts.d.ts +277 -0
- package/dist/server/mcp-prompts.d.ts.map +1 -0
- package/dist/server/mcp-prompts.js +627 -0
- package/dist/server/mcp-prompts.js.map +1 -0
- package/dist/server/mcp.d.ts.map +1 -1
- package/dist/server/mcp.js +618 -643
- package/dist/server/mcp.js.map +1 -1
- package/dist/server/test-plan.d.ts +20 -0
- package/dist/server/test-plan.d.ts.map +1 -0
- package/dist/server/test-plan.js +100 -0
- package/dist/server/test-plan.js.map +1 -0
- package/dist/skills.js +152 -152
- package/dist/store/annotations.d.ts +41 -0
- package/dist/store/annotations.d.ts.map +1 -0
- package/dist/store/annotations.js +192 -0
- package/dist/store/annotations.js.map +1 -0
- package/dist/store/confidence.d.ts +18 -0
- package/dist/store/confidence.d.ts.map +1 -0
- package/dist/store/confidence.js +82 -0
- package/dist/store/confidence.js.map +1 -0
- package/dist/store/db.d.ts +37 -14
- package/dist/store/db.d.ts.map +1 -1
- package/dist/store/db.js +332 -239
- package/dist/store/db.js.map +1 -1
- package/dist/store/schema.sql +128 -116
- package/dist/store/vectors.js +2 -2
- package/dist/types.d.ts +101 -0
- package/dist/types.d.ts.map +1 -1
- package/docs/README.md +24 -0
- package/package.json +80 -66
- package/dist/gateway/analyzer.d.ts +0 -6
- package/dist/gateway/analyzer.d.ts.map +0 -1
- package/dist/gateway/analyzer.js +0 -218
- package/dist/gateway/analyzer.js.map +0 -1
- package/dist/gateway/cache.d.ts +0 -35
- package/dist/gateway/cache.d.ts.map +0 -1
- package/dist/gateway/cache.js +0 -175
- package/dist/gateway/cache.js.map +0 -1
- package/dist/gateway/config.d.ts +0 -10
- package/dist/gateway/config.d.ts.map +0 -1
- package/dist/gateway/config.js +0 -167
- package/dist/gateway/config.js.map +0 -1
- package/dist/gateway/context-memory.d.ts +0 -68
- package/dist/gateway/context-memory.d.ts.map +0 -1
- package/dist/gateway/context-memory.js +0 -157
- package/dist/gateway/context-memory.js.map +0 -1
- package/dist/gateway/observability.d.ts +0 -83
- package/dist/gateway/observability.d.ts.map +0 -1
- package/dist/gateway/observability.js +0 -152
- package/dist/gateway/observability.js.map +0 -1
- package/dist/gateway/privacy.d.ts +0 -27
- package/dist/gateway/privacy.d.ts.map +0 -1
- package/dist/gateway/privacy.js +0 -139
- package/dist/gateway/privacy.js.map +0 -1
- package/dist/gateway/providers.d.ts +0 -66
- package/dist/gateway/providers.d.ts.map +0 -1
- package/dist/gateway/providers.js +0 -377
- package/dist/gateway/providers.js.map +0 -1
- package/dist/gateway/router.d.ts +0 -18
- package/dist/gateway/router.d.ts.map +0 -1
- package/dist/gateway/router.js +0 -102
- package/dist/gateway/router.js.map +0 -1
- package/dist/gateway/server.d.ts +0 -20
- package/dist/gateway/server.d.ts.map +0 -1
- package/dist/gateway/server.js +0 -387
- package/dist/gateway/server.js.map +0 -1
- package/dist/gateway/translator.d.ts +0 -19
- package/dist/gateway/translator.d.ts.map +0 -1
- package/dist/gateway/translator.js +0 -340
- package/dist/gateway/translator.js.map +0 -1
- package/dist/gateway/types.d.ts +0 -215
- package/dist/gateway/types.d.ts.map +0 -1
- package/dist/gateway/types.js +0 -3
- package/dist/gateway/types.js.map +0 -1
- package/dist/store/gateway-schema.sql +0 -53
|
@@ -0,0 +1,627 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
3
|
+
// 1. milens-planner — 5-step implementation planning
|
|
4
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
5
|
+
const PLANNER_ARGS = {
|
|
6
|
+
feature: z.string().describe('Feature or task to plan'),
|
|
7
|
+
target: z.string().optional().describe('Primary symbol to modify (optional)'),
|
|
8
|
+
};
|
|
9
|
+
async function plannerHandler(args) {
|
|
10
|
+
return {
|
|
11
|
+
messages: [{
|
|
12
|
+
role: 'user',
|
|
13
|
+
content: {
|
|
14
|
+
type: 'text',
|
|
15
|
+
text: `You are the Milens Planner Agent. Execute this workflow to create a detailed implementation plan for: "${args.feature}"
|
|
16
|
+
${args.target ? `\nPrimary target symbol: "${args.target}"` : ''}
|
|
17
|
+
|
|
18
|
+
## STEP 1 — RESEARCH (Codebase Intelligence)
|
|
19
|
+
Call these tools in sequence to understand project structure:
|
|
20
|
+
1. \`codebase_summary({})\` → compact overview: symbols, domains, top hubs, test coverage %
|
|
21
|
+
2. \`domains({})\` → module clusters with file/symbol counts — identify which domains are relevant to this feature
|
|
22
|
+
3. \`routes({})\` → inventory of API endpoints — identify which routes need changes or new routes needed
|
|
23
|
+
${args.target ? `4. \`smart_context({name: "${args.target}", intent: "understand"})\` → 360° view of the target symbol (incoming refs, outgoing deps, callers, file peers)` : `4. \`query({query: "${args.feature.split(' ')[0]}"})\` → find relevant symbols by name`}
|
|
24
|
+
|
|
25
|
+
## STEP 2 — TARGET ANALYSIS
|
|
26
|
+
${args.target ? `Perform deep analysis on "${args.target}":
|
|
27
|
+
1. \`smart_context({name: "${args.target}", intent: "edit"})\` → direct callers, blast radius, test coverage, re-export chains
|
|
28
|
+
2. \`edit_check({name: "${args.target}"})\` → pre-edit safety: callers, export status, inherited-by warnings, test coverage
|
|
29
|
+
3. \`trace({name: "${args.target}", direction: "to"})\` → execution paths from entrypoints TO this symbol — understand how code reaches it
|
|
30
|
+
4. \`impact({target: "${args.target}", direction: "upstream", depth: 3})\` → blast radius: what WILL break if this changes
|
|
31
|
+
- depth 1 = WILL BREAK (direct callers)
|
|
32
|
+
- depth 2 = LIKELY AFFECTED (indirect callers)
|
|
33
|
+
- depth 3 = MAY NEED TESTING (transitive dependents)` : `No target symbol specified. Use \`codebase_summary()\` and \`domains()\` output to identify key symbols that need modification. For each key symbol found, run:
|
|
34
|
+
1. \`smart_context({name: "keySymbol", intent: "edit"})\` → callers + blast radius
|
|
35
|
+
2. \`edit_check({name: "keySymbol"})\` → pre-edit safety
|
|
36
|
+
3. \`impact({target: "keySymbol", depth: 2})\` → upstream dependents`}
|
|
37
|
+
|
|
38
|
+
## STEP 3 — TEST STRATEGY
|
|
39
|
+
${args.target ? `1. \`test_plan({name: "${args.target}"})\` → mock plan + >=3 test scenarios for the target symbol
|
|
40
|
+
2. \`test_coverage_gaps({limit: 10})\` → nearby untested exported symbols sorted by risk` : `1. \`test_coverage_gaps({limit: 20})\` → all untested exported symbols, sorted by risk (heat + deps)
|
|
41
|
+
2. For top 5 untested symbols from gaps: \`test_plan({name})\` → mock strategy + scenarios`}
|
|
42
|
+
${args.target ? `3. \`impact({target: "${args.target}", direction: "upstream", depth: 1})\` → identify test files that import or call this symbol` : `3. \`test_impact({})\` → map changed files to which test files need to run`}
|
|
43
|
+
|
|
44
|
+
## STEP 4 — DEPENDENCY DEEPENING (if needed)
|
|
45
|
+
For any key relationships discovered in steps 1-3:
|
|
46
|
+
- \`explain_relationship({from: "A", to: "B"})\` → shortest dependency path between two symbols
|
|
47
|
+
- \`get_type_hierarchy({name: "keySymbol"})\` → inheritance chain if dealing with classes/interfaces
|
|
48
|
+
- \`grep({pattern: "keySymbol"})\` → ALL text references (templates, configs, SCSS, docs, routes) — catches what impact() misses
|
|
49
|
+
|
|
50
|
+
## OUTPUT FORMAT — Implementation Plan
|
|
51
|
+
|
|
52
|
+
Produce a detailed Implementation Plan in the following structure:
|
|
53
|
+
|
|
54
|
+
### 1. Overview
|
|
55
|
+
2-3 sentences summarizing what the feature does and the high-level approach.
|
|
56
|
+
|
|
57
|
+
### 2. Requirements
|
|
58
|
+
- Bullet list of functional and non-functional requirements
|
|
59
|
+
- Derived from codebase_summary + domains + routes analysis
|
|
60
|
+
|
|
61
|
+
### 3. Architecture Changes
|
|
62
|
+
For each file that needs changes, specify:
|
|
63
|
+
- **File:** relative path
|
|
64
|
+
- **Symbol:** names of symbols being added/modified/deleted
|
|
65
|
+
- **Description:** what changes and why
|
|
66
|
+
- **Risk Level:** LOW / MEDIUM / HIGH / CRITICAL (from impact() data — use heat + dependents count)
|
|
67
|
+
- **Dependencies:** other symbols this change depends on (from context() outgoing links)
|
|
68
|
+
|
|
69
|
+
### 4. Implementation Steps
|
|
70
|
+
Ordered list (by dependency — leaf nodes first, shared dependencies before consumers):
|
|
71
|
+
For each step:
|
|
72
|
+
- **Action:** CREATE / MODIFY / DELETE / CONFIG
|
|
73
|
+
- **File:** relative path
|
|
74
|
+
- **Why:** purpose of this change
|
|
75
|
+
- **Dependencies:** prerequisite steps (by step number)
|
|
76
|
+
- **Risk:** LOW / MEDIUM / HIGH / CRITICAL
|
|
77
|
+
- **Impacted Symbols:** symbols affected by this change (from impact() output)
|
|
78
|
+
|
|
79
|
+
### 5. Testing Strategy
|
|
80
|
+
- Test files to create/modify (from test_plan() output)
|
|
81
|
+
- Mock requirements (from test_plan() dependencies-to-mock)
|
|
82
|
+
- Test scenarios (from test_plan() >=3 scenarios per symbol)
|
|
83
|
+
- Coverage improvement estimate (from test_coverage_gaps() baseline vs expected)
|
|
84
|
+
- Command to run tests: \`npx vitest run <files>\`
|
|
85
|
+
|
|
86
|
+
### 6. Risks & Mitigations
|
|
87
|
+
- Each risk from impact() depth-2+ dependents
|
|
88
|
+
- Risk level, likelihood, mitigation strategy
|
|
89
|
+
|
|
90
|
+
### 7. Success Criteria
|
|
91
|
+
- Measurable checkboxes: [ ] each criterion
|
|
92
|
+
- E.g. [ ] Feature works end-to-end, [ ] All tests pass, [ ] No new dead code, [ ] Test coverage improves by X%
|
|
93
|
+
|
|
94
|
+
Important: Use specific file paths, symbol names, and risk levels from the tool outputs. Never guess — always cite which tool produced each finding.
|
|
95
|
+
`,
|
|
96
|
+
},
|
|
97
|
+
}],
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
101
|
+
// 2. milens-reviewer — PR review workflow
|
|
102
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
103
|
+
const REVIEWER_ARGS = {
|
|
104
|
+
change_description: z.string().optional().describe('High-level description of what changed (optional)'),
|
|
105
|
+
};
|
|
106
|
+
async function reviewerHandler(args) {
|
|
107
|
+
return {
|
|
108
|
+
messages: [{
|
|
109
|
+
role: 'user',
|
|
110
|
+
content: {
|
|
111
|
+
type: 'text',
|
|
112
|
+
text: `You are the Milens Reviewer Agent. Perform a thorough code review of the current changes.
|
|
113
|
+
${args.change_description ? `\nContext: "${args.change_description}"` : ''}
|
|
114
|
+
|
|
115
|
+
## STEP 1 — PR RISK SCAN
|
|
116
|
+
Run \`review_pr({})\` to get:
|
|
117
|
+
- All changed symbols with risk scores (LOW/MEDIUM/HIGH/CRITICAL)
|
|
118
|
+
- Risk score factors: heat (centrality), number of dependents, test coverage (no test = +25 risk points)
|
|
119
|
+
- Summary: count of symbols by risk level
|
|
120
|
+
|
|
121
|
+
## STEP 2 — DEEP DIVE ON CRITICAL/HIGH
|
|
122
|
+
For each symbol rated CRITICAL or HIGH:
|
|
123
|
+
1. Run \`review_symbol({name: "symbolName"})\` → deep dive: role, heat, dependents list, dependencies list, test status, risk recommendation
|
|
124
|
+
2. Run \`context({name: "symbolName"})\` → full 360°: incoming refs (who calls it) + outgoing deps (what it calls)
|
|
125
|
+
3. Run \`grep({pattern: "symbolName"})\` → ALL text references across the project including templates, configs, routes, SCSS, docs
|
|
126
|
+
|
|
127
|
+
## STEP 3 — DEAD CODE DETECTION
|
|
128
|
+
Run \`find_dead_code({limit: 30})\` → identify exported symbols with zero incoming references.
|
|
129
|
+
Cross-reference with changed files: if any changed symbol appears in dead code list, flag it for removal consideration.
|
|
130
|
+
|
|
131
|
+
## STEP 4 — SECURITY & TECH DEBT SCAN
|
|
132
|
+
1. Run \`grep({pattern: "password|secret|api_key|token|private_key|AKIA", scope: "code"})\` → hardcoded secrets
|
|
133
|
+
2. Run \`grep({pattern: "TODO|FIXME|HACK|console\\\\.log", scope: "code"})\` → tech debt markers
|
|
134
|
+
3. Run \`grep({pattern: "eval|exec|child_process|Function\\\\(", scope: "code"})\` → dangerous code patterns
|
|
135
|
+
|
|
136
|
+
## STEP 5 — VERIFY SCOPE
|
|
137
|
+
Run \`detect_changes({})\` → verify only expected files changed.
|
|
138
|
+
If unexpected files appear → flag as a concern (unintended side effects).
|
|
139
|
+
|
|
140
|
+
## OUTPUT FORMAT — Review Report
|
|
141
|
+
|
|
142
|
+
Produce a comprehensive code review report:
|
|
143
|
+
|
|
144
|
+
### 1. Risk Summary
|
|
145
|
+
| Risk Level | Count | Symbols |
|
|
146
|
+
|---|---|---|
|
|
147
|
+
| CRITICAL | N | symbol1, symbol2, ... |
|
|
148
|
+
| HIGH | N | ... |
|
|
149
|
+
| MEDIUM | N | ... |
|
|
150
|
+
| LOW | N | ... |
|
|
151
|
+
|
|
152
|
+
### 2. Per-Symbol Deep Dives (for CRITICAL/HIGH only)
|
|
153
|
+
For each CRITICAL and HIGH symbol:
|
|
154
|
+
- **Symbol:** name [kind] file:line
|
|
155
|
+
- **Risk Score:** N / 100
|
|
156
|
+
- **Dependents:** count + top 5 names — these WILL break if symbol changes
|
|
157
|
+
- **Dependencies:** count + top 5 names — what it relies on
|
|
158
|
+
- **Test Coverage:** yes/no — if no, explain risk
|
|
159
|
+
- **Text References:** grep() matches in templates/configs/routes
|
|
160
|
+
- **Assessment:** detailed analysis of the change
|
|
161
|
+
- **Recommendation:** MERGE / FIX / REWRITE / ADD_TESTS
|
|
162
|
+
|
|
163
|
+
### 3. Dead Code List
|
|
164
|
+
List of unreferenced exported symbols from find_dead_code().
|
|
165
|
+
If any are in changed files, recommend removal.
|
|
166
|
+
|
|
167
|
+
### 4. Security Concerns
|
|
168
|
+
Any grep matches for secrets, dangerous patterns, or data leaks.
|
|
169
|
+
For each finding: file, line, pattern matched, severity, fix suggestion.
|
|
170
|
+
|
|
171
|
+
### 5. Recommendations
|
|
172
|
+
- [ ] Symbols safe to merge (LOW/MEDIUM risk)
|
|
173
|
+
- [ ] Symbols needing fixes before merge (HIGH/CRITICAL)
|
|
174
|
+
- [ ] Tests that should be added
|
|
175
|
+
- [ ] Dead code candidates for removal
|
|
176
|
+
|
|
177
|
+
### 6. Verdict
|
|
178
|
+
- **APPROVE** — all changes are safe
|
|
179
|
+
- **APPROVE WITH COMMENTS** — minor issues, merge and fix later
|
|
180
|
+
- **REQUEST CHANGES** — critical issues, cannot merge
|
|
181
|
+
`,
|
|
182
|
+
},
|
|
183
|
+
}],
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
187
|
+
// 3. milens-tester — Test-driven development workflow
|
|
188
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
189
|
+
const TESTER_ARGS = {
|
|
190
|
+
focus: z.string().optional().describe('Specific symbol to focus testing on (optional)'),
|
|
191
|
+
};
|
|
192
|
+
async function testerHandler(args) {
|
|
193
|
+
return {
|
|
194
|
+
messages: [{
|
|
195
|
+
role: 'user',
|
|
196
|
+
content: {
|
|
197
|
+
type: 'text',
|
|
198
|
+
text: `You are the Milens Tester Agent. Execute a test-driven development workflow to improve test coverage.
|
|
199
|
+
${args.focus ? `\nFocus symbol: "${args.focus}"` : ''}
|
|
200
|
+
|
|
201
|
+
## STEP 1 — IDENTIFY COVERAGE GAPS
|
|
202
|
+
1. Run \`test_coverage_gaps({limit: 20})\` → untested exported symbols sorted by risk (heat × dependents).
|
|
203
|
+
- Risk levels: CRITICAL (heat>80), HIGH (heat>50), MEDIUM (heat>30), LOW
|
|
204
|
+
- Pay special attention to HIGH and CRITICAL — these are exploitable gaps
|
|
205
|
+
${args.focus ? `2. Run \`smart_context({name: "${args.focus}", intent: "test"})\` → existing tests for this symbol, dependencies to mock, callers to cover` : `2. From the gaps list, identify the top 5 critical symbols to prioritize`}
|
|
206
|
+
|
|
207
|
+
## STEP 2 — BUILD TEST PLANS
|
|
208
|
+
${args.focus ? `Run \`test_plan({name: "${args.focus}"})\` → generates:
|
|
209
|
+
- Mock plan: which dependencies to mock and how
|
|
210
|
+
- >=3 test scenarios: happy path, edge cases, error handling
|
|
211
|
+
- Suggested test file location` : `For each of the top 5 untested symbols from gaps, run \`test_plan({name: "symbolName"})\` → mock plan + >=3 test scenarios each`}
|
|
212
|
+
${args.focus ? `\nAlso run \`context({name: "${args.focus}"})\` → full incoming/outgoing to understand all relationships before writing tests.` : `\nAlso run \`context({name: "symbolName"})\` for each symbol → understand full relationships before writing tests.`}
|
|
213
|
+
|
|
214
|
+
## STEP 3 — IMPLEMENT TESTS
|
|
215
|
+
Implement the test scenarios from test_plan():
|
|
216
|
+
- Create test files in the suggested locations
|
|
217
|
+
- Write >=3 test cases per symbol: happy path, edge case, error condition
|
|
218
|
+
- Mock external dependencies per the mock plan
|
|
219
|
+
- Use the same test framework as existing tests in the project
|
|
220
|
+
${args.focus ? `- Verify tests reference "${args.focus}" correctly (check context() output for import paths)` : `- Verify tests reference the correct symbol names and import paths`}
|
|
221
|
+
|
|
222
|
+
## STEP 4 — VERIFY IMPACT
|
|
223
|
+
After writing tests:
|
|
224
|
+
1. Run \`test_impact({})\` → maps changed code to affected test files — verify new tests are in the list
|
|
225
|
+
2. Run \`test_coverage_gaps({limit: 10})\` again → verify coverage improved (symbols should drop off the gaps list)
|
|
226
|
+
3. Run \`review_symbol({name: "symbolName"})\` for the tested symbol → confirm "test coverage: yes" now shows
|
|
227
|
+
|
|
228
|
+
## OUTPUT FORMAT — Test Coverage Report
|
|
229
|
+
|
|
230
|
+
### 1. Coverage Gaps Summary
|
|
231
|
+
| Priority | Symbol | Kind | Risk | Heat | Dependents | File |
|
|
232
|
+
|---|---|---|---|---|---|---|
|
|
233
|
+
| 1 | ... | ... | ... | ... | ... | ... |
|
|
234
|
+
|
|
235
|
+
### 2. Test Plans (for top 5)
|
|
236
|
+
For each symbol:
|
|
237
|
+
- **Symbol:** name [kind] file:line
|
|
238
|
+
- **Mock Dependencies:** list from test_plan() dependencies-to-mock
|
|
239
|
+
- **Test Scenarios:** >=3 scenarios from test_plan()
|
|
240
|
+
1. Happy path: description
|
|
241
|
+
2. Edge case: description
|
|
242
|
+
3. Error handling: description
|
|
243
|
+
|
|
244
|
+
### 3. Suggested Test Files
|
|
245
|
+
| Symbol | Test File | Test Framework |
|
|
246
|
+
|---|---|---|
|
|
247
|
+
| ... | src/__tests__/...test.ts | vitest |
|
|
248
|
+
|
|
249
|
+
### 4. Coverage Improvement Estimate
|
|
250
|
+
- **Before:** X% (from initial test_coverage_gaps)
|
|
251
|
+
- **After:** Y% (estimated after implementing all test plans)
|
|
252
|
+
- **Delta:** +Z%
|
|
253
|
+
- **Remaining gaps:** N symbols still untested
|
|
254
|
+
|
|
255
|
+
### 5. Run Command
|
|
256
|
+
\`\`\`bash
|
|
257
|
+
npx vitest run <test files>
|
|
258
|
+
\`\`\`
|
|
259
|
+
`,
|
|
260
|
+
},
|
|
261
|
+
}],
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
265
|
+
// 4. milens-architect — Architecture analysis
|
|
266
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
267
|
+
const ARCHITECT_ARGS = {};
|
|
268
|
+
async function architectHandler() {
|
|
269
|
+
return {
|
|
270
|
+
messages: [{
|
|
271
|
+
role: 'user',
|
|
272
|
+
content: {
|
|
273
|
+
type: 'text',
|
|
274
|
+
text: `You are the Milens Architect Agent. Perform a comprehensive architecture analysis of this codebase.
|
|
275
|
+
|
|
276
|
+
## STEP 1 — CODEBASE OVERVIEW
|
|
277
|
+
Run \`codebase_summary({})\` → compact overview:
|
|
278
|
+
- Total symbols, links, files
|
|
279
|
+
- Test coverage percentage
|
|
280
|
+
- Domain clusters with symbol counts
|
|
281
|
+
- Top hubs (high-heat symbols >70) — these are critical architecture nodes
|
|
282
|
+
|
|
283
|
+
## STEP 2 — DOMAIN MAP
|
|
284
|
+
Run \`domains({})\` → module clusters:
|
|
285
|
+
- Each domain represents a logical module (group of files with high internal coupling)
|
|
286
|
+
- Note domain boundaries — where does one module end and another begin?
|
|
287
|
+
- Identify cross-domain dependencies (potential architecture violations)
|
|
288
|
+
|
|
289
|
+
## STEP 3 — ROUTE INVENTORY
|
|
290
|
+
Run \`routes({})\` → all detected API endpoints:
|
|
291
|
+
- Group by framework (Express, FastAPI, NestJS, Flask, Go, PHP, Rails)
|
|
292
|
+
- Map each route to its handler symbol
|
|
293
|
+
- Identify: public APIs, internal APIs, deprecated routes
|
|
294
|
+
|
|
295
|
+
## STEP 4 — EXECUTION FLOWS
|
|
296
|
+
For the top 3-5 entry points (identified from routes() or top hubs):
|
|
297
|
+
1. Run \`trace({name: "entrypointSymbol", direction: "to"})\` → execution paths from entrypoint inward
|
|
298
|
+
2. Run \`trace({name: "topHubSymbol", direction: "from"})\` → downstream call tree from central hubs
|
|
299
|
+
This reveals the critical execution paths through the system.
|
|
300
|
+
|
|
301
|
+
## STEP 5 — CLASS HIERARCHY
|
|
302
|
+
For each top class/interface from codebase_summary() top hubs:
|
|
303
|
+
Run \`get_type_hierarchy({name: "className"})\` → inheritance tree:
|
|
304
|
+
- ancestors (extends/implements)
|
|
305
|
+
- descendants (extended/implemented by)
|
|
306
|
+
Note deep inheritance chains (>3 levels) — potential refactoring targets.
|
|
307
|
+
|
|
308
|
+
## STEP 6 — COUPLING ANALYSIS
|
|
309
|
+
For key architectural pairs (domains that depend on each other, hub-to-hub connections):
|
|
310
|
+
Run \`explain_relationship({from: "A", to: "B"})\` → shortest dependency path.
|
|
311
|
+
Identify:
|
|
312
|
+
- Tight coupling (path length = 1) — high risk of cascading changes
|
|
313
|
+
- Loose coupling (path length >= 3) — healthier architecture
|
|
314
|
+
- Circular dependencies (path loops) — critical architecture flaw
|
|
315
|
+
|
|
316
|
+
## STEP 7 — GLOBAL REFERENCE CHECK
|
|
317
|
+
Run \`grep({pattern: "TODO|FIXME|DEPRECATED|HACK"})\` → tech debt markers.
|
|
318
|
+
Run \`find_dead_code({limit: 30})\` → orphaned exports — removed functionality still in codebase.
|
|
319
|
+
|
|
320
|
+
## OUTPUT FORMAT — Architecture Analysis
|
|
321
|
+
|
|
322
|
+
### 1. Architecture Overview
|
|
323
|
+
2-3 paragraphs: architecture style (monolith/microservices/layered/hexagonal), primary language/framework, overall health assessment.
|
|
324
|
+
|
|
325
|
+
### 2. Domain Map
|
|
326
|
+
| Domain | Files | Symbols | % of Codebase | Dependencies On | Depended By |
|
|
327
|
+
|---|---|---|---|---|---|
|
|
328
|
+
| ... | ... | ... | ... | ... | ... |
|
|
329
|
+
|
|
330
|
+
### 3. Route Inventory
|
|
331
|
+
| Method | Path | Framework | Handler Symbol | File | Status |
|
|
332
|
+
|---|---|---|---|---|---|
|
|
333
|
+
| GET | /api/users | express | getUsers [method] | src/routes/users.ts:25 | active |
|
|
334
|
+
|
|
335
|
+
### 4. Class / Type Hierarchy
|
|
336
|
+
For each top-level class/interface:
|
|
337
|
+
- Symbol: name [kind] file:line
|
|
338
|
+
- Inheritance chain: BaseClass → ParentClass → ThisClass → ChildClass1 → ChildClass2
|
|
339
|
+
- Depth: N levels (warning if >3)
|
|
340
|
+
|
|
341
|
+
### 5. Critical Execution Paths
|
|
342
|
+
For each entry point traced:
|
|
343
|
+
\`\`\`
|
|
344
|
+
EntryPoint
|
|
345
|
+
→ Middleware (step 1)
|
|
346
|
+
→ ServiceLayer (step 2)
|
|
347
|
+
→ Repository/DB (step 3)
|
|
348
|
+
→ TargetSymbol (step 4)
|
|
349
|
+
\`\`\`
|
|
350
|
+
|
|
351
|
+
### 6. Coupling Hotspots
|
|
352
|
+
| Symbol A | Symbol B | Path Length | Type | Risk | Recommendation |
|
|
353
|
+
|---|---|---|---|---|---|
|
|
354
|
+
| ... | ... | 2 | cross-domain | HIGH | Consider interface abstraction |
|
|
355
|
+
|
|
356
|
+
### 7. Refactoring Suggestions
|
|
357
|
+
- [ ] Deep inheritance chains to flatten (>3 levels)
|
|
358
|
+
- [ ] Cross-domain tight coupling to decouple
|
|
359
|
+
- [ ] Circular dependencies to break
|
|
360
|
+
- [ ] Dead code to remove (from find_dead_code)
|
|
361
|
+
- [ ] Tech debt to resolve (from grep TODO/FIXME)
|
|
362
|
+
|
|
363
|
+
### 8. Architecture Scorecard
|
|
364
|
+
| Metric | Value | Grade | Notes |
|
|
365
|
+
|---|---|---|---|
|
|
366
|
+
| Total Symbols | N | — | |
|
|
367
|
+
| Total Domains | N | — | |
|
|
368
|
+
| Avg Domain Size | N symbols | — | |
|
|
369
|
+
| Max Inheritance Depth | N | — | >3 = concern |
|
|
370
|
+
| Tight Coupling Pairs | N | — | path=1 pairs |
|
|
371
|
+
| Dead Code Symbols | N | — | should be 0 |
|
|
372
|
+
| Test Coverage | X% | — | target >80% |
|
|
373
|
+
|
|
374
|
+
Important: Every finding must cite the tool that produced it. Use specific file paths and symbol names from the tool outputs.
|
|
375
|
+
`,
|
|
376
|
+
},
|
|
377
|
+
}],
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
381
|
+
// 5. milens-security — Security audit
|
|
382
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
383
|
+
const SECURITY_ARGS = {};
|
|
384
|
+
async function securityHandler() {
|
|
385
|
+
return {
|
|
386
|
+
messages: [{
|
|
387
|
+
role: 'user',
|
|
388
|
+
content: {
|
|
389
|
+
type: 'text',
|
|
390
|
+
text: `You are the Milens Security Agent. Perform a comprehensive security audit of this codebase.
|
|
391
|
+
|
|
392
|
+
## STEP 1 — CHANGE RISK ASSESSMENT
|
|
393
|
+
Run \`review_pr({})\` → identify changed symbols with risk scores.
|
|
394
|
+
Pay special attention to HIGH/CRITICAL symbols — these represent the highest-value attack surface.
|
|
395
|
+
|
|
396
|
+
## STEP 2 — HARDCODED SECRETS SCAN
|
|
397
|
+
Run \`grep({pattern: "password|secret|api_key|token|private_key|AKIA", scope: "code"})\` → detect hardcoded credentials.
|
|
398
|
+
|
|
399
|
+
Additionally run these targeted scans:
|
|
400
|
+
- \`grep({pattern: "sk-[a-zA-Z0-9]{32,}", scope: "code", isRegex: true})\` → OpenAI/Stripe API keys
|
|
401
|
+
- \`grep({pattern: "ghp_[a-zA-Z0-9]{36}", scope: "code", isRegex: true})\` → GitHub personal access tokens
|
|
402
|
+
- \`grep({pattern: "-----BEGIN (RSA|EC) PRIVATE KEY-----", scope: "code", isRegex: true})\` → private keys in source
|
|
403
|
+
- \`grep({pattern: "\\.env", scope: "code"})\` → .env file references (check if .env is in .gitignore)
|
|
404
|
+
- \`grep({pattern: "JWT_SECRET|SESSION_SECRET|ENCRYPTION_KEY", scope: "code"})\` → cryptographic secrets
|
|
405
|
+
|
|
406
|
+
## STEP 3 — UNICODE / HOMOGLYPH SCAN
|
|
407
|
+
Run \`grep({pattern: "[\\u202A-\\u202E]", scope: "code", isRegex: true})\` → bidi override characters (used in Trojan Source attacks)
|
|
408
|
+
Run \`grep({pattern: "[\\u200B\\u200C\\u200D\\u2060\\uFEFF]", scope: "code", isRegex: true})\` → zero-width characters (can hide malicious code)
|
|
409
|
+
Run \`grep({pattern: "[\\u0400-\\u04FF]", scope: "code", isRegex: true})\` → Cyrillic characters (potential homoglyph attacks in Latin-named identifiers)
|
|
410
|
+
|
|
411
|
+
## STEP 4 — DANGEROUS CODE PATTERNS
|
|
412
|
+
Run these targeted scans for code execution vulnerabilities:
|
|
413
|
+
- \`grep({pattern: "eval\\\\(", scope: "code", isRegex: true})\` → arbitrary code execution (CRITICAL in JS/Python/PHP)
|
|
414
|
+
- \`grep({pattern: "exec\\\\(", scope: "code", isRegex: true})\` → command injection (CRITICAL in Python/PHP)
|
|
415
|
+
- \`grep({pattern: "child_process", scope: "code"})\` → child process spawning (CRITICAL in Node.js)
|
|
416
|
+
- \`grep({pattern: "Function\\\\(", scope: "code", isRegex: true})\` → dynamic function creation (HIGH)
|
|
417
|
+
- \`grep({pattern: "subprocess\\\\.call.*shell=True|os\\\\.system", scope: "code", isRegex: true})\` → shell execution (CRITICAL in Python)
|
|
418
|
+
- \`grep({pattern: "Runtime\\\\.getRuntime\\\\(\\\\)\\\\.exec|ProcessBuilder", scope: "code", isRegex: true})\` → command execution (CRITICAL in Java)
|
|
419
|
+
- \`grep({pattern: "innerHTML|dangerouslySetInnerHTML|document\\\\.write", scope: "code", isRegex: true})\` → XSS vectors (HIGH in JS/TS)
|
|
420
|
+
|
|
421
|
+
## STEP 5 — DATA LEAKAGE SCAN
|
|
422
|
+
Run \`grep({pattern: "console\\\\.log", scope: "code", isRegex: true})\` → production logging (data leak risk)
|
|
423
|
+
Run \`grep({pattern: "console\\\\.(log|debug|info)\\\\(.*(?:password|token|secret|credential|key)", scope: "code", isRegex: true})\` → sensitive data logged (CRITICAL)
|
|
424
|
+
|
|
425
|
+
## STEP 6 — CONFIGURATION AUDIT
|
|
426
|
+
Run \`grep({pattern: "--dangerously-skip-permissions|access-control-allow-origin: \\\\*|secure: false|httpOnly: false|debug: true", scope: "code", isRegex: true})\` → security misconfigurations
|
|
427
|
+
|
|
428
|
+
## STEP 7 — DEPENDENCY CHECK
|
|
429
|
+
Run \`grep({pattern: "MD5|SHA1\\\\(|Math\\\\.random", scope: "code", isRegex: true})\` → weak/broken cryptography
|
|
430
|
+
Run \`find_dead_code({limit: 30})\` → orphaned exports (dead code = unmaintained attack surface)
|
|
431
|
+
|
|
432
|
+
## OUTPUT FORMAT — Security Audit Report
|
|
433
|
+
|
|
434
|
+
### 1. Executive Summary
|
|
435
|
+
- Total findings: N
|
|
436
|
+
- By severity: CRITICAL=N, HIGH=N, MEDIUM=N, LOW=N
|
|
437
|
+
- Security score: (100 - deductions) / 100
|
|
438
|
+
- Overall risk: LOW / MEDIUM / HIGH / CRITICAL
|
|
439
|
+
|
|
440
|
+
### 2. Findings by Severity
|
|
441
|
+
|
|
442
|
+
#### CRITICAL Findings (Must Fix Immediately)
|
|
443
|
+
| # | Category | File | Line | Match | OWASP | Fix |
|
|
444
|
+
|---|---|---|---|---|---|---|
|
|
445
|
+
| 1 | secrets | src/config.ts | 15 | password = 'admin123' | A02:2021 | Move to process.env.DB_PASSWORD |
|
|
446
|
+
|
|
447
|
+
#### HIGH Findings (Fix Before Next Release)
|
|
448
|
+
| # | Category | File | Line | Match | OWASP | Fix |
|
|
449
|
+
|---|---|---|---|---|---|---|
|
|
450
|
+
|
|
451
|
+
#### MEDIUM Findings (Fix Within 30 Days)
|
|
452
|
+
| # | Category | File | Line | Match | OWASP | Fix |
|
|
453
|
+
|---|---|---|---|---|---|---|
|
|
454
|
+
|
|
455
|
+
#### LOW Findings (Address When Possible)
|
|
456
|
+
| # | Category | File | Line | Match | OWASP | Fix |
|
|
457
|
+
|---|---|---|---|---|---|---|
|
|
458
|
+
|
|
459
|
+
### 3. OWASP Top 10 Coverage
|
|
460
|
+
| OWASP 2021 | Category | Findings Count |
|
|
461
|
+
|---|---|---|
|
|
462
|
+
| A01:2021 Broken Access Control | — | N |
|
|
463
|
+
| A02:2021 Cryptographic Failures | secrets, crypto | N |
|
|
464
|
+
| A03:2021 Injection | injection, dangerous | N |
|
|
465
|
+
| A04:2021 Insecure Design | config | N |
|
|
466
|
+
| A05:2021 Security Misconfiguration | config | N |
|
|
467
|
+
| A07:2021 Identification & Auth | auth | N |
|
|
468
|
+
| A08:2021 Software & Data Integrity | crypto | N |
|
|
469
|
+
| A09:2021 Logging & Monitoring | data-leak | N |
|
|
470
|
+
|
|
471
|
+
### 4. Affected Files Summary
|
|
472
|
+
| File | CRITICAL | HIGH | MEDIUM | LOW | Total |
|
|
473
|
+
|---|---|---|---|---|---|
|
|
474
|
+
|
|
475
|
+
### 5. Remediation Plan
|
|
476
|
+
- Immediate (CRITICAL): list of fixes, estimated effort
|
|
477
|
+
- Short-term (HIGH): list of fixes, target timeline
|
|
478
|
+
- Medium-term (MEDIUM): list of fixes, tracking issues
|
|
479
|
+
- Technical debt (LOW): list, backlog items
|
|
480
|
+
|
|
481
|
+
### 6. Security Recommendations
|
|
482
|
+
- [ ] Add pre-commit hook for secret scanning
|
|
483
|
+
- [ ] Add CI/CD security scan job
|
|
484
|
+
- [ ] Review .gitignore for sensitive file patterns
|
|
485
|
+
- [ ] Enable dependency vulnerability scanning
|
|
486
|
+
- [ ] Conduct regular security audits
|
|
487
|
+
|
|
488
|
+
Important: Every finding must include the OWASP 2021 category and a concrete, actionable fix recommendation. Cite the grep() tool and exact line numbers for each finding.
|
|
489
|
+
`,
|
|
490
|
+
},
|
|
491
|
+
}],
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
495
|
+
// 6. milens-debugger — Root cause analysis
|
|
496
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
497
|
+
const DEBUGGER_ARGS = {
|
|
498
|
+
target: z.string().describe('Symbol to debug — the function, method, or class to analyze'),
|
|
499
|
+
error_description: z.string().optional().describe('Description of the bug or error observed (optional)'),
|
|
500
|
+
};
|
|
501
|
+
async function debuggerHandler(args) {
|
|
502
|
+
return {
|
|
503
|
+
messages: [{
|
|
504
|
+
role: 'user',
|
|
505
|
+
content: {
|
|
506
|
+
type: 'text',
|
|
507
|
+
text: `You are the Milens Debugger Agent. Perform a root cause analysis on "${args.target}".
|
|
508
|
+
${args.error_description ? `\nReported error: "${args.error_description}"` : ''}
|
|
509
|
+
|
|
510
|
+
## STEP 1 — EXECUTION CONTEXT (What happens around this symbol?)
|
|
511
|
+
Run \`smart_context({name: "${args.target}", intent: "debug"})\` → returns:
|
|
512
|
+
- Execution paths: call chains from entrypoints TO this symbol
|
|
513
|
+
- What this symbol calls: downstream dependencies (immediate callees)
|
|
514
|
+
- Data types used: interfaces, types, classes passed as parameters or returned
|
|
515
|
+
This tells you HOW this code gets reached and WHAT it interacts with.
|
|
516
|
+
|
|
517
|
+
## STEP 2 — EXECUTION TRACE (How does execution reach here?)
|
|
518
|
+
Run \`trace({name: "${args.target}", direction: "to"})\` → multiple call chains from entrypoints to this symbol.
|
|
519
|
+
For each chain (path): identify which step is the most likely failure point based on error description.
|
|
520
|
+
Also run \`trace({name: "${args.target}", direction: "from"})\` → downstream call tree to see what cascading effects a bug at this point could cause.
|
|
521
|
+
|
|
522
|
+
## STEP 3 — BLAST RADIUS (What breaks if this is wrong?)
|
|
523
|
+
Run \`impact({target: "${args.target}", direction: "upstream", depth: 3})\` → all symbols that depend on this:
|
|
524
|
+
- depth 1: WILL BREAK — direct callers — these would show related errors
|
|
525
|
+
- depth 2: LIKELY AFFECTED — indirect callers — might show cascading failures
|
|
526
|
+
- depth 3: MAY NEED TESTING — transitive deps — regression risk zone
|
|
527
|
+
|
|
528
|
+
## STEP 4 — DEPENDENCY PATHS (How are things connected?)
|
|
529
|
+
Run \`explain_relationship({from: "entrypointSymbol", to: "${args.target}"})\` → exact path from entrypoint to this symbol.
|
|
530
|
+
${args.error_description ? `If error mentions another symbol, run \`explain_relationship({from: "${args.target}", to: "otherSymbol"})\` to see their connection.` : `If suspicious about related symbols from trace() output, use explain_relationship() to check connections.`}
|
|
531
|
+
|
|
532
|
+
## STEP 5 — DEEP CONTEXT (What does this symbol know?)
|
|
533
|
+
Run \`context({name: "${args.target}"})\` → full 360° view:
|
|
534
|
+
- Incoming references: who calls/imports/uses this symbol
|
|
535
|
+
- Outgoing dependencies: what this symbol calls/imports/uses
|
|
536
|
+
- Identify any UNRESOLVED references (⚠ marker) — these are broken internal links
|
|
537
|
+
|
|
538
|
+
## STEP 6 — TEXT REFERENCE SEARCH (What does the rest of the codebase say?)
|
|
539
|
+
Run \`grep({pattern: "${args.target}"})\` → ALL text references across the project:
|
|
540
|
+
- Check config files for relevant settings
|
|
541
|
+
- Check route definitions for endpoint configuration
|
|
542
|
+
- Check templates for usage context
|
|
543
|
+
- Check documentation for intended behavior vs actual behavior
|
|
544
|
+
${args.error_description ? `\nAlso run \`grep({pattern: "${args.error_description.replace(/['"]/g, '')}"})\` → search for the error message itself — it might appear in error handling code, exceptions, or test fixtures.` : ''}
|
|
545
|
+
|
|
546
|
+
## STEP 7 — TYPE/INTERFACE ANALYSIS (If applicable)
|
|
547
|
+
Run \`get_type_hierarchy({name: "${args.target}"})\` → if this is a class/interface:
|
|
548
|
+
- What does it extend? (ancestors — behavior inherited)
|
|
549
|
+
- What extends it? (descendants — behavior propagated)
|
|
550
|
+
- If the bug is in base class behavior, all descendants are affected
|
|
551
|
+
|
|
552
|
+
## OUTPUT FORMAT — Debug Analysis
|
|
553
|
+
|
|
554
|
+
### 1. Execution Trace
|
|
555
|
+
Show the complete path from entrypoint to target symbol:
|
|
556
|
+
\`\`\`
|
|
557
|
+
EntryPoint (src/routes/users.ts:25)
|
|
558
|
+
→ [calls] AuthMiddleware.authenticate (src/middleware/auth.ts:12)
|
|
559
|
+
→ [calls] UserService.getUser (src/services/user.ts:45)
|
|
560
|
+
→ [calls] ${args.target} (file:line) ← TARGET
|
|
561
|
+
\`\`\`
|
|
562
|
+
For each step, note: file, line, role, potential failure points.
|
|
563
|
+
|
|
564
|
+
### 2. Dependency Chain
|
|
565
|
+
| Symbol | Relation | Role | Risk if Broken |
|
|
566
|
+
|---|---|---|---|
|
|
567
|
+
| CallerA [function] src/file.ts:10 | calls ${args.target} | entrypoint | HIGH |
|
|
568
|
+
| CallerB [method] src/file2.ts:30 | imports ${args.target} | utility | MEDIUM |
|
|
569
|
+
|
|
570
|
+
### 3. Affected Symbols (Blast Radius)
|
|
571
|
+
Organized by depth from impact():
|
|
572
|
+
- **Depth 1 (WILL BREAK):** list symbols
|
|
573
|
+
- **Depth 2 (LIKELY AFFECTED):** list symbols
|
|
574
|
+
- **Depth 3 (MAY NEED TESTING):** list symbols
|
|
575
|
+
|
|
576
|
+
### 4. Likely Root Causes (ranked by probability)
|
|
577
|
+
For each hypothesis:
|
|
578
|
+
1. **Hypothesis:** description of possible root cause
|
|
579
|
+
2. **Evidence:** from which tool output (trace step X, context incoming ref Y, grep match at file:line)
|
|
580
|
+
3. **Probability:** HIGH / MEDIUM / LOW
|
|
581
|
+
4. **How to Verify:** specific test or check to confirm/disprove
|
|
582
|
+
|
|
583
|
+
### 5. Suggested Fixes
|
|
584
|
+
For each root cause hypothesis:
|
|
585
|
+
- **Fix:** code change description
|
|
586
|
+
- **File:** path
|
|
587
|
+
- **Risk:** LOW / MEDIUM / HIGH (from impact() — how many dependents affected)
|
|
588
|
+
- **Test:** how to verify the fix works
|
|
589
|
+
- **Regression Risk:** what might break from impact() output
|
|
590
|
+
|
|
591
|
+
### 6. Recommended Next Steps
|
|
592
|
+
- [ ] Reproduce bug with specific test case
|
|
593
|
+
- [ ] Apply fix for most probable root cause
|
|
594
|
+
- [ ] Run \`test_impact({})\` to identify affected tests
|
|
595
|
+
- [ ] Run affected test suite
|
|
596
|
+
- [ ] Review fix with \`review_symbol({name: "${args.target}"})\`
|
|
597
|
+
|
|
598
|
+
Important: Rank root causes by probability — use evidence from each tool output. Never guess causes — cite specific tool outputs. The blast radius from impact() tells you the cost of being wrong — prioritize hypotheses that are easiest to verify with the least risk.
|
|
599
|
+
`,
|
|
600
|
+
},
|
|
601
|
+
}],
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
605
|
+
// Registry
|
|
606
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
607
|
+
const prompts = [
|
|
608
|
+
{ name: 'milens-planner', description: '5-step implementation planning: research codebase → analyze targets → predict impact → plan tests → produce final plan with step-by-step actions, risk levels, and success criteria', args: PLANNER_ARGS, handler: plannerHandler },
|
|
609
|
+
{ name: 'milens-reviewer', description: 'Comprehensive PR review workflow: scan risk scores → deep dive CRITICAL/HIGH symbols → detect dead code → find secrets, XSS, and tech debt → produce review report with merge verdict', args: REVIEWER_ARGS, handler: reviewerHandler },
|
|
610
|
+
{ name: 'milens-tester', description: 'Test-driven development workflow: identify coverage gaps → build test plans with mock strategies → implement >=3 test scenarios per symbol → verify test impact and coverage improvement', args: TESTER_ARGS, handler: testerHandler },
|
|
611
|
+
{ name: 'milens-architect', description: 'Architecture analysis: codebase overview → domain map → route inventory → execution trace → class hierarchy → coupling hotspots → refactoring suggestions with architecture scorecard', args: ARCHITECT_ARGS, handler: architectHandler },
|
|
612
|
+
{ name: 'milens-security', description: 'Security audit: scan hardcoded secrets → detect unicode/bidi attacks → find dangerous code patterns (eval, exec, child_process) → check data leakage (console.log) → OWASP-mapped report with fix recommendations', args: SECURITY_ARGS, handler: securityHandler },
|
|
613
|
+
{ name: 'milens-debugger', description: 'Root cause analysis: execution trace → blast radius → dependency paths → deep context → text references → ranked root cause hypotheses with suggested fixes and regression risk assessment', args: DEBUGGER_ARGS, handler: debuggerHandler },
|
|
614
|
+
];
|
|
615
|
+
export function registerAllPrompts(server) {
|
|
616
|
+
for (const prompt of prompts) {
|
|
617
|
+
server.prompt(prompt.name, prompt.description, prompt.args, prompt.handler);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
export const MILENS_PROMPT_NAMES = prompts.map(p => p.name);
|
|
621
|
+
export const MILENS_PLANNER_PROMPT = prompts[0];
|
|
622
|
+
export const MILENS_REVIEWER_PROMPT = prompts[1];
|
|
623
|
+
export const MILENS_TESTER_PROMPT = prompts[2];
|
|
624
|
+
export const MILENS_ARCHITECT_PROMPT = prompts[3];
|
|
625
|
+
export const MILENS_SECURITY_PROMPT = prompts[4];
|
|
626
|
+
export const MILENS_DEBUGGER_PROMPT = prompts[5];
|
|
627
|
+
//# sourceMappingURL=mcp-prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
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M,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AACjD,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAC/C,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAClD,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AACjD,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/server/mcp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/server/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/server/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,yCAAyC,CAAC;AA8WtF,wBAAgB,eAAe,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CA83D5D;AAID,wBAAsB,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIjE;AAID,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA+E9E"}
|