@wirecat/cli-base 0.80.9 → 0.81.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/CHANGELOG.md CHANGED
@@ -8,6 +8,30 @@ Versions before 0.8.0 are in the [git tags](https://github.com/WireCatLabs/cli-b
8
8
  Every entry says what changed as a caller sees it, why, and what to watch for — the rules are
9
9
  [`docs/dev/CONVENTIONS.md`](docs/dev/CONVENTIONS.md#the-changelog).
10
10
 
11
+ ## 0.81.0 — 07.11.2026
12
+
13
+ ### Added
14
+
15
+ - **`cli-dev manifest` writes `contracts/wirecat.json`, the file WireCat Desktop reads to add a tool it has not
16
+ checked.** Desktop's catalog entry for a tool outside WireCat was written by hand, and every command word in it was
17
+ copied from the CLI. `cli-dev manifest --program dist/program.js --identity dist/wcat.js` now builds it from the
18
+ command tree (`createProgram`) and the identity (`WCAT`, a `ManifestIdentity` from
19
+ `@wirecat/cli-base/wcat/manifest`): each runnable command with its `effects` (left out, a write) and, with
20
+ `permissionOf`, its permission key, then a `desktop` object holding Desktop's catalog keys. `doctor`, `profiles`,
21
+ `setup`, `runs`, `skill`, `mcpServer`, `sync` and `storage` come from the standard commands, the `skills/` folder
22
+ and the identity's `appName` and `envPrefix`; only `tagline`, `signIn` and, for a CLI with a sync command, `syncs`
23
+ are typed by the developer. The file holds no version, so a release does not make it stale: Desktop reads the
24
+ version from npm. `mcpServer` names no port: Desktop gives the tool a free one and fills `{port}`. It refuses,
25
+ naming the key, any word Desktop's rule would refuse. `--check` fails when the file is stale and prints the command
26
+ that rewrites it. List `contracts/wirecat.json` in the package's `files`;
27
+ it is the one file of `contracts/` a package ships (WC-REL-16). `manifestSchema` and `manifestJsonSchema()` check a
28
+ manifest anywhere.
29
+ - **`--wcat-describe` answers format 2 when the package ships `contracts/wirecat.json`.** The format-1 keys stay, with
30
+ `"wcat_describe": 2`, the file's `desktop` object and `manifest_sha256`, the SHA-256 of the file's bytes as shipped,
31
+ so Desktop can tell the installed tool is the one it showed. `wcatStart` reads the file next to the `package.json`
32
+ nearest the bin and never rebuilds it. Without the file, or past `wcat`'s 64 KiB cap, the answer is format 1 as
33
+ before. `parseDescribe` returns `manifestSha256` for a format-2 answer; `listTools` is unchanged.
34
+
11
35
  ## 0.80.9 — 07.11.2026
12
36
 
13
37
  ### Fixed
package/dist/dev/main.js CHANGED
@@ -11,6 +11,7 @@ import { parseArgs } from "node:util";
11
11
  import spawn from "cross-spawn";
12
12
  import * as v from "valibot";
13
13
  import { parseCommandsDocument } from "../commands/document.js";
14
+ import { describeProgram } from "../commands/registry.js";
14
15
  import { taggedSection } from "../release/fold.js";
15
16
  import { changelogProblems, docsProblems, JOURNAL_IDS, markdownFiles, packageVersion, structureProblems, versionScript, } from "../release/index.js";
16
17
  import { AUDIT_BLOCKS, defineParityGroups, PARITY_GROUPS, REQUIRED_ROOTS } from "../standards/audit.js";
@@ -18,6 +19,7 @@ import { defineReasons } from "../standards/errors.js";
18
19
  import { baselineProblems, baselineSchema, LINT_RULES, OVERRIDE_BUDGET, OVERRIDE_RULE_REVIEW, overrideSchema, overridesProblems, rulesForReview, } from "../standards/lint.js";
19
20
  import { issuesOf, RegistryError } from "../standards/registry.js";
20
21
  import { VOCABULARY } from "../standards/vocabulary.js";
22
+ import { buildManifest, MANIFEST_FILE, ManifestError, manifestText } from "../wcat/manifest.js";
21
23
  import { auditClis, scorecardTable, snakeKeys } from "./audit.js";
22
24
  import { readCapabilities } from "./capabilities.js";
23
25
  import { CONFORMANCE_USAGE, conformanceCommand } from "./conformance.js";
@@ -50,6 +52,10 @@ const USAGE = `usage: cli-dev <command> [options]
50
52
  docs/ against docs/meta.json, the docs portal's structure
51
53
  test-matrix --program <module> --untested <module> --name <cli> [--page <path>] [--check]
52
54
  docs/dev/test-matrix.md from coverage/argv.jsonl
55
+ manifest --program <module> --identity <module> [--check]
56
+ contracts/wirecat.json from the program's command tree (the
57
+ module's createProgram) and the identity (its WCAT export),
58
+ for WireCat Desktop; --check fails when the file is stale
53
59
  lint (--cli <bin> | --commands <file>) [--baseline <dir>] [--overrides <file>] [--budget <n>]
54
60
  [--schemas <file>] [--write-baseline] [--allow-stale]
55
61
  the command tree against the standard's rules; fails on a
@@ -233,6 +239,52 @@ const testMatrix = async (args, io) => {
233
239
  io.err(`test matrix: ${count("tested")} tested, ${count("untested")} untested with a reason, ${missing.length} missing`);
234
240
  return failed ? 1 : 0;
235
241
  };
242
+ const manifest = async (args, io) => {
243
+ const { values } = parseArgs({
244
+ args,
245
+ options: {
246
+ program: { type: "string" },
247
+ identity: { type: "string" },
248
+ check: { type: "boolean", default: false },
249
+ },
250
+ });
251
+ if (!values.program || !values.identity) {
252
+ io.err("manifest needs --program and --identity");
253
+ return 2;
254
+ }
255
+ const fix = `cli-dev manifest --program ${values.program} --identity ${values.identity}`;
256
+ let text;
257
+ try {
258
+ const program = (await load(io.cwd, values.program)).createProgram();
259
+ const identity = (await load(io.cwd, values.identity)).WCAT;
260
+ if (!identity)
261
+ throw new ManifestError([`${values.identity} exports no WCAT identity`]);
262
+ text = manifestText(buildManifest({
263
+ identity,
264
+ commands: describeProgram(program),
265
+ pkg: readJson(join(io.cwd, "package.json")),
266
+ skills: existsSync(join(io.cwd, "skills")),
267
+ }));
268
+ }
269
+ catch (error) {
270
+ io.err(error.message);
271
+ return 1;
272
+ }
273
+ const path = join(io.cwd, MANIFEST_FILE);
274
+ const shipped = existsSync(path) ? readFileSync(path, "utf8") : undefined;
275
+ if (values.check) {
276
+ if (shipped === text) {
277
+ io.out(`${MANIFEST_FILE}: up to date`);
278
+ return 0;
279
+ }
280
+ io.err(`${MANIFEST_FILE} is ${shipped === undefined ? "missing" : "stale"}: run ${fix}`);
281
+ return 1;
282
+ }
283
+ mkdirSync(join(io.cwd, "contracts"), { recursive: true });
284
+ writeFileSync(path, text);
285
+ io.out(`${MANIFEST_FILE}: ${shipped === text ? "unchanged" : "written"}`);
286
+ return 0;
287
+ };
236
288
  const readJson = (path) => {
237
289
  try {
238
290
  return JSON.parse(readFileSync(path, "utf8"));
@@ -738,6 +790,8 @@ export const main = async (argv, io) => {
738
790
  return docsCheck(args, io);
739
791
  case "test-matrix":
740
792
  return testMatrix(args, io);
793
+ case "manifest":
794
+ return manifest(args, io);
741
795
  case "lint":
742
796
  return lint(args, io);
743
797
  case "audit":
@@ -10,13 +10,26 @@ export interface WcatTool {
10
10
  }
11
11
  /** Format of the `--wcat-describe` answer; a later format adds keys and keeps these. */
12
12
  export declare const DESCRIBE_FORMAT = 1;
13
+ /** The format of a tool that ships `contracts/wirecat.json`: format 1's keys, its `desktop` and the file's hash. */
14
+ export declare const DESCRIBE_MANIFEST_FORMAT = 2;
13
15
  export interface DescribeAnswer {
14
16
  wcat_describe: number;
15
17
  name: string;
16
18
  version: string;
17
19
  description: string;
18
20
  docs_url?: string;
21
+ desktop?: unknown;
22
+ manifest_sha256?: string;
19
23
  }
20
- export declare const describeAnswer: (tool: WcatTool) => DescribeAnswer;
21
- /** A `--wcat-describe` answer, or `undefined` for anything else: the program is listed either way. */
22
- export declare const parseDescribe: (text: string) => Omit<WcatTool, "command"> | undefined;
24
+ /** The shipped manifest as `--wcat-describe` passes it on: its `desktop` object and the SHA-256 of its bytes. */
25
+ export interface ShippedManifest {
26
+ desktop: unknown;
27
+ sha256: string;
28
+ }
29
+ export declare const describeAnswer: (tool: WcatTool, manifest?: ShippedManifest) => DescribeAnswer;
30
+ export interface DescribedTool extends Omit<WcatTool, "command"> {
31
+ /** Format 2 only: the SHA-256 of the tool's shipped `contracts/wirecat.json`. */
32
+ manifestSha256?: string;
33
+ }
34
+ /** A `--wcat-describe` answer of any format, or `undefined` for anything else: the program is listed either way. */
35
+ export declare const parseDescribe: (text: string) => DescribedTool | undefined;
@@ -1,16 +1,31 @@
1
1
  import { singleLine } from "../sanitize.js";
2
+ import { DESCRIBE_MAX_BYTES } from "./names.js";
2
3
  /** Format of the `--wcat-describe` answer; a later format adds keys and keeps these. */
3
4
  export const DESCRIBE_FORMAT = 1;
4
- export const describeAnswer = (tool) => ({
5
- wcat_describe: DESCRIBE_FORMAT,
6
- name: tool.command,
7
- version: tool.version,
8
- description: tool.description,
9
- ...(tool.docs ? { docs_url: tool.docs } : {}),
10
- });
5
+ /** The format of a tool that ships `contracts/wirecat.json`: format 1's keys, its `desktop` and the file's hash. */
6
+ export const DESCRIBE_MANIFEST_FORMAT = 2;
7
+ export const describeAnswer = (tool, manifest) => {
8
+ const answer = {
9
+ wcat_describe: DESCRIBE_FORMAT,
10
+ name: tool.command,
11
+ version: tool.version,
12
+ description: tool.description,
13
+ ...(tool.docs ? { docs_url: tool.docs } : {}),
14
+ };
15
+ if (!manifest)
16
+ return answer;
17
+ const full = {
18
+ ...answer,
19
+ wcat_describe: DESCRIBE_MANIFEST_FORMAT,
20
+ desktop: manifest.desktop,
21
+ manifest_sha256: manifest.sha256,
22
+ };
23
+ // `wcat` stops reading past the cap; format 1 still lists the tool, where a cut answer would list it bare.
24
+ return Buffer.byteLength(`${JSON.stringify(full)}\n`) > DESCRIBE_MAX_BYTES ? answer : full;
25
+ };
11
26
  const MAX_TEXT = 200;
12
27
  const clean = (value) => typeof value === "string" && value.trim() !== "" ? singleLine(value.trim()).slice(0, MAX_TEXT) : undefined;
13
- /** A `--wcat-describe` answer, or `undefined` for anything else: the program is listed either way. */
28
+ /** A `--wcat-describe` answer of any format, or `undefined` for anything else: the program is listed either way. */
14
29
  export const parseDescribe = (text) => {
15
30
  let answer;
16
31
  try {
@@ -21,11 +36,12 @@ export const parseDescribe = (text) => {
21
36
  }
22
37
  if (typeof answer !== "object" || answer === null || !("wcat_describe" in answer))
23
38
  return undefined;
24
- const { version, description, docs_url: docs } = answer;
39
+ const { version, description, docs_url: docs, manifest_sha256: sha } = answer;
25
40
  const url = clean(docs);
26
41
  return {
27
42
  version: clean(version) ?? "",
28
43
  description: clean(description) ?? "",
29
44
  ...(url && /^https?:\/\//.test(url) ? { docs: url } : {}),
45
+ ...(typeof sha === "string" && /^[0-9a-f]{64}$/.test(sha) ? { manifestSha256: sha } : {}),
30
46
  };
31
47
  };
@@ -4,12 +4,13 @@
4
4
  * dispatch mode, and each tool repairs it on start.
5
5
  *
6
6
  * A CLI's bin imports `wcatStart` from `@wirecat/cli-base/wcat/start`, which loads only Node built-ins; this entry
7
- * point is the whole library, for WireCat Desktop and for tests.
7
+ * point is the whole library, for WireCat Desktop and for tests. `@wirecat/cli-base/wcat/manifest` builds and checks
8
+ * `contracts/wirecat.json`.
8
9
  */
9
- export { type DescribeAnswer, describeAnswer, parseDescribe, type WcatTool } from "./describe.js";
10
+ export { type DescribeAnswer, type DescribedTool, describeAnswer, parseDescribe, type ShippedManifest, type WcatTool, } from "./describe.js";
10
11
  export { type ListedTool, listTools, runWcat, type WcatContext } from "./dispatch.js";
11
12
  export { type BinFolder, binFolder, ensureLauncher, type LauncherState } from "./launcher.js";
12
- export { BUILT_IN_COMMANDS, DESCRIBE_FLAG, DISPATCH_FLAG, FIRST_PARTY_TOOLS, PROGRAM_PREFIX, RESERVED_NAMES, TOOL_NAME, } from "./names.js";
13
+ export { BUILT_IN_COMMANDS, DESCRIBE_FLAG, DESCRIBE_MAX_BYTES, DISPATCH_FLAG, FIRST_PARTY_TOOLS, PROGRAM_PREFIX, RESERVED_NAMES, TOOL_NAME, } from "./names.js";
13
14
  export { findOnPath, findTools, type SearchEnv } from "./path.js";
14
15
  export { parseShim, SHIM_FORMAT, type ShimKind, shimFiles } from "./shim.js";
15
16
  export { addShortcuts, installedPrograms, listShortcuts, removeShortcuts, type Shortcut, type ShortcutChange, type ShortcutStatus, } from "./shortcuts.js";
@@ -4,12 +4,13 @@
4
4
  * dispatch mode, and each tool repairs it on start.
5
5
  *
6
6
  * A CLI's bin imports `wcatStart` from `@wirecat/cli-base/wcat/start`, which loads only Node built-ins; this entry
7
- * point is the whole library, for WireCat Desktop and for tests.
7
+ * point is the whole library, for WireCat Desktop and for tests. `@wirecat/cli-base/wcat/manifest` builds and checks
8
+ * `contracts/wirecat.json`.
8
9
  */
9
- export { describeAnswer, parseDescribe } from "./describe.js";
10
+ export { describeAnswer, parseDescribe, } from "./describe.js";
10
11
  export { listTools, runWcat } from "./dispatch.js";
11
12
  export { binFolder, ensureLauncher } from "./launcher.js";
12
- export { BUILT_IN_COMMANDS, DESCRIBE_FLAG, DISPATCH_FLAG, FIRST_PARTY_TOOLS, PROGRAM_PREFIX, RESERVED_NAMES, TOOL_NAME, } from "./names.js";
13
+ export { BUILT_IN_COMMANDS, DESCRIBE_FLAG, DESCRIBE_MAX_BYTES, DISPATCH_FLAG, FIRST_PARTY_TOOLS, PROGRAM_PREFIX, RESERVED_NAMES, TOOL_NAME, } from "./names.js";
13
14
  export { findOnPath, findTools } from "./path.js";
14
15
  export { parseShim, SHIM_FORMAT, shimFiles } from "./shim.js";
15
16
  export { addShortcuts, installedPrograms, listShortcuts, removeShortcuts, } from "./shortcuts.js";
@@ -0,0 +1,186 @@
1
+ /**
2
+ * `contracts/wirecat.json`, format 2: what a CLI tells WireCat Desktop about itself, built from its command tree so
3
+ * nothing in it is typed by hand except the tagline and the sign-in texts. Desktop reads it out of the npm tarball
4
+ * without running the package, so every array holds plain words only: the same rule as Desktop's `community.rs`.
5
+ */
6
+ import * as v from "valibot";
7
+ import { type CommandInfo } from "../commands/registry.js";
8
+ import type { WcatTool } from "./describe.js";
9
+ export declare const MANIFEST_FORMAT = 2;
10
+ export declare const MANIFEST_FILE = "contracts/wirecat.json";
11
+ /** Desktop's `plain_word`: letters, digits and `._:=,/+@-`, at most two leading dashes, `--` alone, `{name}` slots. */
12
+ export declare const PLAIN_WORD: RegExp;
13
+ declare const signInSchema: v.StrictObjectSchema<{
14
+ /** What signing in lets the agent do, in a sentence: "Lets your agent read your Acme contacts." */
15
+ readonly gives: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "one line of text">, v.MaxLengthAction<string, number, undefined>]>;
16
+ /** What the person is asked for: "An Acme API token, from Settings → API." */
17
+ readonly asks: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "one line of text">, v.MaxLengthAction<string, number, undefined>]>;
18
+ }, undefined>;
19
+ export type SignIn = v.InferOutput<typeof signInSchema>;
20
+ /** Exactly the keys of a Desktop catalog entry that the tool itself knows; `null` when unused. */
21
+ declare const desktopSchema: v.StrictObjectSchema<{
22
+ readonly tagline: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "one line of text">, v.MaxLengthAction<string, number, undefined>]>;
23
+ readonly profiles: v.NullableSchema<v.StrictObjectSchema<{
24
+ readonly args: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
25
+ readonly shape: v.LiteralSchema<"items", undefined>;
26
+ }, undefined>, undefined>;
27
+ readonly doctor: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
28
+ readonly runs: v.NullableSchema<v.StrictObjectSchema<{
29
+ readonly list: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
30
+ readonly show: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
31
+ }, undefined>, undefined>;
32
+ readonly search: v.NullSchema<undefined>;
33
+ readonly setup: v.NullableSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>, undefined>;
34
+ readonly signIn: v.NullableSchema<v.StrictObjectSchema<{
35
+ /** What signing in lets the agent do, in a sentence: "Lets your agent read your Acme contacts." */
36
+ readonly gives: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "one line of text">, v.MaxLengthAction<string, number, undefined>]>;
37
+ /** What the person is asked for: "An Acme API token, from Settings → API." */
38
+ readonly asks: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "one line of text">, v.MaxLengthAction<string, number, undefined>]>;
39
+ }, undefined>, undefined>;
40
+ readonly skill: v.NullableSchema<v.StrictObjectSchema<{
41
+ readonly status: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
42
+ readonly install: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
43
+ readonly show: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
44
+ }, undefined>, undefined>;
45
+ /** Desktop gives an own tool a free port of its own and fills `{port}`. */
46
+ readonly mcpServer: v.NullableSchema<v.StrictObjectSchema<{
47
+ readonly start: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
48
+ readonly stop: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
49
+ readonly status: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
50
+ readonly revoke: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
51
+ readonly config: v.NullableSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>, undefined>;
52
+ }, undefined>, undefined>;
53
+ readonly tasks: v.NullSchema<undefined>;
54
+ readonly sync: v.NullableSchema<v.StrictObjectSchema<{
55
+ readonly run: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
56
+ readonly last: v.NullableSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>, undefined>;
57
+ readonly lastShape: v.LiteralSchema<"runs", undefined>;
58
+ readonly what: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "one line of text">, v.MaxLengthAction<string, number, undefined>]>;
59
+ readonly note: v.NullSchema<undefined>;
60
+ }, undefined>, undefined>;
61
+ readonly storeInfo: v.NullSchema<undefined>;
62
+ readonly storeTables: v.NullSchema<undefined>;
63
+ readonly storeTableSizes: v.NullSchema<undefined>;
64
+ readonly storeCheck: v.NullSchema<undefined>;
65
+ readonly storeBackup: v.NullSchema<undefined>;
66
+ readonly storeBackupEncrypted: v.NullSchema<undefined>;
67
+ readonly storeResetPreview: v.NullSchema<undefined>;
68
+ readonly storeReset: v.NullSchema<undefined>;
69
+ readonly storage: v.StrictObjectSchema<{
70
+ readonly app: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a folder name">]>;
71
+ readonly env: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "an upper-case environment prefix">]>;
72
+ }, undefined>;
73
+ readonly settings: v.NullSchema<undefined>;
74
+ }, undefined>;
75
+ export type ManifestDesktop = v.InferOutput<typeof desktopSchema>;
76
+ export declare const manifestSchema: v.StrictObjectSchema<{
77
+ readonly wcat_manifest: v.LiteralSchema<2, undefined>;
78
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "lower-case letters, digits and -">]>;
79
+ readonly description: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "one line of text">, v.MaxLengthAction<string, number, undefined>]>;
80
+ readonly docs_url: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.UrlAction<string, undefined>, v.StartsWithAction<string, "https://", "an https link">]>, undefined>;
81
+ readonly package: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a scoped npm package name">]>;
82
+ readonly bin: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "lower-case letters, digits and -">]>;
83
+ readonly commands: v.ArraySchema<v.StrictObjectSchema<{
84
+ readonly path: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
85
+ readonly effects: v.StrictObjectSchema<{
86
+ readonly remote: v.PicklistSchema<readonly ["none", "read", "write"], undefined>;
87
+ readonly local: v.PicklistSchema<readonly ["none", "read", "write"], undefined>;
88
+ }, undefined>;
89
+ /** The permission key cli-core checks this command against; left out for housekeeping or when not given. */
90
+ readonly permission: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>;
91
+ }, undefined>, undefined>;
92
+ readonly desktop: v.StrictObjectSchema<{
93
+ readonly tagline: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "one line of text">, v.MaxLengthAction<string, number, undefined>]>;
94
+ readonly profiles: v.NullableSchema<v.StrictObjectSchema<{
95
+ readonly args: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
96
+ readonly shape: v.LiteralSchema<"items", undefined>;
97
+ }, undefined>, undefined>;
98
+ readonly doctor: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
99
+ readonly runs: v.NullableSchema<v.StrictObjectSchema<{
100
+ readonly list: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
101
+ readonly show: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
102
+ }, undefined>, undefined>;
103
+ readonly search: v.NullSchema<undefined>;
104
+ readonly setup: v.NullableSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>, undefined>;
105
+ readonly signIn: v.NullableSchema<v.StrictObjectSchema<{
106
+ /** What signing in lets the agent do, in a sentence: "Lets your agent read your Acme contacts." */
107
+ readonly gives: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "one line of text">, v.MaxLengthAction<string, number, undefined>]>;
108
+ /** What the person is asked for: "An Acme API token, from Settings → API." */
109
+ readonly asks: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "one line of text">, v.MaxLengthAction<string, number, undefined>]>;
110
+ }, undefined>, undefined>;
111
+ readonly skill: v.NullableSchema<v.StrictObjectSchema<{
112
+ readonly status: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
113
+ readonly install: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
114
+ readonly show: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
115
+ }, undefined>, undefined>;
116
+ /** Desktop gives an own tool a free port of its own and fills `{port}`. */
117
+ readonly mcpServer: v.NullableSchema<v.StrictObjectSchema<{
118
+ readonly start: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
119
+ readonly stop: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
120
+ readonly status: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
121
+ readonly revoke: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
122
+ readonly config: v.NullableSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>, undefined>;
123
+ }, undefined>, undefined>;
124
+ readonly tasks: v.NullSchema<undefined>;
125
+ readonly sync: v.NullableSchema<v.StrictObjectSchema<{
126
+ readonly run: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
127
+ readonly last: v.NullableSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 100, "a command word is at most 100 characters">, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>, undefined>;
128
+ readonly lastShape: v.LiteralSchema<"runs", undefined>;
129
+ readonly what: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "one line of text">, v.MaxLengthAction<string, number, undefined>]>;
130
+ readonly note: v.NullSchema<undefined>;
131
+ }, undefined>, undefined>;
132
+ readonly storeInfo: v.NullSchema<undefined>;
133
+ readonly storeTables: v.NullSchema<undefined>;
134
+ readonly storeTableSizes: v.NullSchema<undefined>;
135
+ readonly storeCheck: v.NullSchema<undefined>;
136
+ readonly storeBackup: v.NullSchema<undefined>;
137
+ readonly storeBackupEncrypted: v.NullSchema<undefined>;
138
+ readonly storeResetPreview: v.NullSchema<undefined>;
139
+ readonly storeReset: v.NullSchema<undefined>;
140
+ readonly storage: v.StrictObjectSchema<{
141
+ readonly app: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a folder name">]>;
142
+ readonly env: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "an upper-case environment prefix">]>;
143
+ }, undefined>;
144
+ readonly settings: v.NullSchema<undefined>;
145
+ }, undefined>;
146
+ }, undefined>;
147
+ export type Manifest = v.InferOutput<typeof manifestSchema>;
148
+ export declare const manifestJsonSchema: () => import("@valibot/to-json-schema").JsonSchema;
149
+ /**
150
+ * What a CLI declares for its manifest: its `wcatStart` argument plus cli-core's `AppIdentity` folders, the tagline
151
+ * and the sign-in texts. `{ ...IDENTITY, docs, tagline, signIn }` builds it from cli-core's identity.
152
+ */
153
+ export interface ManifestIdentity extends WcatTool {
154
+ /** The data folder name: cli-core's `AppIdentity.appName`. */
155
+ appName: string;
156
+ /** The environment prefix: cli-core's `AppIdentity.envPrefix`. */
157
+ envPrefix: string;
158
+ /** At most 55 characters: Desktop's Tools page line. */
159
+ tagline?: string;
160
+ signIn?: SignIn;
161
+ /** What `sync` copies, at most 40 characters: "contacts and deals". Required when the CLI has a sync command. */
162
+ syncs?: string;
163
+ /** The permission key of a command path, such as cli-core's `CommandPermissions.keyOf`; `null` for none. */
164
+ permissionOf?: (path: readonly string[]) => string | null;
165
+ }
166
+ export interface ManifestPackage {
167
+ name?: unknown;
168
+ bin?: unknown;
169
+ }
170
+ export interface ManifestInput {
171
+ identity: ManifestIdentity;
172
+ /** `describeProgram(createProgram())`. */
173
+ commands: readonly CommandInfo[];
174
+ /** The CLI's `package.json`. */
175
+ pkg: ManifestPackage;
176
+ /** Whether the package ships a `skills/` folder. */
177
+ skills: boolean;
178
+ }
179
+ export declare class ManifestError extends Error {
180
+ readonly problems: readonly string[];
181
+ constructor(problems: readonly string[]);
182
+ }
183
+ export declare const buildManifest: ({ identity, commands, pkg, skills }: ManifestInput) => Manifest;
184
+ /** The bytes `cli-dev manifest` writes, so `--check` is a byte compare and the shipped hash is stable. */
185
+ export declare const manifestText: (manifest: Manifest) => string;
186
+ export {};
@@ -0,0 +1,208 @@
1
+ /**
2
+ * `contracts/wirecat.json`, format 2: what a CLI tells WireCat Desktop about itself, built from its command tree so
3
+ * nothing in it is typed by hand except the tagline and the sign-in texts. Desktop reads it out of the npm tarball
4
+ * without running the package, so every array holds plain words only: the same rule as Desktop's `community.rs`.
5
+ */
6
+ import * as v from "valibot";
7
+ import { flatten } from "../commands/registry.js";
8
+ import { effectsSchema } from "../standards/effects.js";
9
+ import { issuesOf, jsonSchemaOf } from "../standards/registry.js";
10
+ import { PROGRAM_PREFIX, TOOL_NAME } from "./names.js";
11
+ export const MANIFEST_FORMAT = 2;
12
+ export const MANIFEST_FILE = "contracts/wirecat.json";
13
+ /** Desktop's `plain_word`: letters, digits and `._:=,/+@-`, at most two leading dashes, `--` alone, `{name}` slots. */
14
+ export const PLAIN_WORD = /^(?:--|-{0,2}(?:[A-Za-z0-9]|\{[A-Za-z]+\})(?:[A-Za-z0-9._:=,/+@-]|\{[A-Za-z]+\})*)$/;
15
+ const plainWord = v.pipe(v.string(), v.maxLength(100, "a command word is at most 100 characters"), v.regex(PLAIN_WORD, (issue) => `${JSON.stringify(issue.input)} is not a plain word: letters, digits and ._:=,/+@-, at most two leading dashes, -- alone and {name} slots; no spaces, quotes or shell syntax`));
16
+ const words = v.pipe(v.array(plainWord), v.minLength(1));
17
+ const line = (max) => v.pipe(v.string(), v.regex(/^\S(?:[^\n\r]*\S)?$/, "one line of text"), v.maxLength(max));
18
+ const signInSchema = v.strictObject({
19
+ /** What signing in lets the agent do, in a sentence: "Lets your agent read your Acme contacts." */
20
+ gives: line(300),
21
+ /** What the person is asked for: "An Acme API token, from Settings → API." */
22
+ asks: line(300),
23
+ });
24
+ /** Exactly the keys of a Desktop catalog entry that the tool itself knows; `null` when unused. */
25
+ const desktopSchema = v.strictObject({
26
+ tagline: line(55),
27
+ profiles: v.nullable(v.strictObject({ args: words, shape: v.literal("items") })),
28
+ doctor: words,
29
+ runs: v.nullable(v.strictObject({ list: words, show: words })),
30
+ search: v.null(),
31
+ setup: v.nullable(words),
32
+ signIn: v.nullable(signInSchema),
33
+ skill: v.nullable(v.strictObject({ status: words, install: words, show: words })),
34
+ /** Desktop gives an own tool a free port of its own and fills `{port}`. */
35
+ mcpServer: v.nullable(v.strictObject({
36
+ start: words,
37
+ stop: words,
38
+ status: words,
39
+ revoke: words,
40
+ config: v.nullable(words),
41
+ })),
42
+ tasks: v.null(),
43
+ sync: v.nullable(v.strictObject({
44
+ run: words,
45
+ last: v.nullable(words),
46
+ lastShape: v.literal("runs"),
47
+ what: line(40),
48
+ note: v.null(),
49
+ })),
50
+ storeInfo: v.null(),
51
+ storeTables: v.null(),
52
+ storeTableSizes: v.null(),
53
+ storeCheck: v.null(),
54
+ storeBackup: v.null(),
55
+ storeBackupEncrypted: v.null(),
56
+ storeResetPreview: v.null(),
57
+ storeReset: v.null(),
58
+ storage: v.strictObject({
59
+ app: v.pipe(v.string(), v.regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/, "a folder name")),
60
+ env: v.pipe(v.string(), v.regex(/^[A-Z][A-Z0-9_]*$/, "an upper-case environment prefix")),
61
+ }),
62
+ settings: v.null(),
63
+ });
64
+ export const manifestSchema = v.strictObject({
65
+ wcat_manifest: v.literal(MANIFEST_FORMAT),
66
+ name: v.pipe(v.string(), v.regex(TOOL_NAME, "lower-case letters, digits and -")),
67
+ description: line(200),
68
+ docs_url: v.optional(v.pipe(v.string(), v.url(), v.startsWith("https://", "an https link"))),
69
+ package: v.pipe(v.string(), v.regex(/^@[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._-]*$/, "a scoped npm package name")),
70
+ bin: v.pipe(v.string(), v.regex(TOOL_NAME, "lower-case letters, digits and -")),
71
+ commands: v.array(v.strictObject({
72
+ path: words,
73
+ effects: effectsSchema,
74
+ /** The permission key cli-core checks this command against; left out for housekeeping or when not given. */
75
+ permission: v.optional(v.pipe(v.string(), v.nonEmpty())),
76
+ })),
77
+ desktop: desktopSchema,
78
+ });
79
+ export const manifestJsonSchema = () => jsonSchemaOf(manifestSchema);
80
+ export class ManifestError extends Error {
81
+ problems;
82
+ constructor(problems) {
83
+ super(`${MANIFEST_FILE} cannot be built: ${problems.join("; ")}`);
84
+ this.problems = problems;
85
+ this.name = "ManifestError";
86
+ }
87
+ }
88
+ const UNDECLARED = { remote: "write", local: "write" };
89
+ const binOf = (pkg, command) => {
90
+ if (typeof pkg.bin === "string" && typeof pkg.name === "string")
91
+ return pkg.name.replace(/^@[^/]+\//, "");
92
+ const names = typeof pkg.bin === "object" && pkg.bin !== null ? Object.keys(pkg.bin) : [];
93
+ const found = [`${PROGRAM_PREFIX}${command}`, command].find((name) => names.includes(name));
94
+ if (!found)
95
+ throw new ManifestError([`package.json "bin" installs neither ${PROGRAM_PREFIX}${command} nor ${command}`]);
96
+ return found;
97
+ };
98
+ export const buildManifest = ({ identity, commands, pkg, skills }) => {
99
+ const all = flatten(commands);
100
+ const at = new Map(all.map((command) => [command.path.join(" "), command]));
101
+ const has = (...paths) => paths.every((path) => at.has(path));
102
+ const optionOf = (path, flag) => at.get(path)?.options.find((option) => option.flags.split(/[ ,|]+/).includes(flag));
103
+ const takes = (path, flag) => optionOf(path, flag) !== undefined;
104
+ const allProfiles = (path) => (takes(path, "--profiles") ? ["--profiles", "all"] : []);
105
+ const profileList = ["account list", "session list"].find((path) => at.has(path));
106
+ const profiles = profileList ? { args: [...profileList.split(" "), "--no-record", "--json"], shape: "items" } : null;
107
+ const profile = profiles ? ["{profile}"] : [];
108
+ if (!has("doctor"))
109
+ throw new ManifestError(["no doctor command: Desktop checks every tool with it"]);
110
+ if (!identity.tagline)
111
+ throw new ManifestError(["no tagline: add `tagline`, at most 55 characters, to the identity the manifest reads"]);
112
+ const setupPath = ["setup", "session start"].find((path) => at.has(path));
113
+ const mcpServer = has("mcp server start", "mcp server stop", "mcp server status", "mcp revoke")
114
+ ? {
115
+ start: [
116
+ "mcp",
117
+ "server",
118
+ "start",
119
+ "--port",
120
+ "{port}",
121
+ ...(takes("mcp server start", "--public-url") ? ["--public-url", "{url}"] : []),
122
+ ...allProfiles("mcp server start"),
123
+ "--json",
124
+ ],
125
+ stop: ["mcp", "server", "stop", ...allProfiles("mcp server stop"), "--json"],
126
+ status: ["mcp", "server", "status", ...allProfiles("mcp server status"), "--no-record", "--json"],
127
+ revoke: ["mcp", "revoke", ...allProfiles("mcp revoke"), "--json"],
128
+ config: has("mcp config") ? ["mcp", "config", ...allProfiles("mcp config"), "--no-record", "--json"] : null,
129
+ }
130
+ : null;
131
+ const nounSyncs = all.filter((command) => command.path.length === 2 && command.path[1] === "sync");
132
+ const syncPath = at.get("sync")?.path ?? (nounSyncs.length === 1 ? nounSyncs[0]?.path : undefined);
133
+ if (syncPath && !identity.syncs)
134
+ throw new ManifestError([
135
+ `no syncs: \`${syncPath.join(" ")}\` exists, so add \`syncs\`, what it copies in at most 40 characters`,
136
+ ]);
137
+ // `runs list` matches `command:` exactly and a plain word holds no space, so only a one-word path can be found.
138
+ const last = syncPath?.length === 1 && has("runs list")
139
+ ? ["runs", "list", "command:sync", "status:success", "--limit", "50", "--no-record", "--json"]
140
+ : null;
141
+ const sync = syncPath
142
+ ? {
143
+ run: [...profile, ...syncPath, "--record", "--json"],
144
+ last,
145
+ lastShape: "runs",
146
+ what: identity.syncs,
147
+ note: null,
148
+ }
149
+ : null;
150
+ const manifest = {
151
+ wcat_manifest: MANIFEST_FORMAT,
152
+ name: identity.command,
153
+ description: identity.description,
154
+ ...(identity.docs ? { docs_url: identity.docs } : {}),
155
+ package: pkg.name,
156
+ bin: binOf(pkg, identity.command),
157
+ commands: all
158
+ .filter((command) => command.commands.length === 0 || command.runnable)
159
+ .map((command) => {
160
+ const permission = identity.permissionOf?.(command.path);
161
+ return {
162
+ path: [...command.path],
163
+ effects: command.effects ?? UNDECLARED,
164
+ ...(permission ? { permission } : {}),
165
+ };
166
+ }),
167
+ desktop: {
168
+ tagline: identity.tagline,
169
+ profiles,
170
+ doctor: [...profile, "doctor", "--record", "--json"],
171
+ runs: has("runs list", "runs show")
172
+ ? {
173
+ list: ["runs", "list", "{query}", "--limit", "{limit}", "--page", "{page}", "--no-record", "--json"],
174
+ show: ["runs", "show", "{run}", "--no-record", "--json"],
175
+ }
176
+ : null,
177
+ search: null,
178
+ setup: setupPath ? [...profile, ...setupPath.split(" ")] : null,
179
+ signIn: identity.signIn ? { gives: identity.signIn.gives, asks: identity.signIn.asks } : null,
180
+ skill: skills && has("skill status", "skill install", "skill show")
181
+ ? {
182
+ status: ["skill", "status", "--no-record", "--json"],
183
+ install: ["skill", "install", "--for", "{target}", "--json"],
184
+ show: ["skill", "show", "--no-record", "--json"],
185
+ }
186
+ : null,
187
+ mcpServer,
188
+ tasks: null,
189
+ sync,
190
+ storeInfo: null,
191
+ storeTables: null,
192
+ storeTableSizes: null,
193
+ storeCheck: null,
194
+ storeBackup: null,
195
+ storeBackupEncrypted: null,
196
+ storeResetPreview: null,
197
+ storeReset: null,
198
+ storage: { app: identity.appName, env: identity.envPrefix },
199
+ settings: null,
200
+ },
201
+ };
202
+ const parsed = v.safeParse(manifestSchema, manifest);
203
+ if (!parsed.success)
204
+ throw new ManifestError(issuesOf(parsed.issues));
205
+ return parsed.output;
206
+ };
207
+ /** The bytes `cli-dev manifest` writes, so `--check` is a byte compare and the shipped hash is stable. */
208
+ export const manifestText = (manifest) => `${JSON.stringify(manifest, null, 2)}\n`;
@@ -12,5 +12,7 @@ export declare const TOOL_NAME: RegExp;
12
12
  export declare const PROGRAM_PREFIX = "wcat-";
13
13
  /** The first argument `wcat-<name> --wcat-describe` answers with its JSON description. */
14
14
  export declare const DESCRIBE_FLAG = "--wcat-describe";
15
+ /** The most a `--wcat-describe` answer may print before `wcat` stops reading it. */
16
+ export declare const DESCRIBE_MAX_BYTES: number;
15
17
  /** The first argument the `wcat` launcher passes, so the tool runs `wcat` instead of its own program. */
16
18
  export declare const DISPATCH_FLAG = "--wcat-dispatch";
@@ -23,5 +23,7 @@ export const TOOL_NAME = /^[a-z][a-z0-9-]{0,39}$/;
23
23
  export const PROGRAM_PREFIX = "wcat-";
24
24
  /** The first argument `wcat-<name> --wcat-describe` answers with its JSON description. */
25
25
  export const DESCRIBE_FLAG = "--wcat-describe";
26
+ /** The most a `--wcat-describe` answer may print before `wcat` stops reading it. */
27
+ export const DESCRIBE_MAX_BYTES = 64 * 1024;
26
28
  /** The first argument the `wcat` launcher passes, so the tool runs `wcat` instead of its own program. */
27
29
  export const DISPATCH_FLAG = "--wcat-dispatch";
@@ -1,8 +1,7 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import crossSpawn from "cross-spawn";
3
3
  import { parseDescribe } from "./describe.js";
4
- import { DESCRIBE_FLAG } from "./names.js";
5
- const MAX_ANSWER_BYTES = 64 * 1024;
4
+ import { DESCRIBE_FLAG, DESCRIBE_MAX_BYTES } from "./names.js";
6
5
  /**
7
6
  * Asks one program to describe itself. Any program can sit on PATH under a `wcat-` name, so it gets no input, a time
8
7
  * limit and a cap on what it may print, and its failure only means "no description".
@@ -37,7 +36,7 @@ export const probeDescribe = (path, { env, timeoutMs }) => new Promise((resolve)
37
36
  const timer = setTimeout(giveUp, timeoutMs);
38
37
  child.stdout?.on("data", (chunk) => {
39
38
  size += chunk.length;
40
- if (size > MAX_ANSWER_BYTES)
39
+ if (size > DESCRIBE_MAX_BYTES)
41
40
  giveUp();
42
41
  else
43
42
  chunks.push(chunk);
@@ -31,7 +31,8 @@ export interface WcatStart {
31
31
  * else await startCli(…)
32
32
  * ```
33
33
  *
34
- * - `wcat-tg --wcat-describe` prints the tool's description as JSON for `wcat --help`.
34
+ * - `wcat-tg --wcat-describe` prints the tool's description as JSON for `wcat --help`, in format 2 when the package
35
+ * ships `contracts/wirecat.json`.
35
36
  * - `wcat-tg --wcat-dispatch …`, which only the launcher passes, runs `wcat …`.
36
37
  * - Any other start makes sure the `wcat` launcher in the tool's bin folder works: a few `stat` calls when it does.
37
38
  */
@@ -2,6 +2,9 @@
2
2
  * The part of `wcat` a CLI loads on every start, kept to Node built-ins: answering `--wcat-describe`, handing over to
3
3
  * the dispatcher when the launcher asks, and otherwise checking the `wcat` launcher with a few `stat` calls.
4
4
  */
5
+ import { createHash } from "node:crypto";
6
+ import { existsSync, readFileSync, realpathSync } from "node:fs";
7
+ import { dirname, join } from "node:path";
5
8
  import { fileURLToPath } from "node:url";
6
9
  import { describeAnswer } from "./describe.js";
7
10
  import { binFolder, ensureLauncher } from "./launcher.js";
@@ -15,7 +18,8 @@ import { DESCRIBE_FLAG, DISPATCH_FLAG } from "./names.js";
15
18
  * else await startCli(…)
16
19
  * ```
17
20
  *
18
- * - `wcat-tg --wcat-describe` prints the tool's description as JSON for `wcat --help`.
21
+ * - `wcat-tg --wcat-describe` prints the tool's description as JSON for `wcat --help`, in format 2 when the package
22
+ * ships `contracts/wirecat.json`.
19
23
  * - `wcat-tg --wcat-dispatch …`, which only the launcher passes, runs `wcat …`.
20
24
  * - Any other start makes sure the `wcat` launcher in the tool's bin folder works: a few `stat` calls when it does.
21
25
  */
@@ -26,7 +30,7 @@ export const wcatStart = async (tool, io = {}) => {
26
30
  const stdout = io.stdout ?? process.stdout;
27
31
  const [first, ...rest] = argv.slice(2);
28
32
  if (first === DESCRIBE_FLAG) {
29
- stdout.write(`${JSON.stringify(describeAnswer(tool))}\n`);
33
+ stdout.write(`${JSON.stringify(describeAnswer(tool, shippedManifest(argv[1])))}\n`);
30
34
  return { code: 0 };
31
35
  }
32
36
  if (first === DISPATCH_FLAG) {
@@ -43,3 +47,27 @@ export const wcatStart = async (tool, io = {}) => {
43
47
  });
44
48
  return folder ? { launcher: ensureLauncher({ ...folder, platform }) } : {};
45
49
  };
50
+ /**
51
+ * `contracts/wirecat.json` beside the `package.json` nearest the bin, read as shipped and never rebuilt, so the hash
52
+ * Desktop compares is of the very bytes it reviewed. Anything unreadable answers format 1.
53
+ */
54
+ const shippedManifest = (bin) => {
55
+ if (!bin)
56
+ return undefined;
57
+ try {
58
+ for (let dir = dirname(realpathSync(bin));; dir = dirname(dir)) {
59
+ if (existsSync(join(dir, "package.json"))) {
60
+ const bytes = readFileSync(join(dir, "contracts", "wirecat.json"));
61
+ const { wcat_manifest: format, desktop } = JSON.parse(bytes.toString("utf8"));
62
+ if (format !== 2 || typeof desktop !== "object" || desktop === null)
63
+ return undefined;
64
+ return { desktop, sha256: createHash("sha256").update(bytes).digest("hex") };
65
+ }
66
+ if (dirname(dir) === dir)
67
+ return undefined;
68
+ }
69
+ }
70
+ catch {
71
+ return undefined;
72
+ }
73
+ };
@@ -377,21 +377,32 @@ The references, each for its own part:
377
377
 
378
378
  ### WC-CMD-29 · Answer `--wcat-describe`, and take no name WireCat reserves
379
379
 
380
+ A CLI ships `contracts/wirecat.json` (`wcat_manifest: 2`), written by `cli-dev manifest` from its command tree and
381
+ its identity, never by hand. The developer types only `tagline`, `signIn` and, with a sync command, `syncs`; the
382
+ commands, their `effects` and every command word in `desktop` are derived, and every word passes Desktop's plain-word
383
+ rule. The file holds nothing that changes per release (no version), and no MCP port: Desktop assigns one. With the
384
+ file shipped, `--wcat-describe` answers format 2: the format-1 keys with `"wcat_describe": 2`, the file's `desktop`
385
+ and `manifest_sha256` of its bytes. Without it the answer stays format 1.
386
+
380
387
  - **Why:** `wcat <name>` runs any `wcat-<name>` program on PATH, and `wcat --help` lists each one with what it says
381
- about itself. A name WireCat reserves would be taken over by WireCat's own tool or by a `wcat` command.
382
- - **Enforced by:** `src/dev/wcat-lint.ts`.
388
+ about itself. A name WireCat reserves would be taken over by WireCat's own tool or by a `wcat` command. WireCat
389
+ Desktop adds a tool it has not checked from the manifest alone, read out of the npm tarball without running the
390
+ package, so a manifest typed by hand or left stale shows the owner words the CLI does not have.
391
+ - **Enforced by:** `src/dev/wcat-lint.ts` · `src/wcat/manifest.ts`.
383
392
  - **Example:** the bin's first call is `wcatStart({ command: "gcal", version, description, docs })` from
384
393
  `@wirecat/cli-base/wcat/start`. `wcat-gcal --wcat-describe` then prints
385
394
  `{"wcat_describe":1,"name":"gcal","version":"1.2.0","description":"…","docs_url":"…"}`. `cli-dev lint` warns when a
386
395
  `"bin"` key does not start with `wcat-`, when a package outside `@wirecat/` takes a name from `RESERVED_NAMES` in
387
396
  `@wirecat/cli-base/wcat` (`tg`, `max`, `wa`, `zm`, `drive`, `memo`, `mail`, `email`, `wcat` and the built-in commands
388
397
  `help`, `version`, `shortcuts`, `doctor`, `update`, `upgrade`, `app`), and, with `--cli`, when the built CLI does not
389
- answer `--wcat-describe`.
398
+ answer `--wcat-describe`. `cli-dev manifest --program dist/program.js --identity dist/wcat.js --check` fails when
399
+ `contracts/wirecat.json` is stale.
390
400
  - **Exceptions:** a CLI keeps its short `"bin"` name beside `wcat-<name>` until callers have moved to the new name; the
391
401
  warning stays until then. A CLI that keeps the short name for good says why in `lint/overrides.json` (`"rule":
392
402
  "wcat-bin-name"`, the target as the warning prints it), which silences the warning and counts against the budget.
393
- - **Applies to:** all CLIs, and third-party CLIs that join `wcat`. **Since:** cli-base 0.66.0. **Rulings:** NEED-149,
394
- NEED-153, NEED-154.
403
+ A WireCat CLI listed in Desktop's own catalog needs no manifest until Desktop reads one for it.
404
+ - **Applies to:** all CLIs, and third-party CLIs that join `wcat`. **Since:** cli-base 0.66.0; the manifest since the
405
+ release after 0.80.9. **Rulings:** NEED-149, NEED-153, NEED-154.
395
406
 
396
407
  ## Settings
397
408
 
@@ -26,7 +26,7 @@ the choices. Nothing is guessed.
26
26
  | `--command` | the command word people type | one word |
27
27
  | `--package` | the npm package name | a scoped name, such as `@wirecat/gcal-cli` |
28
28
  | `--owner` | the GitHub owner of the repository | an owner |
29
- | `--category` | what the CLI reads | `messenger`, `mail`, `notes`, `files`, `calendar`, `meetings` |
29
+ | `--category` | what the CLI reads | `messenger`, `mail`, `notes`, `files`, `calendar`, `meetings`, `crm` |
30
30
  | `--content-lang` | the languages of the content | a list, such as `en,ru` |
31
31
  | `--sign-in` | how the CLI signs in | `oauth`, `token`, `session`, `none` |
32
32
  | `--api` | what the service offers | `official-client`, `official-docs`, `unofficial` |
@@ -38,8 +38,9 @@ Every choice question also takes `other:<your answer>`.
38
38
 
39
39
  `new` copies the template of its own package version into `<name>-cli/`, renames the command word everywhere, runs
40
40
  `git init`, records the template version in `template.json`, writes `docs/dev/DESIGN.md` from your answers and names
41
- a reference CLI for your category in `AGENTS.md`. It does not install packages, push, create the repository or
42
- publish. Then:
41
+ a reference CLI for your category in `AGENTS.md` when the category has one. `mail`, `crm` and `other:` have none
42
+ yet; `AGENTS.md` then says to pick the nearest one with the owner from the Reference CLIs page. It does not
43
+ install packages, push, create the repository or publish. Then:
43
44
 
44
45
  ```sh
45
46
  cd gcal-cli && pnpm install && pnpm ci:quick
@@ -80,8 +81,9 @@ installing that command; nothing else is registered anywhere.
80
81
  [WC-CMD-29](commands.md#wc-cmd-29--answer---wcat-describe-and-take-no-name-wirecat-reserves) asks a CLI outside
81
82
  WireCat not to take one.
82
83
  - **The command.** `"bin": { "wcat-<name>": "dist/bin/<name>.js" }`. `cli-dev lint` warns about a `"bin"` key without
83
- the `wcat-` prefix. The template still writes the short name, and moves to `wcat-<name>` in a later release.
84
- - **The description `wcat --help` shows.** Call `wcatStart` first in the bin, before the program loads:
84
+ the `wcat-` prefix. The template still writes the short name, `"bin": { "<name>": "dist/bin/<name>.js" }`.
85
+ - **The description `wcat --help` shows.** The template's bin does not call `wcatStart` yet: add it first in the bin,
86
+ before the program loads:
85
87
 
86
88
  ```ts
87
89
  import { wcatStart } from "@wirecat/cli-base/wcat/start"
@@ -93,6 +95,25 @@ installing that command; nothing else is registered anywhere.
93
95
 
94
96
  It answers `--wcat-describe`, runs `wcat` when the `wcat` launcher starts the tool, and on any other start makes sure
95
97
  the `wcat` launcher in the tool's bin folder works. `cli-dev lint --cli` warns when the built CLI does not answer.
98
+ - **The manifest WireCat Desktop reads.** Export the identity for it, and commit `contracts/wirecat.json`:
99
+
100
+ ```ts
101
+ import type { ManifestIdentity } from "@wirecat/cli-base/wcat/manifest"
102
+
103
+ export const WCAT: ManifestIdentity = {
104
+ ...IDENTITY,
105
+ docs: "https://example.com/gcal",
106
+ tagline: "Google Calendar events, searchable on your computer",
107
+ signIn: { gives: "Lets your agent read your calendar.", asks: "Google asks to allow read-only access." },
108
+ }
109
+ ```
110
+
111
+ `cli-dev manifest --program dist/program.js --identity dist/wcat.js` writes the file; `--check` in CI fails when it
112
+ is stale. Pass `WCAT` to `wcatStart` too, so the two never differ. List `contracts/wirecat.json`, not all of `contracts`, in
113
+ `files` ([WC-REL-16](releases.md#wc-rel-16--the-package-ships-only-the-files-it-names)). A CLI with a
114
+ `sync` command also sets `syncs`, what it copies in at most 40 characters. The file holds no version, and
115
+ `mcpServer` no port: Desktop reads the version from npm and gives the tool a free port. A command the manifest lists
116
+ without `effects` counts as a write; `permissionOf` adds each command's permission key. See [WC-CMD-29](commands.md#wc-cmd-29--answer---wcat-describe-and-take-no-name-wirecat-reserves).
96
117
  - **The short name.** `wcat shortcuts add <name>` makes `<name>` a shortcut to `wcat-<name>`, only when no program on
97
118
  PATH has that name. A CLI does not install its short name itself.
98
119
 
@@ -189,7 +189,9 @@ on the [CI](ci.md) page.
189
189
  A CLI's `files` holds only what the installed CLI runs from or shows its user: `dist`, the agent skill (`skills`),
190
190
  `README.md`, `LICENSE`, and files its code reads or runs after install, such as `scenarios` for `guide`, an `install`
191
191
  script, third-party notices and licenses. `CHANGELOG.md` may ship too. It never holds `src/`, tests, fakes or
192
- fixtures, `scripts/`, `.github/`, `bin/release`, `config/`, `lint/`, `contracts/`, `docs/dev/` or `template.json`.
192
+ fixtures, `scripts/`, `.github/`, `bin/release`, `config/`, `lint/`, `contracts/`, `docs/dev/` or `template.json`. The one
193
+ exception is `contracts/wirecat.json`, the manifest WireCat Desktop reads before it installs the tool
194
+ ([WC-CMD-29](commands.md#wc-cmd-29--answer---wcat-describe-and-take-no-name-wirecat-reserves)).
193
195
 
194
196
  - **Why:** a stray file in the package can leak local data and grows every install.
195
197
  - **Enforced by:** `node-ci.yml:check` · `<app>: pnpm package:check` · `whatsapp-cli: pnpm release:check`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-base",
3
- "version": "0.80.9",
3
+ "version": "0.81.0",
4
4
  "description": "The parts every command line tool needs: output modes, terminal rendering, error model, exit codes, credentials, clocks",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Viacheslav Ptsarev",
@@ -99,6 +99,10 @@
99
99
  "types": "./dist/wcat/start.d.ts",
100
100
  "default": "./dist/wcat/start.js"
101
101
  },
102
+ "./wcat/manifest": {
103
+ "types": "./dist/wcat/manifest.d.ts",
104
+ "default": "./dist/wcat/manifest.js"
105
+ },
102
106
  "./biome": "./config/biome.base.json",
103
107
  "./tsconfig.base.json": "./config/tsconfig.base.json",
104
108
  "./tsconfig.test.json": "./config/tsconfig.test.json",