@_xtribe/cli 2.0.1 → 2.0.3

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