diff --git a/hive-ag3nt/prompts/agent.md b/hive-ag3nt/prompts/agent.md index 4c601b9..c853e64 100644 --- a/hive-ag3nt/prompts/agent.md +++ b/hive-ag3nt/prompts/agent.md @@ -24,7 +24,7 @@ Claude session (OAuth credentials) lives at `/root/.claude/` and persists across **Code forge**: a private Forgejo at `http://localhost:3000` is available when `/agents/{label}/state/forge-token` exists. You have your own user account (named `{label}`); credentials for the `tea` CLI are pre-configured at boot. Use `tea repos create`, `tea pulls create --base main --head `, `tea pulls list`, `tea issues create`, etc. for any persistent code work — git repos that should outlive a single turn, code you want a peer or the operator to review, anything you'd otherwise jam into `/shared`. Falls back to plain `git`/`curl` if `tea` doesn't fit; the REST API is at `http://localhost:3000/api/v1/` with the same token (`Authorization: token $(cat /agents/{label}/state/forge-token)`). -The `hive-forge` CLI helper wraps common Forgejo API operations: `view`, `issue`, `pr`, `comment`, `assign`, `close`, `labels`, `pr-reviews`, `branches`, `tree-sha`, `diff`, `subscription`. To attach a file to an issue or comment use `hive-forge attach-issue [repo]` or `hive-forge attach-comment [repo]` — both print the `browser_download_url` of the uploaded attachment. Key ops: `hive-forge diff [repo]` prints the unified diff; `hive-forge subscription [--watch|--ignore|--unwatch] [repo]` gets or sets repo watch state. Note: forge notifications are delivered via the internal message daemon — no need to poll the API directly. +The `hive-forge` CLI helper wraps common Forgejo API operations: `view`, `issue`, `issue-create`, `issue-edit`, `pr`, `pr-create`, `comment`, `assign`, `close`, `labels`, `pr-reviews`, `branches`, `tree-sha`, `diff`, `subscription`. To create a PR: `hive-forge pr-create --title "..." --head [--base main] [--body "..."] [--draft] [repo]` — prints the PR URL. To create an issue: `hive-forge issue-create --title "..." [--body "..."] [--assignee ] [repo]`. To attach a file to an issue or comment use `hive-forge attach-issue [repo]` or `hive-forge attach-comment [repo]` — both print the `browser_download_url` of the uploaded attachment. Key ops: `hive-forge diff [repo]` prints the unified diff; `hive-forge subscription [--watch|--ignore|--unwatch] [repo]` manages repo watch state. Note: forge notifications are delivered via the internal message daemon. Keep messages short — a few sentences each. For anything big (file listings, long diffs, transcripts, analysis): write the payload to `/agents/{label}/state/` and `send` a short pointer ("dropped the cluster audit in /agents/{label}/state/cluster-audit-2026-05.md, headline: 3 nodes over 80% mem"). The manager + operator can read your state from the host as `/agents/{label}/state/`. Sub-agent peers can't read each other's state directly — go through the manager if a payload needs to reach another sub-agent. diff --git a/hive-ag3nt/prompts/manager.md b/hive-ag3nt/prompts/manager.md index aabc06a..bbb5c0b 100644 --- a/hive-ag3nt/prompts/manager.md +++ b/hive-ag3nt/prompts/manager.md @@ -91,7 +91,7 @@ Keep messages short — a few sentences each. For anything big (digests, agent r - To the operator: write to your own `/state/` (host path `/var/lib/hyperhive/agents/hm1nd/state/`) and tell them where to look. - For shared artifacts (coordination, common reference data): write to `/shared/`. Only put things here you're willing to lose — other agents may delete them. -**Code forge**: a private Forgejo at `http://localhost:3000` is available when `/state/forge-token` exists. You have your own user (`hm1nd`) and so does every sub-agent (one per name). The `tea` CLI is pre-configured at boot. Use it for code work that should survive a turn — a proposed refactor across sub-agents, scratch repos, PRs you want a sub-agent or the operator to review (`tea pulls create --base main --head `, `tea pulls list`, `tea issues create`). REST API at `http://localhost:3000/api/v1/` with `Authorization: token $(cat /state/forge-token)` for anything `tea` can't express. The `hive-forge` CLI helper wraps common operations: `view`, `issue`, `pr`, `comment`, `assign`, `close`, `labels`, `pr-reviews`, `branches`, `tree-sha`, `diff`, `subscription`, `attach-issue`, `attach-comment`. Key: `diff ` prints unified diff; `subscription [--watch|--ignore|--unwatch] [repo]` manages repo watch state. Forge notifications are delivered via the internal message daemon. +**Code forge**: a private Forgejo at `http://localhost:3000` is available when `/state/forge-token` exists. You have your own user (`hm1nd`) and so does every sub-agent (one per name). The `tea` CLI is pre-configured at boot. Use it for code work that should survive a turn — a proposed refactor across sub-agents, scratch repos, PRs you want a sub-agent or the operator to review (`tea pulls create --base main --head `, `tea pulls list`, `tea issues create`). REST API at `http://localhost:3000/api/v1/` with `Authorization: token $(cat /state/forge-token)` for anything `tea` can't express. The `hive-forge` CLI helper wraps common operations: `view`, `issue`, `issue-create`, `issue-edit`, `pr`, `pr-create`, `comment`, `assign`, `close`, `labels`, `pr-reviews`, `branches`, `tree-sha`, `diff`, `subscription`, `attach-issue`, `attach-comment`. Use `hive-forge pr-create --title "..." --head [--base main] [--body "..."] [--draft]` to open a PR; `hive-forge issue-create --title "..." [--body "..."] [--assignee ]` to file an issue; `diff ` prints unified diff; `subscription [--watch|--ignore|--unwatch] [repo]` manages watch state. Forge notifications arrive via the internal message daemon. A one-line headline + the file path beats a wall-of-text every time — it survives context compaction and the operator can read it in their own time. diff --git a/nix/packages/hive-forge-tools.nix b/nix/packages/hive-forge-tools.nix index 94ba58d..66290bc 100644 --- a/nix/packages/hive-forge-tools.nix +++ b/nix/packages/hive-forge-tools.nix @@ -221,6 +221,63 @@ pkgs.writeShellApplication { | jq -r '.tree.sha // .sha' } + cmd_pr_create() { + # pr-create --title --head <branch> [--base <base>] [--body <body>] [--draft] [repo] + # Create a pull request. Prints the PR URL on success. + local _title="" _head="" _base="main" _body="" _draft="false" _repo="$HIVE_FORGE_REPO" + while [ $# -gt 0 ]; do + case "$1" in + --title) _title="$2"; shift 2 ;; + --head) _head="$2"; shift 2 ;; + --base) _base="$2"; shift 2 ;; + --body) _body="$2"; shift 2 ;; + --draft) _draft="true"; shift ;; + *) _repo="$1"; shift ;; + esac + done + if [ -z "$_title" ] || [ -z "$_head" ]; then + echo "usage: hive-forge pr-create --title <title> --head <branch> [--base <base>] [--body <body>] [--draft] [repo]" >&2 + exit 1 + fi + local _payload + _payload=$(jq -n \ + --arg title "$_title" \ + --arg head "$_head" \ + --arg base "$_base" \ + --arg body "$_body" \ + --argjson draft "$_draft" \ + '{title:$title,head:$head,base:$base,body:$body,draft:$draft}') + forge_post "$FORGE_API/repos/$_repo/pulls" "$_payload" \ + | jq -r '.html_url' + } + + cmd_issue_create() { + # issue-create --title <title> [--body <body>] [--assignee <user>] [repo] + # Create an issue. Prints the issue URL on success. + local _title="" _body="" _assignee="" _repo="$HIVE_FORGE_REPO" + while [ $# -gt 0 ]; do + case "$1" in + --title) _title="$2"; shift 2 ;; + --body) _body="$2"; shift 2 ;; + --assignee) _assignee="$2"; shift 2 ;; + *) _repo="$1"; shift ;; + esac + done + if [ -z "$_title" ]; then + echo "usage: hive-forge issue-create --title <title> [--body <body>] [--assignee <user>] [repo]" >&2 + exit 1 + fi + local _payload + if [ -n "$_assignee" ]; then + _payload=$(jq -n --arg t "$_title" --arg b "$_body" --arg a "$_assignee" \ + '{title:$t,body:$b,assignees:[$a]}') + else + _payload=$(jq -n --arg t "$_title" --arg b "$_body" '{title:$t,body:$b}') + fi + forge_post "$FORGE_API/repos/$_repo/issues" "$_payload" \ + | jq -r '.html_url' + } + cmd_attach_issue() { # attach-issue <number> <file> [repo] # Upload a file as an attachment to an issue. Prints the download URL. @@ -290,8 +347,8 @@ pkgs.writeShellApplication { VERB="''${1:-}" if [ -z "$VERB" ]; then echo "usage: hive-forge <verb> [args...]" >&2 - echo "verbs: view, issue, pr, comment, assign, close, labels, pr-reviews," >&2 - echo " branches, tree-sha, diff, subscription," >&2 + echo "verbs: view, issue, issue-create, issue-edit, pr, pr-create, comment, assign, close," >&2 + echo " labels, pr-reviews, branches, tree-sha, diff, subscription," >&2 echo " attach-issue, attach-comment" >&2 exit 1 fi @@ -300,7 +357,9 @@ pkgs.writeShellApplication { case "$VERB" in view) cmd_view "$@" ;; issue) cmd_issue "$@" ;; + issue-create) cmd_issue_create "$@" ;; pr) cmd_pr "$@" ;; + pr-create) cmd_pr_create "$@" ;; comment) cmd_comment "$@" ;; assign) cmd_assign "$@" ;; close) cmd_close "$@" ;; @@ -314,8 +373,8 @@ pkgs.writeShellApplication { attach-comment) cmd_attach_comment "$@" ;; *) echo "hive-forge: unknown verb '$VERB'" >&2 - echo "verbs: view, issue, pr, comment, assign, close, labels, pr-reviews," >&2 - echo " branches, tree-sha, diff, subscription," >&2 + echo "verbs: view, issue, issue-create, issue-edit, pr, pr-create, comment, assign, close," >&2 + echo " labels, pr-reviews, branches, tree-sha, diff, subscription," >&2 echo " attach-issue, attach-comment" >&2 exit 1 ;;