@kevin0181/memoc 1.3.0 → 1.4.1

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 (3) hide show
  1. package/README.md +5 -5
  2. package/bin/cli.js +324 -154
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -141,7 +141,7 @@ Run it from the project root. It preserves existing project memory, including:
141
141
  - `.memoc/04-handoff.md`
142
142
  - `.memoc/06-project-rules.md`
143
143
  - Legacy `.memoc/log.md` if present
144
- - `.memoc/systems/`
144
+ - Legacy `.memoc/systems/` if present (moved to `.memoc/raw/legacy-systems/` on upgrade)
145
145
  - `.memoc/wiki/`
146
146
 
147
147
  It refreshes the managed blocks, project-local wrappers, runtime copy, PATH helpers, and memoc-owned protocol templates. User-owned memory files such as `session-summary.md`, `03-decisions.md`, `04-handoff.md`, `06-project-rules.md`, and wiki topic/source pages are preserved. Upgrade also runs the `trim-summary` compaction pass so startup memory stays small. If `memoc` is not on PATH after upgrading, keep using:
@@ -176,10 +176,10 @@ llms.txt ← LLM-facing project map
176
176
  actors/ ← Actor profiles for shared repos
177
177
  worklog/ ← Per-actor work records to reduce conflicts
178
178
  raw/ ← Immutable source material, not a startup read
179
- systems/ Subsystem docs
180
- wiki/ Synthesized knowledge base
179
+ wiki/project/ Project implementation wiki
180
+ wiki/knowledge/ Source-backed knowledge wiki
181
181
 
182
- skills/project-memory-maintainer/SKILL.md ← Wiki & systems operations guide
182
+ skills/project-memory-maintainer/SKILL.md ← Wiki operations guide
183
183
  ```
184
184
 
185
185
  ---
@@ -207,7 +207,7 @@ Every entry file (`CLAUDE.md`, `AGENTS.md`, `.cursorrules`, etc.) gets the same
207
207
  - [ ] Decision made → `03-decisions.md` (what & why) + `02`
208
208
  - [ ] Work incomplete or risky → `04-handoff.md` (verified commands, unverified items, next steps)
209
209
  - [ ] Rule/preference set → `06-project-rules.md`
210
- - [ ] Wiki/systems work → read `skills/project-memory-maintainer/SKILL.md`
210
+ - [ ] Wiki/project-memory work → read `skills/project-memory-maintainer/SKILL.md`
211
211
  - [ ] Shared repo work → prefer `memoc work "<title>" --from-git`; run `memoc activity --write` only when regenerating indexes.
212
212
  - [ ] Keep `session-summary.md` replace-only; completed work belongs in actor worklogs.
213
213
  ```
package/bin/cli.js CHANGED
@@ -246,6 +246,89 @@ function archiveLegacyLog(dir, mark) {
246
246
  mark('move', `${path.relative(dir, logPath)} -> ${path.relative(dir, archivePath)}`);
247
247
  }
248
248
 
249
+ function movePathUnique(srcPath, destPath) {
250
+ const target = uniquePath(destPath);
251
+ fs.mkdirSync(path.dirname(target), { recursive: true });
252
+ fs.renameSync(srcPath, target);
253
+ return target;
254
+ }
255
+
256
+ function archiveLegacySystems(dir, mark) {
257
+ const systemsPath = path.join(dir, '.memoc', 'systems');
258
+ if (!fs.existsSync(systemsPath)) {
259
+ mark('skip', '.memoc/systems (legacy; no dir)');
260
+ return;
261
+ }
262
+ const archivePath = movePathUnique(systemsPath, path.join(dir, '.memoc', 'raw', 'legacy-systems'));
263
+ mark('move', `${path.relative(dir, systemsPath)} -> ${path.relative(dir, archivePath)}`);
264
+ }
265
+
266
+ function migrateKnowledgeWiki(dir, mark) {
267
+ const wikiDir = path.join(dir, '.memoc', 'wiki');
268
+ const knowledgeDir = path.join(wikiDir, 'knowledge');
269
+ const moves = [
270
+ ['sources.md', 'sources.md'],
271
+ ['glossary.md', 'glossary.md'],
272
+ ['questions.md', 'questions.md'],
273
+ ['lint.md', 'lint.md'],
274
+ ['sources', 'sources'],
275
+ ['topics', 'topics'],
276
+ ['global', 'global'],
277
+ ];
278
+ for (const [from, to] of moves) {
279
+ const src = path.join(wikiDir, from);
280
+ const dest = path.join(knowledgeDir, to);
281
+ if (!fs.existsSync(src)) continue;
282
+ if (fs.existsSync(dest)) {
283
+ try {
284
+ const st = fs.statSync(dest);
285
+ if (st.isFile() && isDefaultKnowledgeScaffold(dest)) fs.unlinkSync(dest);
286
+ else continue;
287
+ } catch {
288
+ continue;
289
+ }
290
+ }
291
+ const moved = movePathUnique(src, dest);
292
+ mark('move', `${path.relative(dir, src)} -> ${path.relative(dir, moved)}`);
293
+ }
294
+ }
295
+
296
+ function migrateKnowledgeLayerLinks(filePath) {
297
+ if (!fs.existsSync(filePath)) return false;
298
+ const before = safeRead(filePath);
299
+ if (!before) return false;
300
+
301
+ let after = before;
302
+ const normalized = filePath.replace(/\\/g, '/');
303
+
304
+ if (/\/wiki\/knowledge\/(sources|glossary|questions|lint)\.md$/.test(normalized)) {
305
+ after = after
306
+ .replace(/\]\(index\.md\)/g, '](../index.md)')
307
+ .replace(/\]\(\.\.\/raw\/README\.md\)/g, '](../../raw/README.md)');
308
+ }
309
+
310
+ if (/\/wiki\/knowledge\/global\/README\.md$/.test(normalized)) {
311
+ after = after
312
+ .replace(/\]\(\.\.\/index\.md\)/g, '](../../index.md)')
313
+ .replace(/\]\(\.\.\/\.\.\/00-project-brief\.md\)/g, '](../../../00-project-brief.md)')
314
+ .replace(/\]\(\.\.\/\.\.\/06-project-rules\.md\)/g, '](../../../06-project-rules.md)');
315
+ }
316
+
317
+ if (after === before) return false;
318
+ write(filePath, after);
319
+ return true;
320
+ }
321
+
322
+ function isDefaultKnowledgeScaffold(filePath) {
323
+ const src = safeRead(filePath);
324
+ const name = path.basename(filePath);
325
+ if (name === 'sources.md') return src.includes('# Sources') && src.includes('_No sources recorded yet.');
326
+ if (name === 'glossary.md') return src.includes('# Glossary') && src.includes('_No terms defined yet.');
327
+ if (name === 'questions.md') return src.includes('# Open Questions') && src.includes('_No open questions yet._');
328
+ if (name === 'lint.md') return src.includes('# Wiki Lint') && src.includes('_No issues found._');
329
+ return false;
330
+ }
331
+
249
332
  function summarySectionBulletCounts(src) {
250
333
  const counts = {};
251
334
  let current = '';
@@ -797,7 +880,7 @@ function legacyManagedBlock() {
797
880
  - [ ] Decision made → \`03-decisions.md\` (what & why) + \`02\`
798
881
  - [ ] Work incomplete or risky → \`04-handoff.md\` (verified commands, unverified items, next steps)
799
882
  - [ ] Rule/preference set → \`06-project-rules.md\`
800
- - [ ] Wiki/systems work → read \`skills/project-memory-maintainer/SKILL.md\`
883
+ - [ ] Wiki/project-memory work → read \`skills/project-memory-maintainer/SKILL.md\`
801
884
  ${MGMT_E}`;
802
885
  }
803
886
 
@@ -822,7 +905,7 @@ function managedBlock() {
822
905
  - [ ] Decision made? Update \`03-decisions.md\` + \`02\`
823
906
  - [ ] Work incomplete or risky? Update \`04-handoff.md\`
824
907
  - [ ] Rule/preference set? Update \`06-project-rules.md\`
825
- - [ ] Wiki/systems work? Read \`skills/project-memory-maintainer/SKILL.md\`
908
+ - [ ] Wiki/project-memory work? Read \`skills/project-memory-maintainer/SKILL.md\`
826
909
  - [ ] User asked to update memoc/project memory? Run \`memoc update\`, then update the smallest relevant agent-owned memory files.
827
910
  - [ ] Shared repo work? Prefer \`memoc work "<title>" --from-git\` over appending shared files; run \`memoc activity --write\` only when regenerating indexes.
828
911
  - [ ] Keep \`session-summary.md\` as a replace-only snapshot under 800B; move completed work to actor worklogs and resume risks to \`04-handoff.md\`. If it grew, run \`memoc trim-summary\`.
@@ -860,43 +943,44 @@ function coreLlmsInner() {
860
943
  - [Project Brief](.memoc/00-project-brief.md): short identity and direction.
861
944
  - [Workflow](.memoc/01-agent-workflow.md): update trigger matrix.
862
945
  - [Decisions](.memoc/03-decisions.md): durable decisions.
863
- - [Systems](.memoc/systems/README.md): subsystem docs.
946
+ - [Project Wiki](.memoc/wiki/project/README.md): repo implementation docs.
947
+ - [Knowledge Wiki](.memoc/wiki/knowledge/README.md): external sources, concepts, glossary.
864
948
  - [Activity](.memoc/activity.md): generated worklog index.
865
949
  - [Raw Sources](.memoc/raw/README.md): immutable source material; do not read by default.
866
- - [Wiki](.memoc/wiki/index.md): synthesized knowledge.`;
950
+ - [Wiki](.memoc/wiki/index.md): project/knowledge wiki hub.`;
867
951
  }
868
952
 
869
953
  function headerInner(p) {
870
954
  return `# ${p.name}\n\n> LLM-facing project map for this project.`;
871
955
  }
872
956
 
873
- function systemsLlmsInner(dir) {
874
- const systemsDir = path.join(dir, '.memoc', 'systems');
875
- if (!fs.existsSync(systemsDir)) return '_None yet._';
876
- const files = fs.readdirSync(systemsDir)
957
+ function projectWikiLlmsInner(dir) {
958
+ const projectDir = path.join(dir, '.memoc', 'wiki', 'project');
959
+ if (!fs.existsSync(projectDir)) return '_None yet._';
960
+ const files = fs.readdirSync(projectDir)
877
961
  .filter(f => f.endsWith('.md') && f !== 'README.md')
878
962
  .sort();
879
963
  if (!files.length) return '_None yet._';
880
- return files.map(f => `- [${f.replace('.md', '')}](.memoc/systems/${f}): subsystem context.`).join('\n');
964
+ return files.map(f => `- [${f.replace('.md', '')}](.memoc/wiki/project/${f}): project implementation context.`).join('\n');
881
965
  }
882
966
 
883
967
  function wikiLlmsInner(dir) {
884
968
  const wikiDir = path.join(dir, '.memoc', 'wiki');
885
969
  if (!fs.existsSync(wikiDir)) return '_None yet._';
886
970
  const lines = [];
887
- const SKIP = new Set(['index.md']);
888
971
  try {
889
- for (const f of fs.readdirSync(wikiDir).sort()) {
890
- if (!f.endsWith('.md') || SKIP.has(f)) continue;
891
- try { if (fs.statSync(path.join(wikiDir, f)).isDirectory()) continue; } catch { continue; }
892
- lines.push(`- [${f.replace('.md', '')}](.memoc/wiki/${f}): wiki page.`);
972
+ const knowledgeDir = path.join(wikiDir, 'knowledge');
973
+ for (const f of ['README.md', 'sources.md', 'glossary.md', 'questions.md', 'lint.md']) {
974
+ if (fs.existsSync(path.join(knowledgeDir, f))) {
975
+ lines.push(`- [knowledge/${f.replace('.md', '')}](.memoc/wiki/knowledge/${f}): knowledge wiki page.`);
976
+ }
893
977
  }
894
978
  for (const sub of ['sources', 'topics', 'global']) {
895
- const subDir = path.join(wikiDir, sub);
979
+ const subDir = path.join(knowledgeDir, sub);
896
980
  if (!fs.existsSync(subDir)) continue;
897
981
  for (const f of fs.readdirSync(subDir).sort()) {
898
982
  if (!f.endsWith('.md')) continue;
899
- lines.push(`- [${f.replace('.md', '')}](.memoc/wiki/${sub}/${f}): wiki page.`);
983
+ lines.push(`- [knowledge/${sub}/${f.replace('.md', '')}](.memoc/wiki/knowledge/${sub}/${f}): knowledge wiki page.`);
900
984
  }
901
985
  }
902
986
  } catch {}
@@ -908,41 +992,50 @@ function wikiScaffoldFiles(memDir) {
908
992
  [
909
993
  path.join(memDir, 'wiki/index.md'),
910
994
  tplWikiIndex,
911
- src => src.includes('# Wiki Index') && src.includes('Persistent LLM-maintained project wiki') &&
912
- (src.includes('_None yet._') || !src.includes('## Graph Hubs')),
995
+ src => src.includes('# Wiki Index') && !src.includes('wiki/project'),
996
+ ],
997
+ [
998
+ path.join(memDir, 'wiki/project/README.md'),
999
+ tplWikiProjectReadme,
1000
+ src => hasOnlyScaffold(src, ['# Project Wiki', 'Implementation docs']) && !src.includes('## Related'),
1001
+ ],
1002
+ [
1003
+ path.join(memDir, 'wiki/knowledge/README.md'),
1004
+ tplWikiKnowledgeReadme,
1005
+ src => hasOnlyScaffold(src, ['# Knowledge Wiki', 'Source-backed concepts']) && !src.includes('## Related'),
913
1006
  ],
914
1007
  [
915
- path.join(memDir, 'wiki/sources.md'),
1008
+ path.join(memDir, 'wiki/knowledge/sources.md'),
916
1009
  tplWikiSources,
917
1010
  src => hasOnlyScaffold(src, ['# Sources', '_No sources recorded yet._']) && !src.includes('## Related'),
918
1011
  ],
919
1012
  [
920
- path.join(memDir, 'wiki/glossary.md'),
1013
+ path.join(memDir, 'wiki/knowledge/glossary.md'),
921
1014
  tplWikiGlossary,
922
1015
  src => hasOnlyScaffold(src, ['# Glossary', '_No terms defined yet._']) && !src.includes('## Related'),
923
1016
  ],
924
1017
  [
925
- path.join(memDir, 'wiki/questions.md'),
1018
+ path.join(memDir, 'wiki/knowledge/questions.md'),
926
1019
  tplWikiQuestions,
927
1020
  src => hasOnlyScaffold(src, ['# Open Questions', '_No open questions yet._']) && !src.includes('## Related'),
928
1021
  ],
929
1022
  [
930
- path.join(memDir, 'wiki/lint.md'),
1023
+ path.join(memDir, 'wiki/knowledge/lint.md'),
931
1024
  tplWikiLint,
932
1025
  src => src.includes('# Wiki Lint') && src.includes('_No issues found._') && !src.includes('## Graph Checks'),
933
1026
  ],
934
1027
  [
935
- path.join(memDir, 'wiki/sources/README.md'),
1028
+ path.join(memDir, 'wiki/knowledge/sources/README.md'),
936
1029
  tplWikiSourcesReadme,
937
1030
  src => hasOnlyScaffold(src, ['# Sources', 'Provenance records']) && !src.includes('## Related'),
938
1031
  ],
939
1032
  [
940
- path.join(memDir, 'wiki/topics/README.md'),
1033
+ path.join(memDir, 'wiki/knowledge/topics/README.md'),
941
1034
  tplWikiTopicsReadme,
942
1035
  src => hasOnlyScaffold(src, ['# Topics', 'Synthesized topic pages']) && !src.includes('## Related'),
943
1036
  ],
944
1037
  [
945
- path.join(memDir, 'wiki/global/README.md'),
1038
+ path.join(memDir, 'wiki/knowledge/global/README.md'),
946
1039
  tplWikiGlobalReadme,
947
1040
  src => hasOnlyScaffold(src, ['# Global', 'Project-wide principles']) && !src.includes('## Related'),
948
1041
  ],
@@ -1011,7 +1104,31 @@ function obsidianFrontmatterSpec(relPath) {
1011
1104
  type = 'wiki';
1012
1105
  extra.confidence = 'medium';
1013
1106
  tags.push('memoc/wiki');
1014
- if (rel.startsWith('.memoc/wiki/sources/')) {
1107
+ if (rel.startsWith('.memoc/wiki/project/')) {
1108
+ tags.push('memoc/project-wiki');
1109
+ if (rel.endsWith('/README.md')) tags.push('memoc/project-index');
1110
+ else tags.push('memoc/project-doc');
1111
+ } else if (rel.startsWith('.memoc/wiki/knowledge/')) {
1112
+ tags.push('memoc/knowledge-wiki');
1113
+ if (rel.startsWith('.memoc/wiki/knowledge/sources/')) {
1114
+ tags.push('memoc/source');
1115
+ extra.status = 'needs-synthesis';
1116
+ } else if (rel.startsWith('.memoc/wiki/knowledge/topics/')) {
1117
+ tags.push('memoc/topic');
1118
+ } else if (rel.startsWith('.memoc/wiki/knowledge/global/')) {
1119
+ tags.push('memoc/global');
1120
+ } else if (rel.endsWith('/sources.md')) {
1121
+ tags.push('memoc/source');
1122
+ } else if (rel.endsWith('/glossary.md')) {
1123
+ tags.push('memoc/glossary');
1124
+ } else if (rel.endsWith('/questions.md')) {
1125
+ tags.push('memoc/question');
1126
+ extra.status = 'needs-review';
1127
+ } else if (rel.endsWith('/lint.md')) {
1128
+ tags.push('memoc/lint');
1129
+ extra.status = 'generated';
1130
+ }
1131
+ } else if (rel.startsWith('.memoc/wiki/sources/')) {
1015
1132
  tags.push('memoc/source');
1016
1133
  extra.status = 'needs-synthesis';
1017
1134
  } else if (rel.startsWith('.memoc/wiki/topics/')) {
@@ -1215,13 +1332,13 @@ ${CORE_S}
1215
1332
  ${coreLlmsInner()}
1216
1333
  ${CORE_E}
1217
1334
 
1218
- ## Systems
1335
+ ## Project Wiki
1219
1336
 
1220
1337
  ${SYS_S}
1221
1338
  _None yet._
1222
1339
  ${SYS_E}
1223
1340
 
1224
- ## Wiki
1341
+ ## Knowledge Wiki
1225
1342
 
1226
1343
  ${WIKI_S}
1227
1344
  _None yet._
@@ -1257,7 +1374,7 @@ _Not set yet._
1257
1374
  ## How To Approach
1258
1375
 
1259
1376
  - Start from \`session-summary.md\`; search before opening more files.
1260
- - Open status, handoff, rules, map, systems, or wiki docs only when the task needs them.
1377
+ - Open status, handoff, rules, map, project wiki, or knowledge wiki only when the task needs them.
1261
1378
  - After durable work, update the smallest relevant memory set.
1262
1379
  - Do not treat generated output folders as source unless the user explicitly asks.
1263
1380
 
@@ -1304,20 +1421,19 @@ ${SNAP_E}
1304
1421
  - [Actors](actors/README.md)
1305
1422
  - [Worklog](worklog/README.md)
1306
1423
  - [Wiki Index](wiki/index.md)
1424
+ - [Project Wiki](wiki/project/README.md)
1425
+ - [Knowledge Wiki](wiki/knowledge/README.md)
1307
1426
  - [Raw Sources](raw/README.md)
1308
- - [Systems Index](systems/README.md)
1309
-
1310
- ## System Docs
1311
-
1312
- _None yet. Add entries when subsystems are documented._
1313
1427
 
1314
1428
  ## Wiki
1315
1429
 
1316
- - [Wiki Index](wiki/index.md) — hub for every synthesized wiki page.
1317
- - [Sources](wiki/sources.md) — source provenance and ingest notes.
1318
- - [Glossary](wiki/glossary.md) — project terms and aliases.
1319
- - [Open Questions](wiki/questions.md) — unresolved knowledge gaps.
1320
- - [Wiki Lint](wiki/lint.md) — orphan, stale, and contradiction checks.
1430
+ - [Wiki Index](wiki/index.md) — hub for project and knowledge wikis.
1431
+ - [Project Wiki](wiki/project/README.md) — implementation docs for this repo.
1432
+ - [Knowledge Wiki](wiki/knowledge/README.md) — source-backed concepts and external knowledge.
1433
+ - [Sources](wiki/knowledge/sources.md) — source provenance and ingest notes.
1434
+ - [Glossary](wiki/knowledge/glossary.md) — terms and aliases.
1435
+ - [Open Questions](wiki/knowledge/questions.md) — unresolved knowledge gaps.
1436
+ - [Wiki Lint](wiki/knowledge/lint.md) — orphan, stale, and contradiction checks.
1321
1437
  `;
1322
1438
  }
1323
1439
 
@@ -1400,8 +1516,8 @@ On-demand reference only. The entry-file managed block is authoritative.
1400
1516
  | \`.memoc/05-done-checklist.md\` | Before finishing substantial work |
1401
1517
  | \`.memoc/03-decisions.md\` | When a durable decision was made |
1402
1518
  | \`.memoc/memoc-usage.md\` | For command details |
1403
- | \`.memoc/systems/*.md\` | Before touching a specific subsystem |
1404
- | \`.memoc/wiki/*.md\` | For synthesized project knowledge |
1519
+ | \`.memoc/wiki/project/*.md\` | Before touching a specific subsystem |
1520
+ | \`.memoc/wiki/knowledge/*.md\` | For source-backed concepts and external knowledge |
1405
1521
  | \`llms.txt\` | For full project file map |
1406
1522
 
1407
1523
  ## Search First
@@ -1432,12 +1548,12 @@ Shared protocol for any coding agent.
1432
1548
  | --- | --- |
1433
1549
  | User asks "update memoc", "refresh project memory", or similar | Run \`memoc update\` first, then update relevant agent-owned memory files |
1434
1550
  | User creates or changes a requirement | \`02-current-project-state.md\`, \`06-project-rules.md\`, \`memoc work "<title>" --from-git\` |
1435
- | Code, config, data, or assets changed | \`02-current-project-state.md\`, relevant \`systems/*.md\`, \`memoc work "<title>" --from-git\` |
1436
- | Architecture or system behavior changed | relevant \`systems/*.md\`, \`03-decisions.md\` |
1551
+ | Code, config, data, or assets changed | \`02-current-project-state.md\`, relevant \`wiki/project/*.md\`, \`memoc work "<title>" --from-git\` |
1552
+ | Architecture or system behavior changed | relevant \`wiki/project/*.md\`, \`03-decisions.md\` |
1437
1553
  | A decision should affect future agents | \`03-decisions.md\`, \`02-current-project-state.md\` |
1438
1554
  | Work is substantial enough to resume later | \`04-handoff.md\`, \`02-current-project-state.md\`, \`memoc work "<title>" --from-git\` |
1439
- | Durable knowledge was learned | \`wiki/*.md\`, \`wiki/index.md\` |
1440
- | Source material should feed the wiki | \`memoc ingest <path-or-url>\`, then synthesize affected \`wiki/topics/*.md\` |
1555
+ | Durable project implementation knowledge was learned | \`wiki/project/*.md\`, \`wiki/index.md\` |
1556
+ | Source material should feed the wiki | \`memoc ingest <path-or-url>\`, then synthesize affected \`wiki/knowledge/topics/*.md\` |
1441
1557
  | A useful query answer should persist | \`memoc note "<title>"\`, then link related sources/topics |
1442
1558
  | Shared repo work should be traceable | \`memoc work "<title>"\`; avoid appending long details to shared core files |
1443
1559
  | \`session-summary.md\` exceeds 800B or starts accumulating history | Run \`memoc trim-summary\`; move completed history to worklog, resume details to \`04-handoff.md\` |
@@ -1456,7 +1572,8 @@ Shared protocol for any coding agent.
1456
1572
  - \`04-handoff.md\`: resume context, blockers, verified/unverified checks.
1457
1573
  - \`03-decisions.md\`: append durable decisions only.
1458
1574
  - \`worklog/<actor>/YYYY-MM/*.md\`: actor-scoped append-by-new-file activity records for shared repos.
1459
- - \`systems/*.md\` and \`wiki/*.md\`: on-demand durable knowledge.
1575
+ - \`wiki/project/*.md\`: repo implementation docs.
1576
+ - \`wiki/knowledge/*.md\`: source-backed concepts, provenance, glossary, questions.
1460
1577
  `;
1461
1578
  }
1462
1579
 
@@ -1528,7 +1645,7 @@ Run through this before saying substantial work is complete.
1528
1645
  - [ ] \`.memoc/03-decisions.md\` updated if a durable decision was made.
1529
1646
  - [ ] \`.memoc/04-handoff.md\` updated if work is incomplete or risky.
1530
1647
  - [ ] Meaningful shared work has a \`.memoc/worklog/<actor>/YYYY-MM/*.md\` entry.
1531
- - [ ] Relevant \`.memoc/systems/*.md\` or wiki pages updated.
1648
+ - [ ] Relevant \`.memoc/wiki/project/*.md\` or \`.memoc/wiki/knowledge/*.md\` pages updated.
1532
1649
 
1533
1650
  ## Communication
1534
1651
 
@@ -1715,23 +1832,25 @@ Use \`memoc update\` or \`skills/project-memory-maintainer/SKILL.md\` when:
1715
1832
  - Architecture, data flow, routing, auth, or deployment behavior changed.
1716
1833
  - A decision was made that future agents should not revisit blindly.
1717
1834
  - Work is partial, multi-step, blocked, or likely to be resumed by another agent.
1718
- - New durable knowledge belongs in \`.memoc/wiki/\` or a subsystem doc.
1835
+ - New implementation knowledge belongs in \`.memoc/wiki/project/\`.
1836
+ - Source-backed concept knowledge belongs in \`.memoc/wiki/knowledge/\`.
1719
1837
  - Shared work should be traceable without causing conflicts.
1720
1838
 
1721
1839
  Usually skip for pure Q&A, throwaway exploration, or tiny edits with no future impact.
1722
1840
 
1723
- When the user asks for a general memoc/project-memory refresh, run \`memoc update\` first. It refreshes managed sections, reconnects default wiki scaffold links, and applies Obsidian frontmatter tags. Then update only the agent-owned files whose content actually changed, such as \`.memoc/session-summary.md\`, \`.memoc/02-current-project-state.md\`, \`.memoc/04-handoff.md\`, \`.memoc/wiki/index.md\`, or actor worklogs.
1841
+ When the user asks for a general memoc/project-memory refresh, run \`memoc update\` first. It refreshes managed sections, reconnects default wiki scaffold links, and applies Obsidian frontmatter tags. Then update only the agent-owned files whose content actually changed, such as \`.memoc/session-summary.md\`, \`.memoc/02-current-project-state.md\`, \`.memoc/04-handoff.md\`, \`.memoc/wiki/index.md\`, project/knowledge wiki pages, or actor worklogs.
1724
1842
 
1725
1843
  \`.memoc/session-summary.md\` is a startup snapshot, not a timeline. Rewrite it in place, do not append old work. If it exceeds 800B, run \`memoc trim-summary\`; it archives the previous summary and rewrites a compact version. Put completed history in actor worklogs, and put unfinished/risky resume detail in \`.memoc/04-handoff.md\`.
1726
1844
 
1727
1845
  ## Updating The Wiki
1728
1846
 
1729
- Create a new Markdown file under \`.memoc/wiki/\` when synthesized knowledge should compound across sessions.
1847
+ Create wiki pages under the right layer when knowledge should compound across sessions.
1730
1848
 
1731
1849
  - \`.memoc/raw/\`: immutable source material copied or referenced by \`memoc ingest\`.
1732
- - \`.memoc/wiki/sources/\`: provenance records.
1733
- - \`.memoc/wiki/topics/\`: synthesized topic pages.
1734
- - \`.memoc/wiki/global/\`: project-wide principles.
1850
+ - \`.memoc/wiki/project/\`: implementation docs for this repo.
1851
+ - \`.memoc/wiki/knowledge/sources/\`: provenance records.
1852
+ - \`.memoc/wiki/knowledge/topics/\`: synthesized topic pages.
1853
+ - \`.memoc/wiki/knowledge/global/\`: broader source-backed principles.
1735
1854
 
1736
1855
  After creating or editing wiki pages:
1737
1856
  1. Update \`.memoc/wiki/index.md\`.
@@ -1749,7 +1868,7 @@ memoc lint-wiki
1749
1868
 
1750
1869
  ## Updating System Docs
1751
1870
 
1752
- Create or update \`.memoc/systems/*.md\` when a subsystem needs durable detail.
1871
+ Create or update \`.memoc/wiki/project/*.md\` when a subsystem needs durable implementation detail.
1753
1872
 
1754
1873
  Examples: \`frontend.md\`, \`deployment.md\`, \`data-sources.md\`, \`auth.md\`
1755
1874
  `;
@@ -1758,19 +1877,11 @@ Examples: \`frontend.md\`, \`deployment.md\`, \`data-sources.md\`, \`auth.md\`
1758
1877
  function tplSystemsReadme() {
1759
1878
  return `# Systems
1760
1879
 
1761
- Subsystem documentation for agents.
1762
-
1763
- ## How To Use
1880
+ Legacy location. Project implementation docs now live in [Project Wiki](../wiki/project/README.md).
1764
1881
 
1765
- Create a new \`.md\` file here when a subsystem becomes important enough that future agents should not rediscover it from scratch.
1882
+ ## Migration
1766
1883
 
1767
- ## Examples
1768
-
1769
- - \`frontend.md\` — component library, routing, state management
1770
- - \`deployment.md\` — CI/CD, environment setup, release process
1771
- - \`data-sources.md\` — databases, APIs, file sources
1772
- - \`auth.md\` — authentication and authorization
1773
- - \`design-system.md\` — colors, typography, spacing
1884
+ Run \`memoc update\` to move an existing \`.memoc/systems/\` directory into \`.memoc/raw/legacy-systems/\`.
1774
1885
  `;
1775
1886
  }
1776
1887
 
@@ -1783,7 +1894,7 @@ Immutable source material for the memoc wiki.
1783
1894
 
1784
1895
  - Do not edit raw files after ingest; create a new raw file or source record when material changes.
1785
1896
  - Do not read raw files at session start. Search or open the linked source/topic page first.
1786
- - Source records under [wiki/sources](../wiki/sources/README.md) summarize raw material and link to affected topics.
1897
+ - Source records under [knowledge/sources](../wiki/knowledge/sources/README.md) summarize raw material and link to affected topics.
1787
1898
 
1788
1899
  ## Subdirectories
1789
1900
 
@@ -1802,7 +1913,7 @@ Local files copied by \`memoc ingest <path>\`.
1802
1913
  ## Related
1803
1914
 
1804
1915
  - [Raw Sources](../README.md)
1805
- - [Source Records](../../wiki/sources/README.md)
1916
+ - [Source Records](../../wiki/knowledge/sources/README.md)
1806
1917
  `;
1807
1918
  }
1808
1919
 
@@ -1814,7 +1925,7 @@ URL references recorded by \`memoc ingest <url>\`.
1814
1925
  ## Related
1815
1926
 
1816
1927
  - [Raw Sources](../README.md)
1817
- - [Source Records](../../wiki/sources/README.md)
1928
+ - [Source Records](../../wiki/knowledge/sources/README.md)
1818
1929
  `;
1819
1930
  }
1820
1931
 
@@ -1826,7 +1937,7 @@ Conversation excerpts that should feed durable wiki synthesis.
1826
1937
  ## Related
1827
1938
 
1828
1939
  - [Raw Sources](../README.md)
1829
- - [Source Records](../../wiki/sources/README.md)
1940
+ - [Source Records](../../wiki/knowledge/sources/README.md)
1830
1941
  `;
1831
1942
  }
1832
1943
 
@@ -1838,38 +1949,28 @@ Long-form docs, specs, and references kept separate from synthesized topic pages
1838
1949
  ## Related
1839
1950
 
1840
1951
  - [Raw Sources](../README.md)
1841
- - [Source Records](../../wiki/sources/README.md)
1952
+ - [Source Records](../../wiki/knowledge/sources/README.md)
1842
1953
  `;
1843
1954
  }
1844
1955
 
1845
1956
  function tplWikiIndex() {
1846
1957
  return `# Wiki Index
1847
1958
 
1848
- Persistent LLM-maintained project wiki.
1959
+ Persistent LLM-maintained wiki hub.
1849
1960
 
1850
- ## Graph Hubs
1961
+ ## Wiki Layers
1851
1962
 
1963
+ - [Project Wiki](project/README.md) — this repo's implementation docs.
1964
+ - [Knowledge Wiki](knowledge/README.md) — source-backed concepts, external docs, glossary, questions.
1852
1965
  - [Raw Sources](../raw/README.md) — immutable source material before synthesis.
1853
- - [Sources](sources.md) — provenance, ingests, and source-to-topic links.
1854
- - [Topics](topics/README.md) — synthesized topic pages.
1855
- - [Global](global/README.md) — project-wide principles and long-lived direction.
1856
- - [Glossary](glossary.md) — terms, aliases, and canonical page names.
1857
- - [Open Questions](questions.md) — unresolved questions and research leads.
1858
- - [Wiki Lint](lint.md) — graph health, orphan checks, contradictions, stale claims.
1859
-
1860
- ## Pages
1861
-
1862
- _None yet. Add every wiki page here with a relative Markdown link and one-line summary._
1863
1966
 
1864
- ## Saved Queries
1967
+ ## Project Pages
1865
1968
 
1866
- _None yet. Use \`memoc note "<title>"\` for durable analysis or query results that should become a topic._
1969
+ _None yet. Link implementation pages from [project/README.md](project/README.md)._
1867
1970
 
1868
- ## Subdirectories
1971
+ ## Knowledge Pages
1869
1972
 
1870
- - [sources/](sources/README.md) provenance records
1871
- - [topics/](topics/README.md) — synthesized topic pages
1872
- - [global/](global/README.md) — project-wide principles
1973
+ _None yet. Use \`memoc ingest\` or \`memoc note "<title>"\` to create source-backed knowledge pages._
1873
1974
 
1874
1975
  ## Related Core Memory
1875
1976
 
@@ -1879,6 +1980,52 @@ _None yet. Use \`memoc note "<title>"\` for durable analysis or query results th
1879
1980
  `;
1880
1981
  }
1881
1982
 
1983
+ function tplWikiProjectReadme() {
1984
+ return `# Project Wiki
1985
+
1986
+ Implementation docs for this repository.
1987
+
1988
+ ## Project Pages
1989
+
1990
+ _None yet. Add pages like \`architecture.md\`, \`auth.md\`, \`gateway.md\`, \`deployment.md\`, or \`ui-dashboard.md\`._
1991
+
1992
+ ## How To Use
1993
+
1994
+ - Read project pages before editing the matching subsystem.
1995
+ - Keep pages implementation-specific: files, flows, invariants, commands, risks.
1996
+ - Link to [Knowledge Wiki](../knowledge/README.md) when external concepts or sources matter.
1997
+
1998
+ ## Related
1999
+
2000
+ - [Wiki Index](../index.md)
2001
+ - [Current Project State](../../02-current-project-state.md)
2002
+ - [Decisions](../../03-decisions.md)
2003
+ - [Knowledge Wiki](../knowledge/README.md)
2004
+ `;
2005
+ }
2006
+
2007
+ function tplWikiKnowledgeReadme() {
2008
+ return `# Knowledge Wiki
2009
+
2010
+ Source-backed concepts, external docs, glossary, questions, and durable research.
2011
+
2012
+ ## Hubs
2013
+
2014
+ - [Sources](sources.md) — provenance, ingests, and source-to-topic links.
2015
+ - [Topics](topics/README.md) — synthesized topic pages.
2016
+ - [Global](global/README.md) — broad source-backed principles.
2017
+ - [Glossary](glossary.md) — terms, aliases, and canonical page names.
2018
+ - [Open Questions](questions.md) — unresolved questions and research leads.
2019
+ - [Wiki Lint](lint.md) — graph health, orphan checks, contradictions, stale claims.
2020
+
2021
+ ## Related
2022
+
2023
+ - [Wiki Index](../index.md)
2024
+ - [Project Wiki](../project/README.md)
2025
+ - [Raw Sources](../../raw/README.md)
2026
+ `;
2027
+ }
2028
+
1882
2029
  function tplWikiSources() {
1883
2030
  return `# Sources
1884
2031
 
@@ -1886,14 +2033,15 @@ Provenance index for conversations, URLs, docs, issues, and files that feed the
1886
2033
 
1887
2034
  ## Source Records
1888
2035
 
1889
- _No sources recorded yet. Link each source record to the topic/global pages it affects._
2036
+ _No sources recorded yet. Link each source record to the topic/global/project pages it affects._
1890
2037
 
1891
2038
  Use \`memoc ingest <path-or-url>\` to create source records without loading raw material into startup context.
1892
2039
 
1893
2040
  ## Related
1894
2041
 
1895
- - [Wiki Index](index.md)
1896
- - [Raw Sources](../raw/README.md)
2042
+ - [Wiki Index](../index.md)
2043
+ - [Knowledge Wiki](README.md)
2044
+ - [Raw Sources](../../raw/README.md)
1897
2045
  - [Source Records Directory](sources/README.md)
1898
2046
  - [Topics](topics/README.md)
1899
2047
  - [Open Questions](questions.md)
@@ -1907,11 +2055,11 @@ Canonical names, aliases, and short definitions for project terms.
1907
2055
 
1908
2056
  ## Terms
1909
2057
 
1910
- _No terms defined yet. Link terms to their canonical topic, global, source, or system page._
2058
+ _No terms defined yet. Link terms to their canonical topic, global, source, or project page._
1911
2059
 
1912
2060
  ## Related
1913
2061
 
1914
- - [Wiki Index](index.md)
2062
+ - [Knowledge Wiki](README.md)
1915
2063
  - [Topics](topics/README.md)
1916
2064
  - [Global](global/README.md)
1917
2065
  - [Open Questions](questions.md)
@@ -1929,7 +2077,7 @@ _No open questions yet. Link each question to affected pages and sources._
1929
2077
 
1930
2078
  ## Related
1931
2079
 
1932
- - [Wiki Index](index.md)
2080
+ - [Knowledge Wiki](README.md)
1933
2081
  - [Sources](sources.md)
1934
2082
  - [Topics](topics/README.md)
1935
2083
  - [Wiki Lint](lint.md)
@@ -1943,14 +2091,14 @@ Provenance records for conversations, URLs, docs, and issues.
1943
2091
 
1944
2092
  ## How To Link
1945
2093
 
1946
- - Keep source pages short: summary, raw location, affected pages, open synthesis work.
2094
+ - Keep source pages short: summary, raw location, affected project/knowledge pages, open synthesis work.
1947
2095
  - Link each source record back to [Sources](../sources.md).
1948
- - Link outward to every topic, global page, system doc, or question that the source changes.
2096
+ - Link outward to every topic, global page, project wiki page, or question that the source changes.
1949
2097
  - Prefer one source per file when the source is substantial enough to cite later.
1950
2098
 
1951
2099
  ## Related
1952
2100
 
1953
- - [Wiki Index](../index.md)
2101
+ - [Knowledge Wiki](../README.md)
1954
2102
  - [Sources](../sources.md)
1955
2103
  - [Topics](../topics/README.md)
1956
2104
  - [Open Questions](../questions.md)
@@ -1968,13 +2116,13 @@ _None yet. Add pages here when a concept deserves durable synthesis._
1968
2116
 
1969
2117
  ## How To Link
1970
2118
 
1971
- - Each topic page should link back to [Wiki Index](../index.md) and this [Topics](README.md) page.
2119
+ - Each topic page should link back to [Knowledge Wiki](../README.md) and this [Topics](README.md) page.
1972
2120
  - Link to related topics, source records, glossary terms, and open questions in prose or a \`## Related\` section.
1973
2121
  - Avoid orphan pages: every topic needs at least one inbound link from an index, source, or related topic.
1974
2122
 
1975
2123
  ## Related
1976
2124
 
1977
- - [Wiki Index](../index.md)
2125
+ - [Knowledge Wiki](../README.md)
1978
2126
  - [Sources](../sources.md)
1979
2127
  - [Glossary](../glossary.md)
1980
2128
  - [Wiki Lint](../lint.md)
@@ -1988,18 +2136,18 @@ Project-wide principles, positioning, and long-lived direction.
1988
2136
 
1989
2137
  ## Global Pages
1990
2138
 
1991
- _None yet. Add pages here for broad context that many topic/system pages should reference._
2139
+ _None yet. Add pages here for broad source-backed context that many topic/project pages should reference._
1992
2140
 
1993
2141
  ## How To Link
1994
2142
 
1995
- - Link global pages back to [Wiki Index](../index.md), this [Global](README.md) page, and affected topic/system docs.
2143
+ - Link global pages back to [Knowledge Wiki](../README.md), this [Global](README.md) page, and affected topic/project docs.
1996
2144
  - Use global pages for durable synthesis, not temporary task notes.
1997
2145
 
1998
2146
  ## Related
1999
2147
 
2000
- - [Wiki Index](../index.md)
2001
- - [Project Brief](../../00-project-brief.md)
2002
- - [Project Rules](../../06-project-rules.md)
2148
+ - [Knowledge Wiki](../README.md)
2149
+ - [Project Brief](../../../00-project-brief.md)
2150
+ - [Project Rules](../../../06-project-rules.md)
2003
2151
  - [Topics](../topics/README.md)
2004
2152
  `;
2005
2153
  }
@@ -2010,8 +2158,8 @@ Last checked: ${nowISO()}
2010
2158
 
2011
2159
  ## Graph Checks
2012
2160
 
2013
- - Every wiki page is listed from [Wiki Index](index.md) or a directory README.
2014
- - Every wiki page links back to an index, hub, source, topic, or related page.
2161
+ - Every wiki page is listed from [Wiki Index](../index.md) or a directory README.
2162
+ - Every wiki page links back to an index, project hub, knowledge hub, source, topic, or related page.
2015
2163
  - Important concepts mentioned in two or more places have their own linked page.
2016
2164
  - Source records link to the pages they update, and those pages link back to sources when provenance matters.
2017
2165
 
@@ -2025,7 +2173,7 @@ _None._
2025
2173
 
2026
2174
  ## Related
2027
2175
 
2028
- - [Wiki Index](index.md)
2176
+ - [Knowledge Wiki](README.md)
2029
2177
  - [Sources](sources.md)
2030
2178
  - [Topics](topics/README.md)
2031
2179
  - [Open Questions](questions.md)
@@ -2060,11 +2208,11 @@ Use this local skill after meaningful project work so future agents can continue
2060
2208
  - Check \`.memoc/05-done-checklist.md\` before saying substantial work is complete.
2061
2209
  - Update \`.memoc/06-project-rules.md\` when the user gives durable preferences.
2062
2210
  - Create a short actor worklog with \`memoc work "<title>" --from-git\` for meaningful changes, decisions, and handoffs.
2063
- - Create or update \`.memoc/systems/*.md\` when a subsystem needs durable explanation.
2064
- - Create or update \`.memoc/wiki/*.md\` when synthesized knowledge should compound over time.
2211
+ - Create or update \`.memoc/wiki/project/*.md\` when a subsystem needs durable implementation explanation.
2212
+ - Create or update \`.memoc/wiki/knowledge/*.md\` when source-backed concepts should compound over time.
2065
2213
  - Use \`memoc ingest <path-or-url>\` for source material and \`memoc note "<title>"\` for durable query results or analysis.
2066
2214
  - Use \`memoc work "<title>" --from-git\` for meaningful shared-repo work so details are saved in actor-scoped worklog files instead of causing shared-file conflicts.
2067
- - Keep the wiki graph connected: update \`.memoc/wiki/index.md\`, add relative Markdown links between related pages, and include a \`## Related\` section on every new wiki page.
2215
+ - Keep the wiki graph connected: update \`.memoc/wiki/index.md\`, link project pages under \`.memoc/wiki/project/\`, link knowledge pages under \`.memoc/wiki/knowledge/\`, and include a \`## Related\` section on every new wiki page.
2068
2216
  - Run \`memoc lint-wiki\` after wiki/source/topic edits and address broken links before finishing.
2069
2217
  - Keep completed history in actor worklogs; keep current-state files short.
2070
2218
  - Move completed session details out of \`session-summary.md\` into \`.memoc/worklog/<actor>/YYYY-MM/\`; move incomplete/risky resume details into \`04-handoff.md\`.
@@ -2073,12 +2221,12 @@ Use this local skill after meaningful project work so future agents can continue
2073
2221
 
2074
2222
  ## Wiki Link Rules
2075
2223
 
2076
- - Use relative Markdown links that Obsidian can follow, for example \`[Glossary](glossary.md)\` or \`[Topics](topics/README.md)\`.
2077
- - Every wiki page must have at least one inbound link from \`wiki/index.md\`, a directory README, a source page, or a related topic.
2224
+ - Use relative Markdown links that Obsidian can follow, for example \`[Project Wiki](project/README.md)\` or \`[Topics](knowledge/topics/README.md)\`.
2225
+ - Every wiki page must have at least one inbound link from \`wiki/index.md\`, a directory README, a source page, project page, or related topic.
2078
2226
  - Every wiki page must link outward to its parent hub plus 1-5 genuinely related pages when they exist.
2079
2227
  - Prefer links in normal prose when the connection is meaningful; use \`## Related\` for compact navigation.
2080
2228
  - When a concept appears in multiple pages, create or update a topic/glossary page and link all mentions to it.
2081
- - After wiki edits, check \`.memoc/wiki/lint.md\` and note orphan pages, missing backlinks, contradictions, or stale claims.
2229
+ - After wiki edits, check \`.memoc/wiki/knowledge/lint.md\` and note orphan pages, missing backlinks, contradictions, or stale claims.
2082
2230
 
2083
2231
  ## Concrete Triggers
2084
2232
 
@@ -2265,20 +2413,21 @@ function run(dir, forceUpdate, action = 'update') {
2265
2413
  [path.join(memDir, 'actors/README.md'), tplActorsReadme],
2266
2414
  [path.join(memDir, 'worklog/README.md'), tplWorklogReadme],
2267
2415
  [path.join(memDir, 'memoc-usage.md'), tplMemocUsage],
2268
- [path.join(memDir, 'systems/README.md'), tplSystemsReadme],
2269
2416
  [path.join(memDir, 'raw/README.md'), tplRawReadme],
2270
2417
  [path.join(memDir, 'raw/files/README.md'), tplRawFilesReadme],
2271
2418
  [path.join(memDir, 'raw/urls/README.md'), tplRawUrlsReadme],
2272
2419
  [path.join(memDir, 'raw/conversations/README.md'), tplRawConversationsReadme],
2273
2420
  [path.join(memDir, 'raw/docs/README.md'), tplRawDocsReadme],
2274
2421
  [path.join(memDir, 'wiki/index.md'), tplWikiIndex],
2275
- [path.join(memDir, 'wiki/sources.md'), tplWikiSources],
2276
- [path.join(memDir, 'wiki/glossary.md'), tplWikiGlossary],
2277
- [path.join(memDir, 'wiki/questions.md'), tplWikiQuestions],
2278
- [path.join(memDir, 'wiki/lint.md'), tplWikiLint],
2279
- [path.join(memDir, 'wiki/sources/README.md'), tplWikiSourcesReadme],
2280
- [path.join(memDir, 'wiki/topics/README.md'), tplWikiTopicsReadme],
2281
- [path.join(memDir, 'wiki/global/README.md'), tplWikiGlobalReadme],
2422
+ [path.join(memDir, 'wiki/project/README.md'), tplWikiProjectReadme],
2423
+ [path.join(memDir, 'wiki/knowledge/README.md'), tplWikiKnowledgeReadme],
2424
+ [path.join(memDir, 'wiki/knowledge/sources.md'), tplWikiSources],
2425
+ [path.join(memDir, 'wiki/knowledge/glossary.md'), tplWikiGlossary],
2426
+ [path.join(memDir, 'wiki/knowledge/questions.md'), tplWikiQuestions],
2427
+ [path.join(memDir, 'wiki/knowledge/lint.md'), tplWikiLint],
2428
+ [path.join(memDir, 'wiki/knowledge/sources/README.md'), tplWikiSourcesReadme],
2429
+ [path.join(memDir, 'wiki/knowledge/topics/README.md'), tplWikiTopicsReadme],
2430
+ [path.join(memDir, 'wiki/knowledge/global/README.md'), tplWikiGlobalReadme],
2282
2431
  [path.join(dir, 'skills/project-memory-maintainer/SKILL.md'), tplSkillMaintainer],
2283
2432
  ];
2284
2433
  for (const [fp, tpl] of staticFiles) {
@@ -2322,7 +2471,7 @@ function run(dir, forceUpdate, action = 'update') {
2322
2471
  if (fs.existsSync(llmsPath)) {
2323
2472
  updateSection(llmsPath, HDR_S, HDR_E, headerInner(p));
2324
2473
  updateSection(llmsPath, CORE_S, CORE_E, coreLlmsInner());
2325
- updateSection(llmsPath, SYS_S, SYS_E, systemsLlmsInner(dir));
2474
+ updateSection(llmsPath, SYS_S, SYS_E, projectWikiLlmsInner(dir));
2326
2475
  updateSection(llmsPath, WIKI_S, WIKI_E, wikiLlmsInner(dir));
2327
2476
  mark('update', 'llms.txt');
2328
2477
  } else {
@@ -2382,6 +2531,9 @@ function run(dir, forceUpdate, action = 'update') {
2382
2531
  mark(writeChanged(fp, tpl()) ? 'update' : 'skip', rel);
2383
2532
  }
2384
2533
 
2534
+ migrateKnowledgeWiki(dir, mark);
2535
+ archiveLegacySystems(dir, mark);
2536
+
2385
2537
  // Static indexes/scaffolds — add if missing; content may be user- or command-owned.
2386
2538
  const addIfMissing = [
2387
2539
  [path.join(memDir, '03-decisions.md'), tplDecisions],
@@ -2390,20 +2542,21 @@ function run(dir, forceUpdate, action = 'update') {
2390
2542
  [path.join(memDir, 'activity.md'), tplActivity],
2391
2543
  [path.join(memDir, 'actors/README.md'), tplActorsReadme],
2392
2544
  [path.join(memDir, 'worklog/README.md'), tplWorklogReadme],
2393
- [path.join(memDir, 'systems/README.md'), tplSystemsReadme],
2394
2545
  [path.join(memDir, 'raw/README.md'), tplRawReadme],
2395
2546
  [path.join(memDir, 'raw/files/README.md'), tplRawFilesReadme],
2396
2547
  [path.join(memDir, 'raw/urls/README.md'), tplRawUrlsReadme],
2397
2548
  [path.join(memDir, 'raw/conversations/README.md'), tplRawConversationsReadme],
2398
2549
  [path.join(memDir, 'raw/docs/README.md'), tplRawDocsReadme],
2399
2550
  [path.join(memDir, 'wiki/index.md'), tplWikiIndex],
2400
- [path.join(memDir, 'wiki/sources.md'), tplWikiSources],
2401
- [path.join(memDir, 'wiki/glossary.md'), tplWikiGlossary],
2402
- [path.join(memDir, 'wiki/questions.md'), tplWikiQuestions],
2403
- [path.join(memDir, 'wiki/lint.md'), tplWikiLint],
2404
- [path.join(memDir, 'wiki/sources/README.md'), tplWikiSourcesReadme],
2405
- [path.join(memDir, 'wiki/topics/README.md'), tplWikiTopicsReadme],
2406
- [path.join(memDir, 'wiki/global/README.md'), tplWikiGlobalReadme],
2551
+ [path.join(memDir, 'wiki/project/README.md'), tplWikiProjectReadme],
2552
+ [path.join(memDir, 'wiki/knowledge/README.md'), tplWikiKnowledgeReadme],
2553
+ [path.join(memDir, 'wiki/knowledge/sources.md'), tplWikiSources],
2554
+ [path.join(memDir, 'wiki/knowledge/glossary.md'), tplWikiGlossary],
2555
+ [path.join(memDir, 'wiki/knowledge/questions.md'), tplWikiQuestions],
2556
+ [path.join(memDir, 'wiki/knowledge/lint.md'), tplWikiLint],
2557
+ [path.join(memDir, 'wiki/knowledge/sources/README.md'), tplWikiSourcesReadme],
2558
+ [path.join(memDir, 'wiki/knowledge/topics/README.md'), tplWikiTopicsReadme],
2559
+ [path.join(memDir, 'wiki/knowledge/global/README.md'), tplWikiGlobalReadme],
2407
2560
  ];
2408
2561
  for (const [fp, tpl] of addIfMissing) {
2409
2562
  const rel = path.relative(dir, fp);
@@ -2412,13 +2565,23 @@ function run(dir, forceUpdate, action = 'update') {
2412
2565
  }
2413
2566
  ensureWikiScaffoldLinks(memDir, mark);
2414
2567
 
2568
+ const knowledgeLayerFiles = [
2569
+ path.join(memDir, 'wiki/knowledge/sources.md'),
2570
+ path.join(memDir, 'wiki/knowledge/glossary.md'),
2571
+ path.join(memDir, 'wiki/knowledge/questions.md'),
2572
+ path.join(memDir, 'wiki/knowledge/lint.md'),
2573
+ path.join(memDir, 'wiki/knowledge/global/README.md'),
2574
+ ];
2575
+ for (const fp of knowledgeLayerFiles) {
2576
+ if (migrateKnowledgeLayerLinks(fp)) mark('update', `${path.relative(dir, fp)} (wiki links)`);
2577
+ }
2578
+
2415
2579
  const legacyReferenceFiles = [
2416
2580
  path.join(memDir, '02-current-project-state.md'),
2417
2581
  path.join(memDir, '04-handoff.md'),
2418
2582
  path.join(memDir, '06-project-rules.md'),
2419
- path.join(memDir, 'systems/README.md'),
2420
2583
  path.join(memDir, 'wiki/index.md'),
2421
- path.join(memDir, 'wiki/sources.md'),
2584
+ path.join(memDir, 'wiki/knowledge/sources.md'),
2422
2585
  path.join(memDir, 'wiki/glossary.md'),
2423
2586
  path.join(memDir, 'wiki/questions.md'),
2424
2587
  path.join(memDir, 'wiki/lint.md'),
@@ -2778,7 +2941,7 @@ function runWikiLint(dir) {
2778
2941
  if (count === 0) warnings.push(`${rel}: no inbound wiki links`);
2779
2942
  }
2780
2943
 
2781
- const lintPath = path.join(wikiDir, 'lint.md');
2944
+ const lintPath = path.join(wikiDir, 'knowledge', 'lint.md');
2782
2945
  write(lintPath, wikiLintReport(issues, warnings));
2783
2946
  ensureMemocFrontmatter(lintPath, dir);
2784
2947
 
@@ -2786,7 +2949,7 @@ function runWikiLint(dir) {
2786
2949
  console.log(` Files ${files.length}`);
2787
2950
  console.log(` Issues ${issues.length}`);
2788
2951
  console.log(` Warnings ${warnings.length}`);
2789
- console.log(' Report .memoc/wiki/lint.md');
2952
+ console.log(' Report .memoc/wiki/knowledge/lint.md');
2790
2953
  if (issues.length) {
2791
2954
  console.log('\n Issues:');
2792
2955
  for (const issue of issues.slice(0, 10)) console.log(` - ${issue}`);
@@ -2802,8 +2965,8 @@ Last checked: ${nowISO()}
2802
2965
 
2803
2966
  ## Graph Checks
2804
2967
 
2805
- - Every wiki page is listed from [Wiki Index](index.md) or a directory README.
2806
- - Every wiki page links back to an index, hub, source, topic, or related page.
2968
+ - Every wiki page is listed from [Wiki Index](../index.md) or a directory README.
2969
+ - Every wiki page links back to an index, project hub, knowledge hub, source, topic, or related page.
2807
2970
  - Important concepts mentioned in two or more places have their own linked page.
2808
2971
  - Source records link to the pages they update, and those pages link back to sources when provenance matters.
2809
2972
 
@@ -2817,7 +2980,7 @@ ${warnings.length ? warnings.map(x => `- ${x}`).join('\n') : '_None._'}
2817
2980
 
2818
2981
  ## Related
2819
2982
 
2820
- - [Wiki Index](index.md)
2983
+ - [Wiki Index](../index.md)
2821
2984
  - [Sources](sources.md)
2822
2985
  - [Topics](topics/README.md)
2823
2986
  - [Open Questions](questions.md)
@@ -2842,7 +3005,7 @@ function runIngest(dir) {
2842
3005
  const rawPath = uniquePath(path.join(dir, '.memoc', 'raw', 'urls', `${slug}.md`));
2843
3006
  write(rawPath, rawUrlRecord(title, target));
2844
3007
  ensureMemocFrontmatter(rawPath, dir);
2845
- rawRef = pathRelativeMarkdown(path.join(dir, '.memoc', 'wiki', 'sources'), rawPath);
3008
+ rawRef = pathRelativeMarkdown(path.join(dir, '.memoc', 'wiki', 'knowledge', 'sources'), rawPath);
2846
3009
  rawDisplay = normRel(dir, rawPath);
2847
3010
  } else {
2848
3011
  const abs = path.resolve(dir, target);
@@ -2854,16 +3017,16 @@ function runIngest(dir) {
2854
3017
  const rawPath = uniquePath(path.join(dir, '.memoc', 'raw', 'files', `${slug}${ext}`));
2855
3018
  fs.mkdirSync(path.dirname(rawPath), { recursive: true });
2856
3019
  fs.copyFileSync(abs, rawPath);
2857
- rawRef = pathRelativeMarkdown(path.join(dir, '.memoc', 'wiki', 'sources'), rawPath);
3020
+ rawRef = pathRelativeMarkdown(path.join(dir, '.memoc', 'wiki', 'knowledge', 'sources'), rawPath);
2858
3021
  rawDisplay = normRel(dir, rawPath);
2859
3022
  }
2860
3023
 
2861
- const sourcePath = uniquePath(path.join(dir, '.memoc', 'wiki', 'sources', `${slug}.md`));
3024
+ const sourcePath = uniquePath(path.join(dir, '.memoc', 'wiki', 'knowledge', 'sources', `${slug}.md`));
2862
3025
  write(sourcePath, sourceRecord(title, rawRef, target, isUrl));
2863
3026
  ensureMemocFrontmatter(sourcePath, dir);
2864
- addWikiListItem(path.join(dir, '.memoc', 'wiki', 'sources.md'), 'Source Records', pathRelativeMarkdown(path.join(dir, '.memoc', 'wiki'), sourcePath), title, 'needs synthesis');
2865
- addWikiListItem(path.join(dir, '.memoc', 'wiki', 'sources', 'README.md'), 'Source Records', path.basename(sourcePath), title, 'source record');
2866
- addWikiListItem(path.join(dir, '.memoc', 'wiki', 'index.md'), 'Pages', pathRelativeMarkdown(path.join(dir, '.memoc', 'wiki'), sourcePath), title, 'source record');
3027
+ addWikiListItem(path.join(dir, '.memoc', 'wiki', 'knowledge', 'sources.md'), 'Source Records', pathRelativeMarkdown(path.join(dir, '.memoc', 'wiki', 'knowledge'), sourcePath), title, 'needs synthesis');
3028
+ addWikiListItem(path.join(dir, '.memoc', 'wiki', 'knowledge', 'sources', 'README.md'), 'Source Records', path.basename(sourcePath), title, 'source record');
3029
+ addWikiListItem(path.join(dir, '.memoc', 'wiki', 'index.md'), 'Knowledge Pages', pathRelativeMarkdown(path.join(dir, '.memoc', 'wiki'), sourcePath), title, 'source record');
2867
3030
  console.log('\n memoc ingest\n');
2868
3031
  console.log(` Source record ${normRel(dir, sourcePath)}`);
2869
3032
  console.log(` Raw reference ${rawDisplay}`);
@@ -2887,11 +3050,11 @@ function runNote(dir) {
2887
3050
  }
2888
3051
 
2889
3052
  ensureMemocBase(dir);
2890
- const topicPath = uniquePath(path.join(dir, '.memoc', 'wiki', 'topics', `${slugify(title, 'topic')}.md`));
3053
+ const topicPath = uniquePath(path.join(dir, '.memoc', 'wiki', 'knowledge', 'topics', `${slugify(title, 'topic')}.md`));
2891
3054
  write(topicPath, topicNote(title, body));
2892
3055
  ensureMemocFrontmatter(topicPath, dir);
2893
- addWikiListItem(path.join(dir, '.memoc', 'wiki', 'topics', 'README.md'), 'Topic Pages', path.basename(topicPath), title, 'topic note');
2894
- addWikiListItem(path.join(dir, '.memoc', 'wiki', 'index.md'), 'Saved Queries', pathRelativeMarkdown(path.join(dir, '.memoc', 'wiki'), topicPath), title, 'saved query/topic note');
3056
+ addWikiListItem(path.join(dir, '.memoc', 'wiki', 'knowledge', 'topics', 'README.md'), 'Topic Pages', path.basename(topicPath), title, 'topic note');
3057
+ addWikiListItem(path.join(dir, '.memoc', 'wiki', 'index.md'), 'Knowledge Pages', pathRelativeMarkdown(path.join(dir, '.memoc', 'wiki'), topicPath), title, 'saved query/topic note');
2895
3058
  console.log('\n memoc note\n');
2896
3059
  console.log(` Topic ${normRel(dir, topicPath)}`);
2897
3060
  console.log(' Next Link related sources/topics, then run memoc lint-wiki.');
@@ -2903,9 +3066,15 @@ function ensureMemocBase(dir) {
2903
3066
  const memDir = path.join(dir, '.memoc');
2904
3067
  const files = [
2905
3068
  [path.join(memDir, 'wiki/index.md'), tplWikiIndex],
2906
- [path.join(memDir, 'wiki/sources.md'), tplWikiSources],
2907
- [path.join(memDir, 'wiki/sources/README.md'), tplWikiSourcesReadme],
2908
- [path.join(memDir, 'wiki/topics/README.md'), tplWikiTopicsReadme],
3069
+ [path.join(memDir, 'wiki/project/README.md'), tplWikiProjectReadme],
3070
+ [path.join(memDir, 'wiki/knowledge/README.md'), tplWikiKnowledgeReadme],
3071
+ [path.join(memDir, 'wiki/knowledge/sources.md'), tplWikiSources],
3072
+ [path.join(memDir, 'wiki/knowledge/sources/README.md'), tplWikiSourcesReadme],
3073
+ [path.join(memDir, 'wiki/knowledge/topics/README.md'), tplWikiTopicsReadme],
3074
+ [path.join(memDir, 'wiki/knowledge/global/README.md'), tplWikiGlobalReadme],
3075
+ [path.join(memDir, 'wiki/knowledge/glossary.md'), tplWikiGlossary],
3076
+ [path.join(memDir, 'wiki/knowledge/questions.md'), tplWikiQuestions],
3077
+ [path.join(memDir, 'wiki/knowledge/lint.md'), tplWikiLint],
2909
3078
  [path.join(memDir, 'raw/README.md'), tplRawReadme],
2910
3079
  [path.join(memDir, 'raw/files/README.md'), tplRawFilesReadme],
2911
3080
  [path.join(memDir, 'raw/urls/README.md'), tplRawUrlsReadme],
@@ -2965,7 +3134,7 @@ _Summarize only the durable facts future agents should reuse._
2965
3134
 
2966
3135
  ## Synthesis Tasks
2967
3136
 
2968
- - [ ] Create or update affected topic/global/system pages.
3137
+ - [ ] Create or update affected topic/global/project pages.
2969
3138
  - [ ] Link those pages back to this source when provenance matters.
2970
3139
  - [ ] Run \`memoc lint-wiki\`.
2971
3140
 
@@ -2973,7 +3142,7 @@ _Summarize only the durable facts future agents should reuse._
2973
3142
 
2974
3143
  - [Sources Index](../sources.md)
2975
3144
  - [Source Records](README.md)
2976
- - [Wiki Index](../index.md)
3145
+ - [Knowledge Wiki](../README.md)
2977
3146
  `;
2978
3147
  }
2979
3148
 
@@ -2994,7 +3163,7 @@ _None yet._
2994
3163
 
2995
3164
  ## Related
2996
3165
 
2997
- - [Wiki Index](../index.md)
3166
+ - [Knowledge Wiki](../README.md)
2998
3167
  - [Topics](README.md)
2999
3168
  - [Glossary](../glossary.md)
3000
3169
  `;
@@ -3283,8 +3452,9 @@ function searchPriority(file, scope = 'memory') {
3283
3452
  ];
3284
3453
  const exact = order.indexOf(normalized);
3285
3454
  if (exact !== -1) return exact;
3286
- if (normalized.startsWith('.memoc/systems/')) return 20;
3287
- if (normalized.startsWith('.memoc/wiki/')) return 30;
3455
+ if (normalized.startsWith('.memoc/wiki/project/')) return 20;
3456
+ if (normalized.startsWith('.memoc/wiki/knowledge/')) return 30;
3457
+ if (normalized.startsWith('.memoc/wiki/')) return 35;
3288
3458
  if (normalized.startsWith('skills/')) return 40;
3289
3459
  return 50;
3290
3460
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevin0181/memoc",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "description": "Give AI agents a memory. Scaffolds session-to-session context for Claude Code, Codex, Cursor, and more.",
5
5
  "keywords": [
6
6
  "ai",