stitchkit 0.136.4 → 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.
- package/CHANGELOG.md +7 -0
- package/dist/entrypoints/agent-executor/acp.js +5 -5
- package/dist/entrypoints/agent-executor/claude-sdk.js +7 -7
- package/dist/entrypoints/agent-executor/claude.js +7 -7
- package/dist/entrypoints/agent-executor/codex.js +9 -9
- package/dist/entrypoints/agent-executor/testing.js +9 -9
- package/dist/entrypoints/agent-executor.js +5 -5
- package/dist/entrypoints/agent-runtime/coding-tools.js +2 -2
- package/dist/entrypoints/agent-runtime/postgres.js +4 -4
- package/dist/entrypoints/agent-runtime/sandbox.js +7 -7
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +5 -5
- package/dist/entrypoints/agent-runtime/sqlite/node.js +5 -5
- package/dist/entrypoints/agent-runtime/testing.js +4 -4
- package/dist/entrypoints/agent-runtime.js +4 -4
- package/dist/entrypoints/application/diagnostic-journal.js +3 -3
- package/dist/entrypoints/application/directory-inbox.js +7 -7
- package/dist/entrypoints/cli/publish.d.ts +14 -6
- package/dist/entrypoints/cli/publish.d.ts.map +1 -1
- package/dist/entrypoints/cli/publish.js +685 -30
- package/dist/entrypoints/cli.js +7 -124
- package/dist/entrypoints/files/packaging.js +2 -2
- package/dist/entrypoints/files.d.ts +1 -0
- package/dist/entrypoints/files.d.ts.map +1 -1
- package/dist/entrypoints/files.js +9 -9
- package/dist/entrypoints/node.js +3 -3
- package/dist/entrypoints/observability.js +1 -1
- package/dist/entrypoints/process.js +3 -3
- package/dist/entrypoints/server.js +6 -6
- package/dist/entrypoints/service-host/macos.js +7 -7
- package/dist/entrypoints/service-host/work.js +6 -6
- package/dist/entrypoints/service-host.js +9 -9
- package/dist/entrypoints/spend.js +1 -1
- package/dist/entrypoints/telegram.js +3 -3
- package/dist/entrypoints/tools.js +1 -1
- package/dist/{index-05b65gj4.js → index-0s75mjh7.js} +1 -1
- package/dist/{index-s2e3h616.js → index-150b1qyw.js} +10 -1
- package/dist/{index-tcv71frn.js → index-1fhbe4e4.js} +1 -1
- package/dist/{index-8cek82ar.js → index-1h0dtfz3.js} +1 -1
- package/dist/{index-jwtmw39p.js → index-2qnqvq11.js} +1 -1
- package/dist/index-2rs7ze0q.js +376 -0
- package/dist/{index-2wm9b9vs.js → index-3cwq5byx.js} +2 -2
- package/dist/{index-mtpcax6d.js → index-5md04mwc.js} +3 -3
- package/dist/{index-b0mh2t9x.js → index-67mzzkdv.js} +3 -3
- package/dist/{index-d5mhgx72.js → index-8tn10tp6.js} +1 -1
- package/dist/{index-0sxj3y45.js → index-afaq0nc4.js} +1 -1
- package/dist/{index-nfm15ej7.js → index-bbpygynk.js} +1 -1
- package/dist/{index-g04hszcm.js → index-chapre0y.js} +1 -1
- package/dist/{index-vh4291qh.js → index-ctaxjpa4.js} +1 -1
- package/dist/{index-x1r7kxzd.js → index-e4zt2x70.js} +3 -3
- package/dist/{index-s0n0nnz5.js → index-f103md2v.js} +122 -3
- package/dist/{index-2c5w2d1d.js → index-gyfsh29t.js} +1 -1
- package/dist/{index-kgkevngs.js → index-kadgaw1s.js} +4 -4
- package/dist/{index-ca1v40d3.js → index-kd48gk7d.js} +1 -1
- package/dist/{index-ke6jtxkd.js → index-mr3njw67.js} +1 -1
- package/dist/{index-cmqvf0dz.js → index-ppy23bd2.js} +1 -1
- package/dist/{index-43k180c2.js → index-rnhp7je8.js} +2 -2
- package/dist/{index-2tgmggcm.js → index-smvmnz5y.js} +1 -1
- package/dist/{index-9m1m92rg.js → index-tjhhsnjv.js} +1 -1
- package/dist/{index-64t6pheq.js → index-w161azza.js} +1 -1
- package/dist/{index-mttkdm5a.js → index-xqppqn97.js} +1 -1
- package/dist/{index-sjq4akrx.js → index-xsrma0jd.js} +2 -2
- package/dist/{index-zqc64g69.js → index-ypm85xwe.js} +1 -1
- package/dist/{index-zagc12j1.js → index-zcq3dby3.js} +1 -1
- package/dist/{index-29v1p1f4.js → index-zhngww7q.js} +1 -1
- package/dist/internal/atomic-file-owner.d.ts +91 -0
- package/dist/internal/atomic-file-owner.d.ts.map +1 -0
- package/dist/internal/atomic-file.d.ts +29 -7
- package/dist/internal/atomic-file.d.ts.map +1 -1
- package/dist/internal/bounded-file-read.d.ts +6 -2
- package/dist/internal/bounded-file-read.d.ts.map +1 -1
- package/dist/tools/cli/distribution-config.d.ts +56 -0
- package/dist/tools/cli/distribution-config.d.ts.map +1 -0
- package/dist/tools/cli/distribution-routes.d.ts +20 -0
- package/dist/tools/cli/distribution-routes.d.ts.map +1 -0
- package/dist/tools/cli/publication-source.d.ts +77 -0
- package/dist/tools/cli/publication-source.d.ts.map +1 -0
- package/llms/cli-publish.txt +15 -3
- package/llms/cli.2.txt +84 -63
- package/llms/cli.3.txt +67 -1
- package/llms/cli.txt +1 -1
- package/llms/files.txt +1 -1
- package/llms/process.txt +24 -4
- package/llms/stitchkit.txt +1 -1
- package/llms-full.txt +124 -9
- package/llms.txt +5 -5
- package/package.json +1 -1
- package/dist/index-pp97q86a.js +0 -221
- package/dist/{index-5c4m8zdf.js → index-tjakdpf2.js} +45 -45
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
|
|
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 |
|
package/llms/process.txt
CHANGED
|
@@ -50,14 +50,34 @@ try {
|
|
|
50
50
|
await writeFileAtomic('/srv/app/state.json', '{"version":2}', {
|
|
51
51
|
replace: true, durability: 'directory',
|
|
52
52
|
})
|
|
53
|
+
// When a privileged process (e.g. root) updates a private config owned by a service user:
|
|
54
|
+
await writeFileAtomic('/etc/app/node.json', '{"version":2}', {
|
|
55
|
+
mode: 0o600, owner: 'preserve',
|
|
56
|
+
})
|
|
57
|
+
// Or set an explicit POSIX owner on creation or replacement:
|
|
58
|
+
await writeFileAtomic('/etc/app/node.json', '{"version":2}', {
|
|
59
|
+
mode: 0o600, owner: { uid: 1000, gid: 1000 },
|
|
60
|
+
})
|
|
53
61
|
```
|
|
54
62
|
|
|
55
63
|
The defaults are `replace: true`, `durability: 'file'` and `mode: 0o600`: file fsync and atomic
|
|
56
64
|
replacement. `durability: 'none'` skips every sync. `'directory'` runs the full sequence: write all
|
|
57
|
-
bytes, exact descriptor
|
|
58
|
-
link, parent directory fsync. `writeFileAtomicSync` takes the same
|
|
59
|
-
Create fails with the native `EEXIST` when the target exists, is a
|
|
60
|
-
won. Never turn that refusal into a replace automatically.
|
|
65
|
+
bytes, optional descriptor `fchown`, exact descriptor `fchmod`, file fsync, rename (replace) or link
|
|
66
|
+
(create), remove the staging link, parent directory fsync. `writeFileAtomicSync` takes the same
|
|
67
|
+
options and runs the same order. Create fails with the native `EEXIST` when the target exists, is a
|
|
68
|
+
symlink, or a concurrent writer won. Never turn that refusal into a replace automatically.
|
|
69
|
+
|
|
70
|
+
`owner: 'preserve'` inspects an existing regular file at `target` with `lstat` (never following a
|
|
71
|
+
symlink; missing or non-regular targets keep the kernel default) and cannot be combined with
|
|
72
|
+
`replace: false`. `owner: { uid, gid }` validates numeric POSIX IDs (`0..4294967294`; `0xffff_ffff`
|
|
73
|
+
is refused because POSIX `fchown` treats `(uid_t)-1` as a no-op). Both forms compare against the
|
|
74
|
+
staged descriptor's actual `fstat(fd)` — never guessing from `process.getuid()`/`process.getgid()`
|
|
75
|
+
— call `fchown` strictly before `fchmod(mode)` and `fsync`, narrow the staging creation mode to
|
|
76
|
+
`mode & 0o700` while ownership is pending, remove the staging file on any error (including `EPERM`
|
|
77
|
+
and `EACCES`), and rethrow the original system error untouched. With `replace: false`,
|
|
78
|
+
`idempotent: true` and an explicit `owner`, an existing target satisfies the idempotent check only
|
|
79
|
+
when its bytes, mode and `(uid, gid)` all match (while a staging `fchown` failure such as `EPERM`
|
|
80
|
+
still fails before publication). Ownership options are refused explicitly on Windows.
|
|
61
81
|
|
|
62
82
|
`AtomicFilePublicationError.published === true` tells a visible target from an unconfirmed
|
|
63
83
|
acknowledgement. `phase` is `cleanup`, `directory-sync` or `directory-close`; the primary cause is
|
package/llms/stitchkit.txt
CHANGED
|
@@ -74,7 +74,7 @@ own, recorded as an ADR.
|
|
|
74
74
|
| `stitchkit/tools/invoker` | server | stable<br>_redefined in 3 of the 43 minors since 0.94.0, most recently 0.127.0_ | peer-free `createToolInvoker` over the canonical contract tool runner |
|
|
75
75
|
| `stitchkit/tools/connections` | server (Bun or Node) | evolving<br>_redefined in 3 of the 43 minors since 0.94.0, most recently 0.127.0_ | consume external MCP servers and a bounded OpenAPI subset — typed reauthorization, a per-request host fence and per-call credentials |
|
|
76
76
|
| `stitchkit/cli` | server | stable<br>_redefined in 12 of the 43 minors since 0.94.0, most recently 0.128.0_ | `createCli` / `createCliInvoker` — runtime and strict NodeNext declarations without MCP SDK / `ai` |
|
|
77
|
-
| `stitchkit/cli/publish` | build and
|
|
77
|
+
| `stitchkit/cli/publish` | build, release and server tooling (Bun or Node, POSIX) | evolving<br>_redefined in 0 of the 43 minors since 0.94.0_ | `publishCli`, shipping-input versioning (`deriveCliVersionFromShippingInputs`, `cliShippingInputsChanged`, `assertCleanCliSource`), and `createCliDistributionRoutes` (`RawRoute[]` channel manifest, asset and installer routes); see [CLI guide](cli.md#publishing-a-complete-version) |
|
|
78
78
|
| `stitchkit/remote` | browser **and** server | stable<br>_redefined in 1 of the 43 minors since 0.94.0, most recently 0.104.0_ | peer-free `implementRemote` for thin HTTP proxy processes |
|
|
79
79
|
| `stitchkit/process` | server (Bun or Node, POSIX) | evolving<br>_redefined in 4 of the 43 minors since 0.94.0, most recently 0.133.0_ | finite native commands, byte sinks, bounded capture, process-group cancellation and opt-in Linux/Darwin owner-loss cleanup; contract operations executed in one-call child processes |
|
|
80
80
|
| `stitchkit/process/bootstrap` | bundled server entry (Bun, POSIX) | evolving<br>_redefined in 0 of the 4 minors since 0.133.0_ | narrow bootstrap that keeps the process runner lazy while carrying the package's own invocations — the owner-loss guard and the process root of launched work — in a single-file bundle |
|
package/llms-full.txt
CHANGED
|
@@ -65,7 +65,7 @@ own, recorded as an ADR.
|
|
|
65
65
|
| `stitchkit/tools/invoker` | server | stable<br>_redefined in 3 of the 43 minors since 0.94.0, most recently 0.127.0_ | peer-free `createToolInvoker` over the canonical contract tool runner |
|
|
66
66
|
| `stitchkit/tools/connections` | server (Bun or Node) | evolving<br>_redefined in 3 of the 43 minors since 0.94.0, most recently 0.127.0_ | consume external MCP servers and a bounded OpenAPI subset — typed reauthorization, a per-request host fence and per-call credentials |
|
|
67
67
|
| `stitchkit/cli` | server | stable<br>_redefined in 12 of the 43 minors since 0.94.0, most recently 0.128.0_ | `createCli` / `createCliInvoker` — runtime and strict NodeNext declarations without MCP SDK / `ai` |
|
|
68
|
-
| `stitchkit/cli/publish` | build and
|
|
68
|
+
| `stitchkit/cli/publish` | build, release and server tooling (Bun or Node, POSIX) | evolving<br>_redefined in 0 of the 43 minors since 0.94.0_ | `publishCli`, shipping-input versioning (`deriveCliVersionFromShippingInputs`, `cliShippingInputsChanged`, `assertCleanCliSource`), and `createCliDistributionRoutes` (`RawRoute[]` channel manifest, asset and installer routes); see [CLI guide](cli.md#publishing-a-complete-version) |
|
|
69
69
|
| `stitchkit/remote` | browser **and** server | stable<br>_redefined in 1 of the 43 minors since 0.94.0, most recently 0.104.0_ | peer-free `implementRemote` for thin HTTP proxy processes |
|
|
70
70
|
| `stitchkit/process` | server (Bun or Node, POSIX) | evolving<br>_redefined in 4 of the 43 minors since 0.94.0, most recently 0.133.0_ | finite native commands, byte sinks, bounded capture, process-group cancellation and opt-in Linux/Darwin owner-loss cleanup; contract operations executed in one-call child processes |
|
|
71
71
|
| `stitchkit/process/bootstrap` | bundled server entry (Bun, POSIX) | evolving<br>_redefined in 0 of the 4 minors since 0.133.0_ | narrow bootstrap that keeps the process runner lazy while carrying the package's own invocations — the owner-loss guard and the process root of launched work — in a single-file bundle |
|
|
@@ -10797,14 +10797,34 @@ try {
|
|
|
10797
10797
|
await writeFileAtomic('/srv/app/state.json', '{"version":2}', {
|
|
10798
10798
|
replace: true, durability: 'directory',
|
|
10799
10799
|
})
|
|
10800
|
+
// When a privileged process (e.g. root) updates a private config owned by a service user:
|
|
10801
|
+
await writeFileAtomic('/etc/app/node.json', '{"version":2}', {
|
|
10802
|
+
mode: 0o600, owner: 'preserve',
|
|
10803
|
+
})
|
|
10804
|
+
// Or set an explicit POSIX owner on creation or replacement:
|
|
10805
|
+
await writeFileAtomic('/etc/app/node.json', '{"version":2}', {
|
|
10806
|
+
mode: 0o600, owner: { uid: 1000, gid: 1000 },
|
|
10807
|
+
})
|
|
10800
10808
|
```
|
|
10801
10809
|
|
|
10802
10810
|
The defaults are `replace: true`, `durability: 'file'` and `mode: 0o600`: file fsync and atomic
|
|
10803
10811
|
replacement. `durability: 'none'` skips every sync. `'directory'` runs the full sequence: write all
|
|
10804
|
-
bytes, exact descriptor
|
|
10805
|
-
link, parent directory fsync. `writeFileAtomicSync` takes the same
|
|
10806
|
-
Create fails with the native `EEXIST` when the target exists, is a
|
|
10807
|
-
won. Never turn that refusal into a replace automatically.
|
|
10812
|
+
bytes, optional descriptor `fchown`, exact descriptor `fchmod`, file fsync, rename (replace) or link
|
|
10813
|
+
(create), remove the staging link, parent directory fsync. `writeFileAtomicSync` takes the same
|
|
10814
|
+
options and runs the same order. Create fails with the native `EEXIST` when the target exists, is a
|
|
10815
|
+
symlink, or a concurrent writer won. Never turn that refusal into a replace automatically.
|
|
10816
|
+
|
|
10817
|
+
`owner: 'preserve'` inspects an existing regular file at `target` with `lstat` (never following a
|
|
10818
|
+
symlink; missing or non-regular targets keep the kernel default) and cannot be combined with
|
|
10819
|
+
`replace: false`. `owner: { uid, gid }` validates numeric POSIX IDs (`0..4294967294`; `0xffff_ffff`
|
|
10820
|
+
is refused because POSIX `fchown` treats `(uid_t)-1` as a no-op). Both forms compare against the
|
|
10821
|
+
staged descriptor's actual `fstat(fd)` — never guessing from `process.getuid()`/`process.getgid()`
|
|
10822
|
+
— call `fchown` strictly before `fchmod(mode)` and `fsync`, narrow the staging creation mode to
|
|
10823
|
+
`mode & 0o700` while ownership is pending, remove the staging file on any error (including `EPERM`
|
|
10824
|
+
and `EACCES`), and rethrow the original system error untouched. With `replace: false`,
|
|
10825
|
+
`idempotent: true` and an explicit `owner`, an existing target satisfies the idempotent check only
|
|
10826
|
+
when its bytes, mode and `(uid, gid)` all match (while a staging `fchown` failure such as `EPERM`
|
|
10827
|
+
still fails before publication). Ownership options are refused explicitly on Windows.
|
|
10808
10828
|
|
|
10809
10829
|
`AtomicFilePublicationError.published === true` tells a visible target from an unconfirmed
|
|
10810
10830
|
acknowledgement. `phase` is `cleanup`, `directory-sync` or `directory-close`; the primary cause is
|
|
@@ -13644,6 +13664,89 @@ identity to recover; an error does not promise rollback. Optional `signing` and
|
|
|
13644
13664
|
raw digest and size; the updater checks manifest authorship when given a trust
|
|
13645
13665
|
root.
|
|
13646
13666
|
|
|
13667
|
+
### Versioning from shipping inputs and verifying clean source
|
|
13668
|
+
|
|
13669
|
+
When a CLI lives inside a larger repository, ordinary backend commits should not
|
|
13670
|
+
force a new CLI version. `stitchkit/cli/publish` provides three git-backed
|
|
13671
|
+
helpers (`deriveCliVersionFromShippingInputs`, `cliShippingInputsChanged`, and
|
|
13672
|
+
`assertCleanCliSource`) built on `runNativeCommand` with a declared-only
|
|
13673
|
+
environment (`GIT_TERMINAL_PROMPT=0`, `GIT_OPTIONAL_LOCKS=0`, ignoring inherited
|
|
13674
|
+
`GIT_DIR` / `GIT_WORK_TREE`):
|
|
13675
|
+
|
|
13676
|
+
```ts
|
|
13677
|
+
import {
|
|
13678
|
+
assertCleanCliSource,
|
|
13679
|
+
cliShippingInputsChanged,
|
|
13680
|
+
deriveCliVersionFromShippingInputs,
|
|
13681
|
+
} from 'stitchkit/cli/publish'
|
|
13682
|
+
|
|
13683
|
+
const shippingPaths = ['packages/cli', 'packages/shared', 'bun.lock']
|
|
13684
|
+
const head = await assertCleanCliSource({
|
|
13685
|
+
repository: '/srv/myapp/source',
|
|
13686
|
+
untrackedPaths: ['packages/cli', 'packages/shared', 'scripts/cli-publish*'],
|
|
13687
|
+
})
|
|
13688
|
+
const version = await deriveCliVersionFromShippingInputs({
|
|
13689
|
+
repository: '/srv/myapp/source',
|
|
13690
|
+
commit: head,
|
|
13691
|
+
packageJsonPath: 'packages/cli/package.json',
|
|
13692
|
+
shippingPaths,
|
|
13693
|
+
})
|
|
13694
|
+
const changed = await cliShippingInputsChanged({
|
|
13695
|
+
repository: '/srv/myapp/source',
|
|
13696
|
+
previousCommit,
|
|
13697
|
+
nextCommit: head,
|
|
13698
|
+
shippingPaths,
|
|
13699
|
+
})
|
|
13700
|
+
```
|
|
13701
|
+
|
|
13702
|
+
`deriveCliVersionFromShippingInputs` reads `major.minor` from `packageJsonPath`
|
|
13703
|
+
at `<commit>` and counts commits touching `shippingPaths` up to `<commit>`
|
|
13704
|
+
(`major.minor.<count>`). Both `deriveCliVersionFromShippingInputs` and
|
|
13705
|
+
`cliShippingInputsChanged` accept either a git worktree root or a bare
|
|
13706
|
+
repository root (`realpath(--show-toplevel)` or `realpath(--absolute-git-dir)`
|
|
13707
|
+
matching `realpath(repository)`), while `assertCleanCliSource` requires a
|
|
13708
|
+
worktree root; subdirectories and non-bare `.git` directories are refused. All
|
|
13709
|
+
three helpers require exact 40-hex commit objects (refusing tree, blob and
|
|
13710
|
+
annotated-tag SHAs), full history for version counting (refusing shallow
|
|
13711
|
+
clones), and safe repository-relative paths without `:` magic pathspecs.
|
|
13712
|
+
`assertCleanCliSource` returns the verified 40-hex `HEAD` and checks tracked
|
|
13713
|
+
changes plus either all untracked files (`--untracked-files=normal`) or only
|
|
13714
|
+
untracked files matching `untrackedPaths`.
|
|
13715
|
+
|
|
13716
|
+
### Serving a published CLI channel
|
|
13717
|
+
|
|
13718
|
+
`createCliDistributionRoutes` returns portable `RawRoute[]` (`GET` only) that
|
|
13719
|
+
serve a directory published by `publishCli` under `<root>/channels/<channel>/`:
|
|
13720
|
+
|
|
13721
|
+
```ts
|
|
13722
|
+
import { createCliDistributionRoutes } from 'stitchkit/cli/publish'
|
|
13723
|
+
import { createServer } from 'stitchkit/server'
|
|
13724
|
+
|
|
13725
|
+
const server = createServer({
|
|
13726
|
+
rawRoutes: createCliDistributionRoutes({
|
|
13727
|
+
root: process.env.CLI_DISTRIBUTION_DIR,
|
|
13728
|
+
name: 'myapp',
|
|
13729
|
+
trust: RELEASE_TRUST_ROOT,
|
|
13730
|
+
onUnavailable: (event) => logger.warn(event, 'CLI distribution unavailable'),
|
|
13731
|
+
}),
|
|
13732
|
+
})
|
|
13733
|
+
```
|
|
13734
|
+
|
|
13735
|
+
Each configured channel mounts `${basePath}/channels/<channel>/manifest.json`
|
|
13736
|
+
(`Cache-Control: no-store`, exact raw verified bytes) and
|
|
13737
|
+
`${basePath}/channels/<channel>/:version/:asset` (immutable `manifest.json` or a
|
|
13738
|
+
descriptor-streamed binary listed in the signed manifest with `Content-Length`
|
|
13739
|
+
and `Content-Disposition`). `${basePath}/install.sh` renders `renderCliInstaller`
|
|
13740
|
+
from the verified `installerChannel` manifest (`no-store`). Every read checks
|
|
13741
|
+
canonical directory containment (`realpath` + `isWithinDir`), opens regular files
|
|
13742
|
+
with `O_NOFOLLOW`, parses strict UTF-8 JSON without `__proto__`, verifies
|
|
13743
|
+
`manifest.name` and Ed25519 signature strictly (`verifyCliManifest === 'valid'`),
|
|
13744
|
+
and streams full asset bodies portably on both Bun and Node without `Bun.file`.
|
|
13745
|
+
When `root` is `undefined`, `trust.keys` is empty, or the manifest is missing,
|
|
13746
|
+
unsigned, tampered, oversized or has no assets, channel manifest and installer
|
|
13747
|
+
routes fail closed with `503 No verified CLI build is published` (`no-store`),
|
|
13748
|
+
and exceptions thrown by `onUnavailable` are isolated.
|
|
13749
|
+
|
|
13647
13750
|
### Proving who built it — signing the manifest
|
|
13648
13751
|
|
|
13649
13752
|
The asset digest proves the bytes that arrived are the bytes the manifest named.
|
|
@@ -31234,7 +31337,7 @@ available from `stitchkit/contract`.
|
|
|
31234
31337
|
| `ManagedFileError` / `ManagedFileErrorCode` | class / _type_ | stable boundary failures; registered `FILE_*` mistakes are caller-safe while `FILE_IO_ERROR` remains internal |
|
|
31235
31338
|
| `ManagedFileInspector` | _type_ | bounded-prefix read/write inspection callback with a finite cancellation signal that cannot own path or size |
|
|
31236
31339
|
| `ManagedFileInspectionInput` / `ManagedFileInspection` | _type_ | inspector prefix/name/declared media/signal input and validated metadata-only result |
|
|
31237
|
-
| `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
|
|
31340
|
+
| `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 |
|
|
31238
31341
|
| `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)) |
|
|
31239
31342
|
| `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 |
|
|
31240
31343
|
| `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 |
|
|
@@ -31973,9 +32076,12 @@ SDK nor the `ai` peer.
|
|
|
31973
32076
|
|
|
31974
32077
|
## `stitchkit/cli/publish`
|
|
31975
32078
|
|
|
31976
|
-
Build and
|
|
31977
|
-
application-owned directory
|
|
31978
|
-
|
|
32079
|
+
Build, source verification and distribution-route tooling, evolving. Publishes a
|
|
32080
|
+
CLI distribution into a local application-owned directory, derives deterministic
|
|
32081
|
+
versions from git shipping-input history, verifies clean source roots, and
|
|
32082
|
+
serves verified channel manifests, immutable assets and `install.sh` over
|
|
32083
|
+
`RawRoute[]`; the manifest, signatures, installer and updater it writes for stay
|
|
32084
|
+
in `stitchkit/cli` — [guide](../guide/cli.md#publishing-a-complete-version),
|
|
31979
32085
|
[ADR 0245](../decisions/0245-cli-publication-is-an-evolving-leaf.md).
|
|
31980
32086
|
|
|
31981
32087
|
| Export | Kind | Summary |
|
|
@@ -31984,6 +32090,15 @@ writes for stay in `stitchkit/cli` — [guide](../guide/cli.md#publishing-a-comp
|
|
|
31984
32090
|
| `CliPublicationOptions` | _type_ | identity, storage root, base URL, targets, limits, retention, the `admit` and `build` callbacks, optional signing and trust |
|
|
31985
32091
|
| `CliPublicationPhase` | _type_ | the step `admit` is asked about — `prepare`, `build`, `commit` or `promote` |
|
|
31986
32092
|
| `CliPublicationResult` | _type_ | `published` or `existing`, with the manifest ready to serve |
|
|
32093
|
+
| `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 |
|
|
32094
|
+
| `CliShippingVersionOptions` | _type_ | options for `deriveCliVersionFromShippingInputs` (`repository`, `commit`, `packageJsonPath`, `shippingPaths`, `timeoutMs`, `signal`) |
|
|
32095
|
+
| `cliShippingInputsChanged` | function | return `true` when any path in `shippingPaths` differs between `previousCommit` and `nextCommit` using `git diff --no-ext-diff --quiet` |
|
|
32096
|
+
| `CliShippingInputsChangedOptions` | _type_ | options for `cliShippingInputsChanged` (`repository`, `previousCommit`, `nextCommit`, `shippingPaths`, `timeoutMs`, `signal`) |
|
|
32097
|
+
| `assertCleanCliSource` | function | verify a clean git root matching optional `expectedCommit`, optional `untrackedPaths` globs and optional `servingSource` realpath; returns verified 40-hex `HEAD` |
|
|
32098
|
+
| `CleanCliSourceOptions` | _type_ | options for `assertCleanCliSource` (`repository`, `expectedCommit`, `untrackedPaths`, `servingSource`, `timeoutMs`, `signal`) |
|
|
32099
|
+
| `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` |
|
|
32100
|
+
| `CliDistributionRoutesOptions` | _type_ | options for `createCliDistributionRoutes` (`root`, `name`, `trust`, `channels`, `installerChannel`, `basePath`, `binaryName`, `installDir`, `maxManifestBytes`, `serviceName`, `onUnavailable`) |
|
|
32101
|
+
| `CliDistributionUnavailableEvent` | _type_ | diagnostic event passed to `onUnavailable` with `route`, `channel`, optional `version`/`asset`, inline `reason`, optional `verdict` and `error` |
|
|
31987
32102
|
|
|
31988
32103
|
---
|
|
31989
32104
|
|
package/llms.txt
CHANGED
|
@@ -9,7 +9,7 @@ Build with stitchkit: define a contract once, then `implement` it and serve it (
|
|
|
9
9
|
Load the slice for each entrypoint your code imports — `import … from 'stitchkit/server'` → `llms/server.txt`; the root `stitchkit` import → `llms/stitchkit.txt`. A slice holds that entrypoint's API reference section and the guide pages whose home it is; every guide lives in exactly one slice, and a slice that needs another's guide names it under "Also read". Each file is at most 50.0 KB; a longer one continues in numbered parts, each naming the next at its top. Moving across versions: load `llms/upgrading.txt` and the range slices it lists between your version and the target. `llms-full.txt` inlines everything; it is far larger than a context window, so do not read it whole.
|
|
10
10
|
|
|
11
11
|
## Entrypoint slices
|
|
12
|
-
- **stitchkit**: [llms/stitchkit.txt](llms/stitchkit.txt) 44.
|
|
12
|
+
- **stitchkit**: [llms/stitchkit.txt](llms/stitchkit.txt) 44.6 KB → [llms/stitchkit.2.txt](llms/stitchkit.2.txt) 47.2 KB → [llms/stitchkit.3.txt](llms/stitchkit.3.txt) 29.4 KB
|
|
13
13
|
- **stitchkit/live**: [llms/live.txt](llms/live.txt) 22.9 KB
|
|
14
14
|
- **stitchkit/react**: [llms/react.txt](llms/react.txt) 8.7 KB
|
|
15
15
|
- **stitchkit/react/keyboard**: [llms/react-keyboard.txt](llms/react-keyboard.txt) 22.7 KB
|
|
@@ -21,8 +21,8 @@ Load the slice for each entrypoint your code imports — `import … from 'stitc
|
|
|
21
21
|
- **stitchkit/tools/contract**: [llms/tools-contract.txt](llms/tools-contract.txt) 0.2 KB
|
|
22
22
|
- **stitchkit/tools/invoker**: [llms/tools-invoker.txt](llms/tools-invoker.txt) 0.2 KB
|
|
23
23
|
- **stitchkit/tools/connections**: [llms/tools-connections.txt](llms/tools-connections.txt) 4.9 KB
|
|
24
|
-
- **stitchkit/cli**: [llms/cli.txt](llms/cli.txt) 42.0 KB → [llms/cli.2.txt](llms/cli.2.txt)
|
|
25
|
-
- **stitchkit/cli/publish**: [llms/cli-publish.txt](llms/cli-publish.txt)
|
|
24
|
+
- **stitchkit/cli**: [llms/cli.txt](llms/cli.txt) 42.0 KB → [llms/cli.2.txt](llms/cli.2.txt) 47.0 KB → [llms/cli.3.txt](llms/cli.3.txt) 16.2 KB
|
|
25
|
+
- **stitchkit/cli/publish**: [llms/cli-publish.txt](llms/cli-publish.txt) 3.6 KB
|
|
26
26
|
- **stitchkit/remote**: [llms/remote.txt](llms/remote.txt) 1.0 KB
|
|
27
27
|
- **stitchkit/contract**: [llms/contract.txt](llms/contract.txt) 36.5 KB
|
|
28
28
|
- **stitchkit/primitives**: [llms/primitives.txt](llms/primitives.txt) 15.2 KB
|
|
@@ -56,7 +56,7 @@ Load the slice for each entrypoint your code imports — `import … from 'stitc
|
|
|
56
56
|
- **stitchkit/agent-runtime/sandbox**: [llms/agent-runtime-sandbox.txt](llms/agent-runtime-sandbox.txt) 17.1 KB
|
|
57
57
|
- **stitchkit/spend**: [llms/spend.txt](llms/spend.txt) 11.0 KB
|
|
58
58
|
- **stitchkit/spend/testing**: [llms/spend-testing.txt](llms/spend-testing.txt) 1.2 KB
|
|
59
|
-
- **stitchkit/files**: [llms/files.txt](llms/files.txt) 11.
|
|
59
|
+
- **stitchkit/files**: [llms/files.txt](llms/files.txt) 11.7 KB
|
|
60
60
|
- **stitchkit/service-host**: [llms/service-host.txt](llms/service-host.txt) 10.3 KB
|
|
61
61
|
- **stitchkit/service-host/macos**: [llms/service-host-macos.txt](llms/service-host-macos.txt) 6.2 KB
|
|
62
62
|
- **stitchkit/service-host/work**: [llms/service-host-work.txt](llms/service-host-work.txt) 4.1 KB
|
|
@@ -83,7 +83,7 @@ Load the slice for each entrypoint your code imports — `import … from 'stitc
|
|
|
83
83
|
- **stitchkit/agent-runtime/react**: [llms/agent-runtime-react.txt](llms/agent-runtime-react.txt) 1.0 KB
|
|
84
84
|
- **stitchkit/agent-runtime/realtime**: [llms/agent-runtime-realtime.txt](llms/agent-runtime-realtime.txt) 2.6 KB
|
|
85
85
|
- **stitchkit/agent-runtime/ai-sdk**: [llms/agent-runtime-ai-sdk.txt](llms/agent-runtime-ai-sdk.txt) 1.6 KB
|
|
86
|
-
- **stitchkit/process**: [llms/process.txt](llms/process.txt)
|
|
86
|
+
- **stitchkit/process**: [llms/process.txt](llms/process.txt) 43.5 KB → [llms/process.2.txt](llms/process.2.txt) 31.1 KB
|
|
87
87
|
- **stitchkit/process/bootstrap**: [llms/process-bootstrap.txt](llms/process-bootstrap.txt) 1.0 KB
|
|
88
88
|
- **stitchkit/files/packaging**: [llms/files-packaging.txt](llms/files-packaging.txt) 5.7 KB
|
|
89
89
|
- **stitchkit/http**: [llms/http.txt](llms/http.txt) 3.0 KB
|
package/package.json
CHANGED