SuperAPI AI 工具集

jira-spaces

办公与效率

查看项目

更新于 10-13 15:24

技能介绍

用途

Jira Spaces 技能用于管理 Confluence 空间,空间是组织项目文档、维基和知识库的顶层容器。该技能通过 Confluence Cloud REST API 对空间进行创建、列出和删除操作,可用于搭建项目文档结构、为不同团队或计划创建空间、查找可用文档空间,以及归档或删除过时空间。

主要能力

该技能提供以下 API 操作:

  • /space GET:列出所有空间
  • /space POST:创建新空间
  • /space/{spaceKey} GET:获取空间详情
  • /space/{spaceKey} DELETE:删除空间
  • /space/{spaceKey}/content GET:列出空间内容

空间类型有两种:

  • global:站点级空间,适用于公司维基、共享文档
  • personal:用户个人空间,适用于个人笔记、草稿

配套脚本包括 create-space(创建新 Confluence 空间)、delete-space(删除空间,带确认)、list-spaces(列出所有可访问空间)。

使用方式

前置条件

  • Confluence Cloud 实例(与 Jira 同一个 Atlassian 账户)
  • 具有 Confluence 访问权限的 API 令牌
  • 在 .env 中配置环境变量

API 基础信息

Confluence Cloud 使用与 Jira Cloud 相同的基础 URL,但 API 路径不同:https://your-domain.atlassian.net/wiki/rest/api。认证方式与 Jira 相同,采用邮箱加令牌的 Basic Auth。

创建空间

示例请求:

const response = await fetch(`${CONFLUENCE_URL}/wiki/rest/api/space`, {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${auth}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    key: 'PROJ',           // Unique space key (uppercase)
    name: 'Project Docs',   // Display name
    type: 'global',         // 'global' or 'personal'
    description: {
      plain: {
        value: 'Documentation for the project',
        representation: 'plain'
      }
    }
  })
});

响应会返回 id、key、name、type、status 以及 _links 信息。

列出空间

示例请求:

const response = await fetch(`${CONFLUENCE_URL}/wiki/rest/api/space?limit=25&type=global`, {
  headers: {
    'Authorization': `Basic ${auth}`,
    'Accept': 'application/json'
  }
});

响应包含 results 数组、start、limit、size 等字段。

删除空间

警告:删除空间会永久移除所有页面和内容。

示例请求:

const response = await fetch(`${CONFLUENCE_URL}/wiki/rest/api/space/PROJ`, {
  method: 'DELETE',
  headers: {
    'Authorization': `Basic ${auth}`
  }
});

返回 202 Accepted(删除为异步)或 204 No Content。

空间键规则

空间键必须:实例内唯一、仅包含大写字母和数字、长度 1-255 字符、不能以数字开头。常见约定:PROJ 表示项目专属、TEAM 表示团队专属、DOC 表示文档、KB 表示知识库。

常见模式

创建项目文档空间:

// Create space with home page
await createSpace({
  key: 'TUSTLE',
  name: 'Tustle Project Documentation',
  description: 'Technical documentation and guides for Tustle MVP'
});

// Add standard pages
await createPage('TUSTLE', 'Getting Started', 'Overview and setup instructions...');
await createPage('TUSTLE', 'Architecture', 'System architecture documentation...');
await createPage('TUSTLE', 'API Reference', 'API endpoint documentation...');

列出团队空间:

const spaces = await listSpaces({ type: 'global', limit: 50 });
const teamSpaces = spaces.filter(s => s.name.includes('Team'));

脚本使用示例

# List all spaces
node run.js list-spaces

# Create a new space
node run.js create-space DOCS "Documentation Space"

# Delete a space (interactive confirmation)
node run.js delete-space DOCS

# Force delete without confirmation
node run.js delete-space DOCS --confirm

适用场景

  • 为新项目搭建文档结构
  • 为不同团队或计划创建空间
  • 列出可用空间以查找文档
  • 归档或删除过时空间
  • 创建包含标准页面的项目文档空间

错误处理

  • 400:空间键无效,检查键格式(大写、无特殊字符)
  • 401:未授权,检查 API 令牌和邮箱
  • 403:禁止访问,用户缺少空间管理员权限
  • 404:空间未找到,确认空间键存在
  • 409:冲突,空间键已存在

相关技能

  • jira-projects:Jira 项目管理
  • jira-issues:为文档任务创建问题

限制

删除空间会永久移除所有页面和内容,操作不可恢复。删除为异步操作,可能返回 202。空间键必须满足格式要求。相关收费、价格等信息暂未提供。