參考 › REST API
comment
agent 回報進度、你回覆驗收,都是 comment。最後一行寫「下一步:」,看板卡片就會顯示。
| 方法與路徑 | 做什麼 |
|---|---|
GET /api/issues/:ref/comments | 一張票的 comment,舊到新 |
POST /api/issues/:ref/comments | 寫一則 comment |
GET /api/comments?created_since=… | 跨所有票,列出某個時間之後新增的 comment |
GET /api/comments/:id | 讀一則 |
PATCH /api/comments/:id | 改內容 |
comment 的欄位
| 欄位 | 說明 |
|---|---|
id | 數字 |
issue_number | 哪張票(數字) |
author | 誰寫的,自由填寫的文字 |
body | 內容,Markdown |
linear_id | 搬資料用的外部 id,沒有是 null |
created_at、updated_at | 建立、最後修改時間 |
「下一步:」
票的 next_step 取自最新一則 comment 裡以「下一步:」開頭的那一行(全形或半形冒號都可以,前面可以有清單符號),取冒號後面的文字;有好幾行就取最後一個。最新那則沒寫,next_step 就是 null。建議 agent 每則回報都用這行收尾:
匯出 CSV 做好了,Excel 開啟中文正常。
- 產出:src/export.ts、截圖 .scratch/export.png
下一步:你打開 /export 下載一次確認列出一張票的 comment
GET/api/issues/:ref/comments
回
{ "comments": [...] },依建立時間舊到新。寫一則 comment
POST/api/issues/:ref/comments
回
201 與存好的 comment。內容
authorstring · 必填誰寫的,例如 my-repo agent。
bodymarkdown · 必填linear_idstring搬資料用;已經有同一個 id 回 409,帶既有 comment 的 id。
created_at、updated_atISO 時間搬資料用,沒帶就是現在。
請求
curl -X POST -H "Authorization: Bearer $NEXTLINE_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"author":"my-agent","body":"做好了\n下一步:你看一下"}' \ http://127.0.0.1:3000/api/issues/NX-13/comments
回應 201
{
"id": 41,
"issue_number": 13,
"author": "my-agent",
"body": "做好了\n下一步:你看一下",
"linear_id": null,
"created_at": "2026-11-20T09:15:02.511Z",
"updated_at": "2026-11-20T09:15:02.511Z"
}
回覆待驗收的票會交回 agent
你在網頁上回覆一張 In Review 的票時,票會同時移到 In Progress,並寫一筆狀態的變更紀錄(可以還原),agent 下次來看就知道要接著做。
- agent 寫的 comment 不會改狀態,所以 agent 可以放心在待驗收的票上補充說明。
- 判斷「人還是 agent」是看
author:只有網頁上那個人的名字會觸發,其他名稱都當成 agent。名字用NEXTLINE_OWNER_NAME設定(見安裝;Cloudflare 跑法是wrangler.jsonc的OWNER_NAME變數),沒設定是「你」;GET /api/owner查得到目前的名字。 - 帶
linear_id的搬資料寫入不會觸發;其他狀態的票也不會。
跨票列出新的 comment
GET/api/comments
一次找出「上次看過之後,誰在哪些票留言」,不用逐張查。不論狀態,Done、Canceled、已封存的票都列。看的是新增時間,改過的 comment 不會因此出現。
查詢參數
created_sinceISO 時間 · 必填這個時間(含)之後新增的。
created_beforeISO 時間這個時間之前(不含)。
limit、offsetnumber預設 50、最多 200。
請求
curl -H "Authorization: Bearer $NEXTLINE_API_TOKEN" \ "http://127.0.0.1:3000/api/comments?created_since=2026-11-20T00:00:00Z"
回應 200
{
"comments": [
{ "id": 41, "identifier": "NX-13", "author": "my-agent",
"body": "…", "created_at": "…", … }
],
"limit": 50, "offset": 0, "has_more": false
}
依建立時間舊到新,每則多帶票號 identifier。
讀一則 comment
GET/api/comments/:id
回那一則 comment;不存在回
404。改 comment
PATCH/api/comments/:id
內容只收
body(必填),回改完的 comment。內容有變才更新 updated_at。comment 沒有刪除,也沒有回覆串。