Files
agent-profiles/suite-developer/MEMORY.md
T

106 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# MEMORY.md — 套件开发者长期记忆
## 平台入口
- **API:** https://suites.mercator.cn
- **API Key 获取:** https://auth.mercator.cn
- **API 文档:** https://suites.mercator.cn/docs
## 知识库(knowledge/
| 文件 | 内容 |
|------|------|
| `script-data-types.md` | 脚本数据类型分类规范(矢量/栅格/点云/文档/表格...) |
| `script-dependencies.md` | 脚本依赖管理规范(运行时 pip / 扩展镜像 / 自定义镜像) |
## Workflow.yaml 核心规则
### 完整结构
```yaml
name: 套件名称
description: 功能描述
version: 1.0.0
author: 作者
tags: [标签1]
category: 业务分类
params:
input_path:
type: string
required: true
desc: 输入文件路径
base_image: gis-base:latest
steps:
- id: step1
name: 步骤1
type: python
script_id: run
params:
input: $params.input_path
```
### 引用语法
| 语法 | 说明 | 示例 |
|------|------|------|
| `$params.xxx` | 引用套件输入参数 | `$params.input_path` |
| `$steps.step_id.output_name` | 引用前一步骤输出 | `$steps.step1.result_path` |
### 步骤依赖
```yaml
steps:
- id: step1
type: python
script_id: analyze
- id: step2
type: python
script_id: report
depends_on: [step1] # step2 等 step1 完成后才执行
```
### 常见错误
| ❌ 错误 | ✅ 正确 |
|---------|--------|
| `script: run.py` | `script_id: run` |
| `params_mapping: {...}` | `params: {...}` |
| `$inputs.xxx` | `$params.xxx` |
### 跨步骤文件共享
所有步骤共享 `/tmp/output` 目录。Step 1 写入的文件,Step 2 可以直接读取。
## 核心原则:先查市场,再动手写
开发新套件前,先搜索市场是否已有能复用的 Suite:
```bash
curl -s "https://suites.mercator.cn/api/v1/suites/search?q=缓冲区"
curl -s https://suites.mercator.cn/api/v1/suites | python3 -m json.tool
```
找到现成的 Suite → 在 workflow.yaml 中引用,不写新代码。
找不到 → 写新脚本 → 发布 Suite → 方便后续者复用。
## 发布流程
通过 API 上传:
```bash
tar czf suite.tgz --exclude='.git' --exclude='__pycache__' my-suite/
curl -X POST https://suites.mercator.cn/api/v1/publish \
-H "Authorization: Bearer $KEY" \
-F "file=@suite.tgz"
```
## 执行环境
- 每个任务跑在独立 Docker 容器中,用完即销毁
- 容器使用 gis-base 镜像(`gis-base:latest`,本地加载)
- 工作目录 `/tmp/output`(步骤间共享)
- 参数通过 `PARAMS_FILE` 环境变量(指向 JSON 文件)或 `sys.argv[1]` JSON 传入