@pimmesz/afterburner 1.0.1
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/.env.example +16 -0
- package/LICENSE +201 -0
- package/README.md +294 -0
- package/afterburner.config.example.ts +94 -0
- package/assets/afterburner-logo.png +0 -0
- package/dist/chunk-2NSOEZWY.js +11 -0
- package/dist/chunk-OZAFLQDP.js +1098 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1524 -0
- package/dist/core/index.d.ts +781 -0
- package/dist/core/index.js +96 -0
- package/dist/mcp/server.d.ts +13 -0
- package/dist/mcp/server.js +8 -0
- package/package.json +75 -0
- package/skill/SKILL.md +38 -0
package/.env.example
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Afterburner reads secrets from the environment only. Never commit a real .env.
|
|
2
|
+
|
|
3
|
+
# Required ONLY for the 'api-key' backend. Bills your Anthropic API account per
|
|
4
|
+
# token at API rates, so every run costs real money.
|
|
5
|
+
#
|
|
6
|
+
# IMPORTANT: with the 'claude-code' backend, leave this UNSET. In headless mode
|
|
7
|
+
# (`claude -p`) a present ANTHROPIC_API_KEY is ALWAYS used and silently takes
|
|
8
|
+
# precedence over your subscription login, so runs would bill the API instead
|
|
9
|
+
# of spending subscription quota. Afterburner strips it from the child process
|
|
10
|
+
# environment as a defense, but don't rely on that alone.
|
|
11
|
+
ANTHROPIC_API_KEY=
|
|
12
|
+
|
|
13
|
+
# Optional, 'claude-code' backend in CI/headless environments without an
|
|
14
|
+
# interactive `claude /login`: generate a long-lived subscription OAuth token
|
|
15
|
+
# with `claude setup-token` and put it here. Scoped to inference only.
|
|
16
|
+
CLAUDE_CODE_OAUTH_TOKEN=
|
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 2026 Afterburner contributors
|
|
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
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/afterburner-logo.png" alt="Afterburner logo" width="150" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Afterburner</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Turn unused Claude subscription quota into small, reviewed pull requests.</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://github.com/pimmesz/afterburner/actions/workflows/ci.yml">
|
|
13
|
+
<img src="https://github.com/pimmesz/afterburner/actions/workflows/ci.yml/badge.svg" alt="CI status" />
|
|
14
|
+
</a>
|
|
15
|
+
<a href="./LICENSE">
|
|
16
|
+
<img src="https://img.shields.io/badge/license-Apache--2.0-blue" alt="Apache-2.0 license" />
|
|
17
|
+
</a>
|
|
18
|
+
<img src="https://img.shields.io/badge/dry--run-default-2ea44f" alt="Dry-run by default" />
|
|
19
|
+
<img src="https://img.shields.io/badge/output-PR--only-f97316" alt="PR-only output" />
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
<p align="center">
|
|
23
|
+
<code>budget-aware</code> · <code>one bounded task</code> · <code>dry-run first</code> ·
|
|
24
|
+
<code>no telemetry</code>
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
Afterburner watches how much of your Claude budget is left. When there's enough headroom, it
|
|
28
|
+
picks one small, checkable coding task against a repo you've allowlisted and shows exactly
|
|
29
|
+
what it would do.
|
|
30
|
+
|
|
31
|
+
The coding agent isn't the interesting part; that already exists. What Afterburner adds is
|
|
32
|
+
the decision layer: working out when it's safe to spend, and what's worth spending on.
|
|
33
|
+
|
|
34
|
+
> Current status: the dry-run path works end to end. Live Claude Code/API execution and real
|
|
35
|
+
> PR creation are still interface stubs in this version.
|
|
36
|
+
|
|
37
|
+
| What it does | Why it matters |
|
|
38
|
+
| ------------------ | ----------------------------------------------------------------------- |
|
|
39
|
+
| Checks both caps | Uses weekly headroom and 5-hour session availability before doing work. |
|
|
40
|
+
| Keeps work bounded | Runs one task per ignition cycle, sized to fit your configured budget. |
|
|
41
|
+
| Stays review-first | Plans a `claude/` branch and PR; live output stays away from default. |
|
|
42
|
+
| Starts safe | Dry-run is the default, and live runs require a two-part opt-in. |
|
|
43
|
+
|
|
44
|
+
> Fair use: Afterburner is for spending your own subscription quota on your own repos. It
|
|
45
|
+
> doesn't get around provider limits; it keeps capacity you've already paid for from going to
|
|
46
|
+
> waste.
|
|
47
|
+
|
|
48
|
+
## The economics
|
|
49
|
+
|
|
50
|
+
Flat-rate Claude plans are use-it-or-lose-it. Whatever you don't use each week is gone, with
|
|
51
|
+
no rollover. The `claude-code` backend is designed to run tasks through your local Claude
|
|
52
|
+
Code login, so it spends quota you're already paying for and costs nothing extra. The
|
|
53
|
+
`api-key` backend is the alternative: it works anywhere, but it bills your Anthropic API
|
|
54
|
+
account per token, so every run costs real money.
|
|
55
|
+
|
|
56
|
+
Two billing details worth knowing (checked against the official docs on 2026-06-11):
|
|
57
|
+
|
|
58
|
+
- From June 15, 2026, headless `claude -p` usage on subscription plans comes out of a
|
|
59
|
+
separate monthly "Agent SDK credit" (Pro $20/mo, Max 5x/20x $100/$200) rather than your
|
|
60
|
+
interactive weekly limits. Afterburner's budget model tracks the interactive limits you can
|
|
61
|
+
see yourself with `/usage` in Claude Code. Think of the SDK credit as the pool that live
|
|
62
|
+
`claude-code` runs actually draw from.
|
|
63
|
+
- Fable-family models cost real money. Outside promotional windows they're excluded from
|
|
64
|
+
subscription plan limits and bill usage credits at API rates. That's why Afterburner blocks
|
|
65
|
+
them by default (see [Safety model](#safety-model)).
|
|
66
|
+
|
|
67
|
+
## Use at your own risk
|
|
68
|
+
|
|
69
|
+
Afterburner runs on your machine, under your accounts, against your repositories. Whatever it
|
|
70
|
+
uses is yours to pay for: it spends your Claude subscription quota, and with the `api-key`
|
|
71
|
+
backend or a Fable/Mythos model it can spend real money billed to your own Anthropic account.
|
|
72
|
+
The maintainers don't run it for you and don't cover anything it does.
|
|
73
|
+
|
|
74
|
+
You're responsible for what it does on your behalf, including the budgets you set, the repos
|
|
75
|
+
you allowlist, the backend you choose, and reviewing any pull request before you merge it.
|
|
76
|
+
Dry-run is the default and live runs need an explicit opt-in precisely so nothing costs you
|
|
77
|
+
anything until you decide it should. The software is provided "as is", without warranty of any
|
|
78
|
+
kind, as set out in the [Apache-2.0 license](./LICENSE).
|
|
79
|
+
|
|
80
|
+
## Safety model
|
|
81
|
+
|
|
82
|
+
These rules live in the code, not just in this README:
|
|
83
|
+
|
|
84
|
+
- Dry-run is the default. A live run needs both the `--live` flag and a live engine
|
|
85
|
+
(`agent.backend`) in the config. Miss either one and you get a dry run.
|
|
86
|
+
- PR-only. Live work is designed to land on a `claude/`-prefixed branch and become a pull
|
|
87
|
+
request. It never merges and never pushes to your default branch.
|
|
88
|
+
- One task per run. The task has to fit inside the budget or be abandoned cleanly. A killed
|
|
89
|
+
run leaves a resumable `claude/` branch, never a half-broken state.
|
|
90
|
+
- Both caps are checked. A run only fires when a 5-hour session window is available and the
|
|
91
|
+
estimated cost plus a safety margin fits inside the remaining weekly budget.
|
|
92
|
+
- Idempotent. Each task gets a deterministic fingerprint, and a fingerprint that already has
|
|
93
|
+
an open or merged PR won't run again.
|
|
94
|
+
- Fable is gated. Any Fable/Mythos-tier model is refused unless you explicitly set
|
|
95
|
+
`agent.allowFable: true`, so an unattended scheduler can't quietly spend at API rates.
|
|
96
|
+
- Untrusted input stays data. Repo contents, issue titles, and PR text never get interpolated
|
|
97
|
+
into shell commands. They go through stdin and environment variables instead.
|
|
98
|
+
- No telemetry, and no repos configured out of the box. The only network call the CLI makes
|
|
99
|
+
on its own is a once-daily npm version check (skipped off-TTY and in CI; disable with
|
|
100
|
+
`NO_UPDATE_NOTIFIER=1`).
|
|
101
|
+
|
|
102
|
+
## Quickstart (60 seconds)
|
|
103
|
+
|
|
104
|
+
Needs Node.js 22.12 or newer and `git` on your PATH.
|
|
105
|
+
|
|
106
|
+
Heads up before you copy-paste: the first release isn't on npm yet, so install from source —
|
|
107
|
+
clone the repo, then `pnpm install && pnpm build && npm install -g .`. Once published, the
|
|
108
|
+
install line below works; the unscoped `afterburner` name on npm is a different, unrelated
|
|
109
|
+
package, so always use the scoped `@pimmesz/afterburner`.
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
npm install -g @pimmesz/afterburner # once published; until then see above
|
|
113
|
+
afterburner init # interactive setup, writes afterburner.config.mjs
|
|
114
|
+
afterburner doctor # checks prerequisites and prints fixes
|
|
115
|
+
afterburner run-once --dry-run
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Point `init` at a repo (or add one to `repos` in the config later), and a dry run shows
|
|
119
|
+
exactly what a live run would do:
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
Mode: DRY-RUN (no side effects)
|
|
123
|
+
Budget (manual: budget.manual / flags): session=available weekly=100% (~3,000,000 Sonnet-eq tokens remaining)
|
|
124
|
+
|
|
125
|
+
repo /path/to/repo
|
|
126
|
+
[tests] Add tests for src/math.ts
|
|
127
|
+
branch claude/tests-c615710cd153
|
|
128
|
+
PR title Add tests for src/math.ts [afterburner:c615710cd153]
|
|
129
|
+
est cost 90,000 Sonnet-equivalent tokens
|
|
130
|
+
[dry-run] Would check out …, create branch claude/tests-c615710cd153, … No side effects were performed.
|
|
131
|
+
|
|
132
|
+
Next
|
|
133
|
+
This was a preview. Live execution ships in a future release; once it does,
|
|
134
|
+
set agent.backend: 'claude-code' in afterburner.config.mjs, then: afterburner run-once --live
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Claude Code skill
|
|
138
|
+
|
|
139
|
+
```sh
|
|
140
|
+
afterburner skill install # copies the skill to ~/.claude/skills/afterburner/
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Then you can ask Claude Code to "run an afterburner dry run", or use `/afterburner`. Both
|
|
144
|
+
drive the same CLI.
|
|
145
|
+
|
|
146
|
+
### MCP server (stub)
|
|
147
|
+
|
|
148
|
+
`afterburner mcp` is a placeholder for exposing run-once, log, and doctor as MCP tools. It's
|
|
149
|
+
documented but not built yet. The CLI and the skill are the supported front-ends.
|
|
150
|
+
|
|
151
|
+
## Scheduling
|
|
152
|
+
|
|
153
|
+
```sh
|
|
154
|
+
afterburner schedule install # recommended: native launchd / systemd / schtasks entry
|
|
155
|
+
afterburner watch # foreground daemon, useful for dev or temporary runs
|
|
156
|
+
afterburner schedule uninstall
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Use `schedule install` for normal unattended use. It lets the OS restart the cadence after
|
|
160
|
+
login/reboot and is more reliable than keeping a terminal process alive. It figures out your
|
|
161
|
+
platform, writes the unit or plist files, and prints the command to activate them.
|
|
162
|
+
|
|
163
|
+
`watch` is still there for foreground runs and for cron expressions that native schedulers
|
|
164
|
+
can't express. If your cron expression is too complex for the native scheduler, `schedule
|
|
165
|
+
install` says so and points you at `watch`.
|
|
166
|
+
|
|
167
|
+
## Configuration
|
|
168
|
+
|
|
169
|
+
`afterburner init` writes `afterburner.config.mjs`. cosmiconfig loads it, and `.js`, `.cjs`,
|
|
170
|
+
and `.ts` variants of `afterburner.config.*` work too (JSON only as `.afterburnerrc.json`).
|
|
171
|
+
A `.ts` config also needs the `typescript` package available at runtime, which is why `init`
|
|
172
|
+
writes `.mjs` by default. There's a commented example in
|
|
173
|
+
[afterburner.config.example.ts](./afterburner.config.example.ts).
|
|
174
|
+
|
|
175
|
+
| Key | Default | What it does |
|
|
176
|
+
| ------------------------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
|
177
|
+
| `repos[]` | `[]` | Allowlist: `url` (remote or local path), `defaultBranch` (`main`), `branchPrefix` (must stay in `claude/`), `enabledTaskCategories` |
|
|
178
|
+
| `budget.provider` | `manual` | `manual`, `claude-code-transcripts`, or `claude-usage` (the automatic ones are described below) |
|
|
179
|
+
| `budget.weeklyAllowanceSonnetTokens` | `5_000_000` | Your plan's weekly capacity estimate, used by the automatic providers |
|
|
180
|
+
| `budget.usageCacheMaxAgeHours` | `12` | `claude-usage` only: a cache older than this falls back to the transcript estimate |
|
|
181
|
+
| `budget.minWeeklyHeadroomPct` | `20` | Don't fire below this much of the weekly cap remaining |
|
|
182
|
+
| `budget.safetyMarginTokens` | `200_000` | Sonnet-equivalent tokens kept untouched on every decision |
|
|
183
|
+
| `budget.requireSessionAvailable` | `true` | Also require a 5-hour session window |
|
|
184
|
+
| `budget.manual` | session ✓ / 100% / 3M | Inputs for the manual provider; you can override them per run with flags |
|
|
185
|
+
| `schedule.cron` / `schedule.timezone` | `17 */4 * * *` / `UTC` | When `watch` and native schedules fire |
|
|
186
|
+
| `agent.backend` | `dry-run` | `dry-run`, `claude-code`, or `api-key` |
|
|
187
|
+
| `agent.modelByCategory` | sonnet/opus/haiku mix | Per-category model routing. Plain strings, so a new model never breaks the config. |
|
|
188
|
+
| `agent.maxTaskTokens` | `200_000` | Hard per-task ceiling in Sonnet-equivalent tokens |
|
|
189
|
+
| `agent.allowFable` | `false` | Explicit opt-in for Fable-family models |
|
|
190
|
+
| `taskCategories` | all enabled, weighted | Per-category enable/disable plus a ranking weight |
|
|
191
|
+
|
|
192
|
+
Task categories are `security`, `tests`, `types-lint`, `dead-code`, `perf`, `infra`, and
|
|
193
|
+
`docs`. Each one comes with a built-in note on how a reviewer confirms it's done.
|
|
194
|
+
|
|
195
|
+
### The budget model
|
|
196
|
+
|
|
197
|
+
Everything is measured in Sonnet-equivalent tokens, normalized through one cost table built
|
|
198
|
+
from published API price ratios (Haiku 1/3x, Sonnet 1x, Opus 1.67x, Fable 3.33x). There's no
|
|
199
|
+
official API for how much subscription quota you have left, so there are three
|
|
200
|
+
estimate-driven providers:
|
|
201
|
+
|
|
202
|
+
- `claude-usage` (automatic, most accurate). Reads the same numbers the `/usage` panel shows:
|
|
203
|
+
your real 5-hour and 7-day usage percentages and the exact reset times. Claude Code hands
|
|
204
|
+
these to its statusLine feature, and `afterburner statusline install` adds a hook that
|
|
205
|
+
caches them. This provider reads that cache. The reset timestamps let a slightly-stale cache
|
|
206
|
+
correct itself (a 5-hour window that has already reset reads as available again), and it
|
|
207
|
+
falls back to the transcript estimate if the cache is missing or older than
|
|
208
|
+
`budget.usageCacheMaxAgeHours`. Setup:
|
|
209
|
+
|
|
210
|
+
```sh
|
|
211
|
+
afterburner statusline install # wraps any existing status line without clobbering it
|
|
212
|
+
# use Claude Code once so it reports usage after the first API response
|
|
213
|
+
# then set budget.provider: 'claude-usage' in your config
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
You still set `budget.weeklyAllowanceSonnetTokens` once. The percentage is authoritative,
|
|
217
|
+
but turning it into a token figure needs to know your plan's size. The cache refreshes
|
|
218
|
+
whenever you use Claude Code interactively.
|
|
219
|
+
|
|
220
|
+
- `claude-code-transcripts` (automatic). Reads your local Claude Code session transcripts
|
|
221
|
+
(`~/.claude/projects/**/*.jsonl`, written live by every session), adds up what you actually
|
|
222
|
+
spent over the last rolling 7 days, converts it through the cost table, and subtracts it
|
|
223
|
+
from `budget.weeklyAllowanceSonnetTokens`. Set the allowance once against `/usage`, and
|
|
224
|
+
after that the remaining budget tracks itself. Session availability stays a manual input,
|
|
225
|
+
since the 5-hour cap isn't exposed locally.
|
|
226
|
+
|
|
227
|
+
- `manual`. You supply the `budget.manual` numbers (check `/usage`), or override them per run:
|
|
228
|
+
|
|
229
|
+
```sh
|
|
230
|
+
afterburner run-once --weekly-remaining-pct 45 --weekly-remaining-tokens 1500000 --session-available true
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Flags override whichever provider you've configured, so you can spot-check the automatic
|
|
234
|
+
numbers whenever you want.
|
|
235
|
+
|
|
236
|
+
## Live execution status
|
|
237
|
+
|
|
238
|
+
1. Pick an engine in `afterburner init` (it explains the cost of each one inline), or set
|
|
239
|
+
`agent.backend` in the config.
|
|
240
|
+
2. For `claude-code`: install Claude Code, log in with `claude /login`, and make sure
|
|
241
|
+
`ANTHROPIC_API_KEY` is unset. In headless mode a present API key quietly takes priority
|
|
242
|
+
over your subscription and bills the API instead. `afterburner doctor` checks for exactly
|
|
243
|
+
this, including which auth method is actually in use. On headless machines, generate a
|
|
244
|
+
token with `claude setup-token` and set `CLAUDE_CODE_OAUTH_TOKEN`.
|
|
245
|
+
3. For `api-key`: export `ANTHROPIC_API_KEY` (see `.env.example`, which ships with the
|
|
246
|
+
package) and accept that runs bill per token.
|
|
247
|
+
4. Arm a run explicitly with `afterburner run-once --live` (or `watch --live`).
|
|
248
|
+
|
|
249
|
+
The live backends are interface stubs in this version. They validate, gate, and then refuse
|
|
250
|
+
with a single clear message (no stack traces). The dry-run path works end to end.
|
|
251
|
+
|
|
252
|
+
## Uninstall
|
|
253
|
+
|
|
254
|
+
```sh
|
|
255
|
+
afterburner schedule uninstall # remove native scheduler entries first
|
|
256
|
+
rm -rf ~/.claude/skills/afterburner # remove the skill if you installed it
|
|
257
|
+
npm uninstall -g @pimmesz/afterburner # also how a source install (`npm install -g .`) is removed
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
The run store lives in your OS data directory; `afterburner doctor` prints the exact path.
|
|
261
|
+
Delete that directory to clear the audit trail.
|
|
262
|
+
|
|
263
|
+
## Threat model
|
|
264
|
+
|
|
265
|
+
- Prompt injection. Repo contents, issue titles, PR bodies, and comments are all untrusted.
|
|
266
|
+
Afterburner never drops them into shell command strings or CI `run:` blocks. They go through
|
|
267
|
+
stdin and environment variables and get read via `process.env`. The invocation builder has
|
|
268
|
+
unit tests that feed it hostile input.
|
|
269
|
+
- Blast radius. PR-only output, the `claude/` branch namespace, one task per run, and a repo
|
|
270
|
+
allowlist. The default branch can't be reached by design.
|
|
271
|
+
- Spending. Dry-run default, a two-part opt-in for live runs, the both-caps budget gate with a
|
|
272
|
+
safety margin, a hard per-task token ceiling, and the Fable gate. The run store
|
|
273
|
+
(`afterburner log`) is an append-only record of what happened.
|
|
274
|
+
- Secrets. Environment variables only (`.env.example` documents them). For subscription runs
|
|
275
|
+
the child process environment has API-key auth stripped out, so billing can't be quietly
|
|
276
|
+
hijacked.
|
|
277
|
+
|
|
278
|
+
## Naming
|
|
279
|
+
|
|
280
|
+
The short alias is `abr`, not `ab`. On most macOS and Linux systems `ab` is ApacheBench, and
|
|
281
|
+
shadowing it would break benchmarking setups.
|
|
282
|
+
|
|
283
|
+
## Roadmap (out of scope for now)
|
|
284
|
+
|
|
285
|
+
Real PR creation and live `claude-code` execution, the live `api-key` backend, an OpenAI
|
|
286
|
+
provider, prebuilt single binaries and a Homebrew tap (the build is set up so these are easy
|
|
287
|
+
to add later), the MCP server beyond its stub, and any web dashboard or vendor notification
|
|
288
|
+
integration. The `Notifier` interface is the seam for that last one.
|
|
289
|
+
|
|
290
|
+
## Contributing and license
|
|
291
|
+
|
|
292
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) (and [DECISIONS.md](./DECISIONS.md) for the reasoning
|
|
293
|
+
behind the less obvious choices), [SECURITY.md](./SECURITY.md), and
|
|
294
|
+
[CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md). Licensed under [Apache-2.0](./LICENSE).
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// Afterburner example configuration.
|
|
2
|
+
//
|
|
3
|
+
// Copy this to `afterburner.config.mjs` (gitignored, since your repo allowlist
|
|
4
|
+
// is private) and adjust it. The contents are plain JS, so .mjs loads
|
|
5
|
+
// everywhere, which is also why `afterburner init` writes .mjs. A .ts config
|
|
6
|
+
// works too, but only where the `typescript` package is resolvable at runtime
|
|
7
|
+
// (a project with typescript installed, not a bare global install).
|
|
8
|
+
//
|
|
9
|
+
// This file is deliberately dependency-free. With a local install of
|
|
10
|
+
// afterburner you can get full type checking instead:
|
|
11
|
+
// import { defineConfig } from '@pimmesz/afterburner';
|
|
12
|
+
// export default defineConfig({ ... });
|
|
13
|
+
const config = {
|
|
14
|
+
// Allowlist of repositories Afterburner may work on. Local paths work too;
|
|
15
|
+
// the built-in deterministic selector only scans local checkouts.
|
|
16
|
+
repos: [
|
|
17
|
+
{
|
|
18
|
+
url: 'https://github.com/your-name/your-repo',
|
|
19
|
+
defaultBranch: 'main',
|
|
20
|
+
// Must stay in the claude/ namespace so automation branches are
|
|
21
|
+
// unmistakable and the default branch is never touched.
|
|
22
|
+
branchPrefix: 'claude/',
|
|
23
|
+
enabledTaskCategories: ['docs', 'tests', 'dead-code'],
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
|
|
27
|
+
budget: {
|
|
28
|
+
// How remaining budget is determined:
|
|
29
|
+
// 'manual': the manual block below.
|
|
30
|
+
// 'claude-code-transcripts': spend computed from local Claude Code
|
|
31
|
+
// sessions (~/.claude/projects), subtracted
|
|
32
|
+
// from the weekly allowance.
|
|
33
|
+
// 'claude-usage': the real 5h/7d usage % and reset times
|
|
34
|
+
// Claude Code reports, captured via the
|
|
35
|
+
// statusLine hook (run `afterburner statusline
|
|
36
|
+
// install`). Most accurate; falls back to the
|
|
37
|
+
// transcript estimate when the cache is stale.
|
|
38
|
+
provider: 'manual',
|
|
39
|
+
// Your plan's total weekly capacity in Sonnet-equivalent tokens. Calibrate
|
|
40
|
+
// it once against /usage in Claude Code. Both automatic providers use it to
|
|
41
|
+
// turn a percentage into a token figure.
|
|
42
|
+
weeklyAllowanceSonnetTokens: 5_000_000,
|
|
43
|
+
// 'claude-usage' only: a cache older than this (hours) falls back to transcripts.
|
|
44
|
+
usageCacheMaxAgeHours: 12,
|
|
45
|
+
// Don't fire below this much of the weekly cap remaining.
|
|
46
|
+
minWeeklyHeadroomPct: 20,
|
|
47
|
+
// Keep this many Sonnet-equivalent tokens untouched on every decision.
|
|
48
|
+
safetyMarginTokens: 200_000,
|
|
49
|
+
// Also require a 5-hour session window to be available.
|
|
50
|
+
requireSessionAvailable: true,
|
|
51
|
+
// Inputs for the manual provider. There is no official API for remaining
|
|
52
|
+
// subscription quota, so check /usage in Claude Code and keep these roughly
|
|
53
|
+
// current (or override them per run with CLI flags). sessionAvailable is
|
|
54
|
+
// read here by the manual and claude-code-transcripts providers;
|
|
55
|
+
// claude-usage reads the real 5-hour window from its cache instead.
|
|
56
|
+
manual: {
|
|
57
|
+
sessionAvailable: true,
|
|
58
|
+
weeklyRemainingPct: 60,
|
|
59
|
+
weeklyRemainingTokensEst: 3_000_000,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
schedule: {
|
|
64
|
+
cron: '17 */4 * * *',
|
|
65
|
+
timezone: 'UTC',
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
agent: {
|
|
69
|
+
// 'dry-run' (default, simulates everything), 'claude-code' (spends the
|
|
70
|
+
// subscription quota you already pay for), or 'api-key' (bills per token,
|
|
71
|
+
// real money). A live run also needs the --live flag (the two-part opt-in).
|
|
72
|
+
backend: 'dry-run',
|
|
73
|
+
// Per-category model routing. Plain strings on purpose, so a new model
|
|
74
|
+
// can't break the config. Omitted categories use the built-in defaults
|
|
75
|
+
// (sonnet for most, opus for perf and infra, haiku for the simple end).
|
|
76
|
+
modelByCategory: {
|
|
77
|
+
perf: 'claude-opus-4-8',
|
|
78
|
+
docs: 'claude-haiku-4-5',
|
|
79
|
+
},
|
|
80
|
+
// Upper bound for a single task, in Sonnet-equivalent tokens.
|
|
81
|
+
maxTaskTokens: 200_000,
|
|
82
|
+
// Fable-family models are gated: roughly 2x Opus against your limits, and
|
|
83
|
+
// outside promotional windows they bill usage credits at API rates.
|
|
84
|
+
allowFable: false,
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
// Per-category enable/disable plus a ranking weight (higher is more valuable).
|
|
88
|
+
taskCategories: {
|
|
89
|
+
docs: { enabled: true, weight: 1 },
|
|
90
|
+
tests: { enabled: true, weight: 4 },
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default config;
|
|
Binary file
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/mcp/server.ts
|
|
2
|
+
var MCP_STUB_MESSAGE = "The MCP server front-end is not implemented yet.\nUse the CLI (afterburner run-once / log / doctor) or the Claude Code skill (afterburner skill install).\nPlanned: an `afterburner mcp` stdio server exposing run-once, log, and doctor as MCP tools.";
|
|
3
|
+
function startMcpServer() {
|
|
4
|
+
console.error(MCP_STUB_MESSAGE);
|
|
5
|
+
process.exit(1);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
MCP_STUB_MESSAGE,
|
|
10
|
+
startMcpServer
|
|
11
|
+
};
|