gitea-cli-skill 0.1.7 → 0.1.9

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.
@@ -0,0 +1,273 @@
1
+ # gitea-cli Reference
2
+
3
+ Full command reference and workflow details. This file is loaded on demand — the core rules and binary location are in SKILL.md.
4
+
5
+ ## Workflow: Issue 处理
6
+
7
+ ```bash
8
+ # 1. 查看 open issues
9
+ gitea-cli issue list --state open --output json
10
+
11
+ # 2. 查看 issue 详情
12
+ gitea-cli issue get <number> --output json
13
+
14
+ # 3. 查找 label/milestone ID
15
+ gitea-cli label list --output json
16
+ gitea-cli milestone list --output json
17
+
18
+ # 4. 更新 issue
19
+ gitea-cli issue update <number> --label <id> --milestone <id>
20
+
21
+ # 5. 添加评论
22
+ gitea-cli issue comment create <number> -b "分析原因:..."
23
+
24
+ # 6. 上传附件(图片自动嵌入为 markdown)
25
+ gitea-cli issue attachment upload <number> ./screenshot.png
26
+
27
+ # 7. 关闭 issue
28
+ gitea-cli issue close <number>
29
+ ```
30
+
31
+ ## Workflow: PR 工作流
32
+
33
+ ```bash
34
+ # 1. 创建 feature 分支
35
+ gitea-cli branch create feature/xyz --from main
36
+
37
+ # 2. 创建 PR
38
+ gitea-cli pr create --title "feat: xxx" --head feature/xyz --base main --body "## Summary\n- Changes"
39
+
40
+ # 3. 查看 PR 状态
41
+ gitea-cli pr get <index> --output json
42
+
43
+ # 4. 检查 CI
44
+ gitea-cli actions run list --output json
45
+ gitea-cli actions run jobs <run-id> --output json
46
+
47
+ # 5. 合并 PR
48
+ gitea-cli pr merge <index> --strategy squash --delete-branch
49
+ ```
50
+
51
+ ## Workflow: Release 发布
52
+
53
+ ```bash
54
+ # 1. 查看最近提交
55
+ gitea-cli commit list --branch main --limit 20 --output json
56
+
57
+ # 2. 查看 tags/releases
58
+ gitea-cli tag list --output json
59
+ gitea-cli release list --output json
60
+
61
+ # 3. 创建 tag + release
62
+ gitea-cli tag create v1.0.0 --target main -m "Release v1.0.0"
63
+ gitea-cli release create --tag v1.0.0 --name "v1.0.0" --body "## Changes\n- ..." --target main
64
+
65
+ # 4. 上传 assets
66
+ gitea-cli release asset upload v1.0.0 ./dist/binary --name binary-linux-amd64
67
+
68
+ # 5. 确认
69
+ gitea-cli release get v1.0.0 --output json
70
+ gitea-cli release asset list v1.0.0 --output json
71
+ ```
72
+
73
+ ## Workflow: CI/CD 排障
74
+
75
+ ```bash
76
+ gitea-cli actions run list --limit 10 --output json
77
+ gitea-cli actions run jobs <run-id> --output json
78
+ gitea-cli actions job logs <job-id> -o ./logs/
79
+ gitea-cli actions job get <job-id> --output json
80
+ gitea-cli actions workflow dispatch <workflow-id> --ref main
81
+ gitea-cli actions artifact list --output json
82
+ gitea-cli actions artifact download <artifact-id> -o ./dist/
83
+ ```
84
+
85
+ ## Workflow: 仓库文件修改
86
+
87
+ ```bash
88
+ # 读取
89
+ gitea-cli content get src/config.yaml --output json
90
+
91
+ # 创建新文件
92
+ gitea-cli content create src/config.yaml --content "new: value" -m "add config"
93
+
94
+ # 更新(SHA 自动获取)
95
+ gitea-cli content update src/config.yaml --content "updated: value" -m "update config"
96
+
97
+ # 从本地文件上传
98
+ gitea-cli content update src/config.yaml --file ./local-config.yaml -m "update from local"
99
+ ```
100
+
101
+ ## Workflow: 配置管理
102
+
103
+ ```bash
104
+ gitea-cli config list --output json
105
+ gitea-cli config set --name work --host <url> --token <tok> --default-owner myorg
106
+ gitea-cli config get work
107
+ # 临时使用其他 context
108
+ gitea-cli issue list --context personal --output json
109
+ ```
110
+
111
+ ## Command Reference
112
+
113
+ ### Config
114
+
115
+ ```bash
116
+ gitea-cli config list # List all contexts
117
+ gitea-cli config get <name> # Get context details
118
+ gitea-cli config set --name <ctx> --host <url> --token <tok> # Create/update context
119
+ # Additional flags: --default-owner, --default-repo
120
+ ```
121
+
122
+ ### Repository
123
+
124
+ ```bash
125
+ gitea-cli repo list --owner <org> --output json
126
+ gitea-cli repo get --owner <org> --repo <repo> --output json
127
+ ```
128
+
129
+ ### Branch
130
+
131
+ ```bash
132
+ gitea-cli branch list --output json
133
+ gitea-cli branch get <name> --output json
134
+ gitea-cli branch create <name> --from <base>
135
+ gitea-cli branch delete <name> --force
136
+ gitea-cli branch protect list --output json
137
+ gitea-cli branch protect create <name> --enable-push --required-approvals 2
138
+ gitea-cli branch protect delete <name> --force
139
+ ```
140
+
141
+ ### File Content
142
+
143
+ ```bash
144
+ gitea-cli content list [--path] --ref <branch> --output json
145
+ gitea-cli content get <path> --ref <branch> --output json # --raw for decoded content
146
+ gitea-cli content create <path> --content "text" -m "msg" # or --file <local>
147
+ gitea-cli content update <path> --content "text" -m "msg" # --sha auto-fetched
148
+ gitea-cli content delete <path> -m "msg" --force
149
+ ```
150
+
151
+ ### Commit
152
+
153
+ ```bash
154
+ gitea-cli commit list --branch <ref> --limit 10 --output json
155
+ gitea-cli commit get <sha> --output json
156
+ ```
157
+
158
+ ### Issue
159
+
160
+ ```bash
161
+ gitea-cli issue list --state open --output json
162
+ gitea-cli issue get <number> --output json
163
+ gitea-cli issue create -t "Title" -b "Body" --label <id> --milestone <id>
164
+ gitea-cli issue create -t "Title" --attach ./image.png --attach ./log.txt
165
+ gitea-cli issue update <number> -t "New Title" --state closed
166
+ gitea-cli issue close <number>
167
+
168
+ # Comments
169
+ gitea-cli issue comment list <number> --output json
170
+ gitea-cli issue comment create <number> -b "Comment text"
171
+ gitea-cli issue comment update <comment-id> -b "Updated text"
172
+ gitea-cli issue comment delete <comment-id> --force
173
+
174
+ # Attachments
175
+ gitea-cli issue attachment list <number> --output json
176
+ gitea-cli issue attachment upload <number> <file> --name <filename>
177
+ gitea-cli issue attachment download <number> <attach-id> -o ./save/
178
+ gitea-cli issue attachment delete <number> <attach-id> --force
179
+ ```
180
+
181
+ ### Pull Request
182
+
183
+ ```bash
184
+ gitea-cli pr list --state open --output json
185
+ gitea-cli pr get <index> --output json
186
+ gitea-cli pr create --title "Title" --head <src> --base <target> --body "Desc"
187
+ gitea-cli pr close <index>
188
+ gitea-cli pr reopen <index>
189
+ gitea-cli pr merge <index> --strategy merge --delete-branch
190
+ # Strategies: merge, rebase, squash, fast-forward-only
191
+ ```
192
+
193
+ ### Label
194
+
195
+ ```bash
196
+ gitea-cli label list --output json
197
+ gitea-cli label get <id> --output json
198
+ gitea-cli label create --name "bug" --color "#ff0000" --description "Bug report"
199
+ gitea-cli label delete <id> --force
200
+ ```
201
+
202
+ ### Milestone
203
+
204
+ ```bash
205
+ gitea-cli milestone list --state open --output json
206
+ gitea-cli milestone get <id> --output json
207
+ gitea-cli milestone create --title "v1.0" --description "First release" --due-on 2025-12-31T00:00:00Z
208
+ gitea-cli milestone close <id>
209
+ gitea-cli milestone delete <id> --force
210
+ ```
211
+
212
+ ### Tag
213
+
214
+ ```bash
215
+ gitea-cli tag list --output json
216
+ gitea-cli tag get <name> --output json
217
+ gitea-cli tag create <name> --target <ref> -m "Annotated tag message"
218
+ gitea-cli tag delete <name> --force
219
+ ```
220
+
221
+ ### Actions (CI/CD)
222
+
223
+ ```bash
224
+ # Workflows
225
+ gitea-cli actions workflow list --output json
226
+ gitea-cli actions workflow get <id-or-filename> --output json
227
+ gitea-cli actions workflow enable <id-or-filename>
228
+ gitea-cli actions workflow disable <id-or-filename>
229
+ gitea-cli actions workflow dispatch <id-or-filename> --ref main --input key=value
230
+
231
+ # Runs
232
+ gitea-cli actions run list --status completed --output json
233
+ gitea-cli actions run get <run-id> --output json
234
+ gitea-cli actions run jobs <run-id> --output json
235
+ gitea-cli actions run artifacts <run-id> --output json
236
+ gitea-cli actions run delete <run-id> --force
237
+
238
+ # Jobs
239
+ gitea-cli actions job get <job-id> --output json
240
+ gitea-cli actions job logs <job-id> -o ./logs/
241
+
242
+ # Artifacts
243
+ gitea-cli actions artifact list --output json
244
+ gitea-cli actions artifact download <id> -o ./dist/
245
+ gitea-cli actions artifact delete <id> --force
246
+ ```
247
+
248
+ ### Webhook
249
+
250
+ ```bash
251
+ gitea-cli webhook list --output json
252
+ gitea-cli webhook get <id> --output json
253
+ gitea-cli webhook create --url <endpoint> --secret <secret> --event push --event issues --active
254
+ gitea-cli webhook update <id> --url <new-url> --active false
255
+ gitea-cli webhook delete <id> --force
256
+ gitea-cli webhook test <id>
257
+ ```
258
+
259
+ ### Release
260
+
261
+ ```bash
262
+ gitea-cli release list --output json
263
+ gitea-cli release get <tag> --output json
264
+ gitea-cli release create --tag <tag> --name "Title" --body "Notes" --target <ref> --draft --prerelease
265
+ gitea-cli release create --tag <tag> --body-file changelog.md # avoids encoding issues
266
+ gitea-cli release delete <tag> --force
267
+
268
+ # Assets
269
+ gitea-cli release asset list <tag> --output json
270
+ gitea-cli release asset upload <tag> <file> --name <asset-name>
271
+ gitea-cli release asset download <tag> <asset-id> -o ./downloads/
272
+ gitea-cli release asset delete <tag> <asset-id> --force
273
+ ```
package/assets/SKILL.md CHANGED
@@ -5,307 +5,86 @@ description: Use when needing to interact with Gitea repositories, branches, iss
5
5
 
6
6
  # gitea-cli
7
7
 
8
- ## Binary Location
9
-
10
- Binaries for all platforms are bundled under the `scripts/` directory relative to this skill:
8
+ Stateless CLI for Gitea HTTP API. Every call is an independent request, safe for concurrent use.
11
9
 
12
- | Platform | Relative Path |
13
- |----------|------|
14
- | Linux amd64 | `scripts/linux-amd64/gitea-cli` |
15
- | Linux arm64 | `scripts/linux-arm64/gitea-cli` |
16
- | macOS amd64 | `scripts/darwin-amd64/gitea-cli` |
17
- | macOS arm64 | `scripts/darwin-arm64/gitea-cli` |
18
- | Windows amd64 | `scripts/windows-amd64/gitea-cli.exe` |
19
- | Windows arm64 | `scripts/windows-arm64/gitea-cli.exe` |
10
+ ## Binary Location
20
11
 
21
- **Skill directory is `~/.claude/skills/gitea-cli/`.** Before executing commands, resolve `gitea-cli` to the platform-appropriate binary. Auto-detect with:
12
+ Resolve `gitea-cli` to the platform binary in skill directory `~/.claude/skills/gitea-cli/`:
22
13
 
23
14
  ```bash
24
- SKILL_DIR="$HOME/.claude/skills/gitea-cli"
25
-
26
15
  # Linux / macOS
16
+ SKILL_DIR="$HOME/.claude/skills/gitea-cli"
27
17
  OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
28
- ARCH="$(uname -m)"
29
- [[ "$ARCH" == "x86_64" ]] && ARCH="amd64"
30
- [[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]] && ARCH="arm64"
18
+ ARCH="$(uname -m)" && [[ "$ARCH" == "x86_64" ]] && ARCH="amd64" && [[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]] && ARCH="arm64"
31
19
  GITEA_CLI="$SKILL_DIR/scripts/${OS}-${ARCH}/gitea-cli"
32
-
33
- # Windows (PowerShell)
34
- # $GITEA_CLI = "$env:USERPROFILE\.claude\skills\gitea-cli\scripts\windows-amd64\gitea-cli.exe"
20
+ # Windows: %USERPROFILE%\.claude\skills\gitea-cli\scripts\windows-amd64\gitea-cli.exe
35
21
  ```
36
22
 
37
- If the tool is also available in PATH (e.g. installed globally), `gitea-cli` can be used directly.
38
-
39
- ## Overview
40
-
41
- `gitea-cli` is a stateless CLI tool that manages Gitea repositories through the HTTP API. Each call is an independent API request, making it safe for concurrent use. It supports both human-friendly table output and machine-friendly JSON output (`--output json`).
23
+ If available in PATH, `gitea-cli` can be used directly.
42
24
 
43
25
  ## Agent Rules
44
26
 
45
- ### 1. Always use JSON output
46
-
47
- ```bash
48
- gitea-cli <command> --output json --owner <owner> --repo <repo>
49
- ```
50
-
51
- ### 2. Never switch context autonomously
52
-
53
- Use `--owner`/`--repo` flags to target different repos. Do NOT call `config use` without user supervision.
54
-
55
- ### 3. Destructive operations require confirmation
56
-
57
- Always run a list/get command first to verify the target exists before deleting.
58
-
59
- ### 4. Branch/ref auto-detection
60
-
61
- When inside a git repo, `--branch` and `--ref` default to the current branch. `--owner`/`--repo` auto-detect from git remote.
27
+ 1. **Always `--output json`** — All calls must include this flag
28
+ 2. **Never switch context** — Use `--owner`/`--repo` flags; do NOT call `config use` autonomously
29
+ 3. **Verify before delete** — Run `list`/`get` first, then `--force` for non-interactive
30
+ 4. **Auto-detection** In a git repo, `--branch`/`--ref`/`--owner`/`--repo` auto-detect from `.git`
62
31
 
63
32
  ## Global Flags
64
33
 
65
34
  | Flag | Short | Description |
66
35
  |------|-------|-------------|
67
- | `--output` | `-o` | `json` or `table` (agents: always use `json`) |
68
- | `--owner` | | Repository owner |
69
- | `--repo` | `-r` | Repository name |
36
+ | `--output` | `-o` | `json` (agents: always) or `table` |
37
+ | `--owner` | | Repository owner (auto-detect from git) |
38
+ | `--repo` | `-r` | Repository name (auto-detect from git) |
70
39
  | `--context` | `-c` | Context name (override, no save) |
71
- | `--config` | | Config file path |
72
40
  | `--host` | | Gitea host URL |
73
41
  | `--token` | | API token |
74
42
 
75
- **Env vars:** `GITEA_HOST`, `GITEA_TOKEN`, `GITEA_OWNER`, `GITEA_REPO`, `GITEA_OUTPUT`
76
-
77
- ## Command Quick Reference
78
-
79
- ### Config
80
-
81
- ```bash
82
- gitea-cli config list # List all contexts
83
- gitea-cli config get <name> # Get context details
84
- gitea-cli config set --name <ctx> --host <url> --token <tok> # Create/update context
85
- ```
86
-
87
- ### Repository
88
-
89
- ```bash
90
- gitea-cli repo list --owner <org> --output json
91
- gitea-cli repo get --owner <org> --repo <repo> --output json
92
- ```
93
-
94
- ### Branch
95
-
96
- ```bash
97
- gitea-cli branch list --output json
98
- gitea-cli branch get <name> --output json
99
- gitea-cli branch create <name> --from <base>
100
- gitea-cli branch delete <name> --force
101
- gitea-cli branch protect list --output json
102
- gitea-cli branch protect create <name> --enable-push --required-approvals 2
103
- gitea-cli branch protect delete <name> --force
104
- ```
105
-
106
- ### File Content
107
-
108
- ```bash
109
- gitea-cli content list [--path] --ref <branch> --output json
110
- gitea-cli content get <path> --ref <branch> --output json # --raw for decoded content in json
111
- gitea-cli content create <path> --content "text" -m "msg" # or --file <local>
112
- gitea-cli content update <path> --content "text" -m "msg" # --sha auto-fetched
113
- gitea-cli content delete <path> -m "msg" --force
114
- ```
115
-
116
- ### Commit
117
-
118
- ```bash
119
- gitea-cli commit list --branch <ref> --limit 10 --output json
120
- gitea-cli commit get <sha> --output json
121
- ```
122
-
123
- ### Issue
124
-
125
- ```bash
126
- gitea-cli issue list --state open --output json
127
- gitea-cli issue get <number> --output json
128
- gitea-cli issue create -t "Title" -b "Body" --label <id> --milestone <id>
129
- gitea-cli issue create -t "Title" --attach ./image.png --attach ./log.txt # embed attachments in body
130
- gitea-cli issue update <number> -t "New Title" --state closed
131
- gitea-cli issue close <number>
132
-
133
- # Comments
134
- gitea-cli issue comment list <number> --output json
135
- gitea-cli issue comment create <number> -b "Comment text"
136
- gitea-cli issue comment update <comment-id> -b "Updated text"
137
- gitea-cli issue comment delete <comment-id> --force
138
-
139
- # Attachments
140
- gitea-cli issue attachment list <number> --output json
141
- gitea-cli issue attachment upload <number> <file> --name <filename>
142
- gitea-cli issue attachment download <number> <attach-id> -o ./save/
143
- gitea-cli issue attachment delete <number> <attach-id> --force
144
- ```
145
-
146
- ### Pull Request
147
-
148
- ```bash
149
- gitea-cli pr list --state open --output json
150
- gitea-cli pr get <index> --output json
151
- gitea-cli pr create --title "Title" --head <src> --base <target> --body "Desc"
152
- gitea-cli pr close <index>
153
- gitea-cli pr reopen <index>
154
- gitea-cli pr merge <index> --strategy merge --delete-branch
155
- ```
156
-
157
- ### Label
158
-
159
- ```bash
160
- gitea-cli label list --output json
161
- gitea-cli label get <id> --output json
162
- gitea-cli label create --name "bug" --color "#ff0000" --description "Bug report"
163
- gitea-cli label delete <id> --force
164
- ```
165
-
166
- ### Milestone
167
-
168
- ```bash
169
- gitea-cli milestone list --state open --output json
170
- gitea-cli milestone get <id> --output json
171
- gitea-cli milestone create --title "v1.0" --description "First release" --due-on 2025-12-31T00:00:00Z
172
- gitea-cli milestone close <id>
173
- gitea-cli milestone delete <id> --force
174
- ```
175
-
176
- ### Tag
177
-
178
- ```bash
179
- gitea-cli tag list --output json
180
- gitea-cli tag get <name> --output json
181
- gitea-cli tag create <name> --target <ref> -m "Annotated tag message"
182
- gitea-cli tag delete <name> --force
183
- ```
184
-
185
- ### Actions (CI/CD)
186
-
187
- ```bash
188
- # Workflows
189
- gitea-cli actions workflow list --output json
190
- gitea-cli actions workflow get <id-or-filename> --output json
191
- gitea-cli actions workflow enable <id-or-filename>
192
- gitea-cli actions workflow disable <id-or-filename>
193
- gitea-cli actions workflow dispatch <id-or-filename> --ref main --input key=value
194
-
195
- # Runs
196
- gitea-cli actions run list --status completed --output json
197
- gitea-cli actions run get <run-id> --output json
198
- gitea-cli actions run jobs <run-id> --output json
199
- gitea-cli actions run artifacts <run-id> --output json
200
- gitea-cli actions run delete <run-id> --force
43
+ Env vars: `GITEA_HOST`, `GITEA_TOKEN`, `GITEA_OWNER`, `GITEA_REPO`
201
44
 
202
- # Jobs
203
- gitea-cli actions job get <job-id> --output json
204
- gitea-cli actions job logs <job-id> -o ./logs/
45
+ ## Command Summary
205
46
 
206
- # Artifacts
207
- gitea-cli actions artifact list --output json
208
- gitea-cli actions artifact download <id> -o ./dist/
209
- gitea-cli actions artifact delete <id> --force
210
47
  ```
211
-
212
- ### Webhook
213
-
214
- ```bash
215
- gitea-cli webhook list --output json
216
- gitea-cli webhook get <id> --output json
217
- gitea-cli webhook create --url <endpoint> --secret <secret> --event push --event issues --active
218
- gitea-cli webhook update <id> --url <new-url> --active false
219
- gitea-cli webhook delete <id> --force
220
- gitea-cli webhook test <id>
48
+ config set/list/get/use — Context configuration
49
+ issue list/get/create/update/close — Issues + comments + attachments
50
+ pr list/get/create/close/reopen/merge — Pull requests
51
+ branch list/get/create/delete — Branches + protection rules
52
+ content list/get/create/update/delete Repo file CRUD
53
+ commit list/get Commit history
54
+ label list/get/create/delete — Labels
55
+ milestone list/get/create/close/delete Milestones
56
+ tag list/get/create/delete Tags
57
+ release list/get/create/delete — Releases + assets
58
+ actions workflow/run/job/artifact — CI/CD management
59
+ webhook list/get/create/update/delete/test — Webhooks
221
60
  ```
222
61
 
223
- ### Release
62
+ ## Common Workflows
224
63
 
225
- ```bash
226
- gitea-cli release list --output json
227
- gitea-cli release get <tag> --output json
228
- gitea-cli release create --tag <tag> --name "Title" --body "Notes" --target <ref> --draft --prerelease
229
- gitea-cli release create --tag <tag> --body-file changelog.md # use file for release notes (avoids encoding issues)
230
- gitea-cli release delete <tag> --force
231
-
232
- # Assets
233
- gitea-cli release asset list <tag> --output json
234
- gitea-cli release asset upload <tag> <file> --name <asset-name>
235
- gitea-cli release asset download <tag> <asset-id> -o ./downloads/
236
- gitea-cli release asset delete <tag> <asset-id> --force
237
- ```
64
+ When performing a task, follow the matching workflow. Read `REFERENCE.md` in the same skill directory for full command details and flags.
238
65
 
239
- ## Common Patterns
66
+ **Issue** `issue list` → `issue get <n>` → `comment create <n>` → `issue close <n>`
67
+ **PR** — `branch create <name> --from <base>` → `pr create` → `actions run list` → `pr merge <idx>`
68
+ **Release** — `tag create <v>` → `release create --tag <v>` → `release asset upload <v> <file>`
69
+ **CI/CD** — `actions run list` → `actions run jobs <run>` → `actions job logs <job>`
70
+ **File edit** — `content get <path>` → `content update <path> --content "..." -m "msg"`
71
+ **Config** — `config set --name <ctx> --host <url> --token <tok>`
240
72
 
241
- ### Read file from repo, modify, write back
242
-
243
- ```bash
244
- # 1. Get current content (captures SHA for update)
245
- gitea-cli content get src/config.yaml --output json --owner myorg --repo myrepo
73
+ ## Error Handling
246
74
 
247
- # 2. Update with new content (SHA auto-fetched if omitted)
248
- gitea-cli content update src/config.yaml --content "new: value" -m "update config" --owner myorg --repo myrepo
249
- ```
75
+ | Error | Fix |
76
+ |-------|-----|
77
+ | `host is required` | Run `config set` |
78
+ | `API 404` | Verify owner/repo/index |
79
+ | `API 409` | Already exists, skip |
80
+ | `API 401` | Check token |
250
81
 
251
- ### Create issue with labels and milestone
82
+ Destructive ops: always `list`/`get` first, then `--force`. Deleted resources cannot be recovered.
252
83
 
253
- ```bash
254
- # 1. Find label IDs
255
- gitea-cli label list --output json --owner myorg --repo myrepo
84
+ ## On-Demand Reference
256
85
 
257
- # 2. Find milestone ID
258
- gitea-cli milestone list --output json --owner myorg --repo myrepo
86
+ For full command flags and detailed workflow steps, read the reference file:
259
87
 
260
- # 3. Create issue
261
- gitea-cli issue create -t "Fix login bug" -b "Description" --label 3 --label 7 --milestone 2 --owner myorg --repo myrepo
262
88
  ```
263
-
264
- ### Create issue with attachments
265
-
266
- ```bash
267
- # Attach images (auto-embedded as markdown images) and files (embedded as links)
268
- gitea-cli issue create -t "Bug screenshot" -b "Steps to reproduce..." \
269
- --attach ./screenshot.png --attach ./error.log --owner myorg --repo myrepo
270
-
271
- # Supported image formats: png, jpg, jpeg, gif, webp, bmp, svg
272
- # Other file types are embedded as download links
89
+ ~/.claude/skills/gitea-cli/REFERENCE.md
273
90
  ```
274
-
275
- ### Monitor CI/CD pipeline
276
-
277
- ```bash
278
- # 1. Find latest run
279
- gitea-cli actions run list --limit 5 --output json
280
-
281
- # 2. Check job status
282
- gitea-cli actions run jobs <run-id> --output json
283
-
284
- # 3. Get logs for failed job
285
- gitea-cli actions job logs <job-id> -o ./logs/
286
- ```
287
-
288
- ## Error Handling
289
-
290
- | Exit Code | Meaning |
291
- |-----------|---------|
292
- | `0` | Success |
293
- | `1` | Error (see stderr) |
294
-
295
- JSON errors on stderr: `{"error": "API 404: repository not found"}`
296
-
297
- | Error | Cause | Fix |
298
- |-------|-------|-----|
299
- | `host is required` | No context configured | Run `config set` |
300
- | `API 404` | Resource not found | Verify owner/repo/index |
301
- | `API 409` | Resource already exists | Skip duplicate creation |
302
- | `API 401` | Invalid/expired token | Check context token |
303
-
304
- ## Destructive Operations Checklist
305
-
306
- Before running any delete, always verify:
307
-
308
- 1. Run the corresponding `list` or `get` command first
309
- 2. Confirm the resource ID/name matches the intended target
310
- 3. Use `--force` flag to skip interactive prompts (required for agent use)
311
- 4. Consider irreversibility — deleted resources cannot be recovered
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitea-cli-skill",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Install gitea-cli as a Claude Code skill",
5
5
  "bin": {
6
6
  "gitea-cli-skill": "src/index.js"
package/src/index.js CHANGED
@@ -65,6 +65,15 @@ function resolveSkillDir(platformName, targetPath) {
65
65
  return path.join(os.homedir(), PLATFORMS.claude.dir, SKILL_NAME);
66
66
  }
67
67
 
68
+ // ── Find gitea-cli binary for the given platform ────────────────────────────
69
+
70
+ function findGiteaCliBin(platformName, targetPath) {
71
+ const osArch = detectOSArch();
72
+ const binaryName = osArch.os === 'windows' ? 'gitea-cli.exe' : 'gitea-cli';
73
+ const skillDir = resolveSkillDir(platformName, targetPath);
74
+ return path.join(skillDir, 'scripts', `${osArch.os}-${osArch.arch}`, binaryName);
75
+ }
76
+
68
77
  // ── HTTP via curl (robust cross-platform) ───────────────────────────────────
69
78
 
70
79
  function curlGet(url, token) {
@@ -132,39 +141,27 @@ function extractArchive(archivePath, destDir, osArch) {
132
141
  throw new Error(`Binary ${binaryName} not found in extracted archive`);
133
142
  }
134
143
 
135
- // ── Config generation ───────────────────────────────────────────────────────
144
+ // ── Config via gitea-cli ────────────────────────────────────────────────────
136
145
 
137
- function writeGiteaCliConfig(host, token) {
138
- const configDir = path.join(os.homedir(), '.config', 'gitea-cli');
139
- const configPath = path.join(configDir, 'config.yaml');
140
- const contextName = 'default';
141
-
142
- // Read existing config if present
143
- let existing = '';
144
- if (fs.existsSync(configPath)) {
145
- existing = fs.readFileSync(configPath, 'utf-8');
146
- if (existing.includes(contextName)) {
147
- console.log(` Config already exists: ${configPath} (skipped)`);
148
- return;
149
- }
150
- }
151
-
152
- const newConfig = `${existing}contexts:
153
- - name: ${contextName}
154
- host: ${host.replace(/\/$/, '')}
155
- token: ${token}
156
- current-context: ${contextName}
157
- `;
146
+ function configureContext({ giteaCliBin, host, token, contextName, defaultOwner, defaultRepo }) {
147
+ const ctxName = contextName || 'default';
148
+ const cmdArgs = [
149
+ `"${giteaCliBin}"`,
150
+ 'config', 'set',
151
+ '--name', ctxName,
152
+ '--host', host.replace(/\/$/, ''),
153
+ '--token', token,
154
+ ];
155
+ if (defaultOwner) cmdArgs.push('--default-owner', defaultOwner);
156
+ if (defaultRepo) cmdArgs.push('--default-repo', defaultRepo);
158
157
 
159
- fs.mkdirSync(configDir, { recursive: true });
160
- fs.writeFileSync(configPath, newConfig, 'utf-8');
161
- console.log(` Config -> ${configPath}`);
158
+ execSync(cmdArgs.join(' '), { stdio: 'inherit', timeout: 10000 });
162
159
  }
163
160
 
164
161
  // ── Install command ─────────────────────────────────────────────────────────
165
162
 
166
163
  async function install(args) {
167
- const { token: explicitToken, host: explicitHost, platform: platformName, target: targetPath, local: localDir, force } = args;
164
+ const { token: explicitToken, host: explicitHost, platform: platformName, target: targetPath, local: localDir, force, name: contextName, 'default-owner': defaultOwner, 'default-repo': defaultRepo } = args;
168
165
  const giteaHost = explicitHost || GITEA_HOST;
169
166
  const token = explicitToken || process.env.GITEA_TOKEN || null;
170
167
  const osArch = detectOSArch();
@@ -188,15 +185,26 @@ async function install(args) {
188
185
  console.log(` Binary already exists: ${destBinary} (use --force to overwrite)`);
189
186
  } else if (localDir) {
190
187
  // --local: copy from local directory
191
- await installFromLocal(localDir, scriptsDir, destBinary, osArch);
188
+ installFromLocal(localDir, scriptsDir, destBinary, osArch);
192
189
  } else {
193
190
  // Download from Gitea releases
194
191
  await installFromRelease(giteaHost, token, scriptsDir, destBinary, osArch);
195
192
  }
196
193
 
197
- // 4. Write gitea-cli config if token provided
194
+ // 3. Configure context if token provided
198
195
  if (token) {
199
- writeGiteaCliConfig(giteaHost, token);
196
+ const giteaCliBin = findGiteaCliBin(platformName, targetPath);
197
+ if (fs.existsSync(giteaCliBin)) {
198
+ console.log(' Configuring context...');
199
+ try {
200
+ configureContext({ giteaCliBin, host: giteaHost, token, contextName, defaultOwner, defaultRepo });
201
+ } catch (err) {
202
+ console.error(` Failed to configure context: ${err.message}`);
203
+ console.error(' You can manually run: gitea-cli config set --name default --host <url> --token <token>');
204
+ }
205
+ } else {
206
+ console.log(' Binary not found for context setup, skipping.');
207
+ }
200
208
  }
201
209
 
202
210
  console.log(`\nDone!`);
@@ -207,7 +215,6 @@ async function install(args) {
207
215
  function installFromLocal(localDir, scriptsDir, destBinary, osArch) {
208
216
  // Goreleaser dist structure: dist/gitea-cli_<version>_<os>_<arch>/gitea-cli[.exe]
209
217
  const ext = osArch.os === 'windows' ? 'zip' : 'tar.gz';
210
- const archiveName = `gitea-cli_*_${osArch.os}_${osArch.arch}.${ext}`;
211
218
 
212
219
  const resolvedDir = localDir.replace(/^~/, os.homedir());
213
220
 
@@ -294,7 +301,7 @@ async function installFromRelease(giteaHost, token, scriptsDir, destBinary, osAr
294
301
  // ── Context command ─────────────────────────────────────────────────────────
295
302
 
296
303
  async function addContext(args) {
297
- const { token: explicitToken, host: explicitHost, 'default-owner': defaultOwner, 'default-repo': defaultRepo, name: contextName } = args;
304
+ const { token: explicitToken, host: explicitHost, platform: platformName, target: targetPath, 'default-owner': defaultOwner, 'default-repo': defaultRepo, name: contextName } = args;
298
305
  const host = explicitHost || GITEA_HOST;
299
306
  const token = explicitToken || process.env.GITEA_TOKEN || null;
300
307
 
@@ -307,40 +314,14 @@ async function addContext(args) {
307
314
  process.exit(1);
308
315
  }
309
316
 
310
- // Find the installed gitea-cli binary
311
- const osArch = detectOSArch();
312
- const binaryName = osArch.os === 'windows' ? 'gitea-cli.exe' : 'gitea-cli';
313
- const skillDir = path.join(os.homedir(), PLATFORMS.claude.dir, SKILL_NAME);
314
- const giteaCliBin = path.join(skillDir, 'scripts', `${osArch.os}-${osArch.arch}`, binaryName);
317
+ const giteaCliBin = findGiteaCliBin(platformName, targetPath);
315
318
 
316
319
  if (!fs.existsSync(giteaCliBin)) {
317
- // Fallback: write config manually
318
- console.log(' gitea-cli binary not found, writing config directly...');
319
- writeGiteaCliConfig(host, token);
320
- console.log('Context configured successfully.');
321
- return;
322
- }
323
-
324
- // Use gitea-cli config set for proper config management
325
- const ctxName = contextName || 'default';
326
- const cmdArgs = [
327
- `"${giteaCliBin}"`,
328
- 'config', 'set',
329
- '--name', ctxName,
330
- '--host', host.replace(/\/$/, ''),
331
- '--token', token,
332
- ];
333
- if (defaultOwner) cmdArgs.push('--default-owner', defaultOwner);
334
- if (defaultRepo) cmdArgs.push('--default-repo', defaultRepo);
335
-
336
- try {
337
- execSync(cmdArgs.join(' '), { stdio: 'inherit', timeout: 10000 });
338
- } catch (err) {
339
- console.error(`Failed to configure context: ${err.message}`);
340
- console.error('You can manually run:');
341
- console.error(` ${cmdArgs.join(' ')}`);
320
+ console.error('Error: gitea-cli binary not found. Run `npx gitea-cli-skill init` first.');
342
321
  process.exit(1);
343
322
  }
323
+
324
+ configureContext({ giteaCliBin, host, token, contextName, defaultOwner, defaultRepo });
344
325
  }
345
326
 
346
327
  // ── CLI ──────────────────────────────────────────────────────────────────────
@@ -374,49 +355,56 @@ function printHelp() {
374
355
  console.log(`gitea-cli-skill - Install gitea-cli as an AI agent skill
375
356
 
376
357
  Usage:
377
- npx gitea-cli-skill init [flags] # Install skill
378
- gitea-cli-skill add context [flags] # Configure Gitea API context
358
+ npx gitea-cli-skill init [flags] # Install + configure
359
+ gitea-cli-skill add context [flags] # Update context only
379
360
 
380
361
  Commands:
381
- init Install skill (download binary + SKILL.md)
362
+ init Install skill (binary + SKILL.md) and optionally configure context
382
363
  add context Add or update a Gitea API context (requires --token)
383
364
 
384
365
  Flags (init):
385
- --token <t> Gitea API token (needed for private repos, or set GITEA_TOKEN env var)
386
- --host <url> Gitea host URL (default: ${GITEA_HOST})
387
- --local <dir> Install from local goreleaser dist directory (skip download)
388
- --platform <name> Target AI platform (default: claude)
389
- --target <path> Custom install directory (overrides --platform)
390
- --force Overwrite existing binary
366
+ --token <t> Gitea API token (needed for private repos, enables auto-config)
367
+ --host <url> Gitea host URL (default: ${GITEA_HOST})
368
+ --local <dir> Install from local goreleaser dist directory (skip download)
369
+ --platform <name> Target AI platform (default: claude)
370
+ --target <path> Custom install directory (overrides --platform)
371
+ --name <name> Context name for auto-config (default: "default")
372
+ --default-owner <owner> Default owner for auto-config (optional)
373
+ --default-repo <repo> Default repo for auto-config (optional)
374
+ --force Overwrite existing binary
391
375
 
392
376
  Flags (add context):
393
- --name <name> Context name (default: "default")
394
- --host <url> Gitea host URL (required)
395
- --token <t> Gitea API token (required, or set GITEA_TOKEN env var)
396
- --default-owner <owner> Default repository owner (optional)
397
- --default-repo <repo> Default repository name (optional)
377
+ --name <name> Context name (default: "default")
378
+ --host <url> Gitea host URL (required)
379
+ --token <t> Gitea API token (required, or set GITEA_TOKEN env var)
380
+ --default-owner <owner> Default repository owner (optional)
381
+ --default-repo <repo> Default repository name (optional)
382
+ --platform <name> AI platform to locate binary (default: claude)
398
383
 
399
384
  Global:
400
- -h, --help Show this help
385
+ -h, --help Show this help
401
386
 
402
387
  Platforms:
403
388
  ${platformList}
404
389
 
405
390
  Examples:
406
- # Step 1: Install the skill (no token needed for public repos)
407
- npx gitea-cli-skill init
391
+ # One-step install + configure (recommended)
392
+ npx gitea-cli-skill init --host https://gitea.example.com --token abc123
408
393
 
409
- # Step 2: Configure context
410
- gitea-cli-skill add context --host https://gitea.example.com --token abc123
394
+ # With default owner
395
+ npx gitea-cli-skill init --host https://gitea.example.com --token abc123 --default-owner myorg
411
396
 
412
- # Configure context with all options
413
- gitea-cli-skill add context --name work --host https://gitea.example.com --token abc123 --default-owner myorg
397
+ # Install only (public repo, no token needed)
398
+ npx gitea-cli-skill init
414
399
 
415
- # Or install + configure in one step (for private repos)
416
- npx gitea-cli-skill init --token abc123
400
+ # Update context later
401
+ gitea-cli-skill add context --host https://gitea.example.com --token new-token
417
402
 
418
- # Or install from local build
403
+ # Install from local build
419
404
  npx gitea-cli-skill init --local ../dist
405
+
406
+ # Install for another AI platform
407
+ npx gitea-cli-skill init --platform cursor --host https://gitea.example.com --token abc123
420
408
  `);
421
409
  }
422
410