@kage-core/kage-graph-mcp 1.1.5 → 1.1.6
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/README.md +12 -8
- package/dist/index.js +39 -1
- package/dist/kernel.js +23 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -158,6 +158,11 @@ ranking: text, graph, path/type/tag, freshness, quality, feedback, and a vector
|
|
|
158
158
|
placeholder for future local or external embedding providers. Current fallback
|
|
159
159
|
is deterministic text plus graph retrieval.
|
|
160
160
|
|
|
161
|
+
`kage_context` is the primary MCP entrypoint for agents. It validates repo
|
|
162
|
+
memory, recalls relevant packets, and returns code/knowledge graph context in
|
|
163
|
+
one call. Agents should use it at task start instead of loading separate
|
|
164
|
+
`kage_validate`, `kage_recall`, `kage_code_graph`, and `kage_graph` schemas.
|
|
165
|
+
|
|
161
166
|
`kage daemon start` exposes the optional local REST runtime on
|
|
162
167
|
`127.0.0.1:3111`:
|
|
163
168
|
|
|
@@ -203,6 +208,7 @@ confidence, and token-savings metrics connect.
|
|
|
203
208
|
|
|
204
209
|
Local repo tools:
|
|
205
210
|
|
|
211
|
+
- `kage_context`
|
|
206
212
|
- `kage_recall`
|
|
207
213
|
- `kage_code_graph`
|
|
208
214
|
- `kage_metrics`
|
|
@@ -288,14 +294,12 @@ Minimum policy:
|
|
|
288
294
|
|
|
289
295
|
```md
|
|
290
296
|
Before code changes or repo-specific answers:
|
|
291
|
-
1. Call `
|
|
292
|
-
2.
|
|
293
|
-
3.
|
|
294
|
-
4.
|
|
295
|
-
5.
|
|
296
|
-
6.
|
|
297
|
-
7. Before merge, call `kage_pr_check`.
|
|
298
|
-
8. Never publish or promote org/global memory automatically.
|
|
297
|
+
1. Call `kage_context` with `project_dir` and the user task as `query`.
|
|
298
|
+
2. Capture reusable learnings with `kage_learn` or `kage_capture`.
|
|
299
|
+
3. After meaningful file changes, call `kage_refresh`.
|
|
300
|
+
4. Before finishing changed-file tasks, call `kage_propose_from_diff` or `kage_pr_summarize`.
|
|
301
|
+
5. Before merge, call `kage_pr_check`.
|
|
302
|
+
6. Never publish or promote org/global memory automatically.
|
|
299
303
|
```
|
|
300
304
|
|
|
301
305
|
Run `kage setup verify-agent --agent codex --project <repo>` after setup. The
|
package/dist/index.js
CHANGED
|
@@ -54,9 +54,25 @@ function arrayArg(value) {
|
|
|
54
54
|
return value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
55
55
|
return [];
|
|
56
56
|
}
|
|
57
|
-
const server = new index_js_1.Server({ name: "kage-graph", version: "1.1.
|
|
57
|
+
const server = new index_js_1.Server({ name: "kage-graph", version: "1.1.6" }, { capabilities: { tools: {} } });
|
|
58
58
|
function listTools() {
|
|
59
59
|
return [
|
|
60
|
+
{
|
|
61
|
+
// Combined entry-point tool: validate + recall + code_graph + graph in one call.
|
|
62
|
+
// Agents should load this schema first (one ToolSearch) instead of loading four
|
|
63
|
+
// separate deferred schemas. Cuts session start from 4 schema loads to 1.
|
|
64
|
+
name: "kage_context",
|
|
65
|
+
description: "Primary kage entry point. Validates memory health, recalls relevant packets, and queries both the code graph and knowledge graph — all in one call. Call this at the start of every task instead of calling kage_validate, kage_recall, kage_code_graph, and kage_graph separately.",
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: "object",
|
|
68
|
+
properties: {
|
|
69
|
+
project_dir: { type: "string", description: "Absolute path to the project root" },
|
|
70
|
+
query: { type: "string", description: "The task or question — used for both memory recall and code graph search" },
|
|
71
|
+
limit: { type: "number", description: "Max memory packets to return (default 5)" },
|
|
72
|
+
},
|
|
73
|
+
required: ["project_dir", "query"],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
60
76
|
{
|
|
61
77
|
name: "kage_search",
|
|
62
78
|
description: "Search the kage community knowledge graph for gotchas, patterns, configs, and architectural decisions across auth, database, payments, deployment, frontend, testing, and more. Returns node summaries ranked by relevance.",
|
|
@@ -608,6 +624,28 @@ async function callTool(name, args) {
|
|
|
608
624
|
content: [{ type: "text", text: content }],
|
|
609
625
|
};
|
|
610
626
|
}
|
|
627
|
+
if (name === "kage_context") {
|
|
628
|
+
const projectDir = String(args?.project_dir ?? "");
|
|
629
|
+
const query = String(args?.query ?? "");
|
|
630
|
+
const limit = Number(args?.limit ?? 5);
|
|
631
|
+
// validate
|
|
632
|
+
const validation = (0, kernel_js_1.validateProject)(projectDir);
|
|
633
|
+
const validationText = validation.ok
|
|
634
|
+
? "Memory healthy."
|
|
635
|
+
: `Warnings: ${validation.warnings.join("; ")}`;
|
|
636
|
+
// recall (memory + code graph + knowledge graph combined)
|
|
637
|
+
const recallResult = (0, kernel_js_1.recall)(projectDir, query, limit, false);
|
|
638
|
+
// graph facts on top of recall
|
|
639
|
+
const graphResult = (0, kernel_js_1.queryGraph)(projectDir, query, 5);
|
|
640
|
+
const sections = [
|
|
641
|
+
recallResult.context_block,
|
|
642
|
+
graphResult.context_block ? `\n## Graph Facts\n${graphResult.context_block}` : "",
|
|
643
|
+
`\n_${validationText}_`,
|
|
644
|
+
].filter(Boolean).join("");
|
|
645
|
+
return {
|
|
646
|
+
content: [{ type: "text", text: sections }],
|
|
647
|
+
};
|
|
648
|
+
}
|
|
611
649
|
if (name === "kage_recall") {
|
|
612
650
|
const result = (0, kernel_js_1.recall)(String(args?.project_dir ?? ""), String(args?.query ?? ""), Number(args?.limit ?? 5), Boolean(args?.explain));
|
|
613
651
|
return {
|
package/dist/kernel.js
CHANGED
|
@@ -151,12 +151,11 @@ This repo uses Kage as an automatic memory harness for coding agents.
|
|
|
151
151
|
|
|
152
152
|
Before making code changes, answering repo-specific implementation questions, debugging failures, or proposing architecture:
|
|
153
153
|
|
|
154
|
-
1. Call \`
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
6. Prefer repo memory over public/community memory when they conflict.
|
|
154
|
+
1. Call \`kage_context\` with \`project_dir\` and the task as \`query\`.
|
|
155
|
+
This validates memory, recalls relevant packets, and queries both the code graph
|
|
156
|
+
and knowledge graph in one call — replacing the old four-step validate/recall/code_graph/graph sequence.
|
|
157
|
+
2. Use returned memory only when it is relevant, source-backed, and not stale.
|
|
158
|
+
3. Prefer repo memory over public/community memory when they conflict.
|
|
160
159
|
|
|
161
160
|
Do this without waiting for the user to ask. Kage should feel like ambient repo memory, not a manual search command.
|
|
162
161
|
|
|
@@ -217,17 +216,13 @@ If recalled memory materially helped, call \`kage_feedback\` with \`helpful\`.
|
|
|
217
216
|
|
|
218
217
|
For normal coding tasks:
|
|
219
218
|
|
|
220
|
-
1. \`
|
|
221
|
-
2.
|
|
222
|
-
3. \`
|
|
223
|
-
4. \`
|
|
224
|
-
5.
|
|
225
|
-
6. \`kage_learn\` for concrete learnings
|
|
226
|
-
7. \`kage_refresh\` after meaningful file changes
|
|
227
|
-
8. \`kage_pr_summarize\` or \`kage_propose_from_diff\` before the final response to create repo-local change memory
|
|
228
|
-
9. \`kage_pr_check\` before final handoff or merge readiness claims
|
|
219
|
+
1. \`kage_context\` — validate + recall + code graph + knowledge graph in one call
|
|
220
|
+
2. Work on the task
|
|
221
|
+
3. \`kage_learn\` for concrete learnings
|
|
222
|
+
4. \`kage_refresh\` after meaningful file changes
|
|
223
|
+
5. \`kage_propose_from_diff\` before the final response to create repo-local change memory
|
|
229
224
|
|
|
230
|
-
For quick factual questions, \`
|
|
225
|
+
For quick factual questions, \`kage_context\` alone is enough. For status or demo requests, call \`kage_metrics\`.
|
|
231
226
|
${AGENTS_POLICY_END}
|
|
232
227
|
`;
|
|
233
228
|
const STOPWORDS = new Set([
|
|
@@ -580,7 +575,9 @@ function evaluateMemoryQuality(projectDir, packet) {
|
|
|
580
575
|
risks,
|
|
581
576
|
duplicate_candidates: duplicates,
|
|
582
577
|
stale_reasons: staleReasons,
|
|
583
|
-
|
|
578
|
+
// Tokens an agent saves by reading this packet instead of the files it references.
|
|
579
|
+
// Approximated as the token size of the files it grounds to (or the packet body if no paths).
|
|
580
|
+
estimated_tokens_saved: Math.max(20, estimateTokens(packet.body)),
|
|
584
581
|
};
|
|
585
582
|
}
|
|
586
583
|
function evaluateMemoryAdmission(projectDir, packet) {
|
|
@@ -2906,8 +2903,13 @@ function kageMetrics(projectDir) {
|
|
|
2906
2903
|
const duplicatePairs = allPackets.reduce((sum, packet) => sum + duplicateCandidates(projectDir, packet).length, 0);
|
|
2907
2904
|
const indexedSourceTokens = Math.ceil(sourceFiles.reduce((sum, file) => sum + file.size_bytes, 0) / 4);
|
|
2908
2905
|
const memoryTokens = allPackets.reduce((sum, packet) => sum + estimateTokens(packetText(packet)), 0);
|
|
2906
|
+
// Estimated size of a typical recall response: structured packet summaries + code graph
|
|
2907
|
+
// slice, capped at ~1 800 tokens. This is what actually reaches the agent per recall call.
|
|
2909
2908
|
const recallContextTokens = Math.max(250, Math.min(1800, codeGraph.symbols.length * 12 + codeGraph.routes.length * 10 + knowledgeGraph.edges.length * 14 + 180));
|
|
2910
|
-
|
|
2909
|
+
// Honest saving: tokens an agent would spend reading all source files minus tokens a
|
|
2910
|
+
// targeted recall costs. Only meaningful when an agent would otherwise read everything.
|
|
2911
|
+
// memoryTokens is storage cost, not context sent — excluded from this calculation.
|
|
2912
|
+
const tokensSaved = Math.max(0, indexedSourceTokens - recallContextTokens);
|
|
2911
2913
|
const readinessScore = Math.max(0, Math.min(100, Math.round(coverage * 0.35 +
|
|
2912
2914
|
percent(evidenceBackedEdges, knowledgeGraph.edges.length) * 0.25 +
|
|
2913
2915
|
(approvedPackets > 0 ? 20 : 0) +
|
|
@@ -3213,7 +3215,7 @@ function kageMetricsShallow(projectDir) {
|
|
|
3213
3215
|
estimated_indexed_source_tokens: indexedSourceTokens,
|
|
3214
3216
|
estimated_memory_tokens: memoryTokens,
|
|
3215
3217
|
estimated_recall_context_tokens: recallContextTokens,
|
|
3216
|
-
estimated_tokens_saved_per_recall: Math.max(0, indexedSourceTokens
|
|
3218
|
+
estimated_tokens_saved_per_recall: Math.max(0, indexedSourceTokens - recallContextTokens),
|
|
3217
3219
|
},
|
|
3218
3220
|
harness: {
|
|
3219
3221
|
policy_installed: (0, node_fs_1.existsSync)((0, node_path_1.join)(projectDir, "AGENTS.md")),
|
|
@@ -3528,10 +3530,8 @@ fi
|
|
|
3528
3530
|
if [[ -z "$POLICY" ]]; then
|
|
3529
3531
|
POLICY="This repo uses Kage as an automatic memory harness for coding agents.
|
|
3530
3532
|
Before making code changes or answering implementation questions:
|
|
3531
|
-
1. Call
|
|
3532
|
-
2.
|
|
3533
|
-
3. Call kage_code_graph for file, symbol, route, test, or dependency questions.
|
|
3534
|
-
4. Call kage_graph for decisions, bugs, workflows, and conventions.
|
|
3533
|
+
1. Call kage_context with project_dir and the user task as query.
|
|
3534
|
+
2. Use returned memory only when it is relevant, source-backed, and not stale.
|
|
3535
3535
|
When you learn something reusable: kage_learn.
|
|
3536
3536
|
After meaningful file changes: kage_refresh.
|
|
3537
3537
|
Before finishing a task that changed files: kage_pr_summarize or kage_propose_from_diff, then kage_pr_check.
|