Skip to content

Context 0.7.107: update knowledge without cloning through Sourcegraph - #120

Merged
qiansc merged 4 commits into
mainfrom
feat/0.7.107-remote-sources
Nov 29, 2026
Merged

qiansc merged 4 commits into
mainfrom
feat/0.7.107-remote-sources

Conversation

@qiansc

@qiansc qiansc commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Background

Updating knowledge needs a local checkout of every repository source. When the repositories are already registered on a Sourcegraph instance, Context can read the pinned commits remotely instead.

Changes

  • Repository reader with two implementations: local Git (unchanged) and Sourcegraph HTTP (raw blob/blobs reads verified by Git blob id, names-only diff, scope availability, directories).
  • CONTEXT_SOURCE_MODE / --source-mode: local (default, unchanged, no network), remote (skip repositories that cannot be read remotely and report them), auto (remote first, falls back to the local checkout per repository).
  • Authorization: the Agent calls the Sourcegraph MCP tool authorize_cli; context source sourcegraph-auth --code --host exchanges the single-use code for a temporary read-only token kept in the workspace (never printed); one authorization per workspace session; SOURCEGRAPH_URL / SOURCEGRAPH_API_TOKEN take precedence.
  • Path coverage and code-host checks; error mapping that keeps local parity (missing file, not a file, not text) and treats every other remote failure as an unread source.
  • update, revision and verify read through the new reader; update --pending can prepare a commit's contents and wait for it; status/verify report source_access and a single top-level source_authorization.
  • Guides, Skills and procedures; CHANGELOG; version 0.7.107.

Risks

Remote mode depends on the Sourcegraph site exposing the remote-read operations; sites without them are treated as unavailable. Local mode is unchanged.

Compatibility

Default local keeps 0.7.106 behaviour and network access. New output fields are additive.

Testing

Build, typecheck and lint pass; new tests (remote source access, remote update integration) and existing tests of touched modules pass per file. A comparison on a real knowledge workspace produced byte-identical update inputs and evidence in local and remote modes, apart from repositories that are not registered remotely.

🤖 Generated with Claude Code

qiansc and others added 4 commits November 29, 2026 13:39
Updates, revisions, submission checks, verify and status can read a
registered repository from a Sourcegraph site instead of a local checkout.

- CONTEXT_SOURCE_MODE / --source-mode: local (default, no network),
  remote (repositories Sourcegraph cannot serve are skipped and keep their
  processed version) or auto (Sourcegraph first, checkout fallback).
- Raw blobs at the registered commit, batched (100 paths, budget overflow
  reread later, FILE_TOO_LARGE not retried) and checked against their Git
  object id; names-only diffs and directory lists mapped to the subpath,
  split by subdirectory when too large. Results equal the local checkout:
  FILE_NOT_FOUND and NOT_A_FILE map to the local missing-file and file-type
  reasons, every other failure is a read failure, never a citation change.
- A repository is read remotely only when the site declares the remote-read
  operations, the code host and name match the registered remote, one path
  group contains the whole subpath, and the registered commit is readable.
  update --pending prepares an unreadable commit's content and waits a
  bounded time; refusals and limits are reported, not retried.
- context source sourcegraph-auth exchanges a one-time code from the MCP
  authorize_cli tool for a temporary read-only token kept in the workspace
  runtime directory (mode 600) and reused until a 401 or its hard expiry;
  SOURCEGRAPH_URL and SOURCEGRAPH_API_TOKEN take precedence. A reported
  TEMPORARY_TOKEN_LIMIT stops asking for authorization for a while.
- update, verify and status report how each repository was read
  (source_access, skipped_sources, status access fields).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Knowledge-updates guide: "Update without cloning: read repositories
  through Sourcegraph" covers the source modes, when a repository can be
  read remotely, MCP authorize_cli authorization and token reuse, version
  preparation, and reading code through MCP for remote sources.
- The context Skill passes the configured source mode, treats
  access: remote sources as needing no clone, and follows the
  authorization step; the routine update and source-update procedure
  skip checkouts for remote sources and handle skipped_sources.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Auto mode without a token asks for MCP authorization like remote mode
  instead of silently falling back to checkouts; it falls back only after
  a refused authorization or when the site cannot serve the repository.
  The authorization step is reported once at top level
  (next_action / source_authorization in update, verify and status);
  per-source entries keep only their state and reason, and sources
  waiting for it get no checkout or recovery advice in status.
- A directory too large to list exists in that commit, so only its new
  subdirectories are marked new_directory.
- Files over the raw-frame byte budget stay in batched reads while
  batches make progress; only a batch that settles nothing falls back to
  single reads, with a round cap against a misbehaving server.
- A split diff treats only an absent directory as empty; other listing
  failures leave uncited changes unavailable.
- A later prepare-enabled access decision re-decides unless the commit is
  already readable.
- Raw reads reject trailing bytes after the frames and answers that name
  another commit; --host rejects credentials, query and fragment.
- Content preparation clears a rejected temporary token and asks for
  authorization, and stops polling when its job reports failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@qiansc
qiansc merged commit 2ceef9b into main Nov 29, 2026
2 checks passed
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.

1 participant