fix(kugetsu): add kugetsu post-comment helper for PM agent #94

Closed
shoko wants to merge 1 commits from fix/issue-45-post-comment-v2 into main
Owner

Summary

Fix for #45 - PM agent cannot write to /tmp for comment posting.

Problem

PM agent tried to use write_file to create temp files in /tmp, but opencode blocks /tmp/* access in headless mode.

Solution

Add kugetsu post-comment command that posts Gitea comments directly without needing temp files.

Usage

kugetsu post-comment <repo-url> <issue-or-pr-number> <body>

# 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

## Summary Fix for #45 - PM agent cannot write to /tmp for comment posting. ## Problem PM agent tried to use `write_file` to create temp files in /tmp, but opencode blocks `/tmp/*` access in headless mode. ## Solution Add `kugetsu post-comment` command that posts Gitea comments directly without needing temp files. ## Usage ```bash kugetsu post-comment <repo-url> <issue-or-pr-number> <body> # 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
shoko added 1 commit 2026-04-02 03:00:31 +02:00
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 <repo-url> <issue-or-pr-number> <body>

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
First-time contributor

if we merged #92 or #93, does this PR is still necessary?

if we merged #92 or #93, does this PR is still necessary?
Author
Owner

Yes, #94 is still necessary independently. It serves a different purpose:

  • #92 (KUGETSU_TEMP_DIR): Controls where temp files are stored for subagent workflows
  • #93 (fix_session_permissions): Fixes permission issues when forking sessions
  • #94 (post-comment helper): Provides a CLI helper for the PM agent to post comments on issues/PRs

The post-comment helper is a tool/command that the PM agent can use to communicate back to the issue. Its not related to temp dirs or permissions.

It would be useful if the PM agent could append its output/context to the issue as a comment for transparency and for the user to track progress.

Yes, #94 is still necessary independently. It serves a different purpose: - #92 (KUGETSU_TEMP_DIR): Controls where temp files are stored for subagent workflows - #93 (fix_session_permissions): Fixes permission issues when forking sessions - #94 (post-comment helper): Provides a CLI helper for the PM agent to post comments on issues/PRs The post-comment helper is a tool/command that the PM agent can use to communicate back to the issue. Its not related to temp dirs or permissions. It would be useful if the PM agent could append its output/context to the issue as a comment for transparency and for the user to track progress.
First-time contributor

why do we need a specific tool/command when the PM agent can just write a file in a temporary directory now (thanks to #92)? what if we have 100 git servers, do we have to add 100 commands?

why do we need a specific tool/command when the PM agent can just write a file in a temporary directory now (thanks to #92)? what if we have 100 git servers, do we have to add 100 commands?
Author
Owner

You make a fair point! With #92, the PM agent can write files to temp directory.

However, kugetsu post-comment provides:

  1. A CLI interface for the PM agent to post comments without knowing curl/API details
  2. Token management (reads from GITEA_TOKEN in pm-agent.env)
  3. Proper API URL construction from repo URL

But youre right - for 100 git servers, wed need different commands or make it more generic. We could:

  1. Keep it as a helper but make it more generic (accept any API URL)
  2. Deprecate it in favor of the PM agent writing to a file and a human posting
  3. Have the PM agent use the API directly with its token

Option 3 seems cleanest - the PM agent has GITEA_TOKEN and can use curl directly. Want me to close this PR in favor of that approach?

You make a fair point! With #92, the PM agent can write files to temp directory. However, `kugetsu post-comment` provides: 1. A CLI interface for the PM agent to post comments without knowing curl/API details 2. Token management (reads from GITEA_TOKEN in pm-agent.env) 3. Proper API URL construction from repo URL But youre right - for 100 git servers, wed need different commands or make it more generic. We could: 1. Keep it as a helper but make it more generic (accept any API URL) 2. Deprecate it in favor of the PM agent writing to a file and a human posting 3. Have the PM agent use the API directly with its token Option 3 seems cleanest - the PM agent has GITEA_TOKEN and can use curl directly. Want me to close this PR in favor of that approach?
shoko closed this pull request 2026-04-02 04:03:40 +02:00

Pull request closed

Sign in to join this conversation.