agent-yes 1.40.1 → 1.42.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/cli.js +284 -457
- package/dist/index.js +193 -331
- package/package.json +9 -4
- package/ts/SqliteAdapter.ts +109 -0
- package/ts/agent.ts +194 -0
- package/ts/index.ts +25 -20
- package/ts/parseCliArgs.spec.ts +53 -1
- package/ts/parseCliArgs.ts +11 -4
- package/ts/pidStore.ts +69 -101
- package/ts/pty.ts +4 -3
- package/ts/signleton.ts +7 -0
package/dist/cli.js
CHANGED
|
@@ -20595,276 +20595,146 @@ var init_runningLock = __esm(() => {
|
|
|
20595
20595
|
RETRY_DELAYS = [50, 100, 200, 400, 800];
|
|
20596
20596
|
});
|
|
20597
20597
|
|
|
20598
|
-
// ts/
|
|
20599
|
-
import {
|
|
20600
|
-
import { createReadStream as createReadStream2, mkdirSync } from "fs";
|
|
20601
|
-
import { unlink } from "fs/promises";
|
|
20602
|
-
import { dirname } from "path";
|
|
20603
|
-
import { createServer } from "net";
|
|
20604
|
-
function createFifoStream(cli, customPath) {
|
|
20605
|
-
if (process.platform === "win32") {
|
|
20606
|
-
return createWindowsNamedPipe(cli, customPath);
|
|
20607
|
-
} else if (process.platform === "linux") {
|
|
20608
|
-
return createLinuxFifo(cli, customPath);
|
|
20609
|
-
} else {
|
|
20610
|
-
logger.warn(`[${cli}-yes] IPC not supported on platform: ${process.platform}`);
|
|
20611
|
-
return null;
|
|
20612
|
-
}
|
|
20613
|
-
}
|
|
20614
|
-
function createWindowsNamedPipe(cli, customPath) {
|
|
20615
|
-
try {
|
|
20616
|
-
let pipePath;
|
|
20617
|
-
if (customPath) {
|
|
20618
|
-
pipePath = customPath;
|
|
20619
|
-
} else {
|
|
20620
|
-
const timestamp = new Date().toISOString().replace(/\D/g, "").slice(0, 17);
|
|
20621
|
-
const randomSuffix = Math.random().toString(36).substring(2, 5);
|
|
20622
|
-
pipePath = `\\\\.\\pipe\\agent-yes-${timestamp}${randomSuffix}`;
|
|
20623
|
-
}
|
|
20624
|
-
logger.info(`[${cli}-yes] Creating Windows named pipe at ${pipePath}`);
|
|
20625
|
-
const server = createServer();
|
|
20626
|
-
let connection = null;
|
|
20627
|
-
let isClosing = false;
|
|
20628
|
-
const stream = new ReadableStream({
|
|
20629
|
-
start(controller) {
|
|
20630
|
-
server.on("connection", (socket) => {
|
|
20631
|
-
connection = socket;
|
|
20632
|
-
logger.info(`[${cli}-yes] Client connected to named pipe`);
|
|
20633
|
-
socket.on("data", (chunk) => {
|
|
20634
|
-
const data = chunk.toString();
|
|
20635
|
-
logger.debug(`[${cli}-yes] Received data via named pipe: ${data}`);
|
|
20636
|
-
controller.enqueue(data);
|
|
20637
|
-
});
|
|
20638
|
-
socket.on("end", () => {
|
|
20639
|
-
logger.debug(`[${cli}-yes] Client disconnected from named pipe`);
|
|
20640
|
-
connection = null;
|
|
20641
|
-
});
|
|
20642
|
-
socket.on("error", (error) => {
|
|
20643
|
-
logger.warn(`[${cli}-yes] Named pipe socket error:`, error);
|
|
20644
|
-
if (!isClosing) {
|
|
20645
|
-
controller.error(error);
|
|
20646
|
-
}
|
|
20647
|
-
});
|
|
20648
|
-
});
|
|
20649
|
-
server.on("error", (error) => {
|
|
20650
|
-
logger.warn(`[${cli}-yes] Named pipe server error:`, error);
|
|
20651
|
-
if (!isClosing) {
|
|
20652
|
-
controller.error(error);
|
|
20653
|
-
}
|
|
20654
|
-
});
|
|
20655
|
-
server.listen(pipePath, () => {
|
|
20656
|
-
logger.info(`[${cli}-yes] Named pipe server listening at ${pipePath}`);
|
|
20657
|
-
});
|
|
20658
|
-
},
|
|
20659
|
-
cancel() {
|
|
20660
|
-
isClosing = true;
|
|
20661
|
-
if (connection) {
|
|
20662
|
-
connection.end();
|
|
20663
|
-
}
|
|
20664
|
-
server.close();
|
|
20665
|
-
}
|
|
20666
|
-
});
|
|
20667
|
-
const cleanup = async () => {
|
|
20668
|
-
isClosing = true;
|
|
20669
|
-
if (connection) {
|
|
20670
|
-
connection.end();
|
|
20671
|
-
}
|
|
20672
|
-
server.close();
|
|
20673
|
-
logger.info(`[${cli}-yes] Cleaned up Windows named pipe at ${pipePath}`);
|
|
20674
|
-
};
|
|
20675
|
-
process.on("exit", () => cleanup().catch(() => null));
|
|
20676
|
-
process.on("SIGINT", () => cleanup().catch(() => null));
|
|
20677
|
-
process.on("SIGTERM", () => cleanup().catch(() => null));
|
|
20678
|
-
return {
|
|
20679
|
-
stream,
|
|
20680
|
-
cleanup
|
|
20681
|
-
};
|
|
20682
|
-
} catch (error) {
|
|
20683
|
-
logger.warn(`[${cli}-yes] Failed to create Windows named pipe:`, error);
|
|
20684
|
-
return null;
|
|
20685
|
-
}
|
|
20686
|
-
}
|
|
20687
|
-
function createLinuxFifo(cli, customPath) {
|
|
20688
|
-
let fifoPath = null;
|
|
20689
|
-
let fifoStream = null;
|
|
20690
|
-
logger.debug(`[${cli}-yes] Creating Linux FIFO with customPath: ${customPath}`);
|
|
20691
|
-
try {
|
|
20692
|
-
if (customPath) {
|
|
20693
|
-
fifoPath = customPath;
|
|
20694
|
-
} else {
|
|
20695
|
-
const timestamp = new Date().toISOString().replace(/\D/g, "").slice(0, 17);
|
|
20696
|
-
const randomSuffix = Math.random().toString(36).substring(2, 5);
|
|
20697
|
-
fifoPath = `/tmp/agent-yes-${timestamp}${randomSuffix}.stdin`;
|
|
20698
|
-
}
|
|
20699
|
-
try {
|
|
20700
|
-
mkdirSync(dirname(fifoPath), { recursive: true });
|
|
20701
|
-
} catch (dirError) {
|
|
20702
|
-
logger.warn(`[${cli}-yes] Failed to create FIFO directory: ${dirError}`);
|
|
20703
|
-
return null;
|
|
20704
|
-
}
|
|
20705
|
-
const escapedPath = fifoPath.replace(/'/g, `'"'"'`);
|
|
20706
|
-
const mkfifoResult = execaCommandSync(`mkfifo '${escapedPath}'`, {
|
|
20707
|
-
reject: false
|
|
20708
|
-
});
|
|
20709
|
-
if (mkfifoResult.exitCode !== 0) {
|
|
20710
|
-
logger.warn(`[${cli}-yes] mkfifo command failed with exit code ${mkfifoResult.exitCode}`);
|
|
20711
|
-
logger.warn(`[${cli}-yes] Command: mkfifo '${escapedPath}'`);
|
|
20712
|
-
if (mkfifoResult.stderr) {
|
|
20713
|
-
logger.warn(`[${cli}-yes] mkfifo stderr: ${mkfifoResult.stderr}`);
|
|
20714
|
-
}
|
|
20715
|
-
if (mkfifoResult.stdout) {
|
|
20716
|
-
logger.warn(`[${cli}-yes] mkfifo stdout: ${mkfifoResult.stdout}`);
|
|
20717
|
-
}
|
|
20718
|
-
return null;
|
|
20719
|
-
}
|
|
20720
|
-
logger.info(`[${cli}-yes] Created FIFO at ${fifoPath}`);
|
|
20721
|
-
try {
|
|
20722
|
-
execaCommand(`exec 3>"${fifoPath}"`).catch(() => null);
|
|
20723
|
-
fifoStream = createReadStream2(fifoPath, {
|
|
20724
|
-
flags: "r",
|
|
20725
|
-
autoClose: true
|
|
20726
|
-
});
|
|
20727
|
-
logger.info(`[${cli}-yes] FIFO opened for reading`);
|
|
20728
|
-
const cleanupFifo = async () => {
|
|
20729
|
-
if (fifoStream) {
|
|
20730
|
-
try {
|
|
20731
|
-
fifoStream.close();
|
|
20732
|
-
logger.debug(`[${cli}-yes] Closed FIFO stream`);
|
|
20733
|
-
} catch (error) {
|
|
20734
|
-
logger.debug(`[${cli}-yes] Error closing FIFO stream:`, { error });
|
|
20735
|
-
}
|
|
20736
|
-
}
|
|
20737
|
-
if (fifoPath) {
|
|
20738
|
-
try {
|
|
20739
|
-
await unlink(fifoPath).catch(() => null);
|
|
20740
|
-
logger.info(`[${cli}-yes] Cleaned up FIFO at ${fifoPath}`);
|
|
20741
|
-
} catch {}
|
|
20742
|
-
}
|
|
20743
|
-
};
|
|
20744
|
-
process.on("exit", () => {
|
|
20745
|
-
if (fifoPath)
|
|
20746
|
-
unlink(fifoPath).catch(() => null);
|
|
20747
|
-
});
|
|
20748
|
-
process.on("SIGINT", async () => {
|
|
20749
|
-
await cleanupFifo();
|
|
20750
|
-
});
|
|
20751
|
-
process.on("SIGTERM", async () => {
|
|
20752
|
-
await cleanupFifo();
|
|
20753
|
-
});
|
|
20754
|
-
return {
|
|
20755
|
-
stream: src_default(fromReadable(fifoStream)).map((buffer2) => buffer2.toString()),
|
|
20756
|
-
cleanup: cleanupFifo
|
|
20757
|
-
};
|
|
20758
|
-
} catch (error) {
|
|
20759
|
-
logger.warn(`[${cli}-yes] Failed to open FIFO at ${fifoPath}:`, {
|
|
20760
|
-
error
|
|
20761
|
-
});
|
|
20762
|
-
if (error instanceof Error) {
|
|
20763
|
-
logger.warn(`[${cli}-yes] Error details: ${error.message}`);
|
|
20764
|
-
if (error.stack) {
|
|
20765
|
-
logger.debug(`[${cli}-yes] Stack trace: ${error.stack}`);
|
|
20766
|
-
}
|
|
20767
|
-
}
|
|
20768
|
-
if (fifoPath) {
|
|
20769
|
-
unlink(fifoPath).catch(() => null);
|
|
20770
|
-
}
|
|
20771
|
-
return null;
|
|
20772
|
-
}
|
|
20773
|
-
} catch (error) {
|
|
20774
|
-
logger.warn(`[${cli}-yes] Failed to create FIFO:`, { error });
|
|
20775
|
-
if (error instanceof Error) {
|
|
20776
|
-
logger.warn(`[${cli}-yes] Error details: ${error.message}`);
|
|
20777
|
-
}
|
|
20778
|
-
if (fifoPath) {
|
|
20779
|
-
unlink(fifoPath).catch(() => null);
|
|
20780
|
-
}
|
|
20781
|
-
return null;
|
|
20782
|
-
}
|
|
20783
|
-
}
|
|
20784
|
-
var init_fifo = __esm(() => {
|
|
20785
|
-
init_execa();
|
|
20786
|
-
init_dist4();
|
|
20787
|
-
init_logger();
|
|
20788
|
-
});
|
|
20789
|
-
|
|
20790
|
-
// ts/pidStore.ts
|
|
20791
|
-
import { mkdir as mkdir3, writeFile as writeFile3 } from "fs/promises";
|
|
20598
|
+
// ts/SqliteAdapter.ts
|
|
20599
|
+
import { mkdir as mkdir3 } from "fs/promises";
|
|
20792
20600
|
import path9 from "path";
|
|
20793
20601
|
|
|
20794
20602
|
class SqliteAdapter {
|
|
20795
20603
|
db;
|
|
20604
|
+
isInitialized = false;
|
|
20796
20605
|
async init(dbPath) {
|
|
20797
|
-
|
|
20798
|
-
|
|
20606
|
+
try {
|
|
20607
|
+
const dir = path9.dirname(dbPath);
|
|
20608
|
+
await mkdir3(dir, { recursive: true });
|
|
20609
|
+
if (typeof globalThis.Bun !== "undefined") {
|
|
20799
20610
|
const { Database } = await import("bun:sqlite");
|
|
20800
20611
|
this.db = new Database(dbPath);
|
|
20801
|
-
}
|
|
20802
|
-
|
|
20803
|
-
|
|
20804
|
-
this.db = new Database(dbPath);
|
|
20612
|
+
} else {
|
|
20613
|
+
const { DatabaseSync } = await import("node:sqlite");
|
|
20614
|
+
this.db = new DatabaseSync(dbPath);
|
|
20805
20615
|
}
|
|
20806
|
-
|
|
20807
|
-
|
|
20808
|
-
|
|
20616
|
+
this.isInitialized = true;
|
|
20617
|
+
logger.debug(`[SqliteAdapter] Initialized database at ${dbPath}`);
|
|
20618
|
+
} catch (error) {
|
|
20619
|
+
logger.warn(`[SqliteAdapter] Failed to initialize database at ${dbPath}:`, error);
|
|
20620
|
+
this.db = this.createFallbackDb();
|
|
20621
|
+
this.isInitialized = false;
|
|
20809
20622
|
}
|
|
20810
20623
|
}
|
|
20624
|
+
createFallbackDb() {
|
|
20625
|
+
const storage = new Map;
|
|
20626
|
+
return {
|
|
20627
|
+
prepare: (sql) => ({
|
|
20628
|
+
all: (...params) => {
|
|
20629
|
+
logger.debug("[SqliteAdapter] Using fallback mode (query):", sql);
|
|
20630
|
+
return storage.get(sql) || [];
|
|
20631
|
+
},
|
|
20632
|
+
run: (...params) => {
|
|
20633
|
+
logger.debug("[SqliteAdapter] Using fallback mode (run):", sql);
|
|
20634
|
+
return { lastInsertRowid: 0, changes: 0 };
|
|
20635
|
+
}
|
|
20636
|
+
}),
|
|
20637
|
+
query: (sql) => ({
|
|
20638
|
+
all: (params) => {
|
|
20639
|
+
logger.debug("[SqliteAdapter] Using fallback mode (query):", sql);
|
|
20640
|
+
return storage.get(sql) || [];
|
|
20641
|
+
}
|
|
20642
|
+
}),
|
|
20643
|
+
run: (sql, params) => {
|
|
20644
|
+
logger.debug("[SqliteAdapter] Using fallback mode (run):", sql);
|
|
20645
|
+
},
|
|
20646
|
+
close: () => {
|
|
20647
|
+
logger.debug("[SqliteAdapter] Closing fallback db");
|
|
20648
|
+
}
|
|
20649
|
+
};
|
|
20650
|
+
}
|
|
20811
20651
|
query(sql, params = []) {
|
|
20812
|
-
|
|
20813
|
-
|
|
20814
|
-
|
|
20815
|
-
|
|
20652
|
+
try {
|
|
20653
|
+
if (typeof this.db.query === "function") {
|
|
20654
|
+
return this.db.query(sql).all(params);
|
|
20655
|
+
} else {
|
|
20656
|
+
return this.db.prepare(sql).all(...params);
|
|
20657
|
+
}
|
|
20658
|
+
} catch (error) {
|
|
20659
|
+
logger.warn("[SqliteAdapter] Query failed:", error);
|
|
20660
|
+
return [];
|
|
20816
20661
|
}
|
|
20817
20662
|
}
|
|
20818
20663
|
run(sql, params = []) {
|
|
20819
|
-
|
|
20820
|
-
|
|
20821
|
-
|
|
20822
|
-
|
|
20664
|
+
try {
|
|
20665
|
+
if (typeof this.db.query === "function") {
|
|
20666
|
+
this.db.run(sql, params);
|
|
20667
|
+
return {};
|
|
20668
|
+
} else {
|
|
20669
|
+
return this.db.prepare(sql).run(...params);
|
|
20670
|
+
}
|
|
20671
|
+
} catch (error) {
|
|
20672
|
+
logger.warn("[SqliteAdapter] Run failed:", error);
|
|
20823
20673
|
return {};
|
|
20824
20674
|
}
|
|
20825
20675
|
}
|
|
20826
20676
|
close() {
|
|
20827
|
-
|
|
20828
|
-
this.db
|
|
20677
|
+
try {
|
|
20678
|
+
if (this.db?.close) {
|
|
20679
|
+
this.db.close();
|
|
20680
|
+
}
|
|
20681
|
+
} catch (error) {
|
|
20682
|
+
logger.warn("[SqliteAdapter] Close failed:", error);
|
|
20829
20683
|
}
|
|
20830
20684
|
}
|
|
20685
|
+
isReady() {
|
|
20686
|
+
return this.isInitialized;
|
|
20687
|
+
}
|
|
20831
20688
|
}
|
|
20689
|
+
var init_SqliteAdapter = __esm(() => {
|
|
20690
|
+
init_logger();
|
|
20691
|
+
});
|
|
20692
|
+
|
|
20693
|
+
// ts/pidStore.ts
|
|
20694
|
+
import { writeFile as writeFile3 } from "fs/promises";
|
|
20695
|
+
import path10 from "path";
|
|
20832
20696
|
|
|
20833
20697
|
class PidStore {
|
|
20834
20698
|
db;
|
|
20835
20699
|
storeDir;
|
|
20836
20700
|
dbPath;
|
|
20837
20701
|
constructor(workingDir) {
|
|
20838
|
-
this.storeDir =
|
|
20839
|
-
this.dbPath =
|
|
20702
|
+
this.storeDir = path10.resolve(workingDir, ".agent-yes");
|
|
20703
|
+
this.dbPath = path10.join(this.storeDir, "pid.sqlite");
|
|
20840
20704
|
}
|
|
20841
20705
|
async init() {
|
|
20842
|
-
|
|
20843
|
-
|
|
20844
|
-
|
|
20845
|
-
|
|
20846
|
-
|
|
20847
|
-
|
|
20848
|
-
|
|
20849
|
-
|
|
20850
|
-
|
|
20851
|
-
|
|
20852
|
-
|
|
20853
|
-
|
|
20854
|
-
|
|
20855
|
-
|
|
20856
|
-
|
|
20857
|
-
|
|
20858
|
-
|
|
20859
|
-
|
|
20860
|
-
|
|
20861
|
-
|
|
20862
|
-
|
|
20863
|
-
|
|
20864
|
-
|
|
20865
|
-
|
|
20866
|
-
|
|
20867
|
-
|
|
20706
|
+
try {
|
|
20707
|
+
await this.ensureGitignore();
|
|
20708
|
+
this.db = new SqliteAdapter;
|
|
20709
|
+
await this.db.init(this.dbPath);
|
|
20710
|
+
if (this.db.isReady()) {
|
|
20711
|
+
this.db.run("PRAGMA journal_mode=WAL");
|
|
20712
|
+
this.db.run("PRAGMA synchronous=NORMAL");
|
|
20713
|
+
this.db.run("PRAGMA cache_size=1000");
|
|
20714
|
+
this.db.run("PRAGMA temp_store=memory");
|
|
20715
|
+
this.db.run(`
|
|
20716
|
+
CREATE TABLE IF NOT EXISTS pid_records (
|
|
20717
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
20718
|
+
pid INTEGER NOT NULL UNIQUE,
|
|
20719
|
+
cli TEXT NOT NULL,
|
|
20720
|
+
args TEXT NOT NULL,
|
|
20721
|
+
prompt TEXT,
|
|
20722
|
+
logFile TEXT NOT NULL,
|
|
20723
|
+
fifoFile TEXT NOT NULL,
|
|
20724
|
+
status TEXT NOT NULL DEFAULT 'active',
|
|
20725
|
+
exitReason TEXT NOT NULL DEFAULT '',
|
|
20726
|
+
exitCode INTEGER,
|
|
20727
|
+
startedAt INTEGER NOT NULL,
|
|
20728
|
+
updatedAt INTEGER NOT NULL
|
|
20729
|
+
)
|
|
20730
|
+
`);
|
|
20731
|
+
await this.cleanStaleRecords();
|
|
20732
|
+
} else {
|
|
20733
|
+
logger.warn("[pidStore] Database not ready, running in fallback mode");
|
|
20734
|
+
}
|
|
20735
|
+
} catch (error) {
|
|
20736
|
+
logger.warn("[pidStore] Failed to initialize:", error);
|
|
20737
|
+
}
|
|
20868
20738
|
}
|
|
20869
20739
|
async registerProcess({
|
|
20870
20740
|
pid,
|
|
@@ -20874,7 +20744,7 @@ class PidStore {
|
|
|
20874
20744
|
}) {
|
|
20875
20745
|
const now = Date.now();
|
|
20876
20746
|
const argsJson = JSON.stringify(args);
|
|
20877
|
-
const logFile = this.
|
|
20747
|
+
const logFile = path10.resolve(this.getLogDir(), `${pid}.log`);
|
|
20878
20748
|
const fifoFile = this.getFifoPath(pid);
|
|
20879
20749
|
try {
|
|
20880
20750
|
this.db.run(`
|
|
@@ -20912,14 +20782,14 @@ class PidStore {
|
|
|
20912
20782
|
}
|
|
20913
20783
|
logger.debug(`[pidStore] Updated process ${pid} status=${status}`);
|
|
20914
20784
|
}
|
|
20915
|
-
|
|
20916
|
-
return
|
|
20785
|
+
getLogDir() {
|
|
20786
|
+
return path10.resolve(this.storeDir, "logs");
|
|
20917
20787
|
}
|
|
20918
20788
|
getFifoPath(pid) {
|
|
20919
20789
|
if (process.platform === "win32") {
|
|
20920
20790
|
return `\\\\.\\pipe\\agent-yes-${pid}`;
|
|
20921
20791
|
} else {
|
|
20922
|
-
return
|
|
20792
|
+
return path10.resolve(this.storeDir, "fifo", `${pid}.stdin`);
|
|
20923
20793
|
}
|
|
20924
20794
|
}
|
|
20925
20795
|
async cleanStaleRecords() {
|
|
@@ -20950,7 +20820,7 @@ class PidStore {
|
|
|
20950
20820
|
}
|
|
20951
20821
|
}
|
|
20952
20822
|
async ensureGitignore() {
|
|
20953
|
-
const gitignorePath =
|
|
20823
|
+
const gitignorePath = path10.join(this.storeDir, ".gitignore");
|
|
20954
20824
|
const gitignoreContent = `# Auto-generated .gitignore for agent-yes
|
|
20955
20825
|
# Ignore all log files and runtime data
|
|
20956
20826
|
logs/
|
|
@@ -20976,15 +20846,21 @@ fifo/
|
|
|
20976
20846
|
}
|
|
20977
20847
|
}
|
|
20978
20848
|
static async findActiveFifo(workingDir) {
|
|
20979
|
-
|
|
20980
|
-
|
|
20981
|
-
|
|
20982
|
-
|
|
20983
|
-
|
|
20849
|
+
try {
|
|
20850
|
+
const store = new PidStore(workingDir);
|
|
20851
|
+
await store.init();
|
|
20852
|
+
const records = store.db.query("SELECT * FROM pid_records WHERE status != 'exited' ORDER BY startedAt DESC LIMIT 1");
|
|
20853
|
+
await store.close();
|
|
20854
|
+
return records[0]?.fifoFile ?? null;
|
|
20855
|
+
} catch (error) {
|
|
20856
|
+
logger.warn("[pidStore] findActiveFifo failed:", error);
|
|
20857
|
+
return null;
|
|
20858
|
+
}
|
|
20984
20859
|
}
|
|
20985
20860
|
}
|
|
20986
20861
|
var init_pidStore = __esm(() => {
|
|
20987
20862
|
init_logger();
|
|
20863
|
+
init_SqliteAdapter();
|
|
20988
20864
|
});
|
|
20989
20865
|
|
|
20990
20866
|
// ts/core/messaging.ts
|
|
@@ -20992,9 +20868,10 @@ async function sendEnter(context, waitms = 1000) {
|
|
|
20992
20868
|
const st = Date.now();
|
|
20993
20869
|
await context.idleWaiter.wait(waitms);
|
|
20994
20870
|
const et = Date.now();
|
|
20995
|
-
logger.debug(`
|
|
20871
|
+
logger.debug(`sendingEnter| idleWaiter.wait(${String(waitms)}) took ${String(et - st)}ms`);
|
|
20996
20872
|
context.nextStdout.unready();
|
|
20997
20873
|
context.shell.write("\r");
|
|
20874
|
+
logger.debug(`enterSent| idleWaiter.wait(${String(waitms)}) took ${String(et - st)}ms`);
|
|
20998
20875
|
await Promise.race([
|
|
20999
20876
|
context.nextStdout.wait(),
|
|
21000
20877
|
new Promise((resolve) => setTimeout(() => {
|
|
@@ -21032,15 +20909,16 @@ var init_messaging = __esm(() => {
|
|
|
21032
20909
|
});
|
|
21033
20910
|
|
|
21034
20911
|
// ts/core/logging.ts
|
|
21035
|
-
import
|
|
21036
|
-
import { mkdir as
|
|
21037
|
-
function initializeLogPaths(pidStore, pid) {
|
|
21038
|
-
const
|
|
21039
|
-
|
|
21040
|
-
const
|
|
21041
|
-
const
|
|
20912
|
+
import path11 from "path";
|
|
20913
|
+
import { mkdir as mkdir5, writeFile as writeFile4 } from "fs/promises";
|
|
20914
|
+
async function initializeLogPaths(pidStore, pid) {
|
|
20915
|
+
const logDir = pidStore.getLogDir();
|
|
20916
|
+
await mkdir5(logDir, { recursive: true });
|
|
20917
|
+
const rawLogPath = path11.resolve(path11.dirname(logDir), `${pid}.raw.log`);
|
|
20918
|
+
const rawLinesLogPath = path11.resolve(path11.dirname(logDir), `${pid}.lines.log`);
|
|
20919
|
+
const debuggingLogsPath = path11.resolve(path11.dirname(logDir), `${pid}.debug.log`);
|
|
21042
20920
|
return {
|
|
21043
|
-
logPath,
|
|
20921
|
+
logPath: logDir,
|
|
21044
20922
|
rawLogPath,
|
|
21045
20923
|
rawLinesLogPath,
|
|
21046
20924
|
debuggingLogsPath
|
|
@@ -21057,7 +20935,7 @@ function setupDebugLogging(debuggingLogsPath) {
|
|
|
21057
20935
|
async function saveLogFile(logPath, content) {
|
|
21058
20936
|
if (!logPath)
|
|
21059
20937
|
return;
|
|
21060
|
-
await
|
|
20938
|
+
await mkdir5(path11.dirname(logPath), { recursive: true }).catch(() => null);
|
|
21061
20939
|
await writeFile4(logPath, content).catch(() => null);
|
|
21062
20940
|
logger.info(`Full logs saved to ${logPath}`);
|
|
21063
20941
|
}
|
|
@@ -21066,8 +20944,8 @@ async function saveDeprecatedLogFile(logFile, content, verbose) {
|
|
|
21066
20944
|
return;
|
|
21067
20945
|
if (verbose)
|
|
21068
20946
|
logger.info(`Writing rendered logs to ${logFile}`);
|
|
21069
|
-
const logFilePath =
|
|
21070
|
-
await
|
|
20947
|
+
const logFilePath = path11.resolve(logFile);
|
|
20948
|
+
await mkdir5(path11.dirname(logFilePath), { recursive: true }).catch(() => null);
|
|
21071
20949
|
await writeFile4(logFilePath, content);
|
|
21072
20950
|
}
|
|
21073
20951
|
var import_winston2;
|
|
@@ -21093,7 +20971,7 @@ function catcher(catchFn, fn) {
|
|
|
21093
20971
|
var exports_pty_fix = {};
|
|
21094
20972
|
import { execSync as execSync2 } from "child_process";
|
|
21095
20973
|
import { existsSync as existsSync2 } from "fs";
|
|
21096
|
-
import { dirname
|
|
20974
|
+
import { dirname, join as join2 } from "path";
|
|
21097
20975
|
import { arch, platform as platform2 } from "process";
|
|
21098
20976
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
21099
20977
|
function getLibraryName() {
|
|
@@ -21176,7 +21054,7 @@ function rebuildBunPty() {
|
|
|
21176
21054
|
}
|
|
21177
21055
|
var bunPtyPath, libName, libPath;
|
|
21178
21056
|
var init_pty_fix = __esm(() => {
|
|
21179
|
-
bunPtyPath =
|
|
21057
|
+
bunPtyPath = dirname(fileURLToPath3(import.meta.resolve("@snomiao/bun-pty"))) + "/..";
|
|
21180
21058
|
libName = getLibraryName();
|
|
21181
21059
|
libPath = join2(bunPtyPath, "rust-pty", "target", "release", libName);
|
|
21182
21060
|
if (!existsSync2(bunPtyPath)) {
|
|
@@ -21248,9 +21126,7 @@ function spawnAgent(options) {
|
|
|
21248
21126
|
const spawn2 = () => {
|
|
21249
21127
|
const cliCommand = cliConf?.binary || cli;
|
|
21250
21128
|
let [bin, ...args] = [...parseCommandString(cliCommand), ...cliArgs];
|
|
21251
|
-
|
|
21252
|
-
logger.info(`Spawning ${bin} with args: ${JSON.stringify(args)}`);
|
|
21253
|
-
logger.info(`Spawning ${bin} with args: ${JSON.stringify(args)}`);
|
|
21129
|
+
logger.debug(`Spawning ${bin} with args: ${JSON.stringify(args)}`);
|
|
21254
21130
|
const spawned = pty_default.spawn(bin, args, ptyOptions);
|
|
21255
21131
|
logger.info(`[${cli}-yes] Spawned ${bin} with PID ${spawned.pid}`);
|
|
21256
21132
|
return spawned;
|
|
@@ -21289,7 +21165,7 @@ var init_spawner = __esm(async () => {
|
|
|
21289
21165
|
});
|
|
21290
21166
|
|
|
21291
21167
|
// ts/ReadyManager.ts
|
|
21292
|
-
class
|
|
21168
|
+
class ReadyManager {
|
|
21293
21169
|
isReady = false;
|
|
21294
21170
|
readyQueue = [];
|
|
21295
21171
|
wait() {
|
|
@@ -21334,9 +21210,9 @@ class AgentContext {
|
|
|
21334
21210
|
cliConf;
|
|
21335
21211
|
verbose;
|
|
21336
21212
|
robust;
|
|
21337
|
-
stdinReady = new
|
|
21338
|
-
stdinFirstReady = new
|
|
21339
|
-
nextStdout = new
|
|
21213
|
+
stdinReady = new ReadyManager;
|
|
21214
|
+
stdinFirstReady = new ReadyManager;
|
|
21215
|
+
nextStdout = new ReadyManager;
|
|
21340
21216
|
idleWaiter = new IdleWaiter;
|
|
21341
21217
|
isFatal = false;
|
|
21342
21218
|
shouldRestartWithoutContinue = false;
|
|
@@ -21372,7 +21248,7 @@ async function createAutoResponseHandler(line, lineIndex, options) {
|
|
|
21372
21248
|
ctx.stdinFirstReady.ready();
|
|
21373
21249
|
}
|
|
21374
21250
|
if (conf.enter?.some((rx) => line.match(rx))) {
|
|
21375
|
-
logger.debug(`
|
|
21251
|
+
logger.debug(`sendEnter matched|${line}`);
|
|
21376
21252
|
return await sendEnter(ctx.messageContext, 400);
|
|
21377
21253
|
}
|
|
21378
21254
|
const typingResponded = await src_default(Object.entries(conf.typingRespond ?? {})).filter(([_sendString, onThePatterns]) => onThePatterns.some((rx) => line.match(rx))).map(async ([sendString]) => await sendMessage3(ctx.messageContext, sendString, { waitForReady: false })).toCount();
|
|
@@ -21480,23 +21356,14 @@ var exports_agent_yes_config = {};
|
|
|
21480
21356
|
__export(exports_agent_yes_config, {
|
|
21481
21357
|
default: () => agent_yes_config_default
|
|
21482
21358
|
});
|
|
21483
|
-
import { mkdir as
|
|
21359
|
+
import { mkdir as mkdir6 } from "node:fs/promises";
|
|
21484
21360
|
import os from "node:os";
|
|
21485
|
-
import
|
|
21361
|
+
import path12 from "node:path";
|
|
21486
21362
|
function getDefaultConfig() {
|
|
21487
21363
|
return defineCliYesConfig({
|
|
21488
21364
|
configDir,
|
|
21489
|
-
logsDir: configDir &&
|
|
21365
|
+
logsDir: configDir && path12.resolve(configDir, "logs"),
|
|
21490
21366
|
clis: {
|
|
21491
|
-
qwen: {
|
|
21492
|
-
install: "npm install -g @qwen-code/qwen-code@latest",
|
|
21493
|
-
version: "qwen --version"
|
|
21494
|
-
},
|
|
21495
|
-
grok: {
|
|
21496
|
-
install: "npm install -g @vibe-kit/grok-cli@latest",
|
|
21497
|
-
ready: [/^ │ ❯ +/],
|
|
21498
|
-
enter: [/^ 1. Yes/]
|
|
21499
|
-
},
|
|
21500
21367
|
claude: {
|
|
21501
21368
|
promptArg: "last-arg",
|
|
21502
21369
|
install: {
|
|
@@ -21508,19 +21375,20 @@ function getDefaultConfig() {
|
|
|
21508
21375
|
/\? for shortcuts/,
|
|
21509
21376
|
/\u00A0Try "/,
|
|
21510
21377
|
/^\? for shortcuts/,
|
|
21511
|
-
/^> /,
|
|
21378
|
+
/^>[ \u00A0]/,
|
|
21512
21379
|
/──────────+/
|
|
21513
21380
|
],
|
|
21514
21381
|
typingRespond: {
|
|
21515
21382
|
"1\n": [/│ Do you want to use this API key\?/]
|
|
21516
21383
|
},
|
|
21517
21384
|
enter: [
|
|
21518
|
-
|
|
21519
|
-
/^.{0,4} 1\. Yes, continue/m,
|
|
21520
|
-
/^.{0,4} 1\. Dark mode ?✔/m,
|
|
21521
|
-
/❯ 1\. Yes/m,
|
|
21522
|
-
/❯ 1\. Yes, continue/m,
|
|
21385
|
+
/ > 1. Yes, I trust this folder/m,
|
|
21523
21386
|
/❯ 1\. Dark mode ?✔/m,
|
|
21387
|
+
/❯ 1\. Yes, continue/m,
|
|
21388
|
+
/❯ 1\. Yes/m,
|
|
21389
|
+
/^.{0,4} 1\. Dark mode ?✔/m,
|
|
21390
|
+
/^.{0,4} 1\. Yes, continue/m,
|
|
21391
|
+
/^.{0,4} 1\. Yes/m,
|
|
21524
21392
|
/Press Enter to continue…/m
|
|
21525
21393
|
],
|
|
21526
21394
|
fatal: [/⎿ Claude usage limit reached\./, /^error: unknown option/],
|
|
@@ -21533,7 +21401,7 @@ function getDefaultConfig() {
|
|
|
21533
21401
|
gemini: {
|
|
21534
21402
|
install: "npm install -g @google/gemini-cli@latest",
|
|
21535
21403
|
ready: [/Type your message/],
|
|
21536
|
-
enter: [/│ ● 1. Yes, allow once/, /│ ● 1. Allow once/],
|
|
21404
|
+
enter: [/│ ● 1. Yes, allow once/, /│ ● 1. Allow once/, /│ ● 1. Allow once/],
|
|
21537
21405
|
fatal: [/Error resuming session/, /No previous sessions found for this project./],
|
|
21538
21406
|
restoreArgs: ["--resume"],
|
|
21539
21407
|
restartWithoutContinueArg: [
|
|
@@ -21559,6 +21427,15 @@ function getDefaultConfig() {
|
|
|
21559
21427
|
defaultArgs: ["--search"],
|
|
21560
21428
|
noEOL: true
|
|
21561
21429
|
},
|
|
21430
|
+
qwen: {
|
|
21431
|
+
install: "npm install -g @qwen-code/qwen-code@latest",
|
|
21432
|
+
version: "qwen --version"
|
|
21433
|
+
},
|
|
21434
|
+
grok: {
|
|
21435
|
+
install: "npm install -g @vibe-kit/grok-cli@latest",
|
|
21436
|
+
ready: [/^ │ ❯ +/],
|
|
21437
|
+
enter: [/^ 1. Yes/]
|
|
21438
|
+
},
|
|
21562
21439
|
copilot: {
|
|
21563
21440
|
promptArg: "-i",
|
|
21564
21441
|
install: "npm install -g @github/copilot",
|
|
@@ -21600,7 +21477,8 @@ function getDefaultConfig() {
|
|
|
21600
21477
|
bash: "curl -fsSL https://opencode.ai/install | bash",
|
|
21601
21478
|
npm: "npm i -g opencode-ai"
|
|
21602
21479
|
},
|
|
21603
|
-
enter: []
|
|
21480
|
+
enter: [],
|
|
21481
|
+
ready: []
|
|
21604
21482
|
}
|
|
21605
21483
|
}
|
|
21606
21484
|
});
|
|
@@ -21610,21 +21488,21 @@ var init_agent_yes_config = __esm(async () => {
|
|
|
21610
21488
|
init_logger();
|
|
21611
21489
|
logger.debug("loading cli-yes.config.ts from " + import.meta.url);
|
|
21612
21490
|
configDir = await (async () => {
|
|
21613
|
-
const homeConfigDir =
|
|
21614
|
-
const isHomeWritable = await
|
|
21491
|
+
const homeConfigDir = path12.resolve(os.homedir(), ".agent-yes");
|
|
21492
|
+
const isHomeWritable = await mkdir6(homeConfigDir, { recursive: true }).then(() => true).catch(() => false);
|
|
21615
21493
|
if (isHomeWritable) {
|
|
21616
21494
|
logger.debug("[config] Using home directory:", homeConfigDir);
|
|
21617
21495
|
return homeConfigDir;
|
|
21618
21496
|
}
|
|
21619
|
-
const tmpConfigDir =
|
|
21620
|
-
const isWritable = await
|
|
21497
|
+
const tmpConfigDir = path12.resolve("/tmp/.agent-yes");
|
|
21498
|
+
const isWritable = await mkdir6(tmpConfigDir, { recursive: true });
|
|
21621
21499
|
if (isWritable) {
|
|
21622
21500
|
logger.debug("[config] Using workspace directory:", tmpConfigDir);
|
|
21623
21501
|
return tmpConfigDir;
|
|
21624
21502
|
}
|
|
21625
21503
|
return;
|
|
21626
21504
|
})();
|
|
21627
|
-
agent_yes_config_default = deepMixin(await getDefaultConfig(), await import(
|
|
21505
|
+
agent_yes_config_default = deepMixin(await getDefaultConfig(), await import(path12.resolve(os.homedir(), ".agent-yes/config.ts")).catch(() => ({ default: {} })).then((mod) => mod.default), await import(path12.resolve(process.cwd(), "node_modules/.agent-yes/config.ts")).catch(() => ({ default: {} })).then((mod) => mod.default), await import(path12.resolve(process.cwd(), ".agent-yes/config.ts")).catch(() => ({ default: {} })).then((mod) => mod.default));
|
|
21628
21506
|
});
|
|
21629
21507
|
|
|
21630
21508
|
// node_modules/emoji-regex/index.js
|
|
@@ -21663,9 +21541,9 @@ __export(exports_ts, {
|
|
|
21663
21541
|
config: () => config2,
|
|
21664
21542
|
CLIS_CONFIG: () => CLIS_CONFIG2
|
|
21665
21543
|
});
|
|
21666
|
-
import { fromReadable as
|
|
21667
|
-
import { mkdir as
|
|
21668
|
-
import
|
|
21544
|
+
import { fromReadable as fromReadable2, fromWritable as fromWritable2 } from "from-node-stream";
|
|
21545
|
+
import { mkdir as mkdir9, readFile as readFile4, writeFile as writeFile8 } from "fs/promises";
|
|
21546
|
+
import path15 from "path";
|
|
21669
21547
|
async function agentYes2({
|
|
21670
21548
|
cli,
|
|
21671
21549
|
cliArgs = [],
|
|
@@ -21681,7 +21559,7 @@ async function agentYes2({
|
|
|
21681
21559
|
install = false,
|
|
21682
21560
|
resume = false,
|
|
21683
21561
|
useSkills = false,
|
|
21684
|
-
|
|
21562
|
+
useStdinAppend = false
|
|
21685
21563
|
}) {
|
|
21686
21564
|
if (!cli)
|
|
21687
21565
|
throw new Error(`cli is required`);
|
|
@@ -21748,9 +21626,9 @@ async function agentYes2({
|
|
|
21748
21626
|
} catch {}
|
|
21749
21627
|
const skillHeaders = [];
|
|
21750
21628
|
let currentDir = workingDir2;
|
|
21751
|
-
const searchLimit = gitRoot ||
|
|
21629
|
+
const searchLimit = gitRoot || path15.parse(currentDir).root;
|
|
21752
21630
|
while (true) {
|
|
21753
|
-
const skillPath =
|
|
21631
|
+
const skillPath = path15.resolve(currentDir, "SKILL.md");
|
|
21754
21632
|
const md = await readFile4(skillPath, "utf8").catch(() => null);
|
|
21755
21633
|
if (md) {
|
|
21756
21634
|
const headerMatch = md.match(/^[\s\S]*?(?=\n##\s)/);
|
|
@@ -21763,7 +21641,7 @@ async function agentYes2({
|
|
|
21763
21641
|
}
|
|
21764
21642
|
if (currentDir === searchLimit)
|
|
21765
21643
|
break;
|
|
21766
|
-
const parentDir =
|
|
21644
|
+
const parentDir = path15.dirname(currentDir);
|
|
21767
21645
|
if (parentDir === currentDir)
|
|
21768
21646
|
break;
|
|
21769
21647
|
currentDir = parentDir;
|
|
@@ -21829,7 +21707,7 @@ ${prompt}` : prefix;
|
|
|
21829
21707
|
const ptyEnv = { ...env2 ?? process.env };
|
|
21830
21708
|
const ptyOptions = {
|
|
21831
21709
|
name: "xterm-color",
|
|
21832
|
-
...
|
|
21710
|
+
...getTerminalDimensions(),
|
|
21833
21711
|
cwd: cwd ?? process.cwd(),
|
|
21834
21712
|
env: ptyEnv
|
|
21835
21713
|
};
|
|
@@ -21842,7 +21720,7 @@ ${prompt}` : prefix;
|
|
|
21842
21720
|
ptyOptions
|
|
21843
21721
|
});
|
|
21844
21722
|
await pidStore.registerProcess({ pid: shell.pid, cli, args: cliArgs, prompt });
|
|
21845
|
-
const logPaths = initializeLogPaths(pidStore, shell.pid);
|
|
21723
|
+
const logPaths = await initializeLogPaths(pidStore, shell.pid);
|
|
21846
21724
|
setupDebugLogging(logPaths.debuggingLogsPath);
|
|
21847
21725
|
const ctx = new AgentContext({
|
|
21848
21726
|
shell,
|
|
@@ -21882,7 +21760,7 @@ ${prompt}` : prefix;
|
|
|
21882
21760
|
logger.info(`Restarting ${cli} ${JSON.stringify([bin, ...args])}`);
|
|
21883
21761
|
const restartPtyOptions = {
|
|
21884
21762
|
name: "xterm-color",
|
|
21885
|
-
...
|
|
21763
|
+
...getTerminalDimensions(),
|
|
21886
21764
|
cwd: cwd ?? process.cwd(),
|
|
21887
21765
|
env: ptyEnv
|
|
21888
21766
|
};
|
|
@@ -21921,7 +21799,7 @@ ${prompt}` : prefix;
|
|
|
21921
21799
|
}
|
|
21922
21800
|
const restorePtyOptions = {
|
|
21923
21801
|
name: "xterm-color",
|
|
21924
|
-
...
|
|
21802
|
+
...getTerminalDimensions(),
|
|
21925
21803
|
cwd: cwd ?? process.cwd(),
|
|
21926
21804
|
env: ptyEnv
|
|
21927
21805
|
};
|
|
@@ -21939,7 +21817,7 @@ ${prompt}` : prefix;
|
|
|
21939
21817
|
return pendingExitCode.resolve(exitCode2);
|
|
21940
21818
|
});
|
|
21941
21819
|
process.stdout.on("resize", () => {
|
|
21942
|
-
const { cols, rows } =
|
|
21820
|
+
const { cols, rows } = getTerminalDimensions();
|
|
21943
21821
|
shell.resize(cols, rows);
|
|
21944
21822
|
});
|
|
21945
21823
|
const terminalRender = new TerminalTextRender;
|
|
@@ -21954,27 +21832,12 @@ ${prompt}` : prefix;
|
|
|
21954
21832
|
logger.info("[${cli}-yes] ${cli} is idle, exiting...");
|
|
21955
21833
|
await exitAgent();
|
|
21956
21834
|
});
|
|
21957
|
-
await src_default(
|
|
21835
|
+
await src_default(fromReadable2(process.stdin)).map((buffer2) => buffer2.toString()).forkTo(function handleTerminateSignals(s) {
|
|
21958
21836
|
const handler = createTerminateSignalHandler(ctx.stdinReady, (exitCode2) => {
|
|
21959
21837
|
shell.kill("SIGINT");
|
|
21960
21838
|
pendingExitCode.resolve(exitCode2);
|
|
21961
21839
|
});
|
|
21962
21840
|
return s.map(handler);
|
|
21963
|
-
}).by((s) => {
|
|
21964
|
-
if (!useFifo)
|
|
21965
|
-
return s;
|
|
21966
|
-
const fifoPath = pidStore.getFifoPath(shell.pid);
|
|
21967
|
-
if (!fifoPath)
|
|
21968
|
-
return s;
|
|
21969
|
-
const ipcResult = createFifoStream(cli, fifoPath);
|
|
21970
|
-
if (!ipcResult)
|
|
21971
|
-
return s;
|
|
21972
|
-
pendingExitCode.promise.finally(() => ipcResult.cleanup());
|
|
21973
|
-
process.stderr.write(`
|
|
21974
|
-
Append prompts: ${cli}-yes --append-prompt '...'
|
|
21975
|
-
|
|
21976
|
-
`);
|
|
21977
|
-
return s.merge(ipcResult.stream);
|
|
21978
21841
|
}).onStart(async function promptOnStart() {
|
|
21979
21842
|
logger.debug("Sending prompt message: " + JSON.stringify(prompt));
|
|
21980
21843
|
if (prompt)
|
|
@@ -21995,7 +21858,7 @@ ${prompt}` : prefix;
|
|
|
21995
21858
|
const rawLogPath = ctx.logPaths.rawLogPath;
|
|
21996
21859
|
if (!rawLogPath)
|
|
21997
21860
|
return f.run();
|
|
21998
|
-
return await
|
|
21861
|
+
return await mkdir9(path15.dirname(rawLogPath), { recursive: true }).then(() => {
|
|
21999
21862
|
logger.debug(`[${cli}-yes] raw logs streaming to ${rawLogPath}`);
|
|
22000
21863
|
return f.forEach(async (chars) => {
|
|
22001
21864
|
await writeFile8(rawLogPath, chars, { flag: "a" }).catch(() => null);
|
|
@@ -22034,9 +21897,9 @@ ${prompt}` : prefix;
|
|
|
22034
21897
|
}, 5000))
|
|
22035
21898
|
]);
|
|
22036
21899
|
}
|
|
22037
|
-
function
|
|
21900
|
+
function getTerminalDimensions() {
|
|
22038
21901
|
if (!process.stdout.isTTY)
|
|
22039
|
-
return { cols: 80, rows:
|
|
21902
|
+
return { cols: 80, rows: 24 };
|
|
22040
21903
|
return {
|
|
22041
21904
|
cols: Math.max(20, process.stdout.columns),
|
|
22042
21905
|
rows: process.stdout.rows
|
|
@@ -22055,7 +21918,6 @@ var init_ts = __esm(async () => {
|
|
|
22055
21918
|
init_codexSessionManager();
|
|
22056
21919
|
init_runningLock();
|
|
22057
21920
|
init_logger();
|
|
22058
|
-
init_fifo();
|
|
22059
21921
|
init_pidStore();
|
|
22060
21922
|
init_messaging();
|
|
22061
21923
|
init_logging();
|
|
@@ -22078,7 +21940,6 @@ init_dist5();
|
|
|
22078
21940
|
init_codexSessionManager();
|
|
22079
21941
|
init_runningLock();
|
|
22080
21942
|
init_logger();
|
|
22081
|
-
init_fifo();
|
|
22082
21943
|
init_pidStore();
|
|
22083
21944
|
init_messaging();
|
|
22084
21945
|
init_logging();
|
|
@@ -22089,9 +21950,9 @@ await __promiseAll([
|
|
|
22089
21950
|
init_pty(),
|
|
22090
21951
|
init_spawner()
|
|
22091
21952
|
]);
|
|
22092
|
-
import { fromReadable
|
|
22093
|
-
import { mkdir as
|
|
22094
|
-
import
|
|
21953
|
+
import { fromReadable, fromWritable } from "from-node-stream";
|
|
21954
|
+
import { mkdir as mkdir7, readFile as readFile3, writeFile as writeFile5 } from "fs/promises";
|
|
21955
|
+
import path13 from "path";
|
|
22095
21956
|
var config = await init_agent_yes_config().then(() => exports_agent_yes_config).then((mod) => mod.default || mod);
|
|
22096
21957
|
var CLIS_CONFIG = config.clis;
|
|
22097
21958
|
async function agentYes({
|
|
@@ -22109,7 +21970,7 @@ async function agentYes({
|
|
|
22109
21970
|
install = false,
|
|
22110
21971
|
resume = false,
|
|
22111
21972
|
useSkills = false,
|
|
22112
|
-
|
|
21973
|
+
useStdinAppend = false
|
|
22113
21974
|
}) {
|
|
22114
21975
|
if (!cli)
|
|
22115
21976
|
throw new Error(`cli is required`);
|
|
@@ -22176,9 +22037,9 @@ async function agentYes({
|
|
|
22176
22037
|
} catch {}
|
|
22177
22038
|
const skillHeaders = [];
|
|
22178
22039
|
let currentDir = workingDir2;
|
|
22179
|
-
const searchLimit = gitRoot ||
|
|
22040
|
+
const searchLimit = gitRoot || path13.parse(currentDir).root;
|
|
22180
22041
|
while (true) {
|
|
22181
|
-
const skillPath =
|
|
22042
|
+
const skillPath = path13.resolve(currentDir, "SKILL.md");
|
|
22182
22043
|
const md = await readFile3(skillPath, "utf8").catch(() => null);
|
|
22183
22044
|
if (md) {
|
|
22184
22045
|
const headerMatch = md.match(/^[\s\S]*?(?=\n##\s)/);
|
|
@@ -22191,7 +22052,7 @@ async function agentYes({
|
|
|
22191
22052
|
}
|
|
22192
22053
|
if (currentDir === searchLimit)
|
|
22193
22054
|
break;
|
|
22194
|
-
const parentDir =
|
|
22055
|
+
const parentDir = path13.dirname(currentDir);
|
|
22195
22056
|
if (parentDir === currentDir)
|
|
22196
22057
|
break;
|
|
22197
22058
|
currentDir = parentDir;
|
|
@@ -22257,7 +22118,7 @@ ${prompt}` : prefix;
|
|
|
22257
22118
|
const ptyEnv = { ...env ?? process.env };
|
|
22258
22119
|
const ptyOptions = {
|
|
22259
22120
|
name: "xterm-color",
|
|
22260
|
-
...
|
|
22121
|
+
...getTerminalDimensions(),
|
|
22261
22122
|
cwd: cwd ?? process.cwd(),
|
|
22262
22123
|
env: ptyEnv
|
|
22263
22124
|
};
|
|
@@ -22270,7 +22131,7 @@ ${prompt}` : prefix;
|
|
|
22270
22131
|
ptyOptions
|
|
22271
22132
|
});
|
|
22272
22133
|
await pidStore.registerProcess({ pid: shell.pid, cli, args: cliArgs, prompt });
|
|
22273
|
-
const logPaths = initializeLogPaths(pidStore, shell.pid);
|
|
22134
|
+
const logPaths = await initializeLogPaths(pidStore, shell.pid);
|
|
22274
22135
|
setupDebugLogging(logPaths.debuggingLogsPath);
|
|
22275
22136
|
const ctx = new AgentContext({
|
|
22276
22137
|
shell,
|
|
@@ -22310,7 +22171,7 @@ ${prompt}` : prefix;
|
|
|
22310
22171
|
logger.info(`Restarting ${cli} ${JSON.stringify([bin, ...args])}`);
|
|
22311
22172
|
const restartPtyOptions = {
|
|
22312
22173
|
name: "xterm-color",
|
|
22313
|
-
...
|
|
22174
|
+
...getTerminalDimensions(),
|
|
22314
22175
|
cwd: cwd ?? process.cwd(),
|
|
22315
22176
|
env: ptyEnv
|
|
22316
22177
|
};
|
|
@@ -22349,7 +22210,7 @@ ${prompt}` : prefix;
|
|
|
22349
22210
|
}
|
|
22350
22211
|
const restorePtyOptions = {
|
|
22351
22212
|
name: "xterm-color",
|
|
22352
|
-
...
|
|
22213
|
+
...getTerminalDimensions(),
|
|
22353
22214
|
cwd: cwd ?? process.cwd(),
|
|
22354
22215
|
env: ptyEnv
|
|
22355
22216
|
};
|
|
@@ -22367,7 +22228,7 @@ ${prompt}` : prefix;
|
|
|
22367
22228
|
return pendingExitCode.resolve(exitCode2);
|
|
22368
22229
|
});
|
|
22369
22230
|
process.stdout.on("resize", () => {
|
|
22370
|
-
const { cols, rows } =
|
|
22231
|
+
const { cols, rows } = getTerminalDimensions();
|
|
22371
22232
|
shell.resize(cols, rows);
|
|
22372
22233
|
});
|
|
22373
22234
|
const terminalRender = new TerminalTextRender;
|
|
@@ -22382,27 +22243,12 @@ ${prompt}` : prefix;
|
|
|
22382
22243
|
logger.info("[${cli}-yes] ${cli} is idle, exiting...");
|
|
22383
22244
|
await exitAgent();
|
|
22384
22245
|
});
|
|
22385
|
-
await src_default(
|
|
22246
|
+
await src_default(fromReadable(process.stdin)).map((buffer2) => buffer2.toString()).forkTo(function handleTerminateSignals(s) {
|
|
22386
22247
|
const handler = createTerminateSignalHandler(ctx.stdinReady, (exitCode2) => {
|
|
22387
22248
|
shell.kill("SIGINT");
|
|
22388
22249
|
pendingExitCode.resolve(exitCode2);
|
|
22389
22250
|
});
|
|
22390
22251
|
return s.map(handler);
|
|
22391
|
-
}).by((s) => {
|
|
22392
|
-
if (!useFifo)
|
|
22393
|
-
return s;
|
|
22394
|
-
const fifoPath = pidStore.getFifoPath(shell.pid);
|
|
22395
|
-
if (!fifoPath)
|
|
22396
|
-
return s;
|
|
22397
|
-
const ipcResult = createFifoStream(cli, fifoPath);
|
|
22398
|
-
if (!ipcResult)
|
|
22399
|
-
return s;
|
|
22400
|
-
pendingExitCode.promise.finally(() => ipcResult.cleanup());
|
|
22401
|
-
process.stderr.write(`
|
|
22402
|
-
Append prompts: ${cli}-yes --append-prompt '...'
|
|
22403
|
-
|
|
22404
|
-
`);
|
|
22405
|
-
return s.merge(ipcResult.stream);
|
|
22406
22252
|
}).onStart(async function promptOnStart() {
|
|
22407
22253
|
logger.debug("Sending prompt message: " + JSON.stringify(prompt));
|
|
22408
22254
|
if (prompt)
|
|
@@ -22423,7 +22269,7 @@ ${prompt}` : prefix;
|
|
|
22423
22269
|
const rawLogPath = ctx.logPaths.rawLogPath;
|
|
22424
22270
|
if (!rawLogPath)
|
|
22425
22271
|
return f.run();
|
|
22426
|
-
return await
|
|
22272
|
+
return await mkdir7(path13.dirname(rawLogPath), { recursive: true }).then(() => {
|
|
22427
22273
|
logger.debug(`[${cli}-yes] raw logs streaming to ${rawLogPath}`);
|
|
22428
22274
|
return f.forEach(async (chars) => {
|
|
22429
22275
|
await writeFile5(rawLogPath, chars, { flag: "a" }).catch(() => null);
|
|
@@ -22462,9 +22308,9 @@ ${prompt}` : prefix;
|
|
|
22462
22308
|
}, 5000))
|
|
22463
22309
|
]);
|
|
22464
22310
|
}
|
|
22465
|
-
function
|
|
22311
|
+
function getTerminalDimensions() {
|
|
22466
22312
|
if (!process.stdout.isTTY)
|
|
22467
|
-
return { cols: 80, rows:
|
|
22313
|
+
return { cols: 80, rows: 24 };
|
|
22468
22314
|
return {
|
|
22469
22315
|
cols: Math.max(20, process.stdout.columns),
|
|
22470
22316
|
rows: process.stdout.rows
|
|
@@ -23234,19 +23080,19 @@ function ui(opts) {
|
|
|
23234
23080
|
}
|
|
23235
23081
|
|
|
23236
23082
|
// node_modules/escalade/sync/index.mjs
|
|
23237
|
-
import { dirname as
|
|
23083
|
+
import { dirname as dirname2, resolve } from "path";
|
|
23238
23084
|
import { readdirSync, statSync as statSync2 } from "fs";
|
|
23239
23085
|
function sync_default(start, callback) {
|
|
23240
23086
|
let dir = resolve(".", start);
|
|
23241
23087
|
let tmp, stats = statSync2(dir);
|
|
23242
23088
|
if (!stats.isDirectory()) {
|
|
23243
|
-
dir =
|
|
23089
|
+
dir = dirname2(dir);
|
|
23244
23090
|
}
|
|
23245
23091
|
while (true) {
|
|
23246
23092
|
tmp = callback(dir, readdirSync(dir));
|
|
23247
23093
|
if (tmp)
|
|
23248
23094
|
return resolve(dir, tmp);
|
|
23249
|
-
dir =
|
|
23095
|
+
dir = dirname2(tmp = dir);
|
|
23250
23096
|
if (tmp === dir)
|
|
23251
23097
|
break;
|
|
23252
23098
|
}
|
|
@@ -24217,11 +24063,11 @@ var parser = new YargsParser({
|
|
|
24217
24063
|
format: format2,
|
|
24218
24064
|
normalize,
|
|
24219
24065
|
resolve: resolve2,
|
|
24220
|
-
require: (
|
|
24066
|
+
require: (path14) => {
|
|
24221
24067
|
if (typeof require2 !== "undefined") {
|
|
24222
|
-
return require2(
|
|
24223
|
-
} else if (
|
|
24224
|
-
return JSON.parse(readFileSync3(
|
|
24068
|
+
return require2(path14);
|
|
24069
|
+
} else if (path14.match(/\.json$/)) {
|
|
24070
|
+
return JSON.parse(readFileSync3(path14, "utf8"));
|
|
24225
24071
|
} else {
|
|
24226
24072
|
throw Error("only .json config files are supported in ESM");
|
|
24227
24073
|
}
|
|
@@ -24240,7 +24086,7 @@ yargsParser.looksLikeNumber = looksLikeNumber;
|
|
|
24240
24086
|
var lib_default = yargsParser;
|
|
24241
24087
|
|
|
24242
24088
|
// node_modules/yargs/lib/platform-shims/esm.mjs
|
|
24243
|
-
import { basename, dirname as
|
|
24089
|
+
import { basename, dirname as dirname3, extname, relative, resolve as resolve4, join as join3 } from "path";
|
|
24244
24090
|
|
|
24245
24091
|
// node_modules/yargs/build/lib/utils/process-argv.js
|
|
24246
24092
|
function getProcessArgvBinIndex() {
|
|
@@ -24518,7 +24364,7 @@ var esm_default = {
|
|
|
24518
24364
|
Parser: lib_default,
|
|
24519
24365
|
path: {
|
|
24520
24366
|
basename,
|
|
24521
|
-
dirname:
|
|
24367
|
+
dirname: dirname3,
|
|
24522
24368
|
extname,
|
|
24523
24369
|
relative,
|
|
24524
24370
|
resolve: resolve4,
|
|
@@ -27939,7 +27785,7 @@ var package_default = {
|
|
|
27939
27785
|
registry: "https://registry.npmjs.org/"
|
|
27940
27786
|
},
|
|
27941
27787
|
scripts: {
|
|
27942
|
-
build: "bun build ./ts/cli.ts ./ts/index.ts --outdir=dist --target=node --sourcemap --external
|
|
27788
|
+
build: "bun build ./ts/cli.ts ./ts/index.ts --outdir=dist --target=node --sourcemap --external=@snomiao/bun-pty --external=bun-pty --external=node-pty --external=from-node-stream --external=bun",
|
|
27943
27789
|
postbuild: "bun ./ts/postbuild.ts",
|
|
27944
27790
|
demo: "bun run build && bun link && claude-yes -- demo",
|
|
27945
27791
|
dev: "bun ts/index.ts",
|
|
@@ -27953,17 +27799,22 @@ var package_default = {
|
|
|
27953
27799
|
},
|
|
27954
27800
|
dependencies: {
|
|
27955
27801
|
"@snomiao/bun-pty": "^0.3.4",
|
|
27956
|
-
"better-sqlite3": "^12.1.0",
|
|
27957
27802
|
"bun-pty": "^0.4.8",
|
|
27958
27803
|
"from-node-stream": "^0.1.2"
|
|
27959
27804
|
},
|
|
27960
27805
|
devDependencies: {
|
|
27806
|
+
"@ai-sdk/anthropic": "^3.0.28",
|
|
27807
|
+
"@ai-sdk/openai": "^3.0.21",
|
|
27808
|
+
prettier: "^3.8.1",
|
|
27809
|
+
"@ai-sdk/rsc": "^2.0.57",
|
|
27810
|
+
ai: "^6.0.57",
|
|
27811
|
+
"ts-to-zod": "^5.1.0",
|
|
27812
|
+
zod: "^4.3.6",
|
|
27961
27813
|
"@anthropic-ai/sdk": "^0.71.2",
|
|
27962
27814
|
"@semantic-release/changelog": "^6.0.3",
|
|
27963
27815
|
"@semantic-release/exec": "^7.1.0",
|
|
27964
27816
|
"@semantic-release/git": "^10.0.1",
|
|
27965
27817
|
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
27966
|
-
"@types/better-sqlite3": "^7.6.12",
|
|
27967
27818
|
"@types/bun": "^1.3.6",
|
|
27968
27819
|
"@types/jest": "^30.0.0",
|
|
27969
27820
|
"@types/ms": "^2.1.0",
|
|
@@ -28010,7 +27861,7 @@ var package_default = {
|
|
|
28010
27861
|
// ts/parseCliArgs.ts
|
|
28011
27862
|
function parseCliArgs(argv) {
|
|
28012
27863
|
const cliName = argv[1]?.split(/[/\\]/).at(-1)?.replace(/(\.[jt]s)?$/, "").replace(/^(cli|agent)(-yes$)?/, "").replace(/^ay$/, "").replace(/-yes$/, "") || undefined;
|
|
28013
|
-
const parsedArgv = yargs_default(hideBin(argv)).usage("Usage: $0 [cli] [agent-yes args] [agent-cli args] [--] [prompts...]").example("$0 claude --
|
|
27864
|
+
const parsedArgv = yargs_default(hideBin(argv)).usage("Usage: $0 [cli] [agent-yes args] [agent-cli args] [--] [prompts...]").example("$0 claude --timeout=30s -- solve all todos in my codebase, commit one by one", "Run Claude with a 30 seconds idle timeout (will type /exit when timeout), everything after `--` will be treated as the prompt").example("$0 claude --stdpush", "Run Claude with external stdin input enabled via --append-prompt").option("robust", {
|
|
28014
27865
|
type: "boolean",
|
|
28015
27866
|
default: true,
|
|
28016
27867
|
description: "re-spawn Claude with --continue if it crashes, only works for claude yet",
|
|
@@ -28123,6 +27974,9 @@ function parseCliArgs(argv) {
|
|
|
28123
27974
|
return [];
|
|
28124
27975
|
})();
|
|
28125
27976
|
const dashPrompt = dashIndex === undefined ? undefined : rawArgs.slice(dashIndex + 1).join(" ");
|
|
27977
|
+
if (parsedArgv.exitOnIdle !== undefined) {
|
|
27978
|
+
console.warn("\x1B[33m⚠ Warning: --exit-on-idle and -e are deprecated. Please use --timeout instead.\x1B[0m");
|
|
27979
|
+
}
|
|
28126
27980
|
return {
|
|
28127
27981
|
cwd: process.cwd(),
|
|
28128
27982
|
env: process.env,
|
|
@@ -28130,7 +27984,7 @@ function parseCliArgs(argv) {
|
|
|
28130
27984
|
cliArgs: cliArgsForSpawn,
|
|
28131
27985
|
prompt: [parsedArgv.prompt, dashPrompt].filter(Boolean).join(" ") || undefined,
|
|
28132
27986
|
install: parsedArgv.install,
|
|
28133
|
-
exitOnIdle: Number((parsedArgv.idle || parsedArgv.exitOnIdle)?.replace(/.*/, (e) => String(import_ms.default(e))) || 0),
|
|
27987
|
+
exitOnIdle: Number((parsedArgv.timeout || parsedArgv.idle || parsedArgv.exitOnIdle)?.replace(/.*/, (e) => String(import_ms.default(e))) || 0),
|
|
28134
27988
|
queue: parsedArgv.queue,
|
|
28135
27989
|
robust: parsedArgv.robust,
|
|
28136
27990
|
logFile: parsedArgv.logFile,
|
|
@@ -28138,7 +27992,7 @@ function parseCliArgs(argv) {
|
|
|
28138
27992
|
resume: parsedArgv.continue,
|
|
28139
27993
|
useSkills: parsedArgv.useSkills,
|
|
28140
27994
|
appendPrompt: parsedArgv.appendPrompt,
|
|
28141
|
-
|
|
27995
|
+
useStdinAppend: Boolean(parsedArgv.stdpush || parsedArgv.ipc || parsedArgv.fifo)
|
|
28142
27996
|
};
|
|
28143
27997
|
}
|
|
28144
27998
|
|
|
@@ -28161,83 +28015,51 @@ var logger2 = import_winston3.default.createLogger({
|
|
|
28161
28015
|
|
|
28162
28016
|
// ts/pidStore.ts
|
|
28163
28017
|
init_logger();
|
|
28164
|
-
|
|
28165
|
-
import
|
|
28166
|
-
|
|
28167
|
-
class SqliteAdapter2 {
|
|
28168
|
-
db;
|
|
28169
|
-
async init(dbPath) {
|
|
28170
|
-
if (typeof globalThis.Bun !== "undefined") {
|
|
28171
|
-
try {
|
|
28172
|
-
const { Database } = await import("bun:sqlite");
|
|
28173
|
-
this.db = new Database(dbPath);
|
|
28174
|
-
} catch (error) {
|
|
28175
|
-
logger.warn("[pidStore] bun:sqlite not available, falling back to better-sqlite3");
|
|
28176
|
-
const Database = (await import("better-sqlite3")).default;
|
|
28177
|
-
this.db = new Database(dbPath);
|
|
28178
|
-
}
|
|
28179
|
-
} else {
|
|
28180
|
-
const Database = (await import("better-sqlite3")).default;
|
|
28181
|
-
this.db = new Database(dbPath);
|
|
28182
|
-
}
|
|
28183
|
-
}
|
|
28184
|
-
query(sql, params = []) {
|
|
28185
|
-
if (typeof this.db.prepare === "function") {
|
|
28186
|
-
return this.db.prepare(sql).all(params);
|
|
28187
|
-
} else {
|
|
28188
|
-
return this.db.query(sql).all(params);
|
|
28189
|
-
}
|
|
28190
|
-
}
|
|
28191
|
-
run(sql, params = []) {
|
|
28192
|
-
if (typeof this.db.prepare === "function") {
|
|
28193
|
-
return this.db.prepare(sql).run(params);
|
|
28194
|
-
} else {
|
|
28195
|
-
this.db.run(sql, params);
|
|
28196
|
-
return {};
|
|
28197
|
-
}
|
|
28198
|
-
}
|
|
28199
|
-
close() {
|
|
28200
|
-
if (this.db.close) {
|
|
28201
|
-
this.db.close();
|
|
28202
|
-
}
|
|
28203
|
-
}
|
|
28204
|
-
}
|
|
28018
|
+
init_SqliteAdapter();
|
|
28019
|
+
import { writeFile as writeFile7 } from "fs/promises";
|
|
28020
|
+
import path14 from "path";
|
|
28205
28021
|
|
|
28206
28022
|
class PidStore2 {
|
|
28207
28023
|
db;
|
|
28208
28024
|
storeDir;
|
|
28209
28025
|
dbPath;
|
|
28210
28026
|
constructor(workingDir) {
|
|
28211
|
-
this.storeDir =
|
|
28212
|
-
this.dbPath =
|
|
28027
|
+
this.storeDir = path14.resolve(workingDir, ".agent-yes");
|
|
28028
|
+
this.dbPath = path14.join(this.storeDir, "pid.sqlite");
|
|
28213
28029
|
}
|
|
28214
28030
|
async init() {
|
|
28215
|
-
|
|
28216
|
-
|
|
28217
|
-
|
|
28218
|
-
|
|
28219
|
-
|
|
28220
|
-
|
|
28221
|
-
|
|
28222
|
-
|
|
28223
|
-
|
|
28224
|
-
|
|
28225
|
-
|
|
28226
|
-
|
|
28227
|
-
|
|
28228
|
-
|
|
28229
|
-
|
|
28230
|
-
|
|
28231
|
-
|
|
28232
|
-
|
|
28233
|
-
|
|
28234
|
-
|
|
28235
|
-
|
|
28236
|
-
|
|
28237
|
-
|
|
28238
|
-
|
|
28239
|
-
|
|
28240
|
-
|
|
28031
|
+
try {
|
|
28032
|
+
await this.ensureGitignore();
|
|
28033
|
+
this.db = new SqliteAdapter;
|
|
28034
|
+
await this.db.init(this.dbPath);
|
|
28035
|
+
if (this.db.isReady()) {
|
|
28036
|
+
this.db.run("PRAGMA journal_mode=WAL");
|
|
28037
|
+
this.db.run("PRAGMA synchronous=NORMAL");
|
|
28038
|
+
this.db.run("PRAGMA cache_size=1000");
|
|
28039
|
+
this.db.run("PRAGMA temp_store=memory");
|
|
28040
|
+
this.db.run(`
|
|
28041
|
+
CREATE TABLE IF NOT EXISTS pid_records (
|
|
28042
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
28043
|
+
pid INTEGER NOT NULL UNIQUE,
|
|
28044
|
+
cli TEXT NOT NULL,
|
|
28045
|
+
args TEXT NOT NULL,
|
|
28046
|
+
prompt TEXT,
|
|
28047
|
+
logFile TEXT NOT NULL,
|
|
28048
|
+
fifoFile TEXT NOT NULL,
|
|
28049
|
+
status TEXT NOT NULL DEFAULT 'active',
|
|
28050
|
+
exitReason TEXT NOT NULL DEFAULT '',
|
|
28051
|
+
exitCode INTEGER,
|
|
28052
|
+
startedAt INTEGER NOT NULL,
|
|
28053
|
+
updatedAt INTEGER NOT NULL
|
|
28054
|
+
)
|
|
28055
|
+
`);
|
|
28056
|
+
await this.cleanStaleRecords();
|
|
28057
|
+
} else {
|
|
28058
|
+
logger.warn("[pidStore] Database not ready, running in fallback mode");
|
|
28059
|
+
}
|
|
28060
|
+
} catch (error) {
|
|
28061
|
+
logger.warn("[pidStore] Failed to initialize:", error);
|
|
28062
|
+
}
|
|
28241
28063
|
}
|
|
28242
28064
|
async registerProcess({
|
|
28243
28065
|
pid,
|
|
@@ -28247,7 +28069,7 @@ class PidStore2 {
|
|
|
28247
28069
|
}) {
|
|
28248
28070
|
const now = Date.now();
|
|
28249
28071
|
const argsJson = JSON.stringify(args);
|
|
28250
|
-
const logFile = this.
|
|
28072
|
+
const logFile = path14.resolve(this.getLogDir(), `${pid}.log`);
|
|
28251
28073
|
const fifoFile = this.getFifoPath(pid);
|
|
28252
28074
|
try {
|
|
28253
28075
|
this.db.run(`
|
|
@@ -28285,14 +28107,14 @@ class PidStore2 {
|
|
|
28285
28107
|
}
|
|
28286
28108
|
logger.debug(`[pidStore] Updated process ${pid} status=${status}`);
|
|
28287
28109
|
}
|
|
28288
|
-
|
|
28289
|
-
return
|
|
28110
|
+
getLogDir() {
|
|
28111
|
+
return path14.resolve(this.storeDir, "logs");
|
|
28290
28112
|
}
|
|
28291
28113
|
getFifoPath(pid) {
|
|
28292
28114
|
if (process.platform === "win32") {
|
|
28293
28115
|
return `\\\\.\\pipe\\agent-yes-${pid}`;
|
|
28294
28116
|
} else {
|
|
28295
|
-
return
|
|
28117
|
+
return path14.resolve(this.storeDir, "fifo", `${pid}.stdin`);
|
|
28296
28118
|
}
|
|
28297
28119
|
}
|
|
28298
28120
|
async cleanStaleRecords() {
|
|
@@ -28323,7 +28145,7 @@ class PidStore2 {
|
|
|
28323
28145
|
}
|
|
28324
28146
|
}
|
|
28325
28147
|
async ensureGitignore() {
|
|
28326
|
-
const gitignorePath =
|
|
28148
|
+
const gitignorePath = path14.join(this.storeDir, ".gitignore");
|
|
28327
28149
|
const gitignoreContent = `# Auto-generated .gitignore for agent-yes
|
|
28328
28150
|
# Ignore all log files and runtime data
|
|
28329
28151
|
logs/
|
|
@@ -28349,11 +28171,16 @@ fifo/
|
|
|
28349
28171
|
}
|
|
28350
28172
|
}
|
|
28351
28173
|
static async findActiveFifo(workingDir) {
|
|
28352
|
-
|
|
28353
|
-
|
|
28354
|
-
|
|
28355
|
-
|
|
28356
|
-
|
|
28174
|
+
try {
|
|
28175
|
+
const store = new PidStore2(workingDir);
|
|
28176
|
+
await store.init();
|
|
28177
|
+
const records = store.db.query("SELECT * FROM pid_records WHERE status != 'exited' ORDER BY startedAt DESC LIMIT 1");
|
|
28178
|
+
await store.close();
|
|
28179
|
+
return records[0]?.fifoFile ?? null;
|
|
28180
|
+
} catch (error) {
|
|
28181
|
+
logger.warn("[pidStore] findActiveFifo failed:", error);
|
|
28182
|
+
return null;
|
|
28183
|
+
}
|
|
28357
28184
|
}
|
|
28358
28185
|
}
|
|
28359
28186
|
|
|
@@ -28412,5 +28239,5 @@ var { exitCode } = await cliYes(config3);
|
|
|
28412
28239
|
console.log("exiting process");
|
|
28413
28240
|
process.exit(exitCode ?? 1);
|
|
28414
28241
|
|
|
28415
|
-
//# debugId=
|
|
28242
|
+
//# debugId=5B8D6ED3AB380BB964756E2164756E21
|
|
28416
28243
|
//# sourceMappingURL=cli.js.map
|