feat: add automatic project setup detection to generator lifecycle#344
Open
jonaslagoni wants to merge 9 commits intomainfrom
Open
feat: add automatic project setup detection to generator lifecycle#344jonaslagoni wants to merge 9 commits intomainfrom
jonaslagoni wants to merge 9 commits intomainfrom
Conversation
Resolves #336 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for the-codegen-project canceled.
|
Add parseJsonc() function that strips comments and trailing commas before JSON parsing. This fixes auto-detection for projects using TypeScript's official JSONC format in tsconfig.json. - Added parseJsonc() to strip // comments, /* */ comments, and trailing commas - Updated readJsonFile() with allowJsonc parameter - Changed tsconfig.json parsing to use JSONC parser 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replaced naive regex-based comment stripping with a proper state machine parser that tracks string boundaries and escape sequences. This prevents corruption of JSON string values containing '//' (like URLs or scoped package paths such as node_modules//@types). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…gs in JSONC parser Refactored parseJsonc function by extracting helper functions: - copyStringLiteral: handles string literal copying with escapes - skipSingleLineComment: skips // comments - skipMultiLineComment: skips /* */ comments Also replaced bracket notation (content[i]) with .charAt() method to resolve security/detect-object-injection ESLint warnings. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move trailing comma detection into the state machine's first pass instead of applying a regex after. This prevents corruption of string values that contain patterns like ",}" or ",]" (e.g., "some,}path"). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The isTrailingComma function now skips both single-line (//) and multi-line (/* */) comments when checking if a comma is trailing. This fixes parsing of tsconfig.json files with patterns like: "moduleResolution": "node16", // comment } 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Handle EADDRINUSE errors by automatically retrying with a different random port, preventing flaky CI failures when tests run in parallel. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
test/runtime/typescript/test/channels/request_reply/http_client/test-utils.ts
Show resolved
Hide resolved
When runWithServer retried on EADDRINUSE, the test callback still used the original port from closure. Updated testFn signature to receive the actual port and modified all HTTP client test files to use it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
...runtime/typescript/test/channels/request_reply/http_client/oauth2_client_credentials.spec.ts
Outdated
Show resolved
Hide resolved
Tests that don't use runWithServer should reference the locally defined `port` variable, not `actualPort` which is only available inside runWithServer callbacks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #336
See implementation details in
.claude/thoughts/issue-336-add-automatic-project-setup-de-2026-03-09/plan.mdTest Plan
npm run prepare:prpasses🤖 Generated with Claude Code
Note
Medium Risk
Changes default configuration behavior for TypeScript generation by auto-setting
importExtension, which could affect import paths for projects that previously relied on implicit defaults. The new JSONC parsing and filesystem-based detection logic adds surface area for edge-case mis-detections, though it is covered by targeted tests.Overview
Adds automatic
importExtensiondetection duringrealizeGeneratorContextwhen the option is omitted, inferringnone/.ts/.jsfrom bundler config files/dependencies andtsconfig.json(moduleResolution+allowImportingTsExtensions) and logging the chosen value.Introduces
src/codegen/detection.ts(including a JSONC parser fortsconfig.json) plus unit-test fixtures/coverage for detection precedence and error cases, and updates HTTP client runtime test utilities to retry on port collisions (passing the actual bound port into tests). Documentation is updated to describe the new detection behavior and its limitations.Written by Cursor Bugbot for commit 7eece50. This will update automatically on new commits. Configure here.