@commissionsight/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 +3 -1
- package/dist/output/help.d.ts +10 -1
- package/dist/output/help.js +30 -1
- package/dist/router.js +6 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -41,7 +41,9 @@ cs upload batch ./statements --workspace "Main Book" --wait --report ./ingest.js
|
|
|
41
41
|
## Using this CLI from an AI agent (Claude Code, etc.)
|
|
42
42
|
|
|
43
43
|
This section is the contract an autonomous agent should rely on. Everything here
|
|
44
|
-
is stable and machine-checkable.
|
|
44
|
+
is stable and machine-checkable. (Running `cs` with **no arguments** prints a
|
|
45
|
+
condensed version of this guidance, so a harness that discovers the binary is
|
|
46
|
+
onboarded immediately.)
|
|
45
47
|
|
|
46
48
|
### 1. Discover the surface programmatically — don't guess
|
|
47
49
|
|
package/dist/output/help.d.ts
CHANGED
|
@@ -3,5 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { Cmd } from '../types.js';
|
|
5
5
|
import type { IO } from '../io.js';
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* The agent prompt shown when `cs` is run with no args — the first thing an AI
|
|
8
|
+
* harness (Claude Code, Codex, Copilot, …) sees. Tells it exactly how to drive
|
|
9
|
+
* the CLI: discover via `cs schema --json`, then parse the --json envelope and
|
|
10
|
+
* branch on exit codes. Kept plain-text so it is safe to capture/parse.
|
|
11
|
+
*/
|
|
12
|
+
export declare function renderAgentBanner(io: IO): void;
|
|
13
|
+
export declare function renderTopHelp(io: IO, table: Cmd[], opts?: {
|
|
14
|
+
agent?: boolean;
|
|
15
|
+
}): void;
|
|
7
16
|
export declare function renderCommandHelp(io: IO, cmd: Cmd, table: Cmd[]): void;
|
package/dist/output/help.js
CHANGED
|
@@ -7,8 +7,37 @@ function optLine(name, spec) {
|
|
|
7
7
|
const choices = spec.choices ? ` (${spec.choices.join('|')})` : '';
|
|
8
8
|
return ` ${flag.padEnd(30)}${spec.desc}${choices}`;
|
|
9
9
|
}
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The agent prompt shown when `cs` is run with no args — the first thing an AI
|
|
12
|
+
* harness (Claude Code, Codex, Copilot, …) sees. Tells it exactly how to drive
|
|
13
|
+
* the CLI: discover via `cs schema --json`, then parse the --json envelope and
|
|
14
|
+
* branch on exit codes. Kept plain-text so it is safe to capture/parse.
|
|
15
|
+
*/
|
|
16
|
+
export function renderAgentBanner(io) {
|
|
17
|
+
io.stdout([
|
|
18
|
+
'━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━',
|
|
19
|
+
'AI agents (Claude Code, Codex, Copilot, Cursor): drive this CLI like so.',
|
|
20
|
+
'',
|
|
21
|
+
'1. Discover everything — run: cs schema --json',
|
|
22
|
+
' → the full command/flag tree (every command, arg, option) as JSON.',
|
|
23
|
+
'2. Add --json to every command. stdout is exactly ONE envelope:',
|
|
24
|
+
' success → {"ok":true,"data":…}',
|
|
25
|
+
' failure → {"ok":false,"error":{"status","code","message"}}',
|
|
26
|
+
' All logs/progress go to stderr, so parse stdout directly.',
|
|
27
|
+
'3. Branch on exit codes — they are stable:',
|
|
28
|
+
' 0 ok · 2 usage · 3 auth · 4 not-found · 5 conflict (retry --replace)',
|
|
29
|
+
' 6 validation · 7 rate-limited · 124 timeout',
|
|
30
|
+
'4. Auth non-interactively: export COMMISSIONSIGHT_TOKEN, or',
|
|
31
|
+
' printf %s "$TOKEN" | cs auth login --token-stdin',
|
|
32
|
+
'5. Destructive commands need --yes. Uploads are idempotent — safe to retry.',
|
|
33
|
+
'━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━',
|
|
34
|
+
'',
|
|
35
|
+
].join('\n'));
|
|
36
|
+
}
|
|
37
|
+
export function renderTopHelp(io, table, opts = {}) {
|
|
11
38
|
io.stdout(`cs ${cliVersion()} — CommissionSight CLI\n\n`);
|
|
39
|
+
if (opts.agent)
|
|
40
|
+
renderAgentBanner(io);
|
|
12
41
|
io.stdout('Usage: cs <command> [subcommand] [args] [flags]\n\n');
|
|
13
42
|
// Group by top-level segment.
|
|
14
43
|
const groups = new Map();
|
package/dist/router.js
CHANGED
|
@@ -96,9 +96,12 @@ export async function run(argv, opts = {}) {
|
|
|
96
96
|
}
|
|
97
97
|
// No command resolved.
|
|
98
98
|
if (!match) {
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
const noArgs = argv.length === 0;
|
|
100
|
+
const wantsHelp = hasFlag(argv, 'help', 'h') || noArgs || words.length === 0;
|
|
101
|
+
if (wantsHelp && (noArgs || hasFlag(argv, 'help', 'h'))) {
|
|
102
|
+
// No-args invocation leads with the AI-agent prompt (the first touchpoint
|
|
103
|
+
// for a harness discovering the `cs` binary).
|
|
104
|
+
renderTopHelp(io, table, { agent: noArgs });
|
|
102
105
|
return EXIT.OK;
|
|
103
106
|
}
|
|
104
107
|
// Unknown command word(s).
|
package/package.json
CHANGED