Add pkg/prism public API (ADR-0002)#4
Merged
Conversation
Introduce the pkg/prism package as the stable public API for embedding prism as a library. Enables prism-api, editor plugins, and CI integrations to use prism without depending on internal packages. - Add pkg/prism/prism.go with Analyze, Prompt, AnalyzeOptions, Result, PRInfo, AnalysisResult, ChangedFile, and sentinel errors - Add pkg/prism tests covering validation, error categorization, buildResult conversion, and buildPRURL construction (18 tests) - Add ADR-0002 documenting the public API boundary, what is and is not exposed, compatibility guarantees, and differences from CLI JSON - Update README with Library Usage section and code examples - Update architecture.md to include pkg/prism responsibilities - Update json-schema.md noting pkg/prism.Result differs from CLI JSON - Update versioning.md covering both CLI JSON and pkg/prism API stability The CLI refactor to use pkg/prism internally is deferred to Phase 2.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduce the
pkg/prismpackage as the stable public API for embedding prism as a library. This unblocks the plannedprism-api(HTTP service on Fly.io) and enables editor plugins, CI integrations, and other library consumers.What's in
Code
pkg/prism/prism.go—Analyze,Prompt,AnalyzeOptions,Result,PRInfo,AnalysisResult,ChangedFile, sentinel errorspkg/prism/prism_test.go— validation & error categorization (7 tests)pkg/prism/internal_test.go—buildResult&buildPRURLunit tests (11 tests)Docs
docs/adr/0002-public-api-boundary.md— Accepted ADR covering rationale, what is and is not exposed, differences from CLI JSON, compatibility guarantees, and implementation planREADME.md— new Library Usage section with Analyze/Prompt examplesdocs/architecture.md—pkg/prismadded to Package Responsibilitiesdocs/json-schema.md— note thatpkg/prism.Resultdiffers from CLI JSONdocs/versioning.md— covers both CLI JSON andpkg/prismAPI stabilityDesign decisions
AnalyzeandPromptare exposed. Internals (internal/domain,internal/provider, etc.) remain private.AnalyzeOptionsandResultwithout breaking consumers.ErrInvalidInput,ErrUnsupportedProvider,ErrAuthRequired,ErrUpstreamFailure.AnalyzeOptions.IncludePatchesto keep responses lightweight.pkg/prism.Resultdiffers from CLI JSON (provider position, URL inclusion, description exclusion). Phase 2 will unify them via CLI refactor.Phase 2 (deferred)
cmd/prismto usepkg/prisminternallypkg/prism.ResultJSON via golden testsprism-apirepositoryTest plan
make test(with-race) — all 18 pkg/prism tests passmake lint— 0 issuesmake vet— clean