khala-cli 0.4.4 → 0.4.6

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 (32) hide show
  1. package/dist/{chunk-OS2JLDL7.mjs → chunk-2U4E7AM7.mjs} +22 -5
  2. package/dist/{chunk-GE3RXO2X.mjs → chunk-2XTYRBYX.mjs} +10 -4
  3. package/dist/{chunk-6OADQWV7.mjs → chunk-4X35OUAN.mjs} +100 -39
  4. package/dist/{chunk-ZKDDKUUA.mjs → chunk-55KBLEX5.mjs} +1 -1
  5. package/dist/{chunk-AK74S7EN.mjs → chunk-6E3UCO22.mjs} +32 -11
  6. package/dist/chunk-AWBKVTLV.mjs +238 -0
  7. package/dist/{chunk-FA6Z65DW.mjs → chunk-B2MOLCJM.mjs} +9 -5
  8. package/dist/{chunk-DC3OX6F4.mjs → chunk-CWHGNVZV.mjs} +0 -18
  9. package/dist/chunk-DPW43YNC.mjs +36 -0
  10. package/dist/{chunk-PJ3E3IVH.mjs → chunk-FH2CZX5T.mjs} +14 -12
  11. package/dist/{chunk-LHAMBQK7.mjs → chunk-IULQYQJZ.mjs} +3 -3
  12. package/dist/{chunk-FUU775QM.mjs → chunk-JG5J3SHW.mjs} +14 -1
  13. package/dist/{chunk-MZS7XFMC.mjs → chunk-OECJ45NM.mjs} +2 -2
  14. package/dist/{chunk-XEYKJMZL.mjs → chunk-OW3DSTEZ.mjs} +57 -4
  15. package/dist/{chunk-ZRFXZK72.mjs → chunk-PFDUXY3N.mjs} +1 -1
  16. package/dist/{chunk-MU4FUENP.mjs → chunk-PY2ZNVNY.mjs} +20 -5
  17. package/dist/{chunk-7CVU5OZ7.mjs → chunk-RRBIVI77.mjs} +1 -1
  18. package/dist/{chunk-LN3G2LJV.mjs → chunk-SZIEG3RS.mjs} +6 -5
  19. package/dist/chunk-WHONG7UF.mjs +267 -0
  20. package/dist/chunk-XUJIJ4KB.mjs +216 -0
  21. package/dist/{chunk-LQ6KNUNN.mjs → chunk-Z4EDYB6Y.mjs} +465 -349
  22. package/dist/chunk-ZHMGB3PP.mjs +82 -0
  23. package/dist/khala.mjs +10 -10
  24. package/dist/web/assets/local-K8EcTVxW.js +9 -0
  25. package/dist/web/assets/local-R2y0Gl4T.css +1 -0
  26. package/dist/web/index.html +2 -2
  27. package/package.json +1 -1
  28. package/dist/chunk-ENPBK5W2.mjs +0 -187
  29. package/dist/chunk-N5VYKQMR.mjs +0 -108
  30. package/dist/chunk-VUE2DDYY.mjs +0 -34
  31. package/dist/web/assets/local-Bk8hMIT-.js +0 -9
  32. package/dist/web/assets/local-vdvavyq0.css +0 -1
@@ -0,0 +1,82 @@
1
+ import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
2
+ import {
3
+ advanceCursor,
4
+ unread
5
+ } from "./chunk-XUJIJ4KB.mjs";
6
+ import {
7
+ StateError,
8
+ readJson,
9
+ writeJsonAtomic
10
+ } from "./chunk-OW3DSTEZ.mjs";
11
+ import {
12
+ DEFAULT_LISTENING_MODE,
13
+ decodeListeningMode
14
+ } from "./chunk-AUJEUKVM.mjs";
15
+
16
+ // src/activity.ts
17
+ import path from "node:path";
18
+ async function readActivity(files) {
19
+ const activity = await readJson(path.join(files.dir, "activity.json"));
20
+ return activity && ["idle", "busy"].includes(activity.state) && typeof activity.updatedAt === "string" && Number.isFinite(Date.parse(activity.updatedAt)) ? activity : { state: "busy", updatedAt: (/* @__PURE__ */ new Date(0)).toISOString() };
21
+ }
22
+ async function writeActivity(files, state, now = () => /* @__PURE__ */ new Date()) {
23
+ const activity = { state, updatedAt: now().toISOString() };
24
+ await writeJsonAtomic(path.join(files.dir, "activity.json"), activity);
25
+ return activity;
26
+ }
27
+
28
+ // src/mode.ts
29
+ async function readListeningMode(files) {
30
+ const content = await readJson(files.mode);
31
+ const decoded = decodeListeningMode(typeof content === "object" && content !== null ? content.mode : void 0);
32
+ return decoded.ok ? decoded.value : DEFAULT_LISTENING_MODE;
33
+ }
34
+ async function applyListeningMode(files, next, meta, now = () => /* @__PURE__ */ new Date()) {
35
+ const previous = await readListeningMode(files);
36
+ if (previous === "async" && next !== "async") {
37
+ for (let attempt = 0; attempt < 2; attempt++) {
38
+ const { cursor, entries } = await unread(files);
39
+ if (await advanceCursor(files, cursor, entries) !== "conflict") break;
40
+ if (attempt === 1) throw new StateError("storage_failed");
41
+ }
42
+ }
43
+ await writeJsonAtomic(files.mode, { mode: next, ...meta, updatedAt: now().toISOString() });
44
+ return { previous, next };
45
+ }
46
+
47
+ // src/cursor.ts
48
+ import { createHash } from "node:crypto";
49
+ var CURSOR_WORKSPACE_ENV = "KHALA_CURSOR_WORKSPACE";
50
+ var CURSOR_DEFAULT_SESSION = "cursor-default";
51
+ function normalizeWorkspace(root) {
52
+ let value = root.trim();
53
+ if (!value || value.includes("${")) return null;
54
+ if (/^file:\/\//iu.test(value)) {
55
+ try {
56
+ value = decodeURIComponent(new URL(value).pathname);
57
+ } catch {
58
+ return null;
59
+ }
60
+ }
61
+ value = value.replaceAll("\\", "/");
62
+ if (/^\/[A-Za-z]:(?:\/|$)/u.test(value)) value = value.slice(1);
63
+ if (/^[A-Za-z]:(?:\/|$)/u.test(value)) value = value.toLowerCase();
64
+ value = value.replace(/\/+$/u, "");
65
+ if (/^[a-z]:$/u.test(value)) value += "/";
66
+ return value || null;
67
+ }
68
+ function cursorSessionId(root) {
69
+ const normalized = typeof root === "string" ? normalizeWorkspace(root) : null;
70
+ if (normalized === null) return CURSOR_DEFAULT_SESSION;
71
+ return `ws-${createHash("sha256").update(normalized).digest("hex").slice(0, 32)}`;
72
+ }
73
+
74
+ export {
75
+ readActivity,
76
+ writeActivity,
77
+ readListeningMode,
78
+ applyListeningMode,
79
+ CURSOR_WORKSPACE_ENV,
80
+ CURSOR_DEFAULT_SESSION,
81
+ cursorSessionId
82
+ };
package/dist/khala.mjs CHANGED
@@ -2,9 +2,9 @@
2
2
  import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
3
3
  import {
4
4
  KHALA_AGENT_VERSION
5
- } from "./chunk-7CVU5OZ7.mjs";
6
- import "./chunk-ZRFXZK72.mjs";
7
- import "./chunk-ZKDDKUUA.mjs";
5
+ } from "./chunk-RRBIVI77.mjs";
6
+ import "./chunk-PFDUXY3N.mjs";
7
+ import "./chunk-55KBLEX5.mjs";
8
8
 
9
9
  // src/cli.ts
10
10
  var HOOK_NAME = /^[a-z][a-z0-9-]{0,31}$/;
@@ -78,14 +78,14 @@ async function runCli(argv, modules) {
78
78
 
79
79
  // src/cli-bundle.ts
80
80
  var hooks = {
81
- "session-start": () => import("./chunk-GE3RXO2X.mjs"),
82
- deliver: () => import("./chunk-6OADQWV7.mjs"),
83
- "claude-wake": () => import("./chunk-MU4FUENP.mjs")
81
+ "session-start": () => import("./chunk-2XTYRBYX.mjs"),
82
+ deliver: () => import("./chunk-4X35OUAN.mjs"),
83
+ "claude-wake": () => import("./chunk-PY2ZNVNY.mjs")
84
84
  };
85
85
  process.exitCode = await runCli(process.argv.slice(2), {
86
- mcp: () => () => import("./chunk-LQ6KNUNN.mjs"),
87
- watch: () => () => import("./chunk-FA6Z65DW.mjs"),
88
- local: () => () => import("./chunk-PJ3E3IVH.mjs"),
89
- install: () => () => import("./chunk-AK74S7EN.mjs"),
86
+ mcp: () => () => import("./chunk-Z4EDYB6Y.mjs"),
87
+ watch: () => () => import("./chunk-B2MOLCJM.mjs"),
88
+ local: () => () => import("./chunk-FH2CZX5T.mjs"),
89
+ install: () => () => import("./chunk-6E3UCO22.mjs"),
90
90
  hook: (name) => Object.hasOwn(hooks, name) ? hooks[name] : void 0
91
91
  });