agent-yes 1.60.5 → 1.60.7
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/{SUPPORTED_CLIS-Dn3ATPWW.js → SUPPORTED_CLIS-gNHv7RnK.js} +55 -56
- package/dist/{agent-yes.config-B-sre0vp.js → agent-yes.config-DcxG25Gv.js} +4 -4
- package/dist/cli.js +5 -6
- package/dist/index.js +2 -2
- package/dist/{logger-CY9ormLF.js → logger-CX77vJDA.js} +1 -1
- package/package.json +3 -3
- package/ts/JsonlStore.ts +25 -28
- package/ts/cli.ts +0 -3
- package/ts/index.ts +8 -7
- package/ts/parseCliArgs.ts +0 -1
- package/ts/rustBinary.ts +3 -3
- package/dist/agent-yes.config-XmUcKFde.js +0 -4
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { t as logger } from "./logger-
|
|
1
|
+
import { t as logger } from "./logger-CX77vJDA.js";
|
|
2
2
|
import { arch, platform } from "process";
|
|
3
3
|
import { execSync } from "child_process";
|
|
4
|
-
import { closeSync, existsSync, fsyncSync, mkdirSync, openSync } from "fs";
|
|
5
|
-
import path, { dirname, join } from "path";
|
|
6
|
-
import { readFile } from "node:fs/promises";
|
|
7
|
-
import os from "node:os";
|
|
8
|
-
import path$1 from "node:path";
|
|
9
|
-
import winston from "winston";
|
|
10
4
|
import { execaCommandSync, parseCommandString } from "execa";
|
|
11
5
|
import { fromWritable } from "from-node-stream";
|
|
12
|
-
import { appendFile, mkdir
|
|
6
|
+
import { appendFile, mkdir, readFile, readdir, rename, writeFile } from "fs/promises";
|
|
7
|
+
import path, { dirname, join } from "path";
|
|
13
8
|
import DIE from "phpdie";
|
|
14
9
|
import sflow from "sflow";
|
|
15
10
|
import { TerminalRenderStream } from "terminal-render";
|
|
16
11
|
import { homedir } from "os";
|
|
12
|
+
import winston from "winston";
|
|
13
|
+
import { closeSync, existsSync, fsyncSync, openSync } from "fs";
|
|
17
14
|
import { lock } from "proper-lockfile";
|
|
18
15
|
import { execSync as execSync$1 } from "node:child_process";
|
|
19
16
|
import { fileURLToPath } from "url";
|
|
17
|
+
import os from "node:os";
|
|
18
|
+
import { readFile as readFile$1 } from "node:fs/promises";
|
|
19
|
+
import path$1 from "node:path";
|
|
20
20
|
|
|
21
21
|
//#region \0rolldown/runtime.js
|
|
22
22
|
var __defProp = Object.defineProperty;
|
|
@@ -44,7 +44,7 @@ const getCodexSessionsDir = () => process.env.CLI_YES_TEST_HOME ? path.join(proc
|
|
|
44
44
|
*/
|
|
45
45
|
async function loadSessionMap() {
|
|
46
46
|
try {
|
|
47
|
-
const content = await readFile
|
|
47
|
+
const content = await readFile(getSessionsFile(), "utf-8");
|
|
48
48
|
return JSON.parse(content);
|
|
49
49
|
} catch {
|
|
50
50
|
return {};
|
|
@@ -56,8 +56,8 @@ async function loadSessionMap() {
|
|
|
56
56
|
async function saveSessionMap(sessionMap) {
|
|
57
57
|
try {
|
|
58
58
|
const sessionsFile = getSessionsFile();
|
|
59
|
-
await mkdir
|
|
60
|
-
await writeFile
|
|
59
|
+
await mkdir(path.dirname(sessionsFile), { recursive: true });
|
|
60
|
+
await writeFile(sessionsFile, JSON.stringify(sessionMap, null, 2));
|
|
61
61
|
} catch (error) {
|
|
62
62
|
console.warn("Failed to save codex session map:", error);
|
|
63
63
|
}
|
|
@@ -78,7 +78,7 @@ async function storeSessionForCwd(cwd, sessionId) {
|
|
|
78
78
|
*/
|
|
79
79
|
async function parseCodexSessionFile(filePath) {
|
|
80
80
|
try {
|
|
81
|
-
const lines = (await readFile
|
|
81
|
+
const lines = (await readFile(filePath, "utf-8")).trim().split("\n");
|
|
82
82
|
for (const line of lines) {
|
|
83
83
|
if (!line.trim()) continue;
|
|
84
84
|
const data = JSON.parse(line);
|
|
@@ -252,9 +252,9 @@ async function readLockFile() {
|
|
|
252
252
|
try {
|
|
253
253
|
const lockDir = getLockDir();
|
|
254
254
|
const lockFilePath = getLockFile();
|
|
255
|
-
await mkdir
|
|
255
|
+
await mkdir(lockDir, { recursive: true });
|
|
256
256
|
if (!existsSync(lockFilePath)) return { tasks: [] };
|
|
257
|
-
const content = await readFile
|
|
257
|
+
const content = await readFile(lockFilePath, "utf8");
|
|
258
258
|
const lockFile = JSON.parse(content);
|
|
259
259
|
lockFile.tasks = lockFile.tasks.filter((task) => {
|
|
260
260
|
if (isProcessRunning(task.pid)) return true;
|
|
@@ -272,9 +272,9 @@ async function writeLockFile(lockFile, retryCount = 0) {
|
|
|
272
272
|
try {
|
|
273
273
|
const lockDir = getLockDir();
|
|
274
274
|
const lockFilePath = getLockFile();
|
|
275
|
-
await mkdir
|
|
275
|
+
await mkdir(lockDir, { recursive: true });
|
|
276
276
|
const tempFile = `${lockFilePath}.tmp.${process.pid}`;
|
|
277
|
-
await writeFile
|
|
277
|
+
await writeFile(tempFile, JSON.stringify(lockFile, null, 2), "utf8");
|
|
278
278
|
await rename(tempFile, lockFilePath);
|
|
279
279
|
} catch (error) {
|
|
280
280
|
if (retryCount < MAX_RETRIES) {
|
|
@@ -437,19 +437,17 @@ function shouldUseLock(_cwd) {
|
|
|
437
437
|
var JsonlStore = class {
|
|
438
438
|
filePath;
|
|
439
439
|
tempPath;
|
|
440
|
-
lockPath;
|
|
441
440
|
docs = /* @__PURE__ */ new Map();
|
|
442
441
|
constructor(filePath) {
|
|
443
442
|
this.filePath = filePath;
|
|
444
443
|
this.tempPath = filePath + "~";
|
|
445
|
-
this.lockPath = path.dirname(filePath);
|
|
446
444
|
}
|
|
447
445
|
/**
|
|
448
446
|
* Load all records from the JSONL file. No lock needed.
|
|
449
447
|
* Handles crash recovery: partial last line skipped, temp file recovery.
|
|
450
448
|
*/
|
|
451
449
|
async load() {
|
|
452
|
-
await mkdir
|
|
450
|
+
await mkdir(path.dirname(this.filePath), { recursive: true });
|
|
453
451
|
if (!existsSync(this.filePath) && existsSync(this.tempPath)) {
|
|
454
452
|
logger.debug("[JsonlStore] Recovering from temp file");
|
|
455
453
|
await rename(this.tempPath, this.filePath);
|
|
@@ -457,7 +455,7 @@ var JsonlStore = class {
|
|
|
457
455
|
this.docs = /* @__PURE__ */ new Map();
|
|
458
456
|
let raw = "";
|
|
459
457
|
try {
|
|
460
|
-
raw = await readFile
|
|
458
|
+
raw = await readFile(this.filePath, "utf-8");
|
|
461
459
|
} catch (err) {
|
|
462
460
|
if (err.code === "ENOENT") return this.docs;
|
|
463
461
|
throw err;
|
|
@@ -560,24 +558,25 @@ var JsonlStore = class {
|
|
|
560
558
|
* Acquires lock.
|
|
561
559
|
*/
|
|
562
560
|
async compact() {
|
|
563
|
-
|
|
564
|
-
const
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
await
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
await
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
|
|
561
|
+
const lines = Array.from(this.docs.values()).map((doc) => {
|
|
562
|
+
const { _id, $$deleted: _$$deleted, ...rest } = doc;
|
|
563
|
+
return JSON.stringify({
|
|
564
|
+
_id,
|
|
565
|
+
...rest
|
|
566
|
+
});
|
|
567
|
+
}).join("\n");
|
|
568
|
+
const content = lines ? lines + "\n" : "";
|
|
569
|
+
try {
|
|
570
|
+
await this.withLock(async () => {
|
|
571
|
+
await writeFile(this.tempPath, content);
|
|
572
|
+
const fd = openSync(this.tempPath, "r");
|
|
573
|
+
fsyncSync(fd);
|
|
574
|
+
closeSync(fd);
|
|
575
|
+
await rename(this.tempPath, this.filePath);
|
|
576
|
+
});
|
|
577
|
+
} catch {
|
|
578
|
+
await writeFile(this.filePath, content);
|
|
579
|
+
}
|
|
581
580
|
}
|
|
582
581
|
async withLock(fn) {
|
|
583
582
|
const dir = path.dirname(this.filePath);
|
|
@@ -713,8 +712,8 @@ pid-db/
|
|
|
713
712
|
|
|
714
713
|
`;
|
|
715
714
|
try {
|
|
716
|
-
await mkdir
|
|
717
|
-
await writeFile
|
|
715
|
+
await mkdir(this.storeDir, { recursive: true });
|
|
716
|
+
await writeFile(gitignorePath, gitignoreContent, { flag: "wx" });
|
|
718
717
|
logger.debug(`[pidStore] Created .gitignore in ${this.storeDir}`);
|
|
719
718
|
} catch (error) {
|
|
720
719
|
if (error.code !== "EEXIST") logger.warn(`[pidStore] Failed to create .gitignore:`, error);
|
|
@@ -836,7 +835,7 @@ async function sendMessage(context, message, { waitForReady = true } = {}) {
|
|
|
836
835
|
*/
|
|
837
836
|
async function initializeLogPaths(pidStore, pid) {
|
|
838
837
|
const logDir = pidStore.getLogDir();
|
|
839
|
-
await mkdir
|
|
838
|
+
await mkdir(logDir, { recursive: true });
|
|
840
839
|
return {
|
|
841
840
|
logPath: logDir,
|
|
842
841
|
rawLogPath: path.resolve(path.dirname(logDir), `${pid}.raw.log`),
|
|
@@ -861,8 +860,8 @@ function setupDebugLogging(debuggingLogsPath) {
|
|
|
861
860
|
*/
|
|
862
861
|
async function saveLogFile(logPath, content) {
|
|
863
862
|
if (!logPath) return;
|
|
864
|
-
await mkdir
|
|
865
|
-
await writeFile
|
|
863
|
+
await mkdir(path.dirname(logPath), { recursive: true }).catch(() => null);
|
|
864
|
+
await writeFile(logPath, content).catch(() => null);
|
|
866
865
|
logger.info(`Full logs saved to ${logPath}`);
|
|
867
866
|
}
|
|
868
867
|
/**
|
|
@@ -875,8 +874,8 @@ async function saveDeprecatedLogFile(logFile, content, verbose) {
|
|
|
875
874
|
if (!logFile) return;
|
|
876
875
|
if (verbose) logger.info(`Writing rendered logs to ${logFile}`);
|
|
877
876
|
const logFilePath = path.resolve(logFile);
|
|
878
|
-
await mkdir
|
|
879
|
-
await writeFile
|
|
877
|
+
await mkdir(path.dirname(logFilePath), { recursive: true }).catch(() => null);
|
|
878
|
+
await writeFile(logFilePath, content);
|
|
880
879
|
}
|
|
881
880
|
|
|
882
881
|
//#endregion
|
|
@@ -905,7 +904,7 @@ function tryCatch(catchFn, fn) {
|
|
|
905
904
|
//#endregion
|
|
906
905
|
//#region package.json
|
|
907
906
|
var name = "agent-yes";
|
|
908
|
-
var version = "1.60.
|
|
907
|
+
var version = "1.60.7";
|
|
909
908
|
|
|
910
909
|
//#endregion
|
|
911
910
|
//#region ts/pty-fix.ts
|
|
@@ -1070,7 +1069,7 @@ function isCommandNotFoundError(e) {
|
|
|
1070
1069
|
* ```
|
|
1071
1070
|
*/
|
|
1072
1071
|
function spawnAgent(options) {
|
|
1073
|
-
const { cli, cliConf, cliArgs, verbose, install, ptyOptions } = options;
|
|
1072
|
+
const { cli, cliConf, cliArgs, verbose: _verbose, install, ptyOptions } = options;
|
|
1074
1073
|
const spawn = () => {
|
|
1075
1074
|
let [bin, ...args] = [...parseCommandString(cliConf?.binary || cli), ...cliArgs];
|
|
1076
1075
|
logger.debug(`Spawning ${bin} with args: ${JSON.stringify(args)}`);
|
|
@@ -1078,7 +1077,7 @@ function spawnAgent(options) {
|
|
|
1078
1077
|
logger.info(`[${cli}-yes] Spawned ${bin} with PID ${spawned.pid} (agent-yes v${version})`);
|
|
1079
1078
|
return spawned;
|
|
1080
1079
|
};
|
|
1081
|
-
return tryCatch((error,
|
|
1080
|
+
return tryCatch((error, _attempts, spawn, ...args) => {
|
|
1082
1081
|
logger.error(`Fatal: Failed to start ${cli}.`);
|
|
1083
1082
|
const isNotFound = isCommandNotFoundError(error);
|
|
1084
1083
|
if (cliConf?.install && isNotFound) {
|
|
@@ -1292,7 +1291,7 @@ async function loadInstallEnv() {
|
|
|
1292
1291
|
if (_installEnv) return _installEnv;
|
|
1293
1292
|
const envPath = path$1.join(installDir, ".env");
|
|
1294
1293
|
try {
|
|
1295
|
-
_installEnv = parseEnvContent(await readFile(envPath, "utf-8"));
|
|
1294
|
+
_installEnv = parseEnvContent(await readFile$1(envPath, "utf-8"));
|
|
1296
1295
|
} catch {
|
|
1297
1296
|
_installEnv = {};
|
|
1298
1297
|
}
|
|
@@ -1331,7 +1330,7 @@ async function notifyWebhook(status, details, cwd = process.cwd()) {
|
|
|
1331
1330
|
|
|
1332
1331
|
//#endregion
|
|
1333
1332
|
//#region ts/index.ts
|
|
1334
|
-
const config = await import("./agent-yes.config-
|
|
1333
|
+
const config = await import("./agent-yes.config-DcxG25Gv.js").then((mod) => mod.default || mod);
|
|
1335
1334
|
const CLIS_CONFIG = config.clis;
|
|
1336
1335
|
/**
|
|
1337
1336
|
* Main function to run agent-cli with automatic yes/no responses
|
|
@@ -1361,7 +1360,7 @@ const CLIS_CONFIG = config.clis;
|
|
|
1361
1360
|
* });
|
|
1362
1361
|
* ```
|
|
1363
1362
|
*/
|
|
1364
|
-
async function agentYes({ cli, cliArgs = [], prompt, robust = true, cwd, env, exitOnIdle, logFile, removeControlCharactersFromStdout = false, verbose = false, queue = false, install = false, resume = false, useSkills = false, useStdinAppend = false, autoYes = true }) {
|
|
1363
|
+
async function agentYes({ cli, cliArgs = [], prompt, robust = true, cwd, env, exitOnIdle, logFile, removeControlCharactersFromStdout = false, verbose = false, queue = false, install = false, resume = false, useSkills = false, useStdinAppend: _useStdinAppend = false, autoYes = true }) {
|
|
1365
1364
|
if (!cli) throw new Error(`cli is required`);
|
|
1366
1365
|
const conf = CLIS_CONFIG[cli] || DIE(`Unsupported cli tool: ${cli}, current process.argv: ${process.argv.join(" ")}`);
|
|
1367
1366
|
const workingDir = cwd ?? process.cwd();
|
|
@@ -1410,7 +1409,7 @@ async function agentYes({ cli, cliArgs = [], prompt, robust = true, cwd, env, ex
|
|
|
1410
1409
|
let currentDir = workingDir;
|
|
1411
1410
|
const searchLimit = gitRoot || path.parse(currentDir).root;
|
|
1412
1411
|
while (true) {
|
|
1413
|
-
const md = await readFile
|
|
1412
|
+
const md = await readFile(path.resolve(currentDir, "SKILL.md"), "utf8").catch(() => null);
|
|
1414
1413
|
if (md) {
|
|
1415
1414
|
const headerMatch = md.match(/^[\s\S]*?(?=\n##\s)/);
|
|
1416
1415
|
const headerRaw = (headerMatch ? headerMatch[0] : md).trim();
|
|
@@ -1775,7 +1774,7 @@ async function agentYes({ cli, cliArgs = [], prompt, robust = true, cwd, env, ex
|
|
|
1775
1774
|
process.stdin.on("close", endHandler);
|
|
1776
1775
|
process.stdin.on("error", errorHandler);
|
|
1777
1776
|
},
|
|
1778
|
-
cancel(
|
|
1777
|
+
cancel(_reason) {
|
|
1779
1778
|
process.stdin.pause();
|
|
1780
1779
|
}
|
|
1781
1780
|
});
|
|
@@ -1856,10 +1855,10 @@ async function agentYes({ cli, cliArgs = [], prompt, robust = true, cwd, env, ex
|
|
|
1856
1855
|
}).forkTo(async function rawLogger(f) {
|
|
1857
1856
|
const rawLogPath = ctx.logPaths.rawLogPath;
|
|
1858
1857
|
if (!rawLogPath) return f.run();
|
|
1859
|
-
return await mkdir
|
|
1858
|
+
return await mkdir(path.dirname(rawLogPath), { recursive: true }).then(() => {
|
|
1860
1859
|
logger.debug(`[${cli}-yes] raw logs streaming to ${rawLogPath}`);
|
|
1861
1860
|
return f.forEach(async (chars) => {
|
|
1862
|
-
await writeFile
|
|
1861
|
+
await writeFile(rawLogPath, chars, { flag: "a" }).catch(() => null);
|
|
1863
1862
|
}).run();
|
|
1864
1863
|
}).catch(() => f.run());
|
|
1865
1864
|
}).by(function consoleResponder(e) {
|
|
@@ -1952,4 +1951,4 @@ const SUPPORTED_CLIS = Object.keys(CLIS_CONFIG);
|
|
|
1952
1951
|
|
|
1953
1952
|
//#endregion
|
|
1954
1953
|
export { AgentContext as a, PidStore as c, config as i, removeControlCharacters as l, CLIS_CONFIG as n, name as o, agentYes as r, version as s, SUPPORTED_CLIS as t };
|
|
1955
|
-
//# sourceMappingURL=SUPPORTED_CLIS-
|
|
1954
|
+
//# sourceMappingURL=SUPPORTED_CLIS-gNHv7RnK.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as logger } from "./logger-
|
|
2
|
-
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
1
|
+
import { t as logger } from "./logger-CX77vJDA.js";
|
|
3
2
|
import os from "node:os";
|
|
3
|
+
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { parse } from "yaml";
|
|
6
6
|
|
|
@@ -331,5 +331,5 @@ function getDefaultConfig() {
|
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
//#endregion
|
|
334
|
-
export { agent_yes_config_default as
|
|
335
|
-
//# sourceMappingURL=agent-yes.config-
|
|
334
|
+
export { agent_yes_config_default as default };
|
|
335
|
+
//# sourceMappingURL=agent-yes.config-DcxG25Gv.js.map
|
package/dist/cli.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { c as PidStore, o as name, s as version, t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-
|
|
3
|
-
import "./
|
|
4
|
-
import { t as logger } from "./logger-CY9ormLF.js";
|
|
2
|
+
import { c as PidStore, o as name, s as version, t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-gNHv7RnK.js";
|
|
3
|
+
import { t as logger } from "./logger-CX77vJDA.js";
|
|
5
4
|
import { argv } from "process";
|
|
6
5
|
import { spawn } from "child_process";
|
|
7
|
-
import { existsSync, mkdirSync, unlinkSync } from "fs";
|
|
8
|
-
import path from "path";
|
|
9
6
|
import ms from "ms";
|
|
10
7
|
import yargs from "yargs";
|
|
11
8
|
import { hideBin } from "yargs/helpers";
|
|
12
|
-
import { chmod, copyFile
|
|
9
|
+
import { chmod, copyFile } from "fs/promises";
|
|
10
|
+
import path from "path";
|
|
11
|
+
import { existsSync, mkdirSync, unlinkSync } from "fs";
|
|
13
12
|
|
|
14
13
|
//#region ts/parseCliArgs.ts
|
|
15
14
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AgentContext, i as config, l as removeControlCharacters, n as CLIS_CONFIG, r as agentYes } from "./SUPPORTED_CLIS-
|
|
2
|
-
import "./logger-
|
|
1
|
+
import { a as AgentContext, i as config, l as removeControlCharacters, n as CLIS_CONFIG, r as agentYes } from "./SUPPORTED_CLIS-gNHv7RnK.js";
|
|
2
|
+
import "./logger-CX77vJDA.js";
|
|
3
3
|
|
|
4
4
|
export { AgentContext, CLIS_CONFIG, config, agentYes as default, removeControlCharacters };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-yes",
|
|
3
|
-
"version": "1.60.
|
|
3
|
+
"version": "1.60.7",
|
|
4
4
|
"description": "A wrapper tool that automates interactions with various AI CLI tools by automatically handling common prompts and responses.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"prepare": "husky",
|
|
81
81
|
"release": "standard-version && npm publish",
|
|
82
82
|
"release:beta": "standard-version && npm publish --tag beta",
|
|
83
|
-
"test": "bun test --coverage"
|
|
83
|
+
"test": "bun test --coverage ts/"
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
86
|
"@snomiao/bun-pty": "^0.3.4",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"phpdie": "^1.7.0",
|
|
92
92
|
"proper-lockfile": "^4.1.2",
|
|
93
93
|
"sflow": "^1.27.0",
|
|
94
|
-
"terminal-render": "^1.5.
|
|
94
|
+
"terminal-render": "^1.5.1",
|
|
95
95
|
"winston": "^3.19.0",
|
|
96
96
|
"yaml": "^2.8.2",
|
|
97
97
|
"yargs": "^18.0.0"
|
package/ts/JsonlStore.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { appendFile, mkdir, readFile, rename,
|
|
1
|
+
import { appendFile, mkdir, readFile, rename, writeFile } from "fs/promises";
|
|
2
2
|
import { existsSync } from "fs";
|
|
3
3
|
import { fsyncSync, openSync, closeSync } from "fs";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import { lock
|
|
5
|
+
import { lock } from "proper-lockfile";
|
|
6
6
|
import { logger } from "./logger.ts";
|
|
7
7
|
|
|
8
8
|
export interface JsonlDoc {
|
|
@@ -24,14 +24,11 @@ export interface JsonlDoc {
|
|
|
24
24
|
export class JsonlStore<T extends Record<string, any> = Record<string, any>> {
|
|
25
25
|
private filePath: string;
|
|
26
26
|
private tempPath: string;
|
|
27
|
-
private lockPath: string;
|
|
28
27
|
private docs = new Map<string, T & JsonlDoc>();
|
|
29
28
|
|
|
30
29
|
constructor(filePath: string) {
|
|
31
30
|
this.filePath = filePath;
|
|
32
31
|
this.tempPath = filePath + "~";
|
|
33
|
-
// Lock on the directory (proper-lockfile needs an existing path)
|
|
34
|
-
this.lockPath = path.dirname(filePath);
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
/**
|
|
@@ -167,29 +164,29 @@ export class JsonlStore<T extends Record<string, any> = Record<string, any>> {
|
|
|
167
164
|
* Acquires lock.
|
|
168
165
|
*/
|
|
169
166
|
async compact(): Promise<void> {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
await
|
|
192
|
-
}
|
|
167
|
+
const lines = Array.from(this.docs.values())
|
|
168
|
+
.map((doc) => {
|
|
169
|
+
const { _id, $$deleted: _$$deleted, ...rest } = doc;
|
|
170
|
+
return JSON.stringify({ _id, ...rest });
|
|
171
|
+
})
|
|
172
|
+
.join("\n");
|
|
173
|
+
const content = lines ? lines + "\n" : "";
|
|
174
|
+
|
|
175
|
+
try {
|
|
176
|
+
await this.withLock(async () => {
|
|
177
|
+
// Write to temp file
|
|
178
|
+
await writeFile(this.tempPath, content);
|
|
179
|
+
// fsync temp file
|
|
180
|
+
const fd = openSync(this.tempPath, "r");
|
|
181
|
+
fsyncSync(fd);
|
|
182
|
+
closeSync(fd);
|
|
183
|
+
// Atomic rename
|
|
184
|
+
await rename(this.tempPath, this.filePath);
|
|
185
|
+
});
|
|
186
|
+
} catch {
|
|
187
|
+
// Fallback: direct overwrite (e.g. rename fails on Windows, or lock unavailable)
|
|
188
|
+
await writeFile(this.filePath, content);
|
|
189
|
+
}
|
|
193
190
|
}
|
|
194
191
|
|
|
195
192
|
private async withLock<R>(fn: () => Promise<R>): Promise<R> {
|
package/ts/cli.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import { argv } from "process";
|
|
3
3
|
import { spawn } from "child_process";
|
|
4
|
-
import { existsSync } from "fs";
|
|
5
|
-
import path from "path";
|
|
6
|
-
import cliYesConfig from "../agent-yes.config.ts";
|
|
7
4
|
import { parseCliArgs } from "./parseCliArgs.ts";
|
|
8
5
|
import { SUPPORTED_CLIS } from "./SUPPORTED_CLIS.ts";
|
|
9
6
|
import { logger } from "./logger.ts";
|
package/ts/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { execaCommandSync, parseCommandString } from "execa";
|
|
2
|
-
import {
|
|
2
|
+
import { fromWritable } from "from-node-stream";
|
|
3
3
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import DIE from "phpdie";
|
|
6
6
|
import sflow from "sflow";
|
|
7
|
-
import { TerminalRenderStream
|
|
7
|
+
import { TerminalRenderStream } from "terminal-render";
|
|
8
8
|
import {
|
|
9
9
|
extractSessionId,
|
|
10
10
|
getSessionForCwd,
|
|
@@ -14,7 +14,7 @@ import pty, { ptyPackage } from "./pty.ts";
|
|
|
14
14
|
import { removeControlCharacters } from "./removeControlCharacters.ts";
|
|
15
15
|
import { acquireLock, releaseLock, shouldUseLock } from "./runningLock.ts";
|
|
16
16
|
import { logger } from "./logger.ts";
|
|
17
|
-
import { createFifoStream } from "./beta/fifo.ts";
|
|
17
|
+
// import { createFifoStream } from "./beta/fifo.ts";
|
|
18
18
|
import { PidStore } from "./pidStore.ts";
|
|
19
19
|
import { SUPPORTED_CLIS } from "./SUPPORTED_CLIS.ts";
|
|
20
20
|
import { sendEnter, sendMessage } from "./core/messaging.ts";
|
|
@@ -26,10 +26,10 @@ import {
|
|
|
26
26
|
} from "./core/logging.ts";
|
|
27
27
|
import { spawnAgent } from "./core/spawner.ts";
|
|
28
28
|
import { AgentContext } from "./core/context.ts";
|
|
29
|
-
import { createAutoResponseHandler } from "./core/responders.ts";
|
|
29
|
+
// import { createAutoResponseHandler } from "./core/responders.ts";
|
|
30
30
|
import { createTerminatorStream } from "./core/streamHelpers.ts";
|
|
31
31
|
import { globalAgentRegistry } from "./agentRegistry.ts";
|
|
32
|
-
import { ReadyManager } from "./ReadyManager.ts";
|
|
32
|
+
// import { ReadyManager } from "./ReadyManager.ts";
|
|
33
33
|
import { notifyWebhook } from "./webhookNotifier.ts";
|
|
34
34
|
|
|
35
35
|
export { removeControlCharacters };
|
|
@@ -119,7 +119,7 @@ export default async function agentYes({
|
|
|
119
119
|
install = false,
|
|
120
120
|
resume = false,
|
|
121
121
|
useSkills = false,
|
|
122
|
-
useStdinAppend = false,
|
|
122
|
+
useStdinAppend: _useStdinAppend = false,
|
|
123
123
|
autoYes = true,
|
|
124
124
|
}: {
|
|
125
125
|
cli: SUPPORTED_CLIS;
|
|
@@ -730,7 +730,7 @@ export default async function agentYes({
|
|
|
730
730
|
process.stdin.on("close", endHandler);
|
|
731
731
|
process.stdin.on("error", errorHandler);
|
|
732
732
|
},
|
|
733
|
-
cancel(
|
|
733
|
+
cancel(_reason) {
|
|
734
734
|
process.stdin.pause();
|
|
735
735
|
},
|
|
736
736
|
});
|
|
@@ -802,6 +802,7 @@ export default async function agentYes({
|
|
|
802
802
|
// Only check for /auto if line is short enough
|
|
803
803
|
if (line.length <= 20) {
|
|
804
804
|
const cleanLine = line
|
|
805
|
+
// oxlint-disable-next-line no-control-regex
|
|
805
806
|
.replace(/[\x00-\x1f]|\x1b\[[0-9;]*[A-Za-z]|\[[A-Z]/g, "")
|
|
806
807
|
.trim();
|
|
807
808
|
if (cleanLine === "/auto") {
|
package/ts/parseCliArgs.ts
CHANGED
|
@@ -2,7 +2,6 @@ import ms from "ms";
|
|
|
2
2
|
import yargs from "yargs";
|
|
3
3
|
import { hideBin } from "yargs/helpers";
|
|
4
4
|
import { SUPPORTED_CLIS } from "./SUPPORTED_CLIS.ts";
|
|
5
|
-
import pkg from "../package.json" with { type: "json" };
|
|
6
5
|
|
|
7
6
|
// const pkg = await JSON.parse(await readFile(path.resolve((import.meta.dir) + "/../package.json"), 'utf8'))
|
|
8
7
|
/**
|
package/ts/rustBinary.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Rust binary helper - finds or downloads the appropriate prebuilt binary
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { existsSync, mkdirSync, unlinkSync
|
|
6
|
-
import { chmod,
|
|
5
|
+
import { existsSync, mkdirSync, unlinkSync } from "fs";
|
|
6
|
+
import { chmod, copyFile } from "fs/promises";
|
|
7
7
|
import path from "path";
|
|
8
8
|
|
|
9
9
|
// Platform/arch to binary name mapping
|
|
@@ -60,7 +60,7 @@ export function getBinDir(): string {
|
|
|
60
60
|
*/
|
|
61
61
|
export function findRustBinary(verbose = false): string | undefined {
|
|
62
62
|
const binaryName = getBinaryName();
|
|
63
|
-
const
|
|
63
|
+
const _baseName = binaryName.replace(/\.exe$/, "");
|
|
64
64
|
|
|
65
65
|
const searchPaths = [
|
|
66
66
|
// 1. Check in npm package bin directory
|