From 075fe24a031f54955b53f851ac56f99ef7c29824 Mon Sep 17 00:00:00 2001 From: shokollm <270575765+shokollm@users.noreply.github.com> Date: Thu, 2 Apr 2026 01:00:17 +0000 Subject: [PATCH] fix(kugetsu): add kugetsu post-comment helper for PM agent Add cmd_post_comment command for posting Gitea comments without needing to write temp files. This solves the /tmp permission issue where PM agent was blocked from writing to /tmp. Usage: kugetsu post-comment Example: kugetsu post-comment https://git.fbrns.co/shoko/kugetsu 81 "Comment text" The command: - Reads GITEA_TOKEN from environment or pm-agent.env - Constructs the API URL from repo URL - Posts comment directly without temp files Fixes #45 --- skills/kugetsu/scripts/kugetsu | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/skills/kugetsu/scripts/kugetsu b/skills/kugetsu/scripts/kugetsu index 29348bc..b541d76 100755 --- a/skills/kugetsu/scripts/kugetsu +++ b/skills/kugetsu/scripts/kugetsu @@ -593,6 +593,47 @@ cmd_logs() { done } +cmd_post_comment() { + local repo_url="${1:-}" + local issue_or_pr="${2:-}" + local body="${3:-}" + + if [ -z "$repo_url" ] || [ -z "$issue_or_pr" ] || [ -z "$body" ]; then + echo "Usage: kugetsu post-comment " >&2 + echo "Example: kugetsu post-comment https://git.fbrns.co/shoko/kugetsu 81 \"Comment text\"" >&2 + exit 1 + fi + + local token="${GITEA_TOKEN:-}" + if [ -z "$token" ]; then + if [ -f "$ENV_DIR/pm-agent.env" ]; then + set -a + source "$ENV_DIR/pm-agent.env" + set +a + fi + token="${GITEA_TOKEN:-}" + fi + + if [ -z "$token" ]; then + echo "Error: GITEA_TOKEN not set" >&2 + exit 1 + fi + + local api_url="${repo_url%.git}/issues/${issue_or_pr}/comments" + + curl -s -X POST "$api_url" \ + -H "Authorization: token $token" \ + -H "Content-Type: application/json" \ + -d "$(printf '{"body":%s}' "$(echo "$body" | python3 -c 'import sys,json; print(json.dumps(sys.stdin.read()))')")" + + if [ $? -eq 0 ]; then + echo "Comment posted successfully" + else + echo "Error: Failed to post comment" >&2 + exit 1 + fi +} + cmd_env() { local action="${1:-}" local agent_type="${2:-}" @@ -1463,6 +1504,9 @@ main() { shift cmd_logs "$@" ;; + post-comment) + cmd_post_comment "$@" + ;; status) cmd_status ;; -- 2.49.1