@saber2pr/ai-agent 0.0.61 → 0.0.62

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.
@@ -20,6 +20,7 @@ const convertToLangChainTool_1 = require("../utils/convertToLangChainTool");
20
20
  const jsonSchemaToZod_1 = require("../utils/jsonSchemaToZod");
21
21
  const formatSchema_1 = require("../utils/formatSchema");
22
22
  const config_1 = require("../config/config");
23
+ const getSystemPromptTemplate_1 = require("../utils/getSystemPromptTemplate");
23
24
  // ✅ 全局设置:修复 AbortSignal 监听器数量警告
24
25
  // LangChain 的 HTTP 客户端会创建多个 AbortSignal,需要增加默认限制
25
26
  events_1.EventEmitter.defaultMaxListeners = 100;
@@ -415,21 +416,10 @@ class McpGraphAgent {
415
416
  .join('\n')}`
416
417
  : '';
417
418
  // 1. 构建当前的系统提示词模板
418
- const systemPromptTemplate = `You are an expert software engineer. Working directory: ${this.targetDir}.
419
-
420
- # 🧠 Mandatory Thinking Process
421
- Before providing any output or calling a tool, you **MUST** conduct a deep logical analysis. Wrap your thought process within <think> tags.
422
-
423
- # 🛠️ Tool Call Specifications
424
- 1. **Pure JSON Arguments**: Arguments must be a valid JSON object. NEVER wrap the entire JSON object in a string or quotes.
425
- 2. **No Double Escaping**: Do not double-escape characters within the JSON.
426
- 3. **No Idle Operations**: If the task is complete or no tool is needed, DO NOT output any "Action" structure. Never use "None", "null", or empty strings as a tool name.
427
-
428
- # 🎯 Core Instructions
429
- 1. **Termination Criterion**: Once you have read the requested files, answered the questions, or completed the code implementation, you must provide the final response immediately.
430
- 2. **Response Format**: Upon task completion, start your summary with "Final Answer:". No further tool calls should be made after this point.
431
-
432
- {extraPrompt}`;
419
+ const systemPromptTemplate = `
420
+ ${(0, getSystemPromptTemplate_1.getSystemPromptTemplate)(this.targetDir)}
421
+
422
+ {extraPrompt}`.trim();
433
423
  // 2. 核心逻辑:处理消息上下文
434
424
  let inputMessages;
435
425
  // ✅ 检查 options 中的 alwaysSystem 参数 (默认为 true 或根据你的需求设置)
@@ -7,6 +7,7 @@ const function_calling_1 = require("@langchain/core/utils/function_calling");
7
7
  const generateToolMarkdown_1 = require("../utils/generateToolMarkdown");
8
8
  const kit_1 = require("../utils/kit");
9
9
  const getRepoMapPrompt_1 = require("../utils/getRepoMapPrompt");
10
+ const getSystemPromptTemplate_1 = require("../utils/getSystemPromptTemplate");
10
11
  class AgentGraphModel extends chat_models_1.BaseChatModel {
11
12
  boundTools;
12
13
  mcpEnabled = true;
@@ -194,6 +195,8 @@ ${isFirstMessage ? format(systemMsg) : ''}
194
195
  ${toolsContext}
195
196
  ${(0, getRepoMapPrompt_1.getIncrementalRepoMapPrompt)(this.targetDir, isFirstMessage)}
196
197
  `.trim() : `
198
+ ${(0, getSystemPromptTemplate_1.getSystemPromptTemplate)(this.targetDir)}
199
+
197
200
  ## Active Tools (Summary)
198
201
  Available: ${(0, kit_1.getArray)(tools).map(t => t.function.name).join(', ')}
199
202
 
@@ -0,0 +1 @@
1
+ export declare const getSystemPromptTemplate: (targetDir: string) => string;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSystemPromptTemplate = void 0;
4
+ const getSystemPromptTemplate = (targetDir) => {
5
+ return `You are an expert software engineer. Working directory: ${targetDir}.
6
+
7
+ # 🧠 Mandatory Thinking Process
8
+ Before providing any output or calling a tool, you **MUST** conduct a deep logical analysis. Wrap your thought process within <think> tags.
9
+
10
+ # 🛠️ Tool Call Specifications
11
+ 1. **Pure JSON Arguments**: Arguments must be a valid JSON object. NEVER wrap the entire JSON object in a string or quotes.
12
+ 2. **No Double Escaping**: Do not double-escape characters within the JSON.
13
+ 3. **No Idle Operations**: If the task is complete or no tool is needed, DO NOT output any "Action" structure. Never use "None", "null", or empty strings as a tool name.
14
+
15
+ # 🎯 Core Instructions
16
+ 1. **Termination Criterion**: Once you have read the requested files, answered the questions, or completed the code implementation, you must provide the final response immediately.
17
+ 2. **Response Format**: Upon task completion, start your summary with "Final Answer:". No further tool calls should be made after this point.
18
+ `.trim();
19
+ };
20
+ exports.getSystemPromptTemplate = getSystemPromptTemplate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saber2pr/ai-agent",
3
- "version": "0.0.61",
3
+ "version": "0.0.62",
4
4
  "description": "AI Assistant CLI.",
5
5
  "author": "saber2pr",
6
6
  "license": "ISC",