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,83 +0,0 @@
|
||||
export const BDD_KEYWORDS = new Set([
|
||||
"given",
|
||||
"when",
|
||||
"then",
|
||||
"arrange",
|
||||
"act",
|
||||
"assert",
|
||||
"when & then",
|
||||
"when&then",
|
||||
])
|
||||
|
||||
export const TYPE_CHECKER_PREFIXES = [
|
||||
"type:",
|
||||
"noqa",
|
||||
"pyright:",
|
||||
"ruff:",
|
||||
"mypy:",
|
||||
"pylint:",
|
||||
"flake8:",
|
||||
"pyre:",
|
||||
"pytype:",
|
||||
"eslint-disable",
|
||||
"eslint-enable",
|
||||
"eslint-ignore",
|
||||
"prettier-ignore",
|
||||
"ts-ignore",
|
||||
"ts-expect-error",
|
||||
"ts-nocheck",
|
||||
"clippy::",
|
||||
"allow(",
|
||||
"deny(",
|
||||
"warn(",
|
||||
"forbid(",
|
||||
"nolint",
|
||||
"go:generate",
|
||||
"go:build",
|
||||
"go:embed",
|
||||
"coverage:",
|
||||
"c8 ignore",
|
||||
"biome-ignore",
|
||||
"region",
|
||||
"endregion",
|
||||
]
|
||||
|
||||
export const HOOK_MESSAGE_HEADER = `COMMENT/DOCSTRING DETECTED - IMMEDIATE ACTION REQUIRED
|
||||
|
||||
Your recent changes contain comments or docstrings, which triggered this hook.
|
||||
You need to take immediate action. You must follow the conditions below.
|
||||
(Listed in priority order - you must always act according to this priority order)
|
||||
|
||||
CRITICAL WARNING: This hook message MUST NEVER be ignored, even if you receive it multiple times.
|
||||
You MUST provide corresponding explanation or action for EACH occurrence of this message.
|
||||
Ignoring this message or failing to respond appropriately is strictly prohibited.
|
||||
|
||||
PRIORITY-BASED ACTION GUIDELINES:
|
||||
|
||||
1. This is a comment/docstring that already existed before
|
||||
\t-> Explain to the user that this is an existing comment/docstring and proceed (justify it)
|
||||
|
||||
2. This is a newly written comment: but it's in given, when, then format
|
||||
\t-> Tell the user it's a BDD comment and proceed (justify it)
|
||||
\t-> Note: This applies to comments only, not docstrings
|
||||
|
||||
3. This is a newly written comment/docstring: but it's a necessary comment/docstring
|
||||
\t-> Tell the user why this comment/docstring is absolutely necessary and proceed (justify it)
|
||||
\t-> Examples of necessary comments: complex algorithms, security-related, performance optimization, regex, mathematical formulas
|
||||
\t-> Examples of necessary docstrings: public API documentation, complex module/class interfaces
|
||||
\t-> IMPORTANT: Most docstrings are unnecessary if the code is self-explanatory. Only keep truly essential ones.
|
||||
|
||||
4. This is a newly written comment/docstring: but it's an unnecessary comment/docstring
|
||||
\t-> Apologize to the user and remove the comment/docstring.
|
||||
\t-> Make the code itself clearer so it can be understood without comments/docstrings.
|
||||
\t-> For verbose docstrings: refactor code to be self-documenting instead of adding lengthy explanations.
|
||||
|
||||
CODE SMELL WARNING: Using comments as visual separators (e.g., "// =========", "# ---", "// *** Section ***")
|
||||
is a code smell. If you need separators, your file is too long or poorly organized.
|
||||
Refactor into smaller modules or use proper code organization instead of comment-based section dividers.
|
||||
|
||||
MANDATORY REQUIREMENT: You must acknowledge this hook message and take one of the above actions.
|
||||
Review in the above priority order and take the corresponding action EVERY TIME this appears.
|
||||
|
||||
Detected comments/docstrings:
|
||||
`
|
||||
@@ -1,21 +0,0 @@
|
||||
import type { CommentInfo, FilterResult } from "../types"
|
||||
import { BDD_KEYWORDS } from "../constants"
|
||||
|
||||
function stripCommentPrefix(text: string): string {
|
||||
let stripped = text.trim().toLowerCase()
|
||||
const prefixes = ["#", "//", "--", "/*", "*/"]
|
||||
for (const prefix of prefixes) {
|
||||
if (stripped.startsWith(prefix)) {
|
||||
stripped = stripped.slice(prefix.length).trim()
|
||||
}
|
||||
}
|
||||
return stripped
|
||||
}
|
||||
|
||||
export function filterBddComments(comment: CommentInfo): FilterResult {
|
||||
const normalized = stripCommentPrefix(comment.text)
|
||||
if (BDD_KEYWORDS.has(normalized)) {
|
||||
return { shouldSkip: true, reason: `BDD keyword: ${normalized}` }
|
||||
}
|
||||
return { shouldSkip: false }
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import type { CommentInfo, FilterResult } from "../types"
|
||||
import { TYPE_CHECKER_PREFIXES } from "../constants"
|
||||
|
||||
function stripCommentPrefix(text: string): string {
|
||||
let stripped = text.trim().toLowerCase()
|
||||
const prefixes = ["#", "//", "/*", "--"]
|
||||
for (const prefix of prefixes) {
|
||||
if (stripped.startsWith(prefix)) {
|
||||
stripped = stripped.slice(prefix.length).trim()
|
||||
}
|
||||
}
|
||||
stripped = stripped.replace(/^@/, "")
|
||||
return stripped
|
||||
}
|
||||
|
||||
export function filterDirectiveComments(comment: CommentInfo): FilterResult {
|
||||
const normalized = stripCommentPrefix(comment.text)
|
||||
for (const prefix of TYPE_CHECKER_PREFIXES) {
|
||||
if (normalized.startsWith(prefix.toLowerCase())) {
|
||||
return { shouldSkip: true, reason: `Directive: ${prefix}` }
|
||||
}
|
||||
}
|
||||
return { shouldSkip: false }
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import type { CommentInfo, FilterResult } from "../types"
|
||||
|
||||
export function filterDocstringComments(comment: CommentInfo): FilterResult {
|
||||
if (comment.isDocstring) {
|
||||
return { shouldSkip: true, reason: "Docstring" }
|
||||
}
|
||||
const trimmed = comment.text.trimStart()
|
||||
if (trimmed.startsWith("/**")) {
|
||||
return { shouldSkip: true, reason: "JSDoc/PHPDoc" }
|
||||
}
|
||||
return { shouldSkip: false }
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import type { CommentInfo, CommentFilter } from "../types"
|
||||
import { filterBddComments } from "./bdd"
|
||||
import { filterDirectiveComments } from "./directive"
|
||||
import { filterDocstringComments } from "./docstring"
|
||||
import { filterShebangComments } from "./shebang"
|
||||
|
||||
export { filterBddComments, filterDirectiveComments, filterDocstringComments, filterShebangComments }
|
||||
|
||||
const ALL_FILTERS: CommentFilter[] = [
|
||||
filterShebangComments,
|
||||
filterBddComments,
|
||||
filterDirectiveComments,
|
||||
filterDocstringComments,
|
||||
]
|
||||
|
||||
export function applyFilters(comments: CommentInfo[]): CommentInfo[] {
|
||||
return comments.filter((comment) => {
|
||||
for (const filter of ALL_FILTERS) {
|
||||
const result = filter(comment)
|
||||
if (result.shouldSkip) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
import type { CommentInfo, FilterResult } from "../types"
|
||||
|
||||
export function filterShebangComments(comment: CommentInfo): FilterResult {
|
||||
const trimmed = comment.text.trimStart()
|
||||
if (trimmed.startsWith("#!")) {
|
||||
return { shouldSkip: true, reason: "Shebang" }
|
||||
}
|
||||
return { shouldSkip: false }
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import type { FileComments } from "../types"
|
||||
import { HOOK_MESSAGE_HEADER } from "../constants"
|
||||
import { buildCommentsXml } from "./xml-builder"
|
||||
|
||||
export function formatHookMessage(fileCommentsList: FileComments[]): string {
|
||||
if (fileCommentsList.length === 0) {
|
||||
return ""
|
||||
}
|
||||
const xml = buildCommentsXml(fileCommentsList)
|
||||
return `${HOOK_MESSAGE_HEADER}${xml}\n`
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
export { buildCommentsXml } from "./xml-builder"
|
||||
export { formatHookMessage } from "./formatter"
|
||||
@@ -1,24 +0,0 @@
|
||||
import type { FileComments } from "../types"
|
||||
|
||||
function escapeXml(text: string): string {
|
||||
return text
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'")
|
||||
}
|
||||
|
||||
export function buildCommentsXml(fileCommentsList: FileComments[]): string {
|
||||
const lines: string[] = []
|
||||
|
||||
for (const fc of fileCommentsList) {
|
||||
lines.push(`<comments file="${escapeXml(fc.filePath)}">`)
|
||||
for (const comment of fc.comments) {
|
||||
lines.push(`\t<comment line-number="${comment.lineNumber}">${escapeXml(comment.text)}</comment>`)
|
||||
}
|
||||
lines.push(`</comments>`)
|
||||
}
|
||||
|
||||
return lines.join("\n")
|
||||
}
|
||||
Reference in New Issue
Block a user