@lumpcode/recipes 0.0.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 +17 -0
- package/README.md +153 -0
- package/dist/index.cjs +775 -0
- package/dist/index.d.ts +199 -0
- package/dist/index.js +749 -0
- package/package.json +61 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { CommandDescriptor, MaybePromise, PostCommandExecFn, Step } from '@lumpcode/core';
|
|
2
|
+
import { GetContextListFnInput, GetContextListFn, CommandFn, LumpJsConfig, LumpJsConfigSteps, LumpVariables, MaybePromise as MaybePromise$1, Context } from '@lumpcode/cli-utils';
|
|
3
|
+
|
|
4
|
+
/** Run a shell script via `sh -c` (portable on Unix-like systems and Git Bash on Windows). */
|
|
5
|
+
declare function shellCommand(script: string): CommandDescriptor;
|
|
6
|
+
|
|
7
|
+
type MaybePromGetter<T, P = void> = T | ((input: P) => MaybePromise<T>);
|
|
8
|
+
declare function normalizeMaybePromGetter<T, P = void>(maybePromGetter: MaybePromGetter<T, P>): (input: P) => MaybePromise<T>;
|
|
9
|
+
declare function normalizeMaybePromGetter<T, P = void>(maybePromGetter: MaybePromGetter<T, P> | undefined, defaultValue: T): (input?: P) => MaybePromise<T>;
|
|
10
|
+
|
|
11
|
+
type ContextVariables = Record<string, string | number | boolean>;
|
|
12
|
+
type EphemeralContextListFnOptions = {
|
|
13
|
+
contextCount?: MaybePromGetter<number, GetContextListFnInput>;
|
|
14
|
+
contextName?: MaybePromGetter<string, {
|
|
15
|
+
index: number;
|
|
16
|
+
count: number;
|
|
17
|
+
}>;
|
|
18
|
+
variables?: MaybePromGetter<ContextVariables, {
|
|
19
|
+
contextName: string;
|
|
20
|
+
index: number;
|
|
21
|
+
count: number;
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
declare function ephemeralContextListFn(options?: EphemeralContextListFnOptions): GetContextListFn;
|
|
25
|
+
|
|
26
|
+
type StepIndex = number | number[];
|
|
27
|
+
type ValidationCommandFnInput = Parameters<CommandFn>[0] & {
|
|
28
|
+
currentIteration: number;
|
|
29
|
+
prevValidateCommandResult: string | null;
|
|
30
|
+
contextRunStateIsOkFlagKey: string;
|
|
31
|
+
};
|
|
32
|
+
type ValidationCommandFn = (input: ValidationCommandFnInput) => MaybePromise<CommandDescriptor | null | undefined>;
|
|
33
|
+
type IsValidationCommandResultOkInput = Parameters<PostCommandExecFn>[0] & {
|
|
34
|
+
currentIteration: number;
|
|
35
|
+
};
|
|
36
|
+
type GetFirstStepsInput = {
|
|
37
|
+
currentIteration: number;
|
|
38
|
+
prevValidateCommandResult: string | null;
|
|
39
|
+
prevValidateCommandDescriptor: CommandDescriptor | null;
|
|
40
|
+
};
|
|
41
|
+
type GetRecursiveStepsOptions = {
|
|
42
|
+
maxIterations?: number;
|
|
43
|
+
validationCommandFn?: ValidationCommandFn;
|
|
44
|
+
isValidationCommandResultOk?: (input: IsValidationCommandResultOkInput) => boolean;
|
|
45
|
+
getFirstSteps?: (input: GetFirstStepsInput) => LumpJsConfig['steps'];
|
|
46
|
+
currentIteration?: number;
|
|
47
|
+
prevValidateCommandResult?: string | null;
|
|
48
|
+
prevValidateCommandDescriptor?: CommandDescriptor | null;
|
|
49
|
+
contextRunStateIsOkFlagKey?: string;
|
|
50
|
+
};
|
|
51
|
+
/** Agent prompt(s) followed by a validation command, retried until checks pass or `maxIterations` is reached. */
|
|
52
|
+
declare function getRecursiveSteps({ maxIterations, validationCommandFn, isValidationCommandResultOk, getFirstSteps, currentIteration, prevValidateCommandResult, prevValidateCommandDescriptor, contextRunStateIsOkFlagKey, }: GetRecursiveStepsOptions): LumpJsConfigSteps;
|
|
53
|
+
|
|
54
|
+
declare function defaultFixSteps(input: GetFirstStepsInput): LumpJsConfig['steps'];
|
|
55
|
+
interface RetryUntilGreenInput {
|
|
56
|
+
steps: LumpJsConfig['steps'];
|
|
57
|
+
fixSteps?: typeof defaultFixSteps;
|
|
58
|
+
validationCommandFn: ValidationCommandFn;
|
|
59
|
+
isValidationCommandResultOk?: (input: IsValidationCommandResultOkInput) => boolean;
|
|
60
|
+
contextRunStateIsOkFlagKey?: GetRecursiveStepsOptions['contextRunStateIsOkFlagKey'];
|
|
61
|
+
maxIterations?: GetRecursiveStepsOptions['maxIterations'];
|
|
62
|
+
}
|
|
63
|
+
/** Work steps, validation command, and optional fix steps — retried until checks pass or `maxIterations`. */
|
|
64
|
+
declare function retryUntilGreen({ steps, fixSteps, validationCommandFn, isValidationCommandResultOk, contextRunStateIsOkFlagKey, maxIterations, }: RetryUntilGreenInput): LumpJsConfigSteps;
|
|
65
|
+
|
|
66
|
+
declare function lumpPathAndName(configUrl: string | URL): [lumpPath: string, lumpName: string];
|
|
67
|
+
|
|
68
|
+
/** Resolves git project root from a lump `config.ts` module URL. */
|
|
69
|
+
declare function projectRootFromConfigUrl(configUrl: string | URL): string;
|
|
70
|
+
|
|
71
|
+
/** Fails the context when the artifact referenced by a context variable was not created. */
|
|
72
|
+
declare function requireArtifactStep(artifactPathVarName: string): Step;
|
|
73
|
+
|
|
74
|
+
type BacklogPaths$1 = {
|
|
75
|
+
lumpPath: string;
|
|
76
|
+
lumpName: string;
|
|
77
|
+
backlogFilePath: string;
|
|
78
|
+
doneFilePath: string;
|
|
79
|
+
};
|
|
80
|
+
declare function resolveBacklogPaths(configUrl: string | URL, overrides?: {
|
|
81
|
+
backlogFilePath?: string;
|
|
82
|
+
doneFilePath?: string;
|
|
83
|
+
}): BacklogPaths$1;
|
|
84
|
+
|
|
85
|
+
/** Moves a finished backlog item from BACKLOG.yml to DONE.yml after the context completes. */
|
|
86
|
+
declare const setTaskDoneStep: (input: {
|
|
87
|
+
backlogVarName: string;
|
|
88
|
+
doneVarName: string;
|
|
89
|
+
}) => Step;
|
|
90
|
+
|
|
91
|
+
type ImplValidateCommand = string | CommandDescriptor | ValidationCommandFn;
|
|
92
|
+
declare function resolveImplValidateCommand(implValidateCommand: ImplValidateCommand): ValidationCommandFn;
|
|
93
|
+
|
|
94
|
+
type Recipe<Options, V extends LumpVariables = LumpVariables> = (options: Options) => LumpJsConfig<V>;
|
|
95
|
+
declare function defineRecipe<Options, V extends LumpVariables = LumpVariables>(recipe: Recipe<Options, V>): Recipe<Options, V>;
|
|
96
|
+
|
|
97
|
+
type BaseBacklogItem = {
|
|
98
|
+
name: string;
|
|
99
|
+
task: string;
|
|
100
|
+
priority: number;
|
|
101
|
+
dependsOn?: string[];
|
|
102
|
+
};
|
|
103
|
+
type DoneBacklogItem<T extends BaseBacklogItem = BaseBacklogItem> = T & {
|
|
104
|
+
completedAt: string;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
type YmlBacklogContextsOptions<Item extends BaseBacklogItem = BaseBacklogItem> = {
|
|
108
|
+
backlogFilePath: string;
|
|
109
|
+
parseItem?: (item: BaseBacklogItem, index: number, raw: unknown) => Item;
|
|
110
|
+
parseContext?: (item: Item, index: number) => MaybePromise$1<{
|
|
111
|
+
parsed?: Partial<Context>;
|
|
112
|
+
ignored?: boolean;
|
|
113
|
+
}>;
|
|
114
|
+
};
|
|
115
|
+
declare function ymlBacklogContexts<Item extends BaseBacklogItem = BaseBacklogItem>({ backlogFilePath, parseItem, parseContext, }: YmlBacklogContextsOptions<Item>): GetContextListFn;
|
|
116
|
+
|
|
117
|
+
/** Validates and normalizes one YAML backlog row; throws on invalid input. */
|
|
118
|
+
declare function validateBaseBacklogItem(raw: unknown, index: number): BaseBacklogItem;
|
|
119
|
+
|
|
120
|
+
type AbstractionBacklogOptions = {
|
|
121
|
+
implValidateCommand?: ValidationCommandFn | string;
|
|
122
|
+
/** Lump config module URL — pass `import.meta.url` from `config.ts`. */
|
|
123
|
+
configUrl: string | URL;
|
|
124
|
+
} & Omit<LumpJsConfig, 'contextListJson' | 'contextMatchFn' | 'getContextListFn' | 'prompt' | 'steps'>;
|
|
125
|
+
declare const abstractionBacklog: Recipe<AbstractionBacklogOptions>;
|
|
126
|
+
|
|
127
|
+
type AbstractionFinderOptions = {
|
|
128
|
+
scanDirectories: string[];
|
|
129
|
+
customPrompt?(): string;
|
|
130
|
+
maxPendingAbstractions?: number;
|
|
131
|
+
backlogFilePath: string;
|
|
132
|
+
doneFilePath?: string;
|
|
133
|
+
prdDirPath?: string;
|
|
134
|
+
} & LumpJsConfig;
|
|
135
|
+
declare const abstractionFinder: Recipe<AbstractionFinderOptions>;
|
|
136
|
+
|
|
137
|
+
type BacklogStageDefinition = {
|
|
138
|
+
steps: NonNullable<LumpJsConfig['steps']>;
|
|
139
|
+
completion: 'keepPending' | 'moveToDone';
|
|
140
|
+
};
|
|
141
|
+
type BacklogPaths = {
|
|
142
|
+
lumpPath: string;
|
|
143
|
+
lumpName: string;
|
|
144
|
+
backlogFilePath: string;
|
|
145
|
+
doneFilePath: string;
|
|
146
|
+
};
|
|
147
|
+
type BacklogItemResolution<StageName extends string> = {
|
|
148
|
+
ignored: true;
|
|
149
|
+
} | {
|
|
150
|
+
stage: StageName;
|
|
151
|
+
contextName?: string;
|
|
152
|
+
variables?: LumpVariables;
|
|
153
|
+
additionalDependsOnContexts?: string[];
|
|
154
|
+
};
|
|
155
|
+
type BacklogOptions<Item extends BaseBacklogItem, Stages extends Record<string, BacklogStageDefinition>> = {
|
|
156
|
+
configUrl: string | URL;
|
|
157
|
+
backlogFilePath?: string;
|
|
158
|
+
doneFilePath?: string;
|
|
159
|
+
stages: Stages;
|
|
160
|
+
parseItem?: (item: BaseBacklogItem, index: number, raw: unknown) => Item;
|
|
161
|
+
resolveItem(input: {
|
|
162
|
+
item: Item;
|
|
163
|
+
paths: BacklogPaths;
|
|
164
|
+
}): MaybePromise<BacklogItemResolution<Extract<keyof Stages, string>>>;
|
|
165
|
+
} & Omit<LumpJsConfig, 'contextListJson' | 'contextMatchFn' | 'getContextListFn' | 'prompt' | 'steps'>;
|
|
166
|
+
declare const BACKLOG_STAGE_VAR = "BACKLOG_STAGE";
|
|
167
|
+
declare const BACKLOG_TASK_NAME_VAR = "TASK_NAME";
|
|
168
|
+
declare const BACKLOG_TASK_VAR = "TASK";
|
|
169
|
+
declare const BACKLOG_FILE_VAR = "BACKLOG_FILE";
|
|
170
|
+
declare const BACKLOG_DONE_FILE_VAR = "DONE_FILE";
|
|
171
|
+
|
|
172
|
+
declare function backlog<Item extends BaseBacklogItem, Stages extends Record<string, BacklogStageDefinition>>(options: BacklogOptions<Item, Stages>): LumpJsConfig;
|
|
173
|
+
declare const backlogRecipe: Recipe<BacklogOptions<BaseBacklogItem, Record<string, BacklogStageDefinition>>>;
|
|
174
|
+
|
|
175
|
+
type FeatureBacklogItem = BaseBacklogItem & {
|
|
176
|
+
manualPrd?: boolean;
|
|
177
|
+
};
|
|
178
|
+
type FeatureBacklogStage = 'makePrd' | 'makeTestPlan' | 'testImpl' | 'implementation';
|
|
179
|
+
type FeatureBacklogContextVariables = {
|
|
180
|
+
TASK_NAME: string;
|
|
181
|
+
TASK: string;
|
|
182
|
+
BACKLOG_FILE: string;
|
|
183
|
+
DONE_FILE: string;
|
|
184
|
+
BACKLOG_STAGE: FeatureBacklogStage;
|
|
185
|
+
PRD_FILE?: string;
|
|
186
|
+
TEST_PLAN_FILE?: string;
|
|
187
|
+
};
|
|
188
|
+
type FeatureBacklogOptions = {
|
|
189
|
+
configUrl: string | URL;
|
|
190
|
+
baseBranch: string;
|
|
191
|
+
implValidateCommand: ValidationCommandFn | string;
|
|
192
|
+
backlogFilePath?: string;
|
|
193
|
+
doneFilePath?: string;
|
|
194
|
+
} & Omit<LumpJsConfig, 'contextListJson' | 'contextMatchFn' | 'getContextListFn' | 'prompt' | 'steps' | 'baseBranch'>;
|
|
195
|
+
declare function resolveFeatureBacklogItem(item: FeatureBacklogItem, paths: BacklogPaths$1, projectRoot: string, lumpName: string, baseBranch: string): Promise<BacklogItemResolution<FeatureBacklogStage>>;
|
|
196
|
+
declare const featureBacklog: Recipe<FeatureBacklogOptions>;
|
|
197
|
+
|
|
198
|
+
export { BACKLOG_DONE_FILE_VAR, BACKLOG_FILE_VAR, BACKLOG_STAGE_VAR, BACKLOG_TASK_NAME_VAR, BACKLOG_TASK_VAR, abstractionBacklog, abstractionFinder, backlog, backlogRecipe, defineRecipe, ephemeralContextListFn, featureBacklog, getRecursiveSteps, lumpPathAndName, normalizeMaybePromGetter, projectRootFromConfigUrl, requireArtifactStep, resolveBacklogPaths, resolveFeatureBacklogItem, resolveImplValidateCommand, retryUntilGreen, setTaskDoneStep, shellCommand, validateBaseBacklogItem, ymlBacklogContexts };
|
|
199
|
+
export type { AbstractionBacklogOptions, AbstractionFinderOptions, BacklogItemResolution, BacklogOptions, BacklogPaths$1 as BacklogPaths, BacklogStageDefinition, BaseBacklogItem, DoneBacklogItem, EphemeralContextListFnOptions, FeatureBacklogContextVariables, FeatureBacklogItem, FeatureBacklogOptions, FeatureBacklogStage, GetFirstStepsInput, GetRecursiveStepsOptions, ImplValidateCommand, IsValidationCommandResultOkInput, MaybePromGetter, Recipe, RetryUntilGreenInput, StepIndex, ValidationCommandFn, ValidationCommandFnInput, YmlBacklogContextsOptions };
|