@bosun-sh/logbook 1.1.0 → 2.0.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/CHANGELOG.md +139 -0
- package/README.md +248 -318
- package/bin/logbook.cjs +18 -0
- package/dist/context/attachments.d.ts +55 -0
- package/dist/context/attachments.d.ts.map +1 -0
- package/dist/context/attachments.js +329 -0
- package/dist/context/attachments.js.map +1 -0
- package/dist/context/create.d.ts +31 -0
- package/dist/context/create.d.ts.map +1 -0
- package/dist/context/create.js +101 -0
- package/dist/context/create.js.map +1 -0
- package/dist/context/delete.d.ts +20 -0
- package/dist/context/delete.d.ts.map +1 -0
- package/dist/context/delete.js +55 -0
- package/dist/context/delete.js.map +1 -0
- package/dist/context/get.d.ts +20 -0
- package/dist/context/get.d.ts.map +1 -0
- package/dist/context/get.js +55 -0
- package/dist/context/get.js.map +1 -0
- package/dist/context/list.d.ts +30 -0
- package/dist/context/list.d.ts.map +1 -0
- package/dist/context/list.js +172 -0
- package/dist/context/list.js.map +1 -0
- package/dist/context/schema.d.ts +156 -0
- package/dist/context/schema.d.ts.map +1 -0
- package/dist/context/schema.js +34 -0
- package/dist/context/schema.js.map +1 -0
- package/dist/context/search.d.ts +27 -0
- package/dist/context/search.d.ts.map +1 -0
- package/dist/context/search.js +266 -0
- package/dist/context/search.js.map +1 -0
- package/dist/context/topics.d.ts +4 -0
- package/dist/context/topics.d.ts.map +1 -0
- package/dist/context/topics.js +54 -0
- package/dist/context/topics.js.map +1 -0
- package/dist/context/update.d.ts +29 -0
- package/dist/context/update.d.ts.map +1 -0
- package/dist/context/update.js +134 -0
- package/dist/context/update.js.map +1 -0
- package/dist/epic/cascade-delete.d.ts +30 -0
- package/dist/epic/cascade-delete.d.ts.map +1 -0
- package/dist/epic/cascade-delete.js +173 -0
- package/dist/epic/cascade-delete.js.map +1 -0
- package/dist/epic/create.d.ts +24 -0
- package/dist/epic/create.d.ts.map +1 -0
- package/dist/epic/create.js +54 -0
- package/dist/epic/create.js.map +1 -0
- package/dist/epic/delete.d.ts +21 -0
- package/dist/epic/delete.d.ts.map +1 -0
- package/dist/epic/delete.js +42 -0
- package/dist/epic/delete.js.map +1 -0
- package/dist/epic/get.d.ts +19 -0
- package/dist/epic/get.d.ts.map +1 -0
- package/dist/epic/get.js +31 -0
- package/dist/epic/get.js.map +1 -0
- package/dist/epic/list.d.ts +25 -0
- package/dist/epic/list.d.ts.map +1 -0
- package/dist/epic/list.js +114 -0
- package/dist/epic/list.js.map +1 -0
- package/dist/epic/rules.d.ts +34 -0
- package/dist/epic/rules.d.ts.map +1 -0
- package/dist/epic/rules.js +127 -0
- package/dist/epic/rules.js.map +1 -0
- package/dist/epic/schema.d.ts +85 -0
- package/dist/epic/schema.d.ts.map +1 -0
- package/dist/epic/schema.js +14 -0
- package/dist/epic/schema.js.map +1 -0
- package/dist/epic/update.d.ts +25 -0
- package/dist/epic/update.d.ts.map +1 -0
- package/dist/epic/update.js +69 -0
- package/dist/epic/update.js.map +1 -0
- package/dist/hook/list.d.ts +71 -0
- package/dist/hook/list.d.ts.map +1 -0
- package/dist/hook/list.js +364 -0
- package/dist/hook/list.js.map +1 -0
- package/dist/hook/ports.d.ts +16 -0
- package/dist/hook/ports.d.ts.map +1 -0
- package/dist/hook/ports.js +3 -0
- package/dist/hook/ports.js.map +1 -0
- package/dist/hook/run.d.ts +24 -0
- package/dist/hook/run.d.ts.map +1 -0
- package/dist/hook/run.js +185 -0
- package/dist/hook/run.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin/hook-tools.d.ts +8 -0
- package/dist/plugin/hook-tools.d.ts.map +1 -0
- package/dist/plugin/hook-tools.js +31 -0
- package/dist/plugin/hook-tools.js.map +1 -0
- package/dist/plugin/linear-pull-tool.d.ts +20 -0
- package/dist/plugin/linear-pull-tool.d.ts.map +1 -0
- package/dist/plugin/linear-pull-tool.js +19 -0
- package/dist/plugin/linear-pull-tool.js.map +1 -0
- package/dist/plugin/linear-push-tool.d.ts +20 -0
- package/dist/plugin/linear-push-tool.d.ts.map +1 -0
- package/dist/plugin/linear-push-tool.js +27 -0
- package/dist/plugin/linear-push-tool.js.map +1 -0
- package/dist/plugin/linear-setup-tool.d.ts +2 -0
- package/dist/plugin/linear-setup-tool.d.ts.map +1 -0
- package/dist/plugin/linear-setup-tool.js +22 -0
- package/dist/plugin/linear-setup-tool.js.map +1 -0
- package/dist/plugin/linear-status-tool.d.ts +10 -0
- package/dist/plugin/linear-status-tool.d.ts.map +1 -0
- package/dist/plugin/linear-status-tool.js +10 -0
- package/dist/plugin/linear-status-tool.js.map +1 -0
- package/dist/plugin/list.d.ts +15 -0
- package/dist/plugin/list.d.ts.map +1 -0
- package/dist/plugin/list.js +87 -0
- package/dist/plugin/list.js.map +1 -0
- package/dist/plugin/public-schemas.d.ts +42 -0
- package/dist/plugin/public-schemas.d.ts.map +1 -0
- package/dist/plugin/public-schemas.js +577 -0
- package/dist/plugin/public-schemas.js.map +1 -0
- package/dist/plugin/registry.d.ts +3 -0
- package/dist/plugin/registry.d.ts.map +1 -0
- package/dist/plugin/registry.js +3 -0
- package/dist/plugin/registry.js.map +1 -0
- package/dist/plugin/results.d.ts +8 -0
- package/dist/plugin/results.d.ts.map +1 -0
- package/dist/plugin/results.js +114 -0
- package/dist/plugin/results.js.map +1 -0
- package/dist/plugin/sync-conflict-tools.d.ts +2 -0
- package/dist/plugin/sync-conflict-tools.d.ts.map +1 -0
- package/dist/plugin/sync-conflict-tools.js +5 -0
- package/dist/plugin/sync-conflict-tools.js.map +1 -0
- package/dist/plugin/tool-registry.d.ts +23 -0
- package/dist/plugin/tool-registry.d.ts.map +1 -0
- package/dist/plugin/tool-registry.js +251 -0
- package/dist/plugin/tool-registry.js.map +1 -0
- package/dist/plugin/workspace-init-tool.d.ts +2 -0
- package/dist/plugin/workspace-init-tool.d.ts.map +1 -0
- package/dist/plugin/workspace-init-tool.js +16 -0
- package/dist/plugin/workspace-init-tool.js.map +1 -0
- package/dist/plugin/workspace-status-tool.d.ts +2 -0
- package/dist/plugin/workspace-status-tool.d.ts.map +1 -0
- package/dist/plugin/workspace-status-tool.js +15 -0
- package/dist/plugin/workspace-status-tool.js.map +1 -0
- package/dist/shared/ids.d.ts +3 -0
- package/dist/shared/ids.d.ts.map +1 -0
- package/dist/shared/ids.js +15 -0
- package/dist/shared/ids.js.map +1 -0
- package/dist/shared/pagination.d.ts +19 -0
- package/dist/shared/pagination.d.ts.map +1 -0
- package/dist/shared/pagination.js +110 -0
- package/dist/shared/pagination.js.map +1 -0
- package/dist/shared/result.d.ts +20 -0
- package/dist/shared/result.d.ts.map +1 -0
- package/dist/shared/result.js +6 -0
- package/dist/shared/result.js.map +1 -0
- package/dist/shared/schema/value-objects.d.ts +363 -0
- package/dist/shared/schema/value-objects.d.ts.map +1 -0
- package/dist/shared/schema/value-objects.js +112 -0
- package/dist/shared/schema/value-objects.js.map +1 -0
- package/dist/shared/storage/atomic-write.d.ts +25 -0
- package/dist/shared/storage/atomic-write.d.ts.map +1 -0
- package/dist/shared/storage/atomic-write.js +71 -0
- package/dist/shared/storage/atomic-write.js.map +1 -0
- package/dist/shared/storage/jsonl-repository.d.ts +85 -0
- package/dist/shared/storage/jsonl-repository.d.ts.map +1 -0
- package/dist/shared/storage/jsonl-repository.js +278 -0
- package/dist/shared/storage/jsonl-repository.js.map +1 -0
- package/dist/shared/storage/transaction.d.ts +3 -0
- package/dist/shared/storage/transaction.d.ts.map +1 -0
- package/dist/shared/storage/transaction.js +22 -0
- package/dist/shared/storage/transaction.js.map +1 -0
- package/dist/shared/time.d.ts +3 -0
- package/dist/shared/time.d.ts.map +1 -0
- package/dist/shared/time.js +3 -0
- package/dist/shared/time.js.map +1 -0
- package/dist/story/cascade-delete.d.ts +22 -0
- package/dist/story/cascade-delete.d.ts.map +1 -0
- package/dist/story/cascade-delete.js +117 -0
- package/dist/story/cascade-delete.js.map +1 -0
- package/dist/story/create.d.ts +30 -0
- package/dist/story/create.d.ts.map +1 -0
- package/dist/story/create.js +69 -0
- package/dist/story/create.js.map +1 -0
- package/dist/story/delete.d.ts +21 -0
- package/dist/story/delete.d.ts.map +1 -0
- package/dist/story/delete.js +42 -0
- package/dist/story/delete.js.map +1 -0
- package/dist/story/get.d.ts +19 -0
- package/dist/story/get.d.ts.map +1 -0
- package/dist/story/get.js +31 -0
- package/dist/story/get.js.map +1 -0
- package/dist/story/hierarchy.d.ts +20 -0
- package/dist/story/hierarchy.d.ts.map +1 -0
- package/dist/story/hierarchy.js +30 -0
- package/dist/story/hierarchy.js.map +1 -0
- package/dist/story/list.d.ts +25 -0
- package/dist/story/list.d.ts.map +1 -0
- package/dist/story/list.js +118 -0
- package/dist/story/list.js.map +1 -0
- package/dist/story/rules.d.ts +34 -0
- package/dist/story/rules.d.ts.map +1 -0
- package/dist/story/rules.js +100 -0
- package/dist/story/rules.js.map +1 -0
- package/dist/story/schema.d.ts +65 -0
- package/dist/story/schema.d.ts.map +1 -0
- package/dist/story/schema.js +14 -0
- package/dist/story/schema.js.map +1 -0
- package/dist/story/update.d.ts +23 -0
- package/dist/story/update.d.ts.map +1 -0
- package/dist/story/update.js +67 -0
- package/dist/story/update.js.map +1 -0
- package/dist/sync/base-snapshot.d.ts +38 -0
- package/dist/sync/base-snapshot.d.ts.map +1 -0
- package/dist/sync/base-snapshot.js +86 -0
- package/dist/sync/base-snapshot.js.map +1 -0
- package/dist/sync/conflict-tools.d.ts +75 -0
- package/dist/sync/conflict-tools.d.ts.map +1 -0
- package/dist/sync/conflict-tools.js +53 -0
- package/dist/sync/conflict-tools.js.map +1 -0
- package/dist/sync/conflicts.d.ts +201 -0
- package/dist/sync/conflicts.d.ts.map +1 -0
- package/dist/sync/conflicts.js +526 -0
- package/dist/sync/conflicts.js.map +1 -0
- package/dist/sync/deferred-providers.d.ts +2 -0
- package/dist/sync/deferred-providers.d.ts.map +1 -0
- package/dist/sync/deferred-providers.js +6 -0
- package/dist/sync/deferred-providers.js.map +1 -0
- package/dist/sync/events.d.ts +401 -0
- package/dist/sync/events.d.ts.map +1 -0
- package/dist/sync/events.js +357 -0
- package/dist/sync/events.js.map +1 -0
- package/dist/sync/external-links.d.ts +154 -0
- package/dist/sync/external-links.d.ts.map +1 -0
- package/dist/sync/external-links.js +306 -0
- package/dist/sync/external-links.js.map +1 -0
- package/dist/sync/linear/config.d.ts +60 -0
- package/dist/sync/linear/config.d.ts.map +1 -0
- package/dist/sync/linear/config.js +302 -0
- package/dist/sync/linear/config.js.map +1 -0
- package/dist/sync/linear/mapping.d.ts +115 -0
- package/dist/sync/linear/mapping.d.ts.map +1 -0
- package/dist/sync/linear/mapping.js +159 -0
- package/dist/sync/linear/mapping.js.map +1 -0
- package/dist/sync/linear/pull.d.ts +33 -0
- package/dist/sync/linear/pull.d.ts.map +1 -0
- package/dist/sync/linear/pull.js +376 -0
- package/dist/sync/linear/pull.js.map +1 -0
- package/dist/sync/linear/push.d.ts +34 -0
- package/dist/sync/linear/push.d.ts.map +1 -0
- package/dist/sync/linear/push.js +681 -0
- package/dist/sync/linear/push.js.map +1 -0
- package/dist/sync/linear/setup.d.ts +33 -0
- package/dist/sync/linear/setup.d.ts.map +1 -0
- package/dist/sync/linear/setup.js +129 -0
- package/dist/sync/linear/setup.js.map +1 -0
- package/dist/sync/linear/status.d.ts +35 -0
- package/dist/sync/linear/status.d.ts.map +1 -0
- package/dist/sync/linear/status.js +138 -0
- package/dist/sync/linear/status.js.map +1 -0
- package/dist/sync/linear/transport.d.ts +47 -0
- package/dist/sync/linear/transport.d.ts.map +1 -0
- package/dist/sync/linear/transport.js +249 -0
- package/dist/sync/linear/transport.js.map +1 -0
- package/dist/sync/provider-port.d.ts +81 -0
- package/dist/sync/provider-port.d.ts.map +1 -0
- package/dist/sync/provider-port.js +16 -0
- package/dist/sync/provider-port.js.map +1 -0
- package/dist/sync/provider-registry.d.ts +38 -0
- package/dist/sync/provider-registry.d.ts.map +1 -0
- package/dist/sync/provider-registry.js +115 -0
- package/dist/sync/provider-registry.js.map +1 -0
- package/dist/sync/schema.d.ts +147 -0
- package/dist/sync/schema.d.ts.map +1 -0
- package/dist/sync/schema.js +28 -0
- package/dist/sync/schema.js.map +1 -0
- package/dist/task/comments.d.ts +9 -0
- package/dist/task/comments.d.ts.map +1 -0
- package/dist/task/comments.js +79 -0
- package/dist/task/comments.js.map +1 -0
- package/dist/task/create.d.ts +34 -0
- package/dist/task/create.d.ts.map +1 -0
- package/dist/task/create.js +126 -0
- package/dist/task/create.js.map +1 -0
- package/dist/task/current.d.ts +18 -0
- package/dist/task/current.d.ts.map +1 -0
- package/dist/task/current.js +105 -0
- package/dist/task/current.js.map +1 -0
- package/dist/task/edit.d.ts +22 -0
- package/dist/task/edit.d.ts.map +1 -0
- package/dist/task/edit.js +105 -0
- package/dist/task/edit.js.map +1 -0
- package/dist/task/estimate.d.ts +20 -0
- package/dist/task/estimate.d.ts.map +1 -0
- package/dist/task/estimate.js +141 -0
- package/dist/task/estimate.js.map +1 -0
- package/dist/task/get.d.ts +13 -0
- package/dist/task/get.d.ts.map +1 -0
- package/dist/task/get.js +29 -0
- package/dist/task/get.js.map +1 -0
- package/dist/task/hierarchy.d.ts +18 -0
- package/dist/task/hierarchy.d.ts.map +1 -0
- package/dist/task/hierarchy.js +56 -0
- package/dist/task/hierarchy.js.map +1 -0
- package/dist/task/lifecycle.d.ts +14 -0
- package/dist/task/lifecycle.d.ts.map +1 -0
- package/dist/task/lifecycle.js +80 -0
- package/dist/task/lifecycle.js.map +1 -0
- package/dist/task/list.d.ts +24 -0
- package/dist/task/list.d.ts.map +1 -0
- package/dist/task/list.js +116 -0
- package/dist/task/list.js.map +1 -0
- package/dist/task/model-assignment.d.ts +33 -0
- package/dist/task/model-assignment.d.ts.map +1 -0
- package/dist/task/model-assignment.js +145 -0
- package/dist/task/model-assignment.js.map +1 -0
- package/dist/task/ordering.d.ts +4 -0
- package/dist/task/ordering.d.ts.map +1 -0
- package/dist/task/ordering.js +14 -0
- package/dist/task/ordering.js.map +1 -0
- package/dist/task/ports.d.ts +37 -0
- package/dist/task/ports.d.ts.map +1 -0
- package/dist/task/ports.js +3 -0
- package/dist/task/ports.js.map +1 -0
- package/dist/task/schema.d.ts +447 -0
- package/dist/task/schema.d.ts.map +1 -0
- package/dist/task/schema.js +35 -0
- package/dist/task/schema.js.map +1 -0
- package/dist/task/session-assignment.d.ts +23 -0
- package/dist/task/session-assignment.d.ts.map +1 -0
- package/dist/task/session-assignment.js +197 -0
- package/dist/task/session-assignment.js.map +1 -0
- package/dist/task/session-registry.d.ts +8 -0
- package/dist/task/session-registry.d.ts.map +1 -0
- package/dist/task/session-registry.js +3 -0
- package/dist/task/session-registry.js.map +1 -0
- package/dist/task/update.d.ts +23 -0
- package/dist/task/update.d.ts.map +1 -0
- package/dist/task/update.js +92 -0
- package/dist/task/update.js.map +1 -0
- package/dist/task/v1-compat.d.ts +94 -0
- package/dist/task/v1-compat.d.ts.map +1 -0
- package/dist/task/v1-compat.js +181 -0
- package/dist/task/v1-compat.js.map +1 -0
- package/dist/workspace/bin-cli.d.ts +2 -0
- package/dist/workspace/bin-cli.d.ts.map +1 -0
- package/dist/workspace/bin-cli.js +36 -0
- package/dist/workspace/bin-cli.js.map +1 -0
- package/dist/workspace/cli-adapter.d.ts +16 -0
- package/dist/workspace/cli-adapter.d.ts.map +1 -0
- package/dist/workspace/cli-adapter.js +229 -0
- package/dist/workspace/cli-adapter.js.map +1 -0
- package/dist/workspace/cli-commands.d.ts +11 -0
- package/dist/workspace/cli-commands.d.ts.map +1 -0
- package/dist/workspace/cli-commands.js +12 -0
- package/dist/workspace/cli-commands.js.map +1 -0
- package/dist/workspace/duckdb-index.d.ts +56 -0
- package/dist/workspace/duckdb-index.d.ts.map +1 -0
- package/dist/workspace/duckdb-index.js +178 -0
- package/dist/workspace/duckdb-index.js.map +1 -0
- package/dist/workspace/hook-templates/need-info-notify/config.json +10 -0
- package/dist/workspace/hook-templates/need-info-notify/script.mjs +68 -0
- package/dist/workspace/hook-templates/review-spawn/config.json +10 -0
- package/dist/workspace/hook-templates/review-spawn/script.mjs +100 -0
- package/dist/workspace/init-onboarding.d.ts +9 -0
- package/dist/workspace/init-onboarding.d.ts.map +1 -0
- package/dist/workspace/init-onboarding.js +259 -0
- package/dist/workspace/init-onboarding.js.map +1 -0
- package/dist/workspace/init.d.ts +20 -0
- package/dist/workspace/init.d.ts.map +1 -0
- package/dist/workspace/init.js +288 -0
- package/dist/workspace/init.js.map +1 -0
- package/dist/workspace/layers.d.ts +127 -0
- package/dist/workspace/layers.d.ts.map +1 -0
- package/dist/workspace/layers.js +50 -0
- package/dist/workspace/layers.js.map +1 -0
- package/dist/workspace/mcp-server.d.ts +28 -0
- package/dist/workspace/mcp-server.d.ts.map +1 -0
- package/dist/workspace/mcp-server.js +190 -0
- package/dist/workspace/mcp-server.js.map +1 -0
- package/dist/workspace/mcp-stdio.d.ts +2 -0
- package/dist/workspace/mcp-stdio.d.ts.map +1 -0
- package/dist/workspace/mcp-stdio.js +66 -0
- package/dist/workspace/mcp-stdio.js.map +1 -0
- package/dist/workspace/mcp-tools.d.ts +24 -0
- package/dist/workspace/mcp-tools.d.ts.map +1 -0
- package/dist/workspace/mcp-tools.js +43 -0
- package/dist/workspace/mcp-tools.js.map +1 -0
- package/dist/workspace/migrate-v1.d.ts +12 -0
- package/dist/workspace/migrate-v1.d.ts.map +1 -0
- package/dist/workspace/migrate-v1.js +301 -0
- package/dist/workspace/migrate-v1.js.map +1 -0
- package/dist/workspace/ohtools-app.d.ts +3 -0
- package/dist/workspace/ohtools-app.d.ts.map +1 -0
- package/dist/workspace/ohtools-app.js +10 -0
- package/dist/workspace/ohtools-app.js.map +1 -0
- package/dist/workspace/repositories.d.ts +25 -0
- package/dist/workspace/repositories.d.ts.map +1 -0
- package/dist/workspace/repositories.js +76 -0
- package/dist/workspace/repositories.js.map +1 -0
- package/dist/workspace/runtime.d.ts +123 -0
- package/dist/workspace/runtime.d.ts.map +1 -0
- package/dist/workspace/runtime.js +4 -0
- package/dist/workspace/runtime.js.map +1 -0
- package/dist/workspace/session-liveness.d.ts +6 -0
- package/dist/workspace/session-liveness.d.ts.map +1 -0
- package/dist/workspace/session-liveness.js +3 -0
- package/dist/workspace/session-liveness.js.map +1 -0
- package/dist/workspace/status.d.ts +46 -0
- package/dist/workspace/status.d.ts.map +1 -0
- package/dist/workspace/status.js +345 -0
- package/dist/workspace/status.js.map +1 -0
- package/dist/workspace/storage-layout.d.ts +19 -0
- package/dist/workspace/storage-layout.d.ts.map +1 -0
- package/dist/workspace/storage-layout.js +55 -0
- package/dist/workspace/storage-layout.js.map +1 -0
- package/dist/workspace/storage-paths.d.ts +16 -0
- package/dist/workspace/storage-paths.d.ts.map +1 -0
- package/dist/workspace/storage-paths.js +15 -0
- package/dist/workspace/storage-paths.js.map +1 -0
- package/dist/workspace/v1-cli-aliases.d.ts +18 -0
- package/dist/workspace/v1-cli-aliases.d.ts.map +1 -0
- package/dist/workspace/v1-cli-aliases.js +223 -0
- package/dist/workspace/v1-cli-aliases.js.map +1 -0
- package/dist/workspace/v1-cli-task.d.ts +2 -0
- package/dist/workspace/v1-cli-task.d.ts.map +1 -0
- package/dist/workspace/v1-cli-task.js +53 -0
- package/dist/workspace/v1-cli-task.js.map +1 -0
- package/package.json +28 -12
- package/quickstart.md +163 -0
- package/hooks/need-info-notify/config.yml +0 -3
- package/hooks/need-info-notify/script.ts +0 -69
- package/hooks/review-spawn/config.yml +0 -3
- package/hooks/review-spawn/script.ts +0 -96
- package/src/cli/cli.ts +0 -489
- package/src/cli/init.ts +0 -230
- package/src/domain/fibonacci.ts +0 -39
- package/src/domain/kTokens.ts +0 -65
- package/src/domain/status-machine.ts +0 -49
- package/src/domain/types.ts +0 -66
- package/src/hook/hook-executor.ts +0 -70
- package/src/hook/ports.ts +0 -16
- package/src/infra/hook-config-loader.ts +0 -111
- package/src/infra/jsonl-task-repository.ts +0 -157
- package/src/infra/layer.ts +0 -34
- package/src/infra/logger.ts +0 -40
- package/src/infra/pid-session-registry.ts +0 -67
- package/src/mcp/error-codes.ts +0 -213
- package/src/mcp/server.ts +0 -396
- package/src/mcp/session.ts +0 -1
- package/src/mcp/tool-create-task.ts +0 -28
- package/src/mcp/tool-current-task.ts +0 -19
- package/src/mcp/tool-edit-task.ts +0 -40
- package/src/mcp/tool-list-tasks.ts +0 -34
- package/src/mcp/tool-update-task.ts +0 -55
- package/src/task/create-task.ts +0 -67
- package/src/task/current-task.ts +0 -111
- package/src/task/edit-task.ts +0 -59
- package/src/task/list-tasks.ts +0 -35
- package/src/task/ports.ts +0 -15
- package/src/task/session-registry.ts +0 -9
- package/src/task/update-task.ts +0 -160
|
@@ -0,0 +1,681 @@
|
|
|
1
|
+
import { nowIso } from "../../shared/time.js";
|
|
2
|
+
import { createSyncConflict } from "../../sync/conflicts.js";
|
|
3
|
+
import { appendSyncEvent } from "../../sync/events.js";
|
|
4
|
+
import { findExternalLink, upsertExternalLink } from "../../sync/external-links.js";
|
|
5
|
+
import { readLinearApiToken, readLinearWorkspaceConfig } from "../../sync/linear/config.js";
|
|
6
|
+
import { mapTaskToLinearIssueInput } from "../../sync/linear/mapping.js";
|
|
7
|
+
import { Context, Effect } from "effect";
|
|
8
|
+
const LINEAR_PROVIDER_ID = "linear";
|
|
9
|
+
const DEFAULT_COMMENT_PAGE_SIZE = 100;
|
|
10
|
+
const MAX_COMMENT_PAGE_SIZE = 100;
|
|
11
|
+
const LINEAR_CREATE_ISSUE_OPERATION = "LinearCreateIssue";
|
|
12
|
+
const LINEAR_UPDATE_ISSUE_OPERATION = "LinearUpdateIssue";
|
|
13
|
+
const LINEAR_CREATE_COMMENT_OPERATION = "LinearCreateComment";
|
|
14
|
+
const TaskRepository = Context.GenericTag("TaskRepository");
|
|
15
|
+
const SyncEventRepository = Context.GenericTag("SyncEventRepository");
|
|
16
|
+
const LinearGraphQLClientTag = Context.GenericTag("LinearGraphQLClient");
|
|
17
|
+
export const pushLinearSync = (input) => Effect.gen(function* () {
|
|
18
|
+
const configResult = yield* Effect.promise(() => readLinearWorkspaceConfig());
|
|
19
|
+
if (!configResult.ok) {
|
|
20
|
+
return configResult;
|
|
21
|
+
}
|
|
22
|
+
const config = configResult.data;
|
|
23
|
+
const taskRepo = (yield* TaskRepository);
|
|
24
|
+
const eventRepo = (yield* SyncEventRepository);
|
|
25
|
+
const client = (yield* LinearGraphQLClientTag);
|
|
26
|
+
const defaultTeamId = config?.defaultTeamId;
|
|
27
|
+
const defaultProjectId = config?.defaultProjectId;
|
|
28
|
+
const statusMapping = config?.statusMapping;
|
|
29
|
+
const labelMapping = config?.labelMapping;
|
|
30
|
+
if (readLinearApiToken(config) === undefined) {
|
|
31
|
+
return providerError("auth_failed", "Linear API token is required.", {
|
|
32
|
+
provider: LINEAR_PROVIDER_ID,
|
|
33
|
+
reason: "missing_token",
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const tasksResult = yield* loadTasks(taskRepo, input.taskIds);
|
|
37
|
+
if (!tasksResult.ok) {
|
|
38
|
+
return tasksResult;
|
|
39
|
+
}
|
|
40
|
+
const tasks = tasksResult.data;
|
|
41
|
+
let created = 0;
|
|
42
|
+
let updated = 0;
|
|
43
|
+
let skipped = 0;
|
|
44
|
+
let conflicts = 0;
|
|
45
|
+
const events = [];
|
|
46
|
+
for (const task of tasks) {
|
|
47
|
+
const linkResult = yield* findExternalLink({
|
|
48
|
+
provider: LINEAR_PROVIDER_ID,
|
|
49
|
+
localRecord: { kind: "task", id: task.id },
|
|
50
|
+
limit: 2,
|
|
51
|
+
});
|
|
52
|
+
if (!linkResult.ok) {
|
|
53
|
+
return linkResult;
|
|
54
|
+
}
|
|
55
|
+
const link = linkResult.data.externalLinks[0];
|
|
56
|
+
if (link === undefined) {
|
|
57
|
+
if (defaultTeamId === undefined || defaultTeamId.length === 0) {
|
|
58
|
+
const event = yield* appendAndCollect(events, eventRepo, {
|
|
59
|
+
direction: "push",
|
|
60
|
+
data: {
|
|
61
|
+
result: "skipped",
|
|
62
|
+
providerId: LINEAR_PROVIDER_ID,
|
|
63
|
+
entityType: "task",
|
|
64
|
+
entityId: task.id,
|
|
65
|
+
reason: "missing_mapping",
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
if (!event.ok) {
|
|
69
|
+
return event;
|
|
70
|
+
}
|
|
71
|
+
skipped += 1;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (input.dryRun) {
|
|
75
|
+
const event = yield* appendAndCollect(events, eventRepo, {
|
|
76
|
+
direction: "push",
|
|
77
|
+
data: {
|
|
78
|
+
result: "skipped",
|
|
79
|
+
providerId: LINEAR_PROVIDER_ID,
|
|
80
|
+
entityType: "task",
|
|
81
|
+
entityId: task.id,
|
|
82
|
+
reason: "dry_run",
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
if (!event.ok) {
|
|
86
|
+
return event;
|
|
87
|
+
}
|
|
88
|
+
skipped += 1;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const createProjectId = input.projectId ?? defaultProjectId;
|
|
92
|
+
const mapped = mapTaskToLinearIssueInput(task, {
|
|
93
|
+
...(defaultTeamId === undefined ? {} : { defaultTeamId }),
|
|
94
|
+
...(createProjectId === undefined ? {} : { defaultProjectId: createProjectId }),
|
|
95
|
+
...(statusMapping === undefined ? {} : { statusMapping }),
|
|
96
|
+
...(labelMapping === undefined ? {} : { labelMapping }),
|
|
97
|
+
});
|
|
98
|
+
if (!mapped.ok) {
|
|
99
|
+
return mapped;
|
|
100
|
+
}
|
|
101
|
+
const createdIssue = yield* Effect.either(client.request({
|
|
102
|
+
operationName: LINEAR_CREATE_ISSUE_OPERATION,
|
|
103
|
+
query: LINEAR_CREATE_ISSUE_QUERY,
|
|
104
|
+
variables: mapped.data.input,
|
|
105
|
+
}));
|
|
106
|
+
if (createdIssue._tag === "Left") {
|
|
107
|
+
const failure = yield* appendFailedEvent(events, eventRepo, {
|
|
108
|
+
entityType: "task",
|
|
109
|
+
entityId: task.id,
|
|
110
|
+
error: createdIssue.left,
|
|
111
|
+
});
|
|
112
|
+
if (!failure.ok) {
|
|
113
|
+
return failure;
|
|
114
|
+
}
|
|
115
|
+
return providerError("unknown", "Linear issue creation failed.", {
|
|
116
|
+
provider: LINEAR_PROVIDER_ID,
|
|
117
|
+
error: createdIssue.left,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
const createdRecord = createdIssue.right.issueCreate?.issue;
|
|
121
|
+
if (createdRecord === undefined || createdRecord === null) {
|
|
122
|
+
const failure = yield* appendFailedEvent(events, eventRepo, {
|
|
123
|
+
entityType: "task",
|
|
124
|
+
entityId: task.id,
|
|
125
|
+
error: {
|
|
126
|
+
providerId: LINEAR_PROVIDER_ID,
|
|
127
|
+
code: "not_found",
|
|
128
|
+
retryable: false,
|
|
129
|
+
message: "Linear issue creation returned no issue.",
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
if (!failure.ok) {
|
|
133
|
+
return failure;
|
|
134
|
+
}
|
|
135
|
+
return providerError("unknown", "Linear issue creation returned no issue.", {
|
|
136
|
+
provider: LINEAR_PROVIDER_ID,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
const commentResult = yield* pushTaskComments({
|
|
140
|
+
task,
|
|
141
|
+
issueId: createdRecord.id,
|
|
142
|
+
lastPushedLocalVersion: undefined,
|
|
143
|
+
client,
|
|
144
|
+
events,
|
|
145
|
+
eventRepo,
|
|
146
|
+
});
|
|
147
|
+
if (!commentResult.ok) {
|
|
148
|
+
return commentResult;
|
|
149
|
+
}
|
|
150
|
+
const now = yield* nowIso();
|
|
151
|
+
const linked = yield* upsertExternalLink({
|
|
152
|
+
provider: LINEAR_PROVIDER_ID,
|
|
153
|
+
localRecord: { kind: "task", id: task.id },
|
|
154
|
+
remoteRecord: {
|
|
155
|
+
id: createdRecord.id,
|
|
156
|
+
...(createdRecord.url === undefined || createdRecord.url === null
|
|
157
|
+
? {}
|
|
158
|
+
: { url: createdRecord.url }),
|
|
159
|
+
type: "issue",
|
|
160
|
+
},
|
|
161
|
+
lastSyncedAt: now,
|
|
162
|
+
lastSeenRemoteVersion: createdRecord.updatedAt,
|
|
163
|
+
lastPushedLocalVersion: task.updatedAt,
|
|
164
|
+
});
|
|
165
|
+
if (!linked.ok) {
|
|
166
|
+
return linked;
|
|
167
|
+
}
|
|
168
|
+
const event = yield* appendAndCollect(events, eventRepo, {
|
|
169
|
+
direction: "push",
|
|
170
|
+
data: {
|
|
171
|
+
result: "created",
|
|
172
|
+
providerId: LINEAR_PROVIDER_ID,
|
|
173
|
+
entityType: "task",
|
|
174
|
+
entityId: task.id,
|
|
175
|
+
remoteId: createdRecord.id,
|
|
176
|
+
fields: commentResult.data.pushedComments > 0
|
|
177
|
+
? ["title", "description", "status", "priority", "comments"]
|
|
178
|
+
: ["title", "description", "status", "priority"],
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
if (!event.ok) {
|
|
182
|
+
return event;
|
|
183
|
+
}
|
|
184
|
+
created += 1;
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const issueResult = yield* Effect.either(client.request({
|
|
188
|
+
operationName: "LinearGetIssue",
|
|
189
|
+
query: LINEAR_GET_ISSUE_QUERY,
|
|
190
|
+
variables: {
|
|
191
|
+
id: link.remoteRecord.id,
|
|
192
|
+
},
|
|
193
|
+
}));
|
|
194
|
+
if (issueResult._tag === "Left") {
|
|
195
|
+
const failure = yield* appendFailedEvent(events, eventRepo, {
|
|
196
|
+
entityType: "task",
|
|
197
|
+
entityId: task.id,
|
|
198
|
+
remoteId: link.remoteRecord.id,
|
|
199
|
+
error: issueResult.left,
|
|
200
|
+
});
|
|
201
|
+
if (!failure.ok) {
|
|
202
|
+
return failure;
|
|
203
|
+
}
|
|
204
|
+
return providerError("unknown", "Linear issue lookup failed.", {
|
|
205
|
+
provider: LINEAR_PROVIDER_ID,
|
|
206
|
+
error: issueResult.left,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
const remoteIssue = issueResult.right.issue;
|
|
210
|
+
if (remoteIssue === undefined || remoteIssue === null) {
|
|
211
|
+
const failure = yield* appendFailedEvent(events, eventRepo, {
|
|
212
|
+
entityType: "task",
|
|
213
|
+
entityId: task.id,
|
|
214
|
+
remoteId: link.remoteRecord.id,
|
|
215
|
+
error: {
|
|
216
|
+
providerId: LINEAR_PROVIDER_ID,
|
|
217
|
+
code: "not_found",
|
|
218
|
+
retryable: false,
|
|
219
|
+
message: "Linear issue was not found.",
|
|
220
|
+
},
|
|
221
|
+
});
|
|
222
|
+
if (!failure.ok) {
|
|
223
|
+
return failure;
|
|
224
|
+
}
|
|
225
|
+
return providerError("not_found", "Linear issue was not found.", {
|
|
226
|
+
provider: LINEAR_PROVIDER_ID,
|
|
227
|
+
remoteId: link.remoteRecord.id,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
const localChanged = link.lastPushedLocalVersion !== task.updatedAt;
|
|
231
|
+
const remoteChanged = link.lastSeenRemoteVersion !== remoteIssue.updatedAt;
|
|
232
|
+
if (localChanged && remoteChanged) {
|
|
233
|
+
const conflict = yield* createSyncConflict({
|
|
234
|
+
provider: LINEAR_PROVIDER_ID,
|
|
235
|
+
localRecord: { kind: "task", id: task.id },
|
|
236
|
+
remoteRecord: {
|
|
237
|
+
id: remoteIssue.id,
|
|
238
|
+
...(remoteIssue.url === undefined || remoteIssue.url === null
|
|
239
|
+
? {}
|
|
240
|
+
: { url: remoteIssue.url }),
|
|
241
|
+
},
|
|
242
|
+
fields: pushConflictFields(task, remoteIssue),
|
|
243
|
+
});
|
|
244
|
+
if (!conflict.ok) {
|
|
245
|
+
return conflict;
|
|
246
|
+
}
|
|
247
|
+
if (conflict.data.conflict !== undefined) {
|
|
248
|
+
const event = yield* appendAndCollect(events, eventRepo, {
|
|
249
|
+
direction: "push",
|
|
250
|
+
data: {
|
|
251
|
+
result: "conflict",
|
|
252
|
+
providerId: LINEAR_PROVIDER_ID,
|
|
253
|
+
conflictId: conflict.data.conflict.id,
|
|
254
|
+
entityType: "task",
|
|
255
|
+
entityId: task.id,
|
|
256
|
+
fields: [...conflict.data.decision.fields],
|
|
257
|
+
},
|
|
258
|
+
});
|
|
259
|
+
if (!event.ok) {
|
|
260
|
+
return event;
|
|
261
|
+
}
|
|
262
|
+
conflicts += 1;
|
|
263
|
+
}
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (!localChanged) {
|
|
267
|
+
const event = yield* appendAndCollect(events, eventRepo, {
|
|
268
|
+
direction: "push",
|
|
269
|
+
data: {
|
|
270
|
+
result: "skipped",
|
|
271
|
+
providerId: LINEAR_PROVIDER_ID,
|
|
272
|
+
entityType: "task",
|
|
273
|
+
entityId: task.id,
|
|
274
|
+
remoteId: remoteIssue.id,
|
|
275
|
+
reason: "unchanged",
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
if (!event.ok) {
|
|
279
|
+
return event;
|
|
280
|
+
}
|
|
281
|
+
skipped += 1;
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
if (input.dryRun) {
|
|
285
|
+
const event = yield* appendAndCollect(events, eventRepo, {
|
|
286
|
+
direction: "push",
|
|
287
|
+
data: {
|
|
288
|
+
result: "skipped",
|
|
289
|
+
providerId: LINEAR_PROVIDER_ID,
|
|
290
|
+
entityType: "task",
|
|
291
|
+
entityId: task.id,
|
|
292
|
+
remoteId: remoteIssue.id,
|
|
293
|
+
reason: "dry_run",
|
|
294
|
+
},
|
|
295
|
+
});
|
|
296
|
+
if (!event.ok) {
|
|
297
|
+
return event;
|
|
298
|
+
}
|
|
299
|
+
skipped += 1;
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
const updateTeamId = remoteIssue.team?.id ?? defaultTeamId;
|
|
303
|
+
const updateProjectId = input.projectId ?? defaultProjectId ?? remoteIssue.project?.id;
|
|
304
|
+
const mapped = mapTaskToLinearIssueInput(task, {
|
|
305
|
+
...(updateTeamId === undefined ? {} : { defaultTeamId: updateTeamId }),
|
|
306
|
+
...(updateProjectId === undefined ? {} : { defaultProjectId: updateProjectId }),
|
|
307
|
+
...(statusMapping === undefined ? {} : { statusMapping }),
|
|
308
|
+
...(labelMapping === undefined ? {} : { labelMapping }),
|
|
309
|
+
});
|
|
310
|
+
if (!mapped.ok) {
|
|
311
|
+
return mapped;
|
|
312
|
+
}
|
|
313
|
+
const updateInput = {
|
|
314
|
+
input: {
|
|
315
|
+
id: remoteIssue.id,
|
|
316
|
+
title: mapped.data.input.title,
|
|
317
|
+
description: mapped.data.input.description,
|
|
318
|
+
teamId: remoteIssue.team?.id ?? mapped.data.input.teamId,
|
|
319
|
+
...(mapped.data.input.projectId === undefined
|
|
320
|
+
? {}
|
|
321
|
+
: { projectId: mapped.data.input.projectId }),
|
|
322
|
+
...(mapped.data.input.stateId === undefined
|
|
323
|
+
? {}
|
|
324
|
+
: { stateId: mapped.data.input.stateId }),
|
|
325
|
+
priority: mapped.data.input.priority,
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
const issueUpdateResult = yield* Effect.either(client.request({
|
|
329
|
+
operationName: LINEAR_UPDATE_ISSUE_OPERATION,
|
|
330
|
+
query: LINEAR_UPDATE_ISSUE_QUERY,
|
|
331
|
+
variables: updateInput,
|
|
332
|
+
}));
|
|
333
|
+
if (issueUpdateResult._tag === "Left") {
|
|
334
|
+
const failure = yield* appendFailedEvent(events, eventRepo, {
|
|
335
|
+
entityType: "task",
|
|
336
|
+
entityId: task.id,
|
|
337
|
+
remoteId: remoteIssue.id,
|
|
338
|
+
error: issueUpdateResult.left,
|
|
339
|
+
});
|
|
340
|
+
if (!failure.ok) {
|
|
341
|
+
return failure;
|
|
342
|
+
}
|
|
343
|
+
return providerError("unknown", "Linear issue update failed.", {
|
|
344
|
+
provider: LINEAR_PROVIDER_ID,
|
|
345
|
+
error: issueUpdateResult.left,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
const updatedRecord = issueUpdateResult.right.issueUpdate?.issue;
|
|
349
|
+
if (updatedRecord === undefined || updatedRecord === null) {
|
|
350
|
+
const failure = yield* appendFailedEvent(events, eventRepo, {
|
|
351
|
+
entityType: "task",
|
|
352
|
+
entityId: task.id,
|
|
353
|
+
remoteId: remoteIssue.id,
|
|
354
|
+
error: {
|
|
355
|
+
providerId: LINEAR_PROVIDER_ID,
|
|
356
|
+
code: "not_found",
|
|
357
|
+
retryable: false,
|
|
358
|
+
message: "Linear issue update returned no issue.",
|
|
359
|
+
},
|
|
360
|
+
});
|
|
361
|
+
if (!failure.ok) {
|
|
362
|
+
return failure;
|
|
363
|
+
}
|
|
364
|
+
return providerError("unknown", "Linear issue update returned no issue.", {
|
|
365
|
+
provider: LINEAR_PROVIDER_ID,
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
const commentResult = yield* pushTaskComments({
|
|
369
|
+
task,
|
|
370
|
+
issueId: updatedRecord.id,
|
|
371
|
+
lastPushedLocalVersion: link.lastPushedLocalVersion,
|
|
372
|
+
client,
|
|
373
|
+
events,
|
|
374
|
+
eventRepo,
|
|
375
|
+
});
|
|
376
|
+
if (!commentResult.ok) {
|
|
377
|
+
return commentResult;
|
|
378
|
+
}
|
|
379
|
+
const now = yield* nowIso();
|
|
380
|
+
const linked = yield* upsertExternalLink({
|
|
381
|
+
provider: LINEAR_PROVIDER_ID,
|
|
382
|
+
localRecord: { kind: "task", id: task.id },
|
|
383
|
+
remoteRecord: {
|
|
384
|
+
id: updatedRecord.id,
|
|
385
|
+
...(updatedRecord.url === undefined || updatedRecord.url === null
|
|
386
|
+
? {}
|
|
387
|
+
: { url: updatedRecord.url }),
|
|
388
|
+
type: "issue",
|
|
389
|
+
},
|
|
390
|
+
lastSyncedAt: now,
|
|
391
|
+
lastSeenRemoteVersion: updatedRecord.updatedAt,
|
|
392
|
+
lastPushedLocalVersion: task.updatedAt,
|
|
393
|
+
});
|
|
394
|
+
if (!linked.ok) {
|
|
395
|
+
return linked;
|
|
396
|
+
}
|
|
397
|
+
const fields = ["title", "description", "status", "priority"];
|
|
398
|
+
const event = yield* appendAndCollect(events, eventRepo, {
|
|
399
|
+
direction: "push",
|
|
400
|
+
data: {
|
|
401
|
+
result: "updated",
|
|
402
|
+
providerId: LINEAR_PROVIDER_ID,
|
|
403
|
+
entityType: "task",
|
|
404
|
+
entityId: task.id,
|
|
405
|
+
remoteId: updatedRecord.id,
|
|
406
|
+
fields: commentResult.data.pushedComments > 0 ? [...fields, "comments"] : fields,
|
|
407
|
+
},
|
|
408
|
+
});
|
|
409
|
+
if (!event.ok) {
|
|
410
|
+
return event;
|
|
411
|
+
}
|
|
412
|
+
updated += 1;
|
|
413
|
+
}
|
|
414
|
+
return {
|
|
415
|
+
ok: true,
|
|
416
|
+
data: {
|
|
417
|
+
created,
|
|
418
|
+
updated,
|
|
419
|
+
skipped,
|
|
420
|
+
conflicts,
|
|
421
|
+
events,
|
|
422
|
+
},
|
|
423
|
+
};
|
|
424
|
+
});
|
|
425
|
+
const loadTasks = (taskRepo, taskIds) => Effect.gen(function* () {
|
|
426
|
+
if (taskIds === undefined || taskIds.length === 0) {
|
|
427
|
+
const tasks = yield* Effect.either(taskRepo.findByStatus("*"));
|
|
428
|
+
if (tasks._tag === "Left") {
|
|
429
|
+
return repositoryError(tasks.left);
|
|
430
|
+
}
|
|
431
|
+
return { ok: true, data: tasks.right };
|
|
432
|
+
}
|
|
433
|
+
const tasks = [];
|
|
434
|
+
for (const taskId of taskIds) {
|
|
435
|
+
const task = yield* Effect.either(taskRepo.findById(taskId));
|
|
436
|
+
if (task._tag === "Left") {
|
|
437
|
+
return repositoryError(task.left);
|
|
438
|
+
}
|
|
439
|
+
tasks.push(task.right);
|
|
440
|
+
}
|
|
441
|
+
return { ok: true, data: tasks };
|
|
442
|
+
});
|
|
443
|
+
const pushTaskComments = (input) => Effect.gen(function* () {
|
|
444
|
+
const comments = input.task.comments
|
|
445
|
+
.filter((comment) => comment.kind !== "sync")
|
|
446
|
+
.filter((comment) => input.lastPushedLocalVersion === undefined
|
|
447
|
+
? true
|
|
448
|
+
: comment.createdAt > input.lastPushedLocalVersion)
|
|
449
|
+
.sort((left, right) => left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id));
|
|
450
|
+
if (comments.length === 0) {
|
|
451
|
+
return {
|
|
452
|
+
ok: true,
|
|
453
|
+
data: { pushedComments: 0 },
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
const page = comments.slice(0, MAX_COMMENT_PAGE_SIZE);
|
|
457
|
+
if (comments.length > MAX_COMMENT_PAGE_SIZE) {
|
|
458
|
+
const event = yield* appendAndCollect(input.events, input.eventRepo, {
|
|
459
|
+
direction: "push",
|
|
460
|
+
data: {
|
|
461
|
+
result: "skipped",
|
|
462
|
+
providerId: LINEAR_PROVIDER_ID,
|
|
463
|
+
entityType: "task",
|
|
464
|
+
entityId: input.task.id,
|
|
465
|
+
remoteId: input.issueId,
|
|
466
|
+
reason: "filtered",
|
|
467
|
+
},
|
|
468
|
+
});
|
|
469
|
+
if (!event.ok) {
|
|
470
|
+
return event;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
for (const comment of page) {
|
|
474
|
+
const created = yield* Effect.either(input.client.request({
|
|
475
|
+
operationName: LINEAR_CREATE_COMMENT_OPERATION,
|
|
476
|
+
query: LINEAR_CREATE_COMMENT_QUERY,
|
|
477
|
+
variables: {
|
|
478
|
+
issueId: input.issueId,
|
|
479
|
+
body: comment.content,
|
|
480
|
+
},
|
|
481
|
+
}));
|
|
482
|
+
if (created._tag === "Left") {
|
|
483
|
+
return providerError("unknown", "Linear comment creation failed.", {
|
|
484
|
+
provider: LINEAR_PROVIDER_ID,
|
|
485
|
+
error: created.left,
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
if (created.right.commentCreate?.comment === undefined ||
|
|
489
|
+
created.right.commentCreate.comment === null) {
|
|
490
|
+
return providerError("unknown", "Linear comment creation returned no comment.", {
|
|
491
|
+
provider: LINEAR_PROVIDER_ID,
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
if (comments.length > MAX_COMMENT_PAGE_SIZE) {
|
|
496
|
+
return {
|
|
497
|
+
ok: true,
|
|
498
|
+
data: {
|
|
499
|
+
pushedComments: page.length,
|
|
500
|
+
},
|
|
501
|
+
warnings: [
|
|
502
|
+
{
|
|
503
|
+
code: "has_more",
|
|
504
|
+
message: "Linear comments exceeded the 100 item limit.",
|
|
505
|
+
details: {
|
|
506
|
+
providerId: LINEAR_PROVIDER_ID,
|
|
507
|
+
issueId: input.issueId,
|
|
508
|
+
hasMore: true,
|
|
509
|
+
limit: MAX_COMMENT_PAGE_SIZE,
|
|
510
|
+
cursor: {
|
|
511
|
+
providerId: LINEAR_PROVIDER_ID,
|
|
512
|
+
cursor: page[page.length - 1]?.id,
|
|
513
|
+
pageSize: DEFAULT_COMMENT_PAGE_SIZE,
|
|
514
|
+
},
|
|
515
|
+
},
|
|
516
|
+
},
|
|
517
|
+
],
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
return {
|
|
521
|
+
ok: true,
|
|
522
|
+
data: {
|
|
523
|
+
pushedComments: page.length,
|
|
524
|
+
},
|
|
525
|
+
};
|
|
526
|
+
});
|
|
527
|
+
const appendAndCollect = (events, eventRepo, input) => Effect.gen(function* () {
|
|
528
|
+
const result = yield* appendSyncEvent(input);
|
|
529
|
+
if (!result.ok) {
|
|
530
|
+
return result;
|
|
531
|
+
}
|
|
532
|
+
events.push(result.data.syncEvent);
|
|
533
|
+
const saved = yield* Effect.either(eventRepo.create(result.data.syncEvent));
|
|
534
|
+
if (saved._tag === "Left") {
|
|
535
|
+
return repositoryError(saved.left);
|
|
536
|
+
}
|
|
537
|
+
return {
|
|
538
|
+
ok: true,
|
|
539
|
+
data: undefined,
|
|
540
|
+
};
|
|
541
|
+
});
|
|
542
|
+
const appendFailedEvent = (events, eventRepo, input) => appendAndCollect(events, eventRepo, {
|
|
543
|
+
direction: "push",
|
|
544
|
+
data: {
|
|
545
|
+
result: "failed",
|
|
546
|
+
providerId: LINEAR_PROVIDER_ID,
|
|
547
|
+
...(input.entityType === undefined ? {} : { entityType: input.entityType }),
|
|
548
|
+
...(input.entityId === undefined ? {} : { entityId: input.entityId }),
|
|
549
|
+
...(input.remoteId === undefined ? {} : { remoteId: input.remoteId }),
|
|
550
|
+
error: normalizeProviderError(input.error),
|
|
551
|
+
},
|
|
552
|
+
});
|
|
553
|
+
const normalizeProviderError = (error) => isProviderError(error)
|
|
554
|
+
? error
|
|
555
|
+
: {
|
|
556
|
+
providerId: LINEAR_PROVIDER_ID,
|
|
557
|
+
code: "unknown",
|
|
558
|
+
retryable: false,
|
|
559
|
+
message: "Linear provider request failed.",
|
|
560
|
+
details: { error: String(error) },
|
|
561
|
+
};
|
|
562
|
+
const isProviderError = (value) => isRecord(value) &&
|
|
563
|
+
typeof value.providerId === "string" &&
|
|
564
|
+
typeof value.code === "string" &&
|
|
565
|
+
typeof value.retryable === "boolean" &&
|
|
566
|
+
typeof value.message === "string";
|
|
567
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
568
|
+
const repositoryError = (cause) => ({
|
|
569
|
+
ok: false,
|
|
570
|
+
error: {
|
|
571
|
+
code: "storage_error",
|
|
572
|
+
message: "Repository operation failed.",
|
|
573
|
+
...(cause === undefined ? {} : { details: { cause } }),
|
|
574
|
+
},
|
|
575
|
+
});
|
|
576
|
+
const providerError = (code, message, details) => ({
|
|
577
|
+
ok: false,
|
|
578
|
+
error: {
|
|
579
|
+
code,
|
|
580
|
+
message,
|
|
581
|
+
...(details === undefined ? {} : { details }),
|
|
582
|
+
},
|
|
583
|
+
});
|
|
584
|
+
const pushConflictFields = (task, issue) => [
|
|
585
|
+
["title", task.title, issue.title],
|
|
586
|
+
["description", task.description, issue.description ?? ""],
|
|
587
|
+
["status", task.status, mapLinearStateToTaskStatus(issue)],
|
|
588
|
+
["priority", task.priority, issue.priority ?? 0],
|
|
589
|
+
].map(([path, localValue, remoteValue]) => ({
|
|
590
|
+
path,
|
|
591
|
+
localValue,
|
|
592
|
+
remoteValue,
|
|
593
|
+
}));
|
|
594
|
+
const mapLinearStateToTaskStatus = (issue) => {
|
|
595
|
+
switch (issue.state?.type ?? "unstarted") {
|
|
596
|
+
case "backlog":
|
|
597
|
+
return "backlog";
|
|
598
|
+
case "unstarted":
|
|
599
|
+
return "todo";
|
|
600
|
+
case "started":
|
|
601
|
+
return "in_progress";
|
|
602
|
+
case "completed":
|
|
603
|
+
return "done";
|
|
604
|
+
case "canceled":
|
|
605
|
+
return "canceled";
|
|
606
|
+
default:
|
|
607
|
+
return "todo";
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
const LINEAR_CREATE_ISSUE_QUERY = `
|
|
611
|
+
mutation LinearCreateIssue($input: IssueCreateInput!) {
|
|
612
|
+
issueCreate(input: $input) {
|
|
613
|
+
issue {
|
|
614
|
+
id
|
|
615
|
+
identifier
|
|
616
|
+
url
|
|
617
|
+
title
|
|
618
|
+
description
|
|
619
|
+
priority
|
|
620
|
+
updatedAt
|
|
621
|
+
archivedAt
|
|
622
|
+
team { id key name }
|
|
623
|
+
project { id name }
|
|
624
|
+
state { id name type }
|
|
625
|
+
assignee { id name }
|
|
626
|
+
labels { nodes { id name } }
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
`;
|
|
631
|
+
const LINEAR_UPDATE_ISSUE_QUERY = `
|
|
632
|
+
mutation LinearUpdateIssue($input: IssueUpdateInput!) {
|
|
633
|
+
issueUpdate(input: $input) {
|
|
634
|
+
issue {
|
|
635
|
+
id
|
|
636
|
+
identifier
|
|
637
|
+
url
|
|
638
|
+
title
|
|
639
|
+
description
|
|
640
|
+
priority
|
|
641
|
+
updatedAt
|
|
642
|
+
archivedAt
|
|
643
|
+
team { id key name }
|
|
644
|
+
project { id name }
|
|
645
|
+
state { id name type }
|
|
646
|
+
assignee { id name }
|
|
647
|
+
labels { nodes { id name } }
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
`;
|
|
652
|
+
const LINEAR_CREATE_COMMENT_QUERY = `
|
|
653
|
+
mutation LinearCreateComment($issueId: String!, $body: String!) {
|
|
654
|
+
commentCreate(issueId: $issueId, body: $body) {
|
|
655
|
+
comment {
|
|
656
|
+
id
|
|
657
|
+
createdAt
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
`;
|
|
662
|
+
const LINEAR_GET_ISSUE_QUERY = `
|
|
663
|
+
query LinearGetIssue($id: String!) {
|
|
664
|
+
issue(id: $id) {
|
|
665
|
+
id
|
|
666
|
+
identifier
|
|
667
|
+
url
|
|
668
|
+
title
|
|
669
|
+
description
|
|
670
|
+
priority
|
|
671
|
+
updatedAt
|
|
672
|
+
archivedAt
|
|
673
|
+
team { id key name }
|
|
674
|
+
project { id name }
|
|
675
|
+
state { id name type }
|
|
676
|
+
assignee { id name }
|
|
677
|
+
labels { nodes { id name } }
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
`;
|
|
681
|
+
//# sourceMappingURL=push.js.map
|