@earendil-works/pi-coding-agent 0.74.0 → 0.75.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/CHANGELOG.md +57 -0
- package/README.md +9 -7
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +13 -16
- package/dist/config.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 +32 -17
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +1 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +3 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +25 -15
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +1 -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/package-manager.d.ts +5 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +81 -26
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +6 -4
- 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/sdk.d.ts +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +39 -9
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +2 -5
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +3 -2
- 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 +2 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +1 -1
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +0 -10
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/bash-execution.js +1 -1
- package/dist/modes/interactive/components/bash-execution.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +23 -1
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/extension-selector.d.ts +2 -0
- package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-selector.js +6 -1
- package/dist/modes/interactive/components/extension-selector.js.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.d.ts +5 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts.map +1 -1
- package/dist/modes/interactive/components/keybinding-hints.js +19 -5
- package/dist/modes/interactive/components/keybinding-hints.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +3 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +2 -1
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +12 -4
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +67 -27
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +1 -1
- package/dist/modes/interactive/theme/light.json +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +3 -1
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/utils/ansi.d.ts +2 -0
- package/dist/utils/ansi.d.ts.map +1 -0
- package/dist/utils/ansi.js +52 -0
- package/dist/utils/ansi.js.map +1 -0
- package/dist/utils/html.d.ts +7 -0
- package/dist/utils/html.d.ts.map +1 -0
- package/dist/utils/html.js +40 -0
- package/dist/utils/html.js.map +1 -0
- package/dist/utils/mime.d.ts +1 -0
- package/dist/utils/mime.d.ts.map +1 -1
- package/dist/utils/mime.js +59 -16
- package/dist/utils/mime.js.map +1 -1
- package/dist/utils/paths.d.ts +2 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +16 -0
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -0
- package/dist/utils/syntax-highlight.js +118 -0
- package/dist/utils/syntax-highlight.js.map +1 -0
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +80 -8
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/custom-provider.md +58 -3
- package/docs/extensions.md +1 -1
- package/docs/index.md +7 -1
- package/docs/models.md +2 -2
- package/docs/packages.md +2 -2
- package/docs/providers.md +2 -0
- package/docs/sdk.md +24 -44
- package/docs/settings.md +1 -3
- package/docs/skills.md +3 -4
- package/docs/termux.md +3 -3
- package/docs/themes.md +2 -2
- 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/dynamic-resources/dynamic.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/01-minimal.ts +14 -10
- package/examples/sdk/02-custom-model.ts +12 -8
- package/examples/sdk/03-custom-prompt.ts +24 -16
- package/examples/sdk/04-skills.ts +2 -2
- package/examples/sdk/05-tools.ts +8 -4
- package/examples/sdk/06-extensions.ts +11 -7
- package/examples/sdk/07-context-files.ts +2 -2
- package/examples/sdk/08-prompt-templates.ts +2 -2
- package/examples/sdk/09-api-keys-and-oauth.ts +8 -4
- package/examples/sdk/10-settings.ts +4 -4
- package/examples/sdk/11-sessions.ts +4 -0
- package/examples/sdk/12-full-control.ts +11 -7
- package/examples/sdk/README.md +5 -8
- package/package.json +8 -13
|
@@ -845,7 +845,7 @@ export class DefaultPackageManager {
|
|
|
845
845
|
await Promise.all(tasks);
|
|
846
846
|
}
|
|
847
847
|
async shouldUpdateNpmSource(source, scope) {
|
|
848
|
-
const installedPath = this.
|
|
848
|
+
const installedPath = this.getManagedNpmInstallPath(source, scope);
|
|
849
849
|
const installedVersion = existsSync(installedPath) ? this.getInstalledNpmVersion(installedPath) : undefined;
|
|
850
850
|
if (!installedVersion) {
|
|
851
851
|
return true;
|
|
@@ -871,13 +871,9 @@ export class DefaultPackageManager {
|
|
|
871
871
|
});
|
|
872
872
|
}
|
|
873
873
|
async installNpmBatch(specs, scope) {
|
|
874
|
-
if (scope === "user") {
|
|
875
|
-
await this.runNpmCommand(["install", "-g", ...specs]);
|
|
876
|
-
return;
|
|
877
|
-
}
|
|
878
874
|
const installRoot = this.getNpmInstallRoot(scope, false);
|
|
879
875
|
this.ensureNpmProject(installRoot);
|
|
880
|
-
await this.runNpmCommand(
|
|
876
|
+
await this.runNpmCommand(this.getNpmInstallArgs(specs, installRoot));
|
|
881
877
|
}
|
|
882
878
|
async checkForAvailableUpdates() {
|
|
883
879
|
if (isOfflineModeEnabled()) {
|
|
@@ -963,13 +959,14 @@ export class DefaultPackageManager {
|
|
|
963
959
|
return true;
|
|
964
960
|
};
|
|
965
961
|
if (parsed.type === "npm") {
|
|
966
|
-
|
|
962
|
+
let installedPath = this.getNpmInstallPath(parsed, scope);
|
|
967
963
|
const needsInstall = !existsSync(installedPath) ||
|
|
968
964
|
(parsed.pinned && !(await this.installedNpmMatchesPinnedVersion(parsed, installedPath)));
|
|
969
965
|
if (needsInstall) {
|
|
970
966
|
const installed = await installMissing();
|
|
971
967
|
if (!installed)
|
|
972
968
|
continue;
|
|
969
|
+
installedPath = this.getNpmInstallPath(parsed, scope);
|
|
973
970
|
}
|
|
974
971
|
metadata.baseDir = installedPath;
|
|
975
972
|
this.collectPackageResources(installedPath, accumulator, filter, metadata);
|
|
@@ -1363,6 +1360,13 @@ export class DefaultPackageManager {
|
|
|
1363
1360
|
}
|
|
1364
1361
|
return { command, args };
|
|
1365
1362
|
}
|
|
1363
|
+
getPackageManagerName() {
|
|
1364
|
+
const npmCommand = this.getNpmCommand();
|
|
1365
|
+
const commandParts = [npmCommand.command, ...npmCommand.args];
|
|
1366
|
+
const separatorIndex = commandParts.lastIndexOf("--");
|
|
1367
|
+
const packageManagerCommand = separatorIndex >= 0 ? commandParts[separatorIndex + 1] : npmCommand.command;
|
|
1368
|
+
return packageManagerCommand ? basename(packageManagerCommand).replace(/\.(cmd|exe)$/i, "") : "";
|
|
1369
|
+
}
|
|
1366
1370
|
async runNpmCommand(args, options) {
|
|
1367
1371
|
const npmCommand = this.getNpmCommand();
|
|
1368
1372
|
await this.runCommand(npmCommand.command, [...npmCommand.args, ...args], options);
|
|
@@ -1378,24 +1382,30 @@ export class DefaultPackageManager {
|
|
|
1378
1382
|
const npmCommand = this.getNpmCommand();
|
|
1379
1383
|
return this.runCommandSync(npmCommand.command, [...npmCommand.args, ...args]);
|
|
1380
1384
|
}
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
return;
|
|
1385
|
+
getNpmInstallArgs(specs, installRoot) {
|
|
1386
|
+
const packageManagerName = this.getPackageManagerName();
|
|
1387
|
+
if (packageManagerName === "bun") {
|
|
1388
|
+
return ["install", ...specs, "--cwd", installRoot];
|
|
1385
1389
|
}
|
|
1390
|
+
if (packageManagerName === "pnpm") {
|
|
1391
|
+
return ["install", ...specs, "--prefix", installRoot, "--config.strict-dep-builds=false"];
|
|
1392
|
+
}
|
|
1393
|
+
return ["install", ...specs, "--prefix", installRoot];
|
|
1394
|
+
}
|
|
1395
|
+
async installNpm(source, scope, temporary) {
|
|
1386
1396
|
const installRoot = this.getNpmInstallRoot(scope, temporary);
|
|
1387
1397
|
this.ensureNpmProject(installRoot);
|
|
1388
|
-
await this.runNpmCommand([
|
|
1398
|
+
await this.runNpmCommand(this.getNpmInstallArgs([source.spec], installRoot));
|
|
1389
1399
|
}
|
|
1390
1400
|
async uninstallNpm(source, scope) {
|
|
1391
|
-
if (scope === "user") {
|
|
1392
|
-
await this.runNpmCommand(["uninstall", "-g", source.name]);
|
|
1393
|
-
return;
|
|
1394
|
-
}
|
|
1395
1401
|
const installRoot = this.getNpmInstallRoot(scope, false);
|
|
1396
1402
|
if (!existsSync(installRoot)) {
|
|
1397
1403
|
return;
|
|
1398
1404
|
}
|
|
1405
|
+
if (this.getPackageManagerName() === "bun") {
|
|
1406
|
+
await this.runNpmCommand(["uninstall", source.name, "--cwd", installRoot]);
|
|
1407
|
+
return;
|
|
1408
|
+
}
|
|
1399
1409
|
await this.runNpmCommand(["uninstall", source.name, "--prefix", installRoot]);
|
|
1400
1410
|
}
|
|
1401
1411
|
async installGit(source, scope) {
|
|
@@ -1515,7 +1525,7 @@ export class DefaultPackageManager {
|
|
|
1515
1525
|
if (scope === "project") {
|
|
1516
1526
|
return join(this.cwd, CONFIG_DIR_NAME, "npm");
|
|
1517
1527
|
}
|
|
1518
|
-
return join(this.
|
|
1528
|
+
return join(this.agentDir, "npm");
|
|
1519
1529
|
}
|
|
1520
1530
|
getGlobalNpmRoot() {
|
|
1521
1531
|
const npmCommand = this.getNpmCommand();
|
|
@@ -1523,8 +1533,7 @@ export class DefaultPackageManager {
|
|
|
1523
1533
|
if (this.globalNpmRoot && this.globalNpmRootCommandKey === commandKey) {
|
|
1524
1534
|
return this.globalNpmRoot;
|
|
1525
1535
|
}
|
|
1526
|
-
|
|
1527
|
-
if (isBunPackageManager) {
|
|
1536
|
+
if (this.getPackageManagerName() === "bun") {
|
|
1528
1537
|
const binDir = this.runNpmCommandSync(["pm", "bin", "-g"]).trim();
|
|
1529
1538
|
this.globalNpmRoot = join(dirname(binDir), "install", "global", "node_modules");
|
|
1530
1539
|
}
|
|
@@ -1534,14 +1543,43 @@ export class DefaultPackageManager {
|
|
|
1534
1543
|
this.globalNpmRootCommandKey = commandKey;
|
|
1535
1544
|
return this.globalNpmRoot;
|
|
1536
1545
|
}
|
|
1537
|
-
|
|
1546
|
+
getPnpmGlobalPackagePath(packageName) {
|
|
1547
|
+
if (this.getPackageManagerName() !== "pnpm") {
|
|
1548
|
+
return undefined;
|
|
1549
|
+
}
|
|
1550
|
+
const output = this.runNpmCommandSync(["list", "-g", "--depth", "0", "--json"]);
|
|
1551
|
+
const entries = JSON.parse(output);
|
|
1552
|
+
for (const entry of entries) {
|
|
1553
|
+
const path = entry.dependencies?.[packageName]?.path;
|
|
1554
|
+
if (path)
|
|
1555
|
+
return path;
|
|
1556
|
+
}
|
|
1557
|
+
return undefined;
|
|
1558
|
+
}
|
|
1559
|
+
getManagedNpmInstallPath(source, scope) {
|
|
1538
1560
|
if (scope === "temporary") {
|
|
1539
1561
|
return join(this.getTemporaryDir("npm"), "node_modules", source.name);
|
|
1540
1562
|
}
|
|
1541
1563
|
if (scope === "project") {
|
|
1542
1564
|
return join(this.cwd, CONFIG_DIR_NAME, "npm", "node_modules", source.name);
|
|
1543
1565
|
}
|
|
1544
|
-
return join(this.
|
|
1566
|
+
return join(this.agentDir, "npm", "node_modules", source.name);
|
|
1567
|
+
}
|
|
1568
|
+
getLegacyGlobalNpmInstallPath(source) {
|
|
1569
|
+
try {
|
|
1570
|
+
return this.getPnpmGlobalPackagePath(source.name) ?? join(this.getGlobalNpmRoot(), source.name);
|
|
1571
|
+
}
|
|
1572
|
+
catch {
|
|
1573
|
+
return undefined;
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
getNpmInstallPath(source, scope) {
|
|
1577
|
+
const managedPath = this.getManagedNpmInstallPath(source, scope);
|
|
1578
|
+
if (scope !== "user" || existsSync(managedPath)) {
|
|
1579
|
+
return managedPath;
|
|
1580
|
+
}
|
|
1581
|
+
const legacyPath = this.getLegacyGlobalNpmInstallPath(source);
|
|
1582
|
+
return legacyPath && existsSync(legacyPath) ? legacyPath : managedPath;
|
|
1545
1583
|
}
|
|
1546
1584
|
getGitInstallPath(source, scope) {
|
|
1547
1585
|
if (scope === "temporary") {
|
|
@@ -1787,15 +1825,32 @@ export class DefaultPackageManager {
|
|
|
1787
1825
|
this.addResource(target, path, metadata, enabled);
|
|
1788
1826
|
}
|
|
1789
1827
|
};
|
|
1828
|
+
// Project extensions from .pi/
|
|
1790
1829
|
addResources("extensions", collectAutoExtensionEntries(projectDirs.extensions), projectMetadata, projectOverrides.extensions, projectBaseDir);
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1830
|
+
// Project skills from .pi/
|
|
1831
|
+
addResources("skills", collectAutoSkillEntries(projectDirs.skills, "pi"), projectMetadata, projectOverrides.skills, projectBaseDir);
|
|
1832
|
+
// Project skills from .agents/ (each with its own baseDir)
|
|
1833
|
+
for (const agentsSkillsDir of projectAgentsSkillDirs) {
|
|
1834
|
+
const agentsBaseDir = dirname(agentsSkillsDir); // the .agents directory
|
|
1835
|
+
const agentsMetadata = {
|
|
1836
|
+
...projectMetadata,
|
|
1837
|
+
baseDir: agentsBaseDir,
|
|
1838
|
+
};
|
|
1839
|
+
addResources("skills", collectAutoSkillEntries(agentsSkillsDir, "agents"), agentsMetadata, projectOverrides.skills, agentsBaseDir);
|
|
1840
|
+
}
|
|
1795
1841
|
addResources("prompts", collectAutoPromptEntries(projectDirs.prompts), projectMetadata, projectOverrides.prompts, projectBaseDir);
|
|
1796
1842
|
addResources("themes", collectAutoThemeEntries(projectDirs.themes), projectMetadata, projectOverrides.themes, projectBaseDir);
|
|
1843
|
+
// User extensions from ~/.pi/agent/
|
|
1797
1844
|
addResources("extensions", collectAutoExtensionEntries(userDirs.extensions), userMetadata, userOverrides.extensions, globalBaseDir);
|
|
1798
|
-
|
|
1845
|
+
// User skills from ~/.pi/agent/
|
|
1846
|
+
addResources("skills", collectAutoSkillEntries(userDirs.skills, "pi"), userMetadata, userOverrides.skills, globalBaseDir);
|
|
1847
|
+
// User skills from ~/.agents/ (with its own baseDir)
|
|
1848
|
+
const userAgentsBaseDir = dirname(userAgentsSkillsDir);
|
|
1849
|
+
const userAgentsMetadata = {
|
|
1850
|
+
...userMetadata,
|
|
1851
|
+
baseDir: userAgentsBaseDir,
|
|
1852
|
+
};
|
|
1853
|
+
addResources("skills", collectAutoSkillEntries(userAgentsSkillsDir, "agents"), userAgentsMetadata, userOverrides.skills, userAgentsBaseDir);
|
|
1799
1854
|
addResources("prompts", collectAutoPromptEntries(userDirs.prompts), userMetadata, userOverrides.prompts, globalBaseDir);
|
|
1800
1855
|
addResources("themes", collectAutoThemeEntries(userDirs.themes), userMetadata, userOverrides.themes, globalBaseDir);
|
|
1801
1856
|
}
|