chore: include pre-built dist for github install

This commit is contained in:
Robin Mordasiewicz
2026-03-14 04:56:50 +00:00
parent a7f0a4cf46
commit bce8ff3a75
1011 changed files with 150081 additions and 0 deletions
+5
View File
@@ -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;
+12
View File
@@ -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>;
+5
View File
@@ -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";
+5
View File
@@ -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
View File
@@ -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;
+5
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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;
+3
View File
@@ -0,0 +1,3 @@
export declare function findSgCliPathSync(): string | null;
export declare function getSgCliPath(): string | null;
export declare function setSgCliPath(path: string): void;
+2
View File
@@ -0,0 +1,2 @@
import type { SgResult } from "./types";
export declare function createSgResultFromStdout(stdout: string): SgResult;
+3
View File
@@ -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>;
+58
View File
@@ -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;
}