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,924 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import fsp from "node:fs/promises";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { readTextFile, repoTree, ensureAiBridge } from "./fsOps.js";
|
|
6
|
+
import { gitDiff, gitLog, gitStatus } from "./gitOps.js";
|
|
7
|
+
import { discoverSkillInventory } from "./capabilitiesOps.js";
|
|
8
|
+
import { READ_HANDOFF_ARTIFACT_DEFINITIONS, readHandoffLineCount } from "./tools/schemas/readHandoff.js";
|
|
9
|
+
import { WAIT_FOR_HANDOFF_ARTIFACT_DEFINITIONS, waitForHandoffLineCount } from "./tools/schemas/waitForHandoff.js";
|
|
10
|
+
import { discoverInstructions } from "./guidance/instructions.js";
|
|
11
|
+
import { discoverExplicitGlobalSkills, discoverTargetSkills } from "./guidance/skillDiscovery.js";
|
|
12
|
+
import { buildSkillCatalog } from "./guidance/skillCatalog.js";
|
|
13
|
+
import { redactSensitiveText } from "./redact.js";
|
|
14
|
+
function unique(values) {
|
|
15
|
+
return [...new Set(values.filter(Boolean))];
|
|
16
|
+
}
|
|
17
|
+
async function safeReaddir(dir) {
|
|
18
|
+
try {
|
|
19
|
+
return await fsp.readdir(dir, { withFileTypes: true });
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export async function discoverSkills(workspace, options = {}) {
|
|
26
|
+
const candidateDirs = unique([
|
|
27
|
+
path.join(workspace.root, ".codex", "skills"),
|
|
28
|
+
path.join(workspace.root, "skills"),
|
|
29
|
+
...(options.includeGlobal
|
|
30
|
+
? [path.join(os.homedir(), ".codex", "skills"), path.join(os.homedir(), ".chatgpt", "skills")]
|
|
31
|
+
: [])
|
|
32
|
+
]);
|
|
33
|
+
const skills = [];
|
|
34
|
+
for (const dir of candidateDirs) {
|
|
35
|
+
const entries = await safeReaddir(dir);
|
|
36
|
+
for (const entry of entries) {
|
|
37
|
+
if (entry.isDirectory())
|
|
38
|
+
skills.push(entry.name);
|
|
39
|
+
else if (entry.isFile() && entry.name.endsWith(".md"))
|
|
40
|
+
skills.push(entry.name.replace(/\.md$/, ""));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return unique(skills).sort((a, b) => a.localeCompare(b));
|
|
44
|
+
}
|
|
45
|
+
function skillCounts(skills) {
|
|
46
|
+
const counts = { total: skills.length, workspace: 0, user: 0, plugin: 0, other: 0 };
|
|
47
|
+
for (const skill of skills) {
|
|
48
|
+
const source = skill.source ?? "other";
|
|
49
|
+
counts[source] = (counts[source] ?? 0) + 1;
|
|
50
|
+
}
|
|
51
|
+
return counts;
|
|
52
|
+
}
|
|
53
|
+
async function findAgentsFile(workspace) {
|
|
54
|
+
const [first] = await findAgentsFilesInDir(workspace, ".");
|
|
55
|
+
return first;
|
|
56
|
+
}
|
|
57
|
+
function candidateAgentDirs(targetPath) {
|
|
58
|
+
const normalized = targetPath.split(path.sep).join("/").replace(/^\.\//, "");
|
|
59
|
+
const parts = normalized && normalized !== "." ? normalized.split("/").filter(Boolean) : [];
|
|
60
|
+
const dirs = [""];
|
|
61
|
+
const directoryParts = parts.length > 0 && parts.at(-1)?.includes(".") ? parts.slice(0, -1) : parts;
|
|
62
|
+
for (let i = 0; i < directoryParts.length; i += 1) {
|
|
63
|
+
dirs.push(directoryParts.slice(0, i + 1).join("/"));
|
|
64
|
+
}
|
|
65
|
+
return [...new Set(dirs)];
|
|
66
|
+
}
|
|
67
|
+
async function findAgentsFilesInDir(workspace, dir) {
|
|
68
|
+
const names = ["AGENTS.override.md", "AGENTS.md", "agents.md", ".agents.md"];
|
|
69
|
+
const absDir = path.join(workspace.root, dir);
|
|
70
|
+
const entries = await safeReaddir(absDir);
|
|
71
|
+
const files = entries.filter((entry) => entry.isFile());
|
|
72
|
+
const out = [];
|
|
73
|
+
const seen = new Set();
|
|
74
|
+
for (const name of names) {
|
|
75
|
+
const entry = files.find((item) => item.name === name) ??
|
|
76
|
+
files.find((item) => item.name.toLowerCase() === name.toLowerCase());
|
|
77
|
+
if (!entry)
|
|
78
|
+
continue;
|
|
79
|
+
const rel = dir && dir !== "." ? `${dir}/${entry.name}` : entry.name;
|
|
80
|
+
const real = fs.realpathSync(path.join(workspace.root, rel)).toLowerCase();
|
|
81
|
+
if (seen.has(real))
|
|
82
|
+
continue;
|
|
83
|
+
seen.add(real);
|
|
84
|
+
out.push(rel);
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
async function readAgentsChain(config, guard, workspace, targetPath, maxBytes) {
|
|
89
|
+
const chunks = [];
|
|
90
|
+
const files = [];
|
|
91
|
+
const seenRealPaths = new Set();
|
|
92
|
+
const candidates = (await Promise.all(candidateAgentDirs(targetPath).map((dir) => findAgentsFilesInDir(workspace, dir || ".")))).flat();
|
|
93
|
+
for (const rel of candidates) {
|
|
94
|
+
try {
|
|
95
|
+
const resolved = guard.resolve(workspace, rel);
|
|
96
|
+
if (!fs.existsSync(resolved.absPath))
|
|
97
|
+
continue;
|
|
98
|
+
const real = fs.realpathSync(resolved.absPath).toLowerCase();
|
|
99
|
+
if (seenRealPaths.has(real))
|
|
100
|
+
continue;
|
|
101
|
+
seenRealPaths.add(real);
|
|
102
|
+
const agents = await readTextFile(config, guard, workspace, rel, { maxBytes });
|
|
103
|
+
chunks.push(`--- ${rel} ---\n${agents.text}`);
|
|
104
|
+
files.push(rel);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
chunks.push(`--- ${rel} ---\n[unreadable: ${error instanceof Error ? error.message : String(error)}]`);
|
|
108
|
+
files.push(rel);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
text: chunks.length ? chunks.join("\n\n") : "No AGENTS.md-style instruction files found for this target path.",
|
|
113
|
+
files
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export async function workspaceSummary(config, guard, workspace, options = {}) {
|
|
117
|
+
if (options.bootstrapContext) {
|
|
118
|
+
await ensureAiBridge(config, guard, workspace);
|
|
119
|
+
}
|
|
120
|
+
const standardMode = (config.guidanceMode ?? "legacy") === "standard";
|
|
121
|
+
const standardInstructions = standardMode
|
|
122
|
+
? await discoverInstructions({
|
|
123
|
+
root: workspace.root,
|
|
124
|
+
targetPath: ".",
|
|
125
|
+
fallbackNames: config.instructionFallbacks?.length ? config.instructionFallbacks : undefined,
|
|
126
|
+
maxFileBytes: Math.min(60_000, config.maxReadBytes),
|
|
127
|
+
maxTotalBytes: config.maxInstructionTotalBytes ?? 32_768,
|
|
128
|
+
blockedGlobs: config.blockedGlobs
|
|
129
|
+
})
|
|
130
|
+
: null;
|
|
131
|
+
const standardSkillDiscovery = standardMode
|
|
132
|
+
? await (async () => {
|
|
133
|
+
const workspaceSkills = await discoverTargetSkills({
|
|
134
|
+
root: workspace.root,
|
|
135
|
+
targetPath: ".",
|
|
136
|
+
maxCandidates: config.maxSkillCandidates ?? 1_000,
|
|
137
|
+
maxSkills: 120,
|
|
138
|
+
blockedGlobs: config.blockedGlobs
|
|
139
|
+
});
|
|
140
|
+
if (!options.includeGlobalSkills)
|
|
141
|
+
return workspaceSkills;
|
|
142
|
+
const remainingCandidates = (config.maxSkillCandidates ?? 1_000) - workspaceSkills.candidateCount;
|
|
143
|
+
if (remainingCandidates <= 0) {
|
|
144
|
+
return {
|
|
145
|
+
...workspaceSkills,
|
|
146
|
+
scanComplete: false,
|
|
147
|
+
scanTruncated: true,
|
|
148
|
+
diagnostics: workspaceSkills.diagnostics.some((item) => item.code === "SKILL_SCAN_TRUNCATED")
|
|
149
|
+
? workspaceSkills.diagnostics
|
|
150
|
+
: [
|
|
151
|
+
...workspaceSkills.diagnostics,
|
|
152
|
+
{
|
|
153
|
+
status: "warning",
|
|
154
|
+
code: "SKILL_SCAN_TRUNCATED",
|
|
155
|
+
path: null,
|
|
156
|
+
count: 1,
|
|
157
|
+
action: "Reduce Skill candidates or raise the bounded candidate limit."
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const globalSkills = await discoverExplicitGlobalSkills({
|
|
163
|
+
codexDir: config.codexDir,
|
|
164
|
+
maxCandidates: remainingCandidates,
|
|
165
|
+
maxSkills: 120,
|
|
166
|
+
blockedGlobs: config.blockedGlobs
|
|
167
|
+
});
|
|
168
|
+
return mergeSkillDiscovery(workspaceSkills, globalSkills, 120);
|
|
169
|
+
})()
|
|
170
|
+
: null;
|
|
171
|
+
const standardCatalog = standardSkillDiscovery
|
|
172
|
+
? buildSkillCatalog(standardSkillDiscovery.skills, config.maxSkillCatalogChars ?? 8_000)
|
|
173
|
+
: null;
|
|
174
|
+
const skillInventory = standardCatalog
|
|
175
|
+
? standardCatalog.entries.map((skill) => ({
|
|
176
|
+
name: skill.name,
|
|
177
|
+
description: skill.description,
|
|
178
|
+
source: skill.source,
|
|
179
|
+
path: skill.path
|
|
180
|
+
}))
|
|
181
|
+
: options.includeSkills
|
|
182
|
+
? await discoverSkillInventory(workspace, { includeGlobal: options.includeGlobalSkills !== false, maxSkills: 120 })
|
|
183
|
+
: [];
|
|
184
|
+
const skills = skillInventory.map((skill) => skill.name);
|
|
185
|
+
const counts = skillCounts(skillInventory);
|
|
186
|
+
const agentsPath = standardInstructions?.files[0]?.path ?? await findAgentsFile(workspace);
|
|
187
|
+
let agentsText = "AGENTS.md: none loaded";
|
|
188
|
+
if (standardInstructions?.files.length) {
|
|
189
|
+
agentsText = [
|
|
190
|
+
"## Project Instructions",
|
|
191
|
+
...standardInstructions.files.map((file) => `--- ${file.path} ---\n${file.text}`)
|
|
192
|
+
].join("\n\n");
|
|
193
|
+
}
|
|
194
|
+
else if (agentsPath) {
|
|
195
|
+
agentsText = `AGENTS.md: ${agentsPath} (read this file before editing or making project decisions).`;
|
|
196
|
+
}
|
|
197
|
+
let treeText;
|
|
198
|
+
if (options.includeTree !== false) {
|
|
199
|
+
const tree = await repoTree(config, guard, workspace, {
|
|
200
|
+
path: ".",
|
|
201
|
+
maxDepth: Math.max(1, Math.min(options.maxDepth ?? 3, 8)),
|
|
202
|
+
includeHidden: false,
|
|
203
|
+
maxEntries: Math.max(1, Math.min(options.maxEntries ?? 500, 3000))
|
|
204
|
+
});
|
|
205
|
+
treeText = tree.text;
|
|
206
|
+
}
|
|
207
|
+
const status = options.gitStatusProvider
|
|
208
|
+
? await options.gitStatusProvider()
|
|
209
|
+
: gitStatus(config, workspace);
|
|
210
|
+
const log = options.gitLogProvider
|
|
211
|
+
? await options.gitLogProvider()
|
|
212
|
+
: gitLog(config, workspace, 5);
|
|
213
|
+
const skillText = standardCatalog
|
|
214
|
+
? `Skills: ${standardCatalog.entries.length} implicit-ready entries (${standardSkillDiscovery.validCount} valid; ${standardSkillDiscovery.invalidCount} invalid).\n${standardCatalog.serialized}`
|
|
215
|
+
: options.includeSkills
|
|
216
|
+
? `Skills: ${counts.total} total (${counts.workspace ?? 0} workspace, ${counts.user ?? 0} user, ${counts.plugin ?? 0} plugin, ${counts.other ?? 0} other).`
|
|
217
|
+
: "Skills: skipped. Pass include_skills=true if skill discovery is needed.";
|
|
218
|
+
const text = `# Workspace\n\nWorkspace: ${workspace.id}\nRoot: ${workspace.root}\nBash mode: ${config.bashMode}\nWrite mode: ${config.writeMode}\nTool mode: ${config.toolMode}\n\n${agentsText}\n${skillText}\n\n## Git status\n\n${status}\n\n## Recent commits\n\n${log}\n${treeText ? `\n## Files\n\n${treeText}` : ""}`;
|
|
219
|
+
return {
|
|
220
|
+
text,
|
|
221
|
+
workspaceId: workspace.id,
|
|
222
|
+
root: workspace.root,
|
|
223
|
+
agentsLoaded: Boolean(agentsPath),
|
|
224
|
+
agentsPath,
|
|
225
|
+
skills,
|
|
226
|
+
skillInventory,
|
|
227
|
+
skillCounts: counts,
|
|
228
|
+
tree: treeText,
|
|
229
|
+
gitStatus: status,
|
|
230
|
+
...(standardInstructions && standardSkillDiscovery && standardCatalog
|
|
231
|
+
? {
|
|
232
|
+
standardGuidance: {
|
|
233
|
+
status: guidanceDiagnostics(standardInstructions.diagnostics, standardSkillDiscovery, standardCatalog).length ? "warning" : "ok",
|
|
234
|
+
instructionChain: standardInstructions.files,
|
|
235
|
+
instructionDiagnostics: guidanceDiagnostics(standardInstructions.diagnostics, standardSkillDiscovery, standardCatalog),
|
|
236
|
+
skillCatalog: standardCatalog.entries,
|
|
237
|
+
skillScan: {
|
|
238
|
+
candidateCount: standardSkillDiscovery.candidateCount,
|
|
239
|
+
validCount: standardSkillDiscovery.validCount,
|
|
240
|
+
invalidCount: standardSkillDiscovery.invalidCount,
|
|
241
|
+
scanComplete: standardSkillDiscovery.scanComplete,
|
|
242
|
+
scanTruncated: standardSkillDiscovery.scanTruncated,
|
|
243
|
+
returnedTruncated: standardSkillDiscovery.returnedTruncated,
|
|
244
|
+
catalogComplete: standardCatalog.catalogComplete,
|
|
245
|
+
catalogOmittedCount: standardCatalog.catalogOmittedCount,
|
|
246
|
+
descriptionsShortened: standardCatalog.descriptionsShortened,
|
|
247
|
+
catalogChars: standardCatalog.characterCount,
|
|
248
|
+
ineligibleCount: standardCatalog.ineligibleCount
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
: {})
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
function mergeSkillDiscovery(primary, secondary, maxSkills) {
|
|
256
|
+
const allSkills = [...primary.skills, ...secondary.skills];
|
|
257
|
+
const returnedTruncated = primary.returnedTruncated || secondary.returnedTruncated || allSkills.length > maxSkills;
|
|
258
|
+
return {
|
|
259
|
+
skills: allSkills.slice(0, maxSkills),
|
|
260
|
+
candidateCount: primary.candidateCount + secondary.candidateCount,
|
|
261
|
+
validCount: primary.validCount + secondary.validCount,
|
|
262
|
+
invalidCount: primary.invalidCount + secondary.invalidCount,
|
|
263
|
+
scanComplete: primary.scanComplete && secondary.scanComplete,
|
|
264
|
+
scanTruncated: primary.scanTruncated || secondary.scanTruncated,
|
|
265
|
+
returnedTruncated,
|
|
266
|
+
diagnostics: [
|
|
267
|
+
...primary.diagnostics,
|
|
268
|
+
...secondary.diagnostics,
|
|
269
|
+
...(allSkills.length > maxSkills ? [{
|
|
270
|
+
status: "warning",
|
|
271
|
+
code: "SKILL_RESULTS_TRUNCATED",
|
|
272
|
+
path: null,
|
|
273
|
+
count: allSkills.length - maxSkills,
|
|
274
|
+
action: "Use a narrower target or raise the bounded returned-Skill limit."
|
|
275
|
+
}] : [])
|
|
276
|
+
]
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
function guidanceDiagnostics(instructions, discovery, catalog) {
|
|
280
|
+
return [
|
|
281
|
+
...instructions,
|
|
282
|
+
...discovery.diagnostics,
|
|
283
|
+
...(catalog.catalogOmittedCount > 0 ? [{
|
|
284
|
+
status: "warning",
|
|
285
|
+
code: "SKILL_CATALOG_TRUNCATED",
|
|
286
|
+
path: null,
|
|
287
|
+
count: catalog.catalogOmittedCount,
|
|
288
|
+
action: "Use a narrower target or raise the bounded Skill catalog character limit."
|
|
289
|
+
}] : [])
|
|
290
|
+
];
|
|
291
|
+
}
|
|
292
|
+
export function readHandoffLimits(config) {
|
|
293
|
+
const maxTotalBytes = Math.max(1, Math.min(Math.floor(config.maxOutputBytes), 240_000));
|
|
294
|
+
const maxFileBytes = Math.max(1, Math.min(Math.floor(config.maxReadBytes), 80_000, maxTotalBytes));
|
|
295
|
+
return { maxFileBytes, maxTotalBytes };
|
|
296
|
+
}
|
|
297
|
+
function codexAgentDirs(targetPath, targetKind) {
|
|
298
|
+
const normalized = targetPath === "." ? "" : targetPath;
|
|
299
|
+
const targetDirectory = targetKind === "directory"
|
|
300
|
+
? normalized
|
|
301
|
+
: path.posix.dirname(normalized || ".") === "."
|
|
302
|
+
? ""
|
|
303
|
+
: path.posix.dirname(normalized);
|
|
304
|
+
const parts = targetDirectory.split("/").filter(Boolean);
|
|
305
|
+
return ["", ...parts.map((_, index) => parts.slice(0, index + 1).join("/"))];
|
|
306
|
+
}
|
|
307
|
+
function codexRealPathKey(value) {
|
|
308
|
+
return process.platform === "win32" ? value.toLowerCase() : value;
|
|
309
|
+
}
|
|
310
|
+
async function codexAgentCandidatesInDir(guard, workspace, directory) {
|
|
311
|
+
const dirPath = directory || ".";
|
|
312
|
+
const resolved = guard.resolve(workspace, dirPath);
|
|
313
|
+
let stat;
|
|
314
|
+
try {
|
|
315
|
+
stat = await fsp.stat(resolved.absPath);
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
if (nodeErrorHasCode(error, "ENOENT"))
|
|
319
|
+
return [];
|
|
320
|
+
throw error;
|
|
321
|
+
}
|
|
322
|
+
if (!stat.isDirectory())
|
|
323
|
+
return [];
|
|
324
|
+
const entries = await fsp.readdir(resolved.absPath, { withFileTypes: true });
|
|
325
|
+
const names = ["AGENTS.override.md", "AGENTS.md", "agents.md", ".agents.md"];
|
|
326
|
+
const selected = new Set();
|
|
327
|
+
const candidates = [];
|
|
328
|
+
for (const name of names) {
|
|
329
|
+
const entry = entries.find((item) => item.name === name) ??
|
|
330
|
+
entries.find((item) => item.name.toLowerCase() === name.toLowerCase());
|
|
331
|
+
if (!entry || selected.has(entry.name))
|
|
332
|
+
continue;
|
|
333
|
+
selected.add(entry.name);
|
|
334
|
+
candidates.push(directory ? `${directory}/${entry.name}` : entry.name);
|
|
335
|
+
}
|
|
336
|
+
return candidates;
|
|
337
|
+
}
|
|
338
|
+
async function readCodexAgentsChain(config, guard, workspace, target, maxBytes) {
|
|
339
|
+
const chunks = [];
|
|
340
|
+
const files = [];
|
|
341
|
+
const unavailable = [];
|
|
342
|
+
const seenRealPaths = new Set();
|
|
343
|
+
const candidateGroups = await Promise.all(codexAgentDirs(target.targetPath, target.targetKind).map((directory) => codexAgentCandidatesInDir(guard, workspace, directory)));
|
|
344
|
+
for (const relPath of candidateGroups.flat()) {
|
|
345
|
+
const base = { source: "agents", path: relPath };
|
|
346
|
+
let resolved;
|
|
347
|
+
try {
|
|
348
|
+
resolved = guard.resolve(workspace, relPath);
|
|
349
|
+
}
|
|
350
|
+
catch {
|
|
351
|
+
unavailable.push({ ...base, reason: "blocked", bytes: null });
|
|
352
|
+
chunks.push(`--- ${relPath} ---\n[unavailable: blocked]`);
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
let stat;
|
|
356
|
+
try {
|
|
357
|
+
stat = await fsp.stat(resolved.absPath);
|
|
358
|
+
}
|
|
359
|
+
catch (error) {
|
|
360
|
+
const reason = nodeErrorHasCode(error, "ENOENT") ? "missing" : "read_failed";
|
|
361
|
+
unavailable.push({ ...base, reason, bytes: null });
|
|
362
|
+
chunks.push(`--- ${relPath} ---\n[unavailable: ${reason}]`);
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
let realPath;
|
|
366
|
+
try {
|
|
367
|
+
realPath = await fsp.realpath(resolved.absPath);
|
|
368
|
+
}
|
|
369
|
+
catch {
|
|
370
|
+
unavailable.push({ ...base, reason: "read_failed", bytes: stat.size });
|
|
371
|
+
chunks.push(`--- ${relPath} ---\n[unavailable: read_failed]`);
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
const realKey = codexRealPathKey(realPath);
|
|
375
|
+
if (seenRealPaths.has(realKey))
|
|
376
|
+
continue;
|
|
377
|
+
seenRealPaths.add(realKey);
|
|
378
|
+
if (!stat.isFile()) {
|
|
379
|
+
unavailable.push({ ...base, reason: "read_failed", bytes: stat.size });
|
|
380
|
+
chunks.push(`--- ${relPath} ---\n[unavailable: read_failed]`);
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
if (stat.size > maxBytes) {
|
|
384
|
+
unavailable.push({ ...base, reason: "too_large", bytes: stat.size });
|
|
385
|
+
chunks.push(`--- ${relPath} ---\n[unavailable: too_large]`);
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
try {
|
|
389
|
+
await guard.assertTextFile(resolved.absPath, maxBytes);
|
|
390
|
+
}
|
|
391
|
+
catch (error) {
|
|
392
|
+
const bytes = await observedFileSize(resolved.absPath);
|
|
393
|
+
const reason = bytes !== null && bytes > maxBytes
|
|
394
|
+
? "too_large"
|
|
395
|
+
: error instanceof Error && error.message === "Refusing to read binary file."
|
|
396
|
+
? "not_text"
|
|
397
|
+
: "read_failed";
|
|
398
|
+
unavailable.push({ ...base, reason, bytes });
|
|
399
|
+
chunks.push(`--- ${relPath} ---\n[unavailable: ${reason}]`);
|
|
400
|
+
continue;
|
|
401
|
+
}
|
|
402
|
+
try {
|
|
403
|
+
const revalidated = guard.resolve(workspace, relPath);
|
|
404
|
+
const revalidatedReal = await fsp.realpath(revalidated.absPath);
|
|
405
|
+
if (codexRealPathKey(revalidatedReal) !== realKey) {
|
|
406
|
+
unavailable.push({ ...base, reason: "blocked", bytes: null });
|
|
407
|
+
chunks.push(`--- ${relPath} ---\n[unavailable: blocked]`);
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
const agents = await readTextFile(config, guard, workspace, relPath, { maxBytes });
|
|
411
|
+
chunks.push(`--- ${relPath} ---\n${agents.text}`);
|
|
412
|
+
files.push(relPath);
|
|
413
|
+
}
|
|
414
|
+
catch {
|
|
415
|
+
unavailable.push({
|
|
416
|
+
...base,
|
|
417
|
+
reason: "read_failed",
|
|
418
|
+
bytes: await observedFileSize(resolved.absPath)
|
|
419
|
+
});
|
|
420
|
+
chunks.push(`--- ${relPath} ---\n[unavailable: read_failed]`);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
return {
|
|
424
|
+
text: chunks.length ? chunks.join("\n\n") : "No AGENTS.md-style instruction files found for this target path.",
|
|
425
|
+
files,
|
|
426
|
+
unavailable
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
export function waitForHandoffLimits(config) {
|
|
430
|
+
return {
|
|
431
|
+
maxStateBytes: Math.max(1, Math.min(Math.floor(config.maxReadBytes), 64_000)),
|
|
432
|
+
maxArtifactBytes: Math.max(1, Math.min(Math.floor(config.maxReadBytes), 80_000)),
|
|
433
|
+
maxTotalBytes: Math.max(1, Math.min(Math.floor(config.maxOutputBytes), 40_000))
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
function nodeErrorHasCode(error, code) {
|
|
437
|
+
return Boolean(error &&
|
|
438
|
+
typeof error === "object" &&
|
|
439
|
+
"code" in error &&
|
|
440
|
+
error.code === code);
|
|
441
|
+
}
|
|
442
|
+
async function observedFileSize(absPath) {
|
|
443
|
+
try {
|
|
444
|
+
const stat = await fsp.stat(absPath);
|
|
445
|
+
return stat.isFile() ? stat.size : null;
|
|
446
|
+
}
|
|
447
|
+
catch {
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
export async function readHandoffRunState(config, guard, workspace, maxStateBytes = waitForHandoffLimits(config).maxStateBytes) {
|
|
452
|
+
const stateFile = `${config.contextDir}/handoff-run-state.json`;
|
|
453
|
+
const resolved = guard.resolve(workspace, stateFile);
|
|
454
|
+
let stat;
|
|
455
|
+
try {
|
|
456
|
+
stat = await fsp.stat(resolved.absPath);
|
|
457
|
+
}
|
|
458
|
+
catch (error) {
|
|
459
|
+
if (nodeErrorHasCode(error, "ENOENT")) {
|
|
460
|
+
return { stateFile, present: false, bytes: null, text: null };
|
|
461
|
+
}
|
|
462
|
+
throw error;
|
|
463
|
+
}
|
|
464
|
+
if (!stat.isFile() || stat.size > maxStateBytes) {
|
|
465
|
+
throw new Error("Handoff run state is not a bounded regular file.");
|
|
466
|
+
}
|
|
467
|
+
await guard.assertTextFile(resolved.absPath, maxStateBytes);
|
|
468
|
+
const revalidated = guard.resolve(workspace, stateFile);
|
|
469
|
+
if (revalidated.absPath !== resolved.absPath) {
|
|
470
|
+
throw new Error("Handoff run state boundary changed during read.");
|
|
471
|
+
}
|
|
472
|
+
const buffer = await fsp.readFile(revalidated.absPath);
|
|
473
|
+
if (buffer.byteLength > maxStateBytes || buffer.includes(0)) {
|
|
474
|
+
throw new Error("Handoff run state is not bounded text.");
|
|
475
|
+
}
|
|
476
|
+
return {
|
|
477
|
+
stateFile,
|
|
478
|
+
present: true,
|
|
479
|
+
bytes: buffer.byteLength,
|
|
480
|
+
text: buffer.toString("utf8")
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
export async function readWaitForHandoffArtifacts(config, guard, workspace, requestedKinds, maxArtifactBytes = waitForHandoffLimits(config).maxArtifactBytes) {
|
|
484
|
+
const requested = WAIT_FOR_HANDOFF_ARTIFACT_DEFINITIONS
|
|
485
|
+
.filter((definition) => requestedKinds.includes(definition.kind))
|
|
486
|
+
.map((definition) => definition.kind);
|
|
487
|
+
const artifacts = [];
|
|
488
|
+
const unavailable = [];
|
|
489
|
+
for (const definition of WAIT_FOR_HANDOFF_ARTIFACT_DEFINITIONS) {
|
|
490
|
+
if (!requested.includes(definition.kind))
|
|
491
|
+
continue;
|
|
492
|
+
const relPath = `${config.contextDir}/${definition.name}`;
|
|
493
|
+
const base = { path: relPath, kind: definition.kind };
|
|
494
|
+
let resolved;
|
|
495
|
+
try {
|
|
496
|
+
resolved = guard.resolve(workspace, relPath);
|
|
497
|
+
}
|
|
498
|
+
catch {
|
|
499
|
+
unavailable.push({ ...base, reason: "blocked", bytes: null });
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
let stat;
|
|
503
|
+
try {
|
|
504
|
+
stat = await fsp.stat(resolved.absPath);
|
|
505
|
+
}
|
|
506
|
+
catch (error) {
|
|
507
|
+
unavailable.push({
|
|
508
|
+
...base,
|
|
509
|
+
reason: nodeErrorHasCode(error, "ENOENT") ? "missing" : "read_failed",
|
|
510
|
+
bytes: null
|
|
511
|
+
});
|
|
512
|
+
continue;
|
|
513
|
+
}
|
|
514
|
+
if (!stat.isFile()) {
|
|
515
|
+
unavailable.push({ ...base, reason: "read_failed", bytes: stat.size });
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
if (stat.size > maxArtifactBytes) {
|
|
519
|
+
unavailable.push({ ...base, reason: "too_large", bytes: stat.size });
|
|
520
|
+
continue;
|
|
521
|
+
}
|
|
522
|
+
try {
|
|
523
|
+
await guard.assertTextFile(resolved.absPath, maxArtifactBytes);
|
|
524
|
+
}
|
|
525
|
+
catch (error) {
|
|
526
|
+
const latestSize = await observedFileSize(resolved.absPath);
|
|
527
|
+
if (latestSize !== null && latestSize > maxArtifactBytes) {
|
|
528
|
+
unavailable.push({ ...base, reason: "too_large", bytes: latestSize });
|
|
529
|
+
}
|
|
530
|
+
else if (error instanceof Error && error.message === "Refusing to read binary file.") {
|
|
531
|
+
unavailable.push({ ...base, reason: "not_text", bytes: latestSize });
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
unavailable.push({ ...base, reason: "read_failed", bytes: latestSize });
|
|
535
|
+
}
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
let revalidated;
|
|
539
|
+
try {
|
|
540
|
+
revalidated = guard.resolve(workspace, relPath);
|
|
541
|
+
}
|
|
542
|
+
catch {
|
|
543
|
+
unavailable.push({ ...base, reason: "blocked", bytes: null });
|
|
544
|
+
continue;
|
|
545
|
+
}
|
|
546
|
+
if (revalidated.absPath !== resolved.absPath) {
|
|
547
|
+
unavailable.push({ ...base, reason: "blocked", bytes: null });
|
|
548
|
+
continue;
|
|
549
|
+
}
|
|
550
|
+
let buffer;
|
|
551
|
+
try {
|
|
552
|
+
buffer = await fsp.readFile(revalidated.absPath);
|
|
553
|
+
}
|
|
554
|
+
catch {
|
|
555
|
+
unavailable.push({
|
|
556
|
+
...base,
|
|
557
|
+
reason: "read_failed",
|
|
558
|
+
bytes: await observedFileSize(resolved.absPath)
|
|
559
|
+
});
|
|
560
|
+
continue;
|
|
561
|
+
}
|
|
562
|
+
if (buffer.byteLength > maxArtifactBytes) {
|
|
563
|
+
unavailable.push({ ...base, reason: "too_large", bytes: buffer.byteLength });
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
if (buffer.includes(0)) {
|
|
567
|
+
unavailable.push({ ...base, reason: "not_text", bytes: buffer.byteLength });
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
const text = buffer.toString("utf8");
|
|
571
|
+
artifacts.push({
|
|
572
|
+
...base,
|
|
573
|
+
bytes: buffer.byteLength,
|
|
574
|
+
lineCount: waitForHandoffLineCount(text),
|
|
575
|
+
text
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
return {
|
|
579
|
+
contextDir: config.contextDir,
|
|
580
|
+
requestedKinds: requested,
|
|
581
|
+
artifacts,
|
|
582
|
+
unavailable
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
export async function readHandoffContext(config, guard, workspace, limits = readHandoffLimits(config)) {
|
|
586
|
+
const bridgeDir = guard.resolve(workspace, config.contextDir);
|
|
587
|
+
let bridgeStat;
|
|
588
|
+
try {
|
|
589
|
+
bridgeStat = await fsp.stat(bridgeDir.absPath);
|
|
590
|
+
}
|
|
591
|
+
catch (error) {
|
|
592
|
+
if (nodeErrorHasCode(error, "ENOENT")) {
|
|
593
|
+
return {
|
|
594
|
+
contextDir: config.contextDir,
|
|
595
|
+
contextExists: false,
|
|
596
|
+
artifacts: [],
|
|
597
|
+
unavailable: []
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
throw error;
|
|
601
|
+
}
|
|
602
|
+
if (!bridgeStat.isDirectory()) {
|
|
603
|
+
throw new Error("Configured handoff context is not a directory.");
|
|
604
|
+
}
|
|
605
|
+
const artifacts = [];
|
|
606
|
+
const unavailable = [];
|
|
607
|
+
let loadedBytes = 0;
|
|
608
|
+
for (const definition of READ_HANDOFF_ARTIFACT_DEFINITIONS) {
|
|
609
|
+
const relPath = `${config.contextDir}/${definition.name}`;
|
|
610
|
+
const base = { path: relPath, kind: definition.kind };
|
|
611
|
+
let resolved;
|
|
612
|
+
try {
|
|
613
|
+
resolved = guard.resolve(workspace, relPath);
|
|
614
|
+
}
|
|
615
|
+
catch {
|
|
616
|
+
unavailable.push({ ...base, reason: "blocked", bytes: null });
|
|
617
|
+
continue;
|
|
618
|
+
}
|
|
619
|
+
let stat;
|
|
620
|
+
try {
|
|
621
|
+
stat = await fsp.stat(resolved.absPath);
|
|
622
|
+
}
|
|
623
|
+
catch (error) {
|
|
624
|
+
unavailable.push({
|
|
625
|
+
...base,
|
|
626
|
+
reason: nodeErrorHasCode(error, "ENOENT") ? "missing" : "read_failed",
|
|
627
|
+
bytes: null
|
|
628
|
+
});
|
|
629
|
+
continue;
|
|
630
|
+
}
|
|
631
|
+
if (!stat.isFile()) {
|
|
632
|
+
unavailable.push({ ...base, reason: "read_failed", bytes: stat.size });
|
|
633
|
+
continue;
|
|
634
|
+
}
|
|
635
|
+
if (stat.size > limits.maxFileBytes) {
|
|
636
|
+
unavailable.push({ ...base, reason: "too_large", bytes: stat.size });
|
|
637
|
+
continue;
|
|
638
|
+
}
|
|
639
|
+
if (loadedBytes + stat.size > limits.maxTotalBytes) {
|
|
640
|
+
unavailable.push({ ...base, reason: "output_limit", bytes: stat.size });
|
|
641
|
+
continue;
|
|
642
|
+
}
|
|
643
|
+
try {
|
|
644
|
+
await guard.assertTextFile(resolved.absPath, limits.maxFileBytes);
|
|
645
|
+
}
|
|
646
|
+
catch (error) {
|
|
647
|
+
const latestSize = await observedFileSize(resolved.absPath);
|
|
648
|
+
if (latestSize !== null && latestSize > limits.maxFileBytes) {
|
|
649
|
+
unavailable.push({ ...base, reason: "too_large", bytes: latestSize });
|
|
650
|
+
}
|
|
651
|
+
else if (error instanceof Error && error.message === "Refusing to read binary file.") {
|
|
652
|
+
unavailable.push({ ...base, reason: "not_text", bytes: latestSize });
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
unavailable.push({ ...base, reason: "read_failed", bytes: latestSize });
|
|
656
|
+
}
|
|
657
|
+
continue;
|
|
658
|
+
}
|
|
659
|
+
let revalidated;
|
|
660
|
+
try {
|
|
661
|
+
revalidated = guard.resolve(workspace, relPath);
|
|
662
|
+
}
|
|
663
|
+
catch {
|
|
664
|
+
unavailable.push({ ...base, reason: "blocked", bytes: null });
|
|
665
|
+
continue;
|
|
666
|
+
}
|
|
667
|
+
if (revalidated.absPath !== resolved.absPath) {
|
|
668
|
+
unavailable.push({ ...base, reason: "blocked", bytes: null });
|
|
669
|
+
continue;
|
|
670
|
+
}
|
|
671
|
+
let buffer;
|
|
672
|
+
try {
|
|
673
|
+
buffer = await fsp.readFile(revalidated.absPath);
|
|
674
|
+
}
|
|
675
|
+
catch {
|
|
676
|
+
unavailable.push({
|
|
677
|
+
...base,
|
|
678
|
+
reason: "read_failed",
|
|
679
|
+
bytes: await observedFileSize(resolved.absPath)
|
|
680
|
+
});
|
|
681
|
+
continue;
|
|
682
|
+
}
|
|
683
|
+
if (buffer.byteLength > limits.maxFileBytes) {
|
|
684
|
+
unavailable.push({ ...base, reason: "too_large", bytes: buffer.byteLength });
|
|
685
|
+
continue;
|
|
686
|
+
}
|
|
687
|
+
if (loadedBytes + buffer.byteLength > limits.maxTotalBytes) {
|
|
688
|
+
unavailable.push({ ...base, reason: "output_limit", bytes: buffer.byteLength });
|
|
689
|
+
continue;
|
|
690
|
+
}
|
|
691
|
+
if (buffer.includes(0)) {
|
|
692
|
+
unavailable.push({ ...base, reason: "not_text", bytes: buffer.byteLength });
|
|
693
|
+
continue;
|
|
694
|
+
}
|
|
695
|
+
const text = buffer.toString("utf8");
|
|
696
|
+
artifacts.push({
|
|
697
|
+
...base,
|
|
698
|
+
bytes: buffer.byteLength,
|
|
699
|
+
lineCount: readHandoffLineCount(text),
|
|
700
|
+
text
|
|
701
|
+
});
|
|
702
|
+
loadedBytes += buffer.byteLength;
|
|
703
|
+
}
|
|
704
|
+
return {
|
|
705
|
+
contextDir: config.contextDir,
|
|
706
|
+
contextExists: true,
|
|
707
|
+
artifacts,
|
|
708
|
+
unavailable
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
export async function readAiBridgeContext(config, guard, workspace, options = {}) {
|
|
712
|
+
if (options.createIfMissing) {
|
|
713
|
+
await ensureAiBridge(config, guard, workspace);
|
|
714
|
+
}
|
|
715
|
+
const result = await readHandoffContext(config, guard, workspace);
|
|
716
|
+
if (!result.contextExists) {
|
|
717
|
+
return {
|
|
718
|
+
text: `No ${config.contextDir} handoff context exists yet. Use handoff_to_agent or handoff_to_codex to create it when a plan is ready.`,
|
|
719
|
+
files: []
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
const artifactByPath = new Map(result.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
723
|
+
const unavailableByPath = new Map(result.unavailable.map((item) => [item.path, item]));
|
|
724
|
+
const chunks = READ_HANDOFF_ARTIFACT_DEFINITIONS.map((definition) => {
|
|
725
|
+
const relPath = `${config.contextDir}/${definition.name}`;
|
|
726
|
+
const artifact = artifactByPath.get(relPath);
|
|
727
|
+
if (artifact)
|
|
728
|
+
return `--- ${relPath} ---\n${artifact.text}`;
|
|
729
|
+
const unavailable = unavailableByPath.get(relPath);
|
|
730
|
+
return `--- ${relPath} ---\n[unavailable: ${unavailable?.reason ?? "read_failed"}]`;
|
|
731
|
+
});
|
|
732
|
+
return {
|
|
733
|
+
text: chunks.join("\n\n"),
|
|
734
|
+
files: result.artifacts.map((artifact) => artifact.path)
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
export async function resolveCodexContextTarget(guard, workspace, inputPath = ".") {
|
|
738
|
+
const requested = inputPath.trim() || ".";
|
|
739
|
+
if (redactSensitiveText(requested) !== requested) {
|
|
740
|
+
throw new Error("Codex context target path is blocked by safety rules.");
|
|
741
|
+
}
|
|
742
|
+
let resolved = guard.resolve(workspace, requested);
|
|
743
|
+
let stat;
|
|
744
|
+
try {
|
|
745
|
+
stat = await fsp.stat(resolved.absPath);
|
|
746
|
+
}
|
|
747
|
+
catch (error) {
|
|
748
|
+
if (!nodeErrorHasCode(error, "ENOENT"))
|
|
749
|
+
throw error;
|
|
750
|
+
resolved = guard.resolve(workspace, requested, { forWrite: true });
|
|
751
|
+
let existingParent = path.dirname(resolved.absPath);
|
|
752
|
+
let parentStat;
|
|
753
|
+
while (true) {
|
|
754
|
+
try {
|
|
755
|
+
parentStat = await fsp.stat(existingParent);
|
|
756
|
+
break;
|
|
757
|
+
}
|
|
758
|
+
catch (parentError) {
|
|
759
|
+
if (!nodeErrorHasCode(parentError, "ENOENT"))
|
|
760
|
+
throw parentError;
|
|
761
|
+
const next = path.dirname(existingParent);
|
|
762
|
+
if (next === existingParent)
|
|
763
|
+
throw parentError;
|
|
764
|
+
existingParent = next;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
if (!parentStat.isDirectory()) {
|
|
768
|
+
throw new Error("Codex context target parent is not a directory.");
|
|
769
|
+
}
|
|
770
|
+
const realParent = await fsp.realpath(existingParent);
|
|
771
|
+
const suffix = path.relative(existingParent, resolved.absPath);
|
|
772
|
+
const canonical = guard.resolve(workspace, path.resolve(realParent, suffix), { forWrite: true });
|
|
773
|
+
return { targetPath: canonical.relPath, targetKind: "missing" };
|
|
774
|
+
}
|
|
775
|
+
if (!stat.isFile() && !stat.isDirectory()) {
|
|
776
|
+
throw new Error("Codex context target is not a regular file or directory.");
|
|
777
|
+
}
|
|
778
|
+
const realPath = await fsp.realpath(resolved.absPath);
|
|
779
|
+
const canonical = guard.resolve(workspace, realPath);
|
|
780
|
+
return {
|
|
781
|
+
targetPath: canonical.relPath,
|
|
782
|
+
targetKind: stat.isFile() ? "file" : "directory"
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
export async function readCodexContext(config, guard, workspace, options = {}) {
|
|
786
|
+
const target = options.targetKind
|
|
787
|
+
? { targetPath: options.targetPath ?? ".", targetKind: options.targetKind }
|
|
788
|
+
: await resolveCodexContextTarget(guard, workspace, options.targetPath);
|
|
789
|
+
const maxAgentBytes = Math.min(options.maxAgentBytes ?? 60_000, config.maxReadBytes);
|
|
790
|
+
const standardMode = (config.guidanceMode ?? "legacy") === "standard";
|
|
791
|
+
const standardInstructions = standardMode
|
|
792
|
+
? await discoverInstructions({
|
|
793
|
+
root: workspace.root,
|
|
794
|
+
targetPath: target.targetPath,
|
|
795
|
+
fallbackNames: config.instructionFallbacks?.length ? config.instructionFallbacks : undefined,
|
|
796
|
+
maxFileBytes: maxAgentBytes,
|
|
797
|
+
maxTotalBytes: config.maxInstructionTotalBytes ?? 32_768,
|
|
798
|
+
blockedGlobs: config.blockedGlobs
|
|
799
|
+
})
|
|
800
|
+
: null;
|
|
801
|
+
const agents = standardInstructions
|
|
802
|
+
? {
|
|
803
|
+
text: standardInstructions.files.length
|
|
804
|
+
? standardInstructions.files.map((file) => `--- ${file.path} ---\n${file.text}`).join("\n\n")
|
|
805
|
+
: "No AGENTS.md-style instruction files found for this target path.",
|
|
806
|
+
files: standardInstructions.files.map((file) => file.path),
|
|
807
|
+
unavailable: []
|
|
808
|
+
}
|
|
809
|
+
: await readCodexAgentsChain(config, guard, workspace, target, maxAgentBytes);
|
|
810
|
+
const standardSkillDiscovery = standardMode
|
|
811
|
+
? await discoverTargetSkills({
|
|
812
|
+
root: workspace.root,
|
|
813
|
+
targetPath: target.targetPath,
|
|
814
|
+
maxCandidates: config.maxSkillCandidates ?? 1_000,
|
|
815
|
+
maxSkills: 120,
|
|
816
|
+
blockedGlobs: config.blockedGlobs
|
|
817
|
+
})
|
|
818
|
+
: null;
|
|
819
|
+
const standardCatalog = standardSkillDiscovery
|
|
820
|
+
? buildSkillCatalog(standardSkillDiscovery.skills, config.maxSkillCatalogChars ?? 8_000)
|
|
821
|
+
: null;
|
|
822
|
+
const handoff = options.includeAiBridge === false
|
|
823
|
+
? null
|
|
824
|
+
: await readHandoffContext(config, guard, workspace);
|
|
825
|
+
const ai = handoff === null
|
|
826
|
+
? { text: "Skipped by request.", contextExists: null, files: [], unavailable: [] }
|
|
827
|
+
: !handoff.contextExists
|
|
828
|
+
? {
|
|
829
|
+
text: `No ${config.contextDir} handoff context exists yet. Use handoff_to_agent or handoff_to_codex to create it when a plan is ready.`,
|
|
830
|
+
contextExists: false,
|
|
831
|
+
files: [],
|
|
832
|
+
unavailable: []
|
|
833
|
+
}
|
|
834
|
+
: (() => {
|
|
835
|
+
const artifactByPath = new Map(handoff.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
836
|
+
const unavailableByPath = new Map(handoff.unavailable.map((item) => [item.path, item]));
|
|
837
|
+
const chunks = READ_HANDOFF_ARTIFACT_DEFINITIONS.map((definition) => {
|
|
838
|
+
const relPath = `${config.contextDir}/${definition.name}`;
|
|
839
|
+
const artifact = artifactByPath.get(relPath);
|
|
840
|
+
if (artifact)
|
|
841
|
+
return `--- ${relPath} ---\n${artifact.text}`;
|
|
842
|
+
return `--- ${relPath} ---\n[unavailable: ${unavailableByPath.get(relPath)?.reason ?? "read_failed"}]`;
|
|
843
|
+
});
|
|
844
|
+
return {
|
|
845
|
+
text: chunks.join("\n\n"),
|
|
846
|
+
contextExists: true,
|
|
847
|
+
files: handoff.artifacts.map((artifact) => artifact.path),
|
|
848
|
+
unavailable: handoff.unavailable.map((item) => ({
|
|
849
|
+
source: "ai_bridge",
|
|
850
|
+
path: item.path,
|
|
851
|
+
reason: item.reason,
|
|
852
|
+
bytes: item.bytes
|
|
853
|
+
}))
|
|
854
|
+
};
|
|
855
|
+
})();
|
|
856
|
+
const status = options.includeGit === false
|
|
857
|
+
? undefined
|
|
858
|
+
: options.gitStatusProvider
|
|
859
|
+
? await options.gitStatusProvider()
|
|
860
|
+
: gitStatus(config, workspace);
|
|
861
|
+
const diff = options.includeDiff
|
|
862
|
+
? options.gitDiffProvider
|
|
863
|
+
? await options.gitDiffProvider()
|
|
864
|
+
: gitDiff(config, guard, workspace)
|
|
865
|
+
: undefined;
|
|
866
|
+
const text = [
|
|
867
|
+
"# Codex Context",
|
|
868
|
+
"",
|
|
869
|
+
`Workspace: ${workspace.id}`,
|
|
870
|
+
`Root: ${workspace.root}`,
|
|
871
|
+
`Target path: ${target.targetPath}`,
|
|
872
|
+
`Bash mode: ${config.bashMode}`,
|
|
873
|
+
`Write mode: ${config.writeMode}`,
|
|
874
|
+
`Tool mode: ${config.toolMode}`,
|
|
875
|
+
"",
|
|
876
|
+
"## AGENTS Instructions",
|
|
877
|
+
"",
|
|
878
|
+
agents.text,
|
|
879
|
+
...(standardCatalog ? ["", "## Applicable Skills", "", standardCatalog.serialized] : []),
|
|
880
|
+
"",
|
|
881
|
+
"## AI Bridge Context",
|
|
882
|
+
"",
|
|
883
|
+
ai.text,
|
|
884
|
+
...(status !== undefined ? ["", "## Git Status", "", status] : []),
|
|
885
|
+
...(diff !== undefined ? ["", "## Git Diff", "", diff] : [])
|
|
886
|
+
].join("\n");
|
|
887
|
+
return {
|
|
888
|
+
text,
|
|
889
|
+
workspaceId: workspace.id,
|
|
890
|
+
root: workspace.root,
|
|
891
|
+
targetPath: target.targetPath,
|
|
892
|
+
targetKind: target.targetKind,
|
|
893
|
+
agentsFiles: agents.files,
|
|
894
|
+
aiContextExists: ai.contextExists,
|
|
895
|
+
aiContextFiles: ai.files,
|
|
896
|
+
unavailableSources: [...agents.unavailable, ...ai.unavailable],
|
|
897
|
+
gitStatus: status,
|
|
898
|
+
gitDiff: diff,
|
|
899
|
+
...(standardInstructions && standardSkillDiscovery && standardCatalog
|
|
900
|
+
? {
|
|
901
|
+
standardGuidance: {
|
|
902
|
+
status: guidanceDiagnostics(standardInstructions.diagnostics, standardSkillDiscovery, standardCatalog).length ? "warning" : "ok",
|
|
903
|
+
instructionChain: standardInstructions.files,
|
|
904
|
+
instructionDiagnostics: guidanceDiagnostics(standardInstructions.diagnostics, standardSkillDiscovery, standardCatalog),
|
|
905
|
+
skillCatalog: standardCatalog.entries,
|
|
906
|
+
skillScan: {
|
|
907
|
+
candidateCount: standardSkillDiscovery.candidateCount,
|
|
908
|
+
validCount: standardSkillDiscovery.validCount,
|
|
909
|
+
invalidCount: standardSkillDiscovery.invalidCount,
|
|
910
|
+
scanComplete: standardSkillDiscovery.scanComplete,
|
|
911
|
+
scanTruncated: standardSkillDiscovery.scanTruncated,
|
|
912
|
+
returnedTruncated: standardSkillDiscovery.returnedTruncated,
|
|
913
|
+
catalogComplete: standardCatalog.catalogComplete,
|
|
914
|
+
catalogOmittedCount: standardCatalog.catalogOmittedCount,
|
|
915
|
+
descriptionsShortened: standardCatalog.descriptionsShortened,
|
|
916
|
+
catalogChars: standardCatalog.characterCount,
|
|
917
|
+
ineligibleCount: standardCatalog.ineligibleCount
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
: {})
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
//# sourceMappingURL=workspaceOps.js.map
|