stitchkit 0.136.3 → 0.136.5

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 (101) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/browser/http-fetch.d.ts +6 -0
  3. package/dist/browser/http-fetch.d.ts.map +1 -1
  4. package/dist/browser/http-helpers.d.ts +21 -0
  5. package/dist/browser/http-helpers.d.ts.map +1 -1
  6. package/dist/browser/http.d.ts.map +1 -1
  7. package/dist/entrypoints/agent-executor/acp.js +5 -5
  8. package/dist/entrypoints/agent-executor/claude-sdk.js +7 -7
  9. package/dist/entrypoints/agent-executor/claude.js +7 -7
  10. package/dist/entrypoints/agent-executor/codex.js +9 -9
  11. package/dist/entrypoints/agent-executor/testing.js +9 -9
  12. package/dist/entrypoints/agent-executor.js +5 -5
  13. package/dist/entrypoints/agent-runtime/coding-tools.js +2 -2
  14. package/dist/entrypoints/agent-runtime/postgres.js +4 -4
  15. package/dist/entrypoints/agent-runtime/sandbox.js +7 -7
  16. package/dist/entrypoints/agent-runtime/sqlite/bun.js +5 -5
  17. package/dist/entrypoints/agent-runtime/sqlite/node.js +5 -5
  18. package/dist/entrypoints/agent-runtime/testing.js +4 -4
  19. package/dist/entrypoints/agent-runtime.js +4 -4
  20. package/dist/entrypoints/application/diagnostic-journal.js +3 -3
  21. package/dist/entrypoints/application/directory-inbox.js +7 -7
  22. package/dist/entrypoints/cli/publish.d.ts +14 -6
  23. package/dist/entrypoints/cli/publish.d.ts.map +1 -1
  24. package/dist/entrypoints/cli/publish.js +685 -30
  25. package/dist/entrypoints/cli.js +7 -124
  26. package/dist/entrypoints/files/packaging.js +2 -2
  27. package/dist/entrypoints/files.d.ts +1 -0
  28. package/dist/entrypoints/files.d.ts.map +1 -1
  29. package/dist/entrypoints/files.js +9 -9
  30. package/dist/entrypoints/http.js +3 -3
  31. package/dist/entrypoints/index.js +3 -3
  32. package/dist/entrypoints/node.js +3 -3
  33. package/dist/entrypoints/observability.js +1 -1
  34. package/dist/entrypoints/process.js +3 -3
  35. package/dist/entrypoints/react.js +1 -1
  36. package/dist/entrypoints/remote.js +2 -2
  37. package/dist/entrypoints/server.js +6 -6
  38. package/dist/entrypoints/service-host/macos.js +7 -7
  39. package/dist/entrypoints/service-host/work.js +6 -6
  40. package/dist/entrypoints/service-host.js +9 -9
  41. package/dist/entrypoints/spend.js +1 -1
  42. package/dist/entrypoints/telegram.js +3 -3
  43. package/dist/entrypoints/testing.js +2 -2
  44. package/dist/entrypoints/tools.js +1 -1
  45. package/dist/{index-05b65gj4.js → index-0s75mjh7.js} +1 -1
  46. package/dist/{index-s2e3h616.js → index-150b1qyw.js} +10 -1
  47. package/dist/{index-tcv71frn.js → index-1fhbe4e4.js} +1 -1
  48. package/dist/{index-8cek82ar.js → index-1h0dtfz3.js} +1 -1
  49. package/dist/{index-jwtmw39p.js → index-2qnqvq11.js} +1 -1
  50. package/dist/index-2rs7ze0q.js +376 -0
  51. package/dist/{index-2wm9b9vs.js → index-3cwq5byx.js} +2 -2
  52. package/dist/{index-mtpcax6d.js → index-5md04mwc.js} +3 -3
  53. package/dist/{index-b0mh2t9x.js → index-67mzzkdv.js} +3 -3
  54. package/dist/{index-nne3yxew.js → index-6f4fjygr.js} +1 -1
  55. package/dist/{index-d5mhgx72.js → index-8tn10tp6.js} +1 -1
  56. package/dist/{index-rw31t8sj.js → index-9fzjgg86.js} +1 -1
  57. package/dist/{index-0sxj3y45.js → index-afaq0nc4.js} +1 -1
  58. package/dist/{index-nfm15ej7.js → index-bbpygynk.js} +1 -1
  59. package/dist/{index-g04hszcm.js → index-chapre0y.js} +1 -1
  60. package/dist/{index-vh4291qh.js → index-ctaxjpa4.js} +1 -1
  61. package/dist/{index-mhgkzwxz.js → index-d01akj5n.js} +134 -25
  62. package/dist/{index-x1r7kxzd.js → index-e4zt2x70.js} +3 -3
  63. package/dist/{index-s0n0nnz5.js → index-f103md2v.js} +122 -3
  64. package/dist/{index-2c5w2d1d.js → index-gyfsh29t.js} +1 -1
  65. package/dist/{index-kgkevngs.js → index-kadgaw1s.js} +4 -4
  66. package/dist/{index-ca1v40d3.js → index-kd48gk7d.js} +1 -1
  67. package/dist/{index-ke6jtxkd.js → index-mr3njw67.js} +1 -1
  68. package/dist/{index-cmqvf0dz.js → index-ppy23bd2.js} +1 -1
  69. package/dist/{index-43k180c2.js → index-rnhp7je8.js} +2 -2
  70. package/dist/{index-2tgmggcm.js → index-smvmnz5y.js} +1 -1
  71. package/dist/{index-9m1m92rg.js → index-tjhhsnjv.js} +1 -1
  72. package/dist/{index-64t6pheq.js → index-w161azza.js} +1 -1
  73. package/dist/{index-mttkdm5a.js → index-xqppqn97.js} +1 -1
  74. package/dist/{index-sjq4akrx.js → index-xsrma0jd.js} +2 -2
  75. package/dist/{index-zqc64g69.js → index-ypm85xwe.js} +1 -1
  76. package/dist/{index-zagc12j1.js → index-zcq3dby3.js} +1 -1
  77. package/dist/{index-29v1p1f4.js → index-zhngww7q.js} +1 -1
  78. package/dist/internal/atomic-file-owner.d.ts +91 -0
  79. package/dist/internal/atomic-file-owner.d.ts.map +1 -0
  80. package/dist/internal/atomic-file.d.ts +29 -7
  81. package/dist/internal/atomic-file.d.ts.map +1 -1
  82. package/dist/internal/bounded-file-read.d.ts +6 -2
  83. package/dist/internal/bounded-file-read.d.ts.map +1 -1
  84. package/dist/tools/cli/distribution-config.d.ts +56 -0
  85. package/dist/tools/cli/distribution-config.d.ts.map +1 -0
  86. package/dist/tools/cli/distribution-routes.d.ts +20 -0
  87. package/dist/tools/cli/distribution-routes.d.ts.map +1 -0
  88. package/dist/tools/cli/publication-source.d.ts +77 -0
  89. package/dist/tools/cli/publication-source.d.ts.map +1 -0
  90. package/llms/cli-publish.txt +15 -3
  91. package/llms/cli.2.txt +84 -63
  92. package/llms/cli.3.txt +67 -1
  93. package/llms/cli.txt +1 -1
  94. package/llms/files.txt +1 -1
  95. package/llms/process.txt +24 -4
  96. package/llms/stitchkit.txt +11 -3
  97. package/llms-full.txt +134 -11
  98. package/llms.txt +5 -5
  99. package/package.json +1 -1
  100. package/dist/index-pp97q86a.js +0 -221
  101. package/dist/{index-5c4m8zdf.js → index-tjakdpf2.js} +45 -45
@@ -20,6 +20,7 @@
20
20
  * synchronous `rename` on a loaded machine was measured holding a consumer's
21
21
  * main thread for ~15 s — every timer and request of a daemon stood still.
22
22
  */
23
+ import { type DescriptorOwnerView, type TargetLstatView, type WriteFileAtomicOwner } from './atomic-file-owner.js';
23
24
  import { type AtomicPublishOptions } from './atomic-publication.js';
24
25
  /** Options of {@link writeFileAtomic} and {@link writeFileAtomicSync}. */
25
26
  export interface WriteFileAtomicOptions {
@@ -35,8 +36,9 @@ export interface WriteFileAtomicOptions {
35
36
  /**
36
37
  * Only valid with `replace: false` (throws `TypeError` otherwise). When `true`
37
38
  * and `target` already exists, succeed without replacing it if the existing
38
- * regular file (not a symlink, FIFO, or directory) already has identical bytes
39
- * and matching permission bits (`mode`, on POSIX).
39
+ * regular file (not a symlink, FIFO, or directory) already has identical bytes,
40
+ * matching permission bits (`mode`, on POSIX), and matching `(uid, gid)` when an
41
+ * explicit `owner` is requested.
40
42
  */
41
43
  idempotent?: boolean;
42
44
  /**
@@ -44,12 +46,22 @@ export interface WriteFileAtomicOptions {
44
46
  * also fsyncs the parent after it; `'none'` does neither.
45
47
  */
46
48
  durability?: 'none' | 'file' | 'directory';
49
+ /**
50
+ * POSIX file ownership applied via `fchown` before `fchmod`, `fsync` and
51
+ * publication: `'preserve'` copies `(uid, gid)` from an existing regular file
52
+ * at `target` via `lstat` (requires `replace !== false`; missing or non-regular
53
+ * targets keep the kernel default), and `{ uid, gid }` sets an explicit owner.
54
+ * Compared against the staged descriptor's real `fstat(fd)`; unsupported on Windows.
55
+ */
56
+ owner?: 'preserve' | WriteFileAtomicOwner;
47
57
  }
48
58
  /** The staged file as a writer sees it; a `FileHandle` satisfies it. */
49
59
  export interface StagedFile {
50
60
  write(bytes: Uint8Array, offset: number, length: number): Promise<{
51
61
  bytesWritten: number;
52
62
  }>;
63
+ stat(): Promise<DescriptorOwnerView>;
64
+ chown(uid: number, gid: number): Promise<void>;
53
65
  chmod(mode: number): Promise<void>;
54
66
  sync(): Promise<void>;
55
67
  close(): Promise<void>;
@@ -70,14 +82,18 @@ export declare function writeAllBytes(file: StagedFile, bytes: Uint8Array): Prom
70
82
  */
71
83
  export declare function writeFileAtomic(target: string, data: Uint8Array | string, options?: WriteFileAtomicOptions): Promise<void>;
72
84
  interface AtomicFileWriteIO {
73
- open(path: string, flags: 'wx', mode: number): Promise<StagedFile>;
85
+ open(path: string, flags: number, mode: number): Promise<StagedFile>;
74
86
  unlink(path: string): Promise<void>;
75
87
  publish(staged: string, target: string, options: AtomicPublishOptions): Promise<void>;
88
+ lstat?(path: string): Promise<TargetLstatView>;
76
89
  readExisting?(target: string, maxBytes: number): Promise<{
77
90
  bytes: Uint8Array;
78
91
  mode: number | undefined;
92
+ uid?: number | undefined;
93
+ gid?: number | undefined;
79
94
  }>;
80
95
  syncDir?(dir: string): Promise<void>;
96
+ platform?: string;
81
97
  }
82
98
  /** How the staged bytes of one atomic write are produced and vetted. */
83
99
  export interface AtomicFileStage<T> {
@@ -90,9 +106,9 @@ export interface AtomicFileStage<T> {
90
106
  }
91
107
  /**
92
108
  * The one staging sequence behind every asynchronous atomic write: exclusive
93
- * create, fill, chmod, fsync, publication, and removal of the
94
- * staging file on any failure. Also the internal syscall seam for
95
- * publication-order and precommit fault controls.
109
+ * create with `O_NOFOLLOW`, fill, optional `fstat`/`fchown`, `fchmod`, `fsync`,
110
+ * publication, and removal of the staging file on any failure. Also the internal
111
+ * syscall seam for publication-order and precommit fault controls.
96
112
  */
97
113
  export declare function writeAtomicFileStaged<T>(target: string, stage: AtomicFileStage<T>, options: WriteFileAtomicOptions, io?: AtomicFileWriteIO): Promise<T>;
98
114
  /** {@link writeAtomicFileStaged} for bytes already in memory. */
@@ -100,19 +116,25 @@ export declare function writeAtomicFileData(target: string, data: Uint8Array | s
100
116
  /** The staged file of the synchronous form. */
101
117
  interface StagedFileSync {
102
118
  write(bytes: Uint8Array, offset: number, length: number): number;
119
+ stat(): DescriptorOwnerView;
120
+ chown(uid: number, gid: number): void;
103
121
  chmod(mode: number): void;
104
122
  sync(): void;
105
123
  close(): void;
106
124
  }
107
125
  interface AtomicFileWriteSyncIO {
108
- open(path: string, flags: 'wx', mode: number): StagedFileSync;
126
+ open(path: string, flags: number, mode: number): StagedFileSync;
109
127
  unlink(path: string): void;
110
128
  publish(staged: string, target: string, options: AtomicPublishOptions): void;
129
+ lstat?(path: string): TargetLstatView;
111
130
  readExisting?(target: string, maxBytes: number): {
112
131
  bytes: Uint8Array;
113
132
  mode: number;
133
+ uid?: number | undefined;
134
+ gid?: number | undefined;
114
135
  };
115
136
  syncDir?(dir: string): void;
137
+ platform?: string;
116
138
  }
117
139
  /**
118
140
  * The synchronous form of {@link writeFileAtomic}, with the same guarantees in
@@ -1 +1 @@
1
- {"version":3,"file":"atomic-file.d.ts","sourceRoot":"","sources":["../../src/internal/atomic-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,OAAO,EAEL,KAAK,oBAAoB,EAK1B,MAAM,sBAAsB,CAAC;AAM9B,0EAA0E;AAC1E,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,WAAW,CAAC;CAC5C;AAoCD,wEAAwE;AACxE,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,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,cAAc,CAAC;IAChE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC7E,KAAK,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC;IACtC,YAAY,CAAC,CACX,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf;QAAE,KAAK,EAAE,UAAU,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC;IAC3F,OAAO,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA8ED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,GAAG,MAAM,EACzB,OAAO,EAAE,sBAAsB,EAC/B,EAAE,GAAE,qBAAkC,GACrC,IAAI,CA0CN;AAED,mGAAmG;AACnG,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,UAAU,GAAG,MAAM,EACzB,OAAO,GAAE,sBAA2B,GACnC,IAAI,CAEN"}
@@ -36,6 +36,8 @@ export interface BoundedFileRead {
36
36
  bytes: Uint8Array;
37
37
  observation: FileObservation;
38
38
  mode: number | undefined;
39
+ uid?: number | undefined;
40
+ gid?: number | undefined;
39
41
  /** Exact nanosecond post-read stat when the open descriptor supports `{ bigint: true }`. */
40
42
  after?: NanosecondFileStats;
41
43
  }
@@ -51,13 +53,15 @@ export interface BoundedFileReadSyncOptions extends FileOpenOptions {
51
53
  /**
52
54
  * Synchronous counterpart of {@link readBoundedFile}: opens with `O_RDONLY | O_NONBLOCK`
53
55
  * (plus `O_NOFOLLOW` when `rejectSymlinks` is true), validates `fstat` regular file and
54
- * link/size caps (including `maxBytes === 0`), and returns bytes, observation, mode and
55
- * the nanosecond `fstat` taken after the read (`after`) for an exact identity.
56
+ * link/size caps (including `maxBytes === 0`), and returns bytes, observation, mode, uid,
57
+ * gid and the nanosecond `fstat` taken after the read (`after`) for an exact identity.
56
58
  */
57
59
  export declare function readBoundedFileSync(target: string, maxBytes: number, options?: BoundedFileReadSyncOptions, openFd?: (path: string, flags: number) => number, snapshot?: BoundedFileSnapshotSyncHooks): {
58
60
  bytes: Uint8Array;
59
61
  observation: FileObservation;
60
62
  mode: number;
63
+ uid: number;
64
+ gid: number;
61
65
  after: BigIntStats;
62
66
  };
63
67
  export declare function readHandle(handle: {
@@ -1 +1 @@
1
- {"version":3,"file":"bounded-file-read.d.ts","sourceRoot":"","sources":["../../src/internal/bounded-file-read.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAMjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EAYlC,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAE5B,qBAAa,oBAAqB,SAAQ,KAAK;IAE3C,QAAQ,CAAC,IAAI,EACT,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,gBAAgB,GAChB,cAAc;IAElB,QAAQ,CAAC,WAAW,CAAC,EAAE,eAAe;IARxC,YACW,IAAI,EACT,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,gBAAgB,GAChB,cAAc,EAClB,OAAO,EAAE,MAAM,EACN,WAAW,CAAC,EAAE,eAAe,YAAA,EACtC,OAAO,CAAC,EAAE,YAAY,EAIvB;CACF;AAED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EAAE,KAAK,EAAE,MAAM,KAAK,MAAiB,EAC1D,QAAQ,GAAE,4BAAiC,GAC1C;IACD,KAAK,EAAE,UAAU,CAAC;IAClB,WAAW,EAAE,eAAe,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,WAAW,CAAC;CACpB,CAuFA;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE;IACN,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1F,EACD,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC,CAgCrB"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Configuration validation and safe path matching for `createCliDistributionRoutes`.
3
+ */
4
+ import type { CliSignatureVerdict, CliTrustRoot } from './signature.js';
5
+ export declare const SAFE_ASSET_SEGMENT: RegExp;
6
+ /** Diagnostic event emitted when a CLI distribution route responds with 503 or 404. */
7
+ export interface CliDistributionUnavailableEvent {
8
+ readonly route: 'manifest' | 'version-manifest' | 'asset' | 'installer';
9
+ readonly channel: string;
10
+ readonly version?: string;
11
+ readonly asset?: string;
12
+ readonly reason: 'unconfigured-root' | 'empty-trust-root' | 'missing' | 'unsafe-path' | 'too-large' | 'invalid-manifest' | 'identity-mismatch' | 'untrusted-signature' | 'unlisted-asset' | 'io-error';
13
+ readonly verdict?: CliSignatureVerdict;
14
+ readonly error?: unknown;
15
+ }
16
+ /** Configuration for {@link createCliDistributionRoutes}. */
17
+ export interface CliDistributionRoutesOptions {
18
+ /** Absolute path to the CLI distribution root directory, or `undefined` to serve 503 fail-closed. */
19
+ readonly root: string | undefined;
20
+ /** Expected `manifest.name` verified against the signed manifest on every request. */
21
+ readonly name: string;
22
+ /** Trust root whose Ed25519 public keys verify manifest signatures; empty `keys` fails closed with 503. */
23
+ readonly trust: CliTrustRoot;
24
+ /** Release channels mounted under `${basePath}/channels/<channel>/...` (default `['stable', 'beta']`). */
25
+ readonly channels?: readonly string[];
26
+ /** Channel served by `${basePath}/install.sh` (defaults to the first entry of `channels`). */
27
+ readonly installerChannel?: string;
28
+ /** URL path prefix for the routes (default `'/cli'`; `'/'` mounts at root). */
29
+ readonly basePath?: string;
30
+ /** Binary filename written into `install.sh` (defaults to `name`). */
31
+ readonly binaryName?: string;
32
+ /** Default `INSTALL_DIR` in `install.sh` (default `'$HOME/.local/bin'`). */
33
+ readonly installDir?: string;
34
+ /** Maximum byte size read for any manifest file (default `256 * 1024`). */
35
+ readonly maxManifestBytes?: number;
36
+ /** Optional `RawRoute.serviceName` attached to every returned route for observability. */
37
+ readonly serviceName?: string;
38
+ /** Optional observer invoked when a manifest or asset is unavailable or refused; throws are isolated. */
39
+ readonly onUnavailable?: (event: CliDistributionUnavailableEvent) => void;
40
+ }
41
+ export interface ResolvedDistributionConfig {
42
+ readonly root: string | undefined;
43
+ readonly name: string;
44
+ readonly trust: CliTrustRoot;
45
+ readonly channels: readonly string[];
46
+ readonly installerChannel: string;
47
+ readonly basePath: string;
48
+ readonly binaryName: string;
49
+ readonly installDir: string;
50
+ readonly maxManifestBytes: number;
51
+ readonly serviceName: string | undefined;
52
+ readonly onUnavailable: ((event: CliDistributionUnavailableEvent) => void) | undefined;
53
+ }
54
+ export declare function resolveDistributionConfig(options: CliDistributionRoutesOptions): ResolvedDistributionConfig;
55
+ export declare function assetMatchesUrl(entryUrl: string, asset: string): boolean;
56
+ //# sourceMappingURL=distribution-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distribution-config.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/distribution-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MA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;IACnC,0FAA0F;IAC1F,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,yGAAyG;IACzG,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,+BAA+B,KAAK,IAAI,CAAC;CAC3E;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC,KAAK,EAAE,+BAA+B,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CACxF;AA4ED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,4BAA4B,GACpC,0BAA0B,CAgD5B;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAexE"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Portable HTTP distribution routes for a published CLI channel (`stitchkit/cli/publish`).
3
+ *
4
+ * Serves signed channel manifests, immutable versioned manifests and binary assets, and the
5
+ * generated shell installer as portable `RawRoute[]` (compatible with `stitchkit/handler`,
6
+ * `stitchkit/server` and `stitchkit/node`). Every read verifies
7
+ * ancestor directory containment (`realpath` + `isWithinDir`), leaf `O_NOFOLLOW`, strict UTF-8
8
+ * JSON without `__proto__`, exact manifest identity and Ed25519 signature (`verdict === 'valid'`),
9
+ * and streams binaries directly from an open descriptor without `Bun.file`.
10
+ */
11
+ import type { RawRoute } from '../../server/types.js';
12
+ import { type CliDistributionRoutesOptions } from './distribution-config.js';
13
+ /**
14
+ * Create portable `RawRoute[]` handlers serving signed CLI channel manifests, immutable
15
+ * versioned manifests and binary assets, and `install.sh` (`GET` only, full-body descriptor
16
+ * streaming). Fails closed with `503 No verified CLI build is published` when unconfigured,
17
+ * missing, unsigned, or untrusted.
18
+ */
19
+ export declare function createCliDistributionRoutes(options: CliDistributionRoutesOptions): RawRoute[];
20
+ //# sourceMappingURL=distribution-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distribution-routes.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/distribution-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAEL,KAAK,4BAA4B,EAKlC,MAAM,uBAAuB,CAAC;AAuS/B;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,4BAA4B,GACpC,QAAQ,EAAE,CAwCZ"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Git-backed CLI source verification and shipping-input versioning for `stitchkit/cli/publish`.
3
+ *
4
+ * Versions derived from shipping inputs pair the declared `major.minor` series in the CLI package
5
+ * manifest at `<commit>` with the full commit count touching `shippingPaths` up to `<commit>`.
6
+ * Every git invocation runs through `runNativeCommand` with a declared-only environment so parent
7
+ * hook variables (`GIT_DIR`, `GIT_WORK_TREE`, `GIT_INDEX_FILE`) cannot silently redirect checks.
8
+ */
9
+ /** Options for {@link deriveCliVersionFromShippingInputs}. */
10
+ export interface CliShippingVersionOptions {
11
+ /** Absolute path to the git repository root (worktree root or bare repository root). */
12
+ readonly repository: string;
13
+ /** Exact 40-lowercase-hex commit SHA whose shipping inputs determine the version. */
14
+ readonly commit: string;
15
+ /** Repository-relative POSIX path to the package manifest declaring `major.minor` (e.g. `'packages/cli/package.json'`). */
16
+ readonly packageJsonPath: string;
17
+ /** Non-empty list of repository-relative paths whose history determines the patch number. */
18
+ readonly shippingPaths: readonly string[];
19
+ /** End-to-end deadline across all git checks in milliseconds (default `30_000`). */
20
+ readonly timeoutMs?: number;
21
+ /** Optional cancellation signal bound to the git checks. */
22
+ readonly signal?: AbortSignal;
23
+ }
24
+ /** Options for {@link cliShippingInputsChanged}. */
25
+ export interface CliShippingInputsChangedOptions {
26
+ /** Absolute path to the git repository root (worktree root or bare repository root). */
27
+ readonly repository: string;
28
+ /** Earlier 40-lowercase-hex commit SHA. */
29
+ readonly previousCommit: string;
30
+ /** Later 40-lowercase-hex commit SHA. */
31
+ readonly nextCommit: string;
32
+ /** Non-empty list of repository-relative paths to compare between the two commits. */
33
+ readonly shippingPaths: readonly string[];
34
+ /** End-to-end deadline across all git checks in milliseconds (default `30_000`). */
35
+ readonly timeoutMs?: number;
36
+ /** Optional cancellation signal bound to the git checks. */
37
+ readonly signal?: AbortSignal;
38
+ }
39
+ /** Options for {@link assertCleanCliSource}. */
40
+ export interface CleanCliSourceOptions {
41
+ /** Absolute path to the git working tree root directory (bare repositories are refused). */
42
+ readonly repository: string;
43
+ /** When set, `HEAD` must resolve to this exact 40-lowercase-hex commit SHA. */
44
+ readonly expectedCommit?: string;
45
+ /**
46
+ * When omitted, any untracked file in the worktree is refused. When set to a non-empty list
47
+ * of repository-relative paths or `*` globs, untracked files are refused only under those
48
+ * paths (allowing sibling runtime state outside shipping inputs).
49
+ */
50
+ readonly untrackedPaths?: readonly string[];
51
+ /** When set, verifies `realpath(servingSource) === realpath(repository)`. */
52
+ readonly servingSource?: string;
53
+ /** End-to-end deadline across all git checks in milliseconds (default `30_000`). */
54
+ readonly timeoutMs?: number;
55
+ /** Optional cancellation signal bound to the git checks. */
56
+ readonly signal?: AbortSignal;
57
+ }
58
+ /**
59
+ * Derive a CLI semver string from `<commit>`: `major.minor` from `packageJsonPath` at `<commit>`
60
+ * paired with the full commit count touching `shippingPaths` up to `<commit>`. Accepts a git
61
+ * worktree root or bare repository root; refuses shallow repositories, non-commit SHAs,
62
+ * subdirectories and non-bare `.git` directories.
63
+ */
64
+ export declare function deriveCliVersionFromShippingInputs(options: CliShippingVersionOptions): Promise<string>;
65
+ /**
66
+ * Return `true` when any path in `shippingPaths` differs between `previousCommit` and
67
+ * `nextCommit`. Accepts a git worktree root or bare repository root, refuses non-commit SHAs,
68
+ * and uses `git diff --no-ext-diff --quiet`.
69
+ */
70
+ export declare function cliShippingInputsChanged(options: CliShippingInputsChangedOptions): Promise<boolean>;
71
+ /**
72
+ * Verify that `repository` is a clean git root matching `expectedCommit` (when set), with no
73
+ * tracked changes, no disallowed untracked files, and optional `servingSource` realpath identity.
74
+ * Returns the verified 40-lowercase-hex `HEAD` commit SHA.
75
+ */
76
+ export declare function assertCleanCliSource(options: CleanCliSourceOptions): Promise<string>;
77
+ //# sourceMappingURL=publication-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publication-source.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/publication-source.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAwBH,8DAA8D;AAC9D,MAAM,WAAW,yBAAyB;IACxC,wFAAwF;IACxF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qFAAqF;IACrF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,2HAA2H;IAC3H,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,6FAA6F;IAC7F,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,oFAAoF;IACpF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,4DAA4D;IAC5D,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAED,oDAAoD;AACpD,MAAM,WAAW,+BAA+B;IAC9C,wFA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
- application-owned directory; the manifest, signatures, installer and updater it
19
- writes for stay in `stitchkit/cli` — [guide](../guide/cli.md#publishing-a-complete-version),
17
+ Build, source verification and distribution-route tooling, evolving. Publishes a
18
+ CLI distribution into a local application-owned directory, derives deterministic
19
+ versions from git shipping-input history, verifies clean source roots, and
20
+ serves verified channel manifests, immutable assets and `install.sh` over
21
+ `RawRoute[]`; the manifest, signatures, installer and updater it writes for stay
22
+ in `stitchkit/cli` — [guide](../guide/cli.md#publishing-a-complete-version),
20
23
  [ADR 0245](../decisions/0245-cli-publication-is-an-evolving-leaf.md).
21
24
 
22
25
  | Export | Kind | Summary |
@@ -25,5 +28,14 @@ writes for stay in `stitchkit/cli` — [guide](../guide/cli.md#publishing-a-comp
25
28
  | `CliPublicationOptions` | _type_ | identity, storage root, base URL, targets, limits, retention, the `admit` and `build` callbacks, optional signing and trust |
26
29
  | `CliPublicationPhase` | _type_ | the step `admit` is asked about — `prepare`, `build`, `commit` or `promote` |
27
30
  | `CliPublicationResult` | _type_ | `published` or `existing`, with the manifest ready to serve |
31
+ | `deriveCliVersionFromShippingInputs` | function | derive `major.minor.<count>` from `packageJsonPath` at `<commit>` and the full git commit count touching `shippingPaths`; accepts worktree or bare repository roots and refuses shallow clones, subdirectories, non-bare `.git` dirs and non-commit SHAs |
32
+ | `CliShippingVersionOptions` | _type_ | options for `deriveCliVersionFromShippingInputs` (`repository`, `commit`, `packageJsonPath`, `shippingPaths`, `timeoutMs`, `signal`) |
33
+ | `cliShippingInputsChanged` | function | return `true` when any path in `shippingPaths` differs between `previousCommit` and `nextCommit` using `git diff --no-ext-diff --quiet` |
34
+ | `CliShippingInputsChangedOptions` | _type_ | options for `cliShippingInputsChanged` (`repository`, `previousCommit`, `nextCommit`, `shippingPaths`, `timeoutMs`, `signal`) |
35
+ | `assertCleanCliSource` | function | verify a clean git root matching optional `expectedCommit`, optional `untrackedPaths` globs and optional `servingSource` realpath; returns verified 40-hex `HEAD` |
36
+ | `CleanCliSourceOptions` | _type_ | options for `assertCleanCliSource` (`repository`, `expectedCommit`, `untrackedPaths`, `servingSource`, `timeoutMs`, `signal`) |
37
+ | `createCliDistributionRoutes` | function | portable `RawRoute[]` (`GET` only) serving verified signed channel manifests (`no-store`), immutable versioned manifests and descriptor-streamed binary assets, and `install.sh`, failing closed with `503 No verified CLI build is published` |
38
+ | `CliDistributionRoutesOptions` | _type_ | options for `createCliDistributionRoutes` (`root`, `name`, `trust`, `channels`, `installerChannel`, `basePath`, `binaryName`, `installDir`, `maxManifestBytes`, `serviceName`, `onUnavailable`) |
39
+ | `CliDistributionUnavailableEvent` | _type_ | diagnostic event passed to `onUnavailable` with `route`, `channel`, optional `version`/`asset`, inline `reason`, optional `verdict` and `error` |
28
40
 
29
41
  ---
package/llms/cli.2.txt CHANGED
@@ -7,7 +7,7 @@
7
7
  Parts of this slice:
8
8
  - `llms/cli.txt`: Guide: CLI (docs/guide/cli.md)
9
9
  - `llms/cli.2.txt`: Guide: CLI (docs/guide/cli.md)
10
- - `llms/cli.3.txt`: API reference: `stitchkit/cli` (docs/api/reference.md)
10
+ - `llms/cli.3.txt`: Guide: CLI (docs/guide/cli.md) · API reference: `stitchkit/cli` (docs/api/reference.md)
11
11
 
12
12
  ==============================================================================
13
13
  # Guide: CLI (docs/guide/cli.md) (continued)
@@ -352,6 +352,89 @@ identity to recover; an error does not promise rollback. Optional `signing` and
352
352
  raw digest and size; the updater checks manifest authorship when given a trust
353
353
  root.
354
354
 
355
+ ### Versioning from shipping inputs and verifying clean source
356
+
357
+ When a CLI lives inside a larger repository, ordinary backend commits should not
358
+ force a new CLI version. `stitchkit/cli/publish` provides three git-backed
359
+ helpers (`deriveCliVersionFromShippingInputs`, `cliShippingInputsChanged`, and
360
+ `assertCleanCliSource`) built on `runNativeCommand` with a declared-only
361
+ environment (`GIT_TERMINAL_PROMPT=0`, `GIT_OPTIONAL_LOCKS=0`, ignoring inherited
362
+ `GIT_DIR` / `GIT_WORK_TREE`):
363
+
364
+ ```ts
365
+ import {
366
+ assertCleanCliSource,
367
+ cliShippingInputsChanged,
368
+ deriveCliVersionFromShippingInputs,
369
+ } from 'stitchkit/cli/publish'
370
+
371
+ const shippingPaths = ['packages/cli', 'packages/shared', 'bun.lock']
372
+ const head = await assertCleanCliSource({
373
+ repository: '/srv/myapp/source',
374
+ untrackedPaths: ['packages/cli', 'packages/shared', 'scripts/cli-publish*'],
375
+ })
376
+ const version = await deriveCliVersionFromShippingInputs({
377
+ repository: '/srv/myapp/source',
378
+ commit: head,
379
+ packageJsonPath: 'packages/cli/package.json',
380
+ shippingPaths,
381
+ })
382
+ const changed = await cliShippingInputsChanged({
383
+ repository: '/srv/myapp/source',
384
+ previousCommit,
385
+ nextCommit: head,
386
+ shippingPaths,
387
+ })
388
+ ```
389
+
390
+ `deriveCliVersionFromShippingInputs` reads `major.minor` from `packageJsonPath`
391
+ at `<commit>` and counts commits touching `shippingPaths` up to `<commit>`
392
+ (`major.minor.<count>`). Both `deriveCliVersionFromShippingInputs` and
393
+ `cliShippingInputsChanged` accept either a git worktree root or a bare
394
+ repository root (`realpath(--show-toplevel)` or `realpath(--absolute-git-dir)`
395
+ matching `realpath(repository)`), while `assertCleanCliSource` requires a
396
+ worktree root; subdirectories and non-bare `.git` directories are refused. All
397
+ three helpers require exact 40-hex commit objects (refusing tree, blob and
398
+ annotated-tag SHAs), full history for version counting (refusing shallow
399
+ clones), and safe repository-relative paths without `:` magic pathspecs.
400
+ `assertCleanCliSource` returns the verified 40-hex `HEAD` and checks tracked
401
+ changes plus either all untracked files (`--untracked-files=normal`) or only
402
+ untracked files matching `untrackedPaths`.
403
+
404
+ ### Serving a published CLI channel
405
+
406
+ `createCliDistributionRoutes` returns portable `RawRoute[]` (`GET` only) that
407
+ serve a directory published by `publishCli` under `<root>/channels/<channel>/`:
408
+
409
+ ```ts
410
+ import { createCliDistributionRoutes } from 'stitchkit/cli/publish'
411
+ import { createServer } from 'stitchkit/server'
412
+
413
+ const server = createServer({
414
+ rawRoutes: createCliDistributionRoutes({
415
+ root: process.env.CLI_DISTRIBUTION_DIR,
416
+ name: 'myapp',
417
+ trust: RELEASE_TRUST_ROOT,
418
+ onUnavailable: (event) => logger.warn(event, 'CLI distribution unavailable'),
419
+ }),
420
+ })
421
+ ```
422
+
423
+ Each configured channel mounts `${basePath}/channels/<channel>/manifest.json`
424
+ (`Cache-Control: no-store`, exact raw verified bytes) and
425
+ `${basePath}/channels/<channel>/:version/:asset` (immutable `manifest.json` or a
426
+ descriptor-streamed binary listed in the signed manifest with `Content-Length`
427
+ and `Content-Disposition`). `${basePath}/install.sh` renders `renderCliInstaller`
428
+ from the verified `installerChannel` manifest (`no-store`). Every read checks
429
+ canonical directory containment (`realpath` + `isWithinDir`), opens regular files
430
+ with `O_NOFOLLOW`, parses strict UTF-8 JSON without `__proto__`, verifies
431
+ `manifest.name` and Ed25519 signature strictly (`verifyCliManifest === 'valid'`),
432
+ and streams full asset bodies portably on both Bun and Node without `Bun.file`.
433
+ When `root` is `undefined`, `trust.keys` is empty, or the manifest is missing,
434
+ unsigned, tampered, oversized or has no assets, channel manifest and installer
435
+ routes fail closed with `503 No verified CLI build is published` (`no-store`),
436
+ and exceptions thrown by `onUnavailable` are isolated.
437
+
355
438
  ### Proving who built it — signing the manifest
356
439
 
357
440
  The asset digest proves the bytes that arrived are the bytes the manifest named.
@@ -864,65 +947,3 @@ public or local-operator surface, declare that explicitly with
864
947
  `access: { open: 'remote' | 'public' | 'local-operator', afterHandle? }`.
865
948
  A native-only CLI (only `commands`, no `services` or `runtimeTools`) takes no
866
949
  `access`.
867
-
868
- ## Typed context
869
-
870
- For a peer-free CLI, import `createCli` directly from `stitchkit/cli` and
871
- annotate the `context` factory's return type against your app's context shape
872
- — no optional peers are loaded:
873
-
874
- ```ts
875
- import { createCli } from 'stitchkit/cli'
876
-
877
- await createCli({
878
- name: 'myapp',
879
- version: '1.0.0',
880
- services,
881
- access: { gate: { beforeHandle: authHook } },
882
- context: (identity): { user: User | undefined } => ({ user: identity }),
883
- })
884
- ```
885
-
886
- If your application already installs `@modelcontextprotocol/server` and mounts
887
- MCP, peer-free agent tools (`mountAgentTools`), and CLI surfaces together, you
888
- can also pin the shared context type once via `createToolkit<AppContext>()`
889
- from `stitchkit/tools/toolkit` — the tool-side mirror of `createImplement`
890
- ([ADR 0017](../decisions/0017-typed-tool-context.md),
891
- [ADR 0284](../decisions/0284-the-tools-barrel-loads-no-optional-peer.md),
892
- [ADR 0338](../decisions/0338-toolkit-stays-free-of-ai-peer.md)). It stays free
893
- of the `ai` peer; callers needing an AI SDK `ToolSet` use `mountAgent` from
894
- `stitchkit/tools/agent`:
895
-
896
- ```ts
897
- import { createToolkit } from 'stitchkit/tools/toolkit'
898
-
899
- const tools = createToolkit<{ user: User }>()
900
- await tools.createCli({
901
- name: 'myapp',
902
- version: '1.0.0',
903
- services,
904
- access: { gate: { beforeHandle: authHook } },
905
- context: (identity) => ({ user: identity }), // checked against { user: User }
906
- })
907
- ```
908
-
909
- ## Remaining boundary
910
-
911
- File-upload (`multipart`) contract endpoints remain CLI-invisible, the same as
912
- on MCP/Agent: their wire body is not a JSON tool form. Model file-oriented
913
- application behavior as a managed pathless command, or binary-only behavior as
914
- a native command. Streaming (SSE) output is not yet piped to stdout.
915
-
916
- ## Active decisions
917
-
918
- The current CLI parsing, routing, view-checking and runner contract is governed
919
- by:
920
-
921
- - [ADR 0083](../decisions/0083-cli-composes-managed-and-native-commands.md) — composition of contract, runtime and native commands with lazy credential-free native startup.
922
- - [ADR 0289](../decisions/0289-a-managed-command-owns-its-terminal-result-and-a-stream-is-a-command.md) — managed `results` presentation/exit policies, `--schema` and streaming CLI commands.
923
- - [ADR 0295](../decisions/0295-quiet-suppresses-profile-selection-notices.md) — `--quiet` suppresses inferred-profile notices before and inside `createCli`.
924
- - [ADR 0296](../decisions/0296-framework-options-reserve-their-cli-spellings.md) — framework option spellings are reserved and cannot be declared as command names.
925
- - [ADR 0310](../decisions/0310-one-model-for-cli-invocation-and-json-schema-keywords.md) — single-pass `scanCliInvocation`, exhaustive JSON Schema keyword table, pre-call view column checks, shared runner and removal of the ADR 0296 transitional refusal:
926
- - **Boolean case policy:** inline boolean words (`true`/`1`/`yes`/`on`, `false`/`0`/`no`/`off`) and separate adjacent boolean tokens (`true`, `false`) are matched **case-insensitively** (`--quiet TRUE cmd` sets `quiet: true` and selects `cmd`); invalid inline values such as `--quiet=maybe` fail with exit code 2 before any profile notice is printed.
927
- - **Broken boolean boundary:** adjacent `--flag false` remains a value (`inspect --dry-run false` executes `inspect`), but a bare boolean framework flag separated from `true` or `false` by a stripped token (a command name or an application option — `--dry-run inspect false` or `inspect --dry-run --profile demo false`) is refused with exit code 2, zero handler calls, and a hint to pass `--flag=false` or `-- false`.
928
- - **Passthrough coercion:** untyped passthrough flags coerce only `true`/`false` and numbers (`--mode on` stays `"on"`).
package/llms/cli.3.txt CHANGED
@@ -6,7 +6,73 @@
6
6
  Parts of this slice:
7
7
  - `llms/cli.txt`: Guide: CLI (docs/guide/cli.md)
8
8
  - `llms/cli.2.txt`: Guide: CLI (docs/guide/cli.md)
9
- - `llms/cli.3.txt`: API reference: `stitchkit/cli` (docs/api/reference.md)
9
+ - `llms/cli.3.txt`: Guide: CLI (docs/guide/cli.md) · API reference: `stitchkit/cli` (docs/api/reference.md)
10
+
11
+ ==============================================================================
12
+ # Guide: CLI (docs/guide/cli.md) (continued)
13
+ ==============================================================================
14
+
15
+ ## Typed context
16
+
17
+ For a peer-free CLI, import `createCli` directly from `stitchkit/cli` and
18
+ annotate the `context` factory's return type against your app's context shape
19
+ — no optional peers are loaded:
20
+
21
+ ```ts
22
+ import { createCli } from 'stitchkit/cli'
23
+
24
+ await createCli({
25
+ name: 'myapp',
26
+ version: '1.0.0',
27
+ services,
28
+ access: { gate: { beforeHandle: authHook } },
29
+ context: (identity): { user: User | undefined } => ({ user: identity }),
30
+ })
31
+ ```
32
+
33
+ If your application already installs `@modelcontextprotocol/server` and mounts
34
+ MCP, peer-free agent tools (`mountAgentTools`), and CLI surfaces together, you
35
+ can also pin the shared context type once via `createToolkit<AppContext>()`
36
+ from `stitchkit/tools/toolkit` — the tool-side mirror of `createImplement`
37
+ ([ADR 0017](../decisions/0017-typed-tool-context.md),
38
+ [ADR 0284](../decisions/0284-the-tools-barrel-loads-no-optional-peer.md),
39
+ [ADR 0338](../decisions/0338-toolkit-stays-free-of-ai-peer.md)). It stays free
40
+ of the `ai` peer; callers needing an AI SDK `ToolSet` use `mountAgent` from
41
+ `stitchkit/tools/agent`:
42
+
43
+ ```ts
44
+ import { createToolkit } from 'stitchkit/tools/toolkit'
45
+
46
+ const tools = createToolkit<{ user: User }>()
47
+ await tools.createCli({
48
+ name: 'myapp',
49
+ version: '1.0.0',
50
+ services,
51
+ access: { gate: { beforeHandle: authHook } },
52
+ context: (identity) => ({ user: identity }), // checked against { user: User }
53
+ })
54
+ ```
55
+
56
+ ## Remaining boundary
57
+
58
+ File-upload (`multipart`) contract endpoints remain CLI-invisible, the same as
59
+ on MCP/Agent: their wire body is not a JSON tool form. Model file-oriented
60
+ application behavior as a managed pathless command, or binary-only behavior as
61
+ a native command. Streaming (SSE) output is not yet piped to stdout.
62
+
63
+ ## Active decisions
64
+
65
+ The current CLI parsing, routing, view-checking and runner contract is governed
66
+ by:
67
+
68
+ - [ADR 0083](../decisions/0083-cli-composes-managed-and-native-commands.md) — composition of contract, runtime and native commands with lazy credential-free native startup.
69
+ - [ADR 0289](../decisions/0289-a-managed-command-owns-its-terminal-result-and-a-stream-is-a-command.md) — managed `results` presentation/exit policies, `--schema` and streaming CLI commands.
70
+ - [ADR 0295](../decisions/0295-quiet-suppresses-profile-selection-notices.md) — `--quiet` suppresses inferred-profile notices before and inside `createCli`.
71
+ - [ADR 0296](../decisions/0296-framework-options-reserve-their-cli-spellings.md) — framework option spellings are reserved and cannot be declared as command names.
72
+ - [ADR 0310](../decisions/0310-one-model-for-cli-invocation-and-json-schema-keywords.md) — single-pass `scanCliInvocation`, exhaustive JSON Schema keyword table, pre-call view column checks, shared runner and removal of the ADR 0296 transitional refusal:
73
+ - **Boolean case policy:** inline boolean words (`true`/`1`/`yes`/`on`, `false`/`0`/`no`/`off`) and separate adjacent boolean tokens (`true`, `false`) are matched **case-insensitively** (`--quiet TRUE cmd` sets `quiet: true` and selects `cmd`); invalid inline values such as `--quiet=maybe` fail with exit code 2 before any profile notice is printed.
74
+ - **Broken boolean boundary:** adjacent `--flag false` remains a value (`inspect --dry-run false` executes `inspect`), but a bare boolean framework flag separated from `true` or `false` by a stripped token (a command name or an application option — `--dry-run inspect false` or `inspect --dry-run --profile demo false`) is refused with exit code 2, zero handler calls, and a hint to pass `--flag=false` or `-- false`.
75
+ - **Passthrough coercion:** untyped passthrough flags coerce only `true`/`false` and numbers (`--mode on` stays `"on"`).
10
76
 
11
77
  ==============================================================================
12
78
  # API reference: `stitchkit/cli` (docs/api/reference.md)
package/llms/cli.txt CHANGED
@@ -7,7 +7,7 @@
7
7
  Parts of this slice:
8
8
  - `llms/cli.txt`: Guide: CLI (docs/guide/cli.md)
9
9
  - `llms/cli.2.txt`: Guide: CLI (docs/guide/cli.md)
10
- - `llms/cli.3.txt`: API reference: `stitchkit/cli` (docs/api/reference.md)
10
+ - `llms/cli.3.txt`: Guide: CLI (docs/guide/cli.md) · API reference: `stitchkit/cli` (docs/api/reference.md)
11
11
 
12
12
  ==============================================================================
13
13
  # Guide: CLI (docs/guide/cli.md)
package/llms/files.txt CHANGED
@@ -29,7 +29,7 @@ available from `stitchkit/contract`.
29
29
  | `ManagedFileError` / `ManagedFileErrorCode` | class / _type_ | stable boundary failures; registered `FILE_*` mistakes are caller-safe while `FILE_IO_ERROR` remains internal |
30
30
  | `ManagedFileInspector` | _type_ | bounded-prefix read/write inspection callback with a finite cancellation signal that cannot own path or size |
31
31
  | `ManagedFileInspectionInput` / `ManagedFileInspection` | _type_ | inspector prefix/name/declared media/signal input and validated metadata-only result |
32
- | `writeFileAtomic` / `writeFileAtomicSync` / `WriteFileAtomicOptions` | function / _type_ | replace a file atomically: a random staging name created exclusively (never through a planted link), the mode set on the descriptor before the file is visible (default `0o600`, not masked by the umask), `fsync`, rename; a failure leaves the target and no staging file. The asynchronous form keeps the event loop running. A process killed before publication leaves its staging file; sweeping it is the caller's job |
32
+ | `writeFileAtomic` / `writeFileAtomicSync` / `WriteFileAtomicOptions` / `WriteFileAtomicOwner` | function / _type_ | replace a file atomically: a random staging name created exclusively with `O_NOFOLLOW` (never through a planted link), optional POSIX `owner` (`'preserve'` from an existing regular target via `lstat`, or explicit `{ uid, gid }`, applied via `fchown` after comparing real `fstat(fd)` and strictly before `fchmod`), the exact `mode` set on the descriptor before the file is visible (default `0o600`, not masked by the umask), `fsync`, rename; a failure leaves the target untouched, removes the staging file, and propagates the native OS error. The asynchronous form keeps the event loop running. A process killed before publication leaves its staging file; sweeping it is the caller's job |
33
33
  | `isAtomicStagingName` | function | true for a staging file name of an atomic write of this library (`.stitchkit-<24 lowercase hex>.tmp`, also used by the managed writer and the chunk spool); the form is a stable contract, and changing it is a breaking change ([ADR 0242](../decisions/0242-atomic-staging-name-is-a-public-contract.md)) |
34
34
  | `sweepAtomicStaging` / `SweepAtomicStagingOptions` | function / _type_ | remove abandoned staging files from one `directory`: only regular files matching `isAtomicStagingName` and older than the required `olderThanMs`, never following a symlink or entering a subdirectory; stops on `signal`; returns the removed names, `[]` for a `directory` that does not exist |
35
35
  | `withExclusiveLock` / `ExclusiveLockOptions` / `ExclusiveLock` / `ExclusiveLockOwner` | function / _type_ | run work under an exclusive lock between processes — a file recording its owner (pid, host, machine identity, time and nullable kernel process identity); waits up to `timeoutMs` (default 10 s) and stops on `signal`; a dead owner on this machine is taken over, a live, slow or foreign one never is; a lock recorded by this very process is held only while one of its descriptors is open on it, so the lock an earlier image of the same PID left (`bun --watch` restarts in place) is taken over at once; the lock is published with its owner already recorded (temporary file plus hard link), so a stalled holder is never displaced; a legacy empty lock file is taken by age only when `ownerlessGraceMs` is a number (default `null`: never; an abandoned empty reclaim guard is taken after 5 000 ms unless a value is set); exact `mode` is independent of umask; shared readers need a common group and traversable directories |