@event4u/agent-config 8.4.0 → 8.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +6 -0
  3. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  4. package/dist/discovery/deprecation-report.md +1 -1
  5. package/dist/discovery/discovery-manifest.json +1 -1
  6. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  7. package/dist/discovery/discovery-manifest.summary.md +1 -1
  8. package/dist/discovery/orphan-report.md +1 -1
  9. package/dist/discovery/packs.json +1 -1
  10. package/dist/discovery/trust-report.md +1 -1
  11. package/dist/discovery/workspaces.json +1 -1
  12. package/dist/mcp/registry-manifest.json +1 -1
  13. package/package.json +4 -1
  14. package/src/agent-src/README.md +64 -0
  15. package/src/agent-src/scripts/archive_completed_roadmaps.ts +497 -0
  16. package/src/agent-src/scripts/scan-seeder-violations.php +145 -0
  17. package/src/agent-src/scripts/update_roadmap_progress.ts +1087 -0
  18. package/src/agent-src/templates/AGENTS.md +34 -0
  19. package/src/agent-src/templates/scripts/README.md +195 -0
  20. package/src/agent-src/templates/scripts/check_memory.ts +662 -0
  21. package/src/agent-src/templates/scripts/check_memory_proposal.ts +370 -0
  22. package/src/agent-src/templates/scripts/historical-bug-patterns.example.yml +84 -0
  23. package/src/agent-src/templates/scripts/implement_ticket/__main__.ts +27 -0
  24. package/src/agent-src/templates/scripts/memory_hash.ts +355 -0
  25. package/src/agent-src/templates/scripts/memory_lookup.ts +1089 -0
  26. package/src/agent-src/templates/scripts/memory_report.ts +868 -0
  27. package/src/agent-src/templates/scripts/memory_signal.ts +444 -0
  28. package/src/agent-src/templates/scripts/memory_status.ts +215 -0
  29. package/src/agent-src/templates/scripts/ownership-map.example.yml +87 -0
  30. package/src/agent-src/templates/scripts/pr-risk-config.example.yml +76 -0
  31. package/src/agent-src/templates/scripts/pr_review_routing.ts +544 -0
  32. package/src/agent-src/templates/scripts/pr_risk_review.ts +0 -0
  33. package/src/agent-src/templates/scripts/telemetry/aggregator.ts +0 -0
  34. package/src/agent-src/templates/scripts/telemetry/boundary.ts +164 -0
  35. package/src/agent-src/templates/scripts/telemetry/engagement.ts +479 -0
  36. package/src/agent-src/templates/scripts/telemetry/report_renderer.ts +394 -0
  37. package/src/agent-src/templates/scripts/telemetry/settings.ts +210 -0
  38. package/src/agent-src/templates/scripts/telemetry_record.ts +276 -0
  39. package/src/agent-src/templates/scripts/telemetry_report.ts +211 -0
  40. package/src/agent-src/templates/scripts/telemetry_status.ts +333 -0
  41. package/src/agent-src/templates/scripts/tier_usage_report.ts +619 -0
  42. package/src/agent-src/templates/scripts/work_engine/__main__.ts +14 -0
  43. package/src/agent-src/templates/scripts/work_engine/_lib/agent_settings.ts +1261 -0
  44. package/src/agent-src/templates/scripts/work_engine/_lib/user_global_paths.ts +329 -0
  45. package/src/agent-src/templates/scripts/work_engine/cli.ts +206 -0
  46. package/src/agent-src/templates/scripts/work_engine/cli_args.ts +249 -0
  47. package/src/agent-src/templates/scripts/work_engine/delivery_state.ts +225 -0
  48. package/src/agent-src/templates/scripts/work_engine/directives/backend/analyze.ts +125 -0
  49. package/src/agent-src/templates/scripts/work_engine/directives/backend/implement.ts +189 -0
  50. package/src/agent-src/templates/scripts/work_engine/directives/backend/index.ts +94 -0
  51. package/src/agent-src/templates/scripts/work_engine/directives/backend/memory.ts +193 -0
  52. package/src/agent-src/templates/scripts/work_engine/directives/backend/plan.ts +267 -0
  53. package/src/agent-src/templates/scripts/work_engine/directives/backend/refine.ts +518 -0
  54. package/src/agent-src/templates/scripts/work_engine/directives/backend/report.ts +379 -0
  55. package/src/agent-src/templates/scripts/work_engine/directives/backend/test.ts +268 -0
  56. package/src/agent-src/templates/scripts/work_engine/directives/backend/verify.ts +258 -0
  57. package/src/agent-src/templates/scripts/work_engine/directives/index.ts +32 -0
  58. package/src/agent-src/templates/scripts/work_engine/directives/mixed/contract.ts +243 -0
  59. package/src/agent-src/templates/scripts/work_engine/directives/mixed/index.ts +108 -0
  60. package/src/agent-src/templates/scripts/work_engine/directives/mixed/stitch.ts +259 -0
  61. package/src/agent-src/templates/scripts/work_engine/directives/mixed/ui.ts +216 -0
  62. package/src/agent-src/templates/scripts/work_engine/directives/ui/_passthrough.ts +40 -0
  63. package/src/agent-src/templates/scripts/work_engine/directives/ui/app_spec.ts +241 -0
  64. package/src/agent-src/templates/scripts/work_engine/directives/ui/apply.ts +216 -0
  65. package/src/agent-src/templates/scripts/work_engine/directives/ui/audit.ts +506 -0
  66. package/src/agent-src/templates/scripts/work_engine/directives/ui/design.ts +325 -0
  67. package/src/agent-src/templates/scripts/work_engine/directives/ui/index.ts +102 -0
  68. package/src/agent-src/templates/scripts/work_engine/directives/ui/polish.ts +462 -0
  69. package/src/agent-src/templates/scripts/work_engine/directives/ui/review.ts +474 -0
  70. package/src/agent-src/templates/scripts/work_engine/directives/ui/scaffold.ts +352 -0
  71. package/src/agent-src/templates/scripts/work_engine/directives/ui_trivial/_skipped.ts +33 -0
  72. package/src/agent-src/templates/scripts/work_engine/directives/ui_trivial/apply.ts +213 -0
  73. package/src/agent-src/templates/scripts/work_engine/directives/ui_trivial/index.ts +111 -0
  74. package/src/agent-src/templates/scripts/work_engine/directives/ui_trivial/refine.ts +126 -0
  75. package/src/agent-src/templates/scripts/work_engine/directives/ui_trivial/report.ts +112 -0
  76. package/src/agent-src/templates/scripts/work_engine/directives/ui_trivial/test.ts +164 -0
  77. package/src/agent-src/templates/scripts/work_engine/dispatcher.ts +515 -0
  78. package/src/agent-src/templates/scripts/work_engine/emitters.ts +119 -0
  79. package/src/agent-src/templates/scripts/work_engine/errors.ts +24 -0
  80. package/src/agent-src/templates/scripts/work_engine/hook_bootstrap.ts +104 -0
  81. package/src/agent-src/templates/scripts/work_engine/hooks/builtin/_chat_history_base.ts +189 -0
  82. package/src/agent-src/templates/scripts/work_engine/hooks/builtin/chat_history_append.ts +41 -0
  83. package/src/agent-src/templates/scripts/work_engine/hooks/builtin/chat_history_halt_append.ts +89 -0
  84. package/src/agent-src/templates/scripts/work_engine/hooks/builtin/decision_gate.ts +193 -0
  85. package/src/agent-src/templates/scripts/work_engine/hooks/builtin/decision_trace.ts +304 -0
  86. package/src/agent-src/templates/scripts/work_engine/hooks/builtin/directive_set_guard.ts +110 -0
  87. package/src/agent-src/templates/scripts/work_engine/hooks/builtin/halt_surface_audit.ts +118 -0
  88. package/src/agent-src/templates/scripts/work_engine/hooks/builtin/index.ts +17 -0
  89. package/src/agent-src/templates/scripts/work_engine/hooks/builtin/memory_visibility.ts +161 -0
  90. package/src/agent-src/templates/scripts/work_engine/hooks/builtin/state_shape_validation.ts +45 -0
  91. package/src/agent-src/templates/scripts/work_engine/hooks/builtin/trace.ts +134 -0
  92. package/src/agent-src/templates/scripts/work_engine/hooks/context.ts +94 -0
  93. package/src/agent-src/templates/scripts/work_engine/hooks/events.ts +58 -0
  94. package/src/agent-src/templates/scripts/work_engine/hooks/exceptions.ts +85 -0
  95. package/src/agent-src/templates/scripts/work_engine/hooks/index.ts +27 -0
  96. package/src/agent-src/templates/scripts/work_engine/hooks/registry.ts +66 -0
  97. package/src/agent-src/templates/scripts/work_engine/hooks/runner.ts +90 -0
  98. package/src/agent-src/templates/scripts/work_engine/hooks/settings.ts +260 -0
  99. package/src/agent-src/templates/scripts/work_engine/input_builders.ts +260 -0
  100. package/src/agent-src/templates/scripts/work_engine/intent/classify.ts +466 -0
  101. package/src/agent-src/templates/scripts/work_engine/migration/v0_to_v1.ts +531 -0
  102. package/src/agent-src/templates/scripts/work_engine/orchestration.ts +366 -0
  103. package/src/agent-src/templates/scripts/work_engine/persona_policy.ts +97 -0
  104. package/src/agent-src/templates/scripts/work_engine/resolvers/diff.ts +135 -0
  105. package/src/agent-src/templates/scripts/work_engine/resolvers/file.ts +175 -0
  106. package/src/agent-src/templates/scripts/work_engine/resolvers/prompt.ts +115 -0
  107. package/src/agent-src/templates/scripts/work_engine/scoring/confidence.ts +415 -0
  108. package/src/agent-src/templates/scripts/work_engine/scoring/decision_engine.ts +466 -0
  109. package/src/agent-src/templates/scripts/work_engine/scoring/decision_trace.ts +298 -0
  110. package/src/agent-src/templates/scripts/work_engine/scoring/memory_visibility.ts +444 -0
  111. package/src/agent-src/templates/scripts/work_engine/stack/detect.ts +252 -0
  112. package/src/agent-src/templates/scripts/work_engine/stack/runner.ts +745 -0
  113. package/src/agent-src/templates/scripts/work_engine/state.ts +1151 -0
  114. package/src/agent-src/templates/scripts/work_engine/state_io.ts +413 -0
  115. package/src/install/atomic.ts +111 -0
  116. package/src/install/conflict.ts +226 -0
  117. package/src/install/detect.ts +280 -0
  118. package/src/install/paths.ts +90 -0
  119. package/src/install/plan.ts +205 -0
  120. package/src/install/preflight.ts +210 -0
  121. package/src/install/selectedTools.ts +52 -0
  122. package/src/install/toolDetection.ts +120 -0
  123. package/src/install/txlog.ts +161 -0
  124. package/src/install/types.ts +175 -0
  125. package/src/install/wizard-plan.ts +216 -0
  126. package/src/scripts/prepack-check.mjs +108 -5
@@ -0,0 +1,325 @@
1
+ /**
2
+ * `design` step — produces the design brief that locks microcopy.
3
+ *
4
+ * TypeScript twin of `directives/ui/design.py` (ADR-200 py2ts). Public API
5
+ * names stay snake_case to mirror the Python module 1:1.
6
+ *
7
+ * The design step turns the audit findings into a structured design brief that
8
+ * `apply` consumes verbatim. The brief is the lock — apply writes the strings
9
+ * exactly as the brief specifies. Hallucinated microcopy at apply time is the
10
+ * failure mode this step exists to prevent.
11
+ */
12
+ import {
13
+ type Any,
14
+ type DeliveryState,
15
+ Outcome,
16
+ StepResult,
17
+ agent_directive,
18
+ } from '../../delivery_state.js';
19
+
20
+ /** Top-level keys every well-formed design brief must carry. */
21
+ export const REQUIRED_BRIEF_KEYS: ReadonlyArray<string> = [
22
+ 'layout',
23
+ 'components',
24
+ 'states',
25
+ 'microcopy',
26
+ 'a11y',
27
+ ];
28
+
29
+ /** States the brief must cover; missing entries surface as halt items. */
30
+ export const REQUIRED_STATE_KEYS: ReadonlyArray<string> = [
31
+ 'empty',
32
+ 'loading',
33
+ 'error',
34
+ 'success',
35
+ 'disabled',
36
+ ];
37
+
38
+ /** Lower-cased substrings that mark microcopy as unfinished. */
39
+ export const PLACEHOLDER_PATTERNS: ReadonlyArray<string> = [
40
+ '<placeholder>',
41
+ 'lorem',
42
+ 'todo:',
43
+ 'tbd',
44
+ 'xxx',
45
+ ];
46
+
47
+ export const AMBIGUITIES: ReadonlyArray<Record<string, string>> = [
48
+ {
49
+ code: 'design_missing',
50
+ trigger: 'state.ui_design is None or empty — brief has not been produced',
51
+ resolution:
52
+ 'agent directive `ui-design-brief` → skill/agent ' +
53
+ 'writes the brief into state.ui_design',
54
+ },
55
+ {
56
+ code: 'design_placeholders',
57
+ trigger:
58
+ 'microcopy contains placeholder patterns ' +
59
+ '(<placeholder>, Lorem, TODO:, TBD, XXX)',
60
+ resolution:
61
+ 'agent re-runs the brief with final strings; ' +
62
+ 'halt lists the offending microcopy keys',
63
+ },
64
+ {
65
+ code: 'design_unconfirmed',
66
+ trigger: 'brief is well-formed but design_confirmed is unset/False',
67
+ resolution:
68
+ 'user reviews the brief summary and sets ' +
69
+ 'state.ui_design.design_confirmed = True (or asks for ' +
70
+ 'revisions, which loops back to ui-design-brief)',
71
+ },
72
+ ];
73
+
74
+ function _isDict(value: Any): value is Record<string, Any> {
75
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
76
+ }
77
+
78
+ function _pyTruthy(value: Any): boolean {
79
+ if (value === null || value === undefined) return false;
80
+ if (typeof value === 'string') return value.length > 0;
81
+ if (typeof value === 'number') return value !== 0;
82
+ if (typeof value === 'boolean') return value;
83
+ if (Array.isArray(value)) return value.length > 0;
84
+ if (typeof value === 'object') return Object.keys(value).length > 0;
85
+ return true;
86
+ }
87
+
88
+ /** Python `value is None or value == "" or value == [] or value == {}`. */
89
+ function _isEmptyOrNone(value: Any): boolean {
90
+ if (value === null || value === undefined) return true;
91
+ if (value === '') return true;
92
+ if (Array.isArray(value)) return value.length === 0;
93
+ if (_isDict(value)) return Object.keys(value).length === 0;
94
+ return false;
95
+ }
96
+
97
+ function pyStr(value: Any): string {
98
+ if (value === null || value === undefined) return 'None';
99
+ if (value === true) return 'True';
100
+ if (value === false) return 'False';
101
+ return String(value);
102
+ }
103
+
104
+ function _pyRStrip(s: string): string {
105
+ return s.replace(/\s+$/u, '');
106
+ }
107
+
108
+ /** Apply the design-brief lock to `state.ui_design`. */
109
+ export function run(state: DeliveryState): StepResult {
110
+ const design = state.ui_design;
111
+ if (!_is_populated(design)) {
112
+ return _delegate_to_design_skill(state);
113
+ }
114
+
115
+ const designDict = design as Record<string, Any>;
116
+ const missing = _missing_required_keys(designDict);
117
+ if (missing.length > 0) {
118
+ return _halt_incomplete_brief(state, missing);
119
+ }
120
+
121
+ const placeholders = _placeholder_violations(designDict);
122
+ if (placeholders.length > 0) {
123
+ return _halt_placeholders(state, placeholders);
124
+ }
125
+
126
+ if (designDict['design_confirmed'] === true) {
127
+ return new StepResult({ outcome: Outcome.SUCCESS });
128
+ }
129
+
130
+ return _halt_unconfirmed(state, designDict);
131
+ }
132
+
133
+ /** True when `design` carries an actionable brief. */
134
+ function _is_populated(design: Any): boolean {
135
+ if (!_isDict(design)) return false;
136
+ if (Object.keys(design).length === 0) return false;
137
+ return REQUIRED_BRIEF_KEYS.some((key) => key in design);
138
+ }
139
+
140
+ /** Return required top-level keys that are missing or empty. */
141
+ function _missing_required_keys(design: Record<string, Any>): string[] {
142
+ const missing: string[] = [];
143
+ for (const key of REQUIRED_BRIEF_KEYS) {
144
+ const value = design[key];
145
+ if (_isEmptyOrNone(value)) {
146
+ missing.push(key);
147
+ continue;
148
+ }
149
+ if (key === 'states' && _isDict(value)) {
150
+ for (const state_key of REQUIRED_STATE_KEYS) {
151
+ if (!_pyTruthy(value[state_key])) {
152
+ missing.push(`states.${state_key}`);
153
+ }
154
+ }
155
+ }
156
+ }
157
+ return missing;
158
+ }
159
+
160
+ /** Return microcopy paths whose values match a placeholder pattern. */
161
+ function _placeholder_violations(design: Record<string, Any>): string[] {
162
+ const microcopy = design['microcopy'];
163
+ if (!_isDict(microcopy)) return [];
164
+ const violations: string[] = [];
165
+ _walk_microcopy(microcopy, '', violations);
166
+ return violations;
167
+ }
168
+
169
+ function _walk_microcopy(
170
+ node: Record<string, Any>,
171
+ prefix: string,
172
+ violations: string[],
173
+ ): void {
174
+ for (const key of Object.keys(node)) {
175
+ const value = node[key];
176
+ const path = prefix ? `${prefix}.${key}` : String(key);
177
+ if (_isDict(value)) {
178
+ _walk_microcopy(value, path, violations);
179
+ continue;
180
+ }
181
+ if (typeof value !== 'string') {
182
+ continue;
183
+ }
184
+ const lowered = value.toLowerCase();
185
+ for (const pattern of PLACEHOLDER_PATTERNS) {
186
+ if (lowered.includes(pattern)) {
187
+ violations.push(path);
188
+ break;
189
+ }
190
+ }
191
+ }
192
+ }
193
+
194
+ /** Render a one-line preview of the input being designed. */
195
+ function _preview_input(state: DeliveryState): string {
196
+ const data = (_isDict(state.ticket) ? state.ticket : {}) as Record<string, Any>;
197
+ const raw = data['raw'];
198
+ let text: string;
199
+ if (typeof raw === 'string' && raw.trim() !== '') {
200
+ text = raw.split(/\s+/u).filter((x) => x.length > 0).join(' ');
201
+ } else {
202
+ const title = data['title'];
203
+ if (typeof title === 'string') {
204
+ text = title;
205
+ } else {
206
+ const id = data['id'];
207
+ text = _pyTruthy(id) ? pyStr(id) : '(no title)';
208
+ }
209
+ }
210
+ if ([...text].length <= 80) {
211
+ return text;
212
+ }
213
+ return _pyRStrip([...text].slice(0, 79).join('')) + '…';
214
+ }
215
+
216
+ /** Halt with an agent directive so the orchestrator runs `ui-design-brief`. */
217
+ function _delegate_to_design_skill(state: DeliveryState): StepResult {
218
+ const preview = _preview_input(state);
219
+ return new StepResult({
220
+ outcome: Outcome.BLOCKED,
221
+ questions: [
222
+ agent_directive('ui-design-brief'),
223
+ `> Input: ${preview}`,
224
+ '> No design brief yet — producing one now. The brief locks ' +
225
+ 'layout, components, states, microcopy, and a11y before any ' +
226
+ 'code is written.',
227
+ '> 1. Continue — produce the brief from audit findings',
228
+ '> 2. Abort — drop this UI request',
229
+ ],
230
+ message: 'UI design brief missing; delegating to ui-design-brief skill.',
231
+ });
232
+ }
233
+
234
+ /** BLOCKED halt — brief is missing required keys. */
235
+ function _halt_incomplete_brief(state: DeliveryState, missing: string[]): StepResult {
236
+ const preview = _preview_input(state);
237
+ const lines: string[] = [
238
+ agent_directive('ui-design-brief'),
239
+ `> Input: ${preview}`,
240
+ '> Design brief is incomplete. Missing required fields:',
241
+ ];
242
+ for (const p of missing) {
243
+ lines.push(`> - \`${p}\``);
244
+ }
245
+ lines.push(
246
+ '> Re-run the brief skill so every required slot has a final ' +
247
+ 'value before apply.',
248
+ );
249
+ return new StepResult({
250
+ outcome: Outcome.BLOCKED,
251
+ questions: lines,
252
+ message: `UI design brief incomplete; ${missing.length} required field(s) missing.`,
253
+ });
254
+ }
255
+
256
+ /** BLOCKED halt — microcopy still carries placeholder patterns. */
257
+ function _halt_placeholders(state: DeliveryState, violations: string[]): StepResult {
258
+ const preview = _preview_input(state);
259
+ const lines: string[] = [
260
+ agent_directive('ui-design-brief'),
261
+ `> Input: ${preview}`,
262
+ '> Microcopy contains placeholder patterns. Apply rejects these ' +
263
+ 'verbatim, so they have to be replaced with final strings now:',
264
+ ];
265
+ for (const p of violations) {
266
+ lines.push(`> - \`microcopy.${p}\``);
267
+ }
268
+ lines.push(
269
+ '> Re-run the brief skill with finalised copy; the apply step ' +
270
+ 'will write strings exactly as the brief specifies.',
271
+ );
272
+ return new StepResult({
273
+ outcome: Outcome.BLOCKED,
274
+ questions: lines,
275
+ message:
276
+ `UI design brief carries ${violations.length} placeholder ` +
277
+ 'violation(s); halting for finalised microcopy.',
278
+ });
279
+ }
280
+
281
+ /** BLOCKED halt — brief is well-formed; user must sign off. */
282
+ function _halt_unconfirmed(state: DeliveryState, design: Record<string, Any>): StepResult {
283
+ const preview = _preview_input(state);
284
+ const components = _pyTruthy(design['components']) ? design['components'] : [];
285
+ const states = _pyTruthy(design['states']) ? design['states'] : {};
286
+ const microcopy = _pyTruthy(design['microcopy']) ? design['microcopy'] : {};
287
+
288
+ const component_count = Array.isArray(components) ? components.length : 0;
289
+ const state_count = _isDict(states) ? Object.keys(states).length : 0;
290
+ const microcopy_count = _isDict(microcopy) ? _count_microcopy(microcopy) : 0;
291
+
292
+ const lines: string[] = [
293
+ `> Input: ${preview}`,
294
+ '> Design brief is ready. Summary:',
295
+ `> - Components: ${component_count}`,
296
+ `> - States covered: ${state_count}`,
297
+ `> - Microcopy entries (locked): ${microcopy_count}`,
298
+ '> 1. Confirm — lock this brief and advance to apply',
299
+ '> 2. Revise — send feedback; loops back to ui-design-brief',
300
+ '> 3. Abort — drop this UI request',
301
+ '',
302
+ '**Recommendation: 1 — Confirm** — the brief covers all ' +
303
+ 'required slots and microcopy is final. Caveat: flip to 2 only if ' +
304
+ 'a string, state, or component is wrong; do not confirm strings ' +
305
+ 'you have not read.',
306
+ ];
307
+ return new StepResult({
308
+ outcome: Outcome.BLOCKED,
309
+ questions: lines,
310
+ message: 'UI design brief ready; halting for user confirmation before apply.',
311
+ });
312
+ }
313
+
314
+ /** Count leaf string entries in `microcopy` (recursive). */
315
+ function _count_microcopy(microcopy: Record<string, Any>): number {
316
+ let total = 0;
317
+ for (const value of Object.values(microcopy)) {
318
+ if (_isDict(value)) {
319
+ total += _count_microcopy(value);
320
+ } else if (typeof value === 'string') {
321
+ total += 1;
322
+ }
323
+ }
324
+ return total;
325
+ }
@@ -0,0 +1,102 @@
1
+ /**
2
+ * UI directive set — every slot wired to a working handler.
3
+ *
4
+ * TypeScript twin of `work_engine/directives/ui/__init__.py` (ADR-200 py2ts
5
+ * Phase 1 — work_engine TOP/integration layer). The `__init__.py` → `index.ts`
6
+ * mapping mirrors the hooks subpackage convention. Public API names stay
7
+ * snake_case to mirror the Python module 1:1 (per ADR-200).
8
+ *
9
+ * The eight-step shape mirrors `work_engine.directives.backend`:
10
+ *
11
+ * - `refine` → `audit` — existing-UI inventory + greenfield gate.
12
+ * - `memory` → `app_spec` — greenfield app-spec grounding gate.
13
+ * - `analyze` → `design` — produces the locked design brief.
14
+ * - `plan` → `scaffold` — greenfield Zero-to-One skeleton gate.
15
+ * - `implement` → `apply` — stack-dispatched render of the brief.
16
+ * - `test` → `review` — design-review pass produces findings.
17
+ * - `verify` → `polish` — bounded fix loop (≤ 2 rounds).
18
+ * - `report` → backend.report — shared delivery-Markdown renderer.
19
+ *
20
+ * The greenfield order is audit → app-spec → design → scaffold → apply →
21
+ * review → polish (Phases 2-4 council, Option A): `design` fixes the
22
+ * abstract visual language, `scaffold` maps it onto concrete structure.
23
+ */
24
+
25
+ import type { Step } from '../../delivery_state.js';
26
+ import { report } from '../backend/index.js';
27
+
28
+ import * as app_spec from './app_spec.js';
29
+ import * as apply from './apply.js';
30
+ import * as audit from './audit.js';
31
+ import * as design from './design.js';
32
+ import * as polish from './polish.js';
33
+ import * as review from './review.js';
34
+ import * as scaffold from './scaffold.js';
35
+
36
+ /** External name carried in `state.directive_set` for this set. */
37
+ export const DIRECTIVE_SET_NAME = 'ui';
38
+
39
+ /** Roadmap that promoted the deferral stub to fully wired handlers. */
40
+ export const ROADMAP = 'agents/roadmaps/road-to-product-ui-track.md';
41
+
42
+ /**
43
+ * Input kinds this directive set knows how to handle.
44
+ *
45
+ * Wires every UI-classifiable input shape (ticket prose, free-form prompt,
46
+ * `diff` / `file` improve-this-screen envelopes) through to this set.
47
+ */
48
+ export const SUPPORTED_KINDS: ReadonlyArray<string> = ['ticket', 'prompt', 'diff', 'file'];
49
+
50
+ /**
51
+ * Wire the eight-step dispatcher slots for the UI set.
52
+ *
53
+ * `refine` runs audit; `memory` runs the greenfield app-spec gate; `analyze`
54
+ * runs design; `plan` runs the greenfield scaffold gate; `implement` runs
55
+ * apply; `test` runs review; `verify` runs polish; `report` re-uses the shared
56
+ * backend renderer. The app-spec and scaffold gates are no-ops outside the
57
+ * greenfield-scaffold path. The mapping is rebuilt per call (cheap; the
58
+ * dispatcher invokes `get_steps` once per run).
59
+ */
60
+ function _build_step_map(): Map<string, Step> {
61
+ return new Map<string, Step>([
62
+ ['refine', audit.run],
63
+ ['memory', app_spec.run],
64
+ ['analyze', design.run],
65
+ ['plan', scaffold.run],
66
+ ['implement', apply.run],
67
+ ['test', review.run],
68
+ ['verify', polish.run],
69
+ ['report', report.run],
70
+ ]);
71
+ }
72
+
73
+ /**
74
+ * Return the `{step_name: handler}` mapping the dispatcher walks.
75
+ *
76
+ * Mirrors `work_engine.directives.backend.get_steps`.
77
+ */
78
+ export function get_steps(): Map<string, Step> {
79
+ return _build_step_map();
80
+ }
81
+
82
+ /**
83
+ * Per-step ambiguity declarations.
84
+ *
85
+ * Mirrors `work_engine.directives.backend.all_ambiguities`. Each handler
86
+ * re-exports its own `AMBIGUITIES` tuple so doc generators see a uniform shape
87
+ * across all eight steps. `report` borrows the backend renderer's surface.
88
+ */
89
+ export function all_ambiguities(): Record<string, ReadonlyArray<Record<string, string>>> {
90
+ return {
91
+ refine: audit.AMBIGUITIES,
92
+ memory: app_spec.AMBIGUITIES,
93
+ analyze: design.AMBIGUITIES,
94
+ plan: scaffold.AMBIGUITIES,
95
+ implement: apply.AMBIGUITIES,
96
+ test: review.AMBIGUITIES,
97
+ verify: polish.AMBIGUITIES,
98
+ report: report.AMBIGUITIES,
99
+ };
100
+ }
101
+
102
+ export { app_spec, apply, audit, design, polish, report, review, scaffold };