mirror of
https://github.com/JetBrains/thinkrail.git
synced 2026-11-22 08:25:35 +08:00
settings-tree
25
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d2e707f357 |
feat(extensions): ship web access as a ThinkRail extension whose switch also covers its skills (#965)
* feat(extensions): ship web access as a ThinkRail extension whose switch also drops its skills * fix(extensions): keep a disabled extension's skills out of pi's inputs and reload again after a mid-reload toggle * fix(agent): keep web_search headless for a user's own pi-web-access while the web-access extension is off * fix(agent): reload again only when the extension policy moved during a reload |
||
|
|
5be3a379a7 |
fix: show ThinkRail's icon and name on Windows executables instead of Bun's (#881)
* feat(shared): derive Windows file properties from the release identity * fix(desktop): order the Windows icon's frames largest first * fix(cli): stamp ThinkRail's icon and file properties on the Windows binary * test(artifact-tests): check the Windows CLI binary's icon and file properties * fix(desktop): brand bun.exe, launcher.exe and the uninstaller as ThinkRail * fix(desktop): set the Windows window icon that Electrobun leaves unset * docs(specs): record how Windows executables get ThinkRail's identity * fix(desktop): add the DPI-scale frames to the Windows icon and pin signed-PE branding * fix(desktop): group a pinned ThinkRail and its window on the Windows taskbar (#883) * fix(desktop): give the Windows process an explicit AppUserModelID * fix(desktop): stamp ThinkRail shortcuts and pins with the process AppUserModelID * docs(specs): record the Windows taskbar identity * refactor(desktop): read Electrobun's shortcut manifest without a type cast * fix(desktop): match a shortcut's target by its canonical Windows path * fix(desktop): harden the taskbar-identity stamp after review * refactor: move the native icon set to packages/shared * fix(desktop): cache COM thunks, open shortcuts read-only until a stamp is needed, defer the taskbar stamp past readiness, and harden the Windows identity checks --------- Co-authored-by: OLavrik <Olya_lavrik@inbox.ru> |
||
|
|
9d88588eb5 |
feat: unconditional PII-free PostHog error tracking with readable stacks (#769)
* feat(analytics): report sanitized exceptions through the basic PostHog sink * feat(host): report crashes, failed requests and logged errors to error tracking * feat: forward UI errors to host error tracking over client.reportError * feat(desktop): forward handled main-process errors to host error tracking * docs: document unconditional sanitized error reports in specs, README and AGENTS.md * test(artifacts): tolerate allow-listed error reports in the desktop analytics probe * feat(analytics): keep raw frames and chunk ids for PostHog symbolication * feat(web): send PostHog chunk ids with client error reports * feat(cli): embed the binary's source map for readable error stacks * feat(release): upload web and desktop-runtime source maps to PostHog * test(release): pin source-map credential scoping in the build action * docs: document source-map upload and readable error stacks * fix(analytics): carry the report's handled flag into the root exception mechanism * docs: pin client error reports to protocol v90 after rebasing onto main * feat(analytics): send a classifier instead of error message text * fix(host): wait at most 1 s for the crash report and tag the crash kind * fix(desktop): derive runtime chunk ids from the code, its map and the release * build(release): run posthog-cli only after a pinned SHA-256 check of its binary * fix: report stable boundary ids, route main's new desktop errors and scope release credentials * fix(analytics): cut the message out of every stack before the SDK parses frames --------- Co-authored-by: danyaberezun <danya.berezun@gmail.com> |
||
|
|
a9c560a370 |
perf(cli): compile the binary with JSC bytecode (#781)
* build: pin Bun 1.4.3 for development, CI, the CLI and the desktop runtime Bun 1.4.1+ fixes cross-target --bytecode builds (oven-sh/bun#18416) and intermittent aborts on large bytecode builds (oven-sh/bun#40507), and stores bytecode in less than half the space, which the CLI bytecode build needs. The desktop app selects the same Bun through Electrobun's build.bun.version, which Hutch honours but ElectrobunConfig does not type; a desktop test keeps it equal to the root pin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * perf(cli): compile the binary with JSC bytecode Bun now ships the host graph as bytecode, so a launch skips parsing the ~25MB bundle. On linux-x64 /health is ready in ~210ms instead of ~890ms on the same Bun 1.4.3; the binary grows by ~41MB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
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 |
||
|
|
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 |
||
|
|
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> |
||
|
|
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> |
||
|
|
389b230829 |
fix(ci): make the Windows binary smoke real, not POSIX-shaped (#274)
* fix(ci): make the Windows binary smoke real, not POSIX-shaped The release matrix has been red since #255: every nightly and the stable dispatch failed on `windows-latest` in `smoke:binary`, and since `release` needs `build.result == 'success'`, three releases published nothing while discarding the green linux/darwin artifacts. Since #255 the host feeds a global PI extension only through `additionalExtensionPaths`, whose sole producer requires Central to be *installed and supported* — so the smoke's synthetic extension only loads if a `central` executable resolves and spawns. The fake was a `#!/bin/sh` file with no extension: Bun's resolver deliberately refuses extensionless files on Windows, and CreateProcess cannot run a shell script, so inspection reported `absent` and the extension was never loaded. The fake is now compiled (`bun build --compile` → `central`/`central.exe`), a real executable on every platform. A `.cmd` shim was rejected: Bun.spawn needs a cmd.exe wrapper for batch files and it splits the fixture per shell dialect. Two more Windows defects sat behind it, unreached until now: - The pi-free PATH was the hardcoded skeleton `/usr/bin:/bin:…`, which on Windows leaves the host with no `git.exe` and no System32 (`project.open` spawns bare `git`). It is now derived from the live PATH by dropping the entries that hold a `pi`; the no-pi invariant is still asserted, and so is git's survival. - `homedir()` — pi's own home resolution — reads USERPROFILE on Windows and ignores HOME, so the default-agent-dir probe wrote into the runner's real `%USERPROFILE%\.pi\agent`. Spawned hosts now carry both keys, here and in the e2e/binary/workflow harnesses. Same defect on the product path: `jbcentralExtensionPath` resolved `env.HOME ?? homedir()`, so on Windows — where Git Bash sets HOME to an MSYS path pi never reads — a properly installed and configured Central reports `absent`. It now reads USERPROFILE on win32 and HOME elsewhere, per platform, from the live env (plain `homedir()` cannot be redirected in-process under Bun, which resolves it once at startup). The platform is injectable, so both branches are pinned by unit tests on any host OS. Finally, PR CI gains a `windows-latest` binary build+smoke leg. This class of break was structurally invisible until release time, where a red matrix publishes nothing and notifies nobody; Windows is where the host's assumptions diverge most and its runner is the cheap half of that risk. macOS binary coverage stays release-matrix-only. * fix(cli): resolve the binary artifact name in one place `build:binary` writes `thinkrail.exe` on Windows (Bun appends the extension for a Windows target) while `smoke:binary` defaulted to `dist/thinkrail`, so the new PR-CI Windows leg failed before it ever booted the artifact — and so would any Windows developer running the two scripts back to back. The release action never hit it because it passes the resolved path explicitly. The name rule (base name from the target, plus the Windows `.exe`) now lives in `scripts/artifactName.ts`, used by the build for its output path and by the smoke for its default input; the build's final log line becomes truthful on Windows too. The release action keeps its own bash derivation: there the name is also the published-asset contract both installers depend on. * fix(cli): boot the smoke's two hosts one at a time, and name the cause when the extension is missing With the Windows fixtures fixed, the default-agent-dir assertion passed and the custom-agent-dir one failed — the two hosts were booting concurrently and both load the same on-disk extension, whose transpile cache one of them then loses. On POSIX the concurrent write is harmless; on Windows the loser's initial load fails and `prepareInitialRuntime` falls back to a runtime without the extension, so the provider simply is not there. A failed *rebuild* keeps the loaded generation, which is why only the boot load can lose it this way. The custom-agent host is now spawned after the probe has asserted and exited. The failure was also mute: "did not load the global external extension" covers a fixture that never ran, a Central that was not detected, and a load that failed. Both assertions now report `provider.status`'s `jbcentral` state, and the model predicate they share lives in one place. * test(cli): report the Central fixture's own state when the smoke's extension assertion fails * fix(cli): override env vars in the smoke by case-insensitive name, and pin the Central-fed route The Windows leg proved the fixture healthy and the host blind: the exe existed, resolved on the smoke's PATH and answered `--version` with exit 0, yet the host reported Central `absent`. Windows env names are case-insensitive and the runner's PATH is spelled `Path`, so `{...process.env, PATH: noPiPath}` handed the child *both* keys and it read the inherited one — the host ran with the machine's real PATH, where no fake `central` exists. `hostEnv` now drops every inherited case-variant of the keys it overrides (and of the ones it unsets). Both legs now also require `provider.status`'s `jbcentral` to be `configured`, not merely a `compiled-external` model in `model.list`. The artifact lives inside the *default* agent dir, so that leg could otherwise pass through pi's own agent-dir discovery rather than the Central-fed absolute path the gate exists to pin. Verified in both directions locally: green as written, and with a fake that exits non-zero the smoke fails fast naming `probe-failed / nonzero-exit`. * chore(ci): keep the Windows leg's rationale only in .github/SPEC.md * fix(shared): the Central installer fallback names the file each OS installs `resolveJbcentralBin`'s `~/.local/bin` fallback probed an extensionless `central` on every platform, so on Windows it could never match a real install: the official `install.ps1` writes `$HOME\.local\bin\central.exe`. That fallback exists for exactly one case — Central installed from the in-app guidance while the host is already running with a stale PATH — so on Windows it silently never fired, and the card kept reporting `absent` until restart. The PATH lookup keeps the bare name: `Bun.which` tries the Windows executable extensions itself. The test that should have caught it stubbed `exists` as true for every path, which made the filename unobservable. It now pins the exact path each installer writes, per platform, and asserts the extensionless Windows path resolves to null. Reported by the PR review bot; confirmed against the published installer. |
||
|
|
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). |
||
|
|
3f23794e26 |
Integrate JetBrains Central native PI support (#255)
* feat: integrate JetBrains Central PI provider * fix: harden Central runtime reconciliation * fix: prevent legacy migration overwrite races * todo: Record the approved design in specs ThinkRail-Todo: 01a01508-9db7-77af-a286-391527b9c28e/t_1ea9b21e96ca * todo: Confirm watched runtime-rebuild design ThinkRail-Todo: 01a01508-9db7-77af-a286-391527b9c28e/t_85b4ab7fe810 * todo: Finalize runtime-generation contracts and specs ThinkRail-Todo: 01a01508-9db7-77af-a286-391527b9c28e/t_c194ee506cd8 * todo: Implement artifact watcher and runtime generation swap ThinkRail-Todo: 01a01508-9db7-77af-a286-391527b9c28e/t_0540bdf91ec4 * todo: Update wire handlers and JetBrains AI UI ThinkRail-Todo: 01a01508-9db7-77af-a286-391527b9c28e/t_687d5d5d8c12 * todo: Add unit and E2E coverage ThinkRail-Todo: 01a01508-9db7-77af-a286-391527b9c28e/t_4a04e23fd153 * todo: Fix runtime rebuilds dropping host-provided providers ThinkRail-Todo: 01a01508-9db7-77af-a286-391527b9c28e/t_5412a9a2040b * todo: Run full verification and review diff ThinkRail-Todo: 01a01508-9db7-77af-a286-391527b9c28e/t_2c4f5646e2d5 * fix: harden Central watcher and CI boot tests * todo: Apply edits + update specs where rationale must land ThinkRail-Todo: 01a018f5-9709-718d-8cd4-fe13fb6071f1/t_eae96d31928a * feat: gate Central on a minimum version, not an exact reviewed one Support is now a floor only: MINIMUM_CENTRAL_VERSION = 1.4.0, the first Central release carrying the native PI surface (JCP-4019, "Support Pi agent"). Anything at or above it is `supported` and reports its own probed version; only lower versions ask for an update. Drops the `unreviewed` status from the adapter, the wire union, the auth mapping, and the card — a newer Central no longer warns and no longer blocks Connect. There is deliberately no upper bound: gating on one would strand users behind every Central release, as the previous exact 1.6.2 pin already did for 1.7.0. Also folds in the pending working-tree edits to the same files: the install base moves to https://central-cli.labs.jb.gg (with its unit expectation), and the card's install/new-chat copy is trimmed. * feat: check Central's auth and offer Sign in instead of a Connect that fails `central status` is probed and its `Auth` row parsed for one negative marker: `not connected` means signed out, every other rendering means connected, and a missing row / non-zero exit / timeout means unknown. Strictly one-directional — only a positively observed signed-out reaches the wire, because a false sign-in demand is worse than a missed one. The output is never returned or logged: that command prints the user's licence, company, and server URL. The probe costs ~1.3s and records a CLI analytics event per call, so it never runs on the read path. A status read answers from a cached verdict and starts a background refresh that publishes the ordinary provider invalidation only when the answer changed; a refused `add pi` and a launched `central login` drop the cache. Nothing polls Central. Signed out renders as one state, whatever the configuration underneath: the body says only that Central is signed out, and Sign in is the only action — Connect and Disconnect both withheld, since the card must not advertise what cannot succeed or pair the fix with an unrelated choice. All of it returns the moment credentials do. Signing in is one button, never a menu: the `central login` command survives only where the launch itself failed. Adds e2e/00-jbcentral-lifecycle.spec.ts — five scenarios (absent, signed out, uninstalled while connected, PI disconnected in-app and on the host, host-side logout) with review screenshots, plus shared Central fixtures that both Central specs now use instead of duplicated helpers. * fix: bound Central probes by their deadline, and close the coverage gaps that hid it A coverage audit of this integration (274 enumerated behaviours against 57 existing tests, each candidate gap given to a skeptic who tried to refute it) turned up defects that green suites were hiding. The tests written for them found one more. `runProcess` fired a kill on timeout and then still awaited the child's stdout. Killing a child does not close a pipe its grandchildren hold open, and Central spawns a proxy daemon — so a probe could outlive its timeout by as long as that daemon lives. The version probe is on the host's boot path, where an unbounded wait means no port, no UI and no error. The deadline now wins the race outright. The new real-spawn test measured 20s against a 5s timeout before the fix. `launchJbcentralLogin` treated a successful spawn as a started flow. The real `central login` drives its browser handoff from a terminal UI and exits at once without a TTY, so the card told users to finish a sign-in in a browser that never opened. The launch now waits a grace period for an early exit; an immediate zero exit is Central's already-signed-in short-circuit, and a failure surfaces the host command as the fallback. `invalidateAuth` zeroed the timestamp but let an in-flight probe land, stamping a verdict about the world *before* the credential change as fresh — swallowing the invalidation for a whole TTL. Guarded with a generation counter, matching the rebuild drain's existing idiom. Two card defects: a signed-out verdict arriving with a Connect failure rendered two sign-in buttons (reachable precisely because a refused `add pi` invalidates the verdict), and a sign-in note keyed on `status.state` outlived its own demand whenever that state never changed — visible in a real-run screenshot as "Connected" sitting above "Complete sign-in in the browser". Tests: the real process runner had no coverage at all (every suite injected the `run` seam), so the spawn, its stdout bound at and past 4096 bytes, and the kill now execute. The auth probe's cost invariants are pinned — a burst of reads collapses to one probe, and none runs while an action is in flight. Five failure modes wired into the e2e fake had no spec driving them; `update-error` was structurally unreachable because a single-valued control could not be both outdated and refusing to update, so the fake's state is now composable tokens. Each new test was mutation-verified: three of them passed for the wrong reason until the mutation exposed it. Also fixes a pre-existing suite flake: resetState's recursive wipes race the host writing session files, producing ENOTEMPTY false reds in unrelated specs. * todo: Update owning module specs and wire contract ThinkRail-Todo: 01a01a83-db16-7630-9d85-145201610b59/t_fec362ea0463 * todo: Implement Central proxy probe/action across shared, server, contracts, and web ThinkRail-Todo: 01a01a83-db16-7630-9d85-145201610b59/t_e88c3ecfb7f1 * todo: Add unit and deterministic e2e coverage ThinkRail-Todo: 01a01a83-db16-7630-9d85-145201610b59/t_8adb960d62ab * todo: Run focused tests, fast gates, and full e2e suite ThinkRail-Todo: 01a01a83-db16-7630-9d85-145201610b59/t_4cb6035ad5ff * todo: Review complete diff and summarize findings ThinkRail-Todo: 01a01a83-db16-7630-9d85-145201610b59/t_66479ab0d336 |
||
|
|
502ee96d5c |
fix nightly buid (cli): seed the smoke transcript at the host's worktree path (#242)
* fix(cli): seed the smoke transcript at the host's worktree path
The nightly release matrix has been red since 2026-08-13: the macOS arm64 and
Windows x64 `build-binary` jobs both fail their boot-smoke with
smoke FAILED: session.delete left the seeded transcript on disk
while both Linux jobs pass, so `sign`/`release` never run and no nightly ships.
The smoke seeded its throwaway pi transcript at its *own* temp path, but the host
stores git's symlink-resolved root (`openProject` keeps `gitToplevel(path)`, and
the Default workspace inherits it verbatim as `worktreePath`). A handed-in temp
path is only incidentally canonical: macOS resolves `/var` -> `/private/var`, and
Windows' `TEMP` is the 8.3 `RUNNER~1` form of `runneradmin`. pi keys session dirs
by the exact cwd string, so the fixture landed in a directory the host never
scans -- and since `deleteSession` treats "no transcript matched this workspace"
as legitimate idempotent success (a stray id must trash nothing), the RPC
returned ok with the file still on disk. `/tmp` on Linux is already canonical,
which is why only the release matrix saw this; CI smokes the binary on ubuntu
only.
Seed against the host-reported `worktreePath` from `workspace.list` instead --
the same contract e2e already uses (`seedWorkspaceSession(worktreePath, ...)`,
and `auto-open-chats.spec.ts` already guards this hazard with `realpathSync`).
Taking the host's own string also covers Windows, where git reports forward
slashes and `realpathSync` reports backslashes.
Test-harness only; no product behaviour changes. Real sessions are always created
with the host's own resolved cwd, so that side never diverged.
Reproduced the CI failure on Linux by pointing `TMPDIR` at a symlink (identical
message, transcript stranded in the unscanned encoded dir), green after the fix;
baseline real-tmpdir smoke green.
* fix(cli): kill the smoke host on failure and keep its state
`fail()` calls `process.exit(1)`, which unwinds nothing — the `finally` at the
bottom of the script never runs — so every assertion failure after the host was
spawned left it running. On CI that surfaces as `Terminate orphan process: pid
(1334) (thinkrail-darwi)` in the teardown of the very nightly job this branch
fixes; locally it is worse, because the orphan keeps the inherited stdout pipe
open and any piped invocation (`bun run smoke:binary | tail`) hangs indefinitely
after the failure has already been printed.
Kill the host from `fail()` itself, via a `killHost` hook that is a no-op until
the spawn installs it (the pre-boot assertions must stay safe to call). The
`catch` no longer needs its own `SIGKILL`, so every exit path — thrown or
asserted — now sheds the process through one place.
The throwaway dirs are deliberately *kept* on failure and their location printed:
they are the post-mortem for exactly the class of bug this branch fixes (which
encoded session dir a transcript landed in, what got staged), and a CI runner
discards them with the job anyway. The success path still cleans up as before.
Verified both paths against a copy of the script with one assertion deliberately
broken: fails in ~2s with no orphan process and the state dir preserved, and the
unmodified smoke still exits 0 leaving nothing behind.
|
||
|
|
4ebad6ea9d |
Add review clearing and chat deletion (#218)
* review shipped — drop from V2 deferred list * add review clear and chat trash * fix deleted chats reappearing * fix(server): keep chat deletion recoverable * fix(review): converge clear across clients * fix(binary): bundle Linux trash parser * fix(binary): stage OS-trash helpers * fix(agent): retain chats when trash fails * fix(review): archive records on clear * fix(web): reconcile chats after reconnect * test(e2e): close socket in reconnect coverage * docs(spec): record review in V1 scope * fix(agent): fail closed on transcript lookup * fix(agent): reject live commands during a chat delete * fix(agent): single-flight chat deletion * fix(web): keep Clear available for a fully-finished review |
||
|
|
e333401faa |
fix(agent): recover premature length stops (#220)
Upgrade Pi to 0.84.1 and treat agent_settled as the authoritative terminal lifecycle event. Preserve final failures across hydration and reconnects, and harden the affected binary and history seams. |
||
|
|
e75567e2dc |
feat(analytics): every channel reports, tagged by build provenance
Delete the two gates that kept non-release runs silent: the stable/nightly channel allowlist and the empty CI-baked key. `channel` is now a reported property, and a committed `POSTHOG_PROJECT_KEY` gives a from-source host a destination — so `apps/cli/src/analytics-keys.ts` and the release key plumbing go away. In their place, one environment mute policy (`analytics/mute.ts`): THINKRAIL_NO_ANALYTICS > CI > NODE_ENV=test, all failing closed. The service is its single reader, so no entrypoint can forget to mute — `dev.ts` needs no wiring and host-booting unit tests are silent for free. A new `build` property separates a locally compiled binary from a source run (both `channel=dev`). Provenance is a parameter, not a sniff at Bun's internals: `bootstrap.ts` exports `launch(build)`, `index.ts` says "source", `compiled-entry.ts` says "binary". Specs and the README are updated — the README previously promised users that a dev run could never emit events. |
||
|
|
96968fb8a8 |
fix(e2e): per-worktree isolation for tmp state dirs and ports (#133)
* fix(website): keep theme-menu keydown lint-clean with a typed indexOf
biome's useIndexOf flags the findIndex-for-equality in the theme-menu
keydown handler (pre-existing red lint on main). The raw autofix would
break typecheck (activeElement is Element | null vs HTMLButtonElement[]),
so narrow via instanceof first — same semantics, findIndex's -1 fallback
included.
* fix(e2e): per-worktree isolation for tmp state dirs and ports
Parallel e2e runs from different worktrees used to collide: every
worktree resolved the same machine-global $TMPDIR/thinkrail-e2e (one
run's globalSetup/teardown rmSync'd a sibling run's live host state —
persistence, fixture repo, HOME, pi agent dir, picker/central control
files) and the same fixed ports (24252/24272/24254; exact-bind
EADDRINUSE, or during the build-phase race two serial suites
interleaving against one surviving host on the shared baseURL; the
binary suite could even drift ports while Playwright's /health poll was
answered by another worktree's host).
Fix, in the one seam every suite already imports (e2e/fixtures/paths.ts):
- derive a stable per-worktree key from the module's own repo root
(sanitized basename + sha256(realpath) prefix) and suffix every
machine-global dir with it: E2E_DATA_DIR, E2E_BINARY_CACHE, and the
restart spec's data dir + host log (moved here so all machine-global
names live in one file)
- derive a per-worktree port block (25000 + hash%500*10, clear of dev's
24242): main suite +0, e2e:binary +2, restart spec +4 — deterministic
because the Playwright runner, workers, and global setup each evaluate
the module and must agree; THINKRAIL_E2E_PORT_BASE overrides a rare
slot clash (invalid values throw)
- smoke:binary needs no change: the CLI free-scans past a taken port and
the script reads the served URL from stdout (comment corrected)
- within ONE worktree the suites still share state and stay sequential
(unchanged rule, documented); AGENTS.md verification paragraph updated
Verified: check:deps/check:seams/lint/typecheck green; derivation
deterministic per root and distinct across sibling worktrees; bun run
e2e 98/98 green on the derived port/state dir with clean teardown.
* fix(e2e): arbitrate port blocks via an atomic machine-local claim registry
Review-flagged residual: the pure path hash mapped worktrees onto 500
slots, so two worktrees could derive the same port block — and under
that collision the binary suite's failure shape is silent (the CLI
free-scans past the taken port while Playwright polls the expected one,
which the other worktree's host answers), reproducing exactly the class
this change set exists to kill.
The hash now only picks the *preferred* slot; ownership is arbitrated by
a tiny machine-local registry (e2e/fixtures/portBlock.ts): one claim
file per slot under $TMPDIR, content = the owning repo root, created
with O_EXCL so the filesystem arbitrates races. Claims persist across
runs (runner, workers, global setup, and later runs all converge with no
coordination) and self-clean (a claim whose recorded worktree path no
longer exists is reclaimed). Suite teardown never touches the registry —
it is the memory that keeps live worktrees apart. THINKRAIL_E2E_PORT_BASE
still bypasses it to pin a block explicitly.
e2e/port-block.spec.ts pins the contract (convergence, distinct blocks
under a preferred-slot collision, stale reclaim, wrap-around, registry
bootstrap); a 16-process concurrent-claim race was verified by hand.
Full suite: 104/104.
* fix(e2e): serialize port-block claims with an interprocess lock; sticky two-pass allocation
Review round 2 found two real protocol flaws:
1. The read→reclaim→create dance was not atomic: two processes could
both judge one claim stale, and the slower rmSync then deleted the
faster one's FRESH claim — two worktrees on one block, the exact
silent class the registry exists to prevent. The whole transaction
now runs under an interprocess mkdir-lock (atomic to create; a lock
older than 10s is a crashed holder's leftover and is broken — it
guards a sub-millisecond critical section). Stale claims are plain
overwrites under the lock; no unlink window remains.
2. The scan could claim an earlier newly-freed slot before discovering
this worktree's existing later claim — migrating the assignment and
stranding the old claim as a live-looking leak (predecessor churn
could strand slots indefinitely). Allocation is now two-pass under
the same lock: an existing claim for this repo root always wins
(assignments are sticky, never migrate), duplicates are deduped to
the lowest slot; only then does the preferred-slot scan allocate.
port-block.spec.ts grows the churn scenario (displaced worktree stays
put after its predecessor dies; a newcomer reclaims the stale slot),
dedupe, stale-lock breaking, and fresh-lock timeout; a 16-process race
over pre-seeded stale claims was verified by hand (16 distinct stable
blocks, no leaked slots). Full suite: 108/108.
* fix(e2e): liveness-arbitrated registry lock with fenced release
Review round 3: lock age is not proof the holder died — a suspended or
descheduled holder outliving the age threshold would have its lock
broken, resume inside the critical section, and its unconditional
release would then delete the NEW owner's lock, cascading the loss of
mutual exclusion. Node/Bun expose no flock, so the dependency-free
equivalent:
- a lock is born atomically WITH its owner record ({pid, nonce}, staged
then rename()d into place — rename refuses to replace a non-empty
dir, so no created-but-ownerless window exists)
- a held lock is broken ONLY when its recorded pid is provably dead
(kill(pid,0) → ESRCH): a crashed holder breaks immediately (faster
than the old age wait); a live-but-suspended holder is never usurped
— waiters time out LOUDLY; pid reuse degrades the same conservative
way (loud wait, never a broken mutex)
- release is fenced by the nonce: only the acquisition that still owns
the lock may remove it, so no resume interleaving can delete a
successor's mutex
- age (STALE_LOCK_MS) survives only for a garbled lock with no readable
owner, which the protocol itself cannot produce
Tests: dead-pid lock broken immediately; live-pid lock times out loudly
(never usurped); garbled lock waits fresh / breaks old. 16-process race
over pre-seeded stale claims re-verified (16 distinct stable blocks,
zero lock artifacts leaked). Full suite: 109/109.
* fix(e2e): serialize lock-breaking behind a token; verify claims post-release
Review round 4: dead-owner reclamation was still an unfenced
check-then-delete — two waiters could both read one dead owner, and the
slower rmSync, acting on its stale decision, deleted the faster one's
freshly installed lock, re-admitting two processes into the claim
transaction. node/bun expose no flock without native deps, so this is
the fenced equivalent:
- breaking now happens only inside tryBreakLock: the breaker must win an
exclusive break-token (mkdir, single winner), and the kill decision is
re-made on FRESHLY READ state under that token — a stale earlier
reading can never delete a successor's live lock. A leftover token
(crashed breaker) can only BLOCK breaking, never corrupt, so the crude
age rule is safe for tokens.
- belt over the whole protocol: claimPortBlock re-reads its slot AFTER
releasing the lock and retries the transaction (bounded) if the claim
was overwritten — a hypothetical residual mutex failure self-heals at
the layer that matters instead of yielding two worktrees on one block.
- the residual floor is stated in the header: without an OS-death-
released lock, what remains requires a process SIGSTOP'd >10s inside a
sub-millisecond window, twice, at exactly the wrong instants.
Tests add the reviewer-requested forced two-reclaimer interleaving
(driven through the real exported break routine: A breaks the dead lock,
a successor installs, B executes its stale decision — successor
untouched, exclusivity intact) and token serialization (a foreign fresh
token blocks breaking; a stale token only ever blocks and ages out).
16-process race re-run with a planted dead-owner lock contended by all
racers: 16 distinct stable blocks, zero artifacts. Full suite: 111/111.
* fix(e2e): never auto-reclaim break-tokens — wedge loudly instead
Review round 5: aging an orphaned break-token out was itself a
stat-then-delete on a mutable path — the same unfenced-reclamation class
one level down (B pauses after stat, A replaces the token, B's rm
deletes A's live token), and any reclamation primitive would just
recurse the problem.
Terminate the regress by removing reclamation: tokens are never
auto-reclaimed. This is sound because a token exists for microseconds
and is orphaned only by a kill inside that window; an orphaned token
only ever BLOCKS breaking (installs don't consult it); and because the
token holder keeps the sole break right until its own rm fires, a
pending removal can only ever hit the dead lock it verified — never a
successor's. The degraded case is availability-shaped, not
correctness-shaped: the acquire timeout now names the holder state
(live pid / dead pid + wedged / unreadable) and the exact registry dir
to remove, once, by hand.
The token test now pins the wedge semantics (an ancient orphan still
blocks — loudly, with the cleanup path in the message — and manual
removal recovers); race + full suite re-verified (16/16 distinct stable
blocks; 111/111).
* fix(e2e): restore import order in ask-restart spec after main merge
|
||
|
|
eb3cca2cb8 |
feat(cli): real Windows self-update + thinkrail uninstall (#140)
* feat(cli): real Windows self-update + a `thinkrail uninstall` subcommand `thinkrail update` on Windows only printed advice and exited 1. It now runs the published `install.ps1` through `powershell -File` (falling back to `pwsh`), with the resolved `-Channel`/`-Version`/`-Prefix` passed explicitly; install.ps1 already handles replacing the running exe. Any failure still prints the manual per-shell command. New `thinkrail uninstall`: removes the executable, the installer's PATH edit, `install.json`, and the binary's staging cache, and asks whether to delete `~/.thinkrail` (kept by default). `--remove-data` / `--keep-data` / `-y` answer it non-interactively. * fix(cli): only remove the Windows PATH entry install.ps1 recorded adding `install.json` proves ThinkRail was installed, not that the installer added the PATH entry: it is written for `-NoModifyPath`, when the entry was already there, on a failed registry write, and by install.sh under Git Bash (which never touches the Windows PATH). Uninstalling then stripped a directory the user may share with other tools. install.ps1 now records `path_entry_added` (sticky across re-installs of the same prefix, since an update sees 'already' only because an earlier run of ours added it), and uninstall removes the entry only for that flag and that prefix. Legacy metadata counts as unowned. |
||
|
|
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. |
||
|
|
145e5e5dbb |
feat(agent): load portable cross-agent skills (#94)
* feat(agent): load portable cross-agent skills
* fix(agent): gate committed cross-agent skills behind per-project trust
A repo's committed skill aliases (.claude/skills, .github/skills,
.gemini/skills) were loaded automatically on project open and injected
into the agent's system prompt — a prompt-injection surface for any
cloned repo. Gate them behind an explicit per-project trust grant;
personal (~/.claude …), pi-native, and ThinkRail-bundled skills load
regardless.
- Trust is a persisted Project.trusted flag, set via a new project.setTrust
wire method (protocol v10). buildResourceLoader / listSkillCommands take a
trustedProject flag; the host resolves it via a fail-closed
setProjectTrustResolver seam keyed by workspaceId.
- New Workspace shows a trust notice + "Trust project" button; the
autocomplete caption marks the preview as from the current checkout.
- Reorder skill precedence to pi-native > bundled > personal > project so a
repo can never shadow your own or ThinkRail's skills.
- Cache skill.list briefly per (cwd, trust).
- Verified Copilot personal dir (~/.copilot/skills) against GitHub docs —
correct, no change.
Verified: check:deps, lint, typecheck (8/8), unit (171/0), e2e no-agent (45).
@agent composer + smoke:binary updated for the trust grant (not run locally:
needs real-provider auth / binary build).
* refactor(agent): admission-context skill gate (acknowledge-new + toggles)
Generalize the per-project trust boolean into a per-skill admission model that
the later Skills-management UI drives:
- New pure `skillAdmission` resolver (`decideSkill`) → load / untrusted /
pending-ack / disabled, with the trust gate checked before the enable/disable
layer (an "on" override can never un-gate an untrusted/unacknowledged alias).
12 unit tests.
- Model: `Project.acknowledgedSkills` (re-confirm-new — granting trust
acknowledges only what's present now) + `Project.disabledSkills` baseline +
`Workspace.skillOverrides` (per-workspace on/off).
- Wire it through: `skillsGate` filters + relabels in one skillsOverride;
`buildResourceLoader`/`listSkillCommands` take the admission context; the seam
generalizes `setProjectTrustResolver` → `setSkillAdmissionResolver`
(workspaceId → context, fail-closed); `project.setTrust` acknowledges the
skills present at grant via `listProjectAliasSkillNames`.
- All alias dirs are now discoverable (the per-skill gate withholds, not path
omission) so the catalog can enumerate them. Fixes a stray NUL byte in the
skill.list cache key.
Verified: typecheck 8/8, unit 23 (agent/projects), e2e no-agent 45.
* feat(contracts,server): skills-manager wire — catalog, reload, mutations (v11)
Server + protocol for the workspace Skills manager (UI in follow-up stages):
- `skills.state({workspaceId})` → `SkillCatalogEntry[]`: every discovered skill
for the worktree with its admission `decision` (load/untrusted/pending-ack/
disabled) via new `listSkillCatalog` (relabel-only, no filter).
- `session.reloadResources({sessionId})` → `session.reload()` (re-scan skills +
rebuild system prompt, transcript preserved); rejected while streaming.
- `project.acknowledgeSkills` / `project.setSkillEnabled` /
`workspace.setSkillOverride` mutation methods + their persistence helpers.
- `SkillDecision`/`SkillCatalogEntry` in contracts (single source; server
`skillAdmission` re-exports `SkillDecision`). Protocol v10 → v11.
Verified: typecheck 8/8, unit 66 (agent/projects).
* feat(web): presence-gated trust notice + WelcomePanel skills section
- New `project.aliasSkills({projectId})` → present committed alias skill names
in the checkout, so the trust notice is presence-gated (hidden when the repo
ships no skills) and shows a COUNT, never attacker-controlled names, pre-trust.
- `ProjectSkillsNotice` (reusable, pre-workspace): "ships N skills → Trust", a
"N new skills → Review & enable" state (re-confirm-new via
project.acknowledgeSkills), and a quiet "N trusted" confirmation. Mounted in
WelcomePanel so trust is reachable with no workspace yet.
- New Workspace notice now presence-gated + shows the count.
Verified: typecheck 8/8, lint, e2e no-agent 45.
* feat(web): workspace Skills manager dialog (chat header)
A Skills button in the chat header opens a workspace-scoped manager
(SkillsDialog) driven by skills.state:
- Lists every discovered skill grouped by source (Project / Personal /
Bundled / Pi) with its admission verdict.
- Trust a project's committed skills; confirm skills that appeared later
(pending-ack → Enable); per-workspace enable/disable toggles
(workspace.setSkillOverride).
- Reload applies changes to *this* chat's running session
(session.reloadResources); disabled while streaming.
- Mutations echo the updated record back + re-read the catalog so verdicts
refresh live.
Verified: typecheck 8/8, lint. (Dialog lives in the chat header, so its e2e
coverage is @agent — needs a live session; screenshots to follow.)
* feat(web): auto-detect worktree skill changes → reload hint
Reuse the worktree change-notifier (workspace.fsChanged): when a skill dir
(.claude|.github|.gemini|.pi|.agents /skills) changes on disk after a session
loaded (pull/branch/edit), flag skills stale. The chat-header Skills button
gets a dot badge and the dialog shows a "changed on disk — Reload" hint; a
successful Reload clears it. Manual reload (the user's choice), so this only
prompts — nothing changes under the agent without a click.
Verified: typecheck 8/8, lint.
* docs(spec): record the skills-manager feature across module SPECs
Bring the module specs in line with the shipped code (spec-leads-code):
- agent/SPEC.md: the `skillAdmission` model (load/untrusted/pending-ack/
disabled), `setSkillAdmissionResolver` seam, listSkillCatalog/
listProjectAliasSkillNames/reloadSessionResources (replaces the stale
trustedProject/setProjectTrustResolver wording).
- contracts/SPEC.md: acknowledgedSkills/disabledSkills/skillOverrides +
SkillCatalogEntry/SkillDecision + the Skills-manager method set (v11).
- host/SPEC.md: the Skills-manager handlers + setSkillAdmissionResolver wiring.
- chat/SPEC.md: SkillsDialog + the header Skills trigger + fs-nudge staleness.
- panels/SPEC.md: presence-gated notice + ProjectSkillsNotice.
* feat(agent): discover installed Claude plugins' skills
Claude plugins (superpowers, etc.) install under ~/.claude/plugins/cache/…,
not the flat ~/.claude/skills the aliases scan — so they were invisible. Read
~/.claude/plugins/installed_plugins.json and add each install's
<installPath>/skills as a personal-scope source: the resolved (version-pinned)
path from the manifest, never a blind cache sweep — so stale versions and
transitive node_modules/**/skills junk are excluded. Appended after the
hand-written personal aliases, so a loose ~/.claude/skills/<name> still wins a
name collision.
Verified: skillSources + extensions unit tests, typecheck 8/8, lint.
* feat(web): group Skills manager entries by installing plugin
Tag each plugin-discovered source with its plugin name (from the
installed_plugins.json key) → carry it onto `SkillCatalogEntry.plugin` → the
Skills dialog renders a group per plugin (superpowers, chrome-devtools-mcp, …)
between Personal and Bundled, instead of lumping them all under Personal.
Order: Project → Personal → plugins (sorted) → Bundled → Pi.
Verified: skillSources unit test (asserts the plugin tag), typecheck 8/8, lint.
* feat(web): clearer Skills-manager tabulation — boxed groups
Restructure the catalog list so the source/plugin grouping reads at a glance:
each group is a bordered box with a header (label + hint + a count badge) and
its skills in a divide-y container, instead of flat rows under a bare heading.
Per-skill rows drop their individual rounding (the box + dividers separate
them). data-testid="skill-group" for reference.
Verified: typecheck 8/8, lint.
* feat(server): group/source skill toggles + project-scoped catalog (v12)
Extend the admission model with a group dimension so a whole plugin or source
tier can be turned off in one toggle (your #1 + #2):
- `Project.disabledGroups` (a plugin name, a source tier project/personal/
bundled/pi, or the special `@plugins` = all plugin skills). `decideSkill`
disables a skill whose group is off — and keeps future skills in that group
off — while a per-skill `on` override still wins.
- `skillGroup()` assigns each skill its canonical group key (matches
`SkillCatalogEntry.group` so UI + server agree); `project.setGroupEnabled`
mutates the baseline.
- `project.skills({projectId})` — project-scoped catalog (current checkout, no
workspace overrides) for the pre-session manager (your #3). Protocol v12.
Verified: skillAdmission (group cases) + extensions + skillSources + projects
unit tests (30), typecheck 8/8, lint.
* feat(web): group toggles, "all plugins", + Skills manager pre-session
SkillsDialog gains the group/source controls and becomes reusable pre-session:
- Each group header has an on/off toggle (turn a whole plugin or source tier
off via project.setGroupEnabled); a top "All Claude plugins" master toggles
@plugins. A disabled group/master grays its skills' toggles ("group off") —
re-enable the group to change individual skills.
- Two modes from one component: workspace (skills.state + per-workspace
overrides + Reload) and project (project.skills + per-project-baseline
toggles, no session) — driven by an optional `workspace` prop.
- #3: a "Manage skills" opener on WelcomePanel and New Workspace mounts the
manager in project mode, so trust + toggles are reachable with no workspace.
Verified: typecheck 8/8, lint. (Browser screenshot next.)
* docs(spec): record group/source toggles + pre-session manager
- agent/SPEC.md: the group dimension (`disabledGroups`, `@plugins`, `skillGroup`
keys) in the admission model; `listSkillCatalog` drivable workspace- or
project-scoped.
- contracts/SPEC.md: `Project.disabledGroups`, `SkillCatalogEntry.group`,
`project.setGroupEnabled` + `project.skills` (v12).
- host/SPEC.md: the new handlers.
- chat/SPEC.md: SkillsDialog's per-group + All-plugins toggles and its two
modes (chat vs project).
- panels/SPEC.md: the "Manage skills" opener on Welcome + New Workspace.
* feat(web): first-party skills first + sticky group headers
- Reorder the Skills manager: ThinkRail-bundled + pi-native first-party skills
lead, then Personal, then plugins (sorted), then the repo's gated Project
skills last.
- Sticky section headers (VSCode-style): each group header pins to the scroll
top while its group is in view, then the next header pushes it out. Dropped
the per-group overflow-hidden box (it would clip a sticky child); an opaque
header bg keeps rows from bleeding through.
Verified: typecheck 8/8, lint. (Screenshot next.)
* feat(web): rename "All plugins" + make it a sticky header
- Drop "Claude" from the master toggle: the `@plugins` gate disables any
plugin-sourced skill regardless of tool; Claude is just the only plugin
system we discover today, so "All plugins" is the accurate, future-proof
label (Codex/Gemini/etc. plugins would be covered automatically if added).
- Move the master into the scroll container as the first sticky row, so it
follows the same sticky-header pattern: pins at the scroll top, then the
first group's header covers it as you scroll in.
Verified: typecheck 8/8, lint.
* feat(web): pin "All plugins" above everything (two-level sticky)
The all-plugins master now stays pinned at the scroll top (higher z, fixed
h-8) instead of being covered by the first group header; group headers stick
*below* it at `top-8`. So scrolling through any group keeps the master visible
on top — a VSCode-style two-level sticky (master + current section) — rather
than scoping it to the plugins region.
Verified: typecheck 8/8, lint.
* feat(web): use BookOpen (not Sparkles) for the Skills button
* fix(web): Skills dialog — clear close/Reload overlap, nest skills under groups
- Reserve pr-8 on the header so the DialogContent's absolute close (X)
no longer sits on top of the workspace-mode Reload button.
- Indent skill rows with a left guide rail so they read as children of
their group/plugin header; mark plugin groups with a Puzzle icon.
* feat(web): Skills — rename Bundled group to ThinkRail; ThinkRail + Pi lead above All-plugins master
The first-party groups (ThinkRail bundled + Pi native) render at the top
of the catalog, above the All-plugins master — they aren't plugins and the
master doesn't govern them. The master pins once they scroll past and
governs only the plugin groups below it; the two-level plugin sticky is
preserved.
* feat(web): unify the Skills trigger; drop Welcome "Manage skills" opener
Extract the chat header's Skills pill into a shared chat/SkillsButton primitive
and reuse it in NewWorkspaceDialog, so the two triggers can't drift (matching the
ModelSelector / slash-completion sharing pattern). New Workspace's opener now
shows the BookOpen + "Skills" pill instead of a plain text link.
Remove the "Manage skills" opener from the project Welcome screen: the full
manager stays reachable from New Workspace and the chat header, and
ProjectSkillsNotice still surfaces project-trust there. Update the chat + panels
SPECs to record the shared primitive.
* fix(agent): apply skill-admission changes on reload + key the preview cache by group
Two skill-admission correctness fixes flagged in review:
- Reload was a no-op for admission changes. `buildResourceLoader` captured the
workspace's `SkillAdmissionContext` at session creation, and `skillsGate` closed
over that snapshot — so `session.reloadResources` re-scanned the filesystem but
re-applied the original trust/acknowledge/enable/disable/group state, leaving the
running chat's skill set unchanged. Pass the admission as a `() => context` thunk
that the gate re-reads on every `loader.reload()`, so a mid-session grant or toggle
actually lands.
- The pre-session skill-list cache key omitted `disabledGroups`, which `decideSkill`
gates on — so disabling a source/plugin group and creating a workspace within the
5s TTL could serve the stale enabled catalog. Add sorted `disabledGroups` to the key.
Regression tests cover both (reload after a group toggle; two catalog reads differing
only by `disabledGroups`). Spec updated for the resolver + reload semantics.
* fix(agent): reload picks up a compatibility skill dir that appears mid-session
The resource loader froze the set of compatibility source dirs at session
creation: `additionalSkillPaths` held only the dirs that existed then, so a
branch switch / pull / clone that added `.claude/skills` (or another alias root)
after the chat started was invisible to `session.reloadResources` — the watcher
offered Reload but the new dir was never scanned.
Register the fixed project/personal alias roots as candidate skill paths whether
or not they exist yet (pi tolerates an absent path and scans it once it appears),
and re-discover the live source set inside `skillsGate` on every `loader.reload()`
instead of closing over the creation-time snapshot. The fresh discovery is also a
safety requirement: a late-appearing project `.claude/skills` must be reclassified
as a project alias so the trust gate still withholds it — otherwise it would slip
through as an unclassified `load`. (Plugins installed after session start aren't
covered — their install path isn't known up front; that still needs a fresh session.)
Extracts `candidateCompatibilitySkillRoots` (pre-existence-filter view) from
`discoverCompatibilitySkillSources`. Regression tests: a dir created after
construction is picked up on reload, and a late untrusted project alias stays gated.
* refactor(web): drop the slash-completion biome-ignore via render-phase reset
The completion hook reset its highlight + dismissal in a useEffect keyed on
[query, commands], suppressing useExhaustiveDependencies — which the repo's
no-silent-suppressions invariant prohibits and the handoff audit would flag.
Replace it with React's "adjust state on prop change" pattern: track a reset
signal derived from the query + the command *names* (a stable content identity,
so an unstable `commands` reference can neither spuriously reset nor loop) and
reset during render when it changes. No effect, no directive; behavior preserved.
---------
Co-authored-by: danyaberezun <danya.berezun@gmail.com>
|
||
|
|
eb587ed96c |
feat: chat-scoped TODO plans — pi-todos extension + wire + UI
- Adds a chat-scoped TODO list: the `pi-todos` pi-extension (per-session store - under gitignored .thinkrail/context/todos), the todo.* wire protocol + DTOs, - server handlers with git change-artifacts, and the chat plan UI. Related to #21 |
||
|
|
f2e4d5a261 |
feat(pi-thinkrail-workflow): the workflow system — routed skill family with meta-rules (#59)
* spec(pi-thinkrail-workflow): the workflow system — meta-layer with meta-rules skills/SPEC.md is the family's meta-layer and the authoritative why: - concept model (workflow, skill, sibling doc, concept, handoff, gate, artifacts) - three roles — router / worker / concept — with their handoff contracts (concepts carry no ending section; control simply returns to the reader) - meta-rules 1–15: structure, discovery & entry, chaining, artifacts, scaling, maintenance, naming; rule 14 (verify-by-use) is suspended — a known limitation, not currently a done-gate - the workflow family table (roles, routed-from, per-skill status) - current limitations & gaps: rule-14 suspension, brainstorming rework, unowned graph-extension, writing-specs/spec-graph overlap, unbuilt candidates — rationale lives here, never in the skills - per-skill design notes (only what the skill bodies don't state) The package SPEC.md slims to packaging/delivery, thinkrail integration, and testing, deferring the system's why to the meta-layer. Its boundary records that the writing-workflow-skills authoring checklist deliberately ships with the product (the skill body carries the matching workspace guard), and its testing section pins index.test.ts as the handler-wiring test for the system's single always-on entry. The spec leads: the skills land in the next two commits. * feat(pi-thinkrail-workflow): first skills — root router + authoring checklist - choosing-a-workflow (router, the single always-on entry): classifies incoming work and names what runs next — setting-up-a-project, brainstorming, or a declared "no matching workflow" ending; red flags against skipping the route or running skills from memory - writing-workflow-skills (worker, self-trigger only per rule 4): the actionable authoring checklist — design / write / register / verify — citing its rationale as "(rule N)" pointers into skills/SPEC.md; opens with a workspace guard: the family is extended only in the thinkrail repo — in user projects the staged skills are a read-only cache, so the skill says so and stops - index.ts: the before_agent_start WORKFLOW_RULE now points every run at the root router; index.test.ts stays — it pins the factory's handler wiring (registration + prompt append + prefix preservation), the system's single always-on entry, which nothing else exercises - server wiring + agent SPEC note updated for the workflow package * feat(pi-thinkrail-workflow): adapt the existing workflows to the system The pre-existing skills, adopted in place and reshaped to the meta-rules: - renamed per rule 15 (verb-first, name the work): project-setup → setting-up-a-project (sub-router/dispatcher), project-new → starting-a-new-project, project-import → importing-a-codebase - descriptions trimmed to triggers only, "Use when …" + negative triggers (rule 5); endings made explicit (rule 6) - concepts extracted per rules 3/7 where copies had drifted: asking-user-questions (ask_user_question rounds, options, inference confirmation, degradation) and writing-specs (the spec quality bar — short / honest / on-rails; the accruing home for spec + spec-graph rules); consumers now point, never restate — including the root router's own clarifying question, composed per asking-user-questions - dispatcher: router-pure (no norms in the body); the specs-present branch's accepted review/extend offer is a two-line operational instruction — no skill covers graph extension; say so, then align to the user's request holding the writing-specs bar - brainstorming routed as-is; its rework is recorded in the family table - app + e2e follow the rename: the Welcome card seeds /skill:setting-up-a-project, the @agent e2e becomes setting-up-a-project.live.spec.ts; smoke-binary asserts the full staged inventory — every skill under its new name plus skills/SPEC.md, which writing-workflow-skills reads at runtime |
||
|
|
5d29894fe1 |
ci: multi-platform release pipeline (nightly + stable) (#73)
* ci: multi-platform release pipeline (nightly + stable) Port the old repo's release pipeline to the Bun/Turbo monorepo. The shippable artifact is the single-file `thinkrail` binary that apps/cli already produces (build:binary / smoke:binary); this adds the automation to build it for every platform, stamp a release version into it, and publish GitHub releases. - Native OS matrix (_build.yml): compile + boot-smoke on the real OS for all five Bun targets — linux x64/arm64, darwin x64/arm64, windows x64. Chosen over cross-compiling from one host because the binary embeds bun-pty's dlopen'd FFI lib (host-target-proven only) and cross-built artifacts can't be smoke-tested. - Channels: nightly (cron + skip-when-no-commits) and stable (dispatch w/ bump), both main-only, versioned by the reused channel-aware next-version.sh. - _release.yml: build → sign (disabled `if: false` stub) → SHA256SUMS + GitHub release (prerelease for nightly). make-checksums reused; codesign ported/off. - Version stamping: new apps/cli/src/version.ts (default 0.0.0-dev), a `thinkrail --version` flag, threaded bootHost → createServer → server.welcome as ServerWelcome.appVersion (optional field, no PROTOCOL_VERSION bump). - smoke-binary: relax the clean-exit assertion on Windows (no real SIGTERM). - Specs: new .github/SPEC.md (release module) + version note in apps/cli/SPEC.md. * docs: add install.sh + user install guide for release binaries A repo-root installer that resolves the latest stable/nightly GitHub release, downloads the platform binary + SHA256SUMS, verifies, and puts `thinkrail` on PATH (adapted from the old repo: darwin asset names, optional token for the private-repo phase, no upgrade subcommand). README gains an Install section and .github/SPEC.md records the artifact-name contract install.sh consumes. * TEMP(verify-release): trigger nightly on this PR to verify end-to-end DO NOT MERGE this commit — reverted before merge. Adds a pull_request trigger to nightly.yml and lets the pull_request event past the main-only guard so the full build→release pipeline runs on the PR and publishes a test prerelease. * feat(cli): add `thinkrail update` self-update subcommand Port the old repo's `thinkrail upgrade` (renamed to `update`): re-invoke the published install.sh for the binary's channel so the installer stays the single source of the download → checksum → replace → PATH logic. Channel/prefix resolve flag > ~/.config/thinkrail/install.json > baked channel (dev → stable) / ~/.local. Unix-only (can't replace a running .exe on Windows → points to releases). Arg parse + resolution are pure + unit-tested; forwards GITHUB_TOKEN and honors THINKRAIL_INSTALL_SCRIPT_URL. install.sh/README/specs updated to say `update`. * ci: disable the macos-13 (Intel) release leg — runner queue stalls releases Comment out bun-darwin-x64 in the build matrix (mirrors the old repo). Ship 4 platforms: linux x64/arm64, darwin arm64, windows x64. install.sh now fails fast with a helpful message on Intel macOS; docs/spec updated to the 4-platform set. * ci: remove the temporary nightly PR trigger (verification done) Reverts the TEMP(verify-release) trigger: the full nightly pipeline was proven end-to-end on this PR (4-platform build → checksums → published prerelease → authenticated download + checksum verify + --version + boot smoke). Back to main-only (cron + workflow_dispatch). * install.sh: download assets via the releases API when a token is set The public github.com/releases/download URL 404s for private repos even with a token, so with GITHUB_TOKEN/GH_TOKEN/THINKRAIL_TOKEN set, resolve each asset id from the release JSON and pull the bytes via the assets API (Accept: octet-stream). No-token (public) installs keep the browser-URL path unchanged. This makes `install.sh` and `thinkrail update` work in the pre-open-source phase too (verified end-to-end against a real private nightly release). * docs: drop pre-launch/private-repo framing from install guidance Preparing for the public repo: remove the "Auth (private repo)" line from the install.sh usage and the "private (pre-launch)" README note. The token support stays (now framed neutrally: higher rate limits / private forks); no behavior change. * install: drop token/private-repo machinery (repo is going public) Remove the GITHUB_TOKEN/GH_TOKEN/THINKRAIL_TOKEN auth path from install.sh (auth_curl, the releases-API asset download + JSON id parsing) and the token forwarding in `thinkrail update`. Public releases download from the plain github.com/releases/download URL with no auth. Keeps THINKRAIL_INSTALL_SCRIPT_URL + THINKRAIL_REPO overrides. Specs updated. |
||
|
|
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. |
||
|
|
a6f66ad18d |
binary: bundle pi extensions as value-imported factories (#63)
* binary: bundle pi extensions as value-imported factories
The compiled binary crashed on boot since the bundled extensions were
introduced: extensions.ts require.resolve()d their raw-.ts entries out of
node_modules at module load, and a bun-compiled binary has no node_modules
(nor could pi's jiti loader resolve the extensions' own deps from a staged
copy).
- server: new public seam setBundledExtensions({ factories, skillsDir }) —
when set, buildResourceLoader passes the four extensions as value-imported
factories (full API parity per pi's loader) + a staged on-disk skills dir.
Dev keeps jiti path-loading, now resolved lazily on first session.
- cli: build-binary.ts generates a transient bundled-extensions.generated.ts
(value-imports of the entries resolved via the server package, so bun
compiles them + their deps in; skills embedded as file assets) with a
committed .d.ts contract; compiled-entry stages web + skills atomically
(temp dir + rename — also fixes the partial-extraction race on a killed
first run) and registers the factories before handing off.
Verified: binary boots, serves the UI, runs a live agent turn with
spec_grep / web tools / staged skills in an isolated sandbox; full e2e
suite (49, incl. @agent) green.
* ci: boot-smoke the compiled binary on every PR
bun run smoke:binary boots the built artifact against throwaway
data/agent/cache dirs and asserts /health, the staged web UI, the staged
bundled skills, and a clean SIGTERM exit. New CI job builds the binary on
the runner and runs it — the regression class this gates (extension/asset
wiring that only breaks inside the compiled binary) is invisible to the
from-source suites, which is how the boot crash shipped unnoticed.
|
||
|
|
6cc8ef8fba |
M15: CLI host bin + browser open (apps/cli) (#10)
* M15: CLI host bin + browser open (apps/cli)
The `thinkrail-pi` bin now boots the engine host in-process and opens the
browser, replacing the M0 `createServer()` stub.
- apps/cli/src/args.ts: pure parseArgs(argv, env) -> CliOptions + USAGE
(--port/--host with =value form, --no-open, -h/--help, positional
project-dir, THINKRAIL_PI_PORT/_HOST/_STATIC_DIR fallbacks, validation).
- apps/cli/src/index.ts: bootstrap() — resolveShellEnv first; resolve static
dir; createServer with EADDRINUSE fallback to an OS-assigned port; log URL +
cross-platform browser open (open/start/xdg-open) unless --no-open;
SIGINT/SIGTERM -> server.stop() -> exit.
- apps/cli/src/args.test.ts: 12 unit tests for parseArgs.
- server/host/server.ts: stop() now disposes agent sessions (+ terminals),
matching the host SPEC; added optional boot-time projectPath (best-effort
openProject; non-repo is a warning, not a boot failure).
- apps/cli/package.json: add @thinkrail-pi/shared dep + test script.
- Specs updated (apps/cli/SPEC.md draft->active, host/SPEC.md); dev.ts comment.
Verified: lint, typecheck, unit tests (incl. 12 new), no-agent e2e (13/13),
and bin smoke tests (serves /health + SPA + deep-route fallback, --help/exit
codes, port-collision fallback, project-dir open + non-repo warning, clean
SIGTERM shutdown).
* apps/cli: single-file binary build + disable image autoResize (no photon)
Ship a truly self-contained `thinkrail-pi` executable and keep image-read
working without bundling photon's WASM resizer.
Server (agent):
- buildSessionSettings(cwd): the user's real settings + an in-memory
`images.autoResize:false` override (applyOverrides — never persisted), passed
to every createAgentSession (new + disk-reopen). The read tool now sends image
files raw, so image-read needs no photon (its wasm can't be bundled into the
single-file binary). The web UI downsizes user-attached images itself.
- unit test: buildSessionSettings(...).getImageAutoResize() === false.
CLI binary (apps/cli):
- scripts/build-binary.ts: enumerate apps/web/dist, write a transient
web-assets.generated.ts (a `with { type: "file" }` import per asset + a
{route,data}[] manifest + content-hash version), `bun build --compile`
src/compiled-entry.ts, then delete the generated file. `--target` passes
through for cross-compile; each target bundles its bun-pty lib.
- src/compiled-entry.ts: stage embedded web files to a per-build cache dir
(XDG_CACHE_HOME/~/.cache/temp, idempotent), set THINKRAIL_PI_STATIC_DIR, hand
off to index.ts. bun-pty self-extracts automatically; no photon wasm.
- src/web-assets.generated.d.ts: committed type contract (tsc resolves it when
the generated .ts is absent); the .ts is gitignored + tsconfig-excluded.
- package.json: `build:binary` (cli + root); .gitignore the generated manifest.
Verified: lint, typecheck, unit tests (15), no-agent e2e (13), `bun run build`,
and the produced single-file binary booted ALONE from a clean dir (no
node_modules) serving /health + the ThinkRail SPA + hashed JS assets, staging
the UI to the cache dir, exiting cleanly on SIGTERM.
|