prism

module
v0.5.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: MIT

README

Prism

Graph-ranked code context for AI coding agents.

Prism turns a task plus a few precise anchors into the code, callers, callees, tests, docs, and coverage gaps an agent needs to make a change safely.

Prism is not a better grep. Use rg/grep to find the first anchor. Use Prism to answer the follow-up questions that usually cost several file reads:

  • What calls this?
  • What does this call?
  • Which tests define the contract?
  • What else is in the blast radius?
  • Which nearby exported functions have no direct test coverage?

The recommended agent path is now CLI text mode:

prism query "fix direct coverage gaps" --terms buildCoverageGaps --include graph,tests,coverage_gaps --format text
prism read internal/cli/commands.go --format text
prism lookup github.com/provasign/prism/internal/cli.invokeWithPersistentLedger --format text

--format text gives agents plain source-like context with short headers. Use lean or json only when automation needs structured output.

Grove is embedded in the Prism binary. There is no separate daemon, token, or grove_url setup in current releases.


Why Prism

Shell search gives pointers. Agents still have to chase those pointers by reading files, guessing test names, and manually reconstructing call paths.

Prism precomputes the project graph and lets the agent ask for relationships:

rg buildCoverageGaps internal/
  -> prism query "write tests for buildCoverageGaps" \
       --terms buildCoverageGaps \
       --include graph,tests,coverage_gaps \
       --format text

On this repository, five real maintenance scenarios were run both ways on 2026-06-07. Shell-only baselines used rg plus targeted sed reads; Prism used one CLI text command per scenario.

Scenario Shell bytes Prism CLI bytes Context reduction
Init / CLI steering impact 19,970 12,818 35.8%
coverage_gaps precision 21,226 17,145 19.2%
CLI text/lean/json output formatting 15,820 14,198 10.3%
Session cache / savings ledger 33,134 19,922 39.9%
Release/version/install wiring 21,246 12,157 42.8%

The average reduction was 29.6% with one Prism command instead of 5-6 shell commands. The bigger correctness win is that Prism surfaces tests and coverage gaps proactively; shell-only workflows often discover those after CI fails.

Details: Real-World Prism CLI Benchmark.


How It Works

Task + anchor terms
      |
      v
Embedded Grove index
  - symbols
  - call edges
  - dependency edges
  - test edges
      |
      v
Prism ranking
  - graph distance
  - semantic similarity
  - recency
  - test relevance
  - edit frequency / learned weights
      |
      v
Budgeted text context
  - target symbols
  - callers/callees
  - tests
  - docs
  - coverage_gaps

Prism saves context by replacing repeated manual graph chasing with one graph-aware query. The CLI also persists its ledger and file-read cache between commands, so repeated unchanged file reads can return a short SHA pointer.


Installation

# macOS / Linux
curl -fsSL https://raw.githubusercontent.com/provasign/prism/main/install.sh | bash

# Windows PowerShell
irm https://raw.githubusercontent.com/provasign/prism/main/install.ps1 | iex

# Pin a version
VERSION=v0.5.6 curl -fsSL https://raw.githubusercontent.com/provasign/prism/main/install.sh | bash

The installer writes prism to ~/bin by default. Set INSTALL_DIR=/usr/local/bin or another directory to override.

Build from source:

make build
make test
make install

Quick Start

Run this once at the project root:

prism init .
prism index .

This writes:

  • steering files such as AGENTS.md, CLAUDE.md, .cursorrules, .windsurfrules, .github/copilot-instructions.md, and others
  • prism.yaml with the project profile and optional model settings

The generated agent instructions tell agents to use commands like:

prism query "trace the payment refund flow" --terms RefundPayment --include graph,tests --format text
prism query "find direct coverage gaps" --terms UpdatePayment,RequireScope --include graph,coverage_gaps --format text
prism read internal/payment/service.go --format text
prism lookup github.com/example/payflow/internal/payment.(*Service).RefundPayment --format text

Recommended agent workflow:

  1. Locate the first anchor with rg, grep, or find.
  2. Run prism query with the same anchor terms.
  3. Use prism read for whole files only when needed.
  4. Use prism lookup for one known function or method.
  5. Treat coverage_gaps as a terminal structured output, not the start of manual cross-referencing.

CLI Reference

prism init [dir]
prism index [dir]
prism status [dir]

prism query <task> [dir] \
  --terms a,b,c \
  --include graph,tests,docs,coverage_gaps \
  --depth 2 \
  --format text

prism read <file> [dir] --format text
prism lookup <name> [dir] --format text
prism search <keyword> [dir] --format text
prism savings [dir]
prism compact [dir]
prism feedback --tool <name> --rating <0-5> [dir]
prism version

Output formats:

Format Use
text Default and recommended for agents
lean Compact JSON without most metadata
json Full metadata for tooling/debugging

Configuration

prism.yaml is intentionally small:

version: 1
profile: "default"

Optional keys:

model: "claude-sonnet-4-6"
grove_binary: "grove"
embeddings_backend: "tfidf"

Environment overrides include PRISM_MODEL, PRISM_PROFILE, PRISM_GROVE_BINARY, and PRISM_EMBEDDINGS_BACKEND.


Language Support

Prism delegates parsing and graph construction to embedded Grove.

Language Extensions
Go .go
TypeScript / TSX .ts, .tsx
JavaScript / JSX .js, .jsx, .mjs, .cjs
Python .py
Java .java
Rust .rs
C / C++ .c, .h, .cc, .cpp, .hpp, ...
C# .cs
PHP .php, .phtml, ...

Markdown, YAML, JSON, shell scripts, Dockerfiles, Makefiles, SQL, GraphQL, and other non-code files are indexed as document symbols and can be requested with --include docs.


Benchmarks

Read benchmark numbers by transport:

Current practical summary:

  • CLI --format text is the recommended default for shell-capable agents.
  • Prism is strongest on graph/blast-radius/test/coverage-gap questions.
  • Shell tools remain best for locating exact strings or filenames.

Troubleshooting

prism query returns nothing: run prism index . from the project root.

Agent still uses stale instructions: run prism init . and restart or reload the coding agent so it reads the updated steering files.

Wrong Prism binary: run command -v prism and prism version. Reinstall if the version is old.

macOS quarantine:

xattr -d com.apple.quarantine "$(which prism)"
codesign -f -s - "$(which prism)"

Directories

Path Synopsis
cmd
prism command
internal
cli
Package cli implements the Prism command tree (flat dispatch, no cobra dependency — keeps Prism a true single binary with zero runtime deps).
Package cli implements the Prism command tree (flat dispatch, no cobra dependency — keeps Prism a true single binary with zero runtime deps).
compression
Package compression implements the file-read compression pipeline that produces a token-optimized rendering of a file given Grove's symbols and the current session state.
Package compression implements the file-read compression pipeline that produces a token-optimized rendering of a file given Grove's symbols and the current session state.
config
Package config loads Prism configuration from prism.yaml and environment.
Package config loads Prism configuration from prism.yaml and environment.
embeddings
Package embeddings provides Prism's semantic similarity backends.
Package embeddings provides Prism's semantic similarity backends.
grove
Package grove is Prism's adapter to the in-process Grove engine.
Package grove is Prism's adapter to the in-process Grove engine.
ranking
Package ranking implements Prism's 5-signal composite scoring and the budget-aware greedy selector that decides which symbols to deliver and at what fidelity.
Package ranking implements Prism's 5-signal composite scoring and the budget-aware greedy selector that decides which symbols to deliver and at what fidelity.
session
Package session implements Prism's per-session state: an O(1) LRU file tracker (for delivery deduplication) and a token ledger (for savings reporting).
Package session implements Prism's per-session state: an O(1) LRU file tracker (for delivery deduplication) and a token ledger (for savings reporting).
version
Package version exposes the prism build version.
Package version exposes the prism build version.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL