repo-nexus 0.9.4 → 0.9.5
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 +1 -1
- 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/lib/source_helpers.sh +299 -91
- package/plugins/karpathy-llm/plugin.yaml +1 -1
- package/plugins/karpathy-llm/tests/test_plugin.sh +50 -0
- package/plugins/windsurf/plugin.yaml +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "repo-nexus",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
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",
|
|
@@ -3,15 +3,114 @@
|
|
|
3
3
|
# =============================================================================
|
|
4
4
|
# File: plugins/karpathy-llm/lib/source_helpers.sh
|
|
5
5
|
# Architectural Layer: Domain-Aware Source Discovery Helpers (helpers/)
|
|
6
|
-
# Single Responsibility: Resolve and
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
# Security (OWASP A03): Rejects path traversal ("..") escaping workspace root
|
|
12
|
-
# and never follows or creates symbolic links (-type f and [ ! -L ] only).
|
|
6
|
+
# Single Responsibility: Resolve and expand workspace source declarations into
|
|
7
|
+
# concrete regular Markdown files in place, supporting recursive glob patterns
|
|
8
|
+
# ("**/*.md") portably in pure POSIX /bin/sh without symlinks or Bashisms.
|
|
9
|
+
# Standards: POSIX Shell (/bin/sh), OWASP A03 Input Sanitization, SRP.
|
|
10
|
+
# Patterns: Iterator Pattern, Information Expert (GRASP).
|
|
13
11
|
# =============================================================================
|
|
14
12
|
|
|
13
|
+
# -----------------------------------------------------------------------------
|
|
14
|
+
# extract_base_dir_from_pattern
|
|
15
|
+
# Summary: Extracts the static leading directory component of a path before any
|
|
16
|
+
# wildcard characters (*, ?, [) appear.
|
|
17
|
+
# @param $1: pattern - Configured path pattern (e.g., "repos/**/README.md").
|
|
18
|
+
# @returns: Leading static directory path on stdout (e.g., "repos").
|
|
19
|
+
# @pure
|
|
20
|
+
# -----------------------------------------------------------------------------
|
|
21
|
+
extract_base_dir_from_pattern() {
|
|
22
|
+
_pat="$1"
|
|
23
|
+
# Take directory portion
|
|
24
|
+
_dir="$(dirname "$_pat")"
|
|
25
|
+
|
|
26
|
+
# If the directory itself contains wildcards, strip back to the root
|
|
27
|
+
case "$_dir" in
|
|
28
|
+
*\**|*\?*|*\[*)
|
|
29
|
+
_curr="$_pat"
|
|
30
|
+
while [ "$_curr" != "." ] && [ "$_curr" != "/" ]; do
|
|
31
|
+
_curr="$(dirname "$_curr")"
|
|
32
|
+
case "$_curr" in
|
|
33
|
+
*\**|*\?*|*\[*) continue ;;
|
|
34
|
+
*) _dir="$_curr"; break ;;
|
|
35
|
+
esac
|
|
36
|
+
done
|
|
37
|
+
;;
|
|
38
|
+
esac
|
|
39
|
+
|
|
40
|
+
# Default to current directory if pattern starts immediately with a wildcard
|
|
41
|
+
if [ -z "$_dir" ] || [ "$_dir" = "." ] || [ "$_dir" = "/" ]; then
|
|
42
|
+
_dir="."
|
|
43
|
+
fi
|
|
44
|
+
printf '%s\n' "$_dir"
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
# -----------------------------------------------------------------------------
|
|
48
|
+
# match_globstar_path
|
|
49
|
+
# Summary: Tests whether a relative path matches a pattern containing `**`
|
|
50
|
+
# using standard POSIX string pattern matching.
|
|
51
|
+
# @param $1: rel_path - Workspace-relative candidate path.
|
|
52
|
+
# @param $2: pattern - Configured glob pattern (e.g., "repos/**/README.md").
|
|
53
|
+
# @returns: 0 if matched, 1 if not matched.
|
|
54
|
+
# @pure
|
|
55
|
+
# -----------------------------------------------------------------------------
|
|
56
|
+
match_globstar_path() {
|
|
57
|
+
_candidate_path="$1"
|
|
58
|
+
_target_pat="$2"
|
|
59
|
+
|
|
60
|
+
# Strip leading ./ if present
|
|
61
|
+
_candidate_path="${_candidate_path#./}"
|
|
62
|
+
_target_pat="${_target_pat#./}"
|
|
63
|
+
|
|
64
|
+
# Exact equality shortcut
|
|
65
|
+
if [ "$_candidate_path" = "$_target_pat" ]; then
|
|
66
|
+
return 0
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
# Evaluate recursive '**/' globbing via portable POSIX case expansion
|
|
70
|
+
case "$_target_pat" in
|
|
71
|
+
*\*\**)
|
|
72
|
+
# Convert 'prefix/**/suffix' pattern matching into multi-depth validation
|
|
73
|
+
_prefix="${_target_pat%%\*\**}" # substring before first '**'
|
|
74
|
+
_suffix="${_target_pat##*\*\*}" # substring after last '**'
|
|
75
|
+
_suffix="${_suffix#/}" # strip leading separator if present
|
|
76
|
+
|
|
77
|
+
# Validate prefix and suffix alignment
|
|
78
|
+
# shellcheck disable=SC2254
|
|
79
|
+
case "$_candidate_path" in
|
|
80
|
+
"$_prefix"*$_suffix)
|
|
81
|
+
# Check filename constraint when suffix specifies an exact name (e.g., "README.md")
|
|
82
|
+
_expected_filename="$(basename "$_suffix")"
|
|
83
|
+
_actual_filename="$(basename "$_candidate_path")"
|
|
84
|
+
if [ -n "$_expected_filename" ] && [ "$_expected_filename" != "*" ]; then
|
|
85
|
+
case "$_actual_filename" in
|
|
86
|
+
$_expected_filename) return 0 ;;
|
|
87
|
+
*) return 1 ;;
|
|
88
|
+
esac
|
|
89
|
+
fi
|
|
90
|
+
return 0
|
|
91
|
+
;;
|
|
92
|
+
*)
|
|
93
|
+
return 1
|
|
94
|
+
;;
|
|
95
|
+
esac
|
|
96
|
+
;;
|
|
97
|
+
*)
|
|
98
|
+
# Single-level shell pattern match: directory must match, basename matches pattern
|
|
99
|
+
_c_dir="$(dirname "$_candidate_path")"
|
|
100
|
+
_p_dir="$(dirname "$_target_pat")"
|
|
101
|
+
[ "$_c_dir" = "$_p_dir" ] || return 1
|
|
102
|
+
|
|
103
|
+
_c_base="$(basename "$_candidate_path")"
|
|
104
|
+
_p_base="$(basename "$_target_pat")"
|
|
105
|
+
# shellcheck disable=SC2254
|
|
106
|
+
case "$_c_base" in
|
|
107
|
+
$_p_base) return 0 ;;
|
|
108
|
+
*) return 1 ;;
|
|
109
|
+
esac
|
|
110
|
+
;;
|
|
111
|
+
esac
|
|
112
|
+
}
|
|
113
|
+
|
|
15
114
|
# -----------------------------------------------------------------------------
|
|
16
115
|
# parse_yaml_sources_for_scope
|
|
17
116
|
# Summary: Extracts all configured source paths for either the root "repo-nexus"
|
|
@@ -120,137 +219,226 @@ parse_yaml_sources_for_scope() {
|
|
|
120
219
|
|
|
121
220
|
# -----------------------------------------------------------------------------
|
|
122
221
|
# expand_source_entry_to_files
|
|
123
|
-
# Summary:
|
|
124
|
-
#
|
|
125
|
-
#
|
|
126
|
-
# @param $
|
|
127
|
-
# @
|
|
128
|
-
# @returns: Absolute paths to regular files (one per line) on stdout.
|
|
129
|
-
# @pure
|
|
222
|
+
# Summary: Resolves a single source declaration (file, directory, or recursive
|
|
223
|
+
# glob pattern) to absolute paths of existing regular files (-type f).
|
|
224
|
+
# @param $1: workspace_root - Absolute path to workspace or repo root.
|
|
225
|
+
# @param $2: source_entry - Path, folder, or glob from configuration.
|
|
226
|
+
# @returns: Absolute file paths (one per line) on stdout.
|
|
130
227
|
# -----------------------------------------------------------------------------
|
|
131
228
|
expand_source_entry_to_files() {
|
|
132
|
-
|
|
229
|
+
_ws_root="$1"
|
|
133
230
|
_entry="$2"
|
|
134
231
|
|
|
232
|
+
# OWASP A03: Reject empty values or upward path traversals
|
|
135
233
|
case "$_entry" in
|
|
136
234
|
''|*..*|/*) return 0 ;;
|
|
137
235
|
esac
|
|
138
236
|
|
|
139
|
-
|
|
237
|
+
# Normalize entry
|
|
238
|
+
_entry="${_entry#./}"
|
|
239
|
+
_full_target="${_ws_root}/${_entry}"
|
|
140
240
|
|
|
141
|
-
# 1
|
|
142
|
-
if [ -f "$
|
|
143
|
-
printf '%s\n' "$
|
|
241
|
+
# Case 1: Exact regular file
|
|
242
|
+
if [ -f "$_full_target" ] && [ ! -L "$_full_target" ]; then
|
|
243
|
+
printf '%s\n' "$_full_target"
|
|
144
244
|
return 0
|
|
145
245
|
fi
|
|
146
246
|
|
|
147
|
-
# 2
|
|
148
|
-
if [ -d "$
|
|
149
|
-
find "$
|
|
247
|
+
# Case 2: Exact directory -> Ingest Markdown files strictly within this directory
|
|
248
|
+
if [ -d "$_full_target" ] && [ ! -L "$_full_target" ]; then
|
|
249
|
+
find "$_full_target" -type f \( -name '*.md' -o -name '*.mdx' \) \
|
|
150
250
|
! -path '*/.git/*' \
|
|
151
251
|
! -path '*/.rnex/*' \
|
|
152
252
|
! -path '*/node_modules/*' \
|
|
153
|
-
! -path "${
|
|
154
|
-
! -path "${_base_dir}/${RNEX_CFG_REPOS_DIR:-repos}/*" 2>/dev/null | LC_ALL=C sort
|
|
253
|
+
! -path "${_ws_root}/wiki/*" 2>/dev/null | LC_ALL=C sort
|
|
155
254
|
return 0
|
|
156
255
|
fi
|
|
157
256
|
|
|
158
|
-
# 3
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
257
|
+
# Case 3: Glob pattern (e.g., "repos/**/README.md" or "*.md")
|
|
258
|
+
_base_rel="$(extract_base_dir_from_pattern "$_entry")"
|
|
259
|
+
if [ "$_base_rel" = "." ]; then
|
|
260
|
+
_search_dir="$_ws_root"
|
|
261
|
+
else
|
|
262
|
+
_search_dir="${_ws_root}/${_base_rel}"
|
|
263
|
+
fi
|
|
264
|
+
|
|
265
|
+
[ -d "$_search_dir" ] || return 0
|
|
266
|
+
|
|
267
|
+
_leaf_name="$(basename "$_entry")"
|
|
268
|
+
case "$_leaf_name" in
|
|
269
|
+
*\**|*\?*|*\[*)
|
|
270
|
+
find "$_search_dir" -type f \( -name '*.md' -o -name '*.mdx' \) \
|
|
271
|
+
! -path '*/.git/*' \
|
|
272
|
+
! -path '*/.rnex/*' \
|
|
273
|
+
! -path '*/node_modules/*' \
|
|
274
|
+
! -path "${_ws_root}/wiki/*" 2>/dev/null | LC_ALL=C sort | while IFS= read -r _abs_cand; do
|
|
275
|
+
[ -n "$_abs_cand" ] || continue
|
|
276
|
+
_rel_cand="${_abs_cand#"${_ws_root}/"}"
|
|
277
|
+
if match_globstar_path "$_rel_cand" "$_entry"; then
|
|
278
|
+
printf '%s\n' "$_abs_cand"
|
|
279
|
+
fi
|
|
280
|
+
done
|
|
281
|
+
;;
|
|
282
|
+
*)
|
|
283
|
+
find "$_search_dir" -type f -name "$_leaf_name" \
|
|
284
|
+
! -path '*/.git/*' \
|
|
285
|
+
! -path '*/.rnex/*' \
|
|
286
|
+
! -path '*/node_modules/*' \
|
|
287
|
+
! -path "${_ws_root}/wiki/*" 2>/dev/null | LC_ALL=C sort | while IFS= read -r _abs_cand; do
|
|
288
|
+
[ -n "$_abs_cand" ] || continue
|
|
289
|
+
_rel_cand="${_abs_cand#"${_ws_root}/"}"
|
|
290
|
+
if match_globstar_path "$_rel_cand" "$_entry"; then
|
|
291
|
+
printf '%s\n' "$_abs_cand"
|
|
292
|
+
fi
|
|
293
|
+
done
|
|
171
294
|
;;
|
|
172
295
|
esac
|
|
173
|
-
return 0
|
|
174
296
|
}
|
|
175
297
|
|
|
176
298
|
# -----------------------------------------------------------------------------
|
|
177
299
|
# build_workspace_source_manifest
|
|
178
|
-
# Summary:
|
|
179
|
-
#
|
|
180
|
-
#
|
|
181
|
-
# @param $1:
|
|
182
|
-
# @param $2: single_file_opt
|
|
183
|
-
# @returns: 0 on success.
|
|
184
|
-
# @sideEffects: Writes resolved source records to manifest_out_file.
|
|
300
|
+
# Summary: Enumerates all configured sources into a tab-separated manifest:
|
|
301
|
+
# <shard_id>\t<sub_scope>\t<workspace_rel_path>\t<abs_file_path>
|
|
302
|
+
# without injecting arbitrary member repository defaults.
|
|
303
|
+
# @param $1: manifest_out - Output manifest filepath.
|
|
304
|
+
# @param $2: single_file_opt - Optional specific file path to prioritize.
|
|
185
305
|
# -----------------------------------------------------------------------------
|
|
186
306
|
build_workspace_source_manifest() {
|
|
187
307
|
_manifest_out="$1"
|
|
188
308
|
_single_opt="${2:-}"
|
|
189
|
-
_raw_tmp="${_manifest_out}.
|
|
309
|
+
_raw_tmp="${_manifest_out}.tmp.$$"
|
|
190
310
|
: > "$_raw_tmp"
|
|
191
311
|
|
|
192
|
-
#
|
|
193
|
-
|
|
312
|
+
# Collect configured top-level sources (Priority 1: .local.rnex.yaml, Priority 2: rnex.yaml)
|
|
313
|
+
_sources="$(
|
|
194
314
|
{
|
|
195
315
|
parse_yaml_sources_for_scope "${RNEX_WORKSPACE_ROOT}/.local.rnex.yaml" "nexus" ""
|
|
196
316
|
parse_yaml_sources_for_scope "${RNEX_WORKSPACE_ROOT}/rnex.yaml" "nexus" ""
|
|
197
317
|
} | LC_ALL=C awk '!seen[$0]++'
|
|
198
318
|
)"
|
|
199
|
-
|
|
200
|
-
|
|
319
|
+
|
|
320
|
+
_top_sources_configured=1
|
|
321
|
+
if [ -z "$_sources" ]; then
|
|
322
|
+
_top_sources_configured=0
|
|
323
|
+
_sources="$(printf 'README.md\nAGENTS.md\ndocs\n')"
|
|
201
324
|
fi
|
|
202
325
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
326
|
+
# Expand each configured entry
|
|
327
|
+
printf '%s\n' "$_sources" | while IFS= read -r _entry; do
|
|
328
|
+
[ -n "$_entry" ] || continue
|
|
329
|
+
expand_source_entry_to_files "$RNEX_WORKSPACE_ROOT" "$_entry" | while IFS= read -r _abs_file; do
|
|
330
|
+
[ -n "$_abs_file" ] || continue
|
|
331
|
+
_rel_ws="${_abs_file#"${RNEX_WORKSPACE_ROOT}/"}"
|
|
332
|
+
|
|
333
|
+
# Map shard attribution based on repository path
|
|
334
|
+
case "$_rel_ws" in
|
|
335
|
+
repos/*/*)
|
|
336
|
+
# Belongs to a member repo: repos/<repo-name>/...
|
|
337
|
+
_member="$(printf '%s' "$_rel_ws" | cut -d'/' -f2)"
|
|
338
|
+
if command -v is_repo_enabled >/dev/null 2>&1; then
|
|
339
|
+
is_repo_enabled "$_member" || continue
|
|
340
|
+
fi
|
|
341
|
+
_rel_in_repo="${_rel_ws#"repos/${_member}/"}"
|
|
342
|
+
_m_first="$(printf '%s' "$_rel_in_repo" | cut -d'/' -f1)"
|
|
343
|
+
_m_second="$(printf '%s' "$_rel_in_repo" | cut -d'/' -f2)"
|
|
344
|
+
if [ -n "$_m_second" ] && [ "$_m_first" != "$_rel_in_repo" ]; then
|
|
345
|
+
if command -v normalize_slug_id >/dev/null 2>&1; then
|
|
346
|
+
_m_sub="$(normalize_slug_id "$_m_first")"
|
|
347
|
+
else
|
|
348
|
+
_m_sub="$_m_first"
|
|
349
|
+
fi
|
|
350
|
+
else
|
|
351
|
+
_m_sub=""
|
|
352
|
+
fi
|
|
353
|
+
if command -v normalize_slug_id >/dev/null 2>&1; then
|
|
354
|
+
_shard_id="repos-$(normalize_slug_id "$_member")"
|
|
355
|
+
else
|
|
356
|
+
_shard_id="repos-${_member}"
|
|
357
|
+
fi
|
|
358
|
+
;;
|
|
359
|
+
*)
|
|
360
|
+
# Belongs to the Nexus repo
|
|
361
|
+
_first_dir="$(printf '%s' "$_rel_ws" | cut -d'/' -f1)"
|
|
362
|
+
_second_dir="$(printf '%s' "$_rel_ws" | cut -d'/' -f2)"
|
|
363
|
+
if [ -n "$_second_dir" ] && [ "$_first_dir" != "$_rel_ws" ] && [ "$_first_dir" != "docs" ]; then
|
|
364
|
+
if command -v normalize_slug_id >/dev/null 2>&1; then
|
|
365
|
+
_m_sub="$(normalize_slug_id "$_first_dir")"
|
|
366
|
+
else
|
|
367
|
+
_m_sub="$_first_dir"
|
|
368
|
+
fi
|
|
369
|
+
elif [ "$_first_dir" = "docs" ]; then
|
|
370
|
+
_m_sub="docs"
|
|
371
|
+
else
|
|
372
|
+
_m_sub=""
|
|
373
|
+
fi
|
|
374
|
+
_shard_id="repo-nexus"
|
|
375
|
+
;;
|
|
376
|
+
esac
|
|
377
|
+
|
|
378
|
+
printf '%s\t%s\t%s\t%s\n' "$_shard_id" "$_m_sub" "$_rel_ws" "$_abs_file" >> "$_raw_tmp"
|
|
216
379
|
done
|
|
217
380
|
done
|
|
218
381
|
|
|
219
|
-
#
|
|
382
|
+
# Member repositories resolution
|
|
220
383
|
_repos_dir="${RNEX_WORKSPACE_ROOT}/${RNEX_CFG_REPOS_DIR:-repos}"
|
|
221
384
|
for _member in $(discover_enabled_member_repos < /dev/null); do
|
|
222
385
|
_member_root="${_repos_dir}/${_member}"
|
|
223
386
|
[ -d "$_member_root" ] || continue
|
|
224
387
|
|
|
388
|
+
# Check for explicit per-repository sources
|
|
225
389
|
_member_sources="$(
|
|
226
390
|
{
|
|
227
391
|
parse_yaml_sources_for_scope "${RNEX_WORKSPACE_ROOT}/.local.rnex.yaml" "repo" "$_member"
|
|
228
392
|
parse_yaml_sources_for_scope "${RNEX_WORKSPACE_ROOT}/rnex.yaml" "repo" "$_member"
|
|
229
393
|
} | LC_ALL=C awk '!seen[$0]++'
|
|
230
394
|
)"
|
|
231
|
-
if [ -z "$_member_sources" ]; then
|
|
232
|
-
_member_sources="$(printf 'README.md\ndocs\n')"
|
|
233
|
-
fi
|
|
234
395
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
[ -n "$
|
|
396
|
+
if [ -n "$_member_sources" ]; then
|
|
397
|
+
# Explicit per-member sources configured: expand them
|
|
398
|
+
printf '%s\n' "$_member_sources" | while IFS= read -r _m_entry <&0; do
|
|
399
|
+
[ -n "$_m_entry" ] || continue
|
|
400
|
+
expand_source_entry_to_files "$_member_root" "$_m_entry" < /dev/null | while IFS= read -r _abs_mf; do
|
|
401
|
+
[ -n "$_abs_mf" ] || continue
|
|
402
|
+
_rel_ws="${_abs_mf#"${RNEX_WORKSPACE_ROOT}/"}"
|
|
403
|
+
_rel_in_repo="${_abs_mf#"${_member_root}/"}"
|
|
404
|
+
_m_first="$(printf '%s' "$_rel_in_repo" | cut -d'/' -f1)"
|
|
405
|
+
_m_second="$(printf '%s' "$_rel_in_repo" | cut -d'/' -f2)"
|
|
406
|
+
if [ -n "$_m_second" ] && [ "$_m_first" != "$_rel_in_repo" ]; then
|
|
407
|
+
if command -v normalize_slug_id >/dev/null 2>&1; then
|
|
408
|
+
_m_sub="$(normalize_slug_id "$_m_first")"
|
|
409
|
+
else
|
|
410
|
+
_m_sub="$_m_first"
|
|
411
|
+
fi
|
|
412
|
+
else
|
|
413
|
+
_m_sub=""
|
|
414
|
+
fi
|
|
415
|
+
if command -v normalize_slug_id >/dev/null 2>&1; then
|
|
416
|
+
_m_shard="repos-$(normalize_slug_id "$_member")"
|
|
417
|
+
else
|
|
418
|
+
_m_shard="repos-${_member}"
|
|
419
|
+
fi
|
|
420
|
+
printf '%s\t%s\t%s\t%s\n' "$_m_shard" "$_m_sub" "$_rel_ws" "$_abs_mf" >> "$_raw_tmp"
|
|
421
|
+
done
|
|
422
|
+
done
|
|
423
|
+
elif [ "$_top_sources_configured" -eq 0 ]; then
|
|
424
|
+
# Top-level sources were NOT configured at all in rnex.yaml.
|
|
425
|
+
# Default fallback for member repo: only its README.md if present
|
|
426
|
+
if [ -f "${_member_root}/README.md" ] && [ ! -L "${_member_root}/README.md" ]; then
|
|
427
|
+
_abs_mf="${_member_root}/README.md"
|
|
239
428
|
_rel_ws="${_abs_mf#"${RNEX_WORKSPACE_ROOT}/"}"
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
_m_second="$(printf '%s' "$_rel_in_repo" | cut -d'/' -f2)"
|
|
243
|
-
if [ -n "$_m_second" ] && [ "$_m_first" != "$_rel_in_repo" ]; then
|
|
244
|
-
_m_sub="$(normalize_slug_id "$_m_first")"
|
|
429
|
+
if command -v normalize_slug_id >/dev/null 2>&1; then
|
|
430
|
+
_m_shard="repos-$(normalize_slug_id "$_member")"
|
|
245
431
|
else
|
|
246
|
-
|
|
432
|
+
_m_shard="repos-${_member}"
|
|
247
433
|
fi
|
|
248
|
-
printf '
|
|
249
|
-
|
|
250
|
-
|
|
434
|
+
printf '%s\t\t%s\t%s\n' "$_m_shard" "$_rel_ws" "$_abs_mf" >> "$_raw_tmp"
|
|
435
|
+
fi
|
|
436
|
+
fi
|
|
437
|
+
# When _top_sources_configured == 1 and member has no explicit sources,
|
|
438
|
+
# we strictly avoid synthesizing arbitrary docs/ member fallbacks.
|
|
251
439
|
done
|
|
252
440
|
|
|
253
|
-
#
|
|
441
|
+
# Explicit single file inclusion if provided and not yet present
|
|
254
442
|
if [ -n "$_single_opt" ]; then
|
|
255
443
|
case "$_single_opt" in
|
|
256
444
|
/*) _single_abs="$_single_opt" ;;
|
|
@@ -262,21 +450,41 @@ build_workspace_source_manifest() {
|
|
|
262
450
|
repos/*/*)
|
|
263
451
|
_s_after_repos="${_s_rel#repos/}"
|
|
264
452
|
_s_repo="$(printf '%s' "$_s_after_repos" | cut -d'/' -f1)"
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if [ -n "$
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
453
|
+
if command -v is_repo_enabled >/dev/null 2>&1; then
|
|
454
|
+
is_repo_enabled "$_s_repo" || _s_repo=""
|
|
455
|
+
fi
|
|
456
|
+
if [ -n "$_s_repo" ]; then
|
|
457
|
+
_s_in_repo="${_s_after_repos#"${_s_repo}/"}"
|
|
458
|
+
_s_first="$(printf '%s' "$_s_in_repo" | cut -d'/' -f1)"
|
|
459
|
+
_s_second="$(printf '%s' "$_s_in_repo" | cut -d'/' -f2)"
|
|
460
|
+
if [ -n "$_s_second" ] && [ "$_s_first" != "$_s_in_repo" ]; then
|
|
461
|
+
if command -v normalize_slug_id >/dev/null 2>&1; then
|
|
462
|
+
_s_sub="$(normalize_slug_id "$_s_first")"
|
|
463
|
+
else
|
|
464
|
+
_s_sub="$_s_first"
|
|
465
|
+
fi
|
|
466
|
+
else
|
|
467
|
+
_s_sub=""
|
|
468
|
+
fi
|
|
469
|
+
if command -v normalize_slug_id >/dev/null 2>&1; then
|
|
470
|
+
_s_shard="repos-$(normalize_slug_id "$_s_repo")"
|
|
471
|
+
else
|
|
472
|
+
_s_shard="repos-${_s_repo}"
|
|
473
|
+
fi
|
|
474
|
+
printf '%s\t%s\t%s\t%s\n' "$_s_shard" "$_s_sub" "$_s_rel" "$_single_abs" >> "$_raw_tmp"
|
|
272
475
|
fi
|
|
273
|
-
printf 'repos-%s\t%s\t%s\t%s\n' "$(normalize_slug_id "$_s_repo")" "$_s_sub" "$_s_rel" "$_single_abs" >> "$_raw_tmp"
|
|
274
476
|
;;
|
|
275
477
|
*)
|
|
276
478
|
_s_first="$(printf '%s' "$_s_rel" | cut -d'/' -f1)"
|
|
277
479
|
_s_second="$(printf '%s' "$_s_rel" | cut -d'/' -f2)"
|
|
278
|
-
if [ -n "$_s_second" ] && [ "$_s_first" != "$_s_rel" ]; then
|
|
279
|
-
|
|
480
|
+
if [ -n "$_s_second" ] && [ "$_s_first" != "$_s_rel" ] && [ "$_s_first" != "docs" ]; then
|
|
481
|
+
if command -v normalize_slug_id >/dev/null 2>&1; then
|
|
482
|
+
_s_sub="$(normalize_slug_id "$_s_first")"
|
|
483
|
+
else
|
|
484
|
+
_s_sub="$_s_first"
|
|
485
|
+
fi
|
|
486
|
+
elif [ "$_s_first" = "docs" ]; then
|
|
487
|
+
_s_sub="docs"
|
|
280
488
|
else
|
|
281
489
|
_s_sub=""
|
|
282
490
|
fi
|
|
@@ -598,6 +598,56 @@ EOF_DIS
|
|
|
598
598
|
}
|
|
599
599
|
pass
|
|
600
600
|
|
|
601
|
+
# --------------------------------------------------------------------------
|
|
602
|
+
# Test 14: Recursive Globstar Ingestion (repos/**/README.md) & Exclusion of Unmatched Docs
|
|
603
|
+
# --------------------------------------------------------------------------
|
|
604
|
+
run_test "Karpathy-llm: recursive globstar discovery (repos/**/README.md) and member docs exclusion"
|
|
605
|
+
TEST_GLOB_WS="$TEST_TMP/karpathy-glob-ws"
|
|
606
|
+
mkdir -p "$TEST_GLOB_WS"
|
|
607
|
+
setup_plugin_test_workspace karpathy-llm "$TEST_GLOB_WS"
|
|
608
|
+
cd "$TEST_GLOB_WS"
|
|
609
|
+
|
|
610
|
+
mkdir -p "$TEST_GLOB_WS/repos/backend/docs" "$TEST_GLOB_WS/repos/frontend/docs"
|
|
611
|
+
printf '# Backend Service\nBackend API service.\n' > "$TEST_GLOB_WS/repos/backend/README.md"
|
|
612
|
+
printf '# Backend Architecture\nInternal architecture doc.\n' > "$TEST_GLOB_WS/repos/backend/docs/architecture.md"
|
|
613
|
+
printf '# Frontend Client\nFrontend web client.\n' > "$TEST_GLOB_WS/repos/frontend/README.md"
|
|
614
|
+
printf '# Frontend Setup\nInternal setup doc.\n' > "$TEST_GLOB_WS/repos/frontend/docs/setup.md"
|
|
615
|
+
|
|
616
|
+
cat <<'EOF_GLOB_CFG' > "$TEST_GLOB_WS/rnex.yaml"
|
|
617
|
+
version: 1.0.0
|
|
618
|
+
sources:
|
|
619
|
+
- "repos/**/README.md"
|
|
620
|
+
plugins:
|
|
621
|
+
karpathy-llm:
|
|
622
|
+
repos:
|
|
623
|
+
backend:
|
|
624
|
+
frontend:
|
|
625
|
+
EOF_GLOB_CFG
|
|
626
|
+
|
|
627
|
+
"$TEST_GLOB_WS/rnex" init -y --karpathy "$TEST_GLOB_WS" >/dev/null
|
|
628
|
+
(cd "$TEST_GLOB_WS" && ./rnex plugin karpathy-llm ingest >/dev/null)
|
|
629
|
+
|
|
630
|
+
# Verify only matched nested README files are registered in nodes.tsv
|
|
631
|
+
grep -q '^backend-readme[ ]repos-backend[ ]repos/backend/README.md' "$TEST_GLOB_WS/wiki/_graph/nodes.tsv" || {
|
|
632
|
+
fail "backend-readme not registered properly in nodes.tsv: $(cat "$TEST_GLOB_WS/wiki/_graph/nodes.tsv")"; exit 1;
|
|
633
|
+
}
|
|
634
|
+
grep -q '^frontend-readme[ ]repos-frontend[ ]repos/frontend/README.md' "$TEST_GLOB_WS/wiki/_graph/nodes.tsv" || {
|
|
635
|
+
fail "frontend-readme not registered properly in nodes.tsv: $(cat "$TEST_GLOB_WS/wiki/_graph/nodes.tsv")"; exit 1;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
# Verify unconfigured member docs were NOT ingested
|
|
639
|
+
! grep -q 'architecture' "$TEST_GLOB_WS/wiki/_graph/nodes.tsv" || {
|
|
640
|
+
fail "Unexpected member docs (architecture.md) was ingested into wiki/_graph/nodes.tsv"; exit 1;
|
|
641
|
+
}
|
|
642
|
+
! grep -q 'setup' "$TEST_GLOB_WS/wiki/_graph/nodes.tsv" || {
|
|
643
|
+
fail "Unexpected member docs (setup.md) was ingested into wiki/_graph/nodes.tsv"; exit 1;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
# Verify B-tree shards were compiled for backend and frontend
|
|
647
|
+
[ -f "$TEST_GLOB_WS/wiki/_index/repos-backend.md" ] || { fail "repos-backend.md shard missing"; exit 1; }
|
|
648
|
+
[ -f "$TEST_GLOB_WS/wiki/_index/repos-frontend.md" ] || { fail "repos-frontend.md shard missing"; exit 1; }
|
|
649
|
+
pass
|
|
650
|
+
|
|
601
651
|
if [ "${_STANDALONE_RUN:-0}" -eq 1 ]; then
|
|
602
652
|
report_results
|
|
603
653
|
fi
|