atabey-mcp 0.0.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/dist/constants.js +64 -0
- package/dist/index.js +119 -0
- package/dist/tools/control_plane/locking.js +82 -0
- package/dist/tools/control_plane/registry.js +34 -0
- package/dist/tools/definitions.js +290 -0
- package/dist/tools/file_system/batch_surgical_edit.js +59 -0
- package/dist/tools/file_system/patch_file.js +29 -0
- package/dist/tools/file_system/read_file.js +51 -0
- package/dist/tools/file_system/replace_text.js +45 -0
- package/dist/tools/file_system/write_file.js +38 -0
- package/dist/tools/framework/audit_deps.js +41 -0
- package/dist/tools/framework/get_status.js +5 -0
- package/dist/tools/framework/orchestrate.js +5 -0
- package/dist/tools/framework/run_tests.js +27 -0
- package/dist/tools/framework/update_contract_hash.js +5 -0
- package/dist/tools/framework/update_memory.js +8 -0
- package/dist/tools/index.js +60 -0
- package/dist/tools/memory/get_insights.js +34 -0
- package/dist/tools/memory/read_memory.js +28 -0
- package/dist/tools/messaging/log_action.js +22 -0
- package/dist/tools/messaging/send_message.js +94 -0
- package/dist/tools/observability/check_ports.js +26 -0
- package/dist/tools/observability/get_health.js +19 -0
- package/dist/tools/quality/check_lint.js +30 -0
- package/dist/tools/search/get_gaps.js +48 -0
- package/dist/tools/search/get_map.js +43 -0
- package/dist/tools/search/grep_search.js +75 -0
- package/dist/tools/search/list_dir.js +28 -0
- package/dist/tools/shell/run_command.js +56 -0
- package/dist/tools/types.js +1 -0
- package/dist/utils/cli.js +59 -0
- package/dist/utils/compliance.js +78 -0
- package/dist/utils/fs.js +44 -0
- package/dist/utils/metrics.js +56 -0
- package/dist/utils/security.js +60 -0
- package/package.json +26 -0
- package/src/constants.ts +78 -0
- package/src/declarations.d.ts +17 -0
- package/src/index.ts +144 -0
- package/src/tools/control_plane/locking.ts +89 -0
- package/src/tools/control_plane/registry.ts +38 -0
- package/src/tools/definitions.ts +292 -0
- package/src/tools/file_system/batch_surgical_edit.ts +79 -0
- package/src/tools/file_system/patch_file.ts +39 -0
- package/src/tools/file_system/read_file.ts +58 -0
- package/src/tools/file_system/replace_text.ts +54 -0
- package/src/tools/file_system/write_file.ts +45 -0
- package/src/tools/framework/audit_deps.ts +49 -0
- package/src/tools/framework/get_status.ts +7 -0
- package/src/tools/framework/orchestrate.ts +7 -0
- package/src/tools/framework/run_tests.ts +30 -0
- package/src/tools/framework/update_contract_hash.ts +7 -0
- package/src/tools/framework/update_memory.ts +10 -0
- package/src/tools/index.ts +64 -0
- package/src/tools/memory/get_insights.ts +41 -0
- package/src/tools/memory/read_memory.ts +31 -0
- package/src/tools/messaging/log_action.ts +28 -0
- package/src/tools/messaging/send_message.ts +97 -0
- package/src/tools/observability/check_ports.ts +30 -0
- package/src/tools/observability/get_health.ts +24 -0
- package/src/tools/quality/check_lint.ts +36 -0
- package/src/tools/search/get_gaps.ts +54 -0
- package/src/tools/search/get_map.ts +48 -0
- package/src/tools/search/grep_search.ts +75 -0
- package/src/tools/search/list_dir.ts +34 -0
- package/src/tools/shell/run_command.ts +66 -0
- package/src/tools/types.ts +89 -0
- package/src/utils/cli.ts +53 -0
- package/src/utils/compliance.ts +95 -0
- package/src/utils/fs.ts +45 -0
- package/src/utils/metrics.ts +73 -0
- package/src/utils/security.ts +66 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { FRAMEWORK, MCP, UNIFIED_HUB_DIR } from "../constants.js"; // New import
|
|
4
|
+
import os from "os"; // Need os.homedir()
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Validates and resolves a user-provided path to prevent path traversal attacks.
|
|
8
|
+
* Ensures the resolved path stays within the project root boundary.
|
|
9
|
+
*/
|
|
10
|
+
export function safePath(projectRoot: string, userPath: string): string {
|
|
11
|
+
const resolved = path.resolve(projectRoot, userPath);
|
|
12
|
+
const normalizedRoot = path.resolve(projectRoot);
|
|
13
|
+
|
|
14
|
+
if (!resolved.startsWith(normalizedRoot + path.sep) && resolved !== normalizedRoot) {
|
|
15
|
+
throw new Error(`Access denied: path "${userPath}" escapes project root.`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return resolved;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Resolves the active framework directory.
|
|
23
|
+
* Priority: ATABEY_TEST_DIR (env) -> package.json `atabey.frameworkDir` -> `.atabey` -> other adapter dirs -> global HOME.
|
|
24
|
+
*/
|
|
25
|
+
export function resolveFrameworkDir(projectRoot: string): string {
|
|
26
|
+
// For test environments, use the explicitly set test directory.
|
|
27
|
+
const testDir = process.env[MCP.TEST_DIR_ENV];
|
|
28
|
+
if (testDir) return testDir;
|
|
29
|
+
|
|
30
|
+
// 1. Authoritative source: read from package.json if present
|
|
31
|
+
try {
|
|
32
|
+
const pkgPath = path.join(projectRoot, "package.json");
|
|
33
|
+
if (fs.existsSync(pkgPath)) {
|
|
34
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8")) as Record<string, unknown>;
|
|
35
|
+
const atabeyConfig = pkg["atabey"] as Record<string, unknown> | undefined;
|
|
36
|
+
if (atabeyConfig && typeof atabeyConfig["frameworkDir"] === "string") {
|
|
37
|
+
// Ensure the path is relative if it's within the project, otherwise use as-is.
|
|
38
|
+
const resolvedDir = path.resolve(projectRoot, atabeyConfig["frameworkDir"]);
|
|
39
|
+
if (resolvedDir.startsWith(path.resolve(projectRoot))) {
|
|
40
|
+
return path.relative(projectRoot, resolvedDir);
|
|
41
|
+
}
|
|
42
|
+
return atabeyConfig["frameworkDir"];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} catch {
|
|
46
|
+
// ignore — fall through to filesystem scan
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// 2. Filesystem scan in projectRoot for common framework directories
|
|
50
|
+
const localCandidates = [
|
|
51
|
+
FRAMEWORK.CORE_DIR, // .atabey
|
|
52
|
+
UNIFIED_HUB_DIR, // .agents
|
|
53
|
+
// Add other adapter specific directories if needed, or remove if unified is strictly enforced
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
for (const candidate of localCandidates) {
|
|
57
|
+
const candidatePath = path.join(projectRoot, candidate);
|
|
58
|
+
if (fs.existsSync(candidatePath)) {
|
|
59
|
+
return candidate;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 3. Fallback to global home directory.
|
|
64
|
+
const homeDir = os.homedir();
|
|
65
|
+
return path.join(homeDir, FRAMEWORK.CORE_DIR);
|
|
66
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"rootDir": "src",
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"types": ["node"]
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*.ts"]
|
|
14
|
+
}
|