@lumpcode/core 0.0.13 → 0.0.15
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/README.md +2 -2
- package/dist/helpers/executeStepsForContextList/main.d.ts +3 -3
- package/dist/helpers/executeStepsForContextList/main.d.ts.map +1 -1
- package/dist/helpers/getContextStatus/main.d.ts +3 -3
- package/dist/helpers/getContextStatus/main.d.ts.map +1 -1
- package/dist/helpers/getToDoContextList/main.d.ts +4 -4
- package/dist/helpers/getToDoContextList/main.d.ts.map +1 -1
- package/dist/index.cjs +8 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -6
- package/dist/index.js.map +1 -1
- package/dist/types/BranchFn.d.ts +2 -2
- package/dist/types/BranchFn.d.ts.map +1 -1
- package/dist/types/CommandFn.d.ts +3 -3
- package/dist/types/CommandFn.d.ts.map +1 -1
- package/dist/types/ContextStatus.d.ts +1 -7
- package/dist/types/ContextStatus.d.ts.map +1 -1
- package/dist/types/GetContextListFn.d.ts +3 -3
- package/dist/types/GetContextListFn.d.ts.map +1 -1
- package/dist/types/GitCommitMessageFn.d.ts +3 -3
- package/dist/types/GitCommitMessageFn.d.ts.map +1 -1
- package/dist/types/HistoryEntry.d.ts +3 -3
- package/dist/types/HistoryEntry.d.ts.map +1 -1
- package/dist/types/PostCommandExecFn.d.ts +5 -4
- package/dist/types/PostCommandExecFn.d.ts.map +1 -1
- package/dist/types/PromptFn.d.ts +4 -4
- package/dist/types/PromptFn.d.ts.map +1 -1
- package/dist/types/SetupFn.d.ts +2 -2
- package/dist/types/SetupFn.d.ts.map +1 -1
- package/dist/types/Step.d.ts +6 -5
- package/dist/types/Step.d.ts.map +1 -1
- package/dist/types/Steps.d.ts +3 -1
- package/dist/types/Steps.d.ts.map +1 -1
- package/dist/types/TeardownFn.d.ts +2 -2
- package/dist/types/TeardownFn.d.ts.map +1 -1
- package/dist/usages/runLump/main.d.ts +9 -9
- package/dist/usages/runLump/main.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -106,7 +106,7 @@ An array of `Step` objects that are executed sequentially for each context. Each
|
|
|
106
106
|
| `promptFn` | `PromptFn | undefined` | Optional. Generates the prompt string from the current context, run state, and variables. When omitted, `commandFn` receives an empty prompt string. |
|
|
107
107
|
| `commandFn` | `CommandFn` | Required. Returns `{ executable, args, env? }` to run a subprocess, or `null` / `undefined` to skip execution while still running `postCommandExecFn`. Optional `env` merges over the parent process environment for that command only. |
|
|
108
108
|
| `stepVariables` | `StepVariables | undefined` | Optional extra variables passed into `promptFn`, `commandFn`, and `postCommandExecFn`. |
|
|
109
|
-
| `postCommandExecFn` | `PostCommandExecFn | undefined` | Optional hook called after the command finishes, receiving the command output.
|
|
109
|
+
| `postCommandExecFn` | `PostCommandExecFn | undefined` | Optional hook called after the command finishes, receiving the command output. May return `void` / `undefined` / `[]` (no-op) or a `Steps` array to run nested follow-on steps under this leaf. |
|
|
110
110
|
| `timeoutMillis` | `number | undefined` | Maximum time in milliseconds allowed for the command execution. Defaults to `1800000` (30 minutes). |
|
|
111
111
|
|
|
112
112
|
|
|
@@ -350,7 +350,7 @@ type Steps = Array<
|
|
|
350
350
|
>;
|
|
351
351
|
```
|
|
352
352
|
|
|
353
|
-
When the engine encounters a concrete `Step`, it runs optional `promptFn`, then `commandFn`, then `postCommandExecFn` (if provided). When `commandFn` returns `null`, `undefined`, or nothing, the subprocess is skipped and `postCommandExecFn` still runs with an empty `commandResult`. When
|
|
353
|
+
When the engine encounters a concrete `Step`, it runs optional `promptFn`, then `commandFn`, then `postCommandExecFn` (if provided). When `commandFn` returns `null`, `undefined`, or nothing, the subprocess is skipped and `postCommandExecFn` still runs with an empty `commandResult`. When `postCommandExecFn` returns a non-empty `Steps` array, those steps are executed recursively nested under the leaf (same `stepIndex` path rules as function-form children) before the walk continues with any remaining siblings. When the engine encounters a **function**, it calls it and recursively executes the returned `Steps` before moving to the next element. The returned array can itself contain more functions, allowing arbitrary nesting depth. An empty returned array is a no-op.
|
|
354
354
|
|
|
355
355
|
This makes it possible to build dynamic prompt chains: a function can inspect the current context, run state, or variables and decide at runtime how many prompts to produce, what they contain, or whether to skip entirely by returning an empty array.
|
|
356
356
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ContextList, ContextRunState, Failure, Logger } from "../../types";
|
|
1
|
+
import { ContextList, ContextRunState, Failure, Logger, LumpVariables, StepVariables } from "../../types";
|
|
2
2
|
import type { RunLumpInput } from '../../usages';
|
|
3
|
-
export type ExecuteStepsForContextListParams = Required<Pick<RunLumpInput, 'baseBranch' | 'branchFn' | 'lumpVariables' | 'steps' | 'setupFn' | 'teardownFn' | 'gitAddCommandFn' | 'gitCommitCommandFn' | 'gitPushCommandFn' | 'gitCommitMessageFn' | 'projectRoot' | 'setupWorkspaceFn' | 'teardownWorkspaceFn' | 'getKeepHistoryFilePathFn'>> & {
|
|
3
|
+
export type ExecuteStepsForContextListParams<V extends LumpVariables = LumpVariables, SV extends StepVariables = StepVariables> = Required<Pick<RunLumpInput<V, SV>, 'baseBranch' | 'branchFn' | 'lumpVariables' | 'steps' | 'setupFn' | 'teardownFn' | 'gitAddCommandFn' | 'gitCommitCommandFn' | 'gitPushCommandFn' | 'gitCommitMessageFn' | 'projectRoot' | 'setupWorkspaceFn' | 'teardownWorkspaceFn' | 'getKeepHistoryFilePathFn'>> & {
|
|
4
4
|
contextList: ContextList;
|
|
5
5
|
logger?: Logger;
|
|
6
6
|
};
|
|
7
|
-
export declare function executeStepsForContextList({ baseBranch, branchFn, lumpVariables, contextList, gitAddCommandFn, gitCommitCommandFn, gitPushCommandFn, gitCommitMessageFn, projectRoot, steps, setupFn, setupWorkspaceFn, teardownFn, teardownWorkspaceFn, getKeepHistoryFilePathFn, logger: loggerInput, }: ExecuteStepsForContextListParams): Promise<Failure<{
|
|
7
|
+
export declare function executeStepsForContextList<V extends LumpVariables = LumpVariables, SV extends StepVariables = StepVariables>({ baseBranch, branchFn, lumpVariables, contextList, gitAddCommandFn, gitCommitCommandFn, gitPushCommandFn, gitCommitMessageFn, projectRoot, steps, setupFn, setupWorkspaceFn, teardownFn, teardownWorkspaceFn, getKeepHistoryFilePathFn, logger: loggerInput, }: ExecuteStepsForContextListParams<V, SV>): Promise<Failure<{
|
|
8
8
|
message: string;
|
|
9
9
|
}> | import("../..").Success<{
|
|
10
10
|
branchName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/helpers/executeStepsForContextList/main.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,WAAW,EACX,eAAe,EACf,OAAO,EACP,MAAM,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/helpers/executeStepsForContextList/main.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,WAAW,EACX,eAAe,EACf,OAAO,EACP,MAAM,EACN,aAAa,EAIb,aAAa,EAChB,MAAM,aAAa,CAAC;AAUrB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,MAAM,gCAAgC,CACxC,CAAC,SAAS,aAAa,GAAG,aAAa,EACvC,EAAE,SAAS,aAAa,GAAG,aAAa,IACxC,QAAQ,CAAC,IAAI,CACb,YAAY,CAAC,CAAC,EAAE,EAAE,CAAC,EACjB,YAAY,GACZ,UAAU,GACV,eAAe,GACf,OAAO,GACP,SAAS,GACT,YAAY,GACZ,iBAAiB,GACjB,oBAAoB,GACpB,kBAAkB,GAClB,oBAAoB,GACpB,aAAa,GACb,kBAAkB,GAClB,qBAAqB,GACrB,0BAA0B,CAC/B,CAAC,GAAG;IACD,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAA;AAED,wBAAsB,0BAA0B,CAC5C,CAAC,SAAS,aAAa,GAAG,aAAa,EACvC,EAAE,SAAS,aAAa,GAAG,aAAa,EAC1C,EACE,UAAU,EACV,QAAQ,EACR,aAAa,EACb,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,KAAK,EACL,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,wBAAwB,EACxB,MAAM,EAAE,WAAW,GACtB,EAAE,gCAAgC,CAAC,CAAC,EAAE,EAAE,CAAC;aAqEM,MAAM;;;;;IAwOrD;AAED,MAAM,MAAM,gCAAgC,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ContextStatus, Logger, LumpVariables } from "../../types";
|
|
2
2
|
import { GitCommitMessageFn } from "../../types/GitCommitMessageFn";
|
|
3
|
-
export declare function getContextStatus(params: {
|
|
3
|
+
export declare function getContextStatus<V extends LumpVariables = LumpVariables>(params: {
|
|
4
4
|
contextName: string;
|
|
5
|
-
gitCommitMessageFn: GitCommitMessageFn
|
|
5
|
+
gitCommitMessageFn: GitCommitMessageFn<V>;
|
|
6
6
|
projectRoot: string;
|
|
7
7
|
baseBranch: string;
|
|
8
|
-
lumpVariables?:
|
|
8
|
+
lumpVariables?: V;
|
|
9
9
|
contextVariables?: Record<string, string>;
|
|
10
10
|
remoteName?: string;
|
|
11
11
|
logger?: Logger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/helpers/getContextStatus/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIpE,wBAAsB,gBAAgB,CAAC,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/helpers/getContextStatus/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAIpE,wBAAsB,gBAAgB,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EAAE,MAAM,EAAE;IACpF,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,CAAC,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,aAAa,CAAC,CAoEzB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { GetContextListFn, Logger, LumpVariables } from "../../types";
|
|
2
2
|
import { GitCommitMessageFn } from "../../types/GitCommitMessageFn";
|
|
3
|
-
export declare function getToDoContextList(params: {
|
|
4
|
-
getContextListFn: GetContextListFn
|
|
5
|
-
lumpVariables:
|
|
6
|
-
gitCommitMessageFn: GitCommitMessageFn
|
|
3
|
+
export declare function getToDoContextList<V extends LumpVariables = LumpVariables>(params: {
|
|
4
|
+
getContextListFn: GetContextListFn<V>;
|
|
5
|
+
lumpVariables: V;
|
|
6
|
+
gitCommitMessageFn: GitCommitMessageFn<V>;
|
|
7
7
|
projectRoot: string;
|
|
8
8
|
baseBranch: string;
|
|
9
9
|
logger?: Logger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/helpers/getToDoContextList/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE,wBAAsB,kBAAkB,CAAC,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/helpers/getToDoContextList/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE,wBAAsB,kBAAkB,CAAC,CAAC,SAAS,aAAa,GAAG,aAAa,EAAE,MAAM,EAAE;IACtF,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;IACtC,aAAa,EAAE,CAAC,CAAC;IACjB,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;;oGA8DA"}
|
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,6 @@ var fs = require('node:fs');
|
|
|
6
6
|
var path = require('node:path');
|
|
7
7
|
var fs$1 = require('node:fs/promises');
|
|
8
8
|
var ignore = require('ignore');
|
|
9
|
-
var z = require('zod');
|
|
10
9
|
|
|
11
10
|
function _interopNamespaceDefault(e) {
|
|
12
11
|
var n = Object.create(null);
|
|
@@ -3725,7 +3724,10 @@ async function executeStepsForContextList({ baseBranch, branchFn, lumpVariables,
|
|
|
3725
3724
|
}
|
|
3726
3725
|
}
|
|
3727
3726
|
if (postCommandExecFn) {
|
|
3728
|
-
await postCommandExecFn(postCommandExecFnInput);
|
|
3727
|
+
const returnedSteps = await postCommandExecFn(postCommandExecFnInput);
|
|
3728
|
+
if (returnedSteps != null && returnedSteps.length > 0) {
|
|
3729
|
+
await walkAndExecuteSteps(returnedSteps, nextCallHeadIndex);
|
|
3730
|
+
}
|
|
3729
3731
|
}
|
|
3730
3732
|
}
|
|
3731
3733
|
}
|
|
@@ -3864,7 +3866,8 @@ async function scanDirectory({ dirPath, allPaths, gitignoresMap, projectRoot, lo
|
|
|
3864
3866
|
}
|
|
3865
3867
|
|
|
3866
3868
|
async function getContextStatus(params) {
|
|
3867
|
-
const { contextName, gitCommitMessageFn, projectRoot, baseBranch, lumpVariables
|
|
3869
|
+
const { contextName, gitCommitMessageFn, projectRoot, baseBranch, lumpVariables: lumpVariablesInput, contextVariables = {}, remoteName = "origin", logger, } = params;
|
|
3870
|
+
const lumpVariables = (lumpVariablesInput ?? {});
|
|
3868
3871
|
const commitMessage = gitCommitMessageFn({
|
|
3869
3872
|
context: { name: contextName, variables: contextVariables },
|
|
3870
3873
|
lumpVariables,
|
|
@@ -3984,7 +3987,6 @@ async function getToDoContextList(params) {
|
|
|
3984
3987
|
}
|
|
3985
3988
|
|
|
3986
3989
|
const contextStatus = ['toDo', 'branchPushed', 'finished'];
|
|
3987
|
-
const contextStatusSchema = z.enum(contextStatus);
|
|
3988
3990
|
|
|
3989
3991
|
const defaultGitCommitMessageFn = ({ context }) => {
|
|
3990
3992
|
return `LUMP:${context.name}`;
|
|
@@ -4034,7 +4036,8 @@ const defaultSetupWorkspaceFnWithWorktree = async (input) => {
|
|
|
4034
4036
|
};
|
|
4035
4037
|
|
|
4036
4038
|
async function runLump(input) {
|
|
4037
|
-
const { baseBranch, branchFn, lumpVariables
|
|
4039
|
+
const { baseBranch, branchFn, lumpVariables: lumpVariablesInput, getContextListFn, gitAddCommandFn = defaultGitAddCommandFn, gitCommitCommandFn = defaultGitCommitCommandFn, gitCommitMessageFn = defaultGitCommitMessageFn, gitPushCommandFn = defaultGitPushCommandFn, numberOfContextsPerBranch = 1, projectRoot, steps, setupFn = () => ({ contextRunState: {} }), setupWorkspaceFn = defaultSetupWorkspaceFn, teardownFn = () => undefined, teardownWorkspaceFn = defaultTeardownWorkspaceFn, getKeepHistoryFilePathFn = () => undefined, logger: loggerInput, } = input;
|
|
4040
|
+
const lumpVariables = (lumpVariablesInput ?? {});
|
|
4038
4041
|
const logger = loggerInput ?? createConsoleLogger({});
|
|
4039
4042
|
const contextListToDoResult = await getToDoContextList({
|
|
4040
4043
|
getContextListFn,
|
|
@@ -4091,7 +4094,6 @@ async function runLump(input) {
|
|
|
4091
4094
|
exports.appendHistoryEntry = appendHistoryEntry;
|
|
4092
4095
|
exports.collectStepsForContext = collectStepsForContext;
|
|
4093
4096
|
exports.contextStatus = contextStatus;
|
|
4094
|
-
exports.contextStatusSchema = contextStatusSchema;
|
|
4095
4097
|
exports.createConsoleLogger = createConsoleLogger;
|
|
4096
4098
|
exports.defaultGitAddCommandFn = defaultGitAddCommandFn;
|
|
4097
4099
|
exports.defaultGitCommitCommandFn = defaultGitCommitCommandFn;
|