@defrex/autobuild 1.0.0-beta.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/SPEC.md +45 -36
- package/docs/agent-runtimes.md +157 -0
- package/docs/build-store.md +123 -0
- package/docs/builds.md +82 -0
- package/docs/cli.md +48 -0
- package/docs/configuration-overview.md +93 -0
- package/docs/configuration.md +1626 -204
- package/docs/dispatcher-hosting.md +115 -0
- package/docs/dispatcher.md +59 -0
- package/docs/forges.md +121 -0
- package/docs/getting-started.md +60 -0
- package/docs/glossary.md +60 -0
- package/docs/hosted-service.md +2 -2
- package/docs/intake.md +48 -0
- package/docs/integration-overview.md +81 -0
- package/docs/operating.md +114 -0
- package/docs/operator-api.md +6 -6
- package/docs/operator-surfaces.md +90 -0
- package/docs/overview.md +49 -0
- package/docs/plugin-authoring.md +426 -0
- package/docs/remote-store-protocol.md +8 -8
- package/docs/seams.md +66 -0
- package/docs/setup.md +8 -6
- package/docs/skills.md +119 -0
- package/docs/ticket-sources.md +132 -0
- package/docs/tickets.md +69 -0
- package/docs/troubleshooting.md +111 -0
- package/docs/upgrading.md +50 -0
- package/docs/verification.md +146 -0
- package/docs/website.md +47 -5
- package/docs/workspaces.md +152 -0
- package/package.json +5 -4
- package/packages/core/src/cli/env.ts +1 -1
- package/packages/core/src/cli/help.ts +4 -2
- package/packages/core/src/config/landing.ts +8 -0
- package/packages/core/src/config/reference-metadata.ts +31 -0
- package/packages/core/src/config/reference.ts +342 -0
- package/packages/core/src/config/roles.ts +1 -1
- package/packages/core/src/config/schema.ts +344 -6
- package/packages/core/src/ontology.ts +2 -2
- package/packages/core/src/open-map.ts +3 -1
- package/skills/finalize/SKILL.md +3 -1
- package/skills/guide/SKILL.md +42 -25
- package/skills/guide/references/operator-api.md +18 -10
- package/skills/guide/references/plugin-authoring.md +227 -303
- package/skills/guide/references/remote-store-protocol.md +8 -8
- package/skills/guide/references/setup.md +8 -6
- package/skills/implement/SKILL.md +4 -2
- package/skills/operate/SKILL.md +26 -27
- package/skills/plan/SKILL.md +12 -4
- package/skills/spec/SKILL.md +1 -1
- package/skills/tickets/SKILL.md +1 -1
- package/templates/hosted-service/package.json +2 -2
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import type { z } from 'zod'
|
|
2
|
+
import { referenceMetadata, type ReferenceMetadata } from './reference-metadata'
|
|
3
|
+
import { BUILTIN_WORKSPACE_PROVIDER_CONFIG, configRootSchema } from './schema'
|
|
4
|
+
import { BUILD_OWNED_CONFIG_PATHS, CONFIG_RELOAD_CLASSIFICATION } from './live'
|
|
5
|
+
|
|
6
|
+
/** Zod 4 input adapter. Unsupported nodes/checks fail closed at their TOML path. */
|
|
7
|
+
interface Definition {
|
|
8
|
+
type: string
|
|
9
|
+
innerType?: z.ZodType
|
|
10
|
+
in?: z.ZodType
|
|
11
|
+
element?: z.ZodType
|
|
12
|
+
shape?: Record<string, z.ZodType>
|
|
13
|
+
catchall?: z.ZodType
|
|
14
|
+
options?: z.ZodType[]
|
|
15
|
+
entries?: Record<string, string>
|
|
16
|
+
values?: unknown[]
|
|
17
|
+
defaultValue?: unknown
|
|
18
|
+
checks?: { _zod: { def: Check } }[]
|
|
19
|
+
}
|
|
20
|
+
interface Check {
|
|
21
|
+
check: string
|
|
22
|
+
format?: string
|
|
23
|
+
value?: number
|
|
24
|
+
minimum?: number
|
|
25
|
+
maximum?: number
|
|
26
|
+
length?: number
|
|
27
|
+
inclusive?: boolean
|
|
28
|
+
pattern?: RegExp
|
|
29
|
+
error?: () => string
|
|
30
|
+
}
|
|
31
|
+
function definition(schema: z.ZodType): Definition {
|
|
32
|
+
return schema._zod.def as unknown as Definition
|
|
33
|
+
}
|
|
34
|
+
function fail(path: string, message: string): never {
|
|
35
|
+
throw new Error(`Configuration reference ${path}: ${message}`)
|
|
36
|
+
}
|
|
37
|
+
function metadata(schema: z.ZodType, path: string): ReferenceMetadata {
|
|
38
|
+
const result = referenceMetadata(schema) ?? {}
|
|
39
|
+
for (const [key, value] of Object.entries(result)) {
|
|
40
|
+
if (!['description', 'constraints', 'required', 'examples', 'structure'].includes(key))
|
|
41
|
+
fail(path, `unknown metadata ${key}`)
|
|
42
|
+
if (
|
|
43
|
+
['description', 'constraints', 'required'].includes(key) &&
|
|
44
|
+
(typeof value !== 'string' || !value.trim())
|
|
45
|
+
)
|
|
46
|
+
fail(path, `blank or malformed ${key}`)
|
|
47
|
+
}
|
|
48
|
+
if (
|
|
49
|
+
result.examples !== undefined &&
|
|
50
|
+
(!Array.isArray(result.examples) ||
|
|
51
|
+
result.examples.some((v) => typeof v !== 'string' || !v.trim()))
|
|
52
|
+
)
|
|
53
|
+
fail(path, 'malformed examples')
|
|
54
|
+
if (result.structure !== undefined) {
|
|
55
|
+
const structure = result.structure
|
|
56
|
+
if (!structure || typeof structure !== 'object') fail(path, 'malformed structure metadata')
|
|
57
|
+
const allowed =
|
|
58
|
+
structure.kind === 'map'
|
|
59
|
+
? ['kind', 'value', 'keys']
|
|
60
|
+
: structure.kind === 'steps'
|
|
61
|
+
? ['kind', 'steps', 'table', 'afterReconcile']
|
|
62
|
+
: []
|
|
63
|
+
if (!allowed.length) fail(path, 'unsupported structure descriptor')
|
|
64
|
+
for (const key of Object.keys(structure))
|
|
65
|
+
if (!allowed.includes(key)) fail(path, `unknown structure metadata ${key}`)
|
|
66
|
+
const isSchema = (value: unknown): value is z.ZodType =>
|
|
67
|
+
typeof value === 'object' && value !== null && '_zod' in value
|
|
68
|
+
if (structure.kind === 'map') {
|
|
69
|
+
if (!isSchema(structure.value) || !['any', 'nonempty', 'nonblank'].includes(structure.keys))
|
|
70
|
+
fail(path, 'malformed map descriptor')
|
|
71
|
+
} else if (
|
|
72
|
+
!isSchema(structure.steps) ||
|
|
73
|
+
!isSchema(structure.table) ||
|
|
74
|
+
(structure.afterReconcile !== undefined && !isSchema(structure.afterReconcile))
|
|
75
|
+
)
|
|
76
|
+
fail(path, 'malformed steps descriptor')
|
|
77
|
+
}
|
|
78
|
+
return result
|
|
79
|
+
}
|
|
80
|
+
interface Input {
|
|
81
|
+
schema: z.ZodType
|
|
82
|
+
metadata: ReferenceMetadata
|
|
83
|
+
optional: boolean
|
|
84
|
+
default: string
|
|
85
|
+
constraints: string[]
|
|
86
|
+
}
|
|
87
|
+
function checks(schema: z.ZodType, path: string, meta: ReferenceMetadata): string[] {
|
|
88
|
+
return (definition(schema).checks ?? []).map(({ _zod: { def } }) => {
|
|
89
|
+
switch (def.check) {
|
|
90
|
+
case 'number_format':
|
|
91
|
+
if (def.format !== 'safeint') fail(path, `unsupported number format ${def.format}`)
|
|
92
|
+
return 'safe integer'
|
|
93
|
+
case 'greater_than':
|
|
94
|
+
return `${def.inclusive ? '≥' : '>'} ${def.value}`
|
|
95
|
+
case 'less_than':
|
|
96
|
+
return `${def.inclusive ? '≤' : '<'} ${def.value}`
|
|
97
|
+
case 'min_length':
|
|
98
|
+
return `minimum length ${def.minimum}`
|
|
99
|
+
case 'max_length':
|
|
100
|
+
return `maximum length ${def.maximum}`
|
|
101
|
+
case 'length_equals':
|
|
102
|
+
return `length ${def.length}`
|
|
103
|
+
case 'multiple_of':
|
|
104
|
+
return `multiple of ${def.value}`
|
|
105
|
+
case 'string_format':
|
|
106
|
+
if (def.format !== 'regex' || !def.pattern)
|
|
107
|
+
fail(path, `unsupported string format ${def.format}`)
|
|
108
|
+
return `matches ${def.pattern}`
|
|
109
|
+
case 'custom': {
|
|
110
|
+
const message = def.error?.()
|
|
111
|
+
if (message) return message
|
|
112
|
+
if (meta.constraints) return meta.constraints
|
|
113
|
+
return fail(path, 'custom refinement needs constraint metadata')
|
|
114
|
+
}
|
|
115
|
+
default:
|
|
116
|
+
return fail(path, `unsupported check ${def.check}`)
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
/** Preserve outer defaults: optional(default(x)) still applies x in Zod 4. */
|
|
121
|
+
function input(schema: z.ZodType, path: string): Input {
|
|
122
|
+
let current = schema
|
|
123
|
+
let meta: ReferenceMetadata = {}
|
|
124
|
+
let optional = false
|
|
125
|
+
let fallback = 'omitted'
|
|
126
|
+
let hasDefault = false
|
|
127
|
+
const constraints: string[] = []
|
|
128
|
+
for (;;) {
|
|
129
|
+
const own = metadata(current, path)
|
|
130
|
+
meta = { ...own, ...meta }
|
|
131
|
+
constraints.push(...checks(current, path, meta))
|
|
132
|
+
const def = definition(current)
|
|
133
|
+
if (meta.structure) break
|
|
134
|
+
if (['optional', 'default', 'prefault'].includes(def.type)) {
|
|
135
|
+
optional = true
|
|
136
|
+
if (!hasDefault && def.type !== 'optional') {
|
|
137
|
+
fallback = JSON.stringify(def.defaultValue)
|
|
138
|
+
if (def.type === 'prefault')
|
|
139
|
+
fallback += ' (input supplied on omission; nested defaults apply)'
|
|
140
|
+
hasDefault = true
|
|
141
|
+
}
|
|
142
|
+
if (!def.innerType) fail(path, 'wrapper has no inner schema')
|
|
143
|
+
current = def.innerType
|
|
144
|
+
} else if (def.type === 'pipe') {
|
|
145
|
+
if (!def.in) fail(path, 'pipe has no input schema')
|
|
146
|
+
// A transformation must explain input-to-output semantics, not hide them.
|
|
147
|
+
if (!meta.constraints) fail(path, 'transform needs input constraint metadata')
|
|
148
|
+
if (definition(def.in).type === 'unknown')
|
|
149
|
+
fail(path, 'opaque transform needs a structural input descriptor')
|
|
150
|
+
current = def.in
|
|
151
|
+
} else break
|
|
152
|
+
}
|
|
153
|
+
// openMap and stepSection carry their descriptor on an outer prefault.
|
|
154
|
+
if (meta.structure && definition(current).type === 'prefault' && !hasDefault) {
|
|
155
|
+
optional = true
|
|
156
|
+
fallback = `${JSON.stringify(definition(current).defaultValue)} (input supplied on omission)`
|
|
157
|
+
}
|
|
158
|
+
return { schema: current, metadata: meta, optional, default: fallback, constraints }
|
|
159
|
+
}
|
|
160
|
+
function typeOf(value: Input, path: string): string {
|
|
161
|
+
if (value.metadata.structure) return 'table'
|
|
162
|
+
const def = definition(value.schema)
|
|
163
|
+
switch (def.type) {
|
|
164
|
+
case 'object':
|
|
165
|
+
if (!def.catchall || definition(def.catchall).type !== 'never')
|
|
166
|
+
fail(path, 'unsupported non-strict object; use an explicit open-map descriptor')
|
|
167
|
+
return 'strict table'
|
|
168
|
+
case 'unknown':
|
|
169
|
+
return 'plugin-owned TOML value'
|
|
170
|
+
case 'string':
|
|
171
|
+
case 'boolean':
|
|
172
|
+
case 'number':
|
|
173
|
+
return def.type
|
|
174
|
+
case 'literal':
|
|
175
|
+
return def.values!.map((v) => JSON.stringify(v)).join(' | ')
|
|
176
|
+
case 'enum':
|
|
177
|
+
return Object.values(def.entries!)
|
|
178
|
+
.map((v) => JSON.stringify(v))
|
|
179
|
+
.join(' | ')
|
|
180
|
+
case 'array':
|
|
181
|
+
return `array of ${typeOf(input(def.element!, `${path}[]`), `${path}[]`)}`
|
|
182
|
+
case 'union':
|
|
183
|
+
return def.options!.map((v) => typeOf(input(v, path), path)).join(' | ')
|
|
184
|
+
default:
|
|
185
|
+
return fail(path, `unsupported schema node ${def.type}`)
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
export interface ReferenceField {
|
|
189
|
+
path: string
|
|
190
|
+
type: string
|
|
191
|
+
default: string
|
|
192
|
+
required: string
|
|
193
|
+
reload: string
|
|
194
|
+
description: string
|
|
195
|
+
constraints: string[]
|
|
196
|
+
examples: string[]
|
|
197
|
+
variant?: string
|
|
198
|
+
}
|
|
199
|
+
/** Optional ticket fields overlay the candidate in composeReloadedConfig. */
|
|
200
|
+
export const DOCUMENTATION_RELOAD_FALLBACK = {
|
|
201
|
+
'tickets.url': 'hot',
|
|
202
|
+
'tickets.doneState': 'hot',
|
|
203
|
+
} as const
|
|
204
|
+
export function reloadBehavior(path: string): string {
|
|
205
|
+
const parts = path.replaceAll('[]', '').split('.')
|
|
206
|
+
let classification: unknown = CONFIG_RELOAD_CLASSIFICATION
|
|
207
|
+
for (const part of parts) {
|
|
208
|
+
if (typeof classification === 'string') break
|
|
209
|
+
classification = (classification as Record<string, unknown> | undefined)?.[part]
|
|
210
|
+
}
|
|
211
|
+
if (typeof classification === 'object' && classification !== null) {
|
|
212
|
+
const values = Object.values(classification)
|
|
213
|
+
classification = values.every((value) => value === values[0]) ? values[0] : 'mixed'
|
|
214
|
+
}
|
|
215
|
+
classification ??=
|
|
216
|
+
DOCUMENTATION_RELOAD_FALLBACK[path as keyof typeof DOCUMENTATION_RELOAD_FALLBACK]
|
|
217
|
+
if (!['hot', 'restart', 'mixed'].includes(String(classification)))
|
|
218
|
+
fail(path, 'missing reload classification')
|
|
219
|
+
const dispatcher =
|
|
220
|
+
classification === 'hot'
|
|
221
|
+
? 'Hot: next dispatcher action captures the accepted value.'
|
|
222
|
+
: classification === 'restart'
|
|
223
|
+
? 'Dispatcher restart required; startup adapters retain their configuration.'
|
|
224
|
+
: 'Mixed: see individual fields for dispatcher reload behavior.'
|
|
225
|
+
const owned = BUILD_OWNED_CONFIG_PATHS.some((prefix) => parts[0] === prefix)
|
|
226
|
+
return `${dispatcher}${owned ? ' Build-owned pipeline: captured from the build branch; later base-branch edits do not replace it. Workspace provisioning applies at the next build launch.' : ''} A running invocation keeps its captured values.`
|
|
227
|
+
}
|
|
228
|
+
export function schemaFields(
|
|
229
|
+
schema: z.ZodType,
|
|
230
|
+
path: string,
|
|
231
|
+
reload: (path: string) => string = reloadBehavior,
|
|
232
|
+
): ReferenceField[] {
|
|
233
|
+
const fields: ReferenceField[] = []
|
|
234
|
+
function visit(schema: z.ZodType, path: string, variant?: string): void {
|
|
235
|
+
const value = input(schema, path)
|
|
236
|
+
const def = definition(value.schema)
|
|
237
|
+
const description = value.metadata.description ?? schema.description
|
|
238
|
+
if (!description?.trim()) fail(path, 'missing nonempty description')
|
|
239
|
+
const constraints = [...value.constraints]
|
|
240
|
+
if (value.metadata.constraints) constraints.push(value.metadata.constraints)
|
|
241
|
+
if (def.type === 'array') {
|
|
242
|
+
const element = input(def.element!, `${path}[]`)
|
|
243
|
+
constraints.push(...element.constraints.map((c) => `Each item: ${c}`))
|
|
244
|
+
if (element.metadata.constraints)
|
|
245
|
+
constraints.push(`Each item: ${element.metadata.constraints}`)
|
|
246
|
+
}
|
|
247
|
+
fields.push({
|
|
248
|
+
path,
|
|
249
|
+
type: typeOf(value, path),
|
|
250
|
+
default: value.default,
|
|
251
|
+
required:
|
|
252
|
+
value.metadata.required ??
|
|
253
|
+
(value.optional ? 'Optional' : 'Required') + (variant ? ` when ${variant}` : ''),
|
|
254
|
+
reload: reload(path),
|
|
255
|
+
description,
|
|
256
|
+
constraints: [...new Set(constraints)],
|
|
257
|
+
examples: value.metadata.examples ?? [],
|
|
258
|
+
...(variant ? { variant } : {}),
|
|
259
|
+
})
|
|
260
|
+
const structure = value.metadata.structure
|
|
261
|
+
if (structure) {
|
|
262
|
+
if (structure.kind === 'map') {
|
|
263
|
+
if (!structure.value || !['any', 'nonempty', 'nonblank'].includes(structure.keys))
|
|
264
|
+
fail(path, 'malformed map descriptor')
|
|
265
|
+
fields[fields.length - 1]!.constraints.push(`Entry names: ${structure.keys}`)
|
|
266
|
+
visit(structure.value, `${path}.<name>`, variant)
|
|
267
|
+
} else if (structure.kind === 'steps') {
|
|
268
|
+
if (!structure.steps || !structure.table) fail(path, 'malformed steps descriptor')
|
|
269
|
+
visit(structure.steps, `${path}.steps`, variant)
|
|
270
|
+
if (structure.afterReconcile)
|
|
271
|
+
visit(structure.afterReconcile, `${path}.afterReconcile`, variant)
|
|
272
|
+
visit(structure.table, `${path}.<step>`, variant)
|
|
273
|
+
} else fail(path, 'unsupported structure descriptor')
|
|
274
|
+
} else if (def.type === 'object') {
|
|
275
|
+
for (const [key, child] of Object.entries(def.shape!)) visit(child, `${path}.${key}`, variant)
|
|
276
|
+
} else if (def.type === 'array') {
|
|
277
|
+
const element = input(def.element!, `${path}[]`)
|
|
278
|
+
if (definition(element.schema).type === 'object') {
|
|
279
|
+
for (const [key, child] of Object.entries(definition(element.schema).shape!))
|
|
280
|
+
visit(child, `${path}[].${key}`, variant)
|
|
281
|
+
} else if (element.metadata.structure) visit(def.element!, `${path}[]`, variant)
|
|
282
|
+
} else if (def.type === 'union') {
|
|
283
|
+
for (const option of def.options!) {
|
|
284
|
+
const branch = input(option, path)
|
|
285
|
+
const shape = definition(branch.schema).shape
|
|
286
|
+
if (!shape) fail(path, 'union branch must be a strict table')
|
|
287
|
+
const discriminator = shape.kind && definition(input(shape.kind, path).schema).values?.[0]
|
|
288
|
+
if (typeof discriminator !== 'string')
|
|
289
|
+
fail(path, 'union needs a literal kind discriminator')
|
|
290
|
+
for (const [key, child] of Object.entries(shape))
|
|
291
|
+
visit(child, `${path}.${key}`, `kind = ${JSON.stringify(discriminator)}`)
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
visit(schema, path)
|
|
296
|
+
return fields
|
|
297
|
+
}
|
|
298
|
+
export function configurationReference(): Record<string, ReferenceField[]> {
|
|
299
|
+
const regions: Record<string, ReferenceField[]> = { root: [] }
|
|
300
|
+
for (const [key, schema] of Object.entries(configRootSchema.shape)) {
|
|
301
|
+
const fields = schemaFields(schema, key)
|
|
302
|
+
const type = fields[0]!.type
|
|
303
|
+
if (!type.includes('table')) regions.root!.push(...fields)
|
|
304
|
+
else regions[key] = fields
|
|
305
|
+
}
|
|
306
|
+
regions['pr-imageHost'] = regions.pr!.filter((field) => field.path.startsWith('pr.imageHost.'))
|
|
307
|
+
regions.pr = regions.pr!.filter((field) => !field.path.startsWith('pr.imageHost.'))
|
|
308
|
+
for (const [provider, declaration] of BUILTIN_WORKSPACE_PROVIDER_CONFIG) {
|
|
309
|
+
if (declaration.configSchema)
|
|
310
|
+
regions[`workspace-${provider}`] = schemaFields(declaration.configSchema, 'workspace.config')
|
|
311
|
+
else if (declaration.configRefusalMessage)
|
|
312
|
+
regions
|
|
313
|
+
.workspace!.find((field) => field.path === 'workspace.config')!
|
|
314
|
+
.constraints.push(
|
|
315
|
+
`provider = ${JSON.stringify(provider)}: ${declaration.configRefusalMessage}`,
|
|
316
|
+
)
|
|
317
|
+
else fail('workspace.config', `builtin ${provider} has no declaration`)
|
|
318
|
+
}
|
|
319
|
+
return regions
|
|
320
|
+
}
|
|
321
|
+
export function renderFields(fields: readonly ReferenceField[]): string {
|
|
322
|
+
return fields
|
|
323
|
+
.map((field) =>
|
|
324
|
+
[
|
|
325
|
+
`#### \`${field.path}\`${field.variant ? ` (${field.variant})` : ''}`,
|
|
326
|
+
'',
|
|
327
|
+
`**TOML key:** \`${field.path}\``,
|
|
328
|
+
'',
|
|
329
|
+
`- **Type:** \`${field.type}\``,
|
|
330
|
+
`- **Default:** \`${field.default}\``,
|
|
331
|
+
`- **Required:** ${field.required}`,
|
|
332
|
+
`- **Reload:** ${field.reload}`,
|
|
333
|
+
'',
|
|
334
|
+
`**Description:** ${field.description}`,
|
|
335
|
+
'',
|
|
336
|
+
`**Constraints:** ${field.constraints.length ? field.constraints.join('; ') : 'None beyond the input type.'}`,
|
|
337
|
+
...field.examples.flatMap((example) => ['', `**Example:** \`${example}\``]),
|
|
338
|
+
'',
|
|
339
|
+
].join('\n'),
|
|
340
|
+
)
|
|
341
|
+
.join('\n')
|
|
342
|
+
}
|
|
@@ -361,7 +361,7 @@ function deprecationNotice(entry: RoleKeyConsumers): string {
|
|
|
361
361
|
// declares its own step-named role, which wins — so it can never be a reason
|
|
362
362
|
// to keep this key, and it never blocks the rename. Counting it as one made
|
|
363
363
|
// the advice non-converging: "keep it, it is also the superseded key for
|
|
364
|
-
//
|
|
364
|
+
// acceptance", followed on the next dispatch by "it can be deleted".
|
|
365
365
|
|
|
366
366
|
// Inert: the key routes nothing at all.
|
|
367
367
|
if (activeAlias.length === 0) {
|