@mobrienv/autoloop 0.4.0 → 0.7.0
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 +40 -14
- package/bin/autoloop +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/testing/mock-backend.js +3 -5
- package/dist/testing/mock-backend.js.map +1 -1
- package/package.json +30 -23
- package/plugins/autoloop/.claude-plugin/plugin.json +1 -1
- package/dist/agent-map.d.ts +0 -10
- package/dist/agent-map.js +0 -58
- package/dist/agent-map.js.map +0 -1
- package/dist/backend/acp-client.d.ts +0 -38
- package/dist/backend/acp-client.js +0 -293
- package/dist/backend/acp-client.js.map +0 -1
- package/dist/backend/index.d.ts +0 -10
- package/dist/backend/index.js +0 -71
- package/dist/backend/index.js.map +0 -1
- package/dist/backend/kiro-bridge.d.ts +0 -19
- package/dist/backend/kiro-bridge.js +0 -114
- package/dist/backend/kiro-bridge.js.map +0 -1
- package/dist/backend/kiro-worker.d.ts +0 -1
- package/dist/backend/kiro-worker.js +0 -96
- package/dist/backend/kiro-worker.js.map +0 -1
- package/dist/backend/run-command.d.ts +0 -7
- package/dist/backend/run-command.js +0 -50
- package/dist/backend/run-command.js.map +0 -1
- package/dist/backend/run-kiro.d.ts +0 -3
- package/dist/backend/run-kiro.js +0 -16
- package/dist/backend/run-kiro.js.map +0 -1
- package/dist/backend/run-mock.d.ts +0 -1
- package/dist/backend/run-mock.js +0 -6
- package/dist/backend/run-mock.js.map +0 -1
- package/dist/backend/run-pi.d.ts +0 -5
- package/dist/backend/run-pi.js +0 -5
- package/dist/backend/run-pi.js.map +0 -1
- package/dist/backend/types.d.ts +0 -21
- package/dist/backend/types.js +0 -2
- package/dist/backend/types.js.map +0 -1
- package/dist/chains/budget.d.ts +0 -7
- package/dist/chains/budget.js +0 -54
- package/dist/chains/budget.js.map +0 -1
- package/dist/chains/load.d.ts +0 -18
- package/dist/chains/load.js +0 -129
- package/dist/chains/load.js.map +0 -1
- package/dist/chains/render.d.ts +0 -2
- package/dist/chains/render.js +0 -74
- package/dist/chains/render.js.map +0 -1
- package/dist/chains/run.d.ts +0 -17
- package/dist/chains/run.js +0 -260
- package/dist/chains/run.js.map +0 -1
- package/dist/chains/types.d.ts +0 -38
- package/dist/chains/types.js +0 -2
- package/dist/chains/types.js.map +0 -1
- package/dist/chains.d.ts +0 -6
- package/dist/chains.js +0 -5
- package/dist/chains.js.map +0 -1
- package/dist/cli/color.d.ts +0 -6
- package/dist/cli/color.js +0 -40
- package/dist/cli/color.js.map +0 -1
- package/dist/commands/chain.d.ts +0 -1
- package/dist/commands/chain.js +0 -53
- package/dist/commands/chain.js.map +0 -1
- package/dist/commands/config.d.ts +0 -1
- package/dist/commands/config.js +0 -74
- package/dist/commands/config.js.map +0 -1
- package/dist/commands/dashboard.d.ts +0 -1
- package/dist/commands/dashboard.js +0 -68
- package/dist/commands/dashboard.js.map +0 -1
- package/dist/commands/guide.d.ts +0 -1
- package/dist/commands/guide.js +0 -33
- package/dist/commands/guide.js.map +0 -1
- package/dist/commands/inspect.d.ts +0 -1
- package/dist/commands/inspect.js +0 -243
- package/dist/commands/inspect.js.map +0 -1
- package/dist/commands/list.d.ts +0 -1
- package/dist/commands/list.js +0 -15
- package/dist/commands/list.js.map +0 -1
- package/dist/commands/loops.d.ts +0 -1
- package/dist/commands/loops.js +0 -72
- package/dist/commands/loops.js.map +0 -1
- package/dist/commands/memory.d.ts +0 -1
- package/dist/commands/memory.js +0 -65
- package/dist/commands/memory.js.map +0 -1
- package/dist/commands/pi-adapter.d.ts +0 -1
- package/dist/commands/pi-adapter.js +0 -6
- package/dist/commands/pi-adapter.js.map +0 -1
- package/dist/commands/run.d.ts +0 -1
- package/dist/commands/run.js +0 -292
- package/dist/commands/run.js.map +0 -1
- package/dist/commands/runs.d.ts +0 -1
- package/dist/commands/runs.js +0 -50
- package/dist/commands/runs.js.map +0 -1
- package/dist/commands/task.d.ts +0 -1
- package/dist/commands/task.js +0 -74
- package/dist/commands/task.js.map +0 -1
- package/dist/commands/worktree.d.ts +0 -1
- package/dist/commands/worktree.js +0 -162
- package/dist/commands/worktree.js.map +0 -1
- package/dist/config.d.ts +0 -31
- package/dist/config.js +0 -261
- package/dist/config.js.map +0 -1
- package/dist/dashboard/app.d.ts +0 -12
- package/dist/dashboard/app.js +0 -23
- package/dist/dashboard/app.js.map +0 -1
- package/dist/dashboard/routes/api.d.ts +0 -3
- package/dist/dashboard/routes/api.js +0 -186
- package/dist/dashboard/routes/api.js.map +0 -1
- package/dist/dashboard/routes/pages.d.ts +0 -2
- package/dist/dashboard/routes/pages.js +0 -16
- package/dist/dashboard/routes/pages.js.map +0 -1
- package/dist/dashboard/views/alpine-vendor.d.ts +0 -1
- package/dist/dashboard/views/alpine-vendor.js +0 -10
- package/dist/dashboard/views/alpine-vendor.js.map +0 -1
- package/dist/dashboard/views/shell.d.ts +0 -1
- package/dist/dashboard/views/shell.js +0 -1062
- package/dist/dashboard/views/shell.js.map +0 -1
- package/dist/events/decode.d.ts +0 -2
- package/dist/events/decode.js +0 -45
- package/dist/events/decode.js.map +0 -1
- package/dist/events/encode.d.ts +0 -2
- package/dist/events/encode.js +0 -33
- package/dist/events/encode.js.map +0 -1
- package/dist/events/guards.d.ts +0 -5
- package/dist/events/guards.js +0 -42
- package/dist/events/guards.js.map +0 -1
- package/dist/events/types.d.ts +0 -27
- package/dist/events/types.js +0 -2
- package/dist/events/types.js.map +0 -1
- package/dist/harness/artifacts.d.ts +0 -50
- package/dist/harness/artifacts.js +0 -333
- package/dist/harness/artifacts.js.map +0 -1
- package/dist/harness/config-helpers.d.ts +0 -35
- package/dist/harness/config-helpers.js +0 -409
- package/dist/harness/config-helpers.js.map +0 -1
- package/dist/harness/coordination.d.ts +0 -1
- package/dist/harness/coordination.js +0 -127
- package/dist/harness/coordination.js.map +0 -1
- package/dist/harness/display.d.ts +0 -21
- package/dist/harness/display.js +0 -176
- package/dist/harness/display.js.map +0 -1
- package/dist/harness/emit.d.ts +0 -15
- package/dist/harness/emit.js +0 -240
- package/dist/harness/emit.js.map +0 -1
- package/dist/harness/index.d.ts +0 -20
- package/dist/harness/index.js +0 -311
- package/dist/harness/index.js.map +0 -1
- package/dist/harness/iteration.d.ts +0 -16
- package/dist/harness/iteration.js +0 -131
- package/dist/harness/iteration.js.map +0 -1
- package/dist/harness/journal-format.d.ts +0 -25
- package/dist/harness/journal-format.js +0 -153
- package/dist/harness/journal-format.js.map +0 -1
- package/dist/harness/journal.d.ts +0 -31
- package/dist/harness/journal.js +0 -178
- package/dist/harness/journal.js.map +0 -1
- package/dist/harness/metareview.d.ts +0 -4
- package/dist/harness/metareview.js +0 -48
- package/dist/harness/metareview.js.map +0 -1
- package/dist/harness/metrics.d.ts +0 -12
- package/dist/harness/metrics.js +0 -180
- package/dist/harness/metrics.js.map +0 -1
- package/dist/harness/parallel.d.ts +0 -37
- package/dist/harness/parallel.js +0 -237
- package/dist/harness/parallel.js.map +0 -1
- package/dist/harness/prompt.d.ts +0 -46
- package/dist/harness/prompt.js +0 -403
- package/dist/harness/prompt.js.map +0 -1
- package/dist/harness/scratchpad.d.ts +0 -2
- package/dist/harness/scratchpad.js +0 -67
- package/dist/harness/scratchpad.js.map +0 -1
- package/dist/harness/stop.d.ts +0 -5
- package/dist/harness/stop.js +0 -70
- package/dist/harness/stop.js.map +0 -1
- package/dist/harness/tools.d.ts +0 -3
- package/dist/harness/tools.js +0 -65
- package/dist/harness/tools.js.map +0 -1
- package/dist/harness/types.d.ts +0 -110
- package/dist/harness/types.js +0 -2
- package/dist/harness/types.js.map +0 -1
- package/dist/harness/wave/finalize-wave.d.ts +0 -9
- package/dist/harness/wave/finalize-wave.js +0 -87
- package/dist/harness/wave/finalize-wave.js.map +0 -1
- package/dist/harness/wave/launch-branches.d.ts +0 -6
- package/dist/harness/wave/launch-branches.js +0 -314
- package/dist/harness/wave/launch-branches.js.map +0 -1
- package/dist/harness/wave/parse-objectives.d.ts +0 -3
- package/dist/harness/wave/parse-objectives.js +0 -32
- package/dist/harness/wave/parse-objectives.js.map +0 -1
- package/dist/harness/wave/types.d.ts +0 -43
- package/dist/harness/wave/types.js +0 -2
- package/dist/harness/wave/types.js.map +0 -1
- package/dist/harness/wave.d.ts +0 -6
- package/dist/harness/wave.js +0 -159
- package/dist/harness/wave.js.map +0 -1
- package/dist/isolation/index.d.ts +0 -4
- package/dist/isolation/index.js +0 -3
- package/dist/isolation/index.js.map +0 -1
- package/dist/isolation/resolve.d.ts +0 -39
- package/dist/isolation/resolve.js +0 -118
- package/dist/isolation/resolve.js.map +0 -1
- package/dist/isolation/run-scope.d.ts +0 -21
- package/dist/isolation/run-scope.js +0 -50
- package/dist/isolation/run-scope.js.map +0 -1
- package/dist/json.d.ts +0 -8
- package/dist/json.js +0 -82
- package/dist/json.js.map +0 -1
- package/dist/loops/health.d.ts +0 -17
- package/dist/loops/health.js +0 -152
- package/dist/loops/health.js.map +0 -1
- package/dist/loops/list.d.ts +0 -6
- package/dist/loops/list.js +0 -21
- package/dist/loops/list.js.map +0 -1
- package/dist/loops/policy.d.ts +0 -6
- package/dist/loops/policy.js +0 -41
- package/dist/loops/policy.js.map +0 -1
- package/dist/loops/render.d.ts +0 -19
- package/dist/loops/render.js +0 -100
- package/dist/loops/render.js.map +0 -1
- package/dist/loops/show.d.ts +0 -8
- package/dist/loops/show.js +0 -31
- package/dist/loops/show.js.map +0 -1
- package/dist/loops/watch.d.ts +0 -14
- package/dist/loops/watch.js +0 -143
- package/dist/loops/watch.js.map +0 -1
- package/dist/main.d.ts +0 -1
- package/dist/main.js +0 -148
- package/dist/main.js.map +0 -1
- package/dist/markdown.d.ts +0 -10
- package/dist/markdown.js +0 -66
- package/dist/markdown.js.map +0 -1
- package/dist/memory-render.d.ts +0 -6
- package/dist/memory-render.js +0 -81
- package/dist/memory-render.js.map +0 -1
- package/dist/memory.d.ts +0 -22
- package/dist/memory.js +0 -318
- package/dist/memory.js.map +0 -1
- package/dist/pi-adapter.d.ts +0 -1
- package/dist/pi-adapter.js +0 -220
- package/dist/pi-adapter.js.map +0 -1
- package/dist/profiles.d.ts +0 -12
- package/dist/profiles.js +0 -71
- package/dist/profiles.js.map +0 -1
- package/dist/registry/derive.d.ts +0 -8
- package/dist/registry/derive.js +0 -88
- package/dist/registry/derive.js.map +0 -1
- package/dist/registry/discover.d.ts +0 -20
- package/dist/registry/discover.js +0 -98
- package/dist/registry/discover.js.map +0 -1
- package/dist/registry/harness.d.ts +0 -7
- package/dist/registry/harness.js +0 -63
- package/dist/registry/harness.js.map +0 -1
- package/dist/registry/index.d.ts +0 -6
- package/dist/registry/index.js +0 -6
- package/dist/registry/index.js.map +0 -1
- package/dist/registry/read.d.ts +0 -11
- package/dist/registry/read.js +0 -50
- package/dist/registry/read.js.map +0 -1
- package/dist/registry/rebuild.d.ts +0 -5
- package/dist/registry/rebuild.js +0 -22
- package/dist/registry/rebuild.js.map +0 -1
- package/dist/registry/types.d.ts +0 -28
- package/dist/registry/types.js +0 -2
- package/dist/registry/types.js.map +0 -1
- package/dist/registry/update.d.ts +0 -2
- package/dist/registry/update.js +0 -7
- package/dist/registry/update.js.map +0 -1
- package/dist/tasks-render.d.ts +0 -2
- package/dist/tasks-render.js +0 -44
- package/dist/tasks-render.js.map +0 -1
- package/dist/tasks.d.ts +0 -24
- package/dist/tasks.js +0 -184
- package/dist/tasks.js.map +0 -1
- package/dist/topology.d.ts +0 -31
- package/dist/topology.js +0 -309
- package/dist/topology.js.map +0 -1
- package/dist/usage.d.ts +0 -9
- package/dist/usage.js +0 -160
- package/dist/usage.js.map +0 -1
- package/dist/utils.d.ts +0 -21
- package/dist/utils.js +0 -349
- package/dist/utils.js.map +0 -1
- package/dist/worktree/clean.d.ts +0 -12
- package/dist/worktree/clean.js +0 -113
- package/dist/worktree/clean.js.map +0 -1
- package/dist/worktree/create.d.ts +0 -14
- package/dist/worktree/create.js +0 -71
- package/dist/worktree/create.js.map +0 -1
- package/dist/worktree/index.d.ts +0 -10
- package/dist/worktree/index.js +0 -6
- package/dist/worktree/index.js.map +0 -1
- package/dist/worktree/list.d.ts +0 -9
- package/dist/worktree/list.js +0 -24
- package/dist/worktree/list.js.map +0 -1
- package/dist/worktree/merge.d.ts +0 -11
- package/dist/worktree/merge.js +0 -129
- package/dist/worktree/merge.js.map +0 -1
- package/dist/worktree/meta.d.ts +0 -17
- package/dist/worktree/meta.js +0 -34
- package/dist/worktree/meta.js.map +0 -1
- package/presets/autocode/README.md +0 -81
- package/presets/autocode/autoloops.toml +0 -30
- package/presets/autocode/harness.md +0 -26
- package/presets/autocode/miniloops.toml +0 -22
- package/presets/autocode/roles/build.md +0 -34
- package/presets/autocode/roles/critic.md +0 -40
- package/presets/autocode/roles/finalizer.md +0 -43
- package/presets/autocode/roles/planner.md +0 -40
- package/presets/autocode/topology.toml +0 -32
- package/presets/autodebug/README.md +0 -50
- package/presets/autodebug/autoloops.toml +0 -18
- package/presets/autodebug/harness.md +0 -31
- package/presets/autodebug/roles/fixer.md +0 -58
- package/presets/autodebug/roles/investigator.md +0 -52
- package/presets/autodebug/roles/strategist.md +0 -45
- package/presets/autodebug/roles/verifier.md +0 -66
- package/presets/autodebug/topology.toml +0 -34
- package/presets/autodoc/README.md +0 -42
- package/presets/autodoc/autoloops.toml +0 -21
- package/presets/autodoc/harness.md +0 -19
- package/presets/autodoc/miniloops.toml +0 -21
- package/presets/autodoc/roles/auditor.md +0 -39
- package/presets/autodoc/roles/checker.md +0 -43
- package/presets/autodoc/roles/publisher.md +0 -51
- package/presets/autodoc/roles/writer.md +0 -37
- package/presets/autodoc/topology.toml +0 -31
- package/presets/autofix/README.md +0 -56
- package/presets/autofix/autoloops.toml +0 -24
- package/presets/autofix/harness.md +0 -25
- package/presets/autofix/miniloops.toml +0 -21
- package/presets/autofix/roles/closer.md +0 -48
- package/presets/autofix/roles/diagnoser.md +0 -43
- package/presets/autofix/roles/fixer.md +0 -28
- package/presets/autofix/roles/verifier.md +0 -31
- package/presets/autofix/topology.toml +0 -33
- package/presets/autoideas/README.md +0 -73
- package/presets/autoideas/autoloops.toml +0 -18
- package/presets/autoideas/harness.md +0 -31
- package/presets/autoideas/miniloops.toml +0 -18
- package/presets/autoideas/roles/analyst.md +0 -32
- package/presets/autoideas/roles/reviewer.md +0 -36
- package/presets/autoideas/roles/scanner.md +0 -26
- package/presets/autoideas/roles/synthesizer.md +0 -61
- package/presets/autoideas/topology.toml +0 -32
- package/presets/automerge/README.md +0 -3
- package/presets/automerge/autoloops.toml +0 -12
- package/presets/automerge/harness.md +0 -10
- package/presets/automerge/miniloops.toml +0 -12
- package/presets/automerge/roles/merge.md +0 -10
- package/presets/automerge/topology.toml +0 -10
- package/presets/autoperf/README.md +0 -56
- package/presets/autoperf/autoloops.toml +0 -21
- package/presets/autoperf/harness.md +0 -21
- package/presets/autoperf/miniloops.toml +0 -21
- package/presets/autoperf/roles/judge.md +0 -38
- package/presets/autoperf/roles/measurer.md +0 -36
- package/presets/autoperf/roles/optimizer.md +0 -35
- package/presets/autoperf/roles/profiler.md +0 -38
- package/presets/autoperf/topology.toml +0 -32
- package/presets/autopr/README.md +0 -99
- package/presets/autopr/autoloops.toml +0 -22
- package/presets/autopr/harness.md +0 -27
- package/presets/autopr/miniloops.toml +0 -22
- package/presets/autopr/roles/collector.md +0 -55
- package/presets/autopr/roles/drafter.md +0 -38
- package/presets/autopr/roles/publisher.md +0 -28
- package/presets/autopr/roles/validator.md +0 -31
- package/presets/autopr/topology.toml +0 -32
- package/presets/autopreset/README.md +0 -35
- package/presets/autopreset/autoloops.toml +0 -18
- package/presets/autopreset/harness.md +0 -38
- package/presets/autopreset/roles/designer.md +0 -33
- package/presets/autopreset/roles/finalizer.md +0 -23
- package/presets/autopreset/roles/generator.md +0 -34
- package/presets/autopreset/roles/validator.md +0 -31
- package/presets/autopreset/topology.toml +0 -32
- package/presets/autoqa/README.md +0 -105
- package/presets/autoqa/autoloops.toml +0 -21
- package/presets/autoqa/harness.md +0 -52
- package/presets/autoqa/miniloops.toml +0 -21
- package/presets/autoqa/roles/executor.md +0 -96
- package/presets/autoqa/roles/inspector.md +0 -100
- package/presets/autoqa/roles/planner.md +0 -87
- package/presets/autoqa/roles/reporter.md +0 -117
- package/presets/autoqa/topology.toml +0 -31
- package/presets/autoresearch/README.md +0 -63
- package/presets/autoresearch/autoloops.toml +0 -18
- package/presets/autoresearch/harness.md +0 -28
- package/presets/autoresearch/miniloops.toml +0 -18
- package/presets/autoresearch/roles/benchmarker.md +0 -34
- package/presets/autoresearch/roles/evaluator.md +0 -33
- package/presets/autoresearch/roles/implementer.md +0 -26
- package/presets/autoresearch/roles/strategist.md +0 -43
- package/presets/autoresearch/topology.toml +0 -31
- package/presets/autoreview/README.md +0 -51
- package/presets/autoreview/autoloops.toml +0 -21
- package/presets/autoreview/harness.md +0 -20
- package/presets/autoreview/miniloops.toml +0 -21
- package/presets/autoreview/roles/checker.md +0 -36
- package/presets/autoreview/roles/reader.md +0 -33
- package/presets/autoreview/roles/suggester.md +0 -26
- package/presets/autoreview/roles/summarizer.md +0 -57
- package/presets/autoreview/topology.toml +0 -31
- package/presets/autosec/README.md +0 -51
- package/presets/autosec/autoloops.toml +0 -21
- package/presets/autosec/harness.md +0 -20
- package/presets/autosec/miniloops.toml +0 -21
- package/presets/autosec/roles/analyst.md +0 -38
- package/presets/autosec/roles/hardener.md +0 -36
- package/presets/autosec/roles/reporter.md +0 -63
- package/presets/autosec/roles/scanner.md +0 -38
- package/presets/autosec/topology.toml +0 -31
- package/presets/autosimplify/README.md +0 -83
- package/presets/autosimplify/autoloops.toml +0 -26
- package/presets/autosimplify/harness.md +0 -25
- package/presets/autosimplify/miniloops.toml +0 -22
- package/presets/autosimplify/roles/reviewer.md +0 -38
- package/presets/autosimplify/roles/scoper.md +0 -42
- package/presets/autosimplify/roles/simplifier.md +0 -51
- package/presets/autosimplify/roles/verifier.md +0 -40
- package/presets/autosimplify/topology.toml +0 -32
- package/presets/autospec/README.md +0 -84
- package/presets/autospec/autoloops.toml +0 -21
- package/presets/autospec/harness.md +0 -23
- package/presets/autospec/miniloops.toml +0 -21
- package/presets/autospec/roles/clarifier.md +0 -39
- package/presets/autospec/roles/critic.md +0 -41
- package/presets/autospec/roles/designer.md +0 -37
- package/presets/autospec/roles/planner.md +0 -38
- package/presets/autospec/roles/researcher.md +0 -33
- package/presets/autospec/topology.toml +0 -38
- package/presets/autotest/README.md +0 -55
- package/presets/autotest/autoloops.toml +0 -21
- package/presets/autotest/harness.md +0 -21
- package/presets/autotest/miniloops.toml +0 -21
- package/presets/autotest/roles/assessor.md +0 -57
- package/presets/autotest/roles/runner.md +0 -31
- package/presets/autotest/roles/surveyor.md +0 -39
- package/presets/autotest/roles/writer.md +0 -37
- package/presets/autotest/topology.toml +0 -32
package/dist/main.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import { join, resolve } from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { dispatchChain } from "./commands/chain.js";
|
|
5
|
-
import { dispatchConfig } from "./commands/config.js";
|
|
6
|
-
import { dispatchDashboard } from "./commands/dashboard.js";
|
|
7
|
-
import { dispatchGuide } from "./commands/guide.js";
|
|
8
|
-
import { dispatchInspect } from "./commands/inspect.js";
|
|
9
|
-
import { dispatchList } from "./commands/list.js";
|
|
10
|
-
import { dispatchLoops } from "./commands/loops.js";
|
|
11
|
-
import { dispatchMemory } from "./commands/memory.js";
|
|
12
|
-
import { dispatchPiAdapter } from "./commands/pi-adapter.js";
|
|
13
|
-
import { dispatchRun } from "./commands/run.js";
|
|
14
|
-
import { dispatchRuns } from "./commands/runs.js";
|
|
15
|
-
import { dispatchTask } from "./commands/task.js";
|
|
16
|
-
import { dispatchWorktree } from "./commands/worktree.js";
|
|
17
|
-
import * as harness from "./harness/index.js";
|
|
18
|
-
import { printEmitUsage, printUsage } from "./usage.js";
|
|
19
|
-
function main() {
|
|
20
|
-
const argv = process.argv;
|
|
21
|
-
const args = runtimeArgv(argv);
|
|
22
|
-
dispatch(args, argv);
|
|
23
|
-
}
|
|
24
|
-
function dispatch(args, argv) {
|
|
25
|
-
const cmd = args[0] ?? "";
|
|
26
|
-
const selfCmd = selfCommand(argv);
|
|
27
|
-
const bundleRoot = resolveBundleRoot(argv);
|
|
28
|
-
switch (cmd) {
|
|
29
|
-
case "--help":
|
|
30
|
-
case "-h":
|
|
31
|
-
printUsage();
|
|
32
|
-
return;
|
|
33
|
-
case "run":
|
|
34
|
-
dispatchRun(args.slice(1), argv, bundleRoot, selfCmd);
|
|
35
|
-
return;
|
|
36
|
-
case "emit":
|
|
37
|
-
if (!args[1] || args[1] === "--help" || args[1] === "-h") {
|
|
38
|
-
printEmitUsage();
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
harness.emit(resolveRuntimeProjectDir(), args[1], args.slice(2).join(" "));
|
|
42
|
-
return;
|
|
43
|
-
case "list":
|
|
44
|
-
dispatchList(args.slice(1), bundleRoot);
|
|
45
|
-
return;
|
|
46
|
-
case "loops":
|
|
47
|
-
dispatchLoops(args.slice(1));
|
|
48
|
-
return;
|
|
49
|
-
case "inspect":
|
|
50
|
-
dispatchInspect(args.slice(1));
|
|
51
|
-
return;
|
|
52
|
-
case "pi-adapter":
|
|
53
|
-
dispatchPiAdapter(args.slice(1));
|
|
54
|
-
return;
|
|
55
|
-
case "branch-run":
|
|
56
|
-
harness.runParallelBranchCli(args[1], args[2], selfCmd);
|
|
57
|
-
return;
|
|
58
|
-
case "memory":
|
|
59
|
-
dispatchMemory(args.slice(1));
|
|
60
|
-
return;
|
|
61
|
-
case "task":
|
|
62
|
-
dispatchTask(args.slice(1));
|
|
63
|
-
return;
|
|
64
|
-
case "worktree":
|
|
65
|
-
dispatchWorktree(args.slice(1));
|
|
66
|
-
return;
|
|
67
|
-
case "runs":
|
|
68
|
-
dispatchRuns(args.slice(1));
|
|
69
|
-
return;
|
|
70
|
-
case "chain":
|
|
71
|
-
dispatchChain(args.slice(1), selfCmd);
|
|
72
|
-
return;
|
|
73
|
-
case "config":
|
|
74
|
-
dispatchConfig(args.slice(1));
|
|
75
|
-
return;
|
|
76
|
-
case "guide":
|
|
77
|
-
dispatchGuide(args.slice(1));
|
|
78
|
-
return;
|
|
79
|
-
case "dashboard":
|
|
80
|
-
dispatchDashboard(args.slice(1), bundleRoot, selfCmd);
|
|
81
|
-
return;
|
|
82
|
-
default:
|
|
83
|
-
dispatchRun(args, argv, bundleRoot, selfCmd);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function resolveRuntimeProjectDir() {
|
|
87
|
-
return process.env.AUTOLOOP_PROJECT_DIR || ".";
|
|
88
|
-
}
|
|
89
|
-
function runtimeArgv(argv) {
|
|
90
|
-
// argv[0] is node, argv[1] is script, rest is user args
|
|
91
|
-
const userArgs = argv.slice(2);
|
|
92
|
-
if (userArgs.length === 0)
|
|
93
|
-
return [];
|
|
94
|
-
// If first arg is a CLI command, use as-is
|
|
95
|
-
if (isCliCommand(userArgs[0]))
|
|
96
|
-
return userArgs;
|
|
97
|
-
// For "autoloop run <project>" form, pass through
|
|
98
|
-
if (userArgs[0] === "run" && userArgs.length >= 2) {
|
|
99
|
-
return userArgs;
|
|
100
|
-
}
|
|
101
|
-
return userArgs;
|
|
102
|
-
}
|
|
103
|
-
function isCliCommand(value) {
|
|
104
|
-
return [
|
|
105
|
-
"run",
|
|
106
|
-
"emit",
|
|
107
|
-
"inspect",
|
|
108
|
-
"memory",
|
|
109
|
-
"task",
|
|
110
|
-
"list",
|
|
111
|
-
"loops",
|
|
112
|
-
"runs",
|
|
113
|
-
"chain",
|
|
114
|
-
"pi-adapter",
|
|
115
|
-
"branch-run",
|
|
116
|
-
"worktree",
|
|
117
|
-
"config",
|
|
118
|
-
"guide",
|
|
119
|
-
"dashboard",
|
|
120
|
-
"--help",
|
|
121
|
-
"-h",
|
|
122
|
-
].includes(value);
|
|
123
|
-
}
|
|
124
|
-
function selfCommand(argv) {
|
|
125
|
-
// Return a command that re-invokes this program
|
|
126
|
-
return `'${resolve(argv[1] ?? "autoloop")}'`;
|
|
127
|
-
}
|
|
128
|
-
function resolveBundleRoot(argv) {
|
|
129
|
-
const envRoot = process.env.AUTOLOOPS_BUNDLE_ROOT;
|
|
130
|
-
if (envRoot)
|
|
131
|
-
return envRoot;
|
|
132
|
-
// Resolve relative to this file — works for both source and npm-installed binary
|
|
133
|
-
const thisFile = fileURLToPath(import.meta.url);
|
|
134
|
-
const candidate = resolve(thisFile, "../..");
|
|
135
|
-
if (existsSync(join(candidate, "presets")))
|
|
136
|
-
return candidate;
|
|
137
|
-
// Fallback: try argv[1] heuristic (works when running from source via bin/)
|
|
138
|
-
const scriptPath = argv[1] ?? "";
|
|
139
|
-
if (scriptPath) {
|
|
140
|
-
const scriptDir = resolve(scriptPath, "..");
|
|
141
|
-
const argvCandidate = resolve(scriptDir, "..");
|
|
142
|
-
if (existsSync(join(argvCandidate, "presets")))
|
|
143
|
-
return argvCandidate;
|
|
144
|
-
}
|
|
145
|
-
return ".";
|
|
146
|
-
}
|
|
147
|
-
main();
|
|
148
|
-
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,uBA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Z,UAAU;QACV,QAAQ;QACR,OAAO;QACP,WAAW;QACX,QAAQ;QACR,IAAI;KACL,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACpB,CAAC;AAED,SAAS,WAAW,CAAC,IAAc;IACjC,gDAAgD;IAChD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,GAAG,CAAC;AAC/C,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAc;IACvC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC;IAClD,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC;IAC5B,iFAAiF;IACjF,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC7C,IAAI,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IAC7D,4EAA4E;IAC5E,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACjC,IAAI,UAAU,EAAE,CAAC;QACf,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAC5C,MAAM,aAAa,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC/C,IAAI,UAAU,CAAC,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;YAAE,OAAO,aAAa,CAAC;IACvE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,IAAI,EAAE,CAAC"}
|
package/dist/markdown.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare function bold(text: string): string;
|
|
2
|
-
export declare function italic(text: string): string;
|
|
3
|
-
export declare function code(text: string): string;
|
|
4
|
-
export declare function heading(level: number, text: string): string;
|
|
5
|
-
export declare function codeBlock(text: string, lang?: string): string;
|
|
6
|
-
export declare function blockquote(text: string): string;
|
|
7
|
-
export declare function section(title: string, body: string, level?: number): string;
|
|
8
|
-
export declare function bulletList(items: string[]): string;
|
|
9
|
-
export declare function numberedList(items: string[]): string;
|
|
10
|
-
export declare function table(headers: string[], rows: string[][]): string;
|
package/dist/markdown.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
export function bold(text) {
|
|
2
|
-
return `**${text}**`;
|
|
3
|
-
}
|
|
4
|
-
export function italic(text) {
|
|
5
|
-
return `_${text}_`;
|
|
6
|
-
}
|
|
7
|
-
export function code(text) {
|
|
8
|
-
return `\`${text}\``;
|
|
9
|
-
}
|
|
10
|
-
export function heading(level, text) {
|
|
11
|
-
const prefix = "#".repeat(Math.min(Math.max(level, 1), 5));
|
|
12
|
-
return `${prefix} ${text}`;
|
|
13
|
-
}
|
|
14
|
-
export function codeBlock(text, lang = "") {
|
|
15
|
-
return `\`\`\`${lang}\n${text}\n\`\`\``;
|
|
16
|
-
}
|
|
17
|
-
export function blockquote(text) {
|
|
18
|
-
return prefixLines(text, "> ");
|
|
19
|
-
}
|
|
20
|
-
export function section(title, body, level = 2) {
|
|
21
|
-
return `${heading(level, title)}\n\n${body}`;
|
|
22
|
-
}
|
|
23
|
-
export function bulletList(items) {
|
|
24
|
-
if (items.length === 0)
|
|
25
|
-
return "";
|
|
26
|
-
return items.map((item) => `- ${item}`).join("\n");
|
|
27
|
-
}
|
|
28
|
-
export function numberedList(items) {
|
|
29
|
-
if (items.length === 0)
|
|
30
|
-
return "";
|
|
31
|
-
return items.map((item, i) => `${i + 1}. ${item}`).join("\n");
|
|
32
|
-
}
|
|
33
|
-
export function table(headers, rows) {
|
|
34
|
-
const widths = columnWidths(headers, rows);
|
|
35
|
-
const headerRow = tableRow(headers, widths);
|
|
36
|
-
const separator = separatorRow(widths);
|
|
37
|
-
const body = rows.map((row) => tableRow(row, widths)).join("\n");
|
|
38
|
-
return `${headerRow}\n${separator}${rows.length > 0 ? `\n${body}` : ""}`;
|
|
39
|
-
}
|
|
40
|
-
function tableRow(cells, widths) {
|
|
41
|
-
const padded = cells.map((cell, i) => padCell(cell, widths[i] ?? cell.length));
|
|
42
|
-
return `| ${padded.join(" | ")} |`;
|
|
43
|
-
}
|
|
44
|
-
function padCell(cell, width) {
|
|
45
|
-
return cell.padEnd(width);
|
|
46
|
-
}
|
|
47
|
-
function separatorRow(widths) {
|
|
48
|
-
const dashes = widths.map((w) => "-".repeat(w));
|
|
49
|
-
return `| ${dashes.join(" | ")} |`;
|
|
50
|
-
}
|
|
51
|
-
function columnWidths(headers, rows) {
|
|
52
|
-
const widths = headers.map((h) => h.length);
|
|
53
|
-
for (const row of rows) {
|
|
54
|
-
for (let i = 0; i < row.length && i < widths.length; i++) {
|
|
55
|
-
widths[i] = Math.max(widths[i], row[i].length);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return widths;
|
|
59
|
-
}
|
|
60
|
-
function prefixLines(text, prefix) {
|
|
61
|
-
return text
|
|
62
|
-
.split("\n")
|
|
63
|
-
.map((line) => prefix + line)
|
|
64
|
-
.join("\n");
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=markdown.js.map
|
package/dist/markdown.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,IAAI,CAAC,IAAY;IAC/B,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,OAAO,IAAI,IAAI,GAAG,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,IAAY;IAC/B,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,KAAa,EAAE,IAAY;IACjD,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,C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E,CAAC;QACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACzD,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACjD,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,WAAW,CAAC,IAAY,EAAE,MAAc;IAC/C,OAAO,IAAI;SACR,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC;SAC5B,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
package/dist/memory-render.d.ts
DELETED
package/dist/memory-render.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { joinCsv, lineSep } from "./utils.js";
|
|
2
|
-
export function truncateText(text, budgetChars, memory) {
|
|
3
|
-
if (budgetChars <= 0)
|
|
4
|
-
return text;
|
|
5
|
-
if (text.length <= budgetChars)
|
|
6
|
-
return text;
|
|
7
|
-
return truncateOnLineBoundary(text, budgetChars, memory);
|
|
8
|
-
}
|
|
9
|
-
function truncateOnLineBoundary(text, budgetChars, memory) {
|
|
10
|
-
const lines = text.split(lineSep());
|
|
11
|
-
const kept = [];
|
|
12
|
-
let used = 0;
|
|
13
|
-
for (const line of lines) {
|
|
14
|
-
const lineLen = line.length + 1;
|
|
15
|
-
if (used + lineLen > budgetChars)
|
|
16
|
-
break;
|
|
17
|
-
kept.push(line);
|
|
18
|
-
used += lineLen;
|
|
19
|
-
}
|
|
20
|
-
const keptText = kept.join(lineSep());
|
|
21
|
-
const keptCount = countBulletEntries(kept);
|
|
22
|
-
const totalCount = countBulletEntries(lines);
|
|
23
|
-
const dropped = totalCount - keptCount;
|
|
24
|
-
const droppedDetail = truncationDroppedDetail(keptText, memory);
|
|
25
|
-
return (keptText +
|
|
26
|
-
"\n...\n" +
|
|
27
|
-
truncationFooter(dropped, droppedDetail, text.length, budgetChars));
|
|
28
|
-
}
|
|
29
|
-
function countBulletEntries(lines) {
|
|
30
|
-
return lines.filter((l) => l.startsWith("- ")).length;
|
|
31
|
-
}
|
|
32
|
-
function truncationDroppedDetail(keptText, memory) {
|
|
33
|
-
const totalPrefs = memory.preferences.length;
|
|
34
|
-
const totalLearnings = memory.learnings.length;
|
|
35
|
-
const totalMeta = memory.meta.length;
|
|
36
|
-
const keptPrefs = countCategoryInText(keptText, "Preferences:");
|
|
37
|
-
const keptLearnings = countCategoryInText(keptText, "Learnings:");
|
|
38
|
-
const keptMeta = countCategoryInText(keptText, "Meta:");
|
|
39
|
-
return formatDroppedCounts(totalPrefs - keptPrefs, totalLearnings - keptLearnings, totalMeta - keptMeta);
|
|
40
|
-
}
|
|
41
|
-
function countCategoryInText(text, header) {
|
|
42
|
-
if (!text.includes(header))
|
|
43
|
-
return 0;
|
|
44
|
-
const parts = text.split(header);
|
|
45
|
-
if (parts.length < 2)
|
|
46
|
-
return 0;
|
|
47
|
-
const afterHeader = parts[1];
|
|
48
|
-
const sectionLines = afterHeader.split(lineSep());
|
|
49
|
-
let count = 0;
|
|
50
|
-
for (const line of sectionLines) {
|
|
51
|
-
if (line.startsWith("- "))
|
|
52
|
-
count++;
|
|
53
|
-
else if (line.trim() !== "")
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
return count;
|
|
57
|
-
}
|
|
58
|
-
function formatDroppedCounts(prefs, learnings, meta) {
|
|
59
|
-
if (prefs === 0 && learnings === 0 && meta === 0)
|
|
60
|
-
return "";
|
|
61
|
-
const parts = [];
|
|
62
|
-
if (prefs > 0)
|
|
63
|
-
parts.push(`${prefs} preferences`);
|
|
64
|
-
if (learnings > 0)
|
|
65
|
-
parts.push(`${learnings} learnings`);
|
|
66
|
-
if (meta > 0)
|
|
67
|
-
parts.push(`${meta} meta`);
|
|
68
|
-
return ` (${joinCsv(parts)} truncated)`;
|
|
69
|
-
}
|
|
70
|
-
function truncationFooter(droppedEntries, droppedDetail, renderedChars, budgetChars) {
|
|
71
|
-
return ("(memory truncated: " +
|
|
72
|
-
droppedEntries +
|
|
73
|
-
" entries dropped" +
|
|
74
|
-
droppedDetail +
|
|
75
|
-
" — " +
|
|
76
|
-
renderedChars +
|
|
77
|
-
"/" +
|
|
78
|
-
budgetChars +
|
|
79
|
-
" chars)");
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=memory-render.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory-render.js","sourceRoot":"","sources":["../src/memory-render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAQ9C,MAAM,UAAU,YAAY,CAC1B,IAAY,EACZ,WAAmB,EACnB,MAA0B;IAE1B,IAAI,WAAW,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAClC,IAAI,IAAI,CAAC,MAAM,IAAI,WAAW;QAAE,OAAO,IAAI,CAAC;IAC5C,OAAO,sBAAsB,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;AAC3D,CAAC;AAED,SAAS,sBAAsB,CAC7B,IAAY,EACZ,WAAmB,EACnB,MAA0B;IAE1B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACpC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChC,IAAI,IAAI,GAAG,OAAO,GAAG,WAAW;YAAE,MAAM;QACxC,IAAI,CAAC,IAAI,CAAC,IAA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,aAAqB,EACrB,WAAmB;IAEnB,OAAO,CACL,qBAAqB;QACrB,cAAc;QACd,kBAAkB;QAClB,aAAa;QACb,KAAK;QACL,aAAa;QACb,GAAG;QACH,WAAW;QACX,SAAS,CACV,CAAC;AACJ,CAAC"}
|
package/dist/memory.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface MemoryStats {
|
|
2
|
-
preferences: number;
|
|
3
|
-
learnings: number;
|
|
4
|
-
meta: number;
|
|
5
|
-
totalEntries: number;
|
|
6
|
-
renderedChars: number;
|
|
7
|
-
budgetChars: number;
|
|
8
|
-
truncated: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare function resolveFile(projectDir: string): string;
|
|
11
|
-
export declare function renderProject(projectDir: string, budgetChars: number): string;
|
|
12
|
-
export declare function renderFile(path: string, budgetChars: number): string;
|
|
13
|
-
export declare function statsProject(projectDir: string, budgetChars: number): MemoryStats;
|
|
14
|
-
export declare function statsFile(path: string, budgetChars: number): MemoryStats;
|
|
15
|
-
export declare function listProject(projectDir: string): string;
|
|
16
|
-
export declare function rawProject(projectDir: string): string;
|
|
17
|
-
export declare function statusProject(projectDir: string): string;
|
|
18
|
-
export declare function findProject(projectDir: string, pattern: string): string;
|
|
19
|
-
export declare function addLearning(projectDir: string, text: string, source: string): void;
|
|
20
|
-
export declare function addPreference(projectDir: string, category: string, text: string): void;
|
|
21
|
-
export declare function addMeta(projectDir: string, key: string, value: string): void;
|
|
22
|
-
export declare function remove(projectDir: string, id: string, reason: string): void;
|
package/dist/memory.js
DELETED
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
import { appendFileSync, mkdirSync } from "node:fs";
|
|
2
|
-
import { dirname, join } from "node:path";
|
|
3
|
-
import * as config from "./config.js";
|
|
4
|
-
import { readIfExists, readLines } from "./harness/journal.js";
|
|
5
|
-
import { extractField, jsonField } from "./json.js";
|
|
6
|
-
import { bulletList } from "./markdown.js";
|
|
7
|
-
import { truncateText } from "./memory-render.js";
|
|
8
|
-
export function resolveFile(projectDir) {
|
|
9
|
-
const envPath = process.env.AUTOLOOP_MEMORY_FILE;
|
|
10
|
-
if (envPath)
|
|
11
|
-
return envPath;
|
|
12
|
-
const cfg = config.loadProject(projectDir);
|
|
13
|
-
return join(projectDir, config.get(cfg, "core.memory_file", ".autoloop/memory.jsonl"));
|
|
14
|
-
}
|
|
15
|
-
export function renderProject(projectDir, budgetChars) {
|
|
16
|
-
return renderFile(resolveFile(projectDir), budgetChars);
|
|
17
|
-
}
|
|
18
|
-
export function renderFile(path, budgetChars) {
|
|
19
|
-
const memory = materialize(readLines(path));
|
|
20
|
-
const text = renderMaterialized(memory);
|
|
21
|
-
return truncateText(text, budgetChars, memory);
|
|
22
|
-
}
|
|
23
|
-
export function statsProject(projectDir, budgetChars) {
|
|
24
|
-
return statsFile(resolveFile(projectDir), budgetChars);
|
|
25
|
-
}
|
|
26
|
-
export function statsFile(path, budgetChars) {
|
|
27
|
-
const memory = materialize(readLines(path));
|
|
28
|
-
return memoryStats(memory, budgetChars);
|
|
29
|
-
}
|
|
30
|
-
export function listProject(projectDir) {
|
|
31
|
-
return renderMaterialized(materialize(readLines(resolveFile(projectDir))));
|
|
32
|
-
}
|
|
33
|
-
export function rawProject(projectDir) {
|
|
34
|
-
return readIfExists(resolveFile(projectDir));
|
|
35
|
-
}
|
|
36
|
-
export function statusProject(projectDir) {
|
|
37
|
-
const stats = statsProject(projectDir, projectBudgetChars(projectDir));
|
|
38
|
-
return formatStatus(stats);
|
|
39
|
-
}
|
|
40
|
-
export function findProject(projectDir, pattern) {
|
|
41
|
-
const memory = materialize(readLines(resolveFile(projectDir)));
|
|
42
|
-
return renderMatches(findEntries(memory, pattern), pattern);
|
|
43
|
-
}
|
|
44
|
-
export function addLearning(projectDir, text, source) {
|
|
45
|
-
const path = resolveFile(projectDir);
|
|
46
|
-
appendMemoryEntry(path, memoryLine(nextId(path, "mem"), "learning", jsonField("text", text) +
|
|
47
|
-
", " +
|
|
48
|
-
jsonField("source", source) +
|
|
49
|
-
", " +
|
|
50
|
-
jsonField("created", currentTime())));
|
|
51
|
-
console.log("stored learning");
|
|
52
|
-
printBudgetWarning(projectDir);
|
|
53
|
-
}
|
|
54
|
-
export function addPreference(projectDir, category, text) {
|
|
55
|
-
const path = resolveFile(projectDir);
|
|
56
|
-
appendMemoryEntry(path, memoryLine(nextId(path, "mem"), "preference", jsonField("category", category) +
|
|
57
|
-
", " +
|
|
58
|
-
jsonField("text", text) +
|
|
59
|
-
", " +
|
|
60
|
-
jsonField("created", currentTime())));
|
|
61
|
-
console.log("stored preference");
|
|
62
|
-
printBudgetWarning(projectDir);
|
|
63
|
-
}
|
|
64
|
-
export function addMeta(projectDir, key, value) {
|
|
65
|
-
const path = resolveFile(projectDir);
|
|
66
|
-
appendMemoryEntry(path, memoryLine(nextId(path, "meta"), "meta", jsonField("key", key) +
|
|
67
|
-
", " +
|
|
68
|
-
jsonField("value", value) +
|
|
69
|
-
", " +
|
|
70
|
-
jsonField("created", currentTime())));
|
|
71
|
-
console.log("stored meta");
|
|
72
|
-
printBudgetWarning(projectDir);
|
|
73
|
-
}
|
|
74
|
-
export function remove(projectDir, id, reason) {
|
|
75
|
-
const path = resolveFile(projectDir);
|
|
76
|
-
const memory = materialize(readLines(path));
|
|
77
|
-
if (activeEntryExists(memory, id)) {
|
|
78
|
-
removeExistingEntry(path, id, reason);
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
console.log(`warning: no active entry with ID ${id} found`);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
function renderMaterialized(memory) {
|
|
85
|
-
if (memory.preferences.length === 0 &&
|
|
86
|
-
memory.learnings.length === 0 &&
|
|
87
|
-
memory.meta.length === 0) {
|
|
88
|
-
return "";
|
|
89
|
-
}
|
|
90
|
-
return ("Loop memory:\n" +
|
|
91
|
-
renderPreferences(memory.preferences) +
|
|
92
|
-
renderLearnings(memory.learnings) +
|
|
93
|
-
renderMeta(memory.meta));
|
|
94
|
-
}
|
|
95
|
-
function renderPreferences(entries) {
|
|
96
|
-
if (entries.length === 0)
|
|
97
|
-
return "";
|
|
98
|
-
const items = entries.map((e) => {
|
|
99
|
-
const created = extractField(e, "created");
|
|
100
|
-
return ("[" +
|
|
101
|
-
extractField(e, "id") +
|
|
102
|
-
"] [" +
|
|
103
|
-
extractField(e, "category") +
|
|
104
|
-
"] " +
|
|
105
|
-
extractField(e, "text") +
|
|
106
|
-
(created ? ` (created: ${created})` : ""));
|
|
107
|
-
});
|
|
108
|
-
return `Preferences:\n${bulletList(items)}\n`;
|
|
109
|
-
}
|
|
110
|
-
function renderLearnings(entries) {
|
|
111
|
-
if (entries.length === 0)
|
|
112
|
-
return "";
|
|
113
|
-
const items = entries.map((e) => {
|
|
114
|
-
const source = extractField(e, "source");
|
|
115
|
-
const prefix = source ? `(${source}) ` : "";
|
|
116
|
-
const created = extractField(e, "created");
|
|
117
|
-
return ("[" +
|
|
118
|
-
extractField(e, "id") +
|
|
119
|
-
"] " +
|
|
120
|
-
prefix +
|
|
121
|
-
extractField(e, "text") +
|
|
122
|
-
(created ? ` (created: ${created})` : ""));
|
|
123
|
-
});
|
|
124
|
-
return `Learnings:\n${bulletList(items)}\n`;
|
|
125
|
-
}
|
|
126
|
-
function renderMeta(entries) {
|
|
127
|
-
if (entries.length === 0)
|
|
128
|
-
return "";
|
|
129
|
-
const items = entries.map((e) => {
|
|
130
|
-
const created = extractField(e, "created");
|
|
131
|
-
return ("[" +
|
|
132
|
-
extractField(e, "id") +
|
|
133
|
-
"] " +
|
|
134
|
-
extractField(e, "key") +
|
|
135
|
-
": " +
|
|
136
|
-
extractField(e, "value") +
|
|
137
|
-
(created ? ` (created: ${created})` : ""));
|
|
138
|
-
});
|
|
139
|
-
return `Meta:\n${bulletList(items)}\n`;
|
|
140
|
-
}
|
|
141
|
-
function memoryStats(memory, budgetChars) {
|
|
142
|
-
const renderedChars = renderMaterialized(memory).length;
|
|
143
|
-
return {
|
|
144
|
-
preferences: memory.preferences.length,
|
|
145
|
-
learnings: memory.learnings.length,
|
|
146
|
-
meta: memory.meta.length,
|
|
147
|
-
totalEntries: memory.preferences.length + memory.learnings.length + memory.meta.length,
|
|
148
|
-
renderedChars,
|
|
149
|
-
budgetChars,
|
|
150
|
-
truncated: budgetChars > 0 && renderedChars > budgetChars,
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
function formatStatus(stats) {
|
|
154
|
-
const budgetStr = stats.budgetChars <= 0
|
|
155
|
-
? "budget disabled"
|
|
156
|
-
: stats.renderedChars > stats.budgetChars
|
|
157
|
-
? stats.budgetChars +
|
|
158
|
-
" char budget (" +
|
|
159
|
-
Math.floor(((stats.renderedChars - stats.budgetChars) * 100) /
|
|
160
|
-
stats.budgetChars) +
|
|
161
|
-
"% over)"
|
|
162
|
-
: stats.budgetChars +
|
|
163
|
-
" char budget (" +
|
|
164
|
-
Math.floor((stats.renderedChars * 100) / stats.budgetChars) +
|
|
165
|
-
"% used)";
|
|
166
|
-
return ("Memory: " +
|
|
167
|
-
stats.renderedChars +
|
|
168
|
-
" chars rendered, " +
|
|
169
|
-
budgetStr +
|
|
170
|
-
". " +
|
|
171
|
-
stats.learnings +
|
|
172
|
-
" learnings, " +
|
|
173
|
-
stats.preferences +
|
|
174
|
-
" preferences, " +
|
|
175
|
-
stats.meta +
|
|
176
|
-
" meta active.");
|
|
177
|
-
}
|
|
178
|
-
function printBudgetWarning(projectDir) {
|
|
179
|
-
const stats = statsProject(projectDir, projectBudgetChars(projectDir));
|
|
180
|
-
if (stats.truncated) {
|
|
181
|
-
console.log("warning: memory is " +
|
|
182
|
-
stats.renderedChars +
|
|
183
|
-
"/" +
|
|
184
|
-
stats.budgetChars +
|
|
185
|
-
" chars rendered. This entry will be truncated from the agent prompt.");
|
|
186
|
-
console.log("consider increasing memory.prompt_budget_chars or removing stale entries.");
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
function projectBudgetChars(projectDir) {
|
|
190
|
-
const cfg = config.loadProject(projectDir);
|
|
191
|
-
return config.getInt(cfg, "memory.prompt_budget_chars", 8000);
|
|
192
|
-
}
|
|
193
|
-
function findEntries(memory, pattern) {
|
|
194
|
-
const all = [...memory.preferences, ...memory.learnings, ...memory.meta];
|
|
195
|
-
return all.filter((entry) => entryMatches(entry, pattern));
|
|
196
|
-
}
|
|
197
|
-
function entryMatches(entry, pattern) {
|
|
198
|
-
const haystack = searchText(entry);
|
|
199
|
-
return haystack.includes(pattern);
|
|
200
|
-
}
|
|
201
|
-
function searchText(entry) {
|
|
202
|
-
return [
|
|
203
|
-
extractField(entry, "id"),
|
|
204
|
-
extractField(entry, "category"),
|
|
205
|
-
extractField(entry, "text"),
|
|
206
|
-
extractField(entry, "source"),
|
|
207
|
-
extractField(entry, "key"),
|
|
208
|
-
extractField(entry, "value"),
|
|
209
|
-
].join(" ");
|
|
210
|
-
}
|
|
211
|
-
function renderMatches(entries, pattern) {
|
|
212
|
-
if (entries.length === 0) {
|
|
213
|
-
return `No active memory entries matching \`${pattern}\`.`;
|
|
214
|
-
}
|
|
215
|
-
return entries.map(renderMatch).join("\n");
|
|
216
|
-
}
|
|
217
|
-
function renderMatch(entry) {
|
|
218
|
-
const id = extractField(entry, "id");
|
|
219
|
-
const type = extractField(entry, "type");
|
|
220
|
-
if (type === "preference") {
|
|
221
|
-
return (id +
|
|
222
|
-
": preference [" +
|
|
223
|
-
extractField(entry, "category") +
|
|
224
|
-
"] " +
|
|
225
|
-
extractField(entry, "text"));
|
|
226
|
-
}
|
|
227
|
-
if (type === "learning") {
|
|
228
|
-
const source = extractField(entry, "source");
|
|
229
|
-
const prefix = source ? `(${source}) ` : "";
|
|
230
|
-
return `${id}: learning ${prefix}${extractField(entry, "text")}`;
|
|
231
|
-
}
|
|
232
|
-
if (type === "meta") {
|
|
233
|
-
return (id +
|
|
234
|
-
": meta " +
|
|
235
|
-
extractField(entry, "key") +
|
|
236
|
-
": " +
|
|
237
|
-
extractField(entry, "value"));
|
|
238
|
-
}
|
|
239
|
-
return `${id}: ${extractField(entry, "text")}`;
|
|
240
|
-
}
|
|
241
|
-
function activeEntryExists(memory, id) {
|
|
242
|
-
const all = [...memory.preferences, ...memory.learnings, ...memory.meta];
|
|
243
|
-
return all.some((entry) => extractField(entry, "id") === id);
|
|
244
|
-
}
|
|
245
|
-
function materialize(lines) {
|
|
246
|
-
const reversed = [...lines].reverse();
|
|
247
|
-
const seen = [];
|
|
248
|
-
const tombstoned = [];
|
|
249
|
-
const preferences = [];
|
|
250
|
-
const learnings = [];
|
|
251
|
-
const meta = [];
|
|
252
|
-
const metaKeysSeen = [];
|
|
253
|
-
for (const line of reversed) {
|
|
254
|
-
const type = extractField(line, "type");
|
|
255
|
-
const id = extractField(line, "id");
|
|
256
|
-
if (type === "tombstone") {
|
|
257
|
-
const targetId = extractField(line, "target_id");
|
|
258
|
-
tombstoned.push(targetId);
|
|
259
|
-
continue;
|
|
260
|
-
}
|
|
261
|
-
if (!id)
|
|
262
|
-
continue;
|
|
263
|
-
if (tombstoned.includes(id) || seen.includes(id))
|
|
264
|
-
continue;
|
|
265
|
-
seen.push(id);
|
|
266
|
-
if (type === "preference") {
|
|
267
|
-
preferences.push(line);
|
|
268
|
-
}
|
|
269
|
-
else if (type === "learning") {
|
|
270
|
-
learnings.push(line);
|
|
271
|
-
}
|
|
272
|
-
else if (type === "meta") {
|
|
273
|
-
const key = extractField(line, "key");
|
|
274
|
-
if (!metaKeysSeen.includes(key)) {
|
|
275
|
-
metaKeysSeen.push(key);
|
|
276
|
-
meta.push(line);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
return {
|
|
281
|
-
preferences: preferences.reverse(),
|
|
282
|
-
learnings: learnings.reverse(),
|
|
283
|
-
meta: meta.reverse(),
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
function appendMemoryEntry(path, content) {
|
|
287
|
-
const dir = dirname(path);
|
|
288
|
-
mkdirSync(dir, { recursive: true });
|
|
289
|
-
appendFileSync(path, content, "utf-8");
|
|
290
|
-
}
|
|
291
|
-
function nextId(path, prefix) {
|
|
292
|
-
const count = readLines(path).length;
|
|
293
|
-
return `${prefix}-${count + 1}`;
|
|
294
|
-
}
|
|
295
|
-
function removeExistingEntry(path, id, reason) {
|
|
296
|
-
appendMemoryEntry(path, memoryLine(nextId(path, "ts"), "tombstone", tombstoneFields(id, reason)));
|
|
297
|
-
console.log(`removed ${id}`);
|
|
298
|
-
}
|
|
299
|
-
function currentTime() {
|
|
300
|
-
return new Date().toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
301
|
-
}
|
|
302
|
-
function memoryLine(id, type, fieldsJson) {
|
|
303
|
-
return ("{" +
|
|
304
|
-
jsonField("id", id) +
|
|
305
|
-
", " +
|
|
306
|
-
jsonField("type", type) +
|
|
307
|
-
", " +
|
|
308
|
-
fieldsJson +
|
|
309
|
-
"}\n");
|
|
310
|
-
}
|
|
311
|
-
function tombstoneFields(id, reason) {
|
|
312
|
-
return (jsonField("target_id", id) +
|
|
313
|
-
", " +
|
|
314
|
-
jsonField("reason", reason) +
|
|
315
|
-
", " +
|
|
316
|
-
jsonField("created", currentTime()));
|
|
317
|
-
}
|
|
318
|
-
//# sourceMappingURL=memory.js.map
|