kovence-cli 1.2.0 → 1.3.0

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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,44 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ## [1.3.0] - 2026-11-22
11
+
12
+ ### Added & Changed
13
+ - **On-demand headless Playwright browser & multimodal vision (`browser` tool, `/browser`)**:
14
+ - Added zero-dependency lazy `src/tools/browser.js` controller: keeps `package.json` runtime dependencies empty, reuses existing system Chrome/Chromium/Edge when found, and installs `playwright-core` (+ Chromium only if missing) into an isolated user cache directory (`<globalDir>/browser`) on first use.
15
+ - Added `browser` tool (`open`, `screenshot`, `click`, `type`, `evaluate`, `console`, `status`, `install`, `close`) capturing workspace screenshots, DOM summaries, console errors, uncaught `pageerror` exceptions, and HTTP >= 400 network failures, plus `/browser [status|install|close]`.
16
+ - Added multimodal screenshot forwarding for both Anthropic (`tool_result` base64 `image` blocks) and OpenAI-compatible (`image_url` after tool batch) providers with automatic history image pruning and graceful text-only fallback on non-vision models.
17
+ - **Interactive reasoning selection after model choice, TUI polish, real-time write stats & Markdown Skills**:
18
+ - Selecting a model via `/model` or `/settings -> Model` now prompts immediately for the active `reasoning` level (`off`, `low`, `medium`, `high`) and saves it; added `/reasoning [level]` shortcut.
19
+ - Fixed the background color seam in the TUI composer input row after the placeholder text so `barBg` stays uniform across the entire terminal width.
20
+ - Added a dedicated second footer line for keyboard shortcuts so shortcuts remain visible on narrower screens instead of being pushed off by long model/context status.
21
+ - Fixed `StreamingToolArgsParser`, `providers.js` (`apply_patch`), and `createTuiSink` so line counts, `~tokens`, `tok/s`, and 5-line previews stream live even when `content` arrives before `path` or rewrites the same file in later turns.
22
+ - Removed hardcoded 20/24-char truncation in the TUI model picker and bottom footer so full model names render whenever terminal width allows.
23
+ - Added the Markdown Skills system (`src/config/skills.js`, `/skills` slash command, `skill` tool, and interactive multi-select prompting on matching tasks in `runAgentTurn`).
24
+ - **Eval harness & `--log-requests` (`scripts/eval.js`, `eval/fixtures/*`)**: Added standalone eval runner executing isolated temp copies of 3 coding fixtures (`01-fix-failing-test`, `02-rename-symbol`, `03-add-function-and-test`) with ground-truth test verification, JSONL output in `eval/results/`, offline `--mock` mode, and `--log-requests <file>` JSONL logging with secret scrubbing across headers, URLs, API keys, and env secrets.
25
+ - **Anthropic prompt caching & reasoning support**: Added `cache_control: { type: "ephemeral" }` breakpoints to the Anthropic system prompt block and last tool definition with deterministic tool order, recorded `cache_read_input_tokens` / `cache_creation_input_tokens` (and OpenAI `cached_tokens`) in session stats & `/cost`, added `reasoning` (`off` | `low` | `medium` | `high`) setting, captured OpenAI `reasoning_content`/`reasoning` & Anthropic `thinking`+`signature` blocks, preserved Anthropic thinking blocks before `tool_use` across tool loops when enabled (stripped otherwise and excluded from summaries), and downgraded cleanly if `reasoning_effort` is unsupported.
26
+ - **Post-edit feedback (`checkCommand`)**: Added `checkAfterEdit` toggle (default `false`), `checkCommand` (user-level settings only, never read from repo files), `checkTimeoutMs` (30s default), and `checkMaxLines` (30 lines default). Runs once per edit/batch after successful edits with shell-quoted `{file}`, stays quiet on success, and reports errors and timeouts.
27
+ - **Sub-agents (`task` tool) & stateless `runAgentLoop`**: Extracted stateless `runAgentLoop` from `runAgentTurn` and added `src/agent/subagent.js` with `explore` (hard read-only, parallel up to `agents.maxParallel=3`) and `general` (no recursion, serialized by default via `agents.parallelGeneral`), isolated fresh child history/read-tracker, 30-step wrap-up + 12k output cap, parent token accounting, serialized `[sub-agent: ...]` approval queue, derived abort propagation, per-agent `agents.*` model/provider settings + startup warnings, live TUI / 2-line non-TTY progress, and optional `.kovence/agents/*.md` narrow-only definitions.
28
+ - **Model-family system prompt & migration**: Replaced the 4-line default system prompt with a structured coding-agent base prompt + per-family addendum (`claude`, `gpt`, `gemini`, `default`) in a byte-stable prefix, while keeping `MEMORY RULE` and language preferences intact and preserving custom prompts with a reset notice.
29
+ - **Short-manual tool descriptions & `toolset` (`core` | `full`)**: Upgraded every tool description to explain usage, limits, and mistakes; removed duplicate `google_search`, merged memory tools into `memory`, gated `apply_patch` to `gpt`/`codex`, and defaulted `toolset` to `core`.
30
+ - **Instruction file discovery & step-limit wrap-up**: Walks up from `cwd` to `.git` root (or `$HOME`) plus `$XDG_CONFIG_HOME/kovence/AGENTS.md` with nearest-first priority, dedupe, and a 12k-char cap; reaching `maxToolSteps` now sends a `tool_choice: none` wrap-up request while keeping tool definitions valid.
31
+ - **Fuzzy `edit_file` & atomic `multi_edit`**: Added 7-stage matching pipeline (exact, EOL-normalized, line-trimmed, indentation-flexible, whitespace-normalized, escape-normalized, block-anchor), automatic `read_file` line-number prefix stripping, `replace_all`, closest-candidate failure diagnostics, and short unified diffs on success while preserving BOM/EOL.
32
+ - **Read-before-edit tracker**: Per-session / per-agent tracker prevents editing or overwriting existing files that were never read or changed externally on disk.
33
+ - **Accurate `read_file` & richer `search_files`**: Line-based 2000-line / 2000-char-per-line `read_file` with exact continuation footers; `search_files` with `include` glob, `case_insensitive`, `context_lines`, stable sorting, and 200-match cap across both `rg` and JS fallback.
34
+ - **Shell timeouts, background promotion, & `command_output` / `command_kill`**: Raised default/max `run_command` timeouts to 120s / 600s with explicit clamp notices, added `workdir`, ANSI stripping + 16k head / 32k tail ring-buffer capture, and automatic background promotion on timeout.
35
+ - **LoopDetector**: Detects exact repeats, `A-B-A-B` alternation, and repeated failing edits, adding a hint before stopping on the 3rd detection.
36
+ - **Token-budget context management (Zones A / B / C)**: Replaced default message-count slicing (`maxHistoryMessages: 24`) with unlimited history (`null`) managed against model-registry `contextWindow` (32k fallback with one-time notice for unknown models), output reserve, tool schema overhead, and EMA `prompt_tokens` calibration.
37
+ - **Zone B pruning & Zone C structured compaction**: Prunes old tool outputs (`run_command` / `web_fetch` first, protecting recent ~40k tool tokens and last 2 user turns) above 75% usable context; compacts older history above 85% (and via `/compact`) with chunked structured summarization, prune-only fallback on summary failure, and one-retry overflow recovery.
38
+ - **Settings migration (`settingsVersion: 2`)**: Automatically migrates legacy shipped defaults (`maxHistoryMessages: 24` and `contextWindow: 128000`) to `null`; `autoSummarize` now defaults to `false` with larger rolling summary limits and no 1500/2000-char input truncation.
39
+
40
+ ### Fixed & Changed
41
+ - **Tool-call truncation gate**: Tool calls cut off by output limits (`length`, `max_tokens`, `content_filter`, `error`) are never executed; partial streaming writes are reverted, the model receives a retry instruction, and repeated truncations raise the output limit once up to the model maximum before stopping safely.
42
+ - **Strict JSON argument parsing & validation**: Removed brace/bracket balancing and `{}` error fallback. Only safe repairs (BOM, code fences, trailing commas, bare keys outside string literals) are allowed, required parameters and schema types are validated, and calls without a `finishReason` require strict JSON with zero repair.
43
+ - **SSE tool-call stream merging**: Rewrote OpenAI-compatible `tool_calls` delta merging to preserve earlier calls on reused indices, avoid repeated-name concatenation, handle object arguments, and flush multi-byte UTF-8 chunks cleanly.
44
+ - **Provider output limits, `is_error`, and system messages**: Replaced Anthropic's 4096 `max_tokens` fallback with per-model registry `maxOutputTokens` (16384 default), added OpenAI-compatible `max_completion_tokens` and max-limit clamping retries, set `is_error: true` on failed Anthropic `tool_result` blocks, and merged multiple system messages into one leading message on OpenAI-compatible requests.
45
+
8
46
  ## [1.0.0] - 2026-11-19
9
47
 
10
48
  ### Added
package/README.md CHANGED
@@ -193,7 +193,10 @@ Type `/` in the composer to see autocomplete suggestions.
193
193
  | `/settings` | Open interactive Settings panel (`Ctrl+,`) |
194
194
  | `/set <key> <val>` | Update a persisted setting directly |
195
195
  | `/api` | Switch, add, or remove AI providers |
196
- | `/model [name]` | Pick or switch the active model |
196
+ | `/model [name]` | Pick or switch the active model & reasoning level |
197
+ | `/reasoning [level]` | Pick or set reasoning effort (`off \| low \| medium \| high`) |
198
+ | `/skills [subcmd]` | Manage reusable markdown skills (`list \| add <file.md> \| new \| show \| rm`) |
199
+ | `/browser [subcmd]` | Inspect/install/close isolated on-demand headless Playwright browser (`status \| install \| close`) |
197
200
  | `/sessions` | Session picker — list, switch, delete sessions (`Ctrl+S`) |
198
201
  | `/new` | Open a new isolated session (`Ctrl+N`) |
199
202
  | `/rename <name>` | Rename the current session |
@@ -279,7 +282,7 @@ In plain REPL mode, prefix a command with `!` to run it directly in your shell:
279
282
 
280
283
  ### Agent background tasks
281
284
 
282
- The agent can run shell commands as background tasks (`run_command` with `background: true`). Manage them with:
285
+ The agent can run shell commands as background tasks (`run_command` with `background: true`, or automatically promoted on timeout when `commandTimeoutBehavior` is `background`). The model inspects/stops them via `command_output` and `command_kill`, and you can manage them interactively with:
283
286
 
284
287
  ```
285
288
  /tasks # List all running background tasks
@@ -330,6 +333,16 @@ The session picker (`Ctrl+S`) groups sessions by date (Today, Yesterday, This We
330
333
 
331
334
  ---
332
335
 
336
+ ## Sub-Agents (`task` Tool)
337
+
338
+ Parent turns include a `# Delegation` section and the `task` tool so complex tasks can delegate isolated work without bloating the main session context:
339
+
340
+ - **`explore` sub-agents**: Hard read-only in all modes (including `auto`), run concurrently up to `agents.maxParallel` (`3` by default), and return only a final summary + compact stats line.
341
+ - **`general` sub-agents**: Run isolated multi-step subtasks using non-recursive tools (excluding `task`, `todo_write`, `memory`), serialized by default (`agents.parallelGeneral: false`).
342
+ - **Narrow-only inheritance**: Children inherit parent permission mode (`plan` stays read-only), share a serialized confirmation queue labeled `[sub-agent: ...]`, propagate aborts cleanly, and support optional `.kovence/agents/*.md` narrow-only overrides.
343
+
344
+ ---
345
+
333
346
  ## Settings Reference
334
347
 
335
348
  Open the interactive settings panel with `Ctrl+,` or `/settings`. Settings are saved to `~/.config/kovence/settings.json`.
@@ -342,12 +355,17 @@ Open the interactive settings panel with `Ctrl+,` or `/settings`. Settings are s
342
355
  | `model` | string | Default model name |
343
356
  | `provider` | string | Default provider name |
344
357
  | `toolsEnabled` | `true \| false` | Enable/disable tool calling |
345
- | `autoSummarize` | `true \| false` | Auto-compact history when context is full |
358
+ | `autoSummarize` | `true \| false` | Update rolling session summary after each turn (default `false`) |
346
359
  | `maxToolSteps` | number | Max tool-call iterations per turn |
347
- | `maxHistoryMessages` | number | Max messages kept in context |
348
- | `contextWindow` | number | Context window size (tokens) |
360
+ | `maxHistoryMessages` | number / `null` | Optional hard message-count cap (`null` = unlimited token-budget management) |
361
+ | `contextWindow` | number / `null` | Context window in tokens (`null` = auto from model registry, 32k if unknown) |
362
+ | `contextReserveTokens` | number / `null` | Reserved output tokens (`null` = `max(20000, maxOutputTokens)`) |
363
+ | `pruneThreshold` | float | Usable-context ratio triggering Zone B tool-output pruning (default `0.75`) |
364
+ | `compactThreshold` | float | Usable-context ratio triggering Zone C compaction (default `0.85`) |
365
+ | `pruneProtectTokens` | number | Recent tool-output tokens protected from pruning (default `40000`) |
366
+ | `pruneMinSavings` | number | Minimum token savings required before pruning (default `20000`) |
349
367
  | `temperature` | `0.0`–`2.0` | Sampling temperature |
350
- | `maxTokens` | number | Max completion tokens |
368
+ | `maxTokens` | number / `null` | Max completion tokens (`null` uses model-registry default, 16384 fallback for Anthropic) |
351
369
  | `verbosity` | `low \| normal \| high` | Tool output verbosity in TUI |
352
370
  | `language` | `english \| banglish \| bangla` | Preferred response language |
353
371
  | `renderingMode` | `fullscreen \| inline` | TUI layout mode |
@@ -356,6 +374,19 @@ Open the interactive settings panel with `Ctrl+,` or `/settings`. Settings are s
356
374
  | `showActiveTasks` | `true \| false` | Show background task count in status bar |
357
375
  | `notifications` | `true \| false` | Desktop notifications on turn completion |
358
376
  | `colorScheme` | `amber \| dark \| light \| terminal` | TUI color theme |
377
+ | `commandTimeoutMs` | number | Default `run_command` timeout in ms (default `120000`) |
378
+ | `commandTimeoutMaxMs` | number | Maximum `run_command` timeout in ms (default `600000`) |
379
+ | `commandTimeoutBehavior` | `background \| kill` | On command timeout: promote to background task or kill process group |
380
+ | `toolset` | `core \| full` | Exposed tool set: `core` (default coding tools) or `full` (adds download, memory, move, mkdir, delete, ask_user) |
381
+ | `agents.maxParallel` | integer (`1`–`10`) | Maximum concurrent sub-agents per batch (default `3`) |
382
+ | `agents.parallelGeneral` | `true \| false` | Allow concurrent `general` sub-agents (default `false` = serialized) |
383
+ | `agents.explore.*` | `{ model, provider, maxSteps }` | Optional model/provider/step cap override (`maxSteps` default `30`) for `explore` |
384
+ | `agents.general.*` | `{ model, provider, maxSteps }` | Optional model/provider/step cap override (`maxSteps` default `30`) for `general` |
385
+ | `checkAfterEdit` | `true \| false` | Run user-level `checkCommand` once after file edit batches (default `false`) |
386
+ | `checkCommand` | string | User-level post-edit shell check command (supports `{file}`; never loaded from repo files) |
387
+ | `checkTimeoutMs` | integer (`100`–`300000`) | Post-edit check timeout in ms (default `30000`) |
388
+ | `checkMaxLines` | integer | Maximum check failure lines appended to tool output (default `30`) |
389
+ | `reasoning` | `off \| low \| medium \| high` | Extended thinking / reasoning effort for Anthropic & OpenAI reasoning models (default `off`) |
359
390
 
360
391
  You can also set any value directly:
361
392
 
@@ -382,6 +413,35 @@ Checks and reports on:
382
413
 
383
414
  ---
384
415
 
416
+ ## Benchmarking & Request Logging
417
+
418
+ ### Request logging (`--log-requests`)
419
+
420
+ Inspect the exact system prompt, tool schemas, and messages sent to your provider (with headers, API keys, URL tokens, and secret environment variables scrubbed):
421
+
422
+ ```bash
423
+ kovence --log-requests /tmp/requests.jsonl -p "Inspect src/agent/turn.js"
424
+ ```
425
+
426
+ ### Eval harness (`scripts/eval.js`)
427
+
428
+ Run repeatable coding tasks against isolated temporary copies of `eval/fixtures/*`, scored strictly by running each fixture's verification `testCommand` and written to `eval/results/*.jsonl`:
429
+
430
+ ```bash
431
+ # Built-in offline mock run
432
+ node scripts/eval.js --mock
433
+
434
+ # Real provider/model run
435
+ node scripts/eval.js --provider openai --model gpt-4o --runs 3
436
+
437
+ # Compare baseline (Phase 0 commit) vs current commit via git worktree
438
+ git worktree add /tmp/kovence-baseline 7a78d67
439
+ # Run baseline against the same fixtures, then remove worktree:
440
+ git worktree remove /tmp/kovence-baseline
441
+ ```
442
+
443
+ ---
444
+
385
445
  ## License
386
446
 
387
447
  MIT © Kovence
package/nd.js CHANGED
@@ -30,10 +30,13 @@ const { KovenceTUI } = require("./tui");
30
30
  const { buildProviderUrls, listProviderModels } = require("./providers");
31
31
  const { parseArgs, getHelpText } = require("./src/cli/args");
32
32
  const { createPlainSink, addTuiBanner, createTuiSink, nextAgentMode } = require("./src/cli/sinks");
33
+ const { validateAgentModelSettings } = require("./src/agent/subagent");
34
+ const { createRequestLogger } = require("./src/agent/request_logger");
33
35
  const {
34
36
  getEnvFallback,
35
37
  getContextLabel,
36
38
  persistAndApplySetting,
39
+ promptReasoningSelection,
37
40
  handleSlash,
38
41
  switchToSession,
39
42
  openSessionPicker,
@@ -471,11 +474,19 @@ async function runTuiRepl(state) {
471
474
  items,
472
475
  state.model
473
476
  );
477
+ let chosenModel = "";
474
478
  if (picked === "__custom__") {
475
479
  const custom = (await tui.askModal("Custom model ID: ", false)).trim();
476
- if (custom) persistAndApplySetting(state, "model", custom, sink);
480
+ if (custom) {
481
+ persistAndApplySetting(state, "model", custom, sink);
482
+ chosenModel = custom;
483
+ }
477
484
  } else if (picked) {
478
485
  persistAndApplySetting(state, "model", picked, sink);
486
+ chosenModel = picked;
487
+ }
488
+ if (chosenModel) {
489
+ await promptReasoningSelection(state, sink);
479
490
  }
480
491
  }
481
492
  } finally {
@@ -602,6 +613,9 @@ async function main() {
602
613
  if (opts.autoSummarize !== null) settings.autoSummarize = opts.autoSummarize;
603
614
  if (opts.temperature !== null) settings.temperature = opts.temperature;
604
615
  if (opts.maxTokens !== null) settings.maxTokens = opts.maxTokens;
616
+ if (opts.logRequests) {
617
+ settings._requestLogger = createRequestLogger(opts.logRequests);
618
+ }
605
619
 
606
620
  let model = resolveEffectiveModel({
607
621
  cliModel: opts.model,
@@ -620,6 +634,13 @@ async function main() {
620
634
  session.model = model;
621
635
  if (!opts.noSession) saveSession(session, paths);
622
636
 
637
+ const agentModelWarnings = validateAgentModelSettings(settings, provStore);
638
+ if (agentModelWarnings.length && !opts.json) {
639
+ for (const w of agentModelWarnings) {
640
+ console.error(`${C.yellow}Warning:${C.reset} ${w}`);
641
+ }
642
+ }
643
+
623
644
  // Run session retention cleanup on startup (non-fatal, skip active session).
624
645
  try {
625
646
  const retentionDays = persistedSettings.chatHistoryRetentionDays;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kovence-cli",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Kovence CLI — Fast zero-dependency multi-step AI coding-agent CLI harness",
5
5
  "license": "MIT",
6
6
  "homepage": "https://kovence-cli.kovence.com",