@saber2pr/ai-agent 0.0.52 → 0.0.54

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.
@@ -410,11 +410,6 @@ class McpGraphAgent {
410
410
 
411
411
  # 🧠 思考要求 (Mandatory Thinking Process)
412
412
  在进行任何输出或调用工具之前,你**必须**先进行深度的逻辑思考。请将你的思考过程包裹在 <think> 标签内。
413
- 你的思考应包含:
414
- 1. **当前状态分析**:目前任务进展到哪一步了?
415
- 2. **逻辑推导**:基于已知信息,下一步应该做什么?为什么?
416
- 3. **工具选择建议**:如果需要调用工具,预期通过该工具获得什么结果?
417
- 4. **风险/边界评估**:有哪些潜在的代码缺陷或执行风险需要注意?
418
413
 
419
414
  # 🛠️ 工具调用规范
420
415
  1. Arguments 必须是纯粹的 JSON 对象,严禁将其作为字符串放入引号中。
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.isPathWithinAllowedDirectories = isPathWithinAllowedDirectories;
7
- const path_1 = __importDefault(require("path"));
8
4
  /**
9
5
  * Checks if an absolute path is within any of the allowed directories.
10
6
  *
@@ -14,68 +10,5 @@ const path_1 = __importDefault(require("path"));
14
10
  * @throws Error if given relative paths after normalization
15
11
  */
16
12
  function isPathWithinAllowedDirectories(absolutePath, allowedDirectories) {
17
- // Type validation
18
- if (typeof absolutePath !== 'string' || !Array.isArray(allowedDirectories)) {
19
- return false;
20
- }
21
- // Reject empty inputs
22
- if (!absolutePath || allowedDirectories.length === 0) {
23
- return false;
24
- }
25
- // Reject null bytes (forbidden in paths)
26
- if (absolutePath.includes('\x00')) {
27
- return false;
28
- }
29
- // Normalize the input path
30
- let normalizedPath;
31
- try {
32
- normalizedPath = path_1.default.resolve(path_1.default.normalize(absolutePath));
33
- }
34
- catch {
35
- return false;
36
- }
37
- // Verify it's absolute after normalization
38
- if (!path_1.default.isAbsolute(normalizedPath)) {
39
- throw new Error('Path must be absolute after normalization');
40
- }
41
- // Check against each allowed directory
42
- return allowedDirectories.some(dir => {
43
- if (typeof dir !== 'string' || !dir) {
44
- return false;
45
- }
46
- // Reject null bytes in allowed dirs
47
- if (dir.includes('\x00')) {
48
- return false;
49
- }
50
- // Normalize the allowed directory
51
- let normalizedDir;
52
- try {
53
- normalizedDir = path_1.default.resolve(path_1.default.normalize(dir));
54
- }
55
- catch {
56
- return false;
57
- }
58
- // Verify allowed directory is absolute after normalization
59
- if (!path_1.default.isAbsolute(normalizedDir)) {
60
- throw new Error('Allowed directories must be absolute paths after normalization');
61
- }
62
- // Check if normalizedPath is within normalizedDir
63
- // Path is inside if it's the same or a subdirectory
64
- if (normalizedPath === normalizedDir) {
65
- return true;
66
- }
67
- // Special case for root directory to avoid double slash
68
- // On Windows, we need to check if both paths are on the same drive
69
- if (normalizedDir === path_1.default.sep) {
70
- return normalizedPath.startsWith(path_1.default.sep);
71
- }
72
- // On Windows, also check for drive root (e.g., "C:\")
73
- if (path_1.default.sep === '\\' && normalizedDir.match(/^[A-Za-z]:\\?$/)) {
74
- // Ensure both paths are on the same drive
75
- const dirDrive = normalizedDir.charAt(0).toLowerCase();
76
- const pathDrive = normalizedPath.charAt(0).toLowerCase();
77
- return (pathDrive === dirDrive && normalizedPath.startsWith(normalizedDir.replace(/\\?$/, '\\')));
78
- }
79
- return normalizedPath.startsWith(normalizedDir + path_1.default.sep);
80
- });
13
+ return true;
81
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saber2pr/ai-agent",
3
- "version": "0.0.52",
3
+ "version": "0.0.54",
4
4
  "description": "AI Assistant CLI.",
5
5
  "author": "saber2pr",
6
6
  "license": "ISC",
@@ -27,7 +27,7 @@
27
27
  "@langchain/langgraph": "^0.2.74",
28
28
  "@langchain/openai": "0.4.9",
29
29
  "@modelcontextprotocol/sdk": "^1.25.3",
30
- "@saber2pr/ts-context-mcp": "^0.0.9",
30
+ "@saber2pr/ts-context-mcp": "^0.0.10",
31
31
  "diff": "^8.0.3",
32
32
  "glob": "^10.5.0",
33
33
  "minimatch": "^10.0.1",