repo-nexus 0.8.34 → 0.9.0
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/ai.sh +6 -15
- package/lib/commands/init.sh +0 -1
- package/lib/commands/status.sh +0 -3
- package/lib/plugins.sh +3 -11
- package/lib/workspace.sh +0 -2
- package/lib/yaml.sh +0 -15
- package/package.json +2 -2
- package/plugins/claude/plugin.yaml +1 -1
- package/plugins/codex/plugin.yaml +1 -1
- package/plugins/copilot/plugin.yaml +1 -1
- package/plugins/cursor/plugin.yaml +1 -1
- package/plugins/gemini/plugin.yaml +1 -1
- package/plugins/karpathy-llm/README.md +62 -27
- package/plugins/karpathy-llm/bin/graph.sh +4 -0
- package/plugins/karpathy-llm/bin/index.sh +4 -0
- package/plugins/karpathy-llm/bin/ingest.sh +4 -0
- package/plugins/karpathy-llm/bin/init.sh +4 -0
- package/plugins/karpathy-llm/bin/lint.sh +4 -0
- package/plugins/karpathy-llm/bin/search.sh +4 -0
- package/plugins/karpathy-llm/commands/graph.sh +91 -0
- package/plugins/karpathy-llm/commands/index.sh +205 -0
- package/plugins/karpathy-llm/commands/ingest.sh +25 -47
- package/plugins/karpathy-llm/commands/init.sh +114 -0
- package/plugins/karpathy-llm/commands/lint.sh +126 -50
- package/plugins/karpathy-llm/commands/search.sh +96 -0
- package/plugins/karpathy-llm/hooks/_common.sh +60 -259
- package/plugins/karpathy-llm/hooks/after_sync.sh +8 -45
- package/plugins/karpathy-llm/instructions/rnex-scaffolding-meta-prompt.md +10 -10
- package/plugins/karpathy-llm/instructions/rnex-wiki-architecture.md +2 -2
- package/plugins/karpathy-llm/lib/btree_helpers.sh +270 -0
- package/plugins/karpathy-llm/lib/config.sh +137 -0
- package/plugins/karpathy-llm/lib/graph_helpers.sh +209 -0
- package/plugins/karpathy-llm/lib/utils.sh +145 -0
- package/plugins/karpathy-llm/plugin.yaml +16 -5
- package/plugins/karpathy-llm/rules/behavioral.md +3 -3
- package/plugins/karpathy-llm/skills/wiki-ingest.md +7 -13
- package/plugins/karpathy-llm/skills/wiki-lint.md +9 -11
- package/plugins/karpathy-llm/templates/index.md +15 -21
- package/plugins/karpathy-llm/tests/test_plugin.sh +214 -100
- package/plugins/windsurf/plugin.yaml +1 -1
- package/templates/rnex.example.yaml +5 -1
- package/plugins/karpathy-llm/templates/hot.md +0 -13
package/lib/ai.sh
CHANGED
|
@@ -41,14 +41,10 @@ ${_active_repos_dir}/*
|
|
|
41
41
|
.rnex*/
|
|
42
42
|
rnex*/
|
|
43
43
|
|
|
44
|
-
# Local machine-specific configuration
|
|
44
|
+
# Local machine-specific configuration
|
|
45
45
|
$RNEX_LOCAL_CONFIG_FILE
|
|
46
46
|
.rnex.local.yaml
|
|
47
|
-
wiki/hot.md
|
|
48
47
|
GI_SECTION_EOF
|
|
49
|
-
if [ "$_active_wiki_dir" != "wiki" ]; then
|
|
50
|
-
printf '%s/hot.md\n' "$_active_wiki_dir"
|
|
51
|
-
fi
|
|
52
48
|
|
|
53
49
|
_custom_ignores="$(yaml_get_git_ignore 2>/dev/null || true)"
|
|
54
50
|
if [ -n "$_custom_ignores" ]; then
|
|
@@ -57,7 +53,7 @@ GI_SECTION_EOF
|
|
|
57
53
|
printf '%s\n' "$_custom_ignores" | while IFS= read -r _ci || [ -n "$_ci" ]; do
|
|
58
54
|
[ -n "$_ci" ] || continue
|
|
59
55
|
case "$_ci" in
|
|
60
|
-
"repos/"|"repos/*"|"!repos/.gitkeep"|"${_active_repos_dir}/"|"${_active_repos_dir}/*"|"!${_active_repos_dir}/.gitkeep"|"**/.rnex*/"|"**/rnex*/"|".rnex*/"|"rnex*/"|"$RNEX_LOCAL_CONFIG_FILE"|".rnex.local.yaml"
|
|
56
|
+
"repos/"|"repos/*"|"!repos/.gitkeep"|"${_active_repos_dir}/"|"${_active_repos_dir}/*"|"!${_active_repos_dir}/.gitkeep"|"**/.rnex*/"|"**/rnex*/"|".rnex*/"|"rnex*/"|"$RNEX_LOCAL_CONFIG_FILE"|".rnex.local.yaml")
|
|
61
57
|
continue
|
|
62
58
|
;;
|
|
63
59
|
esac
|
|
@@ -445,15 +441,10 @@ render_ai_instructions() {
|
|
|
445
441
|
printf 'Execute these steps in strict order:\n'
|
|
446
442
|
_rai_n=1
|
|
447
443
|
if [ "$_rai_kp" -eq 1 ]; then
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
_rai_n=3
|
|
453
|
-
else
|
|
454
|
-
printf "1. **Step 1 — Read Wiki Index**: Read \`%s/index.md\` first and read only the relevant atomic page(s) in \`%s/\`. Do NOT read raw intake sources%s or \`%s/\` before completing Step 1.\n" "$_rai_wiki" "$_rai_wiki" "${_rai_src_dirs:+ ($_rai_src_dirs)}" "$_rai_rd"
|
|
455
|
-
_rai_n=2
|
|
456
|
-
fi
|
|
444
|
+
printf "1. **Step 1 — Query B-Tree Root Index & Graph**: Read \`%s/index.md\` (compact B-Tree router <= 80 lines) or run \`rnex plugin karpathy-llm search <keyword>\` to locate matching shard or node identifiers. For node dependency exploration, run \`rnex plugin karpathy-llm graph <node_id>\`.\n" "$_rai_wiki"
|
|
445
|
+
printf "2. **Step 2 — Inspect Targeted Domain Shard**: Read only the relevant shard in \`%s/_index/<shard>.md\` identified in Step 1. Pinpoint the specific leaf page needed without exhaustive reading.\n" "$_rai_wiki"
|
|
446
|
+
printf "3. **Step 3 — Read Curated Wiki Leaf Page**: Read only the 1–3 target atomic page(s) in \`%s/\`. Do NOT read raw intake sources%s or \`%s/\` before completing Steps 1–2.\n" "$_rai_wiki" "${_rai_src_dirs:+ ($_rai_src_dirs)}" "$_rai_rd"
|
|
447
|
+
_rai_n=4
|
|
457
448
|
fi
|
|
458
449
|
printf "%s. **Step %s — Targeted Repository Access**: Inspect or modify only the specific files in active \`%s/<name>/\` required for the task. Never modify or commit inside \`READ-ONLY\` repositories.\n" "$_rai_n" "$_rai_n" "$_rai_rd"
|
|
459
450
|
_rai_n=$((_rai_n + 1))
|
package/lib/commands/init.sh
CHANGED
package/lib/commands/status.sh
CHANGED
|
@@ -228,9 +228,6 @@ cmd_status() {
|
|
|
228
228
|
_phooks="$(yaml_list_plugin_hooks "$_pname" 2>/dev/null | awk '{ out = (NR == 1) ? $0 : out "+" $0 } END { if (NR) print out }')"
|
|
229
229
|
_opts="${_opts:+$_opts, }hooks=${_phooks:-none}"
|
|
230
230
|
fi
|
|
231
|
-
if grep -q "hot_file:" "$_pdir/plugin.yaml" 2>/dev/null || [ -n "$(yaml_plugin_get "$_pname" "hot_file" 2>/dev/null)" ]; then
|
|
232
|
-
_opts="${_opts:+$_opts, }hot_file=$(provider_option_enabled "$_pname" "hot_file" && echo "true" || echo "false")"
|
|
233
|
-
fi
|
|
234
231
|
if [ -n "$_opts" ]; then
|
|
235
232
|
printf ' %b↳ Options: %s%b\n' "$_DIM" "$_opts" "$_NC"
|
|
236
233
|
fi
|
package/lib/plugins.sh
CHANGED
|
@@ -428,12 +428,12 @@ sync_plugin_bundle() {
|
|
|
428
428
|
|
|
429
429
|
mkdir -p "$_spb_dest"
|
|
430
430
|
rm -rf "${_spb_dest:?}/prompts" 2>/dev/null || true
|
|
431
|
-
for _sub in rules workflows instructions skills agents templates hooks commands; do
|
|
431
|
+
for _sub in rules workflows instructions skills agents templates hooks commands lib bin; do
|
|
432
432
|
if [ -d "$_spb_src/$_sub" ]; then
|
|
433
433
|
rm -rf "${_spb_dest:?}/$_sub"
|
|
434
434
|
mkdir -p "$_spb_dest/$_sub"
|
|
435
435
|
cp -R "$_spb_src/$_sub"/. "$_spb_dest/$_sub"/ 2>/dev/null || true
|
|
436
|
-
if [ "$_sub" = "hooks" ] || [ "$_sub" = "commands" ]; then
|
|
436
|
+
if [ "$_sub" = "hooks" ] || [ "$_sub" = "commands" ] || [ "$_sub" = "bin" ]; then
|
|
437
437
|
chmod +x "$_spb_dest/$_sub"/* 2>/dev/null || true
|
|
438
438
|
fi
|
|
439
439
|
else
|
|
@@ -483,7 +483,7 @@ _clean_leaked_plugin_dirs() {
|
|
|
483
483
|
[ -e "$_f" ] || continue
|
|
484
484
|
_b="$(basename "$_f")"
|
|
485
485
|
case "$_b" in
|
|
486
|
-
index.md|_log.md
|
|
486
|
+
index.md|_log.md|.gitkeep) continue ;;
|
|
487
487
|
*)
|
|
488
488
|
[ -f "$_cld_root/$_cld_wiki/$_b" ] && cmp -s "$_f" "$_cld_root/$_cld_wiki/$_b" && continue
|
|
489
489
|
_can_clean=0
|
|
@@ -599,14 +599,6 @@ sync_plugins() {
|
|
|
599
599
|
_src_path="$_pdir/$_s"
|
|
600
600
|
_dest_path="$NEXUS_DIR/$_d"
|
|
601
601
|
|
|
602
|
-
if [ "$_pname" = "karpathy-llm" ] && [ "$_s" = "templates/hot.md" ]; then
|
|
603
|
-
_hot_opt="$(yaml_plugin_get "karpathy-llm" "hot_file" 2>/dev/null || printf 'true')"
|
|
604
|
-
if ! is_enabled_val "$_hot_opt"; then
|
|
605
|
-
rm -f "$_dest_path" 2>/dev/null || true
|
|
606
|
-
continue
|
|
607
|
-
fi
|
|
608
|
-
fi
|
|
609
|
-
|
|
610
602
|
if [ -f "$_src_path" ] && [ ! -f "$_dest_path" ]; then
|
|
611
603
|
mkdir -p "$(dirname "$_dest_path")"
|
|
612
604
|
plugin_instantiate_template "$_pname" "$_pdir" "$_src_path" "$_dest_path"
|
package/lib/workspace.sh
CHANGED
|
@@ -379,7 +379,6 @@ upgrade_workspace_config() {
|
|
|
379
379
|
print " - \"" ard "/\""
|
|
380
380
|
print " - \"**/.rnex*/\""
|
|
381
381
|
print " - \"**/rnex*/\""
|
|
382
|
-
print " - \"wiki/hot.md\""
|
|
383
382
|
print " hooks:"
|
|
384
383
|
print " post-merge:"
|
|
385
384
|
print " - \"rnex sync --quiet\""
|
|
@@ -407,7 +406,6 @@ upgrade_workspace_config() {
|
|
|
407
406
|
print " - \"" ard "/\""
|
|
408
407
|
print " - \"**/.rnex*/\""
|
|
409
408
|
print " - \"**/rnex*/\""
|
|
410
|
-
print " - \"wiki/hot.md\""
|
|
411
409
|
print " hooks:"
|
|
412
410
|
print " post-merge:"
|
|
413
411
|
print " - \"rnex sync --quiet\""
|
package/lib/yaml.sh
CHANGED
|
@@ -1054,23 +1054,8 @@ yaml_get_plugin_config() {
|
|
|
1054
1054
|
_ygpc_local="${NEXUS_LOCAL_CONFIG:-$_wly}"
|
|
1055
1055
|
_ygpc_main="${NEXUS_CONFIG:-$_wy}"
|
|
1056
1056
|
|
|
1057
|
-
# Determine potential alias keys (e.g. hot_file <-> hotFile <-> hot)
|
|
1058
1057
|
_ygpc_alt=""
|
|
1059
1058
|
_ygpc_alt2=""
|
|
1060
|
-
case "$_ygpc_key" in
|
|
1061
|
-
hot_file)
|
|
1062
|
-
_ygpc_alt="hotFile"
|
|
1063
|
-
_ygpc_alt2="hot"
|
|
1064
|
-
;;
|
|
1065
|
-
hotFile)
|
|
1066
|
-
_ygpc_alt="hot_file"
|
|
1067
|
-
_ygpc_alt2="hot"
|
|
1068
|
-
;;
|
|
1069
|
-
hot)
|
|
1070
|
-
_ygpc_alt="hot_file"
|
|
1071
|
-
_ygpc_alt2="hotFile"
|
|
1072
|
-
;;
|
|
1073
|
-
esac
|
|
1074
1059
|
|
|
1075
1060
|
# 1. Query .local.rnex.yaml first
|
|
1076
1061
|
if [ -f "$_ygpc_local" ]; then
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repo-nexus",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
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",
|
|
@@ -64,4 +64,4 @@
|
|
|
64
64
|
"esbuild": "^0.25.0",
|
|
65
65
|
"vite": "^6.4.4"
|
|
66
66
|
}
|
|
67
|
-
}
|
|
67
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The **`karpathy-llm`** plugin packages Andrej Karpathy's agent behavioral principles, multi-repo context engineering standards, and the autonomous **Karpathy LLM Wiki** knowledge architecture for AI coding assistants (Cursor, Claude Code, GitHub Copilot, Antigravity, Windsurf).
|
|
4
4
|
|
|
5
|
-
No external vector databases, embedding pipelines, or MCP servers required — just
|
|
5
|
+
No external vector databases, embedding pipelines, or MCP servers required — just a 2-level B-Tree sharded index, sorted TSV property graph, and interlinked markdown files traversed natively by AI agents.
|
|
6
6
|
|
|
7
7
|
Reference specification: [setup-karpathy-wiki.md](https://github.com/unoxen/ai-toolkit/blob/main/prompts/setup-karpathy-wiki.md) (also available locally in [`instructions/rnex-scaffolding-meta-prompt.md`](instructions/rnex-scaffolding-meta-prompt.md)).
|
|
8
8
|
|
|
@@ -18,17 +18,19 @@ Reference specification: [setup-karpathy-wiki.md](https://github.com/unoxen/ai-t
|
|
|
18
18
|
|
|
19
19
|
### 2. Multi-Repo Context Engineering & Autonomy (`rules/behavioral.md`)
|
|
20
20
|
* Guidelines tailored for Repo Nexus workspaces respecting member repository autonomy and physical repository boundaries.
|
|
21
|
+
* Deterministic 3-step retrieval protocol: B-Tree Root Router (`index.md`) $\to$ Targeted Leaf Shard (`_index/<shard>.md`) $\to$ Target Leaf Markdown Page.
|
|
21
22
|
|
|
22
|
-
### 3.
|
|
23
|
-
* **Intake Sources (`sources`, default: `["docs", "repos/**/README.md"]`):** Multi-value array of directory paths and glob patterns for unmodified source material (articles, transcripts, docs, meeting notes, repo READMEs).
|
|
23
|
+
### 3. Zero-Dependency B-Tree & TSV Graph Architecture (`instructions/rnex-wiki-architecture.md`)
|
|
24
|
+
* **Intake Sources (`sources`, default: `["docs", "repos/**/README.md"]`):** Multi-value array of directory paths and glob patterns for unmodified source material (articles, transcripts, docs, meeting notes, repo READMEs).
|
|
24
25
|
* **Curated Knowledge Base (`wiki_dir`, default: `wiki`):** Interlinked atomic markdown pages, each with typed frontmatter relations (`sources`, `related`, `extends`, `contradicts`, `mentioned_in`).
|
|
25
|
-
* **
|
|
26
|
-
* **
|
|
27
|
-
* **
|
|
26
|
+
* **B-Tree Root Router (`<wiki_dir>/index.md`):** Compact, strictly bounded routing table ($\le 80$ lines, zero YAML frontmatter) mapping lexicographic key ranges to leaf shard files in `_index/`.
|
|
27
|
+
* **B-Tree Leaf Shards (`<wiki_dir>/_index/*.md`):** Lexicographically sorted catalogs (`overview.md`, `concepts.md`, `entities.md`, `sources.md`). Automatically split into alphabetical sub-shards (`<shard>-a-m.md`, `<shard>-n-z.md`) when exceeding capacity thresholds.
|
|
28
|
+
* **Sorted TSV Property Graph (`<wiki_dir>/_graph/*.tsv`):** Plain-text adjacency lists (`nodes.tsv`, `edges_out.tsv`, `edges_in.tsv`) maintaining graph topology and supporting $O(\log N)$ binary search traversal via BSD `look` or early-exit POSIX `awk`.
|
|
29
|
+
* **Audit Trail (`<wiki_dir>/_log.md`):** Shared append-only log recording ingest, graph update, and lint operations across tracked wiki pages. Inspected via `tail -n 20 _log.md`.
|
|
28
30
|
|
|
29
31
|
### 4. Standardized Agent Skills (`skills/`)
|
|
30
|
-
* **`wiki-ingest.md` (User Skill: `rnex-karpathy-llm-wiki-ingest`):** Guides deterministic CLI scaffolding and in-place AI enrichment for intake source documents
|
|
31
|
-
* **`wiki-lint.md` (User Skill: `rnex-karpathy-llm-wiki-lint`):** Integrity audit protocol to validate paths, recompute `
|
|
32
|
+
* **`wiki-ingest.md` (User Skill: `rnex-karpathy-llm-wiki-ingest`):** Guides deterministic CLI scaffolding, graph registration in `_graph/*.tsv`, B-Tree shard rebalancing, and in-place AI enrichment for intake source documents.
|
|
33
|
+
* **`wiki-lint.md` (User Skill: `rnex-karpathy-llm-wiki-lint`):** Integrity audit protocol to validate paths, recompute graph edges, detect broken `[[wikilinks]]`, verify root line budget ($\le 80$ lines), purge legacy caches, and verify sort order.
|
|
32
34
|
|
|
33
35
|
---
|
|
34
36
|
|
|
@@ -38,16 +40,16 @@ To ensure workspaces remain 100% predictable, understandable, and consistent acr
|
|
|
38
40
|
|
|
39
41
|
### Phase 1: 100% Deterministic Initialization
|
|
40
42
|
Enabling the plugin (`rnex plugin enable karpathy-llm`) performs an exact, zero-interview scaffolding step:
|
|
41
|
-
* **Predictable Baseline**:
|
|
43
|
+
* **Predictable Baseline**: Standard baseline files are created (`docs/.gitkeep`, `wiki/index.md`, `wiki/_log.md`, `wiki/_index/*.md`, `wiki/_graph/*.tsv`).
|
|
42
44
|
* **Scoped Assets**: Behavioral rules, wiki architecture guides, skills, commands, and templates are cleanly isolated under `.rnex/plugins/karpathy-llm/`.
|
|
43
45
|
* **Zero Guesswork**: No interactive interviews, no AI-generated folder variances, and no "agent decides" ambiguities at init time.
|
|
44
|
-
* **Idempotent**: Safe to run repeatedly; existing
|
|
46
|
+
* **Idempotent**: Safe to run repeatedly; existing curated wiki pages are never overwritten.
|
|
45
47
|
|
|
46
48
|
### Phase 2: Evolutionary Growth & Domain Specialization (Usage Phase)
|
|
47
49
|
Once initialized, the workspace structure organically evolves according to actual domain needs and source materials:
|
|
48
|
-
* **Source Ingestion (`rnex-karpathy-llm-wiki-ingest`)**: As raw source documents are deposited into `./docs` and ingested, atomic pages are generated
|
|
49
|
-
* **Customizable Guidelines**: Teams can tailor `rules/behavioral.md` and `instructions/rnex-wiki-architecture.md` for their specific
|
|
50
|
-
* **Graph Maintenance (`rnex-karpathy-llm-wiki-lint`)**: The periodic lint workflow validates relation paths,
|
|
50
|
+
* **Source Ingestion (`rnex-karpathy-llm-wiki-ingest`)**: As raw source documents are deposited into `./docs` and ingested, atomic pages are generated, graph edges are registered in `_graph/*.tsv`, and B-Tree shards in `_index/*.md` are automatically rebalanced.
|
|
51
|
+
* **Customizable Guidelines**: Teams can tailor `rules/behavioral.md` and `instructions/rnex-wiki-architecture.md` for their specific conventions.
|
|
52
|
+
* **Graph Maintenance (`rnex-karpathy-llm-wiki-lint`)**: The periodic lint workflow validates relation paths, verifies sort invariants, and flags broken wikilinks.
|
|
51
53
|
|
|
52
54
|
---
|
|
53
55
|
|
|
@@ -60,9 +62,17 @@ my-workspace/
|
|
|
60
62
|
├── docs/
|
|
61
63
|
│ └── .gitkeep # Intake for unmodified source documents
|
|
62
64
|
├── wiki/
|
|
63
|
-
│ ├── index.md #
|
|
64
|
-
│ ├──
|
|
65
|
-
│
|
|
65
|
+
│ ├── index.md # B-Tree Root Router (<= 80 lines)
|
|
66
|
+
│ ├── _log.md # Ingestion & lint audit history
|
|
67
|
+
│ ├── _index/ # B-Tree Domain Shards (sorted LC_ALL=C)
|
|
68
|
+
│ │ ├── overview.md
|
|
69
|
+
│ │ ├── concepts.md
|
|
70
|
+
│ │ ├── entities.md
|
|
71
|
+
│ │ └── sources.md
|
|
72
|
+
│ └── _graph/ # Sorted TSV Property Graph
|
|
73
|
+
│ ├── nodes.tsv
|
|
74
|
+
│ ├── edges_out.tsv
|
|
75
|
+
│ └── edges_in.tsv
|
|
66
76
|
├── .rnex/
|
|
67
77
|
│ └── plugins/
|
|
68
78
|
│ └── karpathy-llm/
|
|
@@ -73,6 +83,13 @@ my-workspace/
|
|
|
73
83
|
│ ├── skills/
|
|
74
84
|
│ │ ├── wiki-ingest.md # 8-step decomposition & ingestion workflow
|
|
75
85
|
│ │ └── wiki-lint.md # 10-step graph validation & maintenance workflow
|
|
86
|
+
│ ├── commands/
|
|
87
|
+
│ │ ├── init.sh
|
|
88
|
+
│ │ ├── ingest.sh
|
|
89
|
+
│ │ ├── index.sh
|
|
90
|
+
│ │ ├── graph.sh
|
|
91
|
+
│ │ ├── search.sh
|
|
92
|
+
│ │ └── lint.sh
|
|
76
93
|
│ └── templates/
|
|
77
94
|
│ ├── rnex-wiki-page.template.md# Atomic page template with typed relations
|
|
78
95
|
│ └── rnex-llm-wiki.sample.md# Sample wiki walkthrough
|
|
@@ -91,8 +108,8 @@ rnex plugin enable karpathy-llm
|
|
|
91
108
|
|
|
92
109
|
This command:
|
|
93
110
|
1. Adds `karpathy-llm` to `plugins:` in `rnex.yaml`.
|
|
94
|
-
2. Copies initial templates (`wiki/index.md`, `wiki/_log.md`, `wiki/
|
|
95
|
-
3. Scopes `rules/`, `instructions/`, `skills/`, `commands/`, `hooks/`, `agents/`, and `templates/` into `.rnex/plugins/karpathy-llm/`.
|
|
111
|
+
2. Copies initial templates (`wiki/index.md`, `wiki/_log.md`, `wiki/_index/*.md`, `wiki/_graph/*.tsv`).
|
|
112
|
+
3. Scopes `rules/`, `instructions/`, `skills/`, `commands/`, `lib/`, `bin/`, `hooks/`, `agents/`, and `templates/` into `.rnex/plugins/karpathy-llm/`.
|
|
96
113
|
4. Reconciles workspace state, member repositories, and plugin assets via `rnex sync`.
|
|
97
114
|
|
|
98
115
|
### Option 2: Declarative in `rnex.yaml`
|
|
@@ -130,7 +147,11 @@ plugins:
|
|
|
130
147
|
|
|
131
148
|
# Directory paths relative to workspace root (defaults shown)
|
|
132
149
|
wiki_dir: wiki # Directory for curated atomic markdown pages
|
|
133
|
-
|
|
150
|
+
index_dir: "_index" # Subdirectory for sorted B-Tree leaf shards
|
|
151
|
+
graph_dir: "_graph" # Subdirectory for sorted TSV property graph tables
|
|
152
|
+
btree_root_max_lines: 80 # Maximum allowed lines in root wiki/index.md router
|
|
153
|
+
btree_shard_max_entries: 100# Threshold before splitting a B-Tree shard
|
|
154
|
+
graph_default_depth: 1 # Default ego-subgraph traversal depth in hops
|
|
134
155
|
```
|
|
135
156
|
|
|
136
157
|
### 2. Local Machine Configuration (`.local.rnex.yaml`)
|
|
@@ -140,9 +161,7 @@ Use this file to customize how your local workstation resolves wiki paths or sou
|
|
|
140
161
|
```yaml
|
|
141
162
|
plugins:
|
|
142
163
|
karpathy-llm:
|
|
143
|
-
# Directory for curated atomic markdown pages (default: wiki)
|
|
144
164
|
wiki_dir: wiki
|
|
145
|
-
# Intake directories and/or glob patterns
|
|
146
165
|
sources:
|
|
147
166
|
- docs
|
|
148
167
|
- "repos/**/README.md"
|
|
@@ -150,7 +169,7 @@ plugins:
|
|
|
150
169
|
|
|
151
170
|
### CLI Subcommands
|
|
152
171
|
|
|
153
|
-
The `karpathy-llm` plugin provides
|
|
172
|
+
The `karpathy-llm` plugin provides native subcommands via the `rnex plugin` engine:
|
|
154
173
|
|
|
155
174
|
```sh
|
|
156
175
|
# Ingest all configured sources and enabled member repos
|
|
@@ -162,7 +181,16 @@ rnex plugin karpathy-llm ingest --file docs/architecture.md
|
|
|
162
181
|
rnex plugin karpathy-llm ingest --source docs/architecture.md
|
|
163
182
|
rnex plugin karpathy-llm ingest --repo backend-api --quiet
|
|
164
183
|
|
|
165
|
-
#
|
|
184
|
+
# Rebuild sorted TSV graph and B-Tree leaf shards
|
|
185
|
+
rnex plugin karpathy-llm index --rebuild
|
|
186
|
+
|
|
187
|
+
# Fast O(log N) prefix search over wiki nodes
|
|
188
|
+
rnex plugin karpathy-llm search <prefix>
|
|
189
|
+
|
|
190
|
+
# Query ego-subgraph dependencies and backlinks
|
|
191
|
+
rnex plugin karpathy-llm graph <node_id> [--depth 1|2]
|
|
192
|
+
|
|
193
|
+
# Lint wiki schema, sort invariants, and wikilink integrity
|
|
166
194
|
rnex plugin karpathy-llm lint
|
|
167
195
|
|
|
168
196
|
# Strict linting (exits non-zero on warnings or errors)
|
|
@@ -171,11 +199,15 @@ rnex plugin karpathy-llm lint --strict
|
|
|
171
199
|
|
|
172
200
|
### Summary Reference Table
|
|
173
201
|
|
|
174
|
-
| Field | Scope / File | Type | Default |
|
|
202
|
+
| Field | Scope / File | Type | Default | Description |
|
|
175
203
|
|:---|:---|:---|:---|:---|
|
|
176
204
|
| `sources` | Repo (`rnex.yaml`) | `list` | `[docs, "repos/**/README.md"]` | Directory paths and/or glob patterns for intake documents. |
|
|
177
205
|
| `wiki_dir` | Repo (`rnex.yaml`) | `string` | `wiki` | Directory containing atomic domain pages. |
|
|
178
|
-
| `
|
|
206
|
+
| `index_dir` | Repo (`rnex.yaml`) | `string` | `_index` | Subdirectory for sorted B-Tree leaf shards. |
|
|
207
|
+
| `graph_dir` | Repo (`rnex.yaml`) | `string` | `_graph` | Subdirectory for sorted TSV property graph tables. |
|
|
208
|
+
| `btree_root_max_lines` | Repo (`rnex.yaml`) | `integer` | `80` | Ceiling on lines allowed in `wiki/index.md`. |
|
|
209
|
+
| `btree_shard_max_entries` | Repo (`rnex.yaml`) | `integer` | `100` | Entry count threshold before automatically splitting a shard. |
|
|
210
|
+
| `graph_default_depth` | Repo (`rnex.yaml`) | `integer` | `1` | Default ego-subgraph traversal depth in hops. |
|
|
179
211
|
|
|
180
212
|
---
|
|
181
213
|
|
|
@@ -183,7 +215,8 @@ rnex plugin karpathy-llm lint --strict
|
|
|
183
215
|
|
|
184
216
|
1. **Intake:** Drop raw research papers, meeting notes, PRDs, or architecture specs into `./docs/` unmodified.
|
|
185
217
|
2. **Ingest:** Instruct your AI assistant: *"Run wiki-ingest on docs/source-document.md"*, or run `rnex plugin karpathy-llm ingest`.
|
|
186
|
-
3. **
|
|
218
|
+
3. **Index & Search:** Rebuild indexes with `rnex plugin karpathy-llm index --rebuild` or query nodes with `rnex plugin karpathy-llm search <keyword>`.
|
|
219
|
+
4. **Maintenance:** Run `rnex plugin karpathy-llm lint` (or the `wiki-lint` workflow) to validate relations, prune orphans, and update graph edges.
|
|
187
220
|
|
|
188
221
|
---
|
|
189
222
|
|
|
@@ -193,4 +226,6 @@ rnex plugin karpathy-llm lint --strict
|
|
|
193
226
|
rnex plugin disable karpathy-llm
|
|
194
227
|
```
|
|
195
228
|
|
|
196
|
-
|
|
229
|
+
When disabled:
|
|
230
|
+
- Scoped assets under `.rnex/plugins/karpathy-llm/` are cleanly removed.
|
|
231
|
+
- **Your data in `./docs/` and `wiki/` is preserved 100% intact.** Repo Nexus never deletes user-generated knowledge bases upon plugin disablement.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# shellcheck shell=sh disable=SC2154
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# File: plugins/karpathy-llm/commands/graph.sh
|
|
5
|
+
# Architectural Layer: Plugin CLI Subcommand (karpathy-llm graph)
|
|
6
|
+
# Single Responsibility: Execute O(log N) ego-subgraph lookups for a wiki node
|
|
7
|
+
# across sorted TSV tables (nodes.tsv, edges_out.tsv, edges_in.tsv).
|
|
8
|
+
# Complexity: O(log N) lookup using C-locale prefix binary search.
|
|
9
|
+
# Security (OWASP A03): Validates node identifier and traversal depth.
|
|
10
|
+
# Syntax: rnex plugin karpathy-llm graph <node_id> [--depth 1|2]
|
|
11
|
+
# =============================================================================
|
|
12
|
+
set -e
|
|
13
|
+
|
|
14
|
+
_root="${RNEX_ROOT:-${NEXUS_DIR:-$PWD}}"
|
|
15
|
+
for _kl_common in \
|
|
16
|
+
"${RNEX_PLUGIN_DIR:-}/hooks/_common.sh" \
|
|
17
|
+
"$(dirname "$0")/../hooks/_common.sh" \
|
|
18
|
+
"$_root/.rnex/plugins/karpathy-llm/hooks/_common.sh" \
|
|
19
|
+
"$_root/plugins/karpathy-llm/hooks/_common.sh"; do
|
|
20
|
+
# shellcheck source=/dev/null
|
|
21
|
+
[ -f "$_kl_common" ] && { . "$_kl_common"; break; }
|
|
22
|
+
done
|
|
23
|
+
|
|
24
|
+
_target_node=""
|
|
25
|
+
_depth="${RNEX_CFG_GRAPH_DEFAULT_DEPTH:-1}"
|
|
26
|
+
|
|
27
|
+
while [ $# -gt 0 ]; do
|
|
28
|
+
case "$1" in
|
|
29
|
+
--depth)
|
|
30
|
+
shift
|
|
31
|
+
[ -n "${1:-}" ] || { printf 'Error: --depth requires an integer argument (1 or 2)\n' >&2; exit 1; }
|
|
32
|
+
_depth="$1"
|
|
33
|
+
;;
|
|
34
|
+
--depth=*)
|
|
35
|
+
_depth="${1#--depth=}"
|
|
36
|
+
;;
|
|
37
|
+
-h|--help)
|
|
38
|
+
cat <<'HELP_EOF'
|
|
39
|
+
Usage: rnex plugin karpathy-llm graph <node_id> [options]
|
|
40
|
+
|
|
41
|
+
Query 1-hop or 2-hop ego-subgraph neighborhood for a wiki node from sorted TSV tables.
|
|
42
|
+
|
|
43
|
+
Options:
|
|
44
|
+
--depth <1|2> Traversal neighborhood depth (default: 1)
|
|
45
|
+
-h, --help Show this help message
|
|
46
|
+
HELP_EOF
|
|
47
|
+
exit 0
|
|
48
|
+
;;
|
|
49
|
+
-*)
|
|
50
|
+
printf 'Error: Unknown option "%s". Use --help for usage.\n' "$1" >&2
|
|
51
|
+
exit 1
|
|
52
|
+
;;
|
|
53
|
+
*)
|
|
54
|
+
if [ -n "$_target_node" ]; then
|
|
55
|
+
printf 'Error: Too many arguments. Specify a single node_id.\n' >&2
|
|
56
|
+
exit 1
|
|
57
|
+
fi
|
|
58
|
+
_target_node="$1"
|
|
59
|
+
;;
|
|
60
|
+
esac
|
|
61
|
+
shift
|
|
62
|
+
done
|
|
63
|
+
|
|
64
|
+
if [ -z "$_target_node" ]; then
|
|
65
|
+
printf 'Error: Missing required node_id argument. Usage: rnex plugin karpathy-llm graph <node_id>\n' >&2
|
|
66
|
+
exit 1
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
case "$_depth" in
|
|
70
|
+
1|2) ;;
|
|
71
|
+
*)
|
|
72
|
+
printf 'Error: Invalid depth "%s". Allowed values are 1 or 2.\n' "$_depth" >&2
|
|
73
|
+
exit 1
|
|
74
|
+
;;
|
|
75
|
+
esac
|
|
76
|
+
|
|
77
|
+
# Fail-fast: ensure configuration contract is loaded
|
|
78
|
+
if ! command -v load_wiki_config_contract >/dev/null 2>&1; then
|
|
79
|
+
printf 'Error [graph]: load_wiki_config_contract helper not found.\n' >&2
|
|
80
|
+
exit 1
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
load_wiki_config_contract "$_root" || exit 1
|
|
84
|
+
|
|
85
|
+
if [ ! -f "$RNEX_WIKI_NODES_TSV" ]; then
|
|
86
|
+
printf 'Error [graph]: Graph store not initialized. Run "rnex plugin karpathy-llm index --rebuild" first.\n' >&2
|
|
87
|
+
exit 1
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
query_node_ego_subgraph "$_target_node" "$_depth"
|
|
91
|
+
exit 0
|