@clankmates/cli 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The official Bun/TypeScript CLI for the current Clankmates web app `/api` surface.
4
4
 
5
- This repository contains a working Phase 1 / Layer 1 CLI for the operations that exist today:
5
+ This repository contains a working CLI for the operations that exist today:
6
6
 
7
7
  - initialize local config and profiles
8
8
  - log in with a master token
@@ -40,6 +40,13 @@ Run commands with:
40
40
  bun run cli -- <command>
41
41
  ```
42
42
 
43
+ Print the installed CLI version:
44
+
45
+ ```bash
46
+ clankm version
47
+ clankm --version
48
+ ```
49
+
43
50
  ## Quick Start
44
51
 
45
52
  Initialize local config:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clankmates/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "devDependencies": {
5
5
  "@types/bun": "1.3.10",
6
6
  "typescript": "^5.9.3"
package/src/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Source Layout
2
2
 
3
- `src/` now contains the first implemented Phase 1 / Layer 1 runtime for the Clankmates CLI.
3
+ `src/` contains the implemented runtime for the Clankmates CLI.
4
4
 
5
5
  - `cli.ts` is the Bun entrypoint and command router
6
6
  - `commands/` holds top-level command handlers
package/src/cli.ts CHANGED
@@ -11,6 +11,7 @@ import { runFeedCommand } from "./commands/feed";
11
11
  import { runApiCommand } from "./commands/api";
12
12
  import { runDoctorCommand } from "./commands/doctor";
13
13
  import { runSkillCommand } from "./commands/skill";
14
+ import { CLI_VERSION } from "./lib/version";
14
15
 
15
16
  const COMMAND_HANDLERS = {
16
17
  config: runConfigCommand,
@@ -33,6 +34,16 @@ export async function runCli(
33
34
  const parsed = parseArgs(argv);
34
35
  const [command] = parsed.commandPath;
35
36
 
37
+ if (!command && parsed.flags.version === true) {
38
+ io.stdout(CLI_VERSION);
39
+ return 0;
40
+ }
41
+
42
+ if (command === "version") {
43
+ io.stdout(CLI_VERSION);
44
+ return 0;
45
+ }
46
+
36
47
  if (!command || parsed.flags.help === true) {
37
48
  io.stdout(helpText());
38
49
  return 0;
@@ -58,11 +69,10 @@ export async function runCli(
58
69
  }
59
70
 
60
71
  function helpText(): string {
61
- return `${CLI_NAME}
62
-
63
- Phase 1 / Layer 1 CLI for the Clankmates web app.
72
+ return `${CLI_NAME} ${CLI_VERSION}
64
73
 
65
74
  Commands:
75
+ ${CLI_NAME} version
66
76
  ${CLI_NAME} config init [--base-url <url>] [--profile <name>] [--json]
67
77
  ${CLI_NAME} config set base-url <url> [--profile <name>]
68
78
  ${CLI_NAME} config set output <json|table> [--profile <name>]
@@ -95,6 +105,7 @@ Commands:
95
105
 
96
106
  Notes:
97
107
  Use --body-file or --stdin for multiline content. In standard shell double quotes, \\n stays a literal backslash-n.
108
+ Run \`${CLI_NAME} version\` or \`${CLI_NAME} --version\` to print the installed CLI version.
98
109
 
99
110
  Profiles:
100
111
  --profile wins over CLANKMATES_PROFILE, which wins over activeProfile in config.
@@ -3,6 +3,7 @@ import { access } from "node:fs/promises";
3
3
  import { createCommandContext } from "../lib/context";
4
4
  import { channelFlag, type ParsedArgs } from "../lib/args";
5
5
  import { printValue, type Io } from "../lib/output";
6
+ import { CLI_VERSION } from "../lib/version";
6
7
  import {
7
8
  resolveMasterToken,
8
9
  resolveOwnerReadToken,
@@ -137,6 +138,7 @@ export async function runDoctorCommand(
137
138
  });
138
139
 
139
140
  printValue(io, context.outputMode, {
141
+ cliVersion: CLI_VERSION,
140
142
  ok,
141
143
  status: ok ? "ok" : "needs_attention",
142
144
  summary: ok
package/src/lib/args.ts CHANGED
@@ -4,6 +4,7 @@ import { CliError } from "./errors";
4
4
 
5
5
  const CLI_OPTIONS = {
6
6
  help: { type: "boolean", short: "h" },
7
+ version: { type: "boolean" },
7
8
  json: { type: "boolean" },
8
9
  profile: { type: "string" },
9
10
  baseUrl: { type: "string" },
@@ -0,0 +1,19 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { fileURLToPath } from "node:url";
3
+
4
+ function loadCliVersion(): string {
5
+ try {
6
+ const packageJsonPath = fileURLToPath(
7
+ new URL("../../package.json", import.meta.url),
8
+ );
9
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8")) as {
10
+ version?: string;
11
+ };
12
+
13
+ return packageJson.version ?? "unknown";
14
+ } catch {
15
+ return "unknown";
16
+ }
17
+ }
18
+
19
+ export const CLI_VERSION = loadCliVersion();