From e10b4c0d70018b959c89367bde301f09badae555 Mon Sep 17 00:00:00 2001 From: "Vincent (Wen Yu) Ge" Date: Mon, 6 Apr 2026 19:25:26 -0400 Subject: [PATCH] Add import aliases with @ --- package.json | 9 ++- pnpm-lock.yaml | 82 ++++++++++++++++++++++++++ src/ui/logging-ui.ts | 6 +- src/ui/tui/ink-ui.ts | 10 ++-- src/ui/tui/primitives/ProgressList.tsx | 4 +- src/ui/tui/screens/RunScreen.tsx | 16 ++--- src/ui/tui/store.ts | 14 ++--- src/ui/wizard-ui.ts | 4 +- tsconfig.json | 9 ++- 9 files changed, 124 insertions(+), 30 deletions(-) diff --git a/package.json b/package.json index ed3632db..25b13f4f 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,7 @@ "rimraf": "^3.0.2", "ts-jest": "^29.1.0", "ts-node": "^10.9.1", + "tsc-alias": "^1.8.16", "tsx": "^4.20.3", "typescript": "^5.0.4" }, @@ -100,7 +101,7 @@ "clean": "rm -rf ./dist", "prebuild": "pnpm clean && node scripts/generate-version.js", "build:watch": "pnpm tsc -w", - "build": "pnpm tsc", + "build": "pnpm tsc && tsc-alias", "postbuild": "chmod +x ./dist/bin.js && cp -r scripts/** dist && cp -r src/utils/rules dist/src/utils && cp src/ui/tui/package.json dist/src/ui/tui/package.json && pnpm test:smoke", "test:smoke": "node -e \"require('./dist/bin.js')\" 2>&1 | head -5 | grep -q 'PostHog Wizard' || (echo 'Smoke test failed: compiled binary crashed on load' && exit 1)", "lint": "pnpm lint:prettier && pnpm lint:eslint", @@ -150,7 +151,11 @@ ], "moduleNameMapper": { "^@anthropic-ai/claude-agent-sdk$": "/__mocks__/@anthropic-ai/claude-agent-sdk.ts", - "^(\\.{1,2}/.*)\\.js$": "$1" + "^(\\.{1,2}/.*)\\.js$": "$1", + "^@lib/(.*)$": "/src/lib/$1", + "^@utils/(.*)$": "/src/utils/$1", + "^@ui/(.*)$": "/src/ui/$1", + "^@tui/(.*)$": "/src/ui/tui/$1" } }, "lint-staged": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9d996f11..2567895d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -171,6 +171,9 @@ importers: ts-node: specifier: ^10.9.1 version: 10.9.2(@types/node@18.19.76)(typescript@5.7.3) + tsc-alias: + specifier: ^1.8.16 + version: 1.8.16 tsx: specifier: ^4.20.3 version: 4.20.3 @@ -1670,6 +1673,10 @@ packages: resolution: {integrity: sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==} engines: {node: '>=0.6'} + binary-extensions@2.3.0: + resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} + engines: {node: '>=8'} + bplist-creator@0.1.0: resolution: {integrity: sha512-sXaHZicyEEmY86WyueLTQesbeoH/mquvarJaQNbjuOQO+7gbFcDEWqKmcWA4cOTLzFlfgvkiVxolk1k5bBIpmg==} @@ -1756,6 +1763,10 @@ packages: chardet@0.7.0: resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} + chokidar@3.6.0: + resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} + engines: {node: '>= 8.10.0'} + ci-info@3.9.0: resolution: {integrity: sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==} engines: {node: '>=8'} @@ -1840,6 +1851,10 @@ packages: resolution: {integrity: sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==} engines: {node: '>=18'} + commander@9.5.0: + resolution: {integrity: sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==} + engines: {node: ^12.20.0 || >=14} + concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} @@ -2349,6 +2364,10 @@ packages: is-arrayish@0.2.1: resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} + is-binary-path@2.1.0: + resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} + engines: {node: '>=8'} + is-core-module@2.16.1: resolution: {integrity: sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==} engines: {node: '>= 0.4'} @@ -2781,6 +2800,10 @@ packages: resolution: {integrity: sha512-WWdIxpyjEn+FhQJQQv9aQAYlHoNVdzIzUySNV1gHUPDSdZJ3yZn7pAAbQcV7B56Mvu881q9FZV+0Vx2xC44VWA==} engines: {node: ^18.17.0 || >=20.5.0} + mylas@2.1.14: + resolution: {integrity: sha512-BzQguy9W9NJgoVn2mRWzbFrFWWztGCcng2QI9+41frfk+Athwgx3qhqhvStz7ExeUUu7Kzw427sNzHpEZNINog==} + engines: {node: '>=16.0.0'} + nanostores@1.1.1: resolution: {integrity: sha512-EYJqS25r2iBeTtGQCHidXl1VfZ1jXM7Q04zXJOrMlxVVmD0ptxJaNux92n1mJ7c5lN3zTq12MhH/8x59nP+qmg==} engines: {node: ^20.0.0 || >=22.0.0} @@ -2956,6 +2979,10 @@ packages: resolution: {integrity: sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==} engines: {node: '>=8'} + plimit-lit@1.6.1: + resolution: {integrity: sha512-B7+VDyb8Tl6oMJT9oSO2CW8XC/T4UcJGrwOVoNGwOQsQYhlpfajmrMj5xeejqaASq3V/EqThyOeATEOMuSEXiA==} + engines: {node: '>=12'} + plist@3.1.0: resolution: {integrity: sha512-uysumyrvkUX0rX/dEVqt8gC3sTBzd4zoWfLeS29nb53imdaXVvLINYXTI2GNqzaMuvacNx4uJQ8+b3zXR0pkgQ==} engines: {node: '>=10.4.0'} @@ -2997,6 +3024,10 @@ packages: querystringify@2.2.0: resolution: {integrity: sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==} + queue-lit@1.5.2: + resolution: {integrity: sha512-tLc36IOPeMAubu8BkW8YDBV+WyIgKlYU7zUNs0J5Vk9skSZ4JfGlPOqplP0aHdfv7HL0B2Pg6nwiq60Qc6M2Hw==} + engines: {node: '>=12'} + queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} @@ -3016,6 +3047,10 @@ packages: read-env@1.3.0: resolution: {integrity: sha512-DbCgZ8oHwZreK/E2E27RGk3EUPapMhYGSGIt02k9sX6R3tCFc4u4tkltKvkCvzEQ3SOLUaiYHAnGb+TdsnPp0A==} + readdirp@3.6.0: + resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} + engines: {node: '>=8.10.0'} + recast@0.23.9: resolution: {integrity: sha512-Hx/BGIbwj+Des3+xy5uAtAbdCyqK9y9wbBcDFDYanLS9JnMqf7OeF87HQwUimE87OEc72mr6tkKUKMBBL+hF9Q==} engines: {node: '>= 4'} @@ -3350,6 +3385,11 @@ packages: '@swc/wasm': optional: true + tsc-alias@1.8.16: + resolution: {integrity: sha512-QjCyu55NFyRSBAl6+MTFwplpFcnm2Pq01rR/uxfqJoLMm6X3O14KEGtaSDZpJYaE1bJBGDjD0eSuiIWPe2T58g==} + engines: {node: '>=16.20.2'} + hasBin: true + tslib@1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} @@ -5309,6 +5349,8 @@ snapshots: big-integer@1.6.52: {} + binary-extensions@2.3.0: {} + bplist-creator@0.1.0: dependencies: stream-buffers: 2.2.0 @@ -5391,6 +5433,18 @@ snapshots: chardet@0.7.0: {} + chokidar@3.6.0: + dependencies: + anymatch: 3.1.3 + braces: 3.0.3 + glob-parent: 5.1.2 + is-binary-path: 2.1.0 + is-glob: 4.0.3 + normalize-path: 3.0.0 + readdirp: 3.6.0 + optionalDependencies: + fsevents: 2.3.3 + ci-info@3.9.0: {} cjs-module-lexer@1.4.3: {} @@ -5465,6 +5519,8 @@ snapshots: commander@13.1.0: {} + commander@9.5.0: {} + concat-map@0.0.1: {} console-table-printer@2.12.1: @@ -6016,6 +6072,10 @@ snapshots: is-arrayish@0.2.1: {} + is-binary-path@2.1.0: + dependencies: + binary-extensions: 2.3.0 + is-core-module@2.16.1: dependencies: hasown: 2.0.2 @@ -6619,6 +6679,8 @@ snapshots: mute-stream@2.0.0: {} + mylas@2.1.14: {} + nanostores@1.1.1: {} natural-compare-lite@1.4.0: {} @@ -6762,6 +6824,10 @@ snapshots: dependencies: find-up: 4.1.0 + plimit-lit@1.6.1: + dependencies: + queue-lit: 1.5.2 + plist@3.1.0: dependencies: '@xmldom/xmldom': 0.8.10 @@ -6799,6 +6865,8 @@ snapshots: querystringify@2.2.0: {} + queue-lit@1.5.2: {} + queue-microtask@1.2.3: {} react-is@18.3.1: {} @@ -6814,6 +6882,10 @@ snapshots: dependencies: camelcase: 5.0.0 + readdirp@3.6.0: + dependencies: + picomatch: 2.3.1 + recast@0.23.9: dependencies: ast-types: 0.16.1 @@ -7115,6 +7187,16 @@ snapshots: v8-compile-cache-lib: 3.0.1 yn: 3.1.1 + tsc-alias@1.8.16: + dependencies: + chokidar: 3.6.0 + commander: 9.5.0 + get-tsconfig: 4.10.0 + globby: 11.1.0 + mylas: 2.1.14 + normalize-path: 3.0.0 + plimit-lit: 1.6.1 + tslib@1.14.1: {} tslib@2.8.1: {} diff --git a/src/ui/logging-ui.ts b/src/ui/logging-ui.ts index 574c66f5..45112fea 100644 --- a/src/ui/logging-ui.ts +++ b/src/ui/logging-ui.ts @@ -4,9 +4,9 @@ * No prompts, no TUI, no interactivity. Just console output. */ -import { TaskStatus, type WizardUI, type SpinnerHandle } from './wizard-ui'; -import type { SettingsConflict } from '../lib/agent-interface'; -import type { WizardWorkflowQueue } from '../lib/workflow-queue'; +import { TaskStatus, type WizardUI, type SpinnerHandle } from '@ui/wizard-ui'; +import type { SettingsConflict } from '@lib/agent-interface'; +import type { WizardWorkflowQueue } from '@lib/workflow-queue'; export class LoggingUI implements WizardUI { intro(message: string): void { diff --git a/src/ui/tui/ink-ui.ts b/src/ui/tui/ink-ui.ts index 33e51b06..7564af42 100644 --- a/src/ui/tui/ink-ui.ts +++ b/src/ui/tui/ink-ui.ts @@ -6,11 +6,11 @@ * The router derives the active screen from session state. */ -import type { WizardUI, SpinnerHandle } from '../wizard-ui.js'; -import type { WizardStore } from './store.js'; -import type { SettingsConflict } from '../../lib/agent-interface.js'; -import type { WizardWorkflowQueue } from '../../lib/workflow-queue.js'; -import { RunPhase, OutroKind } from '../../lib/wizard-session.js'; +import type { WizardUI, SpinnerHandle } from '@ui/wizard-ui.js'; +import type { WizardStore } from '@tui/store.js'; +import type { SettingsConflict } from '@lib/agent-interface.js'; +import type { WizardWorkflowQueue } from '@lib/workflow-queue.js'; +import { RunPhase, OutroKind } from '@lib/wizard-session.js'; // Strip ANSI escape codes (chalk formatting) from strings // eslint-disable-next-line no-control-regex diff --git a/src/ui/tui/primitives/ProgressList.tsx b/src/ui/tui/primitives/ProgressList.tsx index 40355d2c..a964a929 100644 --- a/src/ui/tui/primitives/ProgressList.tsx +++ b/src/ui/tui/primitives/ProgressList.tsx @@ -5,9 +5,9 @@ import { Box, Text } from 'ink'; import { Spinner } from '@inkjs/ui'; -import { Colors, Icons } from '../styles.js'; +import { Colors, Icons } from '@tui/styles.js'; import { LoadingBox } from './LoadingBox.js'; -import { TaskStatus } from '../../wizard-ui.js'; +import { TaskStatus } from '@ui/wizard-ui.js'; export interface ProgressItem { label: string; diff --git a/src/ui/tui/screens/RunScreen.tsx b/src/ui/tui/screens/RunScreen.tsx index b0811dfd..9c05649b 100644 --- a/src/ui/tui/screens/RunScreen.tsx +++ b/src/ui/tui/screens/RunScreen.tsx @@ -11,7 +11,7 @@ import { useSyncExternalStore } from 'react'; import { Box } from 'ink'; -import type { WizardStore } from '../store.js'; +import type { WizardStore } from '@tui/store.js'; import { TabContainer, SplitView, @@ -19,13 +19,13 @@ import { LogViewer, EventPlanViewer, HNViewer, -} from '../primitives/index.js'; -import type { ProgressItem } from '../primitives/index.js'; -import { TaskStatus } from '../../wizard-ui.js'; -import { ADDITIONAL_FEATURE_LABELS } from '../../../lib/wizard-session.js'; -import { LearnCard } from '../components/LearnCard.js'; -import { TipsCard } from '../components/TipsCard.js'; -import { useStdoutDimensions } from '../hooks/useStdoutDimensions.js'; +} from '@tui/primitives/index.js'; +import type { ProgressItem } from '@tui/primitives/index.js'; +import { TaskStatus } from '@ui/wizard-ui.js'; +import { ADDITIONAL_FEATURE_LABELS } from '@lib/wizard-session.js'; +import { LearnCard } from '@tui/components/LearnCard.js'; +import { TipsCard } from '@tui/components/TipsCard.js'; +import { useStdoutDimensions } from '@tui/hooks/useStdoutDimensions.js'; const LOG_FILE = '/tmp/posthog-wizard.log'; diff --git a/src/ui/tui/store.ts b/src/ui/tui/store.ts index d5d95584..dca3134f 100644 --- a/src/ui/tui/store.ts +++ b/src/ui/tui/store.ts @@ -11,7 +11,7 @@ */ import { atom, map } from 'nanostores'; -import { TaskStatus } from '../wizard-ui.js'; +import { TaskStatus } from '@ui/wizard-ui.js'; import { type WizardSession, type OutroData, @@ -20,21 +20,21 @@ import { McpOutcome, RunPhase, buildSession, -} from '../../lib/wizard-session.js'; -import type { SettingsConflict } from '../../lib/agent-interface.js'; +} from '@lib/wizard-session.js'; +import type { SettingsConflict } from '@lib/agent-interface.js'; import { WizardRouter, type ScreenName, Screen, Overlay, Flow, -} from './router.js'; -import { analytics, sessionProperties } from '../../utils/analytics.js'; +} from '@tui/router.js'; +import { analytics, sessionProperties } from '@utils/analytics.js'; import { evaluateWizardReadiness, WizardReadiness, -} from '../../lib/health-checks/readiness.js'; -import type { WizardWorkflowQueue } from '../../lib/workflow-queue.js'; +} from '@lib/health-checks/readiness.js'; +import type { WizardWorkflowQueue } from '@lib/workflow-queue.js'; export { TaskStatus, Screen, Overlay, Flow, RunPhase, McpOutcome }; export type { ScreenName, OutroData, WizardSession }; diff --git a/src/ui/wizard-ui.ts b/src/ui/wizard-ui.ts index 8a8beafc..a83d7312 100644 --- a/src/ui/wizard-ui.ts +++ b/src/ui/wizard-ui.ts @@ -8,8 +8,8 @@ * Session-mutating methods trigger reactive screen resolution in the TUI. */ -import type { SettingsConflict } from '../lib/agent-interface'; -import type { WizardWorkflowQueue } from '../lib/workflow-queue'; +import type { SettingsConflict } from '@lib/agent-interface'; +import type { WizardWorkflowQueue } from '@lib/workflow-queue'; export enum TaskStatus { Pending = 'pending', diff --git a/tsconfig.json b/tsconfig.json index 69f59407..b3aaf1e5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,14 @@ "typeRoots": ["./node_modules/@types", "./types"], "declaration": true, "resolveJsonModule": true, - "outDir": "dist" + "outDir": "dist", + "baseUrl": ".", + "paths": { + "@lib/*": ["./src/lib/*"], + "@utils/*": ["./src/utils/*"], + "@ui/*": ["./src/ui/*"], + "@tui/*": ["./src/ui/tui/*"] + } }, "include": [ "__tests__",