happy-coder 0.3.1-beta.0 → 0.3.1-beta.2

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 (45) hide show
  1. package/dist/index.cjs +38 -21
  2. package/dist/index.mjs +41 -24
  3. package/package.json +7 -5
  4. package/scripts/claude_remote_launcher.cjs +13 -0
  5. package/dist/index-B2GqfEZV.cjs +0 -1564
  6. package/dist/index-QItBXhux.mjs +0 -1540
  7. package/dist/install-B0DnBGS_.mjs +0 -29
  8. package/dist/install-B2r_gX72.cjs +0 -109
  9. package/dist/install-C809w0Cj.cjs +0 -31
  10. package/dist/install-DEPy62QN.mjs +0 -97
  11. package/dist/install-GZIzyuIE.cjs +0 -99
  12. package/dist/install-HKe7dyS4.mjs +0 -107
  13. package/dist/run-BmEaINbl.cjs +0 -250
  14. package/dist/run-DMbKhYfb.mjs +0 -247
  15. package/dist/run-FBXkmmN7.mjs +0 -32
  16. package/dist/run-q2To6b-c.cjs +0 -34
  17. package/dist/types-BG9AgCI4.mjs +0 -875
  18. package/dist/types-BRICSarm.mjs +0 -870
  19. package/dist/types-BTQRfIr3.cjs +0 -892
  20. package/dist/types-BeUppqJU.cjs +0 -886
  21. package/dist/types-C6Wx_bRW.cjs +0 -886
  22. package/dist/types-CEvzGLMI.cjs +0 -882
  23. package/dist/types-CKUdOV6c.mjs +0 -875
  24. package/dist/types-CNuBtNA5.cjs +0 -884
  25. package/dist/types-Cg4664gs.cjs +0 -879
  26. package/dist/types-CkPUFpfr.cjs +0 -885
  27. package/dist/types-CzYKFAYa.mjs +0 -882
  28. package/dist/types-D39L8JSd.mjs +0 -850
  29. package/dist/types-D7u2DxfV.cjs +0 -893
  30. package/dist/types-DD9P_5rj.mjs +0 -868
  31. package/dist/types-DNu8okOb.mjs +0 -874
  32. package/dist/types-DYBiuNUQ.cjs +0 -883
  33. package/dist/types-Df5dlWLV.mjs +0 -871
  34. package/dist/types-fXgEaaqP.mjs +0 -861
  35. package/dist/types-hotUTaWz.cjs +0 -863
  36. package/dist/types-ikrrEcJm.mjs +0 -873
  37. package/dist/types-mykDX2xe.cjs +0 -872
  38. package/dist/types-tLWMaptR.mjs +0 -879
  39. package/dist/uninstall-BGgl5V8F.mjs +0 -29
  40. package/dist/uninstall-BWHglipH.mjs +0 -40
  41. package/dist/uninstall-C42CoSCI.cjs +0 -53
  42. package/dist/uninstall-CLkTtlMv.mjs +0 -51
  43. package/dist/uninstall-CdHMb6wi.cjs +0 -31
  44. package/dist/uninstall-FXyyAuGU.cjs +0 -42
  45. /package/scripts/{claudeInteractiveLaunch.cjs → claude_local_launcher.cjs} +0 -0
package/dist/index.cjs CHANGED
@@ -9,6 +9,8 @@ var node_readline = require('node:readline');
9
9
  var node_url = require('node:url');
10
10
  var node_fs = require('node:fs');
11
11
  var os = require('node:os');
12
+ var path = require('path');
13
+ var url = require('url');
12
14
  var promises$1 = require('node:fs/promises');
13
15
  var promises = require('fs/promises');
14
16
  var ink = require('ink');
@@ -25,8 +27,6 @@ var z = require('zod');
25
27
  var child_process = require('child_process');
26
28
  var util = require('util');
27
29
  var crypto = require('crypto');
28
- var path = require('path');
29
- var url = require('url');
30
30
  var qrcode = require('qrcode-terminal');
31
31
  var fs = require('fs');
32
32
  var os$1 = require('os');
@@ -118,7 +118,13 @@ function claudeCheckSession(sessionId, path) {
118
118
  return hasGoodMessage;
119
119
  }
120
120
 
121
- const __dirname$3 = node_path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
121
+ const __dirname$2 = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
122
+ function projectPath() {
123
+ const path$1 = path.resolve(__dirname$2, "..");
124
+ return path$1;
125
+ }
126
+
127
+ node_path.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
122
128
  async function claudeLocal(opts) {
123
129
  const projectDir = getProjectPath(opts.path);
124
130
  node_fs.mkdirSync(projectDir, { recursive: true });
@@ -168,7 +174,10 @@ async function claudeLocal(opts) {
168
174
  if (opts.claudeArgs) {
169
175
  args.push(...opts.claudeArgs);
170
176
  }
171
- const claudeCliPath = process.env.HAPPY_CLAUDE_CLI_PATH || node_path.resolve(node_path.join(__dirname$3, "..", "scripts", "claudeInteractiveLaunch.cjs"));
177
+ const claudeCliPath = node_path.resolve(node_path.join(projectPath(), "scripts", "claude_local_launcher.cjs"));
178
+ if (!claudeCliPath || !node_fs.existsSync(claudeCliPath)) {
179
+ throw new Error("Claude local launcher not found. Please ensure HAPPY_PROJECT_ROOT is set correctly for development.");
180
+ }
172
181
  const env = {
173
182
  ...process.env,
174
183
  ...opts.claudeEnvVars
@@ -845,9 +854,9 @@ class AbortError extends Error {
845
854
  }
846
855
 
847
856
  const __filename$1 = node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
848
- const __dirname$2 = node_path.join(__filename$1, "..");
857
+ const __dirname$1 = node_path.join(__filename$1, "..");
849
858
  function getDefaultClaudeCodePath() {
850
- return node_path.join(__dirname$2, "..", "..", "..", "node_modules", "@anthropic-ai", "claude-code", "cli.js");
859
+ return node_path.join(__dirname$1, "..", "..", "..", "node_modules", "@anthropic-ai", "claude-code", "cli.js");
851
860
  }
852
861
  function logDebug(message) {
853
862
  if (process.env.DEBUG) {
@@ -909,16 +918,20 @@ class Query {
909
918
  try {
910
919
  for await (const line of rl) {
911
920
  if (line.trim()) {
912
- const message = JSON.parse(line);
913
- if (message.type === "control_response") {
914
- const controlResponse = message;
915
- const handler = this.pendingControlResponses.get(controlResponse.response.request_id);
916
- if (handler) {
917
- handler(controlResponse.response);
921
+ try {
922
+ const message = JSON.parse(line);
923
+ if (message.type === "control_response") {
924
+ const controlResponse = message;
925
+ const handler = this.pendingControlResponses.get(controlResponse.response.request_id);
926
+ if (handler) {
927
+ handler(controlResponse.response);
928
+ }
929
+ continue;
918
930
  }
919
- continue;
931
+ this.inputStream.enqueue(message);
932
+ } catch (e) {
933
+ types$1.logger.debug(line);
920
934
  }
921
- this.inputStream.enqueue(message);
922
935
  }
923
936
  }
924
937
  await this.processExitPromise;
@@ -1240,7 +1253,10 @@ async function claudeRemote(opts) {
1240
1253
  permissionPromptToolName: opts.permissionPromptToolName,
1241
1254
  permissionMode: opts.permissionMode,
1242
1255
  executable: "node",
1243
- abort: opts.signal
1256
+ abort: opts.signal,
1257
+ pathToClaudeCodeExecutable: (() => {
1258
+ return node_path.resolve(node_path.join(projectPath(), "scripts", "claude_remote_launcher.cjs"));
1259
+ })()
1244
1260
  };
1245
1261
  if (opts.claudeArgs && opts.claudeArgs.length > 0) {
1246
1262
  sdkOptions.executableArgs = [...sdkOptions.executableArgs || [], ...opts.claudeArgs];
@@ -2232,7 +2248,7 @@ async function loop(opts) {
2232
2248
  }
2233
2249
 
2234
2250
  var name = "happy-coder";
2235
- var version = "0.3.1-beta.0";
2251
+ var version = "0.3.1-beta.2";
2236
2252
  var description = "Claude Code session sharing CLI";
2237
2253
  var author = "Kirill Dubovitskiy";
2238
2254
  var license = "MIT";
@@ -2278,12 +2294,13 @@ var files = [
2278
2294
  var scripts = {
2279
2295
  test: "vitest run",
2280
2296
  "test:watch": "vitest",
2281
- build: "tsc --noEmit && pkgroll",
2297
+ build: "shx rm -rf dist && tsc --noEmit && pkgroll",
2282
2298
  prepublishOnly: "yarn build && yarn test",
2283
2299
  typecheck: "tsc --noEmit",
2284
2300
  dev: "npx tsx --env-file .env.sample src/index.ts",
2285
- "dev:local-server": "HANDY_SERVER_URL=http://localhost:3005 npx tsx --env-file .env.sample src/index.ts",
2286
- prerelease: "npm version prerelease --preid=beta"
2301
+ "dev:local-server": "cross-env HANDY_SERVER_URL=http://localhost:3005 tsx --env-file .env.sample src/index.ts",
2302
+ "version:prerelease": "npm version prerelease --preid=beta",
2303
+ "publish:prerelease": "npm publish --tag beta"
2287
2304
  };
2288
2305
  var dependencies = {
2289
2306
  "@anthropic-ai/claude-code": "^1.0.72",
@@ -2309,6 +2326,7 @@ var dependencies = {
2309
2326
  var devDependencies = {
2310
2327
  "@eslint/compat": "^1",
2311
2328
  "@types/node": ">=18",
2329
+ "cross-env": "^10.0.0",
2312
2330
  eslint: "^9",
2313
2331
  "eslint-config-prettier": "^10",
2314
2332
  pkgroll: "^2.14.2",
@@ -2343,9 +2361,8 @@ var packageJson = {
2343
2361
  overrides: overrides
2344
2362
  };
2345
2363
 
2346
- const __dirname$1 = path.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))));
2347
- const RUNNER_PATH = process.env.HAPPY_RIPGREP_LAUNCHER_PATH || path.resolve(path.join(__dirname$1, "..", "..", "scripts", "ripgrep_launcher.cjs"));
2348
2364
  function run(args, options) {
2365
+ const RUNNER_PATH = path.resolve(path.join(projectPath(), "scripts", "ripgrep_launcher.cjs"));
2349
2366
  return new Promise((resolve2, reject) => {
2350
2367
  const child = child_process.spawn("node", [RUNNER_PATH, JSON.stringify(args)], {
2351
2368
  stdio: ["pipe", "pipe", "pipe"],
package/dist/index.mjs CHANGED
@@ -2,11 +2,13 @@ import chalk from 'chalk';
2
2
  import { l as logger, d as backoff, e as delay, R as RawJSONLinesSchema, c as configuration, f as encodeBase64, A as ApiClient, g as encodeBase64Url, h as decodeBase64, b as initializeConfiguration, i as initLoggerWithGlobalConfiguration } from './types-BX4xv8Ty.mjs';
3
3
  import { randomUUID, randomBytes } from 'node:crypto';
4
4
  import { spawn, execSync } from 'node:child_process';
5
- import { resolve, join, dirname } from 'node:path';
5
+ import { resolve, join, dirname as dirname$1 } from 'node:path';
6
6
  import { createInterface } from 'node:readline';
7
- import { fileURLToPath } from 'node:url';
7
+ import { fileURLToPath as fileURLToPath$1 } from 'node:url';
8
8
  import { existsSync, readFileSync, mkdirSync, watch, rmSync } from 'node:fs';
9
9
  import os, { homedir } from 'node:os';
10
+ import { dirname, resolve as resolve$1, join as join$1 } from 'path';
11
+ import { fileURLToPath } from 'url';
10
12
  import { readFile, mkdir, writeFile as writeFile$1 } from 'node:fs/promises';
11
13
  import { watch as watch$1, access, readFile as readFile$1, stat, writeFile, readdir } from 'fs/promises';
12
14
  import { useStdout, useInput, Box, Text, render } from 'ink';
@@ -24,8 +26,6 @@ import { z as z$1 } from 'zod';
24
26
  import { spawn as spawn$1, exec, execSync as execSync$1 } from 'child_process';
25
27
  import { promisify } from 'util';
26
28
  import crypto, { createHash } from 'crypto';
27
- import { dirname as dirname$1, resolve as resolve$1, join as join$1 } from 'path';
28
- import { fileURLToPath as fileURLToPath$1 } from 'url';
29
29
  import qrcode from 'qrcode-terminal';
30
30
  import { existsSync as existsSync$1, readFileSync as readFileSync$1, writeFileSync, unlinkSync, mkdirSync as mkdirSync$1, chmodSync } from 'fs';
31
31
  import { hostname, homedir as homedir$1 } from 'os';
@@ -97,7 +97,13 @@ function claudeCheckSession(sessionId, path) {
97
97
  return hasGoodMessage;
98
98
  }
99
99
 
100
- const __dirname$2 = dirname(fileURLToPath(import.meta.url));
100
+ const __dirname$1 = dirname(fileURLToPath(import.meta.url));
101
+ function projectPath() {
102
+ const path = resolve$1(__dirname$1, "..");
103
+ return path;
104
+ }
105
+
106
+ dirname$1(fileURLToPath$1(import.meta.url));
101
107
  async function claudeLocal(opts) {
102
108
  const projectDir = getProjectPath(opts.path);
103
109
  mkdirSync(projectDir, { recursive: true });
@@ -147,7 +153,10 @@ async function claudeLocal(opts) {
147
153
  if (opts.claudeArgs) {
148
154
  args.push(...opts.claudeArgs);
149
155
  }
150
- const claudeCliPath = process.env.HAPPY_CLAUDE_CLI_PATH || resolve(join(__dirname$2, "..", "scripts", "claudeInteractiveLaunch.cjs"));
156
+ const claudeCliPath = resolve(join(projectPath(), "scripts", "claude_local_launcher.cjs"));
157
+ if (!claudeCliPath || !existsSync(claudeCliPath)) {
158
+ throw new Error("Claude local launcher not found. Please ensure HAPPY_PROJECT_ROOT is set correctly for development.");
159
+ }
151
160
  const env = {
152
161
  ...process.env,
153
162
  ...opts.claudeEnvVars
@@ -823,10 +832,10 @@ class AbortError extends Error {
823
832
  }
824
833
  }
825
834
 
826
- const __filename = fileURLToPath(import.meta.url);
827
- const __dirname$1 = join(__filename, "..");
835
+ const __filename = fileURLToPath$1(import.meta.url);
836
+ const __dirname = join(__filename, "..");
828
837
  function getDefaultClaudeCodePath() {
829
- return join(__dirname$1, "..", "..", "..", "node_modules", "@anthropic-ai", "claude-code", "cli.js");
838
+ return join(__dirname, "..", "..", "..", "node_modules", "@anthropic-ai", "claude-code", "cli.js");
830
839
  }
831
840
  function logDebug(message) {
832
841
  if (process.env.DEBUG) {
@@ -888,16 +897,20 @@ class Query {
888
897
  try {
889
898
  for await (const line of rl) {
890
899
  if (line.trim()) {
891
- const message = JSON.parse(line);
892
- if (message.type === "control_response") {
893
- const controlResponse = message;
894
- const handler = this.pendingControlResponses.get(controlResponse.response.request_id);
895
- if (handler) {
896
- handler(controlResponse.response);
900
+ try {
901
+ const message = JSON.parse(line);
902
+ if (message.type === "control_response") {
903
+ const controlResponse = message;
904
+ const handler = this.pendingControlResponses.get(controlResponse.response.request_id);
905
+ if (handler) {
906
+ handler(controlResponse.response);
907
+ }
908
+ continue;
897
909
  }
898
- continue;
910
+ this.inputStream.enqueue(message);
911
+ } catch (e) {
912
+ logger.debug(line);
899
913
  }
900
- this.inputStream.enqueue(message);
901
914
  }
902
915
  }
903
916
  await this.processExitPromise;
@@ -1219,7 +1232,10 @@ async function claudeRemote(opts) {
1219
1232
  permissionPromptToolName: opts.permissionPromptToolName,
1220
1233
  permissionMode: opts.permissionMode,
1221
1234
  executable: "node",
1222
- abort: opts.signal
1235
+ abort: opts.signal,
1236
+ pathToClaudeCodeExecutable: (() => {
1237
+ return resolve(join(projectPath(), "scripts", "claude_remote_launcher.cjs"));
1238
+ })()
1223
1239
  };
1224
1240
  if (opts.claudeArgs && opts.claudeArgs.length > 0) {
1225
1241
  sdkOptions.executableArgs = [...sdkOptions.executableArgs || [], ...opts.claudeArgs];
@@ -2211,7 +2227,7 @@ async function loop(opts) {
2211
2227
  }
2212
2228
 
2213
2229
  var name = "happy-coder";
2214
- var version = "0.3.1-beta.0";
2230
+ var version = "0.3.1-beta.2";
2215
2231
  var description = "Claude Code session sharing CLI";
2216
2232
  var author = "Kirill Dubovitskiy";
2217
2233
  var license = "MIT";
@@ -2257,12 +2273,13 @@ var files = [
2257
2273
  var scripts = {
2258
2274
  test: "vitest run",
2259
2275
  "test:watch": "vitest",
2260
- build: "tsc --noEmit && pkgroll",
2276
+ build: "shx rm -rf dist && tsc --noEmit && pkgroll",
2261
2277
  prepublishOnly: "yarn build && yarn test",
2262
2278
  typecheck: "tsc --noEmit",
2263
2279
  dev: "npx tsx --env-file .env.sample src/index.ts",
2264
- "dev:local-server": "HANDY_SERVER_URL=http://localhost:3005 npx tsx --env-file .env.sample src/index.ts",
2265
- prerelease: "npm version prerelease --preid=beta"
2280
+ "dev:local-server": "cross-env HANDY_SERVER_URL=http://localhost:3005 tsx --env-file .env.sample src/index.ts",
2281
+ "version:prerelease": "npm version prerelease --preid=beta",
2282
+ "publish:prerelease": "npm publish --tag beta"
2266
2283
  };
2267
2284
  var dependencies = {
2268
2285
  "@anthropic-ai/claude-code": "^1.0.72",
@@ -2288,6 +2305,7 @@ var dependencies = {
2288
2305
  var devDependencies = {
2289
2306
  "@eslint/compat": "^1",
2290
2307
  "@types/node": ">=18",
2308
+ "cross-env": "^10.0.0",
2291
2309
  eslint: "^9",
2292
2310
  "eslint-config-prettier": "^10",
2293
2311
  pkgroll: "^2.14.2",
@@ -2322,9 +2340,8 @@ var packageJson = {
2322
2340
  overrides: overrides
2323
2341
  };
2324
2342
 
2325
- const __dirname = dirname$1(fileURLToPath$1(import.meta.url));
2326
- const RUNNER_PATH = process.env.HAPPY_RIPGREP_LAUNCHER_PATH || resolve$1(join$1(__dirname, "..", "..", "scripts", "ripgrep_launcher.cjs"));
2327
2343
  function run(args, options) {
2344
+ const RUNNER_PATH = resolve$1(join$1(projectPath(), "scripts", "ripgrep_launcher.cjs"));
2328
2345
  return new Promise((resolve2, reject) => {
2329
2346
  const child = spawn$1("node", [RUNNER_PATH, JSON.stringify(args)], {
2330
2347
  stdio: ["pipe", "pipe", "pipe"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "happy-coder",
3
- "version": "0.3.1-beta.0",
3
+ "version": "0.3.1-beta.2",
4
4
  "description": "Claude Code session sharing CLI",
5
5
  "author": "Kirill Dubovitskiy",
6
6
  "license": "MIT",
@@ -46,12 +46,13 @@
46
46
  "scripts": {
47
47
  "test": "vitest run",
48
48
  "test:watch": "vitest",
49
- "build": "tsc --noEmit && pkgroll",
49
+ "build": "shx rm -rf dist && tsc --noEmit && pkgroll",
50
50
  "prepublishOnly": "yarn build && yarn test",
51
51
  "typecheck": "tsc --noEmit",
52
52
  "dev": "npx tsx --env-file .env.sample src/index.ts",
53
- "dev:local-server": "HANDY_SERVER_URL=http://localhost:3005 npx tsx --env-file .env.sample src/index.ts",
54
- "prerelease": "npm version prerelease --preid=beta"
53
+ "dev:local-server": "cross-env HANDY_SERVER_URL=http://localhost:3005 tsx --env-file .env.sample src/index.ts",
54
+ "version:prerelease": "npm version prerelease --preid=beta",
55
+ "publish:prerelease": "npm publish --tag beta"
55
56
  },
56
57
  "dependencies": {
57
58
  "@anthropic-ai/claude-code": "^1.0.72",
@@ -77,6 +78,7 @@
77
78
  "devDependencies": {
78
79
  "@eslint/compat": "^1",
79
80
  "@types/node": ">=18",
81
+ "cross-env": "^10.0.0",
80
82
  "eslint": "^9",
81
83
  "eslint-config-prettier": "^10",
82
84
  "pkgroll": "^2.14.2",
@@ -89,4 +91,4 @@
89
91
  "overrides": {
90
92
  "whatwg-url": "14.2.0"
91
93
  }
92
- }
94
+ }
@@ -0,0 +1,13 @@
1
+ // Intercept setTimeout for the Claude Code SDK
2
+ const originalSetTimeout = global.setTimeout;
3
+
4
+ global.setTimeout = function(callback, delay, ...args) {
5
+ // Just wrap and call the original setTimeout
6
+ return originalSetTimeout(callback, delay, ...args);
7
+ };
8
+
9
+ // Preserve setTimeout properties
10
+ Object.defineProperty(global.setTimeout, 'name', { value: 'setTimeout' });
11
+ Object.defineProperty(global.setTimeout, 'length', { value: originalSetTimeout.length });
12
+
13
+ import('@anthropic-ai/claude-code/cli.js')