@@ -2,7 +2,7 @@ openapi: 3.0.0
22info :
33 title : Supermodel
44 description : Code Graphing & Analysis API
5- version : 0.9.2
5+ version : 0.9.3
66 license :
77 name : Supermodel API Terms of Service
88 url : https://supermodeltools.com/legal/api-terms
@@ -1486,6 +1486,123 @@ paths:
14861486 application/json :
14871487 schema :
14881488 $ref : ' #/components/schemas/Error'
1489+ /v1/analysis/dead-code :
1490+ post :
1491+ tags :
1492+ - Data Plane
1493+ summary : Dead code analysis
1494+ description : Upload a zipped repository snapshot to identify dead (unreachable) code candidates by combining parse graph declarations with call graph relationships.
1495+ operationId : generateDeadCodeAnalysis
1496+ security :
1497+ - ApiKeyAuth : []
1498+ parameters :
1499+ - $ref : ' #/components/parameters/IdempotencyKey'
1500+ requestBody :
1501+ required : true
1502+ content :
1503+ multipart/form-data :
1504+ schema :
1505+ type : object
1506+ required :
1507+ - file
1508+ properties :
1509+ file :
1510+ type : string
1511+ format : binary
1512+ description : Zipped repository archive containing the code to analyze.
1513+ x-codeSamples :
1514+ - lang : cURL
1515+ label : cURL
1516+ source : |
1517+ curl -X POST 'https://api.supermodeltools.com/v1/analysis/dead-code' \
1518+ -H 'Idempotency-Key: <idempotency-key>' \
1519+ -H 'X-Api-Key: <api-key>' \
1520+ -F 'file=@/path/to/your/repo-snapshot.zip;type=application/zip'
1521+ responses :
1522+ ' 200 ' :
1523+ description : Dead code analysis (job completed)
1524+ headers :
1525+ X-Request-Id :
1526+ $ref : ' #/components/headers/X-Request-Id'
1527+ X-API-Version :
1528+ $ref : ' #/components/headers/X-API-Version'
1529+ RateLimit-Limit :
1530+ $ref : ' #/components/headers/RateLimit-Limit'
1531+ RateLimit-Remaining :
1532+ $ref : ' #/components/headers/RateLimit-Remaining'
1533+ RateLimit-Reset :
1534+ $ref : ' #/components/headers/RateLimit-Reset'
1535+ X-Usage-Units :
1536+ $ref : ' #/components/headers/X-Usage-Units'
1537+ content :
1538+ application/json :
1539+ schema :
1540+ $ref : ' #/components/schemas/DeadCodeAnalysisResponseAsync'
1541+ example :
1542+ status : completed
1543+ jobId : abc-123-def
1544+ result :
1545+ metadata :
1546+ totalDeclarations : 162
1547+ deadCodeCandidates : 102
1548+ aliveCode : 60
1549+ analysisMethod : parse_graph + call_graph
1550+ analysisStartTime : ' 2025-02-05T15:42:05Z'
1551+ analysisEndTime : ' 2025-02-05T15:42:10Z'
1552+ deadCodeCandidates :
1553+ - file : src/utils/idGenerator.ts
1554+ name : generateSequentialId
1555+ line : 8
1556+ type : function
1557+ confidence : high
1558+ reason : No callers found in codebase
1559+ aliveCode :
1560+ - file : src/index.ts
1561+ name : main
1562+ line : 10
1563+ type : function
1564+ callerCount : 3
1565+ entryPoints :
1566+ - file : src/index.ts
1567+ name : main
1568+ line : 10
1569+ type : function
1570+ reason : Module export
1571+ ' 202 ' :
1572+ description : Job accepted and processing
1573+ headers :
1574+ X-Request-Id :
1575+ $ref : ' #/components/headers/X-Request-Id'
1576+ X-API-Version :
1577+ $ref : ' #/components/headers/X-API-Version'
1578+ Retry-After :
1579+ description : Recommended wait time in seconds before polling again.
1580+ schema :
1581+ type : integer
1582+ content :
1583+ application/json :
1584+ schema :
1585+ $ref : ' #/components/schemas/DeadCodeAnalysisResponseAsync'
1586+ example :
1587+ status : processing
1588+ jobId : abc-123-def
1589+ retryAfter : 5
1590+ ' 400 ' :
1591+ $ref : ' #/components/responses/BadRequest'
1592+ ' 401 ' :
1593+ $ref : ' #/components/responses/Unauthorized'
1594+ ' 403 ' :
1595+ $ref : ' #/components/responses/Forbidden'
1596+ ' 429 ' :
1597+ $ref : ' #/components/responses/TooManyRequests'
1598+ ' 500 ' :
1599+ $ref : ' #/components/responses/InternalError'
1600+ ' 502 ' :
1601+ description : Bad Gateway
1602+ content :
1603+ application/json :
1604+ schema :
1605+ $ref : ' #/components/schemas/Error'
14891606components :
14901607 securitySchemes :
14911608 ApiKeyAuth :
@@ -1857,6 +1974,196 @@ components:
18571974 result :
18581975 $ref : ' #/components/schemas/SupermodelIR'
18591976 description : The result (present when status is completed).
1977+ DeadCodeAnalysisResponseAsync :
1978+ allOf :
1979+ - $ref : ' #/components/schemas/JobStatus'
1980+ - type : object
1981+ description : Async response envelope for dead code analysis operations.
1982+ properties :
1983+ result :
1984+ $ref : ' #/components/schemas/DeadCodeAnalysisResponse'
1985+ description : The result (present when status is completed).
1986+ DeadCodeAnalysisResponse :
1987+ type : object
1988+ description : Dead code analysis result containing candidates and alive code.
1989+ required :
1990+ - metadata
1991+ - deadCodeCandidates
1992+ - aliveCode
1993+ - entryPoints
1994+ properties :
1995+ metadata :
1996+ $ref : ' #/components/schemas/DeadCodeAnalysisMetadata'
1997+ deadCodeCandidates :
1998+ type : array
1999+ description : Code elements with no detected callers or references.
2000+ items :
2001+ $ref : ' #/components/schemas/DeadCodeCandidate'
2002+ aliveCode :
2003+ type : array
2004+ description : Code elements with at least one caller or reference.
2005+ items :
2006+ $ref : ' #/components/schemas/AliveCodeItem'
2007+ entryPoints :
2008+ type : array
2009+ description : Detected entry points (exports, route handlers, main functions).
2010+ items :
2011+ $ref : ' #/components/schemas/EntryPoint'
2012+ DeadCodeAnalysisMetadata :
2013+ type : object
2014+ description : Summary statistics for the dead code analysis.
2015+ required :
2016+ - totalDeclarations
2017+ - deadCodeCandidates
2018+ - aliveCode
2019+ - analysisMethod
2020+ properties :
2021+ totalDeclarations :
2022+ type : integer
2023+ format : int64
2024+ description : Total number of declarations (functions, classes, methods) analyzed.
2025+ deadCodeCandidates :
2026+ type : integer
2027+ format : int64
2028+ description : Number of dead code candidates found.
2029+ aliveCode :
2030+ type : integer
2031+ format : int64
2032+ description : Number of code elements with active references.
2033+ rootFilesCount :
2034+ type : integer
2035+ format : int64
2036+ description : Number of root files detected (files with no importers, used as entry points).
2037+ transitiveDeadCount :
2038+ type : integer
2039+ format : int64
2040+ description : Number of functions detected as dead via transitive propagation (all callers are dead).
2041+ symbolLevelDeadCount :
2042+ type : integer
2043+ format : int64
2044+ description : Number of exports detected as dead via symbol-level import analysis (exported but never imported by name).
2045+ analysisMethod :
2046+ type : string
2047+ description : Method used for analysis (e.g., 'dependency_graph_reachability').
2048+ analysisStartTime :
2049+ type : string
2050+ format : date-time
2051+ description : Timestamp when analysis started.
2052+ analysisEndTime :
2053+ type : string
2054+ format : date-time
2055+ description : Timestamp when analysis completed.
2056+ DeadCodeCandidate :
2057+ type : object
2058+ description : A code element identified as potentially dead (unreachable).
2059+ required :
2060+ - file
2061+ - name
2062+ - line
2063+ - type
2064+ - confidence
2065+ - reason
2066+ properties :
2067+ file :
2068+ type : string
2069+ description : File path relative to repository root.
2070+ name :
2071+ type : string
2072+ description : Name of the function, class, or method.
2073+ line :
2074+ type : integer
2075+ format : int32
2076+ description : Line number where the declaration starts.
2077+ type :
2078+ type : string
2079+ description : Type of code element.
2080+ enum :
2081+ - function
2082+ - class
2083+ - method
2084+ - interface
2085+ - type
2086+ - variable
2087+ - constant
2088+ confidence :
2089+ type : string
2090+ description : Confidence level of dead code detection.
2091+ enum :
2092+ - high
2093+ - medium
2094+ - low
2095+ reason :
2096+ type : string
2097+ description : Explanation of why this was flagged as dead code.
2098+ AliveCodeItem :
2099+ type : object
2100+ description : A code element with active callers or references.
2101+ required :
2102+ - file
2103+ - name
2104+ - line
2105+ - type
2106+ - callerCount
2107+ properties :
2108+ file :
2109+ type : string
2110+ description : File path relative to repository root.
2111+ name :
2112+ type : string
2113+ description : Name of the function, class, or method.
2114+ line :
2115+ type : integer
2116+ format : int32
2117+ description : Line number where the declaration starts.
2118+ type :
2119+ type : string
2120+ description : Type of code element.
2121+ enum :
2122+ - function
2123+ - class
2124+ - method
2125+ - interface
2126+ - type
2127+ - variable
2128+ - constant
2129+ callerCount :
2130+ type : integer
2131+ format : int32
2132+ description : Number of unique callers or references.
2133+ EntryPoint :
2134+ type : object
2135+ description : A detected entry point that should not be flagged as dead code.
2136+ required :
2137+ - file
2138+ - name
2139+ - line
2140+ - type
2141+ - reason
2142+ properties :
2143+ file :
2144+ type : string
2145+ description : File path relative to repository root.
2146+ name :
2147+ type : string
2148+ description : Name of the entry point.
2149+ line :
2150+ type : integer
2151+ format : int32
2152+ description : Line number where the entry point is declared.
2153+ type :
2154+ type : string
2155+ description : Type of code element.
2156+ enum :
2157+ - function
2158+ - class
2159+ - method
2160+ - interface
2161+ - type
2162+ - variable
2163+ - constant
2164+ reason :
2165+ type : string
2166+ description : Reason this is considered an entry point (e.g., 'Module export', 'Route handler', 'Main function').
18602167 Error :
18612168 type : object
18622169 description : Standardized error payload returned by the API.
0 commit comments