happy-coder 0.2.3-beta.0 → 0.3.1-beta.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/index.cjs CHANGED
@@ -1269,6 +1269,7 @@ async function claudeRemote(opts) {
1269
1269
  }
1270
1270
  }
1271
1271
  };
1272
+ updateThinking(true);
1272
1273
  try {
1273
1274
  types$1.logger.debug(`[claudeRemote] Starting to iterate over response`);
1274
1275
  for await (const message2 of response) {
@@ -2231,7 +2232,7 @@ async function loop(opts) {
2231
2232
  }
2232
2233
 
2233
2234
  var name = "happy-coder";
2234
- var version = "0.2.3-beta.0";
2235
+ var version = "0.3.1-beta.0";
2235
2236
  var description = "Claude Code session sharing CLI";
2236
2237
  var author = "Kirill Dubovitskiy";
2237
2238
  var license = "MIT";
@@ -2240,7 +2241,7 @@ var homepage = "https://github.com/slopus/happy-cli";
2240
2241
  var bugs = "https://github.com/slopus/happy-cli/issues";
2241
2242
  var repository = "slopus/happy-cli";
2242
2243
  var bin = {
2243
- happy: "./bin/happy"
2244
+ happy: "./bin/happy.mjs"
2244
2245
  };
2245
2246
  var main = "./dist/index.cjs";
2246
2247
  var module$1 = "./dist/index.mjs";
@@ -2343,9 +2344,9 @@ var packageJson = {
2343
2344
  };
2344
2345
 
2345
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))));
2346
- const RUNNER_PATH = path.join(__dirname$1, "..", "..", "scripts", "ripgrep_launcher.cjs");
2347
+ const RUNNER_PATH = process.env.HAPPY_RIPGREP_LAUNCHER_PATH || path.resolve(path.join(__dirname$1, "..", "..", "scripts", "ripgrep_launcher.cjs"));
2347
2348
  function run(args, options) {
2348
- return new Promise((resolve, reject) => {
2349
+ return new Promise((resolve2, reject) => {
2349
2350
  const child = child_process.spawn("node", [RUNNER_PATH, JSON.stringify(args)], {
2350
2351
  stdio: ["pipe", "pipe", "pipe"],
2351
2352
  cwd: options?.cwd
@@ -2359,7 +2360,7 @@ function run(args, options) {
2359
2360
  stderr += data.toString();
2360
2361
  });
2361
2362
  child.on("close", (code) => {
2362
- resolve({
2363
+ resolve2({
2363
2364
  exitCode: code || 0,
2364
2365
  stdout,
2365
2366
  stderr
@@ -2884,6 +2885,51 @@ function setupCleanupHandlers() {
2884
2885
  });
2885
2886
  }
2886
2887
 
2888
+ async function extractSDKMetadata() {
2889
+ const abortController = new AbortController();
2890
+ try {
2891
+ types$1.logger.debug("[metadataExtractor] Starting SDK metadata extraction");
2892
+ const sdkQuery = query({
2893
+ prompt: "hello",
2894
+ options: {
2895
+ allowedTools: ["Bash(echo)"],
2896
+ maxTurns: 1,
2897
+ abort: abortController.signal
2898
+ }
2899
+ });
2900
+ for await (const message of sdkQuery) {
2901
+ if (message.type === "system" && message.subtype === "init") {
2902
+ const systemMessage = message;
2903
+ const metadata = {
2904
+ tools: systemMessage.tools,
2905
+ slashCommands: systemMessage.slash_commands
2906
+ };
2907
+ types$1.logger.debug("[metadataExtractor] Captured SDK metadata:", metadata);
2908
+ abortController.abort();
2909
+ return metadata;
2910
+ }
2911
+ }
2912
+ types$1.logger.debug("[metadataExtractor] No init message received from SDK");
2913
+ return {};
2914
+ } catch (error) {
2915
+ if (error instanceof Error && error.name === "AbortError") {
2916
+ types$1.logger.debug("[metadataExtractor] SDK query aborted after capturing metadata");
2917
+ return {};
2918
+ }
2919
+ types$1.logger.debug("[metadataExtractor] Error extracting SDK metadata:", error);
2920
+ return {};
2921
+ }
2922
+ }
2923
+ function extractSDKMetadataAsync(onComplete) {
2924
+ extractSDKMetadata().then((metadata) => {
2925
+ if (metadata.tools || metadata.slashCommands) {
2926
+ onComplete(metadata);
2927
+ }
2928
+ }).catch((error) => {
2929
+ types$1.logger.debug("[metadataExtractor] Async extraction failed:", error);
2930
+ });
2931
+ }
2932
+
2887
2933
  async function start(credentials, options = {}) {
2888
2934
  const workingDirectory = process.cwd();
2889
2935
  const sessionTag = node_crypto.randomUUID();
@@ -2903,6 +2949,19 @@ async function start(credentials, options = {}) {
2903
2949
  };
2904
2950
  const response = await api.getOrCreateSession({ tag: sessionTag, metadata, state });
2905
2951
  types$1.logger.debug(`Session created: ${response.id}`);
2952
+ extractSDKMetadataAsync(async (sdkMetadata) => {
2953
+ types$1.logger.debug("[start] SDK metadata extracted, updating session:", sdkMetadata);
2954
+ try {
2955
+ api.session(response).updateMetadata((currentMetadata) => ({
2956
+ ...currentMetadata,
2957
+ tools: sdkMetadata.tools,
2958
+ slashCommands: sdkMetadata.slashCommands
2959
+ }));
2960
+ types$1.logger.debug("[start] Session metadata updated with SDK capabilities");
2961
+ } catch (error) {
2962
+ types$1.logger.debug("[start] Failed to update session metadata:", error);
2963
+ }
2964
+ });
2906
2965
  if (options.daemonSpawn) {
2907
2966
  console.log(`daemon:sessionIdCreated:${response.id}`);
2908
2967
  }
package/dist/index.mjs CHANGED
@@ -24,7 +24,7 @@ import { z as z$1 } from 'zod';
24
24
  import { spawn as spawn$1, exec, execSync as execSync$1 } from 'child_process';
25
25
  import { promisify } from 'util';
26
26
  import crypto, { createHash } from 'crypto';
27
- import { dirname as dirname$1, join as join$1 } from 'path';
27
+ import { dirname as dirname$1, resolve as resolve$1, join as join$1 } from 'path';
28
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';
@@ -1248,6 +1248,7 @@ async function claudeRemote(opts) {
1248
1248
  }
1249
1249
  }
1250
1250
  };
1251
+ updateThinking(true);
1251
1252
  try {
1252
1253
  logger.debug(`[claudeRemote] Starting to iterate over response`);
1253
1254
  for await (const message2 of response) {
@@ -2210,7 +2211,7 @@ async function loop(opts) {
2210
2211
  }
2211
2212
 
2212
2213
  var name = "happy-coder";
2213
- var version = "0.2.3-beta.0";
2214
+ var version = "0.3.1-beta.0";
2214
2215
  var description = "Claude Code session sharing CLI";
2215
2216
  var author = "Kirill Dubovitskiy";
2216
2217
  var license = "MIT";
@@ -2219,7 +2220,7 @@ var homepage = "https://github.com/slopus/happy-cli";
2219
2220
  var bugs = "https://github.com/slopus/happy-cli/issues";
2220
2221
  var repository = "slopus/happy-cli";
2221
2222
  var bin = {
2222
- happy: "./bin/happy"
2223
+ happy: "./bin/happy.mjs"
2223
2224
  };
2224
2225
  var main = "./dist/index.cjs";
2225
2226
  var module = "./dist/index.mjs";
@@ -2322,9 +2323,9 @@ var packageJson = {
2322
2323
  };
2323
2324
 
2324
2325
  const __dirname = dirname$1(fileURLToPath$1(import.meta.url));
2325
- const RUNNER_PATH = join$1(__dirname, "..", "..", "scripts", "ripgrep_launcher.cjs");
2326
+ const RUNNER_PATH = process.env.HAPPY_RIPGREP_LAUNCHER_PATH || resolve$1(join$1(__dirname, "..", "..", "scripts", "ripgrep_launcher.cjs"));
2326
2327
  function run(args, options) {
2327
- return new Promise((resolve, reject) => {
2328
+ return new Promise((resolve2, reject) => {
2328
2329
  const child = spawn$1("node", [RUNNER_PATH, JSON.stringify(args)], {
2329
2330
  stdio: ["pipe", "pipe", "pipe"],
2330
2331
  cwd: options?.cwd
@@ -2338,7 +2339,7 @@ function run(args, options) {
2338
2339
  stderr += data.toString();
2339
2340
  });
2340
2341
  child.on("close", (code) => {
2341
- resolve({
2342
+ resolve2({
2342
2343
  exitCode: code || 0,
2343
2344
  stdout,
2344
2345
  stderr
@@ -2863,6 +2864,51 @@ function setupCleanupHandlers() {
2863
2864
  });
2864
2865
  }
2865
2866
 
2867
+ async function extractSDKMetadata() {
2868
+ const abortController = new AbortController();
2869
+ try {
2870
+ logger.debug("[metadataExtractor] Starting SDK metadata extraction");
2871
+ const sdkQuery = query({
2872
+ prompt: "hello",
2873
+ options: {
2874
+ allowedTools: ["Bash(echo)"],
2875
+ maxTurns: 1,
2876
+ abort: abortController.signal
2877
+ }
2878
+ });
2879
+ for await (const message of sdkQuery) {
2880
+ if (message.type === "system" && message.subtype === "init") {
2881
+ const systemMessage = message;
2882
+ const metadata = {
2883
+ tools: systemMessage.tools,
2884
+ slashCommands: systemMessage.slash_commands
2885
+ };
2886
+ logger.debug("[metadataExtractor] Captured SDK metadata:", metadata);
2887
+ abortController.abort();
2888
+ return metadata;
2889
+ }
2890
+ }
2891
+ logger.debug("[metadataExtractor] No init message received from SDK");
2892
+ return {};
2893
+ } catch (error) {
2894
+ if (error instanceof Error && error.name === "AbortError") {
2895
+ logger.debug("[metadataExtractor] SDK query aborted after capturing metadata");
2896
+ return {};
2897
+ }
2898
+ logger.debug("[metadataExtractor] Error extracting SDK metadata:", error);
2899
+ return {};
2900
+ }
2901
+ }
2902
+ function extractSDKMetadataAsync(onComplete) {
2903
+ extractSDKMetadata().then((metadata) => {
2904
+ if (metadata.tools || metadata.slashCommands) {
2905
+ onComplete(metadata);
2906
+ }
2907
+ }).catch((error) => {
2908
+ logger.debug("[metadataExtractor] Async extraction failed:", error);
2909
+ });
2910
+ }
2911
+
2866
2912
  async function start(credentials, options = {}) {
2867
2913
  const workingDirectory = process.cwd();
2868
2914
  const sessionTag = randomUUID();
@@ -2882,6 +2928,19 @@ async function start(credentials, options = {}) {
2882
2928
  };
2883
2929
  const response = await api.getOrCreateSession({ tag: sessionTag, metadata, state });
2884
2930
  logger.debug(`Session created: ${response.id}`);
2931
+ extractSDKMetadataAsync(async (sdkMetadata) => {
2932
+ logger.debug("[start] SDK metadata extracted, updating session:", sdkMetadata);
2933
+ try {
2934
+ api.session(response).updateMetadata((currentMetadata) => ({
2935
+ ...currentMetadata,
2936
+ tools: sdkMetadata.tools,
2937
+ slashCommands: sdkMetadata.slashCommands
2938
+ }));
2939
+ logger.debug("[start] Session metadata updated with SDK capabilities");
2940
+ } catch (error) {
2941
+ logger.debug("[start] Failed to update session metadata:", error);
2942
+ }
2943
+ });
2885
2944
  if (options.daemonSpawn) {
2886
2945
  console.log(`daemon:sessionIdCreated:${response.id}`);
2887
2946
  }
package/dist/lib.d.cts CHANGED
@@ -381,6 +381,8 @@ type Metadata = {
381
381
  updatedAt: number;
382
382
  };
383
383
  machineId?: string;
384
+ tools?: string[];
385
+ slashCommands?: string[];
384
386
  };
385
387
  type AgentState = {
386
388
  controlledByUser?: boolean | null | undefined;
package/dist/lib.d.mts CHANGED
@@ -381,6 +381,8 @@ type Metadata = {
381
381
  updatedAt: number;
382
382
  };
383
383
  machineId?: string;
384
+ tools?: string[];
385
+ slashCommands?: string[];
384
386
  };
385
387
  type AgentState = {
386
388
  controlledByUser?: boolean | null | undefined;