@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.
@@ -133,6 +133,30 @@ function buildOverEngineeringPrompt(locale) {
133
133
  return [...body, "", renderFindingSchemaInstruction(locale, OVER_ENGINEERING_PRIORITIES), "", renderDedupInstruction(locale)].join("\n");
134
134
  }
135
135
 
136
+ // ../review-policy/dist/verdict-gate/verdict-comment.js
137
+ var VERDICT_MARKER = "<!-- archweave-verdict -->";
138
+ function renderCommitLine(locale, shortSha) {
139
+ 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>`;
140
+ }
141
+ var NOT_RUN_REASON = {
142
+ en: {
143
+ secret: (secretName) => `the ${secretName} secret is not registered`,
144
+ fork: () => "this pull request comes from a fork, and GitHub passes no secrets to runs from forks",
145
+ dependabot: (secretName) => `Dependabot runs receive only Dependabot secrets, and ${secretName} is not one of them`,
146
+ rounds: (_secretName, maxRounds) => `the automated review round limit (${maxRounds}) is reached`
147
+ },
148
+ ko: {
149
+ secret: (secretName) => `${secretName} \uC2DC\uD06C\uB9BF\uC774 \uB4F1\uB85D\uB418\uC9C0 \uC54A\uC74C`,
150
+ 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",
151
+ dependabot: (secretName) => `Dependabot \uC2E4\uD589\uC740 Dependabot \uC2DC\uD06C\uB9BF\uB9CC \uBC1B\uB294\uB370, ${secretName}\uB294 \uADF8\uC911\uC5D0 \uC5C6\uC74C`,
152
+ rounds: (_secretName, maxRounds) => `\uC790\uB3D9 \uB9AC\uBDF0 \uB77C\uC6B4\uB4DC \uD55C\uB3C4(${maxRounds})\uC5D0 \uB3C4\uB2EC\uD568`
153
+ }
154
+ };
155
+ function renderNotRunNotice(locale, reason, secretName, maxRounds) {
156
+ const why = NOT_RUN_REASON[locale][reason](secretName, maxRounds);
157
+ 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.`;
158
+ }
159
+
136
160
  // ../review-policy/dist/verdict-gate/verdict-gate.js
137
161
  var ROUND_MARKER = "<!-- archweave-review-round -->";
138
162
 
@@ -177,13 +201,14 @@ function renderConcurrencyBlock() {
177
201
  " cancel-in-progress: false"
178
202
  ].join("\n");
179
203
  }
180
- function renderPermissionsBlock() {
181
- return ["permissions:", " contents: read", " pull-requests: write", " id-token: write"].join("\n");
204
+ var REVIEW_GATE_CONDITION = "steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'";
205
+ function renderReviewPermissions(idToken) {
206
+ return ["permissions:", " contents: read", " pull-requests: write", ...idToken ? [" id-token: write"] : []].join("\n");
182
207
  }
183
208
  function renderCheckoutStep(gateCondition, extraWith = []) {
184
209
  return [
185
210
  "- name: Checkout repository",
186
- ` if: ${gateCondition}`,
211
+ ...gateCondition === void 0 ? [] : [` if: ${gateCondition}`],
187
212
  ` uses: ${pinnedUses("actions/checkout")}`,
188
213
  " with:",
189
214
  ...extraWith.map((line) => ` ${line}`),
@@ -225,10 +250,84 @@ function renderRoundGateStep(maxRounds) {
225
250
  " fi"
226
251
  ].join("\n");
227
252
  }
253
+ function shellQuote(text) {
254
+ return `'${text.replace(/'/g, `'\\''`)}'`;
255
+ }
256
+ function renderNotRunFunction(secretName, maxRounds, locale) {
257
+ const reasons = ["secret", "fork", "dependabot", "rounds"];
258
+ const [commitBefore, commitAfter] = renderCommitLine(locale, "\0").split("\0");
259
+ return [
260
+ "not_run() {",
261
+ ' case "$1" in',
262
+ ...reasons.map((reason) => ` ${reason}) annotation=${shellQuote(renderNotRunNotice("en", reason, secretName, maxRounds))}; notice=${shellQuote(renderNotRunNotice(locale, reason, secretName, maxRounds))} ;;`),
263
+ " esac",
264
+ ' echo "::notice title=AI review did not run::$annotation"',
265
+ ` printf '%s\\n' "$notice" >> "$GITHUB_STEP_SUMMARY"`,
266
+ ` short_sha=$(printf '%s' "$HEAD_SHA" | cut -c1-7)`,
267
+ ' case "$short_sha" in',
268
+ " '' | *[!0-9a-f]*) short_sha= ;;",
269
+ " esac",
270
+ " {",
271
+ ' echo "notice-body<<ARCHWEAVE_NOT_RUN_EOF"',
272
+ ` printf '%s\\n' ${shellQuote(VERDICT_MARKER)} "\u2139\uFE0F $notice"`,
273
+ ` if [ -n "$short_sha" ]; then printf '\\n%s\\n' ${shellQuote(commitBefore)}"$short_sha"${shellQuote(commitAfter)}; fi`,
274
+ ' echo "ARCHWEAVE_NOT_RUN_EOF"',
275
+ ' echo "run=false"',
276
+ ' } >> "$GITHUB_OUTPUT"',
277
+ "}"
278
+ ];
279
+ }
280
+ var JUDGE_CONDITION = "steps.ai-review-result.outputs.run == 'true'";
281
+ function renderAiReviewResultStep(secretName, maxRounds, locale) {
282
+ return [
283
+ "- name: Check the AI review result",
284
+ " id: ai-review-result",
285
+ " env:",
286
+ " AI_REVIEW_RESULT: ${{ needs.ai-review.result }}",
287
+ " REVIEW_ENABLED: ${{ needs.ai-review.outputs.enabled }}",
288
+ " REVIEW_ALLOWED: ${{ needs.ai-review.outputs.allowed }}",
289
+ " LAST_COMMENT_ID: ${{ needs.ai-review.outputs.last-comment-id }}",
290
+ " HEAD_SHA: ${{ github.event.pull_request.head.sha }}",
291
+ " HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}",
292
+ " REPOSITORY: ${{ github.repository }}",
293
+ " PR_AUTHOR: ${{ github.event.pull_request.user.login }}",
294
+ " run: |",
295
+ ...renderNotRunFunction(secretName, maxRounds, locale).map((line) => ` ${line}`),
296
+ ' if [ "$AI_REVIEW_RESULT" != success ]; then',
297
+ ` echo "::error title=AI review did not succeed::The AI review job ended with '$AI_REVIEW_RESULT'."`,
298
+ " exit 1",
299
+ " fi",
300
+ ' case "$REVIEW_ENABLED/$REVIEW_ALLOWED" in',
301
+ " false/*)",
302
+ ' if [ "$HEAD_REPOSITORY" != "$REPOSITORY" ]; then not_run fork',
303
+ ` elif [ "$PR_AUTHOR" = 'dependabot[bot]' ]; then not_run dependabot`,
304
+ " else not_run secret",
305
+ " fi",
306
+ " exit 0",
307
+ " ;;",
308
+ " true/false)",
309
+ " not_run rounds",
310
+ " exit 0",
311
+ " ;;",
312
+ " true/true)",
313
+ ' case "$LAST_COMMENT_ID" in',
314
+ " '' | *[!0-9]*) ;;",
315
+ " *)",
316
+ ' echo "run=true" >> "$GITHUB_OUTPUT"',
317
+ " exit 0",
318
+ " ;;",
319
+ " esac",
320
+ " ;;",
321
+ " esac",
322
+ ` 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."`,
323
+ " exit 1"
324
+ ].join("\n");
325
+ }
228
326
  function renderVerdictGateStep(maxRounds, locale) {
229
327
  return [
230
328
  "- name: Compute review verdict",
231
- " if: steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'",
329
+ " id: verdict",
330
+ ` if: ${JUDGE_CONDITION}`,
232
331
  " env:",
233
332
  " GH_TOKEN: ${{ github.token }}",
234
333
  " GITHUB_REPOSITORY: ${{ github.repository }}",
@@ -236,7 +335,8 @@ function renderVerdictGateStep(maxRounds, locale) {
236
335
  ` ARCHWEAVE_MAX_ROUNDS: '${maxRounds}'`,
237
336
  ` ARCHWEAVE_LOCALE: '${locale}'`,
238
337
  " ARCHWEAVE_HEAD_SHA: ${{ github.event.pull_request.head.sha }}",
239
- " ARCHWEAVE_ROUND_AFTER_ID: ${{ steps.round-gate.outputs.last-comment-id }}",
338
+ " ARCHWEAVE_ROUND_AFTER_ID: ${{ needs.ai-review.outputs.last-comment-id }}",
339
+ " ARCHWEAVE_VERDICT_OUTPUT: 'github-output'",
240
340
  " run: |",
241
341
  " if [ -x node_modules/.bin/archweave-review-verdict ]; then",
242
342
  " node_modules/.bin/archweave-review-verdict",
@@ -245,16 +345,49 @@ function renderVerdictGateStep(maxRounds, locale) {
245
345
  " fi"
246
346
  ].join("\n");
247
347
  }
348
+ function renderBlockStep() {
349
+ return [
350
+ "- name: Fail on a blocking verdict",
351
+ " if: steps.verdict.outputs.blocked == 'true'",
352
+ " run: |",
353
+ ' 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."',
354
+ " exit 1"
355
+ ].join("\n");
356
+ }
357
+ function renderVerdictCommentStep() {
358
+ return [
359
+ "- name: Post review verdict",
360
+ " env:",
361
+ " GH_TOKEN: ${{ github.token }}",
362
+ " REPOSITORY: ${{ github.repository }}",
363
+ " PR_NUMBER: ${{ github.event.pull_request.number }}",
364
+ " VERDICT_BODY: ${{ needs.review.outputs.comment-body }}",
365
+ " PREVIOUS_ID: ${{ needs.review.outputs.previous-comment-id }}",
366
+ " run: |",
367
+ ` payload=$(jq -n --arg body "$VERDICT_BODY" '{body: $body}')`,
368
+ ' if [ -z "$PREVIOUS_ID" ]; then',
369
+ ` 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=`,
370
+ " fi",
371
+ ' case "$PREVIOUS_ID" in',
372
+ " ''|*[!0-9]*) PREVIOUS_ID= ;;",
373
+ " esac",
374
+ ` if [ -n "$PREVIOUS_ID" ] && printf '%s' "$payload" | gh api -X PATCH "repos/$REPOSITORY/issues/comments/$PREVIOUS_ID" --input - > /dev/null; then`,
375
+ " exit 0",
376
+ " fi",
377
+ ` printf '%s' "$payload" | gh api -X POST "repos/$REPOSITORY/issues/$PR_NUMBER/comments" --input - > /dev/null \\`,
378
+ ' || echo "Could not post the verdict comment (continuing)."'
379
+ ].join("\n");
380
+ }
248
381
  var SETUP_NODE_VERSION = "22";
249
382
  var FALLBACK_PNPM_VERSION = "10";
250
383
  var INSTALL_LINES = {
251
- pnpm: [" pnpm install --frozen-lockfile"],
252
- npm: [" npm ci"],
384
+ pnpm: [" pnpm install --frozen-lockfile --ignore-scripts"],
385
+ npm: [" npm ci --ignore-scripts"],
253
386
  yarn: [
254
387
  " corepack enable yarn",
255
- ' if [ "$(yarn --version | cut -d. -f1)" -ge 2 ]; then yarn install --immutable; else yarn install --frozen-lockfile; fi'
388
+ ' 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'
256
389
  ],
257
- bun: [" bun install --frozen-lockfile"]
390
+ bun: [" bun install --frozen-lockfile --ignore-scripts"]
258
391
  };
259
392
  function renderPnpmVersionStep(gate) {
260
393
  return [
@@ -270,7 +403,7 @@ function renderPnpmVersionStep(gate) {
270
403
  ].join("\n");
271
404
  }
272
405
  function renderWorkspaceSetupSteps(packageManager) {
273
- const gate = " if: steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'";
406
+ const gate = ` if: ${JUDGE_CONDITION}`;
274
407
  const steps = [];
275
408
  if (packageManager === "pnpm") {
276
409
  steps.push(renderPnpmVersionStep(gate));
@@ -305,21 +438,89 @@ function renderWorkspaceSetupSteps(packageManager) {
305
438
  ].join("\n"));
306
439
  return steps.join("\n\n");
307
440
  }
441
+ var REVIEW_JOB_TIMEOUT_MINUTES = 15;
442
+ function renderReviewWorkflow(input, parts) {
443
+ const aiReviewSteps = [renderSecretGateStep(parts.secretName), renderRoundGateStep(input.maxRounds), ...parts.reviewSteps];
444
+ const reviewSteps = [
445
+ renderAiReviewResultStep(parts.secretName, input.maxRounds, input.locale),
446
+ renderCheckoutStep(JUDGE_CONDITION),
447
+ renderWorkspaceSetupSteps(input.packageManager),
448
+ renderVerdictGateStep(input.maxRounds, input.locale),
449
+ renderBlockStep()
450
+ ];
451
+ return [
452
+ `name: ${parts.name}`,
453
+ "",
454
+ renderTriggerBlock(),
455
+ "",
456
+ renderConcurrencyBlock(),
457
+ "",
458
+ "permissions: {}",
459
+ "",
460
+ "jobs:",
461
+ " ai-review:",
462
+ " runs-on: ubuntu-latest",
463
+ ` timeout-minutes: ${REVIEW_JOB_TIMEOUT_MINUTES}`,
464
+ indentBlock(renderReviewPermissions(parts.idToken), 4),
465
+ " outputs:",
466
+ " enabled: ${{ steps.secret-gate.outputs.enabled }}",
467
+ " allowed: ${{ steps.round-gate.outputs.allowed }}",
468
+ " last-comment-id: ${{ steps.round-gate.outputs.last-comment-id }}",
469
+ " steps:",
470
+ indentBlock(aiReviewSteps.join("\n\n"), 6),
471
+ "",
472
+ " review:",
473
+ " needs: ai-review",
474
+ " if: always()",
475
+ " runs-on: ubuntu-latest",
476
+ ` timeout-minutes: ${REVIEW_JOB_TIMEOUT_MINUTES}`,
477
+ " permissions:",
478
+ " contents: read",
479
+ " pull-requests: read",
480
+ " outputs:",
481
+ " comment-body: ${{ steps.verdict.outputs.comment-body || steps.ai-review-result.outputs.notice-body }}",
482
+ " previous-comment-id: ${{ steps.verdict.outputs.previous-comment-id }}",
483
+ " steps:",
484
+ indentBlock(reviewSteps.join("\n\n"), 6),
485
+ "",
486
+ " review-comment:",
487
+ " needs: review",
488
+ // Runs after a BLOCK failed the review job, too: the comment explains the red check.
489
+ " if: ${{ !cancelled() && needs.review.outputs.comment-body != '' }}",
490
+ " runs-on: ubuntu-latest",
491
+ ` timeout-minutes: ${REVIEW_JOB_TIMEOUT_MINUTES}`,
492
+ " permissions:",
493
+ " pull-requests: write",
494
+ " steps:",
495
+ indentBlock(renderVerdictCommentStep(), 6),
496
+ ""
497
+ ].join("\n");
498
+ }
308
499
 
309
500
  // ../template-engine/dist/review/claude/claude-provider.js
310
501
  var SECRET_NAME = "CLAUDE_CODE_OAUTH_TOKEN";
311
502
  var ALLOWED_TOOLS = "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)";
503
+ var CLAUDE_STEP_ID = "claude-review";
504
+ var PR_CONTEXT = ["REPO: ${{ github.repository }}", "PR NUMBER: ${{ github.event.pull_request.number }}"];
312
505
  function renderWorkflowInstructions(locale) {
313
506
  const lines = locale === "en" ? [
314
- "Review the diff of this pull request using `gh pr diff` and `gh pr view`.",
315
- "Post specific findings as inline comments and exactly one top-level summary comment.",
507
+ ...PR_CONTEXT,
508
+ "",
509
+ "Review the diff of this pull request using `gh pr diff <PR NUMBER>` and `gh pr view <PR NUMBER>`.",
510
+ "Post specific findings as inline comments with `mcp__github_inline_comment__create_inline_comment` (pass `confirmed: true`), and exactly one top-level summary comment.",
511
+ "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 `$(...)`.",
512
+ "Run each `gh` command on its own: no pipes to other programs, no `&&` chains.",
316
513
  `Always include the literal marker ${ROUND_MARKER} in the top-level summary comment.`,
317
514
  "If there are no findings that require action, post exactly one top-level comment saying so (and still include the marker).",
318
515
  "Do not modify any code, and never approve or merge the pull request.",
319
516
  "Write summaries and explanations in English; keep file names, function names, and identifiers verbatim."
320
517
  ] : [
321
- "\uC774 pull request\uC758 diff\uB97C `gh pr diff`\uC640 `gh pr view`\uB85C \uD655\uC778\uD558\uACE0 \uB9AC\uBDF0\uD558\uC138\uC694.",
322
- "\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.",
518
+ ...PR_CONTEXT,
519
+ "",
520
+ "\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.",
521
+ "\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.",
522
+ "\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.",
523
+ "`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.",
323
524
  `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.`,
324
525
  '\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).',
325
526
  "\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).",
@@ -336,42 +537,44 @@ function composePrompt(input) {
336
537
  sections.push(renderFindingsBlockInstruction(input.locale));
337
538
  return sections.join("\n\n---\n\n");
338
539
  }
339
- function buildWorkflowYaml(input) {
340
- const steps = [
341
- renderSecretGateStep(SECRET_NAME),
342
- renderRoundGateStep(input.maxRounds),
343
- renderCheckoutStep("steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'"),
344
- [
345
- "- name: Run Claude review",
346
- " if: steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'",
347
- ` uses: ${pinnedUses("anthropics/claude-code-action")}`,
348
- " with:",
349
- ` claude_code_oauth_token: \${{ secrets.${SECRET_NAME} }}`,
350
- " prompt: |",
351
- indentBlock(composePrompt(input), 6),
352
- " claude_args: |",
353
- ` --allowedTools "${ALLOWED_TOOLS}"`
354
- ].join("\n"),
355
- renderWorkspaceSetupSteps(input.packageManager),
356
- renderVerdictGateStep(input.maxRounds, input.locale)
357
- ];
540
+ function renderDeniedToolsStep() {
358
541
  return [
359
- "name: Claude Code Review",
360
- "",
361
- renderTriggerBlock(),
362
- "",
363
- renderConcurrencyBlock(),
364
- "",
365
- renderPermissionsBlock(),
366
- "",
367
- "jobs:",
368
- " review:",
369
- " runs-on: ubuntu-latest",
370
- " steps:",
371
- indentBlock(steps.join("\n\n"), 6),
372
- ""
542
+ "- name: Show denied tool calls",
543
+ ` if: always() && steps.${CLAUDE_STEP_ID}.outputs.execution_file != ''`,
544
+ " env:",
545
+ ` EXECUTION_FILE: \${{ steps.${CLAUDE_STEP_ID}.outputs.execution_file }}`,
546
+ " run: |",
547
+ ' [ -f "$EXECUTION_FILE" ] || exit 0',
548
+ ` stop_token="archweave-$(od -An -N16 -tx1 /dev/urandom | tr -d ' \\n')"`,
549
+ ' echo "::stop-commands::$stop_token"',
550
+ ` 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."`,
551
+ ' echo "::$stop_token::"'
373
552
  ].join("\n");
374
553
  }
554
+ function buildWorkflowYaml(input) {
555
+ return renderReviewWorkflow(input, {
556
+ name: "Claude Code Review",
557
+ secretName: SECRET_NAME,
558
+ // The Claude GitHub App signs in with the workflow's OIDC token (claude-code-action's FAQ).
559
+ idToken: true,
560
+ reviewSteps: [
561
+ renderCheckoutStep(REVIEW_GATE_CONDITION),
562
+ [
563
+ "- name: Run Claude review",
564
+ ` id: ${CLAUDE_STEP_ID}`,
565
+ ` if: ${REVIEW_GATE_CONDITION}`,
566
+ ` uses: ${pinnedUses("anthropics/claude-code-action")}`,
567
+ " with:",
568
+ ` claude_code_oauth_token: \${{ secrets.${SECRET_NAME} }}`,
569
+ " prompt: |",
570
+ indentBlock(composePrompt(input), 6),
571
+ " claude_args: |",
572
+ ` --allowedTools "${ALLOWED_TOOLS}"`
573
+ ].join("\n"),
574
+ renderDeniedToolsStep()
575
+ ]
576
+ });
577
+ }
375
578
  var claudeProvider = {
376
579
  id: "claude",
377
580
  workflowFileName: ".github/workflows/claude-code-review.yml",
@@ -410,49 +613,41 @@ function composePrompt2(input) {
410
613
  return sections.join("\n\n---\n\n");
411
614
  }
412
615
  function buildWorkflowYaml2(input) {
413
- const gateCondition = "steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'";
414
- const steps = [
415
- renderSecretGateStep(SECRET_NAME2),
416
- renderRoundGateStep(input.maxRounds),
417
- renderCheckoutStep(gateCondition),
418
- [
419
- "- name: Install cursor-agent CLI",
420
- ` if: ${gateCondition}`,
421
- " run: |",
422
- " curl https://cursor.com/install -fsS | bash",
423
- ' echo "$HOME/.cursor/bin" >> "$GITHUB_PATH"'
424
- ].join("\n"),
425
- [
426
- "- name: Run Cursor review",
427
- ` if: ${gateCondition}`,
428
- " env:",
429
- ` CURSOR_API_KEY: \${{ secrets.${SECRET_NAME2} }}`,
430
- " GH_TOKEN: ${{ github.token }}",
431
- " run: |",
432
- ` agent -p "$(cat <<'${PROMPT_HEREDOC_DELIMITER}'`,
433
- indentBlock(composePrompt2(input), 4),
434
- ` ${PROMPT_HEREDOC_DELIMITER}`,
435
- ' )"'
436
- ].join("\n"),
437
- renderWorkspaceSetupSteps(input.packageManager),
438
- renderVerdictGateStep(input.maxRounds, input.locale)
439
- ];
440
- return [
441
- "name: Cursor Code Review",
442
- "",
443
- renderTriggerBlock(),
444
- "",
445
- renderConcurrencyBlock(),
446
- "",
447
- renderPermissionsBlock(),
448
- "",
449
- "jobs:",
450
- " review:",
451
- " runs-on: ubuntu-latest",
452
- " steps:",
453
- indentBlock(steps.join("\n\n"), 6),
454
- ""
455
- ].join("\n");
616
+ return renderReviewWorkflow(input, {
617
+ name: "Cursor Code Review",
618
+ secretName: SECRET_NAME2,
619
+ // An API key: the Cursor CLI needs no OIDC token.
620
+ idToken: false,
621
+ reviewSteps: [
622
+ renderCheckoutStep(REVIEW_GATE_CONDITION),
623
+ [
624
+ "- name: Install cursor-agent CLI",
625
+ ` if: ${REVIEW_GATE_CONDITION}`,
626
+ " run: |",
627
+ // HTTPS only, TLS 1.2 or newer. Cursor publishes no pinned version or checksum for
628
+ // this installer; docs/pr-review.md states what that leaves open.
629
+ " curl --proto '=https' --tlsv1.2 -fsS https://cursor.com/install | bash",
630
+ // The docs name ~/.cursor/bin; the installer currently links `agent` into ~/.local/bin.
631
+ // Both go on the PATH, so the next step finds it wherever the installer puts it.
632
+ ' echo "$HOME/.local/bin" >> "$GITHUB_PATH"',
633
+ ' echo "$HOME/.cursor/bin" >> "$GITHUB_PATH"'
634
+ ].join("\n"),
635
+ [
636
+ "- name: Run Cursor review",
637
+ ` if: ${REVIEW_GATE_CONDITION}`,
638
+ " env:",
639
+ ` CURSOR_API_KEY: \${{ secrets.${SECRET_NAME2} }}`,
640
+ " GH_TOKEN: ${{ github.token }}",
641
+ " run: |",
642
+ // cursor-agent stops at "Workspace Trust Required" without --trust (2026.10.22 on
643
+ // Actions); the folder is this run's own checkout, and forks never get the secret.
644
+ ` agent --trust -p "$(cat <<'${PROMPT_HEREDOC_DELIMITER}'`,
645
+ indentBlock(composePrompt2(input), 4),
646
+ ` ${PROMPT_HEREDOC_DELIMITER}`,
647
+ ' )"'
648
+ ].join("\n")
649
+ ]
650
+ });
456
651
  }
457
652
  var cursorProvider = {
458
653
  id: "cursor",
@@ -490,41 +685,33 @@ function composePrompt3(input) {
490
685
  sections.push(renderFindingsBlockInstruction(input.locale));
491
686
  return sections.join("\n\n---\n\n");
492
687
  }
688
+ var GEMINI_CLI_VERSION = "0.65.0";
493
689
  function buildWorkflowYaml3(input) {
494
- const steps = [
495
- renderSecretGateStep(SECRET_NAME3),
496
- renderRoundGateStep(input.maxRounds),
497
- renderCheckoutStep("steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'"),
498
- [
499
- "- name: Run Gemini review",
500
- " if: steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'",
501
- ` uses: ${pinnedUses("google-github-actions/run-gemini-cli")}`,
502
- " env:",
503
- " GITHUB_TOKEN: ${{ github.token }}",
504
- " with:",
505
- ` gemini_api_key: \${{ secrets.${SECRET_NAME3} }}`,
506
- " prompt: |",
507
- indentBlock(composePrompt3(input), 6)
508
- ].join("\n"),
509
- renderWorkspaceSetupSteps(input.packageManager),
510
- renderVerdictGateStep(input.maxRounds, input.locale)
511
- ];
512
- return [
513
- "name: Gemini Code Review",
514
- "",
515
- renderTriggerBlock(),
516
- "",
517
- renderConcurrencyBlock(),
518
- "",
519
- renderPermissionsBlock(),
520
- "",
521
- "jobs:",
522
- " review:",
523
- " runs-on: ubuntu-latest",
524
- " steps:",
525
- indentBlock(steps.join("\n\n"), 6),
526
- ""
527
- ].join("\n");
690
+ return renderReviewWorkflow(input, {
691
+ name: "Gemini Code Review",
692
+ secretName: SECRET_NAME3,
693
+ // An API key: run-gemini-cli uses OIDC only for Google Cloud workload identity federation.
694
+ idToken: false,
695
+ reviewSteps: [
696
+ renderCheckoutStep(REVIEW_GATE_CONDITION),
697
+ [
698
+ "- name: Run Gemini review",
699
+ ` if: ${REVIEW_GATE_CONDITION}`,
700
+ ` uses: ${pinnedUses("google-github-actions/run-gemini-cli")}`,
701
+ " env:",
702
+ " GITHUB_TOKEN: ${{ github.token }}",
703
+ // Gemini CLI 0.65 refuses to run in a folder it hasn't been told to trust (measured
704
+ // 2026-10-25 on Actions). The folder is this run's own checkout; pull requests from forks
705
+ // never get here, because they get no secret.
706
+ " GEMINI_CLI_TRUST_WORKSPACE: 'true'",
707
+ " with:",
708
+ ` gemini_api_key: \${{ secrets.${SECRET_NAME3} }}`,
709
+ ` gemini_cli_version: '${GEMINI_CLI_VERSION}'`,
710
+ " prompt: |",
711
+ indentBlock(composePrompt3(input), 6)
712
+ ].join("\n")
713
+ ]
714
+ });
528
715
  }
529
716
  var geminiProvider = {
530
717
  id: "gemini",
@@ -563,64 +750,49 @@ function composePrompt4(input) {
563
750
  return sections.join("\n\n---\n\n");
564
751
  }
565
752
  function buildWorkflowYaml4(input) {
566
- const gateCondition = "steps.secret-gate.outputs.enabled == 'true' && steps.round-gate.outputs.allowed == 'true'";
567
- const steps = [
568
- renderSecretGateStep(SECRET_NAME4),
569
- renderRoundGateStep(input.maxRounds),
570
- renderCheckoutStep(gateCondition, ["ref: refs/pull/${{ github.event.pull_request.number }}/merge"]),
571
- [
572
- "- name: Fetch base and head refs for the PR",
573
- ` if: ${gateCondition}`,
574
- " env:",
575
- " PR_BASE_REF: ${{ github.event.pull_request.base.ref }}",
576
- " PR_NUMBER: ${{ github.event.pull_request.number }}",
577
- " run: |",
578
- " # Explicit destinations: the sandboxed review step has no network, so both sides",
579
- " # of the diff must survive as stable local refs (FETCH_HEAD alone is ambiguous).",
580
- " git fetch --no-tags origin \\",
581
- ' "+refs/heads/$PR_BASE_REF:refs/remotes/origin/pr-base" \\',
582
- ' "+refs/pull/$PR_NUMBER/head:refs/remotes/origin/pr-head"'
583
- ].join("\n"),
584
- [
585
- "- name: Run Codex review",
586
- " id: codex-review",
587
- ` if: ${gateCondition}`,
588
- ` uses: ${pinnedUses("openai/codex-action")}`,
589
- " with:",
590
- ` openai-api-key: \${{ secrets.${SECRET_NAME4} }}`,
591
- ' permission-profile: ":read-only"',
592
- " prompt: |",
593
- indentBlock(composePrompt4(input), 6)
594
- ].join("\n"),
595
- [
596
- "- name: Post review comment",
597
- ` if: ${gateCondition}`,
598
- " env:",
599
- " GH_TOKEN: ${{ github.token }}",
600
- " PR_NUMBER: ${{ github.event.pull_request.number }}",
601
- " REVIEW_BODY: ${{ steps.codex-review.outputs.final-message }}",
602
- " run: |",
603
- ' printf %s "$REVIEW_BODY" | gh pr comment "$PR_NUMBER" --body-file -'
604
- ].join("\n"),
605
- renderWorkspaceSetupSteps(input.packageManager),
606
- renderVerdictGateStep(input.maxRounds, input.locale)
607
- ];
608
- return [
609
- "name: GPT Code Review",
610
- "",
611
- renderTriggerBlock(),
612
- "",
613
- renderConcurrencyBlock(),
614
- "",
615
- renderPermissionsBlock(),
616
- "",
617
- "jobs:",
618
- " review:",
619
- " runs-on: ubuntu-latest",
620
- " steps:",
621
- indentBlock(steps.join("\n\n"), 6),
622
- ""
623
- ].join("\n");
753
+ return renderReviewWorkflow(input, {
754
+ name: "GPT Code Review",
755
+ secretName: SECRET_NAME4,
756
+ // An API key: codex-action needs no OIDC token.
757
+ idToken: false,
758
+ reviewSteps: [
759
+ renderCheckoutStep(REVIEW_GATE_CONDITION, ["ref: refs/pull/${{ github.event.pull_request.number }}/merge"]),
760
+ [
761
+ "- name: Fetch base and head refs for the PR",
762
+ ` if: ${REVIEW_GATE_CONDITION}`,
763
+ " env:",
764
+ " PR_BASE_REF: ${{ github.event.pull_request.base.ref }}",
765
+ " PR_NUMBER: ${{ github.event.pull_request.number }}",
766
+ " run: |",
767
+ " # Explicit destinations: the sandboxed review step has no network, so both sides",
768
+ " # of the diff must survive as stable local refs (FETCH_HEAD alone is ambiguous).",
769
+ " git fetch --no-tags origin \\",
770
+ ' "+refs/heads/$PR_BASE_REF:refs/remotes/origin/pr-base" \\',
771
+ ' "+refs/pull/$PR_NUMBER/head:refs/remotes/origin/pr-head"'
772
+ ].join("\n"),
773
+ [
774
+ "- name: Run Codex review",
775
+ " id: codex-review",
776
+ ` if: ${REVIEW_GATE_CONDITION}`,
777
+ ` uses: ${pinnedUses("openai/codex-action")}`,
778
+ " with:",
779
+ ` openai-api-key: \${{ secrets.${SECRET_NAME4} }}`,
780
+ ' permission-profile: ":read-only"',
781
+ " prompt: |",
782
+ indentBlock(composePrompt4(input), 6)
783
+ ].join("\n"),
784
+ [
785
+ "- name: Post review comment",
786
+ ` if: ${REVIEW_GATE_CONDITION}`,
787
+ " env:",
788
+ " GH_TOKEN: ${{ github.token }}",
789
+ " PR_NUMBER: ${{ github.event.pull_request.number }}",
790
+ " REVIEW_BODY: ${{ steps.codex-review.outputs.final-message }}",
791
+ " run: |",
792
+ ' printf %s "$REVIEW_BODY" | gh pr comment "$PR_NUMBER" --body-file -'
793
+ ].join("\n")
794
+ ]
795
+ });
624
796
  }
625
797
  var gptProvider = {
626
798
  id: "gpt",
@@ -685,933 +857,8 @@ function renderTemplateFiles(srcFolder, target, substitutions) {
685
857
  ).sort((a, b) => a.filePath.localeCompare(b.filePath));
686
858
  }
687
859
 
688
- // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/scanner.js
689
- function createScanner(text, ignoreTrivia = false) {
690
- const len = text.length;
691
- let pos = 0, value = "", tokenOffset = 0, token = 16, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0;
692
- function scanHexDigits(count, exact) {
693
- let digits = 0;
694
- let value2 = 0;
695
- while (digits < count || !exact) {
696
- let ch = text.charCodeAt(pos);
697
- if (ch >= 48 && ch <= 57) {
698
- value2 = value2 * 16 + ch - 48;
699
- } else if (ch >= 65 && ch <= 70) {
700
- value2 = value2 * 16 + ch - 65 + 10;
701
- } else if (ch >= 97 && ch <= 102) {
702
- value2 = value2 * 16 + ch - 97 + 10;
703
- } else {
704
- break;
705
- }
706
- pos++;
707
- digits++;
708
- }
709
- if (digits < count) {
710
- value2 = -1;
711
- }
712
- return value2;
713
- }
714
- function setPosition(newPosition) {
715
- pos = newPosition;
716
- value = "";
717
- tokenOffset = 0;
718
- token = 16;
719
- scanError = 0;
720
- }
721
- function scanNumber() {
722
- let start = pos;
723
- if (text.charCodeAt(pos) === 48) {
724
- pos++;
725
- } else {
726
- pos++;
727
- while (pos < text.length && isDigit(text.charCodeAt(pos))) {
728
- pos++;
729
- }
730
- }
731
- if (pos < text.length && text.charCodeAt(pos) === 46) {
732
- pos++;
733
- if (pos < text.length && isDigit(text.charCodeAt(pos))) {
734
- pos++;
735
- while (pos < text.length && isDigit(text.charCodeAt(pos))) {
736
- pos++;
737
- }
738
- } else {
739
- scanError = 3;
740
- return text.substring(start, pos);
741
- }
742
- }
743
- let end = pos;
744
- if (pos < text.length && (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101)) {
745
- pos++;
746
- if (pos < text.length && text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) {
747
- pos++;
748
- }
749
- if (pos < text.length && isDigit(text.charCodeAt(pos))) {
750
- pos++;
751
- while (pos < text.length && isDigit(text.charCodeAt(pos))) {
752
- pos++;
753
- }
754
- end = pos;
755
- } else {
756
- scanError = 3;
757
- }
758
- }
759
- return text.substring(start, end);
760
- }
761
- function scanString() {
762
- let result = "", start = pos;
763
- while (true) {
764
- if (pos >= len) {
765
- result += text.substring(start, pos);
766
- scanError = 2;
767
- break;
768
- }
769
- const ch = text.charCodeAt(pos);
770
- if (ch === 34) {
771
- result += text.substring(start, pos);
772
- pos++;
773
- break;
774
- }
775
- if (ch === 92) {
776
- result += text.substring(start, pos);
777
- pos++;
778
- if (pos >= len) {
779
- scanError = 2;
780
- break;
781
- }
782
- const ch2 = text.charCodeAt(pos++);
783
- switch (ch2) {
784
- case 34:
785
- result += '"';
786
- break;
787
- case 92:
788
- result += "\\";
789
- break;
790
- case 47:
791
- result += "/";
792
- break;
793
- case 98:
794
- result += "\b";
795
- break;
796
- case 102:
797
- result += "\f";
798
- break;
799
- case 110:
800
- result += "\n";
801
- break;
802
- case 114:
803
- result += "\r";
804
- break;
805
- case 116:
806
- result += " ";
807
- break;
808
- case 117:
809
- const ch3 = scanHexDigits(4, true);
810
- if (ch3 >= 0) {
811
- result += String.fromCharCode(ch3);
812
- } else {
813
- scanError = 4;
814
- }
815
- break;
816
- default:
817
- scanError = 5;
818
- }
819
- start = pos;
820
- continue;
821
- }
822
- if (ch >= 0 && ch <= 31) {
823
- if (isLineBreak(ch)) {
824
- result += text.substring(start, pos);
825
- scanError = 2;
826
- break;
827
- } else {
828
- scanError = 6;
829
- }
830
- }
831
- pos++;
832
- }
833
- return result;
834
- }
835
- function scanNext() {
836
- value = "";
837
- scanError = 0;
838
- tokenOffset = pos;
839
- lineStartOffset = lineNumber;
840
- prevTokenLineStartOffset = tokenLineStartOffset;
841
- if (pos >= len) {
842
- tokenOffset = len;
843
- return token = 17;
844
- }
845
- let code = text.charCodeAt(pos);
846
- if (isWhiteSpace(code)) {
847
- do {
848
- pos++;
849
- value += String.fromCharCode(code);
850
- code = text.charCodeAt(pos);
851
- } while (isWhiteSpace(code));
852
- return token = 15;
853
- }
854
- if (isLineBreak(code)) {
855
- pos++;
856
- value += String.fromCharCode(code);
857
- if (code === 13 && text.charCodeAt(pos) === 10) {
858
- pos++;
859
- value += "\n";
860
- }
861
- lineNumber++;
862
- tokenLineStartOffset = pos;
863
- return token = 14;
864
- }
865
- switch (code) {
866
- // tokens: []{}:,
867
- case 123:
868
- pos++;
869
- return token = 1;
870
- case 125:
871
- pos++;
872
- return token = 2;
873
- case 91:
874
- pos++;
875
- return token = 3;
876
- case 93:
877
- pos++;
878
- return token = 4;
879
- case 58:
880
- pos++;
881
- return token = 6;
882
- case 44:
883
- pos++;
884
- return token = 5;
885
- // strings
886
- case 34:
887
- pos++;
888
- value = scanString();
889
- return token = 10;
890
- // comments
891
- case 47:
892
- const start = pos - 1;
893
- if (text.charCodeAt(pos + 1) === 47) {
894
- pos += 2;
895
- while (pos < len) {
896
- if (isLineBreak(text.charCodeAt(pos))) {
897
- break;
898
- }
899
- pos++;
900
- }
901
- value = text.substring(start, pos);
902
- return token = 12;
903
- }
904
- if (text.charCodeAt(pos + 1) === 42) {
905
- pos += 2;
906
- const safeLength = len - 1;
907
- let commentClosed = false;
908
- while (pos < safeLength) {
909
- const ch = text.charCodeAt(pos);
910
- if (ch === 42 && text.charCodeAt(pos + 1) === 47) {
911
- pos += 2;
912
- commentClosed = true;
913
- break;
914
- }
915
- pos++;
916
- if (isLineBreak(ch)) {
917
- if (ch === 13 && text.charCodeAt(pos) === 10) {
918
- pos++;
919
- }
920
- lineNumber++;
921
- tokenLineStartOffset = pos;
922
- }
923
- }
924
- if (!commentClosed) {
925
- pos++;
926
- scanError = 1;
927
- }
928
- value = text.substring(start, pos);
929
- return token = 13;
930
- }
931
- value += String.fromCharCode(code);
932
- pos++;
933
- return token = 16;
934
- // numbers
935
- case 45:
936
- value += String.fromCharCode(code);
937
- pos++;
938
- if (pos === len || !isDigit(text.charCodeAt(pos))) {
939
- return token = 16;
940
- }
941
- // found a minus, followed by a number so
942
- // we fall through to proceed with scanning
943
- // numbers
944
- case 48:
945
- case 49:
946
- case 50:
947
- case 51:
948
- case 52:
949
- case 53:
950
- case 54:
951
- case 55:
952
- case 56:
953
- case 57:
954
- value += scanNumber();
955
- return token = 11;
956
- // literals and unknown symbols
957
- default:
958
- while (pos < len && isUnknownContentCharacter(code)) {
959
- pos++;
960
- code = text.charCodeAt(pos);
961
- }
962
- if (tokenOffset !== pos) {
963
- value = text.substring(tokenOffset, pos);
964
- switch (value) {
965
- case "true":
966
- return token = 8;
967
- case "false":
968
- return token = 9;
969
- case "null":
970
- return token = 7;
971
- }
972
- return token = 16;
973
- }
974
- value += String.fromCharCode(code);
975
- pos++;
976
- return token = 16;
977
- }
978
- }
979
- function isUnknownContentCharacter(code) {
980
- if (isWhiteSpace(code) || isLineBreak(code)) {
981
- return false;
982
- }
983
- switch (code) {
984
- case 125:
985
- case 93:
986
- case 123:
987
- case 91:
988
- case 34:
989
- case 58:
990
- case 44:
991
- case 47:
992
- return false;
993
- }
994
- return true;
995
- }
996
- function scanNextNonTrivia() {
997
- let result;
998
- do {
999
- result = scanNext();
1000
- } while (result >= 12 && result <= 15);
1001
- return result;
1002
- }
1003
- return {
1004
- setPosition,
1005
- getPosition: () => pos,
1006
- scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
1007
- getToken: () => token,
1008
- getTokenValue: () => value,
1009
- getTokenOffset: () => tokenOffset,
1010
- getTokenLength: () => pos - tokenOffset,
1011
- getTokenStartLine: () => lineStartOffset,
1012
- getTokenStartCharacter: () => tokenOffset - prevTokenLineStartOffset,
1013
- getTokenError: () => scanError
1014
- };
1015
- }
1016
- function isWhiteSpace(ch) {
1017
- return ch === 32 || ch === 9;
1018
- }
1019
- function isLineBreak(ch) {
1020
- return ch === 10 || ch === 13;
1021
- }
1022
- function isDigit(ch) {
1023
- return ch >= 48 && ch <= 57;
1024
- }
1025
- var CharacterCodes;
1026
- (function(CharacterCodes2) {
1027
- CharacterCodes2[CharacterCodes2["lineFeed"] = 10] = "lineFeed";
1028
- CharacterCodes2[CharacterCodes2["carriageReturn"] = 13] = "carriageReturn";
1029
- CharacterCodes2[CharacterCodes2["space"] = 32] = "space";
1030
- CharacterCodes2[CharacterCodes2["_0"] = 48] = "_0";
1031
- CharacterCodes2[CharacterCodes2["_1"] = 49] = "_1";
1032
- CharacterCodes2[CharacterCodes2["_2"] = 50] = "_2";
1033
- CharacterCodes2[CharacterCodes2["_3"] = 51] = "_3";
1034
- CharacterCodes2[CharacterCodes2["_4"] = 52] = "_4";
1035
- CharacterCodes2[CharacterCodes2["_5"] = 53] = "_5";
1036
- CharacterCodes2[CharacterCodes2["_6"] = 54] = "_6";
1037
- CharacterCodes2[CharacterCodes2["_7"] = 55] = "_7";
1038
- CharacterCodes2[CharacterCodes2["_8"] = 56] = "_8";
1039
- CharacterCodes2[CharacterCodes2["_9"] = 57] = "_9";
1040
- CharacterCodes2[CharacterCodes2["a"] = 97] = "a";
1041
- CharacterCodes2[CharacterCodes2["b"] = 98] = "b";
1042
- CharacterCodes2[CharacterCodes2["c"] = 99] = "c";
1043
- CharacterCodes2[CharacterCodes2["d"] = 100] = "d";
1044
- CharacterCodes2[CharacterCodes2["e"] = 101] = "e";
1045
- CharacterCodes2[CharacterCodes2["f"] = 102] = "f";
1046
- CharacterCodes2[CharacterCodes2["g"] = 103] = "g";
1047
- CharacterCodes2[CharacterCodes2["h"] = 104] = "h";
1048
- CharacterCodes2[CharacterCodes2["i"] = 105] = "i";
1049
- CharacterCodes2[CharacterCodes2["j"] = 106] = "j";
1050
- CharacterCodes2[CharacterCodes2["k"] = 107] = "k";
1051
- CharacterCodes2[CharacterCodes2["l"] = 108] = "l";
1052
- CharacterCodes2[CharacterCodes2["m"] = 109] = "m";
1053
- CharacterCodes2[CharacterCodes2["n"] = 110] = "n";
1054
- CharacterCodes2[CharacterCodes2["o"] = 111] = "o";
1055
- CharacterCodes2[CharacterCodes2["p"] = 112] = "p";
1056
- CharacterCodes2[CharacterCodes2["q"] = 113] = "q";
1057
- CharacterCodes2[CharacterCodes2["r"] = 114] = "r";
1058
- CharacterCodes2[CharacterCodes2["s"] = 115] = "s";
1059
- CharacterCodes2[CharacterCodes2["t"] = 116] = "t";
1060
- CharacterCodes2[CharacterCodes2["u"] = 117] = "u";
1061
- CharacterCodes2[CharacterCodes2["v"] = 118] = "v";
1062
- CharacterCodes2[CharacterCodes2["w"] = 119] = "w";
1063
- CharacterCodes2[CharacterCodes2["x"] = 120] = "x";
1064
- CharacterCodes2[CharacterCodes2["y"] = 121] = "y";
1065
- CharacterCodes2[CharacterCodes2["z"] = 122] = "z";
1066
- CharacterCodes2[CharacterCodes2["A"] = 65] = "A";
1067
- CharacterCodes2[CharacterCodes2["B"] = 66] = "B";
1068
- CharacterCodes2[CharacterCodes2["C"] = 67] = "C";
1069
- CharacterCodes2[CharacterCodes2["D"] = 68] = "D";
1070
- CharacterCodes2[CharacterCodes2["E"] = 69] = "E";
1071
- CharacterCodes2[CharacterCodes2["F"] = 70] = "F";
1072
- CharacterCodes2[CharacterCodes2["G"] = 71] = "G";
1073
- CharacterCodes2[CharacterCodes2["H"] = 72] = "H";
1074
- CharacterCodes2[CharacterCodes2["I"] = 73] = "I";
1075
- CharacterCodes2[CharacterCodes2["J"] = 74] = "J";
1076
- CharacterCodes2[CharacterCodes2["K"] = 75] = "K";
1077
- CharacterCodes2[CharacterCodes2["L"] = 76] = "L";
1078
- CharacterCodes2[CharacterCodes2["M"] = 77] = "M";
1079
- CharacterCodes2[CharacterCodes2["N"] = 78] = "N";
1080
- CharacterCodes2[CharacterCodes2["O"] = 79] = "O";
1081
- CharacterCodes2[CharacterCodes2["P"] = 80] = "P";
1082
- CharacterCodes2[CharacterCodes2["Q"] = 81] = "Q";
1083
- CharacterCodes2[CharacterCodes2["R"] = 82] = "R";
1084
- CharacterCodes2[CharacterCodes2["S"] = 83] = "S";
1085
- CharacterCodes2[CharacterCodes2["T"] = 84] = "T";
1086
- CharacterCodes2[CharacterCodes2["U"] = 85] = "U";
1087
- CharacterCodes2[CharacterCodes2["V"] = 86] = "V";
1088
- CharacterCodes2[CharacterCodes2["W"] = 87] = "W";
1089
- CharacterCodes2[CharacterCodes2["X"] = 88] = "X";
1090
- CharacterCodes2[CharacterCodes2["Y"] = 89] = "Y";
1091
- CharacterCodes2[CharacterCodes2["Z"] = 90] = "Z";
1092
- CharacterCodes2[CharacterCodes2["asterisk"] = 42] = "asterisk";
1093
- CharacterCodes2[CharacterCodes2["backslash"] = 92] = "backslash";
1094
- CharacterCodes2[CharacterCodes2["closeBrace"] = 125] = "closeBrace";
1095
- CharacterCodes2[CharacterCodes2["closeBracket"] = 93] = "closeBracket";
1096
- CharacterCodes2[CharacterCodes2["colon"] = 58] = "colon";
1097
- CharacterCodes2[CharacterCodes2["comma"] = 44] = "comma";
1098
- CharacterCodes2[CharacterCodes2["dot"] = 46] = "dot";
1099
- CharacterCodes2[CharacterCodes2["doubleQuote"] = 34] = "doubleQuote";
1100
- CharacterCodes2[CharacterCodes2["minus"] = 45] = "minus";
1101
- CharacterCodes2[CharacterCodes2["openBrace"] = 123] = "openBrace";
1102
- CharacterCodes2[CharacterCodes2["openBracket"] = 91] = "openBracket";
1103
- CharacterCodes2[CharacterCodes2["plus"] = 43] = "plus";
1104
- CharacterCodes2[CharacterCodes2["slash"] = 47] = "slash";
1105
- CharacterCodes2[CharacterCodes2["formFeed"] = 12] = "formFeed";
1106
- CharacterCodes2[CharacterCodes2["tab"] = 9] = "tab";
1107
- })(CharacterCodes || (CharacterCodes = {}));
1108
-
1109
- // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/string-intern.js
1110
- var cachedSpaces = new Array(20).fill(0).map((_, index) => {
1111
- return " ".repeat(index);
1112
- });
1113
- var maxCachedValues = 200;
1114
- var cachedBreakLinesWithSpaces = {
1115
- " ": {
1116
- "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
1117
- return "\n" + " ".repeat(index);
1118
- }),
1119
- "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
1120
- return "\r" + " ".repeat(index);
1121
- }),
1122
- "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
1123
- return "\r\n" + " ".repeat(index);
1124
- })
1125
- },
1126
- " ": {
1127
- "\n": new Array(maxCachedValues).fill(0).map((_, index) => {
1128
- return "\n" + " ".repeat(index);
1129
- }),
1130
- "\r": new Array(maxCachedValues).fill(0).map((_, index) => {
1131
- return "\r" + " ".repeat(index);
1132
- }),
1133
- "\r\n": new Array(maxCachedValues).fill(0).map((_, index) => {
1134
- return "\r\n" + " ".repeat(index);
1135
- })
1136
- }
1137
- };
1138
-
1139
- // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/impl/parser.js
1140
- var ParseOptions;
1141
- (function(ParseOptions2) {
1142
- ParseOptions2.DEFAULT = {
1143
- allowTrailingComma: false
1144
- };
1145
- })(ParseOptions || (ParseOptions = {}));
1146
- function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
1147
- let currentParent = { type: "array", offset: -1, length: -1, children: [], parent: void 0 };
1148
- function ensurePropertyComplete(endOffset) {
1149
- if (currentParent.type === "property") {
1150
- currentParent.length = endOffset - currentParent.offset;
1151
- currentParent = currentParent.parent;
1152
- }
1153
- }
1154
- function onValue(valueNode) {
1155
- currentParent.children.push(valueNode);
1156
- return valueNode;
1157
- }
1158
- const visitor = {
1159
- onObjectBegin: (offset) => {
1160
- currentParent = onValue({ type: "object", offset, length: -1, parent: currentParent, children: [] });
1161
- },
1162
- onObjectProperty: (name, offset, length) => {
1163
- currentParent = onValue({ type: "property", offset, length: -1, parent: currentParent, children: [] });
1164
- currentParent.children.push({ type: "string", value: name, offset, length, parent: currentParent });
1165
- },
1166
- onObjectEnd: (offset, length) => {
1167
- ensurePropertyComplete(offset + length);
1168
- currentParent.length = offset + length - currentParent.offset;
1169
- currentParent = currentParent.parent;
1170
- ensurePropertyComplete(offset + length);
1171
- },
1172
- onArrayBegin: (offset, length) => {
1173
- currentParent = onValue({ type: "array", offset, length: -1, parent: currentParent, children: [] });
1174
- },
1175
- onArrayEnd: (offset, length) => {
1176
- currentParent.length = offset + length - currentParent.offset;
1177
- currentParent = currentParent.parent;
1178
- ensurePropertyComplete(offset + length);
1179
- },
1180
- onLiteralValue: (value, offset, length) => {
1181
- onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
1182
- ensurePropertyComplete(offset + length);
1183
- },
1184
- onSeparator: (sep, offset, length) => {
1185
- if (currentParent.type === "property") {
1186
- if (sep === ":") {
1187
- currentParent.colonOffset = offset;
1188
- } else if (sep === ",") {
1189
- ensurePropertyComplete(offset);
1190
- }
1191
- }
1192
- },
1193
- onError: (error, offset, length) => {
1194
- errors.push({ error, offset, length });
1195
- }
1196
- };
1197
- visit(text, visitor, options);
1198
- const result = currentParent.children[0];
1199
- if (result) {
1200
- delete result.parent;
1201
- }
1202
- return result;
1203
- }
1204
- function findNodeAtLocation(root, path) {
1205
- if (!root) {
1206
- return void 0;
1207
- }
1208
- let node = root;
1209
- for (let segment of path) {
1210
- if (typeof segment === "string") {
1211
- if (node.type !== "object" || !Array.isArray(node.children)) {
1212
- return void 0;
1213
- }
1214
- let found = false;
1215
- for (const propertyNode of node.children) {
1216
- if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment && propertyNode.children.length === 2) {
1217
- node = propertyNode.children[1];
1218
- found = true;
1219
- break;
1220
- }
1221
- }
1222
- if (!found) {
1223
- return void 0;
1224
- }
1225
- } else {
1226
- const index = segment;
1227
- if (node.type !== "array" || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {
1228
- return void 0;
1229
- }
1230
- node = node.children[index];
1231
- }
1232
- }
1233
- return node;
1234
- }
1235
- function visit(text, visitor, options = ParseOptions.DEFAULT) {
1236
- const _scanner = createScanner(text, false);
1237
- const _jsonPath = [];
1238
- let suppressedCallbacks = 0;
1239
- function toNoArgVisit(visitFunction) {
1240
- return visitFunction ? () => suppressedCallbacks === 0 && visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
1241
- }
1242
- function toOneArgVisit(visitFunction) {
1243
- return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()) : () => true;
1244
- }
1245
- function toOneArgVisitWithPath(visitFunction) {
1246
- return visitFunction ? (arg) => suppressedCallbacks === 0 && visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice()) : () => true;
1247
- }
1248
- function toBeginVisit(visitFunction) {
1249
- return visitFunction ? () => {
1250
- if (suppressedCallbacks > 0) {
1251
- suppressedCallbacks++;
1252
- } else {
1253
- let cbReturn = visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter(), () => _jsonPath.slice());
1254
- if (cbReturn === false) {
1255
- suppressedCallbacks = 1;
1256
- }
1257
- }
1258
- } : () => true;
1259
- }
1260
- function toEndVisit(visitFunction) {
1261
- return visitFunction ? () => {
1262
- if (suppressedCallbacks > 0) {
1263
- suppressedCallbacks--;
1264
- }
1265
- if (suppressedCallbacks === 0) {
1266
- visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter());
1267
- }
1268
- } : () => true;
1269
- }
1270
- 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);
1271
- const disallowComments = options && options.disallowComments;
1272
- const allowTrailingComma = options && options.allowTrailingComma;
1273
- function scanNext() {
1274
- while (true) {
1275
- const token = _scanner.scan();
1276
- switch (_scanner.getTokenError()) {
1277
- case 4:
1278
- handleError(
1279
- 14
1280
- /* ParseErrorCode.InvalidUnicode */
1281
- );
1282
- break;
1283
- case 5:
1284
- handleError(
1285
- 15
1286
- /* ParseErrorCode.InvalidEscapeCharacter */
1287
- );
1288
- break;
1289
- case 3:
1290
- handleError(
1291
- 13
1292
- /* ParseErrorCode.UnexpectedEndOfNumber */
1293
- );
1294
- break;
1295
- case 1:
1296
- if (!disallowComments) {
1297
- handleError(
1298
- 11
1299
- /* ParseErrorCode.UnexpectedEndOfComment */
1300
- );
1301
- }
1302
- break;
1303
- case 2:
1304
- handleError(
1305
- 12
1306
- /* ParseErrorCode.UnexpectedEndOfString */
1307
- );
1308
- break;
1309
- case 6:
1310
- handleError(
1311
- 16
1312
- /* ParseErrorCode.InvalidCharacter */
1313
- );
1314
- break;
1315
- }
1316
- switch (token) {
1317
- case 12:
1318
- case 13:
1319
- if (disallowComments) {
1320
- handleError(
1321
- 10
1322
- /* ParseErrorCode.InvalidCommentToken */
1323
- );
1324
- } else {
1325
- onComment();
1326
- }
1327
- break;
1328
- case 16:
1329
- handleError(
1330
- 1
1331
- /* ParseErrorCode.InvalidSymbol */
1332
- );
1333
- break;
1334
- case 15:
1335
- case 14:
1336
- break;
1337
- default:
1338
- return token;
1339
- }
1340
- }
1341
- }
1342
- function handleError(error, skipUntilAfter = [], skipUntil = []) {
1343
- onError(error);
1344
- if (skipUntilAfter.length + skipUntil.length > 0) {
1345
- let token = _scanner.getToken();
1346
- while (token !== 17) {
1347
- if (skipUntilAfter.indexOf(token) !== -1) {
1348
- scanNext();
1349
- break;
1350
- } else if (skipUntil.indexOf(token) !== -1) {
1351
- break;
1352
- }
1353
- token = scanNext();
1354
- }
1355
- }
1356
- }
1357
- function parseString(isValue) {
1358
- const value = _scanner.getTokenValue();
1359
- if (isValue) {
1360
- onLiteralValue(value);
1361
- } else {
1362
- onObjectProperty(value);
1363
- _jsonPath.push(value);
1364
- }
1365
- scanNext();
1366
- return true;
1367
- }
1368
- function parseLiteral() {
1369
- switch (_scanner.getToken()) {
1370
- case 11:
1371
- const tokenValue = _scanner.getTokenValue();
1372
- let value = Number(tokenValue);
1373
- if (isNaN(value)) {
1374
- handleError(
1375
- 2
1376
- /* ParseErrorCode.InvalidNumberFormat */
1377
- );
1378
- value = 0;
1379
- }
1380
- onLiteralValue(value);
1381
- break;
1382
- case 7:
1383
- onLiteralValue(null);
1384
- break;
1385
- case 8:
1386
- onLiteralValue(true);
1387
- break;
1388
- case 9:
1389
- onLiteralValue(false);
1390
- break;
1391
- default:
1392
- return false;
1393
- }
1394
- scanNext();
1395
- return true;
1396
- }
1397
- function parseProperty() {
1398
- if (_scanner.getToken() !== 10) {
1399
- handleError(3, [], [
1400
- 2,
1401
- 5
1402
- /* SyntaxKind.CommaToken */
1403
- ]);
1404
- return false;
1405
- }
1406
- parseString(false);
1407
- if (_scanner.getToken() === 6) {
1408
- onSeparator(":");
1409
- scanNext();
1410
- if (!parseValue()) {
1411
- handleError(4, [], [
1412
- 2,
1413
- 5
1414
- /* SyntaxKind.CommaToken */
1415
- ]);
1416
- }
1417
- } else {
1418
- handleError(5, [], [
1419
- 2,
1420
- 5
1421
- /* SyntaxKind.CommaToken */
1422
- ]);
1423
- }
1424
- _jsonPath.pop();
1425
- return true;
1426
- }
1427
- function parseObject() {
1428
- onObjectBegin();
1429
- scanNext();
1430
- let needsComma = false;
1431
- while (_scanner.getToken() !== 2 && _scanner.getToken() !== 17) {
1432
- if (_scanner.getToken() === 5) {
1433
- if (!needsComma) {
1434
- handleError(4, [], []);
1435
- }
1436
- onSeparator(",");
1437
- scanNext();
1438
- if (_scanner.getToken() === 2 && allowTrailingComma) {
1439
- break;
1440
- }
1441
- } else if (needsComma) {
1442
- handleError(6, [], []);
1443
- }
1444
- if (!parseProperty()) {
1445
- handleError(4, [], [
1446
- 2,
1447
- 5
1448
- /* SyntaxKind.CommaToken */
1449
- ]);
1450
- }
1451
- needsComma = true;
1452
- }
1453
- onObjectEnd();
1454
- if (_scanner.getToken() !== 2) {
1455
- handleError(7, [
1456
- 2
1457
- /* SyntaxKind.CloseBraceToken */
1458
- ], []);
1459
- } else {
1460
- scanNext();
1461
- }
1462
- return true;
1463
- }
1464
- function parseArray() {
1465
- onArrayBegin();
1466
- scanNext();
1467
- let isFirstElement = true;
1468
- let needsComma = false;
1469
- while (_scanner.getToken() !== 4 && _scanner.getToken() !== 17) {
1470
- if (_scanner.getToken() === 5) {
1471
- if (!needsComma) {
1472
- handleError(4, [], []);
1473
- }
1474
- onSeparator(",");
1475
- scanNext();
1476
- if (_scanner.getToken() === 4 && allowTrailingComma) {
1477
- break;
1478
- }
1479
- } else if (needsComma) {
1480
- handleError(6, [], []);
1481
- }
1482
- if (isFirstElement) {
1483
- _jsonPath.push(0);
1484
- isFirstElement = false;
1485
- } else {
1486
- _jsonPath[_jsonPath.length - 1]++;
1487
- }
1488
- if (!parseValue()) {
1489
- handleError(4, [], [
1490
- 4,
1491
- 5
1492
- /* SyntaxKind.CommaToken */
1493
- ]);
1494
- }
1495
- needsComma = true;
1496
- }
1497
- onArrayEnd();
1498
- if (!isFirstElement) {
1499
- _jsonPath.pop();
1500
- }
1501
- if (_scanner.getToken() !== 4) {
1502
- handleError(8, [
1503
- 4
1504
- /* SyntaxKind.CloseBracketToken */
1505
- ], []);
1506
- } else {
1507
- scanNext();
1508
- }
1509
- return true;
1510
- }
1511
- function parseValue() {
1512
- switch (_scanner.getToken()) {
1513
- case 3:
1514
- return parseArray();
1515
- case 1:
1516
- return parseObject();
1517
- case 10:
1518
- return parseString(true);
1519
- default:
1520
- return parseLiteral();
1521
- }
1522
- }
1523
- scanNext();
1524
- if (_scanner.getToken() === 17) {
1525
- if (options.allowEmptyContent) {
1526
- return true;
1527
- }
1528
- handleError(4, [], []);
1529
- return false;
1530
- }
1531
- if (!parseValue()) {
1532
- handleError(4, [], []);
1533
- return false;
1534
- }
1535
- if (_scanner.getToken() !== 17) {
1536
- handleError(9, [], []);
1537
- }
1538
- return true;
1539
- }
1540
- function getNodeType(value) {
1541
- switch (typeof value) {
1542
- case "boolean":
1543
- return "boolean";
1544
- case "number":
1545
- return "number";
1546
- case "string":
1547
- return "string";
1548
- case "object": {
1549
- if (!value) {
1550
- return "null";
1551
- } else if (Array.isArray(value)) {
1552
- return "array";
1553
- }
1554
- return "object";
1555
- }
1556
- default:
1557
- return "null";
1558
- }
1559
- }
1560
-
1561
- // ../../node_modules/.pnpm/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/esm/main.js
1562
- var ScanError;
1563
- (function(ScanError2) {
1564
- ScanError2[ScanError2["None"] = 0] = "None";
1565
- ScanError2[ScanError2["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
1566
- ScanError2[ScanError2["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
1567
- ScanError2[ScanError2["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
1568
- ScanError2[ScanError2["InvalidUnicode"] = 4] = "InvalidUnicode";
1569
- ScanError2[ScanError2["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
1570
- ScanError2[ScanError2["InvalidCharacter"] = 6] = "InvalidCharacter";
1571
- })(ScanError || (ScanError = {}));
1572
- var SyntaxKind;
1573
- (function(SyntaxKind2) {
1574
- SyntaxKind2[SyntaxKind2["OpenBraceToken"] = 1] = "OpenBraceToken";
1575
- SyntaxKind2[SyntaxKind2["CloseBraceToken"] = 2] = "CloseBraceToken";
1576
- SyntaxKind2[SyntaxKind2["OpenBracketToken"] = 3] = "OpenBracketToken";
1577
- SyntaxKind2[SyntaxKind2["CloseBracketToken"] = 4] = "CloseBracketToken";
1578
- SyntaxKind2[SyntaxKind2["CommaToken"] = 5] = "CommaToken";
1579
- SyntaxKind2[SyntaxKind2["ColonToken"] = 6] = "ColonToken";
1580
- SyntaxKind2[SyntaxKind2["NullKeyword"] = 7] = "NullKeyword";
1581
- SyntaxKind2[SyntaxKind2["TrueKeyword"] = 8] = "TrueKeyword";
1582
- SyntaxKind2[SyntaxKind2["FalseKeyword"] = 9] = "FalseKeyword";
1583
- SyntaxKind2[SyntaxKind2["StringLiteral"] = 10] = "StringLiteral";
1584
- SyntaxKind2[SyntaxKind2["NumericLiteral"] = 11] = "NumericLiteral";
1585
- SyntaxKind2[SyntaxKind2["LineCommentTrivia"] = 12] = "LineCommentTrivia";
1586
- SyntaxKind2[SyntaxKind2["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
1587
- SyntaxKind2[SyntaxKind2["LineBreakTrivia"] = 14] = "LineBreakTrivia";
1588
- SyntaxKind2[SyntaxKind2["Trivia"] = 15] = "Trivia";
1589
- SyntaxKind2[SyntaxKind2["Unknown"] = 16] = "Unknown";
1590
- SyntaxKind2[SyntaxKind2["EOF"] = 17] = "EOF";
1591
- })(SyntaxKind || (SyntaxKind = {}));
1592
- var parseTree2 = parseTree;
1593
- var findNodeAtLocation2 = findNodeAtLocation;
1594
- var ParseErrorCode;
1595
- (function(ParseErrorCode2) {
1596
- ParseErrorCode2[ParseErrorCode2["InvalidSymbol"] = 1] = "InvalidSymbol";
1597
- ParseErrorCode2[ParseErrorCode2["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
1598
- ParseErrorCode2[ParseErrorCode2["PropertyNameExpected"] = 3] = "PropertyNameExpected";
1599
- ParseErrorCode2[ParseErrorCode2["ValueExpected"] = 4] = "ValueExpected";
1600
- ParseErrorCode2[ParseErrorCode2["ColonExpected"] = 5] = "ColonExpected";
1601
- ParseErrorCode2[ParseErrorCode2["CommaExpected"] = 6] = "CommaExpected";
1602
- ParseErrorCode2[ParseErrorCode2["CloseBraceExpected"] = 7] = "CloseBraceExpected";
1603
- ParseErrorCode2[ParseErrorCode2["CloseBracketExpected"] = 8] = "CloseBracketExpected";
1604
- ParseErrorCode2[ParseErrorCode2["EndOfFileExpected"] = 9] = "EndOfFileExpected";
1605
- ParseErrorCode2[ParseErrorCode2["InvalidCommentToken"] = 10] = "InvalidCommentToken";
1606
- ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
1607
- ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
1608
- ParseErrorCode2[ParseErrorCode2["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
1609
- ParseErrorCode2[ParseErrorCode2["InvalidUnicode"] = 14] = "InvalidUnicode";
1610
- ParseErrorCode2[ParseErrorCode2["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
1611
- ParseErrorCode2[ParseErrorCode2["InvalidCharacter"] = 16] = "InvalidCharacter";
1612
- })(ParseErrorCode || (ParseErrorCode = {}));
1613
-
1614
860
  // src/generators/shared/json-edit.ts
861
+ import { findNodeAtLocation, parseTree } from "jsonc-parser";
1615
862
  function detectIndent(raw) {
1616
863
  for (const line of raw.split("\n")) {
1617
864
  const match = /^(\t+| +)/.exec(line);
@@ -1669,14 +916,14 @@ function insertProperty(raw, object, key, value, style) {
1669
916
  }
1670
917
  function setJsonValue(raw, path, value) {
1671
918
  const style = styleOf(raw);
1672
- const root = parseTree2(raw);
919
+ const root = parseTree(raw);
1673
920
  if (root === void 0) throw new Error("setJsonValue: not a JSON document");
1674
- const existing = findNodeAtLocation2(root, path);
921
+ const existing = findNodeAtLocation(root, path);
1675
922
  if (existing !== void 0) {
1676
923
  return splice(raw, existing.offset, existing.offset + existing.length, renderValue(value, lineIndentAt(raw, existing.offset), style));
1677
924
  }
1678
925
  for (let depth = path.length - 1; depth >= 0; depth--) {
1679
- const parent = depth === 0 ? root : findNodeAtLocation2(root, path.slice(0, depth));
926
+ const parent = depth === 0 ? root : findNodeAtLocation(root, path.slice(0, depth));
1680
927
  if (parent === void 0) continue;
1681
928
  if (parent.type !== "object") throw new Error(`setJsonValue: ${path.slice(0, depth).join(".") || "the root"} is not an object`);
1682
929
  return insertProperty(raw, parent, path[depth], nest(path.slice(depth + 1), value), style);
@@ -1707,6 +954,7 @@ function treePackageManager(tree, config) {
1707
954
 
1708
955
  // src/generators/add-review/render.ts
1709
956
  var DEPENDABOT_PATH = ".github/dependabot.yml";
957
+ var PROVIDER_STATUS_URL = "https://github.com/clearlydev/nx-archweave/blob/main/docs/pr-review.md#provider-status";
1710
958
  function renderLineDiff(existing, generated) {
1711
959
  const a = existing.split("\n");
1712
960
  const b = generated.split("\n");
@@ -1804,6 +1052,10 @@ function renderAddReviewReport(report) {
1804
1052
  }
1805
1053
  lines.push("");
1806
1054
  lines.push(`Note: the review workflow stays green-skipped until you register the ${report.requiredSecretName} secret.`);
1055
+ if (report.betaProvider !== void 0) {
1056
+ lines.push(`Note: the ${report.betaProvider} provider is in beta \u2014 its workflow hasn't finished a review end to end on`);
1057
+ lines.push(`GitHub Actions yet. Status, costs and known issues: ${PROVIDER_STATUS_URL}`);
1058
+ }
1807
1059
  lines.push("Note: this workflow runs with elevated permissions only after it is merged to the default branch \u2014");
1808
1060
  lines.push("merging is the first real validation.");
1809
1061
  return lines.join("\n");
@@ -1844,6 +1096,7 @@ function deepEqual(a, b) {
1844
1096
  return aKeys.every((key) => deepEqual(a[key], b[key]));
1845
1097
  }
1846
1098
  var PROVIDERS = ["claude", "gemini", "gpt", "cursor"];
1099
+ var BETA_PROVIDERS = ["gemini", "gpt", "cursor"];
1847
1100
  var MODES = ["fast", "standard", "thorough"];
1848
1101
  function recordedReview(config) {
1849
1102
  const review = config?.["review"];
@@ -1863,9 +1116,10 @@ function runAddReview(tree, options) {
1863
1116
  const packageManager = options.packageManager ?? detectedPm ?? "pnpm";
1864
1117
  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;
1865
1118
  const recorded = recordedReview(config.parsed);
1119
+ const provider = options.provider ?? recorded.provider ?? "claude";
1866
1120
  const plan = composeReviewSetup({
1867
1121
  enabled: true,
1868
- provider: options.provider ?? recorded.provider ?? "claude",
1122
+ provider,
1869
1123
  mode: options.mode ?? recorded.mode ?? "standard",
1870
1124
  locale: resolveLocale(options.locale, config),
1871
1125
  maxRounds: options.maxRounds ?? recorded.maxRounds ?? 3,
@@ -1960,7 +1214,8 @@ function runAddReview(tree, options) {
1960
1214
  configError: null,
1961
1215
  dependabot,
1962
1216
  dependabotProposal: dependabot === "proposed" ? dependabotFile.content : null,
1963
- ...packageManagerNote !== void 0 ? { packageManagerNote } : {}
1217
+ ...packageManagerNote !== void 0 ? { packageManagerNote } : {},
1218
+ ...BETA_PROVIDERS.includes(provider) ? { betaProvider: provider } : {}
1964
1219
  };
1965
1220
  }
1966
1221
  async function addReviewGenerator(tree, options) {