Skip to content

feat: vibed cli for valdiating the deepnote files - #109

Merged
jamesbhobbs merged 2 commits into
val-deepnotefilesfrom
val-deepnotefiles-pack
Nov 3, 2025
Merged

jamesbhobbs merged 2 commits into
val-deepnotefilesfrom
val-deepnotefiles-pack

Conversation

@jamesbhobbs

@jamesbhobbs jamesbhobbs commented Nov 3, 2025 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added a validate command to the CLI for checking and validating Deepnote file formats, with support for both directory-wide and single-file validation.
  • Refactor

    • Reorganized CLI architecture to use a command-based structure for improved modularity.
    • Integrated validation functionality directly into the core package.
  • Chores

    • Streamlined build scripts and removed unnecessary dependencies from the toolchain.

@coderabbitai

coderabbitai Bot commented Nov 3, 2025 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

This PR refactors the CLI structure by transitioning from a standalone validation script to an integrated command-based architecture. The validate logic previously in validate-deepnote-files.ts is moved into packages/convert/src/cli.ts as a new public validate() function. The CLI entry point is restructured to use cleye's command API with separate convert and validate subcommands. Build scripts are simplified by delegating configuration to a new tsdown.config.ts file. Dependencies (tsx, yaml, zod) are removed from the root package, consolidating them within the convert package.

Sequence Diagram

sequenceDiagram
    participant User
    participant bin as bin.ts
    participant cli as cli.ts
    participant yaml as YAML Parser

    User->>bin: npm run validate .
    bin->>bin: Parse command: validate
    bin->>cli: validate({ path: ".", cwd: process.cwd() })
    cli->>cli: findDeepnoteFiles(path)
    loop For each .deepnote file
        cli->>yaml: parseYaml(fileContent)
        yaml-->>cli: parsed content
        cli->>cli: validateSingleFile(parsed)
        cli->>User: Print validation result
    end
    cli->>User: Exit with code 0/1
Loading

Possibly related PRs

Suggested reviewers

  • Artmann
  • saltenasl
  • andyjakubowski

Pre-merge checks

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'feat: vibed cli for valdiating the deepnote files' contains a typo ('valdiating' should be 'validating') and uses the informal term 'vibed', which obscures the core change. While the PR does restructure the CLI for validating Deepnote files—moving from a standalone script to an integrated command-based system—the title doesn't clearly communicate this architectural shift. The primary objective is CLI restructuring with improved modularity, not just adding validation. Clarify the title to reflect the main change more precisely. Consider: 'feat: restructure deepnote validation into modular CLI commands' or 'feat: refactor validate command into structured CLI subcommand'. Fix the typo ('valdiating' → 'validating') and replace informal language ('vibed') with concrete terminology describing the actual implementation.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Nov 3, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 72 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.53%. Comparing base (76e7de0) to head (02a9feb).
⚠️ Report is 1 commits behind head on val-deepnotefiles.

Files with missing lines Patch % Lines
packages/convert/src/cli.ts 0.00% 72 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##           val-deepnotefiles     #109      +/-   ##
=====================================================
- Coverage              95.24%   86.53%   -8.72%     
=====================================================
  Files                     25       25              
  Lines                    715      787      +72     
  Branches                 210      225      +15     
=====================================================
  Hits                     681      681              
- Misses                    34      106      +72     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jamesbhobbs
jamesbhobbs marked this pull request as ready for review November 3, 2025 17:46
@jamesbhobbs
jamesbhobbs requested a review from a team as a code owner November 3, 2025 17:46
@jamesbhobbs
jamesbhobbs merged commit 6cb9e6c into val-deepnotefiles Nov 3, 2025
@jamesbhobbs
jamesbhobbs deleted the val-deepnotefiles-pack branch November 3, 2025 17:46

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
package.json (1)

1-61: Update lockfile to match package.json changes.

The pipeline is failing because the lockfile is out of sync with package.json. Run pnpm install to update it.

#!/bin/bash
# Update the lockfile
pnpm install
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 76e7de0 and 7e3c6de.

📒 Files selected for processing (6)
  • package.json (2 hunks)
  • packages/convert/package.json (1 hunks)
  • packages/convert/src/bin.ts (1 hunks)
  • packages/convert/src/cli.ts (2 hunks)
  • packages/convert/tsdown.config.ts (1 hunks)
  • validate-deepnote-files.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • validate-deepnote-files.ts
🧰 Additional context used
📓 Path-based instructions (3)
packages/*/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/*/src/**/*.{ts,tsx}: Use strict type checking and prefer type safety over convenience
Use const for immutable values
Avoid any; use proper type definitions and type guards

Files:

  • packages/convert/src/bin.ts
  • packages/convert/src/cli.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Follow Biome's lint rules as configured in biome.json
Use literal keys (dot notation) instead of bracket notation when possible
Prefer single quotes for strings (except when avoiding escapes)

Files:

  • packages/convert/src/bin.ts
  • packages/convert/tsdown.config.ts
  • packages/convert/src/cli.ts
packages/*/src/**/*

📄 CodeRabbit inference engine (CLAUDE.md)

Place source code under packages/*/src/

Files:

  • packages/convert/src/bin.ts
  • packages/convert/src/cli.ts
🧬 Code graph analysis (2)
packages/convert/src/bin.ts (1)
packages/convert/src/cli.ts (2)
  • convert (16-111)
  • validate (170-254)
packages/convert/src/cli.ts (1)
packages/blocks/src/deserialize-file/parse-yaml.ts (1)
  • parseYaml (3-12)
🪛 GitHub Actions: CI
package.json

[error] 1-1: Lockfile out of date: specifiers in the lockfile don't match package.json. Run 'pnpm install' without --frozen-lockfile to update.

packages/convert/package.json

[error] 1-1: Lockfile out of date: specifiers in the lockfile don't match package.json. Run 'pnpm install' without --frozen-lockfile to update.

🔇 Additional comments (9)
packages/convert/package.json (1)

31-33: LGTM!

Centralizing tsdown configuration in tsdown.config.ts improves maintainability.

packages/convert/tsdown.config.ts (1)

1-8: LGTM!

Configuration correctly defines both library and CLI entry points with appropriate ES module output.

packages/convert/src/bin.ts (3)

10-39: LGTM!

Convert command correctly maps CLI arguments to the convert function.


40-58: LGTM!

Validate command correctly maps CLI arguments to the validate function.


63-69: LGTM!

Test guard and error handling are appropriate for a CLI entry point.

packages/convert/src/cli.ts (4)

113-116: LGTM!

Interface follows the same pattern as ConvertOptions.


121-140: LGTM!

Recursive file discovery with appropriate filtering of node_modules and hidden directories.


145-168: LGTM with one caveat.

Validation logic is sound with proper error handling and user-friendly messages. Just ensure the parseYaml import is updated per the earlier comment.


227-253: LGTM!

Single file validation with clear success/error feedback and appropriate exit codes.

Comment thread package.json
"test:coverage": "vitest run --coverage",
"typecheck": "tsc --noEmit -p tsconfig.json && pnpm -r exec tsc --noEmit",
"validate:deepnote-files": "tsx validate-deepnote-files.ts"
"validate:deepnote-files": "node packages/convert/dist/bin.js validate ."

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.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify build order for validation script.

The script now depends on packages/convert/dist/bin.js being built. Ensure the convert package is built before this script runs (e.g., via pnpm build or a prepare hook).

Run the following to verify the build produces the expected binary:


🏁 Script executed:

#!/bin/bash
# Verify that bin.js is produced by the build

cd packages/convert
pnpm run build

# Check if bin.js exists and is executable
if [ -f "dist/bin.js" ]; then
  echo "✓ dist/bin.js exists"
  head -1 dist/bin.js
else
  echo "✗ dist/bin.js not found"
  exit 1
fi

Length of output: 242



---

🏁 Script executed:

```shell
#!/bin/bash
# Check root package.json for build/prepare scripts
cat package.json | grep -A 20 '"scripts"'

# Check if bin.ts exists and implements validate command
if [ -f "packages/convert/src/bin.ts" ]; then
  echo -e "\n--- bin.ts found ---"
  grep -n "validate" packages/convert/src/bin.ts | head -10
fi

# Verify validate-deepnote-files.ts was removed
if [ -f "packages/convert/src/validate-deepnote-files.ts" ]; then
  echo -e "\n--- validate-deepnote-files.ts still exists ---"
else
  echo -e "\n--- validate-deepnote-files.ts removed ---"
fi

Length of output: 1272


Build dependency not enforced for validation script.

The validate:deepnote-files script depends on packages/convert/dist/bin.js existing, but the prepare hook only runs Husky—it doesn't build. Running this script immediately after pnpm install will fail.

Either:

  • Add pnpm build to the prepare hook or add a postinstall script
  • Revert to using tsx to run the source file directly
  • Document that pnpm build must run first
🤖 Prompt for AI Agents
In package.json around line 29, the "validate:deepnote-files" script points to
packages/convert/dist/bin.js which may not exist after install because the
prepare hook only runs Husky; update to ensure the built file exists by either
adding "pnpm build" to the prepare hook (or adding a postinstall script that
runs the build), or change the validate script to run the source with tsx (e.g.,
point at the TS source) so it doesn't require prior build; apply one of these
fixes and keep package scripts consistent with the chosen approach.

import { deepnoteFileSchema } from '@deepnote/blocks'
import chalk from 'chalk'
import ora from 'ora'
import { parse as parseYaml } from 'yaml'

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.

🛠️ Refactor suggestion | 🟠 Major

Use existing parseYaml helper from @deepnote/blocks.

The blocks package already exports a parseYaml helper with better error messages. Import it instead of using yaml's parse directly.

-import { parse as parseYaml } from 'yaml'
+import { deepnoteFileSchema, parseYaml } from '@deepnote/blocks'

Then update line 149:

-    const parsed = parseYaml(content)
+    const parsed = parseYaml(content)

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In packages/convert/src/cli.ts around line 6 (and affecting line 149), replace
the direct import from 'yaml' with the parseYaml helper exported by
@deepnote/blocks; remove "import { parse as parseYaml } from 'yaml'" and instead
import parseYaml from '@deepnote/blocks', then update the usage at line 149 to
call that helper so you get the blocks package's richer error messages and
handling.

Comment on lines +191 to +194
for (const file of deepnoteFiles) {
const relativePath = basename(file)
const result = await validateSingleFile(file)
results.push({ file: relativePath, ...result })

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.

🧹 Nitpick | 🔵 Trivial

Consider showing relative paths instead of just filenames.

Using basename() shows only the filename. If multiple .deepnote files exist with the same name in different directories, users won't be able to distinguish them.

+import { relative } from 'node:path'
...
-      const relativePath = basename(file)
+      const relativePath = relative(absolutePath, file)

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In packages/convert/src/cli.ts around lines 191 to 194, the code uses
basename(file) which only shows the filename and can collide for same-named
.deepnote files in different directories; replace basename(file) with a relative
path (for example path.relative(process.cwd(), file) or path.relative(inputRoot,
file) depending on the CLI input root) so the pushed results use a
disambiguating relative path, and ensure you import/require path if not already
present.

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