Docs Packages
@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:#f8bbd0Installation#
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
packageManagerfield)
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 resultAPI 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 -istarts 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 isnever.- The server stops by itself after
MARK_IDLE_TIMEOUT_MSwith 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_PORTgives 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.
--verboseshows the decision. The auto-warm does not change the result or the exit code of the command at any time.
- The server stops by itself after
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 getsTOPIC_NOT_FOUND. - The bus is the global bus of the process. The procedures get it as
ctx.bus, so a procedure publishes withctx.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 mcpserves no events: MCP carries only the tool calls, andevents.subscribeis 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/readinessand/_probes/liveness. The answer is 200, or 503 withRetry-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,/livenessand/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 ofmarkgets the root (confineToRoot()of@procedures/fs). mark serveandmark mcp: the root goes to their servers.mark mcpalso readsMCP_FS_ROOT.- A path outside the folder gives
FORBIDDENwith the reasonoutside-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 scancannot 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.runandvitest.run. - The
git.*procedures are confined: git finds no repository above the folder, and the configuration of a repository starts no program. - Give
--fs-rootbefore 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 thatlib auditfound. - It returns an object with an
exitCodethat is not 0. Use this for a procedure that runs an external command, for examplevitest 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:
| Event | Cold mode | Warm mode |
|---|---|---|
| The command ends without a failure | 0 | 0 |
| The command fails | 1 | 1 |
The first SIGINT (Ctrl-C) | 130 | 130 |
SIGTERM | 143 | 143 |
SIGQUIT | 131 | 131 |
| A second signal during the stop | 1 | 1 |
The cold mode is a command in this process: no CLI server operates in this folder, or the command has --local. The MINOR of CLI-26 changed three behaviors. The release before it marked them as deprecated:
- The first Ctrl-C in the cold mode. Before, the aborted command gave the exit code 1. The runner gives 130.
- A second signal. Before, a second Ctrl-C in the cold mode gave the exit code 130. The runner gives 1.
mark server createin the cold mode. Before, the peer of the command kept the process alive after the command. The peer stops at the end of the command. For a server in the foreground, usemark --serverorprocedure-server.
Before CLI-26, a signal in the warm mode ended the process, and the server continued the call. The shell showed 130 or 143. The runner gives the same codes, after the server aborts the call.
Examples#
# Show all available commands
mark
# Show help for a command group
mark lib --help
# Show help for specific command
mark lib new --help
# Execute command with options
mark lib new my-package --preset lib
# Override output format
mark git status --format json
# A global flag before the command (docker ps has its own --format)
mark --format json docker ps
# Verbose discovery
mark --verbose lib new my-pkg
Programmatic API#
run(argv: string[], options?): Promise<void>#
Main CLI entry point.
import { run } from "@procedures/mark";
// Execute CLI programmatically
await run(["lib", "new", "my-package"]);
- By default, the program keeps its process. A command installs no signal handler, does not end the process, and sets
process.exitCode. ownsProcess: truegives the process to the runner of each command, as the bin does. The runner then owns the signals, and it ends the process with the exit code of the command.rungives the options ofrun()of@mark1russell7/service: the process port and the clock. A test givesfakeProcess()of@mark1russell7/service/testing.
parseFromSchema(params, meta, schema?): Record<string, unknown>#
Parse CLI arguments based on procedure metadata. With the schema, each value is converted by the type of its field. parseCommandLine(argv, procedures) splits a whole command line: the global flags, the path and the input.
import { parseFromSchema } from "@procedures/mark";
const params = {
array: ["my-package"],
options: { description: "My pkg" }
};
const meta = {
args: ["name"],
shorts: { description: "d" }
};
const input = parseFromSchema(params, meta);
// { name: "my-package", description: "My pkg" }
generateHelp(path, meta, schema?): string#
Generate help text for a procedure.
import { generateHelp } from "@procedures/mark";
const help = generateHelp(
["lib", "new"],
{
description: "Create a new library package",
args: ["name"],
shorts: { skipGit: "g" }
},
schema
);
console.log(help);
formatOutput(print, result, format): void#
Format and print procedure results.
import { formatOutput } from "@procedures/mark";
// print: an object with info, error, success, warning, table and spin (see format.ts)
formatOutput(print, { message: "Success!" }, "text");
formatOutput(print, { rows: [...] }, "table");
formatOutput(print, { data: {...} }, "json");
CLI Metadata Interface#
Procedures define CLI behavior via metadata:
interface CLIMeta {
/** Description for help text */
description?: string;
/** Field names that are positional args (in order) */
args?: string[];
/** Short flag mappings: { fieldName: "f" } */
shorts?: Record<string, string>;
/** Output format hint */
output?: "text" | "json" | "table" | "streaming";
/** Whether to prompt for missing required fields */
interactive?: boolean;
}
Questions for missing arguments#
In a terminal, mark asks for each required argument that the command line does not give. The question shows the name, the type and the description of the field. mark does not ask in these cases:
- stdin or stdout is not a terminal;
- the environment variable
CIis set; - the command line has
--no-inputbefore the command; - the procedure sets
interactive: false.
Then a missing argument is an error of the input (exit code 1).
Output Format Types#
type OutputFormat = "text" | "json" | "table" | "streaming";
Ecosystem Discovery#
The command manifest#
The build of mark writes dist/manifest.json. It holds the path, the CLI metadata, the input fields and the JSON Schema of each command. mark reads it first, so the help and a call to the CLI server do not load the procedures. The procedures load only when a command runs in this process.
- A fingerprint records the build of each package that has procedures (its
dist/.tsbuildinfo). When a package is built again, added or removed, the manifest is stale. Then mark loads the procedures as before and writes the manifest again. - mark depends on each package that has procedures, so
pnpm buildbuilds mark after them. A test fails when a package is missing from the dependencies of mark, or when the manifest after the build does not match the registry.
Measured on Windows with Node 24 (median of 5 runs, the same machine load):
| Command | Before | After |
|---|---|---|
mark --help | 1127 ms | 164 ms |
mark git status (CLI server) | 1170 ms | 352 ms |
mark git status --local | 1141 ms | 1027 ms |
Discovery of the procedures#
The registry of mark is a registry of its own (loadEcosystemRegistry()). For each workspace package with client.procedures, mark imports its ./module entry, which registers nothing, and puts its procedures in that registry with createRegistry(). A package without a ./module entry still works: mark imports its procedures file and takes the procedures that the import adds to the global registry.
The CLI uses a multi-step discovery process to find and load procedures:
Discovery Flow#
graph TB
START[CLI Starts]
MANIFEST[Find the workspace root:<br/>pnpm-workspace.yaml]
PACKAGES[Iterate packages/*]
PKGJSON[Read package.json]
CHECK{Has client<br/>.procedures?}
IMPORT[Dynamic import<br/>procedures file]
REGISTER[Auto-register to<br/>PROCEDURE_REGISTRY]
READY[Procedures Ready]
SKIP[Skip package]
START --> MANIFEST
MANIFEST --> PACKAGES
PACKAGES --> PKGJSON
PKGJSON --> CHECK
CHECK -->|Yes| IMPORT
CHECK -->|No| SKIP
IMPORT --> REGISTER
REGISTER --> READY
SKIP --> PACKAGES
style START fill:#e3f2fd
style MANIFEST fill:#fff3e0
style REGISTER fill:#c8e6c9
style READY fill:#a5d6a7Package Structure#
For a package to be discovered, it must:
- Be a folder in
packages/of the workspace that holds this CLI - Have a
client.proceduresfield in package.json - Export procedure registrations from that file
A package that does not load gives one warning line. A package that is not built yet is reported only with --verbose.
Example package.json:
{
"name": "@procedures/lib",
"client": {
"procedures": "./dist/register.js"
}
}
Example register.js:
import { defineProcedure } from "@procedures/client";
import * as z from "zod";
const libNew = defineProcedure({
path: ["lib", "new"],
input: z.object({
name: z.string(),
}),
handler: async (input, ctx) => {
// Implementation
return { message: "Created!" };
},
metadata: {
description: "Create a new library",
args: ["name"],
},
});
// Auto-registers when imported
Discovery Sources#
| Source | Path | Description |
|---|---|---|
| Workspace | <root>/pnpm-workspace.yaml, <root>/packages/* | The packages that mark examines |
| Package Metadata | <pkg>/package.json | Contains client.procedures path |
| Procedure Registry | PROCEDURE_REGISTRY | Global registry from @procedures/client |
Argument Parsing#
The CLI uses a smart parser that detects procedure paths and maps arguments correctly.
Path Detection#
graph LR
INPUT[mark lib new pkg<br/>--desc test]
PATH[Path: lib new]
ARGS[Positional: pkg]
OPTS[Options: desc=test]
INPUT --> PATH
INPUT --> ARGS
INPUT --> OPTS
style PATH fill:#e1f5ff
style ARGS fill:#fff3e0
style OPTS fill:#f8bbd0Parsing Rules#
- Path Segments: Consumed until a procedure match is found.
- Flags: A flag is a field of the input schema (
--skip-gitor--skipGit), or the short letter of the metadata (-m). A flag that the procedure does not declare is a global flag. Otherwise it is an error. - Types: Each value is converted by the type of its field. A string field keeps its text:
mark fs exists 2024gives the path"2024", not a number. A number field needs a number. An object field, or a field with no type, takes JSON. - Boolean Flags: A boolean flag alone is
true. It also takestrueorfalseafter it,--flag=false, or--no-flag. - Arrays and Records: A repeated array flag collects its values (
--tag a --tag b). A record flag takeskey=valueand can be repeated (--env A=1 --env B=2). Both also take JSON. - Positional Args: The fields of
argstake the arguments in order. A last array field takes the rest. An argument that no field takes is an error. - Values: A negative number is a value (
--count -5).--ends the flags: the tokens after it are arguments. Short boolean flags can be grouped (-it). A short flag can have its value attached (-n5).
Examples#
# Simple command
mark lib new my-package
# path: ["lib", "new"]
# input: { name: "my-package" }
# With options
mark lib new my-package --preset lib --dry-run
# input: { name: "my-package", preset: "lib", dryRun: true }
# A boolean flag with a value
mark git commit --message "message" --amend false
# input: { message: "message", amend: false }
# Short flags (the metadata of git push maps -f to force and -u to setUpstream)
mark git push -fu
# input: { force: true, setUpstream: true }
# Arguments that look like flags, after --
mark docker exec box -- ls -la /tmp
# input: { container: "box", command: ["ls", "-la", "/tmp"] }
Metadata-Based Mapping#
// Procedure metadata
metadata: {
args: ["name", "version"], // Positional mapping
shorts: { skipGit: "g" }, // Short flag mapping
}
// Command
// mark lib new my-pkg 1.0.0 -g
// Parsed input
{
name: "my-pkg",
version: "1.0.0",
skipGit: true
}
Output Formatting#
The CLI supports multiple output formats for different use cases.
Text Format#
Default format for human-readable output.
// Result with message
{ message: "Package created successfully!" }
// Output: Package created successfully!
// Result with output field
{ output: "file contents..." }
// Output: file contents...
// Result with error
{ success: false, message: "Failed to create" }
// Output: [ERROR] Failed to create
JSON Format#
Structured output for programmatic consumption.
mark lib scan --format json
{
"rootPath": "/path/to/client",
"packages": { "@procedures/lib": { "name": "@procedures/lib" } }
}
Table Format#
Tabular data display.
mark procedure list --format table
path description
fs read Read file contents
fs write Write content to file
Streaming Format#
Shows a spinner during execution, then displays the result.
mark lib audit --format streaming
# Running lib audit...
# lib audit complete
# Result displayed
Integration with the Workspace#
mark loads each package of its pnpm workspace that has a client.procedures field in its package.json. The field names the built module that registers the procedures.
Procedure Packages#
Each client package can export procedures:
packages/client-lib/
├── src/
│ ├── procedures/lib/new.ts
│ ├── procedures/lib/audit.ts
│ └── register.ts # Registers all procedures
├── dist/
│ └── register.js # Built procedures
└── package.json
└── client.procedures: "./dist/register.js"
Transport Layer#
In the cold mode, the client sends each call to the procedures host of this process through localFace() of @procedures/peer (CLI-26). In the warm mode, the client sends each call to the CLI server through HttpTransport.
graph LR
CLI[CLI]
CLIENT[Client]
TRANSPORT["localFace() transport"]
HOST["ProcedureServer of the host<br/>(request tracking of the service)"]
REGISTRY[ProcedureRegistry]
HANDLER[Procedure Handler]
CLI --> CLIENT
CLIENT --> TRANSPORT
TRANSPORT --> HOST
HOST --> REGISTRY
REGISTRY --> HANDLER
HANDLER --> HOST
HOST --> TRANSPORT
TRANSPORT --> CLIENT
CLIENT --> CLI
style CLI fill:#e1f5ff
style CLIENT fill:#c8e6c9
style TRANSPORT fill:#fff3e0
style HANDLER fill:#f8bbd0Available Commands#
Commands are discovered dynamically. Common procedure packages include:
client-lib#
Package management and scaffolding:
mark lib new <name>- Create new packagemark lib scan- List the workspace packagesmark lib audit- Check the packages against the template
client-git#
Git operations:
mark git status- Show git statusmark git commit- Create commitmark git push- Push to remote
client-pnpm#
Package manager operations:
mark pnpm install- Install dependenciesmark pnpm add <pkg>- Add packagemark pnpm remove <pkg>- Remove package
client-shell#
Shell command execution:
mark shell run <command>- Run shell commandmark shell exec <command>- Execute commandmark shell which <binary>- Find binary in PATH
client-procedure#
Procedure management:
mark procedure new <path>- Create new proceduremark procedure list- List all procedures
Advanced Usage#
Procedure References#
Execute procedures via JSON for advanced scripting:
# Execute procedure reference
mark --json '{
"$proc": ["lib", "new"],
"input": {
"name": "my-package",
"dryRun": true
}
}'
Chaining Commands#
Use standard shell pipes. A failed command exits with code 1, so && stops at it:
# Get package list and filter
mark --format json lib scan | jq '.packages | keys'
# Create a package, then audit the workspace
mark lib new my-pkg && mark lib audit
Environment Variables#
# The home folder holds the lockfiles of the CLI servers (~/.mark)
export HOME=/custom/path
Development#
Building#
pnpm --filter @procedures/mark build
Testing#
pnpm --filter @procedures/mark test # unit tests (src/**/*.test.ts)
pnpm --filter @procedures/mark test:e2e # end-to-end tests: they run dist/bin.js as a process
The end-to-end tests use a temporary home folder and a temporary workspace. They do not change the repository and do not use a running CLI server.
There is no container image of mark: the CLI server serves the workspace of the folder where it starts, on loopback, with a token in the lockfile of the user. A container cannot give that. To serve procedures over the network, use the server package.
Project Structure#
packages/mark/
├── src/
│ ├── bin.ts # The mark executable
│ ├── cli.ts # Main CLI implementation (also runnable as dist/cli.js)
│ ├── args.ts # Command line splitting: global flags, path, procedure flags
│ ├── parse.ts # Field types, value conversion and help text
│ ├── failure.ts # Procedure-level failure and the exit code
│ ├── format.ts # Output formatters
│ ├── ecosystem.ts # Discovery system
│ └── index.ts # Public API (importing it runs nothing)
├── e2e/ # End-to-end tests
├── test/ # Test procedures for the unit tests
└── package.json
└── bin: { "mark": "./dist/bin.js" }
Key Modules#
cli.ts#
Main CLI implementation:
- Command routing
- Procedure execution
- Help generation
- Error handling
parse.ts#
Argument parsing and schema introspection:
parseFromSchema()- Parse args based on metadatagenerateHelp()- Generate help textextractSchemaFields()- Introspect Zod schemas
format.ts#
Output formatting:
formatOutput()- Format results based on typeformatText()- Plain text outputformatTable()- Tabular output
ecosystem.ts#
Procedure discovery:
discoverFromEcosystem()- Find procedure packagesloadEcosystemProcedures()- Load and register procedureslistEcosystemProcedurePackages()- List available packages
Troubleshooting#
Procedure Not Found#
Unknown command: mark foo bar
Solution:
- Check that the package is in
packages/of the workspace - Verify the package has
client.proceduresin package.json - Ensure the package is built (
pnpm buildin the workspace root) - Use
mark --verboseto see which packages are being loaded
Import Error#
mark: the procedures of @procedures/foo did not load: <message>
Solution:
- Check that the procedures file exists at the specified path
- Verify the file is valid JavaScript (not TypeScript)
- Build the workspace:
pnpm build
Help Not Showing Schema Fields#
# Only shows basic help without field details
Solution: Ensure procedures have Zod schemas defined in the input field. The CLI introspects schemas to generate detailed help.
Dependencies#
The CLI depends on:
@procedures/client- Client library and procedure system@procedures/*- Various procedure packageschalk,ora,cli-table3- Terminal outputzod- Schema validation
License#
MIT
Repository#
https://github.com/mark1russell7/cli
Author#
Mark Russell marktheprogrammer17@gmail.com