@lumpcode/core 0.0.5 → 0.0.7

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 CHANGED
@@ -1,12 +1,14 @@
1
1
  # @lumpcode/core
2
2
 
3
- The core engine of Lumpcode mainly exporting the `runLump` function.
3
+ The core engine of Lumpcode, mainly exporting the `runLump` function.
4
4
 
5
- `runLump` orchestrates prompts across multiple **contexts** each context is a unit of work (often a file or a logical group of files). Lumpcode scans your codebase, builds a list of contexts, filters out those already completed (each completed context is materialized as exactly one normalized commit on a remote branch), then runs your prompts on the rest, managing git branches and commits and tracking progress via normalized commit messages.
5
+ `runLump` drives one **agent loop** over a context list in a single invocation. Each context is a unit of work (often a file or a logical group of files). Lumpcode scans your codebase, builds a list of contexts, filters out those already completed (each completed context is materialized as exactly one normalized commit on a remote branch), then runs your prompts on the rest, managing git branches and commits and tracking progress via normalized commit messages.
6
+
7
+ **Agent loop campaigns** (`.lumpcode/lumps/` configs, daemon scheduling, `lump-status`, `clean`) are CLI-only. Core runs one agent loop per `runLump` call; use your own scheduler or the CLI to manage campaigns.
6
8
 
7
9
  `runLump` is very configurable but comes with sensible default behaviors.
8
10
 
9
- > **Tip:** for a much smoother end-to-end experience project bootstrap, an isolated working copy, an always-on daemon that calls `runLump` on a schedule, per-lump enable/disable, and built-in lump/context status — use the [Lumpcode CLI](https://lumpcode.com/cli) (based on the core package). It's the recommended way to drive this engine in real projects; this package is for basic usage on small projects.
11
+ > **Important:** `@lumpcode/core` is the engine only. For **agent loop campaign** management (project bootstrap, `.lumpcode/lumps/` configs, background daemon, status, and cleanup), use the [Lumpcode CLI](../apps/cli/README.md) (`npm install -g @lumpcode/cli`).
10
12
 
11
13
  ## Installation
12
14
 
@@ -76,8 +78,8 @@ interface Context {
76
78
  }
77
79
  ```
78
80
 
79
- - **`priority`** — Lower values are processed first. Defaults to `0`.
80
- - **`dependsOnContexts`**An array of context names that must have a `finished` status before this context is eligible to run. If any dependency has not finished yet (`toDo` or `branchPushed`), the context is excluded from the current batch. If a dependency name doesn't exist in the context list at all, the context is also blocked (safe default).
81
+ - `**priority**` — Lower values are processed first. Defaults to `0`.
82
+ - `**dependsOnContexts**` — Context names that must be `finished` before this context is eligible. If any dependency is still `toDo` or `branchPushed`, the context is excluded from the current batch. Core resolves each entry marker commit with your `gitCommitMessageFn`. The [Lumpcode CLI](../apps/cli/README.md) can wire **cross-lump** dependencies between lumps in the same project see [CLI lump config](../apps/cli/DOCS/lump-config.md#context-ordering-and-cross-lump-dependencies).
81
83
 
82
84
  ### CodeBasePath
83
85
 
@@ -98,13 +100,15 @@ A mutable `Record<string, unknown>` that persists across prompt executions withi
98
100
 
99
101
  An array of `Step` objects that are executed sequentially for each context. Each `Step` groups the following fields:
100
102
 
101
- | Field | Type | Description |
102
- |---|---|---|
103
- | `promptFn` | `PromptFn \| undefined` | Optional. Generates the prompt string from the current context, run state, and variables. When omitted, `commandFn` receives an empty prompt string. |
104
- | `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. |
105
- | `stepVariables` | `StepVariables \| undefined` | Optional extra variables passed into `promptFn`, `commandFn`, and `postCommandExecFn`. |
106
- | `postCommandExecFn` | `PostCommandExecFn \| undefined` | Optional hook called after the command finishes, receiving the command output. |
107
- | `timeoutMillis` | `number \| undefined` | Maximum time in milliseconds allowed for the command execution. Defaults to `1800000` (30 minutes). |
103
+
104
+ | Field | Type | Description |
105
+ | ------------------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
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
+ | `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
+ | `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. |
110
+ | `timeoutMillis` | `number | undefined` | Maximum time in milliseconds allowed for the command execution. Defaults to `1800000` (30 minutes). |
111
+
108
112
 
109
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.
110
114
 
@@ -118,7 +122,7 @@ Elements in the array can also be **functions** that return more `Steps` at runt
118
122
 
119
123
  Absolute path to the root of the project Lumpcode will operate on. This directory is scanned to build the list of `CodeBasePath` entries.
120
124
 
121
- We recommend pointing `projectRoot` to a **separate copy** of your project rather than the directory you are manually working in, so that Lumpcode's git operations don't interfere with your own work. Where prompts and git commands actually run is determined by [`setupWorkspaceFn`](#setupworkspacefn) (see `workspacePath` there). The [Lumpcode CLI](https://lumpcode.com/cli) handles this isolated copy for you.
125
+ We recommend pointing `projectRoot` to a **separate copy** of your project rather than the directory you are manually working in, so that Lumpcode's git operations don't interfere with your own work. Where prompts and git commands actually run is determined by `[setupWorkspaceFn](#setupworkspacefn)` (see `workspacePath` there). The [Lumpcode CLI](../apps/cli/README.md) handles this isolated copy for you.
122
126
 
123
127
  #### `baseBranch`
124
128
 
@@ -179,9 +183,9 @@ See [Logging](#logging) below.
179
183
 
180
184
  **Type:** `(context: Context) => string | undefined` -- **Default:** `() => undefined`
181
185
 
182
- When this function returns a non-empty path for a context, the engine appends one JSON object per prompt step (after each successful agent command) to that file. The file is a JSON array; each element has the same shape as `postCommandExecFn` input (`commandResult`, `context`, `prompt`, `stepIndex`, `contextRunState`, `lumpVariables`, optional `stepVariables`, `projectRoot`). Parent directories are created with `mkdir(..., { recursive: true })` before the initial `[]` write.
186
+ When this function returns a non-empty path for a context, the engine appends one YAML mapping per prompt step (after each successful agent command) to that file. The file is a YAML sequence (array); each element has the same shape as `postCommandExecFn` input (`commandResult`, `commandSucceeded`, `context`, `prompt`, `stepIndex`, `contextRunState`, `lumpVariables`, optional `stepVariables`, `projectRoot`). Multi-line `prompt` and `commandResult` values are stored as literal block scalars. Parent directories are created with `mkdir(..., { recursive: true })` before the initial `[]` write. Paths must use a `.yaml` or `.yml` extension.
183
187
 
184
- The Lumpcode CLI sets this from lump config **`keepHistory: true`**, writing to `.lumpcode/lumps/<lumpName>/history/<contextName>.json`. Library callers can supply a custom function for other paths or naming.
188
+ The Lumpcode CLI sets this from lump config **`keepHistory: true`**, writing to `.lumpcode/lumps/<lumpName>/history/<contextName>.yaml`. Library callers can supply a custom function for other paths or naming.
185
189
 
186
190
  ## Advanced Parameters
187
191
 
@@ -226,7 +230,7 @@ Called after each context finishes. Use it for cleanup or logging.
226
230
 
227
231
  ### `gitCommitMessageFn`
228
232
 
229
- **Type:** `GitCommitMessageFn` -- **Default:** `` `LUMP:${context.name}` ``
233
+ **Type:** `GitCommitMessageFn` -- **Default:** ``LUMP:${context.name}``
230
234
 
231
235
  ```typescript
232
236
  type GitCommitMessageFn = (input: {
@@ -246,13 +250,13 @@ Customize the git add command. Receives `{ baseBranch, branchName, contextList,
246
250
 
247
251
  ### `gitCommitCommandFn`
248
252
 
249
- **Type:** `GitCommitCommandFn` -- **Default:** `` `git commit -m "${commitMessage}"` ``
253
+ **Type:** `GitCommitCommandFn` -- **Default:** ``git commit -m "${commitMessage}"``
250
254
 
251
255
  Customize the git commit command. Receives the same input as `gitAddCommandFn` plus `{ commitMessage }`. Invoked **once per context**, producing exactly one commit per context on the work branch.
252
256
 
253
257
  ### `gitPushCommandFn`
254
258
 
255
- **Type:** `GitPushCommandFn` -- **Default:** `` `git push origin ${branchName}` ``
259
+ **Type:** `GitPushCommandFn` -- **Default:** ``git push origin ${branchName}``
256
260
 
257
261
  Customize the git push command. Invoked **once per branch**, after all per-context commits are made.
258
262
 
@@ -288,7 +292,7 @@ Cleans up the workspace after all contexts on a branch are done. The default swi
288
292
 
289
293
  ## Logging
290
294
 
291
- Operational runtime output uses a small shared **`Logger`** type exported from `@lumpcode/core`:
295
+ Operational runtime output uses a small shared `**Logger`** type exported from `@lumpcode/core`:
292
296
 
293
297
  ```typescript
294
298
  type Logger = {
@@ -300,11 +304,11 @@ type Logger = {
300
304
  };
301
305
  ```
302
306
 
303
- - **`createConsoleLogger({ verbose?, json?, prefix? })`** — console-backed implementation (`error` always prints; `verbose` gated by `verbose`; when `json: true`, non-error levels are suppressed).
304
- - **`noopLogger`** — no-op logger for tests.
305
- - **`formatExecFailureMessage({ label, failure })`** — user-facing shell/git failure strings.
307
+ - `**createConsoleLogger({ verbose?, json?, prefix? })**` — console-backed implementation (`error` always prints; `verbose` gated by `verbose`; when `json: true`, non-error levels are suppressed).
308
+ - `**noopLogger**` — no-op logger for tests.
309
+ - `**formatExecFailureMessage({ label, failure })**` — user-facing shell/git failure strings.
306
310
 
307
- Pass **`logger`** on `RunLumpInput`. When omitted, the engine uses `createConsoleLogger({})` (operational errors/warnings/progress only; no verbose detail unless the logger you pass enables it).
311
+ Pass `**logger**` on `RunLumpInput`. When omitted, the engine uses `createConsoleLogger({})` (operational errors/warnings/progress only; no verbose detail unless the logger you pass enables it).
308
312
 
309
313
  ## Return Value
310
314
 
@@ -414,7 +418,7 @@ const steps: Steps = [
414
418
 
415
419
  Lumpcode uses normalized git commit messages to record which contexts have already been processed. Each completed context contributes **exactly one commit** whose subject equals `gitCommitMessageFn({ context, ... })`. On every subsequent call to `runLump`, contexts whose normalized commit message is already present on a remote branch are skipped so the run only works on what remains. This lets you call `runLump` repeatedly (e.g. in a cron job) and each invocation picks up where the previous one left off, progressively working through the full context list without ever re-processing a context.
416
420
 
417
- > If you'd rather not wire up your own scheduler, the [Lumpcode CLI](https://lumpcode.com/cli) ships a built-in daemon (`lumpcode start`) that calls `runLump` on a tick, with concurrent-branch limits and per-lump enable/disable already wired in.
421
+ > If you'd rather not wire up your own scheduler, the [Lumpcode CLI](../apps/cli/README.md) ships a built-in daemon (`lumpcode start`) that calls `runLump` on a tick, with concurrent-branch limits and per-lump enable/disable already wired in.
418
422
 
419
423
  ### Commit message naming
420
424
 
@@ -424,17 +428,21 @@ By default, a context named `my_component_ts` produces a commit with the subject
424
428
  LUMP:my_component_ts
425
429
  ```
426
430
 
427
- You can customize this via the [`gitCommitMessageFn`](#gitcommitmessagefn) parameter. The returned subject **must be unique per context** -- it is the only thing tying the commit back to its context.
431
+ You can customize this via the `[gitCommitMessageFn](#gitcommitmessagefn)` parameter. The returned subject **must be unique per context** -- it is the only thing tying the commit back to its context.
428
432
 
429
433
  ### Context statuses
430
434
 
435
+ CLI users: marker format is `LUMP: <lumpName> - <contextName>` — see [concepts.md](../apps/cli/DOCS/concepts.md).
436
+
431
437
  When filtering contexts, Lumpcode resolves each context's normalized commit message to one of three statuses:
432
438
 
433
- | Status | Meaning | Effect |
434
- |---|---|---|
435
- | `toDo` | No commit with the context's normalized message exists on any remote ref. | Will be processed (unless blocked by `dependsOnContexts`). |
436
- | `branchPushed` | A commit with the context's normalized message exists on a remote branch other than the base branch. | Skipped. |
437
- | `finished` | A commit with the context's normalized message is reachable from `origin/<baseBranch>`. | Skipped. |
439
+
440
+ | Status | Meaning | Effect |
441
+ | -------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
442
+ | `toDo` | No commit with the context's normalized message exists on any remote ref. | Will be processed (unless blocked by `dependsOnContexts`). |
443
+ | `branchPushed` | A commit with the context's normalized message exists on a remote branch other than the base branch. | Skipped. |
444
+ | `finished` | A commit with the context's normalized message is reachable from `origin/<baseBranch>`. | Skipped. |
445
+
438
446
 
439
447
  A context with `dependsOnContexts` is only eligible when **all** of its listed dependencies have the `finished` status. This means the dependency's commit must be reachable from the remote base branch. Contexts stuck at `branchPushed` do not satisfy the dependency.
440
448
 
@@ -504,6 +512,5 @@ flowchart TD
504
512
  TeardownWorkspace --> Done["Return Success or Failure"]
505
513
  ```
506
514
 
507
- ## Going further
508
515
 
509
- `@lumpcode/core` is the engine. The [Lumpcode CLI](https://lumpcode.com/cli) wraps it with everything you'd otherwise have to build yourself: project bootstrap, a managed working copy isolated from your IDE, a background daemon, status/cleanup commands, authentication, and a single-binary distribution. Reach for it whenever you want the full experience.
516
+
@@ -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,EAIT,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAIjD,MAAM,MAAM,gCAAgC,GAAG,QAAQ,CAAC,IAAI,CACxD,YAAY,EACV,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,CAAC,EAC7C,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;aAgEa,MAAM;;;;;IAyOrD;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,OAAO,EACP,MAAM,EAIT,MAAM,aAAa,CAAC;AAUrB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,MAAM,gCAAgC,GAAG,QAAQ,CAAC,IAAI,CACxD,YAAY,EACV,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,CAAC,EAC7C,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;aAgEa,MAAM;;;;;IAmOrD;AAED,MAAM,MAAM,gCAAgC,GAAG,OAAO,CAAC,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC,CAAC"}
@@ -9,5 +9,5 @@ export declare function getToDoContextList(params: {
9
9
  logger?: Logger;
10
10
  }): Promise<import("../../types").Failure<{
11
11
  message: string;
12
- }> | import("../../types").Success<import("../../types").Context[]>>;
12
+ }> | import("../../types").Success<import("../../types").Context<Record<string, string | number | boolean>>[]>>;
13
13
  //# sourceMappingURL=main.d.ts.map
@@ -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;IAC7C,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,aAAa,EAAE,aAAa,CAAC;IAC7B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;;qEA8DA"}
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;IAC7C,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,aAAa,EAAE,aAAa,CAAC;IAC7B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;;gHA8DA"}