chore: include pre-built dist for github install
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
export declare function getAstGrepPath(): Promise<string | null>;
|
||||
export declare function startBackgroundInit(): void;
|
||||
export declare function isCliAvailable(): boolean;
|
||||
export declare function ensureCliAvailable(): Promise<boolean>;
|
||||
export declare function getResolvedSgCliPath(): string | null;
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
import type { CliLanguage, SgResult } from "./types";
|
||||
export { ensureCliAvailable, getAstGrepPath, isCliAvailable, startBackgroundInit, } from "./cli-binary-path-resolution";
|
||||
export interface RunOptions {
|
||||
pattern: string;
|
||||
lang: CliLanguage;
|
||||
paths?: string[];
|
||||
globs?: string[];
|
||||
rewrite?: string;
|
||||
context?: number;
|
||||
updateAll?: boolean;
|
||||
}
|
||||
export declare function runSg(options: RunOptions): Promise<SgResult>;
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
export type { EnvironmentCheckResult } from "./environment-check";
|
||||
export { checkEnvironment, formatEnvironmentCheck } from "./environment-check";
|
||||
export { CLI_LANGUAGES, NAPI_LANGUAGES, LANG_EXTENSIONS } from "./language-support";
|
||||
export { DEFAULT_TIMEOUT_MS, DEFAULT_MAX_OUTPUT_BYTES, DEFAULT_MAX_MATCHES } from "./language-support";
|
||||
export { findSgCliPathSync, getSgCliPath, setSgCliPath } from "./sg-cli-path";
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
export declare function getCacheDir(): string;
|
||||
export declare function getBinaryName(): string;
|
||||
export declare function getCachedBinaryPath(): string | null;
|
||||
export declare function downloadAstGrep(version?: string): Promise<string | null>;
|
||||
export declare function ensureAstGrepBinary(): Promise<string | null>;
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
export interface EnvironmentCheckResult {
|
||||
cli: {
|
||||
available: boolean;
|
||||
path: string;
|
||||
error?: string;
|
||||
};
|
||||
napi: {
|
||||
available: boolean;
|
||||
error?: string;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Check if ast-grep CLI and NAPI are available.
|
||||
* Call this at startup to provide early feedback about missing dependencies.
|
||||
*/
|
||||
export declare function checkEnvironment(): EnvironmentCheckResult;
|
||||
/**
|
||||
* Format environment check result as user-friendly message.
|
||||
*/
|
||||
export declare function formatEnvironmentCheck(result: EnvironmentCheckResult): string;
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
export { createAstGrepTools } from "./tools";
|
||||
export { ensureAstGrepBinary, getCachedBinaryPath, getCacheDir } from "./downloader";
|
||||
export { getAstGrepPath, isCliAvailable, ensureCliAvailable, startBackgroundInit } from "./cli";
|
||||
export { checkEnvironment, formatEnvironmentCheck } from "./constants";
|
||||
export type { EnvironmentCheckResult } from "./constants";
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
export declare const CLI_LANGUAGES: readonly ["bash", "c", "cpp", "csharp", "css", "elixir", "go", "haskell", "html", "java", "javascript", "json", "kotlin", "lua", "nix", "php", "python", "ruby", "rust", "scala", "solidity", "swift", "typescript", "tsx", "yaml"];
|
||||
export declare const NAPI_LANGUAGES: readonly ["html", "javascript", "tsx", "css", "typescript"];
|
||||
export declare const DEFAULT_TIMEOUT_MS = 300000;
|
||||
export declare const DEFAULT_MAX_OUTPUT_BYTES: number;
|
||||
export declare const DEFAULT_MAX_MATCHES = 500;
|
||||
export declare const LANG_EXTENSIONS: Record<string, string[]>;
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
type SpawnedProcess = {
|
||||
stdout: ReadableStream | null;
|
||||
stderr: ReadableStream | null;
|
||||
exited: Promise<number>;
|
||||
kill: () => void;
|
||||
};
|
||||
export declare function collectProcessOutputWithTimeout(process: SpawnedProcess, timeoutMs: number): Promise<{
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
}>;
|
||||
export {};
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import type { AnalyzeResult, SgResult } from "./types";
|
||||
export declare function formatSearchResult(result: SgResult): string;
|
||||
export declare function formatReplaceResult(result: SgResult, isDryRun: boolean): string;
|
||||
export declare function formatAnalyzeResult(results: AnalyzeResult[], extractedMetaVars: boolean): string;
|
||||
export declare function formatTransformResult(_original: string, transformed: string, editCount: number): string;
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export declare function findSgCliPathSync(): string | null;
|
||||
export declare function getSgCliPath(): string | null;
|
||||
export declare function setSgCliPath(path: string): void;
|
||||
@@ -0,0 +1,2 @@
|
||||
import type { SgResult } from "./types";
|
||||
export declare function createSgResultFromStdout(stdout: string): SgResult;
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
import type { PluginInput } from "@opencode-ai/plugin";
|
||||
import { type ToolDefinition } from "@opencode-ai/plugin/tool";
|
||||
export declare function createAstGrepTools(ctx: PluginInput): Record<string, ToolDefinition>;
|
||||
Vendored
+58
@@ -0,0 +1,58 @@
|
||||
import type { CLI_LANGUAGES, NAPI_LANGUAGES } from "./constants";
|
||||
export type CliLanguage = (typeof CLI_LANGUAGES)[number];
|
||||
export type NapiLanguage = (typeof NAPI_LANGUAGES)[number];
|
||||
export interface Position {
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
export interface Range {
|
||||
start: Position;
|
||||
end: Position;
|
||||
}
|
||||
export interface CliMatch {
|
||||
text: string;
|
||||
range: {
|
||||
byteOffset: {
|
||||
start: number;
|
||||
end: number;
|
||||
};
|
||||
start: Position;
|
||||
end: Position;
|
||||
};
|
||||
file: string;
|
||||
lines: string;
|
||||
charCount: {
|
||||
leading: number;
|
||||
trailing: number;
|
||||
};
|
||||
language: string;
|
||||
}
|
||||
export interface SearchMatch {
|
||||
file: string;
|
||||
text: string;
|
||||
range: Range;
|
||||
lines: string;
|
||||
}
|
||||
export interface MetaVariable {
|
||||
name: string;
|
||||
text: string;
|
||||
kind: string;
|
||||
}
|
||||
export interface AnalyzeResult {
|
||||
text: string;
|
||||
range: Range;
|
||||
kind: string;
|
||||
metaVariables: MetaVariable[];
|
||||
}
|
||||
export interface TransformResult {
|
||||
original: string;
|
||||
transformed: string;
|
||||
editCount: number;
|
||||
}
|
||||
export interface SgResult {
|
||||
matches: CliMatch[];
|
||||
totalMatches: number;
|
||||
truncated: boolean;
|
||||
truncatedReason?: "max_matches" | "max_output_bytes" | "timeout";
|
||||
error?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user