mrvn-cli 0.2.9 → 0.3.0

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() {
@@ -6599,13 +6612,13 @@ var error16 = () => {
6599
6612
  // no unit
6600
6613
  };
6601
6614
  const typeEntry = (t) => t ? TypeNames[t] : void 0;
6602
- const typeLabel = (t) => {
6615
+ const typeLabel2 = (t) => {
6603
6616
  const e = typeEntry(t);
6604
6617
  if (e)
6605
6618
  return e.label;
6606
6619
  return t ?? TypeNames.unknown.label;
6607
6620
  };
6608
- const withDefinite = (t) => `\u05D4${typeLabel(t)}`;
6621
+ const withDefinite = (t) => `\u05D4${typeLabel2(t)}`;
6609
6622
  const verbFor = (t) => {
6610
6623
  const e = typeEntry(t);
6611
6624
  const gender = e?.gender ?? "m";
@@ -6655,7 +6668,7 @@ var error16 = () => {
6655
6668
  switch (issue2.code) {
6656
6669
  case "invalid_type": {
6657
6670
  const expectedKey = issue2.expected;
6658
- const expected = TypeDictionary[expectedKey ?? ""] ?? typeLabel(expectedKey);
6671
+ const expected = TypeDictionary[expectedKey ?? ""] ?? typeLabel2(expectedKey);
6659
6672
  const receivedType = parsedType(issue2.input);
6660
6673
  const received = TypeDictionary[receivedType] ?? TypeNames[receivedType]?.label ?? receivedType;
6661
6674
  if (/^[A-Z]/.test(issue2.expected)) {
@@ -20364,8 +20377,8 @@ function executeImportPlan(plan, store, marvinDir, options) {
20364
20377
  }
20365
20378
  function formatPlanSummary(plan) {
20366
20379
  const lines = [];
20367
- const typeLabel = classificationLabel(plan.classification.type);
20368
- lines.push(`Detected: ${typeLabel}`);
20380
+ const typeLabel2 = classificationLabel(plan.classification.type);
20381
+ lines.push(`Detected: ${typeLabel2}`);
20369
20382
  lines.push(`Source: ${plan.classification.inputPath}`);
20370
20383
  lines.push("");
20371
20384
  const imports = plan.items.filter((i) => i.action === "import");
@@ -21398,12 +21411,1048 @@ async function garReportCommand(options) {
21398
21411
  }
21399
21412
  }
21400
21413
 
21414
+ // src/web/server.ts
21415
+ import * as http from "http";
21416
+ import { exec } from "child_process";
21417
+
21418
+ // src/web/data.ts
21419
+ function getOverviewData(store) {
21420
+ const types = [];
21421
+ const counts = store.counts();
21422
+ for (const type of store.registeredTypes) {
21423
+ const total = counts[type] ?? 0;
21424
+ const open = store.list({ type, status: "open" }).length;
21425
+ types.push({ type, total, open });
21426
+ }
21427
+ const allDocs = store.list();
21428
+ const sorted = allDocs.sort(
21429
+ (a, b) => (b.frontmatter.updated ?? b.frontmatter.created).localeCompare(
21430
+ a.frontmatter.updated ?? a.frontmatter.created
21431
+ )
21432
+ );
21433
+ return { types, recent: sorted.slice(0, 20) };
21434
+ }
21435
+ function getDocumentListData(store, type, filterStatus, filterOwner) {
21436
+ if (!store.registeredTypes.includes(type)) return void 0;
21437
+ const allOfType = store.list({ type });
21438
+ const statuses = [...new Set(allOfType.map((d) => d.frontmatter.status))].sort();
21439
+ const owners = [
21440
+ ...new Set(allOfType.map((d) => d.frontmatter.owner).filter(Boolean))
21441
+ ].sort();
21442
+ let docs = allOfType;
21443
+ if (filterStatus) {
21444
+ docs = docs.filter((d) => d.frontmatter.status === filterStatus);
21445
+ }
21446
+ if (filterOwner) {
21447
+ docs = docs.filter((d) => d.frontmatter.owner === filterOwner);
21448
+ }
21449
+ docs.sort((a, b) => a.frontmatter.id.localeCompare(b.frontmatter.id));
21450
+ return { type, docs, statuses, owners, filterStatus, filterOwner };
21451
+ }
21452
+ function getDocumentDetail(store, type, id) {
21453
+ if (!store.registeredTypes.includes(type)) return void 0;
21454
+ return store.get(id);
21455
+ }
21456
+ function getGarData(store, projectName) {
21457
+ const metrics = collectGarMetrics(store);
21458
+ return evaluateGar(projectName, metrics);
21459
+ }
21460
+ function getBoardData(store, type) {
21461
+ const docs = type ? store.list({ type }) : store.list();
21462
+ const types = store.registeredTypes;
21463
+ const byStatus = /* @__PURE__ */ new Map();
21464
+ for (const doc of docs) {
21465
+ const status = doc.frontmatter.status;
21466
+ if (!byStatus.has(status)) byStatus.set(status, []);
21467
+ byStatus.get(status).push(doc);
21468
+ }
21469
+ const statusOrder = ["open", "draft", "in-progress", "blocked"];
21470
+ const allStatuses = [...byStatus.keys()];
21471
+ const ordered = [];
21472
+ for (const s of statusOrder) {
21473
+ if (allStatuses.includes(s)) ordered.push(s);
21474
+ }
21475
+ for (const s of allStatuses.sort()) {
21476
+ if (!ordered.includes(s) && s !== "done" && s !== "closed" && s !== "resolved") {
21477
+ ordered.push(s);
21478
+ }
21479
+ }
21480
+ for (const s of ["done", "closed", "resolved"]) {
21481
+ if (allStatuses.includes(s)) ordered.push(s);
21482
+ }
21483
+ const columns = ordered.map((status) => ({
21484
+ status,
21485
+ docs: byStatus.get(status) ?? []
21486
+ }));
21487
+ return { columns, type, types };
21488
+ }
21489
+
21490
+ // src/web/templates/layout.ts
21491
+ function escapeHtml(str) {
21492
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
21493
+ }
21494
+ function statusBadge(status) {
21495
+ const cls = {
21496
+ open: "badge-open",
21497
+ done: "badge-done",
21498
+ closed: "badge-done",
21499
+ resolved: "badge-resolved",
21500
+ "in-progress": "badge-in-progress",
21501
+ "in progress": "badge-in-progress",
21502
+ draft: "badge-draft",
21503
+ blocked: "badge-blocked"
21504
+ }[status.toLowerCase()] ?? "badge-default";
21505
+ return `<span class="badge ${cls}">${escapeHtml(status)}</span>`;
21506
+ }
21507
+ function formatDate(iso) {
21508
+ if (!iso) return "";
21509
+ return iso.slice(0, 10);
21510
+ }
21511
+ function typeLabel(type) {
21512
+ return type.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
21513
+ }
21514
+ function renderMarkdown(md) {
21515
+ const lines = md.split("\n");
21516
+ const out = [];
21517
+ let inList = false;
21518
+ let listTag = "ul";
21519
+ for (const raw of lines) {
21520
+ const line = raw;
21521
+ if (inList && !/^\s*[-*]\s/.test(line) && !/^\s*\d+\.\s/.test(line) && line.trim() !== "") {
21522
+ out.push(`</${listTag}>`);
21523
+ inList = false;
21524
+ }
21525
+ const headingMatch = line.match(/^(#{1,3})\s+(.+)$/);
21526
+ if (headingMatch) {
21527
+ const level = headingMatch[1].length;
21528
+ out.push(`<h${level}>${inline(headingMatch[2])}</h${level}>`);
21529
+ continue;
21530
+ }
21531
+ const ulMatch = line.match(/^\s*[-*]\s+(.+)$/);
21532
+ if (ulMatch) {
21533
+ if (!inList || listTag !== "ul") {
21534
+ if (inList) out.push(`</${listTag}>`);
21535
+ out.push("<ul>");
21536
+ inList = true;
21537
+ listTag = "ul";
21538
+ }
21539
+ out.push(`<li>${inline(ulMatch[1])}</li>`);
21540
+ continue;
21541
+ }
21542
+ const olMatch = line.match(/^\s*\d+\.\s+(.+)$/);
21543
+ if (olMatch) {
21544
+ if (!inList || listTag !== "ol") {
21545
+ if (inList) out.push(`</${listTag}>`);
21546
+ out.push("<ol>");
21547
+ inList = true;
21548
+ listTag = "ol";
21549
+ }
21550
+ out.push(`<li>${inline(olMatch[1])}</li>`);
21551
+ continue;
21552
+ }
21553
+ if (line.trim() === "") {
21554
+ if (inList) {
21555
+ out.push(`</${listTag}>`);
21556
+ inList = false;
21557
+ }
21558
+ continue;
21559
+ }
21560
+ out.push(`<p>${inline(line)}</p>`);
21561
+ }
21562
+ if (inList) out.push(`</${listTag}>`);
21563
+ return out.join("\n");
21564
+ }
21565
+ function inline(text) {
21566
+ let s = escapeHtml(text);
21567
+ s = s.replace(/`([^`]+)`/g, "<code>$1</code>");
21568
+ s = s.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>");
21569
+ s = s.replace(/__([^_]+)__/g, "<strong>$1</strong>");
21570
+ s = s.replace(/\*([^*]+)\*/g, "<em>$1</em>");
21571
+ s = s.replace(/_([^_]+)_/g, "<em>$1</em>");
21572
+ return s;
21573
+ }
21574
+ function layout(opts, body) {
21575
+ const navItems = [
21576
+ { href: "/", label: "Overview" },
21577
+ { href: "/board", label: "Board" },
21578
+ { href: "/gar", label: "GAR Report" }
21579
+ ];
21580
+ const typeNavItems = opts.navTypes.map((type) => ({
21581
+ href: `/docs/${type}`,
21582
+ label: typeLabel(type) + "s"
21583
+ }));
21584
+ const isActive = (href) => opts.activePath === href || href !== "/" && opts.activePath.startsWith(href) ? " active" : "";
21585
+ return `<!DOCTYPE html>
21586
+ <html lang="en">
21587
+ <head>
21588
+ <meta charset="UTF-8">
21589
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
21590
+ <title>${escapeHtml(opts.title)} \u2014 Marvin</title>
21591
+ <link rel="stylesheet" href="/styles.css">
21592
+ </head>
21593
+ <body>
21594
+ <div class="shell">
21595
+ <aside class="sidebar">
21596
+ <div class="sidebar-brand">
21597
+ <h1>Marvin</h1>
21598
+ <div class="project-name">${escapeHtml(opts.projectName)}</div>
21599
+ </div>
21600
+ <nav>
21601
+ ${navItems.map((n) => `<a href="${n.href}" class="${isActive(n.href)}">${n.label}</a>`).join("\n ")}
21602
+ ${typeNavItems.map((n) => `<a href="${n.href}" class="${isActive(n.href)}">${n.label}</a>`).join("\n ")}
21603
+ </nav>
21604
+ </aside>
21605
+ <main class="main">
21606
+ ${body}
21607
+ </main>
21608
+ </div>
21609
+ </body>
21610
+ </html>`;
21611
+ }
21612
+
21613
+ // src/web/templates/styles.ts
21614
+ function renderStyles() {
21615
+ return `
21616
+ :root {
21617
+ --bg: #0f1117;
21618
+ --bg-card: #1a1d27;
21619
+ --bg-hover: #222632;
21620
+ --border: #2a2e3a;
21621
+ --text: #e1e4ea;
21622
+ --text-dim: #8b8fa4;
21623
+ --accent: #6c8cff;
21624
+ --accent-dim: #4a6ad4;
21625
+ --green: #34d399;
21626
+ --amber: #fbbf24;
21627
+ --red: #f87171;
21628
+ --radius: 8px;
21629
+ --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
21630
+ --mono: "SF Mono", "Fira Code", monospace;
21631
+ }
21632
+
21633
+ * { margin: 0; padding: 0; box-sizing: border-box; }
21634
+
21635
+ body {
21636
+ font-family: var(--font);
21637
+ background: var(--bg);
21638
+ color: var(--text);
21639
+ line-height: 1.6;
21640
+ min-height: 100vh;
21641
+ }
21642
+
21643
+ a { color: var(--accent); text-decoration: none; }
21644
+ a:hover { text-decoration: underline; }
21645
+
21646
+ /* Layout */
21647
+ .shell {
21648
+ display: flex;
21649
+ min-height: 100vh;
21650
+ }
21651
+
21652
+ .sidebar {
21653
+ width: 220px;
21654
+ background: var(--bg-card);
21655
+ border-right: 1px solid var(--border);
21656
+ padding: 1.5rem 0;
21657
+ position: fixed;
21658
+ top: 0;
21659
+ left: 0;
21660
+ bottom: 0;
21661
+ overflow-y: auto;
21662
+ }
21663
+
21664
+ .sidebar-brand {
21665
+ padding: 0 1.25rem 1.25rem;
21666
+ border-bottom: 1px solid var(--border);
21667
+ margin-bottom: 1rem;
21668
+ }
21669
+
21670
+ .sidebar-brand h1 {
21671
+ font-size: 1.1rem;
21672
+ font-weight: 700;
21673
+ color: var(--accent);
21674
+ letter-spacing: -0.02em;
21675
+ }
21676
+
21677
+ .sidebar-brand .project-name {
21678
+ font-size: 0.75rem;
21679
+ color: var(--text-dim);
21680
+ margin-top: 0.25rem;
21681
+ }
21682
+
21683
+ .sidebar nav a {
21684
+ display: block;
21685
+ padding: 0.5rem 1.25rem;
21686
+ color: var(--text-dim);
21687
+ font-size: 0.875rem;
21688
+ transition: background 0.15s, color 0.15s;
21689
+ }
21690
+
21691
+ .sidebar nav a:hover {
21692
+ background: var(--bg-hover);
21693
+ color: var(--text);
21694
+ text-decoration: none;
21695
+ }
21696
+
21697
+ .sidebar nav a.active {
21698
+ color: var(--accent);
21699
+ background: rgba(108, 140, 255, 0.08);
21700
+ border-right: 2px solid var(--accent);
21701
+ }
21702
+
21703
+ .main {
21704
+ margin-left: 220px;
21705
+ flex: 1;
21706
+ padding: 2rem 2.5rem;
21707
+ max-width: 1200px;
21708
+ }
21709
+
21710
+ /* Page header */
21711
+ .page-header {
21712
+ margin-bottom: 2rem;
21713
+ }
21714
+
21715
+ .page-header h2 {
21716
+ font-size: 1.5rem;
21717
+ font-weight: 600;
21718
+ }
21719
+
21720
+ .page-header .subtitle {
21721
+ color: var(--text-dim);
21722
+ font-size: 0.875rem;
21723
+ margin-top: 0.25rem;
21724
+ }
21725
+
21726
+ /* Breadcrumb */
21727
+ .breadcrumb {
21728
+ font-size: 0.8rem;
21729
+ color: var(--text-dim);
21730
+ margin-bottom: 1rem;
21731
+ }
21732
+
21733
+ .breadcrumb a { color: var(--text-dim); }
21734
+ .breadcrumb a:hover { color: var(--accent); }
21735
+ .breadcrumb .sep { margin: 0 0.4rem; }
21736
+
21737
+ /* Cards grid */
21738
+ .cards {
21739
+ display: grid;
21740
+ grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
21741
+ gap: 1rem;
21742
+ margin-bottom: 2rem;
21743
+ }
21744
+
21745
+ .card {
21746
+ background: var(--bg-card);
21747
+ border: 1px solid var(--border);
21748
+ border-radius: var(--radius);
21749
+ padding: 1.25rem;
21750
+ transition: border-color 0.15s;
21751
+ }
21752
+
21753
+ .card:hover {
21754
+ border-color: var(--accent-dim);
21755
+ }
21756
+
21757
+ .card a { color: inherit; text-decoration: none; display: block; }
21758
+
21759
+ .card .card-label {
21760
+ font-size: 0.75rem;
21761
+ text-transform: uppercase;
21762
+ letter-spacing: 0.05em;
21763
+ color: var(--text-dim);
21764
+ margin-bottom: 0.5rem;
21765
+ }
21766
+
21767
+ .card .card-value {
21768
+ font-size: 1.75rem;
21769
+ font-weight: 700;
21770
+ }
21771
+
21772
+ .card .card-sub {
21773
+ font-size: 0.8rem;
21774
+ color: var(--text-dim);
21775
+ margin-top: 0.25rem;
21776
+ }
21777
+
21778
+ /* Status badge */
21779
+ .badge {
21780
+ display: inline-block;
21781
+ padding: 0.15rem 0.6rem;
21782
+ border-radius: 999px;
21783
+ font-size: 0.7rem;
21784
+ font-weight: 600;
21785
+ text-transform: uppercase;
21786
+ letter-spacing: 0.03em;
21787
+ }
21788
+
21789
+ .badge-open { background: rgba(108, 140, 255, 0.15); color: var(--accent); }
21790
+ .badge-done { background: rgba(52, 211, 153, 0.15); color: var(--green); }
21791
+ .badge-in-progress { background: rgba(251, 191, 36, 0.15); color: var(--amber); }
21792
+ .badge-draft { background: rgba(139, 143, 164, 0.15); color: var(--text-dim); }
21793
+ .badge-closed, .badge-resolved { background: rgba(52, 211, 153, 0.15); color: var(--green); }
21794
+ .badge-blocked { background: rgba(248, 113, 113, 0.15); color: var(--red); }
21795
+ .badge-default { background: rgba(139, 143, 164, 0.1); color: var(--text-dim); }
21796
+
21797
+ /* Table */
21798
+ .table-wrap {
21799
+ overflow-x: auto;
21800
+ }
21801
+
21802
+ table {
21803
+ width: 100%;
21804
+ border-collapse: collapse;
21805
+ }
21806
+
21807
+ th {
21808
+ text-align: left;
21809
+ padding: 0.6rem 0.75rem;
21810
+ font-size: 0.7rem;
21811
+ text-transform: uppercase;
21812
+ letter-spacing: 0.05em;
21813
+ color: var(--text-dim);
21814
+ border-bottom: 1px solid var(--border);
21815
+ }
21816
+
21817
+ td {
21818
+ padding: 0.6rem 0.75rem;
21819
+ font-size: 0.875rem;
21820
+ border-bottom: 1px solid var(--border);
21821
+ }
21822
+
21823
+ tr:hover td {
21824
+ background: var(--bg-hover);
21825
+ }
21826
+
21827
+ /* GAR */
21828
+ .gar-overall {
21829
+ text-align: center;
21830
+ padding: 2rem;
21831
+ margin-bottom: 2rem;
21832
+ border-radius: var(--radius);
21833
+ border: 1px solid var(--border);
21834
+ background: var(--bg-card);
21835
+ }
21836
+
21837
+ .gar-overall .dot {
21838
+ width: 60px;
21839
+ height: 60px;
21840
+ border-radius: 50%;
21841
+ display: inline-block;
21842
+ margin-bottom: 0.75rem;
21843
+ }
21844
+
21845
+ .gar-overall .label {
21846
+ font-size: 1.1rem;
21847
+ font-weight: 600;
21848
+ text-transform: uppercase;
21849
+ }
21850
+
21851
+ .gar-areas {
21852
+ display: grid;
21853
+ grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
21854
+ gap: 1rem;
21855
+ }
21856
+
21857
+ .gar-area {
21858
+ background: var(--bg-card);
21859
+ border: 1px solid var(--border);
21860
+ border-radius: var(--radius);
21861
+ padding: 1.25rem;
21862
+ }
21863
+
21864
+ .gar-area .area-header {
21865
+ display: flex;
21866
+ align-items: center;
21867
+ gap: 0.6rem;
21868
+ margin-bottom: 0.75rem;
21869
+ }
21870
+
21871
+ .gar-area .area-dot {
21872
+ width: 14px;
21873
+ height: 14px;
21874
+ border-radius: 50%;
21875
+ flex-shrink: 0;
21876
+ }
21877
+
21878
+ .gar-area .area-name {
21879
+ font-weight: 600;
21880
+ font-size: 1rem;
21881
+ }
21882
+
21883
+ .gar-area .area-summary {
21884
+ font-size: 0.85rem;
21885
+ color: var(--text-dim);
21886
+ margin-bottom: 0.75rem;
21887
+ }
21888
+
21889
+ .gar-area ul {
21890
+ list-style: none;
21891
+ font-size: 0.8rem;
21892
+ }
21893
+
21894
+ .gar-area li {
21895
+ padding: 0.2rem 0;
21896
+ color: var(--text-dim);
21897
+ }
21898
+
21899
+ .gar-area li .ref-id {
21900
+ color: var(--accent);
21901
+ font-family: var(--mono);
21902
+ margin-right: 0.4rem;
21903
+ }
21904
+
21905
+ .dot-green { background: var(--green); }
21906
+ .dot-amber { background: var(--amber); }
21907
+ .dot-red { background: var(--red); }
21908
+
21909
+ /* Board / Kanban */
21910
+ .board {
21911
+ display: flex;
21912
+ gap: 1rem;
21913
+ overflow-x: auto;
21914
+ padding-bottom: 1rem;
21915
+ }
21916
+
21917
+ .board-column {
21918
+ min-width: 240px;
21919
+ max-width: 300px;
21920
+ flex: 1;
21921
+ }
21922
+
21923
+ .board-column-header {
21924
+ font-size: 0.75rem;
21925
+ text-transform: uppercase;
21926
+ letter-spacing: 0.05em;
21927
+ color: var(--text-dim);
21928
+ padding: 0.5rem 0.75rem;
21929
+ border-bottom: 2px solid var(--border);
21930
+ margin-bottom: 0.5rem;
21931
+ display: flex;
21932
+ justify-content: space-between;
21933
+ }
21934
+
21935
+ .board-column-header .count {
21936
+ background: var(--bg-hover);
21937
+ padding: 0 0.5rem;
21938
+ border-radius: 999px;
21939
+ font-size: 0.7rem;
21940
+ }
21941
+
21942
+ .board-card {
21943
+ background: var(--bg-card);
21944
+ border: 1px solid var(--border);
21945
+ border-radius: var(--radius);
21946
+ padding: 0.75rem;
21947
+ margin-bottom: 0.5rem;
21948
+ transition: border-color 0.15s;
21949
+ }
21950
+
21951
+ .board-card:hover {
21952
+ border-color: var(--accent-dim);
21953
+ }
21954
+
21955
+ .board-card .bc-id {
21956
+ font-family: var(--mono);
21957
+ font-size: 0.7rem;
21958
+ color: var(--accent);
21959
+ }
21960
+
21961
+ .board-card .bc-title {
21962
+ font-size: 0.85rem;
21963
+ margin: 0.25rem 0;
21964
+ }
21965
+
21966
+ .board-card .bc-owner {
21967
+ font-size: 0.7rem;
21968
+ color: var(--text-dim);
21969
+ }
21970
+
21971
+ /* Detail page */
21972
+ .detail-meta {
21973
+ background: var(--bg-card);
21974
+ border: 1px solid var(--border);
21975
+ border-radius: var(--radius);
21976
+ padding: 1.25rem;
21977
+ margin-bottom: 1.5rem;
21978
+ }
21979
+
21980
+ .detail-meta dl {
21981
+ display: grid;
21982
+ grid-template-columns: 120px 1fr;
21983
+ gap: 0.4rem 1rem;
21984
+ }
21985
+
21986
+ .detail-meta dt {
21987
+ font-size: 0.75rem;
21988
+ text-transform: uppercase;
21989
+ letter-spacing: 0.05em;
21990
+ color: var(--text-dim);
21991
+ }
21992
+
21993
+ .detail-meta dd {
21994
+ font-size: 0.875rem;
21995
+ }
21996
+
21997
+ .detail-content {
21998
+ background: var(--bg-card);
21999
+ border: 1px solid var(--border);
22000
+ border-radius: var(--radius);
22001
+ padding: 1.5rem;
22002
+ line-height: 1.7;
22003
+ }
22004
+
22005
+ .detail-content h1, .detail-content h2, .detail-content h3 {
22006
+ margin: 1.25rem 0 0.5rem;
22007
+ font-weight: 600;
22008
+ }
22009
+
22010
+ .detail-content h1 { font-size: 1.3rem; }
22011
+ .detail-content h2 { font-size: 1.15rem; }
22012
+ .detail-content h3 { font-size: 1rem; }
22013
+ .detail-content p { margin-bottom: 0.75rem; }
22014
+ .detail-content ul, .detail-content ol { margin: 0.5rem 0 0.75rem 1.5rem; }
22015
+ .detail-content li { margin-bottom: 0.25rem; }
22016
+ .detail-content code {
22017
+ background: var(--bg-hover);
22018
+ padding: 0.1rem 0.35rem;
22019
+ border-radius: 3px;
22020
+ font-family: var(--mono);
22021
+ font-size: 0.85em;
22022
+ }
22023
+
22024
+ /* Filters */
22025
+ .filters {
22026
+ display: flex;
22027
+ gap: 0.75rem;
22028
+ margin-bottom: 1.5rem;
22029
+ flex-wrap: wrap;
22030
+ }
22031
+
22032
+ .filters select {
22033
+ background: var(--bg-card);
22034
+ border: 1px solid var(--border);
22035
+ color: var(--text);
22036
+ padding: 0.4rem 0.75rem;
22037
+ border-radius: var(--radius);
22038
+ font-size: 0.8rem;
22039
+ cursor: pointer;
22040
+ }
22041
+
22042
+ .filters select:focus {
22043
+ outline: none;
22044
+ border-color: var(--accent);
22045
+ }
22046
+
22047
+ /* Empty state */
22048
+ .empty {
22049
+ text-align: center;
22050
+ padding: 3rem;
22051
+ color: var(--text-dim);
22052
+ }
22053
+
22054
+ .empty p { font-size: 0.9rem; }
22055
+
22056
+ /* Section heading */
22057
+ .section-title {
22058
+ font-size: 0.9rem;
22059
+ font-weight: 600;
22060
+ margin: 1.5rem 0 0.75rem;
22061
+ }
22062
+
22063
+ /* Priority */
22064
+ .priority-high { color: var(--red); }
22065
+ .priority-medium { color: var(--amber); }
22066
+ .priority-low { color: var(--green); }
22067
+ `;
22068
+ }
22069
+
22070
+ // src/web/templates/pages/overview.ts
22071
+ function overviewPage(data) {
22072
+ const cards = data.types.map(
22073
+ (t) => `
22074
+ <div class="card">
22075
+ <a href="/docs/${t.type}">
22076
+ <div class="card-label">${escapeHtml(typeLabel(t.type))}s</div>
22077
+ <div class="card-value">${t.total}</div>
22078
+ ${t.open > 0 ? `<div class="card-sub">${t.open} open</div>` : `<div class="card-sub">none open</div>`}
22079
+ </a>
22080
+ </div>`
22081
+ ).join("\n");
22082
+ const rows = data.recent.map(
22083
+ (doc) => `
22084
+ <tr>
22085
+ <td><a href="/docs/${doc.frontmatter.type}/${doc.frontmatter.id}">${escapeHtml(doc.frontmatter.id)}</a></td>
22086
+ <td>${escapeHtml(doc.frontmatter.title)}</td>
22087
+ <td>${escapeHtml(typeLabel(doc.frontmatter.type))}</td>
22088
+ <td>${statusBadge(doc.frontmatter.status)}</td>
22089
+ <td>${formatDate(doc.frontmatter.updated ?? doc.frontmatter.created)}</td>
22090
+ </tr>`
22091
+ ).join("\n");
22092
+ return `
22093
+ <div class="page-header">
22094
+ <h2>Project Overview</h2>
22095
+ </div>
22096
+
22097
+ <div class="cards">
22098
+ ${cards}
22099
+ </div>
22100
+
22101
+ <div class="section-title">Recent Activity</div>
22102
+ ${data.recent.length > 0 ? `
22103
+ <div class="table-wrap">
22104
+ <table>
22105
+ <thead>
22106
+ <tr>
22107
+ <th>ID</th>
22108
+ <th>Title</th>
22109
+ <th>Type</th>
22110
+ <th>Status</th>
22111
+ <th>Updated</th>
22112
+ </tr>
22113
+ </thead>
22114
+ <tbody>
22115
+ ${rows}
22116
+ </tbody>
22117
+ </table>
22118
+ </div>` : `<div class="empty"><p>No documents yet.</p></div>`}
22119
+ `;
22120
+ }
22121
+
22122
+ // src/web/templates/pages/documents.ts
22123
+ function documentsPage(data) {
22124
+ const label = typeLabel(data.type);
22125
+ const statusOptions = data.statuses.map(
22126
+ (s) => `<option value="${escapeHtml(s)}"${data.filterStatus === s ? " selected" : ""}>${escapeHtml(s)}</option>`
22127
+ ).join("");
22128
+ const ownerOptions = data.owners.map(
22129
+ (o) => `<option value="${escapeHtml(o)}"${data.filterOwner === o ? " selected" : ""}>${escapeHtml(o)}</option>`
22130
+ ).join("");
22131
+ const rows = data.docs.map(
22132
+ (doc) => `
22133
+ <tr>
22134
+ <td><a href="/docs/${data.type}/${doc.frontmatter.id}">${escapeHtml(doc.frontmatter.id)}</a></td>
22135
+ <td><a href="/docs/${data.type}/${doc.frontmatter.id}">${escapeHtml(doc.frontmatter.title)}</a></td>
22136
+ <td>${statusBadge(doc.frontmatter.status)}</td>
22137
+ <td>${escapeHtml(doc.frontmatter.owner ?? "\u2014")}</td>
22138
+ <td>${doc.frontmatter.priority ? `<span class="priority-${doc.frontmatter.priority.toLowerCase()}">${escapeHtml(doc.frontmatter.priority)}</span>` : "\u2014"}</td>
22139
+ <td>${formatDate(doc.frontmatter.updated ?? doc.frontmatter.created)}</td>
22140
+ </tr>`
22141
+ ).join("\n");
22142
+ return `
22143
+ <div class="page-header">
22144
+ <h2>${escapeHtml(label)}s</h2>
22145
+ <div class="subtitle">${data.docs.length} document${data.docs.length !== 1 ? "s" : ""}</div>
22146
+ </div>
22147
+
22148
+ <div class="filters">
22149
+ <select onchange="filterByStatus(this.value)">
22150
+ <option value="">All statuses</option>
22151
+ ${statusOptions}
22152
+ </select>
22153
+ <select onchange="filterByOwner(this.value)">
22154
+ <option value="">All owners</option>
22155
+ ${ownerOptions}
22156
+ </select>
22157
+ </div>
22158
+
22159
+ ${data.docs.length > 0 ? `
22160
+ <div class="table-wrap">
22161
+ <table>
22162
+ <thead>
22163
+ <tr>
22164
+ <th>ID</th>
22165
+ <th>Title</th>
22166
+ <th>Status</th>
22167
+ <th>Owner</th>
22168
+ <th>Priority</th>
22169
+ <th>Updated</th>
22170
+ </tr>
22171
+ </thead>
22172
+ <tbody>
22173
+ ${rows}
22174
+ </tbody>
22175
+ </table>
22176
+ </div>` : `<div class="empty"><p>No ${label.toLowerCase()}s found.</p></div>`}
22177
+
22178
+ <script>
22179
+ function filterByStatus(status) {
22180
+ const url = new URL(window.location);
22181
+ if (status) url.searchParams.set('status', status);
22182
+ else url.searchParams.delete('status');
22183
+ window.location = url;
22184
+ }
22185
+ function filterByOwner(owner) {
22186
+ const url = new URL(window.location);
22187
+ if (owner) url.searchParams.set('owner', owner);
22188
+ else url.searchParams.delete('owner');
22189
+ window.location = url;
22190
+ }
22191
+ </script>
22192
+ `;
22193
+ }
22194
+
22195
+ // src/web/templates/pages/document-detail.ts
22196
+ function documentDetailPage(doc) {
22197
+ const fm = doc.frontmatter;
22198
+ const label = typeLabel(fm.type);
22199
+ const skipKeys = /* @__PURE__ */ new Set(["title", "type"]);
22200
+ const entries = Object.entries(fm).filter(
22201
+ ([key]) => !skipKeys.has(key) && fm[key] != null
22202
+ );
22203
+ const dtDd = entries.map(([key, value]) => {
22204
+ let rendered;
22205
+ if (key === "status") {
22206
+ rendered = statusBadge(value);
22207
+ } else if (key === "tags" && Array.isArray(value)) {
22208
+ rendered = value.map((t) => `<span class="badge badge-default">${escapeHtml(t)}</span>`).join(" ");
22209
+ } else if (key === "created" || key === "updated") {
22210
+ rendered = formatDate(value);
22211
+ } else {
22212
+ rendered = escapeHtml(String(value));
22213
+ }
22214
+ return `<dt>${escapeHtml(key)}</dt><dd>${rendered}</dd>`;
22215
+ }).join("\n ");
22216
+ return `
22217
+ <div class="breadcrumb">
22218
+ <a href="/">Overview</a><span class="sep">/</span>
22219
+ <a href="/docs/${fm.type}">${escapeHtml(label)}s</a><span class="sep">/</span>
22220
+ ${escapeHtml(fm.id)}
22221
+ </div>
22222
+
22223
+ <div class="page-header">
22224
+ <h2>${escapeHtml(fm.title)}</h2>
22225
+ <div class="subtitle">${escapeHtml(fm.id)} &middot; ${escapeHtml(label)}</div>
22226
+ </div>
22227
+
22228
+ <div class="detail-meta">
22229
+ <dl>
22230
+ ${dtDd}
22231
+ </dl>
22232
+ </div>
22233
+
22234
+ ${doc.content.trim() ? `<div class="detail-content">${renderMarkdown(doc.content)}</div>` : ""}
22235
+ `;
22236
+ }
22237
+
22238
+ // src/web/templates/pages/gar.ts
22239
+ function garPage(report) {
22240
+ const dotClass = `dot-${report.overall}`;
22241
+ const areaCards = report.areas.map(
22242
+ (area) => `
22243
+ <div class="gar-area">
22244
+ <div class="area-header">
22245
+ <div class="area-dot dot-${area.status}"></div>
22246
+ <div class="area-name">${escapeHtml(area.name)}</div>
22247
+ </div>
22248
+ <div class="area-summary">${escapeHtml(area.summary)}</div>
22249
+ ${area.items.length > 0 ? `<ul>${area.items.map((item) => `<li><span class="ref-id">${escapeHtml(item.id)}</span>${escapeHtml(item.title)}</li>`).join("")}</ul>` : ""}
22250
+ </div>`
22251
+ ).join("\n");
22252
+ return `
22253
+ <div class="page-header">
22254
+ <h2>GAR Report</h2>
22255
+ <div class="subtitle">Generated ${escapeHtml(report.generatedAt)}</div>
22256
+ </div>
22257
+
22258
+ <div class="gar-overall">
22259
+ <div class="dot ${dotClass}"></div>
22260
+ <div class="label">Overall: ${escapeHtml(report.overall)}</div>
22261
+ </div>
22262
+
22263
+ <div class="gar-areas">
22264
+ ${areaCards}
22265
+ </div>
22266
+ `;
22267
+ }
22268
+
22269
+ // src/web/templates/pages/board.ts
22270
+ function boardPage(data) {
22271
+ const typeOptions = data.types.map(
22272
+ (t) => `<option value="${escapeHtml(t)}"${data.type === t ? " selected" : ""}>${escapeHtml(typeLabel(t))}s</option>`
22273
+ ).join("");
22274
+ const columns = data.columns.map(
22275
+ (col) => `
22276
+ <div class="board-column">
22277
+ <div class="board-column-header">
22278
+ <span>${escapeHtml(col.status)}</span>
22279
+ <span class="count">${col.docs.length}</span>
22280
+ </div>
22281
+ ${col.docs.map(
22282
+ (doc) => `
22283
+ <div class="board-card">
22284
+ <a href="/docs/${doc.frontmatter.type}/${doc.frontmatter.id}">
22285
+ <div class="bc-id">${escapeHtml(doc.frontmatter.id)}</div>
22286
+ <div class="bc-title">${escapeHtml(doc.frontmatter.title)}</div>
22287
+ ${doc.frontmatter.owner ? `<div class="bc-owner">${escapeHtml(doc.frontmatter.owner)}</div>` : ""}
22288
+ </a>
22289
+ </div>`
22290
+ ).join("\n")}
22291
+ </div>`
22292
+ ).join("\n");
22293
+ return `
22294
+ <div class="page-header">
22295
+ <h2>Status Board</h2>
22296
+ </div>
22297
+
22298
+ <div class="filters">
22299
+ <select onchange="filterByType(this.value)">
22300
+ <option value="">All types</option>
22301
+ ${typeOptions}
22302
+ </select>
22303
+ </div>
22304
+
22305
+ ${data.columns.length > 0 ? `<div class="board">${columns}</div>` : `<div class="empty"><p>No documents to display.</p></div>`}
22306
+
22307
+ <script>
22308
+ function filterByType(type) {
22309
+ if (type) window.location = '/board/' + type;
22310
+ else window.location = '/board';
22311
+ }
22312
+ </script>
22313
+ `;
22314
+ }
22315
+
22316
+ // src/web/router.ts
22317
+ function handleRequest(req, res, store, projectName) {
22318
+ const parsed = new URL(req.url ?? "/", `http://${req.headers.host ?? "localhost"}`);
22319
+ const pathname = parsed.pathname;
22320
+ const navTypes = store.registeredTypes;
22321
+ try {
22322
+ if (pathname === "/styles.css") {
22323
+ res.writeHead(200, {
22324
+ "Content-Type": "text/css",
22325
+ "Cache-Control": "public, max-age=300"
22326
+ });
22327
+ res.end(renderStyles());
22328
+ return;
22329
+ }
22330
+ if (pathname === "/") {
22331
+ const data = getOverviewData(store);
22332
+ const body = overviewPage(data);
22333
+ respond(res, layout({ title: "Overview", activePath: "/", projectName, navTypes }, body));
22334
+ return;
22335
+ }
22336
+ if (pathname === "/gar") {
22337
+ const report = getGarData(store, projectName);
22338
+ const body = garPage(report);
22339
+ respond(res, layout({ title: "GAR Report", activePath: "/gar", projectName, navTypes }, body));
22340
+ return;
22341
+ }
22342
+ const boardMatch = pathname.match(/^\/board(?:\/([^/]+))?$/);
22343
+ if (boardMatch) {
22344
+ const type = boardMatch[1];
22345
+ if (type && !navTypes.includes(type)) {
22346
+ notFound(res, projectName, navTypes, pathname);
22347
+ return;
22348
+ }
22349
+ const data = getBoardData(store, type);
22350
+ const body = boardPage(data);
22351
+ respond(res, layout({ title: "Board", activePath: "/board", projectName, navTypes }, body));
22352
+ return;
22353
+ }
22354
+ const detailMatch = pathname.match(/^\/docs\/([^/]+)\/([^/]+)$/);
22355
+ if (detailMatch) {
22356
+ const [, type, id] = detailMatch;
22357
+ const doc = getDocumentDetail(store, type, id);
22358
+ if (!doc) {
22359
+ notFound(res, projectName, navTypes, pathname);
22360
+ return;
22361
+ }
22362
+ const body = documentDetailPage(doc);
22363
+ respond(res, layout({ title: `${id} \u2014 ${doc.frontmatter.title}`, activePath: `/docs/${type}`, projectName, navTypes }, body));
22364
+ return;
22365
+ }
22366
+ const listMatch = pathname.match(/^\/docs\/([^/]+)$/);
22367
+ if (listMatch) {
22368
+ const type = listMatch[1];
22369
+ const filterStatus = parsed.searchParams.get("status") ?? void 0;
22370
+ const filterOwner = parsed.searchParams.get("owner") ?? void 0;
22371
+ const data = getDocumentListData(store, type, filterStatus, filterOwner);
22372
+ if (!data) {
22373
+ notFound(res, projectName, navTypes, pathname);
22374
+ return;
22375
+ }
22376
+ const body = documentsPage(data);
22377
+ respond(res, layout({ title: `${type}`, activePath: `/docs/${type}`, projectName, navTypes }, body));
22378
+ return;
22379
+ }
22380
+ notFound(res, projectName, navTypes, pathname);
22381
+ } catch (err) {
22382
+ console.error("[marvin web] Error handling request:", err);
22383
+ res.writeHead(500, { "Content-Type": "text/html" });
22384
+ res.end("<h1>500 \u2014 Internal Server Error</h1>");
22385
+ }
22386
+ }
22387
+ function respond(res, html) {
22388
+ res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
22389
+ res.end(html);
22390
+ }
22391
+ function notFound(res, projectName, navTypes, activePath) {
22392
+ const body = `<div class="empty"><h2>404</h2><p>Page not found.</p><p><a href="/">Go to overview</a></p></div>`;
22393
+ res.writeHead(404, { "Content-Type": "text/html; charset=utf-8" });
22394
+ res.end(layout({ title: "Not Found", activePath, projectName, navTypes }, body));
22395
+ }
22396
+
22397
+ // src/web/server.ts
22398
+ async function startWebServer(opts) {
22399
+ const project = loadProject();
22400
+ const plugin = resolvePlugin(project.config.methodology);
22401
+ const pluginRegs = plugin?.documentTypeRegistrations ?? [];
22402
+ const allSkills = loadAllSkills(project.marvinDir);
22403
+ const allSkillIds = [...allSkills.keys()];
22404
+ const skillRegs = collectSkillRegistrations(allSkillIds, allSkills);
22405
+ const store = new DocumentStore(project.marvinDir, [
22406
+ ...pluginRegs,
22407
+ ...skillRegs
22408
+ ]);
22409
+ const projectName = project.config.name;
22410
+ const server = http.createServer((req, res) => {
22411
+ handleRequest(req, res, store, projectName);
22412
+ });
22413
+ server.listen(opts.port, () => {
22414
+ const url2 = `http://localhost:${opts.port}`;
22415
+ console.log(`
22416
+ Marvin dashboard running at ${url2}
22417
+ `);
22418
+ console.log(" Press Ctrl+C to stop.\n");
22419
+ if (opts.open) {
22420
+ openBrowser(url2);
22421
+ }
22422
+ });
22423
+ const shutdown = () => {
22424
+ console.log("\n Shutting down...\n");
22425
+ server.close(() => process.exit(0));
22426
+ setTimeout(() => process.exit(0), 2e3);
22427
+ };
22428
+ process.on("SIGINT", shutdown);
22429
+ process.on("SIGTERM", shutdown);
22430
+ }
22431
+ function openBrowser(url2) {
22432
+ const platform = process.platform;
22433
+ const cmd = platform === "darwin" ? `open "${url2}"` : platform === "win32" ? `start "${url2}"` : `xdg-open "${url2}"`;
22434
+ exec(cmd, (err) => {
22435
+ if (err) {
22436
+ }
22437
+ });
22438
+ }
22439
+
22440
+ // src/cli/commands/web.ts
22441
+ async function webCommand(options) {
22442
+ const port = options.port ? parseInt(options.port, 10) : 3e3;
22443
+ if (isNaN(port) || port < 1 || port > 65535) {
22444
+ console.error("Error: invalid port number");
22445
+ process.exit(1);
22446
+ }
22447
+ await startWebServer({ port, open: options.open });
22448
+ }
22449
+
21401
22450
  // src/cli/program.ts
21402
22451
  function createProgram() {
21403
22452
  const program = new Command();
21404
22453
  program.name("marvin").description(
21405
22454
  "AI-powered product development assistant with Product Owner, Delivery Manager, and Technical Lead personas"
21406
- ).version("0.2.9");
22455
+ ).version("0.2.10");
21407
22456
  program.command("init").description("Initialize a new Marvin project in the current directory").action(async () => {
21408
22457
  await initCommand();
21409
22458
  });
@@ -21480,6 +22529,9 @@ function createProgram() {
21480
22529
  ).action(async (options) => {
21481
22530
  await garReportCommand(options);
21482
22531
  });
22532
+ program.command("web").description("Launch a local web dashboard for project data").option("-p, --port <port>", "Port to listen on (default: 3000)").option("--no-open", "Don't auto-open the browser").action(async (options) => {
22533
+ await webCommand(options);
22534
+ });
21483
22535
  return program;
21484
22536
  }
21485
22537
  export {