agentplane 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/assets/AGENTS.md +281 -70
- package/assets/agents/CODER.json +1 -0
- package/assets/agents/INTEGRATOR.json +1 -0
- package/assets/agents/ORCHESTRATOR.json +1 -0
- package/assets/agents/PLANNER.json +1 -0
- package/assets/agents/TESTER.json +1 -0
- package/dist/backends/task-backend/load.d.ts +13 -0
- package/dist/backends/task-backend/load.d.ts.map +1 -0
- package/dist/backends/task-backend/load.js +58 -0
- package/dist/backends/task-backend/local-backend.d.ts +28 -0
- package/dist/backends/task-backend/local-backend.d.ts.map +1 -0
- package/dist/backends/task-backend/local-backend.js +335 -0
- package/dist/backends/task-backend/redmine/client.d.ts +8 -0
- package/dist/backends/task-backend/redmine/client.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/client.js +60 -0
- package/dist/backends/task-backend/redmine/comments.d.ts +12 -0
- package/dist/backends/task-backend/redmine/comments.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/comments.js +54 -0
- package/dist/backends/task-backend/redmine/fields.d.ts +9 -0
- package/dist/backends/task-backend/redmine/fields.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/fields.js +38 -0
- package/dist/backends/task-backend/redmine/mapping.d.ts +20 -0
- package/dist/backends/task-backend/redmine/mapping.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/mapping.js +114 -0
- package/dist/backends/task-backend/redmine/parse.d.ts +3 -0
- package/dist/backends/task-backend/redmine/parse.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/parse.js +27 -0
- package/dist/backends/task-backend/redmine/remote.d.ts +19 -0
- package/dist/backends/task-backend/redmine/remote.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine/remote.js +82 -0
- package/dist/backends/task-backend/redmine-backend.d.ts +80 -0
- package/dist/backends/task-backend/redmine-backend.d.ts.map +1 -0
- package/dist/backends/task-backend/redmine-backend.js +505 -0
- package/dist/backends/task-backend/shared/concurrency.d.ts +3 -0
- package/dist/backends/task-backend/shared/concurrency.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/concurrency.js +21 -0
- package/dist/backends/task-backend/shared/constants.d.ts +4 -0
- package/dist/backends/task-backend/shared/constants.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/constants.js +4 -0
- package/dist/backends/task-backend/shared/doc.d.ts +11 -0
- package/dist/backends/task-backend/shared/doc.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/doc.js +78 -0
- package/dist/backends/task-backend/shared/errors.d.ts +10 -0
- package/dist/backends/task-backend/shared/errors.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/errors.js +18 -0
- package/dist/backends/task-backend/shared/events.d.ts +3 -0
- package/dist/backends/task-backend/shared/events.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/events.js +29 -0
- package/dist/backends/task-backend/shared/export.d.ts +15 -0
- package/dist/backends/task-backend/shared/export.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/export.js +60 -0
- package/dist/backends/task-backend/shared/id.d.ts +13 -0
- package/dist/backends/task-backend/shared/id.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/id.js +17 -0
- package/dist/backends/task-backend/shared/normalize.d.ts +8 -0
- package/dist/backends/task-backend/shared/normalize.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/normalize.js +54 -0
- package/dist/backends/task-backend/shared/record.d.ts +4 -0
- package/dist/backends/task-backend/shared/record.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/record.js +53 -0
- package/dist/backends/task-backend/shared/strings.d.ts +4 -0
- package/dist/backends/task-backend/shared/strings.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/strings.js +21 -0
- package/dist/backends/task-backend/shared/types.d.ts +84 -0
- package/dist/backends/task-backend/shared/types.d.ts.map +1 -0
- package/dist/backends/task-backend/shared/types.js +1 -0
- package/dist/backends/task-backend/shared.d.ts +11 -0
- package/dist/backends/task-backend/shared.d.ts.map +1 -0
- package/dist/backends/task-backend/shared.js +9 -0
- package/dist/backends/task-backend.d.ts +4 -204
- package/dist/backends/task-backend.d.ts.map +1 -1
- package/dist/backends/task-backend.js +4 -1366
- package/dist/backends/task-index.js +2 -2
- package/dist/cli/archive.d.ts +0 -2
- package/dist/cli/archive.d.ts.map +1 -1
- package/dist/cli/archive.js +1 -2
- package/dist/cli/command-guide.d.ts.map +1 -1
- package/dist/cli/command-guide.js +25 -8
- package/dist/cli/parse/lifecycle.d.ts +64 -0
- package/dist/cli/parse/lifecycle.d.ts.map +1 -0
- package/dist/cli/parse/lifecycle.js +280 -0
- package/dist/cli/run-cli/command-catalog.d.ts +16 -0
- package/dist/cli/run-cli/command-catalog.d.ts.map +1 -0
- package/dist/cli/run-cli/command-catalog.js +204 -0
- package/dist/cli/run-cli/commands/config.d.ts +20 -0
- package/dist/cli/run-cli/commands/config.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/config.js +130 -0
- package/dist/cli/run-cli/commands/core.d.ts +14 -0
- package/dist/cli/run-cli/commands/core.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/core.js +144 -0
- package/dist/cli/run-cli/commands/ide.d.ts +13 -0
- package/dist/cli/run-cli/commands/ide.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/ide.js +67 -0
- package/dist/cli/run-cli/commands/init/base-branch.d.ts +9 -0
- package/dist/cli/run-cli/commands/init/base-branch.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/base-branch.js +11 -0
- package/dist/cli/run-cli/commands/init/conflicts.d.ts +11 -0
- package/dist/cli/run-cli/commands/init/conflicts.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/conflicts.js +42 -0
- package/dist/cli/run-cli/commands/init/git.d.ts +8 -0
- package/dist/cli/run-cli/commands/init/git.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/git.js +12 -0
- package/dist/cli/run-cli/commands/init/ide-sync.d.ts +9 -0
- package/dist/cli/run-cli/commands/init/ide-sync.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/ide-sync.js +18 -0
- package/dist/cli/run-cli/commands/init/recipes.d.ts +2 -0
- package/dist/cli/run-cli/commands/init/recipes.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/recipes.js +11 -0
- package/dist/cli/run-cli/commands/init/write-agents.d.ts +11 -0
- package/dist/cli/run-cli/commands/init/write-agents.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/write-agents.js +30 -0
- package/dist/cli/run-cli/commands/init/write-config.d.ts +15 -0
- package/dist/cli/run-cli/commands/init/write-config.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init/write-config.js +45 -0
- package/dist/cli/run-cli/commands/init.d.ts +21 -0
- package/dist/cli/run-cli/commands/init.d.ts.map +1 -0
- package/dist/cli/run-cli/commands/init.js +332 -0
- package/dist/cli/run-cli/registry.run.d.ts +4 -0
- package/dist/cli/run-cli/registry.run.d.ts.map +1 -0
- package/dist/cli/run-cli/registry.run.js +19 -0
- package/dist/cli/run-cli.d.ts.map +1 -1
- package/dist/cli/run-cli.js +182 -2463
- package/dist/cli/spec/docs-render.d.ts +3 -0
- package/dist/cli/spec/docs-render.d.ts.map +1 -0
- package/dist/cli/spec/docs-render.js +118 -0
- package/dist/cli/spec/errors.d.ts +9 -0
- package/dist/cli/spec/errors.d.ts.map +1 -0
- package/dist/cli/spec/errors.js +18 -0
- package/dist/cli/spec/help-render.d.ts +43 -0
- package/dist/cli/spec/help-render.d.ts.map +1 -0
- package/dist/cli/spec/help-render.js +185 -0
- package/dist/cli/spec/help.d.ts +10 -0
- package/dist/cli/spec/help.d.ts.map +1 -0
- package/dist/cli/spec/help.js +64 -0
- package/dist/cli/spec/parse.d.ts +8 -0
- package/dist/cli/spec/parse.d.ts.map +1 -0
- package/dist/cli/spec/parse.js +188 -0
- package/dist/cli/spec/registry.d.ts +12 -0
- package/dist/cli/spec/registry.d.ts.map +1 -0
- package/dist/cli/spec/registry.js +47 -0
- package/dist/cli/spec/spec.d.ts +76 -0
- package/dist/cli/spec/spec.d.ts.map +1 -0
- package/dist/cli/spec/spec.js +1 -0
- package/dist/cli/spec/suggest.d.ts +2 -0
- package/dist/cli/spec/suggest.d.ts.map +1 -0
- package/dist/cli/spec/suggest.js +45 -0
- package/dist/commands/backend/sync.command.d.ts +12 -0
- package/dist/commands/backend/sync.command.d.ts.map +1 -0
- package/dist/commands/backend/sync.command.js +79 -0
- package/dist/commands/backend.d.ts +21 -8
- package/dist/commands/backend.d.ts.map +1 -1
- package/dist/commands/backend.js +28 -165
- package/dist/commands/block.command.d.ts +19 -0
- package/dist/commands/block.command.d.ts.map +1 -0
- package/dist/commands/block.command.js +143 -0
- package/dist/commands/branch/base.command.d.ts +20 -0
- package/dist/commands/branch/base.command.d.ts.map +1 -0
- package/dist/commands/branch/base.command.js +110 -0
- package/dist/commands/branch/base.d.ts +19 -0
- package/dist/commands/branch/base.d.ts.map +1 -0
- package/dist/commands/branch/base.js +114 -0
- package/dist/commands/branch/cleanup-merged.d.ts +11 -0
- package/dist/commands/branch/cleanup-merged.d.ts.map +1 -0
- package/dist/commands/branch/cleanup-merged.js +141 -0
- package/dist/commands/branch/index.d.ts +6 -59
- package/dist/commands/branch/index.d.ts.map +1 -1
- package/dist/commands/branch/index.js +6 -513
- package/dist/commands/branch/internal/archive-pr.d.ts +2 -0
- package/dist/commands/branch/internal/archive-pr.d.ts.map +1 -0
- package/dist/commands/branch/internal/archive-pr.js +17 -0
- package/dist/commands/branch/internal/work-validate.d.ts +3 -0
- package/dist/commands/branch/internal/work-validate.d.ts.map +1 -0
- package/dist/commands/branch/internal/work-validate.js +27 -0
- package/dist/commands/branch/remove.command.d.ts +10 -0
- package/dist/commands/branch/remove.command.d.ts.map +1 -0
- package/dist/commands/branch/remove.command.js +63 -0
- package/dist/commands/branch/remove.d.ts +9 -0
- package/dist/commands/branch/remove.d.ts.map +1 -0
- package/dist/commands/branch/remove.js +65 -0
- package/dist/commands/branch/status.command.d.ts +8 -0
- package/dist/commands/branch/status.command.d.ts.map +1 -0
- package/dist/commands/branch/status.command.js +36 -0
- package/dist/commands/branch/status.d.ts +7 -0
- package/dist/commands/branch/status.d.ts.map +1 -0
- package/dist/commands/branch/status.js +60 -0
- package/dist/commands/branch/work-start.command.d.ts +11 -0
- package/dist/commands/branch/work-start.command.d.ts.map +1 -0
- package/dist/commands/branch/work-start.command.js +80 -0
- package/dist/commands/branch/work-start.d.ts +11 -0
- package/dist/commands/branch/work-start.d.ts.map +1 -0
- package/dist/commands/branch/work-start.js +120 -0
- package/dist/commands/cleanup/merged.command.d.ts +17 -0
- package/dist/commands/cleanup/merged.command.d.ts.map +1 -0
- package/dist/commands/cleanup/merged.command.js +75 -0
- package/dist/commands/commit.command.d.ts +6 -0
- package/dist/commands/commit.command.d.ts.map +1 -0
- package/dist/commands/commit.command.js +24 -0
- package/dist/commands/commit.spec.d.ts +18 -0
- package/dist/commands/commit.spec.d.ts.map +1 -0
- package/dist/commands/commit.spec.js +119 -0
- package/dist/commands/docs/cli.command.d.ts +9 -0
- package/dist/commands/docs/cli.command.d.ts.map +1 -0
- package/dist/commands/docs/cli.command.js +51 -0
- package/dist/commands/finish.command.d.ts +28 -0
- package/dist/commands/finish.command.d.ts.map +1 -0
- package/dist/commands/finish.command.js +237 -0
- package/dist/commands/guard/clean.command.d.ts +7 -0
- package/dist/commands/guard/clean.command.d.ts.map +1 -0
- package/dist/commands/guard/clean.command.js +14 -0
- package/dist/commands/guard/commit.command.d.ts +19 -0
- package/dist/commands/guard/commit.command.d.ts.map +1 -0
- package/dist/commands/guard/commit.command.js +132 -0
- package/dist/commands/guard/guard.command.d.ts +5 -0
- package/dist/commands/guard/guard.command.d.ts.map +1 -0
- package/dist/commands/guard/guard.command.js +21 -0
- package/dist/commands/guard/impl/allow.d.ts +18 -0
- package/dist/commands/guard/impl/allow.d.ts.map +1 -0
- package/dist/commands/guard/impl/allow.js +77 -0
- package/dist/commands/guard/impl/close-message.d.ts +16 -0
- package/dist/commands/guard/impl/close-message.d.ts.map +1 -0
- package/dist/commands/guard/impl/close-message.js +156 -0
- package/dist/commands/guard/impl/commands.d.ts +32 -0
- package/dist/commands/guard/impl/commands.d.ts.map +1 -0
- package/dist/commands/guard/impl/commands.js +191 -0
- package/dist/commands/guard/impl/comment-commit.d.ts +25 -0
- package/dist/commands/guard/impl/comment-commit.d.ts.map +1 -0
- package/dist/commands/guard/impl/comment-commit.js +137 -0
- package/dist/commands/guard/impl/env.d.ts +10 -0
- package/dist/commands/guard/impl/env.d.ts.map +1 -0
- package/dist/commands/guard/impl/env.js +12 -0
- package/dist/commands/guard/impl/policy.d.ts +19 -0
- package/dist/commands/guard/impl/policy.d.ts.map +1 -0
- package/dist/commands/guard/impl/policy.js +46 -0
- package/dist/commands/guard/index.d.ts +4 -87
- package/dist/commands/guard/index.d.ts.map +1 -1
- package/dist/commands/guard/index.js +4 -481
- package/dist/commands/guard/suggest-allow.command.d.ts +7 -0
- package/dist/commands/guard/suggest-allow.command.d.ts.map +1 -0
- package/dist/commands/guard/suggest-allow.command.js +28 -0
- package/dist/commands/hooks/hooks.command.d.ts +5 -0
- package/dist/commands/hooks/hooks.command.d.ts.map +1 -0
- package/dist/commands/hooks/hooks.command.js +18 -0
- package/dist/commands/hooks/index.d.ts.map +1 -1
- package/dist/commands/hooks/index.js +36 -81
- package/dist/commands/hooks/install.command.d.ts +7 -0
- package/dist/commands/hooks/install.command.d.ts.map +1 -0
- package/dist/commands/hooks/install.command.js +14 -0
- package/dist/commands/hooks/run.command.d.ts +9 -0
- package/dist/commands/hooks/run.command.d.ts.map +1 -0
- package/dist/commands/hooks/run.command.js +39 -0
- package/dist/commands/hooks/uninstall.command.d.ts +7 -0
- package/dist/commands/hooks/uninstall.command.d.ts.map +1 -0
- package/dist/commands/hooks/uninstall.command.js +16 -0
- package/dist/commands/integrate.command.d.ts +14 -0
- package/dist/commands/integrate.command.d.ts.map +1 -0
- package/dist/commands/integrate.command.js +61 -0
- package/dist/commands/pr/check.d.ts +8 -0
- package/dist/commands/pr/check.d.ts.map +1 -0
- package/dist/commands/pr/check.js +78 -0
- package/dist/commands/pr/index.d.ts +5 -45
- package/dist/commands/pr/index.d.ts.map +1 -1
- package/dist/commands/pr/index.js +5 -857
- package/dist/commands/pr/integrate/artifacts.d.ts +14 -0
- package/dist/commands/pr/integrate/artifacts.d.ts.map +1 -0
- package/dist/commands/pr/integrate/artifacts.js +45 -0
- package/dist/commands/pr/integrate/cmd.d.ts +14 -0
- package/dist/commands/pr/integrate/cmd.d.ts.map +1 -0
- package/dist/commands/pr/integrate/cmd.js +150 -0
- package/dist/commands/pr/integrate/internal/finalize.d.ts +25 -0
- package/dist/commands/pr/integrate/internal/finalize.d.ts.map +1 -0
- package/dist/commands/pr/integrate/internal/finalize.js +86 -0
- package/dist/commands/pr/integrate/internal/merge.d.ts +40 -0
- package/dist/commands/pr/integrate/internal/merge.d.ts.map +1 -0
- package/dist/commands/pr/integrate/internal/merge.js +138 -0
- package/dist/commands/pr/integrate/internal/prepare.d.ts +33 -0
- package/dist/commands/pr/integrate/internal/prepare.d.ts.map +1 -0
- package/dist/commands/pr/integrate/internal/prepare.js +142 -0
- package/dist/commands/pr/integrate/internal/worktree.d.ts +14 -0
- package/dist/commands/pr/integrate/internal/worktree.d.ts.map +1 -0
- package/dist/commands/pr/integrate/internal/worktree.js +51 -0
- package/dist/commands/pr/integrate/verify.d.ts +22 -0
- package/dist/commands/pr/integrate/verify.d.ts.map +1 -0
- package/dist/commands/pr/integrate/verify.js +60 -0
- package/dist/commands/pr/integrate.d.ts +2 -0
- package/dist/commands/pr/integrate.d.ts.map +1 -0
- package/dist/commands/pr/integrate.js +1 -0
- package/dist/commands/pr/internal/pr-paths.d.ts +29 -0
- package/dist/commands/pr/internal/pr-paths.d.ts.map +1 -0
- package/dist/commands/pr/internal/pr-paths.js +38 -0
- package/dist/commands/pr/internal/review-template.d.ts +9 -0
- package/dist/commands/pr/internal/review-template.d.ts.map +1 -0
- package/dist/commands/pr/internal/review-template.js +62 -0
- package/dist/commands/pr/note.d.ts +10 -0
- package/dist/commands/pr/note.d.ts.map +1 -0
- package/dist/commands/pr/note.js +50 -0
- package/dist/commands/pr/open.d.ts +10 -0
- package/dist/commands/pr/open.d.ts.map +1 -0
- package/dist/commands/pr/open.js +80 -0
- package/dist/commands/pr/pr.command.d.ts +33 -0
- package/dist/commands/pr/pr.command.d.ts.map +1 -0
- package/dist/commands/pr/pr.command.js +172 -0
- package/dist/commands/pr/update.d.ts +8 -0
- package/dist/commands/pr/update.d.ts.map +1 -0
- package/dist/commands/pr/update.js +103 -0
- package/dist/commands/ready.command.d.ts +8 -0
- package/dist/commands/ready.command.d.ts.map +1 -0
- package/dist/commands/ready.command.js +28 -0
- package/dist/commands/recipes/cache-prune.command.d.ts +6 -0
- package/dist/commands/recipes/cache-prune.command.d.ts.map +1 -0
- package/dist/commands/recipes/cache-prune.command.js +30 -0
- package/dist/commands/recipes/cache.command.d.ts +6 -0
- package/dist/commands/recipes/cache.command.d.ts.map +1 -0
- package/dist/commands/recipes/cache.command.js +37 -0
- package/dist/commands/recipes/explain.command.d.ts +7 -0
- package/dist/commands/recipes/explain.command.d.ts.map +1 -0
- package/dist/commands/recipes/explain.command.js +10 -0
- package/dist/commands/recipes/impl/apply.d.ts +16 -0
- package/dist/commands/recipes/impl/apply.d.ts.map +1 -0
- package/dist/commands/recipes/impl/apply.js +97 -0
- package/dist/commands/recipes/impl/archive.d.ts +2 -0
- package/dist/commands/recipes/impl/archive.d.ts.map +1 -0
- package/dist/commands/recipes/impl/archive.js +19 -0
- package/dist/commands/recipes/impl/commands/cache-prune.d.ts +7 -0
- package/dist/commands/recipes/impl/commands/cache-prune.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/cache-prune.js +94 -0
- package/dist/commands/recipes/impl/commands/explain.d.ts +6 -0
- package/dist/commands/recipes/impl/commands/explain.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/explain.js +88 -0
- package/dist/commands/recipes/impl/commands/info.d.ts +6 -0
- package/dist/commands/recipes/impl/commands/info.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/info.js +58 -0
- package/dist/commands/recipes/impl/commands/install.d.ts +11 -0
- package/dist/commands/recipes/impl/commands/install.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/install.js +212 -0
- package/dist/commands/recipes/impl/commands/list-remote.d.ts +7 -0
- package/dist/commands/recipes/impl/commands/list-remote.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/list-remote.js +53 -0
- package/dist/commands/recipes/impl/commands/list.d.ts +7 -0
- package/dist/commands/recipes/impl/commands/list.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/list.js +38 -0
- package/dist/commands/recipes/impl/commands/remove.d.ts +6 -0
- package/dist/commands/recipes/impl/commands/remove.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands/remove.js +35 -0
- package/dist/commands/recipes/impl/commands.d.ts +8 -0
- package/dist/commands/recipes/impl/commands.d.ts.map +1 -0
- package/dist/commands/recipes/impl/commands.js +7 -0
- package/dist/commands/recipes/impl/constants.d.ts +13 -0
- package/dist/commands/recipes/impl/constants.d.ts.map +1 -0
- package/dist/commands/recipes/impl/constants.js +16 -0
- package/dist/commands/recipes/impl/format.d.ts +2 -0
- package/dist/commands/recipes/impl/format.d.ts.map +1 -0
- package/dist/commands/recipes/impl/format.js +9 -0
- package/dist/commands/recipes/impl/index.d.ts +12 -0
- package/dist/commands/recipes/impl/index.d.ts.map +1 -0
- package/dist/commands/recipes/impl/index.js +150 -0
- package/dist/commands/recipes/impl/installed-recipes.d.ts +4 -0
- package/dist/commands/recipes/impl/installed-recipes.d.ts.map +1 -0
- package/dist/commands/recipes/impl/installed-recipes.js +58 -0
- package/dist/commands/recipes/impl/manifest.d.ts +4 -0
- package/dist/commands/recipes/impl/manifest.d.ts.map +1 -0
- package/dist/commands/recipes/impl/manifest.js +43 -0
- package/dist/commands/recipes/impl/normalize.d.ts +5 -0
- package/dist/commands/recipes/impl/normalize.d.ts.map +1 -0
- package/dist/commands/recipes/impl/normalize.js +50 -0
- package/dist/commands/recipes/impl/paths.d.ts +13 -0
- package/dist/commands/recipes/impl/paths.d.ts.map +1 -0
- package/dist/commands/recipes/impl/paths.js +27 -0
- package/dist/commands/recipes/impl/project.d.ts +8 -0
- package/dist/commands/recipes/impl/project.d.ts.map +1 -0
- package/dist/commands/recipes/impl/project.js +23 -0
- package/dist/commands/recipes/impl/scenario.d.ts +16 -0
- package/dist/commands/recipes/impl/scenario.d.ts.map +1 -0
- package/dist/commands/recipes/impl/scenario.js +128 -0
- package/dist/commands/recipes/impl/types.d.ts +107 -0
- package/dist/commands/recipes/impl/types.d.ts.map +1 -0
- package/dist/commands/recipes/impl/types.js +1 -0
- package/dist/commands/recipes/info.command.d.ts +7 -0
- package/dist/commands/recipes/info.command.d.ts.map +1 -0
- package/dist/commands/recipes/info.command.js +10 -0
- package/dist/commands/recipes/install.command.d.ts +12 -0
- package/dist/commands/recipes/install.command.d.ts.map +1 -0
- package/dist/commands/recipes/install.command.js +161 -0
- package/dist/commands/recipes/list-remote.command.d.ts +6 -0
- package/dist/commands/recipes/list-remote.command.d.ts.map +1 -0
- package/dist/commands/recipes/list-remote.command.js +46 -0
- package/dist/commands/recipes/list.command.d.ts +6 -0
- package/dist/commands/recipes/list.command.d.ts.map +1 -0
- package/dist/commands/recipes/list.command.js +39 -0
- package/dist/commands/recipes/recipes.command.d.ts +6 -0
- package/dist/commands/recipes/recipes.command.d.ts.map +1 -0
- package/dist/commands/recipes/recipes.command.js +45 -0
- package/dist/commands/recipes/remove.command.d.ts +7 -0
- package/dist/commands/recipes/remove.command.d.ts.map +1 -0
- package/dist/commands/recipes/remove.command.js +10 -0
- package/dist/commands/recipes.d.ts +7 -81
- package/dist/commands/recipes.d.ts.map +1 -1
- package/dist/commands/recipes.js +6 -1457
- package/dist/commands/scenario/impl/commands.d.ts +19 -0
- package/dist/commands/scenario/impl/commands.d.ts.map +1 -0
- package/dist/commands/scenario/impl/commands.js +336 -0
- package/dist/commands/scenario/impl/report.d.ts +30 -0
- package/dist/commands/scenario/impl/report.d.ts.map +1 -0
- package/dist/commands/scenario/impl/report.js +99 -0
- package/dist/commands/scenario/info.command.d.ts +8 -0
- package/dist/commands/scenario/info.command.d.ts.map +1 -0
- package/dist/commands/scenario/info.command.js +27 -0
- package/dist/commands/scenario/list.command.d.ts +5 -0
- package/dist/commands/scenario/list.command.d.ts.map +1 -0
- package/dist/commands/scenario/list.command.js +9 -0
- package/dist/commands/scenario/run.command.d.ts +8 -0
- package/dist/commands/scenario/run.command.d.ts.map +1 -0
- package/dist/commands/scenario/run.command.js +27 -0
- package/dist/commands/scenario/scenario.command.d.ts +6 -0
- package/dist/commands/scenario/scenario.command.d.ts.map +1 -0
- package/dist/commands/scenario/scenario.command.js +37 -0
- package/dist/commands/scenario.d.ts +1 -6
- package/dist/commands/scenario.d.ts.map +1 -1
- package/dist/commands/scenario.js +1 -501
- package/dist/commands/shared/git-context.d.ts +23 -0
- package/dist/commands/shared/git-context.d.ts.map +1 -0
- package/dist/commands/shared/git-context.js +140 -0
- package/dist/commands/shared/policy-deny.d.ts +3 -0
- package/dist/commands/shared/policy-deny.d.ts.map +1 -0
- package/dist/commands/shared/policy-deny.js +12 -0
- package/dist/commands/shared/task-backend.d.ts +17 -5
- package/dist/commands/shared/task-backend.d.ts.map +1 -1
- package/dist/commands/shared/task-backend.js +34 -5
- package/dist/commands/shared/task-store.d.ts +16 -0
- package/dist/commands/shared/task-store.d.ts.map +1 -0
- package/dist/commands/shared/task-store.js +142 -0
- package/dist/commands/start.command.d.ts +19 -0
- package/dist/commands/start.command.d.ts.map +1 -0
- package/dist/commands/start.command.js +143 -0
- package/dist/commands/sync.command.d.ts +6 -0
- package/dist/commands/sync.command.d.ts.map +1 -0
- package/dist/commands/sync.command.js +57 -0
- package/dist/commands/task/add.command.d.ts +18 -0
- package/dist/commands/task/add.command.d.ts.map +1 -0
- package/dist/commands/task/add.command.js +157 -0
- package/dist/commands/task/add.d.ts +13 -3
- package/dist/commands/task/add.d.ts.map +1 -1
- package/dist/commands/task/add.js +21 -126
- package/dist/commands/task/block.d.ts +2 -2
- package/dist/commands/task/block.d.ts.map +1 -1
- package/dist/commands/task/block.js +13 -9
- package/dist/commands/task/comment.command.d.ts +10 -0
- package/dist/commands/task/comment.command.d.ts.map +1 -0
- package/dist/commands/task/comment.command.js +57 -0
- package/dist/commands/task/comment.d.ts +2 -0
- package/dist/commands/task/comment.d.ts.map +1 -1
- package/dist/commands/task/comment.js +10 -7
- package/dist/commands/task/derive.command.d.ts +13 -0
- package/dist/commands/task/derive.command.d.ts.map +1 -0
- package/dist/commands/task/derive.command.js +94 -0
- package/dist/commands/task/derive.d.ts +13 -0
- package/dist/commands/task/derive.d.ts.map +1 -0
- package/dist/commands/task/derive.js +71 -0
- package/dist/commands/task/doc-set.command.d.ts +12 -0
- package/dist/commands/task/doc-set.command.d.ts.map +1 -0
- package/dist/commands/task/doc-set.command.js +82 -0
- package/dist/commands/task/doc-show.command.d.ts +10 -0
- package/dist/commands/task/doc-show.command.d.ts.map +1 -0
- package/dist/commands/task/doc-show.command.js +54 -0
- package/dist/commands/task/doc.command.d.ts +7 -0
- package/dist/commands/task/doc.command.d.ts.map +1 -0
- package/dist/commands/task/doc.command.js +22 -0
- package/dist/commands/task/doc.d.ts +9 -6
- package/dist/commands/task/doc.d.ts.map +1 -1
- package/dist/commands/task/doc.js +61 -113
- package/dist/commands/task/export.command.d.ts +6 -0
- package/dist/commands/task/export.command.d.ts.map +1 -0
- package/dist/commands/task/export.command.js +17 -0
- package/dist/commands/task/export.d.ts +2 -0
- package/dist/commands/task/export.d.ts.map +1 -1
- package/dist/commands/task/export.js +7 -9
- package/dist/commands/task/finish.d.ts +5 -4
- package/dist/commands/task/finish.d.ts.map +1 -1
- package/dist/commands/task/finish.js +50 -17
- package/dist/commands/task/index.d.ts +14 -13
- package/dist/commands/task/index.d.ts.map +1 -1
- package/dist/commands/task/index.js +13 -13
- package/dist/commands/task/lint.command.d.ts +5 -0
- package/dist/commands/task/lint.command.d.ts.map +1 -0
- package/dist/commands/task/lint.command.js +11 -0
- package/dist/commands/task/list.command.d.ts +9 -0
- package/dist/commands/task/list.command.d.ts.map +1 -0
- package/dist/commands/task/list.command.js +68 -0
- package/dist/commands/task/list.d.ts +6 -2
- package/dist/commands/task/list.d.ts.map +1 -1
- package/dist/commands/task/list.js +12 -15
- package/dist/commands/task/migrate-doc.command.d.ts +9 -0
- package/dist/commands/task/migrate-doc.command.d.ts.map +1 -0
- package/dist/commands/task/migrate-doc.command.js +65 -0
- package/dist/commands/task/migrate-doc.d.ts +3 -3
- package/dist/commands/task/migrate-doc.d.ts.map +1 -1
- package/dist/commands/task/migrate-doc.js +40 -47
- package/dist/commands/task/migrate.command.d.ts +10 -0
- package/dist/commands/task/migrate.command.d.ts.map +1 -0
- package/dist/commands/task/migrate.command.js +50 -0
- package/dist/commands/task/migrate.d.ts +5 -1
- package/dist/commands/task/migrate.d.ts.map +1 -1
- package/dist/commands/task/migrate.js +10 -44
- package/dist/commands/task/new.command.d.ts +6 -0
- package/dist/commands/task/new.command.d.ts.map +1 -0
- package/dist/commands/task/new.command.js +13 -0
- package/dist/commands/task/new.d.ts +13 -4
- package/dist/commands/task/new.d.ts.map +1 -1
- package/dist/commands/task/new.js +30 -92
- package/dist/commands/task/new.spec.d.ts +4 -0
- package/dist/commands/task/new.spec.d.ts.map +1 -0
- package/dist/commands/task/new.spec.js +79 -0
- package/dist/commands/task/next.command.d.ts +9 -0
- package/dist/commands/task/next.command.d.ts.map +1 -0
- package/dist/commands/task/next.command.js +89 -0
- package/dist/commands/task/next.d.ts +4 -1
- package/dist/commands/task/next.d.ts.map +1 -1
- package/dist/commands/task/next.js +15 -16
- package/dist/commands/task/normalize.command.d.ts +9 -0
- package/dist/commands/task/normalize.command.d.ts.map +1 -0
- package/dist/commands/task/normalize.command.js +39 -0
- package/dist/commands/task/normalize.d.ts +4 -1
- package/dist/commands/task/normalize.d.ts.map +1 -1
- package/dist/commands/task/normalize.js +18 -31
- package/dist/commands/task/plan-approve.command.d.ts +10 -0
- package/dist/commands/task/plan-approve.command.d.ts.map +1 -0
- package/dist/commands/task/plan-approve.command.js +54 -0
- package/dist/commands/task/plan-reject.command.d.ts +10 -0
- package/dist/commands/task/plan-reject.command.d.ts.map +1 -0
- package/dist/commands/task/plan-reject.command.js +59 -0
- package/dist/commands/task/plan-set.command.d.ts +11 -0
- package/dist/commands/task/plan-set.command.d.ts.map +1 -0
- package/dist/commands/task/plan-set.command.js +76 -0
- package/dist/commands/task/plan.d.ts +23 -10
- package/dist/commands/task/plan.d.ts.map +1 -1
- package/dist/commands/task/plan.js +182 -177
- package/dist/commands/task/ready.d.ts +2 -0
- package/dist/commands/task/ready.d.ts.map +1 -1
- package/dist/commands/task/ready.js +4 -6
- package/dist/commands/task/scaffold.command.d.ts +12 -0
- package/dist/commands/task/scaffold.command.d.ts.map +1 -0
- package/dist/commands/task/scaffold.command.js +73 -0
- package/dist/commands/task/scaffold.d.ts +7 -3
- package/dist/commands/task/scaffold.d.ts.map +1 -1
- package/dist/commands/task/scaffold.js +57 -67
- package/dist/commands/task/scrub.command.d.ts +11 -0
- package/dist/commands/task/scrub.command.d.ts.map +1 -0
- package/dist/commands/task/scrub.command.js +72 -0
- package/dist/commands/task/scrub.d.ts +6 -3
- package/dist/commands/task/scrub.d.ts.map +1 -1
- package/dist/commands/task/scrub.js +12 -68
- package/dist/commands/task/search.command.d.ts +11 -0
- package/dist/commands/task/search.command.d.ts.map +1 -0
- package/dist/commands/task/search.command.js +101 -0
- package/dist/commands/task/search.d.ts +5 -1
- package/dist/commands/task/search.d.ts.map +1 -1
- package/dist/commands/task/search.js +14 -23
- package/dist/commands/task/set-status.command.d.ts +21 -0
- package/dist/commands/task/set-status.command.d.ts.map +1 -0
- package/dist/commands/task/set-status.command.js +171 -0
- package/dist/commands/task/set-status.d.ts +2 -0
- package/dist/commands/task/set-status.d.ts.map +1 -1
- package/dist/commands/task/set-status.js +14 -8
- package/dist/commands/task/shared.d.ts +5 -0
- package/dist/commands/task/shared.d.ts.map +1 -1
- package/dist/commands/task/shared.js +50 -0
- package/dist/commands/task/show.command.d.ts +8 -0
- package/dist/commands/task/show.command.d.ts.map +1 -0
- package/dist/commands/task/show.command.js +19 -0
- package/dist/commands/task/show.d.ts +2 -0
- package/dist/commands/task/show.d.ts.map +1 -1
- package/dist/commands/task/show.js +5 -7
- package/dist/commands/task/start.d.ts +2 -2
- package/dist/commands/task/start.d.ts.map +1 -1
- package/dist/commands/task/start.js +48 -11
- package/dist/commands/task/update.command.d.ts +18 -0
- package/dist/commands/task/update.command.d.ts.map +1 -0
- package/dist/commands/task/update.command.js +141 -0
- package/dist/commands/task/update.d.ts +13 -3
- package/dist/commands/task/update.d.ts.map +1 -1
- package/dist/commands/task/update.js +31 -122
- package/dist/commands/task/verify-ok.command.d.ts +13 -0
- package/dist/commands/task/verify-ok.command.d.ts.map +1 -0
- package/dist/commands/task/verify-ok.command.js +83 -0
- package/dist/commands/task/verify-record.d.ts +30 -8
- package/dist/commands/task/verify-record.d.ts.map +1 -1
- package/dist/commands/task/verify-record.js +107 -117
- package/dist/commands/task/verify-rework.command.d.ts +13 -0
- package/dist/commands/task/verify-rework.command.d.ts.map +1 -0
- package/dist/commands/task/verify-rework.command.js +83 -0
- package/dist/commands/task/verify-show.command.d.ts +9 -0
- package/dist/commands/task/verify-show.command.d.ts.map +1 -0
- package/dist/commands/task/verify-show.command.js +38 -0
- package/dist/commands/task/verify.command.d.ts +7 -0
- package/dist/commands/task/verify.command.d.ts.map +1 -0
- package/dist/commands/task/verify.command.js +20 -0
- package/dist/commands/upgrade.command.d.ts +6 -0
- package/dist/commands/upgrade.command.d.ts.map +1 -0
- package/dist/commands/upgrade.command.js +104 -0
- package/dist/commands/upgrade.d.ts +13 -2
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +12 -80
- package/dist/commands/verify.command.d.ts +16 -0
- package/dist/commands/verify.command.d.ts.map +1 -0
- package/dist/commands/verify.command.js +113 -0
- package/dist/commands/workflow.d.ts +4 -6
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +4 -7
- package/dist/meta/release.d.ts +2 -0
- package/dist/meta/release.d.ts.map +1 -0
- package/dist/meta/release.js +50 -0
- package/dist/policy/evaluate.d.ts +3 -0
- package/dist/policy/evaluate.d.ts.map +1 -0
- package/dist/policy/evaluate.js +27 -0
- package/dist/policy/result.d.ts +7 -0
- package/dist/policy/result.d.ts.map +1 -0
- package/dist/policy/result.js +21 -0
- package/dist/policy/rules/allowlist.d.ts +3 -0
- package/dist/policy/rules/allowlist.d.ts.map +1 -0
- package/dist/policy/rules/allowlist.js +30 -0
- package/dist/policy/rules/branch-pr-base.d.ts +3 -0
- package/dist/policy/rules/branch-pr-base.d.ts.map +1 -0
- package/dist/policy/rules/branch-pr-base.js +43 -0
- package/dist/policy/rules/clean-tree.d.ts +3 -0
- package/dist/policy/rules/clean-tree.d.ts.map +1 -0
- package/dist/policy/rules/clean-tree.js +19 -0
- package/dist/policy/rules/commit-subject.d.ts +3 -0
- package/dist/policy/rules/commit-subject.d.ts.map +1 -0
- package/dist/policy/rules/commit-subject.js +33 -0
- package/dist/policy/rules/protected-paths.d.ts +3 -0
- package/dist/policy/rules/protected-paths.d.ts.map +1 -0
- package/dist/policy/rules/protected-paths.js +53 -0
- package/dist/policy/types.d.ts +38 -0
- package/dist/policy/types.d.ts.map +1 -0
- package/dist/policy/types.js +1 -0
- package/dist/shared/write-if-changed.d.ts +3 -0
- package/dist/shared/write-if-changed.d.ts.map +1 -0
- package/dist/shared/write-if-changed.js +25 -0
- package/package.json +2 -2
- package/dist/cli/help.d.ts +0 -2
- package/dist/cli/help.d.ts.map +0 -1
- package/dist/cli/help.js +0 -127
- package/dist/commands/task/verify.d.ts +0 -2
- package/dist/commands/task/verify.d.ts.map +0 -1
- package/dist/commands/task/verify.js +0 -1
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
import { canonicalizeJson } from "@agentplaneorg/core";
|
|
2
|
+
import { isRecord } from "../../shared/guards.js";
|
|
3
|
+
import { appendCommentNotes as appendCommentNotesImpl, normalizeComments as normalizeCommentsImpl, } from "./redmine/comments.js";
|
|
4
|
+
import { requestJson as requestRedmineJson } from "./redmine/client.js";
|
|
5
|
+
import { appendCustomField as appendRedmineCustomField, customFieldValue as redmineCustomFieldValue, setIssueCustomFieldValue as setRedmineIssueCustomFieldValue, } from "./redmine/fields.js";
|
|
6
|
+
import { doneRatioForStatus, issueToTask as issueToTaskImpl, startDateFromTaskId, taskToIssuePayload as taskToIssuePayloadImpl, } from "./redmine/mapping.js";
|
|
7
|
+
import { coerceDocVersion as coerceRedmineDocVersion, maybeParseJson as maybeParseRedmineJson, } from "./redmine/parse.js";
|
|
8
|
+
import { findIssueByTaskId as findIssueByTaskIdImpl, listTasksRemote as listTasksRemoteImpl, } from "./redmine/remote.js";
|
|
9
|
+
import { BackendError, DEFAULT_DOC_UPDATED_BY, DOC_VERSION, RedmineUnavailable, ensureDocMetadata, firstNonEmptyString, generateTaskId, mapLimit, missingTaskIdMessage, nowIso, redmineConfigMissingMessage, redmineIssueIdMissingMessage, sleep, toStringSafe, unknownTaskIdMessage, validateTaskId, writeTasksExportFromTasks, } from "./shared.js";
|
|
10
|
+
export class RedmineBackend {
|
|
11
|
+
id = "redmine";
|
|
12
|
+
baseUrl;
|
|
13
|
+
apiKey;
|
|
14
|
+
projectId;
|
|
15
|
+
assigneeId;
|
|
16
|
+
ownerAgent;
|
|
17
|
+
statusMap;
|
|
18
|
+
customFields;
|
|
19
|
+
batchSize;
|
|
20
|
+
batchPause;
|
|
21
|
+
cache;
|
|
22
|
+
issueCache = new Map();
|
|
23
|
+
reverseStatus = new Map();
|
|
24
|
+
constructor(settings, opts) {
|
|
25
|
+
const envUrl = firstNonEmptyString(process.env.AGENTPLANE_REDMINE_URL);
|
|
26
|
+
const envApiKey = firstNonEmptyString(process.env.AGENTPLANE_REDMINE_API_KEY);
|
|
27
|
+
const envProjectId = firstNonEmptyString(process.env.AGENTPLANE_REDMINE_PROJECT_ID);
|
|
28
|
+
const envAssignee = (process.env.AGENTPLANE_REDMINE_ASSIGNEE_ID ?? "").trim();
|
|
29
|
+
const envOwner = firstNonEmptyString(process.env.AGENTPLANE_REDMINE_OWNER, process.env.AGENTPLANE_REDMINE_OWNER_AGENT);
|
|
30
|
+
this.baseUrl = firstNonEmptyString(envUrl, settings.url).replaceAll(/\/+$/gu, "");
|
|
31
|
+
this.apiKey = firstNonEmptyString(envApiKey, settings.api_key);
|
|
32
|
+
this.projectId = firstNonEmptyString(envProjectId, settings.project_id);
|
|
33
|
+
this.assigneeId = envAssignee && /^\d+$/u.test(envAssignee) ? Number(envAssignee) : null;
|
|
34
|
+
this.statusMap = isRecord(settings.status_map) ? settings.status_map : {};
|
|
35
|
+
this.customFields = isRecord(settings.custom_fields) ? settings.custom_fields : {};
|
|
36
|
+
this.batchSize = typeof settings.batch_size === "number" ? settings.batch_size : 20;
|
|
37
|
+
this.batchPause = typeof settings.batch_pause === "number" ? settings.batch_pause : 0.5;
|
|
38
|
+
this.ownerAgent = firstNonEmptyString(envOwner, settings.owner_agent, "REDMINE");
|
|
39
|
+
this.cache = opts.cache ?? null;
|
|
40
|
+
if (!this.baseUrl || !this.apiKey || !this.projectId) {
|
|
41
|
+
throw new BackendError(redmineConfigMissingMessage("url, api_key, project_id"), "E_BACKEND");
|
|
42
|
+
}
|
|
43
|
+
if (!this.customFields?.task_id) {
|
|
44
|
+
throw new BackendError(redmineConfigMissingMessage("custom_fields.task_id"), "E_BACKEND");
|
|
45
|
+
}
|
|
46
|
+
for (const [key, value] of Object.entries(this.statusMap)) {
|
|
47
|
+
if (typeof value === "number")
|
|
48
|
+
this.reverseStatus.set(value, key);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async generateTaskId(opts) {
|
|
52
|
+
const length = opts.length;
|
|
53
|
+
const attempts = opts.attempts;
|
|
54
|
+
let existingIds = new Set();
|
|
55
|
+
try {
|
|
56
|
+
const tasks = await this.listTasksRemote();
|
|
57
|
+
existingIds = new Set(tasks.map((task) => toStringSafe(task.id)).filter(Boolean));
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
if (!(err instanceof RedmineUnavailable))
|
|
61
|
+
throw err;
|
|
62
|
+
if (!this.cache)
|
|
63
|
+
throw err;
|
|
64
|
+
const cached = await this.cache.listTasks();
|
|
65
|
+
existingIds = new Set(cached.map((task) => toStringSafe(task.id)).filter(Boolean));
|
|
66
|
+
}
|
|
67
|
+
return await generateTaskId({
|
|
68
|
+
length,
|
|
69
|
+
attempts,
|
|
70
|
+
isAvailable: (taskId) => !existingIds.has(taskId),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async listTasks() {
|
|
74
|
+
try {
|
|
75
|
+
const tasks = await this.listTasksRemote();
|
|
76
|
+
for (const task of tasks) {
|
|
77
|
+
await this.cacheTask(task, false);
|
|
78
|
+
}
|
|
79
|
+
return tasks;
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
if (err instanceof RedmineUnavailable) {
|
|
83
|
+
if (!this.cache)
|
|
84
|
+
throw err;
|
|
85
|
+
return await this.cache.listTasks();
|
|
86
|
+
}
|
|
87
|
+
throw err;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async exportTasksJson(outputPath) {
|
|
91
|
+
const tasks = await this.listTasks();
|
|
92
|
+
await writeTasksExportFromTasks({ outputPath, tasks });
|
|
93
|
+
}
|
|
94
|
+
async normalizeTasks() {
|
|
95
|
+
// Remote backends should avoid expensive downloads; best-effort normalize the local cache if present.
|
|
96
|
+
if (this.cache?.normalizeTasks)
|
|
97
|
+
return await this.cache.normalizeTasks();
|
|
98
|
+
return { scanned: 0, changed: 0 };
|
|
99
|
+
}
|
|
100
|
+
async getTask(taskId) {
|
|
101
|
+
try {
|
|
102
|
+
const issue = await this.findIssueByTaskId(taskId);
|
|
103
|
+
if (!issue)
|
|
104
|
+
return null;
|
|
105
|
+
const task = this.issueToTask(issue, taskId);
|
|
106
|
+
if (task)
|
|
107
|
+
await this.cacheTask(task, false);
|
|
108
|
+
return task;
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
if (err instanceof RedmineUnavailable) {
|
|
112
|
+
if (!this.cache)
|
|
113
|
+
throw err;
|
|
114
|
+
const cached = await this.cache.getTask(taskId);
|
|
115
|
+
return cached ?? null;
|
|
116
|
+
}
|
|
117
|
+
throw err;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async getTasks(taskIds) {
|
|
121
|
+
// Use limited parallelism to avoid hammering the Redmine API.
|
|
122
|
+
return await mapLimit(taskIds, this.batchSize, async (taskId) => await this.getTask(taskId));
|
|
123
|
+
}
|
|
124
|
+
async getTaskDoc(taskId) {
|
|
125
|
+
const task = await this.getTask(taskId);
|
|
126
|
+
if (!task)
|
|
127
|
+
throw new Error(unknownTaskIdMessage(taskId));
|
|
128
|
+
return toStringSafe(task.doc);
|
|
129
|
+
}
|
|
130
|
+
async setTaskDoc(taskId, doc, updatedBy) {
|
|
131
|
+
if (!this.customFields.doc) {
|
|
132
|
+
throw new BackendError(redmineConfigMissingMessage("custom_fields.doc"), "E_BACKEND");
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
const issue = await this.findIssueByTaskId(taskId);
|
|
136
|
+
if (!issue)
|
|
137
|
+
throw new Error(unknownTaskIdMessage(taskId));
|
|
138
|
+
const issueIdText = toStringSafe(issue.id);
|
|
139
|
+
if (!issueIdText)
|
|
140
|
+
throw new Error(redmineIssueIdMissingMessage());
|
|
141
|
+
const taskDoc = { doc: String(doc ?? "") };
|
|
142
|
+
ensureDocMetadata(taskDoc, updatedBy);
|
|
143
|
+
const customFields = [];
|
|
144
|
+
this.appendCustomField(customFields, "doc", taskDoc.doc);
|
|
145
|
+
this.appendCustomField(customFields, "doc_version", taskDoc.doc_version);
|
|
146
|
+
this.appendCustomField(customFields, "doc_updated_at", taskDoc.doc_updated_at);
|
|
147
|
+
this.appendCustomField(customFields, "doc_updated_by", taskDoc.doc_updated_by);
|
|
148
|
+
await this.requestJson("PUT", `issues/${issueIdText}.json`, {
|
|
149
|
+
issue: { custom_fields: customFields },
|
|
150
|
+
});
|
|
151
|
+
const task = this.issueToTask(issue, taskId);
|
|
152
|
+
if (task) {
|
|
153
|
+
task.doc = taskDoc.doc;
|
|
154
|
+
task.doc_version = taskDoc.doc_version;
|
|
155
|
+
task.doc_updated_at = taskDoc.doc_updated_at;
|
|
156
|
+
task.doc_updated_by = taskDoc.doc_updated_by;
|
|
157
|
+
await this.cacheTask(task, false);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch (err) {
|
|
161
|
+
if (err instanceof RedmineUnavailable) {
|
|
162
|
+
if (!this.cache)
|
|
163
|
+
throw err;
|
|
164
|
+
const cached = await this.cache.getTask(taskId);
|
|
165
|
+
if (!cached)
|
|
166
|
+
throw new Error(unknownTaskIdMessage(taskId));
|
|
167
|
+
cached.doc = String(doc ?? "");
|
|
168
|
+
ensureDocMetadata(cached, updatedBy);
|
|
169
|
+
cached.dirty = true;
|
|
170
|
+
await this.cache.writeTask(cached);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
throw err;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async touchTaskDocMetadata(taskId, updatedBy) {
|
|
177
|
+
try {
|
|
178
|
+
const issue = await this.findIssueByTaskId(taskId);
|
|
179
|
+
if (!issue)
|
|
180
|
+
throw new Error(unknownTaskIdMessage(taskId));
|
|
181
|
+
const issueIdText = toStringSafe(issue.id);
|
|
182
|
+
if (!issueIdText)
|
|
183
|
+
throw new Error(redmineIssueIdMissingMessage());
|
|
184
|
+
const docValue = this.customFieldValue(issue, this.customFields.doc);
|
|
185
|
+
const taskDoc = { doc: docValue ?? "" };
|
|
186
|
+
ensureDocMetadata(taskDoc, updatedBy);
|
|
187
|
+
const customFields = [];
|
|
188
|
+
this.appendCustomField(customFields, "doc_version", taskDoc.doc_version);
|
|
189
|
+
this.appendCustomField(customFields, "doc_updated_at", taskDoc.doc_updated_at);
|
|
190
|
+
this.appendCustomField(customFields, "doc_updated_by", taskDoc.doc_updated_by);
|
|
191
|
+
if (customFields.length > 0) {
|
|
192
|
+
await this.requestJson("PUT", `issues/${issueIdText}.json`, {
|
|
193
|
+
issue: { custom_fields: customFields },
|
|
194
|
+
});
|
|
195
|
+
const task = this.issueToTask(issue, taskId);
|
|
196
|
+
if (task) {
|
|
197
|
+
task.doc_version = taskDoc.doc_version;
|
|
198
|
+
task.doc_updated_at = taskDoc.doc_updated_at;
|
|
199
|
+
task.doc_updated_by = taskDoc.doc_updated_by;
|
|
200
|
+
await this.cacheTask(task, false);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
if (err instanceof RedmineUnavailable) {
|
|
206
|
+
if (!this.cache)
|
|
207
|
+
throw err;
|
|
208
|
+
const cached = await this.cache.getTask(taskId);
|
|
209
|
+
if (!cached)
|
|
210
|
+
throw new Error(unknownTaskIdMessage(taskId));
|
|
211
|
+
ensureDocMetadata(cached, updatedBy);
|
|
212
|
+
cached.dirty = true;
|
|
213
|
+
await this.cache.writeTask(cached);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
throw err;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
async writeTask(task) {
|
|
220
|
+
const taskId = toStringSafe(task.id).trim();
|
|
221
|
+
if (!taskId)
|
|
222
|
+
throw new Error(missingTaskIdMessage());
|
|
223
|
+
validateTaskId(taskId);
|
|
224
|
+
try {
|
|
225
|
+
this.ensureDocMetadata(task);
|
|
226
|
+
let issue = await this.findIssueByTaskId(taskId);
|
|
227
|
+
let issueId = issue?.id;
|
|
228
|
+
let issueIdText = issueId ? toStringSafe(issueId) : "";
|
|
229
|
+
let existingIssue = issue ?? null;
|
|
230
|
+
if (issueIdText && !existingIssue) {
|
|
231
|
+
const payload = await this.requestJson("GET", `issues/${issueIdText}.json`);
|
|
232
|
+
existingIssue = this.issueFromPayload(payload);
|
|
233
|
+
}
|
|
234
|
+
const payload = this.taskToIssuePayload(task, existingIssue ?? undefined);
|
|
235
|
+
if (issueIdText) {
|
|
236
|
+
await this.requestJson("PUT", `issues/${issueIdText}.json`, { issue: payload });
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
const createPayload = { ...payload, project_id: this.projectId };
|
|
240
|
+
const created = await this.requestJson("POST", "issues.json", { issue: createPayload });
|
|
241
|
+
const createdIssue = this.issueFromPayload(created);
|
|
242
|
+
issueId = createdIssue?.id;
|
|
243
|
+
issueIdText = issueId ? toStringSafe(issueId) : "";
|
|
244
|
+
if (issueIdText) {
|
|
245
|
+
const updatePayload = { ...payload };
|
|
246
|
+
delete updatePayload.project_id;
|
|
247
|
+
await this.requestJson("PUT", `issues/${issueIdText}.json`, { issue: updatePayload });
|
|
248
|
+
const refreshed = await this.requestJson("GET", `issues/${issueIdText}.json`);
|
|
249
|
+
existingIssue = this.issueFromPayload(refreshed);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (issueIdText) {
|
|
253
|
+
const existingComments = existingIssue && this.customFields.comments
|
|
254
|
+
? this.normalizeComments(this.maybeParseJson(this.customFieldValue(existingIssue, this.customFields.comments)))
|
|
255
|
+
: [];
|
|
256
|
+
const desiredComments = this.normalizeComments(task.comments);
|
|
257
|
+
await this.appendCommentNotes(issueIdText, existingComments, desiredComments);
|
|
258
|
+
}
|
|
259
|
+
task.dirty = false;
|
|
260
|
+
await this.cacheTask(task, false);
|
|
261
|
+
this.issueCache.clear();
|
|
262
|
+
}
|
|
263
|
+
catch (err) {
|
|
264
|
+
if (err instanceof RedmineUnavailable) {
|
|
265
|
+
if (!this.cache)
|
|
266
|
+
throw err;
|
|
267
|
+
task.dirty = true;
|
|
268
|
+
await this.cacheTask(task, true);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
throw err;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
async writeTasks(tasks) {
|
|
275
|
+
for (const [index, task] of tasks.entries()) {
|
|
276
|
+
await this.writeTask(task);
|
|
277
|
+
if (this.batchPause && this.batchSize > 0 && (index + 1) % this.batchSize === 0) {
|
|
278
|
+
await sleep(this.batchPause * 1000);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
async sync(opts) {
|
|
283
|
+
if (opts.direction === "push") {
|
|
284
|
+
await this.syncPush(opts.quiet, opts.confirm);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (opts.direction === "pull") {
|
|
288
|
+
await this.syncPull(opts.conflict, opts.quiet);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
throw new BackendError("Invalid sync direction (expected push|pull)", "E_BACKEND");
|
|
292
|
+
}
|
|
293
|
+
ensureDocMetadata(task) {
|
|
294
|
+
if (task.doc === undefined)
|
|
295
|
+
return;
|
|
296
|
+
if (task.doc_version !== DOC_VERSION)
|
|
297
|
+
task.doc_version = DOC_VERSION;
|
|
298
|
+
task.doc_updated_at ??= nowIso();
|
|
299
|
+
task.doc_updated_by ??= DEFAULT_DOC_UPDATED_BY;
|
|
300
|
+
}
|
|
301
|
+
async syncPush(quiet, confirm) {
|
|
302
|
+
if (!this.cache) {
|
|
303
|
+
throw new BackendError("Redmine cache is disabled; sync push is unavailable", "E_BACKEND");
|
|
304
|
+
}
|
|
305
|
+
const tasks = await this.cache.listTasks();
|
|
306
|
+
const dirty = tasks.filter((task) => task.dirty);
|
|
307
|
+
if (dirty.length === 0) {
|
|
308
|
+
if (!quiet)
|
|
309
|
+
process.stdout.write("ℹ️ no local task changes to push\n");
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
if (!confirm) {
|
|
313
|
+
for (const task of dirty) {
|
|
314
|
+
process.stdout.write(`- pending push: ${task.id}\n`);
|
|
315
|
+
}
|
|
316
|
+
throw new BackendError("Refusing to push without --yes (preview above)", "E_BACKEND");
|
|
317
|
+
}
|
|
318
|
+
await this.writeTasks(dirty);
|
|
319
|
+
if (!quiet)
|
|
320
|
+
process.stdout.write(`✅ pushed ${dirty.length} task(s) (dirty)\n`);
|
|
321
|
+
}
|
|
322
|
+
async syncPull(conflict, quiet) {
|
|
323
|
+
if (!this.cache) {
|
|
324
|
+
throw new BackendError("Redmine cache is disabled; sync pull is unavailable", "E_BACKEND");
|
|
325
|
+
}
|
|
326
|
+
const remoteTasks = await this.listTasksRemote();
|
|
327
|
+
const remoteById = new Map();
|
|
328
|
+
for (const task of remoteTasks) {
|
|
329
|
+
const taskId = toStringSafe(task.id);
|
|
330
|
+
if (taskId)
|
|
331
|
+
remoteById.set(taskId, task);
|
|
332
|
+
}
|
|
333
|
+
const localTasks = await this.cache.listTasks();
|
|
334
|
+
const localById = new Map();
|
|
335
|
+
for (const task of localTasks) {
|
|
336
|
+
const taskId = toStringSafe(task.id);
|
|
337
|
+
if (taskId)
|
|
338
|
+
localById.set(taskId, task);
|
|
339
|
+
}
|
|
340
|
+
for (const [taskId, remoteTask] of remoteById.entries()) {
|
|
341
|
+
const localTask = localById.get(taskId);
|
|
342
|
+
if (localTask?.dirty) {
|
|
343
|
+
if (this.tasksDiffer(localTask, remoteTask)) {
|
|
344
|
+
await this.handleConflict(taskId, localTask, remoteTask, conflict);
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
localTask.dirty = false;
|
|
348
|
+
await this.cacheTask(localTask, false);
|
|
349
|
+
continue;
|
|
350
|
+
}
|
|
351
|
+
await this.cacheTask(remoteTask, false);
|
|
352
|
+
}
|
|
353
|
+
if (!quiet)
|
|
354
|
+
process.stdout.write(`✅ pulled ${remoteById.size} task(s) (remote)\n`);
|
|
355
|
+
}
|
|
356
|
+
async handleConflict(taskId, localTask, remoteTask, conflict) {
|
|
357
|
+
if (conflict === "prefer-local") {
|
|
358
|
+
await this.writeTask(localTask);
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
if (conflict === "prefer-remote") {
|
|
362
|
+
await this.cacheTask(remoteTask, false);
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
if (conflict === "diff") {
|
|
366
|
+
const diff = this.diffTasks(localTask, remoteTask);
|
|
367
|
+
process.stdout.write(`${diff}\n`);
|
|
368
|
+
throw new BackendError(`Conflict detected for ${taskId}`, "E_BACKEND");
|
|
369
|
+
}
|
|
370
|
+
throw new BackendError(`Conflict detected for ${taskId}`, "E_BACKEND");
|
|
371
|
+
}
|
|
372
|
+
diffTasks(localTask, remoteTask) {
|
|
373
|
+
const localText = JSON.stringify(canonicalizeJson(localTask), null, 2).split("\n");
|
|
374
|
+
const remoteText = JSON.stringify(canonicalizeJson(remoteTask), null, 2).split("\n");
|
|
375
|
+
const diff = ["--- remote", "+++ local"];
|
|
376
|
+
const max = Math.max(localText.length, remoteText.length);
|
|
377
|
+
for (let i = 0; i < max; i++) {
|
|
378
|
+
const l = localText[i];
|
|
379
|
+
const r = remoteText[i];
|
|
380
|
+
if (l === r)
|
|
381
|
+
continue;
|
|
382
|
+
if (r !== undefined)
|
|
383
|
+
diff.push(`- ${r}`);
|
|
384
|
+
if (l !== undefined)
|
|
385
|
+
diff.push(`+ ${l}`);
|
|
386
|
+
}
|
|
387
|
+
return diff.join("\n");
|
|
388
|
+
}
|
|
389
|
+
tasksDiffer(localTask, remoteTask) {
|
|
390
|
+
const localText = JSON.stringify(canonicalizeJson(localTask));
|
|
391
|
+
const remoteText = JSON.stringify(canonicalizeJson(remoteTask));
|
|
392
|
+
return localText !== remoteText;
|
|
393
|
+
}
|
|
394
|
+
async cacheTask(task, dirty) {
|
|
395
|
+
if (!this.cache)
|
|
396
|
+
return;
|
|
397
|
+
const next = { ...task, dirty };
|
|
398
|
+
await this.cache.writeTask(next);
|
|
399
|
+
}
|
|
400
|
+
taskIdFieldId() {
|
|
401
|
+
const fieldId = this.customFields?.task_id;
|
|
402
|
+
if (fieldId)
|
|
403
|
+
return fieldId;
|
|
404
|
+
throw new BackendError(redmineConfigMissingMessage("custom_fields.task_id"), "E_BACKEND");
|
|
405
|
+
}
|
|
406
|
+
setIssueCustomFieldValue(issue, fieldId, value) {
|
|
407
|
+
setRedmineIssueCustomFieldValue(issue, fieldId, value);
|
|
408
|
+
}
|
|
409
|
+
async listTasksRemote() {
|
|
410
|
+
const taskFieldId = this.taskIdFieldId();
|
|
411
|
+
return await listTasksRemoteImpl({
|
|
412
|
+
projectId: this.projectId,
|
|
413
|
+
taskFieldId,
|
|
414
|
+
issueCache: this.issueCache,
|
|
415
|
+
requestJson: async (method, reqPath, payload, params) => await this.requestJson(method, reqPath, payload, params),
|
|
416
|
+
customFieldValue: (issue, fieldId) => this.customFieldValue(issue, fieldId),
|
|
417
|
+
issueToTask: (issue, taskIdOverride) => this.issueToTask(issue, taskIdOverride),
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
issueFromPayload(payload) {
|
|
421
|
+
return isRecord(payload.issue) ? payload.issue : null;
|
|
422
|
+
}
|
|
423
|
+
async findIssueByTaskId(taskId) {
|
|
424
|
+
const taskFieldId = this.taskIdFieldId();
|
|
425
|
+
return await findIssueByTaskIdImpl({
|
|
426
|
+
taskId,
|
|
427
|
+
projectId: this.projectId,
|
|
428
|
+
taskFieldId,
|
|
429
|
+
issueCache: this.issueCache,
|
|
430
|
+
requestJson: async (method, reqPath, payload, params) => await this.requestJson(method, reqPath, payload, params),
|
|
431
|
+
customFieldValue: (issue, fieldId) => this.customFieldValue(issue, fieldId),
|
|
432
|
+
refreshList: async () => {
|
|
433
|
+
await this.listTasksRemote();
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
issueToTask(issue, taskIdOverride) {
|
|
438
|
+
return issueToTaskImpl({
|
|
439
|
+
issue,
|
|
440
|
+
taskIdOverride,
|
|
441
|
+
reverseStatus: this.reverseStatus,
|
|
442
|
+
customFields: this.customFields,
|
|
443
|
+
ownerAgent: this.ownerAgent,
|
|
444
|
+
defaultDocVersion: DOC_VERSION,
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
taskToIssuePayload(task, existingIssue) {
|
|
448
|
+
return taskToIssuePayloadImpl({
|
|
449
|
+
task,
|
|
450
|
+
existingIssue,
|
|
451
|
+
statusMap: this.statusMap,
|
|
452
|
+
assigneeId: this.assigneeId,
|
|
453
|
+
customFields: this.customFields,
|
|
454
|
+
appendCustomField: (fields, key, value) => this.appendCustomField(fields, key, value),
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
appendCustomField(fields, key, value) {
|
|
458
|
+
appendRedmineCustomField({ customFields: this.customFields, fields, key, value });
|
|
459
|
+
}
|
|
460
|
+
normalizeComments(value) {
|
|
461
|
+
return normalizeCommentsImpl(value);
|
|
462
|
+
}
|
|
463
|
+
async appendCommentNotes(issueId, existingComments, desiredComments) {
|
|
464
|
+
await appendCommentNotesImpl({
|
|
465
|
+
issueId,
|
|
466
|
+
existingComments,
|
|
467
|
+
desiredComments,
|
|
468
|
+
requestJson: async (method, reqPath, payload, params) => await this.requestJson(method, reqPath, payload, params),
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
startDateFromTaskId(taskId) {
|
|
472
|
+
return startDateFromTaskId(taskId);
|
|
473
|
+
}
|
|
474
|
+
doneRatioForStatus(status) {
|
|
475
|
+
return doneRatioForStatus(status);
|
|
476
|
+
}
|
|
477
|
+
commentsToPairs(comments) {
|
|
478
|
+
const pairs = [];
|
|
479
|
+
for (const comment of comments) {
|
|
480
|
+
const author = toStringSafe(comment.author).trim();
|
|
481
|
+
const body = toStringSafe(comment.body).trim();
|
|
482
|
+
if (!author && !body)
|
|
483
|
+
continue;
|
|
484
|
+
pairs.push([author, body]);
|
|
485
|
+
}
|
|
486
|
+
return pairs;
|
|
487
|
+
}
|
|
488
|
+
formatCommentNote(author = "unknown", body = "") {
|
|
489
|
+
const authorText = author;
|
|
490
|
+
const bodyText = body;
|
|
491
|
+
return `[comment] ${authorText}: ${bodyText}`.trim();
|
|
492
|
+
}
|
|
493
|
+
customFieldValue(issue, fieldId) {
|
|
494
|
+
return redmineCustomFieldValue(issue, fieldId);
|
|
495
|
+
}
|
|
496
|
+
maybeParseJson(value) {
|
|
497
|
+
return maybeParseRedmineJson(value);
|
|
498
|
+
}
|
|
499
|
+
coerceDocVersion(value) {
|
|
500
|
+
return coerceRedmineDocVersion(value);
|
|
501
|
+
}
|
|
502
|
+
async requestJson(method, reqPath, payload, params, opts) {
|
|
503
|
+
return await requestRedmineJson({ baseUrl: this.baseUrl, apiKey: this.apiKey }, method, reqPath, payload, params, opts);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concurrency.d.ts","sourceRoot":"","sources":["../../../../src/backends/task-backend/shared/concurrency.ts"],"names":[],"mappings":"AAAA,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED,wBAAsB,QAAQ,CAAC,CAAC,EAAE,CAAC,EACjC,KAAK,EAAE,CAAC,EAAE,EACV,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,GACzC,OAAO,CAAC,CAAC,EAAE,CAAC,CAkBd"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function sleep(ms) {
|
|
2
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
3
|
+
}
|
|
4
|
+
export async function mapLimit(items, limit, fn) {
|
|
5
|
+
const bounded = Math.max(1, Math.floor(limit));
|
|
6
|
+
const out = [];
|
|
7
|
+
out.length = items.length;
|
|
8
|
+
let nextIndex = 0;
|
|
9
|
+
const worker = async () => {
|
|
10
|
+
for (;;) {
|
|
11
|
+
const i = nextIndex;
|
|
12
|
+
nextIndex++;
|
|
13
|
+
if (i >= items.length)
|
|
14
|
+
return;
|
|
15
|
+
out[i] = await fn(items[i], i);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const workers = Array.from({ length: Math.min(bounded, items.length) }, () => worker());
|
|
19
|
+
await Promise.all(workers);
|
|
20
|
+
return out;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/backends/task-backend/shared/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,QAA6D,CAAC;AACrF,eAAO,MAAM,sBAAsB,eAAe,CAAC;AACnD,eAAO,MAAM,WAAW,IAAI,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TaskData, TaskDocMeta } from "./types.js";
|
|
2
|
+
type ExtractTaskDoc = (body: string) => string;
|
|
3
|
+
type MergeTaskDoc = (body: string, doc: string) => string;
|
|
4
|
+
declare const extractTaskDoc: ExtractTaskDoc;
|
|
5
|
+
declare const mergeTaskDoc: MergeTaskDoc;
|
|
6
|
+
export declare function nowIso(): string;
|
|
7
|
+
export declare function resolveDocUpdatedByFromFrontmatter(frontmatter: Record<string, unknown>, updatedBy: string | undefined, fallback: string): string;
|
|
8
|
+
export declare function resolveDocUpdatedByFromTask(task: TaskData, fallback: string): string;
|
|
9
|
+
export declare function ensureDocMetadata(task: TaskDocMeta & Partial<Pick<TaskData, "comments" | "owner">>, updatedBy?: string): void;
|
|
10
|
+
export { extractTaskDoc, mergeTaskDoc };
|
|
11
|
+
//# sourceMappingURL=doc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../../../src/backends/task-backend/shared/doc.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExD,KAAK,cAAc,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;AAC/C,KAAK,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;AAE1D,QAAA,MAAM,cAAc,EAAE,cAAmC,CAAC;AAC1D,QAAA,MAAM,YAAY,EAAE,YAA+B,CAAC;AAEpD,wBAAgB,MAAM,IAAI,MAAM,CAE/B;AAyBD,wBAAgB,kCAAkC,CAChD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,QAAQ,EAAE,MAAM,GACf,MAAM,CAaR;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CASpF;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,CAAC,EACjE,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI,CAUN;AAED,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { extractTaskDoc as extractTaskDocCore, mergeTaskDoc as mergeTaskDocCore, } from "@agentplaneorg/core";
|
|
2
|
+
import { isRecord } from "../../../shared/guards.js";
|
|
3
|
+
import { DEFAULT_DOC_UPDATED_BY, DOC_VERSION } from "./constants.js";
|
|
4
|
+
const extractTaskDoc = extractTaskDocCore;
|
|
5
|
+
const mergeTaskDoc = mergeTaskDocCore;
|
|
6
|
+
export function nowIso() {
|
|
7
|
+
return new Date().toISOString();
|
|
8
|
+
}
|
|
9
|
+
function normalizeUpdatedBy(value) {
|
|
10
|
+
if (typeof value !== "string")
|
|
11
|
+
return "";
|
|
12
|
+
const trimmed = value.trim();
|
|
13
|
+
if (!trimmed)
|
|
14
|
+
return "";
|
|
15
|
+
if (trimmed.toLowerCase() === DEFAULT_DOC_UPDATED_BY.toLowerCase())
|
|
16
|
+
return "";
|
|
17
|
+
return trimmed;
|
|
18
|
+
}
|
|
19
|
+
function lastCommentAuthor(comments) {
|
|
20
|
+
if (!Array.isArray(comments))
|
|
21
|
+
return null;
|
|
22
|
+
const entries = comments;
|
|
23
|
+
for (let i = entries.length - 1; i >= 0; i -= 1) {
|
|
24
|
+
const entry = entries[i];
|
|
25
|
+
if (!isRecord(entry))
|
|
26
|
+
continue;
|
|
27
|
+
const author = entry.author;
|
|
28
|
+
if (typeof author === "string") {
|
|
29
|
+
const trimmed = author.trim();
|
|
30
|
+
if (trimmed)
|
|
31
|
+
return trimmed;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
export function resolveDocUpdatedByFromFrontmatter(frontmatter, updatedBy, fallback) {
|
|
37
|
+
if (updatedBy !== undefined) {
|
|
38
|
+
const explicit = normalizeUpdatedBy(updatedBy);
|
|
39
|
+
if (explicit)
|
|
40
|
+
return explicit;
|
|
41
|
+
}
|
|
42
|
+
const author = lastCommentAuthor(frontmatter.comments);
|
|
43
|
+
if (author)
|
|
44
|
+
return author;
|
|
45
|
+
const existing = normalizeUpdatedBy(frontmatter.doc_updated_by);
|
|
46
|
+
if (existing)
|
|
47
|
+
return existing;
|
|
48
|
+
const owner = normalizeUpdatedBy(frontmatter.owner);
|
|
49
|
+
if (owner)
|
|
50
|
+
return owner;
|
|
51
|
+
const fallbackValue = normalizeUpdatedBy(fallback);
|
|
52
|
+
return fallbackValue || fallback;
|
|
53
|
+
}
|
|
54
|
+
export function resolveDocUpdatedByFromTask(task, fallback) {
|
|
55
|
+
const author = lastCommentAuthor(task.comments);
|
|
56
|
+
if (author)
|
|
57
|
+
return author;
|
|
58
|
+
const existing = normalizeUpdatedBy(task.doc_updated_by);
|
|
59
|
+
if (existing)
|
|
60
|
+
return existing;
|
|
61
|
+
const owner = normalizeUpdatedBy(task.owner);
|
|
62
|
+
if (owner)
|
|
63
|
+
return owner;
|
|
64
|
+
const fallbackValue = normalizeUpdatedBy(fallback);
|
|
65
|
+
return fallbackValue || fallback;
|
|
66
|
+
}
|
|
67
|
+
export function ensureDocMetadata(task, updatedBy) {
|
|
68
|
+
task.doc_version = DOC_VERSION;
|
|
69
|
+
task.doc_updated_at = nowIso();
|
|
70
|
+
const explicit = normalizeUpdatedBy(updatedBy);
|
|
71
|
+
if (updatedBy !== undefined) {
|
|
72
|
+
task.doc_updated_by =
|
|
73
|
+
explicit || resolveDocUpdatedByFromTask(task, DEFAULT_DOC_UPDATED_BY);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
task.doc_updated_by = resolveDocUpdatedByFromTask(task, DEFAULT_DOC_UPDATED_BY);
|
|
77
|
+
}
|
|
78
|
+
export { extractTaskDoc, mergeTaskDoc };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class BackendError extends Error {
|
|
2
|
+
code: "E_BACKEND" | "E_NETWORK";
|
|
3
|
+
constructor(message: string, code: "E_BACKEND" | "E_NETWORK");
|
|
4
|
+
}
|
|
5
|
+
export declare class RedmineUnavailable extends BackendError {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
export declare function redmineConfigMissingMessage(detail: string): string;
|
|
9
|
+
export declare function redmineIssueIdMissingMessage(): string;
|
|
10
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/backends/task-backend/shared/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;IACrC,IAAI,EAAE,WAAW,GAAG,WAAW,CAAC;gBACpB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,WAAW;CAI7D;AAED,qBAAa,kBAAmB,SAAQ,YAAY;gBACtC,OAAO,EAAE,MAAM;CAG5B;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElE;AAED,wBAAgB,4BAA4B,IAAI,MAAM,CAErD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class BackendError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
constructor(message, code) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.code = code;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export class RedmineUnavailable extends BackendError {
|
|
9
|
+
constructor(message) {
|
|
10
|
+
super(message, "E_NETWORK");
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function redmineConfigMissingMessage(detail) {
|
|
14
|
+
return `Missing required Redmine config: ${detail}`;
|
|
15
|
+
}
|
|
16
|
+
export function redmineIssueIdMissingMessage() {
|
|
17
|
+
return "Missing Redmine issue id for task";
|
|
18
|
+
}
|