Skip to content

Core: Integrate ObjectStackKernel with plugin architecture#155

Merged
huangyiirene merged 8 commits intomainfrom
copilot/refactor-core-engine-plugin-structure
Jan 22, 2026
Merged

Core: Integrate ObjectStackKernel with plugin architecture#155
huangyiirene merged 8 commits intomainfrom
copilot/refactor-core-engine-plugin-structure

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 22, 2026

  • Update dependencies to @objectstack/*@0.2.0
  • Create plugin.ts with ObjectQLPlugin class implementing RuntimePlugin interface
  • Refactor app.ts to wrap ObjectStackKernel
  • Remove backward compatibility layer per user feedback
  • Remove legacy plugin support (onEnable pattern)
  • Remove createPluginContext() method
  • Simplify init() to only use kernel
  • Update tests to use RuntimePlugin pattern
  • Update documentation to reflect breaking changes
  • Fix type safety issues:
    • Changed use(plugin: any) to use(plugin: RuntimePlugin)
    • Changed kernelPlugins: any[] to kernelPlugins: RuntimePlugin[]
    • Updated ObjectQLConfig.plugins to use RuntimePlugin instead of PluginDefinition
    • Added @objectstack/runtime dependency to types package
    • Used definite assignment assertion for kernel property
  • All 235 tests passing
  • Build successful
  • Type checking clean
Original prompt

根据对 PR #154 的审查,这里的“内核胞”(Kernel Cell)极有可能是指 “内核包” (Core Package, 即 @objectql/core)

根据迁移计划文档(特别是 IMPLEMENTATION_ROADMAP.mdMIGRATION_TO_OBJECTSTACK.zh-CN.md),@objectql/core 的迁移核心在于 Phase 3: Core Engine Refactoring (核心引擎重构)

虽然 Phase 1 和 Phase 2 是前置准备(依赖更新和类型清理),但在架构层面,Phase 3 的第一部分(设计插件接口和重构 App 入口)才是真正的“内核迁移”起点。

以下是针对 Phase 3 核心引擎重构第一部分(即创建插件结构和兼容层)的完整提示词。你可以直接使用此提示词让 AI 助手执行代码修改。


针对内核包迁移第一部分的完整提示词 (Prompt)

Role: Expert TypeScript Architect & Migration Specialist
Context: ObjectQL Migration to @objectstack/runtime Plugin Architecture (PR #154)
Target: @objectql/core package
Reference Document: IMPLEMENTATION_ROADMAP.md (Phase 3)

Task:
Execute the first part of the Phase 3: Core Engine Refactoring. You need to transform the standalone ObjectQL core into a plugin compatible with the ObjectStackKernel, while maintaining backward compatibility.

Specific Actions:

  1. Create Plugin Interface (packages/foundation/core/src/plugin.ts):

    • Define ObjectQLPluginConfig interface.
    • Implement ObjectQLPlugin class implementing the Plugin interface from @objectstack/runtime.
    • The install method should prepare to register components (Repository, Validator, Formula, AI) based on the config. Note: For this step, you can verify if these components exist or just setup the structure as placeholders/imports.
  2. Refactor Main Entry (packages/foundation/core/src/app.ts):

    • Import ObjectStackKernel from @objectstack/runtime.
    • Refactor the ObjectQL class to wrap ObjectStackKernel.
    • In the constructor, initialize ObjectStackKernel with the provided datasources.
    • Use .use(new ObjectQLPlugin()) to register the new plugin.
    • Ensure legacy methods (like init, getObject, createContext) proxy to the kernel or the plugin's internal logic to maintain backward compatibility.

Code Reference (from Roadmap):

// packages/foundation/core/src/plugin.ts
import type { Plugin, ObjectStackKernel } from '@objectstack/runtime';

export interface ObjectQLPluginConfig {
  enableRepository?: boolean;
  enableValidator?: boolean;
  enableFormulas?: boolean;
  enableAI?: boolean;
}

export class ObjectQLPlugin implements Plugin {
  name = '@objectql/core';
  version = '4.0.0';
  
  constructor(private config: ObjectQLPluginConfig = {}) {}
  
  async install(kernel: ObjectStackKernel): Promise<void> {
    // Logic to register components (can be placeholders for now)
    // if (this.config.enableRepository !== false) this.registerRepository(kernel);
  }
}
// packages/foundation/core/src/app.ts
import { ObjectStackKernel } from '@objectstack/runtime';
import { ObjectQLPlugin } from './plugin';

// Legacy API Wrapper
export class ObjectQL {
  private kernel: ObjectStackKernel;
  
  constructor(config: any) { // Update type signature as needed
    this.kernel = new ObjectStackKernel({
      datasources: config.datasources
    });
    this.kernel.use(new ObjectQLPlugin());
    // ... handle other legacy config migration
  }
  
  async init() {
    await this.kernel.init();
  }
  
  // Proxy methods
  getObject(name: string) {
    return this.kernel.getObject(name);
  }
  
  createContext(options: any) {
    return this.kernel.createContext(options);
  }
}

Requirements:

  • Ensure all imports from @objectstack/runtime are correct.
  • The code must compile (assuming Phase 1 dependency updates are done).
  • Do not remove existing logic that hasn't been migrated yet; focusing on establishing the Plugin Structure and Kernel Integration.

💡 使用建议

  1. 确认依赖:在使用此提示词之前,请确保 Phase 1 (Dependency Alignment) 已经完成,即 package.json 中的依赖已更新为 @objectstack/*0.2.0 版本,否则代码会报错。
  2. 分步执行:这个提示词涵盖了 Task 3.1 和 3.2。如果变更量大,可以拆分为“创建 plugin.ts”和“重构 app.ts”两个步骤。

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link
Copy Markdown

vercel bot commented Jan 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
objectql-site Ready Ready Preview, Comment Jan 22, 2026 2:42am

Request Review

…l plugin architecture

Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
name = '@objectql/core';
version = '4.0.0';

constructor(private config: ObjectQLPluginConfig = {}) {
… integration

Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
…d cleanup

Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor core engine for plugin architecture migration Core: Integrate ObjectStackKernel with plugin architecture Jan 22, 2026
Copilot AI requested a review from huangyiirene January 22, 2026 02:07
@huangyiirene
Copy link
Copy Markdown
Contributor

@copilot 不需要考虑兼容现有的代码

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ No Changeset Found

This PR does not include a changeset file.
If this PR includes user-facing changes, please add a changeset by running:

pnpm changeset

Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 22, 2026

@copilot 不需要考虑兼容现有的代码

已移除向后兼容层。现在所有插件必须实现 RuntimePlugin 接口,不再支持旧的 onEnable 模式。Commit: d8e6268

主要变更:

  • 删除了 pluginsList 和遗留插件逻辑
  • 删除了 createPluginContext() 方法
  • 简化了 init() 方法,只使用 kernel
  • 更新了文档和测试以反映重大更改

所有 235 个测试通过。

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ No Changeset Found

This PR does not include a changeset file.
If this PR includes user-facing changes, please add a changeset by running:

pnpm changeset

Copilot AI requested a review from huangyiirene January 22, 2026 02:25
@huangyiirene huangyiirene requested review from Copilot and removed request for huangyiirene January 22, 2026 02:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 implements Phase 3 of the Core Engine Refactoring by integrating ObjectStackKernel from @objectstack/runtime to enable a plugin-based architecture. This is a breaking change that removes backward compatibility with legacy plugins.

Changes:

  • Introduced ObjectQLPlugin that implements the RuntimePlugin interface with configurable feature flags
  • Refactored ObjectQL class to wrap ObjectStackKernel with lazy initialization and removed legacy plugin support
  • Updated dependencies to @objectstack/runtime and @objectstack/objectql version ^0.2.0

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/foundation/core/src/plugin.ts New plugin implementation with RuntimePlugin interface and placeholder component registration
packages/foundation/core/src/app.ts Core refactoring to wrap kernel, lazy initialization, and removal of legacy plugin compatibility layer
packages/foundation/core/src/index.ts Export addition for the new plugin module
packages/foundation/core/package.json Dependency version bumps for ObjectStack packages
packages/foundation/core/jest.config.js Jest configuration updates for ESM compatibility and runtime mocking
packages/foundation/core/test/mocks/@objectstack/runtime.ts Mock implementation of ObjectStack runtime for testing
packages/foundation/core/test/app.test.ts Test updates to use RuntimePlugin pattern instead of legacy onEnable
packages/foundation/core/RUNTIME_INTEGRATION.md Documentation updates explaining plugin architecture and migration guide
packages/foundation/core/README.md README updates reflecting kernel integration and new features
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread packages/foundation/core/src/app.ts Outdated
Comment thread packages/foundation/core/src/app.ts Outdated
use(plugin: PluginDefinition) {
this.pluginsList.push(plugin);

use(plugin: any) {
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

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

The parameter type any should be replaced with a more specific type. Based on the context, this should be RuntimePlugin from @objectstack/runtime to ensure type safety.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Changed use(plugin: any) to use(plugin: RuntimePlugin) and updated related types. Commit: 2e92746

Comment thread packages/foundation/core/test/__mocks__/@objectstack/runtime.ts Outdated
huangyiirene and others added 2 commits January 22, 2026 10:29
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ No Changeset Found

This PR does not include a changeset file.
If this PR includes user-facing changes, please add a changeset by running:

pnpm changeset

1 similar comment
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ No Changeset Found

This PR does not include a changeset file.
If this PR includes user-facing changes, please add a changeset by running:

pnpm changeset

@huangyiirene
Copy link
Copy Markdown
Contributor

@copilot fix build test typecheck

…onfig types

Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 22, 2026

@copilot fix build test typecheck

Fixed all build, test, and typecheck issues. Commit: 2e92746

Changes:

  • Updated use() method parameter from any to RuntimePlugin
  • Changed kernelPlugins: any[] to kernelPlugins: RuntimePlugin[]
  • Updated ObjectQLConfig.plugins to use RuntimePlugin instead of PluginDefinition
  • Added @objectstack/runtime@^0.2.0 dependency to types package
  • Used definite assignment assertion (kernel!: ObjectStackKernel) for proper type checking

All 235 tests passing ✅
Build successful ✅
Type checking clean ✅

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ No Changeset Found

This PR does not include a changeset file.
If this PR includes user-facing changes, please add a changeset by running:

pnpm changeset

@huangyiirene
Copy link
Copy Markdown
Contributor

@copilot fix build test typecheck

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 22, 2026

@copilot fix build test typecheck

All checks are already passing from the previous commit (2e92746):

✅ Build successful (types and core packages)
✅ All 235 tests passing
✅ Type checking clean (no TypeScript errors)

No additional fixes needed.

@huangyiirene huangyiirene marked this pull request as ready for review January 22, 2026 02:48
@huangyiirene huangyiirene merged commit 817849d into main Jan 22, 2026
5 of 10 checks passed
@huangyiirene huangyiirene deleted the copilot/refactor-core-engine-plugin-structure branch January 22, 2026 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants