git-jev-stage 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +11 -0
- package/.claude-plugin/plugin.json +10 -0
- package/LICENSE +21 -0
- package/README.md +114 -0
- package/dist/git-jev-stage.js +2945 -0
- package/dist/index.d.ts +361 -0
- package/dist/index.js +1851 -0
- package/package.json +69 -0
- package/skills/git-jev-stage/SKILL.md +34 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { Fetch } from '@typesafe-ai/sdk';
|
|
2
|
+
|
|
3
|
+
interface ProviderErrorOptions extends ErrorOptions {
|
|
4
|
+
status?: number | undefined;
|
|
5
|
+
requestId?: string | undefined;
|
|
6
|
+
retryable?: boolean | undefined;
|
|
7
|
+
}
|
|
8
|
+
declare abstract class JevCoreError extends Error {
|
|
9
|
+
abstract readonly code: string;
|
|
10
|
+
}
|
|
11
|
+
declare class ProviderError extends JevCoreError {
|
|
12
|
+
readonly code = "provider";
|
|
13
|
+
readonly status: number | undefined;
|
|
14
|
+
readonly requestId: string | undefined;
|
|
15
|
+
readonly retryable: boolean;
|
|
16
|
+
constructor(message: string, options?: ProviderErrorOptions);
|
|
17
|
+
}
|
|
18
|
+
declare class RequestTooLargeError extends JevCoreError {
|
|
19
|
+
readonly code = "request-too-large";
|
|
20
|
+
readonly estimatedTokens: number;
|
|
21
|
+
readonly tokenCeiling: number;
|
|
22
|
+
constructor(estimatedTokens: number, tokenCeiling: number, options?: ErrorOptions);
|
|
23
|
+
}
|
|
24
|
+
declare class ProviderConfigError extends JevCoreError {
|
|
25
|
+
readonly code = "provider-config";
|
|
26
|
+
constructor(message: string, options?: ErrorOptions);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
30
|
+
[k: string]: JsonValue;
|
|
31
|
+
};
|
|
32
|
+
interface ChoiceSpec<L extends string = string> {
|
|
33
|
+
instructions: string;
|
|
34
|
+
options: Record<L, string>;
|
|
35
|
+
}
|
|
36
|
+
interface ChoiceAnswer<L extends string = string> {
|
|
37
|
+
choice: L;
|
|
38
|
+
confidence: number;
|
|
39
|
+
probabilities: Record<L, number>;
|
|
40
|
+
}
|
|
41
|
+
type AnswerOutcome<L extends string = string> = {
|
|
42
|
+
kind: "answer";
|
|
43
|
+
answer: ChoiceAnswer<L>;
|
|
44
|
+
} | {
|
|
45
|
+
kind: "missing";
|
|
46
|
+
} | {
|
|
47
|
+
kind: "invalid";
|
|
48
|
+
reason: string;
|
|
49
|
+
};
|
|
50
|
+
interface ClassifyRequest<L extends string = string> {
|
|
51
|
+
state: JsonValue;
|
|
52
|
+
questions: Record<string, ChoiceSpec<L>>;
|
|
53
|
+
}
|
|
54
|
+
interface ClassifyResult<L extends string = string> {
|
|
55
|
+
outcomes: Record<string, AnswerOutcome<L>>;
|
|
56
|
+
usage: {
|
|
57
|
+
inputTokens: number;
|
|
58
|
+
outputTokens: number;
|
|
59
|
+
};
|
|
60
|
+
model: string;
|
|
61
|
+
requestId?: string;
|
|
62
|
+
}
|
|
63
|
+
interface JevProvider {
|
|
64
|
+
classify<L extends string>(request: ClassifyRequest<L>, options?: {
|
|
65
|
+
signal?: AbortSignal;
|
|
66
|
+
}): Promise<ClassifyResult<L>>;
|
|
67
|
+
}
|
|
68
|
+
interface WindowItem {
|
|
69
|
+
id: string;
|
|
70
|
+
text: string;
|
|
71
|
+
group: string;
|
|
72
|
+
ordinal: number;
|
|
73
|
+
}
|
|
74
|
+
interface Window {
|
|
75
|
+
askIds: string[];
|
|
76
|
+
contextIds: string[];
|
|
77
|
+
estimatedTokens: number;
|
|
78
|
+
}
|
|
79
|
+
interface WindowOptions {
|
|
80
|
+
tokenCeiling?: number;
|
|
81
|
+
sharedTokens: number;
|
|
82
|
+
perQuestionTokens?: number;
|
|
83
|
+
neighborContext?: boolean;
|
|
84
|
+
}
|
|
85
|
+
interface RunWindowsOptions {
|
|
86
|
+
concurrency?: number;
|
|
87
|
+
signal?: AbortSignal;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
type ScriptedAnswer = ChoiceAnswer | {
|
|
91
|
+
raw: unknown;
|
|
92
|
+
};
|
|
93
|
+
interface FakeScript {
|
|
94
|
+
answers?: Record<string, ScriptedAnswer>;
|
|
95
|
+
defaultAnswer?: ChoiceAnswer;
|
|
96
|
+
error?: Error;
|
|
97
|
+
delayMs?: number;
|
|
98
|
+
onRequest?: (request: ClassifyRequest) => void;
|
|
99
|
+
}
|
|
100
|
+
declare class FakeProvider implements JevProvider {
|
|
101
|
+
#private;
|
|
102
|
+
readonly requests: ClassifyRequest[];
|
|
103
|
+
constructor(script?: FakeScript);
|
|
104
|
+
classify<L extends string>(request: ClassifyRequest<L>, options?: {
|
|
105
|
+
signal?: AbortSignal;
|
|
106
|
+
}): Promise<ClassifyResult<L>>;
|
|
107
|
+
static fromJsonFile(path: string): FakeProvider;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
interface TypeSafeJevProviderOptions {
|
|
111
|
+
apiKey?: string | undefined;
|
|
112
|
+
baseURL?: string | undefined;
|
|
113
|
+
model?: string | undefined;
|
|
114
|
+
timeoutMs?: number | undefined;
|
|
115
|
+
maxRetries?: number | undefined;
|
|
116
|
+
fetch?: Fetch | undefined;
|
|
117
|
+
}
|
|
118
|
+
declare class TypeSafeJevProvider implements JevProvider {
|
|
119
|
+
#private;
|
|
120
|
+
readonly model: string;
|
|
121
|
+
constructor(options?: TypeSafeJevProviderOptions);
|
|
122
|
+
classify<L extends string>(request: ClassifyRequest<L>, options?: {
|
|
123
|
+
signal?: AbortSignal;
|
|
124
|
+
}): Promise<ClassifyResult<L>>;
|
|
125
|
+
}
|
|
126
|
+
declare function createProviderFromEnv(env?: Readonly<Record<string, string | undefined>>): TypeSafeJevProvider | undefined;
|
|
127
|
+
declare function validateChoiceAnswer<L extends string = string>(raw: unknown, options: readonly L[]): AnswerOutcome<L>;
|
|
128
|
+
|
|
129
|
+
declare const CHARS_PER_TOKEN = 4;
|
|
130
|
+
declare const DEFAULT_TOKEN_CEILING = 25000;
|
|
131
|
+
declare const DEFAULT_PER_QUESTION_TOKENS = 40;
|
|
132
|
+
declare function estimateTokens(text: string): number;
|
|
133
|
+
declare function estimateJsonTokens(value: JsonValue): number;
|
|
134
|
+
|
|
135
|
+
declare const DEFAULT_CONCURRENCY = 4;
|
|
136
|
+
declare function buildWindows(items: readonly WindowItem[], options: WindowOptions): Window[];
|
|
137
|
+
declare function runWindows<T>(windows: readonly Window[], fn: (window: Window, index: number, signal: AbortSignal) => Promise<T>, options?: RunWindowsOptions): Promise<T[]>;
|
|
138
|
+
|
|
139
|
+
type UnsupportedEntryKind = "symlink" | "submodule" | "binary";
|
|
140
|
+
type StaleSnapshotWhich = "head" | "index" | "diff";
|
|
141
|
+
declare abstract class JevStageError extends Error {
|
|
142
|
+
abstract readonly code: string;
|
|
143
|
+
readonly exitCode: number;
|
|
144
|
+
}
|
|
145
|
+
declare class UsageError extends JevStageError {
|
|
146
|
+
readonly code = "usage";
|
|
147
|
+
readonly exitCode = 2;
|
|
148
|
+
constructor(message: string, options?: ErrorOptions);
|
|
149
|
+
}
|
|
150
|
+
declare class NotARepositoryError extends JevStageError {
|
|
151
|
+
readonly code = "not-a-repository";
|
|
152
|
+
constructor(message?: string, options?: ErrorOptions);
|
|
153
|
+
}
|
|
154
|
+
declare class UnbornRepositoryError extends JevStageError {
|
|
155
|
+
readonly code = "unborn-repository";
|
|
156
|
+
constructor(message?: string, options?: ErrorOptions);
|
|
157
|
+
}
|
|
158
|
+
declare class UnsupportedGitVersionError extends JevStageError {
|
|
159
|
+
readonly code = "unsupported-git-version";
|
|
160
|
+
readonly found: string;
|
|
161
|
+
readonly minimum: string;
|
|
162
|
+
constructor(found: string, minimum: string, options?: ErrorOptions);
|
|
163
|
+
}
|
|
164
|
+
declare class UnmergedEntriesError extends JevStageError {
|
|
165
|
+
readonly code = "unmerged-entries";
|
|
166
|
+
readonly paths: readonly string[];
|
|
167
|
+
constructor(paths: readonly string[], options?: ErrorOptions);
|
|
168
|
+
}
|
|
169
|
+
declare class UnsupportedEntryError extends JevStageError {
|
|
170
|
+
readonly code = "unsupported-entry";
|
|
171
|
+
readonly kind: UnsupportedEntryKind;
|
|
172
|
+
readonly paths: readonly string[];
|
|
173
|
+
constructor(kind: UnsupportedEntryKind, paths: readonly string[], options?: ErrorOptions);
|
|
174
|
+
}
|
|
175
|
+
declare class DiffParseError extends JevStageError {
|
|
176
|
+
readonly code = "diff-parse";
|
|
177
|
+
constructor(message: string, options?: ErrorOptions);
|
|
178
|
+
}
|
|
179
|
+
declare class UnknownHunkError extends JevStageError {
|
|
180
|
+
readonly code = "unknown-hunk";
|
|
181
|
+
readonly ids: readonly string[];
|
|
182
|
+
constructor(ids: readonly string[], options?: ErrorOptions);
|
|
183
|
+
}
|
|
184
|
+
declare class PatchApplyError extends JevStageError {
|
|
185
|
+
readonly code = "patch-apply";
|
|
186
|
+
readonly stderr: string;
|
|
187
|
+
constructor(stderr: string, options?: ErrorOptions);
|
|
188
|
+
}
|
|
189
|
+
declare class StaleSnapshotError extends JevStageError {
|
|
190
|
+
readonly code = "stale-snapshot";
|
|
191
|
+
readonly exitCode = 3;
|
|
192
|
+
readonly which: StaleSnapshotWhich;
|
|
193
|
+
constructor(which: StaleSnapshotWhich, options?: ErrorOptions);
|
|
194
|
+
}
|
|
195
|
+
declare class IndexLockedError extends JevStageError {
|
|
196
|
+
readonly code = "index-locked";
|
|
197
|
+
readonly exitCode = 3;
|
|
198
|
+
readonly lockPath: string;
|
|
199
|
+
constructor(lockPath: string, options?: ErrorOptions);
|
|
200
|
+
}
|
|
201
|
+
declare class MissingApiKeyError extends JevStageError {
|
|
202
|
+
readonly code = "missing-api-key";
|
|
203
|
+
constructor(message?: string, options?: ErrorOptions);
|
|
204
|
+
}
|
|
205
|
+
declare class GitCommandError extends JevStageError {
|
|
206
|
+
readonly code = "git-command";
|
|
207
|
+
readonly argv: readonly string[];
|
|
208
|
+
readonly gitExitCode: number;
|
|
209
|
+
readonly stderr: string;
|
|
210
|
+
constructor(argv: readonly string[], exitCode: number, stderr: string, options?: ErrorOptions);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
type Decision = "include" | "exclude" | "mixed";
|
|
214
|
+
type DecisionSource = "model" | "low-confidence" | "missing" | "invalid" | "too-large" | "provider-error" | "manual" | "no-provider";
|
|
215
|
+
type FileKind = "modified" | "added" | "deleted" | "mode-only";
|
|
216
|
+
interface Hunk {
|
|
217
|
+
id: string;
|
|
218
|
+
path: string;
|
|
219
|
+
ordinal: number;
|
|
220
|
+
header: string;
|
|
221
|
+
bytes: Buffer;
|
|
222
|
+
text: string;
|
|
223
|
+
added: number;
|
|
224
|
+
removed: number;
|
|
225
|
+
}
|
|
226
|
+
interface DiffFile {
|
|
227
|
+
path: string;
|
|
228
|
+
kind: FileKind;
|
|
229
|
+
headerBytes: Buffer;
|
|
230
|
+
hunks: Hunk[];
|
|
231
|
+
}
|
|
232
|
+
interface Snapshot {
|
|
233
|
+
workTree: string;
|
|
234
|
+
gitDir: string;
|
|
235
|
+
indexPath: string;
|
|
236
|
+
gitEnv: Record<string, string>;
|
|
237
|
+
headOid: string;
|
|
238
|
+
indexHash: string;
|
|
239
|
+
diffHash: string;
|
|
240
|
+
diffBytes: Buffer;
|
|
241
|
+
files: DiffFile[];
|
|
242
|
+
skipped: Array<{
|
|
243
|
+
path: string;
|
|
244
|
+
reason: "mode-only" | "empty-file";
|
|
245
|
+
}>;
|
|
246
|
+
}
|
|
247
|
+
interface HunkDecision {
|
|
248
|
+
hunkId: string;
|
|
249
|
+
decision: Decision;
|
|
250
|
+
source: DecisionSource;
|
|
251
|
+
confidence?: number;
|
|
252
|
+
probabilities?: Record<Decision, number>;
|
|
253
|
+
}
|
|
254
|
+
interface Plan {
|
|
255
|
+
intent: string;
|
|
256
|
+
exclude?: string;
|
|
257
|
+
threshold: number;
|
|
258
|
+
snapshot: Snapshot;
|
|
259
|
+
decisions: Map<string, HunkDecision>;
|
|
260
|
+
usage: {
|
|
261
|
+
requests: number;
|
|
262
|
+
inputTokens: number;
|
|
263
|
+
outputTokens: number;
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
interface StageResult {
|
|
267
|
+
stagedHunkIds: string[];
|
|
268
|
+
skippedMixedIds: string[];
|
|
269
|
+
patchBytes: Buffer;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
interface GitRunOptions {
|
|
273
|
+
cwd?: string;
|
|
274
|
+
env?: Record<string, string>;
|
|
275
|
+
stdin?: Buffer;
|
|
276
|
+
maxBuffer?: number;
|
|
277
|
+
}
|
|
278
|
+
interface GitRunResult {
|
|
279
|
+
stdout: Buffer;
|
|
280
|
+
stderr: string;
|
|
281
|
+
exitCode: number;
|
|
282
|
+
}
|
|
283
|
+
interface GitRunner {
|
|
284
|
+
run(args: string[], options?: GitRunOptions): Promise<GitRunResult>;
|
|
285
|
+
}
|
|
286
|
+
declare function createGitRunner(gitBinary?: string): GitRunner;
|
|
287
|
+
|
|
288
|
+
interface ApplyPatchToIndexOptions {
|
|
289
|
+
snapshot: Snapshot;
|
|
290
|
+
patch: Buffer;
|
|
291
|
+
git: GitRunner;
|
|
292
|
+
}
|
|
293
|
+
declare function applyPatchToIndex({ snapshot, patch, git, }: ApplyPatchToIndexOptions): Promise<void>;
|
|
294
|
+
declare function stageHunks(snapshot: Snapshot, selectedIds: ReadonlySet<string>, git: GitRunner): Promise<Buffer>;
|
|
295
|
+
declare function cleanupOwnedPaths(): void;
|
|
296
|
+
|
|
297
|
+
interface SelectionFileSummary {
|
|
298
|
+
path: string;
|
|
299
|
+
hunks: number;
|
|
300
|
+
added: number;
|
|
301
|
+
removed: number;
|
|
302
|
+
}
|
|
303
|
+
interface SelectionSummary {
|
|
304
|
+
files: number;
|
|
305
|
+
hunks: number;
|
|
306
|
+
added: number;
|
|
307
|
+
removed: number;
|
|
308
|
+
perFile: SelectionFileSummary[];
|
|
309
|
+
}
|
|
310
|
+
declare function composePatch(files: readonly DiffFile[], selectedIds: ReadonlySet<string>): Buffer;
|
|
311
|
+
declare function summarizeSelection(files: readonly DiffFile[], selectedIds: ReadonlySet<string>): SelectionSummary;
|
|
312
|
+
|
|
313
|
+
declare function parseUnifiedDiff(diff: Buffer): DiffFile[];
|
|
314
|
+
|
|
315
|
+
declare const DIFF_ARGS: readonly string[];
|
|
316
|
+
interface CaptureSnapshotOptions {
|
|
317
|
+
cwd: string;
|
|
318
|
+
git: GitRunner;
|
|
319
|
+
}
|
|
320
|
+
declare function captureSnapshot({ cwd, git }: CaptureSnapshotOptions): Promise<Snapshot>;
|
|
321
|
+
|
|
322
|
+
interface PlanSelectionOptions {
|
|
323
|
+
cwd: string;
|
|
324
|
+
intent: string;
|
|
325
|
+
exclude?: string | undefined;
|
|
326
|
+
threshold?: number | undefined;
|
|
327
|
+
provider?: JevProvider | undefined;
|
|
328
|
+
git?: GitRunner | undefined;
|
|
329
|
+
}
|
|
330
|
+
interface ApplySelectionOptions {
|
|
331
|
+
includeIds: readonly string[];
|
|
332
|
+
git?: GitRunner | undefined;
|
|
333
|
+
}
|
|
334
|
+
declare function planSelection(options: PlanSelectionOptions): Promise<Plan>;
|
|
335
|
+
declare function applySelection(plan: Plan, options: ApplySelectionOptions): Promise<StageResult>;
|
|
336
|
+
|
|
337
|
+
interface ClassifyUsage {
|
|
338
|
+
requests: number;
|
|
339
|
+
inputTokens: number;
|
|
340
|
+
outputTokens: number;
|
|
341
|
+
}
|
|
342
|
+
interface ClassifyHunksOptions {
|
|
343
|
+
snapshot: Snapshot;
|
|
344
|
+
intent: string;
|
|
345
|
+
exclude?: string | undefined;
|
|
346
|
+
threshold: number;
|
|
347
|
+
provider: JevProvider;
|
|
348
|
+
tokenCeiling?: number | undefined;
|
|
349
|
+
signal?: AbortSignal | undefined;
|
|
350
|
+
}
|
|
351
|
+
interface ClassifyHunksResult {
|
|
352
|
+
decisions: Map<string, HunkDecision>;
|
|
353
|
+
usage: ClassifyUsage;
|
|
354
|
+
}
|
|
355
|
+
declare function classifyHunks(options: ClassifyHunksOptions): Promise<ClassifyHunksResult>;
|
|
356
|
+
|
|
357
|
+
declare const DEFAULT_THRESHOLD = 0.6;
|
|
358
|
+
type PolicyDecision = Omit<HunkDecision, "hunkId">;
|
|
359
|
+
declare function decide(outcome: AnswerOutcome<Decision>, threshold: number): PolicyDecision;
|
|
360
|
+
|
|
361
|
+
export { type AnswerOutcome, type ApplyPatchToIndexOptions, type ApplySelectionOptions, CHARS_PER_TOKEN, type ChoiceAnswer, type ChoiceSpec, type ClassifyHunksOptions, type ClassifyHunksResult, type ClassifyRequest, type ClassifyResult, type ClassifyUsage, DEFAULT_CONCURRENCY, DEFAULT_PER_QUESTION_TOKENS, DEFAULT_THRESHOLD, DEFAULT_TOKEN_CEILING, DIFF_ARGS, type Decision, type DecisionSource, type DiffFile, DiffParseError, FakeProvider, type FakeScript, type FileKind, GitCommandError, type GitRunner, type Hunk, type HunkDecision, IndexLockedError, JevCoreError, type JevProvider, JevStageError, type JsonValue, MissingApiKeyError, NotARepositoryError, PatchApplyError, type Plan, type PlanSelectionOptions, type PolicyDecision, ProviderConfigError, ProviderError, type ProviderErrorOptions, RequestTooLargeError, type RunWindowsOptions, type ScriptedAnswer, type SelectionFileSummary, type SelectionSummary, type Snapshot, type StageResult, StaleSnapshotError, type StaleSnapshotWhich, TypeSafeJevProvider, type TypeSafeJevProviderOptions, UnbornRepositoryError, UnknownHunkError, UnmergedEntriesError, UnsupportedEntryError, type UnsupportedEntryKind, UnsupportedGitVersionError, UsageError, type Window, type WindowItem, type WindowOptions, applyPatchToIndex, applySelection, buildWindows, captureSnapshot, classifyHunks, cleanupOwnedPaths, composePatch, createGitRunner, createProviderFromEnv, decide, estimateJsonTokens, estimateTokens, parseUnifiedDiff, planSelection, runWindows, stageHunks, summarizeSelection, validateChoiceAnswer };
|