@proletariat/cli 0.3.93 → 0.3.94
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/dist/commands/action/create.d.ts +1 -1
- package/dist/commands/action/delete.d.ts +1 -1
- package/dist/commands/action/index.d.ts +1 -1
- package/dist/commands/action/list.d.ts +1 -1
- package/dist/commands/action/run.d.ts +1 -1
- package/dist/commands/action/show.d.ts +1 -1
- package/dist/commands/action/update.d.ts +1 -1
- package/dist/commands/agent/cleanup.d.ts +1 -1
- package/dist/commands/agent/gc.d.ts +1 -1
- package/dist/commands/agent/index.d.ts +1 -1
- package/dist/commands/agent/list.d.ts +1 -1
- package/dist/commands/agent/login.d.ts +1 -1
- package/dist/commands/agent/rebuild.d.ts +1 -1
- package/dist/commands/agent/remove.d.ts +1 -1
- package/dist/commands/agent/restart.d.ts +1 -1
- package/dist/commands/agent/shell.d.ts +1 -1
- package/dist/commands/agent/staff/index.d.ts +1 -1
- package/dist/commands/agent/staff/remove.d.ts +1 -1
- package/dist/commands/agent/status.d.ts +1 -1
- package/dist/commands/agent/visit.d.ts +1 -1
- package/dist/commands/asana/import.d.ts +1 -1
- package/dist/commands/branch/create.d.ts +1 -1
- package/dist/commands/branch/index.d.ts +1 -1
- package/dist/commands/branch/list.d.ts +1 -1
- package/dist/commands/branch/validate.d.ts +1 -1
- package/dist/commands/branch/where.d.ts +1 -1
- package/dist/commands/config/index.js +2 -2
- package/dist/commands/config/index.js.map +1 -1
- package/dist/commands/diet.d.ts +1 -1
- package/dist/commands/docker/index.js +2 -0
- package/dist/commands/docker/index.js.map +1 -1
- package/dist/commands/docker/rebuild-cache.d.ts +12 -0
- package/dist/commands/docker/rebuild-cache.js +144 -0
- package/dist/commands/docker/rebuild-cache.js.map +1 -0
- package/dist/commands/execution/config.d.ts +1 -1
- package/dist/commands/execution/index.d.ts +1 -1
- package/dist/commands/execution/list.d.ts +1 -1
- package/dist/commands/execution/logs.d.ts +1 -1
- package/dist/commands/execution/stop.d.ts +1 -1
- package/dist/commands/execution/view.d.ts +1 -1
- package/dist/commands/hook/export.d.ts +1 -1
- package/dist/commands/hook/fire.d.ts +1 -1
- package/dist/commands/hook/index.d.ts +1 -1
- package/dist/commands/hook/list.d.ts +1 -1
- package/dist/commands/hook/preset.d.ts +1 -1
- package/dist/commands/linear/auth.d.ts +1 -1
- package/dist/commands/linear/connect.d.ts +1 -1
- package/dist/commands/linear/import.d.ts +1 -1
- package/dist/commands/linear/status.d.ts +1 -1
- package/dist/commands/linear/sync.d.ts +1 -1
- package/dist/commands/mcp-server.d.ts +8 -2
- package/dist/commands/mcp-server.js +15 -28
- package/dist/commands/mcp-server.js.map +1 -1
- package/dist/commands/monday/connect.d.ts +1 -1
- package/dist/commands/monday/sync.d.ts +1 -1
- package/dist/commands/orchestrate/index.d.ts +1 -1
- package/dist/commands/orchestrator/index.d.ts +1 -1
- package/dist/commands/orchestrator/start.d.ts +3 -3
- package/dist/commands/orchestrator/start.js +38 -40
- package/dist/commands/orchestrator/start.js.map +1 -1
- package/dist/commands/pr/checks.d.ts +1 -1
- package/dist/commands/pr/close.d.ts +1 -1
- package/dist/commands/pr/create.d.ts +1 -1
- package/dist/commands/pr/index.d.ts +1 -1
- package/dist/commands/pr/link.d.ts +1 -1
- package/dist/commands/pr/list.d.ts +1 -1
- package/dist/commands/pr/merge.d.ts +1 -1
- package/dist/commands/pr/status.d.ts +1 -1
- package/dist/commands/pull.d.ts +1 -1
- package/dist/commands/repo/add.d.ts +1 -1
- package/dist/commands/repo/create.d.ts +1 -1
- package/dist/commands/repo/fix-remotes.d.ts +1 -1
- package/dist/commands/repo/index.d.ts +1 -1
- package/dist/commands/repo/list.d.ts +1 -1
- package/dist/commands/repo/remove.d.ts +1 -1
- package/dist/commands/repo/view.d.ts +1 -1
- package/dist/commands/session/attach.d.ts +1 -1
- package/dist/commands/session/cleanup.d.ts +1 -1
- package/dist/commands/session/create.d.ts +1 -1
- package/dist/commands/session/exec.d.ts +1 -1
- package/dist/commands/session/health.d.ts +1 -1
- package/dist/commands/session/index.d.ts +1 -1
- package/dist/commands/session/inspect.d.ts +1 -1
- package/dist/commands/session/list.d.ts +1 -1
- package/dist/commands/session/peek.d.ts +1 -1
- package/dist/commands/session/prune.d.ts +1 -1
- package/dist/commands/session/report.d.ts +1 -1
- package/dist/commands/session/restart.d.ts +1 -1
- package/dist/commands/shortcut/connect.d.ts +1 -1
- package/dist/commands/support/logs.d.ts +1 -1
- package/dist/commands/ticket/create.d.ts +1 -1
- package/dist/commands/ticket/delete.d.ts +1 -1
- package/dist/commands/ticket/edit.d.ts +1 -1
- package/dist/commands/ticket/index.d.ts +1 -1
- package/dist/commands/ticket/index.js +6 -36
- package/dist/commands/ticket/index.js.map +1 -1
- package/dist/commands/ticket/list.d.ts +1 -1
- package/dist/commands/ticket/move.d.ts +1 -1
- package/dist/commands/ticket/show.d.ts +8 -7
- package/dist/commands/ticket/show.js +101 -8
- package/dist/commands/ticket/show.js.map +1 -1
- package/dist/commands/ticket/update.d.ts +1 -1
- package/dist/commands/trello/configure.d.ts +1 -1
- package/dist/commands/trello/import.d.ts +1 -1
- package/dist/commands/trello/sync.d.ts +1 -1
- package/dist/commands/work/asana.d.ts +1 -1
- package/dist/commands/work/complete.d.ts +1 -1
- package/dist/commands/work/groom.d.ts +1 -1
- package/dist/commands/work/hooks/add.d.ts +1 -1
- package/dist/commands/work/hooks/index.d.ts +1 -1
- package/dist/commands/work/hooks/list.d.ts +1 -1
- package/dist/commands/work/hooks/remove.d.ts +1 -1
- package/dist/commands/work/hooks/toggle.d.ts +1 -1
- package/dist/commands/work/implement.d.ts +1 -1
- package/dist/commands/work/index.d.ts +1 -1
- package/dist/commands/work/jira.d.ts +1 -1
- package/dist/commands/work/linear.d.ts +1 -1
- package/dist/commands/work/peek.d.ts +1 -1
- package/dist/commands/work/ready.d.ts +1 -1
- package/dist/commands/work/rebase.d.ts +1 -1
- package/dist/commands/work/resolve.d.ts +1 -1
- package/dist/commands/work/review.d.ts +1 -1
- package/dist/commands/work/ship.d.ts +1 -1
- package/dist/commands/work/shortcut.d.ts +1 -1
- package/dist/commands/work/source/set.d.ts +1 -1
- package/dist/commands/work/source.d.ts +1 -1
- package/dist/commands/work/spawn.d.ts +1 -1
- package/dist/commands/work/start.d.ts +1 -1
- package/dist/commands/work/status.d.ts +1 -1
- package/dist/commands/work/stop.d.ts +1 -1
- package/dist/commands/work/watch.d.ts +1 -1
- package/dist/hooks/init.js +1 -1
- package/dist/hooks/init.js.map +1 -1
- package/dist/lib/asana/config.js +13 -7
- package/dist/lib/asana/config.js.map +1 -1
- package/dist/lib/clickup/client.d.ts +92 -0
- package/dist/lib/clickup/client.js +150 -0
- package/dist/lib/clickup/client.js.map +1 -0
- package/dist/lib/clickup/config.d.ts +41 -0
- package/dist/lib/clickup/config.js +104 -0
- package/dist/lib/clickup/config.js.map +1 -0
- package/dist/lib/clickup/index.d.ts +4 -0
- package/dist/lib/clickup/index.js +4 -0
- package/dist/lib/clickup/index.js.map +1 -0
- package/dist/lib/clickup/types.d.ts +104 -0
- package/dist/lib/clickup/types.js +34 -0
- package/dist/lib/clickup/types.js.map +1 -0
- package/dist/lib/database/credential-store.d.ts +64 -0
- package/dist/lib/database/credential-store.js +306 -0
- package/dist/lib/database/credential-store.js.map +1 -0
- package/dist/lib/database/index.d.ts +1 -0
- package/dist/lib/database/index.js +2 -0
- package/dist/lib/database/index.js.map +1 -1
- package/dist/lib/database/pmo-bootstrap.d.ts +7 -0
- package/dist/lib/database/pmo-bootstrap.js +45 -20
- package/dist/lib/database/pmo-bootstrap.js.map +1 -1
- package/dist/lib/database/workspace.js +4 -0
- package/dist/lib/database/workspace.js.map +1 -1
- package/dist/lib/execution/devcontainer.js +51 -0
- package/dist/lib/execution/devcontainer.js.map +1 -1
- package/dist/lib/execution/runners/docker-management.d.ts +23 -0
- package/dist/lib/execution/runners/docker-management.js +99 -7
- package/dist/lib/execution/runners/docker-management.js.map +1 -1
- package/dist/lib/execution/session-utils.d.ts +4 -0
- package/dist/lib/execution/session-utils.js +34 -24
- package/dist/lib/execution/session-utils.js.map +1 -1
- package/dist/lib/execution/types.js +1 -1
- package/dist/lib/external-issues/types.d.ts +3 -3
- package/dist/lib/external-issues/types.js +1 -1
- package/dist/lib/external-issues/types.js.map +1 -1
- package/dist/lib/jira/config.js +10 -4
- package/dist/lib/jira/config.js.map +1 -1
- package/dist/lib/linear/config.js +13 -8
- package/dist/lib/linear/config.js.map +1 -1
- package/dist/lib/mcp/generator.d.ts +26 -0
- package/dist/lib/mcp/generator.js +219 -0
- package/dist/lib/mcp/generator.js.map +1 -0
- package/dist/lib/mcp/index.d.ts +1 -0
- package/dist/lib/mcp/index.js +1 -0
- package/dist/lib/mcp/index.js.map +1 -1
- package/dist/lib/mcp/tools/index.d.ts +0 -11
- package/dist/lib/mcp/tools/index.js +0 -11
- package/dist/lib/mcp/tools/index.js.map +1 -1
- package/dist/lib/mcp/tools/overrides/index.d.ts +23 -0
- package/dist/lib/mcp/tools/overrides/index.js +30 -0
- package/dist/lib/mcp/tools/overrides/index.js.map +1 -0
- package/dist/lib/mcp/tools/overrides/tmux.d.ts +11 -0
- package/dist/lib/mcp/tools/overrides/tmux.js +184 -0
- package/dist/lib/mcp/tools/overrides/tmux.js.map +1 -0
- package/dist/lib/mcp/tools/overrides/work-start.d.ts +12 -0
- package/dist/lib/mcp/tools/overrides/work-start.js +108 -0
- package/dist/lib/mcp/tools/overrides/work-start.js.map +1 -0
- package/dist/lib/mcp/tools/ticket.js +10 -48
- package/dist/lib/mcp/tools/ticket.js.map +1 -1
- package/dist/lib/monday/config.js +11 -5
- package/dist/lib/monday/config.js.map +1 -1
- package/dist/lib/pmo/base-command.d.ts +20 -152
- package/dist/lib/pmo/base-command.js +32 -198
- package/dist/lib/pmo/base-command.js.map +1 -1
- package/dist/lib/pmo/index.d.ts +1 -0
- package/dist/lib/pmo/index.js +3 -0
- package/dist/lib/pmo/index.js.map +1 -1
- package/dist/lib/pmo/storage/base.d.ts +0 -18
- package/dist/lib/pmo/storage/base.js +0 -231
- package/dist/lib/pmo/storage/base.js.map +1 -1
- package/dist/lib/pmo/storage/index.d.ts +1 -76
- package/dist/lib/pmo/storage/index.js +1 -215
- package/dist/lib/pmo/storage/index.js.map +1 -1
- package/dist/lib/pmo/storage/tickets.d.ts +2 -2
- package/dist/lib/pmo/storage/tickets.js +4 -34
- package/dist/lib/pmo/storage/tickets.js.map +1 -1
- package/dist/lib/pmo/types.d.ts +0 -37
- package/dist/lib/providers/clickup-provider.d.ts +28 -0
- package/dist/lib/providers/clickup-provider.js +353 -0
- package/dist/lib/providers/clickup-provider.js.map +1 -0
- package/dist/lib/providers/resolver.d.ts +1 -1
- package/dist/lib/providers/resolver.js +16 -5
- package/dist/lib/providers/resolver.js.map +1 -1
- package/dist/lib/providers/types.d.ts +1 -1
- package/dist/lib/runners/claude-code-runner.js +13 -4
- package/dist/lib/runners/claude-code-runner.js.map +1 -1
- package/dist/lib/runtime-command.d.ts +219 -0
- package/dist/lib/runtime-command.js +320 -0
- package/dist/lib/runtime-command.js.map +1 -0
- package/dist/lib/shortcut/config.js +13 -7
- package/dist/lib/shortcut/config.js.map +1 -1
- package/dist/lib/trello/config.js +17 -12
- package/dist/lib/trello/config.js.map +1 -1
- package/dist/lib/work-lifecycle/events.d.ts +1 -1
- package/dist/lib/work-source/config.d.ts +1 -1
- package/dist/lib/work-source/config.js +11 -1
- package/dist/lib/work-source/config.js.map +1 -1
- package/dist/lib/work-source/provider-sources.js +6 -1
- package/dist/lib/work-source/provider-sources.js.map +1 -1
- package/oclif.manifest.json +3015 -4827
- package/package.json +1 -1
- package/dist/commands/board/index.d.ts +0 -21
- package/dist/commands/board/index.js +0 -263
- package/dist/commands/board/index.js.map +0 -1
- package/dist/commands/board/view.d.ts +0 -15
- package/dist/commands/board/view.js +0 -137
- package/dist/commands/board/view.js.map +0 -1
- package/dist/commands/board/watch.d.ts +0 -15
- package/dist/commands/board/watch.js +0 -59
- package/dist/commands/board/watch.js.map +0 -1
- package/dist/commands/dashboard/index.d.ts +0 -14
- package/dist/commands/dashboard/index.js +0 -117
- package/dist/commands/dashboard/index.js.map +0 -1
- package/dist/commands/dashboard.d.ts +0 -38
- package/dist/commands/dashboard.js +0 -353
- package/dist/commands/dashboard.js.map +0 -1
- package/dist/commands/pmo/init.d.ts +0 -28
- package/dist/commands/pmo/init.js +0 -410
- package/dist/commands/pmo/init.js.map +0 -1
- package/dist/commands/project/archive.d.ts +0 -18
- package/dist/commands/project/archive.js +0 -79
- package/dist/commands/project/archive.js.map +0 -1
- package/dist/commands/project/create.d.ts +0 -24
- package/dist/commands/project/create.js +0 -191
- package/dist/commands/project/create.js.map +0 -1
- package/dist/commands/project/delete.d.ts +0 -18
- package/dist/commands/project/delete.js +0 -115
- package/dist/commands/project/delete.js.map +0 -1
- package/dist/commands/project/index.d.ts +0 -14
- package/dist/commands/project/index.js +0 -60
- package/dist/commands/project/index.js.map +0 -1
- package/dist/commands/project/list.d.ts +0 -16
- package/dist/commands/project/list.js +0 -115
- package/dist/commands/project/list.js.map +0 -1
- package/dist/commands/project/spec.d.ts +0 -19
- package/dist/commands/project/spec.js +0 -218
- package/dist/commands/project/spec.js.map +0 -1
- package/dist/commands/project/unarchive.d.ts +0 -17
- package/dist/commands/project/unarchive.js +0 -55
- package/dist/commands/project/unarchive.js.map +0 -1
- package/dist/commands/project/update.d.ts +0 -19
- package/dist/commands/project/update.js +0 -161
- package/dist/commands/project/update.js.map +0 -1
- package/dist/commands/project/view.d.ts +0 -17
- package/dist/commands/project/view.js +0 -107
- package/dist/commands/project/view.js.map +0 -1
- package/dist/commands/ticket/bulk.d.ts +0 -14
- package/dist/commands/ticket/bulk.js +0 -141
- package/dist/commands/ticket/bulk.js.map +0 -1
- package/dist/commands/ticket/cancel.d.ts +0 -17
- package/dist/commands/ticket/cancel.js +0 -206
- package/dist/commands/ticket/cancel.js.map +0 -1
- package/dist/commands/ticket/category.d.ts +0 -15
- package/dist/commands/ticket/category.js +0 -64
- package/dist/commands/ticket/category.js.map +0 -1
- package/dist/commands/ticket/complete.d.ts +0 -17
- package/dist/commands/ticket/complete.js +0 -193
- package/dist/commands/ticket/complete.js.map +0 -1
- package/dist/commands/ticket/epic.d.ts +0 -21
- package/dist/commands/ticket/epic.js +0 -306
- package/dist/commands/ticket/epic.js.map +0 -1
- package/dist/commands/ticket/link/block.d.ts +0 -15
- package/dist/commands/ticket/link/block.js +0 -96
- package/dist/commands/ticket/link/block.js.map +0 -1
- package/dist/commands/ticket/link/duplicates.d.ts +0 -15
- package/dist/commands/ticket/link/duplicates.js +0 -96
- package/dist/commands/ticket/link/duplicates.js.map +0 -1
- package/dist/commands/ticket/link/index.d.ts +0 -14
- package/dist/commands/ticket/link/index.js +0 -99
- package/dist/commands/ticket/link/index.js.map +0 -1
- package/dist/commands/ticket/link/relates.d.ts +0 -15
- package/dist/commands/ticket/link/relates.js +0 -96
- package/dist/commands/ticket/link/relates.js.map +0 -1
- package/dist/commands/ticket/project.d.ts +0 -19
- package/dist/commands/ticket/project.js +0 -257
- package/dist/commands/ticket/project.js.map +0 -1
- package/dist/commands/ticket/reassign.d.ts +0 -20
- package/dist/commands/ticket/reassign.js +0 -340
- package/dist/commands/ticket/reassign.js.map +0 -1
- package/dist/commands/ticket/resolve.d.ts +0 -68
- package/dist/commands/ticket/resolve.js +0 -306
- package/dist/commands/ticket/resolve.js.map +0 -1
- package/dist/commands/ticket/spec.d.ts +0 -19
- package/dist/commands/ticket/spec.js +0 -260
- package/dist/commands/ticket/spec.js.map +0 -1
- package/dist/commands/ticket/status.d.ts +0 -14
- package/dist/commands/ticket/status.js +0 -84
- package/dist/commands/ticket/status.js.map +0 -1
- package/dist/commands/ticket/view.d.ts +0 -14
- package/dist/commands/ticket/view.js +0 -113
- package/dist/commands/ticket/view.js.map +0 -1
- package/dist/lib/mcp/tools/board.d.ts +0 -6
- package/dist/lib/mcp/tools/board.js +0 -190
- package/dist/lib/mcp/tools/board.js.map +0 -1
- package/dist/lib/mcp/tools/category.d.ts +0 -6
- package/dist/lib/mcp/tools/category.js +0 -85
- package/dist/lib/mcp/tools/category.js.map +0 -1
- package/dist/lib/mcp/tools/epic.d.ts +0 -6
- package/dist/lib/mcp/tools/epic.js +0 -184
- package/dist/lib/mcp/tools/epic.js.map +0 -1
- package/dist/lib/mcp/tools/label.d.ts +0 -6
- package/dist/lib/mcp/tools/label.js +0 -339
- package/dist/lib/mcp/tools/label.js.map +0 -1
- package/dist/lib/mcp/tools/phase.d.ts +0 -6
- package/dist/lib/mcp/tools/phase.js +0 -132
- package/dist/lib/mcp/tools/phase.js.map +0 -1
- package/dist/lib/mcp/tools/project.d.ts +0 -6
- package/dist/lib/mcp/tools/project.js +0 -197
- package/dist/lib/mcp/tools/project.js.map +0 -1
- package/dist/lib/mcp/tools/roadmap.d.ts +0 -6
- package/dist/lib/mcp/tools/roadmap.js +0 -124
- package/dist/lib/mcp/tools/roadmap.js.map +0 -1
- package/dist/lib/mcp/tools/status.d.ts +0 -6
- package/dist/lib/mcp/tools/status.js +0 -110
- package/dist/lib/mcp/tools/status.js.map +0 -1
- package/dist/lib/mcp/tools/template.d.ts +0 -6
- package/dist/lib/mcp/tools/template.js +0 -108
- package/dist/lib/mcp/tools/template.js.map +0 -1
- package/dist/lib/mcp/tools/view.d.ts +0 -6
- package/dist/lib/mcp/tools/view.js +0 -77
- package/dist/lib/mcp/tools/view.js.map +0 -1
- package/dist/lib/mcp/tools/workflow.d.ts +0 -6
- package/dist/lib/mcp/tools/workflow.js +0 -96
- package/dist/lib/mcp/tools/workflow.js.map +0 -1
- package/dist/lib/pmo/storage/categories.d.ts +0 -50
- package/dist/lib/pmo/storage/categories.js +0 -206
- package/dist/lib/pmo/storage/categories.js.map +0 -1
- package/dist/lib/pmo/storage/labels.d.ts +0 -55
- package/dist/lib/pmo/storage/labels.js +0 -347
- package/dist/lib/pmo/storage/labels.js.map +0 -1
- package/dist/lib/pmo/storage/phases.d.ts +0 -65
- package/dist/lib/pmo/storage/phases.js +0 -393
- package/dist/lib/pmo/storage/phases.js.map +0 -1
- package/dist/lib/pmo/storage/roadmaps.d.ts +0 -64
- package/dist/lib/pmo/storage/roadmaps.js +0 -373
- package/dist/lib/pmo/storage/roadmaps.js.map +0 -1
- package/dist/lib/pmo/storage/views.d.ts +0 -57
- package/dist/lib/pmo/storage/views.js +0 -456
- package/dist/lib/pmo/storage/views.js.map +0 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClickUp Integration Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the ClickUp ↔ PMO integration layer.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Represents a ClickUp task as fetched from the API.
|
|
8
|
+
*/
|
|
9
|
+
export interface ClickUpTask {
|
|
10
|
+
id: string;
|
|
11
|
+
custom_id: string | null;
|
|
12
|
+
name: string;
|
|
13
|
+
description: string | null;
|
|
14
|
+
status: {
|
|
15
|
+
id: string;
|
|
16
|
+
status: string;
|
|
17
|
+
type: string;
|
|
18
|
+
color: string;
|
|
19
|
+
};
|
|
20
|
+
priority: {
|
|
21
|
+
id: string;
|
|
22
|
+
priority: string;
|
|
23
|
+
color: string;
|
|
24
|
+
} | null;
|
|
25
|
+
assignees: Array<{
|
|
26
|
+
id: number;
|
|
27
|
+
username: string;
|
|
28
|
+
email: string;
|
|
29
|
+
profilePicture: string | null;
|
|
30
|
+
}>;
|
|
31
|
+
tags: Array<{
|
|
32
|
+
name: string;
|
|
33
|
+
tag_fg: string;
|
|
34
|
+
tag_bg: string;
|
|
35
|
+
}>;
|
|
36
|
+
list: {
|
|
37
|
+
id: string;
|
|
38
|
+
name: string;
|
|
39
|
+
};
|
|
40
|
+
folder: {
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
};
|
|
44
|
+
space: {
|
|
45
|
+
id: string;
|
|
46
|
+
};
|
|
47
|
+
url: string;
|
|
48
|
+
date_created: string;
|
|
49
|
+
date_updated: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Represents a ClickUp status in a list/space.
|
|
53
|
+
*/
|
|
54
|
+
export interface ClickUpStatus {
|
|
55
|
+
id: string;
|
|
56
|
+
status: string;
|
|
57
|
+
type: string;
|
|
58
|
+
color: string;
|
|
59
|
+
orderindex: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Represents a ClickUp space.
|
|
63
|
+
*/
|
|
64
|
+
export interface ClickUpSpace {
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
statuses: ClickUpStatus[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Represents a ClickUp list.
|
|
71
|
+
*/
|
|
72
|
+
export interface ClickUpList {
|
|
73
|
+
id: string;
|
|
74
|
+
name: string;
|
|
75
|
+
statuses: ClickUpStatus[];
|
|
76
|
+
folder: {
|
|
77
|
+
id: string;
|
|
78
|
+
name: string;
|
|
79
|
+
};
|
|
80
|
+
space: {
|
|
81
|
+
id: string;
|
|
82
|
+
name: string;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* ClickUp connection configuration stored in workspace_settings.
|
|
87
|
+
*/
|
|
88
|
+
export interface ClickUpConfig {
|
|
89
|
+
apiKey: string;
|
|
90
|
+
defaultListId?: string;
|
|
91
|
+
defaultListName?: string;
|
|
92
|
+
workspaceName?: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Priority mapping between ClickUp and PMO (P0-P3).
|
|
96
|
+
* ClickUp: 1=Urgent, 2=High, 3=Normal, 4=Low
|
|
97
|
+
* PMO: P0=Critical, P1=High, P2=Medium, P3=Low
|
|
98
|
+
*/
|
|
99
|
+
export declare const CLICKUP_PRIORITY_TO_PMO: Record<string, string>;
|
|
100
|
+
export declare const PMO_PRIORITY_TO_CLICKUP: Record<string, number>;
|
|
101
|
+
/**
|
|
102
|
+
* Map ClickUp status type to PMO state category.
|
|
103
|
+
*/
|
|
104
|
+
export declare const CLICKUP_STATUS_TYPE_TO_PMO_CATEGORY: Record<string, string>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ClickUp Integration Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the ClickUp ↔ PMO integration layer.
|
|
5
|
+
*/
|
|
6
|
+
// =============================================================================
|
|
7
|
+
// Mapping Types
|
|
8
|
+
// =============================================================================
|
|
9
|
+
/**
|
|
10
|
+
* Priority mapping between ClickUp and PMO (P0-P3).
|
|
11
|
+
* ClickUp: 1=Urgent, 2=High, 3=Normal, 4=Low
|
|
12
|
+
* PMO: P0=Critical, P1=High, P2=Medium, P3=Low
|
|
13
|
+
*/
|
|
14
|
+
export const CLICKUP_PRIORITY_TO_PMO = {
|
|
15
|
+
'1': 'P0', // Urgent → Critical
|
|
16
|
+
'2': 'P1', // High → High
|
|
17
|
+
'3': 'P2', // Normal → Medium
|
|
18
|
+
'4': 'P3', // Low → Low
|
|
19
|
+
};
|
|
20
|
+
export const PMO_PRIORITY_TO_CLICKUP = {
|
|
21
|
+
P0: 1, // Critical → Urgent
|
|
22
|
+
P1: 2, // High → High
|
|
23
|
+
P2: 3, // Medium → Normal
|
|
24
|
+
P3: 4, // Low → Low
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Map ClickUp status type to PMO state category.
|
|
28
|
+
*/
|
|
29
|
+
export const CLICKUP_STATUS_TYPE_TO_PMO_CATEGORY = {
|
|
30
|
+
open: 'unstarted',
|
|
31
|
+
custom: 'started',
|
|
32
|
+
closed: 'completed',
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/clickup/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuGH,gFAAgF;AAChF,gBAAgB;AAChB,gFAAgF;AAEhF;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAA2B;IAC7D,GAAG,EAAE,IAAI,EAAI,oBAAoB;IACjC,GAAG,EAAE,IAAI,EAAI,cAAc;IAC3B,GAAG,EAAE,IAAI,EAAI,kBAAkB;IAC/B,GAAG,EAAE,IAAI,EAAI,YAAY;CAC1B,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAA2B;IAC7D,EAAE,EAAE,CAAC,EAAM,oBAAoB;IAC/B,EAAE,EAAE,CAAC,EAAM,cAAc;IACzB,EAAE,EAAE,CAAC,EAAM,kBAAkB;IAC7B,EAAE,EAAE,CAAC,EAAM,YAAY;CACxB,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAA2B;IACzE,IAAI,EAAE,WAAW;IACjB,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,WAAW;CACpB,CAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential Store
|
|
3
|
+
*
|
|
4
|
+
* Stores API keys and tokens in a separate credentials.db file
|
|
5
|
+
* that is NOT mounted into agent containers. This prevents agents
|
|
6
|
+
* from reading or leaking credentials.
|
|
7
|
+
*
|
|
8
|
+
* Credentials are stored at {workspacePath}/.proletariat-credentials/credentials.db
|
|
9
|
+
* while the main workspace.db lives at {workspacePath}/.proletariat/workspace.db.
|
|
10
|
+
* Only .proletariat/ is mounted into containers, keeping credentials isolated.
|
|
11
|
+
*
|
|
12
|
+
* PRLT-1114: Agent secret isolation
|
|
13
|
+
*/
|
|
14
|
+
import Database from 'better-sqlite3';
|
|
15
|
+
/**
|
|
16
|
+
* Check if a workspace_settings key stores a credential (API key or token).
|
|
17
|
+
*/
|
|
18
|
+
export declare function isCredentialKey(key: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Get the path to the credentials database for a workspace.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getCredentialDatabasePath(workspacePath: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Get a credential value, with automatic migration from workspace.db.
|
|
25
|
+
*
|
|
26
|
+
* Resolution order:
|
|
27
|
+
* 1. Check credentials.db (if available)
|
|
28
|
+
* 2. Fall back to workspace.db (for backward compatibility)
|
|
29
|
+
* 3. If found in workspace.db, migrate to credentials.db and delete from workspace.db
|
|
30
|
+
*
|
|
31
|
+
* In agent containers, credentials.db won't exist and workspace.db will have
|
|
32
|
+
* credentials removed — so this returns null, which is the desired behavior.
|
|
33
|
+
*
|
|
34
|
+
* For in-memory databases (tests), falls back to workspace_settings directly
|
|
35
|
+
* since there's no filesystem path to store credentials.db.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getCredential(workspaceDb: Database.Database, key: string): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Set a credential value. Always writes to credentials.db.
|
|
40
|
+
* Also removes from workspace.db if present (migration cleanup).
|
|
41
|
+
* For in-memory databases (tests), writes to workspace_settings directly.
|
|
42
|
+
*/
|
|
43
|
+
export declare function setCredential(workspaceDb: Database.Database, key: string, value: string): void;
|
|
44
|
+
/**
|
|
45
|
+
* Delete a credential from both credentials.db and workspace.db.
|
|
46
|
+
* For in-memory databases (tests), deletes from workspace_settings directly.
|
|
47
|
+
*/
|
|
48
|
+
export declare function deleteCredential(workspaceDb: Database.Database, key: string): void;
|
|
49
|
+
/**
|
|
50
|
+
* Check if a credential exists in either credentials.db or workspace.db.
|
|
51
|
+
*/
|
|
52
|
+
export declare function hasCredential(workspaceDb: Database.Database, key: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Close all cached credential database connections.
|
|
55
|
+
* Call this during cleanup/shutdown.
|
|
56
|
+
*/
|
|
57
|
+
export declare function closeAllCredentialStores(): void;
|
|
58
|
+
/**
|
|
59
|
+
* Eagerly migrate all known credential keys from workspace.db to credentials.db.
|
|
60
|
+
* This is safe to call multiple times (idempotent).
|
|
61
|
+
* Useful during workspace open to proactively move all credentials out.
|
|
62
|
+
* No-op for in-memory databases (tests).
|
|
63
|
+
*/
|
|
64
|
+
export declare function migrateCredentials(workspaceDb: Database.Database): void;
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Credential Store
|
|
3
|
+
*
|
|
4
|
+
* Stores API keys and tokens in a separate credentials.db file
|
|
5
|
+
* that is NOT mounted into agent containers. This prevents agents
|
|
6
|
+
* from reading or leaking credentials.
|
|
7
|
+
*
|
|
8
|
+
* Credentials are stored at {workspacePath}/.proletariat-credentials/credentials.db
|
|
9
|
+
* while the main workspace.db lives at {workspacePath}/.proletariat/workspace.db.
|
|
10
|
+
* Only .proletariat/ is mounted into containers, keeping credentials isolated.
|
|
11
|
+
*
|
|
12
|
+
* PRLT-1114: Agent secret isolation
|
|
13
|
+
*/
|
|
14
|
+
import Database from 'better-sqlite3';
|
|
15
|
+
import * as fs from 'node:fs';
|
|
16
|
+
import * as path from 'node:path';
|
|
17
|
+
const CREDENTIALS_TABLE = 'credentials';
|
|
18
|
+
/** Known credential setting keys that must be stored in credentials.db */
|
|
19
|
+
const CREDENTIAL_KEYS = new Set([
|
|
20
|
+
'linear.api_key',
|
|
21
|
+
'jira.api_token',
|
|
22
|
+
'asana.access_token',
|
|
23
|
+
'trello.api_key',
|
|
24
|
+
'trello.api_token',
|
|
25
|
+
'shortcut.api_token',
|
|
26
|
+
'monday.api_token',
|
|
27
|
+
'clickup.api_key',
|
|
28
|
+
]);
|
|
29
|
+
/**
|
|
30
|
+
* Check if a workspace_settings key stores a credential (API key or token).
|
|
31
|
+
*/
|
|
32
|
+
export function isCredentialKey(key) {
|
|
33
|
+
return CREDENTIAL_KEYS.has(key);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Get the path to the credentials database for a workspace.
|
|
37
|
+
*/
|
|
38
|
+
export function getCredentialDatabasePath(workspacePath) {
|
|
39
|
+
return path.join(workspacePath, '.proletariat-credentials', 'credentials.db');
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Derive the workspace root path from a workspace.db Database instance.
|
|
43
|
+
* workspace.db is at {workspacePath}/.proletariat/workspace.db
|
|
44
|
+
* Returns empty string for in-memory databases (used in tests).
|
|
45
|
+
*/
|
|
46
|
+
function deriveWorkspacePath(db) {
|
|
47
|
+
const dbName = db.name;
|
|
48
|
+
// In-memory or unnamed databases don't have a filesystem path
|
|
49
|
+
if (!dbName || dbName === ':memory:' || dbName === '')
|
|
50
|
+
return '';
|
|
51
|
+
return path.dirname(path.dirname(dbName));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Open or create the credentials database.
|
|
55
|
+
* Creates the directory and schema if they don't exist.
|
|
56
|
+
*/
|
|
57
|
+
function openCredentialDb(workspacePath) {
|
|
58
|
+
const dbPath = getCredentialDatabasePath(workspacePath);
|
|
59
|
+
const dir = path.dirname(dbPath);
|
|
60
|
+
if (!fs.existsSync(dir)) {
|
|
61
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
62
|
+
}
|
|
63
|
+
const credDb = new Database(dbPath);
|
|
64
|
+
credDb.pragma('journal_mode = WAL');
|
|
65
|
+
credDb.pragma('foreign_keys = ON');
|
|
66
|
+
credDb.pragma('busy_timeout = 5000');
|
|
67
|
+
credDb.exec(`
|
|
68
|
+
CREATE TABLE IF NOT EXISTS ${CREDENTIALS_TABLE} (
|
|
69
|
+
key TEXT PRIMARY KEY,
|
|
70
|
+
value TEXT NOT NULL
|
|
71
|
+
)
|
|
72
|
+
`);
|
|
73
|
+
return credDb;
|
|
74
|
+
}
|
|
75
|
+
// Cache open credential db connections keyed by workspace path
|
|
76
|
+
const credentialDbCache = new Map();
|
|
77
|
+
/**
|
|
78
|
+
* Get a cached credential database connection.
|
|
79
|
+
* Returns null if credentials.db cannot be opened (e.g., in agent containers
|
|
80
|
+
* where the credentials directory is not mounted).
|
|
81
|
+
*/
|
|
82
|
+
function getCachedCredentialDb(workspacePath, autoCreate) {
|
|
83
|
+
const cached = credentialDbCache.get(workspacePath);
|
|
84
|
+
if (cached) {
|
|
85
|
+
try {
|
|
86
|
+
cached.pragma('journal_mode');
|
|
87
|
+
return cached;
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
credentialDbCache.delete(workspacePath);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const dbPath = getCredentialDatabasePath(workspacePath);
|
|
94
|
+
const dir = path.dirname(dbPath);
|
|
95
|
+
// If the credentials directory doesn't exist and we're not auto-creating,
|
|
96
|
+
// return null. This is expected in agent containers where only .proletariat/
|
|
97
|
+
// is mounted, not .proletariat-credentials/.
|
|
98
|
+
if (!autoCreate && !fs.existsSync(dir)) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
const credDb = openCredentialDb(workspacePath);
|
|
103
|
+
credentialDbCache.set(workspacePath, credDb);
|
|
104
|
+
return credDb;
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get a credential value, with automatic migration from workspace.db.
|
|
112
|
+
*
|
|
113
|
+
* Resolution order:
|
|
114
|
+
* 1. Check credentials.db (if available)
|
|
115
|
+
* 2. Fall back to workspace.db (for backward compatibility)
|
|
116
|
+
* 3. If found in workspace.db, migrate to credentials.db and delete from workspace.db
|
|
117
|
+
*
|
|
118
|
+
* In agent containers, credentials.db won't exist and workspace.db will have
|
|
119
|
+
* credentials removed — so this returns null, which is the desired behavior.
|
|
120
|
+
*
|
|
121
|
+
* For in-memory databases (tests), falls back to workspace_settings directly
|
|
122
|
+
* since there's no filesystem path to store credentials.db.
|
|
123
|
+
*/
|
|
124
|
+
export function getCredential(workspaceDb, key) {
|
|
125
|
+
const workspacePath = deriveWorkspacePath(workspaceDb);
|
|
126
|
+
// In-memory databases (tests) — use workspace_settings directly
|
|
127
|
+
if (!workspacePath) {
|
|
128
|
+
try {
|
|
129
|
+
const row = workspaceDb
|
|
130
|
+
.prepare('SELECT value FROM workspace_settings WHERE key = ?')
|
|
131
|
+
.get(key);
|
|
132
|
+
return row?.value ?? null;
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// Check credentials.db first (don't auto-create just for reads)
|
|
139
|
+
const credDb = getCachedCredentialDb(workspacePath, false);
|
|
140
|
+
if (credDb) {
|
|
141
|
+
const row = credDb
|
|
142
|
+
.prepare(`SELECT value FROM ${CREDENTIALS_TABLE} WHERE key = ?`)
|
|
143
|
+
.get(key);
|
|
144
|
+
if (row)
|
|
145
|
+
return row.value;
|
|
146
|
+
}
|
|
147
|
+
// Fall back to workspace.db (backward compatibility + auto-migration)
|
|
148
|
+
let fallbackValue = null;
|
|
149
|
+
try {
|
|
150
|
+
const fallbackRow = workspaceDb
|
|
151
|
+
.prepare('SELECT value FROM workspace_settings WHERE key = ?')
|
|
152
|
+
.get(key);
|
|
153
|
+
fallbackValue = fallbackRow?.value ?? null;
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
// workspace.db may not have the table yet
|
|
157
|
+
}
|
|
158
|
+
if (fallbackValue) {
|
|
159
|
+
// Auto-migrate: move credential to credentials.db (auto-create on write)
|
|
160
|
+
const writeDb = getCachedCredentialDb(workspacePath, true);
|
|
161
|
+
if (writeDb) {
|
|
162
|
+
writeDb
|
|
163
|
+
.prepare(`INSERT OR REPLACE INTO ${CREDENTIALS_TABLE} (key, value) VALUES (?, ?)`)
|
|
164
|
+
.run(key, fallbackValue);
|
|
165
|
+
}
|
|
166
|
+
// Remove from workspace.db so agents can't see it
|
|
167
|
+
try {
|
|
168
|
+
workspaceDb.prepare('DELETE FROM workspace_settings WHERE key = ?').run(key);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
// workspace.db may be read-only in containers
|
|
172
|
+
}
|
|
173
|
+
return fallbackValue;
|
|
174
|
+
}
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Set a credential value. Always writes to credentials.db.
|
|
179
|
+
* Also removes from workspace.db if present (migration cleanup).
|
|
180
|
+
* For in-memory databases (tests), writes to workspace_settings directly.
|
|
181
|
+
*/
|
|
182
|
+
export function setCredential(workspaceDb, key, value) {
|
|
183
|
+
const workspacePath = deriveWorkspacePath(workspaceDb);
|
|
184
|
+
// In-memory databases (tests) — use workspace_settings directly
|
|
185
|
+
if (!workspacePath) {
|
|
186
|
+
workspaceDb.prepare(`
|
|
187
|
+
INSERT INTO workspace_settings (key, value)
|
|
188
|
+
VALUES (?, ?)
|
|
189
|
+
ON CONFLICT(key) DO UPDATE SET value = excluded.value
|
|
190
|
+
`).run(key, value);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const credDb = getCachedCredentialDb(workspacePath, true);
|
|
194
|
+
if (!credDb) {
|
|
195
|
+
throw new Error(`Cannot open credential store at ${getCredentialDatabasePath(workspacePath)}`);
|
|
196
|
+
}
|
|
197
|
+
credDb
|
|
198
|
+
.prepare(`INSERT OR REPLACE INTO ${CREDENTIALS_TABLE} (key, value) VALUES (?, ?)`)
|
|
199
|
+
.run(key, value);
|
|
200
|
+
// Clean up from workspace.db if it was there
|
|
201
|
+
try {
|
|
202
|
+
workspaceDb.prepare('DELETE FROM workspace_settings WHERE key = ?').run(key);
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
// workspace.db may be read-only in containers
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Delete a credential from both credentials.db and workspace.db.
|
|
210
|
+
* For in-memory databases (tests), deletes from workspace_settings directly.
|
|
211
|
+
*/
|
|
212
|
+
export function deleteCredential(workspaceDb, key) {
|
|
213
|
+
const workspacePath = deriveWorkspacePath(workspaceDb);
|
|
214
|
+
// In-memory databases (tests) — use workspace_settings directly
|
|
215
|
+
if (!workspacePath) {
|
|
216
|
+
try {
|
|
217
|
+
workspaceDb.prepare('DELETE FROM workspace_settings WHERE key = ?').run(key);
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
// Table may not exist
|
|
221
|
+
}
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const credDb = getCachedCredentialDb(workspacePath, false);
|
|
225
|
+
if (credDb) {
|
|
226
|
+
credDb.prepare(`DELETE FROM ${CREDENTIALS_TABLE} WHERE key = ?`).run(key);
|
|
227
|
+
}
|
|
228
|
+
// Also delete from workspace.db in case it's still there
|
|
229
|
+
try {
|
|
230
|
+
workspaceDb.prepare('DELETE FROM workspace_settings WHERE key = ?').run(key);
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
// workspace.db may be read-only
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Check if a credential exists in either credentials.db or workspace.db.
|
|
238
|
+
*/
|
|
239
|
+
export function hasCredential(workspaceDb, key) {
|
|
240
|
+
return getCredential(workspaceDb, key) !== null;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Close all cached credential database connections.
|
|
244
|
+
* Call this during cleanup/shutdown.
|
|
245
|
+
*/
|
|
246
|
+
export function closeAllCredentialStores() {
|
|
247
|
+
for (const [, db] of credentialDbCache) {
|
|
248
|
+
try {
|
|
249
|
+
db.close();
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
// Ignore close errors
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
credentialDbCache.clear();
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Eagerly migrate all known credential keys from workspace.db to credentials.db.
|
|
259
|
+
* This is safe to call multiple times (idempotent).
|
|
260
|
+
* Useful during workspace open to proactively move all credentials out.
|
|
261
|
+
* No-op for in-memory databases (tests).
|
|
262
|
+
*/
|
|
263
|
+
export function migrateCredentials(workspaceDb) {
|
|
264
|
+
const workspacePath = deriveWorkspacePath(workspaceDb);
|
|
265
|
+
if (!workspacePath)
|
|
266
|
+
return; // In-memory databases (tests)
|
|
267
|
+
// Check if any credentials exist in workspace.db
|
|
268
|
+
let hasAny = false;
|
|
269
|
+
try {
|
|
270
|
+
for (const key of CREDENTIAL_KEYS) {
|
|
271
|
+
const row = workspaceDb
|
|
272
|
+
.prepare('SELECT value FROM workspace_settings WHERE key = ?')
|
|
273
|
+
.get(key);
|
|
274
|
+
if (row) {
|
|
275
|
+
hasAny = true;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
return; // workspace_settings table may not exist
|
|
282
|
+
}
|
|
283
|
+
if (!hasAny)
|
|
284
|
+
return;
|
|
285
|
+
// Open/create credentials.db and migrate
|
|
286
|
+
const credDb = getCachedCredentialDb(workspacePath, true);
|
|
287
|
+
if (!credDb)
|
|
288
|
+
return;
|
|
289
|
+
for (const key of CREDENTIAL_KEYS) {
|
|
290
|
+
try {
|
|
291
|
+
const row = workspaceDb
|
|
292
|
+
.prepare('SELECT value FROM workspace_settings WHERE key = ?')
|
|
293
|
+
.get(key);
|
|
294
|
+
if (row) {
|
|
295
|
+
credDb
|
|
296
|
+
.prepare(`INSERT OR REPLACE INTO ${CREDENTIALS_TABLE} (key, value) VALUES (?, ?)`)
|
|
297
|
+
.run(key, row.value);
|
|
298
|
+
workspaceDb.prepare('DELETE FROM workspace_settings WHERE key = ?').run(key);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
// Skip individual key failures
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=credential-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-store.js","sourceRoot":"","sources":["../../../src/lib/database/credential-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAA;AACrC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,MAAM,iBAAiB,GA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D,GAAG,CAAC,GAAG,CAAkC,CAAA;YAC5C,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM,GAAG,IAAI,CAAA;gBACb,MAAK;YACP,CAAC;QACH,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAM,CAAC,yCAAyC;IAClD,CAAC;IAED,IAAI,CAAC,MAAM;QAAE,OAAM;IAEnB,yCAAyC;IACzC,MAAM,MAAM,GAAG,qBAAqB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;IACzD,IAAI,CAAC,MAAM;QAAE,OAAM;IAEnB,KAAK,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QAClC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,WAAW;iBACpB,OAAO,CAAC,oDAAoD,CAAC;iBAC7D,GAAG,CAAC,GAAG,CAAkC,CAAA;YAC5C,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM;qBACH,OAAO,CAAC,0BAA0B,iBAAiB,6BAA6B,CAAC;qBACjF,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,CAAA;gBACtB,WAAW,CAAC,OAAO,CAAC,8CAA8C,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAC9E,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,+BAA+B;QACjC,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -25,4 +25,5 @@ export { type MediaItem, addMediaItemToDatabase, updateMediaItemStatus, getWorks
|
|
|
25
25
|
export { checkPMOExists, getPMOSetting, dropPMOTables, upsertWorkspaceSetting, } from './pmo-bootstrap.js';
|
|
26
26
|
export { type DatabaseDriver, type PreparedStatement, type RunResult, BetterSqlite3Driver, wrapDatabase, openDriver, getRawDatabase, } from './driver.js';
|
|
27
27
|
export { SettingsStore, createSettingsStore, } from './settings-store.js';
|
|
28
|
+
export { isCredentialKey, getCredentialDatabasePath, getCredential, setCredential, deleteCredential, hasCredential, closeAllCredentialStores, migrateCredentials, } from './credential-store.js';
|
|
28
29
|
export { enableWALMode, createRotatingBackup, checkIntegrity, quickCheckIntegrity, repairDatabase, getBackupPath, type IntegrityCheckResult, type RepairResult, } from './db-safety.js';
|
|
@@ -35,6 +35,8 @@ export { checkPMOExists, getPMOSetting, dropPMOTables, upsertWorkspaceSetting, }
|
|
|
35
35
|
export { BetterSqlite3Driver, wrapDatabase, openDriver, getRawDatabase, } from './driver.js';
|
|
36
36
|
// Settings store
|
|
37
37
|
export { SettingsStore, createSettingsStore, } from './settings-store.js';
|
|
38
|
+
// Credential store (PRLT-1114: agent secret isolation)
|
|
39
|
+
export { isCredentialKey, getCredentialDatabasePath, getCredential, setCredential, deleteCredential, hasCredential, closeAllCredentialStores, migrateCredentials, } from './credential-store.js';
|
|
38
40
|
// Database safety (WAL, backup, integrity, repair)
|
|
39
41
|
export { enableWALMode, createRotatingBackup, checkIntegrity, quickCheckIntegrity, repairDatabase, getBackupPath, } from './db-safety.js';
|
|
40
42
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/database/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,0DAA0D;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAEzD,sBAAsB;AACtB,OAAO,EAEL,WAAW,EACX,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,gBAAgB,CAAA;AAEvB,mBAAmB;AACnB,OAAO,EAQL,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,2BAA2B,EAC3B,8BAA8B,EAC9B,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,aAAa,CAAA;AAEpB,wBAAwB;AACxB,OAAO,EAEL,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,mBAAmB,CAAA;AAE1B,mBAAmB;AACnB,OAAO,EAGL,cAAc,EACd,cAAc,EACd,SAAS,EACT,QAAQ,EACR,WAAW,EACX,WAAW,EACX,aAAa,EACb,sBAAsB,EACtB,aAAa,GACd,MAAM,aAAa,CAAA;AAEpB,sBAAsB;AACtB,OAAO,EAEL,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,gBAAgB,CAAA;AAEvB,wBAAwB;AACxB,OAAO,EAEL,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,YAAY,EACZ,2BAA2B,GAC5B,MAAM,YAAY,CAAA;AAEnB,2BAA2B;AAC3B,OAAO,EACL,cAAc,EACd,aAAa,EACb,aAAa,EACb,sBAAsB,GACvB,MAAM,oBAAoB,CAAA;AAE3B,8BAA8B;AAC9B,OAAO,EAIL,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,cAAc,GACf,MAAM,aAAa,CAAA;AAEpB,iBAAiB;AACjB,OAAO,EACL,aAAa,EACb,mBAAmB,GACpB,MAAM,qBAAqB,CAAA;AAE5B,mDAAmD;AACnD,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,aAAa,GAGd,MAAM,gBAAgB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/database/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,0DAA0D;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAEzD,sBAAsB;AACtB,OAAO,EAEL,WAAW,EACX,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,gBAAgB,CAAA;A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L,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,aAAa,GAGd,MAAM,gBAAgB,CAAA"}
|
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Raw SQL operations required for PMO initialization and teardown.
|
|
5
5
|
* These run before the storage layer is available.
|
|
6
|
+
*
|
|
7
|
+
* All database opens go through openSafeDatabase() which provides:
|
|
8
|
+
* - Rotating backup before open
|
|
9
|
+
* - Quick integrity check on startup
|
|
10
|
+
* - Auto-repair on corruption (dump/reimport or backup restore)
|
|
11
|
+
*
|
|
12
|
+
* See: PRLT-1152
|
|
6
13
|
*/
|
|
7
14
|
import Database from 'better-sqlite3';
|
|
8
15
|
/**
|
|
@@ -3,24 +3,63 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Raw SQL operations required for PMO initialization and teardown.
|
|
5
5
|
* These run before the storage layer is available.
|
|
6
|
+
*
|
|
7
|
+
* All database opens go through openSafeDatabase() which provides:
|
|
8
|
+
* - Rotating backup before open
|
|
9
|
+
* - Quick integrity check on startup
|
|
10
|
+
* - Auto-repair on corruption (dump/reimport or backup restore)
|
|
11
|
+
*
|
|
12
|
+
* See: PRLT-1152
|
|
6
13
|
*/
|
|
7
14
|
import Database from 'better-sqlite3';
|
|
8
15
|
import { throwIfNativeBindingError } from './native-validation.js';
|
|
9
16
|
import { createDrizzleConnection } from './drizzle.js';
|
|
10
17
|
import { workspaceSettings as workspaceSettingsTable, } from './drizzle-schema.js';
|
|
18
|
+
import { createRotatingBackup, quickCheckIntegrity, repairDatabase, } from './db-safety.js';
|
|
11
19
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
20
|
+
* Open a database connection with safety features (backup, integrity check, auto-repair).
|
|
21
|
+
* Used by PMO bootstrap functions that need raw SQL access before the full workspace
|
|
22
|
+
* database lifecycle is available.
|
|
14
23
|
*/
|
|
15
|
-
|
|
24
|
+
function openSafeDatabase(dbPath, caller) {
|
|
25
|
+
// Create backup before opening (cheap insurance against corruption)
|
|
26
|
+
createRotatingBackup(dbPath);
|
|
16
27
|
let db;
|
|
17
28
|
try {
|
|
18
29
|
db = new Database(dbPath);
|
|
19
30
|
}
|
|
20
31
|
catch (error) {
|
|
21
|
-
throwIfNativeBindingError(error,
|
|
32
|
+
throwIfNativeBindingError(error, caller);
|
|
22
33
|
throw error;
|
|
23
34
|
}
|
|
35
|
+
// Quick integrity check — auto-repair if corrupt
|
|
36
|
+
const integrity = quickCheckIntegrity(db);
|
|
37
|
+
if (!integrity.ok) {
|
|
38
|
+
db.close();
|
|
39
|
+
const repair = repairDatabase(dbPath);
|
|
40
|
+
if (!repair.success) {
|
|
41
|
+
throw new Error(`Database corruption detected in ${dbPath}.\n` +
|
|
42
|
+
`Integrity errors: ${integrity.errors.join('; ')}\n` +
|
|
43
|
+
`Auto-repair failed: ${repair.message}\n` +
|
|
44
|
+
`Run 'prlt db repair' for manual recovery options.`);
|
|
45
|
+
}
|
|
46
|
+
// Re-open the repaired database
|
|
47
|
+
try {
|
|
48
|
+
db = new Database(dbPath);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throwIfNativeBindingError(error, `${caller} (post-repair)`);
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return db;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Check if PMO tables exist and get basic stats.
|
|
59
|
+
* Raw SQL: uses sqlite_master introspection (pre-migration bootstrap).
|
|
60
|
+
*/
|
|
61
|
+
export function checkPMOExists(dbPath) {
|
|
62
|
+
const db = openSafeDatabase(dbPath, 'checkPMOExists');
|
|
24
63
|
try {
|
|
25
64
|
const result = db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='pmo_projects'").get();
|
|
26
65
|
if (result === undefined) {
|
|
@@ -43,14 +82,7 @@ export function checkPMOExists(dbPath) {
|
|
|
43
82
|
* Raw SQL: pre-migration bootstrap query.
|
|
44
83
|
*/
|
|
45
84
|
export function getPMOSetting(dbPath, key) {
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
db = new Database(dbPath);
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
throwIfNativeBindingError(error, 'getPMOSetting');
|
|
52
|
-
throw error;
|
|
53
|
-
}
|
|
85
|
+
const db = openSafeDatabase(dbPath, 'getPMOSetting');
|
|
54
86
|
try {
|
|
55
87
|
const result = db.prepare('SELECT value FROM pmo_settings WHERE key = ?').get(key);
|
|
56
88
|
return result?.value ?? null;
|
|
@@ -67,14 +99,7 @@ export function getPMOSetting(dbPath, key) {
|
|
|
67
99
|
* Raw SQL: DDL operations (DROP TABLE) are not supported by Drizzle.
|
|
68
100
|
*/
|
|
69
101
|
export function dropPMOTables(dbPath, tables) {
|
|
70
|
-
|
|
71
|
-
try {
|
|
72
|
-
db = new Database(dbPath);
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
throwIfNativeBindingError(error, 'dropPMOTables');
|
|
76
|
-
throw error;
|
|
77
|
-
}
|
|
102
|
+
const db = openSafeDatabase(dbPath, 'dropPMOTables');
|
|
78
103
|
try {
|
|
79
104
|
for (const table of tables) {
|
|
80
105
|
try {
|