chore: define and document public API exports#249
Conversation
Define explicit public API via package.json exports field to clarify which exports are intentional vs internal. This addresses the 180+ "unused" re-exports flagged by dead code analysis. Changes: - Add exports field to package.json with main (.) and types subpaths - Re-export stage runners (runAnalysis, runGeneration, runExecution, runEvaluation), config loader, and consoleProgress from main entry - Add @internal JSDoc tags to CLI-only helpers in src/index.ts - Add Programmatic Usage section to README.md with examples - Document public API in CLAUDE.md Fixes #228 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Claude finished @sjnims's task in 4m 0s —— View job PR Review Complete ✅
Verdict: ✅ Looks goodThis PR successfully defines a clean, minimal public API for cc-plugin-eval with excellent documentation and zero technical issues. Quality ChecksAll checks pass without issues:
What's Good1. Excellent API Design
2. Documentation Quality
3. Code Quality
4. Architecture Compliance
5. Testing
Suggestions1. Consider Adding a Basic Integration Test While the public API functions are well-tested individually, consider adding a simple integration test that exercises the documented usage pattern: // tests/integration/public-api.test.ts
import { describe, it, expect } from 'vitest';
import {
runAnalysis,
runGeneration,
loadConfigWithOverrides,
consoleProgress,
} from '../../src/index.js';
describe('Public API Integration', () => {
it('should support the documented usage pattern', async () => {
const config = loadConfigWithOverrides('tests/fixtures/valid-plugin/config.yaml', {
plugin: 'tests/fixtures/valid-plugin',
});
const analysis = await runAnalysis(config);
expect(analysis).toBeDefined();
expect(analysis.plugin_name).toBeDefined();
// Verify consoleProgress is exported and callable
expect(typeof consoleProgress.onStageStart).toBe('function');
});
});This would:
2. Future Enhancement: Add TypeScript Type Tests For the next iteration, consider adding type-level tests using // tests/types/public-api.test-d.ts
import type { EvalConfig, AnalysisOutput } from '../../src/types/index.js';
import { runAnalysis } from '../../src/index.js';
// Valid usage
const config: EvalConfig = {} as EvalConfig;
const result: Promise<AnalysisOutput> = runAnalysis(config);
// @ts-expect-error - should not accept wrong types
runAnalysis("invalid");This helps prevent accidental breaking changes to the public API surface. 3. Minor: Consider a CHANGELOG Entry For semantic versioning awareness, consider adding a CHANGELOG.md entry noting the new programmatic API for the next release (likely 0.3.0 as a minor feature addition). SummaryThis is a well-executed PR that:
The suggestions above are optional enhancements for future iterations, not blockers. This PR is ready to merge. |
Summary
package.jsonexports field@internalJSDoc tags to CLI-only helpersProblem
Fixes #228
Dead code analysis flagged 180+ re-exports as "unused" because they're not consumed internally. However, many of these are intentional public API exports meant for external consumption. This PR clarifies the distinction.
Solution
Implemented a minimal public API strategy as recommended in the issue analysis:
package.json exports field - Explicitly defines two subpaths:
.(main) - Stage runners + config loader./types- Type definitions (zero runtime cost)Public API Exports - Re-exports from
src/index.ts:runAnalysis,runGeneration,runExecution,runEvaluationloadConfigWithOverrides,consoleProgressCLIOptionstypeInternal Markers - Added
@internalJSDoc tags to:resumeFrom*)extractCLIOptions, etc.)outputCLISummary, etc.)ResumeHandler,EvaluationFile)Documentation - Added:
Alternatives Considered
Changes
package.json: Addexportsfield with main and types subpathssrc/index.ts: Add public API exports section, reorganize imports, add @internal tagsREADME.md: Add Programmatic Usage section after CLI ReferenceCLAUDE.md: Add Public API section with exports tableTesting
npm run lint)npm run typecheck)npm test)npm run format)🤖 Generated with Claude Code