codewhale 0.8.49 → 0.8.52

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/README.md CHANGED
@@ -4,8 +4,8 @@ Install and run CodeWhale, the agentic terminal for open-source and open-weight
4
4
  models, from GitHub release artifacts.
5
5
 
6
6
  > Previously published as `deepseek-tui`. See `docs/REBRAND.md` in the upstream
7
- > repository for the migration notes; the legacy `deepseek-tui` npm package
8
- > remains a deprecation shim through the v0.8.x transition.
7
+ > repository for the migration notes; the legacy `deepseek-tui` npm package is
8
+ > deprecated and receives no further releases.
9
9
 
10
10
  ## Install
11
11
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "codewhale",
3
- "version": "0.8.49",
4
- "codewhaleBinaryVersion": "0.8.49",
3
+ "version": "0.8.52",
4
+ "codewhaleBinaryVersion": "0.8.52",
5
5
  "description": "Install and run CodeWhale, the agentic terminal for open-source and open-weight coding models, from GitHub release artifacts.",
6
6
  "author": "Hmbown",
7
7
  "license": "MIT",
package/scripts/run.js CHANGED
@@ -7,31 +7,43 @@ function isVersionFlag(args = process.argv.slice(2)) {
7
7
  return args.includes("--version") || args.includes("-V");
8
8
  }
9
9
 
10
- function handleVersionFallback(binaryName) {
11
- if (isVersionFlag()) {
12
- const binVersion =
13
- pkg.codewhaleBinaryVersion || pkg.deepseekBinaryVersion || pkg.version;
14
- console.log(`${binaryName} (npm wrapper) v${pkg.version}`);
15
- console.log(`binary version: v${binVersion}`);
16
- console.log(`repo: ${pkg.repository?.url || "N/A"}`);
17
- process.exit(0);
18
- }
10
+ function printVersionFallback(binaryName) {
11
+ const binVersion =
12
+ pkg.codewhaleBinaryVersion || pkg.deepseekBinaryVersion || pkg.version;
13
+ console.log(`${binaryName} (npm wrapper) v${pkg.version}`);
14
+ console.log(`binary version: v${binVersion}`);
15
+ console.log(`repo: ${pkg.repository?.url || "N/A"}`);
19
16
  }
20
17
 
21
- async function run(binaryName) {
22
- // Intercept --version before attempting binary download/launch
23
- handleVersionFallback(binaryName);
18
+ async function run(binaryName, options = {}) {
19
+ const args = options.args || process.argv.slice(2);
20
+ const resolveBinaryPath = options.getBinaryPath || getBinaryPath;
21
+ const spawn = options.spawnSync || spawnSync;
22
+ const exit = options.exit || process.exit;
23
+ const versionFlag = isVersionFlag(args);
24
+
25
+ let binaryPath;
26
+ try {
27
+ binaryPath = await resolveBinaryPath(binaryName);
28
+ } catch (error) {
29
+ if (versionFlag) {
30
+ printVersionFallback(binaryName);
31
+ return exit(0);
32
+ }
33
+ throw error;
34
+ }
24
35
 
25
- const binaryPath = await getBinaryPath(binaryName);
26
- const result = spawnSync(binaryPath, process.argv.slice(2), {
36
+ const result = spawn(binaryPath, args, {
27
37
  stdio: "inherit",
28
38
  });
29
39
  if (result.error) {
30
- // If binary fails and user asked for --version, show npm version instead
31
- handleVersionFallback(binaryName);
40
+ if (versionFlag) {
41
+ printVersionFallback(binaryName);
42
+ return exit(0);
43
+ }
32
44
  throw result.error;
33
45
  }
34
- process.exit(result.status ?? 1);
46
+ return exit(result.status ?? 1);
35
47
  }
36
48
 
37
49
  async function runCodeWhale() {
@@ -46,7 +58,7 @@ module.exports = {
46
58
  run,
47
59
  runCodeWhale,
48
60
  runCodeWhaleTui,
49
- _internal: { isVersionFlag },
61
+ _internal: { isVersionFlag, printVersionFallback },
50
62
  };
51
63
 
52
64
  if (require.main === module) {
package/test/run.test.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const assert = require("node:assert/strict");
2
2
  const test = require("node:test");
3
3
 
4
- const { _internal } = require("../scripts/run");
4
+ const { run, _internal } = require("../scripts/run");
5
5
 
6
6
  test("version fallback handles only version flags", () => {
7
7
  assert.equal(_internal.isVersionFlag(["--version"]), true);
@@ -9,3 +9,53 @@ test("version fallback handles only version flags", () => {
9
9
  assert.equal(_internal.isVersionFlag(["-v"]), false);
10
10
  assert.equal(_internal.isVersionFlag(["--verbose"]), false);
11
11
  });
12
+
13
+ test("version flags prefer the installed binary over package metadata", async () => {
14
+ let spawned = false;
15
+ const exits = [];
16
+
17
+ await run("codewhale", {
18
+ args: ["--version"],
19
+ getBinaryPath: async () => "/tmp/codewhale-test-binary",
20
+ spawnSync: (binary, args, options) => {
21
+ spawned = true;
22
+ assert.equal(binary, "/tmp/codewhale-test-binary");
23
+ assert.deepEqual(args, ["--version"]);
24
+ assert.deepEqual(options, { stdio: "inherit" });
25
+ return { status: 0 };
26
+ },
27
+ exit: (status) => {
28
+ exits.push(status);
29
+ },
30
+ });
31
+
32
+ assert.equal(spawned, true);
33
+ assert.deepEqual(exits, [0]);
34
+ });
35
+
36
+ test("version flags fall back to package metadata when the binary is unavailable", async () => {
37
+ const originalLog = console.log;
38
+ const lines = [];
39
+ const exits = [];
40
+ console.log = (line) => lines.push(line);
41
+ try {
42
+ await run("codewhale", {
43
+ args: ["--version"],
44
+ getBinaryPath: async () => {
45
+ throw new Error("download unavailable");
46
+ },
47
+ spawnSync: () => {
48
+ throw new Error("spawn should not run without a binary");
49
+ },
50
+ exit: (status) => {
51
+ exits.push(status);
52
+ },
53
+ });
54
+ } finally {
55
+ console.log = originalLog;
56
+ }
57
+
58
+ assert.deepEqual(exits, [0]);
59
+ assert.match(lines.join("\n"), /codewhale \(npm wrapper\) v/);
60
+ assert.match(lines.join("\n"), /binary version: v/);
61
+ });