repo-nexus 0.10.2 → 0.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/plugins.sh CHANGED
@@ -439,7 +439,7 @@ _plugin_config_default_keys() {
439
439
  k = $0
440
440
  sub(/^[ ]*/, "", k)
441
441
  sub(/:.*/, "", k)
442
- if (k != "sources" && k != "hooks") print k
442
+ if (k != "sources" && k != "exclude" && k != "hooks") print k
443
443
  }
444
444
  }
445
445
  ' "$_pcdk_file"
@@ -785,13 +785,21 @@ _src_normalize_entry() {
785
785
  }
786
786
 
787
787
  # True if a normalized entry names a file rather than a directory
788
- # (glob pattern, .md/.txt suffix, or an existing regular file)
788
+ # (glob pattern, existing regular file, or path whose basename carries a file extension)
789
789
  _src_is_file_like() {
790
790
  _src_has_glob "$1" && return 0
791
- case "$1" in
792
- *.md|*.txt) return 0 ;;
793
- esac
791
+ [ -d "${NEXUS_DIR:-.}/$1" ] && return 1
794
792
  [ -f "${NEXUS_DIR:-.}/$1" ] && return 0
793
+ _sifl_base="${1##*/}"
794
+ case "$_sifl_base" in
795
+ .*.*) return 0 ;;
796
+ *.*)
797
+ case "$_sifl_base" in
798
+ .*) return 1 ;;
799
+ *) return 0 ;;
800
+ esac
801
+ ;;
802
+ esac
795
803
  return 1
796
804
  }
797
805
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repo-nexus",
3
- "version": "0.10.2",
3
+ "version": "0.10.3",
4
4
  "description": "Lightweight, zero-dependency Virtual Meta Repository (meta repo) and Nexus Repository (nexus repo) manager for multi-repo workspaces and shared AI context (no git submodules)",
5
5
  "bin": {
6
6
  "repo-nexus": "rnex",
@@ -1,5 +1,5 @@
1
1
  name: claude
2
- version: 0.10.2
2
+ version: 0.10.3
3
3
  description: Anthropic Claude Code integration (maintains CLAUDE.md instructions and generates user skills in .claude/skills/)
4
4
  author: unoxen
5
5
  homepage: https://github.com/unoxen/repo-nexus
@@ -1,5 +1,5 @@
1
1
  name: codex
2
- version: 0.10.2
2
+ version: 0.10.3
3
3
  description: OpenAI Codex and ChatGPT integration (maintains CODEX.md instructions and generates user skills in .codex/skills/)
4
4
  author: unoxen
5
5
  homepage: https://github.com/unoxen/repo-nexus
@@ -1,5 +1,5 @@
1
1
  name: copilot
2
- version: 0.10.2
2
+ version: 0.10.3
3
3
  description: GitHub Copilot integration (maintains .github/copilot-instructions.md and user skills in .github/skills/)
4
4
  author: unoxen
5
5
  homepage: https://github.com/unoxen/repo-nexus
@@ -1,5 +1,5 @@
1
1
  name: cursor
2
- version: 0.10.2
2
+ version: 0.10.3
3
3
  description: Cursor IDE integration (maintains .cursorrules and generates user skills in .cursor/rules/)
4
4
  author: unoxen
5
5
  homepage: https://github.com/unoxen/repo-nexus
@@ -1,5 +1,5 @@
1
1
  name: gemini
2
- version: 0.10.2
2
+ version: 0.10.3
3
3
  description: Google Gemini and Antigravity integration (maintains GEMINI.md instructions and generates user skills in .agents/skills/)
4
4
  author: unoxen
5
5
  homepage: https://github.com/unoxen/repo-nexus
@@ -98,6 +98,8 @@ plugins:
98
98
  sources:
99
99
  - docs
100
100
  - "repos/**/README.md"
101
+ # Optional excluded files, directories, and/or glob patterns (default: [])
102
+ exclude: []
101
103
 
102
104
  # Directory paths and control files relative to workspace root (defaults shown)
103
105
  wikiDir: ".rnex/wiki" # Directory for curated flat markdown shards
@@ -105,6 +107,7 @@ plugins:
105
107
  logFile: "log.md" # Chronological audit log filename
106
108
  btreeRootMaxLines: 80 # Maximum allowed lines in root indexFile
107
109
  btreeShardMaxEntries: 100 # Threshold before splitting a B-Tree shard
110
+ recordSummaryMaxLength: 100 # Maximum character length of each wiki record summary
108
111
  logMaxRecords: 1000 # Maximum rolling records in logFile
109
112
  relativeLinks: "rewrite" # Relative link strategy: "rewrite" or "strip"
110
113
  ```
@@ -203,42 +203,140 @@ upsert_wiki_entry_line() {
203
203
 
204
204
  # -----------------------------------------------------------------------------
205
205
  # extract_markdown_title_and_summary
206
- # Summary: Extracts the first H1 heading and first non-empty prose paragraph
207
- # from a Markdown file, skipping YAML frontmatter and code blocks.
208
- # @param $1: abs_file_path - Absolute path to the Markdown document.
209
- # @param $2: fallback_title - Fallback title if no H1 heading exists.
206
+ # Summary: Extracts a canonical entry title and bounded summary from any
207
+ # workspace source file:
208
+ # - For Markdown files (*.md, *.mdx, *.markdown): extracts the first
209
+ # H1 heading as title (falling back to $2) and reads all readable
210
+ # Markdown headers ordered by level (#, then ##, then ### and
211
+ # lower) up to max_summary_len, skipping YAML frontmatter and
212
+ # fenced code blocks.
213
+ # - For non-Markdown files: uses $2 (filename) as title and reads
214
+ # all readable '#' comment lines (skipping shebangs, shellcheck
215
+ # directives, and decorative dividers) up to max_summary_len.
216
+ # - If a file has no readable headers or '#' comments, returns an
217
+ # empty summary string so only the title link is emitted.
218
+ # @param $1: abs_file_path - Absolute path to the workspace source file.
219
+ # @param $2: fallback_title - Fallback title (e.g. basename) if no H1 exists.
220
+ # @param $3: max_summary_len - Maximum summary character length (default: 100).
210
221
  # @returns: "<title>|<summary>" on stdout.
211
222
  # @pure
212
223
  # -----------------------------------------------------------------------------
213
224
  extract_markdown_title_and_summary() {
214
225
  _file="$1"
215
226
  _fallback="$2"
216
- LC_ALL=C awk -v def_title="$_fallback" '
217
- BEGIN { in_frontmatter=0; in_code=0; title=""; summary="" }
218
- NR == 1 && /^---[[:space:]]*$/ { in_frontmatter=1; next }
219
- in_frontmatter == 1 {
220
- if (/^(---|\.\.\.)[[:space:]]*$/) in_frontmatter=0
221
- next
227
+ _max_len="${3:-${RNEX_WIKI_RECORD_SUMMARY_MAX_LENGTH:-100}}"
228
+ case "$_max_len" in
229
+ ''|*[!0-9]*|0) _max_len=100 ;;
230
+ esac
231
+
232
+ _is_md=0
233
+ case "$_file" in
234
+ *.md|*.MD|*.mdx|*.MDX|*.markdown|*.MARKDOWN)
235
+ _is_md=1
236
+ ;;
237
+ *.png|*.PNG|*.jpg|*.JPG|*.jpeg|*.JPEG|*.gif|*.GIF|*.webp|*.WEBP|*.ico|*.ICO|*.bmp|*.BMP|*.tiff|*.TIFF|*.pdf|*.PDF|*.zip|*.ZIP|*.tar|*.TAR|*.gz|*.GZ|*.tgz|*.TGZ|*.bz2|*.BZ2|*.xz|*.XZ|*.7z|*.7Z|*.rar|*.RAR|*.woff|*.WOFF|*.woff2|*.WOFF2|*.ttf|*.TTF|*.otf|*.OTF|*.eot|*.EOT|*.mp3|*.MP3|*.mp4|*.MP4|*.wav|*.WAV|*.ogg|*.OGG|*.webm|*.WEBM|*.mov|*.MOV|*.avi|*.AVI|*.wasm|*.WASM|*.o|*.a|*.so|*.dylib|*.dll|*.DLL|*.exe|*.EXE|*.bin|*.BIN|*.pyc|*.class|*.jar|*.JAR|*.db|*.DB|*.sqlite|*.sqlite3)
238
+ printf '%s|\n' "$_fallback"
239
+ return 0
240
+ ;;
241
+ esac
242
+
243
+ LC_ALL=C awk -v def_title="$_fallback" -v is_md="$_is_md" -v max_len="$_max_len" '
244
+ function clean_line(s) {
245
+ gsub(/\r/, "", s)
246
+ gsub(/[\001-\037\177|]/, " ", s)
247
+ gsub(/ +/, " ", s)
248
+ sub(/^ +/, "", s)
249
+ sub(/ +$/, "", s)
250
+ return s
251
+ }
252
+ function is_readable(s) {
253
+ return (s ~ /[a-zA-Z0-9]/)
254
+ }
255
+ function visible_len(s, tmp) {
256
+ tmp = s
257
+ while (match(tmp, /\]\([^()]*\)/)) {
258
+ tmp = substr(tmp, 1, RSTART) substr(tmp, RSTART + RLENGTH)
259
+ }
260
+ return length(tmp)
261
+ }
262
+ BEGIN {
263
+ in_frontmatter = 0
264
+ in_code = 0
265
+ title = ""
266
+ summary = ""
267
+ max_lvl = 0
268
+ }
269
+ /[\001-\010\013\014\016-\037\177]/ {
270
+ if (is_md == 0) {
271
+ summary = ""
272
+ exit
273
+ }
222
274
  }
223
- /^```/ { in_code = !in_code; next }
224
- in_code == 1 { next }
225
- title == "" && /^#[[:space:]]+/ {
226
- line = $0
227
- sub(/^#[[:space:]]+/, "", line)
228
- gsub(/\r/, "", line)
229
- gsub(/[|*]/, " ", line)
230
- title = line
275
+ is_md == 1 {
276
+ if (NR == 1 && /^---[[:space:]]*$/) {
277
+ in_frontmatter = 1
278
+ next
279
+ }
280
+ if (in_frontmatter == 1) {
281
+ if (/^(---|\.\.\.)[[:space:]]*$/) in_frontmatter = 0
282
+ next
283
+ }
284
+ if (/^[[:space:]]*(```|~~~)/) {
285
+ in_code = !in_code
286
+ next
287
+ }
288
+ if (in_code == 1) next
289
+
290
+ if (/^[[:space:]]*#+[[:space:]]+/) {
291
+ line = $0
292
+ sub(/^[[:space:]]*/, "", line)
293
+ match(line, /^#+/)
294
+ lvl = RLENGTH
295
+ sub(/^#+[[:space:]]+/, "", line)
296
+ sub(/[[:space:]]+#+[[:space:]]*$/, "", line)
297
+ line = clean_line(line)
298
+ if (is_readable(line)) {
299
+ if (lvl == 1 && title == "") {
300
+ t_line = line
301
+ gsub(/[*]/, " ", t_line)
302
+ t_line = clean_line(t_line)
303
+ if (t_line != "") title = t_line
304
+ }
305
+ hdr_cnt[lvl]++
306
+ hdrs[lvl, hdr_cnt[lvl]] = line
307
+ if (lvl > max_lvl) max_lvl = lvl
308
+ }
309
+ }
231
310
  next
232
311
  }
233
- title != "" && summary == "" && $0 !~ /^[[:space:]]*$/ && $0 !~ /^[#>-]/ && $0 !~ /^\|/ {
234
- line = $0
235
- gsub(/\r/, "", line)
236
- summary = line
237
- exit
312
+ is_md == 0 {
313
+ if (NR == 1 && /^#!/) next
314
+ if (/^[[:space:]]*#[[:space:]]*shellcheck[[:space:]]/) next
315
+ if (/^[[:space:]]*#[[:space:]]*(include|define|undef|ifdef|ifndef|if|elif|else|endif|pragma|error|line)([[:space:]<"(]|$)/) next
316
+ if (/^[[:space:]]*#/) {
317
+ line = $0
318
+ sub(/^[[:space:]]*#+[[:space:]]*/, "", line)
319
+ sub(/[[:space:]]*#+[[:space:]]*$/, "", line)
320
+ line = clean_line(line)
321
+ if (is_readable(line)) {
322
+ summary = (summary == "") ? line : (summary " " line)
323
+ if (visible_len(summary) >= (max_len + 0)) exit
324
+ }
325
+ }
238
326
  }
239
327
  END {
240
328
  if (title == "") title = def_title
241
- if (summary == "") summary = "Workspace documentation page."
329
+ if (is_md == 1) {
330
+ for (l = 1; l <= max_lvl; l++) {
331
+ c = hdr_cnt[l] + 0
332
+ for (i = 1; i <= c; i++) {
333
+ h = hdrs[l, i]
334
+ summary = (summary == "") ? h : (summary " " h)
335
+ if (visible_len(summary) >= (max_len + 0)) break
336
+ }
337
+ if (visible_len(summary) >= (max_len + 0)) break
338
+ }
339
+ }
242
340
  printf "%s|%s\n", title, summary
243
341
  }
244
342
  ' "$_file"
@@ -266,7 +364,9 @@ resolve_wiki_up_prefix() {
266
364
  # build_wiki_entry_line
267
365
  # Summary: Builds the canonical catalog entry line for a workspace document
268
366
  # directly from its authoritative source content:
269
- # - **[<H1 title>](<up_prefix><rel_path>)** (`<rel_path>`) — <summary>
367
+ # - **[<title>](<up_prefix><rel_path>)** (`<rel_path>`) — <summary>
368
+ # or, when the file has no readable headers or '#' comments:
369
+ # - **[<title>](<up_prefix><rel_path>)** (`<rel_path>`)
270
370
  # This is the SINGLE source of truth for entry construction. Ingest
271
371
  # uses it to create/replace entries; deep lint uses it to detect and
272
372
  # refresh stale entries. Sharing it guarantees ingest and lint can
@@ -275,6 +375,7 @@ resolve_wiki_up_prefix() {
275
375
  # @param $1: rel_path - Workspace-relative path of the source document.
276
376
  # @param $2: up_prefix - Upward prefix from the wiki dir to the workspace root.
277
377
  # @param $3: links_mode - Relative link strategy: "rewrite" (default) or "strip".
378
+ # @param $4: max_len - Optional max summary length (defaults to RNEX_WIKI_RECORD_SUMMARY_MAX_LENGTH or 100).
278
379
  # @returns: Canonical entry line on stdout and exit 0; exit 1 (no output) if
279
380
  # the source document does not exist as a regular file.
280
381
  # @pure (reads the source document only; invoke via "$(...)")
@@ -283,34 +384,44 @@ build_wiki_entry_line() {
283
384
  _bwe_rel="$1"
284
385
  _bwe_up="$2"
285
386
  _bwe_mode="${3:-rewrite}"
387
+ _bwe_max_len="${4:-${RNEX_WIKI_RECORD_SUMMARY_MAX_LENGTH:-100}}"
286
388
  _bwe_abs="${RNEX_WORKSPACE_ROOT}/${_bwe_rel}"
287
389
 
288
390
  # Only regular files can be indexed (symlinks/dirs are rejected upstream).
289
391
  [ -f "$_bwe_abs" ] || return 1
290
392
 
291
- # 1. Extract raw H1 title and first prose paragraph from the source.
292
- _bwe_meta="$(extract_markdown_title_and_summary "$_bwe_abs" "$(basename "$_bwe_rel")")"
393
+ # 1. Extract raw title and headers/comments summary from the source.
394
+ _bwe_meta="$(extract_markdown_title_and_summary "$_bwe_abs" "$(basename "$_bwe_rel")" "$_bwe_max_len")"
293
395
  _bwe_raw_title="${_bwe_meta%%|*}"
294
396
  _bwe_raw_summary="${_bwe_meta#*|}"
295
397
 
296
398
  # 2. Title: strip link markup, sanitize, and drop characters that would
297
399
  # break the "**[title](link)**" entry grammar.
298
- _bwe_title="$(sanitize_markdown_summary "$(strip_markdown_links "$_bwe_raw_title")")"
400
+ _bwe_title="$(sanitize_markdown_summary "$(strip_markdown_links "$_bwe_raw_title")" 140)"
299
401
  _bwe_title="$(printf '%s' "$_bwe_title" | tr -d '[]*')"
300
402
  [ -n "$_bwe_title" ] || _bwe_title="$(basename "$_bwe_rel")"
301
403
 
302
- # 3. Summary: re-anchor relative links from the wiki dir (or strip them),
303
- # then sanitize to a bounded single line.
304
- _bwe_summary="$(rewrite_markdown_links_in_summary \
305
- "$_bwe_raw_summary" \
306
- "$_bwe_rel" \
307
- "$RNEX_WORKSPACE_ROOT" \
308
- "$_bwe_up" \
309
- "$_bwe_mode")"
310
- _bwe_summary="$(sanitize_markdown_summary "$_bwe_summary")"
311
-
312
- printf -- '- **[%s](%s%s)** (`%s`) — %s\n' \
313
- "$_bwe_title" "$_bwe_up" "$_bwe_rel" "$_bwe_rel" "$_bwe_summary"
404
+ # 3. Summary: if readable headers or comments exist, re-anchor relative
405
+ # links from the wiki dir (or strip them), then sanitize and truncate
406
+ # to the configured recordSummaryMaxLength.
407
+ _bwe_summary=""
408
+ if [ -n "$_bwe_raw_summary" ]; then
409
+ _bwe_summary="$(rewrite_markdown_links_in_summary \
410
+ "$_bwe_raw_summary" \
411
+ "$_bwe_rel" \
412
+ "$RNEX_WORKSPACE_ROOT" \
413
+ "$_bwe_up" \
414
+ "$_bwe_mode")"
415
+ _bwe_summary="$(sanitize_markdown_summary "$_bwe_summary" "$_bwe_max_len")"
416
+ fi
417
+
418
+ if [ -n "$_bwe_summary" ]; then
419
+ printf -- '- **[%s](%s%s)** (`%s`) — %s\n' \
420
+ "$_bwe_title" "$_bwe_up" "$_bwe_rel" "$_bwe_rel" "$_bwe_summary"
421
+ else
422
+ printf -- '- **[%s](%s%s)** (`%s`)\n' \
423
+ "$_bwe_title" "$_bwe_up" "$_bwe_rel" "$_bwe_rel"
424
+ fi
314
425
  return 0
315
426
  }
316
427
 
@@ -99,6 +99,34 @@ load_wiki_config_contract() {
99
99
 
100
100
  RNEX_WORKSPACE_ROOT="${_ws_root%/}"
101
101
 
102
+ # Resolve workspace member repositories directory (default: repos)
103
+ if [ -z "${RNEX_CFG_REPOS_DIR:-}" ]; then
104
+ _cfg_rdir=""
105
+ if command -v yaml_get_repos_dir >/dev/null 2>&1; then
106
+ _cfg_rdir="$(yaml_get_repos_dir 2>/dev/null || true)"
107
+ fi
108
+ if [ -z "$_cfg_rdir" ]; then
109
+ for _rcf in "${RNEX_WORKSPACE_ROOT}/.local.rnex.yaml" "${RNEX_WORKSPACE_ROOT}/rnex.yaml"; do
110
+ [ -f "$_rcf" ] || continue
111
+ _cfg_rdir="$(LC_ALL=C awk '
112
+ /^reposDir:[ ]*/ {
113
+ line = $0
114
+ sub(/^[^:]+:[ ]*/, "", line)
115
+ sub(/[ ]*#.*$/, "", line)
116
+ gsub(/^["\047]|["\047]$/, "", line)
117
+ print line
118
+ exit
119
+ }
120
+ ' "$_rcf" 2>/dev/null)"
121
+ [ -n "$_cfg_rdir" ] && break
122
+ done
123
+ fi
124
+ _cfg_rdir="${_cfg_rdir#./}"
125
+ _cfg_rdir="${_cfg_rdir%/}"
126
+ [ -n "$_cfg_rdir" ] || _cfg_rdir="repos"
127
+ RNEX_CFG_REPOS_DIR="$_cfg_rdir"
128
+ fi
129
+
102
130
  # Default wiki directory is strictly encapsulated inside .rnex/wiki
103
131
  if [ -n "${RNEX_CFG_WIKI_DIR:-}" ]; then
104
132
  _wiki_rel="$RNEX_CFG_WIKI_DIR"
@@ -166,8 +194,16 @@ load_wiki_config_contract() {
166
194
  [ -n "$RNEX_WIKI_LOG_MAX_RECORDS" ] || RNEX_WIKI_LOG_MAX_RECORDS=1000
167
195
  fi
168
196
 
197
+ # Record summary capacity: maximum character length of each wiki record summary (default: 100)
198
+ if [ -n "${RNEX_CFG_RECORD_SUMMARY_MAX_LENGTH:-}" ]; then
199
+ RNEX_WIKI_RECORD_SUMMARY_MAX_LENGTH="$RNEX_CFG_RECORD_SUMMARY_MAX_LENGTH"
200
+ else
201
+ RNEX_WIKI_RECORD_SUMMARY_MAX_LENGTH="$(_lookup_llm_wiki_cfg "recordSummaryMaxLength")"
202
+ [ -n "$RNEX_WIKI_RECORD_SUMMARY_MAX_LENGTH" ] || RNEX_WIKI_RECORD_SUMMARY_MAX_LENGTH=100
203
+ fi
204
+
169
205
  # Enforce strictly positive integers for capacity thresholds
170
- for _num_val in "$RNEX_WIKI_BTREE_MAX_ROOT_LINES" "$RNEX_WIKI_BTREE_SHARD_MAX_ENTRIES" "$RNEX_WIKI_LOG_MAX_RECORDS"; do
206
+ for _num_val in "$RNEX_WIKI_BTREE_MAX_ROOT_LINES" "$RNEX_WIKI_BTREE_SHARD_MAX_ENTRIES" "$RNEX_WIKI_LOG_MAX_RECORDS" "$RNEX_WIKI_RECORD_SUMMARY_MAX_LENGTH"; do
171
207
  case "$_num_val" in
172
208
  ''|*[!0-9]*|0)
173
209
  printf 'Error [config]: Numeric threshold "%s" must be a positive integer.\n' "$_num_val" >&2
@@ -193,10 +229,11 @@ load_wiki_config_contract() {
193
229
  ;;
194
230
  esac
195
231
 
196
- export RNEX_WORKSPACE_ROOT RNEX_WIKI_REL_DIR RNEX_WIKI_ROOT \
232
+ export RNEX_WORKSPACE_ROOT RNEX_CFG_REPOS_DIR RNEX_WIKI_REL_DIR RNEX_WIKI_ROOT \
197
233
  RNEX_WIKI_INDEX_FILE RNEX_WIKI_LOG_FILE RNEX_WIKI_UP_PREFIX \
198
234
  RNEX_WIKI_BTREE_MAX_ROOT_LINES RNEX_WIKI_BTREE_SHARD_MAX_ENTRIES \
199
- RNEX_WIKI_RELATIVE_LINKS RNEX_WIKI_LOG_MAX_RECORDS
235
+ RNEX_WIKI_RELATIVE_LINKS RNEX_WIKI_LOG_MAX_RECORDS \
236
+ RNEX_WIKI_RECORD_SUMMARY_MAX_LENGTH
200
237
 
201
238
  return 0
202
239
  }
@@ -120,9 +120,13 @@ _lint_heal_entry_shallow() {
120
120
  "${RNEX_WIKI_UP_PREFIX:-../../}" \
121
121
  "${RNEX_WIKI_RELATIVE_LINKS:-rewrite}" \
122
122
  "1")"
123
- _lhs_healed_sum="$(sanitize_markdown_summary "$_lhs_healed_sum")"
123
+ _lhs_healed_sum="$(sanitize_markdown_summary "$_lhs_healed_sum" "${RNEX_WIKI_RECORD_SUMMARY_MAX_LENGTH:-100}")"
124
124
  if [ "$_lhs_healed_sum" != "$_lhs_sum" ]; then
125
- _lhs_line="${_lhs_prefix} — ${_lhs_healed_sum}"
125
+ if [ -n "$_lhs_healed_sum" ]; then
126
+ _lhs_line="${_lhs_prefix} — ${_lhs_healed_sum}"
127
+ else
128
+ _lhs_line="${_lhs_prefix}"
129
+ fi
126
130
  _lhs_changed=1
127
131
  append_wiki_log_entry "lint" "updated: \`${_lhs_rel}\` in \`${_lhs_shard}\` (auto-healed broken link targets)"
128
132
  fi
@@ -33,22 +33,27 @@ fi
33
33
  RNEX_LLM_WIKI_SOURCE_HELPERS_SH_SOURCED=1
34
34
 
35
35
  # -----------------------------------------------------------------------------
36
- # parse_configured_workspace_sources
37
- # Summary: Parses the `plugins.llm-wiki.sources` list from .local.rnex.yaml
38
- # (Priority 1) or rnex.yaml (Priority 2). Supports both YAML block
39
- # sequences (`- item`) and inline arrays (`sources: [...]`).
40
- # Falls back to default sources when unconfigured.
36
+ # _parse_llm_wiki_config_list
37
+ # Summary: Parses a list-valued key (`sources` or `exclude`) under
38
+ # `plugins.llm-wiki` from .local.rnex.yaml (Priority 1) or rnex.yaml
39
+ # (Priority 2). Supports YAML block sequences (`- item`), inline
40
+ # arrays (`key: [...]`), and empty arrays (`key: []`), and expands
41
+ # `{reposDir}`.
41
42
  # @param $1: workspace_root - Absolute path to workspace root.
42
- # @returns: Newline-delimited source specifications on stdout.
43
+ # @param $2: list_key - Configuration list key name ("sources" or "exclude").
44
+ # @returns: 0 and newline-delimited items on stdout if key was explicitly found
45
+ # in config (even if empty); 1 if key was not configured in either file.
43
46
  # @pure (Read-only configuration inspection)
44
47
  # -----------------------------------------------------------------------------
45
- parse_configured_workspace_sources() {
46
- _ws_root="$1"
47
- _found_sources=""
48
+ _parse_llm_wiki_config_list() {
49
+ _pcl_ws_root="$1"
50
+ _pcl_key="$2"
51
+ _pcl_repos_dir="${RNEX_CFG_REPOS_DIR:-repos}"
52
+ _pcl_repos_dir="${_pcl_repos_dir%/}"
48
53
 
49
- for _cfg_file in "${_ws_root}/.local.rnex.yaml" "${_ws_root}/rnex.yaml"; do
50
- [ -f "$_cfg_file" ] || continue
51
- _extracted="$(LC_ALL=C awk '
54
+ for _pcl_cfg_file in "${_pcl_ws_root}/.local.rnex.yaml" "${_pcl_ws_root}/rnex.yaml"; do
55
+ [ -f "$_pcl_cfg_file" ] || continue
56
+ _pcl_res="$(LC_ALL=C awk -v target_key="$_pcl_key" '
52
57
  function clean_token(s) {
53
58
  gsub(/\r/, "", s)
54
59
  sub(/[[:space:]]+#.*$/, "", s)
@@ -67,6 +72,7 @@ parse_configured_workspace_sources() {
67
72
  if (tok != "") print tok
68
73
  }
69
74
  }
75
+ BEGIN { found_key = 0 }
70
76
  /^[[:space:]]*#/ || /^[[:space:]]*$/ { next }
71
77
  {
72
78
  match($0, /^[ ]*/)
@@ -74,40 +80,63 @@ parse_configured_workspace_sources() {
74
80
  line = substr($0, indent + 1)
75
81
 
76
82
  if (indent == 0) {
77
- in_plugins = (line ~ /^plugins:[[:space:]]*$/)
83
+ in_plugins = (line ~ /^plugins:[[:space:]]*(#.*)?$/)
78
84
  in_llm_wiki = 0
79
- in_llm_wiki_sources = 0
85
+ in_target_list = 0
80
86
  next
81
87
  }
82
88
  if (in_plugins) {
83
89
  if (indent == 2 && line ~ /^[^[:space:]-][^:]*:/) {
84
- in_llm_wiki = (line ~ /^llm-wiki:[[:space:]]*$/)
85
- in_llm_wiki_sources = 0
90
+ in_llm_wiki = (line ~ /^llm-wiki:[[:space:]]*(#.*)?$/)
91
+ in_target_list = 0
86
92
  next
87
93
  }
88
94
  if (in_llm_wiki) {
89
- if (line ~ /^sources:[[:space:]]*\[.*\][[:space:]]*$/) {
90
- sub(/^sources:[[:space:]]*/, "", line)
95
+ if (line ~ ("^" target_key ":[[:space:]]*\\[.*\\][[:space:]]*(#.*)?$")) {
96
+ found_key = 1
97
+ sub(("^" target_key ":[[:space:]]*"), "", line)
98
+ sub(/[[:space:]]+#.*$/, "", line)
91
99
  emit_inline(line)
92
- in_llm_wiki_sources = 0
93
- } else if (line ~ /^sources:[[:space:]]*$/) {
94
- in_llm_wiki_sources = 1
95
- } else if (in_llm_wiki_sources && line ~ /^-[[:space:]]+/) {
100
+ in_target_list = 0
101
+ } else if (line ~ ("^" target_key ":[[:space:]]*(#.*)?$")) {
102
+ found_key = 1
103
+ in_target_list = 1
104
+ } else if (in_target_list && line ~ /^-[[:space:]]+/) {
96
105
  sub(/^-[[:space:]]+/, "", line)
97
106
  tok = clean_token(line)
98
107
  if (tok != "") print tok
99
108
  } else if (line !~ /^-[[:space:]]+/) {
100
- in_llm_wiki_sources = 0
109
+ in_target_list = 0
101
110
  }
102
111
  }
103
112
  }
104
113
  }
105
- ' "$_cfg_file")"
106
- if [ -n "$_extracted" ]; then
107
- _found_sources="$_extracted"
108
- break
109
- fi
114
+ END {
115
+ if (found_key == 1) exit 0
116
+ exit 1
117
+ }
118
+ ' "$_pcl_cfg_file")" && {
119
+ if [ -n "$_pcl_res" ]; then
120
+ printf '%s\n' "$_pcl_res" | sed "s|{reposDir}|${_pcl_repos_dir}|g"
121
+ fi
122
+ return 0
123
+ }
110
124
  done
125
+ return 1
126
+ }
127
+
128
+ # -----------------------------------------------------------------------------
129
+ # parse_configured_workspace_sources
130
+ # Summary: Parses the `plugins.llm-wiki.sources` list from .local.rnex.yaml
131
+ # (Priority 1) or rnex.yaml (Priority 2). Falls back to default
132
+ # sources when unconfigured.
133
+ # @param $1: workspace_root - Absolute path to workspace root.
134
+ # @returns: Newline-delimited source specifications on stdout.
135
+ # @pure (Read-only configuration inspection)
136
+ # -----------------------------------------------------------------------------
137
+ parse_configured_workspace_sources() {
138
+ _ws_root="$1"
139
+ _found_sources="$(_parse_llm_wiki_config_list "$_ws_root" "sources" || true)"
111
140
 
112
141
  # Fall back to default candidate sources defined in plugin.yaml config_defaults
113
142
  if [ -z "$_found_sources" ]; then
@@ -122,6 +151,105 @@ ${_repos_dir}/**/README.md"
122
151
  return 0
123
152
  }
124
153
 
154
+ # -----------------------------------------------------------------------------
155
+ # parse_configured_workspace_excludes
156
+ # Summary: Parses the `plugins.llm-wiki.exclude` list from .local.rnex.yaml
157
+ # (Priority 1) or rnex.yaml (Priority 2). Defaults to empty (nothing
158
+ # excluded by default).
159
+ # @param $1: workspace_root - Absolute path to workspace root.
160
+ # @returns: Newline-delimited exclude specifications on stdout (empty if unset).
161
+ # @pure (Read-only configuration inspection)
162
+ # -----------------------------------------------------------------------------
163
+ parse_configured_workspace_excludes() {
164
+ _ws_root="$1"
165
+ _parse_llm_wiki_config_list "$_ws_root" "exclude" || true
166
+ return 0
167
+ }
168
+
169
+ # -----------------------------------------------------------------------------
170
+ # is_path_excluded_by_spec
171
+ # Summary: Evaluates whether a workspace-relative file path matches a single
172
+ # `plugins.llm-wiki.exclude` specification (exact file path, directory
173
+ # path prefix, or POSIX glob / globstar pattern).
174
+ # @param $1: candidate_rel_path - Normalized workspace-relative file path.
175
+ # @param $2: exclude_spec - Configured exclude file, directory, or glob pattern.
176
+ # @returns: 0 if the path is excluded by the specification; 1 otherwise.
177
+ # @pure
178
+ # -----------------------------------------------------------------------------
179
+ is_path_excluded_by_spec() {
180
+ _ipe_path="$1"
181
+ _ipe_spec="$(printf '%s' "$2" | tr -d '\r')"
182
+ [ -n "$_ipe_path" ] && [ -n "$_ipe_spec" ] || return 1
183
+
184
+ while [ "${_ipe_spec#./}" != "$_ipe_spec" ]; do _ipe_spec="${_ipe_spec#./}"; done
185
+ _ipe_spec="${_ipe_spec%/}"
186
+ [ -n "$_ipe_spec" ] || return 1
187
+
188
+ # 1. Exact file path match
189
+ if [ "$_ipe_path" = "$_ipe_spec" ]; then
190
+ return 0
191
+ fi
192
+
193
+ # 2. Directory path prefix match (e.g., exclude: ["docs/.vitepress"])
194
+ case "$_ipe_path" in
195
+ "${_ipe_spec}/"*)
196
+ return 0
197
+ ;;
198
+ esac
199
+
200
+ # 3. Glob or globstar pattern match (for files or directory trees)
201
+ if match_globstar_path "$_ipe_path" "$_ipe_spec" "$RNEX_WORKSPACE_ROOT"; then
202
+ return 0
203
+ fi
204
+ if match_globstar_path "$_ipe_path" "${_ipe_spec}/**" "$RNEX_WORKSPACE_ROOT"; then
205
+ return 0
206
+ fi
207
+
208
+ return 1
209
+ }
210
+
211
+ # -----------------------------------------------------------------------------
212
+ # filter_excluded_sources
213
+ # Summary: Filters a file of candidate workspace-relative paths in-place,
214
+ # removing any path that matches a pattern, file, or directory in
215
+ # `plugins.llm-wiki.exclude`. When `exclude` is empty (default),
216
+ # performs zero filtering.
217
+ # @param $1: candidates_file - File containing candidate workspace_rel_paths.
218
+ # @returns: 0 on success.
219
+ # @sideEffects: Atomically updates $1 with excluded paths removed.
220
+ # -----------------------------------------------------------------------------
221
+ filter_excluded_sources() {
222
+ _fes_file="$1"
223
+ [ -s "$_fes_file" ] || return 0
224
+
225
+ _fes_excludes="$(parse_configured_workspace_excludes "$RNEX_WORKSPACE_ROOT")"
226
+ [ -n "$_fes_excludes" ] || return 0
227
+
228
+ _fes_ex_tmp="${_fes_file}.exspecs.$$"
229
+ _fes_out_tmp="${_fes_file}.exout.$$"
230
+ printf '%s\n' "$_fes_excludes" > "$_fes_ex_tmp"
231
+ : > "$_fes_out_tmp"
232
+
233
+ while IFS= read -r _fes_cand <&3; do
234
+ [ -n "$_fes_cand" ] || continue
235
+ _fes_drop=0
236
+ while IFS= read -r _fes_spec <&4; do
237
+ [ -n "$_fes_spec" ] || continue
238
+ if is_path_excluded_by_spec "$_fes_cand" "$_fes_spec"; then
239
+ _fes_drop=1
240
+ break
241
+ fi
242
+ done 4< "$_fes_ex_tmp"
243
+ if [ "$_fes_drop" -eq 0 ]; then
244
+ printf '%s\n' "$_fes_cand" >> "$_fes_out_tmp"
245
+ fi
246
+ done 3< "$_fes_file"
247
+
248
+ mv "$_fes_out_tmp" "$_fes_file"
249
+ rm -f "$_fes_ex_tmp"
250
+ return 0
251
+ }
252
+
125
253
  # -----------------------------------------------------------------------------
126
254
  # _is_workspace_source_enabled
127
255
  # Summary: Verifies whether a candidate workspace-relative file path belongs
@@ -212,7 +340,7 @@ derive_shard_id_for_workspace_path() {
212
340
  # expand_single_source_spec
213
341
  # Summary: Expands a single source specification (regular file, directory, or
214
342
  # glob pattern including "**") into normalized workspace-relative
215
- # Markdown file paths, rejecting symlinks, disabled member repos,
343
+ # file paths, rejecting symlinks, disabled member repos,
216
344
  # and the wiki directory itself.
217
345
  # @param $1: source_spec - File path, directory path, or glob pattern.
218
346
  # @param $2: out_candidates_file - Output file to append discovered paths.
@@ -243,7 +371,7 @@ expand_single_source_spec() {
243
371
  [ -n "$_prefix" ] && _search_root="${RNEX_WORKSPACE_ROOT}/${_prefix#./}"
244
372
  [ -d "$_search_root" ] || return 0
245
373
 
246
- find "$_search_root" -type f \( -name '*.md' -o -name '*.mdx' \) \
374
+ find "$_search_root" -type f \
247
375
  ! -path "${RNEX_WIKI_ROOT}/*" ! -path '*/.rnex/*' ! -path '*/.git/*' ! -path '*/node_modules/*' -print \
248
376
  | while IFS= read -r _found_abs; do
249
377
  [ -L "$_found_abs" ] && continue
@@ -271,9 +399,9 @@ expand_single_source_spec() {
271
399
  return 0
272
400
  fi
273
401
 
274
- # Case 4: Directory -> recursively find all regular .md/.mdx files
402
+ # Case 4: Directory -> recursively find all regular files
275
403
  if [ -d "$_abs_spec" ]; then
276
- find "$_abs_spec" -type f \( -name '*.md' -o -name '*.mdx' \) \
404
+ find "$_abs_spec" -type f \
277
405
  ! -path "${RNEX_WIKI_ROOT}/*" ! -path '*/.rnex/*' ! -path '*/.git/*' ! -path '*/node_modules/*' -print \
278
406
  | while IFS= read -r _found_abs; do
279
407
  [ -L "$_found_abs" ] && continue
@@ -321,6 +449,7 @@ resolve_candidate_sources() {
321
449
  fi
322
450
 
323
451
  atomic_sort_unique_file "$_rcs_out" || true
452
+ filter_excluded_sources "$_rcs_out"
324
453
  return 0
325
454
  }
326
455
 
@@ -196,7 +196,8 @@ normalize_workspace_rel_path() {
196
196
  # -----------------------------------------------------------------------------
197
197
  # match_globstar_path
198
198
  # Summary: Evaluates whether a workspace-relative candidate path matches a
199
- # POSIX glob or recursive globstar (**) pattern.
199
+ # POSIX glob or recursive globstar (**) pattern (including leading
200
+ # "**/...", trailing ".../**", and multi-globstar ".../**/.../**").
200
201
  # @param $1: candidate_path - Workspace-relative file path.
201
202
  # @param $2: target_pattern - Glob or globstar pattern (e.g., "repos/**/README.md").
202
203
  # @param $3: workspace_root - Optional workspace root prefix to strip.
@@ -204,32 +205,82 @@ normalize_workspace_rel_path() {
204
205
  # @pure
205
206
  # -----------------------------------------------------------------------------
206
207
  match_globstar_path() {
207
- _candidate_path="$(printf '%s' "$1" | tr -d '"'\''' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
208
- _target_pat="$(printf '%s' "$2" | tr -d '"'\''' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
208
+ _candidate_path="$1"
209
+ _target_pat="$2"
209
210
  _ws_prefix="${3:-}"
210
211
 
212
+ case "$_candidate_path" in
213
+ *[\"\'\ \ ]*)
214
+ _candidate_path="$(printf '%s' "$_candidate_path" | tr -d '"'\''' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
215
+ ;;
216
+ esac
217
+ case "$_target_pat" in
218
+ *[\"\'\ \ ]*)
219
+ _target_pat="$(printf '%s' "$_target_pat" | tr -d '"'\''' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
220
+ ;;
221
+ esac
222
+
211
223
  while [ "${_candidate_path#./}" != "$_candidate_path" ]; do _candidate_path="${_candidate_path#./}"; done
212
224
  while [ "${_target_pat#./}" != "$_target_pat" ]; do _target_pat="${_target_pat#./}"; done
225
+ _target_pat="${_target_pat%/}"
213
226
 
214
227
  if [ -n "$_ws_prefix" ]; then
215
228
  _candidate_path="${_candidate_path#"${_ws_prefix%/}/"}"
216
229
  fi
217
230
 
218
- if [ "$_candidate_path" = "$_target_pat" ]; then
231
+ if [ "$_candidate_path" = "$_target_pat" ] || [ "$_target_pat" = "**" ]; then
219
232
  return 0
220
233
  fi
221
234
 
222
235
  case "$_target_pat" in
236
+ *\*\**\*\**)
237
+ # Multi-globstar pattern (e.g., "**/.vitepress/**" or "repos/**/dist/**")
238
+ _p1="${_target_pat%%\*\**}"
239
+ _rest="${_target_pat#*\*\*}"
240
+ _mid="${_rest%%\*\**}"
241
+ _p2="${_rest##*\*\*}"
242
+ _p1="${_p1#/}"
243
+ _p2="${_p2#/}"
244
+ _Virtual="/${_candidate_path}"
245
+ # shellcheck disable=SC2254
246
+ case "$_Virtual" in
247
+ "/${_p1}"*${_mid}*${_p2})
248
+ if [ -n "$_p2" ]; then
249
+ _exp_fn="${_p2##*/}"
250
+ _act_fn="${_candidate_path##*/}"
251
+ if [ -n "$_exp_fn" ] && [ "$_exp_fn" != "*" ]; then
252
+ case "$_act_fn" in
253
+ $_exp_fn) return 0 ;;
254
+ *) return 1 ;;
255
+ esac
256
+ fi
257
+ fi
258
+ return 0
259
+ ;;
260
+ *)
261
+ return 1
262
+ ;;
263
+ esac
264
+ ;;
223
265
  *\*\**)
224
266
  _prefix="${_target_pat%%\*\**}"
225
267
  _suffix="${_target_pat##*\*\*}"
226
268
  _suffix="${_suffix#/}"
227
269
 
270
+ if [ -z "$_suffix" ]; then
271
+ # Trailing globstar (e.g., "docs/**" or "docs/.vitepress/**")
272
+ # shellcheck disable=SC2254
273
+ case "$_candidate_path" in
274
+ $_prefix*) return 0 ;;
275
+ *) return 1 ;;
276
+ esac
277
+ fi
278
+
228
279
  # shellcheck disable=SC2254
229
280
  case "$_candidate_path" in
230
281
  "$_prefix"*$_suffix)
231
- _expected_filename="$(basename "$_suffix")"
232
- _actual_filename="$(basename "$_candidate_path")"
282
+ _expected_filename="${_suffix##*/}"
283
+ _actual_filename="${_candidate_path##*/}"
233
284
  if [ -n "$_expected_filename" ] && [ "$_expected_filename" != "*" ]; then
234
285
  case "$_actual_filename" in
235
286
  $_expected_filename) return 0 ;;
@@ -446,21 +497,27 @@ normalize_relative_path() {
446
497
  # sanitize_markdown_summary
447
498
  # Summary: Sanitizes a single-line summary string by stripping control chars,
448
499
  # tabs, pipes, and newlines that could corrupt Markdown table or list
449
- # formatting. Collapses consecutive whitespace and truncates to 140 chars
450
- # without slicing through unclosed Markdown links or brackets.
500
+ # formatting. Collapses consecutive whitespace and truncates to the
501
+ # configured maximum character length (default: 100) without slicing
502
+ # through unclosed Markdown links or brackets.
451
503
  # @param $1: raw_text - Input summary string.
452
- # @returns: Sanitized summary truncated to at most 140 characters on stdout.
504
+ # @param $2: max_len - Optional maximum character length (positive integer, default: 100).
505
+ # @returns: Sanitized summary truncated to at most max_len characters on stdout.
453
506
  # @pure
454
507
  # -----------------------------------------------------------------------------
455
508
  sanitize_markdown_summary() {
456
509
  [ -n "$1" ] || return 0
510
+ _sms_max="${2:-100}"
511
+ case "$_sms_max" in
512
+ ''|*[!0-9]*|0) _sms_max=100 ;;
513
+ esac
457
514
  printf '%s\n' "$1" \
458
515
  | tr '\t\r\n|' ' ' \
459
516
  | sed 's/ */ /g; s/^ //; s/ $//' \
460
- | LC_ALL=C awk '
461
- function safe_truncate(s, max_len, sub_s, i, ch, p, p_bra, p_open) {
462
- if (length(s) <= max_len) return s
463
- sub_s = substr(s, 1, max_len)
517
+ | LC_ALL=C awk -v max_len="$_sms_max" '
518
+ function safe_truncate(s, m_len, sub_s, i, ch, p, p_bra, p_open, anchor, pfx_end) {
519
+ if (length(s) <= m_len) return s
520
+ sub_s = substr(s, 1, m_len)
464
521
  p = 0
465
522
  for (i = length(sub_s); i >= 1; i--) {
466
523
  ch = substr(sub_s, i, 1)
@@ -470,7 +527,11 @@ sanitize_markdown_summary() {
470
527
  if (p > 0) {
471
528
  if (p > 1 && substr(sub_s, p - 1, 1) == "[") p--
472
529
  if (p > 1 && substr(sub_s, p - 1, 1) == "!") p--
473
- sub_s = substr(sub_s, 1, p - 1)
530
+ if (p > 1) {
531
+ sub_s = substr(sub_s, 1, p - 1)
532
+ } else {
533
+ sub(/^!?\[\[?/, "", sub_s)
534
+ }
474
535
  } else {
475
536
  p_bra = 0
476
537
  for (i = length(sub_s); i >= 1; i--) {
@@ -483,8 +544,14 @@ sanitize_markdown_summary() {
483
544
  if (substr(sub_s, i, 1) == "[") { p_open = i; break }
484
545
  }
485
546
  if (p_open > 0) {
486
- if (p_open > 1 && substr(sub_s, p_open - 1, 1) == "!") p_open--
487
- sub_s = substr(sub_s, 1, p_open - 1)
547
+ anchor = substr(sub_s, p_open + 1, p_bra - p_open - 1)
548
+ pfx_end = p_open - 1
549
+ if (pfx_end >= 1 && substr(sub_s, pfx_end, 1) == "!") pfx_end--
550
+ if (pfx_end >= 1) {
551
+ sub_s = substr(sub_s, 1, pfx_end)
552
+ } else {
553
+ sub_s = anchor
554
+ }
488
555
  }
489
556
  }
490
557
  }
@@ -492,7 +559,7 @@ sanitize_markdown_summary() {
492
559
  return sub_s
493
560
  }
494
561
  {
495
- print safe_truncate($0, 140)
562
+ print safe_truncate($0, max_len + 0)
496
563
  }
497
564
  '
498
565
  }
@@ -1,5 +1,5 @@
1
1
  name: llm-wiki
2
- version: 0.10.2
2
+ version: 0.10.3
3
3
  description: "Deterministic B-Tree Markdown Wiki (configurable via plugins.llm-wiki.wikiDir) for AI agents"
4
4
  config_defaults:
5
5
  wikiDir: ".rnex/wiki"
@@ -8,11 +8,13 @@ config_defaults:
8
8
  logMaxRecords: 1000
9
9
  btreeRootMaxLines: 80
10
10
  btreeShardMaxEntries: 100
11
+ recordSummaryMaxLength: 100
11
12
  relativeLinks: "rewrite"
12
13
  sources:
13
14
  - "README.md"
14
15
  - "docs"
15
16
  - "{reposDir}/**/README.md"
17
+ exclude: []
16
18
  commands:
17
19
  ingest:
18
20
  script: "bin/ingest.sh"
@@ -48,6 +48,7 @@ AI coding agents navigate wiki context via the 3-step zero-token-bloat protocol:
48
48
  - Execute `rnex plugin llm-wiki ingest [path/to/source]` under the hood. Pass `--force` (`-f`) to re-index already-cataloged documents after header or summary edits.
49
49
  - **NEVER** manually create, sort, or edit `{wikiDir}/{indexFile}` or `{wikiDir}/*.md` shard files.
50
50
  - By default, the CLI identifies which candidate sources from {sources} have not yet been indexed and appends only missing entries into their respective B-Tree shards. When `--force` (`-f`) is passed, existing entries matching the target path (or {sources}) are rebuilt from their authoritative source files and re-routed if their title changed.
51
+ - Each catalog entry extracts Markdown headers ordered by level (`#`, then `##`, then `###` and lower) or `#` comments for non-Markdown files up to {recordSummaryMaxLength} characters (emitting only the title link when no readable headers or comments exist).
51
52
  - B-Tree shards are maintained in strict `LC_ALL=C` sort order and split automatically above {btreeShardMaxEntries} entries.
52
53
  - `{wikiDir}/{indexFile}` is recompiled atomically (bounded to {btreeRootMaxLines} lines) to route to all existing shards.
53
54
  - Relative Markdown links in source summaries use the active `{relativeLinks}` mode from `{wikiDir}/` (pass `--strip-links` or `--rewrite-links` to override for a single run).
@@ -40,7 +40,7 @@ AI coding agents navigate wiki structure through:
40
40
  - Enforces zero symbolic links across `{wikiDir}/`.
41
41
 
42
42
  2. **Auto-Healing & Invariants:**
43
- - **Document Headers & Summaries (Deep by Default):** Reconstructs each catalog entry from its authoritative source document (H1 title, link target, and summary paragraph) and refreshes any stale entry in place. Pass `--shallow` to skip reading document content and validate only links and structure.
43
+ - **Document Headers & Summaries (Deep by Default):** Reconstructs each catalog entry from its authoritative source file (reading Markdown headers `#`, `##`, `###` and lower, or `#` comments up to {recordSummaryMaxLength} characters, or title link only when absent) and refreshes any stale entry in place. Pass `--shallow` to skip reading document content and validate only links and structure.
44
44
  - **Root Router:** Validates that `{wikiDir}/{indexFile}` exists and is within {btreeRootMaxLines} lines; auto-rebuilds router to index orphan shards and prune dead shard links.
45
45
  - **Workspace References:** Validates that every referenced workspace document in shard entries exists; prunes dead references to deleted files.
46
46
  - **Relative Link Integrity:** Validates all relative Markdown links and `[[wikilinks]]`.
@@ -44,6 +44,8 @@ _yaml_file="$_kl_pdir/plugin.yaml"
44
44
  # Assert flat B-Tree configuration defaults
45
45
  grep -q 'btreeShardMaxEntries:' "$_yaml_file" || { fail "btreeShardMaxEntries missing in plugin.yaml"; exit 1; }
46
46
  grep -q 'btreeRootMaxLines:' "$_yaml_file" || { fail "btreeRootMaxLines missing in plugin.yaml"; exit 1; }
47
+ grep -q 'recordSummaryMaxLength: 100' "$_yaml_file" || { fail "recordSummaryMaxLength default missing in plugin.yaml"; exit 1; }
48
+ grep -q 'exclude: \[\]' "$_yaml_file" || { fail "exclude: [] default missing in plugin.yaml"; exit 1; }
47
49
  grep -q 'wikiDir: "\.rnex/wiki"' "$_yaml_file" || { fail "wikiDir default missing in plugin.yaml"; exit 1; }
48
50
  grep -q 'indexFile: "index.md"' "$_yaml_file" || { fail "indexFile default missing in plugin.yaml"; exit 1; }
49
51
  grep -q 'logFile: "log.md"' "$_yaml_file" || { fail "logFile default missing in plugin.yaml"; exit 1; }
@@ -789,12 +791,12 @@ mkdir -p "$TEST_REWRITE_WS/docs/sub"
789
791
  printf '# Guide\nGuide content.\n' > "$TEST_REWRITE_WS/docs/guide.md"
790
792
  printf '# Submodule\nSubmodule content.\n' > "$TEST_REWRITE_WS/docs/sub/module.md"
791
793
 
792
- # Create a source document with intra-folder link, parent link, anchor link, and external link
794
+ # Create a source document with intra-folder link, parent link, anchor link, and external link in headers
793
795
  cat <<'EOF_INT_MD' > "$TEST_REWRITE_WS/docs/intro.md"
794
796
  # Introduction
795
- See [guide](guide.md), [sub/mod](sub/module.md), [sec](#setup), [web](https://example.com).
797
+ ## See [guide](guide.md), [sub/mod](sub/module.md), [sec](#setup), [web](https://example.com).
796
798
 
797
- ## Setup
799
+ ### Setup
798
800
  Setup details here.
799
801
  EOF_INT_MD
800
802
 
@@ -802,6 +804,7 @@ cat <<'EOF_REW_YAML' > "$TEST_REWRITE_WS/rnex.yaml"
802
804
  version: 1.0.0
803
805
  plugins:
804
806
  llm-wiki:
807
+ recordSummaryMaxLength: 180
805
808
  sources: [docs]
806
809
  repos:
807
810
  EOF_REW_YAML
@@ -843,10 +846,10 @@ setup_plugin_test_workspace llm-wiki "$TEST_STRIP_WS"
843
846
  cd "$TEST_STRIP_WS"
844
847
 
845
848
  mkdir -p "$TEST_STRIP_WS/docs"
846
- # Document with link in title and dead link in summary
849
+ # Document with link in title and dead link in header summary
847
850
  cat <<'EOF_DEAD_MD' > "$TEST_STRIP_WS/docs/dead.md"
848
851
  # [Getting Started](nonexistent/setup.md)
849
- Please consult [Dead Target](nonexistent/target.md) and [Real Real](real.md) for info.
852
+ ## Please consult [Dead Target](nonexistent/target.md) and [Real Real](real.md) for info.
850
853
  EOF_DEAD_MD
851
854
  printf '# Real Doc\nReal content.\n' > "$TEST_STRIP_WS/docs/real.md"
852
855
 
@@ -889,7 +892,7 @@ mkdir -p "$TEST_MODE_WS/docs"
889
892
  printf '# Target Doc\nTarget content.\n' > "$TEST_MODE_WS/docs/target.md"
890
893
  cat <<'EOF_MODE_MD' > "$TEST_MODE_WS/docs/source.md"
891
894
  # Source Doc
892
- Check out [Target Doc](target.md) and [External](https://repo-nexus.dev).
895
+ ## Check out [Target Doc](target.md) and [External](https://repo-nexus.dev).
893
896
  EOF_MODE_MD
894
897
 
895
898
  cat <<'EOF_MODE_YAML' > "$TEST_MODE_WS/rnex.yaml"
@@ -916,7 +919,7 @@ echo "$_mode_shard" | grep -q 'Check out Target Doc and \[External\](https://rep
916
919
  }
917
920
 
918
921
  # Test CLI flag --strip-links override
919
- printf '# Fresh One\nSee [Target Doc](target.md).\n' > "$TEST_MODE_WS/docs/fresh-one.md"
922
+ printf '# Fresh One\n## See [Target Doc](target.md).\n' > "$TEST_MODE_WS/docs/fresh-one.md"
920
923
  (cd "$TEST_MODE_WS" && ./rnex plugin llm-wiki ingest --strip-links docs/fresh-one.md >/dev/null)
921
924
  _fresh_shard="$(cat "$TEST_MODE_WS/.rnex/wiki/repo-nexus-docs.md")"
922
925
  echo "$_fresh_shard" | grep -q 'See Target Doc\.' || {
@@ -1675,6 +1678,7 @@ plugins:
1675
1678
  logMaxRecords: 250
1676
1679
  btreeRootMaxLines: 42
1677
1680
  btreeShardMaxEntries: 15
1681
+ recordSummaryMaxLength: 175
1678
1682
  relativeLinks: "strip"
1679
1683
  sources:
1680
1684
  - "guides"
@@ -1697,6 +1701,7 @@ grep -qF "services/" "$_proj_rules" || { fail "Custom reposDir missing in rules/
1697
1701
  grep -qF "42" "$_proj_rules" || { fail "Custom btreeRootMaxLines missing in rules/behavioral.md"; exit 1; }
1698
1702
  grep -qF "strip" "$_proj_ingest" || { fail "Custom relativeLinks missing in skills/ingest.md"; exit 1; }
1699
1703
  grep -qF "250" "$_proj_ingest" || { fail "Custom logMaxRecords missing in skills/ingest.md"; exit 1; }
1704
+ grep -qF "175" "$_proj_ingest" || { fail "Custom recordSummaryMaxLength missing in skills/ingest.md"; exit 1; }
1700
1705
  grep -qF "15" "$_proj_lint" || { fail "Custom btreeShardMaxEntries missing in skills/lint.md"; exit 1; }
1701
1706
 
1702
1707
  for _proj_f in "$_proj_ai" "$_proj_arch" "$_proj_rules" "$_proj_ingest" "$_proj_lint"; do
@@ -1949,7 +1954,7 @@ _strict_err=0
1949
1954
  }
1950
1955
 
1951
1956
  # 2. Update the source document header and summary
1952
- printf '# New Architecture Title\nUpdated summary after review.\n' > "$TEST_DEEP_LINT_WS/docs/spec.md"
1957
+ printf '# New Architecture Title\n## Updated summary after review.\n' > "$TEST_DEEP_LINT_WS/docs/spec.md"
1953
1958
 
1954
1959
  # 3. lint --shallow validates links/structure only and does NOT overwrite the stale title/summary
1955
1960
  _shallow_out="$(cd "$TEST_DEEP_LINT_WS" && ./rnex plugin llm-wiki lint --shallow)"
@@ -1987,6 +1992,204 @@ _log_after_clean="$(cksum < "$TEST_DEEP_LINT_WS/.rnex/wiki/log.md")"
1987
1992
  }
1988
1993
  pass
1989
1994
 
1995
+ # --------------------------------------------------------------------------
1996
+ # Test 34: recordSummaryMaxLength, hierarchy-ordered Markdown headers, '#' comments, and summary-less files
1997
+ # --------------------------------------------------------------------------
1998
+ run_test "LLM Wiki: recordSummaryMaxLength, Markdown header hierarchy (# -> ## -> ###), '#' comments, and summary-less files"
1999
+ TEST_RECLEN_WS="$TEST_TMP/llm-wiki-reclen-ws"
2000
+ mkdir -p "$TEST_RECLEN_WS"
2001
+ setup_plugin_test_workspace llm-wiki "$TEST_RECLEN_WS"
2002
+ cd "$TEST_RECLEN_WS"
2003
+ "$TEST_RECLEN_WS/rnex" init -y --llm-wiki "$TEST_RECLEN_WS" >/dev/null
2004
+
2005
+ mkdir -p "$TEST_RECLEN_WS/docs" "$TEST_RECLEN_WS/scripts" "$TEST_RECLEN_WS/data"
2006
+
2007
+ # 1. Markdown document with out-of-order header hierarchy (#, ###, ##, ####)
2008
+ cat <<'EOF_MD_HIER' > "$TEST_RECLEN_WS/docs/hierarchy.md"
2009
+ # TopOne
2010
+ Body prose that should not appear in summary.
2011
+ ### SubThreeA
2012
+ More prose ignored.
2013
+ ## MidTwoA
2014
+ #### DeepFourA
2015
+ ## MidTwoB
2016
+ ### SubThreeB
2017
+ # TopTwo
2018
+ EOF_MD_HIER
2019
+
2020
+ # 2. Shell script with shebang, divider, and '#' comments
2021
+ cat <<'EOF_SH_COMM' > "$TEST_RECLEN_WS/scripts/deploy.sh"
2022
+ #!/bin/sh
2023
+ # shellcheck shell=sh
2024
+ # ============================================================================
2025
+ # Deployment automation script for microservices.
2026
+ # Verifies cluster health and rolls out containers.
2027
+ # ============================================================================
2028
+ echo "Deploying..."
2029
+ EOF_SH_COMM
2030
+
2031
+ # 3. File without any readable headers or '#' comments (JSON)
2032
+ cat <<'EOF_JSON_NO_COMM' > "$TEST_RECLEN_WS/data/config.json"
2033
+ {
2034
+ "port": 8080,
2035
+ "env": "production"
2036
+ }
2037
+ EOF_JSON_NO_COMM
2038
+
2039
+ # 4. Markdown file without any headers
2040
+ cat <<'EOF_MD_NO_HDR' > "$TEST_RECLEN_WS/docs/plain.md"
2041
+ Just plain text without any markdown headers at all.
2042
+ EOF_MD_NO_HDR
2043
+
2044
+ # 5. Binary image asset inside data/ (even if bytes contain '#FakeHeader')
2045
+ printf '\001\002\n#FakeBinaryComment\n\003' > "$TEST_RECLEN_WS/data/logo.png"
2046
+ printf '\001\002\n#FakeBinaryRaw\n\003' > "$TEST_RECLEN_WS/data/raw.dat"
2047
+
2048
+ cat <<'EOF_RECLEN_CFG' > "$TEST_RECLEN_WS/rnex.yaml"
2049
+ version: 1.0.0
2050
+ plugins:
2051
+ llm-wiki:
2052
+ wikiDir: ".rnex/wiki"
2053
+ sources:
2054
+ - docs
2055
+ - "scripts/*.sh"
2056
+ - "data/*"
2057
+ repos:
2058
+ EOF_RECLEN_CFG
2059
+
2060
+ (cd "$TEST_RECLEN_WS" && ./rnex plugin llm-wiki ingest >/dev/null)
2061
+
2062
+ # Verify Markdown headers are ordered by level (# then ## then ### then ####):
2063
+ # TopOne TopTwo MidTwoA MidTwoB SubThreeA SubThreeB DeepFourA
2064
+ _docs_shard="$(cat "$TEST_RECLEN_WS/.rnex/wiki/repo-nexus-docs.md")"
2065
+ echo "$_docs_shard" | grep -qF -- '- **[TopOne](../../docs/hierarchy.md)** (`docs/hierarchy.md`) — TopOne TopTwo MidTwoA MidTwoB SubThreeA SubThreeB DeepFourA' || {
2066
+ fail "Markdown headers were not ordered by hierarchy (# -> ## -> ### -> ####): $_docs_shard"; exit 1;
2067
+ }
2068
+
2069
+ # Verify plain.md without headers emits only link and title without ' — ' summary
2070
+ echo "$_docs_shard" | grep -q '^- \*\*\[plain\.md\](\.\./\.\./docs/plain\.md)\*\* (`docs/plain\.md`)$' || {
2071
+ fail "Header-free Markdown file should emit only title link without summary: $_docs_shard"; exit 1;
2072
+ }
2073
+
2074
+ # Verify shell script '#' comments are extracted (excluding shebang, shellcheck, and '====' dividers)
2075
+ _scripts_shard="$(cat "$TEST_RECLEN_WS/.rnex/wiki/repo-nexus-scripts.md")"
2076
+ echo "$_scripts_shard" | grep -qF -- '- **[deploy.sh](../../scripts/deploy.sh)** (`scripts/deploy.sh`) — Deployment automation script for microservices. Verifies cluster health and rolls out containers.' || {
2077
+ fail "Script '#' comments were not properly extracted into summary: $_scripts_shard"; exit 1;
2078
+ }
2079
+
2080
+ # Verify JSON and binary files without readable '#' comments emit only link and title without summary
2081
+ _data_shard="$(cat "$TEST_RECLEN_WS/.rnex/wiki/repo-nexus-data.md")"
2082
+ echo "$_data_shard" | grep -q '^- \*\*\[config\.json\](\.\./\.\./data/config\.json)\*\* (`data/config\.json`)$' || {
2083
+ fail "Comment-free JSON file should emit only title link without summary: $_data_shard"; exit 1;
2084
+ }
2085
+ echo "$_data_shard" | grep -q '^- \*\*\[logo\.png\](\.\./\.\./data/logo\.png)\*\* (`data/logo\.png`)$' || {
2086
+ fail "Binary PNG file should emit only title link without summary: $_data_shard"; exit 1;
2087
+ }
2088
+ echo "$_data_shard" | grep -q '^- \*\*\[raw\.dat\](\.\./\.\./data/raw\.dat)\*\* (`data/raw\.dat`)$' || {
2089
+ fail "Binary data file with control bytes should emit only title link without summary: $_data_shard"; exit 1;
2090
+ }
2091
+
2092
+ # Verify custom recordSummaryMaxLength (e.g. 28 chars) truncates summary portion cleanly
2093
+ cat <<'EOF_RECLEN_SHORT' > "$TEST_RECLEN_WS/rnex.yaml"
2094
+ version: 1.0.0
2095
+ plugins:
2096
+ llm-wiki:
2097
+ wikiDir: ".rnex/wiki"
2098
+ recordSummaryMaxLength: 28
2099
+ sources:
2100
+ - docs
2101
+ - "scripts/*.sh"
2102
+ - "data/*"
2103
+ repos:
2104
+ EOF_RECLEN_SHORT
2105
+
2106
+ (cd "$TEST_RECLEN_WS" && ./rnex plugin llm-wiki ingest --force >/dev/null)
2107
+
2108
+ _hier_sum="$(grep '(`docs/hierarchy\.md`)' "$TEST_RECLEN_WS/.rnex/wiki/repo-nexus-docs.md" | sed 's/^.* — //')"
2109
+ _hier_len="${#_hier_sum}"
2110
+ [ "$_hier_len" -le 28 ] && [ "$_hier_len" -gt 0 ] || {
2111
+ fail "Expected hierarchy.md summary length <= 28, got $_hier_len ('$_hier_sum')"; exit 1;
2112
+ }
2113
+
2114
+ _sh_sum="$(grep '(`scripts/deploy\.sh`)' "$TEST_RECLEN_WS/.rnex/wiki/repo-nexus-scripts.md" | sed 's/^.* — //')"
2115
+ _sh_len="${#_sh_sum}"
2116
+ [ "$_sh_len" -le 28 ] && [ "$_sh_len" -gt 0 ] || {
2117
+ fail "Expected deploy.sh summary length <= 28, got $_sh_len ('$_sh_sum')"; exit 1;
2118
+ }
2119
+
2120
+ # Verify both deep lint and shallow lint pass cleanly with zero repairs
2121
+ _lint_deep_reclen="$(cd "$TEST_RECLEN_WS" && ./rnex plugin llm-wiki lint)"
2122
+ echo "$_lint_deep_reclen" | grep -q "all existing docs and references in .rnex/wiki are valid" || {
2123
+ fail "Deep lint failed or reported unexpected repairs: $_lint_deep_reclen"; exit 1;
2124
+ }
2125
+ _lint_shallow_reclen="$(cd "$TEST_RECLEN_WS" && ./rnex plugin llm-wiki lint --shallow)"
2126
+ echo "$_lint_shallow_reclen" | grep -q "all existing docs and references in .rnex/wiki are valid" || {
2127
+ fail "Shallow lint failed or reported unexpected repairs: $_lint_shallow_reclen"; exit 1;
2128
+ }
2129
+
2130
+ # 6. Test 'exclude' setting: by default nothing is excluded (.DS_Store and .vitepress ARE ingested if present),
2131
+ # and when listed in 'exclude' (via file path, directory path, or glob pattern) they are excluded!
2132
+ mkdir -p "$TEST_RECLEN_WS/docs/.vitepress/dist"
2133
+ printf '# VitePress Config\n' > "$TEST_RECLEN_WS/docs/.vitepress/config.mts"
2134
+ printf '# VitePress Dist\n' > "$TEST_RECLEN_WS/docs/.vitepress/dist/index.html"
2135
+ printf '# DS Store\n' > "$TEST_RECLEN_WS/docs/.DS_Store"
2136
+ printf '# Draft Doc\n' > "$TEST_RECLEN_WS/docs/draft.md"
2137
+
2138
+ # First, with no exclude configured (default []), .DS_Store and .vitepress files ARE discovered
2139
+ rm -rf "$TEST_RECLEN_WS/.rnex/wiki"
2140
+ (cd "$TEST_RECLEN_WS" && ./rnex plugin llm-wiki ingest >/dev/null)
2141
+ grep -q 'docs/\.DS_Store' "$TEST_RECLEN_WS/.rnex/wiki/repo-nexus-docs.md" || {
2142
+ fail "With default empty exclude, docs/.DS_Store should not be hardcoded-excluded"; exit 1;
2143
+ }
2144
+ grep -q 'docs/\.vitepress/config\.mts' "$TEST_RECLEN_WS/.rnex/wiki/repo-nexus-docs.md" || {
2145
+ fail "With default empty exclude, docs/.vitepress/config.mts should not be hardcoded-excluded"; exit 1;
2146
+ }
2147
+
2148
+ # Now configure 'exclude' with glob pattern (**/.DS_Store), directory path (docs/.vitepress),
2149
+ # file path (docs/draft.md), and wildcard glob (data/*.png)
2150
+ rm -rf "$TEST_RECLEN_WS/.rnex/wiki"
2151
+ cat <<'EOF_EXCLUDE_CFG' > "$TEST_RECLEN_WS/rnex.yaml"
2152
+ version: 1.0.0
2153
+ plugins:
2154
+ llm-wiki:
2155
+ wikiDir: ".rnex/wiki"
2156
+ sources:
2157
+ - docs
2158
+ - "scripts/*.sh"
2159
+ - "data/*"
2160
+ exclude:
2161
+ - "**/.DS_Store"
2162
+ - "docs/.vitepress"
2163
+ - "docs/draft.md"
2164
+ - "data/*.png"
2165
+ repos:
2166
+ EOF_EXCLUDE_CFG
2167
+
2168
+ (cd "$TEST_RECLEN_WS" && ./rnex plugin llm-wiki ingest >/dev/null)
2169
+
2170
+ _docs_after_ex="$(cat "$TEST_RECLEN_WS/.rnex/wiki/repo-nexus-docs.md")"
2171
+ ! echo "$_docs_after_ex" | grep -q '\.DS_Store' || {
2172
+ fail "exclude pattern '**/.DS_Store' did not exclude docs/.DS_Store: $_docs_after_ex"; exit 1;
2173
+ }
2174
+ ! echo "$_docs_after_ex" | grep -q '\.vitepress' || {
2175
+ fail "exclude directory 'docs/.vitepress' did not exclude .vitepress files: $_docs_after_ex"; exit 1;
2176
+ }
2177
+ ! echo "$_docs_after_ex" | grep -q 'docs/draft\.md' || {
2178
+ fail "exclude file 'docs/draft.md' did not exclude docs/draft.md: $_docs_after_ex"; exit 1;
2179
+ }
2180
+ echo "$_docs_after_ex" | grep -q 'docs/hierarchy\.md' || {
2181
+ fail "Non-excluded docs/hierarchy.md was missing after exclude filtering: $_docs_after_ex"; exit 1;
2182
+ }
2183
+
2184
+ _data_after_ex="$(cat "$TEST_RECLEN_WS/.rnex/wiki/repo-nexus-data.md")"
2185
+ ! echo "$_data_after_ex" | grep -q 'data/logo\.png' || {
2186
+ fail "exclude glob 'data/*.png' did not exclude data/logo.png: $_data_after_ex"; exit 1;
2187
+ }
2188
+ echo "$_data_after_ex" | grep -q 'data/config\.json' || {
2189
+ fail "Non-excluded data/config.json was missing after exclude filtering: $_data_after_ex"; exit 1;
2190
+ }
2191
+ pass
2192
+
1990
2193
  if [ "${_STANDALONE_RUN:-0}" -eq 1 ]; then
1991
2194
  report_results
1992
2195
  fi
@@ -1,5 +1,5 @@
1
1
  name: windsurf
2
- version: 0.10.2
2
+ version: 0.10.3
3
3
  description: Windsurf IDE integration (maintains .windsurfrules and generates user skills in .windsurf/rules/)
4
4
  author: unoxen
5
5
  homepage: https://github.com/unoxen/repo-nexus