@leemour/cli-messaging 0.139.0 → 0.140.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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @leemour/cli-messaging
2
2
 
3
3
  The messenger-neutral half of a messaging command line tool, shared by
4
- [`tg-cli`](https://github.com/leemour/tg-cli) and, later, [`max-cli`](https://github.com/leemour/max-cli).
4
+ [`tg-cli`](https://github.com/leemour/tg-cli) and [`max-cli`](https://github.com/leemour/max-cli).
5
5
  Built on [`@leemour/cli-core`](https://github.com/leemour/cli-core), a peer dependency: the CLI installs
6
6
  it itself, so the install holds one copy.
7
7
 
@@ -48,6 +48,15 @@ Without support, a validated target returns `url: null`, `access: unavailable`,
48
48
  Offline validates this account's stored message and returns reason `offline`, without connecting.
49
49
  A locator for another messenger or account is refused. Singular `link` differs from graph `links`.
50
50
 
51
+ ## Command discovery
52
+
53
+ To discover arguments without reading the whole command tree, run
54
+ `<cli> commands messages evidence --json`. Replace the path with any command or group;
55
+ `<cli> commands messages --json` includes its descendants. The response retains global options
56
+ and exit codes, includes options inherited from ancestor groups, and resolves command aliases.
57
+ Give one command path per call; inspect other groups in separate calls.
58
+ `<cli> commands --json` still returns the full tree.
59
+
51
60
  ## Evidence packets for agents
52
61
 
53
62
  `prepareEvidencePacket` from `@leemour/cli-messaging/services` packages a message page that the
@@ -1 +1 @@
1
- {"version":3,"file":"commands-command.d.ts","sourceRoot":"","sources":["../../src/cli/commands-command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAI3C;;;GAGG;AACH,eAAO,MAAM,QAAQ,IAAI,CAAA;AAEzB;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAS,WAAW,KAAG,OA6B7C,CAAA"}
1
+ {"version":3,"file":"commands-command.d.ts","sourceRoot":"","sources":["../../src/cli/commands-command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAI3C;;;GAGG;AACH,eAAO,MAAM,QAAQ,IAAI,CAAA;AAEzB;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAS,WAAW,KAAG,OAiC7C,CAAA"}
@@ -1,4 +1,4 @@
1
- import { EXIT_CODES, GENERIC_FAILURE } from "@leemour/cli-core";
1
+ import { CliError, EXIT_CODES, GENERIC_FAILURE } from "@leemour/cli-core";
2
2
  import { describeOptions, describeProgram, flatten } from "@leemour/cli-core/commands";
3
3
  import { Command } from "commander";
4
4
  import { outputFor } from "./context.js";
@@ -13,11 +13,14 @@ export const CONTRACT = 0;
13
13
  * settings file: which commands exist does not depend on whether this machine has logged in.
14
14
  */
15
15
  export const commandsCommand = (app) => new Command("commands")
16
- .description("every command, option and exit code as JSON — what an agent reads instead of --help")
17
- .action(function () {
16
+ .description("commands, options and exit codes as JSON — inspect one command path per call")
17
+ .argument("[path...]", "one command path, for example: messages search; inspect other groups in separate calls")
18
+ .action(function (path) {
18
19
  const root = rootOf(this);
19
20
  const { renderer, format } = outputFor(this);
20
- const commands = describeProgram(root);
21
+ const all = describeProgram(root);
22
+ const scoped = path.length > 0 ? scopeOf(root, all, path) : undefined;
23
+ const commands = scoped ? [scoped.command] : all;
21
24
  if (format === "pretty") {
22
25
  renderer.result(flatten(commands).map(({ usage, summary, description, mutates, state }) => ({
23
26
  command: usage,
@@ -33,8 +36,34 @@ export const commandsCommand = (app) => new Command("commands")
33
36
  contract: CONTRACT,
34
37
  description: root.description(),
35
38
  globalOptions: describeOptions(root),
39
+ ...(scoped ? { scope: scoped.command.path, inheritedOptions: scoped.inheritedOptions } : {}),
36
40
  commands,
37
41
  exitCodes: { ok: 0, generic_failure: GENERIC_FAILURE, ...EXIT_CODES },
38
42
  });
39
43
  });
44
+ const scopeOf = (root, all, path) => {
45
+ let parent = root;
46
+ let available = all;
47
+ let selected;
48
+ const inheritedOptions = [];
49
+ for (const word of path) {
50
+ const child = parent.commands.find((command) => command.name() === word || command.aliases().includes(word));
51
+ const described = child && available.find(({ name }) => name === child.name());
52
+ if (!child || !described) {
53
+ const prefix = selected?.path ?? [];
54
+ const choices = available.map(({ name }) => name);
55
+ throw new CliError("validation_error", `unknown command path "${path.join(" ")}" — inspect \`${[root.name(), "commands", ...prefix, "--json"].join(" ")}\`; ` +
56
+ (choices.length ? `available here: ${choices.join(", ")}. ` : "this command has no subcommands. ") +
57
+ `Give one command path per call, not a list of groups: \`${root.name()} commands messages --json\` ` +
58
+ `and \`${root.name()} commands chats --json\` are separate calls`, { path, at: word, available: choices });
59
+ }
60
+ if (selected && selected.options.length > 0) {
61
+ inheritedOptions.push({ path: selected.path, options: [...selected.options] });
62
+ }
63
+ selected = described;
64
+ parent = child;
65
+ available = described.commands;
66
+ }
67
+ return { command: selected, inheritedOptions };
68
+ };
40
69
  //# sourceMappingURL=commands-command.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"commands-command.js","sourceRoot":"","sources":["../../src/cli/commands-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACtF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAA;AAEzB;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAgB,EAAW,EAAE,CAC3D,IAAI,OAAO,CAAC,UAAU,CAAC;KACpB,WAAW,CAAC,qFAAqF,CAAC;KA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AAE,QAAuB,EAAE,gBAAgB,EAAE,CAAA;AAC/D,CAAC,CAAA"}
@@ -34,5 +34,5 @@ export type OpenDatabase = (path: string) => CacheDatabase;
34
34
  *
35
35
  * `foreign_keys` is off by default in SQLite, which surprises everyone once.
36
36
  */
37
- export declare const PRAGMAS = "\n PRAGMA journal_mode = WAL;\n PRAGMA busy_timeout = 5000;\n PRAGMA foreign_keys = ON;\n";
37
+ export declare const PRAGMAS = "\n PRAGMA busy_timeout = 5000;\n PRAGMA journal_mode = WAL;\n PRAGMA foreign_keys = ON;\n";
38
38
  //# sourceMappingURL=driver.d.ts.map
@@ -19,8 +19,8 @@
19
19
  * `foreign_keys` is off by default in SQLite, which surprises everyone once.
20
20
  */
21
21
  export const PRAGMAS = `
22
- PRAGMA journal_mode = WAL;
23
22
  PRAGMA busy_timeout = 5000;
23
+ PRAGMA journal_mode = WAL;
24
24
  PRAGMA foreign_keys = ON;
25
25
  `;
26
26
  //# sourceMappingURL=driver.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leemour/cli-messaging",
3
- "version": "0.139.0",
3
+ "version": "0.140.0",
4
4
  "description": "The messenger-neutral half of a messaging CLI: domain model, message locators, rendering, name resolution, the SQLite seam, the command skeleton and shared read commands, the send guard, run records and the message store",
5
5
  "license": "MIT",
6
6
  "author": "Viacheslav Ptsarev",
package/parity.json CHANGED
@@ -1589,8 +1589,7 @@
1589
1589
  }
1590
1590
  },
1591
1591
  "messages link": {
1592
- "in": [],
1593
- "planned": { "max": "B1c feat/messages-link", "tg": "B1c feat/messages-link" }
1592
+ "in": "all"
1594
1593
  },
1595
1594
  "messages links": {
1596
1595
  "in": "all"