@cydm/pie 4.13.1 → 4.14.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/dist/builtin/extensions/ask-user/index.js +2 -2
- package/dist/builtin/extensions/im-forward/index.js +8092 -8098
- package/dist/builtin/extensions/mcp-adapter/index.js +86 -81
- package/dist/builtin/extensions/memory/index.js +28 -5
- package/dist/builtin/extensions/pie-ipc/index.js +13 -18
- package/dist/builtin/extensions/pie-proc/index.js +61 -55
- package/dist/builtin/extensions/plan-mode/index.js +2 -2
- package/dist/builtin/extensions/subagent/index.js +3 -3
- package/dist/builtin/extensions/todo/index.js +2 -2
- package/dist/chunks/{chunk-6Z54UHXM.js → chunk-BOQIGMGQ.js} +20 -15
- package/dist/chunks/{chunk-XPJHZRTN.js → chunk-EZZTMDWZ.js} +712 -378
- package/dist/chunks/{chunk-HSMO2BEA.js → chunk-FD3KBPDR.js} +23 -18
- package/dist/chunks/{chunk-3F2CSVNH.js → chunk-IK2FR2YF.js} +2 -1
- package/dist/chunks/{chunk-CCPNHS6B.js → chunk-JJH77AUU.js} +1578 -1566
- package/dist/chunks/{chunk-DT22BBZL.js → chunk-JKO42HZW.js} +1 -1
- package/dist/chunks/{chunk-UCVPNLCO.js → chunk-KGWKRO7Z.js} +1 -1
- package/dist/chunks/{chunk-NHWWRE3T.js → chunk-UYDS75SI.js} +725 -718
- package/dist/chunks/{host-image-fallback-LGWYQMLA.js → host-image-fallback-LPHB5CTL.js} +1 -1
- package/dist/chunks/{manager-cli-OTIMAWO6.js → manager-cli-ZV36YNPJ.js} +187 -173
- package/dist/chunks/{memory-git-7SRO5KLB.js → memory-git-ZJN6SPIU.js} +3 -3
- package/dist/chunks/{model-registry-IWOOAMLZ.js → model-registry-GLBIUOJR.js} +1 -1
- package/dist/chunks/{read-file-understanding-3TYWVOLX.js → read-file-understanding-DFJPTTSB.js} +3 -3
- package/dist/chunks/{src-WA2O2O2V.js → src-KZ7YID3I.js} +1 -1
- package/dist/chunks/{src-D2ICRXWW.js → src-LEXKDSFV.js} +22 -4
- package/dist/cli.js +2859 -2741
- package/package.json +1 -1
- package/dist/chunks/{chunk-3GG342QY.js → chunk-TYCKSYUF.js} +19 -19
|
@@ -5,7 +5,7 @@ import "./chunk-LZQXQOPJ.js";
|
|
|
5
5
|
import * as os from "node:os";
|
|
6
6
|
async function describeImageViaUnderstandingChain(options) {
|
|
7
7
|
try {
|
|
8
|
-
const { understandReadFile } = await import("./read-file-understanding-
|
|
8
|
+
const { understandReadFile } = await import("./read-file-understanding-DFJPTTSB.js");
|
|
9
9
|
const ext = options.filePath.toLowerCase().split(".").pop() ?? "";
|
|
10
10
|
const mimeType = ext === "png" ? "image/png" : ext === "gif" ? "image/gif" : ext === "webp" ? "image/webp" : "image/jpeg";
|
|
11
11
|
const result = await understandReadFile(
|
|
@@ -24,7 +24,13 @@ import "./chunk-CBDQJMUI.js";
|
|
|
24
24
|
import "./chunk-LZQXQOPJ.js";
|
|
25
25
|
|
|
26
26
|
// src/commands/manager-cli.ts
|
|
27
|
-
import {
|
|
27
|
+
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
28
|
+
import * as fs3 from "node:fs";
|
|
29
|
+
import * as os3 from "node:os";
|
|
30
|
+
import * as path3 from "node:path";
|
|
31
|
+
|
|
32
|
+
// src/commands/manager-runtime.ts
|
|
33
|
+
import { spawn } from "node:child_process";
|
|
28
34
|
import { createRequire } from "node:module";
|
|
29
35
|
import * as fs from "node:fs";
|
|
30
36
|
import * as os from "node:os";
|
|
@@ -338,7 +344,7 @@ async function waitForAgentReady(dir, timeoutMs, sinceOffset, expectedSessionId)
|
|
|
338
344
|
}
|
|
339
345
|
} catch {
|
|
340
346
|
}
|
|
341
|
-
await new Promise((
|
|
347
|
+
await new Promise((resolve4) => setTimeout(resolve4, 250));
|
|
342
348
|
}
|
|
343
349
|
return false;
|
|
344
350
|
}
|
|
@@ -384,6 +390,141 @@ function managerSpawnEnv() {
|
|
|
384
390
|
}
|
|
385
391
|
return env;
|
|
386
392
|
}
|
|
393
|
+
async function stopConcierge(state) {
|
|
394
|
+
if (!state.pid) {
|
|
395
|
+
console.log("No recorded pid; nothing to do.");
|
|
396
|
+
return 0;
|
|
397
|
+
}
|
|
398
|
+
const liveness0 = managerLiveness(state.pid, state);
|
|
399
|
+
if (liveness0 === "dead") {
|
|
400
|
+
writeState({ sessionId: state.sessionId });
|
|
401
|
+
console.log("The process is no longer running.");
|
|
402
|
+
return 0;
|
|
403
|
+
}
|
|
404
|
+
if (liveness0 === "unknown") {
|
|
405
|
+
console.error(
|
|
406
|
+
`Cannot verify the identity of pid ${state.pid} (ps/wmic failed); refusing to act and keeping the recorded state. Retry later or confirm manually.`
|
|
407
|
+
);
|
|
408
|
+
return 1;
|
|
409
|
+
}
|
|
410
|
+
try {
|
|
411
|
+
process.kill(
|
|
412
|
+
state.pid,
|
|
413
|
+
process.platform === "win32" ? void 0 : "SIGTERM"
|
|
414
|
+
);
|
|
415
|
+
} catch {
|
|
416
|
+
}
|
|
417
|
+
const deadline = Date.now() + 2e4;
|
|
418
|
+
while (Date.now() < deadline) {
|
|
419
|
+
if (!isConciergeAlive(state.pid, state)) break;
|
|
420
|
+
await new Promise((resolve4) => setTimeout(resolve4, 200));
|
|
421
|
+
}
|
|
422
|
+
const finalState = managerLiveness(state.pid, state);
|
|
423
|
+
if (finalState === "alive" || finalState === "unknown") {
|
|
424
|
+
console.error(
|
|
425
|
+
`Shutdown not confirmed (state: ${finalState}); the pid is kept. Retry with pie manager stop or clean up manually.`
|
|
426
|
+
);
|
|
427
|
+
return 1;
|
|
428
|
+
}
|
|
429
|
+
writeState({ sessionId: state.sessionId });
|
|
430
|
+
console.log("Stopped.");
|
|
431
|
+
return 0;
|
|
432
|
+
}
|
|
433
|
+
function startLockDir(dir) {
|
|
434
|
+
return path.join(dir, "start-locks");
|
|
435
|
+
}
|
|
436
|
+
function withStartLock(dir, fn) {
|
|
437
|
+
const locks = startLockDir(dir);
|
|
438
|
+
fs.mkdirSync(locks, { recursive: true });
|
|
439
|
+
const deadline = Date.now() + 9e4;
|
|
440
|
+
let mine;
|
|
441
|
+
for (; ; ) {
|
|
442
|
+
if (Date.now() > deadline)
|
|
443
|
+
throw new Error(
|
|
444
|
+
"another pie manager lifecycle command is in progress; retry shortly"
|
|
445
|
+
);
|
|
446
|
+
let latest = 0;
|
|
447
|
+
try {
|
|
448
|
+
for (const entry of fs.readdirSync(locks)) {
|
|
449
|
+
const m = /^start\.r(\d+)\.json$/.exec(entry);
|
|
450
|
+
if (m) latest = Math.max(latest, Number(m[1]));
|
|
451
|
+
}
|
|
452
|
+
} catch {
|
|
453
|
+
}
|
|
454
|
+
if (latest > 0) {
|
|
455
|
+
let holderBlocking = false;
|
|
456
|
+
const latestPath = path.join(locks, `start.r${latest}.json`);
|
|
457
|
+
try {
|
|
458
|
+
if (fs.existsSync(`${latestPath}.released`)) holderBlocking = false;
|
|
459
|
+
else {
|
|
460
|
+
const content = JSON.parse(fs.readFileSync(latestPath, "utf8"));
|
|
461
|
+
if (typeof content.pid === "number" && content.pid > 0) {
|
|
462
|
+
try {
|
|
463
|
+
process.kill(content.pid, 0);
|
|
464
|
+
holderBlocking = true;
|
|
465
|
+
} catch {
|
|
466
|
+
holderBlocking = false;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
} catch {
|
|
471
|
+
}
|
|
472
|
+
if (holderBlocking) {
|
|
473
|
+
Atomics.wait?.(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 100);
|
|
474
|
+
continue;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
const next = latest + 1;
|
|
478
|
+
const target = path.join(locks, `start.r${next}.json`);
|
|
479
|
+
const tmp = `${target}.${process.pid}.${Date.now().toString(36)}.tmp`;
|
|
480
|
+
try {
|
|
481
|
+
fs.writeFileSync(
|
|
482
|
+
tmp,
|
|
483
|
+
JSON.stringify({ pid: process.pid, at: Date.now() })
|
|
484
|
+
);
|
|
485
|
+
fs.linkSync(tmp, target);
|
|
486
|
+
mine = target;
|
|
487
|
+
break;
|
|
488
|
+
} catch (error) {
|
|
489
|
+
try {
|
|
490
|
+
fs.rmSync(tmp, { force: true });
|
|
491
|
+
} catch {
|
|
492
|
+
}
|
|
493
|
+
if (error.code === "EEXIST") continue;
|
|
494
|
+
throw error;
|
|
495
|
+
} finally {
|
|
496
|
+
try {
|
|
497
|
+
if (mine) fs.rmSync(tmp, { force: true });
|
|
498
|
+
} catch {
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return Promise.resolve(fn()).finally(() => {
|
|
503
|
+
if (!mine) return;
|
|
504
|
+
try {
|
|
505
|
+
const content = JSON.parse(fs.readFileSync(mine, "utf8"));
|
|
506
|
+
if (content.pid === process.pid) {
|
|
507
|
+
const tmp = `${mine}.released.${process.pid}.tmp`;
|
|
508
|
+
fs.writeFileSync(tmp, String(Date.now()));
|
|
509
|
+
try {
|
|
510
|
+
fs.linkSync(tmp, `${mine}.released`);
|
|
511
|
+
} catch {
|
|
512
|
+
}
|
|
513
|
+
try {
|
|
514
|
+
fs.rmSync(tmp, { force: true });
|
|
515
|
+
} catch {
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
} catch {
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
// src/commands/manager-platform-service.ts
|
|
524
|
+
import { execFileSync } from "node:child_process";
|
|
525
|
+
import * as fs2 from "node:fs";
|
|
526
|
+
import * as os2 from "node:os";
|
|
527
|
+
import * as path2 from "node:path";
|
|
387
528
|
function platformServiceName() {
|
|
388
529
|
return "dev.pie.manager";
|
|
389
530
|
}
|
|
@@ -398,8 +539,8 @@ function requestPlatformServiceStart(dir) {
|
|
|
398
539
|
return;
|
|
399
540
|
}
|
|
400
541
|
if (process.platform === "darwin") {
|
|
401
|
-
const plist =
|
|
402
|
-
if (!
|
|
542
|
+
const plist = path2.join(os2.homedir(), "Library", "LaunchAgents", `${platformServiceName()}.plist`);
|
|
543
|
+
if (!fs2.existsSync(plist)) {
|
|
403
544
|
console.error(`Service plist missing (${plist}); run pie manager --uninstall-service then --install-service.`);
|
|
404
545
|
process.exitCode = 1;
|
|
405
546
|
return;
|
|
@@ -457,11 +598,11 @@ function installService(dir, state) {
|
|
|
457
598
|
const servicePath = process.env.PATH ?? "/usr/bin:/bin:/usr/sbin:/sbin";
|
|
458
599
|
const normalizeRoot = (value) => {
|
|
459
600
|
if (typeof value !== "string" || value.length === 0) return void 0;
|
|
460
|
-
const home =
|
|
601
|
+
const home = os2.homedir() || process.env.HOME || process.env.USERPROFILE || "/tmp";
|
|
461
602
|
if (value === "~") return home;
|
|
462
|
-
if (value.startsWith("~/")) return
|
|
463
|
-
if (
|
|
464
|
-
return
|
|
603
|
+
if (value.startsWith("~/")) return path2.resolve(path2.join(home, value.slice(2)));
|
|
604
|
+
if (path2.isAbsolute(value)) return value;
|
|
605
|
+
return path2.resolve(value);
|
|
465
606
|
};
|
|
466
607
|
const serviceEnv = [
|
|
467
608
|
["PIE_PROC_CURATED_NAME", "manager"],
|
|
@@ -490,14 +631,14 @@ ${envPlist}
|
|
|
490
631
|
<key>StandardOutPath</key><string>${xmlEscape(logFile)}</string>
|
|
491
632
|
<key>StandardErrorPath</key><string>${xmlEscape(logFile)}</string>
|
|
492
633
|
</dict></plist>`;
|
|
493
|
-
const target =
|
|
494
|
-
|
|
634
|
+
const target = path2.join(
|
|
635
|
+
os2.homedir(),
|
|
495
636
|
"Library",
|
|
496
637
|
"LaunchAgents",
|
|
497
638
|
`${platformServiceName()}.plist`
|
|
498
639
|
);
|
|
499
|
-
|
|
500
|
-
|
|
640
|
+
fs2.mkdirSync(path2.dirname(target), { recursive: true });
|
|
641
|
+
fs2.writeFileSync(target, plist);
|
|
501
642
|
try {
|
|
502
643
|
execFileSync("launchctl", ["unload", target], { stdio: "ignore" });
|
|
503
644
|
} catch {
|
|
@@ -507,8 +648,8 @@ ${envPlist}
|
|
|
507
648
|
return;
|
|
508
649
|
}
|
|
509
650
|
if (process.platform === "linux") {
|
|
510
|
-
const unitDir =
|
|
511
|
-
|
|
651
|
+
const unitDir = path2.join(os2.homedir(), ".config", "systemd", "user");
|
|
652
|
+
fs2.mkdirSync(unitDir, { recursive: true });
|
|
512
653
|
const unit = `[Unit]
|
|
513
654
|
Description=Pie manager (resident im-forward host)
|
|
514
655
|
After=network-online.target
|
|
@@ -529,8 +670,8 @@ StandardError=append:${systemdScalarPath(logFile)}
|
|
|
529
670
|
|
|
530
671
|
[Install]
|
|
531
672
|
WantedBy=default.target`;
|
|
532
|
-
const unitPath =
|
|
533
|
-
|
|
673
|
+
const unitPath = path2.join(unitDir, `${platformServiceName()}.service`);
|
|
674
|
+
fs2.writeFileSync(unitPath, unit);
|
|
534
675
|
execFileSync("systemctl", ["--user", "daemon-reload"]);
|
|
535
676
|
execFileSync("systemctl", [
|
|
536
677
|
"--user",
|
|
@@ -540,7 +681,7 @@ WantedBy=default.target`;
|
|
|
540
681
|
]);
|
|
541
682
|
console.log(`Installed systemd user service: ${unitPath} (Restart=always)`);
|
|
542
683
|
try {
|
|
543
|
-
const user =
|
|
684
|
+
const user = os2.userInfo().username;
|
|
544
685
|
const linger = execFileSync("loginctl", ["show-user", user, "-p", "Linger", "--value"], {
|
|
545
686
|
encoding: "utf8",
|
|
546
687
|
stdio: ["ignore", "pipe", "ignore"],
|
|
@@ -582,8 +723,8 @@ WantedBy=default.target`;
|
|
|
582
723
|
}
|
|
583
724
|
function uninstallService() {
|
|
584
725
|
if (process.platform === "darwin") {
|
|
585
|
-
const target =
|
|
586
|
-
|
|
726
|
+
const target = path2.join(
|
|
727
|
+
os2.homedir(),
|
|
587
728
|
"Library",
|
|
588
729
|
"LaunchAgents",
|
|
589
730
|
`${platformServiceName()}.plist`
|
|
@@ -609,14 +750,14 @@ function uninstallService() {
|
|
|
609
750
|
platformServiceName()
|
|
610
751
|
]);
|
|
611
752
|
} catch {
|
|
612
|
-
const unitPath2 =
|
|
613
|
-
|
|
753
|
+
const unitPath2 = path2.join(
|
|
754
|
+
os2.homedir(),
|
|
614
755
|
".config",
|
|
615
756
|
"systemd",
|
|
616
757
|
"user",
|
|
617
758
|
`${platformServiceName()}.service`
|
|
618
759
|
);
|
|
619
|
-
ok = !
|
|
760
|
+
ok = !fs2.existsSync(unitPath2);
|
|
620
761
|
if (!ok) {
|
|
621
762
|
console.error(
|
|
622
763
|
"systemctl disable failed; the service may still be running, so the unit file and its ownership are kept."
|
|
@@ -624,15 +765,15 @@ function uninstallService() {
|
|
|
624
765
|
return false;
|
|
625
766
|
}
|
|
626
767
|
}
|
|
627
|
-
const unitPath =
|
|
628
|
-
|
|
768
|
+
const unitPath = path2.join(
|
|
769
|
+
os2.homedir(),
|
|
629
770
|
".config",
|
|
630
771
|
"systemd",
|
|
631
772
|
"user",
|
|
632
773
|
`${platformServiceName()}.service`
|
|
633
774
|
);
|
|
634
775
|
try {
|
|
635
|
-
|
|
776
|
+
fs2.rmSync(unitPath);
|
|
636
777
|
execFileSync("systemctl", ["--user", "daemon-reload"]);
|
|
637
778
|
console.log(`Uninstalled systemd service.`);
|
|
638
779
|
} catch {
|
|
@@ -688,135 +829,8 @@ function uninstallService() {
|
|
|
688
829
|
}
|
|
689
830
|
throw new Error(`unsupported platform: ${process.platform}`);
|
|
690
831
|
}
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
console.log("No recorded pid; nothing to do.");
|
|
694
|
-
return 0;
|
|
695
|
-
}
|
|
696
|
-
const liveness0 = managerLiveness(state.pid, state);
|
|
697
|
-
if (liveness0 === "dead") {
|
|
698
|
-
writeState({ sessionId: state.sessionId });
|
|
699
|
-
console.log("The process is no longer running.");
|
|
700
|
-
return 0;
|
|
701
|
-
}
|
|
702
|
-
if (liveness0 === "unknown") {
|
|
703
|
-
console.error(
|
|
704
|
-
`Cannot verify the identity of pid ${state.pid} (ps/wmic failed); refusing to act and keeping the recorded state. Retry later or confirm manually.`
|
|
705
|
-
);
|
|
706
|
-
return 1;
|
|
707
|
-
}
|
|
708
|
-
try {
|
|
709
|
-
process.kill(
|
|
710
|
-
state.pid,
|
|
711
|
-
process.platform === "win32" ? void 0 : "SIGTERM"
|
|
712
|
-
);
|
|
713
|
-
} catch {
|
|
714
|
-
}
|
|
715
|
-
const deadline = Date.now() + 2e4;
|
|
716
|
-
while (Date.now() < deadline) {
|
|
717
|
-
if (!isConciergeAlive(state.pid, state)) break;
|
|
718
|
-
await new Promise((resolve2) => setTimeout(resolve2, 200));
|
|
719
|
-
}
|
|
720
|
-
const finalState = managerLiveness(state.pid, state);
|
|
721
|
-
if (finalState === "alive" || finalState === "unknown") {
|
|
722
|
-
console.error(
|
|
723
|
-
`Shutdown not confirmed (state: ${finalState}); the pid is kept. Retry with pie manager stop or clean up manually.`
|
|
724
|
-
);
|
|
725
|
-
return 1;
|
|
726
|
-
}
|
|
727
|
-
writeState({ sessionId: state.sessionId });
|
|
728
|
-
console.log("Stopped.");
|
|
729
|
-
return 0;
|
|
730
|
-
}
|
|
731
|
-
function startLockDir(dir) {
|
|
732
|
-
return path.join(dir, "start-locks");
|
|
733
|
-
}
|
|
734
|
-
function withStartLock(dir, fn) {
|
|
735
|
-
const locks = startLockDir(dir);
|
|
736
|
-
fs.mkdirSync(locks, { recursive: true });
|
|
737
|
-
const deadline = Date.now() + 9e4;
|
|
738
|
-
let mine;
|
|
739
|
-
for (; ; ) {
|
|
740
|
-
if (Date.now() > deadline)
|
|
741
|
-
throw new Error(
|
|
742
|
-
"another pie manager lifecycle command is in progress; retry shortly"
|
|
743
|
-
);
|
|
744
|
-
let latest = 0;
|
|
745
|
-
try {
|
|
746
|
-
for (const entry of fs.readdirSync(locks)) {
|
|
747
|
-
const m = /^start\.r(\d+)\.json$/.exec(entry);
|
|
748
|
-
if (m) latest = Math.max(latest, Number(m[1]));
|
|
749
|
-
}
|
|
750
|
-
} catch {
|
|
751
|
-
}
|
|
752
|
-
if (latest > 0) {
|
|
753
|
-
let holderBlocking = false;
|
|
754
|
-
const latestPath = path.join(locks, `start.r${latest}.json`);
|
|
755
|
-
try {
|
|
756
|
-
if (fs.existsSync(`${latestPath}.released`)) holderBlocking = false;
|
|
757
|
-
else {
|
|
758
|
-
const content = JSON.parse(fs.readFileSync(latestPath, "utf8"));
|
|
759
|
-
if (typeof content.pid === "number" && content.pid > 0) {
|
|
760
|
-
try {
|
|
761
|
-
process.kill(content.pid, 0);
|
|
762
|
-
holderBlocking = true;
|
|
763
|
-
} catch {
|
|
764
|
-
holderBlocking = false;
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
} catch {
|
|
769
|
-
}
|
|
770
|
-
if (holderBlocking) {
|
|
771
|
-
Atomics.wait?.(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 100);
|
|
772
|
-
continue;
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
const next = latest + 1;
|
|
776
|
-
const target = path.join(locks, `start.r${next}.json`);
|
|
777
|
-
const tmp = `${target}.${process.pid}.${Date.now().toString(36)}.tmp`;
|
|
778
|
-
try {
|
|
779
|
-
fs.writeFileSync(
|
|
780
|
-
tmp,
|
|
781
|
-
JSON.stringify({ pid: process.pid, at: Date.now() })
|
|
782
|
-
);
|
|
783
|
-
fs.linkSync(tmp, target);
|
|
784
|
-
mine = target;
|
|
785
|
-
break;
|
|
786
|
-
} catch (error) {
|
|
787
|
-
try {
|
|
788
|
-
fs.rmSync(tmp, { force: true });
|
|
789
|
-
} catch {
|
|
790
|
-
}
|
|
791
|
-
if (error.code === "EEXIST") continue;
|
|
792
|
-
throw error;
|
|
793
|
-
} finally {
|
|
794
|
-
try {
|
|
795
|
-
if (mine) fs.rmSync(tmp, { force: true });
|
|
796
|
-
} catch {
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
return Promise.resolve(fn()).finally(() => {
|
|
801
|
-
if (!mine) return;
|
|
802
|
-
try {
|
|
803
|
-
const content = JSON.parse(fs.readFileSync(mine, "utf8"));
|
|
804
|
-
if (content.pid === process.pid) {
|
|
805
|
-
const tmp = `${mine}.released.${process.pid}.tmp`;
|
|
806
|
-
fs.writeFileSync(tmp, String(Date.now()));
|
|
807
|
-
try {
|
|
808
|
-
fs.linkSync(tmp, `${mine}.released`);
|
|
809
|
-
} catch {
|
|
810
|
-
}
|
|
811
|
-
try {
|
|
812
|
-
fs.rmSync(tmp, { force: true });
|
|
813
|
-
} catch {
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
} catch {
|
|
817
|
-
}
|
|
818
|
-
});
|
|
819
|
-
}
|
|
832
|
+
|
|
833
|
+
// src/commands/manager-cli.ts
|
|
820
834
|
async function runUpgradeCommand(args) {
|
|
821
835
|
if (args.includes("--help") || args.includes("-h")) {
|
|
822
836
|
console.log("Usage: pie manager upgrade [--target <latest|x.y.z>] [--force]");
|
|
@@ -885,7 +899,7 @@ async function runManagerCommand(args) {
|
|
|
885
899
|
let running = false;
|
|
886
900
|
try {
|
|
887
901
|
if (process.platform === "darwin") {
|
|
888
|
-
const listing =
|
|
902
|
+
const listing = execFileSync2("launchctl", ["list"], {
|
|
889
903
|
encoding: "utf8",
|
|
890
904
|
stdio: ["ignore", "pipe", "ignore"]
|
|
891
905
|
});
|
|
@@ -902,7 +916,7 @@ async function runManagerCommand(args) {
|
|
|
902
916
|
);
|
|
903
917
|
}
|
|
904
918
|
} else if (process.platform === "linux") {
|
|
905
|
-
|
|
919
|
+
execFileSync2("systemctl", [
|
|
906
920
|
"--user",
|
|
907
921
|
"is-active",
|
|
908
922
|
"--quiet",
|
|
@@ -949,12 +963,12 @@ async function runManagerCommand(args) {
|
|
|
949
963
|
if (state.service) {
|
|
950
964
|
if (process.platform === "darwin") {
|
|
951
965
|
try {
|
|
952
|
-
|
|
966
|
+
execFileSync2(
|
|
953
967
|
"launchctl",
|
|
954
968
|
[
|
|
955
969
|
"unload",
|
|
956
|
-
|
|
957
|
-
|
|
970
|
+
path3.join(
|
|
971
|
+
os3.homedir(),
|
|
958
972
|
"Library",
|
|
959
973
|
"LaunchAgents",
|
|
960
974
|
`${platformServiceName()}.plist`
|
|
@@ -981,7 +995,7 @@ async function runManagerCommand(args) {
|
|
|
981
995
|
}
|
|
982
996
|
} else if (process.platform === "linux") {
|
|
983
997
|
try {
|
|
984
|
-
|
|
998
|
+
execFileSync2("systemctl", [
|
|
985
999
|
"--user",
|
|
986
1000
|
"stop",
|
|
987
1001
|
platformServiceName()
|
|
@@ -998,7 +1012,7 @@ async function runManagerCommand(args) {
|
|
|
998
1012
|
}
|
|
999
1013
|
} else if (process.platform === "win32") {
|
|
1000
1014
|
try {
|
|
1001
|
-
|
|
1015
|
+
execFileSync2("schtasks", ["/End", "/TN", platformServiceName()], {
|
|
1002
1016
|
stdio: ["ignore", "pipe", "pipe"],
|
|
1003
1017
|
windowsHide: true
|
|
1004
1018
|
});
|
|
@@ -1102,7 +1116,7 @@ async function runManagerCommand(args) {
|
|
|
1102
1116
|
tailN = Math.min(n, 1e4);
|
|
1103
1117
|
}
|
|
1104
1118
|
const file = logPath(dir);
|
|
1105
|
-
if (!
|
|
1119
|
+
if (!fs3.existsSync(file)) {
|
|
1106
1120
|
console.error(`No manager log yet (${file}). Run pie manager start first.`);
|
|
1107
1121
|
process.exitCode = 2;
|
|
1108
1122
|
return;
|
|
@@ -1135,21 +1149,21 @@ async function runManagerCommand(args) {
|
|
|
1135
1149
|
const readFrom = (offset2) => {
|
|
1136
1150
|
let fd;
|
|
1137
1151
|
try {
|
|
1138
|
-
fd =
|
|
1152
|
+
fd = fs3.openSync(file, "r");
|
|
1139
1153
|
} catch {
|
|
1140
1154
|
return { buf: Buffer.alloc(0), truncated: true, identity: void 0 };
|
|
1141
1155
|
}
|
|
1142
1156
|
try {
|
|
1143
|
-
const st =
|
|
1157
|
+
const st = fs3.fstatSync(fd);
|
|
1144
1158
|
const identity = { ino: st.ino, dev: st.dev };
|
|
1145
1159
|
const size = st.size;
|
|
1146
1160
|
if (size < offset2) return { buf: Buffer.alloc(0), truncated: true, identity };
|
|
1147
1161
|
const len = Math.min(size - offset2, READ_CHUNK_BYTES);
|
|
1148
1162
|
const buf = Buffer.alloc(len);
|
|
1149
|
-
const bytesRead =
|
|
1163
|
+
const bytesRead = fs3.readSync(fd, buf, 0, len, offset2);
|
|
1150
1164
|
return { buf: buf.subarray(0, bytesRead), truncated: false, identity };
|
|
1151
1165
|
} finally {
|
|
1152
|
-
|
|
1166
|
+
fs3.closeSync(fd);
|
|
1153
1167
|
}
|
|
1154
1168
|
};
|
|
1155
1169
|
const emit = (buf, from) => {
|
|
@@ -1220,7 +1234,7 @@ async function runManagerCommand(args) {
|
|
|
1220
1234
|
let carriedBuf = Buffer.alloc(0);
|
|
1221
1235
|
const pump = () => {
|
|
1222
1236
|
for (; ; ) {
|
|
1223
|
-
if (
|
|
1237
|
+
if (fs3.existsSync(file)) {
|
|
1224
1238
|
const { buf, truncated, identity } = readFrom(offset + carriedBuf.length);
|
|
1225
1239
|
if (identity && lastInode && (identity.ino !== lastInode.ino || identity.dev !== lastInode.dev)) {
|
|
1226
1240
|
offset = 0;
|
|
@@ -1251,8 +1265,8 @@ async function runManagerCommand(args) {
|
|
|
1251
1265
|
};
|
|
1252
1266
|
const startWatch = () => {
|
|
1253
1267
|
try {
|
|
1254
|
-
watcher =
|
|
1255
|
-
if (!filename || filename ===
|
|
1268
|
+
watcher = fs3.watch(path3.dirname(file), (event, filename) => {
|
|
1269
|
+
if (!filename || filename === path3.basename(file)) pump();
|
|
1256
1270
|
});
|
|
1257
1271
|
watcher.on("error", () => {
|
|
1258
1272
|
watcher?.close();
|
|
@@ -1312,7 +1326,7 @@ async function runManagerCommand(args) {
|
|
|
1312
1326
|
const procSeed = seedProcConfig(process.cwd());
|
|
1313
1327
|
if (procSeed.state === "seeded") {
|
|
1314
1328
|
console.log(
|
|
1315
|
-
`Seeded pie-proc config: allowCwd = ${
|
|
1329
|
+
`Seeded pie-proc config: allowCwd = ${path3.resolve(process.cwd())} (dispatching works now; edit ${procSeed.file} to add roots \u2014 it applies on the next spawn)`
|
|
1316
1330
|
);
|
|
1317
1331
|
} else if (procSeed.state === "user-layer") {
|
|
1318
1332
|
console.log(
|
|
@@ -1320,7 +1334,7 @@ async function runManagerCommand(args) {
|
|
|
1320
1334
|
);
|
|
1321
1335
|
} else if (procSeed.state === "too-broad") {
|
|
1322
1336
|
console.log(
|
|
1323
|
-
`Did not seed pie-proc config (the current directory ${
|
|
1337
|
+
`Did not seed pie-proc config (the current directory ${path3.resolve(process.cwd())} is too broad). To dispatch work, run: pie manager allow /your/project (writes ${procSeed.file})`
|
|
1324
1338
|
);
|
|
1325
1339
|
}
|
|
1326
1340
|
let readinessReport;
|
|
@@ -1341,12 +1355,12 @@ async function runManagerCommand(args) {
|
|
|
1341
1355
|
const state = lockedState ?? { sessionId: token };
|
|
1342
1356
|
let sinceOffset = 0;
|
|
1343
1357
|
try {
|
|
1344
|
-
sinceOffset =
|
|
1358
|
+
sinceOffset = fs3.statSync(logPath(dir)).size;
|
|
1345
1359
|
} catch {
|
|
1346
1360
|
}
|
|
1347
1361
|
const pid = spawnResident(state, dir);
|
|
1348
1362
|
try {
|
|
1349
|
-
const listing =
|
|
1363
|
+
const listing = execFileSync2("ps", ["-eo", "pid,command"], {
|
|
1350
1364
|
encoding: "utf8",
|
|
1351
1365
|
timeout: 3e3,
|
|
1352
1366
|
windowsHide: true
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
ensureMemoryGitIgnore,
|
|
5
5
|
isMemoryGitInitialized,
|
|
6
6
|
readCuratedMemoryGitLog
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
} from "./chunk-IK2FR2YF.js";
|
|
8
|
+
import "./chunk-EZZTMDWZ.js";
|
|
9
|
+
import "./chunk-JJH77AUU.js";
|
|
10
10
|
import "./chunk-26KRUYZH.js";
|
|
11
11
|
import "./chunk-MCR4JYI6.js";
|
|
12
12
|
import "./chunk-XXGYUYXI.js";
|
package/dist/chunks/{read-file-understanding-3TYWVOLX.js → read-file-understanding-DFJPTTSB.js}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
understandReadFile
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-KGWKRO7Z.js";
|
|
5
5
|
import "./chunk-F7EBZTZO.js";
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-EZZTMDWZ.js";
|
|
7
|
+
import "./chunk-JJH77AUU.js";
|
|
8
8
|
import "./chunk-26KRUYZH.js";
|
|
9
9
|
import "./chunk-MCR4JYI6.js";
|
|
10
10
|
import "./chunk-XXGYUYXI.js";
|
|
@@ -146,7 +146,7 @@ import {
|
|
|
146
146
|
substituteArgs,
|
|
147
147
|
validateRetainedTailEntries,
|
|
148
148
|
verifyPreparedCompactionCommit
|
|
149
|
-
} from "./chunk-
|
|
149
|
+
} from "./chunk-JJH77AUU.js";
|
|
150
150
|
import "./chunk-26KRUYZH.js";
|
|
151
151
|
import "./chunk-MCR4JYI6.js";
|
|
152
152
|
import "./chunk-XXGYUYXI.js";
|