Skip to content

feat(vscode): add rstack.rstackCli.packagePath setting - #104

Open
fi3ework wants to merge 5 commits into
mainfrom
feat-rstack-cli-package-path
Open

fi3ework wants to merge 5 commits into
mainfrom
feat-rstack-cli-package-path

Conversation

@fi3ework

Copy link
Copy Markdown
Member

Summary

A monorepo can install rstack in a subdirectory (e.g. infra/node_modules/rstack) while rstack.config.* sits at the workspace root. The node_modules walk-up from the folder root never sees that installation, so fmt, bridged lint and bridged test all reported rstack as not installed.

New resource-scoped setting rstack.rstackCli.packagePath: an rstack package directory or its package.json, relative to the workspace folder (${workspaceFolder} supported). It sits in its own group because rstack-cli is one of the parallel tools, beside rstack.rslint.* and rstack.rstest.*.

 resolve rstack (fmt server · bridged lint · bridged test)
-  walk up node_modules from the folder / config dir
+  packagePath set → that package (realpath), else the walk-up as before
+  packagePath does not resolve / is not "rstack" → setting error (crashed), never "not installed"
 spawn a process that loads rstack.config.*
+  packagePath set → NODE_OPTIONS += --import <dist/rstack-resolve-hook.mjs>

Why the hook. Resolving the package only fixes which rs.js the editor starts. The root config's own import { define } from 'rstack' still resolves from the config file and fails the same way: in a terminal it only works through the package manager's .bin shim. The hook (module.registerHooks) resolves rstack and rstack/* as if from inside the configured package, through its own exports. It does not reproduce shim behavior (NODE_PATH) or name files inside rstack, so it works the same for pnpm, npm and Yarn node-modules layouts. It is appended to any existing NODE_OPTIONS and injected only while the setting is set.

Known limit. A config that Node cannot load natively (non-erasable TS syntax such as enum, or extensionless relative imports) falls back to load-config's jiti path, which uses require.resolve. Before Node 24.15, registerHooks does not see require.resolve, so on Node 22 such configs still fail. Configs written like the create-rstack templates load natively and work on every supported Node. The README states the limit.

Measured on Node 22.23.3 / 24.22.0 / 26.11.1, with pnpm, npm and Yarn node-modules layouts, and rs fmt / rs lint / rs test each:

Node plain config config needing the jiti fallback
22.x (latest 22.23.3) ✅ ❌
24.22.0 / 26.11.1 ✅ ✅

Related Links

Closes #103

Checklist

  • Tests updated (or not required). Unit tests for the resolver, the setting-error status and the NODE_OPTIONS composition; new E2E launch rstack-cli-package-path (in the vscode slice) runs fmt, lint and test against a fixture whose rstack lives only under infra/, from a copy outside the repo so no walk-up can find one.
  • Documentation updated (or not required). README settings table; AGENTS.md adaptation 2.

Let a workspace point at an rstack installation the node_modules walk-up
cannot see, e.g. a monorepo that installs its tooling under infra/ while
rstack.config.* sits at the root. One resource-scoped setting covers the
fmt server and the lint and test stacks bridged through rstack.config.*;
a path that does not resolve is reported as a setting error, not as a
missing install.

The root config's own `import 'rstack'` cannot see that installation
either, so while the setting is set every spawned process that loads
rstack.config.* preloads a small resolve hook (NODE_OPTIONS=--import)
that resolves `rstack` and `rstack/*` from inside the configured package
through Node's own resolver. Configs that need load-config's jiti
fallback still require Node >= 24.15, where module.registerHooks covers
require.resolve.

Closes #103
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T09:50:01.073711Z 7d97e99 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a5f48da1f6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/vscode/src/stacks/test/master.ts Outdated
Deliver the resolve hook as an explicit --import node arg, with the
rstack package.json path in the hook URL's query, instead of
NODE_OPTIONS plus an env var. The arg reaches exactly the spawned
process and also fits Rstest's Run in Terminal command line, which
previously ran without the hook.
The rstack package resolution now records whether the setting chose it and
carries the parsed package.json, so the hook gate no longer re-reads the
setting and no consumer reads the same package.json twice. Fold the hook
helper into rstackPackage.ts, share one path-setting reader with
rstack.nodeExecutable, and pass the not-installed hint from the rstack
callers instead of special-casing the package name.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 83c056e878

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/vscode/src/stacks/test/master.ts
Drop the abstractions the setting did not need: the source union, the
carried package.json, the options object, the one-line setting reader
module, the hint parameter and the split hook helper. Each stack now
derives "chosen by the setting" from its own single read of it. Remove
the unit test that only restated the hook URL composition.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b5efbe9856

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/vscode/src/stacks/test/bridge.ts
…lves

A missing rstack.rstackCli.packagePath latched a crash under the bridge's
config directory, and the successful resolution only retired the
not-installed and mismatch latches, so Rstest stayed crashed after the
path appeared (e.g. after an install) until a restart.

This branch has not been deployed

No deployments
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.

[Feature]: Support a custom Rstack installation path for formatting

1 participant