Skip to content

[Repo Assist] improve: extract resolveWorkspacePath utility; fix relative standard paths#139

Draft
github-actions[bot] wants to merge 1 commit intomasterfrom
repo-assist/improve-resolve-workspace-path-2026-04-09-003c4949c0fff40d
Draft

[Repo Assist] improve: extract resolveWorkspacePath utility; fix relative standard paths#139
github-actions[bot] wants to merge 1 commit intomasterfrom
repo-assist/improve-resolve-workspace-path-2026-04-09-003c4949c0fff40d

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 9, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Extracts a new resolveWorkspacePath() utility in lib/utils.js and uses it to resolve the phpcbf.standard setting, fixing the case where relative paths (e.g. ./ruleset.xml) were silently passed through to phpcbf unchanged.

Closes #38 (partially — ./ruleset.xml in phpcbf.standard now resolves to an absolute path against the workspace root).

Root Cause

loadSettings() already handled \$\{workspaceFolder} / \$\{workspaceRoot} substitution for the standard setting, but it did not resolve relative paths like ./ruleset.xml or vendor/standard/ruleset.xml. These were passed directly to phpcbf, which then failed because phpcbf receives a temp-file path as the document and has no notion of the VS Code workspace root.

Changes

File Change
lib/utils.js Add resolveWorkspacePath(inputPath, rootPath) — handles ~ expansion, \$\{workspaceFolder}/\$\{workspaceRoot} substitution, and relative-path resolution
extension.js Replace inline variable substitution in loadSettings() with a call to resolveWorkspacePath()
test/unit.test.js Add 10 unit tests for resolveWorkspacePath (17 total; all pass)

resolveWorkspacePath behaviour

Input rootPath Output
./ruleset.xml /workspace /workspace/ruleset.xml
vendor/bin/standard /workspace /workspace/vendor/bin/standard
\$\{workspaceFolder}/phpcs.xml /workspace /workspace/phpcs.xml
\$\{workspaceRoot}/phpcs.xml /workspace /workspace/phpcs.xml
~/.phpcs.xml any (homedir)/.phpcs.xml
/absolute/path.xml any /absolute/path.xml (unchanged)
./relative.xml null ./relative.xml (unchanged, no root)

Trade-offs

  • Relative-to-workspace semantics — relative paths are resolved against the workspace root folder for the document being formatted, consistent with how executablePath is handled and with user expectation.
  • No breaking change — absolute paths and already-substituted paths pass through unchanged.
  • The utility is reusable; future callers (e.g. executablePath, custom standards from a config file) can use the same function.

Test Status

node --test test/unit.test.js

▶ findFiles (7 tests) ✔
▶ resolveWorkspacePath (10 tests) ✔

tests 17 | pass 17 | fail 0

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

…paths

- Add resolveWorkspacePath() to lib/utils.js that handles ~ expansion,
  ${workspaceFolder}/${workspaceRoot} substitution, and relative path
  resolution against the workspace root.
- Refactor loadSettings() to use resolveWorkspacePath() for the standard
  setting, fixing #38 (relative paths like ./ruleset.xml in phpcbf.standard
  were silently passed through instead of being resolved).
- Add 10 unit tests for resolveWorkspacePath (17 total, all pass).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

phpcbf.standard doesn't allow relative paths or ${workspaceFolder}

0 participants