@c4a/context-cli 0.7.100 → 0.7.102

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 (75) hide show
  1. package/cli.js +1499 -715
  2. package/indexers/contracts/profile-contract.json +245 -245
  3. package/indexers/release-manifest.json +1 -1
  4. package/package.json +12 -12
  5. package/parserEntryWorker.js +80 -3
  6. package/plugins/VERSION +1 -1
  7. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  8. package/plugins/claude/commands/context.md +4 -2
  9. package/plugins/claude/resources/context/routine-update.md +10 -3
  10. package/plugins/claude/skills/context-plan/SKILL.md +22 -4
  11. package/plugins/claude/skills/context-plan/references/knowledge-migration.md +167 -0
  12. package/plugins/claude/skills/context-plan/references/project-planning.md +5 -0
  13. package/plugins/claude/skills/context-plan/references/quality-audit.md +63 -0
  14. package/plugins/claude/skills/context-plan/references/research-report.md +80 -0
  15. package/plugins/claude/skills/context-plan/references/resource-tools.md +13 -0
  16. package/plugins/claude/skills/context-plan/references/stakeholder-intake.md +38 -0
  17. package/plugins/claude/skills/context-plan/templates/PLAN.md +25 -0
  18. package/plugins/claude/skills/context-plan/templates/research-report/README.md +79 -0
  19. package/plugins/claude/skills/context-plan/templates/research-report/build.mjs +144 -0
  20. package/plugins/claude/skills/context-plan/templates/research-report/example/01-conclusions.md +28 -0
  21. package/plugins/claude/skills/context-plan/templates/research-report/example/A-wiki-a.md +10 -0
  22. package/plugins/codex/.codex-plugin/plugin.json +2 -2
  23. package/plugins/codex/skills/context/SKILL.md +4 -2
  24. package/plugins/codex/skills/context/references/routine-update.md +10 -3
  25. package/plugins/codex/skills/context-plan/SKILL.md +22 -4
  26. package/plugins/codex/skills/context-plan/references/knowledge-migration.md +167 -0
  27. package/plugins/codex/skills/context-plan/references/project-planning.md +5 -0
  28. package/plugins/codex/skills/context-plan/references/quality-audit.md +63 -0
  29. package/plugins/codex/skills/context-plan/references/research-report.md +80 -0
  30. package/plugins/codex/skills/context-plan/references/resource-tools.md +13 -0
  31. package/plugins/codex/skills/context-plan/references/stakeholder-intake.md +38 -0
  32. package/plugins/codex/skills/context-plan/templates/PLAN.md +25 -0
  33. package/plugins/codex/skills/context-plan/templates/research-report/README.md +79 -0
  34. package/plugins/codex/skills/context-plan/templates/research-report/build.mjs +144 -0
  35. package/plugins/codex/skills/context-plan/templates/research-report/example/01-conclusions.md +28 -0
  36. package/plugins/codex/skills/context-plan/templates/research-report/example/A-wiki-a.md +10 -0
  37. package/plugins/cursor/.cursor-plugin/plugin.json +1 -1
  38. package/plugins/cursor/commands/c4a-context.md +4 -2
  39. package/plugins/cursor/resources/context/routine-update.md +10 -3
  40. package/plugins/cursor/skills/context-plan/SKILL.md +22 -4
  41. package/plugins/cursor/skills/context-plan/references/knowledge-migration.md +167 -0
  42. package/plugins/cursor/skills/context-plan/references/project-planning.md +5 -0
  43. package/plugins/cursor/skills/context-plan/references/quality-audit.md +63 -0
  44. package/plugins/cursor/skills/context-plan/references/research-report.md +80 -0
  45. package/plugins/cursor/skills/context-plan/references/resource-tools.md +13 -0
  46. package/plugins/cursor/skills/context-plan/references/stakeholder-intake.md +38 -0
  47. package/plugins/cursor/skills/context-plan/templates/PLAN.md +25 -0
  48. package/plugins/cursor/skills/context-plan/templates/research-report/README.md +79 -0
  49. package/plugins/cursor/skills/context-plan/templates/research-report/build.mjs +144 -0
  50. package/plugins/cursor/skills/context-plan/templates/research-report/example/01-conclusions.md +28 -0
  51. package/plugins/cursor/skills/context-plan/templates/research-report/example/A-wiki-a.md +10 -0
  52. package/plugins/skills/context/SKILL.md +4 -2
  53. package/plugins/skills/context/references/routine-update.md +10 -3
  54. package/plugins/skills/context-plan/SKILL.md +22 -4
  55. package/plugins/skills/context-plan/references/knowledge-migration.md +167 -0
  56. package/plugins/skills/context-plan/references/project-planning.md +5 -0
  57. package/plugins/skills/context-plan/references/quality-audit.md +63 -0
  58. package/plugins/skills/context-plan/references/research-report.md +80 -0
  59. package/plugins/skills/context-plan/references/resource-tools.md +13 -0
  60. package/plugins/skills/context-plan/references/stakeholder-intake.md +38 -0
  61. package/plugins/skills/context-plan/templates/PLAN.md +25 -0
  62. package/plugins/skills/context-plan/templates/research-report/README.md +79 -0
  63. package/plugins/skills/context-plan/templates/research-report/build.mjs +144 -0
  64. package/plugins/skills/context-plan/templates/research-report/example/01-conclusions.md +28 -0
  65. package/plugins/skills/context-plan/templates/research-report/example/A-wiki-a.md +10 -0
  66. package/providers/context/manifest.json +18 -18
  67. package/providers/context/provider.yaml +1 -1
  68. package/providers/context/resources/manuals/guides/knowledge-updates.md +47 -0
  69. package/providers/context/resources/manuals/guides/package-outputs.md +8 -0
  70. package/providers/context/resources/procedures/knowledge-review.md +13 -0
  71. package/providers/context/resources/procedures/knowledge-updates.md +47 -0
  72. package/providers/context/resources/procedures/production-requirements.md +7 -0
  73. package/providers/context/resources/procedures/production-stage-files.md +40 -1
  74. package/providers/context/resources/procedures/source-capture-detailed.md +5 -0
  75. package/providers/context/schemas/indexer-agent-step-result.schema.json +3 -0
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env node
2
+ // Build a single-page research report from Markdown chapters. No dependencies.
3
+ // Usage: node build.mjs <chapters-dir> <out.html> [--title T] [--subtitle S] [--labels labels.json]
4
+ import { readFileSync, readdirSync, writeFileSync } from "node:fs";
5
+ import { join } from "node:path";
6
+
7
+ const args = process.argv.slice(2);
8
+ const opt = (k, d) => { const eq = args.find((a) => a.startsWith(`${k}=`)); if (eq) return eq.slice(k.length + 1); const i = args.indexOf(k); return i >= 0 ? args[i + 1] : d; };
9
+ const [dir, out] = args.filter((a, i) => !a.startsWith("--") && !(i > 0 && args[i - 1].startsWith("--") && !args[i - 1].includes("=")));
10
+ if (!dir || !out) { console.error("usage: node build.mjs <chapters-dir> <out.html> [--title T] [--subtitle S] [--labels file]"); process.exit(2); }
11
+ const LABELS = { add: "added", mod: "revised", dir: "new section", keep: "kept unchanged", report: "Report", appendix: "Appendix", outline: "On this chapter", prev: "Previous", next: "Next", copied: "Copied", ...(opt("--labels") ? JSON.parse(readFileSync(opt("--labels"), "utf8")) : {}) };
12
+ const C = { brand: "#2563eb", accent: "#00bec8", ok: "#16a34a", warn: "#d97706", bad: "#dc2626", gray: "#9ca3af", text: "#161e2e", muted: "#646b7c", border: "#e7e9ef" };
13
+ const esc = (s) => String(s).replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
14
+ const unesc = (s) => String(s).replace(/&(amp|lt|gt|quot|#39);/g, (_, e) => ({ amp: "&", lt: "<", gt: ">", quot: '"', "#39": "'" })[e]);
15
+ // Links may only be web, mail, in-page or relative; anything else (javascript:, data:) stays plain text.
16
+ const safeUrl = (u) => { const raw = unesc(u).replace(/[\u0000-\u0020]/g, ""); const scheme = /^([a-z][a-z0-9+.-]*):/i.exec(raw); return !scheme || ["http", "https", "mailto"].includes(scheme[1].toLowerCase()) ? u : null; };
17
+
18
+ // ---------- inline ----------
19
+ const PATH = /^(?:[\p{L}\p{N}_@.+\-]+\/)+(?:[\p{L}\p{N}_@.+\-*]+(?::\d+(?:-\d+)?)?)?$/u;
20
+ const shortPath = (p) => { if (p.length <= 40) return p; const s = p.split("/"); const last = s.pop(); return `${s[0]}/…/${last.length > 32 ? last.slice(0, 14) + "…" + last.slice(-14) : last}`; };
21
+ function inline(t) {
22
+ const codes = [];
23
+ t = t.replace(/`([^`]+)`/g, (_, c) => { codes.push(PATH.test(c) ? `<span class="pc" data-p="${esc(c)}" title="${esc(c)}">${esc(shortPath(c))}</span>` : `<code>${esc(c)}</code>`); return `\u0000${codes.length - 1}\u0000`; });
24
+ t = esc(t)
25
+ .replace(/\*\*(.+?)\*\*/g, "<b>$1</b>")
26
+ .replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (_, x, u) => { const safe = safeUrl(u); return safe === null ? x : `<a href="${safe}">${x}</a>`; });
27
+ return t.replace(/\u0000(\d+)\u0000/g, (_, i) => codes[+i]);
28
+ }
29
+
30
+ // ---------- blocks ----------
31
+ function tree(src) {
32
+ const tags = { "[add]": "add", "[mod]": "mod", "[dir]": "dir", "[keep]": "keep" };
33
+ return `<pre class="tree">${src.trimEnd().split("\n").map((l) => {
34
+ const k = Object.keys(tags).find((t) => l.trimEnd().endsWith(t));
35
+ if (!k) return `<span>${esc(l)}</span>`;
36
+ const body = l.trimEnd().slice(0, -k.length).trimEnd(); const m = body.match(/^([│├└─\s]*)(.*)$/u);
37
+ return `<span class="${tags[k]}">${esc(m[1])}<i>${esc(m[2])}</i><em>${esc(LABELS[tags[k]])}</em></span>`;
38
+ }).join("")}</pre>`;
39
+ }
40
+ function chart(src, where) {
41
+ let d; try { d = JSON.parse(src); } catch (e) { throw new Error(`${where}: invalid chart JSON (${e.message})`); } const COLOR = /^#[0-9a-fA-F]{3,8}$/;
42
+ const color = (c, f) => { if (typeof c !== "string" || !COLOR.test(c)) throw new Error(`${where}: ${f} must be a #rgb or #rrggbb colour`); return c; };
43
+ const num = (v, f) => { if (typeof v !== "number" || !Number.isFinite(v)) throw new Error(`${where}: ${f} must be a finite number`); return v; };
44
+ for (const k of ["max", "xmax", "ymax"]) if (d[k] !== undefined) num(d[k], k);
45
+ (d.values || []).forEach((row, i) => row.forEach((v, j) => num(v, `values[${i}][${j}]`)));
46
+ (d.rows || []).forEach((r, i) => (Array.isArray(r.values) ? r.values : []).forEach((v, j) => num(v, `rows[${i}].values[${j}]`)));
47
+ (d.points || []).forEach((p, i) => { num(p.x, `points[${i}].x`); num(p.y, `points[${i}].y`); if (p.color !== undefined) color(p.color, `points[${i}].color`); });
48
+ const pal = (d.colors || [C.ok, C.warn, C.bad, C.gray, C.brand, C.accent]).map((c, i) => color(c, `colors[${i}]`));
49
+ if ((d.type === "matrix" || d.type === undefined || d.type === "bar") && !(d.rows || []).length) throw new Error(`${where}: chart needs at least one row`);
50
+ if (d.type === "scatter" && !(d.points || []).length) throw new Error(`${where}: scatter needs at least one point`);
51
+ if (d.type === "matrix") {
52
+ const W = 160 + d.columns.length * 112, H = 50 + d.rows.length * 38;
53
+ let s = `<svg viewBox="0 0 ${W} ${H}">`;
54
+ d.columns.forEach((c, j) => { s += `<text x="${160 + j * 112 + 56}" y="22" font-size="11" text-anchor="middle" fill="${C.muted}">${esc(c)}</text>`; });
55
+ const rec = new Set((d.recommend || []).map(([r, c]) => `${r},${c}`));
56
+ d.rows.forEach((r, i) => { const mark = (v, j) => d.recommend ? rec.has(`${i},${j}`) : v === Math.max(...d.values[i]); s += `<text x="150" y="${61 + i * 38}" font-size="12" text-anchor="end">${esc(r)}</text>`;
57
+ d.values[i].forEach((v, j) => { const op = 0.15 + 0.85 * v / ((d.max ?? 5) || 1); s += `<rect x="${164 + j * 112}" y="${40 + i * 38}" width="104" height="32" rx="4" fill="${C.brand}" fill-opacity="${op.toFixed(2)}" ${mark(v, j) ? `stroke="${C.text}" stroke-width="2"` : ""}/><text x="${216 + j * 112}" y="${61 + i * 38}" font-size="12" text-anchor="middle" fill="${op > 0.6 ? "#fff" : C.text}" font-weight="${mark(v, j) ? 700 : 400}">${v}</text>`; }); });
58
+ return fig(s + "</svg>", d.title);
59
+ }
60
+ if (d.type === "scatter") {
61
+ const W = 720, H = 320, X = (v) => 70 + v / (d.xmax || 1) * 600, Y = (v) => 280 - v / (d.ymax || 1) * 250;
62
+ let s = `<svg viewBox="0 0 ${W} ${H}"><rect x="70" y="30" width="600" height="250" fill="#f8f9fc" stroke="${C.border}"/>`;
63
+ s += `<text x="370" y="310" font-size="12" text-anchor="middle" fill="${C.muted}">${esc(d.xlabel || "")}</text><text x="20" y="155" font-size="12" text-anchor="middle" fill="${C.muted}" transform="rotate(-90 20 155)">${esc(d.ylabel || "")}</text>`;
64
+ d.points.forEach((p) => { s += `<circle cx="${X(p.x)}" cy="${Y(p.y)}" r="8" fill="${p.color || C.brand}"/><text x="${X(p.x) + 13}" y="${Y(p.y) - 2}" font-size="12.5" font-weight="700">${esc(p.label)}</text>${p.note ? `<text x="${X(p.x) + 13}" y="${Y(p.y) + 14}" font-size="11" fill="${C.muted}">${esc(p.note)}</text>` : ""}`; });
65
+ return fig(s + "</svg>", d.title);
66
+ }
67
+ const max = (d.max ?? Math.max(...d.rows.map((r) => r.values.reduce((a, b) => a + b, 0)))) || 1; const W = 760, L = 130, R = 190, bw = W - L - R;
68
+ let s = `<svg viewBox="0 0 ${W} ${d.rows.length * 34 + 20}">`;
69
+ d.rows.forEach((r, i) => { const y = 10 + i * 34; let x = L; s += `<text x="${L - 10}" y="${y + 15}" font-size="12" text-anchor="end">${esc(r.label)}</text>`;
70
+ r.values.forEach((v, j) => { const w = Math.max(v / max * bw, v > 0 ? 2 : 0); s += `<rect x="${x}" y="${y}" width="${w}" height="20" rx="3" fill="${pal[j % pal.length]}"/>`; if (d.segmentLabels && w > 22) s += `<text x="${x + w / 2}" y="${y + 14}" font-size="11" text-anchor="middle" fill="#fff">${v}</text>`; x += w; });
71
+ s += `<text x="${x + 8}" y="${y + 15}" font-size="12" fill="${C.muted}">${esc(r.note ?? r.values.reduce((a, b) => a + b, 0) + (d.unit || ""))}</text>`; });
72
+ const legend = (d.legend || []).map((l, j) => `<span><b style="background:${pal[j % pal.length]}"></b>${esc(l)}</span>`).join("");
73
+ return fig(s + "</svg>", d.title, legend);
74
+ }
75
+ const fig = (svg, cap, legend = "") => `<figure>${svg}${legend ? `<div class="lg">${legend}</div>` : ""}${cap ? `<figcaption>${esc(cap)}</figcaption>` : ""}</figure>`;
76
+
77
+ function render(md, file = "") {
78
+ const lines = md.replace(/\r/g, "").split("\n"); let h = ""; let i = 0;
79
+ const isTable = (l) => /^\s*\|.*\|\s*$/.test(l);
80
+ while (i < lines.length) {
81
+ const l = lines[i];
82
+ const fence = l.match(/^```(\w*)/);
83
+ if (fence) { const body = []; i++; while (i < lines.length && !lines[i].startsWith("```")) body.push(lines[i++]); i++;
84
+ const b = body.join("\n"); h += fence[1] === "tree" ? tree(b) : fence[1] === "chart" ? chart(b, `${file}:${i}`) : `<pre><code>${esc(b)}</code></pre>`; continue; }
85
+ const hd = l.match(/^(#{1,4})\s+(.*)$/); if (hd) { h += `<h${hd[1].length}>${inline(hd[2])}</h${hd[1].length}>`; i++; continue; }
86
+ if (isTable(l) && i + 1 < lines.length && /^\s*\|[\s:|-]+\|\s*$/.test(lines[i + 1])) {
87
+ const cells = (r) => r.trim().slice(1, -1).replace(/`[^`]*`/g, (m) => m.replace(/\|/g, "\u0001")).split("|").map((c) => c.trim().replace(/\u0001/g, "|"));
88
+ h += `<div class="tw"><table><thead><tr>${cells(l).map((c) => `<th>${inline(c)}</th>`).join("")}</tr></thead><tbody>`; i += 2;
89
+ while (i < lines.length && isTable(lines[i])) h += `<tr>${cells(lines[i++]).map((c) => `<td>${inline(c)}</td>`).join("")}</tr>`;
90
+ h += "</tbody></table></div>"; continue; }
91
+ if (/^>\s?/.test(l)) { const q = []; while (i < lines.length && /^>\s?/.test(lines[i])) q.push(lines[i++].replace(/^>\s?/, "")); h += `<blockquote><p>${inline(q.join(" "))}</p></blockquote>`; continue; }
92
+ const li = l.match(/^(\s*)([-*]|\d+\.)\s+(.*)$/);
93
+ if (li) { const ordered = /\d/.test(li[2]); h += ordered ? "<ol>" : "<ul>";
94
+ while (i < lines.length) { const m = lines[i].match(/^(\s*)([-*]|\d+\.)\s+(.*)$/); if (!m) { if (/^\s{2,}\S/.test(lines[i])) { h = h.replace(/<\/li>$/, ` ${inline(lines[i].trim())}</li>`); i++; continue; } break; }
95
+ h += `<li${m[1].length ? ' class="sub"' : ""}>${inline(m[3])}</li>`; i++; }
96
+ h += ordered ? "</ol>" : "</ul>"; continue; }
97
+ if (!l.trim()) { i++; continue; }
98
+ const p = []; while (i < lines.length && lines[i].trim() && !/^(#{1,4}\s|```|>|\s*([-*]|\d+\.)\s)/.test(lines[i]) && !isTable(lines[i])) p.push(lines[i++]);
99
+ h += `<p>${inline(p.join(" "))}</p>`;
100
+ }
101
+ return h;
102
+ }
103
+
104
+ // ---------- page ----------
105
+ const files = readdirSync(dir).filter((f) => f.endsWith(".md")).sort();
106
+ let nav = "", body = "", n = 0, inApp = false;
107
+ try { files.forEach((f, k) => {
108
+ const app = /^[A-Z][-_.]/.test(f); const id = `c${k + 1}`; let title = f;
109
+ const html = render(readFileSync(join(dir, f), "utf8"), f).replace(/<h([1-3])>(.*?)<\/h\1>/g, (m, lv, t) => { if (lv === "1") { title = unesc(t.replace(/<[^>]+>/g, "")); return m; } n++; return `<h${lv} id="${id}-${n}">${t}</h${lv}>`; });
110
+ if (app && !inApp) { nav += `<div class="cap">${esc(LABELS.appendix)}</div>`; inApp = true; }
111
+ nav += `<a href="#${id}" data-ch="${id}">${app ? "" : `<span>${k + 1}</span>`}${esc(title)}</a>`;
112
+ body += `<article class="ch" id="${id}" data-title="${esc(title)}">${html}<div class="pager"></div></article>`;
113
+ }); } catch (e) { console.error(`build failed: ${e.message}`); process.exit(1); }
114
+ const title = opt("--title", "Research report"), sub = opt("--subtitle", "");
115
+ writeFileSync(out, `<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${esc(title)}</title><style>
116
+ *{box-sizing:border-box}body{margin:0;font:15px/1.8 Inter,-apple-system,"PingFang SC","Microsoft YaHei",sans-serif;color:${C.text}}
117
+ header{position:fixed;inset:0 0 auto;height:56px;display:flex;align-items:center;gap:12px;padding:0 24px;border-bottom:1px solid ${C.border};background:#fffffff2;z-index:2}header span{color:${C.muted};font-size:13px}
118
+ #side{position:fixed;top:56px;bottom:0;left:0;width:260px;overflow:auto;padding:20px 14px;background:#f8f9fc;border-right:1px solid ${C.border}}#side a{display:flex;gap:8px;padding:6px 10px;border-radius:7px;color:${C.text};text-decoration:none;font-size:14px}#side a span{color:${C.muted}}#side a.on{background:#e8efff;color:${C.brand};font-weight:600}.cap{font-size:12px;color:${C.muted};margin:18px 10px 6px}
119
+ main{margin:0 230px 0 260px;padding:80px 48px 100px}.ch{display:none;max-width:940px;margin:auto}.ch.on{display:block}
120
+ #out{position:fixed;top:56px;right:0;bottom:0;width:230px;overflow:auto;padding:28px 16px;border-left:1px solid ${C.border}}#out a{display:block;color:${C.muted};text-decoration:none;font-size:13px;padding:3px 8px;border-left:2px solid transparent}#out a.h3{padding-left:20px}#out a.on{color:${C.brand};border-color:${C.brand}}
121
+ h1{font-size:28px}h2{font-size:21px;margin-top:36px;padding-top:18px;border-top:1px solid ${C.border}}h2,h3{scroll-margin-top:70px}a{color:${C.brand}}code{background:#f1f3f7;padding:1px 5px;border-radius:4px;font-size:13px}
122
+ pre{background:#f6f8fa;border:1px solid ${C.border};border-radius:8px;padding:12px 16px;overflow:auto;line-height:1.6}.tw{overflow-x:auto}table{border-collapse:collapse;width:100%;font-size:13.5px}th,td{border:1px solid ${C.border};padding:7px 10px;text-align:left;vertical-align:top}th{background:#f8f9fc}
123
+ blockquote{margin:0 0 20px;padding:10px 16px;border-left:4px solid ${C.brand};background:#f3f7ff}li.sub{margin-left:20px}
124
+ figure{margin:18px 0;padding:14px;border:1px solid ${C.border};border-radius:10px}figure svg{width:100%;height:auto}figcaption{text-align:center;color:${C.muted};font-size:13px}.lg{display:flex;gap:14px;flex-wrap:wrap;font-size:12px;color:${C.muted}}.lg b{display:inline-block;width:11px;height:11px;border-radius:3px;margin-right:5px}
125
+ .pc{font:12.5px ui-monospace,monospace;background:#f1f3f7;border:1px solid #e5e8ef;border-radius:5px;padding:0 6px;cursor:copy;white-space:nowrap}td .pc{display:table;margin:2px 0}
126
+ .tree{font:13px/1.65 ui-monospace,"PingFang SC",monospace}.tree span{display:block}.tree i{font-style:normal;padding:0 4px;border-radius:4px}.tree em{font-style:normal;font-size:12px;margin-left:10px;padding:0 6px;border-radius:9px;color:#fff}
127
+ .tree .add i{background:#dcfce7}.tree .add em{background:${C.ok}}.tree .mod i{background:#fef3c7}.tree .mod em{background:${C.warn}}.tree .dir i{background:#dbeafe;font-weight:600}.tree .dir em{background:${C.brand}}.tree .keep i{background:#cffafe}.tree .keep em{background:#0891b2}
128
+ .pager{display:flex;justify-content:space-between;gap:16px;margin-top:48px}.pager a{flex:1;border:1px solid ${C.border};border-radius:10px;padding:10px 14px;text-decoration:none;color:${C.text}}.pager small{display:block;color:${C.muted}}
129
+ @media(max-width:1200px){#out{display:none}main{margin-right:0}}@media(max-width:820px){#side{display:none}main{margin-left:0;padding:72px 16px}}
130
+ </style></head><body><header><b>${esc(title)}</b><span>${esc(sub)}</span></header><nav id="side"><div class="cap">${esc(LABELS.report)}</div>${nav}</nav><main>${body}</main><aside id="out"></aside><script>
131
+ const CH=[...document.querySelectorAll('.ch')],S=[...document.querySelectorAll('#side a')],O=document.getElementById('out');let H=[],A=[];
132
+ const OUTLINE=${JSON.stringify(LABELS.outline).replace(/</g, "\\u003c")},PREV=${JSON.stringify(LABELS.prev).replace(/</g, "\\u003c")},NEXT=${JSON.stringify(LABELS.next).replace(/</g, "\\u003c")};
133
+ // Build navigation from text nodes only; titles never become markup.
134
+ function link(cls,id,small,text){const a=document.createElement('a');if(cls)a.className=cls;a.href='#'+id;if(small){const s=document.createElement('small');s.textContent=small;a.append(s)}a.append(document.createTextNode(text||''));return a}
135
+ function show(h){let e=document.getElementById((h||'').slice(1)),t=null;if(!e||!e.classList.contains('ch')){t=e;e=e?e.closest('.ch'):CH[0]}
136
+ CH.forEach(c=>c.classList.toggle('on',c===e));S.forEach(a=>a.classList.toggle('on',a.dataset.ch===e.id));H=[...e.querySelectorAll('h2,h3')];
137
+ O.replaceChildren();if(H.length){const b=document.createElement('b');b.style.fontSize='13px';b.textContent=OUTLINE;O.append(b,...H.map(x=>link(x.tagName.toLowerCase(),x.id,null,x.textContent)))}A=[...O.querySelectorAll('a')];
138
+ const i=CH.indexOf(e),p=CH[i-1],n=CH[i+1],pg=e.querySelector('.pager');pg.replaceChildren(p?link('',p.id,PREV,p.dataset.title):document.createElement('span'),n?link('',n.id,NEXT,n.dataset.title):document.createElement('span'));
139
+ t?t.scrollIntoView():scrollTo(0,0);spy()}
140
+ function spy(){let k=-1;H.forEach((x,i)=>{if(x.getBoundingClientRect().top<100)k=i});A.forEach((a,i)=>a.classList.toggle('on',i===k))}
141
+ document.addEventListener('click',e=>{const c=e.target.closest('.pc');if(!c)return;navigator.clipboard&&navigator.clipboard.writeText(c.dataset.p);const o=c.textContent;c.textContent=${JSON.stringify(LABELS.copied).replace(/</g, "\\u003c")};setTimeout(()=>c.textContent=o,900)});
142
+ addEventListener('hashchange',()=>show(location.hash));addEventListener('scroll',spy,{passive:true});show(location.hash);
143
+ </script></body></html>`);
144
+ console.log(`${out}: ${files.length} chapters`);
@@ -0,0 +1,28 @@
1
+ # Conclusions and recommendation
2
+
3
+ > **Conclusion**: both collections can be integrated, with different approaches.
4
+
5
+ ## At a glance
6
+
7
+ | Collection | Kind | Approach |
8
+ | --- | --- | --- |
9
+ | Wiki A | Mirror plus summary | Register original upstream |
10
+ | Wiki B | Code-curated wiki | Standard production |
11
+
12
+ ```chart
13
+ {"title": "Code check results", "legend": ["consistent", "partial", "inconsistent", "unverifiable"],
14
+ "rows": [{"label": "Wiki A", "values": [7, 0, 2, 1]}, {"label": "Wiki B", "values": [11, 0, 0, 1]}]}
15
+ ```
16
+
17
+ ## Impact on navigation
18
+
19
+ ```tree
20
+ Knowledge base
21
+ ├── Business
22
+ │ └── Billing rules [mod]
23
+ └── Operations
24
+ └── Incident handbook [dir]
25
+ └── Escalation [add]
26
+ ```
27
+
28
+ Evidence lives in `docs/runbooks/billing/escalation-and-on-call-handbook.md`.
@@ -0,0 +1,10 @@
1
+ # Wiki A
2
+
3
+ ## Overview
4
+
5
+ - **Kind**: mirror plus summary
6
+ - **Upstreams**: 79 documents, 15 already registered
7
+
8
+ ```chart
9
+ {"type": "matrix", "title": "Approach scores", "columns": ["Standard", "Upstream", "Unchanged"], "rows": ["Wiki A"], "values": [[4, 5, 2]], "max": 5}
10
+ ```
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "c4a",
3
3
  "displayName": "C4A Context",
4
- "version": "0.7.100",
4
+ "version": "0.7.102",
5
5
  "description": "Start or continue a project-local knowledge workspace through one graph-routed entry.",
6
6
  "author": {
7
7
  "name": "Context4AI",
@@ -69,7 +69,9 @@ Classify a request in this order:
69
69
  A registration or association is an entrance, not evidence: it does not show that
70
70
  the content was read, verified or is usable by the reader. Links from knowledge to
71
71
  imports are navigation; a conclusion that depends on external content requires
72
- capturing that content into `sources`.
72
+ capturing that content into `sources`. Versioned content such as a released
73
+ package, Skill or documentation repository is captured as a `file` source with
74
+ an origin, described in the knowledge-updates guide.
73
75
 
74
76
  For long-term association of external knowledge, Skills or plugins, maintain
75
77
  `imports.yaml` through [imports](../resources/context/imports.md); registration alone does
@@ -135,7 +137,7 @@ without the user's authorization.
135
137
 
136
138
  ### Check the CLI first
137
139
 
138
- This Skill ships with Context 0.7.100.
140
+ This Skill ships with Context 0.7.102.
139
141
 
140
142
  When entering production in a workspace, align the CLI, this Skill and the
141
143
  workspace SDK once per session with [version alignment](../resources/context/version-alignment.md):
@@ -86,7 +86,9 @@ workspace targets or the delivery configuration.
86
86
  For each document, compare its current revision with the captured one when
87
87
  the host exposes a reliable revision; for a Lark document the captured
88
88
  revision is `metadata.source.revisionId` in its snapshot's `manifest.json`.
89
- Otherwise read it and compare content. Changes in cited files and documents
89
+ Otherwise read it and compare content. For a file source with an origin,
90
+ compare the origin's latest available version with its registered
91
+ `origin.version`; a frozen source never changes. Changes in cited files and documents
90
92
  lead to revisions; changes no article cites are assessed in step 7. Ignore
91
93
  generated code, lock files and third-party directories. An unreadable source
92
94
  is a gap, not a change: never retire or take down pages because of it.
@@ -112,8 +114,13 @@ workspace targets or the delivery configuration.
112
114
  source the candidate pages cite, not only this repository: a page that cites
113
115
  a missing source cannot be submitted. `context source recovery-plan --format
114
116
  json` lists them with a fill-in restore input. Re-capture changed documents
115
- through their normal capture Route. Do not start a new batch after the time
116
- budget; finish or checkpoint the current one.
117
+ through their normal capture Route; for a newer origin version, install it
118
+ into a new version directory and move the registration first, as in the
119
+ knowledge-updates guide's versioned external content section. For pages kept
120
+ as written, keep revisions of code contradictions locally, list them in the
121
+ run report, and do not raise again a contradiction the history shows was
122
+ kept unless its cited code changed. Do not
123
+ start a new batch after the time budget; finish or checkpoint the current one.
117
124
  7. **Cover uncited changes.** In the source-update decision, go through
118
125
  `uncited_changes` by directory, new directories first. Skip tests, lock
119
126
  files, generated code and third-party directories, and read the diff only for
@@ -42,7 +42,14 @@ an audience enters production; do not count registration as completed research.
42
42
  knowledge depends on it, which shortens inventory. The `context` Skill carries
43
43
  a template under `references/source-checklist.md`. It is never required —
44
44
  without one, continue and register material from the conversation.
45
- 3. Read [project-planning.md](references/project-planning.md). Review the existing
45
+ 3. Establish the purpose and constraints before deep research, using
46
+ [stakeholder-intake.md](references/stakeholder-intake.md). Read supplied
47
+ meeting notes, proposals and checklists first and ask only what is still
48
+ missing: where existing knowledge lives and who maintains it, where it should
49
+ be maintained afterwards, what must not be rewritten, who uses the result,
50
+ how packages should be split, and structural constraints. Record the answers
51
+ as the evaluation criteria for the research.
52
+ 4. Read [project-planning.md](references/project-planning.md). Review the existing
46
53
  knowledge workspace and relevant approved articles before grouping new material.
47
54
  Map overlaps, gaps and relationships between documents, repositories and pages;
48
55
  distinguish reuse, revision, consolidation and new coverage in the PLAN.
@@ -53,18 +60,29 @@ an audience enters production; do not count registration as completed research.
53
60
  evidence already available; do not wait for a complete PLAN. Follow the early
54
61
  scope rules in project-planning.md, including previously confirmed choices.
55
62
  Reuse accessible local checkouts and saved research before fetching again.
56
- 4. Create or update `PLAN-YYYYMMDD-slug.md` at that project's Git root using
63
+ When the request brings in existing knowledge collections — knowledge or
64
+ wiki repositories, documentation directories, other workspaces or published
65
+ knowledge packages — also follow [knowledge-migration.md](references/knowledge-migration.md):
66
+ identify each collection's kind and real upstreams, audit a bounded sample of
67
+ its claims with [quality-audit.md](references/quality-audit.md), and choose an
68
+ integration approach per collection.
69
+ 5. Create or update `PLAN-YYYYMMDD-slug.md` at that project's Git root using
57
70
  [the report template](templates/PLAN.md). Keep downloaded research under
58
71
  `.tmp/context-plans/YYYYMMDD-slug/`; the layout is a working convention,
59
72
  not a new CLI validation rule.
60
- 5. Present the first report and complete its review before production. By default,
73
+ 6. When stakeholders must choose between approaches, or the research covers
74
+ existing knowledge collections, present a research report before or with the
75
+ first PLAN, following [research-report.md](references/research-report.md):
76
+ conclusions first, then the analysis and evidence. Record each decision made
77
+ during the discussion in the PLAN before asking for approval.
78
+ 7. Present the first report and complete its review before production. By default,
61
79
  obtain the user's approval; only an authorized `plan_review: delegate` override
62
80
  permits Agent review as described below.
63
81
  Resolve the reporting preference: report after all stages, or after each
64
82
  stage; for stage reports, explicitly establish whether to wait for a reply.
65
83
  Preserve already supplied choices. This project approval does not approve
66
84
  candidate articles or grant missing source, Git or publishing permissions.
67
- 5. If the user requested only research or comparison, finish with the report;
85
+ 8. If the user requested only research or comparison, finish with the report;
68
86
  production needs explicit authorization to execute the plan; review delegation
69
87
  alone does not authorize production for a research-only request. After that approval,
70
88
  follow the authorized Git collaboration process. Hand only
@@ -0,0 +1,167 @@
1
+ # Bring existing knowledge collections into a workspace
2
+
3
+ Use when the project covers knowledge that someone already curated: knowledge
4
+ or wiki repositories (including LLM-maintained wikis), documentation
5
+ directories, another Context workspace, or published knowledge packages.
6
+ This is research guidance for the PLAN; registration and production still
7
+ follow the `context` Skill after approval.
8
+
9
+ ## Identify each collection's kind
10
+
11
+ Inspect the structure before reading bodies. Typical kinds and their signals:
12
+
13
+ | Kind | Signals | Where its value is |
14
+ | --- | --- | --- |
15
+ | Mirror plus summary | A raw or mirror directory of copied documents with source metadata (original link, revision), plus a small set of summary pages | The original documents behind it; the summary layer is secondary |
16
+ | Raw archive | Hundreds or thousands of copied documents or code snapshots, a source list, few distilled pages | Coverage of the originals; needs scoping and batches |
17
+ | Code-curated wiki | Pages written from source code, often with evidence tables naming files, symbols and a code revision | The code it cites; the pages show which questions matter |
18
+ | Maintained first-hand wiki | Organized pages, frequent recent commits by a team, often its own skills, checks or evaluations | The pages themselves; the team keeps them current |
19
+ | Published package or skill | A versioned knowledge package or skill from a registry | Its versioned content; follows its publisher's releases |
20
+
21
+ A collection can contain several kinds; classify parts separately when they
22
+ need different treatment. Record commit activity, owners and last update, since
23
+ they decide whether the collection is still maintained.
24
+
25
+ ## Trace the real upstreams
26
+
27
+ For each collection, list the documents, repositories and other sources its
28
+ pages were built from, using source metadata, source lists, frontmatter, links
29
+ and evidence tables. Deduplicate by actual identity and compare with the
30
+ workspace's registered sources. Record how many are already registered, how
31
+ many are new and stable, and how many are research notes, duplicates, archives
32
+ or empty pages. Report unreadable upstreams as access gaps, not as absent.
33
+
34
+ Estimate what is unique to the collection after removing content that the
35
+ existing articles and the traced upstreams already cover: the collection
36
+ author's own judgments, operating procedures, tables or examples that exist
37
+ nowhere else.
38
+
39
+ ## Compare with the existing knowledge
40
+
41
+ Apply the coverage map in [project-planning.md](project-planning.md). For each
42
+ collection also produce:
43
+
44
+ - **Impact on navigation**: a pruned tree of the existing navigation showing
45
+ which existing articles would be revised, which articles would be added and
46
+ which new subsections are needed. Respect structural constraints from the
47
+ intake, such as keeping the top-level sections; place new topics inside the
48
+ existing sections where readers already look for them.
49
+ - **Conflicts**: statements that disagree with existing articles or with code,
50
+ with both sides quoted briefly. Existing articles can be wrong too.
51
+
52
+ ## Choose an integration approach
53
+
54
+ | Approach | What happens | Content rewritten | Errors correctable from code | Original afterwards |
55
+ | --- | --- | --- | --- | --- |
56
+ | Standard production | Produce articles from the collection's own knowledge: register the collection as a document source (a file source keeping its folders, following its repository version as an origin), or the code its evidence cites (a code-curated wiki then guides which questions to answer) | Yes | Yes | Can be archived once the workspace maintains the topic |
57
+ | Register original upstream | Replace a mirror or summary layer with the original documents it copied; keep only the author's unique judgments as notes | Yes, from the originals | Yes | The summary layer can stop being maintained |
58
+ | Keep unchanged | Keep the collection's pages as they are, placed in the existing sections and selected into a package | No | Only flag when cited code changes | Maintained where it is |
59
+ | In-repository knowledge | Leave the collection in its repository for agents working there; not part of the workspace | No | No | Maintained where it is |
60
+ | Mechanical packaging | Package the collection's files unchanged with a script, outside the workspace | No | No | Maintained where it is |
61
+ | External package source | Install a published package or skill at an exact version and register it as a file source with that origin | Yes | Yes, with code sources | Follows the publisher |
62
+
63
+ Choose per collection, or per part of a collection, using the intake answers:
64
+ where the knowledge really comes from, whether its team keeps maintaining it,
65
+ what must stay unchanged, and how much it overlaps existing articles. Score each
66
+ plausible approach for each collection on a 1–5 fit scale against those intake
67
+ criteria (5 fits best), and show feasibility, effort (for example agent days and
68
+ review time) and risk next to the score. Explain the choice together with its
69
+ benefit and its cost. Approaches can be combined, for example registering the
70
+ upstream of a raw archive while keeping a few distilled pages unchanged.
71
+
72
+ Check what the installed Context actually supports before recommending an
73
+ approach. Approaches the installation cannot perform yet are recorded as options
74
+ with their limitation, not presented as ready. In particular:
75
+
76
+ - A repository source currently has one subpath and no exclusion rules, and
77
+ repository sources are processed as code. A repository that contains only
78
+ Markdown does not enter document production when registered as a repository.
79
+ Register it as a file source that keeps its folders, with the repository and
80
+ commit as its origin, so routine updates follow new commits; or register its
81
+ original upstream instead when it mirrors or summarizes other documents.
82
+ - A file source commits its captured snapshot (documents and the images they
83
+ link), so a very large collection grows the workspace repository; select the
84
+ folders articles need with include rules. Installed origin content itself is
85
+ not committed.
86
+ - Package-only content is available: bind the articles under a hidden knowledge
87
+ map category so they stay out of website navigation, select them into their
88
+ package, and link them from an entry article on the main site. Add the paths to
89
+ the website package's `select.exclude` to leave the pages off the website.
90
+ - Keeping pages unchanged goes through production with `preserve_original: true`
91
+ on the requirement: register the collection as a file source that keeps its
92
+ folders (with its repository and commit as origin when it keeps changing), and
93
+ list the code repositories the pages describe in `evidence_source_scope`.
94
+ Writers keep each page's title, sections, order and wording, cite its lines and
95
+ the code it describes, and propose contradictions with the code for review:
96
+ the user accepts them (also proposing the fix upstream), keeps them only
97
+ locally, or keeps the original. Decisions live in the articles and their
98
+ history. Managed and routine runs revise locally. Each
99
+ page still goes through ordinary batches and review; estimate that cost.
100
+
101
+ When the user chooses an approach the installation cannot perform yet, keep the
102
+ choice, mark the affected stage as blocked by that capability, propose an interim
103
+ approach that can run now (for example mechanical packaging outside the workspace),
104
+ and record the capability dependency in the PLAN.
105
+
106
+ ## Scale and stage limits for collections
107
+
108
+ Count documents by their upstream identity: mirrored copies inside a collection
109
+ are the same documents as their originals, not additional sources. Apply the
110
+ planning scope rules to the distinct upstream documents in this task's scope; a
111
+ large mirror can trigger the human scope question, which may be asked early with
112
+ the evidence already available. The one-new-repository-per-stage limit applies to
113
+ code repositories investigated for production; a collection kept unchanged or
114
+ bypassed in favor of its upstream does not count as a new repository.
115
+
116
+ ## Prepare content that is kept unchanged or packaged mechanically
117
+
118
+ Content that will not be rewritten needs a readiness check before it is selected
119
+ into a package: every page reachable from its index, relative links resolving,
120
+ images and attachments actually present (not placeholders or remote-only files),
121
+ no template or placeholder rows in its source lists, and no credentials or private
122
+ data in logs and build files. Report findings to the owning team instead of
123
+ editing their pages.
124
+
125
+ ## Skills and tools inside collections
126
+
127
+ Collections may carry their own skills, agents or scripts. Do not package them as
128
+ knowledge. Recommend publishing them through the host's skill distribution, and
129
+ assess separately any that write data or call production systems.
130
+
131
+ ## Earlier integrations
132
+
133
+ Check whether the workspace already absorbed an earlier version of a collection,
134
+ for example as notes or articles from a previous project. Record what will
135
+ supersede those notes and which articles they support, so earlier material is not
136
+ duplicated or left contradicting the new sources.
137
+
138
+ ## Following an upstream or absorbing once
139
+
140
+ | Mode | What to do | Afterwards |
141
+ | --- | --- | --- |
142
+ | Follow the upstream | Register the collection, its modules or its originals as sources with fixed versions; a versioned collection or package becomes a file source with an origin | Routine updates follow the upstream; the original team keeps maintaining it |
143
+ | Absorb once | Bring the material in one time — original files as a file source keeping its folders, the author's judgments as notes — and produce articles from it; freeze the file source when the original is archived | The original can be archived; maintenance moves to the workspace |
144
+
145
+ Notes carry summaries and supplements: decisions, procedures, comparisons or
146
+ explanations that exist nowhere else. Do not copy whole summary pages into notes
147
+ when their originals can be registered.
148
+
149
+ ## Packages and navigation
150
+
151
+ Navigation and package scope are independent. A package selects approved
152
+ articles by path patterns or explicit lists, so a new package does not need its
153
+ own top-level section. Explicit lists are normal in an existing workspace whose
154
+ paths are organized by article type; path conventions help mainly for new
155
+ subdirectories, where package selection can then follow new articles
156
+ automatically.
157
+
158
+ When the project produces separate packages, list each package's articles
159
+ individually with their navigation location and status (added, revised, kept
160
+ unchanged, unchanged). Include existing unchanged articles from the navigation
161
+ subtrees the package covers and the articles its new or revised articles link to;
162
+ a large unchanged module may be listed as one row with its page count.
163
+ Content that should appear only in a package, not in website navigation, goes
164
+ under a hidden knowledge map category.
165
+
166
+ State the basis of every overlap figure (pages or characters) and use the same
167
+ basis across collections where possible.
@@ -125,6 +125,11 @@ an unrelated source. Keep approved pages, pending drafts, older package output
125
125
  and previous PLAN deliveries distinct; a draft is pending work, not an approved
126
126
  answer or a reason to produce the same page again.
127
127
 
128
+ When the incoming material is an existing knowledge collection (a wiki or
129
+ knowledge repository, documentation directory, another workspace or a published
130
+ package), also identify its kind, real upstreams and quality as described in
131
+ [knowledge-migration.md](knowledge-migration.md) and [quality-audit.md](quality-audit.md).
132
+
128
133
  Record a compact coverage-and-relationship map in the PLAN, grouping related
129
134
  sources where useful. For each proposed topic, identify the existing page or
130
135
  section, the new material, the actual overlap or gap, useful connections and
@@ -0,0 +1,63 @@
1
+ # Audit the accuracy and freshness of existing knowledge
2
+
3
+ Use during research on an existing knowledge collection, and on existing
4
+ workspace articles that the project will revise. The audit gives evidence for
5
+ the integration approach; it does not correct anything during research.
6
+
7
+ ## Sample claims that code can confirm
8
+
9
+ For each collection, pick about ten concrete claims that the pinned code can
10
+ confirm or refute: service or module names, table and field names, interfaces,
11
+ states and transitions, configuration keys, thresholds and time limits, and
12
+ code paths. Spread the sample across the collection's main areas; prefer claims
13
+ readers would act on.
14
+
15
+ Check each claim against code at a fixed revision. Use already registered or
16
+ locally available repositories first; record repositories you could not read
17
+ instead of cloning unrelated ones. Classify each result:
18
+
19
+ | Result | Meaning |
20
+ | --- | --- |
21
+ | Consistent | The code supports the claim |
22
+ | Partly consistent | The core holds but a detail differs or is incomplete |
23
+ | Inconsistent | The code contradicts the claim |
24
+ | Unverifiable | The claim depends on configuration, data or code that was not available |
25
+
26
+ Record for each claim: the statement, where it appears, the code location, the
27
+ result and, for inconsistencies, what the code actually does.
28
+
29
+ ## Check freshness
30
+
31
+ Note how the collection records currency: update dates, verified revisions,
32
+ status labels. Compare them with the upstream's actual changes, for example
33
+ commits to the cited code since the verified revision, or newer document
34
+ revisions. Flag pages that claim to be current but have not been reviewed
35
+ since material changes.
36
+
37
+ ## Classify the problems
38
+
39
+ Group the inconsistencies and stale items into two kinds:
40
+
41
+ - **Written wrong**: inconsistent with code when written — often names, paths,
42
+ formats or omitted branches. Citing specific code lines while writing and
43
+ reviewing exposes these.
44
+ - **Went stale**: correct once, but the code or rules changed and the page did
45
+ not follow. Comparing cited source regions on scheduled updates exposes these.
46
+
47
+ Include problems found in the existing workspace articles too; the comparison
48
+ is about the method, not about whose content is better.
49
+
50
+ ## Decide how much code evidence each collection needs
51
+
52
+ - Mirrors and summaries of documents: regenerate from the originals and code;
53
+ do not cite the summaries as evidence.
54
+ - Code-curated collections: anchor to current code so drift is detected.
55
+ - Maintained first-hand collections with their own checks: code evidence may be
56
+ limited to flagging changes when they are kept unchanged.
57
+
58
+ ## Report
59
+
60
+ Show the totals per collection, a handful of concrete examples with their
61
+ classification and consequence for readers, and which step of the production
62
+ process would catch each kind of problem. State the cost of that process —
63
+ source registration, review and running scheduled updates — next to its benefit.
@@ -0,0 +1,80 @@
1
+ # Write the research report and discuss it
2
+
3
+ Use when stakeholders must choose between approaches or the research covers
4
+ existing knowledge collections. The report is a communication document for
5
+ people; the PLAN remains the working record. Keep both consistent.
6
+
7
+ ## Structure: conclusions first
8
+
9
+ 1. **Conclusions and recommendation**: a one-screen summary of the current
10
+ state, the recommendation per collection and the benefit next to the cost;
11
+ then the reasons, next steps and a short reading guide.
12
+ 2. **Approaches and their trade-offs**: a neutral description of the
13
+ production process and where each candidate approach attaches to it, ending
14
+ with the cross-collection score matrix and each approach's trade-offs.
15
+ 3. **Recommended plan**: target shape including how readers and agents reach
16
+ the packages (installation, query services, repository agent instructions),
17
+ packages, stages, maintenance ownership, a table comparing the current state
18
+ with the recommendation by dimension (coverage, accuracy, freshness,
19
+ maintenance burden, content kept unchanged) together with the cost, decisions
20
+ needed and risks.
21
+ 4. **Impact on the knowledge structure**: an overview tree of navigation
22
+ changes, then per-collection detail. When a constraint or decision changes the
23
+ placement, show the alternatives side by side.
24
+ 5. **Packages and their articles**: each package's articles listed individually
25
+ with navigation location and status.
26
+ 6. **Comparison with existing knowledge**: how each collection is organized,
27
+ overlap, conflicts and upstream registration status.
28
+ 7. **Quality**: audit totals, concrete examples and what would catch them,
29
+ with one example traced over time to show how scheduled source comparison
30
+ would have caught a stale statement.
31
+ 8. **Background**: meeting decisions and action items, proposals, method.
32
+ 9. **Appendices**: one per collection, each opening with a one-picture summary
33
+ (composition, overlap, audit result, approach scores, conclusion).
34
+
35
+ Open each chapter with its own conclusion in one or two sentences.
36
+
37
+ ## Writing rules
38
+
39
+ - Plain language for people new to the subject; define approach names once and
40
+ use them consistently.
41
+ - Objective tone: describe what each collection and team already provides; do
42
+ not present the recommended process as self-evidently superior.
43
+ - Pair every benefit with its execution cost.
44
+ - Name documents by title and repositories by name instead of pasting long
45
+ addresses; long file paths may be shortened in display while keeping the full
46
+ path available to copy.
47
+ - State how numbers were obtained and label estimates.
48
+
49
+ ## Figures
50
+
51
+ Prefer figures over long tables where they help:
52
+
53
+ | Figure | Shows |
54
+ | --- | --- |
55
+ | Collection map | Collections placed by knowledge origin and maintenance activity |
56
+ | Composition | Original copies versus distilled content per collection |
57
+ | Overlap | Share of duplicated, complementary and new content |
58
+ | Upstream registration | Registered versus unregistered upstreams |
59
+ | Audit results | Consistent, partial, inconsistent and unverifiable claims |
60
+ | Approach scores | Each collection scored on each approach, recommendation marked |
61
+ | Production process | Where each approach attaches (as a tree or table) |
62
+ | Navigation impact | Pruned tree marking added, revised, new sections and unchanged content |
63
+
64
+ ## Build and share
65
+
66
+ Write chapters as Markdown files and build a single-page HTML report with
67
+ [the report template](../templates/research-report/README.md): chapter list on the
68
+ left, one chapter at a time in the middle, the chapter's outline on the right.
69
+ Keep chapter sources and figure data under `.tmp/context-plans/<slug>/research/`.
70
+ Share through a channel that keeps the report access-controlled; do not upload
71
+ it to publicly readable storage. Uploading creates an external copy, so confirm
72
+ with the user before publishing it.
73
+
74
+ ## Discuss and record decisions
75
+
76
+ Expect several rounds. After each round, update the report and record each
77
+ decision in the PLAN with its date and who made it; keep open questions visible.
78
+ When an answer is ambiguous, state the interpretation you applied and invite
79
+ correction. A decision on the approach is not approval of the PLAN or of
80
+ production; follow the review policy in the Skill.