@defrex/autobuild 1.10.0 → 1.11.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 +738 -68
- 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 +155 -25
- 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 +63 -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 +101 -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 +178 -76
- package/packages/core/src/cli/dashboard/render.ts +129 -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 +29 -38
- 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 +200 -34
- 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 +97 -43
- 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 +316 -0
- 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/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/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/reducer-registry.ts +27 -8
- package/packages/core/src/kernel/reducer-revisions.ts +25 -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 +122 -72
- 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 +6987 -5749
- 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 +11 -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/index.ts +18 -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-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 +35 -0
- package/packages/core/src/web/server.ts +97 -0
- package/skills/code-review/SKILL.md +10 -2
- package/skills/guide/SKILL.md +366 -52
- 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
|
@@ -45,7 +45,6 @@ import { currentDeferralObservationReducer, type DeferralLedger } from '../kerne
|
|
|
45
45
|
*/
|
|
46
46
|
import { mergeDecisionFromFacts, mergeIdentity } from './attention'
|
|
47
47
|
import type { AbEvent } from '../events/catalog'
|
|
48
|
-
import type { EventType } from '../events/payloads'
|
|
49
48
|
import type { BuildState, PrLifecycle } from '../kernel/reducer'
|
|
50
49
|
import { buildReducer, reduceBuild } from '../kernel/reducer'
|
|
51
50
|
import { isPhase, type BuildStatus, type Phase } from '../ontology'
|
|
@@ -116,8 +115,17 @@ export interface EventGlob {
|
|
|
116
115
|
text: string
|
|
117
116
|
}
|
|
118
117
|
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
/** Default attention membership. A `target.rewritten` wakes only for a node,
|
|
119
|
+
* once per episode (its first fact); a leaf's kernel owns the response. */
|
|
120
|
+
function isAttentionEvent(
|
|
121
|
+
event: Pick<AbEvent, 'type'> & { seq?: number },
|
|
122
|
+
state: BuildState | undefined,
|
|
123
|
+
): boolean {
|
|
124
|
+
if (event.type === 'target.rewritten')
|
|
125
|
+
return (
|
|
126
|
+
state?.kind === 'node' && (event.seq === undefined || event.seq === state.targetRewriteSince)
|
|
127
|
+
)
|
|
128
|
+
return (BUILD_ATTENTION_EVENTS as readonly string[]).includes(event.type)
|
|
121
129
|
}
|
|
122
130
|
|
|
123
131
|
/**
|
|
@@ -231,7 +239,7 @@ function stateSatisfies(
|
|
|
231
239
|
return (
|
|
232
240
|
(state.kind === 'node' && integrationFailed(state)) ||
|
|
233
241
|
state.janitor?.attention === true ||
|
|
234
|
-
!!state.targetRewrite ||
|
|
242
|
+
(state.kind === 'node' && !!state.targetRewrite) ||
|
|
235
243
|
awaitsConsent(state, restack) ||
|
|
236
244
|
!!state.nodeRestack?.conflict ||
|
|
237
245
|
!!(restack.active && restack.replay?.conflicted) ||
|
|
@@ -288,7 +296,7 @@ export function matchEvent(
|
|
|
288
296
|
return text
|
|
289
297
|
if (
|
|
290
298
|
cond.kind === 'attention' &&
|
|
291
|
-
(isAttentionEvent(event.
|
|
299
|
+
(isAttentionEvent(event, Array.isArray(events) ? undefined : events.state) ||
|
|
292
300
|
(event.type === 'restack.replayed' &&
|
|
293
301
|
!!(event.payload as { conflicted?: boolean })?.conflicted) ||
|
|
294
302
|
(!Array.isArray(events) && stateSatisfies(cond, events.state, events)) ||
|
|
@@ -335,7 +343,7 @@ function matchFirst(
|
|
|
335
343
|
return text
|
|
336
344
|
if (
|
|
337
345
|
cond.kind === 'attention' &&
|
|
338
|
-
(isAttentionEvent(event.
|
|
346
|
+
(isAttentionEvent(event, Array.isArray(events) ? undefined : events.state) ||
|
|
339
347
|
(event.type === 'restack.replayed' &&
|
|
340
348
|
!!(event.payload as { conflicted?: boolean })?.conflicted) ||
|
|
341
349
|
(!Array.isArray(events) && stateSatisfies(cond, events.state, events)) ||
|
|
@@ -1331,9 +1331,13 @@ export async function abWatch(opts: AbWatchOpts): Promise<void> {
|
|
|
1331
1331
|
const checkConsent = (stream: BuildStream): void => {
|
|
1332
1332
|
if (filters.length || stop) return
|
|
1333
1333
|
const currentState = buildReducer.finish(stream.seed.build)
|
|
1334
|
-
const rewrite = currentState.targetRewrite
|
|
1334
|
+
const rewrite = currentState.kind === 'node' ? currentState.targetRewrite : undefined
|
|
1335
1335
|
if (rewrite) {
|
|
1336
|
-
const identity = JSON.stringify([
|
|
1336
|
+
const identity = JSON.stringify([
|
|
1337
|
+
'target.rewritten',
|
|
1338
|
+
stream.slug,
|
|
1339
|
+
currentState.targetRewriteSince ?? rewrite.seq,
|
|
1340
|
+
])
|
|
1337
1341
|
if (!deliveredAttention.has(identity)) {
|
|
1338
1342
|
deliveredAttention.add(identity)
|
|
1339
1343
|
emit(rewrite, currentState)
|
|
@@ -1458,13 +1462,25 @@ export async function abWatch(opts: AbWatchOpts): Promise<void> {
|
|
|
1458
1462
|
stream.seed = buildStreamSeedReducer.advance(stream.seed, [event])
|
|
1459
1463
|
const state = buildReducer.finish(stream.seed.build)
|
|
1460
1464
|
stream.status = state.status
|
|
1465
|
+
// By default a rewritten target wakes once per episode, and only for a
|
|
1466
|
+
// node: a leaf's kernel reprovisions it or raises an escalation.
|
|
1467
|
+
const repeatedRewrite =
|
|
1468
|
+
!filters.length &&
|
|
1469
|
+
event.type === 'target.rewritten' &&
|
|
1470
|
+
(state.kind !== 'node' || event.seq !== state.targetRewriteSince)
|
|
1461
1471
|
if (
|
|
1462
|
-
matchesBuildFilter(event.type, filters) ||
|
|
1472
|
+
(matchesBuildFilter(event.type, filters) && !repeatedRewrite) ||
|
|
1463
1473
|
(!filters.length && event.type === 'restack.replayed' && event.payload.conflicted)
|
|
1464
1474
|
)
|
|
1465
1475
|
emit(event, state)
|
|
1466
1476
|
if (event.type === 'target.rewritten')
|
|
1467
|
-
deliveredAttention.add(
|
|
1477
|
+
deliveredAttention.add(
|
|
1478
|
+
JSON.stringify([
|
|
1479
|
+
'target.rewritten',
|
|
1480
|
+
stream.slug,
|
|
1481
|
+
state.targetRewriteSince ?? event.seq,
|
|
1482
|
+
]),
|
|
1483
|
+
)
|
|
1468
1484
|
checkConsent(stream)
|
|
1469
1485
|
checkMergeDecision(stream, state)
|
|
1470
1486
|
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { RefreshScheduler } from './dashboard/refresh'
|
|
2
|
+
import type { Exec } from '../ports/workspace/git-worktree'
|
|
3
|
+
import { withSessionlessStore, type StoreOpener } from './store-opening'
|
|
4
|
+
import { WebModelHub } from '../web/hub'
|
|
5
|
+
import { WebAnalyticsSource } from '../web/analytics-source'
|
|
6
|
+
import { loopbackHosts, type WebAnalyticsPort } from '../web/http'
|
|
7
|
+
import { repositoryLabel } from '../web/page'
|
|
8
|
+
import { readOnlyStore } from '../web/read-only'
|
|
9
|
+
import { OverviewFrameSource } from '../web/overview-source'
|
|
10
|
+
import { parseWebPort as parseOptionPort, DEFAULT_WEB_HOST, isLoopbackHost } from '../web/options'
|
|
11
|
+
import { startWebServer, type StartedWebServer, type WebServerStarter } from '../web/server'
|
|
12
|
+
|
|
13
|
+
export const WEB_USAGE = 'usage: ab web [--port <n>] [--host <addr>] [--json] [--store <ref>]'
|
|
14
|
+
|
|
15
|
+
export { DEFAULT_WEB_HOST, isLoopbackHost } from '../web/options'
|
|
16
|
+
|
|
17
|
+
/** Parse `--port` for `ab web`: an integer from 0 to 65535; 0 lets the OS choose. */
|
|
18
|
+
export function parseWebPort(value: string | undefined, usage: string = WEB_USAGE): number {
|
|
19
|
+
return parseOptionPort(value, usage)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ServeRepositoryWebOpts {
|
|
23
|
+
hub: WebModelHub
|
|
24
|
+
repo: string
|
|
25
|
+
host?: string
|
|
26
|
+
port: number
|
|
27
|
+
json: boolean
|
|
28
|
+
/** The command naming the server in its announcement, warnings and errors. */
|
|
29
|
+
command: string
|
|
30
|
+
/** Print the URL line: the JSON `{"url":…}` with `json`, prose otherwise. */
|
|
31
|
+
announce: boolean
|
|
32
|
+
stdout: (line: string) => void
|
|
33
|
+
stderr: (line: string) => void
|
|
34
|
+
/** Test seam; defaults to binding a real socket. */
|
|
35
|
+
start?: WebServerStarter
|
|
36
|
+
/** The analytics routes' reads; undefined answers 503. */
|
|
37
|
+
analytics?: () => WebAnalyticsPort | undefined
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Bind the web server over `hub`, warn when `--host` widened it beyond
|
|
41
|
+
* loopback, and announce its URL. Shared by `ab web` and `ab dispatch --web`. */
|
|
42
|
+
export async function serveRepositoryWeb(opts: ServeRepositoryWebOpts): Promise<StartedWebServer> {
|
|
43
|
+
const hostname = opts.host ?? DEFAULT_WEB_HOST
|
|
44
|
+
const widened = opts.host !== undefined && !isLoopbackHost(opts.host)
|
|
45
|
+
const label = repositoryLabel(opts.repo)
|
|
46
|
+
const server = await (opts.start ?? startWebServer)({
|
|
47
|
+
hub: opts.hub,
|
|
48
|
+
repositoryLabel: label,
|
|
49
|
+
allowedHosts: widened ? 'any' : loopbackHosts(hostname),
|
|
50
|
+
hostname,
|
|
51
|
+
port: opts.port,
|
|
52
|
+
command: opts.command,
|
|
53
|
+
...(opts.analytics !== undefined ? { analytics: opts.analytics } : {}),
|
|
54
|
+
})
|
|
55
|
+
if (widened)
|
|
56
|
+
opts.stderr(
|
|
57
|
+
`${opts.command}: --host ${hostname} serves beyond loopback with no access control; anyone who can reach port ${server.port} can read this repository's builds, tickets and escalations.`,
|
|
58
|
+
)
|
|
59
|
+
if (opts.announce)
|
|
60
|
+
opts.stdout(
|
|
61
|
+
opts.json
|
|
62
|
+
? JSON.stringify({ url: server.url })
|
|
63
|
+
: `${opts.command}: serving ${label} at ${server.url}`,
|
|
64
|
+
)
|
|
65
|
+
return server
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface AbWebOpts {
|
|
69
|
+
targetRepo: string
|
|
70
|
+
env: Record<string, string | undefined>
|
|
71
|
+
exec: Exec
|
|
72
|
+
stdout: (line: string) => void
|
|
73
|
+
stderr: (line: string) => void
|
|
74
|
+
port?: number
|
|
75
|
+
host?: string
|
|
76
|
+
json: boolean
|
|
77
|
+
storeRef?: string
|
|
78
|
+
openStore?: StoreOpener
|
|
79
|
+
/** Stops the server; without one it serves until the process ends. */
|
|
80
|
+
signal?: AbortSignal
|
|
81
|
+
scheduler?: RefreshScheduler
|
|
82
|
+
/** Observes the running hub, for tests. */
|
|
83
|
+
onListening?: (server: { url: string; hub: WebModelHub }) => void
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* `ab web`: serve the read-only web UI for this repository's builds. It
|
|
88
|
+
* appends nothing, takes no dispatcher lease and registers no operator
|
|
89
|
+
* presence; the store it holds refuses every write.
|
|
90
|
+
*/
|
|
91
|
+
export async function abWeb(opts: AbWebOpts): Promise<void> {
|
|
92
|
+
await withSessionlessStore(
|
|
93
|
+
{
|
|
94
|
+
targetRepo: opts.targetRepo,
|
|
95
|
+
env: opts.env,
|
|
96
|
+
exec: opts.exec,
|
|
97
|
+
...(opts.storeRef !== undefined ? { storeRef: opts.storeRef } : {}),
|
|
98
|
+
...(opts.openStore !== undefined ? { openStore: opts.openStore } : {}),
|
|
99
|
+
},
|
|
100
|
+
async ({ store, repo }) => {
|
|
101
|
+
const reader = readOnlyStore(store)
|
|
102
|
+
const hub = new WebModelHub({
|
|
103
|
+
source: new OverviewFrameSource(reader, repo),
|
|
104
|
+
networkReads: store.networkReads === true,
|
|
105
|
+
...(opts.scheduler !== undefined ? { scheduler: opts.scheduler } : {}),
|
|
106
|
+
onError: (error) =>
|
|
107
|
+
opts.stderr(
|
|
108
|
+
`ab web: store read failed: ${error instanceof Error ? error.message : error}`,
|
|
109
|
+
),
|
|
110
|
+
})
|
|
111
|
+
const analytics = new WebAnalyticsSource(reader, repo)
|
|
112
|
+
const server = await serveRepositoryWeb({
|
|
113
|
+
hub,
|
|
114
|
+
repo,
|
|
115
|
+
analytics: () => analytics,
|
|
116
|
+
...(opts.host !== undefined ? { host: opts.host } : {}),
|
|
117
|
+
port: opts.port ?? 0,
|
|
118
|
+
json: opts.json,
|
|
119
|
+
command: 'ab web',
|
|
120
|
+
announce: true,
|
|
121
|
+
stdout: opts.stdout,
|
|
122
|
+
stderr: opts.stderr,
|
|
123
|
+
})
|
|
124
|
+
try {
|
|
125
|
+
opts.onListening?.({ url: server.url, hub })
|
|
126
|
+
await untilAborted(opts.signal)
|
|
127
|
+
} finally {
|
|
128
|
+
await server.stop()
|
|
129
|
+
hub.close()
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function untilAborted(signal: AbortSignal | undefined): Promise<void> {
|
|
136
|
+
if (signal === undefined) return new Promise(() => {})
|
|
137
|
+
if (signal.aborted) return Promise.resolve()
|
|
138
|
+
return new Promise((resolve) => signal.addEventListener('abort', () => resolve(), { once: true }))
|
|
139
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOCAL_CONFIG_RELATIVE_PATH, parseLayeredConfig, type LocalOverrideRecord } from './local'
|
|
2
2
|
import type { Config, TicketsConfig } from './schema'
|
|
3
3
|
import { createRuntimeResolver, type RuntimeResolver } from '../ports/runner/routing'
|
|
4
4
|
import type { RuntimeRegistry } from '../ports/runner/runtime'
|
|
@@ -14,6 +14,7 @@ export const DISPATCHER_CONFIG_ARTIFACT = 'dispatcher-config'
|
|
|
14
14
|
export const CONFIG_RELOAD_CLASSIFICATION = {
|
|
15
15
|
store: 'restart',
|
|
16
16
|
upgrade: 'hot',
|
|
17
|
+
operator: 'hot',
|
|
17
18
|
hooks: 'hot',
|
|
18
19
|
baseBranch: 'hot',
|
|
19
20
|
capacity: 'hot',
|
|
@@ -151,6 +152,35 @@ export interface ConfigSnapshot {
|
|
|
151
152
|
readonly resolver: RuntimeResolver
|
|
152
153
|
/** Process-local revision. Zero is the startup file. */
|
|
153
154
|
readonly revision: number
|
|
155
|
+
/** Settings this snapshot took from the checkout's local override file. */
|
|
156
|
+
readonly localOverrides?: LocalOverrideRecord
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** One dispatcher configuration candidate: the committed `autobuild.toml`
|
|
160
|
+
* text and, in checkout mode, the local override file's text when present. */
|
|
161
|
+
export interface ConfigContent {
|
|
162
|
+
committed: string
|
|
163
|
+
local?: string
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface LiveConfigOptions {
|
|
167
|
+
/** Absolute path of the checkout's local override file. Unset in origin
|
|
168
|
+
* mode, which never reads a checkout. */
|
|
169
|
+
localSource?: string
|
|
170
|
+
/** What the startup snapshot took from the local file. */
|
|
171
|
+
startupLocalOverrides?: LocalOverrideRecord
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function normalizeContent(content: string | ConfigContent): ConfigContent {
|
|
175
|
+
return typeof content === 'string' ? { committed: content } : content
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** Comparison key of a candidate. Without a local layer it is exactly the
|
|
179
|
+
* committed text, as it was before the layer existed. */
|
|
180
|
+
function contentKey(content: ConfigContent): string {
|
|
181
|
+
return content.local === undefined
|
|
182
|
+
? content.committed
|
|
183
|
+
: JSON.stringify([content.committed, content.local])
|
|
154
184
|
}
|
|
155
185
|
|
|
156
186
|
export type ConfigReloadOutcome =
|
|
@@ -177,7 +207,10 @@ export type ConfigReloadOutcome =
|
|
|
177
207
|
}
|
|
178
208
|
|
|
179
209
|
export type ConfigReloadPublisher = (input: {
|
|
210
|
+
/** The committed `autobuild.toml` text of the candidate. */
|
|
180
211
|
content: string
|
|
212
|
+
/** Settings the candidate takes from the local override file, if any. */
|
|
213
|
+
localOverrides?: LocalOverrideRecord
|
|
181
214
|
/** Fully composed snapshot that will become current after publication. */
|
|
182
215
|
effectiveConfig: Config
|
|
183
216
|
restartRequired: readonly RestartRequiredConfigPath[]
|
|
@@ -185,7 +218,9 @@ export type ConfigReloadPublisher = (input: {
|
|
|
185
218
|
}) => Promise<void>
|
|
186
219
|
|
|
187
220
|
/**
|
|
188
|
-
* Process-local owner of the dispatcher's effective config.
|
|
221
|
+
* Process-local owner of the dispatcher's effective config: `autobuild.toml`
|
|
222
|
+
* layered with the checkout's `.autobuild/local.toml`, read together as one
|
|
223
|
+
* candidate. A candidate is
|
|
189
224
|
* published only after parsing, eager route validation, and durable journal
|
|
190
225
|
* publication all succeed. Callers capture `current()` once per boundary.
|
|
191
226
|
*
|
|
@@ -200,11 +235,12 @@ export class LiveConfig {
|
|
|
200
235
|
private rejectedContent: string | undefined
|
|
201
236
|
private acceptedDeprecations: readonly string[]
|
|
202
237
|
private noticedCandidate: string | undefined
|
|
238
|
+
private readonly localSource: string | undefined
|
|
203
239
|
|
|
204
240
|
constructor(
|
|
205
241
|
private readonly source: string,
|
|
206
242
|
private readonly startup: Config,
|
|
207
|
-
startupContent: string,
|
|
243
|
+
startupContent: string | ConfigContent,
|
|
208
244
|
private readonly runtimes: RuntimeRegistry,
|
|
209
245
|
private readonly publish: ConfigReloadPublisher,
|
|
210
246
|
startupDeprecations: readonly string[] = [],
|
|
@@ -212,8 +248,10 @@ export class LiveConfig {
|
|
|
212
248
|
* running process (for example the ticket source's capabilities); a
|
|
213
249
|
* throw rejects the reload and keeps the previous snapshot. */
|
|
214
250
|
private readonly validate?: (config: Config) => void,
|
|
251
|
+
options: LiveConfigOptions = {},
|
|
215
252
|
) {
|
|
216
|
-
this.
|
|
253
|
+
this.localSource = options.localSource
|
|
254
|
+
this.acceptedContent = contentKey(normalizeContent(startupContent))
|
|
217
255
|
this.acceptedDeprecations = startupDeprecations
|
|
218
256
|
this.snapshot = {
|
|
219
257
|
config: startup,
|
|
@@ -225,6 +263,7 @@ export class LiveConfig {
|
|
|
225
263
|
startup.profiles,
|
|
226
264
|
),
|
|
227
265
|
revision: 0,
|
|
266
|
+
...(options.startupLocalOverrides ? { localOverrides: options.startupLocalOverrides } : {}),
|
|
228
267
|
}
|
|
229
268
|
}
|
|
230
269
|
|
|
@@ -238,7 +277,33 @@ export class LiveConfig {
|
|
|
238
277
|
}
|
|
239
278
|
|
|
240
279
|
async refreshFromDisk(): Promise<ConfigReloadOutcome> {
|
|
241
|
-
|
|
280
|
+
const localSource = this.localSource
|
|
281
|
+
if (localSource === undefined) return this.refreshFrom(() => Bun.file(this.source).text())
|
|
282
|
+
let local: string | undefined
|
|
283
|
+
try {
|
|
284
|
+
local = await Bun.file(localSource).text()
|
|
285
|
+
} catch (error) {
|
|
286
|
+
const code = (error as NodeJS.ErrnoException).code
|
|
287
|
+
if (code !== 'ENOENT' && code !== 'ENOTDIR') {
|
|
288
|
+
const message =
|
|
289
|
+
`${localSource} could not be read during live reload: ${
|
|
290
|
+
error instanceof Error ? error.message : String(error)
|
|
291
|
+
}; the last valid configuration snapshot remains active — ` +
|
|
292
|
+
`fix or remove ${LOCAL_CONFIG_RELATIVE_PATH} to resume live reload`
|
|
293
|
+
return this.rejectRead(message)
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return this.refreshFrom(async () => {
|
|
297
|
+
const committed = await Bun.file(this.source).text()
|
|
298
|
+
return local === undefined ? committed : { committed, local }
|
|
299
|
+
})
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
private rejectRead(message: string): ConfigReloadOutcome {
|
|
303
|
+
const rejectedRead = `\0${message}`
|
|
304
|
+
const notify = this.rejectedContent !== rejectedRead
|
|
305
|
+
this.rejectedContent = rejectedRead
|
|
306
|
+
return { kind: 'rejected', error: message, notify }
|
|
242
307
|
}
|
|
243
308
|
|
|
244
309
|
/** Reload from any content source — the startup file (refreshFromDisk) or,
|
|
@@ -246,8 +311,8 @@ export class LiveConfig {
|
|
|
246
311
|
* through the forge. Read failures take the same rejected-read path: the
|
|
247
312
|
* last valid snapshot remains active and the error is reported once per
|
|
248
313
|
* distinct failure. */
|
|
249
|
-
async refreshFrom(read: () => Promise<string>): Promise<ConfigReloadOutcome> {
|
|
250
|
-
let content: string
|
|
314
|
+
async refreshFrom(read: () => Promise<string | ConfigContent>): Promise<ConfigReloadOutcome> {
|
|
315
|
+
let content: string | ConfigContent
|
|
251
316
|
try {
|
|
252
317
|
content = await read()
|
|
253
318
|
} catch (error) {
|
|
@@ -261,15 +326,14 @@ export class LiveConfig {
|
|
|
261
326
|
const message =
|
|
262
327
|
`${this.source} ${detail}; the last valid configuration snapshot remains active — ` +
|
|
263
328
|
'restore a valid autobuild.toml to resume live reload'
|
|
264
|
-
|
|
265
|
-
const notify = this.rejectedContent !== rejectedRead
|
|
266
|
-
this.rejectedContent = rejectedRead
|
|
267
|
-
return { kind: 'rejected', error: message, notify }
|
|
329
|
+
return this.rejectRead(message)
|
|
268
330
|
}
|
|
269
331
|
return this.refresh(content)
|
|
270
332
|
}
|
|
271
333
|
|
|
272
|
-
async refresh(
|
|
334
|
+
async refresh(candidateContent: string | ConfigContent): Promise<ConfigReloadOutcome> {
|
|
335
|
+
const layers = normalizeContent(candidateContent)
|
|
336
|
+
const content = contentKey(layers)
|
|
273
337
|
if (content === this.acceptedContent) {
|
|
274
338
|
this.rejectedContent = undefined
|
|
275
339
|
this.noticedCandidate = undefined
|
|
@@ -277,9 +341,23 @@ export class LiveConfig {
|
|
|
277
341
|
}
|
|
278
342
|
|
|
279
343
|
let candidate: Config
|
|
344
|
+
let localOverrides: LocalOverrideRecord | undefined
|
|
280
345
|
const deprecations: string[] = []
|
|
281
346
|
try {
|
|
282
|
-
|
|
347
|
+
;({ config: candidate, localOverrides } = parseLayeredConfig(
|
|
348
|
+
{
|
|
349
|
+
committed: { text: layers.committed, source: this.source },
|
|
350
|
+
...(layers.local === undefined
|
|
351
|
+
? {}
|
|
352
|
+
: {
|
|
353
|
+
local: {
|
|
354
|
+
text: layers.local,
|
|
355
|
+
source: this.localSource ?? LOCAL_CONFIG_RELATIVE_PATH,
|
|
356
|
+
},
|
|
357
|
+
}),
|
|
358
|
+
},
|
|
359
|
+
(line) => deprecations.push(line),
|
|
360
|
+
))
|
|
283
361
|
} catch (error) {
|
|
284
362
|
const message = error instanceof Error ? error.message : String(error)
|
|
285
363
|
const notify = this.rejectedContent !== content
|
|
@@ -317,7 +395,13 @@ export class LiveConfig {
|
|
|
317
395
|
const restartRequired = restartRequiredChanges(this.startup, candidate)
|
|
318
396
|
const effectiveChanged = !same(this.snapshot.config, config)
|
|
319
397
|
try {
|
|
320
|
-
await this.publish({
|
|
398
|
+
await this.publish({
|
|
399
|
+
content: layers.committed,
|
|
400
|
+
...(localOverrides ? { localOverrides } : {}),
|
|
401
|
+
effectiveConfig: config,
|
|
402
|
+
restartRequired,
|
|
403
|
+
effectiveChanged,
|
|
404
|
+
})
|
|
321
405
|
} catch (error) {
|
|
322
406
|
return {
|
|
323
407
|
kind: 'publication-failed',
|
|
@@ -334,6 +418,7 @@ export class LiveConfig {
|
|
|
334
418
|
config,
|
|
335
419
|
resolver,
|
|
336
420
|
revision: this.snapshot.revision + 1,
|
|
421
|
+
...(localOverrides ? { localOverrides } : {}),
|
|
337
422
|
}
|
|
338
423
|
return {
|
|
339
424
|
kind: 'adopted',
|
|
@@ -3,14 +3,18 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Branch-owned worktree config and supplied immutable text are parsed as
|
|
5
5
|
* one-shot inputs: `parseConfig(text)` is the primary API, while
|
|
6
|
-
* `loadConfig(path)`
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* `loadConfig(path)` reads a checkout for scoped CLI and local tooling, layering
|
|
7
|
+
* the checkout's uncommitted `.autobuild/local.toml` over `autobuild.toml`
|
|
8
|
+
* (see `./local`). The running dispatcher has a separate live-reload context:
|
|
9
|
+
* `LiveConfig` reads the main checkout's two files as one candidate, retains its
|
|
10
|
+
* last valid snapshot across rejected candidates, and lets each action capture
|
|
11
|
+
* the current snapshot at its boundary.
|
|
10
12
|
*/
|
|
13
|
+
import { dirname } from 'node:path'
|
|
11
14
|
import { parse as parseToml, TomlError } from 'smol-toml'
|
|
12
15
|
import type { z } from 'zod'
|
|
13
16
|
import { expandIssues } from '../zod-issues'
|
|
17
|
+
import { parseLayeredConfig, readLocalConfig } from './local'
|
|
14
18
|
import { configSchema, TOP_LEVEL_SCALARS, TOP_LEVEL_TABLES, type Config } from './schema'
|
|
15
19
|
|
|
16
20
|
/**
|
|
@@ -84,23 +88,15 @@ function duplicateHookName(text: string, error: TomlError): string | undefined {
|
|
|
84
88
|
return name.startsWith('"') || name.startsWith("'") ? name.slice(1, -1) : name
|
|
85
89
|
}
|
|
86
90
|
|
|
87
|
-
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
|
|
91
|
-
* `ab init`, `ab upgrade`). Recurring or internal callers — the dispatcher and
|
|
92
|
-
* pipeline-source resolution — pass their own sink, a collector or a no-op, so
|
|
93
|
-
* a deprecation is reported once per startup or changed file instead of per
|
|
94
|
-
* phase launch.
|
|
95
|
-
*/
|
|
96
|
-
export function parseConfig(
|
|
91
|
+
/** Parse TOML text into a raw table, naming `source` in every syntax error.
|
|
92
|
+
* No schema validation happens here: layered readers merge raw tables first
|
|
93
|
+
* (see `./local`) so defaults and cross-validation see the merged input. */
|
|
94
|
+
export function parseConfigTable(
|
|
97
95
|
tomlText: string,
|
|
98
96
|
source = 'autobuild.toml',
|
|
99
|
-
|
|
100
|
-
): Config {
|
|
101
|
-
let table: unknown
|
|
97
|
+
): Record<string, unknown> {
|
|
102
98
|
try {
|
|
103
|
-
|
|
99
|
+
return parseToml(tomlText) as Record<string, unknown>
|
|
104
100
|
} catch (error) {
|
|
105
101
|
if (error instanceof TomlError) {
|
|
106
102
|
const hook = duplicateHookName(tomlText, error)
|
|
@@ -112,7 +108,21 @@ export function parseConfig(
|
|
|
112
108
|
}
|
|
113
109
|
throw error
|
|
114
110
|
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Admission for committed input, separate from effective/artifact validation. */
|
|
114
|
+
export function admitCommittedConfig(table: Record<string, unknown>, source: string): void {
|
|
115
|
+
if (Object.hasOwn(table, 'operator'))
|
|
116
|
+
throw new ConfigError(`${source}: [operator] is local-only; set it in .autobuild/local.toml`)
|
|
117
|
+
}
|
|
115
118
|
|
|
119
|
+
/** Validate a raw configuration table; every error names `source`. Deprecated
|
|
120
|
+
* spellings are reported through `warn` after validation succeeds. */
|
|
121
|
+
export function validateConfigTable(
|
|
122
|
+
table: Record<string, unknown>,
|
|
123
|
+
source = 'autobuild.toml',
|
|
124
|
+
warn: (message: string) => void = console.error,
|
|
125
|
+
): Config {
|
|
116
126
|
if (table && typeof table === 'object' && 'orchestrator' in table) {
|
|
117
127
|
const orchestrator = table.orchestrator
|
|
118
128
|
if (orchestrator && typeof orchestrator === 'object') {
|
|
@@ -140,7 +150,38 @@ export function parseConfig(
|
|
|
140
150
|
return result.data
|
|
141
151
|
}
|
|
142
152
|
|
|
143
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Parse and validate autobuild.toml text. Deprecated spellings are reported
|
|
155
|
+
* through `warn` after validation succeeds; invalid text throws first. The
|
|
156
|
+
* `console.error` default suits explicit one-shot reads (scoped CLI commands,
|
|
157
|
+
* `ab init`, `ab upgrade`). Recurring or internal callers — the dispatcher and
|
|
158
|
+
* pipeline-source resolution — pass their own sink, a collector or a no-op, so
|
|
159
|
+
* a deprecation is reported once per startup or changed file instead of per
|
|
160
|
+
* phase launch.
|
|
161
|
+
*
|
|
162
|
+
* This reads committed text only. Readers of a checkout use `loadConfig`,
|
|
163
|
+
* which layers the checkout's `.autobuild/local.toml` over it.
|
|
164
|
+
*/
|
|
165
|
+
export function parseConfig(
|
|
166
|
+
tomlText: string,
|
|
167
|
+
source = 'autobuild.toml',
|
|
168
|
+
warn: (message: string) => void = console.error,
|
|
169
|
+
): Config {
|
|
170
|
+
const table = parseConfigTable(tomlText, source)
|
|
171
|
+
admitCommittedConfig(table, source)
|
|
172
|
+
return validateConfigTable(table, source, warn)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Read a checkout's configuration: `path` (its `autobuild.toml`) layered with
|
|
177
|
+
* the sibling `.autobuild/local.toml` when that file exists. Without a local
|
|
178
|
+
* file the result is exactly `parseConfig` of `path`.
|
|
179
|
+
*/
|
|
180
|
+
export async function loadConfig(
|
|
181
|
+
path: string,
|
|
182
|
+
warn: (message: string) => void = console.error,
|
|
183
|
+
): Promise<Config> {
|
|
144
184
|
const text = await Bun.file(path).text()
|
|
145
|
-
|
|
185
|
+
const local = await readLocalConfig(dirname(path))
|
|
186
|
+
return parseLayeredConfig({ committed: { text, source: path }, local }, warn).config
|
|
146
187
|
}
|