Procházet zdrojové kódy

docs: add JSON output section and ClineMessage schema to CLI reference (#8151)

* docs: add JSON output section and ClineMessage schema to CLI reference

* docs: enhance JSON output section with ClineMessage schema details
Juan Pablo Flores před 1 měsícem
rodič
revize
af4d99e0bc
2 změnil soubory, kde provedl 59 přidání a 0 odebrání
  1. 22 0
      cli/man/cline.1.md
  2. 37 0
      docs/cline-cli/cli-reference.mdx

+ 22 - 0
cli/man/cline.1.md

@@ -78,6 +78,28 @@ These options apply to all subcommands:
 
 :   Output format. Options: **rich** (default), **json**, **plain**
 
+    When you use **-F json**, the CLI prints each client message as JSON.
+
+    Each message is a **ClineMessage** object.
+
+    Required fields:
+
+    - **type**: "ask" or "say"
+    - **text**: message text
+    - **ts**: Unix epoch timestamp in milliseconds
+
+    Optional fields (omitted when empty):
+
+    - **reasoning**: reasoning text
+    - **say**: say subtype (present when type is "say")
+    - **ask**: ask subtype (present when type is "ask")
+    - **partial**: streaming flag
+    - **images**: list of image URIs
+    - **files**: list of file paths
+    - **lastCheckpointHash**: git checkpoint hash
+    - **isCheckpointCheckedOut**: checkpoint checkout flag
+    - **isOperationOutsideWorkspace**: workspace safety flag
+
 **-h**, **\--help**
 
 :   Display help information for the command.

+ 37 - 0
docs/cline-cli/cli-reference.mdx

@@ -371,6 +371,43 @@ COPYRIGHT
        Copyright © 2025 Cline Bot Inc. Licensed under the Apache License 2.0.
 ```
 
+## JSON output (-F json)
+
+When you run a command with `-F json` (or `--output-format json`), Cline prints each client message as JSON.
+
+### ClineMessage schema
+
+| Field | Type | Required | Notes |
+|-------|------|----------|-------|
+| `type` | `"ask" or "say"` | Yes | Top-level message category. |
+| `text` | `string` | Yes | Human-readable message content. |
+| `ts` | `number` | Yes | Unix epoch timestamp in milliseconds. |
+| `reasoning` | `string` | No | Omitted when empty. |
+| `say` | `string` | No | Omitted when empty. Present when `type` is `"say"`. |
+| `ask` | `string` | No | Omitted when empty. Present when `type` is `"ask"`. |
+| `partial` | `boolean` | No | Omitted when false. `true` for streaming updates. |
+| `images` | `string[]` | No | Omitted when empty. Image URIs when included with a message. |
+| `files` | `string[]` | No | Omitted when empty. File paths when attached to a message. |
+| `lastCheckpointHash` | `string` | No | Omitted when empty. Git checkpoint hash when available. |
+| `isCheckpointCheckedOut` | `boolean` | No | Omitted when false. `true` if Cline checked out a checkpoint. |
+| `isOperationOutsideWorkspace` | `boolean` | No | Omitted when false. `true` if an operation happened outside the workspace. |
+
+<Note>
+Most fields are optional and omitted when empty. If you parse this output, treat missing fields as “not present”, not as empty strings.
+</Note>
+
+### Example
+
+```json
+{
+  "type": "say",
+  "text": "Cline is about to run a command.",
+  "ts": 1760501486669,
+  "say": "command",
+  "partial": false
+}
+```
+
 ### Shell Completion
 
 Generate autocompletion scripts for various shells: