-
Notifications
You must be signed in to change notification settings - Fork 3
Closed
Labels
featureNew functionalityNew functionalityinfrastructureBuild, CI, tooling, refactoringBuild, CI, tooling, refactoring
Description
Context
Part of the Native Analysis via Claude Code Hooks feature (Phase 12, v4.8.0).
Plan: docs/plans/2026-03-28-native-analysis-hooks.md
Issue 2 of 6 — Depends on #238 (prompt module migration).
Problem
The insights command needs to run analysis via two different backends: claude -p (native) and the existing LLM provider abstraction. We need a clean interface so the command doesn't care which backend is used.
Solution
AnalysisRunner Interface
interface AnalysisRunner {
readonly name: string;
runAnalysis(params: RunAnalysisParams): Promise<RunAnalysisResult>;
}Two Implementations
-
ClaudeNativeRunner — executes
claude -pviaexecFileSync(notexec— shell injection safety)- Writes system prompt to temp file
- Writes JSON schema to temp file
- Pipes conversation via stdin
- Returns raw JSON response
- Records tokens=0, cost=0 (counted in Claude subscription)
-
ProviderRunner — wraps existing
server/src/llm/client.tsLLM abstraction- Same behavior as current dashboard/API analysis
- Returns actual token counts and costs
JSON Schema Files
Hand-maintained flat JSON schemas for claude -p --json-schema:
cli/src/analysis/schemas/session-analysis.json(from AnalysisResponse type)cli/src/analysis/schemas/prompt-quality.json(from PromptQualityResponse type)
Test that validates schema properties match TypeScript interface fields.
New Files
| File | Purpose |
|---|---|
cli/src/analysis/runner-types.ts |
AnalysisRunner interface + param/result types |
cli/src/analysis/native-runner.ts |
ClaudeNativeRunner (claude -p via execFileSync) |
cli/src/analysis/provider-runner.ts |
ProviderRunner (wraps existing LLM client) |
cli/src/analysis/schemas/session-analysis.json |
JSON schema for session analysis |
cli/src/analysis/schemas/prompt-quality.json |
JSON schema for prompt quality |
cli/src/analysis/schemas/__tests__/schema-sync.test.ts |
Schema ↔ TypeScript sync test |
Acceptance Criteria
- AnalysisRunner interface defined with RunAnalysisParams/RunAnalysisResult
- ClaudeNativeRunner validates
claudeCLI in PATH, usesexecFileSync - ProviderRunner delegates to existing LLM client
- JSON schema files cover all required fields of AnalysisResponse and PromptQualityResponse
- Schema sync test passes in CI
- Unit tests for both runners (mocked execFileSync / LLM client)
- SOLID: adding future runners (e.g., Cursor) requires only implementing the interface
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featureNew functionalityNew functionalityinfrastructureBuild, CI, tooling, refactoringBuild, CI, tooling, refactoring