Skip to content

feat: ChatGPT Plan provider for inline completion and chat - #1

Draft
CoderLambert wants to merge 61 commits into
mainfrom
feat/chatgpt-plan-completion
Draft

CoderLambert wants to merge 61 commits into
mainfrom
feat/chatgpt-plan-completion

Conversation

@CoderLambert

@CoderLambert CoderLambert commented Oct 7, 2026 •

Copy link
Copy Markdown
Owner

Goal

Add a dedicated ChatGPT Plan provider using OpenAI's official Sign in with ChatGPT flow and public Responses API. It supports inline completion and Twinny Chat with account models, without an API key.

Baseline

  • upstream/fork baseline: c8c1979c2a5371b2cb9bc2cc30914b06e628d567
  • branch: feat/chatgpt-plan-completion

Implementation

  • Provider identity and Chat/FIM validation policy; embeddings remain unsupported
  • Provider-neutral structured FIM context
  • Secret Shield coverage for structured FIM and Chat context
  • ChatGPT Plan Responses adapter + dynamic model discovery
  • Twinny Chat support with multi-turn Responses input and text-mode tools
  • Official OAuth/OIDC session manager with PKCE, state, nonce and loopback callback
  • SecretStorage, refresh rotation and concurrent refresh single-flight
  • Auth bridge events and provider UI
  • Usage-limit and authentication error classification
  • Terminal SSE success enforcement and HTTP cancellation
  • Cross-view sign-out cancellation for Chat, suggestions, model listing and provider probes
  • Legacy Twinny gateway compatibility; Extension Host-only providers are rejected by headless gateway configuration
  • Configurable reasoning effort for ChatGPT Plan

Automated validation

  • npm ci
  • npm run lint
  • npm run build-tests
  • npm run build
  • npm test — 821 passing, 4 live-test pending, 0 failing
  • npm run test:sqlite — 109/109 passing
  • npm run vscode:package — twinny-4.3.6.vsix
  • GitHub Actions green for current HEAD — push and pull_request validation passed

Real-account validation

  • Sign in with ChatGPT and account model listing
  • gpt-6-luna selected for FIM and Chat
  • Inline completion and multiline completion
  • Chat request through account Responses route — exact 20-character response in 2.1s
  • Restart persistence
  • Unsupported service_tier: fast removed after real route returned Unsupported service_tier: fast
  • Complete remaining manual inline-completion matrix before changing Draft to Ready

Review

  • Security audit — PASS; all findings fixed
  • Architecture audit — PASS; all findings fixed
  • Regression audit — PASS; all findings fixed

Architecture

  • FIM: CompletionProvider -> FimRequest -> InferenceClient -> ChatGPTPlanInferenceProvider -> /v1/responses
  • Chat: Chat -> ChatRequest -> InferenceClient -> ChatGPTPlanInferenceProvider -> /v1/responses

No Codex credential reuse, ChatGPT cookies, private backend APIs, or API-key fallback.

Draft until the remaining real-account inline-completion scenarios and current-head CI pass.

@CoderLambert CoderLambert changed the title feat: ChatGPT Plan provider for inline code completion feat: ChatGPT Plan provider for inline completion and chat Oct 7, 2026
m1ab0t and others added 28 commits October 8, 2026 08:57
…expired token (twinnydotdev#538)

* Forge plugins: tokens saved once and shared by repositories, one replace for an expired token

Repositories read with a saved token (by id) instead of a copy each.
Inline tokens in repos.json are folded into saved tokens on load,
deduped by value; repo ids are unchanged. Tokens panel: save, label,
replace (checked with the host, then every repository on it syncs),
remove when unused, and pick repositories a token reads. 401s mark the
token and its repositories as refused.

* 4.3.7: forge plugin tokens saved once and shared; one replace for an expired token
… of copying it mid-write (twinnydotdev#542)

The Backups plugin and `backup now` read recordings.sqlite, -wal and -shm
one after another while the gateway keeps appending. In WAL mode every
row since the last checkpoint lives in -wal, so the main file alone can
be an empty shell (a fresh database under ~4 MB of recordings backed up
as "no such table"), and the three files read at different instants are
a torn set SQLite itself says not to copy.

A `.sqlite` file now goes into the archive as one consistent single-file
database made with `VACUUM INTO` next to the original (same private
directory, removed after reading); -wal and -shm are left out. Without
node:sqlite the file is read as before. A restore also removes a stale
-wal/-shm beside the database it writes, since a gateway that was killed
rather than stopped leaves frames SQLite would replay over the snapshot.

Standalone test under `npm run test:sqlite`; docs say what the archive holds.
…servers, team agent rules

Agent mode applies edits straight away, so this makes that safe to live
with, gives the model the context it was missing, lets a team's admin
say what it may do, and fixes what an audit of the agent code found.

A reply that changed files ends with the list of them; each opens
beside what it was before the reply, and undo / undo all put files back
through a workspace edit, so the editor's Undo brings the change back.
Edits, new files, deletes, moves and renames are covered, and inside a
git repository so are files a command changed: the tree is read before
and after each command through a copy of the index. Copies are kept for
the last 50 replies in workspace storage; a file changed since asks.

An applied edit comes back with the new errors the editor reports in
that file (in a file not open before, only errors on the changed lines).
The root AGENTS.md (or CLAUDE.md, .github/copilot-instructions.md) goes
into agent mode's instructions and a folder's own AGENTS.md comes with
the first tool result under it; the footer names the files followed.

A gear beside the agent switch sets changes apply/review, commands
ask/run/off, background or terminal, steps per reply (new
twinny.chatToolsMaxSteps) and forgets always-run commands. MCP servers
in twinny.chatToolsMcpServers (stdio, hand-rolled JSON-RPC, no new
dependency) add their tools, each call asked first unless Always run
was chosen for that tool. Finished command steps can be copied or put
in the terminal.

policy.agent on the gateway turns agent mode off, makes commands ask or
takes them away, makes edits wait for review, turns MCP servers off and
hides paths from every tool. It is edited under Policy -> Agent mode,
shown on the consent card, re-read before an agent reply and enforced by
the extension; while it is set, the gateway refuses agent requests from
extensions that do not send X-Twinny-Agent-Rules.

Fixes from the audit, each with a regression test: the git tool read
files outside the workspace (diff with an outside path, abbreviated
--contents, --ignore-revs-file) and showed ignored-but-tracked files by
blob id, :0:path, ./ and .. paths and --relative; links are judged by
where they lead and a dangling link is not written through; protected
paths match in any case and *.code-workspace is protected; background
commands that left something running never finished; prose mentioning
<tool_call>, held-back text, stray calls on the last step and parallel
results trimmed before the model saw them; line-number stripping of
"404: x" lines and blank lines left by deletions; a reply landing in
the conversation switched to.
…ter mode

A router-mode llama-server picks the model from the request body's
"model" field and refuses a request without it. The llama.cpp FIM body
(also used by warm-up) now carries the provider's model name when one
is set; a single-model server ignores it. The /props context-window
lookup names the model too, with autoload=false so asking never loads it.

Fixes twinnydotdev#544
CoderLambert and others added 29 commits October 15, 2026 16:25
@m1ab0t
m1ab0t force-pushed the feat/chatgpt-plan-completion branch from 7d707b5 to 2a454b6 Compare October 15, 2026 15:29
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.

3 participants