ztile-cli 0.3.3 → 0.3.5

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.
@@ -1,11 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- __require
4
- } from "./chunk-PDX44BCA.js";
5
2
 
6
3
  // src/lib/credentials.ts
7
- import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
4
+ import { existsSync, readFileSync, writeFileSync, mkdirSync, unlinkSync } from "fs";
8
5
  import { join } from "path";
6
+ import { hostname } from "os";
9
7
  function credentialsPath() {
10
8
  const home = process.env["HOME"] ?? process.env["USERPROFILE"] ?? "/tmp";
11
9
  return join(home, ".ztile", "credentials.json");
@@ -44,7 +42,7 @@ function resolveMachineId() {
44
42
  if (envId) return envId;
45
43
  const creds = loadCredentials();
46
44
  if (creds?.machineId) return creds.machineId;
47
- return "";
45
+ return hostname();
48
46
  }
49
47
  function pidFilePath() {
50
48
  const home = process.env["HOME"] ?? process.env["USERPROFILE"] ?? "/tmp";
@@ -67,10 +65,8 @@ function loadPid() {
67
65
  }
68
66
  }
69
67
  function removePid() {
70
- const path = pidFilePath();
71
68
  try {
72
- const { unlinkSync } = __require("fs");
73
- unlinkSync(path);
69
+ unlinkSync(pidFilePath());
74
70
  } catch {
75
71
  }
76
72
  }
package/dist/cli.js CHANGED
@@ -3,16 +3,16 @@
3
3
  // src/cli.ts
4
4
  var args = process.argv.slice(2);
5
5
  if (args[0] === "version" || args[0] === "--version" || args[0] === "-v") {
6
- console.log("0.3.3");
6
+ console.log("0.3.5");
7
7
  process.exit(0);
8
8
  }
9
9
  if (args[0] === "hook") {
10
- const { handleHook } = await import("./hook-5CIEDLN5.js");
10
+ const { handleHook } = await import("./hook-MZFJ2YNL.js");
11
11
  await handleHook();
12
12
  process.exit(0);
13
13
  }
14
14
  if (args[0] === "login") {
15
- const { login } = await import("./login-5E7FSVVL.js");
15
+ const { login } = await import("./login-LHLHSMDL.js");
16
16
  await login({
17
17
  apiKey: findArg(args, "--api-key"),
18
18
  serverUrl: findArg(args, "--server-url"),
@@ -21,25 +21,25 @@ if (args[0] === "login") {
21
21
  process.exit(0);
22
22
  }
23
23
  if (args[0] === "install") {
24
- const { resolveApiKey } = await import("./credentials-OO2RZFLG.js");
24
+ const { resolveApiKey } = await import("./credentials-LO2VVMZQ.js");
25
25
  const apiKey = resolveApiKey();
26
26
  if (!apiKey) {
27
27
  console.error("Error: Not logged in.");
28
28
  console.error(" Run `ztile login` first.");
29
29
  process.exit(1);
30
30
  }
31
- const { setupClaudeCode } = await import("./setup-VFHRFRZH.js");
31
+ const { setupClaudeCode } = await import("./setup-BTW4UVF2.js");
32
32
  await setupClaudeCode();
33
33
  process.exit(0);
34
34
  }
35
35
  if (args[0] === "connect") {
36
- const { runConnect } = await import("./connect-CZ727ZOC.js");
36
+ const { runConnect } = await import("./connect-TYJFBFTE.js");
37
37
  const projectDir = findArg(args, "--project") ?? process.env["ZTILE_PROJECT"] ?? process.cwd();
38
38
  const daemon = args.includes("--daemon") || args.includes("-d");
39
39
  await runConnect({ projectDir, daemon });
40
40
  }
41
41
  if (args[0] === "disconnect") {
42
- const { disconnect } = await import("./disconnect-TZ3MQUZS.js");
42
+ const { disconnect } = await import("./disconnect-CQLCAVXH.js");
43
43
  disconnect();
44
44
  process.exit(0);
45
45
  }
@@ -6,8 +6,7 @@ import {
6
6
  resolveApiKey,
7
7
  resolveServerUrl,
8
8
  savePid
9
- } from "./chunk-XSAVKZSF.js";
10
- import "./chunk-PDX44BCA.js";
9
+ } from "./chunk-YAF63OWJ.js";
11
10
 
12
11
  // src/commands/connect.ts
13
12
  import { hostname } from "os";
@@ -9,8 +9,7 @@ import {
9
9
  resolveServerUrl,
10
10
  saveCredentials,
11
11
  savePid
12
- } from "./chunk-XSAVKZSF.js";
13
- import "./chunk-PDX44BCA.js";
12
+ } from "./chunk-YAF63OWJ.js";
14
13
  export {
15
14
  isProcessRunning,
16
15
  loadCredentials,
@@ -3,8 +3,7 @@ import {
3
3
  isProcessRunning,
4
4
  loadPid,
5
5
  removePid
6
- } from "./chunk-XSAVKZSF.js";
7
- import "./chunk-PDX44BCA.js";
6
+ } from "./chunk-YAF63OWJ.js";
8
7
 
9
8
  // src/commands/disconnect.ts
10
9
  function disconnect() {
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  resolveApiKey,
4
+ resolveMachineId,
4
5
  resolveServerUrl
5
- } from "./chunk-XSAVKZSF.js";
6
- import "./chunk-PDX44BCA.js";
6
+ } from "./chunk-YAF63OWJ.js";
7
7
 
8
8
  // src/commands/hook.ts
9
9
  import { readFile as readFile2, stat } from "fs/promises";
@@ -109,6 +109,15 @@ async function sendRawToServer(payload) {
109
109
  );
110
110
  return false;
111
111
  }
112
+ try {
113
+ const result = await response.json();
114
+ const linesReceived = result["lines_received"];
115
+ const linesParsed = result["lines_parsed"];
116
+ if (linesReceived != null && linesReceived > 0 && linesParsed !== linesReceived) {
117
+ console.error(`[server] Parse drop: ${linesParsed}/${linesReceived} lines parsed, ${result["total_events"]} events`);
118
+ }
119
+ } catch {
120
+ }
112
121
  return true;
113
122
  } catch (error) {
114
123
  console.error(
@@ -121,7 +130,6 @@ async function sendRawToServer(payload) {
121
130
  // src/commands/hook.ts
122
131
  import { appendFileSync } from "fs";
123
132
  import { join as join2 } from "path";
124
- import { hostname } from "os";
125
133
  var LOG_FILE = join2(process.env["HOME"] ?? "/tmp", ".ztile", "hook-debug.log");
126
134
  function debugLog(msg) {
127
135
  const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${msg}
@@ -149,7 +157,7 @@ async function handleHook() {
149
157
  const transcriptPath = payload["transcript_path"];
150
158
  const sessionId = payload["session_id"];
151
159
  const cwd = payload["cwd"];
152
- debugLog(`[hook] ${hookEvent}: payload keys = ${Object.keys(payload).join(", ")}`);
160
+ debugLog(`[hook] ${hookEvent}: session=${sessionId?.slice(0, 12)} transcript=${transcriptPath?.split("/").pop()} keys=${Object.keys(payload).join(", ")}`);
153
161
  if (!transcriptPath) {
154
162
  debugLog("[hook] No transcript_path in payload, skipping");
155
163
  return;
@@ -158,7 +166,7 @@ async function handleHook() {
158
166
  debugLog("[hook] No session_id in payload, skipping");
159
167
  return;
160
168
  }
161
- const machineId = process.env["ZTILE_MACHINE_ID"] ?? hostname();
169
+ const machineId = resolveMachineId();
162
170
  if (hookEvent === "UserPromptSubmit") {
163
171
  const prompt = payload["prompt"];
164
172
  if (prompt) {
@@ -197,7 +205,6 @@ async function handleHook() {
197
205
  project: cwd
198
206
  });
199
207
  debugLog(`[hook] ${hookEvent}` + (ok ? " \u2192 server" : " (send failed)"));
200
- return;
201
208
  }
202
209
  const locked = await acquireLock();
203
210
  if (!locked) {
@@ -207,6 +214,7 @@ async function handleHook() {
207
214
  try {
208
215
  const fromOffset = await getByteOffset(transcriptPath);
209
216
  const fileInfo = await stat(transcriptPath);
217
+ debugLog(`[hook] ${hookEvent}: offset=${fromOffset} fileSize=${fileInfo.size} file=${transcriptPath.split("/").pop()}`);
210
218
  if (fileInfo.size <= fromOffset) {
211
219
  debugLog(`[hook] ${hookEvent}: no diff (offset ${fromOffset} \u2192 ${fileInfo.size})`);
212
220
  await updateByteOffset(transcriptPath, fileInfo.size, sessionId);
@@ -2,8 +2,7 @@
2
2
  import {
3
3
  loadCredentials,
4
4
  saveCredentials
5
- } from "./chunk-XSAVKZSF.js";
6
- import "./chunk-PDX44BCA.js";
5
+ } from "./chunk-YAF63OWJ.js";
7
6
 
8
7
  // src/commands/login.ts
9
8
  import { createInterface } from "readline";
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import "./chunk-PDX44BCA.js";
3
2
 
4
3
  // src/commands/setup.ts
5
4
  import { readFile, writeFile } from "fs/promises";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztile-cli",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Mission control for autonomous coding agents (Claude Code, Codex, Gemini CLI)",
5
5
  "bin": {
6
6
  "ztile": "dist/cli.js"
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
3
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
4
- }) : x)(function(x) {
5
- if (typeof require !== "undefined") return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
8
-
9
- export {
10
- __require
11
- };