Skip to content

Commit 759268b

Browse files
greynewellclaude
andcommitted
feat: rewrite as thin wrapper around supermodel CLI
Replaces the direct API client (TypeScript SDK) with the Supermodel CLI binary. The action now installs the CLI on the runner and delegates all analysis to `supermodel dead-code -o json`, then handles GitHub-specific concerns (PR diff scoping, PR comment, action outputs, fail-on-dead-code). Feature parity maintained: - comment-on-pr, fail-on-dead-code, ignore-patterns, timeout-seconds unchanged - PR diff scoping (scope findings to changed files) unchanged New inputs: - min-confidence: pass --min-confidence to CLI (high/medium/low) - cli-version: pin the CLI version to install (default: latest) Removed: - @supermodeltools/sdk dependency (analysis now done by CLI) - minimatch dependency (glob filtering now done by CLI --ignore flag) - filterByIgnorePatterns (logic moved to CLI) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7d37e62 commit 759268b

12 files changed

Lines changed: 12437 additions & 18410 deletions

action.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,21 @@ inputs:
2323
required: false
2424
default: 'false'
2525
ignore-patterns:
26-
description: 'JSON array of glob patterns to ignore'
26+
description: 'JSON array of glob patterns to exclude from results (supports **)'
2727
required: false
2828
default: '[]'
29+
min-confidence:
30+
description: 'Minimum confidence level to report: high, medium, or low'
31+
required: false
32+
default: ''
2933
timeout-seconds:
3034
description: 'Maximum seconds to wait for analysis to complete (default: 7200)'
3135
required: false
3236
default: '7200'
37+
cli-version:
38+
description: 'Supermodel CLI version to install (default: latest)'
39+
required: false
40+
default: 'latest'
3341

3442
outputs:
3543
dead-code-count:

dist/dead-code.d.ts

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1-
import type { DeadCodeCandidate, DeadCodeAnalysisResponse, DeadCodeAnalysisMetadata } from '@supermodeltools/sdk';
2-
export type { DeadCodeCandidate, DeadCodeAnalysisResponse, DeadCodeAnalysisMetadata };
3-
/**
4-
* Filters dead code candidates by user-provided ignore patterns.
5-
* The API handles all analysis server-side; this is purely for
6-
* client-side post-filtering on file paths.
7-
*/
8-
export declare function filterByIgnorePatterns(candidates: DeadCodeCandidate[], ignorePatterns: string[]): DeadCodeCandidate[];
1+
export type Confidence = 'high' | 'medium' | 'low';
2+
export type CodeType = 'function' | 'class' | 'method' | 'interface' | 'type' | 'variable' | 'constant';
3+
export interface DeadCodeCandidate {
4+
file: string;
5+
name: string;
6+
line: number;
7+
type: CodeType;
8+
confidence: Confidence;
9+
reason: string;
10+
}
11+
export interface DeadCodeMetadata {
12+
totalDeclarations: number;
13+
deadCodeCandidates: number;
14+
aliveCode: number;
15+
analysisMethod: string;
16+
analysisStartTime?: string;
17+
analysisEndTime?: string;
18+
transitiveDeadCount?: number;
19+
symbolLevelDeadCount?: number;
20+
}
21+
export interface DeadCodeResult {
22+
metadata: DeadCodeMetadata;
23+
deadCodeCandidates: DeadCodeCandidate[];
24+
aliveCode: unknown[];
25+
entryPoints: unknown[];
26+
}
927
/**
1028
* Scopes dead code candidates to only files present in the changed files set.
1129
* Used to limit PR comments to findings relevant to the current diff.
@@ -14,4 +32,4 @@ export declare function filterByChangedFiles(candidates: DeadCodeCandidate[], ch
1432
/**
1533
* Formats dead code analysis results as a GitHub PR comment.
1634
*/
17-
export declare function formatPrComment(candidates: DeadCodeCandidate[], metadata?: DeadCodeAnalysisMetadata): string;
35+
export declare function formatPrComment(candidates: DeadCodeCandidate[], metadata?: DeadCodeMetadata): string;

dist/dead-code.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)