Repository navigation
feat(cli): template's outside-the-project refusal names the command that writes the path from its own folder - #12710
josephfarina wants to merge 3 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec 5d76d28 |
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Changes requested: one fix is needed before this can be approved.
- In a project that installs its own CLI, the new suggestion keeps that project's invocation after the change of folder (
cd <folder> && npx astryx template blank ./dash.tsx, orpnpm exec astryx …), which does not resolve from that folder, sonpxfetches the unrelatedastryxpackage andpnpm execfails; pick the invocation for the folder aftercd(formatCliCommand(command, folder), which gives the pinned@astryxdesign/cli@<version>runner there, as global mode FR5 requires) and add a test where the project's own CLI answers.
Otherwise the change holds up: the suggested arguments write the named path from that folder, the disk-root case adds nothing, and JSON keeps the bare form. The three new tests fail on the base and pass on the head.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim, the refusal adds a command that writes the named path from its nearest existing folder: verified for package-runner runs (copy.mjs:119-129, the nearest-folder test); false when the project's own CLI answers (cli-error.mjs:347).
- Claim, no such suggestion when only the disk's root exists: verified (copy.mjs:251, the disk-root test).
- Claim, printed output puts the CLI invocation after the change of folder in the POSIX and PowerShell forms, and JSON stays bare: verified (cli-error test, JSON output), with the folder caveat above.
- Claim, the confinement rule and the JSON shape are unchanged apart from one more name and reason entry: verified.
- Claim, the three new tests fail on main: verified (3 failed on the base with the head's tests).
- Claim, every other template and cli-error test passes unchanged: verified (the stated test scope: 814 passed, 7 skipped).
- Claim, the changeset check passes: verified; typecheck and the pre-review checklist were not rerun.
- Claim, a no-context agent test moved from 5 of 5 redirects to 5 of 5 copies: not verified (no transcripts).
- Changeset, the refusal names the command that writes that same path, as a patch fix: the patch classification is verified; the claim is false when the project's own CLI answers, until the fix above.
- File .changeset/template-refusal-cd-hint.md: covered by the finding.
- File packages/cli/api/template/copy/copy.mjs: clear.
- File packages/cli/clients/cli/lib/cli-error.mjs: the finding.
- File packages/cli/clients/cli/commands/template.path-safety.test.mjs: clear; it has no run where the project's own CLI answers.
- File packages/cli/clients/cli/lib/cli-error.test.mjs: clear.
|
Owner decision (engineering owner, covering this pull request at its current head): |
|
/approve-spec 437744d |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet.
The earlier request is resolved: the run-from-its-folder line now uses the CLI invocation for the folder after cd, and .. paths get the same refusal and commands as absolute ones. Two small follow-ups, neither blocking:
- When a file sits where a folder of the destination should be (
/work/out/notes.txt/x.tsx), the suggestedcdcommand fails withEEXIST, so naming no command there, as for the disk's root, avoids a dead end. - Miss: the new command drops
--overwrite, so a caller who passed it for an existing file gets a second refusal; carrying the flag into that one line keeps their choice.
Claims and files checked
Review mode: full; reason: spec-record
- Changeset: a refused Core-template destination outside the project now comes with a command that writes it from its nearest existing folder, using that folder's CLI invocation: verified (path-safety tests; a run where the project's own CLI answers), except when a file sits on the path (first note).
- Changeset: a
..path now gets the same commands as an absolute path: verified (..test; the base prints only the traversal message). - Changeset: a
..path into the temp folder is not a scratch copy, and the refusal names its absolute path, which takes one: verified (run with scratch copies on; the PR's test skips where the temp folder holds the home folder). - Changeset: a
[feat]patch: verified (changeset check). - Description: only a path that leaves the project without a link gets this refusal: verified (
copy.mjs:101-102; the link tests pass unchanged). - Description: the line is only for a Core template no integration replaces, also when asked for by package: verified (two integration tests).
- Description: a folder given with a trailing separator is named by its file: verified (test).
- Description: no line when only the disk's root exists: verified (test).
- Description: text output uses the invocation for the folder after
cd, and JSON stays bare: verified (folder test; project-CLI run prints the pinned runner). - Description: the folder parse round-trips every printed form, PowerShell's doubled quotes included: verified (round-trip test).
- Description: the record adds one decision beside DEC-15 and DEC-17; the confinement rule and the JSON shape are unchanged: verified (record diff; suggestions stay name and reason).
- Description: the folder walk lives in the subject's adapter: verified (CLI structure check).
- Description: every new test fails on main except the three no-line guards: verified (8 fail on the base, the 3 guards pass; the temp-folder case was run separately).
- Description: running the named command writes the named file: verified (test).
- Description: a copy made from outside the project follows that folder's icon set: verified by reading (
template.mjs:286-289); not tested. - Description: the no-context agent test moved 5 of 5 runs from redirects to copies: not verified (no transcripts).
- Description: every other template and cli-error test passes: verified (the stated scope: 821 passed, 8 skipped).
- Description: no new typecheck errors: verified for the CLI's strict typecheck (the same two unbuilt-theme errors on base and head); the pre-review checklist was not rerun.
- Description: the changeset check passes: verified.
- File
.changeset/template-refusal-cd-hint.md: clear. - File
docs/architecture/cli-surface.md: clear. - File
packages/cli/api/template/_adapter.mjs: first note. - File
packages/cli/api/template/copy/copy.mjs: second note. - File
packages/cli/api/template/template.mjs: clear. - File
packages/cli/api/template/template-integration.test.mjs: clear. - File
packages/cli/clients/cli/commands/template.path-safety.test.mjs: clear. - File
packages/cli/clients/cli/lib/cli-error.folder.test.mjs: clear. - File
packages/cli/clients/cli/lib/cli-error.mjs: clear; the earlier invocation finding is fixed. - File
packages/cli/clients/cli/lib/cli-error.test.mjs: clear. - File
packages/cli/foundation/env/package-manager.mjs: clear. - File
packages/cli/foundation/env/package-manager.test.mjs: clear.
| */ | ||
| export function nearestFolder(dir) { | ||
| let at = dir; | ||
| while (!isFolder(at) && path.dirname(at) !== at) at = path.dirname(at); |
There was a problem hiding this comment.
Non-blocking: this walk steps past an entry that exists but is not a folder. For /work/out/notes.txt/x.tsx with notes.txt a file, the refusal suggests cd /work/out && astryx template blank ./notes.txt/x.tsx, which then fails with ERR_WRITE_FAILED (EEXIST). Stopping at the first existing entry and naming no command when it is not a folder (as for the disk's root) avoids that dead end.
…at writes the path from its own folder
… folder's CLI invocation; record DEC-20 [skip ci]
437744d to
a01d6fd
Compare
|
/approve-spec 5fb29ad |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, because its commits carry [skip ci], and the merge guard still requires the checks to pass.
When astryx template <name> <path> refuses a destination outside the project for a Core template, the refusal now also names the command that writes that destination from its nearest existing folder, printed with that folder's CLI invocation and keeping --overwrite. architecture:cli-surface DEC-20 is approved at this head, and the earlier --overwrite note is fixed.
- Non-blocking: when a file stands on the path (
out/notes.txt/x.tsxwithnotes.txta file),nearestFolderinpackages/cli/api/template/_adapter.mjs(lines 253-257) walks past it, and the suggested command then fails withEEXIST; naming no command when the nearest existing entry is not a folder avoids that dead end.
Claims and files checked
Review mode: full; reason: rebase
Claims (description):
- On the base, an absolute path outside the project got the in-project and print commands and a
..path got only the traversal message: verified (basecopy.mjs,path-safety.mjs:108). - Any path that leaves the project without a link gets the same refusal plus the run-from-its-folder command: verified (
copy.mjs:107-108,:162-169, tests). - The command is named only for a Core template no integration replaces: verified (
copy.mjs:132-135,template.mjs:322-324, two integration tests). - A
..path into the temp folder names its absolute path, which takes a scratch copy: verified (copy.mjs:123-126,:154-161, test run with scratch copies on). - Running the named command from its folder writes the named file: verified (path-safety test runs the same write from that folder).
- A folder given with a trailing separator is named by the file the copy writes: verified (test).
- No command is added when only the disk's root exists: verified (
copy.mjs:288-293, test). - The printed line takes the CLI invocation for the folder after the change of folder, and JSON stays bare: verified (
cli-error.mjs:337-344,:121-129, three tests). - DEC-20 is added beside the other template decisions, INV10 and the JSON shape are unchanged: verified (
cli-surface.md:1288-1309, additions only). - The changeset is a
[feat]patch: verified (check:changesets passes). - The folder parser reads back every form the folder command prints, POSIX and PowerShell with each doubled quote: verified (
package-manager.mjs:786-805, round-trip test). - With
--overwriteand an existing file, the line keeps--overwriteand replaces the file; the in-project place never gets it: verified (copy.mjs:139-141,:151, test). - A copy made from outside the project follows that folder's icon set: verified (
template.mjs:296). - Every new test fails on the base except the three no-line guards: verified (10 fail, 3 pass with the base sources).
- The no-context agent test (5 of 5 runs per arm): not verified, no transcripts in the pull request.
- Every other template and cli-error test passes unchanged: verified (862 passed, none failed).
- Typecheck adds no errors, and pre-review finds nothing: verified (two typecheck errors, both in unchanged template pages whose theme package is unbuilt here; pre-review 0 findings).
Claims (changeset):
- The refusal names the command that writes the same destination from its nearest existing folder, with that folder's invocation: verified (as above).
- With
--overwrite, that command and the scratch-copy command keep it, and the in-project place never does: verified (copy.mjs:151,:157,:165). - A
..path now gets the same commands as an absolute one: verified (test). - A
..path into the temp folder is still not a scratch copy and is pointed at its absolute path: verified (test).
Files:
.changeset/template-refusal-cd-hint.md: cleardocs/architecture/cli-surface.md: clear (DEC-20 approved at this head)packages/cli/api/template/_adapter.mjs: non-blocking note (file on the path)packages/cli/api/template/copy/copy.mjs: clearpackages/cli/api/template/template.mjs: clearpackages/cli/api/template/template-integration.test.mjs: clearpackages/cli/clients/cli/commands/template.path-safety.test.mjs: clearpackages/cli/clients/cli/lib/cli-error.folder.test.mjs: clearpackages/cli/clients/cli/lib/cli-error.mjs: clearpackages/cli/clients/cli/lib/cli-error.test.mjs: clearpackages/cli/foundation/env/package-manager.mjs: clearpackages/cli/foundation/env/package-manager.test.mjs: clear
- #12710 feat(cli): template's outside-the-project refusal names the command that writes the path from its own folder Author: @josephfarina - #13002 fix(cli): doctor outside a project names the issues of an integration installed for the computer Author: @josephfarina
|
Landed in #13045. |
User impact
astryx template <name> <path>refuses a path outside the project and outside the system temp folder. Agents that hit it usually wanted a copy at exactly that path, often in a folder of their own beside the project. For an absolute path the refusal named two commands, write inside the project or print the source, but not the command that writes the path they named; a path that left the project through..got the bare traversal message with no command at all. So they guessed: a shell redirect of the printed source, or a second refusal.Problem and solution fit
architecture:cli-surfaceINV10), and the refusal never said that the same path is fine when the command runs from a folder above it..., never through a link) gets the same refusal, which adds one suggestion: change to the nearest folder of the path that exists, then run the same template command with the path from there. It is named only for a Core template that no integration replaces, because outside the project the project's integrations do not load. A..path that lands in the system temp folder is not a scratch copy; its refusal names the absolute path, which takes one. That command is inside its current folder, so it writes the named path. The command names the file the copy writes, so a folder given with a trailing separator is named by itspage.tsx. No suggestion is added when only the disk's root exists. Printed, the CLI invocation is the one chosen for the folder the line moves into (spec:AST-081FR5) and comes after the change of folder (cd <folder> && npx @astryxdesign/cli@<version> template …); in JSON the entry stays bare, like the others.Expected behavior and authority
Record change:
architecture:cli-surfaceDEC-20, "A refused template path names the same write from its folder" (decided by the owner; it sits beside DEC-15 and DEC-17). INV10 is unchanged: the suggested write runs inside the folder it moves into. The JSON shape is unchanged: one more{name, reason}entry insuggestions. The changeset is[feat], a new suggested command (spec:AST-017FR7).Smallest restoration
api/template/copy/copy.mjs: the refusal covers..escapes and adds the suggestion, built with the existingcommandInFolderandquoteCommandArgument;api/template/template.mjstells it whether an integration replaces the template.api/template/_adapter.mjs:nearestFolder, the folder walk, kept in the subject's adapter (INV21).foundation/env/package-manager.mjs:splitCommandInFolder, which reads back the folder and command of a linecommandInFolderprints (POSIX and PowerShell forms, every quote character PowerShell doubles), next to it.clients/cli/lib/cli-error.mjs: such a suggestion gets the CLI invocation for its folder on the command after the change of folder.docs/architecture/cli-surface.md: DEC-20.Evidence
..path. Every new test fails on main except the three no-line guards (disk root, integration template, replaced Core template), which pass on main because it never adds the line.cd <folder> && astryx template <name> ./<rest>. Running exactly that command writes the named file (tested). A trailing-separator folder is named by its file (tested). A path whose only existing folder is the disk root gets no such entry (tested). The printed line takes the invocation for the folder aftercd(tested), and the folder parse round-trips everycommandInFolderform (tested). A..path gets the same commands (tested); a..path into the temp folder names its absolute path, which then takes the scratch copy (tested). An integration template, and a Core template an integration replaces (also when asked for by package), get no such line (tested). With--overwriteand an existing file at the named path, the line keeps--overwriteand running it replaces the file, with no second refusal (tested); the place inside the project never gets--overwrite, since it is another file. Run from outside the project, the copy follows that folder's icon set, not the project's.Scope
Components: CLI template destination refusal
Writing rubric results
Testing
CI=1 pnpm vitest run --project node packages/cli/api/template packages/cli/clients/cli/commands/template* packages/cli/clients/cli/lib packages/cli/foundation/envpnpm check:changesets,pnpm review:pre(0 findings)