@netscript/cli@0.0.10Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
The NetScript command surface: scaffold a workspace, then grow it — contracts, services, databases, plugins, Fresh UI, deployment — with verbs that regenerate the derived wiring for you.
@netscript/cli
The NetScript command surface: scaffold a workspace, then grow it — contracts, services, databases, plugins, Fresh UI, deployment — with verbs that regenerate the derived wiring for you.
Most scaffolds hand you a starting point and walk away; from then on, every added service or plugin
means hand-editing orchestration files. The netscript binary works the other way around. init
lays down a complete, running backend workspace — contracts, an example oRPC service, a
Prisma-backed database, the Fresh app, and the Aspire orchestration host — and every later verb that
changes the workspace's shape regenerates what is derived from it: the AppHost helpers, the plugin
registries, the contract version aggregates. You never hand-maintain the wiring.
The same command tree is also a library: mount the full public surface inside your own binary while NetScript owns the verbs and you own the process boundary.
Why teams use it
- Scaffold-and-grow, not scaffold-and-diverge —
initwrites the workspace, and every later verb keeps the derived wiring in sync; the generated project is meant to be re-generated, not forked. - See the blast radius first —
netscript init my-app --dry-runprints every file it would write (183 files for a full postgres + service workspace) without touching the disk. - Embeddable command tree —
createPublicCli(host)returns the full public surface against a host port, so your binary owns argv, exit codes, and permissions while NetScript owns the verbs. - Plugin verbs by dispatch —
dispatchPluginVerbroutes the framework-owned verbs (install,sync,doctor, …) into a plugin's own published CLI, so a plugin implements its verbs once and inherits the command surface. - Deterministic testing surface —
./testingsupplies in-memory filesystem, process, prompt, and logger ports plus fixture builders, so CLI and scaffold flows are tested without disk or subprocesses. - Agent tooling in one command —
netscript agent initinstalls the MCP server configuration and the matching skills into Claude Code and VS Code. - Native desktop packaging —
deploy desktop packagebuilds Deno Desktop installers per OS, anddeploy desktop release prepare/servesign and host native update manifests and patches.
Architecture
flowchart LR V["netscript verbs<br/>init · contract · service · db · plugin · ui:* · agent"] --> W["Workspace<br/>(your source of truth)"] W --> G["generate<br/>(derived wiring)"] G --> D1["AppHost helpers"] G --> D2["Plugin registries"] G --> D3["Contract aggregates"] V2["deploy <target> <op>"] --> T["Target adapters<br/>bare metal · deno-deploy · Aspire clouds · cloud-run · desktop"]
Install
deno install --global --allow-all --name netscript --minimum-dependency-age=0 jsr:@netscript/cli@<version>
Or as a library, for the embeddable command tree:
deno add jsr:@netscript/cli@<version>
Pin <version> to the release you want to install; bare jsr:@netscript/* specifiers do not
resolve on the pre-release line.
Quick example
One command lays down a complete, running backend workspace:
netscript init my-app --db postgres --service --yes cd my-app netscript db migrate # evolve the schema netscript service add --name orders # add another service + its v1 contract netscript plugin install worker --name workers # durable background processing
Prefer to see the plan first? --dry-run prints it and writes nothing:
$ netscript init my-app --db postgres --service --yes --dry-run ✓ Project root (deno.json, netscript.config.ts, .gitignore, README.md) ✓ Aspire orchestration (TypeScript AppHost, .helpers/, package.json) ✓ Database workspace (postgres) ✓ Frontend app "dashboard" (Fresh framework) ✓ Contracts (v1 with users stub) ✓ Example service "users" (oRPC handler on port 3000) ✓ Plugins (empty registry) [dry-run] Would create 183 files, 44 directories
Northwind showcase
Opt in to a complete commerce example while keeping the ordinary init output unchanged:
netscript init northwind --from showcase --ci --yes cd northwind deno task showcase:setup deno task aspire:start
The setup task installs the standard plugins and UI components, generates their wiring, and seeds
40 orders with customers, products and line items. Follow an order through worker fulfilment,
the order/payment/shipping saga and delivery webhook, then read its committed activity stream.
The generated showcase/README.md documents the recipe and extension points.
The Assistant uses durable private conversations and read-only order MCP tools. Without a model credential it renders provider setup. Real model and OAuth/OIDC credentials are external prerequisites for signed-in chat; CI uses a stub provider. Private chat currently requires a POSIX host for credential-file permissions. SQLite uses the local Garnet fallback when Docker is absent; PostgreSQL requires Docker. Deno 2.9.8 and the pinned Aspire/.NET toolchain are required.
Managed Garnet durability
Set a Garnet cache entry's DataPath to retain queued work across restarts. Generated Container,
Executable and Auto launches enable AOF recovery and wait for each write's log flush before
acknowledging it. This adds disk latency. Containers keep log and checkpoint files under the
mounted /data; executables use the resolved DataPath for both.
Without DataPath, managed Garnet remains ephemeral and loses its contents on restart. Durable mode
uses the FileStream storage tier for portable checkpoint I/O. Native SAVE/BGSAVE checkpoints
compact retained AOF history; keep the data directory when replacing a container. See
KV, queues & cron
for configuration.
Command map
| Group | What it owns |
|---|---|
init |
Scaffold a new workspace (--db, --service, --no-aspire, --dry-run). |
contract |
add, add-route, version, inspect, list, remove — the typed oRPC contract surface. |
service |
add, add-handler, ref, set, list, remove, generate — service workspaces and their orchestration registration. |
db |
add, init, migrate, generate, seed, status, studio, introspect, reset, deploy — Prisma lifecycle. |
plugin |
new, scaffold, install, remove, sync, update, doctor, list, info, ai, auth — first- and third-party plugins. |
ui:* |
ui:init, ui:add, ui:apply, discovery, registry/preset management, ui:build and ui:migrate variants — app-owned Fresh UI copies and tokens. |
tokens |
init, build, clean — app-owned DTCG sources and generated Fresh UI assets, selected with --app or --project-root. |
generate |
aspire, plugins, runtime-schemas — regenerate derived artifacts on demand. |
config |
inspect, get, set, override, runtime — resolved configuration and runtime overrides. |
agent |
init, mcp — install and run the agent tooling. |
deploy |
Bare-metal, Deno Deploy, Kubernetes, Azure, Cloud Run, and native desktop targets (see below). |
marketplace |
search, publish — plugin discovery and distribution. |
netscript <group> --help prints the live tree for any group; it is generated from the same command
definitions this package exports, so it never drifts from the binary you installed.
ui:update @acme/<collection> reads that namespace's registry catalog and updates the
collection members already recorded in the app's lockfile. It preserves locally edited copies
and leaves uninstalled members uninstalled. An unknown collection or one with no installed
members produces a diagnostic before writing files. A directly named installed item updates
without requiring a catalog request.
Regenerate service clients
netscript service generate reconciles every manifest service into the generator-owned module
apps/<app>/lib/<service>.ts and regenerates Aspire helpers in the same command. Client modules use
the query-factory L1/L2 dialect: factory keys are service-scoped and the generated list invalidation
filter comes from <service>Queries.list.clientKey().
The command validates every manifest entry before writing anything. Each service must have
contracts/versions/v1/<service>.contract.ts exporting <PascalService>ContractV1; otherwise the
error names the service and expected path/export, and neither client modules nor Aspire helpers are
written. Disabled entries (Enabled: false) still receive owned client modules so generation is a
deterministic projection of the whole manifest.
Generated modules are reconciled rather than treated as user-owned: missing or differing content is
written without --force, identical content is skipped, and --force rewrites even identical
outputs. --dry-run reports the complete client-and-Aspire plan without writes. Both flags govern
the whole command, including Aspire helpers.
If a project was scaffolded before this per-service wiring, run netscript service generate after
updating the CLI. Regeneration replaces the fixed example names with service-derived symbols:
exampleServiceName, exampleServiceRouterName, exampleServiceContract,
exampleServiceListInvalidation, exampleServiceClient, and exampleServiceQueries become
<service>Name, <service>RouterName, <service>Contract, <service>ListInvalidation,
<service>Client, and <service>Queries. It also changes the query-key namespace from the literal
service resource to the service's camel-case identity. Update imports of the six old symbols;
persisted cache entries under the old namespace are orphaned and may be cleared. Projects that do
not regenerate keep their existing generated code unchanged.
Plugin source truth
plugin list and plugin doctor distinguish explicit filesystem installs from package-backed
installs. Relative, absolute, and file: plugin specifiers opt into a local-workdir contract;
package and import-map specifiers use their published manifest and do not require a copied
plugins/<name> directory. If both a package specifier and an incidental directory exist, the
configured package wins. Configure an explicit filesystem specifier when local-workdir behaviour is
intended.
Configured-module inspection uses a frozen scratch copy of the consumer's deno.lock (including a
custom string or object lock.path) with the original project configuration. Explicit custom paths
outside the project remain supported; linked input components are rejected. Prepare dependencies and
the lock with netscript generate plugins before running doctor. Missing, disabled, malformed, or
incomplete locks fail closed with preparation guidance; doctor does not resolve an unlocked
replacement or install packages into the project. The child retains its three-second deadline and
read/environment/network grants, denies writes and subprocesses, and its scratch lock is removed
after the child settles, including on failure. This policy is separate from agent MCP startup below.
Published manifest permissions feed the generated runtime configuration. An explicit appsettings permission list still wins, followed by contribution-specific permissions, plugin-wide manifest permissions, and finally global defaults. Doctor warns when an explicit override differs from the published default so that the effective runtime choice stays visible.
Agent tooling
NetScript's agentic surface is one triple: the CLI is the hands, the skills are the playbook, and MCP is the eyes. Install all three into a project root:
netscript agent init # Opt in to the several-megabyte offline prose + exact installed-version API corpus. netscript agent init --with-docs
Claude Code receives .mcp.json, the NetScript skill bundle, and a marked section in AGENTS.md;
VS Code receives .vscode/mcp.json, and Zed receives context_servers in .zed/settings.json.
Apply or re-apply editor setup to any existing project with --editor none|zed|vscode; when
omitted, a single existing .zed or .vscode directory selects the target. Unsupported editors
fail with the supported list and may use --editor none plus a manual MCP configuration. Agent
hosts remain selectable with --host claude|vscode|all. The installed server entry runs
netscript agent mcp (@netscript/mcp); its data boundary covers
telemetry, project metadata, generated registries, and public docs — never project source,
environment values, credentials, or secrets. The generated Deno invocation disables consumer lock
discovery for both the server and its diagnostic child processes, so starting or using MCP leaves
the application's deno.lock byte-identical.
--with-docs is deliberately opt-in because it expands to several megabytes. It installs the
release task router/prose and generates API text for every export subpath of the exact NetScript
package versions present in the project; a version mismatch aborts rather than writing stale docs.
Deployment
netscript deploy <target> <op> is a thin router over target adapters implementing the canonical
plan / emit / up / down / status / logs operations; a target never advertises a verb it
cannot honour.
| Target | Mechanism |
|---|---|
| bare metal | deno compile → single binary managed as an OS service: Servy on Windows, systemd on Linux. |
deno-deploy |
deno deploy [--prod], with a guard that refuses a --prod push when the project uses APIs Deno Deploy rejects. |
kubernetes, azure-aca, azure-app-service, azure-aks |
Validates the generated AppHost declares the matching hosting integration, then delegates to aspire publish / deploy. |
cloud-run |
Docker-image lane: docker build → docker push → gcloud run deploy. |
desktop |
package builds native Deno Desktop installers; release prepare/serve sign and host native updates (see below). |
Cloud authentication and RBAC stay operator-owned: NetScript mints no credentials and hand-authors
no Helm, Bicep, or Kubernetes manifests. Compiled binaries are unsigned — signing is a deliberate
manual hook between deploy build and deploy install.
Packaged installation service identity
The existing Servy packaging lane provisions the internal service credential on the target:
netscript deploy build netscript deploy copy --install-dir <target-directory> netscript deploy install --install-dir <target-directory> netscript deploy start --install-dir <target-directory>
deploy install creates or validates .data/aspire-secrets/installation.secret under the target
directory before registering services. It reuses the file on subsequent installs and preserves it
when artifacts are copied again; .data/ is never copied from the build host. Move the installation
with its .data/ directory and reinstall to relocate the service definitions without changing its
identity. An invalid or unreadable existing secret aborts registration rather than replacing it.
Services, plugin APIs, workers, sagas, and triggers receive NETSCRIPT_INSTALLATION_SECRET_FILE
pointing to ../.data/aspire-secrets/installation.secret from their bin/ working directory.
Compilation preserves declared permissions and adds only that read path and environment key. Apps
receive no installation credential reference or additional credential permissions. Keep backend
working directories at bin/; changing them also changes the meaning of the scoped read grant. The
file contents stay out of service definitions, process arguments, and environment variables.
The provisioning primitive requires owner-only mode 0700 for the directory and 0600 for the file
on POSIX. On Windows the bootstrap replaces inherited and explicit DACL grants: the installing
identity and SYSTEM receive full control, and configured service accounts receive read access.
Installation must run as the credential owner. Native Windows ACL behavior and Servy startup still
require separate platform qualification; the focused tests exercise the policy through the process
port and execute a relocated native binary on the test host.
Compose service authentication and SDK callers as described in the internal procedure recipe. For rotation, stop all backends, replace only the secret file with fresh cryptographically random text (32–4096 bytes), preserve its restrictions, and restart every backend and its SDK clients. Workers use this installation identity independently of any browser, phone app, or user session.
Native desktop packaging
An enabled app with Type: "desktop" in the workspace config packages through its configured task
hook:
{ "Type": "desktop", "Enabled": true, "Workdir": "apps/storefront", "PackageTaskName": "desktop:package" }
The task owns the desktop entrypoint and permissions; NetScript appends the native Deno flags:
netscript deploy desktop package --app storefront --all-targets \ --format app --format appimage --format deb --format rpm --format msi netscript deploy desktop package --app storefront \ --target x86_64-unknown-linux-gnu --format appimage --format deb
Every invocation uses an explicit target and output path. Omitted formats produce all formats for
the selected OS: .app/.dmg on macOS, .AppImage/.deb/.rpm on Linux, and .msi on Windows.
Runtime compression defaults to xz; select --compression none|lzma|zstd explicitly when needed
(zstd requires the external zstd executable). The .dmg format requires a macOS host, and an
unfiltered --all-targets includes .dmg — run that complete matrix on macOS, or use repeatable
--format filters elsewhere while still cross-compiling the remaining targets.
Native installers are unsigned at this stage. Platform signing is separate from the Ed25519 update-manifest signature and stays an external CI step between packaging and release preparation:
- Windows — Authenticode-sign the
.msiwithsigntool(SHA-256 timestamp authority), then verify on a clean Windows runner. - macOS — codesign the
.appand nested code with a Developer ID identity, sign or create the.dmg, notarize with Apple's notary service, and staple/validate the ticket. - Linux — apply your repository/distribution signing policy to
.deband.rpm; AppImage signing is likewise an external release-policy step.
The CLI intentionally accepts no certificate credentials and never invokes those platform tools.
Prepare a native update once CI has retained the current and previous runtime libraries:
netscript deploy desktop release prepare \ --channel stable --target linux-x86_64 \ --version 1.2.0 --sequence 42 \ --current-runtime dist/1.2.0/libdenort.so \ --from 1.1.0=dist/1.1.0/libdenort.so \ --private-key-file .secrets/update-ed25519.pem
Preparation needs read access to the runtime libraries and the PKCS#8 Ed25519 private key, write
access to .deploy/desktop/releases, and run access to an external bsdiff 4.x-compatible
executable; the key never leaves the authoring process. Each channel/target route keeps private,
strictly monotonic sequence state — a failed final manifest replacement burns that sequence, so
retry with a higher number. Immutable patches are written first, the private high-water second, and
latest.json last.
Serve the prepared tree at the same pathname the SDK release base URL composes:
netscript deploy desktop release serve \ --release-dir .deploy/desktop/releases \ --hostname 127.0.0.1 --port 8787 --base-path /application
For baseUrl: "https://releases.example.com/application", the native manifest resolves to
/application/<channel>/<os>-<arch>/latest.json. Terminate public HTTPS at a trusted reverse proxy;
the built-in listener is transport-neutral and intended for a protected origin. It serves only
GET/HEAD allowlisted manifests, patches, and installers — private high-water files, dot paths,
traversal, encoded separators, and symlink escapes are never served.
Windows native apply remains unsupported upstream, so applications handle the SDK seam's
applyMode: "manual" update-ready event and present its trusted manualUpdateUrl (this server may
host the installer, but it does not claim automatic Windows replacement):
import { startAutoUpdate } from '@netscript/sdk/auto-update'; startAutoUpdate({ release: { baseUrl: 'https://releases.example.com/application', publicKey: 'base64-ed25519-public-key', manualUpdateUrl: 'https://releases.example.com/application/windows-installer', }, policy: { checkOnLaunch: true }, onUpdateReady(event) { if (event.applyMode === 'manual') showInstallerPrompt(event.manualUpdateUrl); }, }); declare function showInstallerPrompt(url: string): void;
Deploy permissions
A host binary embedding the deploy surface must grant:
| Permission | Why |
|---|---|
--allow-run |
Invoke desktop package tasks, bsdiff/zstd, and deploy tools such as servy, Aspire, Docker, or gcloud. |
--allow-read |
Read the workspace config, entrypoints, and release/secret files. |
--allow-write |
Emit compiled binaries, native artifacts, private high-water state, release files, and env files. |
--allow-net |
Listen for release HTTP requests and health-probe activated services. |
--allow-sys |
Resolve the host OS/triple to select the Servy vs. systemd adapter and compile target. |
--allow-env |
Read the deploy owner principal for the Windows secret-file ACL; provider CLIs read their auth tokens. |
Library surface
| Subpath | What it gives you |
|---|---|
. |
createPublicCli, runPublicCli, dispatchPluginVerb, createPluginHostLoader, scaffoldPluginPackage |
./scaffolding |
The Scaffolder template-rendering engine for plugin package scaffolds |
./testing |
In-memory ports (createInMemoryFileSystem, createInMemoryProcess, …) + fixture builders |
The always-current symbol list is
deno doc jsr:@netscript/cli@<version>.
Docs
- CLI & scaffold — the full command walkthrough: rickylabs.github.io/netscript/orchestration-runtime/cli-scaffold/
- Reference: rickylabs.github.io/netscript/reference/cli/
- How-to — author a plugin: rickylabs.github.io/netscript/how-to/author-a-plugin/
- How-to — deploy: rickylabs.github.io/netscript/how-to/deploy/
- Agent tooling: rickylabs.github.io/netscript/capabilities/agent-tooling/
- API docs on JSR: jsr.io/@netscript/cli/doc
Compatibility
Requires Deno 2.x; the binary is installed with --allow-all because scaffolding, database, and
deployment verbs read and write the workspace, spawn tools (prisma, aspire, docker, gcloud),
and probe local services. Generated workspaces additionally use the .NET SDK for the Aspire
orchestration host.
License
Apache-2.0 — see LICENSE. Published to JSR with cryptographically verified provenance.
Browser-auth reconciliation reports
Plugin install/update/remove and service add/remove preserve existing browser-auth
helpers and routes. When a preserved file differs from the current formatted
generator output, the command lists its project-relative path as skipped and
divergent. Auth.BrowserTopology: "authored" lists the browser files it leaves to
the app author, including paths that have not been created. Authored layouts at the
project root or outside its generated resource directories are listed as skipped
and not inspected. These observations are
informational; they do not fail the command or overwrite those files. A fresh
scaffold and a rerun whose files match the generator produce no findings.
Programmatic lifecycle results expose browserAuthReport using the existing
DoctorReport contract (plugin: "browser-auth", checks with name, ok: true,
and message). Install previews that do not reconcile omit this report. The same
checks feed normal command output. To extend candidate selection or ownership
rules, start at src/kernel/adapters/plugin/browser-auth-reconciler.ts and its
colocated preservation tests; reporting scenarios live in
tests/browser-auth-reporting_test.ts.
Archetype 6 v2 deviations
The showcase adds one showcase/ concern directory to each of two existing
over-cap parents. Relative to merged main 59e6202, src/kernel/adapters grows
from 18 to 19 immediate children and e2e/src/application/gates/scaffold from 93
to 94; R-FOLD-CARD / F-16 limits immediate children, including subdirectories, to
12. The cost is one more sibling to navigate in each parent. The showcase's
emission and runtime acceptance logic stay grouped, with no runtime, permission,
layering or public-contract exception.
CLI and CLI E2E maintainers own the bounded exception
cli-showcase-cardinality-2571.
Before adding another adapter or scaffold-gate family after #2571, organize the
affected parent into bounded role-named groups. Closure requires both parents at
or below 12 children, preserved default-init bytes and public/maintainer
boundaries, and green structured, quality and runtime gates. Existing scaffold
debt remains open; its historical oversized runtime registry has already been
split and is 362 lines at showcase candidate 04149cb.
Examples
Create an embeddable NetScript CLI command tree.
Create an embeddable NetScript CLI command tree.
import { createPublicCli } from "@netscript/cli"; const cli = createPublicCli({ cwd: () => "/workspace/app", resolvePath: (path = ".") => `/workspace/app/${path}`, });
Add Package
deno add jsr:@netscript/cli@0.0.10
Import symbol
import * as cli from "@netscript/cli";
Import directly with a jsr specifier
import * as cli from "jsr:@netscript/cli@0.0.10";