@cydm/pie 2.7.20 → 2.8.1
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/README.md +18 -0
- package/dist/builtin/extensions/ask-user/README.md +117 -0
- package/dist/builtin/extensions/ask-user/index.js +4 -3
- package/dist/builtin/extensions/cron/index.js +299 -39
- package/dist/builtin/extensions/im-forward/README.md +297 -0
- package/dist/builtin/extensions/im-forward/index.js +315 -27
- package/dist/builtin/extensions/mcp-adapter/README.md +27 -0
- package/dist/builtin/extensions/memory/index.js +515 -0
- package/dist/builtin/extensions/memory/package.json +19 -0
- package/dist/builtin/extensions/pie-ipc/README.md +21 -0
- package/dist/builtin/extensions/plan-mode/METHOD.md +70 -0
- package/dist/builtin/extensions/plan-mode/index.js +150 -82
- package/dist/builtin/extensions/subagent/README.md +315 -0
- package/dist/builtin/extensions/subagent/index.js +8 -5
- package/dist/builtin/extensions/todo/index.js +4 -3
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/{chunk-U75F4DPF.js → chunk-BNSAEVRT.js} +201 -77
- package/dist/builtin/skills/chrome-devtools-axi/{cli-4ITIR57L.js → cli-AO2ZTPRM.js} +57 -202
- package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +6 -1
- package/dist/builtin/skills/computer-use-axi/computer-use-axi-runtime.js +6 -1
- package/dist/chunks/auth-storage-3EGM3VTK.js +13 -0
- package/dist/chunks/{chunk-X7UO6BA6.js → chunk-3BC5KGDQ.js} +451 -162
- package/dist/chunks/chunk-3NHP7HK5.js +298 -0
- package/dist/chunks/chunk-6DNYGVZP.js +278 -0
- package/dist/chunks/{chunk-TGCI5M6R.js → chunk-GDIYSMTS.js} +22 -142
- package/dist/chunks/{chunk-2H2DD22Z.js → chunk-GH4VW2OT.js} +1 -1
- package/dist/chunks/chunk-ILUHTKF3.js +149 -0
- package/dist/chunks/{chunk-UDCGB3LZ.js → chunk-PK72LVWQ.js} +11841 -16501
- package/dist/chunks/chunk-RSL7E4R7.js +9634 -0
- package/dist/chunks/chunk-YRR6C43W.js +1740 -0
- package/dist/chunks/config-74AUVDLT.js +46 -0
- package/dist/chunks/model-registry-LI5THXV4.js +17 -0
- package/dist/chunks/src-66XSMIAM.js +134 -0
- package/dist/chunks/src-BPSQMSSC.js +431 -0
- package/dist/chunks/src-OPPYTPWG.js +285 -0
- package/dist/chunks/{src-GX4UBAYF.js → src-YG5M2H44.js} +2 -2
- package/dist/chunks/{test-stream-AKIZNFCM.js → test-stream-JBWXKOQA.js} +1 -1
- package/dist/cli.js +986 -2292
- package/package.json +3 -3
|
@@ -1,135 +1,28 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
getBuiltinDir,
|
|
4
|
+
getConfigDir
|
|
5
|
+
} from "./chunk-ILUHTKF3.js";
|
|
2
6
|
import {
|
|
3
7
|
classifyShellCommand,
|
|
4
8
|
createSharedWebFetchTool,
|
|
5
9
|
createSharedWebResearchTool,
|
|
6
10
|
createSharedWebSearchTool,
|
|
7
11
|
defaultShellKindForPlatform,
|
|
8
|
-
interpretShellExit
|
|
12
|
+
interpretShellExit
|
|
13
|
+
} from "./chunk-PK72LVWQ.js";
|
|
14
|
+
import {
|
|
9
15
|
requestInteraction
|
|
10
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-RSL7E4R7.js";
|
|
11
17
|
import {
|
|
12
18
|
EMPTY_ASSISTANT_CONTENT_ERROR,
|
|
13
19
|
OPENAI_COMPAT_PROTOCOL_ERROR_CODE,
|
|
14
20
|
getLogger
|
|
15
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-3BC5KGDQ.js";
|
|
16
22
|
import {
|
|
17
23
|
Type
|
|
18
24
|
} from "./chunk-XXGYUYXI.js";
|
|
19
25
|
|
|
20
|
-
// src/config.ts
|
|
21
|
-
import { existsSync, mkdirSync, readFileSync, renameSync } from "fs";
|
|
22
|
-
import { homedir } from "os";
|
|
23
|
-
import { dirname, join } from "path";
|
|
24
|
-
import { fileURLToPath } from "url";
|
|
25
|
-
var __filename = fileURLToPath(import.meta.url);
|
|
26
|
-
var __dirname = dirname(__filename);
|
|
27
|
-
var isBunRuntime = !!process.versions.bun;
|
|
28
|
-
function getPackageDir() {
|
|
29
|
-
const envDir = process.env.PIE_PACKAGE_DIR;
|
|
30
|
-
if (envDir) {
|
|
31
|
-
if (envDir === "~") return homedir();
|
|
32
|
-
if (envDir.startsWith("~/")) return homedir() + envDir.slice(1);
|
|
33
|
-
return envDir;
|
|
34
|
-
}
|
|
35
|
-
let dir = __dirname;
|
|
36
|
-
while (dir !== dirname(dir)) {
|
|
37
|
-
if (existsSync(join(dir, "package.json"))) {
|
|
38
|
-
return dir;
|
|
39
|
-
}
|
|
40
|
-
dir = dirname(dir);
|
|
41
|
-
}
|
|
42
|
-
return __dirname;
|
|
43
|
-
}
|
|
44
|
-
function getThemesDir() {
|
|
45
|
-
const packageDir = getPackageDir();
|
|
46
|
-
const srcOrDist = existsSync(join(packageDir, "src")) ? "src" : "dist";
|
|
47
|
-
return join(packageDir, srcOrDist, "theme");
|
|
48
|
-
}
|
|
49
|
-
function getBuiltinDir() {
|
|
50
|
-
const packageDir = getPackageDir();
|
|
51
|
-
const distBuiltinDir = join(packageDir, "dist", "builtin");
|
|
52
|
-
if (existsSync(distBuiltinDir)) {
|
|
53
|
-
return distBuiltinDir;
|
|
54
|
-
}
|
|
55
|
-
return join(packageDir, "builtin");
|
|
56
|
-
}
|
|
57
|
-
function getPackageJsonPath() {
|
|
58
|
-
return join(getPackageDir(), "package.json");
|
|
59
|
-
}
|
|
60
|
-
var pkg = JSON.parse(readFileSync(getPackageJsonPath(), "utf-8"));
|
|
61
|
-
var CONFIG_DIR_NAME = ".pie";
|
|
62
|
-
var VERSION = pkg.version;
|
|
63
|
-
var ENV_AGENT_DIR = "PIE_CODING_AGENT_DIR";
|
|
64
|
-
function getConfigDir() {
|
|
65
|
-
const envDir = process.env[ENV_AGENT_DIR];
|
|
66
|
-
if (envDir) {
|
|
67
|
-
if (envDir === "~") return homedir();
|
|
68
|
-
if (envDir.startsWith("~/")) return homedir() + envDir.slice(1);
|
|
69
|
-
return envDir;
|
|
70
|
-
}
|
|
71
|
-
return join(homedir(), CONFIG_DIR_NAME);
|
|
72
|
-
}
|
|
73
|
-
function getAgentDir() {
|
|
74
|
-
return getConfigDir();
|
|
75
|
-
}
|
|
76
|
-
function getCustomThemesDir() {
|
|
77
|
-
return join(getConfigDir(), "themes");
|
|
78
|
-
}
|
|
79
|
-
function getSettingsPath() {
|
|
80
|
-
return join(getConfigDir(), "settings.json");
|
|
81
|
-
}
|
|
82
|
-
function getProjectSettingsPath(cwd) {
|
|
83
|
-
return join(cwd, CONFIG_DIR_NAME, "settings.json");
|
|
84
|
-
}
|
|
85
|
-
function getSessionsDir() {
|
|
86
|
-
return join(getConfigDir(), "sessions");
|
|
87
|
-
}
|
|
88
|
-
function getLogsDir() {
|
|
89
|
-
return join(getConfigDir(), "logs");
|
|
90
|
-
}
|
|
91
|
-
function getRuntimeLogPath() {
|
|
92
|
-
return join(getLogsDir(), "pie-cli.log");
|
|
93
|
-
}
|
|
94
|
-
function migrateConfigFromAgentDir() {
|
|
95
|
-
const oldAgentDir = join(homedir(), CONFIG_DIR_NAME, "agent");
|
|
96
|
-
const newConfigDir = getConfigDir();
|
|
97
|
-
if (!existsSync(oldAgentDir)) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
if (!existsSync(newConfigDir)) {
|
|
101
|
-
mkdirSync(newConfigDir, { recursive: true });
|
|
102
|
-
}
|
|
103
|
-
const filesToMigrate = [
|
|
104
|
-
"keybindings.json",
|
|
105
|
-
"settings.json",
|
|
106
|
-
"pie-debug.log"
|
|
107
|
-
];
|
|
108
|
-
for (const file of filesToMigrate) {
|
|
109
|
-
const oldPath = join(oldAgentDir, file);
|
|
110
|
-
const newPath = file === "pie-debug.log" ? getRuntimeLogPath() : join(newConfigDir, file);
|
|
111
|
-
if (existsSync(oldPath) && !existsSync(newPath)) {
|
|
112
|
-
try {
|
|
113
|
-
if (file === "pie-debug.log") {
|
|
114
|
-
mkdirSync(getLogsDir(), { recursive: true });
|
|
115
|
-
}
|
|
116
|
-
renameSync(oldPath, newPath);
|
|
117
|
-
console.log(`[Config] Migrated ${file} to ${newPath}`);
|
|
118
|
-
} catch (e) {
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
const oldThemesDir = join(oldAgentDir, "themes");
|
|
123
|
-
const newThemesDir = getCustomThemesDir();
|
|
124
|
-
if (existsSync(oldThemesDir) && !existsSync(newThemesDir)) {
|
|
125
|
-
try {
|
|
126
|
-
renameSync(oldThemesDir, newThemesDir);
|
|
127
|
-
console.log(`[Config] Migrated themes to ${newThemesDir}`);
|
|
128
|
-
} catch (e) {
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
26
|
// src/runtime/retry-policy.ts
|
|
134
27
|
var TRANSIENT_NETWORK_ERROR_PATTERN = /sse stream aborted|sse stream closed before end|sse stream ended before response completed|responses stream ended without a terminal event|(?:read\s+)?ECONNRESET|ETIMEDOUT|EAI_AGAIN|ENOTFOUND|ECONNREFUSED|(?:read\s+|write\s+)?EPIPE|socket hang up|request timeout|websocket upgrade refused|websocket handshake|websocket connection failed|websocket transport failed|connection closed before opening|client network socket disconnected before secure TLS connection was established|connection.?error|connection.?refused|other side closed|fetch failed|upstream.?connect|reset before headers|terminated/i;
|
|
135
28
|
var TLS_VALIDATION_ERROR_PATTERN = /certificate (?:has )?expired|certificate is not yet valid|unable to verify (?:the first certificate|certificate)|unable to get (?:local )?issuer certificate|self[-_ ]signed cert(?:ificate)?|CERT_HAS_EXPIRED|SELF_SIGNED_CERT|does not match certificate's altnames|ERR_TLS_CERT_ALTNAME_INVALID/i;
|
|
@@ -339,9 +232,9 @@ function createTraceTransportSink(noteRuntimeEvent) {
|
|
|
339
232
|
|
|
340
233
|
// src/capabilities/bash/index.ts
|
|
341
234
|
import { spawn, spawnSync } from "child_process";
|
|
342
|
-
import { closeSync, createWriteStream, existsSync
|
|
235
|
+
import { closeSync, createWriteStream, existsSync, openSync, statSync, unlinkSync, writeFileSync } from "fs";
|
|
343
236
|
import { tmpdir } from "os";
|
|
344
|
-
import { join
|
|
237
|
+
import { join, resolve } from "path";
|
|
345
238
|
import { createHash, randomBytes } from "crypto";
|
|
346
239
|
|
|
347
240
|
// src/capabilities/bash/truncate.ts
|
|
@@ -811,8 +704,8 @@ function resolveWindowsBashPath() {
|
|
|
811
704
|
if (!resolved) {
|
|
812
705
|
const programFiles = [process.env.PROGRAMFILES, process.env["PROGRAMFILES(X86)"]].filter((value) => Boolean(value));
|
|
813
706
|
for (const root of programFiles) {
|
|
814
|
-
const candidate =
|
|
815
|
-
if (
|
|
707
|
+
const candidate = join(root, "Git", "bin", "bash.exe");
|
|
708
|
+
if (existsSync(candidate)) {
|
|
816
709
|
resolved = candidate;
|
|
817
710
|
break;
|
|
818
711
|
}
|
|
@@ -859,7 +752,7 @@ function notifyYoloGrantAwarded(grantMs) {
|
|
|
859
752
|
}
|
|
860
753
|
}
|
|
861
754
|
function validateWorkingDirectory(cwd) {
|
|
862
|
-
if (!
|
|
755
|
+
if (!existsSync(cwd)) {
|
|
863
756
|
throw new Error(`Invalid bash cwd: ${cwd} does not exist. Use the current workspace path or pass an existing directory in cwd.`);
|
|
864
757
|
}
|
|
865
758
|
let stat;
|
|
@@ -874,11 +767,11 @@ function validateWorkingDirectory(cwd) {
|
|
|
874
767
|
}
|
|
875
768
|
function normalizeWorkingDirectory(cwd, defaultCwd) {
|
|
876
769
|
const requestedCwd = typeof cwd === "string" && cwd.trim().length > 0 ? cwd.trim() : void 0;
|
|
877
|
-
return
|
|
770
|
+
return resolve(requestedCwd ?? defaultCwd ?? process.cwd());
|
|
878
771
|
}
|
|
879
772
|
function getTempFilePath() {
|
|
880
773
|
const id = randomBytes(8).toString("hex");
|
|
881
|
-
return
|
|
774
|
+
return join(tmpdir(), `pie-bash-${id}.log`);
|
|
882
775
|
}
|
|
883
776
|
var retainedOutputArtifacts = /* @__PURE__ */ new Set();
|
|
884
777
|
function getErrorCode(error) {
|
|
@@ -940,7 +833,7 @@ function cleanupBashOutputArtifacts() {
|
|
|
940
833
|
process.once("exit", cleanupBashOutputArtifacts);
|
|
941
834
|
function finishTempFileStream(stream) {
|
|
942
835
|
if (!stream || stream.closed) return Promise.resolve();
|
|
943
|
-
return new Promise((
|
|
836
|
+
return new Promise((resolve2, reject) => {
|
|
944
837
|
let done = false;
|
|
945
838
|
const timer = setTimeout(() => {
|
|
946
839
|
stream.destroy(new Error("Timed out flushing shell output."));
|
|
@@ -954,7 +847,7 @@ function finishTempFileStream(stream) {
|
|
|
954
847
|
if (done) return;
|
|
955
848
|
done = true;
|
|
956
849
|
cleanup();
|
|
957
|
-
|
|
850
|
+
resolve2();
|
|
958
851
|
};
|
|
959
852
|
const onError = (error) => {
|
|
960
853
|
if (done) return;
|
|
@@ -1149,7 +1042,7 @@ function createBashTool(defaultCwd, options) {
|
|
|
1149
1042
|
}
|
|
1150
1043
|
const timeoutPolicy = resolveTimeoutPolicy(timeout);
|
|
1151
1044
|
const timeoutMs = timeoutPolicy.effectiveSeconds * 1e3;
|
|
1152
|
-
return new Promise((
|
|
1045
|
+
return new Promise((resolve2, reject) => {
|
|
1153
1046
|
if (signal?.aborted) {
|
|
1154
1047
|
reject(new Error("Operation aborted"));
|
|
1155
1048
|
return;
|
|
@@ -1469,7 +1362,7 @@ ${commandNonzeroHint}`;
|
|
|
1469
1362
|
outputText += "\n\n[Repeat hint: this exact command already returned the same result in this session. If it proves the task, stop; otherwise change the command or inspect a different file/range.]";
|
|
1470
1363
|
}
|
|
1471
1364
|
const content = [{ type: "text", text: outputText }];
|
|
1472
|
-
|
|
1365
|
+
resolve2({ content, details, isError: outcome.toolFailure });
|
|
1473
1366
|
} catch (error) {
|
|
1474
1367
|
discardOutputArtifact(tempFilePath, tempFileStream);
|
|
1475
1368
|
reject(error);
|
|
@@ -1513,7 +1406,7 @@ function resolveMcpScript() {
|
|
|
1513
1406
|
}
|
|
1514
1407
|
function runAxi(args, options = {}) {
|
|
1515
1408
|
const timeoutMs = options.timeoutMs ?? 6e4;
|
|
1516
|
-
return new Promise((
|
|
1409
|
+
return new Promise((resolve2, reject) => {
|
|
1517
1410
|
const child = spawn2(process.execPath, [resolveAxiCli(), ...args], {
|
|
1518
1411
|
stdio: ["ignore", "pipe", "pipe"],
|
|
1519
1412
|
shell: false,
|
|
@@ -1540,7 +1433,7 @@ function runAxi(args, options = {}) {
|
|
|
1540
1433
|
});
|
|
1541
1434
|
child.on("close", (code) => {
|
|
1542
1435
|
clearTimeout(timer);
|
|
1543
|
-
if (code === 0)
|
|
1436
|
+
if (code === 0) resolve2(stdout.trim());
|
|
1544
1437
|
else reject(new Error((stderr || stdout || `chrome-devtools-axi exited with ${code}`).trim()));
|
|
1545
1438
|
});
|
|
1546
1439
|
});
|
|
@@ -1751,19 +1644,6 @@ function createCliHostCapabilities(cwd, options = {}) {
|
|
|
1751
1644
|
}
|
|
1752
1645
|
|
|
1753
1646
|
export {
|
|
1754
|
-
getPackageDir,
|
|
1755
|
-
getThemesDir,
|
|
1756
|
-
getBuiltinDir,
|
|
1757
|
-
VERSION,
|
|
1758
|
-
getConfigDir,
|
|
1759
|
-
getAgentDir,
|
|
1760
|
-
getCustomThemesDir,
|
|
1761
|
-
getSettingsPath,
|
|
1762
|
-
getProjectSettingsPath,
|
|
1763
|
-
getSessionsDir,
|
|
1764
|
-
getLogsDir,
|
|
1765
|
-
getRuntimeLogPath,
|
|
1766
|
-
migrateConfigFromAgentDir,
|
|
1767
1647
|
createCliWebResearchHealthStore,
|
|
1768
1648
|
truncateHeadTail,
|
|
1769
1649
|
formatSize,
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/config.ts
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, renameSync } from "fs";
|
|
5
|
+
import { homedir } from "os";
|
|
6
|
+
import { dirname, join } from "path";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
var __dirname = dirname(__filename);
|
|
10
|
+
var isBunRuntime = !!process.versions.bun;
|
|
11
|
+
function getPackageDir() {
|
|
12
|
+
const envDir = process.env.PIE_PACKAGE_DIR;
|
|
13
|
+
if (envDir) {
|
|
14
|
+
if (envDir === "~") return homedir();
|
|
15
|
+
if (envDir.startsWith("~/")) return homedir() + envDir.slice(1);
|
|
16
|
+
return envDir;
|
|
17
|
+
}
|
|
18
|
+
let dir = __dirname;
|
|
19
|
+
while (dir !== dirname(dir)) {
|
|
20
|
+
if (existsSync(join(dir, "package.json"))) {
|
|
21
|
+
return dir;
|
|
22
|
+
}
|
|
23
|
+
dir = dirname(dir);
|
|
24
|
+
}
|
|
25
|
+
return __dirname;
|
|
26
|
+
}
|
|
27
|
+
function getThemesDir() {
|
|
28
|
+
const packageDir = getPackageDir();
|
|
29
|
+
const srcOrDist = existsSync(join(packageDir, "src")) ? "src" : "dist";
|
|
30
|
+
return join(packageDir, srcOrDist, "theme");
|
|
31
|
+
}
|
|
32
|
+
function getBuiltinDir() {
|
|
33
|
+
const packageDir = getPackageDir();
|
|
34
|
+
const distBuiltinDir = join(packageDir, "dist", "builtin");
|
|
35
|
+
if (existsSync(distBuiltinDir)) {
|
|
36
|
+
return distBuiltinDir;
|
|
37
|
+
}
|
|
38
|
+
return join(packageDir, "builtin");
|
|
39
|
+
}
|
|
40
|
+
function getPackageJsonPath() {
|
|
41
|
+
return join(getPackageDir(), "package.json");
|
|
42
|
+
}
|
|
43
|
+
var pkg = JSON.parse(readFileSync(getPackageJsonPath(), "utf-8"));
|
|
44
|
+
var APP_NAME = "pie";
|
|
45
|
+
var CONFIG_DIR_NAME = ".pie";
|
|
46
|
+
var VERSION = pkg.version;
|
|
47
|
+
var ENV_AGENT_DIR = "PIE_CODING_AGENT_DIR";
|
|
48
|
+
function getConfigDir() {
|
|
49
|
+
const envDir = process.env[ENV_AGENT_DIR];
|
|
50
|
+
if (envDir !== void 0 && envDir !== "") {
|
|
51
|
+
if (envDir === "~") return homedir();
|
|
52
|
+
if (envDir.startsWith("~/")) return homedir() + envDir.slice(1);
|
|
53
|
+
if (envDir === "undefined" || envDir === "null") {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`${ENV_AGENT_DIR} is set to the literal string "${envDir}"; unset it or point it at a real directory`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return envDir;
|
|
59
|
+
}
|
|
60
|
+
return join(homedir(), CONFIG_DIR_NAME);
|
|
61
|
+
}
|
|
62
|
+
function getAgentDir() {
|
|
63
|
+
return getConfigDir();
|
|
64
|
+
}
|
|
65
|
+
function getCustomThemesDir() {
|
|
66
|
+
return join(getConfigDir(), "themes");
|
|
67
|
+
}
|
|
68
|
+
function getKeybindingsPath() {
|
|
69
|
+
return join(getConfigDir(), "keybindings.json");
|
|
70
|
+
}
|
|
71
|
+
function getSettingsPath() {
|
|
72
|
+
return join(getConfigDir(), "settings.json");
|
|
73
|
+
}
|
|
74
|
+
function getProjectSettingsPath(cwd) {
|
|
75
|
+
return join(cwd, CONFIG_DIR_NAME, "settings.json");
|
|
76
|
+
}
|
|
77
|
+
function getSessionsDir() {
|
|
78
|
+
return join(getConfigDir(), "sessions");
|
|
79
|
+
}
|
|
80
|
+
function getLogsDir() {
|
|
81
|
+
return join(getConfigDir(), "logs");
|
|
82
|
+
}
|
|
83
|
+
function getRuntimeLogPath() {
|
|
84
|
+
return join(getLogsDir(), "pie-cli.log");
|
|
85
|
+
}
|
|
86
|
+
function getDebugLogPath() {
|
|
87
|
+
return getRuntimeLogPath();
|
|
88
|
+
}
|
|
89
|
+
function migrateConfigFromAgentDir() {
|
|
90
|
+
const oldAgentDir = join(homedir(), CONFIG_DIR_NAME, "agent");
|
|
91
|
+
const newConfigDir = getConfigDir();
|
|
92
|
+
if (!existsSync(oldAgentDir)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (!existsSync(newConfigDir)) {
|
|
96
|
+
mkdirSync(newConfigDir, { recursive: true });
|
|
97
|
+
}
|
|
98
|
+
const filesToMigrate = [
|
|
99
|
+
"keybindings.json",
|
|
100
|
+
"settings.json",
|
|
101
|
+
"pie-debug.log"
|
|
102
|
+
];
|
|
103
|
+
for (const file of filesToMigrate) {
|
|
104
|
+
const oldPath = join(oldAgentDir, file);
|
|
105
|
+
const newPath = file === "pie-debug.log" ? getRuntimeLogPath() : join(newConfigDir, file);
|
|
106
|
+
if (existsSync(oldPath) && !existsSync(newPath)) {
|
|
107
|
+
try {
|
|
108
|
+
if (file === "pie-debug.log") {
|
|
109
|
+
mkdirSync(getLogsDir(), { recursive: true });
|
|
110
|
+
}
|
|
111
|
+
renameSync(oldPath, newPath);
|
|
112
|
+
console.log(`[Config] Migrated ${file} to ${newPath}`);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const oldThemesDir = join(oldAgentDir, "themes");
|
|
118
|
+
const newThemesDir = getCustomThemesDir();
|
|
119
|
+
if (existsSync(oldThemesDir) && !existsSync(newThemesDir)) {
|
|
120
|
+
try {
|
|
121
|
+
renameSync(oldThemesDir, newThemesDir);
|
|
122
|
+
console.log(`[Config] Migrated themes to ${newThemesDir}`);
|
|
123
|
+
} catch (e) {
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export {
|
|
129
|
+
isBunRuntime,
|
|
130
|
+
getPackageDir,
|
|
131
|
+
getThemesDir,
|
|
132
|
+
getBuiltinDir,
|
|
133
|
+
getPackageJsonPath,
|
|
134
|
+
APP_NAME,
|
|
135
|
+
CONFIG_DIR_NAME,
|
|
136
|
+
VERSION,
|
|
137
|
+
ENV_AGENT_DIR,
|
|
138
|
+
getConfigDir,
|
|
139
|
+
getAgentDir,
|
|
140
|
+
getCustomThemesDir,
|
|
141
|
+
getKeybindingsPath,
|
|
142
|
+
getSettingsPath,
|
|
143
|
+
getProjectSettingsPath,
|
|
144
|
+
getSessionsDir,
|
|
145
|
+
getLogsDir,
|
|
146
|
+
getRuntimeLogPath,
|
|
147
|
+
getDebugLogPath,
|
|
148
|
+
migrateConfigFromAgentDir
|
|
149
|
+
};
|