@stupify/cli 0.0.15 → 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/.review/CORPUS.md +73 -0
- package/.review/REVIEW-PROMPT.md +52 -0
- package/.review/RUBRIC.md +46 -0
- package/LICENSE +1 -1
- package/README.md +41 -39
- package/package.json +24 -25
- package/src/cli.ts +358 -0
- package/src/review-sweep.ts +492 -0
- package/dist/analysis.d.ts +0 -16
- package/dist/analysis.js +0 -165
- package/dist/cache.d.ts +0 -2
- package/dist/cache.js +0 -57
- package/dist/checks.d.ts +0 -4
- package/dist/checks.js +0 -228
- package/dist/command.d.ts +0 -2
- package/dist/command.js +0 -147
- package/dist/constants.d.ts +0 -4
- package/dist/constants.js +0 -53
- package/dist/counter-scout.d.ts +0 -21
- package/dist/counter-scout.js +0 -167
- package/dist/diff.d.ts +0 -1
- package/dist/diff.js +0 -10
- package/dist/doctor.d.ts +0 -4
- package/dist/doctor.js +0 -131
- package/dist/git.d.ts +0 -12
- package/dist/git.js +0 -298
- package/dist/hooks.d.ts +0 -3
- package/dist/hooks.js +0 -117
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/model.d.ts +0 -11
- package/dist/model.js +0 -296
- package/dist/prompts.d.ts +0 -8
- package/dist/prompts.js +0 -89
- package/dist/render.d.ts +0 -3
- package/dist/render.js +0 -151
- package/dist/repomix-provider.d.ts +0 -12
- package/dist/repomix-provider.js +0 -196
- package/dist/search-bench.d.ts +0 -1
- package/dist/search-bench.js +0 -677
- package/dist/search-profile.d.ts +0 -6
- package/dist/search-profile.js +0 -73
- package/dist/sem-provider.d.ts +0 -2
- package/dist/sem-provider.js +0 -252
- package/dist/stupify.d.ts +0 -38
- package/dist/stupify.js +0 -474
- package/dist/trace.d.ts +0 -31
- package/dist/trace.js +0 -86
- package/dist/types.d.ts +0 -328
- package/dist/types.js +0 -6
- package/dist/ui.d.ts +0 -34
- package/dist/ui.js +0 -143
- package/src/analysis.ts +0 -220
- package/src/cache.ts +0 -63
- package/src/checks.ts +0 -231
- package/src/command.ts +0 -173
- package/src/constants.ts +0 -56
- package/src/counter-scout.ts +0 -195
- package/src/diff.ts +0 -9
- package/src/doctor.ts +0 -140
- package/src/git.ts +0 -306
- package/src/hooks.ts +0 -134
- package/src/index.ts +0 -1
- package/src/model.ts +0 -367
- package/src/prompts.ts +0 -100
- package/src/render.ts +0 -154
- package/src/repomix-provider.ts +0 -219
- package/src/search-bench.ts +0 -783
- package/src/search-profile.ts +0 -89
- package/src/sem-provider.ts +0 -297
- package/src/stupify.ts +0 -571
- package/src/trace.ts +0 -126
- package/src/types.ts +0 -348
- package/src/ui.ts +0 -187
package/dist/types.d.ts
DELETED
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
declare const brand: unique symbol;
|
|
2
|
-
type Brand<Value, Name extends string> = Value & {
|
|
3
|
-
readonly [brand]: Name;
|
|
4
|
-
};
|
|
5
|
-
export type SourceId = Brand<string, "SourceId">;
|
|
6
|
-
export type CheckId = Brand<string, "CheckId">;
|
|
7
|
-
export declare function sourceId(value: string): SourceId;
|
|
8
|
-
export declare function checkId(value: string): CheckId;
|
|
9
|
-
export type SearchMode = "warn" | "off";
|
|
10
|
-
export type HookAction = "install" | "uninstall" | "status";
|
|
11
|
-
export type SearchSource = "since" | "stdin" | "commit" | "commits" | "staged";
|
|
12
|
-
type SearchOptions = Readonly<{
|
|
13
|
-
checkIds: readonly string[] | null;
|
|
14
|
-
json: boolean;
|
|
15
|
-
model: ModelId;
|
|
16
|
-
debugSem: boolean;
|
|
17
|
-
maxCandidates: number;
|
|
18
|
-
maxSearchInputTokens: number;
|
|
19
|
-
searchProfilePath: string | null;
|
|
20
|
-
includeCounterReasonInPrompt: boolean;
|
|
21
|
-
}>;
|
|
22
|
-
export type Command = Readonly<{
|
|
23
|
-
kind: "help";
|
|
24
|
-
}> | Readonly<{
|
|
25
|
-
kind: "hook";
|
|
26
|
-
action: HookAction;
|
|
27
|
-
}> | Readonly<{
|
|
28
|
-
kind: "doctor";
|
|
29
|
-
}> | Readonly<{
|
|
30
|
-
kind: "bench-search";
|
|
31
|
-
configPath: string;
|
|
32
|
-
}> | (Readonly<{
|
|
33
|
-
kind: "since";
|
|
34
|
-
since: string;
|
|
35
|
-
mode: "search";
|
|
36
|
-
source: "since";
|
|
37
|
-
}> & SearchOptions) | (Readonly<{
|
|
38
|
-
kind: "stdin";
|
|
39
|
-
mode: "search";
|
|
40
|
-
source: "stdin";
|
|
41
|
-
}> & SearchOptions) | (Readonly<{
|
|
42
|
-
kind: "commit";
|
|
43
|
-
commit: string;
|
|
44
|
-
mode: "search";
|
|
45
|
-
source: "commit";
|
|
46
|
-
}> & SearchOptions) | (Readonly<{
|
|
47
|
-
kind: "commits";
|
|
48
|
-
count: number;
|
|
49
|
-
mode: "search";
|
|
50
|
-
source: "commits";
|
|
51
|
-
}> & SearchOptions) | (Readonly<{
|
|
52
|
-
kind: "staged";
|
|
53
|
-
mode: "search";
|
|
54
|
-
source: "staged";
|
|
55
|
-
}> & SearchOptions);
|
|
56
|
-
export type SearchCommand = Exclude<Command, Readonly<{
|
|
57
|
-
kind: "help";
|
|
58
|
-
}> | Readonly<{
|
|
59
|
-
kind: "hook";
|
|
60
|
-
action: HookAction;
|
|
61
|
-
}> | Readonly<{
|
|
62
|
-
kind: "doctor";
|
|
63
|
-
}> | Readonly<{
|
|
64
|
-
kind: "bench-search";
|
|
65
|
-
configPath: string;
|
|
66
|
-
}>>;
|
|
67
|
-
export type StupifyCheck = Readonly<{
|
|
68
|
-
id: CheckId;
|
|
69
|
-
name: string;
|
|
70
|
-
question: string;
|
|
71
|
-
why: string;
|
|
72
|
-
lookFor: readonly string[];
|
|
73
|
-
ignoreWhen: readonly string[];
|
|
74
|
-
enabledByDefault?: boolean;
|
|
75
|
-
hookMode?: SearchMode;
|
|
76
|
-
searchPrompt?: string;
|
|
77
|
-
searchExamples?: Readonly<{
|
|
78
|
-
match: readonly string[];
|
|
79
|
-
nonMatch: readonly string[];
|
|
80
|
-
}>;
|
|
81
|
-
examples?: Readonly<{
|
|
82
|
-
match?: readonly string[];
|
|
83
|
-
noMatch?: readonly string[];
|
|
84
|
-
}>;
|
|
85
|
-
}>;
|
|
86
|
-
export type NetDiffStats = Readonly<{
|
|
87
|
-
filesChanged: number;
|
|
88
|
-
additions: number;
|
|
89
|
-
deletions: number;
|
|
90
|
-
}>;
|
|
91
|
-
export type StagedDiff = Readonly<{
|
|
92
|
-
text: string;
|
|
93
|
-
stats: NetDiffStats;
|
|
94
|
-
}>;
|
|
95
|
-
export type NetDiff = Readonly<{
|
|
96
|
-
id: SourceId;
|
|
97
|
-
label: string;
|
|
98
|
-
base: string;
|
|
99
|
-
target: string;
|
|
100
|
-
text: string;
|
|
101
|
-
stats: NetDiffStats;
|
|
102
|
-
}>;
|
|
103
|
-
export type SourceRange = Readonly<{
|
|
104
|
-
id: SourceId;
|
|
105
|
-
label: string;
|
|
106
|
-
base: string;
|
|
107
|
-
target: string;
|
|
108
|
-
committers?: readonly string[];
|
|
109
|
-
stats: NetDiffStats;
|
|
110
|
-
}>;
|
|
111
|
-
export type SemChange = Readonly<{
|
|
112
|
-
entityId: string;
|
|
113
|
-
entityName: string;
|
|
114
|
-
entityType: string;
|
|
115
|
-
filePath: string;
|
|
116
|
-
changeType: string;
|
|
117
|
-
beforeContent: string | null;
|
|
118
|
-
afterContent: string | null;
|
|
119
|
-
}>;
|
|
120
|
-
export type SemChangeSummary = Readonly<{
|
|
121
|
-
added: number;
|
|
122
|
-
deleted: number;
|
|
123
|
-
modified: number;
|
|
124
|
-
moved: number;
|
|
125
|
-
renamed: number;
|
|
126
|
-
fileCount: number;
|
|
127
|
-
total: number;
|
|
128
|
-
}>;
|
|
129
|
-
export type SemChangeSet = Readonly<{
|
|
130
|
-
id: SourceId;
|
|
131
|
-
label: string;
|
|
132
|
-
base: string;
|
|
133
|
-
target: string;
|
|
134
|
-
committers?: readonly string[];
|
|
135
|
-
contextCwd: string;
|
|
136
|
-
cleanup: () => Promise<void>;
|
|
137
|
-
changes: readonly SemChange[];
|
|
138
|
-
summary: SemChangeSummary;
|
|
139
|
-
}>;
|
|
140
|
-
export type SemCandidate = Readonly<{
|
|
141
|
-
sourceId: SourceId;
|
|
142
|
-
targetId: string;
|
|
143
|
-
entityId: string;
|
|
144
|
-
checkId: CheckId;
|
|
145
|
-
reason: string;
|
|
146
|
-
}>;
|
|
147
|
-
export type SemContext = Readonly<{
|
|
148
|
-
targetId: string;
|
|
149
|
-
entityId: string;
|
|
150
|
-
entityName: string;
|
|
151
|
-
entityKind: string;
|
|
152
|
-
changeKind: string;
|
|
153
|
-
checkId: CheckId;
|
|
154
|
-
reason: string;
|
|
155
|
-
filePath?: string;
|
|
156
|
-
text: string;
|
|
157
|
-
}>;
|
|
158
|
-
export type SemContextPack = Readonly<{
|
|
159
|
-
provider: "repomix";
|
|
160
|
-
filePaths: readonly string[];
|
|
161
|
-
totalCharacters: number;
|
|
162
|
-
totalTokens: number;
|
|
163
|
-
text: string;
|
|
164
|
-
config: RepomixSearchConfig;
|
|
165
|
-
}>;
|
|
166
|
-
export type RepomixSearchConfig = Readonly<{
|
|
167
|
-
compress: boolean;
|
|
168
|
-
showLineNumbers: boolean;
|
|
169
|
-
removeEmptyLines: boolean;
|
|
170
|
-
maxFileSizeBytes: number;
|
|
171
|
-
maxTotalSizeBytes: number;
|
|
172
|
-
ignorePatterns: readonly string[];
|
|
173
|
-
}>;
|
|
174
|
-
export type SearchProfileRepomixConfig = Readonly<{
|
|
175
|
-
compress?: boolean;
|
|
176
|
-
showLineNumbers?: boolean;
|
|
177
|
-
removeEmptyLines?: boolean;
|
|
178
|
-
maxFileBytes?: number;
|
|
179
|
-
maxTotalBytes?: number;
|
|
180
|
-
ignorePatterns?: readonly string[];
|
|
181
|
-
}>;
|
|
182
|
-
export type SearchProfilePattern = Readonly<{
|
|
183
|
-
enabled?: boolean;
|
|
184
|
-
searchPrompt?: string;
|
|
185
|
-
matchExamples?: readonly string[];
|
|
186
|
-
nonMatchExamples?: readonly string[];
|
|
187
|
-
}>;
|
|
188
|
-
export type SearchProfile = Readonly<{
|
|
189
|
-
id: string;
|
|
190
|
-
context?: "repomix" | "sem";
|
|
191
|
-
maxCandidates?: number;
|
|
192
|
-
maxSearchInputTokens?: number;
|
|
193
|
-
includeCounterReasonInPrompt?: boolean;
|
|
194
|
-
repomix?: SearchProfileRepomixConfig;
|
|
195
|
-
patterns?: Readonly<Record<string, SearchProfilePattern>>;
|
|
196
|
-
}>;
|
|
197
|
-
export type SearchMatch = Readonly<{
|
|
198
|
-
targetId: string;
|
|
199
|
-
patternId: CheckId;
|
|
200
|
-
checkWhy?: string;
|
|
201
|
-
reason: string;
|
|
202
|
-
proof: string;
|
|
203
|
-
snapshot?: string;
|
|
204
|
-
}>;
|
|
205
|
-
export type SearchRunJson = Readonly<{
|
|
206
|
-
schemaVersion: "search.v1";
|
|
207
|
-
mode: "search";
|
|
208
|
-
source: SearchSource;
|
|
209
|
-
model: Readonly<{
|
|
210
|
-
id: ModelId;
|
|
211
|
-
}>;
|
|
212
|
-
patterns: readonly CheckId[];
|
|
213
|
-
stats: Readonly<{
|
|
214
|
-
elapsedMs: number;
|
|
215
|
-
modelCalls: number;
|
|
216
|
-
inputTokens?: number;
|
|
217
|
-
inputTokenCap?: number;
|
|
218
|
-
skipped?: boolean;
|
|
219
|
-
skipReason?: "input_too_large" | "no_candidates";
|
|
220
|
-
committers?: readonly string[];
|
|
221
|
-
filesChanged?: number;
|
|
222
|
-
entitiesScanned?: number;
|
|
223
|
-
candidates?: number;
|
|
224
|
-
repomixFiles?: number;
|
|
225
|
-
repomixTokens?: number;
|
|
226
|
-
repomixConfig?: RepomixSearchConfig;
|
|
227
|
-
searchTargets?: number;
|
|
228
|
-
searchBatches?: number;
|
|
229
|
-
skippedTargets?: number;
|
|
230
|
-
profileId?: string;
|
|
231
|
-
targetsByPattern?: Readonly<Record<string, number>>;
|
|
232
|
-
targetsPreview?: readonly SearchTargetPreview[];
|
|
233
|
-
}>;
|
|
234
|
-
matches: readonly SearchMatch[];
|
|
235
|
-
}>;
|
|
236
|
-
export type SearchTargetPreview = Readonly<{
|
|
237
|
-
targetId: string;
|
|
238
|
-
patternId: CheckId;
|
|
239
|
-
entityKind?: string;
|
|
240
|
-
sourceKind?: string;
|
|
241
|
-
}>;
|
|
242
|
-
export type SearchBenchConfig = Readonly<{
|
|
243
|
-
name: string;
|
|
244
|
-
profiles: readonly string[];
|
|
245
|
-
fixtures: string;
|
|
246
|
-
realSmokeRuns?: readonly SearchBenchSmokeRun[];
|
|
247
|
-
realCommitReplay?: readonly SearchBenchCommitReplay[];
|
|
248
|
-
}>;
|
|
249
|
-
export type SearchBenchSmokeRun = Readonly<{
|
|
250
|
-
id: string;
|
|
251
|
-
cwd?: string;
|
|
252
|
-
args: readonly string[];
|
|
253
|
-
}>;
|
|
254
|
-
export type SearchBenchCommitReplay = Readonly<{
|
|
255
|
-
id: string;
|
|
256
|
-
repoEnv?: string;
|
|
257
|
-
cwd?: string;
|
|
258
|
-
limit: number;
|
|
259
|
-
since?: string;
|
|
260
|
-
nonMerge?: boolean;
|
|
261
|
-
profiles: readonly string[];
|
|
262
|
-
}>;
|
|
263
|
-
export type SearchFixture = Readonly<{
|
|
264
|
-
id: string;
|
|
265
|
-
description: string;
|
|
266
|
-
stagedPatch: string;
|
|
267
|
-
checks: readonly string[];
|
|
268
|
-
expected: readonly SearchFixtureExpectation[];
|
|
269
|
-
}>;
|
|
270
|
-
export type SearchFixtureExpectation = Readonly<{
|
|
271
|
-
patternId: string;
|
|
272
|
-
shouldMatch: boolean;
|
|
273
|
-
}>;
|
|
274
|
-
export type SearchBenchRun = Readonly<{
|
|
275
|
-
profileId: string;
|
|
276
|
-
fixtureId?: string;
|
|
277
|
-
smokeId?: string;
|
|
278
|
-
elapsedMs: number;
|
|
279
|
-
modelCalls: number;
|
|
280
|
-
patterns: readonly CheckId[];
|
|
281
|
-
targets: number;
|
|
282
|
-
targetsByPattern: Readonly<Record<string, number>>;
|
|
283
|
-
inputTokens: number;
|
|
284
|
-
repomixPackedTokens?: number;
|
|
285
|
-
skipped: boolean;
|
|
286
|
-
skipReason?: string;
|
|
287
|
-
matches: readonly SearchMatch[];
|
|
288
|
-
expected?: readonly SearchFixtureExpectation[];
|
|
289
|
-
score?: number;
|
|
290
|
-
targetsPreview: readonly SearchTargetPreview[];
|
|
291
|
-
matchesUsingCounterReasonAsProof: number;
|
|
292
|
-
error?: string;
|
|
293
|
-
}>;
|
|
294
|
-
export type SearchBenchReplayRun = Readonly<{
|
|
295
|
-
profileId: string;
|
|
296
|
-
replayId: string;
|
|
297
|
-
commitId: string;
|
|
298
|
-
outcome: SearchReplayOutcome;
|
|
299
|
-
changedFiles: number;
|
|
300
|
-
addedLines: number;
|
|
301
|
-
deletedLines: number;
|
|
302
|
-
elapsedMs: number;
|
|
303
|
-
skipped: boolean;
|
|
304
|
-
skipReason?: string;
|
|
305
|
-
targets: number;
|
|
306
|
-
inputTokens: number;
|
|
307
|
-
repomixPackedTokens?: number;
|
|
308
|
-
modelCalls: number;
|
|
309
|
-
matches: readonly SearchMatch[];
|
|
310
|
-
matchesByPattern: Readonly<Record<string, number>>;
|
|
311
|
-
error?: string;
|
|
312
|
-
}>;
|
|
313
|
-
export type SearchReplayOutcome = "no_candidates" | "ran_no_matches" | "ran_with_matches" | "skipped_input_too_large" | "error";
|
|
314
|
-
export type ModelId = "gemma-4-e2b" | "gemma-4-e4b" | "gemma-4-26b-a4b" | "qwen3-4b-magicquant" | "qwen2.5-coder-1.5b" | "qwen2.5-coder-7b" | "qwen2.5-coder-32b";
|
|
315
|
-
export type ModelConfig = Readonly<{
|
|
316
|
-
id: ModelId;
|
|
317
|
-
name: string;
|
|
318
|
-
file: string;
|
|
319
|
-
url: string;
|
|
320
|
-
size: string;
|
|
321
|
-
}>;
|
|
322
|
-
export type TraceEvent = Readonly<{
|
|
323
|
-
name: string;
|
|
324
|
-
ms: number;
|
|
325
|
-
count?: number;
|
|
326
|
-
detail?: string;
|
|
327
|
-
}>;
|
|
328
|
-
export {};
|
package/dist/types.js
DELETED
package/dist/ui.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type SpinnerResult } from "@clack/prompts";
|
|
2
|
-
export type CliUi = ReturnType<typeof createCliUi>;
|
|
3
|
-
export type CliUiOptions = Readonly<{
|
|
4
|
-
quiet?: boolean;
|
|
5
|
-
}>;
|
|
6
|
-
type LogOptions = Readonly<{
|
|
7
|
-
force?: boolean;
|
|
8
|
-
}>;
|
|
9
|
-
export declare function createCliUi(options?: CliUiOptions): {
|
|
10
|
-
intro(title: string, logOptions?: LogOptions): void;
|
|
11
|
-
outro(message: string, logOptions?: LogOptions): void;
|
|
12
|
-
note(message: string, title?: string, logOptions?: LogOptions): void;
|
|
13
|
-
info(message: string, logOptions?: LogOptions): void;
|
|
14
|
-
step(message: string, logOptions?: LogOptions): void;
|
|
15
|
-
success(message: string, logOptions?: LogOptions): void;
|
|
16
|
-
warn(message: string, logOptions?: LogOptions): void;
|
|
17
|
-
error(message: string, logOptions?: LogOptions): void;
|
|
18
|
-
debug(message: string): void;
|
|
19
|
-
confirm(message: string): Promise<boolean>;
|
|
20
|
-
spinner(message: string, logOptions?: LogOptions): SpinnerResult;
|
|
21
|
-
progress(message: string, max: number, logOptions?: LogOptions): import("@clack/prompts").ProgressResult;
|
|
22
|
-
writeStdout(text: string): void;
|
|
23
|
-
};
|
|
24
|
-
export declare const format: {
|
|
25
|
-
heading: (value: string) => string;
|
|
26
|
-
label: (value: string) => string;
|
|
27
|
-
muted: (value: string) => string;
|
|
28
|
-
success: (value: string) => string;
|
|
29
|
-
warn: (value: string) => string;
|
|
30
|
-
error: (value: string) => string;
|
|
31
|
-
};
|
|
32
|
-
export declare function diagnostic(message: string): void;
|
|
33
|
-
export declare function diagnosticError(message: string): void;
|
|
34
|
-
export {};
|
package/dist/ui.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { confirm as clackConfirm, intro as clackIntro, isCancel, log, note, outro as clackOutro, progress, spinner, } from "@clack/prompts";
|
|
2
|
-
import { createReadStream, createWriteStream } from "node:fs";
|
|
3
|
-
import { platform } from "node:os";
|
|
4
|
-
import { stdin, stderr, stdout } from "node:process";
|
|
5
|
-
import pc from "picocolors";
|
|
6
|
-
export function createCliUi(options = {}) {
|
|
7
|
-
const quiet = options.quiet ?? false;
|
|
8
|
-
const output = stderr;
|
|
9
|
-
function shouldWrite(logOptions) {
|
|
10
|
-
return logOptions?.force === true || !quiet;
|
|
11
|
-
}
|
|
12
|
-
function withPromptIo(run) {
|
|
13
|
-
const io = promptIo();
|
|
14
|
-
return run(io).finally(() => io.close());
|
|
15
|
-
}
|
|
16
|
-
return {
|
|
17
|
-
intro(title, logOptions) {
|
|
18
|
-
if (shouldWrite(logOptions))
|
|
19
|
-
clackIntro(title, { output });
|
|
20
|
-
},
|
|
21
|
-
outro(message, logOptions) {
|
|
22
|
-
if (shouldWrite(logOptions))
|
|
23
|
-
clackOutro(message, { output });
|
|
24
|
-
},
|
|
25
|
-
note(message, title, logOptions) {
|
|
26
|
-
if (shouldWrite(logOptions))
|
|
27
|
-
note(message, title, { output });
|
|
28
|
-
},
|
|
29
|
-
info(message, logOptions) {
|
|
30
|
-
if (shouldWrite(logOptions))
|
|
31
|
-
log.info(message, { output });
|
|
32
|
-
},
|
|
33
|
-
step(message, logOptions) {
|
|
34
|
-
if (shouldWrite(logOptions))
|
|
35
|
-
log.step(message, { output });
|
|
36
|
-
},
|
|
37
|
-
success(message, logOptions) {
|
|
38
|
-
if (shouldWrite(logOptions))
|
|
39
|
-
log.success(message, { output });
|
|
40
|
-
},
|
|
41
|
-
warn(message, logOptions) {
|
|
42
|
-
if (shouldWrite(logOptions))
|
|
43
|
-
log.warn(message, { output });
|
|
44
|
-
},
|
|
45
|
-
error(message, logOptions) {
|
|
46
|
-
if (shouldWrite(logOptions))
|
|
47
|
-
log.error(message, { output });
|
|
48
|
-
},
|
|
49
|
-
debug(message) {
|
|
50
|
-
if (!quiet)
|
|
51
|
-
log.message(message, { output, symbol: pc.dim("trace") });
|
|
52
|
-
},
|
|
53
|
-
async confirm(message) {
|
|
54
|
-
return withPromptIo(async (io) => {
|
|
55
|
-
const result = await clackConfirm({
|
|
56
|
-
message,
|
|
57
|
-
active: "Yes",
|
|
58
|
-
inactive: "No",
|
|
59
|
-
initialValue: false,
|
|
60
|
-
input: io.input,
|
|
61
|
-
output: io.output,
|
|
62
|
-
});
|
|
63
|
-
if (isCancel(result))
|
|
64
|
-
return false;
|
|
65
|
-
return result;
|
|
66
|
-
});
|
|
67
|
-
},
|
|
68
|
-
spinner(message, logOptions) {
|
|
69
|
-
if (!shouldWrite(logOptions))
|
|
70
|
-
return silentSpinner();
|
|
71
|
-
const active = spinner({ output });
|
|
72
|
-
active.start(message);
|
|
73
|
-
return active;
|
|
74
|
-
},
|
|
75
|
-
progress(message, max, logOptions) {
|
|
76
|
-
if (!shouldWrite(logOptions))
|
|
77
|
-
return silentProgress();
|
|
78
|
-
const active = progress({ output, max });
|
|
79
|
-
active.start(message);
|
|
80
|
-
return active;
|
|
81
|
-
},
|
|
82
|
-
writeStdout(text) {
|
|
83
|
-
stdout.write(text.endsWith("\n") ? text : `${text}\n`);
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
export const format = {
|
|
88
|
-
heading: (value) => pc.bold(value),
|
|
89
|
-
label: (value) => pc.cyan(value),
|
|
90
|
-
muted: (value) => pc.dim(value),
|
|
91
|
-
success: (value) => pc.green(value),
|
|
92
|
-
warn: (value) => pc.yellow(value),
|
|
93
|
-
error: (value) => pc.red(value),
|
|
94
|
-
};
|
|
95
|
-
export function diagnostic(message) {
|
|
96
|
-
log.message(message, {
|
|
97
|
-
output: stderr,
|
|
98
|
-
symbol: pc.dim("·"),
|
|
99
|
-
spacing: 0,
|
|
100
|
-
withGuide: false,
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
export function diagnosticError(message) {
|
|
104
|
-
log.error(message, { output: stderr, spacing: 0, withGuide: false });
|
|
105
|
-
}
|
|
106
|
-
function promptIo() {
|
|
107
|
-
if (stdin.isTTY && stderr.isTTY) {
|
|
108
|
-
return { input: stdin, output: stderr, close: () => undefined };
|
|
109
|
-
}
|
|
110
|
-
if (platform() === "win32") {
|
|
111
|
-
throw new Error("No interactive terminal found. Run `stupify` once in an interactive terminal to set up the model.");
|
|
112
|
-
}
|
|
113
|
-
const input = createReadStream("/dev/tty");
|
|
114
|
-
const output = createWriteStream("/dev/tty");
|
|
115
|
-
return {
|
|
116
|
-
input,
|
|
117
|
-
output,
|
|
118
|
-
close: () => closePromptIo(input, output),
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
function closePromptIo(input, output) {
|
|
122
|
-
input.destroy();
|
|
123
|
-
output.end();
|
|
124
|
-
}
|
|
125
|
-
function silentSpinner() {
|
|
126
|
-
return {
|
|
127
|
-
start: () => undefined,
|
|
128
|
-
stop: () => undefined,
|
|
129
|
-
cancel: () => undefined,
|
|
130
|
-
error: () => undefined,
|
|
131
|
-
message: () => undefined,
|
|
132
|
-
clear: () => undefined,
|
|
133
|
-
get isCancelled() {
|
|
134
|
-
return false;
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
function silentProgress() {
|
|
139
|
-
return {
|
|
140
|
-
...silentSpinner(),
|
|
141
|
-
advance: () => undefined,
|
|
142
|
-
};
|
|
143
|
-
}
|