Agent Skillssandgardenhq/sgai › workspace-management

workspace-management

GitHub

通过 HTTP API 管理 sgai 工作区,支持创建、分叉、删除和重命名操作。适用于新建项目、并行开发分支、清理废弃分支及重命名工作区等场景。

docs/sgai-skills/workspace-management/SKILL.md sandgardenhq/sgai

触发场景

需要创建新的项目工作区 为并行开发创建分叉 清理已完成的工作区分支 重命名现有工作区

安装

npx skills add sandgardenhq/sgai --skill workspace-management -g -y
更多选项

非标准路径

npx skills add https://github.com/sandgardenhq/sgai/tree/main/docs/sgai-skills/workspace-management -g -y

不安装直接使用

npx skills use sandgardenhq/sgai@workspace-management

指定 Agent (Claude Code)

npx skills add sandgardenhq/sgai --skill workspace-management -a claude-code -g -y

安装 repo 全部 skill

npx skills add sandgardenhq/sgai --all -g -y

预览 repo 内 skill

npx skills add sandgardenhq/sgai --list

SKILL.md

Frontmatter
{
    "name": "workspace-management",
    "description": "Create, fork, delete, and rename sgai workspaces via the HTTP API. Use when you need to set up new project workspaces, create parallel forks for concurrent development, clean up finished forks, or rename existing fork workspaces.",
    "compatibility": "Requires a running sgai server. Workspace names must use lowercase letters, numbers, and dashes only."
}

Workspace Management

Workspaces are directories managed by sgai. There are three kinds:

  • Standalone — independent workspace, not part of a fork tree
  • Root — has one or more fork children (displayed in dashboard/fork mode)
  • Fork — child of a root workspace, shares the jj VCS repository

Create a Workspace

Endpoint: POST /api/v1/workspaces

curl -X POST $BASE_URL/api/v1/workspaces \
  -H "Content-Type: application/json" \
  -d '{"name": "my-project"}'

Request:

{"name": "my-project"}

Response (201 Created):

{
  "name": "my-project",
  "dir": "/path/to/workspaces/my-project"
}

Errors:

  • 400 — invalid name (must be lowercase letters, numbers, dashes)
  • 409 — directory already exists

Name Validation Rules

  • Only lowercase letters (a-z), numbers (0-9), and dashes (-)
  • Cannot start or end with a dash
  • No spaces or special characters

Fork a Workspace

Create a jj workspace fork for parallel development.

Endpoint: POST /api/v1/workspaces/{name}/fork

curl -X POST $BASE_URL/api/v1/workspaces/my-project/fork \
  -H "Content-Type: application/json" \
  -d '{"name": "feature-branch"}'

Request:

{"name": "feature-branch"}

Response (201 Created):

{
  "name": "feature-branch",
  "dir": "/path/to/workspaces/feature-branch",
  "parent": "my-project",
  "createdAt": ""
}

Notes:

  • Only standalone or root workspaces can be forked (forks cannot fork)
  • Fork names are normalized (spaces become dashes, etc.)
  • The fork shares the jj repository with the root via jj workspace add

Delete a Fork

Endpoint: POST /api/v1/workspaces/{name}/delete-fork

Where {name} is the root workspace name.

curl -X POST $BASE_URL/api/v1/workspaces/my-project/delete-fork \
  -H "Content-Type: application/json" \
  -d '{"forkDir": "/full/path/to/fork", "confirm": true}'

Request:

{
  "forkDir": "/full/path/to/workspaces/feature-branch",
  "confirm": true
}

Response:

{
  "deleted": true,
  "message": "fork deleted successfully"
}

Notes:

  • confirm: true is required (safety guard)
  • The running session is stopped before deletion
  • Uses jj workspace forget then removes the directory
  • When a root workspace runs out of forks, it reverts from Fork Mode to Repository Mode

Rename a Fork

Only fork workspaces can be renamed (not standalone or root).

Endpoint: POST /api/v1/workspaces/{name}/rename

curl -X POST $BASE_URL/api/v1/workspaces/feature-branch/rename \
  -H "Content-Type: application/json" \
  -d '{"name": "new-feature-name"}'

Request:

{"name": "new-feature-name"}

Response:

{
  "name": "new-feature-name",
  "oldName": "feature-branch",
  "dir": "/path/to/workspaces/new-feature-name"
}

Errors:

  • 400 — workspace is not a fork
  • 409 — session is running (stop first) or name conflict

Toggle Pin

Pin workspaces to keep them prioritized at the top of the list.

Endpoint: POST /api/v1/workspaces/{name}/pin

curl -X POST $BASE_URL/api/v1/workspaces/my-project/pin

Response:

{
  "pinned": true,
  "message": "pin toggled"
}

Update Workspace Summary

Set a human-readable summary for a workspace (shown in the UI).

Endpoint: PUT /api/v1/workspaces/{name}/summary

curl -X PUT $BASE_URL/api/v1/workspaces/my-project/summary \
  -H "Content-Type: application/json" \
  -d '{"summary": "Implementing authentication module"}'

Response:

{
  "updated": true,
  "summary": "Implementing authentication module",
  "workspace": "my-project"
}

Update Commit Description

Update the jj commit description for the current working copy.

Endpoint: POST /api/v1/workspaces/{name}/description

curl -X POST $BASE_URL/api/v1/workspaces/my-project/description \
  -H "Content-Type: application/json" \
  -d '{"description": "feat: add authentication endpoints"}'

Response:

{
  "updated": true,
  "description": "feat: add authentication endpoints"
}

Get GOAL.md

Endpoint: GET /api/v1/workspaces/{name}/goal

curl -s $BASE_URL/api/v1/workspaces/my-project/goal

Response:

{
  "content": "---\nagents:\n  - \"general-purpose\"\nmodel: \"openai/gpt-5.5 (xhigh)\"\n---\n\n- [ ] Task 1\n"
}

Update GOAL.md

Endpoint: PUT /api/v1/workspaces/{name}/goal

curl -X PUT $BASE_URL/api/v1/workspaces/my-project/goal \
  -H "Content-Type: application/json" \
  -d '{"content": "- [ ] Build the auth system\n- [ ] Write tests\n"}'

Response:

{
  "updated": true,
  "workspace": "my-project"
}

版本历史

  • 9efbb7b 当前 2026-07-25 08:54

同 Skill 集合

docs/sgai-skills/adhoc/SKILL.md
docs/sgai-skills/compose/SKILL.md
docs/sgai-skills/human-interaction/SKILL.md
docs/sgai-skills/knowledge/SKILL.md
docs/sgai-skills/monitoring/SKILL.md
docs/sgai-skills/session-control/SKILL.md
docs/sgai-skills/using-sgai/SKILL.md

元信息

文件数
0
版本
9efbb7b
Hash
1ddd7db5
收录时间
2026-07-25 08:54

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-28 23:12
浙ICP备14020137号-1 $访客地图$