atabey-mcp 0.0.10 → 0.0.11
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/dist/index.js
CHANGED
|
File without changes
|
|
@@ -26,16 +26,16 @@ export function handleReadFile(projectRoot, args) {
|
|
|
26
26
|
Metrics.logUsage(projectRoot, "@mcp", `read_file: ${args.path}`, tokens);
|
|
27
27
|
return { content: [{ type: "text", text: sliced }] };
|
|
28
28
|
}
|
|
29
|
-
//
|
|
30
|
-
const
|
|
31
|
-
if (lines.length >
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
Metrics.logUsage(projectRoot, "@mcp", `read_file: ${args.path} (truncated)`, tokens);
|
|
29
|
+
// ENFORCE TOKEN ECONOMY: Hard Limit for large files
|
|
30
|
+
const HARD_LIMIT_LINES = 500;
|
|
31
|
+
if (lines.length > HARD_LIMIT_LINES && (startLine === undefined || endLine === undefined)) {
|
|
32
|
+
const errMsg = `[TOKEN ECONOMY GUARD] File '${args.path}' is too large (${lines.length} lines). To prevent context overflow and token waste, you MUST provide both 'startLine' and 'endLine' parameters to read specific sections of this file.`;
|
|
33
|
+
Metrics.logError(projectRoot, "@mcp", `read_file: ${args.path} (blocked)`, errMsg);
|
|
35
34
|
return {
|
|
35
|
+
isError: true,
|
|
36
36
|
content: [{
|
|
37
37
|
type: "text",
|
|
38
|
-
text:
|
|
38
|
+
text: `[ERROR] ${errMsg}`
|
|
39
39
|
}]
|
|
40
40
|
};
|
|
41
41
|
}
|
|
@@ -13,6 +13,18 @@ export async function handleWriteFile(projectRoot, args) {
|
|
|
13
13
|
}
|
|
14
14
|
try {
|
|
15
15
|
const filePath = safePath(projectRoot, args.path);
|
|
16
|
+
// ENFORCE TOKEN ECONOMY: Prevent full-file rewrites of existing files
|
|
17
|
+
if (fs.existsSync(filePath)) {
|
|
18
|
+
const errMsg = `[TOKEN ECONOMY GUARD] The file '${args.path}' already exists. Overwriting entire existing files is FORBIDDEN to save tokens and prevent context drift. You MUST use 'patch_file' or 'replace_text' tools to make surgical edits.`;
|
|
19
|
+
Metrics.logError(projectRoot, "@mcp", `write_file: ${args.path} (blocked)`, errMsg);
|
|
20
|
+
return {
|
|
21
|
+
isError: true,
|
|
22
|
+
content: [{
|
|
23
|
+
type: "text",
|
|
24
|
+
text: `[ERROR] ${errMsg}`
|
|
25
|
+
}]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
16
28
|
const content = args.content;
|
|
17
29
|
// ENFORCE PERMISSION MATRIX
|
|
18
30
|
verifyWritePermission(projectRoot, args.path);
|
|
@@ -1,29 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { resolveFrameworkDir } from "../../utils/security.js";
|
|
1
|
+
import { Storage } from "../../utils/storage.js";
|
|
4
2
|
/**
|
|
5
|
-
* Extracts key insights from the
|
|
3
|
+
* Extracts key insights from the SQLite database to minimize token usage.
|
|
6
4
|
* Returns only the active phase, trace, and the last 5 decisions/tasks.
|
|
7
5
|
*/
|
|
8
|
-
export function handleGetMemoryInsights(
|
|
6
|
+
export function handleGetMemoryInsights(_projectRoot, _args) {
|
|
9
7
|
try {
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
const content = fs.readFileSync(memoryPath, "utf8");
|
|
16
|
-
const lines = content.split("\n");
|
|
17
|
-
const activePhase = lines.find(l => l.includes("**Phase:**"))?.split("**Phase:**")[1]?.trim() || "Unknown";
|
|
18
|
-
const activeTrace = lines.find(l => l.includes("**Trace ID:**"))?.split("**Trace ID:**")[1]?.trim() || "None";
|
|
19
|
-
// Find the last 5 history items (heuristic)
|
|
20
|
-
const historyStartIndex = lines.findIndex(l => l.toUpperCase().includes("HISTORY"));
|
|
8
|
+
const activePhase = Storage.getMetadata("phase") || "PHASE_0";
|
|
9
|
+
const activeTrace = Storage.getMetadata("traceId") || "None";
|
|
10
|
+
// Get the last 5 logs from SQLite
|
|
11
|
+
const recentLogs = Storage.getLogs().slice(0, 5);
|
|
21
12
|
let recentHistory = "No history found.";
|
|
22
|
-
if (
|
|
23
|
-
recentHistory =
|
|
24
|
-
.filter(l => l.trim().startsWith("-"))
|
|
25
|
-
.slice(-5)
|
|
26
|
-
.join("\n");
|
|
13
|
+
if (recentLogs.length > 0) {
|
|
14
|
+
recentHistory = recentLogs.map(log => `- [${log.agent}] ${log.action}: ${log.summary}`).join("\n");
|
|
27
15
|
}
|
|
28
16
|
const insights = `[MEMORY] **Memory Insights**\n- **Phase:** ${activePhase}\n- **Trace:** ${activeTrace}\n\n**Recent Actions:**\n${recentHistory}`;
|
|
29
17
|
return { content: [{ type: "text", text: insights }] };
|