Tool Support — output-path.js

## §4 Tool Support

### 4.1 `output-path.js` helper

**Location:** `~/system/tools/output-path.js`

**CLI interface:**

```bash
node ~/system/tools/output-path.js resolve \
 --client alai \
 --skill task-postflight \
 --mc 99292
```

Returns: absolute path to the run directory. Creates directory (and `evidence/` subdirectory) if missing. Writes `.provenance.json` on first call.

**Flags:**

| Flag | Required | Description |
|---|---|---|
| `--client` | yes | Client slug or `alai` |
| `--skill` | yes | Skill name or `mc-` for builder evidence |
| `--mc` | yes | MC task id (numeric string) |
| `--model` | no | Model name for provenance (default: unknown) |
| `--agent` | no | Agent persona name for provenance (default: unknown) |

**Idempotent contract:** Given identical `--client`, `--skill`, `--mc` arguments, the tool always returns the same path. On subsequent calls, the directory already exists — no error, no duplicate. The `run_id` is derived deterministically from the mc_id and the date of first creation (stored in `.provenance.json`), not regenerated on each call.

**Exit codes:** `0` = success + path printed to stdout. `1` = missing required flag (error to stderr).

### 4.2 Node.js library counterpart

```js
const { resolve } = require('~/system/tools/output-path');

const runDir = resolve({
 client: 'alai',
 skill: 'task-postflight',
 mc: '99292',
 agent: 'codecraft',
 model: 'claude-sonnet-4-6'
});
// Returns: '/Users/makinja/projects/alai/task-postflight/2026-05-05-99292-a1b2c3'
// Side effects: mkdir -p, writes .provenance.json if not present
```

The library is a thin wrapper around the same logic as the CLI. It does not start a subprocess. Both the CLI and library are the same file — the CLI entry point is a `if (require.main === module)` guard.

### 4.3 No new infrastructure

`output-path.js` uses only Node.js built-ins (`fs`, `path`, `crypto`). No npm dependencies. No network calls. No database writes. It is a pure path-calculator with side-effect-free idempotency.

---