codeer-cli 0.1.14__tar.gz → 0.1.16__tar.gz

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 (48) hide show
  1. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/API_REFERENCE.md +55 -15
  2. codeer_cli-0.1.16/PKG-INFO +479 -0
  3. codeer_cli-0.1.16/README.md +461 -0
  4. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/pyproject.toml +1 -1
  5. codeer_cli-0.1.16/src/codeer_cli/_http_contracts.py +109 -0
  6. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/_validate.py +8 -2
  7. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/agents.py +1 -1
  8. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/cli.py +8 -2
  9. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/client.py +4 -3
  10. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/commands/_util.py +7 -2
  11. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/commands/agent.py +31 -10
  12. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/commands/history.py +142 -9
  13. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/commands/kb.py +400 -0
  14. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/eval_.py +5 -2
  15. codeer_cli-0.1.16/src/codeer_cli/histories.py +359 -0
  16. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/kb.py +0 -1
  17. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/tests/test_client_transport.py +16 -0
  18. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/tests/test_eval_pairs.py +5 -2
  19. codeer_cli-0.1.16/tests/test_history_read.py +847 -0
  20. codeer_cli-0.1.16/tests/test_http_contracts.py +587 -0
  21. codeer_cli-0.1.16/tests/test_kb_export.py +185 -0
  22. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/tests/test_kb_nodes.py +24 -0
  23. codeer_cli-0.1.16/tests/test_util.py +114 -0
  24. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/uv.lock +1 -1
  25. codeer_cli-0.1.14/PKG-INFO +0 -292
  26. codeer_cli-0.1.14/README.md +0 -274
  27. codeer_cli-0.1.14/src/codeer_cli/histories.py +0 -178
  28. codeer_cli-0.1.14/tests/test_history_read.py +0 -132
  29. codeer_cli-0.1.14/tests/test_util.py +0 -22
  30. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/.gitignore +0 -0
  31. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/__init__.py +0 -0
  32. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/chats.py +0 -0
  33. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/commands/__init__.py +0 -0
  34. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/commands/check.py +0 -0
  35. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/commands/eval_cmd.py +0 -0
  36. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/commands/model.py +0 -0
  37. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/commands/profile.py +0 -0
  38. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/constants.py +0 -0
  39. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/models.py +0 -0
  40. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/src/codeer_cli/parse.py +0 -0
  41. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/tests/test_agent_handoff.py +0 -0
  42. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/tests/test_agent_model_settings.py +0 -0
  43. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/tests/test_chats_v2.py +0 -0
  44. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/tests/test_eval_evaluators.py +0 -0
  45. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/tests/test_eval_labels.py +0 -0
  46. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/tests/test_history_send.py +0 -0
  47. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/tests/test_kb_ranges.py +0 -0
  48. {codeer_cli-0.1.14 → codeer_cli-0.1.16}/tests/test_models.py +0 -0
@@ -9,7 +9,9 @@ endpoints authenticate via `x-api-key` from `CODEER_API_KEY`.
9
9
 
10
10
  Envelope: successful responses look like
11
11
  `{"error_code": 0, "message": "", "pagination": null, "data": <payload>}`.
12
- The client unwraps `data` automatically; errors raise `CodeerError`.
12
+ The client unwraps `data` automatically; errors raise `CodeerError`. Reads that
13
+ need top-level pagination can pass `unwrap=False` to preserve the validated
14
+ success envelope.
13
15
 
14
16
  **Environment config split:**
15
17
  Auth means `CODEER_API_KEY`; it comes from the process environment only.
@@ -27,6 +29,11 @@ need a default agent.
27
29
  - `/histories` uses **`limit` + `offset`** (NOT `page` / `page_size`).
28
30
  Default in `histories.list()` is `limit=500`. Backend hard-cap may be
29
31
  lower — check the response length.
32
+ - `/external/histories/{id}/ai-drafts` uses **`limit` + `offset`**, with
33
+ pagination in the response envelope. `histories.list_ai_drafts()` follows
34
+ every page and rejects total-count changes or duplicate IDs. It marks the
35
+ artifact `snapshot_consistency: best-effort` because the endpoint does not
36
+ expose a revision token.
30
37
  - `/api/v2/chats/{id}/messages` also uses `limit` + `offset`.
31
38
  `chats.list_messages()` follows pages until exhaustion; its `limit` argument
32
39
  is a page size, not a total-result cap.
@@ -84,6 +91,20 @@ Base path: `/organizations/{org_id}/workspaces/{ws_id}/knowledge_bases`
84
91
  | `POST .../files/status` | Batch-poll indexing status by node ID |
85
92
  | `GET .../{kb_id}/nodes/{node_id}/content` | Read a file's extracted content |
86
93
 
94
+ The workspace API-key external routes used by `codeer-cli` include:
95
+
96
+ | Method & path | Purpose |
97
+ | --- | --- |
98
+ | `GET /external/knowledge-bases/nodes?parent_id={node_id}` | List KB roots or direct children |
99
+ | `GET /external/knowledge-bases/files/{node_id}/content` | Read one file's extracted snapshot content |
100
+
101
+ `codeer kb export --node-id <file-id> --file <path>` maps directly to the second
102
+ route. `codeer kb export --node-id <folder-id> --dir <path>` recursively follows
103
+ the first route and calls the second route for every file. Any returned text is
104
+ written as UTF-8 Markdown regardless of indexing status, with that status
105
+ preserved in the manifest. A `null` content response cannot be exported. The
106
+ command does not reconstruct the originally uploaded binary file.
107
+
87
108
  Attach KB files to an agent by listing their node IDs in the agent's
88
109
  `unified_tools[].knowledge_node_ids`.
89
110
 
@@ -187,8 +208,8 @@ version; it does not currently replace this draft-pinning path.
187
208
  | `GET /eval/evaluators?wid=<ws>` | List evaluators |
188
209
  | `PUT /eval/evaluators/{id}` | Update |
189
210
  | `DELETE /eval/evaluators/{id}` | Delete |
190
- | `POST /eval/case-evaluator-infos:batch` | Read assigned evaluators/rubrics for cases |
191
- | `PUT /eval/cases/{case_id}/case-evaluator-infos` | Replace assigned evaluators/rubrics for one case |
211
+ | `POST /external/eval/case-evaluator-infos:batch` | Read assigned evaluators/rubrics for cases through the API-key facade |
212
+ | `PUT /external/eval/cases/{case_id}/case-evaluator-infos` | Replace assigned evaluators/rubrics for one case through the API-key facade |
192
213
  | `POST /eval/trigger` | Run explicit assigned `case_evaluator_pairs` pinned to `agent_history_id` |
193
214
  | `POST /eval/stop` | Cancel running case+evaluator combo |
194
215
  | `POST /eval/rubric` | Set/override the rubric for one (case, evaluator); also creates assignment |
@@ -275,12 +296,13 @@ the public CLI.
275
296
  | --- | --- |
276
297
  | `POST /api/v2/chats` | Create a persisted history using an agent's current published version |
277
298
  | `POST /api/v2/chats/{id}/messages` | Append a turn through structured SSE using the current published version |
278
- | `GET /api/v2/chats/{id}/messages` | Read persisted Chat V2 conversation parts |
279
- | `GET /histories?agent_id=X&feedback_filter=improve_feedback&external_user_id=…` | List conversations with filters |
280
- | `GET /histories/{id}` | Read one history's metadata |
281
- | `GET /histories/{id}/conversations` | Legacy compact conversation rows; not complete tool I/O |
282
- | `POST /histories/{hid}/conversations/{cid}/feedbacks` | Leave freeform improvement feedback |
283
- | `POST /histories/{hid}/conversations/{cid}/score` | Numeric score |
299
+ | `GET /api/v1/external/histories/{id}/messages` | Export persisted diagnostic parts for workspace editors (`history-parts-v1`) |
300
+ | `GET /api/v1/external/histories/{id}/ai-drafts` | Export AI Draft content, refinement signals, outcomes, tool activity, and actual delivery |
301
+ | `GET /api/v2/chats/{id}/messages` | Read client-visible parts under the external client-owner contract |
302
+ | `GET /api/v1/external/histories?agent_id=X&feedback_filter=improve_feedback&external_user_id=…&has_ai_drafts=true` | List conversations with filters and AI Draft lifecycle counts |
303
+ | `GET /api/v1/external/histories/{id}` | Read one history's metadata |
304
+ | `GET /api/v1/external/histories/{id}/conversations` | Legacy compact conversation rows; not complete tool I/O |
305
+ | `POST /api/v1/external/histories/{hid}/conversations/{cid}/feedbacks` | Leave freeform improvement feedback |
284
306
 
285
307
  The CLI exposes the first two operations as `codeer history create` and
286
308
  `codeer history send`. Messages explicitly set `stream: true`, consume Chat V2
@@ -289,6 +311,23 @@ per-message SSE read timeout defaults to 240 seconds. A timeout,
289
311
  `response.failed`, or disconnect before completion has an uncertain write
290
312
  outcome, so read the history before retrying to avoid duplicate turns.
291
313
 
314
+ `codeer history conversations` uses the management export by default. Pass
315
+ `--client-visible --user <external-user-id>` only to select the external Chat
316
+ V2 read contract explicitly. The management export includes persisted tool
317
+ calls/results but excludes system prompts and provider raw traces.
318
+
319
+ `codeer history ai-drafts <history-id> --out <path>` uses the AI Draft export
320
+ and follows every page. The artifact preserves `generation_instruction`,
321
+ `dismiss_feedback`, refinement ancestry, lifecycle outcome, tool activities,
322
+ proposed actions, and correlated delivery. Those are recorded improvement
323
+ signals, not a server-generated recommendation. Compare them with the History
324
+ parts and accepted Behavior Contract before proposing an Agent change. Default
325
+ stdout exposes only structural flags and counts; `--full --out <path>` opts into
326
+ bounded sensitive text previews. Because this endpoint has no revision token,
327
+ the artifact is marked `snapshot_consistency: best-effort`; total-count changes
328
+ and duplicate IDs are rejected, but field updates during pagination cannot be
329
+ detected.
330
+
292
331
  `feedback_filter` accepts the `FeedbackFilterType` enum values:
293
332
  `no_feedback`, `with_feedback`, `helpful_feedback`, `improve_feedback`.
294
333
 
@@ -491,12 +530,13 @@ you can and can't recover from each assistant turn:
491
530
  | Tool **outputs** (raw JSON returned by the tool) | same — stored only as derived `primary_sources` for retrieval tools |
492
531
  | Reasoning steps mid-turn | `meta.reasoning_steps` is currently always `null` |
493
532
 
494
- Chat V2 improves this contract: structured SSE emits tool calls and returns as
495
- `response.part.created` / `response.part.completed`, and
496
- `GET /api/v2/chats/{id}/messages` reads the persisted conversation parts.
497
- Capture the SSE artifact with `--out` when exact event order matters; use the
498
- paginated V2 message read for persisted after-the-fact tool I/O. The legacy V1
499
- history read remains useful for compact turn-level compatibility only.
533
+ Native parts improve this contract: structured SSE emits tool calls and returns
534
+ as `response.part.created` / `response.part.completed`, and the management
535
+ `GET /api/v1/external/histories/{id}/messages` export reads persisted
536
+ after-the-fact tool I/O for workspace editors. The client-owner
537
+ `GET /api/v2/chats/{id}/messages` route remains available for explicitly
538
+ client-visible reads. The legacy V1 history read remains useful for compact
539
+ turn-level compatibility only.
500
540
 
501
541
  ### 10. A KB has exactly ONE level of folders — no nesting
502
542
 
@@ -0,0 +1,479 @@
1
+ Metadata-Version: 2.5
2
+ Name: codeer-cli
3
+ Version: 0.1.16
4
+ Summary: Command line tools for managing Codeer agents over the Codeer API.
5
+ Project-URL: Homepage, https://www.codeer.ai
6
+ Author: Codeer.AI
7
+ License: MIT
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Topic :: Software Development
15
+ Requires-Python: >=3.11
16
+ Requires-Dist: httpx>=0.27
17
+ Description-Content-Type: text/markdown
18
+
19
+ # codeer-cli
20
+
21
+ Standalone CLI for managing Codeer agents over the Codeer API.
22
+
23
+ ## User install
24
+
25
+ Install the CLI from PyPI with `pipx`:
26
+
27
+ ```bash
28
+ pipx install codeer-cli
29
+ ```
30
+
31
+ Verify that the command is available:
32
+
33
+ ```bash
34
+ codeer --help
35
+ ```
36
+
37
+ If `pipx` is not installed:
38
+
39
+ ```bash
40
+ python -m pip install --user pipx
41
+ python -m pipx ensurepath
42
+ ```
43
+
44
+ Then restart the terminal and run:
45
+
46
+ ```bash
47
+ pipx install codeer-cli
48
+ ```
49
+
50
+ As a fallback, you can install into your user Python environment:
51
+
52
+ ```bash
53
+ python -m pip install --user codeer-cli
54
+ ```
55
+
56
+ ## Credentials
57
+
58
+ The CLI expects credentials to be configured outside any skill workspace. Add a
59
+ named profile, select it, then verify the setup:
60
+
61
+ ```bash
62
+ codeer profile add work
63
+ codeer profile use work
64
+ codeer check
65
+ ```
66
+
67
+ `codeer profile add` prompts for the API key without echoing it. The local
68
+ project stores only the selected profile name in `.codeer/profile`; API keys
69
+ remain in the user-level config file.
70
+
71
+ For a one-off shell session, you can also export an API key directly:
72
+
73
+ ```bash
74
+ export CODEER_API_KEY=<admin-workspace-api-key>
75
+ codeer check
76
+ ```
77
+
78
+ `CODEER_API_BASE` defaults to `https://api.codeer.ai`. Override it only for
79
+ local, beta, or preview environments:
80
+
81
+ ```bash
82
+ export CODEER_API_BASE=http://localhost:8000
83
+ ```
84
+
85
+ The CLI intentionally does not read repo-root credential files or caller CWD
86
+ `.env`, because those files are often visible to LLM workspace context. Do not
87
+ paste the API key into agent chat or commit it to the repository.
88
+
89
+ Workspace and organization scope are inferred from the workspace API-key
90
+ virtual user's profile. `--workspace`, `--org`, `CODEER_WORKSPACE_ID`, and
91
+ `CODEER_ORGANIZATION_ID` are not used by the CLI.
92
+
93
+ Agent scope is optional and can be set as a non-secret environment variable:
94
+
95
+ ```bash
96
+ CODEER_AGENT_ID=<agent-id>
97
+ ```
98
+
99
+ ## Development install
100
+
101
+ Codeer contributors should use an editable install from this checkout, not the
102
+ PyPI package, so the `codeer` command always executes the folder being edited:
103
+
104
+ ```bash
105
+ cd /path/to/codeer-skills/codeer-cli
106
+ uv tool install --editable .
107
+ ```
108
+
109
+ Reinstall only when dependencies, entry points, or package metadata change:
110
+
111
+ ```bash
112
+ uv tool install --reinstall --editable /path/to/codeer-skills/codeer-cli
113
+ ```
114
+
115
+ Validate setup before API work:
116
+
117
+ ```bash
118
+ codeer check
119
+ ```
120
+
121
+ List the active cloud models without opening the Codeer web app:
122
+
123
+ ```bash
124
+ codeer model list --type text
125
+ ```
126
+
127
+ ## Custom evaluator judge models
128
+
129
+ Custom evaluator create/update commands can select a judge LLM model by ID:
130
+
131
+ ```bash
132
+ codeer eval evaluator-create \
133
+ --name "Correctness" \
134
+ --system-prompt-template-file evaluator-prompt.txt \
135
+ --judge-model <model-id> \
136
+ --dry-run
137
+
138
+ codeer eval evaluator-update \
139
+ --evaluator <evaluator-id> \
140
+ --judge-model <model-id> \
141
+ --dry-run
142
+ ```
143
+
144
+ Omit the judge-model flags on update to leave the current setting unchanged.
145
+ Use `--clear-judge-model` to explicitly clear the override and return to the
146
+ system default:
147
+
148
+ ```bash
149
+ codeer eval evaluator-update \
150
+ --evaluator <evaluator-id> \
151
+ --clear-judge-model \
152
+ --dry-run
153
+ ```
154
+
155
+ ## Agent human handoff
156
+
157
+ `codeer agent apply` accepts the same `human_handoff` object as the Agent API.
158
+ The dry-run validates it and shows whether handoff is enabled before any server
159
+ write:
160
+
161
+ ```json
162
+ {
163
+ "name": "Support Agent",
164
+ "system_prompt": "Help the user safely.",
165
+ "human_handoff": {
166
+ "enabled": true,
167
+ "idle_timeout_minutes": null,
168
+ "handoff_instructions": "Hand off when the user asks for a person."
169
+ }
170
+ }
171
+ ```
172
+
173
+ `idle_timeout_minutes` must be a positive integer or `null`. Human handoff only
174
+ becomes available in live published-agent conversations with a non-empty
175
+ `external_user_id`; editor Live Test conversations are internal and cannot
176
+ activate human mode.
177
+
178
+ ## HTTP input contracts
179
+
180
+ `codeer agent apply --payload` and SDK `agents.create` / `agents.update` accept
181
+ `unified_tools[].http_request.body.input_contracts`. No separate HTTP command is
182
+ needed. The target backend must have the HTTP input-contract feature deployed
183
+ (codeer-copilot #1495); installing this CLI alone does not enable runtime support.
184
+ A local dry-run cannot establish server deployment or API business-rule success.
185
+
186
+ Example payload:
187
+
188
+ ```json
189
+ {
190
+ "name": "Order helper",
191
+ "system_prompt": "Use the configured API for approved order changes.",
192
+ "use_search": false,
193
+ "unified_tools": [{
194
+ "id": "submit",
195
+ "type": "http_request",
196
+ "http_request": {
197
+ "method": "POST",
198
+ "url_template": "https://example.com/orders",
199
+ "body": {
200
+ "template": {
201
+ "quantity": "{{agent[Requested quantity]}}",
202
+ "payload": "{{agent[Order details]}}",
203
+ "changes": "{{agent[Changes as JSON text]}}"
204
+ },
205
+ "input_contracts": {
206
+ "quantity": {"type": "integer"},
207
+ "payload": {"type": "object"},
208
+ "changes": {"type": "string", "format": "json", "json_type": "array"}
209
+ }
210
+ }
211
+ }
212
+ }]
213
+ }
214
+ ```
215
+
216
+ - `type`: `string` (default), `number`, `integer`, `boolean`, `object`, `array`.
217
+ - `format`: `text` (default) or `json`; `json` requires `type: string`.
218
+ - `json_type`: `any` (default), `object`, `array`; outside JSON format, only
219
+ `any` is valid. API names are snake_case; the CLI rejects `inputContracts`,
220
+ `jsonType`, and unknown fields inside individual contracts.
221
+
222
+ `type: object` / `array` sends a native JSON value. `type: string, format: json`
223
+ sends a string containing JSON. Existing valid JSON text is sent unchanged;
224
+ empty strings also pass unchanged, while non-empty text must parse and match
225
+ `json_type`. Plain strings retain existing behavior, including malformed JSON.
226
+ The backend converts supported representations before checking runtime values;
227
+ the CLI only validates configuration and never executes the configured HTTP
228
+ request. Contracts do not configure nested JSON Schema constraints or defaults.
229
+
230
+ Keys come from template paths, not instructions: `order.count` → `order_count`,
231
+ `items[0].id` → `items_0_id`, root string → `body`. Non-ASCII-alphanumeric runs
232
+ become `_`, edge underscores are removed, and keys are lowercased. Multiple
233
+ placeholders in one string add `_1`, `_2`; traversal collisions add `_2`, `_3`.
234
+ Object insertion order matters: preserve it when editing/exporting. Typed and
235
+ JSON-text placeholders must occupy the entire template value. Stale contract
236
+ keys fail validation; omitted entries remain ordinary strings.
237
+
238
+ For an existing Agent:
239
+
240
+ ```bash
241
+ codeer agent get <agent-id> --out .codeer/current/agent.json
242
+ # Prepare local_draft_agent.json from current writable settings; review its diff.
243
+ codeer agent apply --agent-id <agent-id> --payload .codeer/current/local_draft_agent.json --dry-run
244
+ # After approval:
245
+ codeer agent apply --agent-id <agent-id> --payload .codeer/current/local_draft_agent.json
246
+ codeer agent get <agent-id> --out .codeer/current/agent.json
247
+ codeer agent get <agent-id> --history <history-id-from-apply> --out .codeer/current/agent-version.json
248
+ ```
249
+
250
+ The external update uses PATCH, but it is **not a nested partial update**.
251
+ Preserve `name`, `system_prompt`, `use_search`, the complete `unified_tools` list
252
+ (including other tools, templates, auth and `draft_policy`), and the full desired
253
+ contract map. Also preserve description, attachments, suggested questions,
254
+ model settings, handoff and other writable settings. Sending one changed tool
255
+ replaces the list; omitting a contract entry resets that input to ordinary string.
256
+ GET responses and writable payloads have different shapes; reconstruct attachment
257
+ IDs and other absent writable fields from current version evidence as needed.
258
+ Do not apply an update if a current setting cannot be preserved by the CLI. See
259
+ [the skill workflow](../codeer-agent/reference/http-input-contracts.md) for details.
260
+
261
+ Dry-run's `http_inputs` lists tool indexes and each generated key's effective
262
+ `type` / `format` / `json_type`, with `configured: false` for defaults. It excludes
263
+ HTTP URLs, auth, headers, query values, instructions and template content.
264
+ `body_inputs_used` is false for GET/HEAD, whose body inputs are unused at runtime.
265
+ `--full` and `--out` deliberately retain complete nested content, including
266
+ credentials; metadata cleanup is limited to resource-level account fields and
267
+ workspace identity. These exports are not redacted artifacts.
268
+
269
+ Compare the fresh GET and exact version snapshot with the intended tools and
270
+ contracts; the server may materialize omitted defaults. `agent versions --out`
271
+ exports version metadata, not snapshots; use `agent get --history` for a snapshot.
272
+ Apply saves a draft. Publish the verified version separately, after approval,
273
+ using `codeer agent publish --agent <agent-id> --history <history-id>` (preview
274
+ with `--dry-run` first).
275
+
276
+ ## Upgrade and uninstall
277
+
278
+ Upgrade the CLI:
279
+
280
+ ```bash
281
+ pipx upgrade codeer-cli
282
+ codeer check
283
+ ```
284
+
285
+ Remove the CLI:
286
+
287
+ ```bash
288
+ pipx uninstall codeer-cli
289
+ ```
290
+
291
+ ## Output policy for coding agents
292
+
293
+ The CLI is optimized for Codex, Claude Code, Claude Cowork, and similar coding
294
+ agents that keep command output in their LLM context. Default stdout is a
295
+ compact lifecycle summary, not the full server payload.
296
+
297
+ Use this pattern during agent lifecycle work:
298
+
299
+ ```bash
300
+ codeer agent list
301
+ codeer history list --agent <agent-id> --has-ai-drafts --limit 50
302
+ codeer history conversations <history-id> --out .codeer/current/history-<history-id>.json
303
+ codeer history ai-drafts <history-id> --out .codeer/current/ai-drafts-<history-id>.json
304
+ codeer history create --agent <agent-id> --message "Review this plan" --timeout 240
305
+ codeer history send <history-id> --message "Use the recommended options" --timeout 240
306
+ codeer eval run --agent <agent-id> --cases <case-ids> --evaluator <evaluator-id> --out .codeer/eval_run.json
307
+ ```
308
+
309
+ `history create` and `history send` use the agent's current published version.
310
+ They use Chat V2 structured SSE with `stream: true`; their per-message read
311
+ timeout defaults to 240 seconds. Success requires a `response.completed`
312
+ event. If the stream times out, reports `response.failed`, or disconnects
313
+ early, inspect the history before retrying: the server may already have
314
+ persisted the turn.
315
+
316
+ Eval case label commands always operate on the active API-key workspace. They
317
+ do not accept a workspace override; switch CLI profiles to target another
318
+ workspace.
319
+
320
+ Flags:
321
+
322
+ - `--full` prints bounded extra detail for human inspection. Some commands,
323
+ including `agent get`, can expose configuration credentials; `history
324
+ ai-drafts` can expose sensitive conversation text and therefore requires
325
+ `--out`. Use each command's flag description as the output contract, and
326
+ inspect complete artifacts locally without flooding LLM context.
327
+ - `--out <path>` writes complete diagnostic artifacts to a local file. Use it
328
+ for raw eval results, full conversation turns, full rubric matrices, and
329
+ other data that can grow with cases, versions, or turns.
330
+
331
+ `history conversations` reads `/api/v1/external/histories/{id}/messages`
332
+ using a workspace admin API key and follows all pages automatically. Member
333
+ keys retain existing History visibility but are intentionally rejected by this
334
+ complete tool-payload export. This requires a server supporting
335
+ `history-parts-v1`; it never falls back to a
336
+ different authorization contract. Stdout shows at most 20 part summaries (50
337
+ with `--full`) and omits tool payload previews. `--out` retains native tool
338
+ args/results/outcomes, group/part IDs, attachments, feedback, and metadata.
339
+ Attachment URLs remain permission-checked History download endpoints rather
340
+ than direct storage/source URLs.
341
+ Legacy projections have `source: legacy-adapter`; tool outcomes absent from
342
+ the original records are omitted and marked `outcome_not_recorded`. System
343
+ prompts and provider raw traces are not included. Missing parts do not prove a tool never ran. Keep export files private.
344
+
345
+ `--client-visible --user <external-user-id>` explicitly selects the existing
346
+ Chat V2 owner/allowlist contract. No external identity is inferred from History
347
+ metadata. `history get` and the low-level legacy `get_conversations` reader
348
+ remain compatible. Management exports do not hydrate display-only tool payloads.
349
+
350
+ Release order: deploy the backend supporting `history-parts-v1` first, verify
351
+ an authorized management export across multiple pages, then release/install
352
+ this CLI. Existing CLI versions retain their previous behavior until upgraded.
353
+ If the backend endpoint is unavailable, the new CLI fails explicitly with no
354
+ fallback; keep the previous CLI installed until backend verification passes.
355
+ The management endpoint can remain available if the CLI release is rolled back.
356
+
357
+ `history list --has-ai-drafts` narrows the history page to conversations with
358
+ at least one AI Draft and includes lifecycle counts in compact output.
359
+ `history ai-drafts` follows every server page and writes every returned draft
360
+ lifecycle record to `--out`: generated content, refinement lineage,
361
+ `generation_instruction`, `dismiss_reason`, `dismiss_feedback`, outcomes, tool
362
+ activities, proposed actions, operator attribution, and the correlated actual
363
+ delivery when one exists. Default stdout shows structural flags and counts but
364
+ no generated, operator, customer, or tool text. `--full --out <path>` explicitly
365
+ opts into bounded content previews. The endpoint has no revision token, so a
366
+ multi-page artifact is marked `snapshot_consistency: best-effort`: count changes
367
+ and duplicate IDs fail the export, but lifecycle fields can still change during
368
+ paging. Re-run when point-in-time consistency matters. These fields are evidence
369
+ for an improvement analysis; the CLI does not invent a recommended Agent change
370
+ from them.
371
+
372
+ Use the external client-owner contract only when that distinction is the point
373
+ of the test:
374
+
375
+ ```bash
376
+ codeer history conversations <history-id> \
377
+ --client-visible --user <external-user-id> \
378
+ --out .codeer/current/client-history-<history-id>.json
379
+ ```
380
+
381
+ Avoid piping large raw JSON directly into agent chat. Prefer `--out`, then ask
382
+ the coding agent to inspect targeted summaries, IDs, failing cases, or selected
383
+ snippets from the saved file.
384
+
385
+ ## Website crawler KBs
386
+
387
+ Website-backed KB folders can be created and updated with `codeer kb crawl-*`.
388
+ Always preview crawler mutations with `--dry-run` first:
389
+
390
+ ```bash
391
+ codeer kb crawl-create \
392
+ --url https://example.com/docs \
393
+ --folder-name "Product Docs" \
394
+ --include-path "/docs*" \
395
+ --exclude-path "/docs/private*" \
396
+ --limit 250 \
397
+ --max-depth 3 \
398
+ --only-main-content \
399
+ --dry-run
400
+ ```
401
+
402
+ `--include-path` and `--exclude-path` are repeatable clean path patterns. Quote
403
+ paths containing `*` so the shell passes the wildcard to the CLI. Advanced
404
+ settings can still be passed through `--config-json`; explicit crawler flags
405
+ override matching JSON keys.
406
+
407
+ ## Exporting KB snapshot content
408
+
409
+ Export one file directly from the content endpoint:
410
+
411
+ ```bash
412
+ codeer kb export \
413
+ --node-id <file-node-id> \
414
+ --file guide.md
415
+ ```
416
+
417
+ Or recursively export a folder or an entire KB root:
418
+
419
+ ```bash
420
+ codeer kb export \
421
+ --node-id <folder-or-kb-root-node-id> \
422
+ --dir kb-export \
423
+ --out kb-export-manifest.json
424
+ ```
425
+
426
+ `--file` and `--dir` are mutually exclusive. Single-file mode maps directly to
427
+ the external file-content endpoint and lets the caller choose the exact local
428
+ path. Folder mode recursively lists the node tree, calls that endpoint for each
429
+ file, and writes the extracted snapshot content as UTF-8 Markdown. Existing
430
+ `.md`/`.markdown` names are preserved; other folder-export names receive an
431
+ additional `.md` suffix (for example, `guide.pdf` becomes `guide.pdf.md`) so the
432
+ export is not mistaken for the original binary upload.
433
+
434
+ The command asks the content endpoint for every file regardless of indexing
435
+ status. If the endpoint returns text, it is exported even when the status is
436
+ not `READY`; the full manifest preserves that server status and marks the file
437
+ as `exported_while_not_ready`. If the endpoint returns `content: null`, the file
438
+ is skipped and the command exits non-zero. Existing target files block the
439
+ entire export before any content is written; pass `--overwrite` only when
440
+ replacing those local files is intended.
441
+
442
+ This is a snapshot-content export, not an original-file backup. The server API
443
+ returns processed text and does not return the original PDF, DOCX, or other
444
+ binary bytes through this endpoint.
445
+
446
+ ## KB node rename and delete
447
+
448
+ Knowledge Base roots, folders, and files are all KnowledgeNodes. Use
449
+ `codeer kb list` and `codeer kb files` to find node IDs, then preview mutations
450
+ with `--dry-run`:
451
+
452
+ ```bash
453
+ codeer kb node-rename --node-id <node-id> --name "New Name" --dry-run
454
+ codeer kb node-delete --node-id <node-id> --dry-run
455
+ ```
456
+
457
+ `node-delete` deletes the target node and all descendants. Review the dry-run
458
+ output before rerunning without `--dry-run`.
459
+
460
+ ## Context Object FAQ
461
+
462
+ Use Context Object FAQ entries to route high-value questions to a canonical KB
463
+ file when semantic retrieval misses the right source. The FAQ target is a KB
464
+ file's `snapshot_object_id`, shown by `codeer kb files`. Add `--range` when the
465
+ route should reserve a stable passage inside that file. Ranges must include both
466
+ line and column positions so the Codeer UI can map them onto rendered Markdown.
467
+
468
+ ```bash
469
+ codeer kb files --kb-id <kb-id>
470
+ codeer kb faq-list --context-object-id <snapshot-object-id>
471
+ codeer kb faq-create --context-object-id <snapshot-object-id> --question "..." --range 12:0-12:42 --dry-run
472
+ codeer kb faq-update <faq-id> --range 12:0-12:42 --dry-run
473
+ ```
474
+
475
+ `--range` accepts `START_LINE:START_COLUMN-END_LINE:END_COLUMN`; repeat it to
476
+ reserve multiple passages.
477
+
478
+ After reviewing the dry-run output, rerun the create/update/delete command
479
+ without `--dry-run` to apply it.