@stackmemoryai/stackmemory 0.2.4 ā 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +353 -83
- package/dist/index.js +382 -0
- package/dist/scripts/cancel-duplicate-tasks.d.ts +7 -0
- package/dist/scripts/cancel-duplicate-tasks.d.ts.map +1 -0
- package/dist/scripts/cancel-duplicate-tasks.js +171 -0
- package/dist/scripts/cancel-duplicate-tasks.js.map +1 -0
- package/dist/scripts/list-linear-tasks.d.ts +6 -0
- package/dist/scripts/list-linear-tasks.d.ts.map +1 -0
- package/dist/scripts/list-linear-tasks.js +122 -0
- package/dist/scripts/list-linear-tasks.js.map +1 -0
- package/dist/scripts/merge-linear-duplicates-safe.d.ts +7 -0
- package/dist/scripts/merge-linear-duplicates-safe.d.ts.map +1 -0
- package/dist/scripts/merge-linear-duplicates-safe.js +265 -0
- package/dist/scripts/merge-linear-duplicates-safe.js.map +1 -0
- package/dist/scripts/merge-linear-duplicates.d.ts +7 -0
- package/dist/scripts/merge-linear-duplicates.d.ts.map +1 -0
- package/dist/scripts/merge-linear-duplicates.js +126 -0
- package/dist/scripts/merge-linear-duplicates.js.map +1 -0
- package/dist/scripts/show-linear-summary.d.ts +6 -0
- package/dist/scripts/show-linear-summary.d.ts.map +1 -0
- package/dist/scripts/show-linear-summary.js +117 -0
- package/dist/scripts/show-linear-summary.js.map +1 -0
- package/dist/src/analytics/api/analytics-api.d.ts +24 -0
- package/dist/src/analytics/api/analytics-api.d.ts.map +1 -0
- package/dist/src/analytics/api/analytics-api.js +279 -0
- package/dist/src/analytics/api/analytics-api.js.map +1 -0
- package/dist/src/analytics/core/analytics-service.d.ts +23 -0
- package/dist/src/analytics/core/analytics-service.d.ts.map +1 -0
- package/dist/src/analytics/core/analytics-service.js +160 -0
- package/dist/src/analytics/core/analytics-service.js.map +1 -0
- package/dist/src/analytics/index.d.ts +12 -0
- package/dist/src/analytics/index.d.ts.map +1 -0
- package/dist/src/analytics/index.js +11 -0
- package/dist/src/analytics/index.js.map +1 -0
- package/dist/src/analytics/queries/metrics-queries.d.ts +11 -0
- package/dist/src/analytics/queries/metrics-queries.d.ts.map +1 -0
- package/dist/src/analytics/queries/metrics-queries.js +179 -0
- package/dist/src/analytics/queries/metrics-queries.js.map +1 -0
- package/dist/src/analytics/types/metrics.d.ts +60 -0
- package/dist/src/analytics/types/metrics.d.ts.map +1 -0
- package/dist/src/analytics/types/metrics.js +2 -0
- package/dist/src/analytics/types/metrics.js.map +1 -0
- package/dist/src/cli/__tests__/index.test.d.ts +5 -0
- package/dist/src/cli/__tests__/index.test.d.ts.map +1 -0
- package/dist/src/cli/__tests__/index.test.js +726 -0
- package/dist/src/cli/__tests__/index.test.js.map +1 -0
- package/dist/src/cli/analytics-viewer.d.ts +3 -0
- package/dist/src/cli/analytics-viewer.d.ts.map +1 -0
- package/dist/src/cli/analytics-viewer.js +89 -0
- package/dist/src/cli/analytics-viewer.js.map +1 -0
- package/dist/src/cli/auto-detect.d.ts +61 -0
- package/dist/src/cli/auto-detect.d.ts.map +1 -0
- package/dist/src/cli/auto-detect.js +350 -0
- package/dist/src/cli/auto-detect.js.map +1 -0
- package/dist/src/cli/browser-test.d.ts +6 -0
- package/dist/src/cli/browser-test.d.ts.map +1 -0
- package/dist/src/cli/browser-test.js +32 -0
- package/dist/src/cli/browser-test.js.map +1 -0
- package/dist/src/cli/claude-sm.d.ts +7 -0
- package/dist/src/cli/claude-sm.d.ts.map +1 -0
- package/dist/src/cli/claude-sm.js +357 -0
- package/dist/src/cli/claude-sm.js.map +1 -0
- package/dist/src/cli/cli.js +157 -0
- package/dist/src/cli/cli.js.map +1 -1
- package/dist/src/cli/commands/context.d.ts +7 -0
- package/dist/src/cli/commands/context.d.ts.map +1 -0
- package/dist/src/cli/commands/context.js +365 -0
- package/dist/src/cli/commands/context.js.map +1 -0
- package/dist/src/cli/commands/linear-test.d.ts +6 -0
- package/dist/src/cli/commands/linear-test.d.ts.map +1 -0
- package/dist/src/cli/commands/linear-test.js +123 -0
- package/dist/src/cli/commands/linear-test.js.map +1 -0
- package/dist/src/cli/commands/linear.d.ts +6 -0
- package/dist/src/cli/commands/linear.d.ts.map +1 -0
- package/dist/src/cli/commands/linear.js +317 -0
- package/dist/src/cli/commands/linear.js.map +1 -0
- package/dist/src/cli/commands/log.d.ts +7 -0
- package/dist/src/cli/commands/log.d.ts.map +1 -0
- package/dist/src/cli/commands/log.js +168 -0
- package/dist/src/cli/commands/log.js.map +1 -0
- package/dist/src/cli/commands/onboard.d.ts +8 -0
- package/dist/src/cli/commands/onboard.d.ts.map +1 -0
- package/dist/src/cli/commands/onboard.js +363 -0
- package/dist/src/cli/commands/onboard.js.map +1 -0
- package/dist/src/cli/commands/projects.d.ts +8 -0
- package/dist/src/cli/commands/projects.d.ts.map +1 -0
- package/dist/src/cli/commands/projects.js +220 -0
- package/dist/src/cli/commands/projects.js.map +1 -0
- package/dist/src/cli/commands/search.d.ts +7 -0
- package/dist/src/cli/commands/search.d.ts.map +1 -0
- package/dist/src/cli/commands/search.js +162 -0
- package/dist/src/cli/commands/search.js.map +1 -0
- package/dist/src/cli/commands/session.d.ts +7 -0
- package/dist/src/cli/commands/session.d.ts.map +1 -0
- package/dist/src/cli/commands/session.js +222 -0
- package/dist/src/cli/commands/session.js.map +1 -0
- package/dist/src/cli/commands/tasks.d.ts +7 -0
- package/dist/src/cli/commands/tasks.d.ts.map +1 -0
- package/dist/src/cli/commands/tasks.js +229 -0
- package/dist/src/cli/commands/tasks.js.map +1 -0
- package/dist/src/cli/commands/webhook.d.ts +3 -0
- package/dist/src/cli/commands/webhook.d.ts.map +1 -0
- package/dist/src/cli/commands/webhook.js +157 -0
- package/dist/src/cli/commands/webhook.js.map +1 -0
- package/dist/src/cli/commands/worktree.d.ts +8 -0
- package/dist/src/cli/commands/worktree.d.ts.map +1 -0
- package/dist/src/cli/commands/worktree.js +339 -0
- package/dist/src/cli/commands/worktree.js.map +1 -0
- package/dist/src/cli/index.d.ts +8 -0
- package/dist/src/cli/index.d.ts.map +1 -0
- package/dist/src/cli/index.js +944 -0
- package/dist/src/cli/index.js.map +1 -0
- package/dist/src/cli/project-commands.d.ts +8 -0
- package/dist/src/cli/project-commands.d.ts.map +1 -0
- package/dist/src/cli/project-commands.js +212 -0
- package/dist/src/cli/project-commands.js.map +1 -0
- package/dist/src/cli/utils/viewer.d.ts +3 -0
- package/dist/src/cli/utils/viewer.d.ts.map +1 -0
- package/dist/src/cli/utils/viewer.js +91 -0
- package/dist/src/cli/utils/viewer.js.map +1 -0
- package/dist/src/core/context/__tests__/frame-manager.test.d.ts +5 -0
- package/dist/src/core/context/__tests__/frame-manager.test.d.ts.map +1 -0
- package/dist/src/core/context/__tests__/frame-manager.test.js +892 -0
- package/dist/src/core/context/__tests__/frame-manager.test.js.map +1 -0
- package/dist/src/core/context/auto-context.d.ts +22 -0
- package/dist/src/core/context/auto-context.d.ts.map +1 -0
- package/dist/src/core/context/auto-context.js +77 -0
- package/dist/src/core/context/auto-context.js.map +1 -0
- package/dist/src/core/context/frame-manager.d.ts +110 -0
- package/dist/src/core/context/frame-manager.d.ts.map +1 -0
- package/dist/src/core/context/frame-manager.js +593 -0
- package/dist/src/core/context/frame-manager.js.map +1 -0
- package/dist/src/core/errors/__tests__/error-handling.test.d.ts +5 -0
- package/dist/src/core/errors/__tests__/error-handling.test.d.ts.map +1 -0
- package/dist/src/core/errors/__tests__/error-handling.test.js +239 -0
- package/dist/src/core/errors/__tests__/error-handling.test.js.map +1 -0
- package/dist/src/core/errors/index.d.ts +135 -0
- package/dist/src/core/errors/index.d.ts.map +1 -0
- package/dist/src/core/errors/index.js +274 -0
- package/dist/src/core/errors/index.js.map +1 -0
- package/dist/src/core/errors/recovery.d.ts +86 -0
- package/dist/src/core/errors/recovery.d.ts.map +1 -0
- package/dist/src/core/errors/recovery.js +274 -0
- package/dist/src/core/errors/recovery.js.map +1 -0
- package/dist/src/core/logger.test.js +1 -1
- package/dist/src/core/logger.test.js.map +1 -1
- package/dist/src/core/monitoring/error-handler.d.ts +46 -0
- package/dist/src/core/monitoring/error-handler.d.ts.map +1 -0
- package/dist/src/core/monitoring/error-handler.js +212 -0
- package/dist/src/core/monitoring/error-handler.js.map +1 -0
- package/dist/src/core/monitoring/logger.d.ts +24 -0
- package/dist/src/core/monitoring/logger.d.ts.map +1 -0
- package/dist/src/core/monitoring/logger.js +121 -0
- package/dist/src/core/monitoring/logger.js.map +1 -0
- package/dist/src/core/monitoring/metrics.d.ts +7 -0
- package/dist/src/core/monitoring/metrics.d.ts.map +1 -0
- package/dist/src/core/monitoring/metrics.js +13 -0
- package/dist/src/core/monitoring/metrics.js.map +1 -0
- package/dist/src/core/monitoring/progress-tracker.d.ts +95 -0
- package/dist/src/core/monitoring/progress-tracker.d.ts.map +1 -0
- package/dist/src/core/monitoring/progress-tracker.js +178 -0
- package/dist/src/core/monitoring/progress-tracker.js.map +1 -0
- package/dist/src/core/project-manager.d.ts +130 -0
- package/dist/src/core/project-manager.d.ts.map +1 -0
- package/dist/src/core/project-manager.js +582 -0
- package/dist/src/core/project-manager.js.map +1 -0
- package/dist/src/core/projects/project-manager.d.ts +130 -0
- package/dist/src/core/projects/project-manager.d.ts.map +1 -0
- package/dist/src/core/projects/project-manager.js +709 -0
- package/dist/src/core/projects/project-manager.js.map +1 -0
- package/dist/src/core/session/index.d.ts +2 -0
- package/dist/src/core/session/index.d.ts.map +1 -0
- package/dist/src/core/session/index.js +2 -0
- package/dist/src/core/session/index.js.map +1 -0
- package/dist/src/core/session/session-manager.d.ts +69 -0
- package/dist/src/core/session/session-manager.d.ts.map +1 -0
- package/dist/src/core/session/session-manager.js +311 -0
- package/dist/src/core/session/session-manager.js.map +1 -0
- package/dist/src/core/utils/update-checker.d.ts +38 -0
- package/dist/src/core/utils/update-checker.d.ts.map +1 -0
- package/dist/src/core/utils/update-checker.js +213 -0
- package/dist/src/core/utils/update-checker.js.map +1 -0
- package/dist/src/core/worktree/worktree-manager.d.ts +110 -0
- package/dist/src/core/worktree/worktree-manager.d.ts.map +1 -0
- package/dist/src/core/worktree/worktree-manager.js +456 -0
- package/dist/src/core/worktree/worktree-manager.js.map +1 -0
- package/dist/src/features/analytics/api/analytics-api.d.ts +24 -0
- package/dist/src/features/analytics/api/analytics-api.d.ts.map +1 -0
- package/dist/src/features/analytics/api/analytics-api.js +289 -0
- package/dist/src/features/analytics/api/analytics-api.js.map +1 -0
- package/dist/src/features/analytics/core/analytics-service.d.ts +29 -0
- package/dist/src/features/analytics/core/analytics-service.d.ts.map +1 -0
- package/dist/src/features/analytics/core/analytics-service.js +275 -0
- package/dist/src/features/analytics/core/analytics-service.js.map +1 -0
- package/dist/src/features/analytics/index.d.ts +12 -0
- package/dist/src/features/analytics/index.d.ts.map +1 -0
- package/dist/src/features/analytics/index.js +11 -0
- package/dist/src/features/analytics/index.js.map +1 -0
- package/dist/src/features/analytics/queries/metrics-queries.d.ts +11 -0
- package/dist/src/features/analytics/queries/metrics-queries.d.ts.map +1 -0
- package/dist/src/features/analytics/queries/metrics-queries.js +240 -0
- package/dist/src/features/analytics/queries/metrics-queries.js.map +1 -0
- package/dist/src/features/analytics/types/metrics.d.ts +60 -0
- package/dist/src/features/analytics/types/metrics.d.ts.map +1 -0
- package/dist/src/features/analytics/types/metrics.js +2 -0
- package/dist/src/features/analytics/types/metrics.js.map +1 -0
- package/dist/src/features/browser/browser-mcp.d.ts +94 -0
- package/dist/src/features/browser/browser-mcp.d.ts.map +1 -0
- package/dist/src/features/browser/browser-mcp.js +459 -0
- package/dist/src/features/browser/browser-mcp.js.map +1 -0
- package/dist/src/features/tasks/__tests__/pebbles-task-store.test.d.ts +5 -0
- package/dist/src/features/tasks/__tests__/pebbles-task-store.test.d.ts.map +1 -0
- package/dist/src/features/tasks/__tests__/pebbles-task-store.test.js +712 -0
- package/dist/src/features/tasks/__tests__/pebbles-task-store.test.js.map +1 -0
- package/dist/src/features/tasks/pebbles-task-store.d.ts +121 -0
- package/dist/src/features/tasks/pebbles-task-store.d.ts.map +1 -0
- package/dist/src/features/tasks/pebbles-task-store.js +493 -0
- package/dist/src/features/tasks/pebbles-task-store.js.map +1 -0
- package/dist/src/features/tasks/task-aware-context.d.ts +103 -0
- package/dist/src/features/tasks/task-aware-context.d.ts.map +1 -0
- package/dist/src/features/tasks/task-aware-context.js +412 -0
- package/dist/src/features/tasks/task-aware-context.js.map +1 -0
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/integrations/browser-mcp.d.ts +94 -0
- package/dist/src/integrations/browser-mcp.d.ts.map +1 -0
- package/dist/src/integrations/browser-mcp.js +431 -0
- package/dist/src/integrations/browser-mcp.js.map +1 -0
- package/dist/src/integrations/linear/__tests__/auth.test.d.ts +5 -0
- package/dist/src/integrations/linear/__tests__/auth.test.d.ts.map +1 -0
- package/dist/src/integrations/linear/__tests__/auth.test.js +517 -0
- package/dist/src/integrations/linear/__tests__/auth.test.js.map +1 -0
- package/dist/src/integrations/linear/__tests__/sync-service.test.d.ts +5 -0
- package/dist/src/integrations/linear/__tests__/sync-service.test.d.ts.map +1 -0
- package/dist/src/integrations/linear/__tests__/sync-service.test.js +700 -0
- package/dist/src/integrations/linear/__tests__/sync-service.test.js.map +1 -0
- package/dist/src/integrations/linear/auth.d.ts +99 -0
- package/dist/src/integrations/linear/auth.d.ts.map +1 -0
- package/dist/src/integrations/linear/auth.js +319 -0
- package/dist/src/integrations/linear/auth.js.map +1 -0
- package/dist/src/integrations/linear/auto-sync.d.ts +77 -0
- package/dist/src/integrations/linear/auto-sync.d.ts.map +1 -0
- package/dist/src/integrations/linear/auto-sync.js +268 -0
- package/dist/src/integrations/linear/auto-sync.js.map +1 -0
- package/dist/src/integrations/linear/client.d.ts +113 -0
- package/dist/src/integrations/linear/client.d.ts.map +1 -0
- package/dist/src/integrations/linear/client.js +364 -0
- package/dist/src/integrations/linear/client.js.map +1 -0
- package/dist/src/integrations/linear/config.d.ts +51 -0
- package/dist/src/integrations/linear/config.d.ts.map +1 -0
- package/dist/src/integrations/linear/config.js +103 -0
- package/dist/src/integrations/linear/config.js.map +1 -0
- package/dist/src/integrations/linear/sync-service.d.ts +25 -0
- package/dist/src/integrations/linear/sync-service.d.ts.map +1 -0
- package/dist/src/integrations/linear/sync-service.js +198 -0
- package/dist/src/integrations/linear/sync-service.js.map +1 -0
- package/dist/src/integrations/linear/sync.d.ts +119 -0
- package/dist/src/integrations/linear/sync.d.ts.map +1 -0
- package/dist/src/integrations/linear/sync.js +538 -0
- package/dist/src/integrations/linear/sync.js.map +1 -0
- package/dist/src/integrations/linear/types.d.ts +75 -0
- package/dist/src/integrations/linear/types.d.ts.map +1 -0
- package/dist/src/integrations/linear/types.js +2 -0
- package/dist/src/integrations/linear/types.js.map +1 -0
- package/dist/src/integrations/linear/webhook-server.d.ts +32 -0
- package/dist/src/integrations/linear/webhook-server.d.ts.map +1 -0
- package/dist/src/integrations/linear/webhook-server.js +188 -0
- package/dist/src/integrations/linear/webhook-server.js.map +1 -0
- package/dist/src/integrations/linear/webhook.d.ts +95 -0
- package/dist/src/integrations/linear/webhook.d.ts.map +1 -0
- package/dist/src/integrations/linear/webhook.js +204 -0
- package/dist/src/integrations/linear/webhook.js.map +1 -0
- package/dist/src/integrations/mcp/__tests__/server.test.d.ts +5 -0
- package/dist/src/integrations/mcp/__tests__/server.test.d.ts.map +1 -0
- package/dist/src/integrations/mcp/__tests__/server.test.js +790 -0
- package/dist/src/integrations/mcp/__tests__/server.test.js.map +1 -0
- package/dist/src/integrations/mcp/server.d.ts +46 -0
- package/dist/src/integrations/mcp/server.d.ts.map +1 -0
- package/dist/src/integrations/mcp/server.js +1264 -0
- package/dist/src/integrations/mcp/server.js.map +1 -0
- package/dist/src/mcp/mcp-server.d.ts +1 -0
- package/dist/src/mcp/mcp-server.d.ts.map +1 -1
- package/dist/src/mcp/mcp-server.js +11 -0
- package/dist/src/mcp/mcp-server.js.map +1 -1
- package/dist/src/railway/index.d.ts +7 -0
- package/dist/src/railway/index.d.ts.map +1 -0
- package/dist/src/railway/index.js +401 -0
- package/dist/src/railway/index.js.map +1 -0
- package/dist/src/runway/auth/auth-middleware.d.ts +66 -0
- package/dist/src/runway/auth/auth-middleware.d.ts.map +1 -0
- package/dist/src/runway/auth/auth-middleware.js +337 -0
- package/dist/src/runway/auth/auth-middleware.js.map +1 -0
- package/dist/src/runway/server/runway-mcp-server.d.ts +46 -0
- package/dist/src/runway/server/runway-mcp-server.d.ts.map +1 -0
- package/dist/src/runway/server/runway-mcp-server.js +601 -0
- package/dist/src/runway/server/runway-mcp-server.js.map +1 -0
- package/dist/src/runway.bak/auth/auth-middleware.d.ts +66 -0
- package/dist/src/runway.bak/auth/auth-middleware.d.ts.map +1 -0
- package/dist/src/runway.bak/auth/auth-middleware.js +337 -0
- package/dist/src/runway.bak/auth/auth-middleware.js.map +1 -0
- package/dist/src/runway.bak/server/runway-mcp-server.d.ts +46 -0
- package/dist/src/runway.bak/server/runway-mcp-server.d.ts.map +1 -0
- package/dist/src/runway.bak/server/runway-mcp-server.js +601 -0
- package/dist/src/runway.bak/server/runway-mcp-server.js.map +1 -0
- package/dist/src/servers/production/auth-middleware.d.ts +66 -0
- package/dist/src/servers/production/auth-middleware.d.ts.map +1 -0
- package/dist/src/servers/production/auth-middleware.js +346 -0
- package/dist/src/servers/production/auth-middleware.js.map +1 -0
- package/dist/src/servers/railway/index.d.ts +7 -0
- package/dist/src/servers/railway/index.d.ts.map +1 -0
- package/dist/src/servers/railway/index.js +401 -0
- package/dist/src/servers/railway/index.js.map +1 -0
- package/dist/src/services/config-service.d.ts +44 -0
- package/dist/src/services/config-service.d.ts.map +1 -0
- package/dist/src/services/config-service.js +61 -0
- package/dist/src/services/config-service.js.map +1 -0
- package/dist/src/services/context-service.d.ts +17 -0
- package/dist/src/services/context-service.d.ts.map +1 -0
- package/dist/src/services/context-service.js +88 -0
- package/dist/src/services/context-service.js.map +1 -0
- package/dist/src/types/task.d.ts +17 -0
- package/dist/src/types/task.d.ts.map +1 -0
- package/dist/src/types/task.js +2 -0
- package/dist/src/types/task.js.map +1 -0
- package/dist/src/utils/logger.d.ts +13 -0
- package/dist/src/utils/logger.d.ts.map +1 -0
- package/dist/src/utils/logger.js +52 -0
- package/dist/src/utils/logger.js.map +1 -0
- package/package.json +40 -5
package/dist/index.js
ADDED
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Railway MCP Server Entry Point
|
|
4
|
+
* Simplified production server for Railway deployment
|
|
5
|
+
*/
|
|
6
|
+
import express from 'express';
|
|
7
|
+
import { createServer } from 'http';
|
|
8
|
+
import { WebSocketServer } from 'ws';
|
|
9
|
+
import cors from 'cors';
|
|
10
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
11
|
+
import Database from 'better-sqlite3';
|
|
12
|
+
import { join, dirname } from 'path';
|
|
13
|
+
import { fileURLToPath } from 'url';
|
|
14
|
+
import { existsSync, mkdirSync } from 'fs';
|
|
15
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
16
|
+
const __dirname = dirname(__filename);
|
|
17
|
+
// Configuration
|
|
18
|
+
const config = {
|
|
19
|
+
port: parseInt(process.env.PORT || '8080'),
|
|
20
|
+
environment: process.env.NODE_ENV || 'development',
|
|
21
|
+
corsOrigins: process.env.CORS_ORIGINS?.split(',') || ['http://localhost:3000'],
|
|
22
|
+
authMode: process.env.AUTH_MODE || 'api_key',
|
|
23
|
+
apiKeySecret: process.env.API_KEY_SECRET || 'development-secret',
|
|
24
|
+
jwtSecret: process.env.JWT_SECRET || 'development-jwt-secret',
|
|
25
|
+
databaseUrl: process.env.DATABASE_URL || join(process.cwd(), '.stackmemory', 'railway.db'),
|
|
26
|
+
rateLimitEnabled: process.env.RATE_LIMIT_ENABLED === 'true',
|
|
27
|
+
rateLimitFree: parseInt(process.env.RATE_LIMIT_FREE || '100'),
|
|
28
|
+
enableWebSocket: process.env.ENABLE_WEBSOCKET !== 'false',
|
|
29
|
+
enableAnalytics: process.env.ENABLE_ANALYTICS === 'true'
|
|
30
|
+
};
|
|
31
|
+
// Simple in-memory rate limiter
|
|
32
|
+
const rateLimiter = new Map();
|
|
33
|
+
class RailwayMCPServer {
|
|
34
|
+
constructor() {
|
|
35
|
+
this.connections = new Map();
|
|
36
|
+
this.app = express();
|
|
37
|
+
this.httpServer = createServer(this.app);
|
|
38
|
+
this.initializeDatabase();
|
|
39
|
+
this.setupMiddleware();
|
|
40
|
+
this.setupRoutes();
|
|
41
|
+
this.setupMCPServer();
|
|
42
|
+
if (config.enableWebSocket) {
|
|
43
|
+
this.setupWebSocket();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
initializeDatabase() {
|
|
47
|
+
// Use PostgreSQL in production, SQLite for development
|
|
48
|
+
if (config.environment === 'production' && config.databaseUrl.startsWith('postgresql://')) {
|
|
49
|
+
console.log('Using PostgreSQL database');
|
|
50
|
+
// In production, we'd use pg client here
|
|
51
|
+
// For now, we'll use SQLite as fallback
|
|
52
|
+
const dbPath = '/tmp/stackmemory.db';
|
|
53
|
+
this.db = new Database(dbPath);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// Create database directory if it doesn't exist
|
|
57
|
+
const dbDir = dirname(config.databaseUrl);
|
|
58
|
+
if (!existsSync(dbDir)) {
|
|
59
|
+
mkdirSync(dbDir, { recursive: true });
|
|
60
|
+
}
|
|
61
|
+
this.db = new Database(config.databaseUrl);
|
|
62
|
+
}
|
|
63
|
+
// Initialize tables
|
|
64
|
+
this.db.exec(`
|
|
65
|
+
CREATE TABLE IF NOT EXISTS contexts (
|
|
66
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
67
|
+
project_id TEXT NOT NULL,
|
|
68
|
+
content TEXT NOT NULL,
|
|
69
|
+
type TEXT DEFAULT 'general',
|
|
70
|
+
metadata TEXT DEFAULT '{}',
|
|
71
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
72
|
+
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
CREATE TABLE IF NOT EXISTS api_keys (
|
|
76
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
77
|
+
key_hash TEXT UNIQUE NOT NULL,
|
|
78
|
+
user_id TEXT NOT NULL,
|
|
79
|
+
name TEXT,
|
|
80
|
+
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
81
|
+
last_used DATETIME,
|
|
82
|
+
revoked BOOLEAN DEFAULT 0
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
CREATE INDEX IF NOT EXISTS idx_contexts_project ON contexts(project_id);
|
|
86
|
+
CREATE INDEX IF NOT EXISTS idx_api_keys_hash ON api_keys(key_hash);
|
|
87
|
+
`);
|
|
88
|
+
}
|
|
89
|
+
setupMiddleware() {
|
|
90
|
+
// CORS
|
|
91
|
+
this.app.use(cors({
|
|
92
|
+
origin: config.corsOrigins,
|
|
93
|
+
credentials: true
|
|
94
|
+
}));
|
|
95
|
+
// Body parsing
|
|
96
|
+
this.app.use(express.json({ limit: '10mb' }));
|
|
97
|
+
// Request logging
|
|
98
|
+
this.app.use((req, res, next) => {
|
|
99
|
+
console.log(`${new Date().toISOString()} ${req.method} ${req.path}`);
|
|
100
|
+
next();
|
|
101
|
+
});
|
|
102
|
+
// Simple authentication middleware
|
|
103
|
+
this.app.use('/api', this.authenticate.bind(this));
|
|
104
|
+
// Rate limiting
|
|
105
|
+
if (config.rateLimitEnabled) {
|
|
106
|
+
this.app.use('/api', this.rateLimit.bind(this));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
authenticate(req, res, next) {
|
|
110
|
+
// Skip auth for health check
|
|
111
|
+
if (req.path === '/health') {
|
|
112
|
+
return next();
|
|
113
|
+
}
|
|
114
|
+
const authHeader = req.headers.authorization;
|
|
115
|
+
if (config.authMode === 'api_key') {
|
|
116
|
+
// Simple API key authentication
|
|
117
|
+
if (!authHeader?.startsWith('Bearer ')) {
|
|
118
|
+
return res.status(401).json({ error: 'Missing API key' });
|
|
119
|
+
}
|
|
120
|
+
const apiKey = authHeader.substring(7);
|
|
121
|
+
// In production, validate against database
|
|
122
|
+
// For now, simple check
|
|
123
|
+
if (apiKey.length < 32) {
|
|
124
|
+
return res.status(403).json({ error: 'Invalid API key' });
|
|
125
|
+
}
|
|
126
|
+
req.user = { id: 'api-user', tier: 'free' };
|
|
127
|
+
next();
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
// OAuth/JWT mode would go here
|
|
131
|
+
next();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
rateLimit(req, res, next) {
|
|
135
|
+
const userId = req.user?.id || req.ip;
|
|
136
|
+
const now = Date.now();
|
|
137
|
+
const windowMs = 15 * 60 * 1000; // 15 minutes
|
|
138
|
+
const userLimit = rateLimiter.get(userId);
|
|
139
|
+
if (!userLimit || userLimit.resetTime < now) {
|
|
140
|
+
rateLimiter.set(userId, {
|
|
141
|
+
count: 1,
|
|
142
|
+
resetTime: now + windowMs
|
|
143
|
+
});
|
|
144
|
+
return next();
|
|
145
|
+
}
|
|
146
|
+
if (userLimit.count >= config.rateLimitFree) {
|
|
147
|
+
const retryAfter = Math.ceil((userLimit.resetTime - now) / 1000);
|
|
148
|
+
res.setHeader('Retry-After', retryAfter.toString());
|
|
149
|
+
return res.status(429).json({
|
|
150
|
+
error: 'Rate limit exceeded',
|
|
151
|
+
retryAfter
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
userLimit.count++;
|
|
155
|
+
next();
|
|
156
|
+
}
|
|
157
|
+
setupRoutes() {
|
|
158
|
+
// Health check
|
|
159
|
+
this.app.get('/health', (req, res) => {
|
|
160
|
+
const health = {
|
|
161
|
+
status: 'healthy',
|
|
162
|
+
version: '1.0.0',
|
|
163
|
+
timestamp: new Date().toISOString(),
|
|
164
|
+
uptime: process.uptime(),
|
|
165
|
+
environment: config.environment
|
|
166
|
+
};
|
|
167
|
+
res.json(health);
|
|
168
|
+
});
|
|
169
|
+
// API Routes
|
|
170
|
+
this.app.post('/api/context/save', (req, res) => {
|
|
171
|
+
try {
|
|
172
|
+
const { projectId = 'default', content, type = 'general', metadata = {} } = req.body;
|
|
173
|
+
const stmt = this.db.prepare(`
|
|
174
|
+
INSERT INTO contexts (project_id, content, type, metadata)
|
|
175
|
+
VALUES (?, ?, ?, ?)
|
|
176
|
+
`);
|
|
177
|
+
const result = stmt.run(projectId, content, type, JSON.stringify(metadata));
|
|
178
|
+
res.json({
|
|
179
|
+
success: true,
|
|
180
|
+
id: result.lastInsertRowid
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
res.status(500).json({ error: error.message });
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
this.app.get('/api/context/load', (req, res) => {
|
|
188
|
+
try {
|
|
189
|
+
const { projectId = 'default', limit = 10, offset = 0 } = req.query;
|
|
190
|
+
const stmt = this.db.prepare(`
|
|
191
|
+
SELECT * FROM contexts
|
|
192
|
+
WHERE project_id = ?
|
|
193
|
+
ORDER BY created_at DESC
|
|
194
|
+
LIMIT ? OFFSET ?
|
|
195
|
+
`);
|
|
196
|
+
const contexts = stmt.all(projectId, limit, offset);
|
|
197
|
+
res.json({
|
|
198
|
+
success: true,
|
|
199
|
+
contexts: contexts.map(c => ({
|
|
200
|
+
...c,
|
|
201
|
+
metadata: JSON.parse(c.metadata)
|
|
202
|
+
}))
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
res.status(500).json({ error: error.message });
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
// MCP tool execution endpoint
|
|
210
|
+
this.app.post('/api/tools/execute', async (req, res) => {
|
|
211
|
+
try {
|
|
212
|
+
const { tool, params } = req.body;
|
|
213
|
+
// Execute MCP tool
|
|
214
|
+
const result = await this.executeMCPTool(tool, params);
|
|
215
|
+
res.json({
|
|
216
|
+
success: true,
|
|
217
|
+
result
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
res.status(500).json({ error: error.message });
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
// Analytics endpoint
|
|
225
|
+
if (config.enableAnalytics) {
|
|
226
|
+
this.app.get('/api/analytics', (req, res) => {
|
|
227
|
+
try {
|
|
228
|
+
const { projectId = 'default' } = req.query;
|
|
229
|
+
const stats = this.db.prepare(`
|
|
230
|
+
SELECT
|
|
231
|
+
COUNT(*) as total_contexts,
|
|
232
|
+
COUNT(DISTINCT type) as unique_types,
|
|
233
|
+
MAX(created_at) as last_activity
|
|
234
|
+
FROM contexts
|
|
235
|
+
WHERE project_id = ?
|
|
236
|
+
`).get(projectId);
|
|
237
|
+
res.json({
|
|
238
|
+
success: true,
|
|
239
|
+
analytics: stats
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
res.status(500).json({ error: error.message });
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
setupWebSocket() {
|
|
249
|
+
this.wss = new WebSocketServer({
|
|
250
|
+
server: this.httpServer,
|
|
251
|
+
path: '/ws'
|
|
252
|
+
});
|
|
253
|
+
this.wss.on('connection', (ws, req) => {
|
|
254
|
+
console.log('WebSocket connection established');
|
|
255
|
+
const connectionId = Math.random().toString(36).substring(7);
|
|
256
|
+
this.connections.set(connectionId, ws);
|
|
257
|
+
ws.on('message', async (data) => {
|
|
258
|
+
try {
|
|
259
|
+
const message = JSON.parse(data.toString());
|
|
260
|
+
const response = await this.handleWebSocketMessage(message);
|
|
261
|
+
ws.send(JSON.stringify(response));
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
ws.send(JSON.stringify({
|
|
265
|
+
error: error.message
|
|
266
|
+
}));
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
ws.on('close', () => {
|
|
270
|
+
this.connections.delete(connectionId);
|
|
271
|
+
console.log('WebSocket connection closed');
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
async handleWebSocketMessage(message) {
|
|
276
|
+
const { type, tool, params } = message;
|
|
277
|
+
switch (type) {
|
|
278
|
+
case 'execute':
|
|
279
|
+
return await this.executeMCPTool(tool, params);
|
|
280
|
+
case 'ping':
|
|
281
|
+
return { type: 'pong' };
|
|
282
|
+
default:
|
|
283
|
+
throw new Error(`Unknown message type: ${type}`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
setupMCPServer() {
|
|
287
|
+
this.mcpServer = new Server({
|
|
288
|
+
name: 'stackmemory-railway',
|
|
289
|
+
version: '1.0.0'
|
|
290
|
+
}, {
|
|
291
|
+
capabilities: {
|
|
292
|
+
tools: {},
|
|
293
|
+
resources: {}
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
// Register MCP tools
|
|
297
|
+
this.mcpServer.setRequestHandler('tools/list', async () => {
|
|
298
|
+
return {
|
|
299
|
+
tools: [
|
|
300
|
+
{
|
|
301
|
+
name: 'save_context',
|
|
302
|
+
description: 'Save context to StackMemory',
|
|
303
|
+
inputSchema: {
|
|
304
|
+
type: 'object',
|
|
305
|
+
properties: {
|
|
306
|
+
content: { type: 'string' },
|
|
307
|
+
type: { type: 'string' }
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
name: 'load_context',
|
|
313
|
+
description: 'Load context from StackMemory',
|
|
314
|
+
inputSchema: {
|
|
315
|
+
type: 'object',
|
|
316
|
+
properties: {
|
|
317
|
+
query: { type: 'string' },
|
|
318
|
+
limit: { type: 'number' }
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
]
|
|
323
|
+
};
|
|
324
|
+
});
|
|
325
|
+
this.mcpServer.setRequestHandler('tools/call', async (request) => {
|
|
326
|
+
const { name, arguments: args } = request.params;
|
|
327
|
+
return await this.executeMCPTool(name, args);
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
async executeMCPTool(tool, params) {
|
|
331
|
+
switch (tool) {
|
|
332
|
+
case 'save_context': {
|
|
333
|
+
const stmt = this.db.prepare(`
|
|
334
|
+
INSERT INTO contexts (project_id, content, type, metadata)
|
|
335
|
+
VALUES (?, ?, ?, ?)
|
|
336
|
+
`);
|
|
337
|
+
const result = stmt.run(params.projectId || 'default', params.content, params.type || 'general', JSON.stringify(params.metadata || {}));
|
|
338
|
+
return { id: result.lastInsertRowid, success: true };
|
|
339
|
+
}
|
|
340
|
+
case 'load_context': {
|
|
341
|
+
const stmt = this.db.prepare(`
|
|
342
|
+
SELECT * FROM contexts
|
|
343
|
+
WHERE project_id = ? AND content LIKE ?
|
|
344
|
+
ORDER BY created_at DESC
|
|
345
|
+
LIMIT ?
|
|
346
|
+
`);
|
|
347
|
+
const contexts = stmt.all(params.projectId || 'default', `%${params.query || ''}%`, params.limit || 10);
|
|
348
|
+
return { contexts, success: true };
|
|
349
|
+
}
|
|
350
|
+
default:
|
|
351
|
+
throw new Error(`Unknown tool: ${tool}`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
start() {
|
|
355
|
+
this.httpServer.listen(config.port, '0.0.0.0', () => {
|
|
356
|
+
console.log(`
|
|
357
|
+
š Railway MCP Server Started
|
|
358
|
+
================================
|
|
359
|
+
Environment: ${config.environment}
|
|
360
|
+
Port: ${config.port}
|
|
361
|
+
WebSocket: ${config.enableWebSocket ? 'Enabled' : 'Disabled'}
|
|
362
|
+
Analytics: ${config.enableAnalytics ? 'Enabled' : 'Disabled'}
|
|
363
|
+
Rate Limiting: ${config.rateLimitEnabled ? 'Enabled' : 'Disabled'}
|
|
364
|
+
Auth Mode: ${config.authMode}
|
|
365
|
+
================================
|
|
366
|
+
Health: http://localhost:${config.port}/health
|
|
367
|
+
`);
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
// Start server
|
|
372
|
+
const server = new RailwayMCPServer();
|
|
373
|
+
server.start();
|
|
374
|
+
// Graceful shutdown
|
|
375
|
+
process.on('SIGTERM', () => {
|
|
376
|
+
console.log('Shutting down gracefully...');
|
|
377
|
+
process.exit(0);
|
|
378
|
+
});
|
|
379
|
+
process.on('SIGINT', () => {
|
|
380
|
+
console.log('Shutting down...');
|
|
381
|
+
process.exit(0);
|
|
382
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cancel-duplicate-tasks.d.ts","sourceRoot":"","sources":["../../scripts/cancel-duplicate-tasks.ts"],"names":[],"mappings":";AAEA;;;GAGG"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Script to cancel duplicate Linear tasks
|
|
4
|
+
* Uses the actual Linear API to find and cancel duplicates
|
|
5
|
+
*/
|
|
6
|
+
import { readFileSync } from 'fs';
|
|
7
|
+
import { join } from 'path';
|
|
8
|
+
// Define patterns to identify duplicate tasks
|
|
9
|
+
const duplicatePatterns = [
|
|
10
|
+
{ pattern: 'Linear API Integration', keepFirst: true },
|
|
11
|
+
{ pattern: 'Performance Optimization', keepFirst: true },
|
|
12
|
+
{ pattern: 'Security Audit', keepFirst: true },
|
|
13
|
+
{ pattern: '[HIGH] Implement Proper Error Handling', keepFirst: true },
|
|
14
|
+
{ pattern: '[HIGH] Implement Comprehensive Testing Suite', keepFirst: true },
|
|
15
|
+
];
|
|
16
|
+
async function cancelDuplicateTasks(dryRun = true) {
|
|
17
|
+
const mode = dryRun ? 'š DRY RUN MODE' : 'ā” LIVE MODE';
|
|
18
|
+
console.log(`\n${mode} - Cancel duplicate Linear tasks\n`);
|
|
19
|
+
console.log('='.repeat(60));
|
|
20
|
+
// Load Linear tokens
|
|
21
|
+
const tokensPath = join(process.cwd(), '.stackmemory', 'linear-tokens.json');
|
|
22
|
+
let accessToken;
|
|
23
|
+
try {
|
|
24
|
+
const tokensData = readFileSync(tokensPath, 'utf8');
|
|
25
|
+
const tokens = JSON.parse(tokensData);
|
|
26
|
+
accessToken = tokens.accessToken;
|
|
27
|
+
console.log('ā
Loaded Linear authentication tokens\n');
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
console.error('ā Failed to load Linear tokens. Please run: stackmemory linear setup');
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
// GraphQL helper
|
|
34
|
+
const linearApiUrl = 'https://api.linear.app/graphql';
|
|
35
|
+
async function graphqlRequest(query, variables = {}) {
|
|
36
|
+
const response = await fetch(linearApiUrl, {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
headers: {
|
|
39
|
+
Authorization: `Bearer ${accessToken}`,
|
|
40
|
+
'Content-Type': 'application/json',
|
|
41
|
+
},
|
|
42
|
+
body: JSON.stringify({ query, variables }),
|
|
43
|
+
});
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
throw new Error(`Linear API error: ${response.status} ${response.statusText}`);
|
|
46
|
+
}
|
|
47
|
+
const result = (await response.json());
|
|
48
|
+
if (result.errors) {
|
|
49
|
+
throw new Error(`GraphQL errors: ${JSON.stringify(result.errors)}`);
|
|
50
|
+
}
|
|
51
|
+
return result.data;
|
|
52
|
+
}
|
|
53
|
+
// First, get all issues
|
|
54
|
+
console.log('Fetching all issues...\n');
|
|
55
|
+
const issuesQuery = `
|
|
56
|
+
query {
|
|
57
|
+
issues(first: 250, filter: { state: { type: { nin: ["completed", "canceled"] } } }) {
|
|
58
|
+
nodes {
|
|
59
|
+
id
|
|
60
|
+
identifier
|
|
61
|
+
title
|
|
62
|
+
description
|
|
63
|
+
createdAt
|
|
64
|
+
state {
|
|
65
|
+
id
|
|
66
|
+
name
|
|
67
|
+
type
|
|
68
|
+
}
|
|
69
|
+
team {
|
|
70
|
+
id
|
|
71
|
+
key
|
|
72
|
+
states {
|
|
73
|
+
nodes {
|
|
74
|
+
id
|
|
75
|
+
name
|
|
76
|
+
type
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
`;
|
|
84
|
+
const issuesData = (await graphqlRequest(issuesQuery));
|
|
85
|
+
const allIssues = issuesData.issues.nodes;
|
|
86
|
+
console.log(`Found ${allIssues.length} active issues\n`);
|
|
87
|
+
// Get canceled state from the first issue's team
|
|
88
|
+
const canceledState = allIssues[0]?.team?.states?.nodes?.find((s) => s.type === 'canceled');
|
|
89
|
+
if (!canceledState) {
|
|
90
|
+
console.error('ā No canceled state found in workflow');
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
// Group issues by pattern
|
|
94
|
+
const groupedIssues = new Map();
|
|
95
|
+
for (const pattern of duplicatePatterns) {
|
|
96
|
+
const matches = allIssues.filter((issue) => issue.title.includes(pattern.pattern));
|
|
97
|
+
if (matches.length > 1) {
|
|
98
|
+
// Sort by creation date to keep the oldest
|
|
99
|
+
matches.sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime());
|
|
100
|
+
groupedIssues.set(pattern.pattern, matches);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Process each group
|
|
104
|
+
let totalCanceled = 0;
|
|
105
|
+
let totalKept = 0;
|
|
106
|
+
for (const [pattern, issues] of groupedIssues.entries()) {
|
|
107
|
+
console.log(`\nš Pattern: "${pattern}"`);
|
|
108
|
+
console.log(` Found ${issues.length} matching issues:`);
|
|
109
|
+
const [primary, ...duplicates] = issues;
|
|
110
|
+
console.log(` ā
Keep: ${primary.identifier} - ${primary.title}`);
|
|
111
|
+
totalKept++;
|
|
112
|
+
for (const duplicate of duplicates) {
|
|
113
|
+
console.log(` ${dryRun ? 'š' : 'ā'} Cancel: ${duplicate.identifier} - ${duplicate.title}`);
|
|
114
|
+
if (!dryRun) {
|
|
115
|
+
try {
|
|
116
|
+
const cancelMutation = `
|
|
117
|
+
mutation CancelIssue($id: String!, $stateId: String!) {
|
|
118
|
+
issueUpdate(
|
|
119
|
+
id: $id,
|
|
120
|
+
input: {
|
|
121
|
+
stateId: $stateId,
|
|
122
|
+
description: "Duplicate task - kept ${primary.identifier}"
|
|
123
|
+
}
|
|
124
|
+
) {
|
|
125
|
+
success
|
|
126
|
+
issue {
|
|
127
|
+
identifier
|
|
128
|
+
state {
|
|
129
|
+
name
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
`;
|
|
135
|
+
await graphqlRequest(cancelMutation, {
|
|
136
|
+
id: duplicate.id,
|
|
137
|
+
stateId: canceledState.id,
|
|
138
|
+
});
|
|
139
|
+
console.log(` ā
Successfully canceled ${duplicate.identifier}`);
|
|
140
|
+
totalCanceled++;
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
console.log(` ā Failed to cancel ${duplicate.identifier}: ${error.message}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
totalCanceled++;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// Summary
|
|
152
|
+
console.log('\n' + '='.repeat(60));
|
|
153
|
+
console.log(`\n⨠${dryRun ? 'DRY RUN' : 'CLEANUP'} COMPLETE!\n`);
|
|
154
|
+
console.log('š Summary:');
|
|
155
|
+
console.log(` Duplicate groups found: ${groupedIssues.size}`);
|
|
156
|
+
console.log(` Tasks to keep: ${totalKept}`);
|
|
157
|
+
console.log(` Tasks ${dryRun ? 'to cancel' : 'canceled'}: ${totalCanceled}`);
|
|
158
|
+
console.log(` Total active tasks: ${allIssues.length}`);
|
|
159
|
+
console.log(` Tasks after cleanup: ${allIssues.length - totalCanceled}`);
|
|
160
|
+
if (dryRun) {
|
|
161
|
+
console.log('\nš” To execute these changes, run with --execute flag');
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// Parse command line arguments
|
|
165
|
+
const isDryRun = !process.argv.includes('--execute');
|
|
166
|
+
// Run the cleanup
|
|
167
|
+
cancelDuplicateTasks(isDryRun).catch((error) => {
|
|
168
|
+
console.error('ā Fatal error:', error);
|
|
169
|
+
process.exit(1);
|
|
170
|
+
});
|
|
171
|
+
//# sourceMappingURL=cancel-duplicate-tasks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cancel-duplicate-tasks.js","sourceRoot":"","sources":["../../scripts/cancel-duplicate-tasks.ts"],"names":[],"mappings":";AAEA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAO5B,8CAA8C;AAC9C,MAAM,iBAAiB,GAAgB;IACrC,EAAE,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,IAAI,EAAE;IACtD,EAAE,OAAO,EAAE,0BAA0B,EAAE,SAAS,EAAE,IAAI,EAAE;IACxD,EAAE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,IAAI,EAAE;IAC9C,EAAE,OAAO,EAAE,wCAAwC,EAAE,SAAS,EAAE,IAAI,EAAE;IACtE,EAAE,OAAO,EAAE,8CAA8C,EAAE,SAAS,EAAE,IAAI,EAAE;CAC7E,CAAC;AAEF,KAAK,UAAU,oBAAoB,CAAC,MAAM,GAAG,IAAI;IAC/C,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,aAAa,CAAC;IACxD,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,oCAAoC,CAAC,CAAC;IAC3D,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAE5B,qBAAqB;IACrB,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,oBAAoB,CAAC,CAAC;IAC7E,IAAI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