Skip to content

Commit a499cd0

Browse files
authored
feat: redesign action input and output schema
Rename `github-issue-url` to `github-url` (accepts issue or PR URL). Make the identity inputs optional with mutual exclusion. Add `wait`, `wait-timeout-seconds`, and `idempotency-key` inputs. Add chat metadata, PR metadata, and error outputs populated from the chat object the API already returns. * `action.yaml`: rename input, new optional inputs, new outputs (including the `diff-additions` / `diff-deletions` / `diff-changed-files` triple derived from `diff_status`). * `src/schemas.ts`: Zod schemas enforce mutual exclusion, the `wait` enum, and positive-integer coercion of `wait-timeout-seconds`. * `src/coder-client.ts`: `CoderChatSchema` parses `diff_status`, `last_error`, `parent_chat_id`, `root_chat_id`, `last_model_config_id`, and `archived`. * `src/action.ts`: `parseGithubURL` accepts issues and pull requests; `warnUnwiredInputs` notifies callers when they opt into an input not yet wired; `buildOutputs` renders the new outputs and is shared between the create and existing-chat-id branches with a graceful fallback when the post-message `getChat` fetch fails. * `src/outputs.ts` (new): `OUTPUT_MAP` and `setActionOutputs` extracted from `index.ts` for unit testing. * `.github/workflows/ci.yaml`: pin `bun-version: 1.3.13` so `dist/` stays reproducible across runs. * `README.md`: updated input and output tables. * `dist/index.js` rebuilt. Closes CODAGT-283 🤖 Authored by Coder Agents.
1 parent e49abc1 commit a499cd0

13 files changed

Lines changed: 1454 additions & 227 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup Bun
2020
uses: oven-sh/setup-bun@v1
2121
with:
22-
bun-version: latest
22+
bun-version: 1.3.13
2323

2424
- name: Install dependencies
2525
run: bun install

README.md

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
# Coder Agent Chat GitHub Action
22

3-
This GitHub action creates a [Coder Agent Chat](https://coder.com/docs/ai-coder) and optionally posts a comment on a GitHub issue. It's designed to be used as part of a wider workflow.
3+
This GitHub action creates a [Coder Agent Chat](https://coder.com/docs/ai-coder) and optionally posts a comment on a GitHub issue or pull request. It's designed to be used as part of a wider workflow.
44

55
## Overview
66

7-
- When creating a Coder Agent Chat, you must specify either the GitHub user ID or the Coder username as an input.
8-
- The action then queries the Coder deployment to find the Coder user associated with the given GitHub user ID.
9-
- Note that this requires the Coder deployment to be configured with [GitHub OAuth](https://coder.com/docs/admin/external-auth#configure-a-github-oauth-app) and for the Coder user to have linked their GitHub account.
10-
- If no corresponding Coder user is found, the action will fail.
11-
- The action will then create a [Coder Agent Chat](https://coder.com/docs/ai-coder) with the given prompt.
12-
- Unlike Tasks, **Agents does not require specifying a template**. Agents auto-provisions a workspace, or you can pass an existing `workspace-id`.
13-
- Once the chat has been created successfully, the action will post a comment on the GitHub issue with the chat URL.
14-
- You can also send a follow-up message to an existing chat by providing `existing-chat-id`.
7+
- Pass a `chat-prompt` and a `github-url` (issue or PR) and the action creates a Coder Agent Chat associated with that GitHub item.
8+
- The action resolves the Coder user to run as. Either pass `github-user-id` (the action looks up the Coder user with that linked GitHub identity) or pass `coder-username` directly. The two inputs are mutually exclusive.
9+
- GitHub-id lookup requires the Coder deployment to be configured with [GitHub OAuth](https://coder.com/docs/admin/external-auth#configure-a-github-oauth-app) and for the Coder user to have linked their GitHub account.
10+
- Unlike Tasks, **Agents does not require specifying a template**. Agents auto-provisions a workspace, or you can pass an existing `workspace-id`.
11+
- After creation, the action posts a comment on the linked issue or pull request with the chat URL. Disable with `comment-on-issue: false`.
12+
- Send a follow-up message to an existing chat by providing `existing-chat-id`.
1513

1614
## Requirements
1715

1816
- A running Coder deployment with Agents enabled (experimental).
1917
- A Coder session token with the required permissions to:
20-
- Read all users in the given organization
21-
- Create chats
18+
- Read all users in the given organization.
19+
- Create chats.
2220

2321
## Example Usage
2422

25-
The below example will start a Coder Agent Chat when the `coder` label is applied to an issue.
23+
The example below starts a Coder Agent Chat when the `coder` label is applied to an issue.
2624

2725
```yaml
2826
name: Start Coder Agent Chat
@@ -47,7 +45,7 @@ jobs:
4745
coder-token: ${{ secrets.CODER_TOKEN }}
4846
chat-prompt: "Read ${{ github.event.issue.html_url }} using gh CLI and write an appropriate plan for solving the issue to PLAN.md, then wait for feedback."
4947
github-user-id: ${{ github.event.sender.id }}
50-
github-issue-url: ${{ github.event.issue.html_url }}
48+
github-url: ${{ github.event.issue.html_url }}
5149
github-token: ${{ github.token }}
5250
comment-on-issue: true
5351
```
@@ -63,7 +61,7 @@ jobs:
6361
chat-prompt: "Fix the bug described in this issue."
6462
coder-username: "bot-user"
6563
workspace-id: ${{ secrets.WORKSPACE_ID }}
66-
github-issue-url: ${{ github.event.issue.html_url }}
64+
github-url: ${{ github.event.issue.html_url }}
6765
github-token: ${{ github.token }}
6866
```
6967
@@ -78,32 +76,49 @@ jobs:
7876
chat-prompt: "Please also add unit tests for the changes."
7977
existing-chat-id: ${{ steps.create_chat.outputs.chat-id }}
8078
coder-username: "bot-user"
81-
github-issue-url: ${{ github.event.issue.html_url }}
79+
github-url: ${{ github.event.issue.html_url }}
8280
github-token: ${{ github.token }}
8381
```
8482
8583
## Inputs
8684
87-
| Name | Description | Required | Default |
88-
| ----------------- | --------------------------------------------------------------------------- | -------- | --------- |
89-
| chat-prompt | Prompt/instructions to send to the agent chat | true | - |
90-
| coder-token | Coder session token for authentication | true | - |
91-
| coder-url | Coder deployment URL | true | - |
92-
| github-issue-url | GitHub issue URL to link this chat to | true | - |
93-
| github-token | GitHub token for API operations | true | - |
94-
| github-user-id | GitHub user ID to create chat for | false | - |
95-
| coder-username | Coder username (alternative to github-user-id) | false | - |
96-
| coder-organization| Coder organization name | false | "default" |
97-
| workspace-id | Existing workspace ID (if not provided, Agents auto-provisions) | false | - |
98-
| model-config-id | Model configuration ID to use | false | - |
99-
| existing-chat-id | Existing chat ID to send a follow-up message to | false | - |
100-
| comment-on-issue | Whether to comment on the GitHub issue | false | true |
85+
| Name | Description | Required | Default |
86+
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------- |
87+
| chat-prompt | Prompt to send to the agent chat. Templated by the workflow before being passed in. | true | - |
88+
| coder-token | Coder session token used to authenticate with the Coder API. | true | - |
89+
| coder-url | Coder deployment URL. | true | - |
90+
| github-url | GitHub issue or pull request URL to link the chat to. Used for the issue/PR comment and as the human-readable association in the chat label. | true | - |
91+
| github-token | GitHub token used to post and update issue comments. | true | - |
92+
| github-user-id | GitHub user ID to resolve to a Coder user. Mutually exclusive with coder-username. | false | - |
93+
| coder-username | Coder username to use directly. Mutually exclusive with github-user-id; useful for service-account workflows. | false | - |
94+
| coder-organization | Coder organization name. Reserved; not yet wired through to chat creation, the action emits a warning if set. | false | - |
95+
| workspace-id | Existing workspace ID to pin the chat to. If unset, Agents auto-provisions a workspace. | false | - |
96+
| model-config-id | Model configuration ID to use for the chat. | false | - |
97+
| existing-chat-id | Existing chat ID to send a follow-up message to instead of creating a new chat. | false | - |
98+
| comment-on-issue | Whether to comment on the GitHub issue or pull request with the chat URL and status. | false | true |
99+
| wait | Wait mode. Reserved: `complete` is intended to poll until terminal status or wait-timeout-seconds, but is not yet wired; the action emits a warning and returns immediately. | false | none |
100+
| wait-timeout-seconds | Maximum seconds to wait when wait=complete before failing with a timeout. | false | 600 |
101+
| idempotency-key | Optional key used to deduplicate chats. Reserved; not yet wired, the action emits a warning if set and always creates a new chat. | false | - |
101102

102103
## Outputs
103104

104-
| Name | Description |
105-
| -------------- | -------------------------------------------------------------------- |
106-
| coder-username | The Coder username resolved from GitHub user |
107-
| chat-id | The chat ID |
108-
| chat-url | The URL to view the chat in Coder |
109-
| chat-created | Whether the chat was newly created (true) or already existed (false) |
105+
| Name | Description |
106+
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
107+
| coder-username | The Coder username resolved from the GitHub user. |
108+
| chat-id | The chat ID. |
109+
| chat-url | The URL to view the chat in Coder. |
110+
| chat-created | Whether the chat was newly created (true) or a message was sent to an existing chat (false). |
111+
| chat-status | Current chat status (waiting, pending, running, paused, completed, error). |
112+
| chat-title | The chat title. |
113+
| workspace-id | The workspace ID the chat is running in (auto-provisioned or provided). |
114+
| pull-request-url | URL of the pull request or branch page when the chat has tracked changes. |
115+
| pull-request-state | Pull request state (open, closed, merged) when available. |
116+
| pull-request-title | Title of the pull request when available. |
117+
| pull-request-number | Pull request number when available. |
118+
| diff-additions | Number of lines added in tracked changes. |
119+
| diff-deletions | Number of lines deleted in tracked changes. |
120+
| diff-changed-files | Number of files changed in tracked changes. |
121+
| head-branch | Head branch name when available. |
122+
| base-branch | Base branch name when available. |
123+
| chat-error-kind | Machine-readable error kind when the chat fails. Reserved; not yet populated. |
124+
| chat-error-message | Human-readable error message when the chat fails. |

action.yaml

Lines changed: 73 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,70 +7,123 @@ branding:
77
color: purple
88

99
inputs:
10-
# Required inputs
1110
chat-prompt:
12-
description: "Prompt/instructions to send to the agent chat"
11+
description: "Prompt to send to the agent chat. Templated by the workflow before being passed in."
1312
required: true
1413

1514
coder-token:
16-
description: "Coder session token for authentication"
15+
description: "Coder session token used to authenticate with the Coder API."
1716
required: true
1817

1918
coder-url:
20-
description: "Coder deployment URL"
19+
description: "Coder deployment URL."
2120
required: true
2221

23-
github-issue-url:
24-
description: "GitHub issue URL to link this chat to"
22+
github-url:
23+
description: "GitHub issue or pull request URL to link the chat to. Used for the issue/PR comment and as the human-readable association in the chat label."
2524
required: true
2625

2726
github-token:
28-
description: "GitHub token for API operations"
27+
description: "GitHub token used to post and update issue comments."
2928
required: true
3029

3130
github-user-id:
32-
description: "GitHub user ID to create chat for. If provided, `coder-username` must not be set."
31+
description: "GitHub user ID to resolve to a Coder user. Mutually exclusive with coder-username."
3332
required: false
3433

3534
coder-username:
36-
description: "Coder username to create chat for. If provided, github-user-id must not be set. Useful for automated workflows without a triggering user."
35+
description: "Coder username to use directly. Mutually exclusive with github-user-id; useful for service-account workflows."
3736
required: false
3837

39-
# Optional inputs
4038
coder-organization:
41-
description: "Coder organization name"
39+
description: "Coder organization name. Reserved; not yet wired through to chat creation, the action emits a warning if set."
4240
required: false
43-
default: "default"
4441

4542
workspace-id:
46-
description: "Existing workspace ID to use for the chat. If not provided, Agents will auto-provision a workspace."
43+
description: "Existing workspace ID to pin the chat to. If unset, Agents auto-provisions a workspace."
4744
required: false
4845

4946
model-config-id:
50-
description: "Model configuration ID to use for the chat (optional)"
47+
description: "Model configuration ID to use for the chat."
5148
required: false
5249

5350
existing-chat-id:
54-
description: "Existing chat ID to send a follow-up message to instead of creating a new chat"
51+
description: "Existing chat ID to send a follow-up message to instead of creating a new chat."
5552
required: false
5653

5754
comment-on-issue:
58-
description: "Whether to comment on the GitHub issue"
55+
description: "Whether to comment on the GitHub issue or pull request with the chat URL and status."
5956
required: false
6057
default: "true"
6158

59+
wait:
60+
description: "Wait mode. Reserved: 'complete' is intended to poll until the chat reaches a terminal status or wait-timeout-seconds, but is not yet wired; the action emits a warning and returns immediately."
61+
required: false
62+
default: "none"
63+
64+
wait-timeout-seconds:
65+
description: "Maximum seconds to wait when wait=complete before failing with a timeout."
66+
required: false
67+
default: "600"
68+
69+
idempotency-key:
70+
description: "Optional key used to deduplicate chats. Reserved; not yet wired, the action emits a warning if set and always creates a new chat."
71+
required: false
72+
6273
outputs:
6374
coder-username:
64-
description: "The Coder username resolved from GitHub user"
75+
description: "The Coder username resolved from the GitHub user."
6576

6677
chat-id:
67-
description: "The chat ID"
78+
description: "The chat ID."
6879

6980
chat-url:
70-
description: "The URL to view the chat in Coder"
81+
description: "The URL to view the chat in Coder."
7182

7283
chat-created:
73-
description: "Whether the chat was newly created (true) or a message was sent to an existing chat (false)"
84+
description: "Whether the chat was newly created (true) or a message was sent to an existing chat (false)."
85+
86+
chat-status:
87+
description: "Current chat status (waiting, pending, running, paused, completed, error)."
88+
89+
chat-title:
90+
description: "The chat title."
91+
92+
workspace-id:
93+
description: "The workspace ID the chat is running in (auto-provisioned or provided)."
94+
95+
pull-request-url:
96+
description: "URL of the pull request or branch page when the chat has tracked changes."
97+
98+
pull-request-state:
99+
description: "Pull request state (open, closed, merged) when available."
100+
101+
pull-request-title:
102+
description: "Title of the pull request when available."
103+
104+
pull-request-number:
105+
description: "Pull request number when available."
106+
107+
diff-additions:
108+
description: "Number of lines added in tracked changes."
109+
110+
diff-deletions:
111+
description: "Number of lines deleted in tracked changes."
112+
113+
diff-changed-files:
114+
description: "Number of files changed in tracked changes."
115+
116+
head-branch:
117+
description: "Head branch name when available."
118+
119+
base-branch:
120+
description: "Base branch name when available."
121+
122+
chat-error-kind:
123+
description: "Machine-readable error kind when the chat fails. Reserved; not yet populated."
124+
125+
chat-error-message:
126+
description: "Human-readable error message when the chat fails."
74127

75128
runs:
76129
using: "node20"

0 commit comments

Comments
 (0)