Skip to content

feat: codeblock verifier via planner and runner on sandbox#215

Merged
Kinfe123 merged 4 commits into
mainfrom
feat/codeblock-validation-against-runner-planner
May 24, 2026
Merged

feat: codeblock verifier via planner and runner on sandbox#215
Kinfe123 merged 4 commits into
mainfrom
feat/codeblock-validation-against-runner-planner

Conversation

@Kinfe123
Copy link
Copy Markdown
Member

@Kinfe123 Kinfe123 commented May 24, 2026

Summary by cubic

Adds a code block validator to the docs CLI to plan and optionally run fenced MD/MDX snippets. Includes a vercel-sandbox runner powered by @vercel/sandbox with token support and clear pass/skip/fail reporting.

  • New Features

    • Command: docs codeblocks validate with --plan, --run, --json, --config (aliases: codeblocks/code-blocks; help and unknown-subcommand hints).
    • Config: codeBlocks.validate with planner, runner, policies (missingEnv, unsupportedLanguage), and mode (plan | report); loadDocsConfigModule supports silent mode for cleaner CLI output.
    • Planners: "metadata" (default), "openai", "openai-compatible", and reserved "cloud".
    • Runners: "local", "vercel-sandbox", and reserved "cloud"; supports tokenEnv, per-command timeout, and runtime selection.
    • Output: redacts secrets, trims large logs, and exits non-zero on failures.
    • Docs/Types: defineDocs passes through codeBlocks; types exported from index.ts; MCP schema includes codeBlocks and validate; CLI/config docs and skills updated with examples; website docs.config.tsx example; tests for CLI parsing, planning, and sandbox execution. Adds dependency @vercel/sandbox.
  • Migration

    • In docs.config.ts, enable: codeBlocks: { validate: { planner, runner, ... } }; set runner.tokenEnv (defaults to VERCEL_TOKEN).
    • Provide envs:
      • Planners: e.g., OPENAI_API_KEY for "openai"/compatible.
      • Sandbox runs: VERCEL_TOKEN (or your tokenEnv), optional VERCEL_PROJECT_ID/VERCEL_TEAM_ID.
      • Map runtime envs via env: { ... }.
    • Run:
      • Plan only: pnpm exec docs codeblocks validate --plan
      • Execute: pnpm exec docs codeblocks validate

Written for commit 7d95bce. Summary will update on new commits. Review in cubic

@vercel
Copy link
Copy Markdown

vercel Bot commented May 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs-website Ready Ready Preview, Comment May 24, 2026 10:29pm

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 24, 2026

Open in StackBlitz

@farming-labs/astro

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/astro@215

@farming-labs/astro-theme

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/astro-theme@215

@farming-labs/docs

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/docs@215

@farming-labs/theme

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/theme@215

@farming-labs/next

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/next@215

@farming-labs/nuxt

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/nuxt@215

@farming-labs/nuxt-theme

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/nuxt-theme@215

@farming-labs/svelte

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/svelte@215

@farming-labs/svelte-theme

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/svelte-theme@215

@farming-labs/tanstack-start

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/tanstack-start@215

commit: 7d95bce

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 issues found across 16 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/docs/src/cli/codeblocks.ts">

<violation number="1" location="packages/docs/src/cli/codeblocks.ts:122">
P2: Disabled-mode JSON output bypasses redaction and can leak `planner.apiKey`.</violation>

<violation number="2" location="packages/docs/src/cli/codeblocks.ts:146">
P2: Report labeling uses the pre-override mode, so `--run` can execute validations while still printing a "plan" label.</violation>
</file>

<file name="packages/docs/src/code-blocks.ts">

<violation number="1" location="packages/docs/src/code-blocks.ts:304">
P1: The no-runnable-plans branch incorrectly converts any skipped result with a reason into FAIL when `missingEnv` is `error`, including non-env skips.</violation>

<violation number="2" location="packages/docs/src/code-blocks.ts:993">
P2: Closing fence detection rejects valid CommonMark closers that are longer than the opening fence.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/docs/src/code-blocks.ts Outdated
Comment thread packages/docs/src/cli/codeblocks.ts Outdated
Comment thread packages/docs/src/cli/codeblocks.ts Outdated
Comment thread packages/docs/src/code-blocks.ts Outdated
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 8 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/docs/src/code-blocks.ts">

<violation number="1" location="packages/docs/src/code-blocks.ts:965">
P2: Project discovery is nondeterministic: it always uses the first Vercel project, which can select the wrong project/team on multi-project accounts.</violation>
</file>

<file name="packages/docs/src/cli/codeblocks.ts">

<violation number="1" location="packages/docs/src/cli/codeblocks.ts:251">
P2: `readStaticRunnerConfig` incorrectly rejects valid runner objects when `provider` is omitted, so static fallback can silently ignore settings like `timeoutMs`.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

const payload = (await response.json()) as {
projects?: Array<{ id?: unknown; accountId?: unknown }>;
};
const project = payload.projects?.[0];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Project discovery is nondeterministic: it always uses the first Vercel project, which can select the wrong project/team on multi-project accounts.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/docs/src/code-blocks.ts, line 965:

<comment>Project discovery is nondeterministic: it always uses the first Vercel project, which can select the wrong project/team on multi-project accounts.</comment>

<file context>
@@ -876,12 +915,84 @@ async function runPlansInVercelSandbox(
+    const payload = (await response.json()) as {
+      projects?: Array<{ id?: unknown; accountId?: unknown }>;
+    };
+    const project = payload.projects?.[0];
+    if (!project) return undefined;
+
</file context>
Suggested change
const project = payload.projects?.[0];
const projects = payload.projects ?? [];
if (projects.length !== 1) return undefined;
const project = projects[0];

const runtime = readStringProperty(block, "runtime");
const timeoutMs = readNumberProperty(block, "timeoutMs");

if (provider !== "local" && provider !== "vercel-sandbox" && provider !== "cloud") {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: readStaticRunnerConfig incorrectly rejects valid runner objects when provider is omitted, so static fallback can silently ignore settings like timeoutMs.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/docs/src/cli/codeblocks.ts, line 251:

<comment>`readStaticRunnerConfig` incorrectly rejects valid runner objects when `provider` is omitted, so static fallback can silently ignore settings like `timeoutMs`.</comment>

<file context>
@@ -160,12 +165,136 @@ function readStaticCodeBlocksValidateConfig(
+  const runtime = readStringProperty(block, "runtime");
+  const timeoutMs = readNumberProperty(block, "timeoutMs");
+
+  if (provider !== "local" && provider !== "vercel-sandbox" && provider !== "cloud") {
+    return undefined;
+  }
</file context>
Suggested change
if (provider !== "local" && provider !== "vercel-sandbox" && provider !== "cloud") {
if (provider && provider !== "local" && provider !== "vercel-sandbox" && provider !== "cloud") {

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/docs/src/code-blocks.ts">

<violation number="1" location="packages/docs/src/code-blocks.ts:965">
P2: Project discovery is nondeterministic: it always uses the first Vercel project, which can select the wrong project/team on multi-project accounts.</violation>
</file>

<file name="packages/docs/src/cli/codeblocks.ts">

<violation number="1" location="packages/docs/src/cli/codeblocks.ts:251">
P2: `readStaticRunnerConfig` incorrectly rejects valid runner objects when `provider` is omitted, so static fallback can silently ignore settings like `timeoutMs`.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/docs/src/cli/codeblocks.test.ts Outdated
@Kinfe123 Kinfe123 merged commit 30c4d99 into main May 24, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant