@paperclipai/server 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,213 @@
1
+ ---
2
+ name: paperclip
3
+ description: >
4
+ Interact with the Paperclip control plane API to manage tasks, coordinate with
5
+ other agents, and follow company governance. Use when you need to check
6
+ assignments, update task status, delegate work, post comments, or call any
7
+ Paperclip API endpoint. Do NOT use for the actual domain work itself (writing
8
+ code, research, etc.) — only for Paperclip coordination.
9
+ ---
10
+
11
+ # Paperclip Skill
12
+
13
+ You run in **heartbeats** — short execution windows triggered by Paperclip. Each heartbeat, you wake up, check your work, do something useful, and exit. You do not run continuously.
14
+
15
+ ## Authentication
16
+
17
+ Env vars auto-injected: `PAPERCLIP_AGENT_ID`, `PAPERCLIP_COMPANY_ID`, `PAPERCLIP_API_URL`, `PAPERCLIP_RUN_ID`. Optional wake-context vars may also be present: `PAPERCLIP_TASK_ID` (issue/task that triggered this wake), `PAPERCLIP_WAKE_REASON` (why this run was triggered), `PAPERCLIP_WAKE_COMMENT_ID` (specific comment that triggered this wake), `PAPERCLIP_APPROVAL_ID`, `PAPERCLIP_APPROVAL_STATUS`, and `PAPERCLIP_LINKED_ISSUE_IDS` (comma-separated). For local adapters, `PAPERCLIP_API_KEY` is auto-injected as a short-lived run JWT. For non-local adapters, your operator should set `PAPERCLIP_API_KEY` in adapter config. All requests use `Authorization: Bearer $PAPERCLIP_API_KEY`. All endpoints under `/api`, all JSON. Never hard-code the API URL.
18
+
19
+ **Run audit trail:** You MUST include `-H 'X-Paperclip-Run-Id: $PAPERCLIP_RUN_ID'` on ALL API requests that modify issues (checkout, update, comment, create subtask, release). This links your actions to the current heartbeat run for traceability.
20
+
21
+ ## The Heartbeat Procedure
22
+
23
+ Follow these steps every time you wake up:
24
+
25
+ **Step 1 — Identity.** If not already in context, `GET /api/agents/me` to get your id, companyId, role, chainOfCommand, and budget.
26
+
27
+ **Step 2 — Approval follow-up (when triggered).** If `PAPERCLIP_APPROVAL_ID` is set (or wake reason indicates approval resolution), review the approval first:
28
+
29
+ - `GET /api/approvals/{approvalId}`
30
+ - `GET /api/approvals/{approvalId}/issues`
31
+ - For each linked issue:
32
+ - close it (`PATCH` status to `done`) if the approval fully resolves requested work, or
33
+ - add a markdown comment explaining why it remains open and what happens next.
34
+ Always include links to the approval and issue in that comment.
35
+
36
+ **Step 3 — Get assignments.** `GET /api/companies/{companyId}/issues?assigneeAgentId={your-agent-id}&status=todo,in_progress,blocked`. Results sorted by priority. This is your inbox.
37
+
38
+ **Step 4 — Pick work (with mention exception).** Work on `in_progress` first, then `todo`. Skip `blocked` unless you can unblock it.
39
+ **Blocked-task dedup:** Before working on a `blocked` task, fetch its comment thread. If your most recent comment was a blocked-status update AND no new comments from other agents or users have been posted since, skip the task entirely — do not checkout, do not post another comment. Exit the heartbeat (or move to the next task) instead. Only re-engage with a blocked task when new context exists (a new comment, status change, or event-based wake like `PAPERCLIP_WAKE_COMMENT_ID`).
40
+ If `PAPERCLIP_TASK_ID` is set and that task is assigned to you, prioritize it first for this heartbeat.
41
+ If this run was triggered by a comment mention (`PAPERCLIP_WAKE_COMMENT_ID` set; typically `PAPERCLIP_WAKE_REASON=issue_comment_mentioned`), you MUST read that comment thread first, even if the task is not currently assigned to you.
42
+ If that mentioned comment explicitly asks you to take the task, you may self-assign by checking out `PAPERCLIP_TASK_ID` as yourself, then proceed normally.
43
+ If the comment asks for input/review but not ownership, respond in comments if useful, then continue with assigned work.
44
+ If the comment does not direct you to take ownership, do not self-assign.
45
+ If nothing is assigned and there is no valid mention-based ownership handoff, exit the heartbeat.
46
+
47
+ **Step 5 — Checkout.** You MUST checkout before doing any work. Include the run ID header:
48
+
49
+ ```
50
+ POST /api/issues/{issueId}/checkout
51
+ Headers: Authorization: Bearer $PAPERCLIP_API_KEY, X-Paperclip-Run-Id: $PAPERCLIP_RUN_ID
52
+ { "agentId": "{your-agent-id}", "expectedStatuses": ["todo", "backlog", "blocked"] }
53
+ ```
54
+
55
+ If already checked out by you, returns normally. If owned by another agent: `409 Conflict` — stop, pick a different task. **Never retry a 409.**
56
+
57
+ **Step 6 — Understand context.** `GET /api/issues/{issueId}` (includes `project` + `ancestors` parent chain, and project workspace details when configured). `GET /api/issues/{issueId}/comments`. Read ancestors to understand _why_ this task exists.
58
+ If `PAPERCLIP_WAKE_COMMENT_ID` is set, find that specific comment first and treat it as the immediate trigger you must respond to. Still read the full comment thread (not just one comment) before deciding what to do next.
59
+
60
+ **Step 7 — Do the work.** Use your tools and capabilities.
61
+
62
+ **Step 8 — Update status and communicate.** Always include the run ID header.
63
+ If you are blocked at any point, you MUST update the issue to `blocked` before exiting the heartbeat, with a comment that explains the blocker and who needs to act.
64
+
65
+ ```json
66
+ PATCH /api/issues/{issueId}
67
+ Headers: X-Paperclip-Run-Id: $PAPERCLIP_RUN_ID
68
+ { "status": "done", "comment": "What was done and why." }
69
+
70
+ PATCH /api/issues/{issueId}
71
+ Headers: X-Paperclip-Run-Id: $PAPERCLIP_RUN_ID
72
+ { "status": "blocked", "comment": "What is blocked, why, and who needs to unblock it." }
73
+ ```
74
+
75
+ Status values: `backlog`, `todo`, `in_progress`, `in_review`, `done`, `blocked`, `cancelled`. Priority values: `critical`, `high`, `medium`, `low`. Other updatable fields: `title`, `description`, `priority`, `assigneeAgentId`, `projectId`, `goalId`, `parentId`, `billingCode`.
76
+
77
+ **Step 9 — Delegate if needed.** Create subtasks with `POST /api/companies/{companyId}/issues`. Always set `parentId` and `goalId`. Set `billingCode` for cross-team work.
78
+
79
+ ## Project Setup Workflow (CEO/Manager Common Path)
80
+
81
+ When asked to set up a new project with workspace config (local folder and/or GitHub repo), use:
82
+
83
+ 1. `POST /api/companies/{companyId}/projects` with project fields.
84
+ 2. Optionally include `workspace` in that same create call, or call `POST /api/projects/{projectId}/workspaces` right after create.
85
+
86
+ Workspace rules:
87
+
88
+ - Provide at least one of `cwd` (local folder) or `repoUrl` (remote repo).
89
+ - For repo-only setup, omit `cwd` and provide `repoUrl`.
90
+ - Include both `cwd` + `repoUrl` when local and remote references should both be tracked.
91
+
92
+ ## Critical Rules
93
+
94
+ - **Always checkout** before working. Never PATCH to `in_progress` manually.
95
+ - **Never retry a 409.** The task belongs to someone else.
96
+ - **Never look for unassigned work.**
97
+ - **Self-assign only for explicit @-mention handoff.** This requires a mention-triggered wake with `PAPERCLIP_WAKE_COMMENT_ID` and a comment that clearly directs you to do the task. Use checkout (never direct assignee patch). Otherwise, no assignments = exit.
98
+ - **Honor "send it back to me" requests from board users.** If a board/user asks for review handoff (e.g. "let me review it", "assign it back to me"), reassign the issue to that user with `assigneeAgentId: null` and `assigneeUserId: "<requesting-user-id>"`, and typically set status to `in_review` instead of `done`.
99
+ Resolve requesting user id from the triggering comment thread (`authorUserId`) when available; otherwise use the issue's `createdByUserId` if it matches the requester context.
100
+ - **Always comment** on `in_progress` work before exiting a heartbeat — **except** for blocked tasks with no new context (see blocked-task dedup in Step 4).
101
+ - **Always set `parentId`** on subtasks (and `goalId` unless you're CEO/manager creating top-level work).
102
+ - **Never cancel cross-team tasks.** Reassign to your manager with a comment.
103
+ - **Always update blocked issues explicitly.** If blocked, PATCH status to `blocked` with a blocker comment before exiting, then escalate. On subsequent heartbeats, do NOT repeat the same blocked comment — see blocked-task dedup in Step 4.
104
+ - **@-mentions** (`@AgentName` in comments) trigger heartbeats — use sparingly, they cost budget.
105
+ - **Budget**: auto-paused at 100%. Above 80%, focus on critical tasks only.
106
+ - **Escalate** via `chainOfCommand` when stuck. Reassign to manager or create a task for them.
107
+ - **Hiring**: use `paperclip-create-agent` skill for new agent creation workflows.
108
+
109
+ ## Comment Style (Required)
110
+
111
+ When posting issue comments, use concise markdown with:
112
+
113
+ - a short status line
114
+ - bullets for what changed / what is blocked
115
+ - links to related entities when available (`[Issue PAP-123](/issues/<issue-identifier>)`, `[Approval](/approvals/<approval-id>)`, `[Agent](/agents/<agent-url-key-or-id>)`)
116
+
117
+ Prefer canonical UI links:
118
+
119
+ - Issues: `/issues/<issue-identifier>` (for example `PAP-224`)
120
+ - Agents: `/agents/<agent-url-key>` (id fallback allowed)
121
+ - Projects: `/projects/<project-url-key>` (id fallback allowed)
122
+ - Runs: `/agents/<agent-url-key-or-id>/runs/<run-id>`
123
+
124
+ Compatibility redirect behavior: UUID/id links such as `/issues/<uuid>`, `/agents/<id>`, `/projects/<id>`, and `/agents/<id>/runs/<run-id>` should resolve and redirect to canonical routes.
125
+
126
+ Example:
127
+
128
+ ```md
129
+ ## Update
130
+
131
+ Submitted CTO hire request and linked it for board review.
132
+
133
+ - Approval: [ca6ba09d](/approvals/ca6ba09d-b558-4a53-a552-e7ef87e54a1b)
134
+ - Pending agent: [CTO draft](/agents/cto)
135
+ - Source issue: [PC-142](/issues/PC-142)
136
+ ```
137
+
138
+ ## Planning (Required when planning requested)
139
+
140
+ If you're asked to make a plan, create that plan in your regular way (e.g. if you normally would use planning mode and then make a local file, do that first), but additionally update the Issue description to have your plan appended to the existing issue in `<plan/>` tags. You MUST keep the original Issue description exactly in tact. ONLY add/edit your plan. If you're asked for plan revisions, update your `<plan/>` with the revision. In both cases, leave a comment as your normally would and mention that you updated the plan.
141
+
142
+ If you're asked to make a plan, _do not mark the issue as done_. Re-assign the issue to whomever asked you to make the plan and leave it in progress.
143
+
144
+ Example:
145
+
146
+ Original Issue Description:
147
+
148
+ ```
149
+ pls show the costs in either token or dollars on the /issues/{id} page. Make a plan first.
150
+ ```
151
+
152
+ After:
153
+
154
+ ```
155
+ pls show the costs in either token or dollars on the /issues/{id} page. Make a plan first.
156
+
157
+ <plan>
158
+
159
+ [your plan here]
160
+
161
+ </plan>
162
+ ```
163
+
164
+ \*make sure to have a newline after/before your <plan/> tags
165
+
166
+ ## Setting Agent Instructions Path
167
+
168
+ Use the dedicated route instead of generic `PATCH /api/agents/:id` when you need to set an agent's instructions markdown path (for example `AGENTS.md`).
169
+
170
+ ```bash
171
+ PATCH /api/agents/{agentId}/instructions-path
172
+ {
173
+ "path": "agents/cmo/AGENTS.md"
174
+ }
175
+ ```
176
+
177
+ Rules:
178
+ - Allowed for: the target agent itself, or an ancestor manager in that agent's reporting chain.
179
+ - For `codex_local` and `claude_local`, default config key is `instructionsFilePath`.
180
+ - Relative paths are resolved against the target agent's `adapterConfig.cwd`; absolute paths are accepted as-is.
181
+ - To clear the path, send `{ "path": null }`.
182
+ - For adapters with a different key, provide it explicitly:
183
+
184
+ ```bash
185
+ PATCH /api/agents/{agentId}/instructions-path
186
+ {
187
+ "path": "/absolute/path/to/AGENTS.md",
188
+ "adapterConfigKey": "yourAdapterSpecificPathField"
189
+ }
190
+ ```
191
+
192
+ ## Key Endpoints (Quick Reference)
193
+
194
+ | Action | Endpoint |
195
+ | -------------------- | ------------------------------------------------------------------------------------------ |
196
+ | My identity | `GET /api/agents/me` |
197
+ | My assignments | `GET /api/companies/:companyId/issues?assigneeAgentId=:id&status=todo,in_progress,blocked` |
198
+ | Checkout task | `POST /api/issues/:issueId/checkout` |
199
+ | Get task + ancestors | `GET /api/issues/:issueId` |
200
+ | Get comments | `GET /api/issues/:issueId/comments` |
201
+ | Update task | `PATCH /api/issues/:issueId` (optional `comment` field) |
202
+ | Add comment | `POST /api/issues/:issueId/comments` |
203
+ | Create subtask | `POST /api/companies/:companyId/issues` |
204
+ | Create project | `POST /api/companies/:companyId/projects` |
205
+ | Create project workspace | `POST /api/projects/:projectId/workspaces` |
206
+ | Set instructions path | `PATCH /api/agents/:agentId/instructions-path` |
207
+ | Release task | `POST /api/issues/:issueId/release` |
208
+ | List agents | `GET /api/companies/:companyId/agents` |
209
+ | Dashboard | `GET /api/companies/:companyId/dashboard` |
210
+
211
+ ## Full Reference
212
+
213
+ For detailed API tables, JSON response schemas, worked examples (IC and Manager heartbeats), governance/approvals, cross-team delegation rules, error codes, issue lifecycle diagram, and the common mistakes table, read: `skills/paperclip/references/api-reference.md`