@claude-flow/cli 3.6.21 → 3.6.23

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.
@@ -0,0 +1,57 @@
1
+ #!/bin/bash
2
+ # Publish script for @claude-flow/cli
3
+ # Publishes to both @claude-flow/cli@alpha AND claude-flow@v3alpha
4
+
5
+ set -e
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ CLI_DIR="$(dirname "$SCRIPT_DIR")"
9
+
10
+ cd "$CLI_DIR"
11
+
12
+ # Get current version
13
+ VERSION=$(node -p "require('./package.json').version")
14
+ echo "Publishing version: $VERSION"
15
+
16
+ # 1. Publish @claude-flow/cli with alpha tag
17
+ echo ""
18
+ echo "=== Publishing @claude-flow/cli@$VERSION (alpha tag) ==="
19
+ npm publish --tag alpha
20
+
21
+ # 2. Publish to claude-flow with v3alpha tag
22
+ echo ""
23
+ echo "=== Publishing claude-flow@$VERSION (v3alpha tag) ==="
24
+
25
+ # Create temp directory
26
+ TEMP_DIR=$(mktemp -d)
27
+ trap "rm -rf $TEMP_DIR" EXIT
28
+
29
+ # Copy necessary files
30
+ cp -r dist bin src package.json README.md "$TEMP_DIR/"
31
+
32
+ # Change package name to unscoped
33
+ cd "$TEMP_DIR"
34
+ sed -i 's/"name": "@claude-flow\/cli"/"name": "claude-flow"/' package.json
35
+
36
+ # Publish with v3alpha tag
37
+ npm publish --tag v3alpha
38
+
39
+ echo ""
40
+ echo "=== Updating dist-tags ==="
41
+
42
+ # Update all tags to point to the new version
43
+ npm dist-tag add @claude-flow/cli@$VERSION alpha
44
+ npm dist-tag add @claude-flow/cli@$VERSION latest
45
+ npm dist-tag add @claude-flow/cli@$VERSION v3alpha
46
+ npm dist-tag add claude-flow@$VERSION alpha
47
+ npm dist-tag add claude-flow@$VERSION latest
48
+ npm dist-tag add claude-flow@$VERSION v3alpha
49
+
50
+ echo ""
51
+ echo "=== Published successfully ==="
52
+ echo " @claude-flow/cli@$VERSION (alpha, latest, v3alpha)"
53
+ echo " claude-flow@$VERSION (alpha, latest, v3alpha)"
54
+ echo ""
55
+ echo "Install with:"
56
+ echo " npx claude-flow@alpha"
57
+ echo " npx @claude-flow/cli@latest"
@@ -0,0 +1,366 @@
1
+ # IPFS Plugin Registry Setup Guide
2
+
3
+ This guide walks through setting up a live IPFS plugin registry using Google Cloud and Pinata.
4
+
5
+ ## Prerequisites
6
+
7
+ - Google Cloud account with billing enabled
8
+ - Node.js 20+
9
+ - `gcloud` CLI installed
10
+
11
+ ## Step 1: Pinata Setup (IPFS Pinning Service)
12
+
13
+ ### 1.1 Create Pinata Account
14
+
15
+ 1. Go to https://pinata.cloud and create an account
16
+ 2. Navigate to API Keys section
17
+ 3. Create a new API key with these permissions:
18
+ - `pinning/pinFileToIPFS`: true
19
+ - `pinning/pinJSONToIPFS`: true
20
+ - `pinning/unpin`: true
21
+
22
+ ### 1.2 Save Your Credentials
23
+
24
+ ```bash
25
+ # Add to your shell profile (~/.zshrc or ~/.bashrc)
26
+ export PINATA_JWT="your-jwt-token-here"
27
+ ```
28
+
29
+ ### 1.3 Generate IPNS Key (Optional - for stable addressing)
30
+
31
+ If you have Pinata's paid plan with Dedicated Gateways:
32
+
33
+ ```bash
34
+ # Via Pinata dashboard or API
35
+ curl -X POST "https://api.pinata.cloud/v3/ipfs/keys" \
36
+ -H "Authorization: Bearer $PINATA_JWT" \
37
+ -H "Content-Type: application/json" \
38
+ -d '{"name": "claude-flow-registry"}'
39
+ ```
40
+
41
+ ## Step 2: Google Cloud Setup
42
+
43
+ ### 2.1 Create Project
44
+
45
+ ```bash
46
+ # Create new project
47
+ gcloud projects create claude-flow-registry --name="Claude Flow Registry"
48
+
49
+ # Set as active project
50
+ gcloud config set project claude-flow-registry
51
+
52
+ # Enable billing (required for Cloud Functions)
53
+ gcloud beta billing projects link claude-flow-registry \
54
+ --billing-account=YOUR_BILLING_ACCOUNT_ID
55
+ ```
56
+
57
+ ### 2.2 Enable Required APIs
58
+
59
+ ```bash
60
+ gcloud services enable \
61
+ cloudfunctions.googleapis.com \
62
+ cloudbuild.googleapis.com \
63
+ storage.googleapis.com \
64
+ secretmanager.googleapis.com
65
+ ```
66
+
67
+ ### 2.3 Create Storage Bucket
68
+
69
+ ```bash
70
+ # Create bucket for registry source data
71
+ gcloud storage buckets create gs://claude-flow-plugin-registry \
72
+ --location=US \
73
+ --uniform-bucket-level-access
74
+
75
+ # Enable versioning for rollback
76
+ gsutil versioning set on gs://claude-flow-plugin-registry
77
+
78
+ # Make registry.json publicly readable (optional)
79
+ gsutil iam ch allUsers:objectViewer gs://claude-flow-plugin-registry
80
+ ```
81
+
82
+ ### 2.4 Create Service Account
83
+
84
+ ```bash
85
+ # Create service account
86
+ gcloud iam service-accounts create plugin-registry-publisher \
87
+ --display-name="Plugin Registry Publisher"
88
+
89
+ # Grant permissions
90
+ gcloud projects add-iam-policy-binding claude-flow-registry \
91
+ --member="serviceAccount:plugin-registry-publisher@claude-flow-registry.iam.gserviceaccount.com" \
92
+ --role="roles/storage.objectAdmin"
93
+
94
+ gcloud projects add-iam-policy-binding claude-flow-registry \
95
+ --member="serviceAccount:plugin-registry-publisher@claude-flow-registry.iam.gserviceaccount.com" \
96
+ --role="roles/secretmanager.secretAccessor"
97
+ ```
98
+
99
+ ### 2.5 Store Secrets
100
+
101
+ ```bash
102
+ # Store Pinata JWT
103
+ echo -n "$PINATA_JWT" | gcloud secrets create pinata-jwt --data-file=-
104
+
105
+ # Generate and store Ed25519 signing key
106
+ node -e "
107
+ const crypto = require('crypto');
108
+ const { subtle } = require('crypto').webcrypto;
109
+ (async () => {
110
+ const keyPair = await subtle.generateKey(
111
+ { name: 'Ed25519', namedCurve: 'Ed25519' },
112
+ true,
113
+ ['sign', 'verify']
114
+ );
115
+ const privateKey = await subtle.exportKey('pkcs8', keyPair.privateKey);
116
+ const privateKeyHex = Buffer.from(privateKey).toString('hex');
117
+ console.log(privateKeyHex);
118
+ })();
119
+ " | gcloud secrets create registry-private-key --data-file=-
120
+ ```
121
+
122
+ ## Step 3: Deploy Cloud Function
123
+
124
+ ### 3.1 Create Function Directory
125
+
126
+ ```bash
127
+ mkdir -p cloud-functions/publish-registry
128
+ cd cloud-functions/publish-registry
129
+ ```
130
+
131
+ ### 3.2 Create package.json
132
+
133
+ ```json
134
+ {
135
+ "name": "publish-registry",
136
+ "version": "1.0.0",
137
+ "main": "index.js",
138
+ "type": "module",
139
+ "dependencies": {
140
+ "@google-cloud/storage": "^7.0.0",
141
+ "@google-cloud/secret-manager": "^5.0.0",
142
+ "@noble/ed25519": "^2.0.0"
143
+ }
144
+ }
145
+ ```
146
+
147
+ ### 3.3 Create index.js
148
+
149
+ ```javascript
150
+ import { Storage } from '@google-cloud/storage';
151
+ import { SecretManagerServiceClient } from '@google-cloud/secret-manager';
152
+ import * as ed from '@noble/ed25519';
153
+
154
+ const storage = new Storage();
155
+ const secretManager = new SecretManagerServiceClient();
156
+
157
+ async function getSecret(name) {
158
+ const [version] = await secretManager.accessSecretVersion({
159
+ name: `projects/claude-flow-registry/secrets/${name}/versions/latest`,
160
+ });
161
+ return version.payload.data.toString();
162
+ }
163
+
164
+ export async function publishRegistry(req, res) {
165
+ try {
166
+ // Get secrets
167
+ const pinataJwt = await getSecret('pinata-jwt');
168
+ const privateKey = await getSecret('registry-private-key');
169
+
170
+ // Fetch registry from GCS
171
+ const bucket = storage.bucket('claude-flow-plugin-registry');
172
+ const file = bucket.file('registry.json');
173
+ const [content] = await file.download();
174
+ const registry = JSON.parse(content.toString());
175
+
176
+ // Update timestamp
177
+ registry.updatedAt = new Date().toISOString();
178
+
179
+ // Sign registry
180
+ const registryToSign = { ...registry };
181
+ delete registryToSign.registrySignature;
182
+ delete registryToSign.registryPublicKey;
183
+
184
+ const message = JSON.stringify(registryToSign);
185
+ const signature = await ed.signAsync(
186
+ new TextEncoder().encode(message),
187
+ Buffer.from(privateKey, 'hex')
188
+ );
189
+ const publicKey = await ed.getPublicKeyAsync(Buffer.from(privateKey, 'hex'));
190
+
191
+ registry.registrySignature = Buffer.from(signature).toString('hex');
192
+ registry.registryPublicKey = `ed25519:${Buffer.from(publicKey).toString('hex')}`;
193
+
194
+ // Pin to IPFS
195
+ const pinResponse = await fetch('https://api.pinata.cloud/pinning/pinJSONToIPFS', {
196
+ method: 'POST',
197
+ headers: {
198
+ 'Content-Type': 'application/json',
199
+ 'Authorization': `Bearer ${pinataJwt}`,
200
+ },
201
+ body: JSON.stringify({
202
+ pinataContent: registry,
203
+ pinataMetadata: {
204
+ name: 'claude-flow-plugin-registry',
205
+ keyvalues: {
206
+ version: registry.version,
207
+ updatedAt: registry.updatedAt,
208
+ },
209
+ },
210
+ }),
211
+ });
212
+
213
+ if (!pinResponse.ok) {
214
+ throw new Error(`Pinata error: ${await pinResponse.text()}`);
215
+ }
216
+
217
+ const pinResult = await pinResponse.json();
218
+
219
+ res.json({
220
+ success: true,
221
+ cid: pinResult.IpfsHash,
222
+ updatedAt: registry.updatedAt,
223
+ pluginCount: registry.plugins.length,
224
+ gateways: [
225
+ `https://gateway.pinata.cloud/ipfs/${pinResult.IpfsHash}`,
226
+ `https://ipfs.io/ipfs/${pinResult.IpfsHash}`,
227
+ ],
228
+ });
229
+ } catch (error) {
230
+ console.error('Publish failed:', error);
231
+ res.status(500).json({ error: error.message });
232
+ }
233
+ }
234
+ ```
235
+
236
+ ### 3.4 Deploy Function
237
+
238
+ ```bash
239
+ gcloud functions deploy publish-registry \
240
+ --gen2 \
241
+ --runtime=nodejs20 \
242
+ --region=us-central1 \
243
+ --source=. \
244
+ --entry-point=publishRegistry \
245
+ --trigger-http \
246
+ --allow-unauthenticated \
247
+ --service-account=plugin-registry-publisher@claude-flow-registry.iam.gserviceaccount.com \
248
+ --set-env-vars=GCP_PROJECT=claude-flow-registry
249
+ ```
250
+
251
+ ## Step 4: Create Initial Registry
252
+
253
+ ### 4.1 Upload Registry to GCS
254
+
255
+ ```bash
256
+ # Generate initial registry
257
+ npx tsx scripts/publish-registry.ts --dry-run > registry.json
258
+
259
+ # Upload to GCS
260
+ gsutil cp registry.json gs://claude-flow-plugin-registry/registry.json
261
+ ```
262
+
263
+ ### 4.2 Trigger First Publish
264
+
265
+ ```bash
266
+ # Get function URL
267
+ FUNCTION_URL=$(gcloud functions describe publish-registry \
268
+ --gen2 --region=us-central1 --format='value(serviceConfig.uri)')
269
+
270
+ # Trigger publish
271
+ curl -X POST "$FUNCTION_URL"
272
+ ```
273
+
274
+ ## Step 5: Automate with Cloud Build
275
+
276
+ ### 5.1 Create cloudbuild.yaml
277
+
278
+ ```yaml
279
+ steps:
280
+ # Update registry from npm stats
281
+ - name: 'node:20'
282
+ entrypoint: 'npx'
283
+ args: ['tsx', 'scripts/publish-registry.ts', '--dry-run']
284
+ dir: 'v3/@claude-flow/cli'
285
+
286
+ # Upload to GCS
287
+ - name: 'gcr.io/cloud-builders/gsutil'
288
+ args: ['cp', 'registry.json', 'gs://claude-flow-plugin-registry/registry.json']
289
+
290
+ # Trigger Cloud Function
291
+ - name: 'gcr.io/cloud-builders/curl'
292
+ args: ['-X', 'POST', '${_FUNCTION_URL}']
293
+
294
+ substitutions:
295
+ _FUNCTION_URL: 'https://us-central1-claude-flow-registry.cloudfunctions.net/publish-registry'
296
+
297
+ # Run daily at 2am UTC
298
+ options:
299
+ logging: CLOUD_LOGGING_ONLY
300
+ ```
301
+
302
+ ### 5.2 Create Cloud Scheduler Trigger
303
+
304
+ ```bash
305
+ gcloud scheduler jobs create http publish-registry-daily \
306
+ --location=us-central1 \
307
+ --schedule="0 2 * * *" \
308
+ --uri="https://us-central1-claude-flow-registry.cloudfunctions.net/publish-registry" \
309
+ --http-method=POST
310
+ ```
311
+
312
+ ## Step 6: Update Claude Flow CLI
313
+
314
+ Update `DEFAULT_PLUGIN_STORE_CONFIG` in `discovery.ts`:
315
+
316
+ ```typescript
317
+ export const DEFAULT_PLUGIN_STORE_CONFIG: PluginStoreConfig = {
318
+ registries: [
319
+ {
320
+ name: 'claude-flow-official',
321
+ description: 'Official Claude Flow plugin registry',
322
+ // Use the CID from your first publish
323
+ ipnsName: 'YOUR_IPNS_KEY_OR_CID',
324
+ gateway: 'https://gateway.pinata.cloud',
325
+ // Use your public key from the signing step
326
+ publicKey: 'ed25519:YOUR_PUBLIC_KEY',
327
+ trusted: true,
328
+ official: true,
329
+ },
330
+ ],
331
+ // ... rest of config
332
+ };
333
+ ```
334
+
335
+ ## Cost Estimate
336
+
337
+ | Service | Free Tier | Paid Tier |
338
+ |---------|-----------|-----------|
339
+ | Pinata | 1GB storage, 100 pins | $20/mo for 100GB |
340
+ | GCS | 5GB free | ~$0.02/GB/mo |
341
+ | Cloud Functions | 2M invocations free | ~$0.40/million |
342
+ | Cloud Scheduler | 3 jobs free | $0.10/job/mo |
343
+ | **Total** | **$0** | **~$20/mo** |
344
+
345
+ ## Troubleshooting
346
+
347
+ ### IPNS Resolution Fails
348
+ - Ensure the CID is pinned on Pinata
349
+ - Try different gateways (ipfs.io, cloudflare-ipfs.com)
350
+ - IPNS can take 5-10 minutes to propagate
351
+
352
+ ### Signature Verification Fails
353
+ - Ensure the public key in config matches the signing key
354
+ - Check that the registry wasn't modified after signing
355
+
356
+ ### Cloud Function Errors
357
+ - Check Cloud Logging for detailed errors
358
+ - Verify service account has correct permissions
359
+ - Test secrets access manually
360
+
361
+ ## References
362
+
363
+ - [Pinata Docs](https://docs.pinata.cloud/)
364
+ - [Google Cloud Functions](https://cloud.google.com/functions/docs)
365
+ - [IPFS Gateway Spec](https://docs.ipfs.tech/concepts/ipfs-gateway/)
366
+ - [Ed25519 Signatures](https://ed25519.cr.yp.to/)