@defrex/autobuild 1.0.0-beta.4 → 1.0.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/README.md +1 -1
- package/SPEC.md +45 -36
- package/docs/agent-runtimes.md +157 -0
- package/docs/build-store.md +123 -0
- package/docs/builds.md +82 -0
- package/docs/cli.md +48 -0
- package/docs/configuration-overview.md +93 -0
- package/docs/configuration.md +1626 -204
- package/docs/dispatcher-hosting.md +115 -0
- package/docs/dispatcher.md +59 -0
- package/docs/forges.md +121 -0
- package/docs/getting-started.md +60 -0
- package/docs/glossary.md +60 -0
- package/docs/hosted-service.md +2 -2
- package/docs/intake.md +48 -0
- package/docs/integration-overview.md +81 -0
- package/docs/operating.md +114 -0
- package/docs/operator-api.md +6 -6
- package/docs/operator-surfaces.md +90 -0
- package/docs/overview.md +49 -0
- package/docs/plugin-authoring.md +426 -0
- package/docs/remote-store-protocol.md +8 -8
- package/docs/seams.md +66 -0
- package/docs/setup.md +8 -6
- package/docs/skills.md +119 -0
- package/docs/ticket-sources.md +132 -0
- package/docs/tickets.md +69 -0
- package/docs/troubleshooting.md +111 -0
- package/docs/upgrading.md +50 -0
- package/docs/verification.md +146 -0
- package/docs/website.md +47 -5
- package/docs/workspaces.md +152 -0
- package/package.json +5 -4
- package/packages/core/src/cli/env.ts +1 -1
- package/packages/core/src/cli/help.ts +4 -2
- package/packages/core/src/config/landing.ts +8 -0
- package/packages/core/src/config/reference-metadata.ts +31 -0
- package/packages/core/src/config/reference.ts +342 -0
- package/packages/core/src/config/roles.ts +1 -1
- package/packages/core/src/config/schema.ts +344 -6
- package/packages/core/src/ontology.ts +2 -2
- package/packages/core/src/open-map.ts +3 -1
- package/skills/finalize/SKILL.md +3 -1
- package/skills/guide/SKILL.md +42 -25
- package/skills/guide/references/operator-api.md +18 -10
- package/skills/guide/references/plugin-authoring.md +227 -303
- package/skills/guide/references/remote-store-protocol.md +8 -8
- package/skills/guide/references/setup.md +8 -6
- package/skills/implement/SKILL.md +4 -2
- package/skills/operate/SKILL.md +26 -27
- package/skills/plan/SKILL.md +12 -4
- package/skills/spec/SKILL.md +1 -1
- package/skills/tickets/SKILL.md +1 -1
- package/templates/hosted-service/package.json +2 -2
|
@@ -1,96 +1,111 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: "Writing a plugin"
|
|
3
|
+
group: "guides"
|
|
4
|
+
description: "Build, contract-test, package, and publish an Autobuild infrastructure adapter."
|
|
5
|
+
label: "Plugins"
|
|
6
|
+
order: 7
|
|
7
|
+
---
|
|
2
8
|
|
|
3
|
-
|
|
4
|
-
Here, `ab <command>` means the repository-installed CLI; run it as
|
|
5
|
-
`bun ab <command>`, for example `bun ab init`.
|
|
9
|
+
# Writing a plugin
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
conformance or a
|
|
11
|
+
A plugin is a trusted Bun module, loaded in-process from the consuming repository, that connects Autobuild to another ticket tracker, agent runtime, workspace system or forge.
|
|
12
|
+
|
|
13
|
+
Install Autobuild in the target repository with `bun add -d --exact @defrex/autobuild`; `ab <command>` below means `bun ab <command>` there.
|
|
14
|
+
|
|
15
|
+
**Definition of done for an adapter: the unchanged shared contract suite for its port passes.** Interface conformance or a clean `ab plugin doctor` is not enough.
|
|
12
16
|
|
|
13
17
|
## 1. Choose the port and preserve its semantics
|
|
14
18
|
|
|
15
|
-
Import public types only from `@defrex/autobuild/plugin-sdk`;
|
|
16
|
-
paths are not API.
|
|
19
|
+
Import public types only from `@defrex/autobuild/plugin-sdk`; internal module paths are not API.
|
|
17
20
|
|
|
18
|
-
|
|
|
21
|
+
| Port | Manifest map | Factory returns | Selected by |
|
|
19
22
|
|---|---|---|---|
|
|
20
|
-
| `ticket-source` | `ticketSources` | `TicketSource` |
|
|
21
|
-
| `agent-runtime` | `agentRuntimes` | `RuntimeRegistration` |
|
|
22
|
-
| `workspace-provider` | `workspaceProviders` | `WorkspaceProvider` |
|
|
23
|
-
| `forge` | `forges` | `Forge` |
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
never
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
23
|
+
| `ticket-source` | `ticketSources` | `TicketSource` | `[tickets].source` |
|
|
24
|
+
| `agent-runtime` | `agentRuntimes` | `RuntimeRegistration` | `[roles.*].runtime` |
|
|
25
|
+
| `workspace-provider` | `workspaceProviders` | `WorkspaceProvider` | `[workspace].provider` |
|
|
26
|
+
| `forge` | `forges` | `Forge` | root `forge` key |
|
|
27
|
+
|
|
28
|
+
All four manifest maps have production selectors. Omitted forge and workspace selectors default to builtin `github` and `git-worktree`; roles keep normal runtime inheritance.
|
|
29
|
+
|
|
30
|
+
`BuildStore` and `BlobStore` contract types are exported for remote-server authors, but BuildStore is **not** an in-process manifest map: implement the language-neutral remote store protocol and run its conformance path. `TelemetrySource` is a frozen port type with no plugin registration surface in this release.
|
|
31
|
+
|
|
32
|
+
### `ticket-source`
|
|
33
|
+
|
|
34
|
+
Lists, gets and claims tickets to start builds; receives comments, transitions, creates and updates. Owns lifecycle names, dependency completion, idempotent creation with a stable external creation-key projection, and partial-list diagnostics. Never consulted mid-build; not artifact storage.
|
|
35
|
+
|
|
36
|
+
### `agent-runtime`
|
|
37
|
+
|
|
38
|
+
Wrap an `AgentRunner` that supports:
|
|
39
|
+
|
|
40
|
+
- start, continue and end, with complete transcripts and usage
|
|
41
|
+
- per-turn environment refresh, and cancellation that keeps an endable handle for transcript deposition
|
|
42
|
+
- typed failures: verbatim message, retry-compatible `permanent` bit, optional `cause: availability | exhaustion | credentials | configuration` routing evidence
|
|
43
|
+
- the distribution-managed `ab` launcher
|
|
44
|
+
|
|
45
|
+
Declare served model prefixes and a default. Optional tool-free `oneShot` sits beside the runner interface.
|
|
46
|
+
|
|
47
|
+
### `workspace-provider`
|
|
48
|
+
|
|
49
|
+
- Provision an absolute, writable working copy for the requested branch; return durable base evidence.
|
|
50
|
+
- Resume an intact branch non-destructively, never silently re-cut from a newer base. Rematerialize a lost copy. Make release idempotent.
|
|
51
|
+
- Optional `provision.publication` supplies a durable confirmed SHA and known cache tips for authoritative readback and cache repair. Preserve unknown unpublished work.
|
|
52
|
+
|
|
53
|
+
### `forge`
|
|
54
|
+
|
|
55
|
+
- Kernel-owned regular pushes, idempotent PR opening, PR-state projection, gated and ungated auto-merge, head-guarded squash merge, and comments. Agents never receive forge credentials or push.
|
|
56
|
+
- API 1.2: optional idempotent `closePr` and `deleteBranch` for abort cleanup. `closePr` must preserve a racing merge. Without them, cleanup stays visibly pending.
|
|
57
|
+
- Optional `prAttachments` hosts images; the text-only path must work without it.
|
|
58
|
+
|
|
59
|
+
### Reconcile rewrites
|
|
60
|
+
|
|
61
|
+
Reconcile requires the optional grouped `Forge.rewrite` capability:
|
|
62
|
+
|
|
63
|
+
1. Snapshot the actual build branch into a build-private ref.
|
|
64
|
+
2. Publish immutable exact-SHA refs under `refs/autobuild/archive/<slug>/<sha>`.
|
|
65
|
+
3. Replace the explicit branch, leased on an explicit expected remote head.
|
|
66
|
+
|
|
67
|
+
- Return `lease-mismatch` separately from transport, auth and policy failures.
|
|
68
|
+
- If the CAS succeeds but another writer advances the branch before readback, return `lease-mismatch` with `rewritten: true` and the observed `actual` head. The kernel records the write and retries without claiming completion.
|
|
69
|
+
- After an acknowledged replacement, reattach the matching detached workspace HEAD to the build branch so later publication works.
|
|
70
|
+
- Never overwrite unknown work or fall back to merging, ordinary pushes, archive branches or tags.
|
|
71
|
+
- Older forge plugins still load; reconcile refuses them actionably.
|
|
72
|
+
- Remote workspace providers also need trusted `WorkspacePublication.rewrite` after guest teardown; ordinary `publish` can't publish a restack.
|
|
73
|
+
|
|
74
|
+
### Publication readback
|
|
75
|
+
|
|
76
|
+
Publication succeeds only when an authoritative branch-head readback equals the frozen intended SHA, including recovery after a failed push. Unconfirmed candidate ancestry never proves publication.
|
|
77
|
+
|
|
78
|
+
- `pushBranch(workspacePath, branch, sha?)` receives the frozen SHA from kernel callers and stays fast-forward only. Legacy callers may omit the SHA to select HEAD.
|
|
79
|
+
- `confirmPublication` inspects the authoritative head and refreshes caches only on an exact SHA match. Kernel callers refuse adapters lacking it before pushing.
|
|
80
|
+
- Remote-backed local refs are caches: set them unconditionally after confirmation, fetching the advertised ref if objects are missing, without resetting checkout files. `localExpected` is historical input only. Local-git's shared ref database stays authoritative and keeps CAS.
|
|
81
|
+
- Hosted `WorkspacePublication` must provide authoritative `isPublished`, and confirm after writing and before retrying.
|
|
82
|
+
- Remote inspection must not resume a stopped guest or run commands in it; refresh the guest cache inside trusted publication before stopping it. Missing inspection fails actionably.
|
|
83
|
+
|
|
84
|
+
### Forge failures and request accounting
|
|
85
|
+
|
|
86
|
+
API 1.8 adds optional forge failure classification. Import `ForgeFailure` and `isForgeFailure`, plus the types `ForgeFailureDetails`, `ForgeRequestObserver` and `ForgeRequestContext`, from `@defrex/autobuild/plugin-sdk`.
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
// Rate limit, with a valid ISO reset timestamp:
|
|
90
|
+
throw new ForgeFailure(message, { kind: 'rate-limited', resetAt })
|
|
91
|
+
// Retryable transport error:
|
|
92
|
+
throw new ForgeFailure(message, { kind: 'transient', retry: 'retryable' })
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
- Don't classify ordinary policy and permission refusals; they remain deferrals. Never include credentials.
|
|
96
|
+
- The `forgeFailure: 'autobuild.forge-failure.v1'` discriminant and validated details work across separately loaded SDK copies. Arbitrary legacy errors aren't classified.
|
|
97
|
+
|
|
98
|
+
Optional `Forge.observeRequests(observer): () => void` returns a disposer and calls each observer once per wire request, including failures and pagination.
|
|
99
|
+
|
|
100
|
+
- Pass `ForgeRequestContext` with the build slug, or `{}` when unknown; the host fills missing attribution from its current build-scoped operation, else the request is repository/unattributed. Capture context before awaiting transport; notify after the outcome.
|
|
101
|
+
- Credential discovery and skipped calls are not provider requests.
|
|
102
|
+
|
|
103
|
+
| `outcome` | Request |
|
|
104
|
+
|---|---|
|
|
105
|
+
| `restPrimary` | REST HTTP response other than 304 |
|
|
106
|
+
| `restNotModified` | REST 304 |
|
|
107
|
+
| `graphql` | GraphQL call, including failures |
|
|
108
|
+
| omitted | network failure (no proven REST debit) |
|
|
94
109
|
|
|
95
110
|
```ts
|
|
96
111
|
observeRequests(observer: ForgeRequestObserver) {
|
|
@@ -103,48 +118,29 @@ for (const observer of this.observers) {
|
|
|
103
118
|
}
|
|
104
119
|
```
|
|
105
120
|
|
|
106
|
-
|
|
107
|
-
and observations across builds, and tears down on rejection too. Keep concurrent
|
|
108
|
-
operations outside that scope independent. Optional `primeNodeReads({workspacePath,
|
|
109
|
-
parent, head, prNumber?})` seeds opened-node facts. Priming is an optimization:
|
|
110
|
-
non-cooldown failures produce a diagnostic and fall through to ordinary stage
|
|
111
|
-
reads, preserving parent recovery when the previous parent disappeared.
|
|
112
|
-
Neither capability changes the
|
|
113
|
-
plugin API version requirement. Invalidate observations before writes, including
|
|
114
|
-
uncertain writes and Git pushes; acknowledgement and readiness reads must stay
|
|
115
|
-
fresh. Branch and ref endpoints share normalized facts, never HTTP validators.
|
|
116
|
-
|
|
117
|
-
Declare `apiVersion: '^1.8.0'` when using these capabilities. Compatible legacy
|
|
118
|
-
1.x plugins still load without observers and show unavailable counts. Arbitrary
|
|
119
|
-
legacy errors are not classified automatically.
|
|
120
|
-
|
|
121
|
-
Plugin API 1.7 extends the workspace-provider factory context with the
|
|
122
|
-
host-derived seams a store-requiring remote provider needs. Workspace-provider
|
|
123
|
-
factories additionally receive `storeRef` and `delegateCredential` (guaranteed present
|
|
124
|
-
when the registration declares `capabilities.storeRequirements`),
|
|
125
|
-
`runtimeReferences` (the host's effective runtime routes; absent at call sites
|
|
126
|
-
that reference no runtimes), and the checkout-less `origin` and
|
|
127
|
-
`remoteBranchHead` readers (absent means fall back to host `git` from
|
|
128
|
-
`repoRoot`). All five are optional, and a factory that ignores them changes
|
|
129
|
-
nothing. A plugin reading the new seams should declare an API range containing
|
|
130
|
-
`^1.7.0`.
|
|
131
|
-
|
|
132
|
-
`BuildStore` and `BlobStore` contract types are exported for remote-server
|
|
133
|
-
authors, but BuildStore is **not** an in-process manifest map. Implement the
|
|
134
|
-
colocated language-neutral
|
|
135
|
-
[remote store protocol](remote-store-protocol.md) and run its conformance path
|
|
136
|
-
instead. `TelemetrySource` is a frozen port type with no plugin registration
|
|
137
|
-
surface in this release.
|
|
138
|
-
|
|
139
|
-
All four manifest maps have production selectors. Use `[tickets].source` for a
|
|
140
|
-
ticket source, the root `forge` key for a forge, `[workspace].provider` for a
|
|
141
|
-
workspace provider, and `[roles.*].runtime` for an agent runtime. Omitted forge
|
|
142
|
-
and workspace selectors retain the builtin `github` and `git-worktree` defaults;
|
|
143
|
-
role inheritance retains its normal runtime fallback.
|
|
121
|
+
Declare `apiVersion: '^1.8.0'` for these capabilities. Legacy 1.x plugins load without observers and show unavailable counts.
|
|
144
122
|
|
|
145
|
-
|
|
123
|
+
### Read scopes
|
|
124
|
+
|
|
125
|
+
Forge optimizations that don't change the required plugin API version:
|
|
146
126
|
|
|
147
|
-
|
|
127
|
+
- **`withReadScope(work)`** wraps a dispatcher tick, sharing promises and observations across builds; tears down on rejection too. Operations outside the scope stay independent.
|
|
128
|
+
- **`primeNodeReads({workspacePath, parent, head, prNumber?})`** seeds opened-node facts. Non-cooldown failures emit a diagnostic and fall through to ordinary stage reads, preserving recovery when the previous parent disappeared.
|
|
129
|
+
|
|
130
|
+
Invalidate observations before writes, including uncertain writes and Git pushes. Acknowledgement and readiness reads stay fresh. Branch and ref endpoints share normalized facts, never HTTP validators.
|
|
131
|
+
|
|
132
|
+
### API versions
|
|
133
|
+
|
|
134
|
+
A plugin relying on a capability declares an `apiVersion` range containing its version (for example `^1.5.0`). Legacy plugins without newer fields keep working.
|
|
135
|
+
|
|
136
|
+
- **1.2** Forge `closePr` and `deleteBranch`.
|
|
137
|
+
- **1.3** `AgentRunner` failure `cause` and the `exhaustion-failure` contract scenario. Without `cause`, `permanent: false` is eligible for a configured alternate; `permanent: true` stops the chain.
|
|
138
|
+
- **1.4** Optional `Ticket.creationKey`: the stable external create/adoption key, projected from `create`, `get` and `listReady`, correlating ready tickets with durable Harvest reservations while blocker recording is unfinished. Legacy tickets may omit it.
|
|
139
|
+
- **1.5** `path` is the path in the workspace environment; set optional `localPath` only when the dispatcher can reach that same copy directly. Workspace-owned executors receive the durable provider locator as `BuildExecutionStart.workspaceRef`; local PID supervision stays host-owned.
|
|
140
|
+
- **1.7** Workspace factory seams.
|
|
141
|
+
- **1.8** Forge failure classification and request observers.
|
|
142
|
+
|
|
143
|
+
## 2. Create a repository-local module
|
|
148
144
|
|
|
149
145
|
```text
|
|
150
146
|
my-repository/
|
|
@@ -152,8 +148,7 @@ my-repository/
|
|
|
152
148
|
└── autobuild-plugin.ts
|
|
153
149
|
```
|
|
154
150
|
|
|
155
|
-
Use
|
|
156
|
-
only types:
|
|
151
|
+
Use `import type` for SDK symbols that are only types:
|
|
157
152
|
|
|
158
153
|
```ts
|
|
159
154
|
import type {
|
|
@@ -175,50 +170,40 @@ export default {
|
|
|
175
170
|
} satisfies AutobuildPluginManifest
|
|
176
171
|
```
|
|
177
172
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
fall back to host `git` from `repoRoot`.
|
|
213
|
-
|
|
214
|
-
Add the module specifier at the TOML root, before any table. Repository-path
|
|
215
|
-
specifiers resolve from the config-bearing root, which is the immutable build
|
|
216
|
-
worktree in scoped phases. npm package specifiers resolve from the consuming
|
|
217
|
-
main checkout's installed dependencies first, then from the Autobuild
|
|
218
|
-
installation the CLI runs from as a fallback. Install extensions in the
|
|
219
|
-
consuming repository with `bun add -d --exact @defrex/autobuild-<extension>`;
|
|
220
|
-
a repository copy wins over an installed one, and missing packages fail and
|
|
221
|
-
are never installed automatically:
|
|
173
|
+
### The manifest
|
|
174
|
+
|
|
175
|
+
Every module default-exports one strict `AutobuildPluginManifest`:
|
|
176
|
+
|
|
177
|
+
- **`name`** Nonblank diagnostic and ownership identity; need not equal the npm package name.
|
|
178
|
+
- **`apiVersion`** A semver **range accepted by the plugin**, not its package version: the narrowest range containing the host plugin API you ran contracts against. `ab plugin list` reports it beside the host version; invalid or incompatible ranges fail loading.
|
|
179
|
+
- **Registration keys** Only `ticketSources`, `agentRuntimes`, `workspaceProviders` and `forges`; unknown fields fail validation.
|
|
180
|
+
- **Adapter names** Register verbatim. Declare `__proto__` computed, `{ ['__proto__']: factory }`; a plain `__proto__:` key sets the prototype. Parsed maps have a null prototype, so undeclared names read `undefined`. Blank or whitespace-only names are rejected.
|
|
181
|
+
- **Registrations** A bare adapter factory, or `{ factory, contract: { factory, live? } }` whose contract factory returns that port suite's fixture factory. Ticket-source descriptors may declare a deduplicated `requiredEnv` list; the host rejects missing or empty credentials before invoking the selected factory.
|
|
182
|
+
|
|
183
|
+
### Factory context
|
|
184
|
+
|
|
185
|
+
Every adapter and contract factory receives `{ config, env, repoRoot }`: read-only `config`, the process `env`, and `repoRoot`, the absolute consuming-repository root.
|
|
186
|
+
|
|
187
|
+
| Port | `config` |
|
|
188
|
+
|---|---|
|
|
189
|
+
| ticket-source | the existing strict `[tickets]` fields; no untyped plugin-options table |
|
|
190
|
+
| workspace-provider | the open `[workspace.config]` table, the only place for adapter-owned settings |
|
|
191
|
+
| agent-runtime, forge | an empty object |
|
|
192
|
+
|
|
193
|
+
Workspace-provider factories also receive optional host-derived seams (API 1.7), absent when the call site has none; ignoring them changes nothing.
|
|
194
|
+
|
|
195
|
+
- **`storeRef`, `delegateCredential`** Store URL and credential-exchange callback; guaranteed when the registration declares `capabilities.storeRequirements`.
|
|
196
|
+
- **`runtimeReferences`** The host's effective runtime routes.
|
|
197
|
+
- **`origin`, `remoteBranchHead`** Checkout-less readers; when absent, fall back to host `git` from `repoRoot`.
|
|
198
|
+
|
|
199
|
+
Remote workspace factories must call `delegateCredential(storeRef, undefined, target)` for per-resource grants before provisioning or launching guests; parent authority stays in host composition.
|
|
200
|
+
|
|
201
|
+
- `storeToken` is retired and never supplied; factory environments exclude `AB_TOKEN`. Plugins that forwarded it must migrate to the callback and fail closed without it.
|
|
202
|
+
- Launch credentials travel through the separate transient execution-auth argument, never serialized execution identity.
|
|
203
|
+
|
|
204
|
+
### Configure and resolve
|
|
205
|
+
|
|
206
|
+
List module specifiers at the TOML root, before any table, and select adapters:
|
|
222
207
|
|
|
223
208
|
```toml
|
|
224
209
|
plugins = ["./autobuild-plugin.ts"]
|
|
@@ -229,67 +214,40 @@ source = "file"
|
|
|
229
214
|
readyState = "ready"
|
|
230
215
|
```
|
|
231
216
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
so edits between phase commands
|
|
254
|
-
|
|
255
|
-
rules
|
|
256
|
-
|
|
257
|
-
Each configured specifier string must be unique. An exact repeat fails config
|
|
258
|
-
validation before Bun resolves or evaluates any plugin, identifies the repeated
|
|
259
|
-
value and both list positions, and tells the operator to remove or deduplicate
|
|
260
|
-
the entry. Distinct specifiers remain separate declarations.
|
|
261
|
-
|
|
262
|
-
Select only the adapters the repository uses. Set `forge = "acme"` for the
|
|
263
|
-
example forge above; set `[tickets].source`, `[workspace].provider`, or a
|
|
264
|
-
`[roles.*].runtime` to the matching registration name for the other ports.
|
|
265
|
-
Ticket plugins receive the existing strict `[tickets]` fields—there is no
|
|
266
|
-
untyped plugin-options table. Workspace plugins put adapter-owned settings only
|
|
267
|
-
under the open `[workspace.config]` table.
|
|
268
|
-
|
|
269
|
-
Plugin modules load in declaration order. Resolution/evaluation failure, a
|
|
270
|
-
missing or malformed default export, incompatible API range, or collision
|
|
271
|
-
fails before claims/builds. Builtin and earlier-plugin names cannot be
|
|
272
|
-
shadowed within one port; a collision between distinct plugins identifies the
|
|
273
|
-
adapter and both owners. The same adapter name may exist on different ports.
|
|
274
|
-
Registration is atomic per manifest. Plugins are trusted like configured shell
|
|
275
|
-
commands: Bun evaluates them in-process with repository authority and no
|
|
276
|
-
sandbox.
|
|
217
|
+
- Repository-path specifiers resolve from the config-bearing root, which is the immutable build worktree in scoped phases.
|
|
218
|
+
- npm package specifiers resolve from the consuming main checkout's installed dependencies first, then from the Autobuild installation the CLI runs from.
|
|
219
|
+
- Install extensions in the consuming repository with `bun add -d --exact @defrex/autobuild-<extension>`; a repository copy wins over an installed one, and missing packages fail and are never installed automatically.
|
|
220
|
+
- Specifiers must be unique: an exact repeat fails config validation before any plugin loads, naming the value and both positions.
|
|
221
|
+
|
|
222
|
+
### Loading rules
|
|
223
|
+
|
|
224
|
+
- Modules load in declaration order; registration is atomic per manifest.
|
|
225
|
+
- Resolution or evaluation failure, a missing or malformed default export, an incompatible API range, or a collision fails before any claims or builds.
|
|
226
|
+
- Within one port, builtin and earlier-plugin names can't be shadowed; a collision names the adapter and both owners. Different ports may share a name.
|
|
227
|
+
- Plugins are trusted like configured shell commands: Bun evaluates them in-process with repository authority and no sandbox.
|
|
228
|
+
|
|
229
|
+
### Cached dispatcher generations
|
|
230
|
+
|
|
231
|
+
In a cached dispatcher generation, selection uses the same roots, but selected external plugin code and its installed dependency closure are copied into an immutable auxiliary snapshot.
|
|
232
|
+
|
|
233
|
+
- ESM, CommonJS `require`, delayed imports, export-from and module-anchored `createRequire` all resolve the core package, SDK values and classes included, to the same frozen runtime, without loader hooks or source transforms.
|
|
234
|
+
- Repo-path modules copy their literal import closure and literal `new URL(..., import.meta.url)` assets, not the checkout or unused dev dependencies. Packaged plugins keep their package's assets and dependency graph.
|
|
235
|
+
- Package-relative assets stay beside copied modules. `import.meta.url` and filenames name the snapshot; cwd and factory `repoRoot` remain the consuming checkout. Explicit absolute paths stay plugin-controlled external resources.
|
|
236
|
+
- Snapshots use neutral compiler boundaries; cached Bun entrypoints pin the core config with `--no-install --tsconfig-override`. Autobuild-owned compiler chains can't escape the runtime; installed third-party development configs are preserved byte-for-byte.
|
|
237
|
+
- New selections can prepare new snapshots without changing the generation's core identity. Live plugin processes keep their core runtime independently of Store leases.
|
|
238
|
+
- Plugin-loading CLI calls reclaim dead snapshots, so edits between phase commands don't pile up checkout-sized copies.
|
|
239
|
+
|
|
240
|
+
Noncached consumers follow the separately loaded SDK compatibility rules in section 1.
|
|
277
241
|
|
|
278
242
|
## 3. Keep secrets out of source and config
|
|
279
243
|
|
|
280
|
-
Never put credentials in `autobuild.toml`, the manifest, committed fixtures
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
local values in ignored environment files or the process secret manager.
|
|
284
|
-
Validate missing credentials when the selected adapter or live fixture is
|
|
285
|
-
created, not at module top level, so registration remains lazy and diagnostics
|
|
286
|
-
can inspect unrelated adapters. Ticket-source descriptors should declare
|
|
287
|
-
`requiredEnv` when the host can enforce the credential names before factory
|
|
288
|
-
invocation; other ports validate their environment in their factories.
|
|
244
|
+
- Never put credentials in `autobuild.toml`, the manifest, committed fixtures or contract output.
|
|
245
|
+
- Read them from the factory's `env` (for example `env.ACME_FORGE_TOKEN`), document the required environment variables, and keep local values in ignored env files or a secret manager.
|
|
246
|
+
- Validate credentials when the selected adapter or live fixture is created, not at module top level, so registration stays lazy and diagnostics can inspect unrelated adapters. Ticket-source descriptors should declare `requiredEnv`; other ports check in their factories.
|
|
289
247
|
|
|
290
248
|
## 4. Add the contract harness first
|
|
291
249
|
|
|
292
|
-
A contract-bearing registration
|
|
250
|
+
A contract-bearing registration:
|
|
293
251
|
|
|
294
252
|
```ts
|
|
295
253
|
const manifest = {
|
|
@@ -304,25 +262,22 @@ const manifest = {
|
|
|
304
262
|
} satisfies AutobuildPluginManifest
|
|
305
263
|
```
|
|
306
264
|
|
|
307
|
-
The
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
by `@defrex/autobuild/plugin-sdk`. The host invokes the unchanged shared suite; do not
|
|
311
|
-
copy, wrap, skip, or weaken its assertions.
|
|
265
|
+
The contract factory returns a `TicketSourceContractFactory`, `AgentRunnerContractFactory`, `WorkspaceProviderContractFactory` or `ForgeContractFactory` (harness types from `@defrex/autobuild/plugin-sdk`). The host runs the unchanged shared suite; don't copy, wrap, skip or weaken its assertions.
|
|
266
|
+
|
|
267
|
+
Contract fixtures must:
|
|
312
268
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
make retries
|
|
317
|
-
|
|
318
|
-
`contract: { factory, live: true }
|
|
319
|
-
operator explicitly sets:
|
|
269
|
+
- isolate resources (UUID-namespaced records, branches, PRs, sessions or workspaces)
|
|
270
|
+
- expose the independent controls and probes their harness type requires
|
|
271
|
+
- clean up in `cleanup`, even after an assertion failure
|
|
272
|
+
- make retries and release idempotent where the port requires it
|
|
273
|
+
|
|
274
|
+
A fixture that contacts a provider or mutates external resources must declare `contract: { factory, live: true }` and runs only with an explicit opt-in:
|
|
320
275
|
|
|
321
276
|
```sh
|
|
322
277
|
AB_RUN_LIVE_PORT_CONTRACTS=1 ab plugin test forge acme
|
|
323
278
|
```
|
|
324
279
|
|
|
325
|
-
|
|
280
|
+
Author loop:
|
|
326
281
|
|
|
327
282
|
```sh
|
|
328
283
|
ab plugin list
|
|
@@ -330,25 +285,19 @@ ab plugin doctor
|
|
|
330
285
|
ab plugin test ticket-source acme
|
|
331
286
|
```
|
|
332
287
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
per-test output, and returns its exit status.
|
|
288
|
+
| Command | Does |
|
|
289
|
+
|---|---|
|
|
290
|
+
| `list` | builtins and configured registrations: provenance, resolution, API compatibility, contract availability |
|
|
291
|
+
| `doctor` | loads every configured module, nonzero if any fail; not a semantics check |
|
|
292
|
+
| `test` | runs the unchanged suite for one port and adapter, forwards per-test output, returns its exit status |
|
|
339
293
|
|
|
340
|
-
Repeat after every adapter change
|
|
341
|
-
shared suite is green (with the explicit live opt-in when applicable).
|
|
294
|
+
Repeat after every adapter change until the suite is green, with the live opt-in when applicable.
|
|
342
295
|
|
|
343
296
|
## 5. Zero-network wiring walkthrough
|
|
344
297
|
|
|
345
|
-
This
|
|
346
|
-
configuration, and the TicketSource contract bridge without network access. It
|
|
347
|
-
uses Autobuild's reference fake and is **only a wiring exercise**. Replace the
|
|
348
|
-
fake and fixture with the real provider implementation; certification means the
|
|
349
|
-
real adapter's harness passes the same unchanged suite.
|
|
298
|
+
This scratch example proves module resolution, manifest spelling, configuration and the TicketSource contract bridge offline. It uses Autobuild's reference fake, so it is **only a wiring exercise**; your real adapter's harness must still pass the same suite.
|
|
350
299
|
|
|
351
|
-
Create `autobuild-plugin.ts
|
|
300
|
+
Create `autobuild-plugin.ts`:
|
|
352
301
|
|
|
353
302
|
<!-- plugin-authoring-walkthrough-module:start -->
|
|
354
303
|
```ts
|
|
@@ -404,14 +353,11 @@ ab plugin list
|
|
|
404
353
|
ab plugin test ticket-source walkthrough
|
|
405
354
|
```
|
|
406
355
|
|
|
407
|
-
`ab init`
|
|
408
|
-
must show the `walkthrough` plugin/adapter, and the final command must exit zero
|
|
409
|
-
with the TicketSource contract tests.
|
|
356
|
+
`ab init` keeps the existing config and vendors this guide. Doctor and list show the `walkthrough` plugin and adapter; the contract run exits zero.
|
|
410
357
|
|
|
411
358
|
## 6. Package and publish when reuse warrants it
|
|
412
359
|
|
|
413
|
-
A repository-local module
|
|
414
|
-
npm plugin, keep one public module and an ordinary test/typecheck setup:
|
|
360
|
+
A repository-local module needs no packaging. An npm plugin needs one public module plus ordinary test and typecheck setup:
|
|
415
361
|
|
|
416
362
|
```text
|
|
417
363
|
acme-autobuild-plugin/
|
|
@@ -421,7 +367,7 @@ acme-autobuild-plugin/
|
|
|
421
367
|
└── bun.lock
|
|
422
368
|
```
|
|
423
369
|
|
|
424
|
-
|
|
370
|
+
This manifest declares only the tested host release (`1.0.0-beta.2`); widen it only after the unchanged contracts pass on each added host.
|
|
425
371
|
|
|
426
372
|
```json
|
|
427
373
|
{
|
|
@@ -435,24 +381,14 @@ A representative package manifest is:
|
|
|
435
381
|
"test": "bun test",
|
|
436
382
|
"prepublishOnly": "bun run typecheck && bun test"
|
|
437
383
|
},
|
|
438
|
-
"devDependencies": { "autobuild": "
|
|
439
|
-
"peerDependencies": { "autobuild": "
|
|
440
|
-
"peerDependenciesMeta": { "autobuild": { "optional": true } }
|
|
384
|
+
"devDependencies": { "@defrex/autobuild": "1.0.0-beta.2", "typescript": "5.9.3" },
|
|
385
|
+
"peerDependencies": { "@defrex/autobuild": "1.0.0-beta.2" },
|
|
386
|
+
"peerDependenciesMeta": { "@defrex/autobuild": { "optional": true } }
|
|
441
387
|
}
|
|
442
388
|
```
|
|
443
389
|
|
|
444
|
-
|
|
445
|
-
an
|
|
446
|
-
optional peer declaration communicates tested host-package compatibility to
|
|
447
|
-
package consumers without making plugin execution depend on a second Autobuild
|
|
448
|
-
copy. Runtime imports (for example importing a reference fake in the scratch
|
|
449
|
-
walkthrough) are different and require a runtime dependency; do not ship the
|
|
450
|
-
fake walkthrough as a production adapter.
|
|
451
|
-
|
|
452
|
-
Keep the package's own semver independent from the manifest's `apiVersion`
|
|
453
|
-
range. On an incompatible host plugin API, update the adapter and contracts,
|
|
454
|
-
change the range only after they pass against that host, and release the
|
|
455
|
-
package version according to the user-visible compatibility change.
|
|
390
|
+
- **Dependencies.** Type-only SDK imports erase, so Autobuild is a dev dependency, not a runtime `dependencies` entry. The optional peer names the tested host without loading a second Autobuild copy. Runtime imports, such as the reference fake, need a runtime dependency; never ship the fake as a production adapter.
|
|
391
|
+
- **Versions.** Package semver is independent of the host range and `apiVersion`. On an incompatible host plugin API, update adapter and contracts, change the range once they pass, and version the package by the user-visible compatibility change.
|
|
456
392
|
|
|
457
393
|
Before publishing:
|
|
458
394
|
|
|
@@ -465,38 +401,26 @@ npm pack
|
|
|
465
401
|
npm publish --access public
|
|
466
402
|
```
|
|
467
403
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
policy says otherwise.
|
|
404
|
+
1. Check the dry-run and tarball file lists for source, secrets, local fixtures and missing exports.
|
|
405
|
+
2. Install the tarball in a scratch consuming repository with `plugins = ["@acme/autobuild-plugin"]`.
|
|
406
|
+
3. Rerun `ab plugin doctor`, `ab plugin list` and the contract command.
|
|
407
|
+
|
|
408
|
+
Drop `--access public` when the registry or access policy says otherwise.
|
|
474
409
|
|
|
475
410
|
Official npm references: [`package.json` fields](https://docs.npmjs.com/cli/v11/configuring-npm/package-json),
|
|
476
411
|
[`npm pack`](https://docs.npmjs.com/cli/v11/commands/npm-pack), and
|
|
477
412
|
[`npm publish`](https://docs.npmjs.com/cli/v11/commands/npm-publish).
|
|
478
413
|
|
|
479
|
-
Remote workspace factories must use `delegateCredential(storeRef, undefined,
|
|
480
|
-
target)` to obtain per-resource grants before provisioning or launching guests.
|
|
481
|
-
The callback keeps parent authority in host composition. `storeToken` is retired
|
|
482
|
-
and is never supplied; factory environments also exclude `AB_TOKEN`. Launch
|
|
483
|
-
credentials travel through the separate transient execution-auth argument, never
|
|
484
|
-
through serialized execution identity. Existing plugins that forwarded
|
|
485
|
-
`storeToken` must migrate to this callback and fail closed if it is unavailable.
|
|
486
|
-
|
|
487
414
|
## Optional ticket tree capability
|
|
488
415
|
|
|
489
|
-
Existing ticket
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
and updates: omitted preserves
|
|
495
|
-
|
|
496
|
-
existence, node kind, self
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
Legacy sources receive ordinary CRUD unchanged; metadata writes are refused by
|
|
501
|
-
the compatibility facade before legacy methods run. Unsupported sources should
|
|
502
|
-
also refuse metadata explicitly at their own direct write boundary.
|
|
416
|
+
Existing ticket sources stay compatible unchanged. Raw `Ticket.kind` is optional; public projections normalize it to `work`.
|
|
417
|
+
|
|
418
|
+
An adapter opts in with `integrationTree: true` and must:
|
|
419
|
+
|
|
420
|
+
- implement `listAll(): Promise<TicketListing>` over every state, ignoring ready filters, exhausting pagination and propagating infrastructure failures
|
|
421
|
+
- persist `kind?: 'work' | 'node'` and `target?: string | null` on drafts and updates: omitted preserves or defaults, explicit `work` resets kind, `null` clears target
|
|
422
|
+
- read targets as source-local canonical ticket ids
|
|
423
|
+
- before writing any mixed patch, including revision-checked writes, validate same-source existence, node kind, self and ancestor cycles, corrupt chains, and demotion of a node with children
|
|
424
|
+
- expose kind and target in revisions
|
|
425
|
+
|
|
426
|
+
Don't opt in unless the source preserves these semantics. Legacy sources get ordinary CRUD; the compatibility facade refuses metadata writes before legacy methods run, and unsupported sources should also refuse metadata at their own write boundary.
|