Skip to content

fix(core): 修复 censor 的模块导入路径 - #1056

Merged
dingyi222666 merged 2 commits into
ChatLunaLab:v1-devfrom
Procyon-Nan:fix/censor-import-path
Oct 13, 2026
Merged

dingyi222666 merged 2 commits into
ChatLunaLab:v1-devfrom
Procyon-Nan:fix/censor-import-path

Conversation

@Procyon-Nan

@Procyon-Nan Procyon-Nan commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

问题与修复

Close #1055

censor 中的相对导入在打包进 CommonJS 入口后被保留,导致启动时报 Cannot find module '../../utils/langchain',core 无法加载。将 isMessageContentText 的导入改为 koishi-plugin-chatluna/utils/langchain,通过包导出解析正确的构建产物

验证

  • ESLint 和 Git diff 检查通过。
  • yarn fast-build core 通过。
  • 构建后的 core CommonJS 入口加载成功。

将 censor.ts 中的 isMessageContentText 导入改为包导出路径,修复 CommonJS 构建后相对路径失效导致 core 无法加载的问题。
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • packages/core/package.json is excluded by !**/*.json

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 06728d1e-c921-4474-99cd-a5a16820a648

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 87543dfd-ed5c-4563-9871-7f3b53992c9b
📥 Commits

Reviewing files that changed from the base of the PR and between ab69070 and 4ebd593.

📒 Files selected for processing (1)
  • packages/core/src/middlewares/chat/censor.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

Walkthrough

聊天审查中间件现在从 koishi-plugin-chatluna/utils/langchain 导入 isMessageContentText。没有导出的公共声明变更。

Changes

聊天审查导入调整

Layer / File(s) Summary
更新工具导入路径
packages/core/src/middlewares/chat/censor.ts
isMessageContentText 改为从 koishi-plugin-chatluna/utils/langchain 导入。

Priority: ➖ Normal

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Suggested reviewers: hoshino-yumetsuki

Merge Risk: ⚪ Minimal · up to 4ebd5

The new import resolves through the declared package subpath, so no build or startup blocker is established and the change is ready to merge.

Pre-merge checks · Passed 4 · Failed 1

Failed Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed 描述准确说明了 CommonJS 构建中的模块导入问题、修复方式和验证结果,与变更内容直接相关。
Title check Passed 标题明确概括了将 censor 的模块导入路径改为正确路径这一主要变更。
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

兔子轻敲键盘边,
导入路径换新篇。
中间件里工具到,
月光落在代码间。
胡萝卜香伴绿叶,
改动简短笑开颜。

Comment @coderabbitai help to get the list of available commands.

Bump koishi-plugin-chatluna from 1.4.1 to 1.4.2 so the censor middleware
import path fix in this branch can be published to npm.

Verified with `yarn fast-build` (exit 0).
@dingyi222666
dingyi222666 merged commit 9ae242f into ChatLunaLab:v1-dev Oct 13, 2026
5 checks passed
@Procyon-Nan
Procyon-Nan deleted the fix/censor-import-path branch October 13, 2026 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1.4.1 CJS 产物 lib/index.cjs 里残留源码相对路径 require("../../utils/langchain"),导致插件加载失败(Cannot find module)

2 participants