cloving 0.3.20 → 1.0.1
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/{LICENSE.md → LICENSE} +1 -1
- package/README.md +475 -182
- package/dist/src/authority/budgets.d.ts +12 -0
- package/dist/src/authority/budgets.js +42 -0
- package/dist/src/authority/commands.d.ts +7 -0
- package/dist/src/authority/commands.js +263 -0
- package/dist/src/authority/details.d.ts +28 -0
- package/dist/src/authority/details.js +33 -0
- package/dist/src/authority/dispatch-decision.d.ts +40 -0
- package/dist/src/authority/dispatch-decision.js +47 -0
- package/dist/src/authority/effect-requests.d.ts +2 -0
- package/dist/src/authority/effect-requests.js +139 -0
- package/dist/src/authority/effect-results.d.ts +4 -0
- package/dist/src/authority/effect-results.js +236 -0
- package/dist/src/authority/events.d.ts +2 -0
- package/dist/src/authority/events.js +45 -0
- package/dist/src/authority/gate-reduction.d.ts +8 -0
- package/dist/src/authority/gate-reduction.js +109 -0
- package/dist/src/authority/gates.d.ts +48 -0
- package/dist/src/authority/gates.js +77 -0
- package/dist/src/authority/history-state.d.ts +15 -0
- package/dist/src/authority/history-state.js +61 -0
- package/dist/src/authority/history.d.ts +13 -0
- package/dist/src/authority/history.js +37 -0
- package/dist/src/authority/instants.d.ts +3 -0
- package/dist/src/authority/instants.js +38 -0
- package/dist/src/authority/leases.d.ts +15 -0
- package/dist/src/authority/leases.js +113 -0
- package/dist/src/authority/operations.d.ts +101 -0
- package/dist/src/authority/operations.js +75 -0
- package/dist/src/authority/reconciliation.d.ts +27 -0
- package/dist/src/authority/reconciliation.js +147 -0
- package/dist/src/authority/reducer.d.ts +41 -0
- package/dist/src/authority/reducer.js +139 -0
- package/dist/src/authority/reduction-state.d.ts +36 -0
- package/dist/src/authority/reduction-state.js +68 -0
- package/dist/src/authority/reduction.d.ts +6 -0
- package/dist/src/authority/reduction.js +160 -0
- package/dist/src/authority/status-closure.d.ts +4 -0
- package/dist/src/authority/status-closure.js +57 -0
- package/dist/src/authority/status-effects.d.ts +17 -0
- package/dist/src/authority/status-effects.js +43 -0
- package/dist/src/authority/status-input.d.ts +45 -0
- package/dist/src/authority/status-input.js +9 -0
- package/dist/src/authority/status.d.ts +32 -0
- package/dist/src/authority/status.js +256 -0
- package/dist/src/authority/stop-sequence.d.ts +37 -0
- package/dist/src/authority/stop-sequence.js +91 -0
- package/dist/src/authority/transitions.d.ts +63 -0
- package/dist/src/authority/transitions.js +122 -0
- package/dist/src/broker/actor/adapter-calls.d.ts +13 -0
- package/dist/src/broker/actor/adapter-calls.js +34 -0
- package/dist/src/broker/actor/adapter-outcomes.d.ts +28 -0
- package/dist/src/broker/actor/adapter-outcomes.js +80 -0
- package/dist/src/broker/actor/authority-actor.d.ts +25 -0
- package/dist/src/broker/actor/authority-actor.js +169 -0
- package/dist/src/broker/actor/authority-changes.d.ts +31 -0
- package/dist/src/broker/actor/authority-changes.js +46 -0
- package/dist/src/broker/actor/authority-connection.d.ts +15 -0
- package/dist/src/broker/actor/authority-connection.js +44 -0
- package/dist/src/broker/actor/authority-conversion.d.ts +10 -0
- package/dist/src/broker/actor/authority-conversion.js +72 -0
- package/dist/src/broker/actor/authority-delivery.d.ts +13 -0
- package/dist/src/broker/actor/authority-delivery.js +162 -0
- package/dist/src/broker/actor/authority-logger.d.ts +2 -0
- package/dist/src/broker/actor/authority-logger.js +19 -0
- package/dist/src/broker/actor/authority-policy.d.ts +9 -0
- package/dist/src/broker/actor/authority-policy.js +11 -0
- package/dist/src/broker/actor/authority-queries.d.ts +45 -0
- package/dist/src/broker/actor/authority-queries.js +85 -0
- package/dist/src/broker/actor/authority-receipts.d.ts +28 -0
- package/dist/src/broker/actor/authority-receipts.js +84 -0
- package/dist/src/broker/actor/authority-release.d.ts +13 -0
- package/dist/src/broker/actor/authority-release.js +69 -0
- package/dist/src/broker/actor/authority-runtime.d.ts +60 -0
- package/dist/src/broker/actor/authority-runtime.js +204 -0
- package/dist/src/broker/actor/authority-session.d.ts +65 -0
- package/dist/src/broker/actor/authority-session.js +252 -0
- package/dist/src/broker/actor/authority-settings.d.ts +33 -0
- package/dist/src/broker/actor/authority-settings.js +63 -0
- package/dist/src/broker/actor/authority-upgrades.d.ts +16 -0
- package/dist/src/broker/actor/authority-upgrades.js +12 -0
- package/dist/src/broker/actor/authority-watchdog.d.ts +14 -0
- package/dist/src/broker/actor/authority-watchdog.js +41 -0
- package/dist/src/broker/actor/authority.d.ts +14 -0
- package/dist/src/broker/actor/authority.js +115 -0
- package/dist/src/broker/actor/delivery-intents.d.ts +68 -0
- package/dist/src/broker/actor/delivery-intents.js +77 -0
- package/dist/src/broker/actor/delivery-plan.d.ts +2 -0
- package/dist/src/broker/actor/delivery-plan.js +109 -0
- package/dist/src/broker/actor/delivery-results.d.ts +11 -0
- package/dist/src/broker/actor/delivery-results.js +63 -0
- package/dist/src/broker/actor/effect-delivery.d.ts +19 -0
- package/dist/src/broker/actor/effect-delivery.js +118 -0
- package/dist/src/broker/actor/effect-plan.d.ts +41 -0
- package/dist/src/broker/actor/effect-plan.js +173 -0
- package/dist/src/broker/actor/effect-queries.d.ts +27 -0
- package/dist/src/broker/actor/effect-queries.js +80 -0
- package/dist/src/broker/actor/effect-turn.d.ts +25 -0
- package/dist/src/broker/actor/effect-turn.js +84 -0
- package/dist/src/broker/actor/pin-check.d.ts +6 -0
- package/dist/src/broker/actor/pin-check.js +12 -0
- package/dist/src/broker/actor/runtime-parts.d.ts +23 -0
- package/dist/src/broker/actor/runtime-parts.js +34 -0
- package/dist/src/broker/actor/stop-plan.d.ts +20 -0
- package/dist/src/broker/actor/stop-plan.js +46 -0
- package/dist/src/broker/actor/stop-turn.d.ts +17 -0
- package/dist/src/broker/actor/stop-turn.js +42 -0
- package/dist/src/broker/actor/turn-draft.d.ts +31 -0
- package/dist/src/broker/actor/turn-draft.js +138 -0
- package/dist/src/broker/actor/turn-plan.d.ts +17 -0
- package/dist/src/broker/actor/turn-plan.js +136 -0
- package/dist/src/broker/actor/turn-refusals.d.ts +8 -0
- package/dist/src/broker/actor/turn-refusals.js +35 -0
- package/dist/src/broker/actor/turn-staging.d.ts +78 -0
- package/dist/src/broker/actor/turn-staging.js +34 -0
- package/dist/src/broker/actor/turn-state.d.ts +34 -0
- package/dist/src/broker/actor/turn-state.js +208 -0
- package/dist/src/broker/authority-admission.d.ts +21 -0
- package/dist/src/broker/authority-admission.js +70 -0
- package/dist/src/broker/authority-restore.d.ts +30 -0
- package/dist/src/broker/authority-restore.js +165 -0
- package/dist/src/broker/decision-restore.d.ts +16 -0
- package/dist/src/broker/decision-restore.js +158 -0
- package/dist/src/broker/decision-upgrade.d.ts +3 -0
- package/dist/src/broker/decision-upgrade.js +12 -0
- package/dist/src/broker/effect-restore.d.ts +20 -0
- package/dist/src/broker/effect-restore.js +111 -0
- package/dist/src/broker/effect-upgrade.d.ts +3 -0
- package/dist/src/broker/effect-upgrade.js +9 -0
- package/dist/src/broker/operation-digest.d.ts +1 -0
- package/dist/src/broker/operation-digest.js +4 -0
- package/dist/src/broker/socket-address.d.ts +9 -0
- package/dist/src/broker/socket-address.js +14 -0
- package/dist/src/broker/workflow-pin.d.ts +2 -0
- package/dist/src/broker/workflow-pin.js +5 -0
- package/dist/src/chats/destination.d.ts +4 -0
- package/dist/src/chats/destination.js +94 -0
- package/dist/src/chats/import.d.ts +13 -0
- package/dist/src/chats/import.js +71 -0
- package/dist/src/chats/normalize.d.ts +20 -0
- package/dist/src/chats/normalize.js +139 -0
- package/dist/src/chats/reader.d.ts +15 -0
- package/dist/src/chats/reader.js +87 -0
- package/dist/src/cli/arguments.d.ts +23 -0
- package/dist/src/cli/arguments.js +154 -0
- package/dist/src/cli/client.d.ts +15 -0
- package/dist/src/cli/client.js +122 -0
- package/dist/src/cli/commands.d.ts +14 -0
- package/dist/src/cli/commands.js +253 -0
- package/dist/src/cli/main.d.ts +1 -0
- package/dist/src/cli/main.js +80 -0
- package/dist/src/cli/render.d.ts +8 -0
- package/dist/src/cli/render.js +186 -0
- package/dist/src/cli/runtime-arguments.d.ts +73 -0
- package/dist/src/cli/runtime-arguments.js +248 -0
- package/dist/src/cli/runtime-directory.d.ts +4 -0
- package/dist/src/cli/runtime-directory.js +25 -0
- package/dist/src/cli/toolchain.d.ts +3 -0
- package/dist/src/cli/toolchain.js +74 -0
- package/dist/src/cli/usage.d.ts +4 -0
- package/dist/src/cli/usage.js +124 -0
- package/dist/src/cli/validate.d.ts +38 -0
- package/dist/src/cli/validate.js +116 -0
- package/dist/src/cli/watch-board-view.d.ts +22 -0
- package/dist/src/cli/watch-board-view.js +128 -0
- package/dist/src/cli/watch-board.d.ts +15 -0
- package/dist/src/cli/watch-board.js +174 -0
- package/dist/src/cli/watch-element.d.ts +11 -0
- package/dist/src/cli/watch-element.js +6 -0
- package/dist/src/cli/watch-model.d.ts +29 -0
- package/dist/src/cli/watch-model.js +261 -0
- package/dist/src/cli/watch-navigation.d.ts +9 -0
- package/dist/src/cli/watch-navigation.js +40 -0
- package/dist/src/cli/watch-page.d.ts +1 -0
- package/dist/src/cli/watch-page.js +272 -0
- package/dist/src/cli/watch-paths.d.ts +2 -0
- package/dist/src/cli/watch-paths.js +52 -0
- package/dist/src/cli/watch-phases.d.ts +7 -0
- package/dist/src/cli/watch-phases.js +148 -0
- package/dist/src/cli/watch-reads.d.ts +28 -0
- package/dist/src/cli/watch-reads.js +244 -0
- package/dist/src/cli/watch-render.d.ts +139 -0
- package/dist/src/cli/watch-render.js +95 -0
- package/dist/src/cli/watch-server.d.ts +10 -0
- package/dist/src/cli/watch-server.js +176 -0
- package/dist/src/cli/watch-stream.d.ts +11 -0
- package/dist/src/cli/watch-stream.js +128 -0
- package/dist/src/cli/watch-turn.d.ts +29 -0
- package/dist/src/cli/watch-turn.js +130 -0
- package/dist/src/cli/watch-view.d.ts +39 -0
- package/dist/src/cli/watch-view.js +223 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +62 -0
- package/dist/src/daemon/claude-turn.d.ts +28 -0
- package/dist/src/daemon/claude-turn.js +135 -0
- package/dist/src/daemon/claude-worker.d.ts +26 -0
- package/dist/src/daemon/claude-worker.js +224 -0
- package/dist/src/daemon/codex-stream.d.ts +4 -0
- package/dist/src/daemon/codex-stream.js +113 -0
- package/dist/src/daemon/daemon.d.ts +46 -0
- package/dist/src/daemon/daemon.js +186 -0
- package/dist/src/daemon/delivery-router.d.ts +10 -0
- package/dist/src/daemon/delivery-router.js +34 -0
- package/dist/src/daemon/github-calls.d.ts +29 -0
- package/dist/src/daemon/github-calls.js +127 -0
- package/dist/src/daemon/github-issue-methods.d.ts +3 -0
- package/dist/src/daemon/github-issue-methods.js +99 -0
- package/dist/src/daemon/github-issue-privacy.d.ts +6 -0
- package/dist/src/daemon/github-issue-privacy.js +131 -0
- package/dist/src/daemon/github-merge.d.ts +18 -0
- package/dist/src/daemon/github-merge.js +259 -0
- package/dist/src/daemon/github-methods.d.ts +5 -0
- package/dist/src/daemon/github-methods.js +198 -0
- package/dist/src/daemon/github-operation.d.ts +38 -0
- package/dist/src/daemon/github-operation.js +57 -0
- package/dist/src/daemon/github-worker.d.ts +17 -0
- package/dist/src/daemon/github-worker.js +281 -0
- package/dist/src/daemon/host-environment.d.ts +8 -0
- package/dist/src/daemon/host-environment.js +14 -0
- package/dist/src/daemon/issue-queue.d.ts +9 -0
- package/dist/src/daemon/issue-queue.js +163 -0
- package/dist/src/daemon/notify-message.d.ts +14 -0
- package/dist/src/daemon/notify-message.js +48 -0
- package/dist/src/daemon/notify.d.ts +12 -0
- package/dist/src/daemon/notify.js +161 -0
- package/dist/src/daemon/operation-journal.d.ts +42 -0
- package/dist/src/daemon/operation-journal.js +53 -0
- package/dist/src/daemon/ticket-registration.d.ts +33 -0
- package/dist/src/daemon/ticket-registration.js +177 -0
- package/dist/src/daemon/ticket-source.d.ts +17 -0
- package/dist/src/daemon/ticket-source.js +36 -0
- package/dist/src/daemon/work-tree.d.ts +26 -0
- package/dist/src/daemon/work-tree.js +206 -0
- package/dist/src/effect-authorization.d.ts +21 -0
- package/dist/src/effect-authorization.js +14 -0
- package/dist/src/execution-pin.d.ts +4 -0
- package/dist/src/execution-pin.js +68 -0
- package/dist/src/host/start-delivery.d.ts +41 -0
- package/dist/src/host/start-delivery.js +68 -0
- package/dist/src/host/step-bridge-host.d.ts +79 -0
- package/dist/src/host/step-bridge-host.js +205 -0
- package/dist/src/host/step-claims.d.ts +31 -0
- package/dist/src/host/step-claims.js +85 -0
- package/dist/src/host/world-host.d.ts +21 -0
- package/dist/src/host/world-host.js +51 -0
- package/dist/src/host/world-reconciliation.d.ts +37 -0
- package/dist/src/host/world-reconciliation.js +75 -0
- package/dist/src/host/world-runs.d.ts +14 -0
- package/dist/src/host/world-runs.js +61 -0
- package/dist/src/operation-identity.d.ts +7 -0
- package/dist/src/operation-identity.js +59 -0
- package/dist/src/protocol.d.ts +35 -0
- package/dist/src/protocol.js +64 -0
- package/dist/src/resource-files.d.ts +1 -0
- package/dist/src/resource-files.js +29 -0
- package/dist/src/service/changes.d.ts +11 -0
- package/dist/src/service/changes.js +32 -0
- package/dist/src/service/decision-handler.d.ts +9 -0
- package/dist/src/service/decision-handler.js +233 -0
- package/dist/src/service/event-handler.d.ts +10 -0
- package/dist/src/service/event-handler.js +70 -0
- package/dist/src/service/expiry.d.ts +13 -0
- package/dist/src/service/expiry.js +53 -0
- package/dist/src/service/gateway.d.ts +21 -0
- package/dist/src/service/gateway.js +120 -0
- package/dist/src/service/registry.d.ts +40 -0
- package/dist/src/service/registry.js +13 -0
- package/dist/src/service/replies.d.ts +26 -0
- package/dist/src/service/replies.js +56 -0
- package/dist/src/service/run-handlers.d.ts +4 -0
- package/dist/src/service/run-handlers.js +271 -0
- package/dist/src/service/service.d.ts +58 -0
- package/dist/src/service/service.js +212 -0
- package/dist/src/service/submission-handler.d.ts +4 -0
- package/dist/src/service/submission-handler.js +206 -0
- package/dist/src/service/transport.d.ts +16 -0
- package/dist/src/service/transport.js +141 -0
- package/dist/src/service/worker-port.d.ts +85 -0
- package/dist/src/service/worker-port.js +126 -0
- package/dist/src/step-bridge.d.ts +57 -0
- package/dist/src/step-bridge.js +4 -0
- package/dist/src/steps/decision-gate.d.ts +2 -0
- package/dist/src/steps/decision-gate.js +8 -0
- package/dist/src/steps/load-cycle.d.ts +10 -0
- package/dist/src/steps/load-cycle.js +11 -0
- package/dist/src/steps/protected-effect.d.ts +2 -0
- package/dist/src/steps/protected-effect.js +8 -0
- package/dist/src/storage/decision-rows.d.ts +54 -0
- package/dist/src/storage/decision-rows.js +72 -0
- package/dist/src/storage/decision-snapshots.d.ts +17 -0
- package/dist/src/storage/decision-snapshots.js +25 -0
- package/dist/src/storage/domain-changes.d.ts +48 -0
- package/dist/src/storage/domain-changes.js +213 -0
- package/dist/src/storage/domain-rows.d.ts +85 -0
- package/dist/src/storage/domain-rows.js +129 -0
- package/dist/src/storage/domain-schema.d.ts +32 -0
- package/dist/src/storage/domain-schema.js +193 -0
- package/dist/src/storage/effect-changes.d.ts +5 -0
- package/dist/src/storage/effect-changes.js +105 -0
- package/dist/src/storage/effect-rows.d.ts +67 -0
- package/dist/src/storage/effect-rows.js +74 -0
- package/dist/src/storage/effect-schema.d.ts +1 -0
- package/dist/src/storage/effect-schema.js +59 -0
- package/dist/src/storage/statements.d.ts +9 -0
- package/dist/src/storage/statements.js +8 -0
- package/dist/src/submission.d.ts +42 -0
- package/dist/src/submission.js +71 -0
- package/dist/src/turn-profile.d.ts +13 -0
- package/dist/src/turn-profile.js +100 -0
- package/dist/src/workflow-admission.d.ts +45 -0
- package/dist/src/workflow-admission.js +151 -0
- package/dist/src/workflow-contracts.d.ts +27 -0
- package/dist/src/workflow-contracts.js +88 -0
- package/dist/src/workflow-declaration.d.ts +11 -0
- package/dist/src/workflow-declaration.js +57 -0
- package/dist/src/workflow-resources.d.ts +8 -0
- package/dist/src/workflow-resources.js +14 -0
- package/dist/src/workflows.d.ts +5 -0
- package/dist/src/workflows.js +3 -0
- package/dist/tools/compile-workflows.d.ts +1 -0
- package/dist/tools/compile-workflows.js +33 -0
- package/dist/tools/self-host-processes.d.ts +10 -0
- package/dist/tools/self-host-processes.js +151 -0
- package/dist/tools/self-host-workflows.d.ts +15 -0
- package/dist/tools/self-host-workflows.js +78 -0
- package/dist/tools/self-host.d.ts +1 -0
- package/dist/tools/self-host.js +261 -0
- package/dist/tools/self-update-host.d.ts +6 -0
- package/dist/tools/self-update-host.js +41 -0
- package/dist/tools/self-update.d.ts +10 -0
- package/dist/tools/self-update.js +105 -0
- package/dist/tools/workflow-manifest.d.ts +3 -0
- package/dist/tools/workflow-manifest.js +34 -0
- package/dist/workflows/develop-prd.d.ts +7 -0
- package/dist/workflows/develop-prd.js +97 -0
- package/dist/workflows/develop-ticket.d.ts +15 -0
- package/dist/workflows/develop-ticket.js +301 -0
- package/dist/workflows/issue-labels.d.ts +14 -0
- package/dist/workflows/issue-labels.js +36 -0
- package/package.json +82 -75
- package/dist/abstract_gpt/index.js +0 -55
- package/dist/cloving_gpt/adapters/Adapter.js +0 -2
- package/dist/cloving_gpt/adapters/azureopenai.js +0 -69
- package/dist/cloving_gpt/adapters/claude.js +0 -128
- package/dist/cloving_gpt/adapters/gemini.js +0 -135
- package/dist/cloving_gpt/adapters/gpt4all.js +0 -29
- package/dist/cloving_gpt/adapters/index.js +0 -2
- package/dist/cloving_gpt/adapters/mistral.js +0 -128
- package/dist/cloving_gpt/adapters/ollama.js +0 -128
- package/dist/cloving_gpt/adapters/openai.js +0 -100
- package/dist/cloving_gpt/index.js +0 -192
- package/dist/commands/analyze.js +0 -47
- package/dist/commands/chat.js +0 -14
- package/dist/commands/check.js +0 -7
- package/dist/commands/commit.js +0 -44
- package/dist/commands/config.js +0 -167
- package/dist/commands/describe.js +0 -235
- package/dist/commands/generate/code.js +0 -21
- package/dist/commands/generate/commit.js +0 -11
- package/dist/commands/generate/context.js +0 -82
- package/dist/commands/generate/docs.js +0 -11
- package/dist/commands/generate/documentation.js +0 -11
- package/dist/commands/generate/fizzbuzz.js +0 -35
- package/dist/commands/generate/init.js +0 -15
- package/dist/commands/generate/review.js +0 -11
- package/dist/commands/generate/sh.js +0 -95
- package/dist/commands/generate/shell.js +0 -11
- package/dist/commands/generate/unit_tests.js +0 -11
- package/dist/commands/init.js +0 -13
- package/dist/commands/models.js +0 -22
- package/dist/commands/project/build.js +0 -88
- package/dist/commands/project/complete.js +0 -12
- package/dist/commands/project/init.js +0 -82
- package/dist/commands/project/plan.js +0 -108
- package/dist/commands/proxy.js +0 -11
- package/dist/commands/review.js +0 -50
- package/dist/commands/tokens.js +0 -75
- package/dist/commands/unit_tests.js +0 -150
- package/dist/commands/update.js +0 -7
- package/dist/file2.js +0 -4
- package/dist/index.js +0 -136
- package/dist/managers/BlockManager.js +0 -120
- package/dist/managers/ChatManager.js +0 -653
- package/dist/managers/ChunkManager.js +0 -32
- package/dist/managers/CodeManager.js +0 -185
- package/dist/managers/CommitManager.js +0 -78
- package/dist/managers/DocsManager.js +0 -88
- package/dist/managers/DocumentationManager.js +0 -114
- package/dist/managers/InitManager.js +0 -230
- package/dist/managers/ProxyManager.js +0 -210
- package/dist/managers/ReviewManager.js +0 -131
- package/dist/managers/ShellManager.js +0 -163
- package/dist/managers/StreamManager.js +0 -308
- package/dist/managers/UnitTestManager.js +0 -243
- package/dist/managers/src/managers/ProxyManager.js +0 -1
- package/dist/newfile.js +0 -2
- package/dist/package.json +0 -86
- package/dist/utils/command_utils.js +0 -384
- package/dist/utils/config_utils.js +0 -249
- package/dist/utils/gitUtils.js +0 -42
- package/dist/utils/git_utils.js +0 -217
- package/dist/utils/modelUtils.js +0 -7
- package/dist/utils/model_utils.js +0 -7
- package/dist/utils/prompt_utils.js +0 -333
- package/dist/utils/prompts/CODEGEN_COULDNT_APPLY.md +0 -5
- package/dist/utils/prompts/CODEGEN_EXAMPLES.md +0 -82
- package/dist/utils/prompts/CODEGEN_INSTRUCTIONS.md +0 -43
- package/dist/utils/prompts/DOCS_INSTRUCTIONS.md +0 -9
- package/dist/utils/prompts/INIT_INSTRUCTIONS.md +0 -132
- package/dist/utils/prompts/REVIEW_INSTRUCTIONS.md +0 -49
- package/dist/utils/prompts/SHELL_INSTRUCTIONS.md +0 -15
- package/dist/utils/prompts/SPECIAL_FILES.md +0 -66
- package/dist/utils/prompts/index.js +0 -27
- package/dist/utils/string_utils.js +0 -505
- package/dist/utils/types.js +0 -2
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { profileCommand, } from "../turn-profile.js";
|
|
3
|
+
import { startTurn, } from "./claude-turn.js";
|
|
4
|
+
import { interrupted, located as locatedIn, operationKey, readRecord as read, replied as repliedWith, reportOf, writeRecord as written, } from "./operation-journal.js";
|
|
5
|
+
import { changes, treeFailure, workTree } from "./work-tree.js";
|
|
6
|
+
export const claudeLimits = {
|
|
7
|
+
summaryCharacters: 16_000,
|
|
8
|
+
resultBytes: 48_000,
|
|
9
|
+
stopMilliseconds: 2_000,
|
|
10
|
+
};
|
|
11
|
+
const worker = "claude";
|
|
12
|
+
function located(settings, operationId) {
|
|
13
|
+
return locatedIn(settings.journal, operationId);
|
|
14
|
+
}
|
|
15
|
+
function alive(processId) {
|
|
16
|
+
if (typeof processId !== "number")
|
|
17
|
+
return false;
|
|
18
|
+
try {
|
|
19
|
+
process.kill(processId, 0);
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
return Reflect.get(Object(error), "code") === "EPERM";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function replied(key, recorded) {
|
|
27
|
+
return repliedWith({ receipt: key, worker }, recorded);
|
|
28
|
+
}
|
|
29
|
+
async function reconciled(parts, intent) {
|
|
30
|
+
const { key, folder } = located(parts.settings, intent.operationId);
|
|
31
|
+
const result = await read(folder, "result.json");
|
|
32
|
+
if (result !== undefined)
|
|
33
|
+
return replied(key, result);
|
|
34
|
+
if (parts.active.has(key))
|
|
35
|
+
return { kind: "accepted", receipt: key, worker };
|
|
36
|
+
const started = await read(folder, "started.json");
|
|
37
|
+
if (started === undefined)
|
|
38
|
+
return { kind: "absent" };
|
|
39
|
+
if (alive(Reflect.get(Object(started), "processId")))
|
|
40
|
+
return { kind: "unknown", evidence: `claude-turn:${key}` };
|
|
41
|
+
const ending = interrupted("claude-turn-interrupted");
|
|
42
|
+
await written(folder, { name: "result.json", value: ending });
|
|
43
|
+
return replied(key, ending);
|
|
44
|
+
}
|
|
45
|
+
async function resultText(tree, result) {
|
|
46
|
+
const fields = {
|
|
47
|
+
summary: result.text.slice(0, claudeLimits.summaryCharacters),
|
|
48
|
+
...(await changes(tree)),
|
|
49
|
+
worktree: tree.path,
|
|
50
|
+
costUsd: result.costUsd,
|
|
51
|
+
sessionId: result.sessionId,
|
|
52
|
+
turns: result.turns,
|
|
53
|
+
};
|
|
54
|
+
const text = JSON.stringify(fields);
|
|
55
|
+
const excess = Buffer.byteLength(text) - claudeLimits.resultBytes;
|
|
56
|
+
if (excess <= 0)
|
|
57
|
+
return text;
|
|
58
|
+
const kept = Math.max(0, fields.summary.length - excess);
|
|
59
|
+
return JSON.stringify({ ...fields, summary: fields.summary.slice(0, kept) });
|
|
60
|
+
}
|
|
61
|
+
async function outcome(running, end) {
|
|
62
|
+
const endedAt = new Date().toISOString();
|
|
63
|
+
const { result } = end;
|
|
64
|
+
const text = result === undefined ? undefined : await resultText(running.tree, result);
|
|
65
|
+
if (text !== undefined && end.exitCode === 0 && result?.failed === false)
|
|
66
|
+
return { outcome: "completed", result: text, endedAt };
|
|
67
|
+
if (running.stopping.requested)
|
|
68
|
+
return { outcome: "stopped", endedAt };
|
|
69
|
+
return {
|
|
70
|
+
outcome: "failed",
|
|
71
|
+
reason: "claude-turn-failed",
|
|
72
|
+
...(text === undefined ? {} : { result: text }),
|
|
73
|
+
endedAt,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function reported(started, recorded) {
|
|
77
|
+
const { intent, key } = started;
|
|
78
|
+
return reportOf({ intent, commandId: `claude-turn:${key}`, worker }, recorded);
|
|
79
|
+
}
|
|
80
|
+
async function concluded(parts, running) {
|
|
81
|
+
const recorded = await outcome(running, await running.turn.ended);
|
|
82
|
+
await written(running.folder, { name: "result.json", value: recorded });
|
|
83
|
+
await parts.settings.report(reported(running, recorded));
|
|
84
|
+
}
|
|
85
|
+
async function begun(parts, start) {
|
|
86
|
+
const { intent, key, folder, tree, prompt } = start;
|
|
87
|
+
const record = (processId) => written(folder, {
|
|
88
|
+
name: "started.json",
|
|
89
|
+
value: {
|
|
90
|
+
operationId: intent.operationId,
|
|
91
|
+
target: intent.target,
|
|
92
|
+
branch: tree.branch,
|
|
93
|
+
worktree: tree.path,
|
|
94
|
+
startCommit: tree.startCommit,
|
|
95
|
+
processId,
|
|
96
|
+
startedAt: new Date().toISOString(),
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
await record(null);
|
|
100
|
+
const turn = startTurn({
|
|
101
|
+
worker: parts.settings.worker ?? "claude",
|
|
102
|
+
command: profileCommand(parts.settings.command, start.profile),
|
|
103
|
+
environment: start.profile.env ?? {},
|
|
104
|
+
turnId: `${intent.runId}-${key}`,
|
|
105
|
+
directory: tree.path,
|
|
106
|
+
folder,
|
|
107
|
+
prompt,
|
|
108
|
+
});
|
|
109
|
+
const stopping = { requested: false };
|
|
110
|
+
parts.active.set(key, {
|
|
111
|
+
turn,
|
|
112
|
+
stopping,
|
|
113
|
+
concluded: concluded(parts, { ...start, turn, stopping })
|
|
114
|
+
.catch(() => undefined)
|
|
115
|
+
.finally(() => parts.active.delete(key)),
|
|
116
|
+
});
|
|
117
|
+
await record(turn.processId);
|
|
118
|
+
}
|
|
119
|
+
async function firstTurn(settings, opening) {
|
|
120
|
+
const { tree, intent } = opening;
|
|
121
|
+
const { target, runId } = intent;
|
|
122
|
+
const folder = target.startsWith("branch:")
|
|
123
|
+
? join(settings.journal, "runs", operationKey(runId), "targets")
|
|
124
|
+
: join(settings.journal, "targets");
|
|
125
|
+
const name = `${operationKey(target)}.json`;
|
|
126
|
+
const startCommit = Reflect.get(Object(await read(folder, name)), "startCommit");
|
|
127
|
+
if (typeof startCommit === "string")
|
|
128
|
+
return { ...tree, startCommit };
|
|
129
|
+
await written(folder, {
|
|
130
|
+
name,
|
|
131
|
+
value: { target, startCommit: tree.startCommit },
|
|
132
|
+
});
|
|
133
|
+
return tree;
|
|
134
|
+
}
|
|
135
|
+
function turnIntent(intent) {
|
|
136
|
+
return (intent.capability === worker &&
|
|
137
|
+
(intent.method === "run-turn" ||
|
|
138
|
+
/^run-turn:[A-Za-z0-9_-]{1,119}$/.test(intent.method ?? "")) &&
|
|
139
|
+
intent.target !== undefined &&
|
|
140
|
+
intent.payload !== undefined &&
|
|
141
|
+
intent.leaseGeneration !== undefined);
|
|
142
|
+
}
|
|
143
|
+
function failure(reason) {
|
|
144
|
+
return { kind: "failed", reason };
|
|
145
|
+
}
|
|
146
|
+
async function runWorkflow(settings, runId) {
|
|
147
|
+
try {
|
|
148
|
+
return await settings.workflowId?.(runId);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async function selectedProfile(settings, intent) {
|
|
155
|
+
if (intent.method === "run-turn")
|
|
156
|
+
return {};
|
|
157
|
+
if (settings.worker === "codex")
|
|
158
|
+
return "profile-needs-claude";
|
|
159
|
+
const name = intent.method.slice("run-turn:".length);
|
|
160
|
+
const profiles = settings.profiles ?? {};
|
|
161
|
+
const profile = Object.hasOwn(profiles, name) ? profiles[name] : undefined;
|
|
162
|
+
if (profile === undefined)
|
|
163
|
+
return "unknown-profile";
|
|
164
|
+
if (profile.workflows === undefined)
|
|
165
|
+
return profile;
|
|
166
|
+
const workflowId = await runWorkflow(settings, intent.runId);
|
|
167
|
+
if (workflowId === undefined || !profile.workflows.includes(workflowId))
|
|
168
|
+
return "profile-not-allowed";
|
|
169
|
+
return profile;
|
|
170
|
+
}
|
|
171
|
+
async function delivered(parts, call) {
|
|
172
|
+
const { intent, signal } = call;
|
|
173
|
+
const { settings } = parts;
|
|
174
|
+
if (!turnIntent(intent))
|
|
175
|
+
return failure("unsupported-effect");
|
|
176
|
+
const known = await reconciled(parts, intent);
|
|
177
|
+
if (known.kind !== "absent")
|
|
178
|
+
return known;
|
|
179
|
+
const profile = await selectedProfile(settings, intent);
|
|
180
|
+
if (typeof profile === "string")
|
|
181
|
+
return failure(profile);
|
|
182
|
+
const prompt = await settings.document(intent.payload);
|
|
183
|
+
if (prompt === undefined)
|
|
184
|
+
return failure("payload-not-available");
|
|
185
|
+
const tree = await workTree({
|
|
186
|
+
repository: settings.repository,
|
|
187
|
+
worktrees: settings.worktrees,
|
|
188
|
+
target: intent.target,
|
|
189
|
+
signal,
|
|
190
|
+
}).catch(treeFailure);
|
|
191
|
+
if (signal.aborted)
|
|
192
|
+
return failure("claude-start-aborted");
|
|
193
|
+
if (typeof tree === "string")
|
|
194
|
+
return failure(tree);
|
|
195
|
+
const place = located(settings, intent.operationId);
|
|
196
|
+
const first = await firstTurn(settings, { tree, intent });
|
|
197
|
+
await begun(parts, { ...place, intent, tree: first, prompt, profile });
|
|
198
|
+
return { receipt: place.key, worker };
|
|
199
|
+
}
|
|
200
|
+
async function halted(parts, active) {
|
|
201
|
+
active.stopping.requested = true;
|
|
202
|
+
active.turn.stop(parts.settings.stopMilliseconds ?? claudeLimits.stopMilliseconds);
|
|
203
|
+
await active.concluded;
|
|
204
|
+
}
|
|
205
|
+
async function stopped(parts, intent) {
|
|
206
|
+
const { key } = located(parts.settings, intent.operationId);
|
|
207
|
+
const active = parts.active.get(key);
|
|
208
|
+
if (active !== undefined)
|
|
209
|
+
await halted(parts, active);
|
|
210
|
+
return reconciled(parts, intent);
|
|
211
|
+
}
|
|
212
|
+
export function claudeWorker(settings) {
|
|
213
|
+
if (settings.command.length === 0)
|
|
214
|
+
throw new Error("invalid-claude-command");
|
|
215
|
+
const parts = { settings, active: new Map() };
|
|
216
|
+
return {
|
|
217
|
+
deliver: (intent, signal) => delivered(parts, { intent, signal }),
|
|
218
|
+
reconcile: (intent) => reconciled(parts, intent),
|
|
219
|
+
stop: (intent) => stopped(parts, intent),
|
|
220
|
+
close: async () => {
|
|
221
|
+
await Promise.all([...parts.active.values()].map((active) => halted(parts, active)));
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
function record(value) {
|
|
2
|
+
return typeof value === "object" && value !== null ? { ...value } : {};
|
|
3
|
+
}
|
|
4
|
+
function parsed(line) {
|
|
5
|
+
try {
|
|
6
|
+
return record(JSON.parse(line));
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return {};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function text(value) {
|
|
13
|
+
return typeof value === "string" ? value : "";
|
|
14
|
+
}
|
|
15
|
+
function message(content) {
|
|
16
|
+
return JSON.stringify({ type: "assistant", message: { content: [content] } });
|
|
17
|
+
}
|
|
18
|
+
function commandError(item) {
|
|
19
|
+
const code = item["exit_code"];
|
|
20
|
+
if (item["status"] !== "failed" && !(typeof code === "number" && code !== 0))
|
|
21
|
+
return [];
|
|
22
|
+
const fallback = typeof code === "number" ? `exit code ${String(code)}` : "command failed";
|
|
23
|
+
const content = text(item["aggregated_output"]).slice(-2000) || fallback;
|
|
24
|
+
return [
|
|
25
|
+
JSON.stringify({
|
|
26
|
+
type: "user",
|
|
27
|
+
message: { content: [{ type: "tool_result", is_error: true, content }] },
|
|
28
|
+
}),
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
function completed(item) {
|
|
32
|
+
if (item["type"] === "agent_message")
|
|
33
|
+
return [message({ type: "text", text: text(item["text"]) })];
|
|
34
|
+
if (item["type"] === "command_execution")
|
|
35
|
+
return commandError(item);
|
|
36
|
+
if (item["type"] !== "file_change" || !Array.isArray(item["changes"]))
|
|
37
|
+
return [];
|
|
38
|
+
return item["changes"].map((change) => message({
|
|
39
|
+
type: "tool_use",
|
|
40
|
+
name: "Edit",
|
|
41
|
+
input: { file_path: text(record(change)["path"]) },
|
|
42
|
+
}));
|
|
43
|
+
}
|
|
44
|
+
function updated(event, state) {
|
|
45
|
+
const type = event["type"];
|
|
46
|
+
if (type === "thread.started")
|
|
47
|
+
state.sessionId = text(event["thread_id"]) || null;
|
|
48
|
+
if (type === "turn.completed") {
|
|
49
|
+
state.turns += 1;
|
|
50
|
+
state.error = null;
|
|
51
|
+
}
|
|
52
|
+
if (type === "turn.failed")
|
|
53
|
+
state.failure = text(record(event["error"])["message"]);
|
|
54
|
+
if (type === "error")
|
|
55
|
+
state.error = text(event["message"]);
|
|
56
|
+
}
|
|
57
|
+
function translated(event, state) {
|
|
58
|
+
updated(event, state);
|
|
59
|
+
const type = event["type"];
|
|
60
|
+
if (type === "thread.started")
|
|
61
|
+
return [
|
|
62
|
+
JSON.stringify({
|
|
63
|
+
type: "system",
|
|
64
|
+
subtype: "init",
|
|
65
|
+
session_id: state.sessionId,
|
|
66
|
+
}),
|
|
67
|
+
];
|
|
68
|
+
const item = record(event["item"]);
|
|
69
|
+
if (type === "item.started" && item["type"] === "command_execution")
|
|
70
|
+
return [
|
|
71
|
+
message({
|
|
72
|
+
type: "tool_use",
|
|
73
|
+
name: "Bash",
|
|
74
|
+
input: { command: text(item["command"]) },
|
|
75
|
+
}),
|
|
76
|
+
];
|
|
77
|
+
if (type !== "item.completed")
|
|
78
|
+
return [];
|
|
79
|
+
if (item["type"] === "agent_message")
|
|
80
|
+
state.message = text(item["text"]);
|
|
81
|
+
return completed(item);
|
|
82
|
+
}
|
|
83
|
+
export function codexStream() {
|
|
84
|
+
const state = {
|
|
85
|
+
sessionId: null,
|
|
86
|
+
turns: 0,
|
|
87
|
+
failure: null,
|
|
88
|
+
error: null,
|
|
89
|
+
message: "",
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
line: (line) => translated(parsed(line), state),
|
|
93
|
+
result: (exitCode) => {
|
|
94
|
+
const success = exitCode === 0 &&
|
|
95
|
+
state.turns > 0 &&
|
|
96
|
+
state.failure === null &&
|
|
97
|
+
state.error === null;
|
|
98
|
+
return JSON.stringify({
|
|
99
|
+
type: "result",
|
|
100
|
+
subtype: success ? "success" : "error_during_execution",
|
|
101
|
+
is_error: !success,
|
|
102
|
+
result: success
|
|
103
|
+
? state.message
|
|
104
|
+
: state.failure ||
|
|
105
|
+
state.error ||
|
|
106
|
+
`codex ended with the code ${String(exitCode)}`,
|
|
107
|
+
total_cost_usd: null,
|
|
108
|
+
session_id: state.sessionId,
|
|
109
|
+
num_turns: state.turns,
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type WorkflowFunction } from "../host/start-delivery.ts";
|
|
2
|
+
import { type WorkflowHandler } from "../host/world-host.ts";
|
|
3
|
+
import type { TurnProfiles } from "../turn-profile.ts";
|
|
4
|
+
import type { DeclaredWorkflow } from "../workflow-declaration.ts";
|
|
5
|
+
import type { Worker } from "./claude-turn.ts";
|
|
6
|
+
export interface DaemonSettings {
|
|
7
|
+
readonly worker?: Worker;
|
|
8
|
+
readonly profiles?: TurnProfiles;
|
|
9
|
+
readonly directory: string;
|
|
10
|
+
readonly runtimeDirectory: string;
|
|
11
|
+
readonly repository: string;
|
|
12
|
+
readonly manifests: Readonly<Record<string, string | undefined>>;
|
|
13
|
+
readonly declarations?: readonly DeclaredWorkflow[];
|
|
14
|
+
readonly workflows: Readonly<Record<string, WorkflowFunction | undefined>>;
|
|
15
|
+
readonly handler: WorkflowHandler;
|
|
16
|
+
readonly command: readonly string[];
|
|
17
|
+
readonly ticketCommand?: readonly string[];
|
|
18
|
+
readonly nextCommand?: readonly string[];
|
|
19
|
+
readonly notifyCommand?: readonly string[];
|
|
20
|
+
readonly notifyMilliseconds?: number;
|
|
21
|
+
readonly queueMilliseconds?: number;
|
|
22
|
+
readonly githubCommand?: readonly string[];
|
|
23
|
+
readonly checkCommand?: readonly string[];
|
|
24
|
+
readonly privateTexts?: readonly string[];
|
|
25
|
+
readonly concurrency: number;
|
|
26
|
+
}
|
|
27
|
+
export interface Daemon {
|
|
28
|
+
readonly socket: string;
|
|
29
|
+
readonly close: () => Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export type DaemonOpening = {
|
|
32
|
+
readonly kind: "started";
|
|
33
|
+
readonly daemon: Daemon;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: "refused";
|
|
36
|
+
readonly reason: string;
|
|
37
|
+
readonly detail: string;
|
|
38
|
+
};
|
|
39
|
+
export declare const turnLeaseMilliseconds: number;
|
|
40
|
+
export declare const loopMilliseconds = 250;
|
|
41
|
+
export declare const bridgeTiming: {
|
|
42
|
+
lookupTries: number;
|
|
43
|
+
pollMilliseconds: number;
|
|
44
|
+
retryMilliseconds: number;
|
|
45
|
+
};
|
|
46
|
+
export declare function startDaemon(settings: DaemonSettings): Promise<DaemonOpening>;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { mkdir } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { startDelivery, } from "../host/start-delivery.js";
|
|
4
|
+
import { registerStepBridge, sdkStepCall, stepBridge, } from "../host/step-bridge-host.js";
|
|
5
|
+
import { startHost } from "../host/world-host.js";
|
|
6
|
+
import { worldLoop } from "../host/world-reconciliation.js";
|
|
7
|
+
import { cancelled, workflowOutcome, taggedRun, taggedRuns, } from "../host/world-runs.js";
|
|
8
|
+
import { startService, } from "../service/service.js";
|
|
9
|
+
import { claudeWorker } from "./claude-worker.js";
|
|
10
|
+
import { deliveryRouter } from "./delivery-router.js";
|
|
11
|
+
import { githubWorker } from "./github-worker.js";
|
|
12
|
+
import { worldDirectory } from "./host-environment.js";
|
|
13
|
+
import { issueQueue } from "./issue-queue.js";
|
|
14
|
+
import { notifyRuns } from "./notify.js";
|
|
15
|
+
import { ticketRegistrations, ticketRegistrationTable, } from "./ticket-registration.js";
|
|
16
|
+
export const turnLeaseMilliseconds = 4 * 3_600_000;
|
|
17
|
+
export const loopMilliseconds = 250;
|
|
18
|
+
export const bridgeTiming = {
|
|
19
|
+
lookupTries: 250,
|
|
20
|
+
pollMilliseconds: 250,
|
|
21
|
+
retryMilliseconds: 1_000,
|
|
22
|
+
};
|
|
23
|
+
async function hosted(settings, ports) {
|
|
24
|
+
const opening = await startHost({
|
|
25
|
+
dataDirectory: worldDirectory(settings.directory),
|
|
26
|
+
concurrency: settings.concurrency,
|
|
27
|
+
handler: settings.handler,
|
|
28
|
+
});
|
|
29
|
+
if (opening.kind === "refused")
|
|
30
|
+
throw new Error(`${opening.reason}: ${opening.detail}`);
|
|
31
|
+
const loop = worldLoop({
|
|
32
|
+
...ports,
|
|
33
|
+
runs: taggedRuns,
|
|
34
|
+
outcome: workflowOutcome,
|
|
35
|
+
intervalMilliseconds: loopMilliseconds,
|
|
36
|
+
});
|
|
37
|
+
const stopping = new AbortController();
|
|
38
|
+
const remove = registerStepBridge(stepBridge({
|
|
39
|
+
...ports,
|
|
40
|
+
run: taggedRun,
|
|
41
|
+
call: sdkStepCall,
|
|
42
|
+
stopped: stopping.signal,
|
|
43
|
+
timing: bridgeTiming,
|
|
44
|
+
}));
|
|
45
|
+
return {
|
|
46
|
+
reports: loop.reports,
|
|
47
|
+
close: async () => {
|
|
48
|
+
stopping.abort();
|
|
49
|
+
remove();
|
|
50
|
+
await loop.stop();
|
|
51
|
+
await opening.host.close();
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function githubOf(settings, given) {
|
|
56
|
+
const { directory, repository, checkCommand } = settings;
|
|
57
|
+
return githubWorker({
|
|
58
|
+
document: async (digest) => (await given).document(digest),
|
|
59
|
+
report: async (effect) => (await given).reportEffect(effect),
|
|
60
|
+
operationStatus: async (operationId) => (await (await given).operation(operationId))?.status,
|
|
61
|
+
runStatus: async (runId) => (await (await given).state()).runs[runId]?.status,
|
|
62
|
+
repository,
|
|
63
|
+
gh: settings.githubCommand ?? ["gh"],
|
|
64
|
+
worktrees: join(directory, "worktrees"),
|
|
65
|
+
journal: join(directory, "github"),
|
|
66
|
+
...(settings.privateTexts === undefined
|
|
67
|
+
? {}
|
|
68
|
+
: { privateTexts: settings.privateTexts }),
|
|
69
|
+
...(checkCommand === undefined ? {} : { check: checkCommand }),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function adapters(settings, options) {
|
|
73
|
+
const { directory, repository, command } = settings;
|
|
74
|
+
const { given, table } = options;
|
|
75
|
+
const workflows = Object.fromEntries(table.map((row) => [row.workflowId, settings.workflows[row.functionName]]));
|
|
76
|
+
const document = async (digest) => (await given).document(digest);
|
|
77
|
+
const report = async (effect) => (await given).reportEffect(effect);
|
|
78
|
+
const worker = claudeWorker({
|
|
79
|
+
worker: settings.worker ?? "claude",
|
|
80
|
+
profiles: settings.profiles ?? {},
|
|
81
|
+
workflowId: async (runId) => (await given).workflowId(runId),
|
|
82
|
+
repository,
|
|
83
|
+
command,
|
|
84
|
+
document,
|
|
85
|
+
report,
|
|
86
|
+
worktrees: join(directory, "worktrees"),
|
|
87
|
+
journal: join(directory, "journal"),
|
|
88
|
+
});
|
|
89
|
+
const github = githubOf(settings, given);
|
|
90
|
+
const runs = startDelivery({
|
|
91
|
+
document,
|
|
92
|
+
runs: taggedRuns,
|
|
93
|
+
cancel: cancelled,
|
|
94
|
+
input: async (runId) => (await given).input(runId),
|
|
95
|
+
workflow: async (runId) => workflows[String(await (await given).workflowId(runId))],
|
|
96
|
+
});
|
|
97
|
+
return { worker, github, runs };
|
|
98
|
+
}
|
|
99
|
+
export async function startDaemon(settings) {
|
|
100
|
+
const { directory } = settings;
|
|
101
|
+
const table = ticketRegistrationTable({
|
|
102
|
+
repository: settings.repository,
|
|
103
|
+
command: settings.ticketCommand,
|
|
104
|
+
nextCommand: settings.nextCommand,
|
|
105
|
+
}, settings.declarations);
|
|
106
|
+
const admitted = await ticketRegistrations(settings.manifests, { table });
|
|
107
|
+
if (admitted.kind === "rejected")
|
|
108
|
+
return {
|
|
109
|
+
kind: "refused",
|
|
110
|
+
reason: "workflow-rejected",
|
|
111
|
+
detail: admitted.detail,
|
|
112
|
+
};
|
|
113
|
+
const given = Promise.withResolvers();
|
|
114
|
+
const { worker, github, runs } = adapters(settings, {
|
|
115
|
+
given: given.promise,
|
|
116
|
+
table,
|
|
117
|
+
});
|
|
118
|
+
await mkdir(join(directory, "state"), { recursive: true });
|
|
119
|
+
await mkdir(settings.runtimeDirectory, { recursive: true, mode: 0o700 });
|
|
120
|
+
const opening = await startService({
|
|
121
|
+
stateDirectory: join(directory, "state"),
|
|
122
|
+
runtimeDirectory: settings.runtimeDirectory,
|
|
123
|
+
workflows: admitted.registrations.map((registration) => ({
|
|
124
|
+
...registration,
|
|
125
|
+
...(settings.queueMilliseconds !== undefined &&
|
|
126
|
+
registration.workflowId === "develop-issue"
|
|
127
|
+
? { admission: "when-idle" }
|
|
128
|
+
: {}),
|
|
129
|
+
})),
|
|
130
|
+
delivery: deliveryRouter({
|
|
131
|
+
runs,
|
|
132
|
+
effects: { claude: worker, github },
|
|
133
|
+
}),
|
|
134
|
+
effects: { leaseMilliseconds: turnLeaseMilliseconds },
|
|
135
|
+
host: (ports) => {
|
|
136
|
+
given.resolve(ports);
|
|
137
|
+
return hosted(settings, ports);
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
if (opening.kind === "refused") {
|
|
141
|
+
await Promise.all([worker.close(), github.close()]);
|
|
142
|
+
return opening;
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
kind: "started",
|
|
146
|
+
daemon: await runningDaemon(settings, {
|
|
147
|
+
service: opening.service,
|
|
148
|
+
worker,
|
|
149
|
+
github,
|
|
150
|
+
}),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
async function runningDaemon(settings, resources) {
|
|
154
|
+
const { service, worker, github } = resources;
|
|
155
|
+
await github.scan();
|
|
156
|
+
const notifier = settings.notifyCommand === undefined
|
|
157
|
+
? undefined
|
|
158
|
+
: await notifyRuns({
|
|
159
|
+
directory: settings.directory,
|
|
160
|
+
runtimeDirectory: settings.runtimeDirectory,
|
|
161
|
+
command: settings.notifyCommand,
|
|
162
|
+
...(settings.notifyMilliseconds === undefined
|
|
163
|
+
? {}
|
|
164
|
+
: { intervalMilliseconds: settings.notifyMilliseconds }),
|
|
165
|
+
}).catch(async (error) => {
|
|
166
|
+
await Promise.all([worker.close(), github.close()]);
|
|
167
|
+
await service.close();
|
|
168
|
+
throw error;
|
|
169
|
+
});
|
|
170
|
+
const queue = settings.queueMilliseconds === undefined
|
|
171
|
+
? undefined
|
|
172
|
+
: issueQueue({
|
|
173
|
+
directory: settings.directory,
|
|
174
|
+
runtimeDirectory: settings.runtimeDirectory,
|
|
175
|
+
intervalMilliseconds: settings.queueMilliseconds,
|
|
176
|
+
});
|
|
177
|
+
return {
|
|
178
|
+
socket: service.socket,
|
|
179
|
+
close: async () => {
|
|
180
|
+
await notifier?.stop();
|
|
181
|
+
await queue?.stop();
|
|
182
|
+
await Promise.all([worker.close(), github.close()]);
|
|
183
|
+
await service.close();
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Delivery } from "../broker/actor/delivery-intents.ts";
|
|
2
|
+
import type { StartDelivery } from "../host/start-delivery.ts";
|
|
3
|
+
export type EffectDelivery = Delivery & {
|
|
4
|
+
readonly stop: NonNullable<Delivery["stop"]>;
|
|
5
|
+
};
|
|
6
|
+
export interface DeliveryRoutes {
|
|
7
|
+
readonly runs: StartDelivery;
|
|
8
|
+
readonly effects: Readonly<Record<string, EffectDelivery>>;
|
|
9
|
+
}
|
|
10
|
+
export declare function deliveryRouter(routes: DeliveryRoutes): Delivery;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const refused = {
|
|
2
|
+
kind: "failed",
|
|
3
|
+
reason: "unsupported-effect",
|
|
4
|
+
};
|
|
5
|
+
function protectedEffect(intent) {
|
|
6
|
+
return intent.kind === "protected-effect";
|
|
7
|
+
}
|
|
8
|
+
function workerOf(routes, intent) {
|
|
9
|
+
const capability = String(intent.capability);
|
|
10
|
+
return Object.hasOwn(routes.effects, capability)
|
|
11
|
+
? routes.effects[capability]
|
|
12
|
+
: undefined;
|
|
13
|
+
}
|
|
14
|
+
export function deliveryRouter(routes) {
|
|
15
|
+
const { runs } = routes;
|
|
16
|
+
const refusal = () => Promise.resolve(refused);
|
|
17
|
+
return {
|
|
18
|
+
deliver: (intent, signal) => {
|
|
19
|
+
if (!protectedEffect(intent))
|
|
20
|
+
return runs.deliver(intent);
|
|
21
|
+
return workerOf(routes, intent)?.deliver(intent, signal) ?? refusal();
|
|
22
|
+
},
|
|
23
|
+
reconcile: (intent, signal) => {
|
|
24
|
+
if (!protectedEffect(intent))
|
|
25
|
+
return runs.reconcile(intent);
|
|
26
|
+
return workerOf(routes, intent)?.reconcile(intent, signal) ?? refusal();
|
|
27
|
+
},
|
|
28
|
+
stop: (intent, signal) => {
|
|
29
|
+
if (!protectedEffect(intent))
|
|
30
|
+
return runs.stop(intent);
|
|
31
|
+
return workerOf(routes, intent)?.stop(intent, signal) ?? refusal();
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare const reviewer = "greptile-apps[bot]";
|
|
2
|
+
export declare const reviewLimits: {
|
|
3
|
+
summaryCharacters: number;
|
|
4
|
+
findingCharacters: number;
|
|
5
|
+
findingsBytes: number;
|
|
6
|
+
};
|
|
7
|
+
export interface CallSettings {
|
|
8
|
+
readonly repository: string;
|
|
9
|
+
readonly gh: readonly string[];
|
|
10
|
+
readonly environment?: Readonly<Record<string, string>>;
|
|
11
|
+
readonly privateTexts?: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
export interface Calls {
|
|
14
|
+
readonly gh: (parts: readonly string[]) => Promise<string>;
|
|
15
|
+
readonly git: (directory: string, parts: readonly string[]) => Promise<string>;
|
|
16
|
+
readonly run: (command: readonly string[], directory: string) => Promise<string>;
|
|
17
|
+
}
|
|
18
|
+
export interface Scored {
|
|
19
|
+
readonly score: number;
|
|
20
|
+
readonly summary: string;
|
|
21
|
+
}
|
|
22
|
+
export interface Finding {
|
|
23
|
+
readonly path: string;
|
|
24
|
+
readonly line: number | null;
|
|
25
|
+
readonly body: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function calls(settings: CallSettings, signal: AbortSignal): Calls;
|
|
28
|
+
export declare function scoreOf(comments: unknown, commit: string): Scored | undefined;
|
|
29
|
+
export declare function findingsOf(comments: unknown, commit: string): readonly Finding[];
|