refactor(source-control): add @t3tools/source-control-core (#17573)
Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
0e7abea7c9
commit
28f11ed7a5
65 files changed
+268
-70
No files matched your search
@@ -45,6 +45,7 @@
|
||||
"@t3tools/provider-muse": "workspace:*",
|
||||
"@t3tools/provider-opencode": "workspace:*",
|
||||
"@t3tools/provider-pi": "workspace:*",
|
||||
"@t3tools/source-control-core": "workspace:*",
|
||||
"diff": "8.0.3",
|
||||
"effect": "catalog:",
|
||||
"jose": "catalog:",
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
} from "@t3tools/provider-core/server/threadTitleContext";
|
||||
import * as ThreadTitleLinks from "../src/textGeneration/ThreadTitleLinks.ts";
|
||||
import * as SourceControlProviderRegistry from "../src/sourceControl/SourceControlProviderRegistry.ts";
|
||||
import * as ServerSourceControlHost from "../src/sourceControl/ServerSourceControlHost.ts";
|
||||
import * as GitHubApi from "../src/sourceControl/GitHubApi.ts";
|
||||
import * as GitLabCli from "../src/sourceControl/GitLabCli.ts";
|
||||
import * as ForgejoCli from "../src/sourceControl/ForgejoCli.ts";
|
||||
@@ -158,6 +159,7 @@ await Effect.runPromise(
|
||||
AzureDevOpsCli.layer,
|
||||
// No saved credentials here; Bitbucket falls back to T3CODE_BITBUCKET_* variables.
|
||||
BitbucketApi.layer,
|
||||
ServerSourceControlHost.layer,
|
||||
),
|
||||
),
|
||||
// Default settings: no saved Bitbucket token, gh's own GitHub account choice.
|
||||
|
||||
@@ -16,7 +16,7 @@ import * as GitHubApi from "../src/sourceControl/GitHubApi.ts";
|
||||
import * as GitHubCredentials from "../src/sourceControl/GitHubCredentials.ts";
|
||||
import * as ServerSettings from "../src/serverSettings.ts";
|
||||
import * as GitHubQuota from "../src/sourceControl/githubQuota.ts";
|
||||
import * as SourceControlRateLimit from "../src/sourceControl/SourceControlRateLimit.ts";
|
||||
import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
|
||||
import * as VcsProcess from "../src/vcs/VcsProcess.ts";
|
||||
|
||||
const [repository, ...numbers] = process.argv.slice(2);
|
||||
|
||||
@@ -58,7 +58,7 @@ import {
|
||||
ForgejoPullRequestSchema,
|
||||
toForgejoChangeRequest,
|
||||
} from "../sourceControl/forgejoPullRequests.ts";
|
||||
import type { SourceControlProvider } from "../sourceControl/SourceControlProvider.ts";
|
||||
import type { SourceControlProvider } from "@t3tools/source-control-core/server/SourceControlProvider";
|
||||
import * as SourceControlProviderRegistry from "../sourceControl/SourceControlProviderRegistry.ts";
|
||||
import * as ServerConfig from "../config.ts";
|
||||
import * as ProjectionStore from "../orchestration-v2/ProjectionStore.ts";
|
||||
|
||||
@@ -31,7 +31,7 @@ import * as Queue from "effect/Queue";
|
||||
import * as Ref from "effect/Ref";
|
||||
import { TestClock } from "effect/testing";
|
||||
|
||||
import { PullRequestProviderError } from "../pullRequest/PullRequestProvider.ts";
|
||||
import { PullRequestProviderError } from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
import * as GitManager from "../git/GitManager.ts";
|
||||
import * as PullRequestService from "../pullRequest/PullRequestService.ts";
|
||||
import * as ServerActivation from "../serverActivation.ts";
|
||||
|
||||
@@ -29,7 +29,7 @@ import * as Semaphore from "effect/Semaphore";
|
||||
import * as Stream from "effect/Stream";
|
||||
|
||||
import * as GitManager from "../git/GitManager.ts";
|
||||
import { PullRequestProviderError } from "../pullRequest/PullRequestProvider.ts";
|
||||
import { PullRequestProviderError } from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
import * as PullRequestService from "../pullRequest/PullRequestService.ts";
|
||||
import { forkParked } from "../serverActivation.ts";
|
||||
import * as Orchestrator from "./Orchestrator.ts";
|
||||
|
||||
@@ -29,7 +29,7 @@ import type * as Scope from "effect/Scope";
|
||||
import {
|
||||
type ProviderChangeRequestWatchFingerprint,
|
||||
PullRequestProviderError,
|
||||
} from "../pullRequest/PullRequestProvider.ts";
|
||||
} from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
import * as PullRequestService from "../pullRequest/PullRequestService.ts";
|
||||
import { forkParked } from "../serverActivation.ts";
|
||||
import * as Orchestrator from "./Orchestrator.ts";
|
||||
|
||||
@@ -65,7 +65,7 @@ import * as ProviderRuntimeRecoveryService from "./ProviderRuntimeRecoveryServic
|
||||
import * as ProjectionMaintenance from "./ProjectionMaintenance.ts";
|
||||
import * as ProjectionStore from "./ProjectionStore.ts";
|
||||
import * as PullRequestWatchReactor from "./PullRequestWatchReactor.ts";
|
||||
import { PullRequestProviderError } from "../pullRequest/PullRequestProvider.ts";
|
||||
import { PullRequestProviderError } from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
import * as PullRequestService from "../pullRequest/PullRequestService.ts";
|
||||
import * as ProjectStore from "./ProjectStore.ts";
|
||||
import * as ProviderSessionManager from "./ProviderSessionManager.ts";
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
type AzureDevOpsPullRequest,
|
||||
type AzureDevOpsRepositoryLocation,
|
||||
} from "./azureDevOpsPullRequestJson.ts";
|
||||
import type { ProviderListCursor } from "./PullRequestProvider.ts";
|
||||
import type { ProviderListCursor } from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
|
||||
/**
|
||||
* Names the read that produced unusable output, so a failure reports the call it came from
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
type ProviderChangeRequestSummary,
|
||||
type ProviderDiffSlice,
|
||||
type PullRequestProviderApi,
|
||||
} from "./PullRequestProvider.ts";
|
||||
} from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
import type {
|
||||
AzureDevOpsChangeEntry,
|
||||
AzureDevOpsItemContent,
|
||||
|
||||
@@ -39,7 +39,7 @@ import {
|
||||
type BitbucketPullRequest,
|
||||
type BitbucketRawComment,
|
||||
} from "./bitbucketPullRequestJson.ts";
|
||||
import type { ProviderListCursor } from "./PullRequestProvider.ts";
|
||||
import type { ProviderListCursor } from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
|
||||
/**
|
||||
* Names the read that produced unusable output, so a failure reports the call it came from
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
type ProviderChangeRequestActivity,
|
||||
type ProviderChangeRequestDetail,
|
||||
type PullRequestProviderApi,
|
||||
} from "./PullRequestProvider.ts";
|
||||
} from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
import type { BitbucketPullRequest } from "./bitbucketPullRequestJson.ts";
|
||||
|
||||
const CAPABILITIES: PullRequestCapabilities = {
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
type ProviderChangeRequestDetail,
|
||||
type ProviderRepositoryRef,
|
||||
type PullRequestProviderApi,
|
||||
} from "./PullRequestProvider.ts";
|
||||
} from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
import {
|
||||
ForgejoPullRequest,
|
||||
ForgejoRepository,
|
||||
|
||||
@@ -16,7 +16,7 @@ import { AllowGitHubReserve } from "../sourceControl/GitHubApi.ts";
|
||||
import * as GitHubApi from "../sourceControl/GitHubApi.ts";
|
||||
import * as GitHubCredentials from "../sourceControl/GitHubCredentials.ts";
|
||||
import * as GitHubQuota from "../sourceControl/githubQuota.ts";
|
||||
import * as SourceControlRateLimit from "../sourceControl/SourceControlRateLimit.ts";
|
||||
import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
|
||||
import * as VcsProcess from "../vcs/VcsProcess.ts";
|
||||
import * as GitHubPullRequestApi from "./GitHubPullRequestApi.ts";
|
||||
import { KnownWorkflowRuns } from "./gitHubConditionalChecks.ts";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { removeAgentCredits } from "./mergeMessage.ts";
|
||||
import { removeAgentCredits } from "@t3tools/source-control-core/server/mergeMessage";
|
||||
import { KnownWorkflowRuns, makeChecksRevalidator } from "./gitHubConditionalChecks.ts";
|
||||
import { runGitHubStackAction, type GitHubStackActionError } from "./githubStackActions.ts";
|
||||
import * as Cause from "effect/Cause";
|
||||
@@ -45,7 +45,7 @@ import {
|
||||
import * as GitHubApi from "../sourceControl/GitHubApi.ts";
|
||||
import { readGraphQlPages } from "../sourceControl/githubGraphQl.ts";
|
||||
import * as VcsProcess from "../vcs/VcsProcess.ts";
|
||||
import * as SourceControlRateLimit from "../sourceControl/SourceControlRateLimit.ts";
|
||||
import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
|
||||
import {
|
||||
ACTOR_AVATARS_GRAPHQL_QUERY,
|
||||
ADD_REACTION_GRAPHQL_MUTATION,
|
||||
@@ -128,7 +128,10 @@ import {
|
||||
type GitHubReviewThreadPage,
|
||||
type GitHubViewerAccess,
|
||||
} from "./gitHubPullRequestJson.ts";
|
||||
import type { ProviderChangeRequestSummary, ProviderListCursor } from "./PullRequestProvider.ts";
|
||||
import type {
|
||||
ProviderChangeRequestSummary,
|
||||
ProviderListCursor,
|
||||
} from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
|
||||
/**
|
||||
* Names the read that produced unusable output, so a failure reports the call it came from
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
type ProviderChangeRequestDetail,
|
||||
type PullRequestProviderApi,
|
||||
type ProviderRepositoryRef,
|
||||
} from "./PullRequestProvider.ts";
|
||||
} from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
import type { GitHubViewerAccess, GitHubWorkflowRunApproval } from "./gitHubPullRequestJson.ts";
|
||||
|
||||
const CAPABILITIES: PullRequestCapabilities = {
|
||||
|
||||
@@ -44,7 +44,7 @@ import {
|
||||
type GitLabMergeRequestListItem,
|
||||
type GitLabProjectUsers,
|
||||
} from "./gitLabMergeRequestJson.ts";
|
||||
import type { ProviderListCursor } from "./PullRequestProvider.ts";
|
||||
import type { ProviderListCursor } from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
|
||||
/**
|
||||
* Names the read that produced unusable output, so a failure reports the call it came from
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
type ProviderChangeRequestActivity,
|
||||
type ProviderChangeRequestDetail,
|
||||
type PullRequestProviderApi,
|
||||
} from "./PullRequestProvider.ts";
|
||||
} from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
|
||||
const CAPABILITIES: PullRequestCapabilities = {
|
||||
diff: true,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { assert, it } from "@effect/vitest";
|
||||
import * as AzureDevOpsCli from "../sourceControl/AzureDevOpsCli.ts";
|
||||
import * as BitbucketApi from "../sourceControl/BitbucketApi.ts";
|
||||
import * as GitHubApi from "../sourceControl/GitHubApi.ts";
|
||||
import * as SourceControlRateLimit from "../sourceControl/SourceControlRateLimit.ts";
|
||||
import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
|
||||
import * as GitLabCli from "../sourceControl/GitLabCli.ts";
|
||||
import { azureDevOpsProviderFailure } from "./AzureDevOpsPullRequestProvider.ts";
|
||||
import { bitbucketProviderFailure } from "./BitbucketPullRequestProvider.ts";
|
||||
|
||||
@@ -17,7 +17,7 @@ import * as GitHubPullRequestApi from "./GitHubPullRequestApi.ts";
|
||||
import * as GitHubPullRequestProvider from "./GitHubPullRequestProvider.ts";
|
||||
import * as GitLabPullRequestCli from "./GitLabPullRequestCli.ts";
|
||||
import * as GitLabPullRequestProvider from "./GitLabPullRequestProvider.ts";
|
||||
import type { PullRequestProviderApi } from "./PullRequestProvider.ts";
|
||||
import type { PullRequestProviderApi } from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
|
||||
export class PullRequestProviderRegistry extends Context.Service<
|
||||
PullRequestProviderRegistry,
|
||||
|
||||
@@ -29,14 +29,14 @@ import * as SqlitePersistence from "../persistence/Sqlite.ts";
|
||||
import * as PullRequestFilesViewed from "../persistence/PullRequestFilesViewed.ts";
|
||||
import * as RepositoryIdentityResolver from "../project/RepositoryIdentityResolver.ts";
|
||||
import * as SourceControlProviderRegistry from "../sourceControl/SourceControlProviderRegistry.ts";
|
||||
import * as SourceControlRateLimit from "../sourceControl/SourceControlRateLimit.ts";
|
||||
import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
|
||||
import * as ForgejoCli from "../sourceControl/ForgejoCli.ts";
|
||||
import * as ForgejoPullRequestProvider from "./ForgejoPullRequestProvider.ts";
|
||||
import {
|
||||
PullRequestProviderError,
|
||||
type ProviderChangeRequest,
|
||||
type PullRequestProviderApi,
|
||||
} from "./PullRequestProvider.ts";
|
||||
} from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
import * as PullRequestProviderRegistry from "./PullRequestProviderRegistry.ts";
|
||||
import * as PullRequestService from "./PullRequestService.ts";
|
||||
import * as PullRequestReadCache from "./PullRequestReadCache.ts";
|
||||
|
||||
@@ -83,14 +83,14 @@ import * as ServerSettings from "../serverSettings.ts";
|
||||
import * as PullRequestFilesViewed from "../persistence/PullRequestFilesViewed.ts";
|
||||
import * as RepositoryIdentityResolver from "../project/RepositoryIdentityResolver.ts";
|
||||
import * as SourceControlProviderRegistry from "../sourceControl/SourceControlProviderRegistry.ts";
|
||||
import * as SourceControlRateLimit from "../sourceControl/SourceControlRateLimit.ts";
|
||||
import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
|
||||
import {
|
||||
type ProviderChangeRequest,
|
||||
type ProviderListCursor,
|
||||
type ProviderChangeRequestWatchFingerprint,
|
||||
type PullRequestProviderApi,
|
||||
PullRequestProviderError,
|
||||
} from "./PullRequestProvider.ts";
|
||||
} from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
import * as PullRequestReadCache from "./PullRequestReadCache.ts";
|
||||
import * as PullRequestProviderRegistry from "./PullRequestProviderRegistry.ts";
|
||||
import * as ViewedFiles from "./pullRequestViewedFiles.ts";
|
||||
|
||||
@@ -18,7 +18,7 @@ import type {
|
||||
import { TrimmedNonEmptyString } from "@t3tools/contracts";
|
||||
import { decodeJsonResult } from "@t3tools/shared/schemaJson";
|
||||
|
||||
import { dedupeChecks } from "./pullRequestChecks.ts";
|
||||
import { dedupeChecks } from "@t3tools/source-control-core/server/pullRequestChecks";
|
||||
|
||||
/**
|
||||
* Bitbucket's enums are decoded as plain strings and normalized here, in the same tolerant
|
||||
|
||||
@@ -10,8 +10,8 @@ import type {
|
||||
PullRequestReactionContent,
|
||||
PullRequestReviewThread,
|
||||
} from "@t3tools/contracts";
|
||||
import type { ProviderChangeRequest } from "./PullRequestProvider.ts";
|
||||
import { dedupeChecks } from "./pullRequestChecks.ts";
|
||||
import type { ProviderChangeRequest } from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
import { dedupeChecks } from "@t3tools/source-control-core/server/pullRequestChecks";
|
||||
|
||||
export const ForgejoUser = Schema.Struct({
|
||||
login: Schema.String,
|
||||
|
||||
@@ -10,7 +10,7 @@ import { PositiveInt, type PullRequestChecks } from "@t3tools/contracts";
|
||||
import * as GitHubApi from "../sourceControl/GitHubApi.ts";
|
||||
import type { GitHubPullRequestDetail } from "./gitHubPullRequestJson.ts";
|
||||
import type { GitHubPullRequestApiError } from "./GitHubPullRequestApi.ts";
|
||||
import type { ProviderRepositoryRef } from "./PullRequestProvider.ts";
|
||||
import type { ProviderRepositoryRef } from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
|
||||
const HeadSchema = Schema.Struct({
|
||||
head: Schema.Struct({
|
||||
|
||||
@@ -36,7 +36,7 @@ import { quoteGitPatchPath } from "@t3tools/shared/gitPatchPath";
|
||||
import { decodeJsonResult } from "@t3tools/shared/schemaJson";
|
||||
|
||||
import { aliasedGraphQlDocument, type GraphQlDocument } from "../sourceControl/githubGraphQl.ts";
|
||||
import { dedupeChecks } from "./pullRequestChecks.ts";
|
||||
import { dedupeChecks } from "@t3tools/source-control-core/server/pullRequestChecks";
|
||||
|
||||
/**
|
||||
* Enum-ish GitHub CLI fields are decoded as plain strings and normalized here: a `gh`
|
||||
|
||||
@@ -16,7 +16,10 @@ import {
|
||||
} from "@t3tools/contracts";
|
||||
|
||||
import type * as PullRequestFilesViewed from "../persistence/PullRequestFilesViewed.ts";
|
||||
import type { ProviderFileRevisions, PullRequestProviderError } from "./PullRequestProvider.ts";
|
||||
import type {
|
||||
ProviderFileRevisions,
|
||||
PullRequestProviderError,
|
||||
} from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
import type { PullRequestError, SupportedProject } from "./PullRequestService.ts";
|
||||
|
||||
/**
|
||||
|
||||
@@ -104,8 +104,9 @@ import * as ProjectCloneTracker from "./project/ProjectCloneTracker.ts";
|
||||
import * as GitWorkflowService from "./git/GitWorkflowService.ts";
|
||||
import * as ReviewService from "./review/ReviewService.ts";
|
||||
import * as SourceControlProviderRegistry from "./sourceControl/SourceControlProviderRegistry.ts";
|
||||
import * as ServerSourceControlHost from "./sourceControl/ServerSourceControlHost.ts";
|
||||
import * as PullRequestReadCache from "./pullRequest/PullRequestReadCache.ts";
|
||||
import * as SourceControlRateLimit from "./sourceControl/SourceControlRateLimit.ts";
|
||||
import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
|
||||
import * as SourceControlRepositoryService from "./sourceControl/SourceControlRepositoryService.ts";
|
||||
import * as WorktreeSetupTracker from "./project/WorktreeSetupTracker.ts";
|
||||
import * as Observability from "./observability/Observability.ts";
|
||||
@@ -305,6 +306,7 @@ const layerSourceControlProviderRegistry = SourceControlProviderRegistry.layer.p
|
||||
GitHubApi.layerWithDependencies,
|
||||
GitLabCli.layer,
|
||||
ForgejoCli.layer,
|
||||
ServerSourceControlHost.layer,
|
||||
),
|
||||
),
|
||||
Layer.provideMerge(GitVcsDriver.layer),
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
decodeAzureDevOpsPullRequestListJson,
|
||||
type NormalizedAzureDevOpsPullRequestRecord,
|
||||
} from "./azureDevOpsPullRequests.ts";
|
||||
import * as SourceControlProvider from "./SourceControlProvider.ts";
|
||||
import * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";
|
||||
|
||||
const DEFAULT_TIMEOUT_MS = 30_000;
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@ import * as Effect from "effect/Effect";
|
||||
import { SourceControlProviderError, type ChangeRequest } from "@t3tools/contracts";
|
||||
|
||||
import * as AzureDevOpsCli from "./AzureDevOpsCli.ts";
|
||||
import * as SourceControlProvider from "./SourceControlProvider.ts";
|
||||
import * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";
|
||||
import {
|
||||
combinedAuthOutput,
|
||||
firstSafeAuthLine,
|
||||
providerAuth,
|
||||
type SourceControlAuthProbeInput,
|
||||
type SourceControlCliDiscoverySpec,
|
||||
} from "./SourceControlProviderDiscovery.ts";
|
||||
} from "@t3tools/source-control-core/server/discovery";
|
||||
|
||||
function parseAzureAuth(input: SourceControlAuthProbeInput) {
|
||||
const account = input.stdout.trim().split(/\r?\n/)[0]?.trim();
|
||||
|
||||
@@ -29,11 +29,11 @@ import {
|
||||
type NormalizedBitbucketPullRequestRecord,
|
||||
} from "./bitbucketPullRequests.ts";
|
||||
import { collectUint8StreamText } from "@t3tools/provider-core/server/collectStreamText";
|
||||
import * as SourceControlProvider from "./SourceControlProvider.ts";
|
||||
import * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";
|
||||
import * as ServerSettings from "../serverSettings.ts";
|
||||
import * as GitVcsDriver from "../vcs/GitVcsDriver.ts";
|
||||
import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
|
||||
import { retryAtFromHeader } from "./SourceControlRateLimit.ts";
|
||||
import { retryAtFromHeader } from "@t3tools/source-control-core/server/SourceControlRateLimit";
|
||||
|
||||
const DEFAULT_API_BASE_URL = "https://api.bitbucket.org/2.0";
|
||||
/** A response body past this is cut short, so one huge diff cannot exhaust the server. */
|
||||
|
||||
@@ -4,8 +4,8 @@ import { SourceControlProviderError, type ChangeRequest } from "@t3tools/contrac
|
||||
|
||||
import * as BitbucketApi from "./BitbucketApi.ts";
|
||||
import type { NormalizedBitbucketPullRequestRecord } from "./bitbucketPullRequests.ts";
|
||||
import * as SourceControlProvider from "./SourceControlProvider.ts";
|
||||
import type { SourceControlApiDiscoverySpec } from "./SourceControlProviderDiscovery.ts";
|
||||
import * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";
|
||||
import type { SourceControlApiDiscoverySpec } from "@t3tools/source-control-core/server/discovery";
|
||||
|
||||
function toChangeRequest(summary: NormalizedBitbucketPullRequestRecord): ChangeRequest {
|
||||
return {
|
||||
|
||||
@@ -15,7 +15,7 @@ import { decodeJsonResult } from "@t3tools/shared/schemaJson";
|
||||
import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
|
||||
import * as VcsProcess from "../vcs/VcsProcess.ts";
|
||||
import { collectUint8StreamText } from "@t3tools/provider-core/server/collectStreamText";
|
||||
import type { SourceControlProviderContext } from "./SourceControlProvider.ts";
|
||||
import type { SourceControlProviderContext } from "@t3tools/source-control-core/server/SourceControlProvider";
|
||||
|
||||
const encodeApiBody = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));
|
||||
|
||||
|
||||
@@ -5,13 +5,13 @@ import * as Result from "effect/Result";
|
||||
import { SourceControlProviderError } from "@t3tools/contracts";
|
||||
import * as VcsProcess from "../vcs/VcsProcess.ts";
|
||||
import * as ForgejoCli from "./ForgejoCli.ts";
|
||||
import * as SourceControlProvider from "./SourceControlProvider.ts";
|
||||
import * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";
|
||||
import {
|
||||
providerAuth,
|
||||
probeSourceControlProvider,
|
||||
type SourceControlCliDiscoverySpec,
|
||||
type SourceControlManagedCliDiscoverySpec,
|
||||
} from "./SourceControlProviderDiscovery.ts";
|
||||
} from "@t3tools/source-control-core/server/discovery";
|
||||
import { ForgejoPullRequestSchema, toForgejoChangeRequest } from "./forgejoPullRequests.ts";
|
||||
|
||||
const isForgejoCliError = Schema.is(ForgejoCli.ForgejoCliError);
|
||||
|
||||
@@ -13,7 +13,7 @@ import { HttpClient, HttpClientResponse, type HttpClientRequest } from "effect/h
|
||||
import * as GitHubApi from "./GitHubApi.ts";
|
||||
import * as GitHubCredentials from "./GitHubCredentials.ts";
|
||||
import * as GitHubQuota from "./githubQuota.ts";
|
||||
import * as SourceControlRateLimit from "./SourceControlRateLimit.ts";
|
||||
import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
|
||||
import * as VcsProcess from "../vcs/VcsProcess.ts";
|
||||
import * as ServerSettings from "../serverSettings.ts";
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import { HttpClient, HttpClientRequest, type HttpClientResponse } from "effect/h
|
||||
import { collectUint8StreamText } from "@t3tools/provider-core/server/collectStreamText";
|
||||
import * as GitHubCredentials from "./GitHubCredentials.ts";
|
||||
import * as GitHubQuota from "./githubQuota.ts";
|
||||
import * as SourceControlRateLimit from "./SourceControlRateLimit.ts";
|
||||
import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
|
||||
|
||||
const DEFAULT_TIMEOUT = Duration.seconds(30);
|
||||
const DEFAULT_MAX_RESPONSE_BYTES = 8 * 1024 * 1024;
|
||||
|
||||
@@ -37,14 +37,14 @@ import {
|
||||
resolveGitHubRepository,
|
||||
type GitHubRepositoryLocator,
|
||||
} from "./gitHubRepositoryResolution.ts";
|
||||
import * as SourceControlRateLimit from "./SourceControlRateLimit.ts";
|
||||
import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
|
||||
import {
|
||||
effectiveGitHubAccount,
|
||||
findAuthenticatedGitHubAccount,
|
||||
parseGitHubAuthStatus,
|
||||
type GitHubAuthStatusAccount,
|
||||
} from "./gitHubAuthStatus.ts";
|
||||
import * as SourceControlProvider from "./SourceControlProvider.ts";
|
||||
import * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";
|
||||
import {
|
||||
combinedAuthOutput,
|
||||
firstSafeAuthLine,
|
||||
@@ -53,7 +53,7 @@ import {
|
||||
type SourceControlAuthProbeInput,
|
||||
type SourceControlCliDiscoverySpec,
|
||||
type SourceControlManagedCliDiscoverySpec,
|
||||
} from "./SourceControlProviderDiscovery.ts";
|
||||
} from "@t3tools/source-control-core/server/discovery";
|
||||
import * as VcsProcess from "../vcs/VcsProcess.ts";
|
||||
|
||||
const decodeLinkSubject = Schema.decodeUnknownEffect(
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
decodeGitLabMergeRequestJson,
|
||||
decodeGitLabMergeRequestListJson,
|
||||
} from "./gitLabMergeRequests.ts";
|
||||
import type * as SourceControlProvider from "./SourceControlProvider.ts";
|
||||
import type * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";
|
||||
|
||||
const DEFAULT_TIMEOUT_MS = 30_000;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as Option from "effect/Option";
|
||||
import { SourceControlProviderError, type ChangeRequest } from "@t3tools/contracts";
|
||||
|
||||
import * as GitLabCli from "./GitLabCli.ts";
|
||||
import * as SourceControlProvider from "./SourceControlProvider.ts";
|
||||
import * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";
|
||||
import {
|
||||
combinedAuthOutput,
|
||||
firstSafeAuthLine,
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
type SourceControlAuthProbeInput,
|
||||
type SourceControlCliDiscoverySpec,
|
||||
type SourceControlUnknownRemoteRefinementInput,
|
||||
} from "./SourceControlProviderDiscovery.ts";
|
||||
} from "@t3tools/source-control-core/server/discovery";
|
||||
import { findAuthenticatedGitLabHost, parseGitLabAuthStatusHosts } from "./gitLabAuthStatus.ts";
|
||||
|
||||
const decodeLinkSubject = Schema.decodeUnknownEffect(
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* The server's implementation of `SourceControlHost.SourceControlHost`, the only server surface
|
||||
* source control provider packages may use.
|
||||
*
|
||||
* @module sourceControl/ServerSourceControlHost
|
||||
*/
|
||||
import * as SourceControlHost from "@t3tools/source-control-core/server/SourceControlHost";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
|
||||
import * as ServerSettings from "../serverSettings.ts";
|
||||
import * as VcsProcess from "../vcs/VcsProcess.ts";
|
||||
|
||||
export const layer = Layer.effect(
|
||||
SourceControlHost.SourceControlHost,
|
||||
Effect.gen(function* () {
|
||||
const serverSettings = yield* ServerSettings.ServerSettingsService;
|
||||
const process = yield* VcsProcess.VcsProcess;
|
||||
return SourceControlHost.SourceControlHost.of({
|
||||
settings: { get: serverSettings.getSettings },
|
||||
process: { run: process.run },
|
||||
});
|
||||
}),
|
||||
);
|
||||
@@ -25,7 +25,8 @@ import * as ForgejoSourceControlProvider from "./ForgejoSourceControlProvider.ts
|
||||
import * as ForgejoPullRequestProvider from "../pullRequest/ForgejoPullRequestProvider.ts";
|
||||
import * as SourceControlDiscovery from "./SourceControlDiscovery.ts";
|
||||
import * as SourceControlProviderRegistry from "./SourceControlProviderRegistry.ts";
|
||||
import { firstNonEmptyLine } from "./SourceControlProviderDiscovery.ts";
|
||||
import * as ServerSourceControlHost from "./ServerSourceControlHost.ts";
|
||||
import { firstNonEmptyLine } from "@t3tools/source-control-core/server/discovery";
|
||||
|
||||
const layerSourceControlProviderRegistryTest = (input: {
|
||||
readonly bitbucket: Partial<BitbucketApi.BitbucketApi["Service"]>;
|
||||
@@ -46,6 +47,14 @@ const layerSourceControlProviderRegistryTest = (input: {
|
||||
Layer.mock(ForgejoCli.ForgejoCli)({ listLogins: () => Effect.succeed([]) }),
|
||||
Layer.mock(VcsDriverRegistry.VcsDriverRegistry)({}),
|
||||
Layer.mock(VcsProcess.VcsProcess)(input.process),
|
||||
ServerSourceControlHost.layer.pipe(
|
||||
Layer.provide(
|
||||
Layer.merge(
|
||||
Layer.mock(VcsProcess.VcsProcess)(input.process),
|
||||
ServerSettings.ServerSettingsService.layerTest(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -10,7 +10,7 @@ import * as Option from "effect/Option";
|
||||
|
||||
import * as ServerConfig from "../config.ts";
|
||||
import * as VcsProcess from "../vcs/VcsProcess.ts";
|
||||
import { detailFromCause, firstNonEmptyLine } from "./SourceControlProviderDiscovery.ts";
|
||||
import { detailFromCause, firstNonEmptyLine } from "@t3tools/source-control-core/server/discovery";
|
||||
import * as SourceControlProviderRegistry from "./SourceControlProviderRegistry.ts";
|
||||
|
||||
interface DiscoveryProbe {
|
||||
|
||||
@@ -21,6 +21,7 @@ import * as GitHubCredentials from "./GitHubCredentials.ts";
|
||||
import * as GitLabCli from "./GitLabCli.ts";
|
||||
import * as ForgejoCli from "./ForgejoCli.ts";
|
||||
import * as SourceControlProviderRegistry from "./SourceControlProviderRegistry.ts";
|
||||
import * as ServerSourceControlHost from "./ServerSourceControlHost.ts";
|
||||
|
||||
const TEST_EPOCH = DateTime.makeUnsafe("1970-01-01T00:00:00.000Z");
|
||||
|
||||
@@ -96,6 +97,11 @@ function makeRegistry(input: {
|
||||
NodeServices.layer,
|
||||
layerRegistry,
|
||||
layerProcess,
|
||||
ServerSourceControlHost.layer.pipe(
|
||||
Layer.provide(
|
||||
Layer.merge(layerProcess, ServerSettings.ServerSettingsService.layerTest()),
|
||||
),
|
||||
),
|
||||
Layer.mock(AzureDevOpsCli.AzureDevOpsCli)({}),
|
||||
Layer.mock(BitbucketApi.BitbucketApi)({}),
|
||||
ServerSettings.ServerSettingsService.layerTest(),
|
||||
|
||||
@@ -16,15 +16,16 @@ import * as BitbucketSourceControlProvider from "./BitbucketSourceControlProvide
|
||||
import * as GitHubSourceControlProvider from "./GitHubSourceControlProvider.ts";
|
||||
import * as GitLabSourceControlProvider from "./GitLabSourceControlProvider.ts";
|
||||
import * as ForgejoSourceControlProvider from "./ForgejoSourceControlProvider.ts";
|
||||
import * as SourceControlProvider from "./SourceControlProvider.ts";
|
||||
import * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";
|
||||
import {
|
||||
probeSourceControlProvider,
|
||||
refineUnknownRemoteProvider,
|
||||
type SourceControlProviderDiscoverySpec,
|
||||
} from "./SourceControlProviderDiscovery.ts";
|
||||
} from "@t3tools/source-control-core/server/discovery";
|
||||
import * as SourceControlHost from "@t3tools/source-control-core/server/SourceControlHost";
|
||||
|
||||
import * as ServerConfig from "../config.ts";
|
||||
import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
|
||||
import * as VcsProcess from "../vcs/VcsProcess.ts";
|
||||
|
||||
const PROVIDER_DETECTION_CACHE_CAPACITY = 2_048;
|
||||
const PROVIDER_DETECTION_CACHE_TTL = Duration.seconds(5);
|
||||
@@ -201,7 +202,7 @@ function bindProviderContext(
|
||||
export const makeWithProviders = Effect.fn("makeSourceControlProviderRegistryWithProviders")(
|
||||
function* (registrations: ReadonlyArray<SourceControlProviderRegistration>) {
|
||||
const config = yield* ServerConfig.ServerConfig;
|
||||
const process = yield* VcsProcess.VcsProcess;
|
||||
const { process } = yield* SourceControlHost.SourceControlHost;
|
||||
const vcsRegistry = yield* VcsDriverRegistry.VcsDriverRegistry;
|
||||
const providers = new Map<
|
||||
SourceControlProviderKind,
|
||||
|
||||
@@ -15,7 +15,7 @@ import * as ServerConfig from "../config.ts";
|
||||
import * as GitVcsDriver from "../vcs/GitVcsDriver.ts";
|
||||
import * as BitbucketApi from "./BitbucketApi.ts";
|
||||
import * as BitbucketSourceControlProvider from "./BitbucketSourceControlProvider.ts";
|
||||
import type * as SourceControlProvider from "./SourceControlProvider.ts";
|
||||
import type * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";
|
||||
import * as SourceControlProviderRegistry from "./SourceControlProviderRegistry.ts";
|
||||
import * as SourceControlRepositoryService from "./SourceControlRepositoryService.ts";
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as Effect from "effect/Effect";
|
||||
import * as TestClock from "effect/testing/TestClock";
|
||||
|
||||
import * as GitHubQuota from "./githubQuota.ts";
|
||||
import { CredentialScope } from "./SourceControlRateLimit.ts";
|
||||
import { CredentialScope } from "@t3tools/source-control-core/server/SourceControlRateLimit";
|
||||
|
||||
const RESET = Date.parse("2099-08-13T14:00:00Z");
|
||||
const headers = (remaining: number, resource = "graphql", reset = RESET) => ({
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Ref from "effect/Ref";
|
||||
|
||||
import * as SourceControlRateLimit from "./SourceControlRateLimit.ts";
|
||||
import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
|
||||
|
||||
/** The share of each quota a background read leaves for a user's next click. */
|
||||
const RESERVE_RATIO = 0.1;
|
||||
|
||||
@@ -235,6 +235,7 @@ import * as GitHubApi from "./sourceControl/GitHubApi.ts";
|
||||
import * as GitLabCli from "./sourceControl/GitLabCli.ts";
|
||||
import * as ForgejoCli from "./sourceControl/ForgejoCli.ts";
|
||||
import * as SourceControlProviderRegistry from "./sourceControl/SourceControlProviderRegistry.ts";
|
||||
import * as ServerSourceControlHost from "./sourceControl/ServerSourceControlHost.ts";
|
||||
import * as GitVcsDriver from "./vcs/GitVcsDriver.ts";
|
||||
import * as VcsDriverRegistry from "./vcs/VcsDriverRegistry.ts";
|
||||
import * as VcsProjectConfig from "./vcs/VcsProjectConfig.ts";
|
||||
@@ -3209,6 +3210,7 @@ export const layer = Layer.unwrap(
|
||||
GitHubApi.layerWithDependencies,
|
||||
GitLabCli.layer,
|
||||
ForgejoCli.layer,
|
||||
ServerSourceControlHost.layer,
|
||||
),
|
||||
),
|
||||
Layer.provideMerge(GitVcsDriver.layer),
|
||||
|
||||
@@ -17,7 +17,7 @@ a project the token cannot see.
|
||||
|
||||
Below the boundary, in a patch parser or a response decoder, a missing path means this revision
|
||||
does not carry that file. Above it, in
|
||||
[`ProviderFileRevisions`](../../apps/server/src/pullRequest/PullRequestProvider.ts), a missing path
|
||||
[`ProviderFileRevisions`](../../packages/source-control-core/src/server/PullRequestProvider.ts), a missing path
|
||||
means the read could not say. A provider's `getFileRevisions` converts on the way up: a path its
|
||||
host looked at and has no version for arrives as the empty string, and absence is kept for what
|
||||
the provider never got to look at. Absence below the boundary does not survive it.
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@
|
||||
"tc": "vp run -r --concurrency-limit 2 typecheck",
|
||||
"lint": "vp lint --report-unused-disable-directives",
|
||||
"knip": "knip --preprocessor ./scripts/knip-schemas.ts",
|
||||
"knip:check": "knip --include files,dependencies --no-config-hints && knip --workspace apps/server --workspace apps/desktop --workspace apps/web --workspace packages/client-runtime --workspace packages/contracts --workspace packages/effect-acp --workspace packages/effect-codex-app-server --workspace packages/shared --workspace packages/ssh --workspace packages/tailscale --workspace packages/provider-core --workspace packages/provider-acp --workspace packages/provider-acp-registry --workspace packages/provider-testing --workspace packages/provider-pi --workspace packages/provider-muse --workspace packages/provider-opencode --workspace packages/provider-cursor --workspace packages/provider-grok --exports --preprocessor ./scripts/knip-schemas.ts --no-config-hints",
|
||||
"knip:check": "knip --include files,dependencies --no-config-hints && knip --workspace apps/server --workspace apps/desktop --workspace apps/web --workspace packages/client-runtime --workspace packages/contracts --workspace packages/effect-acp --workspace packages/effect-codex-app-server --workspace packages/shared --workspace packages/ssh --workspace packages/tailscale --workspace packages/provider-core --workspace packages/provider-acp --workspace packages/provider-acp-registry --workspace packages/provider-testing --workspace packages/provider-pi --workspace packages/provider-muse --workspace packages/provider-opencode --workspace packages/provider-cursor --workspace packages/provider-grok --workspace packages/source-control-core --exports --preprocessor ./scripts/knip-schemas.ts --no-config-hints",
|
||||
"knip:production": "knip --production --preprocessor ./scripts/knip-schemas.ts",
|
||||
"lint:mobile": "node scripts/mobile-native-static-check.ts",
|
||||
"test": "vp run -r test",
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "@t3tools/source-control-core",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"./server/discovery": {
|
||||
"types": "./src/server/discovery.ts",
|
||||
"import": "./src/server/discovery.ts"
|
||||
},
|
||||
"./server/mergeMessage": {
|
||||
"types": "./src/server/mergeMessage.ts",
|
||||
"import": "./src/server/mergeMessage.ts"
|
||||
},
|
||||
"./server/pullRequestChecks": {
|
||||
"types": "./src/server/pullRequestChecks.ts",
|
||||
"import": "./src/server/pullRequestChecks.ts"
|
||||
},
|
||||
"./server/PullRequestProvider": {
|
||||
"types": "./src/server/PullRequestProvider.ts",
|
||||
"import": "./src/server/PullRequestProvider.ts"
|
||||
},
|
||||
"./server/SourceControlHost": {
|
||||
"types": "./src/server/SourceControlHost.ts",
|
||||
"import": "./src/server/SourceControlHost.ts"
|
||||
},
|
||||
"./server/SourceControlProvider": {
|
||||
"types": "./src/server/SourceControlProvider.ts",
|
||||
"import": "./src/server/SourceControlProvider.ts"
|
||||
},
|
||||
"./server/SourceControlRateLimit": {
|
||||
"types": "./src/server/SourceControlRateLimit.ts",
|
||||
"import": "./src/server/SourceControlRateLimit.ts"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vp test run --config ../../vite.config.ts --dir ."
|
||||
},
|
||||
"dependencies": {
|
||||
"@t3tools/contracts": "workspace:*",
|
||||
"effect": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@effect/vitest": "catalog:",
|
||||
"@types/node": "catalog:",
|
||||
"vite-plus": "catalog:"
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* SourceControlHost — what a source control provider package may ask of the server it runs in.
|
||||
*
|
||||
* Providers run inside a T3 server but must not import it. The server provides this one
|
||||
* service; everything a provider needs from its environment (settings, the process runner)
|
||||
* goes through it, so a provider package depends only on `@t3tools/source-control-core` and
|
||||
* its own API and CLI code. HTTP, the filesystem, and paths come from Effect's platform
|
||||
* services directly.
|
||||
*
|
||||
* @module source-control-core/server/SourceControlHost
|
||||
*/
|
||||
import type { ServerSettings, ServerSettingsError, VcsError } from "@t3tools/contracts";
|
||||
import * as Context from "effect/Context";
|
||||
import type * as Effect from "effect/Effect";
|
||||
import type * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
|
||||
|
||||
/** One CLI invocation. The server bounds concurrency, output, and time for every run. */
|
||||
export interface SourceControlProcessInput {
|
||||
readonly operation: string;
|
||||
readonly command: string;
|
||||
readonly args: ReadonlyArray<string>;
|
||||
readonly cwd: string;
|
||||
readonly spawnCwd?: string;
|
||||
readonly stdin?: string;
|
||||
readonly onStdoutChunk?: (chunk: Uint8Array) => void;
|
||||
readonly env?: NodeJS.ProcessEnv;
|
||||
readonly allowNonZeroExit?: boolean;
|
||||
readonly timeoutMs?: number;
|
||||
readonly maxOutputBytes?: number;
|
||||
/** What happens past `maxOutputBytes`: fail the run, or keep the first bytes. */
|
||||
readonly outputMode?: "error" | "truncate" | undefined;
|
||||
readonly appendTruncationMarker?: boolean;
|
||||
}
|
||||
|
||||
export interface SourceControlProcessOutput {
|
||||
readonly exitCode: ChildProcessSpawner.ExitCode;
|
||||
readonly stdout: string;
|
||||
readonly stderr: string;
|
||||
readonly stdoutTruncated: boolean;
|
||||
readonly stderrTruncated: boolean;
|
||||
/** Present on real process output; optional so narrow test doubles remain lightweight. */
|
||||
readonly stdoutInvalidUtf8?: boolean;
|
||||
readonly stderrInvalidUtf8?: boolean;
|
||||
}
|
||||
|
||||
export class SourceControlHost extends Context.Service<
|
||||
SourceControlHost,
|
||||
{
|
||||
readonly settings: {
|
||||
/** Read fresh on each call, so a credential saved in Settings applies without a restart. */
|
||||
readonly get: Effect.Effect<ServerSettings, ServerSettingsError>;
|
||||
};
|
||||
readonly process: {
|
||||
readonly run: (
|
||||
input: SourceControlProcessInput,
|
||||
) => Effect.Effect<SourceControlProcessOutput, VcsError>;
|
||||
};
|
||||
}
|
||||
>()("@t3tools/source-control-core/server/SourceControlHost") {}
|
||||
File renamed without changes.
+1
-1
@@ -142,4 +142,4 @@ export class SourceControlProvider extends Context.Service<
|
||||
readonly force?: boolean;
|
||||
}) => Effect.Effect<void, SourceControlProviderError>;
|
||||
}
|
||||
>()("t3/sourceControl/SourceControlProvider") {}
|
||||
>()("@t3tools/source-control-core/server/SourceControlProvider") {}
|
||||
File renamed without changes.
+7
-4
@@ -13,9 +13,12 @@ import {
|
||||
const FALLBACK_COOLDOWN = Duration.seconds(30);
|
||||
const MAX_FALLBACK_COOLDOWN = Duration.minutes(15);
|
||||
|
||||
export const CredentialScope = Context.Reference<string>("t3/sourceControl/CredentialScope", {
|
||||
defaultValue: () => "",
|
||||
});
|
||||
export const CredentialScope = Context.Reference<string>(
|
||||
"@t3tools/source-control-core/server/SourceControlRateLimit/CredentialScope",
|
||||
{
|
||||
defaultValue: () => "",
|
||||
},
|
||||
);
|
||||
|
||||
interface RateLimitKey {
|
||||
readonly provider: SourceControlProviderKind;
|
||||
@@ -61,7 +64,7 @@ export class SourceControlRateLimit extends Context.Service<
|
||||
) => Effect.Effect<void>;
|
||||
readonly recordSuccess: (input: RateLimitLease) => Effect.Effect<void>;
|
||||
}
|
||||
>()("t3/sourceControl/SourceControlRateLimit") {}
|
||||
>()("@t3tools/source-control-core/server/SourceControlRateLimit") {}
|
||||
|
||||
function normalizedKey(key: RateLimitKey, scope: string): string {
|
||||
return `${key.provider}\0${key.host.trim().toLowerCase()}\0${scope}`;
|
||||
+10
-5
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* Discovery specs: how each provider reports its CLI or API, and the shared probe that runs them.
|
||||
*
|
||||
* @module source-control-core/server/discovery
|
||||
*/
|
||||
import * as NodeUtil from "node:util";
|
||||
import type {
|
||||
SourceControlProviderAuth,
|
||||
@@ -9,12 +14,12 @@ import * as Effect from "effect/Effect";
|
||||
import * as Option from "effect/Option";
|
||||
|
||||
import type * as SourceControlProvider from "./SourceControlProvider.ts";
|
||||
import type * as VcsProcess from "../vcs/VcsProcess.ts";
|
||||
import type * as SourceControlHost from "./SourceControlHost.ts";
|
||||
|
||||
export interface SourceControlAuthProbeInput {
|
||||
readonly stdout: string;
|
||||
readonly stderr: string;
|
||||
readonly exitCode: VcsProcess.VcsProcessOutput["exitCode"];
|
||||
readonly exitCode: SourceControlHost.SourceControlProcessOutput["exitCode"];
|
||||
}
|
||||
|
||||
export interface SourceControlUnknownRemoteRefinementInput {
|
||||
@@ -179,7 +184,7 @@ function isCliRemoteRefinementSpec(
|
||||
|
||||
function probeCli(input: {
|
||||
readonly spec: SourceControlCliDiscoverySpec;
|
||||
readonly process: VcsProcess.VcsProcess["Service"];
|
||||
readonly process: SourceControlHost.SourceControlHost["Service"]["process"];
|
||||
readonly cwd: string;
|
||||
}): Effect.Effect<DiscoveryProbeResult> {
|
||||
return input.process
|
||||
@@ -223,7 +228,7 @@ function probeCli(input: {
|
||||
|
||||
export function probeSourceControlProvider(input: {
|
||||
readonly spec: SourceControlProviderDiscoverySpec;
|
||||
readonly process: VcsProcess.VcsProcess["Service"];
|
||||
readonly process: SourceControlHost.SourceControlHost["Service"]["process"];
|
||||
readonly cwd: string;
|
||||
}): Effect.Effect<SourceControlProviderDiscoveryItem> {
|
||||
if (input.spec.type === "managed-cli") return input.spec.probe(input.cwd);
|
||||
@@ -292,7 +297,7 @@ export function probeSourceControlProvider(input: {
|
||||
export const refineUnknownRemoteProvider = Effect.fn("refineUnknownRemoteProvider")(
|
||||
function* (input: {
|
||||
readonly specs: ReadonlyArray<SourceControlProviderDiscoverySpec>;
|
||||
readonly process: VcsProcess.VcsProcess["Service"];
|
||||
readonly process: SourceControlHost.SourceControlHost["Service"]["process"];
|
||||
readonly cwd: string;
|
||||
readonly context: SourceControlProvider.SourceControlProviderContext | null;
|
||||
}): Effect.fn.Return<SourceControlProvider.SourceControlProviderContext | null> {
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
Generated
+22
@@ -648,6 +648,9 @@ importers:
|
||||
'@t3tools/provider-pi':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/provider-pi
|
||||
'@t3tools/source-control-core':
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/source-control-core
|
||||
diff:
|
||||
specifier: 8.0.3
|
||||
version: 8.0.3
|
||||
@@ -1510,6 +1513,25 @@ importers:
|
||||
specifier: 1.0.0
|
||||
version: 1.0.0(@types/[email protected])(@vitest/[email protected]([email protected]))([email protected])([email protected])([email protected])([email protected](@noble/[email protected]))([email protected](@types/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])
|
||||
|
||||
packages/source-control-core:
|
||||
dependencies:
|
||||
'@t3tools/contracts':
|
||||
specifier: workspace:*
|
||||
version: link:../contracts
|
||||
effect:
|
||||
specifier: 4.0.2
|
||||
version: 4.0.2(patch_hash=ec61ee307eaec3e17f757e0e6a16296ea4b7a8c3188df0c6ec5e66301fd78688)
|
||||
devDependencies:
|
||||
'@effect/vitest':
|
||||
specifier: 4.0.2
|
||||
version: 4.0.2(patch_hash=595b7d26fb635caba9c3d39fcb189bb78a000192f8d3b60ead7174b310d1ade9)(@types/[email protected])(@vitest/[email protected])([email protected])([email protected](patch_hash=ec61ee307eaec3e17f757e0e6a16296ea4b7a8c3188df0c6ec5e66301fd78688))([email protected])([email protected])([email protected](@noble/[email protected]))([email protected](@types/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])
|
||||
'@types/node':
|
||||
specifier: 24.12.4
|
||||
version: 24.12.4
|
||||
vite-plus:
|
||||
specifier: 1.0.0
|
||||
version: 1.0.0(@types/[email protected])(@vitest/[email protected]([email protected]))([email protected])([email protected])([email protected])([email protected](@noble/[email protected]))([email protected](@types/[email protected])([email protected]))([email protected])([email protected])([email protected])([email protected])([email protected])
|
||||
|
||||
packages/ssh:
|
||||
dependencies:
|
||||
'@t3tools/contracts':
|
||||
|
||||
@@ -37,6 +37,7 @@ const workspaceFiles = [
|
||||
"packages/provider-grok/package.json",
|
||||
"packages/provider-muse/package.json",
|
||||
"packages/provider-opencode/package.json",
|
||||
"packages/source-control-core/package.json",
|
||||
"packages/effect-acp/package.json",
|
||||
"packages/effect-codex-app-server/package.json",
|
||||
"scripts/package.json",
|
||||
|
||||
Reference in new issue
Block a user