From 7c48a854fc7a8b077c6af59403991f8ab3151117 Mon Sep 17 00:00:00 2001 From: "Vincent (Wen Yu) Ge" Date: Fri, 18 Sep 2026 20:05:42 -0400 Subject: [PATCH 1/5] chore(surfaces): move the tree into agent, store, tui, and cli Every module moves under its surface: src/agent (runner, harnesses, switchboard, gateway, security adapters, tool facades), src/store (state, session, programs, tools, detection, frameworks, services, shared), src/tui (everything Ink plus console renderers and program content), src/cli (entry, commands, runners). Same-surface imports are relative; cross-surface imports use the surface aliases @store/*, @agent/*, @tui/*, @cli/*. Vitest projects and the boundary classifier follow the new directories; env.ts owns the headless flag literal. Goldens are byte identical; 19 cross-surface edges remain seeded for the next commit. Generated-By: PostHog Desktop Task-Id: d14e92bb-6ee1-49b5-8502-39cb80079589 --- .gitignore | 2 +- bin.ts | 46 +- .../__tests__/e2e-flow-snapshot.test.ts | 33 +- e2e-harness/__tests__/e2e-profile-ask.test.ts | 12 +- e2e-harness/__tests__/e2e-result.test.ts | 14 +- .../__tests__/wizard-ci-driver.test.ts | 40 +- e2e-harness/action-registry.ts | 12 +- e2e-harness/e2e-profile.ts | 6 +- e2e-harness/e2e-result.ts | 8 +- e2e-harness/profiles.ts | 22 +- e2e-harness/wizard-ci-driver.ts | 11 +- e2e-tests/mocks/handlers.ts | 4 +- scripts/__fixtures__/chunk-manifest.prod.json | 973 +++++++++--------- scripts/check-screens.tsx | 12 +- scripts/generate-version.cjs | 2 +- scripts/mcp-install-smoke-test.ts | 2 +- scripts/tui-host.no-jest.ts | 42 +- scripts/warlock-smoke-test.ts | 4 +- .../architecture/import-boundaries.test.ts | 48 +- .../architecture/known-violations.json | 41 +- .../__snapshots__/commandments.test.ts.snap | 0 .../__tests__/agent-interface.test.ts | 28 +- .../__tests__/agent-prompt-loader.test.ts | 6 +- .../agent/__tests__/agent-prompt.test.ts | 6 +- .../__tests__/agent-runner-ask.test.ts | 4 +- .../agent/__tests__/aio-capture.test.ts | 2 +- .../agent/__tests__/bash-fence-python.test.ts | 2 +- .../agent/__tests__/commandments.test.ts | 6 +- .../__tests__/gateway-session.test.ts | 26 +- .../agent/__tests__/output-signals.test.ts | 7 +- .../agent/__tests__/run-tags.test.ts | 4 +- .../agent/__tests__/stored-login.test.ts | 4 +- .../agent/__tests__/triage-provider.test.ts | 6 +- .../agent/__tests__/tutorial-run-tags.test.ts | 6 +- .../agent/__tests__/variant-gating.test.ts | 2 +- .../__tests__/wizard-can-use-tool.test.ts | 6 +- .../__tests__/yara-hooks.test.ts | 10 +- .../__tests__/yara-policy.test.ts | 2 +- src/{lib => }/agent/agent-interface.ts | 78 +- src/{lib => }/agent/agent-phase.ts | 0 src/{lib => }/agent/agent-prompt-loader.ts | 16 +- src/{lib => }/agent/agent-prompt.ts | 5 +- src/{lib => }/agent/agent-runner.ts | 2 +- src/{lib => }/agent/aio-capture.ts | 4 +- src/{lib => }/agent/bash-fence.ts | 2 +- src/{lib => }/agent/commandments.ts | 0 src/{lib => agent/gateway}/gateway-session.ts | 16 +- src/{lib => }/agent/mcp-prompt-streaming.ts | 21 +- src/{lib => agent}/middleware/benchmark.ts | 22 +- .../middleware/benchmarks/cache-tracker.ts | 4 +- .../benchmarks/compaction-tracker.ts | 6 +- .../benchmarks/context-size-tracker.ts | 4 +- .../middleware/benchmarks/cost-tracker.ts | 8 +- .../middleware/benchmarks/duration-tracker.ts | 2 +- .../middleware/benchmarks/index.ts | 25 +- .../middleware/benchmarks/json-writer.ts | 24 +- .../middleware/benchmarks/summary.ts | 20 +- .../middleware/benchmarks/token-tracker.ts | 4 +- .../middleware/benchmarks/turn-counter.ts | 2 +- src/{lib => agent}/middleware/config.ts | 6 +- src/agent/middleware/index.ts | 19 + .../middleware/phase-detector.ts | 0 src/{lib => agent}/middleware/pipeline.ts | 4 +- src/{lib => agent}/middleware/types.ts | 2 +- src/{lib => }/agent/output-signals.ts | 5 +- src/{lib => }/agent/runner/README.md | 0 .../runner/__tests__/switchboard.test.ts | 10 +- .../runner/harness/agents-platform/README.md | 0 .../agent/runner/harness/anthropic/README.md | 0 .../agent/runner/harness/anthropic/index.ts | 16 +- .../agent/runner/harness/pi/README.md | 0 .../harness/pi/__tests__/completion.test.ts | 4 +- .../harness/pi/__tests__/env-lockdown.test.ts | 2 +- .../harness/pi/__tests__/gateway.test.ts | 4 +- .../harness/pi/__tests__/security.test.ts | 6 +- .../harness/pi/__tests__/status-line.test.ts | 4 +- .../harness/pi/__tests__/task-tools.test.ts | 2 +- .../runner/harness/pi/__tests__/tools.test.ts | 10 +- .../agent/runner/harness/pi/completion.ts | 2 +- .../agent/runner/harness/pi/gateway.ts | 4 +- .../agent/runner/harness/pi/index.ts | 52 +- src/{lib => }/agent/runner/harness/pi/mcp.ts | 4 +- .../runner/harness/pi/orchestrator-tools.ts | 6 +- .../agent/runner/harness/pi/runtime-notes.ts | 2 +- .../agent/runner/harness/pi/security.ts | 10 +- .../agent/runner/harness/pi/subagent.ts | 2 +- src/{lib => }/agent/runner/harness/pi/task.ts | 51 +- .../agent/runner/harness/pi/tasks.ts | 2 +- .../agent/runner/harness/pi/tools.ts | 25 +- src/{lib => }/agent/runner/harness/types.ts | 26 +- src/{lib => }/agent/runner/index.ts | 28 +- src/{lib => }/agent/runner/sequence/README.md | 0 src/{lib => }/agent/runner/sequence/linear.ts | 38 +- .../__tests__/completed-seeded-types.test.ts | 9 +- .../orchestrator/__tests__/executor.test.ts | 11 +- .../__tests__/handoff-schema-parity.test.ts | 4 +- .../__tests__/optional-tasks.test.ts | 6 +- .../__tests__/queue-tools.test.ts | 19 +- .../orchestrator/__tests__/queue.test.ts | 4 +- .../__tests__/run-metrics.test.ts | 2 +- .../__tests__/seeded-decline-skip.test.ts | 8 +- .../__tests__/seeded-deps.test.ts | 12 +- .../__tests__/sink-closure.test.ts | 13 +- .../__tests__/skill-sweep.test.ts | 2 +- .../__tests__/task-notice-timeout.test.ts | 8 +- .../__tests__/variant-resolution.test.ts | 8 +- .../runner/sequence/orchestrator/executor.ts | 6 +- .../orchestrator/orchestrator-runner.ts | 48 +- .../sequence/orchestrator/queue-tools.ts | 9 +- .../runner/sequence/orchestrator/queue.ts | 4 +- .../sequence/orchestrator/run-metrics.ts | 0 .../sequence/orchestrator/seeded-deps.ts | 4 +- .../refresh-access-token-if-needed.test.ts | 23 +- .../agent/runner/shared/authenticate.ts | 18 +- .../agent/runner/shared/bootstrap.ts | 44 +- src/{lib => }/agent/runner/shared/errors.ts | 6 +- src/{lib => }/agent/runner/shared/types.ts | 6 +- .../agent/runner/switchboard/commandments.ts | 9 +- .../flags/__tests__/binding-cases.ts | 6 +- .../switchboard/flags/__tests__/flags.test.ts | 14 +- .../agent/runner/switchboard/flags/index.ts | 19 +- .../runner/switchboard/flags/orchestrator.ts | 4 +- .../agent/runner/switchboard/flags/schemes.ts | 8 +- .../runner/switchboard/flags/self-driving.ts | 4 +- .../agent/runner/switchboard/harness.ts | 14 +- .../agent/runner/switchboard/index.ts | 16 +- .../agent/runner/switchboard/models.ts | 2 +- .../agent/runner/switchboard/sequence.ts | 20 +- src/{lib => agent/security}/yara-hooks.ts | 26 +- src/{lib => agent/security}/yara-policy.ts | 0 src/{lib => }/agent/stored-login.ts | 4 +- src/{lib/wizard-tools => agent/tools}/mcp.ts | 26 +- src/{lib => }/agent/triage-provider.ts | 8 +- .../__tests__/basic-integration-cli.test.ts | 6 +- src/{ => cli}/__tests__/cli.test.ts | 46 +- .../__tests__/headless-scope.test.ts | 12 +- .../helpers/parse-command.no-jest.ts | 4 +- src/{ => cli}/__tests__/mcp-cli.test.ts | 18 +- src/{ => cli}/__tests__/programs-cli.test.ts | 34 +- src/{ => cli}/__tests__/provision-cli.test.ts | 34 +- src/{ => cli}/__tests__/skill-cli.test.ts | 16 +- src/{ => cli}/__tests__/wizard.test.ts | 20 +- src/{ => cli}/commands/ai-observability.ts | 6 +- src/{ => cli}/commands/audit.ts | 6 +- .../__tests__/ci-install.test.ts | 2 +- .../commands/basic-integration/ci-install.ts | 20 +- .../commands/basic-integration/index.ts | 24 +- .../commands/basic-integration/interactive.ts | 4 +- .../basic-integration/non-interactive.ts | 6 +- .../commands/basic-integration/playground.ts | 7 + .../commands/basic-integration/skill.ts | 6 +- .../commands/cli/__tests__/add.test.ts | 10 +- src/{ => cli}/commands/cli/add.ts | 10 +- src/{ => cli}/commands/cli/index.ts | 4 +- src/{ => cli}/commands/command.ts | 2 +- src/{ => cli}/commands/doctor.ts | 24 +- src/{ => cli}/commands/error-tracking.ts | 6 +- .../factories/__tests__/family-picker.test.ts | 6 +- .../__tests__/native-command-factory.test.ts | 6 +- .../factories/family-command-factory.ts | 14 +- .../factories/native-command-factory.ts | 6 +- src/{ => cli}/commands/factories/shared.ts | 16 +- src/{ => cli}/commands/mcp-analytics.ts | 6 +- src/{ => cli}/commands/mcp/add.ts | 22 +- src/cli/commands/mcp/index.ts | 10 + src/{ => cli}/commands/mcp/remove.ts | 20 +- .../commands/mcp/tui-availability.ts | 0 src/{ => cli}/commands/mcp/tutorial.ts | 18 +- src/{ => cli}/commands/metrics.ts | 6 +- src/{ => cli}/commands/migrate.ts | 6 +- src/{ => cli}/commands/provision.ts | 10 +- src/{ => cli}/commands/replay-vision.ts | 6 +- src/{ => cli}/commands/revenue.ts | 6 +- src/{ => cli}/commands/self-driving.ts | 8 +- .../commands/skill-program-options.ts | 0 src/{ => cli}/commands/skill.ts | 18 +- src/{ => cli}/commands/slack.ts | 18 +- src/{ => cli}/commands/upload-sourcemaps.ts | 8 +- src/{ => cli}/commands/warehouse.ts | 6 +- src/{lib => cli}/headless-mode.ts | 3 +- .../runners/__tests__/mint-recovery.test.ts | 38 +- src/cli/runners/index.ts | 5 + .../runners/resolve-no-telemetry.ts | 0 .../runners/run-non-interactive.ts | 59 +- src/{lib => cli}/runners/run-wizard-ci.ts | 4 +- .../runners/run-wizard-headless.ts | 4 +- src/{lib => cli}/runners/run-wizard.ts | 60 +- src/{ => cli}/telemetry.ts | 2 +- src/{ => cli}/wizard.ts | 12 +- src/commands/basic-integration/playground.ts | 7 - src/commands/mcp/index.ts | 10 - src/env.ts | 3 +- src/lib/middleware/index.ts | 15 - src/lib/registry.ts | 59 -- src/lib/runners/index.ts | 5 - src/steps/index.ts | 4 - ...credential-isolation-snapshot.test.ts.snap | 0 .../__tests__/agent-env-isolation.test.ts | 2 +- .../__tests__/claude-settings-backup.test.ts | 4 +- src/{ => store}/__tests__/clipboard.test.ts | 2 +- .../__tests__/cloudflare-detection.test.ts | 4 +- .../__tests__/constants.test.ts | 5 +- .../credential-isolation-snapshot.test.ts | 6 +- .../__tests__/fetch-retry.test.ts | 7 +- .../__tests__/flow-resolution.test.ts | 22 +- .../__tests__/host-resolution.test.ts | 4 +- .../__tests__/link-helpers.test.ts | 2 +- .../__tests__/local-dev.test.ts | 4 +- .../__tests__/mcp-project-profile.test.ts | 2 +- .../__tests__/mcp-role-prompts.test.ts | 6 +- .../__tests__/mcp-seed-events.test.ts | 4 +- .../__tests__/package-json.test.ts | 2 +- .../__tests__/secret-vault.test.ts | 2 +- .../__tests__/settings-conflicts.test.ts | 8 +- .../__tests__/token-pricing.test.ts | 2 +- .../__tests__/wizard-abort.test.ts | 16 +- .../__tests__/wizard-ask-bridge.test.ts | 8 +- .../__tests__/wizard-spellbook.test.ts | 14 +- .../__tests__/wizard-tools.test.ts | 4 +- .../agent-protocol}/agent-env-isolation.ts | 0 .../agent-protocol}/agent-signals.ts | 0 .../agent-protocol}/program-run.ts | 8 +- .../agent-protocol}/token-pricing.ts | 2 +- src/{lib => store}/api.ts | 4 +- src/{lib => store}/auth-session-state.ts | 0 src/{lib => store}/cloudflare-detection.ts | 4 +- .../detection/__tests__/agentic.test.ts | 2 +- .../detection/__tests__/context.test.ts | 9 +- .../detection/__tests__/features.test.ts | 4 +- .../detection/__tests__/framework.test.ts | 18 +- .../__tests__/package-manager.test.ts | 8 +- .../detection/__tests__/project-scope.test.ts | 21 +- src/{lib => store}/detection/agentic.ts | 16 +- src/{lib => store}/detection/context.ts | 6 +- src/{lib => store}/detection/features.ts | 4 +- src/{lib => store}/detection/framework.ts | 4 +- src/{lib => store}/detection/index.ts | 0 .../detection/package-manager.ts | 4 +- src/{lib => store}/detection/project-scope.ts | 14 +- src/{lib => store}/fetch-retry.ts | 6 +- src/{lib => store}/file-watcher.ts | 2 +- src/{lib => store}/framework-config.ts | 6 +- .../android/android-wizard-agent.ts | 12 +- src/{ => store}/frameworks/android/utils.ts | 6 +- .../angular/angular-wizard-agent.ts | 14 +- src/{ => store}/frameworks/angular/utils.ts | 2 +- .../frameworks/astro/astro-wizard-agent.ts | 16 +- src/{ => store}/frameworks/astro/utils.ts | 6 +- .../frameworks/django/django-wizard-agent.ts | 14 +- src/{ => store}/frameworks/django/utils.ts | 8 +- .../frameworks/elixir/elixir-wizard-agent.ts | 8 +- .../fastapi/fastapi-wizard-agent.ts | 14 +- src/{ => store}/frameworks/fastapi/utils.ts | 6 +- .../frameworks/flask/flask-wizard-agent.ts | 14 +- src/{ => store}/frameworks/flask/utils.ts | 8 +- .../flutter/flutter-wizard-agent.ts | 8 +- .../frameworks/go/go-wizard-agent.ts | 8 +- .../frameworks/java/java-wizard-agent.ts | 8 +- .../javascript-node-wizard-agent.ts | 8 +- .../javascript-web-wizard-agent.ts | 14 +- .../frameworks/javascript-web/utils.ts | 6 +- .../frameworks/kmp/kmp-wizard-agent.ts | 8 +- .../laravel/laravel-wizard-agent.ts | 12 +- src/{ => store}/frameworks/laravel/utils.ts | 8 +- .../frameworks/nextjs/nextjs-wizard-agent.ts | 16 +- src/{ => store}/frameworks/nextjs/utils.ts | 6 +- .../frameworks/nuxt/nuxt-wizard-agent.ts | 14 +- .../frameworks/python/python-wizard-agent.ts | 12 +- src/{ => store}/frameworks/python/utils.ts | 2 +- .../frameworks/rails/rails-wizard-agent.ts | 10 +- src/{ => store}/frameworks/rails/utils.ts | 6 +- .../react-native/react-native-wizard-agent.ts | 14 +- .../frameworks/react-native/utils.ts | 10 +- .../react-router/react-router-wizard-agent.ts | 16 +- .../frameworks/react-router/utils.ts | 10 +- .../frameworks/ruby/ruby-wizard-agent.ts | 10 +- src/{ => store}/frameworks/ruby/utils.ts | 6 +- .../frameworks/rust/rust-wizard-agent.ts | 8 +- .../frameworks/svelte/svelte-wizard-agent.ts | 10 +- .../frameworks/swift/__tests__/utils.test.ts | 4 +- .../frameworks/swift/swift-wizard-agent.ts | 12 +- src/{ => store}/frameworks/swift/utils.ts | 4 +- .../tanstack-router-wizard-agent.ts | 16 +- .../frameworks/tanstack-router/utils.ts | 8 +- .../tanstack-start-wizard-agent.ts | 14 +- .../frameworks/tanstack-start/utils.ts | 2 +- .../frameworks/vue/vue-wizard-agent.ts | 12 +- .../__tests__/health-checks.test.ts | 9 +- src/{lib => store}/health-checks/endpoints.ts | 9 +- src/{lib => store}/health-checks/index.ts | 6 +- src/{lib => store}/health-checks/readiness.ts | 6 +- src/{lib => store}/health-checks/testme.md | 0 src/{lib => store}/health-checks/types.ts | 0 src/{lib => store}/helper-functions.ts | 0 src/{lib => store}/host-resolution.ts | 6 +- src/{lib => store}/local-dev.ts | 0 src/{lib => store}/mcp-project-profile.ts | 4 +- src/{lib => store}/mcp-role-prompts.copy.json | 0 src/{lib => store}/mcp-role-prompts.ts | 4 +- src/{lib => store}/mcp-seed-events.ts | 4 +- .../__snapshots__/flow-traces.test.ts.snap | 0 .../post-auth-gates.test.ts.snap | 0 .../programs/__tests__/agent-skill.test.ts | 8 +- .../programs/__tests__/audit-seed.test.ts | 6 +- .../programs/__tests__/error-tracking.test.ts | 44 +- .../programs/__tests__/flow-traces.test.ts | 32 +- .../programs/__tests__/mcp-analytics.test.ts | 2 +- .../__tests__/metrics-program.test.ts | 10 +- .../__tests__/post-auth-gates.test.ts | 4 +- .../__tests__/posthog-cli-preinstall.test.ts | 14 +- .../posthog-integration-detect.test.ts | 2 +- .../__tests__/program-registry.test.ts | 4 +- .../programs/__tests__/program-step.test.ts | 6 +- .../programs/__tests__/replay-vision.test.ts | 4 +- .../revenue-analytics-detect.test.ts | 4 +- .../__tests__/self-driving-detect.test.ts | 26 +- .../__tests__/self-driving-prompt.test.ts | 8 +- .../source-maps-detect-agentic.test.ts | 4 +- .../__tests__/source-maps-detect.test.ts | 4 +- .../__tests__/source-maps-prompt.test.ts | 2 +- .../__tests__/warehouse-ask-timeout.test.ts | 8 +- .../__tests__/warehouse-seed-task.test.ts | 10 +- .../__tests__/warehouse-suggestion.test.ts | 13 +- .../web-analytics-doctor-detect.test.ts | 6 +- .../programs/agent-skill/index.ts | 7 +- .../programs/agent-skill/steps.ts | 6 +- .../programs/ai-observability/index.ts | 4 +- .../programs/ai-observability/test/e2e.json | 0 src/{lib => store}/programs/ai-opt-in-gate.ts | 2 +- src/{lib => store}/programs/audit/detect.ts | 4 +- src/{lib => store}/programs/audit/index.ts | 17 +- .../programs/audit/ledger-watcher.ts | 6 +- src/{lib => store}/programs/audit/seed.ts | 4 +- .../programs/audit/test/e2e.json | 0 src/{lib => store}/programs/audit/types.ts | 2 +- .../programs/dispatch-family.ts | 26 +- .../detect-agentic.ts | 6 +- .../detect.ts | 8 +- .../index.ts | 12 +- .../prompt.ts | 2 +- .../steps.ts | 6 +- .../test/e2e.json | 0 .../programs/error-tracking/detect-agentic.ts | 10 +- .../programs/error-tracking/index.ts | 26 +- .../programs/error-tracking/test/e2e.json | 0 .../programs/events-audit/constants.ts | 0 .../programs/events-audit/index.ts | 18 +- .../programs/events-audit/seed.ts | 2 +- .../programs/events-audit/steps.ts | 8 +- src/{lib => store}/programs/flow-for.ts | 2 +- .../programs/mcp-analytics/index.ts | 6 +- src/{lib => store}/programs/mcp/index.ts | 4 +- src/{lib => store}/programs/metrics/index.ts | 4 +- .../programs/metrics/test/e2e.json | 0 .../programs/migration/index.ts | 6 +- .../programs/migration/steps.ts | 6 +- .../__tests__/doctor-schema.test.ts | 7 +- .../programs/posthog-doctor/fetch.ts | 8 +- .../programs/posthog-doctor/index.ts | 4 +- .../programs/posthog-doctor/kind-metadata.ts | 2 +- .../programs/posthog-doctor/steps.ts | 4 +- .../programs/posthog-doctor/types.ts | 0 .../__tests__/detect.test.ts | 41 +- .../__tests__/handoff.test.ts | 2 +- .../__tests__/index.test.ts | 15 +- .../programs/posthog-integration/constants.ts | 0 .../programs/posthog-integration/detect.ts | 20 +- .../programs/posthog-integration/handoff.ts | 0 .../programs/posthog-integration/index.ts | 58 +- .../programs/posthog-integration/steps.ts | 8 +- .../posthog-integration/test/README.md | 0 .../posthog-integration/test/e2e.json | 0 .../programs/program-registry.ts | 2 +- src/{lib => store}/programs/program-step.ts | 6 +- .../programs/replay-vision/index.ts | 29 +- .../programs/replay-vision/test/e2e.json | 0 .../programs/revenue-analytics/detect.ts | 8 +- .../programs/revenue-analytics/index.ts | 4 +- .../programs/revenue-analytics/steps.ts | 6 +- src/{lib => store}/programs/run-config.ts | 2 +- .../programs/self-driving/ARCHITECTURE.md | 0 .../self-driving/__tests__/step-keys.test.ts | 0 .../programs/self-driving/detect-agentic.ts | 10 +- .../programs/self-driving/detect.ts | 12 +- .../programs/self-driving/index.ts | 8 +- .../programs/self-driving/prompt.ts | 6 +- .../programs/self-driving/step-keys.ts | 0 .../programs/self-driving/steps.ts | 10 +- .../programs/self-driving/test/e2e.json | 0 .../programs/shared/health-check-step.ts | 8 +- .../programs/shared/package-scanning.ts | 2 +- .../programs/shared/posthog-cli-preinstall.ts | 6 +- src/{lib => store}/programs/slack/index.ts | 2 +- .../programs/warehouse-source/detect.ts | 10 +- .../programs/warehouse-source/index.ts | 8 +- .../programs/warehouse-source/steps.ts | 4 +- .../programs/warehouse-source/test/e2e.json | 0 .../programs/web-analytics-doctor/detect.ts | 8 +- .../programs/web-analytics-doctor/index.ts | 2 +- .../programs/web-analytics-doctor/steps.ts | 4 +- src/store/registry.ts | 59 ++ src/{lib => store}/safe-tools.ts | 0 .../services}/claude-settings.ts | 6 +- .../oauth/__tests__/program-scopes.test.ts | 2 +- .../services}/oauth/program-scopes.ts | 4 +- .../add-mcp-server-to-clients/MCPClient.ts | 4 +- .../__tests__/defaults.test.ts | 2 +- .../__tests__/mcp-client.test.ts | 2 +- .../__tests__/results.test.ts | 2 +- .../browser-client.ts | 0 .../clients/__tests__/claude-code.test.ts | 8 +- .../clients/__tests__/claude-web.test.ts | 8 +- .../clients/__tests__/claude.test.ts | 6 +- .../clients/__tests__/codex.test.ts | 6 +- .../clients/__tests__/opencode.test.ts | 4 +- .../clients/claude-code.ts | 23 +- .../clients/claude-web.ts | 8 +- .../clients/claude.ts | 4 +- .../clients/codex.ts | 23 +- .../clients/cursor.ts | 7 +- .../clients/opencode.ts | 7 +- .../clients/visual-studio-code.ts | 7 +- .../add-mcp-server-to-clients/clients/zed.ts | 7 +- .../add-mcp-server-to-clients/defaults.ts | 0 .../steps/add-mcp-server-to-clients/index.ts | 34 +- .../add-mcp-server-to-clients/login-client.ts | 0 .../plugin-client.ts | 2 +- .../add-mcp-server-to-clients/results.ts | 0 .../add-or-update-environment-variables.ts | 10 +- src/store/services/steps/index.ts | 4 + .../__tests__/install-cli-steering.test.ts | 4 +- .../steps/install-cli-steering/index.ts | 2 +- .../services}/steps/run-prettier.ts | 14 +- .../EnvironmentProvider.ts | 0 .../upload-environment-variables/index.ts | 14 +- .../providers/__tests__/vercel.test.ts | 2 +- .../providers/vercel.ts | 6 +- .../__tests__/detect.test.ts | 6 +- .../services}/warehouse-sources/detect.ts | 12 +- .../services}/warehouse-sources/registry.ts | 0 .../services}/warehouse-sources/types.ts | 0 src/{lib => store/session}/ask-policy.ts | 2 +- src/{lib => store/session}/secret-vault.ts | 0 .../session}/wizard-ask-bridge.ts | 4 +- src/{lib => store/session}/wizard-session.ts | 16 +- .../shared}/__fixtures__/provisioning.ts | 0 .../shared}/__tests__/analytics.test.ts | 10 +- .../shared}/__tests__/bounded-fs-walk.test.ts | 10 +- .../shared}/__tests__/bounded-fs.test.ts | 2 +- .../__tests__/ci-flag-overrides.test.ts | 8 +- .../shared}/__tests__/ci-region.test.ts | 18 +- .../shared}/__tests__/debug.test.ts | 2 +- .../shared}/__tests__/env-api-key.test.ts | 2 +- .../shared}/__tests__/env-scan.test.ts | 2 +- .../shared}/__tests__/environment.test.ts | 6 +- .../shared}/__tests__/links.test.ts | 2 +- .../shared}/__tests__/oauth-errors.test.ts | 4 +- .../shared}/__tests__/oauth-refresh.test.ts | 10 +- .../shared}/__tests__/oauth-server.test.ts | 6 +- .../shared}/__tests__/oauth.test.ts | 6 +- .../__tests__/project-resolution.test.ts | 2 +- .../shared}/__tests__/provisioning.test.ts | 12 +- .../shared}/__tests__/semver.test.ts | 2 +- .../shared}/__tests__/terminal-bell.test.ts | 2 +- src/{utils => store/shared}/analytics.ts | 12 +- src/{utils => store/shared}/atomic-ledger.ts | 0 src/{utils => store/shared}/bounded-fs.ts | 6 +- .../shared}/ci-flag-overrides.ts | 2 +- src/{utils => store/shared}/clipboard.ts | 0 src/{lib => store/shared}/constants.ts | 4 +- src/{utils => store/shared}/custom-headers.ts | 0 src/{utils => store/shared}/debug.ts | 6 +- src/{utils => store/shared}/env-api-key.ts | 2 +- src/{utils => store/shared}/env-scan.ts | 2 +- src/{utils => store/shared}/environment.ts | 8 +- .../shared}/errors/__tests__/auth.test.ts | 4 +- .../shared}/errors/__tests__/codes.test.ts | 4 +- .../errors/__tests__/detect-map.test.ts | 6 +- .../errors/__tests__/run-failure.test.ts | 10 +- .../shared}/errors/__tests__/sanitize.test.ts | 2 +- src/{lib => store/shared}/errors/agent-map.ts | 4 +- src/{lib => store/shared}/errors/auth.ts | 2 +- src/{lib => store/shared}/errors/catalog.ts | 4 +- src/{lib => store/shared}/errors/codes.ts | 0 .../shared}/errors/detect-map.ts | 12 +- src/{lib => store/shared}/errors/emit.ts | 2 +- src/{lib => store/shared}/errors/index.ts | 20 +- .../shared}/errors/run-failure.ts | 2 +- src/{lib => store/shared}/errors/sanitize.ts | 0 src/{lib => store/shared}/errors/skill-map.ts | 4 +- src/{lib => store/shared}/errors/types.ts | 0 src/{utils => store/shared}/links.ts | 2 +- src/{utils => store/shared}/oauth-errors.ts | 2 +- src/{utils => store/shared}/oauth.ts | 16 +- src/{utils => store/shared}/package-json.ts | 0 .../shared}/package-manager.ts | 12 +- src/{utils => store/shared}/paths.ts | 0 .../shared}/project-resolution.ts | 0 src/{utils => store/shared}/provisioning.ts | 10 +- .../shared}/rules/astro-rules.md | 0 .../shared}/rules/next-rules.md | 0 .../shared}/rules/react-native-rules.md | 0 .../shared}/rules/react-rules.md | 0 .../shared}/rules/svelte-rules.md | 0 .../shared}/rules/universal.md | 0 src/{utils => store/shared}/semver.ts | 0 src/{utils => store/shared}/setup-utils.ts | 38 +- src/{utils => store/shared}/terminal-bell.ts | 0 src/{utils => store/shared}/types.ts | 2 +- src/{utils => store/shared}/urls.ts | 4 +- .../shared}/vendor/is-unicorn-supported.ts | 0 src/{utils => store/shared}/wizard-abort.ts | 12 +- src/{lib => store}/skill-install.ts | 0 src/{lib => store/state}/flow-resolution.ts | 2 +- src/{lib => store/state}/flow.ts | 13 +- src/{lib => store/state}/interrupts.ts | 0 src/{lib => store/state}/run-failure.ts | 2 +- src/{ui/tui => store/state}/store.ts | 26 +- .../task-stream/__tests__/audit-areas.test.ts | 9 +- .../__tests__/event-plan-watcher.test.ts | 9 +- .../__tests__/file-destination.test.ts | 8 +- .../__tests__/posthog-destination.test.ts | 8 +- .../__tests__/task-stream-push.test.ts | 20 +- src/{lib => store}/task-stream/audit-areas.ts | 4 +- .../task-stream/destinations/file.ts | 6 +- .../task-stream/destinations/posthog.ts | 6 +- .../task-stream/event-plan-watcher.ts | 4 +- src/{lib => store}/task-stream/index.ts | 14 +- .../task-stream/task-stream-push.ts | 16 +- src/{lib => store}/task-stream/types.ts | 2 +- .../tools}/__tests__/handoff.test.ts | 6 +- .../wizard-tools => store/tools}/handoff.ts | 6 +- .../wizard-tools => store/tools}/index.ts | 4 +- .../wizard-tools => store/tools}/tools.ts | 20 +- src/{ => store}/ui/index.ts | 6 +- src/{ => store}/ui/null-ui.ts | 4 +- src/{ => store}/ui/store-ui.ts | 14 +- src/{ => store}/ui/wizard-ui.ts | 10 +- src/{lib => store}/wizard-spellbook.ts | 8 +- src/{ui => }/tui/App.tsx | 2 +- .../tui/__tests__/MintFailureScreen.test.tsx | 20 +- .../tui/__tests__/WizardAskScreen.test.ts | 10 +- .../frames/agent-skill-intro-120x40.txt | 0 .../frames/agent-skill-intro-60x15.txt | 0 .../frames/ai-observability-intro-120x40.txt | 0 .../frames/ai-observability-intro-60x15.txt | 0 .../__snapshots__/frames/ai-opt-in-120x40.txt | 0 .../__snapshots__/frames/ai-opt-in-60x15.txt | 0 .../frames/audit-intro-120x40.txt | 0 .../frames/audit-intro-60x15.txt | 0 .../frames/audit-outro-120x40.txt | 0 .../frames/audit-outro-60x15.txt | 0 .../__snapshots__/frames/audit-run-120x40.txt | 0 .../__snapshots__/frames/audit-run-60x15.txt | 0 .../__snapshots__/frames/auth-120x40.txt | 0 .../__snapshots__/frames/auth-60x15.txt | 0 .../frames/auth-error-120x40.txt | 0 .../__snapshots__/frames/auth-error-60x15.txt | 0 .../frames/doctor-intro-120x40.txt | 0 .../frames/doctor-intro-60x15.txt | 0 .../frames/doctor-report-120x40.txt | 0 .../frames/doctor-report-60x15.txt | 0 .../frames/error-tracking-detect-120x40.txt | 0 .../frames/error-tracking-detect-60x15.txt | 0 .../frames/error-tracking-intro-120x40.txt | 0 .../frames/error-tracking-intro-60x15.txt | 0 .../__snapshots__/frames/exit-120x40.txt | 0 .../__snapshots__/frames/exit-60x15.txt | 0 .../frames/health-check-120x40.txt | 0 .../frames/health-check-60x15.txt | 0 .../__snapshots__/frames/intro-120x40.txt | 0 .../__snapshots__/frames/intro-60x15.txt | 0 .../frames/keep-skills-120x40.txt | 0 .../frames/keep-skills-60x15.txt | 0 .../frames/managed-settings-120x40.txt | 0 .../frames/managed-settings-60x15.txt | 0 .../frames/manual-auth-code-120x40.txt | 0 .../frames/manual-auth-code-60x15.txt | 0 .../__snapshots__/frames/mcp-120x40.txt | 0 .../__snapshots__/frames/mcp-60x15.txt | 0 .../__snapshots__/frames/mcp-add-120x40.txt | 0 .../__snapshots__/frames/mcp-add-60x15.txt | 0 .../frames/mcp-remove-120x40.txt | 0 .../__snapshots__/frames/mcp-remove-60x15.txt | 0 .../frames/mcp-suggested-prompts-120x40.txt | 0 .../frames/mcp-suggested-prompts-60x15.txt | 0 .../frames/metrics-intro-120x40.txt | 0 .../frames/metrics-intro-60x15.txt | 0 .../frames/migration-intro-120x40.txt | 0 .../frames/migration-intro-60x15.txt | 0 .../frames/mint-failure-120x40.txt | 0 .../frames/mint-failure-60x15.txt | 0 .../__snapshots__/frames/outro-120x40.txt | 0 .../__snapshots__/frames/outro-60x15.txt | 0 .../frames/port-conflict-120x40.txt | 0 .../frames/port-conflict-60x15.txt | 0 .../frames/revenue-intro-120x40.txt | 0 .../frames/revenue-intro-60x15.txt | 0 .../__snapshots__/frames/run-120x40.txt | 0 .../__snapshots__/frames/run-60x15.txt | 0 .../frames/self-driving-github-120x40.txt | 0 .../frames/self-driving-github-60x15.txt | 0 .../frames/self-driving-handoff-120x40.txt | 0 .../frames/self-driving-handoff-60x15.txt | 0 .../self-driving-integration-check-120x40.txt | 0 .../self-driving-integration-check-60x15.txt | 0 ...self-driving-integration-detect-120x40.txt | 0 .../self-driving-integration-detect-60x15.txt | 0 .../frames/self-driving-intro-120x40.txt | 0 .../frames/self-driving-intro-60x15.txt | 0 .../frames/session-timeout-120x40.txt | 0 .../frames/session-timeout-60x15.txt | 0 .../frames/settings-override-120x40.txt | 0 .../frames/settings-override-60x15.txt | 0 .../__snapshots__/frames/setup-120x40.txt | 0 .../__snapshots__/frames/setup-60x15.txt | 0 .../frames/slack-connect-120x40.txt | 0 .../frames/slack-connect-60x15.txt | 0 .../frames/source-maps-detect-120x40.txt | 0 .../frames/source-maps-detect-60x15.txt | 0 .../frames/source-maps-intro-120x40.txt | 0 .../frames/source-maps-intro-60x15.txt | 0 .../frames/source-maps-outro-120x40.txt | 0 .../frames/source-maps-outro-60x15.txt | 0 .../frames/task-notice-120x40.txt | 0 .../frames/task-notice-60x15.txt | 0 .../frames/warehouse-intro-120x40.txt | 0 .../frames/warehouse-intro-60x15.txt | 0 .../frames/wizard-ask-120x40.txt | 0 .../__snapshots__/frames/wizard-ask-60x15.txt | 0 .../keyboard-equivalence.test.tsx.snap | 0 .../__tests__/coding-agent-launcher.test.ts | 2 +- src/{ui => }/tui/__tests__/exit-line.test.ts | 14 +- src/{ui => }/tui/__tests__/frames.test.tsx | 68 +- .../tui/__tests__/headless-ui.test.ts | 6 +- .../helpers/render-screen.no-jest.tsx | 8 +- .../__tests__/keyboard-equivalence.test.tsx | 58 +- .../tui/__tests__/keyboard-hints.test.ts | 2 +- .../tui/__tests__/layout-helpers.test.ts | 4 +- .../tui/__tests__/mcp-installer.test.ts | 16 +- .../tui/__tests__/picker-filter.test.ts | 2 +- .../posthog-integration-intro.test.ts | 2 +- src/{ui => }/tui/__tests__/programs.test.ts | 16 +- .../tui/__tests__/self-driving-deck.test.ts | 2 +- .../tui/__tests__/skill-entry.test.ts | 4 +- .../tui/__tests__/store-invariants.test.ts | 32 +- src/{ui => }/tui/__tests__/store.test.ts | 32 +- .../tui/__tests__/task-notice.test.ts | 12 +- src/{ui => }/tui/__tests__/ui-store.test.ts | 12 +- .../tui/__tests__/viewport-too-small.test.ts | 2 +- src/{ui => }/tui/components/LearnCard.tsx | 17 +- src/{ui => }/tui/components/PhaseVisuals.tsx | 22 +- src/{ui => }/tui/components/PrivacyPanel.tsx | 4 +- .../tui/components/ServiceHealthList.tsx | 6 +- .../tui/components/StatusPeekTrigger.tsx | 4 +- src/{ui => }/tui/components/TipsCard.tsx | 9 +- src/{ui => }/tui/components/TitleBar.tsx | 2 +- src/{ui => }/tui/components/TokenCostHud.tsx | 9 +- .../components/__tests__/TokenCostHud.test.ts | 4 +- .../__tests__/visualizer-grid.test.ts | 6 +- .../tui/components/visualizer/CrateStack.tsx | 8 +- .../components/visualizer/DashboardGrid.tsx | 8 +- .../tui/components/visualizer/DiffCascade.tsx | 6 +- .../components/visualizer/LibraryShelf.tsx | 8 +- .../tui/components/visualizer/MatrixRain.tsx | 4 +- .../tui/components/visualizer/Tumblers.tsx | 13 +- .../tui/components/visualizer/grid.ts | 0 .../tui/components/visualizer/palette.ts | 0 .../tui/components/visualizer/panel.tsx | 2 +- src/{ui => }/tui/console/headless-ui.ts | 2 +- src/{ui => }/tui/console/logging-ui.ts | 14 +- src/{ui => }/tui/constants.ts | 2 +- src/{ui => }/tui/exit-line.ts | 13 +- .../factories => tui}/family-picker.tsx | 6 +- .../tui/hooks/__tests__/file-watcher.test.ts | 9 +- .../__tests__/useDismissOnAnyKey.test.ts | 2 +- .../__tests__/useGithubConnection.test.ts | 10 +- src/{ui => }/tui/hooks/file-watcher.ts | 9 +- .../tui/hooks/keyboard-hints-utils.ts | 0 src/{ui => }/tui/hooks/useDismissOnAnyKey.ts | 0 src/{ui => }/tui/hooks/useGithubConnection.ts | 10 +- src/{ui => }/tui/hooks/useKeyBindings.ts | 0 src/{ui => }/tui/hooks/useKeyboardHints.tsx | 0 src/{ui => }/tui/hooks/useStdoutDimensions.ts | 0 src/{ui => }/tui/hooks/useTick.ts | 0 src/{ui => }/tui/hooks/useUiStore.ts | 0 src/tui/ink-ui.ts | 1 + src/{ui => tui}/mint-failure.ts | 2 +- src/{ui => }/tui/package.json | 0 src/{ui => }/tui/playground/PlaygroundApp.tsx | 6 +- .../tui/playground/demos/AiOptInDemo.tsx | 10 +- .../tui/playground/demos/AskModalDemo.tsx | 4 +- .../tui/playground/demos/AuditChecksDemo.tsx | 4 +- .../tui/playground/demos/DoctorReportDemo.tsx | 6 +- .../tui/playground/demos/EndScreensDemo.tsx | 12 +- .../tui/playground/demos/HealthCheckDemo.tsx | 12 +- .../tui/playground/demos/InputDemo.tsx | 4 +- .../playground/demos/KeyboardHintsDemo.tsx | 4 +- .../tui/playground/demos/LayoutDemo.tsx | 8 +- .../tui/playground/demos/LearnDeckDemo.tsx | 16 +- src/{ui => }/tui/playground/demos/LogDemo.tsx | 4 +- src/{ui => }/tui/playground/demos/McpDemo.tsx | 8 +- .../demos/McpSuggestedPromptsDemo.tsx | 20 +- .../tui/playground/demos/ModalDemo.tsx | 4 +- .../tui/playground/demos/ProgressDemo.tsx | 6 +- .../tui/playground/demos/RunScreenDemo.tsx | 26 +- .../playground/demos/ViewportGuardDemo.tsx | 2 +- .../tui/playground/demos/WelcomeDemo.tsx | 4 +- .../tui/playground/start-playground.ts | 12 +- src/{ui => }/tui/posthog-integration-intro.ts | 2 +- src/{ui => }/tui/primitives/CardLayout.tsx | 2 +- src/{ui => }/tui/primitives/ConfirmButton.tsx | 2 +- .../tui/primitives/ConfirmationInput.tsx | 4 +- .../tui/primitives/ContentSequencer.tsx | 0 .../tui/primitives/DissolveTransition.tsx | 0 src/{ui => }/tui/primitives/Divider.tsx | 0 .../tui/primitives/EventPlanViewer.tsx | 2 +- .../tui/primitives/GroupedPickerMenu.tsx | 6 +- src/{ui => }/tui/primitives/HNViewer.tsx | 4 +- .../tui/primitives/KeyboardHintsBar.tsx | 4 +- src/{ui => }/tui/primitives/LinesBlock.tsx | 0 src/{ui => }/tui/primitives/LinkText.tsx | 2 +- src/{ui => }/tui/primitives/LoadingBox.tsx | 0 src/{ui => }/tui/primitives/LogViewer.tsx | 2 +- src/{ui => }/tui/primitives/ModalOverlay.tsx | 0 src/{ui => }/tui/primitives/NodeBlock.tsx | 0 src/{ui => }/tui/primitives/PickerMenu.tsx | 6 +- src/{ui => }/tui/primitives/ProgressList.tsx | 2 +- src/{ui => }/tui/primitives/PromptLabel.tsx | 2 +- .../tui/primitives/ScreenContainer.tsx | 14 +- .../tui/primitives/ScreenErrorBoundary.tsx | 6 +- src/{ui => }/tui/primitives/SplitView.tsx | 0 src/{ui => }/tui/primitives/TabContainer.tsx | 10 +- src/{ui => }/tui/primitives/TextBlock.tsx | 2 +- .../tui/primitives/ViewportTooSmall.tsx | 2 +- src/{ui => }/tui/primitives/content-types.ts | 0 src/{ui => }/tui/primitives/index.ts | 0 src/{ui => }/tui/primitives/layout-helpers.ts | 0 src/{ui => }/tui/primitives/link-helpers.ts | 0 src/{ui => }/tui/primitives/picker-filter.ts | 0 src/{ui => }/tui/primitives/text-helpers.ts | 0 .../programs/agent-skill/content/index.tsx | 6 +- .../content/index.tsx | 10 +- .../programs/error-tracking/content/index.tsx | 6 +- .../programs/error-tracking/content/tips.ts | 4 +- .../programs/migration/content/free-tier.tsx | 4 +- .../tui/programs/migration/content/index.tsx | 16 +- .../migration/content/pricing-structure.tsx | 4 +- .../migration/content/vendor-stack.tsx | 2 +- .../posthog-integration/content/data-flow.tsx | 4 +- .../posthog-integration/content/funnel.tsx | 2 +- .../posthog-integration/content/index.tsx | 10 +- .../content/line-chart.tsx | 2 +- .../content/product-suite.tsx | 2 +- src/{ui => }/tui/programs/presentation.ts | 8 +- .../revenue-analytics/content/index.tsx | 2 +- .../programs/self-driving/content/index.tsx | 10 +- .../self-driving/content/pipeline-diagram.tsx | 4 +- .../programs/self-driving/content/pricing.ts | 0 .../tui/programs/self-driving/content/tips.ts | 2 +- .../warehouse-source/content/index.tsx | 2 +- src/{ui => }/tui/router.ts | 4 +- src/{ui => }/tui/screen-registry.tsx | 10 +- src/{ui => }/tui/screen-sequences.ts | 0 .../tui/screens/AgentSkillIntroScreen.tsx | 2 +- .../screens/AiObservabilityIntroScreen.tsx | 9 +- .../tui/screens/AiOptInRequiredScreen.tsx | 19 +- src/{ui => }/tui/screens/AuthErrorScreen.tsx | 6 +- src/{ui => }/tui/screens/AuthScreen.tsx | 18 +- .../tui/screens/ErrorTrackingDetectScreen.tsx | 10 +- .../tui/screens/ErrorTrackingIntroScreen.tsx | 9 +- src/{ui => }/tui/screens/ExitScreen.tsx | 2 +- .../tui/screens/IntroScreenLayout.tsx | 4 +- src/{ui => }/tui/screens/KeepSkillsScreen.tsx | 8 +- .../tui/screens/ManagedSettingsScreen.tsx | 10 +- .../tui/screens/ManualAuthCodeScreen.tsx | 6 +- src/{ui => }/tui/screens/McpScreen.tsx | 12 +- .../tui/screens/McpSuggestedPromptsScreen.tsx | 22 +- .../tui/screens/MetricsIntroScreen.tsx | 9 +- .../tui/screens/MigrationIntroScreen.tsx | 2 +- .../tui/screens/MintFailureScreen.tsx | 14 +- src/{ui => }/tui/screens/OutroScreen.tsx | 12 +- .../tui/screens/PortConflictScreen.tsx | 6 +- .../screens/PostHogIntegrationIntroScreen.tsx | 26 +- .../tui/screens/RevenueIntroScreen.tsx | 6 +- src/{ui => }/tui/screens/RunScreen.tsx | 24 +- .../tui/screens/SelfDrivingGitHubScreen.tsx | 20 +- .../tui/screens/SelfDrivingHandoffScreen.tsx | 10 +- .../SelfDrivingIntegrationCheckScreen.tsx | 17 +- .../SelfDrivingIntegrationDetectScreen.tsx | 14 +- .../tui/screens/SelfDrivingIntroScreen.tsx | 8 +- .../tui/screens/SessionTimeoutScreen.tsx | 8 +- .../tui/screens/SettingsOverrideScreen.tsx | 8 +- src/{ui => }/tui/screens/SetupScreen.tsx | 8 +- src/{ui => }/tui/screens/SkillSourceInfo.tsx | 7 +- .../tui/screens/SlackConnectScreen.tsx | 22 +- .../tui/screens/SourceMapsDetectScreen.tsx | 10 +- .../tui/screens/SourceMapsIntroScreen.tsx | 2 +- .../tui/screens/SourceMapsOutroScreen.tsx | 8 +- src/{ui => }/tui/screens/TaskNoticeScreen.tsx | 6 +- .../tui/screens/WarehouseIntroScreen.tsx | 6 +- src/{ui => }/tui/screens/WizardAskScreen.tsx | 12 +- .../__tests__/IntroScreenLayout.test.ts | 7 +- .../PostHogIntegrationIntroScreen.test.ts | 4 +- .../tui/screens/audit/AuditAreaPane.tsx | 4 +- .../screens/audit/AuditChecksOutroSection.tsx | 4 +- .../audit/AuditChecksViewer/AreaHeaderRow.tsx | 0 .../AuditChecksViewer/AuditChecksViewer.tsx | 6 +- .../audit/AuditChecksViewer/CheckRow.tsx | 2 +- .../audit/AuditChecksViewer/DetailRow.tsx | 2 +- .../audit/AuditChecksViewer/Footer.tsx | 2 +- .../audit/AuditChecksViewer/Header.tsx | 2 +- .../audit/AuditChecksViewer/Legend.tsx | 0 .../screens/audit/AuditChecksViewer/layout.ts | 2 +- .../screens/audit/AuditChecksViewer/sort.ts | 2 +- .../tui/screens/audit/AuditIntroScreen.tsx | 9 +- .../tui/screens/audit/AuditOutroScreen.tsx | 10 +- .../tui/screens/audit/AuditRunScreen.tsx | 12 +- .../tui/screens/audit/PendingChecksList.tsx | 8 +- .../tui/screens/audit/slides/eventCapture.tsx | 0 .../slides/events-audit/createDashboard.tsx | 0 .../audit/slides/events-audit/detectSdk.tsx | 0 .../audit/slides/events-audit/enrichSites.tsx | 0 .../audit/slides/events-audit/index.ts | 0 .../audit/slides/events-audit/queryVolume.tsx | 0 .../audit/slides/events-audit/scanSites.tsx | 0 .../slides/events-audit/uploadNotebook.tsx | 0 .../audit/slides/events-audit/writeReport.tsx | 0 .../screens/audit/slides/identification.tsx | 0 .../tui/screens/audit/slides/index.ts | 0 .../tui/screens/audit/slides/installation.tsx | 0 .../tui/screens/audit/slides/liveData.tsx | 0 .../tui/screens/audit/slides/shared.tsx | 2 +- .../screens/audit/slides/uploadNotebook.tsx | 0 .../tui/screens/audit/slides/writeReport.tsx | 0 .../tui/screens/doctor/DoctorIntroScreen.tsx | 6 +- .../tui/screens/doctor/DoctorReportScreen.tsx | 14 +- .../tui/screens/doctor/IssueTable.tsx | 6 +- .../tui/screens/health/HealthCheckScreen.tsx | 22 +- .../tui/services/coding-agent-launcher.ts | 0 src/{ui => }/tui/services/mcp-installer.ts | 16 +- .../mcp-suggested-prompts-services.ts | 18 +- src/{ui => }/tui/start-tui.ts | 10 +- src/{ui => }/tui/styles.ts | 0 src/{ui => }/tui/terminal.ts | 0 src/{ui => }/tui/ui-store.ts | 4 +- src/ui/tui/ink-ui.ts | 1 - tsconfig.build.json | 30 +- vitest.config.ts | 44 +- 849 files changed, 3655 insertions(+), 3634 deletions(-) rename src/{lib => }/agent/__tests__/__snapshots__/commandments.test.ts.snap (100%) rename src/{lib => agent}/__tests__/agent-interface.test.ts (97%) rename src/{lib => }/agent/__tests__/agent-prompt-loader.test.ts (99%) rename src/{lib => }/agent/__tests__/agent-prompt.test.ts (91%) rename src/{lib => agent}/__tests__/agent-runner-ask.test.ts (94%) rename src/{lib => }/agent/__tests__/aio-capture.test.ts (99%) rename src/{lib => }/agent/__tests__/bash-fence-python.test.ts (98%) rename src/{lib => }/agent/__tests__/commandments.test.ts (96%) rename src/{lib => agent}/__tests__/gateway-session.test.ts (97%) rename src/{lib => }/agent/__tests__/output-signals.test.ts (97%) rename src/{lib => }/agent/__tests__/run-tags.test.ts (94%) rename src/{lib => }/agent/__tests__/stored-login.test.ts (98%) rename src/{lib => }/agent/__tests__/triage-provider.test.ts (96%) rename src/{lib => }/agent/__tests__/tutorial-run-tags.test.ts (92%) rename src/{lib => }/agent/__tests__/variant-gating.test.ts (88%) rename src/{lib => agent}/__tests__/wizard-can-use-tool.test.ts (99%) rename src/{lib => agent}/__tests__/yara-hooks.test.ts (99%) rename src/{lib => agent}/__tests__/yara-policy.test.ts (99%) rename src/{lib => }/agent/agent-interface.ts (97%) rename src/{lib => }/agent/agent-phase.ts (100%) rename src/{lib => }/agent/agent-prompt-loader.ts (98%) rename src/{lib => }/agent/agent-prompt.ts (95%) rename src/{lib => }/agent/agent-runner.ts (92%) rename src/{lib => }/agent/aio-capture.ts (99%) rename src/{lib => }/agent/bash-fence.ts (99%) rename src/{lib => }/agent/commandments.ts (100%) rename src/{lib => agent/gateway}/gateway-session.ts (97%) rename src/{lib => }/agent/mcp-prompt-streaming.ts (96%) rename src/{lib => agent}/middleware/benchmark.ts (83%) rename src/{lib => agent}/middleware/benchmarks/cache-tracker.ts (97%) rename src/{lib => agent}/middleware/benchmarks/compaction-tracker.ts (94%) rename src/{lib => agent}/middleware/benchmarks/context-size-tracker.ts (96%) rename src/{lib => agent}/middleware/benchmarks/cost-tracker.ts (94%) rename src/{lib => agent}/middleware/benchmarks/duration-tracker.ts (97%) rename src/{lib => agent}/middleware/benchmarks/index.ts (74%) rename src/{lib => agent}/middleware/benchmarks/json-writer.ts (89%) rename src/{lib => agent}/middleware/benchmarks/summary.ts (89%) rename src/{lib => agent}/middleware/benchmarks/token-tracker.ts (97%) rename src/{lib => agent}/middleware/benchmarks/turn-counter.ts (98%) rename src/{lib => agent}/middleware/config.ts (94%) create mode 100644 src/agent/middleware/index.ts rename src/{lib => agent}/middleware/phase-detector.ts (100%) rename src/{lib => agent}/middleware/pipeline.ts (97%) rename src/{lib => agent}/middleware/types.ts (97%) rename src/{lib => }/agent/output-signals.ts (98%) rename src/{lib => }/agent/runner/README.md (100%) rename src/{lib => }/agent/runner/__tests__/switchboard.test.ts (98%) rename src/{lib => }/agent/runner/harness/agents-platform/README.md (100%) rename src/{lib => }/agent/runner/harness/anthropic/README.md (100%) rename src/{lib => }/agent/runner/harness/anthropic/index.ts (91%) rename src/{lib => }/agent/runner/harness/pi/README.md (100%) rename src/{lib => }/agent/runner/harness/pi/__tests__/completion.test.ts (93%) rename src/{lib => }/agent/runner/harness/pi/__tests__/env-lockdown.test.ts (96%) rename src/{lib => }/agent/runner/harness/pi/__tests__/gateway.test.ts (98%) rename src/{lib => }/agent/runner/harness/pi/__tests__/security.test.ts (99%) rename src/{lib => }/agent/runner/harness/pi/__tests__/status-line.test.ts (92%) rename src/{lib => }/agent/runner/harness/pi/__tests__/task-tools.test.ts (99%) rename src/{lib => }/agent/runner/harness/pi/__tests__/tools.test.ts (99%) rename src/{lib => }/agent/runner/harness/pi/completion.ts (94%) rename src/{lib => }/agent/runner/harness/pi/gateway.ts (98%) rename src/{lib => }/agent/runner/harness/pi/index.ts (96%) rename src/{lib => }/agent/runner/harness/pi/mcp.ts (97%) rename src/{lib => }/agent/runner/harness/pi/orchestrator-tools.ts (98%) rename src/{lib => }/agent/runner/harness/pi/runtime-notes.ts (99%) rename src/{lib => }/agent/runner/harness/pi/security.ts (98%) rename src/{lib => }/agent/runner/harness/pi/subagent.ts (99%) rename src/{lib => }/agent/runner/harness/pi/task.ts (94%) rename src/{lib => }/agent/runner/harness/pi/tasks.ts (99%) rename src/{lib => }/agent/runner/harness/pi/tools.ts (97%) rename src/{lib => }/agent/runner/harness/types.ts (87%) rename src/{lib => }/agent/runner/index.ts (90%) rename src/{lib => }/agent/runner/sequence/README.md (100%) rename src/{lib => }/agent/runner/sequence/linear.ts (91%) rename src/{lib => }/agent/runner/sequence/orchestrator/__tests__/completed-seeded-types.test.ts (90%) rename src/{lib => }/agent/runner/sequence/orchestrator/__tests__/executor.test.ts (97%) rename src/{lib => }/agent/runner/sequence/orchestrator/__tests__/handoff-schema-parity.test.ts (96%) rename src/{lib => }/agent/runner/sequence/orchestrator/__tests__/optional-tasks.test.ts (88%) rename src/{lib => }/agent/runner/sequence/orchestrator/__tests__/queue-tools.test.ts (96%) rename src/{lib => }/agent/runner/sequence/orchestrator/__tests__/queue.test.ts (99%) rename src/{lib => }/agent/runner/sequence/orchestrator/__tests__/run-metrics.test.ts (97%) rename src/{lib => }/agent/runner/sequence/orchestrator/__tests__/seeded-decline-skip.test.ts (94%) rename src/{lib => }/agent/runner/sequence/orchestrator/__tests__/seeded-deps.test.ts (98%) rename src/{lib => }/agent/runner/sequence/orchestrator/__tests__/sink-closure.test.ts (97%) rename src/{lib => }/agent/runner/sequence/orchestrator/__tests__/skill-sweep.test.ts (98%) rename src/{lib => }/agent/runner/sequence/orchestrator/__tests__/task-notice-timeout.test.ts (98%) rename src/{lib => }/agent/runner/sequence/orchestrator/__tests__/variant-resolution.test.ts (97%) rename src/{lib => }/agent/runner/sequence/orchestrator/executor.ts (97%) rename src/{lib => }/agent/runner/sequence/orchestrator/orchestrator-runner.ts (97%) rename src/{lib => }/agent/runner/sequence/orchestrator/queue-tools.ts (99%) rename src/{lib => }/agent/runner/sequence/orchestrator/queue.ts (99%) rename src/{lib => }/agent/runner/sequence/orchestrator/run-metrics.ts (100%) rename src/{lib => }/agent/runner/sequence/orchestrator/seeded-deps.ts (97%) rename src/{lib => }/agent/runner/shared/__tests__/refresh-access-token-if-needed.test.ts (88%) rename src/{lib => }/agent/runner/shared/authenticate.ts (88%) rename src/{lib => }/agent/runner/shared/bootstrap.ts (90%) rename src/{lib => }/agent/runner/shared/errors.ts (86%) rename src/{lib => }/agent/runner/shared/types.ts (89%) rename src/{lib => }/agent/runner/switchboard/commandments.ts (96%) rename src/{lib => }/agent/runner/switchboard/flags/__tests__/binding-cases.ts (91%) rename src/{lib => }/agent/runner/switchboard/flags/__tests__/flags.test.ts (97%) rename src/{lib => }/agent/runner/switchboard/flags/index.ts (87%) rename src/{lib => }/agent/runner/switchboard/flags/orchestrator.ts (97%) rename src/{lib => }/agent/runner/switchboard/flags/schemes.ts (96%) rename src/{lib => }/agent/runner/switchboard/flags/self-driving.ts (76%) rename src/{lib => }/agent/runner/switchboard/harness.ts (90%) rename src/{lib => }/agent/runner/switchboard/index.ts (95%) rename src/{lib => }/agent/runner/switchboard/models.ts (99%) rename src/{lib => }/agent/runner/switchboard/sequence.ts (91%) rename src/{lib => agent/security}/yara-hooks.ts (98%) rename src/{lib => agent/security}/yara-policy.ts (100%) rename src/{lib => }/agent/stored-login.ts (97%) rename src/{lib/wizard-tools => agent/tools}/mcp.ts (97%) rename src/{lib => }/agent/triage-provider.ts (95%) rename src/{ => cli}/__tests__/basic-integration-cli.test.ts (91%) rename src/{ => cli}/__tests__/cli.test.ts (95%) rename src/{ => cli}/__tests__/headless-scope.test.ts (80%) rename src/{ => cli}/__tests__/helpers/parse-command.no-jest.ts (95%) rename src/{ => cli}/__tests__/mcp-cli.test.ts (89%) rename src/{ => cli}/__tests__/programs-cli.test.ts (91%) rename src/{ => cli}/__tests__/provision-cli.test.ts (91%) rename src/{ => cli}/__tests__/skill-cli.test.ts (90%) rename src/{ => cli}/__tests__/wizard.test.ts (84%) rename src/{ => cli}/commands/ai-observability.ts (84%) rename src/{ => cli}/commands/audit.ts (86%) rename src/{ => cli}/commands/basic-integration/__tests__/ci-install.test.ts (95%) rename src/{ => cli}/commands/basic-integration/ci-install.ts (91%) rename src/{ => cli}/commands/basic-integration/index.ts (84%) rename src/{ => cli}/commands/basic-integration/interactive.ts (62%) rename src/{ => cli}/commands/basic-integration/non-interactive.ts (82%) create mode 100644 src/cli/commands/basic-integration/playground.ts rename src/{ => cli}/commands/basic-integration/skill.ts (79%) rename src/{ => cli}/commands/cli/__tests__/add.test.ts (92%) rename src/{ => cli}/commands/cli/add.ts (96%) rename src/{ => cli}/commands/cli/index.ts (61%) rename src/{ => cli}/commands/command.ts (98%) rename src/{ => cli}/commands/doctor.ts (82%) rename src/{ => cli}/commands/error-tracking.ts (81%) rename src/{ => cli}/commands/factories/__tests__/family-picker.test.ts (97%) rename src/{ => cli}/commands/factories/__tests__/native-command-factory.test.ts (94%) rename src/{ => cli}/commands/factories/family-command-factory.ts (91%) rename src/{ => cli}/commands/factories/native-command-factory.ts (83%) rename src/{ => cli}/commands/factories/shared.ts (84%) rename src/{ => cli}/commands/mcp-analytics.ts (79%) rename src/{ => cli}/commands/mcp/add.ts (81%) create mode 100644 src/cli/commands/mcp/index.ts rename src/{ => cli}/commands/mcp/remove.ts (74%) rename src/{ => cli}/commands/mcp/tui-availability.ts (100%) rename src/{ => cli}/commands/mcp/tutorial.ts (71%) rename src/{ => cli}/commands/metrics.ts (84%) rename src/{ => cli}/commands/migrate.ts (83%) rename src/{ => cli}/commands/provision.ts (91%) rename src/{ => cli}/commands/replay-vision.ts (79%) rename src/{ => cli}/commands/revenue.ts (71%) rename src/{ => cli}/commands/self-driving.ts (87%) rename src/{ => cli}/commands/skill-program-options.ts (100%) rename src/{ => cli}/commands/skill.ts (91%) rename src/{ => cli}/commands/slack.ts (71%) rename src/{ => cli}/commands/upload-sourcemaps.ts (73%) rename src/{ => cli}/commands/warehouse.ts (71%) rename src/{lib => cli}/headless-mode.ts (97%) rename src/{lib => cli}/runners/__tests__/mint-recovery.test.ts (71%) create mode 100644 src/cli/runners/index.ts rename src/{lib => cli}/runners/resolve-no-telemetry.ts (100%) rename src/{lib => cli}/runners/run-non-interactive.ts (89%) rename src/{lib => cli}/runners/run-wizard-ci.ts (76%) rename src/{lib => cli}/runners/run-wizard-headless.ts (83%) rename src/{lib => cli}/runners/run-wizard.ts (86%) rename src/{ => cli}/telemetry.ts (79%) rename src/{ => cli}/wizard.ts (97%) delete mode 100644 src/commands/basic-integration/playground.ts delete mode 100644 src/commands/mcp/index.ts delete mode 100644 src/lib/middleware/index.ts delete mode 100644 src/lib/registry.ts delete mode 100644 src/lib/runners/index.ts delete mode 100644 src/steps/index.ts rename src/{lib => store}/__tests__/__snapshots__/credential-isolation-snapshot.test.ts.snap (100%) rename src/{lib => store}/__tests__/agent-env-isolation.test.ts (99%) rename src/{lib => store}/__tests__/claude-settings-backup.test.ts (98%) rename src/{ => store}/__tests__/clipboard.test.ts (94%) rename src/{lib => store}/__tests__/cloudflare-detection.test.ts (97%) rename src/{lib => store}/__tests__/constants.test.ts (87%) rename src/{lib => store}/__tests__/credential-isolation-snapshot.test.ts (95%) rename src/{lib => store}/__tests__/fetch-retry.test.ts (98%) rename src/{lib => store}/__tests__/flow-resolution.test.ts (95%) rename src/{lib => store}/__tests__/host-resolution.test.ts (97%) rename src/{ => store}/__tests__/link-helpers.test.ts (99%) rename src/{lib => store}/__tests__/local-dev.test.ts (99%) rename src/{lib => store}/__tests__/mcp-project-profile.test.ts (99%) rename src/{lib => store}/__tests__/mcp-role-prompts.test.ts (99%) rename src/{lib => store}/__tests__/mcp-seed-events.test.ts (98%) rename src/{ => store}/__tests__/package-json.test.ts (99%) rename src/{lib => store}/__tests__/secret-vault.test.ts (97%) rename src/{lib => store}/__tests__/settings-conflicts.test.ts (97%) rename src/{lib => store}/__tests__/token-pricing.test.ts (99%) rename src/{ => store}/__tests__/wizard-abort.test.ts (95%) rename src/{lib => store}/__tests__/wizard-ask-bridge.test.ts (97%) rename src/{lib => store}/__tests__/wizard-spellbook.test.ts (88%) rename src/{lib => store}/__tests__/wizard-tools.test.ts (99%) rename src/{lib => store/agent-protocol}/agent-env-isolation.ts (100%) rename src/{lib => store/agent-protocol}/agent-signals.ts (100%) rename src/{lib => store/agent-protocol}/program-run.ts (97%) rename src/{lib => store/agent-protocol}/token-pricing.ts (99%) rename src/{lib => store}/api.ts (98%) rename src/{lib => store}/auth-session-state.ts (100%) rename src/{lib => store}/cloudflare-detection.ts (95%) rename src/{lib => store}/detection/__tests__/agentic.test.ts (99%) rename src/{lib => store}/detection/__tests__/context.test.ts (92%) rename src/{lib => store}/detection/__tests__/features.test.ts (97%) rename src/{lib => store}/detection/__tests__/framework.test.ts (95%) rename src/{lib => store}/detection/__tests__/package-manager.test.ts (98%) rename src/{lib => store}/detection/__tests__/project-scope.test.ts (93%) rename src/{lib => store}/detection/agentic.ts (98%) rename src/{lib => store}/detection/context.ts (91%) rename src/{lib => store}/detection/features.ts (97%) rename src/{lib => store}/detection/framework.ts (88%) rename src/{lib => store}/detection/index.ts (100%) rename src/{lib => store}/detection/package-manager.ts (99%) rename src/{lib => store}/detection/project-scope.ts (94%) rename src/{lib => store}/fetch-retry.ts (97%) rename src/{lib => store}/file-watcher.ts (99%) rename src/{lib => store}/framework-config.ts (98%) rename src/{ => store}/frameworks/android/android-wizard-agent.ts (92%) rename src/{ => store}/frameworks/android/utils.ts (89%) rename src/{ => store}/frameworks/angular/angular-wizard-agent.ts (85%) rename src/{ => store}/frameworks/angular/utils.ts (64%) rename src/{ => store}/frameworks/astro/astro-wizard-agent.ts (91%) rename src/{ => store}/frameworks/astro/utils.ts (93%) rename src/{ => store}/frameworks/django/django-wizard-agent.ts (91%) rename src/{ => store}/frameworks/django/utils.ts (96%) rename src/{ => store}/frameworks/elixir/elixir-wizard-agent.ts (93%) rename src/{ => store}/frameworks/fastapi/fastapi-wizard-agent.ts (92%) rename src/{ => store}/frameworks/fastapi/utils.ts (97%) rename src/{ => store}/frameworks/flask/flask-wizard-agent.ts (91%) rename src/{ => store}/frameworks/flask/utils.ts (97%) rename src/{ => store}/frameworks/flutter/flutter-wizard-agent.ts (93%) rename src/{ => store}/frameworks/go/go-wizard-agent.ts (92%) rename src/{ => store}/frameworks/java/java-wizard-agent.ts (95%) rename src/{ => store}/frameworks/javascript-node/javascript-node-wizard-agent.ts (89%) rename src/{ => store}/frameworks/javascript-web/javascript-web-wizard-agent.ts (91%) rename src/{ => store}/frameworks/javascript-web/utils.ts (91%) rename src/{ => store}/frameworks/kmp/kmp-wizard-agent.ts (93%) rename src/{ => store}/frameworks/laravel/laravel-wizard-agent.ts (94%) rename src/{ => store}/frameworks/laravel/utils.ts (96%) rename src/{ => store}/frameworks/nextjs/nextjs-wizard-agent.ts (88%) rename src/{ => store}/frameworks/nextjs/utils.ts (86%) rename src/{ => store}/frameworks/nuxt/nuxt-wizard-agent.ts (86%) rename src/{ => store}/frameworks/python/python-wizard-agent.ts (94%) rename src/{ => store}/frameworks/python/utils.ts (98%) rename src/{ => store}/frameworks/rails/rails-wizard-agent.ts (93%) rename src/{ => store}/frameworks/rails/utils.ts (96%) rename src/{ => store}/frameworks/react-native/react-native-wizard-agent.ts (90%) rename src/{ => store}/frameworks/react-native/utils.ts (74%) rename src/{ => store}/frameworks/react-router/react-router-wizard-agent.ts (89%) rename src/{ => store}/frameworks/react-router/utils.ts (91%) rename src/{ => store}/frameworks/ruby/ruby-wizard-agent.ts (93%) rename src/{ => store}/frameworks/ruby/utils.ts (94%) rename src/{ => store}/frameworks/rust/rust-wizard-agent.ts (93%) rename src/{ => store}/frameworks/svelte/svelte-wizard-agent.ts (86%) rename src/{ => store}/frameworks/swift/__tests__/utils.test.ts (96%) rename src/{ => store}/frameworks/swift/swift-wizard-agent.ts (92%) rename src/{ => store}/frameworks/swift/utils.ts (93%) rename src/{ => store}/frameworks/tanstack-router/tanstack-router-wizard-agent.ts (90%) rename src/{ => store}/frameworks/tanstack-router/utils.ts (92%) rename src/{ => store}/frameworks/tanstack-start/tanstack-start-wizard-agent.ts (85%) rename src/{ => store}/frameworks/tanstack-start/utils.ts (67%) rename src/{ => store}/frameworks/vue/vue-wizard-agent.ts (85%) rename src/{lib => store}/health-checks/__tests__/health-checks.test.ts (98%) rename src/{lib => store}/health-checks/endpoints.ts (97%) rename src/{lib => store}/health-checks/index.ts (84%) rename src/{lib => store}/health-checks/readiness.ts (97%) rename src/{lib => store}/health-checks/testme.md (100%) rename src/{lib => store}/health-checks/types.ts (100%) rename src/{lib => store}/helper-functions.ts (100%) rename src/{lib => store}/host-resolution.ts (97%) rename src/{lib => store}/local-dev.ts (100%) rename src/{lib => store}/mcp-project-profile.ts (99%) rename src/{lib => store}/mcp-role-prompts.copy.json (100%) rename src/{lib => store}/mcp-role-prompts.ts (99%) rename src/{lib => store}/mcp-seed-events.ts (98%) rename src/{lib => store}/programs/__tests__/__snapshots__/flow-traces.test.ts.snap (100%) rename src/{lib => store}/programs/__tests__/__snapshots__/post-auth-gates.test.ts.snap (100%) rename src/{lib => store}/programs/__tests__/agent-skill.test.ts (92%) rename src/{lib => store}/programs/__tests__/audit-seed.test.ts (91%) rename src/{lib => store}/programs/__tests__/error-tracking.test.ts (83%) rename src/{lib => store}/programs/__tests__/flow-traces.test.ts (90%) rename src/{lib => store}/programs/__tests__/mcp-analytics.test.ts (97%) rename src/{lib => store}/programs/__tests__/metrics-program.test.ts (87%) rename src/{lib => store}/programs/__tests__/post-auth-gates.test.ts (83%) rename src/{lib => store}/programs/__tests__/posthog-cli-preinstall.test.ts (82%) rename src/{lib => store}/programs/__tests__/posthog-integration-detect.test.ts (96%) rename src/{lib => store}/programs/__tests__/program-registry.test.ts (97%) rename src/{lib => store}/programs/__tests__/program-step.test.ts (92%) rename src/{lib => store}/programs/__tests__/replay-vision.test.ts (95%) rename src/{lib => store}/programs/__tests__/revenue-analytics-detect.test.ts (95%) rename src/{lib => store}/programs/__tests__/self-driving-detect.test.ts (96%) rename src/{lib => store}/programs/__tests__/self-driving-prompt.test.ts (95%) rename src/{lib => store}/programs/__tests__/source-maps-detect-agentic.test.ts (99%) rename src/{lib => store}/programs/__tests__/source-maps-detect.test.ts (98%) rename src/{lib => store}/programs/__tests__/source-maps-prompt.test.ts (97%) rename src/{lib => store}/programs/__tests__/warehouse-ask-timeout.test.ts (83%) rename src/{lib => store}/programs/__tests__/warehouse-seed-task.test.ts (92%) rename src/{lib => store}/programs/__tests__/warehouse-suggestion.test.ts (95%) rename src/{lib => store}/programs/__tests__/web-analytics-doctor-detect.test.ts (95%) rename src/{lib => store}/programs/agent-skill/index.ts (94%) rename src/{lib => store}/programs/agent-skill/steps.ts (82%) rename src/{lib => store}/programs/ai-observability/index.ts (95%) rename src/{lib => store}/programs/ai-observability/test/e2e.json (100%) rename src/{lib => store}/programs/ai-opt-in-gate.ts (97%) rename src/{lib => store}/programs/audit/detect.ts (82%) rename src/{lib => store}/programs/audit/index.ts (88%) rename src/{lib => store}/programs/audit/ledger-watcher.ts (89%) rename src/{lib => store}/programs/audit/seed.ts (96%) rename src/{lib => store}/programs/audit/test/e2e.json (100%) rename src/{lib => store}/programs/audit/types.ts (95%) rename src/{lib => store}/programs/dispatch-family.ts (89%) rename src/{lib => store}/programs/error-tracking-upload-source-maps/detect-agentic.ts (98%) rename src/{lib => store}/programs/error-tracking-upload-source-maps/detect.ts (98%) rename src/{lib => store}/programs/error-tracking-upload-source-maps/index.ts (92%) rename src/{lib => store}/programs/error-tracking-upload-source-maps/prompt.ts (99%) rename src/{lib => store}/programs/error-tracking-upload-source-maps/steps.ts (90%) rename src/{lib => store}/programs/error-tracking-upload-source-maps/test/e2e.json (100%) rename src/{lib => store}/programs/error-tracking/detect-agentic.ts (92%) rename src/{lib => store}/programs/error-tracking/index.ts (90%) rename src/{lib => store}/programs/error-tracking/test/e2e.json (100%) rename src/{lib => store}/programs/events-audit/constants.ts (100%) rename src/{lib => store}/programs/events-audit/index.ts (87%) rename src/{lib => store}/programs/events-audit/seed.ts (96%) rename src/{lib => store}/programs/events-audit/steps.ts (86%) rename src/{lib => store}/programs/flow-for.ts (92%) rename src/{lib => store}/programs/mcp-analytics/index.ts (94%) rename src/{lib => store}/programs/mcp/index.ts (97%) rename src/{lib => store}/programs/metrics/index.ts (95%) rename src/{lib => store}/programs/metrics/test/e2e.json (100%) rename src/{lib => store}/programs/migration/index.ts (92%) rename src/{lib => store}/programs/migration/steps.ts (79%) rename src/{lib => store}/programs/posthog-doctor/__tests__/doctor-schema.test.ts (92%) rename src/{lib => store}/programs/posthog-doctor/fetch.ts (81%) rename src/{lib => store}/programs/posthog-doctor/index.ts (84%) rename src/{lib => store}/programs/posthog-doctor/kind-metadata.ts (97%) rename src/{lib => store}/programs/posthog-doctor/steps.ts (81%) rename src/{lib => store}/programs/posthog-doctor/types.ts (100%) rename src/{lib => store}/programs/posthog-integration/__tests__/detect.test.ts (95%) rename src/{lib => store}/programs/posthog-integration/__tests__/handoff.test.ts (96%) rename src/{lib => store}/programs/posthog-integration/__tests__/index.test.ts (84%) rename src/{lib => store}/programs/posthog-integration/constants.ts (100%) rename src/{lib => store}/programs/posthog-integration/detect.ts (94%) rename src/{lib => store}/programs/posthog-integration/handoff.ts (100%) rename src/{lib => store}/programs/posthog-integration/index.ts (92%) rename src/{lib => store}/programs/posthog-integration/steps.ts (89%) rename src/{lib => store}/programs/posthog-integration/test/README.md (100%) rename src/{lib => store}/programs/posthog-integration/test/e2e.json (100%) rename src/{lib => store}/programs/program-registry.ts (99%) rename src/{lib => store}/programs/program-step.ts (97%) rename src/{lib => store}/programs/replay-vision/index.ts (90%) rename src/{lib => store}/programs/replay-vision/test/e2e.json (100%) rename src/{lib => store}/programs/revenue-analytics/detect.ts (94%) rename src/{lib => store}/programs/revenue-analytics/index.ts (90%) rename src/{lib => store}/programs/revenue-analytics/steps.ts (88%) rename src/{lib => store}/programs/run-config.ts (91%) rename src/{lib => store}/programs/self-driving/ARCHITECTURE.md (100%) rename src/{lib => store}/programs/self-driving/__tests__/step-keys.test.ts (100%) rename src/{lib => store}/programs/self-driving/detect-agentic.ts (93%) rename src/{lib => store}/programs/self-driving/detect.ts (96%) rename src/{lib => store}/programs/self-driving/index.ts (95%) rename src/{lib => store}/programs/self-driving/prompt.ts (98%) rename src/{lib => store}/programs/self-driving/step-keys.ts (100%) rename src/{lib => store}/programs/self-driving/steps.ts (94%) rename src/{lib => store}/programs/self-driving/test/e2e.json (100%) rename src/{lib => store}/programs/shared/health-check-step.ts (89%) rename src/{lib => store}/programs/shared/package-scanning.ts (95%) rename src/{lib => store}/programs/shared/posthog-cli-preinstall.ts (87%) rename src/{lib => store}/programs/slack/index.ts (91%) rename src/{lib => store}/programs/warehouse-source/detect.ts (91%) rename src/{lib => store}/programs/warehouse-source/index.ts (91%) rename src/{lib => store}/programs/warehouse-source/steps.ts (92%) rename src/{lib => store}/programs/warehouse-source/test/e2e.json (100%) rename src/{lib => store}/programs/web-analytics-doctor/detect.ts (90%) rename src/{lib => store}/programs/web-analytics-doctor/index.ts (96%) rename src/{lib => store}/programs/web-analytics-doctor/steps.ts (70%) create mode 100644 src/store/registry.ts rename src/{lib => store}/safe-tools.ts (100%) rename src/{lib => store/services}/claude-settings.ts (98%) rename src/{lib => store/services}/oauth/__tests__/program-scopes.test.ts (98%) rename src/{lib => store/services}/oauth/program-scopes.ts (99%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/MCPClient.ts (98%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/__tests__/defaults.test.ts (97%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/__tests__/mcp-client.test.ts (96%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/__tests__/results.test.ts (98%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/browser-client.ts (100%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/clients/__tests__/claude-code.test.ts (95%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/clients/__tests__/claude-web.test.ts (86%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/clients/__tests__/claude.test.ts (98%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/clients/__tests__/codex.test.ts (98%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/clients/__tests__/opencode.test.ts (98%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/clients/claude-code.ts (93%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/clients/claude-web.ts (85%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/clients/claude.ts (87%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/clients/codex.ts (95%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/clients/cursor.ts (85%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/clients/opencode.ts (91%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/clients/visual-studio-code.ts (91%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/clients/zed.ts (91%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/defaults.ts (100%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/index.ts (91%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/login-client.ts (100%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/plugin-client.ts (93%) rename src/{ => store/services}/steps/add-mcp-server-to-clients/results.ts (100%) rename src/{ => store/services}/steps/add-or-update-environment-variables.ts (95%) create mode 100644 src/store/services/steps/index.ts rename src/{ => store/services}/steps/install-cli-steering/__tests__/install-cli-steering.test.ts (98%) rename src/{ => store/services}/steps/install-cli-steering/index.ts (98%) rename src/{ => store/services}/steps/run-prettier.ts (83%) rename src/{ => store/services}/steps/upload-environment-variables/EnvironmentProvider.ts (100%) rename src/{ => store/services}/steps/upload-environment-variables/index.ts (72%) rename src/{ => store/services}/steps/upload-environment-variables/providers/__tests__/vercel.test.ts (96%) rename src/{ => store/services}/steps/upload-environment-variables/providers/vercel.ts (95%) rename src/{lib => store/services}/warehouse-sources/__tests__/detect.test.ts (99%) rename src/{lib => store/services}/warehouse-sources/detect.ts (95%) rename src/{lib => store/services}/warehouse-sources/registry.ts (100%) rename src/{lib => store/services}/warehouse-sources/types.ts (100%) rename src/{lib => store/session}/ask-policy.ts (94%) rename src/{lib => store/session}/secret-vault.ts (100%) rename src/{lib => store/session}/wizard-ask-bridge.ts (98%) rename src/{lib => store/session}/wizard-session.ts (97%) rename src/{utils => store/shared}/__fixtures__/provisioning.ts (100%) rename src/{utils => store/shared}/__tests__/analytics.test.ts (99%) rename src/{utils => store/shared}/__tests__/bounded-fs-walk.test.ts (89%) rename src/{utils => store/shared}/__tests__/bounded-fs.test.ts (99%) rename src/{utils => store/shared}/__tests__/ci-flag-overrides.test.ts (94%) rename src/{utils => store/shared}/__tests__/ci-region.test.ts (90%) rename src/{utils => store/shared}/__tests__/debug.test.ts (98%) rename src/{utils => store/shared}/__tests__/env-api-key.test.ts (93%) rename src/{utils => store/shared}/__tests__/env-scan.test.ts (99%) rename src/{utils => store/shared}/__tests__/environment.test.ts (92%) rename src/{utils => store/shared}/__tests__/links.test.ts (96%) rename src/{utils => store/shared}/__tests__/oauth-errors.test.ts (99%) rename src/{utils => store/shared}/__tests__/oauth-refresh.test.ts (83%) rename src/{utils => store/shared}/__tests__/oauth-server.test.ts (96%) rename src/{utils => store/shared}/__tests__/oauth.test.ts (98%) rename src/{utils => store/shared}/__tests__/project-resolution.test.ts (95%) rename src/{utils => store/shared}/__tests__/provisioning.test.ts (98%) rename src/{utils => store/shared}/__tests__/semver.test.ts (98%) rename src/{utils => store/shared}/__tests__/terminal-bell.test.ts (96%) rename src/{utils => store/shared}/analytics.ts (98%) rename src/{utils => store/shared}/atomic-ledger.ts (100%) rename src/{utils => store/shared}/bounded-fs.ts (98%) rename src/{utils => store/shared}/ci-flag-overrides.ts (98%) rename src/{utils => store/shared}/clipboard.ts (100%) rename src/{lib => store/shared}/constants.ts (99%) rename src/{utils => store/shared}/custom-headers.ts (100%) rename src/{utils => store/shared}/debug.ts (96%) rename src/{utils => store/shared}/env-api-key.ts (91%) rename src/{utils => store/shared}/env-scan.ts (99%) rename src/{utils => store/shared}/environment.ts (94%) rename src/{lib => store/shared}/errors/__tests__/auth.test.ts (94%) rename src/{lib => store/shared}/errors/__tests__/codes.test.ts (97%) rename src/{lib => store/shared}/errors/__tests__/detect-map.test.ts (95%) rename src/{lib => store/shared}/errors/__tests__/run-failure.test.ts (85%) rename src/{lib => store/shared}/errors/__tests__/sanitize.test.ts (94%) rename src/{lib => store/shared}/errors/agent-map.ts (81%) rename src/{lib => store/shared}/errors/auth.ts (95%) rename src/{lib => store/shared}/errors/catalog.ts (98%) rename src/{lib => store/shared}/errors/codes.ts (100%) rename src/{lib => store/shared}/errors/detect-map.ts (78%) rename src/{lib => store/shared}/errors/emit.ts (90%) rename src/{lib => store/shared}/errors/index.ts (60%) rename src/{lib => store/shared}/errors/run-failure.ts (99%) rename src/{lib => store/shared}/errors/sanitize.ts (100%) rename src/{lib => store/shared}/errors/skill-map.ts (77%) rename src/{lib => store/shared}/errors/types.ts (100%) rename src/{utils => store/shared}/links.ts (98%) rename src/{utils => store/shared}/oauth-errors.ts (99%) rename src/{utils => store/shared}/oauth.ts (98%) rename src/{utils => store/shared}/package-json.ts (100%) rename src/{utils => store/shared}/package-manager.ts (94%) rename src/{utils => store/shared}/paths.ts (100%) rename src/{utils => store/shared}/project-resolution.ts (100%) rename src/{utils => store/shared}/provisioning.ts (98%) rename src/{utils => store/shared}/rules/astro-rules.md (100%) rename src/{utils => store/shared}/rules/next-rules.md (100%) rename src/{utils => store/shared}/rules/react-native-rules.md (100%) rename src/{utils => store/shared}/rules/react-rules.md (100%) rename src/{utils => store/shared}/rules/svelte-rules.md (100%) rename src/{utils => store/shared}/rules/universal.md (100%) rename src/{utils => store/shared}/semver.ts (100%) rename src/{utils => store/shared}/setup-utils.ts (96%) rename src/{utils => store/shared}/terminal-bell.ts (100%) rename src/{utils => store/shared}/types.ts (91%) rename src/{utils => store/shared}/urls.ts (97%) rename src/{utils => store/shared}/vendor/is-unicorn-supported.ts (100%) rename src/{utils => store/shared}/wizard-abort.ts (91%) rename src/{lib => store}/skill-install.ts (100%) rename src/{lib => store/state}/flow-resolution.ts (97%) rename src/{lib => store/state}/flow.ts (88%) rename src/{lib => store/state}/interrupts.ts (100%) rename src/{lib => store/state}/run-failure.ts (82%) rename src/{ui/tui => store/state}/store.ts (98%) rename src/{lib => store}/task-stream/__tests__/audit-areas.test.ts (90%) rename src/{lib => store}/task-stream/__tests__/event-plan-watcher.test.ts (95%) rename src/{lib => store}/task-stream/__tests__/file-destination.test.ts (91%) rename src/{lib => store}/task-stream/__tests__/posthog-destination.test.ts (97%) rename src/{lib => store}/task-stream/__tests__/task-stream-push.test.ts (98%) rename src/{lib => store}/task-stream/audit-areas.ts (93%) rename src/{lib => store}/task-stream/destinations/file.ts (95%) rename src/{lib => store}/task-stream/destinations/posthog.ts (97%) rename src/{lib => store}/task-stream/event-plan-watcher.ts (95%) rename src/{lib => store}/task-stream/index.ts (50%) rename src/{lib => store}/task-stream/task-stream-push.ts (96%) rename src/{lib => store}/task-stream/types.ts (98%) rename src/{lib/wizard-tools => store/tools}/__tests__/handoff.test.ts (98%) rename src/{lib/wizard-tools => store/tools}/handoff.ts (97%) rename src/{lib/wizard-tools => store/tools}/index.ts (78%) rename src/{lib/wizard-tools => store/tools}/tools.ts (98%) rename src/{ => store}/ui/index.ts (62%) rename src/{ => store}/ui/null-ui.ts (94%) rename src/{ => store}/ui/store-ui.ts (95%) rename src/{ => store}/ui/wizard-ui.ts (97%) rename src/{lib => store}/wizard-spellbook.ts (95%) rename src/{ui => }/tui/App.tsx (90%) rename src/{ui => }/tui/__tests__/MintFailureScreen.test.tsx (88%) rename src/{ui => }/tui/__tests__/WizardAskScreen.test.ts (93%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/agent-skill-intro-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/agent-skill-intro-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/ai-observability-intro-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/ai-observability-intro-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/ai-opt-in-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/ai-opt-in-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/audit-intro-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/audit-intro-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/audit-outro-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/audit-outro-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/audit-run-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/audit-run-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/auth-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/auth-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/auth-error-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/auth-error-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/doctor-intro-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/doctor-intro-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/doctor-report-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/doctor-report-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/error-tracking-detect-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/error-tracking-detect-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/error-tracking-intro-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/error-tracking-intro-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/exit-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/exit-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/health-check-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/health-check-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/intro-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/intro-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/keep-skills-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/keep-skills-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/managed-settings-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/managed-settings-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/manual-auth-code-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/manual-auth-code-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/mcp-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/mcp-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/mcp-add-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/mcp-add-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/mcp-remove-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/mcp-remove-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/mcp-suggested-prompts-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/mcp-suggested-prompts-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/metrics-intro-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/metrics-intro-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/migration-intro-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/migration-intro-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/mint-failure-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/mint-failure-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/outro-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/outro-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/port-conflict-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/port-conflict-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/revenue-intro-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/revenue-intro-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/run-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/run-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/self-driving-github-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/self-driving-github-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/self-driving-handoff-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/self-driving-handoff-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/self-driving-integration-check-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/self-driving-integration-check-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/self-driving-integration-detect-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/self-driving-integration-detect-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/self-driving-intro-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/self-driving-intro-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/session-timeout-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/session-timeout-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/settings-override-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/settings-override-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/setup-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/setup-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/slack-connect-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/slack-connect-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/source-maps-detect-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/source-maps-detect-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/source-maps-intro-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/source-maps-intro-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/source-maps-outro-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/source-maps-outro-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/task-notice-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/task-notice-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/warehouse-intro-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/warehouse-intro-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/wizard-ask-120x40.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/frames/wizard-ask-60x15.txt (100%) rename src/{ui => }/tui/__tests__/__snapshots__/keyboard-equivalence.test.tsx.snap (100%) rename src/{ui => }/tui/__tests__/coding-agent-launcher.test.ts (99%) rename src/{ui => }/tui/__tests__/exit-line.test.ts (95%) rename src/{ui => }/tui/__tests__/frames.test.tsx (88%) rename src/{ui => }/tui/__tests__/headless-ui.test.ts (82%) rename src/{ui => }/tui/__tests__/helpers/render-screen.no-jest.tsx (87%) rename src/{ui => }/tui/__tests__/keyboard-equivalence.test.tsx (87%) rename src/{ui => }/tui/__tests__/keyboard-hints.test.ts (99%) rename src/{ui => }/tui/__tests__/layout-helpers.test.ts (95%) rename src/{ui => }/tui/__tests__/mcp-installer.test.ts (94%) rename src/{ui => }/tui/__tests__/picker-filter.test.ts (98%) rename src/{ui => }/tui/__tests__/posthog-integration-intro.test.ts (98%) rename src/{ui => }/tui/__tests__/programs.test.ts (96%) rename src/{ui => }/tui/__tests__/self-driving-deck.test.ts (95%) rename src/{ui => }/tui/__tests__/skill-entry.test.ts (93%) rename src/{ui => }/tui/__tests__/store-invariants.test.ts (96%) rename src/{ui => }/tui/__tests__/store.test.ts (98%) rename src/{ui => }/tui/__tests__/task-notice.test.ts (85%) rename src/{ui => }/tui/__tests__/ui-store.test.ts (90%) rename src/{ui => }/tui/__tests__/viewport-too-small.test.ts (98%) rename src/{ui => }/tui/components/LearnCard.tsx (82%) rename src/{ui => }/tui/components/PhaseVisuals.tsx (93%) rename src/{ui => }/tui/components/PrivacyPanel.tsx (97%) rename src/{ui => }/tui/components/ServiceHealthList.tsx (93%) rename src/{ui => }/tui/components/StatusPeekTrigger.tsx (90%) rename src/{ui => }/tui/components/TipsCard.tsx (96%) rename src/{ui => }/tui/components/TitleBar.tsx (95%) rename src/{ui => }/tui/components/TokenCostHud.tsx (95%) rename src/{ui => }/tui/components/__tests__/TokenCostHud.test.ts (88%) rename src/{ui => }/tui/components/__tests__/visualizer-grid.test.ts (97%) rename src/{ui => }/tui/components/visualizer/CrateStack.tsx (94%) rename src/{ui => }/tui/components/visualizer/DashboardGrid.tsx (96%) rename src/{ui => }/tui/components/visualizer/DiffCascade.tsx (93%) rename src/{ui => }/tui/components/visualizer/LibraryShelf.tsx (93%) rename src/{ui => }/tui/components/visualizer/MatrixRain.tsx (97%) rename src/{ui => }/tui/components/visualizer/Tumblers.tsx (92%) rename src/{ui => }/tui/components/visualizer/grid.ts (100%) rename src/{ui => }/tui/components/visualizer/palette.ts (100%) rename src/{ui => }/tui/components/visualizer/panel.tsx (93%) rename src/{ui => }/tui/console/headless-ui.ts (95%) rename src/{ui => }/tui/console/logging-ui.ts (95%) rename src/{ui => }/tui/constants.ts (80%) rename src/{ui => }/tui/exit-line.ts (93%) rename src/{commands/factories => tui}/family-picker.tsx (96%) rename src/{ui => }/tui/hooks/__tests__/file-watcher.test.ts (97%) rename src/{ui => }/tui/hooks/__tests__/useDismissOnAnyKey.test.ts (85%) rename src/{ui => }/tui/hooks/__tests__/useGithubConnection.test.ts (85%) rename src/{ui => }/tui/hooks/file-watcher.ts (74%) rename src/{ui => }/tui/hooks/keyboard-hints-utils.ts (100%) rename src/{ui => }/tui/hooks/useDismissOnAnyKey.ts (100%) rename src/{ui => }/tui/hooks/useGithubConnection.ts (91%) rename src/{ui => }/tui/hooks/useKeyBindings.ts (100%) rename src/{ui => }/tui/hooks/useKeyboardHints.tsx (100%) rename src/{ui => }/tui/hooks/useStdoutDimensions.ts (100%) rename src/{ui => }/tui/hooks/useTick.ts (100%) rename src/{ui => }/tui/hooks/useUiStore.ts (100%) create mode 100644 src/tui/ink-ui.ts rename src/{ui => tui}/mint-failure.ts (84%) rename src/{ui => }/tui/package.json (100%) rename src/{ui => }/tui/playground/PlaygroundApp.tsx (95%) rename src/{ui => }/tui/playground/demos/AiOptInDemo.tsx (87%) rename src/{ui => }/tui/playground/demos/AskModalDemo.tsx (99%) rename src/{ui => }/tui/playground/demos/AuditChecksDemo.tsx (95%) rename src/{ui => }/tui/playground/demos/DoctorReportDemo.tsx (87%) rename src/{ui => }/tui/playground/demos/EndScreensDemo.tsx (93%) rename src/{ui => }/tui/playground/demos/HealthCheckDemo.tsx (86%) rename src/{ui => }/tui/playground/demos/InputDemo.tsx (97%) rename src/{ui => }/tui/playground/demos/KeyboardHintsDemo.tsx (98%) rename src/{ui => }/tui/playground/demos/LayoutDemo.tsx (92%) rename src/{ui => }/tui/playground/demos/LearnDeckDemo.tsx (93%) rename src/{ui => }/tui/playground/demos/LogDemo.tsx (95%) rename src/{ui => }/tui/playground/demos/McpDemo.tsx (90%) rename src/{ui => }/tui/playground/demos/McpSuggestedPromptsDemo.tsx (95%) rename src/{ui => }/tui/playground/demos/ModalDemo.tsx (92%) rename src/{ui => }/tui/playground/demos/ProgressDemo.tsx (92%) rename src/{ui => }/tui/playground/demos/RunScreenDemo.tsx (91%) rename src/{ui => }/tui/playground/demos/ViewportGuardDemo.tsx (96%) rename src/{ui => }/tui/playground/demos/WelcomeDemo.tsx (90%) rename src/{ui => }/tui/playground/start-playground.ts (79%) rename src/{ui => }/tui/posthog-integration-intro.ts (96%) rename src/{ui => }/tui/primitives/CardLayout.tsx (91%) rename src/{ui => }/tui/primitives/ConfirmButton.tsx (96%) rename src/{ui => }/tui/primitives/ConfirmationInput.tsx (94%) rename src/{ui => }/tui/primitives/ContentSequencer.tsx (100%) rename src/{ui => }/tui/primitives/DissolveTransition.tsx (100%) rename src/{ui => }/tui/primitives/Divider.tsx (100%) rename src/{ui => }/tui/primitives/EventPlanViewer.tsx (90%) rename src/{ui => }/tui/primitives/GroupedPickerMenu.tsx (98%) rename src/{ui => }/tui/primitives/HNViewer.tsx (96%) rename src/{ui => }/tui/primitives/KeyboardHintsBar.tsx (86%) rename src/{ui => }/tui/primitives/LinesBlock.tsx (100%) rename src/{ui => }/tui/primitives/LinkText.tsx (97%) rename src/{ui => }/tui/primitives/LoadingBox.tsx (100%) rename src/{ui => }/tui/primitives/LogViewer.tsx (98%) rename src/{ui => }/tui/primitives/ModalOverlay.tsx (100%) rename src/{ui => }/tui/primitives/NodeBlock.tsx (100%) rename src/{ui => }/tui/primitives/PickerMenu.tsx (99%) rename src/{ui => }/tui/primitives/ProgressList.tsx (97%) rename src/{ui => }/tui/primitives/PromptLabel.tsx (92%) rename src/{ui => }/tui/primitives/ScreenContainer.tsx (93%) rename src/{ui => }/tui/primitives/ScreenErrorBoundary.tsx (89%) rename src/{ui => }/tui/primitives/SplitView.tsx (100%) rename src/{ui => }/tui/primitives/TabContainer.tsx (93%) rename src/{ui => }/tui/primitives/TextBlock.tsx (99%) rename src/{ui => }/tui/primitives/ViewportTooSmall.tsx (98%) rename src/{ui => }/tui/primitives/content-types.ts (100%) rename src/{ui => }/tui/primitives/index.ts (100%) rename src/{ui => }/tui/primitives/layout-helpers.ts (100%) rename src/{ui => }/tui/primitives/link-helpers.ts (100%) rename src/{ui => }/tui/primitives/picker-filter.ts (100%) rename src/{ui => }/tui/primitives/text-helpers.ts (100%) rename src/{ui => }/tui/programs/agent-skill/content/index.tsx (79%) rename src/{ui => }/tui/programs/error-tracking-upload-source-maps/content/index.tsx (96%) rename src/{ui => }/tui/programs/error-tracking/content/index.tsx (67%) rename src/{ui => }/tui/programs/error-tracking/content/tips.ts (88%) rename src/{ui => }/tui/programs/migration/content/free-tier.tsx (93%) rename src/{ui => }/tui/programs/migration/content/index.tsx (91%) rename src/{ui => }/tui/programs/migration/content/pricing-structure.tsx (90%) rename src/{ui => }/tui/programs/migration/content/vendor-stack.tsx (95%) rename src/{ui => }/tui/programs/posthog-integration/content/data-flow.tsx (95%) rename src/{ui => }/tui/programs/posthog-integration/content/funnel.tsx (97%) rename src/{ui => }/tui/programs/posthog-integration/content/index.tsx (90%) rename src/{ui => }/tui/programs/posthog-integration/content/line-chart.tsx (96%) rename src/{ui => }/tui/programs/posthog-integration/content/product-suite.tsx (95%) rename src/{ui => }/tui/programs/presentation.ts (91%) rename src/{ui => }/tui/programs/revenue-analytics/content/index.tsx (73%) rename src/{ui => }/tui/programs/self-driving/content/index.tsx (94%) rename src/{ui => }/tui/programs/self-driving/content/pipeline-diagram.tsx (93%) rename src/{ui => }/tui/programs/self-driving/content/pricing.ts (100%) rename src/{ui => }/tui/programs/self-driving/content/tips.ts (96%) rename src/{ui => }/tui/programs/warehouse-source/content/index.tsx (73%) rename src/{ui => }/tui/router.ts (76%) rename src/{ui => }/tui/screen-registry.tsx (96%) rename src/{ui => }/tui/screen-sequences.ts (100%) rename src/{ui => }/tui/screens/AgentSkillIntroScreen.tsx (97%) rename src/{ui => }/tui/screens/AiObservabilityIntroScreen.tsx (92%) rename src/{ui => }/tui/screens/AiOptInRequiredScreen.tsx (94%) rename src/{ui => }/tui/screens/AuthErrorScreen.tsx (97%) rename src/{ui => }/tui/screens/AuthScreen.tsx (92%) rename src/{ui => }/tui/screens/ErrorTrackingDetectScreen.tsx (95%) rename src/{ui => }/tui/screens/ErrorTrackingIntroScreen.tsx (92%) rename src/{ui => }/tui/screens/ExitScreen.tsx (89%) rename src/{ui => }/tui/screens/IntroScreenLayout.tsx (98%) rename src/{ui => }/tui/screens/KeepSkillsScreen.tsx (95%) rename src/{ui => }/tui/screens/ManagedSettingsScreen.tsx (91%) rename src/{ui => }/tui/screens/ManualAuthCodeScreen.tsx (95%) rename src/{ui => }/tui/screens/McpScreen.tsx (98%) rename src/{ui => }/tui/screens/McpSuggestedPromptsScreen.tsx (98%) rename src/{ui => }/tui/screens/MetricsIntroScreen.tsx (92%) rename src/{ui => }/tui/screens/MigrationIntroScreen.tsx (94%) rename src/{ui => }/tui/screens/MintFailureScreen.tsx (93%) rename src/{ui => }/tui/screens/OutroScreen.tsx (94%) rename src/{ui => }/tui/screens/PortConflictScreen.tsx (88%) rename src/{ui => }/tui/screens/PostHogIntegrationIntroScreen.tsx (94%) rename src/{ui => }/tui/screens/RevenueIntroScreen.tsx (98%) rename src/{ui => }/tui/screens/RunScreen.tsx (81%) rename src/{ui => }/tui/screens/SelfDrivingGitHubScreen.tsx (92%) rename src/{ui => }/tui/screens/SelfDrivingHandoffScreen.tsx (87%) rename src/{ui => }/tui/screens/SelfDrivingIntegrationCheckScreen.tsx (94%) rename src/{ui => }/tui/screens/SelfDrivingIntegrationDetectScreen.tsx (96%) rename src/{ui => }/tui/screens/SelfDrivingIntroScreen.tsx (95%) rename src/{ui => }/tui/screens/SessionTimeoutScreen.tsx (85%) rename src/{ui => }/tui/screens/SettingsOverrideScreen.tsx (91%) rename src/{ui => }/tui/screens/SetupScreen.tsx (94%) rename src/{ui => }/tui/screens/SkillSourceInfo.tsx (95%) rename src/{ui => }/tui/screens/SlackConnectScreen.tsx (95%) rename src/{ui => }/tui/screens/SourceMapsDetectScreen.tsx (96%) rename src/{ui => }/tui/screens/SourceMapsIntroScreen.tsx (98%) rename src/{ui => }/tui/screens/SourceMapsOutroScreen.tsx (95%) rename src/{ui => }/tui/screens/TaskNoticeScreen.tsx (90%) rename src/{ui => }/tui/screens/WarehouseIntroScreen.tsx (97%) rename src/{ui => }/tui/screens/WizardAskScreen.tsx (97%) rename src/{ui => }/tui/screens/__tests__/IntroScreenLayout.test.ts (95%) rename src/{ui => }/tui/screens/__tests__/PostHogIntegrationIntroScreen.test.ts (95%) rename src/{ui => }/tui/screens/audit/AuditAreaPane.tsx (98%) rename src/{ui => }/tui/screens/audit/AuditChecksOutroSection.tsx (95%) rename src/{ui => }/tui/screens/audit/AuditChecksViewer/AreaHeaderRow.tsx (100%) rename src/{ui => }/tui/screens/audit/AuditChecksViewer/AuditChecksViewer.tsx (97%) rename src/{ui => }/tui/screens/audit/AuditChecksViewer/CheckRow.tsx (95%) rename src/{ui => }/tui/screens/audit/AuditChecksViewer/DetailRow.tsx (97%) rename src/{ui => }/tui/screens/audit/AuditChecksViewer/Footer.tsx (82%) rename src/{ui => }/tui/screens/audit/AuditChecksViewer/Header.tsx (94%) rename src/{ui => }/tui/screens/audit/AuditChecksViewer/Legend.tsx (100%) rename src/{ui => }/tui/screens/audit/AuditChecksViewer/layout.ts (96%) rename src/{ui => }/tui/screens/audit/AuditChecksViewer/sort.ts (96%) rename src/{ui => }/tui/screens/audit/AuditIntroScreen.tsx (92%) rename src/{ui => }/tui/screens/audit/AuditOutroScreen.tsx (91%) rename src/{ui => }/tui/screens/audit/AuditRunScreen.tsx (86%) rename src/{ui => }/tui/screens/audit/PendingChecksList.tsx (93%) rename src/{ui => }/tui/screens/audit/slides/eventCapture.tsx (100%) rename src/{ui => }/tui/screens/audit/slides/events-audit/createDashboard.tsx (100%) rename src/{ui => }/tui/screens/audit/slides/events-audit/detectSdk.tsx (100%) rename src/{ui => }/tui/screens/audit/slides/events-audit/enrichSites.tsx (100%) rename src/{ui => }/tui/screens/audit/slides/events-audit/index.ts (100%) rename src/{ui => }/tui/screens/audit/slides/events-audit/queryVolume.tsx (100%) rename src/{ui => }/tui/screens/audit/slides/events-audit/scanSites.tsx (100%) rename src/{ui => }/tui/screens/audit/slides/events-audit/uploadNotebook.tsx (100%) rename src/{ui => }/tui/screens/audit/slides/events-audit/writeReport.tsx (100%) rename src/{ui => }/tui/screens/audit/slides/identification.tsx (100%) rename src/{ui => }/tui/screens/audit/slides/index.ts (100%) rename src/{ui => }/tui/screens/audit/slides/installation.tsx (100%) rename src/{ui => }/tui/screens/audit/slides/liveData.tsx (100%) rename src/{ui => }/tui/screens/audit/slides/shared.tsx (93%) rename src/{ui => }/tui/screens/audit/slides/uploadNotebook.tsx (100%) rename src/{ui => }/tui/screens/audit/slides/writeReport.tsx (100%) rename src/{ui => }/tui/screens/doctor/DoctorIntroScreen.tsx (89%) rename src/{ui => }/tui/screens/doctor/DoctorReportScreen.tsx (93%) rename src/{ui => }/tui/screens/doctor/IssueTable.tsx (94%) rename src/{ui => }/tui/screens/health/HealthCheckScreen.tsx (92%) rename src/{ui => }/tui/services/coding-agent-launcher.ts (100%) rename src/{ui => }/tui/services/mcp-installer.ts (90%) rename src/{ui => }/tui/services/mcp-suggested-prompts-services.ts (92%) rename src/{ui => }/tui/start-tui.ts (92%) rename src/{ui => }/tui/styles.ts (100%) rename src/{ui => }/tui/terminal.ts (100%) rename src/{ui => }/tui/ui-store.ts (96%) delete mode 100644 src/ui/tui/ink-ui.ts diff --git a/.gitignore b/.gitignore index 3519c1fda..4d50d3228 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/store/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/bin.ts b/bin.ts index b30137d41..05a589af1 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 '@store/shared/errors/codes'; +import { emitWizardError } from '@store/shared/errors/emit'; // 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 @@ -65,27 +65,27 @@ if (process.env.NODE_ENV === 'test') { })(); } -import { Wizard } from './src/wizard'; -import { basicIntegrationCommand } from './src/commands/basic-integration'; -import { mcpCommand } from './src/commands/mcp'; -import { mcpAnalyticsCommand } from './src/commands/mcp-analytics'; -import { replayVisionCommand } from './src/commands/replay-vision'; -import { aiObservabilityCommand } from './src/commands/ai-observability'; -import { metricsCommand } from './src/commands/metrics'; -import { auditCommand } from './src/commands/audit'; -import { doctorCommand } from './src/commands/doctor'; -import { migrateCommand } from './src/commands/migrate'; -import { revenueCommand } from './src/commands/revenue'; -import { warehouseCommand } from './src/commands/warehouse'; -import { selfDrivingCommand } from './src/commands/self-driving'; -import { slackCommand } from './src/commands/slack'; -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/claude-settings'; -import { setUI } from './src/ui'; -import { LoggingUI } from './src/ui/tui/console/logging-ui'; +import { Wizard } from './src/cli/wizard.js'; +import { basicIntegrationCommand } from './src/cli/commands/basic-integration/index.js'; +import { mcpCommand } from './src/cli/commands/mcp/index.js'; +import { mcpAnalyticsCommand } from './src/cli/commands/mcp-analytics.js'; +import { replayVisionCommand } from './src/cli/commands/replay-vision.js'; +import { aiObservabilityCommand } from './src/cli/commands/ai-observability.js'; +import { metricsCommand } from './src/cli/commands/metrics.js'; +import { auditCommand } from './src/cli/commands/audit.js'; +import { doctorCommand } from './src/cli/commands/doctor.js'; +import { migrateCommand } from './src/cli/commands/migrate.js'; +import { revenueCommand } from './src/cli/commands/revenue.js'; +import { warehouseCommand } from './src/cli/commands/warehouse.js'; +import { selfDrivingCommand } from './src/cli/commands/self-driving.js'; +import { slackCommand } from './src/cli/commands/slack.js'; +import { uploadSourcemapsCommand } from './src/cli/commands/upload-sourcemaps.js'; +import { errorTrackingCommand } from './src/cli/commands/error-tracking.js'; +import { skillCommand } from './src/cli/commands/skill.js'; +import { cliCommand } from './src/cli/commands/cli/index.js'; +import { recoverOrphanedSettingsBackups } from '@store/services/claude-settings'; +import { setUI } from '@store/ui'; +import { LoggingUI } from '@tui/console/logging-ui'; // The entry point owns the default renderer; @ui ships with none. setUI(new LoggingUI()); diff --git a/e2e-harness/__tests__/e2e-flow-snapshot.test.ts b/e2e-harness/__tests__/e2e-flow-snapshot.test.ts index 13335afd7..0c1ab063d 100644 --- a/e2e-harness/__tests__/e2e-flow-snapshot.test.ts +++ b/e2e-harness/__tests__/e2e-flow-snapshot.test.ts @@ -13,25 +13,28 @@ * Update goldens with `jest -u` after an intentional flow change. */ -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 { FRAMEWORK_REGISTRY } from '@lib/registry'; -import { WizardReadiness } from '@lib/health-checks/readiness'; +import { WizardStore } from '@store/state/store'; +import { InkUI } from '@tui/ink-ui'; +import { setUI } from '@store/ui'; +import { buildSession, RunPhase } from '@store/session/wizard-session'; +import { Integration } from '@store/shared/constants'; +import { HostResolution } from '@store/host-resolution'; +import { FRAMEWORK_REGISTRY } from '@store/registry'; +import { WizardReadiness } from '@store/health-checks/readiness'; import { Program, getProgramConfig, type ProgramId, -} from '@lib/programs/program-registry'; -import { ScreenId } from '@ui/tui/router'; -import { SELF_DRIVING_INTEGRATE_PATH_KEY } from '@lib/programs/self-driving/detect'; -import { WizardCiDriver } from '../wizard-ci-driver'; -import { decideE2eAction, type WizardE2eProfile } from '../e2e-profile'; -import { profileFor } from '../profiles'; -import { flowFor } from '@lib/programs/flow-for'; +} from '@store/programs/program-registry'; +import { ScreenId } from '@tui/router'; +import { SELF_DRIVING_INTEGRATE_PATH_KEY } from '@store/programs/self-driving/detect'; +import { WizardCiDriver } from '@e2e-harness/wizard-ci-driver'; +import { + decideE2eAction, + type WizardE2eProfile, +} from '@e2e-harness/e2e-profile'; +import { profileFor } from '@e2e-harness/profiles'; +import { flowFor } from '@store/programs/flow-for'; /** * Walk a program flow offline using an e2e profile, injecting the external diff --git a/e2e-harness/__tests__/e2e-profile-ask.test.ts b/e2e-harness/__tests__/e2e-profile-ask.test.ts index 5bc8fdf97..6a9a2ed5f 100644 --- a/e2e-harness/__tests__/e2e-profile-ask.test.ts +++ b/e2e-harness/__tests__/e2e-profile-ask.test.ts @@ -7,8 +7,8 @@ * froze, so a workbench run can rely on it. */ -import { Overlay, ScreenId } from '@ui/tui/router'; -import type { AskQuestion } from '@lib/wizard-session'; +import { Overlay, ScreenId } from '@tui/router'; +import type { AskQuestion } from '@store/session/wizard-session'; import { DEFAULT_E2E_PROFILE, E2E_ANSWER_SENTINEL, @@ -16,10 +16,10 @@ import { answerQuestions, decideE2eAction, type WizardE2eProfile, -} from '../e2e-profile'; -import { profileFor, resolveE2eProfile } from '../profiles'; -import { Program } from '@lib/programs/program-registry'; -import type { CiState } from '../wizard-ci-driver'; +} from '@e2e-harness/e2e-profile'; +import { profileFor, resolveE2eProfile } from '@e2e-harness/profiles'; +import { Program } from '@store/programs/program-registry'; +import type { CiState } from '@e2e-harness/wizard-ci-driver'; const text = (id: string, prompt = id): AskQuestion => ({ id, diff --git a/e2e-harness/__tests__/e2e-result.test.ts b/e2e-harness/__tests__/e2e-result.test.ts index cb03ec971..2e00f93b2 100644 --- a/e2e-harness/__tests__/e2e-result.test.ts +++ b/e2e-harness/__tests__/e2e-result.test.ts @@ -11,19 +11,19 @@ import fs from 'fs'; import os from 'os'; import path from 'path'; -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 { OutroKind, RunPhase } from '@store/session/wizard-session'; +import type { AskQuestion, WizardSession } from '@store/session/wizard-session'; +import { DETECTED_WAREHOUSE_SOURCES_KEY } from '@store/programs/warehouse-source/detect'; +import { Overlay } from '@tui/router'; import { E2eRunRecorder, abortReasonFrom, buildE2eResult, detectedSourcesFrom, readReportFile, -} from '../e2e-result'; -import { DEFAULT_E2E_PROFILE, decideE2eAction } from '../e2e-profile'; -import type { CiState } from '../wizard-ci-driver'; +} from '@e2e-harness/e2e-result'; +import { DEFAULT_E2E_PROFILE, decideE2eAction } from '@e2e-harness/e2e-profile'; +import type { CiState } from '@e2e-harness/wizard-ci-driver'; const SECRET = 'sk_live_do_not_leak_9f2b'; diff --git a/e2e-harness/__tests__/wizard-ci-driver.test.ts b/e2e-harness/__tests__/wizard-ci-driver.test.ts index 01127030d..82971a900 100644 --- a/e2e-harness/__tests__/wizard-ci-driver.test.ts +++ b/e2e-harness/__tests__/wizard-ci-driver.test.ts @@ -9,21 +9,31 @@ * through the driver. */ -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 { FRAMEWORK_REGISTRY } from '@lib/registry'; -import { WizardReadiness } from '@lib/health-checks/readiness'; -import { ScreenId, Overlay } from '@ui/tui/router'; -import { Program } from '@lib/programs/program-registry'; -import { WizardCiDriver, UnknownActionError } from '../wizard-ci-driver'; -import { ACTION_REGISTRY, NO_ACTION_SCREENS } from '../action-registry'; -import { SOURCE_MAPS_CONTEXT_KEYS } from '@lib/programs/error-tracking-upload-source-maps/index'; -import { OutroKind } from '@lib/wizard-session'; -import { flowFor } from '@lib/programs/flow-for'; +import { WizardStore } from '@store/state/store'; +import { InkUI } from '@tui/ink-ui'; +import { setUI } from '@store/ui'; +import { + buildSession, + RunPhase, + McpOutcome, +} from '@store/session/wizard-session'; +import { HostResolution } from '@store/host-resolution'; +import { Integration } from '@store/shared/constants'; +import { FRAMEWORK_REGISTRY } from '@store/registry'; +import { WizardReadiness } from '@store/health-checks/readiness'; +import { ScreenId, Overlay } from '@tui/router'; +import { Program } from '@store/programs/program-registry'; +import { + WizardCiDriver, + UnknownActionError, +} from '@e2e-harness/wizard-ci-driver'; +import { + ACTION_REGISTRY, + NO_ACTION_SCREENS, +} from '@e2e-harness/action-registry'; +import { SOURCE_MAPS_CONTEXT_KEYS } from '@store/programs/error-tracking-upload-source-maps'; +import { OutroKind } from '@store/session/wizard-session'; +import { flowFor } from '@store/programs/flow-for'; function freshStore(): WizardStore { const store = new WizardStore(flowFor(Program.PostHogIntegration).flow); diff --git a/e2e-harness/action-registry.ts b/e2e-harness/action-registry.ts index 63c48870c..00d346777 100644 --- a/e2e-harness/action-registry.ts +++ b/e2e-harness/action-registry.ts @@ -12,18 +12,18 @@ * actions speak only in store setters and generic params. */ -import type { WizardStore } from '@ui/tui/store'; -import { ScreenId, Overlay, type ScreenName } from '@ui/tui/router'; -import { McpOutcome, OutroKind } from '@lib/wizard-session'; -import type { AskAnswers } from '@lib/wizard-session'; +import type { WizardStore } from '@store/state/store'; +import { ScreenId, Overlay, type ScreenName } from '@tui/router'; +import { McpOutcome, OutroKind } from '@store/session/wizard-session'; +import type { AskAnswers } from '@store/session/wizard-session'; import { SOURCE_MAPS_CONTEXT_KEYS, VARIANT_DISPLAY_NAME, -} from '@lib/programs/error-tracking-upload-source-maps/index'; +} from '@store/programs/error-tracking-upload-source-maps'; import { GITHUB_REQUIRED_BODY, GITHUB_REQUIRED_MESSAGE, -} from '@lib/programs/self-driving/detect'; +} from '@store/programs/self-driving/detect'; /** One commit action legal on a given screen. */ export interface DriverAction { diff --git a/e2e-harness/e2e-profile.ts b/e2e-harness/e2e-profile.ts index 051fab496..9ea905962 100644 --- a/e2e-harness/e2e-profile.ts +++ b/e2e-harness/e2e-profile.ts @@ -7,9 +7,9 @@ * make. Add a program's profile to {@link ./profiles} to make it e2e-drivable. */ -import { ScreenId, Overlay, type ScreenName } from '@ui/tui/router'; -import type { AskAnswers, AskQuestion } from '@lib/wizard-session'; -import type { CiState } from './wizard-ci-driver.js'; +import { ScreenId, Overlay, type ScreenName } from '@tui/router'; +import type { AskAnswers, AskQuestion } from '@store/session/wizard-session'; +import type { CiState } from '@e2e-harness/wizard-ci-driver'; /** Which option to pick for a setup disambiguation question. */ export type SetupChoice = 'first' | 'last'; diff --git a/e2e-harness/e2e-result.ts b/e2e-harness/e2e-result.ts index e34a52dfd..d3d245fb6 100644 --- a/e2e-harness/e2e-result.ts +++ b/e2e-harness/e2e-result.ts @@ -21,10 +21,10 @@ import fs from 'fs'; import path from 'path'; -import { OutroKind, type WizardSession } from '@lib/wizard-session'; -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'; +import { OutroKind, type WizardSession } from '@store/session/wizard-session'; +import { DETECTED_WAREHOUSE_SOURCES_KEY } from '@store/programs/warehouse-source/detect'; +import type { DetectedSource } from '@store/services/warehouse-sources/types'; +import type { E2eDecisionReport } from '@e2e-harness/e2e-profile'; /** One `wizard_ask` batch the run was shown. */ export interface E2eAskRecord { diff --git a/e2e-harness/profiles.ts b/e2e-harness/profiles.ts index 3cc126d33..38f8271f7 100644 --- a/e2e-harness/profiles.ts +++ b/e2e-harness/profiles.ts @@ -11,23 +11,23 @@ * so `decideE2eAction` stays a pure function of (state, profile). */ -import { Program, type ProgramId } from '@lib/programs/program-registry'; +import { Program, type ProgramId } from '@store/programs/program-registry'; import { DEFAULT_E2E_PROFILE, DEFAULT_E2E_VARIATION, type AskAnswerRule, type WizardE2eProfile, type WizardE2eVariation, -} from './e2e-profile.js'; -import posthogIntegrationE2e from '@lib/programs/posthog-integration/test/e2e.json'; -import aiObservabilityE2e from '@lib/programs/ai-observability/test/e2e.json'; -import metricsE2e from '@lib/programs/metrics/test/e2e.json'; -import replayVisionE2e from '@lib/programs/replay-vision/test/e2e.json'; -import selfDrivingE2e from '@lib/programs/self-driving/test/e2e.json'; -import sourceMapsE2e from '@lib/programs/error-tracking-upload-source-maps/test/e2e.json'; -import errorTrackingE2e from '@lib/programs/error-tracking/test/e2e.json'; -import warehouseSourceE2e from '@lib/programs/warehouse-source/test/e2e.json'; -import auditE2e from '@lib/programs/audit/test/e2e.json'; +} from '@e2e-harness/e2e-profile'; +import posthogIntegrationE2e from '@store/programs/posthog-integration/test/e2e.json'; +import aiObservabilityE2e from '@store/programs/ai-observability/test/e2e.json'; +import metricsE2e from '@store/programs/metrics/test/e2e.json'; +import replayVisionE2e from '@store/programs/replay-vision/test/e2e.json'; +import selfDrivingE2e from '@store/programs/self-driving/test/e2e.json'; +import sourceMapsE2e from '@store/programs/error-tracking-upload-source-maps/test/e2e.json'; +import errorTrackingE2e from '@store/programs/error-tracking/test/e2e.json'; +import warehouseSourceE2e from '@store/programs/warehouse-source/test/e2e.json'; +import auditE2e from '@store/programs/audit/test/e2e.json'; const PROFILES: Partial> = { [Program.PostHogIntegration]: diff --git a/e2e-harness/wizard-ci-driver.ts b/e2e-harness/wizard-ci-driver.ts index 79a5873fb..c068d95e9 100644 --- a/e2e-harness/wizard-ci-driver.ts +++ b/e2e-harness/wizard-ci-driver.ts @@ -18,10 +18,13 @@ * the driver issues the final commit directly instead. */ -import type { WizardStore } from '@ui/tui/store'; -import type { ScreenName } from '@ui/tui/router'; -import type { PendingQuestion, RunPhase } from '@lib/wizard-session'; -import { actionsForScreen, MissingParamError } from './action-registry.js'; +import type { WizardStore } from '@store/state/store'; +import type { ScreenName } from '@tui/router'; +import type { PendingQuestion, RunPhase } from '@store/session/wizard-session'; +import { + actionsForScreen, + MissingParamError, +} from '@e2e-harness/action-registry'; /** A setup question projected for the harness (no `detect` fn, no closures). */ export interface SetupQuestionView { diff --git a/e2e-tests/mocks/handlers.ts b/e2e-tests/mocks/handlers.ts index 5cf864edf..f22ea9e96 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/store/shared/urls'; +import { DEFAULT_HOST_URL } from '../../src/store/shared/constants'; import { fixtureTracker } from './fixture-tracker'; export const shouldRecord = process.env.RECORD_FIXTURES === 'true'; diff --git a/scripts/__fixtures__/chunk-manifest.prod.json b/scripts/__fixtures__/chunk-manifest.prod.json index a451e3364..f74eaf038 100644 --- a/scripts/__fixtures__/chunk-manifest.prod.json +++ b/scripts/__fixtures__/chunk-manifest.prod.json @@ -1,16 +1,16 @@ { "add-mcp-server-to-clients.js": { "sources": [ - "src/steps/add-mcp-server-to-clients/MCPClient.ts", - "src/steps/add-mcp-server-to-clients/clients/claude-code.ts", - "src/steps/add-mcp-server-to-clients/clients/claude-web.ts", - "src/steps/add-mcp-server-to-clients/clients/codex.ts", - "src/steps/add-mcp-server-to-clients/clients/cursor.ts", - "src/steps/add-mcp-server-to-clients/clients/opencode.ts", - "src/steps/add-mcp-server-to-clients/clients/visual-studio-code.ts", - "src/steps/add-mcp-server-to-clients/clients/zed.ts", - "src/steps/add-mcp-server-to-clients/index.ts", - "src/steps/add-mcp-server-to-clients/plugin-client.ts" + "src/store/services/steps/add-mcp-server-to-clients/MCPClient.ts", + "src/store/services/steps/add-mcp-server-to-clients/clients/claude-code.ts", + "src/store/services/steps/add-mcp-server-to-clients/clients/claude-web.ts", + "src/store/services/steps/add-mcp-server-to-clients/clients/codex.ts", + "src/store/services/steps/add-mcp-server-to-clients/clients/cursor.ts", + "src/store/services/steps/add-mcp-server-to-clients/clients/opencode.ts", + "src/store/services/steps/add-mcp-server-to-clients/clients/visual-studio-code.ts", + "src/store/services/steps/add-mcp-server-to-clients/clients/zed.ts", + "src/store/services/steps/add-mcp-server-to-clients/index.ts", + "src/store/services/steps/add-mcp-server-to-clients/plugin-client.ts" ], "imports": [ "analytics.js", @@ -23,28 +23,28 @@ }, "agent-interface.js": { "sources": [ - "src/lib/agent-env-isolation.ts", - "src/lib/agent/agent-interface.ts", - "src/lib/agent/agent-phase.ts", - "src/lib/agent/bash-fence.ts", - "src/lib/agent/commandments.ts", - "src/lib/agent/output-signals.ts", - "src/lib/agent/runner/harness/pi/gateway.ts", - "src/lib/agent/runner/harness/pi/runtime-notes.ts", - "src/lib/agent/runner/switchboard/commandments.ts", - "src/lib/agent/stored-login.ts", - "src/lib/agent/triage-provider.ts", - "src/lib/auth-session-state.ts", - "src/lib/claude-settings.ts", - "src/lib/fetch-retry.ts", - "src/lib/safe-tools.ts", - "src/lib/secret-vault.ts", - "src/lib/wizard-ask-bridge.ts", - "src/lib/wizard-tools/handoff.ts", - "src/lib/wizard-tools/mcp.ts", - "src/lib/wizard-tools/tools.ts", - "src/utils/custom-headers.ts", - "src/utils/env-scan.ts" + "src/agent/agent-interface.ts", + "src/agent/agent-phase.ts", + "src/agent/bash-fence.ts", + "src/agent/commandments.ts", + "src/agent/output-signals.ts", + "src/agent/runner/harness/pi/gateway.ts", + "src/agent/runner/harness/pi/runtime-notes.ts", + "src/agent/runner/switchboard/commandments.ts", + "src/agent/stored-login.ts", + "src/agent/tools/mcp.ts", + "src/agent/triage-provider.ts", + "src/store/agent-protocol/agent-env-isolation.ts", + "src/store/auth-session-state.ts", + "src/store/fetch-retry.ts", + "src/store/safe-tools.ts", + "src/store/services/claude-settings.ts", + "src/store/session/secret-vault.ts", + "src/store/session/wizard-ask-bridge.ts", + "src/store/shared/custom-headers.ts", + "src/store/shared/env-scan.ts", + "src/store/tools/handoff.ts", + "src/store/tools/tools.ts" ], "imports": [ "analytics.js", @@ -63,7 +63,7 @@ }, "agent-prompt-loader.js": { "sources": [ - "src/lib/agent/agent-prompt-loader.ts" + "src/agent/agent-prompt-loader.ts" ], "imports": [ "agent-interface.js", @@ -74,40 +74,40 @@ }, "agent-runner.js": { "sources": [ - "src/lib/agent/agent-prompt.ts", - "src/lib/agent/agent-runner.ts", - "src/lib/agent/runner/harness/anthropic/index.ts", - "src/lib/agent/runner/index.ts", - "src/lib/agent/runner/sequence/linear.ts", - "src/lib/agent/runner/sequence/orchestrator/executor.ts", - "src/lib/agent/runner/sequence/orchestrator/orchestrator-runner.ts", - "src/lib/agent/runner/sequence/orchestrator/run-metrics.ts", - "src/lib/agent/runner/sequence/orchestrator/seeded-deps.ts", - "src/lib/agent/runner/shared/bootstrap.ts", - "src/lib/agent/runner/shared/errors.ts", - "src/lib/agent/runner/switchboard/flags/index.ts", - "src/lib/agent/runner/switchboard/flags/orchestrator.ts", - "src/lib/agent/runner/switchboard/flags/schemes.ts", - "src/lib/agent/runner/switchboard/flags/self-driving.ts", - "src/lib/agent/runner/switchboard/harness.ts", - "src/lib/agent/runner/switchboard/index.ts", - "src/lib/agent/runner/switchboard/sequence.ts", - "src/lib/middleware/benchmark.ts", - "src/lib/middleware/benchmarks/cache-tracker.ts", - "src/lib/middleware/benchmarks/compaction-tracker.ts", - "src/lib/middleware/benchmarks/context-size-tracker.ts", - "src/lib/middleware/benchmarks/cost-tracker.ts", - "src/lib/middleware/benchmarks/duration-tracker.ts", - "src/lib/middleware/benchmarks/index.ts", - "src/lib/middleware/benchmarks/json-writer.ts", - "src/lib/middleware/benchmarks/summary.ts", - "src/lib/middleware/benchmarks/token-tracker.ts", - "src/lib/middleware/benchmarks/turn-counter.ts", - "src/lib/middleware/config.ts", - "src/lib/middleware/phase-detector.ts", - "src/lib/middleware/pipeline.ts", - "src/lib/programs/audit/ledger-watcher.ts", - "src/utils/terminal-bell.ts" + "src/agent/agent-prompt.ts", + "src/agent/agent-runner.ts", + "src/agent/middleware/benchmark.ts", + "src/agent/middleware/benchmarks/cache-tracker.ts", + "src/agent/middleware/benchmarks/compaction-tracker.ts", + "src/agent/middleware/benchmarks/context-size-tracker.ts", + "src/agent/middleware/benchmarks/cost-tracker.ts", + "src/agent/middleware/benchmarks/duration-tracker.ts", + "src/agent/middleware/benchmarks/index.ts", + "src/agent/middleware/benchmarks/json-writer.ts", + "src/agent/middleware/benchmarks/summary.ts", + "src/agent/middleware/benchmarks/token-tracker.ts", + "src/agent/middleware/benchmarks/turn-counter.ts", + "src/agent/middleware/config.ts", + "src/agent/middleware/phase-detector.ts", + "src/agent/middleware/pipeline.ts", + "src/agent/runner/harness/anthropic/index.ts", + "src/agent/runner/index.ts", + "src/agent/runner/sequence/linear.ts", + "src/agent/runner/sequence/orchestrator/executor.ts", + "src/agent/runner/sequence/orchestrator/orchestrator-runner.ts", + "src/agent/runner/sequence/orchestrator/run-metrics.ts", + "src/agent/runner/sequence/orchestrator/seeded-deps.ts", + "src/agent/runner/shared/bootstrap.ts", + "src/agent/runner/shared/errors.ts", + "src/agent/runner/switchboard/flags/index.ts", + "src/agent/runner/switchboard/flags/orchestrator.ts", + "src/agent/runner/switchboard/flags/schemes.ts", + "src/agent/runner/switchboard/flags/self-driving.ts", + "src/agent/runner/switchboard/harness.ts", + "src/agent/runner/switchboard/index.ts", + "src/agent/runner/switchboard/sequence.ts", + "src/store/programs/audit/ledger-watcher.ts", + "src/store/shared/terminal-bell.ts" ], "imports": [ "agent-interface.js", @@ -135,8 +135,8 @@ }, "analytics.js": { "sources": [ - "src/utils/analytics.ts", - "src/utils/ci-flag-overrides.ts" + "src/store/shared/analytics.ts", + "src/store/shared/ci-flag-overrides.ts" ], "imports": [ "constants.js", @@ -147,7 +147,7 @@ }, "api.js": { "sources": [ - "src/lib/api.ts" + "src/store/api.ts" ], "imports": [ "analytics.js", @@ -158,58 +158,58 @@ "bin.js": { "sources": [ "bin.ts", - "src/commands/ai-observability.ts", - "src/commands/audit.ts", - "src/commands/basic-integration/index.ts", - "src/commands/basic-integration/skill.ts", - "src/commands/cli/add.ts", - "src/commands/cli/index.ts", - "src/commands/command.ts", - "src/commands/doctor.ts", - "src/commands/error-tracking.ts", - "src/commands/factories/family-command-factory.ts", - "src/commands/factories/family-picker.tsx", - "src/commands/factories/native-command-factory.ts", - "src/commands/factories/shared.ts", - "src/commands/mcp-analytics.ts", - "src/commands/mcp/add.ts", - "src/commands/mcp/index.ts", - "src/commands/mcp/remove.ts", - "src/commands/mcp/tui-availability.ts", - "src/commands/mcp/tutorial.ts", - "src/commands/metrics.ts", - "src/commands/migrate.ts", - "src/commands/provision.ts", - "src/commands/replay-vision.ts", - "src/commands/revenue.ts", - "src/commands/self-driving.ts", - "src/commands/skill-program-options.ts", - "src/commands/skill.ts", - "src/commands/slack.ts", - "src/commands/upload-sourcemaps.ts", - "src/commands/warehouse.ts", - "src/lib/programs/ai-opt-in-gate.ts", - "src/lib/programs/dispatch-family.ts", - "src/lib/programs/flow-for.ts", - "src/lib/programs/run-config.ts", - "src/lib/runners/resolve-no-telemetry.ts", - "src/lib/runners/run-non-interactive.ts", - "src/lib/runners/run-wizard-ci.ts", - "src/lib/runners/run-wizard-headless.ts", - "src/lib/runners/run-wizard.ts", - "src/ui/mint-failure.ts", - "src/ui/tui/hooks/keyboard-hints-utils.ts", - "src/ui/tui/hooks/useKeyBindings.ts", - "src/ui/tui/hooks/useKeyboardHints.tsx", - "src/ui/tui/hooks/useStdoutDimensions.ts", - "src/ui/tui/primitives/ConfirmButton.tsx", - "src/ui/tui/primitives/PickerMenu.tsx", - "src/ui/tui/primitives/PromptLabel.tsx", - "src/ui/tui/primitives/content-types.ts", - "src/ui/tui/primitives/layout-helpers.ts", - "src/ui/tui/primitives/picker-filter.ts", - "src/ui/tui/styles.ts", - "src/wizard.ts" + "src/cli/commands/ai-observability.ts", + "src/cli/commands/audit.ts", + "src/cli/commands/basic-integration/index.ts", + "src/cli/commands/basic-integration/skill.ts", + "src/cli/commands/cli/add.ts", + "src/cli/commands/cli/index.ts", + "src/cli/commands/command.ts", + "src/cli/commands/doctor.ts", + "src/cli/commands/error-tracking.ts", + "src/cli/commands/factories/family-command-factory.ts", + "src/cli/commands/factories/native-command-factory.ts", + "src/cli/commands/factories/shared.ts", + "src/cli/commands/mcp-analytics.ts", + "src/cli/commands/mcp/add.ts", + "src/cli/commands/mcp/index.ts", + "src/cli/commands/mcp/remove.ts", + "src/cli/commands/mcp/tui-availability.ts", + "src/cli/commands/mcp/tutorial.ts", + "src/cli/commands/metrics.ts", + "src/cli/commands/migrate.ts", + "src/cli/commands/provision.ts", + "src/cli/commands/replay-vision.ts", + "src/cli/commands/revenue.ts", + "src/cli/commands/self-driving.ts", + "src/cli/commands/skill-program-options.ts", + "src/cli/commands/skill.ts", + "src/cli/commands/slack.ts", + "src/cli/commands/upload-sourcemaps.ts", + "src/cli/commands/warehouse.ts", + "src/cli/runners/resolve-no-telemetry.ts", + "src/cli/runners/run-non-interactive.ts", + "src/cli/runners/run-wizard-ci.ts", + "src/cli/runners/run-wizard-headless.ts", + "src/cli/runners/run-wizard.ts", + "src/cli/wizard.ts", + "src/store/programs/ai-opt-in-gate.ts", + "src/store/programs/dispatch-family.ts", + "src/store/programs/flow-for.ts", + "src/store/programs/run-config.ts", + "src/tui/family-picker.tsx", + "src/tui/hooks/keyboard-hints-utils.ts", + "src/tui/hooks/useKeyBindings.ts", + "src/tui/hooks/useKeyboardHints.tsx", + "src/tui/hooks/useStdoutDimensions.ts", + "src/tui/mint-failure.ts", + "src/tui/primitives/ConfirmButton.tsx", + "src/tui/primitives/PickerMenu.tsx", + "src/tui/primitives/PromptLabel.tsx", + "src/tui/primitives/content-types.ts", + "src/tui/primitives/layout-helpers.ts", + "src/tui/primitives/picker-filter.ts", + "src/tui/styles.ts" ], "imports": [ "add-mcp-server-to-clients.js", @@ -249,7 +249,7 @@ }, "bounded-fs.js": { "sources": [ - "src/utils/bounded-fs.ts" + "src/store/shared/bounded-fs.ts" ], "imports": [ "analytics.js", @@ -258,7 +258,7 @@ }, "ci-install.js": { "sources": [ - "src/commands/basic-integration/ci-install.ts" + "src/cli/commands/basic-integration/ci-install.ts" ], "imports": [ "bin.js", @@ -271,7 +271,7 @@ }, "constants.js": { "sources": [ - "src/lib/constants.ts" + "src/store/shared/constants.ts" ], "imports": [ "local-dev.js", @@ -286,14 +286,14 @@ }, "defaults.js": { "sources": [ - "src/steps/add-mcp-server-to-clients/defaults.ts", - "src/steps/add-mcp-server-to-clients/results.ts" + "src/store/services/steps/add-mcp-server-to-clients/defaults.ts", + "src/store/services/steps/add-mcp-server-to-clients/results.ts" ], "imports": [] }, "endpoints.js": { "sources": [ - "src/lib/health-checks/endpoints.ts" + "src/store/health-checks/endpoints.ts" ], "imports": [ "constants.js", @@ -302,7 +302,7 @@ }, "env-api-key.js": { "sources": [ - "src/utils/env-api-key.ts" + "src/store/shared/env-api-key.ts" ], "imports": [ "bounded-fs.js", @@ -311,7 +311,7 @@ }, "environment.js": { "sources": [ - "src/utils/environment.ts" + "src/store/shared/environment.ts" ], "imports": [ "rolldown-runtime.js" @@ -319,22 +319,22 @@ }, "errors.js": { "sources": [ - "src/lib/agent-signals.ts", - "src/lib/errors/agent-map.ts", - "src/lib/errors/auth.ts", - "src/lib/errors/catalog.ts", - "src/lib/errors/codes.ts", - "src/lib/errors/detect-map.ts", - "src/lib/errors/emit.ts", - "src/lib/errors/run-failure.ts", - "src/lib/errors/sanitize.ts", - "src/lib/errors/skill-map.ts" + "src/store/agent-protocol/agent-signals.ts", + "src/store/shared/errors/agent-map.ts", + "src/store/shared/errors/auth.ts", + "src/store/shared/errors/catalog.ts", + "src/store/shared/errors/codes.ts", + "src/store/shared/errors/detect-map.ts", + "src/store/shared/errors/emit.ts", + "src/store/shared/errors/run-failure.ts", + "src/store/shared/errors/sanitize.ts", + "src/store/shared/errors/skill-map.ts" ], "imports": [] }, "file.js": { "sources": [ - "src/lib/task-stream/destinations/file.ts" + "src/store/task-stream/destinations/file.ts" ], "imports": [ "debug.js" @@ -342,7 +342,7 @@ }, "file-watcher.js": { "sources": [ - "src/lib/file-watcher.ts" + "src/store/file-watcher.ts" ], "imports": [ "debug.js" @@ -350,7 +350,7 @@ }, "gateway-session.js": { "sources": [ - "src/lib/gateway-session.ts" + "src/agent/gateway/gateway-session.ts" ], "imports": [ "analytics.js", @@ -362,7 +362,7 @@ }, "headless-ui.js": { "sources": [ - "src/ui/tui/console/headless-ui.ts" + "src/tui/console/headless-ui.ts" ], "imports": [ "logging-ui.js" @@ -370,7 +370,7 @@ }, "interactive.js": { "sources": [ - "src/commands/basic-integration/interactive.ts" + "src/cli/commands/basic-integration/interactive.ts" ], "imports": [ "bin.js", @@ -379,13 +379,13 @@ }, "local-dev.js": { "sources": [ - "src/lib/local-dev.ts" + "src/store/local-dev.ts" ], "imports": [] }, "logging-ui.js": { "sources": [ - "src/ui/tui/console/logging-ui.ts" + "src/tui/console/logging-ui.ts" ], "imports": [ "constants.js", @@ -394,7 +394,7 @@ }, "mcp.js": { "sources": [ - "src/lib/agent/runner/harness/pi/mcp.ts" + "src/agent/runner/harness/pi/mcp.ts" ], "imports": [ "debug.js", @@ -403,7 +403,7 @@ }, "mcp-prompt-streaming.js": { "sources": [ - "src/lib/agent/mcp-prompt-streaming.ts" + "src/agent/mcp-prompt-streaming.ts" ], "imports": [ "agent-interface.js", @@ -415,7 +415,7 @@ }, "non-interactive.js": { "sources": [ - "src/commands/basic-integration/non-interactive.ts" + "src/cli/commands/basic-integration/non-interactive.ts" ], "imports": [ "errors.js", @@ -424,7 +424,7 @@ }, "orchestrator-tools.js": { "sources": [ - "src/lib/agent/runner/harness/pi/orchestrator-tools.ts" + "src/agent/runner/harness/pi/orchestrator-tools.ts" ], "imports": [ "analytics.js", @@ -433,7 +433,7 @@ }, "package-json.js": { "sources": [ - "src/utils/package-json.ts" + "src/store/shared/package-json.ts" ], "imports": [ "rolldown-runtime.js" @@ -441,8 +441,8 @@ }, "package-manager.js": { "sources": [ - "src/frameworks/python/utils.ts", - "src/lib/detection/package-manager.ts" + "src/store/detection/package-manager.ts", + "src/store/frameworks/python/utils.ts" ], "imports": [ "setup-utils.js" @@ -450,9 +450,9 @@ }, "pi.js": { "sources": [ - "src/lib/agent/aio-capture.ts", - "src/lib/agent/runner/harness/pi/completion.ts", - "src/lib/agent/runner/harness/pi/index.ts" + "src/agent/aio-capture.ts", + "src/agent/runner/harness/pi/completion.ts", + "src/agent/runner/harness/pi/index.ts" ], "imports": [ "agent-interface.js", @@ -474,27 +474,27 @@ }, "playground.js": { "sources": [ - "src/commands/basic-integration/playground.ts", - "src/ui/tui/playground/PlaygroundApp.tsx", - "src/ui/tui/playground/demos/AiOptInDemo.tsx", - "src/ui/tui/playground/demos/AskModalDemo.tsx", - "src/ui/tui/playground/demos/AuditChecksDemo.tsx", - "src/ui/tui/playground/demos/DoctorReportDemo.tsx", - "src/ui/tui/playground/demos/EndScreensDemo.tsx", - "src/ui/tui/playground/demos/HealthCheckDemo.tsx", - "src/ui/tui/playground/demos/InputDemo.tsx", - "src/ui/tui/playground/demos/KeyboardHintsDemo.tsx", - "src/ui/tui/playground/demos/LayoutDemo.tsx", - "src/ui/tui/playground/demos/LearnDeckDemo.tsx", - "src/ui/tui/playground/demos/LogDemo.tsx", - "src/ui/tui/playground/demos/McpDemo.tsx", - "src/ui/tui/playground/demos/McpSuggestedPromptsDemo.tsx", - "src/ui/tui/playground/demos/ModalDemo.tsx", - "src/ui/tui/playground/demos/ProgressDemo.tsx", - "src/ui/tui/playground/demos/RunScreenDemo.tsx", - "src/ui/tui/playground/demos/ViewportGuardDemo.tsx", - "src/ui/tui/playground/demos/WelcomeDemo.tsx", - "src/ui/tui/playground/start-playground.ts" + "src/cli/commands/basic-integration/playground.ts", + "src/tui/playground/PlaygroundApp.tsx", + "src/tui/playground/demos/AiOptInDemo.tsx", + "src/tui/playground/demos/AskModalDemo.tsx", + "src/tui/playground/demos/AuditChecksDemo.tsx", + "src/tui/playground/demos/DoctorReportDemo.tsx", + "src/tui/playground/demos/EndScreensDemo.tsx", + "src/tui/playground/demos/HealthCheckDemo.tsx", + "src/tui/playground/demos/InputDemo.tsx", + "src/tui/playground/demos/KeyboardHintsDemo.tsx", + "src/tui/playground/demos/LayoutDemo.tsx", + "src/tui/playground/demos/LearnDeckDemo.tsx", + "src/tui/playground/demos/LogDemo.tsx", + "src/tui/playground/demos/McpDemo.tsx", + "src/tui/playground/demos/McpSuggestedPromptsDemo.tsx", + "src/tui/playground/demos/ModalDemo.tsx", + "src/tui/playground/demos/ProgressDemo.tsx", + "src/tui/playground/demos/RunScreenDemo.tsx", + "src/tui/playground/demos/ViewportGuardDemo.tsx", + "src/tui/playground/demos/WelcomeDemo.tsx", + "src/tui/playground/start-playground.ts" ], "imports": [ "bin.js", @@ -509,7 +509,7 @@ }, "posthog.js": { "sources": [ - "src/lib/task-stream/destinations/posthog.ts" + "src/store/task-stream/destinations/posthog.ts" ], "imports": [ "debug.js" @@ -517,8 +517,8 @@ }, "provisioning.js": { "sources": [ - "src/utils/provisioning.ts", - "src/utils/urls.ts" + "src/store/shared/provisioning.ts", + "src/store/shared/urls.ts" ], "imports": [ "analytics.js", @@ -529,10 +529,10 @@ }, "queue-tools.js": { "sources": [ - "src/lib/agent/runner/sequence/orchestrator/queue-tools.ts", - "src/lib/agent/runner/sequence/orchestrator/queue.ts", - "src/lib/agent/runner/switchboard/models.ts", - "src/utils/atomic-ledger.ts" + "src/agent/runner/sequence/orchestrator/queue-tools.ts", + "src/agent/runner/sequence/orchestrator/queue.ts", + "src/agent/runner/switchboard/models.ts", + "src/store/shared/atomic-ledger.ts" ], "imports": [ "analytics.js", @@ -541,7 +541,7 @@ }, "readiness.js": { "sources": [ - "src/lib/health-checks/readiness.ts" + "src/store/health-checks/readiness.ts" ], "imports": [ "debug.js", @@ -550,51 +550,51 @@ }, "registry.js": { "sources": [ - "src/frameworks/android/android-wizard-agent.ts", - "src/frameworks/android/utils.ts", - "src/frameworks/angular/angular-wizard-agent.ts", - "src/frameworks/angular/utils.ts", - "src/frameworks/astro/astro-wizard-agent.ts", - "src/frameworks/astro/utils.ts", - "src/frameworks/django/django-wizard-agent.ts", - "src/frameworks/django/utils.ts", - "src/frameworks/elixir/elixir-wizard-agent.ts", - "src/frameworks/fastapi/fastapi-wizard-agent.ts", - "src/frameworks/fastapi/utils.ts", - "src/frameworks/flask/flask-wizard-agent.ts", - "src/frameworks/flask/utils.ts", - "src/frameworks/flutter/flutter-wizard-agent.ts", - "src/frameworks/go/go-wizard-agent.ts", - "src/frameworks/java/java-wizard-agent.ts", - "src/frameworks/javascript-node/javascript-node-wizard-agent.ts", - "src/frameworks/javascript-web/javascript-web-wizard-agent.ts", - "src/frameworks/javascript-web/utils.ts", - "src/frameworks/kmp/kmp-wizard-agent.ts", - "src/frameworks/laravel/laravel-wizard-agent.ts", - "src/frameworks/laravel/utils.ts", - "src/frameworks/nextjs/nextjs-wizard-agent.ts", - "src/frameworks/nextjs/utils.ts", - "src/frameworks/nuxt/nuxt-wizard-agent.ts", - "src/frameworks/python/python-wizard-agent.ts", - "src/frameworks/rails/rails-wizard-agent.ts", - "src/frameworks/rails/utils.ts", - "src/frameworks/react-native/react-native-wizard-agent.ts", - "src/frameworks/react-native/utils.ts", - "src/frameworks/react-router/react-router-wizard-agent.ts", - "src/frameworks/react-router/utils.ts", - "src/frameworks/ruby/ruby-wizard-agent.ts", - "src/frameworks/ruby/utils.ts", - "src/frameworks/rust/rust-wizard-agent.ts", - "src/frameworks/svelte/svelte-wizard-agent.ts", - "src/frameworks/swift/swift-wizard-agent.ts", - "src/frameworks/swift/utils.ts", - "src/frameworks/tanstack-router/tanstack-router-wizard-agent.ts", - "src/frameworks/tanstack-router/utils.ts", - "src/frameworks/tanstack-start/tanstack-start-wizard-agent.ts", - "src/frameworks/tanstack-start/utils.ts", - "src/frameworks/vue/vue-wizard-agent.ts", - "src/lib/framework-config.ts", - "src/lib/registry.ts" + "src/store/framework-config.ts", + "src/store/frameworks/android/android-wizard-agent.ts", + "src/store/frameworks/android/utils.ts", + "src/store/frameworks/angular/angular-wizard-agent.ts", + "src/store/frameworks/angular/utils.ts", + "src/store/frameworks/astro/astro-wizard-agent.ts", + "src/store/frameworks/astro/utils.ts", + "src/store/frameworks/django/django-wizard-agent.ts", + "src/store/frameworks/django/utils.ts", + "src/store/frameworks/elixir/elixir-wizard-agent.ts", + "src/store/frameworks/fastapi/fastapi-wizard-agent.ts", + "src/store/frameworks/fastapi/utils.ts", + "src/store/frameworks/flask/flask-wizard-agent.ts", + "src/store/frameworks/flask/utils.ts", + "src/store/frameworks/flutter/flutter-wizard-agent.ts", + "src/store/frameworks/go/go-wizard-agent.ts", + "src/store/frameworks/java/java-wizard-agent.ts", + "src/store/frameworks/javascript-node/javascript-node-wizard-agent.ts", + "src/store/frameworks/javascript-web/javascript-web-wizard-agent.ts", + "src/store/frameworks/javascript-web/utils.ts", + "src/store/frameworks/kmp/kmp-wizard-agent.ts", + "src/store/frameworks/laravel/laravel-wizard-agent.ts", + "src/store/frameworks/laravel/utils.ts", + "src/store/frameworks/nextjs/nextjs-wizard-agent.ts", + "src/store/frameworks/nextjs/utils.ts", + "src/store/frameworks/nuxt/nuxt-wizard-agent.ts", + "src/store/frameworks/python/python-wizard-agent.ts", + "src/store/frameworks/rails/rails-wizard-agent.ts", + "src/store/frameworks/rails/utils.ts", + "src/store/frameworks/react-native/react-native-wizard-agent.ts", + "src/store/frameworks/react-native/utils.ts", + "src/store/frameworks/react-router/react-router-wizard-agent.ts", + "src/store/frameworks/react-router/utils.ts", + "src/store/frameworks/ruby/ruby-wizard-agent.ts", + "src/store/frameworks/ruby/utils.ts", + "src/store/frameworks/rust/rust-wizard-agent.ts", + "src/store/frameworks/svelte/svelte-wizard-agent.ts", + "src/store/frameworks/swift/swift-wizard-agent.ts", + "src/store/frameworks/swift/utils.ts", + "src/store/frameworks/tanstack-router/tanstack-router-wizard-agent.ts", + "src/store/frameworks/tanstack-router/utils.ts", + "src/store/frameworks/tanstack-start/tanstack-start-wizard-agent.ts", + "src/store/frameworks/tanstack-start/utils.ts", + "src/store/frameworks/vue/vue-wizard-agent.ts", + "src/store/registry.ts" ], "imports": [ "bounded-fs.js", @@ -611,57 +611,58 @@ }, "run-failure.js": { "sources": [ - "src/lib/detection/project-scope.ts", - "src/lib/programs/agent-skill/index.ts", - "src/lib/programs/agent-skill/steps.ts", - "src/lib/programs/ai-observability/index.ts", - "src/lib/programs/audit/detect.ts", - "src/lib/programs/audit/index.ts", - "src/lib/programs/audit/seed.ts", - "src/lib/programs/error-tracking-upload-source-maps/detect.ts", - "src/lib/programs/error-tracking-upload-source-maps/index.ts", - "src/lib/programs/error-tracking-upload-source-maps/prompt.ts", - "src/lib/programs/error-tracking-upload-source-maps/steps.ts", - "src/lib/programs/error-tracking/detect-agentic.ts", - "src/lib/programs/error-tracking/index.ts", - "src/lib/programs/events-audit/index.ts", - "src/lib/programs/events-audit/seed.ts", - "src/lib/programs/events-audit/steps.ts", - "src/lib/programs/mcp-analytics/index.ts", - "src/lib/programs/mcp/index.ts", - "src/lib/programs/metrics/index.ts", - "src/lib/programs/migration/index.ts", - "src/lib/programs/migration/steps.ts", - "src/lib/programs/posthog-doctor/fetch.ts", - "src/lib/programs/posthog-doctor/index.ts", - "src/lib/programs/posthog-doctor/kind-metadata.ts", - "src/lib/programs/posthog-doctor/steps.ts", - "src/lib/programs/posthog-doctor/types.ts", - "src/lib/programs/posthog-integration/handoff.ts", - "src/lib/programs/posthog-integration/index.ts", - "src/lib/programs/posthog-integration/steps.ts", - "src/lib/programs/program-registry.ts", - "src/lib/programs/replay-vision/index.ts", - "src/lib/programs/revenue-analytics/detect.ts", - "src/lib/programs/revenue-analytics/index.ts", - "src/lib/programs/revenue-analytics/steps.ts", - "src/lib/programs/self-driving/detect-agentic.ts", - "src/lib/programs/self-driving/detect.ts", - "src/lib/programs/self-driving/index.ts", - "src/lib/programs/self-driving/prompt.ts", - "src/lib/programs/self-driving/step-keys.ts", - "src/lib/programs/self-driving/steps.ts", - "src/lib/programs/shared/health-check-step.ts", - "src/lib/programs/shared/posthog-cli-preinstall.ts", - "src/lib/programs/slack/index.ts", - "src/lib/programs/warehouse-source/index.ts", - "src/lib/programs/warehouse-source/steps.ts", - "src/lib/programs/web-analytics-doctor/detect.ts", - "src/lib/programs/web-analytics-doctor/index.ts", - "src/lib/programs/web-analytics-doctor/steps.ts", - "src/lib/run-failure.ts", - "src/steps/install-cli-steering/index.ts", - "src/ui/tui/programs/self-driving/content/pricing.ts" + "src/cli/headless-mode.ts", + "src/store/detection/project-scope.ts", + "src/store/programs/agent-skill/index.ts", + "src/store/programs/agent-skill/steps.ts", + "src/store/programs/ai-observability/index.ts", + "src/store/programs/audit/detect.ts", + "src/store/programs/audit/index.ts", + "src/store/programs/audit/seed.ts", + "src/store/programs/error-tracking-upload-source-maps/detect.ts", + "src/store/programs/error-tracking-upload-source-maps/index.ts", + "src/store/programs/error-tracking-upload-source-maps/prompt.ts", + "src/store/programs/error-tracking-upload-source-maps/steps.ts", + "src/store/programs/error-tracking/detect-agentic.ts", + "src/store/programs/error-tracking/index.ts", + "src/store/programs/events-audit/index.ts", + "src/store/programs/events-audit/seed.ts", + "src/store/programs/events-audit/steps.ts", + "src/store/programs/mcp-analytics/index.ts", + "src/store/programs/mcp/index.ts", + "src/store/programs/metrics/index.ts", + "src/store/programs/migration/index.ts", + "src/store/programs/migration/steps.ts", + "src/store/programs/posthog-doctor/fetch.ts", + "src/store/programs/posthog-doctor/index.ts", + "src/store/programs/posthog-doctor/kind-metadata.ts", + "src/store/programs/posthog-doctor/steps.ts", + "src/store/programs/posthog-doctor/types.ts", + "src/store/programs/posthog-integration/handoff.ts", + "src/store/programs/posthog-integration/index.ts", + "src/store/programs/posthog-integration/steps.ts", + "src/store/programs/program-registry.ts", + "src/store/programs/replay-vision/index.ts", + "src/store/programs/revenue-analytics/detect.ts", + "src/store/programs/revenue-analytics/index.ts", + "src/store/programs/revenue-analytics/steps.ts", + "src/store/programs/self-driving/detect-agentic.ts", + "src/store/programs/self-driving/detect.ts", + "src/store/programs/self-driving/index.ts", + "src/store/programs/self-driving/prompt.ts", + "src/store/programs/self-driving/step-keys.ts", + "src/store/programs/self-driving/steps.ts", + "src/store/programs/shared/health-check-step.ts", + "src/store/programs/shared/posthog-cli-preinstall.ts", + "src/store/programs/slack/index.ts", + "src/store/programs/warehouse-source/index.ts", + "src/store/programs/warehouse-source/steps.ts", + "src/store/programs/web-analytics-doctor/detect.ts", + "src/store/programs/web-analytics-doctor/index.ts", + "src/store/programs/web-analytics-doctor/steps.ts", + "src/store/services/steps/install-cli-steering/index.ts", + "src/store/state/run-failure.ts", + "src/tui/programs/self-driving/content/pricing.ts" ], "imports": [ "agent-interface.js", @@ -687,7 +688,7 @@ }, "security.js": { "sources": [ - "src/lib/agent/runner/harness/pi/security.ts" + "src/agent/runner/harness/pi/security.ts" ], "imports": [ "agent-interface.js", @@ -698,14 +699,14 @@ }, "setup-utils.js": { "sources": [ - "src/lib/host-resolution.ts", - "src/lib/oauth/program-scopes.ts", - "src/utils/oauth-errors.ts", - "src/utils/oauth.ts", - "src/utils/package-manager.ts", - "src/utils/project-resolution.ts", - "src/utils/semver.ts", - "src/utils/setup-utils.ts" + "src/store/host-resolution.ts", + "src/store/services/oauth/program-scopes.ts", + "src/store/shared/oauth-errors.ts", + "src/store/shared/oauth.ts", + "src/store/shared/package-manager.ts", + "src/store/shared/project-resolution.ts", + "src/store/shared/semver.ts", + "src/store/shared/setup-utils.ts" ], "imports": [ "analytics.js", @@ -723,71 +724,71 @@ }, "start-tui.js": { "sources": [ - "src/lib/programs/error-tracking-upload-source-maps/detect-agentic.ts", - "src/lib/wizard-spellbook.ts", - "src/steps/add-mcp-server-to-clients/browser-client.ts", - "src/steps/add-mcp-server-to-clients/login-client.ts", - "src/ui/store-ui.ts", - "src/ui/tui/App.tsx", - "src/ui/tui/components/PrivacyPanel.tsx", - "src/ui/tui/exit-line.ts", - "src/ui/tui/hooks/useGithubConnection.ts", - "src/ui/tui/posthog-integration-intro.ts", - "src/ui/tui/screen-registry.tsx", - "src/ui/tui/screens/AgentSkillIntroScreen.tsx", - "src/ui/tui/screens/AiObservabilityIntroScreen.tsx", - "src/ui/tui/screens/AuthErrorScreen.tsx", - "src/ui/tui/screens/AuthScreen.tsx", - "src/ui/tui/screens/ErrorTrackingDetectScreen.tsx", - "src/ui/tui/screens/ErrorTrackingIntroScreen.tsx", - "src/ui/tui/screens/ExitScreen.tsx", - "src/ui/tui/screens/IntroScreenLayout.tsx", - "src/ui/tui/screens/KeepSkillsScreen.tsx", - "src/ui/tui/screens/ManagedSettingsScreen.tsx", - "src/ui/tui/screens/ManualAuthCodeScreen.tsx", - "src/ui/tui/screens/MetricsIntroScreen.tsx", - "src/ui/tui/screens/MigrationIntroScreen.tsx", - "src/ui/tui/screens/MintFailureScreen.tsx", - "src/ui/tui/screens/PortConflictScreen.tsx", - "src/ui/tui/screens/PostHogIntegrationIntroScreen.tsx", - "src/ui/tui/screens/RevenueIntroScreen.tsx", - "src/ui/tui/screens/RunScreen.tsx", - "src/ui/tui/screens/SelfDrivingGitHubScreen.tsx", - "src/ui/tui/screens/SelfDrivingHandoffScreen.tsx", - "src/ui/tui/screens/SelfDrivingIntegrationCheckScreen.tsx", - "src/ui/tui/screens/SelfDrivingIntegrationDetectScreen.tsx", - "src/ui/tui/screens/SelfDrivingIntroScreen.tsx", - "src/ui/tui/screens/SessionTimeoutScreen.tsx", - "src/ui/tui/screens/SettingsOverrideScreen.tsx", - "src/ui/tui/screens/SetupScreen.tsx", - "src/ui/tui/screens/SourceMapsDetectScreen.tsx", - "src/ui/tui/screens/SourceMapsIntroScreen.tsx", - "src/ui/tui/screens/SourceMapsOutroScreen.tsx", - "src/ui/tui/screens/TaskNoticeScreen.tsx", - "src/ui/tui/screens/WarehouseIntroScreen.tsx", - "src/ui/tui/screens/WizardAskScreen.tsx", - "src/ui/tui/screens/audit/AuditAreaPane.tsx", - "src/ui/tui/screens/audit/AuditChecksOutroSection.tsx", - "src/ui/tui/screens/audit/AuditIntroScreen.tsx", - "src/ui/tui/screens/audit/AuditOutroScreen.tsx", - "src/ui/tui/screens/audit/AuditRunScreen.tsx", - "src/ui/tui/screens/audit/PendingChecksList.tsx", - "src/ui/tui/screens/audit/slides/events-audit/createDashboard.tsx", - "src/ui/tui/screens/audit/slides/events-audit/detectSdk.tsx", - "src/ui/tui/screens/audit/slides/events-audit/enrichSites.tsx", - "src/ui/tui/screens/audit/slides/events-audit/index.ts", - "src/ui/tui/screens/audit/slides/events-audit/queryVolume.tsx", - "src/ui/tui/screens/audit/slides/events-audit/scanSites.tsx", - "src/ui/tui/screens/audit/slides/events-audit/uploadNotebook.tsx", - "src/ui/tui/screens/audit/slides/events-audit/writeReport.tsx", - "src/ui/tui/screens/doctor/DoctorIntroScreen.tsx", - "src/ui/tui/screens/doctor/DoctorReportScreen.tsx", - "src/ui/tui/screens/health/HealthCheckScreen.tsx", - "src/ui/tui/services/coding-agent-launcher.ts", - "src/ui/tui/services/mcp-installer.ts", - "src/ui/tui/services/mcp-suggested-prompts-services.ts", - "src/ui/tui/start-tui.ts", - "src/utils/clipboard.ts" + "src/store/programs/error-tracking-upload-source-maps/detect-agentic.ts", + "src/store/services/steps/add-mcp-server-to-clients/browser-client.ts", + "src/store/services/steps/add-mcp-server-to-clients/login-client.ts", + "src/store/shared/clipboard.ts", + "src/store/ui/store-ui.ts", + "src/store/wizard-spellbook.ts", + "src/tui/App.tsx", + "src/tui/components/PrivacyPanel.tsx", + "src/tui/exit-line.ts", + "src/tui/hooks/useGithubConnection.ts", + "src/tui/posthog-integration-intro.ts", + "src/tui/screen-registry.tsx", + "src/tui/screens/AgentSkillIntroScreen.tsx", + "src/tui/screens/AiObservabilityIntroScreen.tsx", + "src/tui/screens/AuthErrorScreen.tsx", + "src/tui/screens/AuthScreen.tsx", + "src/tui/screens/ErrorTrackingDetectScreen.tsx", + "src/tui/screens/ErrorTrackingIntroScreen.tsx", + "src/tui/screens/ExitScreen.tsx", + "src/tui/screens/IntroScreenLayout.tsx", + "src/tui/screens/KeepSkillsScreen.tsx", + "src/tui/screens/ManagedSettingsScreen.tsx", + "src/tui/screens/ManualAuthCodeScreen.tsx", + "src/tui/screens/MetricsIntroScreen.tsx", + "src/tui/screens/MigrationIntroScreen.tsx", + "src/tui/screens/MintFailureScreen.tsx", + "src/tui/screens/PortConflictScreen.tsx", + "src/tui/screens/PostHogIntegrationIntroScreen.tsx", + "src/tui/screens/RevenueIntroScreen.tsx", + "src/tui/screens/RunScreen.tsx", + "src/tui/screens/SelfDrivingGitHubScreen.tsx", + "src/tui/screens/SelfDrivingHandoffScreen.tsx", + "src/tui/screens/SelfDrivingIntegrationCheckScreen.tsx", + "src/tui/screens/SelfDrivingIntegrationDetectScreen.tsx", + "src/tui/screens/SelfDrivingIntroScreen.tsx", + "src/tui/screens/SessionTimeoutScreen.tsx", + "src/tui/screens/SettingsOverrideScreen.tsx", + "src/tui/screens/SetupScreen.tsx", + "src/tui/screens/SourceMapsDetectScreen.tsx", + "src/tui/screens/SourceMapsIntroScreen.tsx", + "src/tui/screens/SourceMapsOutroScreen.tsx", + "src/tui/screens/TaskNoticeScreen.tsx", + "src/tui/screens/WarehouseIntroScreen.tsx", + "src/tui/screens/WizardAskScreen.tsx", + "src/tui/screens/audit/AuditAreaPane.tsx", + "src/tui/screens/audit/AuditChecksOutroSection.tsx", + "src/tui/screens/audit/AuditIntroScreen.tsx", + "src/tui/screens/audit/AuditOutroScreen.tsx", + "src/tui/screens/audit/AuditRunScreen.tsx", + "src/tui/screens/audit/PendingChecksList.tsx", + "src/tui/screens/audit/slides/events-audit/createDashboard.tsx", + "src/tui/screens/audit/slides/events-audit/detectSdk.tsx", + "src/tui/screens/audit/slides/events-audit/enrichSites.tsx", + "src/tui/screens/audit/slides/events-audit/index.ts", + "src/tui/screens/audit/slides/events-audit/queryVolume.tsx", + "src/tui/screens/audit/slides/events-audit/scanSites.tsx", + "src/tui/screens/audit/slides/events-audit/uploadNotebook.tsx", + "src/tui/screens/audit/slides/events-audit/writeReport.tsx", + "src/tui/screens/doctor/DoctorIntroScreen.tsx", + "src/tui/screens/doctor/DoctorReportScreen.tsx", + "src/tui/screens/health/HealthCheckScreen.tsx", + "src/tui/services/coding-agent-launcher.ts", + "src/tui/services/mcp-installer.ts", + "src/tui/services/mcp-suggested-prompts-services.ts", + "src/tui/start-tui.ts" ], "imports": [ "add-mcp-server-to-clients.js", @@ -818,9 +819,9 @@ }, "steps.js": { "sources": [ - "src/steps/upload-environment-variables/EnvironmentProvider.ts", - "src/steps/upload-environment-variables/index.ts", - "src/steps/upload-environment-variables/providers/vercel.ts" + "src/store/services/steps/upload-environment-variables/EnvironmentProvider.ts", + "src/store/services/steps/upload-environment-variables/index.ts", + "src/store/services/steps/upload-environment-variables/providers/vercel.ts" ], "imports": [ "analytics.js", @@ -830,8 +831,8 @@ }, "store.js": { "sources": [ - "src/lib/flow-resolution.ts", - "src/ui/tui/store.ts" + "src/store/state/flow-resolution.ts", + "src/store/state/store.ts" ], "imports": [ "analytics.js", @@ -846,7 +847,7 @@ }, "subagent.js": { "sources": [ - "src/lib/agent/runner/harness/pi/subagent.ts" + "src/agent/runner/harness/pi/subagent.ts" ], "imports": [ "debug.js" @@ -854,7 +855,7 @@ }, "task.js": { "sources": [ - "src/lib/agent/runner/harness/pi/task.ts" + "src/agent/runner/harness/pi/task.ts" ], "imports": [ "agent-interface.js", @@ -876,9 +877,9 @@ }, "task-stream.js": { "sources": [ - "src/lib/task-stream/audit-areas.ts", - "src/lib/task-stream/event-plan-watcher.ts", - "src/lib/task-stream/task-stream-push.ts" + "src/store/task-stream/audit-areas.ts", + "src/store/task-stream/event-plan-watcher.ts", + "src/store/task-stream/task-stream-push.ts" ], "imports": [ "debug.js", @@ -890,7 +891,7 @@ }, "tasks.js": { "sources": [ - "src/lib/agent/runner/harness/pi/tasks.ts" + "src/agent/runner/harness/pi/tasks.ts" ], "imports": [ "ui.js" @@ -898,8 +899,8 @@ }, "telemetry.js": { "sources": [ - "src/telemetry.ts", - "src/utils/links.ts" + "src/cli/telemetry.ts", + "src/store/shared/links.ts" ], "imports": [ "analytics.js" @@ -907,97 +908,97 @@ }, "terminal.js": { "sources": [ - "src/lib/mcp-project-profile.ts", - "src/lib/mcp-role-prompts.copy.json", - "src/lib/mcp-role-prompts.ts", - "src/lib/mcp-seed-events.ts", - "src/ui/tui/components/LearnCard.tsx", - "src/ui/tui/components/PhaseVisuals.tsx", - "src/ui/tui/components/ServiceHealthList.tsx", - "src/ui/tui/components/StatusPeekTrigger.tsx", - "src/ui/tui/components/TipsCard.tsx", - "src/ui/tui/components/TitleBar.tsx", - "src/ui/tui/components/TokenCostHud.tsx", - "src/ui/tui/components/visualizer/CrateStack.tsx", - "src/ui/tui/components/visualizer/DashboardGrid.tsx", - "src/ui/tui/components/visualizer/DiffCascade.tsx", - "src/ui/tui/components/visualizer/LibraryShelf.tsx", - "src/ui/tui/components/visualizer/MatrixRain.tsx", - "src/ui/tui/components/visualizer/Tumblers.tsx", - "src/ui/tui/components/visualizer/grid.ts", - "src/ui/tui/components/visualizer/palette.ts", - "src/ui/tui/components/visualizer/panel.tsx", - "src/ui/tui/constants.ts", - "src/ui/tui/hooks/useDismissOnAnyKey.ts", - "src/ui/tui/hooks/useTick.ts", - "src/ui/tui/hooks/useUiStore.ts", - "src/ui/tui/primitives/CardLayout.tsx", - "src/ui/tui/primitives/ConfirmationInput.tsx", - "src/ui/tui/primitives/ContentSequencer.tsx", - "src/ui/tui/primitives/DissolveTransition.tsx", - "src/ui/tui/primitives/Divider.tsx", - "src/ui/tui/primitives/EventPlanViewer.tsx", - "src/ui/tui/primitives/GroupedPickerMenu.tsx", - "src/ui/tui/primitives/HNViewer.tsx", - "src/ui/tui/primitives/KeyboardHintsBar.tsx", - "src/ui/tui/primitives/LinesBlock.tsx", - "src/ui/tui/primitives/LinkText.tsx", - "src/ui/tui/primitives/LoadingBox.tsx", - "src/ui/tui/primitives/LogViewer.tsx", - "src/ui/tui/primitives/ModalOverlay.tsx", - "src/ui/tui/primitives/NodeBlock.tsx", - "src/ui/tui/primitives/ProgressList.tsx", - "src/ui/tui/primitives/ScreenContainer.tsx", - "src/ui/tui/primitives/ScreenErrorBoundary.tsx", - "src/ui/tui/primitives/SplitView.tsx", - "src/ui/tui/primitives/TabContainer.tsx", - "src/ui/tui/primitives/TextBlock.tsx", - "src/ui/tui/primitives/ViewportTooSmall.tsx", - "src/ui/tui/primitives/link-helpers.ts", - "src/ui/tui/primitives/text-helpers.ts", - "src/ui/tui/programs/agent-skill/content/index.tsx", - "src/ui/tui/programs/error-tracking-upload-source-maps/content/index.tsx", - "src/ui/tui/programs/error-tracking/content/index.tsx", - "src/ui/tui/programs/error-tracking/content/tips.ts", - "src/ui/tui/programs/migration/content/free-tier.tsx", - "src/ui/tui/programs/migration/content/index.tsx", - "src/ui/tui/programs/migration/content/pricing-structure.tsx", - "src/ui/tui/programs/migration/content/vendor-stack.tsx", - "src/ui/tui/programs/posthog-integration/content/data-flow.tsx", - "src/ui/tui/programs/posthog-integration/content/funnel.tsx", - "src/ui/tui/programs/posthog-integration/content/index.tsx", - "src/ui/tui/programs/posthog-integration/content/line-chart.tsx", - "src/ui/tui/programs/posthog-integration/content/product-suite.tsx", - "src/ui/tui/programs/presentation.ts", - "src/ui/tui/programs/self-driving/content/index.tsx", - "src/ui/tui/programs/self-driving/content/pipeline-diagram.tsx", - "src/ui/tui/programs/self-driving/content/tips.ts", - "src/ui/tui/screens/AiOptInRequiredScreen.tsx", - "src/ui/tui/screens/McpScreen.tsx", - "src/ui/tui/screens/McpSuggestedPromptsScreen.tsx", - "src/ui/tui/screens/OutroScreen.tsx", - "src/ui/tui/screens/SkillSourceInfo.tsx", - "src/ui/tui/screens/SlackConnectScreen.tsx", - "src/ui/tui/screens/audit/AuditChecksViewer/AreaHeaderRow.tsx", - "src/ui/tui/screens/audit/AuditChecksViewer/AuditChecksViewer.tsx", - "src/ui/tui/screens/audit/AuditChecksViewer/CheckRow.tsx", - "src/ui/tui/screens/audit/AuditChecksViewer/DetailRow.tsx", - "src/ui/tui/screens/audit/AuditChecksViewer/Footer.tsx", - "src/ui/tui/screens/audit/AuditChecksViewer/Header.tsx", - "src/ui/tui/screens/audit/AuditChecksViewer/Legend.tsx", - "src/ui/tui/screens/audit/AuditChecksViewer/layout.ts", - "src/ui/tui/screens/audit/AuditChecksViewer/sort.ts", - "src/ui/tui/screens/audit/slides/eventCapture.tsx", - "src/ui/tui/screens/audit/slides/identification.tsx", - "src/ui/tui/screens/audit/slides/index.ts", - "src/ui/tui/screens/audit/slides/installation.tsx", - "src/ui/tui/screens/audit/slides/liveData.tsx", - "src/ui/tui/screens/audit/slides/shared.tsx", - "src/ui/tui/screens/audit/slides/uploadNotebook.tsx", - "src/ui/tui/screens/audit/slides/writeReport.tsx", - "src/ui/tui/screens/doctor/IssueTable.tsx", - "src/ui/tui/terminal.ts", - "src/ui/tui/ui-store.ts" + "src/store/mcp-project-profile.ts", + "src/store/mcp-role-prompts.copy.json", + "src/store/mcp-role-prompts.ts", + "src/store/mcp-seed-events.ts", + "src/tui/components/LearnCard.tsx", + "src/tui/components/PhaseVisuals.tsx", + "src/tui/components/ServiceHealthList.tsx", + "src/tui/components/StatusPeekTrigger.tsx", + "src/tui/components/TipsCard.tsx", + "src/tui/components/TitleBar.tsx", + "src/tui/components/TokenCostHud.tsx", + "src/tui/components/visualizer/CrateStack.tsx", + "src/tui/components/visualizer/DashboardGrid.tsx", + "src/tui/components/visualizer/DiffCascade.tsx", + "src/tui/components/visualizer/LibraryShelf.tsx", + "src/tui/components/visualizer/MatrixRain.tsx", + "src/tui/components/visualizer/Tumblers.tsx", + "src/tui/components/visualizer/grid.ts", + "src/tui/components/visualizer/palette.ts", + "src/tui/components/visualizer/panel.tsx", + "src/tui/constants.ts", + "src/tui/hooks/useDismissOnAnyKey.ts", + "src/tui/hooks/useTick.ts", + "src/tui/hooks/useUiStore.ts", + "src/tui/primitives/CardLayout.tsx", + "src/tui/primitives/ConfirmationInput.tsx", + "src/tui/primitives/ContentSequencer.tsx", + "src/tui/primitives/DissolveTransition.tsx", + "src/tui/primitives/Divider.tsx", + "src/tui/primitives/EventPlanViewer.tsx", + "src/tui/primitives/GroupedPickerMenu.tsx", + "src/tui/primitives/HNViewer.tsx", + "src/tui/primitives/KeyboardHintsBar.tsx", + "src/tui/primitives/LinesBlock.tsx", + "src/tui/primitives/LinkText.tsx", + "src/tui/primitives/LoadingBox.tsx", + "src/tui/primitives/LogViewer.tsx", + "src/tui/primitives/ModalOverlay.tsx", + "src/tui/primitives/NodeBlock.tsx", + "src/tui/primitives/ProgressList.tsx", + "src/tui/primitives/ScreenContainer.tsx", + "src/tui/primitives/ScreenErrorBoundary.tsx", + "src/tui/primitives/SplitView.tsx", + "src/tui/primitives/TabContainer.tsx", + "src/tui/primitives/TextBlock.tsx", + "src/tui/primitives/ViewportTooSmall.tsx", + "src/tui/primitives/link-helpers.ts", + "src/tui/primitives/text-helpers.ts", + "src/tui/programs/agent-skill/content/index.tsx", + "src/tui/programs/error-tracking-upload-source-maps/content/index.tsx", + "src/tui/programs/error-tracking/content/index.tsx", + "src/tui/programs/error-tracking/content/tips.ts", + "src/tui/programs/migration/content/free-tier.tsx", + "src/tui/programs/migration/content/index.tsx", + "src/tui/programs/migration/content/pricing-structure.tsx", + "src/tui/programs/migration/content/vendor-stack.tsx", + "src/tui/programs/posthog-integration/content/data-flow.tsx", + "src/tui/programs/posthog-integration/content/funnel.tsx", + "src/tui/programs/posthog-integration/content/index.tsx", + "src/tui/programs/posthog-integration/content/line-chart.tsx", + "src/tui/programs/posthog-integration/content/product-suite.tsx", + "src/tui/programs/presentation.ts", + "src/tui/programs/self-driving/content/index.tsx", + "src/tui/programs/self-driving/content/pipeline-diagram.tsx", + "src/tui/programs/self-driving/content/tips.ts", + "src/tui/screens/AiOptInRequiredScreen.tsx", + "src/tui/screens/McpScreen.tsx", + "src/tui/screens/McpSuggestedPromptsScreen.tsx", + "src/tui/screens/OutroScreen.tsx", + "src/tui/screens/SkillSourceInfo.tsx", + "src/tui/screens/SlackConnectScreen.tsx", + "src/tui/screens/audit/AuditChecksViewer/AreaHeaderRow.tsx", + "src/tui/screens/audit/AuditChecksViewer/AuditChecksViewer.tsx", + "src/tui/screens/audit/AuditChecksViewer/CheckRow.tsx", + "src/tui/screens/audit/AuditChecksViewer/DetailRow.tsx", + "src/tui/screens/audit/AuditChecksViewer/Footer.tsx", + "src/tui/screens/audit/AuditChecksViewer/Header.tsx", + "src/tui/screens/audit/AuditChecksViewer/Legend.tsx", + "src/tui/screens/audit/AuditChecksViewer/layout.ts", + "src/tui/screens/audit/AuditChecksViewer/sort.ts", + "src/tui/screens/audit/slides/eventCapture.tsx", + "src/tui/screens/audit/slides/identification.tsx", + "src/tui/screens/audit/slides/index.ts", + "src/tui/screens/audit/slides/installation.tsx", + "src/tui/screens/audit/slides/liveData.tsx", + "src/tui/screens/audit/slides/shared.tsx", + "src/tui/screens/audit/slides/uploadNotebook.tsx", + "src/tui/screens/audit/slides/writeReport.tsx", + "src/tui/screens/doctor/IssueTable.tsx", + "src/tui/terminal.ts", + "src/tui/ui-store.ts" ], "imports": [ "agent-interface.js", @@ -1018,18 +1019,18 @@ }, "token-pricing.js": { "sources": [ - "src/lib/agent/runner/shared/authenticate.ts", - "src/lib/ask-policy.ts", - "src/lib/detection/agentic.ts", - "src/lib/detection/context.ts", - "src/lib/detection/features.ts", - "src/lib/detection/framework.ts", - "src/lib/programs/posthog-integration/detect.ts", - "src/lib/programs/shared/package-scanning.ts", - "src/lib/programs/warehouse-source/detect.ts", - "src/lib/token-pricing.ts", - "src/lib/warehouse-sources/detect.ts", - "src/lib/warehouse-sources/registry.ts" + "src/agent/runner/shared/authenticate.ts", + "src/store/agent-protocol/token-pricing.ts", + "src/store/detection/agentic.ts", + "src/store/detection/context.ts", + "src/store/detection/features.ts", + "src/store/detection/framework.ts", + "src/store/programs/posthog-integration/detect.ts", + "src/store/programs/shared/package-scanning.ts", + "src/store/programs/warehouse-source/detect.ts", + "src/store/services/warehouse-sources/detect.ts", + "src/store/services/warehouse-sources/registry.ts", + "src/store/session/ask-policy.ts" ], "imports": [ "agent-interface.js", @@ -1047,7 +1048,7 @@ }, "tools.js": { "sources": [ - "src/lib/agent/runner/harness/pi/tools.ts" + "src/agent/runner/harness/pi/tools.ts" ], "imports": [ "agent-interface.js", @@ -1061,14 +1062,14 @@ }, "ui.js": { "sources": [ - "src/ui/index.ts", - "src/ui/null-ui.ts" + "src/store/ui/index.ts", + "src/store/ui/null-ui.ts" ], "imports": [] }, "version.js": { "sources": [ - "src/lib/version.ts" + "src/store/shared/version.ts" ], "imports": [] }, @@ -1079,25 +1080,27 @@ ] }, "wizard-session.js": { - "sources": [], + "sources": [ + "src/store/session/wizard-session.ts" + ], "imports": [ - "wizard-session.js" + "local-dev.js" ] }, "wizard-ui.js": { "sources": [ - "src/ui/wizard-ui.ts" + "src/store/ui/wizard-ui.ts" ], "imports": [] }, "yara-hooks.js": { "sources": [ - "src/lib/programs/audit/types.ts", - "src/lib/programs/events-audit/constants.ts", - "src/lib/programs/posthog-integration/constants.ts", - "src/lib/skill-install.ts", - "src/lib/yara-hooks.ts", - "src/lib/yara-policy.ts" + "src/agent/security/yara-hooks.ts", + "src/agent/security/yara-policy.ts", + "src/store/programs/audit/types.ts", + "src/store/programs/events-audit/constants.ts", + "src/store/programs/posthog-integration/constants.ts", + "src/store/skill-install.ts" ], "imports": [ "analytics.js", diff --git a/scripts/check-screens.tsx b/scripts/check-screens.tsx index bfc2871b5..3949b8ffa 100644 --- a/scripts/check-screens.tsx +++ b/scripts/check-screens.tsx @@ -10,12 +10,12 @@ import React from 'react'; import { render } from 'ink-testing-library'; import { Box } from 'ink'; -import { AuthErrorScreen } from '@ui/tui/screens/AuthErrorScreen'; -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 { AuthErrorScreen } from '@tui/screens/AuthErrorScreen'; +import { ProgressList } from '@tui/primitives/ProgressList'; +import { ManagedSettingsScreen } from '@tui/screens/ManagedSettingsScreen'; +import { SettingsOverrideScreen } from '@tui/screens/SettingsOverrideScreen'; +import { WizardAskScreen } from '@tui/screens/WizardAskScreen'; +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..013eaeb38 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', 'store', 'shared', 'version.ts'), output, ); diff --git a/scripts/mcp-install-smoke-test.ts b/scripts/mcp-install-smoke-test.ts index 13140d317..850871613 100644 --- a/scripts/mcp-install-smoke-test.ts +++ b/scripts/mcp-install-smoke-test.ts @@ -15,7 +15,7 @@ import * as os from 'node:os'; import * as path from 'node:path'; import { fileURLToPath } from 'node:url'; -import { HEADLESS_FLAG } from '../src/lib/headless-mode'; +import { HEADLESS_FLAG } from '@cli/headless-mode'; const PROVIDERS = ['claude-code', 'codex'] as const; type Provider = (typeof PROVIDERS)[number]; diff --git a/scripts/tui-host.no-jest.ts b/scripts/tui-host.no-jest.ts index 358bd3589..562938110 100644 --- a/scripts/tui-host.no-jest.ts +++ b/scripts/tui-host.no-jest.ts @@ -16,35 +16,35 @@ 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 { startTUI } from '@tui/start-tui'; +import { VERSION } from '@store/shared/version'; import { Program, getProgramConfig, type ProgramId, -} from '@lib/programs/program-registry'; -import type { Harness, Sequence } from '@lib/constants'; -import { buildSession } from '@lib/wizard-session'; -import { initLocalDev } from '@lib/local-dev'; -import { configureGatewayFromCIEnvironment } from '@lib/gateway-session'; -import { runAgent } from '@lib/agent/agent-runner'; -import { runConfigFor } from '@lib/programs/run-config'; -import { TaskStreamPush, createFileDestination } from '@lib/task-stream/index'; -import { getAuditChecks } from '@lib/programs/audit/types'; -import { authenticate } from '@lib/agent/runner/shared/authenticate'; -import { getOrAskForProjectData } from '@utils/setup-utils'; -import { logToFile } from '@utils/debug'; +} from '@store/programs/program-registry'; +import type { Harness, Sequence } from '@store/shared/constants'; +import { buildSession } from '@store/session/wizard-session'; +import { initLocalDev } from '@store/local-dev'; +import { configureGatewayFromCIEnvironment } from '@agent/gateway/gateway-session'; +import { runAgent } from '@agent/agent-runner'; +import { runConfigFor } from '@store/programs/run-config'; +import { TaskStreamPush, createFileDestination } from '@store/task-stream'; +import { getAuditChecks } from '@store/programs/audit/types'; +import { authenticate } from '@agent/runner/shared/authenticate'; +import { getOrAskForProjectData } from '@store/shared/setup-utils'; +import { logToFile } from '@store/shared/debug'; import { join } from 'path'; -import { detectFramework } from '@lib/detection/index'; -import { FRAMEWORK_REGISTRY } from '@lib/registry'; -import type { Integration } from '@lib/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 { detectFramework } from '@store/detection'; +import { FRAMEWORK_REGISTRY } from '@store/registry'; +import type { Integration } from '@store/shared/constants'; +import { SELF_DRIVING_INTEGRATE_PATH_KEY } from '@store/programs/self-driving/detect'; +import { ERROR_TRACKING_PROJECT_PATH_KEY } from '@store/programs/error-tracking/detect-agentic'; import { detectSourceMapsPrerequisites, SOURCE_MAPS_CONTEXT_KEYS, -} from '@lib/programs/error-tracking-upload-source-maps/index'; -import { ScreenId, Overlay } from '@ui/tui/router'; +} from '@store/programs/error-tracking-upload-source-maps'; +import { ScreenId, Overlay } from '@tui/router'; import { WizardCiDriver } from '@e2e-harness/wizard-ci-driver'; import { decideE2eAction, diff --git a/scripts/warlock-smoke-test.ts b/scripts/warlock-smoke-test.ts index 089e4110d..8ff9cf648 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/security/yara-policy'; +import { scanInstalledSkill } from '@agent/security/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 09639c6e5..86f65e081 100644 --- a/src/__tests__/architecture/import-boundaries.test.ts +++ b/src/__tests__/architecture/import-boundaries.test.ts @@ -10,31 +10,9 @@ 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', - ], - [ - 'tui', - (p) => - p.startsWith('src/ui/tui/') || - p === 'src/commands/factories/family-picker.tsx', - ], - [ - 'cli', - (p) => - p === 'bin.ts' || - p === 'src/wizard.ts' || - p === 'src/telemetry.ts' || - p.startsWith('src/commands/') || - p.startsWith('src/lib/runners/'), - ], + ['agent', (p) => p.startsWith('src/agent/')], + ['tui', (p) => p.startsWith('src/tui/')], + ['cli', (p) => p === 'bin.ts' || p.startsWith('src/cli/')], [ 'harness', (p) => p.startsWith('e2e-harness/') || p.startsWith('scripts/'), @@ -389,23 +367,19 @@ 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('store'); - expect(classifySurface('src/lib/agent/agent-runner.ts')).toBe('agent'); - expect(classifySurface('src/ui/tui/App.tsx')).toBe('tui'); + expect(classifySurface('src/store/shared/analytics.ts')).toBe('store'); + expect(classifySurface('src/agent/agent-runner.ts')).toBe('agent'); + expect(classifySurface('src/tui/App.tsx')).toBe('tui'); expect(classifySurface('bin.ts')).toBe('cli'); expect(classifySurface('e2e-harness/e2e-profile.ts')).toBe('harness'); - expect(classifySurface('src/lib/wizard-tools/mcp.ts')).toBe('agent'); - expect(classifySurface('src/lib/wizard-tools/tools.ts')).toBe('store'); - expect(classifySurface('src/commands/factories/family-picker.tsx')).toBe( - 'tui', - ); + expect(classifySurface('src/agent/tools/mcp.ts')).toBe('agent'); + expect(classifySurface('src/store/tools/tools.ts')).toBe('store'); + expect(classifySurface('src/tui/family-picker.tsx')).toBe('tui'); expect( - classifySurface( - 'src/ui/tui/programs/posthog-integration/content/index.tsx', - ), + classifySurface('src/tui/programs/posthog-integration/content/index.tsx'), ).toBe('tui'); expect( - classifySurface('src/lib/programs/posthog-integration/index.ts'), + classifySurface('src/store/programs/posthog-integration/index.ts'), ).toBe('store'); }); }); diff --git a/src/__tests__/architecture/known-violations.json b/src/__tests__/architecture/known-violations.json index 0409c46d1..206d665fe 100644 --- a/src/__tests__/architecture/known-violations.json +++ b/src/__tests__/architecture/known-violations.json @@ -1,26 +1,23 @@ { "violations": [ - "src/commands/factories/family-picker.tsx -> src/commands/command.ts", - "src/env.ts -> src/lib/headless-mode.ts", - "src/lib/agent/mcp-prompt-streaming.ts -> src/ui/tui/services/mcp-suggested-prompts-services.ts", - "src/lib/detection/agentic.ts -> src/lib/agent/agent-interface.ts", - "src/lib/detection/project-scope.ts -> src/lib/agent/runner/shared/authenticate.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/self-driving/index.ts -> src/ui/tui/programs/self-driving/content/pricing.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-tools/index.ts -> src/lib/wizard-tools/mcp.ts", - "src/lib/wizard-tools/tools.ts -> src/lib/yara-hooks.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/store-ui.ts -> src/ui/tui/store.ts", - "src/ui/tui/components/PhaseVisuals.tsx -> src/lib/agent/agent-phase.ts", - "src/ui/tui/playground/demos/RunScreenDemo.tsx -> src/lib/agent/agent-phase.ts", - "src/ui/tui/services/mcp-suggested-prompts-services.ts -> src/lib/agent/mcp-prompt-streaming.ts", - "src/utils/package-manager.ts -> src/telemetry.ts", - "src/utils/setup-utils.ts -> src/telemetry.ts" + "src/agent/mcp-prompt-streaming.ts -> src/tui/services/mcp-suggested-prompts-services.ts", + "src/store/detection/agentic.ts -> src/agent/agent-interface.ts", + "src/store/detection/project-scope.ts -> src/agent/runner/shared/authenticate.ts", + "src/store/programs/audit/index.ts -> src/cli/headless-mode.ts", + "src/store/programs/dispatch-family.ts -> src/cli/commands/command.ts", + "src/store/programs/dispatch-family.ts -> src/cli/commands/factories/shared.ts", + "src/store/programs/self-driving/index.ts -> src/tui/programs/self-driving/content/pricing.ts", + "src/store/services/steps/add-mcp-server-to-clients/index.ts -> src/cli/telemetry.ts", + "src/store/services/steps/add-or-update-environment-variables.ts -> src/cli/telemetry.ts", + "src/store/services/steps/run-prettier.ts -> src/cli/telemetry.ts", + "src/store/services/steps/upload-environment-variables/index.ts -> src/cli/telemetry.ts", + "src/store/shared/package-manager.ts -> src/cli/telemetry.ts", + "src/store/shared/setup-utils.ts -> src/cli/telemetry.ts", + "src/store/tools/index.ts -> src/agent/tools/mcp.ts", + "src/store/tools/tools.ts -> src/agent/security/yara-hooks.ts", + "src/tui/components/PhaseVisuals.tsx -> src/agent/agent-phase.ts", + "src/tui/family-picker.tsx -> src/cli/commands/command.ts", + "src/tui/playground/demos/RunScreenDemo.tsx -> src/agent/agent-phase.ts", + "src/tui/services/mcp-suggested-prompts-services.ts -> src/agent/mcp-prompt-streaming.ts" ] } 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/__tests__/agent-interface.test.ts b/src/agent/__tests__/agent-interface.test.ts similarity index 97% rename from src/lib/__tests__/agent-interface.test.ts rename to src/agent/__tests__/agent-interface.test.ts index 181382b56..15f67cae7 100644 --- a/src/lib/__tests__/agent-interface.test.ts +++ b/src/agent/__tests__/agent-interface.test.ts @@ -8,25 +8,25 @@ import { buildAuthErrorContext, buildAgentEnv, reportMcpSetup, -} from '@lib/agent/agent-interface'; -import { AgentOutputSignals } from '@lib/agent/output-signals'; -import { RESUME_INSTRUCTION } from '@lib/agent-signals'; -import { analytics } from '@utils/analytics'; -import { wizardAbort } from '@utils/wizard-abort'; -import { Sequence } from '@lib/constants'; -import type { WizardRunOptions } from '@utils/types'; -import type { SpinnerHandle } from '@ui'; +} from '../agent-interface.js'; +import { AgentOutputSignals } from '../output-signals.js'; +import { RESUME_INSTRUCTION } from '@store/agent-protocol/agent-signals'; +import { analytics } from '@store/shared/analytics'; +import { wizardAbort } from '@store/shared/wizard-abort'; +import { Sequence } from '@store/shared/constants'; +import type { WizardRunOptions } from '@store/shared/types'; +import type { SpinnerHandle } from '@store/ui'; import { AdditionalFeature, ADDITIONAL_FEATURE_PROMPTS, -} from '@lib/wizard-session'; +} from '@store/session/wizard-session'; // Mock dependencies -vi.mock('../../utils/analytics'); -vi.mock('../../utils/debug'); +vi.mock('@store/shared/analytics'); +vi.mock('@store/shared/debug'); // wizardAbort exits the process; the 401 tests below need it to just reject. -vi.mock('@utils/wizard-abort', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('@store/shared/wizard-abort', async (importOriginal) => ({ + ...(await importOriginal()), wizardAbort: vi.fn(), })); @@ -69,7 +69,7 @@ const mockUIInstance = { addTokenUsage: vi.fn(), setFinalTokenCostUsd: vi.fn(), }; -vi.mock('../../ui', () => ({ +vi.mock('@store/ui', () => ({ getUI: () => mockUIInstance, })); 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 ab23e6a49..d7d7581ee 100644 --- a/src/lib/agent/__tests__/agent-prompt-loader.test.ts +++ b/src/agent/__tests__/agent-prompt-loader.test.ts @@ -16,9 +16,9 @@ import { type AgentPrompt, type AgentRegistry, type OrchestratorPromptContext, -} from '../agent-prompt-loader'; -import { QueueStore } from '@lib/agent/runner/sequence/orchestrator/queue'; -import { HostResolution } from '@lib/host-resolution'; +} from '../agent-prompt-loader.js'; +import { QueueStore } from '../runner/sequence/orchestrator/queue.js'; +import { HostResolution } from '@store/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 2ee6bfdb9..641449056 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 { ProgramRun } from '@lib/agent/agent-runner'; -import { HostResolution } from '@lib/host-resolution'; +import { assemblePrompt, type PromptContext } from '../agent-prompt.js'; +import type { ProgramRun } from '../agent-runner.js'; +import { HostResolution } from '@store/host-resolution'; function makeRunDef(overrides: Partial = {}): ProgramRun { return { diff --git a/src/lib/__tests__/agent-runner-ask.test.ts b/src/agent/__tests__/agent-runner-ask.test.ts similarity index 94% rename from src/lib/__tests__/agent-runner-ask.test.ts rename to src/agent/__tests__/agent-runner-ask.test.ts index 2364b5ccf..00e1954d1 100644 --- a/src/lib/__tests__/agent-runner-ask.test.ts +++ b/src/agent/__tests__/agent-runner-ask.test.ts @@ -1,5 +1,5 @@ -import { shouldDisableAsk } from '@lib/agent/agent-runner'; -import { buildSession } from '@lib/wizard-session'; +import { shouldDisableAsk } from '../agent-runner.js'; +import { buildSession } from '@store/session/wizard-session'; describe('shouldDisableAsk', () => { it('enables wizard_ask in interactive runs by default', () => { 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..e883219aa 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 '../aio-capture.js'; 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..a6023537d 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 '../bash-fence.js'; /** * 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..79cafefda 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 '../commandments.js'; +import { assembleCommandments } from '../runner/switchboard/commandments.js'; +import { Harness, Sequence } from '@store/shared/constants'; const global = WIZARD_COMMANDMENTS.join('\n'); diff --git a/src/lib/__tests__/gateway-session.test.ts b/src/agent/__tests__/gateway-session.test.ts similarity index 97% rename from src/lib/__tests__/gateway-session.test.ts rename to src/agent/__tests__/gateway-session.test.ts index ce0966fc5..216935044 100644 --- a/src/lib/__tests__/gateway-session.test.ts +++ b/src/agent/__tests__/gateway-session.test.ts @@ -9,24 +9,24 @@ import { isPastRefresh, isTrustedGatewayUrl, resetGatewaySession, -} from '@lib/gateway-session'; -import type { HostResolution } from '@lib/host-resolution'; -import { ErrorCodes } from '@lib/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'; - -vi.mock('@lib/health-checks/endpoints', () => ({ +} from '../gateway/gateway-session.js'; +import type { HostResolution } from '@store/host-resolution'; +import { ErrorCodes } from '@store/shared/errors'; +import { WizardError } from '@store/shared/wizard-abort'; +import { analytics } from '@store/shared/analytics'; +import { logToFile } from '@store/shared/debug'; +import { checkLlmGatewayHealth } from '@store/health-checks/endpoints'; +import { ServiceHealthStatus } from '@store/health-checks/types'; + +vi.mock('@store/health-checks/endpoints', () => ({ checkLlmGatewayHealth: vi.fn(), })); -vi.mock('@utils/analytics', () => ({ +vi.mock('@store/shared/analytics', () => ({ analytics: { wizardCapture: vi.fn(), captureException: vi.fn() }, })); -vi.mock('@utils/debug', () => ({ logToFile: vi.fn() })); +vi.mock('@store/shared/debug', () => ({ logToFile: vi.fn() })); // logToFile is variadic, so a leak in any argument is a leak. Rendered every way the // sink might: JSON (which invokes getters and toJSON), an Error's stack, and inspect. @@ -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('../gateway/gateway-session.js'); 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 cb6870e66..476b432ff 100644 --- a/src/lib/agent/__tests__/output-signals.test.ts +++ b/src/agent/__tests__/output-signals.test.ts @@ -1,5 +1,8 @@ -import { AgentOutputSignals } from '@lib/agent/output-signals'; -import { AgentSignals, REMARK_INSTRUCTION } from '@lib/agent-signals'; +import { AgentOutputSignals } from '../output-signals.js'; +import { + AgentSignals, + REMARK_INSTRUCTION, +} from '@store/agent-protocol/agent-signals'; describe('REMARK_INSTRUCTION', () => { it('carries the marker but no literal placeholder a model could echo', () => { 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..b7744359b 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-interface.js'; +import { CallType } from '@store/shared/constants'; describe('buildRunTags', () => { it('carries the run identifiers as gateway trace tags', () => { diff --git a/src/lib/agent/__tests__/stored-login.test.ts b/src/agent/__tests__/stored-login.test.ts similarity index 98% rename from src/lib/agent/__tests__/stored-login.test.ts rename to src/agent/__tests__/stored-login.test.ts index 6ef5b14e8..4494b39ee 100644 --- a/src/lib/agent/__tests__/stored-login.test.ts +++ b/src/agent/__tests__/stored-login.test.ts @@ -6,10 +6,10 @@ import { createIsolatedAgentConfigDir, detectStoredClaudeLogin, hasStoredClaudeLogin, -} from '../stored-login'; +} from '../stored-login.js'; vi.mock('node:child_process', () => ({ spawnSync: vi.fn() })); -vi.mock('@utils/analytics', () => ({ +vi.mock('@store/shared/analytics', () => ({ analytics: { wizardCapture: vi.fn(), captureException: vi.fn() }, })); 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..19e2aee1f 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 '../triage-provider.js'; import { CallType, GPT5_6_LUNA_MODEL, HAIKU_TRIAGE_MODEL, Harness, -} from '@lib/constants'; -import { triageModelFor } from '@lib/agent/runner/switchboard/models'; +} from '@store/shared/constants'; +import { triageModelFor } from '../runner/switchboard/models.js'; 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 92% rename from src/lib/agent/__tests__/tutorial-run-tags.test.ts rename to src/agent/__tests__/tutorial-run-tags.test.ts index e0d2c2b3f..07ffe5fdd 100644 --- a/src/lib/agent/__tests__/tutorial-run-tags.test.ts +++ b/src/agent/__tests__/tutorial-run-tags.test.ts @@ -7,9 +7,9 @@ * 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 { analytics } from '@utils/analytics'; +import { buildTutorialRunTags } from '../mcp-prompt-streaming.js'; +import { buildAgentEnv } from '../agent-interface.js'; +import { analytics } from '@store/shared/analytics'; describe('buildTutorialRunTags', () => { it('tags the run with the program its spend belongs to', () => { diff --git a/src/lib/agent/__tests__/variant-gating.test.ts b/src/agent/__tests__/variant-gating.test.ts similarity index 88% rename from src/lib/agent/__tests__/variant-gating.test.ts rename to src/agent/__tests__/variant-gating.test.ts index 1734e1446..13561aa74 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 '../runner/switchboard/index.js'; describe('isOrchestratorEnabled', () => { it('is true only when the wizard-orchestrator flag is true', () => { 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..9f23681fc 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-interface.js'; -vi.mock('../../utils/analytics', () => ({ +vi.mock('@store/shared/analytics', () => ({ analytics: { wizardCapture: vi.fn(), }, })); -vi.mock('../../utils/debug'); +vi.mock('@store/shared/debug'); describe('wizardCanUseTool — wizard_ask pending guard', () => { for (const tool of ['Write', 'Edit'] as const) { 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..a12e107d9 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 '../security/yara-hooks.js'; 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 '@store/shared/analytics'; // Mock dependencies -vi.mock('../../utils/debug'); -vi.mock('../../utils/analytics'); +vi.mock('@store/shared/debug'); +vi.mock('@store/shared/analytics'); vi.mock('fs'); vi.mock('fast-glob'); // Mock isSkillInstallCommand from skill-install (extracted to break circular dep) -vi.mock('../skill-install', () => ({ +vi.mock('@store/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 99% rename from src/lib/__tests__/yara-policy.test.ts rename to src/agent/__tests__/yara-policy.test.ts index 33b725f34..a7c42d0b1 100644 --- a/src/lib/__tests__/yara-policy.test.ts +++ b/src/agent/__tests__/yara-policy.test.ts @@ -4,7 +4,7 @@ import { isTerminalMatch, publishBlockingMatch, scanVerdict, -} from '../yara-policy'; +} from '../security/yara-policy.js'; function match( severity: string, diff --git a/src/lib/agent/agent-interface.ts b/src/agent/agent-interface.ts similarity index 97% rename from src/lib/agent/agent-interface.ts rename to src/agent/agent-interface.ts index cd41e82b4..ad9bbe7c7 100644 --- a/src/lib/agent/agent-interface.ts +++ b/src/agent/agent-interface.ts @@ -6,14 +6,19 @@ import path from 'path'; import * as os from 'os'; import { createRequire } from 'node:module'; -import { getUI, type SpinnerHandle } from '@ui'; -import type { TokenUsageDelta } from '@ui/wizard-ui'; -import { debug, logToFile, initLogFile, getLogFilePath } from '@utils/debug'; -import type { WizardRunOptions } from '@utils/types'; -import { analytics } from '@utils/analytics'; -import { isTemplateEnvFileName } from '@utils/env-scan'; +import { getUI, type SpinnerHandle } from '@store/ui'; +import type { TokenUsageDelta } from '@store/ui/wizard-ui'; +import { + debug, + logToFile, + initLogFile, + getLogFilePath, +} from '@store/shared/debug'; +import type { WizardRunOptions } from '@store/shared/types'; +import { analytics } from '@store/shared/analytics'; +import { isTemplateEnvFileName } from '@store/shared/env-scan'; import { runtimeEnv } from '@env'; -import type { AioCapture } from '@lib/agent/aio-capture'; +import type { AioCapture } from './aio-capture.js'; import { Harness, CallType, @@ -22,59 +27,62 @@ import { wizardUserAgentForProgram, DEFAULT_AGENT_MODEL, AWS_SKILLS_BASE_URL, -} from '@lib/constants'; +} from '@store/shared/constants'; import { type AdditionalFeature, ADDITIONAL_FEATURE_PROMPTS, -} from '@lib/wizard-session'; -import { wizardAbort, WizardError } from '@utils/wizard-abort'; -import { createCustomHeaders } from '@utils/custom-headers'; -import type { HostResolution } from '@lib/host-resolution'; +} from '@store/session/wizard-session'; +import { wizardAbort, WizardError } from '@store/shared/wizard-abort'; +import { createCustomHeaders } from '@store/shared/custom-headers'; +import type { HostResolution } from '@store/host-resolution'; import { buildWizardPropertiesBlob, gatewayAuth, isPastRefresh, type GatewayAuth, -} from '@lib/gateway-session'; -import { evaluateBashCommand } from './bash-fence'; -import { createWizardToolsServer, WIZARD_TOOL_NAMES } from '@lib/wizard-tools'; +} from './gateway/gateway-session.js'; +import { evaluateBashCommand } from './bash-fence.js'; +import { createWizardToolsServer, WIZARD_TOOL_NAMES } from '@store/tools'; import { createPreToolUseYaraHooks, createPostToolUseYaraHooks, prewarmYaraScanner, -} from '@lib/yara-hooks'; -import { createTriageLLMProvider } from './triage-provider'; +} from './security/yara-hooks.js'; +import { createTriageLLMProvider } from './triage-provider.js'; import type { LLMProvider } from '@posthog/warlock'; -import { assembleCommandments } from './runner/switchboard/commandments'; -import { classifyToolToStage } from './agent-phase'; -import type { PackageManagerDetector } from '@lib/detection/package-manager'; +import { assembleCommandments } from './runner/switchboard/commandments.js'; +import { classifyToolToStage } from './agent-phase.js'; +import type { PackageManagerDetector } from '@store/detection/package-manager'; import { AgentSignals, AgentErrorType, REMARK_INSTRUCTION, RESUME_INSTRUCTION, -} from '@lib/agent-signals'; -import { classifyAuthFailure } from '@lib/errors'; -import { isGrantRevoked } from '@lib/auth-session-state'; -import { AgentOutputSignals } from './output-signals'; +} from '@store/agent-protocol/agent-signals'; +import { classifyAuthFailure } from '@store/shared/errors'; +import { isGrantRevoked } from '@store/auth-session-state'; +import { AgentOutputSignals } from './output-signals.js'; // Signal vocabulary and the output parser live in dedicated modules; re-export // so existing importers of these from agent-interface keep working. -export { AgentSignals, AgentErrorType } from '@lib/agent-signals'; -export type { AgentSignal } from '@lib/agent-signals'; -export { AgentOutputSignals } from './output-signals'; +export { + AgentSignals, + AgentErrorType, +} from '@store/agent-protocol/agent-signals'; +export type { AgentSignal } from '@store/agent-protocol/agent-signals'; +export { AgentOutputSignals } from './output-signals.js'; import { checkAllSettingsConflicts, type SettingsConflict, type SettingsConflictSource, -} from '@lib/claude-settings'; +} from '@store/services/claude-settings'; import { detectStoredClaudeLogin, hasStoredClaudeLogin, claudeConfigDir, createIsolatedAgentConfigDir, -} from './stored-login'; -import { sanitizeAgentSubprocessEnv } from '@lib/agent-env-isolation'; +} from './stored-login.js'; +import { sanitizeAgentSubprocessEnv } from '@store/agent-protocol/agent-env-isolation'; // Dynamic import cache for ESM module let _sdkModule: any = null; @@ -217,7 +225,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('@store/session/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. */ @@ -229,14 +237,14 @@ export type AgentConfig = { * block Write/Edit while the overlay is open (defense in depth). */ getPendingQuestion?: () => - | import('@lib/wizard-session').PendingQuestion + | import('@store/session/wizard-session').PendingQuestion | null; /** * Orchestrator queue context. Present only when the `wizard-orchestrator` * 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('./runner/sequence/orchestrator/queue-tools.js').OrchestratorToolsContext; /** * Optional AIO capture — mirrors each assistant SDK message into the * authenticated project as `$ai_generation`. No-op instance when @@ -329,7 +337,7 @@ type AgentRunConfig = { * to block Write/Edit while the overlay is open. */ getPendingQuestion?: () => - | import('@lib/wizard-session').PendingQuestion + | import('@store/session/wizard-session').PendingQuestion | null; /** * The orchestrator owns the TUI task panel (it renders its queue), so its @@ -414,7 +422,7 @@ export function buildAgentEnv( } // Re-export for backwards compatibility — canonical source is skill-install.ts -export { isSkillInstallCommand } from '@lib/skill-install'; +export { isSkillInstallCommand } from '@store/skill-install'; /** * Permission hook that allows only safe commands. Bash commands are gated by diff --git a/src/lib/agent/agent-phase.ts b/src/agent/agent-phase.ts similarity index 100% rename from src/lib/agent/agent-phase.ts rename to src/agent/agent-phase.ts diff --git a/src/lib/agent/agent-prompt-loader.ts b/src/agent/agent-prompt-loader.ts similarity index 98% rename from src/lib/agent/agent-prompt-loader.ts rename to src/agent/agent-prompt-loader.ts index c69d8fc87..3abe4d2f1 100644 --- a/src/lib/agent/agent-prompt-loader.ts +++ b/src/agent/agent-prompt-loader.ts @@ -18,17 +18,17 @@ import type { QueueStore, QueuedTask, -} from './runner/sequence/orchestrator/queue'; -import type { ResolvedTask } from './runner/sequence/orchestrator/executor'; -import type { HostResolution } from '@lib/host-resolution'; +} from './runner/sequence/orchestrator/queue.js'; +import type { ResolvedTask } from './runner/sequence/orchestrator/executor.js'; +import type { HostResolution } from '@store/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'; +} from './runner/switchboard/models.js'; +import { logToFile } from '@store/shared/debug'; +import { analytics } from '@store/shared/analytics'; +import { fetchWithRetry } from '@store/fetch-retry'; +import { WIZARD_TOOL_NAMES } from '@store/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 95% rename from src/lib/agent/agent-prompt.ts rename to src/agent/agent-prompt.ts index 8e684322b..144eb587b 100644 --- a/src/lib/agent/agent-prompt.ts +++ b/src/agent/agent-prompt.ts @@ -7,7 +7,10 @@ * 3. Skill prompt — "follow SKILL.md" instructions (if a skill was installed) */ -import type { ProgramRun, PromptContext } from '@lib/program-run'; +import type { + ProgramRun, + PromptContext, +} from '@store/agent-protocol/program-run'; export type { PromptContext }; diff --git a/src/lib/agent/agent-runner.ts b/src/agent/agent-runner.ts similarity index 92% rename from src/lib/agent/agent-runner.ts rename to src/agent/agent-runner.ts index f8fd5a00b..156ff5d1e 100644 --- a/src/lib/agent/agent-runner.ts +++ b/src/agent/agent-runner.ts @@ -13,4 +13,4 @@ export { type AbortCase, type PromptContext, type Credentials, -} from './runner/index'; +} from './runner/index.js'; 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..8a2622e3c 100644 --- a/src/lib/agent/aio-capture.ts +++ b/src/agent/aio-capture.ts @@ -24,8 +24,8 @@ * the main agent flow. Losing an AIO event must never break a run. */ -import { logToFile } from '@utils/debug'; -import { VERSION } from '@lib/version'; +import { logToFile } from '@store/shared/debug'; +import { VERSION } from '@store/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..fe8addd11 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 '@store/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/gateway-session.ts similarity index 97% rename from src/lib/gateway-session.ts rename to src/agent/gateway/gateway-session.ts index 577753df2..d2cba0ab0 100644 --- a/src/lib/gateway-session.ts +++ b/src/agent/gateway/gateway-session.ts @@ -7,15 +7,15 @@ */ import { readFileSync } from 'node:fs'; -import { logToFile } from '@utils/debug'; -import { analytics } from '@utils/analytics'; -import { WizardError } from '@utils/wizard-abort'; -import { ErrorCodes } 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 { logToFile } from '@store/shared/debug'; +import { analytics } from '@store/shared/analytics'; +import { WizardError } from '@store/shared/wizard-abort'; +import { ErrorCodes } from '@store/shared/errors'; +import type { HostResolution } from '@store/host-resolution'; +import { checkLlmGatewayHealth } from '@store/health-checks/endpoints'; +import { ServiceHealthStatus } from '@store/health-checks/types'; import { IS_PRODUCTION_BUILD, runtimeEnv } from '@env'; -import type { CloudRegion } from '@utils/types'; +import type { CloudRegion } from '@store/shared/types'; export interface GatewayAuth { /** Base URL for model calls (no `/v1`; transports append their route). */ diff --git a/src/lib/agent/mcp-prompt-streaming.ts b/src/agent/mcp-prompt-streaming.ts similarity index 96% rename from src/lib/agent/mcp-prompt-streaming.ts rename to src/agent/mcp-prompt-streaming.ts index f0f6e87a9..e9ec8aa2d 100644 --- a/src/lib/agent/mcp-prompt-streaming.ts +++ b/src/agent/mcp-prompt-streaming.ts @@ -12,15 +12,18 @@ * `for await (...)` and render as they arrive. */ -import type { AgentChunk } from '@ui/tui/services/mcp-suggested-prompts-services'; -import type { Credentials } from '@lib/wizard-session'; -import { DEFAULT_AGENT_MODEL, WIZARD_USER_AGENT } from '@lib/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-env-isolation'; -import { createIsolatedAgentConfigDir } from '@lib/agent/stored-login'; -import { analytics } from '@utils/analytics'; +import type { AgentChunk } from '@tui/services/mcp-suggested-prompts-services'; +import type { Credentials } from '@store/session/wizard-session'; +import { + DEFAULT_AGENT_MODEL, + WIZARD_USER_AGENT, +} from '@store/shared/constants'; +import { logToFile } from '@store/shared/debug'; +import { gatewayAuth } from './gateway/gateway-session.js'; +import { buildAgentEnv, buildRunTags } from './agent-interface.js'; +import { sanitizeAgentSubprocessEnv } from '@store/agent-protocol/agent-env-isolation'; +import { createIsolatedAgentConfigDir } from './stored-login.js'; +import { analytics } from '@store/shared/analytics'; // Cached SDK module — first call pays the dynamic-import cost; later // calls reuse the same module. diff --git a/src/lib/middleware/benchmark.ts b/src/agent/middleware/benchmark.ts similarity index 83% rename from src/lib/middleware/benchmark.ts rename to src/agent/middleware/benchmark.ts index 20017ad75..97347a212 100644 --- a/src/lib/middleware/benchmark.ts +++ b/src/agent/middleware/benchmark.ts @@ -7,15 +7,19 @@ * pipeline.finalize(resultMessage, durationMs); */ -import { getUI, type SpinnerHandle } from '@ui'; -import { logToFile, getLogFilePath, configureLogFile } from '@utils/debug'; -import { MiddlewarePipeline } from './pipeline'; -import { PhaseDetector } from './phase-detector'; -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 { getUI, type SpinnerHandle } from '@store/ui'; +import { + logToFile, + getLogFilePath, + configureLogFile, +} from '@store/shared/debug'; +import { MiddlewarePipeline } from './pipeline.js'; +import { PhaseDetector } from './phase-detector.js'; +import { loadBenchmarkConfig } from './config.js'; +import { createPluginsFromConfig } from './benchmarks/index.js'; +import type { BenchmarkConfig } from './config.js'; +import type { WizardRunOptions } from '@store/shared/types'; +import { AgentSignals } from '../agent-interface.js'; // ── Types ────────────────────────────────────────────────────────────── diff --git a/src/lib/middleware/benchmarks/cache-tracker.ts b/src/agent/middleware/benchmarks/cache-tracker.ts similarity index 97% rename from src/lib/middleware/benchmarks/cache-tracker.ts rename to src/agent/middleware/benchmarks/cache-tracker.ts index 047efc3a8..b2744222a 100644 --- a/src/lib/middleware/benchmarks/cache-tracker.ts +++ b/src/agent/middleware/benchmarks/cache-tracker.ts @@ -8,8 +8,8 @@ import type { Middleware, MiddlewareContext, MiddlewareStore, -} from '@lib/middleware/types'; -import type { TurnData } from './turn-counter'; +} from '../types.js'; +import type { TurnData } from './turn-counter.js'; /** Matches SDK usage.cache_creation (ephemeral 5m vs 1h for pricing). */ export interface CacheCreationBreakdown { diff --git a/src/lib/middleware/benchmarks/compaction-tracker.ts b/src/agent/middleware/benchmarks/compaction-tracker.ts similarity index 94% rename from src/lib/middleware/benchmarks/compaction-tracker.ts rename to src/agent/middleware/benchmarks/compaction-tracker.ts index bb16fb6e5..f65ab00a4 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'; -import { logToFile } from '@utils/debug'; -import { AgentSignals } from '@lib/agent/agent-interface'; +} from '../types.js'; +import { logToFile } from '@store/shared/debug'; +import { AgentSignals } from '../../agent-interface.js'; 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 96% rename from src/lib/middleware/benchmarks/context-size-tracker.ts rename to src/agent/middleware/benchmarks/context-size-tracker.ts index f51f0f441..b4d1d99be 100644 --- a/src/lib/middleware/benchmarks/context-size-tracker.ts +++ b/src/agent/middleware/benchmarks/context-size-tracker.ts @@ -10,8 +10,8 @@ import type { Middleware, MiddlewareContext, MiddlewareStore, -} from '@lib/middleware/types'; -import type { TokenData } from './token-tracker'; +} from '../types.js'; +import type { TokenData } from './token-tracker.js'; export interface ContextSizeData { /** Per-phase context size snapshots */ diff --git a/src/lib/middleware/benchmarks/cost-tracker.ts b/src/agent/middleware/benchmarks/cost-tracker.ts similarity index 94% rename from src/lib/middleware/benchmarks/cost-tracker.ts rename to src/agent/middleware/benchmarks/cost-tracker.ts index b65b4f5a0..c5e5414ac 100644 --- a/src/lib/middleware/benchmarks/cost-tracker.ts +++ b/src/agent/middleware/benchmarks/cost-tracker.ts @@ -2,10 +2,10 @@ import type { Middleware, MiddlewareContext, MiddlewareStore, -} from '@lib/middleware/types'; -import { computeTokenCostUsd } from '@lib/token-pricing'; -import type { TokenData } from './token-tracker'; -import type { CacheData } from './cache-tracker'; +} from '../types.js'; +import { computeTokenCostUsd } from '@store/agent-protocol/token-pricing'; +import type { TokenData } from './token-tracker.js'; +import type { CacheData } from './cache-tracker.js'; export interface CostData { totalCost: number; 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..caad0fa50 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 '../types.js'; export interface DurationData { phaseSnapshots: Array<{ diff --git a/src/lib/middleware/benchmarks/index.ts b/src/agent/middleware/benchmarks/index.ts similarity index 74% rename from src/lib/middleware/benchmarks/index.ts rename to src/agent/middleware/benchmarks/index.ts index 470dbd82b..a7c93c5e4 100644 --- a/src/lib/middleware/benchmarks/index.ts +++ b/src/agent/middleware/benchmarks/index.ts @@ -5,20 +5,17 @@ * from a BenchmarkConfig. */ -import type { - Middleware, - MiddlewareFactoryOptions, -} from '@lib/middleware/types'; -import type { BenchmarkConfig } from '@lib/middleware/config'; -import { TurnCounterPlugin } from './turn-counter'; -import { TokenTrackerPlugin } from './token-tracker'; -import { CacheTrackerPlugin } from './cache-tracker'; -import { CompactionTrackerPlugin } from './compaction-tracker'; -import { ContextSizeTrackerPlugin } from './context-size-tracker'; -import { CostTrackerPlugin } from './cost-tracker'; -import { DurationTrackerPlugin } from './duration-tracker'; -import { SummaryPlugin } from './summary'; -import { JsonWriterPlugin } from './json-writer'; +import type { Middleware, MiddlewareFactoryOptions } from '../types.js'; +import type { BenchmarkConfig } from '../config.js'; +import { TurnCounterPlugin } from './turn-counter.js'; +import { TokenTrackerPlugin } from './token-tracker.js'; +import { CacheTrackerPlugin } from './cache-tracker.js'; +import { CompactionTrackerPlugin } from './compaction-tracker.js'; +import { ContextSizeTrackerPlugin } from './context-size-tracker.js'; +import { CostTrackerPlugin } from './cost-tracker.js'; +import { DurationTrackerPlugin } from './duration-tracker.js'; +import { SummaryPlugin } from './summary.js'; +import { JsonWriterPlugin } from './json-writer.js'; type PluginFactory = (opts: MiddlewareFactoryOptions) => Middleware; diff --git a/src/lib/middleware/benchmarks/json-writer.ts b/src/agent/middleware/benchmarks/json-writer.ts similarity index 89% rename from src/lib/middleware/benchmarks/json-writer.ts rename to src/agent/middleware/benchmarks/json-writer.ts index 253225335..09a4b067b 100644 --- a/src/lib/middleware/benchmarks/json-writer.ts +++ b/src/agent/middleware/benchmarks/json-writer.ts @@ -6,22 +6,22 @@ */ import fs from 'fs'; -import { getUI } from '@ui'; -import { logToFile } from '@utils/debug'; -import { AgentSignals } from '@lib/agent/agent-interface'; +import { getUI } from '@store/ui'; +import { logToFile } from '@store/shared/debug'; +import { AgentSignals } from '../../agent-interface.js'; import type { Middleware, MiddlewareContext, MiddlewareStore, -} from '@lib/middleware/types'; -import type { TokenData } from './token-tracker'; -import type { CacheData } from './cache-tracker'; -import type { TurnData } from './turn-counter'; -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'; +} from '../types.js'; +import type { TokenData } from './token-tracker.js'; +import type { CacheData } from './cache-tracker.js'; +import type { TurnData } from './turn-counter.js'; +import type { CostData } from './cost-tracker.js'; +import type { DurationData } from './duration-tracker.js'; +import type { CompactionData } from './compaction-tracker.js'; +import type { ContextSizeData } from './context-size-tracker.js'; +import type { BenchmarkData, StepUsage } from '../benchmark.js'; /** * 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 89% rename from src/lib/middleware/benchmarks/summary.ts rename to src/agent/middleware/benchmarks/summary.ts index 45c3b0a8e..50e2c4597 100644 --- a/src/lib/middleware/benchmarks/summary.ts +++ b/src/agent/middleware/benchmarks/summary.ts @@ -1,17 +1,17 @@ -import { getUI, type SpinnerHandle } from '@ui'; -import { AgentSignals } from '@lib/agent/agent-interface'; +import { getUI, type SpinnerHandle } from '@store/ui'; +import { AgentSignals } from '../../agent-interface.js'; import type { Middleware, MiddlewareContext, MiddlewareStore, -} from '@lib/middleware/types'; -import type { TokenData } from './token-tracker'; -import type { TurnData } from './turn-counter'; -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 { CacheData } from './cache-tracker'; +} from '../types.js'; +import type { TokenData } from './token-tracker.js'; +import type { TurnData } from './turn-counter.js'; +import type { CostData } from './cost-tracker.js'; +import type { DurationData } from './duration-tracker.js'; +import type { CompactionData } from './compaction-tracker.js'; +import type { ContextSizeData } from './context-size-tracker.js'; +import type { CacheData } from './cache-tracker.js'; function fmtDuration(ms: number): string { const s = Math.round(ms / 1000); diff --git a/src/lib/middleware/benchmarks/token-tracker.ts b/src/agent/middleware/benchmarks/token-tracker.ts similarity index 97% rename from src/lib/middleware/benchmarks/token-tracker.ts rename to src/agent/middleware/benchmarks/token-tracker.ts index e709bc75b..2546eda0b 100644 --- a/src/lib/middleware/benchmarks/token-tracker.ts +++ b/src/agent/middleware/benchmarks/token-tracker.ts @@ -11,8 +11,8 @@ import type { Middleware, MiddlewareContext, MiddlewareStore, -} from '@lib/middleware/types'; -import type { TurnData } from './turn-counter'; +} from '../types.js'; +import type { TurnData } from './turn-counter.js'; export interface TokenData { phaseInput: number; 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..2a1baa2d6 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 '../types.js'; 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 94% rename from src/lib/middleware/config.ts rename to src/agent/middleware/config.ts index 5d45af984..de990c92c 100644 --- a/src/lib/middleware/config.ts +++ b/src/agent/middleware/config.ts @@ -7,10 +7,10 @@ import fs from 'fs'; import path from 'path'; -import { logToFile } from '@utils/debug'; -import { AgentSignals } from '@lib/agent/agent-interface'; +import { logToFile } from '@store/shared/debug'; +import { AgentSignals } from '../agent-interface.js'; import { runtimeEnv } from '@env'; -import { WIZARD_BENCHMARK_FILE, WIZARD_LOG_FILE } from '@utils/paths'; +import { WIZARD_BENCHMARK_FILE, WIZARD_LOG_FILE } from '@store/shared/paths'; export interface BenchmarkConfig { /** Enable/disable individual metric plugins */ diff --git a/src/agent/middleware/index.ts b/src/agent/middleware/index.ts new file mode 100644 index 000000000..43876e882 --- /dev/null +++ b/src/agent/middleware/index.ts @@ -0,0 +1,19 @@ +/** + * Middleware system for wizard agent runs. + */ + +export { MiddlewarePipeline } from './pipeline.js'; +export { PhaseDetector } from './phase-detector.js'; +export type { + Middleware, + MiddlewareContext, + MiddlewareStore, +} from './types.js'; + +export { loadBenchmarkConfig, getDefaultConfig } from './config.js'; +export type { BenchmarkConfig } from './config.js'; + +export { createBenchmarkPipeline } from './benchmark.js'; +export type { BenchmarkData, StepUsage } from './benchmark.js'; + +export { createPluginsFromConfig } from './benchmarks/index.js'; 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 97% rename from src/lib/middleware/pipeline.ts rename to src/agent/middleware/pipeline.ts index d1316e9e7..71ce3159f 100644 --- a/src/lib/middleware/pipeline.ts +++ b/src/agent/middleware/pipeline.ts @@ -5,13 +5,13 @@ * while internally dispatching to an ordered list of middleware plugins. */ -import { PhaseDetector } from './phase-detector'; +import { PhaseDetector } from './phase-detector.js'; import type { Middleware, MiddlewareContext, MiddlewareStore, SDKMessage, -} from './types'; +} from './types.js'; export class MiddlewarePipeline { private middlewares: Middleware[]; diff --git a/src/lib/middleware/types.ts b/src/agent/middleware/types.ts similarity index 97% rename from src/lib/middleware/types.ts rename to src/agent/middleware/types.ts index ea1715700..8071eddbf 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 { SpinnerHandle } from '@ui'; +import type { SpinnerHandle } from '@store/ui'; export type SDKMessage = any; diff --git a/src/lib/agent/output-signals.ts b/src/agent/output-signals.ts similarity index 98% rename from src/lib/agent/output-signals.ts rename to src/agent/output-signals.ts index c8df7aed6..035b0de88 100644 --- a/src/lib/agent/output-signals.ts +++ b/src/agent/output-signals.ts @@ -12,7 +12,10 @@ * hooks' onTerminate callback (`yaraViolationReason` in runAgent) instead. */ -import { AgentSignals, REMARK_INSTRUCTION } from '@lib/agent-signals'; +import { + AgentSignals, + REMARK_INSTRUCTION, +} from '@store/agent-protocol/agent-signals'; /** * Single source of truth for the substrings runAgent scans agent output for. 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..e14bc92d4 100644 --- a/src/lib/agent/runner/__tests__/switchboard.test.ts +++ b/src/agent/runner/__tests__/switchboard.test.ts @@ -10,7 +10,7 @@ * asserted directly. */ import { describe, it, expect } from 'vitest'; -import { PROGRAM_REGISTRY } from '@lib/programs/program-registry'; +import { PROGRAM_REGISTRY } from '@store/programs/program-registry'; import { DEFAULT_AGENT_MODEL, GPT5_6_LUNA_MODEL, @@ -21,13 +21,13 @@ import { Harness, Sequence, WIZARD_ORCHESTRATOR_FLAG_KEY, -} from '@lib/constants'; +} from '@store/shared/constants'; import { PROGRAM_BINDINGS, DEFAULT_BINDING, resolveBinding, type SwitchboardCtx, -} from '@lib/agent/runner/switchboard'; +} from '../switchboard/index.js'; 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 '../switchboard/models.js'; +import { runBindingCases } from '../switchboard/flags/__tests__/binding-cases.js'; 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/index.ts b/src/agent/runner/harness/anthropic/index.ts similarity index 91% rename from src/lib/agent/runner/harness/anthropic/index.ts rename to src/agent/runner/harness/anthropic/index.ts index 4f5e449ec..065e13a6a 100644 --- a/src/lib/agent/runner/harness/anthropic/index.ts +++ b/src/agent/runner/harness/anthropic/index.ts @@ -1,21 +1,21 @@ // Supported legacy SDK fallback; both this adapter and Pi implement run and runTask. -import { getUI } from '@ui'; -import { Harness } from '@lib/constants'; +import { getUI } from '@store/ui'; +import { Harness } from '@store/shared/constants'; import { initializeAgent, runAgent as executeAgent, -} from '@lib/agent/agent-interface'; -import { createAioCapture } from '@lib/agent/aio-capture'; -import { getLogFilePath, logToFile } from '@utils/debug'; -import { detectNodePackageManagers } from '@lib/detection/package-manager'; -import { sessionToOptions } from '@lib/agent/runner/shared/bootstrap'; +} from '../../../agent-interface.js'; +import { createAioCapture } from '../../../aio-capture.js'; +import { getLogFilePath, logToFile } from '@store/shared/debug'; +import { detectNodePackageManagers } from '@store/detection/package-manager'; +import { sessionToOptions } from '../../shared/bootstrap.js'; import type { AgentResult, AgentHarness, BackendRunInputs, TaskRunInputs, -} from '../types'; +} from '../types.js'; export const anthropicBackend: AgentHarness = { name: Harness.anthropic, 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 93% rename from src/lib/agent/runner/harness/pi/__tests__/completion.test.ts rename to src/agent/runner/harness/pi/__tests__/completion.test.ts index 43eae2772..4d57bf33c 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 { completionFailure, runErrorType } from '../completion.js'; +import { AgentErrorType } from '@store/agent-protocol/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 96% 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 index 1034e0bca..751de8ef9 100644 --- a/src/lib/agent/runner/harness/pi/__tests__/env-lockdown.test.ts +++ b/src/agent/runner/harness/pi/__tests__/env-lockdown.test.ts @@ -4,7 +4,7 @@ * drops everything else — the leak that exposed the test key before. */ -import { buildScrubbedEnv } from '..'; +import { buildScrubbedEnv } from '../index.js'; describe('buildScrubbedEnv', () => { const saved = { ...process.env }; 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 98% 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..bfcfefb0a 100644 --- a/src/lib/agent/runner/harness/pi/__tests__/gateway.test.ts +++ b/src/agent/runner/harness/pi/__tests__/gateway.test.ts @@ -4,8 +4,8 @@ import { isGatewayAuthRejection, withGatewayRemint, GATEWAY_PROVIDER, -} from '../gateway'; -import type { GatewayAuth } from '@lib/gateway-session'; +} from '../gateway.js'; +import type { GatewayAuth } from '../../../../gateway/gateway-session.js'; 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 99% rename from src/lib/agent/runner/harness/pi/__tests__/security.test.ts rename to src/agent/runner/harness/pi/__tests__/security.test.ts index f73405721..915f6c28c 100644 --- a/src/lib/agent/runner/harness/pi/__tests__/security.test.ts +++ b/src/agent/runner/harness/pi/__tests__/security.test.ts @@ -10,10 +10,10 @@ import { overwriteShrinkReason, MAX_TOOL_CALLS, type PiExtensionApiLike, -} from '../security'; -import { analytics } from '@utils/analytics'; +} from '../security.js'; +import { analytics } from '@store/shared/analytics'; -vi.mock('@utils/analytics', () => ({ +vi.mock('@store/shared/analytics', () => ({ analytics: { wizardCapture: vi.fn() }, })); 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 92% 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 12309fff1..97338801d 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,8 +5,8 @@ */ import { describe, it, expect } from 'vitest'; -import { AgentSignals } from '@lib/agent-signals'; -import { lastStatusLine } from '..'; +import { AgentSignals } from '@store/agent-protocol/agent-signals'; +import { lastStatusLine } from '../index.js'; 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 99% 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 index f55a98995..e8c0b34a4 100644 --- a/src/lib/agent/runner/harness/pi/__tests__/task-tools.test.ts +++ b/src/agent/runner/harness/pi/__tests__/task-tools.test.ts @@ -9,7 +9,7 @@ import { allowedOrchestratorTools, allowedPiWizardTools, fenceDisallowList, -} from '../task'; +} from '../task.js'; describe('allowedPiWizardTools', () => { const always = ['check_env_keys', 'set_env_values', 'detect_package_manager']; 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 c3ef60dc1..d60432630 100644 --- a/src/lib/agent/runner/harness/pi/__tests__/tools.test.ts +++ b/src/agent/runner/harness/pi/__tests__/tools.test.ts @@ -12,10 +12,10 @@ import { describe, it, expect, vi } from 'vitest'; import { CANCELLED_SENTINEL, type WizardAskBridge, -} from '@lib/wizard-ask-bridge'; -import { createWizardPiTools } from '../tools'; -import { evaluateToolCall } from '../security'; -import { allowedPiCodingTools, allowedOrchestratorTools } from '../task'; +} from '@store/session/wizard-ask-bridge'; +import { createWizardPiTools } from '../tools.js'; +import { evaluateToolCall } from '../security.js'; +import { allowedPiCodingTools, allowedOrchestratorTools } from '../task.js'; import { ASK_BATCH_THRESHOLD, ASK_CANCELLED_NOTE, @@ -24,7 +24,7 @@ import { WIZARD_ASK_SENSITIVE_DESCRIPTION, WIZARD_ASK_SUBJECT_DESCRIPTION, WIZARD_ASK_TOOL_DESCRIPTION, -} from '@lib/wizard-tools/tools'; +} from '@store/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 94% rename from src/lib/agent/runner/harness/pi/completion.ts rename to src/agent/runner/harness/pi/completion.ts index a4fed8aa4..f5bb8eaff 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 '@store/agent-protocol/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 98% rename from src/lib/agent/runner/harness/pi/gateway.ts rename to src/agent/runner/harness/pi/gateway.ts index c827bcfcb..25b0fc6bb 100644 --- a/src/lib/agent/runner/harness/pi/gateway.ts +++ b/src/agent/runner/harness/pi/gateway.ts @@ -10,11 +10,11 @@ import { buildWizardPropertiesBlob, isPastRefresh, type GatewayAuth, -} from '@lib/gateway-session'; +} from '../../../gateway/gateway-session.js'; import { modelCapabilities, type ThinkingLevel, -} from '../../switchboard/models'; +} from '../../switchboard/models.js'; /** Provider registered on the in-memory registry for this run. */ export const GATEWAY_PROVIDER = 'posthog-gateway'; diff --git a/src/lib/agent/runner/harness/pi/index.ts b/src/agent/runner/harness/pi/index.ts similarity index 96% rename from src/lib/agent/runner/harness/pi/index.ts rename to src/agent/runner/harness/pi/index.ts index 8c6badb5b..892882b8a 100644 --- a/src/lib/agent/runner/harness/pi/index.ts +++ b/src/agent/runner/harness/pi/index.ts @@ -14,35 +14,41 @@ import fs from 'fs'; import path from 'path'; -import { getUI } from '@ui'; -import { getLogFilePath, logToFile } from '@utils/debug'; +import { getUI } from '@store/ui'; +import { getLogFilePath, logToFile } from '@store/shared/debug'; import { Harness, Sequence, WIZARD_REMARK_EVENT_NAME, WIZARD_USER_AGENT, -} from '@lib/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 { assembleCommandments } from '../../switchboard/commandments'; -import { gatewayAuth, type GatewayAuth } from '@lib/gateway-session'; +} from '@store/shared/constants'; +import { analytics } from '@store/shared/analytics'; +import { AgentErrorType } from '../../../agent-interface.js'; +import { + AgentSignals, + REMARK_INSTRUCTION, +} from '@store/agent-protocol/agent-signals'; +import { AgentOutputSignals } from '../../../output-signals.js'; +import { assembleCommandments } from '../../switchboard/commandments.js'; +import { + gatewayAuth, + type GatewayAuth, +} from '../../../gateway/gateway-session.js'; import { buildGatewayProvider, GATEWAY_PROVIDER, withGatewayRemint, -} from './gateway'; -import { createAioCapture } from '@lib/agent/aio-capture'; +} from './gateway.js'; +import { createAioCapture } from '../../../aio-capture.js'; import type { AgentResult, AgentHarness, BackendRunInputs, TaskRunInputs, -} from '../types'; -import type { BootstrapResult } from '@lib/agent/runner/shared/types'; -import type { TaskStore } from './tasks'; -import { completionFailure, runErrorType } from './completion'; +} from '../types.js'; +import type { BootstrapResult } from '../../shared/types.js'; +import type { TaskStore } from './tasks.js'; +import { completionFailure, runErrorType } from './completion.js'; /** Injects the MCP server `instructions` pi-mcp-adapter drops (project env, skill steer, tool domains) into the system prompt, falling back to a bootstrap-derived project block when the warm-connect captured none. */ function piMcpContext( @@ -304,7 +310,7 @@ export const piBackend: AgentHarness = { // flips it; the security gate reads it to block Write/Edit meanwhile. const askState = { pending: false }; - const { createSecurityExtension } = await import('./security'); + const { createSecurityExtension } = await import('./security.js'); const security = createSecurityExtension({ disallowedTools: programConfig.disallowedTools, getWizardAskPending: () => askState.pending, @@ -315,7 +321,9 @@ 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( + '../../../security/yara-hooks.js' + ); void prewarmYaraScanner(); // Wire the real PostHog MCP into pi (#10): load pi's MCP adapter and point @@ -334,7 +342,7 @@ export const piBackend: AgentHarness = { // failed handshake never registered. `task.ts` has always done this. let posthogMcp = false; try { - const { setupPostHogMcp, fetchInstructions } = await import('./mcp'); + const { setupPostHogMcp, fetchInstructions } = await import('./mcp.js'); // Overlaps the network handshake with the adapter's jiti load. const instructionsPromise = fetchInstructions( boot.credentials.host.mcpUrl, @@ -386,9 +394,9 @@ export const piBackend: AgentHarness = { // the code changes. Loaded lazily — it pulls in typebox (ESM), which must // stay out of the static module graph so CommonJS unit tests can load the // backend seam without parsing it. - const { createWizardPiTools } = await import('./tools'); - const { createWizardPiTaskTools } = await import('./tasks'); - const { createDispatchAgentTool } = await import('./subagent'); + const { createWizardPiTools } = await import('./tools.js'); + const { createWizardPiTaskTools } = await import('./tasks.js'); + const { createDispatchAgentTool } = await import('./subagent.js'); // Created once so the run loop can read the store for the completion guard. const wizardTaskTools = createWizardPiTaskTools(); // The one bash the agent (and its subagents) may use: every subprocess it @@ -680,7 +688,7 @@ export const piBackend: AgentHarness = { // task.ts pulls in typebox (ESM), which must stay out of the static module // graph so CommonJS unit tests can load the backend seam without parsing it. async runTask(inputs: TaskRunInputs): Promise { - const { runPiTask } = await import('./task'); + const { runPiTask } = await import('./task.js'); return runPiTask(inputs); }, }; diff --git a/src/lib/agent/runner/harness/pi/mcp.ts b/src/agent/runner/harness/pi/mcp.ts similarity index 97% rename from src/lib/agent/runner/harness/pi/mcp.ts rename to src/agent/runner/harness/pi/mcp.ts index eeaa3607a..99ec5eace 100644 --- a/src/lib/agent/runner/harness/pi/mcp.ts +++ b/src/agent/runner/harness/pi/mcp.ts @@ -7,8 +7,8 @@ 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 { logToFile } from '@utils/debug'; +import { VERSION } from '@store/shared/version'; +import { logToFile } from '@store/shared/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 98% rename from src/lib/agent/runner/harness/pi/orchestrator-tools.ts rename to src/agent/runner/harness/pi/orchestrator-tools.ts index 83ebbadc3..74721b249 100644 --- a/src/lib/agent/runner/harness/pi/orchestrator-tools.ts +++ b/src/agent/runner/harness/pi/orchestrator-tools.ts @@ -13,7 +13,7 @@ import { Type } from 'typebox'; import { defineTool } from '@earendil-works/pi-coding-agent'; import type { ToolDefinition } from '@earendil-works/pi-coding-agent'; -import { analytics } from '@utils/analytics'; +import { analytics } from '@store/shared/analytics'; import { applyComplete, applyEnqueue, @@ -26,8 +26,8 @@ import { type CompleteArgs, type EnqueueArgs, type OrchestratorToolsContext, -} from '../../sequence/orchestrator/queue-tools'; -import { NotNeededReason } from '../../sequence/orchestrator/queue'; +} from '../../sequence/orchestrator/queue-tools.js'; +import { NotNeededReason } from '../../sequence/orchestrator/queue.js'; function text(s: string): { content: [{ type: 'text'; text: string }]; 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 0d9dabfa3..288a47f8c 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 '@store/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 98% rename from src/lib/agent/runner/harness/pi/security.ts rename to src/agent/runner/harness/pi/security.ts index 0ff5c811c..876b76315 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-interface.js'; import { createRepeatBlockTracker, isWizardDocumentationPath, @@ -28,14 +28,14 @@ import { repeatBlockReason, scanAndTriage, type RepeatBlockTracker, -} from '@lib/yara-hooks'; +} from '../../../security/yara-hooks.js'; import { publishBlockingMatch, scanVerdict, type ScanContext, -} from '@lib/yara-policy'; -import { logToFile } from '@utils/debug'; -import { analytics } from '@utils/analytics'; +} from '../../../security/yara-policy.js'; +import { logToFile } from '@store/shared/debug'; +import { analytics } from '@store/shared/analytics'; /** warlock ScanMatch → the report shape `recordExternalScan` expects. */ function toReportViolation(m: ScanMatch) { diff --git a/src/lib/agent/runner/harness/pi/subagent.ts b/src/agent/runner/harness/pi/subagent.ts similarity index 99% rename from src/lib/agent/runner/harness/pi/subagent.ts rename to src/agent/runner/harness/pi/subagent.ts index 1f5e7f7d6..878256de8 100644 --- a/src/lib/agent/runner/harness/pi/subagent.ts +++ b/src/agent/runner/harness/pi/subagent.ts @@ -16,7 +16,7 @@ import { Type } from 'typebox'; import { defineTool } from '@earendil-works/pi-coding-agent'; import type { ToolDefinition } from '@earendil-works/pi-coding-agent'; -import { logToFile } from '@utils/debug'; +import { logToFile } from '@store/shared/debug'; /** * Read-only built-ins a subagent may use. bash is supplied separately as the diff --git a/src/lib/agent/runner/harness/pi/task.ts b/src/agent/runner/harness/pi/task.ts similarity index 94% rename from src/lib/agent/runner/harness/pi/task.ts rename to src/agent/runner/harness/pi/task.ts index 7c1acf79f..13a75d759 100644 --- a/src/lib/agent/runner/harness/pi/task.ts +++ b/src/agent/runner/harness/pi/task.ts @@ -16,42 +16,45 @@ * Loaded lazily from `index.ts` (typebox/ESM constraint, same as tools.ts). */ -import { getUI } from '@ui'; -import { logToFile } from '@utils/debug'; -import { analytics } from '@utils/analytics'; +import { getUI } from '@store/ui'; +import { logToFile } from '@store/shared/debug'; +import { analytics } from '@store/shared/analytics'; import { Harness, Sequence, WIZARD_REMARK_EVENT_NAME, WIZARD_USER_AGENT, -} from '@lib/constants'; +} from '@store/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'; -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'; +} from '../../../agent-prompt-loader.js'; +import { AgentErrorType } from '../../../agent-interface.js'; +import { REMARK_INSTRUCTION } from '@store/agent-protocol/agent-signals'; +import { AgentOutputSignals } from '../../../output-signals.js'; +import { TaskStatus } from '../../sequence/orchestrator/queue.js'; +import type { OrchestratorToolsContext } from '../../sequence/orchestrator/queue-tools.js'; +import type { AgentResult, TaskRunInputs } from '../types.js'; +import { + gatewayAuth, + type GatewayAuth, +} from '../../../gateway/gateway-session.js'; import { buildGatewayProvider, GATEWAY_PROVIDER, withGatewayRemint, -} from './gateway'; -import { runErrorType } from './completion'; -import { assembleCommandments } from '../../switchboard/commandments'; +} from './gateway.js'; +import { runErrorType } from './completion.js'; +import { assembleCommandments } from '../../switchboard/commandments.js'; import { applyOutroMarkers, buildScrubbedEnv, extractText, lastStatusLine, withMode, -} from './index'; -import { createAioCapture } from '@lib/agent/aio-capture'; +} from './index.js'; +import { createAioCapture } from '../../../aio-capture.js'; /** wizard tool vocabulary → the pi tool definitions it unlocks. */ const CODING_TOOL_MAP: Record = { @@ -276,13 +279,15 @@ export async function runPiTask(inputs: TaskRunInputs): Promise { // The same fail-closed fence as the linear run, with the task's disallow // list layered in (both the wizard-vocabulary and pi-short names). - const { createSecurityExtension } = await import('./security'); + const { createSecurityExtension } = await import('./security.js'); const security = createSecurityExtension({ disallowedTools: fenceDisallowList(disallowedTools), triageProvider: boot.triageProvider, getWizardAskPending: () => askState.pending, }); - const { prewarmYaraScanner } = await import('@lib/yara-hooks'); + const { prewarmYaraScanner } = await import( + '../../../security/yara-hooks.js' + ); void prewarmYaraScanner(); // PostHog MCP, for the tasks whose prompt requests it. Tasks that never @@ -294,7 +299,7 @@ export async function runPiTask(inputs: TaskRunInputs): Promise { let posthogMcp = false; if (allowsPostHogMcp(allowedTools)) { try { - const { setupPostHogMcp } = await import('./mcp'); + const { setupPostHogMcp } = await import('./mcp.js'); const mcp = await setupPostHogMcp({ mcpUrl: boot.credentials.host.mcpUrl, accessToken: boot.credentials.accessToken, @@ -362,7 +367,7 @@ export async function runPiTask(inputs: TaskRunInputs): Promise { // Wizard env + package-manager tools are always on — their handlers are // fenced, and init/build tasks depend on them. publish_handoff rides // along (store-only handler) so the report task can publish the handoff. - const { createWizardPiTools } = await import('./tools'); + const { createWizardPiTools } = await import('./tools.js'); const wizardToolNames = allowedPiWizardTools(allowedTools); const wizardTools = createWizardPiTools({ workingDirectory: dir, @@ -377,7 +382,9 @@ export async function runPiTask(inputs: TaskRunInputs): Promise { }, }).filter((t) => wizardToolNames.has(t.name)); - const { createPiOrchestratorTools } = await import('./orchestrator-tools'); + const { createPiOrchestratorTools } = await import( + './orchestrator-tools.js' + ); const queueTools = createPiOrchestratorTools(orchestrator).filter((t) => orchestratorTools.has(t.name), ); diff --git a/src/lib/agent/runner/harness/pi/tasks.ts b/src/agent/runner/harness/pi/tasks.ts similarity index 99% rename from src/lib/agent/runner/harness/pi/tasks.ts rename to src/agent/runner/harness/pi/tasks.ts index e12f66e1e..5bc0e6cca 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 { getUI } from '@ui'; +import { getUI } from '@store/ui'; 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 97% rename from src/lib/agent/runner/harness/pi/tools.ts rename to src/agent/runner/harness/pi/tools.ts index b194cc79a..74161f704 100644 --- a/src/lib/agent/runner/harness/pi/tools.ts +++ b/src/agent/runner/harness/pi/tools.ts @@ -16,8 +16,8 @@ import path from 'path'; import { Type } from 'typebox'; import { defineTool } from '@earendil-works/pi-coding-agent'; import type { ToolDefinition } from '@earendil-works/pi-coding-agent'; -import { analytics } from '@utils/analytics'; -import { logToFile } from '@utils/debug'; +import { analytics } from '@store/shared/analytics'; +import { logToFile } from '@store/shared/debug'; import { AUDIT_ADD_CHECKS_DESCRIPTION, AUDIT_ADD_CHECKS_PARAM_DESCRIPTION, @@ -52,24 +52,27 @@ import { WIZARD_ASK_SENSITIVE_DESCRIPTION, WIZARD_ASK_SUBJECT_DESCRIPTION, WIZARD_ASK_TOOL_DESCRIPTION, -} from '@lib/wizard-tools/tools'; +} from '@store/tools/tools'; import type { LLMProvider } from '@posthog/warlock'; -import { isFullyCancelled, type WizardAskBridge } from '@lib/wizard-ask-bridge'; +import { + isFullyCancelled, + type WizardAskBridge, +} from '@store/session/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'; -import { AUDIT_CHECKS_FILE } from '@lib/programs/audit/types'; -import type { AuditCheck, AuditStatus } from '@lib/programs/audit/types'; -import { makeMutex } from '@utils/atomic-ledger'; -import { withMode } from './index'; +} from '@store/tools/handoff'; +import { createSecretVault } from '@store/session/secret-vault'; +import { AUDIT_CHECKS_FILE } from '@store/programs/audit/types'; +import type { AuditCheck, AuditStatus } from '@store/programs/audit/types'; +import { makeMutex } from '@store/shared/atomic-ledger'; +import { withMode } from './index.js'; import { detectNodePackageManagers, type PackageManagerDetector, -} from '@lib/detection/package-manager'; +} from '@store/detection/package-manager'; function text(s: string): { content: [{ type: 'text'; text: string }]; diff --git a/src/lib/agent/runner/harness/types.ts b/src/agent/runner/harness/types.ts similarity index 87% rename from src/lib/agent/runner/harness/types.ts rename to src/agent/runner/harness/types.ts index f5fa53099..6719bd1d9 100644 --- a/src/lib/agent/runner/harness/types.ts +++ b/src/agent/runner/harness/types.ts @@ -15,22 +15,16 @@ * rather than silently downgrading. */ -import type { WizardSession } from '@lib/wizard-session'; -import type { AdditionalFeature } from '@lib/wizard-session'; -import type { Harness } from '@lib/constants'; -import type { ProgramRunConfig } from '@lib/program-run'; -import type { SpinnerHandle } from '@ui'; -import type { WizardAskBridge } from '@lib/wizard-ask-bridge'; -import type { AgentErrorType } from '@lib/agent/agent-interface'; -import type { OrchestratorToolsContext } from '@lib/agent/runner/sequence/orchestrator/queue-tools'; -import type { - EffortLevel, - ThinkingLevel, -} from '@lib/agent/runner/switchboard/models'; -import type { - ProgramRun, - BootstrapResult, -} from '@lib/agent/runner/shared/types'; +import type { WizardSession } from '@store/session/wizard-session'; +import type { AdditionalFeature } from '@store/session/wizard-session'; +import type { Harness } from '@store/shared/constants'; +import type { ProgramRunConfig } from '@store/agent-protocol/program-run'; +import type { SpinnerHandle } from '@store/ui'; +import type { WizardAskBridge } from '@store/session/wizard-ask-bridge'; +import type { AgentErrorType } from '../../agent-interface.js'; +import type { OrchestratorToolsContext } from '../sequence/orchestrator/queue-tools.js'; +import type { EffortLevel, ThinkingLevel } from '../switchboard/models.js'; +import type { ProgramRun, BootstrapResult } from '../shared/types.js'; /** 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 90% rename from src/lib/agent/runner/index.ts rename to src/agent/runner/index.ts index f9ee5f3f8..bcfe20d6c 100644 --- a/src/lib/agent/runner/index.ts +++ b/src/agent/runner/index.ts @@ -16,27 +16,27 @@ * [skill install] → agent init → prompt → run → errors → [postRun] → outro */ -import type { WizardSession } from '../../wizard-session'; -import { analytics } from '@utils/analytics'; +import type { WizardSession } from '@store/session/wizard-session'; +import { analytics } from '@store/shared/analytics'; import { Sequence, WIZARD_ORCHESTRATOR_FLAG_KEY, WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY, -} from '@lib/constants'; -import { logToFile } from '@utils/debug'; -import { getUI } from '../../../ui'; -import type { ProgramRunConfig } from '@lib/program-run'; -import type { ProgramRun, BootstrapResult } from './shared/types'; -import { bootstrapProgram } from './shared/bootstrap'; +} from '@store/shared/constants'; +import { logToFile } from '@store/shared/debug'; +import { getUI } from '@store/ui'; +import type { ProgramRunConfig } from '@store/agent-protocol/program-run'; +import type { ProgramRun, BootstrapResult } from './shared/types.js'; +import { bootstrapProgram } from './shared/bootstrap.js'; import { getSequence, resolveBinding, type ProgramBinding, type SwitchboardCtx, -} from './switchboard'; -import { flushScanReport } from '../../yara-hooks'; -import { startAuditLedgerWatcher } from '../../programs/audit/ledger-watcher'; -import { registerCleanup } from '../../../utils/wizard-abort'; +} from './switchboard/index.js'; +import { flushScanReport } from '../security/yara-hooks.js'; +import { startAuditLedgerWatcher } from '@store/programs/audit/ledger-watcher'; +import { registerCleanup } from '@store/shared/wizard-abort'; export type { ProgramRun, @@ -45,8 +45,8 @@ export type { AbortCase, PromptContext, Credentials, -} from './shared/types'; -export { shouldDisableAsk } from './shared/bootstrap'; +} from './shared/types.js'; +export { shouldDisableAsk } from './shared/bootstrap.js'; /** * Resolve a ProgramRunConfig's agent run definition and execute the pipeline. 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 91% rename from src/lib/agent/runner/sequence/linear.ts rename to src/agent/runner/sequence/linear.ts index e7654ac62..fc18df5cf 100644 --- a/src/lib/agent/runner/sequence/linear.ts +++ b/src/agent/runner/sequence/linear.ts @@ -5,33 +5,33 @@ * program-level static metadata (tool allow/disallow lists, etc.). */ -import type { WizardSession } from '../../../wizard-session'; -import { OutroKind } from '../../../wizard-session'; -import { getUI } from '../../../../ui'; -import { AgentErrorType, AgentSignals } from '../../agent-interface'; -import { restoreClaudeSettings } from '@lib/claude-settings'; -import { logToFile } from '../../../../utils/debug'; -import { createBenchmarkPipeline } from '../../../middleware/benchmark'; +import type { WizardSession } from '@store/session/wizard-session'; +import { OutroKind } from '@store/session/wizard-session'; +import { getUI } from '@store/ui'; +import { AgentErrorType, AgentSignals } from '../../agent-interface.js'; +import { restoreClaudeSettings } from '@store/services/claude-settings'; +import { logToFile } from '@store/shared/debug'; +import { createBenchmarkPipeline } from '../../middleware/benchmark.js'; import { wizardAbort, WizardError, registerCleanup, -} from '../../../../utils/wizard-abort'; -import { ErrorCodes, AGENT_ERROR_CODE } from '@lib/errors'; -import { analytics } from '../../../../utils/analytics'; +} from '@store/shared/wizard-abort'; +import { ErrorCodes, AGENT_ERROR_CODE } from '@store/shared/errors'; +import { analytics } from '@store/shared/analytics'; import { formatScanReport, formatYaraAbortMessage, writeScanReport, -} from '../../../yara-hooks'; -import { installSkillById } from '../../../wizard-tools'; -import { createWizardAskBridge } from '../../../wizard-ask-bridge'; -import type { ProgramRunConfig } from '@lib/program-run'; -import { assemblePrompt } from '../../agent-prompt'; -import type { ProgramRun, BootstrapResult } from '../shared/types'; -import { abortOnInstallFailure } from '../shared/errors'; -import { shouldDisableAsk, sessionToOptions } from '../shared/bootstrap'; -import { resolveHarness, getHarness } from '../switchboard'; +} from '../../security/yara-hooks.js'; +import { installSkillById } from '@store/tools'; +import { createWizardAskBridge } from '@store/session/wizard-ask-bridge'; +import type { ProgramRunConfig } from '@store/agent-protocol/program-run'; +import { assemblePrompt } from '../../agent-prompt.js'; +import type { ProgramRun, BootstrapResult } from '../shared/types.js'; +import { abortOnInstallFailure } from '../shared/errors.js'; +import { shouldDisableAsk, sessionToOptions } from '../shared/bootstrap.js'; +import { resolveHarness, getHarness } from '../switchboard/index.js'; export async function runLinearProgram( session: WizardSession, 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 90% 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..074e31483 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 @@ -9,15 +9,12 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -vi.mock('@utils/analytics', () => ({ +vi.mock('@store/shared/analytics', () => ({ analytics: { wizardCapture: vi.fn(), captureException: vi.fn() }, })); -import { - QueueStore, - SkipReason, -} from '@lib/agent/runner/sequence/orchestrator/queue'; -import { completedSeededTypes } from '@lib/agent/runner/sequence/orchestrator/orchestrator-runner'; +import { QueueStore, SkipReason } from '../queue.js'; +import { completedSeededTypes } from '../orchestrator-runner.js'; describe('completedSeededTypes', () => { let dir: string; 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 97% rename from src/lib/agent/runner/sequence/orchestrator/__tests__/executor.test.ts rename to src/agent/runner/sequence/orchestrator/__tests__/executor.test.ts index f83794ad8..ea1183a59 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/executor.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/executor.test.ts @@ -6,16 +6,13 @@ import { TaskStatus, type QueuedTask, type TaskHandoff, -} from '@lib/agent/runner/sequence/orchestrator/queue'; -import { - drainQueue, - type RunTask, -} from '@lib/agent/runner/sequence/orchestrator/executor'; +} from '../queue.js'; +import { drainQueue, type RunTask } from '../executor.js'; -vi.mock('@utils/analytics', () => ({ +vi.mock('@store/shared/analytics', () => ({ analytics: { captureException: vi.fn(), wizardCapture: vi.fn() }, })); -import { analytics } from '@utils/analytics'; +import { analytics } from '@store/shared/analytics'; const HANDOFF: TaskHandoff = { goals: 'g', did: 'd', forNextAgent: 'n' }; 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 96% 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 index 62b147804..5e0ad62e2 100644 --- 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 @@ -10,11 +10,11 @@ import { HANDOFF_FIELDS, HANDOFF_SHAPE_KEYS, type OrchestratorToolsContext, -} from '../queue-tools'; +} from '../queue-tools.js'; import { createPiOrchestratorTools, PI_HANDOFF_PARAM_KEYS, -} from '../../../harness/pi/orchestrator-tools'; +} from '../../../harness/pi/orchestrator-tools.js'; describe('complete_task handoff schema', () => { it('exposes the same fields on both harnesses', () => { 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 88% 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 85e130bce..8073e5db3 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/optional-tasks.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/optional-tasks.test.ts @@ -3,12 +3,12 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -vi.mock('@utils/analytics', () => ({ +vi.mock('@store/shared/analytics', () => ({ analytics: { wizardCapture: vi.fn(), captureException: vi.fn() }, })); -import { QueueStore } from '@lib/agent/runner/sequence/orchestrator/queue'; -import { drainVerdict } from '@lib/agent/runner/sequence/orchestrator/orchestrator-runner'; +import { QueueStore } from '../queue.js'; +import { drainVerdict } from '../orchestrator-runner.js'; 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 96% 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 3ee223d9e..531acef6b 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/queue-tools.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/queue-tools.test.ts @@ -2,14 +2,10 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; import { z } from 'zod'; -import { analytics } from '@utils/analytics'; -import { - NotNeededReason, - QueueStore, - SkipReason, -} from '@lib/agent/runner/sequence/orchestrator/queue'; +import { analytics } from '@store/shared/analytics'; +import { NotNeededReason, QueueStore, SkipReason } from '../queue.js'; -vi.mock('@utils/analytics', () => ({ +vi.mock('@store/shared/analytics', () => ({ analytics: { wizardCapture: vi.fn() }, })); import { @@ -22,12 +18,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 '../queue-tools.js'; +import { PI_COMPLETE_PARAM_KEYS } from '../../../harness/pi/orchestrator-tools.js'; +import { isValidModel, VALID_MODELS } from '../../../switchboard/models.js'; 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..2fc5c0692 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/queue.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/queue.test.ts @@ -11,9 +11,9 @@ import { type QueuedTask, type TaskHandoff, type TransitionEvent, -} from '@lib/agent/runner/sequence/orchestrator/queue'; +} from '../queue.js'; -vi.mock('@utils/analytics', () => ({ +vi.mock('@store/shared/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..7579a71e4 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 '../run-metrics.js'; 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 94% 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 d2379b32c..70731f199 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 @@ -10,10 +10,10 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -vi.mock('@ui', () => ({ +vi.mock('@store/ui', () => ({ getUI: () => ({ showTaskNotice: vi.fn(), cancelTaskNotice: vi.fn() }), })); -vi.mock('@utils/analytics', () => ({ +vi.mock('@store/shared/analytics', () => ({ analytics: { wizardCapture: vi.fn(), setTag: vi.fn(), @@ -25,14 +25,14 @@ vi.mock('@utils/analytics', () => ({ import { skipDeclinedSeededTasks, type SeededConsent, -} from '@lib/agent/runner/sequence/orchestrator/orchestrator-runner'; +} from '../orchestrator-runner.js'; import { QueueStore, SkipReason, TaskStatus, type TransitionEvent, type QueuedTask, -} from '@lib/agent/runner/sequence/orchestrator/queue'; +} from '../queue.js'; 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 98% 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..a3151612b 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/seeded-deps.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/seeded-deps.test.ts @@ -10,18 +10,12 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -vi.mock('@utils/analytics', () => ({ +vi.mock('@store/shared/analytics', () => ({ analytics: { wizardCapture: vi.fn(), captureException: vi.fn() }, })); -import { - QueueStore, - type QueuedTask, -} from '@lib/agent/runner/sequence/orchestrator/queue'; -import { - deferSeededTasks, - seededDependencies, -} from '@lib/agent/runner/sequence/orchestrator/seeded-deps'; +import { QueueStore, type QueuedTask } from '../queue.js'; +import { deferSeededTasks, seededDependencies } from '../seeded-deps.js'; 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 97% 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..e17c3b558 100644 --- a/src/lib/agent/runner/sequence/orchestrator/__tests__/sink-closure.test.ts +++ b/src/agent/runner/sequence/orchestrator/__tests__/sink-closure.test.ts @@ -7,23 +7,20 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -vi.mock('@utils/analytics', () => ({ +vi.mock('@store/shared/analytics', () => ({ analytics: { wizardCapture: vi.fn() }, })); -import { - QueueStore, - SkipReason, -} from '@lib/agent/runner/sequence/orchestrator/queue'; -import { displayOrder } from '@lib/agent/runner/sequence/orchestrator/orchestrator-runner'; +import { QueueStore, SkipReason } from '../queue.js'; +import { displayOrder } from '../orchestrator-runner.js'; 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 '../queue-tools.js'; +import { seededDependencies } from '../seeded-deps.js'; 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..883c2cd85 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 '../orchestrator-runner.js'; 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 98% 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 c6acf1014..85383b089 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 @@ -7,7 +7,7 @@ * the run — so the offer is made at seed time, and only the work it gates is * deferred to the end of the queue. */ -import type { TaskNotice } from '@lib/wizard-session'; +import type { TaskNotice } from '@store/session/wizard-session'; // Hoisted: `vi.mock` factories are lifted above the imports, so the analytics // factory would otherwise read these before they exist. @@ -19,10 +19,10 @@ const { showTaskNotice, cancelTaskNotice, wizardCapture, captureException } = captureException: vi.fn(), })); -vi.mock('@ui', () => ({ +vi.mock('@store/ui', () => ({ getUI: () => ({ showTaskNotice, cancelTaskNotice }), })); -vi.mock('@utils/analytics', () => ({ +vi.mock('@store/shared/analytics', () => ({ analytics: { wizardCapture, setTag: vi.fn(), @@ -36,7 +36,7 @@ import { consentSkipReason, offerSeededTask, TASK_NOTICE_TIMEOUT_MS, -} from '@lib/agent/runner/sequence/orchestrator/orchestrator-runner'; +} from '../orchestrator-runner.js'; const NOTICE: TaskNotice = { title: 'Connect your data sources', 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 97% 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..b3ead9dcf 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 { resolveSkillVariantId } from '../orchestrator-runner.js'; +import { Integration } from '@store/shared/constants'; +import { expandBundleEntry } from '@store/tools'; +import type { SkillEntry } from '@store/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 97% rename from src/lib/agent/runner/sequence/orchestrator/executor.ts rename to src/agent/runner/sequence/orchestrator/executor.ts index 616d29442..28b017934 100644 --- a/src/lib/agent/runner/sequence/orchestrator/executor.ts +++ b/src/agent/runner/sequence/orchestrator/executor.ts @@ -9,9 +9,9 @@ * The drain loop is independent of how a task actually runs. `runTask` is * injected: the real one spins up a fresh agent, the tests use a fake. */ -import { analytics } from '@utils/analytics'; -import { logToFile } from '@utils/debug'; -import { TaskStatus, type QueueStore, type QueuedTask } from './queue'; +import { analytics } from '@store/shared/analytics'; +import { logToFile } from '@store/shared/debug'; +import { TaskStatus, type QueueStore, type QueuedTask } from './queue.js'; /** Per-task agent configuration the resolver produces from a task's type. * The model is resolved separately (per-harness profile), not here. */ diff --git a/src/lib/agent/runner/sequence/orchestrator/orchestrator-runner.ts b/src/agent/runner/sequence/orchestrator/orchestrator-runner.ts similarity index 97% rename from src/lib/agent/runner/sequence/orchestrator/orchestrator-runner.ts rename to src/agent/runner/sequence/orchestrator/orchestrator-runner.ts index 0e981e2cd..f7e98d6c6 100644 --- a/src/lib/agent/runner/sequence/orchestrator/orchestrator-runner.ts +++ b/src/agent/runner/sequence/orchestrator/orchestrator-runner.ts @@ -24,52 +24,52 @@ import { OutroKind, type TaskNotice, type WizardSession, -} from '@lib/wizard-session'; +} from '@store/session/wizard-session'; import { POSTHOG_DOCS_URL, WIZARD_CONTACT_EMAIL, type Integration, -} from '@lib/constants'; -import { FRAMEWORK_REGISTRY } from '@lib/registry'; +} from '@store/shared/constants'; +import { FRAMEWORK_REGISTRY } from '@store/registry'; import { installSkillById, fetchSkillMenu, type SkillEntry, -} from '@lib/wizard-tools'; -import { getUI } from '@ui'; -import { analytics } from '@utils/analytics'; -import { ciExcludedTaskTypes } from '@utils/ci-flag-overrides'; -import { logToFile } from '@utils/debug'; -import { ringTerminalBell } from '@utils/terminal-bell'; -import { wizardAbort, WizardError } from '@utils/wizard-abort'; -import { ErrorCodes } from '@lib/errors'; -import type { ProgramRunConfig } from '@lib/program-run'; -import type { BootstrapResult, ProgramRun } from '../../shared/types'; +} from '@store/tools'; +import { getUI } from '@store/ui'; +import { analytics } from '@store/shared/analytics'; +import { ciExcludedTaskTypes } from '@store/shared/ci-flag-overrides'; +import { logToFile } from '@store/shared/debug'; +import { ringTerminalBell } from '@store/shared/terminal-bell'; +import { wizardAbort, WizardError } from '@store/shared/wizard-abort'; +import { ErrorCodes } from '@store/shared/errors'; +import type { ProgramRunConfig } from '@store/agent-protocol/program-run'; +import type { BootstrapResult, ProgramRun } from '../../shared/types.js'; import { areSeededTasksEnabled, getHarness, resolveHarness, resolveStageOverrides, type HarnessPick, -} from '../../switchboard'; -import { isValidModel, requireKnownModel } from '../../switchboard/models'; -import type { AgentHarness } from '../../harness/types'; +} from '../../switchboard/index.js'; +import { isValidModel, requireKnownModel } from '../../switchboard/models.js'; +import type { AgentHarness } from '../../harness/types.js'; import { QueueStore, QUEUE_DIR_NAME, SkipReason, TaskStatus, type QueuedTask, -} from './queue'; -import { drainQueue, type RunTask } from './executor'; -import { RunMetrics } from './run-metrics'; -import { dependencyClosure, uncoveredBySink } from './queue-tools'; -import { deferSeededTasks } from './seeded-deps'; +} from './queue.js'; +import { drainQueue, type RunTask } from './executor.js'; +import { RunMetrics } from './run-metrics.js'; +import { dependencyClosure, uncoveredBySink } from './queue-tools.js'; +import { deferSeededTasks } from './seeded-deps.js'; import { createWizardAskBridge, LONGER_ASK_TIMEOUT_MS, -} from '@lib/wizard-ask-bridge'; -import { shouldDisableAsk } from '../../shared/bootstrap'; +} from '@store/session/wizard-ask-bridge'; +import { shouldDisableAsk } from '../../shared/bootstrap.js'; import { agentRunTools, assembleSeedPrompt, @@ -81,7 +81,7 @@ import { ASK_TOOL, type AgentPrompt, type OrchestratorPromptContext, -} from '@lib/agent/agent-prompt-loader'; +} from '../../../agent-prompt-loader.js'; /** 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 2e2955823..647b99d7b 100644 --- a/src/lib/agent/runner/sequence/orchestrator/queue-tools.ts +++ b/src/agent/runner/sequence/orchestrator/queue-tools.ts @@ -7,11 +7,8 @@ * `buildOrchestratorTools` wraps them in the SDK `tool()` shape. */ import { z } from 'zod'; -import { analytics } from '@utils/analytics'; -import { - isValidModel, - VALID_MODELS, -} from '@lib/agent/runner/switchboard/models'; +import { analytics } from '@store/shared/analytics'; +import { isValidModel, VALID_MODELS } from '../../switchboard/models.js'; import { isNotNeededReason, NotNeededReason, @@ -20,7 +17,7 @@ import { type QueueStore, type QueuedTask, type TaskHandoff, -} from './queue'; +} from './queue.js'; /** * The `complete_task` `notNeededReason` description, shared by both harnesses' diff --git a/src/lib/agent/runner/sequence/orchestrator/queue.ts b/src/agent/runner/sequence/orchestrator/queue.ts similarity index 99% rename from src/lib/agent/runner/sequence/orchestrator/queue.ts rename to src/agent/runner/sequence/orchestrator/queue.ts index 5896ef07e..3541ee6ff 100644 --- a/src/lib/agent/runner/sequence/orchestrator/queue.ts +++ b/src/agent/runner/sequence/orchestrator/queue.ts @@ -14,8 +14,8 @@ import * as fs from 'fs'; import * as path from 'path'; import { randomUUID } from 'crypto'; -import { writeJsonAtomic } from '@utils/atomic-ledger'; -import { analytics } from '@utils/analytics'; +import { writeJsonAtomic } from '@store/shared/atomic-ledger'; +import { analytics } from '@store/shared/analytics'; export const TaskStatus = { Pending: 'pending', 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 97% rename from src/lib/agent/runner/sequence/orchestrator/seeded-deps.ts rename to src/agent/runner/sequence/orchestrator/seeded-deps.ts index 396c58083..216165ff2 100644 --- a/src/lib/agent/runner/sequence/orchestrator/seeded-deps.ts +++ b/src/agent/runner/sequence/orchestrator/seeded-deps.ts @@ -17,8 +17,8 @@ * Pure and store-reading only — the runner applies what this returns, and the * queue enforces the DAG. */ -import type { QueuedTask, QueueStore } from './queue'; -import { dependencyClosure } from './queue-tools'; +import type { QueuedTask, QueueStore } from './queue.js'; +import { dependencyClosure } from './queue-tools.js'; export interface SeededDepsResult { /** Ids the seeded task should be made to wait for. */ diff --git a/src/lib/agent/runner/shared/__tests__/refresh-access-token-if-needed.test.ts b/src/agent/runner/shared/__tests__/refresh-access-token-if-needed.test.ts similarity index 88% rename from src/lib/agent/runner/shared/__tests__/refresh-access-token-if-needed.test.ts rename to src/agent/runner/shared/__tests__/refresh-access-token-if-needed.test.ts index 5138af7cb..48d6d571e 100644 --- a/src/lib/agent/runner/shared/__tests__/refresh-access-token-if-needed.test.ts +++ b/src/agent/runner/shared/__tests__/refresh-access-token-if-needed.test.ts @@ -1,18 +1,21 @@ -import { refreshAccessTokenIfNeeded } from '../authenticate'; -import { refreshAccessToken } from '@utils/oauth'; -import { OAuthError } from '@utils/oauth-errors'; -import { isGrantRevoked, resetAuthSessionState } from '@lib/auth-session-state'; -import type { WizardSession, Credentials } from '@lib/wizard-session'; - -vi.mock('@utils/oauth', () => ({ refreshAccessToken: vi.fn() })); -vi.mock('@utils/debug', () => ({ logToFile: vi.fn() })); -vi.mock('@utils/analytics', () => ({ +import { refreshAccessTokenIfNeeded } from '../authenticate.js'; +import { refreshAccessToken } from '@store/shared/oauth'; +import { OAuthError } from '@store/shared/oauth-errors'; +import { + isGrantRevoked, + resetAuthSessionState, +} from '@store/auth-session-state'; +import type { WizardSession, Credentials } from '@store/session/wizard-session'; + +vi.mock('@store/shared/oauth', () => ({ refreshAccessToken: vi.fn() })); +vi.mock('@store/shared/debug', () => ({ logToFile: vi.fn() })); +vi.mock('@store/shared/analytics', () => ({ analytics: { wizardCapture: vi.fn() }, groupsFromUser: vi.fn(), })); const setAccessToken = vi.fn(); -vi.mock('@ui', () => ({ +vi.mock('@store/ui', () => ({ getUI: () => ({ setAccessToken }), })); diff --git a/src/lib/agent/runner/shared/authenticate.ts b/src/agent/runner/shared/authenticate.ts similarity index 88% rename from src/lib/agent/runner/shared/authenticate.ts rename to src/agent/runner/shared/authenticate.ts index 8644a328c..8a0fe9663 100644 --- a/src/lib/agent/runner/shared/authenticate.ts +++ b/src/agent/runner/shared/authenticate.ts @@ -10,15 +10,15 @@ * back rather than fetching again. */ -import type { Credentials, WizardSession } from '@lib/wizard-session'; -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 { analytics, groupsFromUser } from '@utils/analytics'; -import { getUI } from '@ui'; -import { logToFile } from '@utils/debug'; +import type { Credentials, WizardSession } from '@store/session/wizard-session'; +import type { ProgramId } from '@store/programs/program-registry'; +import { getOrAskForProjectData } from '@store/shared/setup-utils'; +import { refreshAccessToken } from '@store/shared/oauth'; +import { OAuthError } from '@store/shared/oauth-errors'; +import { markGrantRevoked } from '@store/auth-session-state'; +import { analytics, groupsFromUser } from '@store/shared/analytics'; +import { getUI } from '@store/ui'; +import { logToFile } from '@store/shared/debug'; export async function authenticate( session: WizardSession, diff --git a/src/lib/agent/runner/shared/bootstrap.ts b/src/agent/runner/shared/bootstrap.ts similarity index 90% rename from src/lib/agent/runner/shared/bootstrap.ts rename to src/agent/runner/shared/bootstrap.ts index 4924a61a1..cd234557c 100644 --- a/src/lib/agent/runner/shared/bootstrap.ts +++ b/src/agent/runner/shared/bootstrap.ts @@ -7,40 +7,40 @@ * effects. Returns the values the arms still need. */ -import type { WizardSession } from '@lib/wizard-session'; -import { analytics } from '@utils/analytics'; -import { getUI } from '@ui'; -import { authenticate, refreshAccessTokenIfNeeded } from './authenticate'; -import { maybeStampAiSdkDetected } from '@lib/programs/posthog-integration/detect'; -import { createTriageLLMProvider } from '@lib/agent/triage-provider'; -import { gatewayAuth } from '@lib/gateway-session'; -import { resolveHarness } from '../switchboard'; -import { buildRunTags } from '@lib/agent/agent-interface'; +import type { WizardSession } from '@store/session/wizard-session'; +import { analytics } from '@store/shared/analytics'; +import { getUI } from '@store/ui'; +import { authenticate, refreshAccessTokenIfNeeded } from './authenticate.js'; +import { maybeStampAiSdkDetected } from '@store/programs/posthog-integration/detect'; +import { createTriageLLMProvider } from '../../triage-provider.js'; +import { gatewayAuth } from '../../gateway/gateway-session.js'; +import { resolveHarness } from '../switchboard/index.js'; +import { buildRunTags } from '../../agent-interface.js'; import { checkAllSettingsConflicts, backupAndFixClaudeSettings, classifySettingsConflicts, -} from '@lib/claude-settings'; +} from '@store/services/claude-settings'; import { evaluateWizardReadiness, WizardReadiness, SIGNUP_WIZARD_READINESS_CONFIG, getBlockingServiceKeys, SERVICE_LABELS, -} from '@lib/health-checks/readiness'; -import { enableDebugLogs, logToFile, initLogFile } from '@utils/debug'; -import { wizardAbort } from '@utils/wizard-abort'; -import { ErrorCodes } from '@lib/errors'; -import { isNonInteractiveEnvironment } from '@utils/environment'; -import { CallType, getSkillsBaseUrl, IS_DEV } from '@lib/constants'; -import { VERSION } from '@lib/version'; -import { mcpUrlFor } from '@lib/host-resolution'; -import type { WizardRunOptions } from '@utils/types'; -import type { ProgramRunConfig } from '@lib/program-run'; -import { shouldDisableAsk } from '@lib/ask-policy'; +} from '@store/health-checks/readiness'; +import { enableDebugLogs, logToFile, initLogFile } from '@store/shared/debug'; +import { wizardAbort } from '@store/shared/wizard-abort'; +import { ErrorCodes } from '@store/shared/errors'; +import { isNonInteractiveEnvironment } from '@store/shared/environment'; +import { CallType, getSkillsBaseUrl, IS_DEV } from '@store/shared/constants'; +import { VERSION } from '@store/shared/version'; +import { mcpUrlFor } from '@store/host-resolution'; +import type { WizardRunOptions } from '@store/shared/types'; +import type { ProgramRunConfig } from '@store/agent-protocol/program-run'; +import { shouldDisableAsk } from '@store/session/ask-policy'; export { shouldDisableAsk }; -import type { ProgramRun, BootstrapResult } from './types'; +import type { ProgramRun, BootstrapResult } from './types.js'; // ── Helpers ────────────────────────────────────────────────────────── diff --git a/src/lib/agent/runner/shared/errors.ts b/src/agent/runner/shared/errors.ts similarity index 86% rename from src/lib/agent/runner/shared/errors.ts rename to src/agent/runner/shared/errors.ts index 376cb45d4..827b8dabd 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 { wizardAbort, WizardError } from '@utils/wizard-abort'; +import type { InstallSkillResult } from '@store/tools'; +import { skillErrorCode } from '@store/shared/errors'; +import { wizardAbort, WizardError } from '@store/shared/wizard-abort'; export async function abortOnInstallFailure( integrationLabel: string, diff --git a/src/lib/agent/runner/shared/types.ts b/src/agent/runner/shared/types.ts similarity index 89% rename from src/lib/agent/runner/shared/types.ts rename to src/agent/runner/shared/types.ts index 830c43a8d..6f506a6a1 100644 --- a/src/lib/agent/runner/shared/types.ts +++ b/src/agent/runner/shared/types.ts @@ -3,8 +3,8 @@ * `@lib/program-run`; the agent re-exports it for its own modules. */ -import type { Credentials } from '@lib/wizard-session'; -import type { ApiProject } from '@lib/api'; +import type { Credentials } from '@store/session/wizard-session'; +import type { ApiProject } from '@store/api'; import type { LLMProvider } from '@posthog/warlock'; export type { @@ -13,7 +13,7 @@ export type { AbortCase, ProgramRun, ProgramRunConfig, -} from '@lib/program-run'; +} from '@store/agent-protocol/program-run'; /** * Result of the shared bootstrap, consumed by both the linear and the diff --git a/src/lib/agent/runner/switchboard/commandments.ts b/src/agent/runner/switchboard/commandments.ts similarity index 96% rename from src/lib/agent/runner/switchboard/commandments.ts rename to src/agent/runner/switchboard/commandments.ts index 8cc9aed08..6aadb8493 100644 --- a/src/lib/agent/runner/switchboard/commandments.ts +++ b/src/agent/runner/switchboard/commandments.ts @@ -12,9 +12,12 @@ * an import cycle. */ -import { Harness, Sequence } from '@lib/constants'; -import { WIZARD_COMMANDMENTS } from '@lib/agent/commandments'; -import { piRuntimeNotes, type RuntimeCaps } from '../harness/pi/runtime-notes'; +import { Harness, Sequence } from '@store/shared/constants'; +import { WIZARD_COMMANDMENTS } from '../../commandments.js'; +import { + piRuntimeNotes, + type RuntimeCaps, +} from '../harness/pi/runtime-notes.js'; // ── 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..8e4241f12 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 '@store/shared/constants'; import { resolveBinding, type SwitchboardCtx, type SwitchboardTrace, -} from '@lib/agent/runner/switchboard'; -import type { EffortLevel } from '@lib/agent/runner/switchboard/models'; +} from '../../index.js'; +import type { EffortLevel } from '../../models.js'; /** 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..5b784d335 100644 --- a/src/lib/agent/runner/switchboard/flags/__tests__/flags.test.ts +++ b/src/agent/runner/switchboard/flags/__tests__/flags.test.ts @@ -3,8 +3,8 @@ import { readFileSync } from 'node:fs'; 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 { PROGRAM_REGISTRY } from '@store/programs/program-registry'; +import * as constants from '@store/shared/constants'; import { DEFAULT_AGENT_MODEL, GPT5_6_SOL_MODEL, @@ -14,19 +14,19 @@ import { WIZARD_ORCHESTRATOR_FLAG_KEY, WIZARD_ORCHESTRATOR_OVERRIDE_FLAG_KEY, WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY, -} from '@lib/constants'; +} from '@store/shared/constants'; import { areSeededTasksEnabled, resolveBinding, resolveStageOverrides, type SwitchboardCtx, -} from '@lib/agent/runner/switchboard'; +} from '../../index.js'; 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'; -import { runBindingCases } from './binding-cases'; +} from '../orchestrator.js'; +import { SELF_DRIVING_EXPERIMENT } from '../self-driving.js'; +import { runBindingCases } from './binding-cases.js'; const envState = vi.hoisted(() => ({ runSurface: 'local' as 'cloud' | 'local', diff --git a/src/lib/agent/runner/switchboard/flags/index.ts b/src/agent/runner/switchboard/flags/index.ts similarity index 87% rename from src/lib/agent/runner/switchboard/flags/index.ts rename to src/agent/runner/switchboard/flags/index.ts index b9d3d03a2..7390dc3b6 100644 --- a/src/lib/agent/runner/switchboard/flags/index.ts +++ b/src/agent/runner/switchboard/flags/index.ts @@ -5,15 +5,15 @@ * shapes and resolution. */ import { RUN_SURFACE } from '@env'; -import { logToFile } from '@utils/debug'; -import type { Sequence } from '@lib/constants'; -import type { ProgramId } from '@lib/programs/program-registry'; +import { logToFile } from '@store/shared/debug'; +import type { Sequence } from '@store/shared/constants'; +import type { ProgramId } from '@store/programs/program-registry'; import { ORCHESTRATOR_HARNESS_ROUTE, ORCHESTRATOR_SEQUENCE_ROUTE, ORCHESTRATOR_STAGE_OVERRIDES, -} from './orchestrator'; -import { SELF_DRIVING_EXPERIMENT } from './self-driving'; +} from './orchestrator.js'; +import { SELF_DRIVING_EXPERIMENT } from './self-driving.js'; import { routeFromConfigFlag, stageOverridesFromPayload, @@ -21,7 +21,7 @@ import { type HarnessExperiment, type SequenceExperiment, type StageOverride, -} from './schemes'; +} from './schemes.js'; /** Every experiment on each axis. An experiment routes ONLY by being listed here, and only for the programs it declares. */ export const HARNESS_EXPERIMENTS: readonly HarnessExperiment[] = [ @@ -74,11 +74,14 @@ export function resolveStageOverrides( return overrides; } -export { isOrchestratorEnabled, areSeededTasksEnabled } from './orchestrator'; +export { + isOrchestratorEnabled, + areSeededTasksEnabled, +} from './orchestrator.js'; export type { ConfigFlag, FlagRoute, HarnessExperiment, SequenceExperiment, StageOverride, -} from './schemes'; +} from './schemes.js'; diff --git a/src/lib/agent/runner/switchboard/flags/orchestrator.ts b/src/agent/runner/switchboard/flags/orchestrator.ts similarity index 97% rename from src/lib/agent/runner/switchboard/flags/orchestrator.ts rename to src/agent/runner/switchboard/flags/orchestrator.ts index 544e00b83..2101cf30d 100644 --- a/src/lib/agent/runner/switchboard/flags/orchestrator.ts +++ b/src/agent/runner/switchboard/flags/orchestrator.ts @@ -5,8 +5,8 @@ import { WIZARD_ORCHESTRATOR_FLAG_KEY, WIZARD_ORCHESTRATOR_OVERRIDE_FLAG_KEY, WIZARD_ORCHESTRATOR_SEEDED_TASKS_FLAG_KEY, -} from '@lib/constants'; -import type { HarnessExperiment, SequenceExperiment } from './schemes'; +} from '@store/shared/constants'; +import type { HarnessExperiment, SequenceExperiment } from './schemes.js'; export const ORCHESTRATOR_SEQUENCE_ROUTE: SequenceExperiment = { programs: ['posthog-integration'], diff --git a/src/lib/agent/runner/switchboard/flags/schemes.ts b/src/agent/runner/switchboard/flags/schemes.ts similarity index 96% rename from src/lib/agent/runner/switchboard/flags/schemes.ts rename to src/agent/runner/switchboard/flags/schemes.ts index f55f30141..9929b4f01 100644 --- a/src/lib/agent/runner/switchboard/flags/schemes.ts +++ b/src/agent/runner/switchboard/flags/schemes.ts @@ -12,10 +12,10 @@ import { Harness, Sequence, SONNET_5_MODEL, -} from '@lib/constants'; -import type { ProgramId } from '@lib/programs/program-registry'; -import { logToFile } from '@utils/debug'; -import type { EffortLevel } from '../models'; +} from '@store/shared/constants'; +import type { ProgramId } from '@store/programs/program-registry'; +import { logToFile } from '@store/shared/debug'; +import type { EffortLevel } from '../models.js'; // ── Shared vocabulary ───────────────────────────────────────────────────── diff --git a/src/lib/agent/runner/switchboard/flags/self-driving.ts b/src/agent/runner/switchboard/flags/self-driving.ts similarity index 76% rename from src/lib/agent/runner/switchboard/flags/self-driving.ts rename to src/agent/runner/switchboard/flags/self-driving.ts index beb34ea90..789d29804 100644 --- a/src/lib/agent/runner/switchboard/flags/self-driving.ts +++ b/src/agent/runner/switchboard/flags/self-driving.ts @@ -6,8 +6,8 @@ * 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 type { HarnessExperiment } from './schemes'; +import { WIZARD_SELF_DRIVING_USE_PI_HARNESS_FLAG_KEY } from '@store/shared/constants'; +import type { HarnessExperiment } from './schemes.js'; export const SELF_DRIVING_EXPERIMENT: HarnessExperiment = { program: 'self-driving', diff --git a/src/lib/agent/runner/switchboard/harness.ts b/src/agent/runner/switchboard/harness.ts similarity index 90% rename from src/lib/agent/runner/switchboard/harness.ts rename to src/agent/runner/switchboard/harness.ts index 8710a166f..026f7aa08 100644 --- a/src/lib/agent/runner/switchboard/harness.ts +++ b/src/agent/runner/switchboard/harness.ts @@ -3,12 +3,12 @@ */ import { IS_PRODUCTION_BUILD } from '@env'; -import { Harness } from '@lib/constants'; -import { logToFile } from '@utils/debug'; -import { anthropicBackend } from '../harness/anthropic'; -import { piBackend } from '../harness/pi'; -import type { AgentHarness } from '../harness/types'; -import { resolveFlagRoute } from './flags'; +import { Harness } from '@store/shared/constants'; +import { logToFile } from '@store/shared/debug'; +import { anthropicBackend } from '../harness/anthropic/index.js'; +import { piBackend } from '../harness/pi/index.js'; +import type { AgentHarness } from '../harness/types.js'; +import { resolveFlagRoute } from './flags/index.js'; import { DEFAULT_BINDING, PROGRAM_BINDINGS, @@ -16,7 +16,7 @@ import { type HarnessPick, type Middleware, type SwitchboardCtx, -} from '.'; +} from './index.js'; export const HARNESS_OPTIONS: Partial> = { [Harness.anthropic]: anthropicBackend, diff --git a/src/lib/agent/runner/switchboard/index.ts b/src/agent/runner/switchboard/index.ts similarity index 95% rename from src/lib/agent/runner/switchboard/index.ts rename to src/agent/runner/switchboard/index.ts index f6d641a66..f78232406 100644 --- a/src/lib/agent/runner/switchboard/index.ts +++ b/src/agent/runner/switchboard/index.ts @@ -6,11 +6,11 @@ import { GPT5_6_TERRA_MODEL, Harness, Sequence, -} from '@lib/constants'; -import type { ProgramId } from '@lib/programs/program-registry'; -import { resolveHarness } from './harness'; -import type { EffortLevel } from './models'; -import { resolveSequence } from './sequence'; +} from '@store/shared/constants'; +import type { ProgramId } from '@store/programs/program-registry'; +import { resolveHarness } from './harness.js'; +import type { EffortLevel } from './models.js'; +import { resolveSequence } from './sequence.js'; // ── Shared machinery ──────────────────────────────────────────────────── @@ -179,15 +179,15 @@ export function resolveBinding( } // ── Unified re-export surface ─────────────────────────────────────────── -export { HARNESS_OPTIONS, getHarness, resolveHarness } from './harness'; +export { HARNESS_OPTIONS, getHarness, resolveHarness } from './harness.js'; export { SEQUENCE_OPTIONS, getSequence, resolveSequence, type SequenceRunner, -} from './sequence'; +} from './sequence.js'; export { isOrchestratorEnabled, areSeededTasksEnabled, resolveStageOverrides, -} from './flags'; +} from './flags/index.js'; 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..02ee62455 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 '@store/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 91% rename from src/lib/agent/runner/switchboard/sequence.ts rename to src/agent/runner/switchboard/sequence.ts index ff8b415a6..d48f68080 100644 --- a/src/lib/agent/runner/switchboard/sequence.ts +++ b/src/agent/runner/switchboard/sequence.ts @@ -4,26 +4,26 @@ */ import { IS_PRODUCTION_BUILD } from '@env'; -import { Sequence } from '@lib/constants'; -import { logToFile } from '@utils/debug'; +import { Sequence } from '@store/shared/constants'; +import { logToFile } from '@store/shared/debug'; import { isOrchestratorEnabled, resolveFlagRoute, resolveFlagSequence, -} from './flags'; -import { getHarness, resolveHarness } from './harness'; -import type { WizardSession } from '@lib/wizard-session'; -import type { ProgramRunConfig } from '@lib/program-run'; -import type { ProgramRun, BootstrapResult } from '../shared/types'; -import { runLinearProgram } from '../sequence/linear'; -import { runOrchestrator } from '../sequence/orchestrator/orchestrator-runner'; +} from './flags/index.js'; +import { getHarness, resolveHarness } from './harness.js'; +import type { WizardSession } from '@store/session/wizard-session'; +import type { ProgramRunConfig } from '@store/agent-protocol/program-run'; +import type { ProgramRun, BootstrapResult } from '../shared/types.js'; +import { runLinearProgram } from '../sequence/linear.js'; +import { runOrchestrator } from '../sequence/orchestrator/orchestrator-runner.js'; import { DEFAULT_BINDING, PROGRAM_BINDINGS, runChain, type Middleware, type SwitchboardCtx, -} from '.'; +} from './index.js'; // ── Registry ──────────────────────────────────────────────────────────── diff --git a/src/lib/yara-hooks.ts b/src/agent/security/yara-hooks.ts similarity index 98% rename from src/lib/yara-hooks.ts rename to src/agent/security/yara-hooks.ts index 3ec2cb266..1b7b872f5 100644 --- a/src/lib/yara-hooks.ts +++ b/src/agent/security/yara-hooks.ts @@ -32,19 +32,19 @@ import type { LLMProvider, Category, } from '@posthog/warlock'; -import { logToFile } from '@utils/debug'; -import { readFileHead } from '@utils/bounded-fs'; -import { analytics } from '@utils/analytics'; -import { getUI } from '@ui'; -import type { WizardSession } from '@lib/wizard-session'; -import { isSkillInstallCommand } from './skill-install'; +import { logToFile } from '@store/shared/debug'; +import { readFileHead } from '@store/shared/bounded-fs'; +import { analytics } from '@store/shared/analytics'; +import { getUI } from '@store/ui'; +import type { WizardSession } from '@store/session/wizard-session'; +import { isSkillInstallCommand } from '@store/skill-install'; import { highestSeverityMatch, publishBlockingMatch, scanVerdict, -} from './yara-policy'; -import type { ScanAction, ScanContext } from './yara-policy'; -import { WIZARD_YARA_REPORT_FILE } from '@utils/paths'; +} from './yara-policy.js'; +import type { ScanAction, ScanContext } from './yara-policy.js'; +import { WIZARD_YARA_REPORT_FILE } from '@store/shared/paths'; // TODO(wizard#594): invert this dependency. // L2 infra (yara-hooks) imports product-specific filename constants from // individual programs. The leaf `constants.ts` modules break the *import* @@ -58,9 +58,9 @@ import { SETUP_REPORT_FILE as EVENTS_AUDIT_REPORT_FILE, EVENT_INVENTORY_FILE, EVENT_INVENTORY_PART_PATTERN, -} from '@lib/programs/events-audit/constants'; -import { AUDIT_REPORT_FILE } from '@lib/programs/audit/types'; -import { EVENT_PLAN_FILE } from '@lib/programs/posthog-integration/constants'; +} from '@store/programs/events-audit/constants'; +import { AUDIT_REPORT_FILE } from '@store/programs/audit/types'; +import { EVENT_PLAN_FILE } from '@store/programs/posthog-integration/constants'; // ─── Warlock module accessor ───────────────────────────────────── // Warlock is ESM-only and lazily inits its WASM engine + compiles rules on the @@ -120,7 +120,7 @@ export interface HookCallbackMatcher { timeout?: number; } -export type { ScanAction, ScanContext } from './yara-policy'; +export type { ScanAction, ScanContext } from './yara-policy.js'; // ─── Scan Report Accumulator ───────────────────────────────────── diff --git a/src/lib/yara-policy.ts b/src/agent/security/yara-policy.ts similarity index 100% rename from src/lib/yara-policy.ts rename to src/agent/security/yara-policy.ts diff --git a/src/lib/agent/stored-login.ts b/src/agent/stored-login.ts similarity index 97% rename from src/lib/agent/stored-login.ts rename to src/agent/stored-login.ts index 3a9ca812f..307efde74 100644 --- a/src/lib/agent/stored-login.ts +++ b/src/agent/stored-login.ts @@ -22,8 +22,8 @@ import * as fs from 'fs'; import * as os from 'os'; import path from 'path'; import { spawnSync } from 'node:child_process'; -import { logToFile } from '@utils/debug'; -import { analytics } from '@utils/analytics'; +import { logToFile } from '@store/shared/debug'; +import { analytics } from '@store/shared/analytics'; /** macOS keychain service name Claude Code stores its login under. */ const KEYCHAIN_SERVICE = 'Claude Code-credentials'; diff --git a/src/lib/wizard-tools/mcp.ts b/src/agent/tools/mcp.ts similarity index 97% rename from src/lib/wizard-tools/mcp.ts rename to src/agent/tools/mcp.ts index 4ad43e235..53a2e863e 100644 --- a/src/lib/wizard-tools/mcp.ts +++ b/src/agent/tools/mcp.ts @@ -11,27 +11,33 @@ import path from 'path'; import fs from 'fs'; import { z } from 'zod'; -import { logToFile } from '@utils/debug'; -import { analytics } from '@utils/analytics'; -import { makeMutex } from '@utils/atomic-ledger'; -import type { PackageManagerDetector } from '../detection/package-manager'; +import { logToFile } from '@store/shared/debug'; +import { analytics } from '@store/shared/analytics'; +import { makeMutex } from '@store/shared/atomic-ledger'; +import type { PackageManagerDetector } from '@store/detection/package-manager'; import { AUDIT_CHECKS_FILE, type AuditCheck, type AuditStatus, -} from '../programs/audit/types'; -import { type WizardAskBridge, isFullyCancelled } from '../wizard-ask-bridge'; +} from '@store/programs/audit/types'; +import { + type WizardAskBridge, + isFullyCancelled, +} from '@store/session/wizard-ask-bridge'; import { PUBLISH_HANDOFF_CONTENT_DESCRIPTION, PUBLISH_HANDOFF_DESCRIPTION, PUBLISH_HANDOFF_TOOL_NAME, publishHandoff, -} from './handoff'; -import { createSecretVault, type SecretVault } from '../secret-vault'; +} from '@store/tools/handoff'; +import { + createSecretVault, + type SecretVault, +} from '@store/session/secret-vault'; import { buildOrchestratorTools, type OrchestratorToolsContext, -} from '../agent/runner/sequence/orchestrator/queue-tools'; +} from '../runner/sequence/orchestrator/queue-tools.js'; import type { LLMProvider } from '@posthog/warlock'; import { DEFAULT_ASK_MAX_QUESTIONS, @@ -68,7 +74,7 @@ import { WIZARD_ASK_SENSITIVE_DESCRIPTION, WIZARD_ASK_SUBJECT_DESCRIPTION, WIZARD_ASK_TOOL_DESCRIPTION, -} from './tools'; +} from '@store/tools/tools'; const auditCheckSchema = z.object({ id: z.string().min(1), diff --git a/src/lib/agent/triage-provider.ts b/src/agent/triage-provider.ts similarity index 95% rename from src/lib/agent/triage-provider.ts rename to src/agent/triage-provider.ts index dfb03861d..278163c6a 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 { logToFile } from '@utils/debug'; +import { Harness } from '@store/shared/constants'; +import { logToFile } from '@store/shared/debug'; import { buildGatewayModel, gatewayApiFor, -} from '@lib/agent/runner/harness/pi/gateway'; +} from './runner/harness/pi/gateway.js'; import { modelCapabilities, triageModelFor, -} from '@lib/agent/runner/switchboard/models'; +} from './runner/switchboard/models.js'; import type { LLMProvider } from '@posthog/warlock'; const TRIAGE_MAX_TOKENS = 16_384; diff --git a/src/__tests__/basic-integration-cli.test.ts b/src/cli/__tests__/basic-integration-cli.test.ts similarity index 91% rename from src/__tests__/basic-integration-cli.test.ts rename to src/cli/__tests__/basic-integration-cli.test.ts index 470122d69..7c8570fd1 100644 --- a/src/__tests__/basic-integration-cli.test.ts +++ b/src/cli/__tests__/basic-integration-cli.test.ts @@ -1,6 +1,6 @@ -import { basicIntegrationCommand } from '../commands/basic-integration'; -import { HEADLESS_FLAG } from '../lib/headless-mode'; -import { parseCommand } from './helpers/parse-command.no-jest'; +import { basicIntegrationCommand } from '../commands/basic-integration/index.js'; +import { HEADLESS_FLAG } from '../headless-mode.js'; +import { parseCommand } from './helpers/parse-command.no-jest.js'; describe('basic-integration parsing (end-to-end yargs)', () => { test('parses flags into camelCased argv keys', async () => { diff --git a/src/__tests__/cli.test.ts b/src/cli/__tests__/cli.test.ts similarity index 95% rename from src/__tests__/cli.test.ts rename to src/cli/__tests__/cli.test.ts index 2b8a723f7..bcfcb2117 100644 --- a/src/__tests__/cli.test.ts +++ b/src/cli/__tests__/cli.test.ts @@ -18,7 +18,7 @@ const { mockStreamAttach, mockStreamShutdown, mockStreamDestinations } = // destinations, not about whether a stream exists. mockStreamDestinations: vi.fn(), })); -vi.mock('../lib/task-stream/index', () => ({ +vi.mock('@store/task-stream', () => ({ // shutdown() hardcodes a resolved Promise (not a bare vi.fn) so the // interactive runWizard's dangling SIGTERM handler — which calls // shutdown().catch() and outlives these tests — never hits undefined.catch. @@ -42,8 +42,8 @@ vi.mock('../lib/task-stream/index', () => ({ ? null : { name: 'file', path: '/tmp/task-stream.jsonl' }, })); -vi.mock('../ui/tui/store', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('@store/state/store', async (importOriginal) => ({ + ...(await importOriginal()), WizardStore: class { session: unknown; setRunPhase = vi.fn(); @@ -55,14 +55,14 @@ vi.mock('../ui/tui/store', async (importOriginal) => ({ vi.mock('semver', () => ({ satisfies: () => true })); // importOriginal keeps real exports (e.g. RunPhase) while overriding // buildSession — vitest throws on access to exports a partial mock omits. -vi.mock('../lib/wizard-session', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('@store/session/wizard-session', async (importOriginal) => ({ + ...(await importOriginal()), buildSession: mockBuildSessionCli, })); -vi.mock('../utils/provisioning', () => ({ +vi.mock('@store/shared/provisioning', () => ({ provisionNewAccount: mockProvisionNewAccountCli, })); -vi.mock('../ui/tui/start-tui', () => ({ +vi.mock('@tui/start-tui', () => ({ startTUI: () => ({ unmount: vi.fn(), store: { @@ -75,7 +75,7 @@ vi.mock('../ui/tui/start-tui', () => ({ }, }), })); -vi.mock('../lib/programs/posthog-integration/index', () => ({ +vi.mock('@store/programs/posthog-integration', () => ({ posthogIntegrationConfig: { id: 'posthog-integration', steps: [], @@ -88,31 +88,31 @@ vi.mock('../lib/programs/posthog-integration/index', () => ({ run: () => Promise.resolve(), }, })); -vi.mock('../utils/environment', () => ({ +vi.mock('@store/shared/environment', () => ({ isNonInteractiveEnvironment: () => false, readEnvironment: () => ({}), })); // CI-path dynamic imports need mocks to prevent unhandled rejections -vi.mock('../utils/env-api-key', () => ({ +vi.mock('@store/shared/env-api-key', () => ({ readApiKeyFromEnv: () => undefined, })); -vi.mock('../utils/debug', () => ({ +vi.mock('@store/shared/debug', () => ({ configureLogFileFromEnvironment: vi.fn(), logToFile: vi.fn(), })); -vi.mock('../lib/registry', () => ({ FRAMEWORK_REGISTRY: {} })); -vi.mock('../lib/detection/index', () => ({ +vi.mock('@store/registry', () => ({ FRAMEWORK_REGISTRY: {} })); +vi.mock('@store/detection', () => ({ detectFramework: vi.fn().mockResolvedValue(null), gatherFrameworkContext: vi.fn().mockResolvedValue({}), })); -vi.mock('../utils/analytics', () => ({ +vi.mock('@store/shared/analytics', () => ({ analytics: { setTag: vi.fn() }, })); -vi.mock('../utils/wizard-abort', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('@store/shared/wizard-abort', async (importOriginal) => ({ + ...(await importOriginal()), wizardAbort: vi.fn(), })); -vi.mock('../lib/agent/agent-runner', () => ({ +vi.mock('@agent/agent-runner', () => ({ runAgent: vi.fn().mockResolvedValue(undefined), })); @@ -172,7 +172,7 @@ describe('CLI argument parsing', () => { try { // vi.resetModules() (afterEach) clears the registry, so this re-evaluates // bin.ts fresh on every call — the vitest equivalent of isolateModules. - await import('../../bin'); + await import('../../../bin.js'); } catch { // process.exit mock throws to halt handler execution } @@ -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' + '@store/shared/constants' ); return { actual: getSkillsBaseUrl(), local: LOCAL_SKILLS_BASE_URL }; } @@ -325,7 +325,7 @@ describe('CLI argument parsing', () => { // A global `local` would silently erase `--local` from // `wizard mcp add --help`; a global's `hidden` beats a command-level one. test('no global option is named `local`', async () => { - const { GLOBAL_OPTIONS } = await import('../wizard'); + const { GLOBAL_OPTIONS } = await import('../wizard.js'); expect(Object.keys(GLOBAL_OPTIONS)).not.toContain('local'); }); }); @@ -444,7 +444,7 @@ describe('CLI argument parsing', () => { '/tmp/test', ]); - const { analytics } = await import('../utils/analytics'); + const { analytics } = await import('@store/shared/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('@store/shared/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('@store/shared/analytics'); expect(analytics.setTag).toHaveBeenCalledWith('build', 'headless'); expect(analytics.setTag).not.toHaveBeenCalledWith('build', 'ci'); }); diff --git a/src/__tests__/headless-scope.test.ts b/src/cli/__tests__/headless-scope.test.ts similarity index 80% rename from src/__tests__/headless-scope.test.ts rename to src/cli/__tests__/headless-scope.test.ts index e6d974a31..68de8aaa4 100644 --- a/src/__tests__/headless-scope.test.ts +++ b/src/cli/__tests__/headless-scope.test.ts @@ -1,9 +1,9 @@ -import { auditCommand } from '../commands/audit'; -import { basicIntegrationCommand } from '../commands/basic-integration'; -import { revenueCommand } from '../commands/revenue'; -import { HEADLESS_FLAG } from '../lib/headless-mode'; -import { GLOBAL_OPTIONS } from '../wizard'; -import { parseCommand } from './helpers/parse-command.no-jest'; +import { auditCommand } from '../commands/audit.js'; +import { basicIntegrationCommand } from '../commands/basic-integration/index.js'; +import { revenueCommand } from '../commands/revenue.js'; +import { HEADLESS_FLAG } from '../headless-mode.js'; +import { GLOBAL_OPTIONS } from '../wizard.js'; +import { parseCommand } from './helpers/parse-command.no-jest.js'; // The experimental headless flag is scoped to exactly two surfaces — the base // integration flow (`wizard`) and `wizard audit` — rather than being a global diff --git a/src/__tests__/helpers/parse-command.no-jest.ts b/src/cli/__tests__/helpers/parse-command.no-jest.ts similarity index 95% rename from src/__tests__/helpers/parse-command.no-jest.ts rename to src/cli/__tests__/helpers/parse-command.no-jest.ts index 621c94560..b75c5fd3a 100644 --- a/src/__tests__/helpers/parse-command.no-jest.ts +++ b/src/cli/__tests__/helpers/parse-command.no-jest.ts @@ -1,7 +1,7 @@ import yargs from 'yargs'; import type { Arguments } from 'yargs'; -import { GLOBAL_OPTIONS } from '../../wizard'; -import { toCommandModule, type Command } from '../../commands/command'; +import { GLOBAL_OPTIONS } from '../../wizard.js'; +import { toCommandModule, type Command } from '../../commands/command.js'; /** * Parse an argv string through a command's real yargs configuration (global diff --git a/src/__tests__/mcp-cli.test.ts b/src/cli/__tests__/mcp-cli.test.ts similarity index 89% rename from src/__tests__/mcp-cli.test.ts rename to src/cli/__tests__/mcp-cli.test.ts index e9b41f8b3..f360ed6df 100644 --- a/src/__tests__/mcp-cli.test.ts +++ b/src/cli/__tests__/mcp-cli.test.ts @@ -11,7 +11,7 @@ const { mockBuildSessionMcp, mockStartTUIMcp, mockReadApiKeyFromEnvMcp } = mockReadApiKeyFromEnvMcp: vi.fn(() => undefined as string | undefined), })); -vi.mock('@lib/wizard-session', () => ({ +vi.mock('@store/session/wizard-session', () => ({ buildSession: mockBuildSessionMcp, // analytics.ts imports this for sessionProperties(); unused by this // suite's assertions, stubbed only so the mocked module still satisfies @@ -19,13 +19,13 @@ vi.mock('@lib/wizard-session', () => ({ reportableDiscoveredFeatures: () => undefined, reportablePosthogSdkDetected: () => undefined, })); -vi.mock('@ui/tui/start-tui', () => ({ +vi.mock('@tui/start-tui', () => ({ startTUI: mockStartTUIMcp, })); -vi.mock('@utils/env-api-key', () => ({ +vi.mock('@store/shared/env-api-key', () => ({ readApiKeyFromEnv: mockReadApiKeyFromEnvMcp, })); -vi.mock('@lib/programs/program-registry', () => ({ +vi.mock('@store/programs/program-registry', () => ({ Program: { McpAdd: 'mcp-add', McpRemove: 'mcp-remove', @@ -37,11 +37,11 @@ vi.mock('@lib/programs/program-registry', () => ({ })); import type { Arguments } from 'yargs'; -import { mcpAddCommand } from '../commands/mcp/add'; -import { mcpRemoveCommand } from '../commands/mcp/remove'; -import { mcpTutorialCommand } from '../commands/mcp/tutorial'; -import { mcpCommand } from '../commands/mcp'; -import { parseCommand } from './helpers/parse-command.no-jest'; +import { mcpAddCommand } from '../commands/mcp/add.js'; +import { mcpRemoveCommand } from '../commands/mcp/remove.js'; +import { mcpTutorialCommand } from '../commands/mcp/tutorial.js'; +import { mcpCommand } from '../commands/mcp/index.js'; +import { parseCommand } from './helpers/parse-command.no-jest.js'; function makeArgv(extra: Record = {}): Arguments { return { _: [], $0: 'wizard', ...extra } as Arguments; diff --git a/src/__tests__/programs-cli.test.ts b/src/cli/__tests__/programs-cli.test.ts similarity index 91% rename from src/__tests__/programs-cli.test.ts rename to src/cli/__tests__/programs-cli.test.ts index 89a972809..dccb20a05 100644 --- a/src/__tests__/programs-cli.test.ts +++ b/src/cli/__tests__/programs-cli.test.ts @@ -3,13 +3,13 @@ const { mockRunWizard, mockRunWizardCI } = vi.hoisted(() => ({ mockRunWizardCI: vi.fn(), })); -vi.mock('@lib/runners', () => ({ +vi.mock('../runners/index.js', () => ({ runWizard: mockRunWizard, runWizardCI: mockRunWizardCI, })); -vi.mock('@lib/wizard-tools', async (importOriginal) => { - const actual = await importOriginal(); +vi.mock('@store/tools', async (importOriginal) => { + const actual = await importOriginal(); return { ...actual, fetchSkillMenu: vi.fn(), @@ -18,23 +18,23 @@ vi.mock('@lib/wizard-tools', async (importOriginal) => { import type { Arguments } from 'yargs'; import type { MockedFunction } from 'vitest'; -import { auditCommand } from '../commands/audit'; -import { migrateCommand } from '../commands/migrate'; -import { mcpAnalyticsCommand } from '../commands/mcp-analytics'; -import { replayVisionCommand } from '../commands/replay-vision'; -import { revenueCommand } from '../commands/revenue'; -import { warehouseCommand } from '../commands/warehouse'; -import { uploadSourcemapsCommand } from '../commands/upload-sourcemaps'; -import { selfDrivingCommand } from '../commands/self-driving'; +import { auditCommand } from '../commands/audit.js'; +import { migrateCommand } from '../commands/migrate.js'; +import { mcpAnalyticsCommand } from '../commands/mcp-analytics.js'; +import { replayVisionCommand } from '../commands/replay-vision.js'; +import { revenueCommand } from '../commands/revenue.js'; +import { warehouseCommand } from '../commands/warehouse.js'; +import { uploadSourcemapsCommand } from '../commands/upload-sourcemaps.js'; +import { selfDrivingCommand } from '../commands/self-driving.js'; import { dispatchFamily, pickerChildrenToShow, -} from '@lib/programs/dispatch-family'; -import type { Command } from '../commands/command'; -import { fetchSkillMenu, type CliEntry } from '@lib/wizard-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'; +} from '@store/programs/dispatch-family'; +import type { Command } from '../commands/command.js'; +import { fetchSkillMenu, type CliEntry } from '@store/tools'; +import { auditConfig } from '@store/programs/audit'; +import { webAnalyticsDoctorConfig } from '@store/programs/web-analytics-doctor'; +import { parseCommand } from './helpers/parse-command.no-jest.js'; const mockFetchSkillMenu = fetchSkillMenu as MockedFunction< typeof fetchSkillMenu diff --git a/src/__tests__/provision-cli.test.ts b/src/cli/__tests__/provision-cli.test.ts similarity index 91% rename from src/__tests__/provision-cli.test.ts rename to src/cli/__tests__/provision-cli.test.ts index d1b561ba4..94bf6432a 100644 --- a/src/__tests__/provision-cli.test.ts +++ b/src/cli/__tests__/provision-cli.test.ts @@ -5,16 +5,16 @@ const { mockProvisionNewAccountSubcmd } = vi.hoisted(() => ({ })); vi.mock('semver', () => ({ satisfies: () => true })); -vi.mock('../utils/provisioning', () => ({ +vi.mock('@store/shared/provisioning', () => ({ provisionNewAccount: mockProvisionNewAccountSubcmd, })); // Same supporting mocks as src/__tests__/cli.test.ts — bin.ts imports these // at module load regardless of which subcommand yargs dispatches. -vi.mock('../lib/wizard-session', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('@store/session/wizard-session', async (importOriginal) => ({ + ...(await importOriginal()), buildSession: vi.fn((args: Record) => args), })); -vi.mock('../ui/tui/start-tui', () => ({ +vi.mock('@tui/start-tui', () => ({ startTUI: () => ({ unmount: vi.fn(), store: { @@ -27,7 +27,7 @@ vi.mock('../ui/tui/start-tui', () => ({ }, }), })); -vi.mock('../lib/programs/posthog-integration/index', () => ({ +vi.mock('@store/programs/posthog-integration', () => ({ posthogIntegrationConfig: { id: 'posthog-integration', steps: [], @@ -40,35 +40,35 @@ vi.mock('../lib/programs/posthog-integration/index', () => ({ run: () => Promise.resolve(), }, })); -vi.mock('../utils/environment', () => ({ +vi.mock('@store/shared/environment', () => ({ isNonInteractiveEnvironment: () => false, readEnvironment: () => ({}), })); -vi.mock('../utils/env-api-key', () => ({ +vi.mock('@store/shared/env-api-key', () => ({ readApiKeyFromEnv: () => undefined, })); -vi.mock('../utils/debug', () => ({ +vi.mock('@store/shared/debug', () => ({ configureLogFileFromEnvironment: vi.fn(), logToFile: vi.fn(), })); -vi.mock('../lib/registry', () => ({ FRAMEWORK_REGISTRY: {} })); -vi.mock('../lib/detection/index', () => ({ +vi.mock('@store/registry', () => ({ FRAMEWORK_REGISTRY: {} })); +vi.mock('@store/detection', () => ({ detectFramework: vi.fn().mockResolvedValue(null), gatherFrameworkContext: vi.fn().mockResolvedValue({}), })); -vi.mock('../utils/analytics', () => ({ +vi.mock('@store/shared/analytics', () => ({ analytics: { setTag: vi.fn() }, })); -vi.mock('../utils/wizard-abort', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('@store/shared/wizard-abort', async (importOriginal) => ({ + ...(await importOriginal()), wizardAbort: vi.fn(), })); -vi.mock('../lib/agent/agent-runner', () => ({ +vi.mock('@agent/agent-runner', () => ({ runAgent: vi.fn().mockResolvedValue(undefined), })); -import { provisionCommand } from '../commands/provision'; -import { parseCommand } from './helpers/parse-command.no-jest'; +import { provisionCommand } from '../commands/provision.js'; +import { parseCommand } from './helpers/parse-command.no-jest.js'; describe('provision parsing (end-to-end yargs)', () => { test('parses --email and --region', async () => { @@ -184,7 +184,7 @@ describe('wizard provision subcommand', () => { // vi.resetModules() re-evaluates bin.ts fresh on each call — the vitest // equivalent of jest.isolateModules. vi.resetModules(); - await import('../../bin'); + await import('../../../bin.js'); } catch { // bin.ts dispatch can reject on some parse paths; the run's effect is // asserted via the mocks after settle(). diff --git a/src/__tests__/skill-cli.test.ts b/src/cli/__tests__/skill-cli.test.ts similarity index 90% rename from src/__tests__/skill-cli.test.ts rename to src/cli/__tests__/skill-cli.test.ts index 7acc361ab..e6fbbdd96 100644 --- a/src/__tests__/skill-cli.test.ts +++ b/src/cli/__tests__/skill-cli.test.ts @@ -1,19 +1,19 @@ import type { Arguments } from 'yargs'; -vi.mock('../commands/basic-integration/skill', () => ({ +vi.mock('../commands/basic-integration/skill.js', () => ({ runSkillMode: vi.fn(), })); -vi.mock('@lib/wizard-tools', async (importOriginal) => { - const actual = await importOriginal(); +vi.mock('@store/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 { analytics } from '@utils/analytics'; -import { skillCommand } from '../commands/skill'; -import { parseCommand } from './helpers/parse-command.no-jest'; +import { runSkillMode } from '../commands/basic-integration/skill.js'; +import { fetchSkillMenu } from '@store/tools'; +import { analytics } from '@store/shared/analytics'; +import { skillCommand } from '../commands/skill.js'; +import { parseCommand } from './helpers/parse-command.no-jest.js'; function makeArgv(extra: Record = {}): Arguments { return { _: [], $0: 'wizard', ...extra } as Arguments; diff --git a/src/__tests__/wizard.test.ts b/src/cli/__tests__/wizard.test.ts similarity index 84% rename from src/__tests__/wizard.test.ts rename to src/cli/__tests__/wizard.test.ts index 0b76ff294..163c061e8 100644 --- a/src/__tests__/wizard.test.ts +++ b/src/cli/__tests__/wizard.test.ts @@ -1,13 +1,13 @@ -import { commandKeys, type Command } from '../commands/command'; -import { basicIntegrationCommand } from '../commands/basic-integration'; -import { mcpCommand } from '../commands/mcp'; -import { auditCommand } from '../commands/audit'; -import { doctorCommand } from '../commands/doctor'; -import { migrateCommand } from '../commands/migrate'; -import { replayVisionCommand } from '../commands/replay-vision'; -import { revenueCommand } from '../commands/revenue'; -import { uploadSourcemapsCommand } from '../commands/upload-sourcemaps'; -import { skillCommand } from '../commands/skill'; +import { commandKeys, type Command } from '../commands/command.js'; +import { basicIntegrationCommand } from '../commands/basic-integration/index.js'; +import { mcpCommand } from '../commands/mcp/index.js'; +import { auditCommand } from '../commands/audit.js'; +import { doctorCommand } from '../commands/doctor.js'; +import { migrateCommand } from '../commands/migrate.js'; +import { replayVisionCommand } from '../commands/replay-vision.js'; +import { revenueCommand } from '../commands/revenue.js'; +import { uploadSourcemapsCommand } from '../commands/upload-sourcemaps.js'; +import { skillCommand } from '../commands/skill.js'; const cmd = (name: string | readonly string[]): Command => ({ name, diff --git a/src/commands/ai-observability.ts b/src/cli/commands/ai-observability.ts similarity index 84% rename from src/commands/ai-observability.ts rename to src/cli/commands/ai-observability.ts index abf436c45..d020dc9bc 100644 --- a/src/commands/ai-observability.ts +++ b/src/cli/commands/ai-observability.ts @@ -1,7 +1,7 @@ -import { aiObservabilityConfig } from '@lib/programs/ai-observability/index'; +import { aiObservabilityConfig } from '@store/programs/ai-observability'; -import type { Command } from './command'; -import { nativeCommandFactory } from './factories/native-command-factory'; +import type { Command } from './command.js'; +import { nativeCommandFactory } from './factories/native-command-factory.js'; /** * `wizard ai-observability` — flat skill command, wire AI Observability into a diff --git a/src/commands/audit.ts b/src/cli/commands/audit.ts similarity index 86% rename from src/commands/audit.ts rename to src/cli/commands/audit.ts index e838bbe28..92a7d0414 100644 --- a/src/commands/audit.ts +++ b/src/cli/commands/audit.ts @@ -1,7 +1,7 @@ -import { auditConfig } from '@lib/programs/audit/index'; +import { auditConfig } from '@store/programs/audit'; -import type { Command } from './command'; -import { familyCommandFactory } from './factories/family-command-factory'; +import type { Command } from './command.js'; +import { familyCommandFactory } from './factories/family-command-factory.js'; /** * The `wizard audit` family. diff --git a/src/commands/basic-integration/__tests__/ci-install.test.ts b/src/cli/commands/basic-integration/__tests__/ci-install.test.ts similarity index 95% rename from src/commands/basic-integration/__tests__/ci-install.test.ts rename to src/cli/commands/basic-integration/__tests__/ci-install.test.ts index 934adab68..eb9a7b210 100644 --- a/src/commands/basic-integration/__tests__/ci-install.test.ts +++ b/src/cli/commands/basic-integration/__tests__/ci-install.test.ts @@ -1,4 +1,4 @@ -import { keyPrefixWarning } from '../ci-install'; +import { keyPrefixWarning } from '../ci-install.js'; /** * `--ci` and headless accept the same credentials: a personal API key and a diff --git a/src/commands/basic-integration/ci-install.ts b/src/cli/commands/basic-integration/ci-install.ts similarity index 91% rename from src/commands/basic-integration/ci-install.ts rename to src/cli/commands/basic-integration/ci-install.ts index 3956ef0ca..f8a30d1b9 100644 --- a/src/commands/basic-integration/ci-install.ts +++ b/src/cli/commands/basic-integration/ci-install.ts @@ -1,12 +1,16 @@ import type { Arguments } from 'yargs'; -import { getUI, setUI } from '@ui'; -import { LoggingUI } from '@ui/tui/console/logging-ui'; -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 { getUI, setUI } from '@store/ui'; +import { LoggingUI } from '@tui/console/logging-ui'; +import { + API_KEY_HINT, + runWizardCI, + runWizardHeadless, +} from '../../runners/index.js'; +import type { NonInteractiveMode } from '../../runners/index.js'; +import { provisionNewAccount } from '@store/shared/provisioning'; +import { posthogIntegrationConfig } from '@store/programs/posthog-integration'; +import { ErrorCodes, type ErrorCode } from '@store/shared/errors'; +import { emitWizardError } from '@store/shared/errors'; type Options = Arguments & { region?: string; diff --git a/src/commands/basic-integration/index.ts b/src/cli/commands/basic-integration/index.ts similarity index 84% rename from src/commands/basic-integration/index.ts rename to src/cli/commands/basic-integration/index.ts index 0d1aa8739..391cf20fa 100644 --- a/src/commands/basic-integration/index.ts +++ b/src/cli/commands/basic-integration/index.ts @@ -1,8 +1,12 @@ -import { isNonInteractiveEnvironment } from '@utils/environment'; -import { setEntryCommand } from '@utils/links'; -import { headlessOption, isHeadless, regionOption } from '@lib/headless-mode'; -import { provisionCommand } from '../provision'; -import type { Command } from '../command'; +import { isNonInteractiveEnvironment } from '@store/shared/environment'; +import { setEntryCommand } from '@store/shared/links'; +import { + headlessOption, + isHeadless, + regionOption, +} from '../../headless-mode.js'; +import { provisionCommand } from '../provision.js'; +import type { Command } from '../command.js'; export const basicIntegrationCommand: Command = { name: ['$0'], @@ -57,22 +61,22 @@ export const basicIntegrationCommand: Command = { // functions end-to-end, so headless can diverge later without touching // the CI path or its callers. if (isHeadless(argv)) { - const { runHeadlessInstall } = await import('./ci-install'); + const { runHeadlessInstall } = await import('./ci-install.js'); return runHeadlessInstall(argv); } if (argv.ci) { - const { runCIInstall } = await import('./ci-install'); + const { runCIInstall } = await import('./ci-install.js'); return runCIInstall(argv); } if (isNonInteractiveEnvironment()) { - const { failNonInteractive } = await import('./non-interactive'); + const { failNonInteractive } = await import('./non-interactive.js'); return failNonInteractive(); } if (argv.playground) { - const { runPlayground } = await import('./playground'); + const { runPlayground } = await import('./playground.js'); return runPlayground(); } - const { runInteractive } = await import('./interactive'); + const { runInteractive } = await import('./interactive.js'); runInteractive(argv); })(); }, diff --git a/src/commands/basic-integration/interactive.ts b/src/cli/commands/basic-integration/interactive.ts similarity index 62% rename from src/commands/basic-integration/interactive.ts rename to src/cli/commands/basic-integration/interactive.ts index ee143f5d9..ef25c7016 100644 --- a/src/commands/basic-integration/interactive.ts +++ b/src/cli/commands/basic-integration/interactive.ts @@ -1,6 +1,6 @@ import type { Arguments } from 'yargs'; -import { runWizard } from '@lib/runners'; -import { posthogIntegrationConfig } from '@lib/programs/posthog-integration/index'; +import { runWizard } from '../../runners/index.js'; +import { posthogIntegrationConfig } from '@store/programs/posthog-integration'; /** Default flow: run the posthog-integration program through the TUI. */ export function runInteractive(argv: Arguments): void { diff --git a/src/commands/basic-integration/non-interactive.ts b/src/cli/commands/basic-integration/non-interactive.ts similarity index 82% rename from src/commands/basic-integration/non-interactive.ts rename to src/cli/commands/basic-integration/non-interactive.ts index 02a47675c..539db6b3c 100644 --- a/src/commands/basic-integration/non-interactive.ts +++ b/src/cli/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 { getUI } from '@store/ui'; +import { ErrorCodes } from '@store/shared/errors'; +import { emitWizardError } from '@store/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/cli/commands/basic-integration/playground.ts b/src/cli/commands/basic-integration/playground.ts new file mode 100644 index 000000000..3976a0a97 --- /dev/null +++ b/src/cli/commands/basic-integration/playground.ts @@ -0,0 +1,7 @@ +import { VERSION } from '@store/shared/version'; +import { startPlayground } from '@tui/playground/start-playground'; + +/** Launch the TUI primitives playground. */ +export function runPlayground(): void { + startPlayground(VERSION); +} diff --git a/src/commands/basic-integration/skill.ts b/src/cli/commands/basic-integration/skill.ts similarity index 79% rename from src/commands/basic-integration/skill.ts rename to src/cli/commands/basic-integration/skill.ts index a4a2bc088..1946af808 100644 --- a/src/commands/basic-integration/skill.ts +++ b/src/cli/commands/basic-integration/skill.ts @@ -1,7 +1,7 @@ import type { Arguments } from 'yargs'; -import { POSTHOG_DOCS_URL } from '@lib/constants'; -import { runWizard, runWizardCI } from '@lib/runners'; -import { createSkillProgram } from '@lib/programs/agent-skill/index'; +import { POSTHOG_DOCS_URL } from '@store/shared/constants'; +import { runWizard, runWizardCI } from '../../runners/index.js'; +import { createSkillProgram } from '@store/programs/agent-skill'; /** Run an arbitrary context-mill skill by id (`wizard skill `, headless with `--ci`). */ export function runSkillMode(argv: Arguments): void { diff --git a/src/commands/cli/__tests__/add.test.ts b/src/cli/commands/cli/__tests__/add.test.ts similarity index 92% rename from src/commands/cli/__tests__/add.test.ts rename to src/cli/commands/cli/__tests__/add.test.ts index 44f3914cd..a5a24e72d 100644 --- a/src/commands/cli/__tests__/add.test.ts +++ b/src/cli/commands/cli/__tests__/add.test.ts @@ -21,7 +21,7 @@ const { }, })); -vi.mock('@steps/install-cli-steering', () => ({ +vi.mock('@store/services/steps/install-cli-steering', () => ({ CLI_STEERING_TARGETS: [ { id: 'codex', @@ -40,18 +40,18 @@ vi.mock('@steps/install-cli-steering', () => ({ installOrUpdatePostHogCli: mockCliAddInstallOrUpdatePostHogCli, installSteeringSnippet: mockCliAddInstallSteeringSnippet, })); -vi.mock('@ui', () => ({ +vi.mock('@store/ui', () => ({ getUI: () => mockCliAddUi, setUI: mockCliAddSetUI, })); -vi.mock('@ui/tui/console/logging-ui', () => ({ +vi.mock('@tui/console/logging-ui', () => ({ LoggingUI: vi.fn(), })); -vi.mock('@utils/analytics', () => ({ +vi.mock('@store/shared/analytics', () => ({ analytics: { wizardCapture: mockCliAddWizardCapture }, })); -import { cliAddCommand } from '../add'; +import { cliAddCommand } from '../add.js'; describe('cli add command', () => { const originalExit = process.exit; diff --git a/src/commands/cli/add.ts b/src/cli/commands/cli/add.ts similarity index 96% rename from src/commands/cli/add.ts rename to src/cli/commands/cli/add.ts index e500d7044..b816e832d 100644 --- a/src/commands/cli/add.ts +++ b/src/cli/commands/cli/add.ts @@ -1,9 +1,9 @@ import * as path from 'node:path'; import * as readline from 'node:readline/promises'; import type { Arguments } from 'yargs'; -import { getUI, setUI } from '@ui'; -import { LoggingUI } from '@ui/tui/console/logging-ui'; -import { analytics } from '@utils/analytics'; +import { getUI, setUI } from '@store/ui'; +import { LoggingUI } from '@tui/console/logging-ui'; +import { analytics } from '@store/shared/analytics'; import { CLI_STEERING_TARGETS, type CliSteeringTarget, @@ -11,8 +11,8 @@ import { findTarget, installOrUpdatePostHogCli, installSteeringSnippet, -} from '@steps/install-cli-steering'; -import type { Command } from '../command'; +} from '@store/services/steps/install-cli-steering'; +import type { Command } from '../command.js'; export const cliAddCommand: Command = { name: 'add', diff --git a/src/commands/cli/index.ts b/src/cli/commands/cli/index.ts similarity index 61% rename from src/commands/cli/index.ts rename to src/cli/commands/cli/index.ts index 8e06b39ce..f44b3d7ac 100644 --- a/src/commands/cli/index.ts +++ b/src/cli/commands/cli/index.ts @@ -1,5 +1,5 @@ -import { cliAddCommand } from './add'; -import type { Command } from '../command'; +import { cliAddCommand } from './add.js'; +import type { Command } from '../command.js'; export const cliCommand: Command = { name: 'cli', diff --git a/src/commands/command.ts b/src/cli/commands/command.ts similarity index 98% rename from src/commands/command.ts rename to src/cli/commands/command.ts index 4f7c4c1ca..d7fe4b338 100644 --- a/src/commands/command.ts +++ b/src/cli/commands/command.ts @@ -5,7 +5,7 @@ import type { Options, PositionalOptions, } from 'yargs'; -import { setEntryCommand } from '@utils/links'; +import { setEntryCommand } from '@store/shared/links'; export interface Command { /** Yargs command name. Use `['$0']` for the default command. */ diff --git a/src/commands/doctor.ts b/src/cli/commands/doctor.ts similarity index 82% rename from src/commands/doctor.ts rename to src/cli/commands/doctor.ts index a663eaad2..36598c711 100644 --- a/src/commands/doctor.ts +++ b/src/cli/commands/doctor.ts @@ -1,16 +1,16 @@ -import { getUI, setUI } from '@ui'; -import { LoggingUI } from '@ui/tui/console/logging-ui'; -import { readApiKeyFromEnv } from '@utils/env-api-key'; -import { ErrorCodes } from '@lib/errors'; -import { emitWizardError } from '@lib/errors'; -import { runWizard } from '@lib/runners'; +import { getUI, setUI } from '@store/ui'; +import { LoggingUI } from '@tui/console/logging-ui'; +import { readApiKeyFromEnv } from '@store/shared/env-api-key'; +import { ErrorCodes } from '@store/shared/errors'; +import { emitWizardError } from '@store/shared/errors'; +import { runWizard } from '../runners/index.js'; import { posthogDoctorConfig, fetchHealthIssues, getKindMeta, -} from '@lib/programs/posthog-doctor/index'; -import { skillProgramOptions } from './skill-program-options'; -import type { Command } from './command'; +} from '@store/programs/posthog-doctor'; +import { skillProgramOptions } from './skill-program-options.js'; +import type { Command } from './command.js'; export const doctorCommand: Command = { name: 'doctor', @@ -53,7 +53,9 @@ async function runDoctorCI(options: Record): Promise { getUI().log.info('Running posthog-doctor in CI mode'); try { - const { getOrAskForProjectData } = await import('@utils/setup-utils'); + const { getOrAskForProjectData } = await import( + '@store/shared/setup-utils' + ); const { host, accessToken, projectId } = await getOrAskForProjectData({ signup: false, ci: true, @@ -87,7 +89,7 @@ async function runDoctorCI(options: Record): Promise { } process.exit(1); } catch (error) { - const { ApiError } = await import('@lib/api'); + const { ApiError } = await import('@store/api'); const message = error instanceof ApiError && error.statusCode === 401 ? 'Your PostHog API key is invalid or expired.' diff --git a/src/commands/error-tracking.ts b/src/cli/commands/error-tracking.ts similarity index 81% rename from src/commands/error-tracking.ts rename to src/cli/commands/error-tracking.ts index 3db0b2816..17edfc1c4 100644 --- a/src/commands/error-tracking.ts +++ b/src/cli/commands/error-tracking.ts @@ -1,7 +1,7 @@ -import { errorTrackingConfig } from '@lib/programs/error-tracking/index'; +import { errorTrackingConfig } from '@store/programs/error-tracking'; -import type { Command } from './command'; -import { nativeCommandFactory } from './factories/native-command-factory'; +import type { Command } from './command.js'; +import { nativeCommandFactory } from './factories/native-command-factory.js'; /** * `wizard error-tracking` — flat skill command, set up error tracking today. diff --git a/src/commands/factories/__tests__/family-picker.test.ts b/src/cli/commands/factories/__tests__/family-picker.test.ts similarity index 97% rename from src/commands/factories/__tests__/family-picker.test.ts rename to src/cli/commands/factories/__tests__/family-picker.test.ts index f2faf5dfb..92ae2fe04 100644 --- a/src/commands/factories/__tests__/family-picker.test.ts +++ b/src/cli/commands/factories/__tests__/family-picker.test.ts @@ -10,13 +10,13 @@ vi.mock('ink', async (importOriginal) => { import { render } from 'ink'; -import type { Command } from '../../command'; -import { auditCommand } from '../../audit'; +import type { Command } from '../../command.js'; +import { auditCommand } from '../../audit.js'; import { chooseFamilyChild, createFamilyPickerDefault, orderFamilyChildren, -} from '../family-picker'; +} from '@tui/family-picker'; function makeArgv(extras: Record = {}): Arguments { return { _: [], $0: 'wizard', ...extras } as Arguments; diff --git a/src/commands/factories/__tests__/native-command-factory.test.ts b/src/cli/commands/factories/__tests__/native-command-factory.test.ts similarity index 94% rename from src/commands/factories/__tests__/native-command-factory.test.ts rename to src/cli/commands/factories/__tests__/native-command-factory.test.ts index 9539cc3bd..42abb8e82 100644 --- a/src/commands/factories/__tests__/native-command-factory.test.ts +++ b/src/cli/commands/factories/__tests__/native-command-factory.test.ts @@ -3,16 +3,16 @@ const { mockRunWizard, mockRunWizardCI } = vi.hoisted(() => ({ mockRunWizardCI: vi.fn(), })); -vi.mock('@lib/runners', () => ({ +vi.mock('../../../runners/index.js', () => ({ runWizard: mockRunWizard, runWizardCI: mockRunWizardCI, })); import type { Arguments } from 'yargs'; -import type { ProgramConfig } from '@lib/programs/program-step'; +import type { ProgramConfig } from '@store/programs/program-step'; -import { nativeCommandFactory } from '../native-command-factory'; +import { nativeCommandFactory } from '../native-command-factory.js'; function makeArgv(extra: Record = {}): Arguments { return { _: [], $0: 'wizard', ...extra } as Arguments; diff --git a/src/commands/factories/family-command-factory.ts b/src/cli/commands/factories/family-command-factory.ts similarity index 91% rename from src/commands/factories/family-command-factory.ts rename to src/cli/commands/factories/family-command-factory.ts index 3fea1c7ea..5510eff56 100644 --- a/src/commands/factories/family-command-factory.ts +++ b/src/cli/commands/factories/family-command-factory.ts @@ -1,17 +1,17 @@ import type { Arguments } from 'yargs'; -import type { ProgramConfig } from '@lib/programs/program-step'; +import type { ProgramConfig } from '@store/programs/program-step'; import { buildFamilyPickerChildren, dispatchFamily, pickerChildrenToShow, -} from '@lib/programs/dispatch-family'; -import { getSkillsBaseUrl } from '@lib/constants'; -import { fetchSkillMenu } from '@lib/wizard-tools'; +} from '@store/programs/dispatch-family'; +import { getSkillsBaseUrl } from '@store/shared/constants'; +import { fetchSkillMenu } from '@store/tools'; -import type { Command } from '../command'; -import { createFamilyPickerDefault } from './family-picker'; -import { mergeCommandOptions, runCommandHandler } from './shared'; +import type { Command } from '../command.js'; +import { createFamilyPickerDefault } from '@tui/family-picker'; +import { mergeCommandOptions, runCommandHandler } from './shared.js'; export interface FamilyCommandFactoryOpts { /** The family's CLI name (e.g. 'audit'). */ diff --git a/src/commands/factories/native-command-factory.ts b/src/cli/commands/factories/native-command-factory.ts similarity index 83% rename from src/commands/factories/native-command-factory.ts rename to src/cli/commands/factories/native-command-factory.ts index d9fd65a22..385cb0187 100644 --- a/src/commands/factories/native-command-factory.ts +++ b/src/cli/commands/factories/native-command-factory.ts @@ -1,8 +1,8 @@ -import type { ProgramConfig } from '@lib/programs/program-step'; +import type { ProgramConfig } from '@store/programs/program-step'; -import type { Command } from '../command'; +import type { Command } from '../command.js'; -import { dispatchProgram, mergeCommandOptions } from './shared'; +import { dispatchProgram, mergeCommandOptions } from './shared.js'; export interface NativeCommandFactoryOpts { /** Subcommands nested under this command. */ diff --git a/src/commands/factories/shared.ts b/src/cli/commands/factories/shared.ts similarity index 84% rename from src/commands/factories/shared.ts rename to src/cli/commands/factories/shared.ts index 0cda49719..180880c39 100644 --- a/src/commands/factories/shared.ts +++ b/src/cli/commands/factories/shared.ts @@ -1,12 +1,16 @@ import type { Arguments, Options } from 'yargs'; -import { runWizard, runWizardCI, runWizardHeadless } from '@lib/runners'; -import { isHeadless } from '@lib/headless-mode'; -import type { ProgramConfig } from '@lib/programs/program-step'; +import { + runWizard, + runWizardCI, + runWizardHeadless, +} from '../../runners/index.js'; +import { isHeadless } from '../../headless-mode.js'; +import type { ProgramConfig } from '@store/programs/program-step'; -import { skillProgramOptions } from '../skill-program-options'; -import { ErrorCodes } from '@lib/errors'; -import { emitWizardError } from '@lib/errors'; +import { skillProgramOptions } from '../skill-program-options.js'; +import { ErrorCodes } from '@store/shared/errors'; +import { emitWizardError } from '@store/shared/errors'; /** * Dispatch a parsed yargs invocation to the wizard runner. Applies the diff --git a/src/commands/mcp-analytics.ts b/src/cli/commands/mcp-analytics.ts similarity index 79% rename from src/commands/mcp-analytics.ts rename to src/cli/commands/mcp-analytics.ts index 6d49b114e..47a0bf9e5 100644 --- a/src/commands/mcp-analytics.ts +++ b/src/cli/commands/mcp-analytics.ts @@ -1,7 +1,7 @@ -import { mcpAnalyticsConfig } from '@lib/programs/mcp-analytics/index'; +import { mcpAnalyticsConfig } from '@store/programs/mcp-analytics'; -import type { Command } from './command'; -import { nativeCommandFactory } from './factories/native-command-factory'; +import type { Command } from './command.js'; +import { nativeCommandFactory } from './factories/native-command-factory.js'; /** * `wizard mcp-analytics` — flat skill command, instrument-an-MCP-server today. diff --git a/src/commands/mcp/add.ts b/src/cli/commands/mcp/add.ts similarity index 81% rename from src/commands/mcp/add.ts rename to src/cli/commands/mcp/add.ts index 49c91827b..8ede1cd65 100644 --- a/src/commands/mcp/add.ts +++ b/src/cli/commands/mcp/add.ts @@ -1,11 +1,11 @@ import type { Arguments } from 'yargs'; -import { setUI } from '@ui'; -import { LoggingUI } from '@ui/tui/console/logging-ui'; -import { headlessOption, isHeadless } from '@lib/headless-mode'; -import { Program } from '@lib/programs/program-registry'; -import { VERSION } from '@lib/version'; -import type { Command } from '../command'; -import { isTUIUnavailable } from './tui-availability'; +import { setUI } from '@store/ui'; +import { LoggingUI } from '@tui/console/logging-ui'; +import { headlessOption, isHeadless } from '../../headless-mode.js'; +import { Program } from '@store/programs/program-registry'; +import { VERSION } from '@store/shared/version'; +import type { Command } from '../command.js'; +import { isTUIUnavailable } from './tui-availability.js'; export const mcpAddCommand: Command = { name: 'add', @@ -34,7 +34,7 @@ export const mcpAddCommand: Command = { function runMcpAdd(argv: Arguments): void { const features = parseFeatures(argv.features); void (async () => { - const { readApiKeyFromEnv } = await import('@utils/env-api-key'); + const { readApiKeyFromEnv } = await import('@store/shared/env-api-key'); const apiKey = (argv.apiKey as string | undefined) || readApiKeyFromEnv(); const debug = argv.debug as boolean | undefined; const localMcp = argv.local as boolean | undefined; @@ -50,8 +50,8 @@ function runMcpAdd(argv: Arguments): void { } try { - const { startTUI } = await import('@ui/tui/start-tui'); - const { buildSession } = await import('@lib/wizard-session'); + const { startTUI } = await import('@tui/start-tui'); + const { buildSession } = await import('@store/session/wizard-session'); const tui = startTUI(VERSION, Program.McpAdd); tui.store.session = buildSession({ debug, @@ -74,7 +74,7 @@ async function runHeadlessAdd(args: { }): Promise { setUI(new LoggingUI()); const { addMCPServerToClientsStep } = await import( - '@steps/add-mcp-server-to-clients/index' + '@store/services/steps/add-mcp-server-to-clients' ); // Never forwards `ci`: headless implies session.ci elsewhere, and the step // reads that as "skip MCP entirely" — the opposite of what we're here to do. diff --git a/src/cli/commands/mcp/index.ts b/src/cli/commands/mcp/index.ts new file mode 100644 index 000000000..dbe8ce792 --- /dev/null +++ b/src/cli/commands/mcp/index.ts @@ -0,0 +1,10 @@ +import { mcpAddCommand } from './add.js'; +import { mcpRemoveCommand } from './remove.js'; +import { mcpTutorialCommand } from './tutorial.js'; +import type { Command } from '../command.js'; + +export const mcpCommand: Command = { + name: 'mcp', + description: 'MCP server management commands', + children: [mcpAddCommand, mcpRemoveCommand, mcpTutorialCommand], +}; diff --git a/src/commands/mcp/remove.ts b/src/cli/commands/mcp/remove.ts similarity index 74% rename from src/commands/mcp/remove.ts rename to src/cli/commands/mcp/remove.ts index 47ea3dddc..f063b31ff 100644 --- a/src/commands/mcp/remove.ts +++ b/src/cli/commands/mcp/remove.ts @@ -1,11 +1,11 @@ import type { Arguments } from 'yargs'; -import { setUI } from '@ui'; -import { LoggingUI } from '@ui/tui/console/logging-ui'; -import { headlessOption, isHeadless } from '@lib/headless-mode'; -import { Program } from '@lib/programs/program-registry'; -import { VERSION } from '@lib/version'; -import type { Command } from '../command'; -import { isTUIUnavailable } from './tui-availability'; +import { setUI } from '@store/ui'; +import { LoggingUI } from '@tui/console/logging-ui'; +import { headlessOption, isHeadless } from '../../headless-mode.js'; +import { Program } from '@store/programs/program-registry'; +import { VERSION } from '@store/shared/version'; +import type { Command } from '../command.js'; +import { isTUIUnavailable } from './tui-availability.js'; export const mcpRemoveCommand: Command = { name: 'remove', @@ -35,8 +35,8 @@ function runMcpRemove(argv: Arguments): void { } try { - const { startTUI } = await import('@ui/tui/start-tui'); - const { buildSession } = await import('@lib/wizard-session'); + const { startTUI } = await import('@tui/start-tui'); + const { buildSession } = await import('@store/session/wizard-session'); const tui = startTUI(VERSION, Program.McpRemove); tui.store.session = buildSession({ debug, @@ -56,7 +56,7 @@ function runMcpRemove(argv: Arguments): void { async function runHeadlessRemove(local?: boolean): Promise { setUI(new LoggingUI()); const { removeMCPServerFromClientsStep } = await import( - '@steps/add-mcp-server-to-clients/index' + '@store/services/steps/add-mcp-server-to-clients' ); await removeMCPServerFromClientsStep({ local }); } diff --git a/src/commands/mcp/tui-availability.ts b/src/cli/commands/mcp/tui-availability.ts similarity index 100% rename from src/commands/mcp/tui-availability.ts rename to src/cli/commands/mcp/tui-availability.ts diff --git a/src/commands/mcp/tutorial.ts b/src/cli/commands/mcp/tutorial.ts similarity index 71% rename from src/commands/mcp/tutorial.ts rename to src/cli/commands/mcp/tutorial.ts index 5f300e07f..bfbaa0a2c 100644 --- a/src/commands/mcp/tutorial.ts +++ b/src/cli/commands/mcp/tutorial.ts @@ -1,11 +1,11 @@ import type { Arguments } from 'yargs'; -import { getUI, setUI } from '@ui'; -import { LoggingUI } from '@ui/tui/console/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 type { Command } from '../command'; +import { getUI, setUI } from '@store/ui'; +import { LoggingUI } from '@tui/console/logging-ui'; +import { Program } from '@store/programs/program-registry'; +import { VERSION } from '@store/shared/version'; +import { ErrorCodes } from '@store/shared/errors'; +import { emitWizardError } from '@store/shared/errors'; +import type { Command } from '../command.js'; export const mcpTutorialCommand: Command = { name: 'tutorial', @@ -27,8 +27,8 @@ function runMcpTutorial(argv: Arguments): void { const localMcp = argv.local as boolean | undefined; try { - const { startTUI } = await import('@ui/tui/start-tui'); - const { buildSession } = await import('@lib/wizard-session'); + const { startTUI } = await import('@tui/start-tui'); + const { buildSession } = await import('@store/session/wizard-session'); const tui = startTUI(VERSION, Program.McpTutorial); tui.store.session = buildSession({ debug, diff --git a/src/commands/metrics.ts b/src/cli/commands/metrics.ts similarity index 84% rename from src/commands/metrics.ts rename to src/cli/commands/metrics.ts index a889bd24c..51be1cb02 100644 --- a/src/commands/metrics.ts +++ b/src/cli/commands/metrics.ts @@ -1,7 +1,7 @@ -import { metricsConfig } from '@lib/programs/metrics/index'; +import { metricsConfig } from '@store/programs/metrics'; -import type { Command } from './command'; -import { nativeCommandFactory } from './factories/native-command-factory'; +import type { Command } from './command.js'; +import { nativeCommandFactory } from './factories/native-command-factory.js'; /** * `wizard metrics` — flat skill command, wire PostHog application metrics diff --git a/src/commands/migrate.ts b/src/cli/commands/migrate.ts similarity index 83% rename from src/commands/migrate.ts rename to src/cli/commands/migrate.ts index e7389efcf..f80732df1 100644 --- a/src/commands/migrate.ts +++ b/src/cli/commands/migrate.ts @@ -1,7 +1,7 @@ -import { migrationConfig } from '@lib/programs/migration/index'; +import { migrationConfig } from '@store/programs/migration'; -import type { Command } from './command'; -import { nativeCommandFactory } from './factories/native-command-factory'; +import type { Command } from './command.js'; +import { nativeCommandFactory } from './factories/native-command-factory.js'; /** * `wizard migrate` — flat skill command, Statsig today. diff --git a/src/commands/provision.ts b/src/cli/commands/provision.ts similarity index 91% rename from src/commands/provision.ts rename to src/cli/commands/provision.ts index a113e8829..4db3d4f7e 100644 --- a/src/commands/provision.ts +++ b/src/cli/commands/provision.ts @@ -1,8 +1,8 @@ import type { Arguments } from 'yargs'; -import { getUI, setUI } from '@ui'; -import { LoggingUI } from '@ui/tui/console/logging-ui'; -import type { ProvisioningResult } from '@utils/provisioning'; -import type { Command } from './command'; +import { getUI, setUI } from '@store/ui'; +import { LoggingUI } from '@tui/console/logging-ui'; +import type { ProvisioningResult } from '@store/shared/provisioning'; +import type { Command } from './command.js'; export const provisionCommand: Command = { name: 'provision', @@ -66,7 +66,7 @@ async function provision({ jsonMode, }: ProvisionArgs): Promise { try { - const { provisionNewAccount } = await import('@utils/provisioning'); + const { provisionNewAccount } = await import('@store/shared/provisioning'); if (!jsonMode) { getUI().log.info(`Provisioning account for ${email} in ${region}...`); } diff --git a/src/commands/replay-vision.ts b/src/cli/commands/replay-vision.ts similarity index 79% rename from src/commands/replay-vision.ts rename to src/cli/commands/replay-vision.ts index 10e8e2db9..6d1881c69 100644 --- a/src/commands/replay-vision.ts +++ b/src/cli/commands/replay-vision.ts @@ -1,7 +1,7 @@ -import { replayVisionConfig } from '@lib/programs/replay-vision/index'; +import { replayVisionConfig } from '@store/programs/replay-vision'; -import type { Command } from './command'; -import { nativeCommandFactory } from './factories/native-command-factory'; +import type { Command } from './command.js'; +import { nativeCommandFactory } from './factories/native-command-factory.js'; /** * `wizard replay-vision` — flat skill command, set up Replay vision today. diff --git a/src/commands/revenue.ts b/src/cli/commands/revenue.ts similarity index 71% rename from src/commands/revenue.ts rename to src/cli/commands/revenue.ts index a41f6af09..d6ce5dda2 100644 --- a/src/commands/revenue.ts +++ b/src/cli/commands/revenue.ts @@ -1,7 +1,7 @@ -import { revenueAnalyticsConfig } from '@lib/programs/revenue-analytics/index'; +import { revenueAnalyticsConfig } from '@store/programs/revenue-analytics'; -import type { Command } from './command'; -import { nativeCommandFactory } from './factories/native-command-factory'; +import type { Command } from './command.js'; +import { nativeCommandFactory } from './factories/native-command-factory.js'; /** * `wizard revenue-analytics` — flat skill command, Stripe today. diff --git a/src/commands/self-driving.ts b/src/cli/commands/self-driving.ts similarity index 87% rename from src/commands/self-driving.ts rename to src/cli/commands/self-driving.ts index 5f38f40e4..7382d4d73 100644 --- a/src/commands/self-driving.ts +++ b/src/cli/commands/self-driving.ts @@ -1,7 +1,7 @@ -import { runWizard, runWizardCI } from '@lib/runners'; -import { selfDrivingConfig } from '@lib/programs/self-driving/index'; -import { skillProgramOptions } from './skill-program-options'; -import type { Command } from './command'; +import { runWizard, runWizardCI } from '../runners/index.js'; +import { selfDrivingConfig } from '@store/programs/self-driving'; +import { skillProgramOptions } from './skill-program-options.js'; +import type { Command } from './command.js'; export const selfDrivingCommand: Command = { name: 'self-driving', diff --git a/src/commands/skill-program-options.ts b/src/cli/commands/skill-program-options.ts similarity index 100% rename from src/commands/skill-program-options.ts rename to src/cli/commands/skill-program-options.ts diff --git a/src/commands/skill.ts b/src/cli/commands/skill.ts similarity index 91% rename from src/commands/skill.ts rename to src/cli/commands/skill.ts index 102eff5f8..e2885b025 100644 --- a/src/commands/skill.ts +++ b/src/cli/commands/skill.ts @@ -1,15 +1,15 @@ import type { Arguments } from 'yargs'; -import { getSkillsBaseUrl } from '@lib/constants'; -import { fetchSkillMenu, type CliEntry } from '@lib/wizard-tools'; -import { analytics } from '@utils/analytics'; +import { getSkillsBaseUrl } from '@store/shared/constants'; +import { fetchSkillMenu, type CliEntry } from '@store/tools'; +import { analytics } from '@store/shared/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 type { Command } from './command'; +import { runSkillMode } from './basic-integration/skill.js'; +import { skillProgramOptions } from './skill-program-options.js'; +import { runCommandHandler } from './factories/shared.js'; +import { ErrorCodes } from '@store/shared/errors'; +import { emitWizardError } from '@store/shared/errors'; +import type { Command } from './command.js'; /** Read the `` positional (yargs camelCases the hyphenated key). */ function readSkillName(argv: Arguments): string { diff --git a/src/commands/slack.ts b/src/cli/commands/slack.ts similarity index 71% rename from src/commands/slack.ts rename to src/cli/commands/slack.ts index 1b7f3735f..028a487d8 100644 --- a/src/commands/slack.ts +++ b/src/cli/commands/slack.ts @@ -1,11 +1,11 @@ import type { Arguments } from 'yargs'; -import { getUI, setUI } from '@ui'; -import { LoggingUI } from '@ui/tui/console/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 type { Command } from './command'; +import { getUI, setUI } from '@store/ui'; +import { LoggingUI } from '@tui/console/logging-ui'; +import { Program } from '@store/programs/program-registry'; +import { VERSION } from '@store/shared/version'; +import { ErrorCodes } from '@store/shared/errors'; +import { emitWizardError } from '@store/shared/errors'; +import type { Command } from './command.js'; export const slackCommand: Command = { name: 'slack', @@ -27,8 +27,8 @@ function runSlackConnect(argv: Arguments): void { const debug = argv.debug as boolean | undefined; try { - const { startTUI } = await import('@ui/tui/start-tui'); - const { buildSession } = await import('@lib/wizard-session'); + const { startTUI } = await import('@tui/start-tui'); + const { buildSession } = await import('@store/session/wizard-session'); const tui = startTUI(VERSION, Program.SlackConnect); tui.store.session = buildSession({ debug, diff --git a/src/commands/upload-sourcemaps.ts b/src/cli/commands/upload-sourcemaps.ts similarity index 73% rename from src/commands/upload-sourcemaps.ts rename to src/cli/commands/upload-sourcemaps.ts index 22e6f96c1..bf70c078f 100644 --- a/src/commands/upload-sourcemaps.ts +++ b/src/cli/commands/upload-sourcemaps.ts @@ -1,7 +1,7 @@ -import { runWizard, runWizardCI } from '@lib/runners'; -import { errorTrackingUploadSourceMapsConfig } from '@lib/programs/error-tracking-upload-source-maps/index'; -import { skillProgramOptions } from './skill-program-options'; -import type { Command } from './command'; +import { runWizard, runWizardCI } from '../runners/index.js'; +import { errorTrackingUploadSourceMapsConfig } from '@store/programs/error-tracking-upload-source-maps'; +import { skillProgramOptions } from './skill-program-options.js'; +import type { Command } from './command.js'; export const uploadSourcemapsCommand: Command = { // Must match ProgramConfig.command; legacy alias kept for #489 regression. diff --git a/src/commands/warehouse.ts b/src/cli/commands/warehouse.ts similarity index 71% rename from src/commands/warehouse.ts rename to src/cli/commands/warehouse.ts index b6c53e0df..a203dd74e 100644 --- a/src/commands/warehouse.ts +++ b/src/cli/commands/warehouse.ts @@ -1,7 +1,7 @@ -import { warehouseSourceConfig } from '@lib/programs/warehouse-source/index'; +import { warehouseSourceConfig } from '@store/programs/warehouse-source'; -import type { Command } from './command'; -import { nativeCommandFactory } from './factories/native-command-factory'; +import type { Command } from './command.js'; +import { nativeCommandFactory } from './factories/native-command-factory.js'; /** * `wizard warehouse` — detect and connect a data warehouse source. diff --git a/src/lib/headless-mode.ts b/src/cli/headless-mode.ts similarity index 97% rename from src/lib/headless-mode.ts rename to src/cli/headless-mode.ts index 20f3c4f05..4925e83c1 100644 --- a/src/lib/headless-mode.ts +++ b/src/cli/headless-mode.ts @@ -16,12 +16,13 @@ */ import type { Options } from 'yargs'; +import { HEADLESS_FLAG } from '@env'; /** * The on-CLI flag name. Intentionally ugly + undocumented; do not surface it in * `--help`, the README, or user-facing error messages. */ -export const HEADLESS_FLAG = 'headless-DONOTUSE-EXPERIMENTAL'; +export { HEADLESS_FLAG }; /** * The yargs option declaration for the headless flag. Declared per-command diff --git a/src/lib/runners/__tests__/mint-recovery.test.ts b/src/cli/runners/__tests__/mint-recovery.test.ts similarity index 71% rename from src/lib/runners/__tests__/mint-recovery.test.ts rename to src/cli/runners/__tests__/mint-recovery.test.ts index fc5fe36b3..142f2b74b 100644 --- a/src/lib/runners/__tests__/mint-recovery.test.ts +++ b/src/cli/runners/__tests__/mint-recovery.test.ts @@ -1,25 +1,25 @@ import { vi, it, expect, afterEach } from 'vitest'; -import { runWizard } from '../run-wizard'; -import { runAgent } from '@lib/agent/agent-runner'; -import { startTUI } from '@ui/tui/start-tui'; -import { WizardStore } from '@ui/tui/store'; -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 { analytics } from '@utils/analytics'; -import { flowFor } from '@lib/programs/flow-for'; -import { Program } from '@lib/programs/program-registry'; +import { runWizard } from '../run-wizard.js'; +import { runAgent } from '@agent/agent-runner'; +import { startTUI } from '@tui/start-tui'; +import { WizardStore } from '@store/state/store'; +import { InkUI } from '@tui/ink-ui'; +import { setUI } from '@store/ui'; +import { posthogIntegrationConfig } from '@store/programs/posthog-integration'; +import { ScreenId } from '@tui/router'; +import { HostResolution } from '@store/host-resolution'; +import { analytics } from '@store/shared/analytics'; +import { flowFor } from '@store/programs/flow-for'; +import { Program } from '@store/programs/program-registry'; -vi.mock('@lib/agent/agent-runner', () => ({ runAgent: vi.fn() })); -vi.mock('@ui/tui/start-tui', () => ({ startTUI: vi.fn() })); -vi.mock('@lib/local-dev', async (original) => ({ - ...(await original()), +vi.mock('@agent/agent-runner', () => ({ runAgent: vi.fn() })); +vi.mock('@tui/start-tui', () => ({ startTUI: vi.fn() })); +vi.mock('@store/local-dev', async (original) => ({ + ...(await original()), getLocalDev: () => ({}), checkLocalServices: () => Promise.resolve(null), })); -vi.mock('@utils/analytics', () => ({ +vi.mock('@store/shared/analytics', () => ({ analytics: { wizardCapture: vi.fn(), capture: vi.fn(), @@ -29,7 +29,7 @@ vi.mock('@utils/analytics', () => ({ }, sessionProperties: () => ({}), })); -vi.mock('@lib/task-stream/index', () => ({ +vi.mock('@store/task-stream', () => ({ TaskStreamPush: class { attach = vi.fn(); shutdown() { @@ -37,7 +37,7 @@ vi.mock('@lib/task-stream/index', () => ({ } }, })); -vi.mock('@lib/task-stream/destinations/posthog', () => ({ +vi.mock('@store/task-stream/destinations/posthog', () => ({ PostHogDestination: class {}, })); diff --git a/src/cli/runners/index.ts b/src/cli/runners/index.ts new file mode 100644 index 000000000..2a2412700 --- /dev/null +++ b/src/cli/runners/index.ts @@ -0,0 +1,5 @@ +export { runWizard } from './run-wizard.js'; +export { runWizardCI } from './run-wizard-ci.js'; +export { runWizardHeadless } from './run-wizard-headless.js'; +export { API_KEY_HINT } from './run-non-interactive.js'; +export type { NonInteractiveMode } from './run-non-interactive.js'; diff --git a/src/lib/runners/resolve-no-telemetry.ts b/src/cli/runners/resolve-no-telemetry.ts similarity index 100% rename from src/lib/runners/resolve-no-telemetry.ts rename to src/cli/runners/resolve-no-telemetry.ts diff --git a/src/lib/runners/run-non-interactive.ts b/src/cli/runners/run-non-interactive.ts similarity index 89% rename from src/lib/runners/run-non-interactive.ts rename to src/cli/runners/run-non-interactive.ts index f017065a8..4f5d43341 100644 --- a/src/lib/runners/run-non-interactive.ts +++ b/src/cli/runners/run-non-interactive.ts @@ -1,28 +1,35 @@ -import { POSTHOG_DOCS_URL, type Harness, type Sequence } from '@lib/constants'; +import { + POSTHOG_DOCS_URL, + type Harness, + type Sequence, +} from '@store/shared/constants'; import { checkLocalServices, getLocalDev, POSTHOG_LOCAL_URL, -} from '@lib/local-dev'; -import type { CloudRegion } from '@utils/types'; -import { getUI, setUI } from '@ui'; -import { LoggingUI } from '@ui/tui/console/logging-ui'; -import type { ProgramConfig } from '@lib/programs/program-step'; -import { runConfigFor } from '@lib/programs/run-config'; -import { getAuditChecks } from '@lib/programs/audit/types'; -import { analytics } from '@utils/analytics'; -import { resolveNoTelemetry } from './resolve-no-telemetry'; -import type { WizardStore } from '@ui/tui/store'; -import type { TaskStreamPush } from '@lib/task-stream/task-stream-push'; +} from '@store/local-dev'; +import type { CloudRegion } from '@store/shared/types'; +import { getUI, setUI } from '@store/ui'; +import { LoggingUI } from '@tui/console/logging-ui'; +import type { ProgramConfig } from '@store/programs/program-step'; +import { runConfigFor } from '@store/programs/run-config'; +import { getAuditChecks } from '@store/programs/audit/types'; +import { analytics } from '@store/shared/analytics'; +import { resolveNoTelemetry } from './resolve-no-telemetry.js'; +import type { WizardStore } from '@store/state/store'; +import type { TaskStreamPush } from '@store/task-stream/task-stream-push'; import { join } from 'node:path'; import { ErrorCodes, classifyRunFailure, detectErrorCode, emitWizardError, -} from '@lib/errors'; -import type { OutroData, RunPhase as RunPhaseT } from '@lib/wizard-session'; -import { flowFor } from '@lib/programs/flow-for'; +} from '@store/shared/errors'; +import type { + OutroData, + RunPhase as RunPhaseT, +} from '@store/session/wizard-session'; +import { flowFor } from '@store/programs/flow-for'; /** * The two non-interactive run modes. Both drive the same pipeline today; the @@ -106,14 +113,16 @@ export function runNonInteractive( void (async () => { const path = await import('path'); const { buildSession, RunPhase, OutroKind } = await import( - '@lib/wizard-session' + '@store/session/wizard-session' ); - const { readEnvironment } = await import('@utils/environment'); - const { readApiKeyFromEnv } = await import('@utils/env-api-key'); + const { readEnvironment } = await import('@store/shared/environment'); + const { readApiKeyFromEnv } = await import('@store/shared/env-api-key'); const { configureLogFileFromEnvironment, logToFile } = await import( - '@utils/debug' + '@store/shared/debug' + ); + const { wizardAbort, WizardError } = await import( + '@store/shared/wizard-abort' ); - const { wizardAbort, WizardError } = await import('@utils/wizard-abort'); configureLogFileFromEnvironment(); @@ -182,10 +191,10 @@ export function runNonInteractive( let store: WizardStore | null = null; let taskStream: TaskStreamPush | null = null; { - const { WizardStore } = await import('@ui/tui/store'); - const { HeadlessUI } = await import('@ui/tui/console/headless-ui'); + const { WizardStore } = await import('@store/state/store'); + const { HeadlessUI } = await import('@tui/console/headless-ui'); const { TaskStreamPush, PostHogDestination, createFileDestination } = - await import('@lib/task-stream/index'); + await import('@store/task-stream'); // `''` resolves to the default path, so `--ci` always dumps. const logTarget = @@ -241,7 +250,7 @@ export function runNonInteractive( try { if (mode === 'ci') { const { configureGatewayFromCIEnvironment } = await import( - '@lib/gateway-session' + '@agent/gateway/gateway-session' ); configureGatewayFromCIEnvironment( Number(session.projectId), @@ -337,7 +346,7 @@ export function runNonInteractive( } } - const { runAgent } = await import('@lib/agent/agent-runner'); + const { runAgent } = await import('@agent/agent-runner'); await runAgent(runConfigFor(config), session); await settleStream(RunPhase.Completed); } catch (error) { diff --git a/src/lib/runners/run-wizard-ci.ts b/src/cli/runners/run-wizard-ci.ts similarity index 76% rename from src/lib/runners/run-wizard-ci.ts rename to src/cli/runners/run-wizard-ci.ts index e278bd5f5..2424b8030 100644 --- a/src/lib/runners/run-wizard-ci.ts +++ b/src/cli/runners/run-wizard-ci.ts @@ -1,5 +1,5 @@ -import type { ProgramConfig } from '@lib/programs/program-step'; -import { runNonInteractive } from './run-non-interactive'; +import type { ProgramConfig } from '@store/programs/program-step'; +import { runNonInteractive } from './run-non-interactive.js'; /** * CI-mode entry point (`--ci`, dev/test builds). A thin shell over the shared diff --git a/src/lib/runners/run-wizard-headless.ts b/src/cli/runners/run-wizard-headless.ts similarity index 83% rename from src/lib/runners/run-wizard-headless.ts rename to src/cli/runners/run-wizard-headless.ts index 20916c8eb..02caffb16 100644 --- a/src/lib/runners/run-wizard-headless.ts +++ b/src/cli/runners/run-wizard-headless.ts @@ -1,5 +1,5 @@ -import type { ProgramConfig } from '@lib/programs/program-step'; -import { runNonInteractive } from './run-non-interactive'; +import type { ProgramConfig } from '@store/programs/program-step'; +import { runNonInteractive } from './run-non-interactive.js'; /** * Headless entry point (the experimental published-build, non-interactive run diff --git a/src/lib/runners/run-wizard.ts b/src/cli/runners/run-wizard.ts similarity index 86% rename from src/lib/runners/run-wizard.ts rename to src/cli/runners/run-wizard.ts index 6b4d37a58..1a4314d8d 100644 --- a/src/lib/runners/run-wizard.ts +++ b/src/cli/runners/run-wizard.ts @@ -1,24 +1,24 @@ -import { VERSION } from '@lib/version'; -import { logToFile, getLogFilePath } from '@utils/debug'; -import { runAgent } from '@lib/agent/agent-runner'; -import { authenticate } from '@lib/agent/runner/shared/authenticate'; -import { getProgramConfig } from '@lib/programs/program-registry'; -import { runConfigFor } from '@lib/programs/run-config'; -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 { 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 { runCleanups } from '@utils/wizard-abort'; -import { classifyRunFailure, emitWizardError } from '@lib/errors'; -import { isRunFailure } from '@ui/mint-failure'; -import { getUI } from '@ui'; -import { analytics } from '@utils/analytics'; +import { VERSION } from '@store/shared/version'; +import { logToFile, getLogFilePath } from '@store/shared/debug'; +import { runAgent } from '@agent/agent-runner'; +import { authenticate } from '@agent/runner/shared/authenticate'; +import { getProgramConfig } from '@store/programs/program-registry'; +import { runConfigFor } from '@store/programs/run-config'; +import { getAuditChecks } from '@store/programs/audit/types'; +import { maybeStampAiSdkDetected } from '@store/programs/posthog-integration/detect'; +import type { ProgramConfig } from '@store/programs/program-step'; +import type { Harness, Sequence } from '@store/shared/constants'; +import type { startTUI as StartTUIFn } from '@tui/start-tui'; +import type { WizardStore } from '@store/state/store'; +import { OutroKind, type WizardSession } from '@store/session/wizard-session'; +import type { TaskStreamPush as TaskStreamPushClass } from '@store/task-stream/task-stream-push'; +import { resolveNoTelemetry } from './resolve-no-telemetry.js'; +import { checkLocalServices, getLocalDev } from '@store/local-dev'; +import { runCleanups } from '@store/shared/wizard-abort'; +import { classifyRunFailure, emitWizardError } from '@store/shared/errors'; +import { isRunFailure } from '@tui/mint-failure'; +import { getUI } from '@store/ui'; +import { analytics } from '@store/shared/analytics'; import { join } from 'node:path'; const WIZARD_VERSION = VERSION; @@ -92,14 +92,16 @@ export function runWizard( try { const installDir = (options.installDir as string) || process.cwd(); - const { startTUI } = await import('@ui/tui/start-tui'); - const { buildSession, RunPhase } = await import('@lib/wizard-session'); - const { TaskStreamPush } = await import('@lib/task-stream/index'); + const { startTUI } = await import('@tui/start-tui'); + const { buildSession, RunPhase } = await import( + '@store/session/wizard-session' + ); + const { TaskStreamPush } = await import('@store/task-stream'); const { PostHogDestination } = await import( - '@lib/task-stream/destinations/posthog' + '@store/task-stream/destinations/posthog' ); const { createFileDestination } = await import( - '@lib/task-stream/destinations/file' + '@store/task-stream/destinations/file' ); // Before the TUI mounts: once Ink owns the alt screen, anything written @@ -113,7 +115,7 @@ export function runWizard( localPosthog: local.localPosthog && !options.baseUrl, }); if (localServicesError) { - const { wizardAbort } = await import('@utils/wizard-abort'); + const { wizardAbort } = await import('@store/shared/wizard-abort'); await wizardAbort({ message: localServicesError }); return; } @@ -252,7 +254,9 @@ export function runWizard( if (shown(step)) await advanceStep(step, activeTui.store, config); } } else if (skipAgent) { - const { getOrAskForProjectData } = await import('@utils/setup-utils'); + const { getOrAskForProjectData } = await import( + '@store/shared/setup-utils' + ); const { projectApiKey, host, accessToken, projectId } = await getOrAskForProjectData({ signup: session.signup, diff --git a/src/telemetry.ts b/src/cli/telemetry.ts similarity index 79% rename from src/telemetry.ts rename to src/cli/telemetry.ts index 5d4bc955a..1e5cfb2ec 100644 --- a/src/telemetry.ts +++ b/src/cli/telemetry.ts @@ -1,4 +1,4 @@ -import { analytics } from '@utils/analytics'; +import { analytics } from '@store/shared/analytics'; export function withProgress(step: string, callback: () => T): T { updateProgress(step); diff --git a/src/wizard.ts b/src/cli/wizard.ts similarity index 97% rename from src/wizard.ts rename to src/cli/wizard.ts index 7149cc708..81d3d87ad 100644 --- a/src/wizard.ts +++ b/src/cli/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 { regionOption } from '@lib/headless-mode'; -import { initLocalDev, localMcpSkillsNotice } from '@lib/local-dev'; -import { toCommandModule, type Command } from './commands/command'; -import { ErrorCodes } from '@lib/errors'; -import { emitWizardError } from '@lib/errors'; +import { Harness, Sequence } from '@store/shared/constants'; +import { regionOption } from './headless-mode.js'; +import { initLocalDev, localMcpSkillsNotice } from '@store/local-dev'; +import { toCommandModule, type Command } from './commands/command.js'; +import { ErrorCodes } from '@store/shared/errors'; +import { emitWizardError } from '@store/shared/errors'; /** * Global yargs options applied to every command. These are read from the diff --git a/src/commands/basic-integration/playground.ts b/src/commands/basic-integration/playground.ts deleted file mode 100644 index 61eaaf0fc..000000000 --- a/src/commands/basic-integration/playground.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { VERSION } from '@lib/version'; -import { startPlayground } from '@ui/tui/playground/start-playground'; - -/** Launch the TUI primitives playground. */ -export function runPlayground(): void { - startPlayground(VERSION); -} diff --git a/src/commands/mcp/index.ts b/src/commands/mcp/index.ts deleted file mode 100644 index 24f57079f..000000000 --- a/src/commands/mcp/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { mcpAddCommand } from './add'; -import { mcpRemoveCommand } from './remove'; -import { mcpTutorialCommand } from './tutorial'; -import type { Command } from '../command'; - -export const mcpCommand: Command = { - name: 'mcp', - description: 'MCP server management commands', - children: [mcpAddCommand, mcpRemoveCommand, mcpTutorialCommand], -}; diff --git a/src/env.ts b/src/env.ts index 1c5424c14..8a35cd70a 100644 --- a/src/env.ts +++ b/src/env.ts @@ -15,7 +15,8 @@ * this module instead. */ -import { HEADLESS_FLAG } from '@lib/headless-mode'; +/** The hidden non-interactive flag. Declared here so env reads nothing from a surface. */ +export const HEADLESS_FLAG = 'headless-DONOTUSE-EXPERIMENTAL'; // ── Build-time constants ───────────────────────────────────────────── // tsdown replaces `process.env.NODE_ENV` with a string literal. diff --git a/src/lib/middleware/index.ts b/src/lib/middleware/index.ts deleted file mode 100644 index 070727a8f..000000000 --- a/src/lib/middleware/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Middleware system for wizard agent runs. - */ - -export { MiddlewarePipeline } from './pipeline'; -export { PhaseDetector } from './phase-detector'; -export type { Middleware, MiddlewareContext, MiddlewareStore } from './types'; - -export { loadBenchmarkConfig, getDefaultConfig } from './config'; -export type { BenchmarkConfig } from './config'; - -export { createBenchmarkPipeline } from './benchmark'; -export type { BenchmarkData, StepUsage } from './benchmark'; - -export { createPluginsFromConfig } from './benchmarks'; diff --git a/src/lib/registry.ts b/src/lib/registry.ts deleted file mode 100644 index cd0133aeb..000000000 --- a/src/lib/registry.ts +++ /dev/null @@ -1,59 +0,0 @@ -import type { FrameworkConfig } from './framework-config'; -import { Integration } from './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'; -import { REACT_ROUTER_AGENT_CONFIG } from '@frameworks/react-router/react-router-wizard-agent'; -import { TANSTACK_ROUTER_AGENT_CONFIG } from '@frameworks/tanstack-router/tanstack-router-wizard-agent'; -import { TANSTACK_START_AGENT_CONFIG } from '@frameworks/tanstack-start/tanstack-start-wizard-agent'; -import { REACT_NATIVE_AGENT_CONFIG } from '@frameworks/react-native/react-native-wizard-agent'; -import { ANGULAR_AGENT_CONFIG } from '@frameworks/angular/angular-wizard-agent'; -import { ASTRO_AGENT_CONFIG } from '@frameworks/astro/astro-wizard-agent'; -import { DJANGO_AGENT_CONFIG } from '@frameworks/django/django-wizard-agent'; -import { FLASK_AGENT_CONFIG } from '@frameworks/flask/flask-wizard-agent'; -import { FASTAPI_AGENT_CONFIG } from '@frameworks/fastapi/fastapi-wizard-agent'; -import { LARAVEL_AGENT_CONFIG } from '@frameworks/laravel/laravel-wizard-agent'; -import { SVELTEKIT_AGENT_CONFIG } from '@frameworks/svelte/svelte-wizard-agent'; -import { FLUTTER_AGENT_CONFIG } from '@frameworks/flutter/flutter-wizard-agent'; -import { SWIFT_AGENT_CONFIG } from '@frameworks/swift/swift-wizard-agent'; -import { KMP_AGENT_CONFIG } from '@frameworks/kmp/kmp-wizard-agent'; -import { ANDROID_AGENT_CONFIG } from '@frameworks/android/android-wizard-agent'; -import { RAILS_AGENT_CONFIG } from '@frameworks/rails/rails-wizard-agent'; -import { ELIXIR_AGENT_CONFIG } from '@frameworks/elixir/elixir-wizard-agent'; -import { GO_AGENT_CONFIG } from '@frameworks/go/go-wizard-agent'; -import { JAVA_AGENT_CONFIG } from '@frameworks/java/java-wizard-agent'; -import { RUST_AGENT_CONFIG } from '@frameworks/rust/rust-wizard-agent'; -import { PYTHON_AGENT_CONFIG } from '@frameworks/python/python-wizard-agent'; -import { RUBY_AGENT_CONFIG } from '@frameworks/ruby/ruby-wizard-agent'; -import { JAVASCRIPT_NODE_AGENT_CONFIG } from '@frameworks/javascript-node/javascript-node-wizard-agent'; -import { JAVASCRIPT_WEB_AGENT_CONFIG } from '@frameworks/javascript-web/javascript-web-wizard-agent'; - -export const FRAMEWORK_REGISTRY: Record = { - [Integration.nextjs]: NEXTJS_AGENT_CONFIG, - [Integration.nuxt]: NUXT_AGENT_CONFIG, - [Integration.vue]: VUE_AGENT_CONFIG, - [Integration.tanstackStart]: TANSTACK_START_AGENT_CONFIG, - [Integration.reactRouter]: REACT_ROUTER_AGENT_CONFIG, - [Integration.tanstackRouter]: TANSTACK_ROUTER_AGENT_CONFIG, - [Integration.reactNative]: REACT_NATIVE_AGENT_CONFIG, - [Integration.angular]: ANGULAR_AGENT_CONFIG, - [Integration.astro]: ASTRO_AGENT_CONFIG, - [Integration.django]: DJANGO_AGENT_CONFIG, - [Integration.flask]: FLASK_AGENT_CONFIG, - [Integration.fastapi]: FASTAPI_AGENT_CONFIG, - [Integration.laravel]: LARAVEL_AGENT_CONFIG, - [Integration.sveltekit]: SVELTEKIT_AGENT_CONFIG, - [Integration.flutter]: FLUTTER_AGENT_CONFIG, - [Integration.kmp]: KMP_AGENT_CONFIG, - [Integration.swift]: SWIFT_AGENT_CONFIG, - [Integration.android]: ANDROID_AGENT_CONFIG, - [Integration.rails]: RAILS_AGENT_CONFIG, - [Integration.elixir]: ELIXIR_AGENT_CONFIG, - [Integration.go]: GO_AGENT_CONFIG, - [Integration.rust]: RUST_AGENT_CONFIG, - [Integration.java]: JAVA_AGENT_CONFIG, - [Integration.python]: PYTHON_AGENT_CONFIG, - [Integration.ruby]: RUBY_AGENT_CONFIG, - [Integration.javascriptNode]: JAVASCRIPT_NODE_AGENT_CONFIG, - [Integration.javascript_web]: JAVASCRIPT_WEB_AGENT_CONFIG, -}; diff --git a/src/lib/runners/index.ts b/src/lib/runners/index.ts deleted file mode 100644 index e42598b8e..000000000 --- a/src/lib/runners/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { runWizard } from './run-wizard'; -export { runWizardCI } from './run-wizard-ci'; -export { runWizardHeadless } from './run-wizard-headless'; -export { API_KEY_HINT } from './run-non-interactive'; -export type { NonInteractiveMode } from './run-non-interactive'; diff --git a/src/steps/index.ts b/src/steps/index.ts deleted file mode 100644 index fd6758c45..000000000 --- a/src/steps/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './run-prettier'; -export * from './add-or-update-environment-variables'; -export * from './add-mcp-server-to-clients'; -export * from './upload-environment-variables'; diff --git a/src/lib/__tests__/__snapshots__/credential-isolation-snapshot.test.ts.snap b/src/store/__tests__/__snapshots__/credential-isolation-snapshot.test.ts.snap similarity index 100% rename from src/lib/__tests__/__snapshots__/credential-isolation-snapshot.test.ts.snap rename to src/store/__tests__/__snapshots__/credential-isolation-snapshot.test.ts.snap diff --git a/src/lib/__tests__/agent-env-isolation.test.ts b/src/store/__tests__/agent-env-isolation.test.ts similarity index 99% rename from src/lib/__tests__/agent-env-isolation.test.ts rename to src/store/__tests__/agent-env-isolation.test.ts index d68f01c09..b8047d499 100644 --- a/src/lib/__tests__/agent-env-isolation.test.ts +++ b/src/store/__tests__/agent-env-isolation.test.ts @@ -2,7 +2,7 @@ import { sanitizeAgentSubprocessEnv, isBlockedAgentEnvKey, BLOCKED_AGENT_ENV_KEYS, -} from '@lib/agent-env-isolation'; +} from '../agent-protocol/agent-env-isolation.js'; describe('isBlockedAgentEnvKey', () => { it('blocks the direct API key that outranks the gateway auth token', () => { diff --git a/src/lib/__tests__/claude-settings-backup.test.ts b/src/store/__tests__/claude-settings-backup.test.ts similarity index 98% rename from src/lib/__tests__/claude-settings-backup.test.ts rename to src/store/__tests__/claude-settings-backup.test.ts index 8dd9815e0..8cf5b77b6 100644 --- a/src/lib/__tests__/claude-settings-backup.test.ts +++ b/src/store/__tests__/claude-settings-backup.test.ts @@ -7,7 +7,7 @@ const { captureException, wizardCapture } = vi.hoisted(() => ({ wizardCapture: vi.fn(), })); -vi.mock('@utils/analytics', () => ({ +vi.mock('../shared/analytics.js', () => ({ analytics: { captureException: (...args: unknown[]) => captureException(...args), wizardCapture: (...args: unknown[]) => wizardCapture(...args), @@ -18,7 +18,7 @@ import { backupAndFixClaudeSettings, restoreClaudeSettings, recoverOrphanedSettingsBackups, -} from '@lib/claude-settings'; +} from '../services/claude-settings.js'; const SETTINGS = 'settings.json'; const BACKUP = 'settings.json.wizard-backup'; diff --git a/src/__tests__/clipboard.test.ts b/src/store/__tests__/clipboard.test.ts similarity index 94% rename from src/__tests__/clipboard.test.ts rename to src/store/__tests__/clipboard.test.ts index 04197656d..f76cab2b6 100644 --- a/src/__tests__/clipboard.test.ts +++ b/src/store/__tests__/clipboard.test.ts @@ -1,4 +1,4 @@ -import { browserOpenCommands } from '@utils/clipboard'; +import { browserOpenCommands } from '../shared/clipboard.js'; const URL = 'https://us.posthog.com/api/environments/227926/integrations/authorize?kind=github'; diff --git a/src/lib/__tests__/cloudflare-detection.test.ts b/src/store/__tests__/cloudflare-detection.test.ts similarity index 97% rename from src/lib/__tests__/cloudflare-detection.test.ts rename to src/store/__tests__/cloudflare-detection.test.ts index 7879b5320..2aa18a4b8 100644 --- a/src/lib/__tests__/cloudflare-detection.test.ts +++ b/src/store/__tests__/cloudflare-detection.test.ts @@ -1,9 +1,9 @@ import * as fs from 'fs'; import * as path from 'path'; import * as os from 'os'; -import { detectCloudflareTarget } from '@lib/cloudflare-detection'; +import { detectCloudflareTarget } from '../cloudflare-detection.js'; -vi.mock('../../utils/debug'); +vi.mock('../shared/debug.js'); function makeTmpDir(): string { return fs.mkdtempSync(path.join(os.tmpdir(), 'cloudflare-detect-')); diff --git a/src/lib/__tests__/constants.test.ts b/src/store/__tests__/constants.test.ts similarity index 87% rename from src/lib/__tests__/constants.test.ts rename to src/store/__tests__/constants.test.ts index 6a5390819..07257eb15 100644 --- a/src/lib/__tests__/constants.test.ts +++ b/src/store/__tests__/constants.test.ts @@ -1,4 +1,7 @@ -import { WIZARD_USER_AGENT, wizardUserAgentForProgram } from '@lib/constants'; +import { + WIZARD_USER_AGENT, + wizardUserAgentForProgram, +} from '../shared/constants.js'; describe('wizardUserAgentForProgram', () => { it('tags the program so the backend can attribute created_via (self-driving → self_driving)', () => { diff --git a/src/lib/__tests__/credential-isolation-snapshot.test.ts b/src/store/__tests__/credential-isolation-snapshot.test.ts similarity index 95% rename from src/lib/__tests__/credential-isolation-snapshot.test.ts rename to src/store/__tests__/credential-isolation-snapshot.test.ts index e0ee0d4e7..07067bc36 100644 --- a/src/lib/__tests__/credential-isolation-snapshot.test.ts +++ b/src/store/__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-env-isolation'; -import { classifySettingsConflicts } from '@lib/claude-settings'; -import type { SettingsConflict } from '@lib/claude-settings'; +import { sanitizeAgentSubprocessEnv } from '../agent-protocol/agent-env-isolation.js'; +import { classifySettingsConflicts } from '../services/claude-settings.js'; +import type { SettingsConflict } from '../services/claude-settings.js'; // 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__/fetch-retry.test.ts b/src/store/__tests__/fetch-retry.test.ts similarity index 98% rename from src/lib/__tests__/fetch-retry.test.ts rename to src/store/__tests__/fetch-retry.test.ts index d36d94509..8da33195b 100644 --- a/src/lib/__tests__/fetch-retry.test.ts +++ b/src/store/__tests__/fetch-retry.test.ts @@ -3,8 +3,11 @@ import { fetchWithRetry, awsUrlFor, resetOriginPreference, -} from '../fetch-retry'; -import { GITHUB_SKILLS_BASE_URL, AWS_SKILLS_BASE_URL } from '../constants'; +} from '../fetch-retry.js'; +import { + GITHUB_SKILLS_BASE_URL, + AWS_SKILLS_BASE_URL, +} from '../shared/constants.js'; const GH_LATEST = 'https://github.com/PostHog/context-mill/releases/latest/download'; diff --git a/src/lib/__tests__/flow-resolution.test.ts b/src/store/__tests__/flow-resolution.test.ts similarity index 95% rename from src/lib/__tests__/flow-resolution.test.ts rename to src/store/__tests__/flow-resolution.test.ts index 278a759b7..7b5fc4235 100644 --- a/src/lib/__tests__/flow-resolution.test.ts +++ b/src/store/__tests__/flow-resolution.test.ts @@ -3,14 +3,14 @@ import { McpOutcome, OutroKind, RunPhase, -} from '@lib/wizard-session'; -import { HostResolution } from '@lib/host-resolution'; -import { WizardReadiness } from '@lib/health-checks/readiness'; -import { ScreenId, Overlay, Program, type ProgramId } from '@ui/tui/router'; -import { flowEntries, resolveActiveScreen } from '@lib/flow-resolution'; -import { flowFor } from '@lib/programs/flow-for'; -import type { WizardSession } from '@lib/wizard-session'; -import type { Interrupt } from '@lib/interrupts'; +} from '../session/wizard-session.js'; +import { HostResolution } from '../host-resolution.js'; +import { WizardReadiness } from '../health-checks/readiness.js'; +import { ScreenId, Overlay, Program, type ProgramId } from '@tui/router'; +import { flowEntries, resolveActiveScreen } from '../state/flow-resolution.js'; +import { flowFor } from '../programs/flow-for.js'; +import type { WizardSession } from '../session/wizard-session.js'; +import type { Interrupt } from '../state/interrupts.js'; /** The old router surface over the pure resolver, so the cases port as-is. */ function routerFor(program: ProgramId) { @@ -28,9 +28,9 @@ function routerFor(program: ProgramId) { }, }; } -import { Integration } from '@lib/constants'; -import { FRAMEWORK_REGISTRY } from '@lib/registry'; -import { PROGRAM_REGISTRY } from '@lib/programs/program-registry'; +import { Integration } from '../shared/constants.js'; +import { FRAMEWORK_REGISTRY } from '../registry.js'; +import { PROGRAM_REGISTRY } from '../programs/program-registry.js'; function baseWizardSession() { return buildSession({}); diff --git a/src/lib/__tests__/host-resolution.test.ts b/src/store/__tests__/host-resolution.test.ts similarity index 97% rename from src/lib/__tests__/host-resolution.test.ts rename to src/store/__tests__/host-resolution.test.ts index a22d55150..95f6f7ed0 100644 --- a/src/lib/__tests__/host-resolution.test.ts +++ b/src/store/__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 '../host-resolution.js'; /** * 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('../host-resolution.js'); expect(fresh.mcpUrlFor(false)).toBe('https://mcp.posthog.com/mcp'); expect(fresh.mcpUrlFor(true)).toBe('http://localhost:8787/mcp'); } finally { diff --git a/src/__tests__/link-helpers.test.ts b/src/store/__tests__/link-helpers.test.ts similarity index 99% rename from src/__tests__/link-helpers.test.ts rename to src/store/__tests__/link-helpers.test.ts index 62bc093f7..7440dea74 100644 --- a/src/__tests__/link-helpers.test.ts +++ b/src/store/__tests__/link-helpers.test.ts @@ -3,7 +3,7 @@ import { truncateUrlLabel, extractUrls, splitPromptIntoSegments, -} from '@ui/tui/primitives/link-helpers'; +} from '@tui/primitives/link-helpers'; const ESC = String.fromCharCode(0x1b); const BEL = String.fromCharCode(0x07); diff --git a/src/lib/__tests__/local-dev.test.ts b/src/store/__tests__/local-dev.test.ts similarity index 99% rename from src/lib/__tests__/local-dev.test.ts rename to src/store/__tests__/local-dev.test.ts index 02ced19c2..55e0a6033 100644 --- a/src/lib/__tests__/local-dev.test.ts +++ b/src/store/__tests__/local-dev.test.ts @@ -11,12 +11,12 @@ import { localMcpSkillsNotice, resetLocalDev, resolveLocalDev, -} from '@lib/local-dev'; +} from '../local-dev.js'; import { getSkillsBaseUrl, GITHUB_SKILLS_BASE_URL, LOCAL_SKILLS_BASE_URL, -} from '@lib/constants'; +} from '../shared/constants.js'; describe('local dev endpoints', () => { it('pins each service to its own port', () => { diff --git a/src/lib/__tests__/mcp-project-profile.test.ts b/src/store/__tests__/mcp-project-profile.test.ts similarity index 99% rename from src/lib/__tests__/mcp-project-profile.test.ts rename to src/store/__tests__/mcp-project-profile.test.ts index 14f793ee5..c17dce765 100644 --- a/src/lib/__tests__/mcp-project-profile.test.ts +++ b/src/store/__tests__/mcp-project-profile.test.ts @@ -3,7 +3,7 @@ import { degradedProfile, isKnownCloudHost, type EventVolume, -} from '@lib/mcp-project-profile'; +} from '../mcp-project-profile.js'; // Inconclusive REST result for every product — the "we couldn't tell" // default used by most tier/event tests so they isolate the events probe. diff --git a/src/lib/__tests__/mcp-role-prompts.test.ts b/src/store/__tests__/mcp-role-prompts.test.ts similarity index 99% rename from src/lib/__tests__/mcp-role-prompts.test.ts rename to src/store/__tests__/mcp-role-prompts.test.ts index 704f44cf7..6c8b41cec 100644 --- a/src/lib/__tests__/mcp-role-prompts.test.ts +++ b/src/store/__tests__/mcp-role-prompts.test.ts @@ -10,14 +10,14 @@ import { getSlackAppCard, FOLLOW_UP_EXIT_SENTINEL, TAILORED_ROLES, -} from '@lib/mcp-role-prompts'; -import { Integration } from '@lib/constants'; +} from '../mcp-role-prompts.js'; +import { Integration } from '../shared/constants.js'; import { degradedProfile, type EventVolume, type ProductPresence, type ProjectDataProfile, -} from '@lib/mcp-project-profile'; +} from '../mcp-project-profile.js'; // Build a profile fixture without the network. Defaults to a rich profile // with a clean SaaS funnel and every product absent (so activation diff --git a/src/lib/__tests__/mcp-seed-events.test.ts b/src/store/__tests__/mcp-seed-events.test.ts similarity index 98% rename from src/lib/__tests__/mcp-seed-events.test.ts rename to src/store/__tests__/mcp-seed-events.test.ts index c10031f78..0155351dd 100644 --- a/src/lib/__tests__/mcp-seed-events.test.ts +++ b/src/store/__tests__/mcp-seed-events.test.ts @@ -2,11 +2,11 @@ import { buildSeedEvents, tallySeedEvents, seededProfile, -} from '@lib/mcp-seed-events'; +} from '../mcp-seed-events.js'; import { degradedProfile, type ProjectDataProfile, -} from '@lib/mcp-project-profile'; +} from '../mcp-project-profile.js'; const NOW = new Date('2026-06-08T12:00:00.000Z'); const SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1000; diff --git a/src/__tests__/package-json.test.ts b/src/store/__tests__/package-json.test.ts similarity index 99% rename from src/__tests__/package-json.test.ts rename to src/store/__tests__/package-json.test.ts index 0be66cddc..d4ad92d3a 100644 --- a/src/__tests__/package-json.test.ts +++ b/src/store/__tests__/package-json.test.ts @@ -7,7 +7,7 @@ import { hasDeclaredDependency, findDeclaredPackage, type PackageJson, -} from '@utils/package-json'; +} from '../shared/package-json.js'; describe('getDeclaredVersion', () => { it('returns version from dependencies', () => { diff --git a/src/lib/__tests__/secret-vault.test.ts b/src/store/__tests__/secret-vault.test.ts similarity index 97% rename from src/lib/__tests__/secret-vault.test.ts rename to src/store/__tests__/secret-vault.test.ts index 6e1db3661..64ed91684 100644 --- a/src/lib/__tests__/secret-vault.test.ts +++ b/src/store/__tests__/secret-vault.test.ts @@ -1,4 +1,4 @@ -import { createSecretVault, isSecretRef } from '../secret-vault'; +import { createSecretVault, isSecretRef } from '../session/secret-vault.js'; describe('createSecretVault', () => { it('stores a value and returns a ref', () => { diff --git a/src/lib/__tests__/settings-conflicts.test.ts b/src/store/__tests__/settings-conflicts.test.ts similarity index 97% rename from src/lib/__tests__/settings-conflicts.test.ts rename to src/store/__tests__/settings-conflicts.test.ts index 2c71f14c2..7f20a433b 100644 --- a/src/lib/__tests__/settings-conflicts.test.ts +++ b/src/store/__tests__/settings-conflicts.test.ts @@ -2,7 +2,7 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -vi.mock('@utils/analytics', () => ({ +vi.mock('../shared/analytics.js', () => ({ analytics: { captureException: vi.fn(), wizardCapture: vi.fn() }, })); @@ -10,9 +10,9 @@ import { checkAllSettingsConflicts, managedSettingsPath, classifySettingsConflicts, -} from '@lib/claude-settings'; -import type { SettingsConflict } from '@lib/claude-settings'; -import { buildAuthErrorContext } from '@lib/agent/agent-interface'; +} from '../services/claude-settings.js'; +import type { SettingsConflict } from '../services/claude-settings.js'; +import { buildAuthErrorContext } from '@agent/agent-interface'; const OVERRIDE = JSON.stringify({ apiKeyHelper: 'echo sk-x' }); const ENV_OVERRIDE = JSON.stringify({ diff --git a/src/lib/__tests__/token-pricing.test.ts b/src/store/__tests__/token-pricing.test.ts similarity index 99% rename from src/lib/__tests__/token-pricing.test.ts rename to src/store/__tests__/token-pricing.test.ts index 4a713cb19..92d728b2b 100644 --- a/src/lib/__tests__/token-pricing.test.ts +++ b/src/store/__tests__/token-pricing.test.ts @@ -3,7 +3,7 @@ import { pricePerMtokForModel, formatTokenCount, formatCostUsd, -} from '@lib/token-pricing'; +} from '../agent-protocol/token-pricing.js'; describe('pricePerMtokForModel', () => { it('defaults to Sonnet pricing (DEFAULT_AGENT_MODEL) when no model is given', () => { diff --git a/src/__tests__/wizard-abort.test.ts b/src/store/__tests__/wizard-abort.test.ts similarity index 95% rename from src/__tests__/wizard-abort.test.ts rename to src/store/__tests__/wizard-abort.test.ts index 8699354c6..6899c8330 100644 --- a/src/__tests__/wizard-abort.test.ts +++ b/src/store/__tests__/wizard-abort.test.ts @@ -5,13 +5,13 @@ import { registerCleanup, clearCleanup, runCleanups, -} from '@utils/wizard-abort'; -import { analytics } from '@utils/analytics'; -import { ErrorCodes } from '@lib/errors'; -import { getUI } from '../ui'; +} from '../shared/wizard-abort.js'; +import { analytics } from '../shared/analytics.js'; +import { ErrorCodes } from '../shared/errors/index.js'; +import { getUI } from '../ui/index.js'; -vi.mock('../utils/analytics'); -vi.mock('../ui', () => ({ +vi.mock('../shared/analytics.js'); +vi.mock('../ui/index.js', () => ({ getUI: vi.fn().mockReturnValue({ outroError: vi.fn(), waitForOutroDismissed: vi.fn().mockResolvedValue(undefined), @@ -247,7 +247,7 @@ describe('abort() delegates to wizardAbort()', () => { }); it('abort() calls wizardAbort with message and exitCode', async () => { - const { abort } = await import('@utils/setup-utils'); + const { abort } = await import('../shared/setup-utils.js'); await expect(abort('Test abort', 3)).rejects.toThrow('process.exit called'); @@ -258,7 +258,7 @@ describe('abort() delegates to wizardAbort()', () => { }); it('abort() uses defaults when called with no args', async () => { - const { abort } = await import('@utils/setup-utils'); + const { abort } = await import('../shared/setup-utils.js'); await expect(abort()).rejects.toThrow('process.exit called'); diff --git a/src/lib/__tests__/wizard-ask-bridge.test.ts b/src/store/__tests__/wizard-ask-bridge.test.ts similarity index 97% rename from src/lib/__tests__/wizard-ask-bridge.test.ts rename to src/store/__tests__/wizard-ask-bridge.test.ts index 1f12b9a4c..e33d2c0ce 100644 --- a/src/lib/__tests__/wizard-ask-bridge.test.ts +++ b/src/store/__tests__/wizard-ask-bridge.test.ts @@ -2,11 +2,11 @@ import { CANCELLED_SENTINEL, createWizardAskBridge, isFullyCancelled, -} from '@lib/wizard-ask-bridge'; -import { analytics } from '@utils/analytics'; -import type { AskAnswers, PendingQuestion } from '@lib/wizard-session'; +} from '../session/wizard-ask-bridge.js'; +import { analytics } from '../shared/analytics.js'; +import type { AskAnswers, PendingQuestion } from '../session/wizard-session.js'; -vi.mock('../../utils/analytics', () => ({ +vi.mock('../shared/analytics.js', () => ({ analytics: { wizardCapture: vi.fn(), }, diff --git a/src/lib/__tests__/wizard-spellbook.test.ts b/src/store/__tests__/wizard-spellbook.test.ts similarity index 88% rename from src/lib/__tests__/wizard-spellbook.test.ts rename to src/store/__tests__/wizard-spellbook.test.ts index 727b5f5f1..aabaa3c5d 100644 --- a/src/lib/__tests__/wizard-spellbook.test.ts +++ b/src/store/__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 type { ProgramConfig } from '../programs/program-step'; -import { buildSession } from '../wizard-session'; -import { writeWizardSpellbook } from '../wizard-spellbook'; -import { downloadSkill, fetchSkillMenu } from '../wizard-tools/tools'; +import { Integration } from '../shared/constants.js'; +import type { ProgramConfig } from '../programs/program-step.js'; +import { buildSession } from '../session/wizard-session.js'; +import { writeWizardSpellbook } from '../wizard-spellbook.js'; +import { downloadSkill, fetchSkillMenu } from '../tools/tools.js'; -vi.mock('../wizard-tools/tools', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('../tools/tools.js', async (importOriginal) => ({ + ...(await importOriginal()), fetchSkillMenu: vi.fn(), downloadSkill: vi.fn(), })); diff --git a/src/lib/__tests__/wizard-tools.test.ts b/src/store/__tests__/wizard-tools.test.ts similarity index 99% rename from src/lib/__tests__/wizard-tools.test.ts rename to src/store/__tests__/wizard-tools.test.ts index 5ddeff913..791b37e1f 100644 --- a/src/lib/__tests__/wizard-tools.test.ts +++ b/src/store/__tests__/wizard-tools.test.ts @@ -28,8 +28,8 @@ import { resolveAskQuestionKinds, resolveEnvPath, templateEnvWriteRefusal, -} from '@lib/wizard-tools'; -import type { AuditCheck } from '@lib/programs/audit/types'; +} from '../tools/index.js'; +import type { AuditCheck } from '../programs/audit/types.js'; function makeTmpDir(): string { return fs.mkdtempSync(path.join(os.tmpdir(), 'wizard-tools-')); diff --git a/src/lib/agent-env-isolation.ts b/src/store/agent-protocol/agent-env-isolation.ts similarity index 100% rename from src/lib/agent-env-isolation.ts rename to src/store/agent-protocol/agent-env-isolation.ts diff --git a/src/lib/agent-signals.ts b/src/store/agent-protocol/agent-signals.ts similarity index 100% rename from src/lib/agent-signals.ts rename to src/store/agent-protocol/agent-signals.ts diff --git a/src/lib/program-run.ts b/src/store/agent-protocol/program-run.ts similarity index 97% rename from src/lib/program-run.ts rename to src/store/agent-protocol/program-run.ts index 5296e6a6b..dee08d757 100644 --- a/src/lib/program-run.ts +++ b/src/store/agent-protocol/program-run.ts @@ -9,9 +9,9 @@ import type { AdditionalFeature, WizardSession, TaskNotice, -} from '@lib/wizard-session'; -import type { PackageManagerDetector } from '@lib/detection/package-manager'; -import type { HostResolution } from '@lib/host-resolution'; +} from '../session/wizard-session.js'; +import type { PackageManagerDetector } from '../detection/package-manager.js'; +import type { HostResolution } from '../host-resolution.js'; export type { Credentials }; @@ -53,7 +53,7 @@ export interface AbortCase { message: string; body: string; docsUrl?: string; - errorCode?: import('@lib/errors').ErrorCode; + errorCode?: import('../shared/errors/index.js').ErrorCode; } /** diff --git a/src/lib/token-pricing.ts b/src/store/agent-protocol/token-pricing.ts similarity index 99% rename from src/lib/token-pricing.ts rename to src/store/agent-protocol/token-pricing.ts index 192168207..38fd4842b 100644 --- a/src/lib/token-pricing.ts +++ b/src/store/agent-protocol/token-pricing.ts @@ -35,7 +35,7 @@ import { DEFAULT_AGENT_MODEL, HAIKU_MODEL, SONNET_5_MODEL, -} from '@lib/constants'; +} from '../shared/constants.js'; export interface PricePerMtok { input: number; diff --git a/src/lib/api.ts b/src/store/api.ts similarity index 98% rename from src/lib/api.ts rename to src/store/api.ts index 02bf1c04a..20fe44a0b 100644 --- a/src/lib/api.ts +++ b/src/store/api.ts @@ -1,7 +1,7 @@ import axios, { AxiosError } from 'axios'; import { z } from 'zod'; -import { analytics } from '@utils/analytics'; -import { WIZARD_USER_AGENT } from './constants'; +import { analytics } from './shared/analytics.js'; +import { WIZARD_USER_AGENT } from './shared/constants.js'; /** * User payload from `/api/users/@me/`. Schema typed for the fields the diff --git a/src/lib/auth-session-state.ts b/src/store/auth-session-state.ts similarity index 100% rename from src/lib/auth-session-state.ts rename to src/store/auth-session-state.ts diff --git a/src/lib/cloudflare-detection.ts b/src/store/cloudflare-detection.ts similarity index 95% rename from src/lib/cloudflare-detection.ts rename to src/store/cloudflare-detection.ts index 7dfe304b8..f569ca255 100644 --- a/src/lib/cloudflare-detection.ts +++ b/src/store/cloudflare-detection.ts @@ -1,6 +1,6 @@ import fg from 'fast-glob'; -import { logToFile } from '@utils/debug'; -import { tryGetPackageJson } from '@utils/setup-utils'; +import { logToFile } from './shared/debug.js'; +import { tryGetPackageJson } from './shared/setup-utils.js'; const CLOUDFLARE_PACKAGES = [ '@react-router/cloudflare', diff --git a/src/lib/detection/__tests__/agentic.test.ts b/src/store/detection/__tests__/agentic.test.ts similarity index 99% rename from src/lib/detection/__tests__/agentic.test.ts rename to src/store/detection/__tests__/agentic.test.ts index c63335c74..01a159dbd 100644 --- a/src/lib/detection/__tests__/agentic.test.ts +++ b/src/store/detection/__tests__/agentic.test.ts @@ -3,7 +3,7 @@ import { deriveReportJson, manifestGlob, resolveProjectDir, -} from '@lib/detection/agentic'; +} from '../agentic.js'; const TARGETS = ['nextjs', 'node', 'vite']; diff --git a/src/lib/detection/__tests__/context.test.ts b/src/store/detection/__tests__/context.test.ts similarity index 92% rename from src/lib/detection/__tests__/context.test.ts rename to src/store/detection/__tests__/context.test.ts index 138b94d0c..ae197fe2d 100644 --- a/src/lib/detection/__tests__/context.test.ts +++ b/src/store/detection/__tests__/context.test.ts @@ -1,9 +1,6 @@ -import { - gatherFrameworkContext, - checkFrameworkVersion, -} from '@lib/detection/context'; -import type { FrameworkConfig } from '@lib/framework-config'; -import type { WizardRunOptions } from '@utils/types'; +import { gatherFrameworkContext, checkFrameworkVersion } from '../context.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import type { WizardRunOptions } from '../../shared/types.js'; const baseOptions: WizardRunOptions = { installDir: '/test/dir', diff --git a/src/lib/detection/__tests__/features.test.ts b/src/store/detection/__tests__/features.test.ts similarity index 97% rename from src/lib/detection/__tests__/features.test.ts rename to src/store/detection/__tests__/features.test.ts index a5a21ff7f..2b26df548 100644 --- a/src/lib/detection/__tests__/features.test.ts +++ b/src/store/detection/__tests__/features.test.ts @@ -1,8 +1,8 @@ import * as fs from 'fs'; import * as path from 'path'; import * as os from 'os'; -import { discoverFeatures } from '@lib/detection/features'; -import { DiscoveredFeature } from '@lib/wizard-session'; +import { discoverFeatures } from '../features.js'; +import { DiscoveredFeature } from '../../session/wizard-session.js'; function makeTmpDir(): string { return fs.mkdtempSync(path.join(os.tmpdir(), 'features-detect-')); diff --git a/src/lib/detection/__tests__/framework.test.ts b/src/store/detection/__tests__/framework.test.ts similarity index 95% rename from src/lib/detection/__tests__/framework.test.ts rename to src/store/detection/__tests__/framework.test.ts index 947159368..73b2ef77d 100644 --- a/src/lib/detection/__tests__/framework.test.ts +++ b/src/store/detection/__tests__/framework.test.ts @@ -1,15 +1,15 @@ 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 { 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'; -import { GO_AGENT_CONFIG } from '../../../frameworks/go/go-wizard-agent'; -import { JAVA_AGENT_CONFIG } from '../../../frameworks/java/java-wizard-agent'; -import { RUST_AGENT_CONFIG } from '../../../frameworks/rust/rust-wizard-agent'; -import { FLUTTER_AGENT_CONFIG } from '../../../frameworks/flutter/flutter-wizard-agent'; +import { detectFramework } from '../framework.js'; +import { Integration } from '../../shared/constants.js'; +import { ANDROID_AGENT_CONFIG } from '../../frameworks/android/android-wizard-agent.js'; +import { KMP_AGENT_CONFIG } from '../../frameworks/kmp/kmp-wizard-agent.js'; +import { ELIXIR_AGENT_CONFIG } from '../../frameworks/elixir/elixir-wizard-agent.js'; +import { GO_AGENT_CONFIG } from '../../frameworks/go/go-wizard-agent.js'; +import { JAVA_AGENT_CONFIG } from '../../frameworks/java/java-wizard-agent.js'; +import { RUST_AGENT_CONFIG } from '../../frameworks/rust/rust-wizard-agent.js'; +import { FLUTTER_AGENT_CONFIG } from '../../frameworks/flutter/flutter-wizard-agent.js'; /** A throwaway project dir seeded with the given files. */ function makeProject(files: Record): string { diff --git a/src/lib/detection/__tests__/package-manager.test.ts b/src/store/detection/__tests__/package-manager.test.ts similarity index 98% rename from src/lib/detection/__tests__/package-manager.test.ts rename to src/store/detection/__tests__/package-manager.test.ts index e74e27733..0c40a273e 100644 --- a/src/lib/detection/__tests__/package-manager.test.ts +++ b/src/store/detection/__tests__/package-manager.test.ts @@ -12,13 +12,13 @@ import { mixPackageManager, goModulesPackageManager, pubPackageManager, -} from '@lib/detection/package-manager'; +} from '../package-manager.js'; -vi.mock('../../../utils/debug'); -vi.mock('../../../telemetry', () => ({ +vi.mock('../../shared/debug.js'); +vi.mock('@cli/telemetry', () => ({ withProgress: (_name: string, fn: () => unknown) => fn(), })); -vi.mock('../../../utils/analytics', () => ({ +vi.mock('../../shared/analytics.js', () => ({ analytics: { setTag: vi.fn() }, })); diff --git a/src/lib/detection/__tests__/project-scope.test.ts b/src/store/detection/__tests__/project-scope.test.ts similarity index 93% rename from src/lib/detection/__tests__/project-scope.test.ts rename to src/store/detection/__tests__/project-scope.test.ts index 46aedaf04..7ba5d57fb 100644 --- a/src/lib/detection/__tests__/project-scope.test.ts +++ b/src/store/detection/__tests__/project-scope.test.ts @@ -1,25 +1,22 @@ -import { - detectProjectsWithAgent, - type AgenticProject, -} from '@lib/detection/agentic'; +import { detectProjectsWithAgent, type AgenticProject } from '../agentic.js'; import { chooseIntegrationProject, scopeInstallDirToProject, -} from '@lib/detection/project-scope'; +} from '../project-scope.js'; import { AGENTIC_DETECTION_TIMEOUT_MS, WIZARD_BASIC_INTEGRATION_AGENTIC_DETECTION_FLAG_KEY, -} from '@lib/constants'; -import { authenticate } from '@lib/agent/runner/shared/authenticate'; -import { buildSession } from '@lib/wizard-session'; -import { analytics } from '@utils/analytics'; +} from '../../shared/constants.js'; +import { authenticate } from '@agent/runner/shared/authenticate'; +import { buildSession } from '../../session/wizard-session.js'; +import { analytics } from '../../shared/analytics.js'; // Mock only the two network edges of scopeInstallDirToProject; everything else runs real. -vi.mock('@lib/agent/runner/shared/authenticate', () => ({ +vi.mock('@agent/runner/shared/authenticate', () => ({ authenticate: vi.fn().mockResolvedValue(undefined), })); -vi.mock('@lib/detection/agentic', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('../agentic.js', async (importOriginal) => ({ + ...(await importOriginal()), detectProjectsWithAgent: vi.fn(), })); diff --git a/src/lib/detection/agentic.ts b/src/store/detection/agentic.ts similarity index 98% rename from src/lib/detection/agentic.ts rename to src/store/detection/agentic.ts index aac8d282a..d2853a849 100644 --- a/src/lib/detection/agentic.ts +++ b/src/store/detection/agentic.ts @@ -18,14 +18,18 @@ import { runAgent as executeAgent, buildRunTags, AgentSignals, -} from '@lib/agent/agent-interface'; +} from '@agent/agent-interface'; import { isAbsolute, resolve, sep } from 'path'; import { detectNodePackageManagers } from './package-manager.js'; -import { CallType, getSkillsBaseUrl, HAIKU_MODEL } from '@lib/constants'; -import { analytics } from '@utils/analytics'; -import type { WizardSession } from '@lib/wizard-session'; -import type { WizardRunOptions } from '@utils/types'; -import type { SpinnerHandle } from '@ui'; +import { + CallType, + getSkillsBaseUrl, + HAIKU_MODEL, +} from '../shared/constants.js'; +import { analytics } from '../shared/analytics.js'; +import type { WizardSession } from '../session/wizard-session.js'; +import type { WizardRunOptions } from '../shared/types.js'; +import type { SpinnerHandle } from '../ui/index.js'; /** A category the agent classifies each project into (id the agent returns). */ export type DetectTarget = { id: string; name: string }; diff --git a/src/lib/detection/context.ts b/src/store/detection/context.ts similarity index 91% rename from src/lib/detection/context.ts rename to src/store/detection/context.ts index 5ecb68925..0f16c755b 100644 --- a/src/lib/detection/context.ts +++ b/src/store/detection/context.ts @@ -7,9 +7,9 @@ */ import * as semver from 'semver'; -import { DETECTION_TIMEOUT_MS } from '@lib/constants'; -import type { FrameworkConfig } from '@lib/framework-config'; -import type { WizardRunOptions } from '@utils/types'; +import { DETECTION_TIMEOUT_MS } from '../shared/constants.js'; +import type { FrameworkConfig } from '../framework-config.js'; +import type { WizardRunOptions } from '../shared/types.js'; /** * Run a framework's `gatherContext()` to collect variant-specific diff --git a/src/lib/detection/features.ts b/src/store/detection/features.ts similarity index 97% rename from src/lib/detection/features.ts rename to src/store/detection/features.ts index 2975d5f6c..2cdb88472 100644 --- a/src/lib/detection/features.ts +++ b/src/store/detection/features.ts @@ -7,8 +7,8 @@ */ import { join } from 'path'; -import { readProjectFile } from '@utils/bounded-fs'; -import { DiscoveredFeature } from '@lib/wizard-session'; +import { readProjectFile } from '../shared/bounded-fs.js'; +import { DiscoveredFeature } from '../session/wizard-session.js'; const STRIPE_PACKAGES = new Set(['stripe', '@stripe/stripe-js']); diff --git a/src/lib/detection/framework.ts b/src/store/detection/framework.ts similarity index 88% rename from src/lib/detection/framework.ts rename to src/store/detection/framework.ts index 4efd9f6bf..354a018f7 100644 --- a/src/lib/detection/framework.ts +++ b/src/store/detection/framework.ts @@ -6,8 +6,8 @@ * (or undefined). No store mutations, no UI calls. */ -import { Integration, DETECTION_TIMEOUT_MS } from '@lib/constants'; -import { FRAMEWORK_REGISTRY } from '@lib/registry'; +import { Integration, DETECTION_TIMEOUT_MS } from '../shared/constants.js'; +import { FRAMEWORK_REGISTRY } from '../registry.js'; /** * Loop through all registered frameworks and return the first one diff --git a/src/lib/detection/index.ts b/src/store/detection/index.ts similarity index 100% rename from src/lib/detection/index.ts rename to src/store/detection/index.ts diff --git a/src/lib/detection/package-manager.ts b/src/store/detection/package-manager.ts similarity index 99% rename from src/lib/detection/package-manager.ts rename to src/store/detection/package-manager.ts index be50909fb..8fe77e0dd 100644 --- a/src/lib/detection/package-manager.ts +++ b/src/store/detection/package-manager.ts @@ -12,11 +12,11 @@ import * as path from 'node:path'; import { detectAllPackageManagers, type PackageManager, -} from '@utils/package-manager'; +} from '../shared/package-manager.js'; import { detectPackageManager as detectPythonPM, PythonPackageManager, -} from '@frameworks/python/utils'; +} from '../frameworks/python/utils.js'; // --------------------------------------------------------------------------- // Common types diff --git a/src/lib/detection/project-scope.ts b/src/store/detection/project-scope.ts similarity index 94% rename from src/lib/detection/project-scope.ts rename to src/store/detection/project-scope.ts index 73279b075..5e1459c91 100644 --- a/src/lib/detection/project-scope.ts +++ b/src/store/detection/project-scope.ts @@ -8,17 +8,17 @@ import { type DetectEvent, type DetectTarget, } from './agentic.js'; -import { authenticate } from '@lib/agent/runner/shared/authenticate'; -import { FRAMEWORK_REGISTRY } from '@lib/registry'; +import { authenticate } from '@agent/runner/shared/authenticate'; +import { FRAMEWORK_REGISTRY } from '../registry.js'; import { AGENTIC_DETECTION_TIMEOUT_MS, Integration, WIZARD_BASIC_INTEGRATION_AGENTIC_DETECTION_FLAG_KEY, -} from '@lib/constants'; -import type { WizardSession } from '@lib/wizard-session'; -import { getUI } from '@ui/index'; -import { analytics } from '@utils/analytics'; -import { logToFile } from '@utils/debug'; +} from '../shared/constants.js'; +import type { WizardSession } from '../session/wizard-session.js'; +import { getUI } from '../ui/index.js'; +import { analytics } from '../shared/analytics.js'; +import { logToFile } from '../shared/debug.js'; /** Integration framework targets for the agentic detector (id → display name). */ const INTEGRATION_TARGETS: DetectTarget[] = Object.entries( diff --git a/src/lib/fetch-retry.ts b/src/store/fetch-retry.ts similarity index 97% rename from src/lib/fetch-retry.ts rename to src/store/fetch-retry.ts index ee6edfe25..a8682ff49 100644 --- a/src/lib/fetch-retry.ts +++ b/src/store/fetch-retry.ts @@ -6,9 +6,9 @@ * asset redirects and blocked regions where the asset is present. */ -import { logToFile } from '@utils/debug'; -import { analytics } from '@utils/analytics'; -import { CONTEXT_MILL_URL, AWS_SKILLS_BASE_URL } from './constants'; +import { logToFile } from './shared/debug.js'; +import { analytics } from './shared/analytics.js'; +import { CONTEXT_MILL_URL, AWS_SKILLS_BASE_URL } from './shared/constants.js'; const DEFAULT_TIMEOUT_MS = 60000; // per attempt const DEFAULT_MAX_ATTEMPTS = 3; diff --git a/src/lib/file-watcher.ts b/src/store/file-watcher.ts similarity index 99% rename from src/lib/file-watcher.ts rename to src/store/file-watcher.ts index 1d3d07cc8..0ab175ef1 100644 --- a/src/lib/file-watcher.ts +++ b/src/store/file-watcher.ts @@ -8,7 +8,7 @@ import * as fs from 'fs'; import { basename, dirname } from 'node:path'; -import { logToFile } from '@utils/debug'; +import { logToFile } from './shared/debug.js'; const DEFAULT_POLL_INTERVAL_MS = 5000; const DEFAULT_ATTACH_RETRY_INTERVAL_MS = 1000; diff --git a/src/lib/framework-config.ts b/src/store/framework-config.ts similarity index 98% rename from src/lib/framework-config.ts rename to src/store/framework-config.ts index 5bbc7440b..0d7b0edc2 100644 --- a/src/lib/framework-config.ts +++ b/src/store/framework-config.ts @@ -1,6 +1,6 @@ -import type { Integration } from './constants'; -import type { WizardRunOptions } from '@utils/types'; -import type { PackageManagerDetector } from './detection/package-manager'; +import type { Integration } from './shared/constants.js'; +import type { WizardRunOptions } from './shared/types.js'; +import type { PackageManagerDetector } from './detection/package-manager.js'; /** * A setup question that the SetupScreen renders for framework disambiguation. diff --git a/src/frameworks/android/android-wizard-agent.ts b/src/store/frameworks/android/android-wizard-agent.ts similarity index 92% rename from src/frameworks/android/android-wizard-agent.ts rename to src/store/frameworks/android/android-wizard-agent.ts index dd9acaebf..176c965c7 100644 --- a/src/frameworks/android/android-wizard-agent.ts +++ b/src/store/frameworks/android/android-wizard-agent.ts @@ -1,16 +1,16 @@ /* 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 { boundedGlob } from '@utils/bounded-fs'; +import type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { Integration } from '../../shared/constants.js'; +import { boundedGlob } from '../../shared/bounded-fs.js'; import * as fs from 'node:fs'; import * as path from 'node:path'; import { getKotlinVersion, getKotlinVersionBucket, getMinSdkVersion, -} from './utils'; -import { gradlePackageManager } from '@lib/detection/package-manager'; +} from './utils.js'; +import { gradlePackageManager } from '../../detection/package-manager.js'; type AndroidContext = { kotlinVersion?: string; diff --git a/src/frameworks/android/utils.ts b/src/store/frameworks/android/utils.ts similarity index 89% rename from src/frameworks/android/utils.ts rename to src/store/frameworks/android/utils.ts index 4afad3c77..b827b1a38 100644 --- a/src/frameworks/android/utils.ts +++ b/src/store/frameworks/android/utils.ts @@ -1,6 +1,6 @@ -import type { WizardRunOptions } from '@utils/types'; -import { createVersionBucket } from '@utils/semver'; -import { boundedGlob, readProjectFile } from '@utils/bounded-fs'; +import type { WizardRunOptions } from '../../shared/types.js'; +import { createVersionBucket } from '../../shared/semver.js'; +import { boundedGlob, readProjectFile } from '../../shared/bounded-fs.js'; import * as fs from 'node:fs'; import * as path from 'node:path'; diff --git a/src/frameworks/angular/angular-wizard-agent.ts b/src/store/frameworks/angular/angular-wizard-agent.ts similarity index 85% rename from src/frameworks/angular/angular-wizard-agent.ts rename to src/store/frameworks/angular/angular-wizard-agent.ts index 7db04b37a..266e7570a 100644 --- a/src/frameworks/angular/angular-wizard-agent.ts +++ b/src/store/frameworks/angular/angular-wizard-agent.ts @@ -1,16 +1,16 @@ /* Angular wizard using posthog-agent with PostHog MCP */ -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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { detectNodePackageManagers } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; import { getDeclaredVersion, getInstalledPackageVersion, hasDeclaredDependency, type PackageJson, -} from '@utils/package-json'; -import { tryGetPackageJson } from '@utils/setup-utils'; -import { getAngularVersionBucket } from './utils'; +} from '../../shared/package-json.js'; +import { tryGetPackageJson } from '../../shared/setup-utils.js'; +import { getAngularVersionBucket } from './utils.js'; type AngularContext = Record; diff --git a/src/frameworks/angular/utils.ts b/src/store/frameworks/angular/utils.ts similarity index 64% rename from src/frameworks/angular/utils.ts rename to src/store/frameworks/angular/utils.ts index f820ac582..13e4084d8 100644 --- a/src/frameworks/angular/utils.ts +++ b/src/store/frameworks/angular/utils.ts @@ -1,4 +1,4 @@ -import { createVersionBucket } from '@utils/semver'; +import { createVersionBucket } from '../../shared/semver.js'; /** * Get Angular version bucket for analytics diff --git a/src/frameworks/astro/astro-wizard-agent.ts b/src/store/frameworks/astro/astro-wizard-agent.ts similarity index 91% rename from src/frameworks/astro/astro-wizard-agent.ts rename to src/store/frameworks/astro/astro-wizard-agent.ts index f427935ab..52dc31972 100644 --- a/src/frameworks/astro/astro-wizard-agent.ts +++ b/src/store/frameworks/astro/astro-wizard-agent.ts @@ -1,22 +1,22 @@ /* Astro wizard using posthog-agent with PostHog MCP */ -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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { detectNodePackageManagers } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; import { getDeclaredVersion, getInstalledPackageVersion, hasDeclaredDependency, type PackageJson, -} from '@utils/package-json'; -import { tryGetPackageJson } from '@utils/setup-utils'; -import { getUI } from '@ui'; +} from '../../shared/package-json.js'; +import { tryGetPackageJson } from '../../shared/setup-utils.js'; +import { getUI } from '../../ui/index.js'; import { getAstroRenderingMode, getAstroVersionBucket, getAstroRenderingModeName, AstroRenderingMode, -} from './utils'; +} from './utils.js'; type AstroContext = { renderingMode?: AstroRenderingMode; diff --git a/src/frameworks/astro/utils.ts b/src/store/frameworks/astro/utils.ts similarity index 93% rename from src/frameworks/astro/utils.ts rename to src/store/frameworks/astro/utils.ts index 28db0f641..d0fea2891 100644 --- a/src/frameworks/astro/utils.ts +++ b/src/store/frameworks/astro/utils.ts @@ -1,8 +1,8 @@ -import { boundedGlob, readProjectFile } from '@utils/bounded-fs'; +import { boundedGlob, readProjectFile } from '../../shared/bounded-fs.js'; import fs from 'fs/promises'; import path from 'path'; -import type { WizardRunOptions } from '@utils/types'; -import { createVersionBucket } from '@utils/semver'; +import type { WizardRunOptions } from '../../shared/types.js'; +import { createVersionBucket } from '../../shared/semver.js'; export const getAstroVersionBucket = createVersionBucket(); diff --git a/src/frameworks/django/django-wizard-agent.ts b/src/store/frameworks/django/django-wizard-agent.ts similarity index 91% rename from src/frameworks/django/django-wizard-agent.ts rename to src/store/frameworks/django/django-wizard-agent.ts index 30e2660aa..e0598aee0 100644 --- a/src/frameworks/django/django-wizard-agent.ts +++ b/src/store/frameworks/django/django-wizard-agent.ts @@ -1,10 +1,10 @@ /* Django wizard using posthog-agent with PostHog MCP */ -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 { boundedGlob, readProjectFile } from '@utils/bounded-fs'; +import type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { PYTHON_PACKAGE_INSTALLATION } from '../../framework-config.js'; +import { detectPythonPackageManagers } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; +import { boundedGlob, readProjectFile } from '../../shared/bounded-fs.js'; import * as path from 'node:path'; import { getDjangoVersion, @@ -13,7 +13,7 @@ import { getDjangoVersionBucket, DjangoProjectType, findDjangoSettingsFile, -} from './utils'; +} from './utils.js'; const EXTRA_IGNORE = ['**/env/**', '**/.env/**']; diff --git a/src/frameworks/django/utils.ts b/src/store/frameworks/django/utils.ts similarity index 96% rename from src/frameworks/django/utils.ts rename to src/store/frameworks/django/utils.ts index 276c2b746..7ea0544e4 100644 --- a/src/frameworks/django/utils.ts +++ b/src/store/frameworks/django/utils.ts @@ -1,7 +1,7 @@ -import { boundedGlob, readProjectFile } from '@utils/bounded-fs'; -import { getUI } from '@ui'; -import type { WizardRunOptions } from '@utils/types'; -import { createVersionBucket } from '@utils/semver'; +import { boundedGlob, readProjectFile } from '../../shared/bounded-fs.js'; +import { getUI } from '../../ui/index.js'; +import type { WizardRunOptions } from '../../shared/types.js'; +import { createVersionBucket } from '../../shared/semver.js'; import * as fs from 'node:fs'; import * as path from 'node:path'; diff --git a/src/frameworks/elixir/elixir-wizard-agent.ts b/src/store/frameworks/elixir/elixir-wizard-agent.ts similarity index 93% rename from src/frameworks/elixir/elixir-wizard-agent.ts rename to src/store/frameworks/elixir/elixir-wizard-agent.ts index 26eb007e1..c71711e4f 100644 --- a/src/frameworks/elixir/elixir-wizard-agent.ts +++ b/src/store/frameworks/elixir/elixir-wizard-agent.ts @@ -1,10 +1,10 @@ /* Elixir wizard using posthog-agent with PostHog MCP */ import * as fs from 'node:fs'; 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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { mixPackageManager } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; type ElixirContext = { phoenix?: boolean; diff --git a/src/frameworks/fastapi/fastapi-wizard-agent.ts b/src/store/frameworks/fastapi/fastapi-wizard-agent.ts similarity index 92% rename from src/frameworks/fastapi/fastapi-wizard-agent.ts rename to src/store/frameworks/fastapi/fastapi-wizard-agent.ts index 61f0d8d8d..bea765d2f 100644 --- a/src/frameworks/fastapi/fastapi-wizard-agent.ts +++ b/src/store/frameworks/fastapi/fastapi-wizard-agent.ts @@ -1,9 +1,9 @@ /* FastAPI wizard using posthog-agent with PostHog MCP */ -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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { PYTHON_PACKAGE_INSTALLATION } from '../../framework-config.js'; +import { detectPythonPackageManagers } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; import { getFastAPIVersion, getFastAPIProjectType, @@ -11,8 +11,8 @@ import { getFastAPIVersionBucket, FastAPIProjectType, findFastAPIAppFile, -} from './utils'; -import { boundedGlob, readProjectFile } from '@utils/bounded-fs'; +} from './utils.js'; +import { boundedGlob, readProjectFile } from '../../shared/bounded-fs.js'; import * as path from 'node:path'; const EXTRA_IGNORE = ['**/env/**', '**/.env/**']; diff --git a/src/frameworks/fastapi/utils.ts b/src/store/frameworks/fastapi/utils.ts similarity index 97% rename from src/frameworks/fastapi/utils.ts rename to src/store/frameworks/fastapi/utils.ts index b208dd72f..e8fd56850 100644 --- a/src/frameworks/fastapi/utils.ts +++ b/src/store/frameworks/fastapi/utils.ts @@ -1,7 +1,7 @@ import { major, minVersion } from 'semver'; -import { boundedGlob, readProjectFile } from '@utils/bounded-fs'; -import { getUI } from '@ui'; -import type { WizardRunOptions } from '@utils/types'; +import { boundedGlob, readProjectFile } from '../../shared/bounded-fs.js'; +import { getUI } from '../../ui/index.js'; +import type { WizardRunOptions } from '../../shared/types.js'; import * as path from 'node:path'; export enum FastAPIProjectType { diff --git a/src/frameworks/flask/flask-wizard-agent.ts b/src/store/frameworks/flask/flask-wizard-agent.ts similarity index 91% rename from src/frameworks/flask/flask-wizard-agent.ts rename to src/store/frameworks/flask/flask-wizard-agent.ts index 539afa840..7234e608f 100644 --- a/src/frameworks/flask/flask-wizard-agent.ts +++ b/src/store/frameworks/flask/flask-wizard-agent.ts @@ -1,10 +1,10 @@ /* Flask wizard using posthog-agent with PostHog MCP */ -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 { boundedGlob, readProjectFile } from '@utils/bounded-fs'; +import type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { PYTHON_PACKAGE_INSTALLATION } from '../../framework-config.js'; +import { detectPythonPackageManagers } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; +import { boundedGlob, readProjectFile } from '../../shared/bounded-fs.js'; import * as path from 'node:path'; import { getFlaskVersion, @@ -13,7 +13,7 @@ import { getFlaskVersionBucket, FlaskProjectType, findFlaskAppFile, -} from './utils'; +} from './utils.js'; const EXTRA_IGNORE = ['**/env/**', '**/.env/**']; diff --git a/src/frameworks/flask/utils.ts b/src/store/frameworks/flask/utils.ts similarity index 97% rename from src/frameworks/flask/utils.ts rename to src/store/frameworks/flask/utils.ts index 66eb46a1c..bb3a89d9c 100644 --- a/src/frameworks/flask/utils.ts +++ b/src/store/frameworks/flask/utils.ts @@ -1,7 +1,7 @@ -import { boundedGlob, readProjectFile } from '@utils/bounded-fs'; -import { getUI } from '@ui'; -import type { WizardRunOptions } from '@utils/types'; -import { createVersionBucket } from '@utils/semver'; +import { boundedGlob, readProjectFile } from '../../shared/bounded-fs.js'; +import { getUI } from '../../ui/index.js'; +import type { WizardRunOptions } from '../../shared/types.js'; +import { createVersionBucket } from '../../shared/semver.js'; import * as path from 'node:path'; export enum FlaskProjectType { diff --git a/src/frameworks/flutter/flutter-wizard-agent.ts b/src/store/frameworks/flutter/flutter-wizard-agent.ts similarity index 93% rename from src/frameworks/flutter/flutter-wizard-agent.ts rename to src/store/frameworks/flutter/flutter-wizard-agent.ts index 8a44cddfc..8b69f84d3 100644 --- a/src/frameworks/flutter/flutter-wizard-agent.ts +++ b/src/store/frameworks/flutter/flutter-wizard-agent.ts @@ -1,10 +1,10 @@ /* 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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { Integration } from '../../shared/constants.js'; import * as fs from 'node:fs'; import * as path from 'node:path'; -import { pubPackageManager } from '@lib/detection/package-manager'; +import { pubPackageManager } from '../../detection/package-manager.js'; /** Platform subtrees `flutter create` scaffolds; each needs its own setup notes. */ const FLUTTER_PLATFORM_DIRS = [ diff --git a/src/frameworks/go/go-wizard-agent.ts b/src/store/frameworks/go/go-wizard-agent.ts similarity index 92% rename from src/frameworks/go/go-wizard-agent.ts rename to src/store/frameworks/go/go-wizard-agent.ts index 6010e945b..f4155821a 100644 --- a/src/frameworks/go/go-wizard-agent.ts +++ b/src/store/frameworks/go/go-wizard-agent.ts @@ -1,10 +1,10 @@ /* Go wizard using posthog-agent with PostHog MCP */ import * as fs from 'node:fs'; 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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { goModulesPackageManager } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; type GoContext = { goVersion?: string; diff --git a/src/frameworks/java/java-wizard-agent.ts b/src/store/frameworks/java/java-wizard-agent.ts similarity index 95% rename from src/frameworks/java/java-wizard-agent.ts rename to src/store/frameworks/java/java-wizard-agent.ts index 9223a0525..055d6ea7d 100644 --- a/src/frameworks/java/java-wizard-agent.ts +++ b/src/store/frameworks/java/java-wizard-agent.ts @@ -2,10 +2,10 @@ import fg from 'fast-glob'; import * as fs from 'node:fs'; 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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { detectJavaPackageManagers } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; type JavaContext = { buildTool?: 'maven' | 'gradle'; diff --git a/src/frameworks/javascript-node/javascript-node-wizard-agent.ts b/src/store/frameworks/javascript-node/javascript-node-wizard-agent.ts similarity index 89% rename from src/frameworks/javascript-node/javascript-node-wizard-agent.ts rename to src/store/frameworks/javascript-node/javascript-node-wizard-agent.ts index fb12fb38e..e83ee3f28 100644 --- a/src/frameworks/javascript-node/javascript-node-wizard-agent.ts +++ b/src/store/frameworks/javascript-node/javascript-node-wizard-agent.ts @@ -1,8 +1,8 @@ /* Generic Node.js language wizard using posthog-agent with PostHog MCP */ -import type { FrameworkConfig } from '@lib/framework-config'; -import { Integration } from '@lib/constants'; -import { tryGetPackageJson } from '@utils/setup-utils'; -import { detectNodePackageManagers } from '@lib/detection/package-manager'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { Integration } from '../../shared/constants.js'; +import { tryGetPackageJson } from '../../shared/setup-utils.js'; +import { detectNodePackageManagers } from '../../detection/package-manager.js'; type JavaScriptNodeContext = Record; diff --git a/src/frameworks/javascript-web/javascript-web-wizard-agent.ts b/src/store/frameworks/javascript-web/javascript-web-wizard-agent.ts similarity index 91% rename from src/frameworks/javascript-web/javascript-web-wizard-agent.ts rename to src/store/frameworks/javascript-web/javascript-web-wizard-agent.ts index 1f963eab3..bd65fe3cd 100644 --- a/src/frameworks/javascript-web/javascript-web-wizard-agent.ts +++ b/src/store/frameworks/javascript-web/javascript-web-wizard-agent.ts @@ -1,19 +1,19 @@ /* 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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { Integration } from '../../shared/constants.js'; import * as fs from 'node:fs'; import * as path from 'node:path'; -import { hasDeclaredDependency } from '@utils/package-json'; -import { tryGetPackageJson } from '@utils/setup-utils'; +import { hasDeclaredDependency } from '../../shared/package-json.js'; +import { tryGetPackageJson } from '../../shared/setup-utils.js'; import { FRAMEWORK_PACKAGES, detectJsPackageManager, detectBundler, hasIndexHtml, type JavaScriptContext, -} from './utils'; -import { detectNodePackageManagers } from '@lib/detection/package-manager'; +} from './utils.js'; +import { detectNodePackageManagers } from '../../detection/package-manager.js'; export const JAVASCRIPT_WEB_AGENT_CONFIG: FrameworkConfig = { metadata: { diff --git a/src/frameworks/javascript-web/utils.ts b/src/store/frameworks/javascript-web/utils.ts similarity index 91% rename from src/frameworks/javascript-web/utils.ts rename to src/store/frameworks/javascript-web/utils.ts index 276b72216..110edaa2f 100644 --- a/src/frameworks/javascript-web/utils.ts +++ b/src/store/frameworks/javascript-web/utils.ts @@ -1,8 +1,8 @@ import * as fs from 'node:fs'; import * as path from 'node:path'; -import { boundedGlob } from '@utils/bounded-fs'; -import { detectAllPackageManagers } from '@utils/package-manager'; -import type { WizardRunOptions } from '@utils/types'; +import { boundedGlob } from '../../shared/bounded-fs.js'; +import { detectAllPackageManagers } from '../../shared/package-manager.js'; +import type { WizardRunOptions } from '../../shared/types.js'; export type JavaScriptContext = { packageManagerName?: string; diff --git a/src/frameworks/kmp/kmp-wizard-agent.ts b/src/store/frameworks/kmp/kmp-wizard-agent.ts similarity index 93% rename from src/frameworks/kmp/kmp-wizard-agent.ts rename to src/store/frameworks/kmp/kmp-wizard-agent.ts index 6fa6085d2..51dd01bd6 100644 --- a/src/frameworks/kmp/kmp-wizard-agent.ts +++ b/src/store/frameworks/kmp/kmp-wizard-agent.ts @@ -1,8 +1,8 @@ /* Kotlin Multiplatform (KMP) wizard using posthog-agent with PostHog MCP */ -import type { FrameworkConfig } from '../../lib/framework-config'; -import { Integration } from '../../lib/constants'; -import { gradlePackageManager } from '../../lib/detection/package-manager'; -import { boundedGlob, readProjectFile } from '@utils/bounded-fs'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { Integration } from '../../shared/constants.js'; +import { gradlePackageManager } from '../../detection/package-manager.js'; +import { boundedGlob, readProjectFile } from '../../shared/bounded-fs.js'; import * as path from 'node:path'; export const KMP_AGENT_CONFIG: FrameworkConfig = { diff --git a/src/frameworks/laravel/laravel-wizard-agent.ts b/src/store/frameworks/laravel/laravel-wizard-agent.ts similarity index 94% rename from src/frameworks/laravel/laravel-wizard-agent.ts rename to src/store/frameworks/laravel/laravel-wizard-agent.ts index 36b81b971..58c8166b3 100644 --- a/src/frameworks/laravel/laravel-wizard-agent.ts +++ b/src/store/frameworks/laravel/laravel-wizard-agent.ts @@ -1,9 +1,9 @@ /* Laravel wizard using posthog-agent with PostHog MCP */ -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 { boundedGlob } from '@utils/bounded-fs'; +import type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { composerPackageManager } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; +import { boundedGlob } from '../../shared/bounded-fs.js'; import * as fs from 'node:fs'; import * as path from 'node:path'; import { @@ -15,7 +15,7 @@ import { findLaravelServiceProvider, findLaravelBootstrapFile, detectLaravelStructure, -} from './utils'; +} from './utils.js'; type LaravelContext = { projectType?: LaravelProjectType; diff --git a/src/frameworks/laravel/utils.ts b/src/store/frameworks/laravel/utils.ts similarity index 96% rename from src/frameworks/laravel/utils.ts rename to src/store/frameworks/laravel/utils.ts index 08f9e6900..55a52bf80 100644 --- a/src/frameworks/laravel/utils.ts +++ b/src/store/frameworks/laravel/utils.ts @@ -1,7 +1,7 @@ -import { boundedGlob, readProjectFile } from '@utils/bounded-fs'; -import { getUI } from '@ui'; -import type { WizardRunOptions } from '@utils/types'; -import { createVersionBucket } from '@utils/semver'; +import { boundedGlob, readProjectFile } from '../../shared/bounded-fs.js'; +import { getUI } from '../../ui/index.js'; +import type { WizardRunOptions } from '../../shared/types.js'; +import { createVersionBucket } from '../../shared/semver.js'; import * as fs from 'node:fs'; import * as path from 'node:path'; diff --git a/src/frameworks/nextjs/nextjs-wizard-agent.ts b/src/store/frameworks/nextjs/nextjs-wizard-agent.ts similarity index 88% rename from src/frameworks/nextjs/nextjs-wizard-agent.ts rename to src/store/frameworks/nextjs/nextjs-wizard-agent.ts index d98442f5a..65f2139ed 100644 --- a/src/frameworks/nextjs/nextjs-wizard-agent.ts +++ b/src/store/frameworks/nextjs/nextjs-wizard-agent.ts @@ -1,22 +1,22 @@ /* Simplified Next.js wizard using posthog-agent with PostHog MCP */ -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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { detectNodePackageManagers } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; import { getDeclaredVersion, getInstalledPackageVersion, hasDeclaredDependency, type PackageJson, -} from '@utils/package-json'; -import { tryGetPackageJson } from '@utils/setup-utils'; -import { getUI } from '@ui'; +} from '../../shared/package-json.js'; +import { tryGetPackageJson } from '../../shared/setup-utils.js'; +import { getUI } from '../../ui/index.js'; import { getNextJsRouter, getNextJsVersionBucket, getNextJsRouterName, NextJsRouter, -} from './utils'; +} from './utils.js'; type NextjsContext = { router?: NextJsRouter; diff --git a/src/frameworks/nextjs/utils.ts b/src/store/frameworks/nextjs/utils.ts similarity index 86% rename from src/frameworks/nextjs/utils.ts rename to src/store/frameworks/nextjs/utils.ts index 2815df167..2a89e29d4 100644 --- a/src/frameworks/nextjs/utils.ts +++ b/src/store/frameworks/nextjs/utils.ts @@ -1,6 +1,6 @@ -import type { WizardRunOptions } from '@utils/types'; -import { boundedGlob } from '@utils/bounded-fs'; -import { createVersionBucket } from '@utils/semver'; +import type { WizardRunOptions } from '../../shared/types.js'; +import { boundedGlob } from '../../shared/bounded-fs.js'; +import { createVersionBucket } from '../../shared/semver.js'; export const getNextJsVersionBucket = createVersionBucket(); diff --git a/src/frameworks/nuxt/nuxt-wizard-agent.ts b/src/store/frameworks/nuxt/nuxt-wizard-agent.ts similarity index 86% rename from src/frameworks/nuxt/nuxt-wizard-agent.ts rename to src/store/frameworks/nuxt/nuxt-wizard-agent.ts index 56899b903..70d019293 100644 --- a/src/frameworks/nuxt/nuxt-wizard-agent.ts +++ b/src/store/frameworks/nuxt/nuxt-wizard-agent.ts @@ -1,16 +1,16 @@ /* Nuxt wizard using posthog-agent with PostHog MCP */ -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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { detectNodePackageManagers } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; import { getDeclaredVersion, getInstalledPackageVersion, hasDeclaredDependency, type PackageJson, -} from '@utils/package-json'; -import { tryGetPackageJson } from '@utils/setup-utils'; -import { createVersionBucket } from '@utils/semver'; +} from '../../shared/package-json.js'; +import { tryGetPackageJson } from '../../shared/setup-utils.js'; +import { createVersionBucket } from '../../shared/semver.js'; const getNuxtVersionBucket = createVersionBucket(); diff --git a/src/frameworks/python/python-wizard-agent.ts b/src/store/frameworks/python/python-wizard-agent.ts similarity index 94% rename from src/frameworks/python/python-wizard-agent.ts rename to src/store/frameworks/python/python-wizard-agent.ts index fc44b370b..aeaeef356 100644 --- a/src/frameworks/python/python-wizard-agent.ts +++ b/src/store/frameworks/python/python-wizard-agent.ts @@ -1,9 +1,9 @@ /* Generic Python language wizard using posthog-agent with PostHog MCP */ -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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { PYTHON_PACKAGE_INSTALLATION } from '../../framework-config.js'; +import { detectPythonPackageManagers } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; import fg from 'fast-glob'; import * as fs from 'node:fs'; import * as path from 'node:path'; @@ -13,7 +13,7 @@ import { detectPackageManager, getPackageManagerName, PythonPackageManager, -} from './utils'; +} from './utils.js'; type PythonContext = { packageManager?: PythonPackageManager; diff --git a/src/frameworks/python/utils.ts b/src/store/frameworks/python/utils.ts similarity index 98% rename from src/frameworks/python/utils.ts rename to src/store/frameworks/python/utils.ts index 1eb8ac78d..297c6a45e 100644 --- a/src/frameworks/python/utils.ts +++ b/src/store/frameworks/python/utils.ts @@ -1,5 +1,5 @@ import { execSync } from 'node:child_process'; -import type { WizardRunOptions } from '@utils/types'; +import type { WizardRunOptions } from '../../shared/types.js'; export enum PythonPackageManager { UV = 'uv', diff --git a/src/frameworks/rails/rails-wizard-agent.ts b/src/store/frameworks/rails/rails-wizard-agent.ts similarity index 93% rename from src/frameworks/rails/rails-wizard-agent.ts rename to src/store/frameworks/rails/rails-wizard-agent.ts index f473ac98b..c13a5c18d 100644 --- a/src/frameworks/rails/rails-wizard-agent.ts +++ b/src/store/frameworks/rails/rails-wizard-agent.ts @@ -1,8 +1,8 @@ /* Ruby on Rails wizard using posthog-agent with PostHog MCP */ -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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { bundlerPackageManager } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; import { getRailsVersion, getRailsProjectType, @@ -11,7 +11,7 @@ import { RailsProjectType, findInitializersDir, isRailsProject, -} from './utils'; +} from './utils.js'; type RailsContext = { projectType?: RailsProjectType; diff --git a/src/frameworks/rails/utils.ts b/src/store/frameworks/rails/utils.ts similarity index 96% rename from src/frameworks/rails/utils.ts rename to src/store/frameworks/rails/utils.ts index ab7993e4d..7cc5c5a15 100644 --- a/src/frameworks/rails/utils.ts +++ b/src/store/frameworks/rails/utils.ts @@ -1,7 +1,7 @@ import fg from 'fast-glob'; -import { getUI } from '@ui'; -import type { WizardRunOptions } from '@utils/types'; -import { createVersionBucket } from '@utils/semver'; +import { getUI } from '../../ui/index.js'; +import type { WizardRunOptions } from '../../shared/types.js'; +import { createVersionBucket } from '../../shared/semver.js'; import * as fs from 'node:fs'; import * as path from 'node:path'; diff --git a/src/frameworks/react-native/react-native-wizard-agent.ts b/src/store/frameworks/react-native/react-native-wizard-agent.ts similarity index 90% rename from src/frameworks/react-native/react-native-wizard-agent.ts rename to src/store/frameworks/react-native/react-native-wizard-agent.ts index 7d231781c..7d3b959be 100644 --- a/src/frameworks/react-native/react-native-wizard-agent.ts +++ b/src/store/frameworks/react-native/react-native-wizard-agent.ts @@ -1,21 +1,21 @@ /* React Native wizard using posthog-agent with PostHog MCP */ -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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { detectNodePackageManagers } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; import { getDeclaredVersion, getInstalledPackageVersion, hasDeclaredDependency, type PackageJson, -} from '@utils/package-json'; -import { tryGetPackageJson } from '@utils/setup-utils'; +} from '../../shared/package-json.js'; +import { tryGetPackageJson } from '../../shared/setup-utils.js'; import { detectReactNativeVariant, getReactNativeVariantName, getReactNativeVersionBucket, ReactNativeVariant, -} from './utils'; +} from './utils.js'; type ReactNativeContext = { variant?: ReactNativeVariant; diff --git a/src/frameworks/react-native/utils.ts b/src/store/frameworks/react-native/utils.ts similarity index 74% rename from src/frameworks/react-native/utils.ts rename to src/store/frameworks/react-native/utils.ts index a3601217f..7e09828d6 100644 --- a/src/frameworks/react-native/utils.ts +++ b/src/store/frameworks/react-native/utils.ts @@ -1,8 +1,8 @@ -import { createVersionBucket } from '@utils/semver'; -import { tryGetPackageJson } from '@utils/setup-utils'; -import { hasDeclaredDependency } from '@utils/package-json'; -import { getUI } from '@ui'; -import type { WizardRunOptions } from '@utils/types'; +import { createVersionBucket } from '../../shared/semver.js'; +import { tryGetPackageJson } from '../../shared/setup-utils.js'; +import { hasDeclaredDependency } from '../../shared/package-json.js'; +import { getUI } from '../../ui/index.js'; +import type { WizardRunOptions } from '../../shared/types.js'; export const getReactNativeVersionBucket = createVersionBucket(); diff --git a/src/frameworks/react-router/react-router-wizard-agent.ts b/src/store/frameworks/react-router/react-router-wizard-agent.ts similarity index 89% rename from src/frameworks/react-router/react-router-wizard-agent.ts rename to src/store/frameworks/react-router/react-router-wizard-agent.ts index e1c211ebe..a62514391 100644 --- a/src/frameworks/react-router/react-router-wizard-agent.ts +++ b/src/store/frameworks/react-router/react-router-wizard-agent.ts @@ -1,22 +1,22 @@ /* React Router wizard using posthog-agent with PostHog MCP */ -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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { detectNodePackageManagers } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; import { getDeclaredVersion, getInstalledPackageVersion, hasDeclaredDependency, type PackageJson, -} from '@utils/package-json'; -import { tryGetPackageJson } from '@utils/setup-utils'; -import { getUI } from '@ui'; +} from '../../shared/package-json.js'; +import { tryGetPackageJson } from '../../shared/setup-utils.js'; +import { getUI } from '../../ui/index.js'; import { getReactRouterMode, getReactRouterModeName, getReactRouterVersionBucket, ReactRouterMode, -} from './utils'; +} from './utils.js'; type ReactRouterContext = { routerMode?: ReactRouterMode; diff --git a/src/frameworks/react-router/utils.ts b/src/store/frameworks/react-router/utils.ts similarity index 91% rename from src/frameworks/react-router/utils.ts rename to src/store/frameworks/react-router/utils.ts index 05987339b..2183106fe 100644 --- a/src/frameworks/react-router/utils.ts +++ b/src/store/frameworks/react-router/utils.ts @@ -1,9 +1,9 @@ import { major } from 'semver'; -import { tryGetPackageJson } from '@utils/setup-utils'; -import type { WizardRunOptions } from '@utils/types'; -import { boundedGlob, readProjectFile } from '@utils/bounded-fs'; -import { getDeclaredVersion } from '@utils/package-json'; -import { createVersionBucket } from '@utils/semver'; +import { tryGetPackageJson } from '../../shared/setup-utils.js'; +import type { WizardRunOptions } from '../../shared/types.js'; +import { boundedGlob, readProjectFile } from '../../shared/bounded-fs.js'; +import { getDeclaredVersion } from '../../shared/package-json.js'; +import { createVersionBucket } from '../../shared/semver.js'; import * as path from 'node:path'; import * as semver from 'semver'; diff --git a/src/frameworks/ruby/ruby-wizard-agent.ts b/src/store/frameworks/ruby/ruby-wizard-agent.ts similarity index 93% rename from src/frameworks/ruby/ruby-wizard-agent.ts rename to src/store/frameworks/ruby/ruby-wizard-agent.ts index aa63873b9..526262ea8 100644 --- a/src/frameworks/ruby/ruby-wizard-agent.ts +++ b/src/store/frameworks/ruby/ruby-wizard-agent.ts @@ -1,8 +1,8 @@ /* Generic Ruby language wizard using posthog-agent with PostHog MCP */ -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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { bundlerPackageManager } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; import { getRubyVersion, getRubyVersionBucket, @@ -10,7 +10,7 @@ import { getPackageManagerName, RubyPackageManager, isRubyProject, -} from './utils'; +} from './utils.js'; type RubyContext = { packageManager?: RubyPackageManager; diff --git a/src/frameworks/ruby/utils.ts b/src/store/frameworks/ruby/utils.ts similarity index 94% rename from src/frameworks/ruby/utils.ts rename to src/store/frameworks/ruby/utils.ts index d86deee1c..7341c38c8 100644 --- a/src/frameworks/ruby/utils.ts +++ b/src/store/frameworks/ruby/utils.ts @@ -1,6 +1,6 @@ -import { boundedGlob } from '@utils/bounded-fs'; -import type { WizardRunOptions } from '@utils/types'; -import { createVersionBucket } from '@utils/semver'; +import { boundedGlob } from '../../shared/bounded-fs.js'; +import type { WizardRunOptions } from '../../shared/types.js'; +import { createVersionBucket } from '../../shared/semver.js'; import * as fs from 'node:fs'; import * as path from 'node:path'; diff --git a/src/frameworks/rust/rust-wizard-agent.ts b/src/store/frameworks/rust/rust-wizard-agent.ts similarity index 93% rename from src/frameworks/rust/rust-wizard-agent.ts rename to src/store/frameworks/rust/rust-wizard-agent.ts index 6c0aef1e2..cf05d1116 100644 --- a/src/frameworks/rust/rust-wizard-agent.ts +++ b/src/store/frameworks/rust/rust-wizard-agent.ts @@ -1,10 +1,10 @@ /* Rust wizard using posthog-agent with PostHog MCP */ import * as fs from 'node:fs'; 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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { cargoPackageManager } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; type RustContext = { asyncRuntime?: boolean; diff --git a/src/frameworks/svelte/svelte-wizard-agent.ts b/src/store/frameworks/svelte/svelte-wizard-agent.ts similarity index 86% rename from src/frameworks/svelte/svelte-wizard-agent.ts rename to src/store/frameworks/svelte/svelte-wizard-agent.ts index e84e2cef7..a43986ad8 100644 --- a/src/frameworks/svelte/svelte-wizard-agent.ts +++ b/src/store/frameworks/svelte/svelte-wizard-agent.ts @@ -1,13 +1,13 @@ /* 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 type { FrameworkConfig } from '../../framework-config.js'; +import { detectNodePackageManagers } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; import { getDeclaredVersion, hasDeclaredDependency, type PackageJson, -} from '@utils/package-json'; -import { tryGetPackageJson } from '@utils/setup-utils'; +} from '../../shared/package-json.js'; +import { tryGetPackageJson } from '../../shared/setup-utils.js'; type SvelteKitContext = Record; diff --git a/src/frameworks/swift/__tests__/utils.test.ts b/src/store/frameworks/swift/__tests__/utils.test.ts similarity index 96% rename from src/frameworks/swift/__tests__/utils.test.ts rename to src/store/frameworks/swift/__tests__/utils.test.ts index 1705b3da4..f50705ad4 100644 --- a/src/frameworks/swift/__tests__/utils.test.ts +++ b/src/store/frameworks/swift/__tests__/utils.test.ts @@ -1,8 +1,8 @@ import * as fs from 'fs'; import * as path from 'path'; import * as os from 'os'; -import { detectSwiftProjectType, SwiftProjectType } from '../utils'; -import type { WizardRunOptions } from '@utils/types'; +import { detectSwiftProjectType, SwiftProjectType } from '../utils.js'; +import type { WizardRunOptions } from '../../../shared/types.js'; function makeTmpDir(): string { return fs.mkdtempSync(path.join(os.tmpdir(), 'swift-utils-')); diff --git a/src/frameworks/swift/swift-wizard-agent.ts b/src/store/frameworks/swift/swift-wizard-agent.ts similarity index 92% rename from src/frameworks/swift/swift-wizard-agent.ts rename to src/store/frameworks/swift/swift-wizard-agent.ts index 5e6343b87..60b19e790 100644 --- a/src/frameworks/swift/swift-wizard-agent.ts +++ b/src/store/frameworks/swift/swift-wizard-agent.ts @@ -1,9 +1,9 @@ /* Swift wizard using posthog-agent with PostHog MCP */ -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 { boundedGlob } from '@utils/bounded-fs'; +import type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { swiftPackageManager } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; +import { boundedGlob } from '../../shared/bounded-fs.js'; import fg from 'fast-glob'; import * as fs from 'node:fs'; import * as path from 'node:path'; @@ -11,7 +11,7 @@ import { detectSwiftProjectType, getSwiftProjectTypeName, SwiftProjectType, -} from './utils'; +} from './utils.js'; type SwiftContext = { projectType?: SwiftProjectType; diff --git a/src/frameworks/swift/utils.ts b/src/store/frameworks/swift/utils.ts similarity index 93% rename from src/frameworks/swift/utils.ts rename to src/store/frameworks/swift/utils.ts index a41d51ca3..b592bc22c 100644 --- a/src/frameworks/swift/utils.ts +++ b/src/store/frameworks/swift/utils.ts @@ -1,5 +1,5 @@ -import type { WizardRunOptions } from '@utils/types'; -import { boundedGlob, readProjectFile } from '@utils/bounded-fs'; +import type { WizardRunOptions } from '../../shared/types.js'; +import { boundedGlob, readProjectFile } from '../../shared/bounded-fs.js'; import fg from 'fast-glob'; import * as fs from 'node:fs'; import * as path from 'node:path'; diff --git a/src/frameworks/tanstack-router/tanstack-router-wizard-agent.ts b/src/store/frameworks/tanstack-router/tanstack-router-wizard-agent.ts similarity index 90% rename from src/frameworks/tanstack-router/tanstack-router-wizard-agent.ts rename to src/store/frameworks/tanstack-router/tanstack-router-wizard-agent.ts index c63245a85..2e5dddfa5 100644 --- a/src/frameworks/tanstack-router/tanstack-router-wizard-agent.ts +++ b/src/store/frameworks/tanstack-router/tanstack-router-wizard-agent.ts @@ -1,22 +1,22 @@ /* TanStack Router wizard using posthog-agent with PostHog MCP */ -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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { detectNodePackageManagers } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; import { getDeclaredVersion, getInstalledPackageVersion, hasDeclaredDependency, type PackageJson, -} from '@utils/package-json'; -import { tryGetPackageJson } from '@utils/setup-utils'; -import { getUI } from '@ui'; +} from '../../shared/package-json.js'; +import { tryGetPackageJson } from '../../shared/setup-utils.js'; +import { getUI } from '../../ui/index.js'; import { getTanStackRouterMode, getTanStackRouterModeName, getTanStackRouterVersionBucket, TanStackRouterMode, -} from './utils'; +} from './utils.js'; type TanStackRouterContext = { routerMode?: TanStackRouterMode; diff --git a/src/frameworks/tanstack-router/utils.ts b/src/store/frameworks/tanstack-router/utils.ts similarity index 92% rename from src/frameworks/tanstack-router/utils.ts rename to src/store/frameworks/tanstack-router/utils.ts index 450a4fe47..c3c76be1d 100644 --- a/src/frameworks/tanstack-router/utils.ts +++ b/src/store/frameworks/tanstack-router/utils.ts @@ -1,7 +1,7 @@ -import type { WizardRunOptions } from '@utils/types'; -import { boundedGlob, readProjectFile } from '@utils/bounded-fs'; -import { hasDeclaredDependency } from '@utils/package-json'; -import { createVersionBucket } from '@utils/semver'; +import type { WizardRunOptions } from '../../shared/types.js'; +import { boundedGlob, readProjectFile } from '../../shared/bounded-fs.js'; +import { hasDeclaredDependency } from '../../shared/package-json.js'; +import { createVersionBucket } from '../../shared/semver.js'; import * as fs from 'node:fs'; import * as path from 'node:path'; diff --git a/src/frameworks/tanstack-start/tanstack-start-wizard-agent.ts b/src/store/frameworks/tanstack-start/tanstack-start-wizard-agent.ts similarity index 85% rename from src/frameworks/tanstack-start/tanstack-start-wizard-agent.ts rename to src/store/frameworks/tanstack-start/tanstack-start-wizard-agent.ts index a279ef6bb..dd650fa52 100644 --- a/src/frameworks/tanstack-start/tanstack-start-wizard-agent.ts +++ b/src/store/frameworks/tanstack-start/tanstack-start-wizard-agent.ts @@ -1,16 +1,16 @@ /* TanStack Start wizard using posthog-agent with PostHog MCP */ -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 type { WizardRunOptions } from '../../shared/types.js'; +import type { FrameworkConfig } from '../../framework-config.js'; +import { detectNodePackageManagers } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; import { getDeclaredVersion, getInstalledPackageVersion, hasDeclaredDependency, type PackageJson, -} from '@utils/package-json'; -import { tryGetPackageJson } from '@utils/setup-utils'; -import { getTanStackStartVersionBucket } from './utils'; +} from '../../shared/package-json.js'; +import { tryGetPackageJson } from '../../shared/setup-utils.js'; +import { getTanStackStartVersionBucket } from './utils.js'; type TanStackStartContext = Record; diff --git a/src/frameworks/tanstack-start/utils.ts b/src/store/frameworks/tanstack-start/utils.ts similarity index 67% rename from src/frameworks/tanstack-start/utils.ts rename to src/store/frameworks/tanstack-start/utils.ts index 4f9500600..6fc295bad 100644 --- a/src/frameworks/tanstack-start/utils.ts +++ b/src/store/frameworks/tanstack-start/utils.ts @@ -1,4 +1,4 @@ -import { createVersionBucket } from '@utils/semver'; +import { createVersionBucket } from '../../shared/semver.js'; /** * Get TanStack Start version bucket for analytics diff --git a/src/frameworks/vue/vue-wizard-agent.ts b/src/store/frameworks/vue/vue-wizard-agent.ts similarity index 85% rename from src/frameworks/vue/vue-wizard-agent.ts rename to src/store/frameworks/vue/vue-wizard-agent.ts index a37492a8d..732576500 100644 --- a/src/frameworks/vue/vue-wizard-agent.ts +++ b/src/store/frameworks/vue/vue-wizard-agent.ts @@ -1,15 +1,15 @@ /* 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 type { FrameworkConfig } from '../../framework-config.js'; +import { detectNodePackageManagers } from '../../detection/package-manager.js'; +import { Integration } from '../../shared/constants.js'; import { getDeclaredVersion, getInstalledPackageVersion, hasDeclaredDependency, type PackageJson, -} from '@utils/package-json'; -import { tryGetPackageJson } from '@utils/setup-utils'; -import { createVersionBucket } from '@utils/semver'; +} from '../../shared/package-json.js'; +import { tryGetPackageJson } from '../../shared/setup-utils.js'; +import { createVersionBucket } from '../../shared/semver.js'; const getVueVersionBucket = createVersionBucket(); diff --git a/src/lib/health-checks/__tests__/health-checks.test.ts b/src/store/health-checks/__tests__/health-checks.test.ts similarity index 98% rename from src/lib/health-checks/__tests__/health-checks.test.ts rename to src/store/health-checks/__tests__/health-checks.test.ts index b23b7e2c4..953103ca6 100644 --- a/src/lib/health-checks/__tests__/health-checks.test.ts +++ b/src/store/health-checks/__tests__/health-checks.test.ts @@ -5,12 +5,9 @@ import { evaluateWizardReadiness, ServiceHealthStatus, WizardReadiness, -} from '@lib/health-checks/index'; -import { - checkLlmGatewayHealth, - fetchEndpointHealth, -} from '@lib/health-checks/endpoints'; -import { SIGNUP_WIZARD_READINESS_CONFIG } from '@lib/health-checks/readiness'; +} from '../index.js'; +import { checkLlmGatewayHealth, fetchEndpointHealth } from '../endpoints.js'; +import { SIGNUP_WIZARD_READINESS_CONFIG } from '../readiness.js'; const URLS = { githubSkillMenu: diff --git a/src/lib/health-checks/endpoints.ts b/src/store/health-checks/endpoints.ts similarity index 97% rename from src/lib/health-checks/endpoints.ts rename to src/store/health-checks/endpoints.ts index f98a9eb7b..d352756bb 100644 --- a/src/lib/health-checks/endpoints.ts +++ b/src/store/health-checks/endpoints.ts @@ -1,6 +1,9 @@ -import { AWS_SKILLS_BASE_URL, GITHUB_SKILLS_BASE_URL } from '@lib/constants'; -import { logToFile } from '@utils/debug'; -import { ServiceHealthStatus, type BaseHealthResult } from './types'; +import { + AWS_SKILLS_BASE_URL, + GITHUB_SKILLS_BASE_URL, +} from '../shared/constants.js'; +import { logToFile } from '../shared/debug.js'; +import { ServiceHealthStatus, type BaseHealthResult } from './types.js'; // Direct gateway and skill-origin checks distinguish HTTP failures from connection failures. diff --git a/src/lib/health-checks/index.ts b/src/store/health-checks/index.ts similarity index 84% rename from src/lib/health-checks/index.ts rename to src/store/health-checks/index.ts index a6af0fb7c..3e4f8faf2 100644 --- a/src/lib/health-checks/index.ts +++ b/src/store/health-checks/index.ts @@ -3,9 +3,9 @@ export { type BaseHealthResult, type AllServicesHealth, type HealthCheckKey, -} from './types'; +} from './types.js'; -export { checkLlmGatewayHealth, checkSkillsOriginHealth } from './endpoints'; +export { checkLlmGatewayHealth, checkSkillsOriginHealth } from './endpoints.js'; export { type WizardReadinessConfig, @@ -14,4 +14,4 @@ export { WizardReadiness, type WizardReadinessResult, evaluateWizardReadiness, -} from './readiness'; +} from './readiness.js'; diff --git a/src/lib/health-checks/readiness.ts b/src/store/health-checks/readiness.ts similarity index 97% rename from src/lib/health-checks/readiness.ts rename to src/store/health-checks/readiness.ts index 0eba5a3b4..4957abe9c 100644 --- a/src/lib/health-checks/readiness.ts +++ b/src/store/health-checks/readiness.ts @@ -3,9 +3,9 @@ import { type AllServicesHealth, type BaseHealthResult, type HealthCheckKey, -} from './types'; -import { checkSkillsOriginHealth } from './endpoints'; -import { logToFile } from '@utils/debug'; +} from './types.js'; +import { checkSkillsOriginHealth } from './endpoints.js'; +import { logToFile } from '../shared/debug.js'; // --------------------------------------------------------------------------- // Service labels (used in human-readable reason strings) diff --git a/src/lib/health-checks/testme.md b/src/store/health-checks/testme.md similarity index 100% rename from src/lib/health-checks/testme.md rename to src/store/health-checks/testme.md diff --git a/src/lib/health-checks/types.ts b/src/store/health-checks/types.ts similarity index 100% rename from src/lib/health-checks/types.ts rename to src/store/health-checks/types.ts diff --git a/src/lib/helper-functions.ts b/src/store/helper-functions.ts similarity index 100% rename from src/lib/helper-functions.ts rename to src/store/helper-functions.ts diff --git a/src/lib/host-resolution.ts b/src/store/host-resolution.ts similarity index 97% rename from src/lib/host-resolution.ts rename to src/store/host-resolution.ts index f55f1b4bc..4789eeb24 100644 --- a/src/lib/host-resolution.ts +++ b/src/store/host-resolution.ts @@ -22,10 +22,10 @@ import { getUiHostFromHost, detectRegion, resolveBaseUrl, -} from '@utils/urls'; +} from './shared/urls.js'; import { IS_PRODUCTION_BUILD, runtimeEnv } from '@env'; -import { MCP_LOCAL_URL } from '@lib/local-dev'; -import type { CloudRegion } from '@utils/types'; +import { MCP_LOCAL_URL } from './local-dev.js'; +import type { CloudRegion } from './shared/types.js'; // The wizard's client gets CLI mode (a single `exec` tool) by server default, // so no mode is pinned; the dev env override (see env.ts) is taken verbatim. diff --git a/src/lib/local-dev.ts b/src/store/local-dev.ts similarity index 100% rename from src/lib/local-dev.ts rename to src/store/local-dev.ts diff --git a/src/lib/mcp-project-profile.ts b/src/store/mcp-project-profile.ts similarity index 99% rename from src/lib/mcp-project-profile.ts rename to src/store/mcp-project-profile.ts index 12a398871..b4ebff12d 100644 --- a/src/lib/mcp-project-profile.ts +++ b/src/store/mcp-project-profile.ts @@ -25,8 +25,8 @@ */ import axios from 'axios'; -import { WIZARD_USER_AGENT } from './constants'; -import { logToFile } from '@utils/debug'; +import { WIZARD_USER_AGENT } from './shared/constants.js'; +import { logToFile } from './shared/debug.js'; // Time-box every probe call. The scout sits on the critical path between // auth and the picker, so a wedged endpoint must not stall the tutorial. diff --git a/src/lib/mcp-role-prompts.copy.json b/src/store/mcp-role-prompts.copy.json similarity index 100% rename from src/lib/mcp-role-prompts.copy.json rename to src/store/mcp-role-prompts.copy.json diff --git a/src/lib/mcp-role-prompts.ts b/src/store/mcp-role-prompts.ts similarity index 99% rename from src/lib/mcp-role-prompts.ts rename to src/store/mcp-role-prompts.ts index 5b8921f73..50dbb4504 100644 --- a/src/lib/mcp-role-prompts.ts +++ b/src/store/mcp-role-prompts.ts @@ -19,11 +19,11 @@ * 3. Unknown role → DEFAULT_KIT. */ -import type { Integration } from './constants'; +import type { Integration } from './shared/constants.js'; import type { ProductPresence, ProjectDataProfile, -} from './mcp-project-profile'; +} from './mcp-project-profile.js'; import copyData from './mcp-role-prompts.copy.json'; /** Keys of `ProductPresence` — the products an activation cross-sell can target. */ diff --git a/src/lib/mcp-seed-events.ts b/src/store/mcp-seed-events.ts similarity index 98% rename from src/lib/mcp-seed-events.ts rename to src/store/mcp-seed-events.ts index 99d783189..ab8d37efc 100644 --- a/src/lib/mcp-seed-events.ts +++ b/src/store/mcp-seed-events.ts @@ -23,12 +23,12 @@ * meant to create. */ -import { logToFile } from '@utils/debug'; +import { logToFile } from './shared/debug.js'; import { assembleProfile, type EventVolume, type ProjectDataProfile, -} from './mcp-project-profile'; +} from './mcp-project-profile.js'; export interface SeedEvent { event: string; diff --git a/src/lib/programs/__tests__/__snapshots__/flow-traces.test.ts.snap b/src/store/programs/__tests__/__snapshots__/flow-traces.test.ts.snap similarity index 100% rename from src/lib/programs/__tests__/__snapshots__/flow-traces.test.ts.snap rename to src/store/programs/__tests__/__snapshots__/flow-traces.test.ts.snap diff --git a/src/lib/programs/__tests__/__snapshots__/post-auth-gates.test.ts.snap b/src/store/programs/__tests__/__snapshots__/post-auth-gates.test.ts.snap similarity index 100% rename from src/lib/programs/__tests__/__snapshots__/post-auth-gates.test.ts.snap rename to src/store/programs/__tests__/__snapshots__/post-auth-gates.test.ts.snap diff --git a/src/lib/programs/__tests__/agent-skill.test.ts b/src/store/programs/__tests__/agent-skill.test.ts similarity index 92% rename from src/lib/programs/__tests__/agent-skill.test.ts rename to src/store/programs/__tests__/agent-skill.test.ts index f3df4a406..a3161eac5 100644 --- a/src/lib/programs/__tests__/agent-skill.test.ts +++ b/src/store/programs/__tests__/agent-skill.test.ts @@ -2,10 +2,10 @@ import { createSkillProgram, AGENT_SKILL_STEPS, type SkillProgramOptions, -} from '@lib/programs/agent-skill/index'; -import type { ProgramRun } from '@lib/program-run'; -import { buildSession, RunPhase } from '@lib/wizard-session'; -import { HostResolution } from '@lib/host-resolution'; +} from '../agent-skill/index.js'; +import type { ProgramRun } from '../../agent-protocol/program-run.js'; +import { buildSession, RunPhase } from '../../session/wizard-session.js'; +import { HostResolution } from '../../host-resolution.js'; const baseOpts: SkillProgramOptions = { skillId: 'error-tracking-setup', diff --git a/src/lib/programs/__tests__/audit-seed.test.ts b/src/store/programs/__tests__/audit-seed.test.ts similarity index 91% rename from src/lib/programs/__tests__/audit-seed.test.ts rename to src/store/programs/__tests__/audit-seed.test.ts index 1897a2b19..0d0b4e1cd 100644 --- a/src/lib/programs/__tests__/audit-seed.test.ts +++ b/src/store/programs/__tests__/audit-seed.test.ts @@ -2,9 +2,9 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -import { AUDIT_SEED_CHECKS, seedAuditLedger } from '@lib/programs/audit/seed'; -import { AUDIT_CHECKS_FILE, type AuditCheck } from '@lib/programs/audit/types'; -import { COL_AREA_WIDTH } from '@ui/tui/screens/audit/AuditChecksViewer/layout'; +import { AUDIT_SEED_CHECKS, seedAuditLedger } from '../audit/seed.js'; +import { AUDIT_CHECKS_FILE, type AuditCheck } from '../audit/types.js'; +import { COL_AREA_WIDTH } from '@tui/screens/audit/AuditChecksViewer/layout'; const ids = (checks: AuditCheck[]) => checks.map((c) => c.id); diff --git a/src/lib/programs/__tests__/error-tracking.test.ts b/src/store/programs/__tests__/error-tracking.test.ts similarity index 83% rename from src/lib/programs/__tests__/error-tracking.test.ts rename to src/store/programs/__tests__/error-tracking.test.ts index b2520dcf2..8bbb4faa3 100644 --- a/src/lib/programs/__tests__/error-tracking.test.ts +++ b/src/store/programs/__tests__/error-tracking.test.ts @@ -1,39 +1,41 @@ import { beforeEach, describe, expect, test, vi } from 'vitest'; -import type { ProgramRun } from '@lib/program-run'; -import { Integration } from '@lib/constants'; -import type { AgenticDetectionReport } from '@lib/detection/agentic'; -import { detectFramework } from '@lib/detection/index'; -import { ErrorCodes } from '@lib/errors'; -import { ERROR_TRACKING_TIPS } from '@ui/tui/programs/error-tracking/content/tips'; +import type { ProgramRun } from '../../agent-protocol/program-run.js'; +import { Integration } from '../../shared/constants.js'; +import type { AgenticDetectionReport } from '../../detection/agentic.js'; +import { detectFramework } from '../../detection/index.js'; +import { ErrorCodes } from '../../shared/errors/index.js'; +import { ERROR_TRACKING_TIPS } from '@tui/programs/error-tracking/content/tips'; import { ERROR_TRACKING_PROJECT_PATH_KEY, toErrorTrackingReport, -} from '@lib/programs/error-tracking/detect-agentic'; +} from '../error-tracking/detect-agentic.js'; import { errorTrackingConfig, SYMBOL_UPLOAD_CLI_FRAMEWORKS, -} from '@lib/programs/error-tracking/index'; -import { VARIANTS_REQUIRING_POSTHOG_CLI } from '@lib/programs/error-tracking-upload-source-maps/detect'; -import { preinstallPostHogCliOnce } from '@lib/programs/shared/posthog-cli-preinstall'; -import type { WizardSession } from '@lib/wizard-session'; -import { analytics } from '@utils/analytics'; -import { wizardAbort } from '@utils/wizard-abort'; - -vi.mock('@lib/detection/index', async (importOriginal) => ({ - ...(await importOriginal()), +} from '../error-tracking/index.js'; +import { VARIANTS_REQUIRING_POSTHOG_CLI } from '../error-tracking-upload-source-maps/detect.js'; +import { preinstallPostHogCliOnce } from '../shared/posthog-cli-preinstall.js'; +import type { WizardSession } from '../../session/wizard-session.js'; +import { analytics } from '../../shared/analytics.js'; +import { wizardAbort } from '../../shared/wizard-abort.js'; + +vi.mock('../../detection/index.js', async (importOriginal) => ({ + ...(await importOriginal()), detectFramework: vi.fn(), })); -vi.mock('@lib/detection/project-scope', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('../../detection/project-scope.js', async (importOriginal) => ({ + ...(await importOriginal< + typeof import('../../detection/project-scope.js') + >()), scopeInstallDirToProject: vi.fn(), detectIntegrationProjects: vi.fn(), })); -vi.mock('@lib/programs/shared/posthog-cli-preinstall', () => ({ +vi.mock('../shared/posthog-cli-preinstall.js', () => ({ preinstallPostHogCliOnce: vi.fn(), })); -vi.mock('@utils/wizard-abort', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('../../shared/wizard-abort.js', async (importOriginal) => ({ + ...(await importOriginal()), wizardAbort: vi.fn(), })); diff --git a/src/lib/programs/__tests__/flow-traces.test.ts b/src/store/programs/__tests__/flow-traces.test.ts similarity index 90% rename from src/lib/programs/__tests__/flow-traces.test.ts rename to src/store/programs/__tests__/flow-traces.test.ts index bdc5c825a..a4f251ce1 100644 --- a/src/lib/programs/__tests__/flow-traces.test.ts +++ b/src/store/programs/__tests__/flow-traces.test.ts @@ -3,31 +3,31 @@ * by walking each program's steps through the store with a generic advance per * screen. Baseline for the surface split: must stay byte identical. */ -import { WizardStore, RunPhase, McpOutcome } from '@ui/tui/store'; -import { ScreenId } from '@ui/tui/router'; -import { InkUI } from '@ui/tui/ink-ui'; -import { setUI } from '@ui/index'; +import { WizardStore, RunPhase, McpOutcome } from '../../state/store.js'; +import { ScreenId } from '@tui/router'; +import { InkUI } from '@tui/ink-ui'; +import { setUI } from '../../ui/index.js'; import { buildSession, OutroKind, type WizardSession, -} from '@lib/wizard-session'; -import { Integration } from '@lib/constants'; -import { FRAMEWORK_REGISTRY } from '@lib/registry'; -import { HostResolution } from '@lib/host-resolution'; -import { WizardReadiness } from '@lib/health-checks/readiness'; -import { analytics } from '@utils/analytics'; +} from '../../session/wizard-session.js'; +import { Integration } from '../../shared/constants.js'; +import { FRAMEWORK_REGISTRY } from '../../registry.js'; +import { HostResolution } from '../../host-resolution.js'; +import { WizardReadiness } from '../../health-checks/readiness.js'; +import { analytics } from '../../shared/analytics.js'; import { PROGRAM_REGISTRY, getProgramConfig, type ProgramId, -} from '../program-registry'; -import { SELF_DRIVING_INTEGRATE_PATH_KEY } from '../self-driving/detect'; -import { ERROR_TRACKING_PROJECT_PATH_KEY } from '../error-tracking/detect-agentic'; -import { SOURCE_MAPS_CONTEXT_KEYS } from '../error-tracking-upload-source-maps/detect'; -import { flowFor } from '@lib/programs/flow-for'; +} from '../program-registry.js'; +import { SELF_DRIVING_INTEGRATE_PATH_KEY } from '../self-driving/detect.js'; +import { ERROR_TRACKING_PROJECT_PATH_KEY } from '../error-tracking/detect-agentic.js'; +import { SOURCE_MAPS_CONTEXT_KEYS } from '../error-tracking-upload-source-maps/detect.js'; +import { flowFor } from '../flow-for.js'; -vi.mock('@utils/analytics', () => ({ +vi.mock('../../shared/analytics.js', () => ({ analytics: { capture: vi.fn(), wizardCapture: vi.fn(), diff --git a/src/lib/programs/__tests__/mcp-analytics.test.ts b/src/store/programs/__tests__/mcp-analytics.test.ts similarity index 97% rename from src/lib/programs/__tests__/mcp-analytics.test.ts rename to src/store/programs/__tests__/mcp-analytics.test.ts index e9a8546dc..65fd22a59 100644 --- a/src/lib/programs/__tests__/mcp-analytics.test.ts +++ b/src/store/programs/__tests__/mcp-analytics.test.ts @@ -1,7 +1,7 @@ import { MCP_ANALYTICS_ABORT_CASES, mcpAnalyticsConfig, -} from '@lib/programs/mcp-analytics/index'; +} from '../mcp-analytics/index.js'; describe('MCP_ANALYTICS_ABORT_CASES', () => { // These are the exact `[ABORT] ` strings the mcp-analytics skill diff --git a/src/lib/programs/__tests__/metrics-program.test.ts b/src/store/programs/__tests__/metrics-program.test.ts similarity index 87% rename from src/lib/programs/__tests__/metrics-program.test.ts rename to src/store/programs/__tests__/metrics-program.test.ts index 3a7eba662..ffaaf0b45 100644 --- a/src/lib/programs/__tests__/metrics-program.test.ts +++ b/src/store/programs/__tests__/metrics-program.test.ts @@ -1,9 +1,9 @@ -import { AGENT_SKILL_STEPS } from '@lib/programs/agent-skill/index'; -import { getProgramConfig, Program } from '@lib/programs/program-registry'; -import { metricsConfig } from '@lib/programs/metrics/index'; -import type { ProgramRun } from '@lib/program-run'; +import { AGENT_SKILL_STEPS } from '../agent-skill/index.js'; +import { getProgramConfig, Program } from '../program-registry.js'; +import { metricsConfig } from '../metrics/index.js'; +import type { ProgramRun } from '../../agent-protocol/program-run.js'; -import { metricsCommand } from '../../../commands/metrics'; +import { metricsCommand } from '@cli/commands/metrics'; function staticRun(config: typeof metricsConfig): ProgramRun { if (typeof config.run === 'function') { diff --git a/src/lib/programs/__tests__/post-auth-gates.test.ts b/src/store/programs/__tests__/post-auth-gates.test.ts similarity index 83% rename from src/lib/programs/__tests__/post-auth-gates.test.ts rename to src/store/programs/__tests__/post-auth-gates.test.ts index 15caa52a2..fa17fdea6 100644 --- a/src/lib/programs/__tests__/post-auth-gates.test.ts +++ b/src/store/programs/__tests__/post-auth-gates.test.ts @@ -2,8 +2,8 @@ * Golden of the post-auth gate ids the agent runner awaits per program * (`postAuthGateIdsFor`, the walk between the `auth` and `run` steps). */ -import { PROGRAM_REGISTRY } from '../program-registry'; -import { postAuthGateIdsFor, runConfigFor } from '../run-config'; +import { PROGRAM_REGISTRY } from '../program-registry.js'; +import { postAuthGateIdsFor, runConfigFor } from '../run-config.js'; describe('post-auth gate ids per program', () => { it('match the golden', () => { diff --git a/src/lib/programs/__tests__/posthog-cli-preinstall.test.ts b/src/store/programs/__tests__/posthog-cli-preinstall.test.ts similarity index 82% rename from src/lib/programs/__tests__/posthog-cli-preinstall.test.ts rename to src/store/programs/__tests__/posthog-cli-preinstall.test.ts index 355fd10b1..f05cf5218 100644 --- a/src/lib/programs/__tests__/posthog-cli-preinstall.test.ts +++ b/src/store/programs/__tests__/posthog-cli-preinstall.test.ts @@ -3,18 +3,18 @@ import { beforeEach, describe, expect, test, vi } from 'vitest'; import { preinstallPostHogCliOnce, resetPostHogCliPreinstallForTests, -} from '@lib/programs/shared/posthog-cli-preinstall'; -import { installOrUpdatePostHogCli } from '@steps/install-cli-steering'; -import { getUI } from '@ui'; -import { analytics } from '@utils/analytics'; +} from '../shared/posthog-cli-preinstall.js'; +import { installOrUpdatePostHogCli } from '../../services/steps/install-cli-steering/index.js'; +import { getUI } from '../../ui/index.js'; +import { analytics } from '../../shared/analytics.js'; -vi.mock('@steps/install-cli-steering', () => ({ +vi.mock('../../services/steps/install-cli-steering/index.js', () => ({ installOrUpdatePostHogCli: vi.fn(), })); -vi.mock('@utils/analytics', () => ({ +vi.mock('../../shared/analytics.js', () => ({ analytics: { wizardCapture: vi.fn(), captureException: vi.fn() }, })); -vi.mock('@ui', () => ({ getUI: vi.fn() })); +vi.mock('../../ui/index.js', () => ({ getUI: vi.fn() })); const warn = vi.fn(); diff --git a/src/lib/programs/__tests__/posthog-integration-detect.test.ts b/src/store/programs/__tests__/posthog-integration-detect.test.ts similarity index 96% rename from src/lib/programs/__tests__/posthog-integration-detect.test.ts rename to src/store/programs/__tests__/posthog-integration-detect.test.ts index 7249ee81e..5363c039e 100644 --- a/src/lib/programs/__tests__/posthog-integration-detect.test.ts +++ b/src/store/programs/__tests__/posthog-integration-detect.test.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as path from 'path'; import * as os from 'os'; -import { detectExistingPostHog } from '@lib/programs/posthog-integration/detect'; +import { detectExistingPostHog } from '../posthog-integration/detect.js'; function makeTmpDir(): string { return fs.mkdtempSync(path.join(os.tmpdir(), 'ph-detect-')); diff --git a/src/lib/programs/__tests__/program-registry.test.ts b/src/store/programs/__tests__/program-registry.test.ts similarity index 97% rename from src/lib/programs/__tests__/program-registry.test.ts rename to src/store/programs/__tests__/program-registry.test.ts index 90f3e472d..fd2a89ff0 100644 --- a/src/lib/programs/__tests__/program-registry.test.ts +++ b/src/store/programs/__tests__/program-registry.test.ts @@ -5,8 +5,8 @@ import { getLaunchablePrograms, getProgramConfig, getSubcommandPrograms, -} from '@lib/programs/program-registry'; -import type { WizardSession } from '@lib/wizard-session'; +} from '../program-registry.js'; +import type { WizardSession } from '../../session/wizard-session.js'; describe('PROGRAM_REGISTRY', () => { it('every entry has unique id, description, and non-empty steps', () => { diff --git a/src/lib/programs/__tests__/program-step.test.ts b/src/store/programs/__tests__/program-step.test.ts similarity index 92% rename from src/lib/programs/__tests__/program-step.test.ts rename to src/store/programs/__tests__/program-step.test.ts index c19bf1f14..58b81646e 100644 --- a/src/lib/programs/__tests__/program-step.test.ts +++ b/src/store/programs/__tests__/program-step.test.ts @@ -1,6 +1,6 @@ -import type { ProgramStep } from '@lib/programs/program-step'; -import type { Flow } from '@lib/flow'; -import { flowEntries } from '@lib/flow-resolution'; +import type { ProgramStep } from '../program-step.js'; +import type { Flow } from '../../state/flow.js'; +import { flowEntries } from '../../state/flow-resolution.js'; const flowOf = (steps: ProgramStep[]): Flow => ({ programId: 'posthog-integration', diff --git a/src/lib/programs/__tests__/replay-vision.test.ts b/src/store/programs/__tests__/replay-vision.test.ts similarity index 95% rename from src/lib/programs/__tests__/replay-vision.test.ts rename to src/store/programs/__tests__/replay-vision.test.ts index a9146d2af..0321bb234 100644 --- a/src/lib/programs/__tests__/replay-vision.test.ts +++ b/src/store/programs/__tests__/replay-vision.test.ts @@ -1,10 +1,10 @@ import { describe, expect, test } from 'vitest'; -import { Integration } from '@lib/constants'; +import { Integration } from '../../shared/constants.js'; import { replayVisionConfig, REPLAY_VISION_SUPPORTED, -} from '@lib/programs/replay-vision/index'; +} from '../replay-vision/index.js'; describe('replay-vision program', () => { test('runs the replay-vision agent flow', () => { diff --git a/src/lib/programs/__tests__/revenue-analytics-detect.test.ts b/src/store/programs/__tests__/revenue-analytics-detect.test.ts similarity index 95% rename from src/lib/programs/__tests__/revenue-analytics-detect.test.ts rename to src/store/programs/__tests__/revenue-analytics-detect.test.ts index 5907dc4fa..5011c1aa3 100644 --- a/src/lib/programs/__tests__/revenue-analytics-detect.test.ts +++ b/src/store/programs/__tests__/revenue-analytics-detect.test.ts @@ -1,8 +1,8 @@ import * as fs from 'fs'; import * as path from 'path'; import * as os from 'os'; -import { detectRevenuePrerequisites } from '@lib/programs/revenue-analytics/index'; -import { buildSession } from '@lib/wizard-session'; +import { detectRevenuePrerequisites } from '../revenue-analytics/index.js'; +import { buildSession } from '../../session/wizard-session.js'; function makeTmpDir(): string { return fs.mkdtempSync(path.join(os.tmpdir(), 'rev-detect-')); diff --git a/src/lib/programs/__tests__/self-driving-detect.test.ts b/src/store/programs/__tests__/self-driving-detect.test.ts similarity index 96% rename from src/lib/programs/__tests__/self-driving-detect.test.ts rename to src/store/programs/__tests__/self-driving-detect.test.ts index a5d7461fc..93f865434 100644 --- a/src/lib/programs/__tests__/self-driving-detect.test.ts +++ b/src/store/programs/__tests__/self-driving-detect.test.ts @@ -5,29 +5,29 @@ import { detectSelfDrivingPrerequisites, selfDrivingConfig, SELF_DRIVING_ABORT_CASES, -} from '@lib/programs/self-driving/index'; +} from '../self-driving/index.js'; import { detectPostHogPresent, POSTHOG_MANIFESTS, SELF_DRIVING_DETECTED_TOOLS_KEY, SELF_DRIVING_TOOL_KINDS, getSelfDrivingDetectedTools, -} from '@lib/programs/self-driving/detect'; -import { getDetectedWarehouseSources } from '@lib/programs/warehouse-source/detect'; -import { WizardStore } from '@ui/tui/store'; -import { PROGRAM_PRESENTATION } from '@ui/tui/programs/presentation'; -import { SOURCE_DETECTORS } from '@lib/warehouse-sources/registry'; -import type { DetectedSource } from '@lib/warehouse-sources/types'; -import { toIntegrationReport } from '@lib/programs/self-driving/detect-agentic'; +} from '../self-driving/detect.js'; +import { getDetectedWarehouseSources } from '../warehouse-source/detect.js'; +import { WizardStore } from '../../state/store.js'; +import { PROGRAM_PRESENTATION } from '@tui/programs/presentation'; +import { SOURCE_DETECTORS } from '../../services/warehouse-sources/registry.js'; +import type { DetectedSource } from '../../services/warehouse-sources/types.js'; +import { toIntegrationReport } from '../self-driving/detect-agentic.js'; import { PROJECT_MANIFESTS, type AgenticDetectionReport, -} from '@lib/detection/agentic'; -import { Integration } from '@lib/constants'; -import { WIZARD_TOOL_NAMES } from '@lib/wizard-tools'; -import { buildSession } from '@lib/wizard-session'; +} from '../../detection/agentic.js'; +import { Integration } from '../../shared/constants.js'; +import { WIZARD_TOOL_NAMES } from '../../tools/index.js'; +import { buildSession } from '../../session/wizard-session.js'; import type { Mock } from 'vitest'; -import { flowFor } from '@lib/programs/flow-for'; +import { flowFor } from '../flow-for.js'; function makeTmpDir(): string { return fs.mkdtempSync(path.join(os.tmpdir(), 'self-driving-detect-')); diff --git a/src/lib/programs/__tests__/self-driving-prompt.test.ts b/src/store/programs/__tests__/self-driving-prompt.test.ts similarity index 95% rename from src/lib/programs/__tests__/self-driving-prompt.test.ts rename to src/store/programs/__tests__/self-driving-prompt.test.ts index 36d850cb9..48332d3bc 100644 --- a/src/lib/programs/__tests__/self-driving-prompt.test.ts +++ b/src/store/programs/__tests__/self-driving-prompt.test.ts @@ -1,7 +1,7 @@ -import { buildSelfDrivingPrompt } from '@lib/programs/self-driving/prompt'; -import type { PromptContext } from '@lib/program-run'; -import { HostResolution } from '@lib/host-resolution'; -import type { DetectedSource } from '@lib/warehouse-sources/types'; +import { buildSelfDrivingPrompt } from '../self-driving/prompt.js'; +import type { PromptContext } from '../../agent-protocol/program-run.js'; +import { HostResolution } from '../../host-resolution.js'; +import type { DetectedSource } from '../../services/warehouse-sources/types.js'; const ctx: PromptContext = { projectId: 123, diff --git a/src/lib/programs/__tests__/source-maps-detect-agentic.test.ts b/src/store/programs/__tests__/source-maps-detect-agentic.test.ts similarity index 99% rename from src/lib/programs/__tests__/source-maps-detect-agentic.test.ts rename to src/store/programs/__tests__/source-maps-detect-agentic.test.ts index a64c6973f..0071fdac0 100644 --- a/src/lib/programs/__tests__/source-maps-detect-agentic.test.ts +++ b/src/store/programs/__tests__/source-maps-detect-agentic.test.ts @@ -6,8 +6,8 @@ import { goSdkVerifier, rustSdkVerifier, SOURCE_MAPS_TARGETS, -} from '@lib/programs/error-tracking-upload-source-maps/detect-agentic'; -import { AUTOMATABLE_VARIANTS } from '@lib/programs/error-tracking-upload-source-maps/detect'; +} from '../error-tracking-upload-source-maps/detect-agentic.js'; +import { AUTOMATABLE_VARIANTS } from '../error-tracking-upload-source-maps/detect.js'; describe('SOURCE_MAPS_TARGETS precedence', () => { const ids = SOURCE_MAPS_TARGETS.map((t) => t.id); diff --git a/src/lib/programs/__tests__/source-maps-detect.test.ts b/src/store/programs/__tests__/source-maps-detect.test.ts similarity index 98% rename from src/lib/programs/__tests__/source-maps-detect.test.ts rename to src/store/programs/__tests__/source-maps-detect.test.ts index 456933ad1..7d8a65097 100644 --- a/src/lib/programs/__tests__/source-maps-detect.test.ts +++ b/src/store/programs/__tests__/source-maps-detect.test.ts @@ -4,8 +4,8 @@ import * as os from 'os'; import { detectSourceMapsPrerequisites, SOURCE_MAPS_CONTEXT_KEYS, -} from '@lib/programs/error-tracking-upload-source-maps/index'; -import { buildSession } from '@lib/wizard-session'; +} from '../error-tracking-upload-source-maps/index.js'; +import { buildSession } from '../../session/wizard-session.js'; function makeTmpDir(): string { return fs.mkdtempSync(path.join(os.tmpdir(), 'source-maps-detect-')); diff --git a/src/lib/programs/__tests__/source-maps-prompt.test.ts b/src/store/programs/__tests__/source-maps-prompt.test.ts similarity index 97% rename from src/lib/programs/__tests__/source-maps-prompt.test.ts rename to src/store/programs/__tests__/source-maps-prompt.test.ts index 3945fdc50..3656902f9 100644 --- a/src/lib/programs/__tests__/source-maps-prompt.test.ts +++ b/src/store/programs/__tests__/source-maps-prompt.test.ts @@ -1,4 +1,4 @@ -import { buildSourceMapsUploadPrompt } from '@lib/programs/error-tracking-upload-source-maps/prompt'; +import { buildSourceMapsUploadPrompt } from '../error-tracking-upload-source-maps/prompt.js'; const baseParams = { displayName: 'Node.js', diff --git a/src/lib/programs/__tests__/warehouse-ask-timeout.test.ts b/src/store/programs/__tests__/warehouse-ask-timeout.test.ts similarity index 83% rename from src/lib/programs/__tests__/warehouse-ask-timeout.test.ts rename to src/store/programs/__tests__/warehouse-ask-timeout.test.ts index c74c5f766..2d6e25490 100644 --- a/src/lib/programs/__tests__/warehouse-ask-timeout.test.ts +++ b/src/store/programs/__tests__/warehouse-ask-timeout.test.ts @@ -7,9 +7,9 @@ * The command was on the 5-minute default, so the fallback route gave the * user a quarter of the time the in-run prompt does for identical questions. */ -import type { WizardSession } from '@lib/wizard-session'; +import type { WizardSession } from '../../session/wizard-session.js'; -vi.mock('@utils/analytics', () => ({ +vi.mock('../../shared/analytics.js', () => ({ analytics: { wizardCapture: vi.fn(), setTag: vi.fn(), @@ -18,11 +18,11 @@ vi.mock('@utils/analytics', () => ({ }, })); -import { warehouseSourceConfig } from '@lib/programs/warehouse-source/index'; +import { warehouseSourceConfig } from '../warehouse-source/index.js'; import { LONGER_ASK_TIMEOUT_MS, DEFAULT_ASK_TIMEOUT_MS, -} from '@lib/wizard-ask-bridge'; +} from '../../session/wizard-ask-bridge.js'; function session(): WizardSession { return { installDir: '/tmp/app', frameworkContext: {} } as WizardSession; diff --git a/src/lib/programs/__tests__/warehouse-seed-task.test.ts b/src/store/programs/__tests__/warehouse-seed-task.test.ts similarity index 92% rename from src/lib/programs/__tests__/warehouse-seed-task.test.ts rename to src/store/programs/__tests__/warehouse-seed-task.test.ts index 0a6458392..9a45d9870 100644 --- a/src/lib/programs/__tests__/warehouse-seed-task.test.ts +++ b/src/store/programs/__tests__/warehouse-seed-task.test.ts @@ -3,10 +3,10 @@ * so it belongs only in a run that has both something to connect and someone * to answer — and the wizard, not the planner, is what decides that. */ -import type { WizardSession } from '@lib/wizard-session'; -import type { DetectedSource } from '@lib/warehouse-sources/types'; +import type { WizardSession } from '../../session/wizard-session.js'; +import type { DetectedSource } from '../../services/warehouse-sources/types.js'; -vi.mock('@utils/analytics', () => ({ +vi.mock('../../shared/analytics.js', () => ({ analytics: { wizardCapture: vi.fn(), setTag: vi.fn(), @@ -15,8 +15,8 @@ vi.mock('@utils/analytics', () => ({ }, })); -import { posthogIntegrationConfig } from '@lib/programs/posthog-integration/index'; -import { DETECTED_WAREHOUSE_SOURCES_KEY } from '@lib/programs/warehouse-source/detect'; +import { posthogIntegrationConfig } from '../posthog-integration/index.js'; +import { DETECTED_WAREHOUSE_SOURCES_KEY } from '../warehouse-source/detect.js'; const POSTGRES: DetectedSource = { kind: 'Postgres', diff --git a/src/lib/programs/__tests__/warehouse-suggestion.test.ts b/src/store/programs/__tests__/warehouse-suggestion.test.ts similarity index 95% rename from src/lib/programs/__tests__/warehouse-suggestion.test.ts rename to src/store/programs/__tests__/warehouse-suggestion.test.ts index 0f6023f28..909307404 100644 --- a/src/lib/programs/__tests__/warehouse-suggestion.test.ts +++ b/src/store/programs/__tests__/warehouse-suggestion.test.ts @@ -13,11 +13,14 @@ * say the run already connected the sources. */ -import { posthogIntegrationConfig } from '@lib/programs/posthog-integration/index'; -import { POSTHOG_INTEGRATION_PROGRAM } from '@lib/programs/posthog-integration/steps'; -import { DETECTED_WAREHOUSE_SOURCES_KEY } from '@lib/programs/warehouse-source/detect'; -import { buildSession, type WizardSession } from '@lib/wizard-session'; -import type { DetectedSource } from '@lib/warehouse-sources/types'; +import { posthogIntegrationConfig } from '../posthog-integration/index.js'; +import { POSTHOG_INTEGRATION_PROGRAM } from '../posthog-integration/steps.js'; +import { DETECTED_WAREHOUSE_SOURCES_KEY } from '../warehouse-source/detect.js'; +import { + buildSession, + type WizardSession, +} from '../../session/wizard-session.js'; +import type { DetectedSource } from '../../services/warehouse-sources/types.js'; const POSTGRES: DetectedSource = { kind: 'postgres', diff --git a/src/lib/programs/__tests__/web-analytics-doctor-detect.test.ts b/src/store/programs/__tests__/web-analytics-doctor-detect.test.ts similarity index 95% rename from src/lib/programs/__tests__/web-analytics-doctor-detect.test.ts rename to src/store/programs/__tests__/web-analytics-doctor-detect.test.ts index 2d689c11c..82fcdae53 100644 --- a/src/lib/programs/__tests__/web-analytics-doctor-detect.test.ts +++ b/src/store/programs/__tests__/web-analytics-doctor-detect.test.ts @@ -5,9 +5,9 @@ import { detectWebAnalyticsPrerequisites, webAnalyticsDoctorConfig, WEB_ANALYTICS_ABORT_CASES, -} from '@lib/programs/web-analytics-doctor/index'; -import { WIZARD_TOOL_NAMES } from '@lib/wizard-tools'; -import { buildSession } from '@lib/wizard-session'; +} from '../web-analytics-doctor/index.js'; +import { WIZARD_TOOL_NAMES } from '../../tools/index.js'; +import { buildSession } from '../../session/wizard-session.js'; function makeTmpDir(): string { return fs.mkdtempSync(path.join(os.tmpdir(), 'wa-detect-')); diff --git a/src/lib/programs/agent-skill/index.ts b/src/store/programs/agent-skill/index.ts similarity index 94% rename from src/lib/programs/agent-skill/index.ts rename to src/store/programs/agent-skill/index.ts index fd3da7f80..c5f916873 100644 --- a/src/lib/programs/agent-skill/index.ts +++ b/src/store/programs/agent-skill/index.ts @@ -19,8 +19,11 @@ * }) */ -import type { ProgramConfig } from '@lib/programs/program-step'; -import type { ProgramRun, AbortCase } from '@lib/program-run'; +import type { ProgramConfig } from '../program-step.js'; +import type { + ProgramRun, + AbortCase, +} from '../../agent-protocol/program-run.js'; import { AGENT_SKILL_STEPS } from './steps.js'; export interface SkillProgramOptions { diff --git a/src/lib/programs/agent-skill/steps.ts b/src/store/programs/agent-skill/steps.ts similarity index 82% rename from src/lib/programs/agent-skill/steps.ts rename to src/store/programs/agent-skill/steps.ts index 992726616..ddcc823e3 100644 --- a/src/lib/programs/agent-skill/steps.ts +++ b/src/store/programs/agent-skill/steps.ts @@ -5,9 +5,9 @@ * No detection, no setup, no MCP. */ -import type { ProgramStep } from '@lib/programs/program-step'; -import { RunPhase } from '@lib/wizard-session'; -import { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step'; +import type { ProgramStep } from '../program-step.js'; +import { RunPhase } from '../../session/wizard-session.js'; +import { HEALTH_CHECK_STEP } from '../shared/health-check-step.js'; export const AGENT_SKILL_STEPS: ProgramStep[] = [ { diff --git a/src/lib/programs/ai-observability/index.ts b/src/store/programs/ai-observability/index.ts similarity index 95% rename from src/lib/programs/ai-observability/index.ts rename to src/store/programs/ai-observability/index.ts index c9319e69f..81ff0c015 100644 --- a/src/lib/programs/ai-observability/index.ts +++ b/src/store/programs/ai-observability/index.ts @@ -1,5 +1,5 @@ -import type { ProgramConfig, ProgramStep } from '@lib/programs/program-step'; -import { AGENT_SKILL_STEPS } from '@lib/programs/agent-skill/index'; +import type { ProgramConfig, ProgramStep } from '../program-step.js'; +import { AGENT_SKILL_STEPS } from '../agent-skill/index.js'; const AI_OBSERVABILITY_STEPS: ProgramStep[] = AGENT_SKILL_STEPS.map((step) => step.id === 'intro' ? { ...step, screenId: 'ai-observability-intro' } : step, diff --git a/src/lib/programs/ai-observability/test/e2e.json b/src/store/programs/ai-observability/test/e2e.json similarity index 100% rename from src/lib/programs/ai-observability/test/e2e.json rename to src/store/programs/ai-observability/test/e2e.json diff --git a/src/lib/programs/ai-opt-in-gate.ts b/src/store/programs/ai-opt-in-gate.ts similarity index 97% rename from src/lib/programs/ai-opt-in-gate.ts rename to src/store/programs/ai-opt-in-gate.ts index d101a02a3..eaf134a54 100644 --- a/src/lib/programs/ai-opt-in-gate.ts +++ b/src/store/programs/ai-opt-in-gate.ts @@ -31,7 +31,7 @@ * already treats `ci || signup` as one non-interactive mode. */ -import type { WizardSession } from '@lib/wizard-session'; +import type { WizardSession } from '../session/wizard-session.js'; import type { ProgramConfig, ProgramStep } from './program-step.js'; /** Step id — also the ScreenId.AiOptIn enum value in screen-sequences. */ diff --git a/src/lib/programs/audit/detect.ts b/src/store/programs/audit/detect.ts similarity index 82% rename from src/lib/programs/audit/detect.ts rename to src/store/programs/audit/detect.ts index 4312f79f1..e3705b57c 100644 --- a/src/lib/programs/audit/detect.ts +++ b/src/store/programs/audit/detect.ts @@ -1,5 +1,5 @@ -import type { AbortCase } from '@lib/program-run'; -import { ErrorCodes } from '@lib/errors'; +import type { AbortCase } from '../../agent-protocol/program-run.js'; +import { ErrorCodes } from '../../shared/errors/index.js'; /** `[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/store/programs/audit/index.ts similarity index 88% rename from src/lib/programs/audit/index.ts rename to src/store/programs/audit/index.ts index e0847a05d..8cd6fcfa7 100644 --- a/src/lib/programs/audit/index.ts +++ b/src/store/programs/audit/index.ts @@ -1,13 +1,10 @@ -import { - AGENT_SKILL_STEPS, - createSkillProgram, -} from '@lib/programs/agent-skill/index'; -import type { ProgramStep, ProgramConfig } from '@lib/programs/program-step'; -import type { ProgramRun } from '@lib/program-run'; -import type { WizardSession } from '@lib/wizard-session'; -import { OutroKind } from '@lib/wizard-session'; -import { WIZARD_TOOL_NAMES } from '@lib/wizard-tools'; -import { headlessOption, regionOption } from '@lib/headless-mode'; +import { AGENT_SKILL_STEPS, createSkillProgram } from '../agent-skill/index.js'; +import type { ProgramStep, ProgramConfig } from '../program-step.js'; +import type { ProgramRun } from '../../agent-protocol/program-run.js'; +import type { WizardSession } from '../../session/wizard-session.js'; +import { OutroKind } from '../../session/wizard-session.js'; +import { WIZARD_TOOL_NAMES } from '../../tools/index.js'; +import { headlessOption, regionOption } from '@cli/headless-mode'; import { AUDIT_ABORT_CASES } from './detect.js'; import { AUDIT_CHECKS_FILE, diff --git a/src/lib/programs/audit/ledger-watcher.ts b/src/store/programs/audit/ledger-watcher.ts similarity index 89% rename from src/lib/programs/audit/ledger-watcher.ts rename to src/store/programs/audit/ledger-watcher.ts index f7a312543..fd635a1ae 100644 --- a/src/lib/programs/audit/ledger-watcher.ts +++ b/src/store/programs/audit/ledger-watcher.ts @@ -5,13 +5,13 @@ */ import path from 'path'; -import { getUI } from '@ui'; +import { getUI } from '../../ui/index.js'; import { startFileWatcher, type FileWatcherHandle, type FileWatcherOptions, -} from '@lib/file-watcher'; -import { logToFile } from '@utils/debug'; +} from '../../file-watcher.js'; +import { logToFile } from '../../shared/debug.js'; import { AUDIT_CHECKS_KEY, coerceAuditChecks } from './types.js'; const MAX_LEDGER_FILE_BYTES = 256 * 1024; diff --git a/src/lib/programs/audit/seed.ts b/src/store/programs/audit/seed.ts similarity index 96% rename from src/lib/programs/audit/seed.ts rename to src/store/programs/audit/seed.ts index 47a673c11..626043b81 100644 --- a/src/lib/programs/audit/seed.ts +++ b/src/store/programs/audit/seed.ts @@ -1,6 +1,6 @@ import path from 'path'; -import { writeJsonAtomic } from '@utils/atomic-ledger'; -import { logToFile } from '@utils/debug'; +import { writeJsonAtomic } from '../../shared/atomic-ledger.js'; +import { logToFile } from '../../shared/debug.js'; import { AUDIT_CHECKS_FILE, type AuditCheck } from './types.js'; /** diff --git a/src/lib/programs/audit/test/e2e.json b/src/store/programs/audit/test/e2e.json similarity index 100% rename from src/lib/programs/audit/test/e2e.json rename to src/store/programs/audit/test/e2e.json diff --git a/src/lib/programs/audit/types.ts b/src/store/programs/audit/types.ts similarity index 95% rename from src/lib/programs/audit/types.ts rename to src/store/programs/audit/types.ts index dd858a709..48242e3c9 100644 --- a/src/lib/programs/audit/types.ts +++ b/src/store/programs/audit/types.ts @@ -1,4 +1,4 @@ -import type { WizardSession } from '@lib/wizard-session'; +import type { WizardSession } from '../../session/wizard-session.js'; export type AuditStatus = | 'pending' diff --git a/src/lib/programs/dispatch-family.ts b/src/store/programs/dispatch-family.ts similarity index 89% rename from src/lib/programs/dispatch-family.ts rename to src/store/programs/dispatch-family.ts index a730d8198..388102801 100644 --- a/src/lib/programs/dispatch-family.ts +++ b/src/store/programs/dispatch-family.ts @@ -1,19 +1,19 @@ 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 { 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 { analytics } from '@utils/analytics'; +import { auditConfig } from './audit/index.js'; +import { AUDIT_CHECKS_FILE } from './audit/types.js'; +import { WIZARD_TOOL_NAMES } from '../tools/index.js'; +import { agentSkillConfig } from './program-registry.js'; +import { webAnalyticsDoctorConfig } from './web-analytics-doctor/index.js'; +import type { ProgramConfig } from './program-step.js'; +import { getSkillsBaseUrl } from '../shared/constants.js'; +import { fetchSkillMenu, type CliEntry } from '../tools/index.js'; +import { analytics } from '../shared/analytics.js'; -import { dispatchProgram } from '../../commands/factories/shared'; -import type { Command } from '../../commands/command'; -import { ErrorCodes } from '@lib/errors'; -import { emitWizardError } from '@lib/errors'; +import { dispatchProgram } from '@cli/commands/factories/shared'; +import type { Command } from '@cli/commands/command'; +import { ErrorCodes } from '../shared/errors/index.js'; +import { emitWizardError } from '../shared/errors/index.js'; /** * Capture a CLI dispatch error, flush analytics, and exit. The wizard never diff --git a/src/lib/programs/error-tracking-upload-source-maps/detect-agentic.ts b/src/store/programs/error-tracking-upload-source-maps/detect-agentic.ts similarity index 98% rename from src/lib/programs/error-tracking-upload-source-maps/detect-agentic.ts rename to src/store/programs/error-tracking-upload-source-maps/detect-agentic.ts index 17d3561c0..ca8f07129 100644 --- a/src/lib/programs/error-tracking-upload-source-maps/detect-agentic.ts +++ b/src/store/programs/error-tracking-upload-source-maps/detect-agentic.ts @@ -9,15 +9,15 @@ import { existsSync, readFileSync, readdirSync } from 'fs'; import { join } from 'path'; -import { IGNORED_DIRS, readProjectFile } from '@utils/bounded-fs'; +import { IGNORED_DIRS, readProjectFile } from '../../shared/bounded-fs.js'; import { detectProjectsWithAgent, coerceAgenticReport, type DetectTarget, type AgenticDetectionReport, type DetectEvent, -} from '@lib/detection/agentic'; -import type { WizardSession } from '@lib/wizard-session'; +} from '../../detection/agentic.js'; +import type { WizardSession } from '../../session/wizard-session.js'; import { VARIANT_DISPLAY_NAME, AUTOMATABLE_VARIANTS, diff --git a/src/lib/programs/error-tracking-upload-source-maps/detect.ts b/src/store/programs/error-tracking-upload-source-maps/detect.ts similarity index 98% rename from src/lib/programs/error-tracking-upload-source-maps/detect.ts rename to src/store/programs/error-tracking-upload-source-maps/detect.ts index 5fa9e7ddd..3befb6bcb 100644 --- a/src/lib/programs/error-tracking-upload-source-maps/detect.ts +++ b/src/store/programs/error-tracking-upload-source-maps/detect.ts @@ -15,10 +15,10 @@ import { MAX_DIR_ENTRIES, MAX_WALK_FILES, safeReadFile, -} from '@utils/bounded-fs'; -import type { WizardSession } from '@lib/wizard-session'; -import type { AbortCase } from '@lib/program-run'; -import { ErrorCodes } from '@lib/errors'; +} from '../../shared/bounded-fs.js'; +import type { WizardSession } from '../../session/wizard-session.js'; +import type { AbortCase } from '../../agent-protocol/program-run.js'; +import { ErrorCodes } from '../../shared/errors/index.js'; /** * Skill variants published under the `error-tracking-upload-source-maps` diff --git a/src/lib/programs/error-tracking-upload-source-maps/index.ts b/src/store/programs/error-tracking-upload-source-maps/index.ts similarity index 92% rename from src/lib/programs/error-tracking-upload-source-maps/index.ts rename to src/store/programs/error-tracking-upload-source-maps/index.ts index fe2df3850..6b1b72e41 100644 --- a/src/lib/programs/error-tracking-upload-source-maps/index.ts +++ b/src/store/programs/error-tracking-upload-source-maps/index.ts @@ -1,7 +1,7 @@ -import type { ProgramConfig } from '@lib/programs/program-step'; -import type { ProgramRun } from '@lib/program-run'; -import type { WizardSession } from '@lib/wizard-session'; -import { OutroKind } from '@lib/wizard-session'; +import type { ProgramConfig } from '../program-step.js'; +import type { ProgramRun } from '../../agent-protocol/program-run.js'; +import type { WizardSession } from '../../session/wizard-session.js'; +import { OutroKind } from '../../session/wizard-session.js'; import { ERROR_TRACKING_UPLOAD_SOURCE_MAPS_PROGRAM } from './steps.js'; import { buildSourceMapsUploadPrompt, @@ -13,8 +13,8 @@ import { VARIANTS_REQUIRING_POSTHOG_CLI, type SkillVariant, } from './detect.js'; -import { getUI } from '@ui'; -import { preinstallPostHogCliOnce } from '@lib/programs/shared/posthog-cli-preinstall'; +import { getUI } from '../../ui/index.js'; +import { preinstallPostHogCliOnce } from '../shared/posthog-cli-preinstall.js'; const REPORT_FILE = 'posthog-source-maps-report.md'; const DOCS_URL = 'https://posthog.com/docs/error-tracking/upload-source-maps'; diff --git a/src/lib/programs/error-tracking-upload-source-maps/prompt.ts b/src/store/programs/error-tracking-upload-source-maps/prompt.ts similarity index 99% rename from src/lib/programs/error-tracking-upload-source-maps/prompt.ts rename to src/store/programs/error-tracking-upload-source-maps/prompt.ts index ed31336c6..5bbe087a3 100644 --- a/src/lib/programs/error-tracking-upload-source-maps/prompt.ts +++ b/src/store/programs/error-tracking-upload-source-maps/prompt.ts @@ -1,4 +1,4 @@ -import { AgentSignals } from '@lib/agent-signals'; +import { AgentSignals } from '../../agent-protocol/agent-signals.js'; import type { SkillVariant } from './detect.js'; export type SourceMapsUploadPromptParams = { diff --git a/src/lib/programs/error-tracking-upload-source-maps/steps.ts b/src/store/programs/error-tracking-upload-source-maps/steps.ts similarity index 90% rename from src/lib/programs/error-tracking-upload-source-maps/steps.ts rename to src/store/programs/error-tracking-upload-source-maps/steps.ts index 33bfc7449..9c106e495 100644 --- a/src/lib/programs/error-tracking-upload-source-maps/steps.ts +++ b/src/store/programs/error-tracking-upload-source-maps/steps.ts @@ -7,9 +7,9 @@ * needs credentials. */ -import type { ProgramStep } from '@lib/programs/program-step'; -import type { WizardSession } from '@lib/wizard-session'; -import { RunPhase } from '@lib/wizard-session'; +import type { ProgramStep } from '../program-step.js'; +import type { WizardSession } from '../../session/wizard-session.js'; +import { RunPhase } from '../../session/wizard-session.js'; import { SOURCE_MAPS_CONTEXT_KEYS } from './detect.js'; function projectSelected(session: WizardSession): boolean { diff --git a/src/lib/programs/error-tracking-upload-source-maps/test/e2e.json b/src/store/programs/error-tracking-upload-source-maps/test/e2e.json similarity index 100% rename from src/lib/programs/error-tracking-upload-source-maps/test/e2e.json rename to src/store/programs/error-tracking-upload-source-maps/test/e2e.json diff --git a/src/lib/programs/error-tracking/detect-agentic.ts b/src/store/programs/error-tracking/detect-agentic.ts similarity index 92% rename from src/lib/programs/error-tracking/detect-agentic.ts rename to src/store/programs/error-tracking/detect-agentic.ts index 5f7fd5268..4c143a674 100644 --- a/src/lib/programs/error-tracking/detect-agentic.ts +++ b/src/store/programs/error-tracking/detect-agentic.ts @@ -11,18 +11,18 @@ * - The scan bills to error-tracking. */ -import { Integration } from '@lib/constants'; +import { Integration } from '../../shared/constants.js'; import { resolveProjectDir, type AgenticDetectionReport, type DetectEvent, -} from '@lib/detection/agentic'; -import { gatherFrameworkContext } from '@lib/detection/index'; +} from '../../detection/agentic.js'; +import { gatherFrameworkContext } from '../../detection/index.js'; import { detectIntegrationProjects, toIntegrationCandidates, -} from '@lib/detection/project-scope'; -import type { WizardSession } from '@lib/wizard-session'; +} from '../../detection/project-scope.js'; +import type { WizardSession } from '../../session/wizard-session.js'; /** frameworkContext key for the picked project's path, relative to the repo root. */ export const ERROR_TRACKING_PROJECT_PATH_KEY = 'errorTrackingProjectPath'; diff --git a/src/lib/programs/error-tracking/index.ts b/src/store/programs/error-tracking/index.ts similarity index 90% rename from src/lib/programs/error-tracking/index.ts rename to src/store/programs/error-tracking/index.ts index e52d37bf4..8aa47422a 100644 --- a/src/lib/programs/error-tracking/index.ts +++ b/src/store/programs/error-tracking/index.ts @@ -1,20 +1,20 @@ -import { Integration } from '@lib/constants'; -import { detectFramework } from '@lib/detection/index'; -import { scopeInstallDirToProject } from '@lib/detection/project-scope'; -import { FRAMEWORK_REGISTRY } from '@lib/registry'; -import type { ProgramRun } from '@lib/program-run'; -import { AGENT_SKILL_STEPS } from '@lib/programs/agent-skill/steps'; +import { Integration } from '../../shared/constants.js'; +import { detectFramework } from '../../detection/index.js'; +import { scopeInstallDirToProject } from '../../detection/project-scope.js'; +import { FRAMEWORK_REGISTRY } from '../../registry.js'; +import type { ProgramRun } from '../../agent-protocol/program-run.js'; +import { AGENT_SKILL_STEPS } from '../agent-skill/steps.js'; import { ERROR_TRACKING_UNSUPPORTED, errorTrackingProjectDir, gatherErrorTrackingContext, -} from '@lib/programs/error-tracking/detect-agentic'; -import type { ProgramConfig, ProgramStep } from '@lib/programs/program-step'; -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'; +} from './detect-agentic.js'; +import type { ProgramConfig, ProgramStep } from '../program-step.js'; +import type { WizardSession } from '../../session/wizard-session.js'; +import { preinstallPostHogCliOnce } from '../shared/posthog-cli-preinstall.js'; +import { analytics } from '../../shared/analytics.js'; +import { wizardAbort } from '../../shared/wizard-abort.js'; +import { ErrorCodes } from '../../shared/errors/index.js'; 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/error-tracking/test/e2e.json b/src/store/programs/error-tracking/test/e2e.json similarity index 100% rename from src/lib/programs/error-tracking/test/e2e.json rename to src/store/programs/error-tracking/test/e2e.json diff --git a/src/lib/programs/events-audit/constants.ts b/src/store/programs/events-audit/constants.ts similarity index 100% rename from src/lib/programs/events-audit/constants.ts rename to src/store/programs/events-audit/constants.ts diff --git a/src/lib/programs/events-audit/index.ts b/src/store/programs/events-audit/index.ts similarity index 87% rename from src/lib/programs/events-audit/index.ts rename to src/store/programs/events-audit/index.ts index ae5d1dd9f..96707a062 100644 --- a/src/lib/programs/events-audit/index.ts +++ b/src/store/programs/events-audit/index.ts @@ -1,13 +1,13 @@ -import type { ProgramConfig } from '@lib/programs/program-step'; -import type { ProgramRun } from '@lib/program-run'; -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 type { ProgramConfig } from '../program-step.js'; +import type { ProgramRun } from '../../agent-protocol/program-run.js'; +import type { WizardSession } from '../../session/wizard-session.js'; +import { OutroKind } from '../../session/wizard-session.js'; +import { SPINNER_MESSAGE } from '../../framework-config.js'; +import { isUsingTypeScript } from '../../shared/setup-utils.js'; +import { WIZARD_TOOL_NAMES } from '../../tools/index.js'; 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'; +import { AUDIT_CHECKS_FILE, AUDIT_CHECKS_KEY } from '../audit/types.js'; +import { seedAuditLedger } from '../audit/seed.js'; import { EVENTS_AUDIT_SEED_CHECKS } from './seed.js'; // SETUP_REPORT_FILE is also re-exported for backward compat with existing diff --git a/src/lib/programs/events-audit/seed.ts b/src/store/programs/events-audit/seed.ts similarity index 96% rename from src/lib/programs/events-audit/seed.ts rename to src/store/programs/events-audit/seed.ts index f2c0df189..3bc4d178c 100644 --- a/src/lib/programs/events-audit/seed.ts +++ b/src/store/programs/events-audit/seed.ts @@ -1,4 +1,4 @@ -import type { AuditCheck } from '@lib/programs/audit/types'; +import type { AuditCheck } from '../audit/types.js'; /** * The 7 phases the events-audit skill marches through. One check per area diff --git a/src/lib/programs/events-audit/steps.ts b/src/store/programs/events-audit/steps.ts similarity index 86% rename from src/lib/programs/events-audit/steps.ts rename to src/store/programs/events-audit/steps.ts index b9e07298a..94dab6c22 100644 --- a/src/lib/programs/events-audit/steps.ts +++ b/src/store/programs/events-audit/steps.ts @@ -8,10 +8,10 @@ * logic) instead of the integration intro. */ -import type { ProgramStep } from '@lib/programs/program-step'; -import type { WizardSession } from '@lib/wizard-session'; -import { RunPhase } from '@lib/wizard-session'; -import { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step'; +import type { ProgramStep } from '../program-step.js'; +import type { WizardSession } from '../../session/wizard-session.js'; +import { RunPhase } from '../../session/wizard-session.js'; +import { HEALTH_CHECK_STEP } from '../shared/health-check-step.js'; function needsSetup(session: WizardSession): boolean { const config = session.frameworkConfig; diff --git a/src/lib/programs/flow-for.ts b/src/store/programs/flow-for.ts similarity index 92% rename from src/lib/programs/flow-for.ts rename to src/store/programs/flow-for.ts index 705297194..0d20bce84 100644 --- a/src/lib/programs/flow-for.ts +++ b/src/store/programs/flow-for.ts @@ -1,4 +1,4 @@ -import type { Flow } from '@lib/flow'; +import type { Flow } from '../state/flow.js'; import { getProgramConfig, type ProgramId } from './program-registry.js'; import type { ProgramConfig } from './program-step.js'; import { withAiOptInGate } from './ai-opt-in-gate.js'; diff --git a/src/lib/programs/mcp-analytics/index.ts b/src/store/programs/mcp-analytics/index.ts similarity index 94% rename from src/lib/programs/mcp-analytics/index.ts rename to src/store/programs/mcp-analytics/index.ts index c4f16857e..2e1f1b276 100644 --- a/src/lib/programs/mcp-analytics/index.ts +++ b/src/store/programs/mcp-analytics/index.ts @@ -1,6 +1,6 @@ -import type { AbortCase } from '@lib/program-run'; -import { ErrorCodes } from '@lib/errors'; -import { createSkillProgram } from '@lib/programs/agent-skill/index'; +import type { AbortCase } from '../../agent-protocol/program-run.js'; +import { ErrorCodes } from '../../shared/errors/index.js'; +import { createSkillProgram } from '../agent-skill/index.js'; const MCP_ANALYTICS_REPORT_FILE = 'posthog-mcp-analytics-report.md'; diff --git a/src/lib/programs/mcp/index.ts b/src/store/programs/mcp/index.ts similarity index 97% rename from src/lib/programs/mcp/index.ts rename to src/store/programs/mcp/index.ts index 819e19e8e..39f15b8b0 100644 --- a/src/lib/programs/mcp/index.ts +++ b/src/store/programs/mcp/index.ts @@ -8,8 +8,8 @@ * screen-sequences.ts). */ -import type { ProgramConfig } from '@lib/programs/program-step'; -import { McpOutcome } from '@lib/wizard-session'; +import type { ProgramConfig } from '../program-step.js'; +import { McpOutcome } from '../../session/wizard-session.js'; export const mcpAddConfig: ProgramConfig = { id: 'mcp-add', diff --git a/src/lib/programs/metrics/index.ts b/src/store/programs/metrics/index.ts similarity index 95% rename from src/lib/programs/metrics/index.ts rename to src/store/programs/metrics/index.ts index 4430a72c0..50aa62905 100644 --- a/src/lib/programs/metrics/index.ts +++ b/src/store/programs/metrics/index.ts @@ -1,5 +1,5 @@ -import type { ProgramConfig, ProgramStep } from '@lib/programs/program-step'; -import { AGENT_SKILL_STEPS } from '@lib/programs/agent-skill/index'; +import type { ProgramConfig, ProgramStep } from '../program-step.js'; +import { AGENT_SKILL_STEPS } from '../agent-skill/index.js'; const METRICS_STEPS: ProgramStep[] = AGENT_SKILL_STEPS.map((step) => step.id === 'intro' ? { ...step, screenId: 'metrics-intro' } : step, diff --git a/src/lib/programs/metrics/test/e2e.json b/src/store/programs/metrics/test/e2e.json similarity index 100% rename from src/lib/programs/metrics/test/e2e.json rename to src/store/programs/metrics/test/e2e.json diff --git a/src/lib/programs/migration/index.ts b/src/store/programs/migration/index.ts similarity index 92% rename from src/lib/programs/migration/index.ts rename to src/store/programs/migration/index.ts index 1c3605fbf..9e96a1f65 100644 --- a/src/lib/programs/migration/index.ts +++ b/src/store/programs/migration/index.ts @@ -1,6 +1,6 @@ -import type { ProgramConfig } from '@lib/programs/program-step'; -import type { AbortCase } from '@lib/program-run'; -import { WIZARD_TOOL_NAMES } from '@lib/wizard-tools'; +import type { ProgramConfig } from '../program-step.js'; +import type { AbortCase } from '../../agent-protocol/program-run.js'; +import { WIZARD_TOOL_NAMES } from '../../tools/index.js'; import { MIGRATION_PROGRAM } from './steps.js'; const MIGRATION_REPORT_FILE = 'migration-report.md'; diff --git a/src/lib/programs/migration/steps.ts b/src/store/programs/migration/steps.ts similarity index 79% rename from src/lib/programs/migration/steps.ts rename to src/store/programs/migration/steps.ts index 33635d863..6b670f5f0 100644 --- a/src/lib/programs/migration/steps.ts +++ b/src/store/programs/migration/steps.ts @@ -1,6 +1,6 @@ -import type { ProgramStep } from '@lib/programs/program-step'; -import { RunPhase } from '@lib/wizard-session'; -import { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step'; +import type { ProgramStep } from '../program-step.js'; +import { RunPhase } from '../../session/wizard-session.js'; +import { HEALTH_CHECK_STEP } from '../shared/health-check-step.js'; export const MIGRATION_PROGRAM: ProgramStep[] = [ { diff --git a/src/lib/programs/posthog-doctor/__tests__/doctor-schema.test.ts b/src/store/programs/posthog-doctor/__tests__/doctor-schema.test.ts similarity index 92% rename from src/lib/programs/posthog-doctor/__tests__/doctor-schema.test.ts rename to src/store/programs/posthog-doctor/__tests__/doctor-schema.test.ts index cc23b479f..fa079ffb5 100644 --- a/src/lib/programs/posthog-doctor/__tests__/doctor-schema.test.ts +++ b/src/store/programs/posthog-doctor/__tests__/doctor-schema.test.ts @@ -1,12 +1,9 @@ -import { - HealthIssueListResponseSchema, - HealthIssueSchema, -} from '@lib/programs/posthog-doctor/types'; +import { HealthIssueListResponseSchema, HealthIssueSchema } from '../types.js'; import { getKindMeta, KIND_METADATA, UNKNOWN_KIND_META, -} from '@lib/programs/posthog-doctor/kind-metadata'; +} from '../kind-metadata.js'; describe('posthog-doctor schema', () => { const canned = { diff --git a/src/lib/programs/posthog-doctor/fetch.ts b/src/store/programs/posthog-doctor/fetch.ts similarity index 81% rename from src/lib/programs/posthog-doctor/fetch.ts rename to src/store/programs/posthog-doctor/fetch.ts index b0a5f2e44..3879ec155 100644 --- a/src/lib/programs/posthog-doctor/fetch.ts +++ b/src/store/programs/posthog-doctor/fetch.ts @@ -1,8 +1,8 @@ import axios from 'axios'; -import { analytics } from '@utils/analytics'; -import { handleApiError } from '@lib/api'; -import { WIZARD_USER_AGENT } from '@lib/constants'; -import { HealthIssueListResponseSchema, type HealthIssue } from './types'; +import { analytics } from '../../shared/analytics.js'; +import { handleApiError } from '../../api.js'; +import { WIZARD_USER_AGENT } from '../../shared/constants.js'; +import { HealthIssueListResponseSchema, type HealthIssue } from './types.js'; export async function fetchHealthIssues( accessToken: string, diff --git a/src/lib/programs/posthog-doctor/index.ts b/src/store/programs/posthog-doctor/index.ts similarity index 84% rename from src/lib/programs/posthog-doctor/index.ts rename to src/store/programs/posthog-doctor/index.ts index 8ea70acf1..590112661 100644 --- a/src/lib/programs/posthog-doctor/index.ts +++ b/src/store/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 type { ProgramConfig } from '../program-step.js'; +import { WIZARD_TOOL_NAMES } from '../../tools/index.js'; import { POSTHOG_DOCTOR_PROGRAM } from './steps.js'; export const posthogDoctorConfig: ProgramConfig = { diff --git a/src/lib/programs/posthog-doctor/kind-metadata.ts b/src/store/programs/posthog-doctor/kind-metadata.ts similarity index 97% rename from src/lib/programs/posthog-doctor/kind-metadata.ts rename to src/store/programs/posthog-doctor/kind-metadata.ts index 885e1062e..12787670c 100644 --- a/src/lib/programs/posthog-doctor/kind-metadata.ts +++ b/src/store/programs/posthog-doctor/kind-metadata.ts @@ -1,4 +1,4 @@ -import { POSTHOG_DOCS_URL } from '@lib/constants'; +import { POSTHOG_DOCS_URL } from '../../shared/constants.js'; export interface KindMeta { title: string; diff --git a/src/lib/programs/posthog-doctor/steps.ts b/src/store/programs/posthog-doctor/steps.ts similarity index 81% rename from src/lib/programs/posthog-doctor/steps.ts rename to src/store/programs/posthog-doctor/steps.ts index fe0ef895c..8be7a9434 100644 --- a/src/lib/programs/posthog-doctor/steps.ts +++ b/src/store/programs/posthog-doctor/steps.ts @@ -1,5 +1,5 @@ -import type { ProgramStep } from '@lib/programs/program-step'; -import { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step'; +import type { ProgramStep } from '../program-step.js'; +import { HEALTH_CHECK_STEP } from '../shared/health-check-step.js'; export const POSTHOG_DOCTOR_PROGRAM: ProgramStep[] = [ { diff --git a/src/lib/programs/posthog-doctor/types.ts b/src/store/programs/posthog-doctor/types.ts similarity index 100% rename from src/lib/programs/posthog-doctor/types.ts rename to src/store/programs/posthog-doctor/types.ts diff --git a/src/lib/programs/posthog-integration/__tests__/detect.test.ts b/src/store/programs/posthog-integration/__tests__/detect.test.ts similarity index 95% rename from src/lib/programs/posthog-integration/__tests__/detect.test.ts rename to src/store/programs/posthog-integration/__tests__/detect.test.ts index 3e4a67f56..2f936cded 100644 --- a/src/lib/programs/posthog-integration/__tests__/detect.test.ts +++ b/src/store/programs/posthog-integration/__tests__/detect.test.ts @@ -4,7 +4,7 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -vi.mock('@utils/analytics', () => ({ +vi.mock('../../../shared/analytics.js', () => ({ analytics: { wizardCapture: vi.fn(), setTag: vi.fn(), @@ -15,33 +15,36 @@ vi.mock('@utils/analytics', () => ({ })); // Wrapped so one test can force a throw; the rest use the real scanner. -vi.mock('@lib/warehouse-sources/detect', async (importOriginal) => { - const actual = await importOriginal< - typeof import('@lib/warehouse-sources/detect') - >(); - return { - ...actual, - detectWarehouseSources: vi.fn(actual.detectWarehouseSources), - }; -}); +vi.mock( + '../../../services/warehouse-sources/detect.js', + async (importOriginal) => { + const actual = await importOriginal< + typeof import('../../../services/warehouse-sources/detect.js') + >(); + return { + ...actual, + detectWarehouseSources: vi.fn(actual.detectWarehouseSources), + }; + }, +); -import { analytics } from '@utils/analytics'; -import { detectWarehouseSources } from '@lib/warehouse-sources/detect'; +import { analytics } from '../../../shared/analytics.js'; +import { detectWarehouseSources } from '../../../services/warehouse-sources/detect.js'; import { detectPostHogIntegration, maybeStampAiSdkDetected, reportWarehouseSourcesDetected, -} from '@lib/programs/posthog-integration/detect'; -import { posthogIntegrationConfig } from '@lib/programs/posthog-integration/index'; -import { DETECTED_WAREHOUSE_SOURCES_KEY } from '@lib/programs/warehouse-source/detect'; -import type { ProgramReadyContext } from '@lib/programs/program-step'; +} from '../detect.js'; +import { posthogIntegrationConfig } from '../index.js'; +import { DETECTED_WAREHOUSE_SOURCES_KEY } from '../../warehouse-source/detect.js'; +import type { ProgramReadyContext } from '../../program-step.js'; import { buildSession, DiscoveredFeature, ScanConsent, type WizardSession, -} from '@lib/wizard-session'; -import type { DetectedSource } from '@lib/warehouse-sources/types'; +} from '../../../session/wizard-session.js'; +import type { DetectedSource } from '../../../services/warehouse-sources/types.js'; function makeTmpDir(): string { return fs.mkdtempSync(path.join(os.tmpdir(), 'warehouse-reporting-')); @@ -288,7 +291,7 @@ describe('reportWarehouseSourcesDetected', () => { // scanned". const session = buildSession({ installDir: tmpDir, ci: true }); const { detectWarehousePrerequisites } = await import( - '@lib/programs/warehouse-source/detect' + '../../warehouse-source/detect.js' ); detectWarehousePrerequisites(session, (key, value) => { session.frameworkContext[key] = value; diff --git a/src/lib/programs/posthog-integration/__tests__/handoff.test.ts b/src/store/programs/posthog-integration/__tests__/handoff.test.ts similarity index 96% rename from src/lib/programs/posthog-integration/__tests__/handoff.test.ts rename to src/store/programs/posthog-integration/__tests__/handoff.test.ts index cc6a47e55..4f5ddd95d 100644 --- a/src/lib/programs/posthog-integration/__tests__/handoff.test.ts +++ b/src/store/programs/posthog-integration/__tests__/handoff.test.ts @@ -1,4 +1,4 @@ -import { buildCodingAgentPrompt } from '../handoff'; +import { buildCodingAgentPrompt } from '../handoff.js'; const NOTEBOOK_URL = 'https://us.posthog.com/project/1/notebooks/AbCdEfGh'; diff --git a/src/lib/programs/posthog-integration/__tests__/index.test.ts b/src/store/programs/posthog-integration/__tests__/index.test.ts similarity index 84% rename from src/lib/programs/posthog-integration/__tests__/index.test.ts rename to src/store/programs/posthog-integration/__tests__/index.test.ts index ec55f6efe..e5d535665 100644 --- a/src/lib/programs/posthog-integration/__tests__/index.test.ts +++ b/src/store/programs/posthog-integration/__tests__/index.test.ts @@ -6,12 +6,15 @@ * state, so the value rides on every later capture either way. */ -import { posthogIntegrationConfig } from '@lib/programs/posthog-integration/index'; -import { buildSession, type WizardSession } from '@lib/wizard-session'; -import { analytics } from '@utils/analytics'; -import { isUsingTypeScript } from '@utils/setup-utils'; +import { posthogIntegrationConfig } from '../index.js'; +import { + buildSession, + type WizardSession, +} from '../../../session/wizard-session.js'; +import { analytics } from '../../../shared/analytics.js'; +import { isUsingTypeScript } from '../../../shared/setup-utils.js'; -vi.mock('@utils/analytics', () => ({ +vi.mock('../../../shared/analytics.js', () => ({ analytics: { wizardCapture: vi.fn(), setTag: vi.fn(), @@ -19,7 +22,7 @@ vi.mock('@utils/analytics', () => ({ }, })); -vi.mock('@utils/setup-utils', () => ({ +vi.mock('../../../shared/setup-utils.js', () => ({ isUsingTypeScript: vi.fn(), tryGetPackageJson: vi.fn().mockResolvedValue(null), })); diff --git a/src/lib/programs/posthog-integration/constants.ts b/src/store/programs/posthog-integration/constants.ts similarity index 100% rename from src/lib/programs/posthog-integration/constants.ts rename to src/store/programs/posthog-integration/constants.ts diff --git a/src/lib/programs/posthog-integration/detect.ts b/src/store/programs/posthog-integration/detect.ts similarity index 94% rename from src/lib/programs/posthog-integration/detect.ts rename to src/store/programs/posthog-integration/detect.ts index f27faa6a9..bd12750f5 100644 --- a/src/lib/programs/posthog-integration/detect.ts +++ b/src/store/programs/posthog-integration/detect.ts @@ -9,29 +9,29 @@ * extracted here so the `integrate` subcommand can reuse it. */ -import type { ProgramReadyContext } from '@lib/programs/program-step'; +import type { ProgramReadyContext } from '../program-step.js'; import { DiscoveredFeature, mayReportScanResults, ScanConsent, type WizardSession, -} from '@lib/wizard-session'; -import { FRAMEWORK_REGISTRY } from '@lib/registry'; +} from '../../session/wizard-session.js'; +import { FRAMEWORK_REGISTRY } from '../../registry.js'; import { detectFramework, discoverFeatures, gatherFrameworkContext, checkFrameworkVersion, -} from '@lib/detection/index'; -import { analytics } from '@utils/analytics'; -import { detectWarehouseSources } from '@lib/warehouse-sources/detect'; -import { AI_SOURCE_KINDS } from '@lib/warehouse-sources/registry'; -import type { DetectedSource } from '@lib/warehouse-sources/types'; +} from '../../detection/index.js'; +import { analytics } from '../../shared/analytics.js'; +import { detectWarehouseSources } from '../../services/warehouse-sources/detect.js'; +import { AI_SOURCE_KINDS } from '../../services/warehouse-sources/registry.js'; +import type { DetectedSource } from '../../services/warehouse-sources/types.js'; import { DETECTED_WAREHOUSE_SOURCES_KEY, getDetectedWarehouseSources, -} from '@lib/programs/warehouse-source/detect'; -import { findPackageJsons } from '@lib/programs/shared/package-scanning'; +} from '../warehouse-source/detect.js'; +import { findPackageJsons } from '../shared/package-scanning.js'; export async function detectPostHogIntegration( ctx: ProgramReadyContext, diff --git a/src/lib/programs/posthog-integration/handoff.ts b/src/store/programs/posthog-integration/handoff.ts similarity index 100% rename from src/lib/programs/posthog-integration/handoff.ts rename to src/store/programs/posthog-integration/handoff.ts diff --git a/src/lib/programs/posthog-integration/index.ts b/src/store/programs/posthog-integration/index.ts similarity index 92% rename from src/lib/programs/posthog-integration/index.ts rename to src/store/programs/posthog-integration/index.ts index bd78e52a5..fb3fb0786 100644 --- a/src/lib/programs/posthog-integration/index.ts +++ b/src/store/programs/posthog-integration/index.ts @@ -1,27 +1,37 @@ -import type { ProgramConfig, ProgramStep } from '@lib/programs/program-step'; -import type { ProgramRun } from '@lib/program-run'; -import { WIZARD_TOOL_NAMES } from '@lib/wizard-tools'; -import type { WizardSession } from '@lib/wizard-session'; -import { mayReportScanResults, OutroKind, RunPhase } from '@lib/wizard-session'; -import { AgentSignals } from '@lib/agent-signals'; +import type { ProgramConfig, ProgramStep } from '../program-step.js'; +import type { ProgramRun } from '../../agent-protocol/program-run.js'; +import { WIZARD_TOOL_NAMES } from '../../tools/index.js'; +import type { WizardSession } from '../../session/wizard-session.js'; +import { + mayReportScanResults, + OutroKind, + RunPhase, +} from '../../session/wizard-session.js'; +import { AgentSignals } from '../../agent-protocol/agent-signals.js'; import { DEFAULT_PACKAGE_INSTALLATION, SPINNER_MESSAGE, -} from '@lib/framework-config'; -import { tryGetPackageJson, isUsingTypeScript } from '@utils/setup-utils'; -import { analytics } from '@utils/analytics'; -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 { WIZARD_INTERACTION_EVENT_NAME } from '@lib/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 { getDetectedWarehouseSources } from '@lib/programs/warehouse-source/detect'; -import { shouldDisableAsk } from '@lib/ask-policy'; +} from '../../framework-config.js'; +import { + tryGetPackageJson, + isUsingTypeScript, +} from '../../shared/setup-utils.js'; +import { analytics } from '../../shared/analytics.js'; +import { + detectFramework, + gatherFrameworkContext, +} from '../../detection/index.js'; +import { scopeInstallDirToProject } from '../../detection/project-scope.js'; +import { FRAMEWORK_REGISTRY } from '../../registry.js'; +import { wizardAbort } from '../../shared/wizard-abort.js'; +import { ErrorCodes } from '../../shared/errors/index.js'; +import { WIZARD_INTERACTION_EVENT_NAME } from '../../shared/constants.js'; +import { getUI } from '../../ui/index.js'; +import { requestDeepLink } from '../../shared/provisioning.js'; +import { openTrackedLink, withUtm } from '../../shared/links.js'; +import type { HostResolution } from '../../host-resolution.js'; +import { getDetectedWarehouseSources } from '../warehouse-source/detect.js'; +import { shouldDisableAsk } from '../../session/ask-policy.js'; import { POSTHOG_INTEGRATION_PROGRAM } from './steps.js'; import { buildCodingAgentPrompt } from './handoff.js'; import { EVENT_PLAN_FILE } from './constants.js'; @@ -262,7 +272,9 @@ export const posthogIntegrationConfig: ProgramConfig = { installDir: session.installDir, }); if (packageJson) { - const { hasDeclaredDependency } = await import('@utils/package-json'); + const { hasDeclaredDependency } = await import( + '../../shared/package-json.js' + ); if (!hasDeclaredDependency(config.detection.packageName, packageJson)) { getUI().log.warn( `${config.detection.packageDisplayName} does not seem to be installed. Continuing anyway — the agent will handle it.`, @@ -373,7 +385,7 @@ ${warehouseReportInstruction(session)} ); if (config.environment.uploadToHosting) { const { uploadEnvironmentVariablesStep } = await import( - '@steps/index' + '../../services/steps/index.js' ); const uploadedEnvVars = await uploadEnvironmentVariablesStep( envVars, diff --git a/src/lib/programs/posthog-integration/steps.ts b/src/store/programs/posthog-integration/steps.ts similarity index 89% rename from src/lib/programs/posthog-integration/steps.ts rename to src/store/programs/posthog-integration/steps.ts index bc5adc3b0..df125ca7c 100644 --- a/src/lib/programs/posthog-integration/steps.ts +++ b/src/store/programs/posthog-integration/steps.ts @@ -6,10 +6,10 @@ * definitions — no hardcoded per-flow logic in the store. */ -import type { ProgramStep } from '@lib/programs/program-step'; -import type { WizardSession } from '@lib/wizard-session'; -import { RunPhase } from '@lib/wizard-session'; -import { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step'; +import type { ProgramStep } from '../program-step.js'; +import type { WizardSession } from '../../session/wizard-session.js'; +import { RunPhase } from '../../session/wizard-session.js'; +import { HEALTH_CHECK_STEP } from '../shared/health-check-step.js'; import { detectPostHogIntegration } from './detect.js'; function needsSetup(session: WizardSession): boolean { diff --git a/src/lib/programs/posthog-integration/test/README.md b/src/store/programs/posthog-integration/test/README.md similarity index 100% rename from src/lib/programs/posthog-integration/test/README.md rename to src/store/programs/posthog-integration/test/README.md diff --git a/src/lib/programs/posthog-integration/test/e2e.json b/src/store/programs/posthog-integration/test/e2e.json similarity index 100% rename from src/lib/programs/posthog-integration/test/e2e.json rename to src/store/programs/posthog-integration/test/e2e.json diff --git a/src/lib/programs/program-registry.ts b/src/store/programs/program-registry.ts similarity index 99% rename from src/lib/programs/program-registry.ts rename to src/store/programs/program-registry.ts index 162c2436e..ee2849894 100644 --- a/src/lib/programs/program-registry.ts +++ b/src/store/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-step.ts b/src/store/programs/program-step.ts similarity index 97% rename from src/lib/programs/program-step.ts rename to src/store/programs/program-step.ts index 22c46ce51..c927daa33 100644 --- a/src/lib/programs/program-step.ts +++ b/src/store/programs/program-step.ts @@ -1,12 +1,12 @@ -import type { WizardSession } from '@lib/wizard-session'; +import type { WizardSession } from '../session/wizard-session.js'; import type { FlowStep, StoreInitContext, ProgramReadyContext, -} from '@lib/flow'; +} from '../state/flow.js'; export type { StoreInitContext, ProgramReadyContext }; -import type { ProgramRunConfig } from '@lib/program-run'; +import type { ProgramRunConfig } from '../agent-protocol/program-run.js'; // Type-only — erased at compile time, so no runtime cycle with the // registry that imports `ProgramConfig` back from this module. import type { ProgramId } from './program-registry.js'; diff --git a/src/lib/programs/replay-vision/index.ts b/src/store/programs/replay-vision/index.ts similarity index 90% rename from src/lib/programs/replay-vision/index.ts rename to src/store/programs/replay-vision/index.ts index 0bb2b0b2f..c077ca74f 100644 --- a/src/lib/programs/replay-vision/index.ts +++ b/src/store/programs/replay-vision/index.ts @@ -1,20 +1,23 @@ -import type { AbortCase } from '@lib/program-run'; -import { Integration } from '@lib/constants'; -import { detectFramework, gatherFrameworkContext } from '@lib/detection/index'; -import { scopeInstallDirToProject } from '@lib/detection/project-scope'; -import { FRAMEWORK_REGISTRY } from '@lib/registry'; -import { createSkillProgram } from '@lib/programs/agent-skill/index'; -import { AGENT_SKILL_STEPS } from '@lib/programs/agent-skill/steps'; -import { detectPostHogIntegration } from '@lib/programs/posthog-integration/detect'; +import type { AbortCase } from '../../agent-protocol/program-run.js'; +import { Integration } from '../../shared/constants.js'; +import { + detectFramework, + gatherFrameworkContext, +} from '../../detection/index.js'; +import { scopeInstallDirToProject } from '../../detection/project-scope.js'; +import { FRAMEWORK_REGISTRY } from '../../registry.js'; +import { createSkillProgram } from '../agent-skill/index.js'; +import { AGENT_SKILL_STEPS } from '../agent-skill/steps.js'; +import { detectPostHogIntegration } from '../posthog-integration/detect.js'; import type { ProgramConfig, ProgramReadyContext, ProgramStep, -} from '@lib/programs/program-step'; -import type { WizardSession } from '@lib/wizard-session'; -import { analytics } from '@utils/analytics'; -import { wizardAbort } from '@utils/wizard-abort'; -import { ErrorCodes } from '@lib/errors'; +} from '../program-step.js'; +import type { WizardSession } from '../../session/wizard-session.js'; +import { analytics } from '../../shared/analytics.js'; +import { wizardAbort } from '../../shared/wizard-abort.js'; +import { ErrorCodes } from '../../shared/errors/index.js'; const REPLAY_VISION_REPORT_FILE = 'posthog-replay-vision-report.md'; diff --git a/src/lib/programs/replay-vision/test/e2e.json b/src/store/programs/replay-vision/test/e2e.json similarity index 100% rename from src/lib/programs/replay-vision/test/e2e.json rename to src/store/programs/replay-vision/test/e2e.json diff --git a/src/lib/programs/revenue-analytics/detect.ts b/src/store/programs/revenue-analytics/detect.ts similarity index 94% rename from src/lib/programs/revenue-analytics/detect.ts rename to src/store/programs/revenue-analytics/detect.ts index 4fff50d25..58b114ada 100644 --- a/src/lib/programs/revenue-analytics/detect.ts +++ b/src/store/programs/revenue-analytics/detect.ts @@ -6,16 +6,16 @@ */ import { existsSync, statSync } from 'fs'; -import type { WizardSession } from '@lib/wizard-session'; -import type { AbortCase } from '@lib/program-run'; -import { findPackageJsons } from '@lib/programs/shared/package-scanning'; +import type { WizardSession } from '../../session/wizard-session.js'; +import type { AbortCase } from '../../agent-protocol/program-run.js'; +import { findPackageJsons } from '../shared/package-scanning.js'; export { findPackageJsons, POSTHOG_SDKS, STRIPE_SDKS, type PackageMatch, -} from '@lib/programs/shared/package-scanning'; +} from '../shared/package-scanning.js'; /** * Structured detection errors. The screen renders each kind into JSX diff --git a/src/lib/programs/revenue-analytics/index.ts b/src/store/programs/revenue-analytics/index.ts similarity index 90% rename from src/lib/programs/revenue-analytics/index.ts rename to src/store/programs/revenue-analytics/index.ts index 6478bbd97..117a87ea0 100644 --- a/src/lib/programs/revenue-analytics/index.ts +++ b/src/store/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 type { ProgramConfig } from '../program-step.js'; +import { WIZARD_TOOL_NAMES } from '../../tools/index.js'; import { REVENUE_ANALYTICS_PROGRAM } from './steps.js'; import { REVENUE_ABORT_CASES } from './detect.js'; diff --git a/src/lib/programs/revenue-analytics/steps.ts b/src/store/programs/revenue-analytics/steps.ts similarity index 88% rename from src/lib/programs/revenue-analytics/steps.ts rename to src/store/programs/revenue-analytics/steps.ts index 7e983ab9d..567b89be7 100644 --- a/src/lib/programs/revenue-analytics/steps.ts +++ b/src/store/programs/revenue-analytics/steps.ts @@ -5,9 +5,9 @@ * and agent run live in the program runner (see agent-runner.ts). */ -import type { ProgramStep } from '@lib/programs/program-step'; -import { RunPhase } from '@lib/wizard-session'; -import { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step'; +import type { ProgramStep } from '../program-step.js'; +import { RunPhase } from '../../session/wizard-session.js'; +import { HEALTH_CHECK_STEP } from '../shared/health-check-step.js'; import { detectRevenuePrerequisites } from './detect.js'; export const REVENUE_ANALYTICS_PROGRAM: ProgramStep[] = [ diff --git a/src/lib/programs/run-config.ts b/src/store/programs/run-config.ts similarity index 91% rename from src/lib/programs/run-config.ts rename to src/store/programs/run-config.ts index 0ddb1c8f5..1930de71f 100644 --- a/src/lib/programs/run-config.ts +++ b/src/store/programs/run-config.ts @@ -1,4 +1,4 @@ -import type { ProgramRunConfig } from '@lib/program-run'; +import type { ProgramRunConfig } from '../agent-protocol/program-run.js'; import type { ProgramConfig, ProgramStep } from './program-step.js'; /** Gated step ids between the `auth` and the first `run` step, in order. */ diff --git a/src/lib/programs/self-driving/ARCHITECTURE.md b/src/store/programs/self-driving/ARCHITECTURE.md similarity index 100% rename from src/lib/programs/self-driving/ARCHITECTURE.md rename to src/store/programs/self-driving/ARCHITECTURE.md diff --git a/src/lib/programs/self-driving/__tests__/step-keys.test.ts b/src/store/programs/self-driving/__tests__/step-keys.test.ts similarity index 100% rename from src/lib/programs/self-driving/__tests__/step-keys.test.ts rename to src/store/programs/self-driving/__tests__/step-keys.test.ts diff --git a/src/lib/programs/self-driving/detect-agentic.ts b/src/store/programs/self-driving/detect-agentic.ts similarity index 93% rename from src/lib/programs/self-driving/detect-agentic.ts rename to src/store/programs/self-driving/detect-agentic.ts index ddb416941..8429a6b1c 100644 --- a/src/lib/programs/self-driving/detect-agentic.ts +++ b/src/store/programs/self-driving/detect-agentic.ts @@ -14,14 +14,14 @@ import type { AgenticDetectionReport, DetectEvent, -} from '@lib/detection/agentic'; +} from '../../detection/agentic.js'; import { detectIntegrationProjects, toIntegrationCandidates, -} from '@lib/detection/project-scope'; -import { gatherFrameworkContext } from '@lib/detection/index'; -import type { Integration } from '@lib/constants'; -import type { WizardSession } from '@lib/wizard-session'; +} from '../../detection/project-scope.js'; +import { gatherFrameworkContext } from '../../detection/index.js'; +import type { Integration } from '../../shared/constants.js'; +import type { WizardSession } from '../../session/wizard-session.js'; export type { DetectEvent }; diff --git a/src/lib/programs/self-driving/detect.ts b/src/store/programs/self-driving/detect.ts similarity index 96% rename from src/lib/programs/self-driving/detect.ts rename to src/store/programs/self-driving/detect.ts index 94e30c33e..cc50e7db7 100644 --- a/src/lib/programs/self-driving/detect.ts +++ b/src/store/programs/self-driving/detect.ts @@ -27,12 +27,12 @@ import { type Dirent, } from 'fs'; import { join } from 'path'; -import { analytics } from '@utils/analytics'; -import type { WizardSession } from '@lib/wizard-session'; -import type { AbortCase } from '@lib/program-run'; -import { ErrorCodes } from '@lib/errors'; -import { detectWarehouseSources } from '@lib/warehouse-sources/detect'; -import type { DetectedSource } from '@lib/warehouse-sources/types'; +import { analytics } from '../../shared/analytics.js'; +import type { WizardSession } from '../../session/wizard-session.js'; +import type { AbortCase } from '../../agent-protocol/program-run.js'; +import { ErrorCodes } from '../../shared/errors/index.js'; +import { detectWarehouseSources } from '../../services/warehouse-sources/detect.js'; +import type { DetectedSource } from '../../services/warehouse-sources/types.js'; /** frameworkContext key holding the deterministic PostHog-presence result. */ export const POSTHOG_PRESENT_KEY = 'postHogPresent'; diff --git a/src/lib/programs/self-driving/index.ts b/src/store/programs/self-driving/index.ts similarity index 95% rename from src/lib/programs/self-driving/index.ts rename to src/store/programs/self-driving/index.ts index b0fd3b1f6..9948a2e68 100644 --- a/src/lib/programs/self-driving/index.ts +++ b/src/store/programs/self-driving/index.ts @@ -1,8 +1,8 @@ import { join } from 'path'; import { access, rm } from 'node:fs/promises'; -import type { ProgramConfig } from '@lib/programs/program-step'; -import type { ProgramRun } from '@lib/program-run'; -import { OutroKind, type WizardSession } from '@lib/wizard-session'; +import type { ProgramConfig } from '../program-step.js'; +import type { ProgramRun } from '../../agent-protocol/program-run.js'; +import { OutroKind, type WizardSession } from '../../session/wizard-session.js'; import { createSkillProgram } from '../agent-skill/index.js'; import { SELF_DRIVING_PROGRAM } from './steps.js'; import { @@ -15,7 +15,7 @@ import { NO_DEFAULT_LIMIT, PRICE_PER_PR_USD, PRICING_LONG, -} from '@ui/tui/programs/self-driving/content/pricing.js'; +} from '@tui/programs/self-driving/content/pricing'; export const SELF_DRIVING_SKILL_ID = 'self-driving-setup'; const REPORT_FILE = 'posthog-self-driving-report.md'; diff --git a/src/lib/programs/self-driving/prompt.ts b/src/store/programs/self-driving/prompt.ts similarity index 98% rename from src/lib/programs/self-driving/prompt.ts rename to src/store/programs/self-driving/prompt.ts index 07033c4d0..df79d8a5c 100644 --- a/src/lib/programs/self-driving/prompt.ts +++ b/src/store/programs/self-driving/prompt.ts @@ -1,6 +1,6 @@ -import { AgentSignals } from '@lib/agent-signals'; -import type { PromptContext } from '@lib/program-run'; -import type { DetectedSource } from '@lib/warehouse-sources/types'; +import { AgentSignals } from '../../agent-protocol/agent-signals.js'; +import type { PromptContext } from '../../agent-protocol/program-run.js'; +import type { DetectedSource } from '../../services/warehouse-sources/types.js'; /** * Render the deterministic codebase-tool scan for the prompt. STEP 4 and diff --git a/src/lib/programs/self-driving/step-keys.ts b/src/store/programs/self-driving/step-keys.ts similarity index 100% rename from src/lib/programs/self-driving/step-keys.ts rename to src/store/programs/self-driving/step-keys.ts diff --git a/src/lib/programs/self-driving/steps.ts b/src/store/programs/self-driving/steps.ts similarity index 94% rename from src/lib/programs/self-driving/steps.ts rename to src/store/programs/self-driving/steps.ts index 4eeceb5d4..c30cd89bb 100644 --- a/src/lib/programs/self-driving/steps.ts +++ b/src/store/programs/self-driving/steps.ts @@ -14,11 +14,11 @@ * gates on the GitHub App connection the run cannot proceed without. No keep-skills step: the setup skill is transient, so postRun removes it. */ -import type { ProgramStep } from '@lib/programs/program-step'; -import { resolveProjectDir } from '@lib/detection/agentic'; -import { RunPhase, type WizardSession } from '@lib/wizard-session'; -import { HEALTH_CHECK_STEP } from '@lib/programs/shared/health-check-step'; -import { integrationRunStep } from '@lib/programs/posthog-integration/index'; +import type { ProgramStep } from '../program-step.js'; +import { resolveProjectDir } from '../../detection/agentic.js'; +import { RunPhase, type WizardSession } from '../../session/wizard-session.js'; +import { HEALTH_CHECK_STEP } from '../shared/health-check-step.js'; +import { integrationRunStep } from '../posthog-integration/index.js'; import { detectSelfDrivingPrerequisites, POSTHOG_PRESENT_KEY, diff --git a/src/lib/programs/self-driving/test/e2e.json b/src/store/programs/self-driving/test/e2e.json similarity index 100% rename from src/lib/programs/self-driving/test/e2e.json rename to src/store/programs/self-driving/test/e2e.json diff --git a/src/lib/programs/shared/health-check-step.ts b/src/store/programs/shared/health-check-step.ts similarity index 89% rename from src/lib/programs/shared/health-check-step.ts rename to src/store/programs/shared/health-check-step.ts index 1c630a52c..53da9b47d 100644 --- a/src/lib/programs/shared/health-check-step.ts +++ b/src/store/programs/shared/health-check-step.ts @@ -11,15 +11,15 @@ * render the OutroScreen. */ -import type { ProgramStep } from '@lib/programs/program-step'; -import type { WizardSession } from '@lib/wizard-session'; +import type { ProgramStep } from '../program-step.js'; +import type { WizardSession } from '../../session/wizard-session.js'; import { evaluateWizardReadiness, WizardReadiness, SIGNUP_WIZARD_READINESS_CONFIG, getBlockingServiceKeys, -} from '@lib/health-checks/readiness'; -import { logToFile } from '@utils/debug'; +} from '../../health-checks/readiness.js'; +import { logToFile } from '../../shared/debug.js'; export function healthCheckReady(session: WizardSession): boolean { if (!session.readinessResult) return false; diff --git a/src/lib/programs/shared/package-scanning.ts b/src/store/programs/shared/package-scanning.ts similarity index 95% rename from src/lib/programs/shared/package-scanning.ts rename to src/store/programs/shared/package-scanning.ts index 3b399edf0..5f06769fb 100644 --- a/src/lib/programs/shared/package-scanning.ts +++ b/src/store/programs/shared/package-scanning.ts @@ -1,5 +1,5 @@ import { relative } from 'path'; -import { safeReadFile, walkProjectFiles } from '@utils/bounded-fs'; +import { safeReadFile, walkProjectFiles } from '../../shared/bounded-fs.js'; export const POSTHOG_SDKS = new Set([ 'posthog-js', diff --git a/src/lib/programs/shared/posthog-cli-preinstall.ts b/src/store/programs/shared/posthog-cli-preinstall.ts similarity index 87% rename from src/lib/programs/shared/posthog-cli-preinstall.ts rename to src/store/programs/shared/posthog-cli-preinstall.ts index 865a25a9f..9993709b6 100644 --- a/src/lib/programs/shared/posthog-cli-preinstall.ts +++ b/src/store/programs/shared/posthog-cli-preinstall.ts @@ -8,9 +8,9 @@ * needs the CLI. */ -import { installOrUpdatePostHogCli } from '@steps/install-cli-steering'; -import { getUI } from '@ui'; -import { analytics } from '@utils/analytics'; +import { installOrUpdatePostHogCli } from '../../services/steps/install-cli-steering/index.js'; +import { getUI } from '../../ui/index.js'; +import { analytics } from '../../shared/analytics.js'; let attempted = false; diff --git a/src/lib/programs/slack/index.ts b/src/store/programs/slack/index.ts similarity index 91% rename from src/lib/programs/slack/index.ts rename to src/store/programs/slack/index.ts index 43823ef7d..ca3d5e0ef 100644 --- a/src/lib/programs/slack/index.ts +++ b/src/store/programs/slack/index.ts @@ -6,7 +6,7 @@ * happens in the browser, so a wizard login adds nothing for the user. */ -import type { ProgramConfig } from '@lib/programs/program-step'; +import type { ProgramConfig } from '../program-step.js'; export const slackConnectConfig: ProgramConfig = { id: 'slack', diff --git a/src/lib/programs/warehouse-source/detect.ts b/src/store/programs/warehouse-source/detect.ts similarity index 91% rename from src/lib/programs/warehouse-source/detect.ts rename to src/store/programs/warehouse-source/detect.ts index d6c6bc490..5e05bb1dc 100644 --- a/src/lib/programs/warehouse-source/detect.ts +++ b/src/store/programs/warehouse-source/detect.ts @@ -7,11 +7,11 @@ */ import { existsSync, statSync } from 'fs'; -import { analytics } from '@utils/analytics'; -import type { WizardSession } from '@lib/wizard-session'; -import type { AbortCase } from '@lib/program-run'; -import { detectWarehouseSources } from '@lib/warehouse-sources/detect'; -import type { DetectedSource } from '@lib/warehouse-sources/types'; +import { analytics } from '../../shared/analytics.js'; +import type { WizardSession } from '../../session/wizard-session.js'; +import type { AbortCase } from '../../agent-protocol/program-run.js'; +import { detectWarehouseSources } from '../../services/warehouse-sources/detect.js'; +import type { DetectedSource } from '../../services/warehouse-sources/types.js'; /** Structured detection errors rendered by the intro screen. */ export type WarehouseDetectError = diff --git a/src/lib/programs/warehouse-source/index.ts b/src/store/programs/warehouse-source/index.ts similarity index 91% rename from src/lib/programs/warehouse-source/index.ts rename to src/store/programs/warehouse-source/index.ts index e98fc420f..76d007aa5 100644 --- a/src/lib/programs/warehouse-source/index.ts +++ b/src/store/programs/warehouse-source/index.ts @@ -1,7 +1,7 @@ -import type { ProgramConfig } from '@lib/programs/program-step'; -import type { ProgramRun } from '@lib/program-run'; -import type { WizardSession } from '@lib/wizard-session'; -import { LONGER_ASK_TIMEOUT_MS } from '@lib/wizard-ask-bridge'; +import type { ProgramConfig } from '../program-step.js'; +import type { ProgramRun } from '../../agent-protocol/program-run.js'; +import type { WizardSession } from '../../session/wizard-session.js'; +import { LONGER_ASK_TIMEOUT_MS } from '../../session/wizard-ask-bridge.js'; import { WAREHOUSE_SOURCE_PROGRAM } from './steps.js'; import { WAREHOUSE_ABORT_CASES, diff --git a/src/lib/programs/warehouse-source/steps.ts b/src/store/programs/warehouse-source/steps.ts similarity index 92% rename from src/lib/programs/warehouse-source/steps.ts rename to src/store/programs/warehouse-source/steps.ts index 1a64bfebd..535032bba 100644 --- a/src/lib/programs/warehouse-source/steps.ts +++ b/src/store/programs/warehouse-source/steps.ts @@ -6,8 +6,8 @@ * both in-CLI source creation and deep-link emission per detected source. */ -import type { ProgramStep } from '@lib/programs/program-step'; -import { RunPhase } from '@lib/wizard-session'; +import type { ProgramStep } from '../program-step.js'; +import { RunPhase } from '../../session/wizard-session.js'; import { detectWarehousePrerequisites } from './detect.js'; export const WAREHOUSE_SOURCE_PROGRAM: ProgramStep[] = [ diff --git a/src/lib/programs/warehouse-source/test/e2e.json b/src/store/programs/warehouse-source/test/e2e.json similarity index 100% rename from src/lib/programs/warehouse-source/test/e2e.json rename to src/store/programs/warehouse-source/test/e2e.json diff --git a/src/lib/programs/web-analytics-doctor/detect.ts b/src/store/programs/web-analytics-doctor/detect.ts similarity index 90% rename from src/lib/programs/web-analytics-doctor/detect.ts rename to src/store/programs/web-analytics-doctor/detect.ts index 10f037282..3778a70e2 100644 --- a/src/lib/programs/web-analytics-doctor/detect.ts +++ b/src/store/programs/web-analytics-doctor/detect.ts @@ -1,8 +1,8 @@ import { existsSync, statSync } from 'fs'; -import type { WizardSession } from '@lib/wizard-session'; -import type { AbortCase } from '@lib/program-run'; -import { ErrorCodes } from '@lib/errors'; -import { findPackageJsons } from '@lib/programs/shared/package-scanning'; +import type { WizardSession } from '../../session/wizard-session.js'; +import type { AbortCase } from '../../agent-protocol/program-run.js'; +import { ErrorCodes } from '../../shared/errors/index.js'; +import { findPackageJsons } from '../shared/package-scanning.js'; export type WebAnalyticsDetectError = | { diff --git a/src/lib/programs/web-analytics-doctor/index.ts b/src/store/programs/web-analytics-doctor/index.ts similarity index 96% rename from src/lib/programs/web-analytics-doctor/index.ts rename to src/store/programs/web-analytics-doctor/index.ts index ee360dd0e..1a482dd24 100644 --- a/src/lib/programs/web-analytics-doctor/index.ts +++ b/src/store/programs/web-analytics-doctor/index.ts @@ -1,4 +1,4 @@ -import type { ProgramConfig } from '@lib/programs/program-step'; +import type { ProgramConfig } from '../program-step.js'; import { createSkillProgram } from '../agent-skill/index.js'; import { WEB_ANALYTICS_DOCTOR_PROGRAM } from './steps.js'; import { WEB_ANALYTICS_ABORT_CASES } from './detect.js'; diff --git a/src/lib/programs/web-analytics-doctor/steps.ts b/src/store/programs/web-analytics-doctor/steps.ts similarity index 70% rename from src/lib/programs/web-analytics-doctor/steps.ts rename to src/store/programs/web-analytics-doctor/steps.ts index 941b58a9d..4a717cf9f 100644 --- a/src/lib/programs/web-analytics-doctor/steps.ts +++ b/src/store/programs/web-analytics-doctor/steps.ts @@ -1,5 +1,5 @@ -import type { ProgramStep } from '@lib/programs/program-step'; -import { AGENT_SKILL_STEPS } from '@lib/programs/agent-skill/steps'; +import type { ProgramStep } from '../program-step.js'; +import { AGENT_SKILL_STEPS } from '../agent-skill/steps.js'; import { detectWebAnalyticsPrerequisites } from './detect.js'; export const WEB_ANALYTICS_DOCTOR_PROGRAM: ProgramStep[] = [ diff --git a/src/store/registry.ts b/src/store/registry.ts new file mode 100644 index 000000000..c7ed52aa9 --- /dev/null +++ b/src/store/registry.ts @@ -0,0 +1,59 @@ +import type { FrameworkConfig } from './framework-config.js'; +import { Integration } from './shared/constants.js'; +import { NEXTJS_AGENT_CONFIG } from './frameworks/nextjs/nextjs-wizard-agent.js'; +import { NUXT_AGENT_CONFIG } from './frameworks/nuxt/nuxt-wizard-agent.js'; +import { VUE_AGENT_CONFIG } from './frameworks/vue/vue-wizard-agent.js'; +import { REACT_ROUTER_AGENT_CONFIG } from './frameworks/react-router/react-router-wizard-agent.js'; +import { TANSTACK_ROUTER_AGENT_CONFIG } from './frameworks/tanstack-router/tanstack-router-wizard-agent.js'; +import { TANSTACK_START_AGENT_CONFIG } from './frameworks/tanstack-start/tanstack-start-wizard-agent.js'; +import { REACT_NATIVE_AGENT_CONFIG } from './frameworks/react-native/react-native-wizard-agent.js'; +import { ANGULAR_AGENT_CONFIG } from './frameworks/angular/angular-wizard-agent.js'; +import { ASTRO_AGENT_CONFIG } from './frameworks/astro/astro-wizard-agent.js'; +import { DJANGO_AGENT_CONFIG } from './frameworks/django/django-wizard-agent.js'; +import { FLASK_AGENT_CONFIG } from './frameworks/flask/flask-wizard-agent.js'; +import { FASTAPI_AGENT_CONFIG } from './frameworks/fastapi/fastapi-wizard-agent.js'; +import { LARAVEL_AGENT_CONFIG } from './frameworks/laravel/laravel-wizard-agent.js'; +import { SVELTEKIT_AGENT_CONFIG } from './frameworks/svelte/svelte-wizard-agent.js'; +import { FLUTTER_AGENT_CONFIG } from './frameworks/flutter/flutter-wizard-agent.js'; +import { SWIFT_AGENT_CONFIG } from './frameworks/swift/swift-wizard-agent.js'; +import { KMP_AGENT_CONFIG } from './frameworks/kmp/kmp-wizard-agent.js'; +import { ANDROID_AGENT_CONFIG } from './frameworks/android/android-wizard-agent.js'; +import { RAILS_AGENT_CONFIG } from './frameworks/rails/rails-wizard-agent.js'; +import { ELIXIR_AGENT_CONFIG } from './frameworks/elixir/elixir-wizard-agent.js'; +import { GO_AGENT_CONFIG } from './frameworks/go/go-wizard-agent.js'; +import { JAVA_AGENT_CONFIG } from './frameworks/java/java-wizard-agent.js'; +import { RUST_AGENT_CONFIG } from './frameworks/rust/rust-wizard-agent.js'; +import { PYTHON_AGENT_CONFIG } from './frameworks/python/python-wizard-agent.js'; +import { RUBY_AGENT_CONFIG } from './frameworks/ruby/ruby-wizard-agent.js'; +import { JAVASCRIPT_NODE_AGENT_CONFIG } from './frameworks/javascript-node/javascript-node-wizard-agent.js'; +import { JAVASCRIPT_WEB_AGENT_CONFIG } from './frameworks/javascript-web/javascript-web-wizard-agent.js'; + +export const FRAMEWORK_REGISTRY: Record = { + [Integration.nextjs]: NEXTJS_AGENT_CONFIG, + [Integration.nuxt]: NUXT_AGENT_CONFIG, + [Integration.vue]: VUE_AGENT_CONFIG, + [Integration.tanstackStart]: TANSTACK_START_AGENT_CONFIG, + [Integration.reactRouter]: REACT_ROUTER_AGENT_CONFIG, + [Integration.tanstackRouter]: TANSTACK_ROUTER_AGENT_CONFIG, + [Integration.reactNative]: REACT_NATIVE_AGENT_CONFIG, + [Integration.angular]: ANGULAR_AGENT_CONFIG, + [Integration.astro]: ASTRO_AGENT_CONFIG, + [Integration.django]: DJANGO_AGENT_CONFIG, + [Integration.flask]: FLASK_AGENT_CONFIG, + [Integration.fastapi]: FASTAPI_AGENT_CONFIG, + [Integration.laravel]: LARAVEL_AGENT_CONFIG, + [Integration.sveltekit]: SVELTEKIT_AGENT_CONFIG, + [Integration.flutter]: FLUTTER_AGENT_CONFIG, + [Integration.kmp]: KMP_AGENT_CONFIG, + [Integration.swift]: SWIFT_AGENT_CONFIG, + [Integration.android]: ANDROID_AGENT_CONFIG, + [Integration.rails]: RAILS_AGENT_CONFIG, + [Integration.elixir]: ELIXIR_AGENT_CONFIG, + [Integration.go]: GO_AGENT_CONFIG, + [Integration.rust]: RUST_AGENT_CONFIG, + [Integration.java]: JAVA_AGENT_CONFIG, + [Integration.python]: PYTHON_AGENT_CONFIG, + [Integration.ruby]: RUBY_AGENT_CONFIG, + [Integration.javascriptNode]: JAVASCRIPT_NODE_AGENT_CONFIG, + [Integration.javascript_web]: JAVASCRIPT_WEB_AGENT_CONFIG, +}; diff --git a/src/lib/safe-tools.ts b/src/store/safe-tools.ts similarity index 100% rename from src/lib/safe-tools.ts rename to src/store/safe-tools.ts diff --git a/src/lib/claude-settings.ts b/src/store/services/claude-settings.ts similarity index 98% rename from src/lib/claude-settings.ts rename to src/store/services/claude-settings.ts index 43da0b418..99cac2592 100644 --- a/src/lib/claude-settings.ts +++ b/src/store/services/claude-settings.ts @@ -10,12 +10,12 @@ import path from 'path'; import * as fs from 'fs'; import * as os from 'os'; -import { analytics } from '@utils/analytics'; -import { registerCleanup } from '@utils/wizard-abort'; +import { analytics } from '../shared/analytics.js'; +import { registerCleanup } from '../shared/wizard-abort.js'; import { BLOCKED_AGENT_ENV_KEYS, BLOCKED_AGENT_ENV_PATTERNS, -} from './agent-env-isolation'; +} from '../agent-protocol/agent-env-isolation.js'; /** 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/oauth/__tests__/program-scopes.test.ts b/src/store/services/oauth/__tests__/program-scopes.test.ts similarity index 98% rename from src/lib/oauth/__tests__/program-scopes.test.ts rename to src/store/services/oauth/__tests__/program-scopes.test.ts index 773a7f15d..f048f15d5 100644 --- a/src/lib/oauth/__tests__/program-scopes.test.ts +++ b/src/store/services/oauth/__tests__/program-scopes.test.ts @@ -6,7 +6,7 @@ import { getOAuthScopesForProgram, getProvisioningScopesForProgram, -} from '@lib/oauth/program-scopes'; +} from '../program-scopes.js'; describe('posthog-integration scopes', () => { it('includes the warehouse pair for the orchestrator warehouse task', () => { diff --git a/src/lib/oauth/program-scopes.ts b/src/store/services/oauth/program-scopes.ts similarity index 99% rename from src/lib/oauth/program-scopes.ts rename to src/store/services/oauth/program-scopes.ts index 69da4f59a..71a6be4f3 100644 --- a/src/lib/oauth/program-scopes.ts +++ b/src/store/services/oauth/program-scopes.ts @@ -31,11 +31,11 @@ // read as `undefined` at module init. Keep this type-only and reference // program IDs by their string-literal value below — TypeScript still // catches renames via the `Partial>` keying. -import type { ProgramId } from '@lib/programs/program-registry'; +import type { ProgramId } from '../../programs/program-registry.js'; import { WIZARD_OAUTH_SCOPES, WIZARD_PROVISIONING_SCOPES, -} from '@lib/constants'; +} from '../../shared/constants.js'; /** * Extra scopes the MCP tutorial needs on top of `WIZARD_OAUTH_SCOPES`. diff --git a/src/steps/add-mcp-server-to-clients/MCPClient.ts b/src/store/services/steps/add-mcp-server-to-clients/MCPClient.ts similarity index 98% rename from src/steps/add-mcp-server-to-clients/MCPClient.ts rename to src/store/services/steps/add-mcp-server-to-clients/MCPClient.ts index 087f075c7..2c2082423 100644 --- a/src/steps/add-mcp-server-to-clients/MCPClient.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/MCPClient.ts @@ -1,8 +1,8 @@ import * as fs from 'fs'; import * as path from 'path'; import * as jsonc from 'jsonc-parser'; -import { getDefaultServerConfig } from './defaults'; -import type { InstallResult } from './results'; +import { getDefaultServerConfig } from './defaults.js'; +import type { InstallResult } from './results.js'; export type MCPServerConfig = Record; diff --git a/src/steps/add-mcp-server-to-clients/__tests__/defaults.test.ts b/src/store/services/steps/add-mcp-server-to-clients/__tests__/defaults.test.ts similarity index 97% rename from src/steps/add-mcp-server-to-clients/__tests__/defaults.test.ts rename to src/store/services/steps/add-mcp-server-to-clients/__tests__/defaults.test.ts index c20b8f53b..2c4495a31 100644 --- a/src/steps/add-mcp-server-to-clients/__tests__/defaults.test.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/__tests__/defaults.test.ts @@ -2,7 +2,7 @@ import { buildMCPUrl, getDefaultServerConfig, getNativeHTTPServerConfig, -} from '@steps/add-mcp-server-to-clients/defaults'; +} from '../defaults.js'; describe('defaults', () => { describe('buildMCPUrl', () => { diff --git a/src/steps/add-mcp-server-to-clients/__tests__/mcp-client.test.ts b/src/store/services/steps/add-mcp-server-to-clients/__tests__/mcp-client.test.ts similarity index 96% rename from src/steps/add-mcp-server-to-clients/__tests__/mcp-client.test.ts rename to src/store/services/steps/add-mcp-server-to-clients/__tests__/mcp-client.test.ts index 82b6aaea4..3e04f9ca5 100644 --- a/src/steps/add-mcp-server-to-clients/__tests__/mcp-client.test.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/__tests__/mcp-client.test.ts @@ -1,4 +1,4 @@ -import { DefaultMCPClient } from '@steps/add-mcp-server-to-clients/MCPClient'; +import { DefaultMCPClient } from '../MCPClient.js'; import * as fs from 'fs'; vi.mock('fs', () => ({ diff --git a/src/steps/add-mcp-server-to-clients/__tests__/results.test.ts b/src/store/services/steps/add-mcp-server-to-clients/__tests__/results.test.ts similarity index 98% rename from src/steps/add-mcp-server-to-clients/__tests__/results.test.ts rename to src/store/services/steps/add-mcp-server-to-clients/__tests__/results.test.ts index 56f49dc89..443bf6f53 100644 --- a/src/steps/add-mcp-server-to-clients/__tests__/results.test.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/__tests__/results.test.ts @@ -5,7 +5,7 @@ import { redactSecrets, summarizeFailure, toClientResult, -} from '@steps/add-mcp-server-to-clients/results'; +} from '../results.js'; describe('toClientResult', () => { it('maps a plain success to installed', () => { diff --git a/src/steps/add-mcp-server-to-clients/browser-client.ts b/src/store/services/steps/add-mcp-server-to-clients/browser-client.ts similarity index 100% rename from src/steps/add-mcp-server-to-clients/browser-client.ts rename to src/store/services/steps/add-mcp-server-to-clients/browser-client.ts diff --git a/src/steps/add-mcp-server-to-clients/clients/__tests__/claude-code.test.ts b/src/store/services/steps/add-mcp-server-to-clients/clients/__tests__/claude-code.test.ts similarity index 95% rename from src/steps/add-mcp-server-to-clients/clients/__tests__/claude-code.test.ts rename to src/store/services/steps/add-mcp-server-to-clients/clients/__tests__/claude-code.test.ts index 4af8c4e36..59e7969e5 100644 --- a/src/steps/add-mcp-server-to-clients/clients/__tests__/claude-code.test.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/clients/__tests__/claude-code.test.ts @@ -1,6 +1,6 @@ -import { ClaudeCodeMCPClient } from '@steps/add-mcp-server-to-clients/clients/claude-code'; +import { ClaudeCodeMCPClient } from '../claude-code.js'; import { execSync } from 'child_process'; -import { analytics } from '@utils/analytics'; +import { analytics } from '../../../../../shared/analytics.js'; vi.mock('child_process', () => ({ execSync: vi.fn(), @@ -10,11 +10,11 @@ vi.mock('fs', () => ({ existsSync: vi.fn().mockReturnValue(false), })); -vi.mock('../../../../utils/analytics', () => ({ +vi.mock('../../../../../shared/analytics.js', () => ({ analytics: { captureException: vi.fn() }, })); -vi.mock('../../../../utils/debug', () => ({ +vi.mock('../../../../../shared/debug.js', () => ({ debug: vi.fn(), })); diff --git a/src/steps/add-mcp-server-to-clients/clients/__tests__/claude-web.test.ts b/src/store/services/steps/add-mcp-server-to-clients/clients/__tests__/claude-web.test.ts similarity index 86% rename from src/steps/add-mcp-server-to-clients/clients/__tests__/claude-web.test.ts rename to src/store/services/steps/add-mcp-server-to-clients/clients/__tests__/claude-web.test.ts index 3455279cc..1a872091e 100644 --- a/src/steps/add-mcp-server-to-clients/clients/__tests__/claude-web.test.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/clients/__tests__/claude-web.test.ts @@ -1,8 +1,8 @@ -import { ClaudeWebMCPClient } from '@steps/add-mcp-server-to-clients/clients/claude-web'; -import { isBrowserFinishable } from '@steps/add-mcp-server-to-clients/browser-client'; -import { openTrackedLink } from '@utils/links'; +import { ClaudeWebMCPClient } from '../claude-web.js'; +import { isBrowserFinishable } from '../../browser-client.js'; +import { openTrackedLink } from '../../../../../shared/links.js'; -vi.mock('@utils/links', () => ({ +vi.mock('../../../../../shared/links.js', () => ({ openTrackedLink: vi.fn(), })); diff --git a/src/steps/add-mcp-server-to-clients/clients/__tests__/claude.test.ts b/src/store/services/steps/add-mcp-server-to-clients/clients/__tests__/claude.test.ts similarity index 98% rename from src/steps/add-mcp-server-to-clients/clients/__tests__/claude.test.ts rename to src/store/services/steps/add-mcp-server-to-clients/clients/__tests__/claude.test.ts index 6e2cca39c..cd5ed11e4 100644 --- a/src/steps/add-mcp-server-to-clients/clients/__tests__/claude.test.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/clients/__tests__/claude.test.ts @@ -2,11 +2,11 @@ import * as fs from 'fs'; import * as path from 'path'; import * as os from 'os'; -import { ClaudeMCPClient } from '@steps/add-mcp-server-to-clients/clients/claude'; +import { ClaudeMCPClient } from '../claude.js'; import { getDefaultServerConfig, DefaultMCPClientConfig, -} from '@steps/add-mcp-server-to-clients/defaults'; +} from '../../defaults.js'; vi.mock('fs', () => ({ promises: { @@ -21,7 +21,7 @@ vi.mock('os', () => ({ homedir: vi.fn(), })); -vi.mock('../../defaults', () => ({ +vi.mock('../../defaults.js', () => ({ DefaultMCPClientConfig: { parse: vi.fn(), }, diff --git a/src/steps/add-mcp-server-to-clients/clients/__tests__/codex.test.ts b/src/store/services/steps/add-mcp-server-to-clients/clients/__tests__/codex.test.ts similarity index 98% rename from src/steps/add-mcp-server-to-clients/clients/__tests__/codex.test.ts rename to src/store/services/steps/add-mcp-server-to-clients/clients/__tests__/codex.test.ts index 4ff93c361..6d33fcfd3 100644 --- a/src/steps/add-mcp-server-to-clients/clients/__tests__/codex.test.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/clients/__tests__/codex.test.ts @@ -1,7 +1,7 @@ -import { CodexMCPClient } from '@steps/add-mcp-server-to-clients/clients/codex'; +import { CodexMCPClient } from '../codex.js'; import { execSync, spawnSync } from 'node:child_process'; import * as fs from 'node:fs'; -import { analytics } from '@utils/analytics'; +import { analytics } from '../../../../../shared/analytics.js'; vi.mock('node:child_process', () => ({ execSync: vi.fn(), @@ -14,7 +14,7 @@ vi.mock('node:fs', () => ({ rmSync: vi.fn(), })); -vi.mock('../../../../utils/analytics', () => ({ +vi.mock('../../../../../shared/analytics.js', () => ({ analytics: { captureException: vi.fn() }, })); diff --git a/src/steps/add-mcp-server-to-clients/clients/__tests__/opencode.test.ts b/src/store/services/steps/add-mcp-server-to-clients/clients/__tests__/opencode.test.ts similarity index 98% rename from src/steps/add-mcp-server-to-clients/clients/__tests__/opencode.test.ts rename to src/store/services/steps/add-mcp-server-to-clients/clients/__tests__/opencode.test.ts index 3b20c6b22..1cb1a225d 100644 --- a/src/steps/add-mcp-server-to-clients/clients/__tests__/opencode.test.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/clients/__tests__/opencode.test.ts @@ -1,4 +1,4 @@ -import { OpenCodeMCPClient } from '@steps/add-mcp-server-to-clients/clients/opencode'; +import { OpenCodeMCPClient } from '../opencode.js'; import { execSync } from 'node:child_process'; import * as fs from 'node:fs'; import * as os from 'node:os'; @@ -28,7 +28,7 @@ vi.mock('@env', () => ({ runtimeEnv: vi.fn(), })); -vi.mock('@utils/debug', () => ({ +vi.mock('../../../../../shared/debug.js', () => ({ debug: vi.fn(), })); diff --git a/src/steps/add-mcp-server-to-clients/clients/claude-code.ts b/src/store/services/steps/add-mcp-server-to-clients/clients/claude-code.ts similarity index 93% rename from src/steps/add-mcp-server-to-clients/clients/claude-code.ts rename to src/store/services/steps/add-mcp-server-to-clients/clients/claude-code.ts index 2374a2163..2ccd6c05a 100644 --- a/src/steps/add-mcp-server-to-clients/clients/claude-code.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/clients/claude-code.ts @@ -1,21 +1,12 @@ -import { DefaultMCPClient } from '@steps/add-mcp-server-to-clients/MCPClient'; -import { - DefaultMCPClientConfig, - buildMCPUrl, -} from '@steps/add-mcp-server-to-clients/defaults'; -import { - PluginCapable, - PluginInstallResult, -} from '@steps/add-mcp-server-to-clients/plugin-client'; -import { - redactSecrets, - type InstallResult, -} from '@steps/add-mcp-server-to-clients/results'; -import { LoginCapable } from '@steps/add-mcp-server-to-clients/login-client'; +import { DefaultMCPClient } from '../MCPClient.js'; +import { DefaultMCPClientConfig, buildMCPUrl } from '../defaults.js'; +import { PluginCapable, PluginInstallResult } from '../plugin-client.js'; +import { redactSecrets, type InstallResult } from '../results.js'; +import { LoginCapable } from '../login-client.js'; import { z } from 'zod'; import { execSync } from 'child_process'; -import { analytics } from '@utils/analytics'; -import { debug } from '@utils/debug'; +import { analytics } from '../../../../shared/analytics.js'; +import { debug } from '../../../../shared/debug.js'; import * as os from 'os'; import * as path from 'path'; import * as fs from 'fs'; diff --git a/src/steps/add-mcp-server-to-clients/clients/claude-web.ts b/src/store/services/steps/add-mcp-server-to-clients/clients/claude-web.ts similarity index 85% rename from src/steps/add-mcp-server-to-clients/clients/claude-web.ts rename to src/store/services/steps/add-mcp-server-to-clients/clients/claude-web.ts index 2e34d779e..4c8891bb1 100644 --- a/src/steps/add-mcp-server-to-clients/clients/claude-web.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/clients/claude-web.ts @@ -1,7 +1,7 @@ -import { MCPClient } from '@steps/add-mcp-server-to-clients/MCPClient'; -import type { InstallResult } from '@steps/add-mcp-server-to-clients/results'; -import { BrowserFinishable } from '@steps/add-mcp-server-to-clients/browser-client'; -import { openTrackedLink } from '@utils/links'; +import { MCPClient } from '../MCPClient.js'; +import type { InstallResult } from '../results.js'; +import { BrowserFinishable } from '../browser-client.js'; +import { openTrackedLink } from '../../../../shared/links.js'; /** * Claude Desktop / Claude.ai (web). PostHog ships here as a hosted connector, diff --git a/src/steps/add-mcp-server-to-clients/clients/claude.ts b/src/store/services/steps/add-mcp-server-to-clients/clients/claude.ts similarity index 87% rename from src/steps/add-mcp-server-to-clients/clients/claude.ts rename to src/store/services/steps/add-mcp-server-to-clients/clients/claude.ts index f7db763f5..e852b886f 100644 --- a/src/steps/add-mcp-server-to-clients/clients/claude.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/clients/claude.ts @@ -1,7 +1,7 @@ -import { DefaultMCPClient } from '@steps/add-mcp-server-to-clients/MCPClient'; +import { DefaultMCPClient } from '../MCPClient.js'; import * as path from 'path'; import * as os from 'os'; -import { DefaultMCPClientConfig } from '@steps/add-mcp-server-to-clients/defaults'; +import { DefaultMCPClientConfig } from '../defaults.js'; import { runtimeEnv } from '@env'; import { z } from 'zod'; diff --git a/src/steps/add-mcp-server-to-clients/clients/codex.ts b/src/store/services/steps/add-mcp-server-to-clients/clients/codex.ts similarity index 95% rename from src/steps/add-mcp-server-to-clients/clients/codex.ts rename to src/store/services/steps/add-mcp-server-to-clients/clients/codex.ts index e4020d54b..4ef98a7c8 100644 --- a/src/steps/add-mcp-server-to-clients/clients/codex.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/clients/codex.ts @@ -4,22 +4,13 @@ import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path'; -import { LoginCapable } from '@steps/add-mcp-server-to-clients/login-client'; -import { DefaultMCPClient } from '@steps/add-mcp-server-to-clients/MCPClient'; -import { - DefaultMCPClientConfig, - buildMCPUrl, -} from '@steps/add-mcp-server-to-clients/defaults'; -import { - PluginCapable, - PluginInstallResult, -} from '@steps/add-mcp-server-to-clients/plugin-client'; -import { - redactSecrets, - type InstallResult, -} from '@steps/add-mcp-server-to-clients/results'; - -import { analytics } from '@utils/analytics'; +import { LoginCapable } from '../login-client.js'; +import { DefaultMCPClient } from '../MCPClient.js'; +import { DefaultMCPClientConfig, buildMCPUrl } from '../defaults.js'; +import { PluginCapable, PluginInstallResult } from '../plugin-client.js'; +import { redactSecrets, type InstallResult } from '../results.js'; + +import { analytics } from '../../../../shared/analytics.js'; /** Wording codex uses when the thing we're adding is already registered. */ const ALREADY_INSTALLED_PATTERN = diff --git a/src/steps/add-mcp-server-to-clients/clients/cursor.ts b/src/store/services/steps/add-mcp-server-to-clients/clients/cursor.ts similarity index 85% rename from src/steps/add-mcp-server-to-clients/clients/cursor.ts rename to src/store/services/steps/add-mcp-server-to-clients/clients/cursor.ts index c13d18c12..594ff9e6d 100644 --- a/src/steps/add-mcp-server-to-clients/clients/cursor.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/clients/cursor.ts @@ -1,13 +1,10 @@ -import { - DefaultMCPClient, - MCPServerConfig, -} from '@steps/add-mcp-server-to-clients/MCPClient'; +import { DefaultMCPClient, MCPServerConfig } from '../MCPClient.js'; import * as path from 'path'; import * as os from 'os'; import { DefaultMCPClientConfig, getNativeHTTPServerConfig, -} from '@steps/add-mcp-server-to-clients/defaults'; +} from '../defaults.js'; import { z } from 'zod'; export const CursorMCPConfig = DefaultMCPClientConfig; diff --git a/src/steps/add-mcp-server-to-clients/clients/opencode.ts b/src/store/services/steps/add-mcp-server-to-clients/clients/opencode.ts similarity index 91% rename from src/steps/add-mcp-server-to-clients/clients/opencode.ts rename to src/store/services/steps/add-mcp-server-to-clients/clients/opencode.ts index a6485dbe3..9890ebda8 100644 --- a/src/steps/add-mcp-server-to-clients/clients/opencode.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/clients/opencode.ts @@ -3,11 +3,8 @@ import * as path from 'path'; import * as os from 'os'; import * as fs from 'fs'; import { execSync } from 'node:child_process'; -import { - DefaultMCPClient, - MCPServerConfig, -} from '@steps/add-mcp-server-to-clients/MCPClient'; -import { getNativeHTTPServerConfig } from '@steps/add-mcp-server-to-clients/defaults'; +import { DefaultMCPClient, MCPServerConfig } from '../MCPClient.js'; +import { getNativeHTTPServerConfig } from '../defaults.js'; import { runtimeEnv } from '@env'; export const OpenCodeMCPConfig = z diff --git a/src/steps/add-mcp-server-to-clients/clients/visual-studio-code.ts b/src/store/services/steps/add-mcp-server-to-clients/clients/visual-studio-code.ts similarity index 91% rename from src/steps/add-mcp-server-to-clients/clients/visual-studio-code.ts rename to src/store/services/steps/add-mcp-server-to-clients/clients/visual-studio-code.ts index 4c82ded04..398933b2b 100644 --- a/src/steps/add-mcp-server-to-clients/clients/visual-studio-code.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/clients/visual-studio-code.ts @@ -1,11 +1,8 @@ import z from 'zod'; import * as path from 'path'; import * as os from 'os'; -import { - DefaultMCPClient, - MCPServerConfig, -} from '@steps/add-mcp-server-to-clients/MCPClient'; -import { getNativeHTTPServerConfig } from '@steps/add-mcp-server-to-clients/defaults'; +import { DefaultMCPClient, MCPServerConfig } from '../MCPClient.js'; +import { getNativeHTTPServerConfig } from '../defaults.js'; import { runtimeEnv } from '@env'; export const VisualStudioCodeMCPConfig = z diff --git a/src/steps/add-mcp-server-to-clients/clients/zed.ts b/src/store/services/steps/add-mcp-server-to-clients/clients/zed.ts similarity index 91% rename from src/steps/add-mcp-server-to-clients/clients/zed.ts rename to src/store/services/steps/add-mcp-server-to-clients/clients/zed.ts index cfd0a7667..ef80bd777 100644 --- a/src/steps/add-mcp-server-to-clients/clients/zed.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/clients/zed.ts @@ -1,11 +1,8 @@ import z from 'zod'; import * as path from 'path'; import * as os from 'os'; -import { - DefaultMCPClient, - MCPServerConfig, -} from '@steps/add-mcp-server-to-clients/MCPClient'; -import { getNativeHTTPServerConfig } from '@steps/add-mcp-server-to-clients/defaults'; +import { DefaultMCPClient, MCPServerConfig } from '../MCPClient.js'; +import { getNativeHTTPServerConfig } from '../defaults.js'; import { runtimeEnv } from '@env'; export const ZedMCPConfig = z diff --git a/src/steps/add-mcp-server-to-clients/defaults.ts b/src/store/services/steps/add-mcp-server-to-clients/defaults.ts similarity index 100% rename from src/steps/add-mcp-server-to-clients/defaults.ts rename to src/store/services/steps/add-mcp-server-to-clients/defaults.ts diff --git a/src/steps/add-mcp-server-to-clients/index.ts b/src/store/services/steps/add-mcp-server-to-clients/index.ts similarity index 91% rename from src/steps/add-mcp-server-to-clients/index.ts rename to src/store/services/steps/add-mcp-server-to-clients/index.ts index 9dfcd10ee..12703d866 100644 --- a/src/steps/add-mcp-server-to-clients/index.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/index.ts @@ -1,25 +1,25 @@ -import type { Integration } from '@lib/constants'; -import type { CloudRegion } from '@utils/types'; -import { withProgress } from '../../telemetry'; -import { analytics } from '@utils/analytics'; -import { getUI } from '@ui'; -import { MCPClient } from './MCPClient'; -import { CursorMCPClient } from './clients/cursor'; -import { ClaudeCodeMCPClient } from './clients/claude-code'; -import { ClaudeWebMCPClient } from './clients/claude-web'; -import { VisualStudioCodeClient } from './clients/visual-studio-code'; -import { ZedClient } from './clients/zed'; -import { CodexMCPClient } from './clients/codex'; -import { OpenCodeMCPClient } from './clients/opencode'; -import { ALL_FEATURE_VALUES } from './defaults'; -import { debug } from '@utils/debug'; -import { isPluginCapable, PluginCapable } from './plugin-client'; +import type { Integration } from '../../../shared/constants.js'; +import type { CloudRegion } from '../../../shared/types.js'; +import { withProgress } from '@cli/telemetry'; +import { analytics } from '../../../shared/analytics.js'; +import { getUI } from '../../../ui/index.js'; +import { MCPClient } from './MCPClient.js'; +import { CursorMCPClient } from './clients/cursor.js'; +import { ClaudeCodeMCPClient } from './clients/claude-code.js'; +import { ClaudeWebMCPClient } from './clients/claude-web.js'; +import { VisualStudioCodeClient } from './clients/visual-studio-code.js'; +import { ZedClient } from './clients/zed.js'; +import { CodexMCPClient } from './clients/codex.js'; +import { OpenCodeMCPClient } from './clients/opencode.js'; +import { ALL_FEATURE_VALUES } from './defaults.js'; +import { debug } from '../../../shared/debug.js'; +import { isPluginCapable, PluginCapable } from './plugin-client.js'; import { McpClientStatus, namesWithStatus, toClientResult, type McpClientResult, -} from './results'; +} from './results.js'; export const getSupportedClients = async (): Promise => { const allClients = [ diff --git a/src/steps/add-mcp-server-to-clients/login-client.ts b/src/store/services/steps/add-mcp-server-to-clients/login-client.ts similarity index 100% rename from src/steps/add-mcp-server-to-clients/login-client.ts rename to src/store/services/steps/add-mcp-server-to-clients/login-client.ts diff --git a/src/steps/add-mcp-server-to-clients/plugin-client.ts b/src/store/services/steps/add-mcp-server-to-clients/plugin-client.ts similarity index 93% rename from src/steps/add-mcp-server-to-clients/plugin-client.ts rename to src/store/services/steps/add-mcp-server-to-clients/plugin-client.ts index ea2a0459f..41c308873 100644 --- a/src/steps/add-mcp-server-to-clients/plugin-client.ts +++ b/src/store/services/steps/add-mcp-server-to-clients/plugin-client.ts @@ -1,4 +1,4 @@ -import type { InstallResult } from './results'; +import type { InstallResult } from './results.js'; export type PluginInstallResult = InstallResult; diff --git a/src/steps/add-mcp-server-to-clients/results.ts b/src/store/services/steps/add-mcp-server-to-clients/results.ts similarity index 100% rename from src/steps/add-mcp-server-to-clients/results.ts rename to src/store/services/steps/add-mcp-server-to-clients/results.ts diff --git a/src/steps/add-or-update-environment-variables.ts b/src/store/services/steps/add-or-update-environment-variables.ts similarity index 95% rename from src/steps/add-or-update-environment-variables.ts rename to src/store/services/steps/add-or-update-environment-variables.ts index 67787dfa8..36e61694d 100644 --- a/src/steps/add-or-update-environment-variables.ts +++ b/src/store/services/steps/add-or-update-environment-variables.ts @@ -1,8 +1,8 @@ -import type { Integration } from '@lib/constants'; -import { withProgress } from '../telemetry'; -import { analytics } from '@utils/analytics'; -import { getUI } from '@ui'; -import { getDotGitignore } from '@utils/bounded-fs'; +import type { Integration } from '../../shared/constants.js'; +import { withProgress } from '@cli/telemetry'; +import { analytics } from '../../shared/analytics.js'; +import { getUI } from '../../ui/index.js'; +import { getDotGitignore } from '../../shared/bounded-fs.js'; import * as fs from 'fs'; import path from 'path'; diff --git a/src/store/services/steps/index.ts b/src/store/services/steps/index.ts new file mode 100644 index 000000000..a957338de --- /dev/null +++ b/src/store/services/steps/index.ts @@ -0,0 +1,4 @@ +export * from './run-prettier.js'; +export * from './add-or-update-environment-variables.js'; +export * from './add-mcp-server-to-clients/index.js'; +export * from './upload-environment-variables/index.js'; diff --git a/src/steps/install-cli-steering/__tests__/install-cli-steering.test.ts b/src/store/services/steps/install-cli-steering/__tests__/install-cli-steering.test.ts similarity index 98% rename from src/steps/install-cli-steering/__tests__/install-cli-steering.test.ts rename to src/store/services/steps/install-cli-steering/__tests__/install-cli-steering.test.ts index 19a0b9c8f..4acaf4335 100644 --- a/src/steps/install-cli-steering/__tests__/install-cli-steering.test.ts +++ b/src/store/services/steps/install-cli-steering/__tests__/install-cli-steering.test.ts @@ -10,9 +10,9 @@ import { findTarget, installOrUpdatePostHogCli, installSteeringSnippet, -} from '@steps/install-cli-steering'; +} from '../index.js'; -vi.mock('../../../utils/debug'); +vi.mock('../../../../shared/debug.js'); vi.mock('node:child_process', () => ({ spawnSync: vi.fn(), })); diff --git a/src/steps/install-cli-steering/index.ts b/src/store/services/steps/install-cli-steering/index.ts similarity index 98% rename from src/steps/install-cli-steering/index.ts rename to src/store/services/steps/install-cli-steering/index.ts index 45e133219..f594a6f41 100644 --- a/src/steps/install-cli-steering/index.ts +++ b/src/store/services/steps/install-cli-steering/index.ts @@ -3,7 +3,7 @@ import * as fs from 'node:fs'; import * as os from 'node:os'; import * as path from 'node:path'; -import { debug } from '@utils/debug'; +import { debug } from '../../../shared/debug.js'; /** * A coding agent whose global instructions file the PostHog CLI steering diff --git a/src/steps/run-prettier.ts b/src/store/services/steps/run-prettier.ts similarity index 83% rename from src/steps/run-prettier.ts rename to src/store/services/steps/run-prettier.ts index 61a4d165e..99187f68c 100644 --- a/src/steps/run-prettier.ts +++ b/src/store/services/steps/run-prettier.ts @@ -1,14 +1,14 @@ -import type { Integration } from '@lib/constants'; -import { withProgress } from '../telemetry'; -import { analytics } from '@utils/analytics'; -import { getUI } from '@ui'; +import type { Integration } from '../../shared/constants.js'; +import { withProgress } from '@cli/telemetry'; +import { analytics } from '../../shared/analytics.js'; +import { getUI } from '../../ui/index.js'; import { tryGetPackageJson, getUncommittedOrUntrackedFiles, isInGitRepo, -} from '@utils/setup-utils'; -import { hasDeclaredDependency } from '@utils/package-json'; -import type { WizardRunOptions } from '@utils/types'; +} from '../../shared/setup-utils.js'; +import { hasDeclaredDependency } from '../../shared/package-json.js'; +import type { WizardRunOptions } from '../../shared/types.js'; import * as childProcess from 'node:child_process'; export async function runPrettierStep({ diff --git a/src/steps/upload-environment-variables/EnvironmentProvider.ts b/src/store/services/steps/upload-environment-variables/EnvironmentProvider.ts similarity index 100% rename from src/steps/upload-environment-variables/EnvironmentProvider.ts rename to src/store/services/steps/upload-environment-variables/EnvironmentProvider.ts diff --git a/src/steps/upload-environment-variables/index.ts b/src/store/services/steps/upload-environment-variables/index.ts similarity index 72% rename from src/steps/upload-environment-variables/index.ts rename to src/store/services/steps/upload-environment-variables/index.ts index 3a15081b7..cd3f1f73e 100644 --- a/src/steps/upload-environment-variables/index.ts +++ b/src/store/services/steps/upload-environment-variables/index.ts @@ -1,10 +1,10 @@ -import type { Integration } from '@lib/constants'; -import { withProgress } from '../../telemetry'; -import { analytics } from '@utils/analytics'; -import { getUI } from '@ui'; -import type { WizardSession } from '@lib/wizard-session'; -import { EnvironmentProvider } from './EnvironmentProvider'; -import { VercelEnvironmentProvider } from './providers/vercel'; +import type { Integration } from '../../../shared/constants.js'; +import { withProgress } from '@cli/telemetry'; +import { analytics } from '../../../shared/analytics.js'; +import { getUI } from '../../../ui/index.js'; +import type { WizardSession } from '../../../session/wizard-session.js'; +import { EnvironmentProvider } from './EnvironmentProvider.js'; +import { VercelEnvironmentProvider } from './providers/vercel.js'; export const uploadEnvironmentVariablesStep = async ( envVars: Record, diff --git a/src/steps/upload-environment-variables/providers/__tests__/vercel.test.ts b/src/store/services/steps/upload-environment-variables/providers/__tests__/vercel.test.ts similarity index 96% rename from src/steps/upload-environment-variables/providers/__tests__/vercel.test.ts rename to src/store/services/steps/upload-environment-variables/providers/__tests__/vercel.test.ts index 97c8f73b1..16a3efafa 100644 --- a/src/steps/upload-environment-variables/providers/__tests__/vercel.test.ts +++ b/src/store/services/steps/upload-environment-variables/providers/__tests__/vercel.test.ts @@ -1,4 +1,4 @@ -import { VercelEnvironmentProvider } from '@steps/upload-environment-variables/providers/vercel'; +import { VercelEnvironmentProvider } from '../vercel.js'; import * as fs from 'fs'; import * as child_process from 'child_process'; diff --git a/src/steps/upload-environment-variables/providers/vercel.ts b/src/store/services/steps/upload-environment-variables/providers/vercel.ts similarity index 95% rename from src/steps/upload-environment-variables/providers/vercel.ts rename to src/store/services/steps/upload-environment-variables/providers/vercel.ts index 3279f6ec1..4f10e007b 100644 --- a/src/steps/upload-environment-variables/providers/vercel.ts +++ b/src/store/services/steps/upload-environment-variables/providers/vercel.ts @@ -1,9 +1,9 @@ import { execSync, spawn, spawnSync } from 'child_process'; -import { EnvironmentProvider } from '@steps/upload-environment-variables/EnvironmentProvider'; +import { EnvironmentProvider } from '../EnvironmentProvider.js'; import * as fs from 'fs'; import * as path from 'path'; -import { getUI } from '@ui'; -import { analytics } from '@utils/analytics'; +import { getUI } from '../../../../ui/index.js'; +import { analytics } from '../../../../shared/analytics.js'; export class VercelEnvironmentProvider extends EnvironmentProvider { name = 'Vercel'; diff --git a/src/lib/warehouse-sources/__tests__/detect.test.ts b/src/store/services/warehouse-sources/__tests__/detect.test.ts similarity index 99% rename from src/lib/warehouse-sources/__tests__/detect.test.ts rename to src/store/services/warehouse-sources/__tests__/detect.test.ts index 341756363..c40b05a1d 100644 --- a/src/lib/warehouse-sources/__tests__/detect.test.ts +++ b/src/store/services/warehouse-sources/__tests__/detect.test.ts @@ -5,9 +5,9 @@ import { detectWarehouseSources, parseGemfile, parseEnvKeys, -} from '@lib/warehouse-sources/detect'; -import { MAX_REPORTED_PATH_LENGTH } from '@utils/env-scan'; -import { SOURCE_DETECTORS } from '@lib/warehouse-sources/registry'; +} from '../detect.js'; +import { MAX_REPORTED_PATH_LENGTH } from '../../../shared/env-scan.js'; +import { SOURCE_DETECTORS } from '../registry.js'; function makeTmpDir(): string { return fs.mkdtempSync(path.join(os.tmpdir(), 'warehouse-detect-')); diff --git a/src/lib/warehouse-sources/detect.ts b/src/store/services/warehouse-sources/detect.ts similarity index 95% rename from src/lib/warehouse-sources/detect.ts rename to src/store/services/warehouse-sources/detect.ts index 2153a9a69..720b4d65d 100644 --- a/src/lib/warehouse-sources/detect.ts +++ b/src/store/services/warehouse-sources/detect.ts @@ -9,21 +9,21 @@ * Note we only read `.env` KEY NAMES, never values. */ -import { analytics } from '@utils/analytics'; -import { walkProjectFiles, safeReadFile } from '@utils/bounded-fs'; +import { analytics } from '../../shared/analytics.js'; +import { walkProjectFiles, safeReadFile } from '../../shared/bounded-fs.js'; import { ENV_SCAN_MAX_DEPTH, MAX_ENV_KEY_SET, isEnvFileName, parseEnvKeyNames, toPromptSafeRelativePath, -} from '@utils/env-scan'; -import type { PackageJson } from '@utils/package-json'; +} from '../../shared/env-scan.js'; +import type { PackageJson } from '../../shared/package-json.js'; import { parseRequirementsTxt, parsePyprojectToml, parsePipfile, -} from '@lib/detection/features'; +} from '../../detection/features.js'; import { SOURCE_DETECTORS } from './registry.js'; import type { DetectedSource, SourceDetector } from './types.js'; @@ -222,4 +222,4 @@ export function parseGemfile(content: string): string[] { * Re-exported from `@utils/env-scan`, which `check_env_keys` shares, so the * detector and the tool cannot disagree about what counts as a key. */ -export { parseEnvKeyNames as parseEnvKeys } from '@utils/env-scan'; +export { parseEnvKeyNames as parseEnvKeys } from '../../shared/env-scan.js'; diff --git a/src/lib/warehouse-sources/registry.ts b/src/store/services/warehouse-sources/registry.ts similarity index 100% rename from src/lib/warehouse-sources/registry.ts rename to src/store/services/warehouse-sources/registry.ts diff --git a/src/lib/warehouse-sources/types.ts b/src/store/services/warehouse-sources/types.ts similarity index 100% rename from src/lib/warehouse-sources/types.ts rename to src/store/services/warehouse-sources/types.ts diff --git a/src/lib/ask-policy.ts b/src/store/session/ask-policy.ts similarity index 94% rename from src/lib/ask-policy.ts rename to src/store/session/ask-policy.ts index c0b55652d..cad3ded1c 100644 --- a/src/lib/ask-policy.ts +++ b/src/store/session/ask-policy.ts @@ -1,4 +1,4 @@ -import type { WizardSession } from '@lib/wizard-session'; +import type { WizardSession } from './wizard-session.js'; /** * Decide whether the `wizard_ask` overlay should be wired for this run. diff --git a/src/lib/secret-vault.ts b/src/store/session/secret-vault.ts similarity index 100% rename from src/lib/secret-vault.ts rename to src/store/session/secret-vault.ts diff --git a/src/lib/wizard-ask-bridge.ts b/src/store/session/wizard-ask-bridge.ts similarity index 98% rename from src/lib/wizard-ask-bridge.ts rename to src/store/session/wizard-ask-bridge.ts index 93b06cefa..723327136 100644 --- a/src/lib/wizard-ask-bridge.ts +++ b/src/store/session/wizard-ask-bridge.ts @@ -12,12 +12,12 @@ */ import { randomUUID } from 'crypto'; -import { analytics } from '@utils/analytics'; +import { analytics } from '../shared/analytics.js'; import type { AskAnswers, AskQuestion, PendingQuestion, -} from './wizard-session'; +} from './wizard-session.js'; export interface WizardAskRequest { questions: AskQuestion[]; diff --git a/src/lib/wizard-session.ts b/src/store/session/wizard-session.ts similarity index 97% rename from src/lib/wizard-session.ts rename to src/store/session/wizard-session.ts index bee8c8de9..3252f8760 100644 --- a/src/lib/wizard-session.ts +++ b/src/store/session/wizard-session.ts @@ -10,13 +10,13 @@ * Business logic reads from the session. Never calls a prompt. */ -import { POSTHOG_LOCAL_URL, resolveLocalDev } from './local-dev'; -import type { Harness, Integration, Sequence } from './constants'; -import type { FrameworkConfig } from './framework-config'; -import type { WizardReadinessResult } from './health-checks/readiness'; -import type { SettingsConflict } from './claude-settings'; -import type { ApiUser, ApiProject } from './api'; -import type { HostResolution } from './host-resolution'; +import { POSTHOG_LOCAL_URL, resolveLocalDev } from '../local-dev.js'; +import type { Harness, Integration, Sequence } from '../shared/constants.js'; +import type { FrameworkConfig } from '../framework-config.js'; +import type { WizardReadinessResult } from '../health-checks/readiness.js'; +import type { SettingsConflict } from '../services/claude-settings.js'; +import type { ApiUser, ApiProject } from '../api.js'; +import type { HostResolution } from '../host-resolution.js'; export interface Credentials { accessToken: string; @@ -130,7 +130,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/index.js').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/utils/__fixtures__/provisioning.ts b/src/store/shared/__fixtures__/provisioning.ts similarity index 100% rename from src/utils/__fixtures__/provisioning.ts rename to src/store/shared/__fixtures__/provisioning.ts diff --git a/src/utils/__tests__/analytics.test.ts b/src/store/shared/__tests__/analytics.test.ts similarity index 99% rename from src/utils/__tests__/analytics.test.ts rename to src/store/shared/__tests__/analytics.test.ts index 347424ec1..a9e38f3dd 100644 --- a/src/utils/__tests__/analytics.test.ts +++ b/src/store/shared/__tests__/analytics.test.ts @@ -1,14 +1,14 @@ -import { Analytics, groupsFromUser, sessionProperties } from '@utils/analytics'; +import { Analytics, groupsFromUser, sessionProperties } from '../analytics.js'; 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 '../constants.js'; +import { VERSION } from '../version.js'; +import type { ApiUser } from '../../api.js'; import { buildSession, DiscoveredFeature, ScanConsent, -} from '@lib/wizard-session'; +} from '../../session/wizard-session.js'; vi.mock('posthog-node'); vi.mock('uuid'); diff --git a/src/utils/__tests__/bounded-fs-walk.test.ts b/src/store/shared/__tests__/bounded-fs-walk.test.ts similarity index 89% rename from src/utils/__tests__/bounded-fs-walk.test.ts rename to src/store/shared/__tests__/bounded-fs-walk.test.ts index c9ddeb512..4ec1390d6 100644 --- a/src/utils/__tests__/bounded-fs-walk.test.ts +++ b/src/store/shared/__tests__/bounded-fs-walk.test.ts @@ -1,12 +1,12 @@ import fs from 'fs'; -import { walkProjectFiles, safeReadFile } from '@utils/bounded-fs'; -import { analytics } from '@utils/analytics'; -import { logToFile } from '@utils/debug'; +import { walkProjectFiles, safeReadFile } from '../bounded-fs.js'; +import { analytics } from '../analytics.js'; +import { logToFile } from '../debug.js'; -vi.mock('../analytics', () => ({ +vi.mock('../analytics.js', () => ({ analytics: { captureException: vi.fn() }, })); -vi.mock('../debug', () => ({ logToFile: vi.fn() })); +vi.mock('../debug.js', () => ({ logToFile: vi.fn() })); const captureException = analytics.captureException as ReturnType; const mockLogToFile = logToFile as ReturnType; diff --git a/src/utils/__tests__/bounded-fs.test.ts b/src/store/shared/__tests__/bounded-fs.test.ts similarity index 99% rename from src/utils/__tests__/bounded-fs.test.ts rename to src/store/shared/__tests__/bounded-fs.test.ts index 99fa0f0a7..d7d859c30 100644 --- a/src/utils/__tests__/bounded-fs.test.ts +++ b/src/store/shared/__tests__/bounded-fs.test.ts @@ -6,7 +6,7 @@ import { readFileHead, readProjectFile, MAX_GLOB_MATCHES, -} from '@utils/bounded-fs'; +} from '../bounded-fs.js'; describe('boundedGlob', () => { let dir: string; diff --git a/src/utils/__tests__/ci-flag-overrides.test.ts b/src/store/shared/__tests__/ci-flag-overrides.test.ts similarity index 94% rename from src/utils/__tests__/ci-flag-overrides.test.ts rename to src/store/shared/__tests__/ci-flag-overrides.test.ts index ff6f78876..a24df2668 100644 --- a/src/utils/__tests__/ci-flag-overrides.test.ts +++ b/src/store/shared/__tests__/ci-flag-overrides.test.ts @@ -1,9 +1,9 @@ import { applyCiFlagOverrides, ciExcludedTaskTypes, -} from '@utils/ci-flag-overrides'; +} from '../ci-flag-overrides.js'; -vi.mock('@utils/debug', () => ({ +vi.mock('../debug.js', () => ({ logToFile: vi.fn(), debug: vi.fn(), })); @@ -72,7 +72,7 @@ describe('applyCiFlagOverrides', () => { // Re-import fresh so the module re-reads NODE_ENV at load time (the // vitest equivalent of jest.isolateModules). vi.resetModules(); - const prod = (await import('@utils/ci-flag-overrides')) as { + const prod = (await import('../ci-flag-overrides.js')) as { applyCiFlagOverrides: typeof applyCiFlagOverrides; }; const result = prod.applyCiFlagOverrides({ @@ -108,7 +108,7 @@ describe('ciExcludedTaskTypes', () => { // Re-import fresh so the module re-reads NODE_ENV at load time (the // vitest equivalent of jest.isolateModules). vi.resetModules(); - const prod = (await import('@utils/ci-flag-overrides')) as { + const prod = (await import('../ci-flag-overrides.js')) as { ciExcludedTaskTypes: typeof ciExcludedTaskTypes; }; const result = prod.ciExcludedTaskTypes(); diff --git a/src/utils/__tests__/ci-region.test.ts b/src/store/shared/__tests__/ci-region.test.ts similarity index 90% rename from src/utils/__tests__/ci-region.test.ts rename to src/store/shared/__tests__/ci-region.test.ts index d174852a5..bb5355299 100644 --- a/src/utils/__tests__/ci-region.test.ts +++ b/src/store/shared/__tests__/ci-region.test.ts @@ -1,32 +1,32 @@ -import { getOrAskForProjectData } from '@utils/setup-utils'; -import { detectRegion } from '@utils/urls'; -import { fetchProjectData, fetchUserData } from '@lib/api'; -import { performOAuthFlow } from '@utils/oauth'; +import { getOrAskForProjectData } from '../setup-utils.js'; +import { detectRegion } from '../urls.js'; +import { fetchProjectData, fetchUserData } from '../../api.js'; +import { performOAuthFlow } from '../oauth.js'; -vi.mock('@ui', () => ({ +vi.mock('../../ui/index.js', () => ({ getUI: () => ({ log: { info: vi.fn(), error: vi.fn(), success: vi.fn(), warn: vi.fn() }, }), })); -vi.mock('@utils/urls', () => ({ +vi.mock('../urls.js', () => ({ detectRegion: vi.fn(), getHost: (r: string) => `https://${r}.posthog.com`, getCloudUrl: (r: string) => `https://${r}.posthog.com`, getUiHostFromHost: (host: string) => host, resolveBaseUrl: (baseUrl?: string) => baseUrl, })); -vi.mock('@lib/api', () => ({ +vi.mock('../../api.js', () => ({ fetchProjectData: vi.fn(), fetchUserData: vi.fn(), })); -vi.mock('@utils/analytics', () => ({ +vi.mock('../analytics.js', () => ({ analytics: { identifyUser: vi.fn(), captureException: vi.fn(), setTag: vi.fn(), }, })); -vi.mock('@utils/oauth', () => ({ +vi.mock('../oauth.js', () => ({ performOAuthFlow: vi.fn(), assertWizardCompletionScope: vi.fn(), missingOAuthScopes: vi.fn(() => []), diff --git a/src/utils/__tests__/debug.test.ts b/src/store/shared/__tests__/debug.test.ts similarity index 98% rename from src/utils/__tests__/debug.test.ts rename to src/store/shared/__tests__/debug.test.ts index 31ab68581..f71202caa 100644 --- a/src/utils/__tests__/debug.test.ts +++ b/src/store/shared/__tests__/debug.test.ts @@ -6,7 +6,7 @@ import { getLogFilePath, initLogFile, logToFile, -} from '@utils/debug'; +} from '../debug.js'; describe('log file writing', () => { const originalPath = getLogFilePath(); diff --git a/src/utils/__tests__/env-api-key.test.ts b/src/store/shared/__tests__/env-api-key.test.ts similarity index 93% rename from src/utils/__tests__/env-api-key.test.ts rename to src/store/shared/__tests__/env-api-key.test.ts index a3a192c2b..60e9ec725 100644 --- a/src/utils/__tests__/env-api-key.test.ts +++ b/src/store/shared/__tests__/env-api-key.test.ts @@ -1,7 +1,7 @@ import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -import { readApiKeyFromEnv } from '@utils/env-api-key'; +import { readApiKeyFromEnv } from '../env-api-key.js'; describe('readApiKeyFromEnv', () => { let dir: string; diff --git a/src/utils/__tests__/env-scan.test.ts b/src/store/shared/__tests__/env-scan.test.ts similarity index 99% rename from src/utils/__tests__/env-scan.test.ts rename to src/store/shared/__tests__/env-scan.test.ts index 4d03d8f90..1d31dec8c 100644 --- a/src/utils/__tests__/env-scan.test.ts +++ b/src/store/shared/__tests__/env-scan.test.ts @@ -12,7 +12,7 @@ import { toPromptSafeRelativePath, toRelativePosixPath, type EnvKeyLocations, -} from '@utils/env-scan'; +} from '../env-scan.js'; function makeTmpDir(): string { return fs.mkdtempSync(path.join(os.tmpdir(), 'env-scan-')); diff --git a/src/utils/__tests__/environment.test.ts b/src/store/shared/__tests__/environment.test.ts similarity index 92% rename from src/utils/__tests__/environment.test.ts rename to src/store/shared/__tests__/environment.test.ts index 7938c399c..6de7b391c 100644 --- a/src/utils/__tests__/environment.test.ts +++ b/src/store/shared/__tests__/environment.test.ts @@ -8,9 +8,9 @@ * a run with nobody to answer. */ -import { readEnvironment } from '@utils/environment'; -import { buildSession } from '@lib/wizard-session'; -import { shouldDisableAsk } from '@lib/agent/agent-runner'; +import { readEnvironment } from '../environment.js'; +import { buildSession } from '../../session/wizard-session.js'; +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/store/shared/__tests__/links.test.ts similarity index 96% rename from src/utils/__tests__/links.test.ts rename to src/store/shared/__tests__/links.test.ts index 537aac2a4..123790e19 100644 --- a/src/utils/__tests__/links.test.ts +++ b/src/store/shared/__tests__/links.test.ts @@ -1,4 +1,4 @@ -import { withUtm } from '../links'; +import { withUtm } from '../links.js'; describe('withUtm', () => { it('tags a URL with the wizard UTM params and no campaign', () => { diff --git a/src/utils/__tests__/oauth-errors.test.ts b/src/store/shared/__tests__/oauth-errors.test.ts similarity index 99% rename from src/utils/__tests__/oauth-errors.test.ts rename to src/store/shared/__tests__/oauth-errors.test.ts index 5e0068245..2b6d9f28b 100644 --- a/src/utils/__tests__/oauth-errors.test.ts +++ b/src/store/shared/__tests__/oauth-errors.test.ts @@ -6,12 +6,12 @@ import { oauthErrorFromCallbackParams, oauthErrorFromTokenBody, sanitizeOAuthParam, -} from '@utils/oauth-errors'; +} from '../oauth-errors.js'; import { ISSUES_URL, POSTHOG_STATUS_PAGE_URL, WIZARD_CONTACT_EMAIL, -} from '@lib/constants'; +} from '../constants.js'; 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/store/shared/__tests__/oauth-refresh.test.ts similarity index 83% rename from src/utils/__tests__/oauth-refresh.test.ts rename to src/store/shared/__tests__/oauth-refresh.test.ts index 94e775287..185c1f82a 100644 --- a/src/utils/__tests__/oauth-refresh.test.ts +++ b/src/store/shared/__tests__/oauth-refresh.test.ts @@ -1,14 +1,14 @@ import axios from 'axios'; -import { refreshAccessToken } from '@utils/oauth'; -import { POSTHOG_PROXY_CLIENT_ID } from '@lib/constants'; +import { refreshAccessToken } from '../oauth.js'; +import { POSTHOG_PROXY_CLIENT_ID } from '../constants.js'; vi.mock('axios'); // No base-URL override resolves to prod routing (kills IS_DEV's implicit localhost). -vi.mock('../urls', async (importOriginal) => ({ - ...(await importOriginal()), +vi.mock('../urls.js', async (importOriginal) => ({ + ...(await importOriginal()), resolveBaseUrl: (baseUrl?: string) => baseUrl, })); -vi.mock('../debug', () => ({ logToFile: vi.fn() })); +vi.mock('../debug.js', () => ({ logToFile: vi.fn() })); const mockedAxios = axios as Mocked; diff --git a/src/utils/__tests__/oauth-server.test.ts b/src/store/shared/__tests__/oauth-server.test.ts similarity index 96% rename from src/utils/__tests__/oauth-server.test.ts rename to src/store/shared/__tests__/oauth-server.test.ts index f5086fa04..9e3e635bc 100644 --- a/src/utils/__tests__/oauth-server.test.ts +++ b/src/store/shared/__tests__/oauth-server.test.ts @@ -1,9 +1,9 @@ import * as http from 'node:http'; import * as net from 'node:net'; -import { startCallbackServer } from '@utils/oauth'; -import { logToFile } from '../debug'; +import { startCallbackServer } from '../oauth.js'; +import { logToFile } from '../debug.js'; -vi.mock('../debug', () => ({ logToFile: vi.fn() })); +vi.mock('../debug.js', () => ({ logToFile: vi.fn() })); const authUrl = 'https://oauth.example.test/authorize'; const signupUrl = 'https://oauth.example.test/signup'; diff --git a/src/utils/__tests__/oauth.test.ts b/src/store/shared/__tests__/oauth.test.ts similarity index 98% rename from src/utils/__tests__/oauth.test.ts rename to src/store/shared/__tests__/oauth.test.ts index 6c60212ac..c5dda941f 100644 --- a/src/utils/__tests__/oauth.test.ts +++ b/src/store/shared/__tests__/oauth.test.ts @@ -5,12 +5,12 @@ import { missingOAuthScopes, OAuthTokenResponseSchema, parseOAuthScopes, -} from '@utils/oauth'; +} from '../oauth.js'; import { WIZARD_OAUTH_SCOPES, WIZARD_PROVISIONING_SCOPES, -} from '@lib/constants'; -import { getOAuthScopesForProgram } from '@lib/oauth/program-scopes'; +} from '../constants.js'; +import { getOAuthScopesForProgram } from '../../services/oauth/program-scopes.js'; describe('extractOAuthCode', () => { it('extracts the code from a full callback URL', () => { diff --git a/src/utils/__tests__/project-resolution.test.ts b/src/store/shared/__tests__/project-resolution.test.ts similarity index 95% rename from src/utils/__tests__/project-resolution.test.ts rename to src/store/shared/__tests__/project-resolution.test.ts index 2b99f8273..6dae09ddb 100644 --- a/src/utils/__tests__/project-resolution.test.ts +++ b/src/store/shared/__tests__/project-resolution.test.ts @@ -1,4 +1,4 @@ -import { resolveGrantedProject } from '@utils/project-resolution'; +import { resolveGrantedProject } from '../project-resolution.js'; describe('resolveGrantedProject', () => { // The main integration flow (and every other program) runs without --project-id; diff --git a/src/utils/__tests__/provisioning.test.ts b/src/store/shared/__tests__/provisioning.test.ts similarity index 98% rename from src/utils/__tests__/provisioning.test.ts rename to src/store/shared/__tests__/provisioning.test.ts index 052f04913..a9167ed1b 100644 --- a/src/utils/__tests__/provisioning.test.ts +++ b/src/store/shared/__tests__/provisioning.test.ts @@ -2,8 +2,8 @@ import axios from 'axios'; import { ProvisionedAccountUnreadableError, provisionNewAccount, -} from '@utils/provisioning'; -import { analytics } from '../analytics'; +} from '../provisioning.js'; +import { analytics } from '../analytics.js'; // Fixtures live outside `__tests__` on purpose: every `.ts` in there is collected as a // test suite. import { @@ -11,16 +11,16 @@ import { RESOURCE_READBACK_RESPONSE, RESOURCE_RESPONSE, TOKEN_RESPONSE, -} from '../__fixtures__/provisioning'; +} from '../__fixtures__/provisioning.js'; vi.mock('axios'); // Return the override verbatim so region-based prod routing applies (no IS_DEV // localhost); undefined means no override. -vi.mock('../urls', () => ({ +vi.mock('../urls.js', () => ({ resolveBaseUrl: (baseUrl?: string) => baseUrl, })); -vi.mock('../debug', () => ({ logToFile: vi.fn() })); -vi.mock('../analytics', () => ({ +vi.mock('../debug.js', () => ({ logToFile: vi.fn() })); +vi.mock('../analytics.js', () => ({ analytics: { captureException: vi.fn() }, })); diff --git a/src/utils/__tests__/semver.test.ts b/src/store/shared/__tests__/semver.test.ts similarity index 98% rename from src/utils/__tests__/semver.test.ts rename to src/store/shared/__tests__/semver.test.ts index ee50adfc9..4293e5f4f 100644 --- a/src/utils/__tests__/semver.test.ts +++ b/src/store/shared/__tests__/semver.test.ts @@ -1,4 +1,4 @@ -import { createVersionBucket, versionSatisfiesRange } from '@utils/semver'; +import { createVersionBucket, versionSatisfiesRange } from '../semver.js'; describe('createVersionBucket', () => { describe('without minimum threshold', () => { diff --git a/src/utils/__tests__/terminal-bell.test.ts b/src/store/shared/__tests__/terminal-bell.test.ts similarity index 96% rename from src/utils/__tests__/terminal-bell.test.ts rename to src/store/shared/__tests__/terminal-bell.test.ts index 8978162bb..bea263e82 100644 --- a/src/utils/__tests__/terminal-bell.test.ts +++ b/src/store/shared/__tests__/terminal-bell.test.ts @@ -4,7 +4,7 @@ * of it. It has to be audible to a person who stepped away, and invisible * everywhere a bell cannot ring. */ -import { ringTerminalBell } from '@utils/terminal-bell'; +import { ringTerminalBell } from '../terminal-bell.js'; const BEL = '\u0007'; diff --git a/src/utils/analytics.ts b/src/store/shared/analytics.ts similarity index 98% rename from src/utils/analytics.ts rename to src/store/shared/analytics.ts index f494fc439..969dbc3a5 100644 --- a/src/utils/analytics.ts +++ b/src/store/shared/analytics.ts @@ -4,18 +4,18 @@ import { ANALYTICS_POSTHOG_PUBLIC_PROJECT_WRITE_KEY, ANALYTICS_TEAM_TAG, WIZARD_FLAG_KEYS, -} from '@lib/constants'; +} from './constants.js'; import { reportableDiscoveredFeatures, reportablePosthogSdkDetected, type WizardSession, -} from '@lib/wizard-session'; -import type { ApiUser } from '@lib/api'; +} from '../session/wizard-session.js'; +import type { ApiUser } from '../api.js'; 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 { debug, logToFile } from './debug'; -import { applyCiFlagOverrides } from './ci-flag-overrides'; +import { VERSION } from './version.js'; +import { debug, logToFile } from './debug.js'; +import { applyCiFlagOverrides } from './ci-flag-overrides.js'; /** * The invocation, reduced to flag-safe strings: the command word (first diff --git a/src/utils/atomic-ledger.ts b/src/store/shared/atomic-ledger.ts similarity index 100% rename from src/utils/atomic-ledger.ts rename to src/store/shared/atomic-ledger.ts diff --git a/src/utils/bounded-fs.ts b/src/store/shared/bounded-fs.ts similarity index 98% rename from src/utils/bounded-fs.ts rename to src/store/shared/bounded-fs.ts index 35e6dd55c..40fa30e49 100644 --- a/src/utils/bounded-fs.ts +++ b/src/store/shared/bounded-fs.ts @@ -7,9 +7,9 @@ import path from 'path'; import fs from 'fs'; import type { Dirent } from 'fs'; import fg from 'fast-glob'; -import { analytics } from './analytics'; -import { logToFile } from './debug'; -import type { WizardRunOptions } from './types'; +import { analytics } from './analytics.js'; +import { logToFile } from './debug.js'; +import type { WizardRunOptions } from './types.js'; /** * Errno codes that are expected while walking an arbitrary tree and mean diff --git a/src/utils/ci-flag-overrides.ts b/src/store/shared/ci-flag-overrides.ts similarity index 98% rename from src/utils/ci-flag-overrides.ts rename to src/store/shared/ci-flag-overrides.ts index 9c3864743..b555e5299 100644 --- a/src/utils/ci-flag-overrides.ts +++ b/src/store/shared/ci-flag-overrides.ts @@ -14,7 +14,7 @@ * become a production surface. */ import { runtimeEnv } from '@env'; -import { logToFile } from './debug'; +import { logToFile } from './debug.js'; export function applyCiFlagOverrides( flags: Record, diff --git a/src/utils/clipboard.ts b/src/store/shared/clipboard.ts similarity index 100% rename from src/utils/clipboard.ts rename to src/store/shared/clipboard.ts diff --git a/src/lib/constants.ts b/src/store/shared/constants.ts similarity index 99% rename from src/lib/constants.ts rename to src/store/shared/constants.ts index a0162e708..e19ef76be 100644 --- a/src/lib/constants.ts +++ b/src/store/shared/constants.ts @@ -2,7 +2,7 @@ * Shared constants for the PostHog wizard. */ -import { VERSION } from './version'; +import { VERSION } from './version.js'; // ── Models ────────────────────────────────────────────────────────── // Coordinate IDs/efforts with the mint allowlists and gateway transport/required prompt policy; see agent/runner/README.md. @@ -117,7 +117,7 @@ import { CONTEXT_MILL_LOCAL_URL, getLocalDev, POSTHOG_LOCAL_URL, -} from './local-dev'; +} from '../local-dev.js'; export { IS_DEV }; export const DEBUG = false; diff --git a/src/utils/custom-headers.ts b/src/store/shared/custom-headers.ts similarity index 100% rename from src/utils/custom-headers.ts rename to src/store/shared/custom-headers.ts diff --git a/src/utils/debug.ts b/src/store/shared/debug.ts similarity index 96% rename from src/utils/debug.ts rename to src/store/shared/debug.ts index 1081ff09a..86aee31f1 100644 --- a/src/utils/debug.ts +++ b/src/store/shared/debug.ts @@ -1,9 +1,9 @@ import { appendFileSync, mkdirSync } from 'fs'; import path from 'path'; import { inspect } from 'node:util'; -import { getUI } from '@ui'; +import { getUI } from '../ui/index.js'; import { IS_DEV, runtimeEnv } from '@env'; -import { WIZARD_LOG_FILE } from './paths'; +import { WIZARD_LOG_FILE } from './paths.js'; // Dev builds may redirect the log so concurrent runs don't interleave one file. let logFilePath = @@ -50,7 +50,7 @@ let reportedLogFailure = false; function reportLogFailureOnce(err: unknown): void { if (reportedLogFailure) return; reportedLogFailure = true; - void import('./analytics') + void import('./analytics.js') .then(({ analytics }) => analytics.captureException( err instanceof Error ? err : new Error(String(err)), diff --git a/src/utils/env-api-key.ts b/src/store/shared/env-api-key.ts similarity index 91% rename from src/utils/env-api-key.ts rename to src/store/shared/env-api-key.ts index db1becbd7..79e09f704 100644 --- a/src/utils/env-api-key.ts +++ b/src/store/shared/env-api-key.ts @@ -1,5 +1,5 @@ import * as path from 'path'; -import { readProjectFile } from './bounded-fs'; +import { readProjectFile } from './bounded-fs.js'; /** * Read POSTHOG_PERSONAL_API_KEY from .env.local or .env in the current diff --git a/src/utils/env-scan.ts b/src/store/shared/env-scan.ts similarity index 99% rename from src/utils/env-scan.ts rename to src/store/shared/env-scan.ts index 866b9826b..3481db63a 100644 --- a/src/utils/env-scan.ts +++ b/src/store/shared/env-scan.ts @@ -18,7 +18,7 @@ */ import path from 'path'; -import { walkProjectFiles, safeReadFile } from './bounded-fs'; +import { walkProjectFiles, safeReadFile } from './bounded-fs.js'; /** * Directory levels below the install dir that an env scan descends. Bounds the diff --git a/src/utils/environment.ts b/src/store/shared/environment.ts similarity index 94% rename from src/utils/environment.ts rename to src/store/shared/environment.ts index 58589c869..7ac24e30c 100644 --- a/src/utils/environment.ts +++ b/src/store/shared/environment.ts @@ -4,10 +4,10 @@ const readEnv = typeof readEnvModule === 'function' ? readEnvModule : (readEnvModule as any).default; -import { tryGetPackageJson } from './setup-utils'; -import type { WizardRunOptions } from './types'; -import { boundedGlob } from './bounded-fs'; -import { IS_DEV } from '@lib/constants'; +import { tryGetPackageJson } from './setup-utils.js'; +import type { WizardRunOptions } from './types.js'; +import { boundedGlob } from './bounded-fs.js'; +import { IS_DEV } from './constants.js'; export function isNonInteractiveEnvironment(): boolean { if (IS_DEV) { diff --git a/src/lib/errors/__tests__/auth.test.ts b/src/store/shared/errors/__tests__/auth.test.ts similarity index 94% rename from src/lib/errors/__tests__/auth.test.ts rename to src/store/shared/errors/__tests__/auth.test.ts index 085cfbc71..9021d5bbe 100644 --- a/src/lib/errors/__tests__/auth.test.ts +++ b/src/store/shared/errors/__tests__/auth.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; -import { classifyAuthFailure } from '../auth'; -import { ErrorCodes } from '../codes'; +import { classifyAuthFailure } from '../auth.js'; +import { ErrorCodes } from '../codes.js'; describe('classifyAuthFailure', () => { it('falls back to invalid-or-expired when nothing is known', () => { diff --git a/src/lib/errors/__tests__/codes.test.ts b/src/store/shared/errors/__tests__/codes.test.ts similarity index 97% rename from src/lib/errors/__tests__/codes.test.ts rename to src/store/shared/errors/__tests__/codes.test.ts index 0a49a4ace..36870d658 100644 --- a/src/lib/errors/__tests__/codes.test.ts +++ b/src/store/shared/errors/__tests__/codes.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; -import { ErrorCodes, ERROR_CODE_PATTERN, isErrorCode } from '../codes'; -import { ERROR_CATALOG } from '../catalog'; +import { ErrorCodes, ERROR_CODE_PATTERN, isErrorCode } from '../codes.js'; +import { ERROR_CATALOG } from '../catalog.js'; describe('error codes', () => { it('every code matches the PHW pattern', () => { diff --git a/src/lib/errors/__tests__/detect-map.test.ts b/src/store/shared/errors/__tests__/detect-map.test.ts similarity index 95% rename from src/lib/errors/__tests__/detect-map.test.ts rename to src/store/shared/errors/__tests__/detect-map.test.ts index 28d12cac7..a9580656d 100644 --- a/src/lib/errors/__tests__/detect-map.test.ts +++ b/src/store/shared/errors/__tests__/detect-map.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest'; -import { ErrorCodes } from '../codes'; -import { ERROR_CATALOG } from '../catalog'; -import { detectErrorCode, type DetectErrorKind } from '../detect-map'; +import { ErrorCodes } from '../codes.js'; +import { ERROR_CATALOG } from '../catalog.js'; +import { detectErrorCode, type DetectErrorKind } from '../detect-map.js'; /** * Every kind the programs can emit. `DetectErrorKind` is derived from their diff --git a/src/lib/errors/__tests__/run-failure.test.ts b/src/store/shared/errors/__tests__/run-failure.test.ts similarity index 85% rename from src/lib/errors/__tests__/run-failure.test.ts rename to src/store/shared/errors/__tests__/run-failure.test.ts index 3d9c30091..9e74bbdc3 100644 --- a/src/lib/errors/__tests__/run-failure.test.ts +++ b/src/store/shared/errors/__tests__/run-failure.test.ts @@ -1,10 +1,10 @@ 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 { classifyRunFailure } from '../run-failure.js'; +import { ErrorCodes } from '../codes.js'; +import { WizardError } from '../../wizard-abort.js'; +import { GatewayMintRefused } from '@agent/gateway/gateway-session'; -vi.mock('@utils/analytics', () => ({ +vi.mock('../../analytics.js', () => ({ analytics: { wizardCapture: vi.fn(), captureException: vi.fn() }, })); diff --git a/src/lib/errors/__tests__/sanitize.test.ts b/src/store/shared/errors/__tests__/sanitize.test.ts similarity index 94% rename from src/lib/errors/__tests__/sanitize.test.ts rename to src/store/shared/errors/__tests__/sanitize.test.ts index 464acad8a..af38235f8 100644 --- a/src/lib/errors/__tests__/sanitize.test.ts +++ b/src/store/shared/errors/__tests__/sanitize.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import { sanitizeErrorDetail } from '../sanitize'; +import { sanitizeErrorDetail } from '../sanitize.js'; describe('sanitizeErrorDetail', () => { it('keeps allowlisted fields', () => { diff --git a/src/lib/errors/agent-map.ts b/src/store/shared/errors/agent-map.ts similarity index 81% rename from src/lib/errors/agent-map.ts rename to src/store/shared/errors/agent-map.ts index c795f0e5b..2b5919443 100644 --- a/src/lib/errors/agent-map.ts +++ b/src/store/shared/errors/agent-map.ts @@ -1,5 +1,5 @@ -import { AgentErrorType } from '@lib/agent-signals'; -import { ErrorCodes, type ErrorCode } from './codes'; +import { AgentErrorType } from '../../agent-protocol/agent-signals.js'; +import { ErrorCodes, type ErrorCode } from './codes.js'; export const AGENT_ERROR_CODE: Record = { [AgentErrorType.MCP_MISSING]: ErrorCodes.AgentMcpMissing, diff --git a/src/lib/errors/auth.ts b/src/store/shared/errors/auth.ts similarity index 95% rename from src/lib/errors/auth.ts rename to src/store/shared/errors/auth.ts index 243dc9067..f70637b97 100644 --- a/src/lib/errors/auth.ts +++ b/src/store/shared/errors/auth.ts @@ -1,4 +1,4 @@ -import { ErrorCodes, type ErrorCode } from './codes'; +import { ErrorCodes, type ErrorCode } from './codes.js'; export interface AuthFailureInput { hasSettingsConflict?: boolean; diff --git a/src/lib/errors/catalog.ts b/src/store/shared/errors/catalog.ts similarity index 98% rename from src/lib/errors/catalog.ts rename to src/store/shared/errors/catalog.ts index e49be2929..166c4e90f 100644 --- a/src/lib/errors/catalog.ts +++ b/src/store/shared/errors/catalog.ts @@ -1,5 +1,5 @@ -import { ErrorCodes, type ErrorCode } from './codes'; -import type { ErrorCatalogEntry } from './types'; +import { ErrorCodes, type ErrorCode } from './codes.js'; +import type { ErrorCatalogEntry } from './types.js'; export const ERROR_CATALOG: Record = { [ErrorCodes.CliNodeVersion]: { diff --git a/src/lib/errors/codes.ts b/src/store/shared/errors/codes.ts similarity index 100% rename from src/lib/errors/codes.ts rename to src/store/shared/errors/codes.ts diff --git a/src/lib/errors/detect-map.ts b/src/store/shared/errors/detect-map.ts similarity index 78% rename from src/lib/errors/detect-map.ts rename to src/store/shared/errors/detect-map.ts index b632966ac..9721ec515 100644 --- a/src/lib/errors/detect-map.ts +++ b/src/store/shared/errors/detect-map.ts @@ -1,9 +1,9 @@ -import { ErrorCodes, type ErrorCode } from './codes'; -import type { RevenueDetectError } from '@lib/programs/revenue-analytics/detect'; -import type { SelfDrivingDetectError } from '@lib/programs/self-driving/detect'; -import type { SourceMapsDetectError } from '@lib/programs/error-tracking-upload-source-maps/detect'; -import type { WarehouseDetectError } from '@lib/programs/warehouse-source/detect'; -import type { WebAnalyticsDetectError } from '@lib/programs/web-analytics-doctor/detect'; +import { ErrorCodes, type ErrorCode } from './codes.js'; +import type { RevenueDetectError } from '../../programs/revenue-analytics/detect.js'; +import type { SelfDrivingDetectError } from '../../programs/self-driving/detect.js'; +import type { SourceMapsDetectError } from '../../programs/error-tracking-upload-source-maps/detect.js'; +import type { WarehouseDetectError } from '../../programs/warehouse-source/detect.js'; +import type { WebAnalyticsDetectError } from '../../programs/web-analytics-doctor/detect.js'; /** * Every `kind` a program detect step can write into diff --git a/src/lib/errors/emit.ts b/src/store/shared/errors/emit.ts similarity index 90% rename from src/lib/errors/emit.ts rename to src/store/shared/errors/emit.ts index 4fcae6d9f..046f4893c 100644 --- a/src/lib/errors/emit.ts +++ b/src/store/shared/errors/emit.ts @@ -1,4 +1,4 @@ -import type { ErrorCode } from './codes'; +import type { ErrorCode } from './codes.js'; export const PHW_ERROR_PREFIX = 'phw-error:'; diff --git a/src/lib/errors/index.ts b/src/store/shared/errors/index.ts similarity index 60% rename from src/lib/errors/index.ts rename to src/store/shared/errors/index.ts index 5558c7942..842455bdc 100644 --- a/src/lib/errors/index.ts +++ b/src/store/shared/errors/index.ts @@ -3,18 +3,18 @@ export { ERROR_CODE_PATTERN, isErrorCode, type ErrorCode, -} from './codes'; -export { ERROR_CATALOG } from './catalog'; -export type { ErrorCatalogEntry, ErrorGroup, RetryAdvice } from './types'; -export { classifyAuthFailure, type AuthFailureInput } from './auth'; -export { AGENT_ERROR_CODE } from './agent-map'; -export { detectErrorCode, type DetectErrorKind } from './detect-map'; -export { skillErrorCode } from './skill-map'; +} from './codes.js'; +export { ERROR_CATALOG } from './catalog.js'; +export type { ErrorCatalogEntry, ErrorGroup, RetryAdvice } from './types.js'; +export { classifyAuthFailure, type AuthFailureInput } from './auth.js'; +export { AGENT_ERROR_CODE } from './agent-map.js'; +export { detectErrorCode, type DetectErrorKind } from './detect-map.js'; +export { skillErrorCode } from './skill-map.js'; export { PHW_ERROR_PREFIX, emitWizardError, formatWizardErrorLine, type WizardErrorLine, -} from './emit'; -export { sanitizeErrorDetail } from './sanitize'; -export { classifyRunFailure, type RunFailure } from './run-failure'; +} from './emit.js'; +export { sanitizeErrorDetail } from './sanitize.js'; +export { classifyRunFailure, type RunFailure } from './run-failure.js'; diff --git a/src/lib/errors/run-failure.ts b/src/store/shared/errors/run-failure.ts similarity index 99% rename from src/lib/errors/run-failure.ts rename to src/store/shared/errors/run-failure.ts index 8ad3b0f20..3a958f639 100644 --- a/src/lib/errors/run-failure.ts +++ b/src/store/shared/errors/run-failure.ts @@ -1,4 +1,4 @@ -import { ErrorCodes, isErrorCode, type ErrorCode } from './codes'; +import { ErrorCodes, isErrorCode, type ErrorCode } from './codes.js'; export interface RunFailure { code: ErrorCode; diff --git a/src/lib/errors/sanitize.ts b/src/store/shared/errors/sanitize.ts similarity index 100% rename from src/lib/errors/sanitize.ts rename to src/store/shared/errors/sanitize.ts diff --git a/src/lib/errors/skill-map.ts b/src/store/shared/errors/skill-map.ts similarity index 77% rename from src/lib/errors/skill-map.ts rename to src/store/shared/errors/skill-map.ts index 1bca38eef..10cd219f9 100644 --- a/src/lib/errors/skill-map.ts +++ b/src/store/shared/errors/skill-map.ts @@ -1,5 +1,5 @@ -import { ErrorCodes, type ErrorCode } from './codes'; -import type { InstallSkillResult } from '@lib/wizard-tools'; +import { ErrorCodes, type ErrorCode } from './codes.js'; +import type { InstallSkillResult } from '../../tools/index.js'; const SKILL_CODES: Record< Exclude, diff --git a/src/lib/errors/types.ts b/src/store/shared/errors/types.ts similarity index 100% rename from src/lib/errors/types.ts rename to src/store/shared/errors/types.ts diff --git a/src/utils/links.ts b/src/store/shared/links.ts similarity index 98% rename from src/utils/links.ts rename to src/store/shared/links.ts index 14be27b4b..85fecaa02 100644 --- a/src/utils/links.ts +++ b/src/store/shared/links.ts @@ -8,7 +8,7 @@ */ import opn from 'opn'; import { NODE_ENV } from '@env'; -import { analytics } from './analytics'; +import { analytics } from './analytics.js'; /** * Record the CLI command this run was started with (e.g. `integrate`, diff --git a/src/utils/oauth-errors.ts b/src/store/shared/oauth-errors.ts similarity index 99% rename from src/utils/oauth-errors.ts rename to src/store/shared/oauth-errors.ts index e95f7f751..5644e6ef2 100644 --- a/src/utils/oauth-errors.ts +++ b/src/store/shared/oauth-errors.ts @@ -14,7 +14,7 @@ import { ISSUES_URL, POSTHOG_STATUS_PAGE_URL, WIZARD_CONTACT_EMAIL, -} from '@lib/constants'; +} from './constants.js'; /** * A structured OAuth failure (RFC 6749 §4.1.2.1 authorize errors, §5.2 token diff --git a/src/utils/oauth.ts b/src/store/shared/oauth.ts similarity index 98% rename from src/utils/oauth.ts rename to src/store/shared/oauth.ts index 0fc53e78f..7cf81fe11 100644 --- a/src/utils/oauth.ts +++ b/src/store/shared/oauth.ts @@ -2,27 +2,27 @@ import * as crypto from 'node:crypto'; import * as http from 'node:http'; import { execSync } from 'node:child_process'; import axios from 'axios'; -import { logToFile } from './debug'; +import { logToFile } from './debug.js'; import { z } from 'zod'; -import { getUI } from '@ui'; +import { getUI } from '../ui/index.js'; import { OAUTH_PORTS, OAUTH_TIMEOUT_MS, POSTHOG_DEV_CLIENT_ID, POSTHOG_PROXY_CLIENT_ID, WIZARD_USER_AGENT, -} from '@lib/constants'; -import { getOAuthUrl, resolveBaseUrl } from './urls'; -import { abort } from './setup-utils'; -import { openTrackedLink, withUtm } from './links'; -import { analytics } from './analytics'; +} from './constants.js'; +import { getOAuthUrl, resolveBaseUrl } from './urls.js'; +import { abort } from './setup-utils.js'; +import { openTrackedLink, withUtm } from './links.js'; +import { analytics } from './analytics.js'; import { OAuthError, buildCallbackErrorHtml, buildOAuthFailureMessage, oauthErrorFromCallbackParams, oauthErrorFromTokenBody, -} from './oauth-errors'; +} from './oauth-errors.js'; const OAUTH_CALLBACK_STYLES = `