@jini-ai/cli 0.1.0
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/LICENSE +201 -0
- package/dist/command-registry.d.ts +82 -0
- package/dist/command-registry.d.ts.map +1 -0
- package/dist/command-registry.js +88 -0
- package/dist/command-registry.js.map +1 -0
- package/dist/daemon-command.d.ts +42 -0
- package/dist/daemon-command.d.ts.map +1 -0
- package/dist/daemon-command.js +103 -0
- package/dist/daemon-command.js.map +1 -0
- package/dist/daemon-url.d.ts +68 -0
- package/dist/daemon-url.d.ts.map +1 -0
- package/dist/daemon-url.js +99 -0
- package/dist/daemon-url.js.map +1 -0
- package/dist/errors.d.ts +82 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +103 -0
- package/dist/errors.js.map +1 -0
- package/dist/flags.d.ts +61 -0
- package/dist/flags.d.ts.map +1 -0
- package/dist/flags.js +111 -0
- package/dist/flags.js.map +1 -0
- package/dist/http.d.ts +63 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +226 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/local-daemon-discovery.d.ts +31 -0
- package/dist/local-daemon-discovery.d.ts.map +1 -0
- package/dist/local-daemon-discovery.js +53 -0
- package/dist/local-daemon-discovery.js.map +1 -0
- package/dist/main.d.ts +21 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +231 -0
- package/dist/main.js.map +1 -0
- package/dist/prompt.d.ts +83 -0
- package/dist/prompt.d.ts.map +1 -0
- package/dist/prompt.js +198 -0
- package/dist/prompt.js.map +1 -0
- package/dist/redact.d.ts +48 -0
- package/dist/redact.d.ts.map +1 -0
- package/dist/redact.js +134 -0
- package/dist/redact.js.map +1 -0
- package/dist/run-command.d.ts +39 -0
- package/dist/run-command.d.ts.map +1 -0
- package/dist/run-command.js +291 -0
- package/dist/run-command.js.map +1 -0
- package/dist/tokens.d.ts +3 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +12 -0
- package/dist/tokens.js.map +1 -0
- package/dist/usage.d.ts +24 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +25 -0
- package/dist/usage.js.map +1 -0
- package/dist/version-command.d.ts +38 -0
- package/dist/version-command.d.ts.map +1 -0
- package/dist/version-command.js +78 -0
- package/dist/version-command.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module version-command
|
|
3
|
+
*
|
|
4
|
+
* `version` — prints just the running daemon's version string. Sourced from
|
|
5
|
+
* `GET /api/daemon/status`'s `version` field (`packages/http/src/daemon-status.ts`,
|
|
6
|
+
* `DaemonStatusResponse.version`) — the same route `daemon-command.ts`'s `daemon status`
|
|
7
|
+
* already calls. `packages/cli/source-map.md`'s original UNCLEAR verdict on a standalone
|
|
8
|
+
* `version` command noted "@jini-ai/http has no version route yet ... nothing to call"; that
|
|
9
|
+
* blocker never actually required a *separate* route — `daemonStatusRoute`'s response body
|
|
10
|
+
* already carries a `version` field, so no new HTTP route was added for this command. It just
|
|
11
|
+
* extracts and prints that one field instead of the full status envelope `daemon status` prints.
|
|
12
|
+
*
|
|
13
|
+
* Same DI/testing/`resolveBaseUrl` conventions as `daemon-command.ts`'s `daemon status`/`daemon
|
|
14
|
+
* stop` (this file duplicates rather than imports their small `errorOptions`/`transportOptions`
|
|
15
|
+
* helpers, matching that file's own precedent of each command module owning its own copy rather
|
|
16
|
+
* than sharing a not-otherwise-needed abstraction across files).
|
|
17
|
+
*/
|
|
18
|
+
import { exitWithStructuredError } from './errors.js';
|
|
19
|
+
import { getJsonFromDaemon } from './http.js';
|
|
20
|
+
import { renderUsage } from './usage.js';
|
|
21
|
+
function defaultWrite(text) {
|
|
22
|
+
process.stdout.write(text);
|
|
23
|
+
}
|
|
24
|
+
function defaultWriteErr(text) {
|
|
25
|
+
process.stderr.write(text);
|
|
26
|
+
}
|
|
27
|
+
const VERSION_USAGE = renderUsage({
|
|
28
|
+
usage: ['version'],
|
|
29
|
+
description: 'Prints the running daemon\'s version string (nothing else — see "daemon status" for the full status envelope).',
|
|
30
|
+
});
|
|
31
|
+
/** Builds `{write, exit, exitCodes?}` for `errors.ts`'s structured-error helpers, never assigning `exitCodes` when unset (required under `exactOptionalPropertyTypes`). */
|
|
32
|
+
function errorOptions(deps) {
|
|
33
|
+
return {
|
|
34
|
+
write: deps.writeErr ?? defaultWriteErr,
|
|
35
|
+
exit: deps.exit ?? ((code) => process.exit(code)),
|
|
36
|
+
...(deps.exitCodes !== undefined ? { exitCodes: deps.exitCodes } : {}),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Builds the transport-call options object for `getJsonFromDaemon`, only ever including a key when its value is actually set. */
|
|
40
|
+
function transportOptions(deps) {
|
|
41
|
+
return {
|
|
42
|
+
...(deps.fetchImpl !== undefined ? { fetchImpl: deps.fetchImpl } : {}),
|
|
43
|
+
...(deps.writeErr !== undefined ? { write: deps.writeErr } : {}),
|
|
44
|
+
...(deps.exit !== undefined ? { exit: deps.exit } : {}),
|
|
45
|
+
...(deps.exitCodes !== undefined ? { exitCodes: deps.exitCodes } : {}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Extracts a non-empty `version` string out of `/api/daemon/status`'s parsed JSON body. A daemon
|
|
50
|
+
* that responds 2xx but omits (or mistypes) `version` is exactly as "not behaving like a Jini
|
|
51
|
+
* daemon" as an unreachable one — this reuses the `daemon-not-running` code (the same fallback
|
|
52
|
+
* `structuredHttpFailure` itself defaults to elsewhere in this package) rather than inventing a
|
|
53
|
+
* new exit code for this one caller.
|
|
54
|
+
*/
|
|
55
|
+
function extractVersion(deps, body) {
|
|
56
|
+
if (typeof body === 'object' && body !== null) {
|
|
57
|
+
const version = body.version;
|
|
58
|
+
if (typeof version === 'string' && version.length > 0)
|
|
59
|
+
return version;
|
|
60
|
+
}
|
|
61
|
+
return exitWithStructuredError({ code: 'daemon-not-running', message: '/api/daemon/status response did not include a version string' }, errorOptions(deps));
|
|
62
|
+
}
|
|
63
|
+
/** `version` */
|
|
64
|
+
export async function versionCommand(args, deps) {
|
|
65
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
66
|
+
(deps.write ?? defaultWrite)(`${VERSION_USAGE}\n`);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const baseUrl = await deps.resolveBaseUrl();
|
|
70
|
+
const result = await getJsonFromDaemon(baseUrl, '/api/daemon/status', transportOptions(deps));
|
|
71
|
+
const version = extractVersion(deps, result);
|
|
72
|
+
(deps.write ?? defaultWrite)(`${version}\n`);
|
|
73
|
+
}
|
|
74
|
+
/** Registers `version` against `registry`. */
|
|
75
|
+
export function registerVersionCommand(registry, deps) {
|
|
76
|
+
registry.add('version', (args) => versionCommand(args, deps), { usage: VERSION_USAGE });
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=version-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version-command.js","sourceRoot":"","sources":["../src/version-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,uBAAuB,EAAsB,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAkBzC,SAAS,YAAY,CAAC,IAAY;IAChC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,aAAa,GAAG,WAAW,CAAC;IAChC,KAAK,EAAE,CAAC,SAAS,CAAC;IAClB,WAAW,EAA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0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/AINSEP/Jini.git",
|
|
8
|
+
"directory": "packages/cli"
|
|
9
|
+
},
|
|
10
|
+
"jini": {
|
|
11
|
+
"domain": "server",
|
|
12
|
+
"kind": "cli",
|
|
13
|
+
"runtime": "node",
|
|
14
|
+
"admission": "locked"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"bin": {
|
|
24
|
+
"jini": "./dist/main.js"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"!dist/**/*.test.js",
|
|
29
|
+
"!dist/**/*.test.d.ts",
|
|
30
|
+
"!dist/**/*.test.js.map",
|
|
31
|
+
"!dist/**/*.test.d.ts.map",
|
|
32
|
+
"!dist/**/__tests__/**"
|
|
33
|
+
],
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public",
|
|
36
|
+
"registry": "https://registry.npmjs.org"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@jini-ai/core": "0.1.0",
|
|
40
|
+
"@jini-ai/sidecar": "0.1.0"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc -p tsconfig.json && chmod +x dist/main.js",
|
|
44
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"test:coverage": "vitest run --coverage"
|
|
47
|
+
}
|
|
48
|
+
}
|