diff --git a/.github/workflows/mobile.yml b/.github/workflows/mobile.yml index 0afbc245002..74ac6a9b9e1 100644 --- a/.github/workflows/mobile.yml +++ b/.github/workflows/mobile.yml @@ -34,7 +34,7 @@ on: - 'src/main/runtime/agent-session/agent-session-runtime-*.ts' - 'src/main/runtime/agent-session/agent-session-unsaved-*.ts' # The phone/host contract program's unmocked desktop sources and its declaration owner's inputs. - - 'src/main/runtime/runtime-github-repository-query-commands.ts' + - 'src/main/runtime/integrations/github/runtime-github-repository-query-commands.ts' - 'src/main/github/issue-field-options.ts' - 'config/tsconfig.test.mobile-host-declarations.json' - 'config/tsconfig.node.json' @@ -99,7 +99,7 @@ on: - 'src/main/runtime/agent-session/agent-session-runtime-*.ts' - 'src/main/runtime/agent-session/agent-session-unsaved-*.ts' # The phone/host contract program's unmocked desktop sources and its declaration owner's inputs. - - 'src/main/runtime/runtime-github-repository-query-commands.ts' + - 'src/main/runtime/integrations/github/runtime-github-repository-query-commands.ts' - 'src/main/github/issue-field-options.ts' - 'config/tsconfig.test.mobile-host-declarations.json' - 'config/tsconfig.node.json' diff --git a/config/main-sync-spawn-baseline.txt b/config/main-sync-spawn-baseline.txt index 289fe9bed82..2eeeca72ab7 100644 --- a/config/main-sync-spawn-baseline.txt +++ b/config/main-sync-spawn-baseline.txt @@ -37,7 +37,7 @@ 1 src/main/plugins/catalog/plugin-private-marketplace-ssh-shim.cjs 1 src/main/pty/process-retirement/posix-pty-process-table.ts 1 src/main/pty/shell-startup/pwsh.ts -1 src/main/runtime/runtime-skill-install-authority.ts +1 src/main/runtime/integrations/skill/runtime-skill-install-authority.ts 2 src/main/startup/cli-launch-redirect.ts 1 src/main/startup/linux-secret-service-probe.ts 1 src/main/workspace-hooks/worktree-runner-script.ts diff --git a/config/scripts/ci/sharding/ci-shard-timings.json b/config/scripts/ci/sharding/ci-shard-timings.json index 5e7e25b9e30..5413c682799 100644 --- a/config/scripts/ci/sharding/ci-shard-timings.json +++ b/config/scripts/ci/sharding/ci-shard-timings.json @@ -5544,13 +5544,13 @@ "src/main/runtime/runtime-folder-workspace-delete-lifecycle.test.ts": 4190, "src/main/runtime/runtime-folder-workspace-wsl-failed-start-pane.test.ts": 4472, "src/main/runtime/runtime-folder-workspace-wsl-launch-scope.test.ts": 3705, - "src/main/runtime/runtime-git-execution-host-ownership.test.ts": 1098, - "src/main/runtime/runtime-git-generation-admission.test.ts": 595, - "src/main/runtime/runtime-git-stage-worktree-scope.test.ts": 1246, - "src/main/runtime/runtime-git-sync-commands.test.ts": 938, - "src/main/runtime/runtime-git-target-execution-host.test.ts": 3941, - "src/main/runtime/runtime-github-repository-query-commands.test.ts": 4240, - "src/main/runtime/runtime-gitlab-worktree-base-wsl-gate.test.ts": 1470, + "src/main/runtime/integrations/git/runtime-git-execution-host-ownership.test.ts": 1098, + "src/main/runtime/integrations/git/runtime-git-generation-admission.test.ts": 595, + "src/main/runtime/integrations/git/runtime-git-stage-worktree-scope.test.ts": 1246, + "src/main/runtime/integrations/git/runtime-git-sync-commands.test.ts": 938, + "src/main/runtime/integrations/git/runtime-git-target-execution-host.test.ts": 3941, + "src/main/runtime/integrations/github/runtime-github-repository-query-commands.test.ts": 4240, + "src/main/runtime/integrations/gitlab/runtime-gitlab-worktree-base-wsl-gate.test.ts": 1470, "src/main/runtime/runtime-graph-mirror-capture.test.ts": 4159, "src/main/runtime/runtime-graph-reload-lifecycle.test.ts": 44, "src/main/runtime/runtime-graph-standing-contracts.test.ts": 4122, @@ -5560,8 +5560,8 @@ "src/main/runtime/runtime-legacy-worker-missing-workspace-recovery.test.ts": 91, "src/main/runtime/runtime-legacy-worker-terminal-recovery-persistence.test.ts": 479, "src/main/runtime/runtime-legacy-worker-terminal-recovery-retry.test.ts": 102, - "src/main/runtime/runtime-linear-comment-edit.test.ts": 458, - "src/main/runtime/runtime-linear-write-lifetime.test.ts": 512, + "src/main/runtime/integrations/linear/runtime-linear-comment-edit.test.ts": 458, + "src/main/runtime/integrations/linear/runtime-linear-write-lifetime.test.ts": 512, "src/main/runtime/runtime-local-worktree-create-pr-conflict.test.ts": 462, "src/main/runtime/runtime-local-worktree-create-pr-conflicts.test.ts": 490, "src/main/runtime/runtime-local-worktree-create.test.ts": 693, @@ -5631,7 +5631,7 @@ "src/main/runtime/runtime-search-line-fragments.test.ts": 624, "src/main/runtime/runtime-secondary-visibility-host.test.ts": 3990, "src/main/runtime/runtime-server-environment-commands.test.ts": 262, - "src/main/runtime/runtime-skill-install-commands.test.ts": 720, + "src/main/runtime/integrations/skill/runtime-skill-install-commands.test.ts": 720, "src/main/runtime/runtime-socket-sweep.test.ts": 47, "src/main/runtime/runtime-sort-order-scan-cache.test.ts": 3537, "src/main/runtime/runtime-subscription-registry.test.ts": 142, diff --git a/config/tsconfig.test.mobile-host-declarations.json b/config/tsconfig.test.mobile-host-declarations.json index c22f1a8b335..ffaa7742688 100644 --- a/config/tsconfig.test.mobile-host-declarations.json +++ b/config/tsconfig.test.mobile-host-declarations.json @@ -12,7 +12,7 @@ "outDir": "../mobile/node_modules/.cache/phone-host-contract-types" }, "files": [ - "../src/main/runtime/runtime-github-repository-query-commands.ts", + "../src/main/runtime/integrations/github/runtime-github-repository-query-commands.ts", "../src/main/runtime/rpc/methods/github-repo-work-item-methods.ts", "../src/main/runtime/orca-runtime.ts", "../src/main/runtime/rpc/core.ts", diff --git a/mobile/src/components/pr-sidebar/reviewer-picker.target-contract.test.tsx b/mobile/src/components/pr-sidebar/reviewer-picker.target-contract.test.tsx index d06adc63214..d06f426980a 100644 --- a/mobile/src/components/pr-sidebar/reviewer-picker.target-contract.test.tsx +++ b/mobile/src/components/pr-sidebar/reviewer-picker.target-contract.test.tsx @@ -9,7 +9,7 @@ import { } from '@orca/test-mobile/mobile-web-shell/bridge-host-test-fakes' import { createStableLogicalRpcClient } from '@orca/test-mobile/transport/stable-logical-rpc-client' import type { HostConnectionInputs } from '@orca/test-mobile/transport/client-context-connection-metrics' -import { RuntimeGitHubRepositoryQueryCommands } from '@orca/test-host/main/runtime/runtime-github-repository-query-commands' +import { RuntimeGitHubRepositoryQueryCommands } from '@orca/test-host/main/runtime/integrations/github/runtime-github-repository-query-commands' import { GITHUB_REPO_WORK_ITEM_METHODS } from '@orca/test-host/main/runtime/rpc/methods/github-repo-work-item-methods' import type { OrcaRuntimeService } from '@orca/test-host/main/runtime/orca-runtime' import { eraseRpcMethods } from '@orca/test-host/main/runtime/rpc/core' diff --git a/src/main/github/project-account-operations.test.ts b/src/main/github/project-account-operations.test.ts index 3d782e4e202..aad4bd3d27a 100644 --- a/src/main/github/project-account-operations.test.ts +++ b/src/main/github/project-account-operations.test.ts @@ -53,7 +53,7 @@ import { getPRChecks } from './client/check/get-pr-checks' import { rerunPRChecks } from './client/check/rerun-pr-checks' import { getPRFileContents } from './work-item-details' import { resolveGitHubPrStartPoint } from './pr-start-point' -import { RuntimeGitHubRepositoryQueryCommands } from '../runtime/runtime-github-repository-query-commands' +import { RuntimeGitHubRepositoryQueryCommands } from '../runtime/integrations/github/runtime-github-repository-query-commands' import { clearGhAccountTokenCacheForTests } from './gh-account-token' import { clearGhCapabilityStateForTests } from './gh-capability-state' import { _resetGhRateLimitBreaker } from '../git/gh-rate-limit-breaker' diff --git a/src/main/linear/issue-relation-lifetime.test.ts b/src/main/linear/issue-relation-lifetime.test.ts index 083326f62dd..150e7e5d1ee 100644 --- a/src/main/linear/issue-relation-lifetime.test.ts +++ b/src/main/linear/issue-relation-lifetime.test.ts @@ -1,7 +1,7 @@ import { afterEach, beforeEach, expect, it, vi } from 'vitest' import { acquire, release } from './linear-request-concurrency' import { linearError } from './issue-context/errors' -import { runLinearWriteAction } from '../runtime/runtime-linear-write-action' +import { runLinearWriteAction } from '../runtime/integrations/linear/runtime-linear-write-action' import { writeIssueRelation } from './issue-relation-write' const mocks = vi.hoisted(() => ({ rawRequest: vi.fn() })) diff --git a/src/main/persistence/moving-wsl-projects/wsl-move-incidental-writes.test.ts b/src/main/persistence/moving-wsl-projects/wsl-move-incidental-writes.test.ts index 5fc6e4bad76..2e002290e37 100644 --- a/src/main/persistence/moving-wsl-projects/wsl-move-incidental-writes.test.ts +++ b/src/main/persistence/moving-wsl-projects/wsl-move-incidental-writes.test.ts @@ -22,7 +22,7 @@ vi.mock('../../linear/issue-context/current', async (importOriginal) => ({ })) import { materializeWorktreePushTargetRemote } from '../../ipc/worktree-remote' -import { RuntimeLinearTeamWriteCommands } from '../../runtime/runtime-linear-team-write-commands' +import { RuntimeLinearTeamWriteCommands } from '../../runtime/integrations/linear/runtime-linear-team-write-commands' import { hostWorktreeTarget } from '../../../shared/worktree/host-qualified-identity' const MOVING_WT = 'repo-1::/ws/repo-1/wt' diff --git a/src/main/runtime/construction/runtime-construction.ts b/src/main/runtime/construction/runtime-construction.ts index c660b84c637..b097a868366 100644 --- a/src/main/runtime/construction/runtime-construction.ts +++ b/src/main/runtime/construction/runtime-construction.ts @@ -29,7 +29,7 @@ import { import { type RuntimeGitCommandSurface, installRuntimeGitCommandSurface -} from '../runtime-git-command-surface' +} from '../integrations/git/runtime-git-command-surface' import { type RuntimeRepositoryCommandSurface, installRuntimeRepositoryCommandSurface @@ -42,11 +42,11 @@ import { type RuntimeServiceCommandSurface, installRuntimeServiceCommandSurface } from '../runtime-service-command-surface' -import { RuntimeSkillCommands } from '../runtime-skill-command-surface' +import { RuntimeSkillCommands } from '../integrations/skill/runtime-skill-command-surface' import { type RuntimeSkillCommandSurface, installRuntimeSkillCommandSurface -} from '../runtime-skill-command-contract' +} from '../integrations/skill/runtime-skill-command-contract' import { getAppEnvironment } from '../../../shared/app-environment' import { RuntimeClientSettingsController } from '../runtime-client-settings' import { RuntimeSessionSearchSettingsController } from '../runtime-session-search-settings' diff --git a/src/main/runtime/construction/runtime-file-command-state.ts b/src/main/runtime/construction/runtime-file-command-state.ts index 4f0f1993be4..23190895b26 100644 --- a/src/main/runtime/construction/runtime-file-command-state.ts +++ b/src/main/runtime/construction/runtime-file-command-state.ts @@ -5,16 +5,16 @@ import type { RuntimeTerminalAgentStatus } from '../../../shared/runtime-termina import { OrcaRuntimeWithPreservedBranchCleanup } from './runtime-host-services' import { RuntimeFileCommands } from '../orca-runtime-files' import { createRuntimeFileWatcherRemoval } from '../runtime-file-watcher-removal' -import { RuntimeGitCommands } from '../orca-runtime-git' -import { RuntimeHostedReviewCommands } from '../runtime-hosted-review-commands' -import { RuntimeGitHubRepositoryQueryCommands } from '../runtime-github-repository-query-commands' -import { RuntimeGitLabQueryCommands } from '../runtime-gitlab-query-commands' +import { RuntimeGitCommands } from '../integrations/git/orca-runtime-git' +import { RuntimeHostedReviewCommands } from '../integrations/reviews/runtime-hosted-review-commands' +import { RuntimeGitHubRepositoryQueryCommands } from '../integrations/github/runtime-github-repository-query-commands' +import { RuntimeGitLabQueryCommands } from '../integrations/gitlab/runtime-gitlab-query-commands' import { recordGitLabProjectRecent } from '../../gitlab/gitlab-project-recents' -import { RuntimeGitLabMutationCommands } from '../runtime-gitlab-mutation-commands' -import { RuntimeGitHubReviewQueryCommands } from '../runtime-github-review-query-commands' -import { RuntimeGitHubReviewMutationCommands } from '../runtime-github-review-mutation-commands' -import { RuntimeGitHubIssueCommentCommands } from '../runtime-github-issue-comment-commands' -import { RuntimeGitHubProjectCommands } from '../runtime-github-project-commands' +import { RuntimeGitLabMutationCommands } from '../integrations/gitlab/runtime-gitlab-mutation-commands' +import { RuntimeGitHubReviewQueryCommands } from '../integrations/github/runtime-github-review-query-commands' +import { RuntimeGitHubReviewMutationCommands } from '../integrations/github/runtime-github-review-mutation-commands' +import { RuntimeGitHubIssueCommentCommands } from '../integrations/github/runtime-github-issue-comment-commands' +import { RuntimeGitHubProjectCommands } from '../integrations/github/runtime-github-project-commands' import { RuntimeRepositoryHooksCommands } from '../runtime-repository-hooks-commands' import { RuntimeRepositoryIssueCommand } from '../runtime-repository-issue-command' import { ClientHostedBrowserRowPublisher } from '../client-hosted-browser-row-publication' diff --git a/src/main/runtime/construction/runtime-service-state.ts b/src/main/runtime/construction/runtime-service-state.ts index 0ae338de483..b7f6cfb45fe 100644 --- a/src/main/runtime/construction/runtime-service-state.ts +++ b/src/main/runtime/construction/runtime-service-state.ts @@ -41,7 +41,7 @@ import { OrchestrationMailboxNotificationCoordinator } from '../orchestration/ma import type { RuntimeMessageWaiter } from '../runtime-message-waiters' import { RuntimeMessageWaiters } from '../runtime-message-waiters' import type { WorkerTurnStopReportDeps } from '../orchestration/worker-turn-stop-report' -import type { RuntimeSkillCommands } from '../runtime-skill-command-surface' +import type { RuntimeSkillCommands } from '../integrations/skill/runtime-skill-command-surface' import { RuntimeTerminalStreamConsumers } from '../runtime-terminal-stream-consumers' import type { RecentPtyOutputBuffer } from '../recent-pty-output-buffer' import { ORCA_LAYOUT_OWNER_IS_MAIN } from '../../../shared/layout-owner-switch' diff --git a/src/main/runtime/files/file-access.ts b/src/main/runtime/files/file-access.ts index 75f913e3ede..2414f23ff5e 100644 --- a/src/main/runtime/files/file-access.ts +++ b/src/main/runtime/files/file-access.ts @@ -24,7 +24,7 @@ import { } from './file-target' import { parseExecutionHostId, type ExecutionHostId } from '../../../shared/execution-host' import type { FileStat } from '../../providers/filesystem-provider-contract' -import { assertRuntimeReadWslDistroRunning } from '../runtime-wsl-background-read-gate' +import { assertRuntimeReadWslDistroRunning } from '../integrations/git/runtime-wsl-background-read-gate' type RuntimeFileAccessHost = Pick< RuntimeFileCommandHost, diff --git a/src/main/runtime/github-check-details-paired.integration.test.ts b/src/main/runtime/github-check-details-paired.integration.test.ts index eb7c12d1366..33a8ba2dd8d 100644 --- a/src/main/runtime/github-check-details-paired.integration.test.ts +++ b/src/main/runtime/github-check-details-paired.integration.test.ts @@ -1,3 +1,4 @@ +import type * as GitHubGetPrCheckDetailsModule from '../github/client/check/get-pr-check-details' import './rpc/unused-default-rpc-methods.test-fixture' import type { ChildProcess, SpawnOptions } from 'node:child_process' import { existsSync, mkdtempSync, rmSync } from 'node:fs' @@ -15,7 +16,7 @@ import { RemoteRuntimeRequestConnection } from '../../shared/remote-runtime/requ import type { Repo } from '../../shared/repo-types' import type { OrcaRuntimeService } from './orca-runtime' import { OrcaRuntimeRpcServer } from './runtime-rpc' -import { RuntimeGitHubReviewQueryCommands } from './runtime-github-review-query-commands' +import { RuntimeGitHubReviewQueryCommands } from './integrations/github/runtime-github-review-query-commands' import { GITHUB_PULL_REQUEST_METHODS } from './rpc/methods/github-pull-request-methods' import { clearGhAccountTokenCacheForTests } from '../github/gh-account-token' import { clearGhCapabilityStateForTests } from '../github/gh-capability-state' @@ -34,8 +35,14 @@ const { spawnMock, resolverMock, detailsDelegate, captures, terminationMock } = }) vi.mock('node:child_process', async (original) => ({ ...(await original()), spawn: spawnMock })) vi.mock('../github/github-api-repository', () => ({ resolveGitHubRepoExecution: resolverMock })) +vi.mock('../github/client/check/get-pr-check-details', async (importOriginal) => { + const actual = await importOriginal() + return { getPRCheckDetails: detailsDelegate.mockImplementation(actual.getPRCheckDetails) } +}) vi.mock('../github/client', async () => { - const actual = await import('../github/client/check/get-pr-check-details') + const actual = await vi.importActual( + '../github/client/check/get-pr-check-details' + ) return { getPRCheckDetails: detailsDelegate.mockImplementation(actual.getPRCheckDetails), getPRChecks: vi.fn(), diff --git a/src/main/runtime/orca-runtime-git.ts b/src/main/runtime/integrations/git/orca-runtime-git.ts similarity index 100% rename from src/main/runtime/orca-runtime-git.ts rename to src/main/runtime/integrations/git/orca-runtime-git.ts diff --git a/src/main/runtime/runtime-git-command-surface.ts b/src/main/runtime/integrations/git/runtime-git-command-surface.ts similarity index 100% rename from src/main/runtime/runtime-git-command-surface.ts rename to src/main/runtime/integrations/git/runtime-git-command-surface.ts diff --git a/src/main/runtime/runtime-git-command-target.ts b/src/main/runtime/integrations/git/runtime-git-command-target.ts similarity index 80% rename from src/main/runtime/runtime-git-command-target.ts rename to src/main/runtime/integrations/git/runtime-git-command-target.ts index cee00dff3c5..30a79d000ef 100644 --- a/src/main/runtime/runtime-git-command-target.ts +++ b/src/main/runtime/integrations/git/runtime-git-command-target.ts @@ -1,18 +1,21 @@ -import type { SourceControlAiSettingsInput } from '../../shared/source-control/ai/source-control-ai-operation-resolution' -import { LOCAL_EXECUTION_HOST_ID, type ExecutionHostId } from '../../shared/execution-host' -import type { Repo } from '../../shared/repo-types' -import type { GitPushTarget, GitWorktreeInfo, Worktree } from '../../shared/worktree/types' -import type { GitRuntimeOptions } from '../git/git-runtime-options' -import { getWorktreeSharedLinkPaths } from '../git/worktrees/content-paths/worktree-shared-directories' +import type { SourceControlAiSettingsInput } from '../../../../shared/source-control/ai/source-control-ai-operation-resolution' +import { LOCAL_EXECUTION_HOST_ID, type ExecutionHostId } from '../../../../shared/execution-host' +import type { Repo } from '../../../../shared/repo-types' +import type { GitPushTarget, GitWorktreeInfo, Worktree } from '../../../../shared/worktree/types' +import type { GitRuntimeOptions } from '../../../git/git-runtime-options' +import { getWorktreeSharedLinkPaths } from '../../../git/worktrees/content-paths/worktree-shared-directories' import { ExecutionHostNotDispatchableError, resolveGitRouteForHost -} from '../providers/execution-host-provider-dispatch' -import type { createLocalGitProvider, LocalGitProvider } from '../providers/local-git-provider' -import { SshHostNotServedError } from '../providers/ssh-host-not-served-error' -import type { CommitMessageAgentEnvironmentResolvers } from '../text-generation/commit-message-agent-environment' -import type { PullRequestLinkedIssueMeta } from '../source-control/pull-request-linked-issue' -import { normalizeRuntimeRelativePath } from './runtime-relative-paths' +} from '../../../providers/execution-host-provider-dispatch' +import type { + createLocalGitProvider, + LocalGitProvider +} from '../../../providers/local-git-provider' +import { SshHostNotServedError } from '../../../providers/ssh-host-not-served-error' +import type { CommitMessageAgentEnvironmentResolvers } from '../../../text-generation/commit-message-agent-environment' +import type { PullRequestLinkedIssueMeta } from '../../../source-control/pull-request-linked-issue' +import { normalizeRuntimeRelativePath } from '../../runtime-relative-paths' export type ResolvedRuntimeGitWorktree = Worktree & { git: GitWorktreeInfo } diff --git a/src/main/runtime/runtime-git-diff-commands.ts b/src/main/runtime/integrations/git/runtime-git-diff-commands.ts similarity index 91% rename from src/main/runtime/runtime-git-diff-commands.ts rename to src/main/runtime/integrations/git/runtime-git-diff-commands.ts index 3fa30eacfae..6a6b0adefb3 100644 --- a/src/main/runtime/runtime-git-diff-commands.ts +++ b/src/main/runtime/integrations/git/runtime-git-diff-commands.ts @@ -2,11 +2,11 @@ import type { GitBranchCompareResult, GitCommitCompareResult, GitDiffResult -} from '../../shared/git/diff/git-diff-compare-types' -import { assertGitDiffWithinTransportBudget } from '../../shared/git/diff/git-diff-transport-budget' -import { getBranchDiff } from '../git/source-control/branch-diff' -import type { GitAdmissionTier } from '../git/command-runner/git-exec-options' -import { normalizeRuntimeRelativePath } from './runtime-relative-paths' +} from '../../../../shared/git/diff/git-diff-compare-types' +import { assertGitDiffWithinTransportBudget } from '../../../../shared/git/diff/git-diff-transport-budget' +import { getBranchDiff } from '../../../git/source-control/branch-diff' +import type { GitAdmissionTier } from '../../../../shared/rpc-contract/git-admission-tier-params' +import { normalizeRuntimeRelativePath } from '../../runtime-relative-paths' import { localGitOptionsForTarget, normalizeRuntimeGitRelativePath, diff --git a/src/main/runtime/runtime-git-execution-host-ownership.test.ts b/src/main/runtime/integrations/git/runtime-git-execution-host-ownership.test.ts similarity index 77% rename from src/main/runtime/runtime-git-execution-host-ownership.test.ts rename to src/main/runtime/integrations/git/runtime-git-execution-host-ownership.test.ts index 499feadb70c..61e51d5221a 100644 --- a/src/main/runtime/runtime-git-execution-host-ownership.test.ts +++ b/src/main/runtime/integrations/git/runtime-git-execution-host-ownership.test.ts @@ -1,10 +1,10 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' -import type { GlobalSettings } from '../../shared/global-settings-types' -import type * as GitRemoteModule from '../git/remote' +import type { GlobalSettings } from '../../../../shared/global-settings-types' +import type * as GitRemoteModule from '../../../git/remote' import type { ResolvedRuntimeGitWorktree } from './runtime-git-command-target' import { RuntimeGitCommands } from './orca-runtime-git' -import { SSH_HOST_NOT_SERVED_MESSAGE } from '../providers/ssh-host-not-served-error' +import { SSH_HOST_NOT_SERVED_MESSAGE } from '../../../providers/ssh-host-not-served-error' const mocks = vi.hoisted(() => ({ getStatus: vi.fn(), @@ -12,18 +12,18 @@ const mocks = vi.hoisted(() => ({ stageFile: vi.fn() })) -vi.mock('../git/source-control/status-read', async (importOriginal) => ({ +vi.mock('../../../git/source-control/status-read', async (importOriginal) => ({ ...(await importOriginal>()), getStatus: mocks.getStatus })) -vi.mock('../git/source-control/staging', async (importOriginal) => ({ +vi.mock('../../../git/source-control/staging', async (importOriginal) => ({ ...(await importOriginal>()), stageFile: mocks.stageFile })) -vi.mock('../git/remote', async () => ({ - ...(await vi.importActual('../git/remote')), +vi.mock('../../../git/remote', async () => ({ + ...(await vi.importActual('../../../git/remote')), gitFetch: mocks.gitFetch })) diff --git a/src/main/runtime/runtime-git-generation-admission.test.ts b/src/main/runtime/integrations/git/runtime-git-generation-admission.test.ts similarity index 93% rename from src/main/runtime/runtime-git-generation-admission.test.ts rename to src/main/runtime/integrations/git/runtime-git-generation-admission.test.ts index ec7f8ebd9ea..475e028a79c 100644 --- a/src/main/runtime/runtime-git-generation-admission.test.ts +++ b/src/main/runtime/integrations/git/runtime-git-generation-admission.test.ts @@ -1,6 +1,6 @@ import { setImmediate as nextTurn } from 'node:timers/promises' import { beforeEach, describe, expect, it, vi } from 'vitest' -import type { GlobalSettings } from '../../shared/global-settings-types' +import type { GlobalSettings } from '../../../../shared/global-settings-types' import type { RuntimeGitCommandHost, RuntimeGitTarget } from './runtime-git-command-target' const mocks = vi.hoisted(() => ({ @@ -16,35 +16,35 @@ const mocks = vi.hoisted(() => ({ const linkedLookup = vi.hoisted(() => ({ run: (): Promise => Promise.resolve(null) })) -vi.mock('../git/source-control/staged-commit-context', () => ({ +vi.mock('../../../git/source-control/staged-commit-context', () => ({ getStagedCommitContext: mocks.getStagedCommitContext })) -vi.mock('../git/command-runner/git-exec-file', async (importOriginal) => ({ +vi.mock('../../../git/command-runner/git-exec-file', async (importOriginal) => ({ ...(await importOriginal>()), gitExecFileAsync: mocks.gitExecFileAsync })) -vi.mock('../text-generation/pull-request-context', () => ({ +vi.mock('../../../text-generation/pull-request-context', () => ({ getPullRequestDraftContext: mocks.getPullRequestDraftContext })) -vi.mock('../source-control/pull-request-linked-issue', () => ({ +vi.mock('../../../source-control/pull-request-linked-issue', () => ({ loadPullRequestLinkedIssue: (...args: unknown[]) => { mocks.loadPullRequestLinkedIssue(...args) // A mock return observer would handle the rejection being tested. return linkedLookup.run() } })) -vi.mock('../text-generation/commit-message-agent-environment', () => ({ +vi.mock('../../../text-generation/commit-message-agent-environment', () => ({ prepareLocalCommitMessageAgentEnv: mocks.prepareLocalCommitMessageAgentEnv })) -vi.mock('../text-generation/commit-message-text-generation', () => ({ +vi.mock('../../../text-generation/commit-message-text-generation', () => ({ generateCommitMessageFromContext: mocks.generateCommitMessageFromContext, generatePullRequestFieldsFromContext: mocks.generatePullRequestFieldsFromContext })) -vi.mock('../source-control/pull-request-template', () => ({ +vi.mock('../../../source-control/pull-request-template', () => ({ resolveHostedReviewBodyForGeneration: mocks.resolveHostedReviewBodyForGeneration })) -import { SSH_HOST_NOT_SERVED_MESSAGE } from '../providers/ssh-host-not-served-error' +import { SSH_HOST_NOT_SERVED_MESSAGE } from '../../../providers/ssh-host-not-served-error' import { RuntimeGitGenerationCommands } from './runtime-git-generation-commands' const params = { agentId: 'codex' as const, model: 'gpt-5.5' } diff --git a/src/main/runtime/runtime-git-generation-commands.ts b/src/main/runtime/integrations/git/runtime-git-generation-commands.ts similarity index 84% rename from src/main/runtime/runtime-git-generation-commands.ts rename to src/main/runtime/integrations/git/runtime-git-generation-commands.ts index 86841d754b8..a3f9b709e20 100644 --- a/src/main/runtime/runtime-git-generation-commands.ts +++ b/src/main/runtime/integrations/git/runtime-git-generation-commands.ts @@ -1,29 +1,31 @@ import { textGenerationFailure, textGenerationFailureCodeFields -} from '../../shared/text-generation-failure-copy' -import type { CommitMessageDraftContext } from '../../shared/source-control/ai/generation/commit-message-generation' -import { getCommitMessageModelDiscoveryHostKey } from '../../shared/source-control/ai/generation/commit-message-host-key' -import type { HostedReviewProvider } from '../../shared/source-control/hosted-review/hosted-review-contracts' -import { withLinkedIssueDraftContext } from '../../shared/source-control/ai/recipes/source-control-ai-action-variables' -import type { TuiAgent } from '../../shared/agent-launch/catalog/tui-agent' -import { getStagedCommitContext } from '../git/source-control/staged-commit-context' -import { SSH_HOST_NOT_SERVED_MESSAGE } from '../providers/ssh-host-not-served-error' -import { loadPullRequestLinkedIssue } from '../source-control/pull-request-linked-issue' -import { resolveHostedReviewBodyForGeneration } from '../source-control/pull-request-template' -import { prepareLocalCommitMessageAgentEnv } from '../text-generation/commit-message-agent-environment' +} from '../../../../shared/text-generation-failure-copy' +import type { CommitMessageDraftContext } from '../../../../shared/source-control/ai/generation/commit-message-generation' +import { getCommitMessageModelDiscoveryHostKey } from '../../../../shared/source-control/ai/generation/commit-message-host-key' +import type { HostedReviewProvider } from '../../../../shared/source-control/hosted-review/hosted-review-contracts' +import { withLinkedIssueDraftContext } from '../../../../shared/source-control/ai/recipes/source-control-ai-action-variables' +import type { TuiAgent } from '../../../../shared/agent-launch/catalog/tui-agent' +import { getStagedCommitContext } from '../../../git/source-control/staged-commit-context' +import { SSH_HOST_NOT_SERVED_MESSAGE } from '../../../providers/ssh-host-not-served-error' +import { loadPullRequestLinkedIssue } from '../../../source-control/pull-request-linked-issue' +import { resolveHostedReviewBodyForGeneration } from '../../../source-control/pull-request-template' +import { prepareLocalCommitMessageAgentEnv } from '../../../text-generation/commit-message-agent-environment' import { cancelGenerateCommitMessageLocal, cancelGeneratePullRequestFieldsLocal, discoverCommitMessageModelsLocal, generateCommitMessageFromContext, generatePullRequestFieldsFromContext, - resolveCommitMessageSettings, - type DiscoverCommitMessageModelsResult, - type GenerateCommitMessageResult, - type GeneratePullRequestFieldsResult -} from '../text-generation/commit-message-text-generation' -import { getPullRequestDraftContext } from '../text-generation/pull-request-context' + resolveCommitMessageSettings +} from '../../../text-generation/commit-message-text-generation' +import type { + DiscoverCommitMessageModelsResult, + GenerateCommitMessageResult +} from '../../../text-generation/source-control-text-generation-types' +import type { GeneratePullRequestFieldsResult } from '../../../text-generation/commit-message-text-generation' +import { getPullRequestDraftContext } from '../../../text-generation/pull-request-context' import { localGitOptionsForTarget, runtimeGitRouteForTarget, diff --git a/src/main/runtime/runtime-git-generation-context.ts b/src/main/runtime/integrations/git/runtime-git-generation-context.ts similarity index 79% rename from src/main/runtime/runtime-git-generation-context.ts rename to src/main/runtime/integrations/git/runtime-git-generation-context.ts index 8edf74e2006..defe825d5b8 100644 --- a/src/main/runtime/runtime-git-generation-context.ts +++ b/src/main/runtime/integrations/git/runtime-git-generation-context.ts @@ -1,15 +1,15 @@ -import type { GlobalSettings } from '../../shared/global-settings-types' -import { gitExecFileAsync } from '../git/runner' -import type { getPullRequestDraftContext } from '../text-generation/pull-request-context' -import { mergeLegacyCommitMessageAiIntoSourceControlAi } from '../../shared/source-control/ai/settings/source-control-ai-legacy-reconciliation' +import type { GlobalSettings } from '../../../../shared/global-settings-types' +import { gitExecFileAsync } from '../../../git/command-runner/git-exec-file' +import type { getPullRequestDraftContext } from '../../../text-generation/pull-request-context' +import { mergeLegacyCommitMessageAiIntoSourceControlAi } from '../../../../shared/source-control/ai/settings/source-control-ai-legacy-reconciliation' import type { SourceControlAiSettingsInput, ResolvedSourceControlAiGenerationParams -} from '../../shared/source-control/ai/source-control-ai-operation-resolution' -import type { SourceControlAiOperation } from '../../shared/source-control/ai/settings/source-control-ai-settings-types' -import type { CommitMessageAgentRuntimeTarget } from '../text-generation/commit-message-agent-environment' -import type { CommitMessageGenerationTarget } from '../text-generation/commit-message-text-generation' -import type { PullRequestLinkedIssueMeta } from '../source-control/pull-request-linked-issue' +} from '../../../../shared/source-control/ai/source-control-ai-operation-resolution' +import type { SourceControlAiOperation } from '../../../../shared/source-control/ai/settings/source-control-ai-settings-types' +import type { CommitMessageAgentRuntimeTarget } from '../../../text-generation/commit-message-agent-environment' +import type { CommitMessageGenerationTarget } from '../../../text-generation/source-control-text-generation-types' +import type { PullRequestLinkedIssueMeta } from '../../../source-control/pull-request-linked-issue' import { localGitOptionsForTarget, type RuntimeGitCommandHost, diff --git a/src/main/runtime/runtime-git-stage-worktree-scope.test.ts b/src/main/runtime/integrations/git/runtime-git-stage-worktree-scope.test.ts similarity index 95% rename from src/main/runtime/runtime-git-stage-worktree-scope.test.ts rename to src/main/runtime/integrations/git/runtime-git-stage-worktree-scope.test.ts index 53fe2266176..9d685553310 100644 --- a/src/main/runtime/runtime-git-stage-worktree-scope.test.ts +++ b/src/main/runtime/integrations/git/runtime-git-stage-worktree-scope.test.ts @@ -1,12 +1,12 @@ -import './rpc/unused-default-rpc-methods.test-fixture' +import '../../rpc/unused-default-rpc-methods.test-fixture' import { execFileSync } from 'node:child_process' import { mkdir, mkdtemp, rm, symlink, writeFile } from 'node:fs/promises' import { tmpdir } from 'node:os' import * as path from 'node:path' import { afterEach, describe, expect, it, vi } from 'vitest' -import type { OrcaRuntimeService } from './orca-runtime' -import { RpcDispatcher } from './rpc/dispatcher' -import { GIT_METHODS } from './rpc/methods/git' +import type { OrcaRuntimeService } from '../../orca-runtime' +import { RpcDispatcher } from '../../rpc/dispatcher' +import { GIT_METHODS } from '../../rpc/methods/git' import { RuntimeGitStagingCommands } from './runtime-git-staging-commands' import type * as RuntimeGitCommandTarget from './runtime-git-command-target' import type { RuntimeGitCommandHost } from './runtime-git-command-target' diff --git a/src/main/runtime/runtime-git-staging-commands.ts b/src/main/runtime/integrations/git/runtime-git-staging-commands.ts similarity index 95% rename from src/main/runtime/runtime-git-staging-commands.ts rename to src/main/runtime/integrations/git/runtime-git-staging-commands.ts index 8fdc1d10920..8a7bda327d9 100644 --- a/src/main/runtime/runtime-git-staging-commands.ts +++ b/src/main/runtime/integrations/git/runtime-git-staging-commands.ts @@ -1,13 +1,13 @@ import type { GitStageWorktreeScope, GitStageWorktreeScopeReceipt -} from '../../shared/git/paths/git-stage-worktree-scope' +} from '../../../../shared/git/paths/git-stage-worktree-scope' import { normalizeRuntimeGitRelativePath, requireRuntimeGitProvider, type RuntimeGitCommandHost } from './runtime-git-command-target' -import type { ConflictResolution } from '../../shared/source-control/listing/source-control-entry-actions' +import type { ConflictResolution } from '../../../../shared/source-control/listing/source-control-entry-actions' export class RuntimeGitStagingCommands { constructor(private readonly host: RuntimeGitCommandHost) {} diff --git a/src/main/runtime/runtime-git-status-commands.ts b/src/main/runtime/integrations/git/runtime-git-status-commands.ts similarity index 87% rename from src/main/runtime/runtime-git-status-commands.ts rename to src/main/runtime/integrations/git/runtime-git-status-commands.ts index ea95e098288..54e7e819f5b 100644 --- a/src/main/runtime/runtime-git-status-commands.ts +++ b/src/main/runtime/integrations/git/runtime-git-status-commands.ts @@ -1,16 +1,19 @@ import type { GitHistoryOptions, GitHistoryResult -} from '../../shared/git/history/git-history-types' -import type { GitMutationInFlight } from '../../shared/git/commands/git-mutation-in-flight' -import { isGitWorktreeMutationInFlight } from '../git/command-runner/git-worktree-mutation-state' +} from '../../../../shared/git/history/git-history-types' +import type { GitMutationInFlight } from '../../../../shared/git/commands/git-mutation-in-flight' +import { isGitWorktreeMutationInFlight } from '../../../git/command-runner/git-worktree-mutation-state' import type { GitConflictOperation, GitStagingArea, GitStatusResult -} from '../../shared/git/status/git-status-types' -import type { RuntimeGitCheckoutResult, RuntimeGitLocalBranches } from '../../shared/runtime-types' -import type { GitProviderStatusOptions } from '../providers/git-provider-contract' +} from '../../../../shared/git/status/git-status-types' +import type { + RuntimeGitCheckoutResult, + RuntimeGitLocalBranches +} from '../../../../shared/runtime-worktree-contracts' +import type { GitProviderStatusOptions } from '../../../providers/git-provider-status-options' import { localGitOptionsForTarget, requireLocalRuntimeGitRoute, diff --git a/src/main/runtime/runtime-git-sync-commands.test.ts b/src/main/runtime/integrations/git/runtime-git-sync-commands.test.ts similarity index 72% rename from src/main/runtime/runtime-git-sync-commands.test.ts rename to src/main/runtime/integrations/git/runtime-git-sync-commands.test.ts index b7d0d8eccb9..20518f01e7d 100644 --- a/src/main/runtime/runtime-git-sync-commands.test.ts +++ b/src/main/runtime/integrations/git/runtime-git-sync-commands.test.ts @@ -1,12 +1,12 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' -import type { GlobalSettings } from '../../shared/global-settings-types' -import type { GitPushTarget } from '../../shared/worktree/types' -import type * as GitRemoteModule from '../git/remote' +import type { GlobalSettings } from '../../../../shared/global-settings-types' +import type { GitPushTarget } from '../../../../shared/worktree/types' +import type * as GitRemoteModule from '../../../git/remote' -import type * as GitForkSyncModule from '../git/fork-sync' +import type * as GitForkSyncModule from '../../../git/fork-sync' import type { ResolvedRuntimeGitWorktree } from './runtime-git-command-target' import { RuntimeGitSyncCommands } from './runtime-git-sync-commands' -import { SshHostNotServedError } from '../providers/ssh-host-not-served-error' +import { SshHostNotServedError } from '../../../providers/ssh-host-not-served-error' const mocks = vi.hoisted(() => ({ abortMerge: vi.fn(), @@ -18,24 +18,24 @@ const mocks = vi.hoisted(() => ({ gitPull: vi.fn() })) -vi.mock('../git/fork-sync', async () => ({ - ...(await vi.importActual('../git/fork-sync')), +vi.mock('../../../git/fork-sync', async () => ({ + ...(await vi.importActual('../../../git/fork-sync')), gitSyncForkDefaultBranch: mocks.gitSyncForkDefaultBranch })) -vi.mock('../git/source-control/git-conflict-operation', async (importOriginal) => ({ +vi.mock('../../../git/source-control/git-conflict-operation', async (importOriginal) => ({ ...(await importOriginal>()), abortMerge: mocks.abortMerge, abortRebase: mocks.abortRebase })) -vi.mock('../git/source-control/commit-changes', async (importOriginal) => ({ +vi.mock('../../../git/source-control/commit-changes', async (importOriginal) => ({ ...(await importOriginal>()), commitChanges: mocks.commitChanges })) -vi.mock('../git/remote', async () => ({ - ...(await vi.importActual('../git/remote')), +vi.mock('../../../git/remote', async () => ({ + ...(await vi.importActual('../../../git/remote')), gitFastForward: mocks.gitFastForward, gitFetch: mocks.gitFetch, gitPull: mocks.gitPull diff --git a/src/main/runtime/runtime-git-sync-commands.ts b/src/main/runtime/integrations/git/runtime-git-sync-commands.ts similarity index 93% rename from src/main/runtime/runtime-git-sync-commands.ts rename to src/main/runtime/integrations/git/runtime-git-sync-commands.ts index 863c918e98e..c1bd0a63059 100644 --- a/src/main/runtime/runtime-git-sync-commands.ts +++ b/src/main/runtime/integrations/git/runtime-git-sync-commands.ts @@ -1,12 +1,12 @@ import type { GitForkSyncExpectedUpstream, GitForkSyncResult -} from '../../shared/git/remotes/git-fork-sync' -import type { GitUpstreamStatus } from '../../shared/git/status/git-status-types' -import type { GitPushTarget } from '../../shared/worktree/types' -import { materializeWorktreePushTargetRemote } from '../ipc/worktree-remote' +} from '../../../../shared/git/remotes/git-fork-sync' +import type { GitUpstreamStatus } from '../../../../shared/git/status/git-status-types' +import type { GitPushTarget } from '../../../../shared/worktree/types' +import { materializeWorktreePushTargetRemote } from '../../../ipc/worktree-remote' import { assertRuntimeReadWslDistroRunning } from './runtime-wsl-background-read-gate' -import type { LocalGitProvider } from '../providers/local-git-provider' +import type { LocalGitProvider } from '../../../providers/local-git-provider' import { localGitOptionsForTarget, requireRuntimeGitProvider, diff --git a/src/main/runtime/runtime-git-target-execution-host.test.ts b/src/main/runtime/integrations/git/runtime-git-target-execution-host.test.ts similarity index 92% rename from src/main/runtime/runtime-git-target-execution-host.test.ts rename to src/main/runtime/integrations/git/runtime-git-target-execution-host.test.ts index b4ca74e51e6..d060bac3f68 100644 --- a/src/main/runtime/runtime-git-target-execution-host.test.ts +++ b/src/main/runtime/integrations/git/runtime-git-target-execution-host.test.ts @@ -10,14 +10,14 @@ vi.mock('electron', () => ({ const mocks = vi.hoisted(() => ({ getStatus: vi.fn() })) -vi.mock('../git/source-control/status-read', async (importOriginal) => ({ +vi.mock('../../../git/source-control/status-read', async (importOriginal) => ({ ...(await importOriginal>()), getStatus: mocks.getStatus })) -import { ExecutionHostNotDispatchableError } from '../providers/execution-host-provider-dispatch' -import { SshHostNotServedError } from '../providers/ssh-host-not-served-error' -import { OrcaRuntimeService } from './orca-runtime' +import { ExecutionHostNotDispatchableError } from '../../../providers/execution-host-provider-dispatch' +import { SshHostNotServedError } from '../../../providers/ssh-host-not-served-error' +import { OrcaRuntimeService } from '../../orca-runtime' const REMOTE_PATH = '/srv/app-feature' const WORKTREE_ID = 'repo-shared::/srv/app-feature' diff --git a/src/main/runtime/runtime-wsl-background-read-gate.ts b/src/main/runtime/integrations/git/runtime-wsl-background-read-gate.ts similarity index 84% rename from src/main/runtime/runtime-wsl-background-read-gate.ts rename to src/main/runtime/integrations/git/runtime-wsl-background-read-gate.ts index f4e5c7a0b15..c98b801bc08 100644 --- a/src/main/runtime/runtime-wsl-background-read-gate.ts +++ b/src/main/runtime/integrations/git/runtime-wsl-background-read-gate.ts @@ -1,5 +1,5 @@ -import { LOCAL_EXECUTION_HOST_ID, type ExecutionHostId } from '../../shared/execution-host' -import { assertWslUncPathRunning } from '../wsl/filesystem/wsl-unc-access-gate' +import { LOCAL_EXECUTION_HOST_ID, type ExecutionHostId } from '../../../../shared/execution-host' +import { assertWslUncPathRunning } from '../../../wsl/filesystem/wsl-unc-access-gate' /** * Paired phone, web and CLI clients poll Git followers no user is looking at; a stopped distro diff --git a/src/main/runtime/runtime-github-issue-comment-commands.ts b/src/main/runtime/integrations/github/runtime-github-issue-comment-commands.ts similarity index 78% rename from src/main/runtime/runtime-github-issue-comment-commands.ts rename to src/main/runtime/integrations/github/runtime-github-issue-comment-commands.ts index 939217e9aa6..553180ef57b 100644 --- a/src/main/runtime/runtime-github-issue-comment-commands.ts +++ b/src/main/runtime/integrations/github/runtime-github-issue-comment-commands.ts @@ -1,16 +1,20 @@ -import type { GitHubCreateIssueFields, GitHubIssueUpdate } from '../../shared/issue-mutation-types' -import type { GitHubOwnerRepo } from '../../shared/github/pull-request-types' -import type { GitHubPRReviewCommentInput } from '../../shared/github/comment-types' -import type { Repo } from '../../shared/repo-types' -import type { LocalProjectGhExecOptions } from '../workspaces/execution-host/project-runtime-git-options' +import '../../../github/rate-limit' +import type { + GitHubCreateIssueFields, + GitHubIssueUpdate +} from '../../../../shared/issue-mutation-types' +import type { GitHubOwnerRepo } from '../../../../shared/github/pull-request-types' +import type { GitHubPRReviewCommentInput } from '../../../../shared/github/comment-types' +import type { Repo } from '../../../../shared/repo-types' +import type { LocalProjectGhExecOptions } from '../../../workspaces/execution-host/project-runtime-git-options' +import { addIssueComment } from '../../../github/issue-comment' import { - addIssueComment, addPRReviewComment, - addPRReviewCommentReply, - createIssue, - updateIssue -} from '../github/client' -import { getRepoRoutingConnectionId } from '../../shared/execution-host' + addPRReviewCommentReply +} from '../../../github/client/create/add-pr-review-comment' +import { createIssue } from '../../../github/issue-create' +import { updateIssue } from '../../../github/issue-update' +import { getRepoRoutingConnectionId } from '../../../../shared/execution-host' type LocalGitArgs = [] | [LocalProjectGhExecOptions] diff --git a/src/main/runtime/runtime-github-project-commands.ts b/src/main/runtime/integrations/github/runtime-github-project-commands.ts similarity index 69% rename from src/main/runtime/runtime-github-project-commands.ts rename to src/main/runtime/integrations/github/runtime-github-project-commands.ts index 9b9d283e6e8..6ca90af4da3 100644 --- a/src/main/runtime/runtime-github-project-commands.ts +++ b/src/main/runtime/integrations/github/runtime-github-project-commands.ts @@ -1,21 +1,25 @@ import { addIssueCommentBySlug, - clearProjectItemFieldValue, deleteIssueCommentBySlug, - getProjectViewTable, - getWorkItemDetailsBySlug, - listAccessibleProjects, + updateIssueCommentBySlug +} from '../../../github/project-view/issue-comment-mutations' +import { + clearProjectItemFieldValue, + updateProjectItemFieldValue +} from '../../../github/project-view/project-field-mutations' +import { getProjectViewTable } from '../../../github/project-view/project-view-table' +import { getWorkItemDetailsBySlug } from '../../../github/project-view/work-item-details' +import { listAccessibleProjects } from '../../../github/project-view/project-view-discovery' +import { listAssignableUsersBySlug, listIssueTypesBySlug, - listLabelsBySlug, - listProjectViews, - resolveProjectRef, - updateIssueBySlug, - updateIssueCommentBySlug, - updateIssueTypeBySlug, - updateProjectItemFieldValue, - updatePullRequestBySlug -} from '../github/project-view' + listLabelsBySlug +} from '../../../github/project-view/repository-field-options' +import { listProjectViews } from '../../../github/project-view/project-view-listing' +import { resolveProjectRef } from '../../../github/project-view/project-view-reference' +import { updateIssueBySlug } from '../../../github/project-view/mutations' +import { updateIssueTypeBySlug } from '../../../github/project-view/issue-type-mutation' +import { updatePullRequestBySlug } from '../../../github/project-view/pull-request-mutation' import type { AddIssueCommentBySlugArgs, ClearProjectItemFieldArgs, @@ -33,7 +37,7 @@ import type { UpdateIssueTypeBySlugArgs, UpdateProjectItemFieldArgs, UpdatePullRequestBySlugArgs -} from '../../shared/github/project-request-types' +} from '../../../../shared/github/project-request-types' export class RuntimeGitHubProjectCommands { listGitHubProjects(args?: ListAccessibleProjectsArgs) { diff --git a/src/main/runtime/runtime-github-repository-query-commands.test.ts b/src/main/runtime/integrations/github/runtime-github-repository-query-commands.test.ts similarity index 77% rename from src/main/runtime/runtime-github-repository-query-commands.test.ts rename to src/main/runtime/integrations/github/runtime-github-repository-query-commands.test.ts index 73129a33cd2..0fa5aa1ef58 100644 --- a/src/main/runtime/runtime-github-repository-query-commands.test.ts +++ b/src/main/runtime/integrations/github/runtime-github-repository-query-commands.test.ts @@ -1,16 +1,19 @@ -import './rpc/unused-default-rpc-methods.test-fixture' -import type * as GitHubClient from '../github/client' +import '../../rpc/unused-default-rpc-methods.test-fixture' +import type * as GitHubClient from '../../../github/client' import { describe, expect, it, vi } from 'vitest' -import { RpcDispatcher } from './rpc/dispatcher' -import { GITHUB_REPO_WORK_ITEM_METHODS } from './rpc/methods/github-repo-work-item-methods' +import { RpcDispatcher } from '../../rpc/dispatcher' +import { GITHUB_REPO_WORK_ITEM_METHODS } from '../../rpc/methods/github-repo-work-item-methods' import { RuntimeGitHubRepositoryQueryCommands } from './runtime-github-repository-query-commands' -import { OrcaRuntimeService } from './orca-runtime' -import type { Repo } from '../../shared/repo-types' -import { WorkItemDetails, WorkItem } from '../../shared/rpc-contract/github-repo-work-item-params' -import { RPC_PARAMS_BY_METHOD } from '../../shared/rpc-contract/rpc-params-catalog.generated' +import { OrcaRuntimeService } from '../../orca-runtime' +import type { Repo } from '../../../../shared/repo-types' +import { + WorkItemDetails, + WorkItem +} from '../../../../shared/rpc-contract/github-repo-work-item-params' +import { RPC_PARAMS_BY_METHOD } from '../../../../shared/rpc-contract/rpc-params-catalog.generated' const { read } = vi.hoisted(() => ({ read: vi.fn().mockResolvedValue(null) })) -vi.mock('../github/work-item-details', () => ({ getWorkItemDetails: read })) -vi.mock('../github/client', async (original) => ({ +vi.mock('../../../github/work-item-details', () => ({ getWorkItemDetails: read })) +vi.mock('../../../github/client', async (original) => ({ ...(await original()), countWorkItems: vi.fn(), getWorkItem: vi.fn(), @@ -20,12 +23,12 @@ vi.mock('../github/client', async (original) => ({ listLabels: vi.fn(), listWorkItems: vi.fn() })) -vi.mock('../github/gh-account-binding-inventory', () => ({ +vi.mock('../../../github/gh-account-binding-inventory', () => ({ listGhAccountBindingInventory: vi.fn(), validateGhAccountBinding: vi.fn() })) -vi.mock('../github/rate-limit', () => ({ getRateLimit: vi.fn() })) -vi.mock('../github/account-binding-required-host', () => ({ +vi.mock('../../../github/rate-limit', () => ({ getRateLimit: vi.fn() })) +vi.mock('../../../github/account-binding-required-host', () => ({ resolveGhAccountRequiredHost: vi.fn() })) diff --git a/src/main/runtime/runtime-github-repository-query-commands.ts b/src/main/runtime/integrations/github/runtime-github-repository-query-commands.ts similarity index 83% rename from src/main/runtime/runtime-github-repository-query-commands.ts rename to src/main/runtime/integrations/github/runtime-github-repository-query-commands.ts index 8ad74b5622c..9f940082a59 100644 --- a/src/main/runtime/runtime-github-repository-query-commands.ts +++ b/src/main/runtime/integrations/github/runtime-github-repository-query-commands.ts @@ -1,26 +1,22 @@ -import type { GhAccountBinding } from '../../shared/github/account-binding' -import type { GitHubOwnerRepo } from '../../shared/github/pull-request-types' -import type { ListWorkItemsResult } from '../../shared/github/work-item-types' -import type { Repo } from '../../shared/repo-types' -import type { LocalProjectGhExecOptions } from '../workspaces/execution-host/project-runtime-git-options' -import { - countWorkItems, - getWorkItem, - getWorkItemByOwnerRepo, - listAssignableUsers, - listIssues, - listLabels, - listWorkItems, - type MainWorkItem -} from '../github/client' +import type { GhAccountBinding } from '../../../../shared/github/account-binding' +import type { GitHubOwnerRepo } from '../../../../shared/github/pull-request-types' +import type { ListWorkItemsResult } from '../../../../shared/github/work-item-types' +import type { Repo } from '../../../../shared/repo-types' +import type { LocalProjectGhExecOptions } from '../../../workspaces/execution-host/project-runtime-git-options' +import { countWorkItems } from '../../../github/client/list/count-work-items' +import { getWorkItem, getWorkItemByOwnerRepo } from '../../../github/client/fetch/get-work-item' +import { listAssignableUsers, listLabels } from '../../../github/issue-field-options' +import { listIssues } from '../../../github/issues' +import { listWorkItems } from '../../../github/client/list/list-work-items' +import type { MainWorkItem } from '../../../github/client/map/work-item-field-coercion' import { listGhAccountBindingInventory, validateGhAccountBinding -} from '../github/gh-account-binding-inventory' -import { getRateLimit } from '../github/rate-limit' -import { resolveGhAccountRequiredHost } from '../github/account-binding-required-host' -import { getWorkItemDetails } from '../github/work-item-details' -import { getRepoRoutingConnectionId } from '../../shared/execution-host' +} from '../../../github/gh-account-binding-inventory' +import { getRateLimit } from '../../../github/rate-limit' +import { resolveGhAccountRequiredHost } from '../../../github/account-binding-required-host' +import { getWorkItemDetails } from '../../../github/work-item-details' +import { getRepoRoutingConnectionId } from '../../../../shared/execution-host' type LocalGitArgs = [] | [LocalProjectGhExecOptions] diff --git a/src/main/runtime/runtime-github-review-mutation-commands.ts b/src/main/runtime/integrations/github/runtime-github-review-mutation-commands.ts similarity index 81% rename from src/main/runtime/runtime-github-review-mutation-commands.ts rename to src/main/runtime/integrations/github/runtime-github-review-mutation-commands.ts index 5a9baf70768..74678a15ac0 100644 --- a/src/main/runtime/runtime-github-review-mutation-commands.ts +++ b/src/main/runtime/integrations/github/runtime-github-review-mutation-commands.ts @@ -1,25 +1,20 @@ -import type { GhAccountBinding } from '../../shared/github/account-binding' -import type { GitHubOwnerRepo } from '../../shared/github/pull-request-types' -import type { GitHubPullRequestStateUpdate } from '../../shared/issue-mutation-types' -import type { GitHubReactionContent } from '../../shared/github/comment-types' -import type { Repo } from '../../shared/repo-types' -import type { LocalProjectGhExecOptions } from '../workspaces/execution-host/project-runtime-git-options' -import { - mergePR, - markPRDraft, - markPRReadyForReview, - removePRReviewers, - requestPRReviewers, - rerunPRChecks, - resolveReviewThread, - setPRAutoMerge, - setPRCommentReaction, - setPRFileViewed, - updatePRDetails, - updatePRState, - updatePRTitle -} from '../github/client' -import { getRepoRoutingConnectionId } from '../../shared/execution-host' +import type { GhAccountBinding } from '../../../../shared/github/account-binding' +import type { GitHubOwnerRepo } from '../../../../shared/github/pull-request-types' +import type { GitHubPullRequestStateUpdate } from '../../../../shared/issue-mutation-types' +import type { GitHubReactionContent } from '../../../../shared/github/comment-types' +import type { Repo } from '../../../../shared/repo-types' +import type { LocalProjectGhExecOptions } from '../../../workspaces/execution-host/project-runtime-git-options' +import { mergePR } from '../../../github/client/merge/merge-pr' +import { markPRDraft, markPRReadyForReview } from '../../../github/client/update/pr-ready' +import { removePRReviewers, requestPRReviewers } from '../../../github/client/update/pr-reviewers' +import { rerunPRChecks } from '../../../github/client/check/rerun-pr-checks' +import { resolveReviewThread } from '../../../github/client/update/resolve-review-thread' +import { setPRAutoMerge } from '../../../github/client/merge/pr-auto-merge' +import { setPRCommentReaction } from '../../../github/client/update/pr-comment-reaction' +import { setPRFileViewed } from '../../../github/client/update/pr-file-viewed' +import { updatePRDetails, updatePRTitle } from '../../../github/client/update/pr-details' +import { updatePRState } from '../../../github/client/update/pr-state' +import { getRepoRoutingConnectionId } from '../../../../shared/execution-host' type LocalGitArgs = [] | [LocalProjectGhExecOptions] diff --git a/src/main/runtime/runtime-github-review-query-commands.ts b/src/main/runtime/integrations/github/runtime-github-review-query-commands.ts similarity index 80% rename from src/main/runtime/runtime-github-review-query-commands.ts rename to src/main/runtime/integrations/github/runtime-github-review-query-commands.ts index d4008431aba..36504aa8e11 100644 --- a/src/main/runtime/runtime-github-review-query-commands.ts +++ b/src/main/runtime/integrations/github/runtime-github-review-query-commands.ts @@ -1,9 +1,12 @@ -import type { GitHubOwnerRepo, GitHubPRFile } from '../../shared/github/pull-request-types' -import type { Repo } from '../../shared/repo-types' -import type { LocalProjectGhExecOptions } from '../workspaces/execution-host/project-runtime-git-options' -import { getIssue, getPRCheckDetails, getPRChecks, getPRComments } from '../github/client' -import { getPRFileContents } from '../github/work-item-details' -import { getRepoRoutingConnectionId } from '../../shared/execution-host' +import type { GitHubOwnerRepo, GitHubPRFile } from '../../../../shared/github/pull-request-types' +import type { Repo } from '../../../../shared/repo-types' +import type { LocalProjectGhExecOptions } from '../../../workspaces/execution-host/project-runtime-git-options' +import { getIssue } from '../../../github/issues' +import { getPRCheckDetails } from '../../../github/client/check/get-pr-check-details' +import { getPRChecks } from '../../../github/client/check/get-pr-checks' +import { getPRComments } from '../../../github/client/fetch/get-pr-comments' +import { getPRFileContents } from '../../../github/work-item-details' +import { getRepoRoutingConnectionId } from '../../../../shared/execution-host' type LocalGitArgs = [] | [LocalProjectGhExecOptions] diff --git a/src/main/runtime/runtime-github-worktree-base.ts b/src/main/runtime/integrations/github/runtime-github-worktree-base.ts similarity index 73% rename from src/main/runtime/runtime-github-worktree-base.ts rename to src/main/runtime/integrations/github/runtime-github-worktree-base.ts index 4d4675038fe..4e41d8f86b2 100644 --- a/src/main/runtime/runtime-github-worktree-base.ts +++ b/src/main/runtime/integrations/github/runtime-github-worktree-base.ts @@ -1,21 +1,21 @@ -import type { GitHubPrStartPoint } from '../../shared/worktree/types' -import type { Repo } from '../../shared/repo-types' +import type { GitHubPrStartPoint } from '../../../../shared/worktree/types' +import type { Repo } from '../../../../shared/repo-types' import { fetchPrHeadTrackingRef, fetchGitHubPullRequestHeadRef -} from '../github/pr-head-tracking-ref' -import { resolveGitHubPrStartPoint } from '../github/pr-start-point' -import { resolvePrStartPointUnlessWslStopped } from '../github/pr-start-point-wsl-gate' -import { resolveGitHubReviewHeadRemote } from '../github/review-head-remote' -import { gitExecFileAsync } from '../git/runner' +} from '../../../github/pr-head-tracking-ref' +import { resolveGitHubPrStartPoint } from '../../../github/pr-start-point' +import { resolvePrStartPointUnlessWslStopped } from '../../../github/pr-start-point-wsl-gate' +import { resolveGitHubReviewHeadRemote } from '../../../github/review-head-remote' +import { gitExecFileAsync } from '../../../git/command-runner/git-exec-file' import { getLocalProjectGitExecOptions, getLocalProjectGhExecOptions -} from '../workspaces/execution-host/project-runtime-git-options' -import { isFolderRepo } from '../../shared/repo-kind' -import { requireRepoLocalGitRoute } from '../workspaces/execution-host/repo-execution-host' -import type { ProjectRuntimeResolutionStore } from '../workspaces/execution-host/local-project-runtime-resolution' -import { reviewStartPointFailure } from '../../shared/review-start-point-failure-copy' +} from '../../../workspaces/execution-host/project-runtime-git-options' +import { isFolderRepo } from '../../../../shared/repo-kind' +import { requireRepoLocalGitRoute } from '../../../workspaces/execution-host/repo-execution-host' +import type { ProjectRuntimeResolutionStore } from '../../../workspaces/execution-host/local-project-runtime-resolution' +import { reviewStartPointFailure } from '../../../../shared/review-start-point-failure-copy' export type RuntimeGitHubWorktreeBaseArgs = { repoSelector: string diff --git a/src/main/runtime/runtime-gitlab-fork-mr-base.ts b/src/main/runtime/integrations/gitlab/runtime-gitlab-fork-mr-base.ts similarity index 88% rename from src/main/runtime/runtime-gitlab-fork-mr-base.ts rename to src/main/runtime/integrations/gitlab/runtime-gitlab-fork-mr-base.ts index b03cdc7a220..b9fe7756b98 100644 --- a/src/main/runtime/runtime-gitlab-fork-mr-base.ts +++ b/src/main/runtime/integrations/gitlab/runtime-gitlab-fork-mr-base.ts @@ -1,11 +1,11 @@ -import type { Repo } from '../../shared/repo-types' +import type { Repo } from '../../../../shared/repo-types' import { gitlabMergeRequestHeadLocalRef, reviewHeadRemoteRefComponent -} from '../../shared/review-head-tracking-ref' -import { isTransientReviewHeadFetchError } from '../git/fetch-error-classification' -import { fetchGitLabMergeRequestHeadRef } from '../gitlab/mr-head-tracking-ref' -import { reviewStartPointFailure } from '../../shared/review-start-point-failure-copy' +} from '../../../../shared/review-head-tracking-ref' +import { isTransientReviewHeadFetchError } from '../../../git/fetch-error-classification' +import { fetchGitLabMergeRequestHeadRef } from '../../../gitlab/mr-head-tracking-ref' +import { reviewStartPointFailure } from '../../../../shared/review-start-point-failure-copy' type GitExec = (args: string[]) => Promise<{ stdout: string }> export async function resolveRuntimeGitLabForkMrBase(args: { diff --git a/src/main/runtime/runtime-gitlab-issue-source-remote.ts b/src/main/runtime/integrations/gitlab/runtime-gitlab-issue-source-remote.ts similarity index 80% rename from src/main/runtime/runtime-gitlab-issue-source-remote.ts rename to src/main/runtime/integrations/gitlab/runtime-gitlab-issue-source-remote.ts index 33490b641b4..cc7a9d53ff7 100644 --- a/src/main/runtime/runtime-gitlab-issue-source-remote.ts +++ b/src/main/runtime/integrations/gitlab/runtime-gitlab-issue-source-remote.ts @@ -1,7 +1,7 @@ -import type { Repo } from '../../shared/repo-types' -import { getDefaultRemote } from '../git/repo' -import { getProjectRefForRemote } from '../gitlab/client' -import { getGlabKnownHosts } from '../gitlab/gl-utils' +import type { Repo } from '../../../../shared/repo-types' +import { getDefaultRemote } from '../../../git/repo' +import { getProjectRefForRemote } from '../../../gitlab/gitlab-project-ref-resolution' +import { getGlabKnownHosts } from '../../../gitlab/gitlab-known-host-probe' export async function resolveRuntimeGitLabIssueSourceRemote( repoPath: string, diff --git a/src/main/runtime/runtime-gitlab-mutation-commands.ts b/src/main/runtime/integrations/gitlab/runtime-gitlab-mutation-commands.ts similarity index 90% rename from src/main/runtime/runtime-gitlab-mutation-commands.ts rename to src/main/runtime/integrations/gitlab/runtime-gitlab-mutation-commands.ts index c5f80cef22d..f7d482c5162 100644 --- a/src/main/runtime/runtime-gitlab-mutation-commands.ts +++ b/src/main/runtime/integrations/gitlab/runtime-gitlab-mutation-commands.ts @@ -3,24 +3,20 @@ import type { GitLabMRInlineCommentInput, GitLabMRUpdate, GitLabProjectRef -} from '../../shared/gitlab-types' -import type { Repo } from '../../shared/repo-types' +} from '../../../../shared/gitlab-types' +import type { Repo } from '../../../../shared/repo-types' +import { addIssueComment, createIssue } from '../../../gitlab/issues' import { - addIssueComment, addMRComment, addMRInlineComment, - closeMR, - createIssue, - getJobTrace, - mergeMR, - reopenMR, resolveMRDiscussion, - retryJob, - updateIssue, - updateMR, updateMRReviewers -} from '../gitlab/client' -import { getRepoRoutingConnectionId } from '../../shared/execution-host' +} from '../../../gitlab/merge-request-review-mutations' +import { closeMR, mergeMR, reopenMR } from '../../../gitlab/merge-request-state-mutations' +import { getJobTrace, retryJob } from '../../../gitlab/pipeline-job-mutations' +import { updateIssue } from '../../../gitlab/issue-update' +import { updateMR } from '../../../gitlab/merge-request-update' +import { getRepoRoutingConnectionId } from '../../../../shared/execution-host' type LocalGitArgs = [] | [{ wslDistro?: string }] diff --git a/src/main/runtime/runtime-gitlab-query-commands.ts b/src/main/runtime/integrations/gitlab/runtime-gitlab-query-commands.ts similarity index 89% rename from src/main/runtime/runtime-gitlab-query-commands.ts rename to src/main/runtime/integrations/gitlab/runtime-gitlab-query-commands.ts index d57d0f8a325..cba928e42a0 100644 --- a/src/main/runtime/runtime-gitlab-query-commands.ts +++ b/src/main/runtime/integrations/gitlab/runtime-gitlab-query-commands.ts @@ -1,24 +1,22 @@ -import type { GitLabProjectRef, GitLabWorkItem, MRListState } from '../../shared/gitlab-types' -import type { Repo } from '../../shared/repo-types' +import type { GitLabProjectRef, GitLabWorkItem, MRListState } from '../../../../shared/gitlab-types' +import type { Repo } from '../../../../shared/repo-types' +import { diagnoseAuth, getRateLimit } from '../../../gitlab/gitlab-auth-and-rate-limit' import { - diagnoseAuth, - getRateLimit, getWorkItemByProjectRef, - listAssignableUsers, - listIssues, - listLabels, - listMergeRequests, listTodos, listWorkItems -} from '../gitlab/client' +} from '../../../gitlab/work-item-queries' +import { listAssignableUsers, listLabels } from '../../../gitlab/project-label-and-member-lookup' +import { listIssues } from '../../../gitlab/issues' +import { listMergeRequests } from '../../../gitlab/merge-request-list' import { normalizeGitLabIssueListArgs, normalizeGitLabMRListState, normalizeGitLabPositiveInteger, type GitLabIssueListState -} from '../gitlab/gitlab-preload-args' -import { getWorkItemDetails } from '../gitlab/work-item-details' -import { getRepoRoutingConnectionId } from '../../shared/execution-host' +} from '../../../gitlab/gitlab-preload-args' +import { getWorkItemDetails } from '../../../gitlab/work-item-details' +import { getRepoRoutingConnectionId } from '../../../../shared/execution-host' type LocalGitArgs = [] | [{ wslDistro?: string }] diff --git a/src/main/runtime/runtime-gitlab-worktree-base-wsl-gate.test.ts b/src/main/runtime/integrations/gitlab/runtime-gitlab-worktree-base-wsl-gate.test.ts similarity index 84% rename from src/main/runtime/runtime-gitlab-worktree-base-wsl-gate.test.ts rename to src/main/runtime/integrations/gitlab/runtime-gitlab-worktree-base-wsl-gate.test.ts index 0817ea7e830..6a543846ab4 100644 --- a/src/main/runtime/runtime-gitlab-worktree-base-wsl-gate.test.ts +++ b/src/main/runtime/integrations/gitlab/runtime-gitlab-worktree-base-wsl-gate.test.ts @@ -1,9 +1,9 @@ -import './rpc/unused-default-rpc-methods.test-fixture' +import '../../rpc/unused-default-rpc-methods.test-fixture' import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as DistroGateModule from '../wsl/discovery/wsl-background-distro-gate' -import type { Repo } from '../../shared/repo-types' -import type { RpcRequest } from './rpc/core' -import type { OrcaRuntimeService } from './orca-runtime' +import type * as DistroGateModule from '../../../wsl/discovery/wsl-background-distro-gate' +import type { Repo } from '../../../../shared/repo-types' +import type { RpcRequest } from '../../rpc/core' +import type { OrcaRuntimeService } from '../../orca-runtime' const mocks = vi.hoisted(() => { const state: { distro: 'running' | 'stopped' } = { distro: 'stopped' } @@ -14,11 +14,11 @@ const mocks = vi.hoisted(() => { }) } }) -vi.mock('../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ +vi.mock('../../../wsl/discovery/wsl-background-distro-gate', async (importOriginal) => ({ ...(await importOriginal()), readWslDistroRunningState: vi.fn(async () => mocks.state.distro) })) -vi.mock('../workspaces/execution-host/project-runtime-git-options', () => ({ +vi.mock('../../../workspaces/execution-host/project-runtime-git-options', () => ({ getLocalProjectGitExecOptions: () => ({}), getLocalProjectWorktreeGitOptions: () => ({}) })) @@ -27,8 +27,8 @@ vi.mock('./runtime-gitlab-issue-source-remote', () => ({ })) import { resolveRuntimeGitLabWorktreeBase } from './runtime-gitlab-worktree-base' -import { RpcDispatcher } from './rpc/dispatcher' -import { WORKTREE_METHODS } from './rpc/methods/worktree' +import { RpcDispatcher } from '../../rpc/dispatcher' +import { WORKTREE_METHODS } from '../../rpc/methods/worktree' const WSL_REPO: Repo = { id: 'repo-1', diff --git a/src/main/runtime/runtime-gitlab-worktree-base.ts b/src/main/runtime/integrations/gitlab/runtime-gitlab-worktree-base.ts similarity index 82% rename from src/main/runtime/runtime-gitlab-worktree-base.ts rename to src/main/runtime/integrations/gitlab/runtime-gitlab-worktree-base.ts index 1f55a8417b7..62a8f32f1b9 100644 --- a/src/main/runtime/runtime-gitlab-worktree-base.ts +++ b/src/main/runtime/integrations/gitlab/runtime-gitlab-worktree-base.ts @@ -1,21 +1,22 @@ -import type { GitPushTarget } from '../../shared/worktree/types' -import type { Repo } from '../../shared/repo-types' -import { isFolderRepo } from '../../shared/repo-kind' -import { requireRepoLocalGitRoute } from '../workspaces/execution-host/repo-execution-host' -import { fetchCompareBaseRefWithLocalFallback } from '../git/compare-base-ref-fetch' -import { gitExecFileAsync } from '../git/runner' -import { REVIEW_HEAD_FETCH_TIMEOUT_MS } from '../../shared/review-head-tracking-ref' -import { getProjectRefForRemote, getWorkItemByProjectRef } from '../gitlab/client' -import { getGlabKnownHosts } from '../gitlab/gl-utils' +import type { GitPushTarget } from '../../../../shared/worktree/types' +import type { Repo } from '../../../../shared/repo-types' +import { isFolderRepo } from '../../../../shared/repo-kind' +import { requireRepoLocalGitRoute } from '../../../workspaces/execution-host/repo-execution-host' +import { fetchCompareBaseRefWithLocalFallback } from '../../../git/compare-base-ref-fetch' +import { gitExecFileAsync } from '../../../git/command-runner/git-exec-file' +import { REVIEW_HEAD_FETCH_TIMEOUT_MS } from '../../../../shared/review-head-tracking-ref' +import { getProjectRefForRemote } from '../../../gitlab/gitlab-project-ref-resolution' +import { getWorkItemByProjectRef } from '../../../gitlab/work-item-queries' +import { getGlabKnownHosts } from '../../../gitlab/gitlab-known-host-probe' import { getLocalProjectGitExecOptions, getLocalProjectWorktreeGitOptions -} from '../workspaces/execution-host/project-runtime-git-options' -import type { ProjectRuntimeResolutionStore } from '../workspaces/execution-host/local-project-runtime-resolution' +} from '../../../workspaces/execution-host/project-runtime-git-options' +import type { ProjectRuntimeResolutionStore } from '../../../workspaces/execution-host/local-project-runtime-resolution' import { resolveRuntimeGitLabForkMrBase } from './runtime-gitlab-fork-mr-base' import { resolveRuntimeGitLabIssueSourceRemote } from './runtime-gitlab-issue-source-remote' -import { reviewStartPointFailure } from '../../shared/review-start-point-failure-copy' -import { resolvePrStartPointUnlessWslStopped } from '../github/pr-start-point-wsl-gate' +import { reviewStartPointFailure } from '../../../../shared/review-start-point-failure-copy' +import { resolvePrStartPointUnlessWslStopped } from '../../../github/pr-start-point-wsl-gate' export type RuntimeGitLabWorktreeBaseArgs = { repoSelector: string diff --git a/src/main/runtime/runtime-jira-commands.ts b/src/main/runtime/integrations/jira/runtime-jira-commands.ts similarity index 84% rename from src/main/runtime/runtime-jira-commands.ts rename to src/main/runtime/integrations/jira/runtime-jira-commands.ts index aa9132bcb91..e1faae96bab 100644 --- a/src/main/runtime/runtime-jira-commands.ts +++ b/src/main/runtime/integrations/jira/runtime-jira-commands.ts @@ -1,12 +1,12 @@ import type { JiraIssueSummaryGenerationRequest, JiraIssueSummaryGenerationCancellation -} from '../../shared/jira/jira-issue-summary-generation' +} from '../../../../shared/jira/jira-issue-summary-generation' import { generateJiraIssueSummaryRequest, cancelJiraIssueSummaryRequest, type JiraIssueSummaryGenerationHost -} from '../text-generation/jira-issue-summary-requests' +} from '../../../text-generation/jira-issue-summary-requests' import type { JiraConnectArgs, JiraCreateIssueArgs, @@ -14,28 +14,23 @@ import type { JiraIssueListFilters, JiraIssueUpdate, JiraSiteSelection -} from '../../shared/jira/jira-types' -import type { JiraMediaFormat } from '../../shared/jira/jira-attachment-image' -import { connect, disconnect, getStatus, selectSite, testConnection } from '../jira/client' -import { listFavouriteFilters } from '../jira/favourite-filters' +} from '../../../../shared/jira/jira-types' +import type { JiraMediaFormat } from '../../../../shared/jira/jira-attachment-image' +import { connect, disconnect, getStatus, selectSite, testConnection } from '../../../jira/client' +import { listFavouriteFilters } from '../../../jira/favourite-filters' +import { addIssueComment, createIssue, updateIssue } from '../../../jira/jira-issue-mutations' +import { getIssue, getIssueSummary } from '../../../jira/jira-issue-read' +import { getIssueComments } from '../../../jira/jira-issue-comments' +import { getProjectStatusOrder, listTransitions } from '../../../jira/jira-transition-queries' import { - addIssueComment, - createIssue, - getIssue, - getIssueComments, - getIssueSummary, - getProjectStatusOrder, listAssignableUsers, listCreateFields, listIssueTypes, - listIssues, listPriorities, - listProjects, - listTransitions, - searchIssues, - searchUsers, - updateIssue -} from '../jira/issues' + searchUsers +} from '../../../jira/jira-issue-create-metadata' +import { listIssues, searchIssues } from '../../../jira/jira-issue-search' +import { listProjects } from '../../../jira/jira-project-queries' export class RuntimeJiraCommands { constructor(private readonly host: JiraIssueSummaryGenerationHost) {} diff --git a/src/main/runtime/integrations/linear/linear-agent-write-target.ts b/src/main/runtime/integrations/linear/linear-agent-write-target.ts new file mode 100644 index 00000000000..83c9c9dd28f --- /dev/null +++ b/src/main/runtime/integrations/linear/linear-agent-write-target.ts @@ -0,0 +1,6 @@ +import type { LinearIssueSummary } from '../../../../shared/linear/agent-result-types' + +export type LinearAgentWriteTarget = { + issue: LinearIssueSummary + workspaceId: string +} diff --git a/src/main/runtime/integrations/linear/linear-commands.ts b/src/main/runtime/integrations/linear/linear-commands.ts index 9a8de44f8a2..b6307f051a4 100644 --- a/src/main/runtime/integrations/linear/linear-commands.ts +++ b/src/main/runtime/integrations/linear/linear-commands.ts @@ -1,7 +1,7 @@ import type { RuntimeTerminalShow } from '../../../../shared/runtime-terminal-contracts' import type { ResolvedWorktree } from '../../runtime-worktree-path-identity' import { OrcaRuntimeWithFileCommands } from '../../construction/runtime-file-command-state' -import { RuntimeLinearCommands } from '../../runtime-linear-connection-commands' +import { RuntimeLinearCommands } from './runtime-linear-connection-commands' import { worktreeRowTarget } from '../../../persistence/host-qualified-worktree-meta' export abstract class OrcaRuntimeWithLinearCommands extends OrcaRuntimeWithFileCommands { diff --git a/src/main/runtime/integrations/linear/linear-create-field-intent.ts b/src/main/runtime/integrations/linear/linear-create-field-intent.ts new file mode 100644 index 00000000000..ac7a949b302 --- /dev/null +++ b/src/main/runtime/integrations/linear/linear-create-field-intent.ts @@ -0,0 +1,9 @@ +export type LinearCreateFieldIntent = { + stateId?: string + assigneeId?: string | null + priority?: number + estimate?: number | null + dueDate?: string | null + labelIds?: string[] + projectId?: string +} diff --git a/src/main/runtime/linear-issue-description-comparison.ts b/src/main/runtime/integrations/linear/linear-issue-description-comparison.ts similarity index 100% rename from src/main/runtime/linear-issue-description-comparison.ts rename to src/main/runtime/integrations/linear/linear-issue-description-comparison.ts diff --git a/src/main/runtime/integrations/linear/linear-label-id-equality.ts b/src/main/runtime/integrations/linear/linear-label-id-equality.ts new file mode 100644 index 00000000000..438d906a28d --- /dev/null +++ b/src/main/runtime/integrations/linear/linear-label-id-equality.ts @@ -0,0 +1,7 @@ +export function sameStringSet(left: string[], right: string[]): boolean { + if (left.length !== right.length) { + return false + } + const rightSet = new Set(right) + return left.every((value) => rightSet.has(value)) +} diff --git a/src/main/runtime/runtime-linear-browse-commands.ts b/src/main/runtime/integrations/linear/runtime-linear-browse-commands.ts similarity index 79% rename from src/main/runtime/runtime-linear-browse-commands.ts rename to src/main/runtime/integrations/linear/runtime-linear-browse-commands.ts index c5ce23b4027..df4541155b0 100644 --- a/src/main/runtime/runtime-linear-browse-commands.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-browse-commands.ts @@ -1,19 +1,17 @@ -import type { LinearCustomViewModel } from '../../shared/linear/project-types' -import type { LinearWorkspaceSelection } from '../../shared/linear/workspace-types' -import { clampLinearIssueListLimit } from '../../shared/linear/issue-read-limits' -import { getIssueComments } from '../linear/linear-issue-comments' +import type { LinearCustomViewModel } from '../../../../shared/linear/project-types' +import type { LinearWorkspaceSelection } from '../../../../shared/linear/workspace-types' +import { clampLinearIssueListLimit } from '../../../../shared/linear/issue-read-limits' +import { getIssueComments } from '../../../linear/linear-issue-comments' +import { createProject, getProject, listProjects } from '../../../linear/linear-project-queries' import { - createProject, getCustomView, - getProject, listCustomViewIssues, listCustomViewProjects, - listCustomViews, - listProjectIssues, - listProjects, - type LinearProjectCreateInput -} from '../linear/projects' -import { getTeamLabels, getTeamMembers, getTeamStates, listTeams } from '../linear/teams' + listCustomViews +} from '../../../linear/linear-custom-view-queries' +import { listProjectIssues } from '../../../linear/linear-project-issue-queries' +import type { LinearProjectCreateInput } from '../../../linear/linear-project-nodes' +import { getTeamLabels, getTeamMembers, getTeamStates, listTeams } from '../../../linear/teams' export class RuntimeLinearBrowseCommands { linearIssueComments(issueId: string, workspaceId?: string): ReturnType { diff --git a/src/main/runtime/runtime-linear-command-base.ts b/src/main/runtime/integrations/linear/runtime-linear-command-base.ts similarity index 82% rename from src/main/runtime/runtime-linear-command-base.ts rename to src/main/runtime/integrations/linear/runtime-linear-command-base.ts index 6a09b1b241d..ad9ce3c283d 100644 --- a/src/main/runtime/runtime-linear-command-base.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-command-base.ts @@ -1,6 +1,7 @@ -import type { RuntimeTerminalShow } from '../../shared/runtime-types' -import type { ResolvedWorktree } from './runtime-worktree-path-identity' -import type { LinearLinkedIssueUpdatedEvent } from './runtime-linear-command-dependencies' +import type { RuntimeClientEvent } from '../../../../shared/runtime-client-events' +import type { RuntimeTerminalShow } from '../../../../shared/runtime-terminal-contracts' +import type { ResolvedWorktree } from '../../runtime-worktree-path-identity' + import { RuntimeLinearBrowseCommands } from './runtime-linear-browse-commands' export type RuntimeLinearCommandPorts = { @@ -54,3 +55,8 @@ export class RuntimeLinearCommandBase extends RuntimeLinearBrowseCommands { this.ports.emitClientEvent(event) } } + +export type LinearLinkedIssueUpdatedEvent = Extract< + RuntimeClientEvent, + { type: 'linearLinkedIssueUpdated' } +> diff --git a/src/main/runtime/runtime-linear-command-surface.ts b/src/main/runtime/integrations/linear/runtime-linear-command-surface.ts similarity index 100% rename from src/main/runtime/runtime-linear-command-surface.ts rename to src/main/runtime/integrations/linear/runtime-linear-command-surface.ts diff --git a/src/main/runtime/runtime-linear-comment-commands.ts b/src/main/runtime/integrations/linear/runtime-linear-comment-commands.ts similarity index 89% rename from src/main/runtime/runtime-linear-comment-commands.ts rename to src/main/runtime/integrations/linear/runtime-linear-comment-commands.ts index a518788e5e9..825f8efca63 100644 --- a/src/main/runtime/runtime-linear-comment-commands.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-comment-commands.ts @@ -1,34 +1,33 @@ +import { randomUUID } from 'node:crypto' +import { LINEAR_WRITE_BODY_CAP } from '../../../../shared/linear/agent-access' import { - randomUUID, - LINEAR_WRITE_BODY_CAP, - addLinearIssueCommentForAgent, - createLinearIssueAttachment, - deleteLinearIssueCommentForAgent, - getLinearCommentByUuidForAgent, - isLinearUuid, - updateLinearIssueCommentForAgent, - LinearWriteFailure -} from './runtime-linear-command-dependencies' -import { linearError, type LinearAgentAccessError } from '../linear/issue-context/errors' + addIssueCommentForAgent as addLinearIssueCommentForAgent, + createIssueAttachment as createLinearIssueAttachment, + deleteIssueCommentForAgent as deleteLinearIssueCommentForAgent, + updateIssueCommentForAgent as updateLinearIssueCommentForAgent +} from '../../../linear/linear-issue-comments' +import { getCommentByUuidForAgent as getLinearCommentByUuidForAgent } from '../../../linear/linear-issue-lookups' +import { isLinearUuid } from '../../../../shared/linear/uuid' +import { LinearWriteFailure } from '../../../linear/linear-issue-write-support' +import { linearError, type LinearAgentAccessError } from '../../../linear/issue-context/errors' import type { LinearCommentAddRequest, LinearAttachRequest, LinearCommentEditRequest, LinearCommentDeleteRequest, - LinearAttachResult, - LinearCommentAddResult, LinearCommentDeleteResult, LinearCommentEditResult -} from './runtime-linear-command-dependencies' +} from '../../../../shared/linear/agent-access' +import type * as LinearAgentResults from '../../../../shared/linear/agent-result-types' import { RuntimeLinearCreateCommands } from './runtime-linear-create-commands' -import { getConnectedWorkspaces } from '../linear/issue-context/client' -import { resolveWorkspaceSelector } from '../linear/issue-context/workspaces' +import { getConnectedWorkspaces } from '../../../linear/issue-context/client' +import { resolveWorkspaceSelector } from '../../../linear/issue-context/workspaces' export class RuntimeLinearCommentCommands extends RuntimeLinearCreateCommands { async linearIssueAddComment( params: LinearCommentAddRequest, cancellation?: AbortSignal - ): Promise { + ): Promise { if (params.body.length > LINEAR_WRITE_BODY_CAP) { throw linearError('linear_body_too_large', 'Linear comment body is too large.') } @@ -119,7 +118,7 @@ export class RuntimeLinearCommentCommands extends RuntimeLinearCreateCommands { async linearIssueAttachLink( params: LinearAttachRequest, cancellation?: AbortSignal - ): Promise { + ): Promise { const url = this.parseLinearAttachmentUrl(params.url) const writeId = params.writeId ?? randomUUID() const title = params.title?.trim() || this.defaultLinearAttachmentTitle(url) diff --git a/src/main/runtime/runtime-linear-comment-edit.test.ts b/src/main/runtime/integrations/linear/runtime-linear-comment-edit.test.ts similarity index 96% rename from src/main/runtime/runtime-linear-comment-edit.test.ts rename to src/main/runtime/integrations/linear/runtime-linear-comment-edit.test.ts index d4a7d0a6c5a..8eaa912ea1e 100644 --- a/src/main/runtime/runtime-linear-comment-edit.test.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-comment-edit.test.ts @@ -1,6 +1,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import type * as LinearClientModule from '../linear/client' -import type { ResolvedWorktree } from './runtime-worktree-path-identity' +import type * as LinearClientModule from '../../../linear/client' +import type { ResolvedWorktree } from '../../runtime-worktree-path-identity' const COMMENT_ID = '9f3c2a10-1111-4222-8333-444455556666' @@ -13,13 +13,13 @@ const mocks = vi.hoisted(() => ({ deleteComment: vi.fn() })) -vi.mock('../linear/client', async (importOriginal) => ({ +vi.mock('../../../linear/client', async (importOriginal) => ({ ...(await importOriginal()), getClients: mocks.getClients, getStatus: mocks.getStatus })) -vi.mock('../linear/linear-sdk', () => { +vi.mock('../../../linear/linear-sdk', () => { const sdk = { // Why: writes build a fresh SDK client per call so the deadline signal can abort it. LinearClient: class { @@ -36,9 +36,9 @@ vi.mock('../linear/linear-sdk', () => { }) import { RuntimeLinearReadCommands } from './runtime-linear-read-commands' -import { acquire, release } from '../linear/linear-request-concurrency' -import { addIssueCommentForAgent } from '../linear/linear-issue-comments' -import { linearError } from '../linear/issue-context/errors' +import { acquire, release } from '../../../linear/linear-request-concurrency' +import { addIssueCommentForAgent } from '../../../linear/linear-issue-comments' +import { linearError } from '../../../linear/issue-context/errors' function rawComment(body: string): unknown { return { diff --git a/src/main/runtime/runtime-linear-comment-lookup-commands.ts b/src/main/runtime/integrations/linear/runtime-linear-comment-lookup-commands.ts similarity index 88% rename from src/main/runtime/runtime-linear-comment-lookup-commands.ts rename to src/main/runtime/integrations/linear/runtime-linear-comment-lookup-commands.ts index 30c9ecdce18..cfdfd5c6421 100644 --- a/src/main/runtime/runtime-linear-comment-lookup-commands.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-comment-lookup-commands.ts @@ -1,14 +1,12 @@ -import { - isLinearAuthError, - getLinearIssueCommentThreadRoot -} from './runtime-linear-command-dependencies' +import { isAuthError as isLinearAuthError } from '../../../linear/client' +import { getIssueCommentThreadRoot as getLinearIssueCommentThreadRoot } from '../../../linear/linear-issue-lookups' import { LinearAgentAccessError, linearError, toLinearAccessError -} from '../linear/issue-context/errors' +} from '../../../linear/issue-context/errors' import { runLinearWriteAction } from './runtime-linear-write-action' -import type { LinearWriteFailure } from '../linear/linear-issue-write-support' +import type { LinearWriteFailure } from '../../../linear/linear-issue-write-support' import { RuntimeLinearWriteResultCommands } from './runtime-linear-write-result-commands' export class RuntimeLinearCommentLookupCommands extends RuntimeLinearWriteResultCommands { diff --git a/src/main/runtime/runtime-linear-connection-commands.ts b/src/main/runtime/integrations/linear/runtime-linear-connection-commands.ts similarity index 68% rename from src/main/runtime/runtime-linear-connection-commands.ts rename to src/main/runtime/integrations/linear/runtime-linear-connection-commands.ts index 9df38d5bead..76731cf0917 100644 --- a/src/main/runtime/runtime-linear-connection-commands.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-connection-commands.ts @@ -1,17 +1,15 @@ import { - connectLinear, - disconnectLinear, - getLinearStatus, - selectLinearWorkspace, - testLinearConnection, - searchLinearIssues -} from './runtime-linear-command-dependencies' -import { readLinearIssueContext } from '../linear/issue-context/read-context' -import { searchLinearIssuesForAgents } from '../linear/issue-context/client' -import type { - LinearIssueRequest, - LinearWorkspaceSelection -} from './runtime-linear-command-dependencies' + connect as connectLinear, + disconnect as disconnectLinear, + getStatus as getLinearStatus, + selectWorkspace as selectLinearWorkspace, + testConnection as testLinearConnection +} from '../../../linear/client' +import { searchIssues as searchLinearIssues } from '../../../linear/linear-issue-lookups' +import { readLinearIssueContext } from '../../../linear/issue-context/read-context' +import { searchLinearIssuesForAgents } from '../../../linear/issue-context/client' +import type { LinearIssueRequest } from '../../../../shared/linear/agent-access' +import type { LinearWorkspaceSelection } from '../../../../shared/linear/workspace-types' import { RuntimeLinearReadCommands } from './runtime-linear-read-commands' export class RuntimeLinearCommands extends RuntimeLinearReadCommands { diff --git a/src/main/runtime/runtime-linear-context-commands.ts b/src/main/runtime/integrations/linear/runtime-linear-context-commands.ts similarity index 65% rename from src/main/runtime/runtime-linear-context-commands.ts rename to src/main/runtime/integrations/linear/runtime-linear-context-commands.ts index 39f23c93ee2..7c0b03541ff 100644 --- a/src/main/runtime/runtime-linear-context-commands.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-context-commands.ts @@ -1,17 +1,15 @@ +import { clampLinearIssueListLimit } from '../../../../shared/linear/issue-read-limits' +import { addIssueComment as addLinearIssueComment } from '../../../linear/linear-issue-comments' import { - clampLinearIssueListLimit, - addLinearIssueComment, - createLinearIssue, - getLinearIssue, - listLinearIssues, - updateLinearIssue -} from './runtime-linear-command-dependencies' -import type { - LinearIssueUpdate, - LinearWorkspaceSelection, - LinearListFilter, - LinearIssueListOptions -} from './runtime-linear-command-dependencies' + createIssue as createLinearIssue, + updateIssue as updateLinearIssue +} from '../../../linear/linear-issue-mutations' +import { getIssue as getLinearIssue } from '../../../linear/linear-issue-lookups' +import { listIssues as listLinearIssues } from '../../../linear/linear-issue-listing' +import type { LinearIssueUpdate } from '../../../../shared/issue-mutation-types' +import type { LinearWorkspaceSelection } from '../../../../shared/linear/workspace-types' +import type { LinearListFilter } from '../../../linear/linear-issue-listing' +import type { LinearIssueListOptions } from '../../../linear/linear-issue-query-documents' import { RuntimeLinearStateCommands } from './runtime-linear-state-commands' export class RuntimeLinearContextCommands extends RuntimeLinearStateCommands { diff --git a/src/main/runtime/runtime-linear-create-commands.ts b/src/main/runtime/integrations/linear/runtime-linear-create-commands.ts similarity index 89% rename from src/main/runtime/runtime-linear-create-commands.ts rename to src/main/runtime/integrations/linear/runtime-linear-create-commands.ts index fc5d974eb54..0c36c5d82c3 100644 --- a/src/main/runtime/runtime-linear-create-commands.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-create-commands.ts @@ -1,14 +1,10 @@ -import { - randomUUID, - LINEAR_WRITE_BODY_CAP, - createLinearIssueForAgent, - LinearWriteFailure -} from './runtime-linear-command-dependencies' -import { linearError } from '../linear/issue-context/errors' -import type { - LinearCurrentIssueContextHints, - LinearCreateResult -} from './runtime-linear-command-dependencies' +import { randomUUID } from 'node:crypto' +import { LINEAR_WRITE_BODY_CAP } from '../../../../shared/linear/agent-access' +import { createIssueForAgent as createLinearIssueForAgent } from '../../../linear/linear-issue-mutations' +import { LinearWriteFailure } from '../../../linear/linear-issue-write-support' +import { linearError } from '../../../linear/issue-context/errors' +import type { LinearCurrentIssueContextHints } from '../../../../shared/linear/agent-access' +import type { LinearCreateResult } from '../../../../shared/linear/agent-result-types' import { RuntimeLinearSaveFieldCommands } from './runtime-linear-save-fields-commands' export class RuntimeLinearCreateCommands extends RuntimeLinearSaveFieldCommands { diff --git a/src/main/runtime/runtime-linear-dedupe-commands.ts b/src/main/runtime/integrations/linear/runtime-linear-dedupe-commands.ts similarity index 94% rename from src/main/runtime/runtime-linear-dedupe-commands.ts rename to src/main/runtime/integrations/linear/runtime-linear-dedupe-commands.ts index 111446e6ea6..beb75408bdf 100644 --- a/src/main/runtime/runtime-linear-dedupe-commands.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-dedupe-commands.ts @@ -1,15 +1,15 @@ import { - getLinearAttachmentByUuidForAgent, - getLinearCommentByUuidForAgent, - getLinearIssueByUuidForAgent, - sameStringSet -} from './runtime-linear-command-dependencies' + getAttachmentByUuidForAgent as getLinearAttachmentByUuidForAgent, + getCommentByUuidForAgent as getLinearCommentByUuidForAgent, + getIssueByUuidForAgent as getLinearIssueByUuidForAgent +} from '../../../linear/linear-issue-lookups' +import { sameStringSet } from './linear-label-id-equality' import { LinearAgentAccessError, linearError, sanitizeLinearErrorMessage -} from '../linear/issue-context/errors' -import type { LinearCreateFieldIntent } from './runtime-linear-command-dependencies' +} from '../../../linear/issue-context/errors' +import type { LinearCreateFieldIntent } from './linear-create-field-intent' import { RuntimeLinearCommentLookupCommands } from './runtime-linear-comment-lookup-commands' export class RuntimeLinearDedupeCommands extends RuntimeLinearCommentLookupCommands { diff --git a/src/main/runtime/runtime-linear-label-write-commands.ts b/src/main/runtime/integrations/linear/runtime-linear-label-write-commands.ts similarity index 90% rename from src/main/runtime/runtime-linear-label-write-commands.ts rename to src/main/runtime/integrations/linear/runtime-linear-label-write-commands.ts index 5fc8ec94dac..a986707059c 100644 --- a/src/main/runtime/runtime-linear-label-write-commands.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-label-write-commands.ts @@ -1,12 +1,12 @@ -import { - type getLinearIssueByUuidForAgent, - type LinearIssueTaskUpdateRequest, - type LinearIssueTaskUpdateResult, - type LinearIssueSummary, - getLinearTeamLabelsOrThrow, - sameStringSet -} from './runtime-linear-command-dependencies' -import { linearError } from '../linear/issue-context/errors' +import type { getIssueByUuidForAgent as getLinearIssueByUuidForAgent } from '../../../linear/linear-issue-lookups' +import type { LinearIssueTaskUpdateRequest } from '../../../../shared/linear/agent-access' +import type { + LinearIssueTaskUpdateResult, + LinearIssueSummary +} from '../../../../shared/linear/agent-result-types' +import { getTeamLabelsOrThrow as getLinearTeamLabelsOrThrow } from '../../../linear/teams' +import { sameStringSet } from './linear-label-id-equality' +import { linearError } from '../../../linear/issue-context/errors' import { RuntimeLinearProjectWriteCommands } from './runtime-linear-project-write-commands' export class RuntimeLinearLabelWriteCommands extends RuntimeLinearProjectWriteCommands { diff --git a/src/main/runtime/runtime-linear-project-write-commands.ts b/src/main/runtime/integrations/linear/runtime-linear-project-write-commands.ts similarity index 90% rename from src/main/runtime/runtime-linear-project-write-commands.ts rename to src/main/runtime/integrations/linear/runtime-linear-project-write-commands.ts index 8896b29ebc0..5df9f3119b3 100644 --- a/src/main/runtime/runtime-linear-project-write-commands.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-project-write-commands.ts @@ -1,14 +1,14 @@ +import { LINEAR_SEARCH_MAX_LIMIT } from '../../../../shared/linear/agent-access' +import { isLinearUuid } from '../../../../shared/linear/uuid' import { - LINEAR_SEARCH_MAX_LIMIT, - isLinearUuid, - getLinearProject, - listLinearProjectsByExactName, - listLinearProjectTeams, - listLinearProjects, - getLinearViewerForWorkspaceOrThrow -} from './runtime-linear-command-dependencies' -import { linearError } from '../linear/issue-context/errors' -import type { LinearProjectSummary } from './runtime-linear-command-dependencies' + getProject as getLinearProject, + listProjectsByExactName as listLinearProjectsByExactName, + listProjects as listLinearProjects +} from '../../../linear/linear-project-queries' +import { listProjectTeams as listLinearProjectTeams } from '../../../linear/linear-project-team-queries' +import { getViewerForWorkspaceOrThrow as getLinearViewerForWorkspaceOrThrow } from '../../../linear/teams' +import { linearError } from '../../../linear/issue-context/errors' +import type { LinearProjectSummary } from '../../../../shared/linear/project-types' import { RuntimeLinearTeamWriteCommands } from './runtime-linear-team-write-commands' export class RuntimeLinearProjectWriteCommands extends RuntimeLinearTeamWriteCommands { diff --git a/src/main/runtime/runtime-linear-read-commands.ts b/src/main/runtime/integrations/linear/runtime-linear-read-commands.ts similarity index 89% rename from src/main/runtime/runtime-linear-read-commands.ts rename to src/main/runtime/integrations/linear/runtime-linear-read-commands.ts index f434bf97cab..80130000ae6 100644 --- a/src/main/runtime/runtime-linear-read-commands.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-read-commands.ts @@ -1,25 +1,27 @@ +import { clampLinearSearchLimit } from '../../../../shared/linear/agent-access' +import { clampLinearIssueListLimit } from '../../../../shared/linear/issue-read-limits' +import { listIssues as listLinearIssues } from '../../../linear/linear-issue-listing' +import { listMcpIssues } from '../../../linear/mcp-issue-list' import { - clampLinearSearchLimit, - clampLinearIssueListLimit, - listLinearIssues, - listMcpIssues, - getLinearTeamMembersOrThrow, - listLinearTeamsForAgent -} from './runtime-linear-command-dependencies' -import { sanitizeLinearErrorMessage } from '../linear/issue-context/errors' + getTeamMembersOrThrow as getLinearTeamMembersOrThrow, + listTeamsForAgent as listLinearTeamsForAgent +} from '../../../linear/teams' +import { sanitizeLinearErrorMessage } from '../../../linear/issue-context/errors' +import type { LinearIssueListFilter } from '../../../../shared/linear/agent-access' import type { - LinearIssueListFilter, LinearIssueListResult, LinearProjectListResult, - LinearMcpIssueListRequest, - LinearMcpIssueListResult, LinearTeamLabelsResult, LinearTeamListResult, LinearTeamMembersResult, LinearTeamStatesResult -} from './runtime-linear-command-dependencies' +} from '../../../../shared/linear/agent-result-types' +import type { + LinearMcpIssueListRequest, + LinearMcpIssueListResult +} from '../../../../shared/linear/mcp-issue-list' import { RuntimeLinearContextCommands } from './runtime-linear-context-commands' -import { linearPriorityLabel } from '../../shared/linear/priority-label' +import { linearPriorityLabel } from '../../../../shared/linear/priority-label' export class RuntimeLinearReadCommands extends RuntimeLinearContextCommands { async linearTeamListForAgents(params: { diff --git a/src/main/runtime/runtime-linear-retry-commands.ts b/src/main/runtime/integrations/linear/runtime-linear-retry-commands.ts similarity index 96% rename from src/main/runtime/runtime-linear-retry-commands.ts rename to src/main/runtime/integrations/linear/runtime-linear-retry-commands.ts index 8c7e7928afc..f7ffd4257ad 100644 --- a/src/main/runtime/runtime-linear-retry-commands.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-retry-commands.ts @@ -2,11 +2,9 @@ import { type LinearAgentAccessError, linearError, sanitizeLinearErrorMessage -} from '../linear/issue-context/errors' -import type { - LinearAgentWriteTarget, - LinearCreateFieldIntent -} from './runtime-linear-command-dependencies' +} from '../../../linear/issue-context/errors' +import type { LinearAgentWriteTarget } from './linear-agent-write-target' +import type { LinearCreateFieldIntent } from './linear-create-field-intent' import { RuntimeLinearCommandBase } from './runtime-linear-command-base' export class RuntimeLinearRetryCommands extends RuntimeLinearCommandBase { diff --git a/src/main/runtime/runtime-linear-save-commands.ts b/src/main/runtime/integrations/linear/runtime-linear-save-commands.ts similarity index 92% rename from src/main/runtime/runtime-linear-save-commands.ts rename to src/main/runtime/integrations/linear/runtime-linear-save-commands.ts index 2fdca94b627..55269f24dd6 100644 --- a/src/main/runtime/runtime-linear-save-commands.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-save-commands.ts @@ -1,15 +1,15 @@ -import { - LINEAR_WRITE_BODY_CAP, - updateLinearIssueForAgent, - LinearWriteFailure -} from './runtime-linear-command-dependencies' -import { linearError } from '../linear/issue-context/errors' +import { LINEAR_WRITE_BODY_CAP } from '../../../../shared/linear/agent-access' +import { updateIssueForAgent as updateLinearIssueForAgent } from '../../../linear/linear-issue-mutations' +import { LinearWriteFailure } from '../../../linear/linear-issue-write-support' +import { linearError } from '../../../linear/issue-context/errors' import type { LinearIssueTaskUpdateRequest, + LinearSaveIssueRequest +} from '../../../../shared/linear/agent-access' +import type { LinearIssueTaskUpdateResult, - LinearSaveIssueRequest, LinearSaveIssueResult -} from './runtime-linear-command-dependencies' +} from '../../../../shared/linear/agent-result-types' import { RuntimeLinearCommentCommands } from './runtime-linear-comment-commands' export class RuntimeLinearSaveCommands extends RuntimeLinearCommentCommands { diff --git a/src/main/runtime/runtime-linear-save-fields-commands.ts b/src/main/runtime/integrations/linear/runtime-linear-save-fields-commands.ts similarity index 90% rename from src/main/runtime/runtime-linear-save-fields-commands.ts rename to src/main/runtime/integrations/linear/runtime-linear-save-fields-commands.ts index 866e667d227..9b943e6aecf 100644 --- a/src/main/runtime/runtime-linear-save-fields-commands.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-save-fields-commands.ts @@ -1,10 +1,8 @@ -import { - type getLinearIssueByUuidForAgent, - type LinearIssueUpdate, - type LinearCreateFieldIntent, - sameStringSet -} from './runtime-linear-command-dependencies' -import { linearError } from '../linear/issue-context/errors' +import type { getIssueByUuidForAgent as getLinearIssueByUuidForAgent } from '../../../linear/linear-issue-lookups' +import type { LinearIssueUpdate } from '../../../../shared/issue-mutation-types' +import type { LinearCreateFieldIntent } from './linear-create-field-intent' +import { sameStringSet } from './linear-label-id-equality' +import { linearError } from '../../../linear/issue-context/errors' import { RuntimeLinearTaskFieldCommands } from './runtime-linear-task-fields-commands' export class RuntimeLinearSaveFieldCommands extends RuntimeLinearTaskFieldCommands { diff --git a/src/main/runtime/runtime-linear-state-commands.ts b/src/main/runtime/integrations/linear/runtime-linear-state-commands.ts similarity index 89% rename from src/main/runtime/runtime-linear-state-commands.ts rename to src/main/runtime/integrations/linear/runtime-linear-state-commands.ts index f35a3961133..79c7f4ac21d 100644 --- a/src/main/runtime/runtime-linear-state-commands.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-state-commands.ts @@ -1,15 +1,13 @@ -import { - updateLinearIssueForAgent, - LinearWriteFailure, - writeIssueRelation -} from './runtime-linear-command-dependencies' -import { linearError } from '../linear/issue-context/errors' +import { updateIssueForAgent as updateLinearIssueForAgent } from '../../../linear/linear-issue-mutations' +import { LinearWriteFailure } from '../../../linear/linear-issue-write-support' +import { writeIssueRelation } from '../../../linear/issue-relation-write' +import { linearError } from '../../../linear/issue-context/errors' +import type { LinearCurrentIssueContextHints } from '../../../../shared/linear/agent-access' import type { - LinearCurrentIssueContextHints, LinearIssueRelationWriteRequest, - LinearIssueRelationWriteResult, - LinearStatusSetResult -} from './runtime-linear-command-dependencies' + LinearIssueRelationWriteResult +} from '../../../../shared/linear/issue-relation-write' +import type { LinearStatusSetResult } from '../../../../shared/linear/agent-result-types' import { RuntimeLinearSaveCommands } from './runtime-linear-save-commands' export class RuntimeLinearStateCommands extends RuntimeLinearSaveCommands { diff --git a/src/main/runtime/runtime-linear-task-fields-commands.ts b/src/main/runtime/integrations/linear/runtime-linear-task-fields-commands.ts similarity index 89% rename from src/main/runtime/runtime-linear-task-fields-commands.ts rename to src/main/runtime/integrations/linear/runtime-linear-task-fields-commands.ts index 3541c1fec92..c64f11d640c 100644 --- a/src/main/runtime/runtime-linear-task-fields-commands.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-task-fields-commands.ts @@ -1,19 +1,18 @@ import { - getLinearTeamMembersOrThrow, - isLinearUuid, - getLinearIssueByUuidForAgent, - getLinearTeamStatesOrThrow, - labelsForIds -} from './runtime-linear-command-dependencies' -import { linearError } from '../linear/issue-context/errors' -import { readLinearIssueContext } from '../linear/issue-context/read-context' + getTeamMembersOrThrow as getLinearTeamMembersOrThrow, + getTeamStatesOrThrow as getLinearTeamStatesOrThrow +} from '../../../linear/teams' +import { isLinearUuid } from '../../../../shared/linear/uuid' +import { getIssueByUuidForAgent as getLinearIssueByUuidForAgent } from '../../../linear/linear-issue-lookups' +import { linearError } from '../../../linear/issue-context/errors' +import { readLinearIssueContext } from '../../../linear/issue-context/read-context' import type { LinearIssueTaskUpdateRequest, LinearSaveIssueRequest, - LinearIssueUpdate, - LinearCurrentIssueContextHints, - LinearAgentWriteTarget -} from './runtime-linear-command-dependencies' + LinearCurrentIssueContextHints +} from '../../../../shared/linear/agent-access' +import type { LinearIssueUpdate } from '../../../../shared/issue-mutation-types' +import type { LinearAgentWriteTarget } from './linear-agent-write-target' import { RuntimeLinearLabelWriteCommands } from './runtime-linear-label-write-commands' export class RuntimeLinearTaskFieldCommands extends RuntimeLinearLabelWriteCommands { @@ -280,3 +279,13 @@ export class RuntimeLinearTaskFieldCommands extends RuntimeLinearLabelWriteComma return { issue: result.issue, workspaceId: result.meta.resolved.workspaceId } } } + +function labelsForIds( + ids: string[], + labels: { id?: string | null; name?: string | null; color?: string | null }[] +): { id: string; name: string; color?: string | null }[] { + return ids.map((id) => { + const label = labels.find((candidate) => candidate.id === id) + return { id, name: label?.name ?? id, ...(label?.color ? { color: label.color } : {}) } + }) +} diff --git a/src/main/runtime/runtime-linear-team-write-commands.ts b/src/main/runtime/integrations/linear/runtime-linear-team-write-commands.ts similarity index 92% rename from src/main/runtime/runtime-linear-team-write-commands.ts rename to src/main/runtime/integrations/linear/runtime-linear-team-write-commands.ts index 8fe3bf891d1..e64cb1a60a2 100644 --- a/src/main/runtime/runtime-linear-team-write-commands.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-team-write-commands.ts @@ -1,23 +1,21 @@ -import { - resolve, - isPathInsideOrEqual, - getLinearStatus, - listLinearTeamsOrThrow -} from './runtime-linear-command-dependencies' -import { LinearAgentAccessError, linearError } from '../linear/issue-context/errors' +import { resolve } from 'node:path' +import { isPathInsideOrEqual } from '../../../../shared/cross-platform-path' +import { getStatus as getLinearStatus } from '../../../linear/client' +import { listTeamsOrThrow as listLinearTeamsOrThrow } from '../../../linear/teams' +import { LinearAgentAccessError, linearError } from '../../../linear/issue-context/errors' import { getLinearCurrentIssueFromWorktree, resolveLegacyLinearLinkWorkspace -} from '../linear/issue-context/current' +} from '../../../linear/issue-context/current' import type { LinearCurrentIssueContextHints, - LinearErrorCode, - LinearAgentWriteTarget -} from './runtime-linear-command-dependencies' -import type { ResolvedWorktree } from './runtime-worktree-path-identity' + LinearErrorCode +} from '../../../../shared/linear/agent-access' +import type { LinearAgentWriteTarget } from './linear-agent-write-target' +import type { ResolvedWorktree } from '../../runtime-worktree-path-identity' import { RuntimeLinearDedupeCommands } from './runtime-linear-dedupe-commands' -import { isWslMoveWorktreeBlocked } from '../persistence/moving-wsl-projects/wsl-move-background-backoff' -import { parseWorkspaceKey } from '../../shared/workspace-scope' +import { isWslMoveWorktreeBlocked } from '../../../persistence/moving-wsl-projects/wsl-move-background-backoff' +import { parseWorkspaceKey } from '../../../../shared/workspace-scope' export class RuntimeLinearTeamWriteCommands extends RuntimeLinearDedupeCommands { public parseLinearAttachmentUrl(value: string): URL { diff --git a/src/main/runtime/runtime-linear-write-action.ts b/src/main/runtime/integrations/linear/runtime-linear-write-action.ts similarity index 94% rename from src/main/runtime/runtime-linear-write-action.ts rename to src/main/runtime/integrations/linear/runtime-linear-write-action.ts index 65baa472c76..bd8bb3590ab 100644 --- a/src/main/runtime/runtime-linear-write-action.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-write-action.ts @@ -1,10 +1,10 @@ -import { waitForPromiseWithSignal } from '../../shared/abort-signal-reason' +import { waitForPromiseWithSignal } from '../../../../shared/abort-signal-reason' import { linearError, sanitizeLinearErrorMessage, type LinearAgentAccessError -} from '../linear/issue-context/errors' -import { LinearWriteFailure } from '../linear/linear-issue-write-support' +} from '../../../linear/issue-context/errors' +import { LinearWriteFailure } from '../../../linear/linear-issue-write-support' export async function runLinearWriteAction( resolveOwner: (signal: AbortSignal) => Promise, diff --git a/src/main/runtime/runtime-linear-write-lifetime.test.ts b/src/main/runtime/integrations/linear/runtime-linear-write-lifetime.test.ts similarity index 97% rename from src/main/runtime/runtime-linear-write-lifetime.test.ts rename to src/main/runtime/integrations/linear/runtime-linear-write-lifetime.test.ts index 78b9a0e16b3..938e977baa5 100644 --- a/src/main/runtime/runtime-linear-write-lifetime.test.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-write-lifetime.test.ts @@ -1,10 +1,10 @@ import { afterEach, beforeEach, expect, it, vi } from 'vitest' -import * as mutations from '../linear/linear-issue-mutations' -import * as comments from '../linear/linear-issue-comments' -import * as relations from '../linear/issue-relation-write' -import { LinearWriteFailure } from '../linear/linear-issue-write-support' +import * as mutations from '../../../linear/linear-issue-mutations' +import * as comments from '../../../linear/linear-issue-comments' +import * as relations from '../../../linear/issue-relation-write' +import { LinearWriteFailure } from '../../../linear/linear-issue-write-support' import { RuntimeLinearReadCommands } from './runtime-linear-read-commands' -import type { LinearIssueTaskUpdateRequest } from './runtime-linear-command-dependencies' +import type { LinearIssueTaskUpdateRequest } from '../../../../shared/linear/agent-access' const issue = { id: 'issue-1', diff --git a/src/main/runtime/runtime-linear-write-result-commands.ts b/src/main/runtime/integrations/linear/runtime-linear-write-result-commands.ts similarity index 81% rename from src/main/runtime/runtime-linear-write-result-commands.ts rename to src/main/runtime/integrations/linear/runtime-linear-write-result-commands.ts index 6e86682dce2..ca1c4236532 100644 --- a/src/main/runtime/runtime-linear-write-result-commands.ts +++ b/src/main/runtime/integrations/linear/runtime-linear-write-result-commands.ts @@ -1,12 +1,14 @@ import type { - getLinearAttachmentByUuidForAgent, - getLinearCommentByUuidForAgent, - getLinearIssueByUuidForAgent, + getAttachmentByUuidForAgent as getLinearAttachmentByUuidForAgent, + getCommentByUuidForAgent as getLinearCommentByUuidForAgent, + getIssueByUuidForAgent as getLinearIssueByUuidForAgent +} from '../../../linear/linear-issue-lookups' +import type { LinearAttachResult, LinearCommentAddResult, - LinearCreateResult, - LinearAgentWriteTarget -} from './runtime-linear-command-dependencies' + LinearCreateResult +} from '../../../../shared/linear/agent-result-types' +import type { LinearAgentWriteTarget } from './linear-agent-write-target' import { RuntimeLinearRetryCommands } from './runtime-linear-retry-commands' export class RuntimeLinearWriteResultCommands extends RuntimeLinearRetryCommands { diff --git a/src/main/runtime/runtime-hosted-review-commands.ts b/src/main/runtime/integrations/reviews/runtime-hosted-review-commands.ts similarity index 84% rename from src/main/runtime/runtime-hosted-review-commands.ts rename to src/main/runtime/integrations/reviews/runtime-hosted-review-commands.ts index bd887fcf8c1..978c452d6c5 100644 --- a/src/main/runtime/runtime-hosted-review-commands.ts +++ b/src/main/runtime/integrations/reviews/runtime-hosted-review-commands.ts @@ -6,32 +6,29 @@ import type { HostedReviewCreationEligibility, HostedReviewCreationEligibilityArgs, HostedReviewForBranchReply -} from '../../shared/source-control/hosted-review/hosted-review-contracts' -import type { GitHubOwnerRepo } from '../../shared/github/pull-request-types' +} from '../../../../shared/source-control/hosted-review/hosted-review-contracts' +import type { GitHubOwnerRepo } from '../../../../shared/github/pull-request-types' import type { GitHubPRRefreshReason, PRRefreshOutcome -} from '../../shared/github/pull-request-refresh-types' -import type { Repo } from '../../shared/repo-types' -import { - getPRForBranchOutcome, - getRepoSlug, - getRepoUpstream, - type GitHubPRBranchLookupOptions -} from '../github/client' -import { admissionTierForRefreshReason } from '../github/pr-refresh-candidate-policy' -import type { GitAdmissionTier } from '../git/command-runner/git-exec-options' -import { hostedReviewForBranchReply } from '../../shared/source-control/hosted-review/hosted-review-contracts' -import { readHostedReviewForBranch } from '../source-control/hosted-review' -import { getStoredRepoExecutionHostId } from '../workspaces/execution-host/repo-execution-host' -import { hostedReviewSshConnectionId } from '../source-control/hosted-review-execution-host' +} from '../../../../shared/github/pull-request-refresh-types' +import type { Repo } from '../../../../shared/repo-types' +import { getPRForBranchOutcome } from '../../../github/client/lookup/pr-for-branch-outcome' +import { getRepoSlug, getRepoUpstream } from '../../../github/client/fetch/repo-slug-upstream' +import type { GitHubPRBranchLookupOptions } from '../../../github/client/lookup/pull-request-lookup-data' +import { admissionTierForRefreshReason } from '../../../github/pr-refresh-candidate-policy' +import type { GitAdmissionTier } from '../../../../shared/rpc-contract/git-admission-tier-params' +import { hostedReviewForBranchReply } from '../../../../shared/source-control/hosted-review/hosted-review-contracts' +import { readHostedReviewForBranch } from '../../../source-control/hosted-review' +import { getStoredRepoExecutionHostId } from '../../../workspaces/execution-host/repo-execution-host' +import { hostedReviewSshConnectionId } from '../../../source-control/hosted-review-execution-host' import { createHostedReview, getHostedReviewCreationEligibility -} from '../source-control/hosted-review-creation' -import type { HostedReviewExecutionOptions } from '../source-control/hosted-review-git-options' -import { createStackedHostedReview } from '../source-control/stacked-hosted-review-creation' -import { guardWslUncPathAccess } from '../wsl/filesystem/wsl-unc-access-gate' +} from '../../../source-control/hosted-review-creation' +import type { HostedReviewExecutionOptions } from '../../../source-control/hosted-review-git-options' +import { createStackedHostedReview } from '../../../source-control/stacked-hosted-review-creation' +import { guardWslUncPathAccess } from '../../../wsl/filesystem/wsl-unc-access-gate' type HostedReviewTargetArgs = { repoSelector: string; worktreeSelector?: string } diff --git a/src/main/runtime/selected-review-branch.ts b/src/main/runtime/integrations/reviews/selected-review-branch.ts similarity index 91% rename from src/main/runtime/selected-review-branch.ts rename to src/main/runtime/integrations/reviews/selected-review-branch.ts index 5feda3bd55f..ec96d71eeae 100644 --- a/src/main/runtime/selected-review-branch.ts +++ b/src/main/runtime/integrations/reviews/selected-review-branch.ts @@ -1,6 +1,6 @@ -import type { GitPushTarget } from '../../shared/worktree/types' -import type { ForgeProviderId } from '../source-control/forge-provider' -import type { getPRForBranch } from '../github/client' +import type { GitPushTarget } from '../../../../shared/worktree/types' +import type { ForgeProviderId } from '../../../source-control/forge-provider' +import type { getPRForBranch } from '../../../github/client/lookup/get-pr-for-branch' export type SelectedReviewBranchInput = { branchNameOverride?: string diff --git a/src/main/runtime/runtime-bundled-skill-install.ts b/src/main/runtime/integrations/skill/runtime-bundled-skill-install.ts similarity index 88% rename from src/main/runtime/runtime-bundled-skill-install.ts rename to src/main/runtime/integrations/skill/runtime-bundled-skill-install.ts index 417c4e48391..22210dfd0d8 100644 --- a/src/main/runtime/runtime-bundled-skill-install.ts +++ b/src/main/runtime/integrations/skill/runtime-bundled-skill-install.ts @@ -4,19 +4,19 @@ import type { LocalBundledSkillExecuteRequest, BundledSkillPlan, LocalBundledSkillPlanRequest -} from '../../shared/bundled-skill-plan' +} from '../../../../shared/bundled-skill-plan' import { localBundledSkillInput, type BundledSkillSelection -} from '../skills/bundled-skill-install/local-host' +} from '../../../skills/bundled-skill-install/local-host' import { autoUpdateInstalledBundledSkills, installBundledSkills, previewBundledSkillInstall, type BundledSkillServiceInput -} from '../skills/bundled-skill-install/service' -import { clearSkillDiscoveryCaches } from '../skills/skill-discovery-target' -import { resolveSkillInstallDestination } from '../skills/skill-install-destinations' +} from '../../../skills/bundled-skill-install/service' +import { clearSkillDiscoveryCaches } from '../../../skills/skill-discovery-target' +import { resolveSkillInstallDestination } from '../../../skills/skill-install-destinations' import type { RuntimeSkillCommandHost } from './runtime-skill-command-contract' import { createSkillInstallAuthority } from './runtime-skill-install-authority' diff --git a/src/main/runtime/runtime-skill-command-contract.ts b/src/main/runtime/integrations/skill/runtime-skill-command-contract.ts similarity index 89% rename from src/main/runtime/runtime-skill-command-contract.ts rename to src/main/runtime/integrations/skill/runtime-skill-command-contract.ts index f98fd7004a6..d002e45ca1a 100644 --- a/src/main/runtime/runtime-skill-command-contract.ts +++ b/src/main/runtime/integrations/skill/runtime-skill-command-contract.ts @@ -1,21 +1,21 @@ import type { AgentSkillShareOperation, AgentSkillShareRequest -} from '../../shared/agent-skill-sharing-contract' -import type { DiscoveredSkill } from '../../shared/skills' -import type { ExecutionHostId } from '../../shared/execution-host' +} from '../../../../shared/agent-skill-sharing-contract' +import type { DiscoveredSkill } from '../../../../shared/skills' +import type { ExecutionHostId } from '../../../../shared/execution-host' import type { SkillBundleInstallPreview, SkillBundleInstallPreviewRequest, SkillBundleInstallProgress, SkillBundleInstallRequest, SkillBundleInstallResult -} from '../../shared/skill-bundle-install-contract' +} from '../../../../shared/skill-bundle-install-contract' import type { SkillUploadBeginRequest, SkillUploadChunkRequest -} from '../../shared/skill-upload-session-contract' -import type { SkillUploadSessionService } from '../skills/skill-upload-session-service' +} from '../../../../shared/skill-upload-session-contract' +import type { SkillUploadSessionService } from '../../../skills/skill-upload-session-service' import type { RuntimeSkillCommands } from './runtime-skill-command-surface' import type { SkillCloudDownloadGrant, @@ -25,8 +25,8 @@ import type { SkillCloudPublishRequest, SkillCloudPublishResult, SkillCloudVersion -} from '../../shared/skill-cloud-contract' -import type { SkillCloudService } from '../skills/skill-cloud-service' +} from '../../../../shared/skill-cloud-contract' +import type { SkillCloudService } from '../../../skills/skill-cloud-service' import type { ManagedSkillInstall, SkillInstallPreview, @@ -34,15 +34,15 @@ import type { SkillInstallRequest, SkillInstallResult, SkillRemoveRequest -} from '../../shared/skill-install-contract' -import type { SkillProviderRootOverrides } from '../skills/skill-provider-destinations' +} from '../../../../shared/skill-install-contract' +import type { SkillProviderRootOverrides } from '../../../skills/skill-provider-destinations' import type { BundledSkillAutoUpdateRequest, LocalBundledSkillExecuteRequest, BundledSkillInstallResult, BundledSkillPlan, LocalBundledSkillPlanRequest -} from '../../shared/bundled-skill-plan' +} from '../../../../shared/bundled-skill-plan' export type RuntimeSkillCommandSurface = { setSkillCloudService(service: SkillCloudService): void assertAgentSkillSharingAllowed(): void diff --git a/src/main/runtime/runtime-skill-command-surface.ts b/src/main/runtime/integrations/skill/runtime-skill-command-surface.ts similarity index 88% rename from src/main/runtime/runtime-skill-command-surface.ts rename to src/main/runtime/integrations/skill/runtime-skill-command-surface.ts index efe78f646ca..23b6727eec3 100644 --- a/src/main/runtime/runtime-skill-command-surface.ts +++ b/src/main/runtime/integrations/skill/runtime-skill-command-surface.ts @@ -1,8 +1,10 @@ +import '../../../../shared/git/admission/git-admission-state' +import '../../../crash-reporting/main-process-lifecycle-identity' import { join } from 'node:path' import { assertAgentSkillSharingAllowed, isAgentSkillSharingEnabled -} from '../../shared/agent-skill-sharing-gate' +} from '../../../../shared/agent-skill-sharing-gate' import { AGENT_SKILL_BUNDLE_NAME_TAKEN_CODE, AGENT_SKILL_NOT_SHAREABLE_CODE, @@ -10,19 +12,22 @@ import { AgentSkillSharingError, type AgentSkillShareOperation, type AgentSkillShareRequest -} from '../../shared/agent-skill-sharing-contract' -import type { DiscoveredSkill } from '../../shared/skills' -import { SharingUnavailableOnHostError } from '../../shared/sharing-unavailable-on-host' -import { SKILL_SHARE_NAME_TAKEN_ERROR } from '../../shared/skill-sharing-contract' -import { selectDiscoveredSkills } from '../skills/agent-skill-selection' -import { SkillSharePreparationService } from '../skills/skill-share-preparation-service' +} from '../../../../shared/agent-skill-sharing-contract' +import type { DiscoveredSkill } from '../../../../shared/skills' +import { SharingUnavailableOnHostError } from '../../../../shared/sharing-unavailable-on-host' +import { SKILL_SHARE_NAME_TAKEN_ERROR } from '../../../../shared/skill-sharing-contract' +import { selectDiscoveredSkills } from '../../../skills/agent-skill-selection' +import { SkillSharePreparationService } from '../../../skills/skill-share-preparation-service' import { RuntimeSkillInstallQueries } from './runtime-skill-install-queries' import type { RuntimeSkillCommandSurface, RuntimeSkillCommandHost } from './runtime-skill-command-contract' -import type { SkillCloudOptions, SkillCloudPublishRequest } from '../../shared/skill-cloud-contract' -import type { SkillCloudService } from '../skills/skill-cloud-service' +import type { + SkillCloudOptions, + SkillCloudPublishRequest +} from '../../../../shared/skill-cloud-contract' +import type { SkillCloudService } from '../../../skills/skill-cloud-service' export class RuntimeSkillCommands extends RuntimeSkillInstallQueries diff --git a/src/main/runtime/runtime-skill-install-authority.ts b/src/main/runtime/integrations/skill/runtime-skill-install-authority.ts similarity index 89% rename from src/main/runtime/runtime-skill-install-authority.ts rename to src/main/runtime/integrations/skill/runtime-skill-install-authority.ts index 070160dd3ee..06327783a45 100644 --- a/src/main/runtime/runtime-skill-install-authority.ts +++ b/src/main/runtime/integrations/skill/runtime-skill-install-authority.ts @@ -1,6 +1,6 @@ import { homedir } from 'node:os' -import { getWslHome } from '../wsl/discovery/distro-catalog' -import { parseWslUncPath } from '../../shared/wsl-paths' +import { getWslHome } from '../../../wsl/discovery/distro-catalog' +import { parseWslUncPath } from '../../../../shared/wsl-paths' import { getConnectionExecutionHostId, getRepoExecutionHostId, @@ -8,17 +8,17 @@ import { normalizeExecutionHostId, parseExecutionHostId, type ExecutionHostId -} from '../../shared/execution-host' -import { getRepoIdFromWorktreeId } from '../../shared/worktree/id' -import { parseWorkspaceKey } from '../../shared/workspace-scope' -import type { SkillInstallDestinationAuthority } from '../skills/skill-install-destinations' +} from '../../../../shared/execution-host' +import { getRepoIdFromWorktreeId } from '../../../../shared/worktree/id' +import { parseWorkspaceKey } from '../../../../shared/workspace-scope' +import type { SkillInstallDestinationAuthority } from '../../../skills/skill-install-destinations' import { resolveEnvironmentSkillProviderRoots, resolveWslSkillProviderRoots, withClaudeSkillProviderRoot -} from '../skills/skill-provider-runtime-roots' -import type { SkillInstallRequest } from '../../shared/skill-install-contract' -import type { SkillProviderRootOverrides } from '../skills/skill-provider-destinations' +} from '../../../skills/skill-provider-runtime-roots' +import type { SkillInstallRequest } from '../../../../shared/skill-install-contract' +import type { SkillProviderRootOverrides } from '../../../skills/skill-provider-destinations' import type { RuntimeSkillCommandHost } from './runtime-skill-command-contract' /** Whether the destination lives on an SSH target; a workspace that cannot be placed throws. */ diff --git a/src/main/runtime/runtime-skill-install-commands.test.ts b/src/main/runtime/integrations/skill/runtime-skill-install-commands.test.ts similarity index 95% rename from src/main/runtime/runtime-skill-install-commands.test.ts rename to src/main/runtime/integrations/skill/runtime-skill-install-commands.test.ts index 2da8e1db277..2acdc959540 100644 --- a/src/main/runtime/runtime-skill-install-commands.test.ts +++ b/src/main/runtime/integrations/skill/runtime-skill-install-commands.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from 'vitest' -import type { SkillBundleInstallRequest } from '../../shared/skill-bundle-install-contract' +import type { SkillBundleInstallRequest } from '../../../../shared/skill-bundle-install-contract' import type { RuntimeSkillCommandHost } from './runtime-skill-command-contract' -import { toSshExecutionHostId } from '../../shared/execution-host' +import { toSshExecutionHostId } from '../../../../shared/execution-host' import { RuntimeSkillInstallCommands, SKILL_SSH_UNAVAILABLE diff --git a/src/main/runtime/runtime-skill-install-commands.ts b/src/main/runtime/integrations/skill/runtime-skill-install-commands.ts similarity index 90% rename from src/main/runtime/runtime-skill-install-commands.ts rename to src/main/runtime/integrations/skill/runtime-skill-install-commands.ts index 67be93c636a..d919f1e6e17 100644 --- a/src/main/runtime/runtime-skill-install-commands.ts +++ b/src/main/runtime/integrations/skill/runtime-skill-install-commands.ts @@ -1,15 +1,20 @@ +import '../../../../shared/git/admission/git-admission-state' +import '../../../crash-reporting/main-process-lifecycle-identity' import { join } from 'node:path' -import { detectInstalledAgentsWithShellPathHydration } from '../preflight/agent-detection' -import { executeSkillInstallRequest } from '../skills/skill-install-request-service' -import { executeSkillBundleInstallRequest } from '../skills/skill-bundle-install-request-service' -import { SkillUploadSessionService } from '../skills/skill-upload-session-service' -import { SKILL_UPLOAD_STAGING_ROOT_NAME } from '../skills/skill-upload-staging-ownership' +import { detectInstalledAgentsWithShellPathHydration } from '../../../preflight/installed-agent-detection' +import { executeSkillInstallRequest } from '../../../skills/skill-install-request-service' +import { executeSkillBundleInstallRequest } from '../../../skills/skill-bundle-install-request-service' +import { SkillUploadSessionService } from '../../../skills/skill-upload-session-service' +import { SKILL_UPLOAD_STAGING_ROOT_NAME } from '../../../skills/skill-upload-staging-ownership' import type { SkillBundleInstallProgress, SkillBundleInstallRequest, SkillBundleInstallResult -} from '../../shared/skill-bundle-install-contract' -import type { SkillInstallRequest, SkillInstallResult } from '../../shared/skill-install-contract' +} from '../../../../shared/skill-bundle-install-contract' +import type { + SkillInstallRequest, + SkillInstallResult +} from '../../../../shared/skill-install-contract' import type { RuntimeSkillCommandHost } from './runtime-skill-command-contract' import type { BundledSkillAutoUpdateRequest, @@ -17,7 +22,7 @@ import type { BundledSkillInstallResult, BundledSkillPlan, LocalBundledSkillPlanRequest -} from '../../shared/bundled-skill-plan' +} from '../../../../shared/bundled-skill-plan' import { autoUpdateLocalBundledSkills, executeLocalBundledSkills, diff --git a/src/main/runtime/runtime-skill-install-queries.ts b/src/main/runtime/integrations/skill/runtime-skill-install-queries.ts similarity index 87% rename from src/main/runtime/runtime-skill-install-queries.ts rename to src/main/runtime/integrations/skill/runtime-skill-install-queries.ts index e6174783037..6525a046317 100644 --- a/src/main/runtime/runtime-skill-install-queries.ts +++ b/src/main/runtime/integrations/skill/runtime-skill-install-queries.ts @@ -1,26 +1,28 @@ +import '../../../../shared/git/admission/git-admission-state' +import '../../../crash-reporting/main-process-lifecycle-identity' import { homedir } from 'node:os' import { dirname, join } from 'node:path' -import { detectInstalledAgentsWithShellPathHydration } from '../preflight/agent-detection' -import { listManagedSkillInstalls } from '../skills/skill-install-provenance' -import { WslSkillInstallFilesystem } from '../skills/skill-wsl-install-filesystem' -import { nativeSkillInstallFilesystem } from '../skills/skill-install-filesystem' +import { detectInstalledAgentsWithShellPathHydration } from '../../../preflight/installed-agent-detection' +import { listManagedSkillInstalls } from '../../../skills/skill-install-provenance' +import { WslSkillInstallFilesystem } from '../../../skills/skill-wsl-install-filesystem' +import { nativeSkillInstallFilesystem } from '../../../skills/skill-install-filesystem' import { previewSharedSkillBundleInstall, previewSharedSkillInstall, removeSharedSkillInstall -} from '../skills/skill-install-management-service' -import { toLinuxPath } from '../../shared/wsl-paths' -import type { SkillBundleInstallPreviewRequest } from '../../shared/skill-bundle-install-contract' +} from '../../../skills/skill-install-management-service' +import { toLinuxPath } from '../../../../shared/wsl-paths' +import type { SkillBundleInstallPreviewRequest } from '../../../../shared/skill-bundle-install-contract' import type { SkillInstallPreviewRequest, SkillInstallRequest, SkillRemoveRequest, ManagedSkillInstall -} from '../../shared/skill-install-contract' +} from '../../../../shared/skill-install-contract' import type { SkillUploadBeginRequest, SkillUploadChunkRequest -} from '../../shared/skill-upload-session-contract' +} from '../../../../shared/skill-upload-session-contract' import { RuntimeSkillInstallCommands, SKILL_SSH_UNAVAILABLE diff --git a/src/main/runtime/linear-save-markdown.test.ts b/src/main/runtime/linear-save-markdown.test.ts index ecc0f3bbc57..a7ed80fe3f5 100644 --- a/src/main/runtime/linear-save-markdown.test.ts +++ b/src/main/runtime/linear-save-markdown.test.ts @@ -1,7 +1,7 @@ import { createServer, type Server } from 'node:http' import { afterEach, beforeEach, expect, it, vi } from 'vitest' import type * as linearClient from '../linear/client' -import { RuntimeLinearSaveCommands } from './runtime-linear-save-commands' +import { RuntimeLinearSaveCommands } from './integrations/linear/runtime-linear-save-commands' import { loadLinearSdk } from '../linear/linear-sdk' const boundary = vi.hoisted(() => ({ clients: vi.fn(), status: vi.fn(), signing: vi.fn() })) diff --git a/src/main/runtime/orca-runtime-core.ts b/src/main/runtime/orca-runtime-core.ts index 540518b52aa..66ce03be239 100644 --- a/src/main/runtime/orca-runtime-core.ts +++ b/src/main/runtime/orca-runtime-core.ts @@ -8,13 +8,13 @@ import type { RuntimeTerminalPresentation } from '../../shared/runtime-types' import type { RuntimeEdgeCommandSurface } from './runtime-edge-command-controller' -import type { RuntimeLinearCommandSurface } from './runtime-linear-command-surface' +import type { RuntimeLinearCommandSurface } from './integrations/linear/runtime-linear-command-surface' import type { RuntimeFileCommandSurface } from './runtime-file-command-surface' -import type { RuntimeGitCommandSurface } from './runtime-git-command-surface' +import type { RuntimeGitCommandSurface } from './integrations/git/runtime-git-command-surface' import type { RuntimeRepositoryCommandSurface } from './runtime-repository-command-surface' import type { RuntimeReviewCommandSurface } from './runtime-review-command-surface' import type { RuntimeServiceCommandSurface } from './runtime-service-command-surface' -import type { RuntimeSkillCommandSurface } from './runtime-skill-command-contract' +import type { RuntimeSkillCommandSurface } from './integrations/skill/runtime-skill-command-contract' export type PtyIncarnationHandleRecord = Readonly<{ handle: string diff --git a/src/main/runtime/orca-runtime-git-diff-budget.test.ts b/src/main/runtime/orca-runtime-git-diff-budget.test.ts index dfce0ba1a7a..e43bc5eef97 100644 --- a/src/main/runtime/orca-runtime-git-diff-budget.test.ts +++ b/src/main/runtime/orca-runtime-git-diff-budget.test.ts @@ -3,8 +3,8 @@ import { REMOTE_RPC_MAX_CONTENT_BYTES } from '../../shared/remote-rpc-content-bu import type { GitDiffResult } from '../../shared/git/diff/git-diff-compare-types' import type { GlobalSettings } from '../../shared/global-settings-types' -import { RuntimeGitCommands } from './orca-runtime-git' -import type { ResolvedRuntimeGitWorktree } from './runtime-git-command-target' +import { RuntimeGitCommands } from './integrations/git/orca-runtime-git' +import type { ResolvedRuntimeGitWorktree } from './integrations/git/runtime-git-command-target' const mocks = vi.hoisted(() => ({ getDiff: vi.fn(), diff --git a/src/main/runtime/orca-runtime-git.test.ts b/src/main/runtime/orca-runtime-git.test.ts index 35c0fadbd96..148b4707385 100644 --- a/src/main/runtime/orca-runtime-git.test.ts +++ b/src/main/runtime/orca-runtime-git.test.ts @@ -11,8 +11,8 @@ import { SSH_HOST_NOT_SERVED_MESSAGE, SshHostNotServedError } from '../providers/ssh-host-not-served-error' -import { RuntimeGitCommands } from './orca-runtime-git' -import type { ResolvedRuntimeGitWorktree } from './runtime-git-command-target' +import { RuntimeGitCommands } from './integrations/git/orca-runtime-git' +import type { ResolvedRuntimeGitWorktree } from './integrations/git/runtime-git-command-target' const mocks = vi.hoisted(() => ({ checkoutBranch: vi.fn(), diff --git a/src/main/runtime/orca-runtime-test-mocks/setup.spec.ts b/src/main/runtime/orca-runtime-test-mocks/setup.spec.ts index 10f02dc82b3..97a16c8c683 100644 --- a/src/main/runtime/orca-runtime-test-mocks/setup.spec.ts +++ b/src/main/runtime/orca-runtime-test-mocks/setup.spec.ts @@ -589,7 +589,8 @@ vi.mock('../../github/issues', async (importOriginal) => { const actual = (await importOriginal()) as Record return { ...actual, - getIssue: getIssueMock + getIssue: getIssueMock, + listIssues: listGitHubIssuesMock } }) @@ -712,3 +713,179 @@ export { } export { reconcileClaudeAgentViewMock } + +vi.mock(import('../../preflight/installed-agent-detection'), async (importOriginal) => ({ + ...(await importOriginal()), + detectInstalledAgentsWithShellPathHydration: detectInstalledAgentsWithShellPathHydrationMock +})) + +vi.mock(import('../../github/client/lookup/pr-for-branch-outcome'), async (importOriginal) => ({ + ...(await importOriginal()), + getPRForBranchOutcome: getPRForBranchOutcomeMock +})) + +vi.mock(import('../../github/client/fetch/get-work-item'), async (importOriginal) => ({ + ...(await importOriginal()), + getWorkItem: getGitHubWorkItemMock, + getWorkItemByOwnerRepo: getGitHubWorkItemByOwnerRepoMock +})) + +vi.mock(import('../../github/client/check/get-pr-checks'), async (importOriginal) => ({ + ...(await importOriginal()), + getPRChecks: getGitHubPRChecksMock +})) + +vi.mock(import('../../github/client/check/rerun-pr-checks'), async (importOriginal) => ({ + ...(await importOriginal()), + rerunPRChecks: rerunGitHubPRChecksMock +})) + +vi.mock(import('../../github/client/check/get-pr-check-details'), async (importOriginal) => ({ + ...(await importOriginal()), + getPRCheckDetails: getGitHubPRCheckDetailsMock +})) + +vi.mock(import('../../github/client/fetch/get-pr-comments'), async (importOriginal) => ({ + ...(await importOriginal()), + getPRComments: getGitHubPRCommentsMock +})) + +vi.mock(import('../../github/client/update/resolve-review-thread'), async (importOriginal) => ({ + ...(await importOriginal()), + resolveReviewThread: resolveGitHubReviewThreadMock +})) + +vi.mock(import('../../github/client/update/pr-file-viewed'), async (importOriginal) => ({ + ...(await importOriginal()), + setPRFileViewed: setGitHubPRFileViewedMock +})) + +vi.mock(import('../../github/client/update/pr-details'), async (importOriginal) => ({ + ...(await importOriginal()), + updatePRTitle: updateGitHubPRTitleMock, + updatePRDetails: updateGitHubPRDetailsMock +})) + +vi.mock(import('../../github/client/merge/merge-pr'), async (importOriginal) => ({ + ...(await importOriginal()), + mergePR: mergeGitHubPRMock +})) + +vi.mock(import('../../github/client/merge/pr-auto-merge'), async (importOriginal) => ({ + ...(await importOriginal()), + setPRAutoMerge: setGitHubPRAutoMergeMock +})) + +vi.mock(import('../../github/client/update/pr-state'), async (importOriginal) => ({ + ...(await importOriginal()), + updatePRState: updateGitHubPRStateMock +})) + +vi.mock(import('../../github/client/update/pr-reviewers'), async (importOriginal) => ({ + ...(await importOriginal()), + requestPRReviewers: requestGitHubPRReviewersMock, + removePRReviewers: removeGitHubPRReviewersMock +})) + +vi.mock(import('../../github/client/create/add-pr-review-comment'), async (importOriginal) => ({ + ...(await importOriginal()), + addPRReviewComment: addGitHubPRReviewCommentMock, + addPRReviewCommentReply: addGitHubPRReviewCommentReplyMock +})) + +vi.mock(import('../../github/client/list/list-work-items'), async (importOriginal) => ({ + ...(await importOriginal()), + listWorkItems: listGitHubWorkItemsMock +})) + +vi.mock(import('../../github/client/list/count-work-items'), async (importOriginal) => ({ + ...(await importOriginal()), + countWorkItems: countGitHubWorkItemsMock +})) + +vi.mock(import('../../github/issue-create'), async (importOriginal) => ({ + ...(await importOriginal()), + createIssue: createGitHubIssueMock +})) + +vi.mock(import('../../github/issue-update'), async (importOriginal) => ({ + ...(await importOriginal()), + updateIssue: updateGitHubIssueMock +})) + +vi.mock(import('../../github/issue-comment'), async (importOriginal) => ({ + ...(await importOriginal()), + addIssueComment: addGitHubIssueCommentMock +})) + +vi.mock(import('../../github/issue-field-options'), async (importOriginal) => ({ + ...(await importOriginal()), + listLabels: listGitHubLabelsMock, + listAssignableUsers: listGitHubAssignableUsersMock +})) + +vi.mock(import('../../gitlab/merge-request-list'), async (importOriginal) => ({ + ...(await importOriginal()), + listMergeRequests: listGitLabMergeRequestsMock +})) + +vi.mock(import('../../gitlab/work-item-queries'), async (importOriginal) => ({ + ...(await importOriginal()), + listWorkItems: listGitLabWorkItemsMock, + listTodos: listGitLabTodosMock, + getWorkItemByProjectRef: getGitLabWorkItemByProjectRefMock +})) + +vi.mock(import('../../gitlab/issues'), async (importOriginal) => ({ + ...(await importOriginal()), + listIssues: listGitLabIssuesMock, + createIssue: createGitLabIssueMock, + addIssueComment: addGitLabIssueCommentMock +})) + +vi.mock(import('../../gitlab/project-label-and-member-lookup'), async (importOriginal) => ({ + ...(await importOriginal()), + listLabels: listGitLabLabelsMock, + listAssignableUsers: listGitLabAssignableUsersMock +})) + +vi.mock(import('../../gitlab/gitlab-project-ref-resolution'), async (importOriginal) => ({ + ...(await importOriginal()), + getProjectRefForRemote: getGitLabProjectRefForRemoteMock +})) + +vi.mock(import('../../gitlab/issue-update'), async (importOriginal) => ({ + ...(await importOriginal()), + updateIssue: updateGitLabIssueMock +})) + +vi.mock(import('../../gitlab/merge-request-review-mutations'), async (importOriginal) => ({ + ...(await importOriginal()), + addMRComment: addGitLabMRCommentMock, + addMRInlineComment: addGitLabMRInlineCommentMock, + resolveMRDiscussion: resolveGitLabMRDiscussionMock, + updateMRReviewers: updateGitLabMRReviewersMock +})) + +vi.mock(import('../../gitlab/pipeline-job-mutations'), async (importOriginal) => ({ + ...(await importOriginal()), + getJobTrace: getGitLabJobTraceMock, + retryJob: retryGitLabJobMock +})) + +vi.mock(import('../../gitlab/merge-request-state-mutations'), async (importOriginal) => ({ + ...(await importOriginal()), + mergeMR: mergeGitLabMRMock, + closeMR: closeGitLabMRMock, + reopenMR: reopenGitLabMRMock +})) + +vi.mock(import('../../gitlab/merge-request-update'), async (importOriginal) => ({ + ...(await importOriginal()), + updateMR: updateGitLabMRMock +})) + +vi.mock(import('../../gitlab/gitlab-known-host-probe'), async (importOriginal) => ({ + ...(await importOriginal()), + getGlabKnownHosts: getGlabKnownHostsMock +})) diff --git a/src/main/runtime/orca-runtime.ts b/src/main/runtime/orca-runtime.ts index 0c8dc9e60b9..3163d0e4ec0 100644 --- a/src/main/runtime/orca-runtime.ts +++ b/src/main/runtime/orca-runtime.ts @@ -1,7 +1,7 @@ import type { SessionOptionValue } from '../../shared/native-chat/input/native-chat-session-options' import { conversationRecordReader } from './orchestration/structured-session-lineage' -import type { RuntimeLinearCommandSurface } from './runtime-linear-command-surface' -import { installRuntimeLinearCommandSurface } from './runtime-linear-command-surface' +import type { RuntimeLinearCommandSurface } from './integrations/linear/runtime-linear-command-surface' +import { installRuntimeLinearCommandSurface } from './integrations/linear/runtime-linear-command-surface' import { publishNativeChatFollowUpChanges } from './runtime-native-chat-follow-up-events' import { publishWorkspaceViewChanges } from './runtime-workspace-view-change-events' import { diff --git a/src/main/runtime/runtime-edge-command-controller.ts b/src/main/runtime/runtime-edge-command-controller.ts index 4848a128434..e8f1ff9b179 100644 --- a/src/main/runtime/runtime-edge-command-controller.ts +++ b/src/main/runtime/runtime-edge-command-controller.ts @@ -5,7 +5,7 @@ import type { RuntimeBrowserCommands } from './browser/browser-commands' import { RuntimeEmulatorCommands } from './orca-runtime-emulator' import { RuntimeBrowserScreencastController } from './runtime-browser-screencast-controller' import { createRuntimeBrowserCommands } from './runtime-browser-commands-factory' -import { RuntimeJiraCommands } from './runtime-jira-commands' +import { RuntimeJiraCommands } from './integrations/jira/runtime-jira-commands' import type { RpcBinarySender } from './rpc/rpc-binary-sender' type PublicMethods = Pick diff --git a/src/main/runtime/runtime-linear-command-dependencies.ts b/src/main/runtime/runtime-linear-command-dependencies.ts deleted file mode 100644 index 847ca60a3bc..00000000000 --- a/src/main/runtime/runtime-linear-command-dependencies.ts +++ /dev/null @@ -1,138 +0,0 @@ -import type { RuntimeClientEvent } from '../../shared/runtime-client-events' -import type { LinearIssueSummary } from '../../shared/linear/agent-access' - -export { randomUUID } from 'node:crypto' -export { resolve } from 'node:path' -export type { RuntimeClientEvent } from '../../shared/runtime-client-events' -export type { - LinearCurrentIssueContextHints, - LinearAttachRequest, - LinearAttachResult, - LinearCommentAddRequest, - LinearCommentAddResult, - LinearCommentDeleteRequest, - LinearCommentDeleteResult, - LinearCommentEditRequest, - LinearCommentEditResult, - LinearCreateResult, - LinearErrorCode, - LinearIssueListFilter, - LinearIssueListResult, - LinearProjectListResult, - LinearIssueRequest, - LinearIssueSummary, - LinearIssueTaskUpdateRequest, - LinearIssueTaskUpdateResult, - LinearMcpIssueListRequest, - LinearMcpIssueListResult, - LinearIssueRelationWriteRequest, - LinearIssueRelationWriteResult, - LinearSaveIssueRequest, - LinearSaveIssueResult, - LinearTeamLabelsResult, - LinearTeamListResult, - LinearTeamMembersResult, - LinearTeamStatesResult, - LinearStatusSetResult -} from '../../shared/linear/agent-access' -export type { LinearIssueUpdate } from '../../shared/issue-mutation-types' -export type { LinearProjectSummary } from '../../shared/linear/project-types' -export type { LinearWorkspaceSelection } from '../../shared/linear/workspace-types' -export { - LINEAR_SEARCH_MAX_LIMIT, - LINEAR_WRITE_BODY_CAP, - clampLinearSearchLimit -} from '../../shared/linear/agent-access' -export { clampLinearIssueListLimit } from '../../shared/linear/issue-read-limits' -export { isLinearUuid } from '../../shared/linear/uuid' -export { isPathInsideOrEqual } from '../../shared/cross-platform-path' -export { - connect as connectLinear, - disconnect as disconnectLinear, - getStatus as getLinearStatus, - isAuthError as isLinearAuthError, - selectWorkspace as selectLinearWorkspace, - testConnection as testLinearConnection -} from '../linear/client' -export { - addIssueComment as addLinearIssueComment, - addIssueCommentForAgent as addLinearIssueCommentForAgent, - createIssueAttachment as createLinearIssueAttachment, - deleteIssueCommentForAgent as deleteLinearIssueCommentForAgent, - updateIssueCommentForAgent as updateLinearIssueCommentForAgent -} from '../linear/linear-issue-comments' -export { - createIssueForAgent as createLinearIssueForAgent, - createIssue as createLinearIssue, - updateIssueForAgent as updateLinearIssueForAgent, - updateIssue as updateLinearIssue -} from '../linear/linear-issue-mutations' -export { - getAttachmentByUuidForAgent as getLinearAttachmentByUuidForAgent, - getCommentByUuidForAgent as getLinearCommentByUuidForAgent, - getIssue as getLinearIssue, - getIssueByUuidForAgent as getLinearIssueByUuidForAgent, - getIssueCommentThreadRoot as getLinearIssueCommentThreadRoot, - searchIssues as searchLinearIssues -} from '../linear/linear-issue-lookups' -export { - listIssues as listLinearIssues, - type LinearListFilter -} from '../linear/linear-issue-listing' -export type { LinearIssueListOptions } from '../linear/linear-issue-query-documents' -export { LinearWriteFailure } from '../linear/linear-issue-write-support' - -export { listMcpIssues } from '../linear/mcp-issue-list' -export { writeIssueRelation } from '../linear/issue-relation-write' -export { - getProject as getLinearProject, - listProjectsByExactName as listLinearProjectsByExactName, - listProjectTeams as listLinearProjectTeams, - listProjects as listLinearProjects -} from '../linear/projects' -export { - getTeamLabelsOrThrow as getLinearTeamLabelsOrThrow, - getTeamMembersOrThrow as getLinearTeamMembersOrThrow, - getTeamStatesOrThrow as getLinearTeamStatesOrThrow, - getViewerForWorkspaceOrThrow as getLinearViewerForWorkspaceOrThrow, - listTeamsForAgent as listLinearTeamsForAgent, - listTeamsOrThrow as listLinearTeamsOrThrow -} from '../linear/teams' - -export type LinearAgentWriteTarget = { - issue: LinearIssueSummary - workspaceId: string -} - -export type LinearCreateFieldIntent = { - stateId?: string - assigneeId?: string | null - priority?: number - estimate?: number | null - dueDate?: string | null - labelIds?: string[] - projectId?: string -} - -export type LinearLinkedIssueUpdatedEvent = Extract< - RuntimeClientEvent, - { type: 'linearLinkedIssueUpdated' } -> - -export function sameStringSet(left: string[], right: string[]): boolean { - if (left.length !== right.length) { - return false - } - const rightSet = new Set(right) - return left.every((value) => rightSet.has(value)) -} - -export function labelsForIds( - ids: string[], - labels: { id?: string | null; name?: string | null; color?: string | null }[] -): { id: string; name: string; color?: string | null }[] { - return ids.map((id) => { - const label = labels.find((candidate) => candidate.id === id) - return { id, name: label?.name ?? id, ...(label?.color ? { color: label.color } : {}) } - }) -} diff --git a/src/main/runtime/runtime-local-worktree-create-candidate.ts b/src/main/runtime/runtime-local-worktree-create-candidate.ts index 403397e67d1..b9ccc618e62 100644 --- a/src/main/runtime/runtime-local-worktree-create-candidate.ts +++ b/src/main/runtime/runtime-local-worktree-create-candidate.ts @@ -24,7 +24,7 @@ import { getSelectedReviewBranch, isAllowedPushTargetRemoteConflict, isMatchingSelectedGitHubPr -} from './selected-review-branch' +} from './integrations/reviews/selected-review-branch' import { canCheckoutExistingLocalBranch, getLocalGitHubPrForBranch, diff --git a/src/main/runtime/runtime-local-worktree-create-legacy-branch.ts b/src/main/runtime/runtime-local-worktree-create-legacy-branch.ts index f5d11d0cdaa..2ba8b2e9a19 100644 --- a/src/main/runtime/runtime-local-worktree-create-legacy-branch.ts +++ b/src/main/runtime/runtime-local-worktree-create-legacy-branch.ts @@ -1,6 +1,6 @@ import type { RuntimeManagedWorktreeCreateArgs } from './runtime-managed-worktree-create-types' import { getBranchConflictKind } from '../git/repo' -import { getSelectedReviewBranch } from './selected-review-branch' +import { getSelectedReviewBranch } from './integrations/reviews/selected-review-branch' import { resolveCreateBranchName } from './runtime-worktree-create-git' export async function resolveLegacyRemoteBranch(args: { diff --git a/src/main/runtime/runtime-repository-command-surface.ts b/src/main/runtime/runtime-repository-command-surface.ts index 2a50d1ecb50..74d5a9b54a8 100644 --- a/src/main/runtime/runtime-repository-command-surface.ts +++ b/src/main/runtime/runtime-repository-command-surface.ts @@ -1,5 +1,5 @@ -import type { RuntimeGitHubRepositoryQueryCommands } from './runtime-github-repository-query-commands' -import type { RuntimeHostedReviewCommands } from './runtime-hosted-review-commands' +import type { RuntimeGitHubRepositoryQueryCommands } from './integrations/github/runtime-github-repository-query-commands' +import type { RuntimeHostedReviewCommands } from './integrations/reviews/runtime-hosted-review-commands' import type { RuntimeNestedRepoImport } from './runtime-nested-repo-import' import type { RuntimeProjectGroupController } from './runtime-project-group-controller' import type { RuntimeProjectHostSetupController } from './runtime-project-host-setup-controller' diff --git a/src/main/runtime/runtime-review-command-surface.ts b/src/main/runtime/runtime-review-command-surface.ts index 42c3f2cba42..11b4b1bc6a8 100644 --- a/src/main/runtime/runtime-review-command-surface.ts +++ b/src/main/runtime/runtime-review-command-surface.ts @@ -1,9 +1,9 @@ -import type { RuntimeGitHubIssueCommentCommands } from './runtime-github-issue-comment-commands' -import type { RuntimeGitHubProjectCommands } from './runtime-github-project-commands' -import type { RuntimeGitHubReviewMutationCommands } from './runtime-github-review-mutation-commands' -import type { RuntimeGitHubReviewQueryCommands } from './runtime-github-review-query-commands' -import type { RuntimeGitLabMutationCommands } from './runtime-gitlab-mutation-commands' -import type { RuntimeGitLabQueryCommands } from './runtime-gitlab-query-commands' +import type { RuntimeGitHubIssueCommentCommands } from './integrations/github/runtime-github-issue-comment-commands' +import type { RuntimeGitHubProjectCommands } from './integrations/github/runtime-github-project-commands' +import type { RuntimeGitHubReviewMutationCommands } from './integrations/github/runtime-github-review-mutation-commands' +import type { RuntimeGitHubReviewQueryCommands } from './integrations/github/runtime-github-review-query-commands' +import type { RuntimeGitLabMutationCommands } from './integrations/gitlab/runtime-gitlab-mutation-commands' +import type { RuntimeGitLabQueryCommands } from './integrations/gitlab/runtime-gitlab-query-commands' type GitLabQueryName = Exclude type GitLabMutationName = Exclude diff --git a/src/main/runtime/runtime-worktree-create-git.ts b/src/main/runtime/runtime-worktree-create-git.ts index 72846e5aa54..1c58550ea10 100644 --- a/src/main/runtime/runtime-worktree-create-git.ts +++ b/src/main/runtime/runtime-worktree-create-git.ts @@ -12,7 +12,7 @@ import { getSelectedReviewBranch, getSelectedReviewLookupHints, type SelectedReviewBranchInput -} from './selected-review-branch' +} from './integrations/reviews/selected-review-branch' import { hasLocalGitOptions, normalizeLocalBranchName } from './runtime-worktree-selection' import type { HostedReviewExecutionOptions } from '../source-control/hosted-review-git-options' diff --git a/src/main/runtime/workspaces/workspace-metadata.ts b/src/main/runtime/workspaces/workspace-metadata.ts index 3db7848b52f..c992c0aa931 100644 --- a/src/main/runtime/workspaces/workspace-metadata.ts +++ b/src/main/runtime/workspaces/workspace-metadata.ts @@ -13,11 +13,11 @@ import { import { resolveRuntimeGitHubWorktreeBase, type RuntimeGitHubWorktreeBaseArgs -} from '../runtime-github-worktree-base' +} from '../integrations/github/runtime-github-worktree-base' import { resolveRuntimeGitLabWorktreeBase, type RuntimeGitLabWorktreeBaseArgs -} from '../runtime-gitlab-worktree-base' +} from '../integrations/gitlab/runtime-gitlab-worktree-base' import { listWorktreesStrict } from '../../git/worktrees/catalog/worktree-listing' import { adoptRuntimeProvisionedRoot, diff --git a/src/main/source-control/hosted-review-execution-host-routing.test.ts b/src/main/source-control/hosted-review-execution-host-routing.test.ts index 9cd69798b3d..423b7a62478 100644 --- a/src/main/source-control/hosted-review-execution-host-routing.test.ts +++ b/src/main/source-control/hosted-review-execution-host-routing.test.ts @@ -103,6 +103,15 @@ vi.mock('../gitlab/merge-request-creation', () => ({ createGitLabMergeRequest: createGitLabMergeRequestMock })) +vi.mock('../github/client/fetch/repo-slug-upstream', () => ({ + getRepoSlug: getRepoSlugMock, + getRepoUpstream: getRepoUpstreamMock +})) + +vi.mock('../github/client/lookup/pr-for-branch-outcome', () => ({ + getPRForBranchOutcome: getPRForBranchOutcomeMock +})) + vi.mock('../github/client', () => ({ getRepoSlug: getRepoSlugMock, getRepoUpstream: getRepoUpstreamMock, @@ -151,7 +160,7 @@ vi.mock('../gitea/pull-request-creation', () => ({ import { __resetHostedReviewBranchCacheForTests } from './hosted-review-branch-cache' import { getStoredRepoExecutionHostId } from '../workspaces/execution-host/repo-execution-host' import { hostedReviewSshConnectionId } from './hosted-review-execution-host' -import { RuntimeHostedReviewCommands } from '../runtime/runtime-hosted-review-commands' +import { RuntimeHostedReviewCommands } from '../runtime/integrations/reviews/runtime-hosted-review-commands' import { SshHostNotServedError } from '../providers/ssh-host-not-served-error' const REPO_PATH = '/remote/workspace/repo'