mrvn-cli 0.2.9 → 0.2.10

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/dist/index.js CHANGED
@@ -213,6 +213,11 @@ var DocumentStore = class {
213
213
  const raw = fs3.readFileSync(filePath, "utf-8");
214
214
  const doc = parseDocument(raw, filePath);
215
215
  if (doc.frontmatter.id) {
216
+ if (this.index.has(doc.frontmatter.id)) {
217
+ console.warn(
218
+ `[marvin] Duplicate ID "${doc.frontmatter.id}" in ${file2} \u2014 conflicts with existing entry. Run ID repair to fix.`
219
+ );
220
+ }
216
221
  this.index.set(doc.frontmatter.id, doc.frontmatter);
217
222
  }
218
223
  }
@@ -333,14 +338,22 @@ var DocumentStore = class {
333
338
  if (!prefix) {
334
339
  throw new Error(`Unknown document type: ${type}`);
335
340
  }
336
- const pattern = new RegExp(`^${prefix}-(\\d+)$`);
341
+ const dirName = this.typeDirs[type];
342
+ const dir = path3.join(this.docsDir, dirName);
343
+ if (!fs3.existsSync(dir)) return `${prefix}-001`;
344
+ const idPattern = new RegExp(`^${prefix}-(\\d+)$`);
345
+ const files = fs3.readdirSync(dir).filter((f) => f.endsWith(".md"));
337
346
  let maxNum = 0;
338
- for (const id of this.index.keys()) {
339
- const match = id.match(pattern);
347
+ for (const file2 of files) {
348
+ const filePath = path3.join(dir, file2);
349
+ const raw = fs3.readFileSync(filePath, "utf-8");
350
+ const doc = parseDocument(raw, filePath);
351
+ const match = doc.frontmatter.id?.match(idPattern);
340
352
  if (match) {
341
353
  maxNum = Math.max(maxNum, parseInt(match[1], 10));
342
354
  }
343
355
  }
356
+ maxNum = Math.max(maxNum, files.length);
344
357
  return `${prefix}-${String(maxNum + 1).padStart(3, "0")}`;
345
358
  }
346
359
  counts() {
@@ -21403,7 +21416,7 @@ function createProgram() {
21403
21416
  const program = new Command();
21404
21417
  program.name("marvin").description(
21405
21418
  "AI-powered product development assistant with Product Owner, Delivery Manager, and Technical Lead personas"
21406
- ).version("0.2.9");
21419
+ ).version("0.2.10");
21407
21420
  program.command("init").description("Initialize a new Marvin project in the current directory").action(async () => {
21408
21421
  await initCommand();
21409
21422
  });