Repository navigation
fix(cli): template reads ~/ as the home folder, never a folder named ~ - #12706
josephfarina wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec 914aec9 |
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Approval waits on an engineering owner deciding how the CLI reads a destination that starts with ~, and one change is needed in the meantime.
Owner decision. No current rule in architecture:cli-surface says that a leading ~ in astryx template <path> or --cdn <path> names the home folder, or that the change ships as a patch [fix]; INV10a covers refusing a write outside the project, but main writes these paths inside it (./~/…), and INV10a classifies refusing or moving such inputs like any other change. An engineering owner, the author included, settles it by adding the rule (for template only or CLI-wide, with its release tier) to architecture:cli-surface in this pull request and commenting /approve-spec <full head SHA> on that head. The /approve-spec already on this head approves no record, because the pull request changes none.
Blocking
homeRelativePath(packages/cli/foundation/fs/path-safety.mjs:193) repeats the~branch ofabsoluteFolderinpackages/cli/foundation/agent-docs/skill-places.mjs:116-119, so makeabsoluteFolderreturnhomeRelativePath(value, home) ?? path.resolve(cwd, value)and keep one copy fortemplateandinit --to.
Also worth fixing
- The
astryx template --helptext for<path>and--cdn(packages/cli/clients/cli/commands/template.doc.mjs:40,:82-88) does not mention~/, which only the API doc now explains. ~\is read as the home folder on Linux and macOS too, where no shell does that and\is a filename character.
Claims and files checked
Review mode: full; reason: no-earlier-review
Description claims:
- On
main, a~/…destination passed without a shell is written into a folder named~in the project: verified; the new tests fail onmainwith output under~/project/src/pages. template --cdn ~/page.htmldid the same: verified;cdn.test.mjs:104-110fails onmain.- The old check read
~/…as a relative path: verified;main'scopy.mjspassed the text straight toassertWithin. ~and~/now name the home folder, as a shell reads them: verified (path-safety.mjs:193-199);~\is also read as home on every platform.- The expanded path follows the absolute-path rules (written inside the project, a scratch copy in the temp folder, else refused with the commands that work): verified (
copy.mjs:97-124,template.path-safety.test.mjs:91-136); an inside-project~/path is not reported asgivenPath(copy.mjs:197). - Messages quote the path as given: verified (
copy.mjs:103,:112,cdn.mjs:85). - INV10 confines template writes to the project or a scratch copy in the temp folder (DEC-15): verified against the record.
- INV10a makes this a compatible fix: false;
mainwrites these paths inside the project, and INV10a classifies refusing or moving such inputs like any other change. - The template command's doc names the absolute-path rules: verified (
clients/cli/commands/template.doc.mjs:40); it does not mention~/. - No other path changes meaning (
./~/x,~other/x,a~/x): verified (path-safety.test.mjs:113-123);~\xchanges on Linux and macOS. - The JSON shape is unchanged: verified; receipt and error fields are the same.
- The new tests fail on
main: verified; the three behavior tests fail onmain, and the two helper tests fail because the helper is missing there. - After the change the call is refused with suggestions and writes nothing, and a
~/path inside the project is written there: verified; the new tests pass. - Relative, absolute, temp-folder and
..paths behave as before: verified; the existing suites pass and CItest-nodepassed. - One defect is restored: not established;
main's behavior met INV10 and its help text, so this is a new reading that waits on the owner rule. - No new public API: verified; no export, command or option changes.
- Testing (Vitest, typecheck, Prettier, changeset and CLI structure checks): verified; CI and the changeset, CLI structure and Prettier checks pass.
Changeset claims:
template <name> ~/<path>reads~/as the home folder: verified (copy.mjs:70-71).- No
~folder is made; a home path outside the project is refused with the commands that work, and one inside it is written there: verified (template.path-safety.test.mjs:91-136). template --cdnreads it the same way: verified (cdn.mjs:70,cdn.test.mjs:104-110).- Patch
[fix]: not established; it waits on the owner rule, and no migration (./~/…) is given.
Files:
.changeset/template-home-path.md: release tier waits on the owner rule; no migration line.packages/cli/api/template/cdn/cdn.mjs: clear.packages/cli/api/template/cdn/cdn.test.mjs: clear; two existing assertions are only reflowed.packages/cli/api/template/copy/copy.mjs:givenPathis not reported for a~/path inside the project (non-blocking).packages/cli/api/template/template.doc.mjs: clear; the command help lacks the matching sentence.packages/cli/clients/cli/commands/template.path-safety.test.mjs: clear.packages/cli/foundation/fs/path-safety.mjs: duplicatesskill-places.mjs:116-119(blocking);~\on Linux and macOS (non-blocking).packages/cli/foundation/fs/path-safety.test.mjs: clear.
|
Owner decision (engineering owner, covering this pull request): for |
|
/approve-spec 63cfdfa |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, and the required checks must pass before merge.
The home-folder reading of a leading ~ for astryx template <path> and --cdn is now recorded in architecture:cli-surface INV10 and approved by an engineering owner at this head, and init --to reads ~ through the same helper, so nothing blocks.
Worth a follow-up, not blocking:
- The
<path>and--cdnhelp and thetargetPathAPI doc say only "a path that starts with~/", while INV10 and the helper also read a bare~and a leading~\; on Linux and macOS~\notes/page.tsxis now refused without the help saying why. - A
~/path that lands inside the project does not reportgivenPath(packages/cli/api/template/copy/copy.mjs:197), so the CLI's "written as its relative path" line shows for an absolute path but not for the same place written with~/. - No test covers a
~\…destination or a~/…destination in the temp folder.
Claims and files checked
Review mode: full; reason: spec-record
Description claims:
- Without a shell,
template <name> ~/…wrote into a folder named~in the project, and--cdn ~/…did the same: verified; the new tests fail on the base code, and a probe there writes./~/…. - The old check read
~/…as a relative path: verified; the base copy passed the text straight to the project guard. ~and~/(and~\, on every platform) now name the home folder throughhomeRelativePath: verified (path-safety.mjs:193-199).- The expanded path follows the absolute-path rules: written inside the project, a scratch copy in the temp folder, else refused with
ERR_PATH_TRAVERSALand the commands that work: verified (copy.mjs:97-124,template.path-safety.test.mjs:91-136, probe). - Messages still quote the path as given: verified (
copy.mjs:103,:112;cdn.mjs:85). - The INV10 sentence (template only,
~,~/or~\, then absolute-path rules, no~folder, a compatible[fix]) is in the record: verified (cli-surface.md:328-332), approved by an engineering owner at this head. init --toalready read~this way and both now share one helper: verified (skill-places.mjs:116-118,skill-places.test.mjs).- A folder really named
~stays reachable as./~/<path>, and the changeset says so: verified (probe; changeset line 5). - The listed files make the smallest restoration (helper; copy and CDN check the expanded path; API doc and command help sentence;
init --toon the helper): verified, file by file. - No other path changes meaning (
./~/x,~other/x,a~/x): verified (path-safety.test.mjs:113-124, probe). - The JSON shape is unchanged: verified; the same receipt and error fields.
- Before the change the call wrote under
./~/…, and the three new tests fail on the base: verified with the equivalentblanktests; the two helper tests also fail there. - After the change the call is refused with the message and suggestions and writes nothing, and a
~/path inside the project is written there: verified; the new tests pass. - Relative, absolute, temp-folder and
..paths behave as before: verified; the existing suites pass, apart from one sandbox-only temp-folder case that fails the same way on the base. - One defect restored, no hidden public API or default, no internal context: verified; INV10 classifies it as a
[fix], the API delta is empty, and the text is clean. - Writing rubric: the INV10 sentence states what the CLI does and adds no status: verified.
- Testing (Vitest, typecheck, Prettier, changeset and CLI structure checks): verified; tests pass, the CLI typecheck shows no error in a changed file, the changeset and CLI structure checks pass, and the changed lines are formatted (
skill-places.mjskeeps six older unformatted spots that the base has too).
Changeset claims:
template <name> ~/<path>reads~/as the home folder: verified (copy.mjs:70-71).- No
~folder is made; a home path outside the project is refused with the commands that work, and one inside is written there: verified (template.path-safety.test.mjs:91-136). template --cdnreads it the same way: verified (cdn.mjs:70,cdn.test.mjs:104-110)../~/<path>reaches a real~folder: verified (probe).- Patch
[fix]: verified against INV10's new sentence.
Files:
.changeset/template-home-path.md: clear.docs/architecture/cli-surface.md: clear; owner-approved INV10 sentence, no approval line changed.packages/cli/api/template/cdn/cdn.mjs: clear.packages/cli/api/template/cdn/cdn.test.mjs: clear; two existing assertions only reflowed.packages/cli/api/template/copy/copy.mjs:givenPathnot reported for a~/path inside the project (non-blocking).packages/cli/api/template/template.doc.mjs: names only~/(non-blocking).packages/cli/clients/cli/commands/template.doc.mjs: names only~/(non-blocking).packages/cli/clients/cli/commands/template.path-safety.test.mjs: clear.packages/cli/foundation/agent-docs/skill-places.mjs: clear; reads~through the shared helper.packages/cli/foundation/fs/path-safety.mjs: clear.packages/cli/foundation/fs/path-safety.test.mjs: clear; no~\case (non-blocking).
| required: false, | ||
| description: | ||
| 'Where to scaffold the template, inside the project root: a relative path, or an absolute path inside the project, which is written as its relative path. An absolute path in the system temp folder (such as /tmp/dashboard) takes a scratch copy, outside the project. Any other path outside the project is refused. A path that ends in .tsx, .ts, .jsx, .js, .mjs, .cjs, .css, .scss, .json, .md or .html is the file to write; ' + | ||
| 'Where to scaffold the template, inside the project root: a relative path, or an absolute path inside the project, which is written as its relative path. An absolute path in the system temp folder (such as /tmp/dashboard) takes a scratch copy, outside the project. Any other path outside the project is refused. A path that starts with ~/ names the home folder, as a shell reads it, and follows the same rules. A path that ends in .tsx, .ts, .jsx, .js, .mjs, .cjs, .css, .scss, .json, .md or .html is the file to write; ' + |
There was a problem hiding this comment.
INV10 and homeRelativePath also read a bare ~ and a leading ~\ as the home folder, on every platform, but this help (and --cdn at line 87, and the targetPath API doc) names only ~/. On Linux or macOS ~\notes/page.tsx used to make a folder in the project and is now refused. Consider "A path that is ~, or starts with ~/ or ~\, names the home folder" (non-blocking).
…emplate rule; ~/ in the command help [skip ci]
63cfdfa to
bd60bb4
Compare
|
/approve-spec bd60bb4 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head, because its commit message carries [skip ci], so the required checks run only after a new push without it and must pass before merge.
The home-folder reading of a leading ~ for astryx template <path> and --cdn is recorded in architecture:cli-surface INV10 and approved by an engineering owner at this head, and init --to reads ~ through the same helper, so nothing blocks.
Worth a follow-up, not blocking:
- The
<path>and--cdnhelp and thetargetPathAPI doc say only "a path that starts with~/", while INV10 and the helper also read a bare~and a leading~\; on Linux and macOS~\notes/page.tsxis now refused without the help saying why. - A
~/path that lands inside the project does not reportgivenPath(packages/cli/api/template/copy/copy.mjs:197), while an absolute path to the same place does. - No test covers a bare
~, a~\…destination or a~/…destination in the temp folder.
Claims and files checked
Review mode: full; reason: rebase
Description claims:
- Without a shell,
template <name> ~/…wrote into a folder named~in the project, and--cdn ~/…did the same: verified; the new tests fail on the base code, and running the base code writes./~/…. - The old check read
~/…as a relative path: verified; the base copy passed the text straight to the project guard. ~and~/now name the home folder throughhomeRelativePath: verified (folder-scope.mjs:44-50).- The expanded path follows the absolute-path rules: written inside the project, a scratch copy only in the temp folder, else refused with
ERR_PATH_TRAVERSALand the commands that work: verified (copy.mjs:97-124,template.path-safety.test.mjs:91-136, and a run with the temp folder inside the home folder). - Messages still quote the path as given: verified for the outside-project and temp-folder messages (
copy.mjs:103,:112;cdn.mjs:85); the link refusal keeps quoting the resolved file, as it did before. - The INV10 sentence (template and
--cdnonly;~,~/or~\; then the absolute-path rules; no~folder; a compatible[fix]) is in the record: verified (cli-surface.md:328-332), approved by an engineering owner at this head. init --toalready read~this way, and both now share one helper infolder-scope.mjs: verified (folder-scope.mjs:60-62).- A folder really named
~stays reachable as./~/<path>, and the changeset says so: verified (a run, and the changeset). - The helper stays a leaf with no CLI imports, and
path-safety.mjsre-exports it for the template commands: verified (folder-scope.mjs:16-17,path-safety.mjs:20). - The copy and CDN writers check the expanded path and quote the given one; the API doc and command help gain one sentence on
~/: verified. ~\is read as the home folder on every platform, asinit --toalready read it: verified.- No other path changes meaning (
./~/x,~other/x,a~/x): verified (path-safety.test.mjs:113-124, and a run). - The JSON shape is unchanged: verified; the same receipt and error fields.
- Before the change the call wrote under
./~/…, and the new tests fail on main: verified with the equivalentblanktemplate; all five new tests fail on the base code. - After the change the call is refused and writes nothing, and a
~/path inside the project is written there: verified; the new tests pass. - Relative, absolute, temp-folder and
..paths behave as before, and the existing tests pass: verified; the existing suites give the same results on the base and the head. - One defect restored, no hidden public API or default, no internal context: verified; INV10 classifies it as a
[fix]and no public export changes. - Writing rubric: the INV10 sentence states what the CLI does and adds no status: verified.
- Testing (Vitest, typecheck, Prettier, changeset and CLI structure checks): verified; the typecheck shows only two errors the base has too, and the changed lines are formatted (one untouched line in
folder-scope.mjsfails Prettier on the base too).
Changeset claims:
template <name> ~/<path>reads~/as the home folder: verified (copy.mjs:70-71).- No
~folder is made; a home path outside the project is refused with the commands that work, and one inside is written there: verified (template.path-safety.test.mjs:91-136). template --cdnreads it the same way: verified (cdn.mjs:70,cdn.test.mjs:104-110)../~/<path>reaches a real~folder: verified (a run).- Patch
[fix]: verified against INV10's new sentence.
Files:
.changeset/template-home-path.md: clear.docs/architecture/cli-surface.md: clear; owner-approved INV10 sentence, no approval line changed.packages/cli/api/template/cdn/cdn.mjs: clear.packages/cli/api/template/cdn/cdn.test.mjs: clear; two existing assertions only reflowed.packages/cli/api/template/copy/copy.mjs:givenPathnot reported for a~/path inside the project (non-blocking).packages/cli/api/template/template.doc.mjs: names only~/(non-blocking).packages/cli/clients/cli/commands/template.doc.mjs: names only~/(non-blocking).packages/cli/clients/cli/commands/template.path-safety.test.mjs: clear.packages/cli/foundation/agent-docs/folder-scope.mjs: clear;absoluteFolderreads~through the shared helper.packages/cli/foundation/fs/path-safety.mjs: clear.packages/cli/foundation/fs/path-safety.test.mjs: clear; no~\case (non-blocking).
- #12895 experimental theme: a saved --only on a part styled on its own opens Author: @josephfarina - #12706 fix(cli): template reads ~/ as the home folder, never a folder named ~ Author: @josephfarina - #12750 feat(cli): experimental icon names each match's meaning import Author: @josephfarina - #12307 fix(core): keep anchored layers on screen when their trigger runs past the viewport Author: @josephfarina
|
Landed in #12940. |
User impact
astryx template <name> <path>is often called by tools that pass arguments without a shell. A destination written~/scratch/page.tsxthen reaches the CLI as text, and the copy wrote it into a new folder literally named~inside the project: a stray folder the app now builds, typechecks and lints, and not the place the caller named.template --cdn ~/page.htmldid the same.Problem and solution fit
~/…as a relative path, so it resolves inside the current folder.~and~/…now name the home folder, as a shell reads them (homeRelativePath). The destination then follows the rules an absolute path already follows: inside the project it is written there; anywhere else it is refused withERR_PATH_TRAVERSALand the commands that work. (A~/path takes a scratch copy only where its absolute form would: a path in the system temp folder.) Messages still quote the path as given.Expected behavior and authority
Record change, in
architecture:cli-surfaceINV10, after the scratch-copy sentence (DEC-15): forastryx template <name> <path>and--cdn <path>, a destination that is~, or starts with~/or~\, names the home folder, as a shell reads it, and then follows the rules of an absolute path; a destination written that way never makes a folder named~in the project; reading it so is a compatible[fix]. The rule is fortemplateonly.init --toalready reads~this way, and both now share one helper (foundation/agent-docs/folder-scope.mjs).A folder that is really named
~in the project is still reachable: write it as./~/<path>. The changeset says so.Smallest restoration
foundation/agent-docs/folder-scope.mjs:homeRelativePath(value, home), which only reads~and~/(or~\), next to the folder ruleinit --toalready applies there (absoluteFoldernow calls it). It stays a leaf with no CLI imports, soastryx --versionloads no new module;foundation/fs/path-safety.mjsre-exports it for the template commands.api/template/copy/copy.mjsandapi/template/cdn/cdn.mjs: check the expanded path, quote the given one.api/template/template.doc.mjsand the command help (clients/cli/commands/template.doc.mjs,<path>and--cdn): one sentence on~/.~\is read as the home folder on every platform, asinit --toalready reads it.No other path changes meaning (
./~/x,~other/xanda~/xstay as they were). The JSON shape is unchanged.Evidence
template kanban-board --type page '~/wb-scratch/kanban.tsx'wrote./~/wb-scratch/kanban.tsxin the project. The three new tests fail on main.~/path that resolves inside the project is written at its place there...escapes behave as before (existing path-safety, template and cdn tests pass unchanged).Scope
Components: CLI template destination
Writing rubric results
Testing
CI=1 pnpm vitest run --project node packages/cli/api/template packages/cli/clients/cli/commands/template* packages/cli/foundation/fs packages/cli/clients/cli/lib/cli-error.test.mjs packages/cli/test/golden-reads.test.mjs packages/cli/test/docs-graph.test.mjspnpm check:changesets,pnpm check:cli-structure