@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,165 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import { execFileSync } from 'node:child_process';
|
|
4
|
+
import type { GenesisConfig, GenesisProposal, GenesisOperation, GenesisContext } from '../bot/types.js';
|
|
5
|
+
import { GenesisStore } from '../bot/genesis-store.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Applies proposal operations then validates + compiles. On compile
|
|
9
|
+
* failure, restores the snapshot and returns the failure path with
|
|
10
|
+
* error details so the parent scope can retry with a revised proposal.
|
|
11
|
+
*
|
|
12
|
+
* @flowWeaver nodeType
|
|
13
|
+
* @label Genesis Try Apply
|
|
14
|
+
* @input ctx [order:0] - Genesis context (JSON)
|
|
15
|
+
* @output ctx [order:0] - Genesis context with apply results (JSON)
|
|
16
|
+
* @output onSuccess [order:-2] - On Success
|
|
17
|
+
* @output onFailure [order:-1] [hidden] - On Failure
|
|
18
|
+
*/
|
|
19
|
+
export async function genesisTryApply(
|
|
20
|
+
execute: boolean,
|
|
21
|
+
ctx: string,
|
|
22
|
+
): Promise<{
|
|
23
|
+
onSuccess: boolean; onFailure: boolean;
|
|
24
|
+
ctx: string;
|
|
25
|
+
}> {
|
|
26
|
+
const context = JSON.parse(ctx) as GenesisContext;
|
|
27
|
+
|
|
28
|
+
if (!execute) {
|
|
29
|
+
const result = { applied: 0, failed: 0, errors: [] };
|
|
30
|
+
context.applyResultJson = JSON.stringify(result);
|
|
31
|
+
context.error = '';
|
|
32
|
+
return { onSuccess: true, onFailure: false, ctx: JSON.stringify(context) };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const { env } = context;
|
|
36
|
+
const config = JSON.parse(context.genesisConfigJson) as GenesisConfig;
|
|
37
|
+
const proposal = JSON.parse(context.proposalJson!) as GenesisProposal;
|
|
38
|
+
const targetPath = path.resolve(env.projectDir, config.targetWorkflow);
|
|
39
|
+
|
|
40
|
+
// Apply operations
|
|
41
|
+
let applied = 0;
|
|
42
|
+
let failed = 0;
|
|
43
|
+
const errors: string[] = [];
|
|
44
|
+
|
|
45
|
+
for (const op of proposal.operations) {
|
|
46
|
+
const validationError = validateOperationArgs(op);
|
|
47
|
+
if (validationError) {
|
|
48
|
+
failed++;
|
|
49
|
+
errors.push(validationError);
|
|
50
|
+
console.error(`\x1b[31m x ${op.type} (pre-validation): ${validationError}\x1b[0m`);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
try {
|
|
55
|
+
const cliArgs = buildModifyArgs(op, targetPath);
|
|
56
|
+
execFileSync('flow-weaver', cliArgs, {
|
|
57
|
+
cwd: env.projectDir,
|
|
58
|
+
encoding: 'utf-8',
|
|
59
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
60
|
+
timeout: 30_000,
|
|
61
|
+
});
|
|
62
|
+
applied++;
|
|
63
|
+
console.log(`\x1b[32m + ${op.type}: ${op.rationale}\x1b[0m`);
|
|
64
|
+
} catch (err: unknown) {
|
|
65
|
+
failed++;
|
|
66
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
67
|
+
errors.push(`${op.type}: ${msg}`);
|
|
68
|
+
console.error(`\x1b[31m x ${op.type}: ${msg}\x1b[0m`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const applyResult = { applied, failed, errors };
|
|
73
|
+
context.applyResultJson = JSON.stringify(applyResult);
|
|
74
|
+
|
|
75
|
+
console.log(`\x1b[36m→ Apply: ${applied} succeeded, ${failed} failed\x1b[0m`);
|
|
76
|
+
|
|
77
|
+
// If all operations failed, no point compiling
|
|
78
|
+
if (applied === 0) {
|
|
79
|
+
context.error = '';
|
|
80
|
+
return { onSuccess: false, onFailure: true, ctx: JSON.stringify(context) };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Validate + compile
|
|
84
|
+
try {
|
|
85
|
+
execFileSync('flow-weaver', ['validate', targetPath], {
|
|
86
|
+
cwd: env.projectDir,
|
|
87
|
+
encoding: 'utf-8',
|
|
88
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
89
|
+
timeout: 30_000,
|
|
90
|
+
});
|
|
91
|
+
console.log('\x1b[32m→ Validation passed\x1b[0m');
|
|
92
|
+
|
|
93
|
+
execFileSync('flow-weaver', ['compile', targetPath], {
|
|
94
|
+
cwd: env.projectDir,
|
|
95
|
+
encoding: 'utf-8',
|
|
96
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
97
|
+
timeout: 60_000,
|
|
98
|
+
});
|
|
99
|
+
console.log('\x1b[32m→ Compilation passed\x1b[0m');
|
|
100
|
+
|
|
101
|
+
context.error = '';
|
|
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
|
+
console.error(`\x1b[31m→ Compile/validate failed: ${msg}\x1b[0m`);
|
|
106
|
+
|
|
107
|
+
// Restore from snapshot
|
|
108
|
+
const store = new GenesisStore(env.projectDir);
|
|
109
|
+
const snapshot = store.loadSnapshot(context.snapshotPath!);
|
|
110
|
+
if (snapshot) {
|
|
111
|
+
fs.writeFileSync(targetPath, snapshot, 'utf-8');
|
|
112
|
+
console.log('\x1b[33m→ Restored from snapshot\x1b[0m');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
context.error = msg;
|
|
116
|
+
return { onSuccess: false, onFailure: true, ctx: JSON.stringify(context) };
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function validateOperationArgs(op: GenesisOperation): string | null {
|
|
121
|
+
const { type, args } = op;
|
|
122
|
+
|
|
123
|
+
if (type === 'addConnection' || type === 'removeConnection') {
|
|
124
|
+
const from = args.from as string | undefined;
|
|
125
|
+
const to = args.to as string | undefined;
|
|
126
|
+
if (!from || !to) return `${type}: missing 'from' or 'to' arg`;
|
|
127
|
+
if (!from.includes('.') || from.includes(':'))
|
|
128
|
+
return `${type}: 'from' must be "node.port" format (dot separator), got "${from}"`;
|
|
129
|
+
if (!to.includes('.') || to.includes(':'))
|
|
130
|
+
return `${type}: 'to' must be "node.port" format (dot separator), got "${to}"`;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (type === 'addNode') {
|
|
134
|
+
if (!args.nodeId || !args.nodeType)
|
|
135
|
+
return `addNode: missing 'nodeId' or 'nodeType'`;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (type === 'removeNode') {
|
|
139
|
+
if (!args.nodeId) return `removeNode: missing 'nodeId'`;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (type === 'implementNode') {
|
|
143
|
+
if (!args.nodeId || args.nodeId === 'undefined')
|
|
144
|
+
return `implementNode: missing or invalid 'nodeId'`;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function buildModifyArgs(op: GenesisOperation, targetPath: string): string[] {
|
|
151
|
+
switch (op.type) {
|
|
152
|
+
case 'addNode':
|
|
153
|
+
return ['modify', 'addNode', '--file', targetPath, '--nodeId', String(op.args.nodeId), '--nodeType', String(op.args.nodeType)];
|
|
154
|
+
case 'removeNode':
|
|
155
|
+
return ['modify', 'removeNode', '--file', targetPath, '--nodeId', String(op.args.nodeId)];
|
|
156
|
+
case 'addConnection':
|
|
157
|
+
return ['modify', 'addConnection', '--file', targetPath, '--from', String(op.args.from), '--to', String(op.args.to)];
|
|
158
|
+
case 'removeConnection':
|
|
159
|
+
return ['modify', 'removeConnection', '--file', targetPath, '--from', String(op.args.from), '--to', String(op.args.to)];
|
|
160
|
+
case 'implementNode':
|
|
161
|
+
return ['implement', targetPath, '--nodeId', String(op.args.nodeId)];
|
|
162
|
+
default:
|
|
163
|
+
throw new Error(`Unknown genesis operation type: ${op.type}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { GenesisFingerprint, GenesisProposal, GenesisCycleRecord, GenesisContext } from '../bot/types.js';
|
|
2
|
+
import { GenesisStore } from '../bot/genesis-store.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Builds a cycle record from all available data, determines the outcome,
|
|
6
|
+
* appends it to the genesis history, and saves the current fingerprint.
|
|
7
|
+
*
|
|
8
|
+
* @flowWeaver nodeType
|
|
9
|
+
* @expression
|
|
10
|
+
* @label Genesis Update History
|
|
11
|
+
* @input ctx [order:0] - Genesis context (JSON)
|
|
12
|
+
* @output ctx [order:0] - Genesis context with cycleRecordJson (JSON)
|
|
13
|
+
* @output onFailure [hidden]
|
|
14
|
+
*/
|
|
15
|
+
export function genesisUpdateHistory(ctx: string): { ctx: string } {
|
|
16
|
+
const context = JSON.parse(ctx) as GenesisContext;
|
|
17
|
+
const { env } = context;
|
|
18
|
+
|
|
19
|
+
const fingerprint = context.fingerprintJson
|
|
20
|
+
? JSON.parse(context.fingerprintJson) as GenesisFingerprint
|
|
21
|
+
: null;
|
|
22
|
+
const proposal = context.proposalJson ? JSON.parse(context.proposalJson) as GenesisProposal : null;
|
|
23
|
+
const applyResult = context.applyResultJson ? JSON.parse(context.applyResultJson) as { applied: number; failed: number; errors: string[] } : null;
|
|
24
|
+
|
|
25
|
+
const durationMs = context.startTimeMs ? Date.now() - context.startTimeMs : 0;
|
|
26
|
+
|
|
27
|
+
// Determine outcome
|
|
28
|
+
let outcome: GenesisCycleRecord['outcome'];
|
|
29
|
+
if (context.error) {
|
|
30
|
+
outcome = 'error';
|
|
31
|
+
} else if (!proposal || proposal.operations.length === 0) {
|
|
32
|
+
outcome = 'no-change';
|
|
33
|
+
} else if (context.approved === false) {
|
|
34
|
+
outcome = 'rejected';
|
|
35
|
+
} else if (applyResult && applyResult.failed > 0) {
|
|
36
|
+
outcome = 'rolled-back';
|
|
37
|
+
} else if (context.approved === true && applyResult && applyResult.failed === 0) {
|
|
38
|
+
outcome = 'applied';
|
|
39
|
+
} else {
|
|
40
|
+
outcome = 'error';
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const record: GenesisCycleRecord = {
|
|
44
|
+
id: context.cycleId,
|
|
45
|
+
timestamp: new Date().toISOString(),
|
|
46
|
+
durationMs,
|
|
47
|
+
fingerprint: fingerprint!,
|
|
48
|
+
proposal,
|
|
49
|
+
outcome,
|
|
50
|
+
diffSummary: proposal?.summary ?? null,
|
|
51
|
+
approvalRequired: context.approved !== undefined,
|
|
52
|
+
approved: context.approved ?? null,
|
|
53
|
+
error: context.error ?? (applyResult?.errors?.length ? applyResult.errors.join('; ') : null),
|
|
54
|
+
snapshotFile: context.snapshotPath ?? null,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
const store = new GenesisStore(env.projectDir);
|
|
59
|
+
store.appendCycle(record);
|
|
60
|
+
if (fingerprint) {
|
|
61
|
+
store.saveFingerprint(fingerprint);
|
|
62
|
+
}
|
|
63
|
+
} catch (err: unknown) {
|
|
64
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
65
|
+
console.error(`\x1b[31m→ Failed to save history: ${msg}\x1b[0m`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
console.log(`\x1b[36m→ Cycle ${context.cycleId}: ${outcome} (${durationMs}ms)\x1b[0m`);
|
|
69
|
+
|
|
70
|
+
context.cycleRecordJson = JSON.stringify(record);
|
|
71
|
+
return { ctx: JSON.stringify(context) };
|
|
72
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import type { GenesisConfig, GenesisProposal, GenesisOperation, GenesisContext } from '../bot/types.js';
|
|
3
|
+
import { checkDesignQuality } from '../bot/design-checker.js';
|
|
4
|
+
|
|
5
|
+
const COST_MAP: Record<string, number> = {
|
|
6
|
+
addNode: 1,
|
|
7
|
+
removeNode: 1,
|
|
8
|
+
addConnection: 1,
|
|
9
|
+
removeConnection: 1,
|
|
10
|
+
implementNode: 2,
|
|
11
|
+
selfModifyWorkflow: 3,
|
|
12
|
+
selfModifyNodeType: 2,
|
|
13
|
+
selfModifyModule: 2,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const SELF_MODIFY_TYPES = new Set(['selfModifyWorkflow', 'selfModifyNodeType', 'selfModifyModule']);
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Validates and trims a genesis proposal to fit within the budget.
|
|
20
|
+
* Recalculates costs (never trusts the AI), filters out disallowed
|
|
21
|
+
* operations in stabilize mode, and trims from the end if over budget.
|
|
22
|
+
*
|
|
23
|
+
* @flowWeaver nodeType
|
|
24
|
+
* @expression
|
|
25
|
+
* @label Genesis Validate Proposal
|
|
26
|
+
* @input ctx [order:0] - Genesis context (JSON)
|
|
27
|
+
* @output ctx [order:0] - Genesis context with validated proposalJson (JSON)
|
|
28
|
+
* @output onFailure [hidden]
|
|
29
|
+
*/
|
|
30
|
+
export function genesisValidateProposal(ctx: string): { ctx: string } {
|
|
31
|
+
const context = JSON.parse(ctx) as GenesisContext;
|
|
32
|
+
const config = JSON.parse(context.genesisConfigJson) as GenesisConfig;
|
|
33
|
+
const proposal = JSON.parse(context.proposalJson!) as GenesisProposal;
|
|
34
|
+
|
|
35
|
+
let ops = proposal.operations;
|
|
36
|
+
|
|
37
|
+
// In stabilize mode, hard-reject addNode and addConnection
|
|
38
|
+
if (context.stabilized) {
|
|
39
|
+
const before = ops.length;
|
|
40
|
+
ops = ops.filter(op => op.type !== 'addNode' && op.type !== 'addConnection');
|
|
41
|
+
if (ops.length < before) {
|
|
42
|
+
console.log(`\x1b[33m→ Stabilize: filtered ${before - ops.length} disallowed operations\x1b[0m`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Filter self-modify ops if selfEvolve is disabled
|
|
47
|
+
if (!config.selfEvolve) {
|
|
48
|
+
const before = ops.length;
|
|
49
|
+
ops = ops.filter(op => !SELF_MODIFY_TYPES.has(op.type));
|
|
50
|
+
if (ops.length < before) {
|
|
51
|
+
console.log(`\x1b[33m→ Self-evolve disabled: filtered ${before - ops.length} self-modify operations\x1b[0m`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Validate self-modify ops have required args
|
|
56
|
+
ops = ops.filter(op => {
|
|
57
|
+
if (SELF_MODIFY_TYPES.has(op.type)) {
|
|
58
|
+
if (!op.args.file || !op.args.content) {
|
|
59
|
+
console.log(`\x1b[33m→ Filtered ${op.type}: missing file or content\x1b[0m`);
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Recalculate costs (never trust the AI values)
|
|
67
|
+
for (const op of ops) {
|
|
68
|
+
op.costUnits = COST_MAP[op.type] ?? 1;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Split into regular and self-modify ops for separate budget enforcement
|
|
72
|
+
const regularOps = ops.filter(op => !SELF_MODIFY_TYPES.has(op.type));
|
|
73
|
+
let selfOps = ops.filter(op => SELF_MODIFY_TYPES.has(op.type));
|
|
74
|
+
|
|
75
|
+
// Trim regular ops to regular budget
|
|
76
|
+
let regularCost = regularOps.reduce((sum, op) => sum + op.costUnits, 0);
|
|
77
|
+
while (regularCost > config.budgetPerCycle && regularOps.length > 0) {
|
|
78
|
+
regularOps.pop();
|
|
79
|
+
regularCost = regularOps.reduce((sum, op) => sum + op.costUnits, 0);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Trim self-modify ops to self-evolve budget
|
|
83
|
+
const selfBudget = config.selfEvolveBudget ?? 2;
|
|
84
|
+
let selfCost = selfOps.reduce((sum, op) => sum + op.costUnits, 0);
|
|
85
|
+
while (selfCost > selfBudget && selfOps.length > 0) {
|
|
86
|
+
selfOps.pop();
|
|
87
|
+
selfCost = selfOps.reduce((sum, op) => sum + op.costUnits, 0);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
ops = [...regularOps, ...selfOps];
|
|
91
|
+
let totalCost = regularCost + selfCost;
|
|
92
|
+
|
|
93
|
+
const validated: GenesisProposal = {
|
|
94
|
+
...proposal,
|
|
95
|
+
operations: ops,
|
|
96
|
+
totalCost,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
console.log(`\x1b[36m→ Validated proposal: ${ops.length} ops, cost=${totalCost}/${config.budgetPerCycle}\x1b[0m`);
|
|
100
|
+
|
|
101
|
+
// Design quality gate: parse current workflow and check design score.
|
|
102
|
+
// If the score is below the threshold, flag for review.
|
|
103
|
+
const designThreshold = 50;
|
|
104
|
+
try {
|
|
105
|
+
const targetPath = config.targetWorkflow;
|
|
106
|
+
if (targetPath) {
|
|
107
|
+
const { projectDir } = context.env;
|
|
108
|
+
const astJson = execFileSync('flow-weaver', ['parse', targetPath, '--format', 'json'], {
|
|
109
|
+
cwd: projectDir, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'], timeout: 30_000,
|
|
110
|
+
});
|
|
111
|
+
const ast = JSON.parse(astJson);
|
|
112
|
+
const report = checkDesignQuality(ast);
|
|
113
|
+
if (report.score < designThreshold) {
|
|
114
|
+
console.log(`\x1b[33m→ Design score ${report.score} below threshold ${designThreshold}\x1b[0m`);
|
|
115
|
+
context.approvalRequired = true;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
} catch {
|
|
119
|
+
// Non-fatal: if we can't parse the workflow yet, skip the design check
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
context.proposalJson = JSON.stringify(validated);
|
|
123
|
+
return { ctx: JSON.stringify(context) };
|
|
124
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import type { WeaverContext } from '../bot/types.js';
|
|
3
|
+
import { auditEmit } from '../bot/audit-logger.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Git operations on created/modified files: stage, commit, branch.
|
|
7
|
+
* Runs in parallel with notifications after execution.
|
|
8
|
+
*
|
|
9
|
+
* @flowWeaver nodeType
|
|
10
|
+
* @expression
|
|
11
|
+
* @label Git Operations
|
|
12
|
+
* @input ctx [order:0] - Weaver context (JSON)
|
|
13
|
+
* @output ctx [order:0] - Weaver context with gitResultJson (JSON)
|
|
14
|
+
* @output onFailure [hidden]
|
|
15
|
+
*/
|
|
16
|
+
export function weaverGitOps(ctx: string): { ctx: string } {
|
|
17
|
+
const context = JSON.parse(ctx) as WeaverContext;
|
|
18
|
+
const { projectDir, config } = context.env;
|
|
19
|
+
const files: string[] = context.filesModified ? JSON.parse(context.filesModified) : [];
|
|
20
|
+
const gitConfig = (config as unknown as { git?: { enabled?: boolean; branch?: string; commitPrefix?: string } }).git ?? {};
|
|
21
|
+
|
|
22
|
+
if (gitConfig.enabled === false || files.length === 0) {
|
|
23
|
+
context.gitResultJson = JSON.stringify({ skipped: true, reason: files.length === 0 ? 'no files' : 'git disabled' });
|
|
24
|
+
return { ctx: JSON.stringify(context) };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Check if we're in a git repo
|
|
28
|
+
try {
|
|
29
|
+
execFileSync('git', ['rev-parse', '--is-inside-work-tree'], { cwd: projectDir, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] });
|
|
30
|
+
} catch {
|
|
31
|
+
context.gitResultJson = JSON.stringify({ skipped: true, reason: 'not a git repo' });
|
|
32
|
+
return { ctx: JSON.stringify(context) };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const results: string[] = [];
|
|
36
|
+
|
|
37
|
+
// Create branch if specified
|
|
38
|
+
if (gitConfig.branch) {
|
|
39
|
+
try {
|
|
40
|
+
execFileSync('git', ['checkout', '-b', gitConfig.branch], { cwd: projectDir, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] });
|
|
41
|
+
results.push(`Created branch: ${gitConfig.branch}`);
|
|
42
|
+
} catch {
|
|
43
|
+
// Branch may already exist
|
|
44
|
+
try {
|
|
45
|
+
execFileSync('git', ['checkout', gitConfig.branch], { cwd: projectDir, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] });
|
|
46
|
+
results.push(`Switched to branch: ${gitConfig.branch}`);
|
|
47
|
+
} catch { /* ignore */ }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Stage files
|
|
52
|
+
for (const file of files) {
|
|
53
|
+
try {
|
|
54
|
+
execFileSync('git', ['add', file], { cwd: projectDir, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] });
|
|
55
|
+
} catch { /* ignore unstaged files */ }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Commit
|
|
59
|
+
const prefix = gitConfig.commitPrefix ?? 'weaver:';
|
|
60
|
+
const commitMsg = `${prefix} bot task (${files.length} file${files.length === 1 ? '' : 's'})`;
|
|
61
|
+
try {
|
|
62
|
+
execFileSync('git', ['commit', '-m', commitMsg], { cwd: projectDir, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] });
|
|
63
|
+
results.push(`Committed: ${commitMsg}`);
|
|
64
|
+
console.log(`\x1b[36m→ Git: ${commitMsg}\x1b[0m`);
|
|
65
|
+
} catch {
|
|
66
|
+
results.push('Nothing to commit');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
auditEmit('git-operation', { branch: gitConfig.branch, filesCount: files.length, results });
|
|
70
|
+
context.gitResultJson = JSON.stringify({ skipped: false, results });
|
|
71
|
+
return { ctx: JSON.stringify(context) };
|
|
72
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export { weaverLoadConfig } from './load-config.js';
|
|
2
|
+
export { weaverDetectProvider } from './detect-provider.js';
|
|
3
|
+
export { weaverResolveTarget } from './resolve-target.js';
|
|
4
|
+
export { weaverExecuteTarget } from './execute-target.js';
|
|
5
|
+
export { weaverSendNotify } from './send-notify.js';
|
|
6
|
+
export { weaverReport } from './report.js';
|
|
7
|
+
export { weaverReceiveTask } from './receive-task.js';
|
|
8
|
+
export { weaverRouteTask } from './route-task.js';
|
|
9
|
+
export { weaverReadWorkflow } from './read-workflow.js';
|
|
10
|
+
export { weaverBuildContext } from './build-context.js';
|
|
11
|
+
export { weaverPlanTask } from './plan-task.js';
|
|
12
|
+
export { weaverApprovalGate } from './approval-gate.js';
|
|
13
|
+
export { weaverAbortTask } from './abort-task.js';
|
|
14
|
+
export { weaverExecValidateRetry } from './exec-validate-retry.js';
|
|
15
|
+
export { weaverExecutePlan } from './execute-plan.js';
|
|
16
|
+
export { weaverValidateResult } from './validate-result.js';
|
|
17
|
+
export { weaverFixErrors } from './fix-errors.js';
|
|
18
|
+
export { weaverGitOps } from './git-ops.js';
|
|
19
|
+
export { weaverBotReport } from './bot-report.js';
|
|
20
|
+
export { genesisLoadConfig } from './genesis-load-config.js';
|
|
21
|
+
export { genesisObserve } from './genesis-observe.js';
|
|
22
|
+
export { genesisDiffFingerprint } from './genesis-diff-fingerprint.js';
|
|
23
|
+
export { genesisCheckStabilize } from './genesis-check-stabilize.js';
|
|
24
|
+
export { genesisPropose } from './genesis-propose.js';
|
|
25
|
+
export { genesisValidateProposal } from './genesis-validate-proposal.js';
|
|
26
|
+
export { genesisSnapshot } from './genesis-snapshot.js';
|
|
27
|
+
export { genesisApply } from './genesis-apply.js';
|
|
28
|
+
export { genesisCompileValidate } from './genesis-compile-validate.js';
|
|
29
|
+
export { genesisApplyRetry } from './genesis-apply-retry.js';
|
|
30
|
+
export { genesisTryApply } from './genesis-try-apply.js';
|
|
31
|
+
export { genesisDiffWorkflow } from './genesis-diff-workflow.js';
|
|
32
|
+
export { genesisCheckThreshold } from './genesis-check-threshold.js';
|
|
33
|
+
export { genesisApprove } from './genesis-approve.js';
|
|
34
|
+
export { genesisCommit } from './genesis-commit.js';
|
|
35
|
+
export { genesisUpdateHistory } from './genesis-update-history.js';
|
|
36
|
+
export { genesisReport } from './genesis-report.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
import * as path from 'node:path';
|
|
3
|
+
import type { WeaverConfig } from '../bot/types.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Read .weaver.json, merge with defaults, and output the config object.
|
|
7
|
+
*
|
|
8
|
+
* @flowWeaver nodeType
|
|
9
|
+
* @expression
|
|
10
|
+
* @label Load Config
|
|
11
|
+
* @input [projectDir] [order:0] - Project root directory (defaults to cwd)
|
|
12
|
+
* @output projectDir [order:0] - Project root directory (pass-through)
|
|
13
|
+
* @output config [order:1] - Weaver configuration
|
|
14
|
+
* @output onFailure [hidden]
|
|
15
|
+
*/
|
|
16
|
+
export function weaverLoadConfig(projectDir?: string): { projectDir: string; config: WeaverConfig } {
|
|
17
|
+
const dir = projectDir || process.cwd();
|
|
18
|
+
const configPath = path.join(dir, '.weaver.json');
|
|
19
|
+
let config: WeaverConfig = { provider: 'auto' };
|
|
20
|
+
if (fs.existsSync(configPath)) {
|
|
21
|
+
config = { ...config, ...JSON.parse(fs.readFileSync(configPath, 'utf-8')) };
|
|
22
|
+
console.log(`\x1b[36m→ Loaded config from ${configPath}\x1b[0m`);
|
|
23
|
+
} else {
|
|
24
|
+
console.log('\x1b[36m→ No .weaver.json found, using defaults (provider: auto)\x1b[0m');
|
|
25
|
+
}
|
|
26
|
+
return { projectDir: dir, config };
|
|
27
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { WeaverContext } from '../bot/types.js';
|
|
2
|
+
import { callAI, parseJsonResponse } from '../bot/ai-client.js';
|
|
3
|
+
import { auditEmit } from '../bot/audit-logger.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Sends task + context to the AI provider and gets back a structured
|
|
7
|
+
* execution plan. The core AI planning node.
|
|
8
|
+
*
|
|
9
|
+
* @flowWeaver nodeType
|
|
10
|
+
* @label Plan Task
|
|
11
|
+
* @input ctx [order:0] - Weaver context (JSON)
|
|
12
|
+
* @output ctx [order:0] - Weaver context with planJson (JSON)
|
|
13
|
+
* @output onSuccess [order:-2] - On Success
|
|
14
|
+
* @output onFailure [order:-1] [hidden] - On Failure
|
|
15
|
+
*/
|
|
16
|
+
export async function weaverPlanTask(
|
|
17
|
+
execute: boolean,
|
|
18
|
+
ctx: string,
|
|
19
|
+
): Promise<{
|
|
20
|
+
onSuccess: boolean; onFailure: boolean;
|
|
21
|
+
ctx: string;
|
|
22
|
+
}> {
|
|
23
|
+
const context = JSON.parse(ctx) as WeaverContext;
|
|
24
|
+
const { env } = context;
|
|
25
|
+
|
|
26
|
+
if (!execute) {
|
|
27
|
+
context.planJson = '{"steps":[],"summary":"dry run"}';
|
|
28
|
+
return { onSuccess: true, onFailure: false, ctx: JSON.stringify(context) };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const { providerInfo: pInfo } = env;
|
|
32
|
+
const task = JSON.parse(context.taskJson!);
|
|
33
|
+
|
|
34
|
+
let systemPrompt: string;
|
|
35
|
+
try {
|
|
36
|
+
const mod = await import('../bot/system-prompt.js');
|
|
37
|
+
const basePrompt = await mod.buildSystemPrompt();
|
|
38
|
+
let cliCommands: { name: string; description: string; group?: string; botCompatible?: boolean; options?: { flags: string; arg?: string; description: string }[] }[] = [];
|
|
39
|
+
try {
|
|
40
|
+
const docMeta = await import('@synergenius/flow-weaver/doc-metadata');
|
|
41
|
+
cliCommands = docMeta.CLI_COMMANDS ?? [];
|
|
42
|
+
} catch { /* older flow-weaver version */ }
|
|
43
|
+
const botPrompt = mod.buildBotSystemPrompt(context.contextBundle!, cliCommands);
|
|
44
|
+
systemPrompt = basePrompt + '\n\n' + botPrompt;
|
|
45
|
+
} catch {
|
|
46
|
+
systemPrompt = 'You are Weaver, an AI workflow bot. Return ONLY valid JSON with a plan.';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const userPrompt = `Task: ${task.instruction}\nMode: ${task.mode ?? 'create'}\n${task.targets ? 'Targets: ' + task.targets.join(', ') : ''}\n\nPlan this task. Return a JSON plan with steps and summary.`;
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const text = await callAI(pInfo, systemPrompt, userPrompt, 8192);
|
|
53
|
+
|
|
54
|
+
const plan = parseJsonResponse(text);
|
|
55
|
+
console.log(`\x1b[36m→ Plan: ${(plan as { summary?: string }).summary ?? 'generated'}\x1b[0m`);
|
|
56
|
+
auditEmit('plan-created', { summary: (plan as { summary?: string }).summary, stepCount: (plan as { steps?: unknown[] }).steps?.length ?? 0 });
|
|
57
|
+
|
|
58
|
+
context.planJson = JSON.stringify(plan);
|
|
59
|
+
return { onSuccess: true, onFailure: false, ctx: JSON.stringify(context) };
|
|
60
|
+
} catch (err: unknown) {
|
|
61
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
62
|
+
console.error(`\x1b[31m→ Planning failed: ${msg}\x1b[0m`);
|
|
63
|
+
context.planJson = JSON.stringify({ steps: [], summary: `Planning failed: ${msg}` });
|
|
64
|
+
return { onSuccess: false, onFailure: true, ctx: JSON.stringify(context) };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import * as fs from 'node:fs';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import type { WeaverContext } from '../bot/types.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reads and analyzes a workflow file. Produces structured description
|
|
8
|
+
* with diagram using flow-weaver CLI commands.
|
|
9
|
+
*
|
|
10
|
+
* @flowWeaver nodeType
|
|
11
|
+
* @expression
|
|
12
|
+
* @label Read Workflow
|
|
13
|
+
* @input ctx [order:0] - Weaver context (JSON)
|
|
14
|
+
* @output ctx [order:0] - Weaver context with resultJson (JSON)
|
|
15
|
+
* @output onFailure [hidden]
|
|
16
|
+
*/
|
|
17
|
+
export function weaverReadWorkflow(ctx: string): { ctx: string } {
|
|
18
|
+
const context = JSON.parse(ctx) as WeaverContext;
|
|
19
|
+
const task = JSON.parse(context.taskJson!) as { targets?: string[]; instruction?: string };
|
|
20
|
+
const targets = task.targets ?? [];
|
|
21
|
+
const { projectDir } = context.env;
|
|
22
|
+
|
|
23
|
+
if (targets.length === 0) {
|
|
24
|
+
context.resultJson = JSON.stringify({ success: false, error: 'No target files specified for read' });
|
|
25
|
+
context.filesModified = '[]';
|
|
26
|
+
return { ctx: JSON.stringify(context) };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const results: Array<{ file: string; source?: string; diagram?: string; description?: string; error?: string }> = [];
|
|
30
|
+
|
|
31
|
+
for (const target of targets) {
|
|
32
|
+
const filePath = path.isAbsolute(target) ? target : path.resolve(projectDir, target);
|
|
33
|
+
|
|
34
|
+
if (!fs.existsSync(filePath)) {
|
|
35
|
+
results.push({ file: target, error: `File not found: ${filePath}` });
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const source = fs.readFileSync(filePath, 'utf-8');
|
|
40
|
+
let diagram = '';
|
|
41
|
+
let description = '';
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
diagram = execFileSync('flow-weaver', ['diagram', filePath, '-f', 'ascii-compact'], {
|
|
45
|
+
encoding: 'utf-8',
|
|
46
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
47
|
+
timeout: 30_000,
|
|
48
|
+
cwd: projectDir,
|
|
49
|
+
}).trim();
|
|
50
|
+
} catch { /* diagram generation failed, continue without it */ }
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
description = execFileSync('flow-weaver', ['describe', filePath], {
|
|
54
|
+
encoding: 'utf-8',
|
|
55
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
56
|
+
timeout: 30_000,
|
|
57
|
+
cwd: projectDir,
|
|
58
|
+
}).trim();
|
|
59
|
+
} catch { /* description failed, continue without it */ }
|
|
60
|
+
|
|
61
|
+
results.push({ file: target, source, diagram, description });
|
|
62
|
+
console.log(`\x1b[36m→ Read: ${target}\x1b[0m`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
context.resultJson = JSON.stringify({ success: true, results });
|
|
66
|
+
context.filesModified = '[]';
|
|
67
|
+
return { ctx: JSON.stringify(context) };
|
|
68
|
+
}
|