@p10i/rundown 1.0.0-rc.12
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/LICENSE +21 -0
- package/README.md +192 -0
- package/dist/cli.js +2585 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +397 -0
- package/dist/index.js +2328 -0
- package/dist/index.js.map +1 -0
- package/package.json +71 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown AST-based task parser.
|
|
3
|
+
*
|
|
4
|
+
* Uses mdast to walk the parsed Markdown tree and extract task list items.
|
|
5
|
+
* Fenced code blocks and other non-task structures are naturally excluded
|
|
6
|
+
* by the AST — no regex guessing required.
|
|
7
|
+
*/
|
|
8
|
+
/** Represents a single task extracted from a Markdown document. */
|
|
9
|
+
interface Task {
|
|
10
|
+
/** The text content of the task item. */
|
|
11
|
+
text: string;
|
|
12
|
+
/** Whether the checkbox is checked. */
|
|
13
|
+
checked: boolean;
|
|
14
|
+
/** Zero-based index among all tasks in the document. */
|
|
15
|
+
index: number;
|
|
16
|
+
/** 1-based line number in the source file. */
|
|
17
|
+
line: number;
|
|
18
|
+
/** Column offset of the checkbox in the source line. */
|
|
19
|
+
column: number;
|
|
20
|
+
/** Byte offset of the start of this node in the source. */
|
|
21
|
+
offsetStart: number;
|
|
22
|
+
/** Byte offset of the end of this node in the source. */
|
|
23
|
+
offsetEnd: number;
|
|
24
|
+
/** The source file path (set later by the caller). */
|
|
25
|
+
file: string;
|
|
26
|
+
/** Whether this is an inline CLI task (starts with "cli: "). */
|
|
27
|
+
isInlineCli: boolean;
|
|
28
|
+
/** If inline CLI, the command string. */
|
|
29
|
+
cliCommand?: string;
|
|
30
|
+
/** Nesting depth (0 = top-level list item). */
|
|
31
|
+
depth: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* File sorting.
|
|
36
|
+
*
|
|
37
|
+
* Provides sorting strategies for resolved Markdown file paths.
|
|
38
|
+
*/
|
|
39
|
+
type SortMode = "name-sort" | "none" | "old-first" | "new-first";
|
|
40
|
+
|
|
41
|
+
interface FileSystemStat {
|
|
42
|
+
isFile: boolean;
|
|
43
|
+
isDirectory: boolean;
|
|
44
|
+
birthtimeMs?: number;
|
|
45
|
+
mtimeMs?: number;
|
|
46
|
+
}
|
|
47
|
+
interface FileSystemDirent {
|
|
48
|
+
name: string;
|
|
49
|
+
isFile: boolean;
|
|
50
|
+
isDirectory: boolean;
|
|
51
|
+
}
|
|
52
|
+
interface FileSystem {
|
|
53
|
+
exists(path: string): boolean;
|
|
54
|
+
readText(filePath: string): string;
|
|
55
|
+
writeText(filePath: string, content: string): void;
|
|
56
|
+
mkdir(dirPath: string, options?: {
|
|
57
|
+
recursive?: boolean;
|
|
58
|
+
}): void;
|
|
59
|
+
readdir(dirPath: string): FileSystemDirent[];
|
|
60
|
+
stat(path: string): FileSystemStat | null;
|
|
61
|
+
unlink(filePath: string): void;
|
|
62
|
+
rm(path: string, options?: {
|
|
63
|
+
recursive?: boolean;
|
|
64
|
+
force?: boolean;
|
|
65
|
+
}): void;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type ProcessRunMode = "wait" | "tui" | "detached";
|
|
69
|
+
interface ProcessRunOptions {
|
|
70
|
+
command: string;
|
|
71
|
+
args: string[];
|
|
72
|
+
cwd: string;
|
|
73
|
+
mode: ProcessRunMode;
|
|
74
|
+
shell?: boolean;
|
|
75
|
+
env?: Record<string, string | undefined>;
|
|
76
|
+
timeoutMs?: number;
|
|
77
|
+
}
|
|
78
|
+
interface ProcessRunResult {
|
|
79
|
+
exitCode: number | null;
|
|
80
|
+
stdout: string;
|
|
81
|
+
stderr: string;
|
|
82
|
+
}
|
|
83
|
+
interface ProcessRunner {
|
|
84
|
+
run(options: ProcessRunOptions): Promise<ProcessRunResult>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
interface GitClient {
|
|
88
|
+
run(args: string[], cwd: string, options?: {
|
|
89
|
+
timeoutMs?: number;
|
|
90
|
+
}): Promise<string>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
interface TemplateLoader {
|
|
94
|
+
load(filePath: string): string | null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
interface ValidationSidecar {
|
|
98
|
+
filePath(task: Task): string;
|
|
99
|
+
read(task: Task): string | null;
|
|
100
|
+
remove(task: Task): void;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
type ArtifactStoreStatus = "running" | "completed" | "failed" | "detached" | string;
|
|
104
|
+
type ArtifactStorePhase = "execute" | "verify" | "repair" | "plan" | "inline-cli" | "worker";
|
|
105
|
+
interface ArtifactTaskMetadata {
|
|
106
|
+
text: string;
|
|
107
|
+
file: string;
|
|
108
|
+
line: number;
|
|
109
|
+
index: number;
|
|
110
|
+
source: string;
|
|
111
|
+
}
|
|
112
|
+
interface ArtifactRunContext {
|
|
113
|
+
runId: string;
|
|
114
|
+
rootDir: string;
|
|
115
|
+
cwd: string;
|
|
116
|
+
keepArtifacts: boolean;
|
|
117
|
+
commandName: string;
|
|
118
|
+
workerCommand?: string[];
|
|
119
|
+
mode?: string;
|
|
120
|
+
transport?: string;
|
|
121
|
+
task?: ArtifactTaskMetadata;
|
|
122
|
+
}
|
|
123
|
+
interface ArtifactPhaseHandle {
|
|
124
|
+
context: ArtifactRunContext;
|
|
125
|
+
phase: ArtifactStorePhase;
|
|
126
|
+
sequence: number;
|
|
127
|
+
dir: string;
|
|
128
|
+
promptFile: string | null;
|
|
129
|
+
}
|
|
130
|
+
interface ArtifactRunMetadata {
|
|
131
|
+
runId: string;
|
|
132
|
+
rootDir: string;
|
|
133
|
+
relativePath: string;
|
|
134
|
+
commandName: string;
|
|
135
|
+
workerCommand?: string[];
|
|
136
|
+
mode?: string;
|
|
137
|
+
transport?: string;
|
|
138
|
+
source?: string;
|
|
139
|
+
task?: ArtifactTaskMetadata;
|
|
140
|
+
keepArtifacts: boolean;
|
|
141
|
+
startedAt: string;
|
|
142
|
+
completedAt?: string;
|
|
143
|
+
status?: string;
|
|
144
|
+
}
|
|
145
|
+
interface ArtifactStore {
|
|
146
|
+
createContext(options: {
|
|
147
|
+
cwd?: string;
|
|
148
|
+
commandName: string;
|
|
149
|
+
workerCommand?: string[];
|
|
150
|
+
mode?: string;
|
|
151
|
+
transport?: string;
|
|
152
|
+
source?: string;
|
|
153
|
+
task?: ArtifactTaskMetadata;
|
|
154
|
+
keepArtifacts?: boolean;
|
|
155
|
+
}): ArtifactRunContext;
|
|
156
|
+
beginPhase(context: ArtifactRunContext, options: {
|
|
157
|
+
phase: ArtifactStorePhase;
|
|
158
|
+
prompt?: string;
|
|
159
|
+
command?: string[];
|
|
160
|
+
mode?: string;
|
|
161
|
+
transport?: string;
|
|
162
|
+
notes?: string;
|
|
163
|
+
extra?: Record<string, unknown>;
|
|
164
|
+
}): ArtifactPhaseHandle;
|
|
165
|
+
completePhase(handle: ArtifactPhaseHandle, options: {
|
|
166
|
+
exitCode: number | null;
|
|
167
|
+
stdout?: string;
|
|
168
|
+
stderr?: string;
|
|
169
|
+
outputCaptured: boolean;
|
|
170
|
+
notes?: string;
|
|
171
|
+
extra?: Record<string, unknown>;
|
|
172
|
+
}): void;
|
|
173
|
+
finalize(context: ArtifactRunContext, options: {
|
|
174
|
+
status: ArtifactStoreStatus;
|
|
175
|
+
preserve?: boolean;
|
|
176
|
+
}): void;
|
|
177
|
+
displayPath(context: ArtifactRunContext): string;
|
|
178
|
+
rootDir(cwd?: string): string;
|
|
179
|
+
listSaved(cwd?: string): ArtifactRunMetadata[];
|
|
180
|
+
listFailed(cwd?: string): ArtifactRunMetadata[];
|
|
181
|
+
latest(cwd?: string): ArtifactRunMetadata | null;
|
|
182
|
+
find(runId: string, cwd?: string): ArtifactRunMetadata | null;
|
|
183
|
+
removeSaved(cwd?: string): number;
|
|
184
|
+
removeFailed(cwd?: string): number;
|
|
185
|
+
isFailedStatus(status: string | undefined): boolean;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
interface Clock {
|
|
189
|
+
now(): Date;
|
|
190
|
+
nowIsoString(): string;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
type ApplicationOutputEvent = {
|
|
194
|
+
kind: "info";
|
|
195
|
+
message: string;
|
|
196
|
+
} | {
|
|
197
|
+
kind: "warn";
|
|
198
|
+
message: string;
|
|
199
|
+
} | {
|
|
200
|
+
kind: "error";
|
|
201
|
+
message: string;
|
|
202
|
+
} | {
|
|
203
|
+
kind: "success";
|
|
204
|
+
message: string;
|
|
205
|
+
} | {
|
|
206
|
+
kind: "task";
|
|
207
|
+
task: Task;
|
|
208
|
+
blocked?: boolean;
|
|
209
|
+
} | {
|
|
210
|
+
kind: "text";
|
|
211
|
+
text: string;
|
|
212
|
+
} | {
|
|
213
|
+
kind: "stderr";
|
|
214
|
+
text: string;
|
|
215
|
+
};
|
|
216
|
+
interface ApplicationOutputPort {
|
|
217
|
+
emit(event: ApplicationOutputEvent): void;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
interface SourceResolverPort {
|
|
221
|
+
resolveSources(source: string): Promise<string[]>;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
interface TaskSelectionResult {
|
|
225
|
+
task: Task;
|
|
226
|
+
source: string;
|
|
227
|
+
contextBefore: string;
|
|
228
|
+
}
|
|
229
|
+
interface TaskSelectorPort {
|
|
230
|
+
selectNextTask(files: string[], sortMode: SortMode): TaskSelectionResult | null;
|
|
231
|
+
selectTaskByLocation(filePath: string, line: number): TaskSelectionResult | null;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
type PromptTransport$2 = "file" | "arg";
|
|
235
|
+
interface WorkerRunResult {
|
|
236
|
+
exitCode: number | null;
|
|
237
|
+
stdout: string;
|
|
238
|
+
stderr: string;
|
|
239
|
+
}
|
|
240
|
+
interface WorkerExecutionOptions {
|
|
241
|
+
command: string[];
|
|
242
|
+
prompt: string;
|
|
243
|
+
mode: ProcessRunMode;
|
|
244
|
+
transport: PromptTransport$2;
|
|
245
|
+
cwd: string;
|
|
246
|
+
artifactContext?: unknown;
|
|
247
|
+
artifactPhase?: "execute" | "verify" | "repair" | "worker" | "plan";
|
|
248
|
+
artifactExtra?: Record<string, unknown>;
|
|
249
|
+
}
|
|
250
|
+
interface InlineCliExecutionOptions {
|
|
251
|
+
artifactContext?: unknown;
|
|
252
|
+
keepArtifacts?: boolean;
|
|
253
|
+
artifactExtra?: Record<string, unknown>;
|
|
254
|
+
}
|
|
255
|
+
interface WorkerExecutorPort {
|
|
256
|
+
runWorker(options: WorkerExecutionOptions): Promise<WorkerRunResult>;
|
|
257
|
+
executeInlineCli(command: string, cwd: string, options?: InlineCliExecutionOptions): Promise<WorkerRunResult>;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
interface TaskValidationOptions {
|
|
261
|
+
task: Task;
|
|
262
|
+
source: string;
|
|
263
|
+
contextBefore: string;
|
|
264
|
+
template: string;
|
|
265
|
+
command: string[];
|
|
266
|
+
mode?: ProcessRunMode;
|
|
267
|
+
transport?: PromptTransport$2;
|
|
268
|
+
cwd?: string;
|
|
269
|
+
templateVars?: Record<string, unknown>;
|
|
270
|
+
artifactContext?: unknown;
|
|
271
|
+
}
|
|
272
|
+
interface TaskValidationPort {
|
|
273
|
+
validate(options: TaskValidationOptions): Promise<boolean>;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
interface TaskCorrectionOptions {
|
|
277
|
+
task: Task;
|
|
278
|
+
source: string;
|
|
279
|
+
contextBefore: string;
|
|
280
|
+
correctTemplate: string;
|
|
281
|
+
validateTemplate: string;
|
|
282
|
+
command: string[];
|
|
283
|
+
maxRetries: number;
|
|
284
|
+
mode?: ProcessRunMode;
|
|
285
|
+
transport?: PromptTransport$2;
|
|
286
|
+
cwd?: string;
|
|
287
|
+
templateVars?: Record<string, unknown>;
|
|
288
|
+
artifactContext?: unknown;
|
|
289
|
+
}
|
|
290
|
+
interface TaskCorrectionResult {
|
|
291
|
+
valid: boolean;
|
|
292
|
+
attempts: number;
|
|
293
|
+
}
|
|
294
|
+
interface TaskCorrectionPort {
|
|
295
|
+
correct(options: TaskCorrectionOptions): Promise<TaskCorrectionResult>;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
interface WorkingDirectoryPort {
|
|
299
|
+
cwd(): string;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
interface DirectoryOpenerPort {
|
|
303
|
+
openDirectory(dirPath: string): void;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
type RunnerMode$1 = ProcessRunMode;
|
|
307
|
+
type PromptTransport$1 = PromptTransport$2;
|
|
308
|
+
interface RunTaskOptions {
|
|
309
|
+
source: string;
|
|
310
|
+
mode: RunnerMode$1;
|
|
311
|
+
transport: PromptTransport$1;
|
|
312
|
+
sortMode: SortMode;
|
|
313
|
+
verify: boolean;
|
|
314
|
+
onlyVerify: boolean;
|
|
315
|
+
noRepair: boolean;
|
|
316
|
+
retries: number;
|
|
317
|
+
dryRun: boolean;
|
|
318
|
+
printPrompt: boolean;
|
|
319
|
+
keepArtifacts: boolean;
|
|
320
|
+
varsFileOption: string | boolean | undefined;
|
|
321
|
+
cliTemplateVarArgs: string[];
|
|
322
|
+
workerCommand: string[];
|
|
323
|
+
commitAfterComplete: boolean;
|
|
324
|
+
commitMessageTemplate?: string;
|
|
325
|
+
onCompleteCommand?: string;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
type RunnerMode = ProcessRunMode;
|
|
329
|
+
type PromptTransport = "file" | "arg";
|
|
330
|
+
interface PlanTaskOptions {
|
|
331
|
+
source: string;
|
|
332
|
+
at?: string;
|
|
333
|
+
mode: RunnerMode;
|
|
334
|
+
transport: PromptTransport;
|
|
335
|
+
sortMode: SortMode;
|
|
336
|
+
dryRun: boolean;
|
|
337
|
+
printPrompt: boolean;
|
|
338
|
+
keepArtifacts: boolean;
|
|
339
|
+
varsFileOption: string | boolean | undefined;
|
|
340
|
+
cliTemplateVarArgs: string[];
|
|
341
|
+
workerCommand: string[];
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
interface ListTasksOptions {
|
|
345
|
+
source: string;
|
|
346
|
+
sortMode: SortMode;
|
|
347
|
+
includeAll: boolean;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
interface NextTaskOptions {
|
|
351
|
+
source: string;
|
|
352
|
+
sortMode: SortMode;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
interface ManageArtifactsOptions {
|
|
356
|
+
clean: boolean;
|
|
357
|
+
json: boolean;
|
|
358
|
+
failed: boolean;
|
|
359
|
+
open: string;
|
|
360
|
+
cwd?: string;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
type App = {
|
|
364
|
+
runTask: (options: RunTaskOptions) => Promise<number>;
|
|
365
|
+
planTask: (options: PlanTaskOptions) => Promise<number>;
|
|
366
|
+
listTasks: (options: ListTasksOptions) => Promise<number>;
|
|
367
|
+
nextTask: (options: NextTaskOptions) => Promise<number>;
|
|
368
|
+
initProject: () => Promise<number>;
|
|
369
|
+
manageArtifacts: (options: ManageArtifactsOptions) => number;
|
|
370
|
+
};
|
|
371
|
+
type AppUseCaseFactories = {
|
|
372
|
+
[Key in keyof App]: (ports: AppPorts) => App[Key];
|
|
373
|
+
};
|
|
374
|
+
interface AppPorts {
|
|
375
|
+
fileSystem: FileSystem;
|
|
376
|
+
processRunner: ProcessRunner;
|
|
377
|
+
gitClient: GitClient;
|
|
378
|
+
templateLoader: TemplateLoader;
|
|
379
|
+
validationSidecar: ValidationSidecar;
|
|
380
|
+
artifactStore: ArtifactStore;
|
|
381
|
+
clock: Clock;
|
|
382
|
+
directoryOpener: DirectoryOpenerPort;
|
|
383
|
+
sourceResolver: SourceResolverPort;
|
|
384
|
+
taskSelector: TaskSelectorPort;
|
|
385
|
+
workerExecutor: WorkerExecutorPort;
|
|
386
|
+
taskValidation: TaskValidationPort;
|
|
387
|
+
taskCorrection: TaskCorrectionPort;
|
|
388
|
+
workingDirectory: WorkingDirectoryPort;
|
|
389
|
+
output: ApplicationOutputPort;
|
|
390
|
+
}
|
|
391
|
+
interface CreateAppDependencies {
|
|
392
|
+
ports?: Partial<AppPorts>;
|
|
393
|
+
useCaseFactories?: Partial<AppUseCaseFactories>;
|
|
394
|
+
}
|
|
395
|
+
declare function createApp(dependencies?: CreateAppDependencies): App;
|
|
396
|
+
|
|
397
|
+
export { type App, type AppPorts, type AppUseCaseFactories, type CreateAppDependencies, createApp };
|