agent-yes 1.40.0 → 1.41.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 +281 -448
- package/dist/index.js +191 -322
- package/package.json +9 -4
- package/ts/SqliteAdapter.ts +109 -0
- package/ts/agent.ts +195 -0
- package/ts/index.ts +23 -18
- package/ts/parseCliArgs.ts +9 -6
- 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)) {
|
|
@@ -21289,7 +21167,7 @@ var init_spawner = __esm(async () => {
|
|
|
21289
21167
|
});
|
|
21290
21168
|
|
|
21291
21169
|
// ts/ReadyManager.ts
|
|
21292
|
-
class
|
|
21170
|
+
class ReadyManager {
|
|
21293
21171
|
isReady = false;
|
|
21294
21172
|
readyQueue = [];
|
|
21295
21173
|
wait() {
|
|
@@ -21334,9 +21212,9 @@ class AgentContext {
|
|
|
21334
21212
|
cliConf;
|
|
21335
21213
|
verbose;
|
|
21336
21214
|
robust;
|
|
21337
|
-
stdinReady = new
|
|
21338
|
-
stdinFirstReady = new
|
|
21339
|
-
nextStdout = new
|
|
21215
|
+
stdinReady = new ReadyManager;
|
|
21216
|
+
stdinFirstReady = new ReadyManager;
|
|
21217
|
+
nextStdout = new ReadyManager;
|
|
21340
21218
|
idleWaiter = new IdleWaiter;
|
|
21341
21219
|
isFatal = false;
|
|
21342
21220
|
shouldRestartWithoutContinue = false;
|
|
@@ -21372,7 +21250,7 @@ async function createAutoResponseHandler(line, lineIndex, options) {
|
|
|
21372
21250
|
ctx.stdinFirstReady.ready();
|
|
21373
21251
|
}
|
|
21374
21252
|
if (conf.enter?.some((rx) => line.match(rx))) {
|
|
21375
|
-
logger.debug(`
|
|
21253
|
+
logger.debug(`sendEnter matched|${line}`);
|
|
21376
21254
|
return await sendEnter(ctx.messageContext, 400);
|
|
21377
21255
|
}
|
|
21378
21256
|
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 +21358,14 @@ var exports_agent_yes_config = {};
|
|
|
21480
21358
|
__export(exports_agent_yes_config, {
|
|
21481
21359
|
default: () => agent_yes_config_default
|
|
21482
21360
|
});
|
|
21483
|
-
import { mkdir as
|
|
21361
|
+
import { mkdir as mkdir6 } from "node:fs/promises";
|
|
21484
21362
|
import os from "node:os";
|
|
21485
|
-
import
|
|
21363
|
+
import path12 from "node:path";
|
|
21486
21364
|
function getDefaultConfig() {
|
|
21487
21365
|
return defineCliYesConfig({
|
|
21488
21366
|
configDir,
|
|
21489
|
-
logsDir: configDir &&
|
|
21367
|
+
logsDir: configDir && path12.resolve(configDir, "logs"),
|
|
21490
21368
|
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
21369
|
claude: {
|
|
21501
21370
|
promptArg: "last-arg",
|
|
21502
21371
|
install: {
|
|
@@ -21504,7 +21373,13 @@ function getDefaultConfig() {
|
|
|
21504
21373
|
bash: "curl -fsSL https://claude.ai/install.sh | bash",
|
|
21505
21374
|
npm: "npm i -g @anthropic-ai/claude-code@latest"
|
|
21506
21375
|
},
|
|
21507
|
-
ready: [
|
|
21376
|
+
ready: [
|
|
21377
|
+
/\? for shortcuts/,
|
|
21378
|
+
/\u00A0Try "/,
|
|
21379
|
+
/^\? for shortcuts/,
|
|
21380
|
+
/^> /,
|
|
21381
|
+
/──────────+/
|
|
21382
|
+
],
|
|
21508
21383
|
typingRespond: {
|
|
21509
21384
|
"1\n": [/│ Do you want to use this API key\?/]
|
|
21510
21385
|
},
|
|
@@ -21527,7 +21402,7 @@ function getDefaultConfig() {
|
|
|
21527
21402
|
gemini: {
|
|
21528
21403
|
install: "npm install -g @google/gemini-cli@latest",
|
|
21529
21404
|
ready: [/Type your message/],
|
|
21530
|
-
enter: [/│ ● 1. Yes, allow once/, /│ ● 1. Allow once/],
|
|
21405
|
+
enter: [/│ ● 1. Yes, allow once/, /│ ● 1. Allow once/, /│ ● 1. Allow once/],
|
|
21531
21406
|
fatal: [/Error resuming session/, /No previous sessions found for this project./],
|
|
21532
21407
|
restoreArgs: ["--resume"],
|
|
21533
21408
|
restartWithoutContinueArg: [
|
|
@@ -21553,6 +21428,15 @@ function getDefaultConfig() {
|
|
|
21553
21428
|
defaultArgs: ["--search"],
|
|
21554
21429
|
noEOL: true
|
|
21555
21430
|
},
|
|
21431
|
+
qwen: {
|
|
21432
|
+
install: "npm install -g @qwen-code/qwen-code@latest",
|
|
21433
|
+
version: "qwen --version"
|
|
21434
|
+
},
|
|
21435
|
+
grok: {
|
|
21436
|
+
install: "npm install -g @vibe-kit/grok-cli@latest",
|
|
21437
|
+
ready: [/^ │ ❯ +/],
|
|
21438
|
+
enter: [/^ 1. Yes/]
|
|
21439
|
+
},
|
|
21556
21440
|
copilot: {
|
|
21557
21441
|
promptArg: "-i",
|
|
21558
21442
|
install: "npm install -g @github/copilot",
|
|
@@ -21594,7 +21478,8 @@ function getDefaultConfig() {
|
|
|
21594
21478
|
bash: "curl -fsSL https://opencode.ai/install | bash",
|
|
21595
21479
|
npm: "npm i -g opencode-ai"
|
|
21596
21480
|
},
|
|
21597
|
-
enter: []
|
|
21481
|
+
enter: [],
|
|
21482
|
+
ready: []
|
|
21598
21483
|
}
|
|
21599
21484
|
}
|
|
21600
21485
|
});
|
|
@@ -21604,21 +21489,21 @@ var init_agent_yes_config = __esm(async () => {
|
|
|
21604
21489
|
init_logger();
|
|
21605
21490
|
logger.debug("loading cli-yes.config.ts from " + import.meta.url);
|
|
21606
21491
|
configDir = await (async () => {
|
|
21607
|
-
const homeConfigDir =
|
|
21608
|
-
const isHomeWritable = await
|
|
21492
|
+
const homeConfigDir = path12.resolve(os.homedir(), ".agent-yes");
|
|
21493
|
+
const isHomeWritable = await mkdir6(homeConfigDir, { recursive: true }).then(() => true).catch(() => false);
|
|
21609
21494
|
if (isHomeWritable) {
|
|
21610
21495
|
logger.debug("[config] Using home directory:", homeConfigDir);
|
|
21611
21496
|
return homeConfigDir;
|
|
21612
21497
|
}
|
|
21613
|
-
const tmpConfigDir =
|
|
21614
|
-
const isWritable = await
|
|
21498
|
+
const tmpConfigDir = path12.resolve("/tmp/.agent-yes");
|
|
21499
|
+
const isWritable = await mkdir6(tmpConfigDir, { recursive: true });
|
|
21615
21500
|
if (isWritable) {
|
|
21616
21501
|
logger.debug("[config] Using workspace directory:", tmpConfigDir);
|
|
21617
21502
|
return tmpConfigDir;
|
|
21618
21503
|
}
|
|
21619
21504
|
return;
|
|
21620
21505
|
})();
|
|
21621
|
-
agent_yes_config_default = deepMixin(await getDefaultConfig(), await import(
|
|
21506
|
+
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));
|
|
21622
21507
|
});
|
|
21623
21508
|
|
|
21624
21509
|
// node_modules/emoji-regex/index.js
|
|
@@ -21657,9 +21542,9 @@ __export(exports_ts, {
|
|
|
21657
21542
|
config: () => config2,
|
|
21658
21543
|
CLIS_CONFIG: () => CLIS_CONFIG2
|
|
21659
21544
|
});
|
|
21660
|
-
import { fromReadable as
|
|
21661
|
-
import { mkdir as
|
|
21662
|
-
import
|
|
21545
|
+
import { fromReadable as fromReadable2, fromWritable as fromWritable2 } from "from-node-stream";
|
|
21546
|
+
import { mkdir as mkdir9, readFile as readFile4, writeFile as writeFile8 } from "fs/promises";
|
|
21547
|
+
import path15 from "path";
|
|
21663
21548
|
async function agentYes2({
|
|
21664
21549
|
cli,
|
|
21665
21550
|
cliArgs = [],
|
|
@@ -21742,9 +21627,9 @@ async function agentYes2({
|
|
|
21742
21627
|
} catch {}
|
|
21743
21628
|
const skillHeaders = [];
|
|
21744
21629
|
let currentDir = workingDir2;
|
|
21745
|
-
const searchLimit = gitRoot ||
|
|
21630
|
+
const searchLimit = gitRoot || path15.parse(currentDir).root;
|
|
21746
21631
|
while (true) {
|
|
21747
|
-
const skillPath =
|
|
21632
|
+
const skillPath = path15.resolve(currentDir, "SKILL.md");
|
|
21748
21633
|
const md = await readFile4(skillPath, "utf8").catch(() => null);
|
|
21749
21634
|
if (md) {
|
|
21750
21635
|
const headerMatch = md.match(/^[\s\S]*?(?=\n##\s)/);
|
|
@@ -21757,7 +21642,7 @@ async function agentYes2({
|
|
|
21757
21642
|
}
|
|
21758
21643
|
if (currentDir === searchLimit)
|
|
21759
21644
|
break;
|
|
21760
|
-
const parentDir =
|
|
21645
|
+
const parentDir = path15.dirname(currentDir);
|
|
21761
21646
|
if (parentDir === currentDir)
|
|
21762
21647
|
break;
|
|
21763
21648
|
currentDir = parentDir;
|
|
@@ -21823,7 +21708,7 @@ ${prompt}` : prefix;
|
|
|
21823
21708
|
const ptyEnv = { ...env2 ?? process.env };
|
|
21824
21709
|
const ptyOptions = {
|
|
21825
21710
|
name: "xterm-color",
|
|
21826
|
-
...
|
|
21711
|
+
...getTerminalDimensions(),
|
|
21827
21712
|
cwd: cwd ?? process.cwd(),
|
|
21828
21713
|
env: ptyEnv
|
|
21829
21714
|
};
|
|
@@ -21836,7 +21721,7 @@ ${prompt}` : prefix;
|
|
|
21836
21721
|
ptyOptions
|
|
21837
21722
|
});
|
|
21838
21723
|
await pidStore.registerProcess({ pid: shell.pid, cli, args: cliArgs, prompt });
|
|
21839
|
-
const logPaths = initializeLogPaths(pidStore, shell.pid);
|
|
21724
|
+
const logPaths = await initializeLogPaths(pidStore, shell.pid);
|
|
21840
21725
|
setupDebugLogging(logPaths.debuggingLogsPath);
|
|
21841
21726
|
const ctx = new AgentContext({
|
|
21842
21727
|
shell,
|
|
@@ -21876,7 +21761,7 @@ ${prompt}` : prefix;
|
|
|
21876
21761
|
logger.info(`Restarting ${cli} ${JSON.stringify([bin, ...args])}`);
|
|
21877
21762
|
const restartPtyOptions = {
|
|
21878
21763
|
name: "xterm-color",
|
|
21879
|
-
...
|
|
21764
|
+
...getTerminalDimensions(),
|
|
21880
21765
|
cwd: cwd ?? process.cwd(),
|
|
21881
21766
|
env: ptyEnv
|
|
21882
21767
|
};
|
|
@@ -21915,7 +21800,7 @@ ${prompt}` : prefix;
|
|
|
21915
21800
|
}
|
|
21916
21801
|
const restorePtyOptions = {
|
|
21917
21802
|
name: "xterm-color",
|
|
21918
|
-
...
|
|
21803
|
+
...getTerminalDimensions(),
|
|
21919
21804
|
cwd: cwd ?? process.cwd(),
|
|
21920
21805
|
env: ptyEnv
|
|
21921
21806
|
};
|
|
@@ -21933,7 +21818,7 @@ ${prompt}` : prefix;
|
|
|
21933
21818
|
return pendingExitCode.resolve(exitCode2);
|
|
21934
21819
|
});
|
|
21935
21820
|
process.stdout.on("resize", () => {
|
|
21936
|
-
const { cols, rows } =
|
|
21821
|
+
const { cols, rows } = getTerminalDimensions();
|
|
21937
21822
|
shell.resize(cols, rows);
|
|
21938
21823
|
});
|
|
21939
21824
|
const terminalRender = new TerminalTextRender;
|
|
@@ -21948,27 +21833,12 @@ ${prompt}` : prefix;
|
|
|
21948
21833
|
logger.info("[${cli}-yes] ${cli} is idle, exiting...");
|
|
21949
21834
|
await exitAgent();
|
|
21950
21835
|
});
|
|
21951
|
-
await src_default(
|
|
21836
|
+
await src_default(fromReadable2(process.stdin)).map((buffer2) => buffer2.toString()).forkTo(function handleTerminateSignals(s) {
|
|
21952
21837
|
const handler = createTerminateSignalHandler(ctx.stdinReady, (exitCode2) => {
|
|
21953
21838
|
shell.kill("SIGINT");
|
|
21954
21839
|
pendingExitCode.resolve(exitCode2);
|
|
21955
21840
|
});
|
|
21956
21841
|
return s.map(handler);
|
|
21957
|
-
}).by((s) => {
|
|
21958
|
-
if (!useFifo)
|
|
21959
|
-
return s;
|
|
21960
|
-
const fifoPath = pidStore.getFifoPath(shell.pid);
|
|
21961
|
-
if (!fifoPath)
|
|
21962
|
-
return s;
|
|
21963
|
-
const ipcResult = createFifoStream(cli, fifoPath);
|
|
21964
|
-
if (!ipcResult)
|
|
21965
|
-
return s;
|
|
21966
|
-
pendingExitCode.promise.finally(() => ipcResult.cleanup());
|
|
21967
|
-
process.stderr.write(`
|
|
21968
|
-
Append prompts: ${cli}-yes --append-prompt '...'
|
|
21969
|
-
|
|
21970
|
-
`);
|
|
21971
|
-
return s.merge(ipcResult.stream);
|
|
21972
21842
|
}).onStart(async function promptOnStart() {
|
|
21973
21843
|
logger.debug("Sending prompt message: " + JSON.stringify(prompt));
|
|
21974
21844
|
if (prompt)
|
|
@@ -21989,7 +21859,7 @@ ${prompt}` : prefix;
|
|
|
21989
21859
|
const rawLogPath = ctx.logPaths.rawLogPath;
|
|
21990
21860
|
if (!rawLogPath)
|
|
21991
21861
|
return f.run();
|
|
21992
|
-
return await
|
|
21862
|
+
return await mkdir9(path15.dirname(rawLogPath), { recursive: true }).then(() => {
|
|
21993
21863
|
logger.debug(`[${cli}-yes] raw logs streaming to ${rawLogPath}`);
|
|
21994
21864
|
return f.forEach(async (chars) => {
|
|
21995
21865
|
await writeFile8(rawLogPath, chars, { flag: "a" }).catch(() => null);
|
|
@@ -22028,9 +21898,9 @@ ${prompt}` : prefix;
|
|
|
22028
21898
|
}, 5000))
|
|
22029
21899
|
]);
|
|
22030
21900
|
}
|
|
22031
|
-
function
|
|
21901
|
+
function getTerminalDimensions() {
|
|
22032
21902
|
if (!process.stdout.isTTY)
|
|
22033
|
-
return { cols: 80, rows:
|
|
21903
|
+
return { cols: 80, rows: 24 };
|
|
22034
21904
|
return {
|
|
22035
21905
|
cols: Math.max(20, process.stdout.columns),
|
|
22036
21906
|
rows: process.stdout.rows
|
|
@@ -22049,7 +21919,6 @@ var init_ts = __esm(async () => {
|
|
|
22049
21919
|
init_codexSessionManager();
|
|
22050
21920
|
init_runningLock();
|
|
22051
21921
|
init_logger();
|
|
22052
|
-
init_fifo();
|
|
22053
21922
|
init_pidStore();
|
|
22054
21923
|
init_messaging();
|
|
22055
21924
|
init_logging();
|
|
@@ -22072,7 +21941,6 @@ init_dist5();
|
|
|
22072
21941
|
init_codexSessionManager();
|
|
22073
21942
|
init_runningLock();
|
|
22074
21943
|
init_logger();
|
|
22075
|
-
init_fifo();
|
|
22076
21944
|
init_pidStore();
|
|
22077
21945
|
init_messaging();
|
|
22078
21946
|
init_logging();
|
|
@@ -22083,9 +21951,9 @@ await __promiseAll([
|
|
|
22083
21951
|
init_pty(),
|
|
22084
21952
|
init_spawner()
|
|
22085
21953
|
]);
|
|
22086
|
-
import { fromReadable
|
|
22087
|
-
import { mkdir as
|
|
22088
|
-
import
|
|
21954
|
+
import { fromReadable, fromWritable } from "from-node-stream";
|
|
21955
|
+
import { mkdir as mkdir7, readFile as readFile3, writeFile as writeFile5 } from "fs/promises";
|
|
21956
|
+
import path13 from "path";
|
|
22089
21957
|
var config = await init_agent_yes_config().then(() => exports_agent_yes_config).then((mod) => mod.default || mod);
|
|
22090
21958
|
var CLIS_CONFIG = config.clis;
|
|
22091
21959
|
async function agentYes({
|
|
@@ -22170,9 +22038,9 @@ async function agentYes({
|
|
|
22170
22038
|
} catch {}
|
|
22171
22039
|
const skillHeaders = [];
|
|
22172
22040
|
let currentDir = workingDir2;
|
|
22173
|
-
const searchLimit = gitRoot ||
|
|
22041
|
+
const searchLimit = gitRoot || path13.parse(currentDir).root;
|
|
22174
22042
|
while (true) {
|
|
22175
|
-
const skillPath =
|
|
22043
|
+
const skillPath = path13.resolve(currentDir, "SKILL.md");
|
|
22176
22044
|
const md = await readFile3(skillPath, "utf8").catch(() => null);
|
|
22177
22045
|
if (md) {
|
|
22178
22046
|
const headerMatch = md.match(/^[\s\S]*?(?=\n##\s)/);
|
|
@@ -22185,7 +22053,7 @@ async function agentYes({
|
|
|
22185
22053
|
}
|
|
22186
22054
|
if (currentDir === searchLimit)
|
|
22187
22055
|
break;
|
|
22188
|
-
const parentDir =
|
|
22056
|
+
const parentDir = path13.dirname(currentDir);
|
|
22189
22057
|
if (parentDir === currentDir)
|
|
22190
22058
|
break;
|
|
22191
22059
|
currentDir = parentDir;
|
|
@@ -22251,7 +22119,7 @@ ${prompt}` : prefix;
|
|
|
22251
22119
|
const ptyEnv = { ...env ?? process.env };
|
|
22252
22120
|
const ptyOptions = {
|
|
22253
22121
|
name: "xterm-color",
|
|
22254
|
-
...
|
|
22122
|
+
...getTerminalDimensions(),
|
|
22255
22123
|
cwd: cwd ?? process.cwd(),
|
|
22256
22124
|
env: ptyEnv
|
|
22257
22125
|
};
|
|
@@ -22264,7 +22132,7 @@ ${prompt}` : prefix;
|
|
|
22264
22132
|
ptyOptions
|
|
22265
22133
|
});
|
|
22266
22134
|
await pidStore.registerProcess({ pid: shell.pid, cli, args: cliArgs, prompt });
|
|
22267
|
-
const logPaths = initializeLogPaths(pidStore, shell.pid);
|
|
22135
|
+
const logPaths = await initializeLogPaths(pidStore, shell.pid);
|
|
22268
22136
|
setupDebugLogging(logPaths.debuggingLogsPath);
|
|
22269
22137
|
const ctx = new AgentContext({
|
|
22270
22138
|
shell,
|
|
@@ -22304,7 +22172,7 @@ ${prompt}` : prefix;
|
|
|
22304
22172
|
logger.info(`Restarting ${cli} ${JSON.stringify([bin, ...args])}`);
|
|
22305
22173
|
const restartPtyOptions = {
|
|
22306
22174
|
name: "xterm-color",
|
|
22307
|
-
...
|
|
22175
|
+
...getTerminalDimensions(),
|
|
22308
22176
|
cwd: cwd ?? process.cwd(),
|
|
22309
22177
|
env: ptyEnv
|
|
22310
22178
|
};
|
|
@@ -22343,7 +22211,7 @@ ${prompt}` : prefix;
|
|
|
22343
22211
|
}
|
|
22344
22212
|
const restorePtyOptions = {
|
|
22345
22213
|
name: "xterm-color",
|
|
22346
|
-
...
|
|
22214
|
+
...getTerminalDimensions(),
|
|
22347
22215
|
cwd: cwd ?? process.cwd(),
|
|
22348
22216
|
env: ptyEnv
|
|
22349
22217
|
};
|
|
@@ -22361,7 +22229,7 @@ ${prompt}` : prefix;
|
|
|
22361
22229
|
return pendingExitCode.resolve(exitCode2);
|
|
22362
22230
|
});
|
|
22363
22231
|
process.stdout.on("resize", () => {
|
|
22364
|
-
const { cols, rows } =
|
|
22232
|
+
const { cols, rows } = getTerminalDimensions();
|
|
22365
22233
|
shell.resize(cols, rows);
|
|
22366
22234
|
});
|
|
22367
22235
|
const terminalRender = new TerminalTextRender;
|
|
@@ -22376,27 +22244,12 @@ ${prompt}` : prefix;
|
|
|
22376
22244
|
logger.info("[${cli}-yes] ${cli} is idle, exiting...");
|
|
22377
22245
|
await exitAgent();
|
|
22378
22246
|
});
|
|
22379
|
-
await src_default(
|
|
22247
|
+
await src_default(fromReadable(process.stdin)).map((buffer2) => buffer2.toString()).forkTo(function handleTerminateSignals(s) {
|
|
22380
22248
|
const handler = createTerminateSignalHandler(ctx.stdinReady, (exitCode2) => {
|
|
22381
22249
|
shell.kill("SIGINT");
|
|
22382
22250
|
pendingExitCode.resolve(exitCode2);
|
|
22383
22251
|
});
|
|
22384
22252
|
return s.map(handler);
|
|
22385
|
-
}).by((s) => {
|
|
22386
|
-
if (!useFifo)
|
|
22387
|
-
return s;
|
|
22388
|
-
const fifoPath = pidStore.getFifoPath(shell.pid);
|
|
22389
|
-
if (!fifoPath)
|
|
22390
|
-
return s;
|
|
22391
|
-
const ipcResult = createFifoStream(cli, fifoPath);
|
|
22392
|
-
if (!ipcResult)
|
|
22393
|
-
return s;
|
|
22394
|
-
pendingExitCode.promise.finally(() => ipcResult.cleanup());
|
|
22395
|
-
process.stderr.write(`
|
|
22396
|
-
Append prompts: ${cli}-yes --append-prompt '...'
|
|
22397
|
-
|
|
22398
|
-
`);
|
|
22399
|
-
return s.merge(ipcResult.stream);
|
|
22400
22253
|
}).onStart(async function promptOnStart() {
|
|
22401
22254
|
logger.debug("Sending prompt message: " + JSON.stringify(prompt));
|
|
22402
22255
|
if (prompt)
|
|
@@ -22417,7 +22270,7 @@ ${prompt}` : prefix;
|
|
|
22417
22270
|
const rawLogPath = ctx.logPaths.rawLogPath;
|
|
22418
22271
|
if (!rawLogPath)
|
|
22419
22272
|
return f.run();
|
|
22420
|
-
return await
|
|
22273
|
+
return await mkdir7(path13.dirname(rawLogPath), { recursive: true }).then(() => {
|
|
22421
22274
|
logger.debug(`[${cli}-yes] raw logs streaming to ${rawLogPath}`);
|
|
22422
22275
|
return f.forEach(async (chars) => {
|
|
22423
22276
|
await writeFile5(rawLogPath, chars, { flag: "a" }).catch(() => null);
|
|
@@ -22456,9 +22309,9 @@ ${prompt}` : prefix;
|
|
|
22456
22309
|
}, 5000))
|
|
22457
22310
|
]);
|
|
22458
22311
|
}
|
|
22459
|
-
function
|
|
22312
|
+
function getTerminalDimensions() {
|
|
22460
22313
|
if (!process.stdout.isTTY)
|
|
22461
|
-
return { cols: 80, rows:
|
|
22314
|
+
return { cols: 80, rows: 24 };
|
|
22462
22315
|
return {
|
|
22463
22316
|
cols: Math.max(20, process.stdout.columns),
|
|
22464
22317
|
rows: process.stdout.rows
|
|
@@ -23228,19 +23081,19 @@ function ui(opts) {
|
|
|
23228
23081
|
}
|
|
23229
23082
|
|
|
23230
23083
|
// node_modules/escalade/sync/index.mjs
|
|
23231
|
-
import { dirname as
|
|
23084
|
+
import { dirname as dirname2, resolve } from "path";
|
|
23232
23085
|
import { readdirSync, statSync as statSync2 } from "fs";
|
|
23233
23086
|
function sync_default(start, callback) {
|
|
23234
23087
|
let dir = resolve(".", start);
|
|
23235
23088
|
let tmp, stats = statSync2(dir);
|
|
23236
23089
|
if (!stats.isDirectory()) {
|
|
23237
|
-
dir =
|
|
23090
|
+
dir = dirname2(dir);
|
|
23238
23091
|
}
|
|
23239
23092
|
while (true) {
|
|
23240
23093
|
tmp = callback(dir, readdirSync(dir));
|
|
23241
23094
|
if (tmp)
|
|
23242
23095
|
return resolve(dir, tmp);
|
|
23243
|
-
dir =
|
|
23096
|
+
dir = dirname2(tmp = dir);
|
|
23244
23097
|
if (tmp === dir)
|
|
23245
23098
|
break;
|
|
23246
23099
|
}
|
|
@@ -24211,11 +24064,11 @@ var parser = new YargsParser({
|
|
|
24211
24064
|
format: format2,
|
|
24212
24065
|
normalize,
|
|
24213
24066
|
resolve: resolve2,
|
|
24214
|
-
require: (
|
|
24067
|
+
require: (path14) => {
|
|
24215
24068
|
if (typeof require2 !== "undefined") {
|
|
24216
|
-
return require2(
|
|
24217
|
-
} else if (
|
|
24218
|
-
return JSON.parse(readFileSync3(
|
|
24069
|
+
return require2(path14);
|
|
24070
|
+
} else if (path14.match(/\.json$/)) {
|
|
24071
|
+
return JSON.parse(readFileSync3(path14, "utf8"));
|
|
24219
24072
|
} else {
|
|
24220
24073
|
throw Error("only .json config files are supported in ESM");
|
|
24221
24074
|
}
|
|
@@ -24234,7 +24087,7 @@ yargsParser.looksLikeNumber = looksLikeNumber;
|
|
|
24234
24087
|
var lib_default = yargsParser;
|
|
24235
24088
|
|
|
24236
24089
|
// node_modules/yargs/lib/platform-shims/esm.mjs
|
|
24237
|
-
import { basename, dirname as
|
|
24090
|
+
import { basename, dirname as dirname3, extname, relative, resolve as resolve4, join as join3 } from "path";
|
|
24238
24091
|
|
|
24239
24092
|
// node_modules/yargs/build/lib/utils/process-argv.js
|
|
24240
24093
|
function getProcessArgvBinIndex() {
|
|
@@ -24512,7 +24365,7 @@ var esm_default = {
|
|
|
24512
24365
|
Parser: lib_default,
|
|
24513
24366
|
path: {
|
|
24514
24367
|
basename,
|
|
24515
|
-
dirname:
|
|
24368
|
+
dirname: dirname3,
|
|
24516
24369
|
extname,
|
|
24517
24370
|
relative,
|
|
24518
24371
|
resolve: resolve4,
|
|
@@ -27933,7 +27786,7 @@ var package_default = {
|
|
|
27933
27786
|
registry: "https://registry.npmjs.org/"
|
|
27934
27787
|
},
|
|
27935
27788
|
scripts: {
|
|
27936
|
-
build: "bun build ./ts/cli.ts ./ts/index.ts --outdir=dist --target=node --sourcemap --external
|
|
27789
|
+
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",
|
|
27937
27790
|
postbuild: "bun ./ts/postbuild.ts",
|
|
27938
27791
|
demo: "bun run build && bun link && claude-yes -- demo",
|
|
27939
27792
|
dev: "bun ts/index.ts",
|
|
@@ -27947,17 +27800,22 @@ var package_default = {
|
|
|
27947
27800
|
},
|
|
27948
27801
|
dependencies: {
|
|
27949
27802
|
"@snomiao/bun-pty": "^0.3.4",
|
|
27950
|
-
"better-sqlite3": "^12.1.0",
|
|
27951
27803
|
"bun-pty": "^0.4.8",
|
|
27952
27804
|
"from-node-stream": "^0.1.2"
|
|
27953
27805
|
},
|
|
27954
27806
|
devDependencies: {
|
|
27807
|
+
"@ai-sdk/anthropic": "^3.0.28",
|
|
27808
|
+
"@ai-sdk/openai": "^3.0.21",
|
|
27809
|
+
prettier: "^3.8.1",
|
|
27810
|
+
"@ai-sdk/rsc": "^2.0.57",
|
|
27811
|
+
ai: "^6.0.57",
|
|
27812
|
+
"ts-to-zod": "^5.1.0",
|
|
27813
|
+
zod: "^4.3.6",
|
|
27955
27814
|
"@anthropic-ai/sdk": "^0.71.2",
|
|
27956
27815
|
"@semantic-release/changelog": "^6.0.3",
|
|
27957
27816
|
"@semantic-release/exec": "^7.1.0",
|
|
27958
27817
|
"@semantic-release/git": "^10.0.1",
|
|
27959
27818
|
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
27960
|
-
"@types/better-sqlite3": "^7.6.12",
|
|
27961
27819
|
"@types/bun": "^1.3.6",
|
|
27962
27820
|
"@types/jest": "^30.0.0",
|
|
27963
27821
|
"@types/ms": "^2.1.0",
|
|
@@ -28024,11 +27882,13 @@ function parseCliArgs(argv) {
|
|
|
28024
27882
|
type: "boolean",
|
|
28025
27883
|
description: "Prepend SKILL.md header from current directory to the prompt (helpful for non-Claude agents)",
|
|
28026
27884
|
default: false
|
|
28027
|
-
}).option("
|
|
27885
|
+
}).option("timeout", {
|
|
28028
27886
|
type: "string",
|
|
28029
27887
|
description: 'Exit after a period of inactivity, e.g., "5s" or "1m"',
|
|
28030
|
-
|
|
28031
|
-
|
|
27888
|
+
alias: "t"
|
|
27889
|
+
}).option("exit-on-idle", {
|
|
27890
|
+
type: "string",
|
|
27891
|
+
deprecated: "use --timeout instead",
|
|
28032
27892
|
alias: "e"
|
|
28033
27893
|
}).option("idle", {
|
|
28034
27894
|
type: "string",
|
|
@@ -28036,7 +27896,7 @@ function parseCliArgs(argv) {
|
|
|
28036
27896
|
alias: "i"
|
|
28037
27897
|
}).option("idle-action", {
|
|
28038
27898
|
type: "string",
|
|
28039
|
-
description: 'Idle action to perform when idle time is reached, e.g., "exit" or "TODO.md"'
|
|
27899
|
+
description: 'Idle action to perform when idle time is reached, e.g., "/exit" or "check TODO.md"'
|
|
28040
27900
|
}).option("queue", {
|
|
28041
27901
|
type: "boolean",
|
|
28042
27902
|
description: "Queue Agent Commands when spawning multiple agents in the same directory/repo, can be disabled with --no-queue",
|
|
@@ -28153,83 +28013,51 @@ var logger2 = import_winston3.default.createLogger({
|
|
|
28153
28013
|
|
|
28154
28014
|
// ts/pidStore.ts
|
|
28155
28015
|
init_logger();
|
|
28156
|
-
|
|
28157
|
-
import
|
|
28158
|
-
|
|
28159
|
-
class SqliteAdapter2 {
|
|
28160
|
-
db;
|
|
28161
|
-
async init(dbPath) {
|
|
28162
|
-
if (typeof globalThis.Bun !== "undefined") {
|
|
28163
|
-
try {
|
|
28164
|
-
const { Database } = await import("bun:sqlite");
|
|
28165
|
-
this.db = new Database(dbPath);
|
|
28166
|
-
} catch (error) {
|
|
28167
|
-
logger.warn("[pidStore] bun:sqlite not available, falling back to better-sqlite3");
|
|
28168
|
-
const Database = (await import("better-sqlite3")).default;
|
|
28169
|
-
this.db = new Database(dbPath);
|
|
28170
|
-
}
|
|
28171
|
-
} else {
|
|
28172
|
-
const Database = (await import("better-sqlite3")).default;
|
|
28173
|
-
this.db = new Database(dbPath);
|
|
28174
|
-
}
|
|
28175
|
-
}
|
|
28176
|
-
query(sql, params = []) {
|
|
28177
|
-
if (typeof this.db.prepare === "function") {
|
|
28178
|
-
return this.db.prepare(sql).all(params);
|
|
28179
|
-
} else {
|
|
28180
|
-
return this.db.query(sql).all(params);
|
|
28181
|
-
}
|
|
28182
|
-
}
|
|
28183
|
-
run(sql, params = []) {
|
|
28184
|
-
if (typeof this.db.prepare === "function") {
|
|
28185
|
-
return this.db.prepare(sql).run(params);
|
|
28186
|
-
} else {
|
|
28187
|
-
this.db.run(sql, params);
|
|
28188
|
-
return {};
|
|
28189
|
-
}
|
|
28190
|
-
}
|
|
28191
|
-
close() {
|
|
28192
|
-
if (this.db.close) {
|
|
28193
|
-
this.db.close();
|
|
28194
|
-
}
|
|
28195
|
-
}
|
|
28196
|
-
}
|
|
28016
|
+
init_SqliteAdapter();
|
|
28017
|
+
import { writeFile as writeFile7 } from "fs/promises";
|
|
28018
|
+
import path14 from "path";
|
|
28197
28019
|
|
|
28198
28020
|
class PidStore2 {
|
|
28199
28021
|
db;
|
|
28200
28022
|
storeDir;
|
|
28201
28023
|
dbPath;
|
|
28202
28024
|
constructor(workingDir) {
|
|
28203
|
-
this.storeDir =
|
|
28204
|
-
this.dbPath =
|
|
28025
|
+
this.storeDir = path14.resolve(workingDir, ".agent-yes");
|
|
28026
|
+
this.dbPath = path14.join(this.storeDir, "pid.sqlite");
|
|
28205
28027
|
}
|
|
28206
28028
|
async init() {
|
|
28207
|
-
|
|
28208
|
-
|
|
28209
|
-
|
|
28210
|
-
|
|
28211
|
-
|
|
28212
|
-
|
|
28213
|
-
|
|
28214
|
-
|
|
28215
|
-
|
|
28216
|
-
|
|
28217
|
-
|
|
28218
|
-
|
|
28219
|
-
|
|
28220
|
-
|
|
28221
|
-
|
|
28222
|
-
|
|
28223
|
-
|
|
28224
|
-
|
|
28225
|
-
|
|
28226
|
-
|
|
28227
|
-
|
|
28228
|
-
|
|
28229
|
-
|
|
28230
|
-
|
|
28231
|
-
|
|
28232
|
-
|
|
28029
|
+
try {
|
|
28030
|
+
await this.ensureGitignore();
|
|
28031
|
+
this.db = new SqliteAdapter;
|
|
28032
|
+
await this.db.init(this.dbPath);
|
|
28033
|
+
if (this.db.isReady()) {
|
|
28034
|
+
this.db.run("PRAGMA journal_mode=WAL");
|
|
28035
|
+
this.db.run("PRAGMA synchronous=NORMAL");
|
|
28036
|
+
this.db.run("PRAGMA cache_size=1000");
|
|
28037
|
+
this.db.run("PRAGMA temp_store=memory");
|
|
28038
|
+
this.db.run(`
|
|
28039
|
+
CREATE TABLE IF NOT EXISTS pid_records (
|
|
28040
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
28041
|
+
pid INTEGER NOT NULL UNIQUE,
|
|
28042
|
+
cli TEXT NOT NULL,
|
|
28043
|
+
args TEXT NOT NULL,
|
|
28044
|
+
prompt TEXT,
|
|
28045
|
+
logFile TEXT NOT NULL,
|
|
28046
|
+
fifoFile TEXT NOT NULL,
|
|
28047
|
+
status TEXT NOT NULL DEFAULT 'active',
|
|
28048
|
+
exitReason TEXT NOT NULL DEFAULT '',
|
|
28049
|
+
exitCode INTEGER,
|
|
28050
|
+
startedAt INTEGER NOT NULL,
|
|
28051
|
+
updatedAt INTEGER NOT NULL
|
|
28052
|
+
)
|
|
28053
|
+
`);
|
|
28054
|
+
await this.cleanStaleRecords();
|
|
28055
|
+
} else {
|
|
28056
|
+
logger.warn("[pidStore] Database not ready, running in fallback mode");
|
|
28057
|
+
}
|
|
28058
|
+
} catch (error) {
|
|
28059
|
+
logger.warn("[pidStore] Failed to initialize:", error);
|
|
28060
|
+
}
|
|
28233
28061
|
}
|
|
28234
28062
|
async registerProcess({
|
|
28235
28063
|
pid,
|
|
@@ -28239,7 +28067,7 @@ class PidStore2 {
|
|
|
28239
28067
|
}) {
|
|
28240
28068
|
const now = Date.now();
|
|
28241
28069
|
const argsJson = JSON.stringify(args);
|
|
28242
|
-
const logFile = this.
|
|
28070
|
+
const logFile = path14.resolve(this.getLogDir(), `${pid}.log`);
|
|
28243
28071
|
const fifoFile = this.getFifoPath(pid);
|
|
28244
28072
|
try {
|
|
28245
28073
|
this.db.run(`
|
|
@@ -28277,14 +28105,14 @@ class PidStore2 {
|
|
|
28277
28105
|
}
|
|
28278
28106
|
logger.debug(`[pidStore] Updated process ${pid} status=${status}`);
|
|
28279
28107
|
}
|
|
28280
|
-
|
|
28281
|
-
return
|
|
28108
|
+
getLogDir() {
|
|
28109
|
+
return path14.resolve(this.storeDir, "logs");
|
|
28282
28110
|
}
|
|
28283
28111
|
getFifoPath(pid) {
|
|
28284
28112
|
if (process.platform === "win32") {
|
|
28285
28113
|
return `\\\\.\\pipe\\agent-yes-${pid}`;
|
|
28286
28114
|
} else {
|
|
28287
|
-
return
|
|
28115
|
+
return path14.resolve(this.storeDir, "fifo", `${pid}.stdin`);
|
|
28288
28116
|
}
|
|
28289
28117
|
}
|
|
28290
28118
|
async cleanStaleRecords() {
|
|
@@ -28315,7 +28143,7 @@ class PidStore2 {
|
|
|
28315
28143
|
}
|
|
28316
28144
|
}
|
|
28317
28145
|
async ensureGitignore() {
|
|
28318
|
-
const gitignorePath =
|
|
28146
|
+
const gitignorePath = path14.join(this.storeDir, ".gitignore");
|
|
28319
28147
|
const gitignoreContent = `# Auto-generated .gitignore for agent-yes
|
|
28320
28148
|
# Ignore all log files and runtime data
|
|
28321
28149
|
logs/
|
|
@@ -28341,11 +28169,16 @@ fifo/
|
|
|
28341
28169
|
}
|
|
28342
28170
|
}
|
|
28343
28171
|
static async findActiveFifo(workingDir) {
|
|
28344
|
-
|
|
28345
|
-
|
|
28346
|
-
|
|
28347
|
-
|
|
28348
|
-
|
|
28172
|
+
try {
|
|
28173
|
+
const store = new PidStore2(workingDir);
|
|
28174
|
+
await store.init();
|
|
28175
|
+
const records = store.db.query("SELECT * FROM pid_records WHERE status != 'exited' ORDER BY startedAt DESC LIMIT 1");
|
|
28176
|
+
await store.close();
|
|
28177
|
+
return records[0]?.fifoFile ?? null;
|
|
28178
|
+
} catch (error) {
|
|
28179
|
+
logger.warn("[pidStore] findActiveFifo failed:", error);
|
|
28180
|
+
return null;
|
|
28181
|
+
}
|
|
28349
28182
|
}
|
|
28350
28183
|
}
|
|
28351
28184
|
|
|
@@ -28404,5 +28237,5 @@ var { exitCode } = await cliYes(config3);
|
|
|
28404
28237
|
console.log("exiting process");
|
|
28405
28238
|
process.exit(exitCode ?? 1);
|
|
28406
28239
|
|
|
28407
|
-
//# debugId=
|
|
28240
|
+
//# debugId=20D3748E8769545964756E2164756E21
|
|
28408
28241
|
//# sourceMappingURL=cli.js.map
|