Commit Graph
44 Commits
Author SHA1 Message Date
33372a4170 feat: suggest one-click next messages after a finished turn (#1359)
* feat: suggest one-click next messages after a finished turn

* feat(pi-next-steps): publish suggest_next_steps as a vanilla pi extension

* fix(pi-next-steps): find suggestions past bookkeeping entries on resume

* refactor(ext-next-steps): compose the published pi-next-steps package

* test(pi-next-steps): add vanilla-parity cases and a first-release changeset

* docs: specify the published pi-next-steps package

* test(e2e): ask for next steps explicitly in the live chips spec

* docs(pi-next-steps): add a terminal demo clip for the pi.dev gallery

* docs: mark the next-steps specs active after review

* feat(web): bind the suggestion chips through rebindable local keys

* feat(pi-next-steps): offer next steps only when nothing else continues

* feat(web): put a suggestion in the input with Shift+click or Shift+Alt+N

* test(e2e): pin focus on the chat input after a suggestion chip is sent

* feat(next-steps): cap suggestions at nine, one per Alt+N

* fix: count a round a next-steps call ended as done after reload and in analytics

* feat(next-steps): send decisions to ask_user_question, keep chips for yes/no

* fix(next-steps): dedupe streamed suggestions and document terminal and locale gaps

* docs(next-steps): describe the rebindable keys, edit path and nine-chip cap

* test(e2e): reach the ask-keyboard host through the page's port

* fix(next-steps): keep the finished-turn framing so the agent still offers next steps

* fix(web): keep the final answer copyable when next-step suggestions follow it

---------

Co-authored-by: rsolmano <rinat.solmano@forgood.ai>
Co-authored-by: danyaberezun <danya.berezun@gmail.com>
2026-11-17 17:14:21 +00:00
Lykinanddanyaberezun ad9456eabc fix(i18n): 穿透透明类型包装检查界面文字 (#993)
由 OpenAI Codex 辅助完成;新增回归覆盖 satisfies、非空断言和尖括号类型断言。

Co-authored-by: danyaberezun <danya.berezun@gmail.com>
2026-11-11 17:17:44 +00:00
Rinat S 672d3a5a76 chore(deps): upgrade pi to 1.5.2 and expose cache warming in Settings (#1301)
* chore(deps): upgrade pi to 1.5.1 and port the Anthropic SSE framing patch

* fix(server): follow pi 1.5.1's moved provider default models

* refactor(server): drop the image-only queued-message workaround pi 1.5.1 fixes natively

* fix(server): wait for pending pi credential writes before the host exits

* fix(server): wait for pending pi credential writes before the host exits

* feat(settings): keep cache warming at streaming and expose pi's mode in Settings → Models

* fix(server): read pi settings for cache warming through createPiSettings and register the default override

* docs(pi-compatibility): record the pi 1.5.1 re-check and the cache-warming and credential-write adaptations

* docs(pi-compatibility): keep a removal gate for the queued-message image copy

* fix(server): keep the image override through pi's save() and reconcile cache warming for chats registering mid-write

* chore(deps): upgrade pi to 1.5.2

* refactor(server): trim cache-warming and credential-settle notes to one line

* fix(server): read the cache-warming mode from pi's settings file at every decision so delegated children follow it

* docs(server): record the accepted gaps of opted-in idle cache warming
2026-11-10 18:37:39 +01:00
danyaberezunandOLavrik 6d070e1628 chore(deps): upgrade Biome to 2.6.3 (#1297)
- biome.json: migrated (noPlaywrightMissingAwait and noIdenticalTestTitle left nursery), and
  Markdown formatting and linting stay off so specs keep their hand wrapping.
- The 2.6 formatter output for 35 files, mostly re-wrapped test.each calls.
- Fixes for the new diagnostics: a guardedContent helper and explicit guards instead of unsafe
  optional chaining in tests, Math.max in ChangesReviewGuide, a describeFrame rename for the
  Playwright describe rule, awaited dispose()/close() promises in e2e, textContent where the
  rendered text is not needed, and the dictation test reads the new line's own element.
- apps/website/src/styles.css: contextual icon, link, paragraph and image rules move after the
  plainer rules for the same elements, so specificity never descends. Equal-specificity rules keep
  their relative order (the tree-row/ft-row selector list is split around the hint hover rule) and
  the chat paragraph rules move together with their phone overrides; computed styles of every
  element on all 15 pages are unchanged.

Co-authored-by: OLavrik <Olya_lavrik@inbox.ru>
2026-11-10 10:30:34 +02:00
Andrey Markinanddanyaberezun 1a2087f327 build: typecheck with TypeScript 7 and drop TypeScript 6 (#1232)
Move the catalog `typescript` to 7.1.0-beta, the official native compiler. Package typecheck scripts keep
`tsc`. The spec-surface and check:i18n scripts move to the TypeScript 7 async API, and the website
replaces `astro check` (TypeScript 6 API only) with `tsc --runExternalCode` over
`@astrojs/ts-content-mapper`, which needs Astro 7.4.4 and therefore Node >= 22.23.4 for contributors.

Co-authored-by: danyaberezun <danya.berezun@gmail.com>
2026-11-09 14:05:40 +00:00
597e3d1d86 refactor: enable erasableSyntaxOnly and drop parameter properties (#1061)
* refactor: enable erasableSyntaxOnly and drop constructor parameter properties

Replace all 24 constructor parameter properties (13 files) with explicit
readonly/private fields assigned in the constructor, so every source file is
pure type-strippable TypeScript for Node, Bun, and oxc. Enable Biome
style/noParameterProperties, style/noEnum, and style/noNamespace, which also
guard files outside any tsconfig, and style/useReadonlyClassProperties, fixing
its three hits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(architecture): state the erasable-syntax guarantee without claiming Node runs sources

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor: drop constructor parameter properties added upstream since

Convert the parameter properties in turns/turns.ts (TurnTracker) and webNotifications.test.ts (MockNotification) to explicit fields so erasableSyntaxOnly and noParameterProperties pass.

* refactor: drop the parameter properties main gained since the last pass

* refactor: drop the parameter properties the speech module added

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: danyaberezun <danya.berezun@gmail.com>
2026-11-09 13:57:40 +00:00
Andrey Markinanddanyaberezun 465868d407 scripts: parse boundary and seam imports with oxc-parser (#1233)
* refactor(scripts): parse boundary and binary-seam imports with oxc-parser

* fix(scripts): fail on oxc parse errors and parse JavaScript sources as JSX

* fix(scripts): parse .cjs and .cts sources as CommonJS in the boundary scan

---------

Co-authored-by: danyaberezun <danya.berezun@gmail.com>
2026-11-09 10:46:45 +00:00
a3c4d2731d feat(ask-user-question): redesign the questionnaire card — stable height, notes and Other in place, rich previews, Discuss, receipt (#1192)
* fix(ask-user-question): make every questionnaire control reachable by keyboard in WebKit

* feat(pi-ask-user-question): add question previews, opt-in file previews, discuss-first answers and one-option confirmations

* feat(extensions): add per-extension settings and share the workspace file check through the session seam

* refactor(resource-renderers): share the framed file preview and add compact chrome for embedded frames

* feat(ask-user-question): drive file previews from the rich-preview setting and teach the Discuss and preview conventions

* refactor(ask-user-question): stack question pages at a stable height with in-place note slots and a real Other field

* feat(ask-user-question): add question previews, a fixed preview pane and a per-question Discuss mark to the card

* feat(ask-user-question): replace the answered record with a foldable question → answer receipt

* test(ask-user-question): cover stable paging, growing fields, previews, Discuss, the receipt and the rich-preview switch in Chromium and WebKit

* docs(specs): note the plan page's preview scope and the WKWebView tab-stop gap

* fix(ask-user-question): keep Discuss across reconnects, let the Other checkbox cancel it, and make previews keyboard-scrollable

* test(ask-user-question): click Submit only once the page-change reveal has settled

* feat(ask-user-question): Enter picks, Space adds a note, d discusses and the platform chord submits in the card

* feat(pi-ask-user-question): match the card's keys in the terminal — Enter picks, Space notes, Next and Submit rows, Ctrl+Enter sends

* docs(ask-user-question): describe the explicit-selection keyboard model in the specs and live spec

* chore(locales): restore package.json and tsconfig.json that a catalog edit rewrote

* docs(web): note that the platform modifier now comes from @thinkrail/ui/keyboard

* Document extension settings in the contracts, settings, host, store, transport and chat specs, move them to protocol v104 after the GitHub star ask took v103, and narrow stored setting flags with a type guard instead of a cast.

* Gate Discuss on a shared ASK_DISCUSS_PROTOCOL_VERSION (v104) so a v103 host, whose formatter would report an empty discuss as no answer, never shows the toggle.

* ci(e2e): fail over a stalled apt mirror when installing WebKit's system libraries

* fix(server): load extensions with the setting snapshot the loader records, so a change and revert mid-reload never leaves a stale tool schema current

* ci(e2e): cap each WebKit dependency install attempt so a trickling apt mirror retries instead of exhausting the wait

* ci(e2e): install WebKit's missing libraries without Playwright's font group, whose mirror download stalled past the wait

* Move extension settings and Discuss to protocol v105 after background workspace creation took v104

* test(e2e): assert the plan-page answer by its lasting receipt, not the transient sent state the card can leave before WebKit sees it

---------

Co-authored-by: OLavrik <Olya_lavrik@inbox.ru>
Co-authored-by: rsolmano <rinat.suleimanov@jetbrains.com>
2026-11-06 12:07:21 +00:00
Harshal Paltse 1a490f9d72 fix(dev): parse THINKRAIL_PORT strictly in the dev launchers (#1156)
* fix(dev): parse THINKRAIL_PORT strictly in the dev launchers

Add parsePort to @thinkrail/shared/freePort (plain decimal 0-65535) and use it in scripts/dev.ts and packages/server/src/dev.ts. Invalid values now warn and fall back to the default instead of becoming port 0, 16 or NaN. Adds tests and updates the shared SPEC.

* fix(dev): keep port 0 and warn on empty THINKRAIL_PORT
2026-11-05 10:41:37 +00:00
danyaberezun 9532c7c300 feat(scripts): count queue-on-queue and stacked failures once and read flakes from green e2e jobs (#1122)
* feat(scripts): count queue-on-queue and stacked failures once and read flakes from green e2e jobs

ci:flakes labeled deterministic merge-queue and stack failures as flakes and
missed flaky tests in green jobs. Rules now:

- A run resolves to its PR by head repository and branch (the latest PR
  opened by then), not only through GitHub's run-to-PR link, which covers
  open same-repo PRs; a merged PR's runs and queue entries count once.
- PRs linked because one's base branch is, or was before a retarget,
  another's head branch form a stack that counts as one change. Keys are
  repo-qualified, so a fork PR whose head is `main` absorbs nothing.
- A merge-queue entry whose base SHA is another entry's head SHA charges a
  test or step both failed to the lower entry's change; a failure the lower
  entry lacked stays its own.
- Batched GraphQL reads every run's check runs across all attempts and their
  annotations; a job without a read log contributes its "Playwright Run
  Summary" annotation, so flaky passes in green jobs count.
- Every attempt of a run that failed, was re-run, or holds a failed job
  (a run cancelled after a failure) is read; jobs a re-run carried over from
  an earlier attempt are dropped so nothing counts twice.

* fix(scripts): resolve a stacked PR's base to the branch owner at that time

A base branch resolved to the newest PR with that head, so a reused branch
name could join a later PR to an old stack. Bases now carry when they took
effect (PR creation, then each retarget event) and resolve to the PR that
owned the branch then, or the branch's only PR. gh calls that fail with a
GitHub 5xx or a timeout are retried twice, since one transient error
discarded the whole two-minute report.
2026-10-31 21:45:06 +00:00
Andrey MarkinandClaude Opus 5.5 ec2f2db511 chore(e2e): type-check the e2e tree in typecheck:root (#1064)
Add e2e/tsconfig.json (root config with an e2e include) and run it as
an extra tsc step of typecheck:root. Fix the stale and trivial errors it
surfaced: the removed "endTurn" stop reason, untyped evaluate element
parameters, unchecked index reads, ask/visualize tool arguments that
must be JSON objects, and exact-optional shard options.
reload-navigation.spec.ts stays excluded as the remaining to-do.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 00:19:49 +00:00
Andrey MarkinandClaude Opus 5.5 0c7acd4c5f chore(tooling): type-check root tooling, cli scripts, and website tests (#1063)
Add a root tsconfig for scripts/ and the Playwright configs, run it as the
turbo root task //#typecheck:root from `bun run typecheck`, and add the
missing root @types/bun. Include apps/cli/scripts in the cli tsconfig and
check website unit tests through tsconfig.test.json, since astro check
skips them. Fix the type errors this surfaced in e2e/shardPlan.ts and two
website tests.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 23:32:58 +00:00
Olga Lavrichenko 11655a187c fix(onboarding): bind provider logins to their starting surface, make smoke:logins hermetic, and stop account detection from stacking hung reads (#949) (#978) 2026-10-28 10:54:48 +00:00
Olga Lavrichenkoanddanyaberezun 9066aa9f4b feat(web): first-run onboarding — intro, privacy and connect-and-verify wizard, recommendations from detected accounts, and Start a new project (#808)
* squash: onboarding-first-run

* feat(onboarding): harden account detection, share the consent draft between the dialog and the wizard's privacy step, let custom presets place the TODO List, and align the layout e2e specs with Balanced opening on it

* fix(onboarding): advance the privacy step only after its consent save lands, verify a provider connected before the wizard reaches Connect, and record the new-project Default exception in the top-level docs

* fix(onboarding): keep provider status in one store snapshot invalidated by every change, adopt a consent choice confirmed elsewhere, fence the new-project setup continuation, offer API keys on every provider, and make the onboarding e2e deterministic

* test(projects): write the rollback test's hooksPath with forward slashes so git can parse it on Windows

* fix(locales): drop the Spanish strings for the removed login Submit key and the reworded open-project subtitle

* fix(locales): drop the Japanese strings for the removed login Submit key and the reworded open-project subtitle

* Harden onboarding connect: auto-recheck empty model lists, cancel a pending login on skip, split the wizard into step components, drop the viewport-cap table, and emit a created project once

* Verify a connection against an awaited model.refresh when the cached model.list is empty, instead of a fixed-delay re-read

* fix(onboarding): re-read provider status on Welcome entry and on another login's success, and hand off only from a current snapshot

* test(onboarding): settle the host before each cold start, run every teardown step, and drop wall-clock and inherited git-config dependence

* fix(onboarding): take the connect dialog's baseline from its first report, so a sign-in that lands before the opening re-read still hands off

* test(onboarding): read config.json tolerantly inside polls, remove the projects folder with retries, and count the toast before it auto-dismisses

* test(shared): wait for the Central watcher's second re-arm instead of a fixed 5 ms sleep

---------

Co-authored-by: danyaberezun <danya.berezun@gmail.com>
2026-10-28 01:38:52 +00:00
danyaberezunandrsolmano 565bf50a24 feat(extensions): run ask_user_question as a portable pi package composed per session (#869)
* feat(pi-ask-user-question): add the portable ask_user_question package with a dialog fallback

* feat(pi-ask-user-question): add the terminal questionnaire window and transcript renderers

* test(pi-ask-user-question): drive the terminal and dialog paths in the parity gate and a real session

* docs(pi-ask-user-question): add the package spec, README and first changeset

* refactor(ui): move AttentionLine into @thinkrail/ui for extension cards

* refactor(web): pass the ask card its host actions through ToolRenderProps.interaction

* refactor(ask-user-question): move the questionnaire card into its ThinkRail extension

* docs(web): point the ask card references at the ask-user-question extension

* feat(extension-api): let server extensions take per-session host services

* feat(server): flatten per-session factories of registry extensions

* docs(extensions): document per-session factories of registry extensions

* feat(ask-user-question): add the server half and register it with a session seam

* fix(server): keep registry extension tools ahead of same-name user packages

* feat(server): run ask_user_question through the extension and delete the host tool

* test(server): cover the ask-user-question switch, its reload and a same-name package

* docs(workflow): ask the round in plain chat when ask_user_question is absent

* docs: describe the shipped ask-user-question extension across the spec graph and README

* test(artifacts): answer a scripted ask_user_question through the packaged host

* fix(server): track only ask calls the extension announces, in our argument shape

* fix(web): let the ask card answer only the question the host is waiting for

* docs: record the announced-call ask lifecycle and the accepting card state in the specs

* fix(pi-ask-user-question): end the turn as abandoned when Stop closes a built-in asker

* refactor(ask-user-question): key the web on one tool-name constant and drop a duplicate result guard

* fix(ask-user-question): keep the card from claiming attention for a call the host is not waiting on

* fix(server): acknowledge an ask answer by its persisted details, not the rebuilt envelope (#936)

* refactor(extensions): run interactive tools through a tool-agnostic host contract keyed by toolCallId

The host's answer mailbox, restart repair, session state, wire method and web
interaction props were keyed on the ask_user_question name, and the core
imported texts, an envelope builder and the card from the extension. Make the
seam real: the mailbox (agent/toolResponses) tracks announced calls by id with
opaque responses; the enabled registry extensions declare which tools wait for
a person (ServerExtension.interactiveTools, with describeResponse for the
wording of a response delivered after a restart) and which renderers take an
interaction (ToolRegistrationOptions.interactive). needsInput becomes
{ kind: "tool-response", toolCallId }, session.answerQuestion becomes
session.respondToTool (protocol 92), the late reply is a tool-response custom
message (legacy ask-user-answers transcripts still read), and the pending
marker { kind: "ack" } plus its guard live in contracts. The ask types,
constants and guards leave contracts; the card type-imports them from its pi
package, which the boundary check now allows for a web half (value imports
stay rejected). The plan page renders the awaiting call through the tool
registry, and the web registry is populated at bootstrap so the plan panes
never read a transcript before it. Deleting the extension leaves the core
building; built-in extensions keep winning a same-name collision while enabled.

* fix(web): keep answering questions against a pre-v93 host for one compatibility window

The UI ships independently of the host, so a client at v93 can welcome a host
that still emits needsInput.kind "question" and only knows
session.answerQuestion. Read that state as the awaiting call, send the retired
method below TOOL_RESPONSE_PROTOCOL_VERSION through one transport helper the
chat and the plan page share, and keep the host's side of the window too: the
request registry forwards session.answerQuestion to the same delivery so an
already-loaded older client still answers.

---------

Co-authored-by: rsolmano <rinat.suleimanov@jetbrains.com>
2026-10-27 15:58:12 +00:00
danyaberezun c118c397f9 feat(scripts): add an on-demand CI flake report (#851)
* feat(scripts): add an on-demand CI flake report

* fix(scripts): key flake stats by file and change, and count every unexplained failed step
2026-10-23 21:48:39 +00:00
Rinat Sanddanyaberezun 5a7af32aef feat(web): translate the interface and let users add their own languages (#788)
* feat(web): translate the interface and let users add their own languages

* test(i18n): pass the translator in tests main added for usage counters and hydration

* fix(server): reattach the locale watchers when Linux drops them with a deleted folder

* fix(resource-renderers): retranslate the editor's comment controls without remounting

* fix(resource-renderers): install the current comment label when the editor mounts late

* fix(server): poll the locales folder instead of watching it

* fix(server): catch permission repairs and mtime-preserving rewrites in the locales poller

* fix(locales): let plural forms show or omit the count and fill missing forms from _other

* fix(i18n): stop terminal-group labels rendering their raw key and split the Done status from the Done action

* fix(web): translate default chat, terminal, Changes, diff and plan tab names at render instead of storing them

* fix(i18n): translate theme names, the default workspace, thinking levels and the remaining UI labels

* fix(chat): word the round closer, failure notices and durations at render instead of storing English text

* fix(chat): export the plan Markdown in the interface language

* fix(desktop): translate the native startup and update error dialogs

* fix(i18n): keep extension notices' text, report untitled sessions without an English title, and word the default workspace everywhere

* docs(specs): record that stored names carry no translated text and the plural-form rules

---------

Co-authored-by: danyaberezun <danya.berezun@gmail.com>
2026-10-21 20:55:50 +00:00
Rinat Sanddanyaberezun bbb0e3079a feat(visualize): show workspace files and before/after mockups in chat through the shared resource renderers (#784)
* feat(pi-visualize): show workspace files and before/after diffs with type "file"

* feat(visualize): show workspace files and before/after mockups in chat through the shared resource renderers

* fix(resource-renderers): guard large comparisons, canonicalize preview paths, resolve original-side assets

* chore(web): drop the unused diff dependency and stale path-helper notes after the largeDiff move

* fix(resource-renderers): give each Monaco editor mount its own model

* fix(resource-renderers): give the chat scope its own context and keep preview reads stable

* fix(web): re-read file previews after a reconnect and share the fs-change rule with file tabs

* fix(server): send a review that names its chat as one package

* fix(resource-renderers): keep preview view state through cards, full screen and comparison tabs

* fix(visualize): match the host read guard in file checks and reject a before that names the same file

* refactor(resource-renderers): share renderer toggles and the guarded diff mount across panes

* refactor(resource-renderers): share renderer selection and content derivation across surfaces

* refactor(web): make file comparisons their own diff-tab variant

* refactor(resource-renderers): share element-size measuring and fit HTML previews before paint

* test(web): pin the preview's path identity to the app's and drop the card's second canonicalization

* perf(web): keep review thread arrays stable per file so an unrelated comment re-renders no renderer

* refactor(resource-renderers): trim the barrel to what consumers use and document live card history

* fix(resource-renderers): read a host answer without file metadata as provisional text

* fix(resource-renderers): let an HTML preview width follow a shared view state

* fix(web): name each file in a multi-file review package in the chat

* fix(resource-renderers): mark a preview's retained content stale when a refresh fails

* docs(resource-renderers): set the stale notice text in a code span

---------

Co-authored-by: danyaberezun <danya.berezun@gmail.com>
2026-10-21 00:34:16 +00:00
Rinat Sanddanyaberezun 5bdaf6a4e3 refactor(web): extract the file and diff renderers into @thinkrail/resource-renderers (#783)
* refactor(web): extract the file and diff renderers into @thinkrail/resource-renderers

* docs(specs): mark the resource-renderers spec active

* refactor(web): pass renderer host markdown and code as values, preferences separately

* perf(web): subscribe review-draft scratch per slot so a keystroke re-renders only its composer

* perf(web): build Monaco file options only when their inputs change

* fix(web): keep the rendered markdown diff on screen while a refreshed merge is pending

* refactor(web): drop leftovers of the renderer extraction

* docs(specs): describe the static renderer host, per-slot review drafts, and fix drift from the move

---------

Co-authored-by: danyaberezun <danya.berezun@gmail.com>
2026-10-21 00:34:15 +00:00
Rinat S 22c83a91fc chore(pi-extensions): publish pi packages under the @thinkrail npm scope (#734) 2026-10-14 11:11:20 +00:00
Rinat S fa51117414 feat(extensions): visualize server half, server extension registry; delete pi-visualize (#675)
* feat(visualize): add the server half with the strict mermaid validator

* feat(server): add the ThinkRail extension registry with owner-scoped skill resolution

* refactor(server): compose registry extensions as named inline extensions

* build: stop generating factory entries for registry extensions

* chore: delete the superseded pi-visualize package

* test(artifacts): exercise strict visualize validation through the packaged host

* fix(desktop): read the build-support manifest through the real Bun CLI

* test(server): compare staged skill roots with native paths

* docs: record the visualize server half and the server extension registry
2026-10-07 16:06:54 +00:00
Rinat S 36c7ec57f3 refactor(extensions): extract the host UI SDK and visualize web renderer (#638)
* feat(extensions): enforce browser and server package boundaries

* refactor(ui): extract shared primitives and extension contracts

* refactor(visualize): compose the renderer through its web extension

* fix(web): migrate new main components to the extracted UI SDK

* fix(extensions): preserve resource UI and compiler census after extraction

* test(extension-api): scope browser guards to repository-relative paths

* fix(web): use native paths in build-time token checks

* fix(web): import quit hint class helper from shared UI
2026-10-06 08:14:19 +00:00
Rinat S a9d8eba344 feat(pi-visualize): publish @thinkrail.ai/pi-visualize for vanilla pi with a parity gate and release pipeline (#597)
* docs(specs): record the extensions strategy — portable pi packages and ThinkRail extensions

* docs(specs): publish pi packages under the @thinkrail.ai npm scope

* feat(pi-visualize): add publishable @thinkrail.ai/pi-visualize with TUI rendering and a validator seam

* ci(pi-packages): add the vanilla-parity gate for published pi packages

* ci(release): add Changesets and the pi-package publish workflow

* docs(pi-extensions): describe the parity gate and the release flow

* ci(release): tag only after a real publish

* fix(pi-visualize): keep TUI rows within the viewport and render commented sources

* ci(release): tag once every version is on npm and make the bootstrap publish work

* ci(release): report readyToTag=false on the pending-changesets exit

* docs(pi-visualize): switch the terminal renderer decision to lovely-mermaid

* feat(pi-visualize): draw and validate diagrams with lovely-mermaid
2026-10-04 16:14:26 +00:00
Rustam Sadykovanddanyaberezun 4e95628564 feat(resources): add chat-scoped command and subagent controls (#489)
* docs(resources): define chat resource controls

* feat(commands): add session-owned background commands

* feat(resources): expose chat-scoped resource controls

* feat(resources): add chat resource inspection and controls

* test(resources): enforce resource module public surfaces

* fix(e2e): use the active host for resource wire probes

* refactor(resources): trim redundant tests and private exports

* fix(agent): drain queued input during session teardown

* fix(resources): harden lifecycle and current-main compatibility

---------

Co-authored-by: danyaberezun <danya.berezun@gmail.com>
2026-09-30 22:10:13 +00:00
Rinat S d49d91bef3 feat(website): add consented journey analytics foundation (#524)
* Update website analytics specs for settled mechanics

* feat(website): add consented journey analytics foundation

* fix(website): clear journey enrichment when consent becomes unknown

* feat(website): instrument attribution events (#526)

* feat(website): instrument attribution events

* test(website): cover unattributed install events

* feat(website): persist campaign attribution context (#528)

* feat(website): persist campaign attribution context

* fix(website): import attribution through its public surface

* fix(website): invalidate download bridge on new acquisition

* fix(website): keep attribution context through unknown consent

* feat(website): add attribution claim protocol core (#529)

* feat(website): add attribution claim protocol core

* feat(website): deploy browser attribution claims (#530)

* feat(website): deploy browser attribution claims

* fix(website): require confirmation before binding attribution claims

* feat(analytics): add first-install lifecycle (#531)

* feat(analytics): add first-install lifecycle

* fix(analytics): claim first installs once across concurrent hosts

* feat(analytics): link browser acquisition to product usage (#532)

* feat(analytics): link browser acquisition to product usage

* fix(analytics): revoke queued campaign basics and allow claim confirmation

* test(analytics): verify website-to-product attribution contract (#534)

* refactor(attribution): drop landing page key from claim touches

* fix(website): keep attribution D1 out of preview deployments

* fix(website): derive analytics keys from public page paths

* test(website): validate analytics across every generated page

* fix(website): guard analytics and assets on all built pages

* refactor(website): drop extra build checks and simplify the 404 page

* feat(website): link claims silently and open the blog

* fix(web): describe website attribution in plain language

* fix(web): avoid promising deletion in the attribution note

* fix(web): describe the blog opening as conditional

* adjusts wording

* docs: align privacy specs with the simplified settings copy

* fix(website): bind claims only with current Marketing consent

* docs(web): drop removed privacy copy from the panels spec
2026-09-30 08:32:31 +00:00
Rustam Sadykovanddanyaberezun be8a5e4330 feat(dag): add validated contracts and durable storage (#541)
* feat(dag): add validated contracts and durable storage

* fix(dag): preserve implicit human input authority

* fix(dag): ignore foreign storage listing entries

* fix(dag): handle unsupported Windows directory sync

* fix(dag): keep owner authority out of gates

* fix(dag): validate persisted evidence graph

* fix(dag): preserve approval evidence scopes

* fix(dag): reauthorize persisted gate decisions

---------

Co-authored-by: danyaberezun <danya.berezun@gmail.com>
2026-09-28 22:45:41 +00:00
Rinat S a15a44e254 refactor(desktop): standardize Electrobun builds and isolate artifact tests (#443)
* chore(desktop): upgrade Electrobun to 2.0.1

* chore: align the Bun toolchain and types to 1.4.0

* refactor(desktop): replace handwritten types with the official SDK

* refactor(desktop): use framework builds and isolate artifact tests

* ci: expose the expanded macOS app for private signing

* docs(ci): align signing ownership with the private pipeline

* docs(testing): record artifact collector contract ownership

* docs(ci): preserve private action ownership after rebase
2026-09-08 07:19:20 +00:00
c3ca6ccd66 chore(ci): enforce spec surface contracts (#332)
* chore(ci): check spec surface drift

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* todo: Update the governing specs before code

ThinkRail-Todo: 01a06185-697a-70da-b8a9-b9ea0cfd595b/t_50ab12683096

* todo: Fix checker correctness and durable enrollment

ThinkRail-Todo: 01a06185-697a-70da-b8a9-b9ea0cfd595b/t_a24dd0d7eb1f

* todo: Reconcile barrels, surface specs, and test command

ThinkRail-Todo: 01a06185-697a-70da-b8a9-b9ea0cfd595b/t_b7122b713a24

* fix(tooling): harden spec surface validation

* fix(spec): drop retired numstat surface

* fix(tooling): normalize CommonJS export assignments

* fix(tooling): close spec surface traversal gaps

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: danyaberezun <danya.berezun@gmail.com>
Co-authored-by: Rinat S <rinat.suleimanov@jetbrains.com>
2026-09-03 10:10:12 +00:00
Rustam Sadykovandrsolmano 4879618c66 feat(web): subagent Agent cards, completion turns, and the child transcript dialog (#304)
* feat(web): subagent Agent cards, completion turns, and the child transcript dialog

Live Agent tool cards with REPLACE-semantics run details, the background
subagent-completion custom message rendered as its own chat turn, and the
child transcript dialog polling subagent.getTranscript while the registry
still knows the run. e2e: @agent live spec (foreground fan-out + background
completion) with a seeded echo-agent fixture; scripts: pure-pi subagents
smoke (bun run smoke:subagents). Squashed from subagent-research-planning
(layer 3/3).

* test(web): pin failed Agent results keeping run details through hydration

Review finding on #304 (fix lands in pi-subagents, layer 1): an error tool
result now carries the run's final details, so the failed card's transcript
action survives reload. Pinned at the hydration seam; subagent tools SPEC
records the failed-run guarantee.

* fix(web): review round 2 — aborted completion state, strict details narrowing

- SubagentCompletionCard: three-state icon — green check only for
  completed, red X for error, warning triangle for aborted; a turn-capped
  run no longer reads as success (#304 review finding).
- readRunDetails narrows through contracts' isDelegationRunDetails — the
  same strictness the completion-message guard gained in layer 2 (an open
  status string or empty usage no longer passes). Pinned.

* todo: Fix the icon contract and live transcript polling/identity issues

ThinkRail-Todo: 01a04907-28ba-7ea9-b3d9-deee11fbe0ab/t_2d400f0bf6eb

---------

Co-authored-by: rsolmano <rinat.suleimanov@jetbrains.com>
2026-08-29 00:01:09 +02:00
Rustam Sadykovandrsolmano 6c9698d8c3 feat(host): embed pi-delegation/pi-subagents in the engine host (#303)
* feat(host): embed pi-delegation/pi-subagents in the engine host

Contracts: DelegationRunDetails/DelegationRunStatus mirrored DTOs, the
subagent-completion custom message (tag, pairing, shared guard,
customMessageText), subagent.getTranscript keyed (workspace, parent, child)
with live registry status; protocol 51. Server: per-workspace
DelegationService cache, liveParentContext projection, delegation store under
the data dir, child-dispose cascade on removeSession awaited by workspace
archival, curated child extension set. CLI: bundles the extensions into the
binary (named pi-web-access factory for the child set). Squashed from
subagent-research-planning (layer 2/3).

* fix(host): bind the live runtime resolver into delegation services

Review finding on #303: the per-workspace DelegationService captured the
ModelRuntime active at first-chat time, so a Central connect/disconnect
(new runtime generation) never reached later children. The service now
binds getPiRuntime itself (pi-delegation's provider-function binding,
resolved per createChild); delegationServiceFor/subagentsExtensionFor go
synchronous. Pinned by a generation-flip test verified to fail on the old
binding.

* fix(host): review round 2 — strict details validation, parent-generation children, mirror pins

- contracts: isDelegationRunDetails (closed status union, numeric usage
  fields, durationMs) is the one shape check for untrusted wire details;
  isSubagentCompletionMessage narrows through it (#303 review finding —
  the old guard accepted status:"done" with usage:{}). Pinned.
- server: liveParentContext carries entry.generation.runtime, so a child
  runs on its parent's RETAINED runtime generation — a Central-only-model
  chat still delegates after a disconnect (#303 review follow-up). The
  flip pin now covers both directions: old parent stays on its generation,
  a new parent picks up the new one. Verified to fail without the fix.
- server: mirror pins — the completion tag equals pi-subagents'
  SUBAGENT_COMPLETION_MESSAGE and contracts' DelegationRunDetails stays
  mutually assignable with pi-delegation's original (drift now breaks a
  test, not a client).

* fix(host): review round 3 — teardown ordering for the delegation store + structured transcript-not-found

The delete transaction awaits its child cascade before publishDeleted, and
workspace archival drains a per-workspace registry of pending disposeSession
cascades before removing the delegation store — cascades, not delete
transactions, so archival stays unblocked by a delete wedged mid-trash. Both
pinned via a test-gated child turn (no sleeps; deterministic in both
directions). subagent.getTranscript's permanent miss is now
CodedError(SUBAGENT_TRANSCRIPT_NOT_FOUND) on the wire, and the parent server
SPEC declares the agent → persistence edge the delegation embedding added.

* fix(host): review round 3 — child transcripts read through pi's canonical entry projection

readChildTranscript's private message-entry loop missed that compaction is an
entry TYPE, not a message role: a compacted child's transcript lost its
compactionSummary marker. Entries now project through buildSessionContext —
the same path a live session.messages takes — then filter via the shared
isTranscriptMessageRole, mirroring getSessionMessages. Pinned by appending a
compaction entry to a finished child and asserting the summary survives the
read.

* docs: record ThinkRail delegation embedding

* docs: align delegation boundary surfaces

* fix(desktop): register subagent web access factory

* fix(host): await background subagents on shutdown

* docs(agent): align delegation dependencies

* fix(contracts): validate optional delegation fields

---------

Co-authored-by: rsolmano <rinat.suleimanov@jetbrains.com>
2026-08-28 23:45:18 +02:00
Rinat Sanddanyaberezun a8c42d5999 feat(desktop): package ThinkRail as an Electrobun app (#317)
* todo: Promote the approved desktop architecture

ThinkRail-Todo: 01a0247a-cd52-785c-917b-106f5a75dfc8/t_44fa5c64dcc4

* todo: Implement the Electrobun package and runtime

ThinkRail-Todo: 01a0247a-cd52-785c-917b-106f5a75dfc8/t_95ec4db0a29a

* todo: Add packaging and desktop coverage

ThinkRail-Todo: 01a0247a-cd52-785c-917b-106f5a75dfc8/t_7ab33dbfe2ca

* todo: Run all gates and review the final diff

ThinkRail-Todo: 01a0247a-cd52-785c-917b-106f5a75dfc8/t_1a397cf79389

* todo: Record and promote the approved menu design

ThinkRail-Todo: 01a0247a-cd52-785c-917b-106f5a75dfc8/t_d74f3263a760

* todo: Implement the native application menu

ThinkRail-Todo: 01a0247a-cd52-785c-917b-106f5a75dfc8/t_14f62292581a

* todo: Add regression coverage

ThinkRail-Todo: 01a0247a-cd52-785c-917b-106f5a75dfc8/t_bba36e4af871

* todo: Run gates and review the complete diff

ThinkRail-Todo: 01a0247a-cd52-785c-917b-106f5a75dfc8/t_1f0975890932

* todo: Record and validate the approved design

ThinkRail-Todo: 01a0247a-cd52-785c-917b-106f5a75dfc8/t_882644532c0b

* todo: Promote the decision across owning specs

ThinkRail-Todo: 01a0247a-cd52-785c-917b-106f5a75dfc8/t_90686630ca71

* todo: Add code-level boundary enforcement for launchers

ThinkRail-Todo: 01a0247a-cd52-785c-917b-106f5a75dfc8/t_fec4bc0ec29e

* todo: Run gates and review the complete change

ThinkRail-Todo: 01a0247a-cd52-785c-917b-106f5a75dfc8/t_0b7d16b32cba

* todo: Validate the latest main integration

ThinkRail-Todo: 01a0247a-cd52-785c-917b-106f5a75dfc8/t_04a51b278128

* test(e2e): reveal recalled turn after settlement

---------

Co-authored-by: danyaberezun <danya.berezun@gmail.com>
2026-08-28 11:05:17 +02:00
Rinat Sanddanyaberezun 508710b150 chore: bump pi to 0.84.3; exempt its CLI-only bundle from the seam scan (#307)
* chore: bump pi to 0.84.3; exempt its CLI-only bundle from the seam scan

* fix: reverify pi 0.84.3 compatibility assumptions

---------

Co-authored-by: danyaberezun <danya.berezun@gmail.com>
2026-08-27 13:45:04 +02:00
danyaberezun 1411b94ce4 feat(web): add sticky activity breadcrumbs (#318)
* todo: Promote and approve the chosen design

ThinkRail-Todo: 01a03f04-9a70-7c8d-a04e-dad7105ea6b8/t_f81e2ecc4e8f

* todo: Implement sticky breadcrumbs test-first

ThinkRail-Todo: 01a03f04-9a70-7c8d-a04e-dad7105ea6b8/t_2af3cd24f64f

* todo: Verify and capture the breadcrumb UI

ThinkRail-Todo: 01a03f04-9a70-7c8d-a04e-dad7105ea6b8/t_f6334bfef2d9

* fix(e2e): keep breadcrumb fixture model-neutral

* fix(web): prevent long-chat crashes and resync compaction (#315)

* todo: Draft and validate the recovery design

ThinkRail-Todo: 01a03e67-0f3e-71f5-8113-71eac869713f/t_ba5a364c8500

* todo: Add a failing regression test

ThinkRail-Todo: 01a03e67-0f3e-71f5-8113-71eac869713f/t_498c28840f48

* todo: Implement the root-cause fix and update specs

ThinkRail-Todo: 01a03e67-0f3e-71f5-8113-71eac869713f/t_f78c9562ae5d

* todo: Run full verification and review the diff

ThinkRail-Todo: 01a03e67-0f3e-71f5-8113-71eac869713f/t_e4e4e40281d2

* fix(web): harden transcript resync

* fix(web): prioritize reconnect transcript safety

* feat(web): add an adaptive chat composer (#308)

* todo: Review mockups together and capture the chosen design

ThinkRail-Todo: 01a03d5d-7d37-72f8-aaf2-9dcfca683610/t_fe1105319f17

* todo: Add failing tests for the approved behavior

ThinkRail-Todo: 01a03d5d-7d37-72f8-aaf2-9dcfca683610/t_6b613c5bdfe3

* todo: Implement the global composer growth setting

ThinkRail-Todo: 01a03d5d-7d37-72f8-aaf2-9dcfca683610/t_c6084ad8e5ad

* todo: Implement adaptive Composer layout and growth

ThinkRail-Todo: 01a03d5d-7d37-72f8-aaf2-9dcfca683610/t_65918e2ad100

* fix(web): finish adaptive composer phone behavior

* fix(deps): enforce one React runtime

* fix(web): defer streaming transcript sync
2026-08-27 02:22:51 +02:00
Rinat S 77ab071d04 chore: near-zero code comments — rationale lives in specs (#269)
Strip ~10.6k comments across apps/packages/e2e/scripts (parser-accurate,
string/JSX-safe). What survives: biome-ignore directives, five one-line
hazard notes pointing at their specs, and opaque-literal label tables
(unicode controls, git ref syntax, DEC modes, chunk-error strings,
line-number fixtures).

Rationale not yet specced was promoted first: xterm #6065 IME rescue ->
panels/SPEC.md; palette-reset ordering + alias self-reference ->
apps/web/scripts/SPEC.md. Everything else checked was already recorded
in the owning SPEC.md; the abandoned wsProtocol v4-v17 changelog is
deleted (git history retains it).

Codify the rule where agents read it: AGENTS.md ('Comments: avoid them.
Near-zero is the norm.' + a 'No comment creep' handoff audit),
writing-specs (specs are the only home for rationale), brainstorming
step 9 (self-review checks for rationale comments).
2026-08-20 17:43:43 +02:00
danyaberezunandRinat S ca17198fff feat(cli): add branded startup mark (#238)
Co-authored-by: Rinat S <rinat.suleimanov@jetbrains.com>
2026-08-19 15:39:14 +02:00
Rinat S 3020cdc977 fix(binary): restore OAuth sign-in in release binaries + gates to keep it fixed (#117)
* fix(binary): restore OAuth sign-in in the compiled binary + gates to keep it fixed

Release binaries failed every OAuth sign-in with
  ResolveMessage: Cannot find module './openai-codex.js' from '/$bunfs/root/thinkrail-...'
pi hides Node-only provider code behind bundler-opaque dynamic imports; bun build --compile
cannot follow them and a single-file binary has no node_modules to resolve them at runtime.
Dev + e2e run from source, so no suite could see it.

The fix (pi's own designed seam, mirroring pi's binary entry dist/bun/cli.js):
- setBundledExtensions -> registerBundledRuntime (async): besides injecting the bundled
  extensions it now registers pi's statically-bundled OAuth flows (registerBunOAuthFlows)
  and the Bedrock provider module (same latent break) via dynamic literal imports --
  bundled under --compile, never loaded in dev. compiled-entry awaits it before boot.
  Binary size 95M -> 96M (~1MB AWS SDK).

Keeping it fixed (artifact-verification layers):
- smoke:binary now drives a real Codex OAuth login over WS to its auth URL (offline,
  credential-free) -- red on the pre-fix binary with the exact reported error, green after.
- bun run e2e:binary (playwright.binary.config.ts): the no-agent e2e suite against the
  compiled binary (fake-login specs tagged @dev-seam and skipped -- the fakes live only in
  dev.ts). Wired into CI's Binary job on every PR.
- bun run check:seams (scripts/check-binary-seams.ts): fails when a pi bump introduces a
  NEW bundler-opaque dynamic import the seam doesn't register (exact-set allowlist, both
  directions). In CI lint job + pre-commit.
- live-refresh.spec fs-propagation asserts hardened to 10s (fsExpect): macOS FSEvents
  latency under full-suite load flaked the 5s windows, surfaced by the binary suite.

Docs: server/agent/cli SPECs (seam contract), .github/SPEC.md (CI), AGENTS.md (gates);
drive-by: 'four bundled extensions' lists corrected to five (pi-todos was missing).

* fix(check:seams): match opaque imports per occurrence, not per file

Review finding (jetbrains-air): the allowlist was file-granular, so a pi bump
adding a second binary-hostile import to an already-allowlisted file (e.g.
auth/context.js) passed the gate. Now every opaque import(...) is fingerprinted
as file + whitespace-normalized argument expression and exact-multiset-matched
against the allowlist in both directions -- an added occurrence in a known file
fails, and a reshaped known occurrence fails as new + stale simultaneously
(forcing re-verification).

Verified: the reviewer's exact scenario (sneaky import appended to context.js)
now exits 1 naming the occurrence; a reshaped wrapper reports both directions;
real tree green. Documented limitation stays in the header: new call sites of
an existing wrapper add no import( occurrence -- that class remains covered by
the behavioral artifact gates (smoke OAuth probe + e2e:binary).

* fix(check:seams): parse a real AST instead of line-scanning (review)

Second review finding (jetbrains-air): the line-based scanner missed opaque
dynamic imports formatted across lines (import(\n specifier \n)). Replaced the
regex/line heuristics with the TypeScript parser (already a root devDep): walk
each dist file's AST for call expressions whose callee is the import keyword
and whose specifier is not a constant string (no-substitution templates count
as constant -- the bundler resolves them statically; templates with
substitutions and all other expressions are opaque). Comments and strings can
no longer hide or fake a match, and a cheap /\bimport\s*\(/ pre-filter keeps
the gate at ~0.3s. Dep discovery now walks the @earendil-works closure
transitively (BFS) instead of one level.

Verified: multiline sneaky import in an allowlisted file -> exit 1 naming the
normalized occurrence; the same import inside a block comment -> exit 0;
reshape -> new + stale both reported; real tree green.
2026-07-24 16:09:33 +02:00
Rinat Sandrsolmano de4031dd42 feat: in-app provider authentication (OAuth, API key, JetBrains AI) in Settings (#61)
* feat(web): auth-provider status strip on the Welcome screen

Users had no way to see which model providers are usable — with nothing
authenticated the model picker is just a disabled pill. The Welcome screen
now shows per-provider auth status (pi auth + jbcentral wiring):

- contracts: provider.status → ProviderStatusReport (configured + kind:
  oauth / api-key / env / jbcentral / other; never credential values)
- server/agent: getProviderStatus() revalidates on every read
  (authStorage.reload + modelRegistry.refresh), so pi /login or
  thinkrail jbcentral run in a terminal shows up without a host restart;
  jbcentral detected from effective model baseUrls
- shared/jbcentral: isJbcentralProxyUrl pins the proxy-URL shape; a cli
  drift test keeps buildProxyUrls and the detector in lockstep
- web: ProviderStatusStrip under the Welcome cards — configured rows with
  source labels, compact "N more available" line, and a zero-state with
  copyable setup commands (thinkrail jbcentral; pi + /login — there is
  no 'pi auth login')

* feat(contracts): in-app provider auth wire

Typed, versioned surface for in-app provider authentication:
- ProviderStatus gains canOAuth/canApiKey/canLogout; ProviderStatusReport gains
  jbcentralInstalled (alongside jbcentralWired).
- LoginFrame/LoginPush/LoginReply + a session-less `provider.login` push channel.
- provider.* methods: loginStart/loginReply/loginCancel/setApiKey/logout plus the
  JetBrains AI trio jbcentralConnect/Disconnect/Login (+ JbcentralConnectResult).
- Bump PROTOCOL_VERSION 1 -> 3 (new channel + methods).

Types-only; no runtime pi import.

* feat(server): in-app provider auth engine + JetBrains AI wiring

Host side of in-app provider auth, in a new `auth/` submodule:
- providerStatus (moved from `agent/`) now reports canOAuth/canApiKey/canLogout +
  jbcentralInstalled; OAuth ids are first-class rows (openai-codex/github-copilot).
- providerLogin: a session-less, loginId-keyed OAuth state machine over pi's
  AuthStorage.login — detached start, frames pushed on `provider.login`, parked
  select/prompt/manual-code answered by loginReply, cancel rejects the parked
  promise, registry-refresh on success; plus setApiKey/logout.
- jbcentral: connect/disconnect/login composing the shared protocol + a live
  registry refresh.

Consolidate the jbcentral protocol into `@thinkrail/shared/jbcentral` (read+write),
so `thinkrail jbcentral` and the in-app flow share one implementation. Resolve the
CLI by absolute path (it rebranded jbcentral -> `central`, and installs to
~/.local/bin off PATH); back up models.json only once.

* feat(web): provider auth in a two-pane Settings dialog + Welcome warning

Move all provider management off the Welcome screen into Settings:
- SettingsDialog becomes a store-driven two-pane shell (section rail + content);
  ProvidersSettings hosts connected rows (Sign-out when canLogout), OAuth Sign-in,
  inline API-key entry, and the JetBrainsAiCard (Connect/needs-login/needs-install
  state machine); GithubSettings holds the existing Local GitHub block.
- Welcome shows only a slim ProviderWarningBanner when no provider is connected,
  opening Settings -> Providers; the always-on strip is removed.
- Session-less login: LoginDialog (presentational) driven by store.activeLogin +
  the foldLoginFrame reducer; `provider.login` routed via wireTransport.
- Store holds settingsOpen/settingsSection + openSettings so the gear and the
  banner both deep-link without prop-drilling. Add a --gold-tint token.

* test(e2e): drive provider auth through Settings

Rewrite the Welcome/Settings provider specs for the new surface:
- Welcome shows the provider warning only when none is connected + opens Settings.
- Settings -> Providers lists in-app auth options; API-key add/remove round-trips
  through the host; Sign in opens the login dialog; the JetBrains AI card renders
  (asserting the install-guidance branch when the CLI is absent).
- settings.spec clicks into the GitHub section (Providers is now the default).

* test(e2e): drive the JetBrains AI connect flow via a stub central CLI

Add a deterministic stub `central` (e2e/fixtures/bin/central) on the host's PATH
and pin WIRE_PROXY_PORT, so the in-app JetBrains AI flow is drivable end-to-end
with no real CLI / network / JetBrains auth. New spec walks Connect → the host
resolves `central`, runs `proxy start --return-key`, writes the models.json proxy
override, refreshes the registry → card shows Connected → Disconnect reverts it.

This is the regression guard for the class of bug that shipped once: a CLI rename
(jbcentral → central) or flag change now fails the suite at detection/connect
instead of silently leaving "not installed".

* test(e2e): drive the OAuth login flow via a fake pi provider

Register a deterministic fake OAuth provider (`e2e-oauth`) in the dev/e2e entry
(dev.ts, behind THINKRAIL_E2E_FAKE_OAUTH — never ships), whose login() scripts the
callbacks: select → open-URL + manual-code paste → progress → credentials. New spec
walks the whole session-less bridge — loginStart (detached) → frames on
`provider.login` → the accumulating dialog → a loginReply per select/prompt →
success → status re-read shows the provider configured; plus the cancel path.

ModelRegistry.refresh() resets the OAuth registry (and the host refreshes on every
status read), so the fake is re-registered after each refresh via a prototype wrap
in dev.ts — confined to the e2e entry, leaving production code untouched.

* fix(auth): allow submitting a blank OAuth prompt reply when pi permits it

GitHub Copilot's first login prompt is the GitHub Enterprise domain, which pi
marks 'blank for github.com' (OAuthPrompt.allowEmpty). The login dialog only
submitted a non-empty trimmed value, so the majority github.com path dead-ended:
Submit/Enter on the empty field was a silent no-op and the flow could never
advance to the device code.

Propagate pi's allowEmpty signal end-to-end (LoginFrame prompt -> server
onPrompt -> foldLoginFrame -> LoginDialog) and honor it: a non-empty answer
always submits; an empty one submits only when allowEmpty is set. The bare
manual-code paste path stays guarded (no allowEmpty) so an empty code is still
a no-op.

Adds server + store unit tests for the blank-reply round-trip.

* refactor(web): derive JetBrainsAiCard state from props, not a shadow enum

The card held a local `phase` enum plus `installHint`/`errorMsg` that duplicated
facts already carried by its server-derived `wired`/`installed` props, then kept
them in sync with a reconciliation effect — a dual source of truth where local
state could silently disagree with the host (the class of bug behind the earlier
'installed but Recheck does nothing').

Read `wired`/`installed` straight from props and keep only the one thing props
can't express: the last connect attempt's outcome (`needs-login` / `needs-install`
+ hint / `error`). Behavior is unchanged — every render branch, testid, and copy
string is preserved, incl. the dynamic install hint and the 'clear transient state
when an external wire is seen on Refresh' reconciliation (now a 3-line effect).
Drops 2 of 6 useState and the enum-vs-props divergence.

* test(e2e): cover JetBrains AI not-signed-in and error connect outcomes

The stub `central` always succeeded, so the card's non-happy branches (not signed
in → Sign in; hard error → retry) — the states `wired`/`installed` can't express —
had no automated coverage. Teach the stub to pick its outcome from a control file
(`E2E_CENTRAL_STATE`, read live per call, same pattern as the pick-dir pointer;
safe under the serial `workers: 1` suite), and add a spec that drives needs-login →
error → recovered-to-connected, asserting the card surfaces each affordance and
that a successful wire supersedes the transient error state.

* feat(auth): host-driven per-OS JetBrains Central install command

Show the correct `central` install command for the host's OS (not the
browser's), sourced once and carried over the wire so the JetBrains AI
card never hard-codes or guesses it.

- shared/jbcentral: new `jbcentralInstall(platform)` as the single source
  of truth ({platform, shell, command}); macOS/Linux -> install.sh curl
  pipe, Windows -> install.ps1 PowerShell. Fix the stale S3 path
  (jbcentral/stable -> central/stable). `jbcentralInstallHint` composes
  the same command so the CLI text and card can't drift.
- contracts: new `JbcentralInstall` wire type; `ProviderStatusReport`
  carries `jbcentralInstall`.
- server/auth: populate it from `process.platform` in the status read.
- web/JetBrainsAiCard: drop the hardcoded unix INSTALL_CMD and the
  fragile hint.includes("Windows") check; render the host-provided
  command proactively (fixes Windows host showing the unix command, and
  Windows having no runnable command at all).
- align shared's vestigial composite tsconfig to the repo's source
  resolution pattern (it only worked while shared didn't import contracts).
- specs updated (shared/contracts/server-auth/web-panels) + unit tests.

* fix(agent): keep the jbcentral proxy secret off the wire (WireModel)

When JetBrains AI is wired, a model's effective baseUrl is
http://127.0.0.1:<port>/wire/<SECRET>/… . Raw pi `Model` objects were
shipped over model.list / model.default / the session.create result /
SessionSummary (session.list + getMessages), so the persistent JetBrains
token landed in the browser store / WS frames / devtools — worst under
V2 remote access. Inbound was worse: session.create / session.setModel
passed a client-supplied Model straight to pi, which uses baseUrl
verbatim, so a (remote) client could point the agent's model traffic at
an arbitrary URL.

Fix (both directions):
- contracts: new `WireModel = Omit<Model, "baseUrl" | "headers">` — the
  shape models take on the wire. The Omit is a structural guarantee the
  secret-bearing fields can't be serialized. Used for model.list/default,
  session.create params+result, session.setModel params, SessionSummary.
  Bump PROTOCOL_VERSION 3 → 4.
- server/agent: `toWireModel` strips baseUrl/headers at every outbound
  boundary; `resolveWireModel` re-resolves an inbound {provider,id} ref
  against getAvailable() before handing it to pi — never trusts a client
  baseUrl, and rejects unknown/unavailable refs.
- web: model types Model<string> → WireModel (picker never read baseUrl).
- tests: wire models carry no baseUrl/headers; create re-resolves a
  baseUrl-less ref; an unknown ref is rejected.
- specs: agent + contracts SPECs document the redact/re-resolve invariant.

* refactor(contracts): make WireModel an allowlist (Pick), not a denylist

Follow-up to the jbcentral secret-leak fix. `WireModel` was
`Omit<Model, "baseUrl" | "headers">` — a denylist that fails OPEN: a
future pi `Model` field (e.g. a new credential) would leak by default,
and `toWireModel`'s `{...rest}` shipped ~6 fields the UI never reads.

Switch to an allowlist of exactly what the UI renders:
`Pick<Model, "id" | "name" | "provider" | "contextWindow" | "reasoning">`.
It fails CLOSED (new Model fields excluded by default), trims the wire
payload to those 5 fields, and stays compile-coupled to pi (a field
rename breaks the build). `toWireModel` is now an explicit projection.
A unit test pins the exact key set so the DTO can't silently widen.

Specs (contracts + agent) updated to describe the allowlist rationale.

* refactor(cli): remove the `thinkrail jbcentral` command (superseded by Settings)

The in-app "Connect JetBrains AI" card (Settings → Providers) now covers
wiring/unwiring, so the standalone CLI subcommand is redundant. Drop it
and its thin dev wrapper:

- delete apps/cli/src/jbcentral.ts + its arg test, and
  scripts/setup-jbcentral-cli.ts + the `setup-jbcentral-cli` npm script
- remove the `jbcentral` subcommand dispatch + USAGE line from the CLI

The jbcentral *protocol* stays untouched in @thinkrail/shared/jbcentral
(wire/unwire, install command, secret probe) — the server's card is now
its sole caller. Specs (cli/shared/server-auth) and stale
`thinkrail jbcentral` comments updated to match.

* refactor(jbcentral): drop the dead install-hint path

`jbcentralInstallHint` (and the `hint` it fed through `WireOutcome`
needs-install → `JbcentralConnectResult.hint`) was only rendered by the
removed `thinkrail jbcentral` CLI. The in-app card now shows the per-OS
command from `ProviderStatusReport.jbcentralInstall` and ignores the
hint, so the whole string path was dead.

- shared: remove `jbcentralInstallHint`; `WireOutcome`'s needs-install
  variant no longer carries `hint`.
- contracts: drop `JbcentralConnectResult.hint`.
- server: `connectJbcentral` returns a bare `needs-install`.
- tests/specs updated. `jbcentralInstall` (the structured, wire-carried
  command) is unaffected — still the single source of truth.

* feat(auth): clickable + auto-opened device verification link in login dialog

Improves the device-code sign-in UX (e.g. GitHub Copilot: "Enter this
code at https://github.com/login/device").

- The verification URL is now a real link (opens in a new tab, with an
  external-link affordance) instead of plain text.
- The device page auto-opens in a new tab when the code arrives. It's
  best-effort — it fires right after the user's Submit gesture so it's
  usually inside the browser's transient-activation window; if a popup
  blocker stops it, the clickable link is the guaranteed fallback.

Scoped to the device-code branch; the authUrl/paste flow is unchanged
(and still e2e-covered). auth SPEC updated.

* feat(web): toasts for wire failures with no chat to land in (#71)

* feat(web): toasts for wire failures with no chat to land in

Introduce a small toast system and wire it to the error sites the auth
branch left with `// A toast comes with the error-handling pass.` TODOs —
plus the swallowed/unhandled ones nearby that share the same gap.

- store: `toasts` queue + `pushToast`/`dismissToast` and a fire-from-
  anywhere `toast.error/success/info` helper. It's the home for a rejected
  wire call with no better place to land (no chat tab to host an error
  turn), complementing `appendErrorTurn`.
- components/ui/toast: Radix Toast primitives, themed with our tokens (a
  left accent bar carries severity). panels/Toaster composes them against
  the store and the shell mounts it once; Radix owns the auto-timeout +
  swipe/hover-pause, every close routes back through `dismissToast`.
  Errors persist until dismissed; success/info time out.
- NewWorkspaceDialog: failed `workspace.create` / `session.create` now
  toast (the two spots that named a toast; the latter dropped its chat
  kick-off silently before).
- ProvidersSettings: OAuth-start and login-reply failures now toast, and
  `setApiKey` / `logout` gain the `catch` they lacked (previously an
  unhandled rejection — the card just went quiet).

Verified: store slice unit-tested; full no-agent e2e suite green (incl.
the API-key round-trip that exercises the new catches); lint + typecheck
pass; toast render + variant timeout confirmed visually.

* build: pin all dependencies to exact versions + enforce it

Ranges let a silent minor/patch bump slip in between installs — and `pi`
ships breaking releases daily, so a floating range is a live wire. Pin
every dependency to an exact version so the lockfile is the single source
of a dep's version and every upgrade is an explicit, reviewable diff.

- Pin all ranged deps across root + web + server + spec-graph to their
  installed versions (39 deps; `mermaid ^11.13.0` was actually resolving
  to 11.16.0 — pinned to that). `peerDependencies: "*"` on the extension
  packages stay (the host provides pi/typebox); the root catalog already
  pinned the cross-cutting deps.
- Extend `scripts/check-catalog.ts` (bun run check:deps, in pre-commit +
  CI) to reject ANY range in dependencies/devDependencies/optionalDeps,
  not just catalog drift. peerDeps + local protocols (workspace:/link:/
  file:) exempt.
- Document the policy: architecture.md Decision #10 (full rationale) +
  a one-line rule in CLAUDE.md's Stack pointing at it; note check:deps in
  the fast-gates line.

Verified: check:deps OK (and a negative test confirmed a caret is
rejected); lint + typecheck pass; `bun install` reports no resolution
change (pins match the lockfile).

* unifies agentic instruction

* fix(web): address toast review — coalesce+cap the queue, narrow catches, wire missed chat sites

- pushToast coalesces an identical live toast (a retried failure returns the
  existing id instead of stacking a twin) and caps the queue at 5 — the
  viewport doesn't scroll, so past a screenful the oldest drop
- ProvidersSettings: setApiKey/logout catches narrow to the mutation, so a
  status re-read failure can't be mislabeled as a failed save/sign-out;
  load() documents its never-rejects contract (failures render the banner)
- CenterTabs: a rejected session.create ("+ New chat") or history-reopen
  getMessages now toasts instead of silently doing nothing

---------

Co-authored-by: rsolmano <rinat.solmano@forgood.ai>

---------

Co-authored-by: rsolmano <rinat.solmano@forgood.ai>
2026-07-14 13:50:42 +02:00
danyaberezun 6cd3043762 feat(cli): thinkrail central subcommand — wire pi through JetBrains Central CLI (#46)
* feat(cli): thinkrail central subcommand — wire pi through JetBrains Central CLI

Port scripts/setup-central-cli.ts into apps/cli/src/central.ts so the
jbcentral proxy wiring ships inside the compiled binary — one command
(thinkrail central [--remove]) on mac/linux/windows, no preinstalled bun.

- runCentral(argv, env) + pure, unit-tested helpers (parseCentralArgs,
  resolveProxyPort, buildProxyUrls, apply/removeCentralOverrides,
  centralInstallHint with per-OS guidance)
- index.ts dispatches the central subcommand (next to update); USAGE updated
- scripts/setup-central-cli.ts is now a thin wrapper over runCentral
- SPEC.md documents the subcommand + boundary
- central.test.ts (13 tests)

* docs(cli): trim the JetBrains Central wiring spec section per review

* refactor(cli): rename central subcommand to jbcentral

Reviewer feedback: 'central' is ambiguous. Rename the subcommand + module to
the more specific 'jbcentral' (thinkrail jbcentral [--remove]).

- src/central.ts -> src/jbcentral.ts (+ .test.ts), identifiers renamed
  (runJbcentral, parseJbcentralArgs, apply/removeJbcentralOverrides,
  jbcentralInstallHint, JBCENTRAL_USAGE); resolveProxyPort/buildProxyUrls kept
- index.ts dispatches 'jbcentral'; args.ts USAGE + SPEC.md updated
- scripts/setup-central-cli.ts -> scripts/setup-jbcentral-cli.ts + package.json script
2026-07-08 16:01:37 +03:00
Rinat S 3aab075149 Rebrand thinkrail-pi → thinkrail (#71)
* Rebrand thinkrail-pi → thinkrail

Rename all thinkrail-pi references to thinkrail across the monorepo:
- npm scope @thinkrail-pi/* → @thinkrail/* (all import sites + package.json + bun.lock)
- env vars THINKRAIL_PI_* → THINKRAIL_*
- CLI bin `thinkrail`, APP_SLUG, default state dir ~/.thinkrail, .idea module
- ThinkRail-PI display name → ThinkRail in docs/specs

Portable pi extensions (pi-spec-graph, pi-visualize, pi-thinkrail-workflow)
and the .git worktree pointer are intentionally left untouched.

Split out from #67; the open-source docs/README/badge ship separately in #69.

* e2e: assert terminal text against .xterm-rows (fix xterm measure-element flake)

The terminal specs asserted `toContainText` on the whole terminal-instance
container. xterm.js 6.0.0 appends hidden `.xterm-char-measure-element` width-probe
spans (each `char.repeat(32)`, e.g. 32×"E" / 32×"1") inside the terminal element, so
`toContainText` on the container also reads those. Before the shell output paints,
the container's text is a run of measure glyphs ("EEEE…1111…") rather than the typed
command — a render-timing race that fails on loaded CI runners (passes locally).

Scope the text assertions to `.xterm-rows` (the painted screen only) via a new
`visibleTerminalScreen` helper, so assertions wait for the real output and never see
the measure spans. Test-only; no product change.
2026-07-07 13:21:29 +02:00
Rinat S 2aa236bb44 deps: single-source shared dep versions via bun workspace catalog (#39)
* deps: single-source shared dep versions via bun workspace catalog

Root package.json now carries a workspaces catalog for the deps that must
stay lockstep across packages (the three @earendil-works/pi-* packages,
typebox, typescript, @types/bun); workspace manifests reference them via
the catalog: protocol, so a version bump is a one-line root change.
peerDependencies stay "*" — the portable-extension contract (host
provides pi) is intentionally version-less.

This also folds in the PR #34 review fix: pi-spec-graph's devDeps move
from the stale exact 0.80.2 to the catalog's 0.80.3, removing the nested
duplicate pi tree and the runtime version skew for its StringEnum import.

scripts/check-catalog.ts gates the scheme (a catalog-managed name pinned
with a literal, or a dangling catalog: ref, fails) and runs first in the
husky pre-commit.

* ci: run the dependency-catalog gate in the lint job

check:deps runs before lint/typecheck, same order as the husky pre-commit
— the hook is bypassable with --no-verify, so CI is the backstop.

* deps: pin all catalog entries exact; gate enforces it

@types/bun and typescript move from caret ranges to their resolved
versions (1.3.14, 6.0.3), matching the pi/typebox entries. check:deps
now rejects a catalog entry that carries a range.
2026-07-02 13:16:58 +00:00
Rinat S b7e11ac5cd dev: open the OS default browser, not vite's Chrome heuristic (#28)
vite's `server.open` on macOS opens a running Chrome via AppleScript
regardless of the user's default browser (react-dev-utils heuristic), and no
BROWSER value cleanly bypasses it. Open the browser from scripts/dev.ts
instead, using `open`/`xdg-open`/`start` (the OS default) once vite is serving.

To open the exact URL, pre-pick the vite port too (THINKRAIL_PI_WEB_PORT,
symmetric with the host's THINKRAIL_PI_PORT) and pin it in vite with
`strictPort`; a bare `dev:web` leaves it unset → 24269, free to auto-increment.
Replaces the THINKRAIL_PI_DEV_OPEN flag.
2026-07-01 14:38:52 +02:00
Rinat S 0fbc9faebb host: one boot path (bootHost) + fix doubled dev host, open browser on dev (#25)
* host: one boot path (bootHost) + fix doubled dev host, open browser on dev

Split host launch by *who controls the port and owns the UI URL*, not by
dev-vs-prod, and share one boot wrapper:

- packages/server: add `bootHost(options)` (host/boot.ts) — resolve login-shell
  PATH, pick the port per `portMode` ("exact" honors it, "free" scans upward),
  start createServer, and install SIGINT/SIGTERM graceful-shutdown handlers.
  dev.ts and apps/cli both route through it; dev.ts thereby gains the graceful
  shutdown it previously lacked.
- scripts/dev.ts: filter `turbo run dev` to web + server only. apps/cli was
  booting a redundant second host (24242 taken by server:dev → cli bumped to
  24243) that nothing connected to. Now one host, no stray port.
- apps/web: vite `server.open: true` — `bun run dev` opens the browser at the
  HMR URL (which proxies /ws to the host). The prod bin still opens the host URL.
- e2e (self-contained) is unchanged: still boots server/dev.ts on the pinned
  port with staticDir=dist, tears down after.

SPECs updated first (server + host): bootHost public surface, shared dep.

Verify: typecheck + lint + unit (new host/boot.test.ts: port modes, SPA
serving, stop() releases port) + e2e no-agent (new host.spec.ts: /health, SPA
root, SPA fallback) + turbo dry-run (cli excluded) + CLI-bin smoke (free-pick,
--no-open, serves dist, clean shutdown releases port).

* dev: scope browser-open to the full `bun run dev` launcher

Gate vite's `server.open` on THINKRAIL_PI_DEV_OPEN, which scripts/dev.ts sets
(alongside THINKRAIL_PI_PORT, via the same turbo THINKRAIL_PI_* passthrough).
A bare `bun run dev:web` doesn't go through the launcher, so it no longer opens
the browser. Vite still opens its own actual URL, so it stays correct when the
vite port drifts for a second concurrent dev session.
2026-07-01 12:17:12 +00:00
Rustam Sadykov 7e20f3cd02 scripts: add setup-central-cli to route pi's models via jbcentral (#22)
Adds a manually-run bun script that points pi's built-in `anthropic` and
`openai` providers at the local JetBrains Central CLI proxy (`jbcentral`),
so the in-process pi agent uses JetBrains AI — the same path Claude Code
and Codex use.

- Discovers the proxy secret + port from `jbcentral proxy start` and
  ~/.wire/config.json (WIRE_PROXY_PORT overrides).
- Overrides provider baseUrl only, so built-in model metadata (cost,
  context window, thinking levels) is inherited; no model list to maintain.
- Idempotent; backs up models.json; `--remove` restores defaults.
- Honors PI_CODING_AGENT_DIR.

Run with `bun setup-central-cli` (alias in package.json). WIRE_PROXY_PORT
declared in turbo.json globalPassThroughEnv alongside PI_CODING_AGENT_DIR.
2026-07-01 12:09:32 +02:00
Rinat S c364703557 host: auto-pick a free port for dev + thinkrail-pi (#19)
Bun.serve does not report EADDRINUSE for a busy localhost port (it shares
it via SO_REUSEPORT), so a second host silently co-bound 24242 and the OS
load-balanced requests across the stale and new backends. The apps/cli
EADDRINUSE->port:0 fallback never fired, and vite's hardcoded proxy target
pointed a second dev UI at the wrong host.

- packages/shared/freePort: findFreePort()/isPortFree() probe occupancy via
  a TCP connect (refused = free) and scan upward from the preferred port,
  falling back to an OS-assigned port. Unit-tested.
- thinkrail-pi (apps/cli): resolve a free port before binding.
- bun run dev: scripts/dev.ts launcher picks a free host port, sets
  THINKRAIL_PI_PORT, then runs turbo; vite's proxy target reads the same var.
- packages/server dev entry: auto-pick when THINKRAIL_PI_PORT is unset;
  an explicit value (e2e's 24252, the launcher's pre-picked port) stays strict.

A second `bun run dev` now lands on its own port with its UI wired to its
own host, instead of colliding with one already running.
2026-06-30 16:24:39 +02:00