Repository navigation
Share one Context across commands, CLIs and runtimes - #1635
Merged
Merged
Conversation
Contributor
[High impact] The PR appears safe to merge; the earlier concerns are addressed and no new actionable issues remain.
|
Commands, CLI leaves and runtime executions each carried the same facts under their own type: CommandOpts (plus ExecContext from the workspace to the mount), CLIInvocation with its CLIView, and RuntimeContext. They are now one Context, read as `ctx`, on both hosts: - A command handler is fn(accessor, paths, texts, ctx) and a CLI leaf fn(config, paths, texts, ctx). The account config takes the place the accessor has for a command; commands keep their accessor and mount plumbing (index, io, mount_prefix) for now. - ctx carries files (vfs), the live session (session, was session_view), processes, cwd, env, stdin, argv, flags, spec and shell; the command's own facts stay beside them. - RuntimeContext holds the same Context instead of copies of vfs, session_view, cwd, env and processes. - ExecContext folds into Context; run_command takes the caller's limit override as its own argument. TypeScript's command cwd is a PathSpec, as Python's and the CLIs' already were. - Context.runtime is typed by the RuntimeIdentity protocol, so the shared type imports no runtime class and the runtime binding can hold it without an import cycle. - A CLI's shell is the one commands get, shell(line, stdin=None). - opts, inv and view are renamed ctx; the parity tests that pinned ExecContext and CLIView against CommandOpts are gone with those types. No behavior change. Docs, examples, integ fixtures and CLAUDE.md follow the new shape. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The cli_ref battery loads the tally CLI from .mjs and .js too, whose leaves still read the old invocation; they take (config, paths, texts) now, as the .ts and .py twins do. The browser suite's pause leaf reads ctx.env. The eslint flag-bag selectors matched `opts.flags` and `inv.flags`, names no handler uses any more, so they match `ctx.flags`; the probe test follows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bytecii
force-pushed
the
claude/unify-context
branch
from
October 17, 2026 00:53
6219386 to
8016528
Compare
The TypeScript relay still spread the session view as sessionView, a key Context no longer has, so a cross-mount ls -l printed - for owner and group in a named-profile session. Both hosts now pin the profile columns for a listing that spans mounts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Commands, CLI leaves and runtime executions each received the same facts (the session's files, the live session, processes, cwd, env, stdin, argv, flags) under a type of their own:
CommandOpts(plusExecContextfrom the workspace to the mount),CLIInvocationwith itsCLIView, andRuntimeContext. This PR makes them oneContext, read asctx, on both hosts.A cleanup step toward MIRAGE-21 (S15). Commands keep their accessor and mount plumbing (
index,io,mount_prefix) for now; no behavior changes.What changed
Context(commands/config.py,commands/config.ts) replacesCommandOpts,ExecContext,CLIInvocationandCLIView. Shared fields:vfs,session(wassession_view),processes,cwd,env,stdin,argv,flags,spec,shell. The command's own fields stay beside them.(config, paths, texts, ctx): the account config sits where a command has its accessor. Helpers that took an invocation now take only what they read.RuntimeContextholds actx: Contextinstead of its own copies ofvfs,session_view,cwd,envandprocesses.Mount.run_command(..., ctx, limit_override): the workspace's context is extended with the mount's facts (replace/spread) instead of being copied field by field, and the limit override is its own argument.Context.runtimeis typed by theRuntimeIdentityprotocol, so the shared type imports no runtime class andRuntimeContextcan hold it without an import cycle (both hosts, type-only cycles stay at 0).cwdis aPathSpec, as Python's and the CLIs' already were (ROOT_CWDis aPathSpecon both hosts now).ctx.shellis the commands'shell(line, stdin=None).opts,invandvieware renamedctxthroughout. NoTYPE_CHECKINGguards are added.ExecContextandCLIViewagainstCommandOptsare removed (one type now). The TypeScript test fixturecliInvocationiscontext().cli/custom.mdx,cli/index.mdx,vfs/new.mdx, both languages), examples, integ fixtures andCLAUDE.mdfollow the new shape. The public barrels exportContextin place ofCLIInvocation/CLIView.Notes for review
(inv)signature became four parameters, and TypeScript's formatter puts each on its own line (CLI directories are about +840 lines in TypeScript, +250 in Python, where the four fit on one line). Command modules are line-neutral.CLIViewobject; they are now keyed by theargvarrayverbgives each call, which a derived context ({ ...ctx, flags }, asstash showbuilds fordiff) keeps. Python uses ContextVars and needed no change.Verification
tscclean in every package; vitest core 22,756 passed / 0 failed, node 3,963, browser 310, server 501, dsh 260, agents 197, cli 127, opencode 2.pre-commit run --all-fileswith CI's skips.integpackage typecheck (its Prisma clients are not generated in this checkout).🤖 Generated with Claude Code