@cloudglab/confluence-cli 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +34 -0
- package/CHANGELOG.md +26 -0
- package/README.md +147 -0
- package/assets/readme/confluence-cli-hero.png +0 -0
- package/assets/readme/confluence-cli-hero.svg +7 -0
- package/assets/readme/prompts/01-cover-confluence-cli.md +61 -0
- package/dist/api/endpoints.d.ts +404 -0
- package/dist/api/endpoints.js +85 -0
- package/dist/api/index.d.ts +148 -0
- package/dist/api/index.js +143 -0
- package/dist/bin/confluence-reader.d.ts +2 -0
- package/dist/bin/confluence-reader.js +8 -0
- package/dist/bin/confluence-writer.d.ts +2 -0
- package/dist/bin/confluence-writer.js +8 -0
- package/dist/bin/confluence.d.ts +2 -0
- package/dist/bin/confluence.js +11 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +154 -0
- package/dist/core/api-provider.d.ts +3 -0
- package/dist/core/api-provider.js +13 -0
- package/dist/core/changelog.d.ts +7 -0
- package/dist/core/changelog.js +42 -0
- package/dist/core/cli-output.d.ts +16 -0
- package/dist/core/cli-output.js +318 -0
- package/dist/core/cli-registry.d.ts +20 -0
- package/dist/core/cli-registry.js +148 -0
- package/dist/core/command-groups.generated.d.ts +2 -0
- package/dist/core/command-groups.generated.js +88 -0
- package/dist/core/config.d.ts +5 -0
- package/dist/core/config.js +108 -0
- package/dist/core/http-error.d.ts +2 -0
- package/dist/core/http-error.js +4 -0
- package/dist/core/http.d.ts +28 -0
- package/dist/core/http.js +124 -0
- package/dist/core/inline-comment.d.ts +23 -0
- package/dist/core/inline-comment.js +27 -0
- package/dist/core/list-result.d.ts +14 -0
- package/dist/core/list-result.js +81 -0
- package/dist/core/manifest.d.ts +11 -0
- package/dist/core/manifest.js +42 -0
- package/dist/core/pagination.d.ts +26 -0
- package/dist/core/pagination.js +45 -0
- package/dist/core/roles.d.ts +4 -0
- package/dist/core/roles.js +12 -0
- package/dist/core/tool-registry.d.ts +9 -0
- package/dist/core/tool-registry.js +60 -0
- package/dist/core/validation.d.ts +2 -0
- package/dist/core/validation.js +10 -0
- package/dist/core/value.d.ts +2 -0
- package/dist/core/value.js +19 -0
- package/dist/core/write-guard.d.ts +25 -0
- package/dist/core/write-guard.js +49 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/install.d.ts +3 -0
- package/dist/install.js +407 -0
- package/dist/manifest.json +122 -0
- package/dist/tools/attachments.d.ts +2 -0
- package/dist/tools/attachments.js +46 -0
- package/dist/tools/content.d.ts +2 -0
- package/dist/tools/content.js +45 -0
- package/dist/tools/convert.d.ts +2 -0
- package/dist/tools/convert.js +63 -0
- package/dist/tools/init.d.ts +2 -0
- package/dist/tools/init.js +24 -0
- package/dist/tools/install.d.ts +2 -0
- package/dist/tools/install.js +52 -0
- package/dist/tools/labels.d.ts +2 -0
- package/dist/tools/labels.js +22 -0
- package/dist/tools/metadata.d.ts +2 -0
- package/dist/tools/metadata.js +26 -0
- package/dist/tools/rest.d.ts +2 -0
- package/dist/tools/rest.js +52 -0
- package/dist/tools/spaces.d.ts +2 -0
- package/dist/tools/spaces.js +18 -0
- package/dist/tools/transfer.d.ts +2 -0
- package/dist/tools/transfer.js +407 -0
- package/dist/types/common.d.ts +17 -0
- package/dist/types/common.js +2 -0
- package/dist/update-probe.d.ts +2 -0
- package/dist/update-probe.js +142 -0
- package/dist/utils/mark-metadata.d.ts +9 -0
- package/dist/utils/mark-metadata.js +16 -0
- package/dist/utils/markdown.d.ts +9 -0
- package/dist/utils/markdown.js +220 -0
- package/dist/utils/result.d.ts +3 -0
- package/dist/utils/result.js +7 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +2 -0
- package/docs/confluence-7.13.7-api.md +183 -0
- package/docs/index.html +608 -0
- package/docs/release.md +41 -0
- package/package.json +63 -0
- package/skills/confluence-cli/SKILL.md +63 -0
- package/skills/confluence-cli/reference/cli.md +36 -0
- package/skills/confluence-cli/reference/commands.md +41 -0
- package/skills/confluence-cli/reference/content.md +23 -0
- package/skills/confluence-cli/reference/overview.md +23 -0
- package/skills/confluence-cli/reference/rest.md +19 -0
- package/skills/confluence-cli/reference/transfer.md +27 -0
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cloudglab/confluence-cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Confluence REST CLI for agents and local automation",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/cloudglab/confluence-cli.git"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "dist/index.js",
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
|
+
"bin": {
|
|
13
|
+
"confluence": "dist/bin/confluence.js",
|
|
14
|
+
"confluence-cli": "dist/bin/confluence.js",
|
|
15
|
+
"confluence-reader": "dist/bin/confluence-reader.js",
|
|
16
|
+
"confluence-writer": "dist/bin/confluence-writer.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"!dist/**/*.map",
|
|
21
|
+
"README.md",
|
|
22
|
+
"CHANGELOG.md",
|
|
23
|
+
"AGENTS.md",
|
|
24
|
+
"skills",
|
|
25
|
+
"docs",
|
|
26
|
+
"assets"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "rm -rf dist && tsx scripts/generate-manifest.ts && tsc -p tsconfig.json && node scripts/fix-bin-mode.mjs",
|
|
30
|
+
"dev": "tsx src/bin/confluence.ts",
|
|
31
|
+
"dev:reader": "tsx src/bin/confluence.ts --role reader",
|
|
32
|
+
"dev:writer": "tsx src/bin/confluence.ts --role writer",
|
|
33
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
34
|
+
"test": "vitest run --passWithNoTests",
|
|
35
|
+
"lint": "oxlint src",
|
|
36
|
+
"check": "pnpm lint && pnpm typecheck && pnpm test && pnpm build",
|
|
37
|
+
"release:smoke-query": "node scripts/release-query-smoke.mjs",
|
|
38
|
+
"prepare": "node scripts/prepare.mjs"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@mermaid-js/mermaid-cli": "^11.15.0",
|
|
42
|
+
"@whitebite/diagram-converter": "^0.2.0",
|
|
43
|
+
"axios": "^1.7.9",
|
|
44
|
+
"marked": "^18.0.5",
|
|
45
|
+
"zod": "^3.24.1"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@vitest/coverage-v8": "^4.1.8",
|
|
49
|
+
"@types/node": "^22.10.2",
|
|
50
|
+
"lefthook": "^2.1.9",
|
|
51
|
+
"oxlint": "^0.15.15",
|
|
52
|
+
"tsx": "^4.19.2",
|
|
53
|
+
"typescript": "^5.7.2",
|
|
54
|
+
"vitest": "^4.1.8"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=18"
|
|
58
|
+
},
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public"
|
|
61
|
+
},
|
|
62
|
+
"packageManager": "pnpm@9.15.0"
|
|
63
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: confluence-cli
|
|
3
|
+
description: Use this CLI for Confluence REST operations from a terminal or agent workflow. Triggers on Confluence page search, read, upload (Markdown/HTML with Mermaid + TOC), download, labels, attachments, comments, and Confluence 7.13.7 REST pass-through.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Confluence CLI Skill
|
|
7
|
+
|
|
8
|
+
Use this CLI when a task needs Confluence REST operations from a terminal or agent workflow.
|
|
9
|
+
|
|
10
|
+
Start with these references when you need details:
|
|
11
|
+
|
|
12
|
+
- `reference/overview.md`:整体工作流与安全原则
|
|
13
|
+
- `reference/commands.md`:命令速查
|
|
14
|
+
- `reference/cli.md`:安装、更新、角色入口和环境变量
|
|
15
|
+
- `reference/content.md`:页面查询、读取、子页、评论、标签
|
|
16
|
+
- `reference/transfer.md`:Markdown/HTML 发布、下载、附件、Mermaid/TOC
|
|
17
|
+
- `reference/rest.md`:Confluence 7.13.7 REST 端点透传
|
|
18
|
+
- `../../docs/release.md`:发布前检查与 npm 发布流程
|
|
19
|
+
|
|
20
|
+
## Decision Matrix
|
|
21
|
+
|
|
22
|
+
- Read/search small content: `confluence searchContent` or `confluence getContent`.
|
|
23
|
+
- Convert Markdown locally: `confluence convertMarkdownToWiki`.
|
|
24
|
+
- Generate mark metadata: `confluence generateMarkMetadata`.
|
|
25
|
+
- Upload large Markdown through REST: `confluence uploadMarkdown --toc --confirm true`.
|
|
26
|
+
- Upload raw HTML through REST: `confluence uploadHtml --toc --confirm true`.
|
|
27
|
+
- For full page publishes or republish flows, include `--toc` by default; only omit it when the user explicitly says no TOC.
|
|
28
|
+
- Upload Markdown with attachments: `confluence uploadMarkdown --attachments '["a.png"]' --toc --confirm true`.
|
|
29
|
+
- Dry-run uploads first: omit `--confirm true`.
|
|
30
|
+
- Render Mermaid on the fly: any ```mermaid fence in Markdown/HTML auto-generates PNG attachments by default.
|
|
31
|
+
- Download editable backup: `confluence downloadPage`.
|
|
32
|
+
- Download page with attachments/children: `confluence downloadPage --downloadAttachments true --downloadChildren true`.
|
|
33
|
+
- Use MCP-style page tools: `getPageChildren`, `getComments`, `addComment`, `getLabels`, `addLabels`.
|
|
34
|
+
- Use attachment tools: `listAttachments`, `uploadAttachment`, `updateAttachment`, `downloadAttachment`.
|
|
35
|
+
- Check PAT identity: `confluence getCurrentUser`.
|
|
36
|
+
|
|
37
|
+
## Safety
|
|
38
|
+
|
|
39
|
+
All writes must pass `--confirm true`. Without confirmation, upload, delete, label, comment and attachment write commands return a dry-run preview.
|
|
40
|
+
|
|
41
|
+
## CQL Examples
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
confluence searchContent --cql 'space = "DEV" AND text ~ "API"'
|
|
45
|
+
confluence searchContent --cql 'type = page AND title ~ "Runbook"'
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Upload Patterns
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Markdown → Confluence,自动 Mermaid → PNG 附件图片,默认注入双 TOC 宏
|
|
52
|
+
confluence uploadMarkdown --file doc.md --id 142552620 --toc --tocMaxLevel 3 --confirm true
|
|
53
|
+
|
|
54
|
+
# 保持原代码块不渲染
|
|
55
|
+
confluence uploadMarkdown --file doc.md --id 142552620 --mermaid none --toc --confirm true
|
|
56
|
+
|
|
57
|
+
# HTML → Confluence,同样支持Mermaid和TOC
|
|
58
|
+
confluence uploadHtml --file page.html --space DEV --toc --confirm true
|
|
59
|
+
|
|
60
|
+
# 只预览(dry-run)
|
|
61
|
+
confluence uploadMarkdown --file doc.md --id 142552620 --toc
|
|
62
|
+
confluence uploadHtml --file page.html --space DEV --toc
|
|
63
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# CLI
|
|
2
|
+
|
|
3
|
+
## 安装与更新
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
confluence install --skip-config-check true
|
|
7
|
+
confluence update --skip-config-check true
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
可选参数:
|
|
11
|
+
|
|
12
|
+
- `--skill-source local|git|npm`
|
|
13
|
+
- `--skill-local-path <dir>`
|
|
14
|
+
- `--cli-only true|false`
|
|
15
|
+
- `--skill-only true|false`
|
|
16
|
+
- `--skip-config-check true|false`
|
|
17
|
+
|
|
18
|
+
## 角色入口
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
confluence list
|
|
22
|
+
confluence-reader list
|
|
23
|
+
confluence-writer list
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
- `confluence`:完整入口。
|
|
27
|
+
- `confluence-reader`:不注册发布上传类 transfer 命令。
|
|
28
|
+
- `confluence-writer`:注册写入和发布命令,但仍需要 `--confirm true`。
|
|
29
|
+
|
|
30
|
+
## 环境变量
|
|
31
|
+
|
|
32
|
+
- `CONFLUENCE_URL`
|
|
33
|
+
- `CONFLUENCE_PAT` 或 `CONFLUENCE_PERSONAL_TOKEN`
|
|
34
|
+
- `CONFLUENCE_USERNAME` + `CONFLUENCE_PASSWORD`
|
|
35
|
+
- `CONFLUENCE_DISABLE_WRITE=true`
|
|
36
|
+
- `CONFLUENCE_SKIP_UPDATE_CHECK=true`
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# 命令速查
|
|
2
|
+
|
|
3
|
+
## 基础
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
confluence help
|
|
7
|
+
confluence list
|
|
8
|
+
confluence version
|
|
9
|
+
confluence help searchContent
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 配置
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
confluence initConfluence --url https://confluence.example.com --pat TOKEN --save true
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 查询
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
confluence searchContent --cql 'space = "DEV" AND text ~ "API"'
|
|
22
|
+
confluence getContent --id 123456
|
|
23
|
+
confluence findContent --space DEV --title "API Guide"
|
|
24
|
+
confluence getPageChildren --id 123456 --type page
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 发布与下载
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
confluence uploadMarkdown --file docs/page.md --space DEV --toc --confirm false
|
|
31
|
+
confluence uploadMarkdown --file docs/page.md --id 123456 --attachments '["docs/a.png"]' --toc --confirm true
|
|
32
|
+
confluence uploadHtml --file docs/page.html --space DEV --toc --confirm true
|
|
33
|
+
confluence downloadPage --id 123456 --outputDir exports --downloadAttachments true --downloadChildren true
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## REST 透传
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
confluence listRestApis --group content --limit 20
|
|
40
|
+
confluence callRestApi --method GET --path '/content/{id}' --pathParams '{"id":"123456"}' --query '{"expand":"body.storage,version"}'
|
|
41
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# 内容操作
|
|
2
|
+
|
|
3
|
+
## 查询页面
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
confluence searchContent --cql 'type = page AND title ~ "Runbook"'
|
|
7
|
+
confluence findContent --space DEV --title "Runbook"
|
|
8
|
+
confluence getContent --id 123456
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 子页、评论、标签
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
confluence getPageChildren --id 123456 --type page
|
|
15
|
+
confluence getComments --id 123456
|
|
16
|
+
confluence addComment --id 123456 --text "LGTM" --confirm true
|
|
17
|
+
confluence getLabels --id 123456
|
|
18
|
+
confluence addLabels --id 123456 --labels '["api","docs"]' --confirm true
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 安全原则
|
|
22
|
+
|
|
23
|
+
所有删除、评论、标签等写命令都必须显式 `--confirm true`;不传确认时只返回 preview。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# 总览
|
|
2
|
+
|
|
3
|
+
## 这个 skill 做什么
|
|
4
|
+
|
|
5
|
+
- 用命令行方式操作 Confluence Server/Data Center REST API。
|
|
6
|
+
- 默认写操作只 preview,真实写入必须显式 `--confirm true`。
|
|
7
|
+
- 支持页面搜索、读取、评论、标签、附件、Markdown/HTML 发布、页面下载和 REST 端点透传。
|
|
8
|
+
|
|
9
|
+
## 推荐工作流
|
|
10
|
+
|
|
11
|
+
1. 先确认本机是否安装 `confluence`。
|
|
12
|
+
2. 如果没有,优先运行 `confluence install --skip-config-check true`。
|
|
13
|
+
3. 对命令参数不确定时,先运行 `confluence help <command>` 校对。
|
|
14
|
+
4. 查询类任务优先用 `searchContent`、`getContent`、`findContent`。
|
|
15
|
+
5. 发布类任务优先 dry-run,再加 `--confirm true`。
|
|
16
|
+
6. Markdown/HTML 全量发布默认加 `--toc`,除非用户明确不要目录。
|
|
17
|
+
7. 自动化环境可设置 `CONFLUENCE_DISABLE_WRITE=true` 彻底禁用真实写入。
|
|
18
|
+
|
|
19
|
+
## 适合谁
|
|
20
|
+
|
|
21
|
+
- 需要命令行操作 Confluence 的人。
|
|
22
|
+
- 需要把 Confluence 接入智能体的人。
|
|
23
|
+
- 需要在 Confluence 7.13.7 环境下稳定自动化的人。
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# REST 透传
|
|
2
|
+
|
|
3
|
+
`listRestApis` 和 `callRestApi` 用于覆盖 Confluence 7.13.7 官方 REST 端点。
|
|
4
|
+
|
|
5
|
+
## 查看端点
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
confluence listRestApis --limit 20
|
|
9
|
+
confluence listRestApis --group content --limit 20
|
|
10
|
+
confluence listRestApis --method GET --write false --limit 20
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 调用端点
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
confluence callRestApi --method GET --path '/content/{id}' --pathParams '{"id":"123456"}' --query '{"expand":"body.storage,version"}'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
写 REST 端点仍受 `--confirm true` 和 `CONFLUENCE_DISABLE_WRITE=true` 保护。
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# 发布与下载
|
|
2
|
+
|
|
3
|
+
## Markdown 发布
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
confluence uploadMarkdown --file docs/page.md --space DEV --toc --confirm false
|
|
7
|
+
confluence uploadMarkdown --file docs/page.md --id 123456 --toc --confirm true
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## HTML 发布
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
confluence uploadHtml --file docs/page.html --space DEV --toc --confirm false
|
|
14
|
+
confluence uploadHtml --file docs/page.html --id 123456 --toc --confirm true
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Mermaid 与附件
|
|
18
|
+
|
|
19
|
+
- 默认将 Markdown/HTML 中的 Mermaid 渲染为 PNG 附件并插入图片宏。
|
|
20
|
+
- 如需保留原代码块,使用 `--mermaid none`。
|
|
21
|
+
- 附件用 JSON 数组传入:`--attachments '["docs/a.png"]'`。
|
|
22
|
+
|
|
23
|
+
## 下载
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
confluence downloadPage --id 123456 --outputDir exports --downloadAttachments true --downloadChildren true
|
|
27
|
+
```
|