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,846 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import fsp from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { hasSecretValue, sanitizeGitPatchText } from "../redact.js";
|
|
5
|
+
import { gitV4LiteralPathSchema } from "../tools/schemas/gitV4Common.js";
|
|
6
|
+
import { admitGitRepository, revalidateGitRepository } from "./repositoryIdentity.js";
|
|
7
|
+
import { parseGitBatchCheck, parseGitBatchObjects, parseGitNumstatZ, parseGitRawDiffZ, parseGitStatusPorcelainV2, sanitizeGitPublicOneLine } from "./parsers.js";
|
|
8
|
+
export class ProcessLocalGitReadCoordinator {
|
|
9
|
+
#tails = new Map();
|
|
10
|
+
async run(workspace, action) {
|
|
11
|
+
const key = process.platform === "win32"
|
|
12
|
+
? path.resolve(workspace.root).toLocaleLowerCase("en-US")
|
|
13
|
+
: path.resolve(workspace.root);
|
|
14
|
+
const previous = this.#tails.get(key) ?? Promise.resolve();
|
|
15
|
+
let release;
|
|
16
|
+
const gate = new Promise((resolve) => { release = resolve; });
|
|
17
|
+
const tail = previous.catch(() => { }).then(() => gate);
|
|
18
|
+
this.#tails.set(key, tail);
|
|
19
|
+
await previous.catch(() => { });
|
|
20
|
+
try {
|
|
21
|
+
return await action();
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
release();
|
|
25
|
+
if (this.#tails.get(key) === tail)
|
|
26
|
+
this.#tails.delete(key);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const MAX_STATUS_BYTES = 1_048_576;
|
|
31
|
+
const MAX_PATCH_BYTES = 1_000_000;
|
|
32
|
+
const MAX_ENTRIES = 4096;
|
|
33
|
+
const MAX_ATTRIBUTE_FILES = 1024;
|
|
34
|
+
const MAX_ATTRIBUTE_DIRECTORIES = 4096;
|
|
35
|
+
const MAX_ATTRIBUTE_BYTES = 1_048_576;
|
|
36
|
+
const MAX_SCAN_FILE_BYTES = 524_288;
|
|
37
|
+
const MAX_SCAN_TOTAL_BYTES = 786_432;
|
|
38
|
+
const MAX_OBJECTS = 256;
|
|
39
|
+
const MAX_LOG_OBJECT_BYTES = 262_144;
|
|
40
|
+
const EMPTY_DIGEST = createHash("sha256").update("").digest("hex");
|
|
41
|
+
function gitError(code) {
|
|
42
|
+
return new Error(code);
|
|
43
|
+
}
|
|
44
|
+
function sha256(value) {
|
|
45
|
+
return createHash("sha256").update(value).digest("hex");
|
|
46
|
+
}
|
|
47
|
+
function stableJson(value) {
|
|
48
|
+
if (Array.isArray(value))
|
|
49
|
+
return `[${value.map(stableJson).join(",")}]`;
|
|
50
|
+
if (value && typeof value === "object") {
|
|
51
|
+
const object = value;
|
|
52
|
+
return `{${Object.keys(object).sort().map((key) => `${JSON.stringify(key)}:${stableJson(object[key])}`).join(",")}}`;
|
|
53
|
+
}
|
|
54
|
+
return JSON.stringify(value);
|
|
55
|
+
}
|
|
56
|
+
function posixPath(value) {
|
|
57
|
+
return value.split(path.sep).join("/").replace(/^\.\//, "");
|
|
58
|
+
}
|
|
59
|
+
function isInside(child, parent) {
|
|
60
|
+
const relative = path.relative(parent, child);
|
|
61
|
+
return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
|
|
62
|
+
}
|
|
63
|
+
function decodeUtf8OrNull(value) {
|
|
64
|
+
try {
|
|
65
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(value);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async function readBoundedFile(file, maxBytes) {
|
|
72
|
+
let lexical;
|
|
73
|
+
try {
|
|
74
|
+
lexical = await fsp.lstat(file, { bigint: true });
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
throw gitError("GIT_REPOSITORY_UNSAFE");
|
|
78
|
+
}
|
|
79
|
+
if (lexical.isSymbolicLink() || !lexical.isFile() || lexical.nlink !== 1n || lexical.size > BigInt(maxBytes)) {
|
|
80
|
+
throw gitError("GIT_REPOSITORY_UNSAFE");
|
|
81
|
+
}
|
|
82
|
+
const handle = await fsp.open(file, "r").catch(() => {
|
|
83
|
+
throw gitError("GIT_REPOSITORY_UNSAFE");
|
|
84
|
+
});
|
|
85
|
+
try {
|
|
86
|
+
const stat = await handle.stat({ bigint: true });
|
|
87
|
+
if (!stat.isFile() || stat.nlink !== 1n || stat.size > BigInt(maxBytes) ||
|
|
88
|
+
stat.dev !== lexical.dev || stat.ino !== lexical.ino)
|
|
89
|
+
throw gitError("GIT_REPOSITORY_UNSAFE");
|
|
90
|
+
return await handle.readFile();
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
await handle.close();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function outputText(value, limit = MAX_STATUS_BYTES) {
|
|
97
|
+
if (value.length > limit)
|
|
98
|
+
throw gitError("GIT_SCAN_LIMIT");
|
|
99
|
+
try {
|
|
100
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(value);
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
throw gitError("GIT_REPOSITORY_UNSAFE");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function parseLines(value) {
|
|
107
|
+
return outputText(value).split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
108
|
+
}
|
|
109
|
+
function mapStatusEntry(entry) {
|
|
110
|
+
return {
|
|
111
|
+
path: entry.path,
|
|
112
|
+
old_path: entry.oldPath,
|
|
113
|
+
index: entry.index,
|
|
114
|
+
worktree: entry.worktree,
|
|
115
|
+
submodule: entry.submodule
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function pathIsSecret(value) {
|
|
119
|
+
return hasSecretValue(value) || /(?:^|\/)(?:\.env(?:\.|$)|id_(?:rsa|dsa|ecdsa|ed25519)(?:\.|$)|.*\.(?:pem|key|p12|pfx))$/i.test(value);
|
|
120
|
+
}
|
|
121
|
+
function publicPathSafe(value) {
|
|
122
|
+
return gitV4LiteralPathSchema.safeParse(value).success;
|
|
123
|
+
}
|
|
124
|
+
function bufferHasSecret(value) {
|
|
125
|
+
return hasSecretValue(value.toString("latin1"));
|
|
126
|
+
}
|
|
127
|
+
function parseCommitDisplay(content) {
|
|
128
|
+
const separator = content.indexOf("\n\n");
|
|
129
|
+
if (separator < 0)
|
|
130
|
+
throw gitError("GIT_REPOSITORY_UNSAFE");
|
|
131
|
+
let authorLine = null;
|
|
132
|
+
let cursor = 0;
|
|
133
|
+
while (cursor < separator) {
|
|
134
|
+
const end = content.indexOf(0x0a, cursor);
|
|
135
|
+
const lineEnd = end < 0 || end > separator ? separator : end;
|
|
136
|
+
const line = content.subarray(cursor, lineEnd);
|
|
137
|
+
if (line.length >= 7 && line.subarray(0, 7).toString("ascii") === "author ") {
|
|
138
|
+
authorLine = line;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
cursor = lineEnd + 1;
|
|
142
|
+
}
|
|
143
|
+
if (!authorLine)
|
|
144
|
+
throw gitError("GIT_REPOSITORY_UNSAFE");
|
|
145
|
+
const emailStart = authorLine.lastIndexOf(" <");
|
|
146
|
+
const emailEnd = authorLine.lastIndexOf("> ");
|
|
147
|
+
if (emailStart < 7 || emailEnd <= emailStart + 2)
|
|
148
|
+
throw gitError("GIT_REPOSITORY_UNSAFE");
|
|
149
|
+
const suffix = authorLine.subarray(emailEnd + 2).toString("ascii");
|
|
150
|
+
const suffixMatch = /^(\d+) ([+-]\d{4})$/.exec(suffix);
|
|
151
|
+
if (!suffixMatch)
|
|
152
|
+
throw gitError("GIT_REPOSITORY_UNSAFE");
|
|
153
|
+
const timestampSeconds = Number(suffixMatch[1]);
|
|
154
|
+
if (!Number.isSafeInteger(timestampSeconds))
|
|
155
|
+
throw gitError("GIT_REPOSITORY_UNSAFE");
|
|
156
|
+
const timestampDate = new Date(timestampSeconds * 1000);
|
|
157
|
+
if (!Number.isFinite(timestampDate.getTime()))
|
|
158
|
+
throw gitError("GIT_REPOSITORY_UNSAFE");
|
|
159
|
+
const authorText = decodeUtf8OrNull(authorLine.subarray(7, emailStart));
|
|
160
|
+
const subjectStart = separator + 2;
|
|
161
|
+
const subjectEnd = content.indexOf(0x0a, subjectStart);
|
|
162
|
+
const subjectBytes = content.subarray(subjectStart, subjectEnd < 0 ? content.length : subjectEnd);
|
|
163
|
+
const subjectText = decodeUtf8OrNull(subjectBytes);
|
|
164
|
+
return {
|
|
165
|
+
subject: subjectText === null ? null : sanitizeGitPublicOneLine(subjectText, 240),
|
|
166
|
+
authorName: authorText === null ? null : sanitizeGitPublicOneLine(authorText, 160),
|
|
167
|
+
timestamp: timestampDate.toISOString()
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
async function runRequired(executor, repository, args, options = {}) {
|
|
171
|
+
const result = await executor.run(repository, args, options).catch(() => {
|
|
172
|
+
throw gitError("GIT_CAPABILITY_UNAVAILABLE");
|
|
173
|
+
});
|
|
174
|
+
if (result.timedOut || result.stdoutTruncated || result.stderrTruncated)
|
|
175
|
+
throw gitError("GIT_SCAN_LIMIT");
|
|
176
|
+
if (result.status !== 0)
|
|
177
|
+
throw gitError("GIT_CAPABILITY_UNAVAILABLE");
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
180
|
+
export async function neutralizedFilterConfig(executor, repository) {
|
|
181
|
+
const result = await executor.run(repository, [
|
|
182
|
+
"config",
|
|
183
|
+
"--local",
|
|
184
|
+
"--no-includes",
|
|
185
|
+
"--null",
|
|
186
|
+
"--get-regexp",
|
|
187
|
+
"^filter\\..*\\.(clean|smudge|process|required)$"
|
|
188
|
+
], { stdoutLimitBytes: 128 * 1024 });
|
|
189
|
+
if (result.timedOut ||
|
|
190
|
+
result.stdoutTruncated ||
|
|
191
|
+
result.stderrTruncated ||
|
|
192
|
+
(result.status !== 0 && result.status !== 1))
|
|
193
|
+
throw gitError("GIT_INTEGRATION_REQUIRED");
|
|
194
|
+
if (result.status === 1)
|
|
195
|
+
return [];
|
|
196
|
+
let text;
|
|
197
|
+
try {
|
|
198
|
+
text = new TextDecoder("utf-8", { fatal: true }).decode(result.stdout);
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
throw gitError("GIT_INTEGRATION_REQUIRED");
|
|
202
|
+
}
|
|
203
|
+
const names = new Set();
|
|
204
|
+
for (const record of text.split("\0").filter(Boolean)) {
|
|
205
|
+
const separator = record.indexOf("\n");
|
|
206
|
+
const key = separator < 0 ? record : record.slice(0, separator);
|
|
207
|
+
const match = /^filter\.([A-Za-z0-9._-]+)\.(?:clean|smudge|process|required)$/u.exec(key);
|
|
208
|
+
if (!match || match[1].length > 64)
|
|
209
|
+
throw gitError("GIT_INTEGRATION_REQUIRED");
|
|
210
|
+
names.add(match[1]);
|
|
211
|
+
}
|
|
212
|
+
if (names.size > 32)
|
|
213
|
+
throw gitError("GIT_SCAN_LIMIT");
|
|
214
|
+
return [...names].sort().flatMap((name) => [
|
|
215
|
+
`filter.${name}.process=`,
|
|
216
|
+
`filter.${name}.clean=! :`,
|
|
217
|
+
`filter.${name}.smudge=! :`,
|
|
218
|
+
`filter.${name}.required=false`
|
|
219
|
+
]);
|
|
220
|
+
}
|
|
221
|
+
async function attributeInventory(repository) {
|
|
222
|
+
const queue = [repository.worktreeRoot];
|
|
223
|
+
const records = [];
|
|
224
|
+
let directories = 0;
|
|
225
|
+
let totalBytes = 0;
|
|
226
|
+
let complete = true;
|
|
227
|
+
let integrationsPresent = false;
|
|
228
|
+
const inspect = async (file, relative, optional = false) => {
|
|
229
|
+
if (records.length >= MAX_ATTRIBUTE_FILES) {
|
|
230
|
+
complete = false;
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
let content;
|
|
234
|
+
try {
|
|
235
|
+
const handle = await fsp.open(file, "r");
|
|
236
|
+
try {
|
|
237
|
+
const stat = await handle.stat();
|
|
238
|
+
if (!stat.isFile() || stat.nlink !== 1 || stat.size > MAX_ATTRIBUTE_BYTES - totalBytes) {
|
|
239
|
+
complete = false;
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
content = await handle.readFile();
|
|
243
|
+
}
|
|
244
|
+
finally {
|
|
245
|
+
await handle.close();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
if (optional && error.code === "ENOENT")
|
|
250
|
+
return;
|
|
251
|
+
complete = false;
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
totalBytes += content.length;
|
|
255
|
+
const text = outputText(content, MAX_ATTRIBUTE_BYTES);
|
|
256
|
+
if (/(?:^|\s)(?:filter|diff|merge|working-tree-encoding)(?:=|\s|$)/im.test(text))
|
|
257
|
+
integrationsPresent = true;
|
|
258
|
+
records.push({ path: relative, digest: sha256(content) });
|
|
259
|
+
};
|
|
260
|
+
while (queue.length > 0) {
|
|
261
|
+
const directory = queue.shift();
|
|
262
|
+
directories += 1;
|
|
263
|
+
if (directories > MAX_ATTRIBUTE_DIRECTORIES) {
|
|
264
|
+
complete = false;
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
let entries;
|
|
268
|
+
try {
|
|
269
|
+
entries = await fsp.readdir(directory, { withFileTypes: true });
|
|
270
|
+
}
|
|
271
|
+
catch {
|
|
272
|
+
complete = false;
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
entries.sort((left, right) => left.name.localeCompare(right.name, "en-US"));
|
|
276
|
+
for (const entry of entries) {
|
|
277
|
+
if (entry.name === ".git")
|
|
278
|
+
continue;
|
|
279
|
+
const absolute = path.join(directory, entry.name);
|
|
280
|
+
if (entry.isSymbolicLink()) {
|
|
281
|
+
complete = false;
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
if (entry.isDirectory()) {
|
|
285
|
+
queue.push(absolute);
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
if (entry.isFile() && entry.name === ".gitattributes") {
|
|
289
|
+
await inspect(absolute, posixPath(path.relative(repository.worktreeRoot, absolute)));
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
await inspect(path.join(repository.commonDir, "info", "attributes"), ".git/info/attributes", true);
|
|
294
|
+
try {
|
|
295
|
+
const configContent = await readBoundedFile(path.join(repository.commonDir, "config"), MAX_ATTRIBUTE_BYTES);
|
|
296
|
+
const config = outputText(configContent, MAX_ATTRIBUTE_BYTES);
|
|
297
|
+
records.push({ path: ".git/config", digest: sha256(configContent) });
|
|
298
|
+
if (/^\s*\[(?:filter|diff|merge)(?:\s|\])/im.test(config) || /^\s*attributesfile\s*=/im.test(config)) {
|
|
299
|
+
integrationsPresent = true;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
catch {
|
|
303
|
+
complete = false;
|
|
304
|
+
}
|
|
305
|
+
return {
|
|
306
|
+
digest: sha256(stableJson(records)),
|
|
307
|
+
complete,
|
|
308
|
+
integrationsPresent
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
function literalPaths(workspace, guard, paths) {
|
|
312
|
+
if (!paths)
|
|
313
|
+
return undefined;
|
|
314
|
+
return paths.map((requested) => {
|
|
315
|
+
try {
|
|
316
|
+
const resolved = guard.resolve(workspace, requested);
|
|
317
|
+
return posixPath(resolved.relPath);
|
|
318
|
+
}
|
|
319
|
+
catch {
|
|
320
|
+
throw gitError("GIT_PATH_BLOCKED");
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
async function scanFile(file, workspaceRoot, budget) {
|
|
325
|
+
let lexical;
|
|
326
|
+
try {
|
|
327
|
+
lexical = await fsp.lstat(file, { bigint: true });
|
|
328
|
+
}
|
|
329
|
+
catch {
|
|
330
|
+
return { complete: false, secret: false, unsafe: false, digest: EMPTY_DIGEST };
|
|
331
|
+
}
|
|
332
|
+
if (lexical.isSymbolicLink() || !lexical.isFile() || lexical.nlink !== 1n) {
|
|
333
|
+
return { complete: false, secret: false, unsafe: true, digest: EMPTY_DIGEST };
|
|
334
|
+
}
|
|
335
|
+
let handle;
|
|
336
|
+
try {
|
|
337
|
+
handle = await fsp.open(file, "r");
|
|
338
|
+
}
|
|
339
|
+
catch {
|
|
340
|
+
return { complete: false, secret: false, unsafe: false, digest: EMPTY_DIGEST };
|
|
341
|
+
}
|
|
342
|
+
try {
|
|
343
|
+
const [stat, realPath] = await Promise.all([
|
|
344
|
+
handle.stat({ bigint: true }),
|
|
345
|
+
fsp.realpath(file).catch(() => "")
|
|
346
|
+
]);
|
|
347
|
+
if (!stat.isFile() || stat.nlink !== 1n || stat.dev !== lexical.dev || stat.ino !== lexical.ino ||
|
|
348
|
+
!realPath || !isInside(realPath, workspaceRoot)) {
|
|
349
|
+
return { complete: false, secret: false, unsafe: true, digest: EMPTY_DIGEST };
|
|
350
|
+
}
|
|
351
|
+
if (stat.size > BigInt(MAX_SCAN_FILE_BYTES) || BigInt(budget.total) + stat.size > BigInt(MAX_SCAN_TOTAL_BYTES)) {
|
|
352
|
+
return { complete: false, secret: false, unsafe: false, digest: EMPTY_DIGEST };
|
|
353
|
+
}
|
|
354
|
+
const content = await handle.readFile();
|
|
355
|
+
budget.total += content.length;
|
|
356
|
+
return { complete: true, secret: bufferHasSecret(content), unsafe: false, digest: sha256(content) };
|
|
357
|
+
}
|
|
358
|
+
finally {
|
|
359
|
+
await handle.close();
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function parseIndexEntries(value, oidLength) {
|
|
363
|
+
const records = outputText(value).split("\0").filter(Boolean);
|
|
364
|
+
return records.map((record) => {
|
|
365
|
+
const tab = record.indexOf("\t");
|
|
366
|
+
const match = /^(\d{6}) ([a-f0-9]+) ([0-3])$/.exec(tab < 0 ? "" : record.slice(0, tab));
|
|
367
|
+
const filePath = tab < 0 ? "" : record.slice(tab + 1);
|
|
368
|
+
if (!match || match[2].length !== oidLength || !filePath)
|
|
369
|
+
throw gitError("GIT_REPOSITORY_UNSAFE");
|
|
370
|
+
return { path: filePath, oid: match[2], stage: Number(match[3]) };
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
async function readObjectsBatch(executor, repository, oids, expectedType, maxObjectBytes, maxTotalBytes) {
|
|
374
|
+
if (oids.length === 0)
|
|
375
|
+
return [];
|
|
376
|
+
const stdin = Buffer.from(`${oids.join("\n")}\n`, "ascii");
|
|
377
|
+
const checkResult = await runRequired(executor, repository, ["cat-file", "--batch-check"], {
|
|
378
|
+
stdin,
|
|
379
|
+
stdoutLimitBytes: Math.min(MAX_STATUS_BYTES, Math.max(1, oids.length * 112)),
|
|
380
|
+
timeoutMs: 60_000
|
|
381
|
+
});
|
|
382
|
+
const checks = parseGitBatchCheck(checkResult.stdout, repository.objectFormat);
|
|
383
|
+
if (checks.length !== oids.length ||
|
|
384
|
+
checks.some((entry, index) => entry.oid !== oids[index] || entry.type !== expectedType))
|
|
385
|
+
throw gitError("GIT_OBJECT_MISSING");
|
|
386
|
+
let total = 0;
|
|
387
|
+
for (const check of checks) {
|
|
388
|
+
total += check.size;
|
|
389
|
+
if (check.size > maxObjectBytes || total > maxTotalBytes)
|
|
390
|
+
throw gitError("GIT_SCAN_LIMIT");
|
|
391
|
+
}
|
|
392
|
+
const batchLimit = total + checks.length * 128;
|
|
393
|
+
if (batchLimit > MAX_STATUS_BYTES)
|
|
394
|
+
throw gitError("GIT_SCAN_LIMIT");
|
|
395
|
+
const contentResult = await runRequired(executor, repository, ["cat-file", "--batch"], {
|
|
396
|
+
stdin,
|
|
397
|
+
stdoutLimitBytes: Math.max(1, batchLimit),
|
|
398
|
+
timeoutMs: 60_000
|
|
399
|
+
});
|
|
400
|
+
return parseGitBatchObjects(contentResult.stdout, checks, repository.objectFormat);
|
|
401
|
+
}
|
|
402
|
+
async function scanIndexObjects(executor, repository, paths) {
|
|
403
|
+
const args = ["ls-files", "--stage", "-z"];
|
|
404
|
+
if (paths)
|
|
405
|
+
args.push("--", ...paths);
|
|
406
|
+
const listing = await runRequired(executor, repository, args, { stdoutLimitBytes: MAX_STATUS_BYTES });
|
|
407
|
+
const entries = parseIndexEntries(listing.stdout, repository.objectFormat === "sha1" ? 40 : 64);
|
|
408
|
+
if (entries.length > MAX_OBJECTS || entries.some((entry) => entry.stage !== 0)) {
|
|
409
|
+
return { complete: false, secretPaths: new Set(), digest: sha256(listing.stdout) };
|
|
410
|
+
}
|
|
411
|
+
const uniqueOids = [...new Set(entries.map((entry) => entry.oid))];
|
|
412
|
+
let objects;
|
|
413
|
+
try {
|
|
414
|
+
objects = await readObjectsBatch(executor, repository, uniqueOids, "blob", MAX_SCAN_FILE_BYTES, MAX_SCAN_TOTAL_BYTES);
|
|
415
|
+
}
|
|
416
|
+
catch (error) {
|
|
417
|
+
if (error.message === "GIT_SCAN_LIMIT") {
|
|
418
|
+
return { complete: false, secretPaths: new Set(), digest: sha256(listing.stdout) };
|
|
419
|
+
}
|
|
420
|
+
throw error;
|
|
421
|
+
}
|
|
422
|
+
const secretOids = new Set(objects.filter((entry) => bufferHasSecret(entry.content)).map((entry) => entry.oid));
|
|
423
|
+
const objectDigests = objects.map((entry) => ({ oid: entry.oid, digest: sha256(entry.content) }));
|
|
424
|
+
return {
|
|
425
|
+
complete: true,
|
|
426
|
+
secretPaths: new Set(entries.filter((entry) => secretOids.has(entry.oid)).map((entry) => entry.path)),
|
|
427
|
+
digest: sha256(stableJson({ listing: sha256(listing.stdout), objects: objectDigests }))
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
function snapshotStateDigest(snapshot) {
|
|
431
|
+
return sha256(stableJson({
|
|
432
|
+
repositoryId: snapshot.repository.repositoryId,
|
|
433
|
+
repositoryFingerprint: snapshot.repository.repositoryFingerprint,
|
|
434
|
+
headDigest: snapshot.headDigest,
|
|
435
|
+
indexDigest: snapshot.indexDigest,
|
|
436
|
+
worktreeDigest: snapshot.worktreeDigest,
|
|
437
|
+
ignoredDigest: snapshot.ignoredDigest,
|
|
438
|
+
attributesDigest: snapshot.attributesDigest,
|
|
439
|
+
scopeDigest: snapshot.scopeDigest,
|
|
440
|
+
complete: snapshot.complete,
|
|
441
|
+
entries: snapshot.visibleEntries,
|
|
442
|
+
ignored: snapshot.visibleIgnoredPaths,
|
|
443
|
+
omittedBlocked: snapshot.omittedBlocked,
|
|
444
|
+
omittedSecret: snapshot.omittedSecret
|
|
445
|
+
}));
|
|
446
|
+
}
|
|
447
|
+
export class GitReadServiceV4 {
|
|
448
|
+
capabilityRevision;
|
|
449
|
+
#executor;
|
|
450
|
+
#registry;
|
|
451
|
+
#stateTokens;
|
|
452
|
+
#contextFingerprint;
|
|
453
|
+
#coordinator;
|
|
454
|
+
#integrationGate;
|
|
455
|
+
#admission;
|
|
456
|
+
constructor(options) {
|
|
457
|
+
if (options.registry.contextFingerprint() !== options.contextFingerprint)
|
|
458
|
+
throw gitError("GIT_REPOSITORY_UNSAFE");
|
|
459
|
+
this.capabilityRevision = options.executor.capabilityRevision;
|
|
460
|
+
this.#executor = options.executor;
|
|
461
|
+
this.#registry = options.registry;
|
|
462
|
+
this.#stateTokens = options.stateTokens;
|
|
463
|
+
this.#contextFingerprint = options.contextFingerprint;
|
|
464
|
+
this.#coordinator = options.coordinator ?? new ProcessLocalGitReadCoordinator();
|
|
465
|
+
this.#integrationGate = options.integrationGate ?? null;
|
|
466
|
+
this.#admission = options.admission ?? null;
|
|
467
|
+
}
|
|
468
|
+
currentBranchName(data) {
|
|
469
|
+
if (data.head.kind === "detached")
|
|
470
|
+
return null;
|
|
471
|
+
const ref = this.#registry.resolveBranch(data.repository_id, data.head.branch_id);
|
|
472
|
+
if (!ref.startsWith("refs/heads/"))
|
|
473
|
+
return null;
|
|
474
|
+
return sanitizeGitPublicOneLine(ref.slice("refs/heads/".length), 240);
|
|
475
|
+
}
|
|
476
|
+
async #snapshot(input) {
|
|
477
|
+
const repository = this.#admission
|
|
478
|
+
? await this.#admission.admit(input.workspace)
|
|
479
|
+
: await admitGitRepository({ workspaceRoot: input.workspace.root, executor: this.#executor, registry: this.#registry });
|
|
480
|
+
const paths = literalPaths(input.workspace, input.guard, input.paths);
|
|
481
|
+
const configOverrides = await neutralizedFilterConfig(this.#executor, repository);
|
|
482
|
+
const args = ["status", "--porcelain=v2", "-z", "--branch", "--untracked-files=all", "--ignored=matching"];
|
|
483
|
+
if (paths)
|
|
484
|
+
args.push("--", ...paths);
|
|
485
|
+
const result = await runRequired(this.#executor, repository, args, {
|
|
486
|
+
stdoutLimitBytes: MAX_STATUS_BYTES,
|
|
487
|
+
configOverrides
|
|
488
|
+
});
|
|
489
|
+
const parsed = parseGitStatusPorcelainV2(result.stdout, repository.objectFormat);
|
|
490
|
+
const attributes = await attributeInventory(repository);
|
|
491
|
+
const indexScan = await scanIndexObjects(this.#executor, repository, paths);
|
|
492
|
+
const budget = { total: 0 };
|
|
493
|
+
const visibleEntries = [];
|
|
494
|
+
let omittedBlocked = 0;
|
|
495
|
+
let omittedSecret = 0;
|
|
496
|
+
let contentComplete = indexScan.complete;
|
|
497
|
+
const worktreeRecords = [];
|
|
498
|
+
for (const entry of parsed.entries) {
|
|
499
|
+
if (!publicPathSafe(entry.path) || (entry.oldPath !== null && !publicPathSafe(entry.oldPath))) {
|
|
500
|
+
omittedBlocked += 1;
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
503
|
+
if (input.guard.isBlockedRelativePath(entry.path) || (entry.oldPath !== null && input.guard.isBlockedRelativePath(entry.oldPath))) {
|
|
504
|
+
omittedBlocked += 1;
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
if (pathIsSecret(entry.path) || (entry.oldPath !== null && pathIsSecret(entry.oldPath)) || indexScan.secretPaths.has(entry.path)) {
|
|
508
|
+
omittedSecret += 1;
|
|
509
|
+
continue;
|
|
510
|
+
}
|
|
511
|
+
if (entry.worktree !== "unmodified" && entry.worktree !== "deleted" && entry.worktree !== "unmerged") {
|
|
512
|
+
const scanned = await scanFile(path.join(repository.worktreeRoot, ...entry.path.split("/")), repository.worktreeRoot, budget);
|
|
513
|
+
contentComplete &&= scanned.complete;
|
|
514
|
+
if (scanned.unsafe) {
|
|
515
|
+
omittedBlocked += 1;
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
if (scanned.secret) {
|
|
519
|
+
omittedSecret += 1;
|
|
520
|
+
continue;
|
|
521
|
+
}
|
|
522
|
+
worktreeRecords.push({ path: entry.path, digest: scanned.digest });
|
|
523
|
+
}
|
|
524
|
+
visibleEntries.push(entry);
|
|
525
|
+
}
|
|
526
|
+
const visibleIgnoredPaths = [];
|
|
527
|
+
for (const ignored of parsed.ignoredPaths) {
|
|
528
|
+
if (!publicPathSafe(ignored)) {
|
|
529
|
+
omittedBlocked += 1;
|
|
530
|
+
}
|
|
531
|
+
else if (input.guard.isBlockedRelativePath(ignored)) {
|
|
532
|
+
omittedBlocked += 1;
|
|
533
|
+
}
|
|
534
|
+
else if (pathIsSecret(ignored)) {
|
|
535
|
+
omittedSecret += 1;
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
visibleIgnoredPaths.push(ignored);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
await revalidateGitRepository(repository);
|
|
542
|
+
const complete = parsed.entries.length <= MAX_ENTRIES &&
|
|
543
|
+
omittedBlocked === 0 &&
|
|
544
|
+
omittedSecret === 0 &&
|
|
545
|
+
contentComplete &&
|
|
546
|
+
attributes.complete &&
|
|
547
|
+
(!attributes.integrationsPresent || this.#integrationGate?.enabled === true) &&
|
|
548
|
+
repository.refStorage === "files" &&
|
|
549
|
+
!repository.sparseCheckout &&
|
|
550
|
+
!repository.splitIndex;
|
|
551
|
+
return {
|
|
552
|
+
repository,
|
|
553
|
+
parsed,
|
|
554
|
+
visibleEntries,
|
|
555
|
+
visibleIgnoredPaths,
|
|
556
|
+
omittedBlocked,
|
|
557
|
+
omittedSecret,
|
|
558
|
+
complete,
|
|
559
|
+
headDigest: sha256(stableJson(parsed.head)),
|
|
560
|
+
indexDigest: indexScan.digest,
|
|
561
|
+
worktreeDigest: sha256(stableJson({ status: sha256(result.stdout), files: worktreeRecords })),
|
|
562
|
+
ignoredDigest: sha256(stableJson(visibleIgnoredPaths)),
|
|
563
|
+
attributesDigest: attributes.digest,
|
|
564
|
+
scopeDigest: sha256(stableJson(paths ?? ["<repository>"]))
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
#stateFacts(snapshot, workspaceId, resultDigest) {
|
|
568
|
+
return {
|
|
569
|
+
schemaVersion: 1,
|
|
570
|
+
repositoryId: snapshot.repository.repositoryId,
|
|
571
|
+
workspaceId,
|
|
572
|
+
contextFingerprint: this.#contextFingerprint,
|
|
573
|
+
capabilityRevision: this.#executor.capabilityRevision,
|
|
574
|
+
repositoryFingerprint: snapshot.repository.repositoryFingerprint,
|
|
575
|
+
headDigest: snapshot.headDigest,
|
|
576
|
+
indexDigest: snapshot.indexDigest,
|
|
577
|
+
worktreeDigest: snapshot.worktreeDigest,
|
|
578
|
+
ignoredDigest: snapshot.ignoredDigest,
|
|
579
|
+
attributesDigest: snapshot.attributesDigest,
|
|
580
|
+
scopeDigest: snapshot.scopeDigest,
|
|
581
|
+
resultDigest,
|
|
582
|
+
complete: snapshot.complete
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
status(input) {
|
|
586
|
+
return this.#coordinator.run(input.workspace, async () => (await this.#statusWithDisplay(input)).data);
|
|
587
|
+
}
|
|
588
|
+
statusWithDisplay(input) {
|
|
589
|
+
return this.#coordinator.run(input.workspace, () => this.#statusWithDisplay(input));
|
|
590
|
+
}
|
|
591
|
+
async #statusWithDisplay(input) {
|
|
592
|
+
const snapshot = await this.#snapshot(input);
|
|
593
|
+
const head = snapshot.parsed.head.kind === "detached"
|
|
594
|
+
? { kind: "detached", branch_id: null, oid: snapshot.parsed.head.oid }
|
|
595
|
+
: snapshot.parsed.head.kind === "unborn"
|
|
596
|
+
? { kind: "unborn", branch_id: this.#registry.branchId(snapshot.repository.repositoryId, snapshot.parsed.head.ref), oid: null }
|
|
597
|
+
: { kind: "branch", branch_id: this.#registry.branchId(snapshot.repository.repositoryId, snapshot.parsed.head.ref), oid: snapshot.parsed.head.oid };
|
|
598
|
+
let tokenSnapshot = snapshot;
|
|
599
|
+
if (snapshot.complete) {
|
|
600
|
+
const rechecked = await this.#snapshot(input);
|
|
601
|
+
if (snapshotStateDigest(rechecked) !== snapshotStateDigest(snapshot))
|
|
602
|
+
throw gitError("GIT_STATE_CHANGED");
|
|
603
|
+
tokenSnapshot = rechecked;
|
|
604
|
+
}
|
|
605
|
+
const integrationReview = snapshot.complete && this.#integrationGate?.enabled
|
|
606
|
+
? await this.#integrationGate.review({
|
|
607
|
+
workspaceId: input.workspace.id,
|
|
608
|
+
repository: tokenSnapshot.repository,
|
|
609
|
+
semanticStateDigest: snapshotStateDigest(tokenSnapshot)
|
|
610
|
+
})
|
|
611
|
+
: null;
|
|
612
|
+
const withoutToken = {
|
|
613
|
+
repository_id: snapshot.repository.repositoryId,
|
|
614
|
+
head,
|
|
615
|
+
entries: snapshot.visibleEntries.slice(0, MAX_ENTRIES).map(mapStatusEntry),
|
|
616
|
+
changed_count: snapshot.visibleEntries.length,
|
|
617
|
+
untracked_count: snapshot.visibleEntries.filter((entry) => entry.worktree === "untracked").length,
|
|
618
|
+
ignored_count: snapshot.visibleIgnoredPaths.length,
|
|
619
|
+
omitted_blocked_count: snapshot.omittedBlocked,
|
|
620
|
+
omitted_secret_count: snapshot.omittedSecret,
|
|
621
|
+
scan_complete: snapshot.complete,
|
|
622
|
+
mutation_state: snapshot.complete ? "complete" : "incomplete",
|
|
623
|
+
integration_identity_count: integrationReview?.identities.length ?? 0,
|
|
624
|
+
integration_identity_digest: integrationReview?.identitiesDigest ?? null,
|
|
625
|
+
integration_identities: (integrationReview?.identities ?? []).map((identity) => ({
|
|
626
|
+
kind: identity.kind,
|
|
627
|
+
config_key_digest: identity.configKeyDigest,
|
|
628
|
+
executable_digest: identity.executableDigest,
|
|
629
|
+
content_digest: identity.contentDigest
|
|
630
|
+
})),
|
|
631
|
+
execution_isolation: "none",
|
|
632
|
+
repository_integrations: this.#integrationGate?.enabled
|
|
633
|
+
? "approved_full_access"
|
|
634
|
+
: "disabled"
|
|
635
|
+
};
|
|
636
|
+
const facts = this.#stateFacts(tokenSnapshot, input.workspace.id, sha256(stableJson(withoutToken)));
|
|
637
|
+
const currentBranchName = snapshot.parsed.head.ref?.startsWith("refs/heads/")
|
|
638
|
+
? sanitizeGitPublicOneLine(snapshot.parsed.head.ref.slice("refs/heads/".length), 240)
|
|
639
|
+
: null;
|
|
640
|
+
return {
|
|
641
|
+
data: {
|
|
642
|
+
...withoutToken,
|
|
643
|
+
state_token: snapshot.complete ? this.#stateTokens.mint(facts) : null,
|
|
644
|
+
integration_review_token: integrationReview?.reviewToken ?? null
|
|
645
|
+
},
|
|
646
|
+
currentBranchName
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
diff(input) {
|
|
650
|
+
return this.#coordinator.run(input.workspace, () => this.#diff(input));
|
|
651
|
+
}
|
|
652
|
+
async #diff(input) {
|
|
653
|
+
if (input.comparison === "head_to_base")
|
|
654
|
+
throw gitError("TASK_WORKTREE_NOT_FOUND");
|
|
655
|
+
const snapshot = await this.#snapshot({ workspace: input.workspace, guard: input.guard, paths: input.paths });
|
|
656
|
+
const paths = literalPaths(input.workspace, input.guard, input.paths);
|
|
657
|
+
const baseArgs = input.comparison === "index_to_head" ? ["diff", "--cached"] : ["diff"];
|
|
658
|
+
const common = ["--no-ext-diff", "--no-textconv", "--no-abbrev", "-M", "-C"];
|
|
659
|
+
const pathArgs = paths ? ["--", ...paths] : ["--"];
|
|
660
|
+
await revalidateGitRepository(snapshot.repository);
|
|
661
|
+
const raw = await runRequired(this.#executor, snapshot.repository, [...baseArgs, "--raw", "-z", ...common, ...pathArgs], { stdoutLimitBytes: MAX_STATUS_BYTES });
|
|
662
|
+
await revalidateGitRepository(snapshot.repository);
|
|
663
|
+
const numstat = await runRequired(this.#executor, snapshot.repository, [...baseArgs, "--numstat", "-z", ...common, ...pathArgs], { stdoutLimitBytes: MAX_STATUS_BYTES });
|
|
664
|
+
await revalidateGitRepository(snapshot.repository);
|
|
665
|
+
const rawChanges = parseGitRawDiffZ(raw.stdout, snapshot.repository.objectFormat);
|
|
666
|
+
const stats = parseGitNumstatZ(numstat.stdout);
|
|
667
|
+
const statsByPath = new Map(stats.map((entry) => [entry.path, entry]));
|
|
668
|
+
const visibleStatusPaths = new Set(snapshot.visibleEntries.flatMap((entry) => entry.oldPath === null ? [entry.path] : [entry.path, entry.oldPath]));
|
|
669
|
+
const changes = [];
|
|
670
|
+
let omittedBlocked = snapshot.omittedBlocked;
|
|
671
|
+
let omittedSecret = snapshot.omittedSecret;
|
|
672
|
+
for (const change of rawChanges) {
|
|
673
|
+
if (!visibleStatusPaths.has(change.path) && !(change.oldPath && visibleStatusPaths.has(change.oldPath)))
|
|
674
|
+
continue;
|
|
675
|
+
if (!publicPathSafe(change.path) || (change.oldPath && !publicPathSafe(change.oldPath))) {
|
|
676
|
+
omittedBlocked += 1;
|
|
677
|
+
continue;
|
|
678
|
+
}
|
|
679
|
+
if (input.guard.isBlockedRelativePath(change.path) || (change.oldPath && input.guard.isBlockedRelativePath(change.oldPath))) {
|
|
680
|
+
omittedBlocked += 1;
|
|
681
|
+
continue;
|
|
682
|
+
}
|
|
683
|
+
if (pathIsSecret(change.path) || (change.oldPath && pathIsSecret(change.oldPath))) {
|
|
684
|
+
omittedSecret += 1;
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
const stat = statsByPath.get(change.path);
|
|
688
|
+
changes.push({
|
|
689
|
+
path: change.path,
|
|
690
|
+
change: change.change,
|
|
691
|
+
old_path: change.oldPath,
|
|
692
|
+
binary: stat?.binary ?? false,
|
|
693
|
+
additions: stat?.additions ?? 0,
|
|
694
|
+
deletions: stat?.deletions ?? 0
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
let patch = "";
|
|
698
|
+
let patchIncluded = input.includePatch ?? false;
|
|
699
|
+
let truncated = false;
|
|
700
|
+
if (patchIncluded && changes.length > 0) {
|
|
701
|
+
const visiblePaths = changes.flatMap((change) => change.old_path ? [change.old_path, change.path] : [change.path]);
|
|
702
|
+
const patchResult = await this.#executor.run(snapshot.repository, [...baseArgs, "--patch", "--no-color", "--no-ext-diff", "--no-textconv", "-M", "-C", "--", ...visiblePaths], {
|
|
703
|
+
stdoutLimitBytes: MAX_PATCH_BYTES,
|
|
704
|
+
stderrLimitBytes: 4096,
|
|
705
|
+
timeoutMs: 60_000
|
|
706
|
+
}).catch(() => { throw gitError("GIT_CAPABILITY_UNAVAILABLE"); });
|
|
707
|
+
if (patchResult.timedOut || patchResult.stdoutTruncated || patchResult.stderrTruncated)
|
|
708
|
+
throw gitError("GIT_SCAN_LIMIT");
|
|
709
|
+
if (patchResult.status !== 0)
|
|
710
|
+
throw gitError("GIT_CAPABILITY_UNAVAILABLE");
|
|
711
|
+
await revalidateGitRepository(snapshot.repository);
|
|
712
|
+
const sanitized = sanitizeGitPatchText(outputText(patchResult.stdout, MAX_PATCH_BYTES), MAX_PATCH_BYTES);
|
|
713
|
+
patch = sanitized.text;
|
|
714
|
+
truncated = patchResult.stdoutTruncated || sanitized.truncated;
|
|
715
|
+
if (sanitized.secretRedacted)
|
|
716
|
+
omittedSecret += 1;
|
|
717
|
+
}
|
|
718
|
+
const withoutToken = {
|
|
719
|
+
repository_id: snapshot.repository.repositoryId,
|
|
720
|
+
comparison: input.comparison,
|
|
721
|
+
changes,
|
|
722
|
+
additions: changes.reduce((sum, entry) => sum + (entry.additions ?? 0), 0),
|
|
723
|
+
deletions: changes.reduce((sum, entry) => sum + (entry.deletions ?? 0), 0),
|
|
724
|
+
binary_count: changes.filter((entry) => entry.binary).length,
|
|
725
|
+
patch,
|
|
726
|
+
patch_included: patchIncluded,
|
|
727
|
+
truncated,
|
|
728
|
+
omitted_blocked_count: omittedBlocked,
|
|
729
|
+
omitted_secret_count: omittedSecret
|
|
730
|
+
};
|
|
731
|
+
const complete = snapshot.complete && !truncated && omittedBlocked === 0 && omittedSecret === 0 && rawChanges.length <= MAX_ENTRIES;
|
|
732
|
+
let tokenSnapshot = snapshot;
|
|
733
|
+
if (complete) {
|
|
734
|
+
const rechecked = await this.#snapshot({ workspace: input.workspace, guard: input.guard, paths: input.paths });
|
|
735
|
+
if (snapshotStateDigest(rechecked) !== snapshotStateDigest(snapshot))
|
|
736
|
+
throw gitError("GIT_STATE_CHANGED");
|
|
737
|
+
tokenSnapshot = rechecked;
|
|
738
|
+
}
|
|
739
|
+
await revalidateGitRepository(snapshot.repository);
|
|
740
|
+
const facts = { ...this.#stateFacts(tokenSnapshot, input.workspace.id, sha256(stableJson(withoutToken))), complete };
|
|
741
|
+
return {
|
|
742
|
+
...withoutToken,
|
|
743
|
+
state_token: complete ? this.#stateTokens.mint(facts) : null
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
branches(input) {
|
|
747
|
+
return this.#coordinator.run(input.workspace, () => this.#branches(input));
|
|
748
|
+
}
|
|
749
|
+
async #branches(input) {
|
|
750
|
+
const snapshot = await this.#snapshot(input);
|
|
751
|
+
await revalidateGitRepository(snapshot.repository);
|
|
752
|
+
const result = await runRequired(this.#executor, snapshot.repository, [
|
|
753
|
+
"for-each-ref",
|
|
754
|
+
"--sort=refname",
|
|
755
|
+
"--format=%(refname)%00%(objectname)%00%(worktreepath)%00",
|
|
756
|
+
"refs/heads"
|
|
757
|
+
], { stdoutLimitBytes: MAX_STATUS_BYTES });
|
|
758
|
+
const fields = outputText(result.stdout).split("\0");
|
|
759
|
+
const branches = [];
|
|
760
|
+
const caseKeys = new Set();
|
|
761
|
+
for (let index = 0; index + 2 < fields.length; index += 3) {
|
|
762
|
+
const ref = fields[index].replace(/^\r?\n/, "");
|
|
763
|
+
const oid = fields[index + 1];
|
|
764
|
+
const worktreePath = fields[index + 2];
|
|
765
|
+
if (!ref)
|
|
766
|
+
continue;
|
|
767
|
+
if (!ref.startsWith("refs/heads/") || !new RegExp(`^[a-f0-9]{${snapshot.repository.objectFormat === "sha1" ? 40 : 64}}$`).test(oid))
|
|
768
|
+
throw gitError("GIT_REPOSITORY_UNSAFE");
|
|
769
|
+
const key = ref.toLocaleLowerCase("en-US");
|
|
770
|
+
if (caseKeys.has(key))
|
|
771
|
+
throw gitError("GIT_REPOSITORY_UNSAFE");
|
|
772
|
+
caseKeys.add(key);
|
|
773
|
+
const shortName = ref.slice("refs/heads/".length);
|
|
774
|
+
const name = sanitizeGitPublicOneLine(shortName, 240);
|
|
775
|
+
const current = snapshot.parsed.head.ref === ref;
|
|
776
|
+
branches.push({
|
|
777
|
+
branch_id: this.#registry.branchId(snapshot.repository.repositoryId, ref),
|
|
778
|
+
oid,
|
|
779
|
+
current,
|
|
780
|
+
checked_out: current || worktreePath.trim().length > 0,
|
|
781
|
+
owned_task_worktree_id: null,
|
|
782
|
+
name,
|
|
783
|
+
name_omitted: name === null
|
|
784
|
+
});
|
|
785
|
+
if (branches.length > 512)
|
|
786
|
+
throw gitError("GIT_SCAN_LIMIT");
|
|
787
|
+
}
|
|
788
|
+
await revalidateGitRepository(snapshot.repository);
|
|
789
|
+
return {
|
|
790
|
+
repository_id: snapshot.repository.repositoryId,
|
|
791
|
+
branches,
|
|
792
|
+
truncated: false,
|
|
793
|
+
execution_isolation: "none",
|
|
794
|
+
repository_integrations: "disabled"
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
log(input) {
|
|
798
|
+
return this.#coordinator.run(input.workspace, () => this.#log(input));
|
|
799
|
+
}
|
|
800
|
+
async #log(input) {
|
|
801
|
+
const snapshot = await this.#snapshot(input);
|
|
802
|
+
const limit = input.limit ?? 20;
|
|
803
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 100)
|
|
804
|
+
throw gitError("GIT_SCAN_LIMIT");
|
|
805
|
+
const revision = input.branchId
|
|
806
|
+
? this.#registry.resolveBranch(snapshot.repository.repositoryId, input.branchId)
|
|
807
|
+
: "HEAD";
|
|
808
|
+
await revalidateGitRepository(snapshot.repository);
|
|
809
|
+
const result = await runRequired(this.#executor, snapshot.repository, ["rev-list", `--max-count=${limit + 1}`, "--parents", revision], { stdoutLimitBytes: MAX_STATUS_BYTES });
|
|
810
|
+
await revalidateGitRepository(snapshot.repository);
|
|
811
|
+
const lines = parseLines(result.stdout);
|
|
812
|
+
const truncated = lines.length > limit;
|
|
813
|
+
const selected = lines.slice(0, limit).map((line) => line.split(" "));
|
|
814
|
+
const oidLength = snapshot.repository.objectFormat === "sha1" ? 40 : 64;
|
|
815
|
+
const oidPattern = new RegExp(`^[a-f0-9]{${oidLength}}$`);
|
|
816
|
+
if (selected.some((record) => !record.every((value) => oidPattern.test(value)))) {
|
|
817
|
+
throw gitError("GIT_REPOSITORY_UNSAFE");
|
|
818
|
+
}
|
|
819
|
+
await revalidateGitRepository(snapshot.repository);
|
|
820
|
+
const objects = await readObjectsBatch(this.#executor, snapshot.repository, selected.map(([oid]) => oid), "commit", MAX_LOG_OBJECT_BYTES, MAX_SCAN_TOTAL_BYTES);
|
|
821
|
+
await revalidateGitRepository(snapshot.repository);
|
|
822
|
+
const commits = [];
|
|
823
|
+
for (let index = 0; index < selected.length; index += 1) {
|
|
824
|
+
const [oid, ...parentOids] = selected[index];
|
|
825
|
+
const display = parseCommitDisplay(objects[index].content);
|
|
826
|
+
commits.push({
|
|
827
|
+
oid,
|
|
828
|
+
parent_oids: parentOids,
|
|
829
|
+
subject: display.subject,
|
|
830
|
+
subject_omitted: display.subject === null,
|
|
831
|
+
author_name: display.authorName,
|
|
832
|
+
author_name_omitted: display.authorName === null,
|
|
833
|
+
timestamp: display.timestamp
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
await revalidateGitRepository(snapshot.repository);
|
|
837
|
+
return {
|
|
838
|
+
repository_id: snapshot.repository.repositoryId,
|
|
839
|
+
commits,
|
|
840
|
+
truncated,
|
|
841
|
+
execution_isolation: "none",
|
|
842
|
+
repository_integrations: "disabled"
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
//# sourceMappingURL=readService.js.map
|