Codex Project Context Loader
Codex Project Context Loader renders deterministic, bounded context for one local Git working tree. The default CLI output remains Markdown; a stable JSON interface is also available for machine callers. The tool reads repository state and a fixed set of root files without fetching, executing repository code, network access, or writes to the target repository. Runtime code uses only the Python standard library.
Open-source quick start
Context Loader 是一个“可确定性导出仓库上下文”的本地命令行工具,面向 agent/机器人场景自动生成稳定的 Markdown 或 JSON 上下文。
uv tool install codex-project-context-loader
pip install codex-project-context-loader
codex-project-context --repo /path/to/repo
codex-project-context --repo /path/to/repo --format json
Install
Current release: 0.1.5.
Install a release wheel with uv:
uv tool install /path/to/codex_project_context_loader-0.1.5-py3-none-any.whl
For development or source-based installs, install directly from GitHub as needed:
uv tool install git+https://github.com/xuanheng-tech/context-loader.git
The repository also retains ./codex-project-context as a direct development entry point.
Usage
codex-project-context --version
codex-project-context --repo /home/user/projects/example
codex-project-context --repo /home/user/projects/example --format markdown
codex-project-context --repo /home/user/projects/example --format json
codex-project-context --repo /home/user/projects/example \
--focus "JoinQuant provider notebook runtime" \
--path scripts/joinquant/provider_probe.py
--format defaults to markdown. In Markdown mode, --repo retains the 0.1.1 contract: it must be
the absolute, canonical root of a non-bare Git working tree. In JSON mode, an absolute existing
directory inside the working tree is accepted; symlinks are normalized and the discovered root is
reported as canonical_root. Relative paths, non-Git directories, regular files, and bare
repositories are rejected in both modes.
--focus and --path are optional, bounded selection signals for the root AGENTS.md. --path
must be repository-relative. The collector does not retain either input in output or audit data.
Calls that omit both options remain valid and use the conservative fallback described below.
Markdown Output
Successful repository collection uses schema context-loader/v0.1 and emits these sections in
order:
Git State, including bounded working-tree changesDevelopment InstructionsProject OverviewDeclared CommandsProject Entry FilesRecent CommitsDirectory Tree
The output has no generated timestamp, AI summary, architecture inference, or diff body.
JSON Output
--format json writes exactly one compact UTF-8 JSON document plus one trailing newline to stdout.
Keys are serialized in sorted order with ensure_ascii=False. The declared contract is:
{
"schema_version": 1,
"tool": {
"name": "context-loader",
"version": "0.1.5"
},
"repository": {
"requested_path": "/canonical/requested/path",
"canonical_root": "/canonical/worktree/root"
},
"sources": [
{
"ordinal": 0,
"kind": "agents",
"scope": "repository",
"path": "/canonical/worktree/root/AGENTS.md",
"content_sha256": "sha256-hex",
"content": "actual selected source text",
"selection": {
"source": "AGENTS.md",
"selected_sections": [],
"indexed_only_sections": [],
"chars_selected": 0,
"chars_omitted": 0,
"truncated": false,
"parse_fallback": false,
"source_scan_truncated": false,
"index_truncated": false
}
}
],
"context": "the same assembled Markdown context",
"context_sha256": "sha256-hex",
"warnings": []
}
context_sha256 hashes the UTF-8 bytes of context; each content_sha256 does the same for that
source's content. sources contains only file bodies that actually enter the final context, in
assembly order, after the existing newline normalization and truncation rules. scope distinguishes
repository from global; version 0.1.5's fixed root-file selection currently emits only
repository sources and does not add any global-file discovery.
The optional selection object is present only on a rendered AGENTS.md source. Its section entries
contain heading, heading level, and fixed selection reasons; it never contains the original focus or
target path. Existing source fields and schema version 1 remain unchanged.
The JSON schema version and package version are independent: schema_version is currently the
integer 1, while tool.version is 0.1.5. Callers must depend only on fields declared above.
The document contains no generated time or random identifier, so unchanged input produces identical
JSON bytes. On failure, stdout remains empty and stderr contains only a short diagnostic.
Supported Root Files
Only these exact files directly under the Git root are eligible:
- Development instructions:
AGENTS.md - Project overview:
README.md - Entry files, in fixed order:
pyproject.toml,justfileorJustfile,package.json,Makefile,Cargo.toml, andgo.mod
Lowercase justfile takes precedence over Justfile. Nested files, lockfiles, CI configuration,
.env, and glob-discovered files are not read.
The root AGENTS.md is split at Markdown headings outside fenced code blocks. The output always
starts with complete early sections fitting a 4-KiB head, then adds complete relevant sections in
source order using exact normalized focus/path tokens and their parent context. Remaining headings
appear in an explicit index whose body text is not loaded. With no selection signals, only the small
head and index are emitted. Unsafe heading parsing falls back to a bounded head and an explicit
manual-recovery notice.
Limits
- Final stdout: 98,304 bytes
AGENTS.md: 256-KiB bounded source scan; selected source plus selection audit remains at most 16 KiB, including a 4-KiB maximum small headREADME.md: 16 KiB- Each entry file: 8 KiB
- All entry-file bodies: 24 KiB
- Declared commands: 8 KiB
- Directory tree: 12 KiB, 300 entries, and depth 2
- Working-tree changes: 100 paths and 4 KiB
- Recent commits: 8
Truncation occurs only at complete UTF-8 and line boundaries and is marked explicitly.
Git State Semantics
Git state is derived only from the working tree and local refs. The command does not fetch or query the remote.
- An unborn working tree reports its symbolic branch name, such as
Branch: main, andHEAD: unborn. - A detached HEAD reports
Branch: detachedand the resolved commit object ID. Upstreamis the current branch's configured tracking target. Without one,Upstream: not configuredis used.- A configured target such as
origin/mainmay be shown before its commit is resolvable locally; this is normal after cloning an empty remote. Ahead / behind: not availablemeans the commit relationship cannot currently be computed. Counts are reported only when the configured upstream commit is available locally.
Exit Codes
0: context or version output completed successfully1: required Git collection or an internal operation failed2: command arguments or the repository path do not satisfy the contract
On nonzero exit, stdout is empty and a bounded diagnostic is written to stderr without a traceback or candidate-file content.
Not Included
Version 0.1.5 does not provide AI summaries, project-type detection, nested AGENTS.md handling,
Memory retrieval, semantic ranking, ignore-rule parsing, plugins, profiles, caches, databases,
network services, MCP, daemons, GUIs, CI/CD, telemetry, or automatic updates.
Development
Run the complete local check:
just check
Version maintenance
The versions in pyproject.toml and context_loader/__init__.py, the matching CHANGELOG.md
section, and required tests must change in the same release-preparation batch. CHANGELOG.md is the
authoritative version-change record, and Gitea Release notes are generated from the matching
section. Merging to master is not a release; formal publication still requires a separately
created and pushed tag.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codex_project_context_loader-0.1.5.tar.gz.
File metadata
- Download URL: codex_project_context_loader-0.1.5.tar.gz
- Upload date:
- Size: 25.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aff5b6ecd3a38e70c7f7ff20db52541120dd601cd14a575eba629b26f266b7d6
|
|
| MD5 |
b38d98f86ff9f3c7c6d8d3be1628dc33
|
|
| BLAKE2b-256 |
476df4df546af7aee185724051d377c5c8744fd44f557dd7f8b79bdb93ca1dc0
|
Provenance
The following attestation bundles were made for codex_project_context_loader-0.1.5.tar.gz:
Publisher:
publish-pypi.yml on xuanheng-tech/context-loader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_project_context_loader-0.1.5.tar.gz -
Subject digest:
aff5b6ecd3a38e70c7f7ff20db52541120dd601cd14a575eba629b26f266b7d6 - Sigstore transparency entry: 2500215559
- Sigstore integration time:
-
Permalink:
xuanheng-tech/context-loader@4d80d2ba0eb43b31cd0431a689faf11898801c8f -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/xuanheng-tech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@4d80d2ba0eb43b31cd0431a689faf11898801c8f -
Trigger Event:
push
-
Statement type:
File details
Details for the file codex_project_context_loader-0.1.5-py3-none-any.whl.
File metadata
- Download URL: codex_project_context_loader-0.1.5-py3-none-any.whl
- Upload date:
- Size: 27.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bcaa982ccb9343fcd4285bd5eb7a373065b48f94ad6102f291c074a37079d51
|
|
| MD5 |
62f65436857bdce6eee6ec6f7273b98c
|
|
| BLAKE2b-256 |
c282ba17ba2c66a345524b2f38524af427f8c67eda03259d7ff83dfb195ccc64
|
Provenance
The following attestation bundles were made for codex_project_context_loader-0.1.5-py3-none-any.whl:
Publisher:
publish-pypi.yml on xuanheng-tech/context-loader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
codex_project_context_loader-0.1.5-py3-none-any.whl -
Subject digest:
7bcaa982ccb9343fcd4285bd5eb7a373065b48f94ad6102f291c074a37079d51 - Sigstore transparency entry: 2500215584
- Sigstore integration time:
-
Permalink:
xuanheng-tech/context-loader@4d80d2ba0eb43b31cd0431a689faf11898801c8f -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/xuanheng-tech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@4d80d2ba0eb43b31cd0431a689faf11898801c8f -
Trigger Event:
push
-
Statement type: