@martini-film/cli 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +169 -44
  2. package/dist/api.js +71 -23
  3. package/dist/api.js.map +1 -1
  4. package/dist/approve.js +16 -1
  5. package/dist/approve.js.map +1 -1
  6. package/dist/cli.js +487 -142
  7. package/dist/cli.js.map +1 -1
  8. package/dist/commands/assets.js +165 -29
  9. package/dist/commands/assets.js.map +1 -1
  10. package/dist/commands/call.js +131 -0
  11. package/dist/commands/call.js.map +1 -0
  12. package/dist/commands/context.js +11 -2
  13. package/dist/commands/context.js.map +1 -1
  14. package/dist/commands/files.js +117 -9
  15. package/dist/commands/files.js.map +1 -1
  16. package/dist/commands/guide.js +71 -0
  17. package/dist/commands/guide.js.map +1 -0
  18. package/dist/commands/init.js +213 -0
  19. package/dist/commands/init.js.map +1 -0
  20. package/dist/commands/login.js +37 -6
  21. package/dist/commands/login.js.map +1 -1
  22. package/dist/commands/tools.js +88 -80
  23. package/dist/commands/tools.js.map +1 -1
  24. package/dist/commands/use.js +148 -0
  25. package/dist/commands/use.js.map +1 -0
  26. package/dist/config.js +87 -6
  27. package/dist/config.js.map +1 -1
  28. package/dist/generated/guide.json +104 -0
  29. package/dist/generated/manifest.json +73 -24
  30. package/dist/guideCache.js +204 -0
  31. package/dist/guideCache.js.map +1 -0
  32. package/dist/help.js +391 -34
  33. package/dist/help.js.map +1 -1
  34. package/dist/manifest.js +27 -0
  35. package/dist/manifest.js.map +1 -1
  36. package/dist/manifestCache.js +196 -0
  37. package/dist/manifestCache.js.map +1 -0
  38. package/dist/output.js +289 -30
  39. package/dist/output.js.map +1 -1
  40. package/dist/schema.js +281 -16
  41. package/dist/schema.js.map +1 -1
  42. package/dist/wait.js +33 -2
  43. package/dist/wait.js.map +1 -1
  44. package/package.json +2 -2
package/README.md CHANGED
@@ -2,38 +2,105 @@
2
2
 
3
3
  The Martini command-line interface for agents and scripts. Every tool the Martini MCP server exposes is a
4
4
  command with the same name; on top, a handful of compound commands do what no single tool does — upload local
5
- files, download and measure assets, block until work settles, edit project memory files as a directory, and sign
6
- in. One HTTPS request per call, a static key, no MCP session.
5
+ files, download and measure assets, block until work settles, edit project memory files as a directory, print the
6
+ operator rules, set a repository up for agents, and sign in. One HTTPS request per call, a static key, no MCP
7
+ session.
8
+
9
+ A shell means the CLI: an agent that has one (Claude Code, Codex, Cursor, …) uses `martini` for every Martini
10
+ task, even with the MCP connector installed. The connector is for hosts without a shell (Claude Desktop, ChatGPT,
11
+ claude.ai). Both reach the same tools with the same names and arguments.
7
12
 
8
13
  ```bash
9
- npx @martini-film/cli --help # or: pnpm add -g @martini-film/cli → martini
14
+ npm install --global @martini-film/cli # puts martini on PATH; or run each command as npx @martini-film/cli <command>
10
15
  martini login # pair this device through the browser (90-day key); --no-wait to return at once, rerun to collect
11
- martini get_board_overview --project <id> # any MCP tool, flags from its arguments
16
+ martini guide # the operator rules an MCP agent gets at connect, by topic
17
+ martini init --write # install the agent skill and the AGENTS.md pointer in this repo
18
+ martini use "<project name or id>" # this directory now works in that project (and its canvas)
19
+ martini get_board_overview # any MCP tool, flags from its arguments
12
20
  martini get_asset --asset-id <id> --fields asset.status,asset.imageUrl
13
- martini upload ./ref.png ./take.mp4 --canvas <id>
14
- martini create_node_and_generate --canvas-id <id> --prompt "…" --reference-images <url> --wait
21
+ martini upload ./ref.png ./take.mp4
22
+ martini create_node_and_generate --prompt "…" --reference-images <url> --wait
15
23
  martini wait <asset-id…> # resume a wait; exit 4 with the pending ids on timeout
24
+ martini inspect_video --video-asset-ids <id> <id> --out-dir review # a contact sheet per shot, and which file is which
16
25
  martini files pull ./memory && martini files push ./memory
17
26
  martini probe <path|asset-id>… # duration, resolution, fps, codecs, sha256 (needs ffprobe)
27
+ martini tools # how the server's tool list differs from this build's
28
+ martini call <tool> --args @args.json # a tool by name, for one no tool list shows
18
29
  ```
19
30
 
20
31
  ## How commands are generated
21
32
 
22
- `martini <tool>` exists for every entry of the tool manifest the build carries — the same list the Martini
23
- MCP server publishes; `martini tools` says when the server has a newer one. Flags are derived from each tool's JSON Schema: `assetId` becomes `--asset-id`, arrays take the values
33
+ `martini <tool>` exists for every entry of the tool manifest — the list the Martini MCP server publishes at
34
+ `GET /v1/tools`, filtered to what your key can call. The build carries one (the baked manifest, the offline
35
+ fallback). The CLI also keeps the server's list in a cache, one file per API URL and credential under
36
+ `$XDG_CACHE_HOME/martini/` (else `~/.cache/martini/`), named by a short sha256 fingerprint of the key (never the
37
+ key) and readable only by you; commands run with the cached list when there is one, so a tool or argument the
38
+ server added after this build works without an update.
39
+
40
+ The list is refreshed — one `GET /v1/tools` with `If-None-Match`, a 304 while it is unchanged — only where that
41
+ can change the answer, at most once per command: an unknown command (refreshed, then dispatched again), an
42
+ unknown flag on a known tool (refreshed, then parsed again), and `martini tools` (`--refresh` fetches it whole).
43
+ An ordinary command never waits on it. A refresh that fails keeps the list in use and prints one
44
+ `MANIFEST_REFRESH_FAILED` warning on stderr; a corrupt cache is ignored the same way. `MARTINI_MANIFEST_REFRESH=0`
45
+ turns every refresh off (CI, offline, tests); a cached list still applies. A workflow run key never caches or
46
+ refreshes: its tools are the run's own. `martini tools` names what the server has that this build lacks
47
+ (`serverOnly`), the reverse (`buildOnly`), and the tools whose arguments differ (`changed`); `martini version`
48
+ says which list is in use. A tool no list shows is still reachable: `martini call <tool> --args '{…}'` sends the
49
+ call by name with exactly those arguments — no flags, no local checks, no context beyond `--project` /
50
+ `--canvas` / `--run` typed on it. `--out` with a media name needs `--raw` there: by name, the CLI cannot tell a picture
51
+ from a result.
52
+
53
+ The operator guide — the rules an MCP agent receives when it connects, worded for the CLI — is kept the same way
54
+ and in the same directory: the build carries one (`src/generated/guide.json`), the server publishes the current
55
+ one at `GET /v1/guide?transport=cli`, and the last one the server gave a credential is cached as
56
+ `guide-<url hash>-<key fingerprint>.json` (0600, no key inside). Only `martini guide` reads or refreshes it — one
57
+ request with `If-None-Match` per run, `--refresh` for a whole fetch; no other command fetches it. Every tool
58
+ and manifest answer does carry `X-Martini-Guide-Hash`, the hash of the guide the server serves now: when it
59
+ differs from the copy this CLI has, the next command prints one `GUIDE_CHANGED` warning (once per server hash,
60
+ not per command) that says to run `martini guide` again; reading the guide ends the warning.
61
+ `MARTINI_MANIFEST_REFRESH=0` turns the request off (the cached guide, else the baked one, is printed); a failed
62
+ request prints the copy in use with one `GUIDE_REFRESH_FAILED` warning; with no key, or a workflow run key, the
63
+ baked guide is printed and nothing is asked or cached. One stderr line says which copy was printed.
64
+
65
+ Flags are derived from each tool's JSON Schema: `assetId` becomes `--asset-id`, arrays take the values
24
66
  after the flag (`--node-ids a b`), a repeated flag, or a JSON list, objects take JSON, a `string | null` argument takes the literal `null` to clear it, a
25
67
  `"start" | "end" | {…}` union takes the bare word, and `--args '{…}'` / `--args @args.json` passes the whole
26
68
  arguments object (`--json` is an alias, except on a tool whose own argument is named `json`) — so a plan a script
27
69
  computed is submitted without retyping it. A tool argument named like a global flag (`fields` on `get_models`) is
28
70
  spelled `--tool-<name>`. `--no-context` sends only what you typed, for tools that refuse a
29
- `projectId` next to another selector. `martini <tool> --help` prints the tool's own description, every flag with
30
- its type and whether it is required, the result fields when the tool declares them (as `--fields` paths), and one
31
- example.
71
+ `projectId` next to another selector. A list of objects also reads a file (`--nodes @nodes.json`), and an
72
+ argument that names an asset (`--asset-id`, `--video-asset-ids`, …) takes either spelling a result prints: the
73
+ bare id, or the node id `asset-<id>`.
74
+
75
+ `martini <tool> --help` prints the tool's own description, every flag with its type and whether it is required,
76
+ the result fields when the tool declares them (as `--fields` paths), and an example built from the schema that
77
+ runs as written (`martini create_nodes --project <project-id> --canvas <canvas-id> --nodes '[{"nodeType":"video"}]'`).
78
+ Help is sized to a first call: a tool with more than a dozen flags lists its optional ones on a line each (name,
79
+ type, first sentence) and its result fields as deep as fit in thirty lines, and says at the end what it shortened;
80
+ `--help --all` prints the whole page (`create_node`: 9 KB instead of 16). A tool that answers with media
81
+ (`view_asset`, `inspect_video`, `render_timeline_frame`, …) gets an `Output:` block saying how to save it.
82
+
83
+ Under each JSON flag one line names the keys it takes — `shape: { x*, y*, width, height }` for an object (`*` marks
84
+ a required key), `each: { … }` for a list of objects, `one of:` for a union — and a `Rules:` block spells out the
85
+ tool's own `oneOf` / `anyOf` (`Exactly one of: --video-asset-id | --video-asset-ids`). Every key is named, and a
86
+ required key that is itself a small object shows its own (`source*: { assetIds, shotNumbers }`). `martini <tool>
87
+ --schema <flag>` prints that argument's full JSON Schema as indented JSON (`--schema` alone prints the whole input
88
+ schema), from the tool list in use, with no key and no request; `--schema <flag> --keys` prints one line per key
89
+ instead — name, type, first sentence — which is what a 20 KB schema says about names and types in about four.
32
90
 
33
91
  `projectId`, `canvasId`, and `runId` are filled from context when a tool takes them and the caller did not say:
34
- `--project` / `--canvas` / `--run`, else `MARTINI_PROJECT_ID` / `MARTINI_CANVAS_ID` / `MARTINI_RUN_ID`, else the
35
- config file. A typed selector that replaces one of them keeps it out (`get_board_overview --project-query`,
36
- `run_workflow --workflow-id`, which runs a saved workflow on a canvas of its own).
92
+ `--project` / `--canvas` / `--run`, else `MARTINI_PROJECT_ID` / `MARTINI_CANVAS_ID` / `MARTINI_RUN_ID`, else what
93
+ `martini use` set for the directory, else the config file. A typed selector that replaces one of them keeps it
94
+ out (`get_board_overview --project-query`, `run_workflow --workflow-id`, which runs a saved workflow on a canvas
95
+ of its own).
96
+
97
+ `martini use <project-id|name> [--canvas <id|name>]` is how an agent sets the project: it checks the project with
98
+ one read, and writes `.martini/context.json` in the working directory (`{ projectId, projectName, canvasId?,
99
+ canvasName?, apiUrl }`). Every later command run in that directory tree reads it. An agent's shell is new on every
100
+ command, so an exported variable does not last; a file beside the work does. The file holds no credential, is
101
+ ignored under another `--api-url` (with a `CONFIG_WARNING`), and a flag or variable that names another project
102
+ replaces it whole — its canvas is never sent with someone else's project. `martini use` alone prints it;
103
+ `--clear` removes it; `martini whoami` shows what is in effect.
37
104
 
38
105
  ## Credentials and context
39
106
 
@@ -41,7 +108,8 @@ Most specific first:
41
108
 
42
109
  1. Flags: `--api-key`, `--api-url`, `--profile`.
43
110
  2. Environment: `MARTINI_API_KEY`, `MARTINI_API_URL`, `MARTINI_PROFILE`, `MARTINI_CONFIG_FILE`.
44
- 3. The nearest `.martini/config.json` above the working directory — a Martini workflow run provides one.
111
+ 3. The nearest `.martini/config.json` above the working directory — a Martini workflow run provides one. A file
112
+ there without a key adds its `projectId` / `canvasId` to the profile below instead of hiding it.
45
113
  4. `~/.config/martini/config.json` — the profiles `martini login` saves, with a default (the key `default`). Approving "as you" saves the profile `account`, a key that acts in every organization you belong to; approving for one organization saves a profile named after it (`test-team`). Tools run as you either way and the project you name decides who is billed; an organization key additionally reaches that organization's REST API and is listed in its Settings.
46
114
 
47
115
  `--project-id`, `--canvas-id`, and `--run-id` (the tools' spelling) are accepted wherever `--project`, `--canvas`,
@@ -53,24 +121,56 @@ needs CLI 0.3.0 or newer; the approval page offers only what the CLI that asked
53
121
 
54
122
  ## Output and exit codes
55
123
 
56
- Results are JSON on stdout — compact when piped, indented on a terminal. `--fields a,b.c` keeps only those
57
- dotted paths, applied on the server so a large listing never crosses the wire; a `*` segment steps into every value of
58
- an id-keyed map (`assets.*.status`) and is applied in the CLI. With `--wait` (including default
59
- waits), the CLI keeps the submission identifiers for polling and applies `--fields` to the final result.
60
- `--out <path>` writes the result
61
- (or, with `--raw`, the media bytes of tools like `view_asset`) to a file and prints one summary line. Printed to
62
- stdout, a media block is a stub (`mimeType`, `bytes`, a hint) rather than base64, and `--raw` to a terminal without
63
- `--out` is a usage error. `--quiet` prints nothing on success. Errors are one JSON object on stderr: `{ "error": { "code", "message", "hint", "tool",
64
- "exitCode" } }`, with the tool's own MCP error code (`ASSET_NOT_READY`, `NODE_NOT_FOUND`, …).
65
-
66
- | Exit | Meaning |
67
- | ---- | -------------------------------------------- |
68
- | 0 | ok |
69
- | 1 | the tool failed |
70
- | 2 | usage: unknown command, missing or bad flags |
71
- | 3 | no key, or the key is invalid / expired |
72
- | 4 | not ready or timed out (pending ids named) |
73
- | 5 | insufficient olives |
124
+ **Exit 0 means the command did everything it was asked.** Anything else is non-zero, with one JSON object on
125
+ stderr — `{ "error": { "code", "message", "hint", "tool", "exitCode" } }`, the tool's own MCP error code where
126
+ there is one (`ASSET_NOT_READY`, `NODE_NOT_FOUND`, …). A command that did part of its work prints that part on
127
+ stdout as well, so nothing it produced is lost: a timed-out wait's `pending` ids, a push's `skipped` files, the
128
+ quote a cap refused.
129
+
130
+ Results are JSON on stdout — compact when piped, indented on a terminal — except the text commands (`guide`,
131
+ `init` without `--write`, `files cat`, `--help`), which print text. Warnings are JSON on stderr too
132
+ (`{ "warning": { "code", "message" } }`) and never change stdout or the exit code. `--quiet` prints nothing on
133
+ success.
134
+
135
+ `--fields a,b.c` keeps only those dotted paths. A field that is a map keyed by id is stepped into for you
136
+ (`assets.status` on `get_board_assets`), or explicitly with a `*` segment, quoted for the shell
137
+ (`'assets.*.status'`). A path that matches nothing while others match is named in a `FIELDS_NOT_FOUND` warning.
138
+ When no path matches, the answer depends on what the command did: a read exits 2 (`NO_FIELDS_MATCHED`, naming the
139
+ result's top-level fields) and prints nothing; a command that wrote something prints its whole result with the
140
+ warning and exits 0, because the ids it made must not be lost to a typo and it must not be run twice. The server
141
+ trims the result of a read whose result schema the CLI knows; everything else is trimmed here, after any wait.
142
+
143
+ `--out <path>` writes the result to a file and prints a one-line JSON receipt, `{ path, bytes, summary }`. When
144
+ the path has a media extension (`.jpg`, `.png`, `.webp`, `.mp3`, `.wav`, …) it writes the media bytes of a
145
+ one-media result instead (`view_asset`, `render_timeline_frame`), and the receipt carries the tool's own metadata:
146
+ `{ path, bytes, contentType, result }`. `--raw` asks for the bytes whatever the file is called, and streams them
147
+ to a pipe; to a terminal it is a usage error. Only the path the flag names is ever written. A name whose
148
+ extension contradicts the bytes (`still.png` for `image/webp`) would make a reader that trusts the extension refuse
149
+ the file: from a read nothing is written and it is a usage error naming the right extension (exit 2; running it
150
+ again costs nothing), and from a tool that already did its work the file is written as named with an
151
+ `EXTENSION_MISMATCH` warning. `martini call <tool> --raw` cannot tell a read from a write, so it always takes the
152
+ second way. A name that claims no media type (`--raw --out sheet.json`) is your choice and is
153
+ written as given. Every receipt names its file whole, resolved from the working directory. JSON is never saved under an image name: on a read, a
154
+ result without exactly one media block is a usage error; a tool that writes (`extract_video_frame`) is called once
155
+ and its picture taken from the result, and when it has none its result is printed whole with an `OUT_NOT_MEDIA`
156
+ warning. `--fields` trims the receipt (`--fields path,result.assetId`).
157
+
158
+ `--out-dir <dir>` (read-only tools) writes every media block to its own file and prints
159
+ `{ dir, files: [{ path, mimeType, bytes, about }], notes? }`. A file is named by the asset the text block beside
160
+ it names — `<i>-<id>.jpg` from a batch's `Asset <id> (i/n)` header, `<id>.png` from a JSON text block's `assetId`,
161
+ else `block-<n>.<ext>` — and `about` is that text block parsed (asset id, shot number, duration, …), so the review
162
+ needs no second call. A batch item that failed writes nothing and appears under `notes`. Printed without either
163
+ flag, a media block is a stub (`mimeType`, `bytes`, a hint), and `inspect_video` prints its ordered blocks, each
164
+ asset's text before its sheet, a text that is JSON as `{ "type": "text", "label", "json" }`.
165
+
166
+ | Exit | Meaning |
167
+ | ---- | ------------------------------------------------------------------- |
168
+ | 0 | done, all of it |
169
+ | 1 | the tool failed, part of the work did not land, or what was waited for failed (see stdout) |
170
+ | 2 | usage: unknown command, missing or bad flags, `--fields` on a read that matched nothing |
171
+ | 3 | no key, or the key is invalid / expired |
172
+ | 4 | not ready or timed out (pending ids named) |
173
+ | 5 | over budget: not enough olives, or a quote over `--max-olives` |
74
174
 
75
175
  ## Waiting
76
176
 
@@ -79,19 +179,25 @@ adds `waited` to the result; it is on by default for single-item generation and
79
179
  tools, where you fan out and then `martini wait <ids…>` once. `waited` has one shape whatever was waited on:
80
180
  `{ kind, status, assets? | job? | run? | delivery? }` — `status` is the terminal status (for assets, `failed` when
81
181
  any failed) and the settled records sit under the key that names them; `martini wait` prints the same object.
182
+ Exit 0 means what was waited for completed. A shot, job, render, or run that settles on `failed`, `cancelled`, or
183
+ `needs_revision` prints that same object and exits 1 (`ASSET_FAILED`, `JOB_FAILED`, `RUN_NEEDS_REVISION`, …), so a
184
+ script that goes on to review or cut never does it with a shot that is not there. `martini upload` follows the same
185
+ rule: a file storage refused (`UPLOAD_INCOMPLETE`) or one that failed processing exits 1 with the receipt on stdout.
82
186
  `--timeout <seconds>` (default `MARTINI_WAIT_TIMEOUT_SECONDS` when set, else 50; a malformed value is a usage error) ends the wait with exit 4: the
83
- result the command produced is still printed on stdout, with `pending` (and `settled`) ids, and the error on
84
- stderr names the `martini wait …` command that resumes it. Size `--timeout` to what your shell step allows — a
85
- video generation takes minutes.
187
+ result the command produced is still printed on stdout, with `pending` (and `settled`) ids — `martini wait` itself
188
+ prints `{ kind, status: "pending", pending, settled }` — and the error on stderr names the `martini wait …`
189
+ command that resumes it, project included, so it runs as written in a new shell. Size `--timeout` to what your
190
+ shell step allows — a video generation takes minutes.
86
191
 
87
192
  ## Approving a quote
88
193
 
89
194
  `generate_nodes`, `upscale_assets`, and `enhance_draft` answer a quote first (`approvalNeeded: true`, `planHash`,
90
195
  the estimated olives) and start nothing until called again with that `planHash` (plus `batchRequestId` for
91
196
  upscales) and the approval argument. `--approve --max-olives <n>` does both in one command: it takes the quote,
92
- refuses when the estimated total is over the cap (`PLAN_OVER_BUDGET`) or has no number (`PLAN_UNPRICED`), with
93
- the quote on stdout and nothing started, and otherwise re-calls the tool with exactly what it asked for; the
94
- result carries `approvedPlan`. The cap is required: an approval always states how much it is for. A tool with an
197
+ refuses when the estimated total is over the cap (`PLAN_OVER_BUDGET`) or has no number (`PLAN_UNPRICED`) — exit 5,
198
+ nothing started, the quote on stdout with `overCap: { quotedOlives, maxOlives }` — and otherwise re-calls the tool
199
+ with exactly what it asked for; the result carries `approvedPlan`. Exit 5 is the one refusal to take to the person:
200
+ they raise the cap, or the batch gets smaller. The cap is required: an approval always states how much it is for. A tool with an
95
201
  approval argument but no quote step (`create_nodes_and_generate`) is only attested by `--approve` and cannot be
96
202
  capped — for a capped batch, `create_nodes` then `generate_nodes --approve --max-olives <n>`.
97
203
 
@@ -99,14 +205,33 @@ capped — for a capped batch, `create_nodes` then `generate_nodes --approve --m
99
205
 
100
206
  | Command | Does |
101
207
  | ------------------------------------ | ----------------------------------------------------------------------------------------------------- |
102
- | `login`, `logout`, `whoami` | device-code pairing (a started pairing is resumed by running `login` again; `--no-wait` returns at once), forget a profile, who the CLI acts as |
103
- | `tools`, `models` | the manifest this build knows (and whether the server has a newer one); the cached model catalog |
104
- | `upload <paths…>` | prepare → PUT → complete from local files, then wait for processing |
208
+ | `login`, `logout`, `whoami` | device-code pairing (a started pairing is resumed by running `login` again, or replaced when under two minutes are left on it; `--no-wait` returns at once with `expiresInSeconds`), forget a profile, who the CLI acts as and in which project |
209
+ | `use [<project>] [--canvas <c>]` | the project and canvas for this directory (`.martini/context.json`), by id or name; `--clear` forgets it |
210
+ | `tools`, `models` | how the server's tool list differs from this build's (`--list` adds every tool, about 70 KB; `--refresh`); the cached model catalog |
211
+ | `call <tool> --args <json\|@file>` | a tool call by name with exactly those arguments, for a tool neither list shows |
212
+ | `upload <paths…>` | prepare → PUT → complete from local files, each declared as external material in its lineage where the server takes one (`--lineage <json\|@file>` overrides), then wait for processing |
105
213
  | `download <ids…>` | presigned URL → bytes → file |
106
214
  | `wait <ids…> \| --job \| --run \| --render` | block until assets, a job, a run, or a render settles |
107
- | `files ls\|cat\|write\|pull\|push` | project memory files as a directory; `push` refuses a file edited server-side since the pull |
215
+ | `files ls\|cat\|write\|pull\|push` | project memory files as a directory; neither direction loses an edit silently (below) |
108
216
  | `probe <path\|id>…` | ffprobe + sha256 in one JSON report |
109
- | `init [--write]` | the AGENTS.md snippet that teaches a repo's agents to use the CLI |
217
+ | `guide [topic] [--list]` | the operator rules by topic (`orientation`, `library`, `timeline`, `generation`, `storage`, `support`, `shell`); `--list` gives each topic's size; read once per session |
218
+ | `init [--write] [--force] [--dir <repo>]` | the agent skill and a three-line AGENTS.md pointer; printed without `--write`, installed with it |
219
+
220
+ `martini files pull <dir>` writes every file plus `.martini/files.json` (path → `updatedAt`, sha256).
221
+ `martini files push <dir>` sends only what changed, each write guarded by the version it was pulled at. A file
222
+ that changed on the server meanwhile is refused (`PROJECT_FILE_CHANGED`, listed under `skipped`), and a push that
223
+ skipped anything exits 1 with its result on stdout. `behind` lists files the server has newer, or new, that were
224
+ not touched here (`null`, with a `BEHIND_UNKNOWN` warning, when listing them failed after the push). A pull never overwrites a file edited since the last one: it is kept (`kept`), and when the
225
+ server's copy changed too, that copy is written to `.martini/conflicts/<path>`, the file is listed under
226
+ `conflicts`, and the pull exits 1 (`PULL_CONFLICT`). Merge what you need, delete the copy, and push; until then
227
+ push skips that file (`UNRESOLVED_CONFLICT`). `--force` overwrites, in either direction.
228
+
229
+ `martini init --write` installs a short agent skill at `.agents/skills/martini/SKILL.md` (Codex, Cursor, and
230
+ other agents read it) and `.claude/skills/martini/SKILL.md` (Claude Code; skipped when `.claude/skills` links to
231
+ `.agents/skills`), and appends a three-line `## Martini CLI` pointer to `AGENTS.md` unless the section is there.
232
+ The skill routes the agent to the CLI and points at `martini guide` and `martini <tool> --help` for the detail. A
233
+ skill file with other content is kept unless `--force`; `--dir <repo>` installs into another directory; nothing
234
+ outside it is written. Run it again after an update to refresh the skill (`--force` replaces an older copy).
110
235
 
111
236
  ## Single-file binary
112
237
 
package/dist/api.js CHANGED
@@ -1,24 +1,60 @@
1
1
  import { detectHostAgent } from './host.js';
2
- export const CLI_VERSION = '0.3.0';
2
+ export const CLI_VERSION = '0.4.1';
3
3
  export class CliApiError extends Error {
4
4
  code;
5
5
  status;
6
6
  tool;
7
7
  result;
8
+ hint;
8
9
  constructor(message, details) {
9
10
  super(message);
10
11
  this.name = 'CliApiError';
11
12
  this.code = details.code;
12
13
  this.status = details.status;
13
14
  this.tool = details.tool ?? null;
15
+ this.hint = details.hint;
14
16
  }
15
17
  }
18
+ export function noApiKeyError(config) {
19
+ const url = config.contextApiUrl;
20
+ return new CliApiError('No Martini API key. Run martini login, or set MARTINI_API_KEY.', {
21
+ code: 'NO_API_KEY',
22
+ status: 0,
23
+ ...(url
24
+ ? {
25
+ hint: `This directory's project (martini use) is on ${url}. Sign in for it: martini login --api-url ${url} (an agent adds --no-wait, tells the person the code, and runs it again once they approved), or set MARTINI_API_KEY with MARTINI_API_URL=${url}.`,
26
+ }
27
+ : {}),
28
+ });
29
+ }
30
+ export function isTextBlock(block) {
31
+ return block.type === 'text' && typeof block.text === 'string';
32
+ }
33
+ export function isMediaBlock(block) {
34
+ return block.type === 'image' || block.type === 'audio';
35
+ }
36
+ function isBlocksBody(body) {
37
+ if (!body || typeof body !== 'object' || Array.isArray(body))
38
+ return false;
39
+ const blocks = body.blocks;
40
+ return (Array.isArray(blocks) &&
41
+ blocks.every(block => block !== null &&
42
+ typeof block === 'object' &&
43
+ !Array.isArray(block) &&
44
+ typeof block.type === 'string'));
45
+ }
46
+ export const MANIFEST_FETCH_TIMEOUT_MS = 15_000;
16
47
  export function userAgent(env = process.env) {
17
48
  const host = detectHostAgent(env);
18
49
  return `martini-cli/${CLI_VERSION}${host ? ` (${host})` : ''}`;
19
50
  }
20
51
  export function createApiClient(config, options = {}) {
21
- const fetchImpl = options.fetch ?? fetch;
52
+ const baseFetch = options.fetch ?? fetch;
53
+ const fetchImpl = async (input, init) => {
54
+ const response = await baseFetch(input, init);
55
+ options.onResponse?.(response);
56
+ return response;
57
+ };
22
58
  const env = options.env ?? process.env;
23
59
  function headers(extra = {}) {
24
60
  const base = {
@@ -55,12 +91,8 @@ export function createApiClient(config, options = {}) {
55
91
  });
56
92
  }
57
93
  function requireKey() {
58
- if (!config.apiKey) {
59
- throw new CliApiError('No Martini API key. Run martini login, or set MARTINI_API_KEY.', {
60
- code: 'NO_API_KEY',
61
- status: 0,
62
- });
63
- }
94
+ if (!config.apiKey)
95
+ throw noApiKeyError(config);
64
96
  }
65
97
  async function requestJson(path, init = {}) {
66
98
  const response = await fetchImpl(`${config.apiUrl}${path}`, {
@@ -91,6 +123,32 @@ export function createApiClient(config, options = {}) {
91
123
  ...(options.signal ? { signal: options.signal } : {}),
92
124
  });
93
125
  },
126
+ async callToolBlocks(name, args, options) {
127
+ requireKey();
128
+ const query = new URLSearchParams({ format: 'blocks', media: options.media });
129
+ const response = await fetchImpl(`${config.apiUrl}/v1/tools/${encodeURIComponent(name)}?${query}`, {
130
+ method: 'POST',
131
+ headers: headers({ 'Content-Type': 'application/json' }),
132
+ body: JSON.stringify(args),
133
+ });
134
+ if (!response.ok)
135
+ throw await readError(response, name);
136
+ let body;
137
+ try {
138
+ body = await response.json();
139
+ }
140
+ catch {
141
+ body = undefined;
142
+ }
143
+ if (!isBlocksBody(body)) {
144
+ throw new CliApiError(`The API answered ${name} with format=blocks but no list of blocks.`, {
145
+ code: 'INVALID_RESPONSE',
146
+ status: response.status,
147
+ tool: name,
148
+ });
149
+ }
150
+ return body;
151
+ },
94
152
  async callToolRaw(name, args) {
95
153
  requireKey();
96
154
  const response = await fetchImpl(`${config.apiUrl}/v1/tools/${encodeURIComponent(name)}?format=raw`, {
@@ -120,32 +178,22 @@ export function createApiClient(config, options = {}) {
120
178
  requireKey();
121
179
  return requestJson('/v1/tools', { method: 'GET' });
122
180
  },
123
- async serverManifestHash(localHash) {
181
+ async fetchManifest(ifNoneMatch) {
124
182
  requireKey();
125
183
  const response = await fetchImpl(`${config.apiUrl}/v1/tools`, {
126
184
  method: 'GET',
127
- headers: headers({ 'If-None-Match': `"${localHash}"` }),
185
+ headers: headers(ifNoneMatch ? { 'If-None-Match': `"${ifNoneMatch}"` } : {}),
186
+ signal: AbortSignal.timeout(MANIFEST_FETCH_TIMEOUT_MS),
128
187
  });
129
188
  if (response.status === 304)
130
- return localHash;
189
+ return { notModified: true };
131
190
  if (!response.ok)
132
191
  throw await readError(response);
133
192
  const etag = response.headers
134
193
  .get('etag')
135
194
  ?.replace(/^W\//, '')
136
195
  .replace(/^"(.*)"$/, '$1');
137
- if (etag) {
138
- await response.body?.cancel().catch(() => undefined);
139
- return etag;
140
- }
141
- const body = (await response.json());
142
- if (typeof body.hash !== 'string') {
143
- throw new CliApiError('The server answered GET /v1/tools without a manifest hash.', {
144
- code: 'INVALID_RESPONSE',
145
- status: response.status,
146
- });
147
- }
148
- return body.hash;
196
+ return { notModified: false, body: await response.json(), etag: etag ?? null };
149
197
  },
150
198
  async me() {
151
199
  requireKey();
package/dist/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAG3C,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAA;AAqBlC,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,IAAI,CAAQ;IACZ,MAAM,CAAQ;IACd,IAAI,CAAe;IAE5B,MAAM,CAAU;IAChB,YAAY,OAAe,EAAE,OAA+D;QAC1F,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,aAAa,CAAA;QACzB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QACxB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAA;IAClC,CAAC;CACF;AAmBD,MAAM,UAAU,SAAS,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC5D,MAAM,IAAI,GAAG,eAAe,CAAC,GAAG,CAAC,CAAA;IACjC,OAAO,eAAe,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;AAChE,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAAsB,EAAE,UAA4B,EAAE;IACpF,MA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AC,MAAM;iBACxB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
package/dist/approve.js CHANGED
@@ -54,7 +54,8 @@ export async function runWithApproval(tool, client, args, support, options) {
54
54
  }
55
55
  if (total > maxOlives) {
56
56
  const error = new CliApiError(`${tool.name} quoted ${total} olives, over the --max-olives ${maxOlives} cap; nothing was started.`, { code: 'PLAN_OVER_BUDGET', status: 0, tool: tool.name });
57
- error.result = quote;
57
+ const { nextSteps: _nextSteps, ...plan } = quote;
58
+ error.result = { ...plan, overCap: { quotedOlives: total, maxOlives } };
58
59
  throw error;
59
60
  }
60
61
  const count = itemCount(quote, args);
@@ -69,15 +70,29 @@ export async function runWithApproval(tool, client, args, support, options) {
69
70
  ...(batchRequestId ? { batchRequestId } : {}),
70
71
  [support.argument]: approval,
71
72
  });
73
+ const items = approvedItems(quote);
72
74
  const approvedPlan = {
73
75
  planHash: quote.planHash,
74
76
  ...(batchRequestId ? { batchRequestId } : {}),
75
77
  itemCount: count,
76
78
  estimatedOlives: total,
77
79
  maxOlives,
80
+ ...(items.length ? { items } : {}),
78
81
  };
79
82
  return result && typeof result === 'object' && !Array.isArray(result)
80
83
  ? { ...result, approvedPlan }
81
84
  : { result, approvedPlan };
82
85
  }
86
+ function approvedItems(quote) {
87
+ const listed = Array.isArray(quote.items) ? quote.items : Array.isArray(quote.plan) ? quote.plan : [];
88
+ return listed.flatMap(entry => {
89
+ if (!entry || typeof entry !== 'object')
90
+ return [];
91
+ const item = entry;
92
+ const kept = Object.fromEntries(['nodeId', 'displayName', 'modelId', 'estimatedOlives', 'promptBrief']
93
+ .filter(key => item[key] !== undefined)
94
+ .map(key => [key, item[key]]));
95
+ return Object.keys(kept).length ? [kept] : [];
96
+ });
97
+ }
83
98
  //# sourceMappingURL=approve.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"approve.js","sourceRoot":"","sources":["../src/approve.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,WAAW,EAAkB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