Commit Graph

6670 Commits

Author SHA1 Message Date
can1357 d182db3973 feat(coding-agent): implemented gitignore-aware scan command to ttsr cli
- Added the `scan` action to `ttsr` CLI with support for gitignore-aware file globbing.
- Integrated AST pre-filtering and optimized AST/regex matching to evaluate scan rules.
- Implemented file size limits, binary file detection, and custom `--no-gitignore` and `--max-bytes` flags.
- Introduced comprehensive test suites validating directory mapping, exclusions, and size-limit enforcement.
2026-06-18 01:57:23 +02:00
can1357 265f271197 feat(coding-agent): added pdf image extraction, caching, and markdown rewriting to the read tool
- Added support for extracting and caching images from PDF documents during Markit conversion.
- Implemented a rewriting step to replace PDF markdown image placeholders with clickable reference commands.
- Introduced specific sub-path routing (`file.pdf:image.png`) allowing direct reading of extracted PDF images.
- Implemented caching for extracted PDF images utilizing unique keys and a `.extracted` marker file.
2026-06-18 01:57:23 +02:00
can1357 fd06fe07ae refactor(coding-agent): migrated tool schema helpers to toolWireSchema
- Swapped legacy `zodToWireSchema` for `toolWireSchema` to normalize tool schemas.
- Updated `getSchemaPropertyKeys` in `tool-index.ts` to process schemas via `toolWireSchema`.
- Refactored tool token estimation in `context-usage.ts` to utilize the new schema helper.
- Fixed ArkType assertion checks in test helpers to correctly verify instances against `arkType.errors`.
- Aligned test suites and mock specifications with raw schema-based parameters instead of manually stringified JSON structures.
2026-06-18 01:57:23 +02:00
can1357 93347438ed fix(coding-agent): prevented async leaks and state pollution on disposal
- Added `#disposed` flags and guards to `StatusLineComponent` to stop async callbacks running post-dispose.
- Updated `onThemeChange` to return an unsubscribe function and registered it in `InteractiveMode`.
- Fixed schema validation for `spinnerFramesSchema` to narrower types instead of dynamic or-validation.
- Resolved settings leaks by saving and restoring `tuiTight` state in tests.
- Added regression tests verifying that pending async microtasks do not trigger updates after disposal.
2026-06-18 01:57:23 +02:00
can1357 7bec9af48f refactor(coding-agent): integrated zod validation and upgraded typebox shim
- Imported and injected `zod/v4` under `zod` in runtime environments for custom commands, custom tools, extensions, and hooks.
- Added corresponding Type definitions to `CustomCommandAPI`, `CustomToolAPI`, `ExtensionAPI`, and `HookAPI` interfaces.
- Re-exported Zod and its alias from the main package entry point to expand the public API surface.
- Refactored the internal Typebox validation shim to support parsing via standard `.safeParse()` and `.toJSON()` methods.
- Advanced Typebox shim utility capabilities with support for dual-key record validation and enhanced schema structure handling.
2026-06-18 01:57:23 +02:00
can1357 3f304ee5a8 refactor(agent-core): isolated token counting into a new local tokenizer
- Extracted native token counting into a new localized `tokenizer.ts` wrapping `@oh-my-pi/pi-natives`.
- Introduced a lightning-fast byte-length estimation logic for token counting when accurate counting is disabled.
- Diverted token calculations to the faster estimator during test environments and when `PI_TOKENIZER_ACCURATE` is falsy.
- Updated agent base and coding-agent sessions to consume the new localized `countTokens` utility.
2026-06-18 01:57:23 +02:00
can1357 17ce678468 fix(coding-agent): handled provider error finish reasons and preserve subprocess failure codes
- Added detection for provider error finish reasons occurring before tool calls to identify fatal messages.
- Prevented subprocess tool execution finalization from resetting a non-zero exit code when yield items exist.
- Ensured a default error message is set in stderr when a subprocess fails after yielding a result.
2026-06-18 01:11:10 +02:00
can1357 dc915dfef1 feat(coding-agent/eval): tracked and forwarded session id and working directory
- Added `sessionId` and `cwd` tracking to JS evaluator session instances.
- Updated `acquireSession` in the JS context manager to update existing session identity and directory metadata on reuse.
- Forwarded the current working directory from `executePerCall` and `executeOnSession` callers to the underlying Python kernel tasks.
2026-06-18 00:59:56 +02:00
can1357 7c295faa52 feat: added native support for ArkType schemas alongside Zod
- Added native support for parsing, normalized validation, and serialization of ArkType schemas throughout the agent pipeline.
- Implemented pruning of unconstrained union branches and normalization helpers to handle unrepresentable strict-mode branches.
- Patched ArkType's schema package to preserve declared object key order during serialization.
- Integrated ArkType schemas into `agent-loop` and migrated coding agent tool parameters to ArkType format.
2026-06-18 00:59:56 +02:00
can1357 92855e3daa refactor(coding-agent/web): derived search provider order and labels from common options
- Derived the `SEARCH_PROVIDER_ORDER`, `SEARCH_PROVIDER_PREFERENCES`, and `SEARCH_PROVIDER_LABELS` metadata dynamically from a single `SEARCH_PROVIDER_OPTIONS` source of truth.
- Reprioritized the default search provider sequence, shifting higher-order choices like Perplexity, Gemini, and Anthropic ahead of Tavily and Brave.
- Updated documentation to reflect the new search provider evaluation order.
2026-06-18 00:59:55 +02:00
can1357 e92db73ec6 feat(coding-agent/tools): added explicit ArkType schema descriptions to agent tools
- Added explicit ArkType schema descriptions across all coding agent tool definitions.
- Updated schema definitions in autoresearch and commit tools with descriptive wrappers.
- Documented tool schema enhancements in the packages/coding-agent CHANGELOG.
2026-06-18 00:59:55 +02:00
can1357 a050474af7 feat: migrated validation schemas and tool definitions from Zod to ArkType
- Migrated all wire protocol, schema definitions, and tools validation from Zod to ArkType across multiple packages.
- Updated extension runtimes, custom tools loader, and TypeBox compatibility shim to expose and use ArkType instances.
- Added a comprehensive ArkType migration guide, validation parity tests, and helper utilities.
- Removed redundant PDF asset routing and parsing implementations from the read tool.
2026-06-18 00:59:53 +02:00
can1357 ead63d2440 feat(coding-agent/prompts): added a constraint to use box-drawing characters
- Added a constraint to use box-drawing characters (U+2500) instead of ASCII rules for visual separators in terminal prose.
2026-06-17 23:45:47 +02:00
can1357 d4317d3d20 feat(ai): consolidated OpenAI-family streaming and add OpenRouter API support
This change introduces a new `openrouter` API type and extensively refactors OpenAI-family streaming providers, centralizing shared logic and improving robustness.

Key changes include:
- **Unified OpenAI-family Logic:** Consolidated core utilities, compat resolution, request shaping, and stream processing into `openai-shared.ts`, reducing duplication across `openai-completions`, `openai-responses`, and `openai-codex-responses`.
- **OpenRouter API Type:** Introduced a dedicated `openrouter` API type with dual-surface compatibility, allowing it to dispatch requests as either OpenAI Chat Completions or Responses.
- **Enhanced Provider Integration:**
    - Improved Perplexity search to leverage shared OpenAI streaming transports, including API-key fallback to OpenRouter and support for Perplexity's Responses API.
    - Integrated xAI-specific logic directly into the shared `stream.ts` dispatch, removing the dedicated `xai-responses` provider.
    - Refined credential parsing for Google Gemini CLI and handling of Azure deployment names.
- **Robustness & Consistency:** Improved error handling for Codex, standardized output token parameter resolution, and ensured consistent application of reasoning suppression across all Chat Completions dialects.
- **New Documentation:** Added `provider-endpoint-constraints.md` to detail endpoint-specific behaviors and quirks for various providers.
- **Telemetry & Debugging:** Extended telemetry propagation to advisor calls and overflow compaction tasks. Improved debugging for Codex WebSocket failures and stream error messages.
- **Tooling & Security:** Updated browser stealth scripts to prevent detection and added a new `ts-no-inline-cast-access` TTSR rule.
2026-06-17 21:36:48 +02:00
can1357 eb67863e75 feat(coding-agent/tools): secured browser stealth scripts against detection
- Bound native Reflect methods to local variables in the browser launch script to prevent detection.
- Updated stealth injection scripts to use the bound Reflect methods instead of global Reflect calls.
- Fixed a type assertion issue in the AgentSession tool proxy.
2026-06-17 20:59:20 +02:00
can1357 adaa032333 style(coding-agent/mcp): reformatted MCP render functions for multiline callback formatting
- Reflowed `renderMCPCall` and `renderMCPResult` `WidthAwareText` calls over multiline formatting only.
2026-06-17 20:42:46 +02:00
can1357 ee41822c27 feat(coding-agent/discovery): added ts-no-inline-cast-access rule to built-in discovery rules
- Added a new builtin rule definition file, `ts-no-inline-cast-access.md`, with AST patterns that flag inline cast member access and usage guidance.
- Registered the new rule in `src/discovery/builtin-rules/index.ts` so it is included in the built-in TypeScript rule set.
- Updated `ts-no-any.md` to recommend schema parsing at trust boundaries and clarified when to choose schema parsing, guards, or unchecked casts.
2026-06-17 20:42:39 +02:00
can1357 30229b97c4 feat(cli): added TTSR CLI command with list and test execution modes
- Added a top-level `ttsr` CLI command with `list` and `test` actions.
- Added snippet input handling for inline text, `--file` path, and stdin via `--file -`.
- Added test-mode context inference and result output for matched and unmatched rules.
- Added CLI tests for source inference, explicit source overrides, JSON output, and list mode.
2026-06-17 20:42:19 +02:00
can1357 c81adde1f1 fix(coding-agent/mcp): made MCP rendering adapt to available content width
- Wrapped MCP call and result renderers in WidthAwareText so formatting can use runtime content width.
- Computed inline argument preview budget from the available content width instead of a fixed 70-character cap.
- Updated raw text truncation in MCP results to target the measured content width while preserving expand hints and warnings.
2026-06-17 19:16:12 +02:00
can1357 3588fd30f2 feat(coding-agent/tui): adjusted tool output rendering to use terminal content width
- Introduced a WidthAwareText component that formatted fallback content during render using the computed content width.
- Updated ToolExecutionComponent to use WidthAwareText and invalidate cached text instead of a fixed-width Text path.
- Reworked generic tool output formatting to derive inline and output truncation budgets from terminal width rather than hard-coded 70/80 columns.
2026-06-17 19:14:28 +02:00
can1357 020dd5f821 feat(coding-agent/tools): added PDF embedded-image read support to the read tool
- Added PDF member read syntax (`doc.pdf:<member>`) and trailing-colon listing.
- Added asset-read handling to serve extracted PDF images as inline image content.
- Added PDF image extraction caching keyed by size and mtime with marker files for retries.
- Added basename validation that rejects unknown/traversal-like PDF members and shows available names.
2026-06-17 17:20:09 +02:00
can1357 7251ca16d4 test(coding-agent): added OpenAI key initialization in context test setup
- Added initialization of an OpenAI runtime API key in the context consolidation test setup.
2026-06-17 15:26:11 +02:00
can1357 7e87709d22 chore: bump version to 16.0.5 2026-06-17 15:11:23 +02:00
can1357 9f16ca4797 feat(tui): enabled tight layout mode with optional 1-char padding reduction
- Added new `tui.tight` setting with default `false` and documented behavior.
- Added global tight-mode APIs and `setIgnoreTight` propagation across Box, Text, and Markdown.
- Handled `tui.tight` updates to refresh UI borders and trigger rerendering.
- Updated key message components to ignore tight mode selectively and preserve intended spacing.
2026-06-17 15:09:55 +02:00
can1357 4678c80cd8 fix(tui): fixed inline image transmit replay for full paint
- Adjusted image budget IDs to use a shared 24-bit seed and wrap safely so new budgets no longer collide.
- Added transmit-state reset and changed image output ordering so full paints can replay image data after terminal clears.
- Updated image and protocol tests to match the new wrapped-id behavior and cursor-save/restore-wrapped transmit sequences.
2026-06-17 15:03:32 +02:00
can1357 0075014fe9 fix(tui): used cursor save/restore for direct image placement
- Added cursor save/restore escape handling around direct image emission.
- Replaced the previous up-and-down cursor movement sequence with restore logic to keep renderer output positioned correctly.
- Ensured direct image replay path no longer depends on moving back down after placement to align the cursor.
2026-06-17 13:54:48 +02:00
can1357 19b5479aca chore: update changelogs 2026-06-17 13:51:39 +02:00
can1357 401effc940 fix: removed redundant antigravity preamble instructions
- Removed ANTIGRAVITY_NO_PREAMBLE_INSTRUCTION from the shared Gemini header constants.
- Updated Gemini CLI and web search request builders to prepend only ANTIGRAVITY_SYSTEM_INSTRUCTION before existing system parts.
- Adjusted the Gemini CLI alignment test to stop asserting the removed anti-preamble prompt lines.
2026-06-17 13:50:20 +02:00
can1357 af6e83a651 fix(coding-agent): replaced JSON string equality checks with deep equality
- Changed provider delta input comparisons in `buildResponsesDeltaInput` to use `Bun.deepEquals` instead of stringified JSON checks.
- Updated session message diffing to return early on length changes and compare normalized entries with deep equality.
- Replaced JSON-string assertions in the issue-966 repro test with `Bun.deepEquals` for stable equality checks.
2026-06-17 13:45:11 +02:00
can1357 54d212ec33 feat(coding-agent): added advisor immune-turn window for concern/blocker interruptions
- Tracked completed primary turns in `AgentSession` and started an immune-turn window after each interrupting advisor steer.
- Routed follow-on `concern`/`blocker` notes to the aside channel while the immune window is active, while preserving prior auto-resume-suppressed handling.
- Added the `advisor.immuneTurns` setting and tests for immune-turn detection and delivery-channel decisions.
2026-06-17 13:21:47 +02:00
can1357 e4a87fa3ce feat(coding-agent): added matplotlib rendering and image persistence across session reload
- Added Matplotlib figure PNG rendering and display tracking in Python runner to emit PNG output immediately when figures are displayed via display(fig).
- Extended session persistence to externalize oversized image payloads in both content and details.images, enabling tool result images to survive session reload.
- Enhanced session loader to resolve image data payloads and blob references across content and details.images during session reconstruction.
- Added image cache invalidation in TUI image component when image protocol, cell dimensions, or Kitty Unicode placeholder mode changes.
- Added comprehensive test coverage for Matplotlib display, image persistence across reload, and TUI image rendering with protocol and dimension changes.
2026-06-17 13:19:28 +02:00
can1357 003de8c0e1 fix(coding-agent): fixed web search fallback and settings section registration
- Updated `executeSearch` to read `providers.antigravityEndpoint` once and catch uninitialized-settings errors, so web search fallback no longer aborts before any provider runs.
- Added missing `Vision` and `Git` entries to `TAB_GROUPS` so those new settings now render in their intended setting-section groups.
- Adjusted context and idle-compaction tests to wait for prompt-in-flight transitions and provide `getContextUsage` for deterministic snapshots during pending turns.
2026-06-17 12:45:32 +02:00
usr_bin_roygbiv 39169c8878 feat: add max-time deadline support 2026-06-17 12:44:23 +02:00
can1357 d0e896a0ee fix(coding-agent): clean rebased session stop state
- Removed obsolete context-usage provider fields left unused after rebasing the session stop branch.
- Sorted the rebased SDK import block so `bun check` stays clean.
2026-06-17 12:28:10 +02:00
can1357 6e918712fd fix(coding-agent): guard session stop continuations
- Guarded `session_stop` continuations against aborted or superseded hook results before queueing hidden follow-up turns.
- Reported compaction recovery continuations from `#checkCompaction` and skipped stop hooks while internal recovery owns the next turn.
- Let terminal empty-stop retry caps fall through to `session_stop` and added regression coverage for aborts, empty-stop caps, and promotion recovery.
2026-06-17 12:26:52 +02:00
ben c40bc8365e fix(coding-agent): honor session stop reason fallback 2026-06-17 12:26:52 +02:00
ben bd14fed678 fix(coding-agent): finalize session stop lifecycle 2026-06-17 12:26:52 +02:00
ben c93774f892 fix(coding-agent): implement session stop hook semantics 2026-06-17 12:26:52 +02:00
ben b73325b103 fix(coding-agent): emit session_stop after subagent completion 2026-06-17 12:26:01 +02:00
ben b7ac4b4c43 fix(coding-agent): use session stop extension event 2026-06-17 12:26:01 +02:00
ben 8e45ed9016 fix(coding-agent): add subagent stop extension event 2026-06-17 12:26:00 +02:00
can1357 cca689bd4f fix(minimax): preserve generic auto fallback
- Kept `resolveDialect("auto")` on the legacy GLM fallback when a tool-less model has no catalog-recognized dialect.
- Added `sdk-dialect` coverage for unclassified tool-less models alongside MiniMax preferred dialect routing.
- Updated the coding-agent changelog entry to mention MiniMax auto-mode routing.
2026-06-17 12:24:49 +02:00
can1357 46739f2018 fix(minimax): route auto owned dialect selection
- Routed `resolveDialect("auto")` through `preferredDialect(model.id)` when a tool-less model exposes an id, preserving the legacy GLM fallback for id-less models.
- Added `sdk-dialect` coverage for MiniMax and Qwen auto owned dialect selection while keeping native and explicit dialect behavior unchanged.
2026-06-17 12:24:49 +02:00
Alexander Kirilin 89d2ed8f66 fix(minimax): expose owned dialect selectors 2026-06-17 12:24:49 +02:00
can1357 a0cffe4814 feat: updated model-aware API-key resolution and antigravity endpoint failover
- Updated getApiKey signatures to accept a Model and return ApiKey or ApiKeyResolver.
- Updated stream key handling to resolve credentials per model and use seedApiKeyResolver for retries.
- Added antigravityEndpointMode setting with auto/production/sandbox endpoint selection.
- Added 429/5xx endpoint failover for Gemini stream, usage, search, and image calls.
2026-06-17 12:24:21 +02:00
can1357 409196bf2e fix(coding-agent/session): fixed context usage breakdown to prefer completed in-turn anchors
- Fixed context breakdown to anchor estimates on the latest completed assistant usage message after compaction.
- Adjusted pending-context usage selection to prefer an in-turn provider anchor when available at/after cutoff.
- Added a contextUsageRevision cache token so status-line context memo invalidates after snapshot clear.
2026-06-17 12:24:20 +02:00
can1357 48decd15d7 fix(coding-agent): fixed context usage tracking to keep status and selector totals in sync
- Added context snapshot metadata to AssistantMessage for prompt and non-message token history.
- Anchored context usage calculations on assistant snapshots and computed percent numerically.
- Updated status-line, /context, selector, and interactive mode flows to share session usage totals.
- Extended status-line cache fingerprinting and invalidation for assistant usage and prompt/tool/skill changes.
2026-06-17 12:24:20 +02:00
can1357 3f32971944 feat(ai): align OpenRouter max_tokens with caller intent
OpenRouter previously omitted `max_tokens` entirely (except for specific models) to prevent unintended provider filtering when a model's catalog default `maxTokens` exceeded an upstream's actual capacity. This could lead to incorrect routing if a model had a high catalog cap but individual providers under OpenRouter did not.
2026-06-17 12:24:19 +02:00
can1357 be734240ce ux(coding-agent): added line-number gutters to read tool code cells
- Read tool result details now include optional per-line number arrays so displayed content can retain original line mappings.
- Read tool group and renderer now forward code start-line and line-number metadata into code-cell rendering.
- Code cell rendering now draws aligned line-number gutters and pads hidden-line hints to keep gutter alignment.
2026-06-17 12:24:19 +02:00
roboomp d2bc4b02d2 fix(coding-agent): preserved windows ssh key stat checks
Kept missing-file and directory identity validation on Windows while skipping only the Unix mode-bit rejection.

Added regression tests for Windows missing and directory identity paths.

Fixes #2850
2026-06-17 12:24:19 +02:00