@prmichaelsen/acp-mcp 0.1.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 (94) hide show
  1. package/.env.example +5 -0
  2. package/AGENT.md +1279 -0
  3. package/README.md +78 -0
  4. package/agent/commands/acp.command-create.md +372 -0
  5. package/agent/commands/acp.design-create.md +224 -0
  6. package/agent/commands/acp.init.md +410 -0
  7. package/agent/commands/acp.package-create.md +894 -0
  8. package/agent/commands/acp.package-info.md +211 -0
  9. package/agent/commands/acp.package-install.md +461 -0
  10. package/agent/commands/acp.package-list.md +279 -0
  11. package/agent/commands/acp.package-publish.md +540 -0
  12. package/agent/commands/acp.package-remove.md +292 -0
  13. package/agent/commands/acp.package-search.md +306 -0
  14. package/agent/commands/acp.package-update.md +310 -0
  15. package/agent/commands/acp.package-validate.md +535 -0
  16. package/agent/commands/acp.pattern-create.md +326 -0
  17. package/agent/commands/acp.plan.md +552 -0
  18. package/agent/commands/acp.proceed.md +336 -0
  19. package/agent/commands/acp.project-create.md +672 -0
  20. package/agent/commands/acp.report.md +394 -0
  21. package/agent/commands/acp.resume.md +237 -0
  22. package/agent/commands/acp.status.md +280 -0
  23. package/agent/commands/acp.sync.md +363 -0
  24. package/agent/commands/acp.task-create.md +390 -0
  25. package/agent/commands/acp.update.md +301 -0
  26. package/agent/commands/acp.validate.md +436 -0
  27. package/agent/commands/acp.version-check-for-updates.md +275 -0
  28. package/agent/commands/acp.version-check.md +190 -0
  29. package/agent/commands/acp.version-update.md +288 -0
  30. package/agent/commands/command.template.md +316 -0
  31. package/agent/commands/git.commit.md +513 -0
  32. package/agent/commands/git.init.md +513 -0
  33. package/agent/commands/mcp-server-starter.add-tool.md +677 -0
  34. package/agent/commands/mcp-server-starter.init.md +894 -0
  35. package/agent/design/.gitkeep +0 -0
  36. package/agent/design/design.template.md +136 -0
  37. package/agent/design/remember-mcp-analysis.md +987 -0
  38. package/agent/design/requirements.template.md +387 -0
  39. package/agent/manifest.template.yaml +13 -0
  40. package/agent/manifest.yaml +109 -0
  41. package/agent/milestones/.gitkeep +0 -0
  42. package/agent/milestones/milestone-1-{title}.template.md +206 -0
  43. package/agent/package.template.yaml +36 -0
  44. package/agent/patterns/.gitkeep +0 -0
  45. package/agent/patterns/bootstrap.template.md +1237 -0
  46. package/agent/patterns/mcp-server-starter.bootstrap.md +597 -0
  47. package/agent/patterns/mcp-server-starter.build-config.md +554 -0
  48. package/agent/patterns/mcp-server-starter.config-management.md +525 -0
  49. package/agent/patterns/mcp-server-starter.server-factory.md +616 -0
  50. package/agent/patterns/mcp-server-starter.server-standalone.md +642 -0
  51. package/agent/patterns/mcp-server-starter.test-config.md +558 -0
  52. package/agent/patterns/mcp-server-starter.tool-creation.md +653 -0
  53. package/agent/patterns/pattern.template.md +364 -0
  54. package/agent/progress.template.yaml +161 -0
  55. package/agent/progress.yaml +33 -0
  56. package/agent/schemas/package.schema.yaml +161 -0
  57. package/agent/scripts/acp.common.sh +1362 -0
  58. package/agent/scripts/acp.install.sh +213 -0
  59. package/agent/scripts/acp.package-create.sh +925 -0
  60. package/agent/scripts/acp.package-info.sh +270 -0
  61. package/agent/scripts/acp.package-install.sh +550 -0
  62. package/agent/scripts/acp.package-list.sh +263 -0
  63. package/agent/scripts/acp.package-publish.sh +420 -0
  64. package/agent/scripts/acp.package-remove.sh +272 -0
  65. package/agent/scripts/acp.package-search.sh +156 -0
  66. package/agent/scripts/acp.package-update.sh +356 -0
  67. package/agent/scripts/acp.package-validate.sh +766 -0
  68. package/agent/scripts/acp.uninstall.sh +85 -0
  69. package/agent/scripts/acp.version-check-for-updates.sh +98 -0
  70. package/agent/scripts/acp.version-check.sh +47 -0
  71. package/agent/scripts/acp.version-update.sh +158 -0
  72. package/agent/scripts/acp.yaml-parser.sh +736 -0
  73. package/agent/scripts/acp.yaml-validate.sh +205 -0
  74. package/agent/tasks/.gitkeep +0 -0
  75. package/agent/tasks/task-1-{title}.template.md +225 -0
  76. package/dist/config.d.ts +4 -0
  77. package/dist/server-factory.d.ts +9 -0
  78. package/dist/server-factory.js +99 -0
  79. package/dist/server-factory.js.map +7 -0
  80. package/dist/server.d.ts +2 -0
  81. package/dist/server.js +106 -0
  82. package/dist/server.js.map +7 -0
  83. package/dist/tools/acp-remote-list-files.d.ts +15 -0
  84. package/dist/types/ssh-config.d.ts +16 -0
  85. package/esbuild.build.js +34 -0
  86. package/esbuild.watch.js +31 -0
  87. package/jest.config.js +31 -0
  88. package/package.json +54 -0
  89. package/src/config.ts +16 -0
  90. package/src/server-factory.ts +43 -0
  91. package/src/server.ts +46 -0
  92. package/src/tools/acp-remote-list-files.ts +89 -0
  93. package/src/types/ssh-config.ts +17 -0
  94. package/tsconfig.json +22 -0
@@ -0,0 +1,263 @@
1
+ #!/bin/bash
2
+
3
+ # Agent Context Protocol (ACP) Package List Script
4
+ # Lists installed ACP packages with their versions and details
5
+
6
+ set -e
7
+
8
+ # Source common utilities
9
+ SCRIPT_DIR="$(dirname "$0")"
10
+ . "${SCRIPT_DIR}/acp.common.sh"
11
+
12
+ # Initialize colors
13
+ init_colors
14
+
15
+ # Parse arguments
16
+ VERBOSE=false
17
+ OUTDATED=false
18
+ MODIFIED=false
19
+ GLOBAL_MODE=false
20
+
21
+ while [[ $# -gt 0 ]]; do
22
+ case $1 in
23
+ --global|-g)
24
+ GLOBAL_MODE=true
25
+ shift
26
+ ;;
27
+ -v|--verbose)
28
+ VERBOSE=true
29
+ shift
30
+ ;;
31
+ --outdated)
32
+ OUTDATED=true
33
+ shift
34
+ ;;
35
+ --modified)
36
+ MODIFIED=true
37
+ shift
38
+ ;;
39
+ *)
40
+ shift
41
+ ;;
42
+ esac
43
+ done
44
+
45
+ # Determine manifest file based on mode
46
+ if [ "$GLOBAL_MODE" = true ]; then
47
+ # Initialize global ACP infrastructure if needed
48
+ init_global_acp || {
49
+ echo "${RED}Error: Failed to initialize global infrastructure${NC}" >&2
50
+ exit 1
51
+ }
52
+
53
+ MANIFEST_FILE="$HOME/.acp/agent/manifest.yaml"
54
+ echo "${BLUE}๐Ÿ“ฆ Global Packages (installed to ~/.acp/agent/):${NC}"
55
+ else
56
+ MANIFEST_FILE="./agent/manifest.yaml"
57
+ echo "${BLUE}๐Ÿ“ฆ Installed ACP Packages${NC}"
58
+ fi
59
+ echo ""
60
+
61
+ # Check if manifest exists
62
+ if [ ! -f "$MANIFEST_FILE" ]; then
63
+ if [ "$GLOBAL_MODE" = true ]; then
64
+ echo "${YELLOW}No global packages installed${NC}"
65
+ echo ""
66
+ echo "To install a package globally:"
67
+ echo " ./agent/scripts/acp.package-install.sh --global <repository-url>"
68
+ else
69
+ echo "${YELLOW}No packages installed${NC}"
70
+ echo ""
71
+ echo "To install a package:"
72
+ echo " ./agent/scripts/acp.package-install.sh <repository-url>"
73
+ fi
74
+ exit 0
75
+ fi
76
+
77
+ # Source YAML parser
78
+ source_yaml_parser
79
+
80
+ # Get list of installed packages
81
+ INSTALLED_PACKAGES=$(awk '/^ [a-z]/ && !/^ / && /:$/ {gsub(/:/, ""); print $1}' "$MANIFEST_FILE")
82
+
83
+ if [ -z "$INSTALLED_PACKAGES" ]; then
84
+ if [ "$GLOBAL_MODE" = true ]; then
85
+ echo "${YELLOW}No global packages installed${NC}"
86
+ else
87
+ echo "${YELLOW}No packages installed${NC}"
88
+ fi
89
+ exit 0
90
+ fi
91
+
92
+ PACKAGE_COUNT=0
93
+ DISPLAYED_COUNT=0
94
+
95
+ for package in $INSTALLED_PACKAGES; do
96
+ PACKAGE_COUNT=$((PACKAGE_COUNT + 1))
97
+
98
+ # Get package info from manifest
99
+ version=$(awk -v pkg="$package" '
100
+ $0 ~ "^ " pkg ":" { in_pkg=1; next }
101
+ in_pkg && /^ [a-z]/ { in_pkg=0 }
102
+ in_pkg && /^ package_version:/ { print $2; exit }
103
+ ' "$MANIFEST_FILE")
104
+
105
+ source_url=$(awk -v pkg="$package" '
106
+ $0 ~ "^ " pkg ":" { in_pkg=1; next }
107
+ in_pkg && /^ [a-z]/ { in_pkg=0 }
108
+ in_pkg && /^ source:/ { print $2; exit }
109
+ ' "$MANIFEST_FILE")
110
+
111
+ installed_at=$(awk -v pkg="$package" '
112
+ $0 ~ "^ " pkg ":" { in_pkg=1; next }
113
+ in_pkg && /^ [a-z]/ { in_pkg=0 }
114
+ in_pkg && /^ installed_at:/ { print $2; exit }
115
+ ' "$MANIFEST_FILE")
116
+
117
+ updated_at=$(awk -v pkg="$package" '
118
+ $0 ~ "^ " pkg ":" { in_pkg=1; next }
119
+ in_pkg && /^ [a-z]/ { in_pkg=0 }
120
+ in_pkg && /^ updated_at:/ { print $2; exit }
121
+ ' "$MANIFEST_FILE")
122
+
123
+ # Count files
124
+ patterns_count=$(awk -v pkg="$package" '
125
+ BEGIN { in_pkg=0; in_patterns=0; count=0 }
126
+ $0 ~ "^ " pkg ":" { in_pkg=1; next }
127
+ in_pkg && /^ [a-z]/ { in_pkg=0 }
128
+ in_pkg && /^ patterns:/ { in_patterns=1; next }
129
+ in_patterns && /^ [a-z]/ { in_patterns=0 }
130
+ in_patterns && /^ - name:/ { count++ }
131
+ END { print count }
132
+ ' "$MANIFEST_FILE")
133
+
134
+ commands_count=$(awk -v pkg="$package" '
135
+ BEGIN { in_pkg=0; in_commands=0; count=0 }
136
+ $0 ~ "^ " pkg ":" { in_pkg=1; next }
137
+ in_pkg && /^ [a-z]/ { in_pkg=0 }
138
+ in_pkg && /^ commands:/ { in_commands=1; next }
139
+ in_commands && /^ [a-z]/ { in_commands=0 }
140
+ in_commands && /^ - name:/ { count++ }
141
+ END { print count }
142
+ ' "$MANIFEST_FILE")
143
+
144
+ designs_count=$(awk -v pkg="$package" '
145
+ BEGIN { in_pkg=0; in_designs=0; count=0 }
146
+ $0 ~ "^ " pkg ":" { in_pkg=1; next }
147
+ in_pkg && /^ [a-z]/ { in_pkg=0 }
148
+ in_pkg && /^ designs:/ { in_designs=1; next }
149
+ in_designs && /^ [a-z]/ { in_designs=0 }
150
+ in_designs && /^ - name:/ { count++ }
151
+ END { print count }
152
+ ' "$MANIFEST_FILE")
153
+
154
+ total_files=$((patterns_count + commands_count + designs_count))
155
+
156
+ # Check if package has updates (for --outdated filter)
157
+ has_updates=false
158
+ if [ "$OUTDATED" = true ]; then
159
+ # Create temp dir for checking
160
+ temp_dir=$(mktemp -d)
161
+ trap "rm -rf $temp_dir" RETURN
162
+
163
+ if git clone --depth 1 "$source_url" "$temp_dir" &>/dev/null 2>&1; then
164
+ if [ -f "$temp_dir/package.yaml" ]; then
165
+ remote_version=$(awk '/^version:/ {print $2; exit}' "$temp_dir/package.yaml")
166
+ comparison=$(compare_versions "$version" "$remote_version")
167
+ if [ "$comparison" = "newer" ]; then
168
+ has_updates=true
169
+ fi
170
+ fi
171
+ fi
172
+
173
+ rm -rf "$temp_dir"
174
+
175
+ # Skip if no updates and filtering for outdated
176
+ if [ "$has_updates" = false ]; then
177
+ continue
178
+ fi
179
+ fi
180
+
181
+ # Check if package has modified files (for --modified filter)
182
+ has_modified=false
183
+ if [ "$MODIFIED" = true ]; then
184
+ for file_type in patterns commands design; do
185
+ files=$(awk -v pkg="$package" -v type="$file_type" '
186
+ BEGIN { in_pkg=0; in_type=0 }
187
+ $0 ~ "^ " pkg ":" { in_pkg=1; next }
188
+ in_pkg && /^ [a-z]/ { in_pkg=0 }
189
+ in_pkg && $0 ~ "^ " type ":" { in_type=1; next }
190
+ in_type && /^ [a-z]/ { in_type=0 }
191
+ in_type && /^ - name:/ { print $3 }
192
+ ' "$MANIFEST_FILE")
193
+
194
+ for file_name in $files; do
195
+ if is_file_modified "$package" "$file_type" "$file_name"; then
196
+ has_modified=true
197
+ break 2
198
+ fi
199
+ done
200
+ done
201
+
202
+ # Skip if no modifications and filtering for modified
203
+ if [ "$has_modified" = false ]; then
204
+ continue
205
+ fi
206
+ fi
207
+ DISPLAYED_COUNT=$((DISPLAYED_COUNT + 1))
208
+
209
+
210
+ # Display package info
211
+ echo "${GREEN}$package${NC} ($version) - $total_files file(s)"
212
+
213
+ if [ "$VERBOSE" = true ]; then
214
+ echo " ${BLUE}Source:${NC} $source_url"
215
+ echo " ${BLUE}Installed:${NC} $installed_at"
216
+ if [ "$installed_at" != "$updated_at" ]; then
217
+ echo " ${BLUE}Updated:${NC} $updated_at"
218
+ fi
219
+ echo " ${BLUE}Files:${NC}"
220
+ [ "$patterns_count" -gt 0 ] && echo " - $patterns_count pattern(s)"
221
+ [ "$commands_count" -gt 0 ] && echo " - $commands_count command(s)"
222
+ [ "$designs_count" -gt 0 ] && echo " - $designs_count design(s)"
223
+
224
+ # Show modified files if any
225
+ if [ "$has_modified" = true ]; then
226
+ echo " ${YELLOW}Modified files:${NC}"
227
+ for file_type in patterns commands design; do
228
+ files=$(awk -v pkg="$package" -v type="$file_type" '
229
+ BEGIN { in_pkg=0; in_type=0 }
230
+ $0 ~ "^ " pkg ":" { in_pkg=1; next }
231
+ in_pkg && /^ [a-z]/ { in_pkg=0 }
232
+ in_pkg && $0 ~ "^ " type ":" { in_type=1; next }
233
+ in_type && /^ [a-z]/ { in_type=0 }
234
+ in_type && /^ - name:/ { print $3 }
235
+ ' "$MANIFEST_FILE")
236
+
237
+ for file_name in $files; do
238
+ if is_file_modified "$package" "$file_type" "$file_name"; then
239
+ echo " - $file_type/$file_name"
240
+ fi
241
+ done
242
+ done
243
+ fi
244
+
245
+ # Show update status if checking outdated
246
+ if [ "$has_updates" = true ]; then
247
+ echo " ${GREEN}Update available${NC}"
248
+ fi
249
+
250
+ echo ""
251
+ fi
252
+ done
253
+
254
+ echo ""
255
+ echo "Total: $DISPLAYED_COUNT of $PACKAGE_COUNT package(s)"
256
+
257
+ if [ "$OUTDATED" = true ] && [ $DISPLAYED_COUNT -eq 0 ]; then
258
+ echo "${GREEN}โœ“${NC} All packages are up to date"
259
+ fi
260
+
261
+ if [ "$MODIFIED" = true ] && [ $DISPLAYED_COUNT -eq 0 ]; then
262
+ echo "${GREEN}โœ“${NC} No packages have local modifications"
263
+ fi
@@ -0,0 +1,420 @@
1
+ #!/bin/bash
2
+ # ACP Package Publishing Script
3
+ # Automated package publishing with validation, versioning, and testing
4
+ # Version: 1.0.0
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
+ # Check if we're in a package directory
17
+ if [ ! -f "package.yaml" ]; then
18
+ echo "${RED}Error: Not a package directory${NC}"
19
+ echo "package.yaml not found. This command must be run from an ACP package directory."
20
+ exit 1
21
+ fi
22
+
23
+ # Extract package info
24
+ PACKAGE_NAME=$(yaml_get "package.yaml" "name" 2>/dev/null || echo "unknown")
25
+ CURRENT_VERSION=$(yaml_get "package.yaml" "version" 2>/dev/null || echo "0.0.0")
26
+ REPO_URL=$(yaml_get "package.yaml" "repository" 2>/dev/null || echo "")
27
+
28
+ echo "${BLUE}๐Ÿš€ ACP Package Publishing${NC}"
29
+ echo "${BLUE}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}"
30
+ echo ""
31
+ echo "${BOLD}Package: ${PACKAGE_NAME} (v${CURRENT_VERSION})${NC}"
32
+ echo ""
33
+
34
+ # Step 1: Validation
35
+ echo "${BLUE}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}"
36
+ echo ""
37
+ echo "${BOLD}๐Ÿ” Step 1: Validation${NC}"
38
+ echo ""
39
+ echo "Running @acp.package-validate..."
40
+ echo ""
41
+
42
+ if ! "${SCRIPT_DIR}/acp.package-validate.sh"; then
43
+ echo ""
44
+ echo "${RED}โŒ Package validation failed${NC}"
45
+ echo ""
46
+ echo "Fix validation errors and run @acp.package-publish again."
47
+ echo "Or use @acp.package-validate to see detailed errors."
48
+ exit 1
49
+ fi
50
+
51
+ echo ""
52
+ echo "${GREEN}โœ… Package validation passed!${NC}"
53
+ echo ""
54
+
55
+ # Step 2: Check working directory
56
+ echo "${BLUE}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}"
57
+ echo ""
58
+ echo "${BOLD}๐Ÿ” Step 2: Git Status${NC}"
59
+ echo ""
60
+
61
+ # Check for uncommitted changes
62
+ if [ -n "$(git status --porcelain)" ]; then
63
+ echo "${YELLOW}โš ๏ธ Uncommitted changes detected${NC}"
64
+ git status --short
65
+ echo ""
66
+ echo "${YELLOW}These changes will be committed as part of the release.${NC}"
67
+ echo ""
68
+ fi
69
+
70
+ # Check current branch
71
+ CURRENT_BRANCH=$(git branch --show-current)
72
+ echo "Current branch: ${BOLD}${CURRENT_BRANCH}${NC}"
73
+
74
+ # Validate branch
75
+ RELEASE_BRANCH=$(yaml_get "package.yaml" "release.branch" 2>/dev/null || echo "main")
76
+ VALID_BRANCHES="main master mainline release ${RELEASE_BRANCH}"
77
+
78
+ if ! echo "$VALID_BRANCHES" | grep -qw "$CURRENT_BRANCH"; then
79
+ echo ""
80
+ echo "${RED}โŒ Not on a valid release branch${NC}"
81
+ echo "Current: $CURRENT_BRANCH"
82
+ echo "Valid: $VALID_BRANCHES"
83
+ echo ""
84
+ echo "Switch to a release branch or configure in package.yaml:"
85
+ echo " release:"
86
+ echo " branch: $CURRENT_BRANCH"
87
+ exit 1
88
+ fi
89
+
90
+ echo "${GREEN}โœ“${NC} On valid release branch"
91
+
92
+ # Show remote
93
+ if [ -n "$REPO_URL" ]; then
94
+ echo "Remote: ${REPO_URL}"
95
+ fi
96
+
97
+ echo ""
98
+
99
+ # Step 3: Check remote status
100
+ echo "${BLUE}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}"
101
+ echo ""
102
+ echo "${BOLD}๐Ÿ” Step 3: Remote Status${NC}"
103
+ echo ""
104
+
105
+ echo "Fetching latest from origin..."
106
+ if git fetch origin >/dev/null 2>&1; then
107
+ echo "${GREEN}โœ“${NC} Fetched latest from origin"
108
+
109
+ # Check if remote is ahead
110
+ COMMITS_BEHIND=$(git rev-list HEAD..origin/${CURRENT_BRANCH} --count 2>/dev/null || echo "0")
111
+ if [ "$COMMITS_BEHIND" -gt 0 ]; then
112
+ echo ""
113
+ echo "${RED}โŒ Remote is ahead of local${NC}"
114
+ echo "Remote has $COMMITS_BEHIND commit(s) not in local."
115
+ echo ""
116
+ echo "Pull latest changes first:"
117
+ echo " git pull"
118
+ exit 1
119
+ fi
120
+
121
+ echo "${GREEN}โœ“${NC} Local is up to date with remote"
122
+ else
123
+ echo "${YELLOW}โš ๏ธ Could not fetch from remote${NC}"
124
+ echo "Continuing anyway (remote may not exist yet)..."
125
+ fi
126
+
127
+ echo ""
128
+
129
+ # Step 4: Analyze commits for version bump
130
+ echo "${BLUE}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}"
131
+ echo ""
132
+ echo "${BOLD}๐Ÿ“Š Step 4: Version Analysis${NC}"
133
+ echo ""
134
+
135
+ # Get last tag
136
+ LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
137
+ if [ -z "$LAST_TAG" ]; then
138
+ echo "No previous tags found. This will be the first release."
139
+ LAST_TAG="HEAD~999" # Get all commits
140
+ COMMIT_COUNT=$(git rev-list HEAD --count)
141
+ else
142
+ echo "Last release: ${LAST_TAG}"
143
+ COMMIT_COUNT=$(git rev-list ${LAST_TAG}..HEAD --count)
144
+ fi
145
+
146
+ echo "Commits since last release: ${COMMIT_COUNT}"
147
+ echo ""
148
+
149
+ if [ "$COMMIT_COUNT" -eq 0 ]; then
150
+ echo "${RED}โŒ No commits since last release${NC}"
151
+ echo "Nothing to publish."
152
+ exit 1
153
+ fi
154
+
155
+ # Analyze commits
156
+ echo "Commit analysis:"
157
+ HAS_BREAKING=false
158
+ HAS_FEAT=false
159
+ HAS_FIX=false
160
+
161
+ while IFS= read -r commit; do
162
+ echo " - $commit"
163
+
164
+ # Check for breaking changes
165
+ if echo "$commit" | grep -qiE "(BREAKING CHANGE|feat!:|fix!:)"; then
166
+ HAS_BREAKING=true
167
+ fi
168
+
169
+ # Check for features
170
+ if echo "$commit" | grep -qE "^feat(\(|:)"; then
171
+ HAS_FEAT=true
172
+ fi
173
+
174
+ # Check for fixes
175
+ if echo "$commit" | grep -qE "^fix(\(|:)"; then
176
+ HAS_FIX=true
177
+ fi
178
+ done < <(git log ${LAST_TAG}..HEAD --oneline)
179
+
180
+ echo ""
181
+
182
+ # Determine version bump
183
+ IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
184
+
185
+ if [ "$HAS_BREAKING" = true ]; then
186
+ NEW_MAJOR=$((MAJOR + 1))
187
+ NEW_MINOR=0
188
+ NEW_PATCH=0
189
+ BUMP_TYPE="major"
190
+ BUMP_REASON="Breaking changes detected"
191
+ elif [ "$HAS_FEAT" = true ]; then
192
+ NEW_MAJOR=$MAJOR
193
+ NEW_MINOR=$((MINOR + 1))
194
+ NEW_PATCH=0
195
+ BUMP_TYPE="minor"
196
+ BUMP_REASON="New features added"
197
+ else
198
+ NEW_MAJOR=$MAJOR
199
+ NEW_MINOR=$MINOR
200
+ NEW_PATCH=$((PATCH + 1))
201
+ BUMP_TYPE="patch"
202
+ BUMP_REASON="Bug fixes or improvements"
203
+ fi
204
+
205
+ NEW_VERSION="${NEW_MAJOR}.${NEW_MINOR}.${NEW_PATCH}"
206
+
207
+ echo "Recommendation: ${BOLD}${NEW_VERSION}${NC} (${BUMP_TYPE})"
208
+ echo "Reason: ${BUMP_REASON}"
209
+ echo ""
210
+
211
+ # Step 5: Confirm version
212
+ echo "${BLUE}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}"
213
+ echo ""
214
+ echo "${BOLD}โ“ Step 5: Confirm Version${NC}"
215
+ echo ""
216
+ echo "Publish as version ${BOLD}${NEW_VERSION}${NC}? (Y/n/custom)"
217
+ read -r response
218
+
219
+ case "$response" in
220
+ n|N|no|No|NO)
221
+ echo "Publishing cancelled."
222
+ exit 0
223
+ ;;
224
+ custom|c|C)
225
+ echo "Enter custom version (X.Y.Z format):"
226
+ read -r NEW_VERSION
227
+ if ! echo "$NEW_VERSION" | grep -qE "^[0-9]+\.[0-9]+\.[0-9]+$"; then
228
+ echo "${RED}Error: Invalid version format${NC}"
229
+ exit 1
230
+ fi
231
+ ;;
232
+ *)
233
+ # Use recommended version
234
+ ;;
235
+ esac
236
+
237
+ echo ""
238
+ echo "${GREEN}โœ“${NC} Publishing version: ${BOLD}${NEW_VERSION}${NC}"
239
+ echo ""
240
+
241
+ # Step 6: Generate CHANGELOG (LLM-based - placeholder for now)
242
+ echo "${BLUE}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}"
243
+ echo ""
244
+ echo "${BOLD}๐Ÿ“ Step 6: CHANGELOG Generation${NC}"
245
+ echo ""
246
+ echo "${YELLOW}Note: CHANGELOG generation requires LLM context.${NC}"
247
+ echo "When run via agent, CHANGELOG will be generated automatically."
248
+ echo "For now, please update CHANGELOG.md manually."
249
+ echo ""
250
+ echo "Press Enter to continue after updating CHANGELOG.md..."
251
+ read -r
252
+
253
+ # Step 7: Update version files
254
+ echo "${BLUE}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}"
255
+ echo ""
256
+ echo "${BOLD}โœ๏ธ Step 7: Updating Version Files${NC}"
257
+ echo ""
258
+
259
+ # Update package.yaml version
260
+ if command -v sed >/dev/null 2>&1; then
261
+ sed -i.bak "s/^version: .*/version: ${NEW_VERSION}/" package.yaml && rm package.yaml.bak
262
+ echo "${GREEN}โœ“${NC} Updated package.yaml (${CURRENT_VERSION} โ†’ ${NEW_VERSION})"
263
+ else
264
+ echo "${YELLOW}โš ๏ธ Please update package.yaml version manually to ${NEW_VERSION}${NC}"
265
+ fi
266
+
267
+ echo ""
268
+
269
+ # Step 8: Commit changes
270
+ echo "${BLUE}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}"
271
+ echo ""
272
+ echo "${BOLD}๐Ÿ’พ Step 8: Committing Changes${NC}"
273
+ echo ""
274
+
275
+ git add package.yaml CHANGELOG.md
276
+ COMMIT_MSG="chore(release): bump version to ${NEW_VERSION}
277
+
278
+ Updated package.yaml and CHANGELOG.md for release.
279
+
280
+ Version: ${NEW_VERSION}"
281
+
282
+ git commit -m "$COMMIT_MSG"
283
+ COMMIT_HASH=$(git rev-parse --short HEAD)
284
+
285
+ echo "${GREEN}โœ“${NC} Committed: chore(release): bump version to ${NEW_VERSION}"
286
+ echo "${GREEN}โœ“${NC} Commit hash: ${COMMIT_HASH}"
287
+ echo ""
288
+
289
+ # Step 9: Create git tag
290
+ echo "${BLUE}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}"
291
+ echo ""
292
+ echo "${BOLD}๐Ÿท๏ธ Step 9: Creating Git Tag${NC}"
293
+ echo ""
294
+
295
+ TAG_NAME="v${NEW_VERSION}"
296
+ TAG_MSG="Release v${NEW_VERSION}"
297
+
298
+ if git tag -a "$TAG_NAME" -m "$TAG_MSG"; then
299
+ echo "${GREEN}โœ“${NC} Created tag: ${TAG_NAME}"
300
+ echo "${GREEN}โœ“${NC} Tag message: ${TAG_MSG}"
301
+ else
302
+ echo "${RED}โŒ Failed to create tag${NC}"
303
+ echo "Tag may already exist. Delete it first if needed:"
304
+ echo " git tag -d ${TAG_NAME}"
305
+ exit 1
306
+ fi
307
+
308
+ echo ""
309
+
310
+ # Step 10: Push to remote
311
+ echo "${BLUE}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}"
312
+ echo ""
313
+ echo "${BOLD}๐Ÿš€ Step 10: Pushing to Remote${NC}"
314
+ echo ""
315
+
316
+ echo "Pushing commits to origin/${CURRENT_BRANCH}..."
317
+ if git push origin "$CURRENT_BRANCH"; then
318
+ echo "${GREEN}โœ“${NC} Pushed commits to origin/${CURRENT_BRANCH}"
319
+ else
320
+ echo "${RED}โŒ Failed to push commits${NC}"
321
+ exit 1
322
+ fi
323
+
324
+ echo "Pushing tag ${TAG_NAME}..."
325
+ if git push origin "$TAG_NAME"; then
326
+ echo "${GREEN}โœ“${NC} Pushed tag ${TAG_NAME}"
327
+ else
328
+ echo "${RED}โŒ Failed to push tag${NC}"
329
+ exit 1
330
+ fi
331
+
332
+ if [ -n "$REPO_URL" ]; then
333
+ echo "Remote: ${REPO_URL}"
334
+ fi
335
+
336
+ echo ""
337
+
338
+ # Step 11: Wait for GitHub
339
+ echo "${BLUE}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}"
340
+ echo ""
341
+ echo "${BOLD}โณ Step 11: Waiting for GitHub${NC}"
342
+ echo ""
343
+ echo "Waiting for GitHub to process push... (10 seconds)"
344
+ sleep 10
345
+ echo "${GREEN}โœ“${NC} Ready to test"
346
+ echo ""
347
+
348
+ # Step 12: Test installation from remote
349
+ echo "${BLUE}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}"
350
+ echo ""
351
+ echo "${BOLD}๐Ÿงช Step 12: Test Installation${NC}"
352
+ echo ""
353
+
354
+ TEST_DIR="/tmp/acp-publish-test-$(date +%s)"
355
+ echo "Creating test directory: ${TEST_DIR}"
356
+ mkdir -p "$TEST_DIR/agent/"{patterns,commands,design}
357
+
358
+ # Create minimal manifest
359
+ cat > "$TEST_DIR/agent/manifest.yaml" << 'EOF'
360
+ packages: {}
361
+ manifest_version: 1.0.0
362
+ last_updated: null
363
+ EOF
364
+
365
+ echo "${GREEN}โœ“${NC} Test directory created"
366
+ echo ""
367
+
368
+ # Get current directory for install script
369
+ CURRENT_DIR=$(pwd)
370
+
371
+ # Try to install from remote
372
+ echo "Installing from remote: ${REPO_URL}"
373
+ cd "$TEST_DIR"
374
+
375
+ if "${CURRENT_DIR}/agent/scripts/acp.package-install.sh" "$REPO_URL" --yes >/dev/null 2>&1; then
376
+ echo "${GREEN}โœ“${NC} Package installed successfully"
377
+
378
+ # Verify installation
379
+ INSTALLED_FILES=$(find agent/ -name "*.md" -not -name "*.template.md" 2>/dev/null | wc -l)
380
+ echo "${GREEN}โœ“${NC} Verified ${INSTALLED_FILES} file(s) copied"
381
+
382
+ # Check manifest
383
+ if grep -q "$PACKAGE_NAME:" agent/manifest.yaml 2>/dev/null; then
384
+ echo "${GREEN}โœ“${NC} Manifest updated correctly"
385
+ fi
386
+ else
387
+ echo "${RED}โŒ Package installation failed${NC}"
388
+ echo ""
389
+ echo "${YELLOW}This may indicate issues with the published package.${NC}"
390
+ echo "Check repository and try installing manually."
391
+ fi
392
+
393
+ # Cleanup
394
+ cd "$CURRENT_DIR"
395
+ rm -rf "$TEST_DIR"
396
+ echo "${GREEN}โœ“${NC} Test directory cleaned up"
397
+ echo ""
398
+
399
+ # Step 13: Final report
400
+ echo "${BLUE}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}"
401
+ echo ""
402
+ echo "${GREEN}${BOLD}โœ… Publishing Complete!${NC}"
403
+ echo ""
404
+ echo "๐Ÿ“ฆ Package: ${BOLD}${PACKAGE_NAME} v${NEW_VERSION}${NC}"
405
+ echo "๐ŸŒ Repository: ${REPO_URL}"
406
+ echo "๐Ÿท๏ธ Tag: ${TAG_NAME}"
407
+ echo "โœ… Test Installation: PASSED"
408
+ echo ""
409
+ echo "${BLUE}โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”${NC}"
410
+ echo ""
411
+ echo "${GREEN}${BOLD}๐ŸŽ‰ Your package is now live!${NC}"
412
+ echo ""
413
+ echo "Users can install it with:"
414
+ echo " ${BOLD}@acp.package-install ${REPO_URL}${NC}"
415
+ echo ""
416
+ echo "Next steps:"
417
+ echo " - Announce release to users"
418
+ echo " - Monitor for issues"
419
+ echo " - Update documentation if needed"
420
+ echo ""