Files
windmill/cli/generate-ai-review.ts
fbe776d611 feat: review git sync pull requests with wmill review (#12055)
* feat: add ai review to deployment requests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: bound ai review fetches and surface unreadable items

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: add fix in ai session and model picker to deployment ai review

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: add workspace instructions for deployment ai review

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: read review instructions from the parent and bind ai review to the fork

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: pin the fix-all session preview to the fork's compare page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: show the protection-rule bypass toggle inline

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: make the bypass toggle small and red

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor: drop workspace-settings instructions from deployment ai review

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: folder-scoped review instructions for the deployment ai review

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: review the selected items with ai on compare and deploy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: keep reviewing when review instructions cannot be listed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: say the review instruction floor is a prompt request, not enforcement

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: mark an ai review out of date when its items change

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* chore: update ee-repo-ref to 77703cf32e58964906d87ee83ddda44b5b8d1b7e

This commit updates the EE repository reference after PR #926 was merged in windmill-ee-private.

Previous ee-repo-ref: e30ab9e69d1854fcaed5620c934ace32acb0a729

New ee-repo-ref: 77703cf32e58964906d87ee83ddda44b5b8d1b7e

Automated by sync-ee-ref workflow.

* feat: review git sync pull requests with wmill review

* fix: withhold retyped resources and encryption keys, fall back from the responses route

* fix: withhold fileset children, workspace-specific resources and pathspec-named files

* feat: include the ready-to-post review in wmill review --json

* feat: review a workspace synced into a repository subfolder

* docs: say what wmill review takes from flags rather than wmill.yaml

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
2026-10-28 05:49:07 +01:00

70 lines
2.6 KiB
TypeScript

/**
* Vendors the AI review core into the CLI, for `wmill review`.
*
* The prompt, the size budget and the reading of the model's answer are the
* review: the deployment request panel and a pull request review must ask the
* same thing and read the answer the same way, so both run one source,
* frontend/src/lib/components/deploymentRequest/aiReviewCore.ts, plus the
* folder instruction helpers it imports. The modules are concatenated as
* TypeScript rather than bundled, so the CLI keeps their types.
*
* Run `bun run gen:ai-review` after touching either module;
* test/ai_review_bundle_unit.test.ts fails when the committed copy no longer
* matches them.
*/
import { readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
const REPO_ROOT = join(import.meta.dir, "..");
const COMPONENTS = join(REPO_ROOT, "frontend", "src", "lib", "components");
const SCOPES = join(COMPONENTS, "copilot", "chat", "folderInstructionScopes.ts");
const CORE = join(COMPONENTS, "deploymentRequest", "aiReviewCore.ts");
export const OUT_FILE = join(
import.meta.dir,
"src",
"commands",
"review",
"aiReviewCore.gen.ts",
);
const HEADER = `// Generated by cli/generate-ai-review.ts. Do not edit.
// Run \`bun run gen:ai-review\` from cli/ to rebuild it from
// frontend/src/lib/components/deploymentRequest/aiReviewCore.ts and
// frontend/src/lib/components/copilot/chat/folderInstructionScopes.ts.
`;
const SCOPES_IMPORT =
/^(import|export) \{[^}]*\} from '\.\.\/copilot\/chat\/folderInstructionScopes'\n/gm;
/** The vendored module, header included. Exported so the staleness test can
* build it and compare. Line endings are normalized: a CRLF checkout is the
* same source. */
export function buildAiReviewCore(): string {
const read = (p: string) => readFileSync(p, "utf-8").replace(/\r\n/g, "\n");
const scopes = read(SCOPES);
const core = read(CORE).replace(SCOPES_IMPORT, "");
// Anything else either module imports would not resolve in the CLI.
for (const [file, source] of [[SCOPES, scopes], [CORE, core]]) {
if (/^(import|export) .* from /m.test(source)) {
throw new Error(
`${file} imports another module. Keep the review core self-contained, ` +
"or teach this generator to vendor what it imports.",
);
}
}
return `${HEADER}\n${scopes}\n${core}`;
}
if (import.meta.main) {
const ts = buildAiReviewCore();
const before = (() => {
try {
return readFileSync(OUT_FILE, "utf-8");
} catch {
return "";
}
})();
writeFileSync(OUT_FILE, ts, "utf-8");
console.log(`${before === ts ? "Unchanged" : "Wrote"} ${OUT_FILE}`);
}