@suwujs/king-ai 0.2.2 → 0.2.3
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/src/cli.js +9 -3
- package/dist/src/paths.d.ts +1 -1
- package/dist/src/paths.js +19 -1
- package/package.json +1 -1
package/dist/src/cli.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { cli, command } from "cleye";
|
|
3
|
-
import {
|
|
3
|
+
import { realpathSync } from "node:fs";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
4
5
|
import { CURRENT_VERSION, DEFAULT_SERVER, normalizeCommandName } from "./paths.js";
|
|
5
6
|
import { doPair, doRun, runDoctor } from "./daemon.js";
|
|
6
7
|
import { cleanupWorktrees, installService, isServiceInstalled, prepareWorktrees, printStatus, readRunningState, reloadService, restartService, stopService, tailLogs, uninstallService, watchStatus } from "./service.js";
|
|
@@ -1652,7 +1653,7 @@ const hostCommand = command({
|
|
|
1652
1653
|
async function main() {
|
|
1653
1654
|
await cli({
|
|
1654
1655
|
name: commandNameFromArgv(process.argv[1]),
|
|
1655
|
-
version:
|
|
1656
|
+
version: CURRENT_VERSION,
|
|
1656
1657
|
strictFlags: true,
|
|
1657
1658
|
commands: [agentCommand, skillCheckCommand, projectProfileCommand, usageCommand, teamCommand, hostCommand],
|
|
1658
1659
|
help: {
|
|
@@ -1689,7 +1690,12 @@ async function main() {
|
|
|
1689
1690
|
console.log(`Run \`${commandName} --help\` for usage.`);
|
|
1690
1691
|
});
|
|
1691
1692
|
}
|
|
1692
|
-
|
|
1693
|
+
function isDirectCliInvocation(argv1, moduleUrl) {
|
|
1694
|
+
if (!argv1)
|
|
1695
|
+
return false;
|
|
1696
|
+
return realpathSync(argv1) === realpathSync(fileURLToPath(moduleUrl));
|
|
1697
|
+
}
|
|
1698
|
+
if (isDirectCliInvocation(process.argv[1], import.meta.url)) {
|
|
1693
1699
|
void main().catch((err) => {
|
|
1694
1700
|
process.stderr.write(`${commandNameFromArgv(process.argv[1])}: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
1695
1701
|
process.exit(70);
|
package/dist/src/paths.d.ts
CHANGED
|
@@ -15,5 +15,5 @@ export declare const HEARTBEAT_PATH: string;
|
|
|
15
15
|
export declare const HOST_EVENTS_PATH: string;
|
|
16
16
|
export declare const HOST_RUNS_PATH: string;
|
|
17
17
|
export declare const SERVICE_LABEL = "dev.king-ai";
|
|
18
|
-
export declare const CURRENT_VERSION
|
|
18
|
+
export declare const CURRENT_VERSION: string;
|
|
19
19
|
export declare const DEFAULT_SERVER: string;
|
package/dist/src/paths.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
1
2
|
import { homedir } from "node:os";
|
|
2
3
|
import { join } from "node:path";
|
|
3
4
|
export const APP_NAME = "king-ai";
|
|
@@ -22,5 +23,22 @@ export const HEARTBEAT_PATH = join(CONFIG_DIR, "heartbeat.json");
|
|
|
22
23
|
export const HOST_EVENTS_PATH = join(CONFIG_DIR, "host-events.ndjson");
|
|
23
24
|
export const HOST_RUNS_PATH = join(CONFIG_DIR, "host-runs.ndjson");
|
|
24
25
|
export const SERVICE_LABEL = "dev.king-ai";
|
|
25
|
-
export const CURRENT_VERSION =
|
|
26
|
+
export const CURRENT_VERSION = readPackageVersion();
|
|
26
27
|
export const DEFAULT_SERVER = process.env.KING_AI_SERVER_URL || "https://api.king-ai.ai";
|
|
28
|
+
function readPackageVersion() {
|
|
29
|
+
const candidates = [
|
|
30
|
+
new URL("../../package.json", import.meta.url),
|
|
31
|
+
new URL("../package.json", import.meta.url)
|
|
32
|
+
];
|
|
33
|
+
for (const candidate of candidates) {
|
|
34
|
+
try {
|
|
35
|
+
const pkg = JSON.parse(readFileSync(candidate, "utf8"));
|
|
36
|
+
if (typeof pkg.version === "string" && pkg.version)
|
|
37
|
+
return pkg.version;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// Source and built files live at different depths; try the next candidate.
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return "0.0.0";
|
|
44
|
+
}
|