diff --git a/.claude/skills/adding-framework-support/SKILL.md b/.claude/skills/adding-framework-support/SKILL.md index a7ec93fc1..671b0ad24 100644 --- a/.claude/skills/adding-framework-support/SKILL.md +++ b/.claude/skills/adding-framework-support/SKILL.md @@ -25,7 +25,7 @@ example under [src/frameworks](../../../src/frameworks/). Framework-specific detection, context, environment conventions, and UI metadata belong here. Integration instructions and examples belong in context-mill. -1. Add the integration to [Integration](../../../src/lib/constants.ts). Its +1. Add the integration to [Integration](../../../src/shared/constants.ts). Its order controls first-match detection and the framework picker. Keep specific frameworks before language fallbacks and generic Node last; preserve the overlap rules in the @@ -59,7 +59,7 @@ itself. | [Laravel](../../../src/frameworks/laravel/) | Composer and framework-specific filesystem signals | | [Rails](../../../src/frameworks/rails/) | Gemfile detection and Ruby conventions | -Use [bounded filesystem helpers](../../../src/utils/bounded-fs.ts) for project +Use [bounded filesystem helpers](../../../src/shared/utils/bounded-fs.ts) for project scans and reads. They bound traversal and skip dependency/build directories; add framework-specific exclusions with `extraIgnore`. Keep complex parsers and detectors beside the config so they can be checked independently. @@ -71,7 +71,7 @@ matching integration reference and task-skill variants for the framework. A registry entry alone does not provide integration knowledge. The orchestrator resolves framework variants from the skill menu and rejects missing task variants; see the -[orchestrator runner](../../../src/lib/agent/runner/sequence/orchestrator/orchestrator-runner.ts). +[orchestrator runner](../../../src/agent/runner/sequence/orchestrator/orchestrator-runner.ts). Keep project-specific facts in configuration and reusable integration guidance in that content. Model IDs, reasoning efforts, and gateway-required system diff --git a/.claude/skills/adding-skill-program/SKILL.md b/.claude/skills/adding-skill-program/SKILL.md index 883d63108..60c3f8fb3 100644 --- a/.claude/skills/adding-skill-program/SKILL.md +++ b/.claude/skills/adding-skill-program/SKILL.md @@ -21,7 +21,7 @@ guide owns the fallback criteria and gateway model/effort/system-prompt contract. These are contribution defaults. Current runtime -[bindings](../../../src/lib/agent/runner/switchboard/index.ts) still default +[bindings](../../../src/agent/runner/switchboard/index.ts) still default many programs to Anthropic plus linear; documentation changes do not migrate them. @@ -56,14 +56,14 @@ changing execution behavior. agent work. 2. Supply the flow's seed and task prompts in context-mill, including the task dependencies and applicable skill variants. The - [orchestrator](../../../src/lib/agent/runner/sequence/orchestrator/orchestrator-runner.ts) + [orchestrator](../../../src/agent/runner/sequence/orchestrator/orchestrator-runner.ts) loads `agentFlow ?? id`, requires a seed prompt, and checks task-skill variants before running. `run.skillId` alone does not define this flow. 3. Register the config in [PROGRAM_REGISTRY](../../../src/lib/programs/program-registry.ts) and add its Pi/orchestrator entry to - [PROGRAM_BINDINGS](../../../src/lib/agent/runner/switchboard/index.ts). - [Existing binding checks](../../../src/lib/agent/runner/__tests__/switchboard.test.ts) + [PROGRAM_BINDINGS](../../../src/agent/runner/switchboard/index.ts). + [Existing binding checks](../../../src/agent/runner/__tests__/switchboard.test.ts) enforce coverage; `ProgramId` currently widens to `string`. 4. For a standalone native command, create a command module with [nativeCommandFactory](../../../src/commands/factories/native-command-factory.ts) @@ -93,7 +93,7 @@ config directly and adds prerequisite detection. `ProgramRun.customPrompt`, `abortCases`, `postRun`, and `buildOutroData` are consumed by the -[linear sequence](../../../src/lib/agent/runner/sequence/linear.ts). `postRun` +[linear sequence](../../../src/agent/runner/sequence/linear.ts). `postRun` runs after success; `buildOutroData` receives session and credentials, with host information inside credentials. The orchestrator currently uses its own task prompts, failure handling, and outro, and does not invoke those hooks. Check diff --git a/.claude/skills/exploring-the-wizard/SKILL.md b/.claude/skills/exploring-the-wizard/SKILL.md index 50dbc7160..2dc754f74 100644 --- a/.claude/skills/exploring-the-wizard/SKILL.md +++ b/.claude/skills/exploring-the-wizard/SKILL.md @@ -114,7 +114,7 @@ MCP snapshots are plain `.txt`; the CI snapshot route writes colored `.ans` frames. Keep the screen path and failure evidence with the snapshots. Do not stop a progressing run at an invented turn count: the MCP exposes no turn limit; Pi's continuation and tool-call guards are described in its -[harness README](../../../src/lib/agent/runner/harness/pi/README.md). +[harness README](../../../src/agent/runner/harness/pi/README.md). ## Sweep the workbench diff --git a/.claude/skills/ink-tui/references/PATTERNS.md b/.claude/skills/ink-tui/references/PATTERNS.md index 3f530e742..1db9a4c03 100644 --- a/.claude/skills/ink-tui/references/PATTERNS.md +++ b/.claude/skills/ink-tui/references/PATTERNS.md @@ -48,6 +48,6 @@ layout must update on terminal resize; reading `useStdout` alone does not subscribe. Account for the shell's title, hints, tabs, status expansion, and optional HUD rather than allocating the full terminal height to screen content. -Write diagnostics through [logToFile](../../../../src/utils/debug.ts), which +Write diagnostics through [logToFile](../../../../src/shared/utils/debug.ts), which uses the configured wizard log destination. Avoid introducing a separate hardcoded temporary log or writing debug lines into the live TUI. diff --git a/.claude/skills/ink-tui/references/TERMINAL-COMPAT.md b/.claude/skills/ink-tui/references/TERMINAL-COMPAT.md index f8b30a438..1b941103a 100644 --- a/.claude/skills/ink-tui/references/TERMINAL-COMPAT.md +++ b/.claude/skills/ink-tui/references/TERMINAL-COMPAT.md @@ -38,7 +38,7 @@ Mode selection belongs to command/runner entry points. The [default integration command](../../../../src/commands/basic-integration/index.ts) routes explicit CI/headless requests separately and rejects a detected noninteractive environment for the ordinary interactive path. -[Environment detection](../../../../src/utils/environment.ts) checks +[Environment detection](../../../../src/shared/utils/environment.ts) checks stdout/stderr TTY state outside development mode; checking stdin alone does not describe this command's behavior. diff --git a/.claude/skills/wizard-development/SKILL.md b/.claude/skills/wizard-development/SKILL.md index 3ee4f261d..cde67b09b 100644 --- a/.claude/skills/wizard-development/SKILL.md +++ b/.claude/skills/wizard-development/SKILL.md @@ -22,8 +22,8 @@ infrastructure should consume those boundaries. | Framework detection, context, env conventions | [FrameworkConfig](../../../src/lib/framework-config.ts) and [framework configs](../../../src/frameworks/) | | Integration instructions and orchestrator flows/tasks | [context-mill](https://github.com/PostHog/context-mill) | | Programs, steps, prerequisites and outcomes | [programs](../../../src/lib/programs/) | -| Sequence, harness, model and effort selection | [switchboard](../../../src/lib/agent/runner/switchboard/) | -| Local tool permissions and scanner adapters | [agent-interface](../../../src/lib/agent/agent-interface.ts), [YARA hooks](../../../src/lib/yara-hooks.ts), [Pi security](../../../src/lib/agent/runner/harness/pi/security.ts) | +| Sequence, harness, model and effort selection | [switchboard](../../../src/agent/runner/switchboard/) | +| Local tool permissions and scanner adapters | [agent-interface](../../../src/agent/agent-interface.ts), [YARA hooks](../../../src/agent/yara-hooks.ts), [Pi security](../../../src/agent/runner/harness/pi/security.ts) | | Scanner rules | [warlock](https://github.com/PostHog/warlock) | | Token admission and budgets | [PostHog mint endpoint](https://github.com/PostHog/posthog/blob/master/posthog/llm/wizard_gateway_token.py) and [ai-gateway](https://github.com/PostHog/ai-gateway) | | Screen resolution and rendering | [TUI](../../../src/ui/tui/) through [WizardUI](../../../src/ui/wizard-ui.ts) | @@ -43,7 +43,7 @@ infrastructure should consume those boundaries. new Anthropic models. Existing routing has not all migrated: -[DEFAULT_BINDING](../../../src/lib/agent/runner/switchboard/index.ts) still +[DEFAULT_BINDING](../../../src/agent/runner/switchboard/index.ts) still selects Anthropic + linear, with per-program and flag overrides. Set new bindings explicitly. Migrating an existing program requires checking its flow, tasks, and lifecycle hooks; changing the default constant alone is insufficient. @@ -52,8 +52,8 @@ Both harnesses implement `run` and `runTask`. Adding a model or effort is a cross-repository change: 1. Define the Wizard model ID and capabilities in - [constants](../../../src/lib/constants.ts) and - [models](../../../src/lib/agent/runner/switchboard/models.ts); select it + [constants](../../../src/shared/constants.ts) and + [models](../../../src/agent/runner/switchboard/models.ts); select it through the switchboard or supported context-mill stage metadata. 2. Check the PostHog mint's `WIZARD_MODEL_ALLOWLIST` and allowed efforts. The token's policy is enforced by the gateway; a local constant or CLI override @@ -65,7 +65,7 @@ Adding a model or effort is a cross-repository change: 4. Verify the chosen harness transport and effective effort with the same admission policy used by the target environment. -Local [commandments](../../../src/lib/agent/runner/switchboard/commandments.ts) +Local [commandments](../../../src/agent/runner/switchboard/commandments.ts) provide runtime and tool guidance. They do not replace the gateway's required safety prompt. Keep gateway policy owned there rather than copying it into skills. Do not infer per-model effort authorization merely from the local @@ -94,7 +94,7 @@ only when it gives a real owner a smaller, reusable boundary. ## Lifecycle and security -[runner/index.ts](../../../src/lib/agent/runner/index.ts) bootstraps, resolves a +[runner/index.ts](../../../src/agent/runner/index.ts) bootstraps, resolves a binding, and dispatches to a sequence. `agent-runner.ts` is a compatibility re-export, not the implementation. Sequences own their lifecycle; harnesses own SDK calls. `ProgramRun.postRun`, `buildOutroData`, `customPrompt`, and @@ -109,10 +109,10 @@ than assuming every rejection terminates the run. New scanner rules belong in warlock; changes to how a match is handled belong in Wizard. User-provided secrets should travel through -[secret-vault](../../../src/lib/secret-vault.ts) references. Tool +[secret-vault](../../../src/shared/secret-vault.ts) references. Tool implementations resolve values host-side where they are used; they must not return the raw value to the model. Inspect the -[wizard-tools](../../../src/lib/wizard-tools/) implementations and the Pi +[wizard-tools](../../../src/agent/tools/) implementations and the Pi adapter when extending this shared tool surface. ## Verification and maintenance diff --git a/.claude/skills/wizard-development/references/ARCHITECTURE.md b/.claude/skills/wizard-development/references/ARCHITECTURE.md index bb99255f3..c29badcf2 100644 --- a/.claude/skills/wizard-development/references/ARCHITECTURE.md +++ b/.claude/skills/wizard-development/references/ARCHITECTURE.md @@ -16,19 +16,19 @@ readiness hooks, and traverse steps and gates. detection in `onReady`. Noninteractive execution has its own lifecycle in [run-non-interactive.ts](../../../../src/lib/runners/run-non-interactive.ts). -[runner/index.ts](../../../../src/lib/agent/runner/index.ts) resolves a +[runner/index.ts](../../../../src/agent/runner/index.ts) resolves a program's `run` definition, calls shared bootstrap, selects a binding, dispatches the sequence, and flushes the scanner report on cleanup. The old -[agent-runner.ts](../../../../src/lib/agent/agent-runner.ts) is a compatibility +[agent-runner.ts](../../../../src/agent/agent-runner.ts) is a compatibility export. | Layer | Source and responsibility | | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| Bootstrap | [shared/bootstrap.ts](../../../../src/lib/agent/runner/shared/bootstrap.ts): shared health/settings/auth/flag and MCP setup | -| Switchboard | [switchboard/index.ts](../../../../src/lib/agent/runner/switchboard/index.ts): resolve sequence, harness, model and effort override | -| Linear sequence | [sequence/linear.ts](../../../../src/lib/agent/runner/sequence/linear.ts): one conversation, skill/prompt assembly, post-run hooks and outro | -| Orchestrator | [orchestrator-runner.ts](../../../../src/lib/agent/runner/sequence/orchestrator/orchestrator-runner.ts): seed plan, task queue, focused conversations, handoffs and completion | -| Harness | [harness/types.ts](../../../../src/lib/agent/runner/harness/types.ts): SDK boundary, implemented by Pi and Anthropic | +| Bootstrap | [shared/bootstrap.ts](../../../../src/agent/runner/shared/bootstrap.ts): shared health/settings/auth/flag and MCP setup | +| Switchboard | [switchboard/index.ts](../../../../src/agent/runner/switchboard/index.ts): resolve sequence, harness, model and effort override | +| Linear sequence | [sequence/linear.ts](../../../../src/agent/runner/sequence/linear.ts): one conversation, skill/prompt assembly, post-run hooks and outro | +| Orchestrator | [orchestrator-runner.ts](../../../../src/agent/runner/sequence/orchestrator/orchestrator-runner.ts): seed plan, task queue, focused conversations, handoffs and completion | +| Harness | [harness/types.ts](../../../../src/agent/runner/harness/types.ts): SDK boundary, implemented by Pi and Anthropic | The contribution policy is [Pi by default, orchestration preferred](../SKILL.md#execution-policy-and-model-admission). @@ -40,7 +40,7 @@ route. ### Configuration hooks -Read [ProgramRun](../../../../src/lib/agent/runner/shared/types.ts) for exact +Read [ProgramRun](../../../../src/agent/runner/shared/types.ts) for exact signatures. | Surface | Current consumer | @@ -70,25 +70,25 @@ binding and stamping a trace of the selected precedence rungs. - Sequence: composed linear clamp, development CLI override, `runTask` capability clamp, program flag route, sequence experiment, binding/default. -[Harness](../../../../src/lib/agent/runner/switchboard/harness.ts) and -[sequence](../../../../src/lib/agent/runner/switchboard/sequence.ts) contain the +[Harness](../../../../src/agent/runner/switchboard/harness.ts) and +[sequence](../../../../src/agent/runner/switchboard/sequence.ts) contain the exact chains. Published builds omit CLI overrides. `RUN_SURFACE` can disable harness experiments; static bindings and harness capabilities also affect resolution. Composed sub-runs remain linear even when a CLI override requests orchestration. Effort resolves in two stages: the binding supplies an override, then -[modelCapabilities](../../../../src/lib/agent/runner/switchboard/models.ts) +[modelCapabilities](../../../../src/agent/runner/switchboard/models.ts) applies capabilities and defaults. All selected models and efforts must also be admitted by the minted token and gateway. Local routing cannot bypass that external policy; see the [model admission checklist](../SKILL.md#execution-policy-and-model-admission). Flags belong in -[switchboard/flags](../../../../src/lib/agent/runner/switchboard/flags/). +[switchboard/flags](../../../../src/agent/runner/switchboard/flags/). Experiments declare their program scope; malformed payloads yield no experiment route. Reuse the -[switchboard tests](../../../../src/lib/agent/runner/__tests__/switchboard.test.ts) +[switchboard tests](../../../../src/agent/runner/__tests__/switchboard.test.ts) and experiment tests to check full bindings and isolation of unrelated programs. Do not add a second flag-reading path inside a harness or sequence. @@ -99,17 +99,17 @@ Wizard's local tool boundary separately restricts operations on the user's project. Local commandments provide model guidance; they are not an enforcement mechanism. -- [agent-interface.ts](../../../../src/lib/agent/agent-interface.ts) configures +- [agent-interface.ts](../../../../src/agent/agent-interface.ts) configures the Anthropic SDK's tool permissions, sandbox, and gateway transport. -- [yara-hooks.ts](../../../../src/lib/yara-hooks.ts) adapts warlock scans to SDK +- [yara-hooks.ts](../../../../src/agent/yara-hooks.ts) adapts warlock scans to SDK tool hooks. -- [Pi security](../../../../src/lib/agent/runner/harness/pi/security.ts) adapts +- [Pi security](../../../../src/agent/runner/harness/pi/security.ts) adapts shared permissions and scanning to Pi tool-call/result events, including blocking, violation latching, and tool-call limits. -- [Pi harness](../../../../src/lib/agent/runner/harness/pi/) explicitly supplies +- [Pi harness](../../../../src/agent/runner/harness/pi/) explicitly supplies tools, scrubs shell environments, and disables project-controlled extensions/context loading. -- [triage-provider.ts](../../../../src/lib/agent/triage-provider.ts) supplies +- [triage-provider.ts](../../../../src/agent/triage-provider.ts) supplies gateway-backed classification for scanner findings. Scanner rules live in [warlock](https://github.com/PostHog/warlock); Wizard owns @@ -119,16 +119,16 @@ terminates the run. Check each adapter's state machine when changing rejection handling. Preserve useful rejection diagnostics without logging secret content. Both SDK paths use a scoped gateway token minted through -[gateway-session.ts](../../../../src/lib/gateway-session.ts), not the user's raw +[gateway-session.ts](../../../../src/agent/gateway-session.ts), not the user's raw OAuth credential as a model API key. Rejection and refresh behavior belong at that seam; do not restore a legacy-gateway fallback to bypass admission. ### Secret vault: keeping values out of the model -[secret-vault.ts](../../../../src/lib/secret-vault.ts) stores user-provided +[secret-vault.ts](../../../../src/shared/secret-vault.ts) stores user-provided values in memory and returns opaque references. Sensitive `wizard_ask` answers become `secret:` refs; `set_env_values` resolves the ref host-side when -writing. Follow [wizard-tools](../../../../src/lib/wizard-tools/) and the Pi +writing. Follow [wizard-tools](../../../../src/agent/tools/) and the Pi adapters when adding a secret-consuming tool. Return references and metadata to the agent, never the raw value. References are session-scoped, not durable credentials. @@ -145,7 +145,7 @@ business logic. Harness adapters translate SDK messages, status markers, task updates and tool activity into WizardUI calls. Anthropic message processing lives in -[agent-interface.ts](../../../../src/lib/agent/agent-interface.ts); Pi uses its +[agent-interface.ts](../../../../src/agent/agent-interface.ts); Pi uses its own session event handlers. Orchestrated tasks also have queue and handoff state. Do not assume all harness output passes through `handleSDKMessage`. @@ -165,7 +165,7 @@ separate surfaces. The Anthropic SDK's MCP integration and Pi's adapter expose them differently; inspect the selected harness rather than assuming identical tool names or discovery. Context-mill supplies skills and flow/task prompts. -[Middleware](../../../../src/lib/middleware/) provides opt-in message/phase +[Middleware](../../../../src/agent/middleware/) provides opt-in message/phase instrumentation. The linear sequence creates the benchmark pipeline; there is no pipeline construction in the compatibility `agent-runner.ts`. Inspect the actual consumer before extending instrumentation to another sequence or harness. diff --git a/.eslintrc.cjs b/.eslintrc.cjs index a633af786..a73cf66eb 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -35,18 +35,8 @@ module.exports = { // progress events and asks through an injected answerer, so nothing // here may import a UI, the session, detection, the CLI or a program. // Only direct static imports are checked. Program types stay importable - // until B1 moves PROGRAM_BINDINGS to programs. Today's paths; A2b - // collapses them to src/agent/**. - files: [ - 'src/lib/agent/**/*.ts', - 'src/lib/middleware/**/*.ts', - 'src/lib/wizard-tools/**/*.ts', - 'src/lib/gateway-session.ts', - 'src/lib/safe-tools.ts', - 'src/lib/wizard-ask-bridge.ts', - 'src/lib/yara-hooks.ts', - 'src/lib/yara-policy.ts', - ], + // until B1 moves PROGRAM_BINDINGS to programs. + files: ['src/agent/**/*.ts'], excludedFiles: ['**/__tests__/**'], rules: { '@typescript-eslint/no-restricted-imports': [ @@ -59,6 +49,12 @@ module.exports = { message: 'The agent never exits the process: return a failure in RunResult.', }, + { + name: '@shared/utils/wizard-abort', + importNames: ['wizardAbort'], + message: + 'The agent never exits the process: return a failure in RunResult.', + }, ], patterns: [ { @@ -67,16 +63,13 @@ module.exports = { '@ui/**', '**/ui', '**/ui/**', - '@lib/wizard-session', + '@lib/**', + '!@lib/programs/**', + '**/lib/**', + '!**/lib/programs/**', '**/wizard-session', - '@lib/detection', - '@lib/detection/**', '**/detection', '**/detection/**', - '@lib/registry', - '**/lib/registry', - '@lib/runners', - '@lib/runners/**', '**/runners', '**/runners/**', '**/commands/**', @@ -87,8 +80,10 @@ module.exports = { '@frameworks/**', '**/frameworks/**', '@utils/setup-utils', + '@shared/utils/setup-utils', '**/setup-utils', '@utils/oauth', + '@shared/utils/oauth', '**/utils/oauth', ], message: diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 164f68233..48f68a2a9 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -20,4 +20,4 @@ /src/lib/programs/web-analytics-doctor/ @PostHog/team-web-analytics # Agent runner (harness, model, and tools) -/src/lib/agent/ @PostHog/team-wizard-docs +/src/agent/ @PostHog/team-wizard-docs diff --git a/.gitignore b/.gitignore index 3519c1fda..4ff37b6f0 100644 --- a/.gitignore +++ b/.gitignore @@ -40,7 +40,7 @@ plugins e2e-tests/fixtures/.tracking/* # Generated at build time by scripts/generate-version.js -src/lib/version.ts +src/shared/version.ts # Re-include src/lib explicitly: a user-global ignore pattern like `lib/` # would otherwise silently drop new source files under src/lib from commits. !src/lib/ diff --git a/README.md b/README.md index c66cefffb..8fbba68e9 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ route review to their owning team instead. | Path | Owning team | |---|---| | `*` (everything else, including all other programs) | `@PostHog/team-wizard-docs` | -| `src/lib/agent/` | `@PostHog/team-wizard-docs` | +| `src/agent/` | `@PostHog/team-wizard-docs` | | `src/lib/programs/posthog-integration/` | `@PostHog/team-wizard-docs` | | `src/lib/programs/error-tracking-upload-source-maps/` | `@PostHog/team-error-tracking` | | `src/lib/programs/mcp-analytics/` | `@PostHog/team-mcp-analytics` | @@ -270,7 +270,7 @@ dashboard:write insight:write notebook:write event_definition:write health_issue:read wizard_session:read wizard_session:write ``` -The source of truth is `WIZARD_OAUTH_SCOPES` in `src/lib/constants.ts`, which +The source of truth is `WIZARD_OAUTH_SCOPES` in `src/shared/constants.ts`, which documents why each scope is needed — if this block drifts, trust the code. Some programs request more on top (`PROGRAM_SCOPE_ADDITIONS` in `src/lib/oauth/program-scopes.ts`); the default integration flow adds @@ -291,7 +291,7 @@ are clamped silently (`clamp_scopes_to_ceiling`) — neither path errors; `/oauth/token` just returns a smaller `scope`. So never assume the token carries what was requested: the token response's `scope` field is the truth. The wizard diffs granted vs requested at login (`missingOAuthScopes` in -`src/utils/oauth.ts`), warns the user which permissions are missing, and emits +`src/shared/utils/oauth.ts`), warns the user which permissions are missing, and emits `wizard: oauth grant narrowed` so narrowed runs are countable in analytics. The diff also rides on the session (`credentials.missingScopes`), so when a run does fail on a scope-gated step, the error names the missing permission @@ -396,7 +396,7 @@ and set up the general flow of the application. ## Analytics Did you know you can capture PostHog events even for smaller, supporting -products like a command line tool? `src/utils/analytics.ts` is a great example +products like a command line tool? `src/shared/utils/analytics.ts` is a great example of how to do it. This file wraps `posthog-node` with some convenience functions to set up an @@ -417,7 +417,7 @@ set `POSTHOG_WIZARD_NO_TELEMETRY=1`) to disable. Supporting agent sessions after we leave is important. There are plenty of ways to break or misconfigure PostHog, so guarding against this is key. -`src/utils/rules/add-editor-rules.ts` demonstrates how to dynamically construct +`src/shared/utils/rules/add-editor-rules.ts` demonstrates how to dynamically construct rules files and store them in the project's `.cursor/rules` directory. ## Prompts and LLM interactions @@ -433,7 +433,7 @@ _If_ they are well prompted. chaotic process. Every wizard session gets the same prompt, tailored to the specific files in the project. -These prompts are channeled using `src/utils/query.ts` to an LLM interface we +These prompts are channeled using `src/shared/utils/query.ts` to an LLM interface we host. This gives us more control: we can be certain of the model version and provider which interpret the prompts and modify the files. This way, we can find the right tools for the job and again, apply them consistently. @@ -450,14 +450,14 @@ orchestrates that journey, but the raw value should _never_ enter the LLM conversation, where it would be sent to the model provider, written to transcripts, and captured in logs. -`src/lib/secret-vault.ts` is a small, reusable pattern for exactly this. It's a +`src/shared/secret-vault.ts` is a small, reusable pattern for exactly this. It's a session-scoped, in-memory vault: a tool that handles a secret calls `put()` to store the raw value and hands the agent an opaque `secret:` reference instead. The agent passes that ref between tools as if it were the value; the host resolves it back to the real secret only at the last moment, inside the process, when it writes the file. -Two tools in `src/lib/wizard-tools.ts` form the ends of that pipe: +Two tools in `src/agent/tools/tools.ts` form the ends of that pipe: - `wizard_ask` with `sensitive: true` vaults the user's typed answer and returns `{ secretRef: "secret:..." }` to the agent rather than the string. @@ -504,7 +504,9 @@ Path aliases defined in `tsconfig.build.json`, resolved by tsdown: |---|---| | `@env` | `src/env.ts` | | `@lib/*` | `src/lib/*` | -| `@utils/*` | `src/utils/*` | +| `@agent/*` | `src/agent/*` | +| `@shared/*` | `src/shared/*` | +| `@utils/*` | `src/shared/utils/*` | | `@ui/*` | `src/ui/*` | | `@steps/*` | `src/steps/*` | | `@frameworks/*` | `src/frameworks/*` | @@ -605,7 +607,7 @@ To make your version of a tool usable with a one-line `npx` command: # Health checks -`src/lib/health-checks/` checks skills download origins before the wizard runs. +`src/shared/health-checks/` checks skills download origins before the wizard runs. The entry point is `evaluateWizardReadiness()`, which only blocks on skill downloads: | Decision | Meaning | @@ -645,7 +647,7 @@ gateway URL and reports an unavailable gateway through the existing error path. `skillsOrigin` is one entry covering two origins: skills are published to GitHub Releases and an AWS mirror under the same filenames, and downloads fail -over between them (`src/lib/fetch-retry.ts`). Both are probed in parallel, so +over between them (`src/shared/fetch-retry.ts`). Both are probed in parallel, so the key only reports **Down** when neither origin answers — a GitHub Releases outage on its own doesn't block a run, including a 403 or 404, which is as often about the origin (expired asset redirect, blocked region, a publish that diff --git a/bin.ts b/bin.ts index 2a3d25974..3b61c3c9f 100644 --- a/bin.ts +++ b/bin.ts @@ -1,8 +1,8 @@ #!/usr/bin/env node import { satisfies } from 'semver'; import { Agent, setGlobalDispatcher } from 'undici'; -import { ErrorCodes } from './src/lib/errors/codes.js'; -import { emitWizardError } from './src/lib/errors/emit.js'; +import { ErrorCodes } from '@shared/errors/codes.js'; +import { emitWizardError } from '@shared/errors/emit.js'; // Keep in sync with `engines.node` in package.json. npx does not enforce // engines, so this preflight is the only thing standing between an old Node @@ -83,7 +83,7 @@ import { uploadSourcemapsCommand } from './src/commands/upload-sourcemaps'; import { errorTrackingCommand } from './src/commands/error-tracking'; import { skillCommand } from './src/commands/skill'; import { cliCommand } from './src/commands/cli'; -import { recoverOrphanedSettingsBackups } from './src/lib/agent/claude-settings'; +import { recoverOrphanedSettingsBackups } from '@shared/claude-settings'; // Heal any .claude/settings backup a previous interrupted run left orphaned, // before anything else reads Claude settings — conflict detection, OAuth, and diff --git a/docs/benchmarking.md b/docs/benchmarking.md index 87d7f9225..e5fadf4f7 100644 --- a/docs/benchmarking.md +++ b/docs/benchmarking.md @@ -102,7 +102,7 @@ Everything below ships in this repo (`wizard/`) and its workbench orchestrator on pi, per-task models from context-mill frontmatter; off → the linear anthropic default). Per-stage variations ride `wizard-orchestrator-override` payloads (`{stage: {model?, effort?}}`, - variant keys in `wizard/src/lib/agent/runner/switchboard/flags/schemes.ts`). + variant keys in `wizard/src/agent/runner/switchboard/flags/schemes.ts`). The baseline is `{"wizard-orchestrator":"false"}` — never an empty override, or live remote flags leak into the baseline. diff --git a/docs/error-catalog.md b/docs/error-catalog.md index dc1d90bdb..8e8c05b19 100644 --- a/docs/error-catalog.md +++ b/docs/error-catalog.md @@ -6,11 +6,11 @@ machine-readable code so the backend, the web UI, and sandbox supervisors can classify failures without parsing human-readable messages. - **Source of truth for codes:** - [`src/lib/errors/codes.ts`](../src/lib/errors/codes.ts) + [`src/shared/errors/codes.ts`](../src/shared/errors/codes.ts) - **Source of truth for metadata (group, retry advice, description):** - [`src/lib/errors/catalog.ts`](../src/lib/errors/catalog.ts) + [`src/shared/errors/catalog.ts`](../src/shared/errors/catalog.ts) - **Consumers:** `wizardAbort()` - ([`src/utils/wizard-abort.ts`](../src/utils/wizard-abort.ts)), the task stream + ([`src/shared/utils/wizard-abort.ts`](../src/shared/utils/wizard-abort.ts)), the task stream ([`src/lib/task-stream/`](../src/lib/task-stream/)), and non-interactive hosts reading stderr. @@ -117,7 +117,7 @@ guarantee. Program detect steps write `{ kind, ...detail }` into `session.frameworkContext.detectError`. `detectErrorCode()` -([`src/lib/errors/detect-map.ts`](../src/lib/errors/detect-map.ts)) maps `kind` +([`src/shared/errors/detect-map.ts`](../src/shared/errors/detect-map.ts)) maps `kind` → code, and the whole object — `kind` included — rides along as `OutroData.errorDetail`. @@ -140,7 +140,7 @@ Two rules make the detect group safe for automated retry policy: ## Auth classification Gateway 401s are classified at the abort site by `classifyAuthFailure()` -([`src/lib/errors/auth.ts`](../src/lib/errors/auth.ts)) with priority: +([`src/shared/errors/auth.ts`](../src/shared/errors/auth.ts)) with priority: stored-login conflict → settings conflict → key-type → missing scope → region mismatch → invalid/expired. Inputs are best-effort from the run context; the classifier degrades to `PHW_AUTH_INVALID_OR_EXPIRED` when no distinguishing diff --git a/docs/local-dev.md b/docs/local-dev.md index 10e11ba7b..93f949cdd 100644 --- a/docs/local-dev.md +++ b/docs/local-dev.md @@ -170,7 +170,7 @@ skills url, MCP url, and PostHog host together. ## Implementation -`src/lib/local-dev.ts` defines the endpoints and precedence. Downstream code +`src/shared/local-dev.ts` defines the endpoints and precedence. Downstream code reads the resolved targets. The three service flags have no yargs default. An absent flag is `undefined` diff --git a/docs/runbooks/aio-capture.md b/docs/runbooks/aio-capture.md index 667208d3c..a74f29c9f 100644 --- a/docs/runbooks/aio-capture.md +++ b/docs/runbooks/aio-capture.md @@ -76,7 +76,7 @@ dev-only concern. - **`agents-platform` harness** — placeholder today (`README` only). When it lands, whoever builds it needs to add a third transform + wire point in - `src/lib/agent/aio-capture.ts`. Search for `captureFromPiMessageEndEvent` + `src/agent/aio-capture.ts`. Search for `captureFromPiMessageEndEvent` for the pattern. - **Non-assistant messages** — user turns, tool results, and system messages don't get their own `$ai_generation`. Tool calls ride as content blocks diff --git a/docs/runbooks/warlock-kill-switch.md b/docs/runbooks/warlock-kill-switch.md index 7b0189767..33979e4d5 100644 --- a/docs/runbooks/warlock-kill-switch.md +++ b/docs/runbooks/warlock-kill-switch.md @@ -63,7 +63,7 @@ Narrower is better — keep the security net on for users who aren't affected. ## Timing & reach - The flag is read **once at run start** - ([`agent-runner.ts`](../../src/lib/agent/agent-runner.ts), + ([`agent-runner.ts`](../../src/agent/agent-runner.ts), `getAllFlagsForWizard()`), so a change takes effect on the **next** run — not on runs already in flight. Wizard runs are short-lived, so "next run" is effectively seconds to minutes. @@ -90,10 +90,10 @@ is a **local tool only** — it is per-machine and is **not** the incident lever One feature flag, read at run start, gates the two hooks Warlock registers. - **Flag key:** `wizard-warlock-disabled` — - [`src/lib/constants.ts`](../../src/lib/constants.ts) + [`src/shared/constants.ts`](../../src/shared/constants.ts) (`WIZARD_WARLOCK_DISABLED_FLAG_KEY`). - **Decision helper:** `isWarlockDisabled(flags)` in - [`src/lib/agent/agent-interface.ts`](../../src/lib/agent/agent-interface.ts) — + [`src/agent/agent-interface.ts`](../../src/agent/agent-interface.ts) — pure, unit-tested. - **The gate:** at hook registration in the same file, when disabled the Pre/PostToolUse YARA hooks are registered as empty arrays (`[]`) instead of @@ -114,7 +114,7 @@ exact string `'true'`. Everything else leaves Warlock **ON**: A network blip must never silently disable a security control. This is pinned by unit tests in -[`src/lib/__tests__/agent-interface.test.ts`](../../src/lib/__tests__/agent-interface.test.ts) +[`src/agent/__tests__/agent-interface.test.ts`](../../src/agent/__tests__/agent-interface.test.ts) (`describe('isWarlockDisabled (kill switch)')`). --- @@ -146,5 +146,5 @@ unit tests in - Scanner engine & rules: the [warlock](https://github.com/PostHog/warlock) sibling repo. -- Hook wiring: [`src/lib/yara-hooks.ts`](../../src/lib/yara-hooks.ts). +- Hook wiring: [`src/agent/yara-hooks.ts`](../../src/agent/yara-hooks.ts). - Feedback / questions: wizard@posthog.com. diff --git a/e2e-harness/__tests__/e2e-flow-snapshot.test.ts b/e2e-harness/__tests__/e2e-flow-snapshot.test.ts index 243d4f830..272105bc6 100644 --- a/e2e-harness/__tests__/e2e-flow-snapshot.test.ts +++ b/e2e-harness/__tests__/e2e-flow-snapshot.test.ts @@ -17,10 +17,10 @@ import { WizardStore } from '@ui/tui/store'; import { InkUI } from '@ui/tui/ink-ui'; import { setUI } from '@ui/index'; import { buildSession, RunPhase } from '@lib/wizard-session'; -import { Integration } from '@lib/constants'; -import { HostResolution } from '@lib/host-resolution'; +import { Integration } from '@shared/constants'; +import { HostResolution } from '@shared/host-resolution'; import { FRAMEWORK_REGISTRY } from '@lib/registry'; -import { WizardReadiness } from '@lib/health-checks/readiness'; +import { WizardReadiness } from '@shared/health-checks/readiness'; import { Program, getProgramConfig, diff --git a/e2e-harness/__tests__/e2e-result.test.ts b/e2e-harness/__tests__/e2e-result.test.ts index 96d1f5c29..89506dc87 100644 --- a/e2e-harness/__tests__/e2e-result.test.ts +++ b/e2e-harness/__tests__/e2e-result.test.ts @@ -15,7 +15,7 @@ import { OutroKind, RunPhase } from '@lib/wizard-session'; import type { AskQuestion, WizardSession } from '@lib/wizard-session'; import { DETECTED_WAREHOUSE_SOURCES_KEY } from '@lib/programs/warehouse-source/detect'; import { Overlay } from '@ui/tui/router'; -import { TASK_OUTCOMES_KEY } from '@lib/agent/runner/sequence/orchestrator/queue'; +import { TASK_OUTCOMES_KEY } from '@agent/runner/sequence/orchestrator/queue'; import { E2eRunRecorder, abortReasonFrom, diff --git a/e2e-harness/__tests__/wizard-ci-driver.test.ts b/e2e-harness/__tests__/wizard-ci-driver.test.ts index 2edf4553e..7462b213f 100644 --- a/e2e-harness/__tests__/wizard-ci-driver.test.ts +++ b/e2e-harness/__tests__/wizard-ci-driver.test.ts @@ -13,10 +13,10 @@ import { WizardStore } from '@ui/tui/store'; import { InkUI } from '@ui/tui/ink-ui'; import { setUI } from '@ui/index'; import { buildSession, RunPhase, McpOutcome } from '@lib/wizard-session'; -import { HostResolution } from '@lib/host-resolution'; -import { Integration } from '@lib/constants'; +import { HostResolution } from '@shared/host-resolution'; +import { Integration } from '@shared/constants'; import { FRAMEWORK_REGISTRY } from '@lib/registry'; -import { WizardReadiness } from '@lib/health-checks/readiness'; +import { WizardReadiness } from '@shared/health-checks/readiness'; import { ScreenId, Overlay } from '@ui/tui/router'; import { Program } from '@lib/programs/program-registry'; import { WizardCiDriver, UnknownActionError } from '../wizard-ci-driver'; diff --git a/e2e-harness/e2e-result.ts b/e2e-harness/e2e-result.ts index f862fa2c5..6fc6a668a 100644 --- a/e2e-harness/e2e-result.ts +++ b/e2e-harness/e2e-result.ts @@ -25,7 +25,7 @@ import { OutroKind, type WizardSession } from '@lib/wizard-session'; import { TASK_OUTCOMES_KEY, type TaskOutcome, -} from '@lib/agent/runner/sequence/orchestrator/queue'; +} from '@agent/runner/sequence/orchestrator/queue'; import { DETECTED_WAREHOUSE_SOURCES_KEY } from '@lib/programs/warehouse-source/detect'; import type { DetectedSource } from '@lib/warehouse-sources/types'; import type { E2eDecisionReport } from './e2e-profile.js'; diff --git a/e2e-tests/mocks/handlers.ts b/e2e-tests/mocks/handlers.ts index 5cf864edf..68cd627b4 100644 --- a/e2e-tests/mocks/handlers.ts +++ b/e2e-tests/mocks/handlers.ts @@ -1,6 +1,6 @@ import { http, HttpResponse, passthrough } from 'msw'; -import { getCloudUrl } from '../../src/utils/urls'; -import { DEFAULT_HOST_URL } from '../../src/lib/constants'; +import { getCloudUrl } from '../../src/shared/utils/urls'; +import { DEFAULT_HOST_URL } from '../../src/shared/constants'; import { fixtureTracker } from './fixture-tracker'; export const shouldRecord = process.env.RECORD_FIXTURES === 'true'; diff --git a/scripts/check-screens.tsx b/scripts/check-screens.tsx index bfc2871b5..034106c70 100644 --- a/scripts/check-screens.tsx +++ b/scripts/check-screens.tsx @@ -15,7 +15,7 @@ import { ProgressList } from '@ui/tui/primitives/ProgressList'; import { ManagedSettingsScreen } from '@ui/tui/screens/ManagedSettingsScreen'; import { SettingsOverrideScreen } from '@ui/tui/screens/SettingsOverrideScreen'; import { WizardAskScreen } from '@ui/tui/screens/WizardAskScreen'; -import type { SettingsConflict } from '@lib/agent/agent-interface'; +import type { SettingsConflict } from '@agent/agent-interface'; function fakeStore(session: Record): any { return { diff --git a/scripts/generate-version.cjs b/scripts/generate-version.cjs index 486932d39..3575dfe28 100644 --- a/scripts/generate-version.cjs +++ b/scripts/generate-version.cjs @@ -6,6 +6,6 @@ const pkg = JSON.parse( ); const output = `// Auto-generated by scripts/generate-version.js — do not edit\nexport const VERSION = '${pkg.version}';\n`; fs.writeFileSync( - path.join(__dirname, '..', 'src', 'lib', 'version.ts'), + path.join(__dirname, '..', 'src', 'shared', 'version.ts'), output, ); diff --git a/scripts/smoke-test.sh b/scripts/smoke-test.sh index 241bcab22..f5e28a1cc 100755 --- a/scripts/smoke-test.sh +++ b/scripts/smoke-test.sh @@ -24,7 +24,7 @@ node --input-type=module -e "import '$DIST_BIN'" 2>&1 | head -5 | grep -q 'PostH } # ── 2. CI flag overrides physically absent from production builds ─────────── -# The override path (src/utils/ci-flag-overrides.ts) is dead code in published +# The override path (src/shared/utils/ci-flag-overrides.ts) is dead code in published # builds and tsdown strips it; its env var name appearing in dist/*.js means # dead-code elimination regressed and a prod surface leaked. Sourcemaps keep # the original source, so only .js output counts. diff --git a/scripts/tui-host.no-jest.ts b/scripts/tui-host.no-jest.ts index 61ca921bf..75b246b8e 100644 --- a/scripts/tui-host.no-jest.ts +++ b/scripts/tui-host.no-jest.ts @@ -17,16 +17,16 @@ import fs from 'fs'; import net from 'net'; import { spawnSync } from 'child_process'; import { startTUI } from '@ui/tui/start-tui'; -import { VERSION } from '@lib/version'; +import { VERSION } from '@shared/version'; import { Program, getProgramConfig, type ProgramId, } from '@lib/programs/program-registry'; -import type { Harness, Sequence } from '@lib/constants'; +import type { Harness, Sequence } from '@shared/constants'; import { buildSession } from '@lib/wizard-session'; -import { initLocalDev } from '@lib/local-dev'; -import { configureGatewayFromCIEnvironment } from '@lib/gateway-session'; +import { initLocalDev } from '@shared/local-dev'; +import { configureGatewayFromCIEnvironment } from '@agent/gateway-session'; import { runProgramAgent } from '@lib/programs/run-agent-legacy'; import { TaskStreamPush, createFileDestination } from '@lib/task-stream/index'; import { getAuditChecks } from '@lib/programs/audit/types'; @@ -36,7 +36,7 @@ import { logToFile } from '@utils/debug'; import { join } from 'path'; import { detectFramework } from '@lib/detection/index'; import { FRAMEWORK_REGISTRY } from '@lib/registry'; -import type { Integration } from '@lib/constants'; +import type { Integration } from '@shared/constants'; import { SELF_DRIVING_INTEGRATE_PATH_KEY } from '@lib/programs/self-driving/detect'; import { ERROR_TRACKING_PROJECT_PATH_KEY } from '@lib/programs/error-tracking/detect-agentic'; import { diff --git a/scripts/warlock-smoke-test.ts b/scripts/warlock-smoke-test.ts index 089e4110d..ad261bc5e 100644 --- a/scripts/warlock-smoke-test.ts +++ b/scripts/warlock-smoke-test.ts @@ -11,8 +11,8 @@ import { scan, CATEGORIES, type Category } from '@posthog/warlock'; import fs from 'fs'; import os from 'os'; import path from 'path'; -import { scanVerdict } from '../src/lib/yara-policy'; -import { scanInstalledSkill } from '../src/lib/yara-hooks'; +import { scanVerdict } from '@agent/yara-policy'; +import { scanInstalledSkill } from '@agent/yara-hooks'; // Assembled at runtime so no scannable secret literal is committed. const fakeStripeKey = 'sk_' + 'live_' + '5'.repeat(24); diff --git a/src/__tests__/architecture/import-boundaries.test.ts b/src/__tests__/architecture/import-boundaries.test.ts index 8220182ae..dba4024a4 100644 --- a/src/__tests__/architecture/import-boundaries.test.ts +++ b/src/__tests__/architecture/import-boundaries.test.ts @@ -10,16 +10,7 @@ const REPO_ROOT = path.resolve(HERE, '../../..'); const SURFACE_RULES: ReadonlyArray boolean]> = [ ['env', (p) => p === 'src/env.ts'], - [ - 'agent', - (p) => - p.startsWith('src/lib/agent/') || - p.startsWith('src/lib/middleware/') || - p === 'src/lib/gateway-session.ts' || - p === 'src/lib/yara-hooks.ts' || - p === 'src/lib/yara-policy.ts' || - p === 'src/lib/wizard-tools/mcp.ts', - ], + ['agent', (p) => p.startsWith('src/agent/')], [ 'tui', (p) => @@ -384,12 +375,12 @@ describe('import boundaries', () => { describe('surface classification', () => { it('maps representative paths to their surface', () => { expect(classifySurface('src/env.ts')).toBe('env'); - expect(classifySurface('src/utils/analytics.ts')).toBe('legacy'); - expect(classifySurface('src/lib/agent/agent-runner.ts')).toBe('agent'); + expect(classifySurface('src/shared/utils/analytics.ts')).toBe('legacy'); + expect(classifySurface('src/agent/agent-runner.ts')).toBe('agent'); expect(classifySurface('src/ui/tui/App.tsx')).toBe('tui'); expect(classifySurface('bin.ts')).toBe('cli'); - expect(classifySurface('src/lib/wizard-tools/mcp.ts')).toBe('agent'); - expect(classifySurface('src/lib/wizard-tools/tools.ts')).toBe('legacy'); + expect(classifySurface('src/agent/tools/mcp.ts')).toBe('agent'); + expect(classifySurface('src/agent/tools/tools.ts')).toBe('agent'); expect(classifySurface('src/commands/factories/family-picker.tsx')).toBe( 'tui', ); diff --git a/src/__tests__/architecture/known-violations.json b/src/__tests__/architecture/known-violations.json index cac070705..1f0f7bd21 100644 --- a/src/__tests__/architecture/known-violations.json +++ b/src/__tests__/architecture/known-violations.json @@ -2,76 +2,73 @@ "violations": [ "src/commands/factories/family-picker.tsx -> src/commands/command.ts", "src/env.ts -> src/lib/headless-mode.ts", - "src/lib/detection/agentic.ts -> src/lib/agent/agent-interface.ts", - "src/lib/errors/agent-map.ts -> src/lib/agent/signals.ts", - "src/lib/programs/agent-skill/index.ts -> src/lib/agent/agent-runner.ts", + "src/lib/detection/agentic.ts -> src/agent/agent-interface.ts", + "src/lib/programs/agent-skill/index.ts -> src/agent/agent-runner.ts", "src/lib/programs/agent-skill/index.ts -> src/lib/programs/agent-skill/content/index.tsx", "src/lib/programs/ai-observability/index.ts -> src/lib/programs/agent-skill/content/index.tsx", - "src/lib/programs/audit/detect.ts -> src/lib/agent/agent-runner.ts", + "src/lib/programs/audit/detect.ts -> src/agent/agent-runner.ts", + "src/lib/programs/audit/index.ts -> src/agent/tools/index.ts", + "src/lib/programs/dispatch-family.ts -> src/agent/tools/index.ts", "src/lib/programs/dispatch-family.ts -> src/commands/command.ts", "src/lib/programs/dispatch-family.ts -> src/commands/factories/shared.ts", - "src/lib/programs/error-tracking-upload-source-maps/detect.ts -> src/lib/agent/agent-runner.ts", + "src/lib/programs/error-tracking-upload-source-maps/detect.ts -> src/agent/agent-runner.ts", "src/lib/programs/error-tracking-upload-source-maps/index.ts -> src/lib/programs/error-tracking-upload-source-maps/content/index.tsx", - "src/lib/programs/error-tracking-upload-source-maps/prompt.ts -> src/lib/agent/agent-interface.ts", + "src/lib/programs/error-tracking-upload-source-maps/prompt.ts -> src/agent/agent-interface.ts", "src/lib/programs/error-tracking/index.ts -> src/lib/programs/error-tracking/content/index.tsx", "src/lib/programs/error-tracking/index.ts -> src/lib/programs/error-tracking/content/tips.ts", - "src/lib/programs/mcp-analytics/index.ts -> src/lib/agent/agent-runner.ts", + "src/lib/programs/events-audit/index.ts -> src/agent/tools/index.ts", + "src/lib/programs/mcp-analytics/index.ts -> src/agent/agent-runner.ts", "src/lib/programs/metrics/index.ts -> src/lib/programs/agent-skill/content/index.tsx", - "src/lib/programs/migration/index.ts -> src/lib/agent/agent-runner.ts", + "src/lib/programs/migration/index.ts -> src/agent/agent-runner.ts", + "src/lib/programs/migration/index.ts -> src/agent/tools/index.ts", "src/lib/programs/migration/index.ts -> src/lib/programs/migration/content/index.tsx", - "src/lib/programs/posthog-integration/index.ts -> src/lib/agent/agent-interface.ts", - "src/lib/programs/posthog-integration/index.ts -> src/lib/agent/agent-runner.ts", + "src/lib/programs/posthog-doctor/index.ts -> src/agent/tools/index.ts", + "src/lib/programs/posthog-integration/index.ts -> src/agent/agent-interface.ts", + "src/lib/programs/posthog-integration/index.ts -> src/agent/agent-runner.ts", + "src/lib/programs/posthog-integration/index.ts -> src/agent/tools/index.ts", "src/lib/programs/posthog-integration/index.ts -> src/lib/programs/posthog-integration/content/index.tsx", "src/lib/programs/program-registry.ts -> src/lib/programs/agent-skill/content/index.tsx", - "src/lib/programs/program-run.ts -> src/lib/agent/runner/index.ts", + "src/lib/programs/program-run.ts -> src/agent/runner/index.ts", "src/lib/programs/program-step.ts -> src/ui/tui/components/TipsCard.tsx", "src/lib/programs/program-step.ts -> src/ui/tui/primitives/index.ts", "src/lib/programs/program-step.ts -> src/ui/tui/store.ts", - "src/lib/programs/replay-vision/index.ts -> src/lib/agent/agent-runner.ts", - "src/lib/programs/revenue-analytics/detect.ts -> src/lib/agent/agent-runner.ts", + "src/lib/programs/replay-vision/index.ts -> src/agent/agent-runner.ts", + "src/lib/programs/revenue-analytics/detect.ts -> src/agent/agent-runner.ts", + "src/lib/programs/revenue-analytics/index.ts -> src/agent/tools/index.ts", "src/lib/programs/revenue-analytics/index.ts -> src/lib/programs/revenue-analytics/content/index.tsx", - "src/lib/programs/run-agent-legacy.ts -> src/lib/agent/agent-interface.ts", - "src/lib/programs/run-agent-legacy.ts -> src/lib/agent/claude-settings.ts", - "src/lib/programs/run-agent-legacy.ts -> src/lib/agent/runner/index.ts", - "src/lib/programs/run-agent-legacy.ts -> src/lib/agent/runner/switchboard/index.ts", - "src/lib/programs/run-agent-legacy.ts -> src/lib/yara-hooks.ts", - "src/lib/programs/self-driving/detect.ts -> src/lib/agent/agent-runner.ts", + "src/lib/programs/run-agent-legacy.ts -> src/agent/agent-interface.ts", + "src/lib/programs/run-agent-legacy.ts -> src/agent/runner/index.ts", + "src/lib/programs/run-agent-legacy.ts -> src/agent/runner/switchboard/index.ts", + "src/lib/programs/run-agent-legacy.ts -> src/agent/yara-hooks.ts", + "src/lib/programs/self-driving/detect.ts -> src/agent/agent-runner.ts", "src/lib/programs/self-driving/index.ts -> src/lib/programs/self-driving/content/index.tsx", "src/lib/programs/self-driving/index.ts -> src/lib/programs/self-driving/content/pricing.ts", "src/lib/programs/self-driving/index.ts -> src/lib/programs/self-driving/content/tips.ts", - "src/lib/programs/self-driving/prompt.ts -> src/lib/agent/agent-interface.ts", - "src/lib/programs/self-driving/prompt.ts -> src/lib/agent/agent-runner.ts", - "src/lib/programs/warehouse-source/detect.ts -> src/lib/agent/agent-runner.ts", + "src/lib/programs/self-driving/prompt.ts -> src/agent/agent-interface.ts", + "src/lib/programs/self-driving/prompt.ts -> src/agent/agent-runner.ts", + "src/lib/programs/warehouse-source/detect.ts -> src/agent/agent-runner.ts", + "src/lib/programs/warehouse-source/index.ts -> src/agent/wizard-ask-bridge.ts", "src/lib/programs/warehouse-source/index.ts -> src/lib/programs/warehouse-source/content/index.tsx", - "src/lib/programs/web-analytics-doctor/detect.ts -> src/lib/agent/agent-runner.ts", + "src/lib/programs/web-analytics-doctor/detect.ts -> src/agent/agent-runner.ts", "src/lib/task-stream/event-plan-watcher.ts -> src/ui/tui/store.ts", "src/lib/task-stream/task-stream-push.ts -> src/ui/tui/store.ts", - "src/lib/wizard-ask-bridge.ts -> src/lib/agent/progress.ts", - "src/lib/wizard-session.ts -> src/lib/agent/claude-settings.ts", - "src/lib/wizard-session.ts -> src/lib/agent/progress.ts", - "src/lib/wizard-tools/handoff.ts -> src/lib/agent/progress.ts", - "src/lib/wizard-tools/index.ts -> src/lib/wizard-tools/mcp.ts", - "src/lib/wizard-tools/tools.ts -> src/lib/yara-hooks.ts", + "src/lib/wizard-session.ts -> src/agent/progress.ts", + "src/lib/wizard-spellbook.ts -> src/agent/tools/tools.ts", + "src/shared/claude-settings.ts -> src/agent/agent-env-isolation.ts", + "src/shared/errors/agent-map.ts -> src/agent/signals.ts", + "src/shared/errors/skill-map.ts -> src/agent/tools/index.ts", + "src/shared/utils/package-manager.ts -> src/telemetry.ts", + "src/shared/utils/setup-utils.ts -> src/telemetry.ts", + "src/shared/utils/wizard-abort.ts -> src/ui/logging-ui.ts", "src/steps/add-mcp-server-to-clients/index.ts -> src/telemetry.ts", "src/steps/add-or-update-environment-variables.ts -> src/telemetry.ts", "src/steps/run-prettier.ts -> src/telemetry.ts", "src/steps/upload-environment-variables/index.ts -> src/telemetry.ts", - "src/ui/agent-progress.ts -> src/lib/agent/progress.ts", + "src/ui/agent-progress.ts -> src/agent/progress.ts", "src/ui/index.ts -> src/ui/logging-ui.ts", - "src/ui/logging-ui.ts -> src/lib/agent/claude-settings.ts", - "src/ui/tui/components/PhaseVisuals.tsx -> src/lib/agent/agent-phase.ts", - "src/ui/tui/components/TokenCostHud.tsx -> src/lib/agent/token-pricing.ts", - "src/ui/tui/exit-line.ts -> src/lib/agent/token-pricing.ts", - "src/ui/tui/ink-ui.ts -> src/lib/agent/claude-settings.ts", - "src/ui/tui/playground/demos/RunScreenDemo.tsx -> src/lib/agent/agent-phase.ts", - "src/ui/tui/screens/ManagedSettingsScreen.tsx -> src/lib/agent/claude-settings.ts", - "src/ui/tui/services/mcp-suggested-prompts-services.ts -> src/lib/agent/mcp-prompt-streaming.ts", - "src/ui/tui/store.ts -> src/lib/agent/claude-settings.ts", - "src/ui/tui/store.ts -> src/lib/agent/token-pricing.ts", - "src/ui/wizard-ui.ts -> src/lib/agent/claude-settings.ts", - "src/ui/wizard-ui.ts -> src/lib/agent/progress.ts", - "src/utils/package-manager.ts -> src/telemetry.ts", - "src/utils/setup-utils.ts -> src/telemetry.ts", - "src/utils/wizard-abort.ts -> src/ui/logging-ui.ts" + "src/ui/tui/screens/SkillSourceInfo.tsx -> src/agent/tools/index.ts", + "src/ui/tui/screens/health/HealthCheckScreen.tsx -> src/agent/tools/index.ts", + "src/ui/tui/services/mcp-suggested-prompts-services.ts -> src/agent/mcp-prompt-streaming.ts", + "src/ui/wizard-ui.ts -> src/agent/progress.ts" ] } diff --git a/src/__tests__/cli.test.ts b/src/__tests__/cli.test.ts index 4633470ee..aedc37a40 100644 --- a/src/__tests__/cli.test.ts +++ b/src/__tests__/cli.test.ts @@ -59,7 +59,7 @@ vi.mock('../lib/wizard-session', async (importOriginal) => ({ ...(await importOriginal()), buildSession: mockBuildSessionCli, })); -vi.mock('../utils/provisioning', () => ({ +vi.mock('@utils/provisioning', () => ({ provisionNewAccount: mockProvisionNewAccountCli, })); vi.mock('../ui/tui/start-tui', () => ({ @@ -88,15 +88,15 @@ vi.mock('../lib/programs/posthog-integration/index', () => ({ run: () => Promise.resolve(), }, })); -vi.mock('../utils/environment', () => ({ +vi.mock('@utils/environment', () => ({ isNonInteractiveEnvironment: () => false, readEnvironment: () => ({}), })); // CI-path dynamic imports need mocks to prevent unhandled rejections -vi.mock('../utils/env-api-key', () => ({ +vi.mock('@utils/env-api-key', () => ({ readApiKeyFromEnv: () => undefined, })); -vi.mock('../utils/debug', () => ({ +vi.mock('@utils/debug', () => ({ configureLogFileFromEnvironment: vi.fn(), logToFile: vi.fn(), })); @@ -105,11 +105,11 @@ vi.mock('../lib/detection/index', () => ({ detectFramework: vi.fn().mockResolvedValue(null), gatherFrameworkContext: vi.fn().mockResolvedValue({}), })); -vi.mock('../utils/analytics', () => ({ +vi.mock('@utils/analytics', () => ({ analytics: { setTag: vi.fn() }, })); -vi.mock('../utils/wizard-abort', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('@utils/wizard-abort', async (importOriginal) => ({ + ...(await importOriginal()), wizardAbort: vi.fn(), })); vi.mock('../lib/programs/run-agent-legacy', () => ({ @@ -285,7 +285,7 @@ describe('CLI argument parsing', () => { // from a buildSession arg — so assert the URL the run would actually fetch. async function skillsBaseUrl(): Promise<{ actual: string; local: string }> { const { getSkillsBaseUrl, LOCAL_SKILLS_BASE_URL } = await import( - '../lib/constants' + '@shared/constants' ); return { actual: getSkillsBaseUrl(), local: LOCAL_SKILLS_BASE_URL }; } @@ -444,7 +444,7 @@ describe('CLI argument parsing', () => { '/tmp/test', ]); - const { analytics } = await import('../utils/analytics'); + const { analytics } = await import('@utils/analytics'); expect(analytics.setTag).toHaveBeenCalledWith('build', 'ci'); }); @@ -527,7 +527,7 @@ describe('CLI argument parsing', () => { '/tmp/test', ]); - const { analytics } = await import('../utils/analytics'); + const { analytics } = await import('@utils/analytics'); expect(analytics.setTag).toHaveBeenCalledWith('build', 'headless'); expect(analytics.setTag).not.toHaveBeenCalledWith('build', 'ci'); }); @@ -544,7 +544,7 @@ describe('CLI argument parsing', () => { '/tmp/test', ]); - const { analytics } = await import('../utils/analytics'); + const { analytics } = await import('@utils/analytics'); expect(analytics.setTag).toHaveBeenCalledWith('build', 'headless'); expect(analytics.setTag).not.toHaveBeenCalledWith('build', 'ci'); }); diff --git a/src/__tests__/programs-cli.test.ts b/src/__tests__/programs-cli.test.ts index 89a972809..9f24ddd10 100644 --- a/src/__tests__/programs-cli.test.ts +++ b/src/__tests__/programs-cli.test.ts @@ -8,8 +8,8 @@ vi.mock('@lib/runners', () => ({ runWizardCI: mockRunWizardCI, })); -vi.mock('@lib/wizard-tools', async (importOriginal) => { - const actual = await importOriginal(); +vi.mock('@agent/tools', async (importOriginal) => { + const actual = await importOriginal(); return { ...actual, fetchSkillMenu: vi.fn(), @@ -31,7 +31,7 @@ import { pickerChildrenToShow, } from '@lib/programs/dispatch-family'; import type { Command } from '../commands/command'; -import { fetchSkillMenu, type CliEntry } from '@lib/wizard-tools'; +import { fetchSkillMenu, type CliEntry } from '@agent/tools'; import { auditConfig } from '@lib/programs/audit/index'; import { webAnalyticsDoctorConfig } from '@lib/programs/web-analytics-doctor/index'; import { parseCommand } from './helpers/parse-command.no-jest'; diff --git a/src/__tests__/provision-cli.test.ts b/src/__tests__/provision-cli.test.ts index 95d547bd0..636f75f72 100644 --- a/src/__tests__/provision-cli.test.ts +++ b/src/__tests__/provision-cli.test.ts @@ -5,7 +5,7 @@ const { mockProvisionNewAccountSubcmd } = vi.hoisted(() => ({ })); vi.mock('semver', () => ({ satisfies: () => true })); -vi.mock('../utils/provisioning', () => ({ +vi.mock('@utils/provisioning', () => ({ provisionNewAccount: mockProvisionNewAccountSubcmd, })); // Same supporting mocks as src/__tests__/cli.test.ts — bin.ts imports these @@ -40,14 +40,14 @@ vi.mock('../lib/programs/posthog-integration/index', () => ({ run: () => Promise.resolve(), }, })); -vi.mock('../utils/environment', () => ({ +vi.mock('@utils/environment', () => ({ isNonInteractiveEnvironment: () => false, readEnvironment: () => ({}), })); -vi.mock('../utils/env-api-key', () => ({ +vi.mock('@utils/env-api-key', () => ({ readApiKeyFromEnv: () => undefined, })); -vi.mock('../utils/debug', () => ({ +vi.mock('@utils/debug', () => ({ configureLogFileFromEnvironment: vi.fn(), logToFile: vi.fn(), })); @@ -56,11 +56,11 @@ vi.mock('../lib/detection/index', () => ({ detectFramework: vi.fn().mockResolvedValue(null), gatherFrameworkContext: vi.fn().mockResolvedValue({}), })); -vi.mock('../utils/analytics', () => ({ +vi.mock('@utils/analytics', () => ({ analytics: { setTag: vi.fn() }, })); -vi.mock('../utils/wizard-abort', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('@utils/wizard-abort', async (importOriginal) => ({ + ...(await importOriginal()), wizardAbort: vi.fn(), })); vi.mock('../lib/programs/run-agent-legacy', () => ({ diff --git a/src/__tests__/skill-cli.test.ts b/src/__tests__/skill-cli.test.ts index 7acc361ab..aed48a047 100644 --- a/src/__tests__/skill-cli.test.ts +++ b/src/__tests__/skill-cli.test.ts @@ -4,13 +4,13 @@ vi.mock('../commands/basic-integration/skill', () => ({ runSkillMode: vi.fn(), })); -vi.mock('@lib/wizard-tools', async (importOriginal) => { - const actual = await importOriginal(); +vi.mock('@agent/tools', async (importOriginal) => { + const actual = await importOriginal(); return { ...actual, fetchSkillMenu: vi.fn() }; }); import { runSkillMode } from '../commands/basic-integration/skill'; -import { fetchSkillMenu } from '@lib/wizard-tools'; +import { fetchSkillMenu } from '@agent/tools'; import { analytics } from '@utils/analytics'; import { skillCommand } from '../commands/skill'; import { parseCommand } from './helpers/parse-command.no-jest'; diff --git a/src/__tests__/wizard-abort.test.ts b/src/__tests__/wizard-abort.test.ts index 8699354c6..66111f8b6 100644 --- a/src/__tests__/wizard-abort.test.ts +++ b/src/__tests__/wizard-abort.test.ts @@ -7,10 +7,10 @@ import { runCleanups, } from '@utils/wizard-abort'; import { analytics } from '@utils/analytics'; -import { ErrorCodes } from '@lib/errors'; +import { ErrorCodes } from '@shared/errors'; import { getUI } from '../ui'; -vi.mock('../utils/analytics'); +vi.mock('@utils/analytics'); vi.mock('../ui', () => ({ getUI: vi.fn().mockReturnValue({ outroError: vi.fn(), diff --git a/src/lib/agent/__tests__/__snapshots__/commandments.test.ts.snap b/src/agent/__tests__/__snapshots__/commandments.test.ts.snap similarity index 100% rename from src/lib/agent/__tests__/__snapshots__/commandments.test.ts.snap rename to src/agent/__tests__/__snapshots__/commandments.test.ts.snap diff --git a/src/lib/agent/__tests__/__snapshots__/credential-isolation-snapshot.test.ts.snap b/src/agent/__tests__/__snapshots__/credential-isolation-snapshot.test.ts.snap similarity index 100% rename from src/lib/agent/__tests__/__snapshots__/credential-isolation-snapshot.test.ts.snap rename to src/agent/__tests__/__snapshots__/credential-isolation-snapshot.test.ts.snap diff --git a/src/lib/agent/__tests__/agent-env-isolation.test.ts b/src/agent/__tests__/agent-env-isolation.test.ts similarity index 99% rename from src/lib/agent/__tests__/agent-env-isolation.test.ts rename to src/agent/__tests__/agent-env-isolation.test.ts index 29a1feaf3..3a8c9c6d6 100644 --- a/src/lib/agent/__tests__/agent-env-isolation.test.ts +++ b/src/agent/__tests__/agent-env-isolation.test.ts @@ -2,7 +2,7 @@ import { sanitizeAgentSubprocessEnv, isBlockedAgentEnvKey, BLOCKED_AGENT_ENV_KEYS, -} from '@lib/agent/agent-env-isolation'; +} from '@agent/agent-env-isolation'; describe('isBlockedAgentEnvKey', () => { it('blocks the direct API key that outranks the gateway auth token', () => { diff --git a/src/lib/__tests__/agent-interface.test.ts b/src/agent/__tests__/agent-interface.test.ts similarity index 99% rename from src/lib/__tests__/agent-interface.test.ts rename to src/agent/__tests__/agent-interface.test.ts index cfe1110c3..c14f03c77 100644 --- a/src/lib/__tests__/agent-interface.test.ts +++ b/src/agent/__tests__/agent-interface.test.ts @@ -9,11 +9,11 @@ import { buildAgentEnv, reportMcpSetup, AgentErrorType, -} from '@lib/agent/agent-interface'; -import { AgentOutputSignals } from '@lib/agent/output-signals'; -import { RESUME_INSTRUCTION } from '@lib/agent/signals'; +} from '@agent/agent-interface'; +import { AgentOutputSignals } from '@agent/output-signals'; +import { RESUME_INSTRUCTION } from '@agent/signals'; import { analytics } from '@utils/analytics'; -import { Sequence } from '@lib/constants'; +import { Sequence } from '@shared/constants'; import type { WizardRunOptions } from '@utils/types'; import type { SpinnerHandle } from '@ui'; import { @@ -22,8 +22,8 @@ import { } from '@lib/wizard-session'; // Mock dependencies -vi.mock('../../utils/analytics'); -vi.mock('../../utils/debug'); +vi.mock('@utils/analytics'); +vi.mock('@utils/debug'); // Mock the SDK module const mockQuery = vi.fn(); diff --git a/src/lib/agent/__tests__/agent-prompt-loader.test.ts b/src/agent/__tests__/agent-prompt-loader.test.ts similarity index 99% rename from src/lib/agent/__tests__/agent-prompt-loader.test.ts rename to src/agent/__tests__/agent-prompt-loader.test.ts index a00baf6fa..876364226 100644 --- a/src/lib/agent/__tests__/agent-prompt-loader.test.ts +++ b/src/agent/__tests__/agent-prompt-loader.test.ts @@ -17,8 +17,8 @@ import { type AgentRegistry, type OrchestratorPromptContext, } from '../agent-prompt-loader'; -import { QueueStore } from '@lib/agent/runner/sequence/orchestrator/queue'; -import { HostResolution } from '@lib/host-resolution'; +import { QueueStore } from '@agent/runner/sequence/orchestrator/queue'; +import { HostResolution } from '@shared/host-resolution'; function tmpDir(): string { return fs.mkdtempSync(path.join(os.tmpdir(), 'agent-loader-test-')); diff --git a/src/lib/agent/__tests__/agent-prompt.test.ts b/src/agent/__tests__/agent-prompt.test.ts similarity index 91% rename from src/lib/agent/__tests__/agent-prompt.test.ts rename to src/agent/__tests__/agent-prompt.test.ts index e6bad880c..57d349cd5 100644 --- a/src/lib/agent/__tests__/agent-prompt.test.ts +++ b/src/agent/__tests__/agent-prompt.test.ts @@ -1,6 +1,6 @@ -import { assemblePrompt, type PromptContext } from '@lib/agent/agent-prompt'; -import type { AgentRunDefinition } from '@lib/agent/runner'; -import { HostResolution } from '@lib/host-resolution'; +import { assemblePrompt, type PromptContext } from '@agent/agent-prompt'; +import type { AgentRunDefinition } from '@agent/runner'; +import { HostResolution } from '@shared/host-resolution'; function makeRunDef( overrides: Partial = {}, diff --git a/src/lib/__tests__/agent-runner-ask.test.ts b/src/agent/__tests__/agent-runner-ask.test.ts similarity index 97% rename from src/lib/__tests__/agent-runner-ask.test.ts rename to src/agent/__tests__/agent-runner-ask.test.ts index 2364b5ccf..dfee8067f 100644 --- a/src/lib/__tests__/agent-runner-ask.test.ts +++ b/src/agent/__tests__/agent-runner-ask.test.ts @@ -1,4 +1,4 @@ -import { shouldDisableAsk } from '@lib/agent/agent-runner'; +import { shouldDisableAsk } from '@agent/agent-runner'; import { buildSession } from '@lib/wizard-session'; describe('shouldDisableAsk', () => { diff --git a/src/lib/agent/__tests__/aio-capture.test.ts b/src/agent/__tests__/aio-capture.test.ts similarity index 99% rename from src/lib/agent/__tests__/aio-capture.test.ts rename to src/agent/__tests__/aio-capture.test.ts index 042f1e2d3..5d0c8d90b 100644 --- a/src/lib/agent/__tests__/aio-capture.test.ts +++ b/src/agent/__tests__/aio-capture.test.ts @@ -1,4 +1,4 @@ -import { createAioCapture } from '@lib/agent/aio-capture'; +import { createAioCapture } from '@agent/aio-capture'; const RUN_TAGS = { program_id: 'posthog-integration', diff --git a/src/lib/agent/__tests__/bash-fence-python.test.ts b/src/agent/__tests__/bash-fence-python.test.ts similarity index 98% rename from src/lib/agent/__tests__/bash-fence-python.test.ts rename to src/agent/__tests__/bash-fence-python.test.ts index 1a45587a4..bb96f83ab 100644 --- a/src/lib/agent/__tests__/bash-fence-python.test.ts +++ b/src/agent/__tests__/bash-fence-python.test.ts @@ -1,4 +1,4 @@ -import { evaluateBashCommand } from '@lib/agent/bash-fence'; +import { evaluateBashCommand } from '@agent/bash-fence'; /** * The fence and the pi runtime notes have to agree: the notes tell the agent to diff --git a/src/lib/agent/__tests__/commandments.test.ts b/src/agent/__tests__/commandments.test.ts similarity index 96% rename from src/lib/agent/__tests__/commandments.test.ts rename to src/agent/__tests__/commandments.test.ts index b00a74a4f..2a694c0f2 100644 --- a/src/lib/agent/__tests__/commandments.test.ts +++ b/src/agent/__tests__/commandments.test.ts @@ -1,6 +1,6 @@ -import { WIZARD_COMMANDMENTS } from '@lib/agent/commandments'; -import { assembleCommandments } from '@lib/agent/runner/switchboard/commandments'; -import { Harness, Sequence } from '@lib/constants'; +import { WIZARD_COMMANDMENTS } from '@agent/commandments'; +import { assembleCommandments } from '@agent/runner/switchboard/commandments'; +import { Harness, Sequence } from '@shared/constants'; const global = WIZARD_COMMANDMENTS.join('\n'); diff --git a/src/lib/agent/__tests__/credential-isolation-snapshot.test.ts b/src/agent/__tests__/credential-isolation-snapshot.test.ts similarity index 96% rename from src/lib/agent/__tests__/credential-isolation-snapshot.test.ts rename to src/agent/__tests__/credential-isolation-snapshot.test.ts index a17d5ad04..40649ebcb 100644 --- a/src/lib/agent/__tests__/credential-isolation-snapshot.test.ts +++ b/src/agent/__tests__/credential-isolation-snapshot.test.ts @@ -13,9 +13,9 @@ * isolation surface — a diff here means a credential path changed disposition. */ -import { sanitizeAgentSubprocessEnv } from '@lib/agent/agent-env-isolation'; -import { classifySettingsConflicts } from '@lib/agent/claude-settings'; -import type { SettingsConflict } from '@lib/agent/claude-settings'; +import { sanitizeAgentSubprocessEnv } from '@agent/agent-env-isolation'; +import { classifySettingsConflicts } from '@shared/claude-settings'; +import type { SettingsConflict } from '@shared/claude-settings'; // Every env-based avenue (one key each), plus the gateway routing and benign // env that must survive. Grouped by avenue for readability; the snapshot sorts. diff --git a/src/lib/__tests__/gateway-session.test.ts b/src/agent/__tests__/gateway-session.test.ts similarity index 98% rename from src/lib/__tests__/gateway-session.test.ts rename to src/agent/__tests__/gateway-session.test.ts index ce0966fc5..23d5562d8 100644 --- a/src/lib/__tests__/gateway-session.test.ts +++ b/src/agent/__tests__/gateway-session.test.ts @@ -9,16 +9,16 @@ import { isPastRefresh, isTrustedGatewayUrl, resetGatewaySession, -} from '@lib/gateway-session'; -import type { HostResolution } from '@lib/host-resolution'; -import { ErrorCodes } from '@lib/errors'; +} from '@agent/gateway-session'; +import type { HostResolution } from '@shared/host-resolution'; +import { ErrorCodes } from '@shared/errors'; import { WizardError } from '@utils/wizard-abort'; import { analytics } from '@utils/analytics'; import { logToFile } from '@utils/debug'; -import { checkLlmGatewayHealth } from '@lib/health-checks/endpoints'; -import { ServiceHealthStatus } from '@lib/health-checks/types'; +import { checkLlmGatewayHealth } from '@shared/health-checks/endpoints'; +import { ServiceHealthStatus } from '@shared/health-checks/types'; -vi.mock('@lib/health-checks/endpoints', () => ({ +vi.mock('@shared/health-checks/endpoints', () => ({ checkLlmGatewayHealth: vi.fn(), })); @@ -120,7 +120,7 @@ describe('gatewayAuth', () => { vi.stubEnv('NODE_ENV', 'production'); vi.resetModules(); try { - const prod = await import('@lib/gateway-session'); + const prod = await import('@agent/gateway-session'); expect(() => prod.configureGatewayCredentialsForCI( 'token', diff --git a/src/lib/agent/__tests__/output-signals.test.ts b/src/agent/__tests__/output-signals.test.ts similarity index 97% rename from src/lib/agent/__tests__/output-signals.test.ts rename to src/agent/__tests__/output-signals.test.ts index 76eeaef6c..2c2431935 100644 --- a/src/lib/agent/__tests__/output-signals.test.ts +++ b/src/agent/__tests__/output-signals.test.ts @@ -1,5 +1,5 @@ -import { AgentOutputSignals } from '@lib/agent/output-signals'; -import { AgentSignals, REMARK_INSTRUCTION } from '@lib/agent/signals'; +import { AgentOutputSignals } from '@agent/output-signals'; +import { AgentSignals, REMARK_INSTRUCTION } from '@agent/signals'; describe('REMARK_INSTRUCTION', () => { it('carries the marker but no literal placeholder a model could echo', () => { diff --git a/src/lib/agent/__tests__/progress-collector.test.ts b/src/agent/__tests__/progress-collector.test.ts similarity index 96% rename from src/lib/agent/__tests__/progress-collector.test.ts rename to src/agent/__tests__/progress-collector.test.ts index 1d6e0740f..492d5f1b7 100644 --- a/src/lib/agent/__tests__/progress-collector.test.ts +++ b/src/agent/__tests__/progress-collector.test.ts @@ -1,6 +1,6 @@ import { OutroKind } from '@lib/wizard-session'; import { createProgressCollector } from '../runner/shared/progress-collector'; -import { MAX_STATUS_MESSAGES } from '@lib/status-history'; +import { MAX_STATUS_MESSAGES } from '@shared/status-history'; it('retains a bounded FIFO of statuses and drops consecutive duplicates', () => { const observer = vi.fn(); diff --git a/src/lib/agent/__tests__/run-agent-standalone.test.ts b/src/agent/__tests__/run-agent-standalone.test.ts similarity index 95% rename from src/lib/agent/__tests__/run-agent-standalone.test.ts rename to src/agent/__tests__/run-agent-standalone.test.ts index 13756a9ec..cf4a8f058 100644 --- a/src/lib/agent/__tests__/run-agent-standalone.test.ts +++ b/src/agent/__tests__/run-agent-standalone.test.ts @@ -9,22 +9,22 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -import { Harness, Sequence, DEFAULT_AGENT_MODEL } from '@lib/constants'; -import { HostResolution } from '@lib/host-resolution'; +import { Harness, Sequence, DEFAULT_AGENT_MODEL } from '@shared/constants'; +import { HostResolution } from '@shared/host-resolution'; import { OutroKind, type AskAnswers, type PendingQuestion, } from '@lib/wizard-session'; -import { AGENT_ERROR_CODE, ErrorCodes } from '@lib/errors'; -import { AgentErrorType } from '@lib/agent/signals'; -import type { AgentFailure } from '@lib/agent/runner/shared/types'; -import type { AgentProgress } from '@lib/agent/progress'; +import { AGENT_ERROR_CODE, ErrorCodes } from '@shared/errors'; +import { AgentErrorType } from '@agent/signals'; +import type { AgentFailure } from '@agent/runner/shared/types'; +import type { AgentProgress } from '@agent/progress'; import type { AgentHarness, BackendRunInputs, TaskRunInputs, -} from '@lib/agent/runner/harness/types'; +} from '@agent/runner/harness/types'; vi.mock('@ui', () => ({ getUI: () => { @@ -36,8 +36,8 @@ vi.mock('@ui', () => ({ })); vi.mock('@utils/debug'); vi.mock('@utils/terminal-bell'); -vi.mock('@lib/yara-hooks', async (original) => ({ - ...(await original()), +vi.mock('@agent/yara-hooks', async (original) => ({ + ...(await original()), flushScanReport: vi.fn(), })); vi.mock('@utils/analytics', () => ({ @@ -51,8 +51,8 @@ vi.mock('@utils/analytics', () => ({ shutdown: vi.fn().mockResolvedValue(undefined), }, })); -vi.mock('@lib/gateway-session', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('@agent/gateway-session', async (importOriginal) => ({ + ...(await importOriginal()), gatewayAuth: vi.fn().mockResolvedValue({ gatewayUrl: 'https://gateway.test', token: 'phe_run', @@ -73,7 +73,7 @@ const harnessState = vi.hoisted(() => ({ seedFailure: undefined as AgentFailure | undefined, askQuestions: undefined as PendingQuestion['questions'] | undefined, })); -vi.mock('@lib/agent/runner/switchboard/harness', () => { +vi.mock('@agent/runner/switchboard/harness', () => { const askIfRequested = async (inputs: BackendRunInputs | TaskRunInputs) => { if (!harnessState.askQuestions || !inputs.askBridge) return; const { answers } = await inputs.askBridge.request({ @@ -158,10 +158,8 @@ vi.mock('@lib/agent/runner/switchboard/harness', () => { }; }); -vi.mock('@lib/agent/agent-prompt-loader', async (original) => { - const actual = await original< - typeof import('@lib/agent/agent-prompt-loader') - >(); +vi.mock('@agent/agent-prompt-loader', async (original) => { + const actual = await original(); return { ...actual, loadAgentRegistry: vi.fn(() => @@ -185,16 +183,16 @@ vi.mock('@lib/agent/agent-prompt-loader', async (original) => { ), }; }); -vi.mock('@lib/wizard-tools', async (original) => ({ - ...(await original()), +vi.mock('@agent/tools', async (original) => ({ + ...(await original()), fetchSkillMenu: vi.fn().mockResolvedValue({ categories: {} }), })); -import { runAgent, RunOutcome } from '@lib/agent/runner'; -import type { RunConfig, RunInput } from '@lib/agent/runner'; +import { runAgent, RunOutcome } from '@agent/runner'; +import type { RunConfig, RunInput } from '@agent/runner'; import { analytics } from '@utils/analytics'; import { initLogFile } from '@utils/debug'; -import { flushScanReport } from '@lib/yara-hooks'; +import { flushScanReport } from '@agent/yara-hooks'; import { QUEUE_DIR_NAME } from '../runner/sequence/orchestrator/queue'; let tmp: string; diff --git a/src/lib/agent/__tests__/run-tags.test.ts b/src/agent/__tests__/run-tags.test.ts similarity index 94% rename from src/lib/agent/__tests__/run-tags.test.ts rename to src/agent/__tests__/run-tags.test.ts index b255653f7..8211b96e8 100644 --- a/src/lib/agent/__tests__/run-tags.test.ts +++ b/src/agent/__tests__/run-tags.test.ts @@ -1,5 +1,5 @@ -import { buildRunTags } from '@lib/agent/agent-interface'; -import { CallType } from '@lib/constants'; +import { buildRunTags } from '@agent/agent-interface'; +import { CallType } from '@shared/constants'; describe('buildRunTags', () => { it('carries the run identifiers as gateway trace tags', () => { diff --git a/src/lib/agent/__tests__/settings-conflicts.test.ts b/src/agent/__tests__/settings-conflicts.test.ts similarity index 97% rename from src/lib/agent/__tests__/settings-conflicts.test.ts rename to src/agent/__tests__/settings-conflicts.test.ts index 31f78f3e6..e5fb24d64 100644 --- a/src/lib/agent/__tests__/settings-conflicts.test.ts +++ b/src/agent/__tests__/settings-conflicts.test.ts @@ -10,9 +10,9 @@ import { checkAllSettingsConflicts, managedSettingsPath, classifySettingsConflicts, -} from '@lib/agent/claude-settings'; -import type { SettingsConflict } from '@lib/agent/claude-settings'; -import { buildAuthErrorContext } from '@lib/agent/agent-interface'; +} from '@shared/claude-settings'; +import type { SettingsConflict } from '@shared/claude-settings'; +import { buildAuthErrorContext } from '@agent/agent-interface'; const OVERRIDE = JSON.stringify({ apiKeyHelper: 'echo sk-x' }); const ENV_OVERRIDE = JSON.stringify({ diff --git a/src/lib/agent/__tests__/stored-login.test.ts b/src/agent/__tests__/stored-login.test.ts similarity index 100% rename from src/lib/agent/__tests__/stored-login.test.ts rename to src/agent/__tests__/stored-login.test.ts diff --git a/src/lib/agent/__tests__/triage-provider.test.ts b/src/agent/__tests__/triage-provider.test.ts similarity index 96% rename from src/lib/agent/__tests__/triage-provider.test.ts rename to src/agent/__tests__/triage-provider.test.ts index d51d82b9e..4af277940 100644 --- a/src/lib/agent/__tests__/triage-provider.test.ts +++ b/src/agent/__tests__/triage-provider.test.ts @@ -1,12 +1,12 @@ import { completeSimple } from '@earendil-works/pi-ai'; -import { createTriageLLMProvider } from '@lib/agent/triage-provider'; +import { createTriageLLMProvider } from '@agent/triage-provider'; import { CallType, GPT5_6_LUNA_MODEL, HAIKU_TRIAGE_MODEL, Harness, -} from '@lib/constants'; -import { triageModelFor } from '@lib/agent/runner/switchboard/models'; +} from '@shared/constants'; +import { triageModelFor } from '@agent/runner/switchboard/models'; vi.mock('@earendil-works/pi-ai', () => ({ completeSimple: vi.fn() })); const complete = vi.mocked(completeSimple); diff --git a/src/lib/agent/__tests__/tutorial-run-tags.test.ts b/src/agent/__tests__/tutorial-run-tags.test.ts similarity index 94% rename from src/lib/agent/__tests__/tutorial-run-tags.test.ts rename to src/agent/__tests__/tutorial-run-tags.test.ts index e0d2c2b3f..af00b50ef 100644 --- a/src/lib/agent/__tests__/tutorial-run-tags.test.ts +++ b/src/agent/__tests__/tutorial-run-tags.test.ts @@ -7,8 +7,8 @@ * tests pin the tags so that can't silently return. */ -import { buildTutorialRunTags } from '@lib/agent/mcp-prompt-streaming'; -import { buildAgentEnv } from '@lib/agent/agent-interface'; +import { buildTutorialRunTags } from '@agent/mcp-prompt-streaming'; +import { buildAgentEnv } from '@agent/agent-interface'; import { analytics } from '@utils/analytics'; describe('buildTutorialRunTags', () => { diff --git a/src/lib/agent/__tests__/variant-gating.test.ts b/src/agent/__tests__/variant-gating.test.ts similarity index 89% rename from src/lib/agent/__tests__/variant-gating.test.ts rename to src/agent/__tests__/variant-gating.test.ts index 1734e1446..7efd2ca49 100644 --- a/src/lib/agent/__tests__/variant-gating.test.ts +++ b/src/agent/__tests__/variant-gating.test.ts @@ -1,4 +1,4 @@ -import { isOrchestratorEnabled } from '@lib/agent/runner/switchboard'; +import { isOrchestratorEnabled } from '@agent/runner/switchboard'; describe('isOrchestratorEnabled', () => { it('is true only when the wizard-orchestrator flag is true', () => { diff --git a/src/lib/__tests__/wizard-ask-bridge.test.ts b/src/agent/__tests__/wizard-ask-bridge.test.ts similarity index 99% rename from src/lib/__tests__/wizard-ask-bridge.test.ts rename to src/agent/__tests__/wizard-ask-bridge.test.ts index 650f71b81..bd99ad0c4 100644 --- a/src/lib/__tests__/wizard-ask-bridge.test.ts +++ b/src/agent/__tests__/wizard-ask-bridge.test.ts @@ -2,11 +2,11 @@ import { CANCELLED_SENTINEL, createWizardAskBridge, isFullyCancelled, -} from '@lib/wizard-ask-bridge'; +} from '@agent/wizard-ask-bridge'; import { analytics } from '@utils/analytics'; import type { AskAnswers, PendingQuestion } from '@lib/wizard-session'; -vi.mock('../../utils/analytics', () => ({ +vi.mock('@utils/analytics', () => ({ analytics: { wizardCapture: vi.fn(), }, diff --git a/src/lib/__tests__/wizard-can-use-tool.test.ts b/src/agent/__tests__/wizard-can-use-tool.test.ts similarity index 99% rename from src/lib/__tests__/wizard-can-use-tool.test.ts rename to src/agent/__tests__/wizard-can-use-tool.test.ts index 26272ea66..3d42f954f 100644 --- a/src/lib/__tests__/wizard-can-use-tool.test.ts +++ b/src/agent/__tests__/wizard-can-use-tool.test.ts @@ -1,11 +1,11 @@ -import { wizardCanUseTool } from '@lib/agent/agent-interface'; +import { wizardCanUseTool } from '@agent/agent-interface'; -vi.mock('../../utils/analytics', () => ({ +vi.mock('@utils/analytics', () => ({ analytics: { wizardCapture: vi.fn(), }, })); -vi.mock('../../utils/debug'); +vi.mock('@utils/debug'); describe('wizardCanUseTool — wizard_ask pending guard', () => { for (const tool of ['Write', 'Edit'] as const) { diff --git a/src/lib/__tests__/wizard-tools.test.ts b/src/agent/__tests__/wizard-tools.test.ts similarity index 99% rename from src/lib/__tests__/wizard-tools.test.ts rename to src/agent/__tests__/wizard-tools.test.ts index 84acef33b..d087cabbc 100644 --- a/src/lib/__tests__/wizard-tools.test.ts +++ b/src/agent/__tests__/wizard-tools.test.ts @@ -31,7 +31,7 @@ import { resolveAskQuestionKinds, resolveEnvPath, templateEnvWriteRefusal, -} from '@lib/wizard-tools'; +} from '@agent/tools'; import type { AuditCheck } from '@lib/programs/audit/types'; function makeTmpDir(): string { diff --git a/src/lib/__tests__/yara-flush-report.test.ts b/src/agent/__tests__/yara-flush-report.test.ts similarity index 98% rename from src/lib/__tests__/yara-flush-report.test.ts rename to src/agent/__tests__/yara-flush-report.test.ts index 06e46e5c3..4c4a97b66 100644 --- a/src/lib/__tests__/yara-flush-report.test.ts +++ b/src/agent/__tests__/yara-flush-report.test.ts @@ -25,7 +25,7 @@ import { flushScanReport, recordExternalScan, resetScanReport, -} from '@lib/yara-hooks'; +} from '@agent/yara-hooks'; describe('flushScanReport', () => { beforeEach(() => { diff --git a/src/lib/__tests__/yara-hooks.test.ts b/src/agent/__tests__/yara-hooks.test.ts similarity index 99% rename from src/lib/__tests__/yara-hooks.test.ts rename to src/agent/__tests__/yara-hooks.test.ts index c5167d547..b4cd76683 100644 --- a/src/lib/__tests__/yara-hooks.test.ts +++ b/src/agent/__tests__/yara-hooks.test.ts @@ -8,20 +8,20 @@ import { captureScanReport, recordExternalScan, resetScanReport, -} from '@lib/yara-hooks'; +} from '@agent/yara-hooks'; import { scan, triageMatches } from '@posthog/warlock'; import fs from 'fs'; import fg from 'fast-glob'; -import * as analyticsModule from '../../utils/analytics'; +import * as analyticsModule from '@utils/analytics'; // Mock dependencies -vi.mock('../../utils/debug'); -vi.mock('../../utils/analytics'); +vi.mock('@utils/debug'); +vi.mock('@utils/analytics'); vi.mock('fs'); vi.mock('fast-glob'); // Mock isSkillInstallCommand from skill-install (extracted to break circular dep) -vi.mock('../skill-install', () => ({ +vi.mock('@shared/skill-install', () => ({ isSkillInstallCommand: (command: string) => command.startsWith('mkdir -p .claude/skills/') && command.includes('curl -sL') && diff --git a/src/lib/__tests__/yara-policy.test.ts b/src/agent/__tests__/yara-policy.test.ts similarity index 100% rename from src/lib/__tests__/yara-policy.test.ts rename to src/agent/__tests__/yara-policy.test.ts diff --git a/src/lib/agent/agent-env-isolation.ts b/src/agent/agent-env-isolation.ts similarity index 100% rename from src/lib/agent/agent-env-isolation.ts rename to src/agent/agent-env-isolation.ts diff --git a/src/lib/agent/agent-interface.ts b/src/agent/agent-interface.ts similarity index 99% rename from src/lib/agent/agent-interface.ts rename to src/agent/agent-interface.ts index b635842ff..610608d34 100644 --- a/src/lib/agent/agent-interface.ts +++ b/src/agent/agent-interface.ts @@ -16,7 +16,7 @@ import type { WizardRunOptions } from '@utils/types'; import { analytics } from '@utils/analytics'; import { isTemplateEnvFileName } from '@utils/env-scan'; import { runtimeEnv } from '@env'; -import type { AioCapture } from '@lib/agent/aio-capture'; +import type { AioCapture } from '@agent/aio-capture'; import { Harness, CallType, @@ -27,27 +27,27 @@ import { AWS_SKILLS_BASE_URL, type AdditionalFeature, ADDITIONAL_FEATURE_PROMPTS, -} from '@lib/constants'; +} from '@shared/constants'; import type { AgentFailure } from './runner/shared/types'; import { createCustomHeaders } from '@utils/custom-headers'; -import type { HostResolution } from '@lib/host-resolution'; +import type { HostResolution } from '@shared/host-resolution'; import { buildWizardPropertiesBlob, gatewayAuth, isPastRefresh, type GatewayAuth, -} from '@lib/gateway-session'; +} from '@agent/gateway-session'; import { evaluateBashCommand } from './bash-fence'; -import { createWizardToolsServer, WIZARD_TOOL_NAMES } from '@lib/wizard-tools'; +import { createWizardToolsServer, WIZARD_TOOL_NAMES } from '@agent/tools'; import { createPreToolUseYaraHooks, createPostToolUseYaraHooks, prewarmYaraScanner, -} from '@lib/yara-hooks'; +} from '@agent/yara-hooks'; import { createTriageLLMProvider } from './triage-provider'; import type { LLMProvider } from '@posthog/warlock'; import { assembleCommandments } from './runner/switchboard/commandments'; -import { classifyToolToStage } from './agent-phase'; +import { classifyToolToStage } from '@shared/agent-phase'; import type { PackageManagerDetector } from '@utils/package-manager'; import { AgentSignals, @@ -55,8 +55,8 @@ import { REMARK_INSTRUCTION, RESUME_INSTRUCTION, } from './signals'; -import { classifyAuthFailure, WizardError } from '@lib/errors'; -import { isGrantRevoked } from '@lib/auth-session-state'; +import { classifyAuthFailure, WizardError } from '@shared/errors'; +import { isGrantRevoked } from '@shared/auth-session-state'; import { AgentOutputSignals } from './output-signals'; // Signal vocabulary and the output parser live in dedicated modules; re-export @@ -68,7 +68,7 @@ import { checkAllSettingsConflicts, type SettingsConflict, type SettingsConflictSource, -} from './claude-settings'; +} from '@shared/claude-settings'; import { detectStoredClaudeLogin, hasStoredClaudeLogin, @@ -218,7 +218,7 @@ export type AgentConfig = { */ modelOverride?: string; /** Bridge that drives the `wizard_ask` overlay. Omit in non-interactive hosts. */ - askBridge?: import('@lib/wizard-ask-bridge').WizardAskBridge; + askBridge?: import('@agent/wizard-ask-bridge').WizardAskBridge; /** Per-run cap on `wizard_ask` invocations. Defaults to 10. */ askMaxQuestions?: number; /** Extra tools added on top of BASE_ALLOWED_TOOLS for this run. */ @@ -235,7 +235,7 @@ export type AgentConfig = { * flag routes the run here; threaded into wizard-tools so the orchestrator * tools register. */ - orchestrator?: import('@lib/agent/runner/sequence/orchestrator/queue-tools').OrchestratorToolsContext; + orchestrator?: import('@agent/runner/sequence/orchestrator/queue-tools').OrchestratorToolsContext; /** * Optional AIO capture — mirrors each assistant SDK message into the * authenticated project as `$ai_generation`. No-op instance when @@ -421,7 +421,7 @@ export function buildAgentEnv( } // Re-export for backwards compatibility — canonical source is skill-install.ts -export { isSkillInstallCommand } from '@lib/skill-install'; +export { isSkillInstallCommand } from '@shared/skill-install'; /** * Permission hook that allows only safe commands. Bash commands are gated by diff --git a/src/lib/agent/agent-prompt-loader.ts b/src/agent/agent-prompt-loader.ts similarity index 99% rename from src/lib/agent/agent-prompt-loader.ts rename to src/agent/agent-prompt-loader.ts index 19afc034a..c7b7bea92 100644 --- a/src/lib/agent/agent-prompt-loader.ts +++ b/src/agent/agent-prompt-loader.ts @@ -20,15 +20,15 @@ import type { QueuedTask, } from './runner/sequence/orchestrator/queue'; import type { ResolvedTask } from './runner/sequence/orchestrator/executor'; -import type { HostResolution } from '@lib/host-resolution'; +import type { HostResolution } from '@shared/host-resolution'; import { isThinkingLevel, type ThinkingLevel, } from './runner/switchboard/models'; import { logToFile } from '@utils/debug'; import { analytics } from '@utils/analytics'; -import { fetchWithRetry } from '@lib/fetch-retry'; -import { WIZARD_TOOL_NAMES } from '@lib/wizard-tools/tools'; +import { fetchWithRetry } from '@shared/fetch-retry'; +import { WIZARD_TOOL_NAMES } from '@agent/tools/tools'; /** * The basics the client injects around every agent-prompt body. The `/agents/` diff --git a/src/lib/agent/agent-prompt.ts b/src/agent/agent-prompt.ts similarity index 97% rename from src/lib/agent/agent-prompt.ts rename to src/agent/agent-prompt.ts index 4987adcfb..85abfe958 100644 --- a/src/lib/agent/agent-prompt.ts +++ b/src/agent/agent-prompt.ts @@ -8,7 +8,7 @@ */ import type { AgentRunDefinition } from './runner/shared/types'; -import type { HostResolution } from '@lib/host-resolution'; +import type { HostResolution } from '@shared/host-resolution'; /** * Values available to prompt builders after OAuth completes. diff --git a/src/lib/agent/agent-runner.ts b/src/agent/agent-runner.ts similarity index 100% rename from src/lib/agent/agent-runner.ts rename to src/agent/agent-runner.ts diff --git a/src/lib/agent/aio-capture.ts b/src/agent/aio-capture.ts similarity index 99% rename from src/lib/agent/aio-capture.ts rename to src/agent/aio-capture.ts index ad37d252f..be4182c3c 100644 --- a/src/lib/agent/aio-capture.ts +++ b/src/agent/aio-capture.ts @@ -25,7 +25,7 @@ */ import { logToFile } from '@utils/debug'; -import { VERSION } from '@lib/version'; +import { VERSION } from '@shared/version'; /** Conversation turn shape both harnesses normalize to. Matches Anthropic * message role/content conventions, which is also what AIO's Conversation diff --git a/src/lib/agent/bash-fence.ts b/src/agent/bash-fence.ts similarity index 99% rename from src/lib/agent/bash-fence.ts rename to src/agent/bash-fence.ts index 1264b11af..caf31e77a 100644 --- a/src/lib/agent/bash-fence.ts +++ b/src/agent/bash-fence.ts @@ -13,7 +13,7 @@ * (`npx ` downloads and runs it), and shell injection. Matching is * token-exact per manager — keyword prefixes admitted `npm publish` via `pub`. */ -import { LINTING_TOOLS } from '@lib/safe-tools'; +import { LINTING_TOOLS } from '@agent/safe-tools'; export type BashFenceDecision = | { allowed: true } diff --git a/src/lib/agent/commandments.ts b/src/agent/commandments.ts similarity index 100% rename from src/lib/agent/commandments.ts rename to src/agent/commandments.ts diff --git a/src/lib/gateway-session.ts b/src/agent/gateway-session.ts similarity index 98% rename from src/lib/gateway-session.ts rename to src/agent/gateway-session.ts index 55d50d651..9932f36ad 100644 --- a/src/lib/gateway-session.ts +++ b/src/agent/gateway-session.ts @@ -9,10 +9,10 @@ import { readFileSync } from 'node:fs'; import { logToFile } from '@utils/debug'; import { analytics } from '@utils/analytics'; -import { ErrorCodes, WizardError } from '@lib/errors'; -import type { HostResolution } from '@lib/host-resolution'; -import { checkLlmGatewayHealth } from '@lib/health-checks/endpoints'; -import { ServiceHealthStatus } from '@lib/health-checks/types'; +import { ErrorCodes, WizardError } from '@shared/errors'; +import type { HostResolution } from '@shared/host-resolution'; +import { checkLlmGatewayHealth } from '@shared/health-checks/endpoints'; +import { ServiceHealthStatus } from '@shared/health-checks/types'; import { IS_PRODUCTION_BUILD, runtimeEnv } from '@env'; import type { CloudRegion } from '@utils/types'; diff --git a/src/lib/agent/mcp-prompt-streaming.ts b/src/agent/mcp-prompt-streaming.ts similarity index 97% rename from src/lib/agent/mcp-prompt-streaming.ts rename to src/agent/mcp-prompt-streaming.ts index f3d0354ec..6bafc82fb 100644 --- a/src/lib/agent/mcp-prompt-streaming.ts +++ b/src/agent/mcp-prompt-streaming.ts @@ -12,13 +12,13 @@ * `for await (...)` and render as they arrive. */ -import type { Credentials } from '@lib/api'; -import { DEFAULT_AGENT_MODEL, WIZARD_USER_AGENT } from '@lib/constants'; +import type { Credentials } from '@shared/api'; +import { DEFAULT_AGENT_MODEL, WIZARD_USER_AGENT } from '@shared/constants'; import { logToFile } from '@utils/debug'; -import { gatewayAuth } from '@lib/gateway-session'; -import { buildAgentEnv, buildRunTags } from '@lib/agent/agent-interface'; -import { sanitizeAgentSubprocessEnv } from '@lib/agent/agent-env-isolation'; -import { createIsolatedAgentConfigDir } from '@lib/agent/stored-login'; +import { gatewayAuth } from '@agent/gateway-session'; +import { buildAgentEnv, buildRunTags } from '@agent/agent-interface'; +import { sanitizeAgentSubprocessEnv } from '@agent/agent-env-isolation'; +import { createIsolatedAgentConfigDir } from '@agent/stored-login'; import { analytics } from '@utils/analytics'; /** diff --git a/src/lib/middleware/__tests__/benchmark-emit.test.ts b/src/agent/middleware/__tests__/benchmark-emit.test.ts similarity index 98% rename from src/lib/middleware/__tests__/benchmark-emit.test.ts rename to src/agent/middleware/__tests__/benchmark-emit.test.ts index 2b1979e68..16bb16871 100644 --- a/src/lib/middleware/__tests__/benchmark-emit.test.ts +++ b/src/agent/middleware/__tests__/benchmark-emit.test.ts @@ -1,7 +1,7 @@ import { existsSync, mkdtempSync, rmSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; -import type { AgentProgress } from '@lib/agent/progress'; +import type { AgentProgress } from '@agent/progress'; // The benchmark pipeline runs inside the agent, which has no UI. Reaching one // is the defect this file guards against. diff --git a/src/lib/middleware/benchmark.ts b/src/agent/middleware/benchmark.ts similarity index 95% rename from src/lib/middleware/benchmark.ts rename to src/agent/middleware/benchmark.ts index 08c044253..bcbfad950 100644 --- a/src/lib/middleware/benchmark.ts +++ b/src/agent/middleware/benchmark.ts @@ -7,7 +7,7 @@ * pipeline.finalize(resultMessage, durationMs); */ -import type { ProgressEmitter, SpinnerHandle } from '@lib/agent/progress'; +import type { ProgressEmitter, SpinnerHandle } from '@agent/progress'; import { logToFile, getLogFilePath, configureLogFile } from '@utils/debug'; import { MiddlewarePipeline } from './pipeline'; import { PhaseDetector } from './phase-detector'; @@ -15,7 +15,7 @@ import { loadBenchmarkConfig } from './config'; import { createPluginsFromConfig } from './benchmarks'; import type { BenchmarkConfig } from './config'; import type { WizardRunOptions } from '@utils/types'; -import { AgentSignals } from '@lib/agent/agent-interface'; +import { AgentSignals } from '@agent/agent-interface'; // ── Types ────────────────────────────────────────────────────────────── diff --git a/src/lib/middleware/benchmarks/cache-tracker.ts b/src/agent/middleware/benchmarks/cache-tracker.ts similarity index 99% rename from src/lib/middleware/benchmarks/cache-tracker.ts rename to src/agent/middleware/benchmarks/cache-tracker.ts index 047efc3a8..046a19ea3 100644 --- a/src/lib/middleware/benchmarks/cache-tracker.ts +++ b/src/agent/middleware/benchmarks/cache-tracker.ts @@ -8,7 +8,7 @@ import type { Middleware, MiddlewareContext, MiddlewareStore, -} from '@lib/middleware/types'; +} from '@agent/middleware/types'; import type { TurnData } from './turn-counter'; /** Matches SDK usage.cache_creation (ephemeral 5m vs 1h for pricing). */ diff --git a/src/lib/middleware/benchmarks/compaction-tracker.ts b/src/agent/middleware/benchmarks/compaction-tracker.ts similarity index 96% rename from src/lib/middleware/benchmarks/compaction-tracker.ts rename to src/agent/middleware/benchmarks/compaction-tracker.ts index bb16fb6e5..9f2dcc4dc 100644 --- a/src/lib/middleware/benchmarks/compaction-tracker.ts +++ b/src/agent/middleware/benchmarks/compaction-tracker.ts @@ -9,9 +9,9 @@ import type { Middleware, MiddlewareContext, MiddlewareStore, -} from '@lib/middleware/types'; +} from '@agent/middleware/types'; import { logToFile } from '@utils/debug'; -import { AgentSignals } from '@lib/agent/agent-interface'; +import { AgentSignals } from '@agent/agent-interface'; export interface CompactionData { phaseCompactions: number; diff --git a/src/lib/middleware/benchmarks/context-size-tracker.ts b/src/agent/middleware/benchmarks/context-size-tracker.ts similarity index 98% rename from src/lib/middleware/benchmarks/context-size-tracker.ts rename to src/agent/middleware/benchmarks/context-size-tracker.ts index f51f0f441..a43e4fe98 100644 --- a/src/lib/middleware/benchmarks/context-size-tracker.ts +++ b/src/agent/middleware/benchmarks/context-size-tracker.ts @@ -10,7 +10,7 @@ import type { Middleware, MiddlewareContext, MiddlewareStore, -} from '@lib/middleware/types'; +} from '@agent/middleware/types'; import type { TokenData } from './token-tracker'; export interface ContextSizeData { diff --git a/src/lib/middleware/benchmarks/cost-tracker.ts b/src/agent/middleware/benchmarks/cost-tracker.ts similarity index 97% rename from src/lib/middleware/benchmarks/cost-tracker.ts rename to src/agent/middleware/benchmarks/cost-tracker.ts index 7e33ba0f4..9da769180 100644 --- a/src/lib/middleware/benchmarks/cost-tracker.ts +++ b/src/agent/middleware/benchmarks/cost-tracker.ts @@ -2,8 +2,8 @@ import type { Middleware, MiddlewareContext, MiddlewareStore, -} from '@lib/middleware/types'; -import { computeTokenCostUsd } from '@lib/agent/token-pricing'; +} from '@agent/middleware/types'; +import { computeTokenCostUsd } from '@shared/token-pricing'; import type { TokenData } from './token-tracker'; import type { CacheData } from './cache-tracker'; diff --git a/src/lib/middleware/benchmarks/duration-tracker.ts b/src/agent/middleware/benchmarks/duration-tracker.ts similarity index 97% rename from src/lib/middleware/benchmarks/duration-tracker.ts rename to src/agent/middleware/benchmarks/duration-tracker.ts index 84427273c..abb553038 100644 --- a/src/lib/middleware/benchmarks/duration-tracker.ts +++ b/src/agent/middleware/benchmarks/duration-tracker.ts @@ -6,7 +6,7 @@ import type { Middleware, MiddlewareContext, MiddlewareStore, -} from '@lib/middleware/types'; +} from '@agent/middleware/types'; export interface DurationData { phaseSnapshots: Array<{ diff --git a/src/lib/middleware/benchmarks/index.ts b/src/agent/middleware/benchmarks/index.ts similarity index 95% rename from src/lib/middleware/benchmarks/index.ts rename to src/agent/middleware/benchmarks/index.ts index 33491a8db..35d672237 100644 --- a/src/lib/middleware/benchmarks/index.ts +++ b/src/agent/middleware/benchmarks/index.ts @@ -8,8 +8,8 @@ import type { Middleware, MiddlewareFactoryOptions, -} from '@lib/middleware/types'; -import type { BenchmarkConfig } from '@lib/middleware/config'; +} from '@agent/middleware/types'; +import type { BenchmarkConfig } from '@agent/middleware/config'; import { TurnCounterPlugin } from './turn-counter'; import { TokenTrackerPlugin } from './token-tracker'; import { CacheTrackerPlugin } from './cache-tracker'; diff --git a/src/lib/middleware/benchmarks/json-writer.ts b/src/agent/middleware/benchmarks/json-writer.ts similarity index 96% rename from src/lib/middleware/benchmarks/json-writer.ts rename to src/agent/middleware/benchmarks/json-writer.ts index a68cad9c6..5c9ab8ad1 100644 --- a/src/lib/middleware/benchmarks/json-writer.ts +++ b/src/agent/middleware/benchmarks/json-writer.ts @@ -6,14 +6,14 @@ */ import fs from 'fs'; -import type { ProgressEmitter } from '@lib/agent/progress'; +import type { ProgressEmitter } from '@agent/progress'; import { logToFile } from '@utils/debug'; -import { AgentSignals } from '@lib/agent/agent-interface'; +import { AgentSignals } from '@agent/agent-interface'; import type { Middleware, MiddlewareContext, MiddlewareStore, -} from '@lib/middleware/types'; +} from '@agent/middleware/types'; import type { TokenData } from './token-tracker'; import type { CacheData } from './cache-tracker'; import type { TurnData } from './turn-counter'; @@ -21,7 +21,7 @@ import type { CostData } from './cost-tracker'; import type { DurationData } from './duration-tracker'; import type { CompactionData } from './compaction-tracker'; import type { ContextSizeData } from './context-size-tracker'; -import type { BenchmarkData, StepUsage } from '@lib/middleware/benchmark'; +import type { BenchmarkData, StepUsage } from '@agent/middleware/benchmark'; /** * Sum token usage across all models from the SDK's modelUsage field. diff --git a/src/lib/middleware/benchmarks/summary.ts b/src/agent/middleware/benchmarks/summary.ts similarity index 96% rename from src/lib/middleware/benchmarks/summary.ts rename to src/agent/middleware/benchmarks/summary.ts index be1369561..0c12a0024 100644 --- a/src/lib/middleware/benchmarks/summary.ts +++ b/src/agent/middleware/benchmarks/summary.ts @@ -1,10 +1,10 @@ -import type { ProgressEmitter, SpinnerHandle } from '@lib/agent/progress'; -import { AgentSignals } from '@lib/agent/agent-interface'; +import type { ProgressEmitter, SpinnerHandle } from '@agent/progress'; +import { AgentSignals } from '@agent/agent-interface'; import type { Middleware, MiddlewareContext, MiddlewareStore, -} from '@lib/middleware/types'; +} from '@agent/middleware/types'; import type { TokenData } from './token-tracker'; import type { TurnData } from './turn-counter'; import type { CostData } from './cost-tracker'; diff --git a/src/lib/middleware/benchmarks/token-tracker.ts b/src/agent/middleware/benchmarks/token-tracker.ts similarity index 98% rename from src/lib/middleware/benchmarks/token-tracker.ts rename to src/agent/middleware/benchmarks/token-tracker.ts index e709bc75b..6a49b1355 100644 --- a/src/lib/middleware/benchmarks/token-tracker.ts +++ b/src/agent/middleware/benchmarks/token-tracker.ts @@ -11,7 +11,7 @@ import type { Middleware, MiddlewareContext, MiddlewareStore, -} from '@lib/middleware/types'; +} from '@agent/middleware/types'; import type { TurnData } from './turn-counter'; export interface TokenData { diff --git a/src/lib/middleware/benchmarks/turn-counter.ts b/src/agent/middleware/benchmarks/turn-counter.ts similarity index 98% rename from src/lib/middleware/benchmarks/turn-counter.ts rename to src/agent/middleware/benchmarks/turn-counter.ts index 0012f8595..293168c06 100644 --- a/src/lib/middleware/benchmarks/turn-counter.ts +++ b/src/agent/middleware/benchmarks/turn-counter.ts @@ -10,7 +10,7 @@ import type { Middleware, MiddlewareContext, MiddlewareStore, -} from '@lib/middleware/types'; +} from '@agent/middleware/types'; export interface TurnData { /** Whether the current message is a duplicate of the last processed turn */ diff --git a/src/lib/middleware/config.ts b/src/agent/middleware/config.ts similarity index 98% rename from src/lib/middleware/config.ts rename to src/agent/middleware/config.ts index 5d45af984..e5d3a912c 100644 --- a/src/lib/middleware/config.ts +++ b/src/agent/middleware/config.ts @@ -8,7 +8,7 @@ import fs from 'fs'; import path from 'path'; import { logToFile } from '@utils/debug'; -import { AgentSignals } from '@lib/agent/agent-interface'; +import { AgentSignals } from '@agent/agent-interface'; import { runtimeEnv } from '@env'; import { WIZARD_BENCHMARK_FILE, WIZARD_LOG_FILE } from '@utils/paths'; diff --git a/src/lib/middleware/index.ts b/src/agent/middleware/index.ts similarity index 100% rename from src/lib/middleware/index.ts rename to src/agent/middleware/index.ts diff --git a/src/lib/middleware/phase-detector.ts b/src/agent/middleware/phase-detector.ts similarity index 100% rename from src/lib/middleware/phase-detector.ts rename to src/agent/middleware/phase-detector.ts diff --git a/src/lib/middleware/pipeline.ts b/src/agent/middleware/pipeline.ts similarity index 100% rename from src/lib/middleware/pipeline.ts rename to src/agent/middleware/pipeline.ts diff --git a/src/lib/middleware/types.ts b/src/agent/middleware/types.ts similarity index 96% rename from src/lib/middleware/types.ts rename to src/agent/middleware/types.ts index 8ccd15ec9..a8fa2aa2e 100644 --- a/src/lib/middleware/types.ts +++ b/src/agent/middleware/types.ts @@ -5,7 +5,7 @@ * and can publish data to a shared store for downstream middleware to read. */ -import type { ProgressEmitter, SpinnerHandle } from '@lib/agent/progress'; +import type { ProgressEmitter, SpinnerHandle } from '@agent/progress'; export type SDKMessage = any; diff --git a/src/lib/agent/output-signals.ts b/src/agent/output-signals.ts similarity index 100% rename from src/lib/agent/output-signals.ts rename to src/agent/output-signals.ts diff --git a/src/lib/agent/progress.ts b/src/agent/progress.ts similarity index 98% rename from src/lib/agent/progress.ts rename to src/agent/progress.ts index df4bd35b4..7fc3e027c 100644 --- a/src/lib/agent/progress.ts +++ b/src/agent/progress.ts @@ -9,7 +9,7 @@ * every existing runner is unchanged. */ -import type { SettingsConflict } from './claude-settings'; +import type { SettingsConflict } from '@shared/claude-settings'; // ── What the agent hands back and asks with ───────────────────────── @@ -46,7 +46,7 @@ export interface OutroData { /** Report file the agent wrote (e.g. "posthog-setup-report.md") */ reportFile?: string; /** Stable machine-readable error code from the error catalog (@lib/errors). */ - errorCode?: import('@lib/errors').ErrorCode; + errorCode?: import('@shared/errors').ErrorCode; /** Structured context for the error code; safe for telemetry payloads. */ errorDetail?: Record; /** PostHog dashboard URL the program created on the user's behalf. */ diff --git a/src/lib/agent/runner/README.md b/src/agent/runner/README.md similarity index 100% rename from src/lib/agent/runner/README.md rename to src/agent/runner/README.md diff --git a/src/lib/agent/runner/__tests__/switchboard.test.ts b/src/agent/runner/__tests__/switchboard.test.ts similarity index 98% rename from src/lib/agent/runner/__tests__/switchboard.test.ts rename to src/agent/runner/__tests__/switchboard.test.ts index 5386fc312..6b4f0e8fd 100644 --- a/src/lib/agent/runner/__tests__/switchboard.test.ts +++ b/src/agent/runner/__tests__/switchboard.test.ts @@ -21,13 +21,13 @@ import { Harness, Sequence, WIZARD_ORCHESTRATOR_FLAG_KEY, -} from '@lib/constants'; +} from '@shared/constants'; import { PROGRAM_BINDINGS, DEFAULT_BINDING, resolveBinding, type SwitchboardCtx, -} from '@lib/agent/runner/switchboard'; +} from '@agent/runner/switchboard'; import { modelCapabilities, MINT_ALLOWED_EFFORTS, @@ -35,8 +35,8 @@ import { requireKnownModel, TRIAGE_MODELS, VALID_MODELS, -} from '@lib/agent/runner/switchboard/models'; -import { runBindingCases } from '@lib/agent/runner/switchboard/flags/__tests__/binding-cases'; +} from '@agent/runner/switchboard/models'; +import { runBindingCases } from '@agent/runner/switchboard/flags/__tests__/binding-cases'; const PROGRAM_IDS = PROGRAM_REGISTRY.map((c) => c.id); const DEFAULT_RESOLVED = { diff --git a/src/lib/agent/runner/harness/agents-platform/README.md b/src/agent/runner/harness/agents-platform/README.md similarity index 100% rename from src/lib/agent/runner/harness/agents-platform/README.md rename to src/agent/runner/harness/agents-platform/README.md diff --git a/src/lib/agent/runner/harness/anthropic/README.md b/src/agent/runner/harness/anthropic/README.md similarity index 100% rename from src/lib/agent/runner/harness/anthropic/README.md rename to src/agent/runner/harness/anthropic/README.md diff --git a/src/lib/agent/runner/harness/anthropic/__tests__/pending-question.test.ts b/src/agent/runner/harness/anthropic/__tests__/pending-question.test.ts similarity index 93% rename from src/lib/agent/runner/harness/anthropic/__tests__/pending-question.test.ts rename to src/agent/runner/harness/anthropic/__tests__/pending-question.test.ts index 966cbcb9d..86ff59c3f 100644 --- a/src/lib/agent/runner/harness/anthropic/__tests__/pending-question.test.ts +++ b/src/agent/runner/harness/anthropic/__tests__/pending-question.test.ts @@ -1,16 +1,16 @@ -import { initializeAgent, wizardCanUseTool } from '@lib/agent/agent-interface'; +import { initializeAgent, wizardCanUseTool } from '@agent/agent-interface'; import { createAskBridge } from '../../../shared/ask'; import { anthropicBackend } from '..'; import type { BackendRunInputs, TaskRunInputs } from '../../types'; import type { AskAnswers } from '@lib/wizard-session'; -import { Harness, Sequence } from '@lib/constants'; -import { HostResolution } from '@lib/host-resolution'; +import { Harness, Sequence } from '@shared/constants'; +import { HostResolution } from '@shared/host-resolution'; vi.mock('@utils/analytics'); vi.mock('@utils/debug'); -vi.mock('@lib/agent/aio-capture', () => ({ createAioCapture: vi.fn() })); -vi.mock('@lib/agent/agent-interface', async (original) => ({ - ...(await original()), +vi.mock('@agent/aio-capture', () => ({ createAioCapture: vi.fn() })); +vi.mock('@agent/agent-interface', async (original) => ({ + ...(await original()), initializeAgent: vi.fn().mockResolvedValue({}), runAgent: vi.fn().mockResolvedValue({}), })); diff --git a/src/lib/agent/runner/harness/anthropic/index.ts b/src/agent/runner/harness/anthropic/index.ts similarity index 94% rename from src/lib/agent/runner/harness/anthropic/index.ts rename to src/agent/runner/harness/anthropic/index.ts index 1b967a662..74a051420 100644 --- a/src/lib/agent/runner/harness/anthropic/index.ts +++ b/src/agent/runner/harness/anthropic/index.ts @@ -1,15 +1,15 @@ // Supported legacy SDK fallback; both this adapter and Pi implement run and runTask. -import { Harness } from '@lib/constants'; +import { Harness } from '@shared/constants'; import { initializeAgent, runAgent as executeAgent, -} from '@lib/agent/agent-interface'; -import { createAioCapture } from '@lib/agent/aio-capture'; +} from '@agent/agent-interface'; +import { createAioCapture } from '@agent/aio-capture'; import { getLogFilePath, logToFile } from '@utils/debug'; import { detectNodePackageManagers } from '@utils/package-manager'; -import { runOptions } from '@lib/agent/runner/shared/bootstrap'; -import { createEmitLog } from '@lib/agent/runner/shared/progress-collector'; +import { runOptions } from '@agent/runner/shared/bootstrap'; +import { createEmitLog } from '@agent/runner/shared/progress-collector'; import type { AgentResult, AgentHarness, diff --git a/src/lib/agent/runner/harness/pi/README.md b/src/agent/runner/harness/pi/README.md similarity index 100% rename from src/lib/agent/runner/harness/pi/README.md rename to src/agent/runner/harness/pi/README.md diff --git a/src/lib/agent/runner/harness/pi/__tests__/completion.test.ts b/src/agent/runner/harness/pi/__tests__/completion.test.ts similarity index 97% rename from src/lib/agent/runner/harness/pi/__tests__/completion.test.ts rename to src/agent/runner/harness/pi/__tests__/completion.test.ts index a378c2d6d..f451bcc41 100644 --- a/src/lib/agent/runner/harness/pi/__tests__/completion.test.ts +++ b/src/agent/runner/harness/pi/__tests__/completion.test.ts @@ -1,5 +1,5 @@ import { completionFailure, runErrorType } from '../completion'; -import { AgentErrorType } from '@lib/agent/signals'; +import { AgentErrorType } from '@agent/signals'; describe('completionFailure', () => { it('fails a no-op run (zero tool calls) as NO_PROGRESS', () => { diff --git a/src/lib/agent/runner/harness/pi/__tests__/env-lockdown.test.ts b/src/agent/runner/harness/pi/__tests__/env-lockdown.test.ts similarity index 100% rename from src/lib/agent/runner/harness/pi/__tests__/env-lockdown.test.ts rename to src/agent/runner/harness/pi/__tests__/env-lockdown.test.ts diff --git a/src/lib/agent/runner/harness/pi/__tests__/gateway.test.ts b/src/agent/runner/harness/pi/__tests__/gateway.test.ts similarity index 99% rename from src/lib/agent/runner/harness/pi/__tests__/gateway.test.ts rename to src/agent/runner/harness/pi/__tests__/gateway.test.ts index c68420193..cfedba108 100644 --- a/src/lib/agent/runner/harness/pi/__tests__/gateway.test.ts +++ b/src/agent/runner/harness/pi/__tests__/gateway.test.ts @@ -5,7 +5,7 @@ import { withGatewayRemint, GATEWAY_PROVIDER, } from '../gateway'; -import type { GatewayAuth } from '@lib/gateway-session'; +import type { GatewayAuth } from '@agent/gateway-session'; describe('buildGatewayProvider effort', () => { const base = { diff --git a/src/lib/agent/runner/harness/pi/__tests__/security.test.ts b/src/agent/runner/harness/pi/__tests__/security.test.ts similarity index 100% rename from src/lib/agent/runner/harness/pi/__tests__/security.test.ts rename to src/agent/runner/harness/pi/__tests__/security.test.ts diff --git a/src/lib/agent/runner/harness/pi/__tests__/status-line.test.ts b/src/agent/runner/harness/pi/__tests__/status-line.test.ts similarity index 96% rename from src/lib/agent/runner/harness/pi/__tests__/status-line.test.ts rename to src/agent/runner/harness/pi/__tests__/status-line.test.ts index b2920ab18..f7db0f8d2 100644 --- a/src/lib/agent/runner/harness/pi/__tests__/status-line.test.ts +++ b/src/agent/runner/harness/pi/__tests__/status-line.test.ts @@ -5,7 +5,7 @@ */ import { describe, it, expect } from 'vitest'; -import { AgentSignals } from '@lib/agent/signals'; +import { AgentSignals } from '@agent/signals'; import { lastStatusLine } from '..'; const S = AgentSignals.STATUS; // '[STATUS]' diff --git a/src/lib/agent/runner/harness/pi/__tests__/task-tools.test.ts b/src/agent/runner/harness/pi/__tests__/task-tools.test.ts similarity index 100% rename from src/lib/agent/runner/harness/pi/__tests__/task-tools.test.ts rename to src/agent/runner/harness/pi/__tests__/task-tools.test.ts diff --git a/src/lib/agent/runner/harness/pi/__tests__/tools.test.ts b/src/agent/runner/harness/pi/__tests__/tools.test.ts similarity index 99% rename from src/lib/agent/runner/harness/pi/__tests__/tools.test.ts rename to src/agent/runner/harness/pi/__tests__/tools.test.ts index 0156a0cd5..0fa075634 100644 --- a/src/lib/agent/runner/harness/pi/__tests__/tools.test.ts +++ b/src/agent/runner/harness/pi/__tests__/tools.test.ts @@ -12,7 +12,7 @@ import { describe, it, expect, vi } from 'vitest'; import { CANCELLED_SENTINEL, type WizardAskBridge, -} from '@lib/wizard-ask-bridge'; +} from '@agent/wizard-ask-bridge'; import { createWizardPiTools } from '../tools'; import { evaluateToolCall } from '../security'; import { allowedPiCodingTools, allowedOrchestratorTools } from '../task'; @@ -25,7 +25,7 @@ import { WIZARD_ASK_SENSITIVE_DESCRIPTION, WIZARD_ASK_SUBJECT_DESCRIPTION, WIZARD_ASK_TOOL_DESCRIPTION, -} from '@lib/wizard-tools/tools'; +} from '@agent/tools/tools'; const SECRET = 'phx_live_zendesk_token_123'; diff --git a/src/lib/agent/runner/harness/pi/completion.ts b/src/agent/runner/harness/pi/completion.ts similarity index 95% rename from src/lib/agent/runner/harness/pi/completion.ts rename to src/agent/runner/harness/pi/completion.ts index 3d4c9d606..8219e5c46 100644 --- a/src/lib/agent/runner/harness/pi/completion.ts +++ b/src/agent/runner/harness/pi/completion.ts @@ -1,4 +1,4 @@ -import { AgentErrorType } from '@lib/agent/signals'; +import { AgentErrorType } from '@agent/signals'; /** Which completion guard should fail a pi run, or undefined for a clean finish. */ export function completionFailure(args: { diff --git a/src/lib/agent/runner/harness/pi/gateway.ts b/src/agent/runner/harness/pi/gateway.ts similarity index 99% rename from src/lib/agent/runner/harness/pi/gateway.ts rename to src/agent/runner/harness/pi/gateway.ts index c827bcfcb..9c6a6d6c7 100644 --- a/src/lib/agent/runner/harness/pi/gateway.ts +++ b/src/agent/runner/harness/pi/gateway.ts @@ -10,7 +10,7 @@ import { buildWizardPropertiesBlob, isPastRefresh, type GatewayAuth, -} from '@lib/gateway-session'; +} from '@agent/gateway-session'; import { modelCapabilities, type ThinkingLevel, diff --git a/src/lib/agent/runner/harness/pi/index.ts b/src/agent/runner/harness/pi/index.ts similarity index 97% rename from src/lib/agent/runner/harness/pi/index.ts rename to src/agent/runner/harness/pi/index.ts index b14df2a37..ec903a4e9 100644 --- a/src/lib/agent/runner/harness/pi/index.ts +++ b/src/agent/runner/harness/pi/index.ts @@ -20,28 +20,28 @@ import { Sequence, WIZARD_REMARK_EVENT_NAME, WIZARD_USER_AGENT, -} from '@lib/constants'; +} from '@shared/constants'; import { analytics } from '@utils/analytics'; -import { AgentErrorType } from '@lib/agent/agent-interface'; -import { AgentSignals, REMARK_INSTRUCTION } from '@lib/agent/signals'; -import { AgentOutputSignals } from '@lib/agent/output-signals'; +import { AgentErrorType } from '@agent/agent-interface'; +import { AgentSignals, REMARK_INSTRUCTION } from '@agent/signals'; +import { AgentOutputSignals } from '@agent/output-signals'; import { assembleCommandments } from '../../switchboard/commandments'; -import { gatewayAuth, type GatewayAuth } from '@lib/gateway-session'; +import { gatewayAuth, type GatewayAuth } from '@agent/gateway-session'; import { buildGatewayProvider, GATEWAY_PROVIDER, withGatewayRemint, } from './gateway'; -import { createAioCapture } from '@lib/agent/aio-capture'; +import { createAioCapture } from '@agent/aio-capture'; import type { AgentResult, AgentHarness, BackendRunInputs, TaskRunInputs, } from '../types'; -import type { BootstrapResult } from '@lib/agent/runner/shared/types'; -import type { ProgressEmitter } from '@lib/agent/progress'; -import { createEmitLog } from '@lib/agent/runner/shared/progress-collector'; +import type { BootstrapResult } from '@agent/runner/shared/types'; +import type { ProgressEmitter } from '@agent/progress'; +import { createEmitLog } from '@agent/runner/shared/progress-collector'; import type { TaskStore } from './tasks'; import { completionFailure, runErrorType } from './completion'; @@ -327,7 +327,7 @@ export const piBackend: AgentHarness = { // Pay warlock's WASM-init + rule-compile cost now, off the tool-call // path, so the first scanned call doesn't eat cold-start latency. - const { prewarmYaraScanner } = await import('@lib/yara-hooks'); + const { prewarmYaraScanner } = await import('@agent/yara-hooks'); void prewarmYaraScanner(); // Wire the real PostHog MCP into pi (#10): load pi's MCP adapter and point diff --git a/src/lib/agent/runner/harness/pi/mcp.ts b/src/agent/runner/harness/pi/mcp.ts similarity index 98% rename from src/lib/agent/runner/harness/pi/mcp.ts rename to src/agent/runner/harness/pi/mcp.ts index eeaa3607a..8f553a983 100644 --- a/src/lib/agent/runner/harness/pi/mcp.ts +++ b/src/agent/runner/harness/pi/mcp.ts @@ -7,7 +7,7 @@ import { Client } from '@modelcontextprotocol/sdk/client/index.js'; import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'; import { createJiti } from 'jiti'; -import { VERSION } from '@lib/version'; +import { VERSION } from '@shared/version'; import { logToFile } from '@utils/debug'; const MCP_TOKEN_ENV = 'POSTHOG_MCP_TOKEN'; diff --git a/src/lib/agent/runner/harness/pi/orchestrator-tools.ts b/src/agent/runner/harness/pi/orchestrator-tools.ts similarity index 100% rename from src/lib/agent/runner/harness/pi/orchestrator-tools.ts rename to src/agent/runner/harness/pi/orchestrator-tools.ts diff --git a/src/lib/agent/runner/harness/pi/runtime-notes.ts b/src/agent/runner/harness/pi/runtime-notes.ts similarity index 99% rename from src/lib/agent/runner/harness/pi/runtime-notes.ts rename to src/agent/runner/harness/pi/runtime-notes.ts index 5350d72ab..e67f4fadc 100644 --- a/src/lib/agent/runner/harness/pi/runtime-notes.ts +++ b/src/agent/runner/harness/pi/runtime-notes.ts @@ -12,7 +12,7 @@ * resolved sequence calls for — shared notes always, mode notes by sequence, and * capability notes only when the task actually holds that tool. */ -import { Sequence } from '@lib/constants'; +import { Sequence } from '@shared/constants'; const HEADER = [ '## This runtime', diff --git a/src/lib/agent/runner/harness/pi/security.ts b/src/agent/runner/harness/pi/security.ts similarity index 99% rename from src/lib/agent/runner/harness/pi/security.ts rename to src/agent/runner/harness/pi/security.ts index 0ff5c811c..ffb399712 100644 --- a/src/lib/agent/runner/harness/pi/security.ts +++ b/src/agent/runner/harness/pi/security.ts @@ -20,7 +20,7 @@ import fs from 'fs'; import path from 'path'; import type { LLMProvider, ScanMatch } from '@posthog/warlock'; -import { wizardCanUseTool } from '@lib/agent/agent-interface'; +import { wizardCanUseTool } from '@agent/agent-interface'; import { createRepeatBlockTracker, isWizardDocumentationPath, @@ -28,12 +28,12 @@ import { repeatBlockReason, scanAndTriage, type RepeatBlockTracker, -} from '@lib/yara-hooks'; +} from '@agent/yara-hooks'; import { publishBlockingMatch, scanVerdict, type ScanContext, -} from '@lib/yara-policy'; +} from '@agent/yara-policy'; import { logToFile } from '@utils/debug'; import { analytics } from '@utils/analytics'; diff --git a/src/lib/agent/runner/harness/pi/subagent.ts b/src/agent/runner/harness/pi/subagent.ts similarity index 100% rename from src/lib/agent/runner/harness/pi/subagent.ts rename to src/agent/runner/harness/pi/subagent.ts diff --git a/src/lib/agent/runner/harness/pi/task.ts b/src/agent/runner/harness/pi/task.ts similarity index 97% rename from src/lib/agent/runner/harness/pi/task.ts rename to src/agent/runner/harness/pi/task.ts index af9017a21..76db7a43a 100644 --- a/src/lib/agent/runner/harness/pi/task.ts +++ b/src/agent/runner/harness/pi/task.ts @@ -23,19 +23,19 @@ import { Sequence, WIZARD_REMARK_EVENT_NAME, WIZARD_USER_AGENT, -} from '@lib/constants'; +} from '@shared/constants'; import { allowsPostHogMcp, queueTools, renderToolInventory, -} from '@lib/agent/agent-prompt-loader'; -import { AgentErrorType } from '@lib/agent/agent-interface'; -import { REMARK_INSTRUCTION } from '@lib/agent/signals'; -import { AgentOutputSignals } from '@lib/agent/output-signals'; +} from '@agent/agent-prompt-loader'; +import { AgentErrorType } from '@agent/agent-interface'; +import { REMARK_INSTRUCTION } from '@agent/signals'; +import { AgentOutputSignals } from '@agent/output-signals'; import { TaskStatus } from '../../sequence/orchestrator/queue'; import type { OrchestratorToolsContext } from '../../sequence/orchestrator/queue-tools'; import type { AgentResult, TaskRunInputs } from '../types'; -import { gatewayAuth, type GatewayAuth } from '@lib/gateway-session'; +import { gatewayAuth, type GatewayAuth } from '@agent/gateway-session'; import { buildGatewayProvider, GATEWAY_PROVIDER, @@ -50,7 +50,7 @@ import { lastStatusLine, withMode, } from './index'; -import { createAioCapture } from '@lib/agent/aio-capture'; +import { createAioCapture } from '@agent/aio-capture'; /** wizard tool vocabulary → the pi tool definitions it unlocks. */ const CODING_TOOL_MAP: Record = { @@ -282,7 +282,7 @@ export async function runPiTask(inputs: TaskRunInputs): Promise { triageProvider: boot.triageProvider, getWizardAskPending: () => askState.pending, }); - const { prewarmYaraScanner } = await import('@lib/yara-hooks'); + const { prewarmYaraScanner } = await import('@agent/yara-hooks'); void prewarmYaraScanner(); // PostHog MCP, for the tasks whose prompt requests it. Tasks that never diff --git a/src/lib/agent/runner/harness/pi/tasks.ts b/src/agent/runner/harness/pi/tasks.ts similarity index 98% rename from src/lib/agent/runner/harness/pi/tasks.ts rename to src/agent/runner/harness/pi/tasks.ts index 0ee0f4462..61025abb6 100644 --- a/src/lib/agent/runner/harness/pi/tasks.ts +++ b/src/agent/runner/harness/pi/tasks.ts @@ -9,7 +9,7 @@ import { Type } from 'typebox'; import { defineTool } from '@earendil-works/pi-coding-agent'; import type { ToolDefinition } from '@earendil-works/pi-coding-agent'; -import type { TaskSnapshot } from '@lib/agent/progress'; +import type { TaskSnapshot } from '@agent/progress'; export type TaskStatus = 'pending' | 'in_progress' | 'completed'; export interface TaskEntry { diff --git a/src/lib/agent/runner/harness/pi/tools.ts b/src/agent/runner/harness/pi/tools.ts similarity index 98% rename from src/lib/agent/runner/harness/pi/tools.ts rename to src/agent/runner/harness/pi/tools.ts index 753e8c5df..420f7e96f 100644 --- a/src/lib/agent/runner/harness/pi/tools.ts +++ b/src/agent/runner/harness/pi/tools.ts @@ -53,22 +53,25 @@ import { WIZARD_ASK_SENSITIVE_DESCRIPTION, WIZARD_ASK_SUBJECT_DESCRIPTION, WIZARD_ASK_TOOL_DESCRIPTION, -} from '@lib/wizard-tools/tools'; +} from '@agent/tools/tools'; import type { LLMProvider } from '@posthog/warlock'; -import type { ProgressEmitter } from '@lib/agent/progress'; -import { isFullyCancelled, type WizardAskBridge } from '@lib/wizard-ask-bridge'; +import type { ProgressEmitter } from '@agent/progress'; +import { + isFullyCancelled, + type WizardAskBridge, +} from '@agent/wizard-ask-bridge'; import { PUBLISH_HANDOFF_CONTENT_DESCRIPTION, PUBLISH_HANDOFF_DESCRIPTION, PUBLISH_HANDOFF_TOOL_NAME, publishHandoff, -} from '@lib/wizard-tools/handoff'; -import { createSecretVault } from '@lib/secret-vault'; +} from '@agent/tools/handoff'; +import { createSecretVault } from '@shared/secret-vault'; import { AUDIT_CHECKS_FILE, type AuditCheck, type AuditStatus, -} from '@lib/audit-ledger'; +} from '@shared/audit-ledger'; import { makeMutex } from '@utils/atomic-ledger'; import { withMode } from './index'; import { diff --git a/src/lib/agent/runner/harness/types.ts b/src/agent/runner/harness/types.ts similarity index 91% rename from src/lib/agent/runner/harness/types.ts rename to src/agent/runner/harness/types.ts index cff145347..80d4786c8 100644 --- a/src/lib/agent/runner/harness/types.ts +++ b/src/agent/runner/harness/types.ts @@ -19,22 +19,22 @@ * the run's result. */ -import type { AdditionalFeature } from '@lib/constants'; -import type { Harness } from '@lib/constants'; -import type { WizardAskBridge } from '@lib/wizard-ask-bridge'; -import type { AgentErrorType } from '@lib/agent/agent-interface'; -import type { ProgressEmitter, SpinnerHandle } from '@lib/agent/progress'; -import type { OrchestratorToolsContext } from '@lib/agent/runner/sequence/orchestrator/queue-tools'; +import type { AdditionalFeature } from '@shared/constants'; +import type { Harness } from '@shared/constants'; +import type { WizardAskBridge } from '@agent/wizard-ask-bridge'; +import type { AgentErrorType } from '@agent/agent-interface'; +import type { ProgressEmitter, SpinnerHandle } from '@agent/progress'; +import type { OrchestratorToolsContext } from '@agent/runner/sequence/orchestrator/queue-tools'; import type { EffortLevel, ThinkingLevel, -} from '@lib/agent/runner/switchboard/models'; +} from '@agent/runner/switchboard/models'; import type { AgentFailure, BootstrapResult, RunConfig, RunInput, -} from '@lib/agent/runner/shared/types'; +} from '@agent/runner/shared/types'; /** The benchmark/telemetry hook threaded through a run, if enabled. */ export interface RunMiddleware { diff --git a/src/lib/agent/runner/index.ts b/src/agent/runner/index.ts similarity index 96% rename from src/lib/agent/runner/index.ts rename to src/agent/runner/index.ts index 6f2321001..93de08427 100644 --- a/src/lib/agent/runner/index.ts +++ b/src/agent/runner/index.ts @@ -23,10 +23,10 @@ * behavior on top of this call for every existing caller. */ -import { Sequence } from '@lib/constants'; +import { Sequence } from '@shared/constants'; import { RunOutcome } from './shared/types'; export { RunOutcome } from './shared/types'; -import { classifyRunFailure } from '@lib/errors'; +import { classifyRunFailure } from '@shared/errors'; import { logToFile } from '@utils/debug'; import type { RunAgentOptions, @@ -37,7 +37,7 @@ import type { import { prepareRun } from './shared/bootstrap'; import { createProgressCollector } from './shared/progress-collector'; import { getSequence } from './switchboard'; -import { flushScanReport } from '../../yara-hooks'; +import { flushScanReport } from '@agent/yara-hooks'; export type { AbortCase, @@ -60,7 +60,7 @@ export type { AgentInteraction, AgentProgress, ProgressEmitter, -} from '@lib/agent/progress'; +} from '@agent/progress'; export { shouldDisableAsk } from './shared/bootstrap'; export { resolveBinding } from './switchboard'; export type { ProgramBinding, SwitchboardCtx } from './switchboard'; diff --git a/src/lib/agent/runner/sequence/README.md b/src/agent/runner/sequence/README.md similarity index 100% rename from src/lib/agent/runner/sequence/README.md rename to src/agent/runner/sequence/README.md diff --git a/src/lib/agent/runner/sequence/linear.ts b/src/agent/runner/sequence/linear.ts similarity index 95% rename from src/lib/agent/runner/sequence/linear.ts rename to src/agent/runner/sequence/linear.ts index 8afbe8ef9..7af34d37f 100644 --- a/src/lib/agent/runner/sequence/linear.ts +++ b/src/agent/runner/sequence/linear.ts @@ -10,14 +10,14 @@ * arguments, so the caller's exit sequence is unchanged. */ -import { OutroKind, type OutroData } from '@lib/agent/progress'; +import { OutroKind, type OutroData } from '@agent/progress'; import { AgentErrorType, AgentSignals } from '../../agent-interface'; -import { logToFile } from '../../../../utils/debug'; -import { createBenchmarkPipeline } from '../../../middleware/benchmark'; -import { AGENT_ERROR_CODE, ErrorCodes, WizardError } from '@lib/errors'; -import { analytics } from '../../../../utils/analytics'; -import { formatYaraAbortMessage } from '../../../yara-hooks'; -import { installSkillById } from '../../../wizard-tools'; +import { logToFile } from '@utils/debug'; +import { createBenchmarkPipeline } from '@agent/middleware/benchmark'; +import { AGENT_ERROR_CODE, ErrorCodes, WizardError } from '@shared/errors'; +import { analytics } from '@utils/analytics'; +import { formatYaraAbortMessage } from '@agent/yara-hooks'; +import { installSkillById } from '@agent/tools'; import { assemblePrompt } from '../../agent-prompt'; import type { SequenceResult, SequenceContext } from '../shared/types'; import { failed, installFailure } from '../shared/errors'; diff --git a/src/lib/agent/runner/sequence/orchestrator/__tests__/completed-seeded-types.test.ts b/src/agent/runner/sequence/orchestrator/__tests__/completed-seeded-types.test.ts similarity index 93% rename from src/lib/agent/runner/sequence/orchestrator/__tests__/completed-seeded-types.test.ts rename to src/agent/runner/sequence/orchestrator/__tests__/completed-seeded-types.test.ts index 49e60ce34..fa3446a38 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/completed-seeded-types.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/completed-seeded-types.test.ts @@ -16,8 +16,8 @@ vi.mock('@utils/analytics', () => ({ import { QueueStore, SkipReason, -} from '@lib/agent/runner/sequence/orchestrator/queue'; -import { completedSeededTypes } from '@lib/agent/runner/sequence/orchestrator/orchestrator-runner'; +} from '@agent/runner/sequence/orchestrator/queue'; +import { completedSeededTypes } from '@agent/runner/sequence/orchestrator/orchestrator-runner'; describe('completedSeededTypes', () => { let dir: string; diff --git a/src/lib/agent/runner/sequence/orchestrator/__tests__/excluded-task-types.test.ts b/src/agent/runner/sequence/orchestrator/__tests__/excluded-task-types.test.ts similarity index 94% rename from src/lib/agent/runner/sequence/orchestrator/__tests__/excluded-task-types.test.ts rename to src/agent/runner/sequence/orchestrator/__tests__/excluded-task-types.test.ts index 02240e173..5187ae500 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/excluded-task-types.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/excluded-task-types.test.ts @@ -5,7 +5,7 @@ * red — the mapping test alone cannot see that. */ -import { WIZARD_DEFAULT_AIO_LOGS_FLAG_KEY } from '@lib/constants'; +import { WIZARD_DEFAULT_AIO_LOGS_FLAG_KEY } from '@shared/constants'; import { posthogIntegrationConfig } from '@lib/programs/posthog-integration/index'; import { effectiveExcludedTaskTypes } from '../orchestrator-runner'; diff --git a/src/lib/agent/runner/sequence/orchestrator/__tests__/executor.test.ts b/src/agent/runner/sequence/orchestrator/__tests__/executor.test.ts similarity index 98% rename from src/lib/agent/runner/sequence/orchestrator/__tests__/executor.test.ts rename to src/agent/runner/sequence/orchestrator/__tests__/executor.test.ts index c76f75e86..a5236f1f5 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/executor.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/executor.test.ts @@ -6,12 +6,12 @@ import { TaskStatus, type QueuedTask, type TaskHandoff, -} from '@lib/agent/runner/sequence/orchestrator/queue'; +} from '@agent/runner/sequence/orchestrator/queue'; import { drainQueue, RunTaskFatal, type RunTask, -} from '@lib/agent/runner/sequence/orchestrator/executor'; +} from '@agent/runner/sequence/orchestrator/executor'; vi.mock('@utils/analytics', () => ({ analytics: { captureException: vi.fn(), wizardCapture: vi.fn() }, diff --git a/src/lib/agent/runner/sequence/orchestrator/__tests__/handoff-schema-parity.test.ts b/src/agent/runner/sequence/orchestrator/__tests__/handoff-schema-parity.test.ts similarity index 100% rename from src/lib/agent/runner/sequence/orchestrator/__tests__/handoff-schema-parity.test.ts rename to src/agent/runner/sequence/orchestrator/__tests__/handoff-schema-parity.test.ts diff --git a/src/lib/agent/runner/sequence/orchestrator/__tests__/optional-tasks.test.ts b/src/agent/runner/sequence/orchestrator/__tests__/optional-tasks.test.ts similarity index 95% rename from src/lib/agent/runner/sequence/orchestrator/__tests__/optional-tasks.test.ts rename to src/agent/runner/sequence/orchestrator/__tests__/optional-tasks.test.ts index 1e4e2d7f4..c44157dd6 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/optional-tasks.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/optional-tasks.test.ts @@ -7,11 +7,11 @@ vi.mock('@utils/analytics', () => ({ analytics: { wizardCapture: vi.fn(), captureException: vi.fn() }, })); -import { QueueStore } from '@lib/agent/runner/sequence/orchestrator/queue'; +import { QueueStore } from '@agent/runner/sequence/orchestrator/queue'; import { describeDrainFailure, drainVerdict, -} from '@lib/agent/runner/sequence/orchestrator/orchestrator-runner'; +} from '@agent/runner/sequence/orchestrator/orchestrator-runner'; describe('drainVerdict', () => { let dir: string; diff --git a/src/lib/agent/runner/sequence/orchestrator/__tests__/queue-tools.test.ts b/src/agent/runner/sequence/orchestrator/__tests__/queue-tools.test.ts similarity index 97% rename from src/lib/agent/runner/sequence/orchestrator/__tests__/queue-tools.test.ts rename to src/agent/runner/sequence/orchestrator/__tests__/queue-tools.test.ts index fb9f38311..35a191272 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/queue-tools.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/queue-tools.test.ts @@ -7,7 +7,7 @@ import { NotNeededReason, QueueStore, SkipReason, -} from '@lib/agent/runner/sequence/orchestrator/queue'; +} from '@agent/runner/sequence/orchestrator/queue'; vi.mock('@utils/analytics', () => ({ analytics: { wizardCapture: vi.fn() }, @@ -22,12 +22,9 @@ import { ENQUEUE_MODEL_DESCRIPTION, NOT_NEEDED_REASON_ASK, type OrchestratorToolsContext, -} from '@lib/agent/runner/sequence/orchestrator/queue-tools'; -import { PI_COMPLETE_PARAM_KEYS } from '@lib/agent/runner/harness/pi/orchestrator-tools'; -import { - isValidModel, - VALID_MODELS, -} from '@lib/agent/runner/switchboard/models'; +} from '@agent/runner/sequence/orchestrator/queue-tools'; +import { PI_COMPLETE_PARAM_KEYS } from '@agent/runner/harness/pi/orchestrator-tools'; +import { isValidModel, VALID_MODELS } from '@agent/runner/switchboard/models'; function tmpDir(): string { return fs.mkdtempSync(path.join(os.tmpdir(), 'queue-tools-test-')); diff --git a/src/lib/agent/runner/sequence/orchestrator/__tests__/queue.test.ts b/src/agent/runner/sequence/orchestrator/__tests__/queue.test.ts similarity index 99% rename from src/lib/agent/runner/sequence/orchestrator/__tests__/queue.test.ts rename to src/agent/runner/sequence/orchestrator/__tests__/queue.test.ts index cb306ef5b..6d7fab6c5 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/queue.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/queue.test.ts @@ -11,7 +11,7 @@ import { type QueuedTask, type TaskHandoff, type TransitionEvent, -} from '@lib/agent/runner/sequence/orchestrator/queue'; +} from '@agent/runner/sequence/orchestrator/queue'; vi.mock('@utils/analytics', () => ({ analytics: { captureException: vi.fn(), wizardCapture: vi.fn() }, diff --git a/src/lib/agent/runner/sequence/orchestrator/__tests__/run-metrics.test.ts b/src/agent/runner/sequence/orchestrator/__tests__/run-metrics.test.ts similarity index 97% rename from src/lib/agent/runner/sequence/orchestrator/__tests__/run-metrics.test.ts rename to src/agent/runner/sequence/orchestrator/__tests__/run-metrics.test.ts index da82af353..d86f9257c 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/run-metrics.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/run-metrics.test.ts @@ -1,4 +1,4 @@ -import { RunMetrics } from '@lib/agent/runner/sequence/orchestrator/run-metrics'; +import { RunMetrics } from '@agent/runner/sequence/orchestrator/run-metrics'; describe('RunMetrics', () => { it('reports time to first start and first completion from run start', () => { diff --git a/src/lib/agent/runner/sequence/orchestrator/__tests__/seeded-decline-skip.test.ts b/src/agent/runner/sequence/orchestrator/__tests__/seeded-decline-skip.test.ts similarity index 96% rename from src/lib/agent/runner/sequence/orchestrator/__tests__/seeded-decline-skip.test.ts rename to src/agent/runner/sequence/orchestrator/__tests__/seeded-decline-skip.test.ts index 9ee3fca2a..611543afc 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/seeded-decline-skip.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/seeded-decline-skip.test.ts @@ -22,14 +22,14 @@ vi.mock('@utils/analytics', () => ({ import { skipDeclinedSeededTasks, type SeededConsent, -} from '@lib/agent/runner/sequence/orchestrator/orchestrator-runner'; +} from '@agent/runner/sequence/orchestrator/orchestrator-runner'; import { QueueStore, SkipReason, TaskStatus, type TransitionEvent, type QueuedTask, -} from '@lib/agent/runner/sequence/orchestrator/queue'; +} from '@agent/runner/sequence/orchestrator/queue'; const KEPT: SeededConsent = { keep: true, timedOut: false, errored: false }; const DECLINED: SeededConsent = { diff --git a/src/lib/agent/runner/sequence/orchestrator/__tests__/seeded-deps.test.ts b/src/agent/runner/sequence/orchestrator/__tests__/seeded-deps.test.ts similarity index 99% rename from src/lib/agent/runner/sequence/orchestrator/__tests__/seeded-deps.test.ts rename to src/agent/runner/sequence/orchestrator/__tests__/seeded-deps.test.ts index 2a3069188..c12548838 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/seeded-deps.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/seeded-deps.test.ts @@ -17,11 +17,11 @@ vi.mock('@utils/analytics', () => ({ import { QueueStore, type QueuedTask, -} from '@lib/agent/runner/sequence/orchestrator/queue'; +} from '@agent/runner/sequence/orchestrator/queue'; import { deferSeededTasks, seededDependencies, -} from '@lib/agent/runner/sequence/orchestrator/seeded-deps'; +} from '@agent/runner/sequence/orchestrator/seeded-deps'; const SINKS = ['report']; diff --git a/src/lib/agent/runner/sequence/orchestrator/__tests__/sink-closure.test.ts b/src/agent/runner/sequence/orchestrator/__tests__/sink-closure.test.ts similarity index 98% rename from src/lib/agent/runner/sequence/orchestrator/__tests__/sink-closure.test.ts rename to src/agent/runner/sequence/orchestrator/__tests__/sink-closure.test.ts index 9372bfc1d..4b7cb6b28 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/sink-closure.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/sink-closure.test.ts @@ -14,16 +14,16 @@ vi.mock('@utils/analytics', () => ({ import { QueueStore, SkipReason, -} from '@lib/agent/runner/sequence/orchestrator/queue'; -import { displayOrder } from '@lib/agent/runner/sequence/orchestrator/orchestrator-runner'; +} from '@agent/runner/sequence/orchestrator/queue'; +import { displayOrder } from '@agent/runner/sequence/orchestrator/orchestrator-runner'; import { applyEnqueue, checkEnqueueGuards, dependencyClosure, uncoveredBySink, type OrchestratorToolsContext, -} from '@lib/agent/runner/sequence/orchestrator/queue-tools'; -import { seededDependencies } from '@lib/agent/runner/sequence/orchestrator/seeded-deps'; +} from '@agent/runner/sequence/orchestrator/queue-tools'; +import { seededDependencies } from '@agent/runner/sequence/orchestrator/seeded-deps'; const VALID = ['warehouse', 'install', 'capture', 'report']; const SINKS = ['report']; diff --git a/src/lib/agent/runner/sequence/orchestrator/__tests__/skill-sweep.test.ts b/src/agent/runner/sequence/orchestrator/__tests__/skill-sweep.test.ts similarity index 98% rename from src/lib/agent/runner/sequence/orchestrator/__tests__/skill-sweep.test.ts rename to src/agent/runner/sequence/orchestrator/__tests__/skill-sweep.test.ts index 6a04c2ab8..fc26b1482 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/skill-sweep.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/skill-sweep.test.ts @@ -4,7 +4,7 @@ import * as path from 'path'; import { promoteReferenceSkill, sweepRunInstalledSkills, -} from '@lib/agent/runner/sequence/orchestrator/orchestrator-runner'; +} from '@agent/runner/sequence/orchestrator/orchestrator-runner'; function makeSkill(root: string, id: string, wizardMarked: boolean): string { const dir = path.join(root, id); diff --git a/src/lib/agent/runner/sequence/orchestrator/__tests__/task-notice-timeout.test.ts b/src/agent/runner/sequence/orchestrator/__tests__/task-notice-timeout.test.ts similarity index 99% rename from src/lib/agent/runner/sequence/orchestrator/__tests__/task-notice-timeout.test.ts rename to src/agent/runner/sequence/orchestrator/__tests__/task-notice-timeout.test.ts index c0be82feb..0f36fb4ad 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/task-notice-timeout.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/task-notice-timeout.test.ts @@ -34,7 +34,7 @@ import { consentSkipReason, offerSeededTask, TASK_NOTICE_TIMEOUT_MS, -} from '@lib/agent/runner/sequence/orchestrator/orchestrator-runner'; +} from '@agent/runner/sequence/orchestrator/orchestrator-runner'; /** The answerer under test, standing where `getUI()` used to. */ const interaction = { taskNotice: showTaskNotice }; diff --git a/src/lib/agent/runner/sequence/orchestrator/__tests__/variant-resolution.test.ts b/src/agent/runner/sequence/orchestrator/__tests__/variant-resolution.test.ts similarity index 98% rename from src/lib/agent/runner/sequence/orchestrator/__tests__/variant-resolution.test.ts rename to src/agent/runner/sequence/orchestrator/__tests__/variant-resolution.test.ts index b3f302b37..afbc48a15 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/variant-resolution.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/variant-resolution.test.ts @@ -1,8 +1,8 @@ import { describe, it, expect } from 'vitest'; import { resolveSkillVariantId } from '../orchestrator-runner'; -import { Integration } from '@lib/constants'; -import { expandBundleEntry } from '@lib/wizard-tools'; -import type { SkillEntry } from '@lib/wizard-tools'; +import { Integration } from '@shared/constants'; +import { expandBundleEntry } from '@agent/tools'; +import type { SkillEntry } from '@agent/tools'; // Pinned from the real built skill-menu.json, so this suite tests the actual cross-repo contract. const INTEGRATION_ENTRIES = [ diff --git a/src/lib/agent/runner/sequence/orchestrator/executor.ts b/src/agent/runner/sequence/orchestrator/executor.ts similarity index 100% rename from src/lib/agent/runner/sequence/orchestrator/executor.ts rename to src/agent/runner/sequence/orchestrator/executor.ts diff --git a/src/lib/agent/runner/sequence/orchestrator/orchestrator-runner.ts b/src/agent/runner/sequence/orchestrator/orchestrator-runner.ts similarity index 99% rename from src/lib/agent/runner/sequence/orchestrator/orchestrator-runner.ts rename to src/agent/runner/sequence/orchestrator/orchestrator-runner.ts index e2f76fad8..fb3efca83 100644 --- a/src/lib/agent/runner/sequence/orchestrator/orchestrator-runner.ts +++ b/src/agent/runner/sequence/orchestrator/orchestrator-runner.ts @@ -22,19 +22,19 @@ import { writeFileSync, } from 'fs'; import * as path from 'path'; -import { OutroKind, type TaskNotice } from '@lib/agent/progress'; -import { POSTHOG_DOCS_URL, WIZARD_CONTACT_EMAIL } from '@lib/constants'; +import { OutroKind, type TaskNotice } from '@agent/progress'; +import { POSTHOG_DOCS_URL, WIZARD_CONTACT_EMAIL } from '@shared/constants'; import { installSkillById, fetchSkillMenu, type SkillEntry, -} from '@lib/wizard-tools'; +} from '@agent/tools'; import { analytics } from '@utils/analytics'; import { ciExcludedTaskTypes } from '@utils/ci-flag-overrides'; import { logToFile } from '@utils/debug'; import { ringTerminalBell } from '@utils/terminal-bell'; -import { ErrorCodes, WizardError } from '@lib/errors'; -import type { AgentInteraction } from '@lib/agent/progress'; +import { ErrorCodes, WizardError } from '@shared/errors'; +import type { AgentInteraction } from '@agent/progress'; import type { AgentFailure, RunConfig, @@ -64,7 +64,7 @@ import { drainQueue, RunTaskFatal, type RunTask } from './executor'; import { RunMetrics } from './run-metrics'; import { dependencyClosure, uncoveredBySink } from './queue-tools'; import { deferSeededTasks } from './seeded-deps'; -import { LONGER_ASK_TIMEOUT_MS } from '@lib/wizard-ask-bridge'; +import { LONGER_ASK_TIMEOUT_MS } from '@agent/wizard-ask-bridge'; import { shouldDisableAsk } from '../../shared/bootstrap'; import { agentRunTools, @@ -77,7 +77,7 @@ import { ASK_TOOL, type AgentPrompt, type OrchestratorPromptContext, -} from '@lib/agent/agent-prompt-loader'; +} from '@agent/agent-prompt-loader'; /** Docs page (`django.md`, `nuxt-js-3-6.md`) — steps start with a digit, agent artifacts (`SKILL.md`, `EXAMPLE*`, `COMMANDMENTS.md`) have uppercase. */ const isDocPage = (name: string): boolean => diff --git a/src/lib/agent/runner/sequence/orchestrator/queue-tools.ts b/src/agent/runner/sequence/orchestrator/queue-tools.ts similarity index 99% rename from src/lib/agent/runner/sequence/orchestrator/queue-tools.ts rename to src/agent/runner/sequence/orchestrator/queue-tools.ts index ad7546a30..ae99c0ba3 100644 --- a/src/lib/agent/runner/sequence/orchestrator/queue-tools.ts +++ b/src/agent/runner/sequence/orchestrator/queue-tools.ts @@ -8,10 +8,7 @@ */ import { z } from 'zod'; import { analytics } from '@utils/analytics'; -import { - isValidModel, - VALID_MODELS, -} from '@lib/agent/runner/switchboard/models'; +import { isValidModel, VALID_MODELS } from '@agent/runner/switchboard/models'; import { isNotNeededReason, NotNeededReason, diff --git a/src/lib/agent/runner/sequence/orchestrator/queue.ts b/src/agent/runner/sequence/orchestrator/queue.ts similarity index 100% rename from src/lib/agent/runner/sequence/orchestrator/queue.ts rename to src/agent/runner/sequence/orchestrator/queue.ts diff --git a/src/lib/agent/runner/sequence/orchestrator/run-metrics.ts b/src/agent/runner/sequence/orchestrator/run-metrics.ts similarity index 100% rename from src/lib/agent/runner/sequence/orchestrator/run-metrics.ts rename to src/agent/runner/sequence/orchestrator/run-metrics.ts diff --git a/src/lib/agent/runner/sequence/orchestrator/seeded-deps.ts b/src/agent/runner/sequence/orchestrator/seeded-deps.ts similarity index 100% rename from src/lib/agent/runner/sequence/orchestrator/seeded-deps.ts rename to src/agent/runner/sequence/orchestrator/seeded-deps.ts diff --git a/src/lib/agent/runner/shared/ask.ts b/src/agent/runner/shared/ask.ts similarity index 92% rename from src/lib/agent/runner/shared/ask.ts rename to src/agent/runner/shared/ask.ts index 56cae7874..7acdfcb68 100644 --- a/src/lib/agent/runner/shared/ask.ts +++ b/src/agent/runner/shared/ask.ts @@ -12,8 +12,8 @@ import { createWizardAskBridge, type WizardAskBridge, -} from '@lib/wizard-ask-bridge'; -import type { AgentInteraction } from '@lib/agent/progress'; +} from '@agent/wizard-ask-bridge'; +import type { AgentInteraction } from '@agent/progress'; export function createAskBridge( interaction: AgentInteraction | undefined, diff --git a/src/lib/agent/runner/shared/bootstrap.ts b/src/agent/runner/shared/bootstrap.ts similarity index 94% rename from src/lib/agent/runner/shared/bootstrap.ts rename to src/agent/runner/shared/bootstrap.ts index 7384c5f1a..43d8a570f 100644 --- a/src/lib/agent/runner/shared/bootstrap.ts +++ b/src/agent/runner/shared/bootstrap.ts @@ -8,12 +8,12 @@ * arrives already resolved in `RunConfig` and `RunInput`. */ -import { createTriageLLMProvider } from '@lib/agent/triage-provider'; -import { gatewayAuth } from '@lib/gateway-session'; +import { createTriageLLMProvider } from '@agent/triage-provider'; +import { gatewayAuth } from '@agent/gateway-session'; import { logToFile } from '@utils/debug'; -import { CallType, IS_DEV } from '@lib/constants'; -import { VERSION } from '@lib/version'; -import { mcpUrlFor } from '@lib/host-resolution'; +import { CallType, IS_DEV } from '@shared/constants'; +import { VERSION } from '@shared/version'; +import { mcpUrlFor } from '@shared/host-resolution'; import type { WizardRunOptions } from '@utils/types'; import type { BootstrapResult, RunConfig, RunFlags, RunInput } from './types'; diff --git a/src/lib/agent/runner/shared/errors.ts b/src/agent/runner/shared/errors.ts similarity index 90% rename from src/lib/agent/runner/shared/errors.ts rename to src/agent/runner/shared/errors.ts index d991e4242..d89d3c214 100644 --- a/src/lib/agent/runner/shared/errors.ts +++ b/src/agent/runner/shared/errors.ts @@ -2,9 +2,9 @@ * Shared error helpers for the runner pipeline. */ -import type { InstallSkillResult } from '@lib/wizard-tools'; -import { skillErrorCode } from '@lib/errors'; -import { WizardError } from '@lib/errors'; +import type { InstallSkillResult } from '@agent/tools'; +import { skillErrorCode } from '@shared/errors'; +import { WizardError } from '@shared/errors'; import { RunOutcome, type AgentFailure, type SequenceResult } from './types'; export const failed = (failure: AgentFailure): SequenceResult => ({ diff --git a/src/lib/agent/runner/shared/progress-collector.ts b/src/agent/runner/shared/progress-collector.ts similarity index 97% rename from src/lib/agent/runner/shared/progress-collector.ts rename to src/agent/runner/shared/progress-collector.ts index 42a9da5f8..719603e63 100644 --- a/src/lib/agent/runner/shared/progress-collector.ts +++ b/src/agent/runner/shared/progress-collector.ts @@ -9,12 +9,12 @@ */ import { logToFile } from '@utils/debug'; -import { appendStatus } from '@lib/status-history'; +import { appendStatus } from '@shared/status-history'; import type { AgentProgress, ProgressEmitter, SpinnerHandle, -} from '@lib/agent/progress'; +} from '@agent/progress'; import type { RunSnapshot } from './types'; export interface ProgressCollector { diff --git a/src/lib/agent/runner/shared/types.ts b/src/agent/runner/shared/types.ts similarity index 95% rename from src/lib/agent/runner/shared/types.ts rename to src/agent/runner/shared/types.ts index 79b3147fb..52c284e94 100644 --- a/src/lib/agent/runner/shared/types.ts +++ b/src/agent/runner/shared/types.ts @@ -9,17 +9,17 @@ * that rebuilds today's session-driven behavior on top of this contract. */ -import type { AdditionalFeature } from '@lib/constants'; +import type { AdditionalFeature } from '@shared/constants'; import type { CloudRegion } from '@utils/types'; -import type { Credentials } from '@lib/api'; -import type { OutroData, TaskNotice } from '@lib/agent/progress'; -import type { PromptContext } from '@lib/agent/agent-prompt'; +import type { Credentials } from '@shared/api'; +import type { OutroData, TaskNotice } from '@agent/progress'; +import type { PromptContext } from '@agent/agent-prompt'; import type { PackageManagerDetector } from '@utils/package-manager'; -import type { ApiProject, ApiUser } from '@lib/api'; -import type { Harness, Integration, Sequence } from '@lib/constants'; -import type { ErrorCode } from '@lib/errors'; +import type { ApiProject, ApiUser } from '@shared/api'; +import type { Harness, Integration, Sequence } from '@shared/constants'; +import type { ErrorCode } from '@shared/errors'; import type { LLMProvider } from '@posthog/warlock'; -import type { AgentInteraction, ProgressEmitter } from '@lib/agent/progress'; +import type { AgentInteraction, ProgressEmitter } from '@agent/progress'; import type { EffortLevel } from '../switchboard/models'; import type { SwitchboardCtx } from '../switchboard'; @@ -278,7 +278,7 @@ export interface TokenUsageTotals { /** What the agent reported, accumulated independently of any observer. */ export interface RunSnapshot { - tasks: import('@lib/agent/progress').TaskSnapshot[]; + tasks: import('@agent/progress').TaskSnapshot[]; statusMessages: string[]; stage?: string; usage: TokenUsageTotals; @@ -314,7 +314,7 @@ export type RunResult = ( export interface RunAgentOptions { /** Receives every progress event in emission order. Never awaited. */ - onProgress?: (event: import('@lib/agent/progress').AgentProgress) => void; + onProgress?: (event: import('@agent/progress').AgentProgress) => void; /** Answers the agent's questions. Absent → no ask bridge, notices declined. */ interaction?: AgentInteraction; } diff --git a/src/lib/agent/runner/switchboard/commandments.ts b/src/agent/runner/switchboard/commandments.ts similarity index 98% rename from src/lib/agent/runner/switchboard/commandments.ts rename to src/agent/runner/switchboard/commandments.ts index 8cc9aed08..5f709b1fb 100644 --- a/src/lib/agent/runner/switchboard/commandments.ts +++ b/src/agent/runner/switchboard/commandments.ts @@ -12,8 +12,8 @@ * an import cycle. */ -import { Harness, Sequence } from '@lib/constants'; -import { WIZARD_COMMANDMENTS } from '@lib/agent/commandments'; +import { Harness, Sequence } from '@shared/constants'; +import { WIZARD_COMMANDMENTS } from '@agent/commandments'; import { piRuntimeNotes, type RuntimeCaps } from '../harness/pi/runtime-notes'; // ── Sequence axis ─────────────────────────────────────────────────────── diff --git a/src/lib/agent/runner/switchboard/flags/__tests__/binding-cases.ts b/src/agent/runner/switchboard/flags/__tests__/binding-cases.ts similarity index 91% rename from src/lib/agent/runner/switchboard/flags/__tests__/binding-cases.ts rename to src/agent/runner/switchboard/flags/__tests__/binding-cases.ts index ebddc32e2..341a5d9a8 100644 --- a/src/lib/agent/runner/switchboard/flags/__tests__/binding-cases.ts +++ b/src/agent/runner/switchboard/flags/__tests__/binding-cases.ts @@ -4,13 +4,13 @@ * `runBindingCases` turns a table into `it` blocks — specs stay declarative. */ import { describe, it, expect } from 'vitest'; -import { GPT5_6_SOL_MODEL, Harness, Sequence } from '@lib/constants'; +import { GPT5_6_SOL_MODEL, Harness, Sequence } from '@shared/constants'; import { resolveBinding, type SwitchboardCtx, type SwitchboardTrace, -} from '@lib/agent/runner/switchboard'; -import type { EffortLevel } from '@lib/agent/runner/switchboard/models'; +} from '@agent/runner/switchboard'; +import type { EffortLevel } from '@agent/runner/switchboard/models'; /** The complete resolved binding — every axis stated, nothing implicit. */ export interface ExpectedBinding { diff --git a/src/lib/agent/runner/switchboard/flags/__tests__/flags.test.ts b/src/agent/runner/switchboard/flags/__tests__/flags.test.ts similarity index 97% rename from src/lib/agent/runner/switchboard/flags/__tests__/flags.test.ts rename to src/agent/runner/switchboard/flags/__tests__/flags.test.ts index f0540ab5b..616ed2135 100644 --- a/src/lib/agent/runner/switchboard/flags/__tests__/flags.test.ts +++ b/src/agent/runner/switchboard/flags/__tests__/flags.test.ts @@ -4,7 +4,7 @@ import { fileURLToPath } from 'node:url'; import { join, dirname } from 'node:path'; import { describe, it, expect, vi } from 'vitest'; import { PROGRAM_REGISTRY } from '@lib/programs/program-registry'; -import * as constants from '@lib/constants'; +import * as constants from '@shared/constants'; import { DEFAULT_AGENT_MODEL, GPT5_6_SOL_MODEL, @@ -14,18 +14,18 @@ import { WIZARD_ORCHESTRATOR_FLAG_KEY, WIZARD_ORCHESTRATOR_OVERRIDE_FLAG_KEY, WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY, -} from '@lib/constants'; +} from '@shared/constants'; import { areSeededTasksEnabled, resolveBinding, resolveStageOverrides, type SwitchboardCtx, -} from '@lib/agent/runner/switchboard'; +} from '@agent/runner/switchboard'; import { ORCHESTRATOR_SEQUENCE_ROUTE, ORCHESTRATOR_HARNESS_ROUTE, -} from '@lib/agent/runner/switchboard/flags/orchestrator'; -import { SELF_DRIVING_EXPERIMENT } from '@lib/agent/runner/switchboard/flags/self-driving'; +} from '@agent/runner/switchboard/flags/orchestrator'; +import { SELF_DRIVING_EXPERIMENT } from '@agent/runner/switchboard/flags/self-driving'; import { runBindingCases } from './binding-cases'; const envState = vi.hoisted(() => ({ diff --git a/src/lib/agent/runner/switchboard/flags/index.ts b/src/agent/runner/switchboard/flags/index.ts similarity index 98% rename from src/lib/agent/runner/switchboard/flags/index.ts rename to src/agent/runner/switchboard/flags/index.ts index b9d3d03a2..5b376d3ef 100644 --- a/src/lib/agent/runner/switchboard/flags/index.ts +++ b/src/agent/runner/switchboard/flags/index.ts @@ -6,7 +6,7 @@ */ import { RUN_SURFACE } from '@env'; import { logToFile } from '@utils/debug'; -import type { Sequence } from '@lib/constants'; +import type { Sequence } from '@shared/constants'; import type { ProgramId } from '@lib/programs/program-registry'; import { ORCHESTRATOR_HARNESS_ROUTE, diff --git a/src/lib/agent/runner/switchboard/flags/orchestrator.ts b/src/agent/runner/switchboard/flags/orchestrator.ts similarity index 98% rename from src/lib/agent/runner/switchboard/flags/orchestrator.ts rename to src/agent/runner/switchboard/flags/orchestrator.ts index 544e00b83..3bc6f09ad 100644 --- a/src/lib/agent/runner/switchboard/flags/orchestrator.ts +++ b/src/agent/runner/switchboard/flags/orchestrator.ts @@ -5,7 +5,7 @@ import { WIZARD_ORCHESTRATOR_FLAG_KEY, WIZARD_ORCHESTRATOR_OVERRIDE_FLAG_KEY, WIZARD_ORCHESTRATOR_SEEDED_TASKS_FLAG_KEY, -} from '@lib/constants'; +} from '@shared/constants'; import type { HarnessExperiment, SequenceExperiment } from './schemes'; export const ORCHESTRATOR_SEQUENCE_ROUTE: SequenceExperiment = { diff --git a/src/lib/agent/runner/switchboard/flags/schemes.ts b/src/agent/runner/switchboard/flags/schemes.ts similarity index 99% rename from src/lib/agent/runner/switchboard/flags/schemes.ts rename to src/agent/runner/switchboard/flags/schemes.ts index f55f30141..e30f48c0e 100644 --- a/src/lib/agent/runner/switchboard/flags/schemes.ts +++ b/src/agent/runner/switchboard/flags/schemes.ts @@ -12,7 +12,7 @@ import { Harness, Sequence, SONNET_5_MODEL, -} from '@lib/constants'; +} from '@shared/constants'; import type { ProgramId } from '@lib/programs/program-registry'; import { logToFile } from '@utils/debug'; import type { EffortLevel } from '../models'; diff --git a/src/lib/agent/runner/switchboard/flags/self-driving.ts b/src/agent/runner/switchboard/flags/self-driving.ts similarity index 86% rename from src/lib/agent/runner/switchboard/flags/self-driving.ts rename to src/agent/runner/switchboard/flags/self-driving.ts index beb34ea90..2f1e8fcab 100644 --- a/src/lib/agent/runner/switchboard/flags/self-driving.ts +++ b/src/agent/runner/switchboard/flags/self-driving.ts @@ -6,7 +6,7 @@ * Routes: ONLY `self-driving` — any axis the payload pins. A missing or * invalid payload keeps the non-flagged binding default. */ -import { WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY } from '@lib/constants'; +import { WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY } from '@shared/constants'; import type { HarnessExperiment } from './schemes'; export const SELF_DRIVING_EXPERIMENT: HarnessExperiment = { diff --git a/src/lib/agent/runner/switchboard/harness.ts b/src/agent/runner/switchboard/harness.ts similarity index 98% rename from src/lib/agent/runner/switchboard/harness.ts rename to src/agent/runner/switchboard/harness.ts index 8710a166f..0f5673ed2 100644 --- a/src/lib/agent/runner/switchboard/harness.ts +++ b/src/agent/runner/switchboard/harness.ts @@ -3,7 +3,7 @@ */ import { IS_PRODUCTION_BUILD } from '@env'; -import { Harness } from '@lib/constants'; +import { Harness } from '@shared/constants'; import { logToFile } from '@utils/debug'; import { anthropicBackend } from '../harness/anthropic'; import { piBackend } from '../harness/pi'; diff --git a/src/lib/agent/runner/switchboard/index.ts b/src/agent/runner/switchboard/index.ts similarity index 99% rename from src/lib/agent/runner/switchboard/index.ts rename to src/agent/runner/switchboard/index.ts index f6d641a66..842176c16 100644 --- a/src/lib/agent/runner/switchboard/index.ts +++ b/src/agent/runner/switchboard/index.ts @@ -6,7 +6,7 @@ import { GPT5_6_TERRA_MODEL, Harness, Sequence, -} from '@lib/constants'; +} from '@shared/constants'; import type { ProgramId } from '@lib/programs/program-registry'; import { resolveHarness } from './harness'; import type { EffortLevel } from './models'; diff --git a/src/lib/agent/runner/switchboard/models.ts b/src/agent/runner/switchboard/models.ts similarity index 99% rename from src/lib/agent/runner/switchboard/models.ts rename to src/agent/runner/switchboard/models.ts index ab8d4b202..d72d37c21 100644 --- a/src/lib/agent/runner/switchboard/models.ts +++ b/src/agent/runner/switchboard/models.ts @@ -7,7 +7,7 @@ import { GPT5_6_TERRA_MODEL, HAIKU_TRIAGE_MODEL, Harness, -} from '@lib/constants'; +} from '@shared/constants'; /** Reasoning effort, mapped by each harness to its provider transport. */ const THINKING_LEVELS = [ diff --git a/src/lib/agent/runner/switchboard/sequence.ts b/src/agent/runner/switchboard/sequence.ts similarity index 99% rename from src/lib/agent/runner/switchboard/sequence.ts rename to src/agent/runner/switchboard/sequence.ts index 3d2730405..b6d241720 100644 --- a/src/lib/agent/runner/switchboard/sequence.ts +++ b/src/agent/runner/switchboard/sequence.ts @@ -4,7 +4,7 @@ */ import { IS_PRODUCTION_BUILD } from '@env'; -import { Sequence } from '@lib/constants'; +import { Sequence } from '@shared/constants'; import { logToFile } from '@utils/debug'; import { isOrchestratorEnabled, diff --git a/src/lib/safe-tools.ts b/src/agent/safe-tools.ts similarity index 100% rename from src/lib/safe-tools.ts rename to src/agent/safe-tools.ts diff --git a/src/lib/agent/signals.ts b/src/agent/signals.ts similarity index 100% rename from src/lib/agent/signals.ts rename to src/agent/signals.ts diff --git a/src/lib/agent/stored-login.ts b/src/agent/stored-login.ts similarity index 100% rename from src/lib/agent/stored-login.ts rename to src/agent/stored-login.ts diff --git a/src/lib/wizard-tools/__tests__/handoff-tools.test.ts b/src/agent/tools/__tests__/handoff-tools.test.ts similarity index 96% rename from src/lib/wizard-tools/__tests__/handoff-tools.test.ts rename to src/agent/tools/__tests__/handoff-tools.test.ts index 6f3b6f062..2b70b8b09 100644 --- a/src/lib/wizard-tools/__tests__/handoff-tools.test.ts +++ b/src/agent/tools/__tests__/handoff-tools.test.ts @@ -3,8 +3,8 @@ import { mkdtempSync, rmSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import type { LLMProvider } from '@posthog/warlock'; -import type { AgentProgress } from '@lib/agent/progress'; -import { createWizardPiTools } from '@lib/agent/runner/harness/pi/tools'; +import type { AgentProgress } from '@agent/progress'; +import { createWizardPiTools } from '@agent/runner/harness/pi/tools'; import { createWizardToolsServer } from '../mcp'; import { PUBLISH_HANDOFF_TOOL_NAME } from '../handoff'; diff --git a/src/lib/wizard-tools/__tests__/handoff.test.ts b/src/agent/tools/__tests__/handoff.test.ts similarity index 99% rename from src/lib/wizard-tools/__tests__/handoff.test.ts rename to src/agent/tools/__tests__/handoff.test.ts index c93b792c8..ff56b6df5 100644 --- a/src/lib/wizard-tools/__tests__/handoff.test.ts +++ b/src/agent/tools/__tests__/handoff.test.ts @@ -11,7 +11,7 @@ import { } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; -import type { AgentProgress } from '@lib/agent/progress'; +import type { AgentProgress } from '@agent/progress'; import { MAX_HANDOFF_TEXT_CHARS, publishHandoff } from '../handoff'; // The tool runs inside the agent, which has no UI; the handoff is a progress diff --git a/src/lib/wizard-tools/handoff.ts b/src/agent/tools/handoff.ts similarity index 99% rename from src/lib/wizard-tools/handoff.ts rename to src/agent/tools/handoff.ts index 67411da68..a64e8fa63 100644 --- a/src/lib/wizard-tools/handoff.ts +++ b/src/agent/tools/handoff.ts @@ -4,7 +4,7 @@ * It leaves the tool as a `handoff` progress event; the host projects it. */ -import type { ProgressEmitter } from '@lib/agent/progress'; +import type { ProgressEmitter } from '@agent/progress'; import { analytics } from '@utils/analytics'; import { logToFile } from '@utils/debug'; import { runtimeEnv } from '@env'; diff --git a/src/lib/wizard-tools/index.ts b/src/agent/tools/index.ts similarity index 100% rename from src/lib/wizard-tools/index.ts rename to src/agent/tools/index.ts diff --git a/src/lib/wizard-tools/mcp.ts b/src/agent/tools/mcp.ts similarity index 99% rename from src/lib/wizard-tools/mcp.ts rename to src/agent/tools/mcp.ts index ac366b09f..8c0940ef0 100644 --- a/src/lib/wizard-tools/mcp.ts +++ b/src/agent/tools/mcp.ts @@ -19,7 +19,7 @@ import { AUDIT_CHECKS_FILE, type AuditCheck, type AuditStatus, -} from '../audit-ledger'; +} from '@shared/audit-ledger'; import { type WizardAskBridge, isFullyCancelled } from '../wizard-ask-bridge'; import { PUBLISH_HANDOFF_CONTENT_DESCRIPTION, @@ -27,12 +27,12 @@ import { PUBLISH_HANDOFF_TOOL_NAME, publishHandoff, } from './handoff'; -import { createSecretVault, type SecretVault } from '../secret-vault'; -import type { ProgressEmitter } from '@lib/agent/progress'; +import { createSecretVault, type SecretVault } from '@shared/secret-vault'; +import type { ProgressEmitter } from '@agent/progress'; import { buildOrchestratorTools, type OrchestratorToolsContext, -} from '../agent/runner/sequence/orchestrator/queue-tools'; +} from '@agent/runner/sequence/orchestrator/queue-tools'; import type { LLMProvider } from '@posthog/warlock'; import { ASK_MAX_QUESTIONS_PER_CALL, diff --git a/src/lib/wizard-tools/tools.ts b/src/agent/tools/tools.ts similarity index 99% rename from src/lib/wizard-tools/tools.ts rename to src/agent/tools/tools.ts index f56f8f3bf..e59b6cb51 100644 --- a/src/lib/wizard-tools/tools.ts +++ b/src/agent/tools/tools.ts @@ -20,7 +20,7 @@ import { type EnvKeyDefinition, type EnvKeyLocations, } from '@utils/env-scan'; -import { scanInstalledSkill } from '@lib/yara-hooks'; +import { scanInstalledSkill } from '@agent/yara-hooks'; import type { LLMProvider } from '@posthog/warlock'; import { writeJsonAtomic, makeMutex } from '@utils/atomic-ledger'; import { @@ -28,10 +28,10 @@ import { coerceAuditChecks, type AuditCheck, type AuditStatus, -} from '../audit-ledger'; +} from '@shared/audit-ledger'; import { CANCELLED_SENTINEL } from '../wizard-ask-bridge'; -import type { SecretVault } from '../secret-vault'; -import { fetchWithRetry, type RetryOpts } from '../fetch-retry'; +import type { SecretVault } from '@shared/secret-vault'; +import { fetchWithRetry, type RetryOpts } from '@shared/fetch-retry'; // --------------------------------------------------------------------------- // Skill types diff --git a/src/lib/agent/triage-provider.ts b/src/agent/triage-provider.ts similarity index 96% rename from src/lib/agent/triage-provider.ts rename to src/agent/triage-provider.ts index dfb03861d..426fab116 100644 --- a/src/lib/agent/triage-provider.ts +++ b/src/agent/triage-provider.ts @@ -5,16 +5,16 @@ * transport, reasoning effort and trace headers come from one place. */ -import { Harness } from '@lib/constants'; +import { Harness } from '@shared/constants'; import { logToFile } from '@utils/debug'; import { buildGatewayModel, gatewayApiFor, -} from '@lib/agent/runner/harness/pi/gateway'; +} from '@agent/runner/harness/pi/gateway'; import { modelCapabilities, triageModelFor, -} from '@lib/agent/runner/switchboard/models'; +} from '@agent/runner/switchboard/models'; import type { LLMProvider } from '@posthog/warlock'; const TRIAGE_MAX_TOKENS = 16_384; diff --git a/src/lib/wizard-ask-bridge.ts b/src/agent/wizard-ask-bridge.ts similarity index 98% rename from src/lib/wizard-ask-bridge.ts rename to src/agent/wizard-ask-bridge.ts index 408f26566..f76f1d1cd 100644 --- a/src/lib/wizard-ask-bridge.ts +++ b/src/agent/wizard-ask-bridge.ts @@ -13,11 +13,7 @@ import { randomUUID } from 'crypto'; import { analytics } from '@utils/analytics'; -import type { - AskAnswers, - AskQuestion, - PendingQuestion, -} from './agent/progress'; +import type { AskAnswers, AskQuestion, PendingQuestion } from '@agent/progress'; export interface WizardAskRequest { questions: AskQuestion[]; diff --git a/src/lib/yara-hooks.ts b/src/agent/yara-hooks.ts similarity index 99% rename from src/lib/yara-hooks.ts rename to src/agent/yara-hooks.ts index 6f97de2ac..e922837f3 100644 --- a/src/lib/yara-hooks.ts +++ b/src/agent/yara-hooks.ts @@ -35,7 +35,7 @@ import type { import { logToFile } from '@utils/debug'; import { readFileHead } from '@utils/bounded-fs'; import { analytics } from '@utils/analytics'; -import { isSkillInstallCommand } from './skill-install'; +import { isSkillInstallCommand } from '@shared/skill-install'; import { highestSeverityMatch, publishBlockingMatch, @@ -53,8 +53,8 @@ import { EVENT_INVENTORY_FILE, EVENT_INVENTORY_PART_PATTERN, EVENT_PLAN_FILE, -} from '@lib/constants'; -import { AUDIT_REPORT_FILE } from '@lib/audit-ledger'; +} from '@shared/constants'; +import { AUDIT_REPORT_FILE } from '@shared/audit-ledger'; // ─── Warlock module accessor ───────────────────────────────────── // Warlock is ESM-only and lazily inits its WASM engine + compiles rules on the diff --git a/src/lib/yara-policy.ts b/src/agent/yara-policy.ts similarity index 100% rename from src/lib/yara-policy.ts rename to src/agent/yara-policy.ts diff --git a/src/commands/basic-integration/ci-install.ts b/src/commands/basic-integration/ci-install.ts index ba04ed382..9c24bc880 100644 --- a/src/commands/basic-integration/ci-install.ts +++ b/src/commands/basic-integration/ci-install.ts @@ -5,8 +5,8 @@ import { API_KEY_HINT, runWizardCI, runWizardHeadless } from '@lib/runners'; import type { NonInteractiveMode } from '@lib/runners'; import { provisionNewAccount } from '@utils/provisioning'; import { posthogIntegrationConfig } from '@lib/programs/posthog-integration/index'; -import { ErrorCodes, type ErrorCode } from '@lib/errors'; -import { emitWizardError } from '@lib/errors'; +import { ErrorCodes, type ErrorCode } from '@shared/errors'; +import { emitWizardError } from '@shared/errors'; type Options = Arguments & { region?: string; diff --git a/src/commands/basic-integration/non-interactive.ts b/src/commands/basic-integration/non-interactive.ts index 02a47675c..30877ee93 100644 --- a/src/commands/basic-integration/non-interactive.ts +++ b/src/commands/basic-integration/non-interactive.ts @@ -1,6 +1,6 @@ import { getUI } from '@ui'; -import { ErrorCodes } from '@lib/errors'; -import { emitWizardError } from '@lib/errors'; +import { ErrorCodes } from '@shared/errors'; +import { emitWizardError } from '@shared/errors'; /** Print the "needs a TTY" error and exit. Used when no `--ci` flag and no TTY. */ export function failNonInteractive(): void { diff --git a/src/commands/basic-integration/playground.ts b/src/commands/basic-integration/playground.ts index 61eaaf0fc..92c5eab2a 100644 --- a/src/commands/basic-integration/playground.ts +++ b/src/commands/basic-integration/playground.ts @@ -1,4 +1,4 @@ -import { VERSION } from '@lib/version'; +import { VERSION } from '@shared/version'; import { startPlayground } from '@ui/tui/playground/start-playground'; /** Launch the TUI primitives playground. */ diff --git a/src/commands/basic-integration/skill.ts b/src/commands/basic-integration/skill.ts index a4a2bc088..5b41a205d 100644 --- a/src/commands/basic-integration/skill.ts +++ b/src/commands/basic-integration/skill.ts @@ -1,5 +1,5 @@ import type { Arguments } from 'yargs'; -import { POSTHOG_DOCS_URL } from '@lib/constants'; +import { POSTHOG_DOCS_URL } from '@shared/constants'; import { runWizard, runWizardCI } from '@lib/runners'; import { createSkillProgram } from '@lib/programs/agent-skill/index'; diff --git a/src/commands/doctor.ts b/src/commands/doctor.ts index 4884df234..3b9385b97 100644 --- a/src/commands/doctor.ts +++ b/src/commands/doctor.ts @@ -1,8 +1,8 @@ import { getUI, setUI } from '@ui'; import { LoggingUI } from '@ui/logging-ui'; import { readApiKeyFromEnv } from '@utils/env-api-key'; -import { ErrorCodes } from '@lib/errors'; -import { emitWizardError } from '@lib/errors'; +import { ErrorCodes } from '@shared/errors'; +import { emitWizardError } from '@shared/errors'; import { runWizard } from '@lib/runners'; import { posthogDoctorConfig, @@ -87,7 +87,7 @@ async function runDoctorCI(options: Record): Promise { } process.exit(1); } catch (error) { - const { ApiError } = await import('@lib/api'); + const { ApiError } = await import('@shared/api'); const message = error instanceof ApiError && error.statusCode === 401 ? 'Your PostHog API key is invalid or expired.' diff --git a/src/commands/factories/family-command-factory.ts b/src/commands/factories/family-command-factory.ts index 3fea1c7ea..9ae0f164c 100644 --- a/src/commands/factories/family-command-factory.ts +++ b/src/commands/factories/family-command-factory.ts @@ -6,8 +6,8 @@ import { dispatchFamily, pickerChildrenToShow, } from '@lib/programs/dispatch-family'; -import { getSkillsBaseUrl } from '@lib/constants'; -import { fetchSkillMenu } from '@lib/wizard-tools'; +import { getSkillsBaseUrl } from '@shared/constants'; +import { fetchSkillMenu } from '@agent/tools'; import type { Command } from '../command'; import { createFamilyPickerDefault } from './family-picker'; diff --git a/src/commands/factories/shared.ts b/src/commands/factories/shared.ts index 0cda49719..cf2e73951 100644 --- a/src/commands/factories/shared.ts +++ b/src/commands/factories/shared.ts @@ -5,8 +5,8 @@ import { isHeadless } from '@lib/headless-mode'; import type { ProgramConfig } from '@lib/programs/program-step'; import { skillProgramOptions } from '../skill-program-options'; -import { ErrorCodes } from '@lib/errors'; -import { emitWizardError } from '@lib/errors'; +import { ErrorCodes } from '@shared/errors'; +import { emitWizardError } from '@shared/errors'; /** * Dispatch a parsed yargs invocation to the wizard runner. Applies the diff --git a/src/commands/mcp/add.ts b/src/commands/mcp/add.ts index f1bf00116..f9b22e7a0 100644 --- a/src/commands/mcp/add.ts +++ b/src/commands/mcp/add.ts @@ -3,7 +3,7 @@ import { setUI } from '@ui'; import { LoggingUI } from '@ui/logging-ui'; import { headlessOption, isHeadless } from '@lib/headless-mode'; import { Program } from '@lib/programs/program-registry'; -import { VERSION } from '@lib/version'; +import { VERSION } from '@shared/version'; import type { Command } from '../command'; import { isTUIUnavailable } from './tui-availability'; diff --git a/src/commands/mcp/remove.ts b/src/commands/mcp/remove.ts index 7769056b2..26e34291e 100644 --- a/src/commands/mcp/remove.ts +++ b/src/commands/mcp/remove.ts @@ -3,7 +3,7 @@ import { setUI } from '@ui'; import { LoggingUI } from '@ui/logging-ui'; import { headlessOption, isHeadless } from '@lib/headless-mode'; import { Program } from '@lib/programs/program-registry'; -import { VERSION } from '@lib/version'; +import { VERSION } from '@shared/version'; import type { Command } from '../command'; import { isTUIUnavailable } from './tui-availability'; diff --git a/src/commands/mcp/tutorial.ts b/src/commands/mcp/tutorial.ts index 66e2443fe..eb6c0b495 100644 --- a/src/commands/mcp/tutorial.ts +++ b/src/commands/mcp/tutorial.ts @@ -2,9 +2,9 @@ import type { Arguments } from 'yargs'; import { getUI, setUI } from '@ui'; import { LoggingUI } from '@ui/logging-ui'; import { Program } from '@lib/programs/program-registry'; -import { VERSION } from '@lib/version'; -import { ErrorCodes } from '@lib/errors'; -import { emitWizardError } from '@lib/errors'; +import { VERSION } from '@shared/version'; +import { ErrorCodes } from '@shared/errors'; +import { emitWizardError } from '@shared/errors'; import type { Command } from '../command'; export const mcpTutorialCommand: Command = { diff --git a/src/commands/skill.ts b/src/commands/skill.ts index 102eff5f8..c72fb93ec 100644 --- a/src/commands/skill.ts +++ b/src/commands/skill.ts @@ -1,14 +1,14 @@ import type { Arguments } from 'yargs'; -import { getSkillsBaseUrl } from '@lib/constants'; -import { fetchSkillMenu, type CliEntry } from '@lib/wizard-tools'; +import { getSkillsBaseUrl } from '@shared/constants'; +import { fetchSkillMenu, type CliEntry } from '@agent/tools'; import { analytics } from '@utils/analytics'; import { runSkillMode } from './basic-integration/skill'; import { skillProgramOptions } from './skill-program-options'; import { runCommandHandler } from './factories/shared'; -import { ErrorCodes } from '@lib/errors'; -import { emitWizardError } from '@lib/errors'; +import { ErrorCodes } from '@shared/errors'; +import { emitWizardError } from '@shared/errors'; import type { Command } from './command'; /** Read the `` positional (yargs camelCases the hyphenated key). */ diff --git a/src/commands/slack.ts b/src/commands/slack.ts index 4f0bf7743..cd857e6c2 100644 --- a/src/commands/slack.ts +++ b/src/commands/slack.ts @@ -2,9 +2,9 @@ import type { Arguments } from 'yargs'; import { getUI, setUI } from '@ui'; import { LoggingUI } from '@ui/logging-ui'; import { Program } from '@lib/programs/program-registry'; -import { VERSION } from '@lib/version'; -import { ErrorCodes } from '@lib/errors'; -import { emitWizardError } from '@lib/errors'; +import { VERSION } from '@shared/version'; +import { ErrorCodes } from '@shared/errors'; +import { emitWizardError } from '@shared/errors'; import type { Command } from './command'; export const slackCommand: Command = { diff --git a/src/frameworks/android/android-wizard-agent.ts b/src/frameworks/android/android-wizard-agent.ts index dd9acaebf..789cf3746 100644 --- a/src/frameworks/android/android-wizard-agent.ts +++ b/src/frameworks/android/android-wizard-agent.ts @@ -1,7 +1,7 @@ /* Android (Kotlin) wizard using posthog-agent with PostHog MCP */ import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { boundedGlob } from '@utils/bounded-fs'; import * as fs from 'node:fs'; import * as path from 'node:path'; diff --git a/src/frameworks/angular/angular-wizard-agent.ts b/src/frameworks/angular/angular-wizard-agent.ts index 7db04b37a..bd1fdc675 100644 --- a/src/frameworks/angular/angular-wizard-agent.ts +++ b/src/frameworks/angular/angular-wizard-agent.ts @@ -2,7 +2,7 @@ import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; import { detectNodePackageManagers } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { getDeclaredVersion, getInstalledPackageVersion, diff --git a/src/frameworks/astro/astro-wizard-agent.ts b/src/frameworks/astro/astro-wizard-agent.ts index f427935ab..f8052cc30 100644 --- a/src/frameworks/astro/astro-wizard-agent.ts +++ b/src/frameworks/astro/astro-wizard-agent.ts @@ -2,7 +2,7 @@ import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; import { detectNodePackageManagers } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { getDeclaredVersion, getInstalledPackageVersion, diff --git a/src/frameworks/django/django-wizard-agent.ts b/src/frameworks/django/django-wizard-agent.ts index 30e2660aa..6abe33c2a 100644 --- a/src/frameworks/django/django-wizard-agent.ts +++ b/src/frameworks/django/django-wizard-agent.ts @@ -3,7 +3,7 @@ import type { WizardRunOptions } 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 { Integration } from '@shared/constants'; import { boundedGlob, readProjectFile } from '@utils/bounded-fs'; import * as path from 'node:path'; import { diff --git a/src/frameworks/elixir/elixir-wizard-agent.ts b/src/frameworks/elixir/elixir-wizard-agent.ts index 26eb007e1..f74b4e38e 100644 --- a/src/frameworks/elixir/elixir-wizard-agent.ts +++ b/src/frameworks/elixir/elixir-wizard-agent.ts @@ -4,7 +4,7 @@ import * as path from 'node:path'; import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; import { mixPackageManager } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; type ElixirContext = { phoenix?: boolean; diff --git a/src/frameworks/fastapi/fastapi-wizard-agent.ts b/src/frameworks/fastapi/fastapi-wizard-agent.ts index 61f0d8d8d..1a6763dbd 100644 --- a/src/frameworks/fastapi/fastapi-wizard-agent.ts +++ b/src/frameworks/fastapi/fastapi-wizard-agent.ts @@ -3,7 +3,7 @@ import type { WizardRunOptions } 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 { Integration } from '@shared/constants'; import { getFastAPIVersion, getFastAPIProjectType, diff --git a/src/frameworks/flask/flask-wizard-agent.ts b/src/frameworks/flask/flask-wizard-agent.ts index 539afa840..8d143fda6 100644 --- a/src/frameworks/flask/flask-wizard-agent.ts +++ b/src/frameworks/flask/flask-wizard-agent.ts @@ -3,7 +3,7 @@ import type { WizardRunOptions } 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 { Integration } from '@shared/constants'; import { boundedGlob, readProjectFile } from '@utils/bounded-fs'; import * as path from 'node:path'; import { diff --git a/src/frameworks/flutter/flutter-wizard-agent.ts b/src/frameworks/flutter/flutter-wizard-agent.ts index 8a44cddfc..c2fb22371 100644 --- a/src/frameworks/flutter/flutter-wizard-agent.ts +++ b/src/frameworks/flutter/flutter-wizard-agent.ts @@ -1,7 +1,7 @@ /* Flutter wizard using posthog-agent with PostHog MCP */ import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import * as fs from 'node:fs'; import * as path from 'node:path'; import { pubPackageManager } from '@lib/detection/package-manager'; diff --git a/src/frameworks/go/go-wizard-agent.ts b/src/frameworks/go/go-wizard-agent.ts index 6010e945b..f9e630506 100644 --- a/src/frameworks/go/go-wizard-agent.ts +++ b/src/frameworks/go/go-wizard-agent.ts @@ -4,7 +4,7 @@ import * as path from 'node:path'; import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; import { goModulesPackageManager } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; type GoContext = { goVersion?: string; diff --git a/src/frameworks/java/java-wizard-agent.ts b/src/frameworks/java/java-wizard-agent.ts index 9223a0525..1c9e26828 100644 --- a/src/frameworks/java/java-wizard-agent.ts +++ b/src/frameworks/java/java-wizard-agent.ts @@ -5,7 +5,7 @@ import * as path from 'node:path'; import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; import { detectJavaPackageManagers } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; type JavaContext = { buildTool?: 'maven' | 'gradle'; diff --git a/src/frameworks/javascript-node/javascript-node-wizard-agent.ts b/src/frameworks/javascript-node/javascript-node-wizard-agent.ts index fb12fb38e..62519d721 100644 --- a/src/frameworks/javascript-node/javascript-node-wizard-agent.ts +++ b/src/frameworks/javascript-node/javascript-node-wizard-agent.ts @@ -1,6 +1,6 @@ /* Generic Node.js language wizard using posthog-agent with PostHog MCP */ import type { FrameworkConfig } from '@lib/framework-config'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { tryGetPackageJson } from '@utils/setup-utils'; import { detectNodePackageManagers } from '@lib/detection/package-manager'; diff --git a/src/frameworks/javascript-web/javascript-web-wizard-agent.ts b/src/frameworks/javascript-web/javascript-web-wizard-agent.ts index 1f963eab3..cc3899c06 100644 --- a/src/frameworks/javascript-web/javascript-web-wizard-agent.ts +++ b/src/frameworks/javascript-web/javascript-web-wizard-agent.ts @@ -1,7 +1,7 @@ /* Generic JavaScript Web (client-side) wizard using posthog-agent with PostHog MCP */ import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import * as fs from 'node:fs'; import * as path from 'node:path'; import { hasDeclaredDependency } from '@utils/package-json'; diff --git a/src/frameworks/kmp/kmp-wizard-agent.ts b/src/frameworks/kmp/kmp-wizard-agent.ts index 6fa6085d2..be2a3e969 100644 --- a/src/frameworks/kmp/kmp-wizard-agent.ts +++ b/src/frameworks/kmp/kmp-wizard-agent.ts @@ -1,6 +1,6 @@ /* Kotlin Multiplatform (KMP) wizard using posthog-agent with PostHog MCP */ import type { FrameworkConfig } from '../../lib/framework-config'; -import { Integration } from '../../lib/constants'; +import { Integration } from '@shared/constants'; import { gradlePackageManager } from '../../lib/detection/package-manager'; import { boundedGlob, readProjectFile } from '@utils/bounded-fs'; import * as path from 'node:path'; diff --git a/src/frameworks/laravel/laravel-wizard-agent.ts b/src/frameworks/laravel/laravel-wizard-agent.ts index 36b81b971..b7c0c1651 100644 --- a/src/frameworks/laravel/laravel-wizard-agent.ts +++ b/src/frameworks/laravel/laravel-wizard-agent.ts @@ -2,7 +2,7 @@ import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; import { composerPackageManager } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { boundedGlob } from '@utils/bounded-fs'; import * as fs from 'node:fs'; import * as path from 'node:path'; diff --git a/src/frameworks/nextjs/nextjs-wizard-agent.ts b/src/frameworks/nextjs/nextjs-wizard-agent.ts index d98442f5a..614d9e7aa 100644 --- a/src/frameworks/nextjs/nextjs-wizard-agent.ts +++ b/src/frameworks/nextjs/nextjs-wizard-agent.ts @@ -2,7 +2,7 @@ import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; import { detectNodePackageManagers } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { getDeclaredVersion, getInstalledPackageVersion, diff --git a/src/frameworks/nuxt/nuxt-wizard-agent.ts b/src/frameworks/nuxt/nuxt-wizard-agent.ts index 56899b903..94edb5173 100644 --- a/src/frameworks/nuxt/nuxt-wizard-agent.ts +++ b/src/frameworks/nuxt/nuxt-wizard-agent.ts @@ -2,7 +2,7 @@ import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; import { detectNodePackageManagers } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { getDeclaredVersion, getInstalledPackageVersion, diff --git a/src/frameworks/python/python-wizard-agent.ts b/src/frameworks/python/python-wizard-agent.ts index fc44b370b..15d88cd69 100644 --- a/src/frameworks/python/python-wizard-agent.ts +++ b/src/frameworks/python/python-wizard-agent.ts @@ -3,7 +3,7 @@ import type { WizardRunOptions } 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 { Integration } from '@shared/constants'; import fg from 'fast-glob'; import * as fs from 'node:fs'; import * as path from 'node:path'; diff --git a/src/frameworks/rails/rails-wizard-agent.ts b/src/frameworks/rails/rails-wizard-agent.ts index f473ac98b..e2df48c59 100644 --- a/src/frameworks/rails/rails-wizard-agent.ts +++ b/src/frameworks/rails/rails-wizard-agent.ts @@ -2,7 +2,7 @@ import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; import { bundlerPackageManager } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { getRailsVersion, getRailsProjectType, diff --git a/src/frameworks/react-native/react-native-wizard-agent.ts b/src/frameworks/react-native/react-native-wizard-agent.ts index 7d231781c..c4a489c71 100644 --- a/src/frameworks/react-native/react-native-wizard-agent.ts +++ b/src/frameworks/react-native/react-native-wizard-agent.ts @@ -2,7 +2,7 @@ import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; import { detectNodePackageManagers } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { getDeclaredVersion, getInstalledPackageVersion, diff --git a/src/frameworks/react-router/react-router-wizard-agent.ts b/src/frameworks/react-router/react-router-wizard-agent.ts index e1c211ebe..4c19a4ac4 100644 --- a/src/frameworks/react-router/react-router-wizard-agent.ts +++ b/src/frameworks/react-router/react-router-wizard-agent.ts @@ -2,7 +2,7 @@ import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; import { detectNodePackageManagers } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { getDeclaredVersion, getInstalledPackageVersion, diff --git a/src/frameworks/ruby/ruby-wizard-agent.ts b/src/frameworks/ruby/ruby-wizard-agent.ts index aa63873b9..508ab33a5 100644 --- a/src/frameworks/ruby/ruby-wizard-agent.ts +++ b/src/frameworks/ruby/ruby-wizard-agent.ts @@ -2,7 +2,7 @@ import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; import { bundlerPackageManager } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { getRubyVersion, getRubyVersionBucket, diff --git a/src/frameworks/rust/rust-wizard-agent.ts b/src/frameworks/rust/rust-wizard-agent.ts index 6c0aef1e2..3113a6708 100644 --- a/src/frameworks/rust/rust-wizard-agent.ts +++ b/src/frameworks/rust/rust-wizard-agent.ts @@ -4,7 +4,7 @@ import * as path from 'node:path'; import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; import { cargoPackageManager } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; type RustContext = { asyncRuntime?: boolean; diff --git a/src/frameworks/svelte/svelte-wizard-agent.ts b/src/frameworks/svelte/svelte-wizard-agent.ts index e84e2cef7..5d7777fdc 100644 --- a/src/frameworks/svelte/svelte-wizard-agent.ts +++ b/src/frameworks/svelte/svelte-wizard-agent.ts @@ -1,7 +1,7 @@ /* SvelteKit wizard using posthog-agent with PostHog MCP */ import type { FrameworkConfig } from '@lib/framework-config'; import { detectNodePackageManagers } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { getDeclaredVersion, hasDeclaredDependency, diff --git a/src/frameworks/swift/swift-wizard-agent.ts b/src/frameworks/swift/swift-wizard-agent.ts index 5e6343b87..049255b64 100644 --- a/src/frameworks/swift/swift-wizard-agent.ts +++ b/src/frameworks/swift/swift-wizard-agent.ts @@ -2,7 +2,7 @@ import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; import { swiftPackageManager } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { boundedGlob } from '@utils/bounded-fs'; import fg from 'fast-glob'; import * as fs from 'node:fs'; diff --git a/src/frameworks/tanstack-router/tanstack-router-wizard-agent.ts b/src/frameworks/tanstack-router/tanstack-router-wizard-agent.ts index c63245a85..07e43d0ad 100644 --- a/src/frameworks/tanstack-router/tanstack-router-wizard-agent.ts +++ b/src/frameworks/tanstack-router/tanstack-router-wizard-agent.ts @@ -2,7 +2,7 @@ import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; import { detectNodePackageManagers } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { getDeclaredVersion, getInstalledPackageVersion, diff --git a/src/frameworks/tanstack-start/tanstack-start-wizard-agent.ts b/src/frameworks/tanstack-start/tanstack-start-wizard-agent.ts index a279ef6bb..f28eaa4a9 100644 --- a/src/frameworks/tanstack-start/tanstack-start-wizard-agent.ts +++ b/src/frameworks/tanstack-start/tanstack-start-wizard-agent.ts @@ -2,7 +2,7 @@ import type { WizardRunOptions } from '@utils/types'; import type { FrameworkConfig } from '@lib/framework-config'; import { detectNodePackageManagers } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { getDeclaredVersion, getInstalledPackageVersion, diff --git a/src/frameworks/vue/vue-wizard-agent.ts b/src/frameworks/vue/vue-wizard-agent.ts index a37492a8d..dd61b3ab4 100644 --- a/src/frameworks/vue/vue-wizard-agent.ts +++ b/src/frameworks/vue/vue-wizard-agent.ts @@ -1,7 +1,7 @@ /* Vue wizard using posthog-agent with PostHog MCP */ import type { FrameworkConfig } from '@lib/framework-config'; import { detectNodePackageManagers } from '@lib/detection/package-manager'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { getDeclaredVersion, getInstalledPackageVersion, diff --git a/src/lib/__tests__/cloudflare-detection.test.ts b/src/lib/__tests__/cloudflare-detection.test.ts index 7879b5320..b7c33cf7e 100644 --- a/src/lib/__tests__/cloudflare-detection.test.ts +++ b/src/lib/__tests__/cloudflare-detection.test.ts @@ -3,7 +3,7 @@ import * as path from 'path'; import * as os from 'os'; import { detectCloudflareTarget } from '@lib/cloudflare-detection'; -vi.mock('../../utils/debug'); +vi.mock('@utils/debug'); function makeTmpDir(): string { return fs.mkdtempSync(path.join(os.tmpdir(), 'cloudflare-detect-')); diff --git a/src/lib/__tests__/mcp-role-prompts.test.ts b/src/lib/__tests__/mcp-role-prompts.test.ts index 704f44cf7..be84e1c69 100644 --- a/src/lib/__tests__/mcp-role-prompts.test.ts +++ b/src/lib/__tests__/mcp-role-prompts.test.ts @@ -11,7 +11,7 @@ import { FOLLOW_UP_EXIT_SENTINEL, TAILORED_ROLES, } from '@lib/mcp-role-prompts'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { degradedProfile, type EventVolume, diff --git a/src/lib/__tests__/wizard-spellbook.test.ts b/src/lib/__tests__/wizard-spellbook.test.ts index 727b5f5f1..e23af172b 100644 --- a/src/lib/__tests__/wizard-spellbook.test.ts +++ b/src/lib/__tests__/wizard-spellbook.test.ts @@ -1,14 +1,14 @@ import fs from 'fs/promises'; import os from 'os'; import path from 'path'; -import { Integration } from '../constants'; +import { Integration } from '@shared/constants'; import type { ProgramConfig } from '../programs/program-step'; import { buildSession } from '../wizard-session'; import { writeWizardSpellbook } from '../wizard-spellbook'; -import { downloadSkill, fetchSkillMenu } from '../wizard-tools/tools'; +import { downloadSkill, fetchSkillMenu } from '@agent/tools/tools'; -vi.mock('../wizard-tools/tools', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('@agent/tools/tools', async (importOriginal) => ({ + ...(await importOriginal()), fetchSkillMenu: vi.fn(), downloadSkill: vi.fn(), })); diff --git a/src/lib/detection/__tests__/agentic-progress.test.ts b/src/lib/detection/__tests__/agentic-progress.test.ts index 387bb24fc..41e7f0761 100644 --- a/src/lib/detection/__tests__/agentic-progress.test.ts +++ b/src/lib/detection/__tests__/agentic-progress.test.ts @@ -2,9 +2,9 @@ import { detectProjectsWithAgent } from '../agentic'; import { initializeAgent, runAgent as executeAgent, -} from '@lib/agent/agent-interface'; +} from '@agent/agent-interface'; import { buildSession } from '@lib/wizard-session'; -import { HostResolution } from '@lib/host-resolution'; +import { HostResolution } from '@shared/host-resolution'; import { getUI } from '@ui'; vi.mock('@utils/debug'); @@ -15,8 +15,8 @@ const ui = vi.hoisted(() => ({ pushStatus: vi.fn(), log: { error: vi.fn() }, })); -vi.mock('@lib/agent/agent-interface', async (original) => ({ - ...(await original()), +vi.mock('@agent/agent-interface', async (original) => ({ + ...(await original()), initializeAgent: vi.fn(), runAgent: vi.fn(), })); diff --git a/src/lib/detection/__tests__/agentic-retry.test.ts b/src/lib/detection/__tests__/agentic-retry.test.ts index f0c998262..f1df7e6b3 100644 --- a/src/lib/detection/__tests__/agentic-retry.test.ts +++ b/src/lib/detection/__tests__/agentic-retry.test.ts @@ -6,12 +6,12 @@ import { AgentErrorType, initializeAgent, runAgent, -} from '@lib/agent/agent-interface'; +} from '@agent/agent-interface'; import { buildSession } from '@lib/wizard-session'; -import { HostResolution } from '@lib/host-resolution'; +import { HostResolution } from '@shared/host-resolution'; -vi.mock('@lib/agent/agent-interface', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('@agent/agent-interface', async (importOriginal) => ({ + ...(await importOriginal()), initializeAgent: vi.fn(), runAgent: vi.fn(), })); diff --git a/src/lib/detection/__tests__/framework.test.ts b/src/lib/detection/__tests__/framework.test.ts index 947159368..cd2a333f0 100644 --- a/src/lib/detection/__tests__/framework.test.ts +++ b/src/lib/detection/__tests__/framework.test.ts @@ -2,7 +2,7 @@ import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path'; import { detectFramework } from '@lib/detection/framework'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { ANDROID_AGENT_CONFIG } from '../../../frameworks/android/android-wizard-agent'; import { KMP_AGENT_CONFIG } from '../../../frameworks/kmp/kmp-wizard-agent'; import { ELIXIR_AGENT_CONFIG } from '../../../frameworks/elixir/elixir-wizard-agent'; diff --git a/src/lib/detection/__tests__/package-manager.test.ts b/src/lib/detection/__tests__/package-manager.test.ts index e74e27733..3200bf4fd 100644 --- a/src/lib/detection/__tests__/package-manager.test.ts +++ b/src/lib/detection/__tests__/package-manager.test.ts @@ -14,11 +14,11 @@ import { pubPackageManager, } from '@lib/detection/package-manager'; -vi.mock('../../../utils/debug'); +vi.mock('@utils/debug'); vi.mock('../../../telemetry', () => ({ withProgress: (_name: string, fn: () => unknown) => fn(), })); -vi.mock('../../../utils/analytics', () => ({ +vi.mock('@utils/analytics', () => ({ analytics: { setTag: vi.fn() }, })); diff --git a/src/lib/detection/__tests__/project-scope.test.ts b/src/lib/detection/__tests__/project-scope.test.ts index 0ee4b36e7..dd7e626c3 100644 --- a/src/lib/detection/__tests__/project-scope.test.ts +++ b/src/lib/detection/__tests__/project-scope.test.ts @@ -7,7 +7,7 @@ import { chooseIntegrationProject, scopeInstallDirToProject, } from '@lib/detection/project-scope'; -import { WIZARD_BASIC_INTEGRATION_AGENTIC_DETECTION_FLAG_KEY } from '@lib/constants'; +import { WIZARD_BASIC_INTEGRATION_AGENTIC_DETECTION_FLAG_KEY } from '@shared/constants'; import { authenticate } from '@lib/programs/authenticate'; import { buildSession } from '@lib/wizard-session'; import { analytics } from '@utils/analytics'; diff --git a/src/lib/detection/agentic.ts b/src/lib/detection/agentic.ts index cce567bbc..075298f4a 100644 --- a/src/lib/detection/agentic.ts +++ b/src/lib/detection/agentic.ts @@ -19,7 +19,7 @@ import { buildRunTags, AgentSignals, AgentErrorType, -} from '@lib/agent/agent-interface'; +} from '@agent/agent-interface'; import { isAbsolute, resolve, sep } from 'path'; import { detectNodePackageManagers } from './package-manager.js'; import { @@ -28,7 +28,7 @@ import { CallType, getSkillsBaseUrl, HAIKU_MODEL, -} from '@lib/constants'; +} from '@shared/constants'; import { analytics } from '@utils/analytics'; import type { WizardSession } from '@lib/wizard-session'; import type { WizardRunOptions } from '@utils/types'; diff --git a/src/lib/detection/context.ts b/src/lib/detection/context.ts index 5ecb68925..8e0d845d7 100644 --- a/src/lib/detection/context.ts +++ b/src/lib/detection/context.ts @@ -7,7 +7,7 @@ */ import * as semver from 'semver'; -import { DETECTION_TIMEOUT_MS } from '@lib/constants'; +import { DETECTION_TIMEOUT_MS } from '@shared/constants'; import type { FrameworkConfig } from '@lib/framework-config'; import type { WizardRunOptions } from '@utils/types'; diff --git a/src/lib/detection/framework.ts b/src/lib/detection/framework.ts index 4efd9f6bf..07dfa2c35 100644 --- a/src/lib/detection/framework.ts +++ b/src/lib/detection/framework.ts @@ -6,7 +6,7 @@ * (or undefined). No store mutations, no UI calls. */ -import { Integration, DETECTION_TIMEOUT_MS } from '@lib/constants'; +import { Integration, DETECTION_TIMEOUT_MS } from '@shared/constants'; import { FRAMEWORK_REGISTRY } from '@lib/registry'; /** diff --git a/src/lib/detection/project-scope.ts b/src/lib/detection/project-scope.ts index 5ed7098d3..fd81cca08 100644 --- a/src/lib/detection/project-scope.ts +++ b/src/lib/detection/project-scope.ts @@ -14,7 +14,7 @@ import { FRAMEWORK_REGISTRY } from '@lib/registry'; import { Integration, WIZARD_BASIC_INTEGRATION_AGENTIC_DETECTION_FLAG_KEY, -} from '@lib/constants'; +} from '@shared/constants'; import type { WizardSession } from '@lib/wizard-session'; import { getUI } from '@ui/index'; import { analytics } from '@utils/analytics'; diff --git a/src/lib/framework-config.ts b/src/lib/framework-config.ts index 5bbc7440b..dd33fbe7b 100644 --- a/src/lib/framework-config.ts +++ b/src/lib/framework-config.ts @@ -1,4 +1,4 @@ -import type { Integration } from './constants'; +import type { Integration } from '@shared/constants'; import type { WizardRunOptions } from '@utils/types'; import type { PackageManagerDetector } from './detection/package-manager'; diff --git a/src/lib/mcp-project-profile.ts b/src/lib/mcp-project-profile.ts index 12a398871..a5b810fcd 100644 --- a/src/lib/mcp-project-profile.ts +++ b/src/lib/mcp-project-profile.ts @@ -25,7 +25,7 @@ */ import axios from 'axios'; -import { WIZARD_USER_AGENT } from './constants'; +import { WIZARD_USER_AGENT } from '@shared/constants'; import { logToFile } from '@utils/debug'; // Time-box every probe call. The scout sits on the critical path between diff --git a/src/lib/mcp-role-prompts.ts b/src/lib/mcp-role-prompts.ts index 5b8921f73..0fbf980dd 100644 --- a/src/lib/mcp-role-prompts.ts +++ b/src/lib/mcp-role-prompts.ts @@ -19,7 +19,7 @@ * 3. Unknown role → DEFAULT_KIT. */ -import type { Integration } from './constants'; +import type { Integration } from '@shared/constants'; import type { ProductPresence, ProjectDataProfile, diff --git a/src/lib/oauth/program-scopes.ts b/src/lib/oauth/program-scopes.ts index a4126b651..453b3c48b 100644 --- a/src/lib/oauth/program-scopes.ts +++ b/src/lib/oauth/program-scopes.ts @@ -35,7 +35,7 @@ import type { ProgramId } from '@lib/programs/program-registry'; import { WIZARD_OAUTH_SCOPES, WIZARD_PROVISIONING_SCOPES, -} from '@lib/constants'; +} from '@shared/constants'; /** * Extra scopes the MCP tutorial needs on top of `WIZARD_OAUTH_SCOPES`. diff --git a/src/lib/programs/__tests__/agent-skill.test.ts b/src/lib/programs/__tests__/agent-skill.test.ts index b836f0486..913ce5d01 100644 --- a/src/lib/programs/__tests__/agent-skill.test.ts +++ b/src/lib/programs/__tests__/agent-skill.test.ts @@ -5,7 +5,7 @@ import { } from '@lib/programs/agent-skill/index'; import type { ProgramRun } from '@lib/programs/program-run'; import { buildSession, RunPhase } from '@lib/wizard-session'; -import { HostResolution } from '@lib/host-resolution'; +import { HostResolution } from '@shared/host-resolution'; const baseOpts: SkillProgramOptions = { skillId: 'error-tracking-setup', diff --git a/src/lib/programs/__tests__/error-tracking.test.ts b/src/lib/programs/__tests__/error-tracking.test.ts index 5ecef5279..bf49fb9c5 100644 --- a/src/lib/programs/__tests__/error-tracking.test.ts +++ b/src/lib/programs/__tests__/error-tracking.test.ts @@ -1,10 +1,10 @@ import { beforeEach, describe, expect, test, vi } from 'vitest'; import type { ProgramRun } from '@lib/programs/program-run'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import type { AgenticDetectionReport } from '@lib/detection/agentic'; import { detectFramework } from '@lib/detection/index'; -import { ErrorCodes } from '@lib/errors'; +import { ErrorCodes } from '@shared/errors'; import { ERROR_TRACKING_TIPS } from '@lib/programs/error-tracking/content/tips'; import { ERROR_TRACKING_PROJECT_PATH_KEY, diff --git a/src/lib/programs/__tests__/flow-traces.test.ts b/src/lib/programs/__tests__/flow-traces.test.ts index 43b532b89..769c1759e 100644 --- a/src/lib/programs/__tests__/flow-traces.test.ts +++ b/src/lib/programs/__tests__/flow-traces.test.ts @@ -18,10 +18,10 @@ import { OutroKind, type WizardSession, } from '@lib/wizard-session'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { FRAMEWORK_REGISTRY } from '@lib/registry'; -import { HostResolution } from '@lib/host-resolution'; -import { WizardReadiness } from '@lib/health-checks/readiness'; +import { HostResolution } from '@shared/host-resolution'; +import { WizardReadiness } from '@shared/health-checks/readiness'; import { analytics } from '@utils/analytics'; import { PROGRAM_REGISTRY, diff --git a/src/lib/programs/__tests__/mcp-analytics.test.ts b/src/lib/programs/__tests__/mcp-analytics.test.ts index e9a8546dc..a2c822c00 100644 --- a/src/lib/programs/__tests__/mcp-analytics.test.ts +++ b/src/lib/programs/__tests__/mcp-analytics.test.ts @@ -7,7 +7,7 @@ describe('MCP_ANALYTICS_ABORT_CASES', () => { // These are the exact `[ABORT] ` strings the mcp-analytics skill // emits (context-mill `context/skills/mcp-analytics/description.md`), with // the `[ABORT] ` prefix already stripped — matching what the runner passes - // to `AbortCase.match` (src/lib/agent/runner/sequence/linear.ts). + // to `AbortCase.match` (src/agent/runner/sequence/linear.ts). const reasons = [ 'no mcp server found', 'unsupported language for mcp analytics', diff --git a/src/lib/programs/__tests__/posthog-integration-prompt.test.ts b/src/lib/programs/__tests__/posthog-integration-prompt.test.ts index cb2484360..11978acbf 100644 --- a/src/lib/programs/__tests__/posthog-integration-prompt.test.ts +++ b/src/lib/programs/__tests__/posthog-integration-prompt.test.ts @@ -7,7 +7,7 @@ * to the skill's workflow, and the hard guard against every other category. */ -import { WIZARD_DEFAULT_AIO_LOGS_FLAG_KEY } from '@lib/constants'; +import { WIZARD_DEFAULT_AIO_LOGS_FLAG_KEY } from '@shared/constants'; import { posthogIntegrationConfig } from '@lib/programs/posthog-integration/index'; import { analytics } from '@utils/analytics'; import { promptFor } from './helpers/integration-prompt.no-jest'; diff --git a/src/lib/programs/__tests__/refresh-access-token-if-needed.test.ts b/src/lib/programs/__tests__/refresh-access-token-if-needed.test.ts index 5138af7cb..92f17e703 100644 --- a/src/lib/programs/__tests__/refresh-access-token-if-needed.test.ts +++ b/src/lib/programs/__tests__/refresh-access-token-if-needed.test.ts @@ -1,7 +1,10 @@ import { refreshAccessTokenIfNeeded } from '../authenticate'; import { refreshAccessToken } from '@utils/oauth'; import { OAuthError } from '@utils/oauth-errors'; -import { isGrantRevoked, resetAuthSessionState } from '@lib/auth-session-state'; +import { + isGrantRevoked, + resetAuthSessionState, +} from '@shared/auth-session-state'; import type { WizardSession, Credentials } from '@lib/wizard-session'; vi.mock('@utils/oauth', () => ({ refreshAccessToken: vi.fn() })); diff --git a/src/lib/programs/__tests__/replay-vision.test.ts b/src/lib/programs/__tests__/replay-vision.test.ts index a9146d2af..c049a66b4 100644 --- a/src/lib/programs/__tests__/replay-vision.test.ts +++ b/src/lib/programs/__tests__/replay-vision.test.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from 'vitest'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { replayVisionConfig, REPLAY_VISION_SUPPORTED, diff --git a/src/lib/programs/__tests__/run-agent-legacy.test.ts b/src/lib/programs/__tests__/run-agent-legacy.test.ts index fb4b73139..5f03cfd46 100644 --- a/src/lib/programs/__tests__/run-agent-legacy.test.ts +++ b/src/lib/programs/__tests__/run-agent-legacy.test.ts @@ -2,10 +2,10 @@ import { runNonInteractive } from '@lib/runners/run-non-interactive'; import { runWizard } from '@lib/runners/run-wizard'; import { authenticate } from '@lib/programs/authenticate'; import { runProgramAgent } from '../run-agent-legacy'; -import { runAgent, RunOutcome, type RunResult } from '@lib/agent/runner'; -import { Harness, Sequence } from '@lib/constants'; +import { runAgent, RunOutcome, type RunResult } from '@agent/runner'; +import { Harness, Sequence } from '@shared/constants'; import { buildSession, OutroKind } from '@lib/wizard-session'; -import { HostResolution } from '@lib/host-resolution'; +import { HostResolution } from '@shared/host-resolution'; import { LoggingUI } from '@ui/logging-ui'; import { InkUI } from '@ui/tui/ink-ui'; import { startTUI } from '@ui/tui/start-tui'; @@ -21,16 +21,16 @@ vi.mock('@env', async (original) => ({ ...(await original()), IS_PRODUCTION_BUILD: false, })); -vi.mock('@lib/local-dev', async (original) => ({ - ...(await original()), +vi.mock('@shared/local-dev', async (original) => ({ + ...(await original()), checkLocalServices: vi.fn().mockResolvedValue(null), })); vi.mock('@utils/environment', async (original) => ({ ...(await original()), readEnvironment: () => ({}), })); -vi.mock('@lib/gateway-session', async (original) => ({ - ...(await original()), +vi.mock('@agent/gateway-session', async (original) => ({ + ...(await original()), configureGatewayFromCIEnvironment: vi.fn(), })); vi.mock('@lib/task-stream/index', () => ({ @@ -56,15 +56,15 @@ vi.mock('@utils/analytics', () => ({ }, sessionProperties: () => ({}), })); -vi.mock('@lib/agent/runner', async (original) => ({ - ...(await original()), +vi.mock('@agent/runner', async (original) => ({ + ...(await original()), runAgent: vi.fn(), })); vi.mock('@lib/programs/authenticate', () => ({ authenticate: vi.fn().mockResolvedValue(undefined), refreshAccessTokenIfNeeded: vi.fn().mockResolvedValue(undefined), })); -vi.mock('@lib/agent/claude-settings', () => ({ +vi.mock('@shared/claude-settings', () => ({ checkAllSettingsConflicts: vi.fn().mockReturnValue([]), restoreClaudeSettings: vi.fn(), })); diff --git a/src/lib/programs/__tests__/self-driving-detect.test.ts b/src/lib/programs/__tests__/self-driving-detect.test.ts index bce8b973a..a2ac4f929 100644 --- a/src/lib/programs/__tests__/self-driving-detect.test.ts +++ b/src/lib/programs/__tests__/self-driving-detect.test.ts @@ -22,8 +22,8 @@ import { PROJECT_MANIFESTS, type AgenticDetectionReport, } from '@lib/detection/agentic'; -import { Integration } from '@lib/constants'; -import { WIZARD_TOOL_NAMES } from '@lib/wizard-tools'; +import { Integration } from '@shared/constants'; +import { WIZARD_TOOL_NAMES } from '@agent/tools'; import { buildSession } from '@lib/wizard-session'; import type { Mock } from 'vitest'; diff --git a/src/lib/programs/__tests__/self-driving-prompt.test.ts b/src/lib/programs/__tests__/self-driving-prompt.test.ts index d23e7c1bc..a2b886c5d 100644 --- a/src/lib/programs/__tests__/self-driving-prompt.test.ts +++ b/src/lib/programs/__tests__/self-driving-prompt.test.ts @@ -1,6 +1,6 @@ import { buildSelfDrivingPrompt } from '@lib/programs/self-driving/prompt'; -import type { PromptContext } from '@lib/agent/agent-runner'; -import { HostResolution } from '@lib/host-resolution'; +import type { PromptContext } from '@agent/agent-runner'; +import { HostResolution } from '@shared/host-resolution'; import type { DetectedSource } from '@lib/warehouse-sources/types'; const ctx: PromptContext = { diff --git a/src/lib/programs/__tests__/warehouse-ask-timeout.test.ts b/src/lib/programs/__tests__/warehouse-ask-timeout.test.ts index c74c5f766..77850402d 100644 --- a/src/lib/programs/__tests__/warehouse-ask-timeout.test.ts +++ b/src/lib/programs/__tests__/warehouse-ask-timeout.test.ts @@ -22,7 +22,7 @@ import { warehouseSourceConfig } from '@lib/programs/warehouse-source/index'; import { LONGER_ASK_TIMEOUT_MS, DEFAULT_ASK_TIMEOUT_MS, -} from '@lib/wizard-ask-bridge'; +} from '@agent/wizard-ask-bridge'; function session(): WizardSession { return { installDir: '/tmp/app', frameworkContext: {} } as WizardSession; diff --git a/src/lib/programs/__tests__/web-analytics-doctor-detect.test.ts b/src/lib/programs/__tests__/web-analytics-doctor-detect.test.ts index 2d689c11c..65f338d87 100644 --- a/src/lib/programs/__tests__/web-analytics-doctor-detect.test.ts +++ b/src/lib/programs/__tests__/web-analytics-doctor-detect.test.ts @@ -6,7 +6,7 @@ import { webAnalyticsDoctorConfig, WEB_ANALYTICS_ABORT_CASES, } from '@lib/programs/web-analytics-doctor/index'; -import { WIZARD_TOOL_NAMES } from '@lib/wizard-tools'; +import { WIZARD_TOOL_NAMES } from '@agent/tools'; import { buildSession } from '@lib/wizard-session'; function makeTmpDir(): string { diff --git a/src/lib/programs/agent-skill/index.ts b/src/lib/programs/agent-skill/index.ts index ace6ab19d..8ab764911 100644 --- a/src/lib/programs/agent-skill/index.ts +++ b/src/lib/programs/agent-skill/index.ts @@ -20,7 +20,7 @@ */ import type { ProgramConfig } from '@lib/programs/program-step'; -import type { AbortCase } from '@lib/agent/agent-runner'; +import type { AbortCase } from '@agent/agent-runner'; import type { ProgramRun } from '@lib/programs/program-run'; import { AGENT_SKILL_STEPS } from './steps.js'; import { getContentBlocks } from './content/index.js'; diff --git a/src/lib/programs/audit/detect.ts b/src/lib/programs/audit/detect.ts index 2cfa299a5..37ee475b2 100644 --- a/src/lib/programs/audit/detect.ts +++ b/src/lib/programs/audit/detect.ts @@ -1,5 +1,5 @@ -import type { AbortCase } from '@lib/agent/agent-runner'; -import { ErrorCodes } from '@lib/errors'; +import type { AbortCase } from '@agent/agent-runner'; +import { ErrorCodes } from '@shared/errors'; /** `[ABORT] ` cases the audit skill can emit. Reason strings are * defined in the skill's `Abort statuses` section. */ diff --git a/src/lib/programs/audit/index.ts b/src/lib/programs/audit/index.ts index 261fbaefc..110f09816 100644 --- a/src/lib/programs/audit/index.ts +++ b/src/lib/programs/audit/index.ts @@ -6,7 +6,7 @@ import type { ProgramStep, ProgramConfig } from '@lib/programs/program-step'; import type { ProgramRun } from '@lib/programs/program-run'; import type { WizardSession } from '@lib/wizard-session'; import { OutroKind } from '@lib/wizard-session'; -import { WIZARD_TOOL_NAMES } from '@lib/wizard-tools'; +import { WIZARD_TOOL_NAMES } from '@agent/tools'; import { headlessOption, regionOption } from '@lib/headless-mode'; import { AUDIT_ABORT_CASES } from './detect.js'; import { diff --git a/src/lib/programs/audit/types.ts b/src/lib/programs/audit/types.ts index 0a705ce24..a799d0f3b 100644 --- a/src/lib/programs/audit/types.ts +++ b/src/lib/programs/audit/types.ts @@ -5,7 +5,7 @@ import { coerceAuditChecks, type AuditCheck, type AuditStatus, -} from '@lib/audit-ledger'; +} from '@shared/audit-ledger'; // The ledger contract lives in `@lib/audit-ledger`; re-exported so the audit // views and the ledger watcher keep their import path. diff --git a/src/lib/programs/authenticate.ts b/src/lib/programs/authenticate.ts index 8644a328c..109adc9f4 100644 --- a/src/lib/programs/authenticate.ts +++ b/src/lib/programs/authenticate.ts @@ -15,7 +15,7 @@ import type { ProgramId } from '@lib/programs/program-registry'; import { getOrAskForProjectData } from '@utils/setup-utils'; import { refreshAccessToken } from '@utils/oauth'; import { OAuthError } from '@utils/oauth-errors'; -import { markGrantRevoked } from '@lib/auth-session-state'; +import { markGrantRevoked } from '@shared/auth-session-state'; import { analytics, groupsFromUser } from '@utils/analytics'; import { getUI } from '@ui'; import { logToFile } from '@utils/debug'; diff --git a/src/lib/programs/dispatch-family.ts b/src/lib/programs/dispatch-family.ts index a730d8198..e36831674 100644 --- a/src/lib/programs/dispatch-family.ts +++ b/src/lib/programs/dispatch-family.ts @@ -2,18 +2,18 @@ import type { Arguments } from 'yargs'; import { auditConfig } from '@lib/programs/audit/index'; import { AUDIT_CHECKS_FILE } from '@lib/programs/audit/types'; -import { WIZARD_TOOL_NAMES } from '@lib/wizard-tools'; +import { WIZARD_TOOL_NAMES } from '@agent/tools'; import { agentSkillConfig } from '@lib/programs/program-registry'; import { webAnalyticsDoctorConfig } from '@lib/programs/web-analytics-doctor/index'; import type { ProgramConfig } from '@lib/programs/program-step'; -import { getSkillsBaseUrl } from '@lib/constants'; -import { fetchSkillMenu, type CliEntry } from '@lib/wizard-tools'; +import { getSkillsBaseUrl } from '@shared/constants'; +import { fetchSkillMenu, type CliEntry } from '@agent/tools'; import { analytics } from '@utils/analytics'; import { dispatchProgram } from '../../commands/factories/shared'; import type { Command } from '../../commands/command'; -import { ErrorCodes } from '@lib/errors'; -import { emitWizardError } from '@lib/errors'; +import { ErrorCodes } from '@shared/errors'; +import { emitWizardError } from '@shared/errors'; /** * Capture a CLI dispatch error, flush analytics, and exit. The wizard never diff --git a/src/lib/programs/error-tracking-upload-source-maps/detect.ts b/src/lib/programs/error-tracking-upload-source-maps/detect.ts index 2d81b0061..15ff114af 100644 --- a/src/lib/programs/error-tracking-upload-source-maps/detect.ts +++ b/src/lib/programs/error-tracking-upload-source-maps/detect.ts @@ -17,8 +17,8 @@ import { safeReadFile, } from '@utils/bounded-fs'; import type { WizardSession } from '@lib/wizard-session'; -import type { AbortCase } from '@lib/agent/agent-runner'; -import { ErrorCodes } from '@lib/errors'; +import type { AbortCase } from '@agent/agent-runner'; +import { ErrorCodes } from '@shared/errors'; /** * Skill variants published under the `error-tracking-upload-source-maps` diff --git a/src/lib/programs/error-tracking-upload-source-maps/prompt.ts b/src/lib/programs/error-tracking-upload-source-maps/prompt.ts index 3d19efceb..df2539095 100644 --- a/src/lib/programs/error-tracking-upload-source-maps/prompt.ts +++ b/src/lib/programs/error-tracking-upload-source-maps/prompt.ts @@ -1,4 +1,4 @@ -import { AgentSignals } from '@lib/agent/agent-interface'; +import { AgentSignals } from '@agent/agent-interface'; import type { SkillVariant } from './detect.js'; export type SourceMapsUploadPromptParams = { diff --git a/src/lib/programs/error-tracking/detect-agentic.ts b/src/lib/programs/error-tracking/detect-agentic.ts index 5f7fd5268..1967b79c4 100644 --- a/src/lib/programs/error-tracking/detect-agentic.ts +++ b/src/lib/programs/error-tracking/detect-agentic.ts @@ -11,7 +11,7 @@ * - The scan bills to error-tracking. */ -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { resolveProjectDir, type AgenticDetectionReport, diff --git a/src/lib/programs/error-tracking/index.ts b/src/lib/programs/error-tracking/index.ts index 68e7986b5..b28ae779d 100644 --- a/src/lib/programs/error-tracking/index.ts +++ b/src/lib/programs/error-tracking/index.ts @@ -1,4 +1,4 @@ -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { detectFramework } from '@lib/detection/index'; import { scopeInstallDirToProject } from '@lib/detection/project-scope'; import { FRAMEWORK_REGISTRY } from '@lib/registry'; @@ -16,7 +16,7 @@ import type { WizardSession } from '@lib/wizard-session'; import { preinstallPostHogCliOnce } from '@lib/programs/shared/posthog-cli-preinstall'; import { analytics } from '@utils/analytics'; import { wizardAbort } from '@utils/wizard-abort'; -import { ErrorCodes } from '@lib/errors'; +import { ErrorCodes } from '@shared/errors'; const ERROR_TRACKING_REPORT_FILE = 'posthog-error-tracking-report.md'; const ERROR_TRACKING_DOCS_URL = 'https://posthog.com/docs/error-tracking'; diff --git a/src/lib/programs/events-audit/constants.ts b/src/lib/programs/events-audit/constants.ts index a70c343df..8d381e65c 100644 --- a/src/lib/programs/events-audit/constants.ts +++ b/src/lib/programs/events-audit/constants.ts @@ -8,4 +8,4 @@ export { EVENTS_AUDIT_REPORT_FILE as SETUP_REPORT_FILE, EVENT_INVENTORY_FILE, EVENT_INVENTORY_PART_PATTERN, -} from '@lib/constants'; +} from '@shared/constants'; diff --git a/src/lib/programs/events-audit/index.ts b/src/lib/programs/events-audit/index.ts index 4cfa397f0..850ae62af 100644 --- a/src/lib/programs/events-audit/index.ts +++ b/src/lib/programs/events-audit/index.ts @@ -4,7 +4,7 @@ import type { WizardSession } from '@lib/wizard-session'; import { OutroKind } from '@lib/wizard-session'; import { SPINNER_MESSAGE } from '@lib/framework-config'; import { isUsingTypeScript } from '@utils/setup-utils'; -import { WIZARD_TOOL_NAMES } from '@lib/wizard-tools'; +import { WIZARD_TOOL_NAMES } from '@agent/tools'; import { EVENTS_AUDIT_PROGRAM } from './steps.js'; import { AUDIT_CHECKS_FILE, AUDIT_CHECKS_KEY } from '@lib/programs/audit/types'; import { seedAuditLedger } from '@lib/programs/audit/seed'; diff --git a/src/lib/programs/mcp-analytics/index.ts b/src/lib/programs/mcp-analytics/index.ts index f9199d76e..4b62d407b 100644 --- a/src/lib/programs/mcp-analytics/index.ts +++ b/src/lib/programs/mcp-analytics/index.ts @@ -1,5 +1,5 @@ -import type { AbortCase } from '@lib/agent/agent-runner'; -import { ErrorCodes } from '@lib/errors'; +import type { AbortCase } from '@agent/agent-runner'; +import { ErrorCodes } from '@shared/errors'; import { createSkillProgram } from '@lib/programs/agent-skill/index'; const MCP_ANALYTICS_REPORT_FILE = 'posthog-mcp-analytics-report.md'; diff --git a/src/lib/programs/migration/index.ts b/src/lib/programs/migration/index.ts index 27cf0b3d0..2fc157746 100644 --- a/src/lib/programs/migration/index.ts +++ b/src/lib/programs/migration/index.ts @@ -1,6 +1,6 @@ import type { ProgramConfig } from '@lib/programs/program-step'; -import type { AbortCase } from '@lib/agent/agent-runner'; -import { WIZARD_TOOL_NAMES } from '@lib/wizard-tools'; +import type { AbortCase } from '@agent/agent-runner'; +import { WIZARD_TOOL_NAMES } from '@agent/tools'; import { MIGRATION_PROGRAM } from './steps.js'; import { getContentBlocks } from './content/index.js'; diff --git a/src/lib/programs/posthog-doctor/fetch.ts b/src/lib/programs/posthog-doctor/fetch.ts index b0a5f2e44..f285359de 100644 --- a/src/lib/programs/posthog-doctor/fetch.ts +++ b/src/lib/programs/posthog-doctor/fetch.ts @@ -1,7 +1,7 @@ import axios from 'axios'; import { analytics } from '@utils/analytics'; -import { handleApiError } from '@lib/api'; -import { WIZARD_USER_AGENT } from '@lib/constants'; +import { handleApiError } from '@shared/api'; +import { WIZARD_USER_AGENT } from '@shared/constants'; import { HealthIssueListResponseSchema, type HealthIssue } from './types'; export async function fetchHealthIssues( diff --git a/src/lib/programs/posthog-doctor/index.ts b/src/lib/programs/posthog-doctor/index.ts index 8ea70acf1..cf57eb9c7 100644 --- a/src/lib/programs/posthog-doctor/index.ts +++ b/src/lib/programs/posthog-doctor/index.ts @@ -1,5 +1,5 @@ import type { ProgramConfig } from '@lib/programs/program-step'; -import { WIZARD_TOOL_NAMES } from '@lib/wizard-tools'; +import { WIZARD_TOOL_NAMES } from '@agent/tools'; import { POSTHOG_DOCTOR_PROGRAM } from './steps.js'; export const posthogDoctorConfig: ProgramConfig = { diff --git a/src/lib/programs/posthog-doctor/kind-metadata.ts b/src/lib/programs/posthog-doctor/kind-metadata.ts index 885e1062e..fc9d5859d 100644 --- a/src/lib/programs/posthog-doctor/kind-metadata.ts +++ b/src/lib/programs/posthog-doctor/kind-metadata.ts @@ -1,4 +1,4 @@ -import { POSTHOG_DOCS_URL } from '@lib/constants'; +import { POSTHOG_DOCS_URL } from '@shared/constants'; export interface KindMeta { title: string; diff --git a/src/lib/programs/posthog-integration/constants.ts b/src/lib/programs/posthog-integration/constants.ts index a0bb8d34b..957c41a14 100644 --- a/src/lib/programs/posthog-integration/constants.ts +++ b/src/lib/programs/posthog-integration/constants.ts @@ -4,4 +4,4 @@ * can name it without importing this program. */ -export { EVENT_PLAN_FILE } from '@lib/constants'; +export { EVENT_PLAN_FILE } from '@shared/constants'; diff --git a/src/lib/programs/posthog-integration/index.ts b/src/lib/programs/posthog-integration/index.ts index 5855ccd62..b9f4b9800 100644 --- a/src/lib/programs/posthog-integration/index.ts +++ b/src/lib/programs/posthog-integration/index.ts @@ -1,10 +1,10 @@ import type { ProgramConfig, ProgramStep } from '@lib/programs/program-step'; import { runProgramAgent } from '@lib/programs/run-agent-legacy'; import type { ProgramRun } from '@lib/programs/program-run'; -import { WIZARD_TOOL_NAMES } from '@lib/wizard-tools'; +import { WIZARD_TOOL_NAMES } from '@agent/tools'; import type { WizardSession } from '@lib/wizard-session'; import { mayReportScanResults, OutroKind, RunPhase } from '@lib/wizard-session'; -import { AgentSignals } from '@lib/agent/agent-interface'; +import { AgentSignals } from '@agent/agent-interface'; import { DEFAULT_PACKAGE_INSTALLATION, SPINNER_MESSAGE, @@ -15,17 +15,17 @@ import { detectFramework, gatherFrameworkContext } from '@lib/detection/index'; import { scopeInstallDirToProject } from '@lib/detection/project-scope'; import { FRAMEWORK_REGISTRY } from '@lib/registry'; import { wizardAbort } from '@utils/wizard-abort'; -import { ErrorCodes } from '@lib/errors'; +import { ErrorCodes } from '@shared/errors'; import { WIZARD_DEFAULT_AIO_LOGS_FLAG_KEY, WIZARD_INTERACTION_EVENT_NAME, -} from '@lib/constants'; +} from '@shared/constants'; import { getUI } from '@ui/index'; import { requestDeepLink } from '@utils/provisioning'; import { openTrackedLink, withUtm } from '@utils/links'; -import type { HostResolution } from '@lib/host-resolution'; +import type { HostResolution } from '@shared/host-resolution'; import { getDetectedWarehouseSources } from '@lib/programs/warehouse-source/detect'; -import { shouldDisableAsk } from '@lib/agent/agent-runner'; +import { shouldDisableAsk } from '@agent/agent-runner'; import { POSTHOG_INTEGRATION_PROGRAM } from './steps.js'; import { getContentBlocks } from './content/index.js'; import { buildCodingAgentPrompt } from './handoff.js'; diff --git a/src/lib/programs/program-registry.ts b/src/lib/programs/program-registry.ts index 9bd564bb3..2b001e56c 100644 --- a/src/lib/programs/program-registry.ts +++ b/src/lib/programs/program-registry.ts @@ -11,7 +11,7 @@ */ import type { ProgramConfig } from './program-step.js'; -import { POSTHOG_DOCS_URL } from '../constants.js'; +import { POSTHOG_DOCS_URL } from '@shared/constants.js'; import { posthogIntegrationConfig } from './posthog-integration/index.js'; import { revenueAnalyticsConfig } from './revenue-analytics/index.js'; import { warehouseSourceConfig } from './warehouse-source/index.js'; diff --git a/src/lib/programs/program-run.ts b/src/lib/programs/program-run.ts index 35a3ea90f..523d3bbbe 100644 --- a/src/lib/programs/program-run.ts +++ b/src/lib/programs/program-run.ts @@ -5,7 +5,7 @@ * agent `RunConfig.hooks`. */ -import type { AgentRunDefinition } from '@lib/agent/runner'; +import type { AgentRunDefinition } from '@agent/runner'; import type { Credentials, WizardSession } from '@lib/wizard-session'; export interface ProgramRun extends AgentRunDefinition { diff --git a/src/lib/programs/program-step.ts b/src/lib/programs/program-step.ts index 8fe28bb8a..869e823d1 100644 --- a/src/lib/programs/program-step.ts +++ b/src/lib/programs/program-step.ts @@ -3,9 +3,9 @@ import type { DiscoveredFeature, TaskNotice, } from '@lib/wizard-session'; -import type { WizardReadinessResult } from '@lib/health-checks/readiness'; +import type { WizardReadinessResult } from '@shared/health-checks/readiness'; import type { ProgramRun } from '@lib/programs/program-run'; -import type { Integration } from '@lib/constants'; +import type { Integration } from '@shared/constants'; import type { FrameworkConfig } from '@lib/framework-config'; import type { ContentBlock } from '@ui/tui/primitives/index'; import type { WizardStore } from '@ui/tui/store'; diff --git a/src/lib/programs/replay-vision/index.ts b/src/lib/programs/replay-vision/index.ts index 046f76e25..637f162f5 100644 --- a/src/lib/programs/replay-vision/index.ts +++ b/src/lib/programs/replay-vision/index.ts @@ -1,5 +1,5 @@ -import type { AbortCase } from '@lib/agent/agent-runner'; -import { Integration } from '@lib/constants'; +import type { AbortCase } from '@agent/agent-runner'; +import { Integration } from '@shared/constants'; import { detectFramework, gatherFrameworkContext } from '@lib/detection/index'; import { scopeInstallDirToProject } from '@lib/detection/project-scope'; import { FRAMEWORK_REGISTRY } from '@lib/registry'; @@ -14,7 +14,7 @@ import type { import type { WizardSession } from '@lib/wizard-session'; import { analytics } from '@utils/analytics'; import { wizardAbort } from '@utils/wizard-abort'; -import { ErrorCodes } from '@lib/errors'; +import { ErrorCodes } from '@shared/errors'; const REPLAY_VISION_REPORT_FILE = 'posthog-replay-vision-report.md'; diff --git a/src/lib/programs/revenue-analytics/detect.ts b/src/lib/programs/revenue-analytics/detect.ts index de75eae0b..7089e6e51 100644 --- a/src/lib/programs/revenue-analytics/detect.ts +++ b/src/lib/programs/revenue-analytics/detect.ts @@ -7,7 +7,7 @@ import { existsSync, statSync } from 'fs'; import type { WizardSession } from '@lib/wizard-session'; -import type { AbortCase } from '@lib/agent/agent-runner'; +import type { AbortCase } from '@agent/agent-runner'; import { findPackageJsons } from '@lib/programs/shared/package-scanning'; export { diff --git a/src/lib/programs/revenue-analytics/index.ts b/src/lib/programs/revenue-analytics/index.ts index f75778bd1..9194f9e70 100644 --- a/src/lib/programs/revenue-analytics/index.ts +++ b/src/lib/programs/revenue-analytics/index.ts @@ -1,5 +1,5 @@ import type { ProgramConfig } from '@lib/programs/program-step'; -import { WIZARD_TOOL_NAMES } from '@lib/wizard-tools'; +import { WIZARD_TOOL_NAMES } from '@agent/tools'; import { REVENUE_ANALYTICS_PROGRAM } from './steps.js'; import { REVENUE_ABORT_CASES } from './detect.js'; import { getContentBlocks } from './content/index.js'; diff --git a/src/lib/programs/run-agent-legacy.ts b/src/lib/programs/run-agent-legacy.ts index 0efa87942..2e0998789 100644 --- a/src/lib/programs/run-agent-legacy.ts +++ b/src/lib/programs/run-agent-legacy.ts @@ -26,27 +26,27 @@ import { type RunConfig, type RunInput, type SwitchboardCtx, -} from '@lib/agent/runner'; -import type { ProgramBinding } from '@lib/agent/runner/switchboard'; +} from '@agent/runner'; +import type { ProgramBinding } from '@agent/runner/switchboard'; import type { ProgramRun } from './program-run'; -import { buildRunTags } from '@lib/agent/agent-interface'; +import { buildRunTags } from '@agent/agent-interface'; import { backupAndFixClaudeSettings, checkAllSettingsConflicts, classifySettingsConflicts, restoreClaudeSettings, -} from '@lib/agent/claude-settings'; -import { flushScanReport } from '@lib/yara-hooks'; +} from '@shared/claude-settings'; +import { flushScanReport } from '@agent/yara-hooks'; import { evaluateWizardReadiness, WizardReadiness, SIGNUP_WIZARD_READINESS_CONFIG, getBlockingServiceKeys, SERVICE_LABELS, -} from '@lib/health-checks/readiness'; +} from '@shared/health-checks/readiness'; import { enableDebugLogs, logToFile, initLogFile } from '@utils/debug'; import { registerCleanup, wizardAbort } from '@utils/wizard-abort'; -import { ErrorCodes } from '@lib/errors'; +import { ErrorCodes } from '@shared/errors'; import { isNonInteractiveEnvironment } from '@utils/environment'; import { getSkillsBaseUrl, @@ -54,7 +54,7 @@ import { WIZARD_ORCHESTRATOR_FLAG_KEY, WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY, type Integration, -} from '@lib/constants'; +} from '@shared/constants'; import { FRAMEWORK_REGISTRY } from '@lib/registry'; import { postAuthGateSteps, type ProgramConfig } from './program-step'; import { authenticate, refreshAccessTokenIfNeeded } from './authenticate'; diff --git a/src/lib/programs/self-driving/ARCHITECTURE.md b/src/lib/programs/self-driving/ARCHITECTURE.md index c24073007..3b23569ea 100644 --- a/src/lib/programs/self-driving/ARCHITECTURE.md +++ b/src/lib/programs/self-driving/ARCHITECTURE.md @@ -25,7 +25,7 @@ anchors are point-in-time — the symbol names are the durable part. | The ordered steps | `src/lib/programs/self-driving/prompt.ts` | | What each step _does_ | `context-mill/context/skills/self-driving/references/*.md` | | Program registration / lifecycle | `src/lib/programs/self-driving/index.ts` | -| `wizard_ask` / `.env` tools | `src/lib/wizard-tools.ts`, `src/lib/wizard-ask-bridge.ts` | +| `wizard_ask` / `.env` tools | `src/agent/tools/tools.ts`, `src/agent/wizard-ask-bridge.ts` | | OAuth scopes (+ prod ceiling) | `src/lib/oauth/program-scopes.ts` (§3, §7) | | Signals models / MCP / sync | `posthog/products/signals/backend/…` (§5) | | Why a team gets no findings | §6 | @@ -167,10 +167,10 @@ in `buildOutroData` (no auth deep-link — §7 item 7). CLI: (the agent's working dir and detection target). **Runner & agent loop (generic — not Signals-aware).** `runProgram` -(`src/lib/agent/agent-runner.ts`) is the fixed pipeline +(`src/agent/agent-runner.ts`) is the fixed pipeline `init → health → settings → OAuth → skill install → agent → run → errors → postRun → outro`. It installs the skill by ID, resolves the MCP URL, runs the Claude Agent SDK -`query()` (`src/lib/agent/agent-interface.ts`) in a sandbox with the +`query()` (`src/agent/agent-interface.ts`) in a sandbox with the `posthog-wizard` + `wizard-tools` MCP servers, and parses agent output: `[STATUS]` → UI, `[ABORT] ` → terminal `AgentErrorType.ABORT` matched against `config.abortCases`. `PromptContext` (project/host + AI-consent @@ -179,7 +179,7 @@ against `config.abortCases`. `PromptContext` (project/host + AI-consent `buildSelfDrivingPrompt`. Anything deeper here is generic machinery — read those two files directly. -**`wizard-tools` MCP + `wizard_ask`** (`src/lib/wizard-tools.ts`). +**`wizard-tools` MCP + `wizard_ask`** (`src/agent/tools/tools.ts`). `check_env_keys` / `set_env_values` are the only sanctioned `.env` access (value-safe, `.gitignore`-guarded, secret-vault aware). `wizard_ask` is the **only** way to ask the user anything — questions batched per call, with @@ -196,12 +196,12 @@ A multi-select's default focus is its first enabled option and an empty `enter` submits that focused option — which is why a **decline option, when present, is placed first** (it becomes the safe default). No bridge (CI/non-interactive) → returns an error telling the agent to default or emit -`[ABORT] requires-interactive-mode`. The bridge (`src/lib/wizard-ask-bridge.ts`) +`[ABORT] requires-interactive-mode`. The bridge (`src/agent/wizard-ask-bridge.ts`) brokers into the TUI overlay; cancelled/timed-out fields resolve to `CANCELLED_SENTINEL = '__cancelled__'`. **OAuth scopes** (`src/lib/oauth/program-scopes.ts`). Base `WIZARD_OAUTH_SCOPES` -(`src/lib/constants.ts`) ∪ `SELF_DRIVING_SCOPE_ADDITIONS` — **12 strings**, +(`src/shared/constants.ts`) ∪ `SELF_DRIVING_SCOPE_ADDITIONS` — **12 strings**, requested via a PKCE auth-code flow: | Scope | Why | @@ -226,7 +226,7 @@ requests none. (An *exhaustive* ceiling — no `@default` — is possible and wo reject anything unlisted, but the wizard apps aren't configured that way.) See §7 item 1 and the README's "OAuth app scope ceiling". -**Security & TUI.** YARA hooks (`src/lib/yara-hooks.ts`) scan +**Security & TUI.** YARA hooks (`src/agent/yara-hooks.ts`) scan Bash/Write/Edit/Read content and installed skills via the `warlock` scanner (fail-closed; categories: prompt injection, exfiltration, destructive ops, supply-chain, secrets, PII); a critical match aborts the run. New rules go in @@ -260,7 +260,7 @@ The canonical `signals-scout-*` skills do **not** live here — they're in posth hot-rebuilds individual skill zips but **not** the bundle. Release: a PR to `main` with the **`mcp-publish`** label builds and force-moves the `latest` GitHub release tag. The wizard resolves the skill ID at runtime against - `getSkillsBaseUrl(localMcp)` (`src/lib/constants.ts`): + `getSkillsBaseUrl(localMcp)` (`src/shared/constants.ts`): `…/releases/latest/download` (prod) or `localhost:8765` (`--local-mcp`) — so skill content is decoupled from the wizard npm release (and a prod wizard is broken until the skill is published to `latest`; §7). @@ -358,7 +358,7 @@ source is enabled. > and the `[ABORT] self-driving is not available for this project` path is now > only a safety net for a genuine Signals-API outage. -1. **UI flag `product-autonomy`** (`posthog/frontend/src/lib/constants.tsx`, +1. **UI flag `product-autonomy`** (`posthog/frontend/src/shared/constants.tsx`, `FEATURE_FLAGS.PRODUCT_AUTONOMY`). Frontend-only — gates the Inbox scene, nav item, and source-config loading. Off → the user can't _see_ the inbox; the pipeline is unaffected. diff --git a/src/lib/programs/self-driving/detect-agentic.ts b/src/lib/programs/self-driving/detect-agentic.ts index ddb416941..3822359de 100644 --- a/src/lib/programs/self-driving/detect-agentic.ts +++ b/src/lib/programs/self-driving/detect-agentic.ts @@ -20,7 +20,7 @@ import { toIntegrationCandidates, } from '@lib/detection/project-scope'; import { gatherFrameworkContext } from '@lib/detection/index'; -import type { Integration } from '@lib/constants'; +import type { Integration } from '@shared/constants'; import type { WizardSession } from '@lib/wizard-session'; export type { DetectEvent }; diff --git a/src/lib/programs/self-driving/detect.ts b/src/lib/programs/self-driving/detect.ts index d9c74f055..080b4ce58 100644 --- a/src/lib/programs/self-driving/detect.ts +++ b/src/lib/programs/self-driving/detect.ts @@ -29,8 +29,8 @@ import { import { join } from 'path'; import { analytics } from '@utils/analytics'; import type { WizardSession } from '@lib/wizard-session'; -import type { AbortCase } from '@lib/agent/agent-runner'; -import { ErrorCodes } from '@lib/errors'; +import type { AbortCase } from '@agent/agent-runner'; +import { ErrorCodes } from '@shared/errors'; import { detectWarehouseSources } from '@lib/warehouse-sources/detect'; import type { DetectedSource } from '@lib/warehouse-sources/types'; diff --git a/src/lib/programs/self-driving/prompt.ts b/src/lib/programs/self-driving/prompt.ts index 5bb0a6af2..b79eeaaf9 100644 --- a/src/lib/programs/self-driving/prompt.ts +++ b/src/lib/programs/self-driving/prompt.ts @@ -1,5 +1,5 @@ -import { AgentSignals } from '@lib/agent/agent-interface'; -import type { PromptContext } from '@lib/agent/agent-runner'; +import { AgentSignals } from '@agent/agent-interface'; +import type { PromptContext } from '@agent/agent-runner'; import type { DetectedSource } from '@lib/warehouse-sources/types'; /** diff --git a/src/lib/programs/shared/health-check-step.ts b/src/lib/programs/shared/health-check-step.ts index 1c630a52c..8a42179eb 100644 --- a/src/lib/programs/shared/health-check-step.ts +++ b/src/lib/programs/shared/health-check-step.ts @@ -18,7 +18,7 @@ import { WizardReadiness, SIGNUP_WIZARD_READINESS_CONFIG, getBlockingServiceKeys, -} from '@lib/health-checks/readiness'; +} from '@shared/health-checks/readiness'; import { logToFile } from '@utils/debug'; export function healthCheckReady(session: WizardSession): boolean { diff --git a/src/lib/programs/warehouse-source/detect.ts b/src/lib/programs/warehouse-source/detect.ts index 9e97b7d0c..c9cfa9673 100644 --- a/src/lib/programs/warehouse-source/detect.ts +++ b/src/lib/programs/warehouse-source/detect.ts @@ -9,7 +9,7 @@ import { existsSync, statSync } from 'fs'; import { analytics } from '@utils/analytics'; import type { WizardSession } from '@lib/wizard-session'; -import type { AbortCase } from '@lib/agent/agent-runner'; +import type { AbortCase } from '@agent/agent-runner'; import { detectWarehouseSources } from '@lib/warehouse-sources/detect'; import type { DetectedSource } from '@lib/warehouse-sources/types'; diff --git a/src/lib/programs/warehouse-source/index.ts b/src/lib/programs/warehouse-source/index.ts index 4b31f3851..7b5e99c23 100644 --- a/src/lib/programs/warehouse-source/index.ts +++ b/src/lib/programs/warehouse-source/index.ts @@ -1,7 +1,7 @@ import type { ProgramConfig } from '@lib/programs/program-step'; import type { ProgramRun } from '@lib/programs/program-run'; import type { WizardSession } from '@lib/wizard-session'; -import { LONGER_ASK_TIMEOUT_MS } from '@lib/wizard-ask-bridge'; +import { LONGER_ASK_TIMEOUT_MS } from '@agent/wizard-ask-bridge'; import { WAREHOUSE_SOURCE_PROGRAM } from './steps.js'; import { WAREHOUSE_ABORT_CASES, diff --git a/src/lib/programs/web-analytics-doctor/detect.ts b/src/lib/programs/web-analytics-doctor/detect.ts index 749f4e75d..30ab8ce01 100644 --- a/src/lib/programs/web-analytics-doctor/detect.ts +++ b/src/lib/programs/web-analytics-doctor/detect.ts @@ -1,7 +1,7 @@ import { existsSync, statSync } from 'fs'; import type { WizardSession } from '@lib/wizard-session'; -import type { AbortCase } from '@lib/agent/agent-runner'; -import { ErrorCodes } from '@lib/errors'; +import type { AbortCase } from '@agent/agent-runner'; +import { ErrorCodes } from '@shared/errors'; import { findPackageJsons } from '@lib/programs/shared/package-scanning'; export type WebAnalyticsDetectError = diff --git a/src/lib/registry.ts b/src/lib/registry.ts index cd0133aeb..0c1ae0b1c 100644 --- a/src/lib/registry.ts +++ b/src/lib/registry.ts @@ -1,5 +1,5 @@ import type { FrameworkConfig } from './framework-config'; -import { Integration } from './constants'; +import { Integration } from '@shared/constants'; import { NEXTJS_AGENT_CONFIG } from '@frameworks/nextjs/nextjs-wizard-agent'; import { NUXT_AGENT_CONFIG } from '@frameworks/nuxt/nuxt-wizard-agent'; import { VUE_AGENT_CONFIG } from '@frameworks/vue/vue-wizard-agent'; diff --git a/src/lib/runners/__tests__/mint-recovery.test.ts b/src/lib/runners/__tests__/mint-recovery.test.ts index 9a564640e..affbebc70 100644 --- a/src/lib/runners/__tests__/mint-recovery.test.ts +++ b/src/lib/runners/__tests__/mint-recovery.test.ts @@ -7,13 +7,13 @@ import { InkUI } from '@ui/tui/ink-ui'; import { setUI } from '@ui'; import { posthogIntegrationConfig } from '@lib/programs/posthog-integration'; import { ScreenId } from '@ui/tui/router'; -import { HostResolution } from '@lib/host-resolution'; +import { HostResolution } from '@shared/host-resolution'; import { analytics } from '@utils/analytics'; vi.mock('@lib/programs/run-agent-legacy', () => ({ runProgramAgent: vi.fn() })); vi.mock('@ui/tui/start-tui', () => ({ startTUI: vi.fn() })); -vi.mock('@lib/local-dev', async (original) => ({ - ...(await original()), +vi.mock('@shared/local-dev', async (original) => ({ + ...(await original()), getLocalDev: () => ({}), checkLocalServices: () => Promise.resolve(null), })); diff --git a/src/lib/runners/run-non-interactive.ts b/src/lib/runners/run-non-interactive.ts index 10ebfa4ca..dfa32f9c7 100644 --- a/src/lib/runners/run-non-interactive.ts +++ b/src/lib/runners/run-non-interactive.ts @@ -1,9 +1,13 @@ -import { POSTHOG_DOCS_URL, type Harness, type Sequence } from '@lib/constants'; +import { + POSTHOG_DOCS_URL, + type Harness, + type Sequence, +} from '@shared/constants'; import { checkLocalServices, getLocalDev, POSTHOG_LOCAL_URL, -} from '@lib/local-dev'; +} from '@shared/local-dev'; import type { CloudRegion } from '@utils/types'; import { getUI, setUI } from '@ui'; import { LoggingUI } from '@ui/logging-ui'; @@ -19,7 +23,7 @@ import { classifyRunFailure, detectErrorCode, emitWizardError, -} from '@lib/errors'; +} from '@shared/errors'; import type { OutroData, RunPhase as RunPhaseT } from '@lib/wizard-session'; /** @@ -239,7 +243,7 @@ export function runNonInteractive( try { if (mode === 'ci') { const { configureGatewayFromCIEnvironment } = await import( - '@lib/gateway-session' + '@agent/gateway-session' ); configureGatewayFromCIEnvironment( Number(session.projectId), diff --git a/src/lib/runners/run-wizard.ts b/src/lib/runners/run-wizard.ts index a1f5c5390..a3eaa8f5c 100644 --- a/src/lib/runners/run-wizard.ts +++ b/src/lib/runners/run-wizard.ts @@ -1,4 +1,4 @@ -import { VERSION } from '@lib/version'; +import { VERSION } from '@shared/version'; import { logToFile, getLogFilePath } from '@utils/debug'; import { runProgramAgent } from '@lib/programs/run-agent-legacy'; import { authenticate } from '@lib/programs/authenticate'; @@ -6,15 +6,15 @@ import { getProgramConfig } from '@lib/programs/program-registry'; import { getAuditChecks } from '@lib/programs/audit/types'; import { maybeStampAiSdkDetected } from '@lib/programs/posthog-integration/detect'; import type { ProgramConfig } from '@lib/programs/program-step'; -import type { Harness, Sequence } from '@lib/constants'; +import type { Harness, Sequence } from '@shared/constants'; import type { startTUI as StartTUIFn } from '@ui/tui/start-tui'; import type { WizardStore } from '@ui/tui/store'; import { OutroKind, type WizardSession } from '@lib/wizard-session'; import type { TaskStreamPush as TaskStreamPushClass } from '@lib/task-stream/task-stream-push'; import { resolveNoTelemetry } from './resolve-no-telemetry'; -import { checkLocalServices, getLocalDev } from '@lib/local-dev'; +import { checkLocalServices, getLocalDev } from '@shared/local-dev'; import { runCleanups } from '@utils/wizard-abort'; -import { classifyRunFailure, emitWizardError } from '@lib/errors'; +import { classifyRunFailure, emitWizardError } from '@shared/errors'; import { isRunFailure } from '@ui/mint-failure'; import { getUI } from '@ui'; import { analytics } from '@utils/analytics'; diff --git a/src/lib/task-stream/__tests__/posthog-destination.test.ts b/src/lib/task-stream/__tests__/posthog-destination.test.ts index 3f5945456..48035d7f6 100644 --- a/src/lib/task-stream/__tests__/posthog-destination.test.ts +++ b/src/lib/task-stream/__tests__/posthog-destination.test.ts @@ -1,7 +1,7 @@ import { PostHogDestination } from '../destinations/posthog'; import { StreamEvent, type TaskStreamUpdate } from '../types'; import { RunPhase, type Credentials } from '../../wizard-session'; -import { HostResolution } from '../../host-resolution'; +import { HostResolution } from '@shared/host-resolution'; const SAMPLE_CREDS: Credentials = { host: HostResolution.fromApiHost('https://us.posthog.com'), diff --git a/src/lib/task-stream/task-stream-push.ts b/src/lib/task-stream/task-stream-push.ts index e7c2515d2..d4bce7af9 100644 --- a/src/lib/task-stream/task-stream-push.ts +++ b/src/lib/task-stream/task-stream-push.ts @@ -36,7 +36,7 @@ import { import { EventPlanWatcher } from './event-plan-watcher'; import { rollUpAuditAreas } from './audit-areas'; import { logToFile } from '@utils/debug'; -import { sanitizeErrorDetail } from '@lib/errors'; +import { sanitizeErrorDetail } from '@shared/errors'; /** Trailing-edge debounce window for non-phase-change emits. */ const DEBOUNCE_MS = 250; diff --git a/src/lib/wizard-session.ts b/src/lib/wizard-session.ts index bb3b8a621..18edf4972 100644 --- a/src/lib/wizard-session.ts +++ b/src/lib/wizard-session.ts @@ -10,7 +10,7 @@ * Business logic reads from the session. Never calls a prompt. */ -import { POSTHOG_LOCAL_URL, resolveLocalDev } from './local-dev'; +import { POSTHOG_LOCAL_URL, resolveLocalDev } from '@shared/local-dev'; import { AdditionalFeature, ADDITIONAL_FEATURE_LABELS, @@ -18,11 +18,11 @@ import { type Harness, type Integration, type Sequence, -} from './constants'; +} from '@shared/constants'; import type { FrameworkConfig } from './framework-config'; -import type { WizardReadinessResult } from './health-checks/readiness'; -import type { SettingsConflict } from './agent/claude-settings'; -import type { ApiUser, ApiProject, Credentials } from './api'; +import type { WizardReadinessResult } from '@shared/health-checks/readiness'; +import type { SettingsConflict } from '@shared/claude-settings'; +import type { ApiUser, ApiProject, Credentials } from '@shared/api'; import type { CloudRegion } from '@utils/types'; import { OutroKind, @@ -31,7 +31,7 @@ import { type OutroData, type PendingQuestion, type TaskNotice, -} from './agent/progress'; +} from '@agent/progress'; // These shapes moved to their owners; re-exported so every session reader // keeps its import path. `Credentials` sits with the API types, the @@ -140,7 +140,7 @@ export interface WizardSession { * `--capture-aio`: mirror every wizard LLM call as an `$ai_generation` event * into the authenticated project's AI Observability tab. Dev/test builds * only — the flag is undeclared in published builds so this stays `false` - * there. See `src/lib/agent/aio-capture.ts`. + * there. See `src/agent/aio-capture.ts`. */ captureAio: boolean; @@ -204,7 +204,7 @@ export interface WizardSession { /** * Full user payload from `/api/users/@me/` — identifiers, profile, * current team + organization, preferences, etc. Null until OAuth / - * CI-key auth populates it. Schema lives in `src/lib/api.ts` and + * CI-key auth populates it. Schema lives in `src/shared/api.ts` and * passes through unknown upstream fields so downstream features can * read account context (plan, org name, email, etc.) without * re-fetching. diff --git a/src/lib/wizard-spellbook.ts b/src/lib/wizard-spellbook.ts index ef1847433..894ae1f6e 100644 --- a/src/lib/wizard-spellbook.ts +++ b/src/lib/wizard-spellbook.ts @@ -1,6 +1,6 @@ import fs from 'fs/promises'; import path from 'path'; -import { getSkillsBaseUrl, POSTHOG_DOCS_URL } from './constants'; +import { getSkillsBaseUrl, POSTHOG_DOCS_URL } from '@shared/constants'; import type { ProgramConfig } from './programs/program-step'; import type { WizardSession } from './wizard-session'; import { @@ -8,7 +8,7 @@ import { fetchSkillMenu, type SkillEntry, type SkillMenu, -} from './wizard-tools/tools'; +} from '@agent/tools/tools'; export type WizardSpellbook = { path: string; skillsIncluded: boolean }; type SpellbookSession = Pick< diff --git a/src/lib/agent/__tests__/claude-settings-backup.test.ts b/src/shared/__tests__/claude-settings-backup.test.ts similarity index 99% rename from src/lib/agent/__tests__/claude-settings-backup.test.ts rename to src/shared/__tests__/claude-settings-backup.test.ts index 225c9696e..5f5085f55 100644 --- a/src/lib/agent/__tests__/claude-settings-backup.test.ts +++ b/src/shared/__tests__/claude-settings-backup.test.ts @@ -18,7 +18,7 @@ import { backupAndFixClaudeSettings, restoreClaudeSettings, recoverOrphanedSettingsBackups, -} from '@lib/agent/claude-settings'; +} from '@shared/claude-settings'; const SETTINGS = 'settings.json'; const BACKUP = 'settings.json.wizard-backup'; diff --git a/src/lib/__tests__/constants.test.ts b/src/shared/__tests__/constants.test.ts similarity index 88% rename from src/lib/__tests__/constants.test.ts rename to src/shared/__tests__/constants.test.ts index 6a5390819..93184d5bd 100644 --- a/src/lib/__tests__/constants.test.ts +++ b/src/shared/__tests__/constants.test.ts @@ -1,4 +1,7 @@ -import { WIZARD_USER_AGENT, wizardUserAgentForProgram } from '@lib/constants'; +import { + WIZARD_USER_AGENT, + wizardUserAgentForProgram, +} from '@shared/constants'; describe('wizardUserAgentForProgram', () => { it('tags the program so the backend can attribute created_via (self-driving → self_driving)', () => { diff --git a/src/lib/__tests__/fetch-retry.test.ts b/src/shared/__tests__/fetch-retry.test.ts similarity index 100% rename from src/lib/__tests__/fetch-retry.test.ts rename to src/shared/__tests__/fetch-retry.test.ts diff --git a/src/lib/__tests__/host-resolution.test.ts b/src/shared/__tests__/host-resolution.test.ts similarity index 97% rename from src/lib/__tests__/host-resolution.test.ts rename to src/shared/__tests__/host-resolution.test.ts index a22d55150..1e47ce9f5 100644 --- a/src/lib/__tests__/host-resolution.test.ts +++ b/src/shared/__tests__/host-resolution.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect, vi } from 'vitest'; -import { HostResolution, mcpUrlFor } from '@lib/host-resolution'; +import { HostResolution, mcpUrlFor } from '@shared/host-resolution'; /** * Contract test for HostResolution — the durable record of what the host family @@ -102,7 +102,7 @@ describe('mcpUrlFor', () => { process.env.MCP_URL = 'https://evil.example.com/mcp'; try { vi.resetModules(); - const fresh = await import('@lib/host-resolution'); + const fresh = await import('@shared/host-resolution'); expect(fresh.mcpUrlFor(false)).toBe('https://mcp.posthog.com/mcp'); expect(fresh.mcpUrlFor(true)).toBe('http://localhost:8787/mcp'); } finally { diff --git a/src/lib/__tests__/local-dev.test.ts b/src/shared/__tests__/local-dev.test.ts similarity index 99% rename from src/lib/__tests__/local-dev.test.ts rename to src/shared/__tests__/local-dev.test.ts index 02ced19c2..de3152734 100644 --- a/src/lib/__tests__/local-dev.test.ts +++ b/src/shared/__tests__/local-dev.test.ts @@ -11,12 +11,12 @@ import { localMcpSkillsNotice, resetLocalDev, resolveLocalDev, -} from '@lib/local-dev'; +} from '@shared/local-dev'; import { getSkillsBaseUrl, GITHUB_SKILLS_BASE_URL, LOCAL_SKILLS_BASE_URL, -} from '@lib/constants'; +} from '@shared/constants'; describe('local dev endpoints', () => { it('pins each service to its own port', () => { diff --git a/src/lib/__tests__/secret-vault.test.ts b/src/shared/__tests__/secret-vault.test.ts similarity index 100% rename from src/lib/__tests__/secret-vault.test.ts rename to src/shared/__tests__/secret-vault.test.ts diff --git a/src/lib/agent/__tests__/token-pricing.test.ts b/src/shared/__tests__/token-pricing.test.ts similarity index 99% rename from src/lib/agent/__tests__/token-pricing.test.ts rename to src/shared/__tests__/token-pricing.test.ts index 69bed5e38..bd9c4f10d 100644 --- a/src/lib/agent/__tests__/token-pricing.test.ts +++ b/src/shared/__tests__/token-pricing.test.ts @@ -3,7 +3,7 @@ import { pricePerMtokForModel, formatTokenCount, formatCostUsd, -} from '@lib/agent/token-pricing'; +} from '@shared/token-pricing'; describe('pricePerMtokForModel', () => { it('defaults to Sonnet pricing (DEFAULT_AGENT_MODEL) when no model is given', () => { diff --git a/src/lib/agent/agent-phase.ts b/src/shared/agent-phase.ts similarity index 100% rename from src/lib/agent/agent-phase.ts rename to src/shared/agent-phase.ts diff --git a/src/lib/api.ts b/src/shared/api.ts similarity index 100% rename from src/lib/api.ts rename to src/shared/api.ts diff --git a/src/lib/audit-ledger.ts b/src/shared/audit-ledger.ts similarity index 100% rename from src/lib/audit-ledger.ts rename to src/shared/audit-ledger.ts diff --git a/src/lib/auth-session-state.ts b/src/shared/auth-session-state.ts similarity index 100% rename from src/lib/auth-session-state.ts rename to src/shared/auth-session-state.ts diff --git a/src/lib/agent/claude-settings.ts b/src/shared/claude-settings.ts similarity index 99% rename from src/lib/agent/claude-settings.ts rename to src/shared/claude-settings.ts index 43da0b418..da4873eec 100644 --- a/src/lib/agent/claude-settings.ts +++ b/src/shared/claude-settings.ts @@ -15,7 +15,7 @@ import { registerCleanup } from '@utils/wizard-abort'; import { BLOCKED_AGENT_ENV_KEYS, BLOCKED_AGENT_ENV_PATTERNS, -} from './agent-env-isolation'; +} from '@agent/agent-env-isolation'; /** The file names Claude Code accepts for project settings, in priority order. */ const SETTINGS_FILENAMES = ['settings.json', 'settings'] as const; diff --git a/src/lib/constants.ts b/src/shared/constants.ts similarity index 99% rename from src/lib/constants.ts rename to src/shared/constants.ts index 118bf7bf6..09be1247a 100644 --- a/src/lib/constants.ts +++ b/src/shared/constants.ts @@ -39,8 +39,8 @@ export const GPT5_6_SOL_MODEL = 'openai/gpt-5.6-sol'; * — `Object.values(Harness)` gives an iterable of the values when an array is * needed. Adding a member is enough to pick it up everywhere. * - * Naming matches the directory layout — see `src/lib/agent/runner/harness/` - * and `src/lib/agent/runner/sequence/`. + * Naming matches the directory layout — see `src/agent/runner/harness/` + * and `src/agent/runner/sequence/`. */ export enum Harness { anthropic = 'anthropic', diff --git a/src/lib/errors/__tests__/auth.test.ts b/src/shared/errors/__tests__/auth.test.ts similarity index 100% rename from src/lib/errors/__tests__/auth.test.ts rename to src/shared/errors/__tests__/auth.test.ts diff --git a/src/lib/errors/__tests__/codes.test.ts b/src/shared/errors/__tests__/codes.test.ts similarity index 100% rename from src/lib/errors/__tests__/codes.test.ts rename to src/shared/errors/__tests__/codes.test.ts diff --git a/src/lib/errors/__tests__/detect-map.test.ts b/src/shared/errors/__tests__/detect-map.test.ts similarity index 100% rename from src/lib/errors/__tests__/detect-map.test.ts rename to src/shared/errors/__tests__/detect-map.test.ts diff --git a/src/lib/errors/__tests__/run-failure.test.ts b/src/shared/errors/__tests__/run-failure.test.ts similarity index 96% rename from src/lib/errors/__tests__/run-failure.test.ts rename to src/shared/errors/__tests__/run-failure.test.ts index 3d9c30091..9682327b6 100644 --- a/src/lib/errors/__tests__/run-failure.test.ts +++ b/src/shared/errors/__tests__/run-failure.test.ts @@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'; import { classifyRunFailure } from '../run-failure'; import { ErrorCodes } from '../codes'; import { WizardError } from '@utils/wizard-abort'; -import { GatewayMintRefused } from '@lib/gateway-session'; +import { GatewayMintRefused } from '@agent/gateway-session'; vi.mock('@utils/analytics', () => ({ analytics: { wizardCapture: vi.fn(), captureException: vi.fn() }, diff --git a/src/lib/errors/__tests__/sanitize.test.ts b/src/shared/errors/__tests__/sanitize.test.ts similarity index 100% rename from src/lib/errors/__tests__/sanitize.test.ts rename to src/shared/errors/__tests__/sanitize.test.ts diff --git a/src/lib/errors/agent-map.ts b/src/shared/errors/agent-map.ts similarity index 93% rename from src/lib/errors/agent-map.ts rename to src/shared/errors/agent-map.ts index 4f7efc51d..d55cb517d 100644 --- a/src/lib/errors/agent-map.ts +++ b/src/shared/errors/agent-map.ts @@ -1,4 +1,4 @@ -import { AgentErrorType } from '../agent/signals'; +import { AgentErrorType } from '@agent/signals'; import { ErrorCodes, type ErrorCode } from './codes'; export const AGENT_ERROR_CODE: Record = { diff --git a/src/lib/errors/auth.ts b/src/shared/errors/auth.ts similarity index 100% rename from src/lib/errors/auth.ts rename to src/shared/errors/auth.ts diff --git a/src/lib/errors/catalog.ts b/src/shared/errors/catalog.ts similarity index 100% rename from src/lib/errors/catalog.ts rename to src/shared/errors/catalog.ts diff --git a/src/lib/errors/codes.ts b/src/shared/errors/codes.ts similarity index 100% rename from src/lib/errors/codes.ts rename to src/shared/errors/codes.ts diff --git a/src/lib/errors/detect-map.ts b/src/shared/errors/detect-map.ts similarity index 100% rename from src/lib/errors/detect-map.ts rename to src/shared/errors/detect-map.ts diff --git a/src/lib/errors/emit.ts b/src/shared/errors/emit.ts similarity index 100% rename from src/lib/errors/emit.ts rename to src/shared/errors/emit.ts diff --git a/src/lib/errors/index.ts b/src/shared/errors/index.ts similarity index 100% rename from src/lib/errors/index.ts rename to src/shared/errors/index.ts diff --git a/src/lib/errors/run-failure.ts b/src/shared/errors/run-failure.ts similarity index 100% rename from src/lib/errors/run-failure.ts rename to src/shared/errors/run-failure.ts diff --git a/src/lib/errors/sanitize.ts b/src/shared/errors/sanitize.ts similarity index 100% rename from src/lib/errors/sanitize.ts rename to src/shared/errors/sanitize.ts diff --git a/src/lib/errors/skill-map.ts b/src/shared/errors/skill-map.ts similarity index 88% rename from src/lib/errors/skill-map.ts rename to src/shared/errors/skill-map.ts index 1bca38eef..50f9851fb 100644 --- a/src/lib/errors/skill-map.ts +++ b/src/shared/errors/skill-map.ts @@ -1,5 +1,5 @@ import { ErrorCodes, type ErrorCode } from './codes'; -import type { InstallSkillResult } from '@lib/wizard-tools'; +import type { InstallSkillResult } from '@agent/tools'; const SKILL_CODES: Record< Exclude, diff --git a/src/lib/errors/types.ts b/src/shared/errors/types.ts similarity index 100% rename from src/lib/errors/types.ts rename to src/shared/errors/types.ts diff --git a/src/lib/errors/wizard-error.ts b/src/shared/errors/wizard-error.ts similarity index 100% rename from src/lib/errors/wizard-error.ts rename to src/shared/errors/wizard-error.ts diff --git a/src/lib/fetch-retry.ts b/src/shared/fetch-retry.ts similarity index 100% rename from src/lib/fetch-retry.ts rename to src/shared/fetch-retry.ts diff --git a/src/lib/health-checks/__tests__/health-checks.test.ts b/src/shared/health-checks/__tests__/health-checks.test.ts similarity index 98% rename from src/lib/health-checks/__tests__/health-checks.test.ts rename to src/shared/health-checks/__tests__/health-checks.test.ts index b23b7e2c4..3812f2c33 100644 --- a/src/lib/health-checks/__tests__/health-checks.test.ts +++ b/src/shared/health-checks/__tests__/health-checks.test.ts @@ -5,12 +5,12 @@ import { evaluateWizardReadiness, ServiceHealthStatus, WizardReadiness, -} from '@lib/health-checks/index'; +} from '@shared/health-checks/index'; import { checkLlmGatewayHealth, fetchEndpointHealth, -} from '@lib/health-checks/endpoints'; -import { SIGNUP_WIZARD_READINESS_CONFIG } from '@lib/health-checks/readiness'; +} from '@shared/health-checks/endpoints'; +import { SIGNUP_WIZARD_READINESS_CONFIG } from '@shared/health-checks/readiness'; const URLS = { githubSkillMenu: diff --git a/src/lib/health-checks/endpoints.ts b/src/shared/health-checks/endpoints.ts similarity index 98% rename from src/lib/health-checks/endpoints.ts rename to src/shared/health-checks/endpoints.ts index f98a9eb7b..b6fb91e62 100644 --- a/src/lib/health-checks/endpoints.ts +++ b/src/shared/health-checks/endpoints.ts @@ -1,4 +1,4 @@ -import { AWS_SKILLS_BASE_URL, GITHUB_SKILLS_BASE_URL } from '@lib/constants'; +import { AWS_SKILLS_BASE_URL, GITHUB_SKILLS_BASE_URL } from '@shared/constants'; import { logToFile } from '@utils/debug'; import { ServiceHealthStatus, type BaseHealthResult } from './types'; diff --git a/src/lib/health-checks/index.ts b/src/shared/health-checks/index.ts similarity index 100% rename from src/lib/health-checks/index.ts rename to src/shared/health-checks/index.ts diff --git a/src/lib/health-checks/readiness.ts b/src/shared/health-checks/readiness.ts similarity index 100% rename from src/lib/health-checks/readiness.ts rename to src/shared/health-checks/readiness.ts diff --git a/src/lib/health-checks/testme.md b/src/shared/health-checks/testme.md similarity index 86% rename from src/lib/health-checks/testme.md rename to src/shared/health-checks/testme.md index ba5b04187..31df3aca7 100644 --- a/src/lib/health-checks/testme.md +++ b/src/shared/health-checks/testme.md @@ -3,7 +3,7 @@ Run the existing health and gateway tests with mocked HTTP requests: ```bash -pnpm exec vitest run src/lib/health-checks/__tests__/health-checks.test.ts src/lib/__tests__/gateway-session.test.ts +pnpm exec vitest run src/shared/health-checks/__tests__/health-checks.test.ts src/agent/__tests__/gateway-session.test.ts ``` The checks cover gateway readiness, endpoint retries, and skills downloads from diff --git a/src/lib/health-checks/types.ts b/src/shared/health-checks/types.ts similarity index 100% rename from src/lib/health-checks/types.ts rename to src/shared/health-checks/types.ts diff --git a/src/lib/host-resolution.ts b/src/shared/host-resolution.ts similarity index 99% rename from src/lib/host-resolution.ts rename to src/shared/host-resolution.ts index f55f1b4bc..b7be6a4e3 100644 --- a/src/lib/host-resolution.ts +++ b/src/shared/host-resolution.ts @@ -24,7 +24,7 @@ import { resolveBaseUrl, } from '@utils/urls'; import { IS_PRODUCTION_BUILD, runtimeEnv } from '@env'; -import { MCP_LOCAL_URL } from '@lib/local-dev'; +import { MCP_LOCAL_URL } from '@shared/local-dev'; import type { CloudRegion } from '@utils/types'; // The wizard's client gets CLI mode (a single `exec` tool) by server default, diff --git a/src/lib/local-dev.ts b/src/shared/local-dev.ts similarity index 100% rename from src/lib/local-dev.ts rename to src/shared/local-dev.ts diff --git a/src/lib/secret-vault.ts b/src/shared/secret-vault.ts similarity index 100% rename from src/lib/secret-vault.ts rename to src/shared/secret-vault.ts diff --git a/src/lib/skill-install.ts b/src/shared/skill-install.ts similarity index 100% rename from src/lib/skill-install.ts rename to src/shared/skill-install.ts diff --git a/src/lib/status-history.ts b/src/shared/status-history.ts similarity index 100% rename from src/lib/status-history.ts rename to src/shared/status-history.ts diff --git a/src/lib/agent/token-pricing.ts b/src/shared/token-pricing.ts similarity index 99% rename from src/lib/agent/token-pricing.ts rename to src/shared/token-pricing.ts index 192168207..74a4b84d9 100644 --- a/src/lib/agent/token-pricing.ts +++ b/src/shared/token-pricing.ts @@ -35,7 +35,7 @@ import { DEFAULT_AGENT_MODEL, HAIKU_MODEL, SONNET_5_MODEL, -} from '@lib/constants'; +} from '@shared/constants'; export interface PricePerMtok { input: number; diff --git a/src/utils/__fixtures__/provisioning.ts b/src/shared/utils/__fixtures__/provisioning.ts similarity index 100% rename from src/utils/__fixtures__/provisioning.ts rename to src/shared/utils/__fixtures__/provisioning.ts diff --git a/src/utils/__tests__/analytics.test.ts b/src/shared/utils/__tests__/analytics.test.ts similarity index 99% rename from src/utils/__tests__/analytics.test.ts rename to src/shared/utils/__tests__/analytics.test.ts index 347424ec1..140065508 100644 --- a/src/utils/__tests__/analytics.test.ts +++ b/src/shared/utils/__tests__/analytics.test.ts @@ -1,9 +1,9 @@ import { Analytics, groupsFromUser, sessionProperties } from '@utils/analytics'; import { PostHog } from 'posthog-node'; import { v4 as uuidv4 } from 'uuid'; -import { ANALYTICS_TEAM_TAG, WIZARD_FLAG_KEYS } from '@lib/constants'; -import { VERSION } from '@lib/version'; -import type { ApiUser } from '@lib/api'; +import { ANALYTICS_TEAM_TAG, WIZARD_FLAG_KEYS } from '@shared/constants'; +import { VERSION } from '@shared/version'; +import type { ApiUser } from '@shared/api'; import { buildSession, DiscoveredFeature, diff --git a/src/utils/__tests__/bounded-fs-walk.test.ts b/src/shared/utils/__tests__/bounded-fs-walk.test.ts similarity index 100% rename from src/utils/__tests__/bounded-fs-walk.test.ts rename to src/shared/utils/__tests__/bounded-fs-walk.test.ts diff --git a/src/utils/__tests__/bounded-fs.test.ts b/src/shared/utils/__tests__/bounded-fs.test.ts similarity index 100% rename from src/utils/__tests__/bounded-fs.test.ts rename to src/shared/utils/__tests__/bounded-fs.test.ts diff --git a/src/utils/__tests__/ci-flag-overrides.test.ts b/src/shared/utils/__tests__/ci-flag-overrides.test.ts similarity index 100% rename from src/utils/__tests__/ci-flag-overrides.test.ts rename to src/shared/utils/__tests__/ci-flag-overrides.test.ts diff --git a/src/utils/__tests__/ci-region.test.ts b/src/shared/utils/__tests__/ci-region.test.ts similarity index 97% rename from src/utils/__tests__/ci-region.test.ts rename to src/shared/utils/__tests__/ci-region.test.ts index d174852a5..fd7e69a99 100644 --- a/src/utils/__tests__/ci-region.test.ts +++ b/src/shared/utils/__tests__/ci-region.test.ts @@ -1,6 +1,6 @@ import { getOrAskForProjectData } from '@utils/setup-utils'; import { detectRegion } from '@utils/urls'; -import { fetchProjectData, fetchUserData } from '@lib/api'; +import { fetchProjectData, fetchUserData } from '@shared/api'; import { performOAuthFlow } from '@utils/oauth'; vi.mock('@ui', () => ({ @@ -15,7 +15,7 @@ vi.mock('@utils/urls', () => ({ getUiHostFromHost: (host: string) => host, resolveBaseUrl: (baseUrl?: string) => baseUrl, })); -vi.mock('@lib/api', () => ({ +vi.mock('@shared/api', () => ({ fetchProjectData: vi.fn(), fetchUserData: vi.fn(), })); diff --git a/src/utils/__tests__/debug.test.ts b/src/shared/utils/__tests__/debug.test.ts similarity index 100% rename from src/utils/__tests__/debug.test.ts rename to src/shared/utils/__tests__/debug.test.ts diff --git a/src/utils/__tests__/env-api-key.test.ts b/src/shared/utils/__tests__/env-api-key.test.ts similarity index 100% rename from src/utils/__tests__/env-api-key.test.ts rename to src/shared/utils/__tests__/env-api-key.test.ts diff --git a/src/utils/__tests__/env-scan.test.ts b/src/shared/utils/__tests__/env-scan.test.ts similarity index 100% rename from src/utils/__tests__/env-scan.test.ts rename to src/shared/utils/__tests__/env-scan.test.ts diff --git a/src/utils/__tests__/environment.test.ts b/src/shared/utils/__tests__/environment.test.ts similarity index 97% rename from src/utils/__tests__/environment.test.ts rename to src/shared/utils/__tests__/environment.test.ts index 7938c399c..0830d12c5 100644 --- a/src/utils/__tests__/environment.test.ts +++ b/src/shared/utils/__tests__/environment.test.ts @@ -10,7 +10,7 @@ import { readEnvironment } from '@utils/environment'; import { buildSession } from '@lib/wizard-session'; -import { shouldDisableAsk } from '@lib/agent/agent-runner'; +import { shouldDisableAsk } from '@agent/agent-runner'; /** Every var this file sets, cleared between cases. */ const TOUCHED = [ diff --git a/src/utils/__tests__/links.test.ts b/src/shared/utils/__tests__/links.test.ts similarity index 100% rename from src/utils/__tests__/links.test.ts rename to src/shared/utils/__tests__/links.test.ts diff --git a/src/utils/__tests__/oauth-errors.test.ts b/src/shared/utils/__tests__/oauth-errors.test.ts similarity index 99% rename from src/utils/__tests__/oauth-errors.test.ts rename to src/shared/utils/__tests__/oauth-errors.test.ts index 5e0068245..dcbc46987 100644 --- a/src/utils/__tests__/oauth-errors.test.ts +++ b/src/shared/utils/__tests__/oauth-errors.test.ts @@ -11,7 +11,7 @@ import { ISSUES_URL, POSTHOG_STATUS_PAGE_URL, WIZARD_CONTACT_EMAIL, -} from '@lib/constants'; +} from '@shared/constants'; describe('OAuthError', () => { it('keeps the exact legacy message shape so fingerprint parsing still works', () => { diff --git a/src/utils/__tests__/oauth-refresh.test.ts b/src/shared/utils/__tests__/oauth-refresh.test.ts similarity index 96% rename from src/utils/__tests__/oauth-refresh.test.ts rename to src/shared/utils/__tests__/oauth-refresh.test.ts index 94e775287..d3fafdd39 100644 --- a/src/utils/__tests__/oauth-refresh.test.ts +++ b/src/shared/utils/__tests__/oauth-refresh.test.ts @@ -1,6 +1,6 @@ import axios from 'axios'; import { refreshAccessToken } from '@utils/oauth'; -import { POSTHOG_PROXY_CLIENT_ID } from '@lib/constants'; +import { POSTHOG_PROXY_CLIENT_ID } from '@shared/constants'; vi.mock('axios'); // No base-URL override resolves to prod routing (kills IS_DEV's implicit localhost). diff --git a/src/utils/__tests__/oauth-server.test.ts b/src/shared/utils/__tests__/oauth-server.test.ts similarity index 100% rename from src/utils/__tests__/oauth-server.test.ts rename to src/shared/utils/__tests__/oauth-server.test.ts diff --git a/src/utils/__tests__/oauth.test.ts b/src/shared/utils/__tests__/oauth.test.ts similarity index 99% rename from src/utils/__tests__/oauth.test.ts rename to src/shared/utils/__tests__/oauth.test.ts index 6c60212ac..6466d36b4 100644 --- a/src/utils/__tests__/oauth.test.ts +++ b/src/shared/utils/__tests__/oauth.test.ts @@ -9,7 +9,7 @@ import { import { WIZARD_OAUTH_SCOPES, WIZARD_PROVISIONING_SCOPES, -} from '@lib/constants'; +} from '@shared/constants'; import { getOAuthScopesForProgram } from '@lib/oauth/program-scopes'; describe('extractOAuthCode', () => { diff --git a/src/utils/__tests__/project-resolution.test.ts b/src/shared/utils/__tests__/project-resolution.test.ts similarity index 100% rename from src/utils/__tests__/project-resolution.test.ts rename to src/shared/utils/__tests__/project-resolution.test.ts diff --git a/src/utils/__tests__/provisioning.test.ts b/src/shared/utils/__tests__/provisioning.test.ts similarity index 100% rename from src/utils/__tests__/provisioning.test.ts rename to src/shared/utils/__tests__/provisioning.test.ts diff --git a/src/utils/__tests__/semver.test.ts b/src/shared/utils/__tests__/semver.test.ts similarity index 100% rename from src/utils/__tests__/semver.test.ts rename to src/shared/utils/__tests__/semver.test.ts diff --git a/src/utils/__tests__/terminal-bell.test.ts b/src/shared/utils/__tests__/terminal-bell.test.ts similarity index 100% rename from src/utils/__tests__/terminal-bell.test.ts rename to src/shared/utils/__tests__/terminal-bell.test.ts diff --git a/src/utils/analytics.ts b/src/shared/utils/analytics.ts similarity index 99% rename from src/utils/analytics.ts rename to src/shared/utils/analytics.ts index f494fc439..c5a67fe3f 100644 --- a/src/utils/analytics.ts +++ b/src/shared/utils/analytics.ts @@ -4,16 +4,16 @@ import { ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY, ANALYTICS_TEAM_TAG, WIZARD_FLAG_KEYS, -} from '@lib/constants'; +} from '@shared/constants'; import { reportableDiscoveredFeatures, reportablePosthogSdkDetected, type WizardSession, } from '@lib/wizard-session'; -import type { ApiUser } from '@lib/api'; +import type { ApiUser } from '@shared/api'; import { v4 as uuidv4 } from 'uuid'; import { IS_PRODUCTION_BUILD, RUN_SURFACE, TASK_ID, TASK_RUN_ID } from '@env'; -import { VERSION } from '@lib/version'; +import { VERSION } from '@shared/version'; import { debug, logToFile } from './debug'; import { applyCiFlagOverrides } from './ci-flag-overrides'; diff --git a/src/utils/atomic-ledger.ts b/src/shared/utils/atomic-ledger.ts similarity index 100% rename from src/utils/atomic-ledger.ts rename to src/shared/utils/atomic-ledger.ts diff --git a/src/utils/bounded-fs.ts b/src/shared/utils/bounded-fs.ts similarity index 100% rename from src/utils/bounded-fs.ts rename to src/shared/utils/bounded-fs.ts diff --git a/src/utils/ci-flag-overrides.ts b/src/shared/utils/ci-flag-overrides.ts similarity index 100% rename from src/utils/ci-flag-overrides.ts rename to src/shared/utils/ci-flag-overrides.ts diff --git a/src/utils/clipboard.ts b/src/shared/utils/clipboard.ts similarity index 100% rename from src/utils/clipboard.ts rename to src/shared/utils/clipboard.ts diff --git a/src/utils/custom-headers.ts b/src/shared/utils/custom-headers.ts similarity index 100% rename from src/utils/custom-headers.ts rename to src/shared/utils/custom-headers.ts diff --git a/src/utils/debug.ts b/src/shared/utils/debug.ts similarity index 100% rename from src/utils/debug.ts rename to src/shared/utils/debug.ts diff --git a/src/utils/env-api-key.ts b/src/shared/utils/env-api-key.ts similarity index 100% rename from src/utils/env-api-key.ts rename to src/shared/utils/env-api-key.ts diff --git a/src/utils/env-scan.ts b/src/shared/utils/env-scan.ts similarity index 100% rename from src/utils/env-scan.ts rename to src/shared/utils/env-scan.ts diff --git a/src/utils/environment.ts b/src/shared/utils/environment.ts similarity index 98% rename from src/utils/environment.ts rename to src/shared/utils/environment.ts index 58589c869..e639afa26 100644 --- a/src/utils/environment.ts +++ b/src/shared/utils/environment.ts @@ -7,7 +7,7 @@ const readEnv = import { tryGetPackageJson } from './setup-utils'; import type { WizardRunOptions } from './types'; import { boundedGlob } from './bounded-fs'; -import { IS_DEV } from '@lib/constants'; +import { IS_DEV } from '@shared/constants'; export function isNonInteractiveEnvironment(): boolean { if (IS_DEV) { diff --git a/src/utils/links.ts b/src/shared/utils/links.ts similarity index 100% rename from src/utils/links.ts rename to src/shared/utils/links.ts diff --git a/src/utils/oauth-errors.ts b/src/shared/utils/oauth-errors.ts similarity index 99% rename from src/utils/oauth-errors.ts rename to src/shared/utils/oauth-errors.ts index e95f7f751..3a9f28363 100644 --- a/src/utils/oauth-errors.ts +++ b/src/shared/utils/oauth-errors.ts @@ -14,7 +14,7 @@ import { ISSUES_URL, POSTHOG_STATUS_PAGE_URL, WIZARD_CONTACT_EMAIL, -} from '@lib/constants'; +} from '@shared/constants'; /** * A structured OAuth failure (RFC 6749 §4.1.2.1 authorize errors, §5.2 token diff --git a/src/utils/oauth.ts b/src/shared/utils/oauth.ts similarity index 99% rename from src/utils/oauth.ts rename to src/shared/utils/oauth.ts index 0fc53e78f..dda07db81 100644 --- a/src/utils/oauth.ts +++ b/src/shared/utils/oauth.ts @@ -11,7 +11,7 @@ import { POSTHOG_DEV_CLIENT_ID, POSTHOG_PROXY_CLIENT_ID, WIZARD_USER_AGENT, -} from '@lib/constants'; +} from '@shared/constants'; import { getOAuthUrl, resolveBaseUrl } from './urls'; import { abort } from './setup-utils'; import { openTrackedLink, withUtm } from './links'; diff --git a/src/utils/package-json.ts b/src/shared/utils/package-json.ts similarity index 100% rename from src/utils/package-json.ts rename to src/shared/utils/package-json.ts diff --git a/src/utils/package-manager.ts b/src/shared/utils/package-manager.ts similarity index 99% rename from src/utils/package-manager.ts rename to src/shared/utils/package-manager.ts index 2c3790fda..dc846f275 100644 --- a/src/utils/package-manager.ts +++ b/src/shared/utils/package-manager.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as path from 'path'; import { readFileHead } from './bounded-fs'; -import { withProgress } from '../telemetry'; +import { withProgress } from '../../telemetry'; import { getPackageDotJson, updatePackageDotJson } from './setup-utils'; import type { PackageJson } from './package-json'; import { analytics } from './analytics'; diff --git a/src/utils/paths.ts b/src/shared/utils/paths.ts similarity index 100% rename from src/utils/paths.ts rename to src/shared/utils/paths.ts diff --git a/src/utils/project-resolution.ts b/src/shared/utils/project-resolution.ts similarity index 100% rename from src/utils/project-resolution.ts rename to src/shared/utils/project-resolution.ts diff --git a/src/utils/provisioning.ts b/src/shared/utils/provisioning.ts similarity index 99% rename from src/utils/provisioning.ts rename to src/shared/utils/provisioning.ts index 39e19d73f..ad24cd7ec 100644 --- a/src/utils/provisioning.ts +++ b/src/shared/utils/provisioning.ts @@ -16,11 +16,11 @@ import { POSTHOG_US_CLIENT_ID, WIZARD_PROVISIONING_SCOPES, WIZARD_USER_AGENT, -} from '@lib/constants'; +} from '@shared/constants'; import { resolveBaseUrl } from './urls'; import { logToFile } from './debug'; import { analytics } from './analytics'; -import type { HostResolution } from '@lib/host-resolution'; +import type { HostResolution } from '@shared/host-resolution'; const API_VERSION = '0.1d'; diff --git a/src/utils/rules/astro-rules.md b/src/shared/utils/rules/astro-rules.md similarity index 100% rename from src/utils/rules/astro-rules.md rename to src/shared/utils/rules/astro-rules.md diff --git a/src/utils/rules/next-rules.md b/src/shared/utils/rules/next-rules.md similarity index 100% rename from src/utils/rules/next-rules.md rename to src/shared/utils/rules/next-rules.md diff --git a/src/utils/rules/react-native-rules.md b/src/shared/utils/rules/react-native-rules.md similarity index 100% rename from src/utils/rules/react-native-rules.md rename to src/shared/utils/rules/react-native-rules.md diff --git a/src/utils/rules/react-rules.md b/src/shared/utils/rules/react-rules.md similarity index 100% rename from src/utils/rules/react-rules.md rename to src/shared/utils/rules/react-rules.md diff --git a/src/utils/rules/svelte-rules.md b/src/shared/utils/rules/svelte-rules.md similarity index 100% rename from src/utils/rules/svelte-rules.md rename to src/shared/utils/rules/svelte-rules.md diff --git a/src/utils/rules/universal.md b/src/shared/utils/rules/universal.md similarity index 100% rename from src/utils/rules/universal.md rename to src/shared/utils/rules/universal.md diff --git a/src/utils/semver.ts b/src/shared/utils/semver.ts similarity index 100% rename from src/utils/semver.ts rename to src/shared/utils/semver.ts diff --git a/src/utils/setup-utils.ts b/src/shared/utils/setup-utils.ts similarity index 99% rename from src/utils/setup-utils.ts rename to src/shared/utils/setup-utils.ts index 880fdd8b9..eb434f8ef 100644 --- a/src/utils/setup-utils.ts +++ b/src/shared/utils/setup-utils.ts @@ -4,7 +4,7 @@ import * as os from 'node:os'; import { basename, isAbsolute, join, relative } from 'node:path'; import { promisify } from 'node:util'; -import { withProgress } from '../telemetry'; +import { withProgress } from '../../telemetry'; import { debug, logToFile } from './debug'; import type { PackageJson } from './package-json'; import { @@ -14,7 +14,7 @@ import { } from './package-manager'; import type { CloudRegion, WizardRunOptions } from './types'; import { getDeclaredVersion } from './package-json'; -import { DUMMY_PROJECT_API_KEY, ISSUES_URL } from '@lib/constants'; +import { DUMMY_PROJECT_API_KEY, ISSUES_URL } from '@shared/constants'; import { getOAuthScopesForProgram, getProvisioningScopesForProgram, @@ -22,7 +22,7 @@ import { import type { ProgramId } from '@lib/programs/program-registry'; import { analytics } from './analytics'; import { getUI } from '@ui'; -import { HostResolution } from '@lib/host-resolution'; +import { HostResolution } from '@shared/host-resolution'; import { assertWizardCompletionScope, missingOAuthScopes, @@ -38,7 +38,7 @@ import { fetchProjectData, type ApiUser, type ApiProject, -} from '@lib/api'; +} from '@shared/api'; import { versionSatisfiesRange } from './semver'; import { wizardAbort } from './wizard-abort'; import { OutroKind } from '@lib/wizard-session'; diff --git a/src/utils/terminal-bell.ts b/src/shared/utils/terminal-bell.ts similarity index 100% rename from src/utils/terminal-bell.ts rename to src/shared/utils/terminal-bell.ts diff --git a/src/utils/types.ts b/src/shared/utils/types.ts similarity index 91% rename from src/utils/types.ts rename to src/shared/utils/types.ts index d605a3e76..e553ae65e 100644 --- a/src/utils/types.ts +++ b/src/shared/utils/types.ts @@ -1,4 +1,4 @@ -import type { Harness, Sequence } from '@lib/constants'; +import type { Harness, Sequence } from '@shared/constants'; export type CloudRegion = 'us' | 'eu'; diff --git a/src/utils/urls.ts b/src/shared/utils/urls.ts similarity index 98% rename from src/utils/urls.ts rename to src/shared/utils/urls.ts index 3a0b02d9c..bb10a19af 100644 --- a/src/utils/urls.ts +++ b/src/shared/utils/urls.ts @@ -1,5 +1,5 @@ import axios from 'axios'; -import { IS_DEV, WIZARD_USER_AGENT } from '@lib/constants'; +import { IS_DEV, WIZARD_USER_AGENT } from '@shared/constants'; import type { CloudRegion } from './types'; /** diff --git a/src/utils/vendor/is-unicorn-supported.ts b/src/shared/utils/vendor/is-unicorn-supported.ts similarity index 100% rename from src/utils/vendor/is-unicorn-supported.ts rename to src/shared/utils/vendor/is-unicorn-supported.ts diff --git a/src/utils/wizard-abort.ts b/src/shared/utils/wizard-abort.ts similarity index 96% rename from src/utils/wizard-abort.ts rename to src/shared/utils/wizard-abort.ts index f5973a745..5b55b6864 100644 --- a/src/utils/wizard-abort.ts +++ b/src/shared/utils/wizard-abort.ts @@ -11,8 +11,12 @@ import { logToFile } from './debug'; import { getUI } from '@ui'; import { LoggingUI } from '@ui/logging-ui'; import { OutroKind, type OutroData } from '@lib/wizard-session'; -import type { ErrorCode } from '@lib/errors'; -import { WizardError, emitWizardError, sanitizeErrorDetail } from '@lib/errors'; +import type { ErrorCode } from '@shared/errors'; +import { + WizardError, + emitWizardError, + sanitizeErrorDetail, +} from '@shared/errors'; // Still importable from here; the class lives with the error codes. export { WizardError }; diff --git a/src/steps/add-mcp-server-to-clients/clients/__tests__/claude-code.test.ts b/src/steps/add-mcp-server-to-clients/clients/__tests__/claude-code.test.ts index 346118e1e..e6c886a2a 100644 --- a/src/steps/add-mcp-server-to-clients/clients/__tests__/claude-code.test.ts +++ b/src/steps/add-mcp-server-to-clients/clients/__tests__/claude-code.test.ts @@ -11,11 +11,11 @@ vi.mock('fs', () => ({ existsSync: vi.fn().mockReturnValue(false), })); -vi.mock('../../../../utils/analytics', () => ({ +vi.mock('@utils/analytics', () => ({ analytics: { captureException: vi.fn() }, })); -vi.mock('../../../../utils/debug', () => ({ +vi.mock('@utils/debug', () => ({ debug: vi.fn(), })); diff --git a/src/steps/add-mcp-server-to-clients/clients/__tests__/codex.test.ts b/src/steps/add-mcp-server-to-clients/clients/__tests__/codex.test.ts index 15c74a5bd..52b8992b5 100644 --- a/src/steps/add-mcp-server-to-clients/clients/__tests__/codex.test.ts +++ b/src/steps/add-mcp-server-to-clients/clients/__tests__/codex.test.ts @@ -14,7 +14,7 @@ vi.mock('node:fs', () => ({ rmSync: vi.fn(), })); -vi.mock('../../../../utils/analytics', () => ({ +vi.mock('@utils/analytics', () => ({ analytics: { captureException: vi.fn(), wizardCapture: vi.fn() }, })); diff --git a/src/steps/add-mcp-server-to-clients/index.ts b/src/steps/add-mcp-server-to-clients/index.ts index 9dfcd10ee..fcc85a83b 100644 --- a/src/steps/add-mcp-server-to-clients/index.ts +++ b/src/steps/add-mcp-server-to-clients/index.ts @@ -1,4 +1,4 @@ -import type { Integration } from '@lib/constants'; +import type { Integration } from '@shared/constants'; import type { CloudRegion } from '@utils/types'; import { withProgress } from '../../telemetry'; import { analytics } from '@utils/analytics'; diff --git a/src/steps/add-or-update-environment-variables.ts b/src/steps/add-or-update-environment-variables.ts index 67787dfa8..f4d5d20d4 100644 --- a/src/steps/add-or-update-environment-variables.ts +++ b/src/steps/add-or-update-environment-variables.ts @@ -1,4 +1,4 @@ -import type { Integration } from '@lib/constants'; +import type { Integration } from '@shared/constants'; import { withProgress } from '../telemetry'; import { analytics } from '@utils/analytics'; import { getUI } from '@ui'; diff --git a/src/steps/install-cli-steering/__tests__/install-cli-steering.test.ts b/src/steps/install-cli-steering/__tests__/install-cli-steering.test.ts index 19a0b9c8f..b87d0cbc9 100644 --- a/src/steps/install-cli-steering/__tests__/install-cli-steering.test.ts +++ b/src/steps/install-cli-steering/__tests__/install-cli-steering.test.ts @@ -12,7 +12,7 @@ import { installSteeringSnippet, } from '@steps/install-cli-steering'; -vi.mock('../../../utils/debug'); +vi.mock('@utils/debug'); vi.mock('node:child_process', () => ({ spawnSync: vi.fn(), })); diff --git a/src/steps/run-prettier.ts b/src/steps/run-prettier.ts index 61a4d165e..95078bdd9 100644 --- a/src/steps/run-prettier.ts +++ b/src/steps/run-prettier.ts @@ -1,4 +1,4 @@ -import type { Integration } from '@lib/constants'; +import type { Integration } from '@shared/constants'; import { withProgress } from '../telemetry'; import { analytics } from '@utils/analytics'; import { getUI } from '@ui'; diff --git a/src/steps/upload-environment-variables/index.ts b/src/steps/upload-environment-variables/index.ts index 3a15081b7..239287573 100644 --- a/src/steps/upload-environment-variables/index.ts +++ b/src/steps/upload-environment-variables/index.ts @@ -1,4 +1,4 @@ -import type { Integration } from '@lib/constants'; +import type { Integration } from '@shared/constants'; import { withProgress } from '../../telemetry'; import { analytics } from '@utils/analytics'; import { getUI } from '@ui'; diff --git a/src/ui/__tests__/agent-progress.test.ts b/src/ui/__tests__/agent-progress.test.ts index 6dde35982..237efb9ed 100644 --- a/src/ui/__tests__/agent-progress.test.ts +++ b/src/ui/__tests__/agent-progress.test.ts @@ -4,11 +4,11 @@ vi.mock('@utils/analytics', () => ({ analytics: { wizardCapture: vi.fn() } })); import { createUiReducer, uiInteraction } from '../agent-progress'; import { LoggingUI } from '../logging-ui'; -import type { AgentProgress } from '@lib/agent/progress'; +import type { AgentProgress } from '@agent/progress'; import { CANCELLED_SENTINEL, createWizardAskBridge, -} from '@lib/wizard-ask-bridge'; +} from '@agent/wizard-ask-bridge'; import { OutroKind } from '@lib/wizard-session'; import { logToFile } from '@utils/debug'; diff --git a/src/ui/agent-progress.ts b/src/ui/agent-progress.ts index ec6519aba..4594927a1 100644 --- a/src/ui/agent-progress.ts +++ b/src/ui/agent-progress.ts @@ -1,5 +1,5 @@ import type { WizardUI, SpinnerHandle } from './wizard-ui'; -import type { AgentInteraction, AgentProgress } from '@lib/agent/progress'; +import type { AgentInteraction, AgentProgress } from '@agent/progress'; import { logToFile } from '@utils/debug'; // ── Progress → WizardUI, one call per event ─────────────────────────── diff --git a/src/ui/logging-ui.ts b/src/ui/logging-ui.ts index 30ff56dac..3ddb26b92 100644 --- a/src/ui/logging-ui.ts +++ b/src/ui/logging-ui.ts @@ -11,14 +11,14 @@ import { type AuthErrorDetail, type TokenUsageDelta, } from './wizard-ui'; -import type { SettingsConflict } from '@lib/agent/claude-settings'; -import type { ApiUser } from '@lib/api'; -import { OAUTH_TIMEOUT_MS } from '@lib/constants'; +import type { SettingsConflict } from '@shared/claude-settings'; +import type { ApiUser } from '@shared/api'; +import { OAUTH_TIMEOUT_MS } from '@shared/constants'; import { type WizardReadinessResult, getBlockingServiceKeys, SERVICE_LABELS, -} from '@lib/health-checks/readiness'; +} from '@shared/health-checks/readiness'; import type { AskAnswers, Credentials, diff --git a/src/ui/tui/__tests__/MintFailureScreen.test.tsx b/src/ui/tui/__tests__/MintFailureScreen.test.tsx index ffbb25578..42a224d76 100644 --- a/src/ui/tui/__tests__/MintFailureScreen.test.tsx +++ b/src/ui/tui/__tests__/MintFailureScreen.test.tsx @@ -7,7 +7,7 @@ import { } from '../screens/MintFailureScreen'; import { KeyboardHintsProvider } from '../hooks/useKeyboardHints'; import { OutroKind } from '@lib/wizard-session'; -import { HostResolution } from '@lib/host-resolution'; +import { HostResolution } from '@shared/host-resolution'; import { ScreenId } from '../router'; vi.mock('ink', () => diff --git a/src/ui/tui/__tests__/WizardAskScreen.test.ts b/src/ui/tui/__tests__/WizardAskScreen.test.ts index b2b04a695..5938bfc17 100644 --- a/src/ui/tui/__tests__/WizardAskScreen.test.ts +++ b/src/ui/tui/__tests__/WizardAskScreen.test.ts @@ -9,7 +9,7 @@ import { vi } from 'vitest'; -vi.mock('../../../utils/analytics.js', () => ({ +vi.mock('@utils/analytics.js', () => ({ analytics: { capture: vi.fn(), wizardCapture: vi.fn(), diff --git a/src/ui/tui/__tests__/exit-line.test.ts b/src/ui/tui/__tests__/exit-line.test.ts index f2ee5bc28..604bac57f 100644 --- a/src/ui/tui/__tests__/exit-line.test.ts +++ b/src/ui/tui/__tests__/exit-line.test.ts @@ -1,9 +1,9 @@ import { getExitLine } from '@ui/tui/exit-line'; import { WizardStore, Program } from '@ui/tui/store'; import { OutroKind } from '@lib/wizard-session'; -import { HostResolution } from '@lib/host-resolution'; +import { HostResolution } from '@shared/host-resolution'; -vi.mock('../../../utils/analytics.js', () => ({ +vi.mock('@utils/analytics.js', () => ({ analytics: { capture: vi.fn(), wizardCapture: vi.fn(), diff --git a/src/ui/tui/__tests__/frames.test.tsx b/src/ui/tui/__tests__/frames.test.tsx index 2a2b805f6..c24a782af 100644 --- a/src/ui/tui/__tests__/frames.test.tsx +++ b/src/ui/tui/__tests__/frames.test.tsx @@ -44,13 +44,13 @@ vi.mock('@utils/setup-utils', async (actual) => ({ ...(await actual>()), getOrAskForProjectData: vi.fn(pending), })); -vi.mock('@lib/api', async (actual) => ({ +vi.mock('@shared/api', async (actual) => ({ ...(await actual>()), fetchUserData: vi.fn(pending), fetchSlackConnected: vi.fn(pending), fetchGithubConnected: vi.fn(pending), })); -vi.mock('@lib/wizard-tools', async (actual) => ({ +vi.mock('@agent/tools', async (actual) => ({ ...(await actual>()), fetchSkillMenu: vi.fn(pending), downloadSkill: vi.fn(pending), @@ -108,16 +108,16 @@ import { RunPhase, McpOutcome, } from '@lib/wizard-session'; -import { HostResolution } from '@lib/host-resolution'; -import { Integration } from '@lib/constants'; +import { HostResolution } from '@shared/host-resolution'; +import { Integration } from '@shared/constants'; import { FRAMEWORK_REGISTRY } from '@lib/registry'; import type { FrameworkConfig } from '@lib/framework-config'; import { Program, type ProgramId } from '@lib/programs/program-registry'; import { WizardReadiness, type WizardReadinessResult, -} from '@lib/health-checks/readiness'; -import { ServiceHealthStatus } from '@lib/health-checks/types'; +} from '@shared/health-checks/readiness'; +import { ServiceHealthStatus } from '@shared/health-checks/types'; import { SOURCE_MAPS_CONTEXT_KEYS } from '@lib/programs/error-tracking-upload-source-maps/detect'; import { AUDIT_CHECKS_KEY } from '@lib/programs/audit/types'; import { AUDIT_SEED_CHECKS } from '@lib/programs/audit/seed'; diff --git a/src/ui/tui/__tests__/keyboard-equivalence.test.tsx b/src/ui/tui/__tests__/keyboard-equivalence.test.tsx index 790487197..e240e36dd 100644 --- a/src/ui/tui/__tests__/keyboard-equivalence.test.tsx +++ b/src/ui/tui/__tests__/keyboard-equivalence.test.tsx @@ -24,10 +24,10 @@ import { OutroKind, type WizardSession, } from '@lib/wizard-session'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { FRAMEWORK_REGISTRY } from '@lib/registry'; -import { HostResolution } from '@lib/host-resolution'; -import { WizardReadiness } from '@lib/health-checks/readiness'; +import { HostResolution } from '@shared/host-resolution'; +import { WizardReadiness } from '@shared/health-checks/readiness'; import { SOURCE_MAPS_CONTEXT_KEYS } from '@lib/programs/error-tracking-upload-source-maps/detect'; import { SELF_DRIVING_INTEGRATE_PATH_KEY } from '@lib/programs/self-driving/detect'; import { ScreenContainer } from '../primitives/ScreenContainer'; @@ -61,13 +61,13 @@ vi.mock('@utils/clipboard', async (importOriginal) => ({ openInBrowser: vi.fn().mockResolvedValue(false), })); vi.mock('opn', () => ({ default: vi.fn() })); -vi.mock('@lib/api', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('@shared/api', async (importOriginal) => ({ + ...(await importOriginal()), fetchSlackConnected: vi.fn().mockResolvedValue(false), fetchUserData: vi.fn(() => new Promise(() => undefined)), })); -vi.mock('@lib/wizard-tools', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('@agent/tools', async (importOriginal) => ({ + ...(await importOriginal()), fetchSkillMenu: vi.fn(() => new Promise(() => undefined)), })); vi.mock('@utils/setup-utils', async (importOriginal) => ({ diff --git a/src/ui/tui/__tests__/mcp-installer.test.ts b/src/ui/tui/__tests__/mcp-installer.test.ts index 200289286..1cb41f008 100644 --- a/src/ui/tui/__tests__/mcp-installer.test.ts +++ b/src/ui/tui/__tests__/mcp-installer.test.ts @@ -20,11 +20,11 @@ vi.mock('../../../steps/add-mcp-server-to-clients/defaults.js', () => ({ ALL_FEATURE_VALUES: ['feature-a'], })); -vi.mock('../../../utils/debug.js', () => ({ +vi.mock('@utils/debug.js', () => ({ logToFile: vi.fn(), })); -vi.mock('../../../utils/analytics.js', () => ({ +vi.mock('@utils/analytics.js', () => ({ analytics: { wizardCapture: vi.fn() }, })); diff --git a/src/ui/tui/__tests__/programs.test.ts b/src/ui/tui/__tests__/programs.test.ts index 6030b70d2..7df542c4a 100644 --- a/src/ui/tui/__tests__/programs.test.ts +++ b/src/ui/tui/__tests__/programs.test.ts @@ -1,5 +1,5 @@ import { buildSession, McpOutcome, RunPhase } from '@lib/wizard-session'; -import { WizardReadiness } from '@lib/health-checks/readiness'; +import { WizardReadiness } from '@shared/health-checks/readiness'; import { PROGRAM_SEQUENCES, ScreenId } from '@ui/tui/screen-sequences'; import { Program, type ProgramId } from '@lib/programs/program-registry'; diff --git a/src/ui/tui/__tests__/router.test.ts b/src/ui/tui/__tests__/router.test.ts index 2d893da7e..89b94150f 100644 --- a/src/ui/tui/__tests__/router.test.ts +++ b/src/ui/tui/__tests__/router.test.ts @@ -4,10 +4,10 @@ import { OutroKind, RunPhase, } from '@lib/wizard-session'; -import { HostResolution } from '@lib/host-resolution'; -import { WizardReadiness } from '@lib/health-checks/readiness'; +import { HostResolution } from '@shared/host-resolution'; +import { WizardReadiness } from '@shared/health-checks/readiness'; import { WizardRouter, ScreenId, Overlay, Program } from '@ui/tui/router'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { FRAMEWORK_REGISTRY } from '@lib/registry'; import { PROGRAM_REGISTRY } from '@lib/programs/program-registry'; diff --git a/src/ui/tui/__tests__/skill-entry.test.ts b/src/ui/tui/__tests__/skill-entry.test.ts index 1adece346..09f5d43a0 100644 --- a/src/ui/tui/__tests__/skill-entry.test.ts +++ b/src/ui/tui/__tests__/skill-entry.test.ts @@ -1,5 +1,5 @@ import { resolveSkillEntry } from '@ui/tui/screens/SkillSourceInfo'; -import type { SkillEntry } from '@lib/wizard-tools'; +import type { SkillEntry } from '@agent/tools'; const entry = (id: string): SkillEntry => ({ id, downloadUrl: `https://example.com/${id}.tar.gz` } as SkillEntry); diff --git a/src/ui/tui/__tests__/store-invariants.test.ts b/src/ui/tui/__tests__/store-invariants.test.ts index 8977738e7..a8939578b 100644 --- a/src/ui/tui/__tests__/store-invariants.test.ts +++ b/src/ui/tui/__tests__/store-invariants.test.ts @@ -26,15 +26,15 @@ import { } from '@lib/wizard-session'; import { EXPANDED_COUNT } from '@ui/tui/constants'; import { PROGRAM_SEQUENCES } from '@ui/tui/screen-sequences'; -import { WizardReadiness } from '@lib/health-checks/readiness'; -import { HostResolution } from '@lib/host-resolution'; -import { Integration } from '@lib/constants'; +import { WizardReadiness } from '@shared/health-checks/readiness'; +import { HostResolution } from '@shared/host-resolution'; +import { Integration } from '@shared/constants'; import { FRAMEWORK_REGISTRY } from '@lib/registry'; import { analytics } from '@utils/analytics'; import { PROGRAM_REGISTRY } from '@lib/programs/program-registry'; -import type { SettingsConflict } from '@lib/agent/claude-settings'; +import type { SettingsConflict } from '@shared/claude-settings'; -vi.mock('../../../utils/analytics.js', () => ({ +vi.mock('@utils/analytics.js', () => ({ analytics: { capture: vi.fn(), wizardCapture: vi.fn(), @@ -45,7 +45,7 @@ vi.mock('../../../utils/analytics.js', () => ({ sessionProperties: vi.fn(() => ({})), })); -vi.mock('../../../lib/health-checks/readiness.js', () => ({ +vi.mock('@shared/health-checks/readiness.js', () => ({ evaluateWizardReadiness: vi.fn().mockResolvedValue({ decision: 'yes', health: {}, diff --git a/src/ui/tui/__tests__/store.test.ts b/src/ui/tui/__tests__/store.test.ts index acaf7dc91..ed8cddf1c 100644 --- a/src/ui/tui/__tests__/store.test.ts +++ b/src/ui/tui/__tests__/store.test.ts @@ -13,14 +13,14 @@ import { EXPANDED_COUNT } from '@ui/tui/constants'; import { WizardReadiness, evaluateWizardReadiness, -} from '@lib/health-checks/readiness'; +} from '@shared/health-checks/readiness'; import { buildSession } from '@lib/wizard-session'; -import { HostResolution } from '@lib/host-resolution'; -import { Integration } from '@lib/constants'; +import { HostResolution } from '@shared/host-resolution'; +import { Integration } from '@shared/constants'; import { analytics } from '@utils/analytics'; import { getProgramConfig } from '@lib/programs/program-registry'; -vi.mock('../../../utils/analytics.js', () => ({ +vi.mock('@utils/analytics.js', () => ({ analytics: { capture: vi.fn(), wizardCapture: vi.fn(), @@ -30,7 +30,7 @@ vi.mock('../../../utils/analytics.js', () => ({ sessionProperties: vi.fn(() => ({})), })); -vi.mock('../../../lib/health-checks/readiness.js', () => ({ +vi.mock('@shared/health-checks/readiness.js', () => ({ evaluateWizardReadiness: vi.fn().mockResolvedValue({ decision: 'yes', health: {}, diff --git a/src/ui/tui/__tests__/task-notice.test.ts b/src/ui/tui/__tests__/task-notice.test.ts index 94be3f76c..8534f340a 100644 --- a/src/ui/tui/__tests__/task-notice.test.ts +++ b/src/ui/tui/__tests__/task-notice.test.ts @@ -5,7 +5,7 @@ */ import type { TaskNotice } from '@lib/wizard-session'; -vi.mock('../../../utils/analytics.js', () => ({ +vi.mock('@utils/analytics.js', () => ({ analytics: { capture: vi.fn(), wizardCapture: vi.fn(), diff --git a/src/ui/tui/components/PhaseVisuals.tsx b/src/ui/tui/components/PhaseVisuals.tsx index 3265359c3..1dea3644b 100644 --- a/src/ui/tui/components/PhaseVisuals.tsx +++ b/src/ui/tui/components/PhaseVisuals.tsx @@ -12,7 +12,7 @@ import { Box, Text, measureElement, type DOMElement } from 'ink'; import { useEffect, useRef, useState, useSyncExternalStore } from 'react'; import type { WizardStore } from '@ui/tui/store'; import { useTick } from '@ui/tui/hooks/useTick'; -import { AgentPhase } from '@lib/agent/agent-phase'; +import { AgentPhase } from '@shared/agent-phase'; import { MATRIX_FADE } from './visualizer/panel'; import { VISUALIZER_PALETTE } from './visualizer/palette'; import { MatrixRain } from './visualizer/MatrixRain'; diff --git a/src/ui/tui/components/PrivacyPanel.tsx b/src/ui/tui/components/PrivacyPanel.tsx index c938dac67..b4357a4bb 100644 --- a/src/ui/tui/components/PrivacyPanel.tsx +++ b/src/ui/tui/components/PrivacyPanel.tsx @@ -22,7 +22,7 @@ import { POSTHOG_ORG_AI_SETTINGS_URL, POSTHOG_PRIVACY_URL, POSTHOG_TERMS_URL, -} from '@lib/constants'; +} from '@shared/constants'; import { analytics } from '@utils/analytics'; /** diff --git a/src/ui/tui/components/ServiceHealthList.tsx b/src/ui/tui/components/ServiceHealthList.tsx index 99ac8c7da..a630571d6 100644 --- a/src/ui/tui/components/ServiceHealthList.tsx +++ b/src/ui/tui/components/ServiceHealthList.tsx @@ -5,8 +5,8 @@ import { ServiceHealthStatus, type AllServicesHealth, type HealthCheckKey, -} from '@lib/health-checks/types'; -import { SERVICE_LABELS } from '@lib/health-checks/readiness'; +} from '@shared/health-checks/types'; +import { SERVICE_LABELS } from '@shared/health-checks/readiness'; import { Icons } from '@ui/tui/styles'; function statusIcon(status: ServiceHealthStatus): { diff --git a/src/ui/tui/components/TokenCostHud.tsx b/src/ui/tui/components/TokenCostHud.tsx index 83fb1085d..14632b756 100644 --- a/src/ui/tui/components/TokenCostHud.tsx +++ b/src/ui/tui/components/TokenCostHud.tsx @@ -17,7 +17,7 @@ import { Box, Text } from 'ink'; import { Colors } from '@ui/tui/styles'; import { totalTokenCount, type TokenUsageSnapshot } from '@ui/tui/store'; -import { formatTokenCount, formatCostUsd } from '@lib/agent/token-pricing'; +import { formatTokenCount, formatCostUsd } from '@shared/token-pricing'; /** Self-documents the hidden shortcut once the panel is showing. */ const HINT_TEXT = 'Ctrl+T to hide'; diff --git a/src/ui/tui/constants.ts b/src/ui/tui/constants.ts index ae420b5c3..c2da8eea7 100644 --- a/src/ui/tui/constants.ts +++ b/src/ui/tui/constants.ts @@ -6,4 +6,4 @@ */ export const COLLAPSED_COUNT = 2; -export { MAX_STATUS_MESSAGES as EXPANDED_COUNT } from '@lib/status-history'; +export { MAX_STATUS_MESSAGES as EXPANDED_COUNT } from '@shared/status-history'; diff --git a/src/ui/tui/exit-line.ts b/src/ui/tui/exit-line.ts index 7db085ead..5d2ad68d6 100644 --- a/src/ui/tui/exit-line.ts +++ b/src/ui/tui/exit-line.ts @@ -16,7 +16,7 @@ import { totalTokenCount, type WizardStore } from './store.js'; import { OutroKind } from '@lib/wizard-session'; import { isRunFailure, MINT_FAILURE_CONTACT } from '@ui/mint-failure'; -import { formatTokenCount, formatCostUsd } from '@lib/agent/token-pricing'; +import { formatTokenCount, formatCostUsd } from '@shared/token-pricing'; import { getLogFilePath } from '@utils/debug'; const RESET_ATTRS = '\x1b[0m'; diff --git a/src/ui/tui/hooks/__tests__/useGithubConnection.test.ts b/src/ui/tui/hooks/__tests__/useGithubConnection.test.ts index 96ba780e8..c03de350b 100644 --- a/src/ui/tui/hooks/__tests__/useGithubConnection.test.ts +++ b/src/ui/tui/hooks/__tests__/useGithubConnection.test.ts @@ -1,7 +1,7 @@ import { fetchLoginUrl } from '@ui/tui/hooks/useGithubConnection'; import { requestDeepLink } from '@utils/provisioning'; import type { WizardSession, Credentials } from '@lib/wizard-session'; -import type { HostResolution } from '@lib/host-resolution'; +import type { HostResolution } from '@shared/host-resolution'; vi.mock('@utils/provisioning', () => ({ requestDeepLink: vi.fn() })); diff --git a/src/ui/tui/hooks/useGithubConnection.ts b/src/ui/tui/hooks/useGithubConnection.ts index 0c68aa427..166df92bf 100644 --- a/src/ui/tui/hooks/useGithubConnection.ts +++ b/src/ui/tui/hooks/useGithubConnection.ts @@ -11,7 +11,7 @@ import { useEffect } from 'react'; import type { WizardStore } from '@ui/tui/store'; import type { WizardSession } from '@lib/wizard-session'; -import { fetchGithubConnected } from '@lib/api'; +import { fetchGithubConnected } from '@shared/api'; import { requestDeepLink } from '@utils/provisioning'; import { analytics } from '@utils/analytics'; diff --git a/src/ui/tui/ink-ui.ts b/src/ui/tui/ink-ui.ts index 60c9f27da..1822b649c 100644 --- a/src/ui/tui/ink-ui.ts +++ b/src/ui/tui/ink-ui.ts @@ -13,9 +13,9 @@ import type { TokenUsageDelta, } from '@ui/wizard-ui'; import type { WizardStore } from './store.js'; -import type { SettingsConflict } from '@lib/agent/claude-settings'; -import type { WizardReadinessResult } from '@lib/health-checks/readiness'; -import type { ApiUser } from '@lib/api'; +import type { SettingsConflict } from '@shared/claude-settings'; +import type { WizardReadinessResult } from '@shared/health-checks/readiness'; +import type { ApiUser } from '@shared/api'; import type { AskAnswers, Credentials, diff --git a/src/ui/tui/playground/demos/AiOptInDemo.tsx b/src/ui/tui/playground/demos/AiOptInDemo.tsx index 97897e219..4fb99d37a 100644 --- a/src/ui/tui/playground/demos/AiOptInDemo.tsx +++ b/src/ui/tui/playground/demos/AiOptInDemo.tsx @@ -16,7 +16,7 @@ import { useEffect, useState } from 'react'; import { Box, Text } from 'ink'; import { WizardStore } from '@ui/tui/store'; import { AiOptInRequiredScreen } from '@ui/tui/screens/AiOptInRequiredScreen'; -import { HostResolution } from '@lib/host-resolution'; +import { HostResolution } from '@shared/host-resolution'; type Variant = 'admin' | 'non-admin'; diff --git a/src/ui/tui/playground/demos/EndScreensDemo.tsx b/src/ui/tui/playground/demos/EndScreensDemo.tsx index 7fc165ba6..4038c689e 100644 --- a/src/ui/tui/playground/demos/EndScreensDemo.tsx +++ b/src/ui/tui/playground/demos/EndScreensDemo.tsx @@ -27,7 +27,7 @@ import { SlackConnectScreen } from '@ui/tui/screens/SlackConnectScreen'; import { OutroScreen } from '@ui/tui/screens/OutroScreen'; import { Colors } from '@ui/tui/styles'; import { OutroKind, type OutroData } from '@lib/wizard-session'; -import { HostResolution } from '@lib/host-resolution'; +import { HostResolution } from '@shared/host-resolution'; const VIEWS = ['slack-connect', 'outro'] as const; type View = (typeof VIEWS)[number]; diff --git a/src/ui/tui/playground/demos/HealthCheckDemo.tsx b/src/ui/tui/playground/demos/HealthCheckDemo.tsx index a4e12b936..eb407a1a4 100644 --- a/src/ui/tui/playground/demos/HealthCheckDemo.tsx +++ b/src/ui/tui/playground/demos/HealthCheckDemo.tsx @@ -5,9 +5,9 @@ import { Box, Text } from 'ink'; import { LoadingBox, ModalOverlay } from '@ui/tui/primitives/index'; import { Icons } from '@ui/tui/styles'; import { ServiceHealthList } from '@ui/tui/components/ServiceHealthList'; -import { getBlockingServiceKeys } from '@lib/health-checks/readiness'; -import { ServiceHealthStatus } from '@lib/health-checks/types'; -import type { AllServicesHealth } from '@lib/health-checks/types'; +import { getBlockingServiceKeys } from '@shared/health-checks/readiness'; +import { ServiceHealthStatus } from '@shared/health-checks/types'; +import type { AllServicesHealth } from '@shared/health-checks/types'; const MOCK_CONFIRMED_OUTAGE: AllServicesHealth = { skillsOrigin: { status: ServiceHealthStatus.Down }, diff --git a/src/ui/tui/playground/demos/McpSuggestedPromptsDemo.tsx b/src/ui/tui/playground/demos/McpSuggestedPromptsDemo.tsx index 59aaa256c..a7e4d5b00 100644 --- a/src/ui/tui/playground/demos/McpSuggestedPromptsDemo.tsx +++ b/src/ui/tui/playground/demos/McpSuggestedPromptsDemo.tsx @@ -36,9 +36,9 @@ import { useEffect, useMemo, useRef, useState } from 'react'; import type { WizardStore } from '@ui/tui/store'; import { McpSuggestedPromptsScreen } from '@ui/tui/screens/McpSuggestedPromptsScreen'; import { Colors } from '@ui/tui/styles'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { McpOutcome } from '@lib/wizard-session'; -import { HostResolution } from '@lib/host-resolution'; +import { HostResolution } from '@shared/host-resolution'; import { TAILORED_ROLES } from '@lib/mcp-role-prompts'; import { assembleProfile, diff --git a/src/ui/tui/playground/demos/RunScreenDemo.tsx b/src/ui/tui/playground/demos/RunScreenDemo.tsx index 27cc7d193..d1e34c728 100644 --- a/src/ui/tui/playground/demos/RunScreenDemo.tsx +++ b/src/ui/tui/playground/demos/RunScreenDemo.tsx @@ -23,7 +23,7 @@ import { import { Box, Text, useInput } from 'ink'; import { WizardStore, TaskStatus } from '@ui/tui/store'; import { DiscoveredFeature } from '@lib/wizard-session'; -import { AgentPhase } from '@lib/agent/agent-phase'; +import { AgentPhase } from '@shared/agent-phase'; import { SplitView, ProgressList, diff --git a/src/ui/tui/playground/start-playground.ts b/src/ui/tui/playground/start-playground.ts index 1d59c495e..179ec415d 100644 --- a/src/ui/tui/playground/start-playground.ts +++ b/src/ui/tui/playground/start-playground.ts @@ -6,8 +6,8 @@ import { render } from 'ink'; import { createElement } from 'react'; import { WizardStore } from '@ui/tui/store'; import { PlaygroundApp } from './PlaygroundApp.js'; -import { HostResolution } from '@lib/host-resolution'; -import { WizardReadiness } from '@lib/health-checks/readiness'; +import { HostResolution } from '@shared/host-resolution'; +import { WizardReadiness } from '@shared/health-checks/readiness'; import { enterDarkTerminal, releaseTerminal } from '../terminal.js'; export function startPlayground(version: string): void { diff --git a/src/ui/tui/screens/AiOptInRequiredScreen.tsx b/src/ui/tui/screens/AiOptInRequiredScreen.tsx index ae74821ad..2018af56f 100644 --- a/src/ui/tui/screens/AiOptInRequiredScreen.tsx +++ b/src/ui/tui/screens/AiOptInRequiredScreen.tsx @@ -20,8 +20,8 @@ import type { WizardStore } from '@ui/tui/store'; import { useKeyBindings } from '@ui/tui/hooks/useKeyBindings'; import { Colors } from '@ui/tui/styles'; import { useSkillEntry } from '@ui/tui/screens/SkillSourceInfo'; -import { fetchUserData } from '@lib/api'; -import { CONTEXT_MILL_RELEASES_URL, POSTHOG_APP_URL } from '@lib/constants'; +import { fetchUserData } from '@shared/api'; +import { CONTEXT_MILL_RELEASES_URL, POSTHOG_APP_URL } from '@shared/constants'; import { analytics } from '@utils/analytics'; import { LoadingBox } from '@ui/tui/primitives/index'; diff --git a/src/ui/tui/screens/KeepSkillsScreen.tsx b/src/ui/tui/screens/KeepSkillsScreen.tsx index dfe94a094..5fcd45610 100644 --- a/src/ui/tui/screens/KeepSkillsScreen.tsx +++ b/src/ui/tui/screens/KeepSkillsScreen.tsx @@ -17,7 +17,7 @@ const WIZARD_MARKER = '.posthog-wizard'; import type { WizardStore } from '@ui/tui/store'; import { ConfirmationInput } from '@ui/tui/primitives/index'; import { Colors } from '@ui/tui/styles'; -import { CONTEXT_MILL_URL } from '@lib/constants'; +import { CONTEXT_MILL_URL } from '@shared/constants'; interface KeepSkillsScreenProps { store: WizardStore; diff --git a/src/ui/tui/screens/ManagedSettingsScreen.tsx b/src/ui/tui/screens/ManagedSettingsScreen.tsx index dcb184aa6..9708a2951 100644 --- a/src/ui/tui/screens/ManagedSettingsScreen.tsx +++ b/src/ui/tui/screens/ManagedSettingsScreen.tsx @@ -14,7 +14,7 @@ import { useEffect, useSyncExternalStore } from 'react'; import type { WizardStore } from '@ui/tui/store'; import { ConfirmationInput, ModalOverlay } from '@ui/tui/primitives/index'; import { Icons } from '@ui/tui/styles'; -import type { SettingsConflict } from '@lib/agent/claude-settings'; +import type { SettingsConflict } from '@shared/claude-settings'; import { analytics } from '@utils/analytics'; function sourceLabel(source: SettingsConflict['source']): string { diff --git a/src/ui/tui/screens/McpSuggestedPromptsScreen.tsx b/src/ui/tui/screens/McpSuggestedPromptsScreen.tsx index 05b010920..c8d7ff9d7 100644 --- a/src/ui/tui/screens/McpSuggestedPromptsScreen.tsx +++ b/src/ui/tui/screens/McpSuggestedPromptsScreen.tsx @@ -69,7 +69,7 @@ import { isKnownCloudHost, type ProjectDataProfile, } from '@lib/mcp-project-profile'; -import type { Integration } from '@lib/constants'; +import type { Integration } from '@shared/constants'; import { analytics } from '@utils/analytics'; import { logToFile } from '@utils/debug'; import type { diff --git a/src/ui/tui/screens/PortConflictScreen.tsx b/src/ui/tui/screens/PortConflictScreen.tsx index b110caabf..abb30178c 100644 --- a/src/ui/tui/screens/PortConflictScreen.tsx +++ b/src/ui/tui/screens/PortConflictScreen.tsx @@ -7,7 +7,7 @@ import { Box, Text } from 'ink'; import { useSyncExternalStore } from 'react'; import type { WizardStore } from '@ui/tui/store'; -import { OAUTH_PORTS } from '@lib/constants'; +import { OAUTH_PORTS } from '@shared/constants'; import { ConfirmationInput, ModalOverlay } from '@ui/tui/primitives/index'; interface PortConflictScreenProps { diff --git a/src/ui/tui/screens/PostHogIntegrationIntroScreen.tsx b/src/ui/tui/screens/PostHogIntegrationIntroScreen.tsx index 3da96b496..e4331f473 100644 --- a/src/ui/tui/screens/PostHogIntegrationIntroScreen.tsx +++ b/src/ui/tui/screens/PostHogIntegrationIntroScreen.tsx @@ -12,7 +12,7 @@ import { Box, Text } from 'ink'; import type { ReactNode } from 'react'; import { useState, useSyncExternalStore } from 'react'; import type { WizardStore } from '@ui/tui/store'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { getCommandPath, getLaunchablePrograms, diff --git a/src/ui/tui/screens/SelfDrivingIntegrationCheckScreen.tsx b/src/ui/tui/screens/SelfDrivingIntegrationCheckScreen.tsx index ec3179d07..46d8423b1 100644 --- a/src/ui/tui/screens/SelfDrivingIntegrationCheckScreen.tsx +++ b/src/ui/tui/screens/SelfDrivingIntegrationCheckScreen.tsx @@ -26,7 +26,7 @@ import { PRIVACY_PANEL_LABEL, } from '@ui/tui/components/PrivacyPanel'; import { IntroScreenLayout } from '@ui/tui/screens/IntroScreenLayout'; -import { POSTHOG_PRIVACY_URL, POSTHOG_TERMS_URL } from '@lib/constants'; +import { POSTHOG_PRIVACY_URL, POSTHOG_TERMS_URL } from '@shared/constants'; import { Colors } from '@ui/tui/styles'; interface SelfDrivingIntegrationCheckScreenProps { diff --git a/src/ui/tui/screens/SelfDrivingIntegrationDetectScreen.tsx b/src/ui/tui/screens/SelfDrivingIntegrationDetectScreen.tsx index a5327232f..110dbc8f0 100644 --- a/src/ui/tui/screens/SelfDrivingIntegrationDetectScreen.tsx +++ b/src/ui/tui/screens/SelfDrivingIntegrationDetectScreen.tsx @@ -14,7 +14,7 @@ import { useEffect, useRef, useState, useSyncExternalStore } from 'react'; import type { WizardStore } from '@ui/tui/store'; import { LoadingBox, PickerMenu } from '@ui/tui/primitives/index'; import { Colors, Icons } from '@ui/tui/styles'; -import { Integration } from '@lib/constants'; +import { Integration } from '@shared/constants'; import { FRAMEWORK_REGISTRY } from '@lib/registry'; import { SELF_DRIVING_INTEGRATE_PATH_KEY } from '@lib/programs/self-driving/detect'; import { diff --git a/src/ui/tui/screens/SessionTimeoutScreen.tsx b/src/ui/tui/screens/SessionTimeoutScreen.tsx index 4f928f820..944b80b3d 100644 --- a/src/ui/tui/screens/SessionTimeoutScreen.tsx +++ b/src/ui/tui/screens/SessionTimeoutScreen.tsx @@ -11,7 +11,7 @@ import { Box, Text } from 'ink'; import { useSyncExternalStore } from 'react'; import type { WizardStore } from '@ui/tui/store'; import { Colors } from '@ui/tui/styles'; -import { OAUTH_TIMEOUT_MS } from '@lib/constants'; +import { OAUTH_TIMEOUT_MS } from '@shared/constants'; import { useDismissOnAnyKey } from '@ui/tui/hooks/useDismissOnAnyKey'; interface SessionTimeoutScreenProps { diff --git a/src/ui/tui/screens/SkillSourceInfo.tsx b/src/ui/tui/screens/SkillSourceInfo.tsx index b5184b682..7805f433c 100644 --- a/src/ui/tui/screens/SkillSourceInfo.tsx +++ b/src/ui/tui/screens/SkillSourceInfo.tsx @@ -14,8 +14,8 @@ import { Box, Text } from 'ink'; import { useEffect, useState } from 'react'; -import { fetchSkillMenu, type SkillEntry } from '@lib/wizard-tools'; -import { CONTEXT_MILL_RELEASES_URL, getSkillsBaseUrl } from '@lib/constants'; +import { fetchSkillMenu, type SkillEntry } from '@agent/tools'; +import { CONTEXT_MILL_RELEASES_URL, getSkillsBaseUrl } from '@shared/constants'; /** * Resolve a session skillId against the skill-menu entries. diff --git a/src/ui/tui/screens/SlackConnectScreen.tsx b/src/ui/tui/screens/SlackConnectScreen.tsx index f0f4d99c8..ecc1958ba 100644 --- a/src/ui/tui/screens/SlackConnectScreen.tsx +++ b/src/ui/tui/screens/SlackConnectScreen.tsx @@ -31,7 +31,7 @@ import { Colors, Icons } from '@ui/tui/styles'; import { PickerMenu, LoadingBox } from '@ui/tui/primitives/index'; import { useKeyBindings, KeyMatch } from '@ui/tui/hooks/useKeyBindings'; import { getSlackAppCard } from '@lib/mcp-role-prompts'; -import { fetchSlackConnected } from '@lib/api'; +import { fetchSlackConnected } from '@shared/api'; import { Program } from '@lib/programs/program-registry'; import { getOrAskForProjectData } from '@utils/setup-utils'; import { analytics } from '@utils/analytics'; diff --git a/src/ui/tui/screens/doctor/DoctorReportScreen.tsx b/src/ui/tui/screens/doctor/DoctorReportScreen.tsx index eb4a982de..3e44e6d45 100644 --- a/src/ui/tui/screens/doctor/DoctorReportScreen.tsx +++ b/src/ui/tui/screens/doctor/DoctorReportScreen.tsx @@ -8,8 +8,8 @@ import { type HealthIssue, } from '@lib/programs/posthog-doctor/index'; import { OutroKind } from '@lib/wizard-session'; -import { ApiError } from '@lib/api'; -import { POSTHOG_DOCS_URL } from '@lib/constants'; +import { ApiError } from '@shared/api'; +import { POSTHOG_DOCS_URL } from '@shared/constants'; import { IssueTable, SEVERITY_LABEL, SEVERITY_ORDER } from './IssueTable.js'; interface DoctorReportScreenProps { diff --git a/src/ui/tui/screens/health/HealthCheckScreen.tsx b/src/ui/tui/screens/health/HealthCheckScreen.tsx index 8627e3ec7..c19e6f5af 100644 --- a/src/ui/tui/screens/health/HealthCheckScreen.tsx +++ b/src/ui/tui/screens/health/HealthCheckScreen.tsx @@ -20,12 +20,12 @@ import { ServiceHealthList } from '@ui/tui/components/ServiceHealthList'; import { getBlockingServiceKeys, SIGNUP_WIZARD_READINESS_CONFIG, -} from '@lib/health-checks/readiness'; -import { ServiceHealthStatus } from '@lib/health-checks/types'; +} from '@shared/health-checks/readiness'; +import { ServiceHealthStatus } from '@shared/health-checks/types'; import { wizardAbort } from '@utils/wizard-abort'; -import { ErrorCodes } from '@lib/errors'; -import { fetchSkillMenu, downloadSkill } from '@lib/wizard-tools'; -import { GITHUB_SKILLS_BASE_URL } from '@lib/constants'; +import { ErrorCodes } from '@shared/errors'; +import { fetchSkillMenu, downloadSkill } from '@agent/tools'; +import { GITHUB_SKILLS_BASE_URL } from '@shared/constants'; import { useDismissOnAnyKey } from '@ui/tui/hooks/useDismissOnAnyKey'; interface HealthCheckScreenProps { diff --git a/src/ui/tui/services/mcp-suggested-prompts-services.ts b/src/ui/tui/services/mcp-suggested-prompts-services.ts index 0bd788576..5d0af5eb4 100644 --- a/src/ui/tui/services/mcp-suggested-prompts-services.ts +++ b/src/ui/tui/services/mcp-suggested-prompts-services.ts @@ -14,7 +14,7 @@ import type { Credentials } from '@lib/wizard-session'; import { getOrAskForProjectData } from '@utils/setup-utils'; import { Program } from '@lib/programs/program-registry'; import type { WizardStore } from '@ui/tui/store'; -import type { ApiUser } from '@lib/api'; +import type { ApiUser } from '@shared/api'; import { probeProjectData as runProbe, type ProjectDataProfile, @@ -23,7 +23,7 @@ import { seedDemoEvents as runSeed } from '@lib/mcp-seed-events'; // The streamed event shape is the agent's; re-exported so the screen and the // playground keep their import path. -import type { AgentChunk } from '@lib/agent/mcp-prompt-streaming'; +import type { AgentChunk } from '@agent/mcp-prompt-streaming'; export type { AgentChunk }; export interface McpSuggestedPromptsServices { @@ -161,8 +161,6 @@ async function* runProductionPromptStreaming(args: { // Defer the SDK import to call time — the playground never hits // this path (it overrides the whole service object), so demo // sessions don't pay the SDK load cost. - const { runMcpPromptViaSdk } = await import( - '@lib/agent/mcp-prompt-streaming' - ); + const { runMcpPromptViaSdk } = await import('@agent/mcp-prompt-streaming'); yield* runMcpPromptViaSdk(args); } diff --git a/src/ui/tui/store.ts b/src/ui/tui/store.ts index f4214510e..1f29dfef6 100644 --- a/src/ui/tui/store.ts +++ b/src/ui/tui/store.ts @@ -35,12 +35,12 @@ import { buildSession, type TaskNotice, } from '@lib/wizard-session'; -import type { SettingsConflict } from '@lib/agent/claude-settings'; +import type { SettingsConflict } from '@shared/claude-settings'; import { WizardReadiness, getBlockingServiceKeys, type WizardReadinessResult, -} from '@lib/health-checks/readiness'; +} from '@shared/health-checks/readiness'; import { WizardRouter, type ScreenName, @@ -57,9 +57,9 @@ import type { import { getProgramConfig } from '@lib/programs/program-registry'; import { withAiOptInGate } from '@lib/programs/ai-opt-in-gate'; import { reportWarehouseSourcesDetected } from '@lib/programs/posthog-integration/detect'; -import { appendStatus } from '@lib/status-history'; -import { IS_DEV } from '@lib/constants'; -import { computeTokenCostUsd } from '@lib/agent/token-pricing'; +import { appendStatus } from '@shared/status-history'; +import { IS_DEV } from '@shared/constants'; +import { computeTokenCostUsd } from '@shared/token-pricing'; export { TaskStatus, ScreenId, Overlay, Program, RunPhase, McpOutcome }; export type { ScreenName, OutroData, WizardSession, ProgramId }; diff --git a/src/ui/wizard-ui.ts b/src/ui/wizard-ui.ts index 17f2792f3..f99802402 100644 --- a/src/ui/wizard-ui.ts +++ b/src/ui/wizard-ui.ts @@ -8,9 +8,9 @@ * Session-mutating methods trigger reactive screen resolution in the TUI. */ -import type { SettingsConflict } from '@lib/agent/claude-settings'; -import type { WizardReadinessResult } from '@lib/health-checks/readiness'; -import type { ApiUser } from '@lib/api'; +import type { SettingsConflict } from '@shared/claude-settings'; +import type { WizardReadinessResult } from '@shared/health-checks/readiness'; +import type { ApiUser } from '@shared/api'; import type { Credentials, TaskNotice } from '@lib/wizard-session'; import type { AskAnswers, @@ -34,7 +34,7 @@ import type { AuthErrorDetail, SpinnerHandle, TokenUsageDelta, -} from '@lib/agent/progress'; +} from '@agent/progress'; export type { AuthErrorDetail, SpinnerHandle, TokenUsageDelta }; export interface WizardUI { diff --git a/src/wizard.ts b/src/wizard.ts index 621e14699..9b54de5f4 100644 --- a/src/wizard.ts +++ b/src/wizard.ts @@ -2,12 +2,12 @@ import yargs from 'yargs'; import { hideBin } from 'yargs/helpers'; import type { Argv } from 'yargs'; import { IS_PRODUCTION_BUILD } from '@env'; -import { Harness, Sequence } from '@lib/constants'; +import { Harness, Sequence } from '@shared/constants'; import { regionOption } from '@lib/headless-mode'; -import { initLocalDev, localMcpSkillsNotice } from '@lib/local-dev'; +import { initLocalDev, localMcpSkillsNotice } from '@shared/local-dev'; import { toCommandModule, type Command } from './commands/command'; -import { ErrorCodes } from '@lib/errors'; -import { emitWizardError } from '@lib/errors'; +import { ErrorCodes } from '@shared/errors'; +import { emitWizardError } from '@shared/errors'; /** * Global yargs options applied to every command. These are read from the diff --git a/tsconfig.build.json b/tsconfig.build.json index 8618277c1..f4c4ef2d9 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -19,9 +19,11 @@ "jsx": "react-jsx", "paths": { "@env": ["./src/env.ts"], + "@shared/*": ["./src/shared/*"], + "@agent/*": ["./src/agent/*"], "@lib/*": ["./src/lib/*"], "@e2e-harness/*": ["./e2e-harness/*"], - "@utils/*": ["./src/utils/*"], + "@utils/*": ["./src/shared/utils/*"], "@ui": ["./src/ui/index.ts"], "@ui/*": ["./src/ui/*"], "@steps": ["./src/steps/index.ts"], diff --git a/tsconfig.json b/tsconfig.json index 57db83830..b3b6d448f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,6 @@ "bin.ts", "tsdown.config.ts", "vitest.config.ts", - "src/lib/**/*", "spec/**/*", "src/**/*", "test/**/*", diff --git a/vitest.config.ts b/vitest.config.ts index 7985ed29d..14d4149f8 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -32,14 +32,7 @@ function resolveTsForJs(): Plugin { // Per-surface Vitest projects keyed by today's directories. Each project runs // alone with `vitest run --project `; `vitest run` runs them all. const TESTS = '__tests__/**/*.{js,jsx,ts,tsx}'; -const AGENT_TESTS = [ - `src/lib/agent/**/${TESTS}`, - `src/lib/middleware/**/${TESTS}`, - 'src/lib/__tests__/agent-*.test.ts', - 'src/lib/__tests__/gateway-session.test.ts', - 'src/lib/__tests__/wizard-can-use-tool.test.ts', - 'src/lib/__tests__/yara-*.test.ts', -]; +const AGENT_TESTS = [`src/agent/**/${TESTS}`]; const TUI_TESTS = [`src/ui/tui/**/${TESTS}`]; const CLI_TESTS = [ `src/commands/**/${TESTS}`, @@ -85,11 +78,13 @@ export default defineConfig({ replacement: r('__mocks__/@posthog/warlock.ts'), }, { find: /^ink$/, replacement: r('__mocks__/ink.ts') }, + { find: /^@shared\/(.*)$/, replacement: `${r('src/shared')}/$1` }, + { find: /^@agent\/(.*)$/, replacement: `${r('src/agent')}/$1` }, // Path aliases — mirror tsconfig `paths`. { find: /^@env$/, replacement: r('src/env.ts') }, { find: /^@lib\/(.*)$/, replacement: `${r('src/lib')}/$1` }, { find: /^@e2e-harness\/(.*)$/, replacement: `${r('e2e-harness')}/$1` }, - { find: /^@utils\/(.*)$/, replacement: `${r('src/utils')}/$1` }, + { find: /^@utils\/(.*)$/, replacement: `${r('src/shared/utils')}/$1` }, { find: /^@ui$/, replacement: r('src/ui/index.ts') }, { find: /^@ui\/(.*)$/, replacement: `${r('src/ui')}/$1` }, { find: /^@steps$/, replacement: r('src/steps/index.ts') },