fix: add --version to adapter CLIs, read VERSION from package.json
CI / check (pull_request) Successful in 3m29s

- All uwf-* adapter CLIs now support --version / -V
- util VERSION constant reads from package.json at runtime
- agent-hermes ACP clientInfo uses dynamic VERSION

小橘 🍊(NEKO Team)
This commit is contained in:
2026-06-05 07:29:54 +00:00
parent cd585a26f1
commit 794f9db568
6 changed files with 39 additions and 3 deletions
+7
View File
@@ -1,5 +1,12 @@
#!/usr/bin/env node #!/usr/bin/env node
// eslint-disable-next-line -- dynamic import for version
const pkg = await import("../package.json", { with: { type: "json" } });
if (process.argv.includes("--version") || process.argv.includes("-V")) {
process.stdout.write(`${pkg.default.version}\n`);
process.exit(0);
}
import { createBuiltinAgent } from "./agent.js"; import { createBuiltinAgent } from "./agent.js";
const main = createBuiltinAgent(); const main = createBuiltinAgent();
+7
View File
@@ -1,5 +1,12 @@
#!/usr/bin/env node #!/usr/bin/env node
// eslint-disable-next-line -- dynamic import for version
const pkg = await import("../package.json", { with: { type: "json" } });
if (process.argv.includes("--version") || process.argv.includes("-V")) {
process.stdout.write(`${pkg.default.version}\n`);
process.exit(0);
}
import { createClaudeCodeAgent } from "./claude-code.js"; import { createClaudeCodeAgent } from "./claude-code.js";
const model = process.env.CLAUDE_MODEL ?? null; const model = process.env.CLAUDE_MODEL ?? null;
+2 -1
View File
@@ -1,6 +1,7 @@
import type { ChildProcess } from "node:child_process"; import type { ChildProcess } from "node:child_process";
import { spawn } from "node:child_process"; import { spawn } from "node:child_process";
import { createInterface } from "node:readline"; import { createInterface } from "node:readline";
import { VERSION } from "@united-workforce/util";
const HERMES_COMMAND = "hermes"; const HERMES_COMMAND = "hermes";
const PROTOCOL_VERSION = 1; const PROTOCOL_VERSION = 1;
@@ -299,7 +300,7 @@ export class HermesAcpClient {
private async initialize(): Promise<void> { private async initialize(): Promise<void> {
const initResponse = await this.sendRequest("initialize", { const initResponse = await this.sendRequest("initialize", {
protocolVersion: PROTOCOL_VERSION, protocolVersion: PROTOCOL_VERSION,
clientInfo: { name: "uwf", version: "0.1.0" }, clientInfo: { name: "uwf", version: VERSION },
capabilities: {}, capabilities: {},
}); });
+7
View File
@@ -1,5 +1,12 @@
#!/usr/bin/env node #!/usr/bin/env node
// eslint-disable-next-line -- dynamic import for version
const pkg = await import("../package.json", { with: { type: "json" } });
if (process.argv.includes("--version") || process.argv.includes("-V")) {
process.stdout.write(`${pkg.default.version}\n`);
process.exit(0);
}
import { createHermesAgent } from "./hermes.js"; import { createHermesAgent } from "./hermes.js";
import { isResumeDisabled } from "./session-cache.js"; import { isResumeDisabled } from "./session-cache.js";
+7
View File
@@ -1,5 +1,12 @@
#!/usr/bin/env node #!/usr/bin/env node
// eslint-disable-next-line -- dynamic import for version
const pkg = await import("../package.json", { with: { type: "json" } });
if (process.argv.includes("--version") || process.argv.includes("-V")) {
process.stdout.write(`${pkg.default.version}\n`);
process.exit(0);
}
import { createMockAgent } from "./mock-agent.js"; import { createMockAgent } from "./mock-agent.js";
const USAGE = "usage: uwf-mock --mock-data <path> --thread <id> --role <role> --prompt <text>"; const USAGE = "usage: uwf-mock --mock-data <path> --thread <id> --role <role> --prompt <text>";
+9 -2
View File
@@ -1,2 +1,9 @@
// This version is kept in sync with package.json during releases. import { readFileSync } from "node:fs";
export const VERSION = "0.1.0"; import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8")) as {
version: string;
};
export const VERSION = pkg.version;