Skip to content

Commit 0b9e6b7

Browse files
committed
fix(cli): restore documented help forms
1 parent 1fcd1f9 commit 0b9e6b7

2 files changed

Lines changed: 118 additions & 2 deletions

File tree

src/main.ts

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,29 @@ function helpRowCont(leftW: number, right: string): string {
7777

7878
/** Print grouped help (rounded panels). */
7979
function renderHelp(): void {
80-
const gsLefts = ["index login", 'index intent create "..."', "index negotiation list", "index opportunity list"];
80+
const gsLefts = [
81+
"index login",
82+
"index login --token <token>",
83+
"index logout",
84+
'index intent create "..."',
85+
"index negotiation list",
86+
"index opportunity list",
87+
];
8188
const gsLW = Math.max(...gsLefts.map((s) => s.length));
8289

90+
const formsLefts = [
91+
'index conversation "message"',
92+
"index conversation --session <id>",
93+
"index sync --json",
94+
"index profile create",
95+
"index profile update",
96+
"index intent list",
97+
"index negotiation list",
98+
"index opportunity list",
99+
"index opportunity discover",
100+
];
101+
const formsLW = Math.max(...formsLefts.map((s) => s.length));
102+
83103
const cmdLefts = [
84104
"pattern",
85105
"example",
@@ -96,7 +116,29 @@ function renderHelp(): void {
96116
];
97117
const cmdLW = Math.max(...cmdLefts.map((s) => s.length));
98118

99-
const optLefts = ["--api-url <url>", "--token <token>", "--json", "--help", "--version"];
119+
const optLefts = [
120+
"--api-url <url>",
121+
"--app-url <url>",
122+
"--token <token>",
123+
"--session <id>",
124+
"--archived",
125+
"--status <status>",
126+
"--limit <n>",
127+
"--since <date>",
128+
"--json",
129+
"--name <name>",
130+
"--gmail",
131+
"--objective <text>",
132+
"--target <uid>",
133+
"--introduce <uid>",
134+
"--linkedin <url>",
135+
"--github <url>",
136+
"--twitter <url>",
137+
"--title <text>",
138+
"--details <text>",
139+
"--help",
140+
"--version",
141+
];
100142
const optLW = Math.max(...optLefts.map((s) => s.length));
101143

102144
console.log();
@@ -107,11 +149,26 @@ function renderHelp(): void {
107149

108150
panel("getting started", [
109151
helpRowCmd(gsLW, "index login", "authenticate via browser"),
152+
helpRowCmd(gsLW, "index login --token <token>", "authenticate with a bearer token"),
153+
helpRowCmd(gsLW, "index logout", "clear stored session"),
110154
helpRowCmd(gsLW, 'index intent create "..."', "describe what you're looking for"),
111155
helpRowCmd(gsLW, "index negotiation list", "see agent debates in progress"),
112156
helpRowCmd(gsLW, "index opportunity list", "see what was found for you"),
113157
]);
114158

159+
panel("common forms", [
160+
helpRowCmd(formsLW, 'index conversation "message"', "send a one-shot agent message"),
161+
helpRowCmd(formsLW, "index conversation --session <id>", "resume an agent chat session"),
162+
helpRowCmd(formsLW, "index sync --json", "print synced context as JSON"),
163+
"",
164+
helpRowCmd(formsLW, "index profile create", "use social URL flags"),
165+
helpRowCmd(formsLW, "index profile update", "use action text or --details"),
166+
helpRowCmd(formsLW, "index intent list", "supports --archived and --limit"),
167+
helpRowCmd(formsLW, "index negotiation list", "supports --since and --limit"),
168+
helpRowCmd(formsLW, "index opportunity list", "supports --status and --limit"),
169+
helpRowCmd(formsLW, "index opportunity discover", "supports --target and --introduce"),
170+
]);
171+
115172
panel("commands", [
116173
helpRowDim(cmdLW, "pattern", "index <command> [args] [options]"),
117174
helpRowDim(cmdLW, "example", 'index intent create "looking for a CTO"'),
@@ -134,8 +191,24 @@ function renderHelp(): void {
134191

135192
panel("options", [
136193
helpRowDim(optLW, "--api-url <url>", "override API server URL"),
194+
helpRowDim(optLW, "--app-url <url>", "override app URL for login"),
137195
helpRowDim(optLW, "--token <token>", "provide bearer token directly"),
196+
helpRowDim(optLW, "--session <id>", "resume a chat session"),
197+
helpRowDim(optLW, "--archived", "include archived signals"),
198+
helpRowDim(optLW, "--status <status>", "filter opportunities by status"),
199+
helpRowDim(optLW, "--limit <n>", "limit number of results"),
200+
helpRowDim(optLW, "--since <date>", "filter by ISO date or duration"),
138201
helpRowDim(optLW, "--json", "output raw JSON"),
202+
helpRowDim(optLW, "--name <name>", "name for contact add"),
203+
helpRowDim(optLW, "--gmail", "import contacts from Gmail"),
204+
helpRowDim(optLW, "--objective <text>", "objective for scrape command"),
205+
helpRowDim(optLW, "--target <uid>", "target user for opportunity discovery"),
206+
helpRowDim(optLW, "--introduce <uid>", "source user for introduction discovery"),
207+
helpRowDim(optLW, "--linkedin <url>", "LinkedIn URL for profile create"),
208+
helpRowDim(optLW, "--github <url>", "GitHub URL for profile create"),
209+
helpRowDim(optLW, "--twitter <url>", "Twitter URL for profile create"),
210+
helpRowDim(optLW, "--title <text>", "title for network update"),
211+
helpRowDim(optLW, "--details <text>", "details for profile update"),
139212
helpRowDim(optLW, "--help", "show help for any command"),
140213
helpRowDim(optLW, "--version", "show version"),
141214
]);

tests/help-output.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { describe, expect, it } from "bun:test";
2+
import { spawnSync } from "node:child_process";
3+
import { join } from "node:path";
4+
5+
import { stripAnsi } from "../src/output";
6+
7+
const CLI_ROOT = join(import.meta.dir, "..");
8+
9+
function renderHelp(): string {
10+
const result = spawnSync("bun", ["src/main.ts", "--help"], {
11+
cwd: CLI_ROOT,
12+
encoding: "utf-8",
13+
});
14+
15+
expect(result.status).toBe(0);
16+
expect(result.stderr).toBe("");
17+
return stripAnsi(result.stdout);
18+
}
19+
20+
describe("main help output", () => {
21+
it("documents supported command forms and options", () => {
22+
const help = renderHelp();
23+
24+
for (const expected of [
25+
"index login --token <token>",
26+
"index logout",
27+
'index conversation "message"',
28+
"index conversation --session <id>",
29+
"index sync --json",
30+
"--app-url <url>",
31+
"--session <id>",
32+
"--archived",
33+
"--status <status>",
34+
"--since <date>",
35+
"--objective <text>",
36+
"--target <uid>",
37+
"--introduce <uid>",
38+
"--details <text>",
39+
]) {
40+
expect(help).toContain(expected);
41+
}
42+
});
43+
});

0 commit comments

Comments
 (0)