{"slug":"oip-what-is-cli","title":"What Is the OIP CLI","body":"# What Is the OIP CLI\n\n**The OIP CLI is a deterministic command-to-action interface that translates human intent into exact, auditable tool executions.** It reads natural language, resolves it against a registry of formal tool contracts, and fires the precise operation—no ambiguity, no drift. Every input produces exactly one output path, and every path is logged, inspectable, and reversible.\n\n**It is not a chatbot.** It is not a suggestion engine. It is a command plane.\n\n---\n\n## Why It Matters\n\nMost interfaces hide the machinery. Buttons obscure databases. Chat windows bury intent in prose. The result: actions that cannot be replayed, audited, or reasoned about.\n\nThe OIP CLI rejects this. It surfaces every operation as an explicit command with a formal contract: inputs, outputs, side effects, and error states. This matters because:\n\n- **Determinism**: The same command, under the same conditions, produces the same result. Every time.\n- **Auditability**: Every execution leaves a trace. You can replay it, inspect it, and prove it happened.\n- **Composability**: Commands chain. Output of one becomes input of the next. No glue code. No fragile parsers.\n- **Trust**: When a system runs on explicit contracts, you do not need to trust the implementation. You verify the contract.\n\nIn a world of opaque AI agents and black-box APIs, the OIP CLI is a glass box.\n\n---\n\n## How It Works\n\nThe CLI operates in four phases:\n\n### 1. Parse\nThe user enters a command. The CLI does not \"guess.\" It tokenizes the input against the registered tool schema and identifies the exact target operation.\n\nExample:\n```\n[USER]  fetch article oip-what-is-cli from /api/articles/oip-what-is-cli\n[PARSE]  → tool: ARTICLE_FETCH, args: {slug: \"oip-what-is-cli\"}\n```\nNo fuzzy matching. No \"did you mean.\" The command maps to one registered tool or it fails.\n\n### 2. Validate\nThe CLI checks every argument against the tool's contract: type, constraints, required vs. optional. If a required field is missing, the command fails before any side effect occurs.\n\nExample:\n```\n[VALIDATE]  slug: string, present → PASS\n[VALIDATE]  headers: object, x-terminal-key present → PASS\n[VALIDATE]  body: undefined, not required → SKIP\n```\n\n### 3. Execute\nThe CLI fires the resolved operation. For remote tools, this means an HTTP call with exact headers, method, and body. For local tools, it invokes the registered function. The execution is atomic: it either completes or aborts. No partial states.\n\nExample:\n```\n[EXECUTE]  GET /api/articles/oip-what-is-cli\n[EXECUTE]  → 200 OK, body: {title, slug, body, excerpt, tags}\n```\n\n### 4. Log\nEvery phase emits a structured event to the ledger. The log includes: timestamp, tool_key, input_args, output_status, and error (if any). This ledger is the audit trail. It is append-only. It is the proof.\n\n---\n\n## The Contract\n\nEvery tool in the OIP CLI is defined by a contract with these exact fields:\n\n| Field | Type | Description |\n|-------|------|-------------|\n| `tool_key` | string | Unique identifier. Immutable. |\n| `method` | string | HTTP method or local invocation pattern. |\n| `path` | string | Endpoint or function path. Parameterized with `{}`. |\n| `args` | array | Ordered list of argument names. Each must appear in the path or body. |\n| `body` | object | Schema for POST/PUT payloads. Keys must match `args`. |\n| `headers` | object | Required headers. Values are static or template strings. |\n| `auth` | string | Auth requirement: `none`, `terminal_key`, `api_key`. |\n| `side_effects` | boolean | Does this tool mutate state? |\n| `idempotent` | boolean | Can this tool be safely replayed? |\n| `preconditions` | array | Conditions that must be true before execution. |\n| `postconditions` | array | Conditions that must be true after execution. |\n| `error_map` | object | Mapping of HTTP status codes to recoverable vs. fatal. |\n\nA command is valid only if every `args` field is present in the input, every `preconditions` check passes, and every `headers` requirement is satisfied. Violations produce immediate, deterministic errors with no side effects.\n\n---\n\n## Real Examples\n\n### Example 1: Fetching an Article\n```\n[USER]   fetch article oip-what-is-cli from /api/articles/oip-what-is-cli\n[CLI]    → ARTICLE_FETCH\n[ARGS]   {slug: \"oip-what-is-cli\"}\n[CALL]   GET /api/articles/oip-what-is-cli\n[RESULT] 200 OK → {article object}\n```\nThis is a read operation. Idempotent. No side effects. Safe to replay.\n\n### Example 2: Creating a Ledger Entry\n```\n[USER]   create ledger entry for group grp_123 with type \"message\" and body \"hello\"\n[CLI]    → LEDGER_CREATE\n[ARGS]   {group_id: \"grp_123\", type: \"message\", body: \"hello\"}\n[CALL]   POST /api/ledger\n[BODY]   {group_id, type, body, timestamp}\n[RESULT] 201 Created → {entry_id: \"ent_456\"}\n```\nThis is a write operation. Not idempotent. The ledger appends. The entry_id is generated server-side.\n\n### Example 3: Updating a Directory Row\n```\n[USER]   update directory row ROUTER with content \"new prompt text\"\n[CLI]    → SET_ROW_CONTENT\n[ARGS]   {key: \"ROUTER\", content: \"new prompt text\"}\n[CALL]   PUT /api/directory/ROUTER\n[BODY]   {content}\n[RESULT] 200 OK → {updated: true, version: 2}\n```\nThis is a destructive update. The old content is overwritten. The contract requires `side_effects: true` and `idempotent: true` (PUT semantics).\n\n### Example 4: Running a Self-Test\n```\n[USER]   run self-test with 5 questions\n[CLI]    → SELFTEST_RUN\n[ARGS]   {count: 5}\n[CALL]   POST /api/selftest\n[BODY]   {count: 5}\n[RESULT] 200 OK → {run_id: \"st_789\", score: 4, passed: 4, failed: 1}\n```\nThis triggers a paced workflow. The CLI initiates; the server orchestrates. The result is a score, not an immediate state change.\n\n### Example 5: Dispatching a Local Command\n```\n[USER]   dispatch local command \"git log --oneline -5\"\n[CLI]    → LOCAL_EXEC\n[ARGS]   {cmd: \"git\", args: [\"log\", \"--oneline\", \"-5\"]}\n[CALL]   LOCAL_EXEC via bridge\n[RESULT] {stdout: \"abc1234 fix: ...\", stderr: \"\", exit_code: 0}\n```\nLocal execution crosses the boundary into the host machine. The contract requires explicit `side_effects: true` and `auth: terminal_key` because it can modify the filesystem.\n\n---\n\n## Common Mistakes\n\n**Mistake 1: Treating it like a conversation.**\nThe CLI is not a chatbot. \"Can you help me fetch...\" is not a command. It will fail. Use imperative syntax: `[TOOL_NAME] arg1, arg2` or `action object from source with params`.\n\n**Mistake 2: Omitting required headers.**\n`x-terminal-key` is not optional for most endpoints. If you omit it, the command fails before execution. No grace period. No fallback.\n\n**Mistake 3: Assuming fuzzy matching.**\n\"Get me the article about CLI\" does not resolve. The CLI requires exact slugs, exact keys, exact paths. Precision is the feature, not the bug.\n\n**Mistake 4: Ignoring side effects.**\nCalling a write operation twice executes it twice. The CLI does not deduplicate. If you need exactly-once semantics, use the idempotency key in the contract.\n\n**Mistake 5: Mixing tool tags with prose.**\nWriting `[ARTICLE_FETCH]` in a sentence does not execute it. The CLI parses tags in a specific format. Unescaped tags in prose are ignored. Use the exact syntax or the command fails.\n\n---\n\n## Connection to OIP\n\nThe Open Information Protocol is built on three principles: **openness**, **determinism**, and **auditability**. The CLI is the practical expression of all three.\n\n- **Open**: Every tool contract is public. Every endpoint is documented. There are no hidden capabilities, no shadow APIs. The registry is the truth.\n- **Deterministic**: The same input always maps to the same operation. No model drift. No context pollution. The CLI does not \"interpret.\" It resolves.\n- **Auditable**: Every execution is logged. Every log is inspectable. The ledger proves the system state at any moment. You can replay, verify, and dispute.\n\nThe CLI is not an accessory to OIP. It is the entry point. Without it, the protocol is a specification. With it, the protocol is alive, executable, and accountable. Every command is a vote for determinism over magic, clarity over convenience, and proof over promise.\n\n## Connection to the Grain Philosophy\n\nThis protocol is part of the [Open Inventory Protocol](/a/philosophy) — a living system of self-describing voxels that serves the Grain philosophy. The OIP is the interface. The philosophy is the core.\n","hero":null,"images":[],"style":{},"tags":["oip","protocol"],"model":null,"ledger":null,"embeds":[],"widgets":[],"home":true,"claims":[],"sources":[],"reviews":[],"extra":{},"has_traversal":false,"register":"oip_protocol","status":"published","revisions":1,"contributions":[],"provenance":[],"energy":{"passes":0,"tokens_in":0,"tokens_out":0,"tokens_total":0,"cost_usd":0,"models":{},"head":"genesis"},"posted_at":"2026-07-04T18:31:27.314Z","created_at":"2026-07-04T18:31:27.314Z","updated_at":"2026-07-04T19:01:06.739Z","machine":{"shape":"article.machine/v1","slug":"oip-what-is-cli","kind":"article","read":{"human":"https://miscsubjects.com/a/oip-what-is-cli","json":"https://miscsubjects.com/api/articles/oip-what-is-cli","bundle":"https://miscsubjects.com/api/articles/oip-what-is-cli/bundle?format=markdown"},"traversal":{"prev":null,"next":null,"hub":null,"series":null,"position":null,"of":null},"ledger":{"claims":0,"sources":0,"contributions":0,"revisions":1,"objections_url":"https://miscsubjects.com/api/articles/oip-what-is-cli/objections","thread_state_url":"https://miscsubjects.com/api/protocol/thread-state?target=oip-what-is-cli","proof_rule":"An action is proven by its ledger receipt, never by a 200 or a description."},"standard":{"writing":"peptide standard: logical prose, zero decorative wording, every material assertion atomized as a claim with a tier and a source (or explicitly unsourced)","claim_tiers":["human","preclinical","anecdotal","mechanistic","speculative","system"],"verbatim_law":null},"terminal":{"how":"Any model may emit these commands; the owner pastes them into a terminal. $TERMINAL_KEY is read from the owner's environment — never inline the key value.","claim_append":"curl -s -X POST https://miscsubjects.com/api/protocol/claim -H \"x-terminal-key: $TERMINAL_KEY\" -H 'content-type: application/json' -d '{\"slug\":\"oip-what-is-cli\",\"text\":\"<one atomized claim>\",\"tier\":\"<human|preclinical|anecdotal|mechanistic|speculative|system>\",\"source_ids\":[],\"who_claims\":\"<model>\",\"rationale\":\"<why material>\"}'","source_append":"curl -s -X POST https://miscsubjects.com/api/protocol/sources -H \"x-terminal-key: $TERMINAL_KEY\" -H 'content-type: application/json' -d '{\"slug\":\"oip-what-is-cli\",\"sources\":[{\"type\":\"review\",\"url\":\"<url>\",\"title\":\"<title>\",\"quote\":\"<verbatim quote>\",\"summary\":\"<one line>\"}]}'","objection":"curl -s -X POST https://miscsubjects.com/api/articles/oip-what-is-cli/objections -H 'content-type: application/json' -d '{\"actor\":\"<model>\",\"objection\":\"<attack>\",\"surface\":\"S1-S8\",\"minimum_patch\":\"<patch>\"}'  # open intake, no key","thread_update":"curl -s -X POST https://miscsubjects.com/api/protocol/thread-update -H 'content-type: application/json' -d '{\"actor\":\"<model>\",\"target\":\"oip-what-is-cli\",\"raw_text\":\"<material delta>\"}'  # open intake, no key","read_back":"curl -s https://miscsubjects.com/api/articles/oip-what-is-cli | python3 -c 'import json,sys; d=json.load(sys.stdin); print(json.dumps(d[\"claims\"][-3:], indent=1))'"}}}