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,179 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
8
|
+
const importBuilt = (relativePath) => import(pathToFileURL(path.join(projectRoot, 'dist', relativePath)).href);
|
|
9
|
+
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), 'codexgpt-analysis-'));
|
|
10
|
+
const outside = await fs.mkdtemp(path.join(os.tmpdir(), 'codexgpt-analysis-outside-'));
|
|
11
|
+
|
|
12
|
+
async function write(relativePath, content) {
|
|
13
|
+
const target = path.join(tmp, relativePath);
|
|
14
|
+
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
15
|
+
await fs.writeFile(target, content, 'utf8');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
await write('package.json', JSON.stringify({ name: 'fixture', packageManager: 'pnpm@9.15.0', scripts: { test: 'node --test' } }, null, 2));
|
|
20
|
+
await write('src/index.ts', "import { authenticate } from './auth.js';\nexport const ready = authenticate('demo');\n");
|
|
21
|
+
await write('src/auth.ts', 'export function authenticate(user: string) { return Boolean(user); }\n');
|
|
22
|
+
await write('src/race.ts', 'export function temporaryFile() { return true; }\n');
|
|
23
|
+
await write('test/auth.test.ts', "import { authenticate } from '../src/auth.js';\nvoid authenticate('test');\n");
|
|
24
|
+
await write('README.md', '# Fixture\n');
|
|
25
|
+
await write('.env', 'PRIVATE_TOKEN=never-visible\n');
|
|
26
|
+
await write('python/service.py', 'def load_user(user_id):\n return user_id\n');
|
|
27
|
+
await write('go/service.go', 'package service\nfunc LoadUser(id string) string { return id }\n');
|
|
28
|
+
await write('go.mod', 'module example.com/fixture\n\ngo 1.24\n');
|
|
29
|
+
await write('rust/service.rs', 'pub fn load_user(id: &str) -> &str { id }\n');
|
|
30
|
+
await write('swift/Service.swift', 'public func loadUser(_ id: String) -> String { id }\n');
|
|
31
|
+
await write('java/Service.java', 'public class Service { }\n');
|
|
32
|
+
await write('csharp/Service.cs', 'public class Service { }\n');
|
|
33
|
+
await write('c/service.c', 'int load_user(int id) { return id; }\n');
|
|
34
|
+
await write('cpp/service.cpp', 'class Service { };\n');
|
|
35
|
+
await write('notes/many.txt', Array.from({ length: 20 }, (_, index) => `common marker ${index}`).join('\n') + '\n');
|
|
36
|
+
await write('unknown/service.zig', 'pub fn loadUser() void {}\n');
|
|
37
|
+
await write('packages/core/package.json', JSON.stringify({ name: '@fixture/core' }, null, 2));
|
|
38
|
+
await write('packages/core/src/index.ts', 'export function coreValue() { return 1; }\n');
|
|
39
|
+
await write('packages/web/package.json', JSON.stringify({ name: '@fixture/web', dependencies: { '@fixture/core': 'workspace:*' } }, null, 2));
|
|
40
|
+
await write('packages/web/src/index.ts', "import { coreValue } from '../../core/src/index.js';\nexport const webValue = coreValue();\n");
|
|
41
|
+
await fs.writeFile(path.join(outside, 'outside.ts'), 'export const outside = true;\n', 'utf8');
|
|
42
|
+
let symlinkCreated = false;
|
|
43
|
+
try {
|
|
44
|
+
await fs.symlink(outside, path.join(tmp, 'outside-link'), 'dir');
|
|
45
|
+
symlinkCreated = true;
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (process.platform !== 'win32' || error?.code !== 'EPERM') throw error;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const [{ loadConfig }, { PathGuard, WorkspaceManager }, { inventoryWorkspace }, { extractWorkspaceFiles }, classification, analysisApi] = await Promise.all([
|
|
51
|
+
importBuilt('config.js'),
|
|
52
|
+
importBuilt('guard.js'),
|
|
53
|
+
importBuilt('analysis/inventory.js'),
|
|
54
|
+
importBuilt('analysis/extract.js'),
|
|
55
|
+
importBuilt('analysis/classify.js'),
|
|
56
|
+
importBuilt('analysis/index.js')
|
|
57
|
+
]);
|
|
58
|
+
const config = loadConfig(['--root', tmp, '--bash', 'off', '--write', 'off']);
|
|
59
|
+
const guard = new PathGuard(config);
|
|
60
|
+
const workspace = new WorkspaceManager(config).defaultWorkspace();
|
|
61
|
+
const result = await inventoryWorkspace(config, guard, workspace);
|
|
62
|
+
|
|
63
|
+
assert(result.files.some((file) => file.path === 'src/index.ts' && file.language === 'typescript' && file.role === 'source'));
|
|
64
|
+
assert(result.files.some((file) => file.path === 'test/auth.test.ts' && file.role === 'test'));
|
|
65
|
+
assert(!result.files.some((file) => file.path === '.env'));
|
|
66
|
+
assert(classification.detectProjectTypes(result.files).includes('node'));
|
|
67
|
+
assert(result.files.some((file) => file.path === 'src/index.ts' && file.entrypoint === true));
|
|
68
|
+
assert.equal(result.coverage.inventoryFiles, result.files.length);
|
|
69
|
+
assert.match(result.fingerprint, /^[a-f0-9]{64}$/);
|
|
70
|
+
assert(result.files.some((file) => file.path === 'unknown/service.zig' && file.language === 'unknown'));
|
|
71
|
+
if (symlinkCreated) assert(!result.files.some((file) => file.path.startsWith('outside-link/')));
|
|
72
|
+
await fs.rm(path.join(tmp, 'src', 'race.ts'));
|
|
73
|
+
const changedDuringScan = await extractWorkspaceFiles(config, guard, workspace, result.files);
|
|
74
|
+
assert.equal(changedDuringScan.truncated, true);
|
|
75
|
+
assert(changedDuringScan.warnings.some((warning) => warning.includes('changed or became unreadable')));
|
|
76
|
+
|
|
77
|
+
const analysis = await analysisApi.inspectWorkspace(config, guard, workspace);
|
|
78
|
+
assert(analysis.symbols.some((symbol) => symbol.name === 'authenticate' && symbol.kind === 'function' && symbol.path === 'src/auth.ts'));
|
|
79
|
+
assert(analysis.relationships.some((edge) => edge.from === 'src/index.ts' && edge.to === 'src/auth.ts' && edge.kind === 'imports'));
|
|
80
|
+
assert(analysis.relationships.some((edge) => edge.from === 'packages/web/src/index.ts' && edge.to === 'packages/core/src/index.ts' && edge.kind === 'imports'));
|
|
81
|
+
|
|
82
|
+
const expectedSymbols = [
|
|
83
|
+
['python/service.py', 'load_user'],
|
|
84
|
+
['go/service.go', 'LoadUser'],
|
|
85
|
+
['rust/service.rs', 'load_user'],
|
|
86
|
+
['swift/Service.swift', 'loadUser'],
|
|
87
|
+
['java/Service.java', 'Service'],
|
|
88
|
+
['csharp/Service.cs', 'Service'],
|
|
89
|
+
['c/service.c', 'load_user'],
|
|
90
|
+
['cpp/service.cpp', 'Service']
|
|
91
|
+
];
|
|
92
|
+
for (const [file, name] of expectedSymbols) {
|
|
93
|
+
assert(analysis.symbols.some((symbol) => symbol.path === file && symbol.name === name), `missing ${name} in ${file}`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const structured = await analysisApi.searchWorkspaceStructured(config, guard, workspace, {
|
|
97
|
+
query: 'authenticate',
|
|
98
|
+
intent: 'symbol',
|
|
99
|
+
includeTests: true
|
|
100
|
+
});
|
|
101
|
+
assert.equal(structured.groups.definitions[0]?.path, 'src/auth.ts');
|
|
102
|
+
assert(structured.groups.tests.some((match) => match.path === 'test/auth.test.ts'));
|
|
103
|
+
assert(structured.groups.definitions[0].reasons.includes('symbol definition'));
|
|
104
|
+
const impactSearch = await analysisApi.searchWorkspaceStructured(config, guard, workspace, {
|
|
105
|
+
query: 'authenticate',
|
|
106
|
+
intent: 'impact',
|
|
107
|
+
includeTests: true
|
|
108
|
+
});
|
|
109
|
+
assert(impactSearch.groups.references.some((match) => match.path === 'src/index.ts' && match.reasons.includes('dependent module')));
|
|
110
|
+
assert(impactSearch.groups.tests.some((match) => match.path === 'test/auth.test.ts' && match.reasons.includes('dependent test')));
|
|
111
|
+
|
|
112
|
+
const cached = await analysisApi.inspectWorkspace(config, guard, workspace);
|
|
113
|
+
assert.equal(cached.cache.hit, true);
|
|
114
|
+
await fs.appendFile(path.join(tmp, 'src/auth.ts'), 'export function authorize() { return true; }\n', 'utf8');
|
|
115
|
+
analysisApi.invalidateWorkspaceAnalysis(workspace.id);
|
|
116
|
+
const refreshed = await analysisApi.inspectWorkspace(config, guard, workspace);
|
|
117
|
+
assert.equal(refreshed.cache.hit, false);
|
|
118
|
+
assert(refreshed.symbols.some((symbol) => symbol.name === 'authorize'));
|
|
119
|
+
|
|
120
|
+
const review = await analysisApi.reviewWorkspaceChanges(config, guard, workspace, { changedPaths: ['src/auth.ts'] });
|
|
121
|
+
assert(review.affectedAreas.includes('src'));
|
|
122
|
+
assert(review.dependentFiles.some((file) => file.path === 'src/index.ts'));
|
|
123
|
+
assert(review.relatedTests.some((file) => file.path === 'test/auth.test.ts'));
|
|
124
|
+
assert(review.riskSignals.some((risk) => risk.id === 'authentication'));
|
|
125
|
+
assert(review.recommendedCommands.some((item) => item.command === 'pnpm test' && item.source === 'package.json'));
|
|
126
|
+
assert(review.recommendedCommands.some((item) => item.command === 'go test ./...' && item.source === 'go.mod'));
|
|
127
|
+
|
|
128
|
+
const symbolLimitedConfig = {
|
|
129
|
+
...config,
|
|
130
|
+
analysisLimits: { ...config.analysisLimits, maxSymbols: 2 }
|
|
131
|
+
};
|
|
132
|
+
analysisApi.invalidateWorkspaceAnalysis(workspace.id);
|
|
133
|
+
const symbolLimited = await analysisApi.inspectWorkspace(symbolLimitedConfig, guard, workspace);
|
|
134
|
+
assert.equal(symbolLimited.symbols.length, 2);
|
|
135
|
+
assert.equal(symbolLimited.coverage.truncated, true);
|
|
136
|
+
assert(symbolLimited.warnings.some((warning) => warning.includes('Symbol extraction reached')));
|
|
137
|
+
|
|
138
|
+
const searchLimitedConfig = {
|
|
139
|
+
...config,
|
|
140
|
+
analysisLimits: { ...config.analysisLimits, maxAnalyzedFiles: 1 }
|
|
141
|
+
};
|
|
142
|
+
analysisApi.invalidateWorkspaceAnalysis(workspace.id);
|
|
143
|
+
const searchLimited = await analysisApi.searchWorkspaceStructured(searchLimitedConfig, guard, workspace, {
|
|
144
|
+
query: 'authenticate',
|
|
145
|
+
intent: 'symbol',
|
|
146
|
+
includeTests: true
|
|
147
|
+
});
|
|
148
|
+
assert.equal(searchLimited.coverage.truncated, true);
|
|
149
|
+
assert(searchLimited.warnings.some((warning) => warning.includes('Grouped search reached')));
|
|
150
|
+
|
|
151
|
+
const scoped = await analysisApi.searchWorkspaceStructured(config, guard, workspace, {
|
|
152
|
+
query: 'coreValue',
|
|
153
|
+
intent: 'symbol',
|
|
154
|
+
root: 'src'
|
|
155
|
+
});
|
|
156
|
+
assert.equal(scoped.matches.length, 0);
|
|
157
|
+
|
|
158
|
+
const unsupportedRegex = await analysisApi.searchWorkspaceStructured(config, guard, workspace, {
|
|
159
|
+
query: '(?i)authenticate',
|
|
160
|
+
intent: 'text',
|
|
161
|
+
regex: true
|
|
162
|
+
});
|
|
163
|
+
assert.equal(unsupportedRegex.matches.length, 0);
|
|
164
|
+
assert(unsupportedRegex.warnings.some((warning) => warning.includes('regular expression')));
|
|
165
|
+
|
|
166
|
+
const candidateLimited = await analysisApi.searchWorkspaceStructured(config, guard, workspace, {
|
|
167
|
+
query: 'common marker',
|
|
168
|
+
intent: 'text',
|
|
169
|
+
maxResults: 2
|
|
170
|
+
});
|
|
171
|
+
assert.equal(candidateLimited.matches.length, 2);
|
|
172
|
+
assert.equal(candidateLimited.coverage.truncated, true);
|
|
173
|
+
assert(candidateLimited.warnings.some((warning) => warning.includes('retained the first 8 candidates')));
|
|
174
|
+
|
|
175
|
+
console.log('✓ analysis smoke test passed');
|
|
176
|
+
} finally {
|
|
177
|
+
await fs.rm(tmp, { recursive: true, force: true });
|
|
178
|
+
await fs.rm(outside, { recursive: true, force: true });
|
|
179
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import fsp from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
|
|
6
|
+
function sameIdentity(left, right) {
|
|
7
|
+
return left.dev === right.dev && left.ino === right.ino;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const RENAME_RETRY_CODES = new Set(["EACCES", "EBUSY", "EPERM"]);
|
|
11
|
+
const RENAME_RETRIES = 20;
|
|
12
|
+
const RENAME_RETRY_DELAY_MS = 25;
|
|
13
|
+
const syncWaitBuffer = new Int32Array(new SharedArrayBuffer(4));
|
|
14
|
+
|
|
15
|
+
async function renameAtomic(source, target, rename) {
|
|
16
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
17
|
+
try {
|
|
18
|
+
await rename(source, target);
|
|
19
|
+
return;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (!RENAME_RETRY_CODES.has(error?.code) || attempt >= RENAME_RETRIES) throw error;
|
|
22
|
+
await new Promise((resolve) => setTimeout(resolve, RENAME_RETRY_DELAY_MS));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function renameAtomicSync(source, target, rename) {
|
|
28
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
29
|
+
try {
|
|
30
|
+
rename(source, target);
|
|
31
|
+
return;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
if (!RENAME_RETRY_CODES.has(error?.code) || attempt >= RENAME_RETRIES) throw error;
|
|
34
|
+
Atomics.wait(syncWaitBuffer, 0, 0, RENAME_RETRY_DELAY_MS);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function writeJsonAtomicFileSync(targetPath, value, options = {}) {
|
|
40
|
+
const target = path.resolve(targetPath);
|
|
41
|
+
const temporary = `${target}.${process.pid}.${randomBytes(12).toString("hex")}.tmp`;
|
|
42
|
+
const rename = options.rename ?? fs.renameSync;
|
|
43
|
+
const errors = [];
|
|
44
|
+
let descriptor;
|
|
45
|
+
let temporaryIdentity;
|
|
46
|
+
try {
|
|
47
|
+
descriptor = fs.openSync(temporary, "wx", 0o600);
|
|
48
|
+
temporaryIdentity = fs.fstatSync(descriptor, { bigint: true });
|
|
49
|
+
fs.writeFileSync(descriptor, `${JSON.stringify(value, null, 2)}\n`, "utf8");
|
|
50
|
+
fs.fsyncSync(descriptor);
|
|
51
|
+
fs.closeSync(descriptor);
|
|
52
|
+
descriptor = undefined;
|
|
53
|
+
renameAtomicSync(temporary, target, rename);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
errors.push(error);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (descriptor !== undefined) {
|
|
59
|
+
try {
|
|
60
|
+
fs.closeSync(descriptor);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
errors.push(error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (temporaryIdentity) {
|
|
67
|
+
try {
|
|
68
|
+
const current = fs.lstatSync(temporary, { bigint: true });
|
|
69
|
+
if (
|
|
70
|
+
!current.isFile() ||
|
|
71
|
+
current.isSymbolicLink() ||
|
|
72
|
+
current.nlink !== 1n ||
|
|
73
|
+
!sameIdentity(current, temporaryIdentity)
|
|
74
|
+
) {
|
|
75
|
+
const error = new Error("ATOMIC_TEMP_IDENTITY_CHANGED");
|
|
76
|
+
error.code = "ATOMIC_TEMP_IDENTITY_CHANGED";
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
fs.unlinkSync(temporary);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
if (error?.code !== "ENOENT") errors.push(error);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (errors.length === 1) throw errors[0];
|
|
86
|
+
if (errors.length > 1) throw new AggregateError(errors, "Atomic JSON write and cleanup failed.");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export async function writeJsonAtomicFile(targetPath, value, options = {}) {
|
|
90
|
+
const target = path.resolve(targetPath);
|
|
91
|
+
const temporary = `${target}.${process.pid}.${randomBytes(12).toString("hex")}.tmp`;
|
|
92
|
+
const rename = options.rename ?? fsp.rename;
|
|
93
|
+
const errors = [];
|
|
94
|
+
let handle;
|
|
95
|
+
let temporaryIdentity;
|
|
96
|
+
try {
|
|
97
|
+
handle = await fsp.open(temporary, "wx", 0o600);
|
|
98
|
+
temporaryIdentity = await handle.stat({ bigint: true });
|
|
99
|
+
await handle.writeFile(`${JSON.stringify(value, null, 2)}\n`, "utf8");
|
|
100
|
+
await handle.sync();
|
|
101
|
+
await handle.close();
|
|
102
|
+
handle = undefined;
|
|
103
|
+
await renameAtomic(temporary, target, rename);
|
|
104
|
+
} catch (error) {
|
|
105
|
+
errors.push(error);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (handle) {
|
|
109
|
+
try {
|
|
110
|
+
await handle.close();
|
|
111
|
+
} catch (error) {
|
|
112
|
+
errors.push(error);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (temporaryIdentity) {
|
|
117
|
+
try {
|
|
118
|
+
const current = await fsp.lstat(temporary, { bigint: true });
|
|
119
|
+
if (
|
|
120
|
+
!current.isFile() ||
|
|
121
|
+
current.isSymbolicLink() ||
|
|
122
|
+
current.nlink !== 1n ||
|
|
123
|
+
!sameIdentity(current, temporaryIdentity)
|
|
124
|
+
) {
|
|
125
|
+
const error = new Error("ATOMIC_TEMP_IDENTITY_CHANGED");
|
|
126
|
+
error.code = "ATOMIC_TEMP_IDENTITY_CHANGED";
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
await fsp.unlink(temporary);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
if (error?.code !== "ENOENT") errors.push(error);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (errors.length === 1) throw errors[0];
|
|
136
|
+
if (errors.length > 1) throw new AggregateError(errors, "Atomic JSON write and cleanup failed.");
|
|
137
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import fsp from "node:fs/promises";
|
|
4
|
+
|
|
5
|
+
const argv = process.argv.slice(2);
|
|
6
|
+
function option(name) {
|
|
7
|
+
const index = argv.indexOf(name);
|
|
8
|
+
return index === -1 ? undefined : argv[index + 1];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const base = option("--base");
|
|
12
|
+
const head = option("--head") ?? "HEAD";
|
|
13
|
+
const output = option("--output") ?? process.env.GITHUB_OUTPUT;
|
|
14
|
+
const zeroSha = /^0{40}$/;
|
|
15
|
+
|
|
16
|
+
function git(args) {
|
|
17
|
+
const result = spawnSync("git", args, { encoding: "utf8", windowsHide: true, maxBuffer: 2 * 1024 * 1024 });
|
|
18
|
+
if (result.status !== 0) throw new Error(result.stderr || `git ${args.join(" ")} failed`);
|
|
19
|
+
return result.stdout;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function isDocsOnlyPath(file) {
|
|
23
|
+
return file === "AGENTS.md" ||
|
|
24
|
+
file === "Memory.md" ||
|
|
25
|
+
file === "CHANGELOG.md" ||
|
|
26
|
+
file === "CONTRIBUTING.md" ||
|
|
27
|
+
file === "FAQ.md" ||
|
|
28
|
+
file === "FAQ_ZH.md" ||
|
|
29
|
+
file === "README.md" ||
|
|
30
|
+
file === "README_ZH.md" ||
|
|
31
|
+
file === "SECURITY.md" ||
|
|
32
|
+
file === "DOMAIN_SETUP.md" ||
|
|
33
|
+
file === "PUBLIC_LAUNCH_CHECKLIST.md" ||
|
|
34
|
+
file.startsWith("docs/") ||
|
|
35
|
+
file.endsWith(".md");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let files;
|
|
39
|
+
if (!base || zeroSha.test(base)) {
|
|
40
|
+
files = git(["diff-tree", "--no-commit-id", "--name-only", "-r", head]).split(/\r?\n/).filter(Boolean);
|
|
41
|
+
if (files.length === 0) files = git(["ls-tree", "-r", "--name-only", head]).split(/\r?\n/).filter(Boolean);
|
|
42
|
+
} else {
|
|
43
|
+
files = git(["diff", "--name-only", `${base}...${head}`]).split(/\r?\n/).filter(Boolean);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const docsOnly = files.length > 0 && files.every(isDocsOnlyPath);
|
|
47
|
+
const facts = {
|
|
48
|
+
changed_files: files.length,
|
|
49
|
+
docs_only: docsOnly,
|
|
50
|
+
runtime: !docsOnly,
|
|
51
|
+
files
|
|
52
|
+
};
|
|
53
|
+
const lines = [
|
|
54
|
+
`changed_files=${facts.changed_files}`,
|
|
55
|
+
`docs_only=${facts.docs_only}`,
|
|
56
|
+
`runtime=${facts.runtime}`
|
|
57
|
+
].join("\n") + "\n";
|
|
58
|
+
if (output) await fsp.appendFile(output, lines, "utf8");
|
|
59
|
+
process.stdout.write(`${JSON.stringify(facts, null, 2)}\n`);
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
3
|
+
import { createBoundedCliEnvironment } from "../dist/cliEnvironment.js";
|
|
4
|
+
|
|
5
|
+
const argv = process.argv.slice(2);
|
|
6
|
+
function option(name) {
|
|
7
|
+
const index = argv.indexOf(name);
|
|
8
|
+
return index === -1 ? undefined : argv[index + 1];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const runId = option("--run");
|
|
12
|
+
const maxLines = Number(option("--max-lines") ?? 220);
|
|
13
|
+
const contextLines = Number(option("--context") ?? 2);
|
|
14
|
+
if (!/^\d+$/.test(runId ?? "")) {
|
|
15
|
+
console.error("Usage: npm run ci:failure-summary -- --run <run-id> [--max-lines 220] [--context 2]");
|
|
16
|
+
process.exit(2);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const match = /(?:\bnot ok\b|AssertionError|ERR_ASSERTION|\bactual\s*:|\bexpected\s*:|\boperator\s*:|\berror\s*:|npm ERR!|ELIFECYCLE|Process completed with exit code|Caused by:|UnhandledPromiseRejection|\bSIG(?:TERM|KILL|INT)\b)/i;
|
|
20
|
+
const child = spawn("gh", ["run", "view", runId, "--log-failed"], {
|
|
21
|
+
cwd: process.cwd(),
|
|
22
|
+
env: createBoundedCliEnvironment({ includeCi: false }),
|
|
23
|
+
shell: false,
|
|
24
|
+
windowsHide: true,
|
|
25
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const selected = [];
|
|
29
|
+
const selectedSet = new Set();
|
|
30
|
+
const recent = [];
|
|
31
|
+
let pendingContext = 0;
|
|
32
|
+
let buffer = "";
|
|
33
|
+
let stderr = "";
|
|
34
|
+
let dropped = 0;
|
|
35
|
+
|
|
36
|
+
function add(line) {
|
|
37
|
+
if (selectedSet.has(line)) return;
|
|
38
|
+
if (selected.length >= maxLines) {
|
|
39
|
+
dropped += 1;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
selectedSet.add(line);
|
|
43
|
+
selected.push(line);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function consumeLine(line) {
|
|
47
|
+
recent.push(line);
|
|
48
|
+
if (recent.length > contextLines + 1) recent.shift();
|
|
49
|
+
if (match.test(line)) {
|
|
50
|
+
for (const prior of recent) add(prior);
|
|
51
|
+
pendingContext = contextLines;
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (pendingContext > 0) {
|
|
55
|
+
add(line);
|
|
56
|
+
pendingContext -= 1;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
child.stdout.on("data", (chunk) => {
|
|
61
|
+
buffer += chunk.toString("utf8");
|
|
62
|
+
const lines = buffer.split(/\r?\n/);
|
|
63
|
+
buffer = lines.pop() ?? "";
|
|
64
|
+
for (const line of lines) consumeLine(line);
|
|
65
|
+
});
|
|
66
|
+
child.stderr.on("data", (chunk) => {
|
|
67
|
+
stderr += chunk.toString("utf8");
|
|
68
|
+
if (stderr.length > 32_000) stderr = stderr.slice(-32_000);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const exitCode = await new Promise((resolve) => {
|
|
72
|
+
child.once("error", (error) => {
|
|
73
|
+
stderr += `\n${error.stack ?? error.message}`;
|
|
74
|
+
resolve(127);
|
|
75
|
+
});
|
|
76
|
+
child.once("close", (code) => resolve(code ?? 1));
|
|
77
|
+
});
|
|
78
|
+
if (buffer) consumeLine(buffer);
|
|
79
|
+
|
|
80
|
+
if (exitCode !== 0) {
|
|
81
|
+
console.error(`gh run view ${runId} --log-failed exited ${exitCode}.`);
|
|
82
|
+
console.error(stderr.trim());
|
|
83
|
+
process.exit(exitCode);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (selected.length === 0) {
|
|
87
|
+
console.log(`Run ${runId}: no matching assertion/error lines were found in failed-step logs.`);
|
|
88
|
+
} else {
|
|
89
|
+
console.log(`# Compact failure summary for run ${runId}`);
|
|
90
|
+
console.log(selected.join("\n"));
|
|
91
|
+
if (dropped > 0) console.log(`\n[${dropped} additional matching/context lines omitted by --max-lines]`);
|
|
92
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import os from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { pathToFileURL } from "node:url";
|
|
7
|
+
import {
|
|
8
|
+
CLOUDFLARED_RELEASE,
|
|
9
|
+
cloudflaredAsset,
|
|
10
|
+
cloudflaredReleaseUrl
|
|
11
|
+
} from "./cloudflared-release.mjs";
|
|
12
|
+
import { createOwnedTempRootSync } from "./owned-temp-root.mjs";
|
|
13
|
+
|
|
14
|
+
const MAX_DOWNLOAD_BYTES = 100 * 1024 * 1024;
|
|
15
|
+
|
|
16
|
+
export function cloudflaredTunnelArgs(...args) {
|
|
17
|
+
return ["tunnel", "--no-autoupdate", ...args];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function sha256Buffer(buffer) {
|
|
21
|
+
return createHash("sha256").update(buffer).digest("hex");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function assertSha256(buffer, expected, label = "download") {
|
|
25
|
+
const actual = sha256Buffer(buffer);
|
|
26
|
+
if (actual !== expected.toLowerCase()) {
|
|
27
|
+
throw new Error(`SHA-256 verification failed for ${label}. Expected ${expected}, received ${actual}.`);
|
|
28
|
+
}
|
|
29
|
+
return actual;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function CodexGPTHome() {
|
|
33
|
+
const configured = process.env.CODEXGPT_HOME?.trim();
|
|
34
|
+
return configured ? path.resolve(configured) : path.join(os.homedir(), ".codexgpt");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function binaryName() {
|
|
38
|
+
return process.platform === "win32" ? "cloudflared.exe" : "cloudflared";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function managedCloudflaredInstallPath() {
|
|
42
|
+
return path.join(CodexGPTHome(), "bin", binaryName());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function findFile(root, fileName) {
|
|
46
|
+
for (const entry of fs.readdirSync(root, { withFileTypes: true })) {
|
|
47
|
+
const fullPath = path.join(root, entry.name);
|
|
48
|
+
if (entry.isFile() && entry.name === fileName) return fullPath;
|
|
49
|
+
if (entry.isDirectory()) {
|
|
50
|
+
const nested = findFile(fullPath, fileName);
|
|
51
|
+
if (nested) return nested;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return "";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function cloudflaredVersion(binaryPath) {
|
|
58
|
+
const result = spawnSync(binaryPath, ["--version"], {
|
|
59
|
+
encoding: "utf8",
|
|
60
|
+
shell: false,
|
|
61
|
+
timeout: 15000,
|
|
62
|
+
windowsHide: true
|
|
63
|
+
});
|
|
64
|
+
if (result.error || result.status !== 0) return "";
|
|
65
|
+
return `${result.stdout ?? ""}${result.stderr ?? ""}`.trim();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function verifiedInstalledCloudflaredVersion(binaryPath) {
|
|
69
|
+
if (!fs.existsSync(binaryPath)) return "";
|
|
70
|
+
const asset = cloudflaredAsset();
|
|
71
|
+
if (!asset.archive) {
|
|
72
|
+
const stat = fs.statSync(binaryPath);
|
|
73
|
+
if (!stat.isFile() || stat.size > MAX_DOWNLOAD_BYTES) return "";
|
|
74
|
+
const installedDigest = sha256Buffer(fs.readFileSync(binaryPath));
|
|
75
|
+
if (installedDigest !== asset.sha256) return "";
|
|
76
|
+
}
|
|
77
|
+
const output = cloudflaredVersion(binaryPath);
|
|
78
|
+
return output.includes(CLOUDFLARED_RELEASE.version) ? output : "";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async function downloadVerifiedAsset(asset, tempRoot) {
|
|
82
|
+
const url = cloudflaredReleaseUrl(asset);
|
|
83
|
+
console.error(`[codexgpt] Downloading pinned cloudflared ${CLOUDFLARED_RELEASE.version}: ${asset.file}`);
|
|
84
|
+
const response = await fetch(url, { headers: { "user-agent": "codexgpt-verified-installer" } });
|
|
85
|
+
if (!response.ok) {
|
|
86
|
+
throw new Error(`Failed to download ${url}: ${response.status} ${response.statusText}`);
|
|
87
|
+
}
|
|
88
|
+
const contentLength = Number(response.headers.get("content-length") ?? 0);
|
|
89
|
+
if (Number.isFinite(contentLength) && contentLength > MAX_DOWNLOAD_BYTES) {
|
|
90
|
+
throw new Error(`Refusing cloudflared download larger than ${MAX_DOWNLOAD_BYTES} bytes.`);
|
|
91
|
+
}
|
|
92
|
+
if (!response.body) throw new Error(`Cloudflared download returned no response body: ${url}`);
|
|
93
|
+
const chunks = [];
|
|
94
|
+
let receivedBytes = 0;
|
|
95
|
+
for await (const chunk of response.body) {
|
|
96
|
+
const bufferChunk = Buffer.from(chunk);
|
|
97
|
+
receivedBytes += bufferChunk.byteLength;
|
|
98
|
+
if (receivedBytes > MAX_DOWNLOAD_BYTES) {
|
|
99
|
+
throw new Error(`Refusing cloudflared download larger than ${MAX_DOWNLOAD_BYTES} bytes.`);
|
|
100
|
+
}
|
|
101
|
+
chunks.push(bufferChunk);
|
|
102
|
+
}
|
|
103
|
+
const buffer = Buffer.concat(chunks, receivedBytes);
|
|
104
|
+
const digest = assertSha256(buffer, asset.sha256, asset.file);
|
|
105
|
+
const downloadedPath = path.join(tempRoot, asset.file);
|
|
106
|
+
fs.writeFileSync(downloadedPath, buffer, { mode: 0o700 });
|
|
107
|
+
console.error(`[codexgpt] Verified SHA-256: ${digest}`);
|
|
108
|
+
return downloadedPath;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function extractExecutable(asset, downloadedPath, tempRoot) {
|
|
112
|
+
if (!asset.archive) return downloadedPath;
|
|
113
|
+
const extractDir = path.join(tempRoot, "extract");
|
|
114
|
+
fs.mkdirSync(extractDir, { recursive: true });
|
|
115
|
+
const result = spawnSync("tar", ["-xzf", downloadedPath, "-C", extractDir], {
|
|
116
|
+
encoding: "utf8",
|
|
117
|
+
shell: false,
|
|
118
|
+
windowsHide: true
|
|
119
|
+
});
|
|
120
|
+
if (result.error || result.status !== 0) {
|
|
121
|
+
throw new Error(`Failed to extract ${asset.file}: ${result.stderr || result.stdout || result.error?.message || result.status}`);
|
|
122
|
+
}
|
|
123
|
+
const extracted = findFile(extractDir, "cloudflared");
|
|
124
|
+
if (!extracted) throw new Error(`Could not find cloudflared inside ${asset.file}.`);
|
|
125
|
+
return extracted;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function replaceInstalledBinary(sourcePath, destination) {
|
|
129
|
+
const binDir = path.dirname(destination);
|
|
130
|
+
fs.mkdirSync(binDir, { recursive: true, mode: 0o700 });
|
|
131
|
+
const staged = path.join(binDir, `.${process.pid}.new-${binaryName()}`);
|
|
132
|
+
const backup = path.join(binDir, `.backup-${binaryName()}`);
|
|
133
|
+
fs.rmSync(staged, { force: true });
|
|
134
|
+
fs.copyFileSync(sourcePath, staged);
|
|
135
|
+
if (process.platform !== "win32") fs.chmodSync(staged, 0o755);
|
|
136
|
+
|
|
137
|
+
const versionOutput = cloudflaredVersion(staged);
|
|
138
|
+
if (!versionOutput.includes(CLOUDFLARED_RELEASE.version)) {
|
|
139
|
+
fs.rmSync(staged, { force: true });
|
|
140
|
+
throw new Error(
|
|
141
|
+
`Verified file did not report cloudflared ${CLOUDFLARED_RELEASE.version}. ` +
|
|
142
|
+
`Reported: ${versionOutput || "no version output"}`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
fs.rmSync(backup, { force: true });
|
|
147
|
+
const hadExisting = fs.existsSync(destination);
|
|
148
|
+
try {
|
|
149
|
+
if (hadExisting) fs.renameSync(destination, backup);
|
|
150
|
+
fs.renameSync(staged, destination);
|
|
151
|
+
fs.rmSync(backup, { force: true });
|
|
152
|
+
} catch (error) {
|
|
153
|
+
fs.rmSync(staged, { force: true });
|
|
154
|
+
if (hadExisting && fs.existsSync(backup) && !fs.existsSync(destination)) {
|
|
155
|
+
fs.renameSync(backup, destination);
|
|
156
|
+
}
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
return versionOutput;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export async function installVerifiedCloudflared({ ensureOnly = false } = {}) {
|
|
163
|
+
const destination = managedCloudflaredInstallPath();
|
|
164
|
+
const installed = verifiedInstalledCloudflaredVersion(destination);
|
|
165
|
+
if (installed && ensureOnly) {
|
|
166
|
+
console.error(`[codexgpt] Verified cloudflared already installed: ${installed}`);
|
|
167
|
+
return destination;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const asset = cloudflaredAsset();
|
|
171
|
+
const ownedTemp = createOwnedTempRootSync("cloudflared-install");
|
|
172
|
+
const tempRoot = ownedTemp.path;
|
|
173
|
+
try {
|
|
174
|
+
const downloaded = await downloadVerifiedAsset(asset, tempRoot);
|
|
175
|
+
const executable = extractExecutable(asset, downloaded, tempRoot);
|
|
176
|
+
const versionOutput = replaceInstalledBinary(executable, destination);
|
|
177
|
+
console.error(`[codexgpt] Installed verified cloudflared: ${versionOutput}`);
|
|
178
|
+
console.error(`[codexgpt] Path: ${destination}`);
|
|
179
|
+
return destination;
|
|
180
|
+
} finally {
|
|
181
|
+
ownedTemp.cleanupSync();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async function main() {
|
|
186
|
+
const command = process.argv[2] || "ensure";
|
|
187
|
+
if (command === "status") {
|
|
188
|
+
const destination = managedCloudflaredInstallPath();
|
|
189
|
+
const installed = verifiedInstalledCloudflaredVersion(destination);
|
|
190
|
+
if (!installed) {
|
|
191
|
+
console.error(`[codexgpt] Pinned cloudflared ${CLOUDFLARED_RELEASE.version} is not installed at ${destination}.`);
|
|
192
|
+
process.exitCode = 1;
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
console.log(installed);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
if (command === "ensure") {
|
|
199
|
+
await installVerifiedCloudflared({ ensureOnly: true });
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (command === "install" || command === "upgrade") {
|
|
203
|
+
await installVerifiedCloudflared({ ensureOnly: false });
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
throw new Error("Usage: node scripts/cloudflared-installer.mjs [ensure|install|upgrade|status]");
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const isMain = process.argv[1] && import.meta.url === pathToFileURL(path.resolve(process.argv[1])).href;
|
|
210
|
+
if (isMain) {
|
|
211
|
+
main().catch((error) => {
|
|
212
|
+
console.error(`[codexgpt] ${error instanceof Error ? error.message : String(error)}`);
|
|
213
|
+
process.exitCode = 1;
|
|
214
|
+
});
|
|
215
|
+
}
|