plugin add/remove: nothing records what an install created, so the undo and the uninstall both guess
维护者通常 1 天内回复
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 12/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- node.js, typescript
- 领域
- tooling
调研方向
Start with the plugin add and plugin remove paths that write matbot.yaml, the root package.json key, .plugins/node_modules/<name> and .plugins/.restore/, and with readDependencyNames, which the payload says both paths share. Reproduce one add then remove on the npm route and list what remains under .plugins/. Done when a per-plugin install record drives both the undo and remove, and add then remove leaves nothing add created. Open PR #103 already targets this, so coordinate with it before starting.
由索引模型根据 Issue 内容生成。
描述
Summary
plugin add creates things in up to six places depending on the route: a package.json key, node_modules, .plugins/<host>/…, a .plugins/node_modules/<name> self-link, dependencies installed into a cache directory or a local checkout, and .plugins/.restore/. Nothing records which of them a given install created. So remove, and the undo of an add that then disowns the plugin, both infer it from the state they find. Each fix to one inference has broken the other, and a live run shows remove leaving most of it behind.
These should be fixed together. They are two halves of one question: what did this install create, and who takes it back out?
Already known
The gap #90 left. On the npm route, an add that then disowns the plugin keeps the install. That happens on a duplicate name, an incompatible runtime, or "not a plugin". On a duplicate name config is never written, so remove has no entry to offer the uninstall against.
Two regressions in the attempted fix. The fix is in PR #93's commits (6d56bd1, 1f42280, never merged; #93 is closed in favour of this issue):
readDependencyNameswas widened todevDependenciesandpeerDependenciesfor the undo's before-snapshot.removeshares it, soplugin remove @x/foonow offers topm removea package the project declares only as a peer or dev dependency, deleting the project's own declaration.- A new pre-install name-clash guard refuses
plugin add [email protected]whenfoois loaded. That removes the only in-tool way to change an npm plugin's version; before, the version changed on disk and a reload picked it up despite the clash error.
Found by a live add → reload → remove run
The run used @matatbread/matbot-email from github, a local path, npm and http. All four routes installed, reloaded and worked. remove cleans matbot.yaml and, for npm, the root package.json key and node_modules link, but leaves:
- The self-link
.plugins/node_modules/@matatbread/matbot-email. It survivesremove, so a removed plugin is still resolvable by bare name. It was repointed by whichever route installed last, and was left dangling at the end. - The cached source and its installed dependencies.
.plugins/raw.githubusercontent.com/MatAtBread/matbot-email/keptHEAD/,main/andrefs/heads/main/, each withsrc/and a fullnode_modules(imapflow, mailparser, nodemailer, …). Each spelling of the same repo is a separate cache directory that is never reclaimed;main/held an older revision. - Empty
.plugins/.restore/…directories left behind afterdiscardRestore. - The host's
pnpm-lock.yamlrewritten. After the npm cycle the lockfile had lost itscatalogs:block, whilepackage.jsonwas back as it was. Thenode_modules/.pnpmentries also remain, though pruning those is arguably pnpm's job. - Local route: installing dependencies writes
node_modulesandpackage-lock.jsoninto the user's checkout. That is by design, butremovenever mentions it.
Suggested direction
Use the same shape as the #89 fix (#97): state it instead of deriving it. add would write an install record per plugin, saying which route it took, the dependency key it introduced into package.json (if any), the cache root, the self-link, and the dependency directories and lockfile it created. Both the undo-on-disown and remove would replay that record and act on nothing else, with nothing inferred from the specifier or a manifest diff. Changing an installed plugin's version would become an explicit operation rather than a side effect of the clash path.
Done when
- For every route,
add→removeleaves nothing thataddcreated, unlessremovewas told to keep it. - A failed or disowned
addleaves nothing behind. - Neither path ever touches a dependency that
adddid not introduce. plugin add foo@<version>on a loadedfoohas a defined, documented behaviour.
- 主要语言
- TypeScript
- 星标
- 5
- 派生
- 2
- 平均合并
- 1 天 2 小时
- 30 天内合并 PR
- 12
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
MatAtBread/matbot 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
MatAtBread/matbot#95 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 70/100
MatAtBread/matbot#94 ·
维护者通常 1 天内回复
-
http: let a header value come from the Vault, so a keyed API needs no secret in the conversation未关闭enhancement
难度 4/5 3-5 天 新手友好度 22/100
MatAtBread/matbot#104 ·
维护者通常 1 天内回复
-
难度 3/5 半天 新手友好度 66/100
MatAtBread/matbot#100 · 1 条评论 ·
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 35/100
MatAtBread/matbot#96 ·
维护者通常 1 天内回复
查看 MatAtBread/matbot 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 85/100
juice-shop/juice-shop#3686 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
dsh-market/dsh-market#877 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
-
enhancement
难度 2/5 1-3 小时 新手友好度 74/100
ScottKirvan/GOMAC#61 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
stellar/stellar-dev-skill#151 ·
维护者通常 1 天内回复