mcoda 0.1.2 → 0.1.4
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/CHANGELOG.md +2 -2
- package/README.md +9 -300
- package/dist/bin/McodaEntrypoint.d.ts +5 -0
- package/dist/bin/McodaEntrypoint.d.ts.map +1 -0
- package/dist/bin/McodaEntrypoint.js +175 -0
- package/dist/commands/agents/AgentsCommands.d.ts +4 -0
- package/dist/commands/agents/AgentsCommands.d.ts.map +1 -0
- package/dist/commands/agents/AgentsCommands.js +376 -0
- package/dist/commands/agents/GatewayAgentCommand.d.ts +4 -0
- package/dist/commands/agents/GatewayAgentCommand.d.ts.map +1 -0
- package/dist/commands/agents/GatewayAgentCommand.js +583 -0
- package/dist/commands/agents/TestAgentCommand.d.ts +4 -0
- package/dist/commands/agents/TestAgentCommand.d.ts.map +1 -0
- package/dist/commands/agents/TestAgentCommand.js +57 -0
- package/dist/commands/backlog/BacklogCommands.d.ts +17 -0
- package/dist/commands/backlog/BacklogCommands.d.ts.map +1 -0
- package/dist/commands/backlog/BacklogCommands.js +260 -0
- package/dist/commands/backlog/OrderTasksCommand.d.ts +16 -0
- package/dist/commands/backlog/OrderTasksCommand.d.ts.map +1 -0
- package/dist/commands/backlog/OrderTasksCommand.js +211 -0
- package/dist/commands/backlog/TaskShowCommands.d.ts +16 -0
- package/dist/commands/backlog/TaskShowCommands.d.ts.map +1 -0
- package/dist/commands/backlog/TaskShowCommands.js +275 -0
- package/dist/commands/docs/DocsCommands.d.ts +37 -0
- package/dist/commands/docs/DocsCommands.d.ts.map +1 -0
- package/dist/commands/docs/DocsCommands.js +381 -0
- package/dist/commands/estimate/EstimateCommands.d.ts +24 -0
- package/dist/commands/estimate/EstimateCommands.d.ts.map +1 -0
- package/dist/commands/estimate/EstimateCommands.js +259 -0
- package/dist/commands/jobs/JobsCommands.d.ts +24 -0
- package/dist/commands/jobs/JobsCommands.d.ts.map +1 -0
- package/dist/commands/jobs/JobsCommands.js +535 -0
- package/dist/commands/openapi/OpenapiCommands.d.ts +14 -0
- package/dist/commands/openapi/OpenapiCommands.d.ts.map +1 -0
- package/dist/commands/openapi/OpenapiCommands.js +157 -0
- package/dist/commands/planning/CreateTasksCommand.d.ts +17 -0
- package/dist/commands/planning/CreateTasksCommand.d.ts.map +1 -0
- package/dist/commands/planning/CreateTasksCommand.js +134 -0
- package/dist/commands/planning/MigrateTasksCommand.d.ts +15 -0
- package/dist/commands/planning/MigrateTasksCommand.d.ts.map +1 -0
- package/dist/commands/planning/MigrateTasksCommand.js +95 -0
- package/dist/commands/planning/PlanningCommands.d.ts +3 -0
- package/dist/commands/planning/PlanningCommands.d.ts.map +1 -0
- package/dist/commands/planning/PlanningCommands.js +2 -0
- package/dist/commands/planning/QaTasksCommand.d.ts +30 -0
- package/dist/commands/planning/QaTasksCommand.d.ts.map +1 -0
- package/dist/commands/planning/QaTasksCommand.js +293 -0
- package/dist/commands/planning/RefineTasksCommand.d.ts +30 -0
- package/dist/commands/planning/RefineTasksCommand.d.ts.map +1 -0
- package/dist/commands/planning/RefineTasksCommand.js +365 -0
- package/dist/commands/review/CodeReviewCommand.d.ts +21 -0
- package/dist/commands/review/CodeReviewCommand.d.ts.map +1 -0
- package/dist/commands/review/CodeReviewCommand.js +236 -0
- package/dist/commands/routing/RoutingCommands.d.ts +7 -0
- package/dist/commands/routing/RoutingCommands.d.ts.map +1 -0
- package/dist/commands/routing/RoutingCommands.js +484 -0
- package/dist/commands/telemetry/TelemetryCommands.d.ts +26 -0
- package/dist/commands/telemetry/TelemetryCommands.d.ts.map +1 -0
- package/dist/commands/telemetry/TelemetryCommands.js +313 -0
- package/dist/commands/update/UpdateCommands.d.ts +4 -0
- package/dist/commands/update/UpdateCommands.d.ts.map +1 -0
- package/dist/commands/update/UpdateCommands.js +280 -0
- package/dist/commands/work/WorkOnTasksCommand.d.ts +21 -0
- package/dist/commands/work/WorkOnTasksCommand.d.ts.map +1 -0
- package/dist/commands/work/WorkOnTasksCommand.js +238 -0
- package/dist/commands/workspace/SetWorkspaceCommand.d.ts +9 -0
- package/dist/commands/workspace/SetWorkspaceCommand.d.ts.map +1 -0
- package/dist/commands/workspace/SetWorkspaceCommand.js +128 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/package.json +31 -16
- package/.editorconfig +0 -9
- package/.eslintrc.cjs +0 -12
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -29
- package/.github/ISSUE_TEMPLATE/config.yml +0 -5
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -19
- package/.github/workflows/ci.yml +0 -37
- package/.github/workflows/nightly.yml +0 -38
- package/.github/workflows/release-dry-run.yml +0 -40
- package/.github/workflows/release-please.yml +0 -22
- package/.github/workflows/release.yml +0 -139
- package/.prettierrc +0 -5
- package/.release-please-manifest.json +0 -8
- package/CLA.md +0 -42
- package/CONTRIBUTING.md +0 -38
- package/docs/oss_publishing_plan.md +0 -41
- package/docs/pdr/.gitkeep +0 -0
- package/docs/quality_gates.md +0 -32
- package/docs/rfp/.gitkeep +0 -0
- package/docs/sds/sds.md +0 -11963
- package/docs/usage.md +0 -72
- package/openapi/gen-openapi.ts +0 -1
- package/openapi/generated/clients/.gitkeep +0 -0
- package/openapi/generated/types/.gitkeep +0 -0
- package/openapi/generated/types/index.ts +0 -118
- package/openapi/mcoda.yaml +0 -2063
- package/pack-mcoda.sh +0 -88
- package/packages/agents/CHANGELOG.md +0 -7
- package/packages/agents/LICENSE +0 -21
- package/packages/agents/README.md +0 -9
- package/packages/agents/package.json +0 -41
- package/packages/agents/src/AgentService/.gitkeep +0 -0
- package/packages/agents/src/AgentService/AgentService.d.ts +0 -21
- package/packages/agents/src/AgentService/AgentService.d.ts.map +0 -1
- package/packages/agents/src/AgentService/AgentService.js +0 -141
- package/packages/agents/src/AgentService/AgentService.ts +0 -308
- package/packages/agents/src/__tests__/AgentService.test.ts +0 -284
- package/packages/agents/src/adapters/AdapterTypes.d.ts +0 -29
- package/packages/agents/src/adapters/AdapterTypes.d.ts.map +0 -1
- package/packages/agents/src/adapters/AdapterTypes.js +0 -1
- package/packages/agents/src/adapters/AdapterTypes.ts +0 -32
- package/packages/agents/src/adapters/codex/.gitkeep +0 -0
- package/packages/agents/src/adapters/codex/CodexAdapter.d.ts +0 -11
- package/packages/agents/src/adapters/codex/CodexAdapter.d.ts.map +0 -1
- package/packages/agents/src/adapters/codex/CodexAdapter.js +0 -43
- package/packages/agents/src/adapters/codex/CodexAdapter.ts +0 -63
- package/packages/agents/src/adapters/codex/CodexCliRunner.ts +0 -154
- package/packages/agents/src/adapters/gemini/.gitkeep +0 -0
- package/packages/agents/src/adapters/gemini/GeminiAdapter.d.ts +0 -11
- package/packages/agents/src/adapters/gemini/GeminiAdapter.d.ts.map +0 -1
- package/packages/agents/src/adapters/gemini/GeminiAdapter.js +0 -42
- package/packages/agents/src/adapters/gemini/GeminiAdapter.ts +0 -58
- package/packages/agents/src/adapters/gemini/GeminiCliRunner.ts +0 -75
- package/packages/agents/src/adapters/local/.gitkeep +0 -0
- package/packages/agents/src/adapters/local/LocalAdapter.d.ts +0 -11
- package/packages/agents/src/adapters/local/LocalAdapter.d.ts.map +0 -1
- package/packages/agents/src/adapters/local/LocalAdapter.js +0 -38
- package/packages/agents/src/adapters/local/LocalAdapter.ts +0 -43
- package/packages/agents/src/adapters/ollama/OllamaCliAdapter.ts +0 -58
- package/packages/agents/src/adapters/ollama/OllamaCliRunner.ts +0 -70
- package/packages/agents/src/adapters/ollama/OllamaRemoteAdapter.ts +0 -205
- package/packages/agents/src/adapters/openai/.gitkeep +0 -0
- package/packages/agents/src/adapters/openai/OpenAiAdapter.d.ts +0 -11
- package/packages/agents/src/adapters/openai/OpenAiAdapter.d.ts.map +0 -1
- package/packages/agents/src/adapters/openai/OpenAiAdapter.js +0 -51
- package/packages/agents/src/adapters/openai/OpenAiAdapter.ts +0 -56
- package/packages/agents/src/adapters/openai/OpenAiCliAdapter.ts +0 -62
- package/packages/agents/src/adapters/qa/.gitkeep +0 -0
- package/packages/agents/src/adapters/qa/QaAdapter.d.ts +0 -11
- package/packages/agents/src/adapters/qa/QaAdapter.d.ts.map +0 -1
- package/packages/agents/src/adapters/qa/QaAdapter.js +0 -37
- package/packages/agents/src/adapters/qa/QaAdapter.ts +0 -42
- package/packages/agents/src/adapters/zhipu/ZhipuApiAdapter.ts +0 -273
- package/packages/agents/src/index.d.ts +0 -8
- package/packages/agents/src/index.d.ts.map +0 -1
- package/packages/agents/src/index.js +0 -7
- package/packages/agents/src/index.ts +0 -11
- package/packages/agents/tsconfig.json +0 -14
- package/packages/cli/CHANGELOG.md +0 -7
- package/packages/cli/LICENSE +0 -21
- package/packages/cli/README.md +0 -23
- package/packages/cli/package.json +0 -61
- package/packages/cli/src/__tests__/AgentsCommands.test.ts +0 -137
- package/packages/cli/src/__tests__/BacklogCommands.test.ts +0 -40
- package/packages/cli/src/__tests__/CodeReviewCommand.test.ts +0 -594
- package/packages/cli/src/__tests__/CreateTasksCommand.test.ts +0 -40
- package/packages/cli/src/__tests__/DocsCommands.test.ts +0 -41
- package/packages/cli/src/__tests__/EstimateCommands.test.ts +0 -54
- package/packages/cli/src/__tests__/JobsCommands.behavior.test.ts +0 -311
- package/packages/cli/src/__tests__/JobsCommands.test.ts +0 -49
- package/packages/cli/src/__tests__/MigrateTasksCommand.test.ts +0 -36
- package/packages/cli/src/__tests__/OpenapiCommands.test.ts +0 -34
- package/packages/cli/src/__tests__/OrderTasksCommand.test.ts +0 -150
- package/packages/cli/src/__tests__/PlanningCommands.test.ts +0 -9
- package/packages/cli/src/__tests__/QaTasksCommand.test.ts +0 -58
- package/packages/cli/src/__tests__/RefineTasksCommand.test.ts +0 -63
- package/packages/cli/src/__tests__/RoutingCommands.test.ts +0 -302
- package/packages/cli/src/__tests__/SetWorkspaceCommand.test.ts +0 -18
- package/packages/cli/src/__tests__/TaskShowCommands.test.ts +0 -130
- package/packages/cli/src/__tests__/TelemetryCommands.test.ts +0 -35
- package/packages/cli/src/__tests__/TestAgentCommand.test.ts +0 -41
- package/packages/cli/src/__tests__/UpdateCommands.test.ts +0 -292
- package/packages/cli/src/__tests__/WorkOnTasksCommand.test.ts +0 -42
- package/packages/cli/src/bin/.gitkeep +0 -0
- package/packages/cli/src/bin/McodaEntrypoint.ts +0 -180
- package/packages/cli/src/commands/agents/.gitkeep +0 -0
- package/packages/cli/src/commands/agents/AgentsCommands.ts +0 -374
- package/packages/cli/src/commands/agents/GatewayAgentCommand.ts +0 -621
- package/packages/cli/src/commands/agents/TestAgentCommand.ts +0 -63
- package/packages/cli/src/commands/backlog/.gitkeep +0 -0
- package/packages/cli/src/commands/backlog/BacklogCommands.ts +0 -286
- package/packages/cli/src/commands/backlog/OrderTasksCommand.ts +0 -237
- package/packages/cli/src/commands/backlog/TaskShowCommands.ts +0 -289
- package/packages/cli/src/commands/docs/.gitkeep +0 -0
- package/packages/cli/src/commands/docs/DocsCommands.ts +0 -413
- package/packages/cli/src/commands/estimate/EstimateCommands.ts +0 -290
- package/packages/cli/src/commands/jobs/.gitkeep +0 -0
- package/packages/cli/src/commands/jobs/JobsCommands.ts +0 -595
- package/packages/cli/src/commands/openapi/OpenapiCommands.ts +0 -167
- package/packages/cli/src/commands/planning/.gitkeep +0 -0
- package/packages/cli/src/commands/planning/CreateTasksCommand.ts +0 -149
- package/packages/cli/src/commands/planning/MigrateTasksCommand.ts +0 -105
- package/packages/cli/src/commands/planning/PlanningCommands.ts +0 -1
- package/packages/cli/src/commands/planning/QaTasksCommand.ts +0 -320
- package/packages/cli/src/commands/planning/RefineTasksCommand.ts +0 -408
- package/packages/cli/src/commands/review/CodeReviewCommand.ts +0 -262
- package/packages/cli/src/commands/routing/.gitkeep +0 -0
- package/packages/cli/src/commands/routing/RoutingCommands.ts +0 -554
- package/packages/cli/src/commands/telemetry/.gitkeep +0 -0
- package/packages/cli/src/commands/telemetry/TelemetryCommands.ts +0 -348
- package/packages/cli/src/commands/update/.gitkeep +0 -0
- package/packages/cli/src/commands/update/UpdateCommands.ts +0 -301
- package/packages/cli/src/commands/work/WorkOnTasksCommand.ts +0 -264
- package/packages/cli/src/commands/workspace/SetWorkspaceCommand.ts +0 -132
- package/packages/cli/test/packaging_guardrails.test.js +0 -75
- package/packages/cli/tsconfig.json +0 -20
- package/packages/core/CHANGELOG.md +0 -7
- package/packages/core/LICENSE +0 -21
- package/packages/core/README.md +0 -9
- package/packages/core/package.json +0 -45
- package/packages/core/src/__tests__/SmokeClasses.test.ts +0 -32
- package/packages/core/src/api/AgentsApi.ts +0 -219
- package/packages/core/src/api/QaTasksApi.ts +0 -38
- package/packages/core/src/api/TasksApi.ts +0 -35
- package/packages/core/src/api/__tests__/AgentsApi.test.ts +0 -203
- package/packages/core/src/api/__tests__/QaTasksApi.test.ts +0 -51
- package/packages/core/src/api/__tests__/TasksApi.test.ts +0 -56
- package/packages/core/src/config/.gitkeep +0 -0
- package/packages/core/src/config/ConfigService.ts +0 -1
- package/packages/core/src/domain/dependencies/.gitkeep +0 -0
- package/packages/core/src/domain/dependencies/Dependency.ts +0 -1
- package/packages/core/src/domain/epics/.gitkeep +0 -0
- package/packages/core/src/domain/epics/Epic.ts +0 -1
- package/packages/core/src/domain/projects/.gitkeep +0 -0
- package/packages/core/src/domain/projects/Project.ts +0 -1
- package/packages/core/src/domain/tasks/.gitkeep +0 -0
- package/packages/core/src/domain/tasks/Task.ts +0 -1
- package/packages/core/src/domain/userStories/.gitkeep +0 -0
- package/packages/core/src/domain/userStories/UserStory.ts +0 -1
- package/packages/core/src/index.ts +0 -27
- package/packages/core/src/prompts/.gitkeep +0 -0
- package/packages/core/src/prompts/PdrPrompts.ts +0 -23
- package/packages/core/src/prompts/PromptLoader.ts +0 -1
- package/packages/core/src/prompts/SdsPrompts.ts +0 -47
- package/packages/core/src/services/agents/.gitkeep +0 -0
- package/packages/core/src/services/agents/AgentManagementService.ts +0 -1
- package/packages/core/src/services/agents/GatewayAgentService.ts +0 -956
- package/packages/core/src/services/agents/RoutingService.ts +0 -461
- package/packages/core/src/services/agents/__tests__/GatewayAgentService.test.ts +0 -72
- package/packages/core/src/services/agents/__tests__/RoutingService.test.ts +0 -267
- package/packages/core/src/services/agents/generated/RoutingApiClient.ts +0 -89
- package/packages/core/src/services/backlog/.gitkeep +0 -0
- package/packages/core/src/services/backlog/BacklogService.ts +0 -580
- package/packages/core/src/services/backlog/TaskOrderingService.ts +0 -868
- package/packages/core/src/services/backlog/__tests__/BacklogService.test.ts +0 -219
- package/packages/core/src/services/backlog/__tests__/TaskOrderingService.test.ts +0 -268
- package/packages/core/src/services/docs/.gitkeep +0 -0
- package/packages/core/src/services/docs/DocsService.ts +0 -1913
- package/packages/core/src/services/docs/__tests__/DocsService.test.ts +0 -350
- package/packages/core/src/services/estimate/EstimateService.ts +0 -111
- package/packages/core/src/services/estimate/VelocityService.ts +0 -272
- package/packages/core/src/services/estimate/__tests__/VelocityAndEstimate.test.ts +0 -209
- package/packages/core/src/services/estimate/types.ts +0 -41
- package/packages/core/src/services/execution/.gitkeep +0 -0
- package/packages/core/src/services/execution/ExecutionService.ts +0 -1
- package/packages/core/src/services/execution/QaFollowupService.ts +0 -289
- package/packages/core/src/services/execution/QaProfileService.ts +0 -160
- package/packages/core/src/services/execution/QaTasksService.ts +0 -1303
- package/packages/core/src/services/execution/TaskSelectionService.ts +0 -362
- package/packages/core/src/services/execution/TaskStateService.ts +0 -64
- package/packages/core/src/services/execution/WorkOnTasksService.ts +0 -2023
- package/packages/core/src/services/execution/__tests__/QaFollowupService.test.ts +0 -58
- package/packages/core/src/services/execution/__tests__/QaProfileService.test.ts +0 -49
- package/packages/core/src/services/execution/__tests__/QaTasksService.test.ts +0 -157
- package/packages/core/src/services/execution/__tests__/TaskSelectionService.test.ts +0 -179
- package/packages/core/src/services/execution/__tests__/TaskStateService.test.ts +0 -51
- package/packages/core/src/services/execution/__tests__/WorkOnTasksService.test.ts +0 -285
- package/packages/core/src/services/jobs/.gitkeep +0 -0
- package/packages/core/src/services/jobs/JobInsightsService.ts +0 -355
- package/packages/core/src/services/jobs/JobResumeService.ts +0 -119
- package/packages/core/src/services/jobs/JobService.ts +0 -648
- package/packages/core/src/services/jobs/JobsApiClient.ts +0 -113
- package/packages/core/src/services/jobs/__tests__/JobInsightsService.test.ts +0 -17
- package/packages/core/src/services/jobs/__tests__/JobResumeService.test.ts +0 -45
- package/packages/core/src/services/jobs/__tests__/JobService.test.ts +0 -44
- package/packages/core/src/services/openapi/OpenApiService.ts +0 -558
- package/packages/core/src/services/openapi/__tests__/OpenApiService.test.ts +0 -57
- package/packages/core/src/services/planning/.gitkeep +0 -0
- package/packages/core/src/services/planning/CreateTasksService.ts +0 -1280
- package/packages/core/src/services/planning/KeyHelpers.ts +0 -80
- package/packages/core/src/services/planning/PlanningService.ts +0 -1
- package/packages/core/src/services/planning/RefineTasksService.ts +0 -1552
- package/packages/core/src/services/planning/__tests__/CreateTasksService.test.ts +0 -288
- package/packages/core/src/services/planning/__tests__/KeyHelpers.test.ts +0 -16
- package/packages/core/src/services/planning/__tests__/RefineTasksService.test.ts +0 -172
- package/packages/core/src/services/review/CodeReviewService.ts +0 -1386
- package/packages/core/src/services/review/__tests__/CodeReviewService.test.ts +0 -89
- package/packages/core/src/services/system/SystemUpdateService.ts +0 -177
- package/packages/core/src/services/system/__tests__/SystemUpdateService.test.ts +0 -40
- package/packages/core/src/services/tasks/TaskApiResolver.ts +0 -37
- package/packages/core/src/services/tasks/TaskDetailService.ts +0 -494
- package/packages/core/src/services/tasks/__tests__/TaskApiResolver.test.ts +0 -41
- package/packages/core/src/services/tasks/__tests__/TaskDetailService.test.ts +0 -178
- package/packages/core/src/services/telemetry/.gitkeep +0 -0
- package/packages/core/src/services/telemetry/TelemetryService.ts +0 -515
- package/packages/core/src/services/telemetry/__tests__/TelemetryService.test.ts +0 -160
- package/packages/core/src/workspace/.gitkeep +0 -0
- package/packages/core/src/workspace/WorkspaceManager.ts +0 -234
- package/packages/core/tsconfig.json +0 -20
- package/packages/db/CHANGELOG.md +0 -7
- package/packages/db/LICENSE +0 -21
- package/packages/db/README.md +0 -9
- package/packages/db/package.json +0 -42
- package/packages/db/src/__tests__/GlobalRepository.test.ts +0 -109
- package/packages/db/src/__tests__/SchemaAlignment.test.ts +0 -80
- package/packages/db/src/__tests__/WorkspaceRepository.test.ts +0 -19
- package/packages/db/src/index.d.ts +0 -6
- package/packages/db/src/index.d.ts.map +0 -1
- package/packages/db/src/index.js +0 -5
- package/packages/db/src/index.ts +0 -6
- package/packages/db/src/migrations/global/.gitkeep +0 -0
- package/packages/db/src/migrations/global/GlobalMigrations.d.ts +0 -9
- package/packages/db/src/migrations/global/GlobalMigrations.d.ts.map +0 -1
- package/packages/db/src/migrations/global/GlobalMigrations.js +0 -68
- package/packages/db/src/migrations/global/GlobalMigrations.ts +0 -336
- package/packages/db/src/migrations/workspace/.gitkeep +0 -0
- package/packages/db/src/migrations/workspace/WorkspaceMigrations.d.ts +0 -9
- package/packages/db/src/migrations/workspace/WorkspaceMigrations.d.ts.map +0 -1
- package/packages/db/src/migrations/workspace/WorkspaceMigrations.js +0 -251
- package/packages/db/src/migrations/workspace/WorkspaceMigrations.ts +0 -248
- package/packages/db/src/repositories/global/.gitkeep +0 -0
- package/packages/db/src/repositories/global/GlobalRepository.d.ts +0 -30
- package/packages/db/src/repositories/global/GlobalRepository.d.ts.map +0 -1
- package/packages/db/src/repositories/global/GlobalRepository.js +0 -209
- package/packages/db/src/repositories/global/GlobalRepository.ts +0 -492
- package/packages/db/src/repositories/workspace/.gitkeep +0 -0
- package/packages/db/src/repositories/workspace/WorkspaceRepository.d.ts +0 -282
- package/packages/db/src/repositories/workspace/WorkspaceRepository.d.ts.map +0 -1
- package/packages/db/src/repositories/workspace/WorkspaceRepository.js +0 -773
- package/packages/db/src/repositories/workspace/WorkspaceRepository.ts +0 -1511
- package/packages/db/src/sqlite/connection.d.ts +0 -11
- package/packages/db/src/sqlite/connection.d.ts.map +0 -1
- package/packages/db/src/sqlite/connection.js +0 -31
- package/packages/db/src/sqlite/connection.ts +0 -35
- package/packages/db/src/sqlite/pragmas.d.ts +0 -5
- package/packages/db/src/sqlite/pragmas.d.ts.map +0 -1
- package/packages/db/src/sqlite/pragmas.js +0 -6
- package/packages/db/src/sqlite/pragmas.ts +0 -10
- package/packages/db/tsconfig.json +0 -13
- package/packages/generators/package.json +0 -21
- package/packages/generators/src/__tests__/Generators.test.ts +0 -19
- package/packages/generators/src/index.ts +0 -1
- package/packages/generators/src/openapi/generateTypes.ts +0 -1
- package/packages/generators/src/openapi/validateSchema.ts +0 -1
- package/packages/generators/src/scaffolding/docs/.gitkeep +0 -0
- package/packages/generators/src/scaffolding/docs/DocsScaffolder.ts +0 -1
- package/packages/generators/src/scaffolding/global/.gitkeep +0 -0
- package/packages/generators/src/scaffolding/global/GlobalScaffolder.ts +0 -1
- package/packages/generators/src/scaffolding/workspace/.gitkeep +0 -0
- package/packages/generators/src/scaffolding/workspace/WorkspaceScaffolder.ts +0 -1
- package/packages/generators/tsconfig.json +0 -10
- package/packages/integrations/CHANGELOG.md +0 -7
- package/packages/integrations/LICENSE +0 -21
- package/packages/integrations/README.md +0 -9
- package/packages/integrations/package.json +0 -47
- package/packages/integrations/src/docdex/.gitkeep +0 -0
- package/packages/integrations/src/docdex/DocdexClient.d.ts +0 -50
- package/packages/integrations/src/docdex/DocdexClient.d.ts.map +0 -1
- package/packages/integrations/src/docdex/DocdexClient.js +0 -216
- package/packages/integrations/src/docdex/DocdexClient.ts +0 -261
- package/packages/integrations/src/docdex/__tests__/DocdexClient.test.ts +0 -29
- package/packages/integrations/src/index.d.ts +0 -2
- package/packages/integrations/src/index.d.ts.map +0 -1
- package/packages/integrations/src/index.js +0 -4
- package/packages/integrations/src/index.ts +0 -5
- package/packages/integrations/src/issues/.gitkeep +0 -0
- package/packages/integrations/src/issues/IssuesClient.ts +0 -1
- package/packages/integrations/src/issues/__tests__/IssuesClient.test.ts +0 -10
- package/packages/integrations/src/qa/.gitkeep +0 -0
- package/packages/integrations/src/qa/ChromiumQaAdapter.ts +0 -89
- package/packages/integrations/src/qa/CliQaAdapter.ts +0 -95
- package/packages/integrations/src/qa/MaestroQaAdapter.ts +0 -91
- package/packages/integrations/src/qa/QaAdapter.ts +0 -7
- package/packages/integrations/src/qa/QaClient.ts +0 -1
- package/packages/integrations/src/qa/QaTypes.ts +0 -26
- package/packages/integrations/src/qa/__tests__/ChromiumQaAdapter.test.ts +0 -30
- package/packages/integrations/src/qa/__tests__/CliQaAdapter.test.ts +0 -33
- package/packages/integrations/src/qa/__tests__/MaestroQaAdapter.test.ts +0 -30
- package/packages/integrations/src/qa/index.ts +0 -5
- package/packages/integrations/src/system/SystemClient.ts +0 -50
- package/packages/integrations/src/system/__tests__/SystemClient.test.ts +0 -40
- package/packages/integrations/src/telemetry/TelemetryClient.ts +0 -139
- package/packages/integrations/src/telemetry/__tests__/TelemetryClient.test.ts +0 -41
- package/packages/integrations/src/vcs/.gitkeep +0 -0
- package/packages/integrations/src/vcs/VcsClient.ts +0 -211
- package/packages/integrations/src/vcs/__tests__/VcsClient.test.ts +0 -26
- package/packages/integrations/tsconfig.json +0 -14
- package/packages/shared/CHANGELOG.md +0 -7
- package/packages/shared/LICENSE +0 -21
- package/packages/shared/README.md +0 -9
- package/packages/shared/package.json +0 -40
- package/packages/shared/src/__tests__/CommandMetadata.test.ts +0 -15
- package/packages/shared/src/__tests__/ServiceShells.test.ts +0 -16
- package/packages/shared/src/crypto/.gitkeep +0 -0
- package/packages/shared/src/crypto/CryptoHelper.d.ts +0 -15
- package/packages/shared/src/crypto/CryptoHelper.d.ts.map +0 -1
- package/packages/shared/src/crypto/CryptoHelper.js +0 -54
- package/packages/shared/src/crypto/CryptoHelper.ts +0 -57
- package/packages/shared/src/errors/.gitkeep +0 -0
- package/packages/shared/src/errors/ErrorFactory.ts +0 -1
- package/packages/shared/src/index.d.ts +0 -6
- package/packages/shared/src/index.d.ts.map +0 -1
- package/packages/shared/src/index.js +0 -4
- package/packages/shared/src/index.ts +0 -35
- package/packages/shared/src/logging/.gitkeep +0 -0
- package/packages/shared/src/logging/Logger.ts +0 -1
- package/packages/shared/src/metadata/CommandMetadata.ts +0 -165
- package/packages/shared/src/openapi/.gitkeep +0 -0
- package/packages/shared/src/openapi/OpenApiTypes.d.ts +0 -216
- package/packages/shared/src/openapi/OpenApiTypes.d.ts.map +0 -1
- package/packages/shared/src/openapi/OpenApiTypes.js +0 -1
- package/packages/shared/src/openapi/OpenApiTypes.ts +0 -312
- package/packages/shared/src/paths/.gitkeep +0 -0
- package/packages/shared/src/paths/PathHelper.d.ts +0 -12
- package/packages/shared/src/paths/PathHelper.d.ts.map +0 -1
- package/packages/shared/src/paths/PathHelper.js +0 -24
- package/packages/shared/src/paths/PathHelper.ts +0 -29
- package/packages/shared/src/qa/QaProfile.ts +0 -14
- package/packages/shared/src/utils/.gitkeep +0 -0
- package/packages/shared/src/utils/UtilityService.ts +0 -1
- package/packages/shared/tsconfig.json +0 -10
- package/packages/testing/package.json +0 -26
- package/packages/testing/src/__tests__/TestingFakes.test.ts +0 -15
- package/packages/testing/src/cli/e2e/.gitkeep +0 -0
- package/packages/testing/src/cli/e2e/E2eSuite.ts +0 -1
- package/packages/testing/src/fakes/agents/.gitkeep +0 -0
- package/packages/testing/src/fakes/agents/FakeAgents.ts +0 -1
- package/packages/testing/src/fakes/docdex/.gitkeep +0 -0
- package/packages/testing/src/fakes/docdex/FakeDocdexClient.ts +0 -1
- package/packages/testing/src/fakes/qa/.gitkeep +0 -0
- package/packages/testing/src/fakes/qa/FakeQaClient.ts +0 -1
- package/packages/testing/src/fakes/vcs/.gitkeep +0 -0
- package/packages/testing/src/fakes/vcs/FakeVcsClient.ts +0 -1
- package/packages/testing/src/fixtures/db/.gitkeep +0 -0
- package/packages/testing/src/fixtures/db/DbFixtures.ts +0 -1
- package/packages/testing/src/fixtures/workspaces/.gitkeep +0 -0
- package/packages/testing/src/fixtures/workspaces/WorkspaceFixtures.ts +0 -1
- package/packages/testing/src/index.ts +0 -1
- package/packages/testing/tsconfig.json +0 -10
- package/pnpm-workspace.yaml +0 -2
- package/prompts/README.md +0 -5
- package/prompts/code-reviewer.md +0 -23
- package/prompts/code-writer.md +0 -35
- package/prompts/gateway-agent.md +0 -27
- package/prompts/qa-agent.md +0 -21
- package/release-please-config.json +0 -39
- package/scripts/build-all.ts +0 -1
- package/scripts/dev.ts +0 -1
- package/scripts/install-local-cli.sh +0 -28
- package/scripts/pack-npm-tarballs.js +0 -63
- package/scripts/release.ts +0 -1
- package/scripts/run-node-tests.js +0 -37
- package/tests/all.js +0 -127
- package/tests/api/openapi_spec.test.js +0 -21
- package/tests/artifacts.md +0 -31
- package/tests/component/cli_version.test.js +0 -38
- package/tests/integration/workspace_resolver.test.js +0 -44
- package/tests/unit/crypto_helper.test.js +0 -36
- package/tests/unit/path_helper.test.js +0 -20
- package/tsconfig.base.json +0 -32
- /package/{packages/cli/src/index.ts → dist/index.js} +0 -0
|
@@ -1,648 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { promises as fs } from "node:fs";
|
|
4
|
-
import { PathHelper } from "@mcoda/shared";
|
|
5
|
-
import {
|
|
6
|
-
WorkspaceRepository,
|
|
7
|
-
CommandStatus,
|
|
8
|
-
JobStatus,
|
|
9
|
-
TokenUsageInsert,
|
|
10
|
-
} from "@mcoda/db";
|
|
11
|
-
|
|
12
|
-
export type JobState = JobStatus;
|
|
13
|
-
export type CommandRunStatus = CommandStatus;
|
|
14
|
-
|
|
15
|
-
export interface CommandRunRecord {
|
|
16
|
-
id: string;
|
|
17
|
-
commandName: string;
|
|
18
|
-
workspaceId: string;
|
|
19
|
-
projectKey?: string;
|
|
20
|
-
jobId?: string;
|
|
21
|
-
taskIds?: string[];
|
|
22
|
-
gitBranch?: string;
|
|
23
|
-
gitBaseBranch?: string;
|
|
24
|
-
startedAt: string;
|
|
25
|
-
completedAt?: string;
|
|
26
|
-
status: CommandRunStatus;
|
|
27
|
-
errorSummary?: string;
|
|
28
|
-
durationSeconds?: number;
|
|
29
|
-
spProcessed?: number | null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface JobRecord {
|
|
33
|
-
id: string;
|
|
34
|
-
type: string;
|
|
35
|
-
state: JobState;
|
|
36
|
-
jobState?: JobState;
|
|
37
|
-
jobStateDetail?: string;
|
|
38
|
-
commandRunId?: string;
|
|
39
|
-
commandName?: string;
|
|
40
|
-
workspaceId: string;
|
|
41
|
-
projectKey?: string;
|
|
42
|
-
payload?: Record<string, unknown>;
|
|
43
|
-
totalItems?: number;
|
|
44
|
-
processedItems?: number;
|
|
45
|
-
totalUnits?: number;
|
|
46
|
-
completedUnits?: number;
|
|
47
|
-
lastCheckpoint?: string;
|
|
48
|
-
createdAt: string;
|
|
49
|
-
updatedAt: string;
|
|
50
|
-
completedAt?: string;
|
|
51
|
-
errorSummary?: string;
|
|
52
|
-
durationSeconds?: number;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface TokenUsageRecord extends TokenUsageInsert {
|
|
56
|
-
commandName?: string;
|
|
57
|
-
action?: string;
|
|
58
|
-
promptTokens?: number;
|
|
59
|
-
completionTokens?: number;
|
|
60
|
-
costUsd?: number;
|
|
61
|
-
metadata?: Record<string, unknown>;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface JobCheckpoint {
|
|
65
|
-
stage: string;
|
|
66
|
-
timestamp: string;
|
|
67
|
-
details?: Record<string, unknown>;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface JobLogRow {
|
|
71
|
-
timestamp: string;
|
|
72
|
-
sequence?: number | null;
|
|
73
|
-
level?: string | null;
|
|
74
|
-
source?: string | null;
|
|
75
|
-
message?: string | null;
|
|
76
|
-
taskId?: string | null;
|
|
77
|
-
taskKey?: string | null;
|
|
78
|
-
phase?: string | null;
|
|
79
|
-
details?: Record<string, unknown> | null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface TaskRunSnapshotRow {
|
|
83
|
-
taskId?: string | null;
|
|
84
|
-
taskKey?: string | null;
|
|
85
|
-
status?: string | null;
|
|
86
|
-
startedAt?: string | null;
|
|
87
|
-
finishedAt?: string | null;
|
|
88
|
-
command?: string | null;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const nowIso = (): string => new Date().toISOString();
|
|
92
|
-
|
|
93
|
-
export class JobService {
|
|
94
|
-
private checkpointCounters = new Map<string, number>();
|
|
95
|
-
private workspaceRepoInit = false;
|
|
96
|
-
private telemetryConfig?: { optOut?: boolean; strict?: boolean };
|
|
97
|
-
private telemetryWarningShown = false;
|
|
98
|
-
private telemetryRemoteWarningShown = false;
|
|
99
|
-
private perRunTelemetryDisabled: boolean;
|
|
100
|
-
private envTelemetryDisabled: boolean;
|
|
101
|
-
private requireRepo: boolean;
|
|
102
|
-
private workspaceRoot: string;
|
|
103
|
-
private workspaceId: string;
|
|
104
|
-
|
|
105
|
-
constructor(
|
|
106
|
-
workspace: string | { workspaceRoot: string; workspaceId?: string },
|
|
107
|
-
private workspaceRepo?: WorkspaceRepository,
|
|
108
|
-
options: { noTelemetry?: boolean; requireRepo?: boolean } = {},
|
|
109
|
-
) {
|
|
110
|
-
const resolvedRoot = typeof workspace === "string" ? workspace : workspace.workspaceRoot;
|
|
111
|
-
this.workspaceRoot = resolvedRoot;
|
|
112
|
-
this.workspaceId = typeof workspace === "string" ? resolvedRoot : workspace.workspaceId ?? resolvedRoot;
|
|
113
|
-
this.perRunTelemetryDisabled = options.noTelemetry ?? false;
|
|
114
|
-
this.envTelemetryDisabled = (process.env.MCODA_TELEMETRY ?? "").toLowerCase() === "off";
|
|
115
|
-
this.requireRepo = options.requireRepo ?? false;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
private get mcodaDir(): string {
|
|
119
|
-
return path.join(this.workspaceRoot, ".mcoda");
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
private get commandRunsPath(): string {
|
|
123
|
-
return path.join(this.mcodaDir, "command_runs.json");
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
private get jobsStorePath(): string {
|
|
127
|
-
return path.join(this.mcodaDir, "jobs.json");
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
private get tokenUsagePath(): string {
|
|
131
|
-
return path.join(this.mcodaDir, "token_usage.json");
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
private jobDir(jobId: string): string {
|
|
135
|
-
return path.join(this.mcodaDir, "jobs", jobId);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
private manifestPath(jobId: string): string {
|
|
139
|
-
return path.join(this.jobDir(jobId), "manifest.json");
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
private checkpointDir(jobId: string): string {
|
|
143
|
-
return path.join(this.jobDir(jobId), "checkpoints");
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
private logsDir(jobId: string): string {
|
|
147
|
-
return path.join(this.jobDir(jobId), "logs");
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
private async ensureMcoda(): Promise<void> {
|
|
151
|
-
await PathHelper.ensureDir(this.mcodaDir);
|
|
152
|
-
if (this.workspaceRepoInit) return;
|
|
153
|
-
this.workspaceRepoInit = true;
|
|
154
|
-
if (process.env.MCODA_DISABLE_DB === "1") {
|
|
155
|
-
if (this.requireRepo) {
|
|
156
|
-
throw new Error("Workspace DB disabled via MCODA_DISABLE_DB; job operations require the workspace DB per SDS.");
|
|
157
|
-
}
|
|
158
|
-
this.workspaceRepo = undefined;
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
try {
|
|
162
|
-
if (!this.workspaceRepo) {
|
|
163
|
-
this.workspaceRepo = await WorkspaceRepository.create(this.workspaceRoot);
|
|
164
|
-
}
|
|
165
|
-
} catch (error) {
|
|
166
|
-
if (this.requireRepo) {
|
|
167
|
-
throw new Error(
|
|
168
|
-
`Workspace DB could not be opened for jobs (${(error as Error).message}); run mcoda init/create-tasks to initialize the workspace.`,
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
// Fall back to JSON stores if sqlite is unavailable or schema mismatches.
|
|
172
|
-
this.workspaceRepo = undefined;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
private async readJsonArray<T>(filePath: string): Promise<T[]> {
|
|
177
|
-
try {
|
|
178
|
-
const raw = await fs.readFile(filePath, "utf8");
|
|
179
|
-
const parsed = JSON.parse(raw) as T[];
|
|
180
|
-
if (Array.isArray(parsed)) return parsed;
|
|
181
|
-
return [];
|
|
182
|
-
} catch {
|
|
183
|
-
return [];
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
private async writeJsonArray<T>(filePath: string, records: T[]): Promise<void> {
|
|
188
|
-
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
189
|
-
await fs.writeFile(filePath, JSON.stringify(records, null, 2), "utf8");
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
private async appendJsonArray<T>(filePath: string, record: T): Promise<void> {
|
|
193
|
-
const existing = await this.readJsonArray<T>(filePath);
|
|
194
|
-
existing.push(record);
|
|
195
|
-
await this.writeJsonArray(filePath, existing);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
async listJobs(): Promise<JobRecord[]> {
|
|
199
|
-
await this.ensureMcoda();
|
|
200
|
-
if (this.workspaceRepo && "listJobs" in this.workspaceRepo) {
|
|
201
|
-
const rows = await (this.workspaceRepo as any).listJobs();
|
|
202
|
-
return rows as JobRecord[];
|
|
203
|
-
}
|
|
204
|
-
return this.readJsonArray<JobRecord>(this.jobsStorePath);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
async getJob(jobId: string): Promise<JobRecord | undefined> {
|
|
208
|
-
await this.ensureMcoda();
|
|
209
|
-
if (this.workspaceRepo && "getJob" in this.workspaceRepo) {
|
|
210
|
-
return ((await (this.workspaceRepo as any).getJob(jobId)) as JobRecord | undefined) ?? undefined;
|
|
211
|
-
}
|
|
212
|
-
const jobs = await this.readJsonArray<JobRecord>(this.jobsStorePath);
|
|
213
|
-
return jobs.find((j) => j.id === jobId);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
async readCheckpoints(jobId: string): Promise<JobCheckpoint[]> {
|
|
217
|
-
const dir = this.checkpointDir(jobId);
|
|
218
|
-
try {
|
|
219
|
-
const entries = await fs.readdir(dir);
|
|
220
|
-
const checkpoints: JobCheckpoint[] = [];
|
|
221
|
-
for (const entry of entries.sort()) {
|
|
222
|
-
const raw = await fs.readFile(path.join(dir, entry), "utf8");
|
|
223
|
-
checkpoints.push(JSON.parse(raw) as JobCheckpoint);
|
|
224
|
-
}
|
|
225
|
-
return checkpoints;
|
|
226
|
-
} catch {
|
|
227
|
-
return [];
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
async readLog(jobId: string): Promise<string> {
|
|
232
|
-
const logPath = path.join(this.logsDir(jobId), "stream.log");
|
|
233
|
-
try {
|
|
234
|
-
return await fs.readFile(logPath, "utf8");
|
|
235
|
-
} catch {
|
|
236
|
-
return "";
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
async listJobLogs(
|
|
241
|
-
jobId: string,
|
|
242
|
-
options: { since?: string; after?: { timestamp: string; sequence?: number | null } } = {},
|
|
243
|
-
): Promise<JobLogRow[]> {
|
|
244
|
-
await this.ensureMcoda();
|
|
245
|
-
if (this.workspaceRepo && "getDb" in this.workspaceRepo) {
|
|
246
|
-
const db = (this.workspaceRepo as any).getDb();
|
|
247
|
-
const clauses = ["tr.job_id = ?"];
|
|
248
|
-
const params: any[] = [jobId];
|
|
249
|
-
if (options.since) {
|
|
250
|
-
clauses.push("datetime(tl.timestamp) >= datetime(?)");
|
|
251
|
-
params.push(options.since);
|
|
252
|
-
}
|
|
253
|
-
if (options.after?.timestamp) {
|
|
254
|
-
clauses.push("(datetime(tl.timestamp) > datetime(?) OR (tl.timestamp = ? AND COALESCE(tl.sequence,0) > COALESCE(?,0)))");
|
|
255
|
-
params.push(options.after.timestamp, options.after.timestamp, options.after.sequence ?? 0);
|
|
256
|
-
}
|
|
257
|
-
const where = clauses.length ? `WHERE ${clauses.join(" AND ")}` : "";
|
|
258
|
-
const rows = (await db.all(
|
|
259
|
-
`
|
|
260
|
-
SELECT tl.timestamp, tl.sequence, tl.level, tl.source, tl.message, tl.details_json, tr.task_id, tr.command, t.key as task_key
|
|
261
|
-
FROM task_logs tl
|
|
262
|
-
JOIN task_runs tr ON tr.id = tl.task_run_id
|
|
263
|
-
LEFT JOIN tasks t ON t.id = tr.task_id
|
|
264
|
-
${where}
|
|
265
|
-
ORDER BY datetime(tl.timestamp) ASC, tl.sequence ASC
|
|
266
|
-
LIMIT 500
|
|
267
|
-
`,
|
|
268
|
-
...params
|
|
269
|
-
)) as any[];
|
|
270
|
-
return rows.map((row: any) => {
|
|
271
|
-
const details = row.details_json ? JSON.parse(row.details_json) : null;
|
|
272
|
-
return {
|
|
273
|
-
timestamp: row.timestamp,
|
|
274
|
-
sequence: row.sequence ?? null,
|
|
275
|
-
level: row.level ?? null,
|
|
276
|
-
source: row.source ?? null,
|
|
277
|
-
message: row.message ?? null,
|
|
278
|
-
taskId: row.task_id ?? null,
|
|
279
|
-
taskKey: row.task_key ?? null,
|
|
280
|
-
phase: (details as any)?.phase ?? row.command ?? null,
|
|
281
|
-
details,
|
|
282
|
-
};
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
// Fallback to file-based stream log when DB access is not available.
|
|
286
|
-
const raw = await this.readLog(jobId);
|
|
287
|
-
const lines = raw.split(/\r?\n/).filter(Boolean);
|
|
288
|
-
return lines.map((line, idx) => ({
|
|
289
|
-
timestamp: nowIso(),
|
|
290
|
-
sequence: idx,
|
|
291
|
-
message: line,
|
|
292
|
-
}));
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
async summarizeTaskRuns(jobId: string): Promise<TaskRunSnapshotRow[]> {
|
|
296
|
-
await this.ensureMcoda();
|
|
297
|
-
if (this.workspaceRepo && "getDb" in this.workspaceRepo) {
|
|
298
|
-
const db = (this.workspaceRepo as any).getDb();
|
|
299
|
-
const rows = (await db.all(
|
|
300
|
-
`
|
|
301
|
-
SELECT tr.task_id, tr.status, tr.started_at, tr.finished_at, tr.command, t.key as task_key
|
|
302
|
-
FROM task_runs tr
|
|
303
|
-
LEFT JOIN tasks t ON t.id = tr.task_id
|
|
304
|
-
WHERE tr.job_id = ?
|
|
305
|
-
ORDER BY datetime(tr.started_at) ASC, datetime(tr.finished_at) ASC
|
|
306
|
-
`,
|
|
307
|
-
jobId
|
|
308
|
-
)) as any[];
|
|
309
|
-
return rows.map((row: any) => ({
|
|
310
|
-
taskId: row.task_id ?? null,
|
|
311
|
-
taskKey: row.task_key ?? null,
|
|
312
|
-
status: row.status ?? null,
|
|
313
|
-
startedAt: row.started_at ?? null,
|
|
314
|
-
finishedAt: row.finished_at ?? null,
|
|
315
|
-
command: row.command ?? null,
|
|
316
|
-
}));
|
|
317
|
-
}
|
|
318
|
-
return [];
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
async startCommandRun(
|
|
322
|
-
commandName: string,
|
|
323
|
-
projectKey?: string,
|
|
324
|
-
options?: { gitBranch?: string; gitBaseBranch?: string; taskIds?: string[]; jobId?: string },
|
|
325
|
-
): Promise<CommandRunRecord> {
|
|
326
|
-
await this.ensureMcoda();
|
|
327
|
-
const startedAt = nowIso();
|
|
328
|
-
let record: CommandRunRecord = {
|
|
329
|
-
id: randomUUID(),
|
|
330
|
-
commandName,
|
|
331
|
-
workspaceId: this.workspaceId,
|
|
332
|
-
projectKey,
|
|
333
|
-
jobId: options?.jobId,
|
|
334
|
-
taskIds: options?.taskIds,
|
|
335
|
-
gitBranch: options?.gitBranch,
|
|
336
|
-
gitBaseBranch: options?.gitBaseBranch,
|
|
337
|
-
startedAt,
|
|
338
|
-
status: "running",
|
|
339
|
-
spProcessed: null,
|
|
340
|
-
};
|
|
341
|
-
if (this.workspaceRepo) {
|
|
342
|
-
const row = await this.workspaceRepo.createCommandRun({
|
|
343
|
-
workspaceId: this.workspaceId,
|
|
344
|
-
commandName,
|
|
345
|
-
jobId: record.jobId,
|
|
346
|
-
taskIds: record.taskIds,
|
|
347
|
-
gitBranch: record.gitBranch,
|
|
348
|
-
gitBaseBranch: record.gitBaseBranch,
|
|
349
|
-
startedAt,
|
|
350
|
-
status: "running",
|
|
351
|
-
});
|
|
352
|
-
record = { ...record, id: row.id };
|
|
353
|
-
}
|
|
354
|
-
await this.appendJsonArray(this.commandRunsPath, record);
|
|
355
|
-
return record;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
async finishCommandRun(runId: string, status: CommandRunStatus, errorSummary?: string, spProcessed?: number): Promise<void> {
|
|
359
|
-
const runs = await this.readJsonArray<CommandRunRecord>(this.commandRunsPath);
|
|
360
|
-
const idx = runs.findIndex((r) => r.id === runId);
|
|
361
|
-
if (idx === -1) return;
|
|
362
|
-
const completedAt = nowIso();
|
|
363
|
-
const durationSeconds =
|
|
364
|
-
runs[idx].startedAt ? (Date.parse(completedAt) - Date.parse(runs[idx].startedAt)) / 1000 : undefined;
|
|
365
|
-
runs[idx] = { ...runs[idx], completedAt, status, errorSummary, durationSeconds, spProcessed: spProcessed ?? runs[idx].spProcessed };
|
|
366
|
-
await this.writeJsonArray(this.commandRunsPath, runs);
|
|
367
|
-
if (this.workspaceRepo) {
|
|
368
|
-
await this.workspaceRepo.completeCommandRun(runId, {
|
|
369
|
-
status,
|
|
370
|
-
completedAt,
|
|
371
|
-
errorSummary,
|
|
372
|
-
durationSeconds,
|
|
373
|
-
spProcessed: spProcessed ?? runs[idx].spProcessed ?? null,
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
async startJob(
|
|
379
|
-
type: string,
|
|
380
|
-
commandRunId?: string,
|
|
381
|
-
projectKey?: string,
|
|
382
|
-
options: { payload?: Record<string, unknown>; commandName?: string; totalItems?: number; processedItems?: number } = {},
|
|
383
|
-
): Promise<JobRecord> {
|
|
384
|
-
await this.ensureMcoda();
|
|
385
|
-
const createdAt = nowIso();
|
|
386
|
-
let record: JobRecord = {
|
|
387
|
-
id: randomUUID(),
|
|
388
|
-
type,
|
|
389
|
-
state: "running",
|
|
390
|
-
commandRunId,
|
|
391
|
-
commandName: options.commandName ?? type,
|
|
392
|
-
workspaceId: this.workspaceId,
|
|
393
|
-
projectKey,
|
|
394
|
-
payload: options.payload,
|
|
395
|
-
totalItems: options.totalItems,
|
|
396
|
-
processedItems: options.processedItems,
|
|
397
|
-
totalUnits: options.totalItems,
|
|
398
|
-
completedUnits: options.processedItems,
|
|
399
|
-
createdAt,
|
|
400
|
-
updatedAt: createdAt,
|
|
401
|
-
};
|
|
402
|
-
if (this.workspaceRepo) {
|
|
403
|
-
const row = await this.workspaceRepo.createJob({
|
|
404
|
-
workspaceId: this.workspaceId,
|
|
405
|
-
type,
|
|
406
|
-
state: "running",
|
|
407
|
-
commandName: record.commandName,
|
|
408
|
-
payload: options.payload,
|
|
409
|
-
totalItems: record.totalItems,
|
|
410
|
-
processedItems: record.processedItems,
|
|
411
|
-
});
|
|
412
|
-
record = { ...record, id: row.id, createdAt: row.createdAt, updatedAt: row.updatedAt };
|
|
413
|
-
}
|
|
414
|
-
const jobs = await this.readJsonArray<JobRecord>(this.jobsStorePath);
|
|
415
|
-
jobs.push(record);
|
|
416
|
-
await this.writeJsonArray(this.jobsStorePath, jobs);
|
|
417
|
-
await this.writeManifest(record);
|
|
418
|
-
if (commandRunId) {
|
|
419
|
-
await this.attachCommandRunToJob(commandRunId, record.id);
|
|
420
|
-
}
|
|
421
|
-
return record;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
private async attachCommandRunToJob(commandRunId: string, jobId: string): Promise<void> {
|
|
425
|
-
const runs = await this.readJsonArray<CommandRunRecord>(this.commandRunsPath);
|
|
426
|
-
const idx = runs.findIndex((r) => r.id === commandRunId);
|
|
427
|
-
if (idx !== -1) {
|
|
428
|
-
runs[idx] = { ...runs[idx], jobId };
|
|
429
|
-
await this.writeJsonArray(this.commandRunsPath, runs);
|
|
430
|
-
}
|
|
431
|
-
if (this.workspaceRepo && "setCommandRunJobId" in this.workspaceRepo) {
|
|
432
|
-
try {
|
|
433
|
-
await (this.workspaceRepo as any).setCommandRunJobId(commandRunId, jobId);
|
|
434
|
-
} catch {
|
|
435
|
-
// ignore linking failures
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
async updateJobStatus(
|
|
441
|
-
jobId: string,
|
|
442
|
-
state: JobState,
|
|
443
|
-
metadata?: {
|
|
444
|
-
payload?: Record<string, unknown>;
|
|
445
|
-
totalItems?: number;
|
|
446
|
-
processedItems?: number;
|
|
447
|
-
totalUnits?: number;
|
|
448
|
-
completedUnits?: number;
|
|
449
|
-
lastCheckpoint?: string;
|
|
450
|
-
errorSummary?: string;
|
|
451
|
-
[key: string]: unknown;
|
|
452
|
-
},
|
|
453
|
-
): Promise<void> {
|
|
454
|
-
const jobs = await this.readJsonArray<JobRecord>(this.jobsStorePath);
|
|
455
|
-
const idx = jobs.findIndex((j) => j.id === jobId);
|
|
456
|
-
if (idx === -1) return;
|
|
457
|
-
const completedAt = state !== "running" && state !== "queued" ? nowIso() : jobs[idx].completedAt;
|
|
458
|
-
const durationSeconds =
|
|
459
|
-
completedAt && jobs[idx].createdAt ? (Date.parse(completedAt) - Date.parse(jobs[idx].createdAt)) / 1000 : jobs[idx].durationSeconds;
|
|
460
|
-
const jobStateDetail = (metadata as any)?.job_state_detail ?? (metadata as any)?.jobStateDetail ?? jobs[idx].jobStateDetail;
|
|
461
|
-
const payloadUpdate =
|
|
462
|
-
metadata?.payload ??
|
|
463
|
-
(metadata
|
|
464
|
-
? Object.fromEntries(
|
|
465
|
-
Object.entries(metadata).filter(
|
|
466
|
-
([key]) => !["payload", "totalItems", "processedItems", "lastCheckpoint", "errorSummary", "error"].includes(key),
|
|
467
|
-
),
|
|
468
|
-
)
|
|
469
|
-
: undefined);
|
|
470
|
-
const updated: JobRecord = {
|
|
471
|
-
...jobs[idx],
|
|
472
|
-
state,
|
|
473
|
-
jobState: state,
|
|
474
|
-
jobStateDetail,
|
|
475
|
-
payload: payloadUpdate ? { ...(jobs[idx].payload ?? {}), ...payloadUpdate } : jobs[idx].payload,
|
|
476
|
-
totalItems: metadata?.totalItems ?? jobs[idx].totalItems,
|
|
477
|
-
processedItems: metadata?.processedItems ?? jobs[idx].processedItems,
|
|
478
|
-
totalUnits: metadata?.totalUnits ?? metadata?.totalItems ?? jobs[idx].totalUnits ?? jobs[idx].totalItems,
|
|
479
|
-
completedUnits: metadata?.completedUnits ?? metadata?.processedItems ?? jobs[idx].completedUnits ?? jobs[idx].processedItems,
|
|
480
|
-
lastCheckpoint: metadata?.lastCheckpoint ?? jobs[idx].lastCheckpoint,
|
|
481
|
-
errorSummary: metadata?.errorSummary ?? (metadata as any)?.error ?? jobs[idx].errorSummary,
|
|
482
|
-
updatedAt: nowIso(),
|
|
483
|
-
completedAt,
|
|
484
|
-
durationSeconds,
|
|
485
|
-
};
|
|
486
|
-
jobs[idx] = updated;
|
|
487
|
-
await this.writeJsonArray(this.jobsStorePath, jobs);
|
|
488
|
-
await this.writeManifest(updated);
|
|
489
|
-
if (this.workspaceRepo) {
|
|
490
|
-
await this.workspaceRepo.updateJobState(jobId, {
|
|
491
|
-
state,
|
|
492
|
-
commandName: updated.commandName ?? updated.type,
|
|
493
|
-
totalItems: updated.totalItems,
|
|
494
|
-
processedItems: updated.processedItems,
|
|
495
|
-
lastCheckpoint: updated.lastCheckpoint,
|
|
496
|
-
errorSummary: updated.errorSummary,
|
|
497
|
-
completedAt: updated.completedAt ?? null,
|
|
498
|
-
payload: updated.payload,
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
async writeCheckpoint(jobId: string, checkpoint: JobCheckpoint): Promise<void> {
|
|
504
|
-
const dir = this.checkpointDir(jobId);
|
|
505
|
-
await PathHelper.ensureDir(dir);
|
|
506
|
-
let current = this.checkpointCounters.get(jobId);
|
|
507
|
-
if (current === undefined) {
|
|
508
|
-
try {
|
|
509
|
-
const entries = await fs.readdir(dir);
|
|
510
|
-
const nums = entries
|
|
511
|
-
.map((e) => Number.parseInt(e.replace(/\.ckpt\.json$/, ""), 10))
|
|
512
|
-
.filter((n) => Number.isFinite(n));
|
|
513
|
-
current = nums.length ? Math.max(...nums) : 0;
|
|
514
|
-
} catch {
|
|
515
|
-
current = 0;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
const next = (current ?? 0) + 1;
|
|
519
|
-
this.checkpointCounters.set(jobId, next);
|
|
520
|
-
const filename = `${String(next).padStart(6, "0")}.ckpt.json`;
|
|
521
|
-
const target = path.join(dir, filename);
|
|
522
|
-
const job = await this.getJob(jobId);
|
|
523
|
-
const createdAt = nowIso();
|
|
524
|
-
const payload = {
|
|
525
|
-
schema_version: 1,
|
|
526
|
-
job_id: jobId,
|
|
527
|
-
checkpoint_seq: next,
|
|
528
|
-
checkpoint_id: randomUUID(),
|
|
529
|
-
created_at: createdAt,
|
|
530
|
-
status: job?.state ?? "running",
|
|
531
|
-
stage: checkpoint.stage,
|
|
532
|
-
timestamp: checkpoint.timestamp ?? createdAt,
|
|
533
|
-
reason: checkpoint.details?.reason,
|
|
534
|
-
progress: {
|
|
535
|
-
total: job?.totalItems ?? (checkpoint.details as any)?.totalItems ?? null,
|
|
536
|
-
completed: job?.processedItems ?? (checkpoint.details as any)?.processedItems ?? null,
|
|
537
|
-
},
|
|
538
|
-
details: checkpoint.details,
|
|
539
|
-
};
|
|
540
|
-
await fs.writeFile(target, JSON.stringify(payload, null, 2), "utf8");
|
|
541
|
-
if (this.workspaceRepo) {
|
|
542
|
-
await this.workspaceRepo.updateJobState(jobId, {
|
|
543
|
-
lastCheckpoint: checkpoint.stage,
|
|
544
|
-
});
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
async appendLog(jobId: string, content: string): Promise<void> {
|
|
549
|
-
const logDir = this.logsDir(jobId);
|
|
550
|
-
await PathHelper.ensureDir(logDir);
|
|
551
|
-
const logPath = path.join(logDir, "stream.log");
|
|
552
|
-
await fs.appendFile(logPath, content, "utf8");
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
private async readTelemetryConfig(): Promise<{ optOut?: boolean; strict?: boolean } | undefined> {
|
|
556
|
-
const configPath = path.join(this.mcodaDir, "config.json");
|
|
557
|
-
try {
|
|
558
|
-
const raw = await fs.readFile(configPath, "utf8");
|
|
559
|
-
const parsed = JSON.parse(raw) as { telemetry?: { optOut?: boolean; strict?: boolean } };
|
|
560
|
-
return parsed.telemetry;
|
|
561
|
-
} catch {
|
|
562
|
-
return undefined;
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
private async shouldRecordTokenUsage(): Promise<boolean> {
|
|
567
|
-
if (this.telemetryConfig === undefined) {
|
|
568
|
-
this.telemetryConfig = await this.readTelemetryConfig();
|
|
569
|
-
}
|
|
570
|
-
if (this.telemetryConfig?.strict) {
|
|
571
|
-
if (!this.telemetryWarningShown) {
|
|
572
|
-
// eslint-disable-next-line no-console
|
|
573
|
-
console.warn("Telemetry strict mode is enabled; token usage will not be recorded locally.");
|
|
574
|
-
this.telemetryWarningShown = true;
|
|
575
|
-
}
|
|
576
|
-
return false;
|
|
577
|
-
}
|
|
578
|
-
if (
|
|
579
|
-
(this.perRunTelemetryDisabled || this.envTelemetryDisabled || this.telemetryConfig?.optOut) &&
|
|
580
|
-
!this.telemetryRemoteWarningShown
|
|
581
|
-
) {
|
|
582
|
-
// eslint-disable-next-line no-console
|
|
583
|
-
console.warn(
|
|
584
|
-
"Remote telemetry export disabled for this run (--no-telemetry/MCODA_TELEMETRY=off or opt-out). Local logging still enabled unless telemetry.strict is set.",
|
|
585
|
-
);
|
|
586
|
-
this.telemetryRemoteWarningShown = true;
|
|
587
|
-
}
|
|
588
|
-
return true;
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
async recordTokenUsage(entry: TokenUsageRecord): Promise<void> {
|
|
592
|
-
const recordTelemetry = await this.shouldRecordTokenUsage();
|
|
593
|
-
if (!recordTelemetry) return;
|
|
594
|
-
const normalized: TokenUsageInsert = {
|
|
595
|
-
workspaceId: entry.workspaceId ?? this.workspaceId,
|
|
596
|
-
agentId: entry.agentId ?? null,
|
|
597
|
-
modelName: entry.modelName ?? null,
|
|
598
|
-
jobId: entry.jobId ?? null,
|
|
599
|
-
commandRunId: entry.commandRunId ?? null,
|
|
600
|
-
taskRunId: entry.taskRunId ?? null,
|
|
601
|
-
taskId: entry.taskId ?? null,
|
|
602
|
-
projectId: entry.projectId ?? null,
|
|
603
|
-
epicId: entry.epicId ?? null,
|
|
604
|
-
userStoryId: entry.userStoryId ?? null,
|
|
605
|
-
tokensPrompt: entry.tokensPrompt ?? entry.promptTokens ?? null,
|
|
606
|
-
tokensCompletion: entry.tokensCompletion ?? entry.completionTokens ?? null,
|
|
607
|
-
tokensTotal: entry.tokensTotal ?? null,
|
|
608
|
-
costEstimate: entry.costEstimate ?? entry.costUsd ?? null,
|
|
609
|
-
durationSeconds: entry.durationSeconds ?? null,
|
|
610
|
-
timestamp: entry.timestamp,
|
|
611
|
-
metadata: {
|
|
612
|
-
...(entry.metadata ?? {}),
|
|
613
|
-
...(entry.commandName ? { commandName: entry.commandName } : {}),
|
|
614
|
-
...(entry.action ? { action: entry.action } : {}),
|
|
615
|
-
},
|
|
616
|
-
};
|
|
617
|
-
const fileRecord = {
|
|
618
|
-
...normalized,
|
|
619
|
-
...(entry.commandName ? { commandName: entry.commandName } : {}),
|
|
620
|
-
...(entry.action ? { action: entry.action } : {}),
|
|
621
|
-
};
|
|
622
|
-
await this.appendJsonArray(this.tokenUsagePath, fileRecord as any);
|
|
623
|
-
if (this.workspaceRepo) {
|
|
624
|
-
await this.workspaceRepo.recordTokenUsage(normalized);
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
async writeManifest(job: JobRecord, extras: Record<string, unknown> = {}): Promise<void> {
|
|
629
|
-
await PathHelper.ensureDir(this.jobDir(job.id));
|
|
630
|
-
const manifestPath = this.manifestPath(job.id);
|
|
631
|
-
const payload = {
|
|
632
|
-
schema_version: 1,
|
|
633
|
-
job_id: job.id,
|
|
634
|
-
updated_at: new Date().toISOString(),
|
|
635
|
-
status: (job as any).status ?? job.state,
|
|
636
|
-
progress: { total: job.totalItems ?? null, completed: job.processedItems ?? null },
|
|
637
|
-
...job,
|
|
638
|
-
...extras,
|
|
639
|
-
};
|
|
640
|
-
await fs.writeFile(manifestPath, JSON.stringify(payload, null, 2), "utf8");
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
async close(): Promise<void> {
|
|
644
|
-
if (this.workspaceRepo) {
|
|
645
|
-
await this.workspaceRepo.close();
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
}
|