codexgpt 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.example.md +20 -0
- package/CHANGELOG.md +342 -0
- package/CHATGPT_PROMPT.md +12 -0
- package/CLOUDFLARED_VERIFIED_INSTALL.md +94 -0
- package/CODEX_PROMPT.md +12 -0
- package/CONTRIBUTING.md +62 -0
- package/DOMAIN_SETUP.md +275 -0
- package/FAQ.md +366 -0
- package/FAQ_ZH.md +329 -0
- package/LICENSE +21 -0
- package/PUBLIC_LAUNCH_CHECKLIST.md +111 -0
- package/README.md +490 -0
- package/README_ZH.md +747 -0
- package/SECURITY.md +295 -0
- package/config.example.env +103 -0
- package/dist/access/fullAccessLease.js +148 -0
- package/dist/access/fullAccessLease.js.map +1 -0
- package/dist/access/protectedRoots.js +122 -0
- package/dist/access/protectedRoots.js.map +1 -0
- package/dist/access/rootAdmission.js +347 -0
- package/dist/access/rootAdmission.js.map +1 -0
- package/dist/analysis/cache.js +27 -0
- package/dist/analysis/cache.js.map +1 -0
- package/dist/analysis/classify.js +102 -0
- package/dist/analysis/classify.js.map +1 -0
- package/dist/analysis/extract.js +139 -0
- package/dist/analysis/extract.js.map +1 -0
- package/dist/analysis/graph.js +22 -0
- package/dist/analysis/graph.js.map +1 -0
- package/dist/analysis/impact.js +167 -0
- package/dist/analysis/impact.js.map +1 -0
- package/dist/analysis/index.js +215 -0
- package/dist/analysis/index.js.map +1 -0
- package/dist/analysis/inventory.js +51 -0
- package/dist/analysis/inventory.js.map +1 -0
- package/dist/analysis/providers.js +24 -0
- package/dist/analysis/providers.js.map +1 -0
- package/dist/analysis/rank.js +27 -0
- package/dist/analysis/rank.js.map +1 -0
- package/dist/analysis/types.js +8 -0
- package/dist/analysis/types.js.map +1 -0
- package/dist/audit/canonicalJson.js +79 -0
- package/dist/audit/canonicalJson.js.map +1 -0
- package/dist/audit/diagnostics.js +128 -0
- package/dist/audit/diagnostics.js.map +1 -0
- package/dist/audit/index.js +12 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/audit/lifecycleV3.js +53 -0
- package/dist/audit/lifecycleV3.js.map +1 -0
- package/dist/audit/lifecycleV4.js +70 -0
- package/dist/audit/lifecycleV4.js.map +1 -0
- package/dist/audit/lock.js +195 -0
- package/dist/audit/lock.js.map +1 -0
- package/dist/audit/queryTool.js +120 -0
- package/dist/audit/queryTool.js.map +1 -0
- package/dist/audit/runtime.js +48 -0
- package/dist/audit/runtime.js.map +1 -0
- package/dist/audit/schemas.js +640 -0
- package/dist/audit/schemas.js.map +1 -0
- package/dist/audit/store.js +1309 -0
- package/dist/audit/store.js.map +1 -0
- package/dist/audit/transactionParticipant.js +45 -0
- package/dist/audit/transactionParticipant.js.map +1 -0
- package/dist/audit/types.js +11 -0
- package/dist/audit/types.js.map +1 -0
- package/dist/auth/audit.js +44 -0
- package/dist/auth/audit.js.map +1 -0
- package/dist/auth/authorizationStore.js +333 -0
- package/dist/auth/authorizationStore.js.map +1 -0
- package/dist/auth/challenges.js +25 -0
- package/dist/auth/challenges.js.map +1 -0
- package/dist/auth/clientStore.js +469 -0
- package/dist/auth/clientStore.js.map +1 -0
- package/dist/auth/cloudflareConfig.js +112 -0
- package/dist/auth/cloudflareConfig.js.map +1 -0
- package/dist/auth/configuration.js +167 -0
- package/dist/auth/configuration.js.map +1 -0
- package/dist/auth/credentialStore.js +65 -0
- package/dist/auth/credentialStore.js.map +1 -0
- package/dist/auth/deploymentLock.js +220 -0
- package/dist/auth/deploymentLock.js.map +1 -0
- package/dist/auth/deploymentRegistry.js +149 -0
- package/dist/auth/deploymentRegistry.js.map +1 -0
- package/dist/auth/errors.js +26 -0
- package/dist/auth/errors.js.map +1 -0
- package/dist/auth/grantStore.js +307 -0
- package/dist/auth/grantStore.js.map +1 -0
- package/dist/auth/index.js +39 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/keyManager.js +148 -0
- package/dist/auth/keyManager.js.map +1 -0
- package/dist/auth/localAdminSession.js +173 -0
- package/dist/auth/localAdminSession.js.map +1 -0
- package/dist/auth/metadata.js +69 -0
- package/dist/auth/metadata.js.map +1 -0
- package/dist/auth/oauthProvider.js +589 -0
- package/dist/auth/oauthProvider.js.map +1 -0
- package/dist/auth/ownerApproval.js +51 -0
- package/dist/auth/ownerApproval.js.map +1 -0
- package/dist/auth/policyIdentity.js +189 -0
- package/dist/auth/policyIdentity.js.map +1 -0
- package/dist/auth/rateLimits.js +66 -0
- package/dist/auth/rateLimits.js.map +1 -0
- package/dist/auth/recovery.js +275 -0
- package/dist/auth/recovery.js.map +1 -0
- package/dist/auth/requestContext.js +34 -0
- package/dist/auth/requestContext.js.map +1 -0
- package/dist/auth/resourceMiddleware.js +147 -0
- package/dist/auth/resourceMiddleware.js.map +1 -0
- package/dist/auth/runtimeStatus.js +51 -0
- package/dist/auth/runtimeStatus.js.map +1 -0
- package/dist/auth/schemas.js +84 -0
- package/dist/auth/schemas.js.map +1 -0
- package/dist/auth/stateStore.js +468 -0
- package/dist/auth/stateStore.js.map +1 -0
- package/dist/auth/tokenService.js +631 -0
- package/dist/auth/tokenService.js.map +1 -0
- package/dist/auth/toolSecurity.js +108 -0
- package/dist/auth/toolSecurity.js.map +1 -0
- package/dist/auth/types.js +6 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/auth/windowsDpapi.js +193 -0
- package/dist/auth/windowsDpapi.js.map +1 -0
- package/dist/bashOps.js +292 -0
- package/dist/bashOps.js.map +1 -0
- package/dist/capabilitiesOps.js +412 -0
- package/dist/capabilitiesOps.js.map +1 -0
- package/dist/changesets/crypto.js +92 -0
- package/dist/changesets/crypto.js.map +1 -0
- package/dist/changesets/index.js +9 -0
- package/dist/changesets/index.js.map +1 -0
- package/dist/changesets/moveStore.js +237 -0
- package/dist/changesets/moveStore.js.map +1 -0
- package/dist/changesets/moveUndo.js +386 -0
- package/dist/changesets/moveUndo.js.map +1 -0
- package/dist/changesets/schemas.js +234 -0
- package/dist/changesets/schemas.js.map +1 -0
- package/dist/changesets/store.js +573 -0
- package/dist/changesets/store.js.map +1 -0
- package/dist/changesets/types.js +9 -0
- package/dist/changesets/types.js.map +1 -0
- package/dist/changesets/undo.js +525 -0
- package/dist/changesets/undo.js.map +1 -0
- package/dist/changesets/unifiedUndo.js +31 -0
- package/dist/changesets/unifiedUndo.js.map +1 -0
- package/dist/cliEnvironment.js +85 -0
- package/dist/cliEnvironment.js.map +1 -0
- package/dist/codexSessions.js +733 -0
- package/dist/codexSessions.js.map +1 -0
- package/dist/codexgptSupertool.js +216 -0
- package/dist/codexgptSupertool.js.map +1 -0
- package/dist/codexproSupertool.js +204 -0
- package/dist/codexproSupertool.js.map +1 -0
- package/dist/config.js +733 -0
- package/dist/config.js.map +1 -0
- package/dist/control/localApprovalClient.js +287 -0
- package/dist/control/localApprovalClient.js.map +1 -0
- package/dist/control/localApprovalServer.js +466 -0
- package/dist/control/localApprovalServer.js.map +1 -0
- package/dist/control/runtime.js +178 -0
- package/dist/control/runtime.js.map +1 -0
- package/dist/control/schemas.js +184 -0
- package/dist/control/schemas.js.map +1 -0
- package/dist/control/windowsLocalControl.js +348 -0
- package/dist/control/windowsLocalControl.js.map +1 -0
- package/dist/fsOps.js +541 -0
- package/dist/fsOps.js.map +1 -0
- package/dist/git/admission.js +26 -0
- package/dist/git/admission.js.map +1 -0
- package/dist/git/branchService.js +51 -0
- package/dist/git/branchService.js.map +1 -0
- package/dist/git/capabilities.js +143 -0
- package/dist/git/capabilities.js.map +1 -0
- package/dist/git/commitService.js +344 -0
- package/dist/git/commitService.js.map +1 -0
- package/dist/git/durableState.js +151 -0
- package/dist/git/durableState.js.map +1 -0
- package/dist/git/execution.js +451 -0
- package/dist/git/execution.js.map +1 -0
- package/dist/git/fileTransaction.js +50 -0
- package/dist/git/fileTransaction.js.map +1 -0
- package/dist/git/indexService.js +421 -0
- package/dist/git/indexService.js.map +1 -0
- package/dist/git/integrations.js +653 -0
- package/dist/git/integrations.js.map +1 -0
- package/dist/git/locks.js +287 -0
- package/dist/git/locks.js.map +1 -0
- package/dist/git/mutationContext.js +92 -0
- package/dist/git/mutationContext.js.map +1 -0
- package/dist/git/mutationJournal.js +91 -0
- package/dist/git/mutationJournal.js.map +1 -0
- package/dist/git/mutationService.js +352 -0
- package/dist/git/mutationService.js.map +1 -0
- package/dist/git/normalization.js +57 -0
- package/dist/git/normalization.js.map +1 -0
- package/dist/git/objectQuarantine.js +243 -0
- package/dist/git/objectQuarantine.js.map +1 -0
- package/dist/git/opaqueRecordStore.js +187 -0
- package/dist/git/opaqueRecordStore.js.map +1 -0
- package/dist/git/operationStore.js +287 -0
- package/dist/git/operationStore.js.map +1 -0
- package/dist/git/parsers.js +311 -0
- package/dist/git/parsers.js.map +1 -0
- package/dist/git/privateIndex.js +79 -0
- package/dist/git/privateIndex.js.map +1 -0
- package/dist/git/productionBootstrap.js +39 -0
- package/dist/git/productionBootstrap.js.map +1 -0
- package/dist/git/readService.js +846 -0
- package/dist/git/readService.js.map +1 -0
- package/dist/git/recovery.js +417 -0
- package/dist/git/recovery.js.map +1 -0
- package/dist/git/repositoryIdentity.js +611 -0
- package/dist/git/repositoryIdentity.js.map +1 -0
- package/dist/git/repositoryStore.js +237 -0
- package/dist/git/repositoryStore.js.map +1 -0
- package/dist/git/resources.js +113 -0
- package/dist/git/resources.js.map +1 -0
- package/dist/git/restoreService.js +178 -0
- package/dist/git/restoreService.js.map +1 -0
- package/dist/git/reviewToken.js +86 -0
- package/dist/git/reviewToken.js.map +1 -0
- package/dist/git/stashService.js +566 -0
- package/dist/git/stashService.js.map +1 -0
- package/dist/git/stateToken.js +139 -0
- package/dist/git/stateToken.js.map +1 -0
- package/dist/gitOps.js +147 -0
- package/dist/gitOps.js.map +1 -0
- package/dist/guard.js +608 -0
- package/dist/guard.js.map +1 -0
- package/dist/guidance/diagnostics.js +14 -0
- package/dist/guidance/diagnostics.js.map +1 -0
- package/dist/guidance/instructions.js +167 -0
- package/dist/guidance/instructions.js.map +1 -0
- package/dist/guidance/mode.js +18 -0
- package/dist/guidance/mode.js.map +1 -0
- package/dist/guidance/openaiSkillMetadata.js +29 -0
- package/dist/guidance/openaiSkillMetadata.js.map +1 -0
- package/dist/guidance/safeTextReader.js +171 -0
- package/dist/guidance/safeTextReader.js.map +1 -0
- package/dist/guidance/skillCatalog.js +70 -0
- package/dist/guidance/skillCatalog.js.map +1 -0
- package/dist/guidance/skillDiscovery.js +353 -0
- package/dist/guidance/skillDiscovery.js.map +1 -0
- package/dist/guidance/skillMetadata.js +115 -0
- package/dist/guidance/skillMetadata.js.map +1 -0
- package/dist/guidance/skillResources.js +146 -0
- package/dist/guidance/skillResources.js.map +1 -0
- package/dist/handoffOps.js +449 -0
- package/dist/handoffOps.js.map +1 -0
- package/dist/http/localAdminApp.js +203 -0
- package/dist/http/localAdminApp.js.map +1 -0
- package/dist/http/oauthMcpRuntime.js +294 -0
- package/dist/http/oauthMcpRuntime.js.map +1 -0
- package/dist/http/publicApp.js +350 -0
- package/dist/http/publicApp.js.map +1 -0
- package/dist/http/securityHeaders.js +11 -0
- package/dist/http/securityHeaders.js.map +1 -0
- package/dist/http.js +2076 -0
- package/dist/http.js.map +1 -0
- package/dist/moves/engine.js +1079 -0
- package/dist/moves/engine.js.map +1 -0
- package/dist/moves/index.js +6 -0
- package/dist/moves/index.js.map +1 -0
- package/dist/moves/planner.js +270 -0
- package/dist/moves/planner.js.map +1 -0
- package/dist/moves/recovery.js +557 -0
- package/dist/moves/recovery.js.map +1 -0
- package/dist/moves/service.js +300 -0
- package/dist/moves/service.js.map +1 -0
- package/dist/moves/types.js +11 -0
- package/dist/moves/types.js.map +1 -0
- package/dist/mutations/index.js +4 -0
- package/dist/mutations/index.js.map +1 -0
- package/dist/mutations/lifecycle.js +165 -0
- package/dist/mutations/lifecycle.js.map +1 -0
- package/dist/mutations/localService.js +163 -0
- package/dist/mutations/localService.js.map +1 -0
- package/dist/mutations/runtime.js +322 -0
- package/dist/mutations/runtime.js.map +1 -0
- package/dist/mutations/types.js +2 -0
- package/dist/mutations/types.js.map +1 -0
- package/dist/mutations/writers.js +360 -0
- package/dist/mutations/writers.js.map +1 -0
- package/dist/patchOps.js +420 -0
- package/dist/patchOps.js.map +1 -0
- package/dist/policy/approval.js +306 -0
- package/dist/policy/approval.js.map +1 -0
- package/dist/policy/audit.js +88 -0
- package/dist/policy/audit.js.map +1 -0
- package/dist/policy/authorizationFacts.js +187 -0
- package/dist/policy/authorizationFacts.js.map +1 -0
- package/dist/policy/compat.js +104 -0
- package/dist/policy/compat.js.map +1 -0
- package/dist/policy/context.js +31 -0
- package/dist/policy/context.js.map +1 -0
- package/dist/policy/enforcement.js +46 -0
- package/dist/policy/enforcement.js.map +1 -0
- package/dist/policy/evaluator.js +338 -0
- package/dist/policy/evaluator.js.map +1 -0
- package/dist/policy/executionCapabilities.js +80 -0
- package/dist/policy/executionCapabilities.js.map +1 -0
- package/dist/policy/executionResources.js +192 -0
- package/dist/policy/executionResources.js.map +1 -0
- package/dist/policy/fullAccessResources.js +23 -0
- package/dist/policy/fullAccessResources.js.map +1 -0
- package/dist/policy/hardPolicy.js +50 -0
- package/dist/policy/hardPolicy.js.map +1 -0
- package/dist/policy/identity.js +142 -0
- package/dist/policy/identity.js.map +1 -0
- package/dist/policy/integration.js +331 -0
- package/dist/policy/integration.js.map +1 -0
- package/dist/policy/pendingApprovals.js +301 -0
- package/dist/policy/pendingApprovals.js.map +1 -0
- package/dist/policy/profileStore.js +367 -0
- package/dist/policy/profileStore.js.map +1 -0
- package/dist/policy/resources.js +249 -0
- package/dist/policy/resources.js.map +1 -0
- package/dist/policy/runtime.js +713 -0
- package/dist/policy/runtime.js.map +1 -0
- package/dist/policy/schemas.js +625 -0
- package/dist/policy/schemas.js.map +1 -0
- package/dist/policy/toolPolicy.js +141 -0
- package/dist/policy/toolPolicy.js.map +1 -0
- package/dist/policy/transport.js +10 -0
- package/dist/policy/transport.js.map +1 -0
- package/dist/policy/types.js +31 -0
- package/dist/policy/types.js.map +1 -0
- package/dist/proContext.js +675 -0
- package/dist/proContext.js.map +1 -0
- package/dist/process/authority.js +18 -0
- package/dist/process/authority.js.map +1 -0
- package/dist/process/backendDiscovery.js +83 -0
- package/dist/process/backendDiscovery.js.map +1 -0
- package/dist/process/commandCompiler.js +71 -0
- package/dist/process/commandCompiler.js.map +1 -0
- package/dist/process/outputCursor.js +67 -0
- package/dist/process/outputCursor.js.map +1 -0
- package/dist/process/outputQuota.js +94 -0
- package/dist/process/outputQuota.js.map +1 -0
- package/dist/process/outputRing.js +138 -0
- package/dist/process/outputRing.js.map +1 -0
- package/dist/process/processAuditCoordinator.js +52 -0
- package/dist/process/processAuditCoordinator.js.map +1 -0
- package/dist/process/processManager.js +311 -0
- package/dist/process/processManager.js.map +1 -0
- package/dist/process/runCommand.js +332 -0
- package/dist/process/runCommand.js.map +1 -0
- package/dist/process/streamingRedactor.js +105 -0
- package/dist/process/streamingRedactor.js.map +1 -0
- package/dist/process/types.js +2 -0
- package/dist/process/types.js.map +1 -0
- package/dist/process/windowsHostClient.js +604 -0
- package/dist/process/windowsHostClient.js.map +1 -0
- package/dist/process/windowsHostProtocol.js +270 -0
- package/dist/process/windowsHostProtocol.js.map +1 -0
- package/dist/process/windowsPersistentBackend.js +263 -0
- package/dist/process/windowsPersistentBackend.js.map +1 -0
- package/dist/productionRuntime.js +907 -0
- package/dist/productionRuntime.js.map +1 -0
- package/dist/profileStore.js +231 -0
- package/dist/profileStore.js.map +1 -0
- package/dist/redact.js +124 -0
- package/dist/redact.js.map +1 -0
- package/dist/searchOps.js +186 -0
- package/dist/searchOps.js.map +1 -0
- package/dist/selfTestOps.js +786 -0
- package/dist/selfTestOps.js.map +1 -0
- package/dist/semantic/budgets.js +12 -0
- package/dist/semantic/budgets.js.map +1 -0
- package/dist/semantic/builtin/typescriptAssets.js +68 -0
- package/dist/semantic/builtin/typescriptAssets.js.map +1 -0
- package/dist/semantic/builtin/typescriptProvider.js +211 -0
- package/dist/semantic/builtin/typescriptProvider.js.map +1 -0
- package/dist/semantic/builtin/typescriptWorker.js +365 -0
- package/dist/semantic/builtin/typescriptWorker.js.map +1 -0
- package/dist/semantic/diffPreview.js +36 -0
- package/dist/semantic/diffPreview.js.map +1 -0
- package/dist/semantic/index.js +11 -0
- package/dist/semantic/index.js.map +1 -0
- package/dist/semantic/manager.js +522 -0
- package/dist/semantic/manager.js.map +1 -0
- package/dist/semantic/positions.js +86 -0
- package/dist/semantic/positions.js.map +1 -0
- package/dist/semantic/previewStore.js +276 -0
- package/dist/semantic/previewStore.js.map +1 -0
- package/dist/semantic/projectResolver.js +309 -0
- package/dist/semantic/projectResolver.js.map +1 -0
- package/dist/semantic/sourceSnapshot.js +54 -0
- package/dist/semantic/sourceSnapshot.js.map +1 -0
- package/dist/semantic/status.js +46 -0
- package/dist/semantic/status.js.map +1 -0
- package/dist/semantic/types.js +2 -0
- package/dist/semantic/types.js.map +1 -0
- package/dist/server.js +8676 -0
- package/dist/server.js.map +1 -0
- package/dist/stdio.js +64 -0
- package/dist/stdio.js.map +1 -0
- package/dist/toolCardWidget.js +2000 -0
- package/dist/toolCardWidget.js.map +1 -0
- package/dist/tools/contracts/catalog.js +111 -0
- package/dist/tools/contracts/catalog.js.map +1 -0
- package/dist/tools/contracts/index.js +8 -0
- package/dist/tools/contracts/index.js.map +1 -0
- package/dist/tools/contracts/registration.js +27 -0
- package/dist/tools/contracts/registration.js.map +1 -0
- package/dist/tools/contracts/schemas.js +11 -0
- package/dist/tools/contracts/schemas.js.map +1 -0
- package/dist/tools/contracts/types.js +2 -0
- package/dist/tools/contracts/types.js.map +1 -0
- package/dist/tools/contracts/v3.js +76 -0
- package/dist/tools/contracts/v3.js.map +1 -0
- package/dist/tools/contracts/v4.js +39 -0
- package/dist/tools/contracts/v4.js.map +1 -0
- package/dist/tools/contracts/v5.js +20 -0
- package/dist/tools/contracts/v5.js.map +1 -0
- package/dist/tools/phase3dServer.js +350 -0
- package/dist/tools/phase3dServer.js.map +1 -0
- package/dist/tools/schemas/applyPatch.js +388 -0
- package/dist/tools/schemas/applyPatch.js.map +1 -0
- package/dist/tools/schemas/bash.js +202 -0
- package/dist/tools/schemas/bash.js.map +1 -0
- package/dist/tools/schemas/closeWorkspace.js +105 -0
- package/dist/tools/schemas/closeWorkspace.js.map +1 -0
- package/dist/tools/schemas/codexContext.js +402 -0
- package/dist/tools/schemas/codexContext.js.map +1 -0
- package/dist/tools/schemas/codexSessions.js +328 -0
- package/dist/tools/schemas/codexSessions.js.map +1 -0
- package/dist/tools/schemas/codexgpt.js +1068 -0
- package/dist/tools/schemas/codexgpt.js.map +1 -0
- package/dist/tools/schemas/codexgptInventory.js +359 -0
- package/dist/tools/schemas/codexgptInventory.js.map +1 -0
- package/dist/tools/schemas/codexgptSelfTest.js +563 -0
- package/dist/tools/schemas/codexgptSelfTest.js.map +1 -0
- package/dist/tools/schemas/codexpro.js +917 -0
- package/dist/tools/schemas/codexpro.js.map +1 -0
- package/dist/tools/schemas/codexproInventory.js +352 -0
- package/dist/tools/schemas/codexproInventory.js.map +1 -0
- package/dist/tools/schemas/codexproSelfTest.js +546 -0
- package/dist/tools/schemas/codexproSelfTest.js.map +1 -0
- package/dist/tools/schemas/common.js +21 -0
- package/dist/tools/schemas/common.js.map +1 -0
- package/dist/tools/schemas/createTaskWorktree.js +51 -0
- package/dist/tools/schemas/createTaskWorktree.js.map +1 -0
- package/dist/tools/schemas/edit.js +321 -0
- package/dist/tools/schemas/edit.js.map +1 -0
- package/dist/tools/schemas/execution.js +330 -0
- package/dist/tools/schemas/execution.js.map +1 -0
- package/dist/tools/schemas/exportProContext.js +370 -0
- package/dist/tools/schemas/exportProContext.js.map +1 -0
- package/dist/tools/schemas/getTaskWorktree.js +19 -0
- package/dist/tools/schemas/getTaskWorktree.js.map +1 -0
- package/dist/tools/schemas/gitBranch.js +42 -0
- package/dist/tools/schemas/gitBranch.js.map +1 -0
- package/dist/tools/schemas/gitCommit.js +40 -0
- package/dist/tools/schemas/gitCommit.js.map +1 -0
- package/dist/tools/schemas/gitCreateBranch.js +22 -0
- package/dist/tools/schemas/gitCreateBranch.js.map +1 -0
- package/dist/tools/schemas/gitDiff.js +222 -0
- package/dist/tools/schemas/gitDiff.js.map +1 -0
- package/dist/tools/schemas/gitLog.js +41 -0
- package/dist/tools/schemas/gitLog.js.map +1 -0
- package/dist/tools/schemas/gitRestore.js +47 -0
- package/dist/tools/schemas/gitRestore.js.map +1 -0
- package/dist/tools/schemas/gitStage.js +33 -0
- package/dist/tools/schemas/gitStage.js.map +1 -0
- package/dist/tools/schemas/gitStash.js +102 -0
- package/dist/tools/schemas/gitStash.js.map +1 -0
- package/dist/tools/schemas/gitStatus.js +226 -0
- package/dist/tools/schemas/gitStatus.js.map +1 -0
- package/dist/tools/schemas/gitV4Common.js +205 -0
- package/dist/tools/schemas/gitV4Common.js.map +1 -0
- package/dist/tools/schemas/guidance.js +40 -0
- package/dist/tools/schemas/guidance.js.map +1 -0
- package/dist/tools/schemas/handoffToAgent.js +276 -0
- package/dist/tools/schemas/handoffToAgent.js.map +1 -0
- package/dist/tools/schemas/handoffToCodex.js +137 -0
- package/dist/tools/schemas/handoffToCodex.js.map +1 -0
- package/dist/tools/schemas/inspectWorkspace.js +379 -0
- package/dist/tools/schemas/inspectWorkspace.js.map +1 -0
- package/dist/tools/schemas/listTaskWorktrees.js +21 -0
- package/dist/tools/schemas/listTaskWorktrees.js.map +1 -0
- package/dist/tools/schemas/listWorkspaces.js +134 -0
- package/dist/tools/schemas/listWorkspaces.js.map +1 -0
- package/dist/tools/schemas/loadSkill.js +619 -0
- package/dist/tools/schemas/loadSkill.js.map +1 -0
- package/dist/tools/schemas/mergeTaskWorktree.js +105 -0
- package/dist/tools/schemas/mergeTaskWorktree.js.map +1 -0
- package/dist/tools/schemas/movePaths.js +175 -0
- package/dist/tools/schemas/movePaths.js.map +1 -0
- package/dist/tools/schemas/openCurrentWorkspace.js +174 -0
- package/dist/tools/schemas/openCurrentWorkspace.js.map +1 -0
- package/dist/tools/schemas/openFullAccessWorkspace.js +81 -0
- package/dist/tools/schemas/openFullAccessWorkspace.js.map +1 -0
- package/dist/tools/schemas/openWorkspace.js +193 -0
- package/dist/tools/schemas/openWorkspace.js.map +1 -0
- package/dist/tools/schemas/queryAuditEvents.js +193 -0
- package/dist/tools/schemas/queryAuditEvents.js.map +1 -0
- package/dist/tools/schemas/read.js +199 -0
- package/dist/tools/schemas/read.js.map +1 -0
- package/dist/tools/schemas/readCodexSession.js +353 -0
- package/dist/tools/schemas/readCodexSession.js.map +1 -0
- package/dist/tools/schemas/readHandoff.js +446 -0
- package/dist/tools/schemas/readHandoff.js.map +1 -0
- package/dist/tools/schemas/removeTaskWorktree.js +40 -0
- package/dist/tools/schemas/removeTaskWorktree.js.map +1 -0
- package/dist/tools/schemas/search.js +235 -0
- package/dist/tools/schemas/search.js.map +1 -0
- package/dist/tools/schemas/semantic.js +195 -0
- package/dist/tools/schemas/semantic.js.map +1 -0
- package/dist/tools/schemas/serverConfig.js +157 -0
- package/dist/tools/schemas/serverConfig.js.map +1 -0
- package/dist/tools/schemas/showChanges.js +283 -0
- package/dist/tools/schemas/showChanges.js.map +1 -0
- package/dist/tools/schemas/transactionResult.js +11 -0
- package/dist/tools/schemas/transactionResult.js.map +1 -0
- package/dist/tools/schemas/tree.js +136 -0
- package/dist/tools/schemas/tree.js.map +1 -0
- package/dist/tools/schemas/undoChangeSet.js +152 -0
- package/dist/tools/schemas/undoChangeSet.js.map +1 -0
- package/dist/tools/schemas/waitForHandoff.js +462 -0
- package/dist/tools/schemas/waitForHandoff.js.map +1 -0
- package/dist/tools/schemas/workspaceSnapshot.js +145 -0
- package/dist/tools/schemas/workspaceSnapshot.js.map +1 -0
- package/dist/tools/schemas/write.js +285 -0
- package/dist/tools/schemas/write.js.map +1 -0
- package/dist/transactions/atomicFs.js +438 -0
- package/dist/transactions/atomicFs.js.map +1 -0
- package/dist/transactions/atomicStateFile.js +190 -0
- package/dist/transactions/atomicStateFile.js.map +1 -0
- package/dist/transactions/engine.js +574 -0
- package/dist/transactions/engine.js.map +1 -0
- package/dist/transactions/index.js +12 -0
- package/dist/transactions/index.js.map +1 -0
- package/dist/transactions/installation.js +158 -0
- package/dist/transactions/installation.js.map +1 -0
- package/dist/transactions/manifestV2Store.js +96 -0
- package/dist/transactions/manifestV2Store.js.map +1 -0
- package/dist/transactions/participantRecovery.js +98 -0
- package/dist/transactions/participantRecovery.js.map +1 -0
- package/dist/transactions/recovery.js +513 -0
- package/dist/transactions/recovery.js.map +1 -0
- package/dist/transactions/schemas.js +365 -0
- package/dist/transactions/schemas.js.map +1 -0
- package/dist/transactions/stateRoot.js +63 -0
- package/dist/transactions/stateRoot.js.map +1 -0
- package/dist/transactions/types.js +11 -0
- package/dist/transactions/types.js.map +1 -0
- package/dist/transactions/workspaceLock.js +201 -0
- package/dist/transactions/workspaceLock.js.map +1 -0
- package/dist/workspaceOps.js +924 -0
- package/dist/workspaceOps.js.map +1 -0
- package/dist/worktrees/candidateWorkspace.js +566 -0
- package/dist/worktrees/candidateWorkspace.js.map +1 -0
- package/dist/worktrees/manager.js +258 -0
- package/dist/worktrees/manager.js.map +1 -0
- package/dist/worktrees/materializer.js +60 -0
- package/dist/worktrees/materializer.js.map +1 -0
- package/dist/worktrees/mergeExecute.js +498 -0
- package/dist/worktrees/mergeExecute.js.map +1 -0
- package/dist/worktrees/mergePlanStore.js +247 -0
- package/dist/worktrees/mergePlanStore.js.map +1 -0
- package/dist/worktrees/mergePrepare.js +709 -0
- package/dist/worktrees/mergePrepare.js.map +1 -0
- package/dist/worktrees/recovery.js +294 -0
- package/dist/worktrees/recovery.js.map +1 -0
- package/dist/worktrees/remove.js +296 -0
- package/dist/worktrees/remove.js.map +1 -0
- package/dist/worktrees/remover.js +57 -0
- package/dist/worktrees/remover.js.map +1 -0
- package/dist/worktrees/root.js +47 -0
- package/dist/worktrees/root.js.map +1 -0
- package/dist/worktrees/service.js +245 -0
- package/dist/worktrees/service.js.map +1 -0
- package/dist/worktrees/store.js +156 -0
- package/dist/worktrees/store.js.map +1 -0
- package/dist/worktrees/treeManifest.js +106 -0
- package/dist/worktrees/treeManifest.js.map +1 -0
- package/dist/worktrees/verificationReceipts.js +215 -0
- package/dist/worktrees/verificationReceipts.js.map +1 -0
- package/dist/worktrees/verificationTerminal.js +23 -0
- package/dist/worktrees/verificationTerminal.js.map +1 -0
- package/dist/worktrees/workspaceAuthority.js +64 -0
- package/dist/worktrees/workspaceAuthority.js.map +1 -0
- package/docs/favicon.svg +5 -0
- package/docs/index.html +624 -0
- package/docs/og.svg +52 -0
- package/docs/script.js +33 -0
- package/docs/star.svg +11 -0
- package/docs/styles.css +1571 -0
- package/docs/zh.html +428 -0
- package/package.json +121 -0
- package/scripts/analysis-cli-smoke.mjs +81 -0
- package/scripts/analysis-smoke.mjs +179 -0
- package/scripts/atomic-file.mjs +137 -0
- package/scripts/ci-change-classifier.mjs +59 -0
- package/scripts/ci-failure-summary.mjs +92 -0
- package/scripts/cloudflared-installer.mjs +215 -0
- package/scripts/cloudflared-release.mjs +63 -0
- package/scripts/codexgpt-entry.mjs +235 -0
- package/scripts/codexgpt.mjs +4987 -0
- package/scripts/connector-auth-output-shim.cjs +66 -0
- package/scripts/doctor-smoke.mjs +90 -0
- package/scripts/doctor.mjs +165 -0
- package/scripts/exact-head-ci.mjs +126 -0
- package/scripts/execute-handoff-smoke-platform-compat.mjs +38 -0
- package/scripts/execute-handoff-smoke.mjs +1117 -0
- package/scripts/g8-u-live-probe.mjs +208 -0
- package/scripts/http-smoke-compat.mjs +151 -0
- package/scripts/http-smoke.mjs +776 -0
- package/scripts/long-task-runner.mjs +1037 -0
- package/scripts/oauth-admin.mjs +1608 -0
- package/scripts/output-bounds.mjs +29 -0
- package/scripts/owned-temp-root.d.mts +50 -0
- package/scripts/owned-temp-root.mjs +567 -0
- package/scripts/phase-4a-smoke.mjs +36 -0
- package/scripts/policy-windows-spike.mjs +135 -0
- package/scripts/pro-apply.mjs +152 -0
- package/scripts/pro-bundle.mjs +121 -0
- package/scripts/pro-smoke.mjs +97 -0
- package/scripts/process-identity.mjs +67 -0
- package/scripts/repository-policy.mjs +166 -0
- package/scripts/run-and-summarize.mjs +134 -0
- package/scripts/run-smoke.mjs +52 -0
- package/scripts/run-with-cleanup.mjs +98 -0
- package/scripts/settings-smoke-platform-compat.mjs +85 -0
- package/scripts/settings-smoke.mjs +769 -0
- package/scripts/smoke-platform-compat.mjs +302 -0
- package/scripts/smoke.mjs +1180 -0
- package/scripts/stress-contract-compat.mjs +94 -0
- package/scripts/stress.mjs +882 -0
- package/scripts/test-domains.mjs +247 -0
- package/scripts/test-execution-profile-manifest.mjs +273 -0
- package/scripts/test-execution-profiles.mjs +147 -0
- package/scripts/test-performance-reporter.mjs +291 -0
- package/scripts/toolchain-manager.mjs +266 -0
- package/scripts/toolchains.json +19 -0
- package/scripts/windows-conpty-probe-child.mjs +82 -0
- package/scripts/windows-conpty-worker.ps1 +24 -0
- package/scripts/windows-credential-host-manifest.json +16 -0
- package/scripts/windows-credential-host-protocol-v1.json +16 -0
- package/scripts/windows-credential-host.cs +256 -0
- package/scripts/windows-credential-host.ps1 +26 -0
- package/scripts/windows-local-control-manifest.json +23 -0
- package/scripts/windows-local-control-spike.cs +738 -0
- package/scripts/windows-local-control-spike.mjs +415 -0
- package/scripts/windows-local-control-spike.ps1 +35 -0
- package/scripts/windows-local-control.cs +738 -0
- package/scripts/windows-local-control.ps1 +35 -0
- package/scripts/windows-native-api-inventory-v1.json +90 -0
- package/scripts/windows-process-host-manifest.json +20 -0
- package/scripts/windows-process-host-protocol-v1.json +59 -0
- package/scripts/windows-process-host.cs +2385 -0
- package/scripts/windows-process-host.ps1 +59 -0
- package/scripts/windows-realpath-shim.cjs +78 -0
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
import { hasSecretValue } from "../redact.js";
|
|
2
|
+
import { parseGitRawDiffZ } from "../git/parsers.js";
|
|
3
|
+
import { runGitRequired, sha256Git } from "../git/mutationContext.js";
|
|
4
|
+
import { GitObjectQuarantine } from "../git/objectQuarantine.js";
|
|
5
|
+
import { buildTaskTreeManifest } from "./treeManifest.js";
|
|
6
|
+
async function localIdentity(manager, repository) {
|
|
7
|
+
const read = async (key) => {
|
|
8
|
+
const result = await manager.options.context.options.executor.run(repository, [
|
|
9
|
+
"config", "--local", "--no-includes", "--get", key
|
|
10
|
+
], { stdoutLimitBytes: 1024 });
|
|
11
|
+
const value = result.stdout.toString("utf8").trim();
|
|
12
|
+
if (result.status !== 0 || !value || /[\u0000\r\n]/u.test(value) || hasSecretValue(value)) {
|
|
13
|
+
throw new Error("GIT_IDENTITY_REQUIRED");
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
17
|
+
return { name: await read("user.name"), email: await read("user.email") };
|
|
18
|
+
}
|
|
19
|
+
async function reachableCandidateObjectIds(input) {
|
|
20
|
+
const width = input.repository.objectFormat === "sha1" ? 40 : 64;
|
|
21
|
+
const listed = await runGitRequired(input.executor, input.repository, [
|
|
22
|
+
"rev-list",
|
|
23
|
+
"--objects",
|
|
24
|
+
"--no-object-names",
|
|
25
|
+
input.candidateOid,
|
|
26
|
+
`^${input.targetOid}`,
|
|
27
|
+
`^${input.taskOid}`,
|
|
28
|
+
"--"
|
|
29
|
+
], {
|
|
30
|
+
objectDirectoryPath: input.quarantineRoot,
|
|
31
|
+
stdoutLimitBytes: 32 * 1024
|
|
32
|
+
});
|
|
33
|
+
let text;
|
|
34
|
+
try {
|
|
35
|
+
text = new TextDecoder("utf-8", { fatal: true }).decode(listed.stdout);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
throw new Error("GIT_MERGE_CAPABILITY_UNAVAILABLE");
|
|
39
|
+
}
|
|
40
|
+
const pattern = new RegExp(`^[a-f0-9]{${width}}$`, "u");
|
|
41
|
+
const objects = text.split(/\r?\n/u).filter(Boolean);
|
|
42
|
+
if (objects.length < 1 ||
|
|
43
|
+
objects.length > 256 ||
|
|
44
|
+
objects.some((oid) => !pattern.test(oid)) ||
|
|
45
|
+
new Set(objects).size !== objects.length ||
|
|
46
|
+
!objects.includes(input.candidateOid))
|
|
47
|
+
throw new Error("GIT_MERGE_CAPABILITY_UNAVAILABLE");
|
|
48
|
+
return objects.sort();
|
|
49
|
+
}
|
|
50
|
+
function conflictPaths(stdout, guard) {
|
|
51
|
+
let text;
|
|
52
|
+
try {
|
|
53
|
+
text = new TextDecoder("utf-8", { fatal: true }).decode(stdout);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
throw new Error("GIT_MERGE_CAPABILITY_UNAVAILABLE");
|
|
57
|
+
}
|
|
58
|
+
const values = [];
|
|
59
|
+
for (const field of text.split("\0")) {
|
|
60
|
+
const match = /^(?:100644|100755) [a-f0-9]{40,64} [123]\t(.+)$/u.exec(field);
|
|
61
|
+
if (!match)
|
|
62
|
+
continue;
|
|
63
|
+
const value = match[1];
|
|
64
|
+
if (value.length > 4096 ||
|
|
65
|
+
value.startsWith("/") ||
|
|
66
|
+
value.includes("\\") ||
|
|
67
|
+
value.split("/").some((segment) => !segment || segment === "." || segment === ".." || segment.includes(":") || /[. ]$/u.test(segment)) ||
|
|
68
|
+
guard.isBlockedRelativePath(value) ||
|
|
69
|
+
hasSecretValue(value))
|
|
70
|
+
throw new Error("GIT_MERGE_CAPABILITY_UNAVAILABLE");
|
|
71
|
+
values.push(value);
|
|
72
|
+
}
|
|
73
|
+
return [...new Set(values)].sort().slice(0, 256);
|
|
74
|
+
}
|
|
75
|
+
async function hasCustomMergeDriver(manager, repository) {
|
|
76
|
+
const result = await manager.options.context.options.executor.run(repository, [
|
|
77
|
+
"config",
|
|
78
|
+
"--local",
|
|
79
|
+
"--no-includes",
|
|
80
|
+
"--get-regexp",
|
|
81
|
+
"^merge\\..*\\.driver$"
|
|
82
|
+
], { stdoutLimitBytes: 128 * 1024 });
|
|
83
|
+
if (result.timedOut ||
|
|
84
|
+
result.stdoutTruncated ||
|
|
85
|
+
result.stderrTruncated ||
|
|
86
|
+
(result.status !== 0 && result.status !== 1))
|
|
87
|
+
throw new Error("GIT_INTEGRATION_REQUIRED");
|
|
88
|
+
return result.status === 0;
|
|
89
|
+
}
|
|
90
|
+
export class TaskWorktreeMergePrepareV4 {
|
|
91
|
+
options;
|
|
92
|
+
constructor(options) {
|
|
93
|
+
this.options = options;
|
|
94
|
+
}
|
|
95
|
+
prepare(input) {
|
|
96
|
+
return this.#prepare(input, null);
|
|
97
|
+
}
|
|
98
|
+
async finalize(input) {
|
|
99
|
+
await this.options.candidateWorkspaces.cleanupExpiredReviewedCandidates();
|
|
100
|
+
let review;
|
|
101
|
+
try {
|
|
102
|
+
review = this.options.reviews.inspect(input.reviewToken, "task_merge_finalize");
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
await this.options.candidateWorkspaces.cleanupReviewedCandidateForToken(input.reviewToken);
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
return this.#prepare(input, { review, reviewToken: input.reviewToken, authorization: input.authorization });
|
|
109
|
+
}
|
|
110
|
+
async #prepare(input, finalize) {
|
|
111
|
+
const reservation = this.options.plans.reserveTask(input.taskWorktreeId);
|
|
112
|
+
try {
|
|
113
|
+
return await this.#prepareReserved(input, finalize);
|
|
114
|
+
}
|
|
115
|
+
finally {
|
|
116
|
+
reservation.release();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async #prepareReserved(input, finalize) {
|
|
120
|
+
const ownerFingerprint = this.options.ownerFingerprint();
|
|
121
|
+
let task = await this.options.manager.revalidate(input.taskWorktreeId, ownerFingerprint);
|
|
122
|
+
if (task.record.state !== "ready")
|
|
123
|
+
throw new Error("MERGE_PLAN_INVALID");
|
|
124
|
+
const repository = await this.options.manager.primaryRepository(input.workspace);
|
|
125
|
+
if (repository.repositoryId !== task.record.repositoryId)
|
|
126
|
+
throw new Error("TASK_WORKTREE_NOT_FOUND");
|
|
127
|
+
const executor = this.options.manager.options.context.options.executor;
|
|
128
|
+
if (finalize && input.integrationReviewToken)
|
|
129
|
+
throw new Error("GIT_INTEGRATION_REQUIRED");
|
|
130
|
+
const integrationReview = !finalize && input.integrationReviewToken
|
|
131
|
+
? this.options.integrationGate?.inspect(input.integrationReviewToken)
|
|
132
|
+
: null;
|
|
133
|
+
if (input.integrationReviewToken && (!this.options.integrationGate?.enabled ||
|
|
134
|
+
integrationReview?.workspaceId !== input.workspace.id ||
|
|
135
|
+
integrationReview.repositoryId !== repository.repositoryId))
|
|
136
|
+
throw new Error("GIT_INTEGRATION_REQUIRED");
|
|
137
|
+
const targetOid = (await runGitRequired(executor, repository, [
|
|
138
|
+
"rev-parse", "--verify", task.privateState.targetRef
|
|
139
|
+
], { stdoutLimitBytes: 256 })).stdout.toString("ascii").trim();
|
|
140
|
+
const taskOid = (await runGitRequired(executor, repository, [
|
|
141
|
+
"rev-parse", "--verify", task.privateState.branchRef
|
|
142
|
+
], { stdoutLimitBytes: 256 })).stdout.toString("ascii").trim();
|
|
143
|
+
if (taskOid !== task.record.headOid) {
|
|
144
|
+
this.options.manager.options.store.update(task.record.taskWorktreeId, {
|
|
145
|
+
state: "ready",
|
|
146
|
+
headOid: taskOid
|
|
147
|
+
});
|
|
148
|
+
task = await this.options.manager.revalidate(input.taskWorktreeId, ownerFingerprint);
|
|
149
|
+
}
|
|
150
|
+
const ancestor = await executor.run(repository, ["merge-base", "--is-ancestor", targetOid, taskOid]);
|
|
151
|
+
if (ancestor.status === 0) {
|
|
152
|
+
if (finalize)
|
|
153
|
+
throw new Error("MERGE_PLAN_INVALID");
|
|
154
|
+
const scanned = await this.#scanCandidate(repository, input.guard, targetOid, taskOid);
|
|
155
|
+
const mergePlanId = this.options.plans.allocateId();
|
|
156
|
+
const integrationWorkspaceId = this.options.candidateWorkspaces.allocateId();
|
|
157
|
+
const plan = this.options.plans.create({
|
|
158
|
+
mergePlanId,
|
|
159
|
+
lifecycleState: "preparing",
|
|
160
|
+
taskWorktreeId: task.record.taskWorktreeId,
|
|
161
|
+
taskGeneration: task.record.generation + 1,
|
|
162
|
+
repositoryId: repository.repositoryId,
|
|
163
|
+
repositoryIdentityFingerprint: repository.stableIdentityFingerprint,
|
|
164
|
+
capabilityRevision: repository.capabilityRevision,
|
|
165
|
+
contextFingerprint: sha256Git(this.options.manager.options.context.options.contextFingerprint),
|
|
166
|
+
policyRevision: input.authorization?.policyRevision ?? null,
|
|
167
|
+
ownerFingerprint,
|
|
168
|
+
primaryWorkspaceRoot: input.workspace.root,
|
|
169
|
+
targetRef: task.privateState.targetRef,
|
|
170
|
+
taskRef: task.privateState.branchRef,
|
|
171
|
+
candidateRef: null,
|
|
172
|
+
targetOid,
|
|
173
|
+
taskOid,
|
|
174
|
+
candidateOid: taskOid,
|
|
175
|
+
candidateTreeOid: scanned.treeOid,
|
|
176
|
+
manifestDigest: scanned.manifestDigest,
|
|
177
|
+
diffDigest: scanned.diffDigest,
|
|
178
|
+
historyDigest: scanned.historyDigest,
|
|
179
|
+
checksComplete: false,
|
|
180
|
+
receiptIds: [],
|
|
181
|
+
integrationWorkspaceId,
|
|
182
|
+
requiredCheckCategories: [...this.options.candidateWorkspaces.requiredCategories],
|
|
183
|
+
affectedPathCount: scanned.changes.length,
|
|
184
|
+
affectedByteCount: scanned.totalBytes,
|
|
185
|
+
scanDigest: sha256Git(JSON.stringify(scanned)),
|
|
186
|
+
repositoryIntegrations: integrationReview ? "approved_full_access" : "disabled",
|
|
187
|
+
integrationIdentitiesDigest: integrationReview?.identitiesDigest ?? null,
|
|
188
|
+
integrationConfigDigest: integrationReview?.configDigest ?? null,
|
|
189
|
+
integrationSemanticStateDigest: integrationReview?.semanticStateDigest ?? null
|
|
190
|
+
});
|
|
191
|
+
try {
|
|
192
|
+
const updatedTask = this.options.manager.options.store.update(task.record.taskWorktreeId, {
|
|
193
|
+
state: "merge_prepared",
|
|
194
|
+
headOid: taskOid
|
|
195
|
+
});
|
|
196
|
+
if (updatedTask.generation !== plan.taskGeneration)
|
|
197
|
+
throw new Error("GIT_RECOVERY_REQUIRED");
|
|
198
|
+
await this.options.candidateWorkspaces.create({
|
|
199
|
+
workspace: input.workspace,
|
|
200
|
+
repository,
|
|
201
|
+
taskWorktreeId: task.record.taskWorktreeId,
|
|
202
|
+
taskGeneration: updatedTask.generation,
|
|
203
|
+
mergePlanId,
|
|
204
|
+
candidateOid: taskOid,
|
|
205
|
+
manifest: scanned.manifest,
|
|
206
|
+
expiresAt: plan.expiresAt,
|
|
207
|
+
aliasTaskRoot: task.privateState.worktreePath,
|
|
208
|
+
integrationWorkspaceId
|
|
209
|
+
});
|
|
210
|
+
const preparedPlan = this.options.plans.transition(plan.mergePlanId, ownerFingerprint, "preparing", "prepared");
|
|
211
|
+
return this.#result({
|
|
212
|
+
action: "prepare",
|
|
213
|
+
repositoryId: repository.repositoryId,
|
|
214
|
+
taskWorktreeId: task.record.taskWorktreeId,
|
|
215
|
+
planId: preparedPlan.mergePlanId,
|
|
216
|
+
reviewToken: null,
|
|
217
|
+
status: "checks_required",
|
|
218
|
+
targetOid,
|
|
219
|
+
taskOid,
|
|
220
|
+
candidateOid: taskOid,
|
|
221
|
+
changes: scanned.changes,
|
|
222
|
+
expiresAt: preparedPlan.expiresAt,
|
|
223
|
+
repositoryIntegrations: preparedPlan.repositoryIntegrations,
|
|
224
|
+
integrationWorkspaceId,
|
|
225
|
+
requiredCheckCategories: preparedPlan.requiredCheckCategories
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
try {
|
|
230
|
+
await this.options.candidateWorkspaces.cleanup(integrationWorkspaceId);
|
|
231
|
+
const current = this.options.manager.options.store.read(task.record.taskWorktreeId);
|
|
232
|
+
if (current.record.state === "merge_prepared" && current.record.headOid === taskOid) {
|
|
233
|
+
this.options.manager.options.store.update(task.record.taskWorktreeId, {
|
|
234
|
+
state: "ready",
|
|
235
|
+
headOid: taskOid
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
else if (current.record.state !== "ready") {
|
|
239
|
+
throw new Error("GIT_RECOVERY_REQUIRED");
|
|
240
|
+
}
|
|
241
|
+
this.options.plans.consumeForRecovery(plan.mergePlanId, ownerFingerprint);
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
try {
|
|
245
|
+
this.options.plans.transition(plan.mergePlanId, ownerFingerprint, "preparing", "recovery_required");
|
|
246
|
+
}
|
|
247
|
+
catch { }
|
|
248
|
+
try {
|
|
249
|
+
this.options.manager.options.store.update(task.record.taskWorktreeId, {
|
|
250
|
+
state: "recovery_required",
|
|
251
|
+
headOid: taskOid
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
catch { }
|
|
255
|
+
throw new Error("GIT_RECOVERY_REQUIRED", { cause: error });
|
|
256
|
+
}
|
|
257
|
+
throw error;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const message = finalize?.review.message ?? input.message ?? "Merge CodexGPT task worktree";
|
|
261
|
+
if (!message.trim() || hasSecretValue(message) || Buffer.byteLength(message, "utf8") > 16 * 1024) {
|
|
262
|
+
throw new Error("GIT_SECRET_BLOCKED");
|
|
263
|
+
}
|
|
264
|
+
const systemDate = finalize?.review.systemDate ?? new Date().toISOString();
|
|
265
|
+
const ephemeralQuarantineRoot = finalize
|
|
266
|
+
? null
|
|
267
|
+
: await executor.createPrivateDirectory?.("git-merge") ?? null;
|
|
268
|
+
if (!finalize && !ephemeralQuarantineRoot)
|
|
269
|
+
throw new Error("GIT_MERGE_CAPABILITY_UNAVAILABLE");
|
|
270
|
+
let quarantineRoot = ephemeralQuarantineRoot ?? "";
|
|
271
|
+
try {
|
|
272
|
+
let candidateOid;
|
|
273
|
+
let scanned;
|
|
274
|
+
let scanDigest;
|
|
275
|
+
let objects;
|
|
276
|
+
if (finalize) {
|
|
277
|
+
const review = finalize.review;
|
|
278
|
+
if (review.repositoryId !== repository.repositoryId ||
|
|
279
|
+
review.taskWorktreeId !== task.record.taskWorktreeId ||
|
|
280
|
+
review.ownerFingerprint !== ownerFingerprint ||
|
|
281
|
+
review.targetRef !== task.privateState.targetRef ||
|
|
282
|
+
review.taskRef !== task.privateState.branchRef ||
|
|
283
|
+
review.targetOid !== targetOid ||
|
|
284
|
+
review.taskOid !== taskOid ||
|
|
285
|
+
Date.parse(review.expiresAt) < Date.now())
|
|
286
|
+
throw new Error("GIT_STATE_CHANGED");
|
|
287
|
+
const artifact = await this.options.candidateWorkspaces.openReviewedCandidate({
|
|
288
|
+
artifactId: review.artifactId,
|
|
289
|
+
reviewToken: finalize.reviewToken,
|
|
290
|
+
repository,
|
|
291
|
+
taskWorktreeId: task.record.taskWorktreeId,
|
|
292
|
+
targetOid,
|
|
293
|
+
taskOid,
|
|
294
|
+
candidateOid: review.candidateOid,
|
|
295
|
+
candidateTreeOid: review.candidateTreeOid,
|
|
296
|
+
scanDigest: review.scanDigest,
|
|
297
|
+
objectIdsDigest: review.objectIdsDigest
|
|
298
|
+
});
|
|
299
|
+
quarantineRoot = artifact.objectDirectoryPath;
|
|
300
|
+
candidateOid = review.candidateOid;
|
|
301
|
+
scanned = await this.#scanCandidate(repository, input.guard, targetOid, candidateOid, quarantineRoot);
|
|
302
|
+
scanDigest = sha256Git(JSON.stringify(scanned));
|
|
303
|
+
if (scanned.treeOid !== review.candidateTreeOid ||
|
|
304
|
+
scanDigest !== review.scanDigest)
|
|
305
|
+
throw new Error("GIT_STATE_CHANGED");
|
|
306
|
+
objects = artifact.objectIds;
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
if (!integrationReview && await hasCustomMergeDriver(this.options.manager, repository)) {
|
|
310
|
+
throw new Error("GIT_INTEGRATION_REQUIRED");
|
|
311
|
+
}
|
|
312
|
+
const merged = integrationReview
|
|
313
|
+
? (await this.options.integrationGate.execute({
|
|
314
|
+
workspaceId: input.workspace.id,
|
|
315
|
+
repository,
|
|
316
|
+
reviewToken: input.integrationReviewToken,
|
|
317
|
+
authorization: input.authorization,
|
|
318
|
+
semanticStateDigest: integrationReview.semanticStateDigest,
|
|
319
|
+
expectedToolName: "merge_task_worktree",
|
|
320
|
+
expectedCanonicalAction: "task_merge_prepare_review",
|
|
321
|
+
request: {
|
|
322
|
+
operation: "merge_tree",
|
|
323
|
+
targetOid,
|
|
324
|
+
taskOid,
|
|
325
|
+
objectDirectoryPath: quarantineRoot
|
|
326
|
+
}
|
|
327
|
+
})).result
|
|
328
|
+
: await executor.run(repository, [
|
|
329
|
+
"merge-tree", "--write-tree", "-z", targetOid, taskOid
|
|
330
|
+
], { objectDirectoryPath: quarantineRoot, stdoutLimitBytes: 64 * 1024 });
|
|
331
|
+
if (merged.status !== 0) {
|
|
332
|
+
const conflicts = conflictPaths(merged.stdout, input.guard);
|
|
333
|
+
if (conflicts.length === 0)
|
|
334
|
+
throw new Error("MERGE_CONFLICT");
|
|
335
|
+
return {
|
|
336
|
+
action: "prepare",
|
|
337
|
+
repository_id: repository.repositoryId,
|
|
338
|
+
task_worktree_id: task.record.taskWorktreeId,
|
|
339
|
+
merge_plan_id: null,
|
|
340
|
+
review_token: null,
|
|
341
|
+
status: "conflicted",
|
|
342
|
+
target_oid: targetOid,
|
|
343
|
+
task_oid: taskOid,
|
|
344
|
+
candidate_oid: null,
|
|
345
|
+
changes: [],
|
|
346
|
+
conflicts: conflicts.map((item) => ({ path: item })),
|
|
347
|
+
path_scan_complete: true,
|
|
348
|
+
secret_scan_complete: true,
|
|
349
|
+
history_scan_complete: true,
|
|
350
|
+
checks_complete: false,
|
|
351
|
+
integration_workspace_id: null,
|
|
352
|
+
required_check_categories: [],
|
|
353
|
+
execution_isolation: "none",
|
|
354
|
+
repository_integrations: integrationReview ? "approved_full_access" : "disabled",
|
|
355
|
+
expires_at: null
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
const treeOid = merged.stdout.toString("ascii").split("\0")[0].trim();
|
|
359
|
+
if (!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(treeOid)) {
|
|
360
|
+
throw new Error("GIT_MERGE_CAPABILITY_UNAVAILABLE");
|
|
361
|
+
}
|
|
362
|
+
const identity = await localIdentity(this.options.manager, repository);
|
|
363
|
+
const commit = await runGitRequired(executor, repository, [
|
|
364
|
+
"commit-tree", treeOid, "-p", targetOid, "-p", taskOid
|
|
365
|
+
], {
|
|
366
|
+
objectDirectoryPath: quarantineRoot,
|
|
367
|
+
stdin: Buffer.from(`${message}\n`, "utf8"),
|
|
368
|
+
identity: {
|
|
369
|
+
authorName: identity.name,
|
|
370
|
+
authorEmail: identity.email,
|
|
371
|
+
committerName: identity.name,
|
|
372
|
+
committerEmail: identity.email,
|
|
373
|
+
systemAuthorDate: systemDate,
|
|
374
|
+
systemCommitterDate: systemDate
|
|
375
|
+
},
|
|
376
|
+
stdoutLimitBytes: 256
|
|
377
|
+
});
|
|
378
|
+
candidateOid = commit.stdout.toString("ascii").trim();
|
|
379
|
+
scanned = await this.#scanCandidate(repository, input.guard, targetOid, candidateOid, quarantineRoot);
|
|
380
|
+
scanDigest = sha256Git(JSON.stringify(scanned));
|
|
381
|
+
objects = await reachableCandidateObjectIds({
|
|
382
|
+
executor,
|
|
383
|
+
repository,
|
|
384
|
+
quarantineRoot,
|
|
385
|
+
candidateOid,
|
|
386
|
+
targetOid,
|
|
387
|
+
taskOid
|
|
388
|
+
});
|
|
389
|
+
const expiresAt = new Date(Date.now() + 5 * 60_000).toISOString();
|
|
390
|
+
const retained = await this.options.candidateWorkspaces.retainReviewedCandidate({
|
|
391
|
+
repository,
|
|
392
|
+
taskWorktreeId: task.record.taskWorktreeId,
|
|
393
|
+
targetOid,
|
|
394
|
+
taskOid,
|
|
395
|
+
candidateOid,
|
|
396
|
+
candidateTreeOid: scanned.treeOid,
|
|
397
|
+
scanDigest,
|
|
398
|
+
objectIds: objects,
|
|
399
|
+
quarantineRoot,
|
|
400
|
+
expiresAt
|
|
401
|
+
});
|
|
402
|
+
let reviewToken = null;
|
|
403
|
+
try {
|
|
404
|
+
reviewToken = this.options.reviews.mint("task_merge_finalize", {
|
|
405
|
+
repositoryId: repository.repositoryId,
|
|
406
|
+
taskWorktreeId: task.record.taskWorktreeId,
|
|
407
|
+
ownerFingerprint,
|
|
408
|
+
targetRef: task.privateState.targetRef,
|
|
409
|
+
taskRef: task.privateState.branchRef,
|
|
410
|
+
targetOid,
|
|
411
|
+
taskOid,
|
|
412
|
+
candidateOid,
|
|
413
|
+
candidateTreeOid: scanned.treeOid,
|
|
414
|
+
message,
|
|
415
|
+
systemDate,
|
|
416
|
+
scanDigest,
|
|
417
|
+
artifactId: retained.artifactId,
|
|
418
|
+
objectIdsDigest: retained.objectIdsDigest,
|
|
419
|
+
repositoryIntegrations: integrationReview ? "approved_full_access" : "disabled",
|
|
420
|
+
integrationIdentitiesDigest: integrationReview?.identitiesDigest ?? null,
|
|
421
|
+
integrationConfigDigest: integrationReview?.configDigest ?? null,
|
|
422
|
+
integrationSemanticStateDigest: integrationReview?.semanticStateDigest ?? null,
|
|
423
|
+
expiresAt
|
|
424
|
+
});
|
|
425
|
+
this.options.candidateWorkspaces.bindReviewedCandidate(retained.artifactId, reviewToken);
|
|
426
|
+
}
|
|
427
|
+
catch (error) {
|
|
428
|
+
if (reviewToken)
|
|
429
|
+
this.options.reviews.revoke(reviewToken);
|
|
430
|
+
await this.options.candidateWorkspaces.cleanupReviewedCandidate(retained.artifactId);
|
|
431
|
+
throw error;
|
|
432
|
+
}
|
|
433
|
+
return this.#result({
|
|
434
|
+
action: "prepare",
|
|
435
|
+
repositoryId: repository.repositoryId,
|
|
436
|
+
taskWorktreeId: task.record.taskWorktreeId,
|
|
437
|
+
planId: null,
|
|
438
|
+
reviewToken,
|
|
439
|
+
status: "approval_required",
|
|
440
|
+
targetOid,
|
|
441
|
+
taskOid,
|
|
442
|
+
candidateOid,
|
|
443
|
+
changes: scanned.changes,
|
|
444
|
+
expiresAt,
|
|
445
|
+
repositoryIntegrations: integrationReview ? "approved_full_access" : "disabled"
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
const review = finalize.review;
|
|
449
|
+
const candidateRef = `refs/codexgpt/candidates/${input.taskWorktreeId.slice(5)}-${sha256Git(finalize.reviewToken).slice(0, 16)}`;
|
|
450
|
+
const plan = this.options.plans.create({
|
|
451
|
+
mergePlanId: this.options.plans.allocateId(),
|
|
452
|
+
lifecycleState: "preparing",
|
|
453
|
+
taskWorktreeId: task.record.taskWorktreeId,
|
|
454
|
+
taskGeneration: task.record.generation + 1,
|
|
455
|
+
repositoryId: repository.repositoryId,
|
|
456
|
+
repositoryIdentityFingerprint: repository.stableIdentityFingerprint,
|
|
457
|
+
capabilityRevision: repository.capabilityRevision,
|
|
458
|
+
contextFingerprint: sha256Git(this.options.manager.options.context.options.contextFingerprint),
|
|
459
|
+
policyRevision: input.authorization?.policyRevision ?? null,
|
|
460
|
+
ownerFingerprint,
|
|
461
|
+
primaryWorkspaceRoot: input.workspace.root,
|
|
462
|
+
targetRef: task.privateState.targetRef,
|
|
463
|
+
taskRef: task.privateState.branchRef,
|
|
464
|
+
candidateRef,
|
|
465
|
+
targetOid,
|
|
466
|
+
taskOid,
|
|
467
|
+
candidateOid,
|
|
468
|
+
candidateTreeOid: scanned.treeOid,
|
|
469
|
+
manifestDigest: scanned.manifestDigest,
|
|
470
|
+
diffDigest: scanned.diffDigest,
|
|
471
|
+
historyDigest: scanned.historyDigest,
|
|
472
|
+
checksComplete: false,
|
|
473
|
+
receiptIds: [],
|
|
474
|
+
integrationWorkspaceId: this.options.candidateWorkspaces.allocateId(),
|
|
475
|
+
requiredCheckCategories: [...this.options.candidateWorkspaces.requiredCategories],
|
|
476
|
+
affectedPathCount: scanned.changes.length,
|
|
477
|
+
affectedByteCount: scanned.totalBytes,
|
|
478
|
+
scanDigest,
|
|
479
|
+
repositoryIntegrations: review.repositoryIntegrations,
|
|
480
|
+
integrationIdentitiesDigest: review.integrationIdentitiesDigest,
|
|
481
|
+
integrationConfigDigest: review.integrationConfigDigest,
|
|
482
|
+
integrationSemanticStateDigest: review.integrationSemanticStateDigest
|
|
483
|
+
});
|
|
484
|
+
try {
|
|
485
|
+
await this.options.manager.options.journal.run({
|
|
486
|
+
authorization: finalize.authorization,
|
|
487
|
+
repository,
|
|
488
|
+
toolName: "merge_task_worktree",
|
|
489
|
+
canonicalAction: "task_merge_prepare_finalize",
|
|
490
|
+
workspaceId: input.workspace.id,
|
|
491
|
+
participants: ["object_quarantine", "ref_cas", "task_registry"],
|
|
492
|
+
counts: {
|
|
493
|
+
affectedObjectCount: objects.length,
|
|
494
|
+
affectedPathCount: scanned.changes.length,
|
|
495
|
+
affectedRefCount: 1
|
|
496
|
+
},
|
|
497
|
+
privateState: {
|
|
498
|
+
mergePlanId: plan.mergePlanId,
|
|
499
|
+
taskWorktreeId: task.record.taskWorktreeId,
|
|
500
|
+
targetOid,
|
|
501
|
+
taskOid,
|
|
502
|
+
candidateOid,
|
|
503
|
+
candidateRef,
|
|
504
|
+
integrationWorkspaceId: plan.integrationWorkspaceId,
|
|
505
|
+
reviewTokenDigest: sha256Git(finalize.reviewToken),
|
|
506
|
+
scanDigest,
|
|
507
|
+
reviewedArtifactDigest: sha256Git(review.artifactId)
|
|
508
|
+
},
|
|
509
|
+
effect: async () => {
|
|
510
|
+
const quarantine = new GitObjectQuarantine({ journal: () => undefined });
|
|
511
|
+
await quarantine.promote({
|
|
512
|
+
repository,
|
|
513
|
+
quarantineRoot,
|
|
514
|
+
objects: objects.map((oid) => ({ oid }))
|
|
515
|
+
});
|
|
516
|
+
const zero = "0".repeat(candidateOid.length);
|
|
517
|
+
const refResult = await executor.run(repository, [
|
|
518
|
+
"update-ref", "--no-deref", candidateRef, candidateOid, zero
|
|
519
|
+
]);
|
|
520
|
+
if (refResult.status !== 0)
|
|
521
|
+
throw new Error("GIT_REF_CHANGED");
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
const updatedTask = this.options.manager.options.store.update(task.record.taskWorktreeId, {
|
|
525
|
+
state: "merge_prepared",
|
|
526
|
+
headOid: taskOid
|
|
527
|
+
});
|
|
528
|
+
if (updatedTask.generation !== plan.taskGeneration)
|
|
529
|
+
throw new Error("GIT_RECOVERY_REQUIRED");
|
|
530
|
+
await this.options.candidateWorkspaces.create({
|
|
531
|
+
workspace: input.workspace,
|
|
532
|
+
repository,
|
|
533
|
+
taskWorktreeId: task.record.taskWorktreeId,
|
|
534
|
+
taskGeneration: updatedTask.generation,
|
|
535
|
+
mergePlanId: plan.mergePlanId,
|
|
536
|
+
candidateOid,
|
|
537
|
+
manifest: scanned.manifest,
|
|
538
|
+
expiresAt: plan.expiresAt,
|
|
539
|
+
integrationWorkspaceId: plan.integrationWorkspaceId
|
|
540
|
+
});
|
|
541
|
+
const preparedPlan = this.options.plans.transition(plan.mergePlanId, ownerFingerprint, "preparing", "prepared");
|
|
542
|
+
await this.options.candidateWorkspaces.cleanupReviewedCandidate(review.artifactId);
|
|
543
|
+
this.options.reviews.consume(finalize.reviewToken, "task_merge_finalize");
|
|
544
|
+
return this.#result({
|
|
545
|
+
action: "finalize",
|
|
546
|
+
repositoryId: repository.repositoryId,
|
|
547
|
+
taskWorktreeId: task.record.taskWorktreeId,
|
|
548
|
+
planId: preparedPlan.mergePlanId,
|
|
549
|
+
reviewToken: null,
|
|
550
|
+
status: "checks_required",
|
|
551
|
+
targetOid,
|
|
552
|
+
taskOid,
|
|
553
|
+
candidateOid,
|
|
554
|
+
changes: scanned.changes,
|
|
555
|
+
expiresAt: preparedPlan.expiresAt,
|
|
556
|
+
repositoryIntegrations: preparedPlan.repositoryIntegrations,
|
|
557
|
+
integrationWorkspaceId: preparedPlan.integrationWorkspaceId,
|
|
558
|
+
requiredCheckCategories: preparedPlan.requiredCheckCategories
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
catch (error) {
|
|
562
|
+
try {
|
|
563
|
+
await this.options.candidateWorkspaces.cleanup(plan.integrationWorkspaceId);
|
|
564
|
+
await this.#deleteCandidateRef(repository, candidateRef, candidateOid);
|
|
565
|
+
const current = this.options.manager.options.store.read(task.record.taskWorktreeId);
|
|
566
|
+
if (current.record.state === "merge_prepared" && current.record.headOid === taskOid) {
|
|
567
|
+
this.options.manager.options.store.update(task.record.taskWorktreeId, {
|
|
568
|
+
state: "ready",
|
|
569
|
+
headOid: taskOid
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
else if (current.record.state !== "ready") {
|
|
573
|
+
throw new Error("GIT_RECOVERY_REQUIRED");
|
|
574
|
+
}
|
|
575
|
+
this.options.plans.consumeForRecovery(plan.mergePlanId, ownerFingerprint);
|
|
576
|
+
}
|
|
577
|
+
catch {
|
|
578
|
+
try {
|
|
579
|
+
this.options.plans.transition(plan.mergePlanId, ownerFingerprint, "preparing", "recovery_required");
|
|
580
|
+
}
|
|
581
|
+
catch { }
|
|
582
|
+
try {
|
|
583
|
+
this.options.manager.options.store.update(task.record.taskWorktreeId, {
|
|
584
|
+
state: "recovery_required",
|
|
585
|
+
headOid: taskOid
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
catch { }
|
|
589
|
+
throw new Error("GIT_RECOVERY_REQUIRED", { cause: error });
|
|
590
|
+
}
|
|
591
|
+
throw error;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
finally {
|
|
595
|
+
if (ephemeralQuarantineRoot) {
|
|
596
|
+
await executor.removePrivateDirectory?.(ephemeralQuarantineRoot).catch(() => { });
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
async #deleteCandidateRef(repository, candidateRef, candidateOid) {
|
|
601
|
+
const executor = this.options.manager.options.context.options.executor;
|
|
602
|
+
const deleted = await executor.run(repository, [
|
|
603
|
+
"update-ref", "--no-deref", "-d", candidateRef, candidateOid
|
|
604
|
+
]);
|
|
605
|
+
if (deleted.status === 0)
|
|
606
|
+
return;
|
|
607
|
+
const probe = await executor.run(repository, [
|
|
608
|
+
"show-ref", "--verify", "--quiet", candidateRef
|
|
609
|
+
]);
|
|
610
|
+
if (probe.status === 1 && !probe.timedOut && !probe.stdoutTruncated && !probe.stderrTruncated)
|
|
611
|
+
return;
|
|
612
|
+
throw new Error("GIT_RECOVERY_REQUIRED");
|
|
613
|
+
}
|
|
614
|
+
async #scanCandidate(repository, guard, targetOid, candidateOid, objectDirectoryPath) {
|
|
615
|
+
const executor = this.options.manager.options.context.options.executor;
|
|
616
|
+
const manifest = await buildTaskTreeManifest({
|
|
617
|
+
executor,
|
|
618
|
+
repository,
|
|
619
|
+
treeish: candidateOid,
|
|
620
|
+
guard,
|
|
621
|
+
maxFiles: this.options.manager.options.maxFiles,
|
|
622
|
+
maxBytes: this.options.manager.options.maxBytes,
|
|
623
|
+
objectDirectoryPath
|
|
624
|
+
}).catch(() => {
|
|
625
|
+
throw new Error("GIT_MERGE_CAPABILITY_UNAVAILABLE");
|
|
626
|
+
});
|
|
627
|
+
for (const entry of manifest.entries) {
|
|
628
|
+
if (entry.kind !== "blob")
|
|
629
|
+
continue;
|
|
630
|
+
const content = await runGitRequired(executor, repository, ["cat-file", "blob", entry.oid], {
|
|
631
|
+
objectDirectoryPath,
|
|
632
|
+
stdoutLimitBytes: entry.size + 1
|
|
633
|
+
});
|
|
634
|
+
if (hasSecretValue(content.stdout.toString("latin1")))
|
|
635
|
+
throw new Error("GIT_SECRET_BLOCKED");
|
|
636
|
+
}
|
|
637
|
+
const history = await runGitRequired(executor, repository, [
|
|
638
|
+
"rev-list", "--max-count=4097", `${targetOid}..${candidateOid}`, "--"
|
|
639
|
+
], { objectDirectoryPath, stdoutLimitBytes: 512 * 1024 });
|
|
640
|
+
const historyOids = history.stdout.toString("ascii").trim().split(/\r?\n/u).filter(Boolean);
|
|
641
|
+
if (historyOids.length > 4096)
|
|
642
|
+
throw new Error("GIT_SCAN_LIMIT");
|
|
643
|
+
for (const oid of historyOids) {
|
|
644
|
+
const commit = await runGitRequired(executor, repository, ["cat-file", "commit", oid], {
|
|
645
|
+
objectDirectoryPath,
|
|
646
|
+
stdoutLimitBytes: 1024 * 1024
|
|
647
|
+
});
|
|
648
|
+
if (hasSecretValue(commit.stdout.toString("utf8")))
|
|
649
|
+
throw new Error("GIT_SECRET_BLOCKED");
|
|
650
|
+
}
|
|
651
|
+
const raw = await runGitRequired(executor, repository, [
|
|
652
|
+
"diff",
|
|
653
|
+
"--raw",
|
|
654
|
+
`--abbrev=${repository.objectFormat === "sha1" ? 40 : 64}`,
|
|
655
|
+
"-z",
|
|
656
|
+
"--no-renames",
|
|
657
|
+
targetOid,
|
|
658
|
+
candidateOid,
|
|
659
|
+
"--"
|
|
660
|
+
], { objectDirectoryPath, stdoutLimitBytes: 4 * 1024 * 1024 });
|
|
661
|
+
const changes = parseGitRawDiffZ(raw.stdout, repository.objectFormat).map((change) => ({
|
|
662
|
+
path: change.path,
|
|
663
|
+
change: change.change,
|
|
664
|
+
old_path: change.oldPath,
|
|
665
|
+
binary: false,
|
|
666
|
+
additions: null,
|
|
667
|
+
deletions: null
|
|
668
|
+
}));
|
|
669
|
+
return {
|
|
670
|
+
manifest,
|
|
671
|
+
manifestDigest: sha256Git(JSON.stringify({
|
|
672
|
+
treeOid: manifest.treeOid,
|
|
673
|
+
totalBytes: manifest.totalBytes,
|
|
674
|
+
entries: manifest.entries
|
|
675
|
+
})),
|
|
676
|
+
treeOid: manifest.treeOid,
|
|
677
|
+
totalBytes: manifest.totalBytes,
|
|
678
|
+
historyOids,
|
|
679
|
+
historyDigest: sha256Git(JSON.stringify(historyOids)),
|
|
680
|
+
changes,
|
|
681
|
+
diffDigest: sha256Git(JSON.stringify(changes))
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
#result(input) {
|
|
685
|
+
return {
|
|
686
|
+
action: input.action,
|
|
687
|
+
repository_id: input.repositoryId,
|
|
688
|
+
task_worktree_id: input.taskWorktreeId,
|
|
689
|
+
merge_plan_id: input.planId,
|
|
690
|
+
review_token: input.reviewToken,
|
|
691
|
+
status: input.status,
|
|
692
|
+
target_oid: input.targetOid,
|
|
693
|
+
task_oid: input.taskOid,
|
|
694
|
+
candidate_oid: input.candidateOid,
|
|
695
|
+
changes: input.changes,
|
|
696
|
+
conflicts: [],
|
|
697
|
+
path_scan_complete: true,
|
|
698
|
+
secret_scan_complete: true,
|
|
699
|
+
history_scan_complete: true,
|
|
700
|
+
checks_complete: false,
|
|
701
|
+
integration_workspace_id: input.integrationWorkspaceId ?? null,
|
|
702
|
+
required_check_categories: input.requiredCheckCategories ?? [],
|
|
703
|
+
execution_isolation: "none",
|
|
704
|
+
repository_integrations: input.repositoryIntegrations ?? "disabled",
|
|
705
|
+
expires_at: input.expiresAt
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
//# sourceMappingURL=mergePrepare.js.map
|