@fleetagent/pi-coding-agent 0.0.4 → 0.0.6
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/CHANGELOG.md +48 -0
- package/README.md +28 -5
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +9 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-session.d.ts +4 -3
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +44 -8
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/diagnostics.d.ts +1 -1
- package/dist/core/diagnostics.d.ts.map +1 -1
- package/dist/core/diagnostics.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +4 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +5 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +2 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/package-manager.d.ts +1 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +130 -12
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/resource-loader.d.ts +30 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +94 -0
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/rules.d.ts +57 -0
- package/dist/core/rules.d.ts.map +1 -0
- package/dist/core/rules.js +384 -0
- package/dist/core/rules.js.map +1 -0
- package/dist/core/settings-manager.d.ts +5 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +14 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts +3 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +11 -3
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +6 -2
- package/dist/core/tools/read.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +3 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +12 -3
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +1 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +34 -4
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +14 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +34 -11
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +18 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +17 -2
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/extensions.md +9 -8
- package/docs/index.md +3 -2
- package/docs/packages.md +6 -4
- package/docs/quickstart.md +1 -1
- package/docs/rpc.md +4 -2
- package/docs/rules.md +102 -0
- package/docs/sdk.md +1 -1
- package/docs/settings.md +3 -2
- package/docs/usage.md +4 -2
- package/examples/extensions/README.md +1 -1
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/dynamic-resources/RULES.md +8 -0
- package/examples/extensions/dynamic-resources/index.ts +1 -0
- package/examples/extensions/reload-runtime.ts +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/12-full-control.ts +1 -0
- package/examples/sdk/README.md +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
|
@@ -663,10 +663,12 @@ export class AgentSession {
|
|
|
663
663
|
const loaderAppendSystemPrompt = this._resourceLoader.getAppendSystemPrompt();
|
|
664
664
|
const appendSystemPrompt = loaderAppendSystemPrompt.length > 0 ? loaderAppendSystemPrompt.join("\n\n") : undefined;
|
|
665
665
|
const loadedSkills = this._resourceLoader.getSkills().skills;
|
|
666
|
+
const loadedRules = this._resourceLoader.getRules().rules;
|
|
666
667
|
const loadedContextFiles = this._resourceLoader.getAgentsFiles().agentsFiles;
|
|
667
668
|
this._baseSystemPromptOptions = {
|
|
668
669
|
cwd: this._cwd,
|
|
669
670
|
skills: loadedSkills,
|
|
671
|
+
rules: loadedRules,
|
|
670
672
|
contextFiles: loadedContextFiles,
|
|
671
673
|
customPrompt: loaderSystemPrompt,
|
|
672
674
|
appendSystemPrompt,
|
|
@@ -928,10 +930,11 @@ export class AgentSession {
|
|
|
928
930
|
currentImages = inputResult.images ?? currentImages;
|
|
929
931
|
}
|
|
930
932
|
}
|
|
931
|
-
// Expand skill commands (/skill:name args) and prompt templates (/template args)
|
|
933
|
+
// Expand skill/rule commands (/skill:name or /rule:name args) and prompt templates (/template args)
|
|
932
934
|
let expandedText = currentText;
|
|
933
935
|
if (expandPromptTemplates) {
|
|
934
936
|
expandedText = this._expandSkillCommand(expandedText);
|
|
937
|
+
expandedText = this._expandRuleCommand(expandedText);
|
|
935
938
|
expandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);
|
|
936
939
|
}
|
|
937
940
|
// If streaming, queue via steer() or followUp() based on option
|
|
@@ -1084,11 +1087,35 @@ export class AgentSession {
|
|
|
1084
1087
|
return text; // Return original on error
|
|
1085
1088
|
}
|
|
1086
1089
|
}
|
|
1090
|
+
_expandRuleCommand(text) {
|
|
1091
|
+
if (!text.startsWith("/rule:"))
|
|
1092
|
+
return text;
|
|
1093
|
+
const spaceIndex = text.indexOf(" ");
|
|
1094
|
+
const ruleName = spaceIndex === -1 ? text.slice(6) : text.slice(6, spaceIndex);
|
|
1095
|
+
const args = spaceIndex === -1 ? "" : text.slice(spaceIndex + 1).trim();
|
|
1096
|
+
const rule = this.resourceLoader.getRules().rules.find((r) => r.name === ruleName);
|
|
1097
|
+
if (!rule)
|
|
1098
|
+
return text; // Unknown rule, pass through
|
|
1099
|
+
try {
|
|
1100
|
+
const content = readFileSync(rule.filePath, "utf-8");
|
|
1101
|
+
const body = stripFrontmatter(content).trim();
|
|
1102
|
+
const ruleBlock = `<rule name="${rule.name}" location="${rule.filePath}">\nReferences are relative to ${rule.baseDir}.\n\n${body}\n</rule>`;
|
|
1103
|
+
return args ? `${ruleBlock}\n\n${args}` : ruleBlock;
|
|
1104
|
+
}
|
|
1105
|
+
catch (err) {
|
|
1106
|
+
this._extensionRunner.emitError({
|
|
1107
|
+
extensionPath: rule.filePath,
|
|
1108
|
+
event: "rule_expansion",
|
|
1109
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1110
|
+
});
|
|
1111
|
+
return text;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1087
1114
|
/**
|
|
1088
1115
|
* Queue a steering message while the agent is running.
|
|
1089
1116
|
* Delivered after the current assistant turn finishes executing its tool calls,
|
|
1090
1117
|
* before the next LLM call.
|
|
1091
|
-
* Expands skill commands and prompt templates. Errors on extension commands.
|
|
1118
|
+
* Expands skill/rule commands and prompt templates. Errors on extension commands.
|
|
1092
1119
|
* @param images Optional image attachments to include with the message
|
|
1093
1120
|
* @throws Error if text is an extension command
|
|
1094
1121
|
*/
|
|
@@ -1097,15 +1124,16 @@ export class AgentSession {
|
|
|
1097
1124
|
if (text.startsWith("/")) {
|
|
1098
1125
|
this._throwIfExtensionCommand(text);
|
|
1099
1126
|
}
|
|
1100
|
-
// Expand skill commands and prompt templates
|
|
1127
|
+
// Expand skill/rule commands and prompt templates
|
|
1101
1128
|
let expandedText = this._expandSkillCommand(text);
|
|
1129
|
+
expandedText = this._expandRuleCommand(expandedText);
|
|
1102
1130
|
expandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);
|
|
1103
1131
|
await this._queueSteer(expandedText, images);
|
|
1104
1132
|
}
|
|
1105
1133
|
/**
|
|
1106
1134
|
* Queue a follow-up message to be processed after the agent finishes.
|
|
1107
1135
|
* Delivered only when agent has no more tool calls or steering messages.
|
|
1108
|
-
* Expands skill commands and prompt templates. Errors on extension commands.
|
|
1136
|
+
* Expands skill/rule commands and prompt templates. Errors on extension commands.
|
|
1109
1137
|
* @param images Optional image attachments to include with the message
|
|
1110
1138
|
* @throws Error if text is an extension command
|
|
1111
1139
|
*/
|
|
@@ -1114,8 +1142,9 @@ export class AgentSession {
|
|
|
1114
1142
|
if (text.startsWith("/")) {
|
|
1115
1143
|
this._throwIfExtensionCommand(text);
|
|
1116
1144
|
}
|
|
1117
|
-
// Expand skill commands and prompt templates
|
|
1145
|
+
// Expand skill/rule commands and prompt templates
|
|
1118
1146
|
let expandedText = this._expandSkillCommand(text);
|
|
1147
|
+
expandedText = this._expandRuleCommand(expandedText);
|
|
1119
1148
|
expandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);
|
|
1120
1149
|
await this._queueFollowUp(expandedText, images);
|
|
1121
1150
|
}
|
|
@@ -1851,12 +1880,13 @@ export class AgentSession {
|
|
|
1851
1880
|
if (!this._extensionRunner.hasHandlers("resources_discover")) {
|
|
1852
1881
|
return;
|
|
1853
1882
|
}
|
|
1854
|
-
const { skillPaths, promptPaths, themePaths } = await this._extensionRunner.emitResourcesDiscover(this._cwd, reason);
|
|
1855
|
-
if (skillPaths.length === 0 && promptPaths.length === 0 && themePaths.length === 0) {
|
|
1883
|
+
const { skillPaths, rulePaths, promptPaths, themePaths } = await this._extensionRunner.emitResourcesDiscover(this._cwd, reason);
|
|
1884
|
+
if (skillPaths.length === 0 && rulePaths.length === 0 && promptPaths.length === 0 && themePaths.length === 0) {
|
|
1856
1885
|
return;
|
|
1857
1886
|
}
|
|
1858
1887
|
const extensionPaths = {
|
|
1859
1888
|
skillPaths: this.buildExtensionResourcePaths(skillPaths),
|
|
1889
|
+
rulePaths: this.buildExtensionResourcePaths(rulePaths),
|
|
1860
1890
|
promptPaths: this.buildExtensionResourcePaths(promptPaths),
|
|
1861
1891
|
themePaths: this.buildExtensionResourcePaths(themePaths),
|
|
1862
1892
|
};
|
|
@@ -1926,7 +1956,13 @@ export class AgentSession {
|
|
|
1926
1956
|
source: "skill",
|
|
1927
1957
|
sourceInfo: skill.sourceInfo,
|
|
1928
1958
|
}));
|
|
1929
|
-
|
|
1959
|
+
const rules = this._resourceLoader.getRules().rules.map((rule) => ({
|
|
1960
|
+
name: `rule:${rule.name}`,
|
|
1961
|
+
description: rule.description,
|
|
1962
|
+
source: "rule",
|
|
1963
|
+
sourceInfo: rule.sourceInfo,
|
|
1964
|
+
}));
|
|
1965
|
+
return [...extensionCommands, ...templates, ...skills, ...rules];
|
|
1930
1966
|
};
|
|
1931
1967
|
runner.bindCore({
|
|
1932
1968
|
sendMessage: (message, options) => {
|