Documentation
¶
Overview ¶
Package api provides the HTTP client and base request primitives for the Supermodel API. It handles authentication headers, idempotency keys, error parsing, and response decoding.
This is a shared kernel package. It must contain no business logic. Slice packages under internal/ may import it freely.
Index ¶
- type AliveCode
- type Client
- func (c *Client) Analyze(ctx context.Context, zipPath, idempotencyKey string) (*Graph, error)
- func (c *Client) AnalyzeDomains(ctx context.Context, zipPath, idempotencyKey string) (*SupermodelIR, error)
- func (c *Client) AnalyzeRaw(ctx context.Context, zipPath, idempotencyKey string) (json.RawMessage, error)
- func (c *Client) DeadCode(ctx context.Context, zipPath, idempotencyKey, minConfidence string, limit int) (*DeadCodeResult, error)
- func (c *Client) DisplayGraph(ctx context.Context, repoID, idempotencyKey string) (*Graph, error)
- type DeadCodeCandidate
- type DeadCodeMetadata
- type DeadCodeResult
- type EntryPoint
- type Error
- type Graph
- type IRDomain
- type IRGraph
- type IRMetadata
- type IRNode
- type IRRelationship
- type IRSubdomain
- type JobResponse
- type Node
- type Relationship
- type SupermodelIR
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AliveCode ¶ added in v0.2.0
type AliveCode struct {
File string `json:"file"`
Name string `json:"name"`
Line int `json:"line"`
Type string `json:"type"`
CallerCount int `json:"callerCount"`
}
AliveCode is a function confirmed as reachable.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an authenticated Supermodel API client.
func (*Client) Analyze ¶
Analyze uploads a repository ZIP and runs the full analysis pipeline, polling until the async job completes and returning the Graph.
func (*Client) AnalyzeDomains ¶ added in v0.2.0
func (c *Client) AnalyzeDomains(ctx context.Context, zipPath, idempotencyKey string) (*SupermodelIR, error)
AnalyzeDomains uploads a repository ZIP and runs the full analysis pipeline, returning the complete SupermodelIR response (domains, summary, metadata, graph). Use this instead of Analyze when you need high-level domain information.
func (*Client) AnalyzeRaw ¶ added in v0.2.0
func (c *Client) AnalyzeRaw(ctx context.Context, zipPath, idempotencyKey string) (json.RawMessage, error)
AnalyzeRaw uploads a repository ZIP and runs the full analysis pipeline, returning the raw result JSON from the completed job. Use this when you need the full response payload (e.g. for graph2md / arch-docs generation).
type DeadCodeCandidate ¶ added in v0.2.0
type DeadCodeCandidate struct {
File string `json:"file"`
Name string `json:"name"`
Line int `json:"line"`
Type string `json:"type"`
Confidence string `json:"confidence"`
Reason string `json:"reason"`
}
DeadCodeCandidate is a function flagged as unreachable.
type DeadCodeMetadata ¶ added in v0.2.0
type DeadCodeMetadata struct {
TotalDeclarations int `json:"totalDeclarations"`
DeadCodeCandidates int `json:"deadCodeCandidates"`
AliveCode int `json:"aliveCode"`
AnalysisMethod string `json:"analysisMethod"`
AnalysisStartTime string `json:"analysisStartTime"`
AnalysisEndTime string `json:"analysisEndTime"`
}
DeadCodeMetadata holds summary stats for a dead code analysis.
type DeadCodeResult ¶ added in v0.2.0
type DeadCodeResult struct {
Metadata DeadCodeMetadata `json:"metadata"`
DeadCodeCandidates []DeadCodeCandidate `json:"deadCodeCandidates"`
AliveCode []AliveCode `json:"aliveCode"`
EntryPoints []EntryPoint `json:"entryPoints"`
}
DeadCodeResult is the result from /v1/analysis/dead-code.
type EntryPoint ¶ added in v0.2.0
type EntryPoint struct {
File string `json:"file"`
}
EntryPoint is a detected entry point that should not be flagged as dead.
type Error ¶
type Error struct {
StatusCode int `json:"-"`
Status int `json:"status"`
Code string `json:"code"`
Message string `json:"message"`
}
Error represents a non-2xx response from the API.
type Graph ¶
type Graph struct {
Nodes []Node `json:"nodes"`
Edges []Relationship `json:"edges"`
Relationships []Relationship `json:"relationships"`
Metadata map[string]any `json:"metadata,omitempty"`
}
Graph is the unified response type for /v1/graphs/supermodel and /v1/repos/{id}/graph/display. The API serialises relationships as either "edges" or "relationships" depending on the endpoint; Rels() unifies both.
func (*Graph) NodesByLabel ¶
NodesByLabel returns all nodes that carry the given label.
func (*Graph) Rels ¶
func (g *Graph) Rels() []Relationship
Rels returns all relationships regardless of which JSON field they came from.
type IRDomain ¶ added in v0.2.0
type IRDomain struct {
Name string `json:"name"`
DescriptionSummary string `json:"descriptionSummary"`
KeyFiles []string `json:"keyFiles"`
Responsibilities []string `json:"responsibilities"`
Subdomains []IRSubdomain `json:"subdomains"`
}
IRDomain is the raw representation of a semantic domain from the API.
type IRGraph ¶ added in v0.2.0
type IRGraph struct {
Nodes []IRNode `json:"nodes"`
Relationships []IRRelationship `json:"relationships"`
}
IRGraph is the raw node/relationship sub-graph embedded in SupermodelIR.
type IRMetadata ¶ added in v0.2.0
IRMetadata holds file-count and language statistics from the API response.
type IRRelationship ¶ added in v0.2.0
type IRRelationship struct {
Type string `json:"type"`
Source string `json:"source"`
Target string `json:"target"`
}
IRRelationship is a directed edge in the IRGraph.
type IRSubdomain ¶ added in v0.2.0
type IRSubdomain struct {
Name string `json:"name"`
DescriptionSummary string `json:"descriptionSummary"`
}
IRSubdomain is a named sub-area within an IRDomain.
type JobResponse ¶ added in v0.2.0
type JobResponse struct {
Status string `json:"status"`
JobID string `json:"jobId"`
RetryAfter int `json:"retryAfter"`
Error *string `json:"error"`
Result json.RawMessage `json:"result"`
}
JobResponse is the async envelope returned by the API for long-running jobs.
type Node ¶
type Node struct {
ID string `json:"id"`
Labels []string `json:"labels"`
Properties map[string]any `json:"properties"`
}
Node represents a graph node returned by the Supermodel API.
type Relationship ¶
type Relationship struct {
ID string `json:"id"`
Type string `json:"type"`
StartNode string `json:"startNode"`
EndNode string `json:"endNode"`
Properties map[string]any `json:"properties,omitempty"`
}
Relationship is a directed edge between two graph nodes.
type SupermodelIR ¶ added in v0.2.0
type SupermodelIR struct {
Repo string `json:"repo"`
Summary map[string]any `json:"summary"`
Metadata IRMetadata `json:"metadata"`
Domains []IRDomain `json:"domains"`
Graph IRGraph `json:"graph"`
}
SupermodelIR is the full structured response returned inside a completed job result from /v1/graphs/supermodel. It contains high-level domain information in addition to the raw node/edge graph captured by Graph.