@projitive/mcp 1.0.6 → 1.0.8

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Language: English | [简体中文](README_CN.md)
4
4
 
5
- **Current Spec Version: projitive-spec v1.0.0 | MCP Version: 1.0.6**
5
+ **Current Spec Version: projitive-spec v1.0.0 | MCP Version: 1.0.8**
6
6
 
7
7
  Projitive MCP server (semantic interface edition) helps agents discover projects, select tasks, locate evidence, and execute under governance workflows.
8
8
 
@@ -177,7 +177,7 @@ npm run test
177
177
  #### `projectNext`
178
178
 
179
179
  - **Purpose**: directly list recently actionable projects (ranked by actionable task count and recency).
180
- - **Input**: `maxDepth?`, `limit?`
180
+ - **Input**: `limit?`
181
181
  - **Output Example (Markdown)**:
182
182
 
183
183
  ```markdown
@@ -294,7 +294,7 @@ npm run test
294
294
  #### `taskNext`
295
295
 
296
296
  - **Purpose**: one-step workflow for project discovery + best task selection + evidence/read-order output.
297
- - **Input**: `maxDepth?`, `topCandidates?`
297
+ - **Input**: `limit?`
298
298
  - **Output Example (Markdown)**:
299
299
 
300
300
  ```markdown
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projitive/mcp",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Projitive MCP Server for project and task discovery/update",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -133,6 +133,41 @@ function parentDir(dirPath) {
133
133
  const parent = path.dirname(dirPath);
134
134
  return parent === dirPath ? null : parent;
135
135
  }
136
+ export function toProjectPath(governanceDir) {
137
+ return path.dirname(governanceDir);
138
+ }
139
+ async function listChildGovernanceDirs(parentPath) {
140
+ const entriesResult = await catchIt(fs.readdir(parentPath, { withFileTypes: true }));
141
+ if (entriesResult.isError()) {
142
+ return [];
143
+ }
144
+ const folders = entriesResult.value
145
+ .filter((entry) => entry.isDirectory())
146
+ .map((entry) => path.join(parentPath, entry.name));
147
+ const markerChecks = await Promise.all(folders.map(async (folderPath) => ({
148
+ folderPath,
149
+ hasMarker: await hasProjectMarker(folderPath),
150
+ })));
151
+ const candidates = markerChecks
152
+ .filter((item) => item.hasMarker)
153
+ .map((item) => item.folderPath)
154
+ .sort((a, b) => a.localeCompare(b));
155
+ return candidates;
156
+ }
157
+ async function resolveChildGovernanceDir(parentPath) {
158
+ const candidates = await listChildGovernanceDirs(parentPath);
159
+ if (candidates.length === 0) {
160
+ return undefined;
161
+ }
162
+ const defaultCandidate = path.join(parentPath, DEFAULT_GOVERNANCE_DIR);
163
+ if (candidates.includes(defaultCandidate)) {
164
+ return defaultCandidate;
165
+ }
166
+ if (candidates.length === 1) {
167
+ return candidates[0];
168
+ }
169
+ throw new Error(`Multiple governance roots found under path: ${parentPath}. Use projectPath/governanceDir explicitly.`);
170
+ }
136
171
  export async function resolveGovernanceDir(inputPath) {
137
172
  const absolutePath = path.resolve(inputPath);
138
173
  const statResult = await catchIt(fs.stat(absolutePath));
@@ -145,6 +180,10 @@ export async function resolveGovernanceDir(inputPath) {
145
180
  if (await hasProjectMarker(cursor)) {
146
181
  return cursor;
147
182
  }
183
+ const childGovernanceDir = await resolveChildGovernanceDir(cursor);
184
+ if (childGovernanceDir) {
185
+ return childGovernanceDir;
186
+ }
148
187
  cursor = parentDir(cursor);
149
188
  }
150
189
  throw new Error(`No ${PROJECT_MARKER} marker found from path: ${absolutePath}`);
@@ -158,6 +197,8 @@ export async function discoverProjects(rootPath, maxDepth) {
158
197
  if (await hasProjectMarker(currentPath)) {
159
198
  results.push(currentPath);
160
199
  }
200
+ const childGovernanceDirs = await listChildGovernanceDirs(currentPath);
201
+ results.push(...childGovernanceDirs);
161
202
  const entriesResult = await catchIt(fs.readdir(currentPath, { withFileTypes: true }));
162
203
  if (entriesResult.isError()) {
163
204
  return;
@@ -274,7 +315,7 @@ export async function initializeProjectStructure(inputPath, governanceDir, force
274
315
  export function registerProjectTools(server) {
275
316
  server.registerTool("projectInit", {
276
317
  title: "Project Init",
277
- description: "Bootstrap governance files when a project has no .projitive yet",
318
+ description: "Bootstrap governance files when a project has no .projitive yet (requires projectPath)",
278
319
  inputSchema: {
279
320
  projectPath: z.string(),
280
321
  governanceDir: z.string().optional(),
@@ -313,7 +354,7 @@ export function registerProjectTools(server) {
313
354
  "- After init, fill owner/roadmapRefs/links in tasks.md before marking DONE.",
314
355
  "- Keep task source-of-truth inside marker block only.",
315
356
  ]),
316
- nextCallSection(`projectContext(projectPath=\"${initialized.governanceDir}\")`),
357
+ nextCallSection(`projectContext(projectPath=\"${initialized.projectPath}\")`),
317
358
  ],
318
359
  });
319
360
  return asText(markdown);
@@ -356,12 +397,11 @@ export function registerProjectTools(server) {
356
397
  title: "Project Next",
357
398
  description: "Rank actionable projects and return the best execution target",
358
399
  inputSchema: {
359
- maxDepth: z.number().int().min(0).max(8).optional(),
360
400
  limit: z.number().int().min(1).max(50).optional(),
361
401
  },
362
- }, async ({ maxDepth, limit }) => {
402
+ }, async ({ limit }) => {
363
403
  const root = resolveScanRoot();
364
- const depth = resolveScanDepth(maxDepth);
404
+ const depth = resolveScanDepth();
365
405
  const projects = await discoverProjects(root, depth);
366
406
  const snapshots = await Promise.all(projects.map(async (governanceDir) => {
367
407
  const snapshot = await readTasksSnapshot(governanceDir);
@@ -408,13 +448,13 @@ export function registerProjectTools(server) {
408
448
  ...ranked.map((item, index) => `${index + 1}. ${item.governanceDir} | actionable=${item.actionable} | in_progress=${item.inProgress} | todo=${item.todo} | blocked=${item.blocked} | done=${item.done} | latest=${item.latestUpdatedAt} | tasksPath=${item.tasksPath}${item.tasksExists ? "" : " (missing)"}`),
409
449
  ]),
410
450
  guidanceSection([
411
- "- Pick top 1 project and call `projectContext` with its governanceDir.",
451
+ "- Pick top 1 project and call `projectContext` with its projectPath.",
412
452
  "- Then call `taskList` and `taskContext` to continue execution.",
413
453
  "- If `tasksPath` is missing, create tasks.md using project convention before task-level operations.",
414
454
  ]),
415
455
  lintSection(ranked[0]?.lintSuggestions ?? []),
416
456
  nextCallSection(ranked[0]
417
- ? `projectContext(projectPath=\"${ranked[0].governanceDir}\")`
457
+ ? `projectContext(projectPath=\"${toProjectPath(ranked[0].governanceDir)}\")`
418
458
  : undefined),
419
459
  ],
420
460
  });
@@ -429,18 +469,20 @@ export function registerProjectTools(server) {
429
469
  }, async ({ inputPath }) => {
430
470
  const resolvedFrom = normalizePath(inputPath);
431
471
  const governanceDir = await resolveGovernanceDir(resolvedFrom);
472
+ const projectPath = toProjectPath(governanceDir);
432
473
  const markerPath = path.join(governanceDir, ".projitive");
433
474
  const markdown = renderToolResponseMarkdown({
434
475
  toolName: "projectLocate",
435
476
  sections: [
436
477
  summarySection([
437
478
  `- resolvedFrom: ${resolvedFrom}`,
479
+ `- projectPath: ${projectPath}`,
438
480
  `- governanceDir: ${governanceDir}`,
439
481
  `- markerPath: ${markerPath}`,
440
482
  ]),
441
- guidanceSection(["- Call `projectContext` with this governanceDir to get task and roadmap summaries."]),
483
+ guidanceSection(["- Call `projectContext` with this projectPath to get task and roadmap summaries."]),
442
484
  lintSection(["- Run `projectContext` to get governance/module lint suggestions for this project."]),
443
- nextCallSection(`projectContext(projectPath=\"${governanceDir}\")`),
485
+ nextCallSection(`projectContext(projectPath=\"${projectPath}\")`),
444
486
  ],
445
487
  });
446
488
  return asText(markdown);
@@ -453,6 +495,7 @@ export function registerProjectTools(server) {
453
495
  },
454
496
  }, async ({ projectPath }) => {
455
497
  const governanceDir = await resolveGovernanceDir(projectPath);
498
+ const normalizedProjectPath = toProjectPath(governanceDir);
456
499
  const artifacts = await discoverGovernanceArtifacts(governanceDir);
457
500
  const { tasksPath, tasks, markdown: tasksMarkdown } = await loadTasksDocument(governanceDir);
458
501
  const roadmapIds = await readRoadmapIds(governanceDir);
@@ -468,6 +511,7 @@ export function registerProjectTools(server) {
468
511
  toolName: "projectContext",
469
512
  sections: [
470
513
  summarySection([
514
+ `- projectPath: ${normalizedProjectPath}`,
471
515
  `- governanceDir: ${governanceDir}`,
472
516
  `- tasksFile: ${tasksPath}`,
473
517
  `- roadmapIds: ${roadmapIds.length}`,
@@ -488,7 +532,7 @@ export function registerProjectTools(server) {
488
532
  "- Then call `taskContext` with a task ID to retrieve evidence locations and reading order.",
489
533
  ]),
490
534
  lintSection(lintSuggestions),
491
- nextCallSection(`taskList(projectPath=\"${governanceDir}\")`),
535
+ nextCallSection(`taskList(projectPath=\"${normalizedProjectPath}\")`),
492
536
  ],
493
537
  });
494
538
  return asText(markdown);
@@ -31,6 +31,24 @@ describe("projitive module", () => {
31
31
  const resolved = await resolveGovernanceDir(deepDir);
32
32
  expect(resolved).toBe(governanceDir);
33
33
  });
34
+ it("resolves nested default governance dir when input path is project root", async () => {
35
+ const root = await createTempDir();
36
+ const projectRoot = path.join(root, "repo");
37
+ const governanceDir = path.join(projectRoot, ".projitive");
38
+ await fs.mkdir(governanceDir, { recursive: true });
39
+ await fs.writeFile(path.join(governanceDir, ".projitive"), "", "utf-8");
40
+ const resolved = await resolveGovernanceDir(projectRoot);
41
+ expect(resolved).toBe(governanceDir);
42
+ });
43
+ it("resolves nested custom governance dir when input path is project root", async () => {
44
+ const root = await createTempDir();
45
+ const projectRoot = path.join(root, "repo");
46
+ const governanceDir = path.join(projectRoot, "governance");
47
+ await fs.mkdir(governanceDir, { recursive: true });
48
+ await fs.writeFile(path.join(governanceDir, ".projitive"), "", "utf-8");
49
+ const resolved = await resolveGovernanceDir(projectRoot);
50
+ expect(resolved).toBe(governanceDir);
51
+ });
34
52
  it("discovers projects by marker file", async () => {
35
53
  const root = await createTempDir();
36
54
  const p1 = path.join(root, "a");
@@ -43,6 +61,24 @@ describe("projitive module", () => {
43
61
  expect(projects).toContain(p1);
44
62
  expect(projects).toContain(p2);
45
63
  });
64
+ it("discovers nested default governance directory under project root", async () => {
65
+ const root = await createTempDir();
66
+ const projectRoot = path.join(root, "app");
67
+ const governanceDir = path.join(projectRoot, ".projitive");
68
+ await fs.mkdir(governanceDir, { recursive: true });
69
+ await fs.writeFile(path.join(governanceDir, ".projitive"), "", "utf-8");
70
+ const projects = await discoverProjects(root, 3);
71
+ expect(projects).toContain(governanceDir);
72
+ });
73
+ it("discovers nested custom governance directory under project root", async () => {
74
+ const root = await createTempDir();
75
+ const projectRoot = path.join(root, "app");
76
+ const governanceDir = path.join(projectRoot, "governance");
77
+ await fs.mkdir(governanceDir, { recursive: true });
78
+ await fs.writeFile(path.join(governanceDir, ".projitive"), "", "utf-8");
79
+ const projects = await discoverProjects(root, 3);
80
+ expect(projects).toContain(governanceDir);
81
+ });
46
82
  it("initializes governance structure under default .projitive directory", async () => {
47
83
  const root = await createTempDir();
48
84
  const initialized = await initializeProjectStructure(root);
@@ -6,7 +6,7 @@ import { discoverGovernanceArtifacts } from "./helpers/files/index.js";
6
6
  import { ROADMAP_LINT_CODES, renderLintSuggestions } from "./helpers/linter/index.js";
7
7
  import { findTextReferences } from "./helpers/markdown/index.js";
8
8
  import { asText, evidenceSection, guidanceSection, lintSection, nextCallSection, renderErrorMarkdown, renderToolResponseMarkdown, summarySection, } from "./helpers/response/index.js";
9
- import { resolveGovernanceDir } from "./projitive.js";
9
+ import { resolveGovernanceDir, toProjectPath } from "./projitive.js";
10
10
  import { loadTasks } from "./tasks.js";
11
11
  export const ROADMAP_ID_REGEX = /^ROADMAP-\d{4}$/;
12
12
  function collectRoadmapLintSuggestionItems(roadmapIds, tasks) {
@@ -99,7 +99,7 @@ export function registerRoadmapTools(server) {
99
99
  guidanceSection(["- Pick one roadmap ID and call `roadmapContext`."]),
100
100
  lintSection(lintSuggestions),
101
101
  nextCallSection(roadmapIds[0]
102
- ? `roadmapContext(projectPath=\"${governanceDir}\", roadmapId=\"${roadmapIds[0]}\")`
102
+ ? `roadmapContext(projectPath=\"${toProjectPath(governanceDir)}\", roadmapId=\"${roadmapIds[0]}\")`
103
103
  : undefined),
104
104
  ],
105
105
  });
@@ -157,7 +157,7 @@ export function registerRoadmapTools(server) {
157
157
  "- Re-run `roadmapContext` after edits to confirm references remain consistent.",
158
158
  ]),
159
159
  lintSection(lintSuggestions),
160
- nextCallSection(`roadmapContext(projectPath=\"${governanceDir}\", roadmapId=\"${roadmapId}\")`),
160
+ nextCallSection(`roadmapContext(projectPath=\"${toProjectPath(governanceDir)}\", roadmapId=\"${roadmapId}\")`),
161
161
  ],
162
162
  });
163
163
  return asText(markdown);
@@ -7,7 +7,7 @@ import { findTextReferences } from "./helpers/markdown/index.js";
7
7
  import { asText, evidenceSection, guidanceSection, lintSection, nextCallSection, renderErrorMarkdown, renderToolResponseMarkdown, summarySection, } from "./helpers/response/index.js";
8
8
  import { catchIt } from "./helpers/catch/index.js";
9
9
  import { TASK_LINT_CODES, renderLintSuggestions } from "./helpers/linter/index.js";
10
- import { resolveGovernanceDir, resolveScanDepth, resolveScanRoot, discoverProjects } from "./projitive.js";
10
+ import { resolveGovernanceDir, resolveScanDepth, resolveScanRoot, discoverProjects, toProjectPath } from "./projitive.js";
11
11
  import { isValidRoadmapId } from "./roadmap.js";
12
12
  export const TASKS_START = "<!-- PROJITIVE:TASKS:START -->";
13
13
  export const TASKS_END = "<!-- PROJITIVE:TASKS:END -->";
@@ -535,7 +535,7 @@ export function registerTaskTools(server) {
535
535
  guidanceSection(["- Pick one task ID and call `taskContext`."]),
536
536
  lintSection(lintSuggestions),
537
537
  nextCallSection(nextTaskId
538
- ? `taskContext(projectPath=\"${governanceDir}\", taskId=\"${nextTaskId}\")`
538
+ ? `taskContext(projectPath=\"${toProjectPath(governanceDir)}\", taskId=\"${nextTaskId}\")`
539
539
  : undefined),
540
540
  ],
541
541
  });
@@ -545,12 +545,11 @@ export function registerTaskTools(server) {
545
545
  title: "Task Next",
546
546
  description: "Start here to auto-select the highest-priority actionable task",
547
547
  inputSchema: {
548
- maxDepth: z.number().int().min(0).max(8).optional(),
549
- topCandidates: z.number().int().min(1).max(20).optional(),
548
+ limit: z.number().int().min(1).max(20).optional(),
550
549
  },
551
- }, async ({ maxDepth, topCandidates }) => {
550
+ }, async ({ limit }) => {
552
551
  const root = resolveScanRoot();
553
- const depth = resolveScanDepth(maxDepth);
552
+ const depth = resolveScanDepth();
554
553
  const projects = await discoverProjects(root, depth);
555
554
  const rankedCandidates = rankActionableTaskCandidates(await readActionableTaskCandidates(projects));
556
555
  if (rankedCandidates.length === 0) {
@@ -609,7 +608,7 @@ export function registerTaskTools(server) {
609
608
  "- Ensure each new task has stable TASK-xxxx ID and at least one roadmapRefs item.",
610
609
  ]),
611
610
  nextCallSection(preferredProject
612
- ? `projectContext(projectPath=\"${preferredProject.governanceDir}\")`
611
+ ? `projectContext(projectPath=\"${toProjectPath(preferredProject.governanceDir)}\")`
613
612
  : "projectScan()"),
614
613
  ],
615
614
  });
@@ -624,7 +623,7 @@ export function registerTaskTools(server) {
624
623
  const taskLocation = (await findTextReferences(selected.tasksPath, selected.task.id))[0];
625
624
  const relatedArtifacts = Array.from(new Set(referenceLocations.map((item) => item.filePath)));
626
625
  const suggestedReadOrder = [selected.tasksPath, ...relatedArtifacts.filter((item) => item !== selected.tasksPath)];
627
- const candidateLimit = topCandidates ?? 5;
626
+ const candidateLimit = limit ?? 5;
628
627
  const markdown = renderToolResponseMarkdown({
629
628
  toolName: "taskNext",
630
629
  sections: [
@@ -672,7 +671,7 @@ export function registerTaskTools(server) {
672
671
  "- Re-run `taskContext` for the selectedTaskId after edits to verify evidence consistency.",
673
672
  ]),
674
673
  lintSection(lintSuggestions),
675
- nextCallSection(`taskContext(projectPath=\"${selected.governanceDir}\", taskId=\"${selected.task.id}\")`),
674
+ nextCallSection(`taskContext(projectPath=\"${toProjectPath(selected.governanceDir)}\", taskId=\"${selected.task.id}\")`),
676
675
  ],
677
676
  });
678
677
  return asText(markdown);
@@ -696,7 +695,7 @@ export function registerTaskTools(server) {
696
695
  const task = tasks.find((item) => item.id === taskId);
697
696
  if (!task) {
698
697
  return {
699
- ...asText(renderErrorMarkdown("taskContext", `Task not found: ${taskId}`, ["run `taskList` to discover available IDs", "retry with an existing task ID"], `taskList(projectPath=\"${governanceDir}\")`)),
698
+ ...asText(renderErrorMarkdown("taskContext", `Task not found: ${taskId}`, ["run `taskList` to discover available IDs", "retry with an existing task ID"], `taskList(projectPath=\"${toProjectPath(governanceDir)}\")`)),
700
699
  isError: true,
701
700
  };
702
701
  }
@@ -753,7 +752,7 @@ export function registerTaskTools(server) {
753
752
  "- After editing, re-run `taskContext` to verify references and context consistency.",
754
753
  ]),
755
754
  lintSection(lintSuggestions),
756
- nextCallSection(`taskContext(projectPath=\"${governanceDir}\", taskId=\"${task.id}\")`),
755
+ nextCallSection(`taskContext(projectPath=\"${toProjectPath(governanceDir)}\", taskId=\"${task.id}\")`),
757
756
  ],
758
757
  });
759
758
  return asText(coreMarkdown);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projitive/mcp",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Projitive MCP Server for project and task discovery/update",
5
5
  "license": "ISC",
6
6
  "author": "",