Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 39 additions & 39 deletions bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { VERSION } from './src/lib/version.js';
import { VERSION } from '@lib/version';

const WIZARD_VERSION = VERSION;

Check warning on line 8 in bin.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe assignment of an `any` value

const NODE_VERSION_RANGE = '>=18.17.0';

Expand All @@ -19,16 +19,16 @@
process.exit(1);
}

import { isNonInteractiveEnvironment } from './src/utils/environment';
import { getUI, setUI } from './src/ui';
import { LoggingUI } from './src/ui/logging-ui';
import { isNonInteractiveEnvironment } from '@utils/environment';
import { getUI, setUI } from '@ui';
import { LoggingUI } from '@ui/logging-ui';
import {
getSubcommandPrograms,
Program,
} from './src/lib/programs/program-registry';
import type { ProgramConfig } from './src/lib/programs/program-step';
import type { WizardSession } from './src/lib/wizard-session';
import { POSTHOG_DOCS_URL } from './src/lib/constants';
} from '@lib/programs/program-registry';
import type { ProgramConfig } from '@lib/programs/program-step';
import type { WizardSession } from '@lib/wizard-session';
import { POSTHOG_DOCS_URL } from '@lib/constants';
import { runtimeEnv } from '@env';

// Test mock server — only loaded when NODE_ENV is 'test'.
Expand Down Expand Up @@ -258,7 +258,7 @@
getUI().intro('PostHog Wizard');
try {
const { provisionNewAccount } = await import(
'./src/utils/provisioning.js'
'@utils/provisioning'
);
const signupRegion = (options.region as string).toUpperCase() as
| 'US'
Expand Down Expand Up @@ -298,14 +298,14 @@
}

const { posthogIntegrationConfig } = await import(
'./src/lib/programs/posthog-integration/index.js'
'@lib/programs/posthog-integration/index'
);
const { FRAMEWORK_REGISTRY } = await import('./src/lib/registry.js');
const { FRAMEWORK_REGISTRY } = await import('@lib/registry');
const { detectFramework, gatherFrameworkContext } = await import(
'./src/lib/detection/index.js'
'@lib/detection/index'
);
const { analytics } = await import('./src/utils/analytics.js');
const { wizardAbort } = await import('./src/utils/wizard-abort.js');
const { analytics } = await import('@utils/analytics');
const { wizardAbort } = await import('@utils/wizard-abort');

// preRun: honor --integration, else auto-detect, then gather
// framework context. Bypasses onReady hooks by design.
Expand Down Expand Up @@ -362,15 +362,15 @@
// Playground mode: launch the TUI primitives playground
void (async () => {
const { startPlayground } = await import(
'./src/ui/tui/playground/start-playground.js'
'@ui/tui/playground/start-playground'
);
(startPlayground as (version: string) => void)(WIZARD_VERSION);

Check warning on line 367 in bin.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe argument of type `any` assigned to a parameter of type `string`
})();
} else if (options.skill) {
// Run a specific skill by ID
void (async () => {
const { createSkillProgram } = await import(
'./src/lib/programs/agent-skill/index.js'
'@lib/programs/agent-skill/index'
);
const skillId = options.skill as string;
const config = createSkillProgram({
Expand All @@ -392,7 +392,7 @@
// Same codepath as `npx @posthog/wizard integrate`.
void (async () => {
const { posthogIntegrationConfig } = await import(
'./src/lib/programs/posthog-integration/index.js'
'@lib/programs/posthog-integration/index'
);
runWizard(posthogIntegrationConfig, options);
})();
Expand Down Expand Up @@ -432,18 +432,18 @@
.filter(Boolean);
void (async () => {
const { readApiKeyFromEnv } = await import(
'./src/utils/env-api-key.js'
'@utils/env-api-key'
);
const apiKey =
(options.apiKey as string | undefined) || readApiKeyFromEnv();

try {
const { startTUI } = await import('./src/ui/tui/start-tui.js');
const { startTUI } = await import('@ui/tui/start-tui');
const { buildSession } = await import(
'./src/lib/wizard-session.js'
'@lib/wizard-session'
);

const tui = startTUI(WIZARD_VERSION, Program.McpAdd);

Check warning on line 446 in bin.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe argument of type `any` assigned to a parameter of type `string`
const session = buildSession({
debug: options.debug,
localMcp: options.local,
Expand All @@ -455,7 +455,7 @@
// TUI unavailable — fallback to logging
setUI(new LoggingUI());
const { addMCPServerToClientsStep } = await import(
'./src/steps/add-mcp-server-to-clients/index.js'
'@steps/add-mcp-server-to-clients/index'
);
await addMCPServerToClientsStep({
local: options.local,
Expand Down Expand Up @@ -483,12 +483,12 @@
const options = { ...argv };
void (async () => {
try {
const { startTUI } = await import('./src/ui/tui/start-tui.js');
const { startTUI } = await import('@ui/tui/start-tui');
const { buildSession } = await import(
'./src/lib/wizard-session.js'
'@lib/wizard-session'
);

const tui = startTUI(WIZARD_VERSION, Program.McpRemove);

Check warning on line 491 in bin.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe argument of type `any` assigned to a parameter of type `string`
const session = buildSession({
debug: options.debug,
localMcp: options.local,
Expand All @@ -498,7 +498,7 @@
// TUI unavailable — fallback to logging
setUI(new LoggingUI());
const { removeMCPServerFromClientsStep } = await import(
'./src/steps/add-mcp-server-to-clients/index.js'
'@steps/add-mcp-server-to-clients/index'
);
await removeMCPServerFromClientsStep({
local: options.local,
Expand Down Expand Up @@ -558,7 +558,7 @@
void (async () => {
try {
const { provisionNewAccount } = await import(
'./src/utils/provisioning.js'
'@utils/provisioning'
);
if (!jsonMode) {
getUI().log.info(`Provisioning account for ${email} in ${region}...`);
Expand Down Expand Up @@ -598,7 +598,7 @@
// ── Skill-based program subcommands (derived from registry) ─────────
for (const programConfig of getSubcommandPrograms()) {
cli.command(
programConfig.command!,

Check warning on line 601 in bin.ts

View workflow job for this annotation

GitHub Actions / Lint

Forbidden non-null assertion
programConfig.description,
(y) =>
y.options({
Expand Down Expand Up @@ -638,18 +638,18 @@
try {
const installDir = (options.installDir as string) || process.cwd();

const { startTUI } = await import('./src/ui/tui/start-tui.js');
const { buildSession } = await import('./src/lib/wizard-session.js');
const { TaskStreamPush } = await import('./src/lib/task-stream/index.js');
const { startTUI } = await import('@ui/tui/start-tui');
const { buildSession } = await import('@lib/wizard-session');
const { TaskStreamPush } = await import('@lib/task-stream/index');
const { FileDestination } = await import(
'./src/lib/task-stream/destinations/file.js'
'@lib/task-stream/destinations/file'
);
const { PostHogDestination } = await import(
'./src/lib/task-stream/destinations/posthog.js'
'@lib/task-stream/destinations/posthog'
);
const { analytics } = await import('./src/utils/analytics.js');
const { analytics } = await import('@utils/analytics');

const tui = startTUI(WIZARD_VERSION, config.id as any);

Check warning on line 652 in bin.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

Check warning on line 652 in bin.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe argument of type `any` assigned to a parameter of type `string`

Check warning on line 652 in bin.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe argument of type `any` assigned to a parameter of type `string`

const session = buildSession({
debug: options.debug as boolean | undefined,
Expand All @@ -662,7 +662,7 @@
projectId: options.projectId as string | undefined,
email: options.email as string | undefined,
menu: options.menu as boolean | undefined,
integration: options.integration as any,

Check warning on line 665 in bin.ts

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type

Check warning on line 665 in bin.ts

View workflow job for this annotation

GitHub Actions / Lint

Unsafe assignment of an `any` value
benchmark: options.benchmark as boolean | undefined,
yaraReport: options.yaraReport as boolean | undefined,
});
Expand Down Expand Up @@ -691,7 +691,7 @@

if (skipAgent) {
const { getOrAskForProjectData } = await import(
'./src/utils/setup-utils.js'
'@utils/setup-utils'
);
const { projectApiKey, host, accessToken, projectId } =
await getOrAskForProjectData({
Expand All @@ -707,7 +707,7 @@
projectId,
});
} else {
const { runAgent } = await import('./src/lib/agent/agent-runner.js');
const { runAgent } = await import('@lib/agent/agent-runner');
await runAgent(config, tui.store.session);
}

Expand Down Expand Up @@ -774,14 +774,14 @@

void (async () => {
const path = await import('path');
const { buildSession } = await import('./src/lib/wizard-session.js');
const { readEnvironment } = await import('./src/utils/environment.js');
const { readApiKeyFromEnv } = await import('./src/utils/env-api-key.js');
const { buildSession } = await import('@lib/wizard-session');
const { readEnvironment } = await import('@utils/environment');
const { readApiKeyFromEnv } = await import('@utils/env-api-key');
const { configureLogFileFromEnvironment, logToFile } = await import(
'./src/utils/debug.js'
'@utils/debug'
);
const { wizardAbort, WizardError } = await import(
'./src/utils/wizard-abort.js'
'@utils/wizard-abort'
);

configureLogFileFromEnvironment();
Expand Down Expand Up @@ -857,7 +857,7 @@
}
}

const { runAgent } = await import('./src/lib/agent/agent-runner.js');
const { runAgent } = await import('@lib/agent/agent-runner');
await runAgent(config, session);
} catch (error) {
const errorMessage =
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@
"^@env$": "<rootDir>/src/env.ts",
"^@lib/(.*)$": "<rootDir>/src/lib/$1",
"^@utils/(.*)$": "<rootDir>/src/utils/$1",
"^@ui$": "<rootDir>/src/ui/index.ts",
"^@ui/(.*)$": "<rootDir>/src/ui/$1",
"^@steps$": "<rootDir>/src/steps/index.ts",
"^@steps/(.*)$": "<rootDir>/src/steps/$1",
"^@frameworks/(.*)$": "<rootDir>/src/frameworks/$1",
"^(\\.{1,2}/.*)\\.js$": "$1"
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/package-json.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
hasPackageInstalled,
findInstalledPackageFromList,
type PackageDotJson,
} from '../utils/package-json';
} from '@utils/package-json';

describe('getPackageVersion', () => {
it('returns version from dependencies', () => {
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/wizard-abort.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
WizardError,
registerCleanup,
clearCleanup,
} from '../utils/wizard-abort';
import { analytics } from '../utils/analytics';
} from '@utils/wizard-abort';
import { analytics } from '@utils/analytics';

jest.mock('../utils/analytics');
jest.mock('../ui', () => ({
Expand Down Expand Up @@ -184,7 +184,7 @@ describe('abort() delegates to wizardAbort()', () => {
});

it('abort() calls wizardAbort with message and exitCode', async () => {
const { abort } = await import('../utils/setup-utils.js');
const { abort } = await import('@utils/setup-utils');

await expect(abort('Test abort', 3)).rejects.toThrow('process.exit called');

Expand All @@ -195,7 +195,7 @@ describe('abort() delegates to wizardAbort()', () => {
});

it('abort() uses defaults when called with no args', async () => {
const { abort } = await import('../utils/setup-utils.js');
const { abort } = await import('@utils/setup-utils');

await expect(abort()).rejects.toThrow('process.exit called');

Expand Down
8 changes: 4 additions & 4 deletions src/frameworks/android/android-wizard-agent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Android (Kotlin) wizard using posthog-agent with PostHog MCP */
import type { WizardOptions } from '../../utils/types';
import type { FrameworkConfig } from '../../lib/framework-config';
import { Integration } from '../../lib/constants';
import type { WizardOptions } from '@utils/types';
import type { FrameworkConfig } from '@lib/framework-config';
import { Integration } from '@lib/constants';
import fg from 'fast-glob';
import * as fs from 'node:fs';
import * as path from 'node:path';
Expand All @@ -10,7 +10,7 @@ import {
getKotlinVersionBucket,
getMinSdkVersion,
} from './utils';
import { gradlePackageManager } from '../../lib/detection/package-manager';
import { gradlePackageManager } from '@lib/detection/package-manager';

type AndroidContext = {
kotlinVersion?: string;
Expand Down
4 changes: 2 additions & 2 deletions src/frameworks/android/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { WizardOptions } from '../../utils/types';
import { createVersionBucket } from '../../utils/semver';
import type { WizardOptions } from '@utils/types';
import { createVersionBucket } from '@utils/semver';
import fg from 'fast-glob';
import * as fs from 'node:fs';
import * as path from 'node:path';
Expand Down
12 changes: 6 additions & 6 deletions src/frameworks/angular/angular-wizard-agent.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/* Angular wizard using posthog-agent with PostHog MCP */
import type { WizardOptions } from '../../utils/types';
import type { FrameworkConfig } from '../../lib/framework-config';
import { detectNodePackageManagers } from '../../lib/detection/package-manager';
import { Integration } from '../../lib/constants';
import type { WizardOptions } from '@utils/types';
import type { FrameworkConfig } from '@lib/framework-config';
import { detectNodePackageManagers } from '@lib/detection/package-manager';
import { Integration } from '@lib/constants';
import {
getPackageVersion,
getInstalledPackageVersion,
hasPackageInstalled,
type PackageDotJson,
} from '../../utils/package-json';
import { tryGetPackageJson } from '../../utils/setup-utils';
} from '@utils/package-json';
import { tryGetPackageJson } from '@utils/setup-utils';
import { getAngularVersionBucket } from './utils';

type AngularContext = Record<string, unknown>;
Expand Down
2 changes: 1 addition & 1 deletion src/frameworks/angular/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createVersionBucket } from '../../utils/semver';
import { createVersionBucket } from '@utils/semver';

/**
* Get Angular version bucket for analytics
Expand Down
14 changes: 7 additions & 7 deletions src/frameworks/astro/astro-wizard-agent.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/* Astro wizard using posthog-agent with PostHog MCP */
import type { WizardOptions } from '../../utils/types';
import type { FrameworkConfig } from '../../lib/framework-config';
import { detectNodePackageManagers } from '../../lib/detection/package-manager';
import { Integration } from '../../lib/constants';
import type { WizardOptions } from '@utils/types';
import type { FrameworkConfig } from '@lib/framework-config';
import { detectNodePackageManagers } from '@lib/detection/package-manager';
import { Integration } from '@lib/constants';
import {
getPackageVersion,
getInstalledPackageVersion,
hasPackageInstalled,
type PackageDotJson,
} from '../../utils/package-json';
import { tryGetPackageJson } from '../../utils/setup-utils';
import { getUI } from '../../ui';
} from '@utils/package-json';
import { tryGetPackageJson } from '@utils/setup-utils';
import { getUI } from '@ui';
import {
getAstroRenderingMode,
getAstroVersionBucket,
Expand Down
4 changes: 2 additions & 2 deletions src/frameworks/astro/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fg from 'fast-glob';
import fs from 'fs/promises';
import path from 'path';
import type { WizardOptions } from '../../utils/types';
import { createVersionBucket } from '../../utils/semver';
import type { WizardOptions } from '@utils/types';
import { createVersionBucket } from '@utils/semver';

export const getAstroVersionBucket = createVersionBucket();

Expand Down
10 changes: 5 additions & 5 deletions src/frameworks/django/django-wizard-agent.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* Django wizard using posthog-agent with PostHog MCP */
import type { WizardOptions } from '../../utils/types';
import type { FrameworkConfig } from '../../lib/framework-config';
import { PYTHON_PACKAGE_INSTALLATION } from '../../lib/framework-config';
import { detectPythonPackageManagers } from '../../lib/detection/package-manager';
import { Integration } from '../../lib/constants';
import type { WizardOptions } from '@utils/types';
import type { FrameworkConfig } from '@lib/framework-config';
import { PYTHON_PACKAGE_INSTALLATION } from '@lib/framework-config';
import { detectPythonPackageManagers } from '@lib/detection/package-manager';
import { Integration } from '@lib/constants';
import fg from 'fast-glob';
import * as fs from 'node:fs';
import * as path from 'node:path';
Expand Down
6 changes: 3 additions & 3 deletions src/frameworks/django/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fg from 'fast-glob';
import { getUI } from '../../ui';
import type { WizardOptions } from '../../utils/types';
import { createVersionBucket } from '../../utils/semver';
import { getUI } from '@ui';
import type { WizardOptions } from '@utils/types';
import { createVersionBucket } from '@utils/semver';
import * as fs from 'node:fs';
import * as path from 'node:path';

Expand Down
10 changes: 5 additions & 5 deletions src/frameworks/fastapi/fastapi-wizard-agent.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* FastAPI wizard using posthog-agent with PostHog MCP */
import type { WizardOptions } from '../../utils/types';
import type { FrameworkConfig } from '../../lib/framework-config';
import { PYTHON_PACKAGE_INSTALLATION } from '../../lib/framework-config';
import { detectPythonPackageManagers } from '../../lib/detection/package-manager';
import { Integration } from '../../lib/constants';
import type { WizardOptions } from '@utils/types';
import type { FrameworkConfig } from '@lib/framework-config';
import { PYTHON_PACKAGE_INSTALLATION } from '@lib/framework-config';
import { detectPythonPackageManagers } from '@lib/detection/package-manager';
import { Integration } from '@lib/constants';
import {
getFastAPIVersion,
getFastAPIProjectType,
Expand Down
Loading
Loading