Repository navigation
feat(cli): host entry for a tool that carries the CLI - #7420
Conversation
Define the in-process package-set seam, project authority, exact pin matching, caller working-directory behavior, and integration provenance for hosts that run Astryx without a project install.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression40 of 486 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 20 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
This PR needs a maintainer spec decision before it can be approved. The hosted package-set contract it implements (cli-surface INV30) is not on main yet, and as written its undocumented, process-wide host seam conflicts with current spec:AST-017 FR14 and FR18 and with cli-surface INV12 and INV14, so a maintainer needs to either land INV30 with matching amendments to those records or ask for a documented, invocation-scoped programmatic API instead. Whatever that decision, these changes are needed:
- Split the change, which is about 4,150 authored lines, so that the lockfile and range readers, the host
discoverhandler, and the runtime planner land separately. - Keep
findCoreDirunchanged when no package set is active, or move its new unbounded walk, package-name check, and Yarn PnP fallback into their own PR; as written, it breaks two existing tests inagent-docs.test.mjs. - Fix the
package-set.test.mjscase "names what each root carries…", which fails underpnpm vitestbecause its fixture has no lockfile and the install hint falls back to the runner. - Tag the changeset
[feat]instead of[fix](spec:AST-017FR7).
[Automated review]
| if (fs.existsSync(nodeModules)) { | ||
| return nodeModules; | ||
| } | ||
| for (;;) { |
There was a problem hiding this comment.
With no package set active, this now walks to the filesystem root (the base lookup stopped after five directories), skips a packages/core whose name is not @astryxdesign/core, and falls back to Yarn PnP at line 58. Ordinary runs change: a working directory seven levels below an installed Core now finds it, an unrelated packages/core is no longer returned, and two existing tests in foundation/agent-docs/agent-docs.test.mjs fail, because their Core fixtures have no name. Keep the base lookup when no set is active, or move this change into its own PR with updated fixtures and a disclosing changeset.
| "astryx: this project's Astryx package versions are unavailable:", | ||
| ' @acme/ui: project pinned 1.0.0 (package.json); available: 2.0.0 (set 1), 1.0.0 (set 2)', | ||
| ' @acme/extra: project pinned 1.0.0 (package.json); available: 1.0.0 (set 1), none (set 2)', | ||
| "Install the project's dependencies (npm install) to use its own versions.", |
There was a problem hiding this comment.
This fixture has no lockfile or packageManager, so installCommand falls back to npm_config_user_agent. Under pnpm (pnpm exec vitest run; CI runs pnpm vitest run --project node), the report says pnpm install and this assertion fails; under plain node it passes. Write a package-lock.json into the fixture, or assert only the pin lines.
| '@astryxdesign/cli': patch | ||
| --- | ||
|
|
||
| [fix] Let a host run the unchanged Astryx CLI from a compatible package set while the caller's project keeps authority over its installed versions, configuration, working directory, files, and integration provenance. The in-process seam adds no command, flag, environment variable, or package export. |
There was a problem hiding this comment.
spec:AST-017 FR7 tags compatible capabilities [feat]; [fix] is for corrections. If the Core-discovery change for runs without a host stays in this PR, the changeset should also say so.
| */ | ||
|
|
||
| /** @type {ActivePackageSet | null} */ | ||
| let active = null; |
There was a problem hiding this comment.
spec:AST-017 FR18 requires a programmatic control to be an explicit API input that does not depend on ambient mutable process state, so that concurrent calls can choose different values. This module-level set qualifies as that kind of state: it is activated for the rest of the process, swapped by withoutPackageSet, and paired with the process.chdir/process.argv changes in runHostedCli. Resolving that needs either a spec amendment or an invocation-scoped design, and the decision is with maintainers.
432ef4e to
6d4fc49
Compare
There was a problem hiding this comment.
This PR needs a maintainer spec decision before it can be approved. The hosting contract it implements (cli-surface INV30) is not on main, and as written the hosted runtime conflicts with current spec:AST-017 FR14 and FR18, cli-surface INV12 and INV14, and spec:AST-051 FR6, so a maintainer needs to provide the governing spec by landing INV30 with matching amendments to those records, or ask for a documented, invocation-scoped programmatic API instead. Whatever that decision, these changes are needed:
- Split the change, which is about 4,200 authored lines, so that the lockfile and range readers, the host
discoverhandler, and the runtime planner land separately. - Keep
findCoreDirunchanged when no package set is active, or move its unbounded walk,namecheck, and Yarn PnP fallback into their own PR, because two existing tests inagent-docs.test.mjsfail with it. - Make the
package-set.test.mjscase "names what each root carries…" pass underpnpm vitest, where its fixture's missing lockfile turns the install hint intopnpm install. - Tag the changeset
[feat]instead of[fix](spec:AST-017FR7). - Apply host
discoverhandlers only to integrations served from the package set, and let aprojectplan load a configured integration the project installed, as an installed CLI does.
[Automated review]
| if (fs.existsSync(nodeModules)) { | ||
| return nodeModules; | ||
| } | ||
| for (;;) { |
There was a problem hiding this comment.
With no package set active, this now walks to the filesystem root (the base lookup stopped after five directories), skips a packages/core or installed Core whose name is not @astryxdesign/core (lines 48 and 51), and falls back to Yarn PnP at line 58. Every run without a host changes, and two existing tests in foundation/agent-docs/agent-docs.test.mjs, a file listed in cli-surface verified_by, fail because their Core fixtures carry no name. Keep the base lookup when no set is active, or move this change into its own PR with updated fixtures and a changeset that discloses it.
| "astryx: this project's Astryx package versions are unavailable:", | ||
| ' @acme/ui: project pinned 1.0.0 (package.json); available: 2.0.0 (set 1), 1.0.0 (set 2)', | ||
| ' @acme/extra: project pinned 1.0.0 (package.json); available: 1.0.0 (set 1), none (set 2)', | ||
| "Install the project's dependencies (npm install) to use its own versions.", |
There was a problem hiding this comment.
This fixture has no lockfile or packageManager, so installCommand takes the package manager from the runner's user agent. Under pnpm vitest run --project node (CI's command) the report says pnpm install and this assertion fails; under plain node it passes. Write a package-lock.json into the fixture, or assert only the pin lines.
| '@astryxdesign/cli': patch | ||
| --- | ||
|
|
||
| [fix] Let a host run the unchanged Astryx CLI from a compatible package set while the caller's project keeps authority over its installed versions, configuration, working directory, files, and integration provenance. The in-process seam adds no command, flag, environment variable, or package export. |
There was a problem hiding this comment.
spec:AST-017 FR7 tags compatible capabilities [feat]; [fix] is for corrections. If the Core-discovery change for runs without a host stays in this PR, the changeset should describe it too.
| */ | ||
|
|
||
| /** @type {ActivePackageSet | null} */ | ||
| let active = null; |
There was a problem hiding this comment.
spec:AST-017 FR18 requires a programmatic control to be an explicit API input that does not depend on ambient mutable process state, so that concurrent calls can choose different values. This module-level set is that kind of state: two overlapping withPackageSet calls see each other's set, lose their own, and leave a stale set active afterwards, and withoutPackageSet swaps it while an async doctor run is awaited. Resolving that needs either a spec amendment or an invocation-scoped design, and the decision is with maintainers.
| // discover source itself (foundation/runtime/package-root.mjs). The | ||
| // replacement is validated like the export it replaces, and the | ||
| // integration keeps its own name, so results still name this package. | ||
| const hostDiscover = packageSetHandler(pkg.name ?? spec, 'discover'); |
There was a problem hiding this comment.
This consults the host handler for every loaded integration, including one the project installed itself: in a project plan whose provenance records @acme/catalog as the project's, discover reports the host's source as @acme/catalog's. That breaks the project-authority promise this runtime makes, and a host-provided source is also outside current spec:AST-051 FR6 ("Sources are functions a project or integration provides"). At minimum, apply handlers only to integrations the plan serves from the package set, and test the project-installed case.
| entry.dir != null && | ||
| sameDirectory(entry.dir, dir), | ||
| ); | ||
| if (plannedProjectPackage || projectDeclaresPackage(cwd, packageName)) { |
There was a problem hiding this comment.
A project plan records only declared pins, so a configured integration the project installed but did not declare (for example, hoisted as a dependency of a declared package) is refused here, although the installed CLI loads it and doctor, which runs with no set, reports it healthy. That contradicts the project contract in package-set.mjs lines 21–23 ("as an installed CLI would"). When the plan has no root, admit an installed configured package as the installed CLI does, or correct that contract and have INV30 state the divergence.
There was a problem hiding this comment.
This PR needs a maintainer spec decision before it can be approved: the hosting contract it implements (cli-surface INV30) is not on main, and as written the hosted runtime conflicts with current spec:AST-017 FR14 and FR18, cli-surface INV12 and INV14, and spec:AST-051 FR6. A maintainer needs to provide the governing spec, either by landing INV30 on main with matching amendments to those claims or by asking for a documented, invocation-scoped programmatic API instead. The latest commit resolves the earlier test, changeset, Core-lookup, and provenance findings; whatever the spec decision, two changes are still needed:
- Split the change, about 4,400 authored lines, starting with the host
discoverhandler and the stricter integration-name check for every run, neither of which version planning needs. - Make
projectplans and hosteddoctorruns do what the runtime says, or document what they do: aprojectplan drops undeclared legacy packages that the installed CLI lists, anddoctor integration componentschecks against the package set's Core.
[Automated review]
| scanDir(nodeModulesDir); | ||
| // A plan enumerates only the project package directories it recorded. Never | ||
| // scan the caller's whole node_modules while a hosted set is active. | ||
| for (const entry of set.packages) { |
There was a problem hiding this comment.
In a project plan this reads only the packages the plan recorded, so an installed but undeclared legacy package that the installed CLI lists disappears (for example a hoisted dependency with an astryx.docs field). package-set.mjs lines 21–23 say a project plan resolves "as an installed CLI would". Either scan as the installed CLI does when set.mode === 'project', or state the narrower behavior there, in the PR description, and in INV30.
| */ | ||
| export async function runChecks(options = {}) { | ||
| export function runChecks(options = {}) { | ||
| return withoutPackageSet(() => runProjectChecks(options)); |
There was a problem hiding this comment.
Only the health report is isolated here. doctor integration components calls findCoreDir directly (api/integration/authoring-checks.mjs line 245), so under a hosted plan it checks against the package set's Core while this report says Core is not installed. Run the doctor integration subcommands inside withoutPackageSet too, or narrow the statement that doctor always runs with no package set active.
| */ | ||
|
|
||
| /** @type {ActivePackageSet | null} */ | ||
| let active = null; |
There was a problem hiding this comment.
spec:AST-017 FR18 requires a programmatic control to be an explicit API input that does not depend on ambient mutable process state, so that concurrent calls can choose different values. This module-level set is that kind of state: two overlapping withPackageSet calls see each other's set and can leave a stale set active, and withoutPackageSet blanks it for any other invocation while doctor runs. Resolving that needs either a spec amendment or an invocation-scoped design, and the decision is with maintainers.
| integrations, | ||
| projectCliAlreadyHandled, | ||
| }); | ||
| for (const warning of plan.warnings) stderr.write(`${warning}\n`); |
There was a problem hiding this comment.
cli-surface INV12 makes humanLog and humanWarn the only chatter primitives, and both are silent under --json; this writes every plan warning to stderr in every mode, including --json runs (package-set.test.mjs lines 414–454). Whether a host wrapper is held to INV12 is part of the pending spec decision.
a857fb8 to
28c3e51
Compare
12c63ae to
f06b2e9
Compare
28c3e51 to
2f7f9fc
Compare
There was a problem hiding this comment.
This PR needs a maintainer spec decision before it can be approved: the hosting contract it implements (cli-surface INV30) is not on main, and as built the runtime departs from current cli-surface INV14, spec:AST-051 FR6 and spec:AST-017 FR18, so a maintainer needs to provide the governing spec, either by landing INV30 on main with matching amendments to those claims or by asking for a redesign. This revision resolves the earlier JSON-chatter, project-plan, doctor and overlapping-set findings; whatever the spec decision, these changes are still needed:
- Split the change (5,573 authored lines), starting with the formatter-only reflow, the Core-keyed cache changes, and the host
discoverhandler. - Document
@astryxdesign/cli/hostfor consumers (defaults, error behavior including the rejected overlapping call, and an example) asspec:AST-017FR14 requires, and correct the PR description, which says no export is added. - Read Yarn Berry lockfile keys that list several descriptors in one quoted string; today such a pin is lost and a matched plan can serve a different version.
- Stop truncating delegated output over 1 MiB when the host passes its own streams, and fix the other-CLI refusal, which names the selected root's CLI as the running one.
[Automated review]
| if (!/^\s/.test(line)) { | ||
| current = []; | ||
| if (!line.endsWith(':')) continue; | ||
| for (const raw of line.slice(0, -1).split(',')) { |
There was a problem hiding this comment.
Yarn Berry writes several descriptors as one quoted key, for example "@acme/ui@npm:^1.0.0, @acme/ui@npm:^1.0.2":. Splitting on , before unquoting yields the name "@acme/ui and the range npm:^1.0.2", so when the package has another resolution neither the exact match nor the single-version fallback answers and the planner falls back to the declared range. With a lockfile resolving 1.0.4, a matched plan served 1.0.0 from the first root even though a root carrying 1.0.4 was offered. Unquote the whole key first, then split on , , and add a Berry multi-descriptor case to locked-versions.test.mjs.
| } | ||
| const ownStdout = stdout === process.stdout; | ||
| const ownStderr = stderr === process.stderr; | ||
| const child = spawnSync(process.execPath, [cli.bin, ...argv], { |
There was a problem hiding this comment.
With host-supplied streams the child's stdout and stderr are piped through spawnSync, which keeps Node's default 1 MiB maxBuffer. A project CLI that prints more is killed with ENOBUFS; the truncated output is written to the host's stdout and then followed by an ERR_VERSIONS_UNAVAILABLE envelope, so --json output is no longer one envelope and the code describes a version problem that did not happen. Stream the child asynchronously (or raise maxBuffer), and report a spawn failure without appending an envelope to partial output.
| ) { | ||
| const cli = /** @type {PlannedCli} */ (plan.cli); | ||
| return refuse( | ||
| `astryx: cannot run because this command uses ${CLI_PACKAGE}${cli.version ? ` ${cli.version}` : ''}, but the selected packages require another CLI.`, |
There was a problem hiding this comment.
cli here is plan.cli, the selected root's CLI, so with CLI 0.7.0 running and a root carrying 0.5.0 this prints "this command uses @astryxdesign/cli 0.5.0, but the selected packages require another CLI", which reverses the two. Name the running CLI's version and the selected root's version, and tell the host to call that CLI's own entry (plan.cli.runtime).
| "types": "./api/index.d.mts", | ||
| "import": "./api/index.mjs" | ||
| }, | ||
| "./host": { |
There was a problem hiding this comment.
This adds a public, typed package export, but nothing a consumer reads documents it: spec:AST-017 FR14 asks supported behavior to be documented and discoverable, with accepted values, defaults (such as integrations defaulting to the newest root's dependencies), error behavior (the rejected overlapping call, the other-CLI refusal and the plan.cli.runtime handoff) and a representative invocation, linked from a discovery surface. The PR description also says the change adds no export; please correct its public-delta section.
| argv, | ||
| {cwd = process.cwd(), stdout = process.stdout, stderr = process.stderr} = {}, | ||
| ) { | ||
| if (running) { |
There was a problem hiding this comment.
spec:AST-017 FR18 asks that a programmatic control not depend on ambient mutable process state and that concurrent calls can select different values independently. Package state is now scoped per call, but this runner still switches the process's working directory, argv, stdio and exit handling for each call and rejects an overlapping one. Whether a single-flight host entry is acceptable is part of the pending maintainer spec decision, so this is recorded for that decision rather than as a required change.
…ands written without a runner
… npm G22 failed on devservers: envOf kept http_proxy/https_proxy/all_proxy, so the background check's npm request for the 127.0.0.1 test registry went to the proxy; and the runs' search path held only a node link, so where npm is not beside Node the check could not start it. envOf now drops the proxy variables, and the private computer's node folder links the runner's npm entry file too. With the proxies set, the old test fails and this one passes.
…s why it failed - npmCommand also takes an npm beside the running Node, or on the search path, that links to npm's entry file, as distribution packages install it (/usr/bin/npm to /usr/lib/node_modules_22/npm/bin/npm-cli.js). - resolveLatestRelease names why it returned nothing: npm-missing, npm-failed: <npm's error code>, or bad-reply. The check records it in state.json's checkFailed (diagnosis only, not a contract), and a check that reaches the registry clears it. - doctor's newest-release check says when the last check did not reach the registry and why, noting that npm's registry and proxy settings decide where it asks. Tests: npm found through a link on the search path and beside Node, and npm started directly when there is none; each failure reason; the record and its clearing.
There was a problem hiding this comment.
This needs changes before approval. The host entry's inputs, the one-call rule and the package-set matching follow the current spec:AST-081 FR1 and architecture:cli-surface INV30, but a few things are missing or wrong.
- Split the 2,219 authored lines along the branch's own two feature commits: the host entry first, then the package sets, approved integrations, discover sources and provenance record.
- When another package set's host entry serves a run, settle
runHostedCliwith the child's{status, packages}and carry the host's discover sources across, instead of exiting the host process (foundation/release/handoff.mjs), as INV30 andspec:AST-051FR6 require. - List every path that ends the process in the README and
host/index.d.ts, because--helpand--versionnever settle today. - Give the declined-CLI case its own who-answered line, key the host's saved discover copy per host, and link the entry from
astryx docs cli/api.
[Automated review]
| const options = { | ||
| argv, | ||
| cwd: process.cwd(), | ||
| roots: [root], | ||
| integrations: [...(hosted?.integrations ?? [])], | ||
| ...(door ? {cliCommand: door} : {}), | ||
| ...(declinedProjectCli ? {declinedProjectCli} : {}), | ||
| }; | ||
| const script = [ | ||
| `const {runHostedCli} = await import(${JSON.stringify(pathToFileURL(hostEntry).href)});`, | ||
| `const {status} = await runHostedCli(${JSON.stringify(options)});`, | ||
| 'process.exitCode = status;', | ||
| ].join('\n'); | ||
| return handOff(null, argv, choice, json, () => {}, [ |
There was a problem hiding this comment.
When another package set's host entry serves the run, the child gets no discoverSources, because they are functions and never leave this process. The generated script discards the child's {status, packages}, and handOff then exits this process (line 511), so runHostedCli never settles. architecture:cli-surface INV30 says the host entry returns the provenance record with the run's result, and spec:AST-081 FR1 and spec:AST-051 FR6 say discover calls the door's sources. One way to conform: keep the parent waiting, have the child send its result back over an extra pipe, proxy the source calls over the same channel, and resolve with the child's result.
| * The run owns the process's working folder, arguments, standard streams, | ||
| * and exit: a run handed to another release, and some failures, end the | ||
| * process with the run's exit status instead of returning. |
There was a problem hiding this comment.
--help, --version and --version --json also end the process, through handleCommanderError and handleVersionJsonPreflight, so the call never settles for them either. A host that awaits the result to log packages or clean up never gets there. Please list every path that ends the process here and in the README's Host entry section, or make those paths settle with status 0 in a hosted run.
| if (choice.version === self.version) { | ||
| choice = { | ||
| ...choice, | ||
| copy: 'matched', | ||
| answer: 'self', | ||
| bin: null, | ||
| unavailable: null, | ||
| }; |
There was a problem hiding this comment.
When the project's CLI is this copy's release but its Core is another, for example CLI 0.7.2 with Core 0.7.0, this relabels the run as matched. The run then prints astryx: answered by CLI 0.7.2 with Core 0.7.0, the release that matches this project's Core, which is not true here, and JSON reports copy: matched, which spec:AST-081 FR5 defines as the release matched to the project's Core. A line of its own for the declined-CLI case, naming the project CLI's release, would avoid the misleading claim.
| } | ||
|
|
||
| /** Where a discover source a host passed comes from (spec AST-081 FR1). */ | ||
| const DOOR_SOURCE = 'the host'; |
There was a problem hiding this comment.
Saved discover copies are keyed by the source's from label, so every tool on one computer that carries the CLI shares the same the host saved copy in the per-user cache. When one tool's source fails, discover serves another tool's saved catalog as this host's. spec:AST-051 FR8 keeps saved answers per source. Could a door's key include something host-specific, such as the starting root?
…CLI's release - When another package set's release answers a hosted run through its own host entry, that entry runs in this process with the same inputs, discover sources included, and runHostedCli settles with its result (architecture:cli-surface INV30, spec:AST-051 FR6) instead of a child process that ended the host's. - A declined project CLI answered by this copy, its release, reports copy `project` and prints a line of its own naming that CLI's release and the reason, not the matched-release line. - A host's discover sources keep their saved copies per host, keyed by the root that holds its CLI (spec:AST-051 FR8). - The README, host/index.d.ts, and a new consumer guide (`astryx docs cli/host-entry`, linked from `astryx docs cli/api`) list every path on which a run ends the process instead of settling.
There was a problem hiding this comment.
Approval waits on a maintainer decision: spec:AST-081 FR5 does not say which meta.answeredBy.copy value or which standard-error line a hosted run reports when it answers in place of a declined project CLI of its own release, and this PR reports copy: project with a new in-place line, so a maintainer needs to provide or identify that FR5 position. Whatever that decision is, two changes are needed:
- Split the 2,523 authored lines along the branch's own two feature commits (the entry with its provenance record first, then package sets, approved integrations and discover sources), and drop the formatting-only reflow.
- Report a project's own packages as
projectinpackageswhen the host's CLI is installed inside the project;resolvedPackagescurrently labels everything under the starting rootpackage-set(foundation/runtime/package-root.mjs).
FR1's verification row also asks for host-door tests in a project, and for a discover case with project and integration sources beside the host's.
[Automated review]
| return [...resolved.values()].map(({name, version, dir}) => ({ | ||
| name, | ||
| version, | ||
| source: inPackageSet(dir) ? 'package-set' : 'project', |
There was a problem hiding this comment.
When the host's CLI is installed inside the project (a tool the project depends on, which npm hoists into the project's node_modules), startingRoot is the project itself, so every package the project installed comes back as package-set. A probe with discover --json reported the project's declared integration acme-widgets as package-set, and the same project with the host's CLI elsewhere reported it as project. architecture:cli-surface INV30 says "A project's installed packages always resolve from the project". Could a package inside the project the run answers be labelled project before the package sets are checked?
| else if (!json && inPlace) | ||
| console.error(inPlaceOfProjectLine(choice.version, inPlace)); |
There was a problem hiding this comment.
spec:AST-081 FR2 has the declined CLI's release answer in its place, but FR5 defines neither a meta.answeredBy.copy value nor a standard-error line for this case. Its project value and line rule cover only the project's own CLI answering, or a hand-off to it. A maintainer is deciding whether FR5 takes copy: project and this line.
| }); | ||
|
|
||
| describe("the host's discover sources", () => { | ||
| it("are called after every other source, and reported as the host's", () => { |
There was a problem hiding this comment.
This case runs in an empty folder, so no project or integration source sits beside the host's. spec:AST-081's verification row for FR1 asks for "a door source beside project and integration sources" and fails when "a door's source is called out of order". Adding an astryx.config discover and an integration's discover would cover that order.
… sources in a project - The provenance record names what the project found or loaded as the project's: the Core it resolves, the integrations its load brings in, and, when the host's CLI is installed in the project, every package there. A package set inside the project folder is still a package set. - Approved integrations come from the package set's own node_modules, without moving the existing scan's lines. - An end-to-end test in a project with an astryx.config source and an integration's source checks that the host's sources come after both, before the official list.
|
Maintainer decision on AST-081 FR5: when a host declines a project's own CLI and the copy that answers is that CLI's release, |
There was a problem hiding this comment.
Changes are needed before approval. The host entry, its inputs and the package-set rules follow spec:AST-081 FR1 and FR2 and architecture:cli-surface INV30, and the in-place line for a declined project CLI now follows the maintainer's FR5 decision; what remains:
- Split the 2,708 authored lines along the branch's own two feature commits (the entry with its provenance record first, then package sets, approved integrations and discover sources), and drop the formatting-only reflow in
api/discover/_adapter.mjsand the bin. - Keep a hosted run from installing anything when a qualifying package set's host entry cannot load and the set has no bin, where
startRuncurrently reachesensureRelease(foundation/release/handoff.mjs), against INV30's “A hosted run installs nothing”. - Correct the
declinedProjectClinote inhost/index.d.ts, which leaves out the package set's host entry that serves another release. - Add FR1's per-example door comparison through the host entry, including projects on the current and previous minor.
[Automated review]
| }); | ||
| if (answered) return answered; | ||
| } | ||
| bin = served.bin; |
There was a problem hiding this comment.
When the served set's host entry cannot load (answerInPackageSet returns null) and the set has no astryx bin, which qualifyingRoot allows (foundation/runtime/package-set.mjs line 118), bin stays null here and the run falls into ensureRelease below, which starts npm. A probe with such a set printed astryx: installing CLI release 0.7.0 into the per-user cache (once)... and left releases/.failed-0.7.0.json in the per-user cache. architecture:cli-surface INV30 says “A hosted run installs nothing”. Falling back here when served.bin is null (or keeping ensureRelease out of hosted runs), with a hosted-runtime.test.mjs case for a set whose entry cannot load, would close it.
| * run is then never handed to that CLI: this copy answers when it is that | ||
| * CLI's release, and otherwise answers with one warning line naming the | ||
| * reason and `meta.answeredBy.copy` set to `fallback`. Default: none; a |
There was a problem hiding this comment.
When this copy is not the declined CLI's release, a qualifying package set's host entry of that release answers first (foundation/release/handoff.mjs lines 258–273), as the README's declinedProjectCli row says; only without one does this copy answer with the fallback warning and copy: fallback. Could this sentence name the package-set case too?
| it('gives the same exit status, output, and standard-error line', () => { | ||
| const empty = tempDir('empty'); | ||
| const env = cleanEnv(); | ||
| for (const args of [ |
There was a problem hiding this comment.
spec:AST-081's verification row for FR1 asks for every command example run through each door, in a project on the current minor and one on the previous minor as well as an empty folder. This loop covers three invocations in an empty folder. Running every CommandDoc example through the bin and the host entry in those folders, comparing status, stdout and stderr apart from FR5's names and lines, would supply that evidence.
…h both doors - A hosted run whose matching package set's CLI starts through neither its host entry nor a bin is answered by this copy, announced, and installs nothing (architecture:cli-surface INV30), instead of installing that release. - host/index.d.ts says a package set's host entry of the declined CLI's release answers in its place, as the README does. - A door conformance test runs every command example through the bin and through the host entry, in an empty folder, a project on the current minor, and one on the previous minor, and compares exit status, output, and file changes (spec:AST-081 FR1). - The discover adapter and the bin keep the formatting of the lines this change does not touch.
The gh tool writes a random device id when swizzle asks it whether it is signed in, and npm keeps a cache and logs; both now live outside the folders the conformance runs compare.
There was a problem hiding this comment.
Changes are needed before approval. The host entry, its inputs and the package-set rules follow spec:AST-081 FR1 and FR2 and architecture:cli-surface INV30, the declined-CLI line follows the maintainer's FR5 decision, and last round's install path, type note and per-example door comparison are fixed. What remains is scope: please split the 2,970 authored lines along the branch's own two feature commits, landing the entry with its provenance record and the door-conformance test first, then the package sets, approved integrations and discover sources.
[Automated review]
|
Maintainer decision: this repository has no PR size limit; one PR per piece of work. This PR is one piece: the supported host entry AST-081 FR1 and cli-surface INV30 describe. Its parts are not independently useful. A host entry without package sets, approved integrations or discover sources would ship a partial contract that hosts can't use. The size is accepted; please review the content. |
Maintainer decision: one PR (see the decision comment). Every other review item is resolved on 817efac.
User need
A tool that carries the Astryx CLI for its own users, such as a company's own command-line tool that runs it as
acme astryx …, needs to start the CLI with explicit inputs. It needs two results. First, the commands the CLI prints must name the tool's command. Second, a project CLI that the tool chose not to run must never run anyway. Today there is no supported entry. Such a tool runs theastryxbin, which prints package-runner commands (npx astryx …) that its users may not have, and which hands a project's run to a project CLI that the tool skipped.Problem and solution fit
@astryxdesign/cli/hostexportsrunHostedCli, the host entry thatspec:AST-081FR1 defines. A run behaves as theastryxbin does with the same arguments in the same folder, once per process.cliCommandis the name the door's users type. Printed commands start with it, unless the integrations the run loads declare their owncliCommand(FR5).declinedProjectCliis the reason, in the host's words, that the host found the project's own CLI and did not run it. The run is then never handed to that CLI (FR2, FR9). When this copy is that CLI's release, it answers in that CLI's place:meta.answeredBy.copystaysproject, and in text mode one line names that CLI's release and the reason. A package set whose CLI is that release answers the same way through its host entry. Otherwise this copy answers with FR2's fallback warning, which names the reason.rootsare the host's package sets, in its order of preference. A hosted run installs nothing (INV30, FR2). A release other than this copy comes from the first set whose CLI and Core are that release and that holds what the project would install for each@astryxdesign/*package it leaves uninstalled: the lockfile's version, else a published version in the declared range, never an unrequested prerelease. A package that ships an integration manifest is never filled inside a project. When that set's CLI ships a host entry, the entry runs in this process with the same inputs, discover sources included, and the call settles with its result; otherwise its bin takes the run. With no such set, this copy answers with FR2's fallback warning. A declined project CLI's release is served only through a set's host entry, so the declined CLI never runs.integrationsare the integrations the host approves for use outside a project. Each loads by name from the set that holds this CLI, with FR12's checks, beside what FR12 finds there.discoverSourcesare the host's own discover sources. Discover calls them after every integration's source, before the official list, and reports each asthe host(spec:AST-051FR6). Their saved copies are kept per host, by the root that holds its CLI, so two tools on one computer never answer with each other's (FR8).Current specification
spec:AST-081(current): FR1 (the host entry, its inputs, one call per process), FR2 (a declined project CLI; a hosted run installs nothing), FR5 (the door step of the command-name picker), FR9 (no hand-off to a declined project CLI).architecture:cli-surface(current): INV30 (a host's package sets), INV2 (meta.answeredBy), INV22.Public delta and caller burden
./host(host/index.mjs,host/index.d.ts) and thehostfolder in the package's files.argvastryx.cwdcliCommandcliCommand.declinedProjectClirootsintegrationsdiscoverSources{status, packages}, wherepackageslists each package the run resolved as{name, version, source}andsourceisprojectorpackage-set. When another package set's host entry answers, the call settles with that entry's result. As the bin does, a run ends the process with its status instead when it prints help or the version, rejects the command line, reports an error it stops on (every error in--jsonmode included), meets an unexpected error, or hands the run to another CLI's bin; the README,host/index.d.ts, and the guide list these. It rejects with aTypeError, before anything runs, for an unknown option or an invalid value. It rejects with anError, before anything runs, when a run already started in the process.clients/cli/run.mjs, which the bin calls after its Node version gate. The bin behaves as before.astryx docs cli/host-entry, under the CLI's guides and linked fromastryx docs cli/api, with the options, the result, the errors, and the process-ending paths.@astryxdesign/clipatch[feat].Before, a tool spawns the bin, and search prints
command: npx astryx component Calendar. After:Search then prints
command: acme astryx component Calendar.Design and alternatives
foundation/runtimeholds the active hosted run and the provenance record (package-root.mjs), matching a project to a set (package-set.mjs), and the versions a project would install (locked-versions.mjs), as INV30's owning code lists. It reuses the release choice's lockfile reader and semver helpers instead of carrying its own.Evidence
host/index.test.mjs: every invalid input is rejected before anything runs. A second call in one process fails while the first run completes. A hosted run gives the same exit status, standard output, and standard error as the bin for--version, an error, anddocs --json. Help names the host's command. For each declined reason, the project's CLI never runs, and the fallback line names the reason (meta.answeredBy.copyisfallback). A declined CLI of this copy's own release, with a Core of another release, is answered in its place:copyisproject,coreis the project's, and one line names the release and the reason. Each of these tests fails when its feature is removed.foundation/runtime/package-set.test.mjs(INV30 evidence): the first set whose CLI and Core match serves; a set with a mismatched or missing Core is skipped; the lockfile's version is required, else a version in the declared range; a path or protocol declaration needs the lockfile; a prerelease needs a range that names it; integrations and installed packages are never filled; a root never reads past its ownnode_modules; approved integrations load from the set with FR12's checks, and never from a folder above it; the provenance record names the project's packages as the project's, also when the host's CLI is installed in the project or a workspace hoists them, and a package set inside the project folder as a package set.foundation/runtime/hosted-runtime.test.mjs(INV30 evidence), through the host entry in a host process: a project whose own CLI cannot start is served by the first matching set; its host entry, when it has one, runs in the same process with the same inputs, discover sources included, and the call settles with its result; with no matching set, or one whose CLI starts through neither its host entry nor a bin, this copy answers with the fallback warning and nothing is installed; a declined project CLI is served through a set's host entry and never run, and without one this copy answers naming the reason; the host's discover source is called and reported asthe host, and in a project it comes after theastryx.configsource and an integration's source, before the official list; the result names the CLI and Core from the package set and a project's integration as the project's.api/discover/_adapter.test.mjs: a host's saved discover copies are kept per host; another host's failing source gets none of them.host/door-conformance.test.mjs(FR1 door conformance): every command example runs through the bin and through the host entry, in an empty folder, a project on the current minor, and a project on the previous minor, each run with its own folder, home folder, and per-user cache; exit status, standard output, standard error, and file changes are the same through both doors.mainon the same machine.Scope
Testing
pnpm vitest run --project node packages/cli/host packages/cli/foundation/runtime packages/cli/api/discover/_adapter.test.mjspnpm vitest run --project node packages/clipnpm -F @astryxdesign/cli typecheck:strict,pnpm check:cli-structure,pnpm -F @astryxdesign/cli readme:check,pnpm check:changesets, eslint, and Prettier on the changed filesBranch history
mainholds only the host entry.