sema-core 1.0.11 → 1.0.13

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.
Files changed (325) hide show
  1. package/README.md +6 -11
  2. package/dist/core/Conversation.d.ts +6 -1
  3. package/dist/core/Conversation.d.ts.map +1 -1
  4. package/dist/core/Conversation.js +72 -28
  5. package/dist/core/Conversation.js.map +1 -1
  6. package/dist/core/RunTools.d.ts.map +1 -1
  7. package/dist/core/RunTools.js +1 -1
  8. package/dist/core/RunTools.js.map +1 -1
  9. package/dist/core/SemaCore.d.ts +16 -0
  10. package/dist/core/SemaCore.d.ts.map +1 -1
  11. package/dist/core/SemaCore.js +30 -3
  12. package/dist/core/SemaCore.js.map +1 -1
  13. package/dist/core/SemaEngine.d.ts +2 -18
  14. package/dist/core/SemaEngine.d.ts.map +1 -1
  15. package/dist/core/SemaEngine.js +101 -131
  16. package/dist/core/SemaEngine.js.map +1 -1
  17. package/dist/events/EventSystem.d.ts.map +1 -1
  18. package/dist/events/EventSystem.js +6 -2
  19. package/dist/events/EventSystem.js.map +1 -1
  20. package/dist/events/types.d.ts +60 -13
  21. package/dist/events/types.d.ts.map +1 -1
  22. package/dist/events/types.js +0 -1
  23. package/dist/events/types.js.map +1 -1
  24. package/dist/manager/ConfManager.d.ts.map +1 -1
  25. package/dist/manager/ConfManager.js +3 -1
  26. package/dist/manager/ConfManager.js.map +1 -1
  27. package/dist/manager/CronManager.d.ts +52 -0
  28. package/dist/manager/CronManager.d.ts.map +1 -0
  29. package/dist/manager/CronManager.js +426 -0
  30. package/dist/manager/CronManager.js.map +1 -0
  31. package/dist/manager/PermissionManager.d.ts +1 -1
  32. package/dist/manager/PermissionManager.d.ts.map +1 -1
  33. package/dist/manager/PermissionManager.js +63 -12
  34. package/dist/manager/PermissionManager.js.map +1 -1
  35. package/dist/manager/StateManager.d.ts +79 -11
  36. package/dist/manager/StateManager.d.ts.map +1 -1
  37. package/dist/manager/StateManager.js +287 -4
  38. package/dist/manager/StateManager.js.map +1 -1
  39. package/dist/manager/TaskManager.d.ts +106 -0
  40. package/dist/manager/TaskManager.d.ts.map +1 -0
  41. package/dist/manager/TaskManager.js +664 -0
  42. package/dist/manager/TaskManager.js.map +1 -0
  43. package/dist/services/agents/defaultBuiltInAgentsConfs.js +3 -3
  44. package/dist/services/agents/defaultBuiltInAgentsConfs.js.map +1 -1
  45. package/dist/services/agents/systemReminder.d.ts.map +1 -1
  46. package/dist/services/agents/systemReminder.js +8 -118
  47. package/dist/services/agents/systemReminder.js.map +1 -1
  48. package/dist/services/api/adapt/anthropic.js +2 -2
  49. package/dist/services/api/adapt/anthropic.js.map +1 -1
  50. package/dist/services/api/adapt/openai.js +2 -2
  51. package/dist/services/api/adapt/openai.js.map +1 -1
  52. package/dist/services/api/adapt/util.d.ts +1 -1
  53. package/dist/services/api/adapt/util.d.ts.map +1 -1
  54. package/dist/services/api/adapt/util.js +2 -2
  55. package/dist/services/api/adapt/util.js.map +1 -1
  56. package/dist/services/api/cache.d.ts.map +1 -1
  57. package/dist/services/api/cache.js +1 -3
  58. package/dist/services/api/cache.js.map +1 -1
  59. package/dist/services/api/queryLLM.d.ts.map +1 -1
  60. package/dist/services/api/queryLLM.js +5 -0
  61. package/dist/services/api/queryLLM.js.map +1 -1
  62. package/dist/services/commands/runCommand.d.ts.map +1 -1
  63. package/dist/services/commands/runCommand.js +12 -0
  64. package/dist/services/commands/runCommand.js.map +1 -1
  65. package/dist/services/mcp/MCPManager.d.ts.map +1 -1
  66. package/dist/services/mcp/MCPManager.js +6 -1
  67. package/dist/services/mcp/MCPManager.js.map +1 -1
  68. package/dist/services/plugins/pluginsManager.d.ts.map +1 -1
  69. package/dist/services/plugins/pluginsManager.js +8 -1
  70. package/dist/services/plugins/pluginsManager.js.map +1 -1
  71. package/dist/services/rules/rulesManager.d.ts +51 -0
  72. package/dist/services/rules/rulesManager.d.ts.map +1 -0
  73. package/dist/services/rules/rulesManager.js +192 -0
  74. package/dist/services/rules/rulesManager.js.map +1 -0
  75. package/dist/tools/Agent/Agent.d.ts +19 -11
  76. package/dist/tools/Agent/Agent.d.ts.map +1 -1
  77. package/dist/tools/Agent/Agent.js +249 -72
  78. package/dist/tools/Agent/Agent.js.map +1 -1
  79. package/dist/tools/Agent/prompt.d.ts.map +1 -1
  80. package/dist/tools/Agent/prompt.js +7 -9
  81. package/dist/tools/Agent/prompt.js.map +1 -1
  82. package/dist/tools/Bash/Bash.d.ts +21 -11
  83. package/dist/tools/Bash/Bash.d.ts.map +1 -1
  84. package/dist/tools/Bash/Bash.js +74 -17
  85. package/dist/tools/Bash/Bash.js.map +1 -1
  86. package/dist/tools/Bash/prompt.d.ts.map +1 -1
  87. package/dist/tools/Bash/prompt.js +53 -70
  88. package/dist/tools/Bash/prompt.js.map +1 -1
  89. package/dist/tools/Bash/utils.d.ts +5 -1
  90. package/dist/tools/Bash/utils.d.ts.map +1 -1
  91. package/dist/tools/Bash/utils.js +24 -4
  92. package/dist/tools/Bash/utils.js.map +1 -1
  93. package/dist/tools/CronCreate/CronCreate.d.ts +68 -0
  94. package/dist/tools/CronCreate/CronCreate.d.ts.map +1 -0
  95. package/dist/tools/CronCreate/CronCreate.js +75 -0
  96. package/dist/tools/CronCreate/CronCreate.js.map +1 -0
  97. package/dist/tools/CronCreate/prompt.d.ts +3 -0
  98. package/dist/tools/CronCreate/prompt.d.ts.map +1 -0
  99. package/dist/tools/CronCreate/prompt.js +41 -0
  100. package/dist/tools/CronCreate/prompt.js.map +1 -0
  101. package/dist/tools/CronDelete/CronDelete.d.ts +45 -0
  102. package/dist/tools/CronDelete/CronDelete.d.ts.map +1 -0
  103. package/dist/tools/CronDelete/CronDelete.js +51 -0
  104. package/dist/tools/CronDelete/CronDelete.js.map +1 -0
  105. package/dist/tools/CronDelete/prompt.d.ts +3 -0
  106. package/dist/tools/CronDelete/prompt.d.ts.map +1 -0
  107. package/dist/tools/CronDelete/prompt.js +6 -0
  108. package/dist/tools/CronDelete/prompt.js.map +1 -0
  109. package/dist/tools/CronList/CronList.d.ts +33 -0
  110. package/dist/tools/CronList/CronList.d.ts.map +1 -0
  111. package/dist/tools/CronList/CronList.js +55 -0
  112. package/dist/tools/CronList/CronList.js.map +1 -0
  113. package/dist/tools/CronList/prompt.d.ts +3 -0
  114. package/dist/tools/CronList/prompt.d.ts.map +1 -0
  115. package/dist/tools/CronList/prompt.js +6 -0
  116. package/dist/tools/CronList/prompt.js.map +1 -0
  117. package/dist/tools/Edit/Edit.d.ts.map +1 -1
  118. package/dist/tools/Edit/Edit.js +7 -3
  119. package/dist/tools/Edit/Edit.js.map +1 -1
  120. package/dist/tools/Edit/utils.d.ts.map +1 -1
  121. package/dist/tools/Edit/utils.js +14 -5
  122. package/dist/tools/Edit/utils.js.map +1 -1
  123. package/dist/tools/Grep/Grep.d.ts +4 -4
  124. package/dist/tools/NotebookEdit/NotebookEdit.js +1 -1
  125. package/dist/tools/NotebookEdit/NotebookEdit.js.map +1 -1
  126. package/dist/tools/Read/Read.d.ts +74 -3
  127. package/dist/tools/Read/Read.d.ts.map +1 -1
  128. package/dist/tools/Read/Read.js +188 -18
  129. package/dist/tools/Read/Read.js.map +1 -1
  130. package/dist/tools/Read/prompt.d.ts +1 -1
  131. package/dist/tools/Read/prompt.d.ts.map +1 -1
  132. package/dist/tools/Read/prompt.js +2 -1
  133. package/dist/tools/Read/prompt.js.map +1 -1
  134. package/dist/tools/Skill/Skill.d.ts +2 -1
  135. package/dist/tools/Skill/Skill.d.ts.map +1 -1
  136. package/dist/tools/Skill/Skill.js +3 -2
  137. package/dist/tools/Skill/Skill.js.map +1 -1
  138. package/dist/tools/TaskCreate/TaskCreate.d.ts +54 -0
  139. package/dist/tools/TaskCreate/TaskCreate.d.ts.map +1 -0
  140. package/dist/tools/TaskCreate/TaskCreate.js +51 -0
  141. package/dist/tools/TaskCreate/TaskCreate.js.map +1 -0
  142. package/dist/tools/TaskCreate/prompt.d.ts +3 -0
  143. package/dist/tools/TaskCreate/prompt.d.ts.map +1 -0
  144. package/dist/tools/TaskCreate/prompt.js +45 -0
  145. package/dist/tools/TaskCreate/prompt.js.map +1 -0
  146. package/dist/tools/TaskGet/TaskGet.d.ts +34 -0
  147. package/dist/tools/TaskGet/TaskGet.d.ts.map +1 -0
  148. package/dist/tools/TaskGet/TaskGet.js +57 -0
  149. package/dist/tools/TaskGet/TaskGet.js.map +1 -0
  150. package/dist/tools/TaskGet/prompt.d.ts +3 -0
  151. package/dist/tools/TaskGet/prompt.d.ts.map +1 -0
  152. package/dist/tools/TaskGet/prompt.js +26 -0
  153. package/dist/tools/TaskGet/prompt.js.map +1 -0
  154. package/dist/tools/TaskList/TaskList.d.ts +27 -0
  155. package/dist/tools/TaskList/TaskList.d.ts.map +1 -0
  156. package/dist/tools/TaskList/TaskList.js +56 -0
  157. package/dist/tools/TaskList/TaskList.js.map +1 -0
  158. package/dist/tools/TaskList/prompt.d.ts +3 -0
  159. package/dist/tools/TaskList/prompt.d.ts.map +1 -0
  160. package/dist/tools/TaskList/prompt.js +25 -0
  161. package/dist/tools/TaskList/prompt.js.map +1 -0
  162. package/dist/tools/TaskOutput/TaskOutput.d.ts +58 -0
  163. package/dist/tools/TaskOutput/TaskOutput.d.ts.map +1 -0
  164. package/dist/tools/TaskOutput/TaskOutput.js +95 -0
  165. package/dist/tools/TaskOutput/TaskOutput.js.map +1 -0
  166. package/dist/tools/TaskStop/TaskStop.d.ts +50 -0
  167. package/dist/tools/TaskStop/TaskStop.d.ts.map +1 -0
  168. package/dist/tools/TaskStop/TaskStop.js +69 -0
  169. package/dist/tools/TaskStop/TaskStop.js.map +1 -0
  170. package/dist/tools/TaskUpdate/TaskUpdate.d.ts +88 -0
  171. package/dist/tools/TaskUpdate/TaskUpdate.d.ts.map +1 -0
  172. package/dist/tools/TaskUpdate/TaskUpdate.js +115 -0
  173. package/dist/tools/TaskUpdate/TaskUpdate.js.map +1 -0
  174. package/dist/tools/TaskUpdate/prompt.d.ts +3 -0
  175. package/dist/tools/TaskUpdate/prompt.d.ts.map +1 -0
  176. package/dist/tools/TaskUpdate/prompt.js +80 -0
  177. package/dist/tools/TaskUpdate/prompt.js.map +1 -0
  178. package/dist/tools/WebFetch/WebFetch.d.ts +62 -0
  179. package/dist/tools/WebFetch/WebFetch.d.ts.map +1 -0
  180. package/dist/tools/WebFetch/WebFetch.js +143 -0
  181. package/dist/tools/WebFetch/WebFetch.js.map +1 -0
  182. package/dist/tools/WebFetch/prompt.d.ts +4 -0
  183. package/dist/tools/WebFetch/prompt.d.ts.map +1 -0
  184. package/dist/tools/WebFetch/prompt.js +38 -0
  185. package/dist/tools/WebFetch/prompt.js.map +1 -0
  186. package/dist/tools/WebFetch/utils.d.ts +20 -0
  187. package/dist/tools/WebFetch/utils.d.ts.map +1 -0
  188. package/dist/tools/WebFetch/utils.js +223 -0
  189. package/dist/tools/WebFetch/utils.js.map +1 -0
  190. package/dist/tools/Write/Write.js +1 -1
  191. package/dist/tools/Write/Write.js.map +1 -1
  192. package/dist/tools/base/Tool.d.ts +1 -0
  193. package/dist/tools/base/Tool.d.ts.map +1 -1
  194. package/dist/tools/base/tools.d.ts +4 -2
  195. package/dist/tools/base/tools.d.ts.map +1 -1
  196. package/dist/tools/base/tools.js +61 -14
  197. package/dist/tools/base/tools.js.map +1 -1
  198. package/dist/types/cron.d.ts +21 -0
  199. package/dist/types/cron.d.ts.map +1 -0
  200. package/dist/types/cron.js +6 -0
  201. package/dist/types/cron.js.map +1 -0
  202. package/dist/types/index.d.ts +9 -1
  203. package/dist/types/index.d.ts.map +1 -1
  204. package/dist/types/index.js +4 -2
  205. package/dist/types/index.js.map +1 -1
  206. package/dist/types/rule.d.ts +8 -0
  207. package/dist/types/rule.d.ts.map +1 -0
  208. package/dist/types/rule.js +3 -0
  209. package/dist/types/rule.js.map +1 -0
  210. package/dist/types/task.d.ts +93 -0
  211. package/dist/types/task.d.ts.map +1 -0
  212. package/dist/types/task.js +3 -0
  213. package/dist/types/task.js.map +1 -0
  214. package/dist/types/todoTask.d.ts +29 -0
  215. package/dist/types/todoTask.d.ts.map +1 -0
  216. package/dist/types/todoTask.js +6 -0
  217. package/dist/types/todoTask.js.map +1 -0
  218. package/dist/util/assembleTools.d.ts +6 -0
  219. package/dist/util/assembleTools.d.ts.map +1 -0
  220. package/dist/util/assembleTools.js +17 -0
  221. package/dist/util/assembleTools.js.map +1 -0
  222. package/dist/util/btw.d.ts +6 -0
  223. package/dist/util/btw.d.ts.map +1 -0
  224. package/dist/util/btw.js +80 -0
  225. package/dist/util/btw.js.map +1 -0
  226. package/dist/util/compact.d.ts +16 -4
  227. package/dist/util/compact.d.ts.map +1 -1
  228. package/dist/util/compact.js +12 -18
  229. package/dist/util/compact.js.map +1 -1
  230. package/dist/util/cron.d.ts +17 -0
  231. package/dist/util/cron.d.ts.map +1 -0
  232. package/dist/util/cron.js +82 -0
  233. package/dist/util/cron.js.map +1 -0
  234. package/dist/util/file.d.ts +16 -0
  235. package/dist/util/file.d.ts.map +1 -1
  236. package/dist/util/file.js +55 -0
  237. package/dist/util/file.js.map +1 -1
  238. package/dist/util/fileReference.d.ts.map +1 -1
  239. package/dist/util/fileReference.js +10 -1
  240. package/dist/util/fileReference.js.map +1 -1
  241. package/dist/util/format.d.ts +6 -0
  242. package/dist/util/format.d.ts.map +1 -1
  243. package/dist/util/format.js +17 -0
  244. package/dist/util/format.js.map +1 -1
  245. package/dist/util/history.d.ts +4 -1
  246. package/dist/util/history.d.ts.map +1 -1
  247. package/dist/util/history.js +9 -5
  248. package/dist/util/history.js.map +1 -1
  249. package/dist/util/inputQueue.d.ts +19 -0
  250. package/dist/util/inputQueue.d.ts.map +1 -0
  251. package/dist/util/inputQueue.js +30 -0
  252. package/dist/util/inputQueue.js.map +1 -0
  253. package/dist/util/message.d.ts +4 -0
  254. package/dist/util/message.d.ts.map +1 -1
  255. package/dist/util/message.js +27 -0
  256. package/dist/util/message.js.map +1 -1
  257. package/dist/util/pdf.d.ts +83 -0
  258. package/dist/util/pdf.d.ts.map +1 -0
  259. package/dist/util/pdf.js +472 -0
  260. package/dist/util/pdf.js.map +1 -0
  261. package/dist/util/process.d.ts +10 -0
  262. package/dist/util/process.d.ts.map +1 -0
  263. package/dist/util/process.js +88 -0
  264. package/dist/util/process.js.map +1 -0
  265. package/dist/util/savePath.d.ts +0 -11
  266. package/dist/util/savePath.d.ts.map +1 -1
  267. package/dist/util/savePath.js +0 -17
  268. package/dist/util/savePath.js.map +1 -1
  269. package/dist/util/shell.d.ts +10 -1
  270. package/dist/util/shell.d.ts.map +1 -1
  271. package/dist/util/shell.js +89 -34
  272. package/dist/util/shell.js.map +1 -1
  273. package/dist/util/topic.d.ts +7 -0
  274. package/dist/util/topic.d.ts.map +1 -1
  275. package/dist/util/topic.js +40 -0
  276. package/dist/util/topic.js.map +1 -1
  277. package/package.json +2 -1
  278. package/dist/services/command/customCommands.d.ts +0 -1
  279. package/dist/services/command/customCommands.d.ts.map +0 -1
  280. package/dist/services/command/customCommands.js +0 -197
  281. package/dist/services/command/customCommands.js.map +0 -1
  282. package/dist/services/command/runCommand.d.ts +0 -18
  283. package/dist/services/command/runCommand.d.ts.map +0 -1
  284. package/dist/services/command/runCommand.js +0 -147
  285. package/dist/services/command/runCommand.js.map +0 -1
  286. package/dist/services/plugins/customCommands.d.ts +0 -29
  287. package/dist/services/plugins/customCommands.d.ts.map +0 -1
  288. package/dist/services/plugins/customCommands.js +0 -227
  289. package/dist/services/plugins/customCommands.js.map +0 -1
  290. package/dist/services/skill/skillLoader.d.ts +0 -17
  291. package/dist/services/skill/skillLoader.d.ts.map +0 -1
  292. package/dist/services/skill/skillLoader.js +0 -122
  293. package/dist/services/skill/skillLoader.js.map +0 -1
  294. package/dist/services/skill/skillParser.d.ts +0 -15
  295. package/dist/services/skill/skillParser.d.ts.map +0 -1
  296. package/dist/services/skill/skillParser.js +0 -66
  297. package/dist/services/skill/skillParser.js.map +0 -1
  298. package/dist/services/skill/skillRegistry.d.ts +0 -34
  299. package/dist/services/skill/skillRegistry.d.ts.map +0 -1
  300. package/dist/services/skill/skillRegistry.js +0 -98
  301. package/dist/services/skill/skillRegistry.js.map +0 -1
  302. package/dist/services/skill/skillsManager.d.ts +0 -79
  303. package/dist/services/skill/skillsManager.d.ts.map +0 -1
  304. package/dist/services/skill/skillsManager.js +0 -289
  305. package/dist/services/skill/skillsManager.js.map +0 -1
  306. package/dist/tools/Task/Task.d.ts +0 -59
  307. package/dist/tools/Task/Task.d.ts.map +0 -1
  308. package/dist/tools/Task/Task.js +0 -212
  309. package/dist/tools/Task/Task.js.map +0 -1
  310. package/dist/tools/Task/prompt.d.ts +0 -6
  311. package/dist/tools/Task/prompt.d.ts.map +0 -1
  312. package/dist/tools/Task/prompt.js +0 -75
  313. package/dist/tools/Task/prompt.js.map +0 -1
  314. package/dist/util/frontmatter.d.ts +0 -35
  315. package/dist/util/frontmatter.d.ts.map +0 -1
  316. package/dist/util/frontmatter.js +0 -119
  317. package/dist/util/frontmatter.js.map +0 -1
  318. package/dist/util/rules.d.ts +0 -6
  319. package/dist/util/rules.d.ts.map +0 -1
  320. package/dist/util/rules.js +0 -162
  321. package/dist/util/rules.js.map +0 -1
  322. package/dist/util/systemReminder.d.ts +0 -10
  323. package/dist/util/systemReminder.d.ts.map +0 -1
  324. package/dist/util/systemReminder.js +0 -177
  325. package/dist/util/systemReminder.js.map +0 -1
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TOOL_NAME_FOR_PROMPT = void 0;
4
- exports.getDescription = getDescription;
5
- const agentsManager_1 = require("../../services/agents/agentsManager");
6
- exports.TOOL_NAME_FOR_PROMPT = 'Task';
7
- /**
8
- * 获取 Task 工具的完整描述
9
- */
10
- function getDescription() {
11
- const agentTypesDesc = (0, agentsManager_1.getAgentTypesDescription)();
12
- return `Launch a new agent to handle complex, multi-step tasks autonomously.
13
-
14
- The Task tool launches specialized agents (subprocesses) that autonomously handle complex tasks. Each agent type has specific capabilities and tools available to it.
15
-
16
- Available agent types and the tools they have access to:
17
- ${agentTypesDesc}
18
-
19
- When using the Task tool, you must specify a subagent_type parameter to select which agent type to use.
20
-
21
- When NOT to use the Task tool:
22
- - If you want to read a specific file path, use the Read or Glob tool instead of the Task tool, to find the match more quickly
23
- - If you are searching for a specific class definition like "class Foo", use the Glob tool instead, to find the match more quickly
24
- - If you are searching for code within a specific file or set of 2-3 files, use the Read tool instead of the Task tool, to find the match more quickly
25
- - Other tasks that are not related to the agent descriptions above
26
-
27
-
28
- Usage notes:
29
- - Always include a short description (3-5 words) summarizing what the agent will do
30
- - Call only one agent at a time to maintain clarity and control over task execution.
31
- - When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result.
32
- - When the agent is done, it will return a single message back to you along with its agent ID.
33
- - Provide clear, detailed prompts so the agent can work autonomously and return exactly the information you need.
34
- - The agent's outputs should generally be trusted
35
- - Clearly tell the agent whether you expect it to write code or just to do research (search, file reads, web fetches, etc.), since it is not aware of the user's intent
36
- - If the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.
37
- - If the user specifies that they want you to run agents "in parallel", you MUST send a single message with multiple Task tool use content blocks. For example, if you need to launch both a build-validator agent and a test-runner agent in parallel, send a single message with both tool calls.
38
-
39
- Example usage:
40
-
41
- <example_agent_descriptions>
42
- "test-runner": use this agent after you are done writing code to run tests
43
- "greeting-responder": use this agent when to respond to user greetings with a friendly joke
44
- </example_agent_description>
45
-
46
- <example>
47
- user: "Please write a function that checks if a number is prime"
48
- assistant: Sure let me write a function that checks if a number is prime
49
- assistant: First let me use the Write tool to write a function that checks if a number is prime
50
- assistant: I'm going to use the Write tool to write the following code:
51
- <code>
52
- function isPrime(n) {
53
- if (n <= 1) return false
54
- for (let i = 2; i * i <= n; i++) {
55
- if (n % i === 0) return false
56
- }
57
- return true
58
- }
59
- </code>
60
- <commentary>
61
- Since a significant piece of code was written and the task was completed, now use the test-runner agent to run the tests
62
- </commentary>
63
- assistant: Now let me use the test-runner agent to run the tests
64
- assistant: Uses the Task tool to launch the test-runner agent
65
- </example>
66
-
67
- <example>
68
- user: "Hello"
69
- <commentary>
70
- Since the user is greeting, use the greeting-responder agent to respond with a friendly joke
71
- </commentary>
72
- assistant: "I'm going to use the Task tool to launch the greeting-responder agent"
73
- </example>`;
74
- }
75
- //# sourceMappingURL=prompt.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../../src/tools/Task/prompt.ts"],"names":[],"mappings":";;;AAOA,wCAkEC;AAzED,uEAA8E;AAEjE,QAAA,oBAAoB,GAAG,MAAM,CAAA;AAE1C;;GAEG;AACH,SAAgB,cAAc;IAC5B,MAAM,cAAc,GAAG,IAAA,wCAAwB,GAAE,CAAA;IAEjD,OAAO;;;;;EAKP,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAwDL,CAAA;AAEX,CAAC"}
@@ -1,35 +0,0 @@
1
- /**
2
- * Markdown Frontmatter 解析工具
3
- *
4
- * 提供 YAML frontmatter 的提取和解析功能
5
- */
6
- /**
7
- * Frontmatter 元数据类型
8
- */
9
- export interface FrontmatterMetadata {
10
- [key: string]: string | string[] | undefined;
11
- }
12
- /**
13
- * 从 Markdown 内容中提取 Frontmatter
14
- * @param content Markdown 文件内容
15
- * @returns [frontmatterText, bodyContent] 元组,如果没有 frontmatter 则返回 null
16
- */
17
- export declare function extractFrontmatter(content: string): [string, string] | null;
18
- /**
19
- * 解析 YAML frontmatter
20
- * 简单实现,支持基本的 key: value 格式
21
- * @param text frontmatter 文本(不包含 --- 分隔符)
22
- * @returns 解析后的元数据对象
23
- */
24
- export declare function parseFrontmatter(text: string): FrontmatterMetadata;
25
- /**
26
- * 解析 Markdown 文件的 frontmatter
27
- * 结合 extractFrontmatter 和 parseFrontmatter 的便捷方法
28
- * @param content Markdown 文件内容
29
- * @returns { metadata, body } 对象,如果没有 frontmatter 则 metadata 为空对象
30
- */
31
- export declare function parseMarkdownWithFrontmatter(content: string): {
32
- metadata: FrontmatterMetadata;
33
- body: string;
34
- };
35
- //# sourceMappingURL=frontmatter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../src/util/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAA;CAC7C;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAyB3E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,CAuElE;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG;IAC7D,QAAQ,EAAE,mBAAmB,CAAA;IAC7B,IAAI,EAAE,MAAM,CAAA;CACb,CAcA"}
@@ -1,119 +0,0 @@
1
- "use strict";
2
- /**
3
- * Markdown Frontmatter 解析工具
4
- *
5
- * 提供 YAML frontmatter 的提取和解析功能
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.extractFrontmatter = extractFrontmatter;
9
- exports.parseFrontmatter = parseFrontmatter;
10
- exports.parseMarkdownWithFrontmatter = parseMarkdownWithFrontmatter;
11
- /**
12
- * 从 Markdown 内容中提取 Frontmatter
13
- * @param content Markdown 文件内容
14
- * @returns [frontmatterText, bodyContent] 元组,如果没有 frontmatter 则返回 null
15
- */
16
- function extractFrontmatter(content) {
17
- // 检查是否以 --- 开头
18
- if (!content.startsWith('---\n') && !content.startsWith('---\r\n')) {
19
- return null;
20
- }
21
- // 查找结束标记的位置
22
- const startOffset = content.startsWith('---\r\n') ? 5 : 4;
23
- let endIndex = content.indexOf('\n---\n', startOffset);
24
- let endOffset = 5;
25
- // 兼容 Windows 换行符
26
- if (endIndex === -1) {
27
- endIndex = content.indexOf('\r\n---\r\n', startOffset);
28
- endOffset = 7;
29
- }
30
- if (endIndex === -1) {
31
- return null;
32
- }
33
- const frontmatterText = content.slice(startOffset, endIndex);
34
- const bodyContent = content.slice(endIndex + endOffset).trim();
35
- return [frontmatterText, bodyContent];
36
- }
37
- /**
38
- * 解析 YAML frontmatter
39
- * 简单实现,支持基本的 key: value 格式
40
- * @param text frontmatter 文本(不包含 --- 分隔符)
41
- * @returns 解析后的元数据对象
42
- */
43
- function parseFrontmatter(text) {
44
- const metadata = {};
45
- const length = text.length;
46
- let lineStart = 0;
47
- for (let i = 0; i <= length; i++) {
48
- // 遇到换行符或文件结尾时处理一行
49
- if (i === length || text[i] === '\n') {
50
- if (i > lineStart) {
51
- // 跳过行尾的 \r(Windows 换行符)
52
- const lineEnd = (i > 0 && text[i - 1] === '\r') ? i - 1 : i;
53
- const line = text.slice(lineStart, lineEnd);
54
- // 跳过空行和注释行
55
- if (line && line[0] !== '#') {
56
- const colonIndex = line.indexOf(':');
57
- if (colonIndex !== -1) {
58
- // 提取 key(去除首尾空格)
59
- let keyStart = 0;
60
- let keyEnd = colonIndex;
61
- // 去除 key 前面的空格
62
- while (keyStart < keyEnd && (line[keyStart] === ' ' || line[keyStart] === '\t')) {
63
- keyStart++;
64
- }
65
- // 去除 key 后面的空格
66
- while (keyEnd > keyStart && (line[keyEnd - 1] === ' ' || line[keyEnd - 1] === '\t')) {
67
- keyEnd--;
68
- }
69
- const key = line.slice(keyStart, keyEnd);
70
- // 提取 value(去除首尾空格)
71
- let valueStart = colonIndex + 1;
72
- let valueEnd = line.length;
73
- // 去除 value 前面的空格
74
- while (valueStart < valueEnd && (line[valueStart] === ' ' || line[valueStart] === '\t')) {
75
- valueStart++;
76
- }
77
- // 去除 value 后面的空格
78
- while (valueEnd > valueStart && (line[valueEnd - 1] === ' ' || line[valueEnd - 1] === '\t')) {
79
- valueEnd--;
80
- }
81
- let value = line.slice(valueStart, valueEnd);
82
- // 移除引号(只检查首尾字符)
83
- if (value.length >= 2) {
84
- const firstChar = value[0];
85
- const lastChar = value[value.length - 1];
86
- if ((firstChar === '"' || firstChar === "'") && firstChar === lastChar) {
87
- value = value.slice(1, -1);
88
- }
89
- }
90
- if (key) {
91
- metadata[key] = value;
92
- }
93
- }
94
- }
95
- }
96
- lineStart = i + 1;
97
- }
98
- }
99
- return metadata;
100
- }
101
- /**
102
- * 解析 Markdown 文件的 frontmatter
103
- * 结合 extractFrontmatter 和 parseFrontmatter 的便捷方法
104
- * @param content Markdown 文件内容
105
- * @returns { metadata, body } 对象,如果没有 frontmatter 则 metadata 为空对象
106
- */
107
- function parseMarkdownWithFrontmatter(content) {
108
- const extracted = extractFrontmatter(content);
109
- if (!extracted) {
110
- return {
111
- metadata: {},
112
- body: content.trim()
113
- };
114
- }
115
- const [frontmatterText, body] = extracted;
116
- const metadata = parseFrontmatter(frontmatterText);
117
- return { metadata, body };
118
- }
119
- //# sourceMappingURL=frontmatter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["../../src/util/frontmatter.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAcH,gDAyBC;AAQD,4CAuEC;AAQD,oEAiBC;AAtID;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,OAAe;IAChD,eAAe;IACf,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QACnE,OAAO,IAAI,CAAA;IACb,CAAC;IAED,YAAY;IACZ,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IACzD,IAAI,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,WAAW,CAAC,CA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6 +0,0 @@
1
- import Anthropic from '@anthropic-ai/sdk';
2
- /**
3
- * 生成 rules 相关的系统提醒信息
4
- */
5
- export declare function generateRulesReminders(): Anthropic.ContentBlockParam[];
6
- //# sourceMappingURL=rules.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/util/rules.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAA;AAqGzC;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,SAAS,CAAC,iBAAiB,EAAE,CA4BtE"}
@@ -1,162 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.generateRulesReminders = generateRulesReminders;
37
- const fs = __importStar(require("fs"));
38
- const path = __importStar(require("path"));
39
- const cwd_1 = require("./cwd");
40
- const product_1 = require("../constants/product");
41
- const savePath_1 = require("../util/savePath");
42
- const ConfManager_1 = require("../manager/ConfManager");
43
- /**
44
- * 读取全局 ~/.claude/CLAUDE.md
45
- */
46
- function readGlobalAgentFile() {
47
- try {
48
- const agentPath = (0, savePath_1.getGlobalAgentMdPath)();
49
- console.log('agentPath:', agentPath);
50
- if (fs.existsSync(agentPath)) {
51
- return fs.readFileSync(agentPath, 'utf8');
52
- }
53
- return '';
54
- }
55
- catch (error) {
56
- return '';
57
- }
58
- }
59
- /**
60
- * 从配置管理器中获取自定义的 customRules
61
- */
62
- function readCustomRules() {
63
- try {
64
- const configManager = (0, ConfManager_1.getConfManager)();
65
- const coreConfig = configManager.getCoreConfig();
66
- return coreConfig?.customRules ?? '';
67
- }
68
- catch (error) {
69
- return '';
70
- }
71
- }
72
- /**
73
- * 生成 customRules 描述段
74
- */
75
- function buildCustomRulesSection() {
76
- const customRules = readCustomRules();
77
- if (!customRules)
78
- return '';
79
- return `Custom rules (user-defined instructions):\n\n${customRules}`;
80
- }
81
- /**
82
- * 读取当前目录下的项目配置文件
83
- * 优先读取 AGENT.md,如果不存在则读取 CLAUDE.md
84
- * 返回 { content, filePath } 或 null
85
- */
86
- function readProjectConfigFile() {
87
- try {
88
- const currentDir = (0, cwd_1.getOriginalCwd)();
89
- const agentPath = path.join(currentDir, product_1.PROJECT_FILE);
90
- const claudePath = path.join(currentDir, 'CLAUDE.md');
91
- if (fs.existsSync(agentPath)) {
92
- const content = fs.readFileSync(agentPath, 'utf8');
93
- if (content)
94
- return { content, filePath: agentPath };
95
- }
96
- if (fs.existsSync(claudePath)) {
97
- const content = fs.readFileSync(claudePath, 'utf8');
98
- if (content)
99
- return { content, filePath: claudePath };
100
- }
101
- return null;
102
- }
103
- catch (error) {
104
- return null;
105
- }
106
- }
107
- /**
108
- * 生成全局 agent 文件的描述段
109
- * 若文件不存在或内容为空则返回空字符串
110
- */
111
- function buildGlobalAgentSection(globalContent) {
112
- if (!globalContent)
113
- return '';
114
- return `Contents of ${(0, savePath_1.getGlobalAgentMdPath)()} (user's private global instructions for all projects):\n\n${globalContent}`;
115
- }
116
- /**
117
- * 生成项目配置文件的描述段
118
- * 优先使用 AGENT.md,没有才用 CLAUDE.md;若文件不存在或为空则返回空字符串
119
- */
120
- function buildProjectConfigSection() {
121
- const result = readProjectConfigFile();
122
- if (!result)
123
- return '';
124
- return `Contents of ${result.filePath} (project instructions, checked into the codebase):\n\n${result.content}`;
125
- }
126
- /**
127
- * 生成当前日期描述段
128
- */
129
- function buildCurrentDateSection() {
130
- const today = new Date();
131
- const dateStr = today.toISOString().slice(0, 10);
132
- return `# currentDate\nToday's date is ${dateStr}.`;
133
- }
134
- /**
135
- * 生成 rules 相关的系统提醒信息
136
- */
137
- function generateRulesReminders() {
138
- const globalSection = buildGlobalAgentSection(readGlobalAgentFile());
139
- console.log('globalSection:', globalSection);
140
- const projectSection = buildProjectConfigSection();
141
- const customRulesSection = buildCustomRulesSection();
142
- // 如果全局、项目配置和系统规则配置均为空,直接返回空数组
143
- if (!globalSection && !projectSection && !customRulesSection) {
144
- return [];
145
- }
146
- const sections = [customRulesSection, globalSection, projectSection, buildCurrentDateSection()]
147
- .filter(Boolean)
148
- .join('\n\n');
149
- const rulesReminder = `<system-reminder>
150
- As you answer the user's questions, you can use the following context:
151
- # agentMd
152
- Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.
153
-
154
- ${sections}
155
-
156
- IMPORTANT: this context may or may not be relevant to your tasks. You should not respond to this context unless it is highly relevant to your task.\n</system-reminder>`;
157
- return [{
158
- type: 'text',
159
- text: rulesReminder
160
- }];
161
- }
162
- //# sourceMappingURL=rules.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/util/rules.ts"],"names":[],"mappings":";;;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EG;AACH,SAAgB,sBAAsB;IACpC,MAAM,aAAa,GAAG,uBAAuB,CAAC,mBAAmB,EAAE,CAAC,CAAA;IACpE,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAA;IAC5C,MAAM,cAAc,GAAG,yBAAyB,EAAE,CAAA;IAClD,MAAM,kBAAkB,GAAG,uBAAuB,EAAE,CAAA;IAEpD,8BAA8B;IAC9B,IAAI,CAAC,aAAa,IAAI,CAAC,cAAc,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAC7D,OAAO,EAAE,CAAA;IACX,CAAC;IAED,MAAM,QAAQ,GAAG,CAAC,kBAAkB,EAAE,aAAa,EAAE,cAAc,EAAE,uBAAuB,EAAE,CAAC;SAC5F,MAAM,CAAC,OAAO,CAAC;SACf,IAAI,CAAC,MAAM,CAAC,CAAA;IAEf,MAAM,aAAa,GAAG;;;;;EAKtB,QAAQ;;wKAE8J,CAAA;IAEtK,OAAO,CAAC;YACN,IAAI,EAAE,MAAe;YACrB,IAAI,EAAE,aAAa;SACpB,CAAC,CAAA;AACJ,CAAC"}
@@ -1,10 +0,0 @@
1
- import Anthropic from '@anthropic-ai/sdk';
2
- /**
3
- * 生成 skills 相关的系统提醒信息
4
- */
5
- export declare function generateSkillsReminder(): Anthropic.ContentBlockParam[];
6
- /**
7
- * 生成 rules 相关的系统提醒信息
8
- */
9
- export declare function generateRulesReminders(): Anthropic.ContentBlockParam[];
10
- //# sourceMappingURL=systemReminder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"systemReminder.d.ts","sourceRoot":"","sources":["../../src/util/systemReminder.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAA;AAsGzC;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,SAAS,CAAC,iBAAiB,EAAE,CAUtE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,SAAS,CAAC,iBAAiB,EAAE,CA4BtE"}
@@ -1,177 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.generateSkillsReminder = generateSkillsReminder;
37
- exports.generateRulesReminders = generateRulesReminders;
38
- const fs = __importStar(require("fs"));
39
- const path = __importStar(require("path"));
40
- const cwd_1 = require("./cwd");
41
- const product_1 = require("../constants/product");
42
- const savePath_1 = require("./savePath");
43
- const ConfManager_1 = require("../manager/ConfManager");
44
- const skillsManager_1 = require("../services/skill/skillsManager");
45
- /**
46
- * 读取全局 ~/.claude/CLAUDE.md
47
- */
48
- function readGlobalAgentFile() {
49
- try {
50
- const agentPath = (0, savePath_1.getGlobalAgentMdPath)();
51
- console.log('agentPath:', agentPath);
52
- if (fs.existsSync(agentPath)) {
53
- return fs.readFileSync(agentPath, 'utf8');
54
- }
55
- return '';
56
- }
57
- catch (error) {
58
- return '';
59
- }
60
- }
61
- /**
62
- * 从配置管理器中获取自定义的 customRules
63
- */
64
- function readCustomRules() {
65
- try {
66
- const configManager = (0, ConfManager_1.getConfManager)();
67
- const coreConfig = configManager.getCoreConfig();
68
- return coreConfig?.customRules ?? '';
69
- }
70
- catch (error) {
71
- return '';
72
- }
73
- }
74
- /**
75
- * 生成 customRules 描述段
76
- */
77
- function buildCustomRulesSection() {
78
- const customRules = readCustomRules();
79
- if (!customRules)
80
- return '';
81
- return `Custom rules (user-defined instructions):\n\n${customRules}`;
82
- }
83
- /**
84
- * 读取当前目录下的项目配置文件
85
- * 优先读取 AGENT.md,如果不存在则读取 CLAUDE.md
86
- * 返回 { content, filePath } 或 null
87
- */
88
- function readProjectConfigFile() {
89
- try {
90
- const currentDir = (0, cwd_1.getOriginalCwd)();
91
- const agentPath = path.join(currentDir, product_1.PROJECT_FILE);
92
- const claudePath = path.join(currentDir, 'CLAUDE.md');
93
- if (fs.existsSync(agentPath)) {
94
- const content = fs.readFileSync(agentPath, 'utf8');
95
- if (content)
96
- return { content, filePath: agentPath };
97
- }
98
- if (fs.existsSync(claudePath)) {
99
- const content = fs.readFileSync(claudePath, 'utf8');
100
- if (content)
101
- return { content, filePath: claudePath };
102
- }
103
- return null;
104
- }
105
- catch (error) {
106
- return null;
107
- }
108
- }
109
- /**
110
- * 生成全局 agent 文件的描述段
111
- * 若文件不存在或内容为空则返回空字符串
112
- */
113
- function buildGlobalAgentSection(globalContent) {
114
- if (!globalContent)
115
- return '';
116
- return `Contents of ${(0, savePath_1.getGlobalAgentMdPath)()} (user's private global instructions for all projects):\n\n${globalContent}`;
117
- }
118
- /**
119
- * 生成项目配置文件的描述段
120
- * 优先使用 AGENT.md,没有才用 CLAUDE.md;若文件不存在或为空则返回空字符串
121
- */
122
- function buildProjectConfigSection() {
123
- const result = readProjectConfigFile();
124
- if (!result)
125
- return '';
126
- return `Contents of ${result.filePath} (project instructions, checked into the codebase):\n\n${result.content}`;
127
- }
128
- /**
129
- * 生成当前日期描述段
130
- */
131
- function buildCurrentDateSection() {
132
- const today = new Date();
133
- const dateStr = today.toISOString().slice(0, 10);
134
- return `# currentDate\nToday's date is ${dateStr}.`;
135
- }
136
- /**
137
- * 生成 skills 相关的系统提醒信息
138
- */
139
- function generateSkillsReminder() {
140
- const skillsDesc = (0, skillsManager_1.getSkillTypesDescription)();
141
- if (!skillsDesc)
142
- return [];
143
- const reminder = `<system-reminder>\nThe following skills are available for use with the Skill tool:\n\n${skillsDesc}\n</system-reminder>`;
144
- return [{
145
- type: 'text',
146
- text: reminder
147
- }];
148
- }
149
- /**
150
- * 生成 rules 相关的系统提醒信息
151
- */
152
- function generateRulesReminders() {
153
- const globalSection = buildGlobalAgentSection(readGlobalAgentFile());
154
- console.log('globalSection:', globalSection);
155
- const projectSection = buildProjectConfigSection();
156
- const customRulesSection = buildCustomRulesSection();
157
- // 如果全局、项目配置和系统规则配置均为空,直接返回空数组
158
- if (!globalSection && !projectSection && !customRulesSection) {
159
- return [];
160
- }
161
- const sections = [customRulesSection, globalSection, projectSection, buildCurrentDateSection()]
162
- .filter(Boolean)
163
- .join('\n\n');
164
- const rulesReminder = `<system-reminder>
165
- As you answer the user's questions, you can use the following context:
166
- # agentMd
167
- Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.
168
-
169
- ${sections}
170
-
171
- IMPORTANT: this context may or may not be relevant to your tasks. You should not respond to this context unless it is highly relevant to your task.\n</system-reminder>`;
172
- return [{
173
- type: 'text',
174
- text: rulesReminder
175
- }];
176
- }
177
- //# sourceMappingURL=systemReminder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"systemReminder.js","sourceRoot":"","sources":["../../src/util/systemReminder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGA,wDAUC;AAKD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