project

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package project discovers and generates project context for AI-powered code reviews.

It uses a layered approach:

  1. Discover explicit documentation (README, /docs, AI agent config files, ARCHITECTURE.md, etc.)
  2. Read manifest files (go.mod, package.json, Cargo.toml, etc.) for tech stack info
  3. Capture directory structure (top-level + 1-2 levels) for architecture hints
  4. If docs are thin, use a cheap LLM to infer project purpose/domain from the gathered signals

The result is a compact project briefing injected into batch review prompts so each batch doesn't waste tokens re-discovering what the project is about.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	// Summary is the final project briefing, ready for injection into prompts.
	Summary string

	// InputHash is a SHA-256 hash of all inputs used to generate the summary.
	// Used for cache invalidation.
	InputHash string

	// FromCache indicates whether this result was loaded from cache.
	FromCache bool
}

Context holds the discovered project context.

func Discover

func Discover(ctx context.Context, repoRoot string, client ai.Client, cachedHash string, onProgress func(string)) (*Context, error)

Discover gathers project context from a repository root. If an LLM client is provided and documentation is thin, it uses the LLM to infer project purpose. The client can be nil to skip LLM inference. If cachedHash is non-empty and matches the current inputs, Discover returns early with FromCache=true and an empty Summary (caller should use cached version).

type RuntimeModelResult added in v1.6.0

type RuntimeModelResult struct {
	// Model is the parsed structured shape of the codebase. Nil when
	// loaded from cache (caller already holds the cached value) or
	// when no inputs were available.
	Model *state.RuntimeModel

	// InputHash is a SHA-256 hash of the inputs used to generate the
	// model. Used for cache invalidation by callers.
	InputHash string

	// FromCache indicates the cached hash matched current inputs;
	// Model is nil in that case and the caller should use the cached
	// value it already holds.
	FromCache bool
}

RuntimeModelResult holds the output of a runtime model discovery pass.

func DiscoverRuntimeModel added in v1.6.0

func DiscoverRuntimeModel(
	ctx context.Context,
	client ai.Client,
	repoRoot string,
	projectSummary string,
	cachedHash string,
	onProgress func(string),
) (*RuntimeModelResult, error)

DiscoverRuntimeModel produces a structured runtime model for the codebase. It re-uses the same input set (docs, AI configs, manifests, dir tree) as project context discovery so the cache invalidation rules match: edit a doc or move a directory and both invalidate together. The project summary is folded into the prompt input so the runtime model can ground its claims in the briefing's architecture section.

If cachedHash matches the current inputs, returns Model=nil with FromCache=true so the caller can reuse the already-cached value without paying for the LLM call. Same contract as Discover.

On LLM or parse failure returns a non-nil error and the caller should treat the result as advisory — the runtime model is a quality enhancement, not a blocking input.

Jump to

Keyboard shortcuts

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