@lumpcode/core 0.0.14 → 0.0.16

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.
Files changed (34) hide show
  1. package/README.md +7 -1
  2. package/dist/helpers/execBinary/main.d.ts +19 -5
  3. package/dist/helpers/execBinary/main.d.ts.map +1 -1
  4. package/dist/helpers/executeStepsForContextList/main.d.ts +10 -3
  5. package/dist/helpers/executeStepsForContextList/main.d.ts.map +1 -1
  6. package/dist/index.cjs +410 -159
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.js +409 -161
  9. package/dist/index.js.map +1 -1
  10. package/dist/testing/processTreeChild.d.cts +2 -0
  11. package/dist/testing/processTreeChild.d.cts.map +1 -0
  12. package/dist/testing/processTreeTestHelpers.d.ts +12 -0
  13. package/dist/testing/processTreeTestHelpers.d.ts.map +1 -0
  14. package/dist/testing/sigtermIgnorantTreeChild.d.cts +2 -0
  15. package/dist/testing/sigtermIgnorantTreeChild.d.cts.map +1 -0
  16. package/dist/types/ExecuteStepsFailureData.d.ts +6 -0
  17. package/dist/types/ExecuteStepsFailureData.d.ts.map +1 -0
  18. package/dist/types/ExecuteStepsFailureReason.d.ts +2 -0
  19. package/dist/types/ExecuteStepsFailureReason.d.ts.map +1 -0
  20. package/dist/types/index.d.ts +2 -0
  21. package/dist/types/index.d.ts.map +1 -1
  22. package/dist/usages/runLump/main.d.ts +4 -4
  23. package/dist/usages/runLump/main.d.ts.map +1 -1
  24. package/dist/utils/index.d.ts +3 -0
  25. package/dist/utils/index.d.ts.map +1 -1
  26. package/dist/utils/isProcessAlive/index.d.ts +2 -1
  27. package/dist/utils/isProcessAlive/index.d.ts.map +1 -1
  28. package/dist/utils/killProcessTree/index.d.ts +2 -0
  29. package/dist/utils/killProcessTree/index.d.ts.map +1 -0
  30. package/dist/utils/killProcessTree/main.d.ts +11 -0
  31. package/dist/utils/killProcessTree/main.d.ts.map +1 -0
  32. package/dist/utils/nodeErrnoCode/index.d.ts +1 -1
  33. package/dist/utils/nodeErrnoCode/index.d.ts.map +1 -1
  34. package/package.json +1 -1
package/README.md CHANGED
@@ -107,7 +107,7 @@ An array of `Step` objects that are executed sequentially for each context. Each
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
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
- | `timeoutMillis` | `number | undefined` | Maximum time in milliseconds allowed for the command execution. Defaults to `1800000` (30 minutes). |
110
+ | `timeoutMillis` | `number | undefined` | Maximum time in milliseconds allowed for the command execution. On expiry the process tree is terminated and the step fails with a timeout. Defaults to `1800000` (30 minutes). |
111
111
 
112
112
 
113
113
  Elements in the array can also be **functions** that return more `Steps` at runtime, enabling dynamic and recursive prompt chains. See [Recursive Steps](#recursive-steps) for details.
@@ -179,6 +179,12 @@ Optional operational logger. CLI callers should pass an explicit logger from `cr
179
179
 
180
180
  See [Logging](#logging) below.
181
181
 
182
+ #### `signal`
183
+
184
+ **Type:** `AbortSignal` -- **Default:** none
185
+
186
+ When aborted, the engine kills the in-flight command process tree and stops the step walk (even if the step has `continueOnError: true`). Step `timeoutMillis` expiry also terminates the process tree before failing the step.
187
+
182
188
  #### `getKeepHistoryFilePathFn`
183
189
 
184
190
  **Type:** `(context: Context) => string | undefined` -- **Default:** `() => undefined`
@@ -1,15 +1,29 @@
1
1
  import { type SpawnOptions } from 'node:child_process';
2
2
  import { Failure, Success } from '../../types';
3
- export declare function execBinary(binaryPath: string, args: string[], timeoutMillis?: number, options?: SpawnOptions): Promise<Success<{
4
- stdout: string;
5
- stderr: string;
6
- }> | Failure<{
3
+ export type ExecBinaryFailureReason = 'timeout' | 'aborted' | 'exit' | 'spawn';
4
+ export type ExecBinaryInput = {
5
+ binaryPath: string;
6
+ args: string[];
7
+ timeoutMillis?: number;
8
+ cwd?: string;
9
+ env?: NodeJS.ProcessEnv;
10
+ stdio?: SpawnOptions['stdio'];
11
+ signal?: AbortSignal;
12
+ /** Grace before SIGKILL after SIGTERM on cancel/timeout. Default 5000. */
13
+ killGraceMs?: number;
14
+ };
15
+ export type ExecBinaryFailure = {
7
16
  message: string;
8
17
  binaryPath: string;
9
18
  args: string[];
10
19
  code?: number;
11
20
  stdout?: string;
12
21
  stderr?: string;
13
- }>>;
22
+ reason?: ExecBinaryFailureReason;
23
+ };
24
+ export declare function execBinary(input: ExecBinaryInput): Promise<Success<{
25
+ stdout: string;
26
+ stderr: string;
27
+ }> | Failure<ExecBinaryFailure>>;
14
28
  export type ExecBinaryResponse = ReturnType<typeof execBinary>;
15
29
  //# sourceMappingURL=main.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/helpers/execBinary/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAG/C,wBAAgB,UAAU,CACtB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EAAE,EACd,aAAa,GAAE,MAAuB,EACtC,OAAO,CAAC,EAAE,YAAY,GACvB,OAAO,CACN,OAAO,CAAC;IACJ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC,GAAG,OAAO,CAAC;IACT,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC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AC,CAqHnF;AAED,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC"}
@@ -1,12 +1,19 @@
1
- import { ContextList, ContextRunState, Failure, Logger, LumpVariables, StepVariables } from "../../types";
1
+ import { ContextList, ContextRunState, ExecuteStepsFailureData, Failure, Logger, LumpVariables, StepVariables } from "../../types";
2
2
  import type { RunLumpInput } from '../../usages';
3
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
+ /** When aborted, in-flight commands are killed and the step walk stops (ignores continueOnError). */
7
+ signal?: AbortSignal;
6
8
  };
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<{
9
+ 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, signal, }: ExecuteStepsForContextListParams<V, SV>): Promise<Failure<{
8
10
  message: string;
9
- }> | import("../..").Success<{
11
+ info: {
12
+ command: string;
13
+ stdout: any;
14
+ stderr: any;
15
+ };
16
+ }> | Failure<ExecuteStepsFailureData> | import("../..").Success<{
10
17
  branchName: string;
11
18
  contextNames: string[];
12
19
  contextRunStateList: ContextRunState[];
@@ -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,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
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/helpers/executeStepsForContextList/main.ts"],"names":[],"mappings":"AAEA,OAAO,EACH,WAAW,EACX,eAAe,EACf,uBAAuB,EACvB,OAAO,EACP,MAAM,EACN,aAAa,EAIb,aAAa,EAChB,MAAM,aAAa,CAAC;AASrB,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;IAChB,qGAAqG;IACrG,MAAM,CAAC,EAAE,WAAW,CAAC;CACxB,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,EACnB,MAAM,GACT,EAAE,gCAAgC,CAAC,CAAC,EAAE,EAAE,CAAC;;;;;;;;;;;IA4UzC;AAED,MAAM,MAAM,gCAAgC,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC,CAAC"}