khala-cli 0.4.5 → 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.
- package/dist/{chunk-TZKEQIHP.mjs → chunk-2U4E7AM7.mjs} +18 -3
- package/dist/{chunk-EXHCVFVH.mjs → chunk-2XTYRBYX.mjs} +10 -4
- package/dist/{chunk-MBLP7LQJ.mjs → chunk-4X35OUAN.mjs} +11 -11
- package/dist/{chunk-PXKGKVGW.mjs → chunk-55KBLEX5.mjs} +1 -1
- package/dist/{chunk-RSDOTTZQ.mjs → chunk-6E3UCO22.mjs} +32 -11
- package/dist/{chunk-7G2G4E4U.mjs → chunk-AWBKVTLV.mjs} +15 -13
- package/dist/{chunk-V7M27QLT.mjs → chunk-B2MOLCJM.mjs} +7 -5
- package/dist/{chunk-IR3VN2ID.mjs → chunk-CWHGNVZV.mjs} +0 -18
- package/dist/chunk-DPW43YNC.mjs +36 -0
- package/dist/{chunk-V4Y26O4R.mjs → chunk-FH2CZX5T.mjs} +14 -12
- package/dist/{chunk-HB3UGIZG.mjs → chunk-IULQYQJZ.mjs} +3 -3
- package/dist/{chunk-Y4WVILEJ.mjs → chunk-JG5J3SHW.mjs} +1 -1
- package/dist/{chunk-Y2DRTRBJ.mjs → chunk-OECJ45NM.mjs} +2 -2
- package/dist/{chunk-KCJFSVDN.mjs → chunk-OW3DSTEZ.mjs} +4 -2
- package/dist/{chunk-OLZ62X7S.mjs → chunk-PFDUXY3N.mjs} +1 -1
- package/dist/{chunk-H46OG22B.mjs → chunk-PY2ZNVNY.mjs} +1 -1
- package/dist/{chunk-SQXDATEC.mjs → chunk-RRBIVI77.mjs} +1 -1
- package/dist/{chunk-6LC66VHK.mjs → chunk-SZIEG3RS.mjs} +6 -5
- package/dist/chunk-WHONG7UF.mjs +267 -0
- package/dist/{chunk-T7YRVE43.mjs → chunk-XUJIJ4KB.mjs} +8 -30
- package/dist/{chunk-EW22K3JO.mjs → chunk-Z4EDYB6Y.mjs} +176 -293
- package/dist/chunk-ZHMGB3PP.mjs +82 -0
- package/dist/khala.mjs +10 -10
- package/dist/web/assets/local-K8EcTVxW.js +9 -0
- package/dist/web/assets/local-R2y0Gl4T.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-VUE2DDYY.mjs +0 -34
- package/dist/web/assets/local-C1vz22ps.js +0 -9
- package/dist/web/assets/local-DdjwMERJ.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-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
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-
|
|
82
|
-
deliver: () => import("./chunk-
|
|
83
|
-
"claude-wake": () => import("./chunk-
|
|
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-
|
|
87
|
-
watch: () => () => import("./chunk-
|
|
88
|
-
local: () => () => import("./chunk-
|
|
89
|
-
install: () => () => import("./chunk-
|
|
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
|
});
|