@caupulican/pi-adaptative 0.78.1 → 0.78.3
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 +30 -0
- package/README.md +14 -12
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-session.d.ts +1 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +34 -12
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/types.d.ts +16 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +10 -0
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +1 -0
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/prompt-templates.d.ts +3 -2
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +8 -3
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +1 -0
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/resource-loader.d.ts +5 -5
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +1 -9
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +169 -80
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +23 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +19 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +3 -7
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +6 -3
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts +3 -3
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +27 -18
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js +4 -3
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js +4 -3
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js +1 -0
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts +1 -1
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +29 -4
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +2 -2
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +2 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +2 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts +7 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +66 -8
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tool-group.d.ts +17 -0
- package/dist/modes/interactive/components/tool-group.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-group.js +63 -0
- package/dist/modes/interactive/components/tool-group.js.map +1 -0
- package/dist/modes/interactive/components/tool-panel-registry.d.ts +23 -0
- package/dist/modes/interactive/components/tool-panel-registry.d.ts.map +1 -0
- package/dist/modes/interactive/components/tool-panel-registry.js +70 -0
- package/dist/modes/interactive/components/tool-panel-registry.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +6 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +119 -60
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +4 -1
- package/dist/utils/paths.js.map +1 -1
- package/docs/extensions.md +6 -3
- package/docs/quickstart.md +3 -3
- package/docs/sdk.md +1 -1
- package/docs/settings.md +50 -0
- package/docs/skills.md +3 -3
- package/docs/usage.md +3 -3
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/07-context-files.ts +3 -14
- package/npm-shrinkwrap.json +18 -15
- package/package.json +4 -4
|
@@ -691,6 +691,33 @@ export class AgentSession {
|
|
|
691
691
|
}
|
|
692
692
|
return Array.from(unique);
|
|
693
693
|
}
|
|
694
|
+
_buildSelfModificationPrompt() {
|
|
695
|
+
const settings = this.settingsManager.getSelfModificationSettings();
|
|
696
|
+
if (!settings.enabled) {
|
|
697
|
+
return `Pi self-modification guardrails (local setting inactive):
|
|
698
|
+
- Do not modify Pi core, the installed Pi runtime, or pi-adaptative harness source for self-evolution.
|
|
699
|
+
- If self-modification is needed, ask the user to enable \`selfModification.enabled\` and set \`selfModification.sourcePath\` to the pi-adaptative source checkout.`;
|
|
700
|
+
}
|
|
701
|
+
const rawSourcePath = settings.sourcePath?.trim();
|
|
702
|
+
if (!rawSourcePath) {
|
|
703
|
+
return `Pi self-modification guardrails (local setting active, source missing):
|
|
704
|
+
- Self-modification is enabled, but \`selfModification.sourcePath\` is not set.
|
|
705
|
+
- Do not modify Pi core or runtime output. Ask the user to set \`selfModification.sourcePath\` to the pi-adaptative source checkout before proceeding.`;
|
|
706
|
+
}
|
|
707
|
+
const sourcePath = resolvePath(rawSourcePath, this._cwd, { trim: true });
|
|
708
|
+
const sourceLooksValid = existsSync(sourcePath) && existsSync(resolvePath("package.json", sourcePath));
|
|
709
|
+
const sourceStatus = sourceLooksValid
|
|
710
|
+
? sourcePath
|
|
711
|
+
: `${sourcePath} (missing or not a source checkout; ask the user to correct \`selfModification.sourcePath\` before editing)`;
|
|
712
|
+
return `Pi self-modification guardrails (local setting active):
|
|
713
|
+
- Authorized pi-adaptative source path: ${sourceStatus}
|
|
714
|
+
- Only modify Pi core/harness source under the authorized source path; never patch installed node_modules or generated runtime output as the source of truth.
|
|
715
|
+
- Before changing Pi itself, restate the objective and scope, inspect relevant source/docs/examples, and make the smallest auditable change.
|
|
716
|
+
- Preserve user changes: check git status before and after, avoid unrelated edits, and do not overwrite concurrent work.
|
|
717
|
+
- Validate with focused tests and broader checks proportional to risk before claiming success.
|
|
718
|
+
- Reload/restart/renew only after source changes are saved and auditable.
|
|
719
|
+
- Ask for explicit approval before changing global settings, publishing, tagging, or releasing.`;
|
|
720
|
+
}
|
|
694
721
|
_rebuildSystemPrompt(toolNames) {
|
|
695
722
|
const validToolNames = toolNames.filter((name) => this._toolRegistry.has(name));
|
|
696
723
|
const toolSnippets = {};
|
|
@@ -707,7 +734,8 @@ export class AgentSession {
|
|
|
707
734
|
}
|
|
708
735
|
const loaderSystemPrompt = this._resourceLoader.getSystemPrompt();
|
|
709
736
|
const loaderAppendSystemPrompt = this._resourceLoader.getAppendSystemPrompt();
|
|
710
|
-
const
|
|
737
|
+
const appendSystemPromptParts = [this._buildSelfModificationPrompt(), ...loaderAppendSystemPrompt];
|
|
738
|
+
const appendSystemPrompt = appendSystemPromptParts.length > 0 ? appendSystemPromptParts.join("\n\n") : undefined;
|
|
711
739
|
const loadedSkills = this._resourceLoader.getSkills().skills;
|
|
712
740
|
const loadedContextFiles = this._resourceLoader.getAgentsFiles().agentsFiles;
|
|
713
741
|
this._baseSystemPromptOptions = {
|
|
@@ -845,18 +873,12 @@ export class AgentSession {
|
|
|
845
873
|
}
|
|
846
874
|
throw new Error(formatNoApiKeyFoundMessage(this.model.provider));
|
|
847
875
|
}
|
|
848
|
-
// Check if we need to compact before sending (catches aborted responses)
|
|
876
|
+
// Check if we need to compact before sending (catches aborted responses).
|
|
877
|
+
// Do not call agent.continue() here: the next model turn must include the
|
|
878
|
+
// user's pending prompt, not an empty continuation after compaction.
|
|
849
879
|
const lastAssistant = this._findLastAssistantMessage();
|
|
850
|
-
if (lastAssistant
|
|
851
|
-
|
|
852
|
-
await this.agent.continue();
|
|
853
|
-
while (await this._handlePostAgentRun()) {
|
|
854
|
-
await this.agent.continue();
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
finally {
|
|
858
|
-
this._flushPendingBashMessages();
|
|
859
|
-
}
|
|
880
|
+
if (lastAssistant) {
|
|
881
|
+
await this._checkCompaction(lastAssistant, false);
|
|
860
882
|
}
|
|
861
883
|
// Build messages array (custom message if any, then user message)
|
|
862
884
|
messages = [];
|