claude-yes 1.31.1 → 1.32.1

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.
Files changed (44) hide show
  1. package/README.md +225 -21
  2. package/dist/agent-yes.js +2 -0
  3. package/dist/amp-yes.js +2 -0
  4. package/dist/auggie-yes.js +2 -0
  5. package/dist/claude-yes.js +2 -20432
  6. package/dist/cli.js +18341 -10955
  7. package/dist/cli.js.map +141 -150
  8. package/dist/codex-yes.js +2 -20432
  9. package/dist/copilot-yes.js +2 -20432
  10. package/dist/cursor-yes.js +2 -20432
  11. package/dist/gemini-yes.js +2 -20432
  12. package/dist/grok-yes.js +2 -20432
  13. package/dist/index.js +16258 -13586
  14. package/dist/index.js.map +176 -191
  15. package/dist/qwen-yes.js +2 -20432
  16. package/package.json +95 -84
  17. package/ts/ReadyManager.spec.ts +10 -10
  18. package/ts/ReadyManager.ts +1 -1
  19. package/ts/SUPPORTED_CLIS.ts +4 -0
  20. package/ts/catcher.spec.ts +69 -70
  21. package/ts/cli-idle.spec.ts +8 -8
  22. package/ts/cli.ts +18 -26
  23. package/ts/defineConfig.ts +4 -4
  24. package/ts/idleWaiter.spec.ts +9 -9
  25. package/ts/index.ts +474 -233
  26. package/ts/logger.ts +22 -0
  27. package/ts/parseCliArgs.spec.ts +146 -147
  28. package/ts/parseCliArgs.ts +127 -59
  29. package/ts/postbuild.ts +29 -15
  30. package/ts/pty-fix.ts +155 -0
  31. package/ts/pty.ts +19 -0
  32. package/ts/removeControlCharacters.spec.ts +37 -38
  33. package/ts/removeControlCharacters.ts +2 -1
  34. package/ts/runningLock.spec.ts +119 -125
  35. package/ts/runningLock.ts +44 -55
  36. package/ts/session-integration.spec.ts +34 -42
  37. package/ts/utils.spec.ts +35 -35
  38. package/ts/utils.ts +7 -7
  39. package/ts/codex-resume.spec.ts +0 -239
  40. package/ts/codexSessionManager.spec.ts +0 -51
  41. package/ts/codexSessionManager.test.ts +0 -259
  42. package/ts/codexSessionManager.ts +0 -312
  43. package/ts/yesLog.spec.ts +0 -74
  44. package/ts/yesLog.ts +0 -27
package/ts/postbuild.ts CHANGED
@@ -1,18 +1,32 @@
1
1
  #! /usr/bin/env bun
2
- import { execaCommand } from 'execa';
3
- import { copyFile } from 'fs/promises';
4
- import * as pkg from '../package.json';
5
- import { CLIS_CONFIG } from '.';
2
+ /**
3
+ * Postbuild script: Create Node.js wrapper files in dist/
4
+ * These wrappers execute dist/cli.js with the appropriate CLI name
5
+ */
6
+ import { writeFile, chmod } from "fs/promises";
7
+ import { CLIS_CONFIG } from "./index.ts";
8
+ import sflow from "sflow";
9
+ import pkg from "../package.json";
6
10
 
7
- const src = 'dist/cli.js';
8
- await Promise.all(
9
- Object.keys(CLIS_CONFIG).map(async (cli) => {
10
- const dst = `dist/${cli}-yes.js`;
11
- if (!(pkg.bin as Record<string, string>)?.[`${cli}-yes`]) {
12
- console.log(`package.json Updated bin.${cli}-yes = ${dst}`);
13
- await execaCommand(`npm pkg set bin.${cli}-yes=${dst}`);
11
+ // Create copies for each CLI variant (all use the same wrapper logic)
12
+ await sflow([...Object.keys(CLIS_CONFIG), "agent"])
13
+ .map(async (cli) => {
14
+ const cliName = `${cli}-yes`;
15
+
16
+ const wrapperPath = `./dist/${cliName}.js`;
17
+ await writeFile(
18
+ wrapperPath,
19
+ `
20
+ #!/usr/bin/env bun
21
+ await import('./cli.js')
22
+ `.trim(),
23
+ );
24
+ await chmod(wrapperPath, 0o755);
25
+
26
+ if (!(pkg.bin as Record<string, string>)?.[cliName]) {
27
+ await Bun.$`npm pkg set ${"bin." + cliName}=${wrapperPath}`;
28
+ console.log(`${wrapperPath} created`);
14
29
  }
15
- await copyFile(src, dst);
16
- console.log(`${dst} Updated`);
17
- }),
18
- );
30
+ })
31
+
32
+ .run();
package/ts/pty-fix.ts ADDED
@@ -0,0 +1,155 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execSync } from "child_process";
4
+ import { existsSync } from "fs";
5
+ import { dirname, join } from "path";
6
+ import { arch, platform } from "process";
7
+ import { fileURLToPath } from "url";
8
+
9
+ // Determine the platform-specific library name
10
+ function getLibraryName() {
11
+ switch (platform) {
12
+ case "win32":
13
+ return "rust_pty.dll";
14
+ case "darwin":
15
+ return arch === "arm64" ? "librust_pty_arm64.dylib" : "librust_pty.dylib";
16
+ case "linux":
17
+ return arch === "arm64" ? "librust_pty_arm64.so" : "librust_pty.so";
18
+ default:
19
+ return "librust_pty.so";
20
+ }
21
+ }
22
+
23
+ // Check if we need to rebuild bun-pty
24
+ const bunPtyPath = dirname(fileURLToPath(import.meta.resolve("@snomiao/bun-pty"))) + "/..";
25
+ const libName = getLibraryName();
26
+ const libPath = join(bunPtyPath, "rust-pty", "target", "release", libName);
27
+
28
+ if (!existsSync(bunPtyPath)) {
29
+ console.log({ bunPtyPath });
30
+ console.log("bun-pty not found, skipping pty-fix in ");
31
+ process.exit(0);
32
+ }
33
+
34
+ // Platform-specific compatibility check
35
+ if (platform === "linux") {
36
+ // Check if the binary exists and if it has GLIBC compatibility issues
37
+ try {
38
+ const lddOutput = execSync(`ldd "${libPath}" 2>&1`, { encoding: "utf8" });
39
+ if (lddOutput.includes("GLIBC") && lddOutput.includes("not found")) {
40
+ console.log("GLIBC compatibility issue detected, rebuilding bun-pty...");
41
+ rebuildBunPty();
42
+ } else {
43
+ console.log("bun-pty binary is compatible");
44
+ }
45
+ } catch {
46
+ // If ldd fails or file doesn't exist, try to rebuild
47
+ console.log("Checking bun-pty compatibility...");
48
+ rebuildBunPty();
49
+ }
50
+ } else if (platform === "win32") {
51
+ // Windows: Check if DLL exists
52
+ if (!existsSync(libPath)) {
53
+ console.log("Windows DLL not found, attempting to rebuild...");
54
+ rebuildBunPty();
55
+ } else {
56
+ console.log("bun-pty Windows DLL found");
57
+ }
58
+ } else if (platform === "darwin") {
59
+ // macOS: Check if dylib exists
60
+ if (!existsSync(libPath)) {
61
+ console.log("macOS dylib not found, attempting to rebuild...");
62
+ rebuildBunPty();
63
+ } else {
64
+ console.log("bun-pty macOS dylib found");
65
+ }
66
+ } else {
67
+ console.log(`Platform ${platform} may require manual configuration`);
68
+ }
69
+
70
+ function rebuildBunPty() {
71
+ try {
72
+ // Check if cargo is available
73
+ const cargoCmd = platform === "win32" ? "cargo.exe" : "cargo";
74
+ try {
75
+ execSync(`${cargoCmd} --version`, { stdio: "ignore" });
76
+ } catch {
77
+ console.warn("Warning: Rust/Cargo not found. bun-pty native module may not work.");
78
+ console.warn("To fix this, install Rust: https://rustup.rs/");
79
+ return;
80
+ }
81
+
82
+ const rustPtyDir = join(bunPtyPath, "rust-pty");
83
+ const isWindows = platform === "win32";
84
+ const tempBase = isWindows ? process.env.TEMP || "C:\\Temp" : "/tmp";
85
+
86
+ // Check if source code exists
87
+ if (!existsSync(join(rustPtyDir, "Cargo.toml"))) {
88
+ // Try to clone and build from source
89
+ console.log("Source code not found in npm package, cloning from repository...");
90
+ const tmpDir = join(tempBase, `bun-pty-build-${Date.now()}`);
91
+
92
+ try {
93
+ execSync(`git clone https://github.com/snomiao/bun-pty.git "${tmpDir}"`, {
94
+ stdio: "inherit",
95
+ });
96
+
97
+ // Build command varies by platform
98
+ if (isWindows) {
99
+ execSync(
100
+ `cd /d "${tmpDir}" && cargo build --release --manifest-path rust-pty\\Cargo.toml`,
101
+ { stdio: "inherit" },
102
+ );
103
+ } else {
104
+ execSync(`cd "${tmpDir}" && cargo build --release --manifest-path rust-pty/Cargo.toml`, {
105
+ stdio: "inherit",
106
+ });
107
+ }
108
+
109
+ // Copy the built library
110
+ const builtLib = join(tmpDir, "rust-pty", "target", "release", libName);
111
+ if (existsSync(builtLib)) {
112
+ // Ensure target directory exists
113
+ const targetDir = join(rustPtyDir, "target", "release");
114
+ if (isWindows) {
115
+ execSync(`if not exist "${targetDir}" mkdir "${targetDir}"`, {});
116
+ execSync(`copy /Y "${builtLib}" "${libPath}"`, {});
117
+ } else {
118
+ execSync(`mkdir -p "${targetDir}"`, { stdio: "inherit" });
119
+ execSync(`cp "${builtLib}" "${libPath}"`, { stdio: "inherit" });
120
+ }
121
+ console.log("Successfully rebuilt bun-pty native module");
122
+ }
123
+
124
+ // Cleanup
125
+ if (isWindows) {
126
+ execSync(`rmdir /s /q "${tmpDir}"`, { stdio: "ignore" });
127
+ } else {
128
+ execSync(`rm -rf "${tmpDir}"`, { stdio: "ignore" });
129
+ }
130
+ } catch (buildError) {
131
+ console.error(
132
+ "Failed to build bun-pty:",
133
+ buildError instanceof Error ? buildError.message : buildError,
134
+ );
135
+ console.warn("The application may not work correctly without bun-pty");
136
+ }
137
+ } else {
138
+ // Build from included source
139
+ console.log("Building bun-pty from source...");
140
+ if (isWindows) {
141
+ execSync(`cd /d "${rustPtyDir}" && cargo build --release`, {
142
+ stdio: "inherit",
143
+ });
144
+ } else {
145
+ execSync(`cd "${rustPtyDir}" && cargo build --release`, {
146
+ stdio: "inherit",
147
+ });
148
+ }
149
+ console.log("Successfully rebuilt bun-pty native module");
150
+ }
151
+ } catch (error) {
152
+ console.error("Failed to rebuild bun-pty:", error instanceof Error ? error.message : error);
153
+ console.warn("The application may not work correctly without bun-pty");
154
+ }
155
+ }
package/ts/pty.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { logger } from "./logger.ts";
2
+
3
+ // its recommened to use bun-pty in windows, since node-pty is super complex to install there, requires a 10G M$ build tools
4
+
5
+ async function getPty() {
6
+ return globalThis.Bun
7
+ ? await import("bun-pty").catch((error) => {
8
+ logger.error("Failed to load bun-pty:", error);
9
+ throw error;
10
+ })
11
+ : await import("node-pty").catch((error) => {
12
+ logger.error("Failed to load node-pty:", error);
13
+ throw error;
14
+ });
15
+ }
16
+
17
+ const pty = await getPty();
18
+ export const ptyPackage = globalThis.Bun ? "bun-pty" : "node-pty";
19
+ export default pty;
@@ -1,74 +1,73 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { removeControlCharacters } from './removeControlCharacters';
1
+ import { describe, expect, it } from "vitest";
2
+ import { removeControlCharacters } from "./removeControlCharacters";
3
3
 
4
- describe('removeControlCharacters', () => {
5
- it('should remove ANSI escape sequences', () => {
6
- const input = '\u001b[31mRed text\u001b[0m';
7
- const expected = 'Red text';
4
+ describe("removeControlCharacters", () => {
5
+ it("should remove ANSI escape sequences", () => {
6
+ const input = "\u001b[31mRed text\u001b[0m";
7
+ const expected = "Red text";
8
8
  expect(removeControlCharacters(input)).toBe(expected);
9
9
  });
10
10
 
11
- it('should remove cursor positioning codes', () => {
12
- const input = '\u001b[1;1HHello\u001b[2;1HWorld';
13
- const expected = 'HelloWorld';
11
+ it("should remove cursor positioning codes", () => {
12
+ const input = "\u001b[1;1HHello\u001b[2;1HWorld";
13
+ const expected = "HelloWorld";
14
14
  expect(removeControlCharacters(input)).toBe(expected);
15
15
  });
16
16
 
17
- it('should remove color codes', () => {
18
- const input = '\u001b[32mGreen\u001b[0m \u001b[31mRed\u001b[0m';
19
- const expected = 'Green Red';
17
+ it("should remove color codes", () => {
18
+ const input = "\u001b[32mGreen\u001b[0m \u001b[31mRed\u001b[0m";
19
+ const expected = "Green Red";
20
20
  expect(removeControlCharacters(input)).toBe(expected);
21
21
  });
22
22
 
23
- it('should remove complex ANSI sequences', () => {
24
- const input = '\u001b[1;33;40mYellow on black\u001b[0m';
25
- const expected = 'Yellow on black';
23
+ it("should remove complex ANSI sequences", () => {
24
+ const input = "\u001b[1;33;40mYellow on black\u001b[0m";
25
+ const expected = "Yellow on black";
26
26
  expect(removeControlCharacters(input)).toBe(expected);
27
27
  });
28
28
 
29
- it('should handle empty string', () => {
30
- expect(removeControlCharacters('')).toBe('');
29
+ it("should handle empty string", () => {
30
+ expect(removeControlCharacters("")).toBe("");
31
31
  });
32
32
 
33
- it('should handle string with no control characters', () => {
34
- const input = 'Plain text with no escape sequences';
33
+ it("should handle string with no control characters", () => {
34
+ const input = "Plain text with no escape sequences";
35
35
  expect(removeControlCharacters(input)).toBe(input);
36
36
  });
37
37
 
38
- it('should remove CSI sequences with multiple parameters', () => {
39
- const input = '\u001b[38;5;196mBright red\u001b[0m';
40
- const expected = 'Bright red';
38
+ it("should remove CSI sequences with multiple parameters", () => {
39
+ const input = "\u001b[38;5;196mBright red\u001b[0m";
40
+ const expected = "Bright red";
41
41
  expect(removeControlCharacters(input)).toBe(expected);
42
42
  });
43
43
 
44
- it('should remove C1 control characters', () => {
45
- const input = '\u009b[32mGreen text\u009b[0m';
46
- const expected = 'Green text';
44
+ it("should remove C1 control characters", () => {
45
+ const input = "\u009b[32mGreen text\u009b[0m";
46
+ const expected = "Green text";
47
47
  expect(removeControlCharacters(input)).toBe(expected);
48
48
  });
49
49
 
50
- it('should handle mixed control and regular characters', () => {
51
- const input =
52
- 'Start\u001b[1mBold\u001b[0mMiddle\u001b[4mUnderline\u001b[0mEnd';
53
- const expected = 'StartBoldMiddleUnderlineEnd';
50
+ it("should handle mixed control and regular characters", () => {
51
+ const input = "Start\u001b[1mBold\u001b[0mMiddle\u001b[4mUnderline\u001b[0mEnd";
52
+ const expected = "StartBoldMiddleUnderlineEnd";
54
53
  expect(removeControlCharacters(input)).toBe(expected);
55
54
  });
56
55
 
57
- it('should preserve spaces and newlines', () => {
58
- const input = 'Line 1\u001b[31m\nRed Line 2\u001b[0m\n\nLine 4';
59
- const expected = 'Line 1\nRed Line 2\n\nLine 4';
56
+ it("should preserve spaces and newlines", () => {
57
+ const input = "Line 1\u001b[31m\nRed Line 2\u001b[0m\n\nLine 4";
58
+ const expected = "Line 1\nRed Line 2\n\nLine 4";
60
59
  expect(removeControlCharacters(input)).toBe(expected);
61
60
  });
62
61
 
63
- it('should handle cursor movement sequences', () => {
64
- const input = '\u001b[2AUp\u001b[3BDown\u001b[4CRight\u001b[5DLeft';
65
- const expected = 'UpDownRightLeft';
62
+ it("should handle cursor movement sequences", () => {
63
+ const input = "\u001b[2AUp\u001b[3BDown\u001b[4CRight\u001b[5DLeft";
64
+ const expected = "UpDownRightLeft";
66
65
  expect(removeControlCharacters(input)).toBe(expected);
67
66
  });
68
67
 
69
- it('should handle erase sequences', () => {
70
- const input = 'Text\u001b[2JClear\u001b[KLine';
71
- const expected = 'TextClearLine';
68
+ it("should handle erase sequences", () => {
69
+ const input = "Text\u001b[2JClear\u001b[KLine";
70
+ const expected = "TextClearLine";
72
71
  expect(removeControlCharacters(input)).toBe(expected);
73
72
  });
74
73
  });
@@ -1,7 +1,8 @@
1
1
  export function removeControlCharacters(str: string): string {
2
2
  // Matches control characters in the C0 and C1 ranges, including Delete (U+007F)
3
3
  return str.replace(
4
+ // eslint-disable-next-line no-control-regex This is a control regex
4
5
  /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
5
- '',
6
+ "",
6
7
  );
7
8
  }