@clearlydev/nx-archweave 0.2.1 → 0.3.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.
@@ -228,6 +228,30 @@ function buildOverEngineeringPrompt(locale) {
228
228
  return [...body, "", renderFindingSchemaInstruction(locale, OVER_ENGINEERING_PRIORITIES), "", renderDedupInstruction(locale)].join("\n");
229
229
  }
230
230
 
231
+ // ../review-policy/dist/verdict-gate/verdict-comment.js
232
+ var VERDICT_MARKER = "<!-- archweave-verdict -->";
233
+ function renderCommitLine(locale, shortSha) {
234
+ return locale === "en" ? `<sub>Commit \`${shortSha}\` \xB7 this comment is updated on every review round.</sub>` : `<sub>\uCEE4\uBC0B \`${shortSha}\` \xB7 \uC774 \uCF54\uBA58\uD2B8\uB294 \uB9AC\uBDF0 \uB77C\uC6B4\uB4DC\uB9C8\uB2E4 \uAC31\uC2E0\uB429\uB2C8\uB2E4.</sub>`;
235
+ }
236
+ var NOT_RUN_REASON = {
237
+ en: {
238
+ secret: (secretName) => `the ${secretName} secret is not registered`,
239
+ fork: () => "this pull request comes from a fork, and GitHub passes no secrets to runs from forks",
240
+ dependabot: (secretName) => `Dependabot runs receive only Dependabot secrets, and ${secretName} is not one of them`,
241
+ rounds: (_secretName, maxRounds) => `the automated review round limit (${maxRounds}) is reached`
242
+ },
243
+ ko: {
244
+ secret: (secretName) => `${secretName} \uC2DC\uD06C\uB9BF\uC774 \uB4F1\uB85D\uB418\uC9C0 \uC54A\uC74C`,
245
+ fork: () => "\uD3EC\uD06C\uC5D0\uC11C \uC628 pull request\uC774\uACE0, GitHub\uB294 \uD3EC\uD06C \uC2E4\uD589\uC5D0 \uC2DC\uD06C\uB9BF\uC744 \uB118\uAE30\uC9C0 \uC54A\uC74C",
246
+ dependabot: (secretName) => `Dependabot \uC2E4\uD589\uC740 Dependabot \uC2DC\uD06C\uB9BF\uB9CC \uBC1B\uB294\uB370, ${secretName}\uB294 \uADF8\uC911\uC5D0 \uC5C6\uC74C`,
247
+ rounds: (_secretName, maxRounds) => `\uC790\uB3D9 \uB9AC\uBDF0 \uB77C\uC6B4\uB4DC \uD55C\uB3C4(${maxRounds})\uC5D0 \uB3C4\uB2EC\uD568`
248
+ }
249
+ };
250
+ function renderNotRunNotice(locale, reason, secretName, maxRounds) {
251
+ const why = NOT_RUN_REASON[locale][reason](secretName, maxRounds);
252
+ return locale === "en" ? `AI review did not run for this commit (${why}). A green check here does not mean the change was reviewed.` : `\uC774 \uCEE4\uBC0B\uC5D0\uB294 AI \uB9AC\uBDF0\uAC00 \uC2E4\uD589\uB418\uC9C0 \uC54A\uC558\uC2B5\uB2C8\uB2E4(${why}). \uC774 green \uCCB4\uD06C\uB294 \uBCC0\uACBD \uC0AC\uD56D\uC774 \uB9AC\uBDF0\uB418\uC5C8\uB2E4\uB294 \uB73B\uC774 \uC544\uB2D9\uB2C8\uB2E4.`;
253
+ }
254
+
231
255
  // ../review-policy/dist/verdict-gate/verdict-gate.js
232
256
  var ROUND_MARKER = "<!-- archweave-review-round -->";
233
257
 
@@ -272,13 +296,14 @@ function renderConcurrencyBlock() {
272
296
  " cancel-in-progress: false"
273
297
  ].join("\n");
274
298
  }
275
- function renderPermissionsBlock() {
276
- return ["permissions:", " contents: read", " pull-requests: write", " id-token: write"].join("\n");
299
+ var REVIEW_GATE_CONDITION = "steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'";
300
+ function renderReviewPermissions(idToken) {
301
+ return ["permissions:", " contents: read", " pull-requests: write", ...idToken ? [" id-token: write"] : []].join("\n");
277
302
  }
278
303
  function renderCheckoutStep(gateCondition, extraWith = []) {
279
304
  return [
280
305
  "- name: Checkout repository",
281
- ` if: ${gateCondition}`,
306
+ ...gateCondition === void 0 ? [] : [` if: ${gateCondition}`],
282
307
  ` uses: ${pinnedUses("actions/checkout")}`,
283
308
  " with:",
284
309
  ...extraWith.map((line) => ` ${line}`),
@@ -320,10 +345,84 @@ function renderRoundGateStep(maxRounds) {
320
345
  " fi"
321
346
  ].join("\n");
322
347
  }
348
+ function shellQuote(text) {
349
+ return `'${text.replace(/'/g, `'\\''`)}'`;
350
+ }
351
+ function renderNotRunFunction(secretName, maxRounds, locale) {
352
+ const reasons = ["secret", "fork", "dependabot", "rounds"];
353
+ const [commitBefore, commitAfter] = renderCommitLine(locale, "\0").split("\0");
354
+ return [
355
+ "not_run() {",
356
+ ' case "$1" in',
357
+ ...reasons.map((reason) => ` ${reason}) annotation=${shellQuote(renderNotRunNotice("en", reason, secretName, maxRounds))}; notice=${shellQuote(renderNotRunNotice(locale, reason, secretName, maxRounds))} ;;`),
358
+ " esac",
359
+ ' echo "::notice title=AI review did not run::$annotation"',
360
+ ` printf '%s\\n' "$notice" >> "$GITHUB_STEP_SUMMARY"`,
361
+ ` short_sha=$(printf '%s' "$HEAD_SHA" | cut -c1-7)`,
362
+ ' case "$short_sha" in',
363
+ " '' | *[!0-9a-f]*) short_sha= ;;",
364
+ " esac",
365
+ " {",
366
+ ' echo "notice-body<<ARCHWEAVE_NOT_RUN_EOF"',
367
+ ` printf '%s\\n' ${shellQuote(VERDICT_MARKER)} "\u2139\uFE0F $notice"`,
368
+ ` if [ -n "$short_sha" ]; then printf '\\n%s\\n' ${shellQuote(commitBefore)}"$short_sha"${shellQuote(commitAfter)}; fi`,
369
+ ' echo "ARCHWEAVE_NOT_RUN_EOF"',
370
+ ' echo "run=false"',
371
+ ' } >> "$GITHUB_OUTPUT"',
372
+ "}"
373
+ ];
374
+ }
375
+ var JUDGE_CONDITION = "steps.ai-review-result.outputs.run == 'true'";
376
+ function renderAiReviewResultStep(secretName, maxRounds, locale) {
377
+ return [
378
+ "- name: Check the AI review result",
379
+ " id: ai-review-result",
380
+ " env:",
381
+ " AI_REVIEW_RESULT: ${{ needs.ai-review.result }}",
382
+ " REVIEW_ENABLED: ${{ needs.ai-review.outputs.enabled }}",
383
+ " REVIEW_ALLOWED: ${{ needs.ai-review.outputs.allowed }}",
384
+ " LAST_COMMENT_ID: ${{ needs.ai-review.outputs.last-comment-id }}",
385
+ " HEAD_SHA: ${{ github.event.pull_request.head.sha }}",
386
+ " HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}",
387
+ " REPOSITORY: ${{ github.repository }}",
388
+ " PR_AUTHOR: ${{ github.event.pull_request.user.login }}",
389
+ " run: |",
390
+ ...renderNotRunFunction(secretName, maxRounds, locale).map((line) => ` ${line}`),
391
+ ' if [ "$AI_REVIEW_RESULT" != success ]; then',
392
+ ` echo "::error title=AI review did not succeed::The AI review job ended with '$AI_REVIEW_RESULT'."`,
393
+ " exit 1",
394
+ " fi",
395
+ ' case "$REVIEW_ENABLED/$REVIEW_ALLOWED" in',
396
+ " false/*)",
397
+ ' if [ "$HEAD_REPOSITORY" != "$REPOSITORY" ]; then not_run fork',
398
+ ` elif [ "$PR_AUTHOR" = 'dependabot[bot]' ]; then not_run dependabot`,
399
+ " else not_run secret",
400
+ " fi",
401
+ " exit 0",
402
+ " ;;",
403
+ " true/false)",
404
+ " not_run rounds",
405
+ " exit 0",
406
+ " ;;",
407
+ " true/true)",
408
+ ' case "$LAST_COMMENT_ID" in',
409
+ " '' | *[!0-9]*) ;;",
410
+ " *)",
411
+ ' echo "run=true" >> "$GITHUB_OUTPUT"',
412
+ " exit 0",
413
+ " ;;",
414
+ " esac",
415
+ " ;;",
416
+ " esac",
417
+ ` echo "::error title=Review verdict not computed::The AI review job's results did not reach this job, so no verdict can be computed. Re-run all jobs."`,
418
+ " exit 1"
419
+ ].join("\n");
420
+ }
323
421
  function renderVerdictGateStep(maxRounds, locale) {
324
422
  return [
325
423
  "- name: Compute review verdict",
326
- " if: steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'",
424
+ " id: verdict",
425
+ ` if: ${JUDGE_CONDITION}`,
327
426
  " env:",
328
427
  " GH_TOKEN: ${{ github.token }}",
329
428
  " GITHUB_REPOSITORY: ${{ github.repository }}",
@@ -331,7 +430,8 @@ function renderVerdictGateStep(maxRounds, locale) {
331
430
  ` ARCHWEAVE_MAX_ROUNDS: '${maxRounds}'`,
332
431
  ` ARCHWEAVE_LOCALE: '${locale}'`,
333
432
  " ARCHWEAVE_HEAD_SHA: ${{ github.event.pull_request.head.sha }}",
334
- " ARCHWEAVE_ROUND_AFTER_ID: ${{ steps.round-gate.outputs.last-comment-id }}",
433
+ " ARCHWEAVE_ROUND_AFTER_ID: ${{ needs.ai-review.outputs.last-comment-id }}",
434
+ " ARCHWEAVE_VERDICT_OUTPUT: 'github-output'",
335
435
  " run: |",
336
436
  " if [ -x node_modules/.bin/archweave-review-verdict ]; then",
337
437
  " node_modules/.bin/archweave-review-verdict",
@@ -340,16 +440,49 @@ function renderVerdictGateStep(maxRounds, locale) {
340
440
  " fi"
341
441
  ].join("\n");
342
442
  }
443
+ function renderBlockStep() {
444
+ return [
445
+ "- name: Fail on a blocking verdict",
446
+ " if: steps.verdict.outputs.blocked == 'true'",
447
+ " run: |",
448
+ ' echo "The review check failed: the verdict is BLOCK, or the AI review left no readable summary. See the verdict comment on this pull request."',
449
+ " exit 1"
450
+ ].join("\n");
451
+ }
452
+ function renderVerdictCommentStep() {
453
+ return [
454
+ "- name: Post review verdict",
455
+ " env:",
456
+ " GH_TOKEN: ${{ github.token }}",
457
+ " REPOSITORY: ${{ github.repository }}",
458
+ " PR_NUMBER: ${{ github.event.pull_request.number }}",
459
+ " VERDICT_BODY: ${{ needs.review.outputs.comment-body }}",
460
+ " PREVIOUS_ID: ${{ needs.review.outputs.previous-comment-id }}",
461
+ " run: |",
462
+ ` payload=$(jq -n --arg body "$VERDICT_BODY" '{body: $body}')`,
463
+ ' if [ -z "$PREVIOUS_ID" ]; then',
464
+ ` PREVIOUS_ID=$(gh api "repos/$REPOSITORY/issues/$PR_NUMBER/comments" --paginate --jq '.[] | select(.user.login == "github-actions[bot]") | select(.body | contains("${VERDICT_MARKER}")) | .id' | tail -n 1) || PREVIOUS_ID=`,
465
+ " fi",
466
+ ' case "$PREVIOUS_ID" in',
467
+ " ''|*[!0-9]*) PREVIOUS_ID= ;;",
468
+ " esac",
469
+ ` if [ -n "$PREVIOUS_ID" ] && printf '%s' "$payload" | gh api -X PATCH "repos/$REPOSITORY/issues/comments/$PREVIOUS_ID" --input - > /dev/null; then`,
470
+ " exit 0",
471
+ " fi",
472
+ ` printf '%s' "$payload" | gh api -X POST "repos/$REPOSITORY/issues/$PR_NUMBER/comments" --input - > /dev/null \\`,
473
+ ' || echo "Could not post the verdict comment (continuing)."'
474
+ ].join("\n");
475
+ }
343
476
  var SETUP_NODE_VERSION = "22";
344
477
  var FALLBACK_PNPM_VERSION = "10";
345
478
  var INSTALL_LINES = {
346
- pnpm: [" pnpm install --frozen-lockfile"],
347
- npm: [" npm ci"],
479
+ pnpm: [" pnpm install --frozen-lockfile --ignore-scripts"],
480
+ npm: [" npm ci --ignore-scripts"],
348
481
  yarn: [
349
482
  " corepack enable yarn",
350
- ' if [ "$(yarn --version | cut -d. -f1)" -ge 2 ]; then yarn install --immutable; else yarn install --frozen-lockfile; fi'
483
+ ' if [ "$(yarn --version | cut -d. -f1)" -ge 2 ]; then YARN_ENABLE_SCRIPTS=false yarn install --immutable --mode=skip-build; else yarn install --frozen-lockfile --ignore-scripts; fi'
351
484
  ],
352
- bun: [" bun install --frozen-lockfile"]
485
+ bun: [" bun install --frozen-lockfile --ignore-scripts"]
353
486
  };
354
487
  function renderPnpmVersionStep(gate) {
355
488
  return [
@@ -365,7 +498,7 @@ function renderPnpmVersionStep(gate) {
365
498
  ].join("\n");
366
499
  }
367
500
  function renderWorkspaceSetupSteps(packageManager) {
368
- const gate = " if: steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'";
501
+ const gate = ` if: ${JUDGE_CONDITION}`;
369
502
  const steps = [];
370
503
  if (packageManager === "pnpm") {
371
504
  steps.push(renderPnpmVersionStep(gate));
@@ -400,21 +533,89 @@ function renderWorkspaceSetupSteps(packageManager) {
400
533
  ].join("\n"));
401
534
  return steps.join("\n\n");
402
535
  }
536
+ var REVIEW_JOB_TIMEOUT_MINUTES = 15;
537
+ function renderReviewWorkflow(input, parts) {
538
+ const aiReviewSteps = [renderSecretGateStep(parts.secretName), renderRoundGateStep(input.maxRounds), ...parts.reviewSteps];
539
+ const reviewSteps = [
540
+ renderAiReviewResultStep(parts.secretName, input.maxRounds, input.locale),
541
+ renderCheckoutStep(JUDGE_CONDITION),
542
+ renderWorkspaceSetupSteps(input.packageManager),
543
+ renderVerdictGateStep(input.maxRounds, input.locale),
544
+ renderBlockStep()
545
+ ];
546
+ return [
547
+ `name: ${parts.name}`,
548
+ "",
549
+ renderTriggerBlock(),
550
+ "",
551
+ renderConcurrencyBlock(),
552
+ "",
553
+ "permissions: {}",
554
+ "",
555
+ "jobs:",
556
+ " ai-review:",
557
+ " runs-on: ubuntu-latest",
558
+ ` timeout-minutes: ${REVIEW_JOB_TIMEOUT_MINUTES}`,
559
+ indentBlock(renderReviewPermissions(parts.idToken), 4),
560
+ " outputs:",
561
+ " enabled: ${{ steps.secret-gate.outputs.enabled }}",
562
+ " allowed: ${{ steps.round-gate.outputs.allowed }}",
563
+ " last-comment-id: ${{ steps.round-gate.outputs.last-comment-id }}",
564
+ " steps:",
565
+ indentBlock(aiReviewSteps.join("\n\n"), 6),
566
+ "",
567
+ " review:",
568
+ " needs: ai-review",
569
+ " if: always()",
570
+ " runs-on: ubuntu-latest",
571
+ ` timeout-minutes: ${REVIEW_JOB_TIMEOUT_MINUTES}`,
572
+ " permissions:",
573
+ " contents: read",
574
+ " pull-requests: read",
575
+ " outputs:",
576
+ " comment-body: ${{ steps.verdict.outputs.comment-body || steps.ai-review-result.outputs.notice-body }}",
577
+ " previous-comment-id: ${{ steps.verdict.outputs.previous-comment-id }}",
578
+ " steps:",
579
+ indentBlock(reviewSteps.join("\n\n"), 6),
580
+ "",
581
+ " review-comment:",
582
+ " needs: review",
583
+ // Runs after a BLOCK failed the review job, too: the comment explains the red check.
584
+ " if: ${{ !cancelled() && needs.review.outputs.comment-body != '' }}",
585
+ " runs-on: ubuntu-latest",
586
+ ` timeout-minutes: ${REVIEW_JOB_TIMEOUT_MINUTES}`,
587
+ " permissions:",
588
+ " pull-requests: write",
589
+ " steps:",
590
+ indentBlock(renderVerdictCommentStep(), 6),
591
+ ""
592
+ ].join("\n");
593
+ }
403
594
 
404
595
  // ../template-engine/dist/review/claude/claude-provider.js
405
596
  var SECRET_NAME = "CLAUDE_CODE_OAUTH_TOKEN";
406
597
  var ALLOWED_TOOLS = "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)";
598
+ var CLAUDE_STEP_ID = "claude-review";
599
+ var PR_CONTEXT = ["REPO: ${{ github.repository }}", "PR NUMBER: ${{ github.event.pull_request.number }}"];
407
600
  function renderWorkflowInstructions(locale) {
408
601
  const lines = locale === "en" ? [
409
- "Review the diff of this pull request using `gh pr diff` and `gh pr view`.",
410
- "Post specific findings as inline comments and exactly one top-level summary comment.",
602
+ ...PR_CONTEXT,
603
+ "",
604
+ "Review the diff of this pull request using `gh pr diff <PR NUMBER>` and `gh pr view <PR NUMBER>`.",
605
+ "Post specific findings as inline comments with `mcp__github_inline_comment__create_inline_comment` (pass `confirmed: true`), and exactly one top-level summary comment.",
606
+ "Post the summary with `gh pr comment <PR NUMBER> --body-file - <<'ARCHWEAVE_EOF'`, the body on the following lines, then a line `ARCHWEAVE_EOF` (the quoted delimiter keeps backticks and `$` literal). Never pass the body with `--body \"...\"` or `$(...)`.",
607
+ "Run each `gh` command on its own: no pipes to other programs, no `&&` chains.",
411
608
  `Always include the literal marker ${ROUND_MARKER} in the top-level summary comment.`,
412
609
  "If there are no findings that require action, post exactly one top-level comment saying so (and still include the marker).",
413
610
  "Do not modify any code, and never approve or merge the pull request.",
414
611
  "Write summaries and explanations in English; keep file names, function names, and identifiers verbatim."
415
612
  ] : [
416
- "\uC774 pull request\uC758 diff\uB97C `gh pr diff`\uC640 `gh pr view`\uB85C \uD655\uC778\uD558\uACE0 \uB9AC\uBDF0\uD558\uC138\uC694.",
417
- "\uAD6C\uCCB4\uC801 \uC9C0\uC801\uC740 inline comment\uB85C, \uC804\uCCB4 \uC694\uC57D\uC740 \uC815\uD655\uD788 \uD55C \uAC1C\uC758 top-level comment\uB85C \uAC8C\uC2DC\uD558\uC138\uC694.",
613
+ ...PR_CONTEXT,
614
+ "",
615
+ "\uC774 pull request\uC758 diff\uB97C `gh pr diff <PR NUMBER>`\uC640 `gh pr view <PR NUMBER>`\uB85C \uD655\uC778\uD558\uACE0 \uB9AC\uBDF0\uD558\uC138\uC694.",
616
+ "\uAD6C\uCCB4\uC801 \uC9C0\uC801\uC740 `mcp__github_inline_comment__create_inline_comment`(`confirmed: true` \uC804\uB2EC)\uB85C inline comment\uB97C \uB2EC\uACE0, \uC804\uCCB4 \uC694\uC57D\uC740 \uC815\uD655\uD788 \uD55C \uAC1C\uC758 top-level comment\uB85C \uAC8C\uC2DC\uD558\uC138\uC694.",
617
+ "\uC694\uC57D\uC740 `gh pr comment <PR NUMBER> --body-file - <<'ARCHWEAVE_EOF'`\uB85C \uAC8C\uC2DC\uD558\uC138\uC694. \uB2E4\uC74C \uC904\uBD80\uD130 \uBCF8\uBB38\uC744 \uC4F0\uACE0, \uB9C8\uC9C0\uB9C9 \uC904\uC5D0 `ARCHWEAVE_EOF`\uB9CC \uC4F0\uC138\uC694(\uB530\uC634\uD45C \uCE5C \uAD6C\uBD84\uC790\uB77C \uBC31\uD2F1\uACFC `$`\uAC00 \uADF8\uB300\uB85C \uB0A8\uC544\uC694). \uBCF8\uBB38\uC744 `--body \"...\"`\uB098 `$(...)`\uB85C \uB118\uAE30\uC9C0 \uB9C8\uC138\uC694.",
618
+ "`gh` \uBA85\uB839\uC740 \uD558\uB098\uC529 \uB530\uB85C \uC2E4\uD589\uD558\uC138\uC694. \uB2E4\uB978 \uD504\uB85C\uADF8\uB7A8\uC73C\uB85C \uD30C\uC774\uD504\uD558\uAC70\uB098 `&&`\uB85C \uC787\uC9C0 \uB9C8\uC138\uC694.",
418
619
  `top-level \uC694\uC57D \uCF54\uBA58\uD2B8\uC5D0\uB294 \uBC18\uB4DC\uC2DC \uB9AC\uD130\uB7F4 \uB9C8\uCEE4 ${ROUND_MARKER}\uB97C \uD3EC\uD568\uD558\uC138\uC694.`,
419
620
  '\uC870\uCE58\uAC00 \uD544\uC694\uD55C \uBB38\uC81C\uAC00 \uC5C6\uC73C\uBA74 "\uC870\uCE58\uAC00 \uD544\uC694\uD55C \uBB38\uC81C\uB97C \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4."\uB77C\uB294 top-level comment\uB97C \uC815\uD655\uD788 \uD55C \uAC1C \uAC8C\uC2DC\uD558\uC138\uC694(\uC774\uB54C\uB3C4 \uB9C8\uCEE4\uB294 \uD3EC\uD568).',
420
621
  "\uCF54\uB4DC\uB97C \uC218\uC815\uD558\uC9C0 \uB9C8\uC138\uC694(Do not modify any code). PR\uC744 \uC2B9\uC778\uD558\uAC70\uB098 \uBCD1\uD569\uD558\uC9C0 \uB9C8\uC138\uC694(never approve or merge).",
@@ -431,42 +632,44 @@ function composePrompt(input) {
431
632
  sections.push(renderFindingsBlockInstruction(input.locale));
432
633
  return sections.join("\n\n---\n\n");
433
634
  }
434
- function buildWorkflowYaml(input) {
435
- const steps = [
436
- renderSecretGateStep(SECRET_NAME),
437
- renderRoundGateStep(input.maxRounds),
438
- renderCheckoutStep("steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'"),
439
- [
440
- "- name: Run Claude review",
441
- " if: steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'",
442
- ` uses: ${pinnedUses("anthropics/claude-code-action")}`,
443
- " with:",
444
- ` claude_code_oauth_token: \${{ secrets.${SECRET_NAME} }}`,
445
- " prompt: |",
446
- indentBlock(composePrompt(input), 6),
447
- " claude_args: |",
448
- ` --allowedTools "${ALLOWED_TOOLS}"`
449
- ].join("\n"),
450
- renderWorkspaceSetupSteps(input.packageManager),
451
- renderVerdictGateStep(input.maxRounds, input.locale)
452
- ];
635
+ function renderDeniedToolsStep() {
453
636
  return [
454
- "name: Claude Code Review",
455
- "",
456
- renderTriggerBlock(),
457
- "",
458
- renderConcurrencyBlock(),
459
- "",
460
- renderPermissionsBlock(),
461
- "",
462
- "jobs:",
463
- " review:",
464
- " runs-on: ubuntu-latest",
465
- " steps:",
466
- indentBlock(steps.join("\n\n"), 6),
467
- ""
637
+ "- name: Show denied tool calls",
638
+ ` if: always() && steps.${CLAUDE_STEP_ID}.outputs.execution_file != ''`,
639
+ " env:",
640
+ ` EXECUTION_FILE: \${{ steps.${CLAUDE_STEP_ID}.outputs.execution_file }}`,
641
+ " run: |",
642
+ ' [ -f "$EXECUTION_FILE" ] || exit 0',
643
+ ` stop_token="archweave-$(od -An -N16 -tx1 /dev/urandom | tr -d ' \\n')"`,
644
+ ' echo "::stop-commands::$stop_token"',
645
+ ` jq -c '.[] | select(.type == "result") | .permission_denials[]? | {tool: .tool_name, command: ((.tool_input.command // "") | tostring | .[0:200])}' "$EXECUTION_FILE" || echo "Could not read the execution file."`,
646
+ ' echo "::$stop_token::"'
468
647
  ].join("\n");
469
648
  }
649
+ function buildWorkflowYaml(input) {
650
+ return renderReviewWorkflow(input, {
651
+ name: "Claude Code Review",
652
+ secretName: SECRET_NAME,
653
+ // The Claude GitHub App signs in with the workflow's OIDC token (claude-code-action's FAQ).
654
+ idToken: true,
655
+ reviewSteps: [
656
+ renderCheckoutStep(REVIEW_GATE_CONDITION),
657
+ [
658
+ "- name: Run Claude review",
659
+ ` id: ${CLAUDE_STEP_ID}`,
660
+ ` if: ${REVIEW_GATE_CONDITION}`,
661
+ ` uses: ${pinnedUses("anthropics/claude-code-action")}`,
662
+ " with:",
663
+ ` claude_code_oauth_token: \${{ secrets.${SECRET_NAME} }}`,
664
+ " prompt: |",
665
+ indentBlock(composePrompt(input), 6),
666
+ " claude_args: |",
667
+ ` --allowedTools "${ALLOWED_TOOLS}"`
668
+ ].join("\n"),
669
+ renderDeniedToolsStep()
670
+ ]
671
+ });
672
+ }
470
673
  var claudeProvider = {
471
674
  id: "claude",
472
675
  workflowFileName: ".github/workflows/claude-code-review.yml",
@@ -505,49 +708,41 @@ function composePrompt2(input) {
505
708
  return sections.join("\n\n---\n\n");
506
709
  }
507
710
  function buildWorkflowYaml2(input) {
508
- const gateCondition = "steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'";
509
- const steps = [
510
- renderSecretGateStep(SECRET_NAME2),
511
- renderRoundGateStep(input.maxRounds),
512
- renderCheckoutStep(gateCondition),
513
- [
514
- "- name: Install cursor-agent CLI",
515
- ` if: ${gateCondition}`,
516
- " run: |",
517
- " curl https://cursor.com/install -fsS | bash",
518
- ' echo "$HOME/.cursor/bin" >> "$GITHUB_PATH"'
519
- ].join("\n"),
520
- [
521
- "- name: Run Cursor review",
522
- ` if: ${gateCondition}`,
523
- " env:",
524
- ` CURSOR_API_KEY: \${{ secrets.${SECRET_NAME2} }}`,
525
- " GH_TOKEN: ${{ github.token }}",
526
- " run: |",
527
- ` agent -p "$(cat <<'${PROMPT_HEREDOC_DELIMITER}'`,
528
- indentBlock(composePrompt2(input), 4),
529
- ` ${PROMPT_HEREDOC_DELIMITER}`,
530
- ' )"'
531
- ].join("\n"),
532
- renderWorkspaceSetupSteps(input.packageManager),
533
- renderVerdictGateStep(input.maxRounds, input.locale)
534
- ];
535
- return [
536
- "name: Cursor Code Review",
537
- "",
538
- renderTriggerBlock(),
539
- "",
540
- renderConcurrencyBlock(),
541
- "",
542
- renderPermissionsBlock(),
543
- "",
544
- "jobs:",
545
- " review:",
546
- " runs-on: ubuntu-latest",
547
- " steps:",
548
- indentBlock(steps.join("\n\n"), 6),
549
- ""
550
- ].join("\n");
711
+ return renderReviewWorkflow(input, {
712
+ name: "Cursor Code Review",
713
+ secretName: SECRET_NAME2,
714
+ // An API key: the Cursor CLI needs no OIDC token.
715
+ idToken: false,
716
+ reviewSteps: [
717
+ renderCheckoutStep(REVIEW_GATE_CONDITION),
718
+ [
719
+ "- name: Install cursor-agent CLI",
720
+ ` if: ${REVIEW_GATE_CONDITION}`,
721
+ " run: |",
722
+ // HTTPS only, TLS 1.2 or newer. Cursor publishes no pinned version or checksum for
723
+ // this installer; docs/pr-review.md states what that leaves open.
724
+ " curl --proto '=https' --tlsv1.2 -fsS https://cursor.com/install | bash",
725
+ // The docs name ~/.cursor/bin; the installer currently links `agent` into ~/.local/bin.
726
+ // Both go on the PATH, so the next step finds it wherever the installer puts it.
727
+ ' echo "$HOME/.local/bin" >> "$GITHUB_PATH"',
728
+ ' echo "$HOME/.cursor/bin" >> "$GITHUB_PATH"'
729
+ ].join("\n"),
730
+ [
731
+ "- name: Run Cursor review",
732
+ ` if: ${REVIEW_GATE_CONDITION}`,
733
+ " env:",
734
+ ` CURSOR_API_KEY: \${{ secrets.${SECRET_NAME2} }}`,
735
+ " GH_TOKEN: ${{ github.token }}",
736
+ " run: |",
737
+ // cursor-agent stops at "Workspace Trust Required" without --trust (2026.10.22 on
738
+ // Actions); the folder is this run's own checkout, and forks never get the secret.
739
+ ` agent --trust -p "$(cat <<'${PROMPT_HEREDOC_DELIMITER}'`,
740
+ indentBlock(composePrompt2(input), 4),
741
+ ` ${PROMPT_HEREDOC_DELIMITER}`,
742
+ ' )"'
743
+ ].join("\n")
744
+ ]
745
+ });
551
746
  }
552
747
  var cursorProvider = {
553
748
  id: "cursor",
@@ -585,41 +780,33 @@ function composePrompt3(input) {
585
780
  sections.push(renderFindingsBlockInstruction(input.locale));
586
781
  return sections.join("\n\n---\n\n");
587
782
  }
783
+ var GEMINI_CLI_VERSION = "0.65.0";
588
784
  function buildWorkflowYaml3(input) {
589
- const steps = [
590
- renderSecretGateStep(SECRET_NAME3),
591
- renderRoundGateStep(input.maxRounds),
592
- renderCheckoutStep("steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'"),
593
- [
594
- "- name: Run Gemini review",
595
- " if: steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'",
596
- ` uses: ${pinnedUses("google-github-actions/run-gemini-cli")}`,
597
- " env:",
598
- " GITHUB_TOKEN: ${{ github.token }}",
599
- " with:",
600
- ` gemini_api_key: \${{ secrets.${SECRET_NAME3} }}`,
601
- " prompt: |",
602
- indentBlock(composePrompt3(input), 6)
603
- ].join("\n"),
604
- renderWorkspaceSetupSteps(input.packageManager),
605
- renderVerdictGateStep(input.maxRounds, input.locale)
606
- ];
607
- return [
608
- "name: Gemini Code Review",
609
- "",
610
- renderTriggerBlock(),
611
- "",
612
- renderConcurrencyBlock(),
613
- "",
614
- renderPermissionsBlock(),
615
- "",
616
- "jobs:",
617
- " review:",
618
- " runs-on: ubuntu-latest",
619
- " steps:",
620
- indentBlock(steps.join("\n\n"), 6),
621
- ""
622
- ].join("\n");
785
+ return renderReviewWorkflow(input, {
786
+ name: "Gemini Code Review",
787
+ secretName: SECRET_NAME3,
788
+ // An API key: run-gemini-cli uses OIDC only for Google Cloud workload identity federation.
789
+ idToken: false,
790
+ reviewSteps: [
791
+ renderCheckoutStep(REVIEW_GATE_CONDITION),
792
+ [
793
+ "- name: Run Gemini review",
794
+ ` if: ${REVIEW_GATE_CONDITION}`,
795
+ ` uses: ${pinnedUses("google-github-actions/run-gemini-cli")}`,
796
+ " env:",
797
+ " GITHUB_TOKEN: ${{ github.token }}",
798
+ // Gemini CLI 0.65 refuses to run in a folder it hasn't been told to trust (measured
799
+ // 2026-10-25 on Actions). The folder is this run's own checkout; pull requests from forks
800
+ // never get here, because they get no secret.
801
+ " GEMINI_CLI_TRUST_WORKSPACE: 'true'",
802
+ " with:",
803
+ ` gemini_api_key: \${{ secrets.${SECRET_NAME3} }}`,
804
+ ` gemini_cli_version: '${GEMINI_CLI_VERSION}'`,
805
+ " prompt: |",
806
+ indentBlock(composePrompt3(input), 6)
807
+ ].join("\n")
808
+ ]
809
+ });
623
810
  }
624
811
  var geminiProvider = {
625
812
  id: "gemini",
@@ -658,64 +845,49 @@ function composePrompt4(input) {
658
845
  return sections.join("\n\n---\n\n");
659
846
  }
660
847
  function buildWorkflowYaml4(input) {
661
- const gateCondition = "steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'";
662
- const steps = [
663
- renderSecretGateStep(SECRET_NAME4),
664
- renderRoundGateStep(input.maxRounds),
665
- renderCheckoutStep(gateCondition, ["ref: refs/pull/${{ github.event.pull_request.number }}/merge"]),
666
- [
667
- "- name: Fetch base and head refs for the PR",
668
- ` if: ${gateCondition}`,
669
- " env:",
670
- " PR_BASE_REF: ${{ github.event.pull_request.base.ref }}",
671
- " PR_NUMBER: ${{ github.event.pull_request.number }}",
672
- " run: |",
673
- " # Explicit destinations: the sandboxed review step has no network, so both sides",
674
- " # of the diff must survive as stable local refs (FETCH_HEAD alone is ambiguous).",
675
- " git fetch --no-tags origin \\",
676
- ' "+refs/heads/$PR_BASE_REF:refs/remotes/origin/pr-base" \\',
677
- ' "+refs/pull/$PR_NUMBER/head:refs/remotes/origin/pr-head"'
678
- ].join("\n"),
679
- [
680
- "- name: Run Codex review",
681
- " id: codex-review",
682
- ` if: ${gateCondition}`,
683
- ` uses: ${pinnedUses("openai/codex-action")}`,
684
- " with:",
685
- ` openai-api-key: \${{ secrets.${SECRET_NAME4} }}`,
686
- ' permission-profile: ":read-only"',
687
- " prompt: |",
688
- indentBlock(composePrompt4(input), 6)
689
- ].join("\n"),
690
- [
691
- "- name: Post review comment",
692
- ` if: ${gateCondition}`,
693
- " env:",
694
- " GH_TOKEN: ${{ github.token }}",
695
- " PR_NUMBER: ${{ github.event.pull_request.number }}",
696
- " REVIEW_BODY: ${{ steps.codex-review.outputs.final-message }}",
697
- " run: |",
698
- ' printf %s "$REVIEW_BODY" | gh pr comment "$PR_NUMBER" --body-file -'
699
- ].join("\n"),
700
- renderWorkspaceSetupSteps(input.packageManager),
701
- renderVerdictGateStep(input.maxRounds, input.locale)
702
- ];
703
- return [
704
- "name: GPT Code Review",
705
- "",
706
- renderTriggerBlock(),
707
- "",
708
- renderConcurrencyBlock(),
709
- "",
710
- renderPermissionsBlock(),
711
- "",
712
- "jobs:",
713
- " review:",
714
- " runs-on: ubuntu-latest",
715
- " steps:",
716
- indentBlock(steps.join("\n\n"), 6),
717
- ""
718
- ].join("\n");
848
+ return renderReviewWorkflow(input, {
849
+ name: "GPT Code Review",
850
+ secretName: SECRET_NAME4,
851
+ // An API key: codex-action needs no OIDC token.
852
+ idToken: false,
853
+ reviewSteps: [
854
+ renderCheckoutStep(REVIEW_GATE_CONDITION, ["ref: refs/pull/${{ github.event.pull_request.number }}/merge"]),
855
+ [
856
+ "- name: Fetch base and head refs for the PR",
857
+ ` if: ${REVIEW_GATE_CONDITION}`,
858
+ " env:",
859
+ " PR_BASE_REF: ${{ github.event.pull_request.base.ref }}",
860
+ " PR_NUMBER: ${{ github.event.pull_request.number }}",
861
+ " run: |",
862
+ " # Explicit destinations: the sandboxed review step has no network, so both sides",
863
+ " # of the diff must survive as stable local refs (FETCH_HEAD alone is ambiguous).",
864
+ " git fetch --no-tags origin \\",
865
+ ' "+refs/heads/$PR_BASE_REF:refs/remotes/origin/pr-base" \\',
866
+ ' "+refs/pull/$PR_NUMBER/head:refs/remotes/origin/pr-head"'
867
+ ].join("\n"),
868
+ [
869
+ "- name: Run Codex review",
870
+ " id: codex-review",
871
+ ` if: ${REVIEW_GATE_CONDITION}`,
872
+ ` uses: ${pinnedUses("openai/codex-action")}`,
873
+ " with:",
874
+ ` openai-api-key: \${{ secrets.${SECRET_NAME4} }}`,
875
+ ' permission-profile: ":read-only"',
876
+ " prompt: |",
877
+ indentBlock(composePrompt4(input), 6)
878
+ ].join("\n"),
879
+ [
880
+ "- name: Post review comment",
881
+ ` if: ${REVIEW_GATE_CONDITION}`,
882
+ " env:",
883
+ " GH_TOKEN: ${{ github.token }}",
884
+ " PR_NUMBER: ${{ github.event.pull_request.number }}",
885
+ " REVIEW_BODY: ${{ steps.codex-review.outputs.final-message }}",
886
+ " run: |",
887
+ ' printf %s "$REVIEW_BODY" | gh pr comment "$PR_NUMBER" --body-file -'
888
+ ].join("\n")
889
+ ]
890
+ });
719
891
  }
720
892
  var gptProvider = {
721
893
  id: "gpt",
@@ -1198,6 +1370,39 @@ function buildFsdPolicyNotes(locale, notes) {
1198
1370
  return lines.length === 0 ? "" : [text.heading, ...lines].join("\n");
1199
1371
  }
1200
1372
 
1373
+ // ../templates/dist/agents/module-boundaries.js
1374
+ function buildModuleBoundariesSection(locale, tags) {
1375
+ const { frontend, backend, shared } = tags;
1376
+ if (locale === "ko") {
1377
+ return {
1378
+ id: "module-boundaries",
1379
+ heading: "\uBAA8\uB4C8 \uACBD\uACC4",
1380
+ body: [
1381
+ "\uB8E8\uD2B8 ESLint \uC124\uC815\uC758 `@nx/enforce-module-boundaries` \uADDC\uCE59\uC774 \uD504\uB85C\uC81D\uD2B8 \uD0DC\uADF8\uB85C \uD504\uB860\uD2B8\uC5D4\uB4DC\uC640 \uBC31\uC5D4\uB4DC\uB97C \uB098\uB208\uB2E4:",
1382
+ `- \`${frontend}\` \uD504\uB85C\uC81D\uD2B8\uB294 \`${backend}\` \uD504\uB85C\uC81D\uD2B8\uB97C import\uD558\uC9C0 \uC54A\uACE0, \uADF8 \uBC18\uB300\uB3C4 \uB9C8\uCC2C\uAC00\uC9C0\uB2E4.`,
1383
+ `- \`${shared}\` \uD504\uB85C\uC81D\uD2B8(shared-types \uB77C\uC774\uBE0C\uB7EC\uB9AC \uB4F1)\uB294 \uC5B4\uB290 \uCABD\uB3C4 import\uD558\uC9C0 \uC54A\uB294\uB2E4.`,
1384
+ "- \uC774 \uD0DC\uADF8\uAC00 \uD558\uB098\uB3C4 \uC5C6\uB294 \uD504\uB85C\uC81D\uD2B8\uB294 \uADDC\uCE59 \uBC16\uC5D0 \uC788\uB2E4. \uB77C\uC774\uBE0C\uB7EC\uB9AC\uB97C \uB9CC\uB4E4 \uB54C\uB294 \uBC14\uB85C \uC790\uAE30 \uCABD \uD0DC\uADF8\uB97C \uBD99\uC778\uB2E4:",
1385
+ ` \`nx g @nx/js:lib libs/<name> --tags=${shared}\` (\uD504\uB860\uD2B8\uC5D4\uB4DC \uC804\uC6A9\uC774\uBA74 \`${frontend}\`, \uBC31\uC5D4\uB4DC \uC804\uC6A9\uC774\uBA74 \`${backend}\`).`,
1386
+ `import\uB97C \uD1B5\uACFC\uC2DC\uD0A4\uB824\uACE0 \uD0DC\uADF8\uB97C \uC9C0\uC6B0\uAC70\uB098 \`depConstraints\`\uB97C \uB290\uC2A8\uD558\uAC8C \uD558\uC9C0 \uC54A\uB294\uB2E4. \uD568\uAED8 \uC4F0\uB294 \uCF54\uB4DC\uB294 \`${shared}\``,
1387
+ "\uB77C\uC774\uBE0C\uB7EC\uB9AC\uB85C \uC62E\uAE34\uB2E4."
1388
+ ].join("\n")
1389
+ };
1390
+ }
1391
+ return {
1392
+ id: "module-boundaries",
1393
+ heading: "Module Boundaries",
1394
+ body: [
1395
+ "The root ESLint config's `@nx/enforce-module-boundaries` rule keeps the frontend and the backend apart by project tag:",
1396
+ `- \`${frontend}\` projects never import \`${backend}\` projects, and the other way round.`,
1397
+ `- \`${shared}\` projects (such as the shared-types library) import neither side.`,
1398
+ "- A project with none of these tags is outside the rule. When you create a library, give it its side right away:",
1399
+ ` \`nx g @nx/js:lib libs/<name> --tags=${shared}\` (\`${frontend}\` or \`${backend}\` for code only one side uses).`,
1400
+ `Never remove a tag or loosen the \`depConstraints\` to make an import pass; move the shared code into a \`${shared}\``,
1401
+ "library instead."
1402
+ ].join("\n")
1403
+ };
1404
+ }
1405
+
1201
1406
  // ../templates/dist/fsd/fsd-eslint.js
1202
1407
  var FSD_ESLINT_MODULE = "@clearlydev/nx-archweave/eslint";
1203
1408
  function buildFsdEslintImportLine() {
@@ -1821,6 +2026,11 @@ function composeAgentRules(input) {
1821
2026
 
1822
2027
  ${notes}` } : section;
1823
2028
  });
2029
+ if (input.moduleBoundaries !== void 0 && input.sections === void 0) {
2030
+ const anchor = sections.findIndex((section) => section.id === FSD_AGENT_SECTION_ID);
2031
+ const at = (anchor === -1 ? sections.findIndex((section) => section.id === "code-structure") : anchor) + 1;
2032
+ sections.splice(at, 0, buildModuleBoundariesSection(input.locale, input.moduleBoundaries));
2033
+ }
1824
2034
  const content = renderSections(sections);
1825
2035
  return input.files.map((filePath) => ({ filePath, content }));
1826
2036
  }
@@ -1906,933 +2116,8 @@ function resolveDryRun(options) {
1906
2116
  // src/generators/shared/frontend-app.ts
1907
2117
  import { getProjects } from "@nx/devkit";
1908
2118
 
1909
- // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
1910
- function createScanner(text, ignoreTrivia = false) {
1911
- const len = text.length;
1912
- let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
1913
- function scanHexDigits(count, exact) {
1914
- let digits = 0;
1915
- let value2 = 0;
1916
- while (digits < count || !exact) {
1917
- let ch = text.charCodeAt(pos);
1918
- if (ch >= 48 && ch <= 57) {
1919
- value2 = value2 * 16 + ch - 48;
1920
- } else if (ch >= 65 && ch <= 70) {
1921
- value2 = value2 * 16 + ch - 65 + 10;
1922
- } else if (ch >= 97 && ch <= 102) {
1923
- value2 = value2 * 16 + ch - 97 + 10;
1924
- } else {
1925
- break;
1926
- }
1927
- pos++;
1928
- digits++;
1929
- }
1930
- if (digits < count) {
1931
- value2 = -1;
1932
- }
1933
- return value2;
1934
- }
1935
- function setPosition(newPosition) {
1936
- pos = newPosition;
1937
- value = "";
1938
- tokenOffset = 0;
1939
- token = 16;
1940
- scanError = 0;
1941
- }
1942
- function scanNumber() {
1943
- let start = pos;
1944
- if (text.charCodeAt(pos) === 48) {
1945
- pos++;
1946
- } else {
1947
- pos++;
1948
- while (pos < text.length && isDigit(text.charCodeAt(pos))) {
1949
- pos++;
1950
- }
1951
- }
1952
- if (pos < text.length && text.charCodeAt(pos) === 46) {
1953
- pos++;
1954
- if (pos < text.length && isDigit(text.charCodeAt(pos))) {
1955
- pos++;
1956
- while (pos < text.length && isDigit(text.charCodeAt(pos))) {
1957
- pos++;
1958
- }
1959
- } else {
1960
- scanError = 3;
1961
- return text.substring(start, pos);
1962
- }
1963
- }
1964
- let end = pos;
1965
- if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
1966
- pos++;
1967
- if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
1968
- pos++;
1969
- }
1970
- if (pos < text.length && isDigit(text.charCodeAt(pos))) {
1971
- pos++;
1972
- while (pos < text.length && isDigit(text.charCodeAt(pos))) {
1973
- pos++;
1974
- }
1975
- end = pos;
1976
- } else {
1977
- scanError = 3;
1978
- }
1979
- }
1980
- return text.substring(start, end);
1981
- }
1982
- function scanString() {
1983
- let result = "", start = pos;
1984
- while (true) {
1985
- if (pos >= len) {
1986
- result += text.substring(start, pos);
1987
- scanError = 2;
1988
- break;
1989
- }
1990
- const ch = text.charCodeAt(pos);
1991
- if (ch === 34) {
1992
- result += text.substring(start, pos);
1993
- pos++;
1994
- break;
1995
- }
1996
- if (ch === 92) {
1997
- result += text.substring(start, pos);
1998
- pos++;
1999
- if (pos >= len) {
2000
- scanError = 2;
2001
- break;
2002
- }
2003
- const ch2 = text.charCodeAt(pos++);
2004
- switch (ch2) {
2005
- case 34:
2006
- result += '"';
2007
- break;
2008
- case 92:
2009
- result += "\\";
2010
- break;
2011
- case 47:
2012
- result += "/";
2013
- break;
2014
- case 98:
2015
- result += "\b";
2016
- break;
2017
- case 102:
2018
- result += "\f";
2019
- break;
2020
- case 110:
2021
- result += "\n";
2022
- break;
2023
- case 114:
2024
- result += "\r";
2025
- break;
2026
- case 116:
2027
- result += " ";
2028
- break;
2029
- case 117:
2030
- const ch3 = scanHexDigits(4, true);
2031
- if (ch3 >= 0) {
2032
- result += String.fromCharCode(ch3);
2033
- } else {
2034
- scanError = 4;
2035
- }
2036
- break;
2037
- default:
2038
- scanError = 5;
2039
- }
2040
- start = pos;
2041
- continue;
2042
- }
2043
- if (ch >= 0 && ch <= 31) {
2044
- if (isLineBreak(ch)) {
2045
- result += text.substring(start, pos);
2046
- scanError = 2;
2047
- break;
2048
- } else {
2049
- scanError = 6;
2050
- }
2051
- }
2052
- pos++;
2053
- }
2054
- return result;
2055
- }
2056
- function scanNext() {
2057
- value = "";
2058
- scanError = 0;
2059
- tokenOffset = pos;
2060
- lineStartOffset = lineNumber;
2061
- prevTokenLineStartOffset = tokenLineStartOffset;
2062
- if (pos >= len) {
2063
- tokenOffset = len;
2064
- return token = 17;
2065
- }
2066
- let code = text.charCodeAt(pos);
2067
- if (isWhiteSpace(code)) {
2068
- do {
2069
- pos++;
2070
- value += String.fromCharCode(code);
2071
- code = text.charCodeAt(pos);
2072
- } while (isWhiteSpace(code));
2073
- return token = 15;
2074
- }
2075
- if (isLineBreak(code)) {
2076
- pos++;
2077
- value += String.fromCharCode(code);
2078
- if (code === 13 && text.charCodeAt(pos) === 10) {
2079
- pos++;
2080
- value += "\n";
2081
- }
2082
- lineNumber++;
2083
- tokenLineStartOffset = pos;
2084
- return token = 14;
2085
- }
2086
- switch (code) {
2087
- // tokens: []{}:,
2088
- case 123:
2089
- pos++;
2090
- return token = 1;
2091
- case 125:
2092
- pos++;
2093
- return token = 2;
2094
- case 91:
2095
- pos++;
2096
- return token = 3;
2097
- case 93:
2098
- pos++;
2099
- return token = 4;
2100
- case 58:
2101
- pos++;
2102
- return token = 6;
2103
- case 44:
2104
- pos++;
2105
- return token = 5;
2106
- // strings
2107
- case 34:
2108
- pos++;
2109
- value = scanString();
2110
- return token = 10;
2111
- // comments
2112
- case 47:
2113
- const start = pos - 1;
2114
- if (text.charCodeAt(pos + 1) === 47) {
2115
- pos += 2;
2116
- while (pos < len) {
2117
- if (isLineBreak(text.charCodeAt(pos))) {
2118
- break;
2119
- }
2120
- pos++;
2121
- }
2122
- value = text.substring(start, pos);
2123
- return token = 12;
2124
- }
2125
- if (text.charCodeAt(pos + 1) === 42) {
2126
- pos += 2;
2127
- const safeLength = len - 1;
2128
- let commentClosed = false;
2129
- while (pos < safeLength) {
2130
- const ch = text.charCodeAt(pos);
2131
- if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
2132
- pos += 2;
2133
- commentClosed = true;
2134
- break;
2135
- }
2136
- pos++;
2137
- if (isLineBreak(ch)) {
2138
- if (ch === 13 && text.charCodeAt(pos) === 10) {
2139
- pos++;
2140
- }
2141
- lineNumber++;
2142
- tokenLineStartOffset = pos;
2143
- }
2144
- }
2145
- if (!commentClosed) {
2146
- pos++;
2147
- scanError = 1;
2148
- }
2149
- value = text.substring(start, pos);
2150
- return token = 13;
2151
- }
2152
- value += String.fromCharCode(code);
2153
- pos++;
2154
- return token = 16;
2155
- // numbers
2156
- case 45:
2157
- value += String.fromCharCode(code);
2158
- pos++;
2159
- if (pos === len || !isDigit(text.charCodeAt(pos))) {
2160
- return token = 16;
2161
- }
2162
- // found a minus, followed by a number so
2163
- // we fall through to proceed with scanning
2164
- // numbers
2165
- case 48:
2166
- case 49:
2167
- case 50:
2168
- case 51:
2169
- case 52:
2170
- case 53:
2171
- case 54:
2172
- case 55:
2173
- case 56:
2174
- case 57:
2175
- value += scanNumber();
2176
- return token = 11;
2177
- // literals and unknown symbols
2178
- default:
2179
- while (pos < len && isUnknownContentCharacter(code)) {
2180
- pos++;
2181
- code = text.charCodeAt(pos);
2182
- }
2183
- if (tokenOffset !== pos) {
2184
- value = text.substring(tokenOffset, pos);
2185
- switch (value) {
2186
- case "true":
2187
- return token = 8;
2188
- case "false":
2189
- return token = 9;
2190
- case "null":
2191
- return token = 7;
2192
- }
2193
- return token = 16;
2194
- }
2195
- value += String.fromCharCode(code);
2196
- pos++;
2197
- return token = 16;
2198
- }
2199
- }
2200
- function isUnknownContentCharacter(code) {
2201
- if (isWhiteSpace(code) || isLineBreak(code)) {
2202
- return false;
2203
- }
2204
- switch (code) {
2205
- case 125:
2206
- case 93:
2207
- case 123:
2208
- case 91:
2209
- case 34:
2210
- case 58:
2211
- case 44:
2212
- case 47:
2213
- return false;
2214
- }
2215
- return true;
2216
- }
2217
- function scanNextNonTrivia() {
2218
- let result;
2219
- do {
2220
- result = scanNext();
2221
- } while (result >= 12 && result <= 15);
2222
- return result;
2223
- }
2224
- return {
2225
- setPosition,
2226
- getPosition: () => pos,
2227
- scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
2228
- getToken: () => token,
2229
- getTokenValue: () => value,
2230
- getTokenOffset: () => tokenOffset,
2231
- getTokenLength: () => pos - tokenOffset,
2232
- getTokenStartLine: () => lineStartOffset,
2233
- getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
2234
- getTokenError: () => scanError
2235
- };
2236
- }
2237
- function isWhiteSpace(ch) {
2238
- return ch === 32 || ch === 9;
2239
- }
2240
- function isLineBreak(ch) {
2241
- return ch === 10 || ch === 13;
2242
- }
2243
- function isDigit(ch) {
2244
- return ch >= 48 && ch <= 57;
2245
- }
2246
- var CharacterCodes;
2247
- (function(CharacterCodes2) {
2248
- CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
2249
- CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
2250
- CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
2251
- CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
2252
- CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
2253
- CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
2254
- CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
2255
- CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
2256
- CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
2257
- CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
2258
- CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
2259
- CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
2260
- CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
2261
- CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
2262
- CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
2263
- CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
2264
- CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
2265
- CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
2266
- CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
2267
- CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
2268
- CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
2269
- CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
2270
- CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
2271
- CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
2272
- CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
2273
- CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
2274
- CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
2275
- CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
2276
- CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
2277
- CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
2278
- CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
2279
- CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
2280
- CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
2281
- CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
2282
- CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
2283
- CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
2284
- CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
2285
- CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
2286
- CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
2287
- CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
2288
- CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
2289
- CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
2290
- CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
2291
- CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
2292
- CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
2293
- CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
2294
- CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
2295
- CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
2296
- CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
2297
- CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
2298
- CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
2299
- CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
2300
- CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
2301
- CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
2302
- CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
2303
- CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
2304
- CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
2305
- CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
2306
- CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
2307
- CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
2308
- CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
2309
- CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
2310
- CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
2311
- CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
2312
- CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
2313
- CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
2314
- CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
2315
- CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
2316
- CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
2317
- CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
2318
- CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
2319
- CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
2320
- CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
2321
- CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
2322
- CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
2323
- CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
2324
- CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
2325
- CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
2326
- CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
2327
- CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
2328
- })(CharacterCodes || (CharacterCodes = {}));
2329
-
2330
- // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/string-intern.js
2331
- var cachedSpaces = new Array(20).fill(0).map((_, index) => {
2332
- return " ".repeat(index);
2333
- });
2334
- var maxCachedValues = 200;
2335
- var cachedBreakLinesWithSpaces = {
2336
- " ": {
2337
- "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
2338
- return "\n" + " ".repeat(index);
2339
- }),
2340
- "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
2341
- return "\r" + " ".repeat(index);
2342
- }),
2343
- "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
2344
- return "\r\n" + " ".repeat(index);
2345
- })
2346
- },
2347
- " ": {
2348
- "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
2349
- return "\n" + " ".repeat(index);
2350
- }),
2351
- "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
2352
- return "\r" + " ".repeat(index);
2353
- }),
2354
- "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
2355
- return "\r\n" + " ".repeat(index);
2356
- })
2357
- }
2358
- };
2359
-
2360
- // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/parser.js
2361
- var ParseOptions;
2362
- (function(ParseOptions2) {
2363
- ParseOptions2.DEFAULT = {
2364
- allowTrailingComma: false
2365
- };
2366
- })(ParseOptions || (ParseOptions = {}));
2367
- function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
2368
- let currentParent = { type: "array", offset: -1, length: -1, children: [], parent: void 0 };
2369
- function ensurePropertyComplete(endOffset) {
2370
- if (currentParent.type === "property") {
2371
- currentParent.length = endOffset - currentParent.offset;
2372
- currentParent = currentParent.parent;
2373
- }
2374
- }
2375
- function onValue(valueNode) {
2376
- currentParent.children.push(valueNode);
2377
- return valueNode;
2378
- }
2379
- const visitor = {
2380
- onObjectBegin: (offset) => {
2381
- currentParent = onValue({ type: "object", offset, length: -1, parent: currentParent, children: [] });
2382
- },
2383
- onObjectProperty: (name, offset, length) => {
2384
- currentParent = onValue({ type: "property", offset, length: -1, parent: currentParent, children: [] });
2385
- currentParent.children.push({ type: "string", value: name, offset, length, parent: currentParent });
2386
- },
2387
- onObjectEnd: (offset, length) => {
2388
- ensurePropertyComplete(offset + length);
2389
- currentParent.length = offset + length - currentParent.offset;
2390
- currentParent = currentParent.parent;
2391
- ensurePropertyComplete(offset + length);
2392
- },
2393
- onArrayBegin: (offset, length) => {
2394
- currentParent = onValue({ type: "array", offset, length: -1, parent: currentParent, children: [] });
2395
- },
2396
- onArrayEnd: (offset, length) => {
2397
- currentParent.length = offset + length - currentParent.offset;
2398
- currentParent = currentParent.parent;
2399
- ensurePropertyComplete(offset + length);
2400
- },
2401
- onLiteralValue: (value, offset, length) => {
2402
- onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
2403
- ensurePropertyComplete(offset + length);
2404
- },
2405
- onSeparator: (sep, offset, length) => {
2406
- if (currentParent.type === "property") {
2407
- if (sep === ":") {
2408
- currentParent.colonOffset = offset;
2409
- } else if (sep === ",") {
2410
- ensurePropertyComplete(offset);
2411
- }
2412
- }
2413
- },
2414
- onError: (error, offset, length) => {
2415
- errors.push({ error, offset, length });
2416
- }
2417
- };
2418
- visit(text, visitor, options);
2419
- const result = currentParent.children[0];
2420
- if (result) {
2421
- delete result.parent;
2422
- }
2423
- return result;
2424
- }
2425
- function findNodeAtLocation(root, path) {
2426
- if (!root) {
2427
- return void 0;
2428
- }
2429
- let node = root;
2430
- for (let segment of path) {
2431
- if (typeof segment === "string") {
2432
- if (node.type !== "object" || !Array.isArray(node.children)) {
2433
- return void 0;
2434
- }
2435
- let found = false;
2436
- for (const propertyNode of node.children) {
2437
- if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
2438
- node = propertyNode.children[1];
2439
- found = true;
2440
- break;
2441
- }
2442
- }
2443
- if (!found) {
2444
- return void 0;
2445
- }
2446
- } else {
2447
- const index = segment;
2448
- if (node.type !== "array" || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {
2449
- return void 0;
2450
- }
2451
- node = node.children[index];
2452
- }
2453
- }
2454
- return node;
2455
- }
2456
- function visit(text, visitor, options = ParseOptions.DEFAULT) {
2457
- const _scanner = createScanner(text, false);
2458
- const _jsonPath = [];
2459
- let suppressedCallbacks = 0;
2460
- function toNoArgVisit(visitFunction) {
2461
- return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
2462
- }
2463
- function toOneArgVisit(visitFunction) {
2464
- return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
2465
- }
2466
- function toOneArgVisitWithPath(visitFunction) {
2467
- return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
2468
- }
2469
- function toBeginVisit(visitFunction) {
2470
- return visitFunction ? () => {
2471
- if (suppressedCallbacks > 0) {
2472
- suppressedCallbacks++;
2473
- } else {
2474
- let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice());
2475
- if (cbReturn === false) {
2476
- suppressedCallbacks = 1;
2477
- }
2478
- }
2479
- } : () => true;
2480
- }
2481
- function toEndVisit(visitFunction) {
2482
- return visitFunction ? () => {
2483
- if (suppressedCallbacks > 0) {
2484
- suppressedCallbacks--;
2485
- }
2486
- if (suppressedCallbacks === 0) {
2487
- visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
2488
- }
2489
- } : () => true;
2490
- }
2491
- const onObjectBegin = toBeginVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisitWithPath(visitor.onObjectProperty), onObjectEnd = toEndVisit(visitor.onObjectEnd), onArrayBegin = toBeginVisit(visitor.onArrayBegin), onArrayEnd = toEndVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisitWithPath(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
2492
- const disallowComments = options && options.disallowComments;
2493
- const allowTrailingComma = options && options.allowTrailingComma;
2494
- function scanNext() {
2495
- while (true) {
2496
- const token = _scanner.scan();
2497
- switch (_scanner.getTokenError()) {
2498
- case 4:
2499
- handleError(
2500
- 14
2501
- /* ParseErrorCode.InvalidUnicode */
2502
- );
2503
- break;
2504
- case 5:
2505
- handleError(
2506
- 15
2507
- /* ParseErrorCode.InvalidEscapeCharacter */
2508
- );
2509
- break;
2510
- case 3:
2511
- handleError(
2512
- 13
2513
- /* ParseErrorCode.UnexpectedEndOfNumber */
2514
- );
2515
- break;
2516
- case 1:
2517
- if (!disallowComments) {
2518
- handleError(
2519
- 11
2520
- /* ParseErrorCode.UnexpectedEndOfComment */
2521
- );
2522
- }
2523
- break;
2524
- case 2:
2525
- handleError(
2526
- 12
2527
- /* ParseErrorCode.UnexpectedEndOfString */
2528
- );
2529
- break;
2530
- case 6:
2531
- handleError(
2532
- 16
2533
- /* ParseErrorCode.InvalidCharacter */
2534
- );
2535
- break;
2536
- }
2537
- switch (token) {
2538
- case 12:
2539
- case 13:
2540
- if (disallowComments) {
2541
- handleError(
2542
- 10
2543
- /* ParseErrorCode.InvalidCommentToken */
2544
- );
2545
- } else {
2546
- onComment();
2547
- }
2548
- break;
2549
- case 16:
2550
- handleError(
2551
- 1
2552
- /* ParseErrorCode.InvalidSymbol */
2553
- );
2554
- break;
2555
- case 15:
2556
- case 14:
2557
- break;
2558
- default:
2559
- return token;
2560
- }
2561
- }
2562
- }
2563
- function handleError(error, skipUntilAfter = [], skipUntil = []) {
2564
- onError(error);
2565
- if (skipUntilAfter.length + skipUntil.length > 0) {
2566
- let token = _scanner.getToken();
2567
- while (token !== 17) {
2568
- if (skipUntilAfter.indexOf(token) !== -1) {
2569
- scanNext();
2570
- break;
2571
- } else if (skipUntil.indexOf(token) !== -1) {
2572
- break;
2573
- }
2574
- token = scanNext();
2575
- }
2576
- }
2577
- }
2578
- function parseString(isValue) {
2579
- const value = _scanner.getTokenValue();
2580
- if (isValue) {
2581
- onLiteralValue(value);
2582
- } else {
2583
- onObjectProperty(value);
2584
- _jsonPath.push(value);
2585
- }
2586
- scanNext();
2587
- return true;
2588
- }
2589
- function parseLiteral() {
2590
- switch (_scanner.getToken()) {
2591
- case 11:
2592
- const tokenValue = _scanner.getTokenValue();
2593
- let value = Number(tokenValue);
2594
- if (isNaN(value)) {
2595
- handleError(
2596
- 2
2597
- /* ParseErrorCode.InvalidNumberFormat */
2598
- );
2599
- value = 0;
2600
- }
2601
- onLiteralValue(value);
2602
- break;
2603
- case 7:
2604
- onLiteralValue(null);
2605
- break;
2606
- case 8:
2607
- onLiteralValue(true);
2608
- break;
2609
- case 9:
2610
- onLiteralValue(false);
2611
- break;
2612
- default:
2613
- return false;
2614
- }
2615
- scanNext();
2616
- return true;
2617
- }
2618
- function parseProperty() {
2619
- if (_scanner.getToken() !== 10) {
2620
- handleError(3, [], [
2621
- 2,
2622
- 5
2623
- /* SyntaxKind.CommaToken */
2624
- ]);
2625
- return false;
2626
- }
2627
- parseString(false);
2628
- if (_scanner.getToken() === 6) {
2629
- onSeparator(":");
2630
- scanNext();
2631
- if (!parseValue()) {
2632
- handleError(4, [], [
2633
- 2,
2634
- 5
2635
- /* SyntaxKind.CommaToken */
2636
- ]);
2637
- }
2638
- } else {
2639
- handleError(5, [], [
2640
- 2,
2641
- 5
2642
- /* SyntaxKind.CommaToken */
2643
- ]);
2644
- }
2645
- _jsonPath.pop();
2646
- return true;
2647
- }
2648
- function parseObject() {
2649
- onObjectBegin();
2650
- scanNext();
2651
- let needsComma = false;
2652
- while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
2653
- if (_scanner.getToken() === 5) {
2654
- if (!needsComma) {
2655
- handleError(4, [], []);
2656
- }
2657
- onSeparator(",");
2658
- scanNext();
2659
- if (_scanner.getToken() === 2 && allowTrailingComma) {
2660
- break;
2661
- }
2662
- } else if (needsComma) {
2663
- handleError(6, [], []);
2664
- }
2665
- if (!parseProperty()) {
2666
- handleError(4, [], [
2667
- 2,
2668
- 5
2669
- /* SyntaxKind.CommaToken */
2670
- ]);
2671
- }
2672
- needsComma = true;
2673
- }
2674
- onObjectEnd();
2675
- if (_scanner.getToken() !== 2) {
2676
- handleError(7, [
2677
- 2
2678
- /* SyntaxKind.CloseBraceToken */
2679
- ], []);
2680
- } else {
2681
- scanNext();
2682
- }
2683
- return true;
2684
- }
2685
- function parseArray() {
2686
- onArrayBegin();
2687
- scanNext();
2688
- let isFirstElement = true;
2689
- let needsComma = false;
2690
- while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
2691
- if (_scanner.getToken() === 5) {
2692
- if (!needsComma) {
2693
- handleError(4, [], []);
2694
- }
2695
- onSeparator(",");
2696
- scanNext();
2697
- if (_scanner.getToken() === 4 && allowTrailingComma) {
2698
- break;
2699
- }
2700
- } else if (needsComma) {
2701
- handleError(6, [], []);
2702
- }
2703
- if (isFirstElement) {
2704
- _jsonPath.push(0);
2705
- isFirstElement = false;
2706
- } else {
2707
- _jsonPath[_jsonPath.length - 1]++;
2708
- }
2709
- if (!parseValue()) {
2710
- handleError(4, [], [
2711
- 4,
2712
- 5
2713
- /* SyntaxKind.CommaToken */
2714
- ]);
2715
- }
2716
- needsComma = true;
2717
- }
2718
- onArrayEnd();
2719
- if (!isFirstElement) {
2720
- _jsonPath.pop();
2721
- }
2722
- if (_scanner.getToken() !== 4) {
2723
- handleError(8, [
2724
- 4
2725
- /* SyntaxKind.CloseBracketToken */
2726
- ], []);
2727
- } else {
2728
- scanNext();
2729
- }
2730
- return true;
2731
- }
2732
- function parseValue() {
2733
- switch (_scanner.getToken()) {
2734
- case 3:
2735
- return parseArray();
2736
- case 1:
2737
- return parseObject();
2738
- case 10:
2739
- return parseString(true);
2740
- default:
2741
- return parseLiteral();
2742
- }
2743
- }
2744
- scanNext();
2745
- if (_scanner.getToken() === 17) {
2746
- if (options.allowEmptyContent) {
2747
- return true;
2748
- }
2749
- handleError(4, [], []);
2750
- return false;
2751
- }
2752
- if (!parseValue()) {
2753
- handleError(4, [], []);
2754
- return false;
2755
- }
2756
- if (_scanner.getToken() !== 17) {
2757
- handleError(9, [], []);
2758
- }
2759
- return true;
2760
- }
2761
- function getNodeType(value) {
2762
- switch (typeof value) {
2763
- case "boolean":
2764
- return "boolean";
2765
- case "number":
2766
- return "number";
2767
- case "string":
2768
- return "string";
2769
- case "object": {
2770
- if (!value) {
2771
- return "null";
2772
- } else if (Array.isArray(value)) {
2773
- return "array";
2774
- }
2775
- return "object";
2776
- }
2777
- default:
2778
- return "null";
2779
- }
2780
- }
2781
-
2782
- // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/main.js
2783
- var ScanError;
2784
- (function(ScanError2) {
2785
- ScanError2[ScanError2["None"] = 0] = "None";
2786
- ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
2787
- ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
2788
- ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
2789
- ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
2790
- ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
2791
- ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
2792
- })(ScanError || (ScanError = {}));
2793
- var SyntaxKind;
2794
- (function(SyntaxKind2) {
2795
- SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
2796
- SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
2797
- SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
2798
- SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
2799
- SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
2800
- SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
2801
- SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
2802
- SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
2803
- SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
2804
- SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
2805
- SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
2806
- SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
2807
- SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
2808
- SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
2809
- SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
2810
- SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
2811
- SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
2812
- })(SyntaxKind || (SyntaxKind = {}));
2813
- var parseTree2 = parseTree;
2814
- var findNodeAtLocation2 = findNodeAtLocation;
2815
- var ParseErrorCode;
2816
- (function(ParseErrorCode2) {
2817
- ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
2818
- ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
2819
- ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
2820
- ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
2821
- ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
2822
- ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
2823
- ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
2824
- ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
2825
- ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
2826
- ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
2827
- ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
2828
- ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
2829
- ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
2830
- ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
2831
- ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
2832
- ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
2833
- })(ParseErrorCode || (ParseErrorCode = {}));
2834
-
2835
2119
  // src/generators/shared/json-edit.ts
2120
+ import { findNodeAtLocation, parseTree } from "jsonc-parser";
2836
2121
  function detectIndent(raw) {
2837
2122
  for (const line of raw.split("\n")) {
2838
2123
  const match = /^(\t+| +)/.exec(line);
@@ -2890,14 +2175,14 @@ function insertProperty(raw, object, key, value, style) {
2890
2175
  }
2891
2176
  function setJsonValue(raw, path, value) {
2892
2177
  const style = styleOf(raw);
2893
- const root = parseTree2(raw);
2178
+ const root = parseTree(raw);
2894
2179
  if (root === void 0) throw new Error("setJsonValue: not a JSON document");
2895
- const existing = findNodeAtLocation2(root, path);
2180
+ const existing = findNodeAtLocation(root, path);
2896
2181
  if (existing !== void 0) {
2897
2182
  return splice(raw, existing.offset, existing.offset + existing.length, renderValue(value, lineIndentAt(raw, existing.offset), style));
2898
2183
  }
2899
2184
  for (let depth = path.length - 1; depth >= 0; depth--) {
2900
- const parent = depth === 0 ? root : findNodeAtLocation2(root, path.slice(0, depth));
2185
+ const parent = depth === 0 ? root : findNodeAtLocation(root, path.slice(0, depth));
2901
2186
  if (parent === void 0) continue;
2902
2187
  if (parent.type !== "object") throw new Error(`setJsonValue: ${path.slice(0, depth).join(".") || "the root"} is not an object`);
2903
2188
  return insertProperty(raw, parent, path[depth], nest(path.slice(depth + 1), value), style);
@@ -2906,8 +2191,8 @@ function setJsonValue(raw, path, value) {
2906
2191
  }
2907
2192
  function appendJsonArrayItem(raw, path, item) {
2908
2193
  const style = styleOf(raw);
2909
- const root = parseTree2(raw);
2910
- const array = root === void 0 ? void 0 : findNodeAtLocation2(root, path);
2194
+ const root = parseTree(raw);
2195
+ const array = root === void 0 ? void 0 : findNodeAtLocation(root, path);
2911
2196
  if (array === void 0) return setJsonValue(raw, path, [item]);
2912
2197
  if (array.type !== "array") throw new Error(`appendJsonArrayItem: ${path.join(".")} is not an array`);
2913
2198
  const items = array.children ?? [];
@@ -3361,6 +2646,7 @@ function renderAddAgentRulesReport(report) {
3361
2646
 
3362
2647
  // src/generators/add-review/render.ts
3363
2648
  var DEPENDABOT_PATH = ".github/dependabot.yml";
2649
+ var PROVIDER_STATUS_URL = "https://github.com/clearlydev/nx-archweave/blob/main/docs/pr-review.md#provider-status";
3364
2650
  function renderLineDiff(existing, generated) {
3365
2651
  const a = existing.split("\n");
3366
2652
  const b = generated.split("\n");
@@ -3458,6 +2744,10 @@ function renderAddReviewReport(report) {
3458
2744
  }
3459
2745
  lines.push("");
3460
2746
  lines.push(`Note: the review workflow stays green-skipped until you register the ${report.requiredSecretName} secret.`);
2747
+ if (report.betaProvider !== void 0) {
2748
+ lines.push(`Note: the ${report.betaProvider} provider is in beta \u2014 its workflow hasn't finished a review end to end on`);
2749
+ lines.push(`GitHub Actions yet. Status, costs and known issues: ${PROVIDER_STATUS_URL}`);
2750
+ }
3461
2751
  lines.push("Note: this workflow runs with elevated permissions only after it is merged to the default branch \u2014");
3462
2752
  lines.push("merging is the first real validation.");
3463
2753
  return lines.join("\n");
@@ -3525,6 +2815,10 @@ function resolveFsdStructure(config) {
3525
2815
  const frontend = config?.["frontend"];
3526
2816
  return typeof frontend === "string" && frontend !== "none";
3527
2817
  }
2818
+ function resolveModuleBoundaries(config) {
2819
+ const backend = config?.["backend"];
2820
+ return backend === "express" || backend === "nest" ? readBoundaryTags(config) : void 0;
2821
+ }
3528
2822
  var POLICY_KEYS = ["preset", "sliceGroups", "sharedPublicApi", "testFiles"];
3529
2823
  function resolveFsdPolicyNotes(config) {
3530
2824
  const fsd = config?.["fsd"];
@@ -3532,14 +2826,22 @@ function resolveFsdPolicyNotes(config) {
3532
2826
  const policy = resolveFsdPolicy(fsd);
3533
2827
  return { sliceGroups: policy.sliceGroups !== false, sharedPublicApi: policy.sharedPublicApi, testFiles: policy.testFiles !== false };
3534
2828
  }
3535
- function runAddAgentRules(tree, options, { recordHosts = true, fsdStructure } = {}) {
2829
+ function runAddAgentRules(tree, options, { recordHosts = true, fsdStructure, moduleBoundaries } = {}) {
3536
2830
  const config = readToolkitConfig(tree);
3537
2831
  const hosts = resolveAiHostsOption(options.hosts, config);
3538
2832
  const files = rulesFilesFor(hosts);
3539
2833
  const locale = resolveLocaleOption(options.locale, config);
3540
2834
  const teamRules = resolveTeamRules(options.teamRules, config);
3541
2835
  const dryRun = options.dryRun ?? false;
3542
- const composed = composeAgentRules({ files, locale, teamRules, fsdStructure: fsdStructure ?? resolveFsdStructure(config), fsdPolicy: resolveFsdPolicyNotes(config) });
2836
+ const boundaries = moduleBoundaries === void 0 ? resolveModuleBoundaries(config) : moduleBoundaries ?? void 0;
2837
+ const composed = composeAgentRules({
2838
+ files,
2839
+ locale,
2840
+ teamRules,
2841
+ fsdStructure: fsdStructure ?? resolveFsdStructure(config),
2842
+ fsdPolicy: resolveFsdPolicyNotes(config),
2843
+ ...boundaries !== void 0 ? { moduleBoundaries: boundaries } : {}
2844
+ });
3543
2845
  const results = composed.map(({ filePath, content }) => {
3544
2846
  if (!validateAgentRules(content, teamRules ? ["team-rules"] : [])) {
3545
2847
  throw new Error(
@@ -3691,6 +2993,7 @@ function deepEqual(a, b) {
3691
2993
  return aKeys.every((key) => deepEqual(a[key], b[key]));
3692
2994
  }
3693
2995
  var PROVIDERS = ["claude", "gemini", "gpt", "cursor"];
2996
+ var BETA_PROVIDERS = ["gemini", "gpt", "cursor"];
3694
2997
  var MODES = ["fast", "standard", "thorough"];
3695
2998
  function recordedReview(config) {
3696
2999
  const review = config?.["review"];
@@ -3710,9 +3013,10 @@ function runAddReview(tree, options) {
3710
3013
  const packageManager = options.packageManager ?? detectedPm ?? "pnpm";
3711
3014
  const packageManagerNote = options.packageManager === void 0 && detectedPm === null ? "the package manager could not be detected (no pnpm, yarn, bun or npm lockfile) \u2014 the workflow was rendered for pnpm; re-run with --packageManager=npm|yarn|bun if that is wrong." : void 0;
3712
3015
  const recorded = recordedReview(config.parsed);
3016
+ const provider = options.provider ?? recorded.provider ?? "claude";
3713
3017
  const plan = composeReviewSetup({
3714
3018
  enabled: true,
3715
- provider: options.provider ?? recorded.provider ?? "claude",
3019
+ provider,
3716
3020
  mode: options.mode ?? recorded.mode ?? "standard",
3717
3021
  locale: resolveLocale(options.locale, config),
3718
3022
  maxRounds: options.maxRounds ?? recorded.maxRounds ?? 3,
@@ -3807,7 +3111,8 @@ function runAddReview(tree, options) {
3807
3111
  configError: null,
3808
3112
  dependabot,
3809
3113
  dependabotProposal: dependabot === "proposed" ? dependabotFile.content : null,
3810
- ...packageManagerNote !== void 0 ? { packageManagerNote } : {}
3114
+ ...packageManagerNote !== void 0 ? { packageManagerNote } : {},
3115
+ ...BETA_PROVIDERS.includes(provider) ? { betaProvider: provider } : {}
3811
3116
  };
3812
3117
  }
3813
3118
 
@@ -4241,7 +3546,7 @@ function renderInitReport(report) {
4241
3546
  }
4242
3547
  }
4243
3548
  const ranDirty = report.allowDirty === true && !report.cleanTree && !report.dryRun;
4244
- if (ranDirty) {
3549
+ if (ranDirty && report.dirtyFromCaller !== true) {
4245
3550
  lines.push("");
4246
3551
  lines.push("Note: --allowDirty was set and the working tree already had uncommitted changes \u2014");
4247
3552
  lines.push("restoring the files this run modified also reverts your earlier changes to them.");
@@ -4459,8 +3764,8 @@ function runInit(tree, options, deps) {
4459
3764
  dryRun
4460
3765
  },
4461
3766
  // init records aiHosts below, with its other choices; the FSD section follows this run's
4462
- // frontend axis
4463
- { recordHosts: false, fsdStructure: fsdEnabled }
3767
+ // frontend axis, the Module Boundaries section its backend axis
3768
+ { recordHosts: false, fsdStructure: fsdEnabled, moduleBoundaries: backend === "none" ? null : readBoundaryTags(recorded) }
4464
3769
  );
4465
3770
  sections.push({ id: "agentRules", enabled: true, report: { kind: "agentRules", report } });
4466
3771
  } else {
@@ -4559,6 +3864,7 @@ function runInit(tree, options, deps) {
4559
3864
  dryRun,
4560
3865
  cleanTree,
4561
3866
  allowDirty,
3867
+ dirtyFromCaller: options.dirtyFromCaller ?? false,
4562
3868
  refused: false,
4563
3869
  sections,
4564
3870
  config: configOutcome,