@kbediako/codex-orchestrator 0.1.37 → 0.2.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/plugins/marketplace.json +20 -0
- package/README.md +73 -291
- package/bin/codex-orchestrator.js +161 -0
- package/codex.orchestrator.json +149 -13
- package/dist/bin/codex-orchestrator.js +795 -1154
- package/dist/orchestrator/src/cli/adapters/CommandPlanner.js +22 -4
- package/dist/orchestrator/src/cli/adapters/CommandReviewer.js +3 -3
- package/dist/orchestrator/src/cli/adapters/CommandTester.js +2 -2
- package/dist/orchestrator/src/cli/adapters/cloudFailureDiagnostics.js +183 -11
- package/dist/orchestrator/src/cli/coStatusAttachCliShell.js +402 -0
- package/dist/orchestrator/src/cli/coStatusCliShell.js +429 -0
- package/dist/orchestrator/src/cli/coStatusOperatorAutopilotCliShell.js +120 -0
- package/dist/orchestrator/src/cli/codexCliShell.js +72 -0
- package/dist/orchestrator/src/cli/codexDefaultsSetup.js +49 -11
- package/dist/orchestrator/src/cli/config/delegationConfig.js +317 -5
- package/dist/orchestrator/src/cli/config/repoConfigPolicy.js +2 -3
- package/dist/orchestrator/src/cli/config/userConfig.js +28 -13
- package/dist/orchestrator/src/cli/control/authenticatedControlRouteGate.js +69 -0
- package/dist/orchestrator/src/cli/control/authenticatedRouteComposition.js +267 -0
- package/dist/orchestrator/src/cli/control/authenticatedRouteController.js +5 -0
- package/dist/orchestrator/src/cli/control/authenticatedRouteDispatcher.js +41 -0
- package/dist/orchestrator/src/cli/control/compatibilityIssuePresenter.js +1035 -0
- package/dist/orchestrator/src/cli/control/confirmationApproveController.js +62 -0
- package/dist/orchestrator/src/cli/control/confirmationCreateController.js +69 -0
- package/dist/orchestrator/src/cli/control/confirmationIssueConsumeController.js +43 -0
- package/dist/orchestrator/src/cli/control/confirmationListController.js +22 -0
- package/dist/orchestrator/src/cli/control/confirmationValidateController.js +58 -0
- package/dist/orchestrator/src/cli/control/confirmations.js +25 -3
- package/dist/orchestrator/src/cli/control/controlActionCancelConfirmation.js +65 -0
- package/dist/orchestrator/src/cli/control/controlActionController.js +77 -0
- package/dist/orchestrator/src/cli/control/controlActionControllerSequencing.js +161 -0
- package/dist/orchestrator/src/cli/control/controlActionExecution.js +142 -0
- package/dist/orchestrator/src/cli/control/controlActionFinalization.js +43 -0
- package/dist/orchestrator/src/cli/control/controlActionOutcome.js +60 -0
- package/dist/orchestrator/src/cli/control/controlActionPreflight.js +476 -0
- package/dist/orchestrator/src/cli/control/controlAuthenticatedRouteHandoff.js +57 -0
- package/dist/orchestrator/src/cli/control/controlBootstrapAssembly.js +39 -0
- package/dist/orchestrator/src/cli/control/controlBootstrapMetadataPersistence.js +16 -0
- package/dist/orchestrator/src/cli/control/controlEventTransport.js +49 -0
- package/dist/orchestrator/src/cli/control/controlExpiryLifecycle.js +102 -0
- package/dist/orchestrator/src/cli/control/controlHostOwnership.js +480 -0
- package/dist/orchestrator/src/cli/control/controlHostSupervision.js +608 -0
- package/dist/orchestrator/src/cli/control/controlOversightFacade.js +8 -0
- package/dist/orchestrator/src/cli/control/controlOversightReadContract.js +1 -0
- package/dist/orchestrator/src/cli/control/controlOversightReadService.js +16 -0
- package/dist/orchestrator/src/cli/control/controlOversightUpdateContract.js +1 -0
- package/dist/orchestrator/src/cli/control/controlPersistenceFiles.js +6 -0
- package/dist/orchestrator/src/cli/control/controlQuestionChildResolution.js +18 -0
- package/dist/orchestrator/src/cli/control/controlRequestContext.js +42 -0
- package/dist/orchestrator/src/cli/control/controlRequestController.js +9 -0
- package/dist/orchestrator/src/cli/control/controlRequestPredispatch.js +17 -0
- package/dist/orchestrator/src/cli/control/controlRequestRouteDispatch.js +44 -0
- package/dist/orchestrator/src/cli/control/controlRuntime.js +992 -0
- package/dist/orchestrator/src/cli/control/controlServer.js +23 -1456
- package/dist/orchestrator/src/cli/control/controlServerAuditAndErrorHelpers.js +115 -0
- package/dist/orchestrator/src/cli/control/controlServerAuthenticatedRouteBranch.js +29 -0
- package/dist/orchestrator/src/cli/control/controlServerBootstrapLifecycle.js +30 -0
- package/dist/orchestrator/src/cli/control/controlServerBootstrapStartSequence.js +21 -0
- package/dist/orchestrator/src/cli/control/controlServerOwnedRuntimeLifecycle.js +67 -0
- package/dist/orchestrator/src/cli/control/controlServerPublicLifecycle.js +756 -0
- package/dist/orchestrator/src/cli/control/controlServerPublicRouteHelpers.js +86 -0
- package/dist/orchestrator/src/cli/control/controlServerReadyInstanceLifecycle.js +25 -0
- package/dist/orchestrator/src/cli/control/controlServerReadyInstanceStartup.js +18 -0
- package/dist/orchestrator/src/cli/control/controlServerRequestBodyHelpers.js +37 -0
- package/dist/orchestrator/src/cli/control/controlServerRequestShell.js +40 -0
- package/dist/orchestrator/src/cli/control/controlServerRequestShellBinding.js +17 -0
- package/dist/orchestrator/src/cli/control/controlServerSeedLoading.js +27 -0
- package/dist/orchestrator/src/cli/control/controlServerSeededRuntimeAssembly.js +186 -0
- package/dist/orchestrator/src/cli/control/controlServerStartupInputPreparation.js +31 -0
- package/dist/orchestrator/src/cli/control/controlServerStartupSequence.js +49 -0
- package/dist/orchestrator/src/cli/control/controlState.js +233 -2
- package/dist/orchestrator/src/cli/control/controlStatusDashboard.js +1899 -0
- package/dist/orchestrator/src/cli/control/controlTelegramBridgeBootstrapLifecycle.js +22 -0
- package/dist/orchestrator/src/cli/control/controlTelegramBridgeLifecycle.js +67 -0
- package/dist/orchestrator/src/cli/control/controlTelegramBridgeOversightFacadeFactory.js +8 -0
- package/dist/orchestrator/src/cli/control/controlTelegramCommandController.js +49 -0
- package/dist/orchestrator/src/cli/control/controlTelegramDispatchRead.js +40 -0
- package/dist/orchestrator/src/cli/control/controlTelegramPollingController.js +89 -0
- package/dist/orchestrator/src/cli/control/controlTelegramProjectionNotificationController.js +29 -0
- package/dist/orchestrator/src/cli/control/controlTelegramPushState.js +63 -0
- package/dist/orchestrator/src/cli/control/controlTelegramQuestionRead.js +13 -0
- package/dist/orchestrator/src/cli/control/controlTelegramReadController.js +216 -0
- package/dist/orchestrator/src/cli/control/controlTelegramUpdateHandler.js +63 -0
- package/dist/orchestrator/src/cli/control/controlWatcher.js +73 -5
- package/dist/orchestrator/src/cli/control/delegationRegisterController.js +35 -0
- package/dist/orchestrator/src/cli/control/dynamicToolBridgePolicy.js +139 -0
- package/dist/orchestrator/src/cli/control/eventsSseController.js +12 -0
- package/dist/orchestrator/src/cli/control/linearBudgetState.js +1789 -0
- package/dist/orchestrator/src/cli/control/linearDispatchSource.js +1137 -0
- package/dist/orchestrator/src/cli/control/linearGraphqlClient.js +150 -0
- package/dist/orchestrator/src/cli/control/linearRateLimit.js +102 -0
- package/dist/orchestrator/src/cli/control/linearWebhookController.js +499 -0
- package/dist/orchestrator/src/cli/control/liveLinearAdvisoryRuntime.js +70 -0
- package/dist/orchestrator/src/cli/control/observabilityApiController.js +173 -0
- package/dist/orchestrator/src/cli/control/observabilityReadModel.js +500 -0
- package/dist/orchestrator/src/cli/control/observabilitySurface.js +284 -0
- package/dist/orchestrator/src/cli/control/observabilityUpdateNotifier.js +22 -0
- package/dist/orchestrator/src/cli/control/operatorDashboardPresenter.js +252 -0
- package/dist/orchestrator/src/cli/control/providerAgentCapacity.js +70 -0
- package/dist/orchestrator/src/cli/control/providerControlHostFreshnessGauge.js +1068 -0
- package/dist/orchestrator/src/cli/control/providerIntakeState.js +473 -0
- package/dist/orchestrator/src/cli/control/providerIssueHandoff.js +6811 -0
- package/dist/orchestrator/src/cli/control/providerIssueObservability.js +1348 -0
- package/dist/orchestrator/src/cli/control/providerIssueRetryQueue.js +84 -0
- package/dist/orchestrator/src/cli/control/providerLinearRuntimeProof.js +588 -0
- package/dist/orchestrator/src/cli/control/providerLinearScreenshotProof.js +473 -0
- package/dist/orchestrator/src/cli/control/providerLinearWorkerTruth.js +383 -0
- package/dist/orchestrator/src/cli/control/providerLinearWorkflowAudit.js +254 -0
- package/dist/orchestrator/src/cli/control/providerLinearWorkflowFacade.js +5573 -0
- package/dist/orchestrator/src/cli/control/providerLinearWorkflowStates.js +115 -0
- package/dist/orchestrator/src/cli/control/providerMergeCloseout.js +1868 -0
- package/dist/orchestrator/src/cli/control/providerOperatorAutopilot.js +1580 -0
- package/dist/orchestrator/src/cli/control/providerOperatorAutopilotLifecycle.js +154 -0
- package/dist/orchestrator/src/cli/control/providerOperatorAutopilotLocalRolloutExecution.js +1006 -0
- package/dist/orchestrator/src/cli/control/providerPollingHealth.js +435 -0
- package/dist/orchestrator/src/cli/control/providerTerminalCleanup.js +516 -0
- package/dist/orchestrator/src/cli/control/providerWorkerHosts.js +191 -0
- package/dist/orchestrator/src/cli/control/providerWorkflowConfigStore.js +515 -0
- package/dist/orchestrator/src/cli/control/questionChildResolutionAdapter.js +361 -0
- package/dist/orchestrator/src/cli/control/questionQueueController.js +181 -0
- package/dist/orchestrator/src/cli/control/questionReadRetryDeduplication.js +9 -0
- package/dist/orchestrator/src/cli/control/questionReadSequence.js +10 -0
- package/dist/orchestrator/src/cli/control/securityViolationController.js +27 -0
- package/dist/orchestrator/src/cli/control/selectedRunProjection.js +1838 -0
- package/dist/orchestrator/src/cli/control/telegramOversightApiClient.js +48 -0
- package/dist/orchestrator/src/cli/control/telegramOversightBridge.js +180 -0
- package/dist/orchestrator/src/cli/control/telegramOversightBridgeProjectionDeliveryQueue.js +25 -0
- package/dist/orchestrator/src/cli/control/telegramOversightBridgeRuntimeLifecycle.js +45 -0
- package/dist/orchestrator/src/cli/control/telegramOversightBridgeStateStore.js +77 -0
- package/dist/orchestrator/src/cli/control/telegramOversightControlActionApiClient.js +45 -0
- package/dist/orchestrator/src/cli/control/trackerDispatchPilot.js +439 -0
- package/dist/orchestrator/src/cli/control/uiDataController.js +34 -0
- package/dist/orchestrator/src/cli/control/uiSessionController.js +100 -0
- package/dist/orchestrator/src/cli/controlHostCliShell.js +860 -0
- package/dist/orchestrator/src/cli/controlHostFreshnessGaugeCliShell.js +129 -0
- package/dist/orchestrator/src/cli/controlHostSupervisionCliShell.js +2127 -0
- package/dist/orchestrator/src/cli/delegationCliShell.js +62 -0
- package/dist/orchestrator/src/cli/delegationServer.js +567 -678
- package/dist/orchestrator/src/cli/delegationServerCliShell.js +52 -0
- package/dist/orchestrator/src/cli/delegationServerQuestionFlowShell.js +228 -0
- package/dist/orchestrator/src/cli/delegationServerToolDispatchShell.js +411 -0
- package/dist/orchestrator/src/cli/delegationServerTransport.js +274 -0
- package/dist/orchestrator/src/cli/delegationSetup.js +51 -171
- package/dist/orchestrator/src/cli/devtoolsCliShell.js +34 -0
- package/dist/orchestrator/src/cli/doctor.js +542 -122
- package/dist/orchestrator/src/cli/doctorCliRequestShell.js +72 -0
- package/dist/orchestrator/src/cli/doctorCliShell.js +138 -0
- package/dist/orchestrator/src/cli/doctorUsage.js +136 -16
- package/dist/orchestrator/src/cli/exec/experience.js +16 -2
- package/dist/orchestrator/src/cli/exec/summary.js +3 -0
- package/dist/orchestrator/src/cli/execCliShell.js +51 -0
- package/dist/orchestrator/src/cli/flowCliRequestShell.js +44 -0
- package/dist/orchestrator/src/cli/flowCliShell.js +239 -0
- package/dist/orchestrator/src/cli/frontendTestCliRequestShell.js +80 -0
- package/dist/orchestrator/src/cli/frontendTestCliShell.js +41 -0
- package/dist/orchestrator/src/cli/init.js +1 -0
- package/dist/orchestrator/src/cli/initCliShell.js +50 -0
- package/dist/orchestrator/src/cli/linearCliShell.js +1200 -0
- package/dist/orchestrator/src/cli/mcpEnableCliShell.js +132 -0
- package/dist/orchestrator/src/cli/metrics/metricsAggregator.js +3 -2
- package/dist/orchestrator/src/cli/metrics/metricsRecorder.js +56 -0
- package/dist/orchestrator/src/cli/orchestrator.js +66 -1376
- package/dist/orchestrator/src/cli/planCliShell.js +19 -0
- package/dist/orchestrator/src/cli/prCliShell.js +41 -0
- package/dist/orchestrator/src/cli/providerLinearChildLanePhaseContract.js +204 -0
- package/dist/orchestrator/src/cli/providerLinearChildLaneRunner.js +1772 -0
- package/dist/orchestrator/src/cli/providerLinearChildLaneShell.js +2420 -0
- package/dist/orchestrator/src/cli/providerLinearChildStreamShell.js +385 -0
- package/dist/orchestrator/src/cli/providerLinearWorkerRunner.js +5738 -0
- package/dist/orchestrator/src/cli/resumeCliShell.js +14 -0
- package/dist/orchestrator/src/cli/reviewCliLaunchShell.js +72 -0
- package/dist/orchestrator/src/cli/rlm/alignment.js +3 -3
- package/dist/orchestrator/src/cli/rlm/context.js +94 -7
- package/dist/orchestrator/src/cli/rlm/rlmCodexRuntimeShell.js +546 -0
- package/dist/orchestrator/src/cli/rlm/symbolic.js +4 -2
- package/dist/orchestrator/src/cli/rlmCliRequestShell.js +42 -0
- package/dist/orchestrator/src/cli/rlmCompletionCliShell.js +46 -0
- package/dist/orchestrator/src/cli/rlmLaunchCliShell.js +51 -0
- package/dist/orchestrator/src/cli/rlmRunner.js +83 -523
- package/dist/orchestrator/src/cli/run/blockMemory.js +500 -0
- package/dist/orchestrator/src/cli/run/manifest.js +410 -73
- package/dist/orchestrator/src/cli/run/manifestPersister.js +45 -14
- package/dist/orchestrator/src/cli/run/runMemoryController.js +216 -0
- package/dist/orchestrator/src/cli/run/source0.js +690 -0
- package/dist/orchestrator/src/cli/run/workspacePath.js +101 -0
- package/dist/orchestrator/src/cli/runtime/mode.js +2 -1
- package/dist/orchestrator/src/cli/runtime/provider.js +39 -2
- package/dist/orchestrator/src/cli/selfCheckCliShell.js +12 -0
- package/dist/orchestrator/src/cli/services/commandRunner.js +668 -18
- package/dist/orchestrator/src/cli/services/execRuntime.js +66 -1
- package/dist/orchestrator/src/cli/services/orchestratorAutoScoutEvidenceRecorder.js +71 -0
- package/dist/orchestrator/src/cli/services/orchestratorCloudBranchResolution.js +8 -0
- package/dist/orchestrator/src/cli/services/orchestratorCloudEnvironmentResolution.js +22 -0
- package/dist/orchestrator/src/cli/services/orchestratorCloudExecutionLifecycleShell.js +39 -0
- package/dist/orchestrator/src/cli/services/orchestratorCloudPromptBuilder.js +37 -0
- package/dist/orchestrator/src/cli/services/orchestratorCloudRouteFallbackContract.js +45 -0
- package/dist/orchestrator/src/cli/services/orchestratorCloudRouteShell.js +36 -0
- package/dist/orchestrator/src/cli/services/orchestratorCloudTargetExecutor.js +277 -0
- package/dist/orchestrator/src/cli/services/orchestratorControlPlaneLifecycle.js +98 -0
- package/dist/orchestrator/src/cli/services/orchestratorControlPlaneLifecycleShell.js +54 -0
- package/dist/orchestrator/src/cli/services/orchestratorExecutionLifecycle.js +112 -0
- package/dist/orchestrator/src/cli/services/orchestratorExecutionModePolicy.js +27 -0
- package/dist/orchestrator/src/cli/services/orchestratorExecutionRouteAdapterShell.js +59 -0
- package/dist/orchestrator/src/cli/services/orchestratorExecutionRouteDecisionShell.js +57 -0
- package/dist/orchestrator/src/cli/services/orchestratorExecutionRouteState.js +21 -0
- package/dist/orchestrator/src/cli/services/orchestratorExecutionRouter.js +2 -0
- package/dist/orchestrator/src/cli/services/orchestratorLocalPipelineExecutor.js +149 -0
- package/dist/orchestrator/src/cli/services/orchestratorLocalRouteShell.js +63 -0
- package/dist/orchestrator/src/cli/services/orchestratorPlanShell.js +54 -0
- package/dist/orchestrator/src/cli/services/orchestratorPlanTargetTracker.js +16 -0
- package/dist/orchestrator/src/cli/services/orchestratorResumePreparationShell.js +84 -0
- package/dist/orchestrator/src/cli/services/orchestratorResumeTokenValidation.js +15 -0
- package/dist/orchestrator/src/cli/services/orchestratorRunLifecycleCompletion.js +31 -0
- package/dist/orchestrator/src/cli/services/orchestratorRunLifecycleExecutionRegistration.js +37 -0
- package/dist/orchestrator/src/cli/services/orchestratorRunLifecycleOrchestrationShell.js +83 -0
- package/dist/orchestrator/src/cli/services/orchestratorRunLifecycleTaskManagerShell.js +37 -0
- package/dist/orchestrator/src/cli/services/orchestratorRuntimeManifestMutation.js +20 -0
- package/dist/orchestrator/src/cli/services/orchestratorStartPreparationShell.js +56 -0
- package/dist/orchestrator/src/cli/services/orchestratorStatusShell.js +70 -0
- package/dist/orchestrator/src/cli/services/pipelineResolver.js +7 -3
- package/dist/orchestrator/src/cli/services/plannerMemory.js +119 -0
- package/dist/orchestrator/src/cli/services/runPreparation.js +7 -3
- package/dist/orchestrator/src/cli/services/runSummaryWriter.js +9 -0
- package/dist/orchestrator/src/cli/setupBootstrapShell.js +114 -0
- package/dist/orchestrator/src/cli/setupCliShell.js +51 -0
- package/dist/orchestrator/src/cli/skillsCliShell.js +56 -0
- package/dist/orchestrator/src/cli/startCliRequestShell.js +53 -0
- package/dist/orchestrator/src/cli/startCliShell.js +68 -0
- package/dist/orchestrator/src/cli/statusCliShell.js +22 -0
- package/dist/orchestrator/src/cli/utils/authProvenanceFingerprint.js +27 -0
- package/dist/orchestrator/src/cli/utils/cloudPreflight.js +83 -1
- package/dist/orchestrator/src/cli/utils/delegationConfigParser.js +250 -0
- package/dist/orchestrator/src/cli/utils/delegationMcpHealth.js +1382 -0
- package/dist/orchestrator/src/cli/utils/devtools.js +2 -54
- package/dist/orchestrator/src/cli/utils/mcpServerEntry.js +53 -0
- package/dist/orchestrator/src/cli/utils/packageProgramResolver.js +151 -0
- package/dist/orchestrator/src/cli/utils/providerOverrideEnv.js +71 -0
- package/dist/orchestrator/src/cli/utils/trailingJsonObject.js +59 -0
- package/dist/orchestrator/src/learning/crystalizer.js +2 -2
- package/dist/orchestrator/src/persistence/ExperienceStore.js +233 -49
- package/dist/orchestrator/src/persistence/TaskStateStore.js +6 -6
- package/dist/orchestrator/src/persistence/lockFile.js +70 -4
- package/dist/orchestrator/src/persistence/sanitizeIdentifier.js +39 -0
- package/dist/orchestrator/src/sync/createCloudSyncWorker.js +3 -2
- package/dist/orchestrator/src/utils/atomicWrite.js +17 -2
- package/dist/packages/orchestrator/src/exec/unified-exec.js +99 -6
- package/dist/packages/orchestrator/src/instructions/promptPacks.js +150 -19
- package/dist/packages/sdk-node/src/orchestrator.js +137 -13
- package/dist/packages/shared/config/designConfig.js +8 -1
- package/dist/packages/shared/streams/stdio.js +1 -1
- package/dist/scripts/design/pipeline/permit.js +15 -0
- package/dist/scripts/lib/docs-catalog.js +365 -0
- package/dist/scripts/lib/docs-helpers.js +87 -5
- package/dist/scripts/lib/pr-watch-merge.js +1088 -80
- package/dist/scripts/lib/provider-run-contract.js +26 -0
- package/dist/scripts/lib/review-command-intent-classification.js +532 -0
- package/dist/scripts/lib/review-command-probe-classification.js +385 -0
- package/dist/scripts/lib/review-execution-boundary-preflight.js +279 -0
- package/dist/scripts/lib/review-execution-runtime.js +753 -0
- package/dist/scripts/lib/review-execution-state.js +1144 -0
- package/dist/scripts/lib/review-execution-telemetry.js +215 -0
- package/dist/scripts/lib/review-inspection-target-parsing.js +78 -0
- package/dist/scripts/lib/review-launch-attempt.js +601 -0
- package/dist/scripts/lib/review-meta-surface-boundary-analysis.js +300 -0
- package/dist/scripts/lib/review-meta-surface-normalization.js +746 -0
- package/dist/scripts/lib/review-non-interactive-handoff.js +61 -0
- package/dist/scripts/lib/review-prompt-context.js +376 -0
- package/dist/scripts/lib/review-scope-advisory.js +286 -0
- package/dist/scripts/lib/review-scope-paths.js +123 -0
- package/dist/scripts/lib/review-shell-command-parser.js +389 -0
- package/dist/scripts/lib/review-shell-env-interpreter.js +340 -0
- package/dist/scripts/lib/run-manifests.js +192 -36
- package/dist/scripts/lib/spark-policy-classifier.js +593 -0
- package/dist/scripts/run-review.js +507 -1777
- package/docs/public/downstream-setup.md +106 -0
- package/docs/public/provider-onboarding.md +173 -0
- package/package.json +30 -11
- package/plugins/codex-orchestrator/.codex-plugin/plugin.json +30 -0
- package/plugins/codex-orchestrator/.mcp.json +13 -0
- package/plugins/codex-orchestrator/launcher.mjs +359 -0
- package/schemas/manifest.json +395 -0
- package/skills/chrome-devtools/SKILL.md +1 -1
- package/skills/codex-orchestrator/SKILL.md +83 -0
- package/skills/collab-subagents-first/SKILL.md +2 -1
- package/skills/delegation-usage/DELEGATION_GUIDE.md +24 -11
- package/skills/delegation-usage/SKILL.md +20 -13
- package/skills/land/SKILL.md +77 -0
- package/skills/linear/SKILL.md +255 -0
- package/skills/release/SKILL.md +47 -3
- package/skills/standalone-review/SKILL.md +6 -1
- package/templates/README.md +4 -2
- package/templates/codex/.codex/agents/awaiter-high.toml +2 -2
- package/templates/codex/.codex/agents/explorer-fast.toml +1 -0
- package/templates/codex/.codex/agents/worker-complex.toml +1 -1
- package/templates/codex/.codex/config.toml +3 -4
- package/templates/codex/.codex/providers/README.md +13 -0
- package/templates/codex/.codex/providers/control.example.json +18 -0
- package/templates/codex/.codex/providers/provider.env.example +15 -0
- package/templates/codex/AGENTS.md +12 -7
- package/templates/codex/mcp-client.json +5 -1
- package/docs/README.md +0 -307
- package/docs/assets/setup.gif +0 -0
|
@@ -0,0 +1,500 @@
|
|
|
1
|
+
import { mkdir, readFile, realpath } from 'node:fs/promises';
|
|
2
|
+
import { isAbsolute, join, relative, resolve } from 'node:path';
|
|
3
|
+
import { buildContextObject } from '../rlm/context.js';
|
|
4
|
+
import { relativeToRepo } from './runPaths.js';
|
|
5
|
+
import { writeJsonAtomic } from '../utils/fs.js';
|
|
6
|
+
const RUN_BLOCK_MEMORY_SCHEMA_VERSION = 1;
|
|
7
|
+
const RUN_BLOCK_MEMORY_DESCRIPTOR_KIND = 'index';
|
|
8
|
+
const RUN_BLOCK_MEMORY_INDEX_KIND = 'run_block_memory';
|
|
9
|
+
const RUN_BLOCK_MEMORY_BLOCK_KIND = 'run_block_memory_block';
|
|
10
|
+
const RUN_BLOCK_MEMORY_CHUNK_TARGET_BYTES = 65_536;
|
|
11
|
+
const RUN_BLOCK_MEMORY_CHUNK_OVERLAP_BYTES = 4_096;
|
|
12
|
+
const WINDOWS_DRIVE_PATH_RE = /^[A-Za-z]:/u;
|
|
13
|
+
function isRecord(value) {
|
|
14
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
15
|
+
}
|
|
16
|
+
function readNonEmptyString(value) {
|
|
17
|
+
if (typeof value !== 'string') {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const trimmed = value.trim();
|
|
21
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
22
|
+
}
|
|
23
|
+
function readInteger(value) {
|
|
24
|
+
if (typeof value === 'number' && Number.isInteger(value)) {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
function readStringArray(value) {
|
|
30
|
+
if (!Array.isArray(value)) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const strings = value
|
|
34
|
+
.map((entry) => readNonEmptyString(entry))
|
|
35
|
+
.filter((entry) => entry !== null);
|
|
36
|
+
return strings.length === value.length ? strings : null;
|
|
37
|
+
}
|
|
38
|
+
function readRunBlockMemoryCandidate(input) {
|
|
39
|
+
if (!isRecord(input)) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
if (isRecord(input.memory) && isRecord(input.memory.block_memory)) {
|
|
43
|
+
return input.memory.block_memory;
|
|
44
|
+
}
|
|
45
|
+
return input;
|
|
46
|
+
}
|
|
47
|
+
export function readRunBlockMemoryDescriptor(input) {
|
|
48
|
+
const candidate = readRunBlockMemoryCandidate(input);
|
|
49
|
+
if (!candidate) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const schemaVersion = readInteger(candidate.schema_version);
|
|
53
|
+
const kind = readNonEmptyString(candidate.kind);
|
|
54
|
+
const indexPath = readNonEmptyString(candidate.index_path);
|
|
55
|
+
const generatedAt = readNonEmptyString(candidate.generated_at);
|
|
56
|
+
const blockCount = readInteger(candidate.block_count);
|
|
57
|
+
if (schemaVersion === null ||
|
|
58
|
+
schemaVersion < 1 ||
|
|
59
|
+
kind !== RUN_BLOCK_MEMORY_DESCRIPTOR_KIND ||
|
|
60
|
+
!indexPath ||
|
|
61
|
+
!generatedAt ||
|
|
62
|
+
blockCount === null ||
|
|
63
|
+
blockCount < 1) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
schema_version: schemaVersion,
|
|
68
|
+
kind: RUN_BLOCK_MEMORY_DESCRIPTOR_KIND,
|
|
69
|
+
index_path: indexPath,
|
|
70
|
+
generated_at: generatedAt,
|
|
71
|
+
block_count: blockCount
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function readRunBlockMemoryEventQuery(input) {
|
|
75
|
+
if (!isRecord(input)) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
const eventTypes = readStringArray(input.event_types);
|
|
79
|
+
const stageId = input.stage_id === null ? null : readNonEmptyString(input.stage_id);
|
|
80
|
+
const stageIndex = input.stage_index === null ? null : readInteger(input.stage_index);
|
|
81
|
+
if (!eventTypes ||
|
|
82
|
+
eventTypes.length === 0 ||
|
|
83
|
+
input.stage_id === undefined ||
|
|
84
|
+
input.stage_index === undefined ||
|
|
85
|
+
(input.stage_id !== null && stageId === null) ||
|
|
86
|
+
(input.stage_index !== null && stageIndex === null)) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
event_types: eventTypes,
|
|
91
|
+
stage_id: stageId,
|
|
92
|
+
stage_index: stageIndex
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function readRunBlockMemoryTraceability(input) {
|
|
96
|
+
if (!isRecord(input)) {
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
const manifestPath = readNonEmptyString(input.manifest_path);
|
|
100
|
+
const runSummaryPath = input.run_summary_path === null ? null : readNonEmptyString(input.run_summary_path);
|
|
101
|
+
const eventsPath = readNonEmptyString(input.events_path);
|
|
102
|
+
const runnerLogPath = input.runner_log_path === null ? null : readNonEmptyString(input.runner_log_path);
|
|
103
|
+
const commandLogPath = input.command_log_path === null ? null : readNonEmptyString(input.command_log_path);
|
|
104
|
+
const subRunManifestPath = input.sub_run_manifest_path === null ? null : readNonEmptyString(input.sub_run_manifest_path);
|
|
105
|
+
const eventQuery = readRunBlockMemoryEventQuery(input.event_query);
|
|
106
|
+
if (!manifestPath ||
|
|
107
|
+
!eventsPath ||
|
|
108
|
+
input.run_summary_path === undefined ||
|
|
109
|
+
input.runner_log_path === undefined ||
|
|
110
|
+
input.command_log_path === undefined ||
|
|
111
|
+
input.sub_run_manifest_path === undefined ||
|
|
112
|
+
(input.run_summary_path !== null && runSummaryPath === null) ||
|
|
113
|
+
(input.runner_log_path !== null && runnerLogPath === null) ||
|
|
114
|
+
(input.command_log_path !== null && commandLogPath === null) ||
|
|
115
|
+
(input.sub_run_manifest_path !== null && subRunManifestPath === null) ||
|
|
116
|
+
!eventQuery) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
manifest_path: manifestPath,
|
|
121
|
+
run_summary_path: runSummaryPath,
|
|
122
|
+
events_path: eventsPath,
|
|
123
|
+
runner_log_path: runnerLogPath,
|
|
124
|
+
command_log_path: commandLogPath,
|
|
125
|
+
sub_run_manifest_path: subRunManifestPath,
|
|
126
|
+
event_query: eventQuery
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function readRunBlockMemoryBlockDescriptor(input) {
|
|
130
|
+
if (!isRecord(input)) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const id = readNonEmptyString(input.id);
|
|
134
|
+
const phaseKind = readNonEmptyString(input.phase_kind);
|
|
135
|
+
const title = readNonEmptyString(input.title);
|
|
136
|
+
const status = readNonEmptyString(input.status);
|
|
137
|
+
const summary = input.summary === null ? null : readNonEmptyString(input.summary);
|
|
138
|
+
const pointer = readNonEmptyString(input.pointer);
|
|
139
|
+
const objectId = readNonEmptyString(input.object_id);
|
|
140
|
+
const dirPath = readNonEmptyString(input.dir_path);
|
|
141
|
+
const indexPath = readNonEmptyString(input.index_path);
|
|
142
|
+
const sourcePath = readNonEmptyString(input.source_path);
|
|
143
|
+
const byteLength = readInteger(input.byte_length);
|
|
144
|
+
const chunkCount = readInteger(input.chunk_count);
|
|
145
|
+
const createdAt = readNonEmptyString(input.created_at);
|
|
146
|
+
const traceability = readRunBlockMemoryTraceability(input.traceability);
|
|
147
|
+
if (!id ||
|
|
148
|
+
(phaseKind !== 'run' && phaseKind !== 'stage') ||
|
|
149
|
+
!title ||
|
|
150
|
+
!status ||
|
|
151
|
+
input.summary === undefined ||
|
|
152
|
+
(input.summary !== null && summary === null) ||
|
|
153
|
+
!pointer ||
|
|
154
|
+
!objectId ||
|
|
155
|
+
!dirPath ||
|
|
156
|
+
!indexPath ||
|
|
157
|
+
!sourcePath ||
|
|
158
|
+
byteLength === null ||
|
|
159
|
+
byteLength < 0 ||
|
|
160
|
+
chunkCount === null ||
|
|
161
|
+
chunkCount < 1 ||
|
|
162
|
+
!createdAt ||
|
|
163
|
+
!traceability) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
id,
|
|
168
|
+
phase_kind: phaseKind,
|
|
169
|
+
title,
|
|
170
|
+
status,
|
|
171
|
+
summary,
|
|
172
|
+
pointer,
|
|
173
|
+
object_id: objectId,
|
|
174
|
+
dir_path: dirPath,
|
|
175
|
+
index_path: indexPath,
|
|
176
|
+
source_path: sourcePath,
|
|
177
|
+
byte_length: byteLength,
|
|
178
|
+
chunk_count: chunkCount,
|
|
179
|
+
created_at: createdAt,
|
|
180
|
+
traceability
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function resolveRepoRelativePath(repoRoot, candidate, field) {
|
|
184
|
+
const normalizedCandidate = candidate.replaceAll('\\', '/');
|
|
185
|
+
if (isAbsolute(candidate) ||
|
|
186
|
+
WINDOWS_DRIVE_PATH_RE.test(candidate) ||
|
|
187
|
+
normalizedCandidate.startsWith('/')) {
|
|
188
|
+
throw new Error(`block_memory ${field} must be repo-relative`);
|
|
189
|
+
}
|
|
190
|
+
if (normalizedCandidate.split('/').some((segment) => segment === '..')) {
|
|
191
|
+
throw new Error(`block_memory ${field} must not traverse outside the repo root`);
|
|
192
|
+
}
|
|
193
|
+
const resolvedPath = resolve(repoRoot, candidate);
|
|
194
|
+
const relativePath = relative(repoRoot, resolvedPath);
|
|
195
|
+
if (!relativePath ||
|
|
196
|
+
relativePath === '.' ||
|
|
197
|
+
isAbsolute(relativePath) ||
|
|
198
|
+
WINDOWS_DRIVE_PATH_RE.test(relativePath) ||
|
|
199
|
+
relativePath.split(/[\\/]+/u).some((segment) => segment === '..')) {
|
|
200
|
+
throw new Error(`block_memory ${field} escapes the repo root`);
|
|
201
|
+
}
|
|
202
|
+
return resolvedPath;
|
|
203
|
+
}
|
|
204
|
+
function assertContainedWithinRepoRoot(repoRoot, candidatePath, field) {
|
|
205
|
+
const relativePath = relative(repoRoot, candidatePath);
|
|
206
|
+
if (!relativePath ||
|
|
207
|
+
relativePath === '.' ||
|
|
208
|
+
isAbsolute(relativePath) ||
|
|
209
|
+
WINDOWS_DRIVE_PATH_RE.test(relativePath) ||
|
|
210
|
+
relativePath.split(/[\\/]+/u).some((segment) => segment === '..')) {
|
|
211
|
+
throw new Error(`block_memory ${field} escapes the repo root`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
export async function readRunBlockMemoryIndex(repoRoot, descriptor) {
|
|
215
|
+
const resolvedRepoRoot = resolve(repoRoot);
|
|
216
|
+
const resolvedIndexPath = resolveRepoRelativePath(resolvedRepoRoot, descriptor.index_path, 'index_path');
|
|
217
|
+
const canonicalRepoRoot = await realpath(resolvedRepoRoot);
|
|
218
|
+
let canonicalIndexPath;
|
|
219
|
+
try {
|
|
220
|
+
canonicalIndexPath = await realpath(resolvedIndexPath);
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
assertContainedWithinRepoRoot(canonicalRepoRoot, canonicalIndexPath, 'index_path');
|
|
226
|
+
let parsed;
|
|
227
|
+
try {
|
|
228
|
+
const raw = await readFile(canonicalIndexPath, 'utf8');
|
|
229
|
+
parsed = JSON.parse(raw);
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
if (!isRecord(parsed)) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
const schemaVersion = readInteger(parsed.schema_version);
|
|
238
|
+
const kind = readNonEmptyString(parsed.kind);
|
|
239
|
+
const generatedAt = readNonEmptyString(parsed.generated_at);
|
|
240
|
+
const runContract = isRecord(parsed.run_contract) ? parsed.run_contract : null;
|
|
241
|
+
const artifacts = isRecord(parsed.artifacts) ? parsed.artifacts : null;
|
|
242
|
+
const decodedBlocks = Array.isArray(parsed.blocks)
|
|
243
|
+
? parsed.blocks.map((entry) => readRunBlockMemoryBlockDescriptor(entry))
|
|
244
|
+
: null;
|
|
245
|
+
const blocks = decodedBlocks?.filter((entry) => entry !== null) ?? null;
|
|
246
|
+
if (schemaVersion !== RUN_BLOCK_MEMORY_SCHEMA_VERSION ||
|
|
247
|
+
kind !== RUN_BLOCK_MEMORY_INDEX_KIND ||
|
|
248
|
+
!generatedAt ||
|
|
249
|
+
!runContract ||
|
|
250
|
+
!artifacts ||
|
|
251
|
+
!decodedBlocks ||
|
|
252
|
+
!blocks ||
|
|
253
|
+
blocks.length !== decodedBlocks.length) {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
const taskId = readNonEmptyString(runContract.task_id);
|
|
257
|
+
const runId = readNonEmptyString(runContract.run_id);
|
|
258
|
+
const pipelineId = readNonEmptyString(runContract.pipeline_id);
|
|
259
|
+
const pipelineTitle = readNonEmptyString(runContract.pipeline_title);
|
|
260
|
+
const manifestPath = readNonEmptyString(artifacts.manifest_path);
|
|
261
|
+
const runSummaryPath = artifacts.run_summary_path === null ? null : readNonEmptyString(artifacts.run_summary_path);
|
|
262
|
+
const eventsPath = readNonEmptyString(artifacts.events_path);
|
|
263
|
+
const runnerLogPath = artifacts.runner_log_path === null ? null : readNonEmptyString(artifacts.runner_log_path);
|
|
264
|
+
if (!taskId ||
|
|
265
|
+
!runId ||
|
|
266
|
+
!pipelineId ||
|
|
267
|
+
!pipelineTitle ||
|
|
268
|
+
!manifestPath ||
|
|
269
|
+
!eventsPath ||
|
|
270
|
+
artifacts.run_summary_path === undefined ||
|
|
271
|
+
artifacts.runner_log_path === undefined ||
|
|
272
|
+
(artifacts.run_summary_path !== null && runSummaryPath === null) ||
|
|
273
|
+
(artifacts.runner_log_path !== null && runnerLogPath === null) ||
|
|
274
|
+
blocks.length < 1) {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
schema_version: schemaVersion,
|
|
279
|
+
kind: RUN_BLOCK_MEMORY_INDEX_KIND,
|
|
280
|
+
generated_at: generatedAt,
|
|
281
|
+
run_contract: {
|
|
282
|
+
task_id: taskId,
|
|
283
|
+
run_id: runId,
|
|
284
|
+
pipeline_id: pipelineId,
|
|
285
|
+
pipeline_title: pipelineTitle
|
|
286
|
+
},
|
|
287
|
+
artifacts: {
|
|
288
|
+
manifest_path: manifestPath,
|
|
289
|
+
run_summary_path: runSummaryPath,
|
|
290
|
+
events_path: eventsPath,
|
|
291
|
+
runner_log_path: runnerLogPath
|
|
292
|
+
},
|
|
293
|
+
blocks
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
export function buildRunBlockMemoryPromptLines(params) {
|
|
297
|
+
const { descriptor, index } = params;
|
|
298
|
+
if (!descriptor || !index) {
|
|
299
|
+
return [];
|
|
300
|
+
}
|
|
301
|
+
const maxBlocks = Math.max(1, Math.trunc(params.maxBlocks ?? 3));
|
|
302
|
+
const blockCount = index.blocks.length;
|
|
303
|
+
const lines = [
|
|
304
|
+
'Shared block memory:',
|
|
305
|
+
`- Index: \`${descriptor.index_path}\``,
|
|
306
|
+
`- Blocks: ${blockCount}`
|
|
307
|
+
];
|
|
308
|
+
for (const block of index.blocks.slice(0, maxBlocks)) {
|
|
309
|
+
lines.push(`- Block \`${block.id}\` (${block.phase_kind}, ${block.status}): \`${block.pointer}\``);
|
|
310
|
+
}
|
|
311
|
+
if (index.blocks.length > maxBlocks) {
|
|
312
|
+
lines.push(`- Additional blocks: ${index.blocks.length - maxBlocks} more in \`${descriptor.index_path}\``);
|
|
313
|
+
}
|
|
314
|
+
return lines;
|
|
315
|
+
}
|
|
316
|
+
function resolveRunSummaryArtifactPath(params) {
|
|
317
|
+
return (params.manifest.run_summary_path ??
|
|
318
|
+
relativeToRepo(params.env, join(params.paths.runDir, 'run-summary.json')));
|
|
319
|
+
}
|
|
320
|
+
function sanitizeBlockSegment(input) {
|
|
321
|
+
const sanitized = input
|
|
322
|
+
.trim()
|
|
323
|
+
.replace(/[^A-Za-z0-9._-]+/gu, '-')
|
|
324
|
+
.replace(/^-+/u, '')
|
|
325
|
+
.replace(/-+$/u, '');
|
|
326
|
+
return sanitized.length > 0 ? sanitized : 'block';
|
|
327
|
+
}
|
|
328
|
+
function findChildManifestPath(manifest, subRunId) {
|
|
329
|
+
if (!subRunId) {
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
const child = manifest.child_runs.find((entry) => entry.run_id === subRunId);
|
|
333
|
+
return child?.manifest ?? null;
|
|
334
|
+
}
|
|
335
|
+
function buildRunTraceability(params) {
|
|
336
|
+
return {
|
|
337
|
+
manifest_path: relativeToRepo(params.env, params.paths.manifestPath),
|
|
338
|
+
run_summary_path: resolveRunSummaryArtifactPath(params),
|
|
339
|
+
events_path: relativeToRepo(params.env, params.paths.eventsPath),
|
|
340
|
+
runner_log_path: params.manifest.log_path ?? relativeToRepo(params.env, params.paths.logPath),
|
|
341
|
+
command_log_path: null,
|
|
342
|
+
sub_run_manifest_path: null,
|
|
343
|
+
event_query: {
|
|
344
|
+
event_types: ['run_started', 'run_completed'],
|
|
345
|
+
stage_id: null,
|
|
346
|
+
stage_index: null
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function buildStageTraceability(params) {
|
|
351
|
+
return {
|
|
352
|
+
manifest_path: relativeToRepo(params.env, params.paths.manifestPath),
|
|
353
|
+
run_summary_path: resolveRunSummaryArtifactPath(params),
|
|
354
|
+
events_path: relativeToRepo(params.env, params.paths.eventsPath),
|
|
355
|
+
runner_log_path: params.manifest.log_path ?? relativeToRepo(params.env, params.paths.logPath),
|
|
356
|
+
command_log_path: params.command.log_path ?? null,
|
|
357
|
+
sub_run_manifest_path: findChildManifestPath(params.manifest, params.command.sub_run_id),
|
|
358
|
+
event_query: {
|
|
359
|
+
event_types: ['step_started', 'step_completed', 'step_failed'],
|
|
360
|
+
stage_id: params.command.id,
|
|
361
|
+
stage_index: params.command.index
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
function buildRunBlockPayload(params) {
|
|
366
|
+
return {
|
|
367
|
+
schema_version: RUN_BLOCK_MEMORY_SCHEMA_VERSION,
|
|
368
|
+
kind: RUN_BLOCK_MEMORY_BLOCK_KIND,
|
|
369
|
+
generated_at: params.manifest.completed_at ?? params.manifest.updated_at,
|
|
370
|
+
block: {
|
|
371
|
+
id: 'run:completion',
|
|
372
|
+
phase_kind: 'run',
|
|
373
|
+
title: 'Run completion',
|
|
374
|
+
status: params.manifest.status,
|
|
375
|
+
summary: params.manifest.summary,
|
|
376
|
+
started_at: params.manifest.started_at,
|
|
377
|
+
completed_at: params.manifest.completed_at,
|
|
378
|
+
command: null
|
|
379
|
+
},
|
|
380
|
+
traceability: params.traceability
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function buildStageBlockPayload(params) {
|
|
384
|
+
return {
|
|
385
|
+
schema_version: RUN_BLOCK_MEMORY_SCHEMA_VERSION,
|
|
386
|
+
kind: RUN_BLOCK_MEMORY_BLOCK_KIND,
|
|
387
|
+
generated_at: params.manifest.completed_at ?? params.manifest.updated_at,
|
|
388
|
+
block: {
|
|
389
|
+
id: `stage:${params.command.id}`,
|
|
390
|
+
phase_kind: 'stage',
|
|
391
|
+
title: params.command.title,
|
|
392
|
+
status: params.command.status,
|
|
393
|
+
summary: params.command.summary,
|
|
394
|
+
started_at: params.command.started_at,
|
|
395
|
+
completed_at: params.command.completed_at,
|
|
396
|
+
command: {
|
|
397
|
+
index: params.command.index,
|
|
398
|
+
id: params.command.id,
|
|
399
|
+
kind: params.command.kind,
|
|
400
|
+
exit_code: params.command.exit_code,
|
|
401
|
+
sub_run_id: params.command.sub_run_id
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
traceability: params.traceability
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
async function materializeBlockDescriptor(params) {
|
|
408
|
+
const contextObject = await buildContextObject({
|
|
409
|
+
source: {
|
|
410
|
+
type: 'text',
|
|
411
|
+
value: `${JSON.stringify(params.payload, null, 2)}\n`
|
|
412
|
+
},
|
|
413
|
+
targetDir: params.targetDir,
|
|
414
|
+
chunking: {
|
|
415
|
+
targetBytes: RUN_BLOCK_MEMORY_CHUNK_TARGET_BYTES,
|
|
416
|
+
overlapBytes: RUN_BLOCK_MEMORY_CHUNK_OVERLAP_BYTES,
|
|
417
|
+
strategy: 'byte'
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
const firstChunk = contextObject.index.chunks[0];
|
|
421
|
+
if (!firstChunk) {
|
|
422
|
+
throw new Error('block_memory context object must contain at least one chunk');
|
|
423
|
+
}
|
|
424
|
+
return {
|
|
425
|
+
id: params.payload.block.id,
|
|
426
|
+
phase_kind: params.payload.block.phase_kind,
|
|
427
|
+
title: params.payload.block.title,
|
|
428
|
+
status: params.payload.block.status,
|
|
429
|
+
summary: params.payload.block.summary,
|
|
430
|
+
pointer: `ctx:${contextObject.index.object_id}#chunk:${firstChunk.id}`,
|
|
431
|
+
object_id: contextObject.index.object_id,
|
|
432
|
+
dir_path: relativeToRepo(params.env, params.targetDir),
|
|
433
|
+
index_path: relativeToRepo(params.env, contextObject.indexPath),
|
|
434
|
+
source_path: relativeToRepo(params.env, contextObject.sourcePath),
|
|
435
|
+
byte_length: contextObject.index.source.byte_length,
|
|
436
|
+
chunk_count: contextObject.index.chunks.length,
|
|
437
|
+
created_at: contextObject.index.created_at,
|
|
438
|
+
traceability: params.payload.traceability
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
export async function materializeRunBlockMemory(params) {
|
|
442
|
+
const rootDir = join(params.paths.runDir, 'memory', 'block-memory');
|
|
443
|
+
await mkdir(rootDir, { recursive: true });
|
|
444
|
+
const blocks = [];
|
|
445
|
+
blocks.push(await materializeBlockDescriptor({
|
|
446
|
+
env: params.env,
|
|
447
|
+
targetDir: join(rootDir, 'blocks', '00-run-completion'),
|
|
448
|
+
payload: buildRunBlockPayload({
|
|
449
|
+
manifest: params.manifest,
|
|
450
|
+
traceability: buildRunTraceability(params)
|
|
451
|
+
})
|
|
452
|
+
}));
|
|
453
|
+
const emittedCommands = params.manifest.commands.filter((command) => command.status !== 'pending');
|
|
454
|
+
for (const command of emittedCommands) {
|
|
455
|
+
const segment = `${String(command.index).padStart(2, '0')}-${sanitizeBlockSegment(command.id)}`;
|
|
456
|
+
blocks.push(await materializeBlockDescriptor({
|
|
457
|
+
env: params.env,
|
|
458
|
+
targetDir: join(rootDir, 'blocks', segment),
|
|
459
|
+
payload: buildStageBlockPayload({
|
|
460
|
+
manifest: params.manifest,
|
|
461
|
+
command,
|
|
462
|
+
traceability: buildStageTraceability({
|
|
463
|
+
env: params.env,
|
|
464
|
+
paths: params.paths,
|
|
465
|
+
manifest: params.manifest,
|
|
466
|
+
command
|
|
467
|
+
})
|
|
468
|
+
})
|
|
469
|
+
}));
|
|
470
|
+
}
|
|
471
|
+
const indexPath = join(rootDir, 'index.json');
|
|
472
|
+
const index = {
|
|
473
|
+
schema_version: RUN_BLOCK_MEMORY_SCHEMA_VERSION,
|
|
474
|
+
kind: RUN_BLOCK_MEMORY_INDEX_KIND,
|
|
475
|
+
generated_at: params.manifest.completed_at ?? params.manifest.updated_at,
|
|
476
|
+
run_contract: {
|
|
477
|
+
task_id: params.manifest.task_id,
|
|
478
|
+
run_id: params.manifest.run_id,
|
|
479
|
+
pipeline_id: params.manifest.pipeline_id,
|
|
480
|
+
pipeline_title: params.manifest.pipeline_title
|
|
481
|
+
},
|
|
482
|
+
artifacts: {
|
|
483
|
+
manifest_path: relativeToRepo(params.env, params.paths.manifestPath),
|
|
484
|
+
run_summary_path: resolveRunSummaryArtifactPath(params),
|
|
485
|
+
events_path: relativeToRepo(params.env, params.paths.eventsPath),
|
|
486
|
+
runner_log_path: params.manifest.log_path ?? relativeToRepo(params.env, params.paths.logPath)
|
|
487
|
+
},
|
|
488
|
+
blocks
|
|
489
|
+
};
|
|
490
|
+
await writeJsonAtomic(indexPath, index);
|
|
491
|
+
return {
|
|
492
|
+
block_memory: {
|
|
493
|
+
schema_version: RUN_BLOCK_MEMORY_SCHEMA_VERSION,
|
|
494
|
+
kind: RUN_BLOCK_MEMORY_DESCRIPTOR_KIND,
|
|
495
|
+
index_path: relativeToRepo(params.env, indexPath),
|
|
496
|
+
generated_at: index.generated_at,
|
|
497
|
+
block_count: blocks.length
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
}
|