@procedures/mark

npm install --global @procedures/mark

Mark CLI - Development workflow automation through dynamic procedure discovery
Overview
@procedures/mark is a dynamic, extensible CLI that automatically discovers and executes procedures from ecosystem packages. It provides a unified interface for development workflows, package management, and automation tasks across the @mark1russell7 ecosystem.
Key Features
- Dynamic Procedure Discovery: Automatically loads procedures from ecosystem packages
- Self-Documenting: Generates help text from procedure schemas
- Type-Safe: Leverages Zod schemas for runtime validation
- Multiple Output Formats: text, json, table, streaming with spinners
- Workspace-Aware: Loads each package of its pnpm workspace that declares
client.procedures
- Extensible: New commands added by installing procedure packages
Architecture
graph TB
subgraph "User Layer"
CMD[Command Line<br/>mark lib new pkg]
end
subgraph "CLI Layer"
PARSER[Argument Parser]
ROUTER[Command Router]
FORMATTER[Output Formatter]
end
subgraph "Discovery Layer"
MANIFEST[pnpm workspace<br/>packages/*]
DISCOVER[Package Discovery]
LOADER[Dynamic Importer]
end
subgraph "Execution Layer"
REGISTRY[Procedure Registry]
TRANSPORT["Local face of the host"]
CLIENT[Client]
end
subgraph "Procedure Packages"
P1[client-lib]
P2[client-git]
P3[client-pnpm]
P4[client-shell]
end
CMD --> PARSER
PARSER --> ROUTER
ROUTER --> DISCOVER
MANIFEST --> DISCOVER
DISCOVER --> LOADER
LOADER --> P1
LOADER --> P2
LOADER --> P3
LOADER --> P4
P1 --> REGISTRY
P2 --> REGISTRY
P3 --> REGISTRY
P4 --> REGISTRY
ROUTER --> CLIENT
CLIENT --> TRANSPORT
TRANSPORT --> REGISTRY
REGISTRY --> FORMATTER
FORMATTER --> CMD
style CMD fill:#e1f5ff
style MANIFEST fill:#fff3e0
style REGISTRY fill:#c8e6c9
style FORMATTER fill:#f8bbd0
Installation
mark is the package packages/mark of the client monorepo. Build the workspace, then run the CLI:
pnpm install && pnpm build
node packages/mark/dist/cli.js --help
Prerequisites
- Node.js >= 22.0.0
- pnpm (the version of the workspace
packageManager field)
The compile cache
The mark executable enables the compile cache of Node.js (22.1 and later) before it loads the CLI. The second and later runs read the compiled code from the cache.
A study in CI on 2026-11-02 measured the code of commit 74a2801a (@procedures/mark 0.46.0, Node.js 26.13, Linux), in the record of the study. One mark call took 1019 ms with no cache and 754 ms with a warm cache. The first call after an install, or after a change of a file, wrote the cache and took approximately 170 ms more. The numbers are of that commit. A later version can give different numbers.
The cache folder is mark/compile-cache in the cache folder of the user: $XDG_CACHE_HOME or ~/.cache on Linux, ~/Library/Caches on macOS and %LOCALAPPDATA% on Windows. Set NODE_COMPILE_CACHE=<folder> to use a different folder, or NODE_DISABLE_COMPILE_CACHE=1 to turn the cache off. If the folder cannot be written, mark runs with no cache.
Execution Flow
sequenceDiagram
participant User
participant CLI
participant Discovery
participant Registry
participant Procedure
participant Formatter
User->>CLI: mark lib new my-pkg
CLI->>Discovery: Load ecosystem packages
Discovery->>Registry: Import & register procedures
Registry-->>CLI: Procedures ready
CLI->>CLI: Parse arguments
CLI->>Registry: Find procedure ["lib", "new"]
Registry-->>CLI: Return procedure
CLI->>CLI: Parse input from args + schema
CLI->>Procedure: Execute with validated input
Procedure-->>CLI: Return result
CLI->>Formatter: Format output
Formatter-->>User: Display result
API Reference
CLI Binary
The package provides a mark binary for command-line usage.
Basic Syntax
mark [global options] <path...> [positional...] [--options]
mark serve [--procedures pkgs] [--port N] [--token T | --no-token] [--expose patterns] [--events topics] [--fs-root folder] [--probe-port N]
mark mcp [--bundles list] [--tool-timeout ms] [--read-only] [--http port] [--max-sessions n] [--fs-root folder] [--debug]
mark --server [--port N] [--host H] [--allowed-host names] [--transport http|websocket|both] [--events topics] [--probe-port N] [--idle-timeout ms]
mark -i
mark --fs-root <folder> <command | --server | -i | serve | mcp>
The bin is dist/bin.js. node dist/cli.js also runs the CLI. Importing @procedures/mark runs nothing.
The hosts
mark is the one command that a user needs. It starts each host of the ecosystem:
| Command |
Host |
Notes |
mark <command> |
This process (the cold mode), or the CLI server (the warm mode) |
The registry has the module of each workspace package with client.procedures. In the two modes, the command starts under run() of @mark1russell7/service. |
mark --server |
The CLI server |
The same registry, on 127.0.0.1, with a token in the lockfile. A later mark command in the same folder uses it. With --port 0, each listener takes a free port, and the lockfile gives the port. |
mark serve |
The procedure server |
The options of the procedure-server command. A package of --procedures resolves from the current folder, then from the folder of mark. A token is necessary by default. |
mark mcp |
The dev-tools MCP server, over stdio |
The server of Claude Code's MCP configuration. stdout holds only protocol lines, and mark mcp --help writes to stderr. |
mark mcp <procedure> runs an mcp.* procedure (for example mark mcp listTools), not the server. Each host gets its policy from hostPolicy() of @procedures/client.
The cold mode and the warm mode
Each command that runs a procedure is a service of one request (CLI-26, decision D17). The runner of @mark1russell7/service owns the signals, the stop in stages and the exit. mark installs no signal handler of its own.
- The warm mode. A CLI server (
mark --server) of this build operates in this folder, with the same --fs-root. The command goes to the server over HTTP.
- The cold mode. No such server operates, or the command has
--local. The procedures host of the CLI server then operates in this process, with the same registry and policy. It has no port, no token and no lockfile.
- The profile. The service has the profile
ephemeral: no checks, no probes, and a flush of the output before the exit.
- Ctrl-C. A first Ctrl-C starts the stop. The drain aborts the call at once: a shell command stops its process tree, and a stream ends. In the warm mode, the server aborts the call too. Before, the server continued it.
- A second Ctrl-C. A second signal during the stop ends the process at once, with the exit code 1.
- The exit. After the command, the runner ends the process with the exit code of the command. A timer or a socket that a procedure left open does not keep the process alive.
- The REPL.
mark -i starts each line in the cold mode, without the signals: the REPL keeps its process.
- The auto-warm (CLI-27). With
MARK_AUTO_WARM=after-cold, a cold command starts a background CLI server before it exits. The next command in this folder is then warm. The default is never.
- The server stops by itself after
MARK_IDLE_TIMEOUT_MS with no call. The default is 600000 (10 minutes). An open stream is a call until its end.
mark --server --idle-timeout <ms> gives the same idle stop to a server that you start. Without it, the server has no idle stop.
MARK_AUTO_WARM_PORT gives the port of the server. The default is 3000.
- The command starts no server when a warm server operates, when another command starts one, or when another program holds the port.
--verbose shows the decision. The auto-warm does not change the result or the exit code of the command at any time.
graph LR
CMD[mark command] --> SVC["service of the command<br/>run(), profile ephemeral"]
SVC -->|warm| HTTP[HttpTransport + signal] --> SERVER["CLI server<br/>runProcedureHost, daemon"]
SVC -->|cold| FACE["localFace()"] --> HOST["the same host<br/>in this process"]
Remote events of the hosts
mark --server and mark serve always serve the procedure events.subscribe (EVENTS.md):
--events <patterns> gives the topics that a peer can subscribe to: exact names (orders.created), prefixes (orders.*) or *. Repeat the flag, or separate the patterns with commas.
- Without
--events, the host serves no topic. Each subscription gets TOPIC_NOT_FOUND.
- The bus is the global bus of the process. The procedures get it as
ctx.bus, so a procedure publishes with ctx.bus.emit().
- The token of the host applies to a subscription. The hosts have no capability limits, so they permit each subscription to a topic of the rule.
mark mcp serves no events: MCP carries only the tool calls, and events.subscribe is not a tool.
mark --server --transport both --events "orders.*"
mark serve --procedures ./my-procedures.js --events orders.created --events audit.created
The health probes of the hosts
mark --server and mark serve answer the probes of their service (CLI-9, decision D5). The probes give only the status, and they need no token.
- By default, each listener answers
GET /_probes/startup, /_probes/readiness and /_probes/liveness. The answer is 200, or 503 with Retry-After. The probes stop when the listener closes at the stop of the intake.
--probe-port <port> moves the probes to a port of their own, on the address of --host: /startup, /readiness, /liveness and /report. The listeners then answer no probes.
- The startup prints the URL of the probes.
curl http://127.0.0.1:3000/_probes/readiness
mark --server --probe-port 9090
The root of the files
--fs-root <folder> confines each procedure to the folder (roadmap R33). Each procedure keeps its paths in the folder, or mark refuses it. It applies to each mode and host of mark:
- A command in this process, the REPL (
-i) and the CLI server (--server): the registry of mark gets the root (confineToRoot() of @procedures/fs).
mark serve and mark mcp: the root goes to their servers. mark mcp also reads MCP_FS_ROOT.
- A path outside the folder gives
FORBIDDEN with the reason outside-root. A relative path starts at the folder. A working folder without a value is the folder.
- The nested calls are confined too. For example,
mark --fs-root ./data lib scan cannot list the packages of a workspace outside ./data.
- A procedure that the folder cannot confine gives the same error, also for a path in the folder. Examples are
pnpm.*, docker.run, docker.compose.*, shell.run and vitest.run.
- The
git.* procedures are confined: git finds no repository above the folder, and the configuration of a repository starts no program.
- Give
--fs-root before the command. After the command, it is an error, because the procedures loaded without it.
- A command uses a CLI server only when the server has the same root. The lockfile of the server records its root.
The rules and the table of the procedures are in CAPABILITIES-2026-10.md.
mark --fs-root ./data fs read notes.txt
mark --fs-root ./data sqlite tables --dbPath notes.db
mark --fs-root ./data --server
The command line reads the longest path that names a procedure. Thus mark fs read json a.json starts fs.read.json, and mark fs read notes.txt starts fs.read. To read a file with the name json, write mark fs read ./json.
Global Options
A flag before the command path is a global flag. After the path, a flag is the command's flag when the command declares it. Otherwise it is a global flag. For example, mark docker compose down -v gives -v (volumes) to the command. To show the version, write mark -v. mark lib audit lists the command flags that hide a global flag.
| Option |
Short |
Description |
--help |
-h |
Show help for command or group |
--version |
-v |
Show CLI version |
--verbose |
-V |
Enable verbose output during discovery |
--format <format> |
-f |
Override output format (text, json, table, streaming) |
--local |
|
Run the command in this process, not on the CLI server |
--json <json> |
|
Execute raw procedure reference |
--fs-root <folder> |
|
Keep each path of each procedure in the folder, also in the nested calls, and refuse the procedures that it cannot confine. Give it before the command. |
--server |
|
Start the CLI server (with --port, --host, --allowed-host, --transport, --events) |
--interactive |
-i |
Start the REPL |
Exit Codes and Failures
mark exits with code 1 when:
- the command is unknown, or the command line has a problem (an unknown flag, a missing value, an extra argument);
- the input is not valid for the procedure;
- the procedure throws an error;
- the result reports a failure.
A procedure reports a failure in one of three ways:
- It throws an error. This is the usual way.
- It returns an object with
success: false. Use this when the result has more to show, for example the problems that lib audit found.
- It returns an object with an
exitCode that is not 0. Use this for a procedure that runs an external command, for example vitest run.
For a streaming procedure, mark examines each item. One failed item makes the command fail.
The exit codes of a command, since the MINOR of CLI-26. A signal stops a command through the runner: