@defrex/autobuild 1.10.0 → 1.11.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/README.md +1 -1
- package/SPEC.md +745 -69
- package/bin/ab-dispatch-generation.ts +3 -1
- package/docs/accounts.md +2 -1
- package/docs/answering-blocked-builds.md +20 -0
- package/docs/architecture.md +165 -29
- package/docs/build-store.md +10 -7
- package/docs/cli.md +33 -1
- package/docs/configuration-overview.md +4 -1
- package/docs/configuration.md +381 -29
- package/docs/dispatcher.md +64 -4
- package/docs/forges.md +7 -0
- package/docs/integration-tree.md +2 -2
- package/docs/operating.md +4 -2
- package/docs/operator-api.md +134 -6
- package/docs/operator-surfaces.md +85 -0
- package/docs/optimization-nodes.md +69 -11
- package/docs/plugin-authoring.md +37 -1
- package/docs/remote-store-protocol.md +94 -13
- package/docs/remote-ticket-protocol.md +40 -0
- package/docs/restacking.md +20 -4
- package/docs/setup.md +14 -2
- package/docs/ticket-dependencies.md +10 -3
- package/docs/ticket-sources.md +24 -2
- package/docs/tickets.md +7 -1
- package/docs/troubleshooting.md +8 -0
- package/docs/verification.md +4 -3
- package/docs/workspaces.md +3 -0
- package/package.json +9 -5
- package/packages/core/src/cli/accounts.ts +7 -2
- package/packages/core/src/cli/attention.ts +3 -1
- package/packages/core/src/cli/binary-direct.ts +2 -0
- package/packages/core/src/cli/binary-lifecycle.ts +2 -1
- package/packages/core/src/cli/build-control.ts +79 -1
- package/packages/core/src/cli/context.ts +4 -0
- package/packages/core/src/cli/dashboard/facts.ts +49 -53
- package/packages/core/src/cli/dashboard/header.ts +111 -0
- package/packages/core/src/cli/dashboard/model.ts +31 -39
- package/packages/core/src/cli/dashboard/objective-row.ts +46 -14
- package/packages/core/src/cli/dashboard/poll.ts +179 -76
- package/packages/core/src/cli/dashboard/render.ts +159 -230
- package/packages/core/src/cli/dashboard/row-text.ts +538 -0
- package/packages/core/src/cli/dashboard/timeline.ts +288 -0
- package/packages/core/src/cli/dashboard/vocabulary.ts +188 -0
- package/packages/core/src/cli/dispatch-args.ts +44 -1
- package/packages/core/src/cli/dispatch-frontend.ts +40 -40
- package/packages/core/src/cli/dispatch-launch-stop.ts +18 -0
- package/packages/core/src/cli/dispatch-launcher.ts +20 -7
- package/packages/core/src/cli/dispatch-web.ts +155 -0
- package/packages/core/src/cli/dispatch.ts +202 -38
- package/packages/core/src/cli/help.ts +87 -3
- package/packages/core/src/cli/init-validation.ts +3 -3
- package/packages/core/src/cli/main.ts +70 -6
- package/packages/core/src/cli/mcp.ts +35 -3
- package/packages/core/src/cli/objective.ts +1 -1
- package/packages/core/src/cli/operator-preference.ts +57 -0
- package/packages/core/src/cli/repo-lease.ts +2 -0
- package/packages/core/src/cli/repo-state.ts +56 -6
- package/packages/core/src/cli/repository-status.ts +105 -49
- package/packages/core/src/cli/status.ts +82 -1
- package/packages/core/src/cli/terminal-restore.ts +32 -7
- package/packages/core/src/cli/ticket.ts +98 -36
- package/packages/core/src/cli/wait.ts +14 -6
- package/packages/core/src/cli/watch.ts +20 -4
- package/packages/core/src/cli/web.ts +139 -0
- package/packages/core/src/config/live.ts +99 -14
- package/packages/core/src/config/load.ts +61 -20
- package/packages/core/src/config/local.ts +212 -0
- package/packages/core/src/config/pipeline-source.ts +2 -0
- package/packages/core/src/config/reference.ts +18 -0
- package/packages/core/src/config/schema.ts +45 -10
- package/packages/core/src/events/catalog.ts +4 -0
- package/packages/core/src/events/payloads.ts +97 -0
- package/packages/core/src/events/policy.ts +10 -0
- package/packages/core/src/events/repository.ts +46 -3
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +381 -30
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/017d8dd5bb6dd80b.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/178e12f1759b7552.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/4932c70a2af97faf.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/536085773daf6b58.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/6bd6275061aaffa5.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/89625654b02e9ac1.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/a98af134be2da8a9.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/d5d5ccca80a893d8.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-corpora/f8155387eb5f375c.json.gz +0 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/3c27f918b194e3b3.json +465 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/46196d8f0076496a.json +97 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/79f0e0f4ccd43ba2.json +455 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/859c09edac738823.json +1086 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a283c1f3462b1cc1.json +81 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a6e570fb126991ff.json +36 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/a8acf22c968b6e3d.json +81 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/ba7b85895bf6698e.json +1153 -0
- package/packages/core/src/kernel/__snapshots__/reducer-identity-records/fc66408cde0b6b04.json +637 -0
- package/packages/core/src/kernel/build-roster.ts +230 -0
- package/packages/core/src/kernel/dispatch-capacity.ts +4 -2
- package/packages/core/src/kernel/dispatch-status.ts +139 -0
- package/packages/core/src/kernel/engine.ts +43 -5
- package/packages/core/src/kernel/execution-intervals.ts +61 -0
- package/packages/core/src/kernel/generators/optimization-log.ts +101 -0
- package/packages/core/src/kernel/generators/repository-journals.ts +13 -0
- package/packages/core/src/kernel/leaf-restack-base.ts +33 -7
- package/packages/core/src/kernel/leaf-restack-state.ts +82 -3
- package/packages/core/src/kernel/log-index.ts +19 -0
- package/packages/core/src/kernel/optimization-admission.ts +244 -3
- package/packages/core/src/kernel/optimization.ts +183 -4
- package/packages/core/src/kernel/phase-failures.ts +121 -0
- package/packages/core/src/kernel/published-branch-head.ts +60 -0
- package/packages/core/src/kernel/read-facts.ts +15 -13
- package/packages/core/src/kernel/reducer-registry.ts +27 -8
- package/packages/core/src/kernel/reducer-revisions.ts +27 -0
- package/packages/core/src/kernel/reducer.ts +63 -4
- package/packages/core/src/kernel/rollup.ts +61 -0
- package/packages/core/src/kernel/setup-streak.ts +38 -0
- package/packages/core/src/kernel/step-durations.ts +257 -0
- package/packages/core/src/kernel/target-observation.ts +6 -1
- package/packages/core/src/kernel/target-rewrite-recovery.ts +116 -0
- package/packages/core/src/kernel/verify-diff-base.ts +5 -0
- package/packages/core/src/kernel/verify-stages.ts +13 -3
- package/packages/core/src/ontology.ts +5 -0
- package/packages/core/src/operator/agent-context-serve.ts +631 -0
- package/packages/core/src/operator/annotations.ts +75 -5
- package/packages/core/src/operator/attention.ts +470 -0
- package/packages/core/src/operator/canonical-skills.ts +35 -0
- package/packages/core/src/operator/cli-equivalents.ts +270 -0
- package/packages/core/src/operator/context-prompts.ts +61 -0
- package/packages/core/src/operator/index.ts +49 -1
- package/packages/core/src/operator/landings.ts +28 -19
- package/packages/core/src/operator/optimization.ts +7 -0
- package/packages/core/src/operator/protocol.ts +3 -0
- package/packages/core/src/operator/query.ts +129 -74
- package/packages/core/src/operator/read-view.ts +5 -2
- package/packages/core/src/operator/registry.ts +406 -46
- package/packages/core/src/operator/requests.ts +20 -18
- package/packages/core/src/operator/sandbox-host.ts +107 -11
- package/packages/core/src/operator/sandbox-resolver.ts +253 -0
- package/packages/core/src/operator/sandbox.ts +778 -82
- package/packages/core/src/operator/ticket-asset-list.ts +77 -0
- package/packages/core/src/operator/ticket-assets.ts +167 -0
- package/packages/core/src/operator/tickets.ts +33 -2
- package/packages/core/src/plugin-sdk/index.ts +22 -0
- package/packages/core/src/plugins/manifest.ts +1 -1
- package/packages/core/src/ports/forge/fake.ts +92 -1
- package/packages/core/src/ports/forge/git-blob.ts +15 -0
- package/packages/core/src/ports/forge/github.ts +82 -0
- package/packages/core/src/ports/forge/local-git.ts +61 -1
- package/packages/core/src/ports/forge-failure.ts +24 -0
- package/packages/core/src/ports/runner/antigravity-test.fixture.ts +149 -0
- package/packages/core/src/ports/runner/claude-test.fixture.ts +71 -0
- package/packages/core/src/ports/runner/codex-test.fixture.ts +63 -0
- package/packages/core/src/ports/tickets/contract.ts +71 -0
- package/packages/core/src/ports/tickets/fake.ts +11 -0
- package/packages/core/src/ports/tickets/file.ts +18 -0
- package/packages/core/src/ports/tickets/github-fake.ts +136 -4
- package/packages/core/src/ports/tickets/github.ts +387 -30
- package/packages/core/src/ports/tickets/hosted-index.ts +10 -0
- package/packages/core/src/ports/tickets/linear.ts +130 -0
- package/packages/core/src/ports/tickets/priority.ts +9 -0
- package/packages/core/src/ports/tickets/remote-protocol.ts +34 -0
- package/packages/core/src/ports/tickets/remote.ts +70 -6
- package/packages/core/src/ports/tickets/search.ts +139 -0
- package/packages/core/src/ports/types.ts +104 -2
- package/packages/core/src/ports/workspace/builtin-capabilities.ts +9 -0
- package/packages/core/src/ports/workspace/create.ts +15 -1
- package/packages/core/src/ports/workspace/fake.ts +340 -12
- package/packages/core/src/ports/workspace/git-worktree.ts +833 -42
- package/packages/core/src/ports/workspace/operator-sandbox.ts +129 -12
- package/packages/core/src/ports/workspace/process-group.ts +48 -0
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +1260 -123
- package/packages/core/src/processes/agent-context-assemble.ts +576 -0
- package/packages/core/src/processes/agent-context.ts +469 -0
- package/packages/core/src/processes/build-runner.ts +387 -236
- package/packages/core/src/processes/dispatcher.ts +211 -55
- package/packages/core/src/processes/execution-no-progress.ts +4 -0
- package/packages/core/src/processes/optimization-activity.ts +120 -0
- package/packages/core/src/processes/phase-failure-budget.ts +1 -0
- package/packages/core/src/processes/repo-view.ts +78 -2
- package/packages/core/src/processes/sandbox-state.ts +53 -6
- package/packages/core/src/processes/tick-publication.ts +2 -0
- package/packages/core/src/processes/workspace-preparation.ts +76 -0
- package/packages/core/src/scenarios/harness.ts +0 -5
- package/packages/core/src/store/account-redaction.ts +1 -0
- package/packages/core/src/store/adapter.ts +52 -1
- package/packages/core/src/store/agent-context.ts +432 -0
- package/packages/core/src/store/build-feed.ts +291 -0
- package/packages/core/src/store/build-scope.ts +19 -1
- package/packages/core/src/store/contract.ts +911 -14
- package/packages/core/src/store/digest.ts +19 -6
- package/packages/core/src/store/histogram.ts +113 -0
- package/packages/core/src/store/local/schema.ts +62 -0
- package/packages/core/src/store/local/store.ts +628 -22
- package/packages/core/src/store/local/ticket-asset-heads.ts +23 -0
- package/packages/core/src/store/memory.ts +461 -69
- package/packages/core/src/store/open-builds.ts +19 -0
- package/packages/core/src/store/phase-session.ts +32 -4
- package/packages/core/src/store/reduced-reads.ts +14 -4
- package/packages/core/src/store/reducer-value-shapes.json +7027 -5751
- package/packages/core/src/store/reducer-values.ts +6 -1
- package/packages/core/src/store/remote/client.ts +208 -2
- package/packages/core/src/store/remote/compatibility.ts +1 -1
- package/packages/core/src/store/remote/index.ts +33 -0
- package/packages/core/src/store/remote/protocol.ts +69 -0
- package/packages/core/src/store/remote/released-clients.json +22 -0
- package/packages/core/src/store/remote/released-reducer-values/1.11.0.json +35680 -0
- package/packages/core/src/store/remote/released-reducer-values/1.11.1.json +35718 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +20 -16
- package/packages/core/src/store/retention.ts +23 -1
- package/packages/core/src/store/rollups.ts +337 -0
- package/packages/core/src/store/session-handle.ts +20 -2
- package/packages/core/src/store/snapshots.ts +10 -0
- package/packages/core/src/store/types.ts +108 -9
- package/packages/core/src/testing/dispatch-journals.ts +117 -0
- package/packages/core/src/testing/dispatch-read-budget.ts +1092 -2
- package/packages/core/src/testing/git-config-isolation.ts +7 -5
- package/packages/core/src/testing/index.ts +27 -0
- package/packages/core/src/testing/memory-operator-sandbox.ts +346 -0
- package/packages/core/src/testing/reduced-read-budget.ts +1873 -98
- package/packages/core/src/web/analytics-source.ts +303 -0
- package/packages/core/src/web/assets/Atkinson-OFL.txt +93 -0
- package/packages/core/src/web/assets/AtkinsonHyperlegibleNext.latin.woff2 +0 -0
- package/packages/core/src/web/assets/JetBrains-OFL.txt +93 -0
- package/packages/core/src/web/assets/JetBrainsMono.latin.woff2 +0 -0
- package/packages/core/src/web/assets/app.css +1 -0
- package/packages/core/src/web/assets/app.js +9 -0
- package/packages/core/src/web/assets/manifest.json +31 -0
- package/packages/core/src/web/assets/theme.js +1 -0
- package/packages/core/src/web/bounded.ts +31 -0
- package/packages/core/src/web/http.ts +315 -0
- package/packages/core/src/web/hub.ts +160 -0
- package/packages/core/src/web/options.ts +38 -0
- package/packages/core/src/web/overview-source.ts +322 -0
- package/packages/core/src/web/page.ts +56 -0
- package/packages/core/src/web/protocol.ts +151 -0
- package/packages/core/src/web/read-only.ts +23 -0
- package/packages/core/src/web/repository-source.ts +39 -0
- package/packages/core/src/web/server.ts +97 -0
- package/skills/code-review/SKILL.md +10 -2
- package/skills/guide/SKILL.md +376 -54
- package/skills/guide/references/accounts.md +2 -1
- package/skills/guide/references/integration-tree.md +2 -2
- package/skills/guide/references/operator-api.md +134 -6
- package/skills/guide/references/optimization-nodes.md +69 -11
- package/skills/guide/references/plugin-authoring.md +37 -1
- package/skills/guide/references/remote-store-protocol.md +94 -13
- package/skills/guide/references/remote-ticket-protocol.md +40 -0
- package/skills/guide/references/restacking.md +20 -4
- package/skills/guide/references/setup.md +14 -2
- package/skills/guide/references/ticket-dependencies.md +10 -3
- package/skills/implement/SKILL.md +23 -4
- package/skills/operate/SKILL.md +134 -32
- package/skills/plan/SKILL.md +10 -4
- package/skills/plan-review/SKILL.md +9 -2
- package/skills/spec/SKILL.md +34 -8
- package/skills/tickets/SKILL.md +51 -5
- package/templates/hosted-service/package.json +2 -2
|
@@ -8,10 +8,23 @@ import { mkdtemp, rm, writeFile } from 'node:fs/promises'
|
|
|
8
8
|
import { tmpdir } from 'node:os'
|
|
9
9
|
import { join } from 'node:path'
|
|
10
10
|
import { z } from 'zod'
|
|
11
|
-
import type {
|
|
11
|
+
import type {
|
|
12
|
+
AutoMergeResult,
|
|
13
|
+
ClosePrResult,
|
|
14
|
+
Forge,
|
|
15
|
+
ForgeTreeEntry,
|
|
16
|
+
PrRef,
|
|
17
|
+
PrState,
|
|
18
|
+
} from '../types'
|
|
19
|
+
import { matchesGitBlobOid } from './git-blob'
|
|
12
20
|
import { bunExec, type Exec } from './github'
|
|
13
21
|
|
|
14
22
|
const objectId = z.string().regex(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/)
|
|
23
|
+
const treeEntry = z.object({
|
|
24
|
+
mode: z.enum(['100644', '100755', '040000', '120000', '160000']),
|
|
25
|
+
type: z.enum(['blob', 'tree', 'commit']),
|
|
26
|
+
oid: objectId,
|
|
27
|
+
})
|
|
15
28
|
const pendingLanding = z.strictObject({
|
|
16
29
|
baseSha: objectId,
|
|
17
30
|
headSha: objectId,
|
|
@@ -148,6 +161,53 @@ export class LocalGitForge implements Forge {
|
|
|
148
161
|
return result.stdout
|
|
149
162
|
}
|
|
150
163
|
|
|
164
|
+
/** Complete recursive tree of `commit`; git has no listing limit. */
|
|
165
|
+
async readTree(commit: string): Promise<ForgeTreeEntry[]> {
|
|
166
|
+
if (this.repoRoot === undefined) {
|
|
167
|
+
throw new Error('local-git forge has no repository root for tree reads')
|
|
168
|
+
}
|
|
169
|
+
const result = await this.command(
|
|
170
|
+
['ls-tree', '-r', '-t', '-l', '-z', '--full-tree', '--end-of-options', commit],
|
|
171
|
+
this.repoRoot,
|
|
172
|
+
)
|
|
173
|
+
const entries: ForgeTreeEntry[] = []
|
|
174
|
+
for (const record of result.stdout.split('\0')) {
|
|
175
|
+
if (record === '') continue
|
|
176
|
+
const tab = record.indexOf('\t')
|
|
177
|
+
const [mode, type, oid, size] = record.slice(0, tab).trim().split(/\s+/)
|
|
178
|
+
const parsed = treeEntry.safeParse({ mode, type, oid })
|
|
179
|
+
if (tab < 0 || !parsed.success)
|
|
180
|
+
throw new Error(`local-git: unexpected ls-tree line ${record}`)
|
|
181
|
+
entries.push({
|
|
182
|
+
path: record.slice(tab + 1),
|
|
183
|
+
...parsed.data,
|
|
184
|
+
...(size !== undefined && size !== '-' ? { size: Number(size) } : {}),
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
return entries
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** Exact bytes of blob `oid`, verified against the id. */
|
|
191
|
+
async readBlob(oid: string): Promise<Uint8Array> {
|
|
192
|
+
if (this.repoRoot === undefined) {
|
|
193
|
+
throw new Error('local-git forge has no repository root for blob reads')
|
|
194
|
+
}
|
|
195
|
+
if (!objectId.safeParse(oid).success) throw new Error(`local-git: invalid blob id ${oid}`)
|
|
196
|
+
const text = await this.command(['cat-file', 'blob', oid], this.repoRoot)
|
|
197
|
+
const direct = new Uint8Array(Buffer.from(text.stdout))
|
|
198
|
+
if (matchesGitBlobOid(oid, direct)) return direct
|
|
199
|
+
// Exec decodes stdout as text (BOM stripped, invalid UTF-8 replaced), so
|
|
200
|
+
// read anything else as hex.
|
|
201
|
+
const hex = await this.exec(
|
|
202
|
+
['sh', '-c', 'git cat-file blob "$1" | od -An -v -tx1', 'read-blob', oid],
|
|
203
|
+
{ cwd: this.repoRoot },
|
|
204
|
+
)
|
|
205
|
+
if (hex.exitCode !== 0) throw new Error(`local-git: cannot read blob ${oid}: ${hex.stderr}`)
|
|
206
|
+
const bytes = new Uint8Array(Buffer.from(hex.stdout.replace(/\s+/g, ''), 'hex'))
|
|
207
|
+
if (!matchesGitBlobOid(oid, bytes)) throw new Error(`local-git: blob ${oid} read back corrupt`)
|
|
208
|
+
return bytes
|
|
209
|
+
}
|
|
210
|
+
|
|
151
211
|
private async command(args: string[], cwd: string, allowFailure = false) {
|
|
152
212
|
const result = await this.exec(['git', ...args], { cwd })
|
|
153
213
|
if (!allowFailure && result.exitCode !== 0) {
|
|
@@ -82,6 +82,30 @@ export function isArchiveConflict(error: unknown): error is ArchiveConflictError
|
|
|
82
82
|
)
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/** A forge cannot list one directory of a commit's tree completely (GitHub:
|
|
86
|
+
* a single directory with more than 100,000 direct entries). `readTree`
|
|
87
|
+
* throws this rather than ever returning a partial listing. */
|
|
88
|
+
export class ForgeTreeUnlistable extends Error {
|
|
89
|
+
readonly treeUnlistable = 'autobuild.tree-unlistable.v1' as const
|
|
90
|
+
readonly directory: string
|
|
91
|
+
constructor(directory: string) {
|
|
92
|
+
super(`forge cannot list directory ${directory === '' ? '/' : directory} completely`)
|
|
93
|
+
this.name = 'ForgeTreeUnlistable'
|
|
94
|
+
this.directory = directory
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Brand check, so an adapter built against another copy of the plugin SDK is
|
|
99
|
+
* still recognized. */
|
|
100
|
+
export function isForgeTreeUnlistable(error: unknown): error is ForgeTreeUnlistable {
|
|
101
|
+
return (
|
|
102
|
+
!!error &&
|
|
103
|
+
typeof error === 'object' &&
|
|
104
|
+
(error as ForgeTreeUnlistable).treeUnlistable === 'autobuild.tree-unlistable.v1' &&
|
|
105
|
+
typeof (error as ForgeTreeUnlistable).directory === 'string'
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
85
109
|
export interface ForgeRejectionDetails {
|
|
86
110
|
/** Human-readable forge name, e.g. `GitHub`. */
|
|
87
111
|
forge: string
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { AgentStartOpts } from '../types'
|
|
2
|
+
import type {
|
|
3
|
+
AntigravityCliInvocation,
|
|
4
|
+
AntigravityCliResult,
|
|
5
|
+
AntigravityCliRunFn,
|
|
6
|
+
AntigravityCliStreamFn,
|
|
7
|
+
} from './antigravity'
|
|
8
|
+
|
|
9
|
+
export type Event = Record<string, unknown>
|
|
10
|
+
|
|
11
|
+
export function init(id = 'conv-1'): Event {
|
|
12
|
+
return { event: 'init', conversation_id: id, init: { cwd: '/ws', tools: [] } }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function step(id: string, index: number, fields: Record<string, unknown>): Event {
|
|
16
|
+
return {
|
|
17
|
+
event: 'step_update',
|
|
18
|
+
step_update: { conversation_id: id, step_index: index, state: 'DONE', ...fields },
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function delta(
|
|
23
|
+
id: string,
|
|
24
|
+
index: number,
|
|
25
|
+
text: string,
|
|
26
|
+
state: 'ACTIVE' | 'DONE' = 'DONE',
|
|
27
|
+
usage?: { input_tokens: number; output_tokens: number },
|
|
28
|
+
): Event {
|
|
29
|
+
return step(id, index, {
|
|
30
|
+
state,
|
|
31
|
+
step_type: 'agent_response',
|
|
32
|
+
text_delta: text,
|
|
33
|
+
...(usage !== undefined ? { usage } : {}),
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function userInput(id: string, index: number): Event {
|
|
38
|
+
return step(id, index, { step_type: 'user_input' })
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function tool(
|
|
42
|
+
id: string,
|
|
43
|
+
index: number,
|
|
44
|
+
name: string,
|
|
45
|
+
parameters: unknown,
|
|
46
|
+
output: unknown,
|
|
47
|
+
state: 'ACTIVE' | 'DONE' = 'DONE',
|
|
48
|
+
): Event {
|
|
49
|
+
return step(id, index, {
|
|
50
|
+
state,
|
|
51
|
+
step_type: 'tool',
|
|
52
|
+
tool_name: name,
|
|
53
|
+
tool_info: { name, parameters, ...(state === 'DONE' ? { output } : {}) },
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function result(
|
|
58
|
+
id: string,
|
|
59
|
+
opts: {
|
|
60
|
+
status?: string
|
|
61
|
+
response?: string
|
|
62
|
+
error?: string
|
|
63
|
+
usage?: { input_tokens: number; output_tokens: number }
|
|
64
|
+
numTurns?: number
|
|
65
|
+
} = {},
|
|
66
|
+
): Event {
|
|
67
|
+
return {
|
|
68
|
+
event: 'result',
|
|
69
|
+
result: {
|
|
70
|
+
conversation_id: id,
|
|
71
|
+
status: opts.status ?? 'SUCCESS',
|
|
72
|
+
...(opts.response !== undefined ? { response: opts.response } : {}),
|
|
73
|
+
...(opts.error !== undefined ? { error: opts.error } : {}),
|
|
74
|
+
num_turns: opts.numTurns ?? 1,
|
|
75
|
+
usage: opts.usage ?? { input_tokens: 3, output_tokens: 2 },
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function output(
|
|
81
|
+
events: Event[],
|
|
82
|
+
opts: { stderr?: string; exitCode?: number; extra?: string } = {},
|
|
83
|
+
): AntigravityCliResult {
|
|
84
|
+
return {
|
|
85
|
+
stdout:
|
|
86
|
+
events.map((event) => JSON.stringify(event)).join('\n') +
|
|
87
|
+
(events.length > 0 ? '\n' : '') +
|
|
88
|
+
(opts.extra ?? ''),
|
|
89
|
+
stderr: opts.stderr ?? '',
|
|
90
|
+
exitCode: opts.exitCode ?? 0,
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export type Script =
|
|
95
|
+
| AntigravityCliResult
|
|
96
|
+
| Error
|
|
97
|
+
| ((call: AntigravityCliInvocation) => AntigravityCliResult | Promise<AntigravityCliResult>)
|
|
98
|
+
|
|
99
|
+
export function fakeCli(scripts: Script[]): {
|
|
100
|
+
calls: AntigravityCliInvocation[]
|
|
101
|
+
runCli: AntigravityCliRunFn
|
|
102
|
+
} {
|
|
103
|
+
const calls: AntigravityCliInvocation[] = []
|
|
104
|
+
return {
|
|
105
|
+
calls,
|
|
106
|
+
runCli: async (call) => {
|
|
107
|
+
calls.push(call)
|
|
108
|
+
const script = scripts[calls.length - 1]
|
|
109
|
+
if (script === undefined) throw new Error('missing fake agy script')
|
|
110
|
+
if (script instanceof Error) throw script
|
|
111
|
+
return typeof script === 'function' ? script(call) : script
|
|
112
|
+
},
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** Line-at-a-time streaming boundary over the same scripts. */
|
|
117
|
+
export function fakeStream(scripts: Script[]): {
|
|
118
|
+
calls: AntigravityCliInvocation[]
|
|
119
|
+
runCliStream: AntigravityCliStreamFn
|
|
120
|
+
} {
|
|
121
|
+
const buffered = fakeCli(scripts)
|
|
122
|
+
return {
|
|
123
|
+
calls: buffered.calls,
|
|
124
|
+
runCliStream: (call) => {
|
|
125
|
+
const completed = buffered.runCli(call)
|
|
126
|
+
return {
|
|
127
|
+
lines: (async function* () {
|
|
128
|
+
const cli = await completed
|
|
129
|
+
for (const line of cli.stdout.split('\n')) if (line !== '') yield line
|
|
130
|
+
})(),
|
|
131
|
+
result: completed,
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function promptOf(call: AntigravityCliInvocation): string {
|
|
138
|
+
return call.args[call.args.lastIndexOf('-p') + 1] ?? ''
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export function startOpts(overrides: Partial<AgentStartOpts> = {}): AgentStartOpts {
|
|
142
|
+
return {
|
|
143
|
+
skill: 'ab-plan',
|
|
144
|
+
invocation: 'agy-runtime',
|
|
145
|
+
workspacePath: '/ws/agy-runtime',
|
|
146
|
+
env: { AB_BUILD: 'agy-runtime', AB_SESSION: 's_1' },
|
|
147
|
+
...overrides,
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { AgentStartOpts } from '../types'
|
|
2
|
+
import type { ClaudeCliInvocation, ClaudeCliResult, ClaudeCliRunFn } from './claude'
|
|
3
|
+
|
|
4
|
+
export function event(value: Record<string, unknown>): string {
|
|
5
|
+
return JSON.stringify(value)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function assistant(...texts: string[]): Record<string, unknown> {
|
|
9
|
+
return {
|
|
10
|
+
type: 'assistant',
|
|
11
|
+
message: { content: texts.map((text) => ({ type: 'text', text })) },
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function result(
|
|
16
|
+
sessionId: string,
|
|
17
|
+
inputTokens: number,
|
|
18
|
+
outputTokens: number,
|
|
19
|
+
extra: Record<string, unknown> = {},
|
|
20
|
+
): Record<string, unknown> {
|
|
21
|
+
return {
|
|
22
|
+
type: 'result',
|
|
23
|
+
subtype: 'success',
|
|
24
|
+
is_error: false,
|
|
25
|
+
session_id: sessionId,
|
|
26
|
+
usage: { input_tokens: inputTokens, output_tokens: outputTokens },
|
|
27
|
+
...extra,
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function output(
|
|
32
|
+
events: Record<string, unknown>[],
|
|
33
|
+
opts: { stderr?: string; exitCode?: number } = {},
|
|
34
|
+
): ClaudeCliResult {
|
|
35
|
+
return {
|
|
36
|
+
stdout: events.map(event).join('\n') + (events.length > 0 ? '\n' : ''),
|
|
37
|
+
stderr: opts.stderr ?? '',
|
|
38
|
+
exitCode: opts.exitCode ?? 0,
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function fakeCli(
|
|
43
|
+
scripts: Array<ClaudeCliResult | Error | ((call: ClaudeCliInvocation) => ClaudeCliResult)>,
|
|
44
|
+
): { calls: ClaudeCliInvocation[]; runCli: ClaudeCliRunFn } {
|
|
45
|
+
const calls: ClaudeCliInvocation[] = []
|
|
46
|
+
return {
|
|
47
|
+
calls,
|
|
48
|
+
runCli: async (call) => {
|
|
49
|
+
calls.push(call)
|
|
50
|
+
const script = scripts[calls.length - 1]
|
|
51
|
+
if (script === undefined) throw new Error('missing fake CLI script')
|
|
52
|
+
if (script instanceof Error) throw script
|
|
53
|
+
return typeof script === 'function' ? script(call) : script
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function promptOf(call: ClaudeCliInvocation): string {
|
|
59
|
+
const index = call.args.indexOf('--')
|
|
60
|
+
return call.args[index + 1] ?? ''
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function startOpts(overrides: Partial<AgentStartOpts> = {}): AgentStartOpts {
|
|
64
|
+
return {
|
|
65
|
+
skill: 'ab-plan',
|
|
66
|
+
buildSlug: 'auth-rate-limit',
|
|
67
|
+
workspacePath: '/ws/auth-rate-limit',
|
|
68
|
+
env: { AB_BUILD: 'auth-rate-limit', AB_SESSION: 's_9f2' },
|
|
69
|
+
...overrides,
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { AgentStartOpts } from '../types'
|
|
2
|
+
import type { CodexCliInvocation, CodexCliResult, CodexCliRunFn } from './codex'
|
|
3
|
+
|
|
4
|
+
export function event(value: Record<string, unknown>): string {
|
|
5
|
+
return JSON.stringify(value)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function thread(id = 'thread-1'): Record<string, unknown> {
|
|
9
|
+
return { type: 'thread.started', thread_id: id }
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function message(text: string): Record<string, unknown> {
|
|
13
|
+
return { type: 'item.completed', item: { id: 'item-1', type: 'agent_message', text } }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function completed(inputTokens = 3, outputTokens = 2): Record<string, unknown> {
|
|
17
|
+
return {
|
|
18
|
+
type: 'turn.completed',
|
|
19
|
+
usage: { input_tokens: inputTokens, output_tokens: outputTokens },
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function output(
|
|
24
|
+
events: Record<string, unknown>[],
|
|
25
|
+
opts: { stderr?: string; exitCode?: number } = {},
|
|
26
|
+
): CodexCliResult {
|
|
27
|
+
return {
|
|
28
|
+
stdout: events.map(event).join('\n') + (events.length > 0 ? '\n' : ''),
|
|
29
|
+
stderr: opts.stderr ?? '',
|
|
30
|
+
exitCode: opts.exitCode ?? 0,
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function fakeCli(
|
|
35
|
+
scripts: Array<CodexCliResult | Error | ((call: CodexCliInvocation) => CodexCliResult)>,
|
|
36
|
+
): { calls: CodexCliInvocation[]; runCli: CodexCliRunFn } {
|
|
37
|
+
const calls: CodexCliInvocation[] = []
|
|
38
|
+
return {
|
|
39
|
+
calls,
|
|
40
|
+
runCli: async (call) => {
|
|
41
|
+
calls.push(call)
|
|
42
|
+
const script = scripts[calls.length - 1]
|
|
43
|
+
if (script === undefined) throw new Error('missing fake Codex CLI script')
|
|
44
|
+
if (script instanceof Error) throw script
|
|
45
|
+
return typeof script === 'function' ? script(call) : script
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function promptOf(call: CodexCliInvocation): string {
|
|
51
|
+
const delimiter = call.args.lastIndexOf('--')
|
|
52
|
+
return call.args[delimiter + 1] ?? ''
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function startOpts(overrides: Partial<AgentStartOpts> = {}): AgentStartOpts {
|
|
56
|
+
return {
|
|
57
|
+
skill: 'ab-plan',
|
|
58
|
+
invocation: 'codex-runtime',
|
|
59
|
+
workspacePath: '/ws/codex-runtime',
|
|
60
|
+
env: { AB_BUILD: 'codex-runtime', AB_SESSION: 's_1' },
|
|
61
|
+
...overrides,
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -242,6 +242,77 @@ export function describeTicketSourceContract(
|
|
|
242
242
|
})
|
|
243
243
|
})
|
|
244
244
|
|
|
245
|
+
test('search, when declared, matches title and body, honours filters, and pages by cursor', async () => {
|
|
246
|
+
await withTicketSource(factory, async (harness) => {
|
|
247
|
+
const source = harness.source
|
|
248
|
+
if (!source.search) return
|
|
249
|
+
const token = crypto.randomUUID().replaceAll('-', '')
|
|
250
|
+
const inTitle = await createTracked(
|
|
251
|
+
harness,
|
|
252
|
+
{
|
|
253
|
+
title: `${contractTicketTitle('search')} ${token}`,
|
|
254
|
+
body: CONTRACT_TICKET_BODY,
|
|
255
|
+
labels: [harness.editableLabel],
|
|
256
|
+
},
|
|
257
|
+
{ state: harness.states.ready },
|
|
258
|
+
)
|
|
259
|
+
const mixed = token.slice(0, 8).toUpperCase() + token.slice(8)
|
|
260
|
+
const inBody = await createTracked(
|
|
261
|
+
harness,
|
|
262
|
+
{
|
|
263
|
+
title: contractTicketTitle('search'),
|
|
264
|
+
body: `${CONTRACT_TICKET_BODY}\nSearch marker ${mixed}.\n`,
|
|
265
|
+
},
|
|
266
|
+
{ state: harness.states.completed },
|
|
267
|
+
)
|
|
268
|
+
await createTracked(harness, {
|
|
269
|
+
title: contractTicketTitle('search miss'),
|
|
270
|
+
body: CONTRACT_TICKET_BODY,
|
|
271
|
+
})
|
|
272
|
+
const search = (query: Partial<Parameters<NonNullable<TicketSource['search']>>[0]>) =>
|
|
273
|
+
source.search!({ text: token.toUpperCase(), limit: 100, ...query })
|
|
274
|
+
const ids = (page: { tickets: Array<{ id: string }> }) =>
|
|
275
|
+
page.tickets.map((hit) => hit.id).sort()
|
|
276
|
+
|
|
277
|
+
const all = await search({})
|
|
278
|
+
expect(ids(all)).toEqual([inTitle.ref.id, inBody.ref.id].sort())
|
|
279
|
+
expect(all.cursor).toBeUndefined()
|
|
280
|
+
for (const hit of all.tickets) {
|
|
281
|
+
const ticket = (await source.get(hit.id))!
|
|
282
|
+
expect({
|
|
283
|
+
id: hit.id,
|
|
284
|
+
title: hit.title,
|
|
285
|
+
state: hit.state,
|
|
286
|
+
labels: [...hit.labels].sort(),
|
|
287
|
+
kind: hit.kind,
|
|
288
|
+
}).toEqual({
|
|
289
|
+
id: ticket.ref.id,
|
|
290
|
+
title: ticket.title,
|
|
291
|
+
state: ticket.state,
|
|
292
|
+
labels: [...ticket.labels].sort(),
|
|
293
|
+
kind: ticket.kind ?? 'work',
|
|
294
|
+
})
|
|
295
|
+
}
|
|
296
|
+
expect(ids(await search({ labels: [harness.editableLabel] }))).toEqual([inTitle.ref.id])
|
|
297
|
+
expect(ids(await search({ state: inTitle.state ?? harness.states.ready }))).toEqual([
|
|
298
|
+
inTitle.ref.id,
|
|
299
|
+
])
|
|
300
|
+
expect(ids(await search({ state: harness.states.completed }))).toEqual([inBody.ref.id])
|
|
301
|
+
expect((await search({ text: `${token} ${crypto.randomUUID()}` })).tickets).toEqual([])
|
|
302
|
+
|
|
303
|
+
const paged: string[] = []
|
|
304
|
+
let cursor: string | undefined
|
|
305
|
+
let pages = 0
|
|
306
|
+
do {
|
|
307
|
+
const page = await search({ limit: 1, ...(cursor !== undefined ? { cursor } : {}) })
|
|
308
|
+
paged.push(...page.tickets.map((hit) => hit.id))
|
|
309
|
+
cursor = page.cursor
|
|
310
|
+
expect(++pages).toBeLessThanOrEqual(3)
|
|
311
|
+
} while (cursor !== undefined)
|
|
312
|
+
expect(paged.sort()).toEqual([inTitle.ref.id, inBody.ref.id].sort())
|
|
313
|
+
})
|
|
314
|
+
})
|
|
315
|
+
|
|
245
316
|
test('native pages order urgent dispatch first and newest filed first when declared', async () => {
|
|
246
317
|
await withTicketSource(factory, async (harness) => {
|
|
247
318
|
const source = harness.source
|
|
@@ -13,12 +13,15 @@ import type {
|
|
|
13
13
|
TicketCreateOptions,
|
|
14
14
|
TicketDraft,
|
|
15
15
|
TicketListing,
|
|
16
|
+
TicketSearchPage,
|
|
17
|
+
TicketSearchQuery,
|
|
16
18
|
TicketSource,
|
|
17
19
|
TicketUpdate,
|
|
18
20
|
TicketMutation,
|
|
19
21
|
} from '../types'
|
|
20
22
|
import { validateTicketUpdate } from './update'
|
|
21
23
|
import { normalizeIssueLinks } from './issue-links'
|
|
24
|
+
import { pageSearch } from './search'
|
|
22
25
|
|
|
23
26
|
function cloneTicket(ticket: Ticket, doneState: string): Ticket {
|
|
24
27
|
return {
|
|
@@ -126,6 +129,14 @@ export class FakeTicketSource implements TicketSource {
|
|
|
126
129
|
}
|
|
127
130
|
}
|
|
128
131
|
|
|
132
|
+
async search(query: TicketSearchQuery): Promise<TicketSearchPage> {
|
|
133
|
+
return pageSearch(
|
|
134
|
+
this.name,
|
|
135
|
+
[...this.tickets.values()].map((ticket) => cloneTicket(ticket, this.doneState)),
|
|
136
|
+
query,
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
|
|
129
140
|
async get(id: string): Promise<Ticket | null> {
|
|
130
141
|
const ticket = this.tickets.get(id)
|
|
131
142
|
return ticket ? cloneTicket(ticket, this.doneState) : null
|
|
@@ -50,6 +50,8 @@ import type {
|
|
|
50
50
|
TicketCreateOptions,
|
|
51
51
|
TicketDraft,
|
|
52
52
|
TicketListing,
|
|
53
|
+
TicketSearchPage,
|
|
54
|
+
TicketSearchQuery,
|
|
53
55
|
TicketSource,
|
|
54
56
|
TicketStateCount,
|
|
55
57
|
TicketStateInfo,
|
|
@@ -58,6 +60,7 @@ import type {
|
|
|
58
60
|
} from '../types'
|
|
59
61
|
import { validateTicketUpdate } from './update'
|
|
60
62
|
import { normalizeIssueLinks } from './issue-links'
|
|
63
|
+
import { pageSearch } from './search'
|
|
61
64
|
|
|
62
65
|
/** Repo-relative fallback when no selected local-state root is supplied. */
|
|
63
66
|
export const DEFAULT_TICKETS_DIR = '.autobuild/tickets'
|
|
@@ -177,6 +180,21 @@ export class FileTicketSource implements TicketSource {
|
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
182
|
|
|
183
|
+
async search(query: TicketSearchQuery): Promise<TicketSearchPage> {
|
|
184
|
+
const state =
|
|
185
|
+
query.state === undefined ? undefined : resolveState(query.state, await this.states())
|
|
186
|
+
// The single tracker scan: listAll walks the state directories once and
|
|
187
|
+
// reads each ticket file once. Hits are projected from that scan, so there
|
|
188
|
+
// is no follow-up read per result.
|
|
189
|
+
const listing = await this.listAll()
|
|
190
|
+
return pageSearch(
|
|
191
|
+
this.name,
|
|
192
|
+
listing.tickets,
|
|
193
|
+
{ ...query, ...(state !== undefined ? { state } : {}) },
|
|
194
|
+
listing.diagnostics,
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
|
|
180
198
|
async get(id: string): Promise<Ticket | null> {
|
|
181
199
|
const found = await this.locate(id)
|
|
182
200
|
if (found === null) return null
|