repo-nexus 0.7.31 → 0.7.34

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.
Files changed (29) hide show
  1. package/lib/ai.sh +19 -373
  2. package/lib/commands/init.sh +24 -61
  3. package/lib/commands/plugin.sh +6 -19
  4. package/lib/commands/repo.sh +23 -31
  5. package/lib/commands/status.sh +45 -52
  6. package/lib/commands/sync.sh +1 -7
  7. package/lib/plugins.sh +40 -41
  8. package/lib/sdk.sh +643 -0
  9. package/lib/workspace.sh +2 -1
  10. package/package.json +1 -1
  11. package/rnex +2 -1
  12. package/templates/rnex-env.sh +17 -410
  13. package/toolkit/plugins/claude/hooks/after_sync.sh +6 -47
  14. package/toolkit/plugins/claude/hooks/before_plugin_disable.sh +3 -4
  15. package/toolkit/plugins/copilot/hooks/after_sync.sh +6 -146
  16. package/toolkit/plugins/copilot/hooks/before_plugin_disable.sh +6 -95
  17. package/toolkit/plugins/cursor/hooks/after_sync.sh +8 -22
  18. package/toolkit/plugins/cursor/hooks/before_plugin_disable.sh +3 -4
  19. package/toolkit/plugins/gemini/hooks/after_sync.sh +9 -56
  20. package/toolkit/plugins/gemini/hooks/before_plugin_disable.sh +3 -4
  21. package/toolkit/plugins/karpathy-llm/hooks/_common.sh +66 -0
  22. package/toolkit/plugins/karpathy-llm/hooks/after_sync.sh +26 -233
  23. package/toolkit/plugins/karpathy-llm/hooks/before_plugin_disable.sh +3 -16
  24. package/toolkit/plugins/karpathy-llm/hooks/git_post-commit.sh +8 -87
  25. package/toolkit/plugins/karpathy-llm/hooks/git_post-merge.sh +8 -87
  26. package/toolkit/plugins/karpathy-llm/hooks/git_pre-commit.sh +8 -87
  27. package/toolkit/plugins/karpathy-llm/hooks/git_pre-push.sh +12 -94
  28. package/toolkit/plugins/windsurf/hooks/after_sync.sh +4 -7
  29. package/toolkit/plugins/windsurf/hooks/before_plugin_disable.sh +3 -4
package/lib/ai.sh CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/bin/sh
2
2
  # shellcheck shell=sh
3
3
  # ============================================================================
4
- # lib/ai.sh — AI Instructions, workspace context, and AI provider synchronization
4
+ # lib/ai.sh — Workspace AI context, .gitignore/.ignore, and skill orchestration
5
5
  # ============================================================================
6
6
 
7
- # ---- AI Instructions Management (Routing-Only) ----------------------------
7
+ # ---- Gitignore & Search Tool Ignore Reconciliation -------------------------
8
8
 
9
9
  reconcile_gitignore() {
10
10
  _dir="${1:-$NEXUS_DIR}"
@@ -31,7 +31,7 @@ GI_EOF
31
31
  log_ok "Removed legacy lint trigger counter entries from .gitignore"
32
32
  fi
33
33
 
34
- # 2. Strip legacy .rnex/ entries if present (.rnex/ contains tracked prompts, plugins, and hooks)
34
+ # 2. Strip legacy .rnex/ entries if present (.rnex/ contains tracked plugins, skills, and hooks)
35
35
  if grep -qE '^[ ]*#?[ ]*Repo Nexus internal state' "$_gi" 2>/dev/null || grep -qE '^\.rnex/?$' "$_gi" 2>/dev/null; then
36
36
  _tmp="$(mktemp)"
37
37
  grep -vE '(^[ ]*#?[ ]*Repo Nexus internal state|^\.rnex/?$)' "$_gi" > "$_tmp" && mv "$_tmp" "$_gi"
@@ -54,28 +54,12 @@ GI_EOF
54
54
  fi
55
55
 
56
56
  # Universal search tool ignore file (ripgrep, Claude Code, VS Code, Zed)
57
- # Un-ignores member repositories for search tools while Git continues to ignore them
58
- _ign="$_dir/.ignore"
59
- if [ ! -f "$_ign" ]; then
60
- cat > "$_ign" <<IGN_EOF
61
- # Member repos (un-ignored for ripgrep, Claude Code, VS Code, and search tools)
62
- !repos/*
63
- IGN_EOF
64
- log_ok "Created .ignore (un-ignoring member repos for search tools)"
65
- elif ! grep -q '!repos/\*' "$_ign" 2>/dev/null; then
66
- printf '\n# Member repos (un-ignored for search tools)\n!repos/*\n' >> "$_ign"
67
- log_dim "Added !repos/* to .ignore"
68
- fi
57
+ ensure_provider_ignore "$_dir/.ignore" \
58
+ "Member repos (un-ignored for ripgrep, Claude Code, VS Code, and search tools)" \
59
+ "Created .ignore (un-ignoring member repos for search tools)"
69
60
  }
70
61
 
71
- # ---- AI Instructions Management (Routing-Only) ----------------------------
72
-
73
- AI_MARKER_START="<!-- REPO-NEXUS:START -->"
74
- AI_MARKER_END="<!-- REPO-NEXUS:END -->"
75
-
76
- get_rnex_instructions() {
77
- printf "CRITICAL: You MUST read and strictly follow all instructions in \`.rnex/ai-instructions.md\` before executing any task or answering any query in this workspace.\n"
78
- }
62
+ # ---- AI Instructions Compilation (.rnex/ai-instructions.md) ----------------
79
63
 
80
64
  build_ai_instructions() {
81
65
  _dir="${1:-$NEXUS_DIR}"
@@ -165,135 +149,7 @@ BASE_AI_EOF
165
149
  mv "$_out_tmp" "$_ai_file"
166
150
  }
167
151
 
168
- merge_rnex_instructions() {
169
- _dst="$1"
170
- _body_tmp="$(mktemp)"
171
- get_rnex_instructions > "$_body_tmp"
172
-
173
- if [ ! -f "$_dst" ]; then
174
- mkdir -p "$(dirname "$_dst")"
175
- {
176
- printf '%s\n' "$AI_MARKER_START"
177
- cat "$_body_tmp"
178
- printf '%s\n' "$AI_MARKER_END"
179
- } > "$_dst"
180
- rm -f "$_body_tmp"
181
- log_ok "Created $(basename "$_dst") with Repo Nexus routing instructions"
182
- return 0
183
- fi
184
-
185
- if grep -q "CRITICAL: You MUST read and strictly follow all instructions in \`.rnex/ai-instructions.md\`" "$_dst" 2>/dev/null && ! grep -qF "$AI_MARKER_START" "$_dst" 2>/dev/null; then
186
- {
187
- printf '%s\n' "$AI_MARKER_START"
188
- cat "$_body_tmp"
189
- printf '%s\n' "$AI_MARKER_END"
190
- } > "$_dst"
191
- rm -f "$_body_tmp"
192
- return 0
193
- fi
194
-
195
- # Case 1: If delimiters already exist, update the block in-place
196
- if grep -qF "$AI_MARKER_START" "$_dst" 2>/dev/null; then
197
- _tmp="$(mktemp)"
198
- awk -v s="$AI_MARKER_START" -v e="$AI_MARKER_END" -v src="$_body_tmp" '
199
- $0 == s {
200
- in_b = 1
201
- print s
202
- while ((getline line < src) > 0) print line
203
- close(src)
204
- next
205
- }
206
- $0 == e {
207
- in_b = 0
208
- print e
209
- next
210
- }
211
- !in_b { print }
212
- ' "$_dst" > "$_tmp" && mv "$_tmp" "$_dst"
213
- rm -f "$_body_tmp"
214
- log_ok "Updated Repo Nexus routing instructions in $(basename "$_dst")"
215
- return 0
216
- fi
217
-
218
- # Case 2: If no delimiters, check for legacy un-delimited Repo Nexus block
219
- # (e.g. starting with "# Multi-Repo AI Workspace Context" or containing "Symlink Write-Through")
220
- if grep -q "Multi-Repo AI Workspace Context" "$_dst" 2>/dev/null || grep -q "Symlink Write-Through" "$_dst" 2>/dev/null; then
221
- _tmp="$(mktemp)"
222
- awk -v s="$AI_MARKER_START" -v e="$AI_MARKER_END" -v src="$_body_tmp" '
223
- BEGIN { in_legacy = 0; replaced = 0 }
224
- /^# Multi-Repo AI Workspace Context/ {
225
- in_legacy = 1
226
- if (!replaced) {
227
- print s
228
- while ((getline line < src) > 0) print line
229
- close(src)
230
- print e
231
- replaced = 1
232
- }
233
- next
234
- }
235
- in_legacy {
236
- if (/^# [^#]/ && !/^# Multi-Repo/) {
237
- in_legacy = 0
238
- print
239
- next
240
- }
241
- next
242
- }
243
- !in_legacy { print }
244
- END {
245
- if (!replaced) {
246
- print s
247
- while ((getline line < src) > 0) print line
248
- close(src)
249
- print e
250
- }
251
- }
252
- ' "$_dst" > "$_tmp" && mv "$_tmp" "$_dst"
253
- rm -f "$_body_tmp"
254
- log_ok "Upgraded legacy instructions to Repo Nexus routing block in $(basename "$_dst")"
255
- return 0
256
- fi
257
-
258
- # Case 3: Completely custom instructions file without rnex context — append delimited block
259
- _tmp="$(mktemp)"
260
- cp "$_dst" "$_tmp"
261
- if [ -s "$_tmp" ] && [ -n "$(tail -c 1 "$_tmp" 2>/dev/null)" ]; then
262
- printf '\n' >> "$_tmp"
263
- fi
264
- {
265
- printf '\n%s\n' "$AI_MARKER_START"
266
- cat "$_body_tmp"
267
- printf '\n%s\n' "$AI_MARKER_END"
268
- } >> "$_tmp"
269
- mv "$_tmp" "$_dst"
270
- rm -f "$_body_tmp"
271
- log_ok "Merged Repo Nexus routing instructions with existing $(basename "$_dst")"
272
- }
273
-
274
- clean_rnex_instructions() {
275
- _dst="$1"
276
- [ -f "$_dst" ] || return 0
277
- if grep -qF "$AI_MARKER_START" "$_dst" 2>/dev/null; then
278
- _non_rnex="$(awk -v s="$AI_MARKER_START" -v e="$AI_MARKER_END" '
279
- $0 == s { skip=1; next }
280
- $0 == e { skip=0; next }
281
- !skip { print }
282
- ' "$_dst" | tr -d " \t\r\n")"
283
- if [ -z "$_non_rnex" ]; then
284
- rm -f "$_dst"
285
- log_ok "Removed $(basename "$_dst")"
286
- else
287
- _tmp="$(mktemp)"
288
- awk -v s="$AI_MARKER_START" -v e="$AI_MARKER_END" '
289
- $0 == s { skip=1; next }
290
- $0 == e { skip=0; next }
291
- !skip { print }
292
- ' "$_dst" > "$_tmp" && mv "$_tmp" "$_dst"
293
- log_ok "Removed Repo Nexus routing instructions from $(basename "$_dst")"
294
- fi
295
- fi
296
- }
152
+ # ---- Multi-Root IDE Workspace (.code-workspace) ----------------------------
297
153
 
298
154
  sync_code_workspace() {
299
155
  [ -n "$CODE_WORKSPACE_FILE" ] || return 0
@@ -363,27 +219,28 @@ sync_code_workspace() {
363
219
  fi
364
220
  }
365
221
 
366
- # ---- Provider Skill Directory & User Skill Generator API -------------------
222
+ # ---- Provider Skill Directory & Base Asset Synchronization -----------------
367
223
 
368
224
  write_rnex_env_script() {
369
225
  _dir="${1:-$NEXUS_DIR}"
370
226
  _bin_dir="$_dir/.rnex/bin"
371
227
  mkdir -p "$_bin_dir"
372
228
  _env_script="$_bin_dir/rnex-env.sh"
373
- _tmpl_env=""
229
+ _src_sdk=""
374
230
  for _cand in \
231
+ "${RNEX_LIB_DIR:-}/sdk.sh" \
232
+ "$SCRIPT_LOCATION/lib/sdk.sh" \
233
+ "$(dirname "$SCRIPT_LOCATION")/lib/sdk.sh" \
234
+ "$_dir/lib/sdk.sh" \
375
235
  "$_dir/templates/rnex-env.sh" \
376
- "$SCRIPT_LOCATION/templates/rnex-env.sh" \
377
- "$(dirname "$SCRIPT_LOCATION")/templates/rnex-env.sh" \
378
- "${RNEX_LIB_DIR:-}/../templates/rnex-env.sh" \
379
- "./templates/rnex-env.sh"; do
380
- if [ -f "$_cand" ]; then
381
- _tmpl_env="$_cand"
236
+ "$SCRIPT_LOCATION/templates/rnex-env.sh"; do
237
+ if [ -n "$_cand" ] && [ -f "$_cand" ]; then
238
+ _src_sdk="$_cand"
382
239
  break
383
240
  fi
384
241
  done
385
- if [ -n "$_tmpl_env" ]; then
386
- cp "$_tmpl_env" "$_env_script"
242
+ if [ -n "$_src_sdk" ]; then
243
+ cp "$_src_sdk" "$_env_script"
387
244
  fi
388
245
  chmod +x "$_env_script" 2>/dev/null || true
389
246
  }
@@ -419,172 +276,6 @@ get_active_provider_skill_dirs() {
419
276
  printf '%s' "$_dirs"
420
277
  }
421
278
 
422
- _tmpl_env=""
423
- for _cand in \
424
- "$SCRIPT_LOCATION/templates/rnex-env.sh" \
425
- "$(dirname "$SCRIPT_LOCATION")/templates/rnex-env.sh" \
426
- "${RNEX_LIB_DIR:-}/../templates/rnex-env.sh" \
427
- "./templates/rnex-env.sh"; do
428
- if [ -f "$_cand" ]; then
429
- _tmpl_env="$_cand"
430
- break
431
- fi
432
- done
433
- if [ -n "$_tmpl_env" ]; then
434
- # shellcheck source=/dev/null
435
- . "$_tmpl_env"
436
- fi
437
-
438
- clean_provider_user_skills() {
439
- _sk_dir="$1"
440
- [ -d "$_sk_dir" ] || return 0
441
- rm -f "$_sk_dir"/rnex-*.md 2>/dev/null || true
442
- for _d in "$_sk_dir"/rnex-*; do
443
- [ -d "$_d" ] || continue
444
- rm -rf "$_d" 2>/dev/null || true
445
- done
446
- rmdir "$_sk_dir" 2>/dev/null || true
447
- }
448
-
449
- clean_plugin_user_skills() {
450
- _pdir="$1"
451
- [ -d "$_pdir" ] || return 0
452
- _pname="$(basename "$_pdir")"
453
- if [ -d "$_pdir/skills" ]; then
454
- for _sk_file in "$_pdir/skills"/*.md; do
455
- [ -f "$_sk_file" ] || continue
456
- _sk_name="$(basename "$_sk_file" .md)"
457
- rnex_unregister_user_skill "$_sk_name" "$_pname"
458
- rnex_unregister_user_skill "$_sk_name"
459
- done
460
- fi
461
- }
462
-
463
- clean_provider_ignore() {
464
- _file="$1"
465
- [ -f "$_file" ] || return 0
466
- if grep -q '!repos/\*' "$_file" 2>/dev/null; then
467
- _non_rnex="$(grep -vE '^[ ]*#.*(Cursor|Gemini|Repo Nexus|member repos)' "$_file" 2>/dev/null | grep -v '^!repos/\*' | tr -d " \t\r\n")"
468
- if [ -z "$_non_rnex" ]; then
469
- rm -f "$_file"
470
- log_ok "Removed $(basename "$_file")"
471
- else
472
- _tmp="$(mktemp)"
473
- grep -vE '(^[ ]*#.*(Cursor|Gemini|Repo Nexus|member repos)|!repos/\*)' "$_file" > "$_tmp" && mv "$_tmp" "$_file"
474
- log_ok "Removed !repos/* un-ignore from $(basename "$_file")"
475
- fi
476
- fi
477
- }
478
-
479
- clean_provider_agents() {
480
- _ag_dir="$1"
481
- _ext="${2:-.md}"
482
- [ -d "$_ag_dir" ] || return 0
483
-
484
- for _pdir in "$SCRIPT_LOCATION/toolkit/plugins"/* "$NEXUS_DIR/toolkit/plugins"/* "$NEXUS_DIR/.rnex/plugins"/*; do
485
- [ -d "$_pdir" ] || continue
486
- [ -d "$_pdir/agents" ] || continue
487
- for _afile in "$_pdir/agents"/*.md; do
488
- [ -f "$_afile" ] || continue
489
- _aname="$(basename "$_afile" .agent.md)"
490
- _aname="$(basename "$_aname" .md)"
491
- rm -f "$_ag_dir/${_aname}${_ext}" 2>/dev/null || true
492
- done
493
- done
494
-
495
- rmdir "$_ag_dir" 2>/dev/null || true
496
- }
497
-
498
- clean_claude_auto_sync_hook() {
499
- _settings="$1"
500
- [ -f "$_settings" ] || return 0
501
- if grep -q "auto-sync.sh" "$_settings" 2>/dev/null; then
502
- _tmp="$(mktemp)"
503
- awk '
504
- /\{[ \t]*"command"[ \t]*:[ \t]*"\.rnex\/bin\/auto-sync\.sh"[ \t]*\}/ { next }
505
- /"command"[ \t]*:[ \t]*"\.rnex\/bin\/auto-sync\.sh"/ { next }
506
- { print }
507
- ' "$_settings" > "$_tmp"
508
- _clean="$(sed -e 's/"hooks"//g' -e 's/"SessionStart"//g' < "$_tmp" | tr -d ' \t\r\n[]{}:,"')"
509
- if [ -z "$_clean" ]; then
510
- rm -f "$_tmp" "$_settings"
511
- else
512
- awk '
513
- { lines[NR] = $0 }
514
- END {
515
- for (i = 1; i <= NR; i++) {
516
- if (i < NR && lines[i] ~ /,[ \t]*$/) {
517
- next_is_bracket = 0
518
- for (j = i + 1; j <= NR; j++) {
519
- if (lines[j] ~ /^[ \t]*$/) continue
520
- if (lines[j] ~ /^[ \t]*[\]\}]/) next_is_bracket = 1
521
- break
522
- }
523
- if (next_is_bracket) {
524
- sub(/,[ \t]*$/, "", lines[i])
525
- }
526
- }
527
- print lines[i]
528
- }
529
- }
530
- ' "$_tmp" > "$_settings"
531
- rm -f "$_tmp"
532
- fi
533
- fi
534
- }
535
-
536
- clean_agents_auto_sync_hook() {
537
- _hooks="$1"
538
- [ -f "$_hooks" ] || return 0
539
- if grep -q '"rnex-auto-sync"' "$_hooks" 2>/dev/null; then
540
- _tmp="$(mktemp)"
541
- awk '
542
- BEGIN { skip=0; depth=0 }
543
- /"rnex-auto-sync"[ \t]*:[ \t]*\{/ { skip=1; depth=1; next }
544
- skip {
545
- for (i=1; i<=length($0); i++) {
546
- c = substr($0, i, 1)
547
- if (c == "{") depth++
548
- if (c == "}") {
549
- depth--
550
- if (depth == 0) {
551
- skip = 0
552
- next
553
- }
554
- }
555
- }
556
- next
557
- }
558
- { print }
559
- ' "$_hooks" > "$_tmp"
560
- _clean="$(tr -d " \t\r\n{}" < "$_tmp")"
561
- if [ -z "$_clean" ]; then
562
- rm -f "$_tmp" "$_hooks"
563
- else
564
- awk '
565
- { lines[NR] = $0 }
566
- END {
567
- for (i = 1; i <= NR; i++) {
568
- if (i < NR && lines[i] ~ /,[ \t]*$/) {
569
- next_is_brace = 0
570
- for (j = i + 1; j <= NR; j++) {
571
- if (lines[j] ~ /^[ \t]*$/) continue
572
- if (lines[j] ~ /^[ \t]*\}/) next_is_brace = 1
573
- break
574
- }
575
- if (next_is_brace) {
576
- sub(/,[ \t]*$/, "", lines[i])
577
- }
578
- }
579
- print lines[i]
580
- }
581
- }
582
- ' "$_tmp" > "$_hooks"
583
- rm -f "$_tmp"
584
- fi
585
- fi
586
- }
587
-
588
279
  sync_rnex_base_assets() {
589
280
  _src_toolkit=""
590
281
  if [ -d "$SCRIPT_LOCATION/toolkit" ]; then
@@ -636,52 +327,7 @@ sync_rnex_base_assets() {
636
327
  done
637
328
  }
638
329
 
639
- sync_claude() {
640
- if yaml_plugin_enabled "claude" 2>/dev/null; then
641
- run_plugin_hook "claude" "after_sync"
642
- else
643
- run_plugin_hook "claude" "before_plugin_disable"
644
- fi
645
- }
646
-
647
- sync_gemini() {
648
- if yaml_plugin_enabled "gemini" 2>/dev/null; then
649
- run_plugin_hook "gemini" "after_sync"
650
- else
651
- run_plugin_hook "gemini" "before_plugin_disable"
652
- fi
653
- }
654
-
655
- sync_cursor() {
656
- if yaml_plugin_enabled "cursor" 2>/dev/null; then
657
- run_plugin_hook "cursor" "after_sync"
658
- else
659
- run_plugin_hook "cursor" "before_plugin_disable"
660
- fi
661
- }
662
-
663
- sync_windsurf() {
664
- if yaml_plugin_enabled "windsurf" 2>/dev/null; then
665
- run_plugin_hook "windsurf" "after_sync"
666
- else
667
- run_plugin_hook "windsurf" "before_plugin_disable"
668
- fi
669
- }
670
-
671
- sync_copilot() {
672
- if yaml_plugin_enabled "copilot" 2>/dev/null; then
673
- run_plugin_hook "copilot" "after_sync"
674
- else
675
- run_plugin_hook "copilot" "before_plugin_disable"
676
- fi
677
- }
678
-
679
- sync_ai_providers() {
680
- :
681
- }
682
-
683
330
  sync_skills() {
684
331
  write_rnex_env_script "$NEXUS_DIR"
685
332
  sync_rnex_base_assets
686
333
  }
687
-
@@ -17,18 +17,8 @@ cmd_init() {
17
17
  -y|--yes) _non_interactive=1 ;;
18
18
  --hooks) _cli_hooks="true" ;;
19
19
  --no-hooks) _cli_no_hooks=1; _cli_hooks="false" ;;
20
- --copilot) _cli_plugins="${_cli_plugins:+$_cli_plugins }copilot" ;;
21
- --no-copilot) _cli_plugins="$(printf '%s' " $_cli_plugins " | sed -e 's/ copilot / /g' -e 's/^ *//;s/ *$//')" ;;
22
- --claude) _cli_plugins="${_cli_plugins:+$_cli_plugins }claude" ;;
23
- --no-claude) _cli_plugins="$(printf '%s' " $_cli_plugins " | sed -e 's/ claude / /g' -e 's/^ *//;s/ *$//')" ;;
24
- --gemini) _cli_plugins="${_cli_plugins:+$_cli_plugins }gemini" ;;
25
- --no-gemini) _cli_plugins="$(printf '%s' " $_cli_plugins " | sed -e 's/ gemini / /g' -e 's/^ *//;s/ *$//')" ;;
26
- --cursor) _cli_plugins="${_cli_plugins:+$_cli_plugins }cursor" ;;
27
- --no-cursor) _cli_plugins="$(printf '%s' " $_cli_plugins " | sed -e 's/ cursor / /g' -e 's/^ *//;s/ *$//')" ;;
28
- --windsurf) _cli_plugins="${_cli_plugins:+$_cli_plugins }windsurf" ;;
29
- --no-windsurf) _cli_plugins="$(printf '%s' " $_cli_plugins " | sed -e 's/ windsurf / /g' -e 's/^ *//;s/ *$//')" ;;
30
- --karpathy|--karpathy-llm) _cli_plugins="${_cli_plugins:+$_cli_plugins }karpathy-llm" ;;
31
- --no-karpathy|--no-karpathy-llm) _cli_plugins="$(printf '%s' " $_cli_plugins " | sed -e 's/ karpathy-llm / /g' -e 's/^ *//;s/ *$//')" ;;
20
+ --karpathy) _cli_plugins="${_cli_plugins:+$_cli_plugins }karpathy-llm" ;;
21
+ --no-karpathy) _cli_plugins="$(printf '%s' " $_cli_plugins " | sed -e 's/ karpathy-llm / /g' -e 's/^ *//;s/ *$//')" ;;
32
22
  --plugin|--enable-plugin)
33
23
  shift
34
24
  [ -n "$1" ] && _cli_plugins="${_cli_plugins:+$_cli_plugins }$1"
@@ -53,6 +43,18 @@ cmd_init() {
53
43
  esac
54
44
  fi
55
45
  ;;
46
+ --no-*)
47
+ _pflag="${1#--no-}"
48
+ if find_plugin_dir "$_pflag" >/dev/null 2>&1; then
49
+ _cli_plugins="$(printf '%s' " $_cli_plugins " | sed -e "s/ $_pflag / /g" -e 's/^ *//;s/ *$//')"
50
+ fi
51
+ ;;
52
+ --*)
53
+ _pflag="${1#--}"
54
+ if find_plugin_dir "$_pflag" >/dev/null 2>&1; then
55
+ _cli_plugins="${_cli_plugins:+$_cli_plugins }$_pflag"
56
+ fi
57
+ ;;
56
58
  *)
57
59
  if [ -z "$_init_dir" ]; then
58
60
  _init_dir="$1"
@@ -155,9 +157,6 @@ YAML_EOF
155
157
  fi
156
158
 
157
159
  # Set active workspace context for initialization
158
- _orig_nexus="$NEXUS_DIR"
159
- _orig_yaml="$WORKSPACE_YAML"
160
- _orig_local_yaml="$WORKSPACE_LOCAL_YAML"
161
160
  NEXUS_DIR="$_init_dir"
162
161
  WORKSPACE_YAML="$_target_yaml"
163
162
  WORKSPACE_LOCAL_YAML="$_init_dir/$RNEX_LOCAL_CONFIG_FILE"
@@ -166,11 +165,9 @@ YAML_EOF
166
165
  if ! has_active_provider_instructions "$_init_dir"; then
167
166
  merge_rnex_instructions "$_init_dir/AGENTS.md"
168
167
  fi
169
- [ -f "$_init_dir/CLAUDE.md" ] && merge_rnex_instructions "$_init_dir/CLAUDE.md"
170
- [ -f "$_init_dir/GEMINI.md" ] && merge_rnex_instructions "$_init_dir/GEMINI.md"
171
- [ -f "$_init_dir/.cursorrules" ] && merge_rnex_instructions "$_init_dir/.cursorrules"
172
- [ -f "$_init_dir/.windsurfrules" ] && merge_rnex_instructions "$_init_dir/.windsurfrules"
173
- [ -f "$_init_dir/.github/copilot-instructions.md" ] && merge_rnex_instructions "$_init_dir/.github/copilot-instructions.md"
168
+ for _if in CLAUDE.md GEMINI.md .cursorrules .windsurfrules .github/copilot-instructions.md; do
169
+ [ -f "$_init_dir/$_if" ] && merge_rnex_instructions "$_init_dir/$_if"
170
+ done
174
171
 
175
172
  # ---- 3. Create repos directory with .gitkeep -----------------------------
176
173
  _repos_dir="$_init_dir/repos"
@@ -183,50 +180,21 @@ YAML_EOF
183
180
  sync_plugins
184
181
  build_ai_instructions "$_init_dir"
185
182
  sync_skills
186
- WORKSPACE_LOCAL_YAML="$_orig_local_yaml"
187
- WORKSPACE_YAML="$_orig_yaml"
188
- NEXUS_DIR="$_orig_nexus"
189
183
 
190
184
  # ---- 5. Ensure repos/ and local configs are gitignored ---------
191
185
  reconcile_gitignore "$_init_dir"
192
186
 
193
187
  # ---- 6. Generate VS Code / Cursor workspace if configured ----------------
194
- _target_cw="$_cli_code_workspace"
195
- if [ -z "$_target_cw" ] && [ -f "$_init_dir/$RNEX_LOCAL_CONFIG_FILE" ]; then
196
- _target_cw="$(awk '/^(code_workspace|vscode_workspace):/ { sub(/^[a-zA-Z0-9_]+:[ ]*/, ""); sub(/[ ]*#.*/, ""); val=$0 } END { if (val) print val }' "$_init_dir/$RNEX_LOCAL_CONFIG_FILE")"
197
- fi
198
- if [ -z "$_target_cw" ] && [ -f "$_target_yaml" ]; then
199
- _target_cw="$(awk '/^(code_workspace|vscode_workspace):/ { sub(/^[a-zA-Z0-9_]+:[ ]*/, ""); sub(/[ ]*#.*/, ""); val=$0 } END { if (val) print val }' "$_target_yaml")"
200
- fi
201
- _target_cw="$(echo "$_target_cw" | tr -d " \t\r\n'\"")"
202
- case "$_target_cw" in
203
- true|yes|1)
204
- _cw_name="$(basename "$_init_dir").code-workspace"
205
- ;;
206
- false|no|0|none|"")
207
- _cw_name=""
208
- ;;
209
- *)
210
- case "$_target_cw" in
211
- *.code-workspace) _cw_name="$_target_cw" ;;
212
- *) _cw_name="$_target_cw.code-workspace" ;;
213
- esac
214
- ;;
215
- esac
216
-
188
+ _orig_repos="$REPOS_DIR"
189
+ _orig_cw="$CODE_WORKSPACE_FILE"
190
+ _load_code_workspace "$_cli_code_workspace"
191
+ _cw_name="$CODE_WORKSPACE_FILE"
217
192
  if [ -n "$_cw_name" ]; then
218
- _orig_nexus="$NEXUS_DIR"
219
- _orig_repos="$REPOS_DIR"
220
- _orig_cw="$CODE_WORKSPACE_FILE"
221
- CODE_WORKSPACE_FILE="$_cw_name"
222
- NEXUS_DIR="$_init_dir"
223
- _repos_rel="repos"
224
- REPOS_DIR="$_init_dir/$_repos_rel"
193
+ REPOS_DIR="$_init_dir/repos"
225
194
  sync_code_workspace
226
- NEXUS_DIR="$_orig_nexus"
227
- REPOS_DIR="$_orig_repos"
228
- CODE_WORKSPACE_FILE="$_orig_cw"
229
195
  fi
196
+ REPOS_DIR="$_orig_repos"
197
+ CODE_WORKSPACE_FILE="$_orig_cw"
230
198
 
231
199
  # ---- 7. Setup automated Git hooks if inside a Git repository ------------
232
200
  if [ "$_is_git_ws" -eq 1 ]; then
@@ -238,13 +206,8 @@ YAML_EOF
238
206
  fi
239
207
 
240
208
  _write_auto_sync_script "$_init_dir"
241
- _sync_ai_session_start_hooks "$_init_dir"
242
209
  update_sync_stamp "$_init_dir"
243
210
 
244
- NEXUS_DIR="$_init_dir"
245
- WORKSPACE_YAML="$_target_yaml"
246
- WORKSPACE_LOCAL_YAML="$_init_dir/$RNEX_LOCAL_CONFIG_FILE"
247
-
248
211
  if [ "$_config_created" -eq 1 ]; then
249
212
  printf '\n'
250
213
  log_ok "Initialized Repo Nexus workspace at ${_BOLD}$_init_dir${_NC}"
@@ -245,29 +245,16 @@ cmd_rnex_dir() {
245
245
  done
246
246
 
247
247
  case "$_action" in
248
- enable)
248
+ enable|disable)
249
249
  [ -n "$_name" ] || die "Usage: rnex rnex-dir <enable|disable> <name> [--local]"
250
250
  yaml_has_repo "$_name" || die "Repo '$_name' is not registered"
251
- if [ "$_is_local" -eq 1 ]; then
252
- yaml_set_local "$_name" "rnex_dir" "true"
253
- log_ok "Enabled member .rnex directory for '$_name' locally in $(basename "$WORKSPACE_LOCAL_YAML")"
251
+ if [ "$_action" = "enable" ]; then
252
+ _repo_set_config_and_log "$_name" "rnex_dir" "true" "$_is_local" "Enabled member .rnex directory for"
253
+ sync_repo_rnex "$_name"
254
254
  else
255
- yaml_set "$_name" "rnex_dir" "true"
256
- log_ok "Enabled member .rnex directory for '$_name' in $(basename "$WORKSPACE_YAML")"
255
+ _repo_set_config_and_log "$_name" "rnex_dir" "false" "$_is_local" "Disabled member .rnex directory for"
256
+ clean_repo_rnex "$_name"
257
257
  fi
258
- sync_repo_rnex "$_name"
259
- ;;
260
- disable)
261
- [ -n "$_name" ] || die "Usage: rnex rnex-dir <enable|disable> <name> [--local]"
262
- yaml_has_repo "$_name" || die "Repo '$_name' is not registered"
263
- if [ "$_is_local" -eq 1 ]; then
264
- yaml_set_local "$_name" "rnex_dir" "false"
265
- log_ok "Disabled member .rnex directory for '$_name' locally in $(basename "$WORKSPACE_LOCAL_YAML")"
266
- else
267
- yaml_set "$_name" "rnex_dir" "false"
268
- log_ok "Disabled member .rnex directory for '$_name' in $(basename "$WORKSPACE_YAML")"
269
- fi
270
- clean_repo_rnex "$_name"
271
258
  ;;
272
259
  *)
273
260
  die "Usage: rnex rnex-dir <enable|disable> <name> [--local]"