Commit Graph

243 Commits

Author SHA1 Message Date
Adryel Dearo ecbc2a3c15 feat(coding-agent): add configurable title system prompt for sessions
- add discovery of `TITLE_SYSTEM.md` and pass it through interactive startup context
- route custom title prompts to online and local tiny title generators via protocol
- update session-title docs and changelog with override behavior
- add tests for prompt discovery, forwarding, and fallback to bundled title prompts
2026-06-10 08:31:32 +02:00
can1357 35474d98be refactor(config): moved lastChangelogVersion to marker file
- Stored last-seen version in ~/.omp/agent/last-changelog-version so version bumps no longer dirty user configs.
- Migrated the legacy config.yml key into the marker, never clobbering a newer existing marker.
- Added read/write helpers and migration tests.
2026-06-10 02:22:33 +02:00
can1357 f0b6608aff fix(coding-agent): fixed edit pipeline silent-corruption paths
non-exact patch matches warn and prefix/substring matches must preserve the discarded suffix; multi-entry edits stop at first failure and report applied vs not; ast-edit and file-mention snapshots use canonical realpath keys and re-record post-apply; notebook marker-shaped lines escaped on render; fuzzy matcher pre-normalizes once per seek; streaming preview caches text+tree per tick.
2026-06-10 01:27:40 +02:00
Can Bölük 19ce6b28c4 Merge pull request #2116 from danzaio/fix/split-commit-empty-hunks
fix(commit): reject empty split hunk selectors
2026-06-08 22:29:16 +02:00
can1357 243ad581e6 perf(commit): reuse split diff parser 2026-06-08 15:17:38 -03:00
can1357 22b152e220 fix(commit): allow deferred changelog targets 2026-06-08 14:56:36 -03:00
can1357 5d468a2378 fix(commit): reject empty split hunk selectors 2026-06-08 13:31:09 -03:00
can1357 3d5572a0fc test(natives): documented AST conditions and expanded astMatch tests
- Updated `docs/ttsr-injection-lifecycle.md` to document `astCondition` behavior, including registration rules and tool-stream matching.
- Extended `packages/natives/test/native.test.ts` with new `astMatch` coverage for Smart matching, metavariable consistency, parse errors, and empty-language rejection.
2026-06-08 15:00:28 +02:00
can1357 0890b2be61 fix: fixed tool-call recovery, stream parsing, and image normalization flows
- Fixed tool result validation to reject invalid blocks and append explicit error diagnostics.
- Handled aborted and leaked tool calls by returning abort results and dropping partial leaked output.
- Fixed Anthropic streaming by enforcing strict SSE parsing and content-block lifecycle checks.
- Fixed image handling by normalizing model-context inputs and preserving images on resize failure.
2026-06-08 14:40:18 +02:00
can1357 1e5017bf7d feat: enabled block-boundary context support across read and diff previews
- Added tree-sitter `enclosing_block_boundaries` API with line range models.
- Added N-API `enclosingBlockBoundaries` bridge and exported JS declarations.
- Replaced matching-bracket context resolution with source-aware block context in read and diff flows.
- Passed source path through diff/read generators to surface native block boundary previews.
2026-06-08 14:29:59 +02:00
can1357 b8eecfffde feat(coding-agent): added matching bracket context lines to read and edit previews
- Added matching-bracket utilities to locate partner lines for visible spans.
- Added read tool output to use displayContent text and startLine for bracket-aware previews.
- Added matching-bracket context rows to generateDiffString and generateUnifiedDiffString.
- Adjusted diff row insertion to deduplicate and keep contiguous changed groups together.
2026-06-08 14:00:54 +02:00
can1357 30959d3ad4 feat(coding-agent): updated title guidance to generate 3-7 word sentence-case titles
- Updated the title-system prompts to enforce 3-7 word, sentence-case session titles.
- Expanded handling guidance so non-task inputs can map to "none" and link/reference-only messages are summarized by intent.
- Updated the title tool description and generator comments to match the new sentence-case, 3-7 word title contract.
2026-06-08 11:53:37 +02:00
can1357 caa9c69309 feat(coding-agent): added provider-priority model selection and refined fallback ordering
- Added first-party-first provider priority defaults for model ranking.
- Consolidated model resolution to use getModelMatchPreferences from session settings.
- Prioritized providerPriorityRank ahead of usage rank when picking preferred models.
- Added second-pass fallback to default-model or API-key-valid matching order.
2026-06-08 01:32:39 +02:00
can1357 41aa4de9b2 fix(packages/coding-agent): resolved OSC5522 BEL and metadata behavior
- Tracked kitty-dot payload listings to emit BEL-terminated OSC5522 responses.
- Updated non-kitty-dot writes to include mime in metadata and drop ST terminator.
- Adjusted enhanced-paste tests to assert BEL terminator and metadata formatting.
2026-06-08 01:09:47 +02:00
roboomp 29730eb643 fix(tui): handle kitty osc 5522 dot-listing paste responses
Kitty implements OSC 5522 paste-event listings by sending one DATA
packet whose mime field decodes to the literal dot sentinel and whose
payload carries the available types as a whitespace-separated list. The
TUI previously only honored the ancillary per-type DATA-packet form, so
plain-text Kitty pastes were rejected as unsupported.

Decode the dot-listing payload during the listing phase and keep the
per-type packet path as a fallback. Also emit the follow-up OSC 5522 read
request using the Kitty protocol shape: the selected MIME list belongs in
the request payload, not in mime metadata. Sending it as metadata makes
Kitty parse an empty requested MIME list and returns no clipboard bytes,
which surfaces as an empty paste.

Add regression coverage for Kitty's text-only and multi-type listings,
and assert the payload-form read requests for default and primary
selection paste events.

Fixes #2051
2026-06-07 13:14:38 +00:00
roboomp 43477234e2 fix(tui): handle kitty osc 5522 dot-listing paste responses
Kitty implements the OSC 5522 "list available MIME types" reply by
sending one DATA packet whose `mime` field decodes to the literal `.`
and whose payload carries the available types as a whitespace-separated
list (see `fulfill_read_request` in kovidgoyal/kitty:kitty/clipboard.py
when the requested MIME is `TARGETS_MIME = '.'`). The 5522-mode
ancillary spec (rockorager.dev/misc/bracketed-paste-mime) instead
encodes each available type as its own DATA packet with an empty
payload.

The TUI's EnhancedPasteController only honored the ancillary form. When
Kitty delivered the dot-listing form for a plain-text paste, the parser
pushed `.` into the candidate list, `choosePasteMime(["."])` matched
nothing, and the editor surfaced "Clipboard paste has no supported text
or image data" instead of inserting the text.

Decode the payload as a UTF-8 whitespace-separated MIME list when the
DATA packet's mime is the dot sentinel, then fall through to the
existing per-type behavior. Add two regression tests covering the
single-type and multi-type Kitty payload shapes.

Fixes #2051
2026-06-07 12:10:52 +00:00
can1357 6adf98fd10 feat(coding-agent): added OSC5522 enhanced paste support for local image and text inserts
- Added OSC5522 parsing and a payload controller that prefers image MIME and reassembles chunks.
- Added bracketed image-path detection and `onPasteImagePath` callback wiring in the editor.
- Added local image-path paste insertion with fallback to text paste on image-size errors.
- Added `Editor.pasteText()` and OSC5522 disable sequencing on terminal cleanup.
2026-06-07 06:43:52 +02:00
can1357 c10eb5e50e feat(coding-agent): added resolver-based auth retries to image and search tools
- Routed image-gen, inspect-image, and web search providers through `withAuth`.
- Used `reuseInitialApiKey`/`createAuthStorageResolver` for force-refresh and rotate retries.
- Attached HTTP status to thrown errors so the retry classifier detects retryable failures.
2026-06-07 04:49:19 +02:00
can1357 cba6641299 feat: enabled resolver-based API key retries with refresh and rotation
- Added `ApiKeyResolver`/`ApiKey` types and exported auth-retry helpers.
- Changed stream and gateway auth retry handling to use resolver steps.
- Added initial-key, force-refresh, and rotate credential retries for auth failures.
- Updated agent and coding-agent integrations to use context-aware API-key resolvers.
2026-06-07 04:20:48 +02:00
can1357 8943fb8084 refactor(file-mentions): removed fuzzy and prefix resolution for @-mentions
- Resolved @-mentions to exact existing paths only.
- Relied on the TUI @-selector to insert complete real paths.
- Dropped candidate scanning to avoid dragging in same-named files.
2026-06-05 15:51:37 +02:00
can1357 1dfab0a883 fix(file-mentions): resolved trailing-slash mentions to directories only
- Made `@`-mention resolution directory-aware so a mention ending in `/` or `\` matches only directory candidates.
- Stopped stripping the trailing separator and fuzzy-matching an arbitrary same-named file (e.g. npm scopes like `@scope/`).
- Left non-slash mentions unchanged.
2026-06-05 15:47:53 +02:00
roboomp 356db2b845 fix(coding-agent): surfaced title generation failures
Logged structured session-title generation skip and failure outcomes with session/model context, and prevented credential lookup errors from escaping into the caller's swallowed promise path.

Added regression coverage for missing and failing title credentials.

Fixes #1892
2026-06-04 22:27:23 +00:00
can1357 e495f073da feat(coding-agent): deferred session titling past greetings
- Skipped titling for greeting/filler/empty first messages deterministically, retrying on later user messages.
- Let capable title models decline taskless input via a "none" sentinel.
- Guarded against clobbering a name set by a concurrent attempt.
2026-06-04 15:24:53 +02:00
Can Bölük a6997b1b7f Merge branch 'main' into fix/session-accent-light-contrast 2026-06-04 06:28:21 +03:00
can1357 1379772628 refactor(utils): consolidate color utilities into pi-utils
Move the color math added for the session-accent fix into the shared
@oh-my-pi/pi-utils color module instead of a coding-agent-local file:

- colorLuma, relativeLuminance, and hslToHex now live in
  packages/utils/src/color.ts (hslToHex lifted out of session-color.ts).
- Drop the duplicate hex parser: toRgb reuses the existing hexToRgb and
  paletteToRgb returns the shared RGB type, so hex parsing lives once.
- Delete packages/coding-agent/src/utils/color.ts; theme.ts and
  session-color.ts import from @oh-my-pi/pi-utils.
- Move the color unit test into the utils package; repoint session-color
  test imports.

No behavior change to accent luminance capping.
2026-06-04 05:27:11 +02:00
can1357 2e14db49ca fix(coding-agent/utils): fixed jj workspace detection for non-default .jj/repo indirection
- Detection now recognized `.jj/repo` as workspace metadata whether it is a directory or a file.
- Repository resolution followed `.jj/repo` file indirection so non-default `jj workspace add` workspaces resolved their shared store path.
- Tests were added to confirm `jj.repo.is` and `jj.repo.resolve` handle file-backed `.jj/repo` workspaces correctly.
2026-06-03 16:37:03 +02:00
Paweł J. Wal 9d9119a8c6 Merge branch 'main' into fix/session-accent-light-contrast 2026-06-03 07:17:57 +02:00
can1357 6baa985672 feat(coding-agent): added ts-no-deprecated-leftovers builtin rule
- Warns against leaving `@deprecated` compatibility shims instead of finishing a refactor.
- Registered in the builtin rule index and covered by the defaults test.
2026-06-03 00:13:24 +02:00
can1357 bce01ce0db refactor(jj): restructured exports into namespaced repo and diff objects
- Grouped `isRepository`, `workspaceRoot`, and `clearWorkspaceRootCache` under a `repo` namespace (`repo.is`, `repo.root`, `repo.clearRootCache`).
- Promoted `diff` to a named export with a `changedFiles` sub-method via `Object.assign`.
- Added `ensureAvailable` check and `nameOnly` support to `diff`.
- Updated callers and tests to use the new API surface.
2026-06-03 00:13:05 +02:00
can1357 9b4a951919 refactor(jj): replaced subprocess-based workspace detection with fs walk
- Replaced `jj workspace root` subprocess call with a local `.jj/repo/store` directory traversal, eliminating process spawning overhead.
- Added LRU cache for resolved workspace roots to avoid redundant filesystem walks.
- Renamed internal `runCommand` helpers to `git`/`jj` for clarity.
- Replaced git subprocess setup in review test with mocked `git.status` and `git.diff` calls.
2026-06-03 00:10:23 +02:00
Paweł J. Wal 34e8a79994 Opus: fix(tui): use WCAG relative luminance for accent contrast caps
Per review on #1715: the cap fed gamma-encoded luma into the WCAG contrast formula, so the >=3:1 target wasn't real (light-poimandres #340df2 was ~2.5:1 actual). Split the color helpers into colorLuma (perceptual, for light/dark classification — unchanged behavior) and relativeLuminance (WCAG-linearized sRGB, for contrast ratios). Session accents are now sized, and tests asserted, against relativeLuminance, so >=3:1 holds against the actual surface. Theme keeps luma for isLight/isLightTheme and exposes the WCAG status-line luminance for the cap.
2026-06-02 17:07:05 +02:00
Paweł J. Wal 1c78f19c93 Opus: fix(tui): size session accent by status-line contrast, not a fixed cap
Per review on #1715: the light-theme cap was a fixed absolute luminance (0.2) tuned for near-white backgrounds. On a mid-light shipped theme like light-poimandres (statusLineBg #7390aa, luminance ~0.55) that still left accents at only ~1.8-2.4:1. Theme now exposes statusLineLuminance + accentSurfaceLuminance; getSessionAccentHex takes the surface luminance and caps the accent to guarantee >=3:1 (WCAG AA large) against the actual surface, so near-white and mid-light light themes are both legible. Tests assert contrast across light + mid-light surfaces.
2026-06-02 16:53:01 +02:00
Paweł J. Wal e58863238e Opus: fix(tui): classify numeric (256-palette) theme backgrounds
Per review on #1715: theme color values may be a 256-color palette index (colorValueSchema = string | number), so a custom theme can set a light statusLineBg numerically (e.g. 15 = white). bgIsLight only handled hex strings and returned false for numbers, routing those light themes through the dark-accent path and reintroducing the unreadable accent. Add paletteLuminance (0-15 xterm defaults, 16-231 color cube, 232-255 grayscale) and a colorLuminance(string|number) dispatcher; route bgIsLight and isLightTheme through it. Tests added.
2026-06-02 16:19:08 +02:00
Paweł J. Wal 4856c1dd3b Opus: refactor(tui): unify accent luminance math, accept #rgb shorthand
Per review on #1715 (nits 3 & 4): the BT.709 relative-luminance + #rrggbb parsing was duplicated three ways (session-color relativeLuminance, theme bgIsLight, isLightTheme), and each rejected #rgb shorthand via length !== 7 — so a custom theme using shorthand backgrounds silently kept the washed-out accent. Lift it into utils/color.ts hexLuminance() (accepts #rgb and #rrggbb), route all three call sites through it, and add tests.
2026-06-02 15:41:16 +02:00
Paweł J. Wal 06eb1d709f Opus: fix(tui): cap session accent luminance on light themes
The status line session_name (plus editor border / gap fill) colors itself with a per-session accent hashed from the name via hslToHex(hue, 0.9, 0.72). The fixed lightness is tuned for dark backgrounds; on light themes high-luminance hues (yellow/lime/cyan) render near-invisible (~1.3:1 contrast). statusLine.sessionAccent (#918) only gates the border/gap fill, not the segment text, so there was no way to make the title legible on a light theme.

Add Theme.isLight (from userMessageBg luminance) and make getSessionAccentHex bisect lightness to cap perceived luminance on light themes, keeping the per-session hue while staying readable. Pass theme.isLight at all four accent call sites; add a unit test.

Refs #918, #680.
2026-06-02 15:09:02 +02:00
Patrik Sundberg 5f5c61465a Document JJ utility exports 2026-06-02 11:45:18 +01:00
Patrik Sundberg f5114a4ba9 Support JJ workspaces in review 2026-06-02 10:45:58 +01:00
can1357 09d91301ae Merge remote-tracking branch 'fork-apoc/feat/cc-client-parity' 2026-06-02 10:31:52 +02:00
can1357 7b5517b255 fix(open): fixed WSL local file opening via wslpath and wslview
- Converted existing local paths to Windows paths via `wslpath -w` before opening.
- Used `wslview` directly in WSL environments, bypassing `xdg-open`'s broken file-handler translation.
- Fell back to `xdg-open` for URLs or when `wslview` is unavailable.
- Added unit tests covering WSL file, URL, and fallback scenarios.
2026-06-02 08:42:44 +02:00
Can Bölük 7b20de4ef1 Merge pull request #1587 from devxplay-forks/feat/raw-paste
feat(clipboard): add raw text paste functionality with keyboard shortcut
2026-06-02 09:18:16 +03:00
Miroslav Drbal 5d3718e82e refactor(ai,agent): dedup cch placeholder constant, reuse TextEncoder, patch in-place, drop Uint8Array copy
- Extract CCH_PLACEHOLDER_STR so createClaudeBillingHeader and wrapFetchForCch share one literal
- Add module-level cchEncoder singleton; reused for CCH_PLACEHOLDER, SYSTEM_MARKER, and per-request encode (was allocating a new TextEncoder per eligible request)
- patchCch mutates the caller-owned buffer in-place instead of slicing the full body just to write 5 bytes
- clipboard: Buffer.from() already returns a Uint8Array subclass; drop the redundant new Uint8Array() copy

Co-Authored-By: Claude <noreply@anthropic.com>
2026-06-01 22:23:16 +02:00
roboomp 56b222f544 fix(coding-agent): clone full repo when plugin source pins a SHA
git clone --depth 1 --single-branch only fetches the tip of the
requested branch, so any subsequent git checkout <sha> for a non-tip
commit fails with 'reference is not a tree'. The error was caught and
rethrown as 'shallow clone may not contain this commit', but the clone
arguments were never adjusted.

Drop --depth 1 (and --single-branch when no ref is requested) when the
caller supplies options.sha so the desired commit is present in the
local object store. The ref-only path remains shallow.

Fixes #1589
2026-05-31 14:47:14 +00:00
devxpi 7ac4ed9757 feat(clipboard): add raw text paste functionality with keyboard shortcut
- Add new keybinding `app.clipboard.pasteTextRaw` with Ctrl+Shift+V / Alt+Shift+V defaults
- Implement `readTextFromClipboard()` utility supporting macOS, Windows, Linux (Wayland/X11), and Termux
- Integrate raw paste handler into CustomEditor and InputController
- Text is inserted without formatting collapse to preserve whitespace and newlines
2026-05-31 22:29:40 +08:00
can1357 826c3b932d refactor(packages/coding-agent): reorganized tiny-title runtime stack
- Added tiny-title protocol contracts, including progress-state unions, message payloads, and transport interfaces.
- Added title text utilities to truncate long inputs, wrap `<user-message>` blocks, and normalize generated titles.
- Added tiny-title model registry and helpers with type-safe keys and runtime optional loading via optionalDependencies.
- Added client-side worker orchestration with spawn fallback, request queueing, progress/error routing, and smoke-test APIs.
- Added worker runtime for model resolution, prompt-based inference, lock-based install retries, and close-time cache clear.
2026-05-30 17:40:18 +02:00
can1357 4544db344c feat: added tiny-title generation core with worker flow and model specs
- Added `providers.tinyModel` with an `online` default and UI schema metadata; documented tiny-title updates in changelogs.
- Added tiny-title system prompt and title-text helpers to truncate input, wrap `<user-message>`, and normalize output.
- Added tiny-title model registry, local model specs, key validation, and cache-path helper.
- Added tiny-title transport/client/worker flow with spawn fallback, queued requests, ping checks, and graceful close.
- Updated `generateSessionTitle` to route by tiny-title model and race local generation against delayed online fallback.
2026-05-30 16:55:54 +02:00
can1357 01c34db450 feat(hashline): added full-file hash snapshots with 4-hex tags
- Replaced snapshot internals with full-file records and removed contiguous/sparse snapshot APIs.
- Added file-hash normalization, computed `computeFileHash`, and updated grammar/messages to 4-hex tags.
- Simplified recovery by checking whole-file hashes first, then applying merge-replay fallback after mismatches.
- Updated coding-agent tools to use `record`/`recordFileSnapshot` and skip hash headers for unsnapshotted large files.
- Expanded patcher and snapshot tests to verify 4-hex anchors, hash deduplication, and cache-capped behavior.
2026-05-29 18:12:08 +02:00
can1357 7c64576524 feat(hashline): replaced file-hash anchors with opaque snapshot-store tags
- Replaced 4-hex content-derived file hashes with 3-hex opaque tags minted by InMemorySnapshotStore, making tags session-bound pointers rather than content fingerprints.
- Removed lru-cache dependency; replaced LRU-bounded per-path rings with a flat 4096-slot global ring using a scrambled permutation to prevent LLM tag extrapolation.
- Made SnapshotStore required in Patcher (was optional); tag resolution now drives stale-anchor detection instead of recomputing hashes at apply time.
- Changed literal payload sigil from `|` to `+` and accepted `^A` shorthand for `^A-A`; added lenient recovery for bare bodies, lone `-` rows, and overlapping bare/concrete block pairs.
2026-05-28 01:00:23 +02:00
roboomp 8c37a8adb0 fix(coding-agent): scoped package-dir lookup to omp's own package
`getPackageDir()` walked up from `import.meta.dir` and fell back to
`getProjectDir()` (the user's `cwd`) when no `package.json` was located.
Inside `bun --compile` binaries `import.meta.dir` resolves to
`/$bunfs/root`, so the walk hit the filesystem root and `omp` ended up
reading the host project's `CHANGELOG.md` as its own — both in startup
"What's New" display and `/changelog`. Worse, parsing succeeded on any
`## [x.y.z]` heading, so `lastChangelogVersion` was persisted into
`~/.omp/agent/config.yml` based on the host project's file.

- Made `getPackageDir()` return `string | undefined`; removed the `cwd`
  fallback so package-asset lookup never bleeds into the host project.
- Extracted the walk-up into a pure `walkUpForPackageDir(startDir)` so
  the resolution contract is unit-testable from arbitrary directories.
- Made `getChangelogPath()` propagate `undefined` and taught
  `parseChangelog` to accept it, returning `[]`. Existing callers
  (`main.ts` startup, `/changelog` TUI handler, `/changelog` slash
  command) already gate on empty entries, so the compiled-binary path
  now skips changelog display cleanly without mutating settings.
- Added `test/issue-1423-repro.test.ts` covering the resolver contract,
  the `parseChangelog(undefined)` path, the `PI_PACKAGE_DIR` override,
  and the negative assertion that a host `## [99.0.0]` heading never
  surfaces as an omp entry.

Fixes #1423
2026-05-27 05:46:35 +00:00
can1357 b12e4698a6 feat: added @oh-my-pi/hashline package and migrated hashline tooling
- Added a dedicated @oh-my-pi/hashline package with parser, patcher, filesystem, snapshots, and release metadata.
- Migrated coding-agent hashline and stream entrypoints to @oh-my-pi/hashline and removed old hashline module exports.
- Changed multi-section hashline execution to validate section hashes and flush diagnostics only at the final commit.
- Added session fileSnapshotStore support and rewired edit/read/search/write tools to use it instead of fileReadCache.
2026-05-27 04:03:49 +02:00
can1357 30793c1655 refactor: restructured hashline to use file-level hash validation with colon separators
- Replaced per-line hash anchors with file-level hash validation in hashline format, changing anchor syntax from LINE+HASH to bare LINE numbers.
- Simplified hashline line separator from pipe (|) to colon (:) and replaced replace operator (->) with colon, added delete operator (!) for explicit line deletion.
- Implemented file-read snapshot caching with multi-snapshot ring buffer per path and file-hash-based recovery to detect and recover from stale edits.
- Refactored hashline grammar, parser, and execution to support file-level hash binding, anchor-scoped validation, and structural bracket warnings for delete operations.
- Updated documentation and test fixtures to reflect new hashline syntax with file hashes, colon separators, and delete operator throughout.
2026-05-26 13:25:22 +02:00