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,595 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { JobInsightsService, JobResumeService, JobService, TelemetryService, TokenUsageRow, WorkspaceResolver, WorkspaceResolution } from "@mcoda/core";
|
|
3
|
-
import { DocsCommands } from "../docs/DocsCommands.js";
|
|
4
|
-
|
|
5
|
-
type JobSubcommand = "list" | "status" | "watch" | "logs" | "inspect" | "resume" | "cancel" | "tokens";
|
|
6
|
-
|
|
7
|
-
export interface ParsedJobArgs {
|
|
8
|
-
subcommand: JobSubcommand;
|
|
9
|
-
jobId?: string;
|
|
10
|
-
workspaceRoot?: string;
|
|
11
|
-
project?: string;
|
|
12
|
-
status?: string;
|
|
13
|
-
type?: string;
|
|
14
|
-
since?: string;
|
|
15
|
-
limit?: number;
|
|
16
|
-
json?: boolean;
|
|
17
|
-
intervalSeconds?: number;
|
|
18
|
-
noLogs?: boolean;
|
|
19
|
-
follow?: boolean;
|
|
20
|
-
agent?: string;
|
|
21
|
-
noTelemetry?: boolean;
|
|
22
|
-
force?: boolean;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const usage = `mcoda job <list|status|watch|logs|inspect|resume|cancel|tokens> ...
|
|
26
|
-
|
|
27
|
-
Commands:
|
|
28
|
-
mcoda job list [--project <KEY>] [--status <STATE>] [--type <TYPE>] [--since <DURATION|TIMESTAMP>] [--limit <N>] [--json]
|
|
29
|
-
mcoda job status <JOB_ID> [--json]
|
|
30
|
-
mcoda job watch <JOB_ID> [--interval <SECONDS>] [--no-logs]
|
|
31
|
-
mcoda job logs <JOB_ID> [--since <TIMESTAMP|DURATION>] [--follow]
|
|
32
|
-
mcoda job inspect <JOB_ID> [--json]
|
|
33
|
-
mcoda job resume <JOB_ID> [--agent <NAME>] [--no-telemetry]
|
|
34
|
-
mcoda job cancel <JOB_ID> [--force]
|
|
35
|
-
mcoda job tokens <JOB_ID> [--since <TIMESTAMP|DURATION>] [--format table|json]
|
|
36
|
-
|
|
37
|
-
Flags:
|
|
38
|
-
--workspace-root <PATH> Override workspace root (defaults to cwd)
|
|
39
|
-
--project <KEY> Filter jobs by project key (when available in payload)
|
|
40
|
-
--status <STATE> Filter by job state (queued|running|checkpointing|paused|completed|failed|cancelled)
|
|
41
|
-
--type <TYPE> Filter by job type (task_creation|task_refinement|work|review|qa|pdr_generate|sds_generate|openapi_change|other)
|
|
42
|
-
--since <DURATION|TS> Time filter (e.g. 1h, 24h, 2025-01-01T00:00:00Z)
|
|
43
|
-
--limit <N> Max rows for list (default 50)
|
|
44
|
-
--json JSON output for list/status/inspect
|
|
45
|
-
Jobs API required Set MCODA_API_BASE_URL/MCODA_JOBS_API_URL or workspace api.baseUrl for all job commands
|
|
46
|
-
|
|
47
|
-
Examples:
|
|
48
|
-
mcoda job list --status running
|
|
49
|
-
mcoda job status <JOB_ID> --json
|
|
50
|
-
mcoda job watch <JOB_ID> --interval 2 --no-logs
|
|
51
|
-
mcoda job logs <JOB_ID> --since 10m --follow
|
|
52
|
-
mcoda job inspect <JOB_ID>
|
|
53
|
-
mcoda job resume <JOB_ID> --agent codex
|
|
54
|
-
mcoda job cancel <JOB_ID>
|
|
55
|
-
mcoda job tokens <JOB_ID> --since 24h
|
|
56
|
-
|
|
57
|
-
Exit codes:
|
|
58
|
-
status/watch/logs return non-zero when a job is failed or cancelled.
|
|
59
|
-
|
|
60
|
-
Run "mcoda job --help" to see all flags and usage details for job management.`;
|
|
61
|
-
|
|
62
|
-
export const parseJobArgs = (argv: string[]): ParsedJobArgs => {
|
|
63
|
-
if (argv.length === 0 || argv.includes("--help") || argv.includes("-h")) {
|
|
64
|
-
// eslint-disable-next-line no-console
|
|
65
|
-
console.log(usage);
|
|
66
|
-
process.exit(0);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
let subcommand: JobSubcommand | undefined;
|
|
70
|
-
let workspaceRoot: string | undefined;
|
|
71
|
-
let jobId: string | undefined;
|
|
72
|
-
let project: string | undefined;
|
|
73
|
-
let status: string | undefined;
|
|
74
|
-
let type: string | undefined;
|
|
75
|
-
let since: string | undefined;
|
|
76
|
-
let limit: number | undefined;
|
|
77
|
-
let json = false;
|
|
78
|
-
let intervalSeconds: number | undefined;
|
|
79
|
-
let noLogs = false;
|
|
80
|
-
let follow = false;
|
|
81
|
-
let agent: string | undefined;
|
|
82
|
-
let noTelemetry = false;
|
|
83
|
-
let force = false;
|
|
84
|
-
|
|
85
|
-
const [first, ...rest] = argv;
|
|
86
|
-
if (first && !first.startsWith("--")) {
|
|
87
|
-
subcommand = first as JobSubcommand;
|
|
88
|
-
}
|
|
89
|
-
const args = subcommand ? rest : argv;
|
|
90
|
-
|
|
91
|
-
for (let i = 0; i < args.length; i += 1) {
|
|
92
|
-
const arg = args[i];
|
|
93
|
-
if (!arg.startsWith("--") && !jobId) {
|
|
94
|
-
jobId = arg;
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
switch (arg) {
|
|
98
|
-
case "--workspace-root":
|
|
99
|
-
case "--workspace":
|
|
100
|
-
workspaceRoot = args[i + 1] ? path.resolve(args[i + 1]) : undefined;
|
|
101
|
-
i += 1;
|
|
102
|
-
break;
|
|
103
|
-
case "--project":
|
|
104
|
-
project = args[i + 1];
|
|
105
|
-
i += 1;
|
|
106
|
-
break;
|
|
107
|
-
case "--status":
|
|
108
|
-
status = args[i + 1];
|
|
109
|
-
i += 1;
|
|
110
|
-
break;
|
|
111
|
-
case "--type":
|
|
112
|
-
type = args[i + 1];
|
|
113
|
-
i += 1;
|
|
114
|
-
break;
|
|
115
|
-
case "--since":
|
|
116
|
-
since = args[i + 1];
|
|
117
|
-
i += 1;
|
|
118
|
-
break;
|
|
119
|
-
case "--limit":
|
|
120
|
-
limit = Number(args[i + 1]);
|
|
121
|
-
i += 1;
|
|
122
|
-
break;
|
|
123
|
-
case "--interval":
|
|
124
|
-
intervalSeconds = Number(args[i + 1]);
|
|
125
|
-
i += 1;
|
|
126
|
-
break;
|
|
127
|
-
case "--no-logs":
|
|
128
|
-
noLogs = true;
|
|
129
|
-
break;
|
|
130
|
-
case "--follow":
|
|
131
|
-
follow = true;
|
|
132
|
-
break;
|
|
133
|
-
case "--agent":
|
|
134
|
-
agent = args[i + 1];
|
|
135
|
-
i += 1;
|
|
136
|
-
break;
|
|
137
|
-
case "--no-telemetry":
|
|
138
|
-
noTelemetry = true;
|
|
139
|
-
break;
|
|
140
|
-
case "--force":
|
|
141
|
-
force = true;
|
|
142
|
-
break;
|
|
143
|
-
case "--json":
|
|
144
|
-
json = true;
|
|
145
|
-
break;
|
|
146
|
-
case "--format":
|
|
147
|
-
json = args[i + 1] === "json";
|
|
148
|
-
i += 1;
|
|
149
|
-
break;
|
|
150
|
-
case "--id":
|
|
151
|
-
jobId = args[i + 1];
|
|
152
|
-
i += 1;
|
|
153
|
-
break;
|
|
154
|
-
default:
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
if (!subcommand || !["list", "status", "watch", "logs", "inspect", "resume", "cancel", "tokens"].includes(subcommand)) {
|
|
160
|
-
throw new Error(`Unknown job subcommand.\n\n${usage}`);
|
|
161
|
-
}
|
|
162
|
-
if (["status", "watch", "logs", "inspect", "resume", "cancel", "tokens"].includes(subcommand) && !jobId) {
|
|
163
|
-
throw new Error(`${subcommand} requires a JOB_ID.\n\n${usage}`);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
return {
|
|
167
|
-
subcommand,
|
|
168
|
-
jobId,
|
|
169
|
-
workspaceRoot,
|
|
170
|
-
project,
|
|
171
|
-
status,
|
|
172
|
-
type,
|
|
173
|
-
since,
|
|
174
|
-
limit: Number.isFinite(limit) ? (limit as number) : undefined,
|
|
175
|
-
json,
|
|
176
|
-
intervalSeconds: Number.isFinite(intervalSeconds) ? (intervalSeconds as number) : undefined,
|
|
177
|
-
noLogs,
|
|
178
|
-
follow,
|
|
179
|
-
agent,
|
|
180
|
-
noTelemetry,
|
|
181
|
-
force,
|
|
182
|
-
};
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
const pad = (value: string, width: number): string => value.padEnd(width, " ");
|
|
186
|
-
|
|
187
|
-
const formatTable = (headers: string[], rows: string[][]): string => {
|
|
188
|
-
if (rows.length === 0) return headers.join(" | ");
|
|
189
|
-
const widths = headers.map((header, idx) => Math.max(header.length, ...rows.map((row) => (row[idx] ?? "").length)));
|
|
190
|
-
const headerLine = headers.map((h, idx) => pad(h, widths[idx])).join(" | ");
|
|
191
|
-
const sepLine = widths.map((w) => "-".repeat(w)).join("-+-");
|
|
192
|
-
const body = rows.map((row) => row.map((cell, idx) => pad(cell ?? "", widths[idx])).join(" | ")).join("\n");
|
|
193
|
-
return [headerLine, sepLine, body].filter(Boolean).join("\n");
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
const formatProgress = (total?: number | null, completed?: number | null): string => {
|
|
197
|
-
if (!total || total <= 0) return "-";
|
|
198
|
-
const pct = Math.round(((completed ?? 0) / total) * 100);
|
|
199
|
-
return `${pct}% (${completed ?? 0}/${total})`;
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const isTerminalState = (state: string | undefined): boolean => {
|
|
203
|
-
if (!state) return false;
|
|
204
|
-
return ["completed", "failed", "cancelled", "paused"].includes(state);
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const statusExitCode = (state: string | undefined): number => {
|
|
208
|
-
if (!state) return 1;
|
|
209
|
-
if (["failed", "cancelled"].includes(state)) return 1;
|
|
210
|
-
return 0;
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
const renderJobTokens = (rows: TokenUsageRow[]): void => {
|
|
214
|
-
if (rows.length === 0) {
|
|
215
|
-
// eslint-disable-next-line no-console
|
|
216
|
-
console.log("No telemetry data for this job.");
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
const headers = [
|
|
220
|
-
"TIME",
|
|
221
|
-
"ACTION",
|
|
222
|
-
"COMMAND",
|
|
223
|
-
"CMD_RUN",
|
|
224
|
-
"TASK",
|
|
225
|
-
"AGENT",
|
|
226
|
-
"MODEL",
|
|
227
|
-
"TOKENS_IN",
|
|
228
|
-
"TOKENS_OUT",
|
|
229
|
-
"TOKENS_TOTAL",
|
|
230
|
-
"DURATION_MS",
|
|
231
|
-
"ERROR_KIND",
|
|
232
|
-
];
|
|
233
|
-
const tableRows = rows.map((row) => [
|
|
234
|
-
row.timestamp,
|
|
235
|
-
row.action ?? "-",
|
|
236
|
-
row.command_name ?? "-",
|
|
237
|
-
row.command_run_id ?? "-",
|
|
238
|
-
row.task_id ?? row.task_run_id ?? "-",
|
|
239
|
-
row.agent_id ?? "-",
|
|
240
|
-
row.model_name ?? "-",
|
|
241
|
-
row.tokens_prompt != null ? `${row.tokens_prompt}` : "-",
|
|
242
|
-
row.tokens_completion != null ? `${row.tokens_completion}` : "-",
|
|
243
|
-
row.tokens_total != null ? `${row.tokens_total}` : "-",
|
|
244
|
-
row.duration_seconds != null ? `${Math.round(row.duration_seconds * 1000)}` : "-",
|
|
245
|
-
row.error_kind ?? "-",
|
|
246
|
-
]);
|
|
247
|
-
// eslint-disable-next-line no-console
|
|
248
|
-
console.log(formatTable(headers, tableRows));
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
const printLogs = (entries: { timestamp: string; taskKey?: string | null; source?: string | null; message?: string | null; level?: string | null; phase?: string | null }[]): void => {
|
|
252
|
-
for (const entry of entries) {
|
|
253
|
-
const parts = [entry.timestamp];
|
|
254
|
-
if (entry.taskKey) parts.push(`[${entry.taskKey}]`);
|
|
255
|
-
if (entry.phase) parts.push(entry.phase);
|
|
256
|
-
if (entry.source) parts.push(entry.source);
|
|
257
|
-
const prefix = parts.join(" ");
|
|
258
|
-
// eslint-disable-next-line no-console
|
|
259
|
-
console.log(`${prefix}: ${entry.message ?? ""}`.trim());
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
const sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));
|
|
264
|
-
|
|
265
|
-
const printJobStatus = (
|
|
266
|
-
job: {
|
|
267
|
-
id: string;
|
|
268
|
-
type: string;
|
|
269
|
-
commandName?: string;
|
|
270
|
-
commandRunId?: string;
|
|
271
|
-
state?: string;
|
|
272
|
-
stateDetail?: string;
|
|
273
|
-
jobState?: string;
|
|
274
|
-
jobStateDetail?: string;
|
|
275
|
-
errorSummary?: string;
|
|
276
|
-
totalItems?: number | null;
|
|
277
|
-
processedItems?: number | null;
|
|
278
|
-
totalUnits?: number | null;
|
|
279
|
-
completedUnits?: number | null;
|
|
280
|
-
createdAt?: string;
|
|
281
|
-
updatedAt?: string;
|
|
282
|
-
completedAt?: string | null;
|
|
283
|
-
},
|
|
284
|
-
checkpoint?: { stage?: string; timestamp?: string },
|
|
285
|
-
): void => {
|
|
286
|
-
// eslint-disable-next-line no-console
|
|
287
|
-
console.log(`Job ${job.id} (${job.commandName ?? job.type})`);
|
|
288
|
-
if (job.commandRunId) {
|
|
289
|
-
// eslint-disable-next-line no-console
|
|
290
|
-
console.log(`Command Run: ${job.commandRunId}`);
|
|
291
|
-
}
|
|
292
|
-
// eslint-disable-next-line no-console
|
|
293
|
-
console.log(
|
|
294
|
-
`State: ${job.jobState ?? job.state ?? "unknown"}${job.jobStateDetail ? ` (${job.jobStateDetail})` : job.stateDetail ? ` (${job.stateDetail})` : ""}${
|
|
295
|
-
job.errorSummary ? ` [${job.errorSummary}]` : ""
|
|
296
|
-
}`,
|
|
297
|
-
);
|
|
298
|
-
// eslint-disable-next-line no-console
|
|
299
|
-
console.log(
|
|
300
|
-
`Progress: ${formatProgress(
|
|
301
|
-
(job as any).totalUnits ?? job.totalItems,
|
|
302
|
-
(job as any).completedUnits ?? job.processedItems,
|
|
303
|
-
)}`,
|
|
304
|
-
);
|
|
305
|
-
if (job.createdAt) {
|
|
306
|
-
// eslint-disable-next-line no-console
|
|
307
|
-
console.log(`Created: ${job.createdAt}`);
|
|
308
|
-
}
|
|
309
|
-
if (job.updatedAt) {
|
|
310
|
-
// eslint-disable-next-line no-console
|
|
311
|
-
console.log(`Updated: ${job.updatedAt}`);
|
|
312
|
-
}
|
|
313
|
-
if (job.completedAt) {
|
|
314
|
-
// eslint-disable-next-line no-console
|
|
315
|
-
console.log(`Completed: ${job.completedAt}`);
|
|
316
|
-
}
|
|
317
|
-
if (checkpoint?.stage || checkpoint?.timestamp) {
|
|
318
|
-
// eslint-disable-next-line no-console
|
|
319
|
-
console.log(`Last checkpoint: ${checkpoint?.stage ?? ""}${checkpoint?.timestamp ? ` @ ${checkpoint.timestamp}` : ""}`.trim());
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
const handleResume = async (
|
|
324
|
-
parsed: ParsedJobArgs,
|
|
325
|
-
workspace: WorkspaceResolution,
|
|
326
|
-
resumeService: JobResumeService,
|
|
327
|
-
): Promise<void> => {
|
|
328
|
-
if (!parsed.jobId) throw new Error("resume requires a job id");
|
|
329
|
-
await resumeService.resume(parsed.jobId, { agentName: parsed.agent, noTelemetry: parsed.noTelemetry });
|
|
330
|
-
};
|
|
331
|
-
|
|
332
|
-
const handleCancel = async (parsed: ParsedJobArgs, jobService: JobService, insights: JobInsightsService): Promise<void> => {
|
|
333
|
-
if (!parsed.jobId) throw new Error("cancel requires a job id");
|
|
334
|
-
const existing = await insights.getJob(parsed.jobId);
|
|
335
|
-
if (!existing) {
|
|
336
|
-
throw new Error(`Job not found: ${parsed.jobId}`);
|
|
337
|
-
}
|
|
338
|
-
const currentState = (existing as any).jobState ?? existing.state ?? "unknown";
|
|
339
|
-
const cancellableStates = new Set(["queued", "running", "checkpointing", "paused"]);
|
|
340
|
-
const terminalStates = new Set(["completed", "failed", "cancelled"]);
|
|
341
|
-
if (terminalStates.has(currentState) && !parsed.force) {
|
|
342
|
-
throw new Error(`Job ${existing.id} is ${currentState}; rerun with --force to mark cancelled.`);
|
|
343
|
-
}
|
|
344
|
-
if (!cancellableStates.has(currentState) && !parsed.force) {
|
|
345
|
-
throw new Error(`Job ${existing.id} is ${currentState}; rerun with --force to mark cancelled.`);
|
|
346
|
-
}
|
|
347
|
-
const reason = parsed.force ? "force" : "user";
|
|
348
|
-
await insights.cancelJob(parsed.jobId, { force: parsed.force, reason });
|
|
349
|
-
const updated = await insights.getJob(parsed.jobId);
|
|
350
|
-
if (updated) {
|
|
351
|
-
// eslint-disable-next-line no-console
|
|
352
|
-
console.log(`Job ${updated.id} is now ${updated.state ?? updated.jobState ?? "cancelled"}`);
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
const handleTokens = async (parsed: ParsedJobArgs, workspace: WorkspaceResolution): Promise<void> => {
|
|
357
|
-
if (!parsed.jobId) throw new Error("tokens requires a job id");
|
|
358
|
-
const telemetry = await TelemetryService.create(workspace, { allowMissingTelemetry: false, requireApi: true });
|
|
359
|
-
try {
|
|
360
|
-
const usage = await telemetry.getTokenUsage({ jobId: parsed.jobId, since: parsed.since });
|
|
361
|
-
if (parsed.json) {
|
|
362
|
-
// eslint-disable-next-line no-console
|
|
363
|
-
console.log(JSON.stringify(usage, null, 2));
|
|
364
|
-
} else {
|
|
365
|
-
renderJobTokens(usage);
|
|
366
|
-
if (usage.length === 0) {
|
|
367
|
-
// eslint-disable-next-line no-console
|
|
368
|
-
console.log("No telemetry data for the selected filters/time window.");
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
} finally {
|
|
372
|
-
await telemetry.close();
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
export class JobsCommands {
|
|
377
|
-
static async run(argv: string[]): Promise<void> {
|
|
378
|
-
const parsed = parseJobArgs(argv);
|
|
379
|
-
const workspace = await WorkspaceResolver.resolveWorkspace({
|
|
380
|
-
cwd: process.cwd(),
|
|
381
|
-
explicitWorkspace: parsed.workspaceRoot,
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
const jobService = new JobService(workspace, undefined, {
|
|
385
|
-
noTelemetry: parsed.noTelemetry,
|
|
386
|
-
requireRepo: true,
|
|
387
|
-
});
|
|
388
|
-
const apiBaseUrl =
|
|
389
|
-
(workspace as any).config?.api?.baseUrl ??
|
|
390
|
-
process.env.MCODA_API_BASE_URL ??
|
|
391
|
-
process.env.MCODA_JOBS_API_URL ??
|
|
392
|
-
undefined;
|
|
393
|
-
if (!apiBaseUrl) {
|
|
394
|
-
throw new Error(
|
|
395
|
-
"Jobs API is not configured. Set MCODA_API_BASE_URL/MCODA_JOBS_API_URL or configure workspace api.baseUrl to use job commands.",
|
|
396
|
-
);
|
|
397
|
-
}
|
|
398
|
-
const insights = new JobInsightsService(workspace, jobService, apiBaseUrl);
|
|
399
|
-
const resumeService = new JobResumeService(workspace, jobService);
|
|
400
|
-
const commandRun = await jobService.startCommandRun(`job ${parsed.subcommand}`, undefined, { jobId: parsed.jobId });
|
|
401
|
-
try {
|
|
402
|
-
if (parsed.subcommand === "list") {
|
|
403
|
-
const jobs = await insights.listJobs({
|
|
404
|
-
projectKey: parsed.project,
|
|
405
|
-
status: parsed.status,
|
|
406
|
-
type: parsed.type,
|
|
407
|
-
since: parsed.since,
|
|
408
|
-
limit: parsed.limit,
|
|
409
|
-
});
|
|
410
|
-
if (parsed.json) {
|
|
411
|
-
// eslint-disable-next-line no-console
|
|
412
|
-
console.log(JSON.stringify(jobs, null, 2));
|
|
413
|
-
} else if (jobs.length === 0) {
|
|
414
|
-
// eslint-disable-next-line no-console
|
|
415
|
-
console.log("No jobs found.");
|
|
416
|
-
} else {
|
|
417
|
-
const headers = ["ID", "TYPE", "COMMAND", "STATE", "DETAIL", "PROGRESS", "CREATED", "UPDATED"];
|
|
418
|
-
const rows = jobs.map((job) => [
|
|
419
|
-
job.id,
|
|
420
|
-
job.type,
|
|
421
|
-
job.commandName ?? "-",
|
|
422
|
-
job.jobState ?? job.state ?? "-",
|
|
423
|
-
job.jobStateDetail ?? (job as any).stateDetail ?? job.errorSummary ?? "-",
|
|
424
|
-
formatProgress(job.totalUnits ?? job.totalItems, job.completedUnits ?? job.processedItems),
|
|
425
|
-
job.createdAt ?? "-",
|
|
426
|
-
job.updatedAt ?? "-",
|
|
427
|
-
]);
|
|
428
|
-
// eslint-disable-next-line no-console
|
|
429
|
-
console.log(formatTable(headers, rows));
|
|
430
|
-
}
|
|
431
|
-
await jobService.finishCommandRun(commandRun.id, "succeeded");
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
if (parsed.subcommand === "status") {
|
|
436
|
-
const job = parsed.jobId ? await insights.getJob(parsed.jobId) : undefined;
|
|
437
|
-
if (!job) throw new Error(`Job not found: ${parsed.jobId}`);
|
|
438
|
-
const checkpoint = parsed.jobId ? await insights.latestCheckpoint(parsed.jobId) : undefined;
|
|
439
|
-
if (parsed.json) {
|
|
440
|
-
const payload = {
|
|
441
|
-
job: {
|
|
442
|
-
...job,
|
|
443
|
-
job_state: (job as any).jobState ?? job.state,
|
|
444
|
-
job_state_detail: job.jobStateDetail ?? (job as any).stateDetail ?? job.errorSummary,
|
|
445
|
-
total_units: job.totalUnits ?? job.totalItems,
|
|
446
|
-
completed_units: job.completedUnits ?? job.processedItems,
|
|
447
|
-
},
|
|
448
|
-
checkpoint,
|
|
449
|
-
};
|
|
450
|
-
// eslint-disable-next-line no-console
|
|
451
|
-
console.log(JSON.stringify(payload, null, 2));
|
|
452
|
-
} else {
|
|
453
|
-
printJobStatus({ ...job, stateDetail: (job as any).stateDetail ?? job.errorSummary }, checkpoint);
|
|
454
|
-
}
|
|
455
|
-
const exit = statusExitCode(job.jobState ?? job.state);
|
|
456
|
-
if (exit !== 0) process.exitCode = exit;
|
|
457
|
-
await jobService.finishCommandRun(commandRun.id, exit === 0 ? "succeeded" : "failed", job.errorSummary);
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
if (parsed.subcommand === "watch") {
|
|
462
|
-
const intervalMs = Math.max(1, parsed.intervalSeconds ?? 3) * 1000;
|
|
463
|
-
let stop = false;
|
|
464
|
-
let logCursor: { timestamp: string; sequence?: number | null } | undefined;
|
|
465
|
-
const onSigint = () => {
|
|
466
|
-
stop = true;
|
|
467
|
-
};
|
|
468
|
-
process.once("SIGINT", onSigint);
|
|
469
|
-
while (!stop) {
|
|
470
|
-
const job = parsed.jobId ? await insights.getJob(parsed.jobId) : undefined;
|
|
471
|
-
if (!job) throw new Error(`Job not found: ${parsed.jobId}`);
|
|
472
|
-
const checkpoint = parsed.jobId ? await insights.latestCheckpoint(parsed.jobId) : undefined;
|
|
473
|
-
printJobStatus(job, checkpoint);
|
|
474
|
-
if (!parsed.noLogs) {
|
|
475
|
-
const logs = await insights.getJobLogs(parsed.jobId!, { since: logCursor ? undefined : parsed.since, after: logCursor });
|
|
476
|
-
printLogs(logs.entries);
|
|
477
|
-
logCursor = logs.cursor;
|
|
478
|
-
}
|
|
479
|
-
if (isTerminalState(job.state)) {
|
|
480
|
-
const exit = statusExitCode(job.state);
|
|
481
|
-
if (exit !== 0) process.exitCode = exit;
|
|
482
|
-
// eslint-disable-next-line no-console
|
|
483
|
-
console.log(`Job reached terminal state: ${job.state}`);
|
|
484
|
-
break;
|
|
485
|
-
}
|
|
486
|
-
await sleep(intervalMs);
|
|
487
|
-
}
|
|
488
|
-
process.removeListener("SIGINT", onSigint);
|
|
489
|
-
await jobService.finishCommandRun(commandRun.id, process.exitCode ? "failed" : "succeeded");
|
|
490
|
-
return;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
if (parsed.subcommand === "logs") {
|
|
494
|
-
let logCursor: { timestamp: string; sequence?: number | null } | undefined;
|
|
495
|
-
const intervalMs = Math.max(1, parsed.intervalSeconds ?? 3) * 1000;
|
|
496
|
-
let done = false;
|
|
497
|
-
const onSigint = () => {
|
|
498
|
-
done = true;
|
|
499
|
-
};
|
|
500
|
-
process.once("SIGINT", onSigint);
|
|
501
|
-
while (!done) {
|
|
502
|
-
const logs = await insights.getJobLogs(parsed.jobId!, { since: logCursor ? undefined : parsed.since, after: logCursor });
|
|
503
|
-
printLogs(logs.entries);
|
|
504
|
-
logCursor = logs.cursor;
|
|
505
|
-
|
|
506
|
-
if (!parsed.follow) break;
|
|
507
|
-
const job = await insights.getJob(parsed.jobId!);
|
|
508
|
-
if (job && isTerminalState(job.state)) {
|
|
509
|
-
const exit = statusExitCode(job.state);
|
|
510
|
-
if (exit !== 0) process.exitCode = exit;
|
|
511
|
-
break;
|
|
512
|
-
}
|
|
513
|
-
await sleep(intervalMs);
|
|
514
|
-
}
|
|
515
|
-
process.removeListener("SIGINT", onSigint);
|
|
516
|
-
await jobService.finishCommandRun(commandRun.id, "succeeded");
|
|
517
|
-
return;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
if (parsed.subcommand === "inspect") {
|
|
521
|
-
const job = parsed.jobId ? await insights.getJob(parsed.jobId) : undefined;
|
|
522
|
-
if (!job) throw new Error(`Job not found: ${parsed.jobId}`);
|
|
523
|
-
const checkpoint = await insights.latestCheckpoint(parsed.jobId!);
|
|
524
|
-
const tasks = await insights.summarizeTasks(parsed.jobId!);
|
|
525
|
-
const tokens = await insights.summarizeTokenUsage(parsed.jobId!);
|
|
526
|
-
const payload = { job, checkpoint, tasks, tokens };
|
|
527
|
-
if (parsed.json) {
|
|
528
|
-
// eslint-disable-next-line no-console
|
|
529
|
-
console.log(JSON.stringify(payload, null, 2));
|
|
530
|
-
} else {
|
|
531
|
-
printJobStatus(job, checkpoint);
|
|
532
|
-
if (job.commandRunId) {
|
|
533
|
-
// eslint-disable-next-line no-console
|
|
534
|
-
console.log(`Command run: ${job.commandRunId}`);
|
|
535
|
-
}
|
|
536
|
-
// eslint-disable-next-line no-console
|
|
537
|
-
console.log("\nTasks:");
|
|
538
|
-
const totalsLine = Object.entries(tasks.totals)
|
|
539
|
-
.map(([key, value]) => `${key}=${value}`)
|
|
540
|
-
.join(" ");
|
|
541
|
-
// eslint-disable-next-line no-console
|
|
542
|
-
console.log(totalsLine || "(no task runs)");
|
|
543
|
-
tasks.tasks.forEach((task) => {
|
|
544
|
-
const parts = [task.taskKey ?? task.taskId ?? "(unknown)", task.status ?? "unknown"];
|
|
545
|
-
if (task.startedAt) parts.push(`started ${task.startedAt}`);
|
|
546
|
-
if (task.finishedAt) parts.push(`finished ${task.finishedAt}`);
|
|
547
|
-
// eslint-disable-next-line no-console
|
|
548
|
-
console.log(`- ${parts.join(" | ")}`);
|
|
549
|
-
});
|
|
550
|
-
if (tokens.length) {
|
|
551
|
-
// eslint-disable-next-line no-console
|
|
552
|
-
console.log("\nToken usage:");
|
|
553
|
-
tokens.forEach((row) => {
|
|
554
|
-
const r: any = row as any;
|
|
555
|
-
// eslint-disable-next-line no-console
|
|
556
|
-
console.log(
|
|
557
|
-
`- command=${r.commandName ?? job.commandName ?? "-"} agent=${row.agentId ?? "-"} model=${row.modelName ?? "-"} tokens=${row.tokensTotal ?? row.tokensPrompt ?? 0}` +
|
|
558
|
-
(row.cost != null ? ` cost=${row.cost}` : "") +
|
|
559
|
-
(r.commandRunId ? ` cmd_run=${r.commandRunId}` : "") +
|
|
560
|
-
(r.taskId ? ` task=${r.taskId}` : ""),
|
|
561
|
-
);
|
|
562
|
-
});
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
await jobService.finishCommandRun(commandRun.id, "succeeded");
|
|
566
|
-
return;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
if (parsed.subcommand === "resume") {
|
|
570
|
-
await handleResume(parsed, workspace, resumeService);
|
|
571
|
-
await jobService.finishCommandRun(commandRun.id, process.exitCode ? "failed" : "succeeded");
|
|
572
|
-
return;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
if (parsed.subcommand === "cancel") {
|
|
576
|
-
await handleCancel(parsed, jobService, insights);
|
|
577
|
-
await jobService.finishCommandRun(commandRun.id, "succeeded");
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
if (parsed.subcommand === "tokens") {
|
|
582
|
-
await handleTokens(parsed, workspace);
|
|
583
|
-
await jobService.finishCommandRun(commandRun.id, "succeeded");
|
|
584
|
-
}
|
|
585
|
-
} catch (error) {
|
|
586
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
587
|
-
// eslint-disable-next-line no-console
|
|
588
|
-
console.error(message);
|
|
589
|
-
process.exitCode = process.exitCode ?? 1;
|
|
590
|
-
await jobService.finishCommandRun(commandRun.id, "failed", message);
|
|
591
|
-
} finally {
|
|
592
|
-
await insights.close();
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
}
|