[bug]: dist/ JS retains @agentscript/* imports after scope rewrite, breaking installed package
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 冷清
- 技术栈
- node.js, typescript
- 领域
- build-system, release
调研方向
从 scripts/publish.mjs 开始,检查相对于 package.json scope 重写,packages//dist/ 是如何生成的。使用提供的 npm install 和动态导入进行复现,然后检查 dist/index.js 和 dist/index.d.ts 中是否还存在 @agentscript/ 引用。完成标准是已安装的软件包能够解析其 @sf-agentscript/* 依赖,并且可以调用 parse 导出。
由索引模型根据 Issue 内容生成。
描述
Summary
Installing the published npm package @sf-agentscript/agentforce@2.5.31 and importing it throws ERR_MODULE_NOT_FOUND: Cannot find package '@agentscript/parser' at runtime. The package on npm is currently unusable end-to-end.
Root cause
scripts/publish.mjs rewrites @agentscript/* → @sf-agentscript/* in package.json files only (lines 14–15, 28–29). The compiled JS in packages/*/dist/ is built before this rewrite step, so the compiled output still contains literal import specifiers like:
import { parseAndHighlight } from "@agentscript/parser";
When npm installs @sf-agentscript/agentforce, dependency resolution correctly places the dep at node_modules/@sf-agentscript/parser (because the rewritten package.json lists it under that name). But the runtime code still asks for @agentscript/parser, so Node throws ERR_MODULE_NOT_FOUND.
The same issue affects the JSDoc @example blocks in dist/index.d.ts (cosmetic, but inconsistent).
Reproduction
mkdir /tmp/repro && cd /tmp/repro
npm init -y
node -e "let p=require('./package.json');p.type='module';require('fs').writeFileSync('package.json',JSON.stringify(p,null,2))"
npm install @sf-agentscript/agentforce
node --input-type=module -e "import('@sf-agentscript/agentforce').then(m => console.log(typeof m.parse))"
Actual output:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@agentscript/parser' imported from
/tmp/repro/node_modules/@sf-agentscript/agentforce/dist/index.js
Expected: function (the parse export is callable).
Evidence
node_modules/@sf-agentscript/agentforce/package.jsoncorrectly lists"@sf-agentscript/parser": "4.0.0"✅node_modules/@sf-agentscript/agentforce/dist/index.jsline ~3 readsimport { ... } from "@agentscript/parser"❌node_modules/@sf-agentscript/agentforce/dist/index.d.tsJSDoc@exampleblocks reference'@agentscript/agentforce'(cosmetic, lower priority)
grep -rE "from '(@agentscript|@sf-agentscript)" node_modules/@sf-agentscript/agentforce/dist/ confirms every cross-package import in dist/ uses the un-rewritten @agentscript/* scope.
Possible fixes
- Rewrite dist after build, before publish. Add a step to
scripts/publish.mjsthat walkspackages/*/dist/**/*.{js,mjs,cjs,d.ts,d.mts,map}and applies the same@agentscript/→@sf-agentscript/string replace. ~20 lines. Lowest blast radius. - Build after rewrite. Reorder publish steps so package.json rewrite happens before
pnpm build, then build emits the new scope. But TypeScript doesn't transform import specifiers, so this alone wouldn't help — sources still sayfrom '@agentscript/parser'. Would also require source rewrites or a tsconfig path alias. - Bundler alias / path mapping during publish builds. More invasive, requires per-package config changes.
Option 1 is the smallest, safest, and most localized change. I have a draft patch ready and am happy to send a PR if this approach is acceptable.
Related
- #6 — the install command in the README was wrong; the README fix is in #34. This issue is the runtime half of the same end-to-end user journey.
- This is also why PR #23's
installation.mdtroubleshooting note describes the npm visibility error: users hitting the install-side bug never get to discover the runtime-side bug.
Environment
- Node v20.14.0 (also reproduced on v22)
- npm 10.7.0
- macOS arm64
- Package:
@sf-agentscript/agentforce@2.5.31(current latest on npm at time of report)
- 主要语言
- TypeScript
- 星标
- 267
- 派生
- 54
- 平均合并
- 48 分钟
- 30 天内合并 PR
- 1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
salesforce/agentscript 的其他 Issue
-
README Quick Start fails on macOS: Node 26 incompatibility and missing tree-sitter CLI prerequisite 未关闭
难度 2/5 半天 新手友好度 75/100
salesforce/agentscript#33 · 2 条评论 ·
-
难度 4/5 3-5 天 新手友好度 52/100
salesforce/agentscript#73 ·
-
难度 3/5 1-2 天 新手友好度 55/100
salesforce/agentscript#71 · 1 条评论 ·
-
bug
难度 3/5 1-2 天 新手友好度 35/100
salesforce/agentscript#67 ·
-
难度 3/5 1-2 天 新手友好度 52/100
salesforce/agentscript#42 · 1 条评论 ·
查看 salesforce/agentscript 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
mksglu/context-mode#1200 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
难度 2/5 1-3 小时 新手友好度 75/100
anthropics/claude-code#96687 ·
-
good first issue
难度 1/5 1 小时以内 新手友好度 95/100
AOSSIE-Org/DebateAI#582 · 2 条评论 ·