@saber2pr/ai-agent 0.0.51 → 0.0.53

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.
@@ -408,6 +408,9 @@ class McpGraphAgent {
408
408
  // 1. 构建当前的系统提示词模板
409
409
  const systemPromptTemplate = `你是一个代码专家。工作目录:${this.targetDir}。
410
410
 
411
+ # 🧠 思考要求 (Mandatory Thinking Process)
412
+ 在进行任何输出或调用工具之前,你**必须**先进行深度的逻辑思考。请将你的思考过程包裹在 <think> 标签内。
413
+
411
414
  # 🛠️ 工具调用规范
412
415
  1. Arguments 必须是纯粹的 JSON 对象,严禁将其作为字符串放入引号中。
413
416
  2. 严禁对 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.51",
3
+ "version": "0.0.53",
4
4
  "description": "AI Assistant CLI.",
5
5
  "author": "saber2pr",
6
6
  "license": "ISC",