Skip to content

Commit df30851

Browse files
authored
Merge pull request #3 from 302ai/dev
feat: add aliyun image & acp prompt
2 parents d598336 + 0aa7add commit df30851

3 files changed

Lines changed: 121 additions & 5 deletions

File tree

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
.claude
2+
__pycache__
23
.git
4+
.github
5+
.idea
36
.venv
47
app.db*
58
docker-compose.yml
9+
docker-compose.yml*
610

711
.gitignore

.github/workflows/docker-image.yml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ on:
1010
env:
1111
REGISTRY: ghcr.io
1212
IMAGE_NAME: ${{ github.repository }}
13+
# 阿里云镜像仓库地址
14+
ALIYUN_REGISTRY: ${{ secrets.ALIYUN_REGISTRY }}
15+
ALIYUN_IMAGE: ${{ secrets.ALIYUN_REGISTRY }}/${{ secrets.ALIYUN_NAMESPACE }}/local_agent
1316

1417
jobs:
1518
push_to_registry:
16-
name: Push Docker image to GHCR
19+
name: Push Docker image to GHCR and Aliyun
1720
runs-on: ubuntu-latest
1821
permissions:
1922
contents: read
@@ -22,37 +25,61 @@ jobs:
2225
- name: Check out the repo
2326
uses: actions/checkout@v4
2427

28+
# ✅ 登录 GHCR
2529
- name: Log in to GHCR
2630
uses: docker/login-action@v3
2731
with:
2832
registry: ghcr.io
2933
username: ${{ github.actor }}
3034
password: ${{ secrets.GITHUB_TOKEN }}
3135

32-
- name: Extract metadata (tags, labels) for Docker
33-
id: meta
36+
# ✅ 登录阿里云容器镜像服务
37+
- name: Log in to Aliyun Container Registry
38+
uses: docker/login-action@v3
39+
with:
40+
registry: ${{ secrets.ALIYUN_REGISTRY }}
41+
username: ${{ secrets.ALIYUN_USERNAME }}
42+
password: ${{ secrets.ALIYUN_PASSWORD }}
43+
44+
# ✅ 为 GHCR 提取 metadata
45+
- name: Extract metadata for GHCR
46+
id: meta-ghcr
3447
uses: docker/metadata-action@v5
3548
with:
3649
images: ghcr.io/${{ github.repository }}
3750
tags: |
3851
type=ref,event=tag
3952
type=ref,event=branch
4053
54+
# ✅ 为阿里云提取 metadata
55+
- name: Extract metadata for Aliyun
56+
id: meta-aliyun
57+
uses: docker/metadata-action@v5
58+
with:
59+
images: ${{ env.ALIYUN_IMAGE }}
60+
tags: |
61+
type=ref,event=tag
62+
type=ref,event=branch
63+
4164
- name: Set up QEMU
4265
uses: docker/setup-qemu-action@v3
4366

4467
- name: Set up Docker Buildx
4568
uses: docker/setup-buildx-action@v3
4669

70+
# ✅ 同时推送到 GHCR 和阿里云
4771
- name: Build and push Docker image
4872
uses: docker/build-push-action@v5
4973
with:
5074
context: .
5175
file: Dockerfile
5276
platforms: linux/amd64,linux/arm64
5377
push: true
54-
tags: ${{ steps.meta.outputs.tags }}
55-
labels: ${{ steps.meta.outputs.labels }}
78+
# 合并两个仓库的 tags
79+
tags: |
80+
${{ steps.meta-ghcr.outputs.tags }}
81+
${{ steps.meta-aliyun.outputs.tags }}
82+
labels: ${{ steps.meta-ghcr.outputs.labels }}
5683
cache-from: type=gha
5784
cache-to: type=gha,mode=max
5885
shm-size: 2g

app/core/oc_ops.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,91 @@ async def add_my_oc_system_prompt_to_agent_md(
918918
- 即使代码很长,也必须完整展示(可以分段展示,标注"第X部分")
919919
- 这条规则适用于所有代码生成任务
920920
921+
---
922+
923+
### ACPX + Claude Code 工作流
924+
925+
**触发条件**: OpenClaw 收到编程相关任务时
926+
927+
**执行方式**: 通过 `acpx` CLI 调用 Claude Code,而非原生 subagent 或 PTY
928+
929+
#### 会话命名规则
930+
```
931+
acpx-claude-{openclaw_session_id}
932+
```
933+
934+
#### 超时设置
935+
- 默认超时: 600秒 (10分钟)
936+
- 复杂任务: 1200秒 (20分钟) 或更长
937+
938+
#### 输出过滤(只显示给用户的内容)
939+
需要过滤的元信息前缀:
940+
941+
| 前缀 | 含义 | 处理方式 |
942+
|------|------|----------|
943+
| `[client] initialize` | 客户端初始化 | 隐藏 |
944+
| `[tool] ...` | 工具调用日志 | 隐藏 |
945+
| `[thinking] ...` | 思考过程 | 隐藏 |
946+
| `[done] end_turn` | 回复完成 | 隐藏 |
947+
948+
#### 错误处理模板
949+
```bash
950+
${ACPX_CMD} claude exec "任务描述" || echo "❌ 任务执行失败"
951+
```
952+
953+
#### 会话管理(推荐:优先使用持久会话)
954+
955+
**首次创建会话**(每个项目/任务只做一次):
956+
```bash
957+
acpx claude sessions new --name acpx-claude-{session_id}
958+
```
959+
960+
**后续使用持久会话**(保留上下文):
961+
```bash
962+
acpx claude -s acpx-claude-{session_id} "任务描述"
963+
```
964+
965+
**查看会话状态**:
966+
```bash
967+
acpx claude sessions show acpx-claude-{session_id}
968+
```
969+
970+
**关闭会话**:
971+
```bash
972+
acpx claude sessions close acpx-claude-{session_id}
973+
```
974+
975+
#### 一次性执行(仅用于简单、无需上下文的任务)
976+
```bash
977+
acpx claude exec "任务描述"
978+
```
979+
980+
#### 工作目录处理(--cwd)
981+
982+
acpx 支持 `--cwd` 参数指定工作目录。
983+
984+
**⚠️ 重要规则**:如果用户在自然语言任务描述中**明确提及了工作区路径**,必须:
985+
1. 将该路径通过 `--cwd` 参数原样传入
986+
2. **严格使用用户提及的原路径**,禁止传入自以为"正确"的路径
987+
3. 路径优先级:用户明确指定的路径 > 当前 OpenClaw 工作区
988+
989+
**示例**:
990+
```bash
991+
# 用户说:"在 /home/user/projects/myapp 目录下修复 bug"
992+
# ✅ 正确做法:
993+
acpx claude -s acpx-claude-{session_id} --cwd /home/user/projects/myapp "修复 bug"
994+
995+
# ❌ 错误做法(禁止这样做):
996+
# acpx claude -s acpx-claude-{session_id} --cwd /home/user/.openclaw/workspace "修复 bug"
997+
```
998+
999+
#### 二进制路径
1000+
```bash
1001+
ACPX_CMD="acpx" # 已全局安装
1002+
```
1003+
1004+
---
1005+
9211006
## 💓 Heartbeats - Be Proactive!
9221007
9231008
When you receive a heartbeat poll (message matches the configured heartbeat prompt), don't just reply `HEARTBEAT_OK` every time. Use heartbeats productively!

0 commit comments

Comments
 (0)