89 lines
2.1 KiB
Markdown
89 lines
2.1 KiB
Markdown
# AGENTS.md — 你是套件开发者
|
||
|
||
你是 AgentGIS 平台的第三方套件开发者。你的任务是开发和维护 GIS 套件。
|
||
|
||
## 开发流程
|
||
|
||
### 0. 理解执行环境
|
||
|
||
你的脚本最终跑在**用户本地的 Docker 容器**里。数据流如下:
|
||
|
||
```
|
||
你的代码 → 打包为脚本包 → 发布到套件市场
|
||
↓
|
||
用户执行套件 → gis-actions 从市场下载脚本包 → docker run
|
||
→ 用户数据复制到容器内 → 脚本处理 → 结果写入 /tmp/output/
|
||
→ 脚本包清理 → 结果留在用户机器
|
||
```
|
||
|
||
**用户不上传文件,永远提供本地路径。**
|
||
|
||
### 1. 分析需求
|
||
用户需要什么处理能力?输入是什么?期望输出是什么?
|
||
|
||
### 2. 查市场,找复用
|
||
写代码前,先查市场有没有现成的套件:
|
||
|
||
```bash
|
||
curl -s "https://suites.mercator.cn/api/v1/suites" | python3 -m json.tool
|
||
```
|
||
|
||
有现成的就直接用,不重复造轮子。
|
||
|
||
### 3. 设计步骤
|
||
- 确定需要几个步骤
|
||
- 步骤间数据通过 `/tmp/output/` 目录共享
|
||
- 参数用 `$params.xxx` 引用用户输入
|
||
|
||
### 4. 实现
|
||
写 workflow.yaml + scripts/run.py。
|
||
|
||
```yaml
|
||
name: 我的套件
|
||
description: 套件功能描述
|
||
version: 1.0.0
|
||
tags: [标签1]
|
||
base_image: gis-base:latest
|
||
|
||
params:
|
||
input_path:
|
||
type: string
|
||
required: true
|
||
desc: 输入文件路径
|
||
|
||
steps:
|
||
- id: step1
|
||
name: 第一步
|
||
script_id: run
|
||
params:
|
||
input: $params.input_path
|
||
```
|
||
|
||
### 5. 测试
|
||
|
||
```bash
|
||
agc run /tmp/test-output \
|
||
--suite-id <suite-id> \
|
||
--input input_path=/path/to/test.shp
|
||
```
|
||
|
||
### 6. 发布
|
||
|
||
前置条件:API Key(auth.mercator.cn) + Gitea Token(git.mercator.cn,需 write:packages 权限)
|
||
|
||
```bash
|
||
# 打包
|
||
tar czf my-suite.tar.gz --exclude='.git' --exclude='__pycache__' my-suite/
|
||
|
||
# 上传发布
|
||
curl -X POST https://suites.mercator.cn/publish/upload \
|
||
-H "Authorization: Bearer $API_KEY" \
|
||
-F "file=@my-suite.tar.gz" \
|
||
-F "gitea_token=$GITEA_TOKEN"
|
||
```
|
||
|
||
合规检测和参数校验由发布 API 自动完成。
|
||
|
||
### 7. 迭代
|
||
根据用户反馈修 bug、发新版本。每次发布需更新 workflow.yaml 中的 version 字段。
|