@jimhoyd/urlcode 0.4.1 → 0.4.6
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/.claude/skills/urlcode-authoring/SKILL.md +60 -7
- package/.claude/skills/urlcode-operations/SKILL.md +4 -0
- package/README.md +19 -15
- package/SECURITY.md +5 -3
- package/dist/BUILD-MANIFEST.json +31 -28
- package/dist/agent-context.js +82 -0
- package/dist/agents-guide.js +42 -42
- package/dist/authoring.js +12 -2
- package/dist/body-schema.js +159 -0
- package/dist/build-cloudflare.js +2 -0
- package/dist/capabilities.js +1 -1
- package/dist/cli.js +29 -12
- package/dist/config.js +74 -6
- package/dist/context.js +4 -6
- package/dist/errors.js +3 -1
- package/dist/examples.js +1 -1
- package/dist/extensions.js +138 -3
- package/dist/http-policy.js +19 -4
- package/dist/http-response.js +2 -2
- package/dist/init-with.js +71 -9
- package/dist/mcp.js +15 -2
- package/dist/pattern-guard.js +32 -0
- package/dist/policies/security.js +0 -0
- package/dist/policy.js +16 -0
- package/dist/project-tests.js +35 -11
- package/dist/readiness.js +188 -32
- package/dist/recipes.js +1 -1
- package/dist/router.js +17 -0
- package/dist/runtime.js +26 -3
- package/dist/scaffold.js +0 -0
- package/dist/server.js +26 -3
- package/dist/site.js +0 -0
- package/dist/tooling.js +3 -1
- package/dist/types/agent-context.d.ts +44 -0
- package/dist/types/authoring.d.ts +3 -1
- package/dist/types/body-schema.d.ts +58 -0
- package/dist/types/config.d.ts +10 -2
- package/dist/types/context.d.ts +1 -1
- package/dist/types/errors.d.ts +9 -1
- package/dist/types/examples.d.ts +1 -1
- package/dist/types/extensions.d.ts +105 -2
- package/dist/types/http-policy.d.ts +3 -0
- package/dist/types/init-with.d.ts +10 -1
- package/dist/types/pattern-guard.d.ts +10 -0
- package/dist/types/project-tests.d.ts +9 -0
- package/dist/types/readiness.d.ts +71 -0
- package/dist/types/recipes.d.ts +1 -1
- package/dist/types/runtime.d.ts +4 -0
- package/dist/types/server.d.ts +9 -1
- package/dist/types/tooling.d.ts +2 -0
- package/dist/types/types.d.ts +13 -0
- package/dist/types.js +10 -2
- package/dist/typescript-authoring.js +5 -3
- package/dist/verify-deployment.js +16 -10
- package/examples/body-validation/README.md +16 -0
- package/examples/body-validation/example.yaml +17 -0
- package/examples/body-validation/tests/requests.json +15 -0
- package/examples/body-validation/urlcode.yaml +34 -0
- package/examples/coverage-waiver/README.md +8 -0
- package/examples/coverage-waiver/example.yaml +16 -0
- package/examples/coverage-waiver/functions/notes.mjs +2 -0
- package/examples/coverage-waiver/tests/requests.json +3 -0
- package/examples/coverage-waiver/urlcode.yaml +10 -0
- package/examples/data-dir/README.md +39 -0
- package/examples/data-dir/data/welcome.txt +1 -0
- package/examples/data-dir/example.yaml +22 -0
- package/examples/data-dir/functions/note.mjs +18 -0
- package/examples/data-dir/tests/requests.json +6 -0
- package/examples/data-dir/urlcode.yaml +6 -0
- package/examples/lifecycle/README.md +15 -0
- package/examples/lifecycle/example.yaml +19 -0
- package/examples/lifecycle/functions/notes.mjs +29 -0
- package/examples/lifecycle/tests/requests.json +12 -0
- package/examples/lifecycle/urlcode.yaml +29 -0
- package/examples/not-found/README.md +10 -0
- package/examples/not-found/example.yaml +17 -0
- package/examples/not-found/public/404.html +3 -0
- package/examples/not-found/public/index.html +3 -0
- package/examples/not-found/tests/requests.json +7 -0
- package/examples/not-found/urlcode.yaml +7 -0
- package/examples/shared-blocks/README.md +11 -0
- package/examples/shared-blocks/example.yaml +17 -0
- package/examples/shared-blocks/tests/requests.json +7 -0
- package/examples/shared-blocks/urlcode.yaml +37 -0
- package/llms-full.txt +436 -149
- package/llms.txt +44 -6
- package/package.json +15 -22
- package/recipes/static-page/README.md +9 -0
- package/recipes/static-page/public/index.html +11 -0
- package/recipes/static-page/recipe.yaml +21 -0
- package/recipes/static-page/tests/requests.json +22 -0
- package/recipes/static-page/urlcode.yaml +7 -0
- package/recipes/static-plus-api/README.md +6 -0
- package/recipes/static-plus-api/urlcode.yaml +4 -0
- package/recipes/store-crud/README.md +53 -0
- package/recipes/store-crud/recipe.yaml +31 -0
- package/recipes/store-crud/tests/requests.json +18 -0
- package/recipes/store-crud/urlcode.yaml +18 -0
- package/schemas/urlcode.schema.json +125 -60
- package/skills/urlcode/SKILL.md +53 -26
- package/starters/default/AGENTS.md +43 -43
- package/starters/page/README.md +14 -0
- package/starters/page/public/index.html +12 -0
- package/starters/page/tests/requests.json +17 -0
- package/starters/page/urlcode.yaml +6 -0
- package/.claude-plugin/marketplace.json +0 -18
- package/CONTRIBUTING.md +0 -112
- package/ROADMAP.md +0 -66
- package/docs/AI-AUTHORING.md +0 -338
- package/docs/ASSETS.md +0 -107
- package/docs/AUTH-BACKUP.md +0 -32
- package/docs/AWS.md +0 -86
- package/docs/BEST-PRACTICES.md +0 -276
- package/docs/BULK.md +0 -79
- package/docs/CAPABILITIES.md +0 -192
- package/docs/CAPACITY.md +0 -305
- package/docs/CI-FOLLOWUP-2026-09-19.md +0 -97
- package/docs/CI-RELEASE-AUDIT-2026-09-19.md +0 -322
- package/docs/CI.md +0 -147
- package/docs/CLOUDFLARE.md +0 -109
- package/docs/CODEBASE-AUDIT-2026-09-20.md +0 -284
- package/docs/COMPLIANCE.md +0 -239
- package/docs/COMPOSING-A-SITE.md +0 -278
- package/docs/CONDITIONS.md +0 -74
- package/docs/DEPLOYMENT-CHECKS.md +0 -108
- package/docs/DEVELOPMENT-PIPELINE.md +0 -270
- package/docs/EGRESS.md +0 -125
- package/docs/EXTENSIONS.md +0 -438
- package/docs/FRAMEWORK.md +0 -217
- package/docs/FUNCTION-SECURITY.md +0 -254
- package/docs/HTTP.md +0 -129
- package/docs/INSTALL.md +0 -128
- package/docs/INTERCHANGE.md +0 -134
- package/docs/LOAD-TESTING.md +0 -91
- package/docs/LOCAL-DEVELOPMENT.md +0 -102
- package/docs/MIDDLEWARE-EXAMPLES.md +0 -75
- package/docs/MIDDLEWARE.md +0 -102
- package/docs/MONITORING.md +0 -115
- package/docs/OBSERVABILITY.md +0 -222
- package/docs/OPEN-DECISIONS.md +0 -224
- package/docs/OPERATIONAL-PROOF.md +0 -41
- package/docs/OPERATIONS.md +0 -201
- package/docs/ORGANIZATION.md +0 -135
- package/docs/PERFORMANCE.md +0 -72
- package/docs/PLUGINS.md +0 -271
- package/docs/POLICIES.md +0 -211
- package/docs/PRERENDER.md +0 -245
- package/docs/PROJECT-DIRECTION.md +0 -118
- package/docs/PROVIDER-VERIFICATION.md +0 -84
- package/docs/READINESS.md +0 -150
- package/docs/README.md +0 -87
- package/docs/RECIPES.md +0 -99
- package/docs/RELEASE-0.4.0-alpha.3.md +0 -50
- package/docs/RELEASE-0.4.1.md +0 -73
- package/docs/RELEASE-READINESS.md +0 -117
- package/docs/RELEASE-SECURITY.md +0 -96
- package/docs/RESILIENCE.md +0 -161
- package/docs/ROUTING.md +0 -92
- package/docs/SANDBOX-REVIEW.md +0 -72
- package/docs/SCAFFOLDING.md +0 -70
- package/docs/SECURITY-AUDIT.md +0 -164
- package/docs/SITE.md +0 -150
- package/docs/SPECIFICATION.md +0 -359
- package/docs/SPIKE-AI-FRAMEWORK-BENCHMARK.md +0 -288
- package/docs/SPIKE-BUSINESS-SUITE.md +0 -1029
- package/docs/SPIKE-CORE-LAYERING.md +0 -368
- package/docs/SPIKE-DEFAULT-TRUST-MODEL.md +0 -211
- package/docs/STANDARDS.md +0 -311
- package/docs/STARTERS.md +0 -83
- package/docs/STATIC.md +0 -105
- package/docs/TOOLING.md +0 -298
- package/docs/TUNNELS.md +0 -72
- package/docs/TYPESCRIPT-AUTHORING.md +0 -87
- package/docs/TYPESCRIPT.md +0 -123
- package/docs/VERCEL.md +0 -114
- package/docs/VERSION-ALIGNMENT.md +0 -80
- package/docs/YAML-GUIDE.md +0 -57
- package/docs/YAML-REFERENCE.md +0 -449
- package/docs/archive/2026-09-19/EXTENSION-IMPLEMENTATION.md +0 -68
- package/docs/archive/2026-09-19/MANAGEMENT-SECURITY.md +0 -102
- package/docs/archive/2026-09-19/NEXT-PHASE-PLAN.md +0 -108
- package/docs/archive/2026-09-19/NEXT-STEPS.md +0 -646
- package/docs/archive/2026-09-19/OPEN-DECISIONS.md +0 -277
- package/docs/archive/2026-09-19/RELEASE-SECURITY.md +0 -186
- package/docs/archive/2026-09-19/ROADMAP.md +0 -387
- package/docs/archive/2026-09-19/SPIKE-EXTENSION-MODEL.md +0 -430
- package/docs/archive/2026-09-19/SPIKE-EXTENSIONS.md +0 -492
- package/docs/archive/2026-09-19/SPIKE-LAMBDA-COMPILE.md +0 -365
- package/docs/archive/2026-09-19/SPIKE-MONOREPO.md +0 -778
- package/docs/archive/2026-09-19/USABILITY-REVIEW.md +0 -139
- package/docs/archive/README.md +0 -28
- package/docs/policies/agents.md +0 -182
- package/docs/policies/cache.md +0 -152
- package/docs/policies/compression.md +0 -169
- package/docs/policies/contract.md +0 -52
- package/docs/policies/hardened.md +0 -56
- package/docs/policies/interoperability.md +0 -169
- package/docs/policies/operations.md +0 -45
- package/docs/policies/security.md +0 -161
- package/docs/policies/throttle.md +0 -103
- package/docs/yaml/assets.md +0 -36
- package/docs/yaml/conditions.md +0 -20
- package/docs/yaml/functions.md +0 -168
- package/docs/yaml/middleware.md +0 -31
- package/docs/yaml/organization.md +0 -74
- package/docs/yaml/policies.md +0 -37
- package/docs/yaml/redirects.md +0 -64
- package/docs/yaml/responses.md +0 -57
- package/docs/yaml/site.md +0 -24
- package/packaging/claude-plugin/.claude-plugin/plugin.json +0 -19
- package/packaging/claude-plugin/skills/urlcode-authoring/SKILL.md +0 -120
- package/packaging/claude-plugin/skills/urlcode-operations/SKILL.md +0 -108
package/docs/TOOLING.md
DELETED
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
# Tooling SDK and local MCP
|
|
2
|
-
|
|
3
|
-
The tooling API consolidates authoring operations without starting a runtime:
|
|
4
|
-
|
|
5
|
-
- `inspectProject(project, {origin?, target?, offset?, limit?})` loads and
|
|
6
|
-
semantically compiles the project and returns route metadata, revision hash and
|
|
7
|
-
target compatibility. Route pages default to 100 entries, maximum 1,000.
|
|
8
|
-
Compatibility contains global `compatible`, `requirementCount` and `issueCount`
|
|
9
|
-
plus a separate `issues` page. Both arrays use the same zero-based `offset`
|
|
10
|
-
and `limit`, independently: an issue page is indexed over all compatibility
|
|
11
|
-
issues, not filtered to the route page. Compatibility includes `hasMore` for
|
|
12
|
-
its issue page. Empty pages never imply compatibility; the verdict and counts
|
|
13
|
-
always cover the entire project. Full requirement arrays are omitted because
|
|
14
|
-
route entries already contain their capability names.
|
|
15
|
-
- `validateProject(project, options)` returns the same compilation verdict and
|
|
16
|
-
compatibility verdict and global counts without route or issue pages.
|
|
17
|
-
`firstIssue` is the first issue across the whole project, or null; supplied
|
|
18
|
-
pagination settings do not change it. The low-level
|
|
19
|
-
`analyzeCompiledCapabilities` API still returns the complete report.
|
|
20
|
-
For unusually long route paths, request smaller pages to fit the MCP output
|
|
21
|
-
byte limit; page entry bounds do not override that transport limit.
|
|
22
|
-
- `explainRoute(project, path, options)` selects the route for a path and
|
|
23
|
-
describes its effective behavior from the compiled IR: methods, handler (with
|
|
24
|
-
its destination, module and export, file, extension or link collection),
|
|
25
|
-
the middleware chain in order, validated inputs (parameters and the request
|
|
26
|
-
body policy), the policies in effect with each compiled policy's inventory,
|
|
27
|
-
extension requirements, the cache outcome (the policy strategy, an explicit
|
|
28
|
-
header, an asset declaration, or the `no-store` the runtime forces on
|
|
29
|
-
extension, proxy and conditional routes), binding names (never values),
|
|
30
|
-
egress origins, response headers, capabilities and per-target support. A miss
|
|
31
|
-
returns `matched: false` with the nearest route patterns. With `extensions`
|
|
32
|
-
(a host file's registrations) each extension requirement also reports whether
|
|
33
|
-
a provider is registered, whether its revision pin matches and whether the
|
|
34
|
-
requirement satisfies the provider's policy schema; nothing is activated.
|
|
35
|
-
`explainProject(project, options)` returns every route the same way.
|
|
36
|
-
- `buildManifest(project, options)` returns the generated semantic manifest
|
|
37
|
-
described under [`urlcode manifest`](#explain-and-manifest).
|
|
38
|
-
- `getCapabilities(target?)` describes local implementation support and separate
|
|
39
|
-
deployment evidence.
|
|
40
|
-
- `getCapability(name)` returns one catalog entry: kind, summary, resolved schema
|
|
41
|
-
fragments, constraints, required operator grants, per-target support, refused
|
|
42
|
-
targets and the bundled recipes and cookbook routes that use it. Unknown names
|
|
43
|
-
throw a `ConfigError` listing the valid names.
|
|
44
|
-
- `getSchemaFragment(path)` returns only the fragment of
|
|
45
|
-
`schemas/urlcode.schema.json` for a dotted path (`route`, `redirect`,
|
|
46
|
-
`policies.cache`, `site.sitemap`) with local `$ref`s inlined; `schemaPathNames()`
|
|
47
|
-
lists the accepted top-level names. Both read bundled package data only.
|
|
48
|
-
- `previewImport(options)` and `previewExport(project, format, acknowledgment?)`
|
|
49
|
-
return conversion reports and candidate text, never writing files. Provider
|
|
50
|
-
semantic differences require the existing explicit acknowledgment and remain
|
|
51
|
-
non-lossless.
|
|
52
|
-
- `listRecipes()` and `showRecipe(name)` expose the fixed bundled recipe catalog.
|
|
53
|
-
- `inspectExtensions({project, hostFile?})` reports each operator-registered
|
|
54
|
-
extension's name, contract version, targets, credential headers, configuration
|
|
55
|
-
and policy JSON Schemas, whether the project declares it, whether its revision
|
|
56
|
-
pin matches and where routes mount or require it, plus the project's declared
|
|
57
|
-
names. With `hostFile` it executes that trusted operator module under the
|
|
58
|
-
`--host-file` rules (absolute path, outside the project) and releases it
|
|
59
|
-
afterwards; without one it lists declarations only. `describeExtensions(project,
|
|
60
|
-
registrations?)` produces the same report from registrations already in hand.
|
|
61
|
-
Neither activates an extension. See [EXTENSIONS.md](EXTENSIONS.md).
|
|
62
|
-
- `buildContext(project, {target?, hostFile?, budget?})` returns the compact
|
|
63
|
-
project context an authoring agent needs before it writes anything (see
|
|
64
|
-
below); `renderContext` produces the YAML rendering and `estimateTokens`
|
|
65
|
-
the characters-per-token estimate the budget uses.
|
|
66
|
-
|
|
67
|
-
## Project context
|
|
68
|
-
|
|
69
|
-
`urlcode context [--project DIR] [--target T] [--host-file F] [--budget N]
|
|
70
|
-
[--json] [--stats]` emits one deterministic YAML document (JSON with
|
|
71
|
-
`--json`) derived only from the compiled project and the capability catalog,
|
|
72
|
-
never from prose. It uses the same loader and semantic compiler as
|
|
73
|
-
`inspectProject`: no binding values, guest execution, environment reads or
|
|
74
|
-
network. Keys always appear in this order:
|
|
75
|
-
|
|
76
|
-
- `urlcode` (package version) and `schema` (`"1"`).
|
|
77
|
-
- `project`: entry file, route count, handlers used with counts, extensions
|
|
78
|
-
declared, policies in effect at the top level and the number of routes each
|
|
79
|
-
policy applies to, requested env and secret binding names,
|
|
80
|
-
`site` keys, and `files` (include, function and middleware paths). With
|
|
81
|
-
`--host-file`, `host` counts the operator module's extensions and plugins
|
|
82
|
-
without activating them.
|
|
83
|
-
- `routes`: path, methods and handler per route, sorted by path.
|
|
84
|
-
- `constraints`: a fixed list that holds for every project (network and Node
|
|
85
|
-
built-ins available to trusted code and withdrawn by `sandbox: true`, no
|
|
86
|
-
regex routes, one handler per route, exact or `{param}` path segments,
|
|
87
|
-
subtree mounts only for static and extension routes, no YAML interpolation,
|
|
88
|
-
injected `env`/`secrets` by operator grant only), each with a value and a
|
|
89
|
-
note spelling out how it differs between the two trust modes.
|
|
90
|
-
- `targets`: for each capability target (or the one `--target`), which of this
|
|
91
|
-
project's used features are supported, conditional, refused or unknown.
|
|
92
|
-
- `commands`: the exact `validate`, `test`, `audit --expect-routes N` (N is
|
|
93
|
-
the compiled route count), `routes` and `capabilities` invocations.
|
|
94
|
-
|
|
95
|
-
`--budget N` drops sections in a fixed order until the YAML rendering fits
|
|
96
|
-
the estimate: per-route detail, then `targets`, then the constraint notes
|
|
97
|
-
(keys and values stay), then `project.files`, then `commands`. The dropped
|
|
98
|
-
sections are listed under `omitted`. The estimate is `ceil(characters / 4)`;
|
|
99
|
-
there is no tokenizer dependency, so treat both numbers as approximate. A
|
|
100
|
-
budget the smallest rendering cannot meet is an error rather than an
|
|
101
|
-
overrun. `--stats` writes a JSON line to stderr comparing the estimated size
|
|
102
|
-
of the shipped documentation (`docs/*.md` and `llms.txt`) with the emitted
|
|
103
|
-
context, labeled `estimate: characters/4`. The MCP tool `get_context` takes
|
|
104
|
-
`target` and `budget` and returns the same object with `--project .` in the
|
|
105
|
-
commands; it never takes a host file or any other path.
|
|
106
|
-
|
|
107
|
-
Inspection reads declared configuration and function source graphs to validate
|
|
108
|
-
references and compute revision hashes. It compiles route and policy semantics
|
|
109
|
-
using dummy binding values. It never reads environment or dotenv credentials,
|
|
110
|
-
starts guest execution, follows network destinations, or opens operator link
|
|
111
|
-
stores. The result contains no raw compiled route, binding values or source text.
|
|
112
|
-
Inspection is not deployment readiness: missing operator grants, live service
|
|
113
|
-
availability, asset snapshot activation and provider behavior require their own
|
|
114
|
-
checks. Build output remains an explicit separate build API/CLI operation.
|
|
115
|
-
|
|
116
|
-
The package root also exports existing operator-invoked workflow APIs:
|
|
117
|
-
`buildCloudflare(project, options)` compiles and writes a Cloudflare artifact;
|
|
118
|
-
`buildStatic(project, options)` compiles redirects and static files into plain
|
|
119
|
-
objects and redirect metadata for S3 + CloudFront (see [static
|
|
120
|
-
hosting](STATIC.md)); `runProjectTests(project, options)` starts the local
|
|
121
|
-
runtime, executes request fixtures and closes it; `scaffoldProject(project,
|
|
122
|
-
{dryRun})` creates missing placeholders while preserving existing files;
|
|
123
|
-
`initProject(destination)` creates the standard starter; and
|
|
124
|
-
`addRedirect(project, destination, alias?)` updates project YAML under the
|
|
125
|
-
authoring lock. `CloudflareBuildOptions`, `CloudflareBuildReport`,
|
|
126
|
-
`StaticBuildOptions`, `StaticBuildReport`, `ProjectTestOptions`,
|
|
127
|
-
`ProjectTestResult`, `ScaffoldReport` and `ScaffoldUnresolved` describe these
|
|
128
|
-
existing operations.
|
|
129
|
-
|
|
130
|
-
These SDK functions have explicit write or execution effects and are available
|
|
131
|
-
to trusted callers only. Project tests use normal runtime activation, grants and
|
|
132
|
-
sandboxing; granted proxy/signal fixtures can perform real outbound operations.
|
|
133
|
-
Compilation and authoring write caller-selected destinations under each existing
|
|
134
|
-
helper's documented rules. They are **not** MCP tools. MCP remains limited to
|
|
135
|
-
the read-only operations below; adding a package-root export does not grant an
|
|
136
|
-
assistant file-write, guest-execution, deployment or network authority.
|
|
137
|
-
|
|
138
|
-
## Explain and manifest
|
|
139
|
-
|
|
140
|
-
`urlcode explain [/route] [--project DIR] [--target T] [--host-file F] [--json]`
|
|
141
|
-
prints what `explainRoute` returns: one route in detail, or without a path a
|
|
142
|
-
one-line-per-route table (methods, handler, state, execution mode, middleware
|
|
143
|
-
count, policies, cache outcome and target support). `--target` narrows the support columns to
|
|
144
|
-
one deployment target; `--host-file` supplies the operator registry so
|
|
145
|
-
extension requirements show their provider. An unknown route exits 1 and names
|
|
146
|
-
the nearest patterns. Everything comes from the compiled configuration: no
|
|
147
|
-
request is evaluated, no function runs and no binding is read.
|
|
148
|
-
|
|
149
|
-
`urlcode manifest [--project DIR] [--json]` emits the semantic manifest:
|
|
150
|
-
`schemaVersion`, the `urlcode` version, the entry file and its includes, the
|
|
151
|
-
`revision` (the same digest `inspectExtensionRevision` returns, so an operator
|
|
152
|
-
pin can be checked against it), the config `configVersion`, every route (path,
|
|
153
|
-
methods, handler, state, execution mode (`sandbox`, with `sandboxReason` when
|
|
154
|
-
the route declares one), middleware, inputs, policy names, extension
|
|
155
|
-
requirements, cache outcome, binding names, egress origins, capabilities and
|
|
156
|
-
per-target support), the union of capabilities used, extension declarations
|
|
157
|
-
(version, configuration keys, mounts and protected routes), recipe provenance
|
|
158
|
-
(from a `recipe.yaml` beside the entry file when one exists), external
|
|
159
|
-
requirements (environment and secret names, proxy and signal origins,
|
|
160
|
-
extensions), the function and middleware
|
|
161
|
-
modules with the routes that use them, and per-target compatibility. Without
|
|
162
|
-
`--json` a short summary prints. The manifest is deterministic: the same
|
|
163
|
-
project produces the same bytes. `urlcode build` writes the same document as
|
|
164
|
-
`manifest.json` beside its output, and `buildManifest` returns it from the SDK.
|
|
165
|
-
It is generated output, never a checked-in source of truth; regenerate it
|
|
166
|
-
rather than editing it.
|
|
167
|
-
|
|
168
|
-
`serveMcp({project, input?, output?, origin?, allowAuthoring?, hostFile?})` serves one
|
|
169
|
-
operator-selected root on stdio. Its tools are `inspect`, `validate`,
|
|
170
|
-
`capabilities`, `get_capability`, `get_schema`, `explain`, `get_manifest`,
|
|
171
|
-
`import_preview`, `export_preview`, `recipes_list`, `recipes_show`,
|
|
172
|
-
`search_recipes`, `search_examples` and `get_context`. When the operator starts
|
|
173
|
-
the server with `--host-file`, it loads that trusted module once for the session
|
|
174
|
-
and additionally advertises `get_extensions`, which returns the
|
|
175
|
-
`inspectExtensions` report; without the option the tool is absent and calls to
|
|
176
|
-
it are rejected. Tools accept no project/file/output path argument; recipe names
|
|
177
|
-
come from the fixed catalog, `get_capability` names from the capability catalog,
|
|
178
|
-
`get_schema` paths from the bundled schema, and the two searches match bundled
|
|
179
|
-
metadata locally (see [recipes](RECIPES.md)).
|
|
180
|
-
There is no shell, arbitrary file read, remote fetch, binding access, write or
|
|
181
|
-
route-execution tool without the explicit [authoring mode](#authoring-mode) flag. Configuration includes and module references retain the
|
|
182
|
-
runtime's existing root containment checks. Returned project and recipe content
|
|
183
|
-
is data, not trusted instructions for the consuming agent.
|
|
184
|
-
|
|
185
|
-
The server implements the MCP **2025-11-25** lifecycle and stdio framing. Clients
|
|
186
|
-
initialize, verify the returned protocol version, then send
|
|
187
|
-
`notifications/initialized` before tool operations. Other requested revisions
|
|
188
|
-
negotiate to this explicit supported version; a client that cannot support it
|
|
189
|
-
must disconnect. Newer lifecycle revisions are not claimed. Requests use UTF-8
|
|
190
|
-
newline-delimited JSON-RPC 2.0, with one request at a time and stream backpressure.
|
|
191
|
-
There is a 1 MiB input-frame and output-message limit; oversized input terminates
|
|
192
|
-
the session after a fixed error, and truncated/invalid frames return protocol
|
|
193
|
-
errors. Import text is additionally capped at 512 KiB. Tool schemas reject
|
|
194
|
-
unknown arguments. Tool operation errors are generic to avoid exposing local
|
|
195
|
-
source paths, credentials or configuration excerpts; inspect locally for details.
|
|
196
|
-
|
|
197
|
-
## Registering the server
|
|
198
|
-
|
|
199
|
-
`urlcode init` (and `init --with`) writes `.mcp.json` at the project root, the
|
|
200
|
-
shape Claude Code and Codex read:
|
|
201
|
-
|
|
202
|
-
```json
|
|
203
|
-
{ "mcpServers": { "urlcode": { "command": "urlcode", "args": ["mcp", "--project", "."] } } }
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
For an `init --with` site the file sits beside `host.mjs` and passes
|
|
207
|
-
`--project app`. An existing `.mcp.json` is never overwritten. The file registers
|
|
208
|
-
the read-only server only: `--allow-authoring` (and `--host-file`) are operator
|
|
209
|
-
choices added by hand, never by `init` or by an agent.
|
|
210
|
-
|
|
211
|
-
- **Claude Code** reads `.mcp.json` in the project directory as a project-scoped
|
|
212
|
-
server and asks for approval on first use. Without a global install, replace
|
|
213
|
-
`"command": "urlcode"` with `"node"` and prefix the arguments with
|
|
214
|
-
`node_modules/@jimhoyd/urlcode/dist/cli.js`.
|
|
215
|
-
- **Codex** reads the same `mcpServers` shape; alternatively register it in
|
|
216
|
-
`~/.codex/config.toml`:
|
|
217
|
-
|
|
218
|
-
```toml
|
|
219
|
-
[mcp_servers.urlcode]
|
|
220
|
-
command = "urlcode"
|
|
221
|
-
args = ["mcp", "--project", "."]
|
|
222
|
-
```
|
|
223
|
-
- **Any stdio client** spawns `urlcode mcp --project DIR` with the project as the
|
|
224
|
-
working directory, speaks newline-delimited JSON-RPC 2.0 over stdin/stdout,
|
|
225
|
-
and follows the 2025-11-25 lifecycle described above. Nothing listens on a
|
|
226
|
-
port; closing stdin ends the session.
|
|
227
|
-
|
|
228
|
-
The generated `AGENTS.md` and the packaged skill tell agents to prefer
|
|
229
|
-
`get_context`, `get_capability`, `get_schema`, `search_recipes`, `explain` and
|
|
230
|
-
`get_manifest` when the server is registered and to fall back to the matching
|
|
231
|
-
CLI commands otherwise.
|
|
232
|
-
|
|
233
|
-
## Authoring mode
|
|
234
|
-
|
|
235
|
-
`urlcode mcp --allow-authoring --project DIR` adds six tools to the fourteen read
|
|
236
|
-
tools above. The flag is honored from the operator's command line only: no
|
|
237
|
-
tool argument, environment variable or client capability enables it, and
|
|
238
|
-
without it the server is exactly the read-only server described above.
|
|
239
|
-
|
|
240
|
-
What it can do, all inside the selected project root (resolved with realpath):
|
|
241
|
-
|
|
242
|
-
- `create_route {path, handler, middleware?, file?}` adds one route to
|
|
243
|
-
`urlcode.yaml` or to an include listed in it. `handler` is a route object
|
|
244
|
-
(`{redirect: {...}}`, `{function: {...}}`, `{page: {...}}`, ...) or a short
|
|
245
|
-
form: an `http(s)://` URL becomes a redirect, a `.js`/`.mjs` path becomes a
|
|
246
|
-
function whose `{param}` path segments expand to required bounded string
|
|
247
|
-
parameters and matching `args`. `middleware` entries are sources or objects.
|
|
248
|
-
The merged project is checked before the write (schema, duplicate routes,
|
|
249
|
-
the `auth` short form, and the same reference compilation `urlcode add`
|
|
250
|
-
performs when every referenced source exists). The edit runs under the
|
|
251
|
-
authoring lock and replaces the file atomically. Missing sources are listed
|
|
252
|
-
in `missingSources` for `scaffold_feature`.
|
|
253
|
-
- `add_recipe {name, destination, dryRun?}` runs `recipes add` into a new
|
|
254
|
-
directory under the project. The parent must exist; an existing destination
|
|
255
|
-
is refused, never merged. `dryRun` reports the destination and writes nothing.
|
|
256
|
-
- `scaffold_feature {dryRun?}` runs `urlcode scaffold`: placeholder modules,
|
|
257
|
-
pages and directories for references the YAML makes and the disk lacks.
|
|
258
|
-
Existing files are preserved, never overwritten.
|
|
259
|
-
- `run_validate`, `run_test`, `run_audit` spawn `urlcode validate --local`,
|
|
260
|
-
`urlcode test` and `urlcode audit` against the project with a minimal
|
|
261
|
-
environment (`PATH` only), a two-minute deadline and stdout/stderr each capped
|
|
262
|
-
at 32 KiB. The result carries `exitCode`, `signal`, `stdout`, `stderr` and
|
|
263
|
-
`truncated`. `run_test` activates the local runtime and executes fixtures,
|
|
264
|
-
under the same rules as the CLI.
|
|
265
|
-
|
|
266
|
-
Every tool returns `validation`, the `validateProject` verdict of the project
|
|
267
|
-
after the operation (or `valid: false` with a generic note; use `run_validate`
|
|
268
|
-
for the CLI report).
|
|
269
|
-
|
|
270
|
-
What it cannot do:
|
|
271
|
-
|
|
272
|
-
- Write outside the project root. Paths are project-relative; absolute paths,
|
|
273
|
-
`..`, backslashes, drive letters, and any symlink on the walk are refused
|
|
274
|
-
before the write, and the recipe, scaffold and `urlcode add` paths keep their
|
|
275
|
-
own containment checks.
|
|
276
|
-
- Touch `.env*`, anything under `.git`, `node_modules`, `package.json`,
|
|
277
|
-
credential files (`.pem`, `.key`, `.p12`, `.pfx`), the authoring lock, or
|
|
278
|
-
operator files by name: `*policy*.json`, `*compliance*`, `host.mjs` /
|
|
279
|
-
`host-file.mjs` and link stores (`.sqlite`, `.db` and their WAL/SHM files).
|
|
280
|
-
Operator files belong outside the checkout in the first place.
|
|
281
|
-
- Create or change grants, read bindings or secret values, deploy, build, run
|
|
282
|
-
arbitrary commands, delete or edit existing files (except the one YAML file a
|
|
283
|
-
`create_route` targets), or serve a project other than the one the operator
|
|
284
|
-
selected.
|
|
285
|
-
|
|
286
|
-
Authoring mode is a local, unauthenticated stdio process for an operator who
|
|
287
|
-
already trusts the assistant to edit this checkout. Review the resulting diff
|
|
288
|
-
as you would any contributor's before running `serve` or deploying.
|
|
289
|
-
|
|
290
|
-
Only tools are advertised. Resources, prompts, subscriptions, sampling,
|
|
291
|
-
elicitation, HTTP transport, cancellation and durable tasks are not implemented.
|
|
292
|
-
Closing stdin ends the session after the current bounded operation. Existing
|
|
293
|
-
configuration-loader and semantic-compiler deadlines still apply. This local
|
|
294
|
-
process is not an authenticated remote service or an independent security review.
|
|
295
|
-
|
|
296
|
-
Protocol references: [MCP stdio transport](https://modelcontextprotocol.io/specification/2025-11-25/basic/transports),
|
|
297
|
-
[MCP lifecycle](https://modelcontextprotocol.io/specification/2025-11-25/basic/lifecycle),
|
|
298
|
-
and [MCP tools](https://modelcontextprotocol.io/specification/2025-11-25/server/tools).
|
package/docs/TUNNELS.md
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# Public tunnels for local development
|
|
2
|
-
|
|
3
|
-
A tunnel gives a project running on your machine a public HTTPS address, which
|
|
4
|
-
is what you need to test redirects from a phone, receive a provider's webhook,
|
|
5
|
-
complete an OAuth callback or show someone a work in progress.
|
|
6
|
-
|
|
7
|
-
URLCode has one requirement that matters here, and one warning.
|
|
8
|
-
|
|
9
|
-
## Always pass `--origin`
|
|
10
|
-
|
|
11
|
-
Forwarded headers are deliberately not trusted, so the runtime cannot infer its
|
|
12
|
-
public address. Without `--origin`, functions receive `http://127.0.0.1:3000/...`
|
|
13
|
-
as `request.url` even though the visitor arrived over HTTPS at a public host —
|
|
14
|
-
so anything built from the request URL is wrong: OAuth redirect URIs, absolute
|
|
15
|
-
links in generated HTML, canonical URLs, signature checks.
|
|
16
|
-
|
|
17
|
-
```sh
|
|
18
|
-
urlcode dev --project . --origin https://your-subdomain.ngrok-free.app
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
The startup record reports what was chosen, so you can confirm it:
|
|
22
|
-
|
|
23
|
-
```json
|
|
24
|
-
{"event":"listening","address":"127.0.0.1","port":3000,"mode":"dev","origin":"https://your-subdomain.ngrok-free.app"}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
`--origin` must be a bare HTTP(S) origin: no path, no credentials, no trailing
|
|
28
|
-
slash. It works with `serve` too, and behind a reverse proxy it is the same
|
|
29
|
-
mechanism.
|
|
30
|
-
|
|
31
|
-
## ngrok
|
|
32
|
-
|
|
33
|
-
Start the tunnel, then start URLCode with the origin it gave you:
|
|
34
|
-
|
|
35
|
-
```sh
|
|
36
|
-
ngrok http 3000
|
|
37
|
-
urlcode dev --project . --origin https://your-subdomain.ngrok-free.app
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Because that address changes on every restart of a free tunnel,
|
|
41
|
-
[`examples/tunnel/dev-with-ngrok.sh`](../examples/tunnel/dev-with-ngrok.sh)
|
|
42
|
-
reads it from the ngrok agent's local API and passes it for you:
|
|
43
|
-
|
|
44
|
-
```sh
|
|
45
|
-
ngrok http 3000 # terminal 1
|
|
46
|
-
PROJECT=. ./examples/tunnel/dev-with-ngrok.sh # terminal 2
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
It selects the HTTPS tunnel forwarding to your port and refuses to guess when
|
|
50
|
-
there is no match, so a second unrelated tunnel on the same agent cannot send
|
|
51
|
-
your traffic somewhere unexpected. `--print` shows the resolved origin without
|
|
52
|
-
starting anything. It discovers a tunnel; it does not start, stop or configure
|
|
53
|
-
ngrok, and it holds no ngrok credentials.
|
|
54
|
-
|
|
55
|
-
Other tunnels — Cloudflare Tunnel, Tailscale Funnel, localtunnel, an SSH remote
|
|
56
|
-
forward — work the same way: get the public origin, pass it to `--origin`.
|
|
57
|
-
|
|
58
|
-
## What you are exposing
|
|
59
|
-
|
|
60
|
-
A tunnel makes a development server reachable by anyone with the URL, including
|
|
61
|
-
scanners that find it within minutes.
|
|
62
|
-
|
|
63
|
-
- `dev` loads `.env.local` and watches files. Any secret in that file is
|
|
64
|
-
available to the functions you just published.
|
|
65
|
-
- The runtime has **no authentication and no rate limiting**. Put access control
|
|
66
|
-
in the tunnel: ngrok's OAuth, OIDC or basic auth; Cloudflare Access; a
|
|
67
|
-
Tailscale ACL.
|
|
68
|
-
- Prefer `serve` with a fixed snapshot, a project containing no real secrets,
|
|
69
|
-
and a tunnel you shut down when finished.
|
|
70
|
-
|
|
71
|
-
A tunnel is for development and demos. For a real deployment, terminate TLS at a
|
|
72
|
-
proxy you control and read [operations](OPERATIONS.md).
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
# Build-time TypeScript guests
|
|
2
|
-
|
|
3
|
-
TypeScript guest authoring is a separate build step. Serving still accepts only
|
|
4
|
-
JavaScript ES modules. The build never imports application modules into Node
|
|
5
|
-
or runs application code, and it is `sandbox`-aware per route
|
|
6
|
-
(docs/SPIKE-DEFAULT-TRUST-MODEL.md): a route that declares `sandbox: true` is
|
|
7
|
-
transpiled under the sandbox's own module rules (relative imports only, no
|
|
8
|
-
dynamic import/bare specifiers, the module/size limits below), exactly as
|
|
9
|
-
before; a trusted (non-`sandbox: true`) route is transpiled without those
|
|
10
|
-
import/size restrictions, since it will run with full Node access — bare/npm
|
|
11
|
-
imports, dynamic `import()`, `import.meta` — once served. Both modes still
|
|
12
|
-
diagnose only syntax, not semantics, and neither imports application code into
|
|
13
|
-
the build process in a way that executes it.
|
|
14
|
-
|
|
15
|
-
```sh
|
|
16
|
-
urlcode recipes add typescript --out ./hello-source
|
|
17
|
-
urlcode build-typescript --project ./hello-source --out ./hello-built --dry-run
|
|
18
|
-
urlcode build-typescript --project ./hello-source --out ./hello-built
|
|
19
|
-
urlcode validate --local --project ./hello-built
|
|
20
|
-
urlcode serve --project ./hello-built
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
The SDK equivalent is
|
|
24
|
-
`await buildTypeScriptProject(source, output, {dryRun: false})`. The report lists
|
|
25
|
-
emitted modules and files and explicitly returns `typeChecked: false`.
|
|
26
|
-
|
|
27
|
-
Point `function.source` or `middleware[].source` at a `.ts`, `.js` or `.mjs`
|
|
28
|
-
module. Use explicit relative extensions in imports, such as
|
|
29
|
-
`import {message} from './message.ts'`. The build emits `.ts` as `.js` and
|
|
30
|
-
rewrites the runtime imports and YAML source references. Existing JavaScript
|
|
31
|
-
modules are preserved. Output name collisions, including case-only collisions,
|
|
32
|
-
are refused for portability. Source `.d.ts` entries are not executable modules.
|
|
33
|
-
The runtime's existing handling of relative imports/re-exports applies to the
|
|
34
|
-
emitted graph; unsupported re-export forms remain refused.
|
|
35
|
-
|
|
36
|
-
The trusted pinned TypeScript compiler transpiles ES2022/ES modules with fixed
|
|
37
|
-
settings. It does not read `tsconfig.json`, package scripts, plugins, compiler
|
|
38
|
-
transformers, dependency packages, Node declarations or ambient environment
|
|
39
|
-
files. It diagnoses syntax errors, but does **not** perform semantic type
|
|
40
|
-
checking, in either mode. CommonJS import/export syntax and imports outside
|
|
41
|
-
the project are always refused. Type-only relative imports are erased without
|
|
42
|
-
reading their targets.
|
|
43
|
-
|
|
44
|
-
For a `sandbox: true` route, bare/npm imports (including static type-only
|
|
45
|
-
imports), dynamic runtime imports, `import.meta` and import attributes are
|
|
46
|
-
refused, and the source graph is limited to 128 modules, 1 MiB per source and
|
|
47
|
-
4 MiB aggregate; the emitted graph must also pass the runtime's own sandboxed
|
|
48
|
-
source parser and byte limits before publication. For a trusted route, none of
|
|
49
|
-
that applies: bare/npm specifiers, dynamic `import()`, `import.meta` and
|
|
50
|
-
import attributes pass through unchanged (resolved by Node at serve time, not
|
|
51
|
-
by this build), and there is no module-count or aggregate-size ceiling — only
|
|
52
|
-
a generous 16 MiB per-source read cap that bounds authoring-time memory. A
|
|
53
|
-
module may be shared by trusted and sandboxed routes: it is emitted once, and
|
|
54
|
-
every module reachable from a `sandbox: true` route is still validated under
|
|
55
|
-
the sandbox rules and budgets above, which does not disqualify the trusted
|
|
56
|
-
route that also imports it. In both modes,
|
|
57
|
-
no import extension inference occurs — relative imports of project modules
|
|
58
|
-
still need an explicit `.ts`/`.js`/`.mjs` extension to be rewritten and
|
|
59
|
-
followed. This does not execute the modules or replace normal route, policy,
|
|
60
|
-
binding or sandbox validation at activation. Unsupported host/browser APIs
|
|
61
|
-
remain unavailable in QuickJS, even if TypeScript accepts their names. Run
|
|
62
|
-
`urlcode validate --local` and project tests on the output.
|
|
63
|
-
|
|
64
|
-
Includes are flattened into a duplicate-checked entry document. Only referenced
|
|
65
|
-
modules, page/download assets, static trees, site favicon/llms files and the
|
|
66
|
-
`tests/requests.json` fixtures (when present) are snapshotted. Unreferenced files, dotenv, hidden files, package manifests and
|
|
67
|
-
credential extensions are not copied. An explicit reference to a forbidden file
|
|
68
|
-
fails rather than silently excluding it. Asset limits are 16 MiB per file,
|
|
69
|
-
64 MiB aggregate and 10,000 output files. Empty static directories are refused;
|
|
70
|
-
add an asset before building. Paths have at most 32 segments and 1,024 characters;
|
|
71
|
-
symlinked source files/directories and multiply linked files are refused.
|
|
72
|
-
The input project and output parent must be stable and controlled by the caller
|
|
73
|
-
while building; this is not a hardened service for concurrent hostile writers.
|
|
74
|
-
|
|
75
|
-
Output must be a new directory whose parent already exists. Dependencies are
|
|
76
|
-
written before an atomic rename publishes the complete entry YAML; existing
|
|
77
|
-
outputs are never overwritten. Failed builds remove their newly created output.
|
|
78
|
-
Dry-run still transpiles and validates an isolated temporary snapshot, then
|
|
79
|
-
removes it; it never writes the requested output. Configuration parsing keeps
|
|
80
|
-
the loader's worker limits; transpilation runs in the authoring process and is
|
|
81
|
-
not a sandboxed multi-tenant compilation service.
|
|
82
|
-
|
|
83
|
-
Create operator grants against the **built** configuration/code revision.
|
|
84
|
-
Transpilation and flattened includes change the snapshot digest, so source
|
|
85
|
-
project grants must not be reused. External capabilities remain denied without
|
|
86
|
-
an exact revision-pinned operator policy. The build never resolves bindings or
|
|
87
|
-
copies credentials; it preserves logical binding declarations only.
|
package/docs/TYPESCRIPT.md
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
# Using URLCode from TypeScript
|
|
2
|
-
|
|
3
|
-
The runtime is written in TypeScript and the published package ships
|
|
4
|
-
declarations for every export, so an operator application, a plugin, an
|
|
5
|
-
observer, a compliance rules module or a build script can be type-checked
|
|
6
|
-
against the same contract the runtime enforces at load time. Nothing in the
|
|
7
|
-
project format changes: YAML and sandboxed functions are unaffected, and a
|
|
8
|
-
JavaScript application keeps working exactly as before.
|
|
9
|
-
|
|
10
|
-
## What ships
|
|
11
|
-
|
|
12
|
-
The tarball contains `dist/`: one `.js` per runtime module, `dist/types/*.d.ts`
|
|
13
|
-
beside them, and `dist/BUILD-MANIFEST.json` with a SHA-256 per emitted file.
|
|
14
|
-
`package.json` resolves every subpath through export conditions:
|
|
15
|
-
|
|
16
|
-
| Import | Runtime | Declarations |
|
|
17
|
-
|---|---|---|
|
|
18
|
-
| `urlcode` | `dist/index.js` | `dist/types/index.d.ts` |
|
|
19
|
-
| `@jimhoyd/urlcode/plugins`, `@jimhoyd/urlcode/policies`, `@jimhoyd/urlcode/observability`, `@jimhoyd/urlcode/compliance`, `@jimhoyd/urlcode/prerender`, `@jimhoyd/urlcode/extensions`, `@jimhoyd/urlcode/sandbox` | `dist/<name>.js` | `dist/types/<name>.d.ts` |
|
|
20
|
-
| `@jimhoyd/urlcode/aws`, `@jimhoyd/urlcode/vercel`, `@jimhoyd/urlcode/cloudflare` | `dist/<name>.js` | `dist/types/<name>.d.ts` |
|
|
21
|
-
| `@jimhoyd/urlcode/schema` | `schemas/urlcode.schema.json` | — |
|
|
22
|
-
|
|
23
|
-
Each entry has three conditions: `types` (the declarations), `default` (the
|
|
24
|
-
built JavaScript) and `development`, which points at the `.ts` source and
|
|
25
|
-
exists only so the repository's own tests and examples can import the package
|
|
26
|
-
by name without a build (`node --conditions=development`). An installed
|
|
27
|
-
package never uses it; Node refuses to strip types under `node_modules`.
|
|
28
|
-
|
|
29
|
-
Use `"module": "NodeNext"` (or `"bundler"`) resolution so the `exports` map
|
|
30
|
-
and its `types` condition apply. The declarations reference Node's types
|
|
31
|
-
(`Buffer`, `node:http`, `NodeJS.Timeout`), so a consumer needs `@types/node`,
|
|
32
|
-
as any Node application already has. The package smoke test installs the
|
|
33
|
-
packed tarball and type-checks a consumer that imports every subpath, so a
|
|
34
|
-
release cannot ship a declaration that does not resolve.
|
|
35
|
-
|
|
36
|
-
## The main exported types
|
|
37
|
-
|
|
38
|
-
- `urlcode`: `Runtime`, `RuntimeOptions`, `RuntimeRequest`, `RequestTrace`,
|
|
39
|
-
`Server`, `ServerOptions`, `HostPlugin`, `Observer`, `TestPlan`.
|
|
40
|
-
- `@jimhoyd/urlcode/plugins`: `Plugin`, `PluginRuntime`, `PolicyRequest`,
|
|
41
|
-
`HandlerResult`, `HeaderPair`, `TargetName`. See [plugins](PLUGINS.md).
|
|
42
|
-
- `@jimhoyd/urlcode/policies`: `PolicyModule`, `PolicyRegistry`, `PolicyRequest`,
|
|
43
|
-
`PolicyContext`, `PolicyChain`, `PolicyShared`. See [policies](POLICIES.md).
|
|
44
|
-
- `@jimhoyd/urlcode/observability`: `Observer`, `ObserverEvent`, `MetricsSnapshot`,
|
|
45
|
-
`Metrics`, `RecordContext`. See [observability](OBSERVABILITY.md).
|
|
46
|
-
- `@jimhoyd/urlcode/compliance`: `ComplianceRule`, `ProjectRule`, `RouteRule`,
|
|
47
|
-
`ProjectContext`, `RouteContext`, `RawFinding`, `Finding`,
|
|
48
|
-
`ComplianceOptions`, `ComplianceReport`, `ComplianceProfileName`. See
|
|
49
|
-
[compliance](COMPLIANCE.md).
|
|
50
|
-
- `@jimhoyd/urlcode/prerender`: `PrerenderOptions`, `PrerenderedPage`,
|
|
51
|
-
`NativeProjectOptions`. See [prerendering](PRERENDER.md).
|
|
52
|
-
- `@jimhoyd/urlcode/aws`, `@jimhoyd/urlcode/vercel`, `@jimhoyd/urlcode/cloudflare`: `LambdaEvent`,
|
|
53
|
-
`LambdaHandler`, `LambdaHandlerOptions`; `VercelHandler`,
|
|
54
|
-
`VercelHandlerOptions`; `Artifact`, `WorkerRoute`, `Validators`.
|
|
55
|
-
- `@jimhoyd/urlcode/sandbox`: `SandboxPool`, `SandboxEntry`, `SandboxTarget`,
|
|
56
|
-
`SandboxInvocation`, `SandboxPoolOptions`, `functionFile`. The public
|
|
57
|
-
sandboxed-execution primitive: the same QuickJS/worker-thread engine that
|
|
58
|
-
already backs a `sandbox: true` `function`/`middleware` route
|
|
59
|
-
(`FunctionPool`, internally), generalized to an explicit list of
|
|
60
|
-
`{source, export}` entries instead of anything route/YAML-shaped, for an
|
|
61
|
-
extension package that needs to run a project-supplied hook through real
|
|
62
|
-
isolation when the project's own config declares `sandbox: true` on it
|
|
63
|
-
(see [EXTENSIONS.md](EXTENSIONS.md#project-level-lifecycle-hooks) and
|
|
64
|
-
[FUNCTION-SECURITY.md](FUNCTION-SECURITY.md)). There is no trusted-mode
|
|
65
|
-
export here: a hook that does not declare `sandbox: true` is ordinary
|
|
66
|
-
project code the extension `import()`s directly via
|
|
67
|
-
`ExtensionActivation.root`, no primitive required.
|
|
68
|
-
|
|
69
|
-
```ts
|
|
70
|
-
import { SandboxPool, functionFile } from '@jimhoyd/urlcode/sandbox';
|
|
71
|
-
|
|
72
|
-
const source = await functionFile(root, hookConfig.source); // root: ExtensionActivation.root
|
|
73
|
-
const entries = [{ source, export: hookConfig.export ?? 'default' }];
|
|
74
|
-
const pool = await new SandboxPool(entries, { root, workers: 1 }).start();
|
|
75
|
-
const result = await pool.execute({ entry: entries[0] }, request, context, undefined);
|
|
76
|
-
await pool.close();
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
```ts
|
|
80
|
-
import { startServer, type ServerOptions, type Observer } from '@jimhoyd/urlcode';
|
|
81
|
-
import type { Plugin } from '@jimhoyd/urlcode/plugins';
|
|
82
|
-
|
|
83
|
-
const audit: Plugin = { name: 'audit', version: '1.0.0', targets: ['node'], onError(request, error) { console.error(request.route, error); } };
|
|
84
|
-
const forwarder: Observer = { name: 'forwarder', version: '1.0.0', onEvent(event) { queue.push(event); } };
|
|
85
|
-
const options: ServerOptions = { project: './site', port: 3000, plugins: [audit], observers: [forwarder], metrics: true };
|
|
86
|
-
const server = await startServer(options);
|
|
87
|
-
await server.close();
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## How `dist/` is built, and why it is the same JavaScript
|
|
91
|
-
|
|
92
|
-
`npm run build` (`scripts/build.ts`) runs Node's own type stripping over every
|
|
93
|
-
`src/*.ts`, the same transform that runs the source in development, and
|
|
94
|
-
rewrites relative specifiers from `.ts` to `.js`. It does not bundle, minify,
|
|
95
|
-
down-level or transform syntax, and it refuses to emit a file whose line count
|
|
96
|
-
differs from its source, so every line and column of `dist/x.js` is the
|
|
97
|
-
corresponding line of `src/x.ts` with types turned into whitespace. The
|
|
98
|
-
`.d.ts` files come from `tsc` and never touch runtime output; the build fails
|
|
99
|
-
on any type error. `dist` is never committed: the release workflow builds it
|
|
100
|
-
in the digest-pinned container, records the Node and TypeScript versions and
|
|
101
|
-
the per-file hashes in the signed manifest, and CI's `build-fidelity` job
|
|
102
|
-
builds twice and diffs the trees. See [release security](RELEASE-SECURITY.md).
|
|
103
|
-
|
|
104
|
-
## No runtime cost
|
|
105
|
-
|
|
106
|
-
Because the shipped JavaScript is the stripped source, the package runs what
|
|
107
|
-
it ran before the conversion. The measurement in
|
|
108
|
-
[performance](PERFORMANCE.md#typescript-conversion-2026-09-17) compared the
|
|
109
|
-
last plain-JavaScript commit with `dist/` on the same machine: CLI cold start,
|
|
110
|
-
routing throughput, p95 latency and RSS are within run-to-run spread. Running
|
|
111
|
-
the `.ts` source directly, as `npm run dev` does in a clone, costs about
|
|
112
|
-
190 ms of cold start and 35 MiB for the stripping itself; that mode is the
|
|
113
|
-
developer loop and never ships.
|
|
114
|
-
|
|
115
|
-
## Contributing in TypeScript
|
|
116
|
-
|
|
117
|
-
The source, scripts, tests and benchmarks are checked by `npm run typecheck`
|
|
118
|
-
(strict, `noUncheckedIndexedAccess`, `exactOptionalPropertyTypes`,
|
|
119
|
-
`erasableSyntaxOnly`), which `npm run verify` runs. Only erasable syntax is
|
|
120
|
-
allowed, so no enums, namespaces or parameter properties: what Node can strip
|
|
121
|
-
is exactly what the build emits. Contributors need Node 22.18+ to run the
|
|
122
|
-
source; installed packages still run on 22.13+. See
|
|
123
|
-
[local development](LOCAL-DEVELOPMENT.md).
|