@wirecat/cli-base 0.105.0 → 0.107.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,64 @@ 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.107.0 — 16.11.2026
12
+
13
+ ### Added
14
+
15
+ - **`adaptOpenApi` reads the OpenAPI 3.1 unions Notion's API file uses**, which it refused before, so a CLI no longer
16
+ rewrites its spec around them. OpenAPI 3.1 takes these keywords from JSON Schema 2020-12
17
+ ([Schema Object](https://spec.openapis.org/oas/v3.1.0.html#schema-object)):
18
+ - a `{"type": "null"}` member of `oneOf` or `anyOf` makes the union `nullable`; with one member left, the result is
19
+ that member, nullable, under the outer description. `type: [..., "null"]` beside `oneOf` or `anyOf` makes the
20
+ union nullable too, which it silently did not before;
21
+ - `anyOf` is a union, as `oneOf` is: a generated union passes when any member matches, and `oneOf`'s "exactly one" was
22
+ never checked. A schema with both stops generation;
23
+ - an `allOf` with one union member, inline or behind a `$ref`, becomes a union of `allOf`s: A and (B or C) is
24
+ (A and B) or (A and C). A null member of that union is left out, not made nullable: null would also have to pass
25
+ A, which is an object. A reference to a base with a `discriminator` keeps its meaning and is not looked through;
26
+ two union members, or a union that reaches itself this way, stop generation;
27
+ - a field that is only ever `null` (`{"type": "null"}`, `type: ["null"]`) is `unknown`: the model has no null type,
28
+ and accepting more is the same trade as ignoring `not`.
29
+
30
+ `exclusiveMinimum`, `exclusiveMaximum` and `maxProperties` are still refused.
31
+ - **`cli-dev slow-tests` (`pnpm test:slow`) warns on stderr about each test over 3 s**, and still exits 0. A slow CI
32
+ runner takes up to five times as long, so such a test fails the 15 s limit there while it passes on your machine;
33
+ twice it failed a release. Shrink the test's data; a longer timeout on that one test is not the fix.
34
+ - **A new rule in the handbook's [Testing](docs/standards/testing.md) page**: every repository sets
35
+ `testTimeout: 15_000` in `vitest.config.ts`, and a test that builds big data runs within 3 s on a developer
36
+ machine. A CLI on vitest's default 5 s adds the line to its `vitest.config.ts`; the template seeds it only into new
37
+ CLIs.
38
+ - **`invitation` is a shared view word**: the text that invites people to a meeting. cli-core's shared
39
+ `meetings invitation` passed the command lint only through a CLI's own baseline (zoom-cli's
40
+ `lint/baseline/unknown-verb.json`); that baseline line can go once a CLI builds on this version.
41
+
42
+ ### Changed — may break callers
43
+
44
+ - **Generated types write a map as `{ [key: string]: T }`, not `Record<string, T>`.** A type alias may name itself
45
+ inside an index signature, not inside `Record`, so a JSON value type (string, number, boolean, null, arrays and maps
46
+ of itself) compiles. Every `types.ts` with a map changes, so `generate --check` reports it stale until the CLI
47
+ regenerates once after this bump. The types mean the same.
48
+
49
+ ## 0.106.0 — 16.11.2026
50
+
51
+ ### Added
52
+
53
+ - **`skill install` copies the whole skill folder, not only SKILL.md.** A long skill can keep a short core in SKILL.md
54
+ and the rest in files beside it (`references/tasks.md`), so an agent that opens it carries about 2,000 tokens into
55
+ every turn instead of 12,000. `installSkill`, the Hermes copy and the new `writeSkillFolder(app, skillUrl, folder)`
56
+ write every file of the folder except dotfiles and symbolic links; only SKILL.md is stamped with the version. A file
57
+ an older version shipped and this one does not stays in the installed folder. Hermes's own copy is still taken out
58
+ once Hermes reads `~/.agents/skills`, now with its other files, and still only when the folder holds nothing else.
59
+ memo's `topics/` are installed too from its next bump.
60
+ - **`skill show <name>` prints a part of the skill by its file name** (`tg skill show tasks` prints
61
+ `references/tasks.md`), for an agent that read SKILL.md from `skill show` or over MCP and has no folder to follow a
62
+ link into. A skill a library ships under the same name still wins. `skillFiles(skillUrl)` lists the parts.
63
+ - **`skillResources(app, skillUrl)` serves each part over MCP** at the address its relative link resolves to from
64
+ `<command>://skill` (`tg://skill/references/tasks.md`), after the `skillResource` it starts with. A server that
65
+ registers them all lets an MCP-only client follow the guide's links; the first one's `instruction` says so.
66
+ - **A new rule in the handbook's [Documents](docs/standards/docs.md) page**: a skill's SKILL.md stays at about 8 KB or less, with the
67
+ main user job first and one index line per linked file saying when to read it.
68
+
11
69
  ## 0.105.0 — 16.11.2026
12
70
 
13
71
  ### Fixed
@@ -73,7 +73,10 @@ export type SchemaNode = SchemaCommon & ({
73
73
  type: "allOf";
74
74
  of: readonly SchemaNode[];
75
75
  }
76
- /** Only where the source itself says "anything". An adapter never falls back to this. */
76
+ /**
77
+ * Only where the source itself says "anything", or a field that is only ever `null`, which this has no type for.
78
+ * An adapter never falls back to this.
79
+ */
77
80
  | {
78
81
  type: "unknown";
79
82
  });
@@ -28,6 +28,7 @@ const KNOWN = new Set([
28
28
  "additionalProperties",
29
29
  "allOf",
30
30
  "oneOf",
31
+ "anyOf",
31
32
  "$ref",
32
33
  "discriminator",
33
34
  ]);
@@ -50,6 +51,7 @@ const CONTRACT_MARKS = [
50
51
  "maxLength",
51
52
  "allOf",
52
53
  "oneOf",
54
+ "anyOf",
53
55
  ];
54
56
  export class OpenApiError extends Error {
55
57
  problems;
@@ -68,6 +70,10 @@ const EFFECT_BY_METHOD = {
68
70
  PATCH: "write",
69
71
  DELETE: "destructive",
70
72
  };
73
+ /** `{type: "null"}` or `type: ["null"]`: JSON Schema 2020-12's own way to say "only null". */
74
+ const isNullOnly = (source) => isObject(source) &&
75
+ (source.type === "null" ||
76
+ (Array.isArray(source.type) && source.type.length > 0 && source.type.every((t) => t === "null")));
71
77
  const pick = (source, keys) => Object.fromEntries(keys.map((key) => [key, source[key]]));
72
78
  const typeOfConst = (value) => typeof value === "string"
73
79
  ? "string"
@@ -99,6 +105,7 @@ class Adapter {
99
105
  document;
100
106
  #components;
101
107
  #parameters;
108
+ #distributing = new Set();
102
109
  constructor(document) {
103
110
  this.document = document;
104
111
  const components = isObject(document.components) ? document.components : {};
@@ -174,11 +181,21 @@ class Adapter {
174
181
  const common = this.#common(source);
175
182
  if (source.$ref !== undefined)
176
183
  return { ...common, type: "ref", ref: this.refId(source.$ref, where) };
184
+ // The model has no null type; "anything" accepts the one value this allows, as losing `not` does.
185
+ if (isNullOnly(source))
186
+ return { ...common, type: "unknown" };
177
187
  if (Array.isArray(source.allOf))
178
188
  return this.#allOf(source, source.allOf, common, where);
179
- if (Array.isArray(source.oneOf)) {
180
- const of = source.oneOf.map((member, index) => this.schema(member, `${where}.oneOf[${index}]`));
181
- return { ...common, type: "union", of };
189
+ if (Array.isArray(source.oneOf) && Array.isArray(source.anyOf)) {
190
+ this.problems.push(`${where}: both oneOf and anyOf on one schema`);
191
+ return { type: "unknown" };
192
+ }
193
+ // A union passes when any member matches, which is anyOf; oneOf's "exactly one" is never checked.
194
+ const keyword = Array.isArray(source.oneOf) ? "oneOf" : Array.isArray(source.anyOf) ? "anyOf" : undefined;
195
+ if (keyword) {
196
+ if (Array.isArray(source.type) && source.type.includes("null"))
197
+ common.nullable = true;
198
+ return this.#union(source[keyword], keyword, common, where);
182
199
  }
183
200
  const type = this.#type(source, common, where);
184
201
  const values = source.const !== undefined ? [source.const] : Array.isArray(source.enum) ? source.enum : undefined;
@@ -269,7 +286,73 @@ class Adapter {
269
286
  }
270
287
  return node;
271
288
  }
289
+ /** OpenAPI 3.1 writes a nullable reference as `oneOf: [{$ref}, {type: "null"}]`. */
290
+ #union(members, keyword, common, where) {
291
+ const kept = members.flatMap((member, index) => (isNullOnly(member) ? [] : [{ member, index }]));
292
+ const of = kept.map(({ member, index }) => this.schema(member, `${where}.${keyword}[${index}]`));
293
+ if (kept.length === members.length)
294
+ return { ...common, type: "union", of };
295
+ const [only] = of;
296
+ if (!only)
297
+ return { ...common, type: "unknown" };
298
+ if (of.length === 1)
299
+ return { ...only, ...common, nullable: true };
300
+ return { ...common, nullable: true, type: "union", of };
301
+ }
302
+ /** The members of a union an allOf member stands for, inline or behind references; never a discriminated base. */
303
+ #unionMembers(member, seen = new Set()) {
304
+ if (!isObject(member) || Array.isArray(member.allOf))
305
+ return undefined;
306
+ const members = Array.isArray(member.oneOf) ? member.oneOf : Array.isArray(member.anyOf) ? member.anyOf : undefined;
307
+ if (members)
308
+ return isObject(member.discriminator) ? undefined : { members };
309
+ const prefix = "#/components/schemas/";
310
+ if (typeof member.$ref !== "string" || !member.$ref.startsWith(prefix) || seen.has(member.$ref))
311
+ return undefined;
312
+ seen.add(member.$ref);
313
+ const found = this.#unionMembers(this.#components[member.$ref.slice(prefix.length)], seen);
314
+ return found && { ref: found.ref ?? member.$ref.slice(prefix.length), members: found.members };
315
+ }
316
+ /**
317
+ * A and (B or C) is (A and B) or (A and C): the model merges only objects, so the one union member is
318
+ * distributed over the rest, as Notion's property configs extend a common base.
319
+ */
320
+ #distribute(members, common, where) {
321
+ const unions = members.flatMap((member) => {
322
+ const found = this.#unionMembers(member);
323
+ return found ? [{ member, ...found }] : [];
324
+ });
325
+ if (unions.length === 0)
326
+ return undefined;
327
+ const [union] = unions;
328
+ if (unions.length > 1 || !union) {
329
+ this.problems.push(`${where}: an allOf of several unions`);
330
+ return { type: "unknown" };
331
+ }
332
+ if (union.ref && this.#distributing.has(union.ref)) {
333
+ this.problems.push(`${where}: an allOf distributes the union "${union.ref}" inside itself`);
334
+ return { type: "unknown" };
335
+ }
336
+ const rest = members.filter((member) => member !== union.member);
337
+ // Alone, the allOf only describes a reference, which keeps its name.
338
+ if (rest.length === 0)
339
+ return undefined;
340
+ // Null would also have to pass the rest, which the model only merges as objects: that alternative is empty.
341
+ const alternatives = union.members.filter((one) => !isNullOnly(one)).map((one) => ({ allOf: [...rest, one] }));
342
+ if (union.ref)
343
+ this.#distributing.add(union.ref);
344
+ try {
345
+ return this.#union(alternatives, "union", common, where);
346
+ }
347
+ finally {
348
+ if (union.ref)
349
+ this.#distributing.delete(union.ref);
350
+ }
351
+ }
272
352
  #allOf(source, members, common, where) {
353
+ const distributed = this.#distribute(members, common, where);
354
+ if (distributed)
355
+ return distributed;
273
356
  const of = members.map((member, index) => this.schema(member, `${where}.allOf[${index}]`));
274
357
  const [only] = of;
275
358
  // `type: object` beside a one-member allOf is inheritance with no fields of its own; without it,
@@ -47,8 +47,9 @@ class TypeWriter {
47
47
  const names = Object.keys(node.properties);
48
48
  if (literal && !names.includes(literal.property))
49
49
  names.unshift(literal.property);
50
+ // An index signature, not Record: a type alias may name itself inside one, as a JSON value does.
50
51
  const rest = node.additionalProperties
51
- ? `Record<string, ${this.node(node.additionalProperties, where)}>`
52
+ ? `{ [key: string]: ${this.node(node.additionalProperties, where)} }`
52
53
  : undefined;
53
54
  if (names.length === 0)
54
55
  return rest ?? "Record<string, unknown>";
package/dist/dev/main.js CHANGED
@@ -35,7 +35,8 @@ import { matrixPage, matrixRows, parseArgvLog } from "./test-matrix.js";
35
35
  import { binNameWarnings, describeWarnings, hostsWarnings, WCAT_RULES } from "./wcat-lint.js";
36
36
  const USAGE = `usage: cli-dev <command> [options]
37
37
 
38
- slow-tests [report] [count] the slowest tests and files (report: coverage/tests.json, count: 20)
38
+ slow-tests [report] [count] the slowest tests and files (report: coverage/tests.json, count: 20);
39
+ warns on stderr about each test over 3 s, and still exits 0
39
40
  next-version <wanted> <latest> <versions-json>
40
41
  the version bin/release publishes, given npm's answers
41
42
  version [--sync] [--file <path>] package.json's version against src/version.ts
@@ -914,7 +915,10 @@ export const main = async (argv, io) => {
914
915
  case "slow-tests": {
915
916
  const [file = "coverage/tests.json", count = "20"] = args;
916
917
  const parsed = JSON.parse(readFileSync(join(io.cwd, file), "utf8"));
917
- io.out(slowTests(parsed, io.cwd, Number(count)));
918
+ const { out, warning } = slowTests(parsed, io.cwd, Number(count));
919
+ io.out(out);
920
+ if (warning)
921
+ io.err(warning);
918
922
  return 0;
919
923
  }
920
924
  case "next-version": {
@@ -10,4 +10,8 @@ export interface VitestReport {
10
10
  }[];
11
11
  }[];
12
12
  }
13
- export declare const slowTests: (report: VitestReport, cwd: string, count: number) => string;
13
+ export declare const SLOW_TEST_MS = 3000;
14
+ export declare const slowTests: (report: VitestReport, cwd: string, count: number) => {
15
+ out: string;
16
+ warning?: string;
17
+ };
@@ -1,3 +1,5 @@
1
+ // A fifth of the 15 s limit every repository sets (WC-TEST-20): a slow CI runner takes up to five times as long.
2
+ export const SLOW_TEST_MS = 3000;
1
3
  export const slowTests = (report, cwd, count) => {
2
4
  const relative = (path) => path.slice(cwd.length + 1);
3
5
  const tests = report.testResults
@@ -6,11 +8,21 @@ export const slowTests = (report, cwd, count) => {
6
8
  const files = report.testResults
7
9
  .map((result) => ({ ms: result.endTime - result.startTime, file: result.name }))
8
10
  .sort((a, b) => b.ms - a.ms);
11
+ const line = ({ ms, file, test }) => `${ms.toFixed(0).padStart(6)} ms ${relative(file)} ${test}`;
9
12
  const total = tests.reduce((sum, test) => sum + test.ms, 0);
10
- return [
13
+ const over = tests.filter((test) => test.ms > SLOW_TEST_MS);
14
+ const out = [
11
15
  `${tests.length} tests, ${(total / 1000).toFixed(1)} s of test time\n\nslowest tests:`,
12
- ...tests.slice(0, count).map(({ ms, file, test }) => `${ms.toFixed(0).padStart(6)} ms ${relative(file)} ${test}`),
16
+ ...tests.slice(0, count).map(line),
13
17
  "\nslowest files:",
14
18
  ...files.slice(0, 10).map(({ ms, file }) => `${ms.toFixed(0).padStart(6)} ms ${relative(file)}`),
15
19
  ].join("\n");
20
+ if (over.length === 0)
21
+ return { out };
22
+ const warning = [
23
+ `warning: ${over.length} ${over.length === 1 ? "test takes" : "tests take"} over ${SLOW_TEST_MS / 1000} s, ` +
24
+ "a fifth of the 15 s test limit; a slow CI runner fails them. Shrink their data (WC-TEST-20):",
25
+ ...over.map(line),
26
+ ].join("\n");
27
+ return { out, warning };
16
28
  };
@@ -20,7 +20,18 @@ export declare const skillPath: (target: SkillTarget, appName: string, env: Env)
20
20
  export declare const skillVersion: (content: string) => string | undefined;
21
21
  /** Adds or replaces `metadata.version` as a string; every other byte stays as it was. */
22
22
  export declare const withVersion: (content: string, version: string) => string;
23
- /** Writes the stamped SKILL.md to each target, creating directories; the same run twice gives the same files. */
23
+ /**
24
+ * The files beside SKILL.md that it links to or names (`references/tasks.md`), as `/`-separated paths relative to its
25
+ * folder. A long skill keeps its core in SKILL.md and the rest in these, so an agent loads only what its task needs.
26
+ * Dotfiles and symbolic links are left out: a link could point anywhere on the machine.
27
+ */
28
+ export declare const skillFiles: (skill: URL) => string[];
29
+ /**
30
+ * Writes the stamped SKILL.md and every file of `skillFiles` into `folder`, and answers the SKILL.md written. A file
31
+ * an older version shipped and this one does not stays: the folder may hold the owner's own files too.
32
+ */
33
+ export declare const writeSkillFolder: (app: SkillApp, skill: URL, folder: string) => string;
34
+ /** Writes the skill's folder to each target, creating directories; the same run twice gives the same files. */
24
35
  export declare const installSkill: (app: SkillApp, skill: URL, { targets, env }?: {
25
36
  targets?: readonly SkillTarget[];
26
37
  env?: Env;
@@ -131,4 +142,10 @@ export interface SkillResource {
131
142
  * `server.registerResource(r.name, r.uri, { title, description, mimeType }, r.read)`. The SDK stays the host's.
132
143
  */
133
144
  export declare const skillResource: (app: SkillApp, skill: URL) => SkillResource;
145
+ /**
146
+ * `skillResource` and one resource per Markdown file beside SKILL.md, at the address its relative link resolves to
147
+ * from `<command>://skill` (`references/tasks.md` is `tg://skill/references/tasks.md`), so an MCP client follows a
148
+ * link the guide gives. Register them all; the first one's `instruction` is the line for the server.
149
+ */
150
+ export declare const skillResources: (app: SkillApp, skill: URL) => SkillResource[];
134
151
  export {};
@@ -5,9 +5,10 @@
5
5
  * Nothing here prints by itself. The command writes through the renderer and streams the host hands
6
6
  * it, and the hint is a string the host puts on stderr — never stdout, which an agent parses.
7
7
  */
8
- import { existsSync, mkdirSync, readdirSync, readFileSync, rmdirSync, rmSync, writeFileSync } from "node:fs";
8
+ import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
9
9
  import { homedir } from "node:os";
10
- import { dirname, join, resolve } from "node:path";
10
+ import { basename, dirname, join, relative, resolve, sep } from "node:path";
11
+ import { fileURLToPath, pathToFileURL } from "node:url";
11
12
  import { Command, Option } from "commander";
12
13
  import crossSpawn from "cross-spawn";
13
14
  import { annotate } from "../commands/index.js";
@@ -78,22 +79,52 @@ export const withVersion = (content, version) => {
78
79
  }
79
80
  return `---${eol}${lines.join("")}---${close}${content.slice(whole.length)}`;
80
81
  };
81
- /** Writes the stamped SKILL.md to each target, creating directories; the same run twice gives the same files. */
82
- export const installSkill = (app, skill, { targets = SKILL_TARGETS, env = process.env } = {}) => {
82
+ /**
83
+ * The files beside SKILL.md that it links to or names (`references/tasks.md`), as `/`-separated paths relative to its
84
+ * folder. A long skill keeps its core in SKILL.md and the rest in these, so an agent loads only what its task needs.
85
+ * Dotfiles and symbolic links are left out: a link could point anywhere on the machine.
86
+ */
87
+ export const skillFiles = (skill) => {
88
+ const root = dirname(fileURLToPath(skill));
89
+ const found = [];
90
+ const walk = (folder) => {
91
+ for (const entry of readdirSync(folder, { withFileTypes: true })) {
92
+ if (entry.name.startsWith("."))
93
+ continue;
94
+ const path = join(folder, entry.name);
95
+ if (entry.isDirectory())
96
+ walk(path);
97
+ else if (entry.isFile() && path !== join(root, "SKILL.md"))
98
+ found.push(relative(root, path).split(sep).join("/"));
99
+ }
100
+ };
101
+ walk(root);
102
+ return found.sort();
103
+ };
104
+ /**
105
+ * Writes the stamped SKILL.md and every file of `skillFiles` into `folder`, and answers the SKILL.md written. A file
106
+ * an older version shipped and this one does not stays: the folder may hold the owner's own files too.
107
+ */
108
+ export const writeSkillFolder = (app, skill, folder) => {
83
109
  const source = readFileSync(skill, "utf8");
84
110
  // The specification requires it, and an agent that checks skips a skill whose name and directory differ.
85
111
  const name = skillName(source);
86
112
  if (name !== app.appName) {
87
113
  throw new CliError("configuration_error", `SKILL.md is named ${name === undefined ? "nothing" : `"${name}"`}, but installs into a directory "${app.appName}"; the two must match`);
88
114
  }
89
- const content = withVersion(source, app.version);
90
- return targets.map((target) => {
91
- const path = skillPath(target, app.appName, env);
92
- mkdirSync(dirname(path), { recursive: true });
93
- writeFileSync(path, content);
94
- return path;
95
- });
115
+ const root = dirname(fileURLToPath(skill));
116
+ for (const file of skillFiles(skill)) {
117
+ const target = join(folder, file);
118
+ mkdirSync(dirname(target), { recursive: true });
119
+ writeFileSync(target, readFileSync(join(root, file)));
120
+ }
121
+ const path = join(folder, "SKILL.md");
122
+ mkdirSync(folder, { recursive: true });
123
+ writeFileSync(path, withVersion(source, app.version));
124
+ return path;
96
125
  };
126
+ /** Writes the skill's folder to each target, creating directories; the same run twice gives the same files. */
127
+ export const installSkill = (app, skill, { targets = SKILL_TARGETS, env = process.env } = {}) => targets.map((target) => writeSkillFolder(app, skill, dirname(skillPath(target, app.appName, env))));
97
128
  /** Each target's installed copy against this CLI's version; reads only, and an unreadable file is missing. */
98
129
  export const skillStatus = (app, env = process.env) => SKILL_TARGETS.map((target) => {
99
130
  const path = skillPath(target, app.appName, env);
@@ -159,16 +190,19 @@ const expanded = (entry, env) => resolve(entry
159
190
  .replace(/^~(?=$|[\\/])/, homeOf(env))
160
191
  .replace(/\$\{(\w+)\}|\$(\w+)/g, (whole, braced, bare) => env[braced ?? bare ?? ""] ?? whole));
161
192
  const lists = (dirs, folder, env) => dirs.some((entry) => expanded(entry, env) === resolve(folder));
162
- /** Our own earlier copy, alone in its folder: anything else there was put by someone else and stays. */
163
- const removeOwnCopy = (appName, env) => {
164
- const path = hermesCopyPath(appName, env);
193
+ /** Our own earlier copy: its folder holds only SKILL.md and what the skill ships; anything else was put by someone else. */
194
+ const removeOwnCopy = (app, skill, env) => {
195
+ const path = hermesCopyPath(app.appName, env);
196
+ const shipped = new Set(skillFiles(skill));
197
+ const top = new Set(["SKILL.md", ...[...shipped].map((file) => file.split("/")[0])]);
165
198
  try {
166
- if (readdirSync(dirname(path)).join() !== "SKILL.md")
199
+ if (!readdirSync(dirname(path)).every((entry) => top.has(entry)))
167
200
  return undefined;
168
- if (skillName(readFileSync(path, "utf8")) !== appName)
201
+ if (!skillFiles(pathToFileURL(path)).every((file) => shipped.has(file)))
169
202
  return undefined;
170
- rmSync(path);
171
- rmdirSync(dirname(path));
203
+ if (skillName(readFileSync(path, "utf8")) !== app.appName)
204
+ return undefined;
205
+ rmSync(dirname(path), { recursive: true });
172
206
  return path;
173
207
  }
174
208
  catch {
@@ -200,12 +234,10 @@ export const installHermesSkill = (app, skill, { env = process.env, run = runPro
200
234
  const [shared] = installSkill(app, skill, { targets: ["agents"], env });
201
235
  const reason = readFolder(dirname(dirname(shared)), env, run);
202
236
  if (reason === undefined) {
203
- const removed = removeOwnCopy(app.appName, env);
237
+ const removed = removeOwnCopy(app, skill, env);
204
238
  return { written: [shared], hermes: { via: "external_dirs", path: shared, ...(removed ? { removed } : {}) } };
205
239
  }
206
- const copy = hermesCopyPath(app.appName, env);
207
- mkdirSync(dirname(copy), { recursive: true });
208
- writeFileSync(copy, readFileSync(shared));
240
+ const copy = writeSkillFolder(app, skill, dirname(hermesCopyPath(app.appName, env)));
209
241
  return { written: [shared, copy], hermes: { via: "copy", path: copy, reason } };
210
242
  };
211
243
  /**
@@ -225,6 +257,21 @@ export const hermesSkillStatus = (app, { env = process.env, run = runProgram } =
225
257
  return { ...read, via: "external_dirs" };
226
258
  return { path: shared, installed: null, state: "missing", via: null };
227
259
  };
260
+ /**
261
+ * The skill's own Markdown files beside SKILL.md by name (`references/tasks.md` is `tasks`), for `skill show <name>`:
262
+ * an agent that read SKILL.md from `skill show` or over MCP has no folder to follow a relative link into.
263
+ */
264
+ const skillParts = (skill) => {
265
+ try {
266
+ return Object.fromEntries(skillFiles(skill)
267
+ .filter((file) => file.endsWith(".md"))
268
+ .reverse()
269
+ .map((file) => [basename(file, ".md"), new URL(file, skill)]));
270
+ }
271
+ catch {
272
+ return {};
273
+ }
274
+ };
228
275
  /**
229
276
  * `more`: skills a library ships for every CLI built on it, by name — `skill show <name>` prints one with
230
277
  * `{{command}}` turned into this CLI's command. They are printed, not installed: two CLIs would install
@@ -236,12 +283,14 @@ export const skillCommand = (app, skill, environment, more = {}) => {
236
283
  const { json, jsonl } = self.optsWithGlobals();
237
284
  return json === true || jsonl === true;
238
285
  };
239
- const named = Object.keys(more);
286
+ // The skill's own parts first, so a library's skill of the same name still wins.
287
+ const shown = { ...skillParts(skill), ...more };
288
+ const named = Object.keys(shown);
240
289
  const show = annotate(command.command("show"), { effects: { remote: "none", local: "read" } })
241
290
  .summary("print the tool's instructions for AI agents")
242
291
  .description(`print SKILL.md — \`${app.command} skill install\` puts it where Claude Code, Codex, Gemini CLI and OpenClaw look for it, and where Hermes does on request; --for prints the copy already there`);
243
292
  if (named.length > 0)
244
- show.argument("[name]", `one of the skills shipped for a task: ${named.join(", ")}`);
293
+ show.argument("[name]", `a part of this skill, or a skill shipped for a task: ${named.join(", ")}`);
245
294
  show.addOption(new Option("--for <agents>", "print the copy installed for these agents instead of this version's").choices(SKILL_TARGETS));
246
295
  show.action(function (given) {
247
296
  // Without a declared argument Commander passes the options here, not a name.
@@ -265,7 +314,7 @@ export const skillCommand = (app, skill, environment, more = {}) => {
265
314
  streams.data(content);
266
315
  return;
267
316
  }
268
- const source = name === undefined ? skill : more[name];
317
+ const source = name === undefined ? skill : shown[name];
269
318
  if (!source) {
270
319
  throw new CliError("validation_error", `no skill "${name}" — there are: ${named.join(", ")}`);
271
320
  }
@@ -363,3 +412,40 @@ export const skillResource = (app, skill) => {
363
412
  instruction: `- The full guide is the resource ${uri}; \`${app.command} skill install\` installs it as an agent skill.`,
364
413
  };
365
414
  };
415
+ /**
416
+ * `skillResource` and one resource per Markdown file beside SKILL.md, at the address its relative link resolves to
417
+ * from `<command>://skill` (`references/tasks.md` is `tg://skill/references/tasks.md`), so an MCP client follows a
418
+ * link the guide gives. Register them all; the first one's `instruction` is the line for the server.
419
+ */
420
+ export const skillResources = (app, skill) => {
421
+ const main = skillResource(app, skill);
422
+ let parts = [];
423
+ try {
424
+ parts = skillFiles(skill).filter((file) => file.endsWith(".md"));
425
+ }
426
+ catch {
427
+ // A skill read from somewhere without a folder still has its SKILL.md.
428
+ }
429
+ if (parts.length === 0)
430
+ return [main];
431
+ return [
432
+ {
433
+ ...main,
434
+ instruction: `- The guide is the resource ${main.uri}; the parts it links are ${main.uri}/<path>, read only the one a task needs. \`${app.command} skill install\` installs it as an agent skill.`,
435
+ },
436
+ ...parts.map((file) => {
437
+ const uri = `${main.uri}/${file}`;
438
+ return {
439
+ uri,
440
+ name: `skill/${file}`,
441
+ title: `${app.appName} ${file}`,
442
+ description: `A part of the ${app.command} guide that ${main.uri} links to.`,
443
+ mimeType: "text/markdown",
444
+ read: () => ({
445
+ contents: [{ uri, mimeType: "text/markdown", text: readFileSync(new URL(file, skill), "utf8") }],
446
+ }),
447
+ instruction: "",
448
+ };
449
+ }),
450
+ ];
451
+ };
@@ -372,6 +372,7 @@ const views = [
372
372
  ["transcript", "the text of speech: a voice message or a meeting recording"],
373
373
  ["evidence", "the stored messages or lines a result or a reference rests on"],
374
374
  ["passage", "a cited transcript line with bounded surrounding lines from the same revision"],
375
+ ["invitation", "the text that invites people to a meeting: how to join it and when"],
375
376
  ["agenda", "what needs a look today"],
376
377
  ["busy", "when calendars or people are taken, without what takes them"],
377
378
  ["categories", "the categories a thing takes, with what each means"],
@@ -38,9 +38,9 @@ the four steps that need a person. A new CLI is ready for its first release when
38
38
  | [Lifecycle](lifecycle.md) | `LIFE` | 16 | Opening late, who closes, deadlines, long-running commands, the `serve` relay, resumable syncs and their request budget, the run log, provider requests inside the run |
39
39
  | [Store](store.md) | `STORE` | 14 | Store areas, account scope, migrations, test isolation |
40
40
  | [Data model](data-model.md) | `DATA` | 9 | Core entities, entities and source records, `external_id`, field names, links and duplicates, files, calendar entries |
41
- | [Testing](testing.md) | `TEST` | 18 | Sandbox, no network, no real waits, leak tests, coverage, contracts, test matrix, parity, fakes as strict as the service |
41
+ | [Testing](testing.md) | `TEST` | 19 | Sandbox, no network, no real waits, one test time limit, leak tests, coverage, contracts, test matrix, parity, fakes as strict as the service |
42
42
  | [Security](security.md) | `SECR` | 24 | Secrets, logs, keyring, argv, error text, untrusted text, scanners, workflow hardening, reporting, OAuth sign-in and which app it uses, meeting secrets, keyring in moved-folder runs |
43
- | [Documents](docs.md) | `DOC` | 21 | User pages and developer pages, generated pages, current facts, changelog, repository page |
43
+ | [Documents](docs.md) | `DOC` | 22 | User pages and developer pages, generated pages, current facts, changelog, repository page |
44
44
  | [Comparisons](comparisons.md) | `CMP` | 11 | Which tools a comparison page lists, rows as user tasks, agents and safety, where others are better, proof of marks |
45
45
  | [Releases](releases.md) | `REL` | 16 | `bin/release`, the release lock, versions, the owner's yes, trusted publishing |
46
46
  | [CI](ci.md) | `CI` | 13 | Hooks, the pull request budget, full validation, monthly runs, conflict markers |
@@ -244,6 +244,25 @@ Rule ids on this page are `WC-DOC-<n>`. How to read a rule, how ids work and whi
244
244
  `cli-docs`, `cli-testing`).
245
245
  - **Applies to:** every public WireCat repository. **Since:** cli-base 0.75.3. **Rulings:** none.
246
246
 
247
+ ### WC-DOC-22 · The agent skill keeps a short core and puts the rest in files it links
248
+
249
+ An agent that opens the skill carries SKILL.md in every later turn of its session, so its size is paid many times.
250
+
251
+ - **Why:** tg's 50 KB SKILL.md (about 12,000 tokens) raised the median input of every turn of an agent from about 31,000
252
+ to 47,000 tokens, and half the sessions of a timed test ran out of time.
253
+ - **Enforced by:** `<app>: pnpm docs:check`. It runs cli-core's skill validation with a byte limit, which also checks
254
+ the links and command paths in each linked file.
255
+ - **Example:** `skills/tg-cli/SKILL.md` is at most about 8 KB (about 2,000 tokens). It holds the frontmatter, what the
256
+ tool is, the profile rule, the main user job first (for a messenger: answer a question from the chats, then read and
257
+ send), the hard boundaries, the output and exit-code basics, and an index. Everything else, verbatim or tightened
258
+ but with no rule dropped, is in `skills/tg-cli/references/<topic>.md`. Each index line names one file and says when
259
+ to read it, with both routes, for example a link to `references/tasks.md`, then `tg skill show tasks`, then "when
260
+ the owner asks about tasks or promises". An installed copy follows the link; an agent that read the skill from
261
+ `skill show` or over MCP runs the command or reads `tg://skill/references/tasks.md`. Text that `--help`,
262
+ `commands --json` or `guide` already gives stays out of both; a trap that prevents a real mistake stays.
263
+ - **Exceptions:** a SKILL.md under the limit needs no references.
264
+ - **Applies to:** every CLI that ships an agent skill. **Since:** cli-base 0.106.0. **Rulings:** none.
265
+
247
266
  ## Sources
248
267
 
249
268
  These documents explain the rules on this page in more detail. Where one of them disagrees with this page, this page
@@ -97,7 +97,8 @@ and which run after merge is in [CI](ci.md).
97
97
  - **Enforced by:** review only.
98
98
  - **Example:** waits go through an injected `SleepLike`, and `fakeClock()` from `@wirecat/cli-base/testing` records
99
99
  them without waiting. A test harness passes `sleep: async () => {}`. `pnpm test:slow` lists the 20 slowest tests
100
- and the 10 slowest files. A test may wait for a local process or server it started, for example polling its
100
+ and the 10 slowest files, and warns about each test over 3 s
101
+ ([WC-TEST-20](#wc-test-20--one-test-time-limit-of-15-s-and-each-test-runs-within-3-s)). A test may wait for a local process or server it started, for example polling its
101
102
  status with `vi.waitFor` and a timeout shorter than the test's own; that waits for an event, not for time. A
102
103
  fixed sleep or `setTimeout` is still a wait for real time.
103
104
  - **Exceptions:** none. A new wait in the code gets a seam, never a longer test timeout.
@@ -268,6 +269,26 @@ a captured answer, beside it or in the table it comes from.
268
269
  vocabulary.
269
270
  - **Applies to:** all CLIs that talk to a provider. **Since:** cli-base 0.80.1. **Rulings:** none.
270
271
 
272
+ ### WC-TEST-20 · One test time limit of 15 s, and each test runs within 3 s
273
+
274
+ Every repository sets `testTimeout: 15_000` in `vitest.config.ts`. A test that builds big data, such as a thousand
275
+ meetings or a long conversation, sizes it so the test runs within 3 s on a developer machine: a fifth of the limit,
276
+ because a slow CI runner takes up to five times as long. `pnpm test:slow` warns about each test over 3 s, so it is
277
+ shrunk before a release runner fails it.
278
+
279
+ - **Why:** twice a release failed on a slow GitHub runner with no real wait involved, only CPU work: cli-core's test
280
+ of 1200 meetings, and zoom-cli's `src/answer-entities.test.ts` at 6.9 s against vitest's default 5 s. Each
281
+ repository had its own limit (15 s in cli-core and tg-cli, 5 s in zoom-cli, gcal-cli and max-cli), so the same
282
+ test passed in one and failed in another.
283
+ - **Enforced by:** `pnpm test:slow`.
284
+ - **Example:** `vitest.config.ts` has `test: { testTimeout: 15_000 }`. A test that checks paging over many meetings
285
+ builds as many as it needs to cross two pages, not 1200. `pnpm test:slow` ends with
286
+ `warning: 1 test takes over 3 s, …` and the test's line on stderr; it still exits 0.
287
+ - **Exceptions:** none. A longer timeout on one test is not the fix: cli-core #2980 gave the 1200-meeting test 60 s,
288
+ and the next slower runner fails it again. The macOS and Windows jobs of cli-base's `node-ci.yml` pass
289
+ `--testTimeout=20000` because those runners are slower for every test, not for one.
290
+ - **Applies to:** all CLIs and the shared packages. **Since:** cli-base 0.107.0. **Rulings:** owner, 2026-11-16.
291
+
271
292
  ## Sources
272
293
 
273
294
  These documents explain the rules on this page in more detail. Where one of them disagrees with this page, this page
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirecat/cli-base",
3
- "version": "0.105.0",
3
+ "version": "0.107.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",