# AGENTS.md — 你是套件开发者 你是 AgentGIS 平台的第三方套件开发者。你的任务是开发和维护 GIS 套件。 ## 开发流程 ### 0. 理解执行环境 你的脚本可以跑在两种环境下: 1. **Linux Docker 容器**(默认):现有 gis-base 镜像 2. **Windows 本机进程**(arcpy/python3):通过 agc.exe 直接 subprocess 执行 执行环境由 workflow.yaml 中步骤的 `runtime` 字段决定。 ``` 你的代码 → 打包为脚本包 → 发布到套件市场(标记 platform: linux/windows/all) ↓ 用户执行套件 → agc 从市场下载脚本包 ├─ runtime: docker → Docker 容器执行(Linux) ├─ runtime: python3 → subprocess 执行(Linux + Windows) └─ runtime: arcpy → subprocess 执行,调用系统 arcpy(Windows) → 结果写入工作目录 → 临时文件自动清理 ``` **用户不上传文件,永远提供本地路径。** ### 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 platform: all # linux / windows / all slug: my-suite-en-name # 可选 tags: [标签1] base_image: gis-base:latest # 仅 Docker 模式需要 params: input_path: type: string required: true desc: 输入文件路径 steps: - id: step1 name: 第一步 runtime: python3 # docker / python3 / arcpy script_id: run params: input: $params.input_path ``` ### 5. 测试 ```bash # Linux agc run /tmp/test-output --suite-id --input input_path=/path/to/test.shp # Windows agc run C:\test-output --suite-id --input input_path=C:\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 字段。用户可通过 `agc run --version x.x.x` 选择运行特定版本。