Skip to content

feat(plugins): install local artifacts through the plugin manager - #4615

Merged
thymikee merged 11 commits into
0.22from
feat/0.22-managed-plugin-artifacts
Nov 17, 2026
Merged

thymikee merged 11 commits into
0.22from
feat/0.22-managed-plugin-artifacts

Conversation

@thymikee

@thymikee thymikee commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Use one plugins add command for npm selectors and local plugin tarballs, for #4591 and #4597.

agent-device plugins add @scope/plugin@1.2.3
agent-device plugins add ./provider-plugin.tgz --json

Local paths must start with ./ or ../, or be absolute. Missing archives fail locally without falling back to npm. The unreleased add-artifact command is removed.

The existing archive installer retains integrity and package validation, disabled lifecycle scripts, factory non-execution, collision protection and rollback. Local installation reports compatibility unchecked; use plugins list to check it. Close sessions and restart the daemon after changes. Registry selectors retain their existing behavior. The public addPluginArtifact(path, { env, cwd }) SDK remains unchanged.

Scope: 13 files. One private transaction owns locking, selection publication and failure cleanup for both sources.

Validation

Tested head: 26d012581ef13d9dabee852a5cc4b6c01aae377f, based on 0.22 at e3211ae.

Exact affected and full checks passed with unchanged checkout. Focused tests cover both target kinds, supplied host context, missing local files without registry fallback, and real tarball installation without executing scripts or factories. The packed SDK/CLI inventory acceptance remains intact.

Independent full-range source review cleared aea42b3; root reviewed the subsequent five-file CLI change. Hosted checks for this head are pending. Live consumer adoption remains separate.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.14 MB 6.15 MB +4.2 kB
Package (unpacked) 6.14 MB 6.14 MB +4.2 kB
Package (download) 1.86 MB 1.86 MB +1.3 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 20.4 ms 22.5 ms +2.1 ms
CLI --help 39.0 ms 53.0 ms +14.1 ms

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 9 files

You’re at about 98% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread src/cli/commands/plugins.ts Resolved
Comment thread src/cli/commands/plugins.ts Resolved
Comment thread packages/plugins/src/store.ts Resolved
Comment thread .changeset/managed-plugin-artifact.md Resolved
@apex-sentinel-staging

apex-sentinel-staging Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve

Since the last review: 0 new · 0 still open · 0 no longer raised

No open findings.

2 findings below minor hidden (user_settings.min_severity).

1 new finding away from what changed since aea42b3 not shown. Comment @apex-sentinel-staging review for a full review.

Reviewed with this repository's own Sentinel configuration (fdf595127a75).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

Earlier reviews

Review of aea42b38 · 17.11.2026 12:07 UTC

Apex Sentinel · ✅ Approve

Since the last review: 0 new · 0 still open · 1 no longer raised

No open findings.

1 finding below minor hidden (user_settings.min_severity).

1 new finding away from what changed since 6cf24b2 not shown. Comment @apex-sentinel-staging review for a full review.

Reviewed with this repository's own Sentinel configuration (fce2fa6247c5).

Review of 6cf24b2d · 17.11.2026 11:02 UTC

Apex Sentinel · ✅ Approve

Since the last review: 1 new · 0 still open · 0 no longer raised

1 finding(s): 1 minor.

🟡 Minor (1)

Where Finding
packages/plugins/src/store.ts:402 🆕 add-artifact and add lock different paths when AGENT_DEVICE_HOME traverses a symlink

Reviewed with this repository's own Sentinel configuration (e0ab0c255c3d).

Review of d8c7b4b4 · 17.11.2026 10:07 UTC

Apex Sentinel · ✅ Approve

Since the last review: 0 new · 0 still open · 0 no longer raised

No open findings.

Reviewed with this repository's own Sentinel configuration (e0ab0c255c3d).

Review of 38f1587e · 17.11.2026 09:31 UTC

Apex Sentinel · ✅ Approve

Since the last review: 0 new · 0 still open · 0 no longer raised

No open findings.

1 new finding away from what changed since bda3910 not shown. Comment @apex-sentinel-staging review for a full review.

Reviewed with this repository's own Sentinel configuration (e0ab0c255c3d).

Review of bda39101 · 17.11.2026 08:42 UTC

Apex Sentinel · ✅ Approve

Since the last review: 0 new · 0 still open · 0 no longer raised

No open findings.

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (e0ab0c255c3d).

Review of 4d0b0108 · 16.11.2026 22:25 UTC

Apex Sentinel · ✅ Approve

Since the last review: 0 new · 0 still open · 0 no longer raised

No open findings.

Reviewed with this repository's own Sentinel configuration (a30accf38081).

Review of 47b4d14e · 16.11.2026 21:36 UTC

Apex Sentinel · ✅ Approve

Since the last review: 0 new · 0 still open · 1 no longer raised (1 marked fixed)

No open findings.

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (a30accf38081).

Review of 356a6696 · 16.11.2026 20:48 UTC

Apex Sentinel · ✅ Approve

1 finding(s): 1 minor.

🟡 Minor (1)

Where Finding
packages/plugins/src/store.ts:399 add-artifact refuses hosts where HOME is unset but homedir() resolves

2 findings below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (ea414582b7fa).

@apex-sentinel-staging apex-sentinel-staging 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.

Apex Sentinel: 1 new finding on 356a669. The verdict and the full list are in the summary comment.

Comment thread packages/plugins/src/store.ts Resolved
@thymikee

Copy link
Copy Markdown
Member Author

I found no blocking problem in the code at 356a669. All 17 checks pass at this commit and there are no conflicts. The containment claim rests on npm's extractor, the realpath checks at store.ts:437-449, and --ignore-scripts.

Not blocking, and you can take or leave these: addPluginArtifact at store.ts:393 copies the lock, config, publish and cleanup steps from changePlugin (store.ts:341-389), so the two can drift. Would one shared "replace one selection under the plugins lock" owner, with only the staging step differing, be simpler? Also, an artifact selection stores the version twice, in selection.version and selection.artifact.version (store.ts:455). A hand-edited config can make them differ, and only artifact.version is honored. Keeping one version field would remove that case.

Before merge, please answer or fix the open inline threads. The most useful ones are the host plumbing at plugins.ts:27 (#4615 (comment)) and the positional label at command-overrides.ts:23 (#4615 (comment)). The other threads that still apply are the Windows npm call in tests (#4615 (comment)), the unchecked-compatibility text output (#4615 (comment)), the prerelease leading zeros (#4615 (comment)), and the missing-HOME refusal (#4615 (comment)). The thread about documenting the replacement steps does not apply, so you can resolve it: website/docs/docs/plugins.md already documents them, and the CLI refuses with typed reasons (#4615 (comment)).

@thymikee

Copy link
Copy Markdown
Member Author

Thanks for the update. At 47b4d14 the code looks right to me, but the Coverage check is red on this head and it passed at 356a669, so the new failure came with this change. The failing route overlaps your delta: store.ts (isExactVersion, addPluginArtifact), src/cli/commands/plugins.ts and the new tests. The job log (run 43960510039) stops during the test run with no failing test or gate message, so it may be a runner problem rather than this change. Please rerun it; if it fails again, check whether the vi.spyOn on the @agent-device/plugins/store namespace behaves differently under coverage instrumentation.

From the earlier review: the HOME and ~/ handling now sits in resolveUserConfigPath, the CLI command uses host consistently, the artifact result reports compatibility as unchecked, leading-zero prerelease identifiers are rejected, and the npm pack fixtures check the exit code.

Could addPluginArtifact stage and validate the tarball through a source-specific helper, while sharing one store transaction owner with changePlugin for plugins.lock, config preservation, selection publication and rollback? Both paths implement that same transaction in store.ts and store.ts. Keeping the immutable artifact marker and npm lockfile details in staging would leave a smaller shared mutation boundary. Neither path has a concrete failure today. Would this smaller shape work, or what made you keep two copies?

The open inline threads from #r4591300984, #r4591300998, #r4591301004, #r4591301012, #r4591301043, #r4591301051 and #r4591349998 are fixed at this head. Please resolve them. There are no conflicts. Before merge, please answer the shared-transaction question and get Coverage green or explained.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready from the code side at 4d0b010. The earlier review at 47b4d14 (#4615 (comment)) asked for evidence, and that evidence is now in place.

Not blocking: the fix in src/core/interactors/limrun-ios-runner.fixtures.ts (https://github.com/callstack/agent-device/blob/4d0b010/src/core/interactors/limrun-ios-runner.fixtures.ts#L18) for the aborted-upload rejection is unrelated to the plugin manager, so would you consider moving it into its own small PR? Keeping it here is fine, since it is test-only and unblocks Coverage.

All seven earlier inline threads are addressed at this head, so you can resolve them. The six marked fixed are: the Windows npm exit-code check in store-artifact.test.ts (#4615 (comment)), the "unchecked" compatibility report in plugins.ts (#4615 (comment)), consistent host.env use in plugins.ts (#4615 (comment)), the leading-zero prerelease check in isExactVersion (#4615 (comment)), the package-or-path? label in command-overrides.ts (#4615 (comment)), and the HOME handling through resolveUserConfigPath (#4615 (comment)). The replacement-steps thread (#4615 (comment)) needs no change, because the steps are in website/docs/docs/plugins.md and the CLI refuses with typed reasons.

Smoke Tests failed in smoke:keyboard-ime, where open com.callstack.agentdevicelab --relaunch returned android-app-close-timeout. That is Android app lifecycle, and this diff does not touch it. The plugin store is not read on that route, and the run selects no plugins. Please rerun that job.

There are no conflicts. Before merge, please rerun the Android smoke job. Please also answer the open question from the 47b4d14 review: should changePlugin and addPluginArtifact (store.ts:342 and store.ts:394) share one store-transaction owner? This update does not address it.

@thymikee

Copy link
Copy Markdown
Member Author

I reviewed bda3910 as a follow-up to the earlier review (#4615 (comment)). The code looks ready, and no code change is needed from this pass. The rebase is clean and all 17 checks pass at this commit. The earlier Android smoke failure is gone; it was on a route this PR does not touch. The range-diff shows the patch is unchanged.

Could packages/plugins/src/store.ts give changePlugin (https://github.com/callstack/agent-device/blob/bda3910/packages/plugins/src/store.ts#L342) and addPluginArtifact (https://github.com/callstack/agent-device/blob/bda3910/packages/plugins/src/store.ts#L394) one shared store-transaction function? It would own plugins.lock acquisition, config publication, staged-install rollback and release. Registry requests and artifact byte and identity validation would stay in their own staging functions. The artifact-selection concept belongs in this module. The repeated lifecycle leaves two paths that must keep the same publication and cleanup rules. If you keep both copies, please say why.

The review threads from the earlier pass now look fixed at this commit, so you can resolve them: the Windows npm pack exit code check (#4615 (comment)), the unchecked compatibility receipt (#4615 (comment)), the handler passing host instead of reading process.env (#4615 (comment)), leading-zero prerelease versions (#4615 (comment)), the changeset step order (#4615 (comment)), the positional label (#4615 (comment)), and the HOME pre-check (#4615 (comment)).

Before merge, please answer the shared-transaction question above. You can also split the unrelated Limrun fixture commit into its own PR.

@thymikee

Copy link
Copy Markdown
Member Author

Thanks for the update. At 38f1587 the code looks good, and the checks show 17 of 17 passing, with no conflicts. Nothing in the earlier review (#4615 (comment)) is still a defect; the one thing left is a design question.

Could packages/plugins/src/store.ts give changePlugin and addPluginArtifact one private owner for the locked selection transaction (config read, atomic publication and staged-directory rollback), with registry and archive staging supplying their source-specific validation and selection data? Both entrypoints still implement those steps separately at https://github.com/callstack/agent-device/blob/38f1587/packages/plugins/src/store.ts#L348-L389 and https://github.com/callstack/agent-device/blob/38f1587/packages/plugins/src/store.ts#L402-L469, and the copies already differ in home realpath and cleanup style. The ADR 0034 update clarifies public SDK ownership, but it does not consolidate this internal responsibility. Please merge them into one transaction owner, or say why the two copies must stay separate.

The required evidence is in place, and the CI run covers this head.

Of the earlier inline threads, these no longer apply, so please resolve them: the packed npm exit code is asserted at store-artifact.test.ts:62 (#4615 (comment)); the receipt reports compatibility as 'unchecked' in code and in the human line at src/cli/commands/plugins.ts:35 and :46 (#4615 (comment)); the handler passes host to addPluginArtifact(name, host) at src/cli/commands/plugins.ts:13,26 (#4615 (comment)); isExactVersion at store.ts:119 rejects leading-zero numeric prerelease identifiers (#4615 (comment)); the changeset names remove, then add-artifact, then a daemon restart (#4615 (comment)); the positional label is 'package-or-path?' at packages/command-surface/src/schema/command-overrides.ts:23 (#4615 (comment)); and addPluginArtifact resolves home through resolveUserConfigPath(host.env) at store.ts:401, so no separate HOME pre-check is needed (#4615 (comment)).

@thymikee
thymikee force-pushed the feat/0.22-managed-plugin-artifacts branch from d8c7b4b to 6cf24b2 Compare November 17, 2026 10:54
@thymikee

Copy link
Copy Markdown
Member Author

Thanks for the update. I found no new code problems at d8c7b4b, and the fix since 38f1587 is in: the lock is now released in the finally block, and the new unit test asserts that the lock is acquired.

CI is green: 17/17 checks pass at d8c7b4b, and the change touches only packages/plugins/src/store.ts and its unit test. This review covers d8c7b4b; 6cf24b2 (the rebase onto e3211ae) landed after it and will be checked next. No review threads changed since the last review.

Not blocking, and you can take or leave it: the new typed cleanup failure (artifact_cleanup_failed, keeping both errors) exists only in addPluginArtifact, while changePlugin and stagePlugin still do a bare rmSync in catch. So when plugins add from the registry fails to clean up its staging, the user sees the raw fs error and loses the npm install error, but add-artifact reports both.

Could one private transaction helper in store.ts own the realpathed home, the plugins.lock acquire and release, the config read, publishFileSync and the staged-project rollback with that typed error? Registry staging and archive staging would then be callbacks that return the project dir and the selection to write. That would remove the second lock and publish copy and give both routes the same cleanup-failure contract.

Before merge, please either fold the two paths into one store-transaction owner or say on the PR why the copies must stay separate.

@apex-sentinel-staging apex-sentinel-staging 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.

Apex Sentinel: 1 new finding on 6cf24b2. The verdict and the full list are in the summary comment.

Comment thread packages/plugins/src/store.ts Resolved
@thymikee

Copy link
Copy Markdown
Member Author

Addressed the shared-owner request in aea42b388c07bcb1503aeb3c4838d31c284a1abc. One private transaction now owns canonical mutation home, lock acquisition, the config/selection read, install project preallocation, atomic publication, and rollback. Registry and archive callbacks retain their source-specific validation; archive bytes and digest are still captured before the transaction.

Both routes report plugin_cleanup_failed with the operation and cleanup errors and original cause; the existing lock helper releases after the task. A malformed config now fails before staging, and simultaneous task/release failures follow withProcessLock precedence. A release failure after publication does not remove the selected project.

The focused tests cover registry cleanup failure with real lock reacquisition, removal without staging, post-publication release failure, malformed config precedence, and artifact cleanup. Exact-head affected passed 42 checks (25 skipped), and full passed 41 (25 skipped), both with unchanged checkout. An independent full-range source review at this head found no actionable P1/P2/P3 findings. Hosted CI and live consumer adoption remain separate.

@thymikee

Copy link
Copy Markdown
Member Author

I reviewed aea42b3 and found no code problems. The lock issue is fixed: add and add-artifact now take the same lock path, built from the resolved home directory in transactSelection (store.ts:322). The registry behavior is unchanged, apart from the typed cleanup-failure contract. The earlier request for evidence is now satisfied.

The open inline thread on the lock path no longer applies, so you can resolve it: the shared lock is in place at this commit. #4615 (comment)

CI shows 16 of 17 checks passing. The one check still queued runs no code, so it does not overlap the store.ts change. There are no conflicts. The PR only needs that check to finish before merge.

The live-automation-scenario and vitest.config.ts entries in the delta come from the base moving forward, so they are not PR code.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 17, 2026
@thymikee

Copy link
Copy Markdown
Member Author

plugins add now accepts either an npm selector or an explicit local .tgz path. Relative paths use ./ or ../; absolute paths use the host platform's path rules. Bare names, including names ending in .tgz, retain their registry meaning.

Local paths go directly to the existing managed artifact installer, with its integrity checks, transaction, script suppression, and unchecked compatibility receipt. A missing or invalid local archive fails locally without trying the registry. The unreleased add-artifact action is removed; the public SDK manager API remains available.

@thymikee
thymikee merged commit 7ccde11 into 0.22 Nov 17, 2026
17 checks passed
@thymikee
thymikee deleted the feat/0.22-managed-plugin-artifacts branch November 17, 2026 13:10
thymikee added a commit that referenced this pull request Nov 19, 2026
)

* feat(plugins): install managed local artifacts

* fix(plugins): bind artifact integrity and inventory to installed selections

* test(plugins): exercise managed artifact installation from the packed SDK

* fix(plugins): preserve host context and clarify artifact receipts

* test(plugins): correct list assertions and isolate host fixtures

* test(limrun): handle canceled fixture uploads

* refactor(plugins): keep one artifact version and clarify manager ownership

* fix(plugins): release artifact lock when staging cleanup fails

* test(plugins): verify lock release after cleanup failure

* refactor(plugins): unify selection transactions

* feat(plugins): accept local archives with add
thymikee added a commit that referenced this pull request Nov 20, 2026
)

* feat(plugins): install managed local artifacts

* fix(plugins): bind artifact integrity and inventory to installed selections

* test(plugins): exercise managed artifact installation from the packed SDK

* fix(plugins): preserve host context and clarify artifact receipts

* test(plugins): correct list assertions and isolate host fixtures

* test(limrun): handle canceled fixture uploads

* refactor(plugins): keep one artifact version and clarify manager ownership

* fix(plugins): release artifact lock when staging cleanup fails

* test(plugins): verify lock release after cleanup failure

* refactor(plugins): unify selection transactions

* feat(plugins): accept local archives with add
thymikee added a commit that referenced this pull request Nov 20, 2026
)

* feat(plugins): install managed local artifacts

* fix(plugins): bind artifact integrity and inventory to installed selections

* test(plugins): exercise managed artifact installation from the packed SDK

* fix(plugins): preserve host context and clarify artifact receipts

* test(plugins): correct list assertions and isolate host fixtures

* test(limrun): handle canceled fixture uploads

* refactor(plugins): keep one artifact version and clarify manager ownership

* fix(plugins): release artifact lock when staging cleanup fails

* test(plugins): verify lock release after cleanup failure

* refactor(plugins): unify selection transactions

* feat(plugins): accept local archives with add
thymikee added a commit that referenced this pull request Nov 21, 2026
)

* feat(plugins): install managed local artifacts

* fix(plugins): bind artifact integrity and inventory to installed selections

* test(plugins): exercise managed artifact installation from the packed SDK

* fix(plugins): preserve host context and clarify artifact receipts

* test(plugins): correct list assertions and isolate host fixtures

* test(limrun): handle canceled fixture uploads

* refactor(plugins): keep one artifact version and clarify manager ownership

* fix(plugins): release artifact lock when staging cleanup fails

* test(plugins): verify lock release after cleanup failure

* refactor(plugins): unify selection transactions

* feat(plugins): accept local archives with add
thymikee added a commit that referenced this pull request Nov 21, 2026
)

* feat(plugins): install managed local artifacts

* fix(plugins): bind artifact integrity and inventory to installed selections

* test(plugins): exercise managed artifact installation from the packed SDK

* fix(plugins): preserve host context and clarify artifact receipts

* test(plugins): correct list assertions and isolate host fixtures

* test(limrun): handle canceled fixture uploads

* refactor(plugins): keep one artifact version and clarify manager ownership

* fix(plugins): release artifact lock when staging cleanup fails

* test(plugins): verify lock release after cleanup failure

* refactor(plugins): unify selection transactions

* feat(plugins): accept local archives with add
thymikee added a commit that referenced this pull request Nov 23, 2026
)

* feat(plugins): install managed local artifacts

* fix(plugins): bind artifact integrity and inventory to installed selections

* test(plugins): exercise managed artifact installation from the packed SDK

* fix(plugins): preserve host context and clarify artifact receipts

* test(plugins): correct list assertions and isolate host fixtures

* test(limrun): handle canceled fixture uploads

* refactor(plugins): keep one artifact version and clarify manager ownership

* fix(plugins): release artifact lock when staging cleanup fails

* test(plugins): verify lock release after cleanup failure

* refactor(plugins): unify selection transactions

* feat(plugins): accept local archives with add
hannojg pushed a commit to hannojg/agent-device that referenced this pull request Nov 23, 2026
…llstack#4615)

* feat(plugins): install managed local artifacts

* fix(plugins): bind artifact integrity and inventory to installed selections

* test(plugins): exercise managed artifact installation from the packed SDK

* fix(plugins): preserve host context and clarify artifact receipts

* test(plugins): correct list assertions and isolate host fixtures

* test(limrun): handle canceled fixture uploads

* refactor(plugins): keep one artifact version and clarify manager ownership

* fix(plugins): release artifact lock when staging cleanup fails

* test(plugins): verify lock release after cleanup failure

* refactor(plugins): unify selection transactions

* feat(plugins): accept local archives with add
thymikee added a commit that referenced this pull request Nov 24, 2026
)

* feat(plugins): install managed local artifacts

* fix(plugins): bind artifact integrity and inventory to installed selections

* test(plugins): exercise managed artifact installation from the packed SDK

* fix(plugins): preserve host context and clarify artifact receipts

* test(plugins): correct list assertions and isolate host fixtures

* test(limrun): handle canceled fixture uploads

* refactor(plugins): keep one artifact version and clarify manager ownership

* fix(plugins): release artifact lock when staging cleanup fails

* test(plugins): verify lock release after cleanup failure

* refactor(plugins): unify selection transactions

* feat(plugins): accept local archives with add
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant