@wirecat/cli-base 0.84.0 → 0.85.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 +28 -0
- package/dist/commands/registry.d.ts +2 -0
- package/dist/commands/registry.js +2 -0
- package/dist/dev/lint.d.ts +5 -1
- package/dist/dev/lint.js +5 -1
- package/dist/dev/main.js +21 -0
- package/dist/dev/network.d.ts +23 -0
- package/dist/dev/network.js +75 -0
- package/dist/http/fetch.d.ts +12 -0
- package/dist/http/fetch.js +69 -0
- package/dist/http/hosts.d.ts +5 -0
- package/dist/http/hosts.js +14 -0
- package/dist/http/index.d.ts +2 -0
- package/dist/http/index.js +2 -0
- package/dist/standards/lint.d.ts +1 -1
- package/dist/standards/lint.js +13 -1
- package/dist/wcat/manifest.d.ts +22 -0
- package/dist/wcat/manifest.js +51 -5
- package/docs/standards/README.md +1 -1
- package/docs/standards/architecture.md +4 -2
- package/docs/standards/ci.md +3 -3
- package/docs/standards/commands.md +30 -3
- package/docs/standards/new-cli.md +7 -0
- package/docs/standards/permissions.md +1 -2
- package/docs/standards/store.md +1 -1
- package/docs/standards/toolchain.md +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,34 @@ 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.85.0 — 08.11.2026
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **The manifest says what each command touches and which hosts the CLI talks to.** `contracts/wirecat.json` gives
|
|
16
|
+
each command its one-line `summary` and its `entity`, lists under `entities` the fields each query covers, and
|
|
17
|
+
writes `network: { hosts, user_hosts? }` from the identity's new `hosts` and `userHosts`. WireCat Desktop can then
|
|
18
|
+
tell a person, before they install a CLI it has not reviewed, "reads contacts: name, email, phone" and which hosts
|
|
19
|
+
it reaches. Every key is optional inside `wcat_manifest: 2`; a reader that does not know them ignores them.
|
|
20
|
+
- **`hostFetch` in `@wirecat/cli-base/http` reaches only the hosts a CLI declares.** It refuses any other host before
|
|
21
|
+
a byte is sent, checks every redirect hop, drops credentials on a hop to another origin and bounds the exchange
|
|
22
|
+
with a timeout (30 s by default). Pass it the identity's `hosts`.
|
|
23
|
+
|
|
24
|
+
### Changed — may break callers
|
|
25
|
+
|
|
26
|
+
- **`cli-dev lint` reads the CLI's own `src` with two new rules, `raw-network` and `undeclared-host`.** The first
|
|
27
|
+
fails network code that goes around `hostFetch` (`node:https`, `axios`, `undici`, `ws`, the global `fetch` and the
|
|
28
|
+
like), the second a URL host the shipped manifest's `network.hosts` does not list (skipped while it lists none).
|
|
29
|
+
A CLI that upgrades fixes them, runs `--write-baseline`, or says why in `lint/overrides.json`. Its
|
|
30
|
+
`contracts/wirecat.json` also goes stale once (the new `summary` and `entity` keys): run `cli-dev manifest`.
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- **The handbook says where bitrix24-cli stands today.** WC-PERM-23 lists no exceptions: b24 and beeline both hand
|
|
35
|
+
`configuration` to the program and to `appMcpCommand`. WC-ARCH-5's known gap names only what is still b24's own
|
|
36
|
+
(people, organizations, products, users). b24 joins "the WireCat repositories" in the CI and toolchain pages, the
|
|
37
|
+
`pr.yml` list of WC-CI-5 and the CLIs WC-STORE-1 applies to.
|
|
38
|
+
|
|
11
39
|
## 0.84.0 — 08.11.2026
|
|
12
40
|
|
|
13
41
|
### Added
|
|
@@ -113,6 +113,8 @@ export declare const annotateOption: <T extends Option>(option: T, meta: OptionM
|
|
|
113
113
|
export declare const optionMetaOf: (option: Option) => OptionMeta;
|
|
114
114
|
export declare const describeProgram: (root: Command) => CommandInfo[];
|
|
115
115
|
export declare const describeOptions: (command: Command) => OptionInfo[];
|
|
116
|
+
/** The one-line help `--help` shows: the summary, else the description's first line. */
|
|
117
|
+
export declare const summaryOf: (command: Pick<CommandInfo, "summary" | "description">) => string;
|
|
116
118
|
export declare const flatten: (commands: readonly CommandInfo[]) => CommandInfo[];
|
|
117
119
|
/**
|
|
118
120
|
* What a next step may name, by command path (`messages list`): its effects, and the arguments and options it takes
|
|
@@ -15,6 +15,8 @@ export const annotateOption = (option, meta) => {
|
|
|
15
15
|
export const optionMetaOf = (option) => optionLabels.get(option) ?? {};
|
|
16
16
|
export const describeProgram = (root) => visible(root).map((child) => describe(child, root.name(), [], { offMcp: false, noOffline: false }));
|
|
17
17
|
export const describeOptions = (command) => command.options.filter((option) => !option.hidden).map(describeOption);
|
|
18
|
+
/** The one-line help `--help` shows: the summary, else the description's first line. */
|
|
19
|
+
export const summaryOf = (command) => (command.summary ?? command.description.split("\n")[0] ?? "").trim();
|
|
18
20
|
export const flatten = (commands) => commands.flatMap((command) => [command, ...flatten(command.commands)]);
|
|
19
21
|
const snake = (name) => name.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`).replaceAll("-", "_");
|
|
20
22
|
/**
|
package/dist/dev/lint.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type CommandsDocument } from "../commands/document.js";
|
|
2
2
|
import type { CommandInfo, OptionInfo } from "../commands/index.js";
|
|
3
|
+
import { summaryOf } from "../commands/registry.js";
|
|
3
4
|
import { type LintRule, type Override } from "../standards/lint.js";
|
|
4
5
|
import type { Vocabulary } from "../standards/vocabulary.js";
|
|
6
|
+
import { type NetworkContext } from "./network.js";
|
|
5
7
|
export interface Violation {
|
|
6
8
|
rule: string;
|
|
7
9
|
/** What the baseline and overrides name: `chats list`, `chats show <chat>`, `chats list --limit`, `--until`. */
|
|
@@ -12,7 +14,7 @@ export declare const walk: (commands: readonly CommandInfo[]) => CommandInfo[];
|
|
|
12
14
|
export declare const longName: (flags: string) => string;
|
|
13
15
|
/** A flag's kind of value: its value name, or `switch`. Two kinds under one name are two meanings. */
|
|
14
16
|
export declare const kindOf: (option: OptionInfo) => string;
|
|
15
|
-
export
|
|
17
|
+
export { summaryOf };
|
|
16
18
|
export interface LintContext {
|
|
17
19
|
/** The commands document as the CLI printed it; parsing drops keys it does not know, so casing is checked here. */
|
|
18
20
|
raw?: unknown;
|
|
@@ -23,6 +25,8 @@ export interface LintContext {
|
|
|
23
25
|
schemas?: Readonly<Record<string, unknown>>;
|
|
24
26
|
/** What `cli-dev lint --cli` saw when it made the built CLI fail once in an empty home; absent with `--commands`. */
|
|
25
27
|
runLog?: RunLogProbe;
|
|
28
|
+
/** The CLI's own source and declared hosts, for `raw-network` and `undeclared-host`; absent, both find nothing. */
|
|
29
|
+
network?: NetworkContext;
|
|
26
30
|
}
|
|
27
31
|
export interface RunLogProbe {
|
|
28
32
|
kept: boolean;
|
package/dist/dev/lint.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
import { commandsDocumentJsonSchema } from "../commands/document.js";
|
|
3
|
+
import { summaryOf } from "../commands/registry.js";
|
|
3
4
|
import { exampleProblems } from "../query/registry.js";
|
|
4
5
|
import { queryAstSchema, queryNodeSchema } from "../query/types.js";
|
|
5
6
|
import { errorObjectSchema } from "../standards/errors.js";
|
|
@@ -8,6 +9,7 @@ import { LINT_RULES } from "../standards/lint.js";
|
|
|
8
9
|
import { isContentKey, logAttributesJsonSchema, logRecordSchema } from "../standards/log.js";
|
|
9
10
|
import { itemEnvelopeSchema, jsonlEndSchema, jsonlItemSchema, listEnvelopeSchema } from "../standards/output.js";
|
|
10
11
|
import { jsonSchemaOf, SNAKE_CASE } from "../standards/registry.js";
|
|
12
|
+
import { rawNetwork, undeclaredHosts } from "./network.js";
|
|
11
13
|
const SUMMARY_LIMIT = 80;
|
|
12
14
|
const EXAMPLES_MIN = 1;
|
|
13
15
|
const EXAMPLES_MAX = 3;
|
|
@@ -23,7 +25,7 @@ export const kindOf = (option) => {
|
|
|
23
25
|
return "switch";
|
|
24
26
|
return option.flags.match(/[<[]([^>\]]+)[>\]]/)?.[1]?.toLowerCase() ?? "value";
|
|
25
27
|
};
|
|
26
|
-
export
|
|
28
|
+
export { summaryOf };
|
|
27
29
|
const label = (command) => command.path.join(" ");
|
|
28
30
|
/** The run log's reader and its switches; what `runsCommand` and cli-core's shared program add. */
|
|
29
31
|
export const RUN_LOG_COMMANDS = ["runs list", "runs show"];
|
|
@@ -423,6 +425,8 @@ const CHECKS = {
|
|
|
423
425
|
: []),
|
|
424
426
|
];
|
|
425
427
|
},
|
|
428
|
+
"raw-network": (_document, _vocabulary, context) => (context.network ? rawNetwork(context.network) : []),
|
|
429
|
+
"undeclared-host": (_document, _vocabulary, context) => (context.network ? undeclaredHosts(context.network) : []),
|
|
426
430
|
};
|
|
427
431
|
export const lintRuleIds = () => Object.keys(CHECKS);
|
|
428
432
|
/** Every violation, one per rule and target, sorted. Generated commands keep the names of the API they mirror. */
|
package/dist/dev/main.js
CHANGED
|
@@ -25,6 +25,7 @@ import { readCapabilities } from "./capabilities.js";
|
|
|
25
25
|
import { CONFORMANCE_USAGE, conformanceCommand } from "./conformance.js";
|
|
26
26
|
import { changelogChange, landChange, landFold, newestTag, processShell, restoreChange } from "./land.js";
|
|
27
27
|
import { baselineOf, judge, lintCommands, RUN_LOG_COMMANDS, walk } from "./lint.js";
|
|
28
|
+
import { readSources } from "./network.js";
|
|
28
29
|
import { nextVersion } from "./next-version.js";
|
|
29
30
|
import { slowTests } from "./slow-tests.js";
|
|
30
31
|
import { matrixPage, matrixRows, parseArgvLog } from "./test-matrix.js";
|
|
@@ -461,6 +462,7 @@ const lintRun = (args, io) => {
|
|
|
461
462
|
raw,
|
|
462
463
|
schemas: schemas,
|
|
463
464
|
...(values.cli && hasRuns ? { runLog: probeRunLog(io.cwd, values.cli) } : {}),
|
|
465
|
+
network: networkContext(io.cwd),
|
|
464
466
|
});
|
|
465
467
|
const severity = new Map(LINT_RULES.map((rule) => [rule.id, rule.severity]));
|
|
466
468
|
if (values["write-baseline"]) {
|
|
@@ -500,8 +502,27 @@ const lintRun = (args, io) => {
|
|
|
500
502
|
if (values["allow-stale"])
|
|
501
503
|
for (const line of stale)
|
|
502
504
|
io.err(`warning ${line}`);
|
|
505
|
+
if (!existsSync(join(io.cwd, MANIFEST_FILE)) || !shippedHosts(io.cwd))
|
|
506
|
+
io.err(`undeclared-host: skipped, ${MANIFEST_FILE} declares no network.hosts`);
|
|
503
507
|
return report(io, problems, "lint: ok");
|
|
504
508
|
};
|
|
509
|
+
const shippedManifest = (cwd) => {
|
|
510
|
+
const path = join(cwd, MANIFEST_FILE);
|
|
511
|
+
return existsSync(path) ? readJson(path) : undefined;
|
|
512
|
+
};
|
|
513
|
+
const shippedHosts = (cwd) => {
|
|
514
|
+
const hosts = shippedManifest(cwd)?.network?.hosts;
|
|
515
|
+
return Array.isArray(hosts) ? hosts.filter((host) => typeof host === "string") : undefined;
|
|
516
|
+
};
|
|
517
|
+
const networkContext = (cwd) => {
|
|
518
|
+
const docs = shippedManifest(cwd)?.docs_url;
|
|
519
|
+
const hosts = shippedHosts(cwd);
|
|
520
|
+
return {
|
|
521
|
+
sources: readSources(cwd),
|
|
522
|
+
...(hosts ? { hosts } : {}),
|
|
523
|
+
...(typeof docs === "string" && URL.canParse(docs) ? { docsHost: new URL(docs).hostname } : {}),
|
|
524
|
+
};
|
|
525
|
+
};
|
|
505
526
|
const wcatWarnings = (cwd, cli) => {
|
|
506
527
|
const pkgPath = join(cwd, "package.json");
|
|
507
528
|
const pkg = existsSync(pkgPath) ? readJson(pkgPath) : {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface SourceFile {
|
|
2
|
+
/** Relative to the CLI's root, with `/`: `src/api/client.ts`. */
|
|
3
|
+
path: string;
|
|
4
|
+
text: string;
|
|
5
|
+
}
|
|
6
|
+
/** What a run of `cli-dev lint` knows about the CLI's network: its own source and what its manifest declares. */
|
|
7
|
+
export interface NetworkContext {
|
|
8
|
+
sources: readonly SourceFile[];
|
|
9
|
+
/** `network.hosts` of the shipped manifest; absent when it declares none, and the host check is skipped. */
|
|
10
|
+
hosts?: readonly string[];
|
|
11
|
+
docsHost?: string;
|
|
12
|
+
}
|
|
13
|
+
/** The CLI's own source under `src`; tests, fixtures and the fakes in `src/testing` left out. */
|
|
14
|
+
export declare const readSources: (cwd: string, dir?: string) => SourceFile[];
|
|
15
|
+
export declare const rawNetwork: ({ sources }: NetworkContext) => {
|
|
16
|
+
target: string;
|
|
17
|
+
message: string;
|
|
18
|
+
}[];
|
|
19
|
+
/** One finding per host, so a host named in many files takes one override. */
|
|
20
|
+
export declare const undeclaredHosts: ({ sources, hosts, docsHost, }: NetworkContext) => {
|
|
21
|
+
target: string;
|
|
22
|
+
message: string;
|
|
23
|
+
}[];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { join, relative } from "node:path";
|
|
3
|
+
import { hostCovered } from "../http/hosts.js";
|
|
4
|
+
const NETWORK_MODULES = /^(?:(?:node:)?(?:http|https|http2|net|tls|dgram)|undici|axios|got|node-fetch|ws)(?:\/.*)?$/;
|
|
5
|
+
const SKIPPED_DIRS = new Set([
|
|
6
|
+
"node_modules",
|
|
7
|
+
"dist",
|
|
8
|
+
"test",
|
|
9
|
+
"tests",
|
|
10
|
+
"testing",
|
|
11
|
+
"__tests__",
|
|
12
|
+
"fixtures",
|
|
13
|
+
"__fixtures__",
|
|
14
|
+
]);
|
|
15
|
+
const SOURCE_FILE = /\.(?:ts|tsx|mts|cts|js|jsx|mjs|cjs)$/;
|
|
16
|
+
const NOT_SOURCE = /\.(?:test|spec)\.[^.]+$|\.d\.[cm]?ts$/;
|
|
17
|
+
/** The CLI's own source under `src`; tests, fixtures and the fakes in `src/testing` left out. */
|
|
18
|
+
export const readSources = (cwd, dir = "src") => {
|
|
19
|
+
const root = join(cwd, dir);
|
|
20
|
+
if (!existsSync(root))
|
|
21
|
+
return [];
|
|
22
|
+
const walk = (at) => readdirSync(at).flatMap((name) => {
|
|
23
|
+
const path = join(at, name);
|
|
24
|
+
if (statSync(path).isDirectory())
|
|
25
|
+
return SKIPPED_DIRS.has(name) ? [] : walk(path);
|
|
26
|
+
return SOURCE_FILE.test(name) && !NOT_SOURCE.test(name)
|
|
27
|
+
? [{ path: relative(cwd, path).split("\\").join("/"), text: readFileSync(path, "utf8") }]
|
|
28
|
+
: [];
|
|
29
|
+
});
|
|
30
|
+
return walk(root).sort((a, b) => (a.path < b.path ? -1 : 1));
|
|
31
|
+
};
|
|
32
|
+
const MODULE_REF = /\b(?:import\s+(type\s+)?(?:[\w$*{}\s,]+?\s+from\s*)?|export\s+(type\s+)?[\w$*{}\s,]*?\s*from\s*|import\s*\(\s*|require\s*\(\s*)["']([^"']+)["']/g;
|
|
33
|
+
// A file that binds its own `fetch` (an injected FetchLike, `const fetch = hostFetch(…)`) calls that one.
|
|
34
|
+
const BINDS_FETCH = /\b(?:const|let|var|function)\s+fetch\b|[{,(]\s*fetch\s*[,}):=]/;
|
|
35
|
+
const GLOBAL_FETCH_CALL = /(?<![\w$.])fetch\s*\(/;
|
|
36
|
+
const GLOBAL_FETCH = /(?<!\btypeof\s+)\b(?:globalThis|window|self)\s*\.\s*fetch\b/;
|
|
37
|
+
export const rawNetwork = ({ sources }) => sources.flatMap(({ path, text }) => {
|
|
38
|
+
const modules = [...text.matchAll(MODULE_REF)]
|
|
39
|
+
.filter(([, type, exportType, module]) => !type && !exportType && module && NETWORK_MODULES.test(module))
|
|
40
|
+
.map(([, , , module]) => module);
|
|
41
|
+
const fetches = [
|
|
42
|
+
...(GLOBAL_FETCH.test(text) || (GLOBAL_FETCH_CALL.test(text) && !BINDS_FETCH.test(text)) ? ["fetch"] : []),
|
|
43
|
+
];
|
|
44
|
+
return [...new Set([...modules, ...fetches])].map((what) => ({
|
|
45
|
+
target: `${path} ${what}`,
|
|
46
|
+
message: what === "fetch"
|
|
47
|
+
? "calls the global fetch: use hostFetch from @wirecat/cli-base/http, which reaches only the declared hosts"
|
|
48
|
+
: `imports ${what}: send HTTP through hostFetch from @wirecat/cli-base/http, or say why in lint/overrides.json`,
|
|
49
|
+
}));
|
|
50
|
+
});
|
|
51
|
+
const URL_HOST = /\bhttps?:\/\/([a-z0-9.-]+)/gi;
|
|
52
|
+
const COMMENT_LINE = /^\s*(?:\/\/|\/\*|\*)/;
|
|
53
|
+
/** Names, not addresses: placeholders and schema or namespace identifiers nobody fetches. */
|
|
54
|
+
const NOT_CONTACTED = /(?:^|\.)(?:example(?:\.com|\.org|\.net)?|test|invalid)$|^(?:json-schema\.org|www\.w3\.org)$/;
|
|
55
|
+
/** One finding per host, so a host named in many files takes one override. */
|
|
56
|
+
export const undeclaredHosts = ({ sources, hosts, docsHost, }) => {
|
|
57
|
+
if (hosts === undefined)
|
|
58
|
+
return [];
|
|
59
|
+
const files = new Map();
|
|
60
|
+
for (const { path, text } of sources)
|
|
61
|
+
for (const line of text.split("\n"))
|
|
62
|
+
if (!COMMENT_LINE.test(line))
|
|
63
|
+
for (const [, found] of line.matchAll(URL_HOST)) {
|
|
64
|
+
const host = found.toLowerCase().replace(/\.$/, "");
|
|
65
|
+
if (host === docsHost || NOT_CONTACTED.test(host) || hostCovered(host, hosts))
|
|
66
|
+
continue;
|
|
67
|
+
const seen = files.get(host) ?? [];
|
|
68
|
+
if (!seen.includes(path))
|
|
69
|
+
files.set(host, [...seen, path]);
|
|
70
|
+
}
|
|
71
|
+
return [...files].map(([host, paths]) => ({
|
|
72
|
+
target: host,
|
|
73
|
+
message: `named in ${paths.join(", ")} but not in network.hosts: add it to \`hosts\` in the WCAT identity and run cli-dev manifest`,
|
|
74
|
+
}));
|
|
75
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FetchLike } from "./index.js";
|
|
2
|
+
export interface HostFetchOptions {
|
|
3
|
+
/** The identity's `hosts`, plus any host the person configured (`userHosts`). */
|
|
4
|
+
hosts: readonly string[];
|
|
5
|
+
fetch?: FetchLike;
|
|
6
|
+
/** For the whole exchange, every redirect and the body. */
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
redirects?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const HOST_FETCH_TIMEOUT_MS = 30000;
|
|
11
|
+
/** `fetch` that reaches only the declared hosts, checks every redirect hop, and gives up after `timeoutMs`. */
|
|
12
|
+
export declare const hostFetch: (options: HostFetchOptions) => FetchLike;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { CliError, isCliError } from "../errors.js";
|
|
2
|
+
import { hostCovered, hostProblems } from "./hosts.js";
|
|
3
|
+
export const HOST_FETCH_TIMEOUT_MS = 30_000;
|
|
4
|
+
const REDIRECTS = 5;
|
|
5
|
+
const REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
|
|
6
|
+
const CREDENTIAL_HEADERS = ["authorization", "cookie", "proxy-authorization"];
|
|
7
|
+
const undeclared = (url) => new CliError("configuration_error", `${url.hostname} is not a host this CLI declares: add "${url.hostname}" to \`hosts\` in its WCAT identity and run cli-dev manifest`, { reason: "network.host-undeclared", sent: false });
|
|
8
|
+
const checked = (url, hosts) => {
|
|
9
|
+
if (url.protocol !== "https:" && url.protocol !== "http:")
|
|
10
|
+
throw new CliError("validation_error", `only http and https are fetched, not ${url.protocol.replace(/:$/, "")}`, {
|
|
11
|
+
sent: false,
|
|
12
|
+
});
|
|
13
|
+
if (!hostCovered(url.hostname, hosts))
|
|
14
|
+
throw undeclared(url);
|
|
15
|
+
return url;
|
|
16
|
+
};
|
|
17
|
+
/** `fetch` that reaches only the declared hosts, checks every redirect hop, and gives up after `timeoutMs`. */
|
|
18
|
+
export const hostFetch = (options) => {
|
|
19
|
+
const problems = hostProblems(options.hosts);
|
|
20
|
+
if (problems.length > 0)
|
|
21
|
+
throw new CliError("configuration_error", problems.join("; "));
|
|
22
|
+
const { hosts, fetch: send = globalThis.fetch, timeoutMs = HOST_FETCH_TIMEOUT_MS, redirects = REDIRECTS } = options;
|
|
23
|
+
return async (input, init = {}) => {
|
|
24
|
+
const request = input instanceof Request ? input : undefined;
|
|
25
|
+
let url = checked(new URL(request?.url ?? String(input)), hosts);
|
|
26
|
+
const caller = init.signal ?? request?.signal;
|
|
27
|
+
const timeout = AbortSignal.timeout(timeoutMs);
|
|
28
|
+
const signal = caller ? AbortSignal.any([caller, timeout]) : timeout;
|
|
29
|
+
const follow = (init.redirect ?? request?.redirect ?? "follow") === "follow";
|
|
30
|
+
let method = (init.method ?? request?.method ?? "GET").toUpperCase();
|
|
31
|
+
let body = init.body ?? request?.body ?? undefined;
|
|
32
|
+
const headers = new Headers(init.headers ?? request?.headers);
|
|
33
|
+
try {
|
|
34
|
+
let response = await send(input, { ...init, signal, ...(follow ? { redirect: "manual" } : {}) });
|
|
35
|
+
for (let hop = 0; follow && REDIRECT_STATUSES.has(response.status); hop += 1) {
|
|
36
|
+
const location = response.headers.get("location");
|
|
37
|
+
if (!location)
|
|
38
|
+
return response;
|
|
39
|
+
if (hop >= redirects)
|
|
40
|
+
throw new CliError("invalid_response", `more than ${redirects} redirects from ${url.hostname}`);
|
|
41
|
+
void response.body?.cancel().catch(() => { });
|
|
42
|
+
const next = checked(new URL(location, url), hosts);
|
|
43
|
+
if (response.status === 303 || ((response.status === 301 || response.status === 302) && method === "POST")) {
|
|
44
|
+
method = method === "HEAD" ? "HEAD" : "GET";
|
|
45
|
+
body = undefined;
|
|
46
|
+
headers.delete("content-type");
|
|
47
|
+
headers.delete("content-length");
|
|
48
|
+
}
|
|
49
|
+
else if (body instanceof ReadableStream)
|
|
50
|
+
throw new CliError("invalid_response", `${url.hostname} redirected a streamed body, which cannot be sent again`);
|
|
51
|
+
if (next.origin !== url.origin)
|
|
52
|
+
for (const name of CREDENTIAL_HEADERS)
|
|
53
|
+
headers.delete(name);
|
|
54
|
+
url = next;
|
|
55
|
+
response = await send(url, { ...init, method, headers, body, signal, redirect: "manual" });
|
|
56
|
+
}
|
|
57
|
+
return response;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
if (isCliError(error))
|
|
61
|
+
throw error;
|
|
62
|
+
if (caller?.aborted)
|
|
63
|
+
throw isCliError(caller.reason) ? caller.reason : new CliError("cancelled", "request cancelled");
|
|
64
|
+
if (timeout.aborted)
|
|
65
|
+
throw new CliError("timeout", `${url.hostname} did not answer within ${timeoutMs} ms`, { retryable: true });
|
|
66
|
+
throw new CliError("network_error", `${url.hostname} could not be reached`, { retryable: true });
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** A lower-case hostname, or `*.` and at least two labels: `api.acme.example`, `*.cdn.acme.example`, never `*.com`. */
|
|
2
|
+
export declare const HOST_PATTERN: RegExp;
|
|
3
|
+
export declare const hostProblems: (hosts: readonly string[]) => string[];
|
|
4
|
+
/** `*.x` covers every name under `x`, but not `x` itself. */
|
|
5
|
+
export declare const hostCovered: (hostname: string, hosts: readonly string[]) => boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const LABEL = "[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?";
|
|
2
|
+
/** A lower-case hostname, or `*.` and at least two labels: `api.acme.example`, `*.cdn.acme.example`, never `*.com`. */
|
|
3
|
+
export const HOST_PATTERN = new RegExp(`^(?:${LABEL}(?:\\.${LABEL})*|\\*\\.${LABEL}(?:\\.${LABEL})+)$`);
|
|
4
|
+
export const hostProblems = (hosts) => [
|
|
5
|
+
...hosts
|
|
6
|
+
.filter((host) => !HOST_PATTERN.test(host) || host.length > 253)
|
|
7
|
+
.map((host) => `${JSON.stringify(host)} is not a host: a lower-case hostname with no scheme, port or path, or one leading *. before two labels or more`),
|
|
8
|
+
...hosts.filter((host, at) => hosts.indexOf(host) !== at).map((host) => `${JSON.stringify(host)} is listed twice`),
|
|
9
|
+
];
|
|
10
|
+
/** `*.x` covers every name under `x`, but not `x` itself. */
|
|
11
|
+
export const hostCovered = (hostname, hosts) => {
|
|
12
|
+
const name = hostname.toLowerCase().replace(/\.$/, "");
|
|
13
|
+
return hosts.some((host) => (host.startsWith("*.") ? name.endsWith(host.slice(1)) : name === host));
|
|
14
|
+
};
|
package/dist/http/index.d.ts
CHANGED
|
@@ -18,3 +18,5 @@ export declare const providerWaitMs: (headers: Headers, now: WallClock) => numbe
|
|
|
18
18
|
export declare const retryableStatus: (status: number) => boolean;
|
|
19
19
|
export declare const statusToCode: (status: number) => ErrorCode;
|
|
20
20
|
export { type JsonResponseOptions, readJsonResponse } from "./body.js";
|
|
21
|
+
export { HOST_FETCH_TIMEOUT_MS, type HostFetchOptions, hostFetch } from "./fetch.js";
|
|
22
|
+
export { HOST_PATTERN, hostCovered, hostProblems } from "./hosts.js";
|
package/dist/http/index.js
CHANGED
package/dist/standards/lint.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ declare const lintRuleSchema: v.StrictObjectSchema<{
|
|
|
4
4
|
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a lower-case word, words joined by -">]>;
|
|
5
5
|
readonly severity: v.PicklistSchema<readonly ["high", "medium", "low"], undefined>;
|
|
6
6
|
/** What the rule looks at; a violation's target names one of these. */
|
|
7
|
-
readonly scope: v.PicklistSchema<["command", "group", "argument", "option", "flag", "key"], undefined>;
|
|
7
|
+
readonly scope: v.PicklistSchema<["command", "group", "argument", "option", "flag", "key", "source"], undefined>;
|
|
8
8
|
readonly summary: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
9
9
|
}, undefined>;
|
|
10
10
|
export type LintRule = v.InferOutput<typeof lintRuleSchema>;
|
package/dist/standards/lint.js
CHANGED
|
@@ -5,7 +5,7 @@ const lintRuleSchema = v.strictObject({
|
|
|
5
5
|
id: word,
|
|
6
6
|
severity: v.picklist(LINT_SEVERITIES),
|
|
7
7
|
/** What the rule looks at; a violation's target names one of these. */
|
|
8
|
-
scope: v.picklist(["command", "group", "argument", "option", "flag", "key"]),
|
|
8
|
+
scope: v.picklist(["command", "group", "argument", "option", "flag", "key", "source"]),
|
|
9
9
|
summary: text,
|
|
10
10
|
});
|
|
11
11
|
export const defineLintRules = (input) => parseRegistry("lint rules", v.array(lintRuleSchema), input, (rules) => duplicates(rules.map((rule) => rule.id)).map((id) => `"${id}" is listed twice`));
|
|
@@ -116,6 +116,18 @@ export const LINT_RULES = defineLintRules([
|
|
|
116
116
|
scope: "group",
|
|
117
117
|
summary: "the CLI keeps a failed run and reads it back: `runs list`, `runs show`, global `--record` and `--no-record`",
|
|
118
118
|
},
|
|
119
|
+
{
|
|
120
|
+
id: "raw-network",
|
|
121
|
+
severity: "high",
|
|
122
|
+
scope: "source",
|
|
123
|
+
summary: "the CLI's own source reaches the network only through `hostFetch`: no `node:http`, `https`, `net`, `tls`, `undici`, `axios`, `got`, `node-fetch` or `ws`, no global `fetch`",
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: "undeclared-host",
|
|
127
|
+
severity: "medium",
|
|
128
|
+
scope: "source",
|
|
129
|
+
summary: "every `http(s)://` host in the CLI's own source is in the manifest's `network.hosts`",
|
|
130
|
+
},
|
|
119
131
|
]);
|
|
120
132
|
/** `lint/baseline/<rule-id>.json`: today's violations of one rule, by target. It may only shrink. */
|
|
121
133
|
export const baselineSchema = v.array(text);
|
package/dist/wcat/manifest.d.ts
CHANGED
|
@@ -82,12 +82,27 @@ export declare const manifestSchema: v.StrictObjectSchema<{
|
|
|
82
82
|
readonly bin: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "lower-case letters, digits and -">]>;
|
|
83
83
|
readonly commands: v.ArraySchema<v.StrictObjectSchema<{
|
|
84
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
|
+
/** The command's one-line help; left out when it has none. */
|
|
86
|
+
readonly summary: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "one line of text">, v.MaxLengthAction<string, number, undefined>]>, undefined>;
|
|
85
87
|
readonly effects: v.StrictObjectSchema<{
|
|
86
88
|
readonly remote: v.PicklistSchema<readonly ["none", "read", "write"], undefined>;
|
|
87
89
|
readonly local: v.PicklistSchema<readonly ["none", "read", "write"], undefined>;
|
|
88
90
|
}, undefined>;
|
|
89
91
|
/** The permission key cli-core checks this command against; left out for housekeeping or when not given. */
|
|
90
92
|
readonly permission: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, undefined>;
|
|
93
|
+
/** What it answers with: its output entity, else its query's. */
|
|
94
|
+
readonly entity: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a snake_case entity name">]>, undefined>;
|
|
95
|
+
}, undefined>, undefined>;
|
|
96
|
+
/** The keys cli-base knows of each entity, from the queries over it; an entity with no query is not listed. */
|
|
97
|
+
readonly entities: v.OptionalSchema<v.RecordSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a snake_case entity name">]>, v.StrictObjectSchema<{
|
|
98
|
+
readonly fields: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a snake_case entity name">]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
|
|
99
|
+
}, undefined>, undefined>, undefined>;
|
|
100
|
+
/** Left out when the identity declares no `hosts`: the CLI did not say, which Desktop flags. */
|
|
101
|
+
readonly network: v.OptionalSchema<v.StrictObjectSchema<{
|
|
102
|
+
/** Every host the CLI contacts; `[]` says it contacts none. */
|
|
103
|
+
readonly hosts: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 253, undefined>, v.RegexAction<string, (issue: v.RegexIssue<string>) => string>]>, undefined>;
|
|
104
|
+
/** Hosts the person chooses, in words: "the mail server you sign in to". */
|
|
105
|
+
readonly user_hosts: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "one line of text">, v.MaxLengthAction<string, number, undefined>]>, undefined>;
|
|
91
106
|
}, undefined>, undefined>;
|
|
92
107
|
readonly desktop: v.StrictObjectSchema<{
|
|
93
108
|
readonly tagline: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "one line of text">, v.MaxLengthAction<string, number, undefined>]>;
|
|
@@ -160,6 +175,13 @@ export interface ManifestIdentity extends WcatTool {
|
|
|
160
175
|
signIn?: SignIn;
|
|
161
176
|
/** What `sync` copies, at most 40 characters: "contacts and deals". Required when the CLI has a sync command. */
|
|
162
177
|
syncs?: string;
|
|
178
|
+
/**
|
|
179
|
+
* Every host the CLI contacts, as `hostFetch` checks them: `["api.acme.example", "*.cdn.acme.example"]`; `[]` for
|
|
180
|
+
* none. Written to the manifest as `network.hosts`.
|
|
181
|
+
*/
|
|
182
|
+
hosts?: readonly string[];
|
|
183
|
+
/** Hosts the person chooses, at most 120 characters: "the mail server you sign in to". Needs `hosts`. */
|
|
184
|
+
userHosts?: string;
|
|
163
185
|
/** The permission key of a command path, such as cli-core's `CommandPermissions.keyOf`; `null` for none. */
|
|
164
186
|
permissionOf?: (path: readonly string[]) => string | null;
|
|
165
187
|
}
|
package/dist/wcat/manifest.js
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* without running the package, so every array holds plain words only: the same rule as Desktop's `community.rs`.
|
|
5
5
|
*/
|
|
6
6
|
import * as v from "valibot";
|
|
7
|
-
import { flatten } from "../commands/registry.js";
|
|
7
|
+
import { flatten, summaryOf } from "../commands/registry.js";
|
|
8
|
+
import { HOST_PATTERN } from "../http/hosts.js";
|
|
8
9
|
import { effectsSchema } from "../standards/effects.js";
|
|
9
|
-
import { issuesOf, jsonSchemaOf } from "../standards/registry.js";
|
|
10
|
+
import { issuesOf, jsonSchemaOf, SNAKE_CASE } from "../standards/registry.js";
|
|
10
11
|
import { PROGRAM_PREFIX, TOOL_NAME } from "./names.js";
|
|
11
12
|
export const MANIFEST_FORMAT = 2;
|
|
12
13
|
export const MANIFEST_FILE = "contracts/wirecat.json";
|
|
@@ -61,6 +62,14 @@ const desktopSchema = v.strictObject({
|
|
|
61
62
|
}),
|
|
62
63
|
settings: v.null(),
|
|
63
64
|
});
|
|
65
|
+
const hostSchema = v.pipe(v.string(), v.maxLength(253), v.regex(HOST_PATTERN, (issue) => `${JSON.stringify(issue.input)} is not a host: a lower-case hostname with no scheme, port or path, or one leading *. before two labels or more`));
|
|
66
|
+
const networkSchema = v.strictObject({
|
|
67
|
+
/** Every host the CLI contacts; `[]` says it contacts none. */
|
|
68
|
+
hosts: v.array(hostSchema),
|
|
69
|
+
/** Hosts the person chooses, in words: "the mail server you sign in to". */
|
|
70
|
+
user_hosts: v.optional(line(120)),
|
|
71
|
+
});
|
|
72
|
+
const entityName = v.pipe(v.string(), v.regex(SNAKE_CASE, "a snake_case entity name"));
|
|
64
73
|
export const manifestSchema = v.strictObject({
|
|
65
74
|
wcat_manifest: v.literal(MANIFEST_FORMAT),
|
|
66
75
|
name: v.pipe(v.string(), v.regex(TOOL_NAME, "lower-case letters, digits and -")),
|
|
@@ -70,10 +79,18 @@ export const manifestSchema = v.strictObject({
|
|
|
70
79
|
bin: v.pipe(v.string(), v.regex(TOOL_NAME, "lower-case letters, digits and -")),
|
|
71
80
|
commands: v.array(v.strictObject({
|
|
72
81
|
path: words,
|
|
82
|
+
/** The command's one-line help; left out when it has none. */
|
|
83
|
+
summary: v.optional(line(300)),
|
|
73
84
|
effects: effectsSchema,
|
|
74
85
|
/** The permission key cli-core checks this command against; left out for housekeeping or when not given. */
|
|
75
86
|
permission: v.optional(v.pipe(v.string(), v.nonEmpty())),
|
|
87
|
+
/** What it answers with: its output entity, else its query's. */
|
|
88
|
+
entity: v.optional(entityName),
|
|
76
89
|
})),
|
|
90
|
+
/** The keys cli-base knows of each entity, from the queries over it; an entity with no query is not listed. */
|
|
91
|
+
entities: v.optional(v.record(entityName, v.strictObject({ fields: v.pipe(v.array(entityName), v.minLength(1)) }))),
|
|
92
|
+
/** Left out when the identity declares no `hosts`: the CLI did not say, which Desktop flags. */
|
|
93
|
+
network: v.optional(networkSchema),
|
|
77
94
|
desktop: desktopSchema,
|
|
78
95
|
});
|
|
79
96
|
export const manifestJsonSchema = () => jsonSchemaOf(manifestSchema);
|
|
@@ -147,6 +164,22 @@ export const buildManifest = ({ identity, commands, pkg, skills }) => {
|
|
|
147
164
|
note: null,
|
|
148
165
|
}
|
|
149
166
|
: null;
|
|
167
|
+
const twice = identity.hosts?.filter((host, index) => identity.hosts?.indexOf(host) !== index) ?? [];
|
|
168
|
+
if (twice.length > 0)
|
|
169
|
+
throw new ManifestError(twice.map((host) => `hosts: ${host} is listed twice`));
|
|
170
|
+
if (identity.userHosts && !identity.hosts)
|
|
171
|
+
throw new ManifestError(["userHosts needs hosts: list the fixed hosts the CLI contacts, [] when there are none"]);
|
|
172
|
+
const runs = all.filter((command) => command.commands.length === 0 || command.runnable);
|
|
173
|
+
const fields = new Map();
|
|
174
|
+
for (const { query } of all)
|
|
175
|
+
if (query) {
|
|
176
|
+
const known = fields.get(query.entity) ?? new Set();
|
|
177
|
+
for (const field of query.fields)
|
|
178
|
+
if (field.relation === undefined)
|
|
179
|
+
known.add(field.name);
|
|
180
|
+
if (known.size > 0)
|
|
181
|
+
fields.set(query.entity, known);
|
|
182
|
+
}
|
|
150
183
|
const manifest = {
|
|
151
184
|
wcat_manifest: MANIFEST_FORMAT,
|
|
152
185
|
name: identity.command,
|
|
@@ -154,16 +187,29 @@ export const buildManifest = ({ identity, commands, pkg, skills }) => {
|
|
|
154
187
|
...(identity.docs ? { docs_url: identity.docs } : {}),
|
|
155
188
|
package: pkg.name,
|
|
156
189
|
bin: binOf(pkg, identity.command),
|
|
157
|
-
commands:
|
|
158
|
-
.filter((command) => command.commands.length === 0 || command.runnable)
|
|
159
|
-
.map((command) => {
|
|
190
|
+
commands: runs.map((command) => {
|
|
160
191
|
const permission = identity.permissionOf?.(command.path);
|
|
192
|
+
const summary = summaryOf(command);
|
|
193
|
+
const entity = command.output?.entity ?? command.query?.entity;
|
|
161
194
|
return {
|
|
162
195
|
path: [...command.path],
|
|
196
|
+
...(summary ? { summary } : {}),
|
|
163
197
|
effects: command.effects ?? UNDECLARED,
|
|
164
198
|
...(permission ? { permission } : {}),
|
|
199
|
+
...(entity ? { entity } : {}),
|
|
165
200
|
};
|
|
166
201
|
}),
|
|
202
|
+
...(fields.size > 0
|
|
203
|
+
? { entities: Object.fromEntries([...fields].map(([name, known]) => [name, { fields: [...known] }])) }
|
|
204
|
+
: {}),
|
|
205
|
+
...(identity.hosts
|
|
206
|
+
? {
|
|
207
|
+
network: {
|
|
208
|
+
hosts: [...identity.hosts],
|
|
209
|
+
...(identity.userHosts ? { user_hosts: identity.userHosts } : {}),
|
|
210
|
+
},
|
|
211
|
+
}
|
|
212
|
+
: {}),
|
|
167
213
|
desktop: {
|
|
168
214
|
tagline: identity.tagline,
|
|
169
215
|
profiles,
|
package/docs/standards/README.md
CHANGED
|
@@ -29,7 +29,7 @@ the four steps that need a person. A new CLI is ready for its first release when
|
|
|
29
29
|
|---|---|---:|---|
|
|
30
30
|
| [Toolchain](toolchain.md) | `TOOL` | 20 | TypeScript, Biome, grit plugins, size caps, import cycles, spelling, Markdown, Go |
|
|
31
31
|
| [Layout](layout.md) | `LAY` | 10 | Repository layout, entry points, exports, file size, one job per file, splitting a unit, the bundled bin |
|
|
32
|
-
| [Commands](commands.md) | `CMD` |
|
|
32
|
+
| [Commands](commands.md) | `CMD` | 32 | Paths, vocabulary, flags, arguments, effects, lifetime, query, help, external references, joining `wcat`, settings in the config file, refs, network hosts |
|
|
33
33
|
| [Output](output.md) | `OUT` | 24 | Data on stdout only, envelopes, errors, exit codes, partial answers, projection |
|
|
34
34
|
| [MCP](mcp.md) | `MCP` | 13 | The MCP tools, how they come from commands, what each permission shows |
|
|
35
35
|
| [Accounts](accounts.md) | `ACCT` | 12 | The explicit profile, reads across accounts, scope flags, linked identities, sign-in commands |
|
|
@@ -97,8 +97,10 @@ cli-core's entities, and the adapter behind cli-core's ports. CRM is the first d
|
|
|
97
97
|
with its `operation_id`); b24 builds the Bitrix24 transport, the mappers and the adapter, and mounts cli-core's
|
|
98
98
|
commands.
|
|
99
99
|
- **Exceptions:** a feature stays in one CLI only when the other providers cannot have it, such as MAX's socket server,
|
|
100
|
-
Telegram's app registration, or gcal's generated `api` commands. Known gap, as of 2026-11-
|
|
101
|
-
|
|
100
|
+
Telegram's app registration, or gcal's generated `api` commands. Known gap, as of 2026-11-08: b24's `people`,
|
|
101
|
+
`organizations`, `products` and `users` are still its own commands, read live, with its own `people` and
|
|
102
|
+
`organizations` writes; they move to cli-core's when it has them. Deals, leads, pipelines, stages and `sync` are
|
|
103
|
+
cli-core's.
|
|
102
104
|
- **Applies to:** messenger CLIs (tg, max, wa), calendar CLIs (gcal) and CRM CLIs (b24). **Since:** cli-base 0.41.0
|
|
103
105
|
(CRM, and the shared domain built first: cli-base 0.80.1). **Rulings:** NEED-820, NEED-440, NEED-301, NEED-444,
|
|
104
106
|
NEED-2298.
|
package/docs/standards/ci.md
CHANGED
|
@@ -10,7 +10,7 @@ Rule ids on this page are `WC-CI-<n>`. How to read a rule, how ids work and whic
|
|
|
10
10
|
[Releases page](releases.md); which scanners must exist and how workflows are hardened is on the
|
|
11
11
|
[Security page](security.md).
|
|
12
12
|
|
|
13
|
-
"The WireCat repositories" on this page means every WireCat CLI (today tg, max, memo, drive, zoom, wa and
|
|
13
|
+
"The WireCat repositories" on this page means every WireCat CLI (today tg, max, memo, drive, zoom, wa, gcal and b24; a
|
|
14
14
|
CLI made with `npx @wirecat/cli-template new` counts from its first commit), cli-base, cli-core, cli-testing, cli-docs,
|
|
15
15
|
plus community itself. cli-template follows every rule here as a CLI does
|
|
16
16
|
([New CLI](new-cli.md#the-template-repository-itself)).
|
|
@@ -98,8 +98,8 @@ plus community itself. cli-template follows every rule here as a CLI does
|
|
|
98
98
|
cli-docs validates its site before each deployment instead, and community has no build. Third-party security apps
|
|
99
99
|
may post their own checks.
|
|
100
100
|
- **Applies to:** the CLIs, cli-base, cli-core and cli-testing. cli-base, whatsapp-cli, tg-cli, max-cli, cli-core,
|
|
101
|
-
cli-memo, zoom-cli, drive-cli, gcal-cli and cli-template have `pr.yml`; cli-testing does not have it
|
|
102
|
-
cli-base 0.41.0 (pull request validation since cli-base 0.45.0). **Rulings:** none.
|
|
101
|
+
cli-memo, zoom-cli, drive-cli, gcal-cli, bitrix24-cli and cli-template have `pr.yml`; cli-testing does not have it
|
|
102
|
+
yet. **Since:** cli-base 0.41.0 (pull request validation since cli-base 0.45.0). **Rulings:** none.
|
|
103
103
|
|
|
104
104
|
### WC-CI-6 · Run the changelog guard on every pull request
|
|
105
105
|
|
|
@@ -7,7 +7,7 @@ lifetime it declares, the entity it prints, the query language for lists, the `m
|
|
|
7
7
|
|
|
8
8
|
Rule ids on this page are `WC-CMD-<n>`. How to read a rule, how ids work and which rule wins are in the
|
|
9
9
|
[index](README.md). What a command prints is on the [output](output.md) page. How long it runs and how it ends is on
|
|
10
|
-
the [lifecycle](lifecycle.md) page. How a CLI joins the `wcat` command is under "Joining `wcat`" below.
|
|
10
|
+
the [lifecycle](lifecycle.md) page. How a CLI joins the `wcat` command is under "Joining `wcat`" below, and which hosts it may reach under "Network".
|
|
11
11
|
|
|
12
12
|
The words themselves are not copied here. They live in the cli-base registries, and `cli-dev lint` reads them from
|
|
13
13
|
there:
|
|
@@ -379,8 +379,9 @@ The references, each for its own part:
|
|
|
379
379
|
|
|
380
380
|
A CLI ships `contracts/wirecat.json` (`wcat_manifest: 2`), written by `cli-dev manifest` from its command tree and
|
|
381
381
|
its identity, never by hand. The developer types only `tagline`, `signIn` and, with a sync command, `syncs`; the
|
|
382
|
-
commands, their `effects` and
|
|
383
|
-
|
|
382
|
+
commands, their `summary`, `effects` and `entity`, the fields of each entity a query covers, and every command word in
|
|
383
|
+
`desktop` are derived, and every word passes Desktop's plain-word rule. The hosts it contacts are typed too
|
|
384
|
+
([WC-CMD-32](#wc-cmd-32--declare-every-host-the-cli-contacts-and-reach-them-only-through-hostfetch)). The file holds nothing that changes per release (no version), and no MCP port: Desktop assigns one. With the
|
|
384
385
|
file shipped, `--wcat-describe` answers format 2: the format-1 keys with `"wcat_describe": 2`, the file's `desktop`
|
|
385
386
|
and `manifest_sha256` of its bytes. Without it the answer stays format 1.
|
|
386
387
|
|
|
@@ -443,6 +444,32 @@ right one, never `not_found`.
|
|
|
443
444
|
cli-core's reference slices.
|
|
444
445
|
- **Applies to:** all CLIs. **Since:** cli-base 0.75.3. **Rulings:** none.
|
|
445
446
|
|
|
447
|
+
## Network
|
|
448
|
+
|
|
449
|
+
### WC-CMD-32 · Declare every host the CLI contacts, and reach them only through `hostFetch`
|
|
450
|
+
|
|
451
|
+
The CLI's `WCAT` identity lists every internet host it contacts in `hosts` (`["api.acme.example"]`, `[]` for none):
|
|
452
|
+
lower-case hostnames with no scheme, port or path, and a leading `*.` only before two labels or more. A host the
|
|
453
|
+
person chooses (a mail server, a page to read) is named in words in `userHosts`, and the CLI adds the configured host
|
|
454
|
+
to the list at run time. `cli-dev manifest` writes them to `network` in `contracts/wirecat.json`. The CLI's own source
|
|
455
|
+
sends HTTP only through `hostFetch` from `@wirecat/cli-base/http`, which refuses any other host before a byte leaves
|
|
456
|
+
the machine and checks every redirect.
|
|
457
|
+
|
|
458
|
+
- **Why:** before the person installs a CLI WireCat has not reviewed, Desktop shows where its data goes. A list the
|
|
459
|
+
developer types can be wrong, so the CLI enforces it on itself at run time, and the lint finds network code that
|
|
460
|
+
goes around it.
|
|
461
|
+
- **Enforced by:** `raw-network` · `undeclared-host` · `src/http/fetch.ts` · `src/wcat/manifest.ts`.
|
|
462
|
+
- **Example:** `hosts: ["api.acme.example"]` in the identity, then
|
|
463
|
+
`const fetch = hostFetch({ hosts: WCAT.hosts ?? [] })`. `raw-network` reports `src/api.ts node:https` for an
|
|
464
|
+
import of `node:https` and `src/api.ts fetch` for a call of the global `fetch`; `undeclared-host` reports
|
|
465
|
+
`collector.acme.dev`, naming the files, for a URL whose host the shipped manifest does not list.
|
|
466
|
+
- **Exceptions:** network code that cannot use `hostFetch` (a socket protocol, a provider SDK) says why in
|
|
467
|
+
`lint/overrides.json`, and still lists its hosts. The lint is not a sandbox: a dependency, a computed URL or `eval`
|
|
468
|
+
passes it, which is why Desktop also scans the package and flags what it finds. Without `network.hosts` in the
|
|
469
|
+
shipped manifest, `undeclared-host` is skipped and `cli-dev lint` says so.
|
|
470
|
+
- **Applies to:** all CLIs, and third-party CLIs that join `wcat`. **Since:** the release after cli-base 0.84.0.
|
|
471
|
+
**Rulings:** none.
|
|
472
|
+
|
|
446
473
|
## Sources
|
|
447
474
|
|
|
448
475
|
These documents explain the rules on this page in more detail. Where one of them disagrees with this page, this page
|
|
@@ -105,6 +105,7 @@ installing that command; nothing else is registered anywhere.
|
|
|
105
105
|
docs: "https://example.com/gcal",
|
|
106
106
|
tagline: "Google Calendar events, searchable on your computer",
|
|
107
107
|
signIn: { gives: "Lets your agent read your calendar.", asks: "Google asks to allow read-only access." },
|
|
108
|
+
hosts: ["www.googleapis.com", "oauth2.googleapis.com"],
|
|
108
109
|
}
|
|
109
110
|
```
|
|
110
111
|
|
|
@@ -116,6 +117,12 @@ installing that command; nothing else is registered anywhere.
|
|
|
116
117
|
`mcpServer` no port: Desktop reads the version from npm and gives the tool a free port. A command the manifest lists
|
|
117
118
|
without `effects` counts as a write; `permissionOf` adds each command's permission key. See
|
|
118
119
|
[WC-CMD-29](commands.md#wc-cmd-29--answer---wcat-describe-and-take-no-name-wirecat-reserves).
|
|
120
|
+
- **The hosts it talks to.** `hosts` lists every host the CLI contacts (`[]` for none), and `userHosts` says in words
|
|
121
|
+
which hosts the person chooses: "the mail server you sign in to". Send HTTP through
|
|
122
|
+
`hostFetch({ hosts: WCAT.hosts ?? [] })` from `@wirecat/cli-base/http`, never `node:https`, `axios` or the global
|
|
123
|
+
`fetch`: it refuses any host not listed. `cli-dev lint` reports raw network code (`raw-network`) and URLs whose host
|
|
124
|
+
the manifest does not list (`undeclared-host`). See
|
|
125
|
+
[WC-CMD-32](commands.md#wc-cmd-32--declare-every-host-the-cli-contacts-and-reach-them-only-through-hostfetch).
|
|
119
126
|
- **A CLI published outside `@wirecat`.** WireCat Desktop adds it only when its data folder, the identity's `appName`,
|
|
120
127
|
is `<scope>-<name>` of the package or starts with `<scope>-<name>-`, with `.` and `_` read as `-`: `@acme/crm-cli`
|
|
121
128
|
keeps its data in `acme-crm-cli`. Only the scope's owner publishes under it, so the folder Desktop may delete is
|
|
@@ -405,8 +405,7 @@ builds a context of its own.
|
|
|
405
405
|
`appMcpCommand(IDENTITY, configuration, …)`. With `{ "deals": "deny" }` in the profile, `b24 work deals list`
|
|
406
406
|
exits 5 (`permission_error`) and sends nothing. cli-template's `contracts/plan.json` has
|
|
407
407
|
`"deny": { "profile": "personal" }`, so every CLI made from it runs the check on each pull request.
|
|
408
|
-
- **Exceptions:**
|
|
409
|
-
servers of b24 and beeline call `toolsFromCommands` without `permissions`.
|
|
408
|
+
- **Exceptions:** none.
|
|
410
409
|
- **Applies to:** every CLI on cli-core's `run()`. **Since:** cli-base 0.80.1. **Rulings:** none.
|
|
411
410
|
|
|
412
411
|
## Sources
|
package/docs/standards/store.md
CHANGED
|
@@ -30,7 +30,7 @@ Related pages: which account a read covers, and how a read across accounts is as
|
|
|
30
30
|
`%LOCALAPPDATA%\WireCat\Data\` on Windows). Rows are keyed by provider and account. `storePath` is the only code
|
|
31
31
|
that reads `MESSAGING_STORE` and `WIRECAT_STATE_DIR`.
|
|
32
32
|
- **Exceptions:** none. Older documents that name `messages.db` describe a store that is no longer used.
|
|
33
|
-
- **Applies to:** CLIs that keep local data through cli-core (tg, max, wa, memo, drive, zoom, gcal). **Since:** cli-base 0.41.0.
|
|
33
|
+
- **Applies to:** CLIs that keep local data through cli-core (tg, max, wa, memo, drive, zoom, gcal, b24). **Since:** cli-base 0.41.0.
|
|
34
34
|
**Rulings:** NEED-383.
|
|
35
35
|
|
|
36
36
|
### WC-STORE-2 · Reach the data through its area, and add a new kind of record as a new area
|
|
@@ -15,7 +15,7 @@ The [community standards](https://github.com/WireCatLabs/community/blob/main/sta
|
|
|
15
15
|
one source of the presets. Each repository holds a copy of them in `config/wirecat/`, installed by
|
|
16
16
|
`adopt-standards.py`.
|
|
17
17
|
|
|
18
|
-
"The WireCat repositories" on this page means every WireCat CLI (today tg, max, memo, drive, zoom, wa and
|
|
18
|
+
"The WireCat repositories" on this page means every WireCat CLI (today tg, max, memo, drive, zoom, wa, gcal and b24; a
|
|
19
19
|
CLI made with `npx @wirecat/cli-template new` counts from its first commit), cli-base, cli-core, cli-testing, cli-docs,
|
|
20
20
|
plus community itself. cli-template follows every rule here as a CLI does
|
|
21
21
|
([New CLI](new-cli.md#the-template-repository-itself)).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.85.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",
|