14-tr-gitmap

TotalClaw 作者 totalclaw

ArcGIS 网页地图的版本控制——以原生 OpenClaw 工具形式暴露。

安装 / 下载方式

TotalClaw CLI推荐
totalclaw install totalclaw:totalclaw~14-tr-gitmap
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~14-tr-gitmap/file -o 14-tr-gitmap.md
## 概述(中文)

ArcGIS 网页地图的版本控制——以原生 OpenClaw 工具形式暴露。

## 技能正文

# GitMap 技能

ArcGIS 网页地图的版本控制——以原生 OpenClaw 工具形式暴露。

## 概述

GitMap 为 ArcGIS Online 和 Enterprise Portal 网页地图提供类 Git 的版本控制。本技能将 `gitmap` CLI 封装为轻量子进程调用,将分支、提交、差异、推送/拉取和地图发现暴露为可调用工具。

**8 个工具** | 轻量 CLI 封装 | 无本地数据库 | 需要:`gitmap-core` Python 包

---

## 前置条件

### 安装 GitMap Core

```bash
pip install gitmap-core
```

### 配置凭据

设置以下环境变量:

```bash
export PORTAL_URL="https://your-org.maps.arcgis.com"
export ARCGIS_USERNAME="your_username"
export ARCGIS_PASSWORD="your_password"
```

**安全提示:** 尽可能使用作用域 API 令牌,而非明文密码。

---

## 必需环境变量

- **PORTAL_URL**:ArcGIS Portal 或 AGOL URL(例如 `https://myorg.maps.arcgis.com`)
- **ARCGIS_USERNAME**:Portal 用户名
- **ARCGIS_PASSWORD**:Portal 密码(优先使用作用域 API 令牌而非明文密码)

---

## 工具

### 发现与状态

- `gitmap_list` — 从 Portal 列出可用网页地图(支持可选过滤器)
- `gitmap_status` — 显示本地 GitMap 仓库的工作树状态
- `gitmap_log` — 查看仓库提交历史

### 版本控制

- `gitmap_commit` — 提交当前地图状态及消息
- `gitmap_branch` — 列出或创建仓库分支
- `gitmap_diff` — 显示提交或分支之间的变更

### Portal 同步

- `gitmap_push` — 将已提交变更推送到 ArcGIS Portal
- `gitmap_pull` — 从 ArcGIS Portal 拉取最新地图

---

## 工具参考

### `gitmap_list`

在 Portal 中发现网页地图。

```python
gitmap_list(
    query=None,        # 搜索查询(例如 "title:MyMap")
    owner=None,        # 按所有者用户名过滤
    tag=None,          # 按标签过滤
    max_results=50,    # 最大返回数量
    portal_url=None,   # Portal URL(或使用 PORTAL_URL 环境变量)
    username=None,     # Portal 用户名(或 ARCGIS_USERNAME 环境变量)
    password=None,     # Portal 密码(或 ARCGIS_PASSWORD 环境变量)
    cwd=None,          # 工作目录(默认:home)
)
```

### `gitmap_status`

显示仓库状态。

```python
gitmap_status(
    cwd,               # GitMap 仓库路径(必需)
)
```

### `gitmap_commit`

提交当前变更。

```python
gitmap_commit(
    message,           # 提交消息(必需)
    cwd,               # GitMap 仓库路径(必需)
    author=None,       # 覆盖提交作者
)
```

### `gitmap_branch`

列出或创建分支。

```python
gitmap_branch(
    cwd,               # GitMap 仓库路径(必需)
    name=None,         # 要创建的分支名(省略则列出)
    delete=False,      # 删除指定分支
)
```

### `gitmap_diff`

显示版本间变更。

```python
gitmap_diff(
    cwd,               # GitMap 仓库路径(必需)
    branch=None,       # 与此分支比较
    commit=None,       # 与此提交哈希比较
)
```

### `gitmap_push`

推送变更到 Portal。

```python
gitmap_push(
    cwd,               # GitMap 仓库路径(必需)
    branch=None,       # 要推送的分支(默认:当前)
    portal_url=None,   # Portal URL
    username=None,     # Portal 用户名
    password=None,     # Portal 密码
)
```

### `gitmap_pull`

从 Portal 拉取变更。

```python
gitmap_pull(
    cwd,               # GitMap 仓库路径(必需)
    branch=None,       # 要拉取的分支(默认:当前)
    portal_url=None,   # Portal URL
    username=None,     # Portal 用户名
    password=None,     # Portal 密码
)
```

### `gitmap_log`

查看提交历史。

```python
gitmap_log(
    cwd,               # GitMap 仓库路径(必需)
    branch=None,       # 要显示日志的分支
    limit=None,        # 最大显示提交数
)
```

---

## 使用示例

### 发现地图并克隆

```python
# 查找某用户拥有的地图
gitmap_list(owner="john.doe", max_results=20)
# → 返回带 item ID 的地图表

# 然后手动克隆:
# cd ~/maps && gitmap clone <item_id>
```

### 典型 编辑 → 提交 → 推送 循环

```python
# 查看变更
gitmap_status(cwd="~/maps/MyWebMap")

# 提交变更
gitmap_commit(message="Updated layer symbology", cwd="~/maps/MyWebMap")

# 推送到 Portal
gitmap_push(cwd="~/maps/MyWebMap")
```

### 功能分支工作流

```python
# 列出分支
gitmap_branch(cwd="~/maps/MyWebMap")

# 创建功能分支
gitmap_branch(name="feature/new-basemap", cwd="~/maps/MyWebMap")

# 编辑后,提交并推送功能分支
gitmap_commit(message="Added satellite basemap", cwd="~/maps/MyWebMap")
gitmap_push(cwd="~/maps/MyWebMap", branch="feature/new-basemap")
```

### 查看历史

```python
# 最近提交
gitmap_log(cwd="~/maps/MyWebMap", limit=10)

# 自 main 以来有何变更?
gitmap_diff(cwd="~/maps/MyWebMap", branch="main")
```

---

## 服务器

HTTP 服务器位于 `localhost:7400`(运行时):

```bash
python server.py
```

端点:
- `POST /tools/{tool_name}` — 以 JSON 正文调用工具
- `GET /health` — 健康检查

---

## 安装

**安装命令:**

```bash
pip install gitmap-core
```

本技能直接使用 `gitmap_core` Python 包进行 API 访问。

---

## 说明与已知限制

- **大多数命令需要工作目录** — GitMap 仓库与 Git 一样是目录式的。
- **Portal 凭据** 可按调用传入或通过环境变量(PORTAL_URL、ARCGIS_USERNAME、ARCGIS_PASSWORD)。
- **`gitmap list`** 不需要本地仓库 — 直接查询 Portal。
- **输出为原始 CLI 文本** — 在可能处会轻度解析为结构化响应。
- 本技能**不实现** `clone`、`init`、`merge`、`checkout`、`lsm`、`context-repos`、`setup` — 请直接调用 CLI。

---

## 相关

- GitMap 项目:https://github.com/14-TR/gitmap