@bli-cockpit/cli 0.2.58 → 0.2.59

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.
Files changed (39) hide show
  1. package/dist/commands/browser-open.js +88 -0
  2. package/dist/commands/docs.js +27 -6
  3. package/dist/commands/doctor-report.js +17 -1
  4. package/dist/commands/doctor.js +12 -2
  5. package/dist/commands/heartbeat.js +65 -1
  6. package/dist/commands/jarvis-answer-envelope.js +80 -0
  7. package/dist/commands/jarvis-turn.js +16 -1
  8. package/dist/commands/jarvis.js +3 -0
  9. package/dist/commands/local-args-collector-setup.js +17 -0
  10. package/dist/commands/local-args-tower-admin.js +12 -2
  11. package/dist/commands/local-args-tower-docs-msg.js +95 -6
  12. package/dist/commands/local-args-tower-search.js +50 -0
  13. package/dist/commands/local-args-tower.js +4 -1
  14. package/dist/commands/local-args.js +24 -13
  15. package/dist/commands/local-command-shapes.js +12 -0
  16. package/dist/commands/local-help-commands.js +643 -0
  17. package/dist/commands/local-help.js +8 -581
  18. package/dist/commands/local.js +3 -0
  19. package/dist/commands/login.js +91 -8
  20. package/dist/commands/memory-install-claude.js +35 -15
  21. package/dist/commands/memory-install-codex-hooks.js +200 -0
  22. package/dist/commands/memory-install-codex.js +12 -2
  23. package/dist/commands/memory-install-receipt.js +222 -0
  24. package/dist/commands/memory-install-report.js +25 -1
  25. package/dist/commands/memory-install.js +76 -2
  26. package/dist/commands/msg.js +85 -2
  27. package/dist/commands/onboard-completion.js +47 -0
  28. package/dist/commands/onboard-setup.js +82 -2
  29. package/dist/commands/ops-render-memory.js +76 -0
  30. package/dist/commands/ops-render.js +1 -0
  31. package/dist/commands/ops.js +56 -1
  32. package/dist/commands/public-root.js +1 -1
  33. package/dist/commands/search.js +122 -0
  34. package/dist/commands/setup-receipt-lines.js +71 -0
  35. package/dist/commands/setup-receipt.js +241 -0
  36. package/dist/commands/status.js +20 -1
  37. package/dist/local-state-pairing-code.js +200 -0
  38. package/dist/local-state.js +6 -0
  39. package/package.json +4 -4
@@ -20,9 +20,11 @@ export function parseDocsArgs(args) {
20
20
  "--visibility",
21
21
  "--file",
22
22
  "--body-stdin",
23
+ "--query",
24
+ "--limit",
23
25
  "--json",
24
26
  ],
25
- valueFlags: ["--home", "--dashboard-url", "--title", "--parent", "--visibility", "--file"],
27
+ valueFlags: ["--home", "--dashboard-url", "--title", "--parent", "--visibility", "--file", "--query", "--limit"],
26
28
  });
27
29
  const first = values.positionals[0];
28
30
  const action = (first === undefined ? "list" : first);
@@ -57,6 +59,18 @@ export function parseDocsArgs(args) {
57
59
  if (action === "create" && !title) {
58
60
  throw new Error("docs create needs --title.");
59
61
  }
62
+ // BLI-3737: narrowing belongs to `list` only. `--parent` keeps its create/
63
+ // update meaning elsewhere (which parent to file the document under); on
64
+ // `list` the same word names which parent to list UNDER, plus the literal
65
+ // `root` for the top of the tree.
66
+ const query = optionalNonEmpty(values.flags.get("--query"));
67
+ if (query && action !== "list") {
68
+ throw new Error("--query belongs to `cockpit docs list`.");
69
+ }
70
+ const limit = optionalPositiveInteger(values.flags.get("--limit"), "--limit");
71
+ if (limit !== undefined && action !== "list") {
72
+ throw new Error("--limit belongs to `cockpit docs list`.");
73
+ }
60
74
  return {
61
75
  kind: "docs",
62
76
  action,
@@ -69,22 +83,92 @@ export function parseDocsArgs(args) {
69
83
  visibility: visibility,
70
84
  filePath: optionalNonEmpty(values.flags.get("--file")),
71
85
  bodyStdin: values.booleans.has("--body-stdin"),
86
+ ...(query ? { query } : {}),
87
+ ...(limit === undefined ? {} : { limit }),
72
88
  json: values.booleans.has("--json"),
73
89
  };
74
90
  }
75
- const MSG_ACTIONS = new Set(["channels", "read", "send", "thread"]);
91
+ const MSG_ACTIONS = new Set(["channels", "read", "send", "thread", "create", "dm"]);
76
92
  const MSG_ACTIONS_NEEDING_A_CHANNEL = new Set(["read", "send"]);
93
+ /**
94
+ * `--members a@x.test,b@y.test` — addresses only, split on commas, never
95
+ * fuzzy (BLI-3749). The door resolves each one exactly, so a typo comes back
96
+ * as `person_not_found` naming the address rather than as a stranger added
97
+ * to a private channel.
98
+ */
99
+ function parseMemberEmails(raw) {
100
+ const value = optionalNonEmpty(raw);
101
+ if (!value)
102
+ return undefined;
103
+ const emails = value
104
+ .split(",")
105
+ .map((part) => part.trim())
106
+ .filter((part) => part !== "");
107
+ if (emails.length === 0)
108
+ throw new Error("msg create --members needs at least one email address.");
109
+ const notAnAddress = emails.find((email) => !email.includes("@"));
110
+ if (notAnAddress) {
111
+ throw new Error(`msg create --members takes email addresses; "${notAnAddress}" is not one.`);
112
+ }
113
+ return emails;
114
+ }
77
115
  export function parseMsgArgs(args) {
78
116
  const values = parseNamedArgs(args, {
79
- allowedFlags: ["--home", "--dashboard-url", "--channel", "--thread", "--limit", "--json"],
80
- valueFlags: ["--home", "--dashboard-url", "--channel", "--thread", "--limit"],
117
+ allowedFlags: [
118
+ "--home",
119
+ "--dashboard-url",
120
+ "--channel",
121
+ "--thread",
122
+ "--limit",
123
+ "--private",
124
+ "--members",
125
+ "--description",
126
+ "--json",
127
+ ],
128
+ valueFlags: ["--home", "--dashboard-url", "--channel", "--thread", "--limit", "--members", "--description"],
81
129
  });
82
130
  const first = values.positionals[0];
83
131
  const action = (first === undefined ? "channels" : first);
84
132
  if (!MSG_ACTIONS.has(action)) {
85
- throw new Error(`Unknown msg command: ${first}. Try channels, read, send, or thread.`);
133
+ throw new Error(`Unknown msg command: ${first}. Try channels, read, send, thread, create, or dm.`);
86
134
  }
87
135
  const rest = values.positionals.slice(first === undefined ? 0 : 1);
136
+ let channelName;
137
+ let dmEmail;
138
+ if (action === "create") {
139
+ channelName = optionalNonEmpty(rest[0]);
140
+ if (!channelName)
141
+ throw new Error("msg create needs a channel name, e.g. `cockpit msg create general`.");
142
+ if (rest.length > 1)
143
+ throw new Error(`msg create takes one channel name, not ${rest.length}.`);
144
+ // `#general` is how a person says it and how `read`/`send` accept it, so
145
+ // the leading # is dropped here rather than becoming part of the name.
146
+ if (channelName.startsWith("#"))
147
+ channelName = channelName.slice(1);
148
+ if (channelName === "")
149
+ throw new Error("msg create needs a channel name, e.g. `cockpit msg create general`.");
150
+ }
151
+ else if (action === "dm") {
152
+ dmEmail = optionalNonEmpty(rest[0]);
153
+ if (!dmEmail)
154
+ throw new Error("msg dm needs the person's email address, e.g. `cockpit msg dm ada@example.com`.");
155
+ if (rest.length > 1)
156
+ throw new Error(`msg dm takes one email address, not ${rest.length}.`);
157
+ if (!dmEmail.includes("@"))
158
+ throw new Error(`msg dm takes an email address; "${dmEmail}" is not one.`);
159
+ }
160
+ const isPrivate = values.booleans.has("--private");
161
+ if (isPrivate && action !== "create") {
162
+ throw new Error("--private belongs to `cockpit msg create`.");
163
+ }
164
+ const memberEmails = parseMemberEmails(values.flags.get("--members"));
165
+ if (memberEmails && action !== "create") {
166
+ throw new Error("--members belongs to `cockpit msg create`.");
167
+ }
168
+ const description = optionalNonEmpty(values.flags.get("--description"));
169
+ if (description && action !== "create") {
170
+ throw new Error("--description belongs to `cockpit msg create`.");
171
+ }
88
172
  let channelRef;
89
173
  if (MSG_ACTIONS_NEEDING_A_CHANNEL.has(action)) {
90
174
  channelRef = optionalNonEmpty(rest[0]);
@@ -99,7 +183,7 @@ export function parseMsgArgs(args) {
99
183
  if (rest.length > 1)
100
184
  throw new Error(`msg thread takes one thread id, not ${rest.length}.`);
101
185
  }
102
- else if (rest.length > 0) {
186
+ else if (action !== "create" && action !== "dm" && rest.length > 0) {
103
187
  throw new Error(`msg ${action} does not take "${rest[0]}".`);
104
188
  }
105
189
  const threadFlag = optionalNonEmpty(values.flags.get("--thread"));
@@ -119,6 +203,11 @@ export function parseMsgArgs(args) {
119
203
  homeDir: optionalNonEmpty(values.flags.get("--home")),
120
204
  dashboardUrl: optionalUrl(values.flags.get("--dashboard-url")),
121
205
  ...(channelRef ? { channelRef } : {}),
206
+ ...(channelName ? { channelName } : {}),
207
+ ...(dmEmail ? { dmEmail } : {}),
208
+ ...(memberEmails ? { memberEmails } : {}),
209
+ ...(description ? { description } : {}),
210
+ isPrivate,
122
211
  ...(threadId ? { threadId } : {}),
123
212
  ...(limit === undefined ? {} : { limit }),
124
213
  json: values.booleans.has("--json"),
@@ -0,0 +1,50 @@
1
+ /**
2
+ * `cockpit search` argument parsing (BLI-3728).
3
+ *
4
+ * Its own sibling of `local-args-tower.ts` rather than folded into
5
+ * `local-args-tower-pages.ts` or `-docs-msg.ts`: search is not one surface's
6
+ * verb, it is the door OVER all of them — documents, messages, issues, meeting
7
+ * notes and memory — and putting it under any one family's doc comment would
8
+ * say something untrue about what it reads.
9
+ *
10
+ * The query is a POSITIONAL, not a flag, because that is how every search
11
+ * command a person has ever typed works (`grep`, `rg`, `gh search`). Several
12
+ * positionals are joined with a space so `cockpit search storage ceiling`
13
+ * behaves the way it looks, without demanding quotes.
14
+ */
15
+ import { optionalNonEmpty, optionalPositiveInteger, optionalUrl, parseNamedArgs, } from "./local-arg-values.js";
16
+ /** The five corpora. Kept here so an unknown kind is refused BEFORE a round trip. */
17
+ export const SEARCH_KINDS = ["doc", "msg", "issue", "note", "memory"];
18
+ export function parseSearchArgs(args) {
19
+ const values = parseNamedArgs(args, {
20
+ allowedFlags: ["--home", "--dashboard-url", "--kind", "--limit", "--json"],
21
+ valueFlags: ["--home", "--dashboard-url", "--kind", "--limit"],
22
+ });
23
+ const query = values.positionals.join(" ").trim();
24
+ if (query.length === 0) {
25
+ throw new Error('search needs something to search for, e.g. `cockpit search "storage ceiling"`.');
26
+ }
27
+ const kindFlag = optionalNonEmpty(values.flags.get("--kind"));
28
+ let kinds;
29
+ if (kindFlag) {
30
+ kinds = [];
31
+ for (const part of kindFlag.split(",").map((entry) => entry.trim()).filter(Boolean)) {
32
+ if (!SEARCH_KINDS.includes(part)) {
33
+ throw new Error(`search --kind must be one or more of ${SEARCH_KINDS.join(", ")} — not "${part}".`);
34
+ }
35
+ if (!kinds.includes(part))
36
+ kinds.push(part);
37
+ }
38
+ if (kinds.length === 0)
39
+ kinds = undefined;
40
+ }
41
+ return {
42
+ kind: "search",
43
+ query,
44
+ ...(kinds ? { kinds } : {}),
45
+ limit: optionalPositiveInteger(values.flags.get("--limit"), "--limit"),
46
+ homeDir: optionalNonEmpty(values.flags.get("--home")),
47
+ dashboardUrl: optionalUrl(values.flags.get("--dashboard-url")),
48
+ json: values.booleans.has("--json"),
49
+ };
50
+ }
@@ -20,6 +20,8 @@
20
20
  * channels/messages (BLI-3706)
21
21
  * local-args-tower-work.ts issue, project — the issue tracker
22
22
  * (BLI-3716)
23
+ * local-args-tower-search.ts search — one bar over all five
24
+ * corpora (BLI-3728)
23
25
  *
24
26
  * Every name this module has ever exported is still importable from here.
25
27
  */
@@ -27,4 +29,5 @@ export { parseJarvisArgs, parseCorrectArgs } from "./local-args-tower-chat.js";
27
29
  export { parseBriefArgs, WORKBOOK_MIN_WIDTH, parseWorkbookArgs, parseNotesArgs, } from "./local-args-tower-pages.js";
28
30
  export { SCOUT_MIN_PREFIX_LENGTH, parseScoutArgs, parseOpsArgs, SLACK_WORKSPACE_KEYS, parseSlackArgs, parseSettingsArgs, parseTeamArgs, parseModelArgs, } from "./local-args-tower-admin.js";
29
31
  export { parseDocsArgs, parseMsgArgs, } from "./local-args-tower-docs-msg.js";
30
- export { ISSUE_STATES, parseIssueArgs, parseProjectArgs, } from "./local-args-tower-work.js";
32
+ export { ISSUE_STATES, parseIssueArgs, parseProjectArgs, } from "./local-args-tower-work.js";
33
+ export { SEARCH_KINDS, parseSearchArgs } from "./local-args-tower-search.js";
@@ -1,23 +1,32 @@
1
+ /**
2
+ * What a person may type, and what each subcommand means once typed.
3
+ *
4
+ * Two things live here and nothing else: `LocalCommand`, the shape every
5
+ * command runner is handed, and `parseLocalArgs`, the table that picks which
6
+ * decision table reads the rest of `argv`. The decision tables themselves are
7
+ * next door, one file per half of the product (BLI-3578):
8
+ *
9
+ * local-arg-values.ts argv into named flags, then one question per value
10
+ * local-args-collector.ts the commands that act on THIS machine
11
+ * local-args-tower.ts the commands that talk to Tower
12
+ *
13
+ * Split out of commands/local.ts originally so the command runners read as a
14
+ * table of contents and the parser (pure, independently testable) can change at
15
+ * its own rate. Behavior-preserving extraction throughout: functions moved
16
+ * verbatim, no logic change.
17
+ */
1
18
  import { parseAgentRulesArgs, parseAnalyzeArgs, parseAutostartArgs, parseBackfillArgs, parseCleanArgs, parseDoctorArgs, parseInstallArgs, parseLoginArgs, parseMemoryArgs, parseLogoutArgs, parseOnboardArgs, parseReleaseArgs, parseServeArgs, parseSessionsArgs, parseStartArgs, parseStatusArgs, parseSyncArgs, parseUpdateArgs, } from "./local-args-collector.js";
2
- import { parseBriefArgs, parseCorrectArgs, parseDocsArgs, parseIssueArgs, parseJarvisArgs, parseModelArgs, parseMsgArgs, parseNotesArgs, parseOpsArgs, parseProjectArgs, parseScoutArgs, parseSettingsArgs, parseSlackArgs, parseTeamArgs, parseWorkbookArgs, } from "./local-args-tower.js";
19
+ import { parseBriefArgs, parseCorrectArgs, parseDocsArgs, parseIssueArgs, parseJarvisArgs, parseModelArgs, parseMsgArgs, parseNotesArgs, parseOpsArgs, parseProjectArgs, parseScoutArgs, parseSearchArgs, parseSettingsArgs, parseSlackArgs, parseTeamArgs, parseWorkbookArgs, } from "./local-args-tower.js";
3
20
  // `normalizeUrl` has always been part of this module's surface — `local.ts` and
4
21
  // `local-auth.ts` import it from here — so it stays exported from this address
5
22
  // even though it now lives next door. The same goes for the four names the
6
23
  // Tower parsers publish.
7
24
  export { normalizeUrl } from "./local-arg-values.js";
25
+ // BLI-3728: the command SHAPES moved to a sibling when this file crossed the
26
+ // 700-line ceiling. Re-exported here because ~40 modules and every sibling
27
+ // parser import them from this path.
28
+ export { DOCTOR_SETUP_ALIASES, } from "./local-command-shapes.js";
8
29
  export { SCOUT_MIN_PREFIX_LENGTH, SLACK_WORKSPACE_KEYS, WORKBOOK_MIN_WIDTH, ISSUE_STATES, } from "./local-args-tower.js";
9
- // The six human "set my machine up" doors. They are one thing wearing six
10
- // hats, so they all run the convergence command — but they keep accepting the
11
- // flags they always accepted, because DMs, runbooks and AGENTS.md rules across
12
- // the fleet still spell them out.
13
- export const DOCTOR_SETUP_ALIASES = [
14
- "install",
15
- "onboard",
16
- "login",
17
- "pair",
18
- "update",
19
- "upgrade",
20
- ];
21
30
  export function parseLocalArgs(argv) {
22
31
  const command = argv[0];
23
32
  switch (command) {
@@ -92,6 +101,8 @@ export function parseLocalArgs(argv) {
92
101
  return parseIssueArgs(argv.slice(1));
93
102
  case "project":
94
103
  return parseProjectArgs(argv.slice(1));
104
+ case "search":
105
+ return parseSearchArgs(argv.slice(1));
95
106
  case "release":
96
107
  return parseReleaseArgs(argv.slice(1));
97
108
  default:
@@ -0,0 +1,12 @@
1
+ // The six human "set my machine up" doors. They are one thing wearing six
2
+ // hats, so they all run the convergence command — but they keep accepting the
3
+ // flags they always accepted, because DMs, runbooks and AGENTS.md rules across
4
+ // the fleet still spell them out.
5
+ export const DOCTOR_SETUP_ALIASES = [
6
+ "install",
7
+ "onboard",
8
+ "login",
9
+ "pair",
10
+ "update",
11
+ "upgrade",
12
+ ];