@codemap-ai/core 0.2.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.
- package/LICENSE +21 -0
- package/dist/config.d.ts +40 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +229 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/agent-pack-doctor.d.ts +36 -0
- package/dist/lib/agent-pack-doctor.d.ts.map +1 -0
- package/dist/lib/agent-pack-doctor.js +325 -0
- package/dist/lib/agent-pack-doctor.js.map +1 -0
- package/dist/lib/agent-pack-installer.d.ts +35 -0
- package/dist/lib/agent-pack-installer.d.ts.map +1 -0
- package/dist/lib/agent-pack-installer.js +371 -0
- package/dist/lib/agent-pack-installer.js.map +1 -0
- package/dist/lib/agent-pack.d.ts +36 -0
- package/dist/lib/agent-pack.d.ts.map +1 -0
- package/dist/lib/agent-pack.js +119 -0
- package/dist/lib/agent-pack.js.map +1 -0
- package/dist/lib/agent-workflow.d.ts +37 -0
- package/dist/lib/agent-workflow.d.ts.map +1 -0
- package/dist/lib/agent-workflow.js +329 -0
- package/dist/lib/agent-workflow.js.map +1 -0
- package/dist/lib/api-types.d.ts +32 -0
- package/dist/lib/api-types.d.ts.map +1 -0
- package/dist/lib/api-types.js +3 -0
- package/dist/lib/api-types.js.map +1 -0
- package/dist/lib/auto-inject.d.ts +16 -0
- package/dist/lib/auto-inject.d.ts.map +1 -0
- package/dist/lib/auto-inject.js +80 -0
- package/dist/lib/auto-inject.js.map +1 -0
- package/dist/lib/bundled-runtime.d.ts +9 -0
- package/dist/lib/bundled-runtime.d.ts.map +1 -0
- package/dist/lib/bundled-runtime.js +20 -0
- package/dist/lib/bundled-runtime.js.map +1 -0
- package/dist/lib/codemap-api.d.ts +22 -0
- package/dist/lib/codemap-api.d.ts.map +1 -0
- package/dist/lib/codemap-api.js +74 -0
- package/dist/lib/codemap-api.js.map +1 -0
- package/dist/lib/import-health.d.ts +38 -0
- package/dist/lib/import-health.d.ts.map +1 -0
- package/dist/lib/import-health.js +186 -0
- package/dist/lib/import-health.js.map +1 -0
- package/dist/lib/local-index.d.ts +52 -0
- package/dist/lib/local-index.d.ts.map +1 -0
- package/dist/lib/local-index.js +262 -0
- package/dist/lib/local-index.js.map +1 -0
- package/dist/lib/markdown-fence.d.ts +8 -0
- package/dist/lib/markdown-fence.d.ts.map +1 -0
- package/dist/lib/markdown-fence.js +98 -0
- package/dist/lib/markdown-fence.js.map +1 -0
- package/dist/lib/mcp-auth.d.ts +39 -0
- package/dist/lib/mcp-auth.d.ts.map +1 -0
- package/dist/lib/mcp-auth.js +184 -0
- package/dist/lib/mcp-auth.js.map +1 -0
- package/dist/lib/monorepo-root.d.ts +7 -0
- package/dist/lib/monorepo-root.d.ts.map +1 -0
- package/dist/lib/monorepo-root.js +23 -0
- package/dist/lib/monorepo-root.js.map +1 -0
- package/dist/lib/onboarding.d.ts +5 -0
- package/dist/lib/onboarding.d.ts.map +1 -0
- package/dist/lib/onboarding.js +96 -0
- package/dist/lib/onboarding.js.map +1 -0
- package/dist/lib/open-url.d.ts +7 -0
- package/dist/lib/open-url.d.ts.map +1 -0
- package/dist/lib/open-url.js +38 -0
- package/dist/lib/open-url.js.map +1 -0
- package/dist/lib/regex-utils.d.ts +2 -0
- package/dist/lib/regex-utils.d.ts.map +1 -0
- package/dist/lib/regex-utils.js +4 -0
- package/dist/lib/regex-utils.js.map +1 -0
- package/dist/lib/server-instructions.d.ts +2 -0
- package/dist/lib/server-instructions.d.ts.map +1 -0
- package/dist/lib/server-instructions.js +34 -0
- package/dist/lib/server-instructions.js.map +1 -0
- package/dist/lib/session-context.d.ts +2 -0
- package/dist/lib/session-context.d.ts.map +1 -0
- package/dist/lib/session-context.js +40 -0
- package/dist/lib/session-context.js.map +1 -0
- package/dist/lib/session-tracker.d.ts +16 -0
- package/dist/lib/session-tracker.d.ts.map +1 -0
- package/dist/lib/session-tracker.js +32 -0
- package/dist/lib/session-tracker.js.map +1 -0
- package/dist/lib/sqlite-index-store.d.ts +165 -0
- package/dist/lib/sqlite-index-store.d.ts.map +1 -0
- package/dist/lib/sqlite-index-store.js +609 -0
- package/dist/lib/sqlite-index-store.js.map +1 -0
- package/dist/lib/tool-response.d.ts +97 -0
- package/dist/lib/tool-response.d.ts.map +1 -0
- package/dist/lib/tool-response.js +127 -0
- package/dist/lib/tool-response.js.map +1 -0
- package/dist/lib/uuid-schema.d.ts +8 -0
- package/dist/lib/uuid-schema.d.ts.map +1 -0
- package/dist/lib/uuid-schema.js +10 -0
- package/dist/lib/uuid-schema.js.map +1 -0
- package/dist/lib/workspace-git.d.ts +16 -0
- package/dist/lib/workspace-git.d.ts.map +1 -0
- package/dist/lib/workspace-git.js +53 -0
- package/dist/lib/workspace-git.js.map +1 -0
- package/dist/lib/workspace-project.d.ts +61 -0
- package/dist/lib/workspace-project.d.ts.map +1 -0
- package/dist/lib/workspace-project.js +231 -0
- package/dist/lib/workspace-project.js.map +1 -0
- package/dist/lib/workspace-resolver.d.ts +16 -0
- package/dist/lib/workspace-resolver.d.ts.map +1 -0
- package/dist/lib/workspace-resolver.js +59 -0
- package/dist/lib/workspace-resolver.js.map +1 -0
- package/dist/lib/workspace-zip.d.ts +12 -0
- package/dist/lib/workspace-zip.d.ts.map +1 -0
- package/dist/lib/workspace-zip.js +126 -0
- package/dist/lib/workspace-zip.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { AGENT_PACK_INDEX_URI, AGENT_PACK_INSTALL_URI, AGENT_PACK_SKILLS, AGENT_PACK_TEMPLATES, skillResourceUri, } from "./agent-pack.js";
|
|
2
|
+
export const MCP_FIRST_RULE_URI = "codemap://rules/mcp-first";
|
|
3
|
+
export const TASK_LIFECYCLE_RULE_URI = "codemap://rules/task-lifecycle";
|
|
4
|
+
export const SKILL_ROUTING_RULE_URI = "codemap://rules/skill-routing";
|
|
5
|
+
export const WORKFLOW_GATES_RULE_URI = "codemap://rules/workflow-gates";
|
|
6
|
+
export const VERIFICATION_BEFORE_COMPLETION_RULE_URI = "codemap://rules/verification-before-completion";
|
|
7
|
+
export const TASK_TYPES = [
|
|
8
|
+
"feature",
|
|
9
|
+
"bugfix",
|
|
10
|
+
"debugging",
|
|
11
|
+
"review",
|
|
12
|
+
"refactor",
|
|
13
|
+
"test",
|
|
14
|
+
"research",
|
|
15
|
+
];
|
|
16
|
+
export const WORKFLOW_PHASES = [
|
|
17
|
+
"orient",
|
|
18
|
+
"design",
|
|
19
|
+
"plan",
|
|
20
|
+
"implement",
|
|
21
|
+
"verify",
|
|
22
|
+
"finish",
|
|
23
|
+
];
|
|
24
|
+
export const DEFAULT_VERIFICATION_CHECKLIST = [
|
|
25
|
+
"Inspect uncommitted changes with diff(mode=\"working\").",
|
|
26
|
+
"Run the smallest relevant build or test command.",
|
|
27
|
+
"Refresh the local MCP index with refresh_local_index after local edits.",
|
|
28
|
+
"Decide whether cloud graph/insights need reimport.",
|
|
29
|
+
"Report verification results, skipped checks, and residual risk.",
|
|
30
|
+
];
|
|
31
|
+
export const WORKFLOW_ROUTES = {
|
|
32
|
+
feature: {
|
|
33
|
+
taskType: "feature",
|
|
34
|
+
description: "New capability, product behavior, route, API, workflow, or vague implementation request.",
|
|
35
|
+
requiredSkills: [
|
|
36
|
+
"brainstorming",
|
|
37
|
+
"writing-plans",
|
|
38
|
+
"executing-plans",
|
|
39
|
+
"verification-before-completion",
|
|
40
|
+
],
|
|
41
|
+
firstTools: ["explore_task"],
|
|
42
|
+
hardGates: [
|
|
43
|
+
"Do not edit production files before the design is approved.",
|
|
44
|
+
"After design approval, write an implementation plan before code changes.",
|
|
45
|
+
"Complete verification-before-completion before declaring done.",
|
|
46
|
+
],
|
|
47
|
+
requiredOutputs: ["Approved design summary", "Implementation plan", "Verification report"],
|
|
48
|
+
completionChecks: DEFAULT_VERIFICATION_CHECKLIST,
|
|
49
|
+
phases: ["orient", "design", "plan", "implement", "verify", "finish"],
|
|
50
|
+
},
|
|
51
|
+
bugfix: {
|
|
52
|
+
taskType: "bugfix",
|
|
53
|
+
description: "Known broken behavior with an expected correct behavior.",
|
|
54
|
+
requiredSkills: [
|
|
55
|
+
"symbol-level-debugging",
|
|
56
|
+
"test-driven-development",
|
|
57
|
+
"safe-edit-and-reimport",
|
|
58
|
+
"verification-before-completion",
|
|
59
|
+
],
|
|
60
|
+
firstTools: ["explore_task", "search_codebase", "symbol"],
|
|
61
|
+
hardGates: [
|
|
62
|
+
"Reproduce or identify the failing path before changing code.",
|
|
63
|
+
"Prefer a failing test before production changes when the repo has a matching test pattern.",
|
|
64
|
+
"Complete verification-before-completion before declaring done.",
|
|
65
|
+
],
|
|
66
|
+
requiredOutputs: ["Failure hypothesis", "Fix summary", "Verification report"],
|
|
67
|
+
completionChecks: DEFAULT_VERIFICATION_CHECKLIST,
|
|
68
|
+
phases: ["orient", "design", "implement", "verify", "finish"],
|
|
69
|
+
},
|
|
70
|
+
debugging: {
|
|
71
|
+
taskType: "debugging",
|
|
72
|
+
description: "Investigation, diagnosis, or explanation of confusing behavior.",
|
|
73
|
+
requiredSkills: [
|
|
74
|
+
"symbol-level-debugging",
|
|
75
|
+
"feature-area-investigation",
|
|
76
|
+
"interpreting-codemap-output",
|
|
77
|
+
],
|
|
78
|
+
firstTools: ["search_codebase", "symbol", "symbol"],
|
|
79
|
+
hardGates: [
|
|
80
|
+
"Do not patch before the likely root cause is grounded in CodeMap context.",
|
|
81
|
+
"Use symbol context and callers/usages before raw broad reads.",
|
|
82
|
+
],
|
|
83
|
+
requiredOutputs: ["Root-cause explanation", "Impacted files/symbols", "Suggested next action"],
|
|
84
|
+
completionChecks: ["Inspect relevant symbols/callers.", "State confidence and remaining unknowns."],
|
|
85
|
+
phases: ["orient", "design", "finish"],
|
|
86
|
+
},
|
|
87
|
+
review: {
|
|
88
|
+
taskType: "review",
|
|
89
|
+
description: "Code review, PR review, diff review, or risk assessment.",
|
|
90
|
+
requiredSkills: ["token-efficient-code-review", "interpreting-codemap-output"],
|
|
91
|
+
firstTools: ["diff", "symbol"],
|
|
92
|
+
hardGates: [
|
|
93
|
+
"Lead with findings by severity.",
|
|
94
|
+
"Use changed symbols and usages before summarizing broad context.",
|
|
95
|
+
],
|
|
96
|
+
requiredOutputs: ["Findings", "Open questions", "Test gaps"],
|
|
97
|
+
completionChecks: ["Inspect diff.", "Check usages for risky shared changes.", "Mention residual risk."],
|
|
98
|
+
phases: ["orient", "verify", "finish"],
|
|
99
|
+
},
|
|
100
|
+
refactor: {
|
|
101
|
+
taskType: "refactor",
|
|
102
|
+
description: "Behavior-preserving cleanup, symbol move, rename, or structural change.",
|
|
103
|
+
requiredSkills: [
|
|
104
|
+
"feature-area-investigation",
|
|
105
|
+
"safe-edit-and-reimport",
|
|
106
|
+
"verification-before-completion",
|
|
107
|
+
],
|
|
108
|
+
firstTools: ["find_related_files", "symbol", "diff"],
|
|
109
|
+
hardGates: [
|
|
110
|
+
"Confirm behavior-preserving scope before edits.",
|
|
111
|
+
"Use usages/callers before moving or renaming shared symbols.",
|
|
112
|
+
"Complete verification-before-completion before declaring done.",
|
|
113
|
+
],
|
|
114
|
+
requiredOutputs: ["Refactor scope", "Affected usages", "Verification report"],
|
|
115
|
+
completionChecks: DEFAULT_VERIFICATION_CHECKLIST,
|
|
116
|
+
phases: ["orient", "plan", "implement", "verify", "finish"],
|
|
117
|
+
},
|
|
118
|
+
test: {
|
|
119
|
+
taskType: "test",
|
|
120
|
+
description: "Add, repair, or improve tests.",
|
|
121
|
+
requiredSkills: ["test-driven-development", "verification-before-completion"],
|
|
122
|
+
firstTools: ["search_codebase", "symbol"],
|
|
123
|
+
hardGates: [
|
|
124
|
+
"Find existing test patterns before adding tests.",
|
|
125
|
+
"For bug coverage, confirm the test fails before the fix when feasible.",
|
|
126
|
+
],
|
|
127
|
+
requiredOutputs: ["Test target", "Test command", "Verification report"],
|
|
128
|
+
completionChecks: ["Run the targeted test command.", "Inspect diff.", "Refresh local index if files changed."],
|
|
129
|
+
phases: ["orient", "implement", "verify", "finish"],
|
|
130
|
+
},
|
|
131
|
+
research: {
|
|
132
|
+
taskType: "research",
|
|
133
|
+
description: "Read-only exploration, codebase explanation, feasibility analysis, or planning.",
|
|
134
|
+
requiredSkills: ["mcp-first-exploration", "interpreting-codemap-output"],
|
|
135
|
+
firstTools: ["explore_task", "find_related_files", "get_file"],
|
|
136
|
+
hardGates: [
|
|
137
|
+
"Prefer CodeMap summaries, rankings, and next steps before opening raw files.",
|
|
138
|
+
"Do not edit files for read-only research tasks.",
|
|
139
|
+
],
|
|
140
|
+
requiredOutputs: ["Relevant files/symbols", "Findings", "Recommended next step"],
|
|
141
|
+
completionChecks: ["Cite inspected CodeMap context.", "State confidence and unknowns."],
|
|
142
|
+
phases: ["orient", "finish"],
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
export const ARTIFACT_TEMPLATES = AGENT_PACK_TEMPLATES.map((template) => ({
|
|
146
|
+
id: template.id,
|
|
147
|
+
title: template.title,
|
|
148
|
+
path: template.path,
|
|
149
|
+
resourceUri: template.uri,
|
|
150
|
+
}));
|
|
151
|
+
export const AGENT_WORKFLOW_SUMMARY = [
|
|
152
|
+
"Use CodeMap MCP tools before raw file reads or grep.",
|
|
153
|
+
"For broad coding tasks, call explore_task first — it automatically runs keyword, edit-location, and semantic search in parallel.",
|
|
154
|
+
"For 'which files are related?' or 'what should I read?', call find_related_files — semantic similarity is a built-in signal.",
|
|
155
|
+
"For known keywords, files, symbols, or exports, call search_codebase.",
|
|
156
|
+
"For conceptual queries ('authentication flow', 'error handling') where exact names are unknown, call search_codebase(semantic=true).",
|
|
157
|
+
"After you have a shortlist, call get_file for outlines, then get_file for specific content or symbols.",
|
|
158
|
+
"Use symbol/symbol for symbol impact analysis.",
|
|
159
|
+
"Use diff after edits, then build/test as appropriate.",
|
|
160
|
+
"Call refresh_local_index after local edits; call reimport only when cloud/web indexing should refresh.",
|
|
161
|
+
"Read required CodeMap Agent Pack skills before implementing gated work.",
|
|
162
|
+
];
|
|
163
|
+
export const AGENT_WORKFLOW_SEQUENCE = [
|
|
164
|
+
"New session: check project-context resource. If no local index exists yet, call refresh_local_index first (no auth required).",
|
|
165
|
+
"Broad task: explore_task -> follow suggestedNextTools -> get_file. Semantic search runs automatically.",
|
|
166
|
+
"Related-file question: find_related_files(query/file_path/symbol_name) -> get_file -> get_file. Semantic signal is built in.",
|
|
167
|
+
"Narrow lookup by name: search_codebase -> get_file(include=[outline] or [symbols]).",
|
|
168
|
+
"Conceptual lookup (no exact name): search_codebase(semantic=true) -> get_file(include=[outline]).",
|
|
169
|
+
"Refactor/cleanup: symbol or symbol -> get_file(blast_radius if risky) -> diff.",
|
|
170
|
+
"Broad work: choose CodeMap exploration tools -> required skills -> design/plan gates -> implementation.",
|
|
171
|
+
"Verification: inspect diff, build/test, refresh_local_index, and decide whether cloud reimport is needed.",
|
|
172
|
+
];
|
|
173
|
+
export const SKILL_ROUTING_RULE_MARKDOWN = `# CodeMap Skill Routing
|
|
174
|
+
|
|
175
|
+
Choose the appropriate CodeMap context tool before broad implementation, debugging, review, refactor, testing, or research tasks.
|
|
176
|
+
|
|
177
|
+
## Routing Matrix
|
|
178
|
+
|
|
179
|
+
${Object.values(WORKFLOW_ROUTES)
|
|
180
|
+
.map((route) => `- **${route.taskType}** — ${route.requiredSkills
|
|
181
|
+
.map((skill) => `\`codemap-${skill}\``)
|
|
182
|
+
.join(", ")}. ${route.description}`)
|
|
183
|
+
.join("\n")}
|
|
184
|
+
|
|
185
|
+
## Mandatory Skill Reads
|
|
186
|
+
|
|
187
|
+
- New features and vague product work require \`codemap-brainstorming\`.
|
|
188
|
+
- Approved designs require \`codemap-writing-plans\`.
|
|
189
|
+
- Implementation from a plan requires \`codemap-executing-plans\`, unless the task is a strict TDD task.
|
|
190
|
+
- Bug fixes and tests should use \`codemap-test-driven-development\` when a test pattern exists.
|
|
191
|
+
- Completion of edited work requires \`codemap-verification-before-completion\`.
|
|
192
|
+
`;
|
|
193
|
+
export const WORKFLOW_GATES_RULE_MARKDOWN = `# CodeMap Workflow Gates
|
|
194
|
+
|
|
195
|
+
CodeMap Agent Pack uses Superpowers-style gates to keep agents from jumping into edits too early.
|
|
196
|
+
|
|
197
|
+
## Gates
|
|
198
|
+
|
|
199
|
+
1. **Orient** — The project-context resource is already loaded in your context — do NOT call \`get_project\` or \`list_projects\` unless the user explicitly asks for project or account info. If no local index exists yet, call \`refresh_local_index\` (no auth required). Then choose the narrowest CodeMap context tool: \`explore_task\` for broad unclear work, \`search_codebase\` for known names, \`find_related_files\` for related-file questions, or \`get_file\`/\`get_file\` for known paths.
|
|
200
|
+
2. **Design** — for features or vague tasks, complete brainstorming and get design approval before editing production files.
|
|
201
|
+
3. **Plan** — after design approval, write an implementation plan with exact files, steps, and verification commands.
|
|
202
|
+
4. **Implement** — follow the plan or TDD loop; keep changes scoped.
|
|
203
|
+
5. **Verify** — inspect diff, run relevant checks, refresh local index, and decide cloud reimport.
|
|
204
|
+
6. **Finish** — summarize changed behavior, verification, skipped checks, and residual risk.
|
|
205
|
+
|
|
206
|
+
Low-risk one-line fixes may use a lightweight design summary instead of a full spec, but they still require verification.
|
|
207
|
+
`;
|
|
208
|
+
export const VERIFICATION_BEFORE_COMPLETION_RULE_MARKDOWN = `# Verification Before Completion
|
|
209
|
+
|
|
210
|
+
Never declare edited work complete until the verification checklist is done or a skipped item is explicitly explained.
|
|
211
|
+
|
|
212
|
+
## Checklist
|
|
213
|
+
|
|
214
|
+
${DEFAULT_VERIFICATION_CHECKLIST.map((item) => `- ${item}`).join("\n")}
|
|
215
|
+
|
|
216
|
+
## Completion Summary
|
|
217
|
+
|
|
218
|
+
Final responses should include changed behavior, verification commands/results, and whether local index refresh or cloud reimport was performed.
|
|
219
|
+
`;
|
|
220
|
+
export const MCP_FIRST_RULE_MARKDOWN = `# MCP-First Code Exploration
|
|
221
|
+
|
|
222
|
+
When working in a CodeMap-indexed repository, prefer CodeMap MCP tools before raw file reads or grep.
|
|
223
|
+
|
|
224
|
+
## Tool Selection
|
|
225
|
+
|
|
226
|
+
Choose the tool based on the shape of the question:
|
|
227
|
+
|
|
228
|
+
1. \`explore_task\` — use first for broad tasks such as "fix bug X", "implement Y", or "investigate Z". It returns likely files, entrypoints, symbols, risks, recommended reads, and suggested next tools.
|
|
229
|
+
3. \`find_related_files\` — use when you already have an anchor file/symbol, or when the user asks "which files should I read?", "what is related to X?", or "what is the scope around X?".
|
|
230
|
+
4. \`search_codebase\` — use for known keywords, filenames, exports, or symbols. Pass \`semantic=true\` for conceptual queries where you do not know the exact symbol name (e.g. "authentication flow", "error handling logic").
|
|
231
|
+
5. \`get_file\` — fetch outlines for several candidate files in one call. Use after \`explore_task\`, \`find_related_files\`, or \`search_codebase\`.
|
|
232
|
+
6. \`get_file\` — read exact content only after you know what you need. Prefer \`include=["outline"]\` for map context and \`include=["symbols"]\` with \`symbol_names\` for function/class bodies.
|
|
233
|
+
7. \`symbol\` / \`symbol\` — use for symbol impact analysis. Use \`symbol\` when the symbol's file is known.
|
|
234
|
+
8. \`get_project_map\` — inspect folder structure when module layout is unclear.
|
|
235
|
+
9. \`diff\` — inspect uncommitted local changes (mode=working) or committed ref diffs (mode=ref).
|
|
236
|
+
10. Raw Read / grep — fallback only when MCP cannot answer, such as unindexed files, dynamic string access, or complex regex searches.
|
|
237
|
+
|
|
238
|
+
## Quick Decisions
|
|
239
|
+
|
|
240
|
+
- "Fix/investigate/implement" with unclear files -> \`explore_task\` (semantic runs automatically).
|
|
241
|
+
- "Which files are related?" -> \`find_related_files\` (semantic signal built in).
|
|
242
|
+
- Known symbol or filename -> \`search_codebase\`.
|
|
243
|
+
- Conceptual query, no exact name -> \`search_codebase(semantic=true)\`.
|
|
244
|
+
- Several candidate files -> \`get_file\`.
|
|
245
|
+
- Specific symbol body -> \`get_file(include=["symbols"], symbol_names=[...])\`.
|
|
246
|
+
- Who calls/imports this? -> \`symbol\` or \`symbol\`.
|
|
247
|
+
- After edits -> \`diff\`, build/test, then \`refresh_local_index\` when the local MCP index should refresh.
|
|
248
|
+
`;
|
|
249
|
+
export const TASK_LIFECYCLE_RULE_MARKDOWN = `# CodeMap Agent Task Lifecycle
|
|
250
|
+
|
|
251
|
+
## 1. Orient
|
|
252
|
+
|
|
253
|
+
- The project-context resource is already loaded in your context — skip \`get_project\` and \`list_projects\` unless the user explicitly asks for project or account info.
|
|
254
|
+
- Use \`explore_task\`, \`find_related_files\`, or \`search_codebase\` according to the task shape.
|
|
255
|
+
|
|
256
|
+
## 2. Read Deliberately
|
|
257
|
+
|
|
258
|
+
- Use \`get_file\` to survey multiple outlines.
|
|
259
|
+
- Use \`get_file(include=["outline"])\` before full content for large/unknown files.
|
|
260
|
+
- Use \`get_file(include=["symbols"], symbol_names=[...])\` for exact function/class bodies.
|
|
261
|
+
|
|
262
|
+
## 3. Edit Safely
|
|
263
|
+
|
|
264
|
+
- Keep changes scoped to the task.
|
|
265
|
+
- Follow local repo patterns.
|
|
266
|
+
- Do not rewrite unrelated files or revert user changes.
|
|
267
|
+
- For database changes, prefer schema-first workflows and generated migrations.
|
|
268
|
+
|
|
269
|
+
## 4. Verify
|
|
270
|
+
|
|
271
|
+
- Run the smallest sufficient build/test.
|
|
272
|
+
- Build shared packages before dependents when applicable.
|
|
273
|
+
- Use \`diff\` to confirm changed files.
|
|
274
|
+
|
|
275
|
+
## 5. Refresh Index
|
|
276
|
+
|
|
277
|
+
- Use \`refresh_local_index\` after local edits to refresh the MCP SQLite index without cloud access.
|
|
278
|
+
- Use \`reimport\` only when the cloud index, web graph, or insights should refresh.
|
|
279
|
+
|
|
280
|
+
## 6. Final Response
|
|
281
|
+
|
|
282
|
+
- Summarize what changed.
|
|
283
|
+
- Mention verification results.
|
|
284
|
+
- Call out blockers, skipped tests, or unrelated dirty files.
|
|
285
|
+
`;
|
|
286
|
+
export function buildAgentWorkflowMarkdown() {
|
|
287
|
+
return [
|
|
288
|
+
"# CodeMap MCP Agent Workflow",
|
|
289
|
+
"",
|
|
290
|
+
"Use this guidance before exploring or editing a CodeMap-indexed repository.",
|
|
291
|
+
"",
|
|
292
|
+
"## Summary",
|
|
293
|
+
...AGENT_WORKFLOW_SUMMARY.map((item) => `- ${item}`),
|
|
294
|
+
"",
|
|
295
|
+
"## Recommended Sequence",
|
|
296
|
+
...AGENT_WORKFLOW_SEQUENCE.map((item, index) => `${index + 1}. ${item}`),
|
|
297
|
+
"",
|
|
298
|
+
"## Rule Resources",
|
|
299
|
+
`- ${MCP_FIRST_RULE_URI}`,
|
|
300
|
+
`- ${TASK_LIFECYCLE_RULE_URI}`,
|
|
301
|
+
`- ${SKILL_ROUTING_RULE_URI}`,
|
|
302
|
+
`- ${WORKFLOW_GATES_RULE_URI}`,
|
|
303
|
+
`- ${VERIFICATION_BEFORE_COMPLETION_RULE_URI}`,
|
|
304
|
+
`- ${AGENT_PACK_INDEX_URI}`,
|
|
305
|
+
`- ${AGENT_PACK_INSTALL_URI}`,
|
|
306
|
+
"",
|
|
307
|
+
"## Agent Pack Skills",
|
|
308
|
+
...AGENT_PACK_SKILLS.map((skill) => `- ${skillResourceUri(skill)}`),
|
|
309
|
+
"",
|
|
310
|
+
"## Workflow Routing",
|
|
311
|
+
...Object.values(WORKFLOW_ROUTES).map((route) => `- ${route.taskType}: ${route.requiredSkills
|
|
312
|
+
.map((skill) => skillResourceUri(skill))
|
|
313
|
+
.join(", ")}`),
|
|
314
|
+
"",
|
|
315
|
+
"## Artifact Templates",
|
|
316
|
+
...ARTIFACT_TEMPLATES.map((template) => `- ${template.resourceUri} — ${template.title}`),
|
|
317
|
+
"",
|
|
318
|
+
MCP_FIRST_RULE_MARKDOWN,
|
|
319
|
+
"",
|
|
320
|
+
TASK_LIFECYCLE_RULE_MARKDOWN,
|
|
321
|
+
"",
|
|
322
|
+
SKILL_ROUTING_RULE_MARKDOWN,
|
|
323
|
+
"",
|
|
324
|
+
WORKFLOW_GATES_RULE_MARKDOWN,
|
|
325
|
+
"",
|
|
326
|
+
VERIFICATION_BEFORE_COMPLETION_RULE_MARKDOWN,
|
|
327
|
+
].join("\n");
|
|
328
|
+
}
|
|
329
|
+
//# sourceMappingURL=agent-workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-workflow.js","sourceRoot":"","sources":["../../src/lib/agent-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,oBAAoB,EAEpB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AAC9D,MAAM,CAAC,MAAM,uBAAuB,GAAG,gCAAgC,CAAC;AACxE,MAAM,CAAC,MAAM,sBAAsB,GAAG,+BAA+B,CAAC;AACtE,MAAM,CAAC,MAAM,uBAAuB,GAAG,gCAAgC,CAAC;AACxE,MAAM,CAAC,MAAM,uCAAuC,GAClD,gDAAgD,CAAC;AAEnD,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,SAAS;IACT,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,UAAU;IACV,MAAM;IACN,UAAU;CACF,CAAC;AAIX,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,WAAW;IACX,QAAQ;IACR,QAAQ;CACA,CAAC;AAeX,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,0DAA0D;IAC1D,kDAAkD;IAClD,yEAAyE;IACzE,oDAAoD;IACpD,iEAAiE;CAClE,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAyC;IACnE,OAAO,EAAE;QACP,QAAQ,EAAE,SAAS;QACnB,WAAW,EAAE,0FAA0F;QACvG,cAAc,EAAE;YACd,eAAe;YACf,eAAe;YACf,iBAAiB;YACjB,gCAAgC;SACjC;QACD,UAAU,EAAE,CAAC,cAAc,CAAC;QAC5B,SAA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BAAsB,EAAE;QAC7B,EAAE;QACF,sBAAsB;QACtB,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;QACnE,EAAE;QACF,qBAAqB;QACrB,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,GAAG,CACnC,CAAC,KAAK,EAAE,EAAE,CACR,KAAK,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,cAAc;aACzC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;aACvC,IAAI,CAAC,IAAI,CAAC,EAAE,CAClB;QACD,EAAE;QACF,uBAAuB;QACvB,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,KAAK,QAAQ,CAAC,WAAW,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC;QACxF,EAAE;QACF,uBAAuB;QACvB,EAAE;QACF,4BAA4B;QAC5B,EAAE;QACF,2BAA2B;QAC3B,EAAE;QACF,4BAA4B;QAC5B,EAAE;QACF,4CAA4C;KAC7C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Shared response types for the CodeMap API used across MCP tools. */
|
|
2
|
+
import type { Project, ProjectAnalysisSummary, ProjectFileBlastRadius, ProjectFileContent, ProjectFileContentKind, ProjectFileContentStatus, ProjectImport, ProjectImportParseStatus, ProjectImportStatus, ProjectMapInsightsResponse, ProjectMapSearchExportResult, ProjectMapSearchFileResult, ProjectMapSearchResponse, ProjectMapSearchSymbolResult } from "@codemap-ai/shared";
|
|
3
|
+
export type { EditLocationConfidence, EditLocationNextTool, EditLocationReadInclude, EditLocationReadPlan, EditLocationSuggestion, EditLocationSymbol, EditLocationsResponse, FileReparseResult, GithubRepository, GitlabRepository, GithubStatus, Project, ProjectFileContent, ProjectImport, ProjectMapSnapshot, ProjectMapTreeNode, ProjectSourceImportResult, SymbolCaller, SymbolOccurrenceUsage, SymbolUsageConfidence, SymbolUsageRange, SymbolUsageTarget, SymbolUsagesResponse, WorkspaceDetail, } from "@codemap-ai/shared";
|
|
4
|
+
export type ImportStatus = ProjectImportStatus;
|
|
5
|
+
export type ParseStatus = ProjectImportParseStatus;
|
|
6
|
+
export type ProjectDetail = Project;
|
|
7
|
+
export type ProjectImportDetail = ProjectImport;
|
|
8
|
+
export type TriggerImportResult = ProjectImport;
|
|
9
|
+
export type FileContentStatus = ProjectFileContentStatus;
|
|
10
|
+
export type FileContentKind = ProjectFileContentKind;
|
|
11
|
+
export type FileContent = ProjectFileContent;
|
|
12
|
+
export type SearchFileResult = ProjectMapSearchFileResult;
|
|
13
|
+
export type SearchSymbolResult = ProjectMapSearchSymbolResult;
|
|
14
|
+
export type SearchExportResult = ProjectMapSearchExportResult;
|
|
15
|
+
export type CodebaseSearchResponse = ProjectMapSearchResponse;
|
|
16
|
+
export type SemanticSearchResult = {
|
|
17
|
+
path: string;
|
|
18
|
+
symbolName?: string;
|
|
19
|
+
chunkType: string;
|
|
20
|
+
startLine?: number;
|
|
21
|
+
endLine?: number;
|
|
22
|
+
score: number;
|
|
23
|
+
snippet?: string;
|
|
24
|
+
};
|
|
25
|
+
export type BlastRadius = ProjectFileBlastRadius;
|
|
26
|
+
export type InsightsFileEntry = ProjectMapInsightsResponse["topFilesByImportCount"][number];
|
|
27
|
+
export type InsightsFolderEntry = ProjectMapInsightsResponse["topFoldersBySourceFileCount"][number];
|
|
28
|
+
export type InsightsEntryLikeFile = ProjectMapInsightsResponse["entryLikeFiles"][number];
|
|
29
|
+
export type InsightsCycleCandidate = ProjectMapInsightsResponse["circularDependencyCandidates"][number];
|
|
30
|
+
export type ProjectInsightsSummary = ProjectMapInsightsResponse;
|
|
31
|
+
export type ProjectAnalysisSummaryResponse = ProjectAnalysisSummary;
|
|
32
|
+
//# sourceMappingURL=api-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-types.d.ts","sourceRoot":"","sources":["../../src/lib/api-types.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAEvE,OAAO,KAAK,EACV,OAAO,EACP,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,aAAa,EACb,wBAAwB,EACxB,mBAAmB,EACnB,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,wBAAwB,EACxB,4BAA4B,EAC7B,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EACV,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,YAAY,EACZ,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAC/C,MAAM,MAAM,WAAW,GAAG,wBAAwB,CAAC;AACnD,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC;AACpC,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAChD,MAAM,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAAG,wBAAwB,CAAC;AACzD,MAAM,MAAM,eAAe,GAAG,sBAAsB,CAAC;AACrD,MAAM,MAAM,WAAW,GAAG,kBAAkB,CAAC;AAE7C,MAAM,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAC1D,MAAM,MAAM,kBAAkB,GAAG,4BAA4B,CAAC;AAC9D,MAAM,MAAM,kBAAkB,GAAG,4BAA4B,CAAC;AAC9D,MAAM,MAAM,sBAAsB,GAAG,wBAAwB,CAAC;AAE9D,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,sBAAsB,CAAC;AAEjD,MAAM,MAAM,iBAAiB,GAC3B,0BAA0B,CAAC,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAC9D,MAAM,MAAM,mBAAmB,GAC7B,0BAA0B,CAAC,6BAA6B,CAAC,CAAC,MAAM,CAAC,CAAC;AACpE,MAAM,MAAM,qBAAqB,GAC/B,0BAA0B,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AACvD,MAAM,MAAM,sBAAsB,GAChC,0BAA0B,CAAC,8BAA8B,CAAC,CAAC,MAAM,CAAC,CAAC;AACrE,MAAM,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAChE,MAAM,MAAM,8BAA8B,GAAG,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-types.js","sourceRoot":"","sources":["../../src/lib/api-types.ts"],"names":[],"mappings":"AAAA,uEAAuE"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
type DetectedEditor = "claude" | "cursor" | "copilot" | "gemini" | "codex" | null;
|
|
3
|
+
/**
|
|
4
|
+
* Detect which AI tool is connecting via:
|
|
5
|
+
* 1. MCP clientInfo.name from the initialize handshake (most reliable)
|
|
6
|
+
* 2. Environment variables as fallback
|
|
7
|
+
*/
|
|
8
|
+
export declare function detectEditor(server: McpServer): DetectedEditor;
|
|
9
|
+
/**
|
|
10
|
+
* Auto-inject agent rules for the detected editor on first connect.
|
|
11
|
+
* Idempotent via .codemap-injected marker file.
|
|
12
|
+
* Non-fatal if detection or injection fails.
|
|
13
|
+
*/
|
|
14
|
+
export declare function autoInjectRules(server: McpServer, cwd: string): Promise<void>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=auto-inject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-inject.d.ts","sourceRoot":"","sources":["../../src/lib/auto-inject.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,KAAK,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,CAAC;AA4BlF;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,cAAc,CAQ9D;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BnF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { installAgentPack } from "./agent-pack-installer.js";
|
|
4
|
+
// Known MCP client name patterns (case-insensitive substring match)
|
|
5
|
+
const CLIENT_NAME_MAP = [
|
|
6
|
+
{ pattern: /claude/i, target: "claude" },
|
|
7
|
+
{ pattern: /cursor/i, target: "cursor" },
|
|
8
|
+
{ pattern: /copilot|github/i, target: "copilot" },
|
|
9
|
+
{ pattern: /gemini|google/i, target: "gemini" },
|
|
10
|
+
{ pattern: /codex|openai|chatgpt/i, target: "codex" },
|
|
11
|
+
];
|
|
12
|
+
function detectFromClientName(name) {
|
|
13
|
+
if (!name)
|
|
14
|
+
return null;
|
|
15
|
+
for (const { pattern, target } of CLIENT_NAME_MAP) {
|
|
16
|
+
if (pattern.test(name))
|
|
17
|
+
return target;
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
function detectFromEnv() {
|
|
22
|
+
if (process.env.CLAUDE_CODE || process.env.CLAUDE_MCP_SERVER_VERSION || process.env.ANTHROPIC_MCP_SERVER)
|
|
23
|
+
return "claude";
|
|
24
|
+
if (process.env.CURSOR_MCP || process.env.CURSOR_EDITOR)
|
|
25
|
+
return "cursor";
|
|
26
|
+
if (process.env.GITHUB_COPILOT_MCP || process.env.GITHUB_COPILOT)
|
|
27
|
+
return "copilot";
|
|
28
|
+
if (process.env.GOOGLE_GEMINI_MCP || process.env.GEMINI_API_KEY)
|
|
29
|
+
return "gemini";
|
|
30
|
+
if (process.env.OPENAI_MCP || process.env.CODEX_MCP)
|
|
31
|
+
return "codex";
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Detect which AI tool is connecting via:
|
|
36
|
+
* 1. MCP clientInfo.name from the initialize handshake (most reliable)
|
|
37
|
+
* 2. Environment variables as fallback
|
|
38
|
+
*/
|
|
39
|
+
export function detectEditor(server) {
|
|
40
|
+
// Primary: clientInfo from MCP protocol (available after server.connect())
|
|
41
|
+
const clientInfo = server.server.getClientVersion();
|
|
42
|
+
const fromProtocol = detectFromClientName(clientInfo?.name);
|
|
43
|
+
if (fromProtocol)
|
|
44
|
+
return fromProtocol;
|
|
45
|
+
// Fallback: environment variables
|
|
46
|
+
return detectFromEnv();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Auto-inject agent rules for the detected editor on first connect.
|
|
50
|
+
* Idempotent via .codemap-injected marker file.
|
|
51
|
+
* Non-fatal if detection or injection fails.
|
|
52
|
+
*/
|
|
53
|
+
export async function autoInjectRules(server, cwd) {
|
|
54
|
+
const editor = detectEditor(server);
|
|
55
|
+
const clientInfo = server.server.getClientVersion();
|
|
56
|
+
const clientName = clientInfo?.name ?? "(unknown)";
|
|
57
|
+
if (!editor) {
|
|
58
|
+
process.stderr.write(`[CodeMap] Client detected: "${clientName}" — no matching editor target, skipping auto-inject.\n`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
// Idempotent: skip if already injected
|
|
62
|
+
const markerFile = path.join(cwd, ".codemap-injected");
|
|
63
|
+
try {
|
|
64
|
+
const marker = await import("node:fs/promises").then((fs) => fs.readFile(markerFile, "utf-8"));
|
|
65
|
+
if (marker.includes(editor))
|
|
66
|
+
return; // Already injected for this editor
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Marker not found or unreadable — proceed
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
await installAgentPack({ target: editor, cwd, force: false });
|
|
73
|
+
await writeFile(markerFile, `${editor}\n${clientName}\n${new Date().toISOString()}\n`, "utf-8");
|
|
74
|
+
process.stderr.write(`[CodeMap] Auto-injected agent rules for ${editor} (client: "${clientName}").\n`);
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
process.stderr.write(`[CodeMap] Auto-inject failed (non-fatal): ${err instanceof Error ? err.message : String(err)}\n`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=auto-inject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-inject.js","sourceRoot":"","sources":["../../src/lib/auto-inject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAI7D,oEAAoE;AACpE,MAAM,eAAe,GAAuD;IAC1E,EAAE,OAAO,EAAE,SAAS,EAAgB,MAAM,EAAE,QAAQ,EAAG;IACvD,EAAE,OAAO,EAAE,SAAS,EAAgB,MAAM,EAAE,QAAQ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ChG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,2CAA2C,MAAM,cAAc,UAAU,OAAO,CAAC,CAAC;IACzG,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,6CAA6C,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAClG,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the package root directory.
|
|
3
|
+
*
|
|
4
|
+
* Works in both source (tsx) and bundled (tsup dist/) runtimes.
|
|
5
|
+
* Pass the caller's own `import.meta.url` so the result is relative to the
|
|
6
|
+
* actual file location.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getPackageRoot(callerImportMetaUrl: string): string;
|
|
9
|
+
//# sourceMappingURL=bundled-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundled-runtime.d.ts","sourceRoot":"","sources":["../../src/lib/bundled-runtime.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAWlE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
/**
|
|
4
|
+
* Returns the package root directory.
|
|
5
|
+
*
|
|
6
|
+
* Works in both source (tsx) and bundled (tsup dist/) runtimes.
|
|
7
|
+
* Pass the caller's own `import.meta.url` so the result is relative to the
|
|
8
|
+
* actual file location.
|
|
9
|
+
*/
|
|
10
|
+
export function getPackageRoot(callerImportMetaUrl) {
|
|
11
|
+
const callerDir = path.dirname(fileURLToPath(callerImportMetaUrl));
|
|
12
|
+
// Source (tsx): caller is somewhere under <pkg>/src/… → go up to src/ then one more.
|
|
13
|
+
const srcIdx = callerDir.lastIndexOf(`${path.sep}src${path.sep}`);
|
|
14
|
+
if (srcIdx !== -1) {
|
|
15
|
+
return path.resolve(callerDir.slice(0, srcIdx));
|
|
16
|
+
}
|
|
17
|
+
// Bundled (tsup): caller is at <pkg>/dist/ → go up one level.
|
|
18
|
+
return path.resolve(callerDir, "..");
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=bundled-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundled-runtime.js","sourceRoot":"","sources":["../../src/lib/bundled-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,mBAA2B;IACxD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAEnE,qFAAqF;IACrF,MAAM,MAAM,GAAG,SAAS,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAClE,IAAI,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,8DAA8D;IAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { McpServerConfig } from "../config.js";
|
|
2
|
+
type RequestOptions = {
|
|
3
|
+
method?: "GET" | "POST" | "PATCH" | "DELETE";
|
|
4
|
+
body?: unknown;
|
|
5
|
+
query?: Record<string, string | undefined>;
|
|
6
|
+
authRequired?: boolean;
|
|
7
|
+
};
|
|
8
|
+
type UploadOptions = {
|
|
9
|
+
query?: Record<string, string | undefined>;
|
|
10
|
+
authRequired?: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Creates a typed API client bound to a MCP server config.
|
|
14
|
+
* All methods throw on HTTP errors — callers should wrap with `withToolError`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createCodeMapClient(config: McpServerConfig): {
|
|
17
|
+
request: <T>(path: string, options?: RequestOptions) => Promise<T>;
|
|
18
|
+
upload: <T>(path: string, buffer: Buffer, options?: UploadOptions) => Promise<T>;
|
|
19
|
+
};
|
|
20
|
+
export type CodeMapClient = ReturnType<typeof createCodeMapClient>;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=codemap-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codemap-api.d.ts","sourceRoot":"","sources":["../../src/lib/codemap-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,KAAK,cAAc,GAAG;IACpB,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC7C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe;cAqClC,CAAC,QAAQ,MAAM,YAAY,cAAc,KAAG,OAAO,CAAC,CAAC,CAAC;aAyBvD,CAAC,QACf,MAAM,UACJ,MAAM,YACJ,aAAa,KACtB,OAAO,CAAC,CAAC,CAAC;EAyBd;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a typed API client bound to a MCP server config.
|
|
3
|
+
* All methods throw on HTTP errors — callers should wrap with `withToolError`.
|
|
4
|
+
*/
|
|
5
|
+
export function createCodeMapClient(config) {
|
|
6
|
+
function buildUrl(path, query) {
|
|
7
|
+
const url = new URL(path, config.apiUrl);
|
|
8
|
+
for (const [key, value] of Object.entries(query ?? {})) {
|
|
9
|
+
if (value !== undefined)
|
|
10
|
+
url.searchParams.set(key, value);
|
|
11
|
+
}
|
|
12
|
+
return url;
|
|
13
|
+
}
|
|
14
|
+
function buildAuthHeaders(extra) {
|
|
15
|
+
const headers = { ...extra };
|
|
16
|
+
if (config.apiToken) {
|
|
17
|
+
headers["x-api-key"] = config.apiToken;
|
|
18
|
+
headers["Authorization"] = `Bearer ${config.apiToken}`;
|
|
19
|
+
}
|
|
20
|
+
return headers;
|
|
21
|
+
}
|
|
22
|
+
async function handleResponse(response) {
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
const body = await response.text().catch(() => "");
|
|
25
|
+
throw new Error(`CodeMap API returned ${response.status} ${response.statusText}. ${body}`.trim());
|
|
26
|
+
}
|
|
27
|
+
const json = (await response.json());
|
|
28
|
+
if (json.data === undefined)
|
|
29
|
+
throw new Error("Unexpected response from API.");
|
|
30
|
+
return json.data;
|
|
31
|
+
}
|
|
32
|
+
function checkAuth(required) {
|
|
33
|
+
if (required && !config.apiToken) {
|
|
34
|
+
throw new Error("Not authenticated. Run `codemap login`.");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async function request(path, options) {
|
|
38
|
+
checkAuth(options?.authRequired);
|
|
39
|
+
const url = buildUrl(path, options?.query);
|
|
40
|
+
const hasBody = options?.body !== undefined;
|
|
41
|
+
const headers = buildAuthHeaders(hasBody ? { "Content-Type": "application/json" } : undefined);
|
|
42
|
+
let response;
|
|
43
|
+
try {
|
|
44
|
+
response = await fetch(url.toString(), {
|
|
45
|
+
method: options?.method ?? "GET",
|
|
46
|
+
headers,
|
|
47
|
+
body: hasBody ? JSON.stringify(options.body) : undefined,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw new Error(`Failed to reach CodeMap API at ${config.apiUrl}. ${error instanceof Error ? error.message : String(error)}`);
|
|
52
|
+
}
|
|
53
|
+
return handleResponse(response);
|
|
54
|
+
}
|
|
55
|
+
async function upload(path, buffer, options) {
|
|
56
|
+
checkAuth(options?.authRequired);
|
|
57
|
+
const url = buildUrl(path, options?.query);
|
|
58
|
+
const headers = buildAuthHeaders({ "Content-Type": "application/zip" });
|
|
59
|
+
let response;
|
|
60
|
+
try {
|
|
61
|
+
response = await fetch(url.toString(), {
|
|
62
|
+
method: "POST",
|
|
63
|
+
headers,
|
|
64
|
+
body: Buffer.from(buffer),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
throw new Error(`Failed to reach CodeMap API at ${config.apiUrl}. ${error instanceof Error ? error.message : String(error)}`);
|
|
69
|
+
}
|
|
70
|
+
return handleResponse(response);
|
|
71
|
+
}
|
|
72
|
+
return { request, upload };
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=codemap-api.js.map
|