@_xtribe/cli 2.0.3 → 2.0.5

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,761 @@
1
+ ---
2
+ # TRIBE Complete Deployment - Bundled with NPM Package
3
+ # This file is automatically deployed by 'npx @_xtribe/cli'
4
+ #
5
+ # IMPORTANT: This deployment uses PUBLIC Docker Hub images from tribexal/tribe
6
+ # - tribexal/tribe:latest-taskmaster
7
+ # - tribexal/tribe:latest-bridge
8
+ # - tribexal/tribe:latest-claude-agent
9
+ #
10
+ # DO NOT change these to local image names for the npm package!
11
+ # ⚠️ CRITICAL WARNING: DATA PROTECTION ⚠️
12
+ # BEFORE APPLYING THIS MANIFEST:
13
+ # 1. Run: /Users/almorris/TRIBE/0zen/scripts/data-safety-check.sh
14
+ # 2. Check for existing PVCs: kubectl get pvc -n tribe-system
15
+ # 3. NEVER delete PVCs - they contain your data!
16
+ #
17
+ # This manifest will CREATE resources if they don't exist
18
+ # or UPDATE them if they do. PVCs are NEVER deleted.
19
+ ---
20
+ apiVersion: v1
21
+ kind: Namespace
22
+ metadata:
23
+ name: tribe-system
24
+ ---
25
+ # ServiceAccount for Bridge
26
+ apiVersion: v1
27
+ kind: ServiceAccount
28
+ metadata:
29
+ name: bridge
30
+ namespace: tribe-system
31
+ ---
32
+ # Role for Bridge
33
+ apiVersion: rbac.authorization.k8s.io/v1
34
+ kind: Role
35
+ metadata:
36
+ name: bridge-role
37
+ namespace: tribe-system
38
+ rules:
39
+ - apiGroups: [""]
40
+ resources: ["pods", "services", "pods/exec", "pods/log", "configmaps", "secrets", "namespaces"]
41
+ verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
42
+ - apiGroups: ["apps"]
43
+ resources: ["deployments", "replicasets"]
44
+ verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
45
+ - apiGroups: ["batch"]
46
+ resources: ["jobs"]
47
+ verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
48
+ - apiGroups: ["rbac.authorization.k8s.io"]
49
+ resources: ["rolebindings"]
50
+ verbs: ["get", "list", "patch"]
51
+ ---
52
+ # RoleBinding for Bridge
53
+ apiVersion: rbac.authorization.k8s.io/v1
54
+ kind: RoleBinding
55
+ metadata:
56
+ name: bridge-rolebinding
57
+ namespace: tribe-system
58
+ subjects:
59
+ - kind: ServiceAccount
60
+ name: bridge
61
+ namespace: tribe-system
62
+ roleRef:
63
+ kind: Role
64
+ name: bridge-role
65
+ apiGroup: rbac.authorization.k8s.io
66
+ ---
67
+ # PostgreSQL
68
+ apiVersion: apps/v1
69
+ kind: Deployment
70
+ metadata:
71
+ name: postgres
72
+ namespace: tribe-system
73
+ spec:
74
+ replicas: 1
75
+ selector:
76
+ matchLabels:
77
+ app: postgres
78
+ template:
79
+ metadata:
80
+ labels:
81
+ app: postgres
82
+ spec:
83
+ containers:
84
+ - name: postgres
85
+ image: postgres:15
86
+ env:
87
+ - name: POSTGRES_DB
88
+ value: gitea
89
+ - name: POSTGRES_USER
90
+ value: gitea
91
+ - name: POSTGRES_PASSWORD
92
+ value: gitea
93
+ ports:
94
+ - containerPort: 5432
95
+ readinessProbe:
96
+ exec:
97
+ command:
98
+ - pg_isready
99
+ - -U
100
+ - gitea
101
+ initialDelaySeconds: 5
102
+ periodSeconds: 5
103
+ ---
104
+ apiVersion: v1
105
+ kind: Service
106
+ metadata:
107
+ name: postgres
108
+ namespace: tribe-system
109
+ spec:
110
+ selector:
111
+ app: postgres
112
+ ports:
113
+ - port: 5432
114
+ ---
115
+ # Gitea
116
+ apiVersion: apps/v1
117
+ kind: Deployment
118
+ metadata:
119
+ name: gitea
120
+ namespace: tribe-system
121
+ spec:
122
+ replicas: 1
123
+ selector:
124
+ matchLabels:
125
+ app: gitea
126
+ template:
127
+ metadata:
128
+ labels:
129
+ app: gitea
130
+ spec:
131
+ securityContext:
132
+ fsGroup: 1000
133
+ initContainers:
134
+ - name: wait-for-db
135
+ image: busybox:1.35
136
+ command: ['sh', '-c', 'until nc -z postgres 5432; do echo waiting for db; sleep 2; done']
137
+ - name: init-gitea
138
+ image: gitea/gitea:1.20.5
139
+ command: ['/bin/bash', '-c']
140
+ args:
141
+ - |
142
+ # Create app.ini
143
+ mkdir -p /data/gitea/conf
144
+ cat > /data/gitea/conf/app.ini << 'EOF'
145
+ APP_NAME = Gitea
146
+ RUN_MODE = prod
147
+
148
+ [database]
149
+ DB_TYPE = postgres
150
+ HOST = postgres:5432
151
+ NAME = gitea
152
+ USER = gitea
153
+ PASSWD = gitea
154
+
155
+ [server]
156
+ DOMAIN = gitea
157
+ ROOT_URL = http://gitea:3000/
158
+ HTTP_PORT = 3000
159
+
160
+ [service]
161
+ DISABLE_REGISTRATION = true
162
+
163
+ [security]
164
+ INSTALL_LOCK = true
165
+ SECRET_KEY = changeme
166
+
167
+ [oauth2]
168
+ ENABLE = false
169
+
170
+ [service]
171
+ DEFAULT_USER_IS_RESTRICTED = false
172
+
173
+ [repository]
174
+ DEFAULT_PRIVATE = false
175
+ EOF
176
+
177
+ # Fix permissions
178
+ chown -R 1000:1000 /data
179
+ env:
180
+ - name: USER_UID
181
+ value: "1000"
182
+ - name: USER_GID
183
+ value: "1000"
184
+ - name: GITEA_WORK_DIR
185
+ value: /data
186
+ - name: GITEA_CUSTOM
187
+ value: /data/gitea
188
+ volumeMounts:
189
+ - name: gitea-data
190
+ mountPath: /data
191
+ containers:
192
+ - name: gitea
193
+ image: gitea/gitea:1.20.5
194
+ ports:
195
+ - containerPort: 3000
196
+ env:
197
+ - name: USER_UID
198
+ value: "1000"
199
+ - name: USER_GID
200
+ value: "1000"
201
+ - name: GITEA_WORK_DIR
202
+ value: /data
203
+ - name: GITEA_CUSTOM
204
+ value: /data/gitea
205
+ volumeMounts:
206
+ - name: gitea-data
207
+ mountPath: /data
208
+ readinessProbe:
209
+ httpGet:
210
+ path: /
211
+ port: 3000
212
+ initialDelaySeconds: 30
213
+ periodSeconds: 10
214
+ lifecycle:
215
+ postStart:
216
+ exec:
217
+ command:
218
+ - /bin/bash
219
+ - -c
220
+ - |
221
+ sleep 30
222
+ # Create admin user without password change requirement
223
+ su git -c 'gitea admin user create --admin --username gitea_admin --password admin123 --email admin@example.com --must-change-password=false' || true
224
+ volumes:
225
+ - name: gitea-data
226
+ emptyDir: {}
227
+ ---
228
+ apiVersion: v1
229
+ kind: Service
230
+ metadata:
231
+ name: gitea
232
+ namespace: tribe-system
233
+ spec:
234
+ selector:
235
+ app: gitea
236
+ ports:
237
+ - port: 3000
238
+ ---
239
+ # TaskMaster
240
+ apiVersion: apps/v1
241
+ kind: Deployment
242
+ metadata:
243
+ name: taskmaster
244
+ namespace: tribe-system
245
+ spec:
246
+ replicas: 1
247
+ selector:
248
+ matchLabels:
249
+ app: taskmaster
250
+ template:
251
+ metadata:
252
+ labels:
253
+ app: taskmaster
254
+ spec:
255
+ initContainers:
256
+ - name: wait-for-db
257
+ image: busybox:1.35
258
+ command: ['sh', '-c', 'until nc -z postgres 5432; do echo waiting for db; sleep 2; done']
259
+ containers:
260
+ - name: taskmaster
261
+ image: tribexal/tribe:latest-taskmaster
262
+ imagePullPolicy: IfNotPresent
263
+ ports:
264
+ - containerPort: 8080
265
+ resources:
266
+ requests:
267
+ memory: "256Mi"
268
+ cpu: "250m"
269
+ limits:
270
+ memory: "1Gi"
271
+ cpu: "1"
272
+ env:
273
+ - name: FLASK_ENV
274
+ value: development
275
+ - name: DATABASE_URL
276
+ value: postgresql://gitea:gitea@postgres:5432/gitea
277
+ - name: GITEA_URL
278
+ value: http://gitea:3000
279
+ - name: GITEA_TOKEN
280
+ value: will-be-set-by-init-job
281
+ readinessProbe:
282
+ httpGet:
283
+ path: /health
284
+ port: 8080
285
+ initialDelaySeconds: 10
286
+ periodSeconds: 5
287
+ ---
288
+ apiVersion: v1
289
+ kind: Service
290
+ metadata:
291
+ name: taskmaster
292
+ namespace: tribe-system
293
+ spec:
294
+ selector:
295
+ app: taskmaster
296
+ ports:
297
+ - port: 5000
298
+ targetPort: 8080
299
+ ---
300
+ # Bridge
301
+ apiVersion: apps/v1
302
+ kind: Deployment
303
+ metadata:
304
+ name: bridge
305
+ namespace: tribe-system
306
+ spec:
307
+ replicas: 1
308
+ selector:
309
+ matchLabels:
310
+ app: bridge
311
+ template:
312
+ metadata:
313
+ labels:
314
+ app: bridge
315
+ spec:
316
+ serviceAccountName: bridge
317
+ initContainers:
318
+ - name: wait-for-services
319
+ image: busybox:1.35
320
+ command: ['sh', '-c']
321
+ args:
322
+ - |
323
+ echo "Waiting for services..."
324
+ until nc -z taskmaster 8080; do echo waiting for taskmaster; sleep 2; done
325
+ until nc -z gitea 3000; do echo waiting for gitea; sleep 2; done
326
+ echo "All services ready!"
327
+ containers:
328
+ - name: bridge
329
+ image: bridge:latest
330
+ imagePullPolicy: IfNotPresent
331
+ ports:
332
+ - containerPort: 8080
333
+ - containerPort: 3456
334
+ resources:
335
+ requests:
336
+ memory: "256Mi"
337
+ cpu: "250m"
338
+ limits:
339
+ memory: "1Gi"
340
+ cpu: "1"
341
+ env:
342
+ - name: TASKMASTER_URL
343
+ value: http://taskmaster:8080
344
+ - name: GITEA_URL
345
+ value: http://gitea:3000
346
+ - name: GITEA_ADMIN_USER
347
+ value: gitea_admin
348
+ - name: GITEA_ADMIN_PASSWORD
349
+ value: admin123
350
+ - name: GITEA_TOKEN
351
+ valueFrom:
352
+ secretKeyRef:
353
+ name: gitea-token
354
+ key: token
355
+ - name: NAMESPACE
356
+ value: tribe-system
357
+ - name: TARGET_NAMESPACE
358
+ value: tribe-system
359
+ readinessProbe:
360
+ httpGet:
361
+ path: /
362
+ port: 3456
363
+ initialDelaySeconds: 10
364
+ periodSeconds: 5
365
+ ---
366
+ apiVersion: v1
367
+ kind: Service
368
+ metadata:
369
+ name: bridge
370
+ namespace: tribe-system
371
+ spec:
372
+ selector:
373
+ app: bridge
374
+ ports:
375
+ - name: http
376
+ port: 8080
377
+ - name: websocket
378
+ port: 3456
379
+ ---
380
+ # Claude Worker Deployment (starts with 0 replicas)
381
+ apiVersion: apps/v1
382
+ kind: Deployment
383
+ metadata:
384
+ name: claude-worker-deployment
385
+ namespace: tribe-system
386
+ spec:
387
+ replicas: 1 # Start with 1 worker (auto-scaling broken in Docker Hub bridge image)
388
+ selector:
389
+ matchLabels:
390
+ app: claude-worker
391
+ template:
392
+ metadata:
393
+ labels:
394
+ app: claude-worker
395
+ spec:
396
+ containers:
397
+ - name: claude-agent
398
+ image: claude-agent:authenticated
399
+ imagePullPolicy: IfNotPresent
400
+ ports:
401
+ - containerPort: 9090
402
+ name: metrics
403
+ resources:
404
+ requests:
405
+ memory: "512Mi"
406
+ cpu: "500m"
407
+ limits:
408
+ memory: "2Gi"
409
+ cpu: "2"
410
+ env:
411
+ - name: ROLE
412
+ value: worker
413
+ - name: TASKMASTER_URL
414
+ value: http://taskmaster:8080
415
+ - name: GITEA_URL
416
+ value: http://gitea:3000
417
+ - name: GITEA_USER
418
+ value: gitea_admin
419
+ - name: GITEA_PASS
420
+ value: admin123
421
+ - name: GITEA_TOKEN
422
+ valueFrom:
423
+ secretKeyRef:
424
+ name: gitea-token
425
+ key: token
426
+ optional: true
427
+ - name: NAMESPACE
428
+ value: tribe-system
429
+ - name: MCP_CONFIG_PATH
430
+ value: /home/claude/.config/claude-code/mcp.json
431
+ - name: SYSTEM_PROMPT_FILE
432
+ value: /app/minimal-config/worker-prompt.txt
433
+ - name: ANTHROPIC_API_KEY
434
+ valueFrom:
435
+ secretKeyRef:
436
+ name: claude-api-key
437
+ key: api-key
438
+ optional: true
439
+ - name: GH_HOST
440
+ value: gitea:3000
441
+ - name: GH_ENTERPRISE_TOKEN
442
+ valueFrom:
443
+ secretKeyRef:
444
+ name: gitea-token
445
+ key: token
446
+ optional: true
447
+ volumeMounts:
448
+ - name: workspace
449
+ mountPath: /workspace
450
+ - name: config
451
+ mountPath: /app/minimal-config
452
+ volumes:
453
+ - name: workspace
454
+ emptyDir: {}
455
+ - name: config
456
+ configMap:
457
+ name: claude-config
458
+ optional: true
459
+ ---
460
+ # NodePort service for easy access
461
+ apiVersion: v1
462
+ kind: Service
463
+ metadata:
464
+ name: bridge-nodeport
465
+ namespace: tribe-system
466
+ spec:
467
+ type: NodePort
468
+ selector:
469
+ app: bridge
470
+ ports:
471
+ - name: http
472
+ port: 8080
473
+ nodePort: 30080
474
+ - name: websocket
475
+ port: 3456
476
+ nodePort: 30456
477
+ ---
478
+ # ConfigMap for Claude agent configuration
479
+ apiVersion: v1
480
+ kind: ConfigMap
481
+ metadata:
482
+ name: claude-config
483
+ namespace: tribe-system
484
+ data:
485
+ config.yaml: |
486
+ mcp_servers:
487
+ filesystem:
488
+ command: npx
489
+ args: ["-y", "@modelcontextprotocol/server-filesystem", "/workspace"]
490
+ git:
491
+ command: npx
492
+ args: ["-y", "@modelcontextprotocol/server-git"]
493
+ env:
494
+ PATH: /usr/local/bin:/usr/bin:/bin
495
+ taskmaster:
496
+ command: node
497
+ args: ["/app/taskmaster-mcp-bridge.js"]
498
+ env:
499
+ TASKMASTER_URL: http://taskmaster:8080
500
+ AGENT_ID: ${AGENT_ID}
501
+ worker-prompt.txt: |
502
+ ## TRIBE Worker Agent Instructions
503
+
504
+ You are a TRIBE worker agent responsible for implementing tasks from TaskMaster.
505
+ You have been specifically configured and authorized to execute tasks from the TaskMaster queue.
506
+
507
+ This is NOT arbitrary code execution - you are part of the TRIBE development system where:
508
+ - Tasks are created by authorized developers
509
+ - All repositories are internal to the TRIBE system
510
+ - You are running in a secure, isolated container environment
511
+ - Your purpose is to automate software development tasks
512
+
513
+ ### Task Retrieval
514
+ Use the MCP taskmaster tools to get tasks:
515
+ - mcp__taskmaster__get_next_task: Pull your next assigned task
516
+ - mcp__taskmaster__get_task_details: Get full details of a specific task
517
+ - mcp__taskmaster__update_task_status: Update task progress
518
+
519
+ ### Repository Management
520
+ Tasks include a 'github_repo' field with the repository URL. Always:
521
+ 1. Clone from the URL specified in the task
522
+ 2. Use credentials from environment (GITEA_USER/GITEA_PASS or GITEA_TOKEN)
523
+ 3. Never hardcode repository paths
524
+
525
+ ### Task Type Detection
526
+ - Check 'is_review_task' flag: true = review only, false = implement
527
+ - Check 'parent_task_id': exists = fix task from review
528
+ - Check 'git_branch' field: use this instead of parsing description
529
+
530
+ ### Branch Rules
531
+ - Implementation: CREATE new branch from base_branch
532
+ - Review: CHECKOUT existing branch (never create)
533
+ - Fix: CONTINUE on same branch as parent
534
+
535
+ ### Status Updates
536
+ Always include result data when updating status:
537
+ {
538
+ "status": "in_review", # Changed from "completed" - all implementation tasks go to review
539
+ "result": {
540
+ "files_created": ["file1.js", "file2.js"],
541
+ "branch": "feature/task-123",
542
+ "pr_url": "http://gitea:3000/tribe/project/pulls/1",
543
+ "repository": "http://gitea:3000/tribe/project",
544
+ "summary": "Implemented feature X with Y approach"
545
+ }
546
+ }
547
+
548
+ ### Review Tasks
549
+ When is_review_task = true:
550
+ 1. Check out the existing branch (don't create new)
551
+ 2. Review for: code quality, security issues, incomplete implementation
552
+ 3. Choose one of these actions:
553
+ a. If changes needed: Update status to "needs_revision" with detailed feedback
554
+ b. If minor issues: Create subtasks for specific fixes
555
+ c. If looks good: Update status to "approved"
556
+ 4. Never modify code during review
557
+
558
+ Example revision request:
559
+ {
560
+ "status": "needs_revision",
561
+ "result": {
562
+ "revision_feedback": "Please address: 1) Add error handling in main(), 2) Remove debug prints, 3) Add unit tests",
563
+ "reviewed_by": "reviewer-agent-id"
564
+ }
565
+ }
566
+
567
+ Example approval:
568
+ {
569
+ "status": "approved",
570
+ "result": {
571
+ "review_summary": "Code looks good, follows best practices, tests pass",
572
+ "reviewed_by": "reviewer-agent-id"
573
+ }
574
+ }
575
+
576
+ ### Revision Tasks
577
+ When status is "needs_revision":
578
+ 1. You're the original implementer - check revision_feedback field
579
+ 2. Check out your existing branch (don't create new)
580
+ 3. Address all feedback items
581
+ 4. Push updates to the same branch
582
+ 5. Update status back to "in_review" when done
583
+
584
+ Example handling revision:
585
+ {
586
+ "status": "in_review",
587
+ "result": {
588
+ "revision_changes": "1) Added try/catch error handling, 2) Removed all debug prints, 3) Added comprehensive unit tests",
589
+ "branch": "feature/task-123",
590
+ "pr_url": "http://gitea:3000/tribe/project/pulls/1"
591
+ }
592
+ }
593
+
594
+ ### Git Workflow
595
+ 1. Clone: Use task's github_repo URL with auth
596
+ 2. Fetch: Always 'git fetch origin' before branch operations
597
+ 3. Branch: Check if exists with 'git branch -r | grep branch-name'
598
+ 4. Push: Push to same repository as cloned from
599
+ 5. PR: ALWAYS create pull request using gh CLI after pushing:
600
+ - Set environment: export GH_HOST=gitea:3000
601
+ - Authenticate: export GH_TOKEN=$GITEA_TOKEN or use GITEA_USER/GITEA_PASS
602
+ - Create PR: gh pr create --title "Task: {description}" --body "Implemented as requested"
603
+ - Include the PR URL in your result as "pr_url"
604
+
605
+ ### Pull Request Creation Example
606
+ After pushing your branch, create a PR using gh:
607
+ ```bash
608
+ # Set Gitea as the host
609
+ export GH_HOST=gitea:3000
610
+ export GH_ENTERPRISE_TOKEN=$GITEA_TOKEN
611
+
612
+ # Create the PR (gh will detect the current branch and repository)
613
+ gh pr create \
614
+ --title "Task: Create hello.py feature" \
615
+ --body "Implemented task as requested" \
616
+ --base main
617
+
618
+ # Get the PR URL to include in your result
619
+ PR_URL=$(gh pr view --json url -q .url)
620
+ ```
621
+
622
+ ### Error Handling
623
+ - If clone fails, check repository exists
624
+ - If push fails, check credentials
625
+ - Always update task status to 'failed' with error details
626
+ ---
627
+ # Initialization Job
628
+ apiVersion: v1
629
+ kind: ServiceAccount
630
+ metadata:
631
+ name: tribe-init
632
+ namespace: tribe-system
633
+ ---
634
+ apiVersion: rbac.authorization.k8s.io/v1
635
+ kind: Role
636
+ metadata:
637
+ name: tribe-init
638
+ namespace: tribe-system
639
+ rules:
640
+ - apiGroups: [""]
641
+ resources: ["secrets"]
642
+ verbs: ["create", "update", "patch", "get"]
643
+ ---
644
+ apiVersion: rbac.authorization.k8s.io/v1
645
+ kind: RoleBinding
646
+ metadata:
647
+ name: tribe-init
648
+ namespace: tribe-system
649
+ roleRef:
650
+ apiGroup: rbac.authorization.k8s.io
651
+ kind: Role
652
+ name: tribe-init
653
+ subjects:
654
+ - kind: ServiceAccount
655
+ name: tribe-init
656
+ namespace: tribe-system
657
+ ---
658
+ apiVersion: batch/v1
659
+ kind: Job
660
+ metadata:
661
+ name: tribe-init
662
+ namespace: tribe-system
663
+ spec:
664
+ template:
665
+ spec:
666
+ serviceAccountName: tribe-init
667
+ restartPolicy: OnFailure
668
+ containers:
669
+ - name: init
670
+ image: alpine/k8s:1.28.3
671
+ command: ['/bin/sh', '-c']
672
+ args:
673
+ - |
674
+ echo "Waiting for Gitea to be ready..."
675
+ i=1
676
+ while [ $i -le 60 ]; do
677
+ if curl -s http://gitea:3000 > /dev/null 2>&1; then
678
+ echo "Gitea is ready"
679
+ break
680
+ fi
681
+ echo "Waiting for Gitea... ($i/60)"
682
+ sleep 5
683
+ i=$((i + 1))
684
+ done
685
+
686
+ echo "Waiting for user creation..."
687
+ sleep 40
688
+
689
+ echo "Creating Gitea access token..."
690
+ # Create token as gitea_admin since it doesn't have password change requirement
691
+ attempt=1
692
+ while [ $attempt -le 5 ]; do
693
+ echo "Attempt $attempt to create token..."
694
+
695
+ RESPONSE=$(curl -s -X POST http://gitea:3000/api/v1/users/gitea_admin/tokens \
696
+ -u gitea_admin:admin123 \
697
+ -H "Content-Type: application/json" \
698
+ -d '{"name":"bridge-token-'$(date +%s)'","scopes":["write:repository","write:user","write:issue","write:organization","read:repository"]}')
699
+
700
+ echo "API Response: $RESPONSE"
701
+ TOKEN=$(echo "$RESPONSE" | grep -o '"sha1":"[^"]*' | cut -d'"' -f4)
702
+
703
+ if [ ! -z "$TOKEN" ]; then
704
+ echo "Token created successfully: ${TOKEN:0:8}..."
705
+ break
706
+ else
707
+ echo "Failed to create token, waiting..."
708
+ sleep 10
709
+ fi
710
+ attempt=$((attempt + 1))
711
+ done
712
+
713
+ if [ -z "$TOKEN" ]; then
714
+ echo "Failed to create token after 5 attempts!"
715
+ exit 1
716
+ fi
717
+
718
+ # Create secret with the token
719
+ kubectl create secret generic gitea-token \
720
+ --from-literal=token="$TOKEN" \
721
+ --from-literal=user="gitea_admin" \
722
+ --namespace=tribe-system \
723
+ --dry-run=client -o yaml | kubectl apply -f -
724
+
725
+ echo "Secret created successfully"
726
+
727
+ # Create organization
728
+ echo "Creating Tribe organization..."
729
+ ORG_RESPONSE=$(curl -s -X POST http://gitea:3000/api/v1/orgs \
730
+ -H "Authorization: token $TOKEN" \
731
+ -H "Content-Type: application/json" \
732
+ -d '{"username": "tribe", "full_name": "Tribe Organization", "description": "Default organization for Tribe"}')
733
+
734
+ if echo "$ORG_RESPONSE" | grep -q '"id"'; then
735
+ echo "Organization created successfully"
736
+ else
737
+ echo "Organization creation response: $ORG_RESPONSE"
738
+ fi
739
+
740
+ # Create project repository
741
+ echo "Creating project repository..."
742
+ REPO_RESPONSE=$(curl -s -X POST http://gitea:3000/api/v1/orgs/tribe/repos \
743
+ -H "Authorization: token $TOKEN" \
744
+ -H "Content-Type: application/json" \
745
+ -d '{"name": "project", "description": "Default project repository", "private": false, "auto_init": true}')
746
+
747
+ if echo "$REPO_RESPONSE" | grep -q '"id"'; then
748
+ echo "Repository created successfully"
749
+ else
750
+ echo "Repository creation response: $REPO_RESPONSE"
751
+ fi
752
+
753
+ # Also update services that need the token
754
+ echo "Updating services with token..."
755
+
756
+ # Update taskmaster if it has a config endpoint
757
+ curl -X POST http://taskmaster:8080/api/config \
758
+ -H "Content-Type: application/json" \
759
+ -d "{\"gitea_token\":\"$TOKEN\"}" || echo "Taskmaster config update skipped"
760
+
761
+ echo "Initialization complete!"