@defrex/autobuild 1.2.0 → 1.4.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 +416 -36
- package/docs/accounts.md +50 -1
- package/docs/answering-blocked-builds.md +4 -1
- package/docs/architecture.md +298 -17
- package/docs/build-store.md +18 -0
- package/docs/builds.md +7 -1
- package/docs/cli.md +1 -1
- package/docs/configuration-overview.md +6 -0
- package/docs/configuration.md +44 -19
- package/docs/dispatcher-hosting.md +42 -0
- package/docs/dispatcher.md +41 -0
- package/docs/forges.md +5 -0
- package/docs/integration-tree.md +24 -5
- package/docs/operating.md +11 -3
- package/docs/operator-api.md +81 -10
- package/docs/operator-surfaces.md +29 -0
- package/docs/plugin-authoring.md +51 -2
- package/docs/remote-store-protocol.md +321 -46
- package/docs/remote-ticket-protocol.md +12 -10
- package/docs/restacking.md +105 -3
- package/docs/setup.md +37 -8
- package/docs/skills.md +1 -1
- package/docs/spec-standard.md +41 -5
- package/docs/ticket-dependencies.md +8 -0
- package/docs/troubleshooting.md +9 -0
- package/docs/workspaces.md +1 -1
- package/package.json +4 -3
- package/packages/core/src/accounts/availability.ts +96 -0
- package/packages/core/src/accounts/local-owner.ts +49 -2
- package/packages/core/src/cli/attention.ts +2 -0
- package/packages/core/src/cli/binary.ts +17 -1
- package/packages/core/src/cli/context.ts +62 -0
- package/packages/core/src/cli/dashboard/model.ts +12 -3
- package/packages/core/src/cli/dashboard/poll.ts +65 -8
- package/packages/core/src/cli/dashboard/refresh.ts +2 -0
- package/packages/core/src/cli/dashboard/render.ts +46 -5
- package/packages/core/src/cli/dispatch-args.ts +27 -3
- package/packages/core/src/cli/dispatch-frontend.ts +179 -52
- package/packages/core/src/cli/dispatch-mode.ts +94 -0
- package/packages/core/src/cli/dispatch-preflight.ts +43 -0
- package/packages/core/src/cli/dispatch-repository-feed.ts +150 -33
- package/packages/core/src/cli/dispatch.ts +209 -36
- package/packages/core/src/cli/dispatcher-liveness.ts +6 -1
- package/packages/core/src/cli/forge-clear.ts +30 -0
- package/packages/core/src/cli/harvest.ts +2 -1
- package/packages/core/src/cli/help.ts +17 -3
- package/packages/core/src/cli/historical-build-state.ts +6 -0
- package/packages/core/src/cli/main.ts +43 -2
- package/packages/core/src/cli/publication-settlement.ts +17 -0
- package/packages/core/src/cli/remote-poll.ts +11 -1
- package/packages/core/src/cli/repository-status.ts +11 -0
- package/packages/core/src/cli/status.ts +7 -1
- package/packages/core/src/cli/wait.ts +9 -2
- package/packages/core/src/cli/watch.ts +47 -16
- package/packages/core/src/config/roles.ts +16 -1
- package/packages/core/src/events/catalog.ts +8 -0
- package/packages/core/src/events/forge-degradation-policy.ts +11 -0
- package/packages/core/src/events/payloads.ts +95 -2
- package/packages/core/src/events/policy.ts +19 -0
- package/packages/core/src/events/repository.ts +108 -2
- package/packages/core/src/kernel/__snapshots__/reducer-accumulator-shapes.json +464 -0
- package/packages/core/src/kernel/change-presence.ts +74 -8
- package/packages/core/src/kernel/dispatch-placement.ts +30 -0
- package/packages/core/src/kernel/engine.ts +27 -12
- package/packages/core/src/kernel/generators/leaf-restack-log.ts +17 -1
- package/packages/core/src/kernel/generators/node-restack-log.ts +14 -0
- package/packages/core/src/kernel/leaf-restack-state.ts +24 -2
- package/packages/core/src/kernel/log-index.ts +1 -1
- package/packages/core/src/kernel/node-landing.ts +27 -10
- package/packages/core/src/kernel/node-polling.ts +40 -7
- package/packages/core/src/kernel/node-restack-demand.ts +75 -0
- package/packages/core/src/kernel/node-restack-state.ts +20 -1
- package/packages/core/src/kernel/node-restack-transaction.ts +47 -1
- package/packages/core/src/kernel/read-facts.ts +120 -9
- package/packages/core/src/kernel/reconcile-head.ts +34 -11
- package/packages/core/src/kernel/reconcile-restack.ts +106 -72
- package/packages/core/src/kernel/reducer-registry.ts +6 -0
- package/packages/core/src/kernel/reducer.ts +20 -2
- package/packages/core/src/kernel/replay-retention.ts +176 -0
- package/packages/core/src/kernel/target-lineage.ts +65 -0
- package/packages/core/src/kernel/target-observation.ts +117 -0
- package/packages/core/src/kernel/ticket-preparation.ts +66 -0
- package/packages/core/src/operator/annotations.ts +6 -0
- package/packages/core/src/operator/control.ts +20 -0
- package/packages/core/src/operator/index.ts +2 -0
- package/packages/core/src/operator/registry.ts +25 -13
- package/packages/core/src/operator/tickets.ts +8 -2
- package/packages/core/src/plugin-sdk/index.ts +1 -0
- package/packages/core/src/ports/forge/fake.ts +22 -0
- package/packages/core/src/ports/forge/git-rewrite.ts +49 -12
- package/packages/core/src/ports/forge/github.ts +42 -10
- package/packages/core/src/ports/forge/local-git.ts +16 -1
- package/packages/core/src/ports/runner/account-env.ts +60 -9
- package/packages/core/src/ports/runner/claude.ts +49 -45
- package/packages/core/src/ports/types.ts +58 -4
- package/packages/core/src/ports/workspace/account-policy.ts +2 -1
- package/packages/core/src/ports/workspace/commit-preservation.ts +175 -0
- package/packages/core/src/ports/workspace/create.ts +2 -0
- package/packages/core/src/ports/workspace/fake.ts +4 -0
- package/packages/core/src/ports/workspace/git-worktree.ts +22 -1
- package/packages/core/src/ports/workspace/vercel-sandbox.ts +304 -56
- package/packages/core/src/processes/build-runner.ts +240 -111
- package/packages/core/src/processes/dispatcher-selectors.ts +3 -2
- package/packages/core/src/processes/dispatcher.ts +732 -201
- package/packages/core/src/processes/execution-no-progress.ts +8 -0
- package/packages/core/src/processes/harvest-runner.ts +6 -7
- package/packages/core/src/processes/harvest.ts +11 -16
- package/packages/core/src/processes/publication-state.ts +2 -1
- package/packages/core/src/processes/repo-view.ts +25 -0
- package/packages/core/src/processes/workspace-preservation.ts +164 -0
- package/packages/core/src/scenarios/harness.ts +7 -0
- package/packages/core/src/store/adapter.ts +9 -0
- package/packages/core/src/store/artifact-meta.ts +7 -0
- package/packages/core/src/store/build-scope.ts +28 -0
- package/packages/core/src/store/contract.ts +182 -0
- package/packages/core/src/store/event-reads.ts +156 -0
- package/packages/core/src/store/local/schema.ts +11 -0
- package/packages/core/src/store/local/store.ts +117 -2
- package/packages/core/src/store/memory.ts +241 -0
- package/packages/core/src/store/phase-session.ts +47 -0
- package/packages/core/src/store/reduced-reads.ts +8 -0
- package/packages/core/src/store/reducer-value-shapes.json +10546 -8877
- package/packages/core/src/store/reducer-value-validation.ts +109 -6
- package/packages/core/src/store/reducer-values.ts +62 -2
- package/packages/core/src/store/remote/client.ts +208 -23
- package/packages/core/src/store/remote/compatibility.ts +195 -25
- package/packages/core/src/store/remote/errors.ts +16 -0
- package/packages/core/src/store/remote/index.ts +17 -0
- package/packages/core/src/store/remote/protocol.ts +30 -1
- package/packages/core/src/store/remote/released-clients.json +37 -0
- package/packages/core/src/store/remote/released-clients.ts +88 -0
- package/packages/core/src/store/remote/released-reducer-values/1.2.0.json +8129 -0
- package/packages/core/src/store/remote/released-reducer-values/1.3.0.json +25093 -0
- package/packages/core/src/store/remote/released-reducer-values/1.4.0.json +26128 -0
- package/packages/core/src/store/remote/released-reducer-values/index.ts +13 -0
- package/packages/core/src/store/remote/version.ts +8 -1
- package/packages/core/src/store/repo-state-events.ts +6 -3
- package/packages/core/src/store/scan-cadence.ts +15 -0
- package/packages/core/src/store/session-handle.ts +18 -0
- package/packages/core/src/store/snapshots.ts +16 -3
- package/packages/core/src/store/types.ts +29 -6
- package/packages/core/src/testing/dispatch-read-budget.ts +457 -7
- package/packages/core/src/testing/index.ts +6 -1
- package/packages/core/src/testing/reduced-read-budget.ts +1240 -9
- package/skills/guide/SKILL.md +220 -22
- package/skills/guide/references/accounts.md +50 -1
- package/skills/guide/references/integration-tree.md +24 -5
- package/skills/guide/references/operator-api.md +81 -10
- package/skills/guide/references/plugin-authoring.md +51 -2
- package/skills/guide/references/remote-store-protocol.md +321 -46
- package/skills/guide/references/remote-ticket-protocol.md +12 -10
- package/skills/guide/references/restacking.md +105 -3
- package/skills/guide/references/setup.md +37 -8
- package/skills/guide/references/spec-standard.md +41 -5
- package/skills/guide/references/ticket-dependencies.md +8 -0
- package/skills/implement/SKILL.md +12 -3
- package/skills/operate/SKILL.md +85 -12
- package/skills/plan/SKILL.md +27 -4
- package/skills/plan-review/SKILL.md +22 -2
- package/skills/reconcile/SKILL.md +16 -1
- package/skills/spec/SKILL.md +7 -4
- package/skills/tickets/SKILL.md +7 -3
- package/templates/hosted-service/package.json +2 -2
|
@@ -71,6 +71,7 @@ export type MaterializedEntry = ArtifactRef | 'derived'
|
|
|
71
71
|
* commands validate with, so skills are self-checking.
|
|
72
72
|
*/
|
|
73
73
|
export interface ContextManifest {
|
|
74
|
+
workspaceRecovery?: string
|
|
74
75
|
compatibility?: import('../events/compatibility').CompatibilityState
|
|
75
76
|
compatibilityDiagnostic?: string
|
|
76
77
|
build: string
|
|
@@ -295,6 +296,67 @@ export async function buildContext(deps: ContextDeps): Promise<ContextManifest>
|
|
|
295
296
|
materialized,
|
|
296
297
|
}
|
|
297
298
|
|
|
299
|
+
// A receipt belongs to the next session, including repeated hydration. The
|
|
300
|
+
// preceding session start bounds that window without consuming notes on read.
|
|
301
|
+
const [earlier, latest] =
|
|
302
|
+
events.sessionStarts.length === 2 ? events.sessionStarts : [undefined, events.sessionStarts[0]]
|
|
303
|
+
const previousSession = (latest?.session === env.session ? earlier?.seq : latest?.seq) ?? 0
|
|
304
|
+
const loss =
|
|
305
|
+
events.workspaceLoss && events.workspaceLoss.seq > previousSession
|
|
306
|
+
? events.workspaceLoss.payload
|
|
307
|
+
: undefined
|
|
308
|
+
const checkpoint = events.workspacePreservation
|
|
309
|
+
const preserved =
|
|
310
|
+
checkpoint && checkpoint.seq > previousSession && checkpoint.payload.heads.length
|
|
311
|
+
? checkpoint.payload
|
|
312
|
+
: undefined
|
|
313
|
+
const recoveries = Object.values(events.candidateRecoveries).filter(
|
|
314
|
+
(recovery) =>
|
|
315
|
+
recovery && (events.candidateRecoverySeqs[recovery.operation] ?? 0) > previousSession,
|
|
316
|
+
)
|
|
317
|
+
const legacyRequest = events.publication.latestUncompletedRequest()
|
|
318
|
+
if (
|
|
319
|
+
loss ||
|
|
320
|
+
preserved ||
|
|
321
|
+
recoveries.length ||
|
|
322
|
+
(legacyRequest && events.publication.lostRecorded(legacyRequest))
|
|
323
|
+
) {
|
|
324
|
+
const lines = ['# Workspace commit recovery', '']
|
|
325
|
+
if (preserved) {
|
|
326
|
+
lines.push(`Preserved from ${preserved.ref}, ${preserved.phase}@${preserved.round}:`)
|
|
327
|
+
for (const head of preserved.heads)
|
|
328
|
+
lines.push(
|
|
329
|
+
`- ${head.role}: ${head.sha} (${head.remoteRef}); commits: ${head.commits.join(', ')}`,
|
|
330
|
+
)
|
|
331
|
+
lines.push(
|
|
332
|
+
'Replacement provisioning restores these exact refs before starting a session.',
|
|
333
|
+
'',
|
|
334
|
+
)
|
|
335
|
+
}
|
|
336
|
+
if (loss)
|
|
337
|
+
lines.push(
|
|
338
|
+
`Source workspace ${loss.ref}, ${loss.phase}@${loss.round}: ${loss.reason}`,
|
|
339
|
+
`Known lost candidates: ${loss.shas.join(', ') || '(no SHA inventory was observable)'}. Additional unpublished SHAs are unavailable.`,
|
|
340
|
+
'',
|
|
341
|
+
)
|
|
342
|
+
for (const recovery of recoveries) {
|
|
343
|
+
if (!recovery) continue
|
|
344
|
+
lines.push(
|
|
345
|
+
`${recovery.operation} candidate ${recovery.sha} was confirmed unavailable. Reconstruct its producer result under retained intent ${recovery.replacementId}; do not search for the retired candidate.`,
|
|
346
|
+
'',
|
|
347
|
+
)
|
|
348
|
+
}
|
|
349
|
+
const legacy = events.publication.latestUncompletedRequest()
|
|
350
|
+
if (!loss && legacy && events.publication.lostRecorded(legacy))
|
|
351
|
+
lines.push(
|
|
352
|
+
`Historical publication loss names ${legacy.payload.sha} (${legacy.payload.operation}). Availability must be checked before treating it as irrecoverable.`,
|
|
353
|
+
)
|
|
354
|
+
manifest.workspaceRecovery = await writeDerived(
|
|
355
|
+
'workspace-recovery.md',
|
|
356
|
+
`${lines.join('\n')}\n`,
|
|
357
|
+
)
|
|
358
|
+
}
|
|
359
|
+
|
|
298
360
|
if (inputs.ticket === true) {
|
|
299
361
|
const created = events.created
|
|
300
362
|
if (created !== undefined && created.type === 'build.created') {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { repositoryReadFactsReducer } from '../../kernel/read-facts'
|
|
1
2
|
import { workTargetDistance } from './target-distance'
|
|
2
3
|
import { migrationIdentity, ticketMigrationsReducer } from '../../kernel/ticket-migrations'
|
|
3
4
|
import { projectRollback, type DashboardRollback } from './rollback'
|
|
@@ -313,6 +314,7 @@ export interface DashboardCounter {
|
|
|
313
314
|
}
|
|
314
315
|
|
|
315
316
|
export interface DashboardModel {
|
|
317
|
+
viewer?: { dispatchedBy?: string }
|
|
316
318
|
rollback?: DashboardRollback
|
|
317
319
|
handoffs?: DashboardHandoff[]
|
|
318
320
|
repo: string
|
|
@@ -1350,6 +1352,15 @@ export function buildDashboardFromProjected(
|
|
|
1350
1352
|
const builds = enrichIntegrationRows(
|
|
1351
1353
|
projectedBuilds.map((row) => enrichDrainingRow(row, upgrade.draining)),
|
|
1352
1354
|
).sort((a, b) => a.slug.localeCompare(b.slug))
|
|
1355
|
+
const missingAccounts = Array.isArray(repositoryEvents)
|
|
1356
|
+
? repositoryReadFactsReducer.reduce(repositoryEvents).missingAccounts
|
|
1357
|
+
: repositoryEvents.missingAccounts
|
|
1358
|
+
const warningLines = [
|
|
1359
|
+
...(header.warningLines ?? []),
|
|
1360
|
+
...Object.values(missingAccounts).map(
|
|
1361
|
+
(account) => `Missing credentials: ${account.remedy} [${account.source}]`,
|
|
1362
|
+
),
|
|
1363
|
+
]
|
|
1353
1364
|
const harvestProjection = projectRepositoryHarvest(repositoryEvents)
|
|
1354
1365
|
const settings = Array.isArray(repositoryEvents)
|
|
1355
1366
|
? reduceDispatchSettings(repositoryEvents)
|
|
@@ -1372,9 +1383,7 @@ export function buildDashboardFromProjected(
|
|
|
1372
1383
|
...(header.selection !== undefined ? { selection: header.selection } : {}),
|
|
1373
1384
|
...(header.standby !== undefined ? { standby: header.standby } : {}),
|
|
1374
1385
|
...(header.availableUpgrade !== undefined ? { availableUpgrade: header.availableUpgrade } : {}),
|
|
1375
|
-
...(
|
|
1376
|
-
? { warningLines: header.warningLines }
|
|
1377
|
-
: {}),
|
|
1386
|
+
...(warningLines.length > 0 ? { warningLines } : {}),
|
|
1378
1387
|
...(header.resumeInput !== undefined ? { resumeInput: header.resumeInput } : {}),
|
|
1379
1388
|
builds,
|
|
1380
1389
|
...(harvestProjection.harvest !== undefined ? { harvest: harvestProjection.harvest } : {}),
|
|
@@ -14,8 +14,20 @@ import {
|
|
|
14
14
|
parseBuildConfigMetadata,
|
|
15
15
|
parseEffectiveBuildConfig,
|
|
16
16
|
} from '../../processes/build-execution-state'
|
|
17
|
-
import type {
|
|
18
|
-
|
|
17
|
+
import type {
|
|
18
|
+
Artifact,
|
|
19
|
+
BuildRecord,
|
|
20
|
+
BuildStore,
|
|
21
|
+
StreamRecord,
|
|
22
|
+
StreamScope,
|
|
23
|
+
} from '../../store/types'
|
|
24
|
+
import { readBuildFacts } from '../../store/reduced-reads'
|
|
25
|
+
import {
|
|
26
|
+
projectBuild,
|
|
27
|
+
projectBuildFromFacts,
|
|
28
|
+
type DashboardBuild,
|
|
29
|
+
type DashboardRowFacts,
|
|
30
|
+
} from './model'
|
|
19
31
|
|
|
20
32
|
/** The read-only BuildStore surface needed to construct dashboard build rows.
|
|
21
33
|
* `listStreams` is optional: when present, build-scope records enrich each
|
|
@@ -24,6 +36,7 @@ import { projectBuild, type DashboardBuild } from './model'
|
|
|
24
36
|
* metadata decorates each row with its pinned pipeline source and revision
|
|
25
37
|
* (SPEC §16.1). */
|
|
26
38
|
export interface DashboardBuildReader {
|
|
39
|
+
getReducerValue?: BuildStore['getReducerValue']
|
|
27
40
|
listBuildsForRepo(repo: string): Promise<BuildRecord[]>
|
|
28
41
|
getEvents(slug: string, sinceSeq?: number): Promise<AbEvent[]>
|
|
29
42
|
listStreams?(scope: StreamScope): Promise<StreamRecord[]>
|
|
@@ -61,7 +74,17 @@ interface TerminalEntry {
|
|
|
61
74
|
record: BuildRecord
|
|
62
75
|
}
|
|
63
76
|
|
|
64
|
-
|
|
77
|
+
interface ReducedEntry {
|
|
78
|
+
kind: 'reduced'
|
|
79
|
+
cursor: number
|
|
80
|
+
record: BuildRecord
|
|
81
|
+
state: BuildState
|
|
82
|
+
workspace: boolean
|
|
83
|
+
provisioning: boolean
|
|
84
|
+
build: DashboardBuild | null
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
type PollEntry = LiveEntry | TerminalEntry | ReducedEntry
|
|
65
88
|
|
|
66
89
|
function isTerminal(state: BuildState): boolean {
|
|
67
90
|
// `build.aborted` acknowledges cancellation but begins the checkpointed
|
|
@@ -93,8 +116,9 @@ function validateDelta(slug: string, sinceSeq: number, events: AbEvent[]): void
|
|
|
93
116
|
* Process-local, display-only acceleration for the interactive dispatch frame.
|
|
94
117
|
*
|
|
95
118
|
* Every refresh still discovers records with `listBuildsForRepo(repo)`. A first-seen
|
|
96
|
-
* stream
|
|
97
|
-
*
|
|
119
|
+
* stream uses persisted build facts when available, with no event reads; local
|
|
120
|
+
* readers without reduced values hydrate from seq 0, then read only after their
|
|
121
|
+
* reduced `lastSeq`. Empty deltas preserve the exact reduction and
|
|
98
122
|
* projected row, so phase timing is not recomputed. Only fully completed
|
|
99
123
|
* streams compact to tombstones; acknowledged aborts remain live through their
|
|
100
124
|
* cleanup checkpoints and final completion.
|
|
@@ -179,6 +203,7 @@ export class DashboardBuildPollCache {
|
|
|
179
203
|
state: BuildState,
|
|
180
204
|
events: AbEvent[],
|
|
181
205
|
config: Config,
|
|
206
|
+
facts?: DashboardRowFacts,
|
|
182
207
|
): Promise<DashboardBuild | null> {
|
|
183
208
|
const [streams, artifact] = await Promise.all([
|
|
184
209
|
this.readStreams(record.slug),
|
|
@@ -186,7 +211,9 @@ export class DashboardBuildPollCache {
|
|
|
186
211
|
])
|
|
187
212
|
const pinnedConfig =
|
|
188
213
|
artifact?.config !== undefined ? composeBuildConfig(artifact.config, config) : undefined
|
|
189
|
-
const build =
|
|
214
|
+
const build = facts
|
|
215
|
+
? projectBuildFromFacts(record, state, facts, config, streams, pinnedConfig)
|
|
216
|
+
: projectBuild(record, state, config, events, streams, pinnedConfig)
|
|
190
217
|
if (build !== null && artifact !== undefined) {
|
|
191
218
|
if (artifact.revision !== undefined) build.effectiveConfigRev = artifact.revision
|
|
192
219
|
if (artifact.pipelineSource !== undefined) build.pipelineSource = artifact.pipelineSource
|
|
@@ -225,6 +252,35 @@ export class DashboardBuildPollCache {
|
|
|
225
252
|
continue
|
|
226
253
|
}
|
|
227
254
|
|
|
255
|
+
if (this.reader.getReducerValue !== undefined) {
|
|
256
|
+
const { cursor, value } = await readBuildFacts(
|
|
257
|
+
{ getReducerValue: this.reader.getReducerValue.bind(this.reader) },
|
|
258
|
+
record.slug,
|
|
259
|
+
)
|
|
260
|
+
if (isTerminal(value.state)) {
|
|
261
|
+
next.set(record.slug, { kind: 'terminal', record })
|
|
262
|
+
} else {
|
|
263
|
+
next.set(record.slug, {
|
|
264
|
+
kind: 'reduced',
|
|
265
|
+
cursor,
|
|
266
|
+
record,
|
|
267
|
+
state: value.state,
|
|
268
|
+
workspace: value.workspace !== null,
|
|
269
|
+
provisioning: value.provisionMarker !== undefined,
|
|
270
|
+
build:
|
|
271
|
+
current?.kind === 'reduced' &&
|
|
272
|
+
current.cursor === cursor &&
|
|
273
|
+
!fullEnrichment &&
|
|
274
|
+
!configChanged &&
|
|
275
|
+
current.build?.ticketId === record.ticket?.id
|
|
276
|
+
? current.build
|
|
277
|
+
: await this.projectRow(record, value.state, [], config, value),
|
|
278
|
+
})
|
|
279
|
+
}
|
|
280
|
+
continue
|
|
281
|
+
}
|
|
282
|
+
if (current?.kind === 'reduced') throw new Error('dashboard reader lost reduced values')
|
|
283
|
+
|
|
228
284
|
const sinceSeq = current?.state.lastSeq ?? 0
|
|
229
285
|
const delta = await this.reader.getEvents(record.slug, sinceSeq)
|
|
230
286
|
validateDelta(record.slug, sinceSeq, delta)
|
|
@@ -288,8 +344,9 @@ export class DashboardBuildPollCache {
|
|
|
288
344
|
capacityBuilds.push({
|
|
289
345
|
record: entry.record,
|
|
290
346
|
state: entry.state,
|
|
291
|
-
workspace: entry.workspace.open !== null,
|
|
292
|
-
provisioning:
|
|
347
|
+
workspace: entry.kind === 'reduced' ? entry.workspace : entry.workspace.open !== null,
|
|
348
|
+
provisioning:
|
|
349
|
+
entry.kind === 'reduced' ? entry.provisioning : entry.provisionMarker.marker !== null,
|
|
293
350
|
})
|
|
294
351
|
states.set(slug, entry.state)
|
|
295
352
|
if (entry.build !== null) builds.push(entry.build)
|
|
@@ -40,6 +40,7 @@ export class DashboardRefresh {
|
|
|
40
40
|
private readonly refresh: () => Promise<void>,
|
|
41
41
|
private readonly time: RefreshScheduler = scheduler,
|
|
42
42
|
private readonly networkReads = false,
|
|
43
|
+
private readonly cadenceMs?: number,
|
|
43
44
|
) {}
|
|
44
45
|
|
|
45
46
|
get painting(): boolean {
|
|
@@ -141,6 +142,7 @@ export class DashboardRefresh {
|
|
|
141
142
|
|
|
142
143
|
/** Current admission cadence, also used to bound presentation staleness. */
|
|
143
144
|
get intervalMs(): number {
|
|
145
|
+
if (this.cadenceMs !== undefined) return this.cadenceMs
|
|
144
146
|
if (this.networkReads && !this.focused) return 5000
|
|
145
147
|
return this.live || this.time.now() < this.deadline ? 500 : 5000
|
|
146
148
|
}
|
|
@@ -557,6 +557,15 @@ export const DASHBOARD_SESSION_LIVE_LEGEND =
|
|
|
557
557
|
export const DASHBOARD_SESSION_PAUSED_LEGEND =
|
|
558
558
|
'Keys: Up/Down scroll (paused) Esc back Ctrl-C quit'
|
|
559
559
|
|
|
560
|
+
function modeLegend(model: DashboardModel, legend: string): string {
|
|
561
|
+
return model.viewer
|
|
562
|
+
? legend
|
|
563
|
+
.replace('Up/Down select', 'Up/Down')
|
|
564
|
+
.replace('Ctrl-C quit', 'Ctrl-C close viewer')
|
|
565
|
+
.replace(/ {2}/g, ' ')
|
|
566
|
+
: legend
|
|
567
|
+
}
|
|
568
|
+
|
|
560
569
|
function buildLegend(build: DashboardBuild, detail: boolean): string {
|
|
561
570
|
if (build.status === 'aborting' || build.status === 'cleaning') {
|
|
562
571
|
return detail
|
|
@@ -1026,7 +1035,7 @@ function renderDetail(model: DashboardModel, opts: RenderOpts): string[] {
|
|
|
1026
1035
|
const controls =
|
|
1027
1036
|
model.resumeInput !== undefined || model.abortConfirmation !== undefined
|
|
1028
1037
|
? dashboardControls(model, color, width, controlsCapacity(height, top.length))
|
|
1029
|
-
: [truncate(paint(buildLegend(build, true), 'dim', color), width)]
|
|
1038
|
+
: [truncate(paint(modeLegend(model, buildLegend(build, true)), 'dim', color), width)]
|
|
1030
1039
|
if (height !== undefined && height <= 0) return []
|
|
1031
1040
|
if (height !== undefined && height <= top.length) return top.slice(0, height)
|
|
1032
1041
|
if (height !== undefined && height === top.length + 1) return [...top, ...controls]
|
|
@@ -1134,7 +1143,7 @@ function renderTranscript(model: DashboardModel, opts: RenderOpts): string[] {
|
|
|
1134
1143
|
]
|
|
1135
1144
|
const content = transcriptContent(view.transcript, width).map((line) => truncate(line, width))
|
|
1136
1145
|
const controls = truncate(
|
|
1137
|
-
paint('Keys: Up/Down scroll Esc back Ctrl-C quit', 'dim', color),
|
|
1146
|
+
paint(modeLegend(model, 'Keys: Up/Down scroll Esc back Ctrl-C quit'), 'dim', color),
|
|
1138
1147
|
width,
|
|
1139
1148
|
)
|
|
1140
1149
|
if (height !== undefined && height <= 0) return []
|
|
@@ -1212,7 +1221,10 @@ function renderSessionView(model: DashboardModel, opts: RenderOpts): string[] {
|
|
|
1212
1221
|
const content = sessionContentLines(view, width).map((line) => truncate(line, width))
|
|
1213
1222
|
const controls = truncate(
|
|
1214
1223
|
paint(
|
|
1215
|
-
|
|
1224
|
+
modeLegend(
|
|
1225
|
+
model,
|
|
1226
|
+
view.follow ? DASHBOARD_SESSION_LIVE_LEGEND : DASHBOARD_SESSION_PAUSED_LEGEND,
|
|
1227
|
+
),
|
|
1216
1228
|
'dim',
|
|
1217
1229
|
color,
|
|
1218
1230
|
),
|
|
@@ -1562,7 +1574,7 @@ function dashboardControls(
|
|
|
1562
1574
|
? DASHBOARD_HARVEST_ACKNOWLEDGE_LEGEND
|
|
1563
1575
|
: DASHBOARD_HARVEST_LEGEND
|
|
1564
1576
|
: DASHBOARD_GLOBAL_LEGEND
|
|
1565
|
-
return [truncate(paint(legend, 'dim', color), width)]
|
|
1577
|
+
return [truncate(paint(modeLegend(model, legend), 'dim', color), width)]
|
|
1566
1578
|
}
|
|
1567
1579
|
return resumePanel(model, color, width, capacity)
|
|
1568
1580
|
}
|
|
@@ -1812,10 +1824,39 @@ function renderDashboardContent(model: DashboardModel, opts: RenderOpts): string
|
|
|
1812
1824
|
* truncation, and right-pinning share one geometry. Prefixing only after the
|
|
1813
1825
|
* frame is composed preserves its logical line count (including truly blank
|
|
1814
1826
|
* separators) and therefore leaves vertical budgeting unchanged. */
|
|
1827
|
+
export function renderViewerNotice(
|
|
1828
|
+
viewer: { dispatchedBy?: string },
|
|
1829
|
+
message: string,
|
|
1830
|
+
width: number,
|
|
1831
|
+
height: number,
|
|
1832
|
+
): string[] {
|
|
1833
|
+
const contentWidth = dashboardContentWidth(width)
|
|
1834
|
+
return [viewerIndicator(viewer, contentWidth), truncate(displayText(message), contentWidth)]
|
|
1835
|
+
.slice(0, Math.max(0, height))
|
|
1836
|
+
.map((line) => (width > 0 ? ` ${line}` : line))
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
export function viewerIndicator(viewer: { dispatchedBy?: string }, width: number): string {
|
|
1840
|
+
const label =
|
|
1841
|
+
viewer.dispatchedBy === undefined
|
|
1842
|
+
? 'viewer'
|
|
1843
|
+
: `viewer · dispatched by ${displayText(viewer.dispatchedBy)}`
|
|
1844
|
+
return width >= 6 && width < 9 ? 'viewer' : truncate(label, width)
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1815
1847
|
export function renderDashboard(model: DashboardModel, opts: RenderOpts): string[] {
|
|
1816
1848
|
const terminalWidth = Math.max(0, opts.width)
|
|
1817
1849
|
const contentWidth = dashboardContentWidth(terminalWidth)
|
|
1818
|
-
const
|
|
1850
|
+
const viewerRows = model.viewer ? 1 : 0
|
|
1851
|
+
const height = opts.height === undefined ? undefined : Math.max(0, opts.height - viewerRows)
|
|
1852
|
+
const lines = renderDashboardContent(model, {
|
|
1853
|
+
...opts,
|
|
1854
|
+
width: contentWidth,
|
|
1855
|
+
...(height !== undefined ? { height } : {}),
|
|
1856
|
+
})
|
|
1857
|
+
if (model.viewer && (opts.height === undefined || opts.height > 0)) {
|
|
1858
|
+
lines.unshift(viewerIndicator(model.viewer, contentWidth))
|
|
1859
|
+
}
|
|
1819
1860
|
const leftGutter = terminalWidth > 0 ? ' ' : ''
|
|
1820
1861
|
|
|
1821
1862
|
return lines.map((line) => (line === '' ? '' : `${leftGutter}${line}`))
|
|
@@ -4,10 +4,13 @@ export function parseDispatchArgs(
|
|
|
4
4
|
env: Record<string, string | undefined>,
|
|
5
5
|
) {
|
|
6
6
|
const usage =
|
|
7
|
-
'usage: ab dispatch [--once] [--interval <seconds>] [--store <ref>] [--repository <origin>] [--plain] [--intake | --no-intake] [--auto-merge | --no-auto-merge] (§3.3)'
|
|
7
|
+
'usage: ab dispatch [--viewer [--dispatched-by <label>] | --takeover] [--once] [--interval <seconds>] [--store <ref>] [--repository <origin>] [--plain] [--intake | --no-intake] [--auto-merge | --no-auto-merge] (§3.3)'
|
|
8
8
|
const parsed = parseArgs(
|
|
9
9
|
rest,
|
|
10
10
|
{
|
|
11
|
+
viewer: 'boolean',
|
|
12
|
+
takeover: 'boolean',
|
|
13
|
+
'dispatched-by': 'value',
|
|
11
14
|
once: 'boolean',
|
|
12
15
|
interval: 'value',
|
|
13
16
|
store: 'value',
|
|
@@ -22,6 +25,16 @@ export function parseDispatchArgs(
|
|
|
22
25
|
)
|
|
23
26
|
if (parsed.positionals.length > 0) throw new Error(usage)
|
|
24
27
|
|
|
28
|
+
const takeover = parsed.flags.has('takeover')
|
|
29
|
+
const viewer = parsed.flags.has('viewer')
|
|
30
|
+
if (viewer && takeover) throw new Error('--viewer and --takeover cannot be combined')
|
|
31
|
+
const dispatchedBy = stringFlag(parsed, 'dispatched-by')?.trim()
|
|
32
|
+
if (dispatchedBy !== undefined && (!viewer || dispatchedBy === ''))
|
|
33
|
+
throw new Error('--dispatched-by requires --viewer and a nonblank label')
|
|
34
|
+
if (viewer && parsed.flags.has('repository'))
|
|
35
|
+
throw new Error('--viewer requires a local checkout; omit --repository')
|
|
36
|
+
if (viewer && (parsed.flags.has('intake') || parsed.flags.has('no-intake')))
|
|
37
|
+
throw new Error('--viewer cannot set startup intake; use the interactive intake control')
|
|
25
38
|
const once = parsed.flags.has('once')
|
|
26
39
|
const plain = parsed.flags.has('plain')
|
|
27
40
|
const sawIntake = parsed.flags.has('intake')
|
|
@@ -45,9 +58,20 @@ export function parseDispatchArgs(
|
|
|
45
58
|
intervalMs = Math.round(seconds * 1000)
|
|
46
59
|
}
|
|
47
60
|
const storeRef = stringFlag(parsed, 'store')
|
|
48
|
-
const repository = stringFlag(parsed, 'repository') ?? env.AB_REPOSITORY
|
|
61
|
+
const repository = stringFlag(parsed, 'repository') ?? (viewer ? undefined : env.AB_REPOSITORY)
|
|
49
62
|
const intake = sawIntake ? true : sawNoIntake ? false : undefined
|
|
50
63
|
const defaultAutoMerge = sawAutoMerge ? true : sawNoAutoMerge ? false : undefined
|
|
51
64
|
|
|
52
|
-
return {
|
|
65
|
+
return {
|
|
66
|
+
viewer,
|
|
67
|
+
takeover,
|
|
68
|
+
dispatchedBy,
|
|
69
|
+
once,
|
|
70
|
+
plain,
|
|
71
|
+
intake,
|
|
72
|
+
defaultAutoMerge,
|
|
73
|
+
intervalMs,
|
|
74
|
+
storeRef,
|
|
75
|
+
repository,
|
|
76
|
+
}
|
|
53
77
|
}
|