@caupulican/pi-adaptative 0.80.38 → 0.80.42

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 (32) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/core/agent-session.d.ts.map +1 -1
  3. package/dist/core/agent-session.js +18 -10
  4. package/dist/core/agent-session.js.map +1 -1
  5. package/dist/core/compaction/compaction.d.ts +1 -1
  6. package/dist/core/compaction/compaction.d.ts.map +1 -1
  7. package/dist/core/compaction/compaction.js +4 -2
  8. package/dist/core/compaction/compaction.js.map +1 -1
  9. package/dist/core/settings-manager.d.ts +2 -0
  10. package/dist/core/settings-manager.d.ts.map +1 -1
  11. package/dist/core/settings-manager.js +1 -0
  12. package/dist/core/settings-manager.js.map +1 -1
  13. package/dist/core/system-prompt.d.ts.map +1 -1
  14. package/dist/core/system-prompt.js +3 -0
  15. package/dist/core/system-prompt.js.map +1 -1
  16. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  17. package/dist/modes/interactive/components/settings-selector.js +3 -1
  18. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  19. package/dist/modes/interactive/interactive-mode.d.ts +3 -0
  20. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  21. package/dist/modes/interactive/interactive-mode.js +38 -14
  22. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  23. package/docs/adaptive-extension-shared-state-audit.md +1 -1
  24. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  25. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  26. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  27. package/examples/extensions/sandbox/package-lock.json +2 -2
  28. package/examples/extensions/sandbox/package.json +1 -1
  29. package/examples/extensions/with-deps/package-lock.json +2 -2
  30. package/examples/extensions/with-deps/package.json +1 -1
  31. package/npm-shrinkwrap.json +12 -12
  32. package/package.json +4 -4
@@ -4258,22 +4258,43 @@ export class InteractiveMode {
4258
4258
  return undefined;
4259
4259
  return `Auto Learn model "${modelValue}" is not in configured subscription/API models; saved as manual/unverified.`;
4260
4260
  }
4261
+ collectSelfModificationCandidates(settings) {
4262
+ return [
4263
+ ...(Array.isArray(settings.sourcePaths) ? settings.sourcePaths : []),
4264
+ ...(settings.sourcePath ? [settings.sourcePath] : []),
4265
+ ]
4266
+ .map((candidate) => candidate?.trim())
4267
+ .filter((candidate) => Boolean(candidate));
4268
+ }
4269
+ getCurrentCwdForSettings() {
4270
+ return this.runtimeHost?.session?.sessionManager?.getCwd?.() || process.cwd();
4271
+ }
4272
+ resolveSelfModificationSource(settings) {
4273
+ const cwd = this.getCurrentCwdForSettings();
4274
+ const resolved = this.collectSelfModificationCandidates(settings).map((candidate) => resolvePath(candidate, cwd, { trim: true }));
4275
+ if (resolved.length === 0)
4276
+ return undefined;
4277
+ return (resolved.find((candidate) => fs.existsSync(candidate) && fs.existsSync(path.join(candidate, "package.json"))) ?? resolved[0]);
4278
+ }
4261
4279
  validateSelfModificationSource(settings) {
4262
4280
  if (!settings.enabled)
4263
4281
  return undefined;
4264
- const rawPath = settings.sourcePath?.trim();
4265
- if (!rawPath)
4282
+ const cwd = this.getCurrentCwdForSettings();
4283
+ const resolved = this.collectSelfModificationCandidates(settings).map((candidate) => resolvePath(candidate, cwd, { trim: true }));
4284
+ if (resolved.length === 0)
4266
4285
  return "Self modification is enabled, but no pi-adaptative source path is set.";
4267
- const sourcePath = resolvePath(rawPath, this.sessionManager.getCwd(), { trim: true });
4268
- if (!fs.existsSync(sourcePath))
4269
- return `Self modification source path does not exist: ${sourcePath}`;
4270
- if (!fs.existsSync(path.join(sourcePath, "package.json"))) {
4271
- return `Self modification source path has no package.json: ${sourcePath}`;
4272
- }
4273
- if (!fs.existsSync(path.join(sourcePath, "packages", "coding-agent"))) {
4274
- return `Self modification source path does not look like pi-adaptative (missing packages/coding-agent): ${sourcePath}`;
4286
+ const valid = resolved.find((candidate) => fs.existsSync(candidate) &&
4287
+ fs.existsSync(path.join(candidate, "package.json")) &&
4288
+ fs.existsSync(path.join(candidate, "packages", "coding-agent")));
4289
+ if (valid)
4290
+ return undefined;
4291
+ const first = resolved[0];
4292
+ if (!fs.existsSync(first))
4293
+ return `Self modification source path does not exist: ${first}`;
4294
+ if (!fs.existsSync(path.join(first, "package.json"))) {
4295
+ return `Self modification source path has no package.json: ${first}`;
4275
4296
  }
4276
- return undefined;
4297
+ return `Self modification source path does not look like pi-adaptative (missing packages/coding-agent): ${first}`;
4277
4298
  }
4278
4299
  evaluateAutoLearn(force = false) {
4279
4300
  const settings = this.getEffectiveAutoLearnSettings();
@@ -4292,9 +4313,12 @@ export class InteractiveMode {
4292
4313
  "- Durable memory writes require the configured high-confidence policy; skills, extensions, source, settings, publishing, tagging, and releases remain proposals unless the foreground user explicitly asks.",
4293
4314
  ].join("\n");
4294
4315
  }
4295
- const sourceAuthority = selfModification.enabled && selfModification.sourcePath?.trim()
4296
- ? `- Pi source: standing authority to edit the authorized selfModification.sourcePath (${selfModification.sourcePath.trim()}) for self-evolution improvements; inspect git status first, preserve unrelated user changes, run focused validation, and leave a clear rollback/test summary.`
4297
- : "- Pi source: no standing source-edit authority until selfModification.enabled and selfModification.sourcePath are set.";
4316
+ const selfModificationSource = selfModification.enabled
4317
+ ? this.resolveSelfModificationSource(selfModification)
4318
+ : undefined;
4319
+ const sourceAuthority = selfModification.enabled && selfModificationSource
4320
+ ? `- Pi source: standing authority to edit the authorized selfModification source (${selfModificationSource}) for self-evolution improvements; inspect git status first, preserve unrelated user changes, run focused validation, and leave a clear rollback/test summary.`
4321
+ : "- Pi source: no standing source-edit authority until selfModification.enabled and selfModification.sourcePaths are set.";
4298
4322
  return [
4299
4323
  "Authority mode: FULL AUTONOMOUS standing grant.",
4300
4324
  "- Memory: may apply high-confidence durable Automata memory/corrections after duplicate and corroboration checks.",