2.8 KiB
vscode-cline-parser (Shared Helper)
Shared discovery and parsing for Cline and VS Code extensions descended from Cline.
- Source:
src/providers/vscode-cline-parser.ts - Loading: not a provider; imported by
cline.ts,ibm-bob.ts,kilo-code.ts, androo-code.ts. - Test: none directly. Coverage comes from
tests/providers/cline.test.ts,tests/providers/ibm-bob.test.ts,tests/providers/kilo-code.test.ts, andtests/providers/roo-code.test.ts.
What it does
Two responsibilities:
discoverClineTasks(extensionId)walks a base directory'stasks/child and returns one source per task that has aui_messages.jsonfile (vscode-cline-parser.ts:25-50). Without an override directory it uses VS Code'sglobalStorage/<extensionId>/path.discoverClineTasksInBaseDirs(baseDirs)does the same for non-VS Code apps with compatible task storage, such as IBM Bob.createClineParserreads each task'sui_messages.jsonandapi_conversation_history.json, extracts model, tools, and token counts, and yieldsParsedProviderCallobjects.
Storage layout
Per task directory:
<baseDir>/tasks/<taskId>/
ui_messages.json # event stream
api_conversation_history.json # full prompt history with model tags
Model resolution
The model is extracted from api_conversation_history.json by searching user message content blocks for a <model>...</model> tag. Falls back to the provider-supplied auto model (cline-auto by default) if no tag is found.
Token extraction
From api_req_started entries inside ui_messages.json. Each such entry's text field is JSON-parsed; the parsed object holds tokensIn, tokensOut, cacheReads, cacheWrites, and (optionally) cost.
If cost is present, it is used directly. If not, calculateCost from src/models.ts computes it from tokens.
Deduplication
Per <providerName>:<taskId>:<index> where index is the position of the api_req_started entry within ui_messages.json.
Quirks
- Only the first user message is emitted as
userMessagein theParsedProviderCall. Subsequent user turns are accounted but not surfaced. - The model regex looks inside content blocks, not at top-level fields. Some Cline-derivative extensions emit the model elsewhere; if you add support for one, branch on extension ID rather than rewriting the regex.
When fixing a bug here
- A change here ripples to Cline, IBM Bob, KiloCode, and Roo Code. Run all four provider test files before opening a PR.
- If you find that one of the extensions emits a different shape, branch on the extension ID parameter that the discovery function already takes; do not duplicate the parser.
- If you add support for another Cline-family task store, register it as a thin wrapper file in the same shape as
cline.ts,ibm-bob.ts,kilo-code.ts, androo-code.ts.