claude-yes 1.32.3 → 1.34.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 +441 -206
- package/dist/index.js +210 -40
- package/package.json +7 -5
- package/ts/cli.ts +22 -5
- package/ts/index.ts +104 -27
- package/ts/logger.ts +0 -1
- package/ts/parseCliArgs.ts +11 -0
- package/ts/pidStore.ts +135 -0
package/dist/index.js
CHANGED
|
@@ -20631,16 +20631,20 @@ import { fromReadable } from "from-node-stream";
|
|
|
20631
20631
|
import { createReadStream as createReadStream2, mkdirSync } from "fs";
|
|
20632
20632
|
import { unlink } from "fs/promises";
|
|
20633
20633
|
import { dirname } from "path";
|
|
20634
|
-
function createFifoStream(cli) {
|
|
20634
|
+
function createFifoStream(cli, customPath) {
|
|
20635
20635
|
if (process.platform !== "linux") {
|
|
20636
20636
|
return null;
|
|
20637
20637
|
}
|
|
20638
20638
|
let fifoPath = null;
|
|
20639
20639
|
let fifoStream = null;
|
|
20640
20640
|
try {
|
|
20641
|
-
|
|
20642
|
-
|
|
20643
|
-
|
|
20641
|
+
if (customPath) {
|
|
20642
|
+
fifoPath = customPath;
|
|
20643
|
+
} else {
|
|
20644
|
+
const timestamp = new Date().toISOString().replace(/\D/g, "").slice(0, 17);
|
|
20645
|
+
const randomSuffix = Math.random().toString(36).substring(2, 5);
|
|
20646
|
+
fifoPath = `/tmp/agent-yes-${timestamp}${randomSuffix}.stdin`;
|
|
20647
|
+
}
|
|
20644
20648
|
mkdirSync(dirname(fifoPath), { recursive: true });
|
|
20645
20649
|
const mkfifoResult = execaCommandSync(`mkfifo ${fifoPath}`, {
|
|
20646
20650
|
reject: false
|
|
@@ -20725,6 +20729,107 @@ var init_fifo = __esm(() => {
|
|
|
20725
20729
|
init_logger();
|
|
20726
20730
|
});
|
|
20727
20731
|
|
|
20732
|
+
// ts/pidStore.ts
|
|
20733
|
+
import Datastore from "@seald-io/nedb";
|
|
20734
|
+
import { mkdir as mkdir3 } from "fs/promises";
|
|
20735
|
+
import path9 from "path";
|
|
20736
|
+
|
|
20737
|
+
class PidStore {
|
|
20738
|
+
db;
|
|
20739
|
+
baseDir;
|
|
20740
|
+
constructor(workingDir) {
|
|
20741
|
+
this.baseDir = path9.resolve(workingDir, ".agent-yes");
|
|
20742
|
+
}
|
|
20743
|
+
async init() {
|
|
20744
|
+
await mkdir3(path9.join(this.baseDir, "logs"), { recursive: true });
|
|
20745
|
+
await mkdir3(path9.join(this.baseDir, "fifo"), { recursive: true });
|
|
20746
|
+
this.db = new Datastore({
|
|
20747
|
+
filename: path9.join(this.baseDir, "pid.jsonl"),
|
|
20748
|
+
autoload: true
|
|
20749
|
+
});
|
|
20750
|
+
await this.db.loadDatabaseAsync();
|
|
20751
|
+
await this.cleanStaleRecords();
|
|
20752
|
+
}
|
|
20753
|
+
async registerProcess({
|
|
20754
|
+
pid,
|
|
20755
|
+
cli,
|
|
20756
|
+
args,
|
|
20757
|
+
prompt
|
|
20758
|
+
}) {
|
|
20759
|
+
const now = Date.now();
|
|
20760
|
+
const record = {
|
|
20761
|
+
pid,
|
|
20762
|
+
cli,
|
|
20763
|
+
args,
|
|
20764
|
+
prompt,
|
|
20765
|
+
logFile: this.getLogPath(pid),
|
|
20766
|
+
fifoFile: this.getFifoPath(pid),
|
|
20767
|
+
status: "active",
|
|
20768
|
+
exitReason: "",
|
|
20769
|
+
startedAt: now,
|
|
20770
|
+
updatedAt: now
|
|
20771
|
+
};
|
|
20772
|
+
await this.db.insertAsync(record);
|
|
20773
|
+
logger.debug(`[pidStore] Registered process ${pid}`);
|
|
20774
|
+
return record;
|
|
20775
|
+
}
|
|
20776
|
+
async updateStatus(pid, status, extra) {
|
|
20777
|
+
const update2 = {
|
|
20778
|
+
status,
|
|
20779
|
+
updatedAt: Date.now(),
|
|
20780
|
+
...extra
|
|
20781
|
+
};
|
|
20782
|
+
await this.db.updateAsync({ pid }, { $set: update2 }, {});
|
|
20783
|
+
logger.debug(`[pidStore] Updated process ${pid} status=${status}`);
|
|
20784
|
+
}
|
|
20785
|
+
getLogPath(pid) {
|
|
20786
|
+
return path9.resolve(this.baseDir, "logs", `${pid}.log`);
|
|
20787
|
+
}
|
|
20788
|
+
getFifoPath(pid) {
|
|
20789
|
+
return path9.resolve(this.baseDir, "fifo", `${pid}.stdin`);
|
|
20790
|
+
}
|
|
20791
|
+
async cleanStaleRecords() {
|
|
20792
|
+
const activeRecords = await this.db.findAsync({
|
|
20793
|
+
status: { $ne: "exited" }
|
|
20794
|
+
});
|
|
20795
|
+
for (const record of activeRecords) {
|
|
20796
|
+
if (!this.isProcessAlive(record.pid)) {
|
|
20797
|
+
await this.db.updateAsync({ pid: record.pid }, {
|
|
20798
|
+
$set: {
|
|
20799
|
+
status: "exited",
|
|
20800
|
+
exitReason: "stale-cleanup",
|
|
20801
|
+
updatedAt: Date.now()
|
|
20802
|
+
}
|
|
20803
|
+
}, {});
|
|
20804
|
+
logger.debug(`[pidStore] Cleaned stale record for PID ${record.pid}`);
|
|
20805
|
+
}
|
|
20806
|
+
}
|
|
20807
|
+
}
|
|
20808
|
+
async close() {
|
|
20809
|
+
await this.db.compactDatafileAsync();
|
|
20810
|
+
logger.debug("[pidStore] Database compacted and closed");
|
|
20811
|
+
}
|
|
20812
|
+
isProcessAlive(pid) {
|
|
20813
|
+
try {
|
|
20814
|
+
process.kill(pid, 0);
|
|
20815
|
+
return true;
|
|
20816
|
+
} catch {
|
|
20817
|
+
return false;
|
|
20818
|
+
}
|
|
20819
|
+
}
|
|
20820
|
+
static async findActiveFifo(workingDir) {
|
|
20821
|
+
const store = new PidStore(workingDir);
|
|
20822
|
+
await store.init();
|
|
20823
|
+
const records = await store.db.findAsync({ status: { $ne: "exited" } });
|
|
20824
|
+
await store.close();
|
|
20825
|
+
const sorted = records.sort((a2, b) => b.startedAt - a2.startedAt);
|
|
20826
|
+
return sorted[0]?.fifoFile ?? null;
|
|
20827
|
+
}
|
|
20828
|
+
}
|
|
20829
|
+
var init_pidStore = __esm(() => {
|
|
20830
|
+
init_logger();
|
|
20831
|
+
});
|
|
20832
|
+
|
|
20728
20833
|
// ts/defineConfig.ts
|
|
20729
20834
|
async function defineCliYesConfig(cfg) {
|
|
20730
20835
|
if (typeof cfg === "function")
|
|
@@ -20755,13 +20860,13 @@ var exports_agent_yes_config = {};
|
|
|
20755
20860
|
__export(exports_agent_yes_config, {
|
|
20756
20861
|
default: () => agent_yes_config_default
|
|
20757
20862
|
});
|
|
20758
|
-
import { mkdir as
|
|
20863
|
+
import { mkdir as mkdir4 } from "node:fs/promises";
|
|
20759
20864
|
import os from "node:os";
|
|
20760
|
-
import
|
|
20865
|
+
import path10 from "node:path";
|
|
20761
20866
|
function getDefaultConfig() {
|
|
20762
20867
|
return defineCliYesConfig({
|
|
20763
20868
|
configDir,
|
|
20764
|
-
logsDir: configDir &&
|
|
20869
|
+
logsDir: configDir && path10.resolve(configDir, "logs"),
|
|
20765
20870
|
clis: {
|
|
20766
20871
|
qwen: {
|
|
20767
20872
|
install: "npm install -g @qwen-code/qwen-code@latest",
|
|
@@ -20774,8 +20879,12 @@ function getDefaultConfig() {
|
|
|
20774
20879
|
},
|
|
20775
20880
|
claude: {
|
|
20776
20881
|
promptArg: "last-arg",
|
|
20777
|
-
install:
|
|
20778
|
-
|
|
20882
|
+
install: {
|
|
20883
|
+
powershell: "irm https://claude.ai/install.ps1 | iex",
|
|
20884
|
+
bash: "curl -fsSL https://claude.ai/install.sh | bash",
|
|
20885
|
+
npm: "npm i -g @anthropic-ai/claude-code@latest"
|
|
20886
|
+
},
|
|
20887
|
+
ready: [/^\? for shortcuts/, /^> /],
|
|
20779
20888
|
typingRespond: {
|
|
20780
20889
|
"1\n": [/│ Do you want to use this API key\?/]
|
|
20781
20890
|
},
|
|
@@ -20858,21 +20967,21 @@ var init_agent_yes_config = __esm(async () => {
|
|
|
20858
20967
|
init_logger();
|
|
20859
20968
|
logger.debug("loading cli-yes.config.ts from " + import.meta.url);
|
|
20860
20969
|
configDir = await (async () => {
|
|
20861
|
-
const homeConfigDir =
|
|
20862
|
-
const isHomeWritable = await
|
|
20970
|
+
const homeConfigDir = path10.resolve(os.homedir(), ".agent-yes");
|
|
20971
|
+
const isHomeWritable = await mkdir4(homeConfigDir, { recursive: true }).then(() => true).catch(() => false);
|
|
20863
20972
|
if (isHomeWritable) {
|
|
20864
20973
|
logger.debug("[config] Using home directory:", homeConfigDir);
|
|
20865
20974
|
return homeConfigDir;
|
|
20866
20975
|
}
|
|
20867
|
-
const tmpConfigDir =
|
|
20868
|
-
const isWritable = await
|
|
20976
|
+
const tmpConfigDir = path10.resolve("/tmp/.agent-yes");
|
|
20977
|
+
const isWritable = await mkdir4(tmpConfigDir, { recursive: true });
|
|
20869
20978
|
if (isWritable) {
|
|
20870
20979
|
logger.debug("[config] Using workspace directory:", tmpConfigDir);
|
|
20871
20980
|
return tmpConfigDir;
|
|
20872
20981
|
}
|
|
20873
20982
|
return;
|
|
20874
20983
|
})();
|
|
20875
|
-
agent_yes_config_default = deepMixin(await getDefaultConfig(), await import(
|
|
20984
|
+
agent_yes_config_default = deepMixin(await getDefaultConfig(), await import(path10.resolve(os.homedir(), ".agent-yes/config.ts")).catch(() => ({ default: {} })).then((mod) => mod.default), await import(path10.resolve(process.cwd(), "node_modules/.agent-yes/config.ts")).catch(() => ({ default: {} })).then((mod) => mod.default), await import(path10.resolve(process.cwd(), ".agent-yes/config.ts")).catch(() => ({ default: {} })).then((mod) => mod.default));
|
|
20876
20985
|
});
|
|
20877
20986
|
|
|
20878
20987
|
// ts/pty-fix.ts
|
|
@@ -21011,11 +21120,12 @@ init_codexSessionManager();
|
|
|
21011
21120
|
init_runningLock();
|
|
21012
21121
|
init_logger();
|
|
21013
21122
|
init_fifo();
|
|
21123
|
+
init_pidStore();
|
|
21014
21124
|
await init_pty();
|
|
21015
21125
|
var import_winston2 = __toESM(require_winston(), 1);
|
|
21016
21126
|
import { fromReadable as fromReadable2, fromWritable } from "from-node-stream";
|
|
21017
|
-
import { mkdir as
|
|
21018
|
-
import
|
|
21127
|
+
import { mkdir as mkdir5, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
|
|
21128
|
+
import path11 from "path";
|
|
21019
21129
|
var config = await init_agent_yes_config().then(() => exports_agent_yes_config).then((mod) => mod.default || mod);
|
|
21020
21130
|
var CLIS_CONFIG = config.clis;
|
|
21021
21131
|
async function agentYes({
|
|
@@ -21061,6 +21171,8 @@ async function agentYes({
|
|
|
21061
21171
|
process.exit(code);
|
|
21062
21172
|
});
|
|
21063
21173
|
}
|
|
21174
|
+
const pidStore = new PidStore(workingDir);
|
|
21175
|
+
await pidStore.init();
|
|
21064
21176
|
process.stdin.setRawMode?.(true);
|
|
21065
21177
|
let isFatal = false;
|
|
21066
21178
|
let shouldRestartWithoutContinue = false;
|
|
@@ -21076,16 +21188,10 @@ async function agentYes({
|
|
|
21076
21188
|
const shellOutputStream = new TransformStream;
|
|
21077
21189
|
const outputWriter = shellOutputStream.writable.getWriter();
|
|
21078
21190
|
logger.debug(`Using ${ptyPackage} for pseudo terminal management.`);
|
|
21079
|
-
|
|
21080
|
-
|
|
21081
|
-
|
|
21082
|
-
|
|
21083
|
-
const debuggingLogsPath = config.logsDir && path10.resolve(config.logsDir, `${cli}-yes-${datetime}.debug.log`);
|
|
21084
|
-
if (debuggingLogsPath)
|
|
21085
|
-
logger.add(new import_winston2.default.transports.File({
|
|
21086
|
-
filename: debuggingLogsPath,
|
|
21087
|
-
level: "debug"
|
|
21088
|
-
}));
|
|
21191
|
+
let logPath = false;
|
|
21192
|
+
let rawLogPath = false;
|
|
21193
|
+
let rawLinesLogPath = false;
|
|
21194
|
+
let debuggingLogsPath = false;
|
|
21089
21195
|
const isSubAgent = !!process.env.CLAUDE_PPID;
|
|
21090
21196
|
if (isSubAgent)
|
|
21091
21197
|
logger.info(`[${cli}-yes] Running as sub-agent (CLAUDE_PPID=${process.env.CLAUDE_PPID})`);
|
|
@@ -21115,9 +21221,9 @@ async function agentYes({
|
|
|
21115
21221
|
} catch {}
|
|
21116
21222
|
const skillHeaders = [];
|
|
21117
21223
|
let currentDir = workingDir2;
|
|
21118
|
-
const searchLimit = gitRoot ||
|
|
21224
|
+
const searchLimit = gitRoot || path11.parse(currentDir).root;
|
|
21119
21225
|
while (true) {
|
|
21120
|
-
const skillPath =
|
|
21226
|
+
const skillPath = path11.resolve(currentDir, "SKILL.md");
|
|
21121
21227
|
const md = await readFile3(skillPath, "utf8").catch(() => null);
|
|
21122
21228
|
if (md) {
|
|
21123
21229
|
const headerMatch = md.match(/^[\s\S]*?(?=\n##\s)/);
|
|
@@ -21130,7 +21236,7 @@ async function agentYes({
|
|
|
21130
21236
|
}
|
|
21131
21237
|
if (currentDir === searchLimit)
|
|
21132
21238
|
break;
|
|
21133
|
-
const parentDir =
|
|
21239
|
+
const parentDir = path11.dirname(currentDir);
|
|
21134
21240
|
if (parentDir === currentDir)
|
|
21135
21241
|
break;
|
|
21136
21242
|
currentDir = parentDir;
|
|
@@ -21193,6 +21299,26 @@ ${prompt}` : prefix;
|
|
|
21193
21299
|
logger.warn(`Unknown promptArg format: ${cliConf.promptArg}`);
|
|
21194
21300
|
}
|
|
21195
21301
|
}
|
|
21302
|
+
const getInstallCommand = (installConfig) => {
|
|
21303
|
+
if (typeof installConfig === "string") {
|
|
21304
|
+
return installConfig;
|
|
21305
|
+
}
|
|
21306
|
+
const isWindows = process.platform === "win32";
|
|
21307
|
+
const platform3 = isWindows ? "windows" : "unix";
|
|
21308
|
+
if (installConfig[platform3]) {
|
|
21309
|
+
return installConfig[platform3];
|
|
21310
|
+
}
|
|
21311
|
+
if (isWindows && installConfig.powershell) {
|
|
21312
|
+
return installConfig.powershell;
|
|
21313
|
+
}
|
|
21314
|
+
if (!isWindows && installConfig.bash) {
|
|
21315
|
+
return installConfig.bash;
|
|
21316
|
+
}
|
|
21317
|
+
if (installConfig.npm) {
|
|
21318
|
+
return installConfig.npm;
|
|
21319
|
+
}
|
|
21320
|
+
return null;
|
|
21321
|
+
};
|
|
21196
21322
|
const spawn2 = () => {
|
|
21197
21323
|
const cliCommand = cliConf?.binary || cli;
|
|
21198
21324
|
let [bin, ...args] = [...parseCommandString(cliCommand), ...cliArgs];
|
|
@@ -21207,14 +21333,19 @@ ${prompt}` : prefix;
|
|
|
21207
21333
|
logger.error(`Fatal: Failed to start ${cli}.`);
|
|
21208
21334
|
const isNotFound = isCommandNotFoundError(error);
|
|
21209
21335
|
if (cliConf?.install && isNotFound) {
|
|
21210
|
-
|
|
21336
|
+
const installCmd = getInstallCommand(cliConf.install);
|
|
21337
|
+
if (!installCmd) {
|
|
21338
|
+
logger.error(`No suitable install command found for ${cli} on this platform`);
|
|
21339
|
+
throw error;
|
|
21340
|
+
}
|
|
21341
|
+
logger.info(`Please install the cli by run ${installCmd}`);
|
|
21211
21342
|
if (install) {
|
|
21212
21343
|
logger.info(`Attempting to install ${cli}...`);
|
|
21213
|
-
execaCommandSync(
|
|
21344
|
+
execaCommandSync(installCmd, { stdio: "inherit" });
|
|
21214
21345
|
logger.info(`${cli} installed successfully. Please rerun the command.`);
|
|
21215
21346
|
return spawn2();
|
|
21216
21347
|
} else {
|
|
21217
|
-
logger.error(`If you did not installed it yet, Please install it first: ${
|
|
21348
|
+
logger.error(`If you did not installed it yet, Please install it first: ${installCmd}`);
|
|
21218
21349
|
throw error;
|
|
21219
21350
|
}
|
|
21220
21351
|
}
|
|
@@ -21230,6 +21361,16 @@ ${prompt}` : prefix;
|
|
|
21230
21361
|
return false;
|
|
21231
21362
|
}
|
|
21232
21363
|
}, spawn2)();
|
|
21364
|
+
await pidStore.registerProcess({ pid: shell.pid, cli, args: cliArgs, prompt });
|
|
21365
|
+
logPath = pidStore.getLogPath(shell.pid);
|
|
21366
|
+
rawLogPath = path11.resolve(path11.dirname(logPath), `${shell.pid}.raw.log`);
|
|
21367
|
+
rawLinesLogPath = path11.resolve(path11.dirname(logPath), `${shell.pid}.lines.log`);
|
|
21368
|
+
debuggingLogsPath = path11.resolve(path11.dirname(logPath), `${shell.pid}.debug.log`);
|
|
21369
|
+
if (debuggingLogsPath)
|
|
21370
|
+
logger.add(new import_winston2.default.transports.File({
|
|
21371
|
+
filename: debuggingLogsPath,
|
|
21372
|
+
level: "debug"
|
|
21373
|
+
}));
|
|
21233
21374
|
const pendingExitCode = Promise.withResolvers();
|
|
21234
21375
|
async function onData(data) {
|
|
21235
21376
|
await outputWriter.write(data);
|
|
@@ -21239,6 +21380,10 @@ ${prompt}` : prefix;
|
|
|
21239
21380
|
stdinReady.unready();
|
|
21240
21381
|
const agentCrashed = exitCode2 !== 0;
|
|
21241
21382
|
if (shouldRestartWithoutContinue) {
|
|
21383
|
+
await pidStore.updateStatus(shell.pid, "exited", {
|
|
21384
|
+
exitReason: "restarted",
|
|
21385
|
+
exitCode: exitCode2 ?? undefined
|
|
21386
|
+
});
|
|
21242
21387
|
shouldRestartWithoutContinue = false;
|
|
21243
21388
|
isFatal = false;
|
|
21244
21389
|
const cliCommand = cliConf?.binary || cli;
|
|
@@ -21248,6 +21393,7 @@ ${prompt}` : prefix;
|
|
|
21248
21393
|
];
|
|
21249
21394
|
logger.info(`Restarting ${cli} ${JSON.stringify([bin, ...args])}`);
|
|
21250
21395
|
shell = pty_default.spawn(bin, args, getPtyOptions());
|
|
21396
|
+
await pidStore.registerProcess({ pid: shell.pid, cli, args, prompt });
|
|
21251
21397
|
shell.onData(onData);
|
|
21252
21398
|
shell.onExit(onExit);
|
|
21253
21399
|
return;
|
|
@@ -21257,8 +21403,17 @@ ${prompt}` : prefix;
|
|
|
21257
21403
|
logger.warn(`robust is only supported for ${Object.entries(CLIS_CONFIG).filter(([_, v]) => v.restoreArgs).map(([k]) => k).join(", ")} currently, not ${cli}`);
|
|
21258
21404
|
return;
|
|
21259
21405
|
}
|
|
21260
|
-
if (isFatal)
|
|
21406
|
+
if (isFatal) {
|
|
21407
|
+
await pidStore.updateStatus(shell.pid, "exited", {
|
|
21408
|
+
exitReason: "fatal",
|
|
21409
|
+
exitCode: exitCode2 ?? undefined
|
|
21410
|
+
});
|
|
21261
21411
|
return pendingExitCode.resolve(exitCode2);
|
|
21412
|
+
}
|
|
21413
|
+
await pidStore.updateStatus(shell.pid, "exited", {
|
|
21414
|
+
exitReason: "restarted",
|
|
21415
|
+
exitCode: exitCode2 ?? undefined
|
|
21416
|
+
});
|
|
21262
21417
|
logger.info(`${cli} crashed, restarting...`);
|
|
21263
21418
|
let restoreArgs = conf.restoreArgs;
|
|
21264
21419
|
if (cli === "codex") {
|
|
@@ -21271,10 +21426,16 @@ ${prompt}` : prefix;
|
|
|
21271
21426
|
}
|
|
21272
21427
|
}
|
|
21273
21428
|
shell = pty_default.spawn(cli, restoreArgs, getPtyOptions());
|
|
21429
|
+
await pidStore.registerProcess({ pid: shell.pid, cli, args: restoreArgs, prompt });
|
|
21274
21430
|
shell.onData(onData);
|
|
21275
21431
|
shell.onExit(onExit);
|
|
21276
21432
|
return;
|
|
21277
21433
|
}
|
|
21434
|
+
const exitReason = agentCrashed ? "crash" : "normal";
|
|
21435
|
+
await pidStore.updateStatus(shell.pid, "exited", {
|
|
21436
|
+
exitReason,
|
|
21437
|
+
exitCode: exitCode2 ?? undefined
|
|
21438
|
+
});
|
|
21278
21439
|
return pendingExitCode.resolve(exitCode2);
|
|
21279
21440
|
});
|
|
21280
21441
|
process.stdout.on("resize", () => {
|
|
@@ -21286,6 +21447,7 @@ ${prompt}` : prefix;
|
|
|
21286
21447
|
const idleWaiter = new IdleWaiter;
|
|
21287
21448
|
if (exitOnIdle)
|
|
21288
21449
|
idleWaiter.wait(exitOnIdle).then(async () => {
|
|
21450
|
+
await pidStore.updateStatus(shell.pid, "idle").catch(() => null);
|
|
21289
21451
|
if (isStillWorkingQ()) {
|
|
21290
21452
|
logger.warn("[${cli}-yes] ${cli} is idle, but seems still working, not exiting yet");
|
|
21291
21453
|
return;
|
|
@@ -21311,10 +21473,14 @@ ${prompt}` : prefix;
|
|
|
21311
21473
|
}).by((s) => {
|
|
21312
21474
|
if (!useFifo)
|
|
21313
21475
|
return s;
|
|
21314
|
-
const fifoResult = createFifoStream(cli);
|
|
21476
|
+
const fifoResult = createFifoStream(cli, pidStore.getFifoPath(shell.pid));
|
|
21315
21477
|
if (!fifoResult)
|
|
21316
21478
|
return s;
|
|
21317
21479
|
pendingExitCode.promise.finally(() => fifoResult.cleanup());
|
|
21480
|
+
process.stderr.write(`
|
|
21481
|
+
Append prompts: ${cli}-yes --append-prompt '...'
|
|
21482
|
+
|
|
21483
|
+
`);
|
|
21318
21484
|
return s.merge(fifoResult.stream);
|
|
21319
21485
|
}).onStart(async function promptOnStart() {
|
|
21320
21486
|
logger.debug("Sending prompt message: " + JSON.stringify(prompt));
|
|
@@ -21328,10 +21494,13 @@ ${prompt}` : prefix;
|
|
|
21328
21494
|
}
|
|
21329
21495
|
}),
|
|
21330
21496
|
readable: shellOutputStream.readable
|
|
21331
|
-
}).forEach(() =>
|
|
21497
|
+
}).forEach(() => {
|
|
21498
|
+
idleWaiter.ping();
|
|
21499
|
+
pidStore.updateStatus(shell.pid, "active").catch(() => null);
|
|
21500
|
+
}).forEach(() => nextStdout.ready()).forkTo(async function rawLogger(f) {
|
|
21332
21501
|
if (!rawLogPath)
|
|
21333
21502
|
return f.run();
|
|
21334
|
-
return await
|
|
21503
|
+
return await mkdir5(path11.dirname(rawLogPath), { recursive: true }).then(() => {
|
|
21335
21504
|
logger.debug(`[${cli}-yes] raw logs streaming to ${rawLogPath}`);
|
|
21336
21505
|
return f.forEach(async (chars) => {
|
|
21337
21506
|
await writeFile3(rawLogPath, chars, { flag: "a" }).catch(() => null);
|
|
@@ -21405,18 +21574,19 @@ ${prompt}` : prefix;
|
|
|
21405
21574
|
flush: (ctrl) => ctrl.terminate()
|
|
21406
21575
|
})).to(fromWritable(process.stdout));
|
|
21407
21576
|
if (logPath) {
|
|
21408
|
-
await
|
|
21577
|
+
await mkdir5(path11.dirname(logPath), { recursive: true }).catch(() => null);
|
|
21409
21578
|
await writeFile3(logPath, terminalRender.render()).catch(() => null);
|
|
21410
21579
|
logger.info(`[${cli}-yes] Full logs saved to ${logPath}`);
|
|
21411
21580
|
}
|
|
21412
21581
|
const exitCode = await pendingExitCode.promise;
|
|
21413
21582
|
logger.info(`[${cli}-yes] ${cli} exited with code ${exitCode}`);
|
|
21583
|
+
await pidStore.close();
|
|
21414
21584
|
await outputWriter.close();
|
|
21415
21585
|
if (logFile) {
|
|
21416
21586
|
if (verbose)
|
|
21417
21587
|
logger.info(`[${cli}-yes] Writing rendered logs to ${logFile}`);
|
|
21418
|
-
const logFilePath =
|
|
21419
|
-
await
|
|
21588
|
+
const logFilePath = path11.resolve(logFile);
|
|
21589
|
+
await mkdir5(path11.dirname(logFilePath), { recursive: true }).catch(() => null);
|
|
21420
21590
|
await writeFile3(logFilePath, terminalRender.render());
|
|
21421
21591
|
}
|
|
21422
21592
|
return { exitCode, logs: terminalRender.render() };
|
|
@@ -21484,5 +21654,5 @@ export {
|
|
|
21484
21654
|
CLIS_CONFIG
|
|
21485
21655
|
};
|
|
21486
21656
|
|
|
21487
|
-
//# debugId=
|
|
21657
|
+
//# debugId=6BCBE693D722CAEF64756E2164756E21
|
|
21488
21658
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-yes",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.34.0",
|
|
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",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"agent-yes": "./dist/agent-yes.js",
|
|
33
33
|
"amp-yes": "./dist/amp-yes.js",
|
|
34
34
|
"auggie-yes": "./dist/auggie-yes.js",
|
|
35
|
+
"ay": "./dist/agent-yes.js",
|
|
35
36
|
"claude-yes": "./dist/claude-yes.js",
|
|
36
37
|
"codex-yes": "./dist/codex-yes.js",
|
|
37
38
|
"copilot-yes": "./dist/copilot-yes.js",
|
|
@@ -44,10 +45,10 @@
|
|
|
44
45
|
"doc": "docs"
|
|
45
46
|
},
|
|
46
47
|
"files": [
|
|
47
|
-
"dist/**/*.js",
|
|
48
|
-
"!dist/**/*.map",
|
|
49
48
|
"scripts",
|
|
50
|
-
"ts/*.ts"
|
|
49
|
+
"ts/*.ts",
|
|
50
|
+
"!dist/**/*.map",
|
|
51
|
+
"dist/**/*.js"
|
|
51
52
|
],
|
|
52
53
|
"type": "module",
|
|
53
54
|
"module": "ts/index.ts",
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
"registry": "https://registry.npmjs.org/"
|
|
62
63
|
},
|
|
63
64
|
"scripts": {
|
|
64
|
-
"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",
|
|
65
|
+
"build": "bun build ./ts/cli.ts ./ts/index.ts --outdir=dist --target=node --sourcemap --external=@seald-io/nedb --external=@snomiao/bun-pty --external=bun-pty --external=node-pty --external=from-node-stream --external=bun",
|
|
65
66
|
"postbuild": "bun ./ts/postbuild.ts",
|
|
66
67
|
"demo": "bun run build && bun link && claude-yes -- demo",
|
|
67
68
|
"dev": "bun ts/index.ts",
|
|
@@ -73,6 +74,7 @@
|
|
|
73
74
|
"test": "bun test --coverage"
|
|
74
75
|
},
|
|
75
76
|
"dependencies": {
|
|
77
|
+
"@seald-io/nedb": "^4.0.4",
|
|
76
78
|
"@snomiao/bun-pty": "^0.3.4",
|
|
77
79
|
"bun-pty": "^0.4.8",
|
|
78
80
|
"from-node-stream": "^0.1.2"
|
package/ts/cli.ts
CHANGED
|
@@ -3,19 +3,36 @@ import { argv } from "process";
|
|
|
3
3
|
import cliYesConfig from "../agent-yes.config.ts";
|
|
4
4
|
import { parseCliArgs } from "./parseCliArgs.ts";
|
|
5
5
|
import { logger } from "./logger.ts";
|
|
6
|
+
import { PidStore } from "./pidStore.ts";
|
|
6
7
|
|
|
7
8
|
// Import the CLI module
|
|
8
9
|
|
|
9
10
|
// Parse CLI arguments
|
|
10
11
|
const config = parseCliArgs(process.argv);
|
|
11
12
|
|
|
13
|
+
// Handle --append-prompt: write to active FIFO and exit
|
|
14
|
+
if (config.appendPrompt) {
|
|
15
|
+
const fifoPath = await PidStore.findActiveFifo(process.cwd());
|
|
16
|
+
if (!fifoPath) {
|
|
17
|
+
console.error("No active agent with FIFO found in current directory.");
|
|
18
|
+
process.exit(1);
|
|
19
|
+
}
|
|
20
|
+
const { writeFileSync, openSync, closeSync } = await import("fs");
|
|
21
|
+
const fd = openSync(fifoPath, "w");
|
|
22
|
+
writeFileSync(fd, config.appendPrompt + "\r");
|
|
23
|
+
closeSync(fd);
|
|
24
|
+
console.log(`Sent prompt to ${fifoPath}`);
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
|
|
12
28
|
// Validate CLI name
|
|
13
29
|
if (!config.cli) {
|
|
14
|
-
logger.error(process.argv);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
)
|
|
30
|
+
// logger.error(process.argv);
|
|
31
|
+
config.cli = "claude"; // default to claude, for smooth UX
|
|
32
|
+
logger.warn("Warning: No CLI name provided. Using default 'claude'.");
|
|
33
|
+
// throw new Error(
|
|
34
|
+
// `missing cli def, available clis: ${Object.keys((await cliYesConfig).clis).join(", ")}`,
|
|
35
|
+
// );
|
|
19
36
|
}
|
|
20
37
|
|
|
21
38
|
// console.log(`Using CLI: ${config.cli}`);
|