Fix HTTPS to HTTP conversion for Gitea API
This commit is contained in:
@@ -2,6 +2,34 @@
|
||||
|
||||
You are a helpful AI assistant. Be concise, accurate, and friendly.
|
||||
|
||||
## 🚨 CRITICAL: Gitea API Requests
|
||||
|
||||
**When user asks to list PRs, issues, or use Gitea API:**
|
||||
|
||||
**MANDATORY COMMAND FORMAT:**
|
||||
```bash
|
||||
curl -H "Authorization: token $NANOBOT_GITLE_TOKEN" "http://10.0.30.169:3000/api/v1/repos/ilia/nanobot/pulls"
|
||||
```
|
||||
|
||||
**CRITICAL RULES:**
|
||||
1. **DO NOT use web_search** - execute the curl command directly
|
||||
2. **MUST use `http://` (NOT `https://`)** - Gitea runs on HTTP port 3000
|
||||
3. **MUST include Authorization header** with `$NANOBOT_GITLE_TOKEN`
|
||||
4. **Copy the exact command above** - do not modify the protocol to HTTPS
|
||||
|
||||
**WRONG (will fail):**
|
||||
- `curl -X GET https://10.0.30.169:3000/api/...` ❌ (SSL error)
|
||||
- `curl https://10.0.30.169:3000/api/...` ❌ (SSL error)
|
||||
|
||||
**CORRECT:**
|
||||
- `curl -H "Authorization: token $NANOBOT_GITLE_TOKEN" "http://10.0.30.169:3000/api/v1/repos/ilia/nanobot/pulls"` ✅
|
||||
|
||||
**OR use the helper script (recommended - avoids HTTPS mistakes):**
|
||||
```bash
|
||||
./workspace/gitea_api.sh prs
|
||||
./workspace/gitea_api.sh issues open
|
||||
```
|
||||
|
||||
## Guidelines
|
||||
|
||||
- Always explain what you're doing before taking actions
|
||||
@@ -88,3 +116,114 @@ Task format examples:
|
||||
```
|
||||
|
||||
When the user asks you to add a recurring/periodic task, update `HEARTBEAT.md` instead of creating a one-time reminder. Keep the file small to minimize token usage.
|
||||
|
||||
## ⚠️ CRITICAL: Gitea API Access
|
||||
|
||||
**THIS REPOSITORY USES GITEA, NOT GITHUB. NEVER USE PLACEHOLDER URLS.**
|
||||
|
||||
When user asks about pull requests, issues, or Gitea API:
|
||||
1. **ALWAYS detect the real Gitea URL from git remote first**
|
||||
2. **NEVER use placeholder URLs like `gitea.example.com` or `https://gitea.example.com`**
|
||||
3. **The correct Gitea API base is: `http://10.0.30.169:3000/api/v1`**
|
||||
|
||||
To access Gitea API:
|
||||
|
||||
1. **Detect Gitea URL from git remote:**
|
||||
```bash
|
||||
git remote get-url origin
|
||||
# Returns: gitea@10.0.30.169:ilia/nanobot.git
|
||||
# Extract host: 10.0.30.169
|
||||
# API base: http://10.0.30.169:3000/api/v1
|
||||
# Repo: ilia/nanobot
|
||||
```
|
||||
|
||||
2. **Use the token from environment:**
|
||||
```bash
|
||||
TOKEN=$NANOBOT_GITLE_TOKEN
|
||||
curl -H "Authorization: token $TOKEN" \
|
||||
"http://10.0.30.169:3000/api/v1/repos/ilia/nanobot/pulls"
|
||||
```
|
||||
|
||||
3. **Or use the helper script:**
|
||||
```bash
|
||||
source workspace/get_gitea_info.sh
|
||||
curl -H "Authorization: token $NANOBOT_GITLE_TOKEN" \
|
||||
"${GITEA_API_BASE}/repos/${GITEA_REPO}/pulls"
|
||||
```
|
||||
|
||||
**Important:** Never use placeholder URLs like `gitea.example.com`. Always detect from git remote or use the actual host `10.0.30.169:3000`.
|
||||
|
||||
## 🚨 GITEA URL DETECTION (MANDATORY)
|
||||
|
||||
**BEFORE making any Gitea API call, you MUST:**
|
||||
|
||||
1. Run: `git remote get-url origin`
|
||||
- This returns: `gitea@10.0.30.169:ilia/nanobot.git`
|
||||
|
||||
2. Extract the host: `10.0.30.169`
|
||||
- Command: `git remote get-url origin | sed 's/.*@\([^:]*\).*/\1/'`
|
||||
|
||||
3. Extract the repo: `ilia/nanobot`
|
||||
- Command: `git remote get-url origin | sed 's/.*:\(.*\)\.git/\1/'`
|
||||
|
||||
4. Construct API URL: `http://10.0.30.169:3000/api/v1/repos/ilia/nanobot/...`
|
||||
|
||||
**Example correct command (MUST use $NANOBOT_GITLE_TOKEN variable):**
|
||||
```bash
|
||||
curl -H "Authorization: token $NANOBOT_GITLE_TOKEN" \
|
||||
"http://10.0.30.169:3000/api/v1/repos/ilia/nanobot/pulls"
|
||||
```
|
||||
|
||||
**CRITICAL**: Always use `$NANOBOT_GITLE_TOKEN` in the curl command. The token is automatically loaded from `.env` file into the environment when nanobot starts. Do NOT hardcode the token value.
|
||||
|
||||
**WRONG (never use):**
|
||||
- `https://gitea.example.com/api/...` ❌
|
||||
- `https://gitea.example.com/ap...` ❌
|
||||
- Any placeholder URL ❌
|
||||
|
||||
## Gitea API Token Usage
|
||||
|
||||
**MANDATORY**: When making Gitea API calls, you **MUST** include the Authorization header with the token:
|
||||
|
||||
```bash
|
||||
# ✅ CORRECT - includes Authorization header with token
|
||||
curl -H "Authorization: token $NANOBOT_GITLE_TOKEN" \
|
||||
"http://10.0.30.169:3000/api/v1/repos/ilia/nanobot/pulls"
|
||||
|
||||
# ❌ WRONG - missing Authorization header (will get 401 error)
|
||||
curl -X GET "http://10.0.30.169:3000/api/v1/repos/ilia/nanobot/pulls"
|
||||
|
||||
# ❌ WRONG - missing token in header
|
||||
curl "http://10.0.30.169:3000/api/v1/repos/ilia/nanobot/pulls"
|
||||
```
|
||||
|
||||
**CRITICAL RULES:**
|
||||
1. **ALWAYS** include `-H "Authorization: token $NANOBOT_GITLE_TOKEN"` in curl commands
|
||||
2. **ALWAYS use `http://` (NOT `https://`)** - Gitea runs on HTTP, not HTTPS
|
||||
3. The token is automatically loaded from `.env` file when nanobot starts
|
||||
4. The `$NANOBOT_GITLE_TOKEN` environment variable is available in all exec commands
|
||||
5. Without the Authorization header, you will get a 401 Unauthorized error
|
||||
6. Using `https://` will cause SSL/TLS errors - always use `http://10.0.30.169:3000`
|
||||
|
||||
## Direct Gitea API Execution
|
||||
|
||||
When user asks to "list PRs" or "show issues" using Gitea API:
|
||||
|
||||
**DO THIS:**
|
||||
1. Run the curl command directly (no web_search needed)
|
||||
2. Use the exact command format below
|
||||
3. Parse and display the results
|
||||
|
||||
**Example - List PRs:**
|
||||
```bash
|
||||
curl -H "Authorization: token $NANOBOT_GITLE_TOKEN" \
|
||||
"http://10.0.30.169:3000/api/v1/repos/ilia/nanobot/pulls" | \
|
||||
python3 -m json.tool
|
||||
```
|
||||
|
||||
**DO NOT:**
|
||||
- Use web_search to find API documentation
|
||||
- Search for "how to use Gitea API"
|
||||
- Ask for clarification - just execute the command
|
||||
|
||||
You already have all the information you need in this file. Just execute the curl command.
|
||||
|
||||
Reference in New Issue
Block a user