Skip to content

Sync fork with upstream earendil-works/pi (73 commits), preserve replaceTranscript - #6

Merged
sprootbot[bot] merged 76 commits into
mainfrom
sync-upstream-pi
Sep 26, 2026
Merged

sprootbot[bot] merged 76 commits into
mainfrom
sync-upstream-pi

Conversation

@sprootbot

@sprootbot sprootbot Bot commented Sep 26, 2026

Copy link
Copy Markdown

Summary

Merges earendil-works/pi@main (73 commits ahead, including upstream's new
"canonical session context boundaries" feature) into this fork via a real
git merge (no rebase/squash), preserving all of this fork's own commits —
most importantly pi.replaceTranscript, the extension API this fork exists
to provide.

replaceTranscript needed one internal (non-behavioral) change, no contract
change.
The signature, options (reason, source, details, deliverAs),
and delivery semantics ("steer" at end of current turn, "followUp" once
settled, "nextTurn" with the next prompt) are unchanged and still work
end-to-end, confirmed by the existing dedicated test
(packages/coding-agent/test/transcript-replacement-delivery.test.ts,
including the test that drives a real tool call and asserts the next
provider request contains only the replacement, not the discarded history).

Why no contract change was needed: upstream's new architecture makes
SessionManager.buildSessionProjection() the single authoritative source for
what the model sees on every request, replacing the old pattern of trusting
whatever context.messages a caller passed in. replaceTranscript already
persisted its effect as a session entry (appendTranscript() writing a
"transcript" boundary entry) rather than only mutating in-memory context, and
the shared boundary-scanning logic that treats "transcript" as an end-of-context
boundary (alongside "compaction") already existed at the merge base. So once
agent-session.ts's prepareNextTurnWithContext was updated (per upstream) to
always rebuild context.messages from buildSessionProjection(), it picked up
an applied transcript replacement automatically — no transcript-specific logic
needed to change.

One internal cleanup fell out of this: AgentSession's private
_takeTranscriptReplacementForNextTurn() used to manually splice the replaced
messages into the next-turn context. That splice is now redundant (the
projection rebuild does it), so the method was simplified away and the
now-write-only _transcriptReplacedDuringRun flag was deleted (caught by
biome's noUnusedPrivateClassMembers). No externally visible behavior change.

Notable merge decisions

  • packages/coding-agent/src/core/session-manager.ts: fork's TranscriptEntry
    type (backs replaceTranscript) and upstream's new ContextEditEntry type
    (backs upstream's context_edit/actionable turn-boundary events) are
    independent additions — kept both.
  • packages/coding-agent/src/core/compaction/compaction.ts: adopted upstream's
    projection-based rewrite of prepareCompaction() wholesale. It already
    handles the "transcript" boundary correctly for free, because
    buildContextEntries() treats "transcript" and "compaction" as the same
    kind of boundary and truncates the projection at whichever is most recent.
  • packages/ai/src/api/simple-options.ts: kept fork's logprobs/topLogprobs
    fields (from the logprobs-capture feature); took upstream's relocation of
    samplingParams model-default merging into each OpenAI-compatible adapter's
    buildParams() (fixes those defaults being dropped on direct
    stream()/complete() calls that bypass streamSimple()). Verified no
    other adapter (Anthropic, Google, Bedrock, Mistral) reads samplingParams,
    so nothing regresses.
  • packages/coding-agent/docs/extensions.md: upstream split this doc into
    several smaller files and rewrote the remainder in a terser style; took
    upstream's version and added a concise pi.replaceTranscript() section in
    the new "Context and session changes" section, in the same terse style,
    linking to the existing skill-state.ts example.
  • .github/workflows/publish-model-catalog.yml: kept deleted (this fork
    deliberately stopped publishing to the upstream model catalog in 571f18f;
    upstream's further edits to that workflow don't apply here).

Testing

  • packages/coding-agent/test/transcript-replacement-delivery.test.ts,
    skill-state-extension.test.ts, extensions-runner.test.ts,
    extensions-discovery.test.ts, suite/agent-session-boundaries.test.ts,
    suite/agent-session-compaction.test.ts, compaction-summary-reasoning.test.ts,
    session-context-edit.test.ts, and the session-manager/ suite all pass
    (191+ tests) after conflict resolution and after the dead-flag cleanup.
  • npm run check passes clean (biome, pinned-deps, runtime-deps, ts-imports,
    entry-graphs, shrinkwrap, install-lock, tsc, browser-smoke).
  • Full non-e2e suite run per-package (packages/coding-agent, packages/ai,
    packages/agent, packages/chord, packages/client, plus ./test.sh for
    the rest): 2465+ passed in coding-agent alone, ~5900 total across packages.
    The handful of remaining failures were individually root-caused and are all
    pre-existing environment gaps, not merge regressions — confirmed by checking
    that the affected source/config lines are byte-identical between this fork's
    pre-merge tip and upstream/main (i.e. the same failure would occur running
    either branch's tests in this sandbox):
    • Several packages (session-backends/sqlite-node, agent, client) fail
      on Cannot find package '.../dist/...' for cross-package subpath imports
      (e.g. @earendil-works/pi-ai/utils/uuid, @earendil-works/chord) that
      their vitest.config.ts doesn't alias to source — those packages need a
      prior npm run build, which wasn't run here per this repo's "never run
      npm run build unless requested" rule.
    • find tool tests fail because this sandbox's installed fd is v8.6.0,
      which predates the --no-require-git flag the tool passes.
    • One packages/ai test (anthropic-sse-parsing.test.ts) fails because the
      live models.dev/OpenRouter catalog (fetched fresh into the gitignored
      packages/ai/src/providers/data/*.json) no longer lists
      anthropic/claude-3-haiku on OpenRouter — the same live-catalog-drift
      class of issue this fork's own logprobs commit (d478246) already
      documented as pre-existing and reproducible with zero diff.
    • One packages/chord fuzz test (state-fuzz.test.ts) timed out at the
      default 5000ms running 100 randomized seeds; looks like sandbox CPU
      headroom, not a correctness issue.

🤖 Generated with Claude Code

badlogic and others added 30 commits September 21, 2026 16:59
Make SessionManager projections authoritative for provider requests, add append-only context edits and actionable turn boundaries, and preserve existing queue scheduling during continuation and recovery.
…earendil-works#9846)

Since 0.86 the prompt and tool declarations live in transcript system
messages, so a context handler that filters or slices messages could drop
them. After extension-driven compaction this sent requests without built-in
tools and made Codex emit raw tool-call text.

context handlers now see the conversation only. An unchanged list keeps the
transcript as is; a changed list gets the replayed prompt sections and tool
declarations as one leading system message. Handler-added system messages
are kept after it.

Add context_with_system, which runs after every context handler on the full
transcript and sends its result verbatim, for extensions that need to edit
system messages per request. Dropping the leading system message is reported
as an extension error.

closes earendil-works#9789, closes earendil-works#9822
earendil-works#9842)

- center the label independently of scrollbar visibility
- clip drawing and click bounds before the scrollbar
- fixes earendil-works#9136
Prevent OpenAI-compatible providers from rejecting image-only prompts.

Fixes earendil-works#9797
Replace persisted inputs with strict input and passive-write submissions. Add atomic document bases, deltas, historical reads, reincarnation, reclamation, and indexed memory queries.
* docs(coding-agent): improve getting started documentation

* docs(coding-agent): correct getting started details

* docs(coding-agent): clarify SDK entry point

* docs(coding-agent): restructure guides and references

* docs(coding-agent): improve getting started guides

* docs(coding-agent): refresh integration guides

* docs(coding-agent): improve terminal and CLI guides

* docs(coding-agent): refresh customisation guides

* docs(coding-agent): clarify project trust terminology

* docs(coding-agent): simplify customisation guidance

* docs(coding-agent): improve runtime and reference guidance

* Fix settings reference

* feat(coding-agent): add Crowdin documentation sync

* docs(coding-agent): separate CLI and slash command references

* docs(coding-agent): correct compaction reference

* docs(coding-agent): streamline package documentation

* docs(coding-agent): split RPC reference documentation

* Update configuration docs

* Shorten config docs

* docs(coding-agent): refine configuration references

* docs(coding-agent): streamline settings reference

* docs(coding-agent): clarify configuration reference

* docs(coding-agent): clarify project trust exception

* docs(coding-agent): simplify keybindings reference

* docs(coding-agent): remove Crowdin integration

* docs(coding-agent): turn themes reference into guide

* docs(coding-agent): consolidate model and authentication docs

* docs(tui): require Component.invalidate() (fixes earendil-works#9358)

* docs(coding-agent): document offline catalog behavior (fixes earendil-works#8684)

* docs(coding-agent): preserve established documentation routes

* docs(coding-agent): reorganize documentation navigation

* docs(coding-agent): correct audited behavior

Clarify provider, session, local-model, Termux, TUI, SDK, debug, and extension behavior. Simplify the documentation audit to report only clear user-visible contradictions.

* docs(coding-agent): fix broken documentation links
…works#9908)

Separate conversation content from instructions and replace prefix/suffix wording with continuation-oriented summarization guidance.

Hopefully this avoids the refusals.

Fixes earendil-works#9652
Add the portable SQLite storage core, Node adapter, versioned migrations, conformance coverage, and storage benchmarks.
mitsuhiko and others added 28 commits September 24, 2026 14:42
…works#8398)

Expose theme colors as values and add theme.style() for combined styling.

- @earendil-works/pi-tui gains a Color type (palette index, sRGB, OKLCH) with parseColor(), mixColors(), colorToHex(), colorToRgb(), styleText() and related helpers.
- Theme JSON accepts #rgb and oklch(...) values and an optional appearance ("dark" or "light"), detected from the theme colors when omitted.
- theme.style() combines tokens or concrete colors with text attributes; theme.colors exposes concrete colors, including the terminal's reported default colors (OSC 10/11) for tokens set to "".
- Terminals with TERM=*-direct are detected as truecolor.
Replace the alternate tracker implementations with the optimized immutable overlay, validate draft placements as strict JSON, and document the ownership contract. Consolidate tracker tests and benchmarks around the canonical implementation.
Add typed document definitions, atomic Session transactions, complete commit publication, task/document lifecycle handling, and paginated Tx scans. Share Chord's strict JSON copier across draft placements and durable ownership boundaries.
… extensions

Temporary git extensions (-e git:...@ref) were cached in a folder keyed
only by host and repo path. After changing the pinned ref, pi reused the
old checkout without refreshing it and kept loading the first downloaded
commit. Include the ref in the temporary folder hash so each ref gets
its own checkout. Unpinned sources keep their existing folder.

closes earendil-works#9982
… offset/limit

Strict tool schemas make models send null for omitted optional fields.
The read renderer only treated undefined as missing, so full-file reads
rendered as "path:1".

fixes earendil-works#9996
Replace the tsgo native preview with typescript@7.0.2 and port the check scripts to the TS 7 API. Target ES2024, drop useDefineForClassFields: false and unused decorator options, and enable verbatimModuleSyntax. Replace tsx with node plus the source resolver hook, passed to --import as a file URL.

closes earendil-works#9965
Closing the last overlay hid the terminal cursor. If an extension closed
an overlay during session shutdown, this ran after stop() had restored
the cursor, leaving the shell with an invisible cursor.

closes earendil-works#10026
Successful RPC prompt, steer, and follow_up responses include
data.disposition ("handled", "queued", or "started" for prompt), so clients
know whether to wait for agent_settled.

fixes earendil-works#9098
Model-level samplingParams were only merged by streamSimple(). Direct
stream()/complete() calls, such as extensions using
modelRegistry.complete(), dropped them. The OpenAI-compatible adapters
now merge model defaults with request keys, and request keys take
precedence.

closes earendil-works#9506
GLM models on Mistral send empty content deltas at the start of a
response, alongside tool call fragments, and sometimes mid-thinking.
Each one opened an empty text block, and a mid-thinking one split
thinking into two blocks, which Mistral rejects on replay with
"Expected at most one leading ThinkChunk".

closes earendil-works#9674
A new session was only written to disk once the first assistant message
existed. If pi exited during the first turn (Ctrl+C twice while streaming,
or the process was killed), the user's prompt was lost and the session
never appeared in /resume.

The file is now created as soon as the session has a user or assistant
message. A session with only setup entries (model, thinking level) still
stays in memory, so starting pi and quitting without chatting leaves no
file. Forking uses the same rule through a shared helper, so the two paths
cannot drift apart and write the header twice (earendil-works#1672).

closes earendil-works#10000
* fix(ai): upgrade openai SDK to 7.19.0

Adds the "fast" service tier to the SDK types, needed to price
GPT-6 Fast mode requests correctly. Drops the local
prompt_cache_options type, which the SDK now defines.

* fix(coding-agent): check Cloudflare compat request via fetch instead of SDK mock

pi-ai now resolves its own nested openai 7.x while evals keeps 6.x at the
root, so vi.mock("openai") in coding-agent no longer reached pi-ai's client.
Capture the outgoing request with a fake fetch and assert the URL and headers.

* fix(ai): drop any casts for stream_options and max_tokens in openai-completions

stream_options is typed by the SDK, so assign it directly. max_tokens is
deprecated by OpenAI but still needed for OpenAI-compatible providers
that reject max_completion_tokens; use a narrow cast instead of any to
avoid the deprecation warning.
GPT-6 models return service_tier "fast" for Fast mode requests (the new
name for priority processing), which fell through to the 1x default.

closes earendil-works#10034
# Conflicts:
#	.github/workflows/publish-model-catalog.yml
#	packages/ai/src/api/simple-options.ts
#	packages/coding-agent/docs/extensions.md
#	packages/coding-agent/src/core/agent-session.ts
#	packages/coding-agent/src/core/compaction/compaction.ts
#	packages/coding-agent/src/core/session-manager.ts
The canonical session projection introduced upstream already reflects
any replaceTranscript() boundary by the time prepareNextTurnWithContext
rebuilds context.messages, so _transcriptReplacedDuringRun became
write-only dead state during the upstream sync merge. biome's
noUnusedPrivateClassMembers caught it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…enRouter

anthropic/claude-3-haiku has been delisted from OpenRouter's catalog, so it
no longer type-checks against the freshly generated model-literal union,
failing tsc in CI. Swap to anthropic/claude-haiku-4.5, currently listed with
the same anthropic-messages api/provider shape the test needs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@sprootbot
sprootbot Bot merged commit dcc013b into main Sep 26, 2026
1 check passed
@sprootbot
sprootbot Bot deleted the sync-upstream-pi branch September 26, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants