@genesislcap/ai-assistant 15.70.0 → 15.71.0-FUI-2650.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 (139) hide show
  1. package/dist/ai-assistant.api.json +97 -0
  2. package/dist/ai-assistant.d.ts +65 -0
  3. package/dist/chat-driver.cjs +18031 -0
  4. package/dist/chat-driver.cjs.map +4 -4
  5. package/dist/chat-driver.mjs +18024 -0
  6. package/dist/chat-driver.mjs.map +4 -4
  7. package/dist/custom-elements.json +9287 -6447
  8. package/dist/dts/chat-driver-node.d.ts +2 -0
  9. package/dist/dts/chat-driver-node.d.ts.map +1 -1
  10. package/dist/dts/code-review/code-review.types.d.ts +76 -0
  11. package/dist/dts/code-review/code-review.types.d.ts.map +1 -0
  12. package/dist/dts/code-review/code-reviewer.agent.d.ts +77 -0
  13. package/dist/dts/code-review/code-reviewer.agent.d.ts.map +1 -0
  14. package/dist/dts/code-review/code-reviewer.prompt.d.ts +23 -0
  15. package/dist/dts/code-review/code-reviewer.prompt.d.ts.map +1 -0
  16. package/dist/dts/code-review/gate.d.ts +44 -0
  17. package/dist/dts/code-review/gate.d.ts.map +1 -0
  18. package/dist/dts/code-review/index.d.ts +27 -0
  19. package/dist/dts/code-review/index.d.ts.map +1 -0
  20. package/dist/dts/code-review/review-changes.d.ts +70 -0
  21. package/dist/dts/code-review/review-changes.d.ts.map +1 -0
  22. package/dist/dts/code-review/rules/context-trigger-map.d.ts +6 -0
  23. package/dist/dts/code-review/rules/context-trigger-map.d.ts.map +1 -0
  24. package/dist/dts/code-review/rules/context.registry.d.ts +123 -0
  25. package/dist/dts/code-review/rules/context.registry.d.ts.map +1 -0
  26. package/dist/dts/code-review/rules/fui-ai-extensions.d.ts +13 -0
  27. package/dist/dts/code-review/rules/fui-ai-extensions.d.ts.map +1 -0
  28. package/dist/dts/code-review/rules/fui-blotter.d.ts +16 -0
  29. package/dist/dts/code-review/rules/fui-blotter.d.ts.map +1 -0
  30. package/dist/dts/code-review/rules/fui-chart.d.ts +20 -0
  31. package/dist/dts/code-review/rules/fui-chart.d.ts.map +1 -0
  32. package/dist/dts/code-review/rules/fui-column-defs.d.ts +21 -0
  33. package/dist/dts/code-review/rules/fui-column-defs.d.ts.map +1 -0
  34. package/dist/dts/code-review/rules/fui-components.d.ts +9 -0
  35. package/dist/dts/code-review/rules/fui-components.d.ts.map +1 -0
  36. package/dist/dts/code-review/rules/fui-criteria.d.ts +32 -0
  37. package/dist/dts/code-review/rules/fui-criteria.d.ts.map +1 -0
  38. package/dist/dts/code-review/rules/fui-custom-renderer.d.ts +15 -0
  39. package/dist/dts/code-review/rules/fui-custom-renderer.d.ts.map +1 -0
  40. package/dist/dts/code-review/rules/fui-dashboard.d.ts +19 -0
  41. package/dist/dts/code-review/rules/fui-dashboard.d.ts.map +1 -0
  42. package/dist/dts/code-review/rules/fui-dialogs.d.ts +19 -0
  43. package/dist/dts/code-review/rules/fui-dialogs.d.ts.map +1 -0
  44. package/dist/dts/code-review/rules/fui-entity-management.d.ts +19 -0
  45. package/dist/dts/code-review/rules/fui-entity-management.d.ts.map +1 -0
  46. package/dist/dts/code-review/rules/fui-error-boundary.d.ts +9 -0
  47. package/dist/dts/code-review/rules/fui-error-boundary.d.ts.map +1 -0
  48. package/dist/dts/code-review/rules/fui-eventing.d.ts +8 -0
  49. package/dist/dts/code-review/rules/fui-eventing.d.ts.map +1 -0
  50. package/dist/dts/code-review/rules/fui-flexlayout.d.ts +17 -0
  51. package/dist/dts/code-review/rules/fui-flexlayout.d.ts.map +1 -0
  52. package/dist/dts/code-review/rules/fui-flyout-panel.d.ts +10 -0
  53. package/dist/dts/code-review/rules/fui-flyout-panel.d.ts.map +1 -0
  54. package/dist/dts/code-review/rules/fui-form-component.d.ts +9 -0
  55. package/dist/dts/code-review/rules/fui-form-component.d.ts.map +1 -0
  56. package/dist/dts/code-review/rules/fui-formatters.d.ts +12 -0
  57. package/dist/dts/code-review/rules/fui-formatters.d.ts.map +1 -0
  58. package/dist/dts/code-review/rules/fui-foundation-comms.d.ts +10 -0
  59. package/dist/dts/code-review/rules/fui-foundation-comms.d.ts.map +1 -0
  60. package/dist/dts/code-review/rules/fui-global-filters.d.ts +33 -0
  61. package/dist/dts/code-review/rules/fui-global-filters.d.ts.map +1 -0
  62. package/dist/dts/code-review/rules/fui-import-surface.d.ts +37 -0
  63. package/dist/dts/code-review/rules/fui-import-surface.d.ts.map +1 -0
  64. package/dist/dts/code-review/rules/fui-inline-editing.d.ts +10 -0
  65. package/dist/dts/code-review/rules/fui-inline-editing.d.ts.map +1 -0
  66. package/dist/dts/code-review/rules/fui-layout.d.ts +7 -0
  67. package/dist/dts/code-review/rules/fui-layout.d.ts.map +1 -0
  68. package/dist/dts/code-review/rules/fui-notifications.d.ts +12 -0
  69. package/dist/dts/code-review/rules/fui-notifications.d.ts.map +1 -0
  70. package/dist/dts/code-review/rules/fui-primitives.d.ts +26 -0
  71. package/dist/dts/code-review/rules/fui-primitives.d.ts.map +1 -0
  72. package/dist/dts/code-review/rules/fui-rapid-grid-pro.d.ts +18 -0
  73. package/dist/dts/code-review/rules/fui-rapid-grid-pro.d.ts.map +1 -0
  74. package/dist/dts/code-review/rules/fui-redux-store.d.ts +8 -0
  75. package/dist/dts/code-review/rules/fui-redux-store.d.ts.map +1 -0
  76. package/dist/dts/code-review/rules/fui-reporting.d.ts +19 -0
  77. package/dist/dts/code-review/rules/fui-reporting.d.ts.map +1 -0
  78. package/dist/dts/code-review/rules/fui-styling.d.ts +15 -0
  79. package/dist/dts/code-review/rules/fui-styling.d.ts.map +1 -0
  80. package/dist/dts/code-review/rules/fui-trade-form.d.ts +13 -0
  81. package/dist/dts/code-review/rules/fui-trade-form.d.ts.map +1 -0
  82. package/dist/dts/code-review/submit-code-review.tool.d.ts +12 -0
  83. package/dist/dts/code-review/submit-code-review.tool.d.ts.map +1 -0
  84. package/dist/dts/code-review/unified-diff.d.ts +7 -0
  85. package/dist/dts/code-review/unified-diff.d.ts.map +1 -0
  86. package/dist/dts/code-review/verdict.d.ts +23 -0
  87. package/dist/dts/code-review/verdict.d.ts.map +1 -0
  88. package/dist/dts/components/code-review-result/code-review-result.d.ts +26 -0
  89. package/dist/dts/components/code-review-result/code-review-result.d.ts.map +1 -0
  90. package/dist/dts/index.d.ts +1 -0
  91. package/dist/dts/index.d.ts.map +1 -1
  92. package/dist/dts/react.d.ts +10 -0
  93. package/dist/esm/chat-driver-node.js +6 -0
  94. package/dist/esm/code-review/code-review.types.js +6 -0
  95. package/dist/esm/code-review/code-reviewer.agent.js +167 -0
  96. package/dist/esm/code-review/code-reviewer.prompt.js +103 -0
  97. package/dist/esm/code-review/gate.js +93 -0
  98. package/dist/esm/code-review/index.js +28 -0
  99. package/dist/esm/code-review/review-changes.js +123 -0
  100. package/dist/esm/code-review/rules/context-trigger-map.js +20 -0
  101. package/dist/esm/code-review/rules/context.registry.js +772 -0
  102. package/dist/esm/code-review/rules/fui-ai-extensions.js +306 -0
  103. package/dist/esm/code-review/rules/fui-blotter.js +596 -0
  104. package/dist/esm/code-review/rules/fui-chart.js +669 -0
  105. package/dist/esm/code-review/rules/fui-column-defs.js +862 -0
  106. package/dist/esm/code-review/rules/fui-components.js +245 -0
  107. package/dist/esm/code-review/rules/fui-criteria.js +538 -0
  108. package/dist/esm/code-review/rules/fui-custom-renderer.js +612 -0
  109. package/dist/esm/code-review/rules/fui-dashboard.js +604 -0
  110. package/dist/esm/code-review/rules/fui-dialogs.js +588 -0
  111. package/dist/esm/code-review/rules/fui-entity-management.js +1014 -0
  112. package/dist/esm/code-review/rules/fui-error-boundary.js +244 -0
  113. package/dist/esm/code-review/rules/fui-eventing.js +628 -0
  114. package/dist/esm/code-review/rules/fui-flexlayout.js +860 -0
  115. package/dist/esm/code-review/rules/fui-flyout-panel.js +432 -0
  116. package/dist/esm/code-review/rules/fui-form-component.js +898 -0
  117. package/dist/esm/code-review/rules/fui-formatters.js +415 -0
  118. package/dist/esm/code-review/rules/fui-foundation-comms.js +518 -0
  119. package/dist/esm/code-review/rules/fui-global-filters.js +778 -0
  120. package/dist/esm/code-review/rules/fui-import-surface.js +452 -0
  121. package/dist/esm/code-review/rules/fui-inline-editing.js +445 -0
  122. package/dist/esm/code-review/rules/fui-layout.js +431 -0
  123. package/dist/esm/code-review/rules/fui-notifications.js +439 -0
  124. package/dist/esm/code-review/rules/fui-primitives.js +1216 -0
  125. package/dist/esm/code-review/rules/fui-rapid-grid-pro.js +650 -0
  126. package/dist/esm/code-review/rules/fui-redux-store.js +522 -0
  127. package/dist/esm/code-review/rules/fui-reporting.js +506 -0
  128. package/dist/esm/code-review/rules/fui-styling.js +1229 -0
  129. package/dist/esm/code-review/rules/fui-trade-form.js +618 -0
  130. package/dist/esm/code-review/submit-code-review.tool.js +43 -0
  131. package/dist/esm/code-review/unified-diff.js +96 -0
  132. package/dist/esm/code-review/verdict.js +24 -0
  133. package/dist/esm/components/code-review-result/code-review-result.js +89 -0
  134. package/dist/esm/index.js +3 -0
  135. package/dist/react.cjs +7 -0
  136. package/dist/react.mjs +6 -0
  137. package/docs/code-review.md +137 -0
  138. package/package.json +24 -17
  139. package/scripts/smoke-chat-driver-node.mjs +15 -0
@@ -0,0 +1,26 @@
1
+ import { GenesisElement } from '@genesislcap/web-core';
2
+ import type { CodeReviewGateResult } from '../../code-review/code-review.types';
3
+ import { type CodeReviewSummary } from '../../code-review/verdict';
4
+ /**
5
+ * Displays one code-review verdict: the status (approved, blocking, advisory, skipped or
6
+ * unavailable), the files reviewed and the reviewer's feedback. Display only — it does not apply a
7
+ * fix; the host decides what a verdict means for its write path.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const el = document.createElement('ai-code-review-result') as AiCodeReviewResult;
12
+ * el.result = await runCodeReviewPreGate(files, requestSubAgent);
13
+ * el.files = files.map((f) => f.path);
14
+ * ```
15
+ *
16
+ * @beta
17
+ */
18
+ export declare class AiCodeReviewResult extends GenesisElement {
19
+ /** The gate result to show; `null` means the review was skipped. */
20
+ result: CodeReviewGateResult | null;
21
+ /** Paths of the files the review covered. */
22
+ files: string[];
23
+ /** @internal */
24
+ get summary(): CodeReviewSummary;
25
+ }
26
+ //# sourceMappingURL=code-review-result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-review-result.d.ts","sourceRoot":"","sources":["../../../../src/components/code-review-result/code-review-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAKf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAuB,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAExF;;;;;;;;;;;;;GAaG;AACH,qBA2Da,kBAAmB,SAAQ,cAAc;IACpD,oEAAoE;IACxD,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAAQ;IAEvD,6CAA6C;IACjC,KAAK,EAAE,MAAM,EAAE,CAAM;IAEjC,gBAAgB;IAChB,IAAI,OAAO,IAAI,iBAAiB,CAE/B;CACF"}
@@ -36,5 +36,6 @@ export type { HandlerCapabilityFactory, HandlerCapabilityScope } from './types/h
36
36
  export type { DecisionAnswer, DecisionOption, DecisionSpec, InteractionSurface, InvokeResult, SurfaceAction, SurfaceActionSpec, SurfaceSpec, } from './types/interaction-surface';
37
37
  export { getInteractionRegistration, registerInteraction, type InteractionControllerFactory, type InteractionRegistration, } from './state/interaction-registry';
38
38
  export { AiChatMarkdown, MARKDOWN_EXPORTPARTS } from './components/chat-markdown/chat-markdown';
39
+ export { AiCodeReviewResult } from './components/code-review-result/code-review-result';
39
40
  export type { GenesisChangeRequest, GenesisReviewPayload, GenesisWriteReviewCompletedEventDetail, } from './genesis/review-payload';
40
41
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc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AW,GACZ,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,GAC7B,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAGhG,OAAO,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AAIxF,YAAY,EACV,oBAAoB,EACpB,oBAAoB,EACpB,sCAAsC,GACvC,MAAM,0BAA0B,CAAC"}
@@ -10,6 +10,7 @@ import type { AgentPicker as AgentPickerWC } from './components/agent-picker/age
10
10
  import type { AiChatBubble as AiChatBubbleWC } from './components/chat-bubble/chat-bubble';
11
11
  import type { AiChatInteractionWrapper as AiChatInteractionWrapperWC } from './components/chat-interaction-wrapper/chat-interaction-wrapper';
12
12
  import type { AiChatMarkdown as AiChatMarkdownWC } from './components/chat-markdown/chat-markdown';
13
+ import type { AiCodeReviewResult as AiCodeReviewResultWC } from './components/code-review-result/code-review-result';
13
14
  import type { AiFlowingWavesIndicator as AiFlowingWavesIndicatorWC } from './components/flowing-waves-indicator';
14
15
  import type { AiHaloOverlay as AiHaloOverlayWC } from './components/halo-overlay';
15
16
  import type { MessageFeedback as MessageFeedbackWC } from './components/message-feedback/message-feedback';
@@ -165,6 +166,15 @@ export declare const AiChatMarkdown: React.ForwardRefExoticComponent<
165
166
  >;
166
167
  export type AiChatMarkdownRef = AiChatMarkdownWC;
167
168
 
169
+ export declare const AiCodeReviewResult: React.ForwardRefExoticComponent<
170
+ React.PropsWithChildren<
171
+ Omit<PublicOf<AiCodeReviewResultWC>, 'children' | 'style'> &
172
+ HTMLWCProps & {
173
+ }
174
+ > & React.RefAttributes<AiCodeReviewResultWC>
175
+ >;
176
+ export type AiCodeReviewResultRef = AiCodeReviewResultWC;
177
+
168
178
  export declare const MessageFeedback: React.ForwardRefExoticComponent<
169
179
  React.PropsWithChildren<
170
180
  Omit<PublicOf<MessageFeedbackWC>, 'children' | 'style'> &
@@ -113,3 +113,9 @@ export { buildTimelineEntries } from './state/persistence/build-timeline-entries
113
113
  // and cost figures are as old as that. Pass a fresh snapshot of your own through this before
114
114
  // `assembleDebugLog`, or state in your own output that the totals are historical.
115
115
  export { assembleDebugLog, withFreshMetaSnapshot } from './state/persistence/diagnostics';
116
+ // The UI Code Reviewer (FUI-2650), for Node hosts such as a CI job reviewing a patch. Bundled
117
+ // here rather than as its own Node artifact so `createHeadlessSubAgentCaller` drives the SAME
118
+ // ChatDriver / foundation-ai instance as the providers built from this entry (see the provider
119
+ // note above on `instanceof`). Named, like everything else here; its closure is the rule-pack
120
+ // strings plus the driver, so it stays DOM-clean (smoke-chat-driver-node.mjs checks).
121
+ export { CODE_REVIEWER_AGENT_NAME, createCodeReviewAgent, createHeadlessSubAgentCaller, isGenesisWebFile, parseUnifiedDiff, reviewChanges, summarizeCodeReview, } from './code-review';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The name the code reviewer registers under. Hosts call it through
3
+ * `requestSubAgent(CODE_REVIEWER_AGENT_NAME, …)`; {@link runCodeReviewPreGate} does.
4
+ * @beta
5
+ */
6
+ export const CODE_REVIEWER_AGENT_NAME = 'UI Code Reviewer';
@@ -0,0 +1,167 @@
1
+ import { __awaiter } from "tslib";
2
+ import { logger } from '../utils/logger';
3
+ import { CODE_REVIEWER_AGENT_NAME } from './code-review.types';
4
+ import { buildCodeReviewerPrompt } from './code-reviewer.prompt';
5
+ import { createContextToolDefinitions, createContextToolHandlers, } from './rules/context.registry';
6
+ import { submitCodeReviewHandler, submitCodeReviewToolDefinition } from './submit-code-review.tool';
7
+ const FILE_TOOL_NAMES = ['vfs_read', 'vfs_list'];
8
+ // ── Tool-call budget (GENC-1358) ──────────────────────────────────────────────
9
+ // The reviewer has five read/explore tools and only one terminal tool
10
+ // (submit_code_review), and sub-agent turns default tool_choice to 'required' — so
11
+ // a model that keeps choosing reads can never end the turn on its own. One run
12
+ // crawled 38 distinct files over ~46 tool calls reviewing a single trivial slice,
13
+ // never submitted, and hit the framework's DEFAULT_MAX_TOOL_ITERATIONS (50). That
14
+ // fails the sub-agent with `max_iterations` — which fails open to "approved", but
15
+ // only after burning ~2.5 min of High-tier calls and leaving no verdict. "Normal
16
+ // reviews finish in 4–11 turns" was the GENC-1358 design premise; MEASURED live
17
+ // since (GENC-1560 buildout scenario) that premise does not hold for a real
18
+ // multi-file generating step — reviews routinely ran 22–26 turns, right up
19
+ // against FORCE_AT, not the rare backstop case it was sized for. We warn as the
20
+ // budget runs down, then force submit_code_review well short of the framework
21
+ // cap so a runaway terminates with a real verdict cheaply. FORCE_AT is
22
+ // deliberately generous (>2x the ORIGINAL observed legitimate max) to leave
23
+ // headroom for genuinely interconnected changes. Moved unchanged from genesis-create
24
+ // (FUI-2650) — retune only against a new measurement.
25
+ /** @internal */
26
+ export const FORCE_AT = 25;
27
+ /** @internal */
28
+ export const WARN_FROM = 18;
29
+ // A SEPARATE, earlier nudge (GENC-1560) — not a budget countdown, a batching
30
+ // reminder. The turn-count blowup above traces to the model reading one file or
31
+ // one context module per turn despite the prompt's own worked example of a
32
+ // parallel batch (34 tools over 26 turns ⇒ ~1.3 tools/turn, near strictly
33
+ // sequential). WARN_FROM=18 fires far too late to change that pattern — by turn
34
+ // 18 the sequential habit for THIS review is already set. This fires while there
35
+ // is still time for the review to recover into 1-2 genuine parallel batches.
36
+ /** @internal */
37
+ export const BATCHING_REMINDER_FROM = 6;
38
+ /**
39
+ * Escalating budget warning, delivered via tailContext (its own framed
40
+ * `<system-reminder>` block, hence no leading separator).
41
+ */
42
+ function budgetWarning(turnIndex) {
43
+ const remaining = FORCE_AT - turnIndex;
44
+ return (`⚠️ TOOL-CALL BUDGET: you have made ${turnIndex} tool calls. You MUST call ` +
45
+ `submit_code_review within ${remaining} more — after that it is forced ` +
46
+ `automatically. Submit your verdict NOW, based on the issues you have ALREADY ` +
47
+ `identified in the supplied files. Stop reading further files, and do not ` +
48
+ `invent a blocking issue to justify more investigation.`);
49
+ }
50
+ /** Earlier, non-countdown nudge — see BATCHING_REMINDER_FROM. */
51
+ function batchingReminder(turnIndex) {
52
+ return (`⚠️ ${turnIndex} turns in and still going: if each turn so far made only ONE tool call, ` +
53
+ `stop — that is the sequential pattern Step 1 asks you to avoid. Decide everything you ` +
54
+ `still need (remaining files, remaining context modules) and emit ALL of those calls ` +
55
+ `together in your NEXT reply, then submit. If you are already batching and there is ` +
56
+ `genuinely more to check, continue — this is a reminder, not a limit.`);
57
+ }
58
+ /**
59
+ * Per-turn nudge text, delivered via `tailContext` — NOT concatenated onto `systemPrompt`.
60
+ * Both nudge strings interpolate the live turn number, so a system prompt carrying them changes
61
+ * on EVERY turn from BATCHING_REMINDER_FROM onward — and 'history' scope's cache breakpoint
62
+ * chain starts at the system block, so that defeats the cache to the end of the review.
63
+ * MEASURED in genesis-create (GENC-1560): 82% of one generating step's cost.
64
+ */
65
+ function reviewerTailContext(ctx) {
66
+ if (ctx.turnIndex >= WARN_FROM)
67
+ return budgetWarning(ctx.turnIndex);
68
+ if (ctx.turnIndex >= BATCHING_REMINDER_FROM)
69
+ return batchingReminder(ctx.turnIndex);
70
+ return '';
71
+ }
72
+ /** Mirrors the sub-agent default ('required') until FORCE_AT, then forces the verdict. */
73
+ function reviewerToolChoice(ctx) {
74
+ if (ctx.turnIndex >= FORCE_AT) {
75
+ // Log once at the force point (the forced submit ends the loop). Surfaces an
76
+ // otherwise-silent runaway — the fail-open path swallowed these completely.
77
+ if (ctx.turnIndex === FORCE_AT) {
78
+ logger.warn(`Code reviewer reached the tool-call budget (${FORCE_AT}) without submitting — forcing submit_code_review.`);
79
+ }
80
+ return { tool: 'submit_code_review' };
81
+ }
82
+ return 'required';
83
+ }
84
+ const isFileTools = (files) => 'definitions' in files && 'handlers' in files;
85
+ /** Generic `vfs_read` / `vfs_list` over a {@link CodeReviewFileReader}. */
86
+ function fileReaderTools(reader) {
87
+ return {
88
+ definitions: [
89
+ {
90
+ name: 'vfs_list',
91
+ description: 'List every file path you may read. Use an exact path from this list with vfs_read.',
92
+ parameters: { type: 'object', properties: {} },
93
+ },
94
+ {
95
+ name: 'vfs_read',
96
+ description: 'Read the full content of a file, as it stands with the change under review applied.',
97
+ parameters: {
98
+ type: 'object',
99
+ required: ['path'],
100
+ properties: {
101
+ path: { type: 'string', description: 'Exact path from vfs_list.' },
102
+ },
103
+ },
104
+ },
105
+ ],
106
+ handlers: {
107
+ vfs_list: () => __awaiter(this, void 0, void 0, function* () { return ({ files: yield reader.list() }); }),
108
+ vfs_read: (args) => __awaiter(this, void 0, void 0, function* () {
109
+ const { path } = args;
110
+ const content = yield reader.read(path);
111
+ if (content === undefined) {
112
+ return { error: `File not found: '${path}'. Call vfs_list to see readable paths.` };
113
+ }
114
+ return { path, content };
115
+ }),
116
+ },
117
+ };
118
+ }
119
+ /** Keeps only `vfs_read` / `vfs_list` — the reviewer must never hold a write tool. */
120
+ function readOnlyFileTools(tools) {
121
+ const allowed = (name) => FILE_TOOL_NAMES.includes(name);
122
+ return {
123
+ definitions: tools.definitions.filter((t) => allowed(t.name)),
124
+ handlers: Object.fromEntries(Object.entries(tools.handlers).filter(([k]) => allowed(k))),
125
+ };
126
+ }
127
+ /**
128
+ * Creates the UI Code Reviewer: a read-only sub-agent that reviews changed web files for Genesis
129
+ * UI pattern compliance and semantic correctness, and submits exactly one verdict through
130
+ * `submit_code_review`. Register it in a parent agent's `subAgents` and call it with
131
+ * {@link runCodeReviewPreGate}.
132
+ *
133
+ * The tool budget, `tailContext` nudges, `history` cache scope and the read-only tool set are
134
+ * fixed here so every host gets the same cost behaviour.
135
+ * @beta
136
+ */
137
+ export function createCodeReviewAgent(options) {
138
+ var _a, _b, _c;
139
+ const files = readOnlyFileTools(isFileTools(options.files) ? options.files : fileReaderTools(options.files));
140
+ const extraRules = (_a = options.extraRules) !== null && _a !== void 0 ? _a : [];
141
+ const grounding = options.grounding;
142
+ return Object.assign(Object.assign({ name: CODE_REVIEWER_AGENT_NAME, description: (_b = options.description) !== null && _b !== void 0 ? _b : 'Reviews changed web files for Genesis UI pattern compliance before they are written.' }, (options.provider !== undefined ? { provider: options.provider } : {})), { thinkingPolicy: (_c = options.thinkingPolicy) !== null && _c !== void 0 ? _c : 'off',
143
+ // Byte-stable: the turn-count nudges are delivered per turn via tailContext (below), NOT
144
+ // concatenated here, so the prompt never churns mid-review — see reviewerTailContext.
145
+ systemPrompt: buildCodeReviewerPrompt({
146
+ triggerTable: options.triggerTable,
147
+ grounding: grounding !== undefined,
148
+ }),
149
+ // 'history', not 'prompt' (GENC-1560). 'prompt' caches ONLY the tools+system prefix, so every
150
+ // tool result the reviewer has already read is resent uncached on every later turn of the
151
+ // SAME review. MEASURED in genesis-create: reviews routinely ran 22–26 turns, and ten such
152
+ // reviews cost $51 of a $73 scenario run under 'prompt'. 'history' caches the growing
153
+ // conversation itself. No-op on Gemini (implicit caching). Depends on systemPrompt staying
154
+ // byte-stable turn to turn.
155
+ cachePolicy: { scope: 'history' },
156
+ // Resolved every turn, but injected outside the cached prefix — '' (the common case, before
157
+ // turn 6) is dropped. Raw content; foundation-ai frames it in a <system-reminder>.
158
+ tailContext: reviewerTailContext,
159
+ // Bounds the read/explore loop: force the verdict before the framework's
160
+ // max-iterations cap turns a runaway into a silent, expensive fail-open.
161
+ toolChoice: reviewerToolChoice, toolDefinitions: [
162
+ ...files.definitions,
163
+ ...createContextToolDefinitions(extraRules),
164
+ ...(grounding ? [grounding.definition] : []),
165
+ submitCodeReviewToolDefinition,
166
+ ], toolHandlers: Object.assign(Object.assign(Object.assign(Object.assign({}, files.handlers), createContextToolHandlers(extraRules)), (grounding ? { [grounding.definition.name]: grounding.handler } : {})), { submit_code_review: submitCodeReviewHandler }) });
167
+ }
@@ -0,0 +1,103 @@
1
+ import { CONTEXT_TRIGGER_TABLE } from './rules/context-trigger-map';
2
+ /**
3
+ * The reviewer's tool names in the order the prompt lists them. `query_project_schema` is listed
4
+ * only when the host registers it — the prompt must never name a tool the host did not wire.
5
+ */
6
+ export const CODE_REVIEWER_BASE_TOOL_NAMES = [
7
+ 'vfs_read',
8
+ 'vfs_list',
9
+ 'search_context',
10
+ 'read_contextIndex',
11
+ 'read_context',
12
+ ];
13
+ /**
14
+ * The reviewer's system prompt (moved from genesis-create, text unchanged — FUI-2650). Byte-stable
15
+ * for a given host: turn-count nudges go in `tailContext`, never here, or the `history` cache
16
+ * breaks on every turn (GENC-1560).
17
+ * @beta
18
+ */
19
+ export function buildCodeReviewerPrompt(options = {}) {
20
+ var _a;
21
+ const triggerTable = (_a = options.triggerTable) !== null && _a !== void 0 ? _a : CONTEXT_TRIGGER_TABLE;
22
+ const toolNames = [
23
+ ...CODE_REVIEWER_BASE_TOOL_NAMES,
24
+ ...(options.grounding ? ['query_project_schema'] : []),
25
+ 'submit_code_review',
26
+ ];
27
+ return `You are an automated code reviewer for Genesis React/TypeScript applications.
28
+
29
+ You receive a set of changed files immediately before they are written to disk. Your job: catch semantic issues that TypeScript and Vite cannot verify. You do NOT generate or fix code — you read, evaluate, and submit exactly one verdict.
30
+
31
+ **TypeScript type errors and Vite build errors have already been checked by automated tooling.** Do NOT re-check TypeScript correctness. Your job is semantic and pattern compliance only.
32
+
33
+ **Your tool set is exactly: ${toolNames.join(', ')}.**
34
+ Calling vfs_edit, vfs_write, or any other tool will fail immediately.
35
+
36
+ ---
37
+
38
+ ## Step 1 — Locate the files
39
+
40
+ **READ EVERYTHING YOU NEED IN ONE PARALLEL BATCH — never one call per reply.** MEASURED (GENC-1560 buildout scenario): reviews of a real multi-file change routinely ran 22–26 separate turns, most of them a single \`vfs_read\` or \`read_context\` call each — the SAME total reads would have taken 2–3 turns done as parallel batches. Every extra sequential turn resends this review's own growing history in full; batching is not a style preference, it directly controls how much this review costs. Decide up front what you need — the supplied files' related imports, AND every context module the trigger table below matches — and emit ALL of those tool calls together, in ONE reply:
41
+
42
+ \`\`\`
43
+ // One reply, multiple tool calls — not four separate turns:
44
+ read_context({ name: "fui-column-defs" })
45
+ read_context({ name: "fui-styling" })
46
+ vfs_read({ path: "MainTrading/AxesGrid/AxesGridOptions.ts" })
47
+ vfs_read({ path: "MainTrading/AxesGrid/AxesTypes.ts" })
48
+ \`\`\`
49
+
50
+ Two batches is normal for a large change (e.g. \`read_contextIndex\` + initial reads, then a second batch once you know what else you need); a THIRD round of individual single-tool-call turns is the failure mode this section exists to prevent.
51
+
52
+ The files to review are in your context message under the \`files\` array. A NEW file arrives as \`{ path, content }\` (full content); an EDITED file arrives as \`{ path, diff }\` — a unified diff of this change only (\`-\` removed, \`+\` added, other lines unchanged context). Planned files additionally carry \`purpose\` and \`acceptanceChecks\` from the architecture plan.
53
+ **Do NOT call vfs_read for a path supplied with \`content\`** — use the supplied content directly. For a \`diff\` entry, the CHANGE is the subject of your review: judge the added/changed lines, and do NOT flag pre-existing code that merely appears as diff context — it is not part of this change. You MAY vfs_read a diff entry's own path when surrounding code is genuinely needed to judge the change (the read returns the post-edit content) — but decide THAT up front too, and batch it with everything else, rather than reading one diff file, deciding you need another, and reading that next turn.
54
+
55
+ You MAY read OTHER VFS files, but only ones **directly relevant** to reviewing the supplied files. A file is directly relevant only if a supplied file imports from it, or it imports from a supplied file, AND you need to confirm a specific symbol or type. Do NOT read a file merely because it belongs to the same page or feature, and do NOT survey the project. When in doubt, submit your verdict: over-reading is itself a failure mode.
56
+
57
+ ## Step 2 — Identify and load relevant contexts (run in parallel)
58
+
59
+ 1. Call read_contextIndex() to get the full module catalog.
60
+ 2. Inspect the imports, component names, and patterns in the provided files.
61
+ 3. In one parallel batch, call read_context(name) for every relevant module.
62
+
63
+ Context trigger map — load the matching module if any of these signals appear in the provided files:
64
+
65
+ ${triggerTable}
66
+
67
+ ## Step 3 — Evaluate against loaded context rules
68
+
69
+ For each loaded context, check only the rules and anti-patterns it explicitly documents. Do NOT invent new rules or apply personal style preferences.
70
+
71
+ Additionally, check these universal issues regardless of which contexts were loaded:
72
+
73
+ **BLOCKING — must be fixed before the changes apply (a runtime/build break, or a hard Genesis convention):**
74
+ - JSX syntax (\`<ComponentName />\`, \`<div>\`, JSX expressions) written inside a \`.ts\` file (non-component files like column defs, store slices, and utilities must be \`.ts\`)
75
+ - React hooks (\`useState\`, \`useEffect\`, \`useRef\`, \`useCallback\`, \`useMemo\`) called after a conditional \`return\` statement — violates React rules of hooks
76
+ - Explicit \`any\` type annotation on a variable, function parameter, return type, or generic
77
+ - **Raw HTML form/interactive controls where a design-system component exists** — \`<input>\` / \`<select>\` / \`<textarea>\` / \`<button>\` used instead of \`TextField\` / \`NumberField\` / \`Select\` + \`ListboxOption\` / \`TextArea\` / \`Button\` from \`@genesislcap/rapid-design-system/react\`. Genesis components give design tokens, theming, and consistent behaviour; raw HTML controls skip all of it. A frequent tell: a design-system form component is imported but the field is rendered as raw HTML (which also leaves the import unused). Scope it tightly: layout/semantic elements (\`<div>\`, \`<span>\`, etc.) are fine, and a \`<table>\` is fine for a FIXED non-interactive matrix (a price ladder, a key/value summary) though a scrolling/sortable DATASET belongs in RapidGridPro, and a native control genuinely required with NO Genesis equivalent (e.g. a file input) is not a violation — do not flag those. But do NOT narrow this to form fields: an interactive \`<button>\` is in scope WHEREVER it appears — inside an ag-Grid cell renderer, in a toolbar strip, inside a hand-built modal — because \`Button\` always exists and a native one is unthemed everywhere. A whole renderer component returning \`<button style={{…}}>\` is the same violation as an inline one; the extra file does not make it a different thing. **Separately: a hand-built toolbar div or strip rendered directly above or beside an \`<EntityManagement>\` grid is itself the anti-pattern, themed button or not** — grid-level actions belong on the grid via \`customActions\` (\`{ name, action, position: CrudMenuPosition.Top, requiresSelection? }\`), not in a sibling container. Flag the container as the primary issue there, not just an unthemed button inside it. This is ADVISORY, not blocking — a hand-rolled strip beside a RapidGridPro grid, a page-level filter row, or an \`onRenderTabSet\` action is legitimate. This exact case shipped and passed review, because an earlier version of this line ended "flag only a form field".
78
+
79
+ **ADVISORY — non-blocking, worth flagging:**
80
+ - TODO / stub / placeholder code — NOT only comments. The comment forms (\`// TODO: implement\`, empty function bodies, \`throw new Error('not implemented')\`) are the easy ones. The form that actually ships is a handler that RUNS and does the wrong thing: \`onClick={() => alert('+ New RFQ placeholder clicked!')}\`, \`onClick={() => console.log('todo')}\`, a submit that only closes the dialog. This passed review on every step of a benchmark run because the checklist said "comments". Treat any \`alert()\`/\`console.log()\` standing in for a real interaction as a stub — but do NOT flag \`alert()\` used as genuine post-submit success/error feedback next to a real \`commitGenesisEvent\`; that is crude, not missing.
81
+ - Hardcoded enum or status strings in UI that the server schema defines (should be fetched or imported from a typed constant)
82
+
83
+ **PLAN ACCEPTANCE CHECKS — verify when supplied:** a file entry may carry its plan spec: \`purpose\` (what the file is for) and \`acceptanceChecks\` (the planner's concrete "done" criteria for that file). Verify each acceptance check against the supplied content or diff (vfs_read the file's own path when the diff alone cannot confirm a check). Report every unmet check as an issue, quoting the failed check — blocking when required behaviour is missing or wrong, advisory when the shortfall is cosmetic or partial. A check you cannot verify from the code alone (e.g. it needs the running app) is NOT an issue — skip it. Files without these fields have no plan spec; review them against the loaded context rules only.
84
+
85
+ ## Step 4 — Call submit_code_review exactly once
86
+
87
+ **Only report an issue you are CONFIRMING is a real violation.** Decide each candidate issue BEFORE you write it: if, on inspection, the code is actually correct (it follows the rule, the cast is necessary, the pattern is the documented one), do NOT list it. NEVER emit a \`[BLOCKING]\` (or advisory) issue whose own explanation concludes the code is fine ("…however this is correct", "…this is fine per <rule>") — that wastes a whole fix cycle making the primary agent "fix" working code. A blocking verdict must contain only issues that genuinely block. If you are unsure whether something is a violation, leave it out.
88
+
89
+ Submit as soon as you have evaluated the supplied files against the loaded contexts — do not keep exploring for more files to read. Once you have your verdict:
90
+
91
+ \`\`\`
92
+ // All clear:
93
+ submit_code_review({ approved: true })
94
+
95
+ // Advisory issues only (changes proceed, feedback attached):
96
+ submit_code_review({ approved: false, severity: "advisory", feedback: "<numbered list>" })
97
+
98
+ // Any blocking issue (changes rejected, primary agent must fix first):
99
+ submit_code_review({ approved: false, severity: "blocking", feedback: "<numbered list>" })
100
+ \`\`\`
101
+
102
+ In \`feedback\`: for each issue include the file path, the violating code snippet, the rule violated (referencing the loaded context by name), and the correct pattern. List ALL issues — both blocking and advisory — when severity is "blocking".`;
103
+ }
@@ -0,0 +1,93 @@
1
+ import { __awaiter } from "tslib";
2
+ import { CODE_REVIEWER_AGENT_NAME, } from './code-review.types';
3
+ import { buildUnifiedDiff } from './unified-diff';
4
+ // Review-proportionality thresholds (R12): micro-changes skip the semantic reviewer.
5
+ // A single small edit, or a 2-3 file batch of tiny tweaks, is not worth a sub-agent run.
6
+ const MINOR_SINGLE_FILE_DELTA = 500;
7
+ const MINOR_BATCH_TOTAL_DELTA = 700;
8
+ const MINOR_BATCH_MAX_FILES = 3;
9
+ /**
10
+ * Whether a change is big enough to review. Minor changes skip the model: CSS-only, a single
11
+ * non-CSS file whose size changed by under 500 characters, or a batch of at most 3 brand-new
12
+ * files totalling under 700 characters. A multi-file batch containing any edit always reviews.
13
+ * @beta
14
+ */
15
+ export function shouldRunCodeReviewPreGate(files) {
16
+ const reviewable = files.filter((f) => f.newContent !== '');
17
+ if (reviewable.length === 0)
18
+ return false;
19
+ const nonCss = reviewable.filter((f) => !f.path.endsWith('.css'));
20
+ if (nonCss.length === 0)
21
+ return false;
22
+ if (nonCss.length === 1) {
23
+ const delta = Math.abs(nonCss[0].newContent.length - nonCss[0].oldContent.length);
24
+ return delta >= MINOR_SINGLE_FILE_DELTA;
25
+ }
26
+ // Multi-file batch: only skip when EVERY non-CSS file is a brand-new create. An edit can
27
+ // swap logic without changing length, so its length delta is a lie — never skip a batch
28
+ // that contains one. For all-creates the delta really is file size, so gate on total size.
29
+ const allCreates = nonCss.every((f) => f.oldContent === '');
30
+ if (!allCreates)
31
+ return true;
32
+ const totalSize = nonCss.reduce((sum, f) => sum + f.newContent.length, 0);
33
+ // A small batch of tiny new files is as minor as one small edit — bounded by file count
34
+ // so a wide batch always reviews regardless of its combined size.
35
+ return !(nonCss.length <= MINOR_BATCH_MAX_FILES && totalSize < MINOR_BATCH_TOTAL_DELTA);
36
+ }
37
+ /**
38
+ * Builds the reviewer's `files` context. Edits ride as a compact unified diff so the reviewer
39
+ * judges THIS change, not the pre-existing file around it; new files keep full content (recall
40
+ * risk on creations is real), as does an edit too large to diff cheaply. A plan spec rides
41
+ * along on either shape. Deletions are dropped.
42
+ * @beta
43
+ */
44
+ export function buildReviewFiles(files, specFor) {
45
+ return files
46
+ .filter((f) => f.newContent !== '')
47
+ .map((f) => {
48
+ var _a, _b;
49
+ const diff = f.oldContent === '' ? null : buildUnifiedDiff(f.path, f.oldContent, f.newContent);
50
+ const body = diff === null ? { content: f.newContent } : { diff };
51
+ const spec = specFor === null || specFor === void 0 ? void 0 : specFor(f.path);
52
+ return Object.assign(Object.assign(Object.assign({ path: f.path }, body), (((_a = spec === null || spec === void 0 ? void 0 : spec.purpose) === null || _a === void 0 ? void 0 : _a.trim()) ? { purpose: spec.purpose } : {})), (((_b = spec === null || spec === void 0 ? void 0 : spec.acceptanceChecks) === null || _b === void 0 ? void 0 : _b.length) ? { acceptanceChecks: spec.acceptanceChecks } : {}));
53
+ });
54
+ }
55
+ /**
56
+ * Sends already-built review files to the reviewer sub-agent and maps its outcome. A sub-agent
57
+ * that never returns a verdict yields `{ unavailable, reason }` — callers fail open on it (a
58
+ * reviewer crash must not block a change whose mechanical checks passed) but must not claim the
59
+ * review found no errors.
60
+ * @beta
61
+ */
62
+ export function requestCodeReview(files, requestSubAgent) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ const withChecks = files.filter((f) => { var _a; return (_a = f.acceptanceChecks) === null || _a === void 0 ? void 0 : _a.length; }).length;
65
+ const verdict = yield requestSubAgent(CODE_REVIEWER_AGENT_NAME, {
66
+ task: `Review ${files.length} changed file(s) for Genesis UI pattern compliance and semantic correctness.` +
67
+ (withChecks > 0
68
+ ? ` ${withChecks} file(s) carry their plan spec (purpose / acceptanceChecks) — verify each acceptance check and report any unmet one as an issue.`
69
+ : ''),
70
+ context: { files },
71
+ historyCap: 1,
72
+ });
73
+ if ('reason' in verdict)
74
+ return { unavailable: true, reason: verdict.reason };
75
+ return verdict.result;
76
+ });
77
+ }
78
+ /**
79
+ * Invokes the code reviewer sub-agent before the host commits a change.
80
+ * Returns the verdict; an `{ unavailable, reason }` marker when the sub-agent failed to produce
81
+ * one; or `null` when the change is minor (see {@link shouldRunCodeReviewPreGate}) or no
82
+ * sub-agent caller is available.
83
+ * @beta
84
+ */
85
+ export function runCodeReviewPreGate(files_1, requestSubAgent_1) {
86
+ return __awaiter(this, arguments, void 0, function* (files, requestSubAgent, options = {}) {
87
+ if (!requestSubAgent)
88
+ return null;
89
+ if (!shouldRunCodeReviewPreGate(files))
90
+ return null;
91
+ return requestCodeReview(buildReviewFiles(files, options.specFor), requestSubAgent);
92
+ });
93
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The UI Code Reviewer (`@genesislcap/ai-assistant/code-review`) — FUI-2650.
3
+ *
4
+ * A read-only sub-agent that reviews changed web files for Genesis UI pattern compliance and
5
+ * semantic correctness, the proportionality gate that decides when to run it, and the default
6
+ * Genesis web rule pack it reviews against. Lifted from genesis-create's UI Builder; Create is its
7
+ * first consumer.
8
+ *
9
+ * Its own entry point, not re-exported from the package root: the rule pack is several hundred KB
10
+ * of reference text that only a host running the reviewer should pay for. Node hosts (a CI job)
11
+ * get the same surface from `./chat-driver`, which bundles it with the driver it runs on. The
12
+ * `<ai-code-review-result>` element is on the package root, since it needs a DOM.
13
+ *
14
+ * @packageDocumentation
15
+ * @beta
16
+ */
17
+ export { CODE_REVIEWER_AGENT_NAME, } from './code-review.types';
18
+ export { buildReviewFiles, requestCodeReview, runCodeReviewPreGate, shouldRunCodeReviewPreGate, } from './gate';
19
+ export { createCodeReviewAgent, } from './code-reviewer.agent';
20
+ export { buildCodeReviewerPrompt } from './code-reviewer.prompt';
21
+ export { submitCodeReviewHandler, submitCodeReviewToolDefinition } from './submit-code-review.tool';
22
+ export { createHeadlessSubAgentCaller, isGenesisWebFile, parseUnifiedDiff, reviewChanges, } from './review-changes';
23
+ export { summarizeCodeReview } from './verdict';
24
+ export { buildUnifiedDiff } from './unified-diff';
25
+ // The default Genesis web rule pack. genesis-create's writer agents read the same modules, so the
26
+ // whole registry surface is public, not just what the reviewer needs.
27
+ export { contextToolDefinitions, createContextToolDefinitions, createContextToolHandlers, GENESIS_WEB_RULE_MODULE_NAMES, getContextModule, isKnownContext, MAX_DEPENDENCY_CONTEXT_CHARS, MAX_DEPENDENCY_CONTEXT_MODULES, resolveContextDependencies, searchContextModules, } from './rules/context.registry';
28
+ export { CONTEXT_TRIGGER_TABLE } from './rules/context-trigger-map';
@@ -0,0 +1,123 @@
1
+ import { __awaiter } from "tslib";
2
+ import { ChatDriver } from '../components/chat-driver/chat-driver';
3
+ import { requestCodeReview, shouldRunCodeReviewPreGate } from './gate';
4
+ const stripPrefix = (p) => p.replace(/^[ab]\//, '');
5
+ /** Length of the `--- ` / `+++ ` file-header markers. */
6
+ const FILE_HEADER_MARKER_LENGTH = '--- '.length;
7
+ /**
8
+ * Parses a `git diff` / `git format-patch` unified diff into one entry per file. Binary files and
9
+ * renames without content changes are skipped.
10
+ * @beta
11
+ */
12
+ export function parseUnifiedDiff(patch) {
13
+ var _a, _b;
14
+ const files = [];
15
+ const sections = patch.split(/^(?=diff --git )/m).filter((s) => s.startsWith('diff --git '));
16
+ for (const section of sections) {
17
+ const lines = section.split('\n');
18
+ const oldPath = (_a = lines
19
+ .find((l) => l.startsWith('--- '))) === null || _a === void 0 ? void 0 : _a.slice(FILE_HEADER_MARKER_LENGTH).trim();
20
+ const newPath = (_b = lines
21
+ .find((l) => l.startsWith('+++ '))) === null || _b === void 0 ? void 0 : _b.slice(FILE_HEADER_MARKER_LENGTH).trim();
22
+ if (!oldPath || !newPath)
23
+ continue;
24
+ const kind = oldPath === '/dev/null' ? 'create' : newPath === '/dev/null' ? 'delete' : 'edit';
25
+ const path = stripPrefix(kind === 'delete' ? oldPath : newPath);
26
+ const hunkStart = lines.findIndex((l) => l.startsWith('@@'));
27
+ const body = hunkStart === -1 ? [] : lines.slice(hunkStart);
28
+ const added = body.filter((l) => l.startsWith('+')).map((l) => l.slice(1));
29
+ const removed = body.filter((l) => l.startsWith('-')).map((l) => l.slice(1));
30
+ const addedChars = added.reduce((n, l) => n + l.length + 1, 0);
31
+ const removedChars = removed.reduce((n, l) => n + l.length + 1, 0);
32
+ files.push(Object.assign(Object.assign(Object.assign({ path,
33
+ kind }, (kind === 'create' ? { content: added.join('\n') } : {})), (kind === 'edit'
34
+ ? { diff: [`--- ${path}`, `+++ ${path}`, ...body].join('\n').trimEnd() }
35
+ : {})), { addedChars,
36
+ removedChars }));
37
+ }
38
+ return files;
39
+ }
40
+ /**
41
+ * Whether the default Genesis web rule pack covers a path: TypeScript, TSX and CSS sources, not
42
+ * declaration files or tests.
43
+ * @beta
44
+ */
45
+ export function isGenesisWebFile(path) {
46
+ if (!/\.(tsx?|css)$/.test(path))
47
+ return false;
48
+ return !/\.d\.ts$|\.(test|spec)\.tsx?$/.test(path);
49
+ }
50
+ /**
51
+ * Runs agents as sub-agents with no parent conversation — the same lifecycle a parent
52
+ * `ChatDriver` uses for `requestSubAgent`, for hosts (a CI job, a script) that have a provider
53
+ * registry but no assistant.
54
+ * @beta
55
+ */
56
+ export function createHeadlessSubAgentCaller(registry, agents) {
57
+ return ((name, opts) => __awaiter(this, void 0, void 0, function* () {
58
+ var _a, _b, _c, _d;
59
+ const config = agents.find((a) => a.name === name);
60
+ if (!config)
61
+ return { ok: false, reason: `unknown sub-agent "${name}"` };
62
+ const child = new ChatDriver(registry, {});
63
+ child.markAsSubAgent();
64
+ const contextMessages = (opts === null || opts === void 0 ? void 0 : opts.context)
65
+ ? [{ role: 'user', content: `[Sub-agent context]: ${JSON.stringify(opts.context)}` }]
66
+ : [];
67
+ child.installAgent(Object.assign(Object.assign({}, config), { primerHistory: [...contextMessages, ...((_a = config.primerHistory) !== null && _a !== void 0 ? _a : [])] }));
68
+ try {
69
+ yield child.sendMessage((_b = opts === null || opts === void 0 ? void 0 : opts.task) !== null && _b !== void 0 ? _b : '');
70
+ const completion = child.getSubAgentCompletion();
71
+ if (completion)
72
+ return { ok: true, result: completion.result };
73
+ return { ok: false, reason: (_d = (_c = child.getSubAgentFailure()) === null || _c === void 0 ? void 0 : _c.reason) !== null && _d !== void 0 ? _d : 'no_completion' };
74
+ }
75
+ catch (e) {
76
+ return { ok: false, reason: e instanceof Error ? e.message : String(e) };
77
+ }
78
+ finally {
79
+ yield child.dispose();
80
+ }
81
+ }));
82
+ }
83
+ /**
84
+ * Reviews a unified diff without an assistant: keeps the files the rule pack covers, applies the
85
+ * same proportionality skip as the pre-gate, and asks the reviewer for one verdict. Edits ride as
86
+ * their diff, new files as full content; deletions are not reviewed.
87
+ *
88
+ * For an edit the skip rule uses the diff's added/removed character counts in place of the
89
+ * before/after file sizes, which it does not have.
90
+ * @beta
91
+ */
92
+ export function reviewChanges(patch, options) {
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ var _a;
95
+ const covers = (_a = options.covers) !== null && _a !== void 0 ? _a : isGenesisWebFile;
96
+ const parsed = parseUnifiedDiff(patch).filter((f) => f.kind !== 'delete');
97
+ const inScope = parsed.filter((f) => covers(f.path));
98
+ const outOfScope = parsed.filter((f) => !covers(f.path)).map((f) => f.path);
99
+ const reviewed = inScope.map((f) => f.path);
100
+ // Size stand-ins with the same length delta as the diff. An edit's stand-ins share a non-empty
101
+ // prefix so an add-only edit is never mistaken for a create (oldContent '') by the skip rule.
102
+ const asChanged = inScope.map((f) => {
103
+ var _a;
104
+ return f.kind === 'create'
105
+ ? { path: f.path, newContent: (_a = f.content) !== null && _a !== void 0 ? _a : '', oldContent: '' }
106
+ : {
107
+ path: f.path,
108
+ newContent: `~${'+'.repeat(f.addedChars)}`,
109
+ oldContent: `~${'-'.repeat(f.removedChars)}`,
110
+ };
111
+ });
112
+ if (!shouldRunCodeReviewPreGate(asChanged))
113
+ return { verdict: null, reviewed, outOfScope };
114
+ const files = inScope.map((f) => {
115
+ var _a, _b;
116
+ return f.kind === 'create'
117
+ ? { path: f.path, content: (_a = f.content) !== null && _a !== void 0 ? _a : '' }
118
+ : { path: f.path, diff: (_b = f.diff) !== null && _b !== void 0 ? _b : '' };
119
+ });
120
+ const verdict = yield requestCodeReview(files, options.requestSubAgent);
121
+ return { verdict, reviewed, outOfScope };
122
+ });
123
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Shared context trigger table used by Code Reviewer, Error Analyst, and Convergence Judge.
3
+ * Each row maps a code signal to the focused context module that covers it.
4
+ */
5
+ export const CONTEXT_TRIGGER_TABLE = `\
6
+ | If you see… | Load context |
7
+ |---|---|
8
+ | Imports from rapid-grid-pro, foundation-entity-management, or ag-Grid ColDef | fui-column-defs |
9
+ | EntityManagement, createEvent, updateEvent, deleteEvent, onRowClicked | fui-entity-management |
10
+ | RapidGridPro, GridProGenesisDatasource, GridProColumn, ColDef | fui-rapid-grid-pro |
11
+ | Form, UiSchema, VerticalLayout, Categorization, Stepper, childElements | fui-form-component |
12
+ | Dialog, Modal, Flyout, useRef for modal/flyout, ref.current?.show() | fui-dialogs |
13
+ | Button, Select, ListboxOption, Tabs, TabPanel, Card, Snackbar, DatePicker, OptionsDatasource, MultiselectDatasource, Combobox, Multiselect | fui-primitives |
14
+ | Redux slices, publishEventName, row selection, cross-tile filtering | fui-eventing |
15
+ | Connect, snapshot(), request(), commitEvent(), stream() | fui-foundation-comms |
16
+ | editable column config, cellEditor, inline editing | fui-inline-editing |
17
+ | flexlayout-react, Layout, Model, TabNode, componentMap | fui-layout |
18
+ | .css files or className styling | fui-styling |
19
+ | TileErrorBoundary or withTileErrorBoundary | fui-error-boundary |
20
+ | GlobalFilters, CriteriaBuilder, shared filter bar, Filters from foundation-forms | fui-global-filters |`;