Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/dispatch.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Command dispatch: parse args, route to skill/agent/version/help trees.

import { createRequire } from "node:module";
import { AGENTS } from "./registry.mjs";
import { cmdAdd, cmdUpdate, cmdRemove, cmdStatus } from "./commands/skills.mjs";
import { cmdTeamSetup, cmdTeamUpdate, cmdTeamRepair } from "./commands/team.mjs";
Expand All @@ -16,7 +17,10 @@ import {
printHelp,
} from "./help.mjs";

const VERSION = "2.0.0";
// Single source of truth: package.json (drifts when hard-coded — v2.1.0
// shipped printing "2.0.0"). dispatch.mjs lives in src/, so ../package.json
// resolves the repo root both in-repo and when installed.
const { version: VERSION } = createRequire(import.meta.url)("../package.json");

export async function dispatch(argv, mode = "legacy") {
const parsed = parseArgs(argv);
Expand Down
7 changes: 7 additions & 0 deletions tests/bins.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { test } from "node:test";
import assert from "node:assert/strict";
import { execFile } from "node:child_process";
import { promisify } from "node:util";
import { readFileSync } from "node:fs";

const exec = promisify(execFile);

Expand All @@ -20,3 +21,9 @@ test("legacy bin still dispatches the add command surface", async () => {
const { stdout } = await exec(process.execPath, ["bin/adlc-skills-cli.mjs", "agents"]);
assert.match(stdout, /OpenCode/);
});

test("version output matches package.json (no drift)", async () => {
const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
const { stdout } = await exec(process.execPath, ["bin/adlc-cli.mjs", "version"]);
assert.equal(stdout.trim(), `adlc-cli ${pkg.version}`);
});
Loading