From 870eb4db77cb25e4807722713361e40bf30a4096 Mon Sep 17 00:00:00 2001 From: Michael Zhou Date: Tue, 1 Dec 2026 18:54:42 +0800 Subject: [PATCH 1/3] Make scripts a workspace package Co-Authored-By: Claude Code --- packages/outpost/package.json | 4 +++ pnpm-lock.yaml | 25 ++++++++++++++++++ pnpm-workspace.yaml | 5 ++-- scripts/import-linear.ts | 49 ++++++++++++++++------------------- scripts/package.json | 21 +++++++++++++++ scripts/tsconfig.json | 3 +-- scripts/vitest.config.ts | 8 ++++++ 7 files changed, 85 insertions(+), 30 deletions(-) create mode 100644 scripts/package.json create mode 100644 scripts/vitest.config.ts diff --git a/packages/outpost/package.json b/packages/outpost/package.json index be74ac3a..4f5e1f3e 100644 --- a/packages/outpost/package.json +++ b/packages/outpost/package.json @@ -20,6 +20,10 @@ "types": "./shared/dist/index.d.ts", "import": "./shared/dist/index.js" }, + "./shared/source": { + "types": "./shared/src/index.ts", + "import": "./shared/src/index.ts" + }, "./shared/platforms": { "types": "./shared/dist/platforms/index.d.ts", "import": "./shared/dist/platforms/index.js" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5c65102e..8d1bbab1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -398,6 +398,31 @@ importers: specifier: ^4.1.4 version: 4.1.4(@types/node@22.19.17)(jsdom@29.0.2)(vite@8.0.8(@types/node@22.19.17)(esbuild@0.27.7)(jiti@2.6.1)(tsx@4.21.0)) + scripts: + dependencies: + '@copilotkit/outpost': + specifier: workspace:* + version: link:../packages/outpost + '@linear/sdk': + specifier: ^81.0.0 + version: 81.0.0(graphql@16.13.2) + '@prisma/client': + specifier: ^6.2.0 + version: 6.19.3(prisma@6.19.3(typescript@5.9.3))(typescript@5.9.3) + devDependencies: + '@types/node': + specifier: ^22.10.0 + version: 22.19.17 + tsx: + specifier: ^4.21.0 + version: 4.21.0 + typescript: + specifier: ^5.7.0 + version: 5.9.3 + vitest: + specifier: ^4.1.4 + version: 4.1.4(@types/node@22.19.17)(jsdom@29.0.2)(vite@8.0.8(@types/node@22.19.17)(esbuild@0.27.7)(jiti@2.6.1)(tsx@4.21.0)) + packages: '@adobe/css-tools@4.4.4': diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 4af31626..8c4493ce 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,3 +1,4 @@ packages: - - "apps/*" - - "packages/*" + - 'apps/*' + - 'packages/*' + - 'scripts' diff --git a/scripts/import-linear.ts b/scripts/import-linear.ts index d336aef2..8a5e0dab 100644 --- a/scripts/import-linear.ts +++ b/scripts/import-linear.ts @@ -16,7 +16,7 @@ import { createLinearStatusMap, createLinearPriorityMap, createLinearLabelMapper, -} from '../packages/outpost/shared/src/sync/index.js'; +} from '@copilotkit/outpost/shared/source'; // ─── Types ──────────────────────────────────────────────────────────────── @@ -78,7 +78,7 @@ let displayIdCounter = 0; async function nextDisplayId(prisma: PrismaClient): Promise { if (displayIdCounter === 0) { - const latest = await (prisma.ticket as { findFirst: (args: Record) => Promise<{ displayId: string } | null> }).findFirst({ + const latest = await prisma.ticket.findFirst({ orderBy: { createdAt: 'desc' }, select: { displayId: true }, }); @@ -132,9 +132,7 @@ export async function importLinearIssues( for (const issue of issuesPage.nodes) { try { // Check if this issue is already linked - const existingLink = await (prisma.ticketExternalLink as { - findUnique: (args: Record) => Promise<{ id: string; ticketId: string } | null>; - }).findUnique({ + const existingLink = await prisma.ticketExternalLink.findUnique({ where: { plugin_externalId: { plugin: 'linear', @@ -145,7 +143,9 @@ export async function importLinearIssues( if (existingLink) { report.skipped++; - console.log(` SKIP ${issue.identifier}: already linked to ${existingLink.ticketId}`); + console.log( + ` SKIP ${issue.identifier}: already linked to ${existingLink.ticketId}`, + ); continue; } @@ -157,9 +157,7 @@ export async function importLinearIssues( const url = attachment.url; if (url && /github\.com\/.*\/(issues|pull)\/\d+/.test(url)) { // Try to find an existing ticket linked to this GitHub URL - const githubLink = await (prisma.ticketExternalLink as { - findFirst: (args: Record) => Promise<{ ticketId: string } | null>; - }).findFirst({ + const githubLink = await prisma.ticketExternalLink.findFirst({ where: { plugin: 'github', externalUrl: url, @@ -175,9 +173,7 @@ export async function importLinearIssues( if (matchedTicketId) { // Cross-reference match: link to existing ticket if (!args.dryRun) { - await (prisma.ticketExternalLink as { - create: (args: Record) => Promise; - }).create({ + await prisma.ticketExternalLink.create({ data: { ticketId: matchedTicketId, plugin: 'linear', @@ -203,16 +199,16 @@ export async function importLinearIssues( const outpostTags = labelMapper.toOutpost(labelNames); if (args.dryRun) { - console.log(` DRY-RUN ${issue.identifier}: would create ticket (${outpostStatus}, ${outpostPriority})`); + console.log( + ` DRY-RUN ${issue.identifier}: would create ticket (${outpostStatus}, ${outpostPriority})`, + ); report.created++; continue; } // Create the Outpost ticket const displayId = await nextDisplayId(prisma); - const ticket = await (prisma.ticket as { - create: (args: Record) => Promise<{ id: string }>; - }).create({ + const ticket = await prisma.ticket.create({ data: { displayId, title: issue.title, @@ -233,9 +229,7 @@ export async function importLinearIssues( }); // Create the external link - await (prisma.ticketExternalLink as { - create: (args: Record) => Promise; - }).create({ + await prisma.ticketExternalLink.create({ data: { ticketId: ticket.id, plugin: 'linear', @@ -249,9 +243,7 @@ export async function importLinearIssues( const comments = await issue.comments(); for (const comment of comments.nodes) { const authorUser = await comment.user; - await (prisma.message as { - create: (args: Record) => Promise; - }).create({ + await prisma.message.create({ data: { ticketId: ticket.id, author: authorUser?.name ?? 'Unknown', @@ -262,7 +254,9 @@ export async function importLinearIssues( } report.created++; - console.log(` CREATE ${issue.identifier} → ${displayId} (${comments.nodes.length} comments)`); + console.log( + ` CREATE ${issue.identifier} → ${displayId} (${comments.nodes.length} comments)`, + ); } catch (err) { const message = err instanceof Error ? err.message : String(err); report.failed++; @@ -275,7 +269,7 @@ export async function importLinearIssues( } hasMore = issuesPage.pageInfo.hasNextPage; - afterCursor = issuesPage.pageInfo.endCursor; + afterCursor = issuesPage.pageInfo.endCursor ?? undefined; } return report; @@ -287,7 +281,9 @@ async function main(): Promise { const args = parseArgs(process.argv); if (!args.teamId) { - console.error('Usage: npx tsx scripts/import-linear.ts --team-id [--dry-run] [--since DATE]'); + console.error( + 'Usage: npx tsx scripts/import-linear.ts --team-id [--dry-run] [--since DATE]', + ); process.exit(1); } @@ -331,7 +327,8 @@ async function main(): Promise { } // Only run when executed directly (not when imported by tests) -const isDirectRun = process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/.*\//, '')); +const isDirectRun = + process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/.*\//, '')); if (isDirectRun) { main().catch((err) => { console.error('Fatal error:', err); diff --git a/scripts/package.json b/scripts/package.json new file mode 100644 index 00000000..d04fce0b --- /dev/null +++ b/scripts/package.json @@ -0,0 +1,21 @@ +{ + "name": "@copilotkit/outpost-scripts", + "version": "0.1.0", + "private": true, + "type": "module", + "scripts": { + "test": "vitest run", + "typecheck": "tsc --project tsconfig.json --noEmit" + }, + "dependencies": { + "@copilotkit/outpost": "workspace:*", + "@linear/sdk": "^81.0.0", + "@prisma/client": "^6.2.0" + }, + "devDependencies": { + "@types/node": "^22.10.0", + "tsx": "^4.21.0", + "typescript": "^5.7.0", + "vitest": "^4.1.4" + } +} diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index cceae7e9..e2749a5a 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -11,6 +11,5 @@ "noEmit": true, "forceConsistentCasingInFileNames": true }, - "include": ["**/*.ts"], - "exclude": ["__tests__"] + "include": ["**/*.ts"] } diff --git a/scripts/vitest.config.ts b/scripts/vitest.config.ts new file mode 100644 index 00000000..cb8bb282 --- /dev/null +++ b/scripts/vitest.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + test: { + globals: true, + include: ['__tests__/**/*.test.ts'], + }, +}); From a062c46b51b1cbe96ca30d6faf9587107167a247 Mon Sep 17 00:00:00 2001 From: Michael Zhou Date: Wed, 2 Dec 2026 13:37:35 +0800 Subject: [PATCH 2/3] Address review feedback for the scripts workspace Remove the redundant root vitest config and root-only script dependencies. Limit the source export to the sync subpath and document that it is only for tsx and vitest. Co-Authored-By: Claude Code --- package.json | 2 -- packages/outpost/package.json | 6 +++--- pnpm-lock.yaml | 6 ------ scripts/import-linear.ts | 3 ++- turbo.json | 2 +- vitest.config.ts | 8 -------- 6 files changed, 6 insertions(+), 21 deletions(-) delete mode 100644 vitest.config.ts diff --git a/package.json b/package.json index c5e0e73a..e1984f28 100644 --- a/package.json +++ b/package.json @@ -17,12 +17,10 @@ }, "devDependencies": { "@eslint/js": "^9.39.4", - "@linear/sdk": "^81.0.0", "@typescript-eslint/eslint-plugin": "^8.58.2", "@typescript-eslint/parser": "^8.58.2", "eslint": "^9.16.0", "prettier": "^3.2.0", - "tsx": "^4.21.0", "turbo": "^2.3.0", "typescript": "^5.7.0", "vitest": "^4.1.4" diff --git a/packages/outpost/package.json b/packages/outpost/package.json index 4f5e1f3e..176e4510 100644 --- a/packages/outpost/package.json +++ b/packages/outpost/package.json @@ -20,9 +20,9 @@ "types": "./shared/dist/index.d.ts", "import": "./shared/dist/index.js" }, - "./shared/source": { - "types": "./shared/src/index.ts", - "import": "./shared/src/index.ts" + "./shared/source/sync": { + "types": "./shared/src/sync/index.ts", + "import": "./shared/src/sync/index.ts" }, "./shared/platforms": { "types": "./shared/dist/platforms/index.d.ts", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8d1bbab1..5f677128 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,9 +11,6 @@ importers: '@eslint/js': specifier: ^9.39.4 version: 9.39.4 - '@linear/sdk': - specifier: ^81.0.0 - version: 81.0.0(graphql@16.13.2) '@typescript-eslint/eslint-plugin': specifier: ^8.58.2 version: 8.58.2(@typescript-eslint/parser@8.58.2(eslint@9.39.4(jiti@2.6.1))(typescript@5.9.3))(eslint@9.39.4(jiti@2.6.1))(typescript@5.9.3) @@ -26,9 +23,6 @@ importers: prettier: specifier: ^3.2.0 version: 3.8.3 - tsx: - specifier: ^4.21.0 - version: 4.21.0 turbo: specifier: ^2.3.0 version: 2.9.6 diff --git a/scripts/import-linear.ts b/scripts/import-linear.ts index 8a5e0dab..de9a38d8 100644 --- a/scripts/import-linear.ts +++ b/scripts/import-linear.ts @@ -12,11 +12,12 @@ import { LinearClient } from '@linear/sdk'; import { PrismaClient } from '@prisma/client'; +// Source-only subpath for tsx and vitest; runtime packages import @copilotkit/outpost/shared. import { createLinearStatusMap, createLinearPriorityMap, createLinearLabelMapper, -} from '@copilotkit/outpost/shared/source'; +} from '@copilotkit/outpost/shared/source/sync'; // ─── Types ──────────────────────────────────────────────────────────────── diff --git a/turbo.json b/turbo.json index 2d75b78a..9cbdb06e 100644 --- a/turbo.json +++ b/turbo.json @@ -4,7 +4,7 @@ // EVERY package, so a file listed here busts build and test caches too. tsconfig.json // qualifies — everything builds and typechecks against it. The ESLint config does not, // and lives on the lint task's `inputs` instead; it cannot change a build or test result, - // which is the same reason .prettierrc and the root vitest.config.ts are absent. + // which is the same reason .prettierrc is absent. "globalDependencies": ["tsconfig.json"], // Pinned rather than relying on turbo 2's default, so the reasoning below cannot be // invalidated by a future change to that default: in strict mode a task sees only the diff --git a/vitest.config.ts b/vitest.config.ts deleted file mode 100644 index 40f3a2b9..00000000 --- a/vitest.config.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { defineConfig } from 'vitest/config'; - -export default defineConfig({ - test: { - globals: true, - include: ['scripts/__tests__/**/*.test.ts'], - }, -}); From 3993a525a7a5e54bcc2dc651298a760861dac246 Mon Sep 17 00:00:00 2001 From: Michael Zhou Date: Thu, 3 Dec 2026 20:07:42 +0800 Subject: [PATCH 3/3] Restore tsx in the root devDependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit npx tsx scripts/... from the repo root is the documented way to run the import and cutover scripts (scripts/cutover/README.md and both scripts' usage text), and with tsx only in scripts/package.json npx no longer finds a local copy there — it fetches an unpinned version or fails. @linear/sdk stays in scripts/package.json. Co-Authored-By: Claude Code --- package.json | 1 + pnpm-lock.yaml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/package.json b/package.json index e1984f28..faf5b8b0 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@typescript-eslint/parser": "^8.58.2", "eslint": "^9.16.0", "prettier": "^3.2.0", + "tsx": "^4.21.0", "turbo": "^2.3.0", "typescript": "^5.7.0", "vitest": "^4.1.4" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5f677128..78bc5ea6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,6 +23,9 @@ importers: prettier: specifier: ^3.2.0 version: 3.8.3 + tsx: + specifier: ^4.21.0 + version: 4.21.0 turbo: specifier: ^2.3.0 version: 2.9.6