Skip to content

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

Closed
jamesbhobbs wants to merge 3 commits into
filipzitny/mar-250-create-examples-for-open-sourcefrom
val-deepnotefiles
Closed

jamesbhobbs wants to merge 3 commits into
filipzitny/mar-250-create-examples-for-open-sourcefrom
val-deepnotefiles

Conversation

@jamesbhobbs

@jamesbhobbs jamesbhobbs commented Nov 3, 2025 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features
    • Added .deepnote file validation functionality with recursive directory scanning
    • Integrated .deepnote validation into the CI pipeline as an automated quality check
    • New validate:deepnote-files script available for manual validation

@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 (e443f6d) to head (24438fe).

Files with missing lines Patch % Lines
packages/convert/src/cli.ts 0.00% 72 Missing ⚠️

❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@                                  Coverage Diff                                   @@
##           filipzitny/mar-250-create-examples-for-open-source     #108      +/-   ##
======================================================================================
- Coverage                                               95.24%   86.53%   -8.72%     
======================================================================================
  Files                                                      25       25              
  Lines                                                     715      787      +72     
  Branches                                                  207      225      +18     
======================================================================================
  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.

@coderabbitai

coderabbitai Bot commented Nov 3, 2025 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Extends the convert package CLI from single-command to multi-command architecture supporting both convert and validate operations. Adds a new validate function that recursively scans directories for .deepnote files, parses their YAML content, validates against the Deepnote schema, and reports results via CLI. Introduces a corresponding CI job to run validation in the pipeline. Updates build configuration to use tsdown defaults and adds an npm script to trigger validation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Validate Function
    participant File System
    participant Schema Validator

    User->>CLI: pnpm run validate:deepnote-files
    CLI->>Validate Function: validate(inputPath, cwd)
    
    alt Is Single File
        Validate Function->>File System: Read .deepnote file
        File System-->>Validate Function: YAML content
    else Is Directory
        Validate Function->>File System: Find all .deepnote files recursively
        File System-->>Validate Function: File list
        loop For each file
            Validate Function->>File System: Read file
            File System-->>Validate Function: YAML content
        end
    end
    
    loop Validate each file
        Validate Function->>Validate Function: Parse YAML
        Validate Function->>Schema Validator: Validate against deepnoteFileSchema
        Schema Validator-->>Validate Function: { valid, errors? }
    end
    
    Validate Function->>CLI: Report per-file results (colored output)
    CLI->>User: Exit with code (0 if all valid, 1 if any invalid)
Loading

Possibly related PRs

Suggested reviewers

  • andyjakubowski
  • Artmann

Pre-merge checks

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title mentions 'vibed cli' and 'validating deepnote files' which aligns with the core changes: adding a new validate command to the CLI and introducing a validation workflow in the CI pipeline. However, 'vibed' appears to be a typo (likely 'vibrant' or similar), and the phrasing is awkward. The title captures the main intent but is somewhat unclear due to the typo and informal language.

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

* feat: vibed cli for valdiating the deepnote files

* chore: fix lock
@jamesbhobbs jamesbhobbs changed the title chore: enable deepnote file validation in our repo feat: vibed cli for valdiating the deepnote files Nov 3, 2025

@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: 4

📜 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 e443f6d and 6cb9e6c.

📒 Files selected for processing (6)
  • .github/workflows/ci.yml (1 hunks)
  • package.json (1 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)
🧰 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)
🔇 Additional comments (6)
packages/convert/tsdown.config.ts (1)

1-8: LGTM!

The tsdown configuration correctly defines entry points, output format, and target runtime. Aligns with the package's Node 18+ requirement.

package.json (1)

28-29: LGTM!

The validation script correctly targets the built CLI. CI workflow appropriately runs build before validation.

.github/workflows/ci.yml (1)

41-66: LGTM!

The CI job follows existing patterns and correctly builds before validating. Timeout and steps are appropriate.

packages/convert/package.json (1)

31-33: LGTM!

Simplified scripts by moving configuration to tsdown.config.ts. Cleaner and follows best practices.

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

142-168: LGTM!

Clean validation logic with proper error handling. safeParse prevents throws, and error formatting is clear.


170-254: LGTM on overall structure and exit handling.

The validate function appropriately handles both directory and single-file cases. Exit code 1 on failure is correct for CI integration.

Comment on lines +6 to 60
cli({
name: 'deepnote-convert',
parameters: ['<path>'],
flags: {
projectName: {
description: 'The name of the Deepnote project.',
type: String,
},
outputPath: {
alias: 'o',
description: 'The path where the .deepnote file will be saved.',
type: String,
},
cwd: {
description: 'The working directory to resolve paths relative to.',
type: String,
},
},
})

await convert({
inputPath: argv._.path,
projectName: argv.flags.projectName,
outputPath: argv.flags.outputPath,
cwd: argv.flags.cwd ?? process.cwd(),
version: '1.2.0',
commands: [
command(
{
name: 'convert',
alias: 'c',
parameters: ['<path>'],
flags: {
projectName: {
description: 'The name of the Deepnote project.',
type: String,
},
outputPath: {
alias: 'o',
description: 'The path where the .deepnote file will be saved.',
type: String,
},
cwd: {
description: 'The working directory to resolve paths relative to.',
type: String,
},
},
},
async argv => {
await convert({
inputPath: argv._.path,
projectName: argv.flags.projectName,
outputPath: argv.flags.outputPath,
cwd: argv.flags.cwd ?? process.cwd(),
})
}
),
command(
{
name: 'validate',
alias: 'v',
parameters: ['<path>'],
flags: {
cwd: {
description: 'The working directory to resolve paths relative to.',
type: String,
},
},
},
async argv => {
await validate({
inputPath: argv._.path,
cwd: argv.flags.cwd ?? process.cwd(),
})
}
),
],
})

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 importing version from package.json.

The version is hardcoded at line 8, duplicating the value in package.json. This creates maintenance overhead.

You could import it from package.json:

+import { readFileSync } from 'node:fs'
+import { resolve, dirname } from 'node:path'
+import { fileURLToPath } from 'node:url'
 import { cli, command } from 'cleye'
 import { convert, validate } from './cli.js'

+const __dirname = dirname(fileURLToPath(import.meta.url))
+const pkg = JSON.parse(readFileSync(resolve(__dirname, '../package.json'), 'utf-8'))
+
 async function main() {
   cli({
     name: 'deepnote-convert',
-    version: '1.2.0',
+    version: pkg.version,
     commands: [

Or keep it simple if manual sync is acceptable.

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

🤖 Prompt for AI Agents
In packages/convert/src/bin.ts around lines 6 to 60, the CLI version is
hardcoded ("1.2.0") which duplicates package.json; import the version field from
the package.json (e.g., const { version } = require('../package.json') or the
appropriate relative path / ES import) at the top of the file and replace the
hardcoded string with that imported version value so the CLI always reflects
package.json.

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.

🧹 Nitpick | 🔵 Trivial

Consider using @deepnote/blocks parseYaml wrapper.

The blocks package has a parseYaml wrapper (packages/blocks/src/deserialize-file/parse-yaml.ts) that adds error handling. Currently importing directly from yaml library duplicates this logic at line 149.

If the wrapper is exported, prefer it:

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

Otherwise, current approach is acceptable but involves slight duplication.

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

🤖 Prompt for AI Agents
In packages/convert/src/cli.ts around line 6 (and usage at line 149), the file
imports parse from 'yaml' directly which duplicates error-handling logic;
replace the direct import with the @deepnote/blocks parseYaml wrapper
(packages/blocks/src/deserialize-file/parse-yaml.ts) by importing the exported
wrapper and use it where parseYaml is currently called; if that wrapper is not
exported from the blocks package, leave the existing direct import but add a
TODO comment referencing the wrapper export so we can switch once it’s
available.

Comment on lines +118 to +140
/**
* Recursively find all .deepnote files in a directory
*/
async function findDeepnoteFiles(dir: string): Promise<string[]> {
const files: string[] = []
const entries = await fs.readdir(dir, { withFileTypes: true })

for (const entry of entries) {
const fullPath = resolve(dir, entry.name)

if (entry.isDirectory()) {
// Skip node_modules and hidden directories
if (entry.name === 'node_modules' || entry.name.startsWith('.')) {
continue
}
files.push(...(await findDeepnoteFiles(fullPath)))
} else if (entry.name.endsWith('.deepnote')) {
files.push(fullPath)
}
}

return files
}

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 | 🟡 Minor

Extension check is case-sensitive.

Line 134 checks entry.name.endsWith('.deepnote') which won't match files like .Deepnote or .DEEPNOTE. If these exist in the wild, validation will skip them silently.

If case-insensitivity is desired:

-    } else if (entry.name.endsWith('.deepnote')) {
+    } else if (entry.name.toLowerCase().endsWith('.deepnote')) {

Otherwise, document that validation is case-sensitive.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* Recursively find all .deepnote files in a directory
*/
async function findDeepnoteFiles(dir: string): Promise<string[]> {
const files: string[] = []
const entries = await fs.readdir(dir, { withFileTypes: true })
for (const entry of entries) {
const fullPath = resolve(dir, entry.name)
if (entry.isDirectory()) {
// Skip node_modules and hidden directories
if (entry.name === 'node_modules' || entry.name.startsWith('.')) {
continue
}
files.push(...(await findDeepnoteFiles(fullPath)))
} else if (entry.name.endsWith('.deepnote')) {
files.push(fullPath)
}
}
return files
}
/**
* Recursively find all .deepnote files in a directory
*/
async function findDeepnoteFiles(dir: string): Promise<string[]> {
const files: string[] = []
const entries = await fs.readdir(dir, { withFileTypes: true })
for (const entry of entries) {
const fullPath = resolve(dir, entry.name)
if (entry.isDirectory()) {
// Skip node_modules and hidden directories
if (entry.name === 'node_modules' || entry.name.startsWith('.')) {
continue
}
files.push(...(await findDeepnoteFiles(fullPath)))
} else if (entry.name.toLowerCase().endsWith('.deepnote')) {
files.push(fullPath)
}
}
return files
}
🤖 Prompt for AI Agents
In packages/convert/src/cli.ts around lines 118 to 140 the extension check
entry.name.endsWith('.deepnote') is case-sensitive and will miss files like
.Deepnote or .DEEPNOTE; update the condition to perform a case-insensitive
comparison (e.g. use entry.name.toLowerCase().endsWith('.deepnote')) so all case
variants are matched, and keep the rest of the logic unchanged.

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.

⚠️ Potential issue | 🟡 Minor

File display loses directory context.

Line 192 uses basename(file) for display. If multiple .deepnote files have the same name in different subdirectories, the output becomes ambiguous—you won't know which file failed.

Consider using relative path instead:

+    const relativePath = relative(absolutePath, file)
-    const relativePath = basename(file)
     const result = await validateSingleFile(file)

Or keep basename if directory structure is guaranteed flat.

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 drops directory context and can make multiple files with
the same name ambiguous; change it to a relative path (e.g.,
path.relative(process.cwd(), file) or relative to the input directory you
expect) so the display preserves subdirectory structure, and use that
relativePath variable when pushing results instead of basename.

@Yggdrasill501
Yggdrasill501 deleted the branch filipzitny/mar-250-create-examples-for-open-source November 6, 2025 15:20
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.

2 participants