@prmichaelsen/remember-mcp 2.7.10 → 2.8.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.
Files changed (76) hide show
  1. package/.env.example +6 -0
  2. package/AGENT.md +224 -21
  3. package/CHANGELOG.md +47 -912
  4. package/README.md +35 -0
  5. package/agent/commands/acp.command-create.md +373 -0
  6. package/agent/commands/acp.design-create.md +225 -0
  7. package/agent/commands/acp.init.md +40 -5
  8. package/agent/commands/acp.package-create.md +895 -0
  9. package/agent/commands/acp.package-info.md +212 -0
  10. package/agent/commands/acp.package-install.md +207 -33
  11. package/agent/commands/acp.package-list.md +280 -0
  12. package/agent/commands/acp.package-publish.md +541 -0
  13. package/agent/commands/acp.package-remove.md +293 -0
  14. package/agent/commands/acp.package-search.md +307 -0
  15. package/agent/commands/acp.package-update.md +361 -0
  16. package/agent/commands/acp.package-validate.md +540 -0
  17. package/agent/commands/acp.pattern-create.md +327 -0
  18. package/agent/commands/acp.plan.md +553 -0
  19. package/agent/commands/acp.proceed.md +112 -86
  20. package/agent/commands/acp.project-create.md +673 -0
  21. package/agent/commands/acp.project-list.md +225 -0
  22. package/agent/commands/acp.project-set.md +227 -0
  23. package/agent/commands/acp.report.md +3 -0
  24. package/agent/commands/acp.resume.md +238 -0
  25. package/agent/commands/acp.status.md +1 -0
  26. package/agent/commands/acp.sync.md +56 -15
  27. package/agent/commands/acp.task-create.md +391 -0
  28. package/agent/commands/acp.update.md +1 -0
  29. package/agent/commands/acp.validate.md +62 -10
  30. package/agent/commands/acp.version-check-for-updates.md +6 -5
  31. package/agent/commands/acp.version-check.md +7 -6
  32. package/agent/commands/acp.version-update.md +7 -6
  33. package/agent/commands/command.template.md +48 -0
  34. package/agent/commands/git.commit.md +6 -3
  35. package/agent/commands/git.init.md +1 -0
  36. package/agent/manifest.template.yaml +13 -0
  37. package/agent/package.template.yaml +53 -0
  38. package/agent/progress.template.yaml +3 -0
  39. package/agent/progress.yaml +103 -5
  40. package/agent/scripts/acp.common.sh +1536 -0
  41. package/agent/scripts/acp.install.sh +293 -0
  42. package/agent/scripts/acp.package-create.sh +925 -0
  43. package/agent/scripts/acp.package-info.sh +270 -0
  44. package/agent/scripts/acp.package-install.sh +675 -0
  45. package/agent/scripts/acp.package-list.sh +263 -0
  46. package/agent/scripts/acp.package-publish.sh +420 -0
  47. package/agent/scripts/acp.package-remove.sh +272 -0
  48. package/agent/scripts/acp.package-search.sh +156 -0
  49. package/agent/scripts/acp.package-update.sh +438 -0
  50. package/agent/scripts/acp.package-validate.sh +954 -0
  51. package/agent/scripts/acp.project-list.sh +121 -0
  52. package/agent/scripts/acp.project-set.sh +138 -0
  53. package/agent/scripts/{uninstall.sh → acp.uninstall.sh} +25 -15
  54. package/agent/scripts/{check-for-updates.sh → acp.version-check-for-updates.sh} +24 -14
  55. package/agent/scripts/{version.sh → acp.version-check.sh} +20 -8
  56. package/agent/scripts/{update.sh → acp.version-update.sh} +44 -25
  57. package/agent/scripts/acp.yaml-parser.sh +853 -0
  58. package/agent/scripts/acp.yaml-validate.sh +205 -0
  59. package/agent/tasks/task-68-fix-missing-space-properties.md +192 -0
  60. package/agent/tasks/task-69-add-comprehensive-tool-debugging.md +454 -0
  61. package/dist/config.d.ts +18 -0
  62. package/dist/server-factory.js +296 -19
  63. package/dist/server.js +296 -19
  64. package/dist/utils/debug.d.ts +52 -0
  65. package/dist/utils/debug.spec.d.ts +5 -0
  66. package/dist/weaviate/client.d.ts +1 -1
  67. package/package.json +1 -1
  68. package/src/config.ts +33 -0
  69. package/src/tools/confirm.ts +70 -7
  70. package/src/tools/publish.ts +19 -1
  71. package/src/tools/query-space.ts +36 -3
  72. package/src/tools/search-space.ts +36 -3
  73. package/src/utils/debug.spec.ts +257 -0
  74. package/src/utils/debug.ts +138 -0
  75. package/src/weaviate/client.ts +42 -3
  76. package/agent/scripts/install.sh +0 -157
@@ -0,0 +1,675 @@
1
+ #!/bin/bash
2
+
3
+ # Agent Context Protocol (ACP) Package Install Script
4
+ # Installs third-party ACP packages (commands, patterns, designs, etc.) from git repositories
5
+
6
+ set -e
7
+
8
+ # Source common utilities
9
+ SCRIPT_DIR="$(dirname "$0")"
10
+ . "${SCRIPT_DIR}/acp.common.sh"
11
+ . "${SCRIPT_DIR}/acp.yaml-parser.sh"
12
+
13
+ # Initialize colors
14
+ init_colors
15
+
16
+ # Parse arguments
17
+ REPO_URL=""
18
+ INSTALL_PATTERNS=false
19
+ INSTALL_COMMANDS=false
20
+ INSTALL_DESIGNS=false
21
+ PATTERN_FILES=()
22
+ COMMAND_FILES=()
23
+ DESIGN_FILES=()
24
+ LIST_ONLY=false
25
+ GLOBAL_INSTALL=false
26
+ INSTALL_EXPERIMENTAL=false
27
+ SKIP_CONFIRM=false
28
+
29
+ while [[ $# -gt 0 ]]; do
30
+ case $1 in
31
+ --repo)
32
+ REPO_URL="$2"
33
+ shift 2
34
+ ;;
35
+ --global)
36
+ GLOBAL_INSTALL=true
37
+ shift
38
+ ;;
39
+ --experimental)
40
+ INSTALL_EXPERIMENTAL=true
41
+ shift
42
+ ;;
43
+ -y|--yes)
44
+ SKIP_CONFIRM=true
45
+ shift
46
+ ;;
47
+ --patterns)
48
+ INSTALL_PATTERNS=true
49
+ shift
50
+ # Collect pattern file names until next flag
51
+ while [[ $# -gt 0 && ! $1 =~ ^-- ]]; do
52
+ PATTERN_FILES+=("$1")
53
+ shift
54
+ done
55
+ ;;
56
+ --commands)
57
+ INSTALL_COMMANDS=true
58
+ shift
59
+ # Collect command file names until next flag
60
+ while [[ $# -gt 0 && ! $1 =~ ^-- ]]; do
61
+ COMMAND_FILES+=("$1")
62
+ shift
63
+ done
64
+ ;;
65
+ --designs)
66
+ INSTALL_DESIGNS=true
67
+ shift
68
+ # Collect design file names until next flag
69
+ while [[ $# -gt 0 && ! $1 =~ ^-- ]]; do
70
+ DESIGN_FILES+=("$1")
71
+ shift
72
+ done
73
+ ;;
74
+ --list)
75
+ LIST_ONLY=true
76
+ shift
77
+ ;;
78
+ *)
79
+ echo "${RED}Error: Unknown option: $1${NC}"
80
+ echo "Use --repo to specify repository URL"
81
+ exit 1
82
+ ;;
83
+ esac
84
+ done
85
+
86
+ # Check if repository URL provided
87
+ if [ -z "$REPO_URL" ]; then
88
+ echo "${RED}Error: Repository URL required${NC}"
89
+ echo "Usage: $0 --repo <repository-url> [options]"
90
+ echo ""
91
+ echo "Required:"
92
+ echo " --repo <url> Repository URL to install from"
93
+ echo ""
94
+ echo "Options:"
95
+ echo " --global Install to ~/.acp/packages/ instead of ./agent/"
96
+ echo " --patterns [files...] Install patterns (all if no files specified)"
97
+ echo " --commands [files...] Install commands (all if no files specified)"
98
+ echo " --designs [files...] Install designs (all if no files specified)"
99
+ echo " --list List available files without installing"
100
+ echo ""
101
+ echo "Examples:"
102
+ echo " $0 https://github.com/example/acp-package.git"
103
+ echo " $0 --patterns https://github.com/example/acp-package.git"
104
+ echo " $0 --patterns file1 file2 https://github.com/example/acp-package.git"
105
+ echo " $0 --list https://github.com/example/acp-package.git"
106
+ exit 1
107
+ fi
108
+
109
+ # Default: install everything if no selective flags specified
110
+ if [[ "$INSTALL_PATTERNS" == false && "$INSTALL_COMMANDS" == false && "$INSTALL_DESIGNS" == false ]]; then
111
+ INSTALL_PATTERNS=true
112
+ INSTALL_COMMANDS=true
113
+ INSTALL_DESIGNS=true
114
+ fi
115
+
116
+ echo "${BLUE}📦 ACP Package Installer${NC}"
117
+ echo "========================================"
118
+ echo ""
119
+ echo "Repository: $REPO_URL"
120
+ echo ""
121
+
122
+ # Validate URL format (allow local paths for testing)
123
+ if [[ ! "$REPO_URL" =~ ^https?:// ]] && [[ ! "$REPO_URL" =~ ^file:// ]] && [[ ! -d "$REPO_URL" ]]; then
124
+ echo "${RED}Error: Invalid repository URL${NC}"
125
+ echo "URL must start with http://, https://, file://, or be a local directory path"
126
+ exit 1
127
+ fi
128
+
129
+ # Create temporary directory
130
+ TEMP_DIR=$(mktemp -d)
131
+ trap "rm -rf $TEMP_DIR" EXIT
132
+
133
+ echo "Cloning repository..."
134
+ if ! git clone --depth 1 "$REPO_URL" "$TEMP_DIR" &>/dev/null; then
135
+ echo "${RED}Error: Failed to clone repository${NC}"
136
+ echo "Please check the URL and your internet connection."
137
+ exit 1
138
+ fi
139
+
140
+ echo "${GREEN}✓${NC} Repository cloned"
141
+ echo ""
142
+
143
+ # Check if repository has agent/ directory
144
+ if [ ! -d "$TEMP_DIR/agent" ]; then
145
+ echo "${RED}Error: No agent/ directory found${NC}"
146
+ echo "Repository must contain an 'agent/' directory with ACP files"
147
+ exit 1
148
+ fi
149
+
150
+ # Determine installation directory and manifest based on --global flag
151
+ if [ "$GLOBAL_INSTALL" = true ]; then
152
+ # Global installation - install directly into ~/.acp/agent/
153
+ INSTALL_BASE_DIR="$HOME/.acp/agent"
154
+ MANIFEST_FILE="$HOME/.acp/agent/manifest.yaml"
155
+
156
+ echo "${BLUE}Installing globally to ~/.acp/agent/${NC}"
157
+ echo ""
158
+
159
+ # Initialize global ACP infrastructure (auto-initialization)
160
+ init_global_acp || {
161
+ echo "${RED}Error: Failed to initialize global infrastructure${NC}" >&2
162
+ exit 1
163
+ }
164
+ else
165
+ # Local installation (existing behavior)
166
+ INSTALL_BASE_DIR="./agent"
167
+ MANIFEST_FILE="./agent/manifest.yaml"
168
+
169
+ echo "${BLUE}Installing locally to ./agent/${NC}"
170
+ echo ""
171
+
172
+ # Initialize local manifest
173
+ init_manifest
174
+ fi
175
+
176
+ # Parse package metadata
177
+ parse_package_metadata "$TEMP_DIR"
178
+
179
+ # Get commit hash
180
+ COMMIT_HASH=$(get_commit_hash "$TEMP_DIR")
181
+ info "Commit: $COMMIT_HASH"
182
+ echo ""
183
+
184
+ # List mode - show available files and exit
185
+ if [ "$LIST_ONLY" = true ]; then
186
+ echo "${BLUE}📁 Available files in package:${NC}"
187
+ echo ""
188
+
189
+ # List patterns
190
+ if [ -d "$TEMP_DIR/agent/patterns" ]; then
191
+ PATTERN_COUNT=$(find "$TEMP_DIR/agent/patterns" -maxdepth 1 -name "*.md" ! -name "*.template.md" -type f 2>/dev/null | wc -l)
192
+ if [ "$PATTERN_COUNT" -gt 0 ]; then
193
+ echo "${GREEN}Patterns ($PATTERN_COUNT):${NC}"
194
+ find "$TEMP_DIR/agent/patterns" -maxdepth 1 -name "*.md" ! -name "*.template.md" -type f 2>/dev/null | xargs -n1 basename | sed 's/^/ - /'
195
+ echo ""
196
+ fi
197
+ fi
198
+
199
+ # List commands
200
+ if [ -d "$TEMP_DIR/agent/commands" ]; then
201
+ COMMAND_COUNT=$(find "$TEMP_DIR/agent/commands" -maxdepth 1 -name "*.*.md" ! -name "*.template.md" -type f 2>/dev/null | wc -l)
202
+ if [ "$COMMAND_COUNT" -gt 0 ]; then
203
+ echo "${GREEN}Commands ($COMMAND_COUNT):${NC}"
204
+ find "$TEMP_DIR/agent/commands" -maxdepth 1 -name "*.*.md" ! -name "*.template.md" -type f 2>/dev/null | xargs -n1 basename | sed 's/^/ - /'
205
+ echo ""
206
+ fi
207
+ fi
208
+
209
+ # List designs
210
+ if [ -d "$TEMP_DIR/agent/design" ]; then
211
+ DESIGN_COUNT=$(find "$TEMP_DIR/agent/design" -maxdepth 1 -name "*.md" ! -name "*.template.md" -type f 2>/dev/null | wc -l)
212
+ if [ "$DESIGN_COUNT" -gt 0 ]; then
213
+ echo "${GREEN}Designs ($DESIGN_COUNT):${NC}"
214
+ find "$TEMP_DIR/agent/design" -maxdepth 1 -name "*.md" ! -name "*.template.md" -type f 2>/dev/null | xargs -n1 basename | sed 's/^/ - /'
215
+ echo ""
216
+ fi
217
+ fi
218
+
219
+ TOTAL_COUNT=$((PATTERN_COUNT + COMMAND_COUNT + DESIGN_COUNT))
220
+ echo "Total: $TOTAL_COUNT file(s) available"
221
+ echo ""
222
+ echo "To install all files:"
223
+ echo " $0 $REPO_URL"
224
+ echo ""
225
+ echo "To install specific types:"
226
+ echo " $0 --patterns $REPO_URL"
227
+ echo " $0 --commands $REPO_URL"
228
+ echo " $0 --patterns --commands $REPO_URL"
229
+ echo ""
230
+ echo "To install specific files:"
231
+ echo " $0 --patterns file1 file2 $REPO_URL"
232
+
233
+ exit 0
234
+ fi
235
+
236
+ # Validate project dependencies
237
+ if [ -f "$TEMP_DIR/package.yaml" ]; then
238
+ if ! validate_project_dependencies "$TEMP_DIR/package.yaml"; then
239
+ echo "${RED}Installation cancelled due to dependency issues${NC}"
240
+ exit 1
241
+ fi
242
+ fi
243
+
244
+ # Directories to install from (based on flags)
245
+ INSTALL_DIRS=()
246
+ [ "$INSTALL_PATTERNS" = true ] && INSTALL_DIRS+=("patterns")
247
+ [ "$INSTALL_COMMANDS" = true ] && INSTALL_DIRS+=("commands")
248
+ [ "$INSTALL_DESIGNS" = true ] && INSTALL_DIRS+=("design")
249
+ [ "$INSTALL_COMMANDS" = true ] && INSTALL_DIRS+=("scripts") # Scripts installed with commands
250
+
251
+ INSTALLED_COUNT=0
252
+ SKIPPED_COUNT=0
253
+
254
+ echo "Scanning for installable files..."
255
+ echo ""
256
+
257
+ # Process each directory
258
+ for dir in "${INSTALL_DIRS[@]}"; do
259
+ SOURCE_DIR="$TEMP_DIR/agent/$dir"
260
+
261
+ if [ ! -d "$SOURCE_DIR" ]; then
262
+ continue
263
+ fi
264
+
265
+ # Determine which files to process based on selective flags
266
+ declare -n FILE_LIST
267
+ case "$dir" in
268
+ patterns)
269
+ FILE_LIST=PATTERN_FILES
270
+ ;;
271
+ commands)
272
+ FILE_LIST=COMMAND_FILES
273
+ ;;
274
+ design)
275
+ FILE_LIST=DESIGN_FILES
276
+ ;;
277
+ scripts)
278
+ FILE_LIST=COMMAND_FILES # Scripts use command files list (empty array if no specific files)
279
+ ;;
280
+ esac
281
+
282
+ # If specific files requested, use those; otherwise find all
283
+ if [ ${#FILE_LIST[@]} -gt 0 ]; then
284
+ # Selective file installation
285
+ FILES_TO_PROCESS=()
286
+ for file_name in "${FILE_LIST[@]}"; do
287
+ # Add appropriate extension if not present
288
+ if [ "$dir" = "scripts" ]; then
289
+ [[ "$file_name" != *.sh ]] && file_name="${file_name}.sh"
290
+ else
291
+ [[ "$file_name" != *.md ]] && file_name="${file_name}.md"
292
+ fi
293
+
294
+ file_path="$SOURCE_DIR/$file_name"
295
+ if [ -f "$file_path" ]; then
296
+ FILES_TO_PROCESS+=("$file_path")
297
+ else
298
+ echo "${YELLOW}⚠${NC} File not found in $dir/: $file_name"
299
+ SKIPPED_COUNT=$((SKIPPED_COUNT + 1))
300
+ fi
301
+ done
302
+ else
303
+ # Install all files from directory
304
+ FILES_TO_PROCESS=()
305
+ if [ "$dir" = "scripts" ]; then
306
+ # For scripts, find .sh files
307
+ while IFS= read -r file; do
308
+ [ -n "$file" ] && FILES_TO_PROCESS+=("$file")
309
+ done < <(find "$SOURCE_DIR" -maxdepth 1 -name "*.sh" ! -name "*.template.sh" -type f)
310
+ else
311
+ # For other types, find .md files
312
+ while IFS= read -r file; do
313
+ [ -n "$file" ] && FILES_TO_PROCESS+=("$file")
314
+ done < <(find "$SOURCE_DIR" -maxdepth 1 -name "*.md" ! -name "*.template.md" -type f)
315
+ fi
316
+ fi
317
+
318
+ if [ ${#FILES_TO_PROCESS[@]} -eq 0 ]; then
319
+ continue
320
+ fi
321
+
322
+ echo "${BLUE}📁 $dir/${NC} (${#FILES_TO_PROCESS[@]} file(s))"
323
+
324
+ # Validate and list files
325
+ for file in "${FILES_TO_PROCESS[@]}"; do
326
+ filename=$(basename "$file")
327
+
328
+ # Special validation for commands
329
+ if [ "$dir" = "commands" ]; then
330
+ # Check for reserved 'acp' namespace
331
+ if [[ "$filename" =~ ^acp\. ]]; then
332
+ echo " ${RED}✗${NC} $filename (reserved namespace 'acp')"
333
+ SKIPPED_COUNT=$((SKIPPED_COUNT + 1))
334
+ continue
335
+ fi
336
+
337
+ # Check for agent directive
338
+ if ! grep -q "🤖 Agent Directive" "$file"; then
339
+ echo " ${YELLOW}⚠${NC} $filename (missing agent directive - skipping)"
340
+ SKIPPED_COUNT=$((SKIPPED_COUNT + 1))
341
+ continue
342
+ fi
343
+ fi
344
+
345
+ # Special validation for scripts
346
+ if [ "$dir" = "scripts" ]; then
347
+ # Check for reserved 'acp' namespace
348
+ if [[ "$filename" =~ ^acp\. ]]; then
349
+ echo " ${RED}✗${NC} $filename (reserved namespace 'acp')"
350
+ SKIPPED_COUNT=$((SKIPPED_COUNT + 1))
351
+ continue
352
+ fi
353
+
354
+ # Check for shebang
355
+ if ! head -n1 "$file" | grep -q "^#!/"; then
356
+ echo " ${YELLOW}⚠${NC} $filename (missing shebang)"
357
+ fi
358
+ fi
359
+
360
+ # Check for conflicts
361
+ if [ -f "$INSTALL_BASE_DIR/$dir/$filename" ]; then
362
+ echo " ${YELLOW}⚠${NC} $filename (will overwrite existing)"
363
+ else
364
+ echo " ${GREEN}✓${NC} $filename"
365
+ fi
366
+
367
+ INSTALLED_COUNT=$((INSTALLED_COUNT + 1))
368
+ done
369
+
370
+ unset -n FILE_LIST
371
+ echo ""
372
+ done
373
+
374
+ # Exit if nothing to install
375
+ if [ $INSTALLED_COUNT -eq 0 ]; then
376
+ echo "${RED}Error: No valid files to install${NC}"
377
+ if [ $SKIPPED_COUNT -gt 0 ]; then
378
+ echo "Skipped $SKIPPED_COUNT file(s) due to validation failures"
379
+ fi
380
+ exit 1
381
+ fi
382
+
383
+ # Confirm installation
384
+ echo "Ready to install $INSTALLED_COUNT file(s)"
385
+ if [ $SKIPPED_COUNT -gt 0 ]; then
386
+ echo "($SKIPPED_COUNT file(s) will be skipped)"
387
+ fi
388
+ echo ""
389
+
390
+ if [ "$SKIP_CONFIRM" = false ]; then
391
+ read -p "Proceed with installation? (y/N) " -n 1 -r
392
+ echo
393
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
394
+ echo "Installation cancelled."
395
+ exit 0
396
+ fi
397
+ else
398
+ echo "Auto-confirming installation (-y flag)"
399
+ fi
400
+
401
+ echo ""
402
+ echo "Installing files..."
403
+
404
+ # Parse package.yaml for experimental checking
405
+ if [ -f "$TEMP_DIR/package.yaml" ]; then
406
+ yaml_parse "$TEMP_DIR/package.yaml"
407
+ fi
408
+
409
+ # Check if file should be installed based on experimental status
410
+ should_install_file() {
411
+ local filename="$1"
412
+ local file_type="$2" # commands, patterns, designs, scripts
413
+
414
+ # If no package.yaml, install everything
415
+ if [ ! -f "$TEMP_DIR/package.yaml" ]; then
416
+ return 0
417
+ fi
418
+
419
+ # Check if file is marked experimental in package.yaml
420
+ local is_experimental=$(grep -A 1000 "^ ${file_type}:" "$TEMP_DIR/package.yaml" 2>/dev/null | grep -A 2 "name: ${filename}" | grep "^ *experimental: true" | grep -v "^[[:space:]]*#" | head -1)
421
+
422
+ if [ -n "$is_experimental" ]; then
423
+ if [ "$INSTALL_EXPERIMENTAL" = true ]; then
424
+ echo " ${YELLOW}⚠${NC} Installing experimental: ${filename}"
425
+ return 0 # Install it
426
+ else
427
+ echo " ${DIM}⊘${NC} Skipping experimental: ${filename} (use --experimental to install)"
428
+ return 1 # Skip it
429
+ fi
430
+ fi
431
+
432
+ return 0 # Install non-experimental files
433
+ }
434
+
435
+ # Add package to manifest
436
+ add_package_to_manifest "$PACKAGE_NAME" "$REPO_URL" "$PACKAGE_VERSION" "$COMMIT_HASH"
437
+
438
+ # Collect installed commands for script dependency resolution
439
+ INSTALLED_COMMANDS=()
440
+
441
+ # Install files (same logic for both global and local)
442
+ for dir in "${INSTALL_DIRS[@]}"; do
443
+ SOURCE_DIR="$TEMP_DIR/agent/$dir"
444
+
445
+ if [ ! -d "$SOURCE_DIR" ]; then
446
+ continue
447
+ fi
448
+
449
+ # Create target directory
450
+ mkdir -p "$INSTALL_BASE_DIR/$dir"
451
+
452
+ # Skip scripts directory in first pass - handle after commands
453
+ if [ "$dir" = "scripts" ]; then
454
+ continue
455
+ fi
456
+
457
+ # Determine which files to install based on selective flags
458
+ declare -n FILE_LIST
459
+ case "$dir" in
460
+ patterns)
461
+ FILE_LIST=PATTERN_FILES
462
+ ;;
463
+ commands)
464
+ FILE_LIST=COMMAND_FILES
465
+ ;;
466
+ design)
467
+ FILE_LIST=DESIGN_FILES
468
+ ;;
469
+ esac
470
+
471
+ # If specific files requested, use those; otherwise find all
472
+ if [ ${#FILE_LIST[@]} -gt 0 ]; then
473
+ # Selective file installation
474
+ FILES_TO_INSTALL=()
475
+ for file_name in "${FILE_LIST[@]}"; do
476
+ # Add appropriate extension if not present
477
+ [[ "$file_name" != *.md ]] && file_name="${file_name}.md"
478
+
479
+ file_path="$SOURCE_DIR/$file_name"
480
+ if [ -f "$file_path" ]; then
481
+ FILES_TO_INSTALL+=("$file_path")
482
+ fi
483
+ done
484
+ else
485
+ # Install all files from directory
486
+ FILES_TO_INSTALL=()
487
+ while IFS= read -r file; do
488
+ [ -n "$file" ] && FILES_TO_INSTALL+=("$file")
489
+ done < <(find "$SOURCE_DIR" -maxdepth 1 -name "*.md" ! -name "*.template.md" -type f)
490
+ fi
491
+
492
+ for file in "${FILES_TO_INSTALL[@]}"; do
493
+ filename=$(basename "$file")
494
+
495
+ # Skip invalid files
496
+ if [ "$dir" = "commands" ]; then
497
+ if [[ "$filename" =~ ^acp\. ]] || ! grep -q "🤖 Agent Directive" "$file"; then
498
+ continue
499
+ fi
500
+ fi
501
+
502
+ # Check if should install based on experimental status
503
+ if ! should_install_file "$filename" "$dir"; then
504
+ continue
505
+ fi
506
+
507
+ # Copy file
508
+ cp "$file" "$INSTALL_BASE_DIR/$dir/$filename"
509
+
510
+ # Get file version from package.yaml
511
+ FILE_VERSION=$(get_file_version "$TEMP_DIR/package.yaml" "$dir" "$filename")
512
+
513
+ # Add file to manifest (pass package.yaml path for experimental tracking)
514
+ add_file_to_manifest "$PACKAGE_NAME" "$dir" "$filename" "$FILE_VERSION" "$INSTALL_BASE_DIR/$dir/$filename" "$TEMP_DIR/package.yaml"
515
+
516
+ echo " ${GREEN}✓${NC} Installed $dir/$filename (v$FILE_VERSION)"
517
+
518
+ # Track installed commands for script dependency resolution
519
+ if [ "$dir" = "commands" ]; then
520
+ INSTALLED_COMMANDS+=("$filename")
521
+ fi
522
+ done
523
+
524
+ unset -n FILE_LIST
525
+ echo ""
526
+ done
527
+
528
+ # Now install scripts based on command dependencies
529
+ if [ -f "$TEMP_DIR/package.yaml" ] && [ ${#INSTALLED_COMMANDS[@]} -gt 0 ]; then
530
+ echo "Resolving script dependencies..."
531
+
532
+ # Collect required scripts from installed commands
533
+ REQUIRED_SCRIPTS=()
534
+ for cmd in "${INSTALLED_COMMANDS[@]}"; do
535
+ # Query scripts array from package.yaml for this command
536
+ cmd_scripts=$(yaml_query ".contents.commands[] | select(.name == \"$cmd\") | .scripts[]?" 2>/dev/null || echo "")
537
+
538
+ # Add each script to required list (with deduplication)
539
+ while IFS= read -r script; do
540
+ if [ -n "$script" ] && [ "$script" != "null" ]; then
541
+ # Check if already in list
542
+ already_added=false
543
+ for existing in "${REQUIRED_SCRIPTS[@]}"; do
544
+ if [ "$existing" = "$script" ]; then
545
+ already_added=true
546
+ break
547
+ fi
548
+ done
549
+
550
+ if [ "$already_added" = false ]; then
551
+ REQUIRED_SCRIPTS+=("$script")
552
+ fi
553
+ fi
554
+ done <<< "$cmd_scripts"
555
+ done
556
+
557
+ # Install required scripts
558
+ if [ ${#REQUIRED_SCRIPTS[@]} -gt 0 ]; then
559
+ echo " Required scripts: ${#REQUIRED_SCRIPTS[@]}"
560
+ echo ""
561
+
562
+ for script in "${REQUIRED_SCRIPTS[@]}"; do
563
+ script_path="$TEMP_DIR/agent/scripts/$script"
564
+
565
+ # Check if script exists
566
+ if [ ! -f "$script_path" ]; then
567
+ echo " ${RED}✗${NC} Script not found: $script (declared in package.yaml)"
568
+ continue
569
+ fi
570
+
571
+ # Check if should install based on experimental status
572
+ if ! should_install_file "$script" "scripts"; then
573
+ continue
574
+ fi
575
+
576
+ # Copy script
577
+ cp "$script_path" "$INSTALL_BASE_DIR/scripts/$script"
578
+ chmod +x "$INSTALL_BASE_DIR/scripts/$script"
579
+
580
+ # Get file version
581
+ FILE_VERSION=$(get_file_version "$TEMP_DIR/package.yaml" "scripts" "$script")
582
+
583
+ # Add to manifest
584
+ add_file_to_manifest "$PACKAGE_NAME" "scripts" "$script" "$FILE_VERSION" "$INSTALL_BASE_DIR/scripts/$script" "$TEMP_DIR/package.yaml"
585
+
586
+ echo " ${GREEN}✓${NC} Installed scripts/$script (v$FILE_VERSION) [executable]"
587
+ done
588
+ echo ""
589
+ else
590
+ echo " ${DIM}No script dependencies${NC}"
591
+ echo ""
592
+ fi
593
+ elif [ -d "$TEMP_DIR/agent/scripts" ]; then
594
+ # No package.yaml or no commands installed - install all scripts (backward compatibility)
595
+ echo "Installing all scripts (no package.yaml or no commands)..."
596
+
597
+ while IFS= read -r script_file; do
598
+ if [ -n "$script_file" ]; then
599
+ filename=$(basename "$script_file")
600
+
601
+ # Skip acp.* scripts (core scripts)
602
+ if [[ "$filename" =~ ^acp\. ]]; then
603
+ continue
604
+ fi
605
+
606
+ # Check experimental status
607
+ if ! should_install_file "$filename" "scripts"; then
608
+ continue
609
+ fi
610
+
611
+ cp "$script_file" "$INSTALL_BASE_DIR/scripts/$filename"
612
+ chmod +x "$INSTALL_BASE_DIR/scripts/$filename"
613
+
614
+ FILE_VERSION=$(get_file_version "$TEMP_DIR/package.yaml" "scripts" "$filename")
615
+ add_file_to_manifest "$PACKAGE_NAME" "scripts" "$filename" "$FILE_VERSION" "$INSTALL_BASE_DIR/scripts/$filename" "$TEMP_DIR/package.yaml"
616
+
617
+ echo " ${GREEN}✓${NC} Installed scripts/$filename (v$FILE_VERSION) [executable]"
618
+ fi
619
+ done < <(find "$TEMP_DIR/agent/scripts" -maxdepth 1 -name "*.sh" ! -name "*.template.sh" -type f)
620
+ echo ""
621
+ fi
622
+
623
+ echo ""
624
+
625
+ # Success message based on installation mode
626
+ if [ "$GLOBAL_INSTALL" = true ]; then
627
+ echo "${GREEN}✅ Package installed globally!${NC}"
628
+ echo ""
629
+ echo "Location: $INSTALL_BASE_DIR"
630
+ echo "Manifest: $MANIFEST_FILE"
631
+ echo ""
632
+ echo "Agents can now discover this package by reading ~/.acp/agent/manifest.yaml"
633
+ echo ""
634
+ echo "To use in any project:"
635
+ echo " 1. Run @acp.init to discover global packages"
636
+ echo " 2. Reference commands via @namespace.command"
637
+ echo ""
638
+ echo "To list global packages: @acp.package-list --global"
639
+ echo ""
640
+ else
641
+ echo "${GREEN}✅ Installation complete!${NC}"
642
+ echo ""
643
+ echo "Installed $INSTALLED_COUNT file(s) from:"
644
+ echo " $REPO_URL"
645
+ echo ""
646
+ echo "Package: $PACKAGE_NAME ($PACKAGE_VERSION)"
647
+ echo "Manifest: agent/manifest.yaml updated"
648
+ echo ""
649
+ fi
650
+
651
+ # List installed commands
652
+ if [ -d "$TEMP_DIR/agent/commands" ]; then
653
+ COMMANDS=$(find "$TEMP_DIR/agent/commands" -maxdepth 1 -name "*.*.md" ! -name "*.template.md" -type f)
654
+ if [ -n "$COMMANDS" ]; then
655
+ echo "Installed commands:"
656
+ while IFS= read -r cmd_file; do
657
+ cmd_name=$(basename "$cmd_file" .md)
658
+ if [[ ! "$cmd_name" =~ ^acp\. ]]; then
659
+ invocation="@${cmd_name}"
660
+ echo " - $invocation"
661
+ fi
662
+ done <<< "$COMMANDS"
663
+ echo ""
664
+ fi
665
+ fi
666
+
667
+ echo "${YELLOW}⚠️ Security Reminder:${NC}"
668
+ echo "Review installed files before using them."
669
+ echo "Third-party files can instruct agents to modify files and execute scripts."
670
+ echo ""
671
+ echo "Next steps:"
672
+ echo " 1. Review installed files in agent/ directories"
673
+ echo " 2. Test installed commands"
674
+ echo " 3. Update progress.yaml with installation notes"
675
+ echo ""