@synergenius/flow-weaver-pack-weaver 0.8.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 +204 -0
- package/README.md +167 -0
- package/dist/bot/agent-provider.d.ts +34 -0
- package/dist/bot/agent-provider.d.ts.map +1 -0
- package/dist/bot/agent-provider.js +218 -0
- package/dist/bot/agent-provider.js.map +1 -0
- package/dist/bot/ai-client.d.ts +15 -0
- package/dist/bot/ai-client.d.ts.map +1 -0
- package/dist/bot/ai-client.js +128 -0
- package/dist/bot/ai-client.js.map +1 -0
- package/dist/bot/approvals.d.ts +22 -0
- package/dist/bot/approvals.d.ts.map +1 -0
- package/dist/bot/approvals.js +187 -0
- package/dist/bot/approvals.js.map +1 -0
- package/dist/bot/audit-logger.d.ts +5 -0
- package/dist/bot/audit-logger.d.ts.map +1 -0
- package/dist/bot/audit-logger.js +42 -0
- package/dist/bot/audit-logger.js.map +1 -0
- package/dist/bot/audit-store.d.ts +13 -0
- package/dist/bot/audit-store.d.ts.map +1 -0
- package/dist/bot/audit-store.js +59 -0
- package/dist/bot/audit-store.js.map +1 -0
- package/dist/bot/bot-agent-channel.d.ts +46 -0
- package/dist/bot/bot-agent-channel.d.ts.map +1 -0
- package/dist/bot/bot-agent-channel.js +58 -0
- package/dist/bot/bot-agent-channel.js.map +1 -0
- package/dist/bot/cli-provider.d.ts +29 -0
- package/dist/bot/cli-provider.d.ts.map +1 -0
- package/dist/bot/cli-provider.js +132 -0
- package/dist/bot/cli-provider.js.map +1 -0
- package/dist/bot/cli-stream-parser.d.ts +11 -0
- package/dist/bot/cli-stream-parser.d.ts.map +1 -0
- package/dist/bot/cli-stream-parser.js +53 -0
- package/dist/bot/cli-stream-parser.js.map +1 -0
- package/dist/bot/cost-store.d.ts +18 -0
- package/dist/bot/cost-store.d.ts.map +1 -0
- package/dist/bot/cost-store.js +81 -0
- package/dist/bot/cost-store.js.map +1 -0
- package/dist/bot/cost-tracker.d.ts +18 -0
- package/dist/bot/cost-tracker.d.ts.map +1 -0
- package/dist/bot/cost-tracker.js +60 -0
- package/dist/bot/cost-tracker.js.map +1 -0
- package/dist/bot/cron-parser.d.ts +5 -0
- package/dist/bot/cron-parser.d.ts.map +1 -0
- package/dist/bot/cron-parser.js +141 -0
- package/dist/bot/cron-parser.js.map +1 -0
- package/dist/bot/cron-scheduler.d.ts +12 -0
- package/dist/bot/cron-scheduler.d.ts.map +1 -0
- package/dist/bot/cron-scheduler.js +43 -0
- package/dist/bot/cron-scheduler.js.map +1 -0
- package/dist/bot/dashboard.d.ts +34 -0
- package/dist/bot/dashboard.d.ts.map +1 -0
- package/dist/bot/dashboard.js +602 -0
- package/dist/bot/dashboard.js.map +1 -0
- package/dist/bot/design-checker.d.ts +24 -0
- package/dist/bot/design-checker.d.ts.map +1 -0
- package/dist/bot/design-checker.js +269 -0
- package/dist/bot/design-checker.js.map +1 -0
- package/dist/bot/file-lock.d.ts +7 -0
- package/dist/bot/file-lock.d.ts.map +1 -0
- package/dist/bot/file-lock.js +64 -0
- package/dist/bot/file-lock.js.map +1 -0
- package/dist/bot/file-validator.d.ts +10 -0
- package/dist/bot/file-validator.d.ts.map +1 -0
- package/dist/bot/file-validator.js +27 -0
- package/dist/bot/file-validator.js.map +1 -0
- package/dist/bot/file-watcher.d.ts +24 -0
- package/dist/bot/file-watcher.d.ts.map +1 -0
- package/dist/bot/file-watcher.js +98 -0
- package/dist/bot/file-watcher.js.map +1 -0
- package/dist/bot/fw-api.d.ts +8 -0
- package/dist/bot/fw-api.d.ts.map +1 -0
- package/dist/bot/fw-api.js +12 -0
- package/dist/bot/fw-api.js.map +1 -0
- package/dist/bot/genesis-prompt-context.d.ts +31 -0
- package/dist/bot/genesis-prompt-context.d.ts.map +1 -0
- package/dist/bot/genesis-prompt-context.js +121 -0
- package/dist/bot/genesis-prompt-context.js.map +1 -0
- package/dist/bot/genesis-store.d.ts +28 -0
- package/dist/bot/genesis-store.d.ts.map +1 -0
- package/dist/bot/genesis-store.js +154 -0
- package/dist/bot/genesis-store.js.map +1 -0
- package/dist/bot/index.d.ts +38 -0
- package/dist/bot/index.d.ts.map +1 -0
- package/dist/bot/index.js +37 -0
- package/dist/bot/index.js.map +1 -0
- package/dist/bot/notifications.d.ts +20 -0
- package/dist/bot/notifications.d.ts.map +1 -0
- package/dist/bot/notifications.js +215 -0
- package/dist/bot/notifications.js.map +1 -0
- package/dist/bot/pipeline-runner.d.ts +22 -0
- package/dist/bot/pipeline-runner.d.ts.map +1 -0
- package/dist/bot/pipeline-runner.js +263 -0
- package/dist/bot/pipeline-runner.js.map +1 -0
- package/dist/bot/provider-registry.d.ts +26 -0
- package/dist/bot/provider-registry.d.ts.map +1 -0
- package/dist/bot/provider-registry.js +175 -0
- package/dist/bot/provider-registry.js.map +1 -0
- package/dist/bot/run-store.d.ts +25 -0
- package/dist/bot/run-store.d.ts.map +1 -0
- package/dist/bot/run-store.js +156 -0
- package/dist/bot/run-store.js.map +1 -0
- package/dist/bot/runner.d.ts +13 -0
- package/dist/bot/runner.d.ts.map +1 -0
- package/dist/bot/runner.js +244 -0
- package/dist/bot/runner.js.map +1 -0
- package/dist/bot/session-state.d.ts +19 -0
- package/dist/bot/session-state.d.ts.map +1 -0
- package/dist/bot/session-state.js +65 -0
- package/dist/bot/session-state.js.map +1 -0
- package/dist/bot/steering.d.ts +13 -0
- package/dist/bot/steering.d.ts.map +1 -0
- package/dist/bot/steering.js +40 -0
- package/dist/bot/steering.js.map +1 -0
- package/dist/bot/step-executor.d.ts +10 -0
- package/dist/bot/step-executor.d.ts.map +1 -0
- package/dist/bot/step-executor.js +30 -0
- package/dist/bot/step-executor.js.map +1 -0
- package/dist/bot/system-prompt.d.ts +19 -0
- package/dist/bot/system-prompt.d.ts.map +1 -0
- package/dist/bot/system-prompt.js +222 -0
- package/dist/bot/system-prompt.js.map +1 -0
- package/dist/bot/task-queue.d.ts +26 -0
- package/dist/bot/task-queue.d.ts.map +1 -0
- package/dist/bot/task-queue.js +98 -0
- package/dist/bot/task-queue.js.map +1 -0
- package/dist/bot/types.d.ts +478 -0
- package/dist/bot/types.d.ts.map +1 -0
- package/dist/bot/types.js +2 -0
- package/dist/bot/types.js.map +1 -0
- package/dist/bot/utils.d.ts +2 -0
- package/dist/bot/utils.d.ts.map +1 -0
- package/dist/bot/utils.js +20 -0
- package/dist/bot/utils.js.map +1 -0
- package/dist/bot/watch-daemon.d.ts +19 -0
- package/dist/bot/watch-daemon.d.ts.map +1 -0
- package/dist/bot/watch-daemon.js +178 -0
- package/dist/bot/watch-daemon.js.map +1 -0
- package/dist/bot/web-approval.d.ts +19 -0
- package/dist/bot/web-approval.d.ts.map +1 -0
- package/dist/bot/web-approval.js +207 -0
- package/dist/bot/web-approval.js.map +1 -0
- package/dist/cli-bridge.d.ts +2 -0
- package/dist/cli-bridge.d.ts.map +1 -0
- package/dist/cli-bridge.js +30 -0
- package/dist/cli-bridge.js.map +1 -0
- package/dist/cli-handlers.d.ts +79 -0
- package/dist/cli-handlers.d.ts.map +1 -0
- package/dist/cli-handlers.js +1335 -0
- package/dist/cli-handlers.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +749 -0
- package/dist/cli.js.map +1 -0
- package/dist/docs/docs/weaver-config.md +135 -0
- package/dist/docs/weaver-config.md +141 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-tools.d.ts +13 -0
- package/dist/mcp-tools.d.ts.map +1 -0
- package/dist/mcp-tools.js +197 -0
- package/dist/mcp-tools.js.map +1 -0
- package/dist/node-types/abort-task.d.ts +15 -0
- package/dist/node-types/abort-task.d.ts.map +1 -0
- package/dist/node-types/abort-task.js +28 -0
- package/dist/node-types/abort-task.js.map +1 -0
- package/dist/node-types/approval-gate.d.ts +18 -0
- package/dist/node-types/approval-gate.d.ts.map +1 -0
- package/dist/node-types/approval-gate.js +80 -0
- package/dist/node-types/approval-gate.js.map +1 -0
- package/dist/node-types/bot-report.d.ts +20 -0
- package/dist/node-types/bot-report.d.ts.map +1 -0
- package/dist/node-types/bot-report.js +67 -0
- package/dist/node-types/bot-report.js.map +1 -0
- package/dist/node-types/build-context.d.ts +16 -0
- package/dist/node-types/build-context.d.ts.map +1 -0
- package/dist/node-types/build-context.js +64 -0
- package/dist/node-types/build-context.js.map +1 -0
- package/dist/node-types/detect-provider.d.ts +17 -0
- package/dist/node-types/detect-provider.d.ts.map +1 -0
- package/dist/node-types/detect-provider.js +71 -0
- package/dist/node-types/detect-provider.js.map +1 -0
- package/dist/node-types/exec-validate-retry.d.ts +17 -0
- package/dist/node-types/exec-validate-retry.d.ts.map +1 -0
- package/dist/node-types/exec-validate-retry.js +147 -0
- package/dist/node-types/exec-validate-retry.js.map +1 -0
- package/dist/node-types/execute-plan.d.ts +26 -0
- package/dist/node-types/execute-plan.d.ts.map +1 -0
- package/dist/node-types/execute-plan.js +120 -0
- package/dist/node-types/execute-plan.js.map +1 -0
- package/dist/node-types/execute-target.d.ts +16 -0
- package/dist/node-types/execute-target.d.ts.map +1 -0
- package/dist/node-types/execute-target.js +238 -0
- package/dist/node-types/execute-target.js.map +1 -0
- package/dist/node-types/fix-errors.d.ts +24 -0
- package/dist/node-types/fix-errors.d.ts.map +1 -0
- package/dist/node-types/fix-errors.js +49 -0
- package/dist/node-types/fix-errors.js.map +1 -0
- package/dist/node-types/genesis-apply-retry.d.ts +27 -0
- package/dist/node-types/genesis-apply-retry.d.ts.map +1 -0
- package/dist/node-types/genesis-apply-retry.js +97 -0
- package/dist/node-types/genesis-apply-retry.js.map +1 -0
- package/dist/node-types/genesis-apply.d.ts +29 -0
- package/dist/node-types/genesis-apply.d.ts.map +1 -0
- package/dist/node-types/genesis-apply.js +76 -0
- package/dist/node-types/genesis-apply.js.map +1 -0
- package/dist/node-types/genesis-approve.d.ts +19 -0
- package/dist/node-types/genesis-approve.d.ts.map +1 -0
- package/dist/node-types/genesis-approve.js +59 -0
- package/dist/node-types/genesis-approve.js.map +1 -0
- package/dist/node-types/genesis-check-stabilize.d.ts +16 -0
- package/dist/node-types/genesis-check-stabilize.d.ts.map +1 -0
- package/dist/node-types/genesis-check-stabilize.js +32 -0
- package/dist/node-types/genesis-check-stabilize.js.map +1 -0
- package/dist/node-types/genesis-check-threshold.d.ts +15 -0
- package/dist/node-types/genesis-check-threshold.d.ts.map +1 -0
- package/dist/node-types/genesis-check-threshold.js +29 -0
- package/dist/node-types/genesis-check-threshold.js.map +1 -0
- package/dist/node-types/genesis-commit.d.ts +17 -0
- package/dist/node-types/genesis-commit.d.ts.map +1 -0
- package/dist/node-types/genesis-commit.js +59 -0
- package/dist/node-types/genesis-commit.js.map +1 -0
- package/dist/node-types/genesis-compile-validate.d.ts +26 -0
- package/dist/node-types/genesis-compile-validate.d.ts.map +1 -0
- package/dist/node-types/genesis-compile-validate.js +60 -0
- package/dist/node-types/genesis-compile-validate.js.map +1 -0
- package/dist/node-types/genesis-diff-fingerprint.d.ts +15 -0
- package/dist/node-types/genesis-diff-fingerprint.d.ts.map +1 -0
- package/dist/node-types/genesis-diff-fingerprint.js +59 -0
- package/dist/node-types/genesis-diff-fingerprint.js.map +1 -0
- package/dist/node-types/genesis-diff-workflow.d.ts +15 -0
- package/dist/node-types/genesis-diff-workflow.d.ts.map +1 -0
- package/dist/node-types/genesis-diff-workflow.js +67 -0
- package/dist/node-types/genesis-diff-workflow.js.map +1 -0
- package/dist/node-types/genesis-escrow-grace.d.ts +15 -0
- package/dist/node-types/genesis-escrow-grace.d.ts.map +1 -0
- package/dist/node-types/genesis-escrow-grace.js +52 -0
- package/dist/node-types/genesis-escrow-grace.js.map +1 -0
- package/dist/node-types/genesis-escrow-migrate.d.ts +21 -0
- package/dist/node-types/genesis-escrow-migrate.d.ts.map +1 -0
- package/dist/node-types/genesis-escrow-migrate.js +116 -0
- package/dist/node-types/genesis-escrow-migrate.js.map +1 -0
- package/dist/node-types/genesis-escrow-recover.d.ts +15 -0
- package/dist/node-types/genesis-escrow-recover.d.ts.map +1 -0
- package/dist/node-types/genesis-escrow-recover.js +90 -0
- package/dist/node-types/genesis-escrow-recover.js.map +1 -0
- package/dist/node-types/genesis-escrow-stage.d.ts +17 -0
- package/dist/node-types/genesis-escrow-stage.d.ts.map +1 -0
- package/dist/node-types/genesis-escrow-stage.js +86 -0
- package/dist/node-types/genesis-escrow-stage.js.map +1 -0
- package/dist/node-types/genesis-escrow-validate.d.ts +17 -0
- package/dist/node-types/genesis-escrow-validate.d.ts.map +1 -0
- package/dist/node-types/genesis-escrow-validate.js +110 -0
- package/dist/node-types/genesis-escrow-validate.js.map +1 -0
- package/dist/node-types/genesis-load-config.d.ts +17 -0
- package/dist/node-types/genesis-load-config.d.ts.map +1 -0
- package/dist/node-types/genesis-load-config.js +36 -0
- package/dist/node-types/genesis-load-config.js.map +1 -0
- package/dist/node-types/genesis-observe.d.ts +18 -0
- package/dist/node-types/genesis-observe.d.ts.map +1 -0
- package/dist/node-types/genesis-observe.js +103 -0
- package/dist/node-types/genesis-observe.js.map +1 -0
- package/dist/node-types/genesis-propose.d.ts +17 -0
- package/dist/node-types/genesis-propose.d.ts.map +1 -0
- package/dist/node-types/genesis-propose.js +69 -0
- package/dist/node-types/genesis-propose.js.map +1 -0
- package/dist/node-types/genesis-report.d.ts +20 -0
- package/dist/node-types/genesis-report.d.ts.map +1 -0
- package/dist/node-types/genesis-report.js +87 -0
- package/dist/node-types/genesis-report.js.map +1 -0
- package/dist/node-types/genesis-snapshot.d.ts +15 -0
- package/dist/node-types/genesis-snapshot.d.ts.map +1 -0
- package/dist/node-types/genesis-snapshot.js +26 -0
- package/dist/node-types/genesis-snapshot.js.map +1 -0
- package/dist/node-types/genesis-try-apply.d.ts +18 -0
- package/dist/node-types/genesis-try-apply.d.ts.map +1 -0
- package/dist/node-types/genesis-try-apply.js +142 -0
- package/dist/node-types/genesis-try-apply.js.map +1 -0
- package/dist/node-types/genesis-update-history.d.ts +15 -0
- package/dist/node-types/genesis-update-history.d.ts.map +1 -0
- package/dist/node-types/genesis-update-history.js +70 -0
- package/dist/node-types/genesis-update-history.js.map +1 -0
- package/dist/node-types/genesis-validate-proposal.d.ts +16 -0
- package/dist/node-types/genesis-validate-proposal.d.ts.map +1 -0
- package/dist/node-types/genesis-validate-proposal.js +109 -0
- package/dist/node-types/genesis-validate-proposal.js.map +1 -0
- package/dist/node-types/git-ops.d.ts +15 -0
- package/dist/node-types/git-ops.d.ts.map +1 -0
- package/dist/node-types/git-ops.js +69 -0
- package/dist/node-types/git-ops.js.map +1 -0
- package/dist/node-types/index.d.ts +37 -0
- package/dist/node-types/index.d.ts.map +1 -0
- package/dist/node-types/index.js +37 -0
- package/dist/node-types/index.js.map +1 -0
- package/dist/node-types/load-config.d.ts +17 -0
- package/dist/node-types/load-config.d.ts.map +1 -0
- package/dist/node-types/load-config.js +27 -0
- package/dist/node-types/load-config.js.map +1 -0
- package/dist/node-types/plan-task.d.ts +17 -0
- package/dist/node-types/plan-task.d.ts.map +1 -0
- package/dist/node-types/plan-task.js +55 -0
- package/dist/node-types/plan-task.js.map +1 -0
- package/dist/node-types/read-workflow.d.ts +15 -0
- package/dist/node-types/read-workflow.d.ts.map +1 -0
- package/dist/node-types/read-workflow.js +60 -0
- package/dist/node-types/read-workflow.js.map +1 -0
- package/dist/node-types/receive-task.d.ts +20 -0
- package/dist/node-types/receive-task.d.ts.map +1 -0
- package/dist/node-types/receive-task.js +69 -0
- package/dist/node-types/receive-task.js.map +1 -0
- package/dist/node-types/report.d.ts +14 -0
- package/dist/node-types/report.d.ts.map +1 -0
- package/dist/node-types/report.js +25 -0
- package/dist/node-types/report.js.map +1 -0
- package/dist/node-types/resolve-target.d.ts +16 -0
- package/dist/node-types/resolve-target.d.ts.map +1 -0
- package/dist/node-types/resolve-target.js +67 -0
- package/dist/node-types/resolve-target.js.map +1 -0
- package/dist/node-types/route-task.d.ts +14 -0
- package/dist/node-types/route-task.d.ts.map +1 -0
- package/dist/node-types/route-task.js +22 -0
- package/dist/node-types/route-task.js.map +1 -0
- package/dist/node-types/send-notify.d.ts +14 -0
- package/dist/node-types/send-notify.d.ts.map +1 -0
- package/dist/node-types/send-notify.js +71 -0
- package/dist/node-types/send-notify.js.map +1 -0
- package/dist/node-types/validate-result.d.ts +24 -0
- package/dist/node-types/validate-result.d.ts.map +1 -0
- package/dist/node-types/validate-result.js +38 -0
- package/dist/node-types/validate-result.js.map +1 -0
- package/dist/templates/index.d.ts +5 -0
- package/dist/templates/index.d.ts.map +1 -0
- package/dist/templates/index.js +4 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/weaver-bot-template.d.ts +11 -0
- package/dist/templates/weaver-bot-template.d.ts.map +1 -0
- package/dist/templates/weaver-bot-template.js +99 -0
- package/dist/templates/weaver-bot-template.js.map +1 -0
- package/dist/templates/weaver-template.d.ts +11 -0
- package/dist/templates/weaver-template.d.ts.map +1 -0
- package/dist/templates/weaver-template.js +53 -0
- package/dist/templates/weaver-template.js.map +1 -0
- package/dist/workflows/genesis-task.d.ts +62 -0
- package/dist/workflows/genesis-task.d.ts.map +1 -0
- package/dist/workflows/genesis-task.js +64 -0
- package/dist/workflows/genesis-task.js.map +1 -0
- package/dist/workflows/index.d.ts +4 -0
- package/dist/workflows/index.d.ts.map +1 -0
- package/dist/workflows/index.js +4 -0
- package/dist/workflows/index.js.map +1 -0
- package/dist/workflows/weaver-bot-batch.d.ts +49 -0
- package/dist/workflows/weaver-bot-batch.d.ts.map +1 -0
- package/dist/workflows/weaver-bot-batch.js +49 -0
- package/dist/workflows/weaver-bot-batch.js.map +1 -0
- package/dist/workflows/weaver-bot-session.d.ts +65 -0
- package/dist/workflows/weaver-bot-session.d.ts.map +1 -0
- package/dist/workflows/weaver-bot-session.js +68 -0
- package/dist/workflows/weaver-bot-session.js.map +1 -0
- package/dist/workflows/weaver-bot.d.ts +61 -0
- package/dist/workflows/weaver-bot.d.ts.map +1 -0
- package/dist/workflows/weaver-bot.js +61 -0
- package/dist/workflows/weaver-bot.js.map +1 -0
- package/dist/workflows/weaver.d.ts +24 -0
- package/dist/workflows/weaver.d.ts.map +1 -0
- package/dist/workflows/weaver.js +28 -0
- package/dist/workflows/weaver.js.map +1 -0
- package/flowweaver.manifest.json +1001 -0
- package/package.json +78 -0
- package/src/bot/agent-provider.ts +273 -0
- package/src/bot/ai-client.ts +153 -0
- package/src/bot/approvals.ts +273 -0
- package/src/bot/audit-logger.ts +45 -0
- package/src/bot/audit-store.ts +69 -0
- package/src/bot/bot-agent-channel.ts +99 -0
- package/src/bot/cli-provider.ts +169 -0
- package/src/bot/cli-stream-parser.ts +59 -0
- package/src/bot/cost-store.ts +92 -0
- package/src/bot/cost-tracker.ts +72 -0
- package/src/bot/cron-parser.ts +153 -0
- package/src/bot/cron-scheduler.ts +48 -0
- package/src/bot/dashboard.ts +658 -0
- package/src/bot/design-checker.ts +327 -0
- package/src/bot/file-lock.ts +73 -0
- package/src/bot/file-validator.ts +41 -0
- package/src/bot/file-watcher.ts +103 -0
- package/src/bot/fw-api.ts +18 -0
- package/src/bot/genesis-prompt-context.ts +135 -0
- package/src/bot/genesis-store.ts +180 -0
- package/src/bot/index.ts +127 -0
- package/src/bot/notifications.ts +263 -0
- package/src/bot/pipeline-runner.ts +324 -0
- package/src/bot/provider-registry.ts +236 -0
- package/src/bot/run-store.ts +169 -0
- package/src/bot/runner.ts +311 -0
- package/src/bot/session-state.ts +73 -0
- package/src/bot/steering.ts +44 -0
- package/src/bot/step-executor.ts +34 -0
- package/src/bot/system-prompt.ts +280 -0
- package/src/bot/task-queue.ts +111 -0
- package/src/bot/types.ts +571 -0
- package/src/bot/utils.ts +17 -0
- package/src/bot/watch-daemon.ts +203 -0
- package/src/bot/web-approval.ts +240 -0
- package/src/cli-bridge.ts +41 -0
- package/src/cli-handlers.ts +1445 -0
- package/src/docs/weaver-config.md +135 -0
- package/src/index.ts +177 -0
- package/src/mcp-tools.ts +274 -0
- package/src/node-types/abort-task.ts +31 -0
- package/src/node-types/approval-gate.ts +95 -0
- package/src/node-types/bot-report.ts +82 -0
- package/src/node-types/build-context.ts +65 -0
- package/src/node-types/detect-provider.ts +77 -0
- package/src/node-types/exec-validate-retry.ts +170 -0
- package/src/node-types/execute-plan.ts +130 -0
- package/src/node-types/execute-target.ts +256 -0
- package/src/node-types/fix-errors.ts +63 -0
- package/src/node-types/genesis-apply-retry.ts +133 -0
- package/src/node-types/genesis-apply.ts +96 -0
- package/src/node-types/genesis-approve.ts +73 -0
- package/src/node-types/genesis-check-stabilize.ts +37 -0
- package/src/node-types/genesis-check-threshold.ts +34 -0
- package/src/node-types/genesis-commit.ts +71 -0
- package/src/node-types/genesis-compile-validate.ts +77 -0
- package/src/node-types/genesis-diff-fingerprint.ts +67 -0
- package/src/node-types/genesis-diff-workflow.ts +71 -0
- package/src/node-types/genesis-escrow-grace.ts +62 -0
- package/src/node-types/genesis-escrow-migrate.ts +138 -0
- package/src/node-types/genesis-escrow-recover.ts +99 -0
- package/src/node-types/genesis-escrow-stage.ts +104 -0
- package/src/node-types/genesis-escrow-validate.ts +120 -0
- package/src/node-types/genesis-load-config.ts +44 -0
- package/src/node-types/genesis-observe.ts +119 -0
- package/src/node-types/genesis-propose.ts +86 -0
- package/src/node-types/genesis-report.ts +95 -0
- package/src/node-types/genesis-snapshot.ts +30 -0
- package/src/node-types/genesis-try-apply.ts +165 -0
- package/src/node-types/genesis-update-history.ts +72 -0
- package/src/node-types/genesis-validate-proposal.ts +124 -0
- package/src/node-types/git-ops.ts +72 -0
- package/src/node-types/index.ts +36 -0
- package/src/node-types/load-config.ts +27 -0
- package/src/node-types/plan-task.ts +66 -0
- package/src/node-types/read-workflow.ts +68 -0
- package/src/node-types/receive-task.ts +92 -0
- package/src/node-types/report.ts +25 -0
- package/src/node-types/resolve-target.ts +64 -0
- package/src/node-types/route-task.ts +25 -0
- package/src/node-types/send-notify.ts +75 -0
- package/src/node-types/validate-result.ts +49 -0
- package/src/templates/index.ts +5 -0
- package/src/templates/weaver-bot-template.ts +106 -0
- package/src/workflows/genesis-task.ts +91 -0
- package/src/workflows/index.ts +3 -0
- package/src/workflows/weaver-bot-batch.ts +65 -0
- package/src/workflows/weaver-bot.ts +79 -0
- package/templates.js +1 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import * as crypto from 'node:crypto';
|
|
4
|
+
import type { GenesisContext, GenesisConfig, GenesisProposal, GenesisOperation, EscrowToken } from '../bot/types.js';
|
|
5
|
+
import { GenesisStore } from '../bot/genesis-store.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Separates self-modify operations from the proposal, copies current files
|
|
9
|
+
* to backup, writes new content to staged, and creates the escrow token.
|
|
10
|
+
*
|
|
11
|
+
* @flowWeaver nodeType
|
|
12
|
+
* @label Genesis Escrow Stage
|
|
13
|
+
* @input ctx [order:0] - Genesis context (JSON)
|
|
14
|
+
* @output ctx [order:0] - Genesis context with escrow staging result (JSON)
|
|
15
|
+
* @output onSuccess [order:-2] - On Success
|
|
16
|
+
* @output onFailure [order:-1] [hidden] - On Failure
|
|
17
|
+
*/
|
|
18
|
+
export function genesisEscrowStage(ctx: string): {
|
|
19
|
+
onSuccess: boolean; onFailure: boolean;
|
|
20
|
+
ctx: string;
|
|
21
|
+
} {
|
|
22
|
+
const context = JSON.parse(ctx) as GenesisContext;
|
|
23
|
+
const { env } = context;
|
|
24
|
+
const config = JSON.parse(context.genesisConfigJson) as GenesisConfig;
|
|
25
|
+
const proposal = JSON.parse(context.proposalJson!) as GenesisProposal;
|
|
26
|
+
|
|
27
|
+
const selfModifyTypes = new Set(['selfModifyWorkflow', 'selfModifyNodeType', 'selfModifyModule']);
|
|
28
|
+
const selfOps = proposal.operations.filter(op => selfModifyTypes.has(op.type));
|
|
29
|
+
|
|
30
|
+
if (selfOps.length === 0) {
|
|
31
|
+
context.hasSelfModifyOps = false;
|
|
32
|
+
return { onSuccess: true, onFailure: false, ctx: JSON.stringify(context) };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Resolve the pack root (parent of src/)
|
|
36
|
+
const packRoot = path.resolve(path.dirname(new URL(import.meta.url).pathname), '..', '..');
|
|
37
|
+
|
|
38
|
+
const store = new GenesisStore(env.projectDir);
|
|
39
|
+
store.ensureEscrowDirs();
|
|
40
|
+
|
|
41
|
+
const affectedFiles: string[] = [];
|
|
42
|
+
const stagedHashes: Record<string, string> = {};
|
|
43
|
+
const backupHashes: Record<string, string> = {};
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
for (const op of selfOps) {
|
|
47
|
+
const relFile = op.args.file!;
|
|
48
|
+
|
|
49
|
+
// Path traversal protection
|
|
50
|
+
const normalized = path.normalize(relFile);
|
|
51
|
+
if (normalized.startsWith('..') || path.isAbsolute(normalized)) {
|
|
52
|
+
console.error(`\x1b[31m→ Rejected unsafe file path: ${relFile}\x1b[0m`);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const absFile = path.resolve(packRoot, relFile);
|
|
57
|
+
affectedFiles.push(relFile);
|
|
58
|
+
|
|
59
|
+
// Backup current file
|
|
60
|
+
if (fs.existsSync(absFile)) {
|
|
61
|
+
const backupDest = store.getEscrowBackupPath(relFile);
|
|
62
|
+
fs.mkdirSync(path.dirname(backupDest), { recursive: true });
|
|
63
|
+
fs.copyFileSync(absFile, backupDest);
|
|
64
|
+
backupHashes[relFile] = GenesisStore.hashFile(absFile);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Write staged content then hash the file (consistent with GenesisStore.hashFile)
|
|
68
|
+
const stagedDest = store.getEscrowStagedPath(relFile);
|
|
69
|
+
fs.mkdirSync(path.dirname(stagedDest), { recursive: true });
|
|
70
|
+
fs.writeFileSync(stagedDest, op.args.content!, 'utf-8');
|
|
71
|
+
stagedHashes[relFile] = GenesisStore.hashFile(stagedDest);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const gracePeriod = config.selfEvolveGracePeriod ?? 3;
|
|
75
|
+
|
|
76
|
+
const token: EscrowToken = {
|
|
77
|
+
migrationId: crypto.randomUUID().slice(0, 12),
|
|
78
|
+
cycleId: context.cycleId,
|
|
79
|
+
stagedAt: new Date().toISOString(),
|
|
80
|
+
phase: 'staged',
|
|
81
|
+
affectedFiles,
|
|
82
|
+
stagedFileHashes: stagedHashes,
|
|
83
|
+
backupFileHashes: backupHashes,
|
|
84
|
+
ownerPid: process.pid,
|
|
85
|
+
graceRemaining: gracePeriod,
|
|
86
|
+
graceCycleIds: [],
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
store.saveEscrowToken(token);
|
|
90
|
+
|
|
91
|
+
context.hasSelfModifyOps = true;
|
|
92
|
+
context.selfModifyOpsJson = JSON.stringify(selfOps);
|
|
93
|
+
context.escrowResultJson = JSON.stringify({ staged: true, migrationId: token.migrationId, files: affectedFiles });
|
|
94
|
+
|
|
95
|
+
console.log(`\x1b[36m→ Escrow staged: ${affectedFiles.length} file(s), migration ${token.migrationId}\x1b[0m`);
|
|
96
|
+
return { onSuccess: true, onFailure: false, ctx: JSON.stringify(context) };
|
|
97
|
+
} catch (err: unknown) {
|
|
98
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
99
|
+
console.error(`\x1b[31m→ Escrow staging failed: ${msg}\x1b[0m`);
|
|
100
|
+
store.clearEscrow();
|
|
101
|
+
context.error = `Escrow staging failed: ${msg}`;
|
|
102
|
+
return { onSuccess: false, onFailure: true, ctx: JSON.stringify(context) };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import * as os from 'node:os';
|
|
4
|
+
import { execFileSync } from 'node:child_process';
|
|
5
|
+
import type { GenesisContext } from '../bot/types.js';
|
|
6
|
+
import { GenesisStore } from '../bot/genesis-store.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Validates staged escrow files. For workflows, runs flow-weaver compile+validate
|
|
10
|
+
* on a temp copy. For TypeScript modules, runs a transpile check.
|
|
11
|
+
*
|
|
12
|
+
* @flowWeaver nodeType
|
|
13
|
+
* @label Genesis Escrow Validate
|
|
14
|
+
* @input ctx [order:0] - Genesis context (JSON)
|
|
15
|
+
* @output ctx [order:0] - Genesis context with escrow validation result (JSON)
|
|
16
|
+
* @output onSuccess [order:-2] - On Success
|
|
17
|
+
* @output onFailure [order:-1] [hidden] - On Failure
|
|
18
|
+
*/
|
|
19
|
+
export function genesisEscrowValidate(ctx: string): {
|
|
20
|
+
onSuccess: boolean; onFailure: boolean;
|
|
21
|
+
ctx: string;
|
|
22
|
+
} {
|
|
23
|
+
const context = JSON.parse(ctx) as GenesisContext;
|
|
24
|
+
const { env } = context;
|
|
25
|
+
const store = new GenesisStore(env.projectDir);
|
|
26
|
+
const token = store.loadEscrowToken();
|
|
27
|
+
|
|
28
|
+
if (!token || token.phase !== 'staged') {
|
|
29
|
+
// No staged escrow: pass through (not an error, just nothing to validate)
|
|
30
|
+
return { onSuccess: true, onFailure: false, ctx: JSON.stringify(context) };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const packRoot = path.resolve(path.dirname(new URL(import.meta.url).pathname), '..', '..');
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
for (const relFile of token.affectedFiles) {
|
|
37
|
+
const stagedPath = store.getEscrowStagedPath(relFile);
|
|
38
|
+
const content = fs.readFileSync(stagedPath, 'utf-8');
|
|
39
|
+
|
|
40
|
+
if (relFile.includes('workflows/')) {
|
|
41
|
+
// Workflow file: write to temp, run compile+validate
|
|
42
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'escrow-validate-'));
|
|
43
|
+
const tmpFile = path.join(tmpDir, path.basename(relFile));
|
|
44
|
+
fs.writeFileSync(tmpFile, content, 'utf-8');
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
execFileSync('flow-weaver', ['compile', tmpFile], {
|
|
48
|
+
cwd: packRoot,
|
|
49
|
+
encoding: 'utf-8',
|
|
50
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
51
|
+
timeout: 30_000,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
execFileSync('flow-weaver', ['validate', tmpFile], {
|
|
55
|
+
cwd: packRoot,
|
|
56
|
+
encoding: 'utf-8',
|
|
57
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
58
|
+
timeout: 30_000,
|
|
59
|
+
});
|
|
60
|
+
} finally {
|
|
61
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
// TypeScript module: transpile check using tsc --noEmit on a temp file
|
|
65
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'escrow-tsc-'));
|
|
66
|
+
const tmpFile = path.join(tmpDir, path.basename(relFile));
|
|
67
|
+
fs.writeFileSync(tmpFile, content, 'utf-8');
|
|
68
|
+
|
|
69
|
+
// Write a minimal tsconfig for the check
|
|
70
|
+
const tsconfig = {
|
|
71
|
+
compilerOptions: {
|
|
72
|
+
target: 'ES2022',
|
|
73
|
+
module: 'Node16',
|
|
74
|
+
moduleResolution: 'Node16',
|
|
75
|
+
noEmit: true,
|
|
76
|
+
strict: true,
|
|
77
|
+
skipLibCheck: true,
|
|
78
|
+
esModuleInterop: true,
|
|
79
|
+
},
|
|
80
|
+
include: [path.basename(relFile)],
|
|
81
|
+
};
|
|
82
|
+
fs.writeFileSync(path.join(tmpDir, 'tsconfig.json'), JSON.stringify(tsconfig), 'utf-8');
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
execFileSync('npx', ['tsc', '--project', path.join(tmpDir, 'tsconfig.json')], {
|
|
86
|
+
cwd: tmpDir,
|
|
87
|
+
encoding: 'utf-8',
|
|
88
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
89
|
+
timeout: 30_000,
|
|
90
|
+
});
|
|
91
|
+
} finally {
|
|
92
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
token.phase = 'validated';
|
|
98
|
+
token.validationResult = { compiled: true, validated: true };
|
|
99
|
+
store.saveEscrowToken(token);
|
|
100
|
+
|
|
101
|
+
console.log('\x1b[32m→ Escrow validation passed\x1b[0m');
|
|
102
|
+
return { onSuccess: true, onFailure: false, ctx: JSON.stringify(context) };
|
|
103
|
+
} catch (err: unknown) {
|
|
104
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
105
|
+
|
|
106
|
+
token.phase = 'rolled-back';
|
|
107
|
+
token.rollbackReason = `Validation failed: ${msg.slice(0, 500)}`;
|
|
108
|
+
token.validationResult = { compiled: false, validated: false, error: msg.slice(0, 500) };
|
|
109
|
+
store.saveEscrowToken(token);
|
|
110
|
+
|
|
111
|
+
// Clean up staged files
|
|
112
|
+
for (const relFile of token.affectedFiles) {
|
|
113
|
+
try { fs.unlinkSync(store.getEscrowStagedPath(relFile)); } catch { /* ignore */ }
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
console.error(`\x1b[31m→ Escrow validation failed: ${msg.slice(0, 200)}\x1b[0m`);
|
|
117
|
+
context.error = `Escrow validation failed: ${msg.slice(0, 200)}`;
|
|
118
|
+
return { onSuccess: false, onFailure: true, ctx: JSON.stringify(context) };
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import type { WeaverEnv, GenesisConfig, GenesisContext } from '../bot/types.js';
|
|
4
|
+
import { GenesisStore } from '../bot/genesis-store.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Loads genesis configuration from the project .genesis directory,
|
|
8
|
+
* validates the target workflow exists, and generates a new cycle ID.
|
|
9
|
+
* Creates the initial GenesisContext that threads through the pipeline.
|
|
10
|
+
*
|
|
11
|
+
* @flowWeaver nodeType
|
|
12
|
+
* @expression
|
|
13
|
+
* @label Genesis Load Config
|
|
14
|
+
* @input env [order:0] - Weaver environment bundle
|
|
15
|
+
* @output ctx [order:0] - Genesis context (JSON)
|
|
16
|
+
* @output onFailure [hidden]
|
|
17
|
+
*/
|
|
18
|
+
export function genesisLoadConfig(env: WeaverEnv): {
|
|
19
|
+
ctx: string;
|
|
20
|
+
} {
|
|
21
|
+
const store = new GenesisStore(env.projectDir);
|
|
22
|
+
const config = store.loadConfig();
|
|
23
|
+
|
|
24
|
+
if (!config.targetWorkflow) {
|
|
25
|
+
throw new Error('Genesis config has no targetWorkflow set. Run "weaver genesis --init" and set it in .genesis/config.json');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const targetPath = path.resolve(env.projectDir, config.targetWorkflow);
|
|
29
|
+
if (!fs.existsSync(targetPath) || !fs.statSync(targetPath).isFile()) {
|
|
30
|
+
throw new Error(`Target workflow not found: ${targetPath}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const cycleId = GenesisStore.newCycleId();
|
|
34
|
+
console.log(`\x1b[36m→ Genesis config loaded, cycle ${cycleId}\x1b[0m`);
|
|
35
|
+
|
|
36
|
+
const ctx: GenesisContext = {
|
|
37
|
+
env,
|
|
38
|
+
genesisConfigJson: JSON.stringify(config),
|
|
39
|
+
cycleId,
|
|
40
|
+
startTimeMs: Date.now(),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
return { ctx: JSON.stringify(ctx) };
|
|
44
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import * as crypto from 'node:crypto';
|
|
4
|
+
import { execFileSync } from 'node:child_process';
|
|
5
|
+
import type { GenesisFingerprint, GenesisContext } from '../bot/types.js';
|
|
6
|
+
import { getWorkflowDescription } from '../bot/genesis-prompt-context.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Fingerprints the project state: hashes .ts files, reads package.json,
|
|
10
|
+
* captures git branch/commit, scans for workflow files, and hashes the
|
|
11
|
+
* target workflow content.
|
|
12
|
+
*
|
|
13
|
+
* @flowWeaver nodeType
|
|
14
|
+
* @label Genesis Observe
|
|
15
|
+
* @input ctx [order:0] - Genesis context (JSON)
|
|
16
|
+
* @output ctx [order:0] - Genesis context with fingerprintJson (JSON)
|
|
17
|
+
* @output onSuccess [order:-2] - On Success
|
|
18
|
+
* @output onFailure [order:-1] [hidden] - On Failure
|
|
19
|
+
*/
|
|
20
|
+
export async function genesisObserve(
|
|
21
|
+
execute: boolean,
|
|
22
|
+
ctx: string,
|
|
23
|
+
): Promise<{
|
|
24
|
+
onSuccess: boolean; onFailure: boolean;
|
|
25
|
+
ctx: string;
|
|
26
|
+
}> {
|
|
27
|
+
const context = JSON.parse(ctx) as GenesisContext;
|
|
28
|
+
const { env } = context;
|
|
29
|
+
const config = JSON.parse(context.genesisConfigJson);
|
|
30
|
+
|
|
31
|
+
if (!execute) {
|
|
32
|
+
const empty: GenesisFingerprint = {
|
|
33
|
+
timestamp: new Date().toISOString(),
|
|
34
|
+
files: {},
|
|
35
|
+
packageJson: null,
|
|
36
|
+
gitBranch: null,
|
|
37
|
+
gitCommit: null,
|
|
38
|
+
workflowHash: '',
|
|
39
|
+
existingWorkflows: [],
|
|
40
|
+
};
|
|
41
|
+
context.fingerprintJson = JSON.stringify(empty);
|
|
42
|
+
return { onSuccess: true, onFailure: false, ctx: JSON.stringify(context) };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const projectDir = env.projectDir;
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
const files: Record<string, string> = {};
|
|
49
|
+
const dirsToScan = [projectDir];
|
|
50
|
+
const srcDir = path.join(projectDir, 'src');
|
|
51
|
+
if (fs.existsSync(srcDir) && fs.statSync(srcDir).isDirectory()) dirsToScan.push(srcDir);
|
|
52
|
+
|
|
53
|
+
for (const dir of dirsToScan) {
|
|
54
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
55
|
+
for (const entry of entries) {
|
|
56
|
+
if (entry.isFile() && entry.name.endsWith('.ts')) {
|
|
57
|
+
const filePath = path.join(dir, entry.name);
|
|
58
|
+
const relPath = path.relative(projectDir, filePath);
|
|
59
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
60
|
+
files[relPath] = crypto.createHash('sha256').update(content).digest('hex');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let packageJson: Record<string, unknown> | null = null;
|
|
66
|
+
const pkgPath = path.join(projectDir, 'package.json');
|
|
67
|
+
if (fs.existsSync(pkgPath)) {
|
|
68
|
+
packageJson = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let gitBranch: string | null = null;
|
|
72
|
+
let gitCommit: string | null = null;
|
|
73
|
+
try {
|
|
74
|
+
gitBranch = execFileSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {
|
|
75
|
+
cwd: projectDir, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'],
|
|
76
|
+
}).trim();
|
|
77
|
+
gitCommit = execFileSync('git', ['rev-parse', 'HEAD'], {
|
|
78
|
+
cwd: projectDir, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'],
|
|
79
|
+
}).trim();
|
|
80
|
+
} catch {
|
|
81
|
+
// Not a git repo or git unavailable
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const existingWorkflows: string[] = [];
|
|
85
|
+
for (const [relPath, _hash] of Object.entries(files)) {
|
|
86
|
+
const filePath = path.join(projectDir, relPath);
|
|
87
|
+
const content = fs.readFileSync(filePath, 'utf-8');
|
|
88
|
+
if (content.includes('@flowWeaver workflow')) {
|
|
89
|
+
existingWorkflows.push(relPath);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const targetPath = path.resolve(projectDir, config.targetWorkflow);
|
|
94
|
+
const targetContent = fs.readFileSync(targetPath, 'utf-8');
|
|
95
|
+
const workflowHash = crypto.createHash('sha256').update(targetContent).digest('hex');
|
|
96
|
+
|
|
97
|
+
const fingerprint: GenesisFingerprint = {
|
|
98
|
+
timestamp: new Date().toISOString(),
|
|
99
|
+
files,
|
|
100
|
+
packageJson,
|
|
101
|
+
gitBranch,
|
|
102
|
+
gitCommit,
|
|
103
|
+
workflowHash,
|
|
104
|
+
existingWorkflows,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
console.log(`\x1b[36m→ Fingerprint: ${Object.keys(files).length} files, ${existingWorkflows.length} workflows\x1b[0m`);
|
|
108
|
+
|
|
109
|
+
context.fingerprintJson = JSON.stringify(fingerprint);
|
|
110
|
+
context.workflowDescription = await getWorkflowDescription(targetPath);
|
|
111
|
+
|
|
112
|
+
return { onSuccess: true, onFailure: false, ctx: JSON.stringify(context) };
|
|
113
|
+
} catch (err: unknown) {
|
|
114
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
115
|
+
console.error(`\x1b[31m→ Observe failed: ${msg}\x1b[0m`);
|
|
116
|
+
context.fingerprintJson = '{}';
|
|
117
|
+
return { onSuccess: false, onFailure: true, ctx: JSON.stringify(context) };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import type { GenesisConfig, GenesisProposal, GenesisContext } from '../bot/types.js';
|
|
3
|
+
import { callAI, parseJsonResponse } from '../bot/ai-client.js';
|
|
4
|
+
import { getGenesisSystemPrompt, getOperationExamples } from '../bot/genesis-prompt-context.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Sends project context and diff information to the AI provider, which
|
|
8
|
+
* returns a structured proposal of workflow operations to apply.
|
|
9
|
+
*
|
|
10
|
+
* @flowWeaver nodeType
|
|
11
|
+
* @label Genesis Propose
|
|
12
|
+
* @input ctx [order:0] - Genesis context (JSON)
|
|
13
|
+
* @output ctx [order:0] - Genesis context with proposalJson (JSON)
|
|
14
|
+
* @output onSuccess [order:-2] - On Success
|
|
15
|
+
* @output onFailure [order:-1] [hidden] - On Failure
|
|
16
|
+
*/
|
|
17
|
+
export async function genesisPropose(
|
|
18
|
+
execute: boolean,
|
|
19
|
+
ctx: string,
|
|
20
|
+
): Promise<{
|
|
21
|
+
onSuccess: boolean; onFailure: boolean;
|
|
22
|
+
ctx: string;
|
|
23
|
+
}> {
|
|
24
|
+
const context = JSON.parse(ctx) as GenesisContext;
|
|
25
|
+
const { env } = context;
|
|
26
|
+
|
|
27
|
+
if (!execute) {
|
|
28
|
+
const empty: GenesisProposal = { operations: [], totalCost: 0, impactLevel: 'COSMETIC', summary: 'dry run', rationale: '' };
|
|
29
|
+
context.proposalJson = JSON.stringify(empty);
|
|
30
|
+
return { onSuccess: true, onFailure: false, ctx: JSON.stringify(context) };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const { providerInfo: pInfo } = env;
|
|
34
|
+
const config = JSON.parse(context.genesisConfigJson) as GenesisConfig;
|
|
35
|
+
const diff = JSON.parse(context.diffJson!);
|
|
36
|
+
const targetPath = path.resolve(env.projectDir, config.targetWorkflow);
|
|
37
|
+
|
|
38
|
+
const systemPrompt = await getGenesisSystemPrompt(config, !!context.stabilized, {
|
|
39
|
+
selfEvolveLocked: !!context.escrowGraceLocked,
|
|
40
|
+
graceRemaining: context.escrowGraceRemaining ?? 0,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const userPrompt = [
|
|
44
|
+
'## Current Workflow Structure',
|
|
45
|
+
context.workflowDescription || '(no description available)',
|
|
46
|
+
'',
|
|
47
|
+
'## Project Diff Since Last Cycle',
|
|
48
|
+
JSON.stringify(diff, null, 2),
|
|
49
|
+
'',
|
|
50
|
+
'## Current Fingerprint',
|
|
51
|
+
context.fingerprintJson!,
|
|
52
|
+
'',
|
|
53
|
+
getOperationExamples(targetPath),
|
|
54
|
+
'',
|
|
55
|
+
'Propose workflow evolution operations within the budget. Use node IDs and port names that exist in the workflow structure above.',
|
|
56
|
+
].join('\n');
|
|
57
|
+
|
|
58
|
+
const maxAttempts = 2;
|
|
59
|
+
let lastError = '';
|
|
60
|
+
|
|
61
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
62
|
+
try {
|
|
63
|
+
const text = await callAI(pInfo, systemPrompt, userPrompt, 8192);
|
|
64
|
+
|
|
65
|
+
const proposal = parseJsonResponse(text) as unknown as GenesisProposal;
|
|
66
|
+
console.log(`\x1b[36m→ Proposal: ${proposal.summary} (${proposal.operations.length} ops, impact=${proposal.impactLevel})\x1b[0m`);
|
|
67
|
+
|
|
68
|
+
context.proposalJson = JSON.stringify(proposal);
|
|
69
|
+
return { onSuccess: true, onFailure: false, ctx: JSON.stringify(context) };
|
|
70
|
+
} catch (err: unknown) {
|
|
71
|
+
lastError = err instanceof Error ? err.message : String(err);
|
|
72
|
+
const isTransient = /ETIMEDOUT|ECONNRESET|ECONNREFUSED|EPIPE|socket hang up/i.test(lastError);
|
|
73
|
+
|
|
74
|
+
if (isTransient && attempt < maxAttempts) {
|
|
75
|
+
console.log(`\x1b[33m→ Proposal attempt ${attempt} failed (transient): ${lastError.slice(0, 100)}. Retrying...\x1b[0m`);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
console.error(`\x1b[31m→ Proposal failed: ${lastError}\x1b[0m`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
context.error = `Proposal failed: ${lastError}`;
|
|
84
|
+
context.proposalJson = JSON.stringify({ operations: [], totalCost: 0, impactLevel: 'COSMETIC', summary: `Failed: ${lastError}`, rationale: '' });
|
|
85
|
+
return { onSuccess: false, onFailure: true, ctx: JSON.stringify(context) };
|
|
86
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { GenesisCycleRecord, GenesisContext } from '../bot/types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Formats a genesis cycle summary for console output. Receives context
|
|
5
|
+
* from either the success path or the fail path. Fires from any
|
|
6
|
+
* incoming path.
|
|
7
|
+
*
|
|
8
|
+
* @flowWeaver nodeType
|
|
9
|
+
* @expression
|
|
10
|
+
* @label Genesis Report
|
|
11
|
+
* @executeWhen DISJUNCTION
|
|
12
|
+
* @input [successCtx] [order:0] - Genesis context from success path (JSON)
|
|
13
|
+
* @input [failCtx] [order:1] - Genesis context from apply-retry fail path (JSON)
|
|
14
|
+
* @input [proposeFailCtx] [order:2] - Genesis context from propose failure (JSON)
|
|
15
|
+
* @input [commitFailCtx] [order:3] - Genesis context from commit failure (JSON)
|
|
16
|
+
* @output summary [order:1] - Formatted summary text
|
|
17
|
+
* @output onFailure [hidden]
|
|
18
|
+
*/
|
|
19
|
+
export function genesisReport(successCtx?: string, failCtx?: string, proposeFailCtx?: string, commitFailCtx?: string): { summary: string } {
|
|
20
|
+
const ctx = successCtx ?? failCtx ?? proposeFailCtx ?? commitFailCtx;
|
|
21
|
+
if (!ctx) {
|
|
22
|
+
const summary = 'Genesis cycle completed with no record';
|
|
23
|
+
console.log(`\n\x1b[33m${summary}\x1b[0m\n`);
|
|
24
|
+
return { summary };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const context = JSON.parse(ctx) as GenesisContext;
|
|
28
|
+
const elapsed = formatElapsed(context.startTimeMs);
|
|
29
|
+
|
|
30
|
+
if (context.error) {
|
|
31
|
+
const reason = categorizeFailure(context);
|
|
32
|
+
let summary = `Genesis: ${reason}`;
|
|
33
|
+
if (context.applyResultJson) {
|
|
34
|
+
try {
|
|
35
|
+
const result = JSON.parse(context.applyResultJson) as { applied: number; failed: number };
|
|
36
|
+
summary += ` (applied: ${result.applied}, failed: ${result.failed})`;
|
|
37
|
+
} catch { /* ignore */ }
|
|
38
|
+
}
|
|
39
|
+
summary += elapsed ? ` [${elapsed}]` : '';
|
|
40
|
+
console.log(`\n\x1b[31m${summary}\x1b[0m\n`);
|
|
41
|
+
return { summary };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!context.cycleRecordJson) {
|
|
45
|
+
const summary = `Genesis: no changes proposed${elapsed ? ` [${elapsed}]` : ''}`;
|
|
46
|
+
console.log(`\n\x1b[33m${summary}\x1b[0m\n`);
|
|
47
|
+
return { summary };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const record = JSON.parse(context.cycleRecordJson) as GenesisCycleRecord;
|
|
51
|
+
|
|
52
|
+
const parts: string[] = [`Cycle ${record.id}`];
|
|
53
|
+
|
|
54
|
+
if (record.proposal) {
|
|
55
|
+
parts.push(`${record.proposal.operations.length} ops`);
|
|
56
|
+
parts.push(`impact=${record.proposal.impactLevel}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
parts.push(record.outcome);
|
|
60
|
+
|
|
61
|
+
if (record.approved !== null) {
|
|
62
|
+
parts.push(record.approved ? 'approved' : 'rejected');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (elapsed) parts.push(elapsed);
|
|
66
|
+
|
|
67
|
+
if (record.error) {
|
|
68
|
+
parts.push(record.error);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const summary = `Genesis: ${parts.join(' | ')}`;
|
|
72
|
+
const color = record.outcome === 'applied' ? '\x1b[32m' : record.outcome === 'error' ? '\x1b[31m' : '\x1b[33m';
|
|
73
|
+
|
|
74
|
+
console.log(`\n\x1b[1m${color}${summary}\x1b[0m\n`);
|
|
75
|
+
|
|
76
|
+
return { summary };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function formatElapsed(startTimeMs?: number): string {
|
|
80
|
+
if (!startTimeMs) return '';
|
|
81
|
+
const seconds = (Date.now() - startTimeMs) / 1000;
|
|
82
|
+
if (seconds < 60) return `${seconds.toFixed(1)}s`;
|
|
83
|
+
const minutes = Math.floor(seconds / 60);
|
|
84
|
+
const remaining = seconds % 60;
|
|
85
|
+
return `${minutes}m${remaining.toFixed(0)}s`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function categorizeFailure(context: GenesisContext): string {
|
|
89
|
+
const err = context.error ?? '';
|
|
90
|
+
if (err.startsWith('Proposal failed')) return 'proposal failed';
|
|
91
|
+
if (err.includes('not approved') || err.includes('rejected')) return 'proposal rejected';
|
|
92
|
+
if (err.startsWith('Commit failed')) return 'commit failed';
|
|
93
|
+
if (err.includes('Apply') || err.includes('compile')) return 'apply/compile failed';
|
|
94
|
+
return err.slice(0, 120);
|
|
95
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import type { GenesisConfig, GenesisContext } from '../bot/types.js';
|
|
4
|
+
import { GenesisStore } from '../bot/genesis-store.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Saves a snapshot of the target workflow file before any modifications
|
|
8
|
+
* are applied, enabling rollback if something goes wrong.
|
|
9
|
+
*
|
|
10
|
+
* @flowWeaver nodeType
|
|
11
|
+
* @expression
|
|
12
|
+
* @label Genesis Snapshot
|
|
13
|
+
* @input ctx [order:0] - Genesis context (JSON)
|
|
14
|
+
* @output ctx [order:0] - Genesis context with snapshotPath (JSON)
|
|
15
|
+
* @output onFailure [hidden]
|
|
16
|
+
*/
|
|
17
|
+
export function genesisSnapshot(ctx: string): { ctx: string } {
|
|
18
|
+
const context = JSON.parse(ctx) as GenesisContext;
|
|
19
|
+
const config = JSON.parse(context.genesisConfigJson) as GenesisConfig;
|
|
20
|
+
const targetPath = path.resolve(context.env.projectDir, config.targetWorkflow);
|
|
21
|
+
const content = fs.readFileSync(targetPath, 'utf-8');
|
|
22
|
+
|
|
23
|
+
const store = new GenesisStore(context.env.projectDir);
|
|
24
|
+
const snapshotPath = store.saveSnapshot(context.cycleId, content);
|
|
25
|
+
|
|
26
|
+
console.log(`\x1b[36m→ Snapshot saved: ${snapshotPath}\x1b[0m`);
|
|
27
|
+
|
|
28
|
+
context.snapshotPath = snapshotPath;
|
|
29
|
+
return { ctx: JSON.stringify(context) };
|
|
30
|
+
}
|