@amical/aiagent-sdk 0.1.6 → 0.1.7
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/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +50 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -1
- package/dist/index.mjs.map +1 -1
- package/dist/runtime/nodeRuntime.d.mts +1 -0
- package/dist/runtime/nodeRuntime.d.ts +1 -0
- package/dist/runtime/nodeRuntime.js +58 -1
- package/dist/runtime/nodeRuntime.js.map +1 -1
- package/dist/runtime/nodeRuntime.mjs +58 -1
- package/dist/runtime/nodeRuntime.mjs.map +1 -1
- package/dist/runtime/webRuntime.d.mts +1 -0
- package/dist/runtime/webRuntime.d.ts +1 -0
- package/dist/runtime/webRuntime.js +58 -1
- package/dist/runtime/webRuntime.js.map +1 -1
- package/dist/runtime/webRuntime.mjs +58 -1
- package/dist/runtime/webRuntime.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -491,6 +491,7 @@ var ClineAgent = class {
|
|
|
491
491
|
/** 最大循环次数 */
|
|
492
492
|
maxLoopCount;
|
|
493
493
|
skillDir;
|
|
494
|
+
rulesDir;
|
|
494
495
|
customTools;
|
|
495
496
|
customToolNames;
|
|
496
497
|
allowDefaultTools;
|
|
@@ -539,7 +540,8 @@ var ClineAgent = class {
|
|
|
539
540
|
}
|
|
540
541
|
}
|
|
541
542
|
this.customToolNames = new Set(this.customTools.map((t) => t.name));
|
|
542
|
-
this.skillDir = this.runtime.path.join(this.runtime.env.cwd(), ".
|
|
543
|
+
this.skillDir = this.runtime.path.join(this.runtime.env.cwd(), ".agents/skills");
|
|
544
|
+
this.rulesDir = this.runtime.path.join(this.runtime.env.cwd(), ".agents/rules");
|
|
543
545
|
}
|
|
544
546
|
setState(newState) {
|
|
545
547
|
this.state = newState;
|
|
@@ -560,6 +562,7 @@ var ClineAgent = class {
|
|
|
560
562
|
os: this.runtime.env.osInfo(),
|
|
561
563
|
shell: this.runtime.env.shell(),
|
|
562
564
|
skills: await this.getSkills(),
|
|
565
|
+
agentRules: await this.getAgentRules(),
|
|
563
566
|
customTools: this.customTools,
|
|
564
567
|
allowDefaultTools: this.allowDefaultTools,
|
|
565
568
|
customInstructions: this.customInstructions
|
|
@@ -586,6 +589,52 @@ var ClineAgent = class {
|
|
|
586
589
|
throw err;
|
|
587
590
|
}
|
|
588
591
|
}
|
|
592
|
+
/**
|
|
593
|
+
* 读取项目级 Agent Rules:
|
|
594
|
+
* 1. ${cwd}/Agents.md
|
|
595
|
+
* 2. ${cwd}/.agents/rules/ 一级目录下所有 .md 文件
|
|
596
|
+
* 将内容合并为一段文本,供系统提示词注入。
|
|
597
|
+
*/
|
|
598
|
+
async getAgentRules() {
|
|
599
|
+
const cwd = this.runtime.env.cwd();
|
|
600
|
+
const rules = [];
|
|
601
|
+
const agentsMdPath = this.runtime.path.join(cwd, "Agents.md");
|
|
602
|
+
try {
|
|
603
|
+
if (await this.runtime.fs.fileExists(agentsMdPath)) {
|
|
604
|
+
const content = await this.runtime.fs.readFile(agentsMdPath);
|
|
605
|
+
if (content && content.trim()) {
|
|
606
|
+
rules.push(content.trim());
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
} catch (e) {
|
|
610
|
+
}
|
|
611
|
+
try {
|
|
612
|
+
if (await this.runtime.fs.fileExists(this.rulesDir)) {
|
|
613
|
+
const files = await this.runtime.fs.readDir(this.rulesDir);
|
|
614
|
+
for (const file of files) {
|
|
615
|
+
if (!file.isFile()) {
|
|
616
|
+
continue;
|
|
617
|
+
}
|
|
618
|
+
const name = String(file.name);
|
|
619
|
+
if (!name.toLowerCase().endsWith(".md")) {
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
const filePath = this.runtime.path.join(this.rulesDir, name);
|
|
623
|
+
try {
|
|
624
|
+
const content = await this.runtime.fs.readFile(filePath);
|
|
625
|
+
if (content && content.trim()) {
|
|
626
|
+
rules.push(`\`\`\`markdown
|
|
627
|
+
# ${name}
|
|
628
|
+
${content.trim()}\`\`\``);
|
|
629
|
+
}
|
|
630
|
+
} catch (e) {
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
} catch (e) {
|
|
635
|
+
}
|
|
636
|
+
return rules.join("\n---\n");
|
|
637
|
+
}
|
|
589
638
|
async getSkills() {
|
|
590
639
|
const skillDir = this.skillDir;
|
|
591
640
|
const skillList = [];
|
|
@@ -1085,6 +1134,14 @@ ${this.getToolInstructions(context)}
|
|
|
1085
1134
|
if (envPrompt) {
|
|
1086
1135
|
prompt += `
|
|
1087
1136
|
${envPrompt}
|
|
1137
|
+
`;
|
|
1138
|
+
}
|
|
1139
|
+
if (context.agentRules) {
|
|
1140
|
+
prompt += `
|
|
1141
|
+
# Project Rules
|
|
1142
|
+
|
|
1143
|
+
The user has specified instructions for all working directories:
|
|
1144
|
+
${context.agentRules}
|
|
1088
1145
|
`;
|
|
1089
1146
|
}
|
|
1090
1147
|
if (context.customInstructions) {
|