@ykdz/template 0.0.38 → 0.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/dist/application.d.ts +1 -52
  2. package/dist/application.js +0 -81
  3. package/dist/cli.js +14 -28
  4. package/dist/input-schemas.d.ts +30 -0
  5. package/dist/input-schemas.js +75 -0
  6. package/dist/main.d.ts +3 -14
  7. package/dist/main.js +496 -378
  8. package/dist/result-schemas.d.ts +222 -0
  9. package/dist/result-schemas.js +74 -0
  10. package/dist/standard-schema.d.ts +3 -0
  11. package/dist/standard-schema.js +29 -0
  12. package/node_modules/@standard-schema/spec/LICENSE +21 -0
  13. package/node_modules/@standard-schema/spec/README.md +198 -0
  14. package/node_modules/@standard-schema/spec/dist/index.cjs +18 -0
  15. package/node_modules/@standard-schema/spec/dist/index.d.cts +119 -0
  16. package/node_modules/@standard-schema/spec/dist/index.d.ts +119 -0
  17. package/node_modules/@standard-schema/spec/dist/index.js +0 -0
  18. package/node_modules/@standard-schema/spec/package.json +52 -0
  19. package/node_modules/@types/node/LICENSE +21 -0
  20. package/node_modules/@types/node/README.md +15 -0
  21. package/node_modules/@types/node/assert/strict.d.ts +111 -0
  22. package/node_modules/@types/node/assert.d.ts +1115 -0
  23. package/node_modules/@types/node/async_hooks.d.ts +619 -0
  24. package/node_modules/@types/node/buffer.buffer.d.ts +477 -0
  25. package/node_modules/@types/node/buffer.d.ts +1941 -0
  26. package/node_modules/@types/node/child_process.d.ts +1480 -0
  27. package/node_modules/@types/node/cluster.d.ts +578 -0
  28. package/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
  29. package/node_modules/@types/node/console.d.ts +453 -0
  30. package/node_modules/@types/node/constants.d.ts +21 -0
  31. package/node_modules/@types/node/crypto.d.ts +5484 -0
  32. package/node_modules/@types/node/dgram.d.ts +715 -0
  33. package/node_modules/@types/node/diagnostics_channel.d.ts +576 -0
  34. package/node_modules/@types/node/dns/promises.d.ts +503 -0
  35. package/node_modules/@types/node/dns.d.ts +923 -0
  36. package/node_modules/@types/node/domain.d.ts +166 -0
  37. package/node_modules/@types/node/events.d.ts +967 -0
  38. package/node_modules/@types/node/fs/promises.d.ts +1354 -0
  39. package/node_modules/@types/node/fs.d.ts +4777 -0
  40. package/node_modules/@types/node/globals.d.ts +170 -0
  41. package/node_modules/@types/node/globals.typedarray.d.ts +41 -0
  42. package/node_modules/@types/node/http.d.ts +2246 -0
  43. package/node_modules/@types/node/http2.d.ts +2882 -0
  44. package/node_modules/@types/node/https.d.ts +585 -0
  45. package/node_modules/@types/node/index.d.ts +101 -0
  46. package/node_modules/@types/node/inspector.d.ts +323 -0
  47. package/node_modules/@types/node/inspector.generated.d.ts +4406 -0
  48. package/node_modules/@types/node/module.d.ts +844 -0
  49. package/node_modules/@types/node/net.d.ts +1197 -0
  50. package/node_modules/@types/node/os.d.ts +507 -0
  51. package/node_modules/@types/node/package.json +140 -0
  52. package/node_modules/@types/node/path.d.ts +200 -0
  53. package/node_modules/@types/node/perf_hooks.d.ts +1054 -0
  54. package/node_modules/@types/node/process.d.ts +2101 -0
  55. package/node_modules/@types/node/punycode.d.ts +117 -0
  56. package/node_modules/@types/node/querystring.d.ts +152 -0
  57. package/node_modules/@types/node/readline/promises.d.ts +161 -0
  58. package/node_modules/@types/node/readline.d.ts +600 -0
  59. package/node_modules/@types/node/repl.d.ts +438 -0
  60. package/node_modules/@types/node/sea.d.ts +162 -0
  61. package/node_modules/@types/node/sqlite.d.ts +1182 -0
  62. package/node_modules/@types/node/stream/consumers.d.ts +45 -0
  63. package/node_modules/@types/node/stream/promises.d.ts +90 -0
  64. package/node_modules/@types/node/stream/web.d.ts +596 -0
  65. package/node_modules/@types/node/stream.d.ts +1707 -0
  66. package/node_modules/@types/node/string_decoder.d.ts +67 -0
  67. package/node_modules/@types/node/test.d.ts +2656 -0
  68. package/node_modules/@types/node/timers/promises.d.ts +108 -0
  69. package/node_modules/@types/node/timers.d.ts +285 -0
  70. package/node_modules/@types/node/tls.d.ts +1314 -0
  71. package/node_modules/@types/node/trace_events.d.ts +197 -0
  72. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +473 -0
  73. package/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  74. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
  75. package/node_modules/@types/node/ts5.6/index.d.ts +103 -0
  76. package/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  77. package/node_modules/@types/node/ts5.7/index.d.ts +103 -0
  78. package/node_modules/@types/node/tty.d.ts +209 -0
  79. package/node_modules/@types/node/url.d.ts +1103 -0
  80. package/node_modules/@types/node/util.d.ts +2376 -0
  81. package/node_modules/@types/node/v8.d.ts +1010 -0
  82. package/node_modules/@types/node/vm.d.ts +1160 -0
  83. package/node_modules/@types/node/wasi.d.ts +202 -0
  84. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
  85. package/node_modules/@types/node/web-globals/crypto.d.ts +32 -0
  86. package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
  87. package/node_modules/@types/node/web-globals/events.d.ts +97 -0
  88. package/node_modules/@types/node/web-globals/fetch.d.ts +62 -0
  89. package/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
  90. package/node_modules/@types/node/web-globals/storage.d.ts +24 -0
  91. package/node_modules/@types/node/web-globals/streams.d.ts +22 -0
  92. package/node_modules/@types/node/worker_threads.d.ts +894 -0
  93. package/node_modules/@types/node/zlib.d.ts +768 -0
  94. package/node_modules/@valibot/to-json-schema/LICENSE.md +9 -0
  95. package/node_modules/@valibot/to-json-schema/README.md +475 -0
  96. package/node_modules/@valibot/to-json-schema/dist/index.cjs +800 -0
  97. package/node_modules/@valibot/to-json-schema/dist/index.d.cts +991 -0
  98. package/node_modules/@valibot/to-json-schema/dist/index.d.mts +991 -0
  99. package/node_modules/@valibot/to-json-schema/dist/index.min.cjs +1 -0
  100. package/node_modules/@valibot/to-json-schema/dist/index.min.mjs +1 -0
  101. package/node_modules/@valibot/to-json-schema/dist/index.mjs +795 -0
  102. package/node_modules/@valibot/to-json-schema/package.json +75 -0
  103. package/node_modules/@ykdz/cli-contract/LICENSE +21 -0
  104. package/node_modules/@ykdz/cli-contract/dist/atomic-variant-compiler.d.ts +17 -0
  105. package/node_modules/@ykdz/cli-contract/dist/atomic-variant-compiler.js +55 -0
  106. package/node_modules/@ykdz/cli-contract/dist/cli-contract.d.ts +1164 -0
  107. package/node_modules/@ykdz/cli-contract/dist/cli-contract.js +1408 -0
  108. package/node_modules/@ykdz/cli-contract/dist/cli-execution.d.ts +54 -0
  109. package/node_modules/@ykdz/cli-contract/dist/cli-execution.js +708 -0
  110. package/node_modules/@ykdz/cli-contract/dist/cli-invocation.d.ts +174 -0
  111. package/node_modules/@ykdz/cli-contract/dist/cli-invocation.js +524 -0
  112. package/node_modules/@ykdz/cli-contract/dist/cli-write-error.d.ts +10 -0
  113. package/node_modules/@ykdz/cli-contract/dist/cli-write-error.js +14 -0
  114. package/node_modules/@ykdz/cli-contract/dist/contract-definition-error.d.ts +260 -0
  115. package/node_modules/@ykdz/cli-contract/dist/contract-definition-error.js +130 -0
  116. package/node_modules/@ykdz/cli-contract/dist/contract-execution-error.d.ts +63 -0
  117. package/node_modules/@ykdz/cli-contract/dist/contract-execution-error.js +17 -0
  118. package/node_modules/@ykdz/cli-contract/dist/contract-schema-compiler.d.ts +6 -0
  119. package/node_modules/@ykdz/cli-contract/dist/contract-schema-compiler.js +532 -0
  120. package/node_modules/@ykdz/cli-contract/dist/contract-schema.d.ts +14 -0
  121. package/node_modules/@ykdz/cli-contract/dist/contract-schema.js +1 -0
  122. package/node_modules/@ykdz/cli-contract/dist/description.d.ts +2 -0
  123. package/node_modules/@ykdz/cli-contract/dist/description.js +13 -0
  124. package/node_modules/@ykdz/cli-contract/dist/index.d.ts +8 -0
  125. package/node_modules/@ykdz/cli-contract/dist/index.js +7 -0
  126. package/node_modules/@ykdz/cli-contract/dist/json-value.d.ts +4 -0
  127. package/node_modules/@ykdz/cli-contract/dist/json-value.js +64 -0
  128. package/node_modules/@ykdz/cli-contract/dist/node.d.ts +21 -0
  129. package/node_modules/@ykdz/cli-contract/dist/node.js +109 -0
  130. package/node_modules/@ykdz/cli-contract/dist/outcome-fact.d.ts +162 -0
  131. package/node_modules/@ykdz/cli-contract/dist/outcome-fact.js +113 -0
  132. package/node_modules/@ykdz/cli-contract/dist/outcome-wire.d.ts +53 -0
  133. package/node_modules/@ykdz/cli-contract/dist/outcome-wire.js +189 -0
  134. package/node_modules/@ykdz/cli-contract/dist/stream-variant-compiler.d.ts +16 -0
  135. package/node_modules/@ykdz/cli-contract/dist/stream-variant-compiler.js +45 -0
  136. package/node_modules/@ykdz/cli-contract/package.json +69 -0
  137. package/node_modules/@ykdz/template-builtin-presets/dist/src/foundation.d.ts +20 -0
  138. package/node_modules/@ykdz/template-builtin-presets/dist/src/foundation.js +38 -2
  139. package/node_modules/@ykdz/template-builtin-presets/dist/src/generation-record.d.ts +19 -0
  140. package/node_modules/@ykdz/template-builtin-presets/dist/src/generation-record.js +1 -1
  141. package/node_modules/@ykdz/template-builtin-presets/dist/src/index.d.ts +2 -1
  142. package/node_modules/@ykdz/template-builtin-presets/dist/src/index.js +2 -1
  143. package/node_modules/@ykdz/template-builtin-presets/dist/src/ts-cli/definition.js +9 -5
  144. package/node_modules/@ykdz/template-builtin-presets/package.json +2 -1
  145. package/node_modules/@ykdz/template-builtin-presets/templates/foundation/AGENTS.md.template +5 -3
  146. package/node_modules/@ykdz/template-builtin-presets/templates/{shared/devcontainer/node-pnpm.Dockerfile → foundation/devcontainer/base.Dockerfile} +14 -1
  147. package/node_modules/@ykdz/template-builtin-presets/templates/rust-bin/devcontainer/rust.Dockerfile +1 -5
  148. package/node_modules/@ykdz/template-builtin-presets/templates/shared/devcontainer/github-cli.Dockerfile +1 -3
  149. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/artifact.ts +128 -59
  150. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/handoff.ts +80 -8
  151. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/publication/readiness.ts +7 -3
  152. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/src/cli.ts +9 -19
  153. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/src/main.ts +144 -60
  154. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/src/standard-schema.ts +37 -0
  155. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/e2e/journeys/lookup.journey.ts +71 -0
  156. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/integration/command.test.ts +118 -59
  157. package/node_modules/@ykdz/template-core/dist/dependency-catalog.d.ts +0 -1
  158. package/node_modules/@ykdz/template-core/dist/dependency-catalog.js +0 -19
  159. package/node_modules/@ykdz/template-core/dist/pnpm-workspace.yaml +3 -2
  160. package/node_modules/@ykdz/template-core/dist/project-blueprint.d.ts +15 -0
  161. package/node_modules/@ykdz/template-core/dist/project-blueprint.js +1 -1
  162. package/node_modules/@ykdz/template-core/dist/project-github.d.ts +0 -59
  163. package/node_modules/@ykdz/template-core/dist/project-github.js +0 -67
  164. package/node_modules/undici-types/LICENSE +21 -0
  165. package/node_modules/undici-types/README.md +6 -0
  166. package/node_modules/undici-types/agent.d.ts +32 -0
  167. package/node_modules/undici-types/api.d.ts +43 -0
  168. package/node_modules/undici-types/balanced-pool.d.ts +30 -0
  169. package/node_modules/undici-types/cache-interceptor.d.ts +179 -0
  170. package/node_modules/undici-types/cache.d.ts +36 -0
  171. package/node_modules/undici-types/client-stats.d.ts +15 -0
  172. package/node_modules/undici-types/client.d.ts +123 -0
  173. package/node_modules/undici-types/connector.d.ts +36 -0
  174. package/node_modules/undici-types/content-type.d.ts +21 -0
  175. package/node_modules/undici-types/cookies.d.ts +30 -0
  176. package/node_modules/undici-types/diagnostics-channel.d.ts +74 -0
  177. package/node_modules/undici-types/dispatcher.d.ts +279 -0
  178. package/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
  179. package/node_modules/undici-types/errors.d.ts +177 -0
  180. package/node_modules/undici-types/eventsource.d.ts +66 -0
  181. package/node_modules/undici-types/fetch.d.ts +211 -0
  182. package/node_modules/undici-types/formdata.d.ts +108 -0
  183. package/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  184. package/node_modules/undici-types/global-origin.d.ts +7 -0
  185. package/node_modules/undici-types/h2c-client.d.ts +73 -0
  186. package/node_modules/undici-types/handlers.d.ts +15 -0
  187. package/node_modules/undici-types/header.d.ts +160 -0
  188. package/node_modules/undici-types/index.d.ts +91 -0
  189. package/node_modules/undici-types/interceptors.d.ts +80 -0
  190. package/node_modules/undici-types/mock-agent.d.ts +68 -0
  191. package/node_modules/undici-types/mock-call-history.d.ts +111 -0
  192. package/node_modules/undici-types/mock-client.d.ts +27 -0
  193. package/node_modules/undici-types/mock-errors.d.ts +12 -0
  194. package/node_modules/undici-types/mock-interceptor.d.ts +94 -0
  195. package/node_modules/undici-types/mock-pool.d.ts +27 -0
  196. package/node_modules/undici-types/package.json +55 -0
  197. package/node_modules/undici-types/patch.d.ts +29 -0
  198. package/node_modules/undici-types/pool-stats.d.ts +19 -0
  199. package/node_modules/undici-types/pool.d.ts +41 -0
  200. package/node_modules/undici-types/proxy-agent.d.ts +29 -0
  201. package/node_modules/undici-types/readable.d.ts +68 -0
  202. package/node_modules/undici-types/retry-agent.d.ts +8 -0
  203. package/node_modules/undici-types/retry-handler.d.ts +125 -0
  204. package/node_modules/undici-types/round-robin-pool.d.ts +41 -0
  205. package/node_modules/undici-types/snapshot-agent.d.ts +109 -0
  206. package/node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
  207. package/node_modules/undici-types/util.d.ts +18 -0
  208. package/node_modules/undici-types/utility.d.ts +7 -0
  209. package/node_modules/undici-types/webidl.d.ts +347 -0
  210. package/node_modules/undici-types/websocket.d.ts +188 -0
  211. package/package.json +5 -3
  212. package/dist/command-result.d.ts +0 -9
  213. package/dist/command-result.js +0 -231
  214. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/e2e/journeys/greet.journey.ts +0 -46
  215. package/node_modules/@ykdz/template-builtin-presets/templates/ts-cli/test/unit/greet.test.ts +0 -15
  216. package/node_modules/commander/LICENSE +0 -22
  217. package/node_modules/commander/Readme.md +0 -1172
  218. package/node_modules/commander/index.js +0 -21
  219. package/node_modules/commander/lib/argument.js +0 -147
  220. package/node_modules/commander/lib/command.js +0 -2790
  221. package/node_modules/commander/lib/error.js +0 -36
  222. package/node_modules/commander/lib/help.js +0 -731
  223. package/node_modules/commander/lib/option.js +0 -377
  224. package/node_modules/commander/lib/suggestSimilar.js +0 -99
  225. package/node_modules/commander/package-support.json +0 -19
  226. package/node_modules/commander/package.json +0 -64
  227. package/node_modules/commander/typings/index.d.ts +0 -1113
@@ -5,79 +5,138 @@ import { describe, expect, it } from "vitest";
5
5
  import { cliCommandIdentity } from "../../src/cli-command-identity.ts";
6
6
  import { runCli, type CliRuntime } from "../../src/main.ts";
7
7
 
8
- const require = createRequire(import.meta.url);
9
- const packageManifest = require("../../package.json") as unknown;
10
- const identity = cliCommandIdentity(packageManifest);
8
+ const identity = cliCommandIdentity(
9
+ createRequire(import.meta.url)("../../package.json"),
10
+ );
11
11
 
12
- function testRuntime(args: readonly string[]): {
13
- readonly runtime: CliRuntime;
14
- readonly stdout: () => string;
15
- readonly stderr: () => string;
16
- } {
12
+ function testRuntime(args: readonly string[]) {
17
13
  let stdout = "";
18
14
  let stderr = "";
19
- return {
20
- runtime: {
21
- argv: ["node", identity.commandName, ...args],
22
- streams: {
23
- stdin: {},
24
- stdout: { write: (chunk) => (stdout += chunk) },
25
- stderr: { write: (chunk) => (stderr += chunk) },
26
- },
27
- cwd: "/workspace",
28
- env: { MODE: "test" },
29
- tty: { stdin: false, stdout: false, stderr: false },
30
- identity,
15
+ const runtime: CliRuntime = {
16
+ argv: ["node", identity.commandName, ...args],
17
+ identity,
18
+ write: ({ destination, chunk }) => {
19
+ if (destination === "stdout") stdout += chunk;
20
+ else stderr += chunk;
31
21
  },
32
- stdout: () => stdout,
33
- stderr: () => stderr,
34
22
  };
23
+ return { runtime, stdout: () => stdout, stderr: () => stderr };
35
24
  }
36
25
 
37
- describe("CLI command control", () => {
38
- it("parses greet and writes business output to the injected stream", async () => {
39
- const output = testRuntime(["greet", " Ada Lovelace "]);
40
-
41
- await expect(runCli(output.runtime)).resolves.toBe(0);
42
- expect(output.stdout()).toBe("Hello, Ada Lovelace\n");
26
+ describe("CLI 契约", () => {
27
+ it("查询成功默认返回结构化数据,也支持中文文本", async () => {
28
+ const output = testRuntime(["lookup", "ada"]);
29
+ expect(await runCli(output.runtime)).toBe(0);
30
+ expect(JSON.parse(output.stdout())).toEqual({
31
+ schemaVersion: "1",
32
+ command: "lookup",
33
+ kind: "data",
34
+ variant: "found",
35
+ data: { name: "ada", title: "Ada Lovelace" },
36
+ });
43
37
  expect(output.stderr()).toBe("");
38
+ const human = testRuntime(["lookup", "ada", "--output-format", "text"]);
39
+ expect(await runCli(human.runtime)).toBe(0);
40
+ expect(human.stdout()).toContain("找到记录");
41
+ expect(human.stdout()).toContain("Ada Lovelace");
44
42
  });
45
43
 
46
- it("renders the version derived from the package manifest", async () => {
47
- const output = testRuntime(["--version"]);
48
-
49
- await expect(runCli(output.runtime)).resolves.toBe(0);
50
- expect(output.stdout()).toBe(`${identity.version}\n`);
51
- expect(output.stderr()).toBe("");
52
- });
53
-
54
- it("renders Commander help without exiting the process", async () => {
55
- const output = testRuntime(["--help"]);
56
-
57
- await expect(runCli(output.runtime)).resolves.toBe(0);
58
- expect(output.stdout()).toContain(
59
- `Usage: ${identity.commandName} [options] [command]`,
60
- );
61
- expect(output.stdout()).toContain("greet <name>");
62
- expect(output.stderr()).toBe("");
44
+ it("未找到记录是已声明失败,非法名称是用法错误", async () => {
45
+ const missing = testRuntime(["lookup", "missing"]);
46
+ expect(await runCli(missing.runtime)).toBe(1);
47
+ expect(missing.stdout()).toBe("");
48
+ expect(JSON.parse(missing.stderr())).toMatchObject({
49
+ kind: "failure",
50
+ variant: "notFound",
51
+ data: { name: "missing" },
52
+ });
53
+ for (const args of [["lookup"], ["lookup", " "]]) {
54
+ const invalid = testRuntime([...args, "--output-format", "text"]);
55
+ expect(await runCli(invalid.runtime)).toBe(2);
56
+ expect(invalid.stdout()).toBe("");
57
+ expect(JSON.parse(invalid.stderr())).toMatchObject({
58
+ kind: "usageFailure",
59
+ });
60
+ }
63
61
  });
64
62
 
65
- it("reports missing arguments as Commander usage errors", async () => {
66
- const output = testRuntime(["greet"]);
67
-
68
- await expect(runCli(output.runtime)).resolves.toBe(1);
69
- expect(output.stdout()).toBe("");
70
- expect(output.stderr()).toContain(
71
- "error: missing required argument 'name'",
63
+ it("帮助和版本使用 manifest 身份,schema 导出完整契约", async () => {
64
+ const version = testRuntime(["--version"]);
65
+ expect(await runCli(version.runtime)).toBe(0);
66
+ expect(version.stdout()).toBe(
67
+ `${identity.commandName} ${identity.version}\n`,
72
68
  );
73
- expect(output.stderr()).toContain(`Usage: ${identity.commandName} greet`);
69
+ const help = testRuntime(["--help"]);
70
+ expect(await runCli(help.runtime)).toBe(0);
71
+ expect(help.stdout()).toContain(identity.commandName);
72
+ expect(help.stdout()).toContain("lookup");
73
+ expect(help.stdout()).toContain("schema");
74
+ const schema = testRuntime(["schema"]);
75
+ expect(await runCli(schema.runtime)).toBe(0);
76
+ const humanSchema = testRuntime(["schema", "--output-format", "text"]);
77
+ expect(await runCli(humanSchema.runtime)).toBe(0);
78
+ expect(humanSchema.stdout()).toContain("CLI 契约");
79
+ expect(humanSchema.stdout()).toContain('"commands"');
80
+ const manifest = JSON.parse(schema.stdout()).data.manifest;
81
+ expect(manifest).toMatchObject({
82
+ commands: {
83
+ lookup: {
84
+ input: {
85
+ inputSchema: {
86
+ properties: { name: { pattern: "^[a-z]+$" } },
87
+ required: ["name"],
88
+ },
89
+ },
90
+ success: { variants: { found: { exitCode: 0 } } },
91
+ failures: { notFound: { exitCode: 1 } },
92
+ },
93
+ schema: { success: { variants: { exported: { exitCode: 0 } } } },
94
+ },
95
+ controls: {
96
+ output: {
97
+ defaultFormat: "structured",
98
+ formats: ["structured", "text"],
99
+ },
100
+ },
101
+ usageFailure: { exitCode: 2 },
102
+ });
74
103
  });
75
104
 
76
- it("adapts business validation into a testable command error", async () => {
77
- const output = testRuntime(["greet", " "]);
78
-
79
- await expect(runCli(output.runtime)).resolves.toBe(1);
80
- expect(output.stdout()).toBe("");
81
- expect(output.stderr()).toContain("error: Name must not be empty");
105
+ it("等待输出完成,仅 stdout EPIPE 安静成功", async () => {
106
+ const output = testRuntime(["lookup", "ada"]);
107
+ expect(
108
+ await runCli({
109
+ ...output.runtime,
110
+ write: async () => {
111
+ throw Object.assign(new Error("pipe"), { code: "EPIPE" });
112
+ },
113
+ }),
114
+ ).toBe(0);
115
+ expect(
116
+ await runCli({
117
+ ...output.runtime,
118
+ write: async () => {
119
+ throw new Error("disk");
120
+ },
121
+ }),
122
+ ).toBe(70);
123
+ const failure = testRuntime(["lookup", "missing"]);
124
+ expect(
125
+ await runCli({
126
+ ...failure.runtime,
127
+ write: async () => {
128
+ throw Object.assign(new Error("pipe"), { code: "EPIPE" });
129
+ },
130
+ }),
131
+ ).toBe(70);
132
+ const argv = ["node", identity.commandName];
133
+ Object.defineProperty(argv, "slice", {
134
+ value() {
135
+ throw new Error("内部细节");
136
+ },
137
+ });
138
+ expect(await runCli({ ...output.runtime, argv })).toBe(70);
139
+ expect(output.stderr()).toContain("命令执行失败");
140
+ expect(output.stderr()).not.toContain("内部细节");
82
141
  });
83
142
  });
@@ -28,7 +28,6 @@ export declare function renderCargoLockForPackage(options: {
28
28
  }): string;
29
29
  export declare function selectTemplateCargoDependencyVersions(dependencies: readonly string[], catalog?: TemplateCargoDependencyVersions): TemplateCargoDependencyVersions;
30
30
  export declare function renderCargoDependencyTomlEntries(dependencies: readonly string[], catalog?: TemplateCargoDependencyVersions): string[];
31
- export declare function collectGeneratedManifestCatalogDependencies(manifests: readonly GeneratedPackageManifestDependencies[]): string[];
32
31
  export declare function collectGeneratedManifestCatalogReferences(manifests: readonly GeneratedPackageManifestDependencies[]): string[];
33
32
  export declare function pnpmWorkspaceYamlWithCatalogDependencies(workspaceYaml: string, dependencies: readonly string[], templateCatalog?: TemplateDependencyCatalog): string;
34
33
  export declare function renderGeneratedPnpmWorkspaceYaml(options: GeneratedDependencyCatalogOptions): string;
@@ -127,25 +127,6 @@ export function renderCargoDependencyTomlEntries(dependencies, catalog = loadTem
127
127
  return `${renderTomlKey(dependency)} = ${JSON.stringify(version)}`;
128
128
  });
129
129
  }
130
- export function collectGeneratedManifestCatalogDependencies(manifests) {
131
- const dependencies = new Set();
132
- for (const manifest of manifests) {
133
- for (const dependencyMap of [
134
- manifest.dependencies,
135
- manifest.devDependencies,
136
- manifest.optionalDependencies,
137
- manifest.peerDependencies,
138
- ]) {
139
- for (const [dependency, specifier] of Object.entries(dependencyMap ?? {})) {
140
- if (specifier !== "catalog:") {
141
- throw new Error(`Generated manifest dependency ${dependency} must use catalog:, got ${specifier}`);
142
- }
143
- dependencies.add(dependency);
144
- }
145
- }
146
- }
147
- return [...dependencies].toSorted();
148
- }
149
130
  export function collectGeneratedManifestCatalogReferences(manifests) {
150
131
  const dependencies = new Set();
151
132
  for (const manifest of manifests) {
@@ -21,9 +21,11 @@ overrides:
21
21
  "vue>typescript": "-"
22
22
 
23
23
  catalog:
24
+ "@ykdz/cli-contract": 0.2.1
25
+ "@valibot/to-json-schema": ^1.8.0
24
26
  "@devcontainers/cli": 0.89.0
25
27
  "@hono/node-server": ^2.0.12
26
- "@playwright/test": ^1.62.1
28
+ "@playwright/test": 1.64.0
27
29
  "@tailwindcss/vite": ^4.3.3
28
30
  "@types/node": ^24.13.3
29
31
  "@types/web-bluetooth": ^0.0.21
@@ -31,7 +33,6 @@ catalog:
31
33
  "@vikejs/hono": ^0.2.1
32
34
  "@vue/devtools-api": ^8.1.5
33
35
  "@vue/tsconfig": ^0.9.1
34
- commander: ^15.0.0
35
36
  drizzle-kit: 1.0.0-rc.5-ab785fc
36
37
  drizzle-orm: 1.0.0-rc.5-ab785fc
37
38
  execa: ^10.0.1
@@ -1,3 +1,4 @@
1
+ import * as v from "valibot";
1
2
  /**
2
3
  * The durable, preset-agnostic topology used by local template follow-up
3
4
  * operations. Preset provenance deliberately belongs in Generation Record.
@@ -40,6 +41,20 @@ export type BlueprintValidationResult = {
40
41
  readonly ok: false;
41
42
  readonly issues: readonly BlueprintValidationIssue[];
42
43
  };
44
+ declare function packageDefinitionMessage(issue: v.BaseIssue<unknown>): string;
45
+ export declare const projectBlueprintSchema: v.StrictObjectSchema<{
46
+ readonly schemaVersion: v.LiteralSchema<3, (issue: v.LiteralIssue) => string>;
47
+ readonly packages: v.ArraySchema<v.StrictObjectSchema<{
48
+ readonly name: v.StringSchema<"Package name must be a string">;
49
+ readonly path: v.StringSchema<"Package Path must be a string">;
50
+ readonly role: v.PicklistSchema<readonly ["cli-tool", "runtime-service", "shared-library", "native-package"], "Package Role must be cli-tool, runtime-service, shared-library, or native-package">;
51
+ readonly packageDefinitionId: v.StringSchema<"Package Definition ID must use the package-<sha256> format">;
52
+ }, typeof packageDefinitionMessage>, "Package Definitions must be an array">;
53
+ readonly packageLinkIntents: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
54
+ readonly consumerPackagePath: v.StringSchema<"Package Link Intent consumer Package Path must be a string">;
55
+ readonly providerPackagePath: v.StringSchema<"Package Link Intent provider Package Path must be a string">;
56
+ }, (issue: v.StrictObjectIssue) => "Package Link Intent must be an object" | "Unknown Blueprint v3 field">, "Package Link Intents must be an array">, undefined>;
57
+ }, (issue: v.StrictObjectIssue) => "Local Template Metadata must be an object" | "Unknown Blueprint v3 field">;
43
58
  /** Canonical npm package-name predicate shared by Blueprint and input preparation. */
44
59
  export declare function isValidNewNpmPackageName(value: string): boolean;
45
60
  export type NewPackagePathValidation = {
@@ -42,7 +42,7 @@ const packageLinkIntentSchema = v.strictObject({
42
42
  }, (issue) => issue.path?.at(-1)?.origin === "key" && issue.input !== undefined
43
43
  ? unknownBlueprintField
44
44
  : "Package Link Intent must be an object");
45
- const projectBlueprintSchema = v.strictObject({
45
+ export const projectBlueprintSchema = v.strictObject({
46
46
  schemaVersion: v.literal(3, (issue) => `Unsupported Local Template Metadata schema version ${String(issue.input)}; expected 3`),
47
47
  packages: v.array(packageDefinitionSchema, "Package Definitions must be an array"),
48
48
  packageLinkIntents: v.optional(v.array(packageLinkIntentSchema, "Package Link Intents must be an array")),
@@ -1,52 +1,4 @@
1
- import { type CiDiagnosticArtifactDeclaration } from "./ci-diagnostic-artifact.ts";
2
1
  import type { DeploymentEnvironmentNeed } from "./module-graph.ts";
3
- export type CiCapability = {
4
- readonly workflowName: "Check";
5
- readonly jobName: "check";
6
- readonly jobDisplayName: "Root Check";
7
- readonly runner: "ubuntu-latest";
8
- readonly timeoutMinutes: 30;
9
- };
10
- export type CiEnvironmentPreparation = {
11
- readonly nodeFromPackageMetadata: boolean;
12
- readonly packageManagerFromPackageMetadata: boolean;
13
- readonly pnpmStoreCache: boolean;
14
- };
15
- export type PnpmTaskLayer = {
16
- readonly installCommand: "pnpm install --frozen-lockfile";
17
- readonly checkCommand: "pnpm run check";
18
- };
19
- export type CiCheckMatrixEntry = {
20
- readonly capability: "root" | "deployment";
21
- readonly jobDisplayName: "Root Check" | "Deployment Check";
22
- readonly taskEntrypoint: "pnpm run check" | "pnpm run check:deployment";
23
- readonly timeoutMinutes: 30 | 45;
24
- readonly requiresDocker: boolean;
25
- };
26
- export type ProjectCheckWorkflowPlan = {
27
- readonly workflowName: "Check";
28
- readonly triggers: {
29
- readonly pullRequest: true;
30
- readonly pushBranches: readonly ["main"];
31
- };
32
- readonly permissions: {
33
- readonly contents: "read";
34
- };
35
- readonly concurrency: {
36
- readonly group: "${{ github.workflow }}-${{ github.ref }}";
37
- readonly cancelInProgress: true;
38
- };
39
- readonly rootCheck: CiCapability;
40
- readonly matrix: {
41
- readonly failFast: false;
42
- readonly include: readonly CiCheckMatrixEntry[];
43
- } | undefined;
44
- readonly environmentPreparation: CiEnvironmentPreparation;
45
- readonly taskLayer: PnpmTaskLayer;
46
- /** Actual Package Boundaries allowed to own retained native diagnostics. */
47
- readonly packagePaths: readonly string[];
48
- readonly diagnosticArtifacts: readonly CiDiagnosticArtifactDeclaration[];
49
- };
50
2
  export type DependencyEcosystem = "npm" | "cargo" | "github-actions" | "docker" | "devcontainers" | "rust-toolchain";
51
3
  export type DependabotDirectory = `/${string}`;
52
4
  export type DependencyMaintenancePolicy = {
@@ -60,16 +12,6 @@ export type ProjectCheckWorkflowDiagnosticOptions = {
60
12
  readonly packagePaths: readonly string[];
61
13
  readonly diagnosticArtifacts?: readonly unknown[] | undefined;
62
14
  };
63
- type ProjectCheckWorkflowOptions = ProjectCheckWorkflowDiagnosticOptions & {
64
- readonly deploymentCheck?: {
65
- readonly environmentNeeds: readonly DeploymentEnvironmentNeed[];
66
- } | undefined;
67
- readonly capability?: CiCapability | undefined;
68
- readonly environmentPreparation?: Partial<CiEnvironmentPreparation> | undefined;
69
- readonly taskLayer?: PnpmTaskLayer | undefined;
70
- };
71
- /** Capability facts for the Foundation-owned GitHub Actions Template Source. */
72
- export declare function projectCheckWorkflowPlan(options: ProjectCheckWorkflowOptions): ProjectCheckWorkflowPlan;
73
15
  /** Selects a complete Foundation-owned workflow Template Source. */
74
16
  export declare function projectCheckWorkflowTemplateSource(options: ProjectCheckWorkflowDiagnosticOptions & {
75
17
  readonly deploymentCheck?: {
@@ -81,4 +23,3 @@ export declare function projectCheckWorkflowTemplateReplacements(options: Projec
81
23
  export declare function projectDependabotConfig(policy: DependencyMaintenancePolicy): string;
82
24
  /** Limited substitution for the Foundation-owned Dependabot Template Source. */
83
25
  export declare function projectDependabotTemplateReplacements(policy: DependencyMaintenancePolicy): Record<string, string>;
84
- export {};
@@ -5,73 +5,6 @@ function validatedDiagnosticArtifacts(options) {
5
5
  declarations: options.artifacts,
6
6
  });
7
7
  }
8
- const defaultCiCapability = {
9
- workflowName: "Check",
10
- jobName: "check",
11
- jobDisplayName: "Root Check",
12
- runner: "ubuntu-latest",
13
- timeoutMinutes: 30,
14
- };
15
- const pnpmTaskLayer = {
16
- installCommand: "pnpm install --frozen-lockfile",
17
- checkCommand: "pnpm run check",
18
- };
19
- /** Capability facts for the Foundation-owned GitHub Actions Template Source. */
20
- export function projectCheckWorkflowPlan(options) {
21
- const capability = options.capability ?? defaultCiCapability;
22
- const environmentPreparation = {
23
- nodeFromPackageMetadata: true,
24
- packageManagerFromPackageMetadata: true,
25
- pnpmStoreCache: true,
26
- ...options.environmentPreparation,
27
- };
28
- const taskLayer = options.taskLayer ?? pnpmTaskLayer;
29
- const hasDeploymentTask = options.deploymentCheck !== undefined;
30
- const needsDocker = (options.deploymentCheck?.environmentNeeds ?? []).some((need) => need.kind === "docker-engine");
31
- if (hasDeploymentTask && !needsDocker) {
32
- throw new Error("Deployment Check requires a Docker environment need");
33
- }
34
- const packagePaths = [...options.packagePaths];
35
- const diagnosticArtifacts = validatedDiagnosticArtifacts({
36
- packagePaths,
37
- artifacts: options.diagnosticArtifacts ?? [],
38
- });
39
- return {
40
- workflowName: capability.workflowName,
41
- triggers: { pullRequest: true, pushBranches: ["main"] },
42
- permissions: { contents: "read" },
43
- concurrency: {
44
- group: "${{ github.workflow }}-${{ github.ref }}",
45
- cancelInProgress: true,
46
- },
47
- rootCheck: capability,
48
- matrix: hasDeploymentTask
49
- ? {
50
- failFast: false,
51
- include: [
52
- {
53
- capability: "root",
54
- jobDisplayName: capability.jobDisplayName,
55
- taskEntrypoint: taskLayer.checkCommand,
56
- timeoutMinutes: capability.timeoutMinutes,
57
- requiresDocker: false,
58
- },
59
- {
60
- capability: "deployment",
61
- jobDisplayName: "Deployment Check",
62
- taskEntrypoint: "pnpm run check:deployment",
63
- timeoutMinutes: 45,
64
- requiresDocker: true,
65
- },
66
- ],
67
- }
68
- : undefined,
69
- environmentPreparation,
70
- taskLayer,
71
- packagePaths,
72
- diagnosticArtifacts,
73
- };
74
- }
75
8
  /** Selects a complete Foundation-owned workflow Template Source. */
76
9
  export function projectCheckWorkflowTemplateSource(options) {
77
10
  const hasDeploymentTask = options.deploymentCheck !== undefined;
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Matteo Collina and Undici contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ # undici-types
2
+
3
+ This package is a dual-publish of the [undici](https://www.npmjs.com/package/undici) library types. The `undici` package **still contains types**. This package is for users who _only_ need undici types (such as for `@types/node`). It is published alongside every release of `undici`, so you can always use the same version.
4
+
5
+ - [GitHub nodejs/undici](https://github.com/nodejs/undici)
6
+ - [Undici Documentation](https://undici.nodejs.org/#/)
@@ -0,0 +1,32 @@
1
+ import { URL } from 'node:url'
2
+ import Pool from './pool'
3
+ import Dispatcher from './dispatcher'
4
+ import TClientStats from './client-stats'
5
+ import TPoolStats from './pool-stats'
6
+
7
+ export default Agent
8
+
9
+ declare class Agent extends Dispatcher {
10
+ constructor (opts?: Agent.Options)
11
+ /** `true` after `dispatcher.close()` has been called. */
12
+ closed: boolean
13
+ /** `true` after `dispatcher.destroyed()` has been called or `dispatcher.close()` has been called and the dispatcher shutdown has completed. */
14
+ destroyed: boolean
15
+ /** Dispatches a request. */
16
+ dispatch (options: Agent.DispatchOptions, handler: Dispatcher.DispatchHandler): boolean
17
+ /** Aggregate stats for a Agent by origin. */
18
+ readonly stats: Record<string, TClientStats | TPoolStats>
19
+ }
20
+
21
+ declare namespace Agent {
22
+ export interface Options extends Pool.Options {
23
+ /** Default: `(origin, opts) => new Pool(origin, opts)`. */
24
+ factory?(origin: string | URL, opts: Object): Dispatcher;
25
+
26
+ interceptors?: { Agent?: readonly Dispatcher.DispatchInterceptor[] } & Pool.Options['interceptors']
27
+ maxOrigins?: number
28
+ }
29
+
30
+ export interface DispatchOptions extends Dispatcher.DispatchOptions {
31
+ }
32
+ }
@@ -0,0 +1,43 @@
1
+ import { URL, UrlObject } from 'node:url'
2
+ import { Duplex } from 'node:stream'
3
+ import Dispatcher from './dispatcher'
4
+
5
+ /** Performs an HTTP request. */
6
+ declare function request<TOpaque = null> (
7
+ url: string | URL | UrlObject,
8
+ options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions<TOpaque>, 'origin' | 'path' | 'method'> & Partial<Pick<Dispatcher.RequestOptions, 'method'>>,
9
+ ): Promise<Dispatcher.ResponseData<TOpaque>>
10
+
11
+ /** A faster version of `request`. */
12
+ declare function stream<TOpaque = null> (
13
+ url: string | URL | UrlObject,
14
+ options: { dispatcher?: Dispatcher } & Omit<Dispatcher.RequestOptions<TOpaque>, 'origin' | 'path'>,
15
+ factory: Dispatcher.StreamFactory<TOpaque>
16
+ ): Promise<Dispatcher.StreamData<TOpaque>>
17
+
18
+ /** For easy use with `stream.pipeline`. */
19
+ declare function pipeline<TOpaque = null> (
20
+ url: string | URL | UrlObject,
21
+ options: { dispatcher?: Dispatcher } & Omit<Dispatcher.PipelineOptions<TOpaque>, 'origin' | 'path'>,
22
+ handler: Dispatcher.PipelineHandler<TOpaque>
23
+ ): Duplex
24
+
25
+ /** Starts two-way communications with the requested resource. */
26
+ declare function connect<TOpaque = null> (
27
+ url: string | URL | UrlObject,
28
+ options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.ConnectOptions<TOpaque>, 'origin' | 'path'>
29
+ ): Promise<Dispatcher.ConnectData<TOpaque>>
30
+
31
+ /** Upgrade to a different protocol. */
32
+ declare function upgrade (
33
+ url: string | URL | UrlObject,
34
+ options?: { dispatcher?: Dispatcher } & Omit<Dispatcher.UpgradeOptions, 'origin' | 'path'>
35
+ ): Promise<Dispatcher.UpgradeData>
36
+
37
+ export {
38
+ request,
39
+ stream,
40
+ pipeline,
41
+ connect,
42
+ upgrade
43
+ }
@@ -0,0 +1,30 @@
1
+ import Pool from './pool'
2
+ import Dispatcher from './dispatcher'
3
+ import { URL } from 'node:url'
4
+
5
+ export default BalancedPool
6
+
7
+ type BalancedPoolConnectOptions = Omit<Dispatcher.ConnectOptions, 'origin'>
8
+
9
+ declare class BalancedPool extends Dispatcher {
10
+ constructor (url: string | string[] | URL | URL[], options?: Pool.Options)
11
+
12
+ addUpstream (upstream: string | URL): BalancedPool
13
+ removeUpstream (upstream: string | URL): BalancedPool
14
+ getUpstream (upstream: string | URL): Pool | undefined
15
+ upstreams: Array<string>
16
+
17
+ /** `true` after `pool.close()` has been called. */
18
+ closed: boolean
19
+ /** `true` after `pool.destroyed()` has been called or `pool.close()` has been called and the pool shutdown has completed. */
20
+ destroyed: boolean
21
+
22
+ // Override dispatcher APIs.
23
+ override connect (
24
+ options: BalancedPoolConnectOptions
25
+ ): Promise<Dispatcher.ConnectData>
26
+ override connect (
27
+ options: BalancedPoolConnectOptions,
28
+ callback: (err: Error | null, data: Dispatcher.ConnectData) => void
29
+ ): void
30
+ }