khala-cli 0.4.5 → 0.4.7
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-25AX7UMF.mjs} +305 -97
- package/dist/{chunk-AUJEUKVM.mjs → chunk-3OFKVYOX.mjs} +1 -1
- package/dist/{chunk-7G2G4E4U.mjs → chunk-4LSCOWWN.mjs} +18 -17
- package/dist/chunk-5RGEO5HN.mjs +142 -0
- package/dist/{chunk-V7M27QLT.mjs → chunk-6YEYXZZB.mjs} +8 -7
- package/dist/{chunk-EXHCVFVH.mjs → chunk-7V2YQIRI.mjs} +11 -5
- package/dist/{chunk-PXKGKVGW.mjs → chunk-APIWKRKG.mjs} +1 -1
- package/dist/{chunk-H46OG22B.mjs → chunk-C5SMOUTO.mjs} +34 -5
- package/dist/{chunk-Y4WVILEJ.mjs → chunk-IG2NU5J6.mjs} +4 -4
- package/dist/chunk-JEI32DEA.mjs +634 -0
- package/dist/{chunk-MBLP7LQJ.mjs → chunk-K6EJSZYO.mjs} +95 -98
- package/dist/{chunk-V4Y26O4R.mjs → chunk-L7L6UNXN.mjs} +85 -36
- package/dist/{chunk-P5CP32X2.mjs → chunk-LNG3ZZBK.mjs} +1 -1
- package/dist/{chunk-IR3VN2ID.mjs → chunk-OAFYPBCP.mjs} +1 -19
- package/dist/{chunk-Y2DRTRBJ.mjs → chunk-ODTSGEID.mjs} +24 -8
- package/dist/{chunk-T7YRVE43.mjs → chunk-OP2HZ7EM.mjs} +8 -30
- package/dist/{chunk-RSDOTTZQ.mjs → chunk-S3FX7VCY.mjs} +30 -12
- package/dist/{chunk-OLZ62X7S.mjs → chunk-SU6362YU.mjs} +1 -1
- package/dist/{chunk-EW22K3JO.mjs → chunk-TOBQUAPD.mjs} +210 -311
- package/dist/{chunk-SN3STAO2.mjs → chunk-U3MKSPRO.mjs} +40 -3
- package/dist/{chunk-6LC66VHK.mjs → chunk-W5HS2PQO.mjs} +12 -13
- package/dist/{chunk-KCJFSVDN.mjs → chunk-WNOIHCCC.mjs} +9 -7
- package/dist/{chunk-SQXDATEC.mjs → chunk-YIHRHD7W.mjs} +1 -1
- package/dist/khala.mjs +10 -10
- package/dist/web/assets/local-BQl2KrE1.js +9 -0
- package/dist/web/assets/local-OwDq47O4.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-HB3UGIZG.mjs +0 -144
- 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
|
@@ -11,11 +11,7 @@ import {
|
|
|
11
11
|
stateKey,
|
|
12
12
|
writeJsonAtomic,
|
|
13
13
|
writeStateFile
|
|
14
|
-
} from "./chunk-
|
|
15
|
-
import {
|
|
16
|
-
DEFAULT_LISTENING_MODE,
|
|
17
|
-
decodeListeningMode
|
|
18
|
-
} from "./chunk-AUJEUKVM.mjs";
|
|
14
|
+
} from "./chunk-WNOIHCCC.mjs";
|
|
19
15
|
|
|
20
16
|
// src/inbox.ts
|
|
21
17
|
import * as fs from "node:fs/promises";
|
|
@@ -157,9 +153,12 @@ async function migrateLegacy(files) {
|
|
|
157
153
|
const nested = channelFiles(files, id);
|
|
158
154
|
await ensureStateDir(nested.dir);
|
|
159
155
|
const destinationInbox = await exists(nested.inbox);
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
|
|
156
|
+
if (!destinationInbox && present[0] && await exists(nested.cursor)) {
|
|
157
|
+
const [legacyCursor, channelCursor] = await Promise.all([readCursor(files), readCursor(nested)]);
|
|
158
|
+
if (legacyCursor.deliveredCount !== channelCursor.deliveredCount || legacyCursor.lastDeliveredEventId !== channelCursor.lastDeliveredEventId) {
|
|
159
|
+
const safe = legacyCursor.deliveredCount < channelCursor.deliveredCount ? legacyCursor : channelCursor;
|
|
160
|
+
await writeStateFile(nested.dir, "cursor.json", safe);
|
|
161
|
+
console.warn(`Khala cursor migration: conflicting cursors for ${id}; using earlier position ${safe.deliveredCount} to avoid skipping messages (legacy=${legacyCursor.deliveredCount}, channel=${channelCursor.deliveredCount}).`);
|
|
163
162
|
}
|
|
164
163
|
}
|
|
165
164
|
const status = await readStatus(files);
|
|
@@ -203,25 +202,6 @@ function resolveChannel(list, ref) {
|
|
|
203
202
|
return { ok: false, code: matches.length ? "channel_ambiguous" : "channel_unknown", channels };
|
|
204
203
|
}
|
|
205
204
|
|
|
206
|
-
// src/mode.ts
|
|
207
|
-
async function readListeningMode(files) {
|
|
208
|
-
const content = await readJson(files.mode);
|
|
209
|
-
const decoded = decodeListeningMode(typeof content === "object" && content !== null ? content.mode : void 0);
|
|
210
|
-
return decoded.ok ? decoded.value : DEFAULT_LISTENING_MODE;
|
|
211
|
-
}
|
|
212
|
-
async function applyListeningMode(files, next, meta, now = () => /* @__PURE__ */ new Date()) {
|
|
213
|
-
const previous = await readListeningMode(files);
|
|
214
|
-
if (previous === "async" && next !== "async") {
|
|
215
|
-
for (let attempt = 0; attempt < 2; attempt++) {
|
|
216
|
-
const { cursor, entries } = await unread(files);
|
|
217
|
-
if (await advanceCursor(files, cursor, entries) !== "conflict") break;
|
|
218
|
-
if (attempt === 1) throw new StateError("storage_failed");
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
await writeJsonAtomic(files.mode, { mode: next, ...meta, updatedAt: now().toISOString() });
|
|
222
|
-
return { previous, next };
|
|
223
|
-
}
|
|
224
|
-
|
|
225
205
|
export {
|
|
226
206
|
readEntries,
|
|
227
207
|
readCursor,
|
|
@@ -232,7 +212,5 @@ export {
|
|
|
232
212
|
channelKey,
|
|
233
213
|
listChannels,
|
|
234
214
|
migrateLegacy,
|
|
235
|
-
resolveChannel
|
|
236
|
-
readListeningMode,
|
|
237
|
-
applyListeningMode
|
|
215
|
+
resolveChannel
|
|
238
216
|
};
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
bundle
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-SU6362YU.mjs";
|
|
5
5
|
import {
|
|
6
|
-
CURSOR_WORKSPACE_ENV
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
CURSOR_WORKSPACE_ENV,
|
|
7
|
+
adapterFor
|
|
8
|
+
} from "./chunk-JEI32DEA.mjs";
|
|
9
|
+
import "./chunk-OP2HZ7EM.mjs";
|
|
10
|
+
import "./chunk-WNOIHCCC.mjs";
|
|
11
|
+
import "./chunk-3OFKVYOX.mjs";
|
|
12
|
+
import "./chunk-U3MKSPRO.mjs";
|
|
13
|
+
import "./chunk-APIWKRKG.mjs";
|
|
9
14
|
|
|
10
15
|
// src/install/main.ts
|
|
11
16
|
import { spawnSync } from "node:child_process";
|
|
@@ -193,7 +198,14 @@ async function installCursor(input) {
|
|
|
193
198
|
// src/install/main.ts
|
|
194
199
|
var MCP_MARKER = "# Khala MCP server, managed by `khala install codex`";
|
|
195
200
|
var USAGE = "usage: khala install codex [--codex-home <dir>] [--uninstall] | khala install cursor [--uninstall]";
|
|
196
|
-
async function runCursorInstall(flags, deps
|
|
201
|
+
async function runCursorInstall(flags, deps) {
|
|
202
|
+
const env = deps.env ?? process.env;
|
|
203
|
+
const stdout = deps.stdout ?? ((line) => {
|
|
204
|
+
process.stdout.write(line + "\n");
|
|
205
|
+
});
|
|
206
|
+
const stderr = deps.stderr ?? ((line) => {
|
|
207
|
+
process.stderr.write(line + "\n");
|
|
208
|
+
});
|
|
197
209
|
let uninstall = false;
|
|
198
210
|
for (const flag of flags) {
|
|
199
211
|
if (flag === "--uninstall") uninstall = true;
|
|
@@ -272,7 +284,7 @@ async function readOr(file, fallback) {
|
|
|
272
284
|
throw error;
|
|
273
285
|
}
|
|
274
286
|
}
|
|
275
|
-
async function
|
|
287
|
+
async function runCodexInstall(flags, deps) {
|
|
276
288
|
const env = deps.env ?? process.env;
|
|
277
289
|
const stdout = deps.stdout ?? ((line) => {
|
|
278
290
|
process.stdout.write(line + "\n");
|
|
@@ -280,8 +292,6 @@ async function runInstall(argv, deps = {}) {
|
|
|
280
292
|
const stderr = deps.stderr ?? ((line) => {
|
|
281
293
|
process.stderr.write(line + "\n");
|
|
282
294
|
});
|
|
283
|
-
const [target, ...flags] = argv;
|
|
284
|
-
if (target === "cursor") return runCursorInstall(flags, deps, env, stdout, stderr);
|
|
285
295
|
let codexHome = env.CODEX_HOME && path.isAbsolute(env.CODEX_HOME) ? env.CODEX_HOME : path.join(env.HOME ?? os.homedir(), ".codex");
|
|
286
296
|
let uninstall = false;
|
|
287
297
|
for (let i = 0; i < flags.length; i++) {
|
|
@@ -292,10 +302,6 @@ async function runInstall(argv, deps = {}) {
|
|
|
292
302
|
return 1;
|
|
293
303
|
}
|
|
294
304
|
}
|
|
295
|
-
if (target !== "codex") {
|
|
296
|
-
stderr(USAGE);
|
|
297
|
-
return 1;
|
|
298
|
-
}
|
|
299
305
|
const pkg = "package" in deps ? deps.package : bundle;
|
|
300
306
|
if (!pkg && !uninstall) {
|
|
301
307
|
stderr("khala: install runs from the published package (npx -y <package> install codex); from a checkout follow packages/agent/docs/install-codex.md");
|
|
@@ -355,6 +361,16 @@ async function runInstall(argv, deps = {}) {
|
|
|
355
361
|
}
|
|
356
362
|
return 0;
|
|
357
363
|
}
|
|
364
|
+
async function runInstall(argv, deps = {}) {
|
|
365
|
+
const [target = "", ...flags] = argv;
|
|
366
|
+
const adapter = adapterFor(target);
|
|
367
|
+
const run = adapter?.install;
|
|
368
|
+
if (run) return run(flags, deps);
|
|
369
|
+
(deps.stderr ?? ((line) => {
|
|
370
|
+
process.stderr.write(line + "\n");
|
|
371
|
+
}))(USAGE);
|
|
372
|
+
return 1;
|
|
373
|
+
}
|
|
358
374
|
async function main(argv) {
|
|
359
375
|
return runInstall(argv);
|
|
360
376
|
}
|
|
@@ -362,6 +378,8 @@ export {
|
|
|
362
378
|
MCP_MARKER,
|
|
363
379
|
codexMcpBlock,
|
|
364
380
|
main as default,
|
|
381
|
+
runCodexInstall,
|
|
382
|
+
runCursorInstall,
|
|
365
383
|
runInstall,
|
|
366
384
|
shellQuote,
|
|
367
385
|
updateCodexToml
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __khalaCreateRequire } from 'node:module'; const require = __khalaCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
define_KHALA_BUNDLE_default
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-APIWKRKG.mjs";
|
|
5
5
|
|
|
6
6
|
// src/bundle.ts
|
|
7
7
|
var bundle = typeof define_KHALA_BUNDLE_default === "undefined" ? void 0 : define_KHALA_BUNDLE_default;
|