feat: entrypoint posts completion comment on Vikunja task after opencode exits
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
143391af17
commit
c6ad5d008f
1 changed files with 22 additions and 2 deletions
|
|
@ -193,6 +193,25 @@ def move_task_to_bucket(pm_token: str, bucket_id: str) -> None:
|
||||||
log.warning("Failed to move task to bucket %s: %s", bucket_id, e)
|
log.warning("Failed to move task to bucket %s: %s", bucket_id, e)
|
||||||
|
|
||||||
|
|
||||||
|
def post_task_comment(pm_token: str, rc: int) -> None:
|
||||||
|
"""Post a completion comment on the Vikunja task."""
|
||||||
|
if rc == 0:
|
||||||
|
body = f"✅ **{AGENT_ROLE}** agent completed this task and moved it to In Review."
|
||||||
|
else:
|
||||||
|
body = f"⚠️ **{AGENT_ROLE}** agent finished with exit code {rc}. Task moved to In Review for manual check."
|
||||||
|
try:
|
||||||
|
resp = httpx.put(
|
||||||
|
f"{VIKUNJA_BASE_URL}/api/v1/tasks/{TASK_ID}/comments",
|
||||||
|
headers={"Authorization": f"Bearer {pm_token}", "Content-Type": "application/json"},
|
||||||
|
json={"comment": body},
|
||||||
|
timeout=10,
|
||||||
|
)
|
||||||
|
resp.raise_for_status()
|
||||||
|
log.info("Posted completion comment on task %s", TASK_ID)
|
||||||
|
except Exception as e:
|
||||||
|
log.warning("Failed to post task comment: %s", e)
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
log.info("Agent entrypoint: role=%s task=%s", AGENT_ROLE, TASK_ID)
|
log.info("Agent entrypoint: role=%s task=%s", AGENT_ROLE, TASK_ID)
|
||||||
|
|
||||||
|
|
@ -203,7 +222,7 @@ def main() -> None:
|
||||||
write_opencode_config(secrets, AGENT_ROLE)
|
write_opencode_config(secrets, AGENT_ROLE)
|
||||||
configure_git_identity()
|
configure_git_identity()
|
||||||
|
|
||||||
# Fetch pm token for bucket moves (admin operation)
|
# Fetch pm token for bucket moves and comments (admin operation)
|
||||||
pm_token = ""
|
pm_token = ""
|
||||||
try:
|
try:
|
||||||
pm_token = get_secret(bao_token, "autojanet/pm/vikunja-token", "token")
|
pm_token = get_secret(bao_token, "autojanet/pm/vikunja-token", "token")
|
||||||
|
|
@ -214,8 +233,9 @@ def main() -> None:
|
||||||
prompt = build_prompt(TASK_ID, TASK_TITLE)
|
prompt = build_prompt(TASK_ID, TASK_TITLE)
|
||||||
rc = run_opencode(prompt)
|
rc = run_opencode(prompt)
|
||||||
|
|
||||||
# Move to In Review regardless of exit code — work was attempted
|
# Always post comment and move bucket regardless of exit code
|
||||||
if pm_token:
|
if pm_token:
|
||||||
|
post_task_comment(pm_token, rc)
|
||||||
move_task_to_bucket(pm_token, IN_REVIEW_BUCKET_ID)
|
move_task_to_bucket(pm_token, IN_REVIEW_BUCKET_ID)
|
||||||
|
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue