@mcoda/core 0.1.37 → 0.1.40

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.
Files changed (29) hide show
  1. package/dist/api/MswarmApi.d.ts +155 -0
  2. package/dist/api/MswarmApi.d.ts.map +1 -0
  3. package/dist/api/MswarmApi.js +593 -0
  4. package/dist/api/MswarmConfigStore.d.ts +53 -0
  5. package/dist/api/MswarmConfigStore.d.ts.map +1 -0
  6. package/dist/api/MswarmConfigStore.js +111 -0
  7. package/dist/index.d.ts +3 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +3 -0
  10. package/dist/services/docs/DocsService.d.ts.map +1 -1
  11. package/dist/services/docs/DocsService.js +1 -11
  12. package/dist/services/estimate/VelocityService.d.ts.map +1 -1
  13. package/dist/services/estimate/VelocityService.js +1 -2
  14. package/dist/services/execution/AddTestsService.d.ts.map +1 -1
  15. package/dist/services/execution/AddTestsService.js +2 -2
  16. package/dist/services/execution/QaTasksService.d.ts.map +1 -1
  17. package/dist/services/execution/QaTasksService.js +3 -2
  18. package/dist/services/execution/WorkOnTasksService.d.ts.map +1 -1
  19. package/dist/services/execution/WorkOnTasksService.js +2 -6
  20. package/dist/services/openapi/OpenApiService.d.ts.map +1 -1
  21. package/dist/services/openapi/OpenApiService.js +1 -11
  22. package/dist/services/planning/CreateTasksService.d.ts +9 -0
  23. package/dist/services/planning/CreateTasksService.d.ts.map +1 -1
  24. package/dist/services/planning/CreateTasksService.js +490 -209
  25. package/dist/services/review/CodeReviewService.js +2 -2
  26. package/dist/services/shared/GitBranch.d.ts +6 -0
  27. package/dist/services/shared/GitBranch.d.ts.map +1 -0
  28. package/dist/services/shared/GitBranch.js +62 -0
  29. package/package.json +6 -6
@@ -14,11 +14,11 @@ import { createTaskKeyGenerator } from "../planning/KeyHelpers.js";
14
14
  import { RoutingService } from "../agents/RoutingService.js";
15
15
  import { AgentRatingService } from "../agents/AgentRatingService.js";
16
16
  import { ensureProjectGuidance, isDocContextExcluded, loadProjectGuidance, normalizeDocType, } from "../shared/ProjectGuidance.js";
17
+ import { resolveWorkspaceBaseBranch } from "../shared/GitBranch.js";
17
18
  import { buildDocdexUsageGuidance } from "../shared/DocdexGuidance.js";
18
19
  import { createTaskCommentSlug, formatTaskCommentBody } from "../tasks/TaskCommentFormatter.js";
19
20
  import { AUTH_ERROR_REASON, isAuthErrorMessage } from "../shared/AuthErrors.js";
20
21
  import { normalizeReviewOutput } from "./ReviewNormalizer.js";
21
- const DEFAULT_BASE_BRANCH = "mcoda-dev";
22
22
  const REVIEW_DIR = (mcodaDir, jobId) => path.join(mcodaDir, "jobs", jobId, "review");
23
23
  const STATE_PATH = (mcodaDir, jobId) => path.join(REVIEW_DIR(mcodaDir, jobId), "state.json");
24
24
  const REVIEW_PROMPT_LIMITS = {
@@ -1530,7 +1530,7 @@ export class CodeReviewService {
1530
1530
  async reviewTasks(request) {
1531
1531
  await this.ensureMcoda();
1532
1532
  const agentStream = request.agentStream !== false;
1533
- const baseRef = request.baseRef ?? this.workspace.config?.branch ?? DEFAULT_BASE_BRANCH;
1533
+ const baseRef = await resolveWorkspaceBaseBranch(this.workspace, request.baseRef);
1534
1534
  let executionContextPolicy = normalizeExecutionContextPolicy(request.executionContextPolicy);
1535
1535
  let emptyDiffApprovalPolicy = normalizeEmptyDiffApprovalPolicy(request.emptyDiffApprovalPolicy, "complete");
1536
1536
  const ignoreStatusFilter = Boolean(request.taskKeys?.length) || request.ignoreStatusFilter === true;
@@ -0,0 +1,6 @@
1
+ import type { WorkspaceResolution } from "../../workspace/WorkspaceManager.js";
2
+ type WorkspaceBranchContext = Pick<WorkspaceResolution, "workspaceRoot" | "config">;
3
+ export declare const readGitBranch: (workspaceRoot: string) => Promise<string | undefined>;
4
+ export declare const resolveWorkspaceBaseBranch: (workspace: WorkspaceBranchContext, requestedBranch?: string | null, fallbackBranch?: string) => Promise<string>;
5
+ export {};
6
+ //# sourceMappingURL=GitBranch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitBranch.d.ts","sourceRoot":"","sources":["../../../src/services/shared/GitBranch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAM/E,KAAK,sBAAsB,GAAG,IAAI,CAAC,mBAAmB,EAAE,eAAe,GAAG,QAAQ,CAAC,CAAC;AA6BpF,eAAO,MAAM,aAAa,GAAU,eAAe,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAmBrF,CAAC;AAEF,eAAO,MAAM,0BAA0B,GACrC,WAAW,sBAAsB,EACjC,kBAAkB,MAAM,GAAG,IAAI,EAC/B,uBAAwC,KACvC,OAAO,CAAC,MAAM,CAShB,CAAC"}
@@ -0,0 +1,62 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ const GITDIR_PREFIX = "gitdir:";
4
+ const DETACHED_HEAD_REGEX = /^[0-9a-f]{40}$/i;
5
+ const DEFAULT_FALLBACK_BRANCH = "main";
6
+ const trimToUndefined = (value) => {
7
+ const trimmed = value?.trim();
8
+ return trimmed ? trimmed : undefined;
9
+ };
10
+ const resolveGitDir = async (workspaceRoot) => {
11
+ const dotGitPath = path.join(workspaceRoot, ".git");
12
+ try {
13
+ const stat = await fs.lstat(dotGitPath);
14
+ if (stat.isDirectory())
15
+ return dotGitPath;
16
+ if (!stat.isFile())
17
+ return undefined;
18
+ }
19
+ catch {
20
+ return undefined;
21
+ }
22
+ try {
23
+ const content = (await fs.readFile(dotGitPath, "utf8")).trim();
24
+ if (!content.toLowerCase().startsWith(GITDIR_PREFIX)) {
25
+ return undefined;
26
+ }
27
+ const gitDir = trimToUndefined(content.slice(GITDIR_PREFIX.length));
28
+ return gitDir ? path.resolve(workspaceRoot, gitDir) : undefined;
29
+ }
30
+ catch {
31
+ return undefined;
32
+ }
33
+ };
34
+ export const readGitBranch = async (workspaceRoot) => {
35
+ const gitDir = await resolveGitDir(workspaceRoot);
36
+ if (!gitDir) {
37
+ return undefined;
38
+ }
39
+ try {
40
+ const content = (await fs.readFile(path.join(gitDir, "HEAD"), "utf8")).trim();
41
+ const match = content.match(/^ref:\s+refs\/heads\/(.+)$/);
42
+ if (match) {
43
+ return trimToUndefined(match[1]);
44
+ }
45
+ if (!content || content === "HEAD" || DETACHED_HEAD_REGEX.test(content)) {
46
+ return undefined;
47
+ }
48
+ return undefined;
49
+ }
50
+ catch {
51
+ return undefined;
52
+ }
53
+ };
54
+ export const resolveWorkspaceBaseBranch = async (workspace, requestedBranch, fallbackBranch = DEFAULT_FALLBACK_BRANCH) => {
55
+ const configuredBranch = trimToUndefined(workspace.config?.branch);
56
+ const effectiveFallback = configuredBranch ?? (await readGitBranch(workspace.workspaceRoot)) ?? fallbackBranch;
57
+ const explicitBranch = trimToUndefined(requestedBranch);
58
+ if (explicitBranch === "dev") {
59
+ return effectiveFallback;
60
+ }
61
+ return explicitBranch ?? effectiveFallback;
62
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcoda/core",
3
- "version": "0.1.37",
3
+ "version": "0.1.40",
4
4
  "description": "Core services and APIs for the mcoda CLI.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -32,11 +32,11 @@
32
32
  "dependencies": {
33
33
  "@apidevtools/swagger-parser": "^10.1.0",
34
34
  "yaml": "^2.4.2",
35
- "@mcoda/db": "0.1.37",
36
- "@mcoda/shared": "0.1.37",
37
- "@mcoda/generators": "0.1.37",
38
- "@mcoda/agents": "0.1.37",
39
- "@mcoda/integrations": "0.1.37"
35
+ "@mcoda/shared": "0.1.40",
36
+ "@mcoda/db": "0.1.40",
37
+ "@mcoda/agents": "0.1.40",
38
+ "@mcoda/integrations": "0.1.40",
39
+ "@mcoda/generators": "0.1.40"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "tsc -p tsconfig.json",