repo-nexus 0.9.26 → 0.9.27
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/commands/init.sh +1 -1
- package/lib/commands/sync.sh +13 -1
- package/lib/plugins.sh +209 -82
- package/lib/yaml.sh +131 -5
- package/package.json +1 -1
- package/plugins/claude/plugin.yaml +1 -1
- package/plugins/codex/plugin.yaml +1 -1
- package/plugins/copilot/instructions/rnex-copilot-integration.md +1 -1
- package/plugins/copilot/plugin.yaml +1 -1
- package/plugins/cursor/instructions/rnex-cursor-integration.md +1 -1
- package/plugins/cursor/plugin.yaml +1 -1
- package/plugins/gemini/instructions/rnex-gemini-integration.md +1 -1
- package/plugins/gemini/plugin.yaml +1 -1
- package/plugins/llm-wiki/ai-instructions.md +7 -6
- package/plugins/llm-wiki/instructions/rnex-wiki-architecture.md +2 -2
- package/plugins/llm-wiki/lib/config.sh +1 -1
- package/plugins/llm-wiki/plugin.yaml +7 -3
- package/plugins/llm-wiki/rules/behavioral.md +8 -8
- package/plugins/llm-wiki/skills/ingest.md +17 -17
- package/plugins/llm-wiki/skills/lint.md +11 -11
- package/plugins/llm-wiki/tests/test_plugin.sh +51 -4
- package/plugins/windsurf/plugin.yaml +1 -1
package/lib/commands/init.sh
CHANGED
|
@@ -118,7 +118,7 @@ cmd_init() {
|
|
|
118
118
|
[ -n "$_pdir" ] || _pdir="$(find_plugin_dir "$_p" 2>/dev/null || true)"
|
|
119
119
|
_cfg_lines=""
|
|
120
120
|
if [ -n "$_pdir" ] && [ -f "$_pdir/plugin.yaml" ]; then
|
|
121
|
-
_cfg_lines="$(plugin_config_default_lines "$_pdir/plugin.yaml")"
|
|
121
|
+
_cfg_lines="$(plugin_config_default_lines "$_pdir/plugin.yaml" "$_init_repos_dir")"
|
|
122
122
|
fi
|
|
123
123
|
if [ -n "$_cfg_lines" ]; then
|
|
124
124
|
_init_plugins="${_init_plugins} ${_p}:\n${_cfg_lines}\n"
|
package/lib/commands/sync.sh
CHANGED
|
@@ -115,9 +115,21 @@ cmd_sync() {
|
|
|
115
115
|
# 3.4. Reconcile VS Code / Cursor multi-root workspace if configured
|
|
116
116
|
sync_code_workspace
|
|
117
117
|
|
|
118
|
+
# 3.5. Validate configuration schema, deprecated keys, and declared plugins (Fail-Fast)
|
|
119
|
+
_sync_validation_failed=0
|
|
120
|
+
if command -v validate_workspace_config >/dev/null 2>&1; then
|
|
121
|
+
validate_workspace_config || _sync_validation_failed=1
|
|
122
|
+
fi
|
|
123
|
+
if command -v validate_configured_plugins >/dev/null 2>&1; then
|
|
124
|
+
validate_configured_plugins || _sync_validation_failed=1
|
|
125
|
+
fi
|
|
126
|
+
|
|
127
|
+
_sync_quiet="$_old_sync_quiet"
|
|
128
|
+
if [ "$_sync_validation_failed" -ne 0 ]; then
|
|
129
|
+
return 1
|
|
130
|
+
fi
|
|
118
131
|
if [ "$_sync_quiet" -eq 0 ]; then
|
|
119
132
|
log_ok "Sync complete — workspace, plugins, skills, and member repositories reconciled"
|
|
120
133
|
fi
|
|
121
|
-
_sync_quiet="$_old_sync_quiet"
|
|
122
134
|
return 0
|
|
123
135
|
}
|
package/lib/plugins.sh
CHANGED
|
@@ -409,94 +409,154 @@ plugin_list_instructions() {
|
|
|
409
409
|
' "$_pdir/plugin.yaml"
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
-
#
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
412
|
+
# Escape \, &, and | characters in a string for safe use as a POSIX sed replacement.
|
|
413
|
+
#
|
|
414
|
+
# @param $1 raw_value Unescaped replacement value.
|
|
415
|
+
# @returns Escaped string on stdout.
|
|
416
|
+
# @pure
|
|
417
|
+
_sed_escape_replacement() {
|
|
418
|
+
printf '%s' "$1" | sed -e 's/[\\&|]/\\&/g'
|
|
419
|
+
}
|
|
416
420
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
421
|
+
# Extract direct scalar configuration key names declared under config_defaults: in
|
|
422
|
+
# a plugin manifest, skipping structured sequence/map keys (sources, hooks).
|
|
423
|
+
#
|
|
424
|
+
# @param $1 manifest_file Path to plugin.yaml.
|
|
425
|
+
# @returns Newline-separated key names on stdout.
|
|
426
|
+
# @pure
|
|
427
|
+
_plugin_config_default_keys() {
|
|
428
|
+
_pcdk_file="$1"
|
|
429
|
+
[ -f "$_pcdk_file" ] || return 0
|
|
430
|
+
awk '
|
|
431
|
+
/^config_defaults:[ ]*(#.*)?$/ { in_c=1; def_indent=-1; next }
|
|
432
|
+
in_c && /^[^ #]/ { exit }
|
|
433
|
+
in_c && /^[ ]*(#|$)/ { next }
|
|
434
|
+
in_c {
|
|
435
|
+
match($0, /^[ ]*/)
|
|
436
|
+
ind = RLENGTH
|
|
437
|
+
if (def_indent == -1) def_indent = ind
|
|
438
|
+
if (ind == def_indent && $0 ~ /^[ ]*[a-zA-Z0-9_.-]+:[ ]*/) {
|
|
422
439
|
k = $0
|
|
423
440
|
sub(/^[ ]*/, "", k)
|
|
424
441
|
sub(/:.*/, "", k)
|
|
425
|
-
print k
|
|
442
|
+
if (k != "sources" && k != "hooks") print k
|
|
426
443
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
444
|
+
}
|
|
445
|
+
' "$_pcdk_file"
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
# Resolve a single scalar plugin configuration value, preferring workspace YAML
|
|
449
|
+
# overrides (.local.rnex.yaml > rnex.yaml) and falling back to plugin.yaml defaults.
|
|
450
|
+
# Normalizes *_dir / dir values as clean relative paths.
|
|
451
|
+
#
|
|
452
|
+
# @param $1 plugin_name Target plugin name.
|
|
453
|
+
# @param $2 plugin_dir Resolved plugin directory.
|
|
454
|
+
# @param $3 key_name Configuration key name.
|
|
455
|
+
# @returns Resolved string value on stdout.
|
|
456
|
+
# @pure
|
|
457
|
+
_plugin_resolve_scalar_value() {
|
|
458
|
+
_prsv_p="$1"; _prsv_pd="$2"; _prsv_k="$3"
|
|
459
|
+
_prsv_v="$(yaml_plugin_get "$_prsv_p" "$_prsv_k" 2>/dev/null || true)"
|
|
460
|
+
if [ -z "$_prsv_v" ] && [ -f "$_prsv_pd/plugin.yaml" ]; then
|
|
461
|
+
_prsv_v="$(awk -v k="$_prsv_k" '
|
|
462
|
+
/^config_defaults:[ ]*(#.*)?$/ { in_c=1; next }
|
|
463
|
+
in_c && /^[^ #]/ { exit }
|
|
464
|
+
in_c && $0 ~ ("^[ ]*" k ":") {
|
|
465
|
+
sub("^[ ]*" k ":[ ]*", "")
|
|
466
|
+
sub(/[ ]*#.*/, "")
|
|
467
|
+
gsub(/["\047]/, "")
|
|
468
|
+
print
|
|
469
|
+
exit
|
|
470
|
+
}
|
|
471
|
+
' "$_prsv_pd/plugin.yaml")"
|
|
472
|
+
fi
|
|
473
|
+
case "$_prsv_k" in
|
|
474
|
+
*_dir|dir) _prsv_v="$(normalize_rel_path "$_prsv_v")" ;;
|
|
475
|
+
esac
|
|
476
|
+
printf '%s' "$_prsv_v"
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
# Substitute configurable placeholders declared in plugin.yaml config_defaults
|
|
480
|
+
# and core workspace metadata ({repos_dir}, {plugin_dir}) in template paths.
|
|
481
|
+
#
|
|
482
|
+
# @param $1 plugin_name Target plugin name.
|
|
483
|
+
# @param $2 plugin_dir Resolved plugin directory.
|
|
484
|
+
# @param $3 input_str Path or string containing {placeholder} tokens.
|
|
485
|
+
# @returns Resolved relative path string on stdout.
|
|
486
|
+
# @pure
|
|
487
|
+
plugin_resolve_placeholders() {
|
|
488
|
+
_p="$1"; _pd="$2"; _str="$3"
|
|
489
|
+
_res="$(printf '%s' "$_str" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -d "'\"")"
|
|
490
|
+
|
|
491
|
+
if [ -f "$_pd/plugin.yaml" ]; then
|
|
492
|
+
for _k in $(_plugin_config_default_keys "$_pd/plugin.yaml"); do
|
|
493
|
+
_v="$(_plugin_resolve_scalar_value "$_p" "$_pd" "$_k")"
|
|
494
|
+
if [ -n "$_v" ]; then
|
|
495
|
+
_v_esc="$(_sed_escape_replacement "$_v")"
|
|
496
|
+
_res="$(printf '%s' "$_res" | sed -e "s|{$_k}|$_v_esc|g")"
|
|
443
497
|
fi
|
|
444
|
-
case "$_k" in
|
|
445
|
-
*_dir|dir)
|
|
446
|
-
_v="$(normalize_rel_path "$_v")"
|
|
447
|
-
;;
|
|
448
|
-
esac
|
|
449
|
-
[ -n "$_v" ] && _res="$(printf '%s' "$_res" | sed -e "s|{$_k}|$_v|g")"
|
|
450
498
|
done
|
|
451
499
|
fi
|
|
452
500
|
|
|
501
|
+
_rdir_v="$(normalize_rel_path "$(_plugin_repos_rel_dir)")"
|
|
502
|
+
if [ -n "$_rdir_v" ]; then
|
|
503
|
+
_rdir_esc="$(_sed_escape_replacement "$_rdir_v")"
|
|
504
|
+
_res="$(printf '%s' "$_res" | sed -e "s|{repos_dir}|$_rdir_esc|g")"
|
|
505
|
+
fi
|
|
506
|
+
_pdir_esc="$(_sed_escape_replacement ".rnex/plugins/$_p")"
|
|
507
|
+
_res="$(printf '%s' "$_res" | sed -e "s|{plugin_dir}|$_pdir_esc|g")"
|
|
508
|
+
|
|
453
509
|
_res="$(printf '%s' "$_res" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | tr -d "'\"" | sed -e 's#^\./##')"
|
|
454
510
|
|
|
455
511
|
printf '%s' "$_res"
|
|
456
512
|
}
|
|
457
513
|
|
|
514
|
+
# Instantiate a Markdown template or AI asset file by resolving all workspace,
|
|
515
|
+
# manifest, and plugin config placeholders into concrete values.
|
|
516
|
+
# Fast-paths to raw copy when the source file contains no {placeholder} tokens.
|
|
517
|
+
#
|
|
518
|
+
# @param $1 plugin_name Target plugin name.
|
|
519
|
+
# @param $2 plugin_dir Resolved source plugin directory.
|
|
520
|
+
# @param $3 src_file Source file path.
|
|
521
|
+
# @param $4 dest_file Destination file path.
|
|
522
|
+
# @returns 0 on success.
|
|
523
|
+
# @sideEffects Writes instantiated file to $4.
|
|
458
524
|
plugin_instantiate_template() {
|
|
459
525
|
_p="$1"; _pd="$2"; _src="$3"; _dest="$4"
|
|
460
526
|
|
|
461
|
-
#
|
|
527
|
+
# Fast path: avoid spawning awk/sed when source file has no {placeholder} tokens
|
|
528
|
+
if ! grep -qE '\{[a-zA-Z0-9_-]+\}' "$_src" 2>/dev/null; then
|
|
529
|
+
cp "$_src" "$_dest"
|
|
530
|
+
return 0
|
|
531
|
+
fi
|
|
532
|
+
|
|
533
|
+
# Core workspace & plugin metadata placeholders (sed-escaped)
|
|
534
|
+
_r_val="$(normalize_rel_path "$(_plugin_repos_rel_dir)")"
|
|
535
|
+
_r_val="$(_sed_escape_replacement "$_r_val")"
|
|
536
|
+
|
|
537
|
+
_sd_val="$(normalize_rel_path "$(plugin_get_skill_dir "$_p" 2>/dev/null || true)")"
|
|
538
|
+
_sd_val="$(_sed_escape_replacement "$_sd_val")"
|
|
539
|
+
|
|
540
|
+
_if_val=""
|
|
541
|
+
[ -f "$_pd/plugin.yaml" ] && _if_val="$(normalize_rel_path "$(plugin_get_field "$_pd" "instruction_file" 2>/dev/null || true)")"
|
|
542
|
+
_if_val="$(_sed_escape_replacement "$_if_val")"
|
|
543
|
+
|
|
544
|
+
_pdir_val="$(_sed_escape_replacement ".rnex/plugins/$_p")"
|
|
545
|
+
|
|
546
|
+
# {sources}: human-readable list of resolved intake sources (or "(none configured)")
|
|
462
547
|
_s_val="$(plugin_sources_display "$_p" 2>/dev/null || true)"
|
|
463
|
-
|
|
548
|
+
[ -n "$_s_val" ] || _s_val="(none configured)"
|
|
549
|
+
_s_val="$(_sed_escape_replacement "$_s_val")"
|
|
464
550
|
|
|
465
551
|
# {today}: current UTC date (ISO-8601, YYYY-MM-DD)
|
|
466
552
|
_t_val="$(date -u +%Y-%m-%d 2>/dev/null || date +%Y-%m-%d 2>/dev/null || date +%F 2>/dev/null || echo "2026-10-15")"
|
|
467
553
|
|
|
468
554
|
cp "$_src" "$_dest"
|
|
469
555
|
if [ -f "$_pd/plugin.yaml" ]; then
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
in_c && /^[^ #]/ { exit }
|
|
473
|
-
in_c && /^[ ]*[a-zA-Z0-9_.-]+:[ ]*/ {
|
|
474
|
-
k = $0
|
|
475
|
-
sub(/^[ ]*/, "", k)
|
|
476
|
-
sub(/:.*/, "", k)
|
|
477
|
-
print k
|
|
478
|
-
}
|
|
479
|
-
' "$_pd/plugin.yaml")"
|
|
480
|
-
for _k in $_keys; do
|
|
481
|
-
_v="$(yaml_plugin_get "$_p" "$_k" 2>/dev/null || true)"
|
|
482
|
-
if [ -z "$_v" ]; then
|
|
483
|
-
_v="$(awk -v k="$_k" '
|
|
484
|
-
/^config_defaults:[ ]*$/ || /^config_defaults:[ ]*#/ { in_c=1; next }
|
|
485
|
-
in_c && /^[^ #]/ { exit }
|
|
486
|
-
in_c && $0 ~ ("^[ ]*" k ":") {
|
|
487
|
-
sub("^[ ]*" k ":[ ]*", "")
|
|
488
|
-
sub(/[ ]*#.*/, "")
|
|
489
|
-
gsub(/["\047]/, "")
|
|
490
|
-
print
|
|
491
|
-
exit
|
|
492
|
-
}
|
|
493
|
-
' "$_pd/plugin.yaml")"
|
|
494
|
-
fi
|
|
495
|
-
case "$_k" in
|
|
496
|
-
*_dir|dir) _v="$(normalize_rel_path "$_v")" ;;
|
|
497
|
-
esac
|
|
556
|
+
for _k in $(_plugin_config_default_keys "$_pd/plugin.yaml"); do
|
|
557
|
+
_v="$(_plugin_resolve_scalar_value "$_p" "$_pd" "$_k")"
|
|
498
558
|
if [ -n "$_v" ]; then
|
|
499
|
-
_v_esc="$(
|
|
559
|
+
_v_esc="$(_sed_escape_replacement "$_v")"
|
|
500
560
|
_tmp_inst="$(mktemp)"
|
|
501
561
|
sed -e "s|{$_k}|$_v_esc|g" "$_dest" > "$_tmp_inst" && mv "$_tmp_inst" "$_dest"
|
|
502
562
|
fi
|
|
@@ -504,14 +564,25 @@ plugin_instantiate_template() {
|
|
|
504
564
|
fi
|
|
505
565
|
|
|
506
566
|
_tmp_inst="$(mktemp)"
|
|
507
|
-
sed -e "s|{
|
|
567
|
+
sed -e "s|{repos_dir}|$_r_val|g" \
|
|
568
|
+
-e "s|{skill_dir}|$_sd_val|g" \
|
|
569
|
+
-e "s|{instruction_file}|$_if_val|g" \
|
|
570
|
+
-e "s|{plugin_dir}|$_pdir_val|g" \
|
|
571
|
+
-e "s|{sources}|$_s_val|g" \
|
|
508
572
|
-e "s|{today}|$_t_val|g" \
|
|
509
573
|
"$_dest" > "$_tmp_inst" && mv "$_tmp_inst" "$_dest"
|
|
510
574
|
}
|
|
511
575
|
|
|
512
|
-
# Deterministically sync plugin asset directories and manifest files into destination
|
|
576
|
+
# Deterministically sync plugin asset directories and manifest files into destination.
|
|
577
|
+
# Compiles AI-facing Markdown files via plugin_instantiate_template so runtime agent
|
|
578
|
+
# artifacts under .rnex/plugins/<name>/ contain concrete workspace paths without placeholders.
|
|
579
|
+
#
|
|
580
|
+
# @param $1 src_dir Resolved plugin source directory.
|
|
581
|
+
# @param $2 dest_dir Target scoped directory (.rnex/plugins/<name>).
|
|
582
|
+
# @param $3 plugin_name Optional explicit plugin name (defaults to basename of dest_dir).
|
|
583
|
+
# @sideEffects Reconciles destination tree and projected files.
|
|
513
584
|
sync_plugin_bundle() {
|
|
514
|
-
_spb_src="$1"; _spb_dest="$2"
|
|
585
|
+
_spb_src="$1"; _spb_dest="$2"; _spb_pname="${3:-$(basename "$2")}"
|
|
515
586
|
[ -n "$_spb_src" ] && [ -n "$_spb_dest" ] || return 0
|
|
516
587
|
[ "$_spb_src" != "$_spb_dest" ] || return 0
|
|
517
588
|
|
|
@@ -523,6 +594,11 @@ sync_plugin_bundle() {
|
|
|
523
594
|
cp -R "$_spb_src/$_sub"/. "$_spb_dest/$_sub"/ 2>/dev/null || true
|
|
524
595
|
if [ "$_sub" = "hooks" ] || [ "$_sub" = "commands" ] || [ "$_sub" = "bin" ]; then
|
|
525
596
|
chmod +x "$_spb_dest/$_sub"/* 2>/dev/null || true
|
|
597
|
+
elif [ "$_sub" = "rules" ] || [ "$_sub" = "workflows" ] || [ "$_sub" = "instructions" ] || [ "$_sub" = "skills" ] || [ "$_sub" = "agents" ]; then
|
|
598
|
+
find "$_spb_src/$_sub" -type f -name '*.md' 2>/dev/null | while IFS= read -r _spb_md; do
|
|
599
|
+
_spb_rel="${_spb_md#"$_spb_src"/}"
|
|
600
|
+
plugin_instantiate_template "$_spb_pname" "$_spb_src" "$_spb_md" "$_spb_dest/$_spb_rel"
|
|
601
|
+
done
|
|
526
602
|
fi
|
|
527
603
|
else
|
|
528
604
|
rm -rf "${_spb_dest:?}/$_sub"
|
|
@@ -531,7 +607,14 @@ sync_plugin_bundle() {
|
|
|
531
607
|
_spb_ai_fn="${RNEX_PLUGIN_AI_FILENAME:-ai-instructions.md}"
|
|
532
608
|
for _meta in plugin.yaml instructions.md README.md "$_spb_ai_fn"; do
|
|
533
609
|
if [ -f "$_spb_src/$_meta" ]; then
|
|
534
|
-
|
|
610
|
+
case "$_meta" in
|
|
611
|
+
instructions.md|"$_spb_ai_fn")
|
|
612
|
+
plugin_instantiate_template "$_spb_pname" "$_spb_src" "$_spb_src/$_meta" "$_spb_dest/$_meta"
|
|
613
|
+
;;
|
|
614
|
+
*)
|
|
615
|
+
cp "$_spb_src/$_meta" "$_spb_dest/$_meta"
|
|
616
|
+
;;
|
|
617
|
+
esac
|
|
535
618
|
elif [ "$_meta" = "$_spb_ai_fn" ]; then
|
|
536
619
|
# Prune stale projected ai-instructions.md if removed from source plugin
|
|
537
620
|
rm -f "${_spb_dest:?}/$_meta" 2>/dev/null || true
|
|
@@ -579,24 +662,14 @@ sync_plugins() {
|
|
|
579
662
|
|
|
580
663
|
# OWASP A03 / Path Traversal Guard: plugin name must strictly match allowlist
|
|
581
664
|
case "$_pname" in
|
|
582
|
-
*[!a-zA-Z0-9._-]*|"")
|
|
583
|
-
log_warn "Skipping invalid plugin name containing disallowed characters: '$_pname'"
|
|
584
|
-
continue
|
|
585
|
-
;;
|
|
586
|
-
.|..)
|
|
587
|
-
log_warn "Skipping invalid plugin name: '$_pname'"
|
|
588
|
-
continue
|
|
589
|
-
;;
|
|
665
|
+
*[!a-zA-Z0-9._-]*|""|.|..) continue ;;
|
|
590
666
|
esac
|
|
591
667
|
|
|
592
668
|
_pdir="$(plugin_resolve_dir "$_pname" 2>/dev/null || true)"
|
|
593
669
|
[ -n "$_pdir" ] || _pdir="$(find_plugin_dir "$_pname" 2>/dev/null || true)"
|
|
594
|
-
|
|
595
|
-
log_warn "Plugin '$_pname' declared in config but not found on disk"
|
|
596
|
-
continue
|
|
597
|
-
fi
|
|
670
|
+
[ -n "$_pdir" ] || continue
|
|
598
671
|
|
|
599
|
-
sync_plugin_bundle "$_pdir" "$NEXUS_DIR/.rnex/plugins/$_pname"
|
|
672
|
+
sync_plugin_bundle "$_pdir" "$NEXUS_DIR/.rnex/plugins/$_pname" "$_pname"
|
|
600
673
|
|
|
601
674
|
# Provision explicit directory sources declared under plugins.<name>.sources (e.g. ./docs)
|
|
602
675
|
for _sdir in $(plugin_source_dirs "$_pname" 2>/dev/null); do
|
|
@@ -642,6 +715,40 @@ sync_plugins() {
|
|
|
642
715
|
done
|
|
643
716
|
}
|
|
644
717
|
|
|
718
|
+
# Validate all plugin entries declared in rnex.yaml and .local.rnex.yaml.
|
|
719
|
+
# Enforces name allowlisting (OWASP A03) and verifies every configured plugin
|
|
720
|
+
# resolves to a valid directory, emitting non-suppressible stderr errors when
|
|
721
|
+
# stale or nonexistent plugins (e.g. removed names) remain in config.
|
|
722
|
+
#
|
|
723
|
+
# @returns 0 if all configured plugins resolve; 1 if any unknown plugin is declared.
|
|
724
|
+
# @sideEffects Emits diagnostic errors via log_err (stderr).
|
|
725
|
+
validate_configured_plugins() {
|
|
726
|
+
_vcp_rc=0
|
|
727
|
+
_vcp_list="$(yaml_list_plugins 2>/dev/null || true)"
|
|
728
|
+
[ -n "$_vcp_list" ] || return 0
|
|
729
|
+
|
|
730
|
+
while IFS= read -r _vcp_name || [ -n "$_vcp_name" ]; do
|
|
731
|
+
[ -n "$_vcp_name" ] || continue
|
|
732
|
+
|
|
733
|
+
case "$_vcp_name" in
|
|
734
|
+
*[!a-zA-Z0-9._-]*|""|.|..)
|
|
735
|
+
log_err "Invalid plugin name '$_vcp_name' declared in configuration (disallowed characters or path traversal rejected)."
|
|
736
|
+
continue
|
|
737
|
+
;;
|
|
738
|
+
esac
|
|
739
|
+
|
|
740
|
+
_vcp_dir="$(plugin_resolve_dir "$_vcp_name" 2>/dev/null || true)"
|
|
741
|
+
[ -n "$_vcp_dir" ] || _vcp_dir="$(find_plugin_dir "$_vcp_name" 2>/dev/null || true)"
|
|
742
|
+
if [ -z "$_vcp_dir" ]; then
|
|
743
|
+
log_err "Unknown plugin '$_vcp_name' declared in configuration: plugin does not exist in built-in plugins or via a valid 'path:'. Remove or update 'plugins.$_vcp_name'."
|
|
744
|
+
_vcp_rc=1
|
|
745
|
+
fi
|
|
746
|
+
done <<EOF_VCP
|
|
747
|
+
$_vcp_list
|
|
748
|
+
EOF_VCP
|
|
749
|
+
return "$_vcp_rc"
|
|
750
|
+
}
|
|
751
|
+
|
|
645
752
|
# ----------------------------------------------------------------------------
|
|
646
753
|
# Plugin source resolution (directories + POSIX glob patterns)
|
|
647
754
|
# ----------------------------------------------------------------------------
|
|
@@ -688,13 +795,32 @@ _src_is_file_like() {
|
|
|
688
795
|
return 1
|
|
689
796
|
}
|
|
690
797
|
|
|
798
|
+
# Expand workspace placeholders (e.g. {repos_dir}) inside a configured plugin source
|
|
799
|
+
# specification and normalize it as a clean relative entry.
|
|
800
|
+
#
|
|
801
|
+
# @param $1 raw_entry Source specification string.
|
|
802
|
+
# @param $2 repos_dir Optional relative member repos directory override.
|
|
803
|
+
# @returns Normalized source specification on stdout.
|
|
804
|
+
# @pure
|
|
805
|
+
_plugin_expand_source_entry() {
|
|
806
|
+
_pese_val="$1"
|
|
807
|
+
_pese_rdir="${2:-$(_plugin_repos_rel_dir)}"
|
|
808
|
+
case "$_pese_val" in
|
|
809
|
+
*"{repos_dir}"*)
|
|
810
|
+
_pese_esc="$(_sed_escape_replacement "$_pese_rdir")"
|
|
811
|
+
_pese_val="$(printf '%s' "$_pese_val" | sed -e "s|{repos_dir}|$_pese_esc|g")"
|
|
812
|
+
;;
|
|
813
|
+
esac
|
|
814
|
+
_src_normalize_entry "$_pese_val"
|
|
815
|
+
}
|
|
816
|
+
|
|
691
817
|
# List explicit directory sources of a plugin that rnex may provision (mkdir).
|
|
692
818
|
# Skips glob patterns, file entries, absolute paths, '..' traversal, the workspace
|
|
693
819
|
# root, and paths inside the member repositories directory.
|
|
694
820
|
plugin_source_dirs() {
|
|
695
821
|
_psd_rdir="$(_plugin_repos_rel_dir)"
|
|
696
822
|
get_plugin_config_list "$1" "sources" 2>/dev/null | while IFS= read -r _psd_e || [ -n "$_psd_e" ]; do
|
|
697
|
-
_psd_e="$(
|
|
823
|
+
_psd_e="$(_plugin_expand_source_entry "$_psd_e" "$_psd_rdir")"
|
|
698
824
|
case "$_psd_e" in
|
|
699
825
|
''|.|/*|..|../*|*/..|*/../*) continue ;;
|
|
700
826
|
esac
|
|
@@ -708,8 +834,9 @@ plugin_source_dirs() {
|
|
|
708
834
|
|
|
709
835
|
# Human-readable source list for templates, e.g.: `docs/`, `repos/**/README.md`
|
|
710
836
|
plugin_sources_display() {
|
|
837
|
+
_psy_rdir="$(_plugin_repos_rel_dir)"
|
|
711
838
|
get_plugin_config_list "$1" "sources" 2>/dev/null | while IFS= read -r _psy_e || [ -n "$_psy_e" ]; do
|
|
712
|
-
_psy_e="$(
|
|
839
|
+
_psy_e="$(_plugin_expand_source_entry "$_psy_e" "$_psy_rdir")"
|
|
713
840
|
[ -n "$_psy_e" ] || continue
|
|
714
841
|
if _src_is_file_like "$_psy_e"; then
|
|
715
842
|
printf '\140%s\140\n' "$_psy_e"
|
package/lib/yaml.sh
CHANGED
|
@@ -957,8 +957,7 @@ _yaml_rnex_hook_commands_from_file() {
|
|
|
957
957
|
#
|
|
958
958
|
# Summary:
|
|
959
959
|
# Reads lifecycle hook commands for a specified stage from rnex-hooks.<stage>
|
|
960
|
-
#
|
|
961
|
-
# .local.rnex.yaml override priority over rnex.yaml.
|
|
960
|
+
# with strict .local.rnex.yaml override priority over rnex.yaml.
|
|
962
961
|
# Adheres to strict opt-in execution: if the stage is not explicitly configured
|
|
963
962
|
# or is set to an empty list / false, zero commands are returned.
|
|
964
963
|
#
|
|
@@ -1420,18 +1419,145 @@ get_plugin_config_list() {
|
|
|
1420
1419
|
yaml_get_plugin_list "$1" "$2" 2>/dev/null || true
|
|
1421
1420
|
}
|
|
1422
1421
|
|
|
1422
|
+
# Audit a single YAML configuration file for deprecated top-level schema keys and
|
|
1423
|
+
# malformed YAML hook list syntax that would otherwise be silently skipped.
|
|
1424
|
+
#
|
|
1425
|
+
# @param $1 file_path Path to rnex.yaml or .local.rnex.yaml.
|
|
1426
|
+
# @returns Emits structured findings (<CODE>|<line>|<detail>) on stdout.
|
|
1427
|
+
# @pure Read-only configuration inspection.
|
|
1428
|
+
_yaml_audit_config_file() {
|
|
1429
|
+
_yacf_f="$1"
|
|
1430
|
+
[ -f "$_yacf_f" ] || return 0
|
|
1431
|
+
awk '
|
|
1432
|
+
/^[ \t]*#/ || /^[ \t]*$/ { next }
|
|
1433
|
+
{
|
|
1434
|
+
match($0, /^[ \t]*/)
|
|
1435
|
+
indent = RLENGTH
|
|
1436
|
+
trimmed = substr($0, indent + 1)
|
|
1437
|
+
}
|
|
1438
|
+
trimmed ~ /^([#]|$)/ { next }
|
|
1439
|
+
|
|
1440
|
+
# Detect deprecated top-level keys removed in current schema
|
|
1441
|
+
indent == 0 && trimmed ~ /^rnex_hooks:[ \t]*(#.*)?$/ {
|
|
1442
|
+
printf "LEGACY_RNEX_HOOKS|%d|%s\n", NR, trimmed
|
|
1443
|
+
in_rnex_hooks = 0
|
|
1444
|
+
next
|
|
1445
|
+
}
|
|
1446
|
+
indent == 0 && trimmed ~ /^git_hooks:[ \t]*(#.*)?$/ {
|
|
1447
|
+
printf "LEGACY_GIT_HOOKS|%d|%s\n", NR, trimmed
|
|
1448
|
+
in_rnex_hooks = 0
|
|
1449
|
+
next
|
|
1450
|
+
}
|
|
1451
|
+
indent == 0 && trimmed ~ /^sources:[ \t]*(#.*)?$/ {
|
|
1452
|
+
printf "LEGACY_ROOT_SOURCES|%d|%s\n", NR, trimmed
|
|
1453
|
+
in_rnex_hooks = 0
|
|
1454
|
+
next
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
# Track rnex-hooks section for malformed YAML list items (e.g. -"cmd" without space)
|
|
1458
|
+
indent == 0 && trimmed ~ /^rnex-hooks:[ \t]*(#.*)?$/ {
|
|
1459
|
+
in_rnex_hooks = 1
|
|
1460
|
+
in_hooks_sub = 0
|
|
1461
|
+
next
|
|
1462
|
+
}
|
|
1463
|
+
indent == 0 && trimmed ~ /^[a-zA-Z0-9_.-]+:/ {
|
|
1464
|
+
in_rnex_hooks = 0
|
|
1465
|
+
in_hooks_sub = 0
|
|
1466
|
+
next
|
|
1467
|
+
}
|
|
1468
|
+
|
|
1469
|
+
# Track nested git.hooks or plugins.<p>.hooks sections for malformed list syntax
|
|
1470
|
+
trimmed ~ /^hooks:[ \t]*(#.*)?$/ && indent > 0 {
|
|
1471
|
+
in_hooks_sub = 1
|
|
1472
|
+
hooks_sub_indent = indent
|
|
1473
|
+
next
|
|
1474
|
+
}
|
|
1475
|
+
in_hooks_sub && indent <= hooks_sub_indent {
|
|
1476
|
+
in_hooks_sub = 0
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
in_rnex_hooks || in_hooks_sub {
|
|
1480
|
+
# Flag inline sequence syntax immediately attached to hyphen (e.g. -"cmd" instead of - "cmd")
|
|
1481
|
+
if (trimmed ~ /^-[^ \t-]/) {
|
|
1482
|
+
printf "MALFORMED_HOOK_ITEM|%d|%s\n", NR, trimmed
|
|
1483
|
+
next
|
|
1484
|
+
}
|
|
1485
|
+
if (trimmed ~ /^[a-zA-Z0-9_.-]+:[ \t]*-[^ \t-]/) {
|
|
1486
|
+
printf "MALFORMED_HOOK_ITEM|%d|%s\n", NR, trimmed
|
|
1487
|
+
next
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
' "$_yacf_f"
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
# Validate merged workspace configuration files (rnex.yaml and .local.rnex.yaml)
|
|
1494
|
+
# against deprecated keys and malformed YAML hook list syntax.
|
|
1495
|
+
#
|
|
1496
|
+
# @returns 0 if valid; 1 if any deprecated key or malformed syntax is detected.
|
|
1497
|
+
# @sideEffects Writes diagnostic errors via log_err (stderr, always visible).
|
|
1498
|
+
validate_workspace_config() {
|
|
1499
|
+
_yaml_resolve_files
|
|
1500
|
+
_vwc_err=0
|
|
1501
|
+
for _vwc_file in "${NEXUS_CONFIG:-$_wy}" "${NEXUS_LOCAL_CONFIG:-$_wly}"; do
|
|
1502
|
+
[ -f "$_vwc_file" ] || continue
|
|
1503
|
+
_vwc_name="$(basename "$_vwc_file")"
|
|
1504
|
+
_vwc_findings="$(_yaml_audit_config_file "$_vwc_file" 2>/dev/null || true)"
|
|
1505
|
+
[ -n "$_vwc_findings" ] || continue
|
|
1506
|
+
|
|
1507
|
+
_vwc_rc_tmp=0
|
|
1508
|
+
while IFS='|' read -r _f_code _f_line _f_detail; do
|
|
1509
|
+
[ -n "$_f_code" ] || continue
|
|
1510
|
+
case "$_f_code" in
|
|
1511
|
+
LEGACY_RNEX_HOOKS)
|
|
1512
|
+
log_err "Deprecated configuration key 'rnex_hooks:' at $_vwc_name:$_f_line — rename it to 'rnex-hooks:'."
|
|
1513
|
+
_vwc_rc_tmp=1
|
|
1514
|
+
;;
|
|
1515
|
+
LEGACY_GIT_HOOKS)
|
|
1516
|
+
log_err "Deprecated configuration key 'git_hooks:' at $_vwc_name:$_f_line — move Git hooks under 'git: hooks:'."
|
|
1517
|
+
_vwc_rc_tmp=1
|
|
1518
|
+
;;
|
|
1519
|
+
LEGACY_ROOT_SOURCES)
|
|
1520
|
+
log_err "Deprecated top-level key 'sources:' at $_vwc_name:$_f_line — move 'sources:' under the owning plugin section (plugins.<name>.sources)."
|
|
1521
|
+
_vwc_rc_tmp=1
|
|
1522
|
+
;;
|
|
1523
|
+
MALFORMED_HOOK_ITEM)
|
|
1524
|
+
log_err "Malformed YAML hook entry at $_vwc_name:$_f_line ('$_f_detail'): add a space after '-' (e.g. '- \"...\"')."
|
|
1525
|
+
_vwc_rc_tmp=1
|
|
1526
|
+
;;
|
|
1527
|
+
esac
|
|
1528
|
+
done <<EOF_VWC
|
|
1529
|
+
$_vwc_findings
|
|
1530
|
+
EOF_VWC
|
|
1531
|
+
[ "$_vwc_rc_tmp" -eq 0 ] || _vwc_err=1
|
|
1532
|
+
done
|
|
1533
|
+
return "$_vwc_err"
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1423
1536
|
# Emit a plugin's config_defaults block from plugin.yaml, re-indented for insertion
|
|
1424
|
-
# under plugins.<name> in rnex.yaml by shifting indentation +2 spaces
|
|
1537
|
+
# under plugins.<name> in rnex.yaml by shifting indentation +2 spaces and resolving
|
|
1538
|
+
# workspace {repos_dir} placeholders deterministically.
|
|
1539
|
+
#
|
|
1540
|
+
# @param $1 plugin_yaml Path to plugin.yaml manifest.
|
|
1541
|
+
# @param $2 repos_dir Optional relative repos directory (defaults to configured repos_dir).
|
|
1542
|
+
# @returns Re-indented YAML block lines on stdout.
|
|
1543
|
+
# @pure Read-only manifest inspection.
|
|
1425
1544
|
plugin_config_default_lines() {
|
|
1426
1545
|
_pcd_file="$1"
|
|
1546
|
+
_pcd_rdir="${2:-}"
|
|
1547
|
+
if [ -z "$_pcd_rdir" ] && command -v yaml_get_repos_dir >/dev/null 2>&1; then
|
|
1548
|
+
_pcd_rdir="$(yaml_get_repos_dir 2>/dev/null || true)"
|
|
1549
|
+
fi
|
|
1550
|
+
[ -n "$_pcd_rdir" ] || _pcd_rdir="repos"
|
|
1427
1551
|
[ -f "$_pcd_file" ] || return 0
|
|
1428
|
-
awk '
|
|
1552
|
+
awk -v rdir="$_pcd_rdir" '
|
|
1429
1553
|
/^config_defaults:[ ]*$/ || /^config_defaults:[ ]*#/ { in_c=1; next }
|
|
1430
1554
|
in_c && /^[^ #]/ { exit }
|
|
1431
1555
|
in_c && /^[ ]*#/ { next }
|
|
1432
1556
|
in_c && /^[ ]*$/ { next }
|
|
1433
1557
|
in_c {
|
|
1434
|
-
|
|
1558
|
+
line = $0
|
|
1559
|
+
gsub(/\{repos_dir\}/, rdir, line)
|
|
1560
|
+
print " " line
|
|
1435
1561
|
}
|
|
1436
1562
|
' "$_pcd_file"
|
|
1437
1563
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repo-nexus",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.27",
|
|
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",
|
|
@@ -4,4 +4,4 @@ This workspace has the Repo Nexus `copilot` plugin enabled.
|
|
|
4
4
|
|
|
5
5
|
## Operating Principles
|
|
6
6
|
- **Instructions Integration**: GitHub Copilot natively reads `.github/copilot-instructions.md` and root `AGENTS.md` for workspace routing and active plugin guidelines between `<!-- REPO-NEXUS:START -->` and `<!-- REPO-NEXUS:END -->`. Custom instructions outside these markers are strictly preserved.
|
|
7
|
-
- **User Skills**: Standardized Repo Nexus core skills and active plugin skills can be accessed via `.github/skills/rnex-*/SKILL.md
|
|
7
|
+
- **User Skills**: Standardized Repo Nexus core skills and active plugin skills can be accessed via `.github/skills/rnex-*/SKILL.md`.
|
|
@@ -5,5 +5,5 @@ This workspace has the Repo Nexus `cursor` plugin enabled.
|
|
|
5
5
|
## Operating Principles
|
|
6
6
|
- **Cursor Rules (`.cursorrules` & `.cursor/rules/repo-nexus.mdc`)**: Synthesizes workspace routing protocol between `<!-- REPO-NEXUS:START -->` and `<!-- REPO-NEXUS:END -->`, supporting both legacy `.cursorrules` and modern Cursor MDC rules format (`alwaysApply: true`).
|
|
7
7
|
- **User Skills (`.cursor/rules/rnex-*.md`)**: Zero-logic user skill pointers linking directly to core skills (`.rnex/skills/`) and active plugins' skills (`.rnex/plugins/<name>/skills/`).
|
|
8
|
-
- **Codebase Indexing Un-Ignore (`.cursorignore`)**: Un-ignores member repositories (`!
|
|
8
|
+
- **Codebase Indexing Un-Ignore (`.cursorignore`)**: Un-ignores member repositories (`!{repos_dir}/*`) so Cursor's semantic indexing engine indexes code across member repositories, while workspace Git continues to ignore them.
|
|
9
9
|
- **Decoupled Cross-Plugin Discovery**: The `cursor` provider discovers and registers user skills from whatever Repo Nexus plugins are currently active.
|
|
@@ -5,5 +5,5 @@ This workspace has the Repo Nexus `gemini` plugin enabled.
|
|
|
5
5
|
## Operating Principles
|
|
6
6
|
- **Gemini Instructions (`GEMINI.md`)**: Synthesizes workspace routing protocol between `<!-- REPO-NEXUS:START -->` and `<!-- REPO-NEXUS:END -->`, preserving any manual user instructions outside those markers. This serves as the primary instructions file for Google Gemini CLI and Google Antigravity.
|
|
7
7
|
- **User Skills (`.agents/skills/rnex-*/SKILL.md`)**: Zero-logic user skill pointers linking directly to core skills (`.rnex/skills/`) and active plugins' skills (`.rnex/plugins/<name>/skills/`).
|
|
8
|
-
- **File Discovery Un-Ignore (`.geminiignore`)**: Un-ignores member repositories (`!
|
|
8
|
+
- **File Discovery Un-Ignore (`.geminiignore`)**: Un-ignores member repositories (`!{repos_dir}/*`) so Gemini CLI and Google Antigravity can discover and access member repository files, while workspace Git continues to ignore them.
|
|
9
9
|
- **Decoupled Cross-Plugin Discovery**: The `gemini` provider discovers and registers user skills from whatever Repo Nexus plugins are currently active.
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
## 1. B-Tree Wiki Retrieval Protocol
|
|
4
4
|
|
|
5
|
-
1. **Step 1 — B-Tree Root Index**: Read
|
|
6
|
-
2. **Step 2 — Leaf Shard & Source Access**: Read only the specific B-Tree leaf shard identified in Step 1 (
|
|
5
|
+
1. **Step 1 — B-Tree Root Index**: Read `{wiki_dir}/{index_file}` to identify the relevant shard.
|
|
6
|
+
2. **Step 2 — Leaf Shard & Source Access**: Read only the specific B-Tree leaf shard identified in Step 1 (`{wiki_dir}/repo-nexus*.md` or `{wiki_dir}/repos-*.md`) and open only authoritative source documents referenced in that shard.
|
|
7
7
|
|
|
8
8
|
## 2. Maintenance & Operations
|
|
9
9
|
|
|
10
|
-
- **Zero Ad-Hoc Edits**: Never edit
|
|
11
|
-
- **Ingestion**: Run `rnex plugin llm-wiki ingest` (or shorthand `rnex plugin ingest`) to index missing sources from `
|
|
12
|
-
- **Linting & Auto-Healing**: Run `rnex plugin llm-wiki lint` (or shorthand `rnex plugin lint`) to validate shard bounds, cross-references, and alphabetical sorting
|
|
13
|
-
- **
|
|
10
|
+
- **Zero Ad-Hoc Edits**: Never edit `{wiki_dir}/` shards manually or create ad-hoc files inside `{wiki_dir}/`.
|
|
11
|
+
- **Ingestion**: Run `rnex plugin llm-wiki ingest` (or shorthand `rnex plugin ingest`) to index missing sources from {sources} into `{wiki_dir}/`.
|
|
12
|
+
- **Linting & Auto-Healing**: Run `rnex plugin llm-wiki lint` (or shorthand `rnex plugin lint`) to validate shard bounds (root router limit: {btree_root_max_lines} lines; shard entry limit: {btree_shard_max_entries} entries), cross-references, and alphabetical sorting inside `{wiki_dir}/`.
|
|
13
|
+
- **Audit Log**: Maintenance records are tracked in `{wiki_dir}/{log_file}` (bounded to {log_max_records} records).
|
|
14
|
+
- **Agent Skills**: Load `.rnex/plugins/llm-wiki/skills/ingest.md` or `.rnex/plugins/llm-wiki/skills/lint.md` only when performing corresponding wiki tasks.
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
> Follow the execution gate and routing directives in `.rnex/ai-instructions.md` and `.rnex/plugins/llm-wiki/ai-instructions.md`.
|
|
4
4
|
|
|
5
5
|
- **Behavioral Rules**: (1) State assumptions and surface trade-offs before coding; (2) Prefer minimal, non-speculative code; (3) Make surgical edits touching only required lines; (4) Verify changes against concrete goals.
|
|
6
|
-
- **Wiki-First**: Follow the B-Tree retrieval protocol: (1) Read
|
|
7
|
-
- **Wiki Operations**: Never edit
|
|
6
|
+
- **Wiki-First**: Follow the B-Tree retrieval protocol: (1) Read `{wiki_dir}/{index_file}`; (2) Read the target index shard `{wiki_dir}/repo-nexus*.md` or `{wiki_dir}/repos-*.md` and open only the authoritative source documents referenced by the shard.
|
|
7
|
+
- **Wiki Operations**: Never edit `{wiki_dir}/` shards ad-hoc. Run `rnex plugin llm-wiki ingest` or `rnex plugin llm-wiki lint`, or load `.rnex/plugins/llm-wiki/skills/ingest.md` or `.rnex/plugins/llm-wiki/skills/lint.md` when executing ingestion or linting.
|
|
@@ -52,7 +52,7 @@ _lookup_llm_wiki_cfg() {
|
|
|
52
52
|
[ -f "$_cf" ] || continue
|
|
53
53
|
_v="$(LC_ALL=C awk -v target_k="$_k" '
|
|
54
54
|
BEGIN { in_plugin=0 }
|
|
55
|
-
/^[ ]*llm-wiki:[ ]
|
|
55
|
+
/^[ ]*llm-wiki:[ ]*(#.*)?$/ { in_plugin=1; next }
|
|
56
56
|
in_plugin && /^[^ ]/ { in_plugin=0 }
|
|
57
57
|
in_plugin && $1 ~ ("^" target_k ":") {
|
|
58
58
|
line = $0
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
name: llm-wiki
|
|
2
|
-
version: 0.9.
|
|
3
|
-
description: "Deterministic B-Tree Markdown Wiki
|
|
4
|
-
|
|
2
|
+
version: 0.9.27
|
|
3
|
+
description: "Deterministic B-Tree Markdown Wiki (configurable via plugins.llm-wiki.wiki_dir) for AI agents"
|
|
4
|
+
config_defaults:
|
|
5
5
|
wiki_dir: ".rnex/wiki"
|
|
6
6
|
index_file: "index.md"
|
|
7
7
|
log_file: "log.md"
|
|
@@ -9,6 +9,10 @@ config:
|
|
|
9
9
|
btree_root_max_lines: 80
|
|
10
10
|
btree_shard_max_entries: 100
|
|
11
11
|
relative_links: "rewrite"
|
|
12
|
+
sources:
|
|
13
|
+
- "README.md"
|
|
14
|
+
- "docs"
|
|
15
|
+
- "{repos_dir}/**/README.md"
|
|
12
16
|
commands:
|
|
13
17
|
ingest:
|
|
14
18
|
script: "bin/ingest.sh"
|
|
@@ -30,22 +30,22 @@ These rules define standing behavioral principles for AI coding assistants worki
|
|
|
30
30
|
|
|
31
31
|
## 2. Multi-Repo Context Engineering
|
|
32
32
|
|
|
33
|
-
In
|
|
33
|
+
In this Repo Nexus workspace, independent repositories live inside `{repos_dir}/` as autonomous Git repositories. Coding agents must follow these rules:
|
|
34
34
|
|
|
35
35
|
1. **Repository Boundaries & Encapsulation:**
|
|
36
|
-
- Edits made to
|
|
37
|
-
- Member repositories are autonomous projects and remain 100% clean of workspace `.rnex/` metadata. Do not introduce cross-repository source imports or shared runtime dependencies unless an explicit monorepo architecture is
|
|
38
|
-
- Run Git operations (commits, branches, pushes) directly within the respective member repository root
|
|
36
|
+
- Edits made to a member repository directory inside `{repos_dir}/` modify the underlying member repository directly.
|
|
37
|
+
- Member repositories are autonomous projects and remain 100% clean of workspace `.rnex/` metadata. Do not introduce cross-repository source imports or shared runtime dependencies unless an explicit monorepo architecture is part of the codebase.
|
|
38
|
+
- Run Git operations (commits, branches, pushes) directly within the respective member repository root inside `{repos_dir}/`.
|
|
39
39
|
|
|
40
40
|
2. **Context Economy:**
|
|
41
41
|
- Do not redundantly read entire files or directory trees when targeted symbol lookups or line ranges suffice.
|
|
42
42
|
- Rely on active workspace context, indexing, and compiled documentation rather than re-scanning raw files repeatedly.
|
|
43
43
|
|
|
44
44
|
3. **In-Place Source Indexing & Encapsulated Metadata:**
|
|
45
|
-
- Source documents
|
|
46
|
-
- Generated wiki metadata (
|
|
45
|
+
- Source documents from {sources} and member repositories in `{repos_dir}/` are indexed directly in place without symlinks (`ln -s`) or redundant copies.
|
|
46
|
+
- Generated wiki metadata (`{index_file}`, `{log_file}`, `repo-nexus*.md`, `repos-*.md`) resides exclusively inside `{wiki_dir}/`.
|
|
47
47
|
|
|
48
48
|
4. **Wiki Navigation Order:**
|
|
49
|
-
- **Step 1 — B-Tree Root Index**: Consult
|
|
50
|
-
- **Step 2 — Domain Shard Pinpointing**: Read only the specific B-Tree leaf shard
|
|
49
|
+
- **Step 1 — B-Tree Root Index**: Consult `{wiki_dir}/{index_file}` (capped at {btree_root_max_lines} lines) to locate the appropriate shard (`{wiki_dir}/repo-nexus*.md` or `{wiki_dir}/repos-*.md`).
|
|
50
|
+
- **Step 2 — Domain Shard Pinpointing**: Read only the specific B-Tree leaf shard inside `{wiki_dir}/` identified in Step 1 to locate the target source path.
|
|
51
51
|
- **Step 3 — Authoritative Source Retrieval**: Open only the 1–3 authoritative workspace source document(s) referenced in the shard.
|
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
# Agentic Skill: ingest
|
|
2
2
|
|
|
3
|
-
Deterministically ingest missing documentation sources
|
|
3
|
+
Deterministically ingest missing documentation sources from {sources} into `{wiki_dir}/` using the `rnex` CLI.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
## Capabilities & Context
|
|
8
8
|
|
|
9
|
-
Use this skill when ingesting new reference materials, architecture documentation, transcripts, articles, or member repository documentation from
|
|
9
|
+
Use this skill when ingesting new reference materials, architecture documentation, transcripts, articles, or member repository documentation from {sources} into the curated wiki catalog shards inside `{wiki_dir}/`.
|
|
10
10
|
|
|
11
11
|
## CLI Helper
|
|
12
12
|
|
|
13
13
|
Always scaffold and ingest missing documentation deterministically using the built-in CLI helper:
|
|
14
14
|
|
|
15
15
|
```sh
|
|
16
|
-
rnex plugin llm-wiki ingest [
|
|
16
|
+
rnex plugin llm-wiki ingest [path/to/source] [--file path/to/doc.md] [--rewrite-links] [--strip-links] [--quiet]
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
- Ingest all missing sources
|
|
19
|
+
- Ingest all missing sources from {sources}:
|
|
20
20
|
```sh
|
|
21
21
|
rnex plugin llm-wiki ingest
|
|
22
22
|
```
|
|
23
23
|
- Ingest a specific missing document, directory, or glob pattern:
|
|
24
24
|
```sh
|
|
25
|
-
rnex plugin llm-wiki ingest
|
|
25
|
+
rnex plugin llm-wiki ingest path/to/source.md
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
## Agent Context Retrieval Protocol
|
|
29
29
|
|
|
30
30
|
AI coding agents navigate wiki context via the 3-step zero-token-bloat protocol:
|
|
31
|
-
1. **Root Router:** Read
|
|
32
|
-
2. **Shard Read:** Read the target shard directly in
|
|
31
|
+
1. **Root Router:** Read `{wiki_dir}/{index_file}` to locate the target shard file (`{wiki_dir}/repo-nexus*.md` or `{wiki_dir}/repos-*.md`).
|
|
32
|
+
2. **Shard Read:** Read the target shard directly in `{wiki_dir}/` to find the exact workspace file path and summary.
|
|
33
33
|
3. **In-Place Access:** Open the authoritative source file directly in place. To locate cross-references or backlinks, use native workspace search tools (`grep`, `ripgrep`).
|
|
34
34
|
|
|
35
35
|
## Ingestion Protocol
|
|
36
36
|
|
|
37
37
|
1. **Zero-Duplication In-Place Architecture:**
|
|
38
|
-
- Files are indexed directly in place from authoritative workspace paths
|
|
38
|
+
- Files are indexed directly in place from authoritative workspace paths in {sources} and member repositories under `{repos_dir}/`.
|
|
39
39
|
- Zero symbolic links (`ln -s`) and zero redundant content copies.
|
|
40
|
-
- Generated wiki artifacts reside exclusively inside `
|
|
40
|
+
- Generated wiki artifacts reside exclusively inside `{wiki_dir}/`: `{wiki_dir}/{index_file}` (root router table), `{wiki_dir}/{log_file}` (audit log), and flat leaf shards (`{wiki_dir}/repo-nexus*.md`, `{wiki_dir}/repos-*.md`).
|
|
41
41
|
|
|
42
42
|
2. **Deterministic CLI Ingestion (Missing Sources Only):**
|
|
43
|
-
- Execute `rnex plugin llm-wiki ingest [
|
|
44
|
-
- **NEVER** manually create, sort, or edit
|
|
45
|
-
- The CLI identifies which candidate sources from
|
|
46
|
-
- B-Tree shards are maintained in strict `LC_ALL=C` sort order.
|
|
47
|
-
-
|
|
48
|
-
- Relative Markdown links in source summaries
|
|
49
|
-
- Detailed document lifecycle records (`created`, `updated`, `deleted`) are appended to
|
|
43
|
+
- Execute `rnex plugin llm-wiki ingest [path/to/source]` under the hood.
|
|
44
|
+
- **NEVER** manually create, sort, or edit `{wiki_dir}/{index_file}` or `{wiki_dir}/*.md` shard files.
|
|
45
|
+
- The CLI identifies which candidate sources from {sources} have not yet been indexed and appends only missing entries into their respective B-Tree shards, preserving all existing shard entries and custom summaries intact.
|
|
46
|
+
- B-Tree shards are maintained in strict `LC_ALL=C` sort order and split automatically above {btree_shard_max_entries} entries.
|
|
47
|
+
- `{wiki_dir}/{index_file}` is recompiled atomically (bounded to {btree_root_max_lines} lines) to route to all existing shards.
|
|
48
|
+
- Relative Markdown links in source summaries use the active `{relative_links}` mode from `{wiki_dir}/` (pass `--strip-links` or `--rewrite-links` to override for a single run).
|
|
49
|
+
- Detailed document lifecycle records (`created`, `updated`, `deleted`) are appended to `{wiki_dir}/{log_file}`, capped at {log_max_records} records pruning oldest first.
|
|
50
50
|
|
|
51
51
|
3. **In-Place Synthesis & Enrichment:**
|
|
52
52
|
- Read and enrich authoritative source documents directly where they live.
|
|
53
53
|
- Maintain clear Markdown cross-references and backlinks.
|
|
54
54
|
|
|
55
55
|
4. **Integrity Verification:**
|
|
56
|
-
- Execute `rnex plugin llm-wiki lint` to verify zero symlinks, zero broken links, valid workspace references, and
|
|
56
|
+
- Execute `rnex plugin llm-wiki lint` to verify zero symlinks, zero broken links, valid workspace references, and the {btree_root_max_lines}-line limit on `{wiki_dir}/{index_file}`.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Agentic Skill: lint
|
|
2
2
|
|
|
3
|
-
Validate existing wiki documents, shard links, and workspace references inside
|
|
3
|
+
Validate existing wiki documents, shard links, and workspace references inside `{wiki_dir}/`.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
## Capabilities & Context
|
|
8
8
|
|
|
9
|
-
Use this skill to validate the curated flat wiki catalog
|
|
9
|
+
Use this skill to validate the curated flat wiki catalog inside `{wiki_dir}/`, ensuring all B-Tree shards, `{wiki_dir}/{index_file}` links, workspace references, and sort invariants remain consistent without scanning intake sources or triggering re-ingestion.
|
|
10
10
|
|
|
11
11
|
## CLI Helper
|
|
12
12
|
|
|
@@ -19,23 +19,23 @@ rnex plugin llm-wiki lint [--strict] [--quiet]
|
|
|
19
19
|
## Agent Context Retrieval Protocol
|
|
20
20
|
|
|
21
21
|
AI coding agents navigate wiki structure through:
|
|
22
|
-
1. **Root Router:** Read
|
|
23
|
-
2. **Leaf Shards:** Read
|
|
22
|
+
1. **Root Router:** Read `{wiki_dir}/{index_file}` to route to the appropriate shard.
|
|
23
|
+
2. **Leaf Shards:** Read `{wiki_dir}/repo-nexus*.md` or `{wiki_dir}/repos-*.md` directly in `{wiki_dir}/`.
|
|
24
24
|
3. **Authoritative Sources:** Read source documents directly in place in the workspace.
|
|
25
25
|
|
|
26
26
|
## Linting Protocol
|
|
27
27
|
|
|
28
28
|
1. **Scope & Source Independence:**
|
|
29
|
-
- Inspects existing files inside `
|
|
30
|
-
- Does NOT
|
|
31
|
-
- Enforces zero symbolic links across
|
|
29
|
+
- Inspects existing files inside `{wiki_dir}/` exclusively.
|
|
30
|
+
- Does NOT scan workspace intake sources and does NOT run ingestion of workspace files.
|
|
31
|
+
- Enforces zero symbolic links across `{wiki_dir}/`.
|
|
32
32
|
|
|
33
33
|
2. **Auto-Healing & Invariants:**
|
|
34
|
-
- **Root Router:** Validates that
|
|
34
|
+
- **Root Router:** Validates that `{wiki_dir}/{index_file}` exists and is within {btree_root_max_lines} lines; auto-rebuilds router to index orphan shards and prune dead shard links.
|
|
35
35
|
- **Workspace References:** Validates that every referenced workspace document in shard entries exists; prunes dead references to deleted files.
|
|
36
36
|
- **Relative Link Integrity:** Validates all relative Markdown links and `[[wikilinks]]`.
|
|
37
|
-
- **Deterministic Sort Order & Capacity:** Auto-heals and enforces strict `LC_ALL=C` sorting of catalog entries and splits shards exceeding
|
|
37
|
+
- **Deterministic Sort Order & Capacity:** Auto-heals and enforces strict `LC_ALL=C` sorting of catalog entries and splits shards exceeding {btree_shard_max_entries} entries.
|
|
38
38
|
|
|
39
39
|
3. **Conditional Audit Logging:**
|
|
40
|
-
- If issues are detected and repaired: appends granular audit records (`created`, `updated`, `deleted`) to
|
|
41
|
-
- If everything is already valid (clean run): does NOT touch
|
|
40
|
+
- If issues are detected and repaired: appends granular audit records (`created`, `updated`, `deleted`) to `{wiki_dir}/{log_file}` detailing the repairs, bounded by {log_max_records} records.
|
|
41
|
+
- If everything is already valid (clean run): does NOT touch `{wiki_dir}/{log_file}` or any wiki files, preserving clean working tree state for Git hooks (e.g. `pre-commit`).
|
|
@@ -1641,26 +1641,73 @@ pass
|
|
|
1641
1641
|
# --------------------------------------------------------------------------
|
|
1642
1642
|
# Test 30: AI instructions projection and Section 2 routing in .rnex/ai-instructions.md
|
|
1643
1643
|
# --------------------------------------------------------------------------
|
|
1644
|
-
run_test "LLM Wiki: ai-instructions.md projection and Section 2 routing contract"
|
|
1644
|
+
run_test "LLM Wiki: ai-instructions.md projection, concrete path instantiation, and Section 2 routing contract"
|
|
1645
1645
|
TEST_AI_INSTR_WS="$TEST_TMP/llm-wiki-ai-instr-ws"
|
|
1646
1646
|
mkdir -p "$TEST_AI_INSTR_WS"
|
|
1647
1647
|
setup_plugin_test_workspace llm-wiki "$TEST_AI_INSTR_WS"
|
|
1648
1648
|
(cd "$TEST_AI_INSTR_WS" && ./rnex init -y --llm-wiki "$TEST_AI_INSTR_WS" >/dev/null)
|
|
1649
1649
|
(cd "$TEST_AI_INSTR_WS" && ./rnex sync -y --quiet)
|
|
1650
1650
|
|
|
1651
|
-
# 1. Verify projected ai-instructions.md in .rnex/plugins/llm-wiki/
|
|
1651
|
+
# 1. Verify projected ai-instructions.md in .rnex/plugins/llm-wiki/ with default resolved values
|
|
1652
1652
|
_proj_ai="$TEST_AI_INSTR_WS/.rnex/plugins/llm-wiki/ai-instructions.md"
|
|
1653
1653
|
[ -f "$_proj_ai" ] || { fail ".rnex/plugins/llm-wiki/ai-instructions.md was not projected"; exit 1; }
|
|
1654
1654
|
grep -q "LLM Wiki AI Instructions" "$_proj_ai" || { fail "Projected ai-instructions.md content corrupted"; exit 1; }
|
|
1655
|
+
grep -qF ".rnex/wiki/index.md" "$_proj_ai" || { fail "Default wiki index path not resolved in ai-instructions.md"; exit 1; }
|
|
1655
1656
|
|
|
1656
|
-
# 2.
|
|
1657
|
+
# 2. Customize all llm-wiki and repos_dir settings and assert exact concrete paths with ZERO placeholders/config refs
|
|
1658
|
+
cat <<'EOF_CUSTOM_AI_CFG' > "$TEST_AI_INSTR_WS/rnex.yaml"
|
|
1659
|
+
version: 1.0.0
|
|
1660
|
+
repos_dir: "services"
|
|
1661
|
+
plugins:
|
|
1662
|
+
llm-wiki:
|
|
1663
|
+
wiki_dir: "knowledge/wiki"
|
|
1664
|
+
index_file: "HOME.md"
|
|
1665
|
+
log_file: "HISTORY.md"
|
|
1666
|
+
log_max_records: 250
|
|
1667
|
+
btree_root_max_lines: 42
|
|
1668
|
+
btree_shard_max_entries: 15
|
|
1669
|
+
relative_links: "strip"
|
|
1670
|
+
sources:
|
|
1671
|
+
- "guides"
|
|
1672
|
+
- "services/**/README.md"
|
|
1673
|
+
repos:
|
|
1674
|
+
EOF_CUSTOM_AI_CFG
|
|
1675
|
+
(cd "$TEST_AI_INSTR_WS" && ./rnex sync -y --quiet)
|
|
1676
|
+
|
|
1677
|
+
_proj_arch="$TEST_AI_INSTR_WS/.rnex/plugins/llm-wiki/instructions/rnex-wiki-architecture.md"
|
|
1678
|
+
_proj_rules="$TEST_AI_INSTR_WS/.rnex/plugins/llm-wiki/rules/behavioral.md"
|
|
1679
|
+
_proj_ingest="$TEST_AI_INSTR_WS/.rnex/plugins/llm-wiki/skills/ingest.md"
|
|
1680
|
+
_proj_lint="$TEST_AI_INSTR_WS/.rnex/plugins/llm-wiki/skills/lint.md"
|
|
1681
|
+
|
|
1682
|
+
grep -qF "knowledge/wiki/HOME.md" "$_proj_ai" || { fail "Custom wiki_dir/index_file not resolved in ai-instructions.md"; exit 1; }
|
|
1683
|
+
grep -qF "knowledge/wiki/HISTORY.md" "$_proj_ai" || { fail "Custom log_file not resolved in ai-instructions.md"; exit 1; }
|
|
1684
|
+
grep -qF 'guides/' "$_proj_ai" || { fail "Custom sources missing in ai-instructions.md"; exit 1; }
|
|
1685
|
+
grep -qF 'services/**/README.md' "$_proj_ai" || { fail "Custom glob source missing in ai-instructions.md"; exit 1; }
|
|
1686
|
+
grep -qF "knowledge/wiki/HOME.md" "$_proj_arch" || { fail "Custom wiki index path missing in rnex-wiki-architecture.md"; exit 1; }
|
|
1687
|
+
grep -qF "services/" "$_proj_rules" || { fail "Custom repos_dir missing in rules/behavioral.md"; exit 1; }
|
|
1688
|
+
grep -qF "42" "$_proj_rules" || { fail "Custom btree_root_max_lines missing in rules/behavioral.md"; exit 1; }
|
|
1689
|
+
grep -qF "strip" "$_proj_ingest" || { fail "Custom relative_links missing in skills/ingest.md"; exit 1; }
|
|
1690
|
+
grep -qF "250" "$_proj_ingest" || { fail "Custom log_max_records missing in skills/ingest.md"; exit 1; }
|
|
1691
|
+
grep -qF "15" "$_proj_lint" || { fail "Custom btree_shard_max_entries missing in skills/lint.md"; exit 1; }
|
|
1692
|
+
|
|
1693
|
+
for _proj_f in "$_proj_ai" "$_proj_arch" "$_proj_rules" "$_proj_ingest" "$_proj_lint"; do
|
|
1694
|
+
[ -f "$_proj_f" ] || { fail "Missing projected file $_proj_f"; exit 1; }
|
|
1695
|
+
if grep -qE '(\{[a-zA-Z0-9_-]+\}|<wiki_dir>|<index_file>|<log_file>|<repos_dir>|<source_path>)' "$_proj_f"; then
|
|
1696
|
+
fail "Unresolved placeholder detected in $_proj_f: $(cat "$_proj_f")"; exit 1;
|
|
1697
|
+
fi
|
|
1698
|
+
if grep -qE '(rnex\.yaml|plugins\.llm-wiki|default:|repos_dir)' "$_proj_f"; then
|
|
1699
|
+
fail "Disallowed rnex config reference detected in $_proj_f: $(cat "$_proj_f")"; exit 1;
|
|
1700
|
+
fi
|
|
1701
|
+
done
|
|
1702
|
+
|
|
1703
|
+
# 3. Verify Section 2 in .rnex/ai-instructions.md contains mandatory reference
|
|
1657
1704
|
_ai_instr="$TEST_AI_INSTR_WS/.rnex/ai-instructions.md"
|
|
1658
1705
|
[ -f "$_ai_instr" ] || { fail ".rnex/ai-instructions.md missing after sync"; exit 1; }
|
|
1659
1706
|
grep -qF "1. **Mandatory**: Read and follow \`.rnex/plugins/llm-wiki/ai-instructions.md\`." "$_ai_instr" || {
|
|
1660
1707
|
fail "Missing llm-wiki reference in Section 2 of ai-instructions.md"; exit 1;
|
|
1661
1708
|
}
|
|
1662
1709
|
|
|
1663
|
-
#
|
|
1710
|
+
# 4. Disable llm-wiki and assert removal from ai-instructions.md and fallback message
|
|
1664
1711
|
(cd "$TEST_AI_INSTR_WS" && ./rnex plugin disable llm-wiki >/dev/null)
|
|
1665
1712
|
! grep -qF "llm-wiki" "$_ai_instr" || { fail "llm-wiki reference not removed after plugin disable"; exit 1; }
|
|
1666
1713
|
grep -qF "No plugin AI instructions registered." "$_ai_instr" || {
|