Skip to main content

Deterministic codebase context for AI coding agents

Project description

sourcecode

Deterministic codebase context for AI coding agents.

Version Status Python


What is it?

sourcecode analyzes a repository and produces a structured context map (JSON or YAML) designed to be consumed by AI agents or language models. It solves the "stuff the whole repo into the prompt" problem by instead producing a deterministic extract: entry points, dependencies, stacks, inline annotations, environment variables, and git activity. It is an MVP tool under active evolution — the semantic analysis and module graph features work but have known limitations that are explicitly documented below.


Installation

Prerequisites: Python 3.10+

pip install sourcecode
# or with pipx for isolation:
pipx install sourcecode

Verify installation:

sourcecode version
# sourcecode 1.0.0

Quickstart

The primary command — a high-signal, low-noise summary for Java/Spring codebases:

sourcecode --compact
# ~600-800 tokens: stack, entry points, dependencies, risk flags, confidence.

sourcecode --compact --git-context
# Adds git hotspots and uncommitted file count.

sourcecode --compact --copy
# Copies the result to clipboard.

Example output for a Spring Boot project:

{
  "project_type": "api",
  "stacks": [{ "stack": "java", "frameworks": ["Spring Boot", "MyBatis"] }],
  "entry_points": {
    "bootstrap": ["src/main/java/io/spring/RealWorldApplication.java"],
    "security": ["src/main/java/io/spring/api/security/WebSecurityConfig.java"],
    "controllers": { "count": 8, "sample": [...] }
  },
  "key_dependencies": [
    { "name": "org.mybatis.spring.boot:mybatis-spring-boot-starter",
      "version": "2.2.2", "risk_flags": ["spring-boot-2.x-eol"] }
  ],
  "language_version": "11",
  "deployment": { "spring_boot_version": "2.6.3" },
  "mybatis": { "mapper_interfaces": 4, "xml_files": 4 },
  "confidence_summary": { "overall": "high" }
}

For full structured output with per-file contracts and signals, use --agent:

sourcecode --agent

Flags reference

Global options

Flag Alias Type Default Description
--compact flag off Recommended. ~600-800 token summary: stack, entry points, deps, risk flags, confidence.
--git-context -g flag off Adds git hotspots (top changed files), branch, uncommitted file count. Use with --compact.
--agent flag off Full structured JSON for AI agents. Auto-enables dependency, env-var, and code-notes analysis.
--changed-only flag off Limit output to git-modified files (staged, unstaged, untracked).
--depth INT [1–20] 4 File tree traversal depth. Java projects auto-adjust to 12.
--format -f json|yaml json Output format. JSON preferred in pipelines.
--output -o PATH stdout Write output to a file instead of stdout.
--copy -c flag off Copy output to clipboard after a successful run.
--no-redact flag off Disable automatic secret redaction. Output may contain sensitive values.
--version -v flag Show version and exit.

Subcommands

prepare-context TASK [PATH]

Generates task-specific context for AI agents.

Task Description Status
explain Architecture, entry points, key dependencies ✅ CORE
fix-bug Files prioritized by risk, inline annotations ✅ CORE
onboard Full context for new agents or developers ✅ CORE
delta Incremental context: only files changed in git ✅ CORE
refactor Structural problems, improvement opportunities 🧪 EXP
generate-tests Files without tests, coverage gap analysis 🧪 EXP
review-pr Changed files + architectural impact 🧪 EXP

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sourcecode-1.12.0.tar.gz (352.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sourcecode-1.12.0-py3-none-any.whl (264.7 kB view details)

Uploaded Python 3

File details

Details for the file sourcecode-1.12.0.tar.gz.

File metadata

  • Download URL: sourcecode-1.12.0.tar.gz
  • Upload date:
  • Size: 352.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for sourcecode-1.12.0.tar.gz
Algorithm Hash digest
SHA256 b184bdc7bdbb05cd294ea449cbd99bc7bc530358e2b34bb04599aba5d3bcfe66
MD5 0c42ba585b7a1c0f8c32c66c83a9ef93
BLAKE2b-256 7a8252af5161cc541f3df8c430e1345fdb738b9b5cd02d4ada80fd1ffbdb1891

See more details on using hashes here.

File details

Details for the file sourcecode-1.12.0-py3-none-any.whl.

File metadata

  • Download URL: sourcecode-1.12.0-py3-none-any.whl
  • Upload date:
  • Size: 264.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for sourcecode-1.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1384049f16fe9da65b4302aea9854ecb4e7a0f62d1d97ad158da8ac52cc59f0e
MD5 214ba45b738ded1c87859bfd9febe17b
BLAKE2b-256 86af1579f3baf90bbff12285982e3d7c5a10b4b006b362759c7e06148fd3c7e6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page