fix(tools): minor ast-grep improvements
Small fixes to AST-grep constants, tools, and utility functions. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
3f002ff50c
commit
2690301833
@ -233,9 +233,9 @@ export function formatEnvironmentCheck(result: EnvironmentCheckResult): string {
|
||||
|
||||
// CLI status
|
||||
if (result.cli.available) {
|
||||
lines.push(`✓ CLI: Available (${result.cli.path})`)
|
||||
lines.push(`[OK] CLI: Available (${result.cli.path})`)
|
||||
} else {
|
||||
lines.push(`✗ CLI: Not available`)
|
||||
lines.push(`[X] CLI: Not available`)
|
||||
if (result.cli.error) {
|
||||
lines.push(` Error: ${result.cli.error}`)
|
||||
}
|
||||
@ -244,9 +244,9 @@ export function formatEnvironmentCheck(result: EnvironmentCheckResult): string {
|
||||
|
||||
// NAPI status
|
||||
if (result.napi.available) {
|
||||
lines.push(`✓ NAPI: Available`)
|
||||
lines.push(`[OK] NAPI: Available`)
|
||||
} else {
|
||||
lines.push(`✗ NAPI: Not available`)
|
||||
lines.push(`[X] NAPI: Not available`)
|
||||
if (result.napi.error) {
|
||||
lines.push(` Error: ${result.napi.error}`)
|
||||
}
|
||||
|
||||
@ -15,17 +15,17 @@ function getEmptyResultHint(pattern: string, lang: CliLanguage): string | null {
|
||||
if (lang === "python") {
|
||||
if (src.startsWith("class ") && src.endsWith(":")) {
|
||||
const withoutColon = src.slice(0, -1)
|
||||
return `💡 Hint: Remove trailing colon. Try: "${withoutColon}"`
|
||||
return `Hint: Remove trailing colon. Try: "${withoutColon}"`
|
||||
}
|
||||
if ((src.startsWith("def ") || src.startsWith("async def ")) && src.endsWith(":")) {
|
||||
const withoutColon = src.slice(0, -1)
|
||||
return `💡 Hint: Remove trailing colon. Try: "${withoutColon}"`
|
||||
return `Hint: Remove trailing colon. Try: "${withoutColon}"`
|
||||
}
|
||||
}
|
||||
|
||||
if (["javascript", "typescript", "tsx"].includes(lang)) {
|
||||
if (/^(export\s+)?(async\s+)?function\s+\$[A-Z_]+\s*$/i.test(src)) {
|
||||
return `💡 Hint: Function patterns need params and body. Try "function $NAME($$$) { $$$ }"`
|
||||
return `Hint: Function patterns need params and body. Try "function $NAME($$$) { $$$ }"`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ export function formatSearchResult(result: SgResult): string {
|
||||
: result.truncatedReason === "max_output_bytes"
|
||||
? "output exceeded 1MB limit"
|
||||
: "search timed out"
|
||||
lines.push(`⚠️ Results truncated (${reason})\n`)
|
||||
lines.push(`[TRUNCATED] Results truncated (${reason})\n`)
|
||||
}
|
||||
|
||||
lines.push(`Found ${result.matches.length} match(es)${result.truncated ? ` (truncated from ${result.totalMatches})` : ""}:\n`)
|
||||
@ -50,7 +50,7 @@ export function formatReplaceResult(result: SgResult, isDryRun: boolean): string
|
||||
: result.truncatedReason === "max_output_bytes"
|
||||
? "output exceeded 1MB limit"
|
||||
: "search timed out"
|
||||
lines.push(`⚠️ Results truncated (${reason})\n`)
|
||||
lines.push(`[TRUNCATED] Results truncated (${reason})\n`)
|
||||
}
|
||||
|
||||
lines.push(`${prefix}${result.matches.length} replacement(s):\n`)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user