@lumpcode/core 0.0.5 → 0.0.6
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 +38 -31
- package/package.json +2 -2
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`
|
|
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
|
-
> **
|
|
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
|
-
- **`
|
|
80
|
-
- **`
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
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 [
|
|
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
|
|
|
@@ -181,7 +185,7 @@ See [Logging](#logging) below.
|
|
|
181
185
|
|
|
182
186
|
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.
|
|
183
187
|
|
|
184
|
-
The Lumpcode CLI sets this from lump config
|
|
188
|
+
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.
|
|
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:** ``
|
|
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:** ``
|
|
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:** ``
|
|
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
|
|
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
|
-
-
|
|
304
|
-
- **`
|
|
305
|
-
-
|
|
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 **`
|
|
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](
|
|
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 [
|
|
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
|
-
|
|
434
|
-
|
|
435
|
-
|
|
|
436
|
-
| `
|
|
437
|
-
| `
|
|
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
|
-
|
|
516
|
+
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lumpcode/core",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Core engine for Lumpcode —
|
|
3
|
+
"version": "0.0.6",
|
|
4
|
+
"description": "Core engine for Lumpcode agent loops — runLump orchestrates prompts across contexts with git-tracked progress",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "",
|
|
7
7
|
"type": "module",
|