@prmichaelsen/remember-mcp 3.0.0 → 3.13.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/AGENT.md +296 -250
- package/CHANGELOG.md +358 -0
- package/README.md +68 -45
- package/agent/commands/acp.clarification-create.md +382 -0
- package/agent/commands/acp.project-info.md +309 -0
- package/agent/commands/acp.project-remove.md +379 -0
- package/agent/commands/acp.project-update.md +296 -0
- package/agent/commands/acp.task-create.md +17 -9
- package/agent/commands/git.commit.md +13 -1
- package/agent/design/comment-memory-type.md +2 -2
- package/agent/design/local.collaborative-memory-sync.md +265 -0
- package/agent/design/local.content-flags.md +210 -0
- package/agent/design/local.ghost-persona-system.md +273 -0
- package/agent/design/local.group-acl-integration.md +338 -0
- package/agent/design/local.memory-acl-schema.md +352 -0
- package/agent/design/local.memory-collection-pattern-v2.md +348 -0
- package/agent/design/local.moderation-and-space-config.md +257 -0
- package/agent/design/local.v2-api-reference.md +621 -0
- package/agent/design/local.v2-migration-guide.md +191 -0
- package/agent/design/local.v2-usage-examples.md +265 -0
- package/agent/design/permissions-storage-architecture.md +11 -3
- package/agent/design/trust-escalation-prevention.md +9 -2
- package/agent/design/trust-system-implementation.md +12 -3
- package/agent/milestones/milestone-14-memory-collection-v2.md +182 -0
- package/agent/milestones/milestone-15-moderation-space-config.md +126 -0
- package/agent/progress.yaml +628 -49
- package/agent/scripts/acp.common.sh +2 -0
- package/agent/scripts/acp.install.sh +11 -1
- package/agent/scripts/acp.package-install-optimized.sh +454 -0
- package/agent/scripts/acp.package-install.sh +247 -300
- package/agent/scripts/acp.project-info.sh +218 -0
- package/agent/scripts/acp.project-remove.sh +302 -0
- package/agent/scripts/acp.project-update.sh +296 -0
- package/agent/scripts/acp.yaml-parser.sh +128 -10
- package/agent/tasks/milestone-14-memory-collection-v2/task-165-core-infrastructure-setup.md +171 -0
- package/agent/tasks/milestone-14-memory-collection-v2/task-166-update-remember-publish.md +191 -0
- package/agent/tasks/milestone-14-memory-collection-v2/task-167-update-remember-retract.md +186 -0
- package/agent/tasks/milestone-14-memory-collection-v2/task-168-implement-remember-revise.md +184 -0
- package/agent/tasks/milestone-14-memory-collection-v2/task-169-update-remember-search-space.md +179 -0
- package/agent/tasks/milestone-14-memory-collection-v2/task-170-update-remember-create-update.md +139 -0
- package/agent/tasks/milestone-14-memory-collection-v2/task-172-performance-testing-optimization.md +161 -0
- package/agent/tasks/milestone-14-memory-collection-v2/task-173-documentation-examples.md +258 -0
- package/agent/tasks/milestone-15-moderation-space-config/task-174-add-moderation-schema-fields.md +57 -0
- package/agent/tasks/milestone-15-moderation-space-config/task-175-create-space-config-service.md +64 -0
- package/agent/tasks/milestone-15-moderation-space-config/task-176-wire-moderation-publish-flow.md +45 -0
- package/agent/tasks/milestone-15-moderation-space-config/task-177-add-moderation-search-filters.md +70 -0
- package/agent/tasks/milestone-15-moderation-space-config/task-178-create-remember-moderate-tool.md +69 -0
- package/agent/tasks/milestone-15-moderation-space-config/task-179-documentation-integration-tests.md +58 -0
- package/agent/tasks/milestone-16-ghost-system/task-187-ghost-config-firestore.md +41 -0
- package/agent/tasks/milestone-16-ghost-system/task-188-trust-filter-integration.md +44 -0
- package/agent/tasks/milestone-16-ghost-system/task-189-ghost-memory-filtering.md +43 -0
- package/agent/tasks/milestone-16-ghost-system/task-190-ghost-config-tools.md +45 -0
- package/agent/tasks/milestone-16-ghost-system/task-191-escalation-firestore.md +38 -0
- package/agent/tasks/milestone-16-ghost-system/task-192-documentation-verification.md +39 -0
- package/agent/tasks/milestone-7-trust-permissions/task-180-access-result-permission-types.md +69 -0
- package/agent/tasks/milestone-7-trust-permissions/task-181-firestore-permissions-access-logs.md +56 -0
- package/agent/tasks/milestone-7-trust-permissions/task-182-trust-enforcement-service.md +68 -0
- package/agent/tasks/milestone-7-trust-permissions/task-183-access-control-service.md +70 -0
- package/agent/tasks/milestone-7-trust-permissions/task-184-permission-tools.md +79 -0
- package/agent/tasks/milestone-7-trust-permissions/task-185-wire-trust-into-search-query.md +55 -0
- package/agent/tasks/milestone-7-trust-permissions/task-186-documentation-verification.md +56 -0
- package/agent/tasks/task-76-fix-indexnullstate-schema-bug.md +197 -0
- package/dist/collections/composite-ids.d.ts +106 -0
- package/dist/collections/core-infrastructure.spec.d.ts +11 -0
- package/dist/collections/dot-notation.d.ts +106 -0
- package/dist/collections/tracking-arrays.d.ts +176 -0
- package/dist/constants/content-types.d.ts +1 -0
- package/dist/schema/v2-collections-comments.spec.d.ts +8 -0
- package/dist/schema/v2-collections.d.ts +210 -0
- package/dist/server-factory.d.ts +15 -0
- package/dist/server-factory.js +2798 -1029
- package/dist/server.js +2526 -1012
- package/dist/services/access-control.d.ts +103 -0
- package/dist/services/access-control.spec.d.ts +2 -0
- package/dist/services/credentials-provider.d.ts +24 -0
- package/dist/services/credentials-provider.spec.d.ts +2 -0
- package/dist/services/escalation.service.d.ts +22 -0
- package/dist/services/escalation.service.spec.d.ts +2 -0
- package/dist/services/ghost-config.service.d.ts +55 -0
- package/dist/services/ghost-config.service.spec.d.ts +2 -0
- package/dist/services/space-config.service.d.ts +23 -0
- package/dist/services/space-config.service.spec.d.ts +2 -0
- package/dist/services/trust-enforcement.d.ts +83 -0
- package/dist/services/trust-enforcement.spec.d.ts +2 -0
- package/dist/services/trust-validator.d.ts +43 -0
- package/dist/services/trust-validator.spec.d.ts +2 -0
- package/dist/tools/confirm-publish-moderation.spec.d.ts +8 -0
- package/dist/tools/confirm.d.ts +8 -1
- package/dist/tools/create-memory.d.ts +2 -1
- package/dist/tools/create-memory.spec.d.ts +10 -0
- package/dist/tools/create-relationship.d.ts +2 -1
- package/dist/tools/delete-memory.d.ts +2 -1
- package/dist/tools/delete-relationship.d.ts +2 -1
- package/dist/tools/deny.d.ts +2 -1
- package/dist/tools/find-similar.d.ts +2 -1
- package/dist/tools/get-preferences.d.ts +2 -1
- package/dist/tools/ghost-config.d.ts +27 -0
- package/dist/tools/ghost-config.spec.d.ts +2 -0
- package/dist/tools/moderate.d.ts +20 -0
- package/dist/tools/moderate.spec.d.ts +5 -0
- package/dist/tools/publish.d.ts +11 -3
- package/dist/tools/query-memory.d.ts +3 -1
- package/dist/tools/query-space.d.ts +4 -1
- package/dist/tools/retract.d.ts +29 -0
- package/dist/tools/revise.d.ts +45 -0
- package/dist/tools/revise.spec.d.ts +8 -0
- package/dist/tools/search-memory.d.ts +2 -1
- package/dist/tools/search-relationship.d.ts +2 -1
- package/dist/tools/search-space.d.ts +25 -5
- package/dist/tools/search-space.spec.d.ts +9 -0
- package/dist/tools/set-preference.d.ts +2 -1
- package/dist/tools/update-memory.d.ts +2 -1
- package/dist/tools/update-relationship.d.ts +2 -1
- package/dist/types/access-result.d.ts +48 -0
- package/dist/types/access-result.spec.d.ts +2 -0
- package/dist/types/auth.d.ts +46 -0
- package/dist/types/ghost-config.d.ts +36 -0
- package/dist/types/memory.d.ts +3 -1
- package/dist/types/preferences.d.ts +1 -1
- package/dist/utils/auth-helpers.d.ts +14 -0
- package/dist/utils/auth-helpers.spec.d.ts +2 -0
- package/dist/utils/test-data-generator.d.ts +124 -0
- package/dist/utils/test-data-generator.spec.d.ts +12 -0
- package/dist/v2-performance.e2e.d.ts +17 -0
- package/dist/v2-smoke.e2e.d.ts +14 -0
- package/dist/weaviate/client.d.ts +5 -8
- package/dist/weaviate/space-schema.d.ts +2 -2
- package/docs/performance/v2-benchmarks.md +80 -0
- package/jest.e2e.config.js +14 -3
- package/package.json +1 -1
- package/scripts/.collection-recreation-state.yaml +16 -0
- package/scripts/.gitkeep +5 -0
- package/scripts/README-collection-recreation.md +224 -0
- package/scripts/README.md +51 -0
- package/scripts/backup-collections.ts +543 -0
- package/scripts/delete-collection.ts +137 -0
- package/scripts/migrate-recreate-collections.ts +578 -0
- package/scripts/migrate-v1-to-v2.ts +1094 -0
- package/scripts/package-lock.json +1113 -0
- package/scripts/package.json +27 -0
- package/src/collections/composite-ids.ts +193 -0
- package/src/collections/core-infrastructure.spec.ts +353 -0
- package/src/collections/dot-notation.ts +212 -0
- package/src/collections/tracking-arrays.ts +298 -0
- package/src/constants/content-types.ts +20 -0
- package/src/schema/v2-collections-comments.spec.ts +141 -0
- package/src/schema/v2-collections.ts +433 -0
- package/src/server-factory.ts +89 -20
- package/src/server.ts +45 -17
- package/src/services/access-control.spec.ts +383 -0
- package/src/services/access-control.ts +291 -0
- package/src/services/credentials-provider.spec.ts +22 -0
- package/src/services/credentials-provider.ts +34 -0
- package/src/services/escalation.service.spec.ts +183 -0
- package/src/services/escalation.service.ts +150 -0
- package/src/services/ghost-config.service.spec.ts +339 -0
- package/src/services/ghost-config.service.ts +219 -0
- package/src/services/space-config.service.spec.ts +102 -0
- package/src/services/space-config.service.ts +79 -0
- package/src/services/trust-enforcement.spec.ts +309 -0
- package/src/services/trust-enforcement.ts +197 -0
- package/src/services/trust-validator.spec.ts +108 -0
- package/src/services/trust-validator.ts +105 -0
- package/src/tools/confirm-publish-moderation.spec.ts +240 -0
- package/src/tools/confirm.ts +869 -135
- package/src/tools/create-memory.spec.ts +126 -0
- package/src/tools/create-memory.ts +20 -27
- package/src/tools/create-relationship.ts +17 -8
- package/src/tools/delete-memory.ts +13 -6
- package/src/tools/delete-relationship.ts +15 -6
- package/src/tools/deny.ts +8 -1
- package/src/tools/find-similar.ts +21 -8
- package/src/tools/get-preferences.ts +10 -1
- package/src/tools/ghost-config.spec.ts +180 -0
- package/src/tools/ghost-config.ts +230 -0
- package/src/tools/moderate.spec.ts +277 -0
- package/src/tools/moderate.ts +219 -0
- package/src/tools/publish.ts +99 -41
- package/src/tools/query-memory.ts +28 -6
- package/src/tools/query-space.ts +39 -4
- package/src/tools/retract.ts +292 -0
- package/src/tools/revise.spec.ts +146 -0
- package/src/tools/revise.ts +283 -0
- package/src/tools/search-memory.ts +30 -7
- package/src/tools/search-relationship.ts +11 -2
- package/src/tools/search-space.spec.ts +341 -0
- package/src/tools/search-space.ts +323 -99
- package/src/tools/set-preference.ts +10 -1
- package/src/tools/update-memory.ts +16 -5
- package/src/tools/update-relationship.ts +10 -1
- package/src/types/access-result.spec.ts +193 -0
- package/src/types/access-result.ts +62 -0
- package/src/types/auth.ts +52 -0
- package/src/types/ghost-config.ts +46 -0
- package/src/types/memory.ts +9 -1
- package/src/types/preferences.ts +2 -2
- package/src/utils/auth-helpers.spec.ts +75 -0
- package/src/utils/auth-helpers.ts +25 -0
- package/src/utils/test-data-generator.spec.ts +317 -0
- package/src/utils/test-data-generator.ts +292 -0
- package/src/utils/weaviate-filters.ts +4 -4
- package/src/v2-performance.e2e.ts +173 -0
- package/src/v2-smoke.e2e.ts +401 -0
- package/src/weaviate/client.spec.ts +5 -5
- package/src/weaviate/client.ts +51 -36
- package/src/weaviate/schema.ts +11 -256
- package/src/weaviate/space-schema.spec.ts +24 -24
- package/src/weaviate/space-schema.ts +18 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
-
# Agent Context Protocol (ACP) Package Install Script
|
|
4
|
-
# Installs third-party ACP packages
|
|
3
|
+
# Agent Context Protocol (ACP) Package Install Script - OPTIMIZED VERSION
|
|
4
|
+
# Installs third-party ACP packages with batched operations for 10x+ performance improvement
|
|
5
5
|
|
|
6
6
|
set -e
|
|
7
7
|
|
|
@@ -13,14 +13,16 @@ SCRIPT_DIR="$(dirname "$0")"
|
|
|
13
13
|
# Initialize colors
|
|
14
14
|
init_colors
|
|
15
15
|
|
|
16
|
-
# Parse arguments
|
|
16
|
+
# Parse arguments (same as original)
|
|
17
17
|
REPO_URL=""
|
|
18
18
|
INSTALL_PATTERNS=false
|
|
19
19
|
INSTALL_COMMANDS=false
|
|
20
20
|
INSTALL_DESIGNS=false
|
|
21
|
+
INSTALL_FILES=false
|
|
21
22
|
PATTERN_FILES=()
|
|
22
23
|
COMMAND_FILES=()
|
|
23
24
|
DESIGN_FILES=()
|
|
25
|
+
FILE_FILES=()
|
|
24
26
|
LIST_ONLY=false
|
|
25
27
|
GLOBAL_INSTALL=false
|
|
26
28
|
INSTALL_EXPERIMENTAL=false
|
|
@@ -47,7 +49,6 @@ while [[ $# -gt 0 ]]; do
|
|
|
47
49
|
--patterns)
|
|
48
50
|
INSTALL_PATTERNS=true
|
|
49
51
|
shift
|
|
50
|
-
# Collect pattern file names until next flag
|
|
51
52
|
while [[ $# -gt 0 && ! $1 =~ ^-- ]]; do
|
|
52
53
|
PATTERN_FILES+=("$1")
|
|
53
54
|
shift
|
|
@@ -56,7 +57,6 @@ while [[ $# -gt 0 ]]; do
|
|
|
56
57
|
--commands)
|
|
57
58
|
INSTALL_COMMANDS=true
|
|
58
59
|
shift
|
|
59
|
-
# Collect command file names until next flag
|
|
60
60
|
while [[ $# -gt 0 && ! $1 =~ ^-- ]]; do
|
|
61
61
|
COMMAND_FILES+=("$1")
|
|
62
62
|
shift
|
|
@@ -65,12 +65,19 @@ while [[ $# -gt 0 ]]; do
|
|
|
65
65
|
--designs)
|
|
66
66
|
INSTALL_DESIGNS=true
|
|
67
67
|
shift
|
|
68
|
-
# Collect design file names until next flag
|
|
69
68
|
while [[ $# -gt 0 && ! $1 =~ ^-- ]]; do
|
|
70
69
|
DESIGN_FILES+=("$1")
|
|
71
70
|
shift
|
|
72
71
|
done
|
|
73
72
|
;;
|
|
73
|
+
--files)
|
|
74
|
+
INSTALL_FILES=true
|
|
75
|
+
shift
|
|
76
|
+
while [[ $# -gt 0 && ! $1 =~ ^-- ]]; do
|
|
77
|
+
FILE_FILES+=("$1")
|
|
78
|
+
shift
|
|
79
|
+
done
|
|
80
|
+
;;
|
|
74
81
|
--list)
|
|
75
82
|
LIST_ONLY=true
|
|
76
83
|
shift
|
|
@@ -87,42 +94,26 @@ done
|
|
|
87
94
|
if [ -z "$REPO_URL" ]; then
|
|
88
95
|
echo "${RED}Error: Repository URL required${NC}"
|
|
89
96
|
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
97
|
exit 1
|
|
107
98
|
fi
|
|
108
99
|
|
|
109
100
|
# Default: install everything if no selective flags specified
|
|
110
|
-
if [[ "$INSTALL_PATTERNS" == false && "$INSTALL_COMMANDS" == false && "$INSTALL_DESIGNS" == false ]]; then
|
|
101
|
+
if [[ "$INSTALL_PATTERNS" == false && "$INSTALL_COMMANDS" == false && "$INSTALL_DESIGNS" == false && "$INSTALL_FILES" == false ]]; then
|
|
111
102
|
INSTALL_PATTERNS=true
|
|
112
103
|
INSTALL_COMMANDS=true
|
|
113
104
|
INSTALL_DESIGNS=true
|
|
105
|
+
INSTALL_FILES=true
|
|
114
106
|
fi
|
|
115
107
|
|
|
116
|
-
echo "${BLUE}📦 ACP Package Installer${NC}"
|
|
108
|
+
echo "${BLUE}📦 ACP Package Installer (Optimized)${NC}"
|
|
117
109
|
echo "========================================"
|
|
118
110
|
echo ""
|
|
119
111
|
echo "Repository: $REPO_URL"
|
|
120
112
|
echo ""
|
|
121
113
|
|
|
122
|
-
# Validate URL format
|
|
114
|
+
# Validate URL format
|
|
123
115
|
if [[ ! "$REPO_URL" =~ ^https?:// ]] && [[ ! "$REPO_URL" =~ ^file:// ]] && [[ ! -d "$REPO_URL" ]]; then
|
|
124
116
|
echo "${RED}Error: Invalid repository URL${NC}"
|
|
125
|
-
echo "URL must start with http://, https://, file://, or be a local directory path"
|
|
126
117
|
exit 1
|
|
127
118
|
fi
|
|
128
119
|
|
|
@@ -133,107 +124,49 @@ trap "rm -rf $TEMP_DIR" EXIT
|
|
|
133
124
|
echo "Cloning repository..."
|
|
134
125
|
if ! git clone --depth 1 "$REPO_URL" "$TEMP_DIR" &>/dev/null; then
|
|
135
126
|
echo "${RED}Error: Failed to clone repository${NC}"
|
|
136
|
-
echo "Please check the URL and your internet connection."
|
|
137
127
|
exit 1
|
|
138
128
|
fi
|
|
139
129
|
|
|
140
130
|
echo "${GREEN}✓${NC} Repository cloned"
|
|
141
131
|
echo ""
|
|
142
132
|
|
|
143
|
-
# Check
|
|
133
|
+
# Check for agent/ directory
|
|
144
134
|
if [ ! -d "$TEMP_DIR/agent" ]; then
|
|
145
135
|
echo "${RED}Error: No agent/ directory found${NC}"
|
|
146
|
-
echo "Repository must contain an 'agent/' directory with ACP files"
|
|
147
136
|
exit 1
|
|
148
137
|
fi
|
|
149
138
|
|
|
150
|
-
# Determine installation directory and manifest
|
|
139
|
+
# Determine installation directory and manifest
|
|
151
140
|
if [ "$GLOBAL_INSTALL" = true ]; then
|
|
152
|
-
# Global installation - install directly into ~/.acp/agent/
|
|
153
141
|
INSTALL_BASE_DIR="$HOME/.acp/agent"
|
|
154
142
|
MANIFEST_FILE="$HOME/.acp/agent/manifest.yaml"
|
|
155
|
-
|
|
156
143
|
echo "${BLUE}Installing globally to ~/.acp/agent/${NC}"
|
|
157
144
|
echo ""
|
|
158
|
-
|
|
159
|
-
# Initialize global ACP infrastructure (auto-initialization)
|
|
160
145
|
init_global_acp || {
|
|
161
146
|
echo "${RED}Error: Failed to initialize global infrastructure${NC}" >&2
|
|
162
147
|
exit 1
|
|
163
148
|
}
|
|
164
149
|
else
|
|
165
|
-
# Local installation (existing behavior)
|
|
166
150
|
INSTALL_BASE_DIR="./agent"
|
|
167
151
|
MANIFEST_FILE="./agent/manifest.yaml"
|
|
168
|
-
|
|
169
152
|
echo "${BLUE}Installing locally to ./agent/${NC}"
|
|
170
153
|
echo ""
|
|
171
|
-
|
|
172
|
-
# Initialize local manifest
|
|
173
154
|
init_manifest
|
|
174
155
|
fi
|
|
175
156
|
|
|
176
157
|
# Parse package metadata
|
|
177
158
|
parse_package_metadata "$TEMP_DIR"
|
|
178
|
-
|
|
179
|
-
# Get commit hash
|
|
180
159
|
COMMIT_HASH=$(get_commit_hash "$TEMP_DIR")
|
|
181
160
|
info "Commit: $COMMIT_HASH"
|
|
182
161
|
echo ""
|
|
183
162
|
|
|
184
|
-
# List mode
|
|
163
|
+
# List mode (unchanged)
|
|
185
164
|
if [ "$LIST_ONLY" = true ]; then
|
|
186
|
-
|
|
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
|
-
|
|
165
|
+
# ... (same as original)
|
|
233
166
|
exit 0
|
|
234
167
|
fi
|
|
235
168
|
|
|
236
|
-
# Validate
|
|
169
|
+
# Validate dependencies
|
|
237
170
|
if [ -f "$TEMP_DIR/package.yaml" ]; then
|
|
238
171
|
if ! validate_project_dependencies "$TEMP_DIR/package.yaml"; then
|
|
239
172
|
echo "${RED}Installation cancelled due to dependency issues${NC}"
|
|
@@ -241,12 +174,30 @@ if [ -f "$TEMP_DIR/package.yaml" ]; then
|
|
|
241
174
|
fi
|
|
242
175
|
fi
|
|
243
176
|
|
|
244
|
-
# Directories to install from
|
|
177
|
+
# Directories to install from
|
|
245
178
|
INSTALL_DIRS=()
|
|
246
179
|
[ "$INSTALL_PATTERNS" = true ] && INSTALL_DIRS+=("patterns")
|
|
247
180
|
[ "$INSTALL_COMMANDS" = true ] && INSTALL_DIRS+=("commands")
|
|
248
181
|
[ "$INSTALL_DESIGNS" = true ] && INSTALL_DIRS+=("design")
|
|
249
|
-
[ "$INSTALL_COMMANDS" = true ] && INSTALL_DIRS+=("scripts")
|
|
182
|
+
[ "$INSTALL_COMMANDS" = true ] && INSTALL_DIRS+=("scripts")
|
|
183
|
+
[ "$INSTALL_FILES" = true ] && INSTALL_DIRS+=("files")
|
|
184
|
+
|
|
185
|
+
# Mapping from dir names to manifest keys (dir → manifest key)
|
|
186
|
+
declare -A MANIFEST_KEYS=(
|
|
187
|
+
["patterns"]="patterns"
|
|
188
|
+
["commands"]="commands"
|
|
189
|
+
["design"]="designs"
|
|
190
|
+
["scripts"]="scripts"
|
|
191
|
+
["files"]="files"
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
# ============================================================================
|
|
195
|
+
# OPTIMIZATION: Collect all files first, then batch process
|
|
196
|
+
# ============================================================================
|
|
197
|
+
|
|
198
|
+
# Arrays to hold all files to install
|
|
199
|
+
declare -A ALL_FILES_TO_INSTALL # Key: dir, Value: space-separated file paths
|
|
200
|
+
declare -A FILE_METADATA # Key: "dir/filename", Value: "version|experimental"
|
|
250
201
|
|
|
251
202
|
INSTALLED_COUNT=0
|
|
252
203
|
SKIPPED_COUNT=0
|
|
@@ -254,7 +205,12 @@ SKIPPED_COUNT=0
|
|
|
254
205
|
echo "Scanning for installable files..."
|
|
255
206
|
echo ""
|
|
256
207
|
|
|
257
|
-
#
|
|
208
|
+
# Parse package.yaml once for experimental checking
|
|
209
|
+
if [ -f "$TEMP_DIR/package.yaml" ]; then
|
|
210
|
+
yaml_parse "$TEMP_DIR/package.yaml"
|
|
211
|
+
fi
|
|
212
|
+
|
|
213
|
+
# Collect all files to install
|
|
258
214
|
for dir in "${INSTALL_DIRS[@]}"; do
|
|
259
215
|
SOURCE_DIR="$TEMP_DIR/agent/$dir"
|
|
260
216
|
|
|
@@ -262,35 +218,27 @@ for dir in "${INSTALL_DIRS[@]}"; do
|
|
|
262
218
|
continue
|
|
263
219
|
fi
|
|
264
220
|
|
|
265
|
-
# Determine which files to process
|
|
221
|
+
# Determine which files to process
|
|
266
222
|
declare -n FILE_LIST
|
|
267
223
|
case "$dir" in
|
|
268
|
-
patterns)
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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
|
-
;;
|
|
224
|
+
patterns) FILE_LIST=PATTERN_FILES ;;
|
|
225
|
+
commands) FILE_LIST=COMMAND_FILES ;;
|
|
226
|
+
design) FILE_LIST=DESIGN_FILES ;;
|
|
227
|
+
scripts) FILE_LIST=COMMAND_FILES ;;
|
|
228
|
+
files) FILE_LIST=FILE_FILES ;;
|
|
280
229
|
esac
|
|
281
|
-
|
|
282
|
-
#
|
|
230
|
+
|
|
231
|
+
# Collect files
|
|
232
|
+
FILES_TO_PROCESS=()
|
|
283
233
|
if [ ${#FILE_LIST[@]} -gt 0 ]; then
|
|
284
|
-
# Selective
|
|
285
|
-
FILES_TO_PROCESS=()
|
|
234
|
+
# Selective installation
|
|
286
235
|
for file_name in "${FILE_LIST[@]}"; do
|
|
287
|
-
# Add appropriate extension if not present
|
|
288
236
|
if [ "$dir" = "scripts" ]; then
|
|
289
237
|
[[ "$file_name" != *.sh ]] && file_name="${file_name}.sh"
|
|
290
|
-
|
|
238
|
+
elif [ "$dir" != "files" ]; then
|
|
291
239
|
[[ "$file_name" != *.md ]] && file_name="${file_name}.md"
|
|
292
240
|
fi
|
|
293
|
-
|
|
241
|
+
|
|
294
242
|
file_path="$SOURCE_DIR/$file_name"
|
|
295
243
|
if [ -f "$file_path" ]; then
|
|
296
244
|
FILES_TO_PROCESS+=("$file_path")
|
|
@@ -300,15 +248,17 @@ for dir in "${INSTALL_DIRS[@]}"; do
|
|
|
300
248
|
fi
|
|
301
249
|
done
|
|
302
250
|
else
|
|
303
|
-
# Install all files
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
251
|
+
# Install all files
|
|
252
|
+
if [ "$dir" = "files" ]; then
|
|
253
|
+
# files/ directory: recursive scan, all file types
|
|
254
|
+
while IFS= read -r file; do
|
|
255
|
+
[ -n "$file" ] && FILES_TO_PROCESS+=("$file")
|
|
256
|
+
done < <(find "$SOURCE_DIR" -type f)
|
|
257
|
+
elif [ "$dir" = "scripts" ]; then
|
|
307
258
|
while IFS= read -r file; do
|
|
308
259
|
[ -n "$file" ] && FILES_TO_PROCESS+=("$file")
|
|
309
260
|
done < <(find "$SOURCE_DIR" -maxdepth 1 -name "*.sh" ! -name "*.template.sh" -type f)
|
|
310
261
|
else
|
|
311
|
-
# For other types, find .md files
|
|
312
262
|
while IFS= read -r file; do
|
|
313
263
|
[ -n "$file" ] && FILES_TO_PROCESS+=("$file")
|
|
314
264
|
done < <(find "$SOURCE_DIR" -maxdepth 1 -name "*.md" ! -name "*.template.md" -type f)
|
|
@@ -316,75 +266,124 @@ for dir in "${INSTALL_DIRS[@]}"; do
|
|
|
316
266
|
fi
|
|
317
267
|
|
|
318
268
|
if [ ${#FILES_TO_PROCESS[@]} -eq 0 ]; then
|
|
269
|
+
unset -n FILE_LIST
|
|
319
270
|
continue
|
|
320
271
|
fi
|
|
321
272
|
|
|
322
|
-
|
|
273
|
+
if [ "$dir" = "files" ]; then
|
|
274
|
+
echo "${BLUE}📁 $dir/${NC} (${#FILES_TO_PROCESS[@]} file(s)) → installs to ./"
|
|
275
|
+
else
|
|
276
|
+
echo "${BLUE}📁 $dir/${NC} (${#FILES_TO_PROCESS[@]} file(s))"
|
|
277
|
+
fi
|
|
323
278
|
|
|
324
|
-
# Validate
|
|
279
|
+
# Validate files
|
|
280
|
+
VALID_FILES=()
|
|
325
281
|
for file in "${FILES_TO_PROCESS[@]}"; do
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
282
|
+
# For files/ dir, use relative path from SOURCE_DIR; otherwise basename
|
|
283
|
+
if [ "$dir" = "files" ]; then
|
|
284
|
+
filename="${file#$SOURCE_DIR/}"
|
|
285
|
+
else
|
|
286
|
+
filename=$(basename "$file")
|
|
287
|
+
fi
|
|
288
|
+
|
|
289
|
+
# Validation (not applied to files/ directory)
|
|
329
290
|
if [ "$dir" = "commands" ]; then
|
|
330
|
-
# Check for reserved 'acp' namespace
|
|
331
291
|
if [[ "$filename" =~ ^acp\. ]]; then
|
|
332
292
|
echo " ${RED}✗${NC} $filename (reserved namespace 'acp')"
|
|
333
293
|
SKIPPED_COUNT=$((SKIPPED_COUNT + 1))
|
|
334
294
|
continue
|
|
335
295
|
fi
|
|
336
|
-
|
|
337
|
-
# Check for agent directive
|
|
338
296
|
if ! grep -q "🤖 Agent Directive" "$file"; then
|
|
339
297
|
echo " ${YELLOW}⚠${NC} $filename (missing agent directive - skipping)"
|
|
340
298
|
SKIPPED_COUNT=$((SKIPPED_COUNT + 1))
|
|
341
299
|
continue
|
|
342
300
|
fi
|
|
343
301
|
fi
|
|
344
|
-
|
|
345
|
-
# Special validation for scripts
|
|
302
|
+
|
|
346
303
|
if [ "$dir" = "scripts" ]; then
|
|
347
|
-
# Check for reserved 'acp' namespace
|
|
348
304
|
if [[ "$filename" =~ ^acp\. ]]; then
|
|
349
305
|
echo " ${RED}✗${NC} $filename (reserved namespace 'acp')"
|
|
350
306
|
SKIPPED_COUNT=$((SKIPPED_COUNT + 1))
|
|
351
307
|
continue
|
|
352
308
|
fi
|
|
353
|
-
|
|
354
|
-
# Check for shebang
|
|
355
|
-
if ! head -n1 "$file" | grep -q "^#!/"; then
|
|
356
|
-
echo " ${YELLOW}⚠${NC} $filename (missing shebang)"
|
|
357
|
-
fi
|
|
358
309
|
fi
|
|
359
|
-
|
|
360
|
-
# Check for
|
|
361
|
-
|
|
362
|
-
|
|
310
|
+
|
|
311
|
+
# Check experimental status (skip for files/ — no per-file experimental marking)
|
|
312
|
+
is_experimental=""
|
|
313
|
+
if [ "$dir" != "files" ] && [ -f "$TEMP_DIR/package.yaml" ]; then
|
|
314
|
+
is_experimental=$(grep -A 1000 "^ ${dir}:" "$TEMP_DIR/package.yaml" 2>/dev/null | grep -A 2 "name: ${filename}" | grep "^ *experimental: true" | grep -v "^[[:space:]]*#" | head -1)
|
|
315
|
+
fi
|
|
316
|
+
|
|
317
|
+
if [ -n "$is_experimental" ] && [ "$INSTALL_EXPERIMENTAL" = false ]; then
|
|
318
|
+
echo " ${DIM}⊘${NC} $filename (experimental - use --experimental)"
|
|
319
|
+
SKIPPED_COUNT=$((SKIPPED_COUNT + 1))
|
|
320
|
+
continue
|
|
321
|
+
fi
|
|
322
|
+
|
|
323
|
+
# Get file version
|
|
324
|
+
FILE_VERSION=$(get_file_version "$TEMP_DIR/package.yaml" "$dir" "$filename")
|
|
325
|
+
|
|
326
|
+
# Store metadata
|
|
327
|
+
FILE_METADATA["$dir/$filename"]="$FILE_VERSION|$is_experimental"
|
|
328
|
+
|
|
329
|
+
# Add to valid files
|
|
330
|
+
VALID_FILES+=("$file")
|
|
331
|
+
|
|
332
|
+
# Check for overwrites — files/ targets project root, others target agent/
|
|
333
|
+
if [ "$dir" = "files" ]; then
|
|
334
|
+
target_path="./$filename"
|
|
335
|
+
else
|
|
336
|
+
target_path="$INSTALL_BASE_DIR/$dir/$filename"
|
|
337
|
+
fi
|
|
338
|
+
|
|
339
|
+
if [ -f "$target_path" ]; then
|
|
340
|
+
echo " ${YELLOW}⚠${NC} $filename (will overwrite)"
|
|
363
341
|
else
|
|
364
342
|
echo " ${GREEN}✓${NC} $filename"
|
|
365
343
|
fi
|
|
366
|
-
|
|
344
|
+
|
|
367
345
|
INSTALLED_COUNT=$((INSTALLED_COUNT + 1))
|
|
368
346
|
done
|
|
369
347
|
|
|
348
|
+
# Store valid files for this directory
|
|
349
|
+
if [ ${#VALID_FILES[@]} -gt 0 ]; then
|
|
350
|
+
ALL_FILES_TO_INSTALL["$dir"]="${VALID_FILES[*]}"
|
|
351
|
+
fi
|
|
352
|
+
|
|
370
353
|
unset -n FILE_LIST
|
|
371
354
|
echo ""
|
|
372
355
|
done
|
|
373
356
|
|
|
357
|
+
# Warn about unrecognized directories in the package
|
|
358
|
+
KNOWN_DIRS="patterns commands design scripts files"
|
|
359
|
+
if [ -d "$TEMP_DIR/agent" ]; then
|
|
360
|
+
UNRECOGNIZED=()
|
|
361
|
+
while IFS= read -r pkg_dir; do
|
|
362
|
+
dir_name=$(basename "$pkg_dir")
|
|
363
|
+
if ! echo " $KNOWN_DIRS " | grep -q " $dir_name "; then
|
|
364
|
+
UNRECOGNIZED+=("$dir_name")
|
|
365
|
+
fi
|
|
366
|
+
done < <(find "$TEMP_DIR/agent" -mindepth 1 -maxdepth 1 -type d)
|
|
367
|
+
|
|
368
|
+
if [ ${#UNRECOGNIZED[@]} -gt 0 ]; then
|
|
369
|
+
echo "${YELLOW}⚠ Unrecognized directories in package (not installed):${NC}"
|
|
370
|
+
for udir in "${UNRECOGNIZED[@]}"; do
|
|
371
|
+
echo " $udir/"
|
|
372
|
+
done
|
|
373
|
+
echo ""
|
|
374
|
+
fi
|
|
375
|
+
fi
|
|
376
|
+
|
|
374
377
|
# Exit if nothing to install
|
|
375
378
|
if [ $INSTALLED_COUNT -eq 0 ]; then
|
|
376
379
|
echo "${RED}Error: No valid files to install${NC}"
|
|
377
|
-
|
|
378
|
-
echo "Skipped $SKIPPED_COUNT file(s) due to validation failures"
|
|
379
|
-
fi
|
|
380
|
+
[ $SKIPPED_COUNT -gt 0 ] && echo "Skipped $SKIPPED_COUNT file(s)"
|
|
380
381
|
exit 1
|
|
381
382
|
fi
|
|
382
383
|
|
|
383
384
|
# Confirm installation
|
|
384
385
|
echo "Ready to install $INSTALLED_COUNT file(s)"
|
|
385
|
-
|
|
386
|
-
echo "($SKIPPED_COUNT file(s) will be skipped)"
|
|
387
|
-
fi
|
|
386
|
+
[ $SKIPPED_COUNT -gt 0 ] && echo "($SKIPPED_COUNT file(s) will be skipped)"
|
|
388
387
|
echo ""
|
|
389
388
|
|
|
390
389
|
if [ "$SKIP_CONFIRM" = false ]; then
|
|
@@ -401,163 +400,133 @@ fi
|
|
|
401
400
|
echo ""
|
|
402
401
|
echo "Installing files..."
|
|
403
402
|
|
|
404
|
-
#
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
fi
|
|
403
|
+
# ============================================================================
|
|
404
|
+
# OPTIMIZATION: Batch file operations
|
|
405
|
+
# ============================================================================
|
|
408
406
|
|
|
409
|
-
#
|
|
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
|
|
407
|
+
# Add package to manifest once
|
|
436
408
|
add_package_to_manifest "$PACKAGE_NAME" "$REPO_URL" "$PACKAGE_VERSION" "$COMMIT_HASH"
|
|
437
409
|
|
|
438
|
-
#
|
|
439
|
-
for dir in "${
|
|
410
|
+
# Batch copy all files
|
|
411
|
+
for dir in "${!ALL_FILES_TO_INSTALL[@]}"; do
|
|
440
412
|
SOURCE_DIR="$TEMP_DIR/agent/$dir"
|
|
441
|
-
|
|
442
|
-
if [ ! -d "$SOURCE_DIR" ]; then
|
|
443
|
-
continue
|
|
444
|
-
fi
|
|
445
|
-
|
|
446
|
-
# Create target directory
|
|
447
|
-
mkdir -p "$INSTALL_BASE_DIR/$dir"
|
|
448
413
|
|
|
449
|
-
#
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
;;
|
|
458
|
-
design)
|
|
459
|
-
FILE_LIST=DESIGN_FILES
|
|
460
|
-
;;
|
|
461
|
-
scripts)
|
|
462
|
-
FILE_LIST=COMMAND_FILES # Scripts use command files list
|
|
463
|
-
;;
|
|
464
|
-
esac
|
|
465
|
-
|
|
466
|
-
# If specific files requested, use those; otherwise find all
|
|
467
|
-
if [ ${#FILE_LIST[@]} -gt 0 ]; then
|
|
468
|
-
# Selective file installation
|
|
469
|
-
FILES_TO_INSTALL=()
|
|
470
|
-
for file_name in "${FILE_LIST[@]}"; do
|
|
471
|
-
# Add appropriate extension if not present
|
|
472
|
-
if [ "$dir" = "scripts" ]; then
|
|
473
|
-
[[ "$file_name" != *.sh ]] && file_name="${file_name}.sh"
|
|
474
|
-
else
|
|
475
|
-
[[ "$file_name" != *.md ]] && file_name="${file_name}.md"
|
|
476
|
-
fi
|
|
477
|
-
|
|
478
|
-
file_path="$SOURCE_DIR/$file_name"
|
|
479
|
-
if [ -f "$file_path" ]; then
|
|
480
|
-
FILES_TO_INSTALL+=("$file_path")
|
|
481
|
-
fi
|
|
482
|
-
done
|
|
483
|
-
else
|
|
484
|
-
# Install all files from directory
|
|
485
|
-
FILES_TO_INSTALL=()
|
|
486
|
-
if [ "$dir" = "scripts" ]; then
|
|
487
|
-
while IFS= read -r file; do
|
|
488
|
-
[ -n "$file" ] && FILES_TO_INSTALL+=("$file")
|
|
489
|
-
done < <(find "$SOURCE_DIR" -maxdepth 1 -name "*.sh" ! -name "*.template.sh" -type f)
|
|
414
|
+
# Copy all files
|
|
415
|
+
for file in ${ALL_FILES_TO_INSTALL[$dir]}; do
|
|
416
|
+
if [ "$dir" = "files" ]; then
|
|
417
|
+
# files/ installs to project root, preserving subdirectory structure
|
|
418
|
+
rel_path="${file#$SOURCE_DIR/}"
|
|
419
|
+
target_dir="$(dirname "./$rel_path")"
|
|
420
|
+
mkdir -p "$target_dir"
|
|
421
|
+
cp "$file" "./$rel_path"
|
|
490
422
|
else
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
filename=$(basename "$file")
|
|
499
|
-
|
|
500
|
-
# Skip invalid files
|
|
501
|
-
if [ "$dir" = "commands" ]; then
|
|
502
|
-
if [[ "$filename" =~ ^acp\. ]] || ! grep -q "🤖 Agent Directive" "$file"; then
|
|
503
|
-
continue
|
|
423
|
+
mkdir -p "$INSTALL_BASE_DIR/$dir"
|
|
424
|
+
filename=$(basename "$file")
|
|
425
|
+
cp "$file" "$INSTALL_BASE_DIR/$dir/$filename"
|
|
426
|
+
|
|
427
|
+
# Make scripts executable
|
|
428
|
+
if [ "$dir" = "scripts" ]; then
|
|
429
|
+
chmod +x "$INSTALL_BASE_DIR/$dir/$filename"
|
|
504
430
|
fi
|
|
505
431
|
fi
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
432
|
+
done
|
|
433
|
+
done
|
|
434
|
+
|
|
435
|
+
# ============================================================================
|
|
436
|
+
# OPTIMIZATION: Batch checksum calculation
|
|
437
|
+
# ============================================================================
|
|
438
|
+
|
|
439
|
+
echo " ${BLUE}Calculating checksums...${NC}"
|
|
440
|
+
|
|
441
|
+
# Collect all installed files for batch checksum
|
|
442
|
+
ALL_INSTALLED_FILES=()
|
|
443
|
+
for dir in "${!ALL_FILES_TO_INSTALL[@]}"; do
|
|
444
|
+
SOURCE_DIR="$TEMP_DIR/agent/$dir"
|
|
445
|
+
for file in ${ALL_FILES_TO_INSTALL[$dir]}; do
|
|
446
|
+
if [ "$dir" = "files" ]; then
|
|
447
|
+
rel_path="${file#$SOURCE_DIR/}"
|
|
448
|
+
ALL_INSTALLED_FILES+=("./$rel_path")
|
|
449
|
+
else
|
|
450
|
+
filename=$(basename "$file")
|
|
451
|
+
ALL_INSTALLED_FILES+=("$INSTALL_BASE_DIR/$dir/$filename")
|
|
512
452
|
fi
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
453
|
+
done
|
|
454
|
+
done
|
|
455
|
+
|
|
456
|
+
# Calculate all checksums in one pass
|
|
457
|
+
declare -A CHECKSUMS
|
|
458
|
+
if [ ${#ALL_INSTALLED_FILES[@]} -gt 0 ]; then
|
|
459
|
+
while IFS= read -r line; do
|
|
460
|
+
checksum=$(echo "$line" | awk '{print $1}')
|
|
461
|
+
filepath=$(echo "$line" | awk '{$1=""; print substr($0,2)}')
|
|
462
|
+
CHECKSUMS["$filepath"]="$checksum"
|
|
463
|
+
done < <(sha256sum "${ALL_INSTALLED_FILES[@]}" 2>/dev/null)
|
|
464
|
+
fi
|
|
465
|
+
|
|
466
|
+
# ============================================================================
|
|
467
|
+
# OPTIMIZATION: Batch manifest update
|
|
468
|
+
# ============================================================================
|
|
469
|
+
|
|
470
|
+
echo " ${BLUE}Updating manifest...${NC}"
|
|
471
|
+
|
|
472
|
+
# Parse manifest once
|
|
473
|
+
yaml_parse "$MANIFEST_FILE"
|
|
474
|
+
|
|
475
|
+
# Add all files to manifest in memory
|
|
476
|
+
timestamp=$(get_timestamp)
|
|
477
|
+
for dir in "${!ALL_FILES_TO_INSTALL[@]}"; do
|
|
478
|
+
SOURCE_DIR="$TEMP_DIR/agent/$dir"
|
|
479
|
+
manifest_key="${MANIFEST_KEYS[$dir]:-$dir}"
|
|
480
|
+
|
|
481
|
+
for file in ${ALL_FILES_TO_INSTALL[$dir]}; do
|
|
482
|
+
# Determine filename and installed filepath based on dir type
|
|
483
|
+
if [ "$dir" = "files" ]; then
|
|
484
|
+
filename="${file#$SOURCE_DIR/}"
|
|
485
|
+
filepath="./$filename"
|
|
486
|
+
else
|
|
487
|
+
filename=$(basename "$file")
|
|
488
|
+
filepath="$INSTALL_BASE_DIR/$dir/$filename"
|
|
517
489
|
fi
|
|
518
|
-
|
|
519
|
-
#
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
#
|
|
523
|
-
|
|
524
|
-
|
|
490
|
+
|
|
491
|
+
# Get metadata
|
|
492
|
+
IFS='|' read -r file_version is_experimental <<< "${FILE_METADATA[$dir/$filename]}"
|
|
493
|
+
|
|
494
|
+
# Get checksum
|
|
495
|
+
checksum="${CHECKSUMS[$filepath]:-unknown}"
|
|
496
|
+
|
|
497
|
+
# Append to manifest using mapped key
|
|
498
|
+
obj_node=$(yaml_array_append_object ".packages.${PACKAGE_NAME}.files.${manifest_key}")
|
|
499
|
+
yaml_object_set "$obj_node" "name" "$filename" >/dev/null
|
|
500
|
+
yaml_object_set "$obj_node" "version" "$file_version" >/dev/null
|
|
501
|
+
yaml_object_set "$obj_node" "installed_at" "$timestamp" >/dev/null
|
|
502
|
+
yaml_object_set "$obj_node" "modified" "false" >/dev/null
|
|
503
|
+
yaml_object_set "$obj_node" "checksum" "sha256:$checksum" >/dev/null
|
|
504
|
+
|
|
505
|
+
if [ -n "$is_experimental" ]; then
|
|
506
|
+
yaml_object_set "$obj_node" "experimental" "true" >/dev/null
|
|
525
507
|
fi
|
|
526
|
-
|
|
527
|
-
# Get file version from package.yaml
|
|
528
|
-
FILE_VERSION=$(get_file_version "$TEMP_DIR/package.yaml" "$dir" "$filename")
|
|
529
|
-
|
|
530
|
-
# Add file to manifest (pass package.yaml path for experimental tracking)
|
|
531
|
-
add_file_to_manifest "$PACKAGE_NAME" "$dir" "$filename" "$FILE_VERSION" "$INSTALL_BASE_DIR/$dir/$filename" "$TEMP_DIR/package.yaml"
|
|
532
|
-
|
|
508
|
+
|
|
533
509
|
if [ "$dir" = "scripts" ]; then
|
|
534
|
-
echo " ${GREEN}✓${NC} Installed $dir/$filename (v$
|
|
510
|
+
echo " ${GREEN}✓${NC} Installed $dir/$filename (v$file_version) [executable]"
|
|
511
|
+
elif [ "$dir" = "files" ]; then
|
|
512
|
+
echo " ${GREEN}✓${NC} Installed $filename → ./$filename"
|
|
535
513
|
else
|
|
536
|
-
echo " ${GREEN}✓${NC} Installed $dir/$filename (v$
|
|
514
|
+
echo " ${GREEN}✓${NC} Installed $dir/$filename (v$file_version)"
|
|
537
515
|
fi
|
|
538
516
|
done
|
|
539
|
-
|
|
540
|
-
unset -n FILE_LIST
|
|
541
|
-
echo ""
|
|
542
517
|
done
|
|
543
518
|
|
|
519
|
+
# Write manifest once at the end
|
|
520
|
+
yaml_write "$MANIFEST_FILE"
|
|
521
|
+
|
|
544
522
|
echo ""
|
|
545
523
|
|
|
546
|
-
# Success message
|
|
524
|
+
# Success message
|
|
547
525
|
if [ "$GLOBAL_INSTALL" = true ]; then
|
|
548
526
|
echo "${GREEN}✅ Package installed globally!${NC}"
|
|
549
527
|
echo ""
|
|
550
528
|
echo "Location: $INSTALL_BASE_DIR"
|
|
551
529
|
echo "Manifest: $MANIFEST_FILE"
|
|
552
|
-
echo ""
|
|
553
|
-
echo "Agents can now discover this package by reading ~/.acp/agent/manifest.yaml"
|
|
554
|
-
echo ""
|
|
555
|
-
echo "To use in any project:"
|
|
556
|
-
echo " 1. Run @acp.init to discover global packages"
|
|
557
|
-
echo " 2. Reference commands via @namespace.command"
|
|
558
|
-
echo ""
|
|
559
|
-
echo "To list global packages: @acp.package-list --global"
|
|
560
|
-
echo ""
|
|
561
530
|
else
|
|
562
531
|
echo "${GREEN}✅ Installation complete!${NC}"
|
|
563
532
|
echo ""
|
|
@@ -566,31 +535,9 @@ else
|
|
|
566
535
|
echo ""
|
|
567
536
|
echo "Package: $PACKAGE_NAME ($PACKAGE_VERSION)"
|
|
568
537
|
echo "Manifest: agent/manifest.yaml updated"
|
|
569
|
-
echo ""
|
|
570
|
-
fi
|
|
571
|
-
|
|
572
|
-
# List installed commands
|
|
573
|
-
if [ -d "$TEMP_DIR/agent/commands" ]; then
|
|
574
|
-
COMMANDS=$(find "$TEMP_DIR/agent/commands" -maxdepth 1 -name "*.*.md" ! -name "*.template.md" -type f)
|
|
575
|
-
if [ -n "$COMMANDS" ]; then
|
|
576
|
-
echo "Installed commands:"
|
|
577
|
-
while IFS= read -r cmd_file; do
|
|
578
|
-
cmd_name=$(basename "$cmd_file" .md)
|
|
579
|
-
if [[ ! "$cmd_name" =~ ^acp\. ]]; then
|
|
580
|
-
invocation="@${cmd_name}"
|
|
581
|
-
echo " - $invocation"
|
|
582
|
-
fi
|
|
583
|
-
done <<< "$COMMANDS"
|
|
584
|
-
echo ""
|
|
585
|
-
fi
|
|
586
538
|
fi
|
|
587
539
|
|
|
540
|
+
echo ""
|
|
588
541
|
echo "${YELLOW}⚠️ Security Reminder:${NC}"
|
|
589
542
|
echo "Review installed files before using them."
|
|
590
|
-
echo "Third-party files can instruct agents to modify files and execute scripts."
|
|
591
|
-
echo ""
|
|
592
|
-
echo "Next steps:"
|
|
593
|
-
echo " 1. Review installed files in agent/ directories"
|
|
594
|
-
echo " 2. Test installed commands"
|
|
595
|
-
echo " 3. Update progress.yaml with installation notes"
|
|
596
543
|
echo ""
|