@harperfast/agent 0.14.1 → 0.15.0
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/agent.js +37 -24
- package/package.json +2 -2
package/dist/agent.js
CHANGED
|
@@ -488,13 +488,20 @@ async function handleExit() {
|
|
|
488
488
|
process.exit(0);
|
|
489
489
|
}
|
|
490
490
|
|
|
491
|
-
// lifecycle/
|
|
491
|
+
// lifecycle/readAgentSkillsRoot.ts
|
|
492
492
|
import { existsSync as existsSync3, readFileSync } from "fs";
|
|
493
493
|
import { join as join4 } from "path";
|
|
494
|
-
|
|
495
|
-
|
|
494
|
+
|
|
495
|
+
// lifecycle/agentsSkillReference.ts
|
|
496
|
+
var agentsSkillDir = ".agents/skills/harper-best-practices";
|
|
497
|
+
var agentsSkillReference = `${agentsSkillDir}/SKILL.md`;
|
|
498
|
+
|
|
499
|
+
// lifecycle/readAgentSkillsRoot.ts
|
|
500
|
+
function readAgentSkillsRoot() {
|
|
501
|
+
const agentsFile = join4(trackedState.cwd, agentsSkillReference);
|
|
502
|
+
const agentsMdExists = existsSync3(agentsFile);
|
|
496
503
|
if (agentsMdExists) {
|
|
497
|
-
return readFileSync(
|
|
504
|
+
return readFileSync(agentsFile, "utf8");
|
|
498
505
|
}
|
|
499
506
|
}
|
|
500
507
|
|
|
@@ -796,17 +803,23 @@ import { readdirSync, readFileSync as readFileSync2 } from "fs";
|
|
|
796
803
|
import { createRequire } from "module";
|
|
797
804
|
import { dirname as dirname2, join as join5 } from "path";
|
|
798
805
|
import { z as z10 } from "zod";
|
|
799
|
-
var
|
|
800
|
-
var
|
|
801
|
-
|
|
802
|
-
|
|
806
|
+
var require2 = createRequire(import.meta.url);
|
|
807
|
+
var harperSkillsModuleDir = dirname2(
|
|
808
|
+
require2.resolve("@harperfast/skills/package.json")
|
|
809
|
+
);
|
|
810
|
+
var harperBestPracticesDir = join5(
|
|
811
|
+
harperSkillsModuleDir,
|
|
812
|
+
"harper-best-practices"
|
|
813
|
+
);
|
|
814
|
+
var skillRootFile = join5(
|
|
815
|
+
harperBestPracticesDir,
|
|
816
|
+
"SKILL.md"
|
|
803
817
|
);
|
|
804
|
-
var
|
|
805
|
-
|
|
806
|
-
"
|
|
807
|
-
"skills"
|
|
818
|
+
var rulesDir = join5(
|
|
819
|
+
harperBestPracticesDir,
|
|
820
|
+
"rules"
|
|
808
821
|
);
|
|
809
|
-
var skillLinkRegex = /\[[^\]]+]\(skills\/([^)]+)\.md\)/g;
|
|
822
|
+
var skillLinkRegex = /\[[^\]]+]\((?:rules|skills)\/([^)]+)\.md\)/g;
|
|
810
823
|
var skills = getSkills();
|
|
811
824
|
var ToolParameters10 = z10.object({
|
|
812
825
|
skill: z10.enum(skills.length > 0 ? skills : ["none"]).describe(
|
|
@@ -821,24 +834,24 @@ var getHarperSkillTool = tool10({
|
|
|
821
834
|
});
|
|
822
835
|
function getSkillsDescription() {
|
|
823
836
|
try {
|
|
824
|
-
return readFileSync2(
|
|
837
|
+
return readFileSync2(skillRootFile, "utf8").replace("This repository contains", "This tool describes").replace(skillLinkRegex, "$1");
|
|
825
838
|
} catch {
|
|
826
839
|
return "Returns the contents of a Harper skill markdown file. Skills provide guidance on developing Harper applications.";
|
|
827
840
|
}
|
|
828
841
|
}
|
|
829
842
|
function getSkills() {
|
|
830
843
|
try {
|
|
831
|
-
return readdirSync(
|
|
844
|
+
return readdirSync(rulesDir).filter((file) => file.endsWith(".md")).map((file) => file.replace(".md", ""));
|
|
832
845
|
} catch {
|
|
833
846
|
return [];
|
|
834
847
|
}
|
|
835
848
|
}
|
|
836
849
|
async function execute10({ skill }) {
|
|
837
850
|
if (skill === "none") {
|
|
838
|
-
return "No
|
|
851
|
+
return "No skill requested.";
|
|
839
852
|
}
|
|
840
853
|
try {
|
|
841
|
-
const filePath = join5(
|
|
854
|
+
const filePath = join5(rulesDir, `${skill}.md`);
|
|
842
855
|
const content = readFileSync2(filePath, "utf8");
|
|
843
856
|
agentManager.session?.addSkillRead?.(skill);
|
|
844
857
|
return content;
|
|
@@ -1176,18 +1189,18 @@ async function execute12({ path: path9 }) {
|
|
|
1176
1189
|
}
|
|
1177
1190
|
process.chdir(target);
|
|
1178
1191
|
trackedState.cwd = process.cwd();
|
|
1179
|
-
const
|
|
1180
|
-
if (
|
|
1192
|
+
const agentSkillsRoot = readAgentSkillsRoot();
|
|
1193
|
+
if (agentSkillsRoot) {
|
|
1181
1194
|
if (agentManager.agent) {
|
|
1182
|
-
agentManager.agent.instructions =
|
|
1195
|
+
agentManager.agent.instructions = agentSkillsRoot;
|
|
1183
1196
|
}
|
|
1184
1197
|
emitToListeners("PushNewMessages", [{
|
|
1185
1198
|
type: "agent",
|
|
1186
|
-
text: "Detected
|
|
1199
|
+
text: "Detected agent skills, reading its contents.",
|
|
1187
1200
|
version: 1
|
|
1188
1201
|
}]);
|
|
1189
|
-
return `Switched current working directory to ${trackedState.cwd}, with
|
|
1190
|
-
${
|
|
1202
|
+
return `Switched current working directory to ${trackedState.cwd}, with ${agentsSkillReference} file containing:
|
|
1203
|
+
${agentSkillsRoot}
|
|
1191
1204
|
I strongly suggest you use these newfound skills!`;
|
|
1192
1205
|
}
|
|
1193
1206
|
return `Switched current working directory to ${trackedState.cwd}`;
|
|
@@ -3728,7 +3741,7 @@ var AgentManager = class {
|
|
|
3728
3741
|
name: "Harper Agent",
|
|
3729
3742
|
model: isOpenAIModel(trackedState.model) ? trackedState.model : getModel(trackedState.model),
|
|
3730
3743
|
modelSettings: getModelSettings(trackedState.model),
|
|
3731
|
-
instructions:
|
|
3744
|
+
instructions: readAgentSkillsRoot() || defaultInstructions(),
|
|
3732
3745
|
tools: createTools()
|
|
3733
3746
|
});
|
|
3734
3747
|
this.session = createSession(trackedState.sessionPath);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harperfast/agent",
|
|
3
3
|
"description": "AI to help you with Harper app management",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.15.0",
|
|
5
5
|
"main": "dist/agent.js",
|
|
6
6
|
"repository": "github:HarperFast/harper-agent",
|
|
7
7
|
"bugs": {
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"@ai-sdk/anthropic": "^3.0.41",
|
|
47
47
|
"@ai-sdk/google": "^3.0.24",
|
|
48
48
|
"@ai-sdk/openai": "^3.0.26",
|
|
49
|
+
"@harperfast/skills": "^1.0.0",
|
|
49
50
|
"@inkjs/ui": "^2.0.0",
|
|
50
51
|
"@openai/agents": "^0.4.6",
|
|
51
52
|
"@openai/agents-extensions": "^0.4.6",
|
|
52
53
|
"ai": "^6.0.79",
|
|
53
54
|
"chalk": "^5.6.2",
|
|
54
|
-
"create-harper": "^1.0.0",
|
|
55
55
|
"cross-spawn": "^7.0.6",
|
|
56
56
|
"dotenv": "^17.2.4",
|
|
57
57
|
"ink": "^6.7.0",
|