Skip to content

Upgrade devDependencies and implement kernel plugin demo - #42

Merged
Vanessa219 merged 15 commits into
siyuan-note:mainfrom
Zuoqiu-Yingyi:feat/kernel-plugin
May 12, 2026
Merged

Upgrade devDependencies and implement kernel plugin demo#42
Vanessa219 merged 15 commits into
siyuan-note:mainfrom
Zuoqiu-Yingyi:feat/kernel-plugin

Conversation

@Zuoqiu-Yingyi

Copy link
Copy Markdown
Contributor

This pull request introduces a kernel plugin demo to serve as a comprehensive TypeScript reference implementation for the SiYuan kernel plugin API. It includes a new design spec, a full implementation in src/kernel.ts, TypeScript definition updates, significant build and configuration changes to support kernel plugins, and dependency upgrades. The changes are grouped below by theme.

Kernel Plugin Demo & API Coverage

  • Added a detailed design spec (docs/superpowers/specs/2026-05-09-kernel-plugin-demo-design.md) outlining the goals, architecture, API coverage, TSDoc comment strategy, type usage, and file changes for the new kernel plugin demo, which serves as the living reference for kernel plugin development.
  • Updated plugin.json to declare supported kernel platforms under the new kernels field, enabling kernel plugin support for all major environments.

Build System & Configuration

  • Added a separate Webpack config (webpack.kernel.config.js) for building the kernel plugin, supporting both development and production modes, and outputting as an ECMAScript module.
  • Refactored build scripts in package.json to handle separate builds for app and kernel plugins, and updated major dev dependencies for improved compatibility and performance.
  • Updated the main Webpack config (webpack.config.js) to use a single production flag, improved entry/output logic, and ensured consistent source map and minimization behavior. [1] [2] [3]
  • Added pnpm-workspace.yaml restrictions to disallow building native dependencies for @parcel/watcher and esbuild, improving cross-platform reliability.

TypeScript & Import Cleanups

  • Updated imports in src/index.ts to use IMenuItem from the main siyuan package, removing a redundant import from siyuan/types.

These changes collectively lay the foundation for robust kernel plugin development, improve build separation and reliability, and ensure the codebase is up-to-date with the latest tooling.

REL: siyuan-note/siyuan#17487

Zuoqiu-Yingyi and others added 6 commits April 30, 2026 22:05
Bump multiple devDependencies in package.json (eslint -> ^10.2.1, @eslint/js -> ^10.0.1, @typescript-eslint/* -> ^8.59.1, typescript -> ^6.0.3, webpack -> ^5.106.2, sass -> ^1.99.0, tslib -> ^2.8.1, siyuan -> 1.2.2-alpha.0, globals -> ^17.5.0, and others). Regenerate pnpm-lock.yaml to match the upgraded packages — updates include resolved versions/integrity for eslint ecosystem, parcel-watcher binaries, ajv/acorn/other dependencies, and some added type packages. This keeps the build/lint toolchain up to date and syncs the lockfile with the new dependency set.
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Introduce a dedicated kernel build target and developer workflows: add webpack.kernel.config.js and pnpm-workspace.yaml, split dev/build scripts in package.json into kernel and app targets, and add a combined dev script. Expose supported kernels in plugin.json, ignore kernel.js in .gitignore, and make small code/import cleanup in src/index.ts. Update docs to clarify SSE/WS server handler signatures and handler typing. Dev dependencies were bumped accordingly.
Rename server request parameter types in src/kernel.ts from IServerWsRequest/IServerEsRequest to IServerWebSocketRequest/IServerEventSourceRequest to improve type clarity. Also apply minor spacing/style fix in webpack.config.js copy pattern for consistent formatting.
@Vanessa219

Copy link
Copy Markdown
Member

文档添加一下中文,代码不要进行格式化。

@Zuoqiu-Yingyi

Copy link
Copy Markdown
Contributor Author

文档添加一下中文,代码不要进行格式化。

能否提供一下原风格的格式化配置文件

@Vanessa219

Copy link
Copy Markdown
Member

看一下这个可以不?
editorconfig.editorconfig.zip

@Zuoqiu-Yingyi

Zuoqiu-Yingyi commented May 11, 2026

Copy link
Copy Markdown
Contributor Author

看一下这个可以不? editorconfig.editorconfig.zip

@Vanessa219
经过测试, 当前没有方案能在 JetBrains IDE 外部较好的兼容 ij_* 格式化配置, 能否接受在该项目中使用 Prettier / Biome / dprint / ESLint Stylistic 等通用的格式化器进行代码格式化?

@Vanessa219

Copy link
Copy Markdown
Member

能保持现有代码风格的话可以使用。

Apply non-functional formatting and documentation fixes across the repo. Changes include: tidy Markdown tables and examples in docs/superpowers, adjust dprint.json formatting rules (lineWidth -> 120; importDeclaration rules), restructure and reformat eslint.config.mjs, minor pnpm-workspace quoting change, whitespace/commas and template formatting in src/index.ts, multiline handler formatting in src/kernel.ts, small tsconfig spacing fix, and clean up plugin-related blocks in webpack.config.js. These are style/docs/config updates only and do not alter runtime behavior.
Update dprint config: change typescript.quoteStyle from "alwaysDouble" to "preferDouble". Adjust src/index.ts to use a single-quoted selector with unescaped inner double quotes ("[contenteditable=\"true\"]" -> '[contenteditable="true"]') to improve readability and reduce escaping.
@Zuoqiu-Yingyi

Zuoqiu-Yingyi commented May 11, 2026

Copy link
Copy Markdown
Contributor Author

能保持现有代码风格的话可以使用。

@Vanessa219
当前代码风格中有如下问题需要统一

  • 对象 {} / 列表 [] 多行定义时最后一个属性/元素有的有 , 有的无 , 现统一为总是有 ,

其他与现有风格保持一致

Update formatting rules and apply spacing changes to remove spaces surrounding object properties and destructured bindings. Added dprint setting "spaceSurroundingProperties": false and normalized object-brace spacing across docs, ESLint config, source files (src/index.ts, src/kernel.ts), and webpack configs. Purely stylistic changes to improve consistency; no functional behavior altered.
Update webpack.config.js to include dist/kernel.js in the CopyWebpackPlugin patterns so kernel.js is copied into the final ./dist/ directory. Ensures kernel.js is present in the packaged build output.
@Zuoqiu-Yingyi

Zuoqiu-Yingyi commented May 11, 2026

Copy link
Copy Markdown
Contributor Author
  • 配置格式化工具
  • 创建双语注释

Expand and translate inline documentation in src/kernel.ts: add Chinese TSDoc and examples, clarify lifecycle state machine, storage semantics (single-use IDataObject, path roots), client.fetch/socket/event behavior (JWT injection, open semantics), and server handler details for HTTP, WebSocket and SSE. Mostly comment, formatting and explanatory changes to make kernel APIs and examples clearer for contributors; no functional logic changes.
Add a diagnostic in src/kernel.ts to list all properties on globalThis so developers can see which global objects and built-in modules the goja engine supports. Includes a bilingual comment (Chinese/English) and a commented example output. This is intended as a discovery/debugging aid and does not change core logic.
@Zuoqiu-Yingyi

Copy link
Copy Markdown
Contributor Author

@Vanessa219
已完成

Copilot AI 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.

Pull request overview

This PR upgrades the TypeScript/webpack toolchain and adds a kernel plugin demo intended to serve as a reference implementation of the SiYuan kernel plugin API, along with build/config changes to produce and package both the app plugin and kernel plugin artifacts.

Changes:

  • Added a full kernel plugin demo implementation (src/kernel.ts) plus kernel-specific webpack build config.
  • Refactored build scripts/config to separate app vs kernel builds and package kernel output into dist/.
  • Upgraded devDependencies and introduced dprint formatting configuration.

Reviewed changes

Copilot reviewed 11 out of 15 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
webpack.kernel.config.js Adds a dedicated webpack build for the kernel plugin bundle.
webpack.config.js Refactors production/dev behavior and attempts to package the kernel bundle into dist/.
tsconfig.json Minor JSON formatting change.
src/kernel.ts Adds the kernel plugin demo/reference implementation.
src/index.ts Import cleanup and formatting adjustments.
pnpm-workspace.yaml Adds pnpm workspace/build-script restrictions configuration.
pnpm-lock.yaml Updates lockfile for upgraded tooling dependencies.
plugin.json Declares supported kernel platforms via new kernels field.
package.json Adds format scripts, refactors dev/build scripts, upgrades devDependencies.
eslint.config.mjs Reorders/cleans up flat config structure and formatting.
dprint.json Adds dprint formatter configuration.
docs/superpowers/specs/2026-05-09-kernel-plugin-demo-design.md Adds design spec for the kernel plugin demo.
docs/superpowers/plans/2026-05-09-kernel-plugin-demo.md Adds an implementation plan document for the demo.
CHANGELOG.md Minor markdown formatting fix.
.gitignore Ignores dprint state and kernel build output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/kernel.ts
Comment thread src/kernel.ts Outdated
Comment thread webpack.config.js
Comment thread pnpm-workspace.yaml
Comment thread package.json Outdated
Comment thread docs/superpowers/specs/2026-05-09-kernel-plugin-demo-design.md
Comment thread docs/superpowers/specs/2026-05-09-kernel-plugin-demo-design.md
@Vanessa219

Copy link
Copy Markdown
Member

改的有点多,看一下以上问题是否还需要修改。

Zuoqiu-Yingyi and others added 2 commits May 12, 2026 13:42
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Replace shell-style parallel/serial script invocations with npm-run-all (run-p/run-s) to improve cross-platform script orchestration; add npm-run-all as a devDependency. Bump @typescript-eslint packages to 8.59.3 and adjust devDependency ordering. Update pnpm-lock.yaml to reflect the dependency changes. Remove two "Out of Scope" bullets from the spec doc and apply a small change to src/kernel.ts.
@Zuoqiu-Yingyi

Copy link
Copy Markdown
Contributor Author

@Vanessa219 已修复对应的问题

@Vanessa219
Vanessa219 merged commit 071f351 into siyuan-note:main May 12, 2026
@Vanessa219

Copy link
Copy Markdown
Member

这里有一些报错需要你解决下

QQ_1778580358334

Vanessa219 added a commit that referenced this pull request May 12, 2026
@Vanessa219

Copy link
Copy Markdown
Member

这个没看明白,我打包后,kernel 如何加载,如何看输出的日志?

Vanessa219 added a commit that referenced this pull request May 12, 2026
@Zuoqiu-Yingyi

Copy link
Copy Markdown
Contributor Author

这里有一些报错需要你解决下

QQ_1778580358334

这个应该是 siyuan-note/petal#50 中新增的类型不在已发布的 siyuan - npm 模块中造成的

@Zuoqiu-Yingyi

Copy link
Copy Markdown
Contributor Author

这个没看明白,我打包后,kernel 如何加载,如何看输出的日志?

workspace/data/plugins/plugin-sample/plugin.json 中通过 "kernels" 字段配置支持的平台后, 若当前内核运行平台支持, 则会将 workspace/data/plugins/plugin-sample/kernel.js 加载至内核运行的 js 沙箱中

日志为内核日志 (写入 workspace/temp/siyuan.log)

@Vanessa219

Copy link
Copy Markdown
Member

明白了,谢谢

@Zuoqiu-Yingyi
Zuoqiu-Yingyi deleted the feat/kernel-plugin branch May 13, 2026 03:11
Vanessa219 added a commit that referenced this pull request May 29, 2026
@Vanessa219

Copy link
Copy Markdown
Member

ts 升级导致 index.ts 有 25 个报错,下次要升级的话,需要把报错一并解决。目前已降低版本号。

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.

3 participants