superagent-skill 0.0.0-stage → 0.2.0

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.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,121 @@
1
- # Temporary Holding Version
1
+ # superagent
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An agent that turns requests from GitHub and Feishu into tickets, and runs each ticket on the coding agent you choose.
4
+
5
+ - **No web panel.** State is JSON files under `stateDir`, so `ls` and `cat` answer what a dashboard would.
6
+ - **No vendor lock-in.** The executor is a configuration value: `claude`, `codex` or `opencode`, behind one interface.
7
+ - **No daemon.** Every command is a short-lived process; a cron job or a coding agent can drive it.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ pnpm install && pnpm build
13
+ # put `bin/superagent.js` on PATH, or link it:
14
+ ln -sf "$PWD/bin/superagent.js" ~/.local/bin/superagent
15
+ ```
16
+
17
+ ## Use
18
+
19
+ ```sh
20
+ mkdir my-agent && cd my-agent
21
+ superagent init # writes settings.yaml and state/
22
+ $EDITOR settings.yaml # set github.repository, executor.agent, allowed lists
23
+ superagent doctor # confirms the chosen agent is installed
24
+ superagent run . -p "Read README.md and summarise it in one sentence."
25
+ superagent status
26
+ ```
27
+
28
+ `superagent run` is the smallest end-to-end test: it starts the configured agent in the current directory, waits for the
29
+ turn to end, and prints the report the agent left in `.superagent/report.json`.
30
+
31
+ ## How a ticket runs
32
+
33
+ 1. A Source receives a message a person addressed to the agent, from an account on the allow list.
34
+ 2. The engine records a Trigger, assesses it, and either accepts it as a **ticket** or ignores it with a reason.
35
+ 3. The executor prepares a worktree and starts the configured agent in it with the composed prompt.
36
+ 4. The agent works, and writes `.superagent/report.json` before it stops.
37
+ 5. The report is delivered back to the conversation the request came from.
38
+
39
+ ## The agent contract
40
+
41
+ Every runner satisfies the same three conditions, which is what makes agents interchangeable:
42
+
43
+ | Condition | Why |
44
+ | --- | --- |
45
+ | Starts in the ticket's directory | The worktree, not the operator's checkout, is what changes |
46
+ | Reads one prompt on stdin, ends the turn | No interactive step a runner must drive |
47
+ | Writes `.superagent/report.json` | One file to read, identical for every agent |
48
+
49
+ Adding an agent is one file in `src/agents/` plus one line in the registry.
50
+
51
+ ## Layout
52
+
53
+ ```
54
+ src/core/ domain: triggers, decisions, tickets, assignments, engine
55
+ src/state/ file-backed durable state
56
+ src/agents/ one runner per coding agent
57
+ src/infra/ CLI wrappers, account shims, git configuration
58
+ src/settings.ts the settings schema and a small YAML reader
59
+ ```
60
+
61
+ ## Polling
62
+
63
+ ```sh
64
+ superagent poll . # one round every github.pollSeconds until interrupted
65
+ superagent poll . --once # one round, for a cron job or a test
66
+ ```
67
+
68
+ A round reads the agent account's GitHub notifications, keeps the ones for `github.repository` from a login on
69
+ `github.allowed`, builds a Trigger for each mention, and accepts it as a ticket. The ticket runs on
70
+ `executor.agent`; its report is written under `stateDir/work/<ticket>/.superagent/log.md`.
71
+
72
+ A message in a chat the bot reads that names no one is assessed by one `claude -p` call per message, against the
73
+ `policy.rules` in `settings.yaml`. In `observe` mode the verdict is recorded and no ticket starts; `auto` accepts the
74
+ ones the assessor matches. `superagent status` lists the recent judgements.
75
+
76
+ Arbitrary polling is not yet wired, so a person runs `poll` under cron or a systemd timer:
77
+
78
+ ```cron
79
+ */1 * * * * cd /path/to/install && superagent poll . --once >> state/poll.log 2>&1
80
+ ```
81
+
82
+ ## Compare with dsh-superagent
83
+
84
+ [`docs/dsh-superagent-comparison.md`](docs/dsh-superagent-comparison.md)([中文版](docs/dsh-superagent-comparison.zh.md))
85
+ compares this project with the earlier `dsh-superagent` DSH bundle: what both keep, what each does differently, and where
86
+ this one is behind.
87
+
88
+ ## Status
89
+
90
+ Done and tested: the domain, file-backed state, the settings file, three agent runners (verified against the real CLIs),
91
+ the GitHub notification poller, the Feishu Source, worktree creation per ticket, the round loop, and delivery of the
92
+ agent's report back to the conversation. The Feishu path is proven with a stand-in `lark-cli` and once end to end
93
+ against a real Feishu bot.
94
+
95
+ ## Install once
96
+
97
+ ```sh
98
+ npm install -g superagent-skill
99
+ superagent init ~/my-superagent && cd ~/my-superagent
100
+ superagent doctor
101
+ ```
102
+
103
+ From a checkout instead, build it and link it yourself:
104
+
105
+ ```sh
106
+ pnpm install && pnpm build
107
+ ln -sf "$PWD/bin/superagent.js" ~/.local/bin/superagent # a directory on PATH
108
+ ```
109
+
110
+ Start the loop from that directory: `superagent poll` keeps running, and `superagent poll --once` runs one round, which
111
+ is what a cron entry calls each minute.
112
+
113
+ `checkout` names the repository the tickets change, and `executor.agent` names the coding agent. Both `github` and
114
+ `feishu` are optional, but at least one must be on.
115
+
116
+ ## Tests
117
+
118
+ ```sh
119
+ pnpm check # typecheck, unit tests, build
120
+ SUPERAGENT_LIVE=1 SUPERAGENT_AGENT=codex pnpm test # also runs a real agent end to end
121
+ ```
package/SKILL.md ADDED
@@ -0,0 +1,143 @@
1
+ ---
2
+ name: superagent
3
+ description: Run an agent that turns requests from GitHub issues or Feishu chats into tickets and executes each ticket on a configurable coding agent (Claude Code, Codex, opencode). Use when the user wants an agent to watch a repository or a chat, act on @ mentions, and record its work as plain files instead of a dashboard; when they ask what superagent has done, which tickets are open, or to change which coding agent runs tickets.
4
+ ---
5
+
6
+ # Superagent
7
+
8
+ Superagent listens to GitHub and Feishu. A request that names the agent becomes a **ticket**. Each ticket runs on a
9
+ coding agent you choose, in its own worktree, and records itself as files on disk. When the agent reports it is done,
10
+ the summary goes back as a reply in the conversation that asked.
11
+
12
+ You operate an installation; you do not reimplement it. Read state with `superagent status` or by reading the files, and
13
+ change behaviour by editing `settings.yaml`.
14
+
15
+ ## Look before acting
16
+
17
+ Run these from the installation directory — the one that holds `settings.yaml`:
18
+
19
+ ```sh
20
+ superagent status # open and ended tickets, as Markdown
21
+ superagent doctor # which coding agents are installed, which one runs tickets
22
+ ```
23
+
24
+ State is plain JSON under `stateDir`, so `ls` and `cat` answer more than the commands do:
25
+
26
+ | Path | Holds |
27
+ | --- | --- |
28
+ | `state/tickets/<id>/ticket.json` | one ticket: its mandate, assignments, attention and outcome |
29
+ | `state/tickets/<id>/log.md` | what the agent did for that ticket |
30
+ | `stateDir/work/<id>/.superagent/log.md` | the prompt, the agent's output and its report, kept beside the worktree |
31
+ | `state/threads/<key>.json` | one conversation, with the triggers waiting for an assessment |
32
+ | `state/decisions/<id>.json` | why a request was accepted or ignored |
33
+ | `state/triggers/<thread>/<at>-<id>.json` | every message a Source received |
34
+
35
+ ## Choose the coding agent
36
+
37
+ `executor.agent` in `settings.yaml` names one of `claude`, `codex` or `opencode`. All three satisfy the same contract:
38
+
39
+ - The agent starts in the ticket's directory.
40
+ - It receives the composed prompt on standard input and stops at the end of the turn.
41
+ - It writes `.superagent/report.json` with at least `{"summary": "..."}`, and optionally `state`, `prs` and `question`.
42
+
43
+ Because the contract is a file and not a tool channel, adding an agent means one file in `src/agents/` that implements
44
+ `AgentRunner` and one line in `src/agents/index.ts`. Nothing else changes.
45
+
46
+ ```yaml
47
+ executor:
48
+ agent: codex # claude | codex | opencode
49
+ binary: codex # optional; defaults to the agent name on PATH
50
+ model: null # passed as --model when set
51
+ maxWorkers: 1 # tickets that may run at once
52
+ timeoutMinutes: 60
53
+ ```
54
+
55
+ Verify a choice before trusting it:
56
+
57
+ ```sh
58
+ superagent doctor
59
+ superagent run . -p "Read README.md and summarise it in one sentence."
60
+ ```
61
+
62
+ `run` starts the configured agent in the current directory and prints its report. That is the smallest end-to-end test
63
+ of an installation.
64
+
65
+ ## Who may ask for work
66
+
67
+ Both Sources use an allow list. An empty list accepts nobody.
68
+
69
+ ```yaml
70
+ github:
71
+ repository: owner/name
72
+ cli: gh-agent # the CLI that acts as the agent's account
73
+ allowed: [alice] # GitHub logins
74
+ feishu:
75
+ cli: lark-bot # the CLI that acts as the bot
76
+ chats: [{ chatId: oc_..., name: Team }]
77
+ allowed: [] # or set syncChat to copy the chat's members
78
+ syncChat: oc_...
79
+ ```
80
+
81
+ The agent acts only as the accounts those CLIs are signed in to. Never point `cli` at a personal login: everything the
82
+ agent writes would appear under that person's name.
83
+
84
+ ### Messages that do not address the agent
85
+
86
+ A message in a chat the bot reads that names no one is assessed, once per message, by one `claude -p` call that prints
87
+ a verdict. Turn this on in `settings.yaml`:
88
+
89
+ ```yaml
90
+ policy:
91
+ mode: observe # off, observe, or auto
92
+ rules:
93
+ - id: unasked # the rule that says the message asks for work at all
94
+ name: Request
95
+ instruction: The discussion asks for a concrete change to this project.
96
+ - id: docs
97
+ name: Documentation
98
+ instruction: The change is to a document in the repository.
99
+ ```
100
+
101
+ `observe` records what `auto` would accept and starts nothing; `auto` accepts the candidates the assessor matches. The
102
+ `unasked` rule is required for an unaddressed message to start work. `superagent status` lists the recent
103
+ judgements under "Unaddressed messages". Keep `observe` until the judgements read right.
104
+
105
+ ## Rules to keep
106
+
107
+ - **Start narrow.** One repository, one chat, one allowed login. Widen after the agent's work looks right.
108
+ - **Tune for less noise.** When the agent is noisy, shorten the prompt or stop it. Do not add messages to explain noise.
109
+ - **Own what it says.** The agent writes under an account the team sees. Read what it posts and correct the prompt.
110
+
111
+ ## Commands
112
+
113
+ | Command | Does |
114
+ | --- | --- |
115
+ | `superagent init [dir]` | create `settings.yaml` and the state directory; a second run keeps both |
116
+ | `superagent status [dir]` | print open and ended tickets, and the recent judgements of unaddressed messages, as Markdown |
117
+ | `superagent doctor [dir]` | show installed agents and the selected one |
118
+ | `superagent agents` | list the agent names a configuration may use |
119
+ | `superagent run [dir] -p <text>` | run one prompt on the configured agent and print its report |
120
+ | `superagent poll [dir] [--once]` | read GitHub notifications, accept mentions as tickets, and run them |
121
+
122
+ The first argument is the installation directory and defaults to the current directory.
123
+
124
+ ## When something is wrong
125
+
126
+ | Symptom | Cause and fix |
127
+ | --- | --- |
128
+ | `No configuration at …` | Run `superagent init` in the installation directory. |
129
+ | `The configuration at … is invalid` | The message names the key; fix that key in `settings.yaml`. |
130
+ | `Selected: **x** — not installed` | Install that CLI or choose another `executor.agent`. |
131
+ | A ticket ends with a failed report | Read `state/tickets/<id>/log.md`; the agent's last message is at the end. |
132
+ | Nothing happens after a mention | Check the author is on the allow list and `enabled` is true for that Source. |
133
+
134
+ ## Going further
135
+
136
+ `src/` holds the whole implementation:
137
+
138
+ - `src/core/` — the domain: triggers, decisions, tickets, assignments, and the engine that joins them. Pure TypeScript.
139
+ - `src/state/files.ts` — durable state as JSON files, with in-memory transactions.
140
+ - `src/agents/` — one file per coding agent, all behind `AgentRunner`.
141
+ - `src/infra/` — the CLI wrappers and the shims that bind a run to the agent's accounts.
142
+
143
+ Change a runner when an agent's output format changes; change the core only when the domain itself changes.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { main } from '../lib/cli.mjs'
3
+ process.exitCode = await main(process.argv.slice(2))