repo-nexus 0.9.13 → 0.9.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "repo-nexus",
3
- "version": "0.9.13",
3
+ "version": "0.9.14",
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.9.13
2
+ version: 0.9.14
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.9.13
2
+ version: 0.9.14
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.9.13
2
+ version: 0.9.14
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.9.13
2
+ version: 0.9.14
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.9.13
2
+ version: 0.9.14
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
@@ -145,6 +145,7 @@ EOF
145
145
  # @sideEffects: Writes $RNEX_WIKI_INDEX_FILE atomically.
146
146
  # -----------------------------------------------------------------------------
147
147
  compile_root_index_router() {
148
+ ensure_baseline_flat_shards
148
149
  _idx_tmp="${RNEX_WIKI_INDEX_FILE}.tmp.$$"
149
150
  cat <<'EOF' > "$_idx_tmp"
150
151
  # Wiki Index
@@ -425,6 +426,7 @@ EOF
425
426
  resolve_target_btree_shard_file() {
426
427
  _s_id="$1"
427
428
  _doc_title="$2"
429
+ _doc_path="${3:-}"
428
430
  _base_file="${RNEX_WIKI_ROOT}/${_s_id}.md"
429
431
 
430
432
  # Find existing shard candidate files for this shard ID
@@ -451,13 +453,47 @@ resolve_target_btree_shard_file() {
451
453
  fi
452
454
  fi
453
455
 
456
+ _base_exists=0
457
+ [ -f "$_base_file" ] && _base_exists=1
458
+
454
459
  # Sub-shards exist; route title to the most appropriate sub-shard via awk
455
460
  printf '%s\n' "$_cand_files" | LC_ALL=C awk \
456
461
  -v sid="$_s_id" \
457
462
  -v title="$_doc_title" \
458
- -v def_file="$_base_file" '
463
+ -v path="$_doc_path" \
464
+ -v def_file="$_base_file" \
465
+ -v base_exists="$_base_exists" '
466
+ function clean_alpha_key(str, res, i, c, d) {
467
+ res = ""
468
+ for (i = 1; i <= length(str); i++) {
469
+ c = substr(str, i, 1)
470
+ if (c >= "a" && c <= "z") {
471
+ res = res c
472
+ } else if (c >= "A" && c <= "Z") {
473
+ res = res tolower(c)
474
+ } else if (c >= "0" && c <= "9") {
475
+ d = c + 0
476
+ if (d == 0) res = res "zero"
477
+ else if (d == 1) res = res "one"
478
+ else if (d == 2) res = res "two"
479
+ else if (d == 3) res = res "three"
480
+ else if (d == 4) res = res "four"
481
+ else if (d == 5) res = res "five"
482
+ else if (d == 6) res = res "six"
483
+ else if (d == 7) res = res "seven"
484
+ else if (d == 8) res = res "eight"
485
+ else if (d == 9) res = res "nine"
486
+ }
487
+ }
488
+ return res
489
+ }
459
490
  BEGIN {
460
- t = tolower(title)
491
+ kt = clean_alpha_key(title)
492
+ kp = clean_alpha_key(path)
493
+ if (kt != "") t = kt kp
494
+ else if (kp != "") t = kp
495
+ else t = "untitled"
496
+
461
497
  prefix = sid "-"
462
498
  first_child = ""
463
499
  last_child = ""
@@ -512,8 +548,14 @@ resolve_target_btree_shard_file() {
512
548
  print first_child
513
549
  } else if (t > "z" && last_child != "") {
514
550
  print last_child
515
- } else {
551
+ } else if (base_exists == 1 || first_child == "") {
516
552
  print def_file
553
+ } else {
554
+ if (first_child != "") {
555
+ print first_child
556
+ } else {
557
+ print def_file
558
+ }
517
559
  }
518
560
  }
519
561
  '
@@ -681,13 +723,27 @@ split_oversized_btree_shards() {
681
723
  }
682
724
  return ""
683
725
  }
684
- function clean_alpha_key(str, res, i, c) {
726
+ function clean_alpha_key(str, res, i, c, d) {
685
727
  res = ""
686
728
  for (i = 1; i <= length(str); i++) {
687
729
  c = substr(str, i, 1)
688
- if (c >= "a" && c <= "z") res = res c
689
- else if (c >= "0" && c <= "9") res = res c
690
- else if (c == "/" || c == "-" || c == "_") res = res "-"
730
+ if (c >= "a" && c <= "z") {
731
+ res = res c
732
+ } else if (c >= "A" && c <= "Z") {
733
+ res = res tolower(c)
734
+ } else if (c >= "0" && c <= "9") {
735
+ d = c + 0
736
+ if (d == 0) res = res "zero"
737
+ else if (d == 1) res = res "one"
738
+ else if (d == 2) res = res "two"
739
+ else if (d == 3) res = res "three"
740
+ else if (d == 4) res = res "four"
741
+ else if (d == 5) res = res "five"
742
+ else if (d == 6) res = res "six"
743
+ else if (d == 7) res = res "seven"
744
+ else if (d == 8) res = res "eight"
745
+ else if (d == 9) res = res "nine"
746
+ }
691
747
  }
692
748
  return res
693
749
  }
@@ -701,27 +757,19 @@ split_oversized_btree_shards() {
701
757
  t = tolower(get_title($0))
702
758
  p = tolower(get_path($0))
703
759
  titles[lines_count] = (t != "") ? t : "untitled"
704
- paths[lines_count] = (p != "") ? p : ("item-" lines_count)
760
+ paths[lines_count] = (p != "") ? p : ("item" lines_count)
705
761
  }
706
762
  END {
707
763
  if (lines_count == 0) exit 0
708
764
 
709
- # Check if all titles are identical
710
- all_titles_same = 1
711
- for (i = 2; i <= lines_count; i++) {
712
- if (titles[i] != titles[1]) {
713
- all_titles_same = 0
714
- break
715
- }
716
- }
717
-
718
- # Build sorting keys: use title if they differ; use title + "-" + path if all titles are identical
765
+ # Build sorting keys: title + unique path
719
766
  for (i = 1; i <= lines_count; i++) {
720
- if (all_titles_same) {
721
- clean_p = clean_alpha_key(paths[i])
722
- keys[i] = clean_alpha_key(titles[i]) "-" clean_p
767
+ kt = clean_alpha_key(titles[i])
768
+ kp = clean_alpha_key(paths[i])
769
+ if (kt != "") {
770
+ keys[i] = kt kp
723
771
  } else {
724
- keys[i] = clean_alpha_key(titles[i])
772
+ keys[i] = (kp != "") ? kp : ("entry" clean_alpha_key(i))
725
773
  }
726
774
  }
727
775
 
@@ -834,12 +882,17 @@ split_oversized_btree_shards() {
834
882
  }
835
883
  }
836
884
 
837
- # Pure alphabetical fallback: derive semantic letter ranges from halves
885
+ # Pure alphabetical fallback: find first character position where the two halves differ
838
886
  half_idx = int((lines_count + 1) / 2)
839
- k1_start = substr(keys[1], 1, 2)
840
- k1_end = substr(keys[half_idx], 1, 2)
841
- k2_start = substr(keys[half_idx + 1], 1, 2)
842
- k2_end = substr(keys[lines_count], 1, 2)
887
+ diff_pos = 1
888
+ while (substr(keys[half_idx], diff_pos, 1) == substr(keys[half_idx + 1], diff_pos, 1) && diff_pos < length(keys[half_idx])) {
889
+ diff_pos++
890
+ }
891
+
892
+ k1_start = substr(keys[1], 1, diff_pos)
893
+ k1_end = substr(keys[half_idx], 1, diff_pos)
894
+ k2_start = substr(keys[half_idx + 1], 1, diff_pos)
895
+ k2_end = substr(keys[lines_count], 1, diff_pos)
843
896
 
844
897
  sfx1 = (k1_start == k1_end) ? k1_start : (k1_start "-" k1_end)
845
898
  sfx2 = (k2_start == k2_end) ? k2_start : (k2_start "-" k2_end)
@@ -863,6 +916,12 @@ split_oversized_btree_shards() {
863
916
  _c1_id="${_child_names%%|*}"
864
917
  _c2_id="${_child_names#*|}"
865
918
 
919
+ # Safety guard: reject self-split or identical child names
920
+ if [ -z "$_c1_id" ] || [ -z "$_c2_id" ] || [ "$_c1_id" = "$_c2_id" ] || [ "$_c1_id" = "$_s_id" ] || [ "$_c2_id" = "$_s_id" ]; then
921
+ rm -f "$_part1_tmp" "$_part2_tmp"
922
+ continue
923
+ fi
924
+
866
925
  _wrote_any=0
867
926
 
868
927
  # Write Child 1 if part1 has entries
@@ -946,6 +1005,7 @@ ingest_missing_sources_into_btree() {
946
1005
  _missing_file="$1"
947
1006
  _arg_label="$2"
948
1007
  mkdir -p "$RNEX_WIKI_ROOT"
1008
+ ensure_baseline_flat_shards
949
1009
 
950
1010
  # If zero missing sources, inspect existing shards for any needed splits before declaring up-to-date
951
1011
  if [ ! -s "$_missing_file" ] && [ -f "$RNEX_WIKI_INDEX_FILE" ]; then
@@ -993,7 +1053,7 @@ ingest_missing_sources_into_btree() {
993
1053
  _entry_line="- **[${_title}](${_rel_link})** (\`${_rel_path}\`) — ${_summary}"
994
1054
 
995
1055
  # Route dynamically to existing leaf sub-shard or base shard
996
- _target_shard_file="$(resolve_target_btree_shard_file "$_shard_id" "$_title")"
1056
+ _target_shard_file="$(resolve_target_btree_shard_file "$_shard_id" "$_title" "$_rel_path")"
997
1057
 
998
1058
  _shard_existed=0
999
1059
  [ -f "$_target_shard_file" ] && _shard_existed=1
@@ -209,7 +209,7 @@ lint_existing_wiki_directory() {
209
209
  fi
210
210
  fi
211
211
 
212
- _target_shard_file="$(resolve_target_btree_shard_file "$_shard_id" "$_title")"
212
+ _target_shard_file="$(resolve_target_btree_shard_file "$_shard_id" "$_title" "$_rel_path")"
213
213
  _target_shard_id="$(basename "$_target_shard_file" .md)"
214
214
 
215
215
  _t_entries="${_target_shard_file}.entries.$$"
@@ -268,6 +268,30 @@ lint_existing_wiki_directory() {
268
268
  -v k="${#_sp}" \
269
269
  -v val_file="$_valid_entries" \
270
270
  -v mis_file="$_misplaced_entries" '
271
+ function clean_alpha_key(str, res, i, c, d) {
272
+ res = ""
273
+ for (i = 1; i <= length(str); i++) {
274
+ c = substr(str, i, 1)
275
+ if (c >= "a" && c <= "z") {
276
+ res = res c
277
+ } else if (c >= "A" && c <= "Z") {
278
+ res = res tolower(c)
279
+ } else if (c >= "0" && c <= "9") {
280
+ d = c + 0
281
+ if (d == 0) res = res "zero"
282
+ else if (d == 1) res = res "one"
283
+ else if (d == 2) res = res "two"
284
+ else if (d == 3) res = res "three"
285
+ else if (d == 4) res = res "four"
286
+ else if (d == 5) res = res "five"
287
+ else if (d == 6) res = res "six"
288
+ else if (d == 7) res = res "seven"
289
+ else if (d == 8) res = res "eight"
290
+ else if (d == 9) res = res "nine"
291
+ }
292
+ }
293
+ return res
294
+ }
271
295
  function get_title(line, m) {
272
296
  if (match(line, /^- \*\*\[[^]]+\]/)) {
273
297
  m = substr(line, 6)
@@ -280,10 +304,25 @@ lint_existing_wiki_directory() {
280
304
  }
281
305
  return ""
282
306
  }
307
+ function get_path(line, m) {
308
+ if (match(line, /\(`[^`]+`\)/)) {
309
+ m = substr(line, RSTART + 2, RLENGTH - 4)
310
+ return m
311
+ } else if (match(line, /\]\([^)]+\)/)) {
312
+ m = substr(line, RSTART + 2, RLENGTH - 3)
313
+ return m
314
+ }
315
+ return ""
316
+ }
283
317
  /^- \*\*/ {
284
- t = tolower(get_title($0))
318
+ kt = clean_alpha_key(get_title($0))
319
+ kp = clean_alpha_key(get_path($0))
320
+ if (kt != "") t = kt kp
321
+ else if (kp != "") t = kp
322
+ else t = "untitled"
323
+
285
324
  pfx = substr(t, 1, k)
286
- if ((sp == "a" && pfx < sp) || (pfx >= sp && pfx <= ep)) {
325
+ if ((sp == "a" && pfx < sp) || (pfx >= sp && (ep == "z" || pfx <= ep))) {
287
326
  print $0 >> val_file
288
327
  } else {
289
328
  print $0 >> mis_file
@@ -330,7 +369,7 @@ lint_existing_wiki_directory() {
330
369
  fi
331
370
  fi
332
371
 
333
- _target_shard_file="$(resolve_target_btree_shard_file "$_t_shard_id" "$_title")"
372
+ _target_shard_file="$(resolve_target_btree_shard_file "$_t_shard_id" "$_title" "$_rel_path")"
334
373
  _target_shard_id="$(basename "$_target_shard_file" .md)"
335
374
 
336
375
  _t_entries="${_target_shard_file}.entries.$$"
@@ -1,5 +1,5 @@
1
1
  name: karpathy-llm
2
- version: 0.9.13
2
+ version: 0.9.14
3
3
  description: "Deterministic B-Tree Markdown Wiki in .rnex/wiki for AI agents"
4
4
  config:
5
5
  wiki_dir: ".rnex/wiki"
@@ -1509,6 +1509,84 @@ done
1509
1509
  }
1510
1510
  pass
1511
1511
 
1512
+ # --------------------------------------------------------------------------
1513
+ # Test 29: Idempotency across repeated ingest -> lint -> ingest -> lint cycles
1514
+ # --------------------------------------------------------------------------
1515
+ run_test "Karpathy-llm: strict idempotency across repeated ingest/lint cycles (zero ping-pong repairs)"
1516
+ TEST_IDEM_WS="$TEST_TMP/karpathy-idem-ws"
1517
+ mkdir -p "$TEST_IDEM_WS"
1518
+ setup_plugin_test_workspace karpathy-llm "$TEST_IDEM_WS"
1519
+ cd "$TEST_IDEM_WS"
1520
+
1521
+ "$TEST_IDEM_WS/rnex" init -y --karpathy "$TEST_IDEM_WS" >/dev/null
1522
+ mkdir -p "$TEST_IDEM_WS/wiki"
1523
+ mkdir -p "$TEST_IDEM_WS/repos/test-repo/packages"
1524
+
1525
+ _k=1
1526
+ while [ "$_k" -le 175 ]; do
1527
+ mkdir -p "$TEST_IDEM_WS/repos/test-repo/packages/pkg-$_k"
1528
+ printf '# Package %s\nDocumentation for package %s.\n' "$_k" "$_k" > "$TEST_IDEM_WS/repos/test-repo/packages/pkg-$_k/README.md"
1529
+ _k=$((_k + 1))
1530
+ done
1531
+
1532
+ cat <<'EOF_IDEM_CFG' > "$TEST_IDEM_WS/rnex.yaml"
1533
+ version: 1.0.0
1534
+ plugins:
1535
+ karpathy-llm:
1536
+ wiki_dir: wiki
1537
+ btree_shard_max_entries: 100
1538
+ sources: [repos/test-repo/packages]
1539
+ repos:
1540
+ test-repo:
1541
+ path: repos/test-repo
1542
+ EOF_IDEM_CFG
1543
+
1544
+ # Cycle 1: First Ingest
1545
+ _out_ingest1="$(cd "$TEST_IDEM_WS" && ./rnex plugin karpathy-llm ingest)"
1546
+ echo "$_out_ingest1" | grep -q "Ingested 175 missing source(s)" || {
1547
+ fail "First ingest failed to ingest 175 sources: $_out_ingest1"; exit 1;
1548
+ }
1549
+
1550
+ # Invariant: All shards must have <= 100 entries and zero numeric shards
1551
+ for _shard in "$TEST_IDEM_WS/wiki"/*.md; do
1552
+ [ -f "$_shard" ] || continue
1553
+ case "$(basename "$_shard")" in
1554
+ index.md|log.md) continue ;;
1555
+ esac
1556
+ _cnt="$(LC_ALL=C grep -c '^- \*\*' "$_shard" 2>/dev/null || true)"
1557
+ [ "$_cnt" -le 100 ] || { fail "Shard $(basename "$_shard") has $_cnt records (> 100)"; exit 1; }
1558
+ done
1559
+ _num_shards="$(find "$TEST_IDEM_WS/wiki" -name '*-[0-9]*.md' | grep -v 'log.md' || true)"
1560
+ [ -z "$_num_shards" ] || { fail "Numeric shards found: $_num_shards"; exit 1; }
1561
+
1562
+ # Cycle 2: First Lint (must be 100% clean with ZERO repairs)
1563
+ _out_lint1="$(cd "$TEST_IDEM_WS" && ./rnex plugin karpathy-llm lint)"
1564
+ echo "$_out_lint1" | grep -q "all existing docs and references in wiki are valid" || {
1565
+ fail "First lint reported repairs instead of clean validation: $_out_lint1"; exit 1;
1566
+ }
1567
+
1568
+ # Capture log checksum after first lint
1569
+ _log_sum1="$(cksum < "$TEST_IDEM_WS/wiki/log.md")"
1570
+
1571
+ # Cycle 3: Second Ingest (must be completely up to date with zero changes)
1572
+ _out_ingest2="$(cd "$TEST_IDEM_WS" && ./rnex plugin karpathy-llm ingest)"
1573
+ echo "$_out_ingest2" | grep -q "Wiki is up to date" || {
1574
+ fail "Second ingest re-ingested sources instead of reporting up to date: $_out_ingest2"; exit 1;
1575
+ }
1576
+
1577
+ # Cycle 4: Second Lint (must be 100% clean with ZERO repairs)
1578
+ _out_lint2="$(cd "$TEST_IDEM_WS" && ./rnex plugin karpathy-llm lint)"
1579
+ echo "$_out_lint2" | grep -q "all existing docs and references in wiki are valid" || {
1580
+ fail "Second lint reported repairs on unchanged wiki: $_out_lint2"; exit 1;
1581
+ }
1582
+
1583
+ # Verify audit log was not mutated in cycles 2, 3, or 4
1584
+ _log_sum2="$(cksum < "$TEST_IDEM_WS/wiki/log.md")"
1585
+ [ "$_log_sum1" = "$_log_sum2" ] || {
1586
+ fail "Operational log mutated during idempotent read-only cycles"; exit 1;
1587
+ }
1588
+ pass
1589
+
1512
1590
  if [ "${_STANDALONE_RUN:-0}" -eq 1 ]; then
1513
1591
  report_results
1514
1592
  fi
@@ -1,5 +1,5 @@
1
1
  name: windsurf
2
- version: 0.9.13
2
+ version: 0.9.14
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