@brickhouse-tech/sync-agents 0.1.9 → 0.1.10

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": "@brickhouse-tech/sync-agents",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Simple scripts to DRY up common agent interactions across multiple LLM providers.",
5
5
  "keywords": [
6
6
  "agents",
@@ -75,6 +75,7 @@ ${BOLD}COMMANDS${RESET}
75
75
  watch Watch .agents/ for changes and auto-regenerate index
76
76
  import <url> Import a rule/skill/workflow from a URL
77
77
  hook Install a pre-commit git hook for auto-sync
78
+ fix [type] Migrate legacy dirs into .agents/ (type: skills, rules, workflows, or all)
78
79
  inherit <label> <path> Add an inheritance link to AGENTS.md (convention-based)
79
80
  inherit --list List current inheritance links
80
81
  inherit --remove <label> Remove an inheritance link by label
@@ -249,7 +250,14 @@ cmd_add() {
249
250
 
250
251
  ensure_agents_dir
251
252
 
252
- local filepath="$PROJECT_ROOT/$AGENTS_DIR/$type/$name.md"
253
+ # Skills use directory layout: skills/name/SKILL.md
254
+ # Rules and workflows use flat files: rules/name.md, workflows/name.md
255
+ local filepath
256
+ if [[ "$type" == "skills" ]]; then
257
+ filepath="$PROJECT_ROOT/$AGENTS_DIR/$type/$name/SKILL.md"
258
+ else
259
+ filepath="$PROJECT_ROOT/$AGENTS_DIR/$type/$name.md"
260
+ fi
253
261
 
254
262
  if [[ -f "$filepath" ]] && [[ "$FORCE" != "true" ]]; then
255
263
  error "File already exists: $filepath (use --force to overwrite)"
@@ -265,6 +273,9 @@ cmd_add() {
265
273
  *) template_name="RULE_TEMPLATE.md" ;;
266
274
  esac
267
275
 
276
+ # Create parent directory for skills
277
+ mkdir -p "$(dirname "$filepath")"
278
+
268
279
  if [[ -f "$TEMPLATES_DIR/$template_name" ]]; then
269
280
  sed "s/\${NAME}/$name/g" "$TEMPLATES_DIR/$template_name" > "$filepath"
270
281
  elif [[ -f "$TEMPLATES_DIR/RULE_TEMPLATE.md" ]]; then
@@ -287,6 +298,105 @@ TMPL_EOF
287
298
  info "Updated $AGENTS_MD index"
288
299
  }
289
300
 
301
+ cmd_fix() {
302
+ ensure_agents_dir
303
+
304
+ local fix_type="${1:-all}"
305
+ local subdirs=()
306
+
307
+ case "$fix_type" in
308
+ skills|rules|workflows)
309
+ subdirs=("$fix_type")
310
+ ;;
311
+ all)
312
+ subdirs=(skills rules workflows)
313
+ ;;
314
+ *)
315
+ error "Unknown type: $fix_type (expected: skills, rules, workflows, or all)"
316
+ exit 1
317
+ ;;
318
+ esac
319
+
320
+ local agents_abs
321
+ agents_abs="$(cd "$PROJECT_ROOT/$AGENTS_DIR" && pwd)"
322
+ local fixed=0
323
+
324
+ for subdir in "${subdirs[@]}"; do
325
+ local legacy_dir="$PROJECT_ROOT/$subdir"
326
+ local agents_subdir="$agents_abs/$subdir"
327
+
328
+ # Skip if legacy dir doesn't exist or is already a symlink
329
+ if [[ ! -d "$legacy_dir" ]] || [[ -L "$legacy_dir" ]]; then
330
+ continue
331
+ fi
332
+
333
+ info "Found legacy directory: $subdir/"
334
+ mkdir -p "$agents_subdir"
335
+
336
+ # Move each item from legacy dir into .agents/subdir
337
+ for item in "$legacy_dir"/*/; do
338
+ [[ -d "$item" ]] || continue
339
+ local name
340
+ name="$(basename "$item")"
341
+
342
+ if [[ -d "$agents_subdir/$name" ]]; then
343
+ warn "Skipping $subdir/$name — already exists in $AGENTS_DIR/$subdir/"
344
+ continue
345
+ fi
346
+
347
+ if [[ "$DRY_RUN" == "true" ]]; then
348
+ echo " would move: $subdir/$name -> $AGENTS_DIR/$subdir/$name"
349
+ else
350
+ mv "$item" "$agents_subdir/$name"
351
+ info "Moved: $subdir/$name -> $AGENTS_DIR/$subdir/$name"
352
+ fi
353
+ fixed=$((fixed + 1))
354
+ done
355
+
356
+ # Also move any top-level files (e.g. loose .md rules)
357
+ for item in "$legacy_dir"/*; do
358
+ [[ -f "$item" ]] || continue
359
+ local name
360
+ name="$(basename "$item")"
361
+
362
+ if [[ -f "$agents_subdir/$name" ]]; then
363
+ warn "Skipping $subdir/$name — already exists in $AGENTS_DIR/$subdir/"
364
+ continue
365
+ fi
366
+
367
+ if [[ "$DRY_RUN" == "true" ]]; then
368
+ echo " would move: $subdir/$name -> $AGENTS_DIR/$subdir/$name"
369
+ else
370
+ mv "$item" "$agents_subdir/$name"
371
+ info "Moved: $subdir/$name -> $AGENTS_DIR/$subdir/$name"
372
+ fi
373
+ fixed=$((fixed + 1))
374
+ done
375
+
376
+ # Remove the now-empty legacy dir and replace with symlink
377
+ if [[ "$DRY_RUN" == "true" ]]; then
378
+ echo " would replace $subdir/ with symlink -> $AGENTS_DIR/$subdir"
379
+ else
380
+ # Check if dir is empty (only . and .. remain)
381
+ if [[ -z "$(ls -A "$legacy_dir" 2>/dev/null)" ]]; then
382
+ rmdir "$legacy_dir"
383
+ ln -s "$AGENTS_DIR/$subdir" "$legacy_dir"
384
+ info "Replaced $subdir/ with symlink -> $AGENTS_DIR/$subdir"
385
+ else
386
+ warn "$subdir/ is not empty after migration — skipping symlink replacement"
387
+ warn "Remaining items:"
388
+ find "$legacy_dir" -mindepth 1 -maxdepth 1 -exec basename {} \; | sed 's/^/ /'
389
+ fi
390
+ fi
391
+ done
392
+
393
+ if [[ "$fixed" -eq 0 ]]; then
394
+ info "Nothing to fix — all directories are already in $AGENTS_DIR/ or symlinked."
395
+ else
396
+ info "Fixed $fixed item(s). Run 'sync-agents sync' to update agent target symlinks."
397
+ fi
398
+ }
399
+
290
400
  cmd_sync() {
291
401
  ensure_agents_dir
292
402
 
@@ -936,16 +1046,30 @@ HEADER
936
1046
  fi
937
1047
  echo ""
938
1048
 
939
- # Skills
1049
+ # Skills (directory layout: skills/name/SKILL.md, or legacy flat: skills/name.md)
940
1050
  echo "## Skills"
941
1051
  echo ""
1052
+ local has_skills="false"
1053
+ # Directory skills: skills/name/SKILL.md
1054
+ for d in "$agents_dir/skills/"*/; do
1055
+ [[ -d "$d" ]] || continue
1056
+ local name
1057
+ name="$(basename "$d")"
1058
+ if [[ -f "$d/SKILL.md" ]]; then
1059
+ echo "- [$name](.agents/skills/$name/SKILL.md)"
1060
+ has_skills="true"
1061
+ fi
1062
+ done
1063
+ # Legacy flat skills: skills/name.md
942
1064
  if compgen -G "$agents_dir/skills/*.md" > /dev/null 2>&1; then
943
1065
  for f in "$agents_dir/skills/"*.md; do
944
1066
  local name
945
1067
  name="$(basename "$f" .md)"
946
1068
  echo "- [$name](.agents/skills/$name.md)"
1069
+ has_skills="true"
947
1070
  done
948
- else
1071
+ fi
1072
+ if [[ "$has_skills" == "false" ]]; then
949
1073
  echo "_No skills defined yet. Add one with \`sync-agents add skill <name>\`._"
950
1074
  fi
951
1075
  echo ""
@@ -1124,6 +1248,9 @@ main() {
1124
1248
  import)
1125
1249
  cmd_import "$@"
1126
1250
  ;;
1251
+ fix)
1252
+ cmd_fix "$@"
1253
+ ;;
1127
1254
  hook)
1128
1255
  cmd_hook
1129
1256
  ;;