@crouton-kit/crouter 0.3.36 → 0.3.38

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 (177) hide show
  1. package/dist/build-root.js +3 -6
  2. package/dist/{builtin-personas/runtime-base.md → builtin-memory/00-runtime-base.md} +8 -1
  3. package/dist/{builtin-personas/spine/has-manager.md → builtin-memory/01-spine/00-has-manager.md} +8 -0
  4. package/dist/builtin-memory/01-spine/01-no-manager.md +10 -0
  5. package/dist/{builtin-personas/lifecycle/terminal.md → builtin-memory/02-lifecycle/00-terminal.md} +8 -0
  6. package/dist/{builtin-personas/lifecycle/resident.md → builtin-memory/02-lifecycle/01-resident.md} +8 -0
  7. package/dist/{builtin-personas/waiting.md → builtin-memory/03-waiting.md} +7 -0
  8. package/dist/{builtin-personas/orchestration-kernel.md → builtin-memory/04-orchestration-kernel.md} +8 -0
  9. package/dist/{builtin-personas/advisor/PERSONA.md → builtin-memory/05-kinds/advisor/00-base.md} +5 -2
  10. package/dist/{builtin-personas/design/PERSONA.md → builtin-memory/05-kinds/design/00-base.md} +5 -2
  11. package/dist/{builtin-personas/design/orchestrator.md → builtin-memory/05-kinds/design/01-orchestrator.md} +5 -4
  12. package/dist/{builtin-personas/developer/PERSONA.md → builtin-memory/05-kinds/developer/00-base.md} +5 -2
  13. package/dist/{builtin-personas/developer/orchestrator.md → builtin-memory/05-kinds/developer/01-orchestrator.md} +5 -4
  14. package/dist/{builtin-personas/explore/PERSONA.md → builtin-memory/05-kinds/explore/00-base.md} +5 -2
  15. package/dist/{builtin-personas/explore/orchestrator.md → builtin-memory/05-kinds/explore/01-orchestrator.md} +5 -3
  16. package/dist/{builtin-personas/general/PERSONA.md → builtin-memory/05-kinds/general/00-base.md} +5 -2
  17. package/dist/{builtin-personas/general/orchestrator.md → builtin-memory/05-kinds/general/01-orchestrator.md} +5 -3
  18. package/dist/{builtin-personas/plan/PERSONA.md → builtin-memory/05-kinds/plan/00-base.md} +5 -2
  19. package/dist/{builtin-personas/plan/orchestrator.md → builtin-memory/05-kinds/plan/01-orchestrator.md} +5 -4
  20. package/dist/{builtin-personas/plan/reviewers/architecture-fit/PERSONA.md → builtin-memory/05-kinds/plan/reviewers/architecture-fit.md} +5 -2
  21. package/dist/{builtin-personas/plan/reviewers/code-smells/PERSONA.md → builtin-memory/05-kinds/plan/reviewers/code-smells.md} +5 -2
  22. package/dist/{builtin-personas/plan/reviewers/pattern-consistency/PERSONA.md → builtin-memory/05-kinds/plan/reviewers/pattern-consistency.md} +5 -2
  23. package/dist/{builtin-personas/plan/reviewers/requirements-coverage/PERSONA.md → builtin-memory/05-kinds/plan/reviewers/requirements-coverage.md} +5 -2
  24. package/dist/{builtin-personas/plan/reviewers/security/PERSONA.md → builtin-memory/05-kinds/plan/reviewers/security.md} +5 -2
  25. package/dist/{builtin-personas/product/PERSONA.md → builtin-memory/05-kinds/product/00-base.md} +5 -2
  26. package/dist/{builtin-personas/product/orchestrator.md → builtin-memory/05-kinds/product/01-orchestrator.md} +5 -4
  27. package/dist/{builtin-personas/product/teardown/PERSONA.md → builtin-memory/05-kinds/product/teardown.md} +5 -3
  28. package/dist/{builtin-personas/review/PERSONA.md → builtin-memory/05-kinds/review/00-base.md} +5 -2
  29. package/dist/{builtin-personas/review/orchestrator.md → builtin-memory/05-kinds/review/01-orchestrator.md} +5 -3
  30. package/dist/{builtin-personas/spec/PERSONA.md → builtin-memory/05-kinds/spec/00-base.md} +5 -2
  31. package/dist/{builtin-personas/spec/orchestrator.md → builtin-memory/05-kinds/spec/01-orchestrator.md} +5 -4
  32. package/dist/{builtin-personas/spec/requirements/PERSONA.md → builtin-memory/05-kinds/spec/requirements.md} +5 -2
  33. package/dist/builtin-memory/internal/INDEX.md +1 -1
  34. package/dist/builtin-memory/internal/examples/imessage-assistant.md +2 -2
  35. package/dist/builtin-memory/internal/nodes-and-canvas.md +1 -1
  36. package/dist/builtin-pi-packages/pi-mode-switch/extensions/index.ts +4 -4
  37. package/dist/builtin-views/canvas/core.mjs +3 -2
  38. package/dist/builtin-views/prompt-review/core.mjs +6 -134
  39. package/dist/builtin-views/settings/core.mjs +26 -94
  40. package/dist/builtin-views/settings/text.mjs +0 -5
  41. package/dist/builtin-views/settings/tui.mjs +1 -7
  42. package/dist/builtin-views/settings/web.jsx +3 -49
  43. package/dist/clients/attach/__tests__/crtr-output-render.test.js +21 -205
  44. package/dist/clients/attach/attach-cmd.js +429 -432
  45. package/dist/clients/web/web-cmd.js +7 -7
  46. package/dist/commands/__tests__/human.test.js +1 -15
  47. package/dist/commands/attention.js +9 -6
  48. package/dist/commands/canvas-history/search.js +2 -2
  49. package/dist/commands/canvas-history/show.js +3 -3
  50. package/dist/commands/canvas-history.js +1 -1
  51. package/dist/commands/canvas-issue.js +1 -0
  52. package/dist/commands/canvas-snapshot.js +1 -0
  53. package/dist/commands/canvas.js +10 -11
  54. package/dist/commands/chord.js +1 -0
  55. package/dist/commands/human/prompts.js +0 -1
  56. package/dist/commands/human/queue.js +1 -0
  57. package/dist/commands/memory/read.js +3 -3
  58. package/dist/commands/memory/shared.d.ts +13 -8
  59. package/dist/commands/memory/shared.js +22 -8
  60. package/dist/commands/memory/write.js +5 -3
  61. package/dist/commands/node-snapshot.js +1 -0
  62. package/dist/commands/node.js +52 -22
  63. package/dist/commands/profile/add-project.d.ts +1 -0
  64. package/dist/commands/profile/add-project.js +42 -0
  65. package/dist/commands/profile/delete.d.ts +1 -0
  66. package/dist/commands/profile/delete.js +39 -0
  67. package/dist/commands/profile/list.d.ts +1 -0
  68. package/dist/commands/profile/list.js +35 -0
  69. package/dist/commands/profile/new.d.ts +1 -0
  70. package/dist/commands/profile/new.js +50 -0
  71. package/dist/commands/profile/remove-project.d.ts +1 -0
  72. package/dist/commands/profile/remove-project.js +42 -0
  73. package/dist/commands/profile/rename.d.ts +1 -0
  74. package/dist/commands/profile/rename.js +42 -0
  75. package/dist/commands/profile/show.d.ts +1 -0
  76. package/dist/commands/profile/show.js +50 -0
  77. package/dist/commands/profile.d.ts +2 -0
  78. package/dist/commands/profile.js +33 -0
  79. package/dist/commands/push.d.ts +0 -1
  80. package/dist/commands/push.js +2 -228
  81. package/dist/commands/revive.js +2 -2
  82. package/dist/commands/{canvas-tmux-spread.js → surface-tmux-spread.js} +9 -6
  83. package/dist/commands/surface.js +3 -2
  84. package/dist/commands/sys/config.js +6 -21
  85. package/dist/commands/sys/daemon.d.ts +2 -0
  86. package/dist/commands/{daemon.js → sys/daemon.js} +12 -12
  87. package/dist/commands/sys/doctor.js +1 -0
  88. package/dist/commands/sys/prompt-review.js +90 -17
  89. package/dist/commands/sys.js +4 -3
  90. package/dist/core/__tests__/daemon-boot.test.js +1 -1
  91. package/dist/core/__tests__/daemon-wedge.test.d.ts +1 -0
  92. package/dist/core/__tests__/daemon-wedge.test.js +87 -0
  93. package/dist/core/__tests__/hearth-bootstrap.test.js +2 -2
  94. package/dist/core/__tests__/history-inbox.test.d.ts +1 -0
  95. package/dist/core/__tests__/history-inbox.test.js +105 -0
  96. package/dist/core/__tests__/kickoff.test.js +3 -3
  97. package/dist/core/__tests__/revive.test.js +39 -1
  98. package/dist/core/canvas/canvas.js +10 -9
  99. package/dist/core/canvas/db.js +11 -0
  100. package/dist/core/canvas/history.d.ts +1 -1
  101. package/dist/core/canvas/history.js +91 -3
  102. package/dist/core/canvas/paths.d.ts +6 -0
  103. package/dist/core/canvas/paths.js +9 -0
  104. package/dist/core/canvas/status-glyph.js +1 -0
  105. package/dist/core/canvas/types.d.ts +10 -0
  106. package/dist/core/config.d.ts +44 -1
  107. package/dist/core/config.js +155 -12
  108. package/dist/core/fault-classifier.d.ts +2 -2
  109. package/dist/core/feed/inbox.d.ts +7 -12
  110. package/dist/core/feed/inbox.js +45 -29
  111. package/dist/core/hearth/providers/blaxel-bootstrap.js +1 -1
  112. package/dist/core/memory-resolver.d.ts +26 -15
  113. package/dist/core/memory-resolver.js +158 -40
  114. package/dist/core/preview-registry.js +14 -112
  115. package/dist/core/profiles/manifest.d.ts +33 -0
  116. package/dist/core/profiles/manifest.js +332 -0
  117. package/dist/core/profiles/select.d.ts +11 -0
  118. package/dist/core/profiles/select.js +115 -0
  119. package/dist/core/render.js +1 -1
  120. package/dist/core/runtime/bearings.d.ts +9 -0
  121. package/dist/core/runtime/bearings.js +31 -0
  122. package/dist/core/runtime/busy.d.ts +15 -0
  123. package/dist/core/runtime/busy.js +32 -1
  124. package/dist/core/runtime/close.d.ts +10 -0
  125. package/dist/core/runtime/close.js +18 -13
  126. package/dist/core/runtime/fault-recovery.js +4 -0
  127. package/dist/core/runtime/front-door.js +9 -2
  128. package/dist/core/runtime/kickoff.js +5 -7
  129. package/dist/core/runtime/launch.d.ts +25 -7
  130. package/dist/core/runtime/launch.js +42 -55
  131. package/dist/core/runtime/nodes.d.ts +7 -0
  132. package/dist/core/runtime/nodes.js +6 -0
  133. package/dist/core/runtime/persona.js +18 -32
  134. package/dist/core/runtime/placement.js +1 -1
  135. package/dist/core/runtime/revive.js +9 -1
  136. package/dist/core/runtime/spawn.d.ts +13 -0
  137. package/dist/core/runtime/spawn.js +25 -0
  138. package/dist/core/runtime/tmux.d.ts +2 -2
  139. package/dist/core/runtime/tmux.js +2 -2
  140. package/dist/core/scope.d.ts +14 -7
  141. package/dist/core/scope.js +76 -20
  142. package/dist/core/substrate/index.d.ts +3 -3
  143. package/dist/core/substrate/index.js +5 -3
  144. package/dist/core/substrate/on-read.js +3 -2
  145. package/dist/core/substrate/render.d.ts +16 -11
  146. package/dist/core/substrate/render.js +249 -62
  147. package/dist/core/substrate/schema.d.ts +11 -3
  148. package/dist/core/substrate/schema.js +25 -0
  149. package/dist/core/substrate/subject.d.ts +15 -2
  150. package/dist/core/substrate/subject.js +24 -2
  151. package/dist/daemon/crtrd-cli.js +1 -1
  152. package/dist/daemon/crtrd.d.ts +24 -0
  153. package/dist/daemon/crtrd.js +213 -5
  154. package/dist/daemon/manage.js +2 -2
  155. package/dist/pi-extensions/canvas-doc-substrate.js +2 -3
  156. package/dist/pi-extensions/canvas-nav.js +2 -2
  157. package/dist/pi-extensions/canvas-stophook.d.ts +1 -1
  158. package/dist/pi-extensions/canvas-stophook.js +59 -2
  159. package/dist/types.d.ts +57 -1
  160. package/dist/types.js +83 -1
  161. package/dist/web-client/assets/{index-IAJVtuVe.js → index-CbO8L0mN.js} +4 -4
  162. package/dist/web-client/assets/index-DwO46Cs5.css +2 -0
  163. package/dist/web-client/index.html +2 -2
  164. package/package.json +2 -2
  165. package/dist/builtin-memory/crouter-development/personas/base-prompt.md +0 -56
  166. package/dist/builtin-memory/crouter-development/personas/orchestrator-prompt.md +0 -57
  167. package/dist/builtin-memory/crouter-development/personas.md +0 -112
  168. package/dist/builtin-personas/spine/no-manager.md +0 -2
  169. package/dist/commands/daemon.d.ts +0 -2
  170. package/dist/core/personas/index.d.ts +0 -13
  171. package/dist/core/personas/index.js +0 -11
  172. package/dist/core/personas/loader.d.ts +0 -159
  173. package/dist/core/personas/loader.js +0 -327
  174. package/dist/core/personas/resolve.d.ts +0 -59
  175. package/dist/core/personas/resolve.js +0 -376
  176. package/dist/web-client/assets/index-DUThOUzU.css +0 -2
  177. /package/dist/commands/{canvas-tmux-spread.d.ts → surface-tmux-spread.d.ts} +0 -0
@@ -4,7 +4,19 @@ import { join, resolve, dirname } from 'node:path';
4
4
  import { fileURLToPath } from 'node:url';
5
5
  import { CRTR_DIR_NAME } from '../types.js';
6
6
  import { usage } from './errors.js';
7
- let cachedProjectRoot;
7
+ import { loadProfileManifest } from './profiles/manifest.js';
8
+ // Cache of resolved project-scope-root STACKS, keyed by (resolved cwd, profile
9
+ // id). A profile widens the pointer set beyond the bare cwd (see
10
+ // findProjectScopeRoots below), so the cache key must carry both — the same
11
+ // cwd resolves to a different stack under a different (or no) profile.
12
+ // `resetScopeCache()` (called by every profile mutation in
13
+ // src/core/profiles/manifest.ts) clears the whole cache; there is no
14
+ // per-entry invalidation because a profile edit can change which pointer set
15
+ // any cached cwd belongs to.
16
+ const scopeRootsCache = new Map();
17
+ function scopeRootsCacheKey(resolvedStartDir, profileId) {
18
+ return `${resolvedStartDir}\u0000${profileId ?? ''}`;
19
+ }
8
20
  export function builtinViewsRoot() {
9
21
  // Resolved relative to this file: dist/core/scope.js → dist/builtin-views/
10
22
  // (src/ at dev time).
@@ -47,20 +59,13 @@ function isProjectScopeDir(candidate, userRoot) {
47
59
  }
48
60
  }
49
61
  export function findProjectScopeRoot(startDir = process.cwd()) {
50
- if (cachedProjectRoot !== undefined)
51
- return cachedProjectRoot;
52
- const roots = findProjectScopeRoots(startDir);
53
- cachedProjectRoot = roots[0] ?? null;
54
- return cachedProjectRoot;
55
- }
56
- /** Every project scope root visible from `startDir`, nearest first. Each
57
- * ancestor directory with a `.crouter/` contributes memory/preferences to the
58
- * current workspace; the nearest root still wins for writes and duplicate doc
59
- * names. The user-global `~/.crouter/` is excluded because it is the separate
60
- * user scope, not a project ancestor. */
61
- export function findProjectScopeRoots(startDir = process.cwd()) {
62
+ return findProjectScopeRoots(startDir)[0] ?? null;
63
+ }
64
+ /** Walk `startDir` upward to the filesystem root, collecting every ancestor
65
+ * `.crouter/` dir (nearest first). The user-global `~/.crouter/` is excluded
66
+ * because it is the separate user scope, not a project ancestor. */
67
+ function collectAncestorScopeRoots(startDir, userRoot) {
62
68
  const roots = [];
63
- const userRoot = userScopeRoot();
64
69
  let dir = resolve(startDir);
65
70
  while (true) {
66
71
  const candidate = join(dir, CRTR_DIR_NAME);
@@ -72,11 +77,55 @@ export function findProjectScopeRoots(startDir = process.cwd()) {
72
77
  dir = parent;
73
78
  }
74
79
  }
80
+ /** Every project scope root visible from `startDir`, nearest first — now a
81
+ * PROFILE-AWARE pointer walk, not a single-pointer ancestor walk. Pointers are
82
+ * `[startDir]` plus, when `profileId` resolves to a manifest, each of its
83
+ * `projects` in manifest order; each pointer independently walks upward
84
+ * collecting every ancestor `.crouter/` dir, the pointers' contributions
85
+ * concatenate in pointer order, and the combined list dedupes to first
86
+ * occurrence — so a `.crouter/` shared by two pointers contributes once, at
87
+ * whichever pointer reached it first. `profileId` defaults to the process's
88
+ * selected profile (`CRTR_PROFILE_ID`); a null/unresolvable profile collapses
89
+ * to the single `[startDir]` pointer, reproducing today's behavior exactly.
90
+ * Results are cached per (resolved startDir, profileId) — `resetScopeCache()`
91
+ * invalidates on any profile mutation that can change project dirs or names. */
92
+ export function findProjectScopeRoots(startDir = process.cwd(), profileId = process.env['CRTR_PROFILE_ID'] || null) {
93
+ const resolvedStart = resolve(startDir);
94
+ const key = scopeRootsCacheKey(resolvedStart, profileId);
95
+ const cached = scopeRootsCache.get(key);
96
+ if (cached !== undefined)
97
+ return cached;
98
+ const userRoot = userScopeRoot();
99
+ const pointers = [resolvedStart];
100
+ if (profileId !== null && profileId !== '') {
101
+ try {
102
+ const { manifest } = loadProfileManifest(profileId);
103
+ pointers.push(...manifest.projects);
104
+ }
105
+ catch {
106
+ // Missing/deleted/invalid profile: this is a hot path every memory and
107
+ // launch-config resolve runs through, so fall back to the bare
108
+ // `[startDir]` pointer rather than throwing.
109
+ }
110
+ }
111
+ const seen = new Set();
112
+ const roots = [];
113
+ for (const pointer of pointers) {
114
+ for (const root of collectAncestorScopeRoots(pointer, userRoot)) {
115
+ if (seen.has(root))
116
+ continue;
117
+ seen.add(root);
118
+ roots.push(root);
119
+ }
120
+ }
121
+ scopeRootsCache.set(key, roots);
122
+ return roots;
123
+ }
75
124
  export function projectScopeRoot(startDir) {
76
125
  return findProjectScopeRoot(startDir);
77
126
  }
78
- export function projectScopeRoots(startDir) {
79
- return findProjectScopeRoots(startDir);
127
+ export function projectScopeRoots(startDir, profileId) {
128
+ return findProjectScopeRoots(startDir, profileId);
80
129
  }
81
130
  export function scopeRoot(scope) {
82
131
  // The builtin scope has no scope-root dir: its only content is memory
@@ -96,9 +145,16 @@ export function ensureProjectScopeRoot(startDir = process.cwd()) {
96
145
  const found = findProjectScopeRoot(startDir);
97
146
  if (found)
98
147
  return found;
99
- // Initialize new project scope at startDir
100
- const root = join(resolve(startDir), CRTR_DIR_NAME);
101
- cachedProjectRoot = root;
148
+ // Initialize new project scope at startDir. `found` was falsy, which means
149
+ // the (resolvedStart, profileId) cache key above resolved to an EMPTY stack
150
+ // (no pointer had an existing `.crouter/` yet) — seed that same cache entry
151
+ // with the about-to-exist root so a caller that immediately writes under it
152
+ // (without an intervening disk rescan) sees it without a stale empty-array
153
+ // cache hit.
154
+ const resolvedStart = resolve(startDir);
155
+ const root = join(resolvedStart, CRTR_DIR_NAME);
156
+ const profileId = process.env['CRTR_PROFILE_ID'] || null;
157
+ scopeRootsCache.set(scopeRootsCacheKey(resolvedStart, profileId), [root]);
102
158
  return root;
103
159
  }
104
160
  export function pluginsDir(scope) {
@@ -154,5 +210,5 @@ export function listScopes(scopeArg) {
154
210
  return [v];
155
211
  }
156
212
  export function resetScopeCache() {
157
- cachedProjectRoot = undefined;
213
+ scopeRootsCache.clear();
158
214
  }
@@ -1,9 +1,9 @@
1
- export { KINDS, isDocKind, RUNGS, rungRank, rungAtLeast, FALLBACK_RUNG, parseSubstrateFrontmatter, parseSubstrateDoc, previewLine, } from './schema.js';
1
+ export { KINDS, isDocKind, RUNGS, rungRank, rungAtLeast, FALLBACK_RUNG, parseSubstrateFrontmatter, parseSubstrateDoc, previewLine, normalizeNameSegment, normalizeDocName, } from './schema.js';
2
2
  export type { DocKind, Rung, GatePredicate, SubstrateSchema, SubstrateDoc } from './schema.js';
3
- export { scopeForCwd, spineDepth, assembleNodeSubject } from './subject.js';
3
+ export { scopeForCwd, spineDepth, assembleNodeSubject, profileNameFor } from './subject.js';
4
4
  export type { NodeConfigSubject } from './subject.js';
5
5
  export { gatePasses } from './gate.js';
6
6
  export { INDEX_NAME, isIndexName, indexDirOf, displayName, buildCeilingIndex, effectiveRung, } from './ceiling.js';
7
7
  export type { Surface } from './ceiling.js';
8
- export { renderPreferencesSection, renderKnowledgeBlock, } from './render.js';
8
+ export { renderPreferencesSection, renderKnowledgeBlock, renderPreferencesForSubject, } from './render.js';
9
9
  export { renderOnReadDocs } from './on-read.js';
@@ -11,9 +11,11 @@ RUNGS, rungRank, rungAtLeast,
11
11
  // fallback floor
12
12
  FALLBACK_RUNG,
13
13
  // parse + render-shared helpers
14
- parseSubstrateFrontmatter, parseSubstrateDoc, previewLine, } from './schema.js';
15
- export { scopeForCwd, spineDepth, assembleNodeSubject } from './subject.js';
14
+ parseSubstrateFrontmatter, parseSubstrateDoc, previewLine,
15
+ // display-name normalization
16
+ normalizeNameSegment, normalizeDocName, } from './schema.js';
17
+ export { scopeForCwd, spineDepth, assembleNodeSubject, profileNameFor } from './subject.js';
16
18
  export { gatePasses } from './gate.js';
17
19
  export { INDEX_NAME, isIndexName, indexDirOf, displayName, buildCeilingIndex, effectiveRung, } from './ceiling.js';
18
- export { renderPreferencesSection, renderKnowledgeBlock, } from './render.js';
20
+ export { renderPreferencesSection, renderKnowledgeBlock, renderPreferencesForSubject, } from './render.js';
19
21
  export { renderOnReadDocs } from './on-read.js';
@@ -56,7 +56,7 @@ import { pathExists, readText, walkFiles } from '../fs-utils.js';
56
56
  import { parseFrontmatterGeneric } from '../frontmatter.js';
57
57
  import { evalCondition } from '../predicate.js';
58
58
  import { listAllMemoryDocs } from '../memory-resolver.js';
59
- import { assembleNodeSubject, buildCeilingIndex, displayName, effectiveRung, gatePasses, parseSubstrateDoc, parseSubstrateFrontmatter, previewLine, } from './index.js';
59
+ import { assembleNodeSubject, buildCeilingIndex, displayName, effectiveRung, gatePasses, normalizeDocName, parseSubstrateDoc, parseSubstrateFrontmatter, previewLine, } from './index.js';
60
60
  import { cachedSubstrateDocs } from './session-cache.js';
61
61
  // Ancestor dirs we never look inside for a `.crouter/memory/` store (the read
62
62
  // file may live under a build/dependency tree; `.crouter` is NOT junk here — it
@@ -113,10 +113,11 @@ function isJunkAncestor(dir) {
113
113
  * (gate eval keys off the NODE subject, render off name/body/rung). */
114
114
  function loadPositionalDoc(file, memDir, scope) {
115
115
  try {
116
- const name = relative(memDir, file)
116
+ const raw = relative(memDir, file)
117
117
  .replace(/\.md$/i, '')
118
118
  .split(sep)
119
119
  .join('/');
120
+ const name = normalizeDocName(raw);
120
121
  if (name === '')
121
122
  return null;
122
123
  const { data, body } = parseFrontmatterGeneric(readText(file));
@@ -1,16 +1,21 @@
1
- /** The system-prompt memory block: the always-present memory-usage guidance,
2
- * then (when any are eligible) the `kind: preference` docs in one tree at their
3
- * effective rung (the preference default rung is `preview` → the routing line).
4
- * ALWAYS returns a non-empty `<memory kind="preference">` block — the guidance
5
- * frame is unconditional, so the system-prompt splice is never empty even when
6
- * no preference is eligible. */
1
+ import { type NodeConfigSubject, type SubstrateDoc } from './index.js';
7
2
  export declare function renderPreferencesSection(nodeId: string): string;
3
+ export declare function renderPreferencesForSubject(subject: NodeConfigSubject): {
4
+ block: string;
5
+ contentDocs: SubstrateDoc[];
6
+ tree: string;
7
+ };
8
8
  /** The `<memory kind="knowledge">` block embedded in the session_start bearings
9
9
  * message (bearings.ts pushes it as a SIBLING of `<crtr-bearings>`, or drops it
10
10
  * when ''). The consultable catalog: every eligible `kind: knowledge` resolver
11
- * doc at its effective rung (most surface only as `[+N more]` counts unless
12
- * author-promoted) PLUS the node-local memory docs (any kind), the latter
13
- * floored to `name` so a `none`-rung node-local doc still shows its name rather
14
- * than collapsing into a count. Procedural guidance and factual references both
15
- * live here as `knowledge`. Returns '' when nothing is eligible. */
11
+ * doc PLUS the node-local memory docs (any kind) resolver docs win
12
+ * first-wins dedup over a same-named node-local doc. GROUPED by rung exactly
13
+ * like the preference block: content prose first (general→specific,
14
+ * node-local last), then the preview/name catalog tree. Node-local docs are
15
+ * floored HERE a rung-none node-local doc's effective rung is bumped to
16
+ * `name` before grouping, so it still surfaces as a bare-name tree entry
17
+ * rather than collapsing into a `[+N more]` count (its body still never
18
+ * renders: floored docs never reach the `content` rung). Procedural guidance
19
+ * and factual references both live here as `knowledge`. Returns '' when
20
+ * nothing is eligible. */
16
21
  export declare function renderKnowledgeBlock(nodeId: string): string;