Skip to content

Fix project context resolution for file-based commands#3174

Draft
techmannih wants to merge 2 commits into
tscircuit:mainfrom
techmannih:fix/file-based-project-context
Draft

Fix project context resolution for file-based commands#3174
techmannih wants to merge 2 commits into
tscircuit:mainfrom
techmannih:fix/file-based-project-context

Conversation

@techmannih
Copy link
Copy Markdown
Member

@techmannih techmannih commented Jun 3, 2026

Why

File-based commands were resolving runtime project context from process.cwd() instead of the target file path.

That meant tsci export and tsci simulate analog could load the wrong tscircuit.config.* and resolve the wrong user-land dependencies when they were run from outside the target project directory.

Before

  • export loaded runtime config from the shell working directory
  • simulate analog loaded runtime config from the shell working directory
  • shared user-land module resolution also depended on the shell working directory
  • the same file could produce different results depending on where the command was launched from

After

  • file-based commands derive project context from the target file path
  • the CLI finds the nearest tscircuit.config.ts, tscircuit.config.js, or tscircuit.config.json starting from the target file directory
  • user-land module resolution now follows the target project context instead of the shell working directory
  • export and simulate analog now behave consistently when invoked with absolute or nested file paths from outside the target project directory

What Changed

  • added nearest-config lookup in the project config loader
  • updated export to resolve runtime config from the target file path
  • updated simulate analog to use the same project resolution behavior
  • updated shared user-land module resolution to resolve from the target project directory
  • added @tscircuit/ti-parts-engine to package.json
  • updated bun.lock for the new dependency
  • added a regression test covering file-based export from outside the target project

Validation

  • bun test tests/cli/runtime-project-config-command-flows.test.ts
  • bun test tests/lib/project-config.test.ts
  • bun test tests/cli/export/export-circuit-json.test.ts tests/cli/export/export-kicad-library.test.ts tests/cli/simulate/simulate.test.ts

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