Command namespace specification (v0)
Status: draft v0. The rule numbers match the concept page (NS-1..NS-14). Items marked PROVISIONAL are listed in Design decisions.
The key words MUST, MUST NOT, SHOULD and MAY are used as in RFC 2119.
Nodes and paths (NS-1)
-
The namespace is a tree. A node path is one or more words separated by
/. -
A word MUST match
[a-z0-9][a-z0-9._+-]*. Paths are lowercase. A shell MAY fold case on input on case-insensitive platforms, but stored paths are lowercase. -
Every node has a kind:
verb(an action such asinstall; the resolver’s command is literallyinstall, and on Unixinstall(1)lives atlegacy/install, see Coexisting with install(1)),provider(one way to do a verb, such asinstall/npm),command(a plain runnable),alias(points at another path) orgroup(a container with no entry of its own). -
Schema:
schema/namespace-node.schema.json.
Registration (NS-2)
-
A tool claims nodes through a registration manifest (
schema/registration-manifest.schema.json). Manifests are written in JSON5 (*.manifest.json5), format version0. JSON5 parses to the JSON data model, so the JSON Schema validates the parsed value. Plain JSON is valid JSON5. -
Every claim records its owning package id and version. A registry MUST be able to answer "who owns this path".
-
An alias MUST name a valid target path. The registry follows aliases while resolving and MUST detect loops.
Conflicts (NS-3)
-
Two claims on one path MUST NOT be resolved silently by "last installed wins".
-
If any claimant’s policy is
refuse, the path is ambiguous: resolving it MUST fail and report every claimant. -
If every claimant’s policy is
shadow-with-warning, the first registered claim wins. The others are shadowed and MUST still appear in conflict reports.
Discovery (NS-4)
-
Resolving an unknown name MUST NOT fail bare. Tools SHOULD offer did-you-mean candidates (edit distance on the last word and on the full path).
-
children(path)lists a node’s direct children, so every level of the tree can be browsed.
Legacy PATH (NS-5)
-
Entries found on the platform
PATHare imported underlegacy/<name>with policyshadow-with-warning, in PATH order. This keeps today’s PATH order while making the shadowing visible. -
On Windows, within one folder,
PATHEXTorder picks which file<name>means. Names are case-folded. -
A top-level name resolves to its namespace claim first, then to
legacy/<name>.
CLI style (NS-6)
-
Each runnable node declares
entry.style:strict(the default, CLI Styles CS-1) orresolver.
Token tables (NS-7)
-
A node MAY declare its subcommands, contextual flags (meaning depends on the verb) and free flags (meaning is the same everywhere). Free flags use the
+sigil (decided), and repeating the sigil steps throughlevels.
Changed-since markers (NS-8)
-
A node MAY carry
changed-since, keyed by an earlier version, listing tokens that were added, removed or changed. Tools use it to warn about scripts written for older versions.
Input signatures (NS-9, NS-10)
-
An input signature (
schema/input-signature.schema.json) declares which ambient context a command asks for: the current folder (none/read/write, always or only under a flag), environment variables, identity, network and stdin, plus its typed inputs and effects. -
Signatures are declarations, not sandboxing. Isolation is the
isolatefront door’s job (NS-13, NS-14).
Composition block (NS-11, NS-12)
-
Defined on the concept page. This version of the library does not implement it.
Isolation (NS-13, NS-14)
-
Levels overlay / fence / partition / guest x lifetimes run / session / kept x scope. Owned by isolateunchecked. Not part of this library.
Storage (PROVISIONAL)
-
The JSON5 manifests are the editable source of truth. A registry MAY compile them into an index for fast queries. The proposed index is SQLite; see Provisional decisions. The index can always be rebuilt from the manifests and MUST NOT be edited by hand.
Reference library
source/command_namespace (D, dub package command-namespace):
-
node.d:Node,NodeKind,isValidPath,parentOf -
registry.d:Registry.register / resolve / conflicts / suggest / children -
manifest.d:parseManifestfor JSON5 manifests (format version 0) -
json5.d: small JSON5-to-JSON translator (parseJSON5,json5ToJson)
Run dub test from the repository root.