Skip to content

Write toolkit generator output safely#1077

Draft
jottakka wants to merge 4 commits into
mainfrom
fix/safe-toolkit-generator-output
Draft

Write toolkit generator output safely#1077
jottakka wants to merge 4 commits into
mainfrom
fix/safe-toolkit-generator-output

Conversation

@jottakka

@jottakka jottakka commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • reject unsafe, reserved, and colliding toolkit output filenames before writes begin
  • atomically replace generated JSON and sort index entries deterministically
  • prevent --overwrite-output from deleting the repository root, home directory, or outside-repository paths

Test plan

  • pnpm exec tsc --noEmit --project toolkit-docs-generator/tsconfig.json
  • pnpm exec vitest run --root toolkit-docs-generator

Note

Medium Risk
Changes default output location and overwrite safety rules, which can surprise existing workflows; filesystem deletion guards reduce catastrophic misuse risk.

Overview
Hardens toolkit docs generation so writes and --overwrite-output are less likely to corrupt data or delete the wrong paths.

JSON output: Toolkit IDs are validated before any file is written (safe filename pattern, index reserved, case-insensitive collisions blocked). Per-toolkit and index.json writes use atomic replace (temp file + rename). index.json toolkit entries are sorted deterministically by normalized ID.

CLI / paths: Default -o output moves to toolkit-docs-generator/data/toolkits via shared resolveDefaultOutputDir. Clearing output delegates to clearSafeOutputDir, which refuses dangerous targets (repo root, generator package root, home, and relative paths outside the repo).

Tests: Coverage for unsafe IDs, collisions, index sorting, safe clear behavior, and default output resolution.

Reviewed by Cursor Bugbot for commit 264ca42. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jul 17, 2026 4:24am

Request Review

Comment thread toolkit-docs-generator/src/utils/output-dir.ts Outdated
Comment thread toolkit-docs-generator/src/generator/json-generator.ts
@jottakka
jottakka marked this pull request as draft July 17, 2026 03:44
@jottakka

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor

cursor Bot commented Jul 17, 2026

Copy link
Copy Markdown

Current version of PR was reviewed by /review-bugbot on Jul 17, 00:49 GMT-3. It flagged 0 findings.

Bugbot on commit 983b428 is skipped.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jottakka

Copy link
Copy Markdown
Contributor Author

bugbot run

Comment thread toolkit-docs-generator/src/generator/json-generator.ts
Co-authored-by: Cursor <cursoragent@cursor.com>
@jottakka

Copy link
Copy Markdown
Contributor Author

bugbot run

Comment thread toolkit-docs-generator/src/utils/output-dir.ts
Comment thread toolkit-docs-generator/src/generator/json-generator.ts Outdated
Co-authored-by: Cursor <cursoragent@cursor.com>
@jottakka

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 264ca42. Configure here.

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