chore: remove 1,152 lines of verified dead code (#874)
* chore(deps): remove unused dependencies Removed @openauthjs/openauth, hono, open, and xdg-basedir - none are imported in src/ Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> * chore(cleanup): remove unused agent prompts and tool files Deleted: - src/agents/build-prompt.ts (exports never imported) - src/agents/plan-prompt.ts (exports never imported) - src/tools/ast-grep/napi.ts (never imported) - src/tools/interactive-bash/types.ts (never imported) Verified by: LSP FindReferences + explore agents Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> * chore(hooks): remove unused comment-checker filters Deleted entire filters/ directory: - filters/bdd.ts - filters/directive.ts - filters/docstring.ts - filters/shebang.ts - filters/index.ts Not used by main hook (cli.ts uses external binary instead) Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> * chore(hooks): remove unused comment-checker output and constants Deleted: - output/formatter.ts - output/xml-builder.ts - output/index.ts - constants.ts All 0 external imports - migrated to external binary Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> * chore(hooks): remove unused pruning subsystem Deleted pruning subsystem (dependency order): - pruning-purge-errors.ts - pruning-storage.ts - pruning-supersede.ts - pruning-executor.ts Not imported by main recovery hook Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> * chore(hooks): remove unused createBackgroundCompactionHook export Removed export from index.ts - never imported in src/index.ts Verified by: LSP FindReferences (only 2 refs: definition + barrel export) Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai> --------- Co-authored-by: justsisyphus <sisyphus-dev-ai@users.noreply.github.com> Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -1,116 +0,0 @@
|
||||
import { parse, Lang } from "@ast-grep/napi"
|
||||
import { NAPI_LANGUAGES } from "./constants"
|
||||
import type { NapiLanguage, AnalyzeResult, MetaVariable, Range } from "./types"
|
||||
|
||||
const LANG_MAP: Record<NapiLanguage, Lang> = {
|
||||
html: Lang.Html,
|
||||
javascript: Lang.JavaScript,
|
||||
tsx: Lang.Tsx,
|
||||
css: Lang.Css,
|
||||
typescript: Lang.TypeScript,
|
||||
}
|
||||
|
||||
export function parseCode(code: string, lang: NapiLanguage) {
|
||||
const parseLang = LANG_MAP[lang]
|
||||
if (!parseLang) {
|
||||
const supportedLangs = NAPI_LANGUAGES.join(", ")
|
||||
throw new Error(
|
||||
`Unsupported language for NAPI: "${lang}"\n` +
|
||||
`Supported languages: ${supportedLangs}\n\n` +
|
||||
`Use ast_grep_search for other languages (25 supported via CLI).`
|
||||
)
|
||||
}
|
||||
return parse(parseLang, code)
|
||||
}
|
||||
|
||||
export function findPattern(root: ReturnType<typeof parseCode>, pattern: string) {
|
||||
return root.root().findAll(pattern)
|
||||
}
|
||||
|
||||
function nodeToRange(node: ReturnType<ReturnType<typeof parseCode>["root"]>): Range {
|
||||
const range = node.range()
|
||||
return {
|
||||
start: { line: range.start.line, column: range.start.column },
|
||||
end: { line: range.end.line, column: range.end.column },
|
||||
}
|
||||
}
|
||||
|
||||
function extractMetaVariablesFromPattern(pattern: string): string[] {
|
||||
const matches = pattern.match(/\$[A-Z_][A-Z0-9_]*/g) || []
|
||||
return [...new Set(matches.map((m) => m.slice(1)))]
|
||||
}
|
||||
|
||||
export function extractMetaVariables(
|
||||
node: ReturnType<ReturnType<typeof parseCode>["root"]>,
|
||||
pattern: string
|
||||
): MetaVariable[] {
|
||||
const varNames = extractMetaVariablesFromPattern(pattern)
|
||||
const result: MetaVariable[] = []
|
||||
|
||||
for (const name of varNames) {
|
||||
const match = node.getMatch(name)
|
||||
if (match) {
|
||||
result.push({
|
||||
name,
|
||||
text: match.text(),
|
||||
kind: String(match.kind()),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
export function analyzeCode(
|
||||
code: string,
|
||||
lang: NapiLanguage,
|
||||
pattern: string,
|
||||
shouldExtractMetaVars: boolean
|
||||
): AnalyzeResult[] {
|
||||
const root = parseCode(code, lang)
|
||||
const matches = findPattern(root, pattern)
|
||||
|
||||
return matches.map((node) => ({
|
||||
text: node.text(),
|
||||
range: nodeToRange(node),
|
||||
kind: String(node.kind()),
|
||||
metaVariables: shouldExtractMetaVars ? extractMetaVariables(node, pattern) : [],
|
||||
}))
|
||||
}
|
||||
|
||||
export function transformCode(
|
||||
code: string,
|
||||
lang: NapiLanguage,
|
||||
pattern: string,
|
||||
rewrite: string
|
||||
): { transformed: string; editCount: number } {
|
||||
const root = parseCode(code, lang)
|
||||
const matches = findPattern(root, pattern)
|
||||
|
||||
if (matches.length === 0) {
|
||||
return { transformed: code, editCount: 0 }
|
||||
}
|
||||
|
||||
const edits = matches.map((node) => {
|
||||
const metaVars = extractMetaVariables(node, pattern)
|
||||
let replacement = rewrite
|
||||
|
||||
for (const mv of metaVars) {
|
||||
replacement = replacement.replace(new RegExp(`\\$${mv.name}`, "g"), mv.text)
|
||||
}
|
||||
|
||||
return node.replace(replacement)
|
||||
})
|
||||
|
||||
const transformed = root.root().commitEdits(edits)
|
||||
return { transformed, editCount: edits.length }
|
||||
}
|
||||
|
||||
export function getRootInfo(code: string, lang: NapiLanguage): { kind: string; childCount: number } {
|
||||
const root = parseCode(code, lang)
|
||||
const rootNode = root.root()
|
||||
return {
|
||||
kind: String(rootNode.kind()),
|
||||
childCount: rootNode.children().length,
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export interface InteractiveBashArgs {
|
||||
tmux_command: string
|
||||
}
|
||||
Reference in New Issue
Block a user