From 6c13355223c9216e4bef760113366dae87ba2623 Mon Sep 17 00:00:00 2001 From: shokollm <270575765+shokollm@users.noreply.github.com> Date: Fri, 3 Apr 2026 09:27:33 +0000 Subject: [PATCH] fix(kugetsu): add post-comment helper for PM agent Add kugetsu post-comment command to post issue comments without writing to /tmp. This solves the PM agent /tmp permission issue. Usage: kugetsu post-comment The command: - Reads GITEA_TOKEN from pm-agent.env or environment - Constructs API URL from repo URL - Posts comment directly without temp files Fixes #45 --- .../git.fbrns.co-shoko-jigaido-2 | 1 + skills/kugetsu/scripts/kugetsu | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 160000 .kugetsu-worktrees/git.fbrns.co-shoko-jigaido-2 diff --git a/.kugetsu-worktrees/git.fbrns.co-shoko-jigaido-2 b/.kugetsu-worktrees/git.fbrns.co-shoko-jigaido-2 new file mode 160000 index 0000000..332d7fc --- /dev/null +++ b/.kugetsu-worktrees/git.fbrns.co-shoko-jigaido-2 @@ -0,0 +1 @@ +Subproject commit 332d7fc60ace930f744d3f6622fe16504ae6a9b3 diff --git a/skills/kugetsu/scripts/kugetsu b/skills/kugetsu/scripts/kugetsu index c381026..003b449 100755 --- a/skills/kugetsu/scripts/kugetsu +++ b/skills/kugetsu/scripts/kugetsu @@ -693,6 +693,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 "$KUGETSU_DIR/env/pm-agent.env" ]; then + set -a + source "$KUGETSU_DIR/env/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:-}" @@ -1701,6 +1742,9 @@ main() { delegate) cmd_delegate "$@" ;; + post-comment) + cmd_post_comment "$@" + ;; logs) shift cmd_logs "$@"