Skip to content

trivia - #14

Merged
xiaoland merged 1 commit into
claude/extension-manager-lifecycle-uBXisfrom
claude/add-client-federation-RNIkY
Dec 31, 2025
Merged

trivia#14
xiaoland merged 1 commit into
claude/extension-manager-lifecycle-uBXisfrom
claude/add-client-federation-RNIkY

Conversation

@xiaoland

Copy link
Copy Markdown
Member

No description provided.

1. 实现 Module Federation 实际加载逻辑
   - 使用动态 script 标签加载远程入口
   - 支持动态 import 导入远程模块
   - 实现 loadRemoteEntry 方法

2. 添加 Client 模型 (src/business/client.ts)
   - 使用 zod-class 定义客户端模型
   - 支持 ping 检查在线状态
   - 支持向远程客户端发送请求
   - 实现 enableExtension/disableExtension 远程调用

3. 完善配置管理 (src/config.ts)
   - 添加 zod schema 验证
   - 实现 localStorage 持久化
   - 添加 LOCAL_CLIENT_ID 字段
   - 提供 configUtils 工具函数

4. 扩展 ExtensionManager 功能
   - 添加 enableExtensionForClient 方法
   - 添加 disableExtensionForClient 方法
   - 自动判断本地/远程客户端并调用相应逻辑

系统设计:
- 所有节点平等,无"后端"概念
- 本地客户端 ID 存储在 localStorage
- 支持联邦化的插件管理
@xiaoland
xiaoland changed the base branch from main to claude/extension-manager-lifecycle-uBXis December 31, 2025 01:53
@xiaoland
xiaoland merged commit e5856ec into claude/extension-manager-lifecycle-uBXis Dec 31, 2025
2 checks passed
@xiaoland
xiaoland deleted the claude/add-client-federation-RNIkY branch December 31, 2025 01:55
xiaoland added a commit that referenced this pull request Jul 24, 2026
* trivia

* make deployable to Cloudflare Worker
- initially introduced Dynamic Federation

* temp

* prepare for impl new business layer

* add openapi json

* simplify stores and add auth store

* impl business layer initially

* sync work

* sync work

* sync work

* add component inkHeader

* rm env file

* initially imple extensions management

* feat: add scss design tokens and unocss setup

* include .vscode/code-snippet, tasks, add launch example

* upd(inkHeader): add page mode

* config launch in VSCode and remove tasks.json

* Add design system usage guide

* Remove legacy design token aliases

* Initial plan

* Add i18n support with vue-i18n and settings view

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Improve i18n implementation based on code review feedback

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Split token maps into ref and semantic files

* Refine token structure and typography layer

* Add data-theme handling to design system entry

* Use direct token maps for reference and semantic layers

* Move design-system SCSS under styles

* Flatten styles entrypoint

* move i18n.ts to locales/index.ts

* upd(inkHeader): add mode `section`

* make an initial style migration (no build error)

* Initial plan

* Initial exploration: understand new style system

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Refactor all views to use new design token system

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Remove test file

* continue migrating style system

* move inkHeader to common/inkHeader

* Add InkButton component and replace buttons in shared components (#8)

* Add InkButton component and replace buttons in components

* Align InkButton with design tokens

* Use forwarded sys-var helper in InkButton styles

* trivias

* upd(.vscode): shutdown dev server more gracefully

* use Vite additionalData to remove manual common sass use; introduce @inkcre/web-design

* restart and implement start view, add docs

* initially implement sources view (createSource, sourceCard) and a series of common form components

* implement createSource to call real API

* trivia fixes and sourceCard delete, edit collectAt works

* upd(source): collectAtForm does not handle null case

* impl(sourceCard): run now

* Initial plan

* Add InkDoubleCheck component and apply to SourceCard delete, fix import case issues

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Remove unused useI18n import and fix documentation punctuation

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* fix(doubleCheck): style import

* upd(collectAt): both weekday and hour can be null

* add(extension): initially added extensions view, extensionCard, installExtension

* upd(form): impl `required` prop

* upd(extensions): make installExtension inline; toggle extension do not refetch

* upd(InkSwitch): add loading state; fix(extensions): trivias

* add: InkLoading, apply to views/extensions, sources

* upd(InkInput): add type `inline` and apply to sourceCard nickname editing

* attempt to use common components from `@inkcre/web-design`

* trivias

* fix: @inkcre/web-design linking locally

* add .npmrc for inkcre org package registry

* Initial plan

* Update all imports to use @inkcre/web-design package

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Delete migrated common components and fix remaining imports

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Remove redundant type assertion from sourceCard formatter

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* upd(extension): edit config with JSON schema lint, auto-complete support and use inkDialog

* fix(httpApiClient): infer content-type

* fix(App): use inkHeader correctly to load page title automatically

* trivias

* fix(business): DBApiClient extends postgrest-js in a wrong way

* upd(source): config edit with JSON schema support

* Add collect job detail view with metadata and state management (#11)

* Initial plan

* Add collectJob view with metadata and state sections

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Fix code review issues: move watch import and improve null handling

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Improve error handling and remove redundant lifecycle hooks

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* upd(sources): add logs section to source collect job initially

* upd: implement logsViewer and sourceCollectJob view

* fix(logsViewer): log polling not work

* trivias(sourceCollectJob)

* fix(logsViewer): auto scroll to bottom

* Add source detail view with collect jobs list and enhance SourceCard navigation (#12)

* Initial plan

* Add source detail view and update SourceCard with running job link

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Make SourceCard clickable to navigate to detail view and add Chinese translations

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Fix router order to prevent route matching issues

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Address code review feedback: use absolute imports, add i18n, improve error handling

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Rename newCollectJob to collectJobForm, add config field, extract sourceForm component

- Renamed newCollectJob component to collectJobForm
- Updated collectJobForm to be a pure form component with config field support
- Added config field to SourceCollectJob
- Created sourceForm component extracted from createSource
- Updated createSource to use sourceForm
- Updated source detail view to use sourceForm with inline editing and save button
- Used shallow: true for latestRunningJob in sourceCard
- Added create button to new job popup

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Fix code review issues: add config field, remove redundant handler, add error handling

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Extract sourceCollectJobCard component and rename latestRunningJob to latestOpenJob

- Created sourceCollectJobCard component for displaying job items
- Renamed getLatestRunningBySource to getLatestOpenBySource
- Updated method to include both PENDING and RUNNING statuses
- Updated all references from latestRunningJob to latestOpenJob
- Removed inline job-item styles in favor of component

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* trivias fixes on sourceForm, collectJobForm

* chore(sourceCard): checkRunningJob -> checkOpenJob

* upd(sourceCollectJob): add refresh-indicator

* trivias

* chore: update agent docs

* try fix copilot-setup-steps.yml

* try fix copilot-setup-steps.yml

* add pnpm-lock.yaml

* rm pnpm-lock

* try fix

* try fix

* Update copilot-setup-steps.yml

* Update .npmrc

* Update copilot-setup-steps.yml

* Update copilot-setup-steps.yml

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>
Co-authored-by: Lanzhijiang <lanzhijiang@foxmail.com>

* fix(i18n): vite dynamic load warning

* fix: @inkcre/web-design inkButton breaking change

* upd(source): job list uses InkPagination

* ref: source is at the same level with info-base

* add(info-base): graph initally

* fix(info-base): graph's block overlayed

* fix(info-base) graph edge invisible

* upd(info-base): somehow beautify the graph ...

* start over of info-base graph

* impl of info-graph with vue-flow

* ref(info-base-graph): re-impl with vue-flow and view by communities (initially).

* fix(info-graph): some warnings, styles and use InkDropdown with stepping and search

* fix(info-graph): edge don't have arrow at the end

* ref: utils/graph -> business/info-base/graph

* upd(info-base-graph): add multiple layout support (auto-layout also)

* fix(info-base-graph): all communites layout; show minimap on need

* upd(info-graph): use MSD layout for "All Communites"

* add: resolver, storage system, and integrate into graph

* upd(info-base-graph): revert multiple layout; fix relation edge overlaped

* improve resolver system and initially implement twitter extension

* 实现 ExtensionManager 和插件生命周期管理

主要更改:

1. 数据库表结构更新 (extension.ts)
   - 将 disabled (boolean) 字段改为 enabled (uuid array)
   - 每个客户端可以独立启用/禁用插件
   - 添加 isEnabledForClient() 方法检查插件是否对特定客户端启用

2. ExtensionManager 核心实现 (extensionManager.ts)
   - 完整的插件生命周期状态机:
     DISCOVERED → LOADING → LOADED → INITIALIZING → READY → ACTIVATING → ACTIVE
     支持 DEACTIVATING → READY 和 UNLOADING → UNLOADED 转换
     任何阶段可进入 ERROR 状态,支持重试机制
   - 插件接口定义 (IExtension):initialize, activate, deactivate, dispose
   - ExtensionInstance 类:管理单个插件实例的状态和错误
   - ExtensionManager 类:
     * 从数据库发现插件
     * 并行加载插件(使用 Promise.allSettled 实现错误隔离)
     * 动态启用/禁用插件
     * 完整的 startup/shutdown 流程
     * 重试机制(最多3次)

3. UI 组件更新
   - ExtensionCard 组件:
     * 添加 clientId prop
     * 更新 toggle 逻辑使用新的 enable/disable 方法
     * 根据 clientId 显示正确的启用状态
   - Extensions View:
     * 添加客户端选择下拉框
     * 从所有插件的 enabled 数组中提取可用的客户端 ID
     * 根据选择的客户端过滤和显示插件状态
   - 样式更新:为客户端选择器添加响应式布局

特性:
- 并行加载:使用 Promise.allSettled 同时加载多个插件
- 错误隔离:单个插件失败不影响其他插件
- 状态追踪:详细的日志记录每个状态转换
- 灵活配置:每个客户端独立的插件配置

* 添加 Client 模型和完善 ExtensionManager (#14)

1. 实现 Module Federation 实际加载逻辑
   - 使用动态 script 标签加载远程入口
   - 支持动态 import 导入远程模块
   - 实现 loadRemoteEntry 方法

2. 添加 Client 模型 (src/business/client.ts)
   - 使用 zod-class 定义客户端模型
   - 支持 ping 检查在线状态
   - 支持向远程客户端发送请求
   - 实现 enableExtension/disableExtension 远程调用

3. 完善配置管理 (src/config.ts)
   - 添加 zod schema 验证
   - 实现 localStorage 持久化
   - 添加 LOCAL_CLIENT_ID 字段
   - 提供 configUtils 工具函数

4. 扩展 ExtensionManager 功能
   - 添加 enableExtensionForClient 方法
   - 添加 disableExtensionForClient 方法
   - 自动判断本地/远程客户端并调用相应逻辑

系统设计:
- 所有节点平等,无"后端"概念
- 本地客户端 ID 存储在 localStorage
- 支持联邦化的插件管理

Co-authored-by: Claude <noreply@anthropic.com>

* Sync work, includes extension, resolver, settings

* remove config.configUtils

* sync changes of setting

* Refactor config.ts with proper zod-config usage, Vue reactive pattern, and separate persistence (#15)

* Initial plan

* Refactor config.ts with proper types and singleton pattern

- Added missing types: AdapterType, ConfigAdapter interface
- Implemented ConfigAdapter interface with save() method for both localStorage and HTTP
- Created proper singleton pattern using Proxy for CONFIG access
- Removed redundant saveToLocalStorage and saveToHttp functions
- Added adapters map to configManager
- Improved error handling and initialization logic
- Fixed missing _currentAdapterType and adapters variables

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Update settings view to use configManager.getConfig() instead of direct CONFIG access

- Removed unused CONFIG import from settings.vue
- Updated all CONFIG access to use configManager.getConfig()
- Initialize formConfig with configManager.getConfig()
- Improved config initialization to use defaults immediately

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Fix config.ts to properly use zod-config design

- Remove custom ConfigAdapter interface (incorrect extension of zod-config)
- Use standard Adapter type from zod-config for read operations only
- Separate save functions from adapters (zod-config is for loading, not saving)
- Create saveFunctions map to handle persistence separately
- Remove adapters property from configManager export
- Update getCurrentAdapter() to return Adapter instead of custom ConfigAdapter
- Clarify comments to indicate adapters are read-only per zod-config design

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* Refactor CONFIG to use Vue reactive and export ADAPTERS

- Changed CONFIG from Proxy-based singleton to Vue reactive object
- Initialize CONFIG with ConfigSchema.parse({}) for cleaner defaults
- Export ADAPTERS as Record<AdapterType, Adapter> for external access
- Update all config operations to use Object.assign with reactive CONFIG
- Remove internal _config variable and Proxy wrapper
- Simplified default value initialization using empty object parse

Co-authored-by: xiaoland <37663413+xiaoland@users.noreply.github.com>

* fix config

* fix(resolver): add dispose hook

* upd: add clientList and self registry

* fix(extension): extension card toggle not follows client selection

* update ARCH docs

* save work of extension development

* simplify ARCHITECTURE.md

* refactor into monorepo (initially)

* joint dev extensions with client-web first success

* completely migrated package core, and make client-web, client-webext, extension uses it.

* refactor(core): config based on pinia; core provide global singleton of store

* ref(core): consolidate protocols into info-base, extension

* ref(core): merge ResolverManager into Resolver

* finally, somehow fix the @InKCre/core package sharing in mf

* cleanup

* Add refactoring plan for packages/core restructuring

Create detailed plan for reorganizing packages/core into domain-driven structure:
- Analyzed current structure (41 files, ~4,500 lines)
- Mapped all files to new structure (base/, extension/, client/, obsrc/, info-base/, sink/, auth/, config/, utils/, libs/ai/)
- Defined 14-phase incremental refactoring approach
- Documented risk mitigation and backwards compatibility strategy
- Preserved expected behaviors: Vue coupling, singletons, Active Record pattern

* Update refactoring plan with ruthless evolution approach

Key changes to the plan:
- Remove all backwards compatibility (delete models/ and api/ directories)
- Consolidate CoreAPIClient into DBAPIClient for unified API layer
- Fix directory naming: source/ for data collection, obsrv/ for observability
- Add Prettier and ESLint for automated code quality verification
- Define 14 phases with complete automation and verification
- Breaking changes: all old import paths will break for clean evolution

* refactor(core): ruthless evolution - complete restructuring

Complete domain-driven refactoring of packages/core with zero backwards compatibility:

**Breaking Changes:**
- ❌ NO backwards compatibility - all old import paths will break
- 🔄 Consolidated CoreAPIClient into DBAPIClient
- 📦 Deleted models/ and api/ directories
- 🧹 Automated code quality with Prettier + ESLint

**New Structure:**
- src/base/db-api.ts - Unified API client (PostgREST + custom endpoints)
- src/client/ - Client peer management
- src/source/ - Data collection sources (Source, SourceType, CollectJob, CollectAt)
- src/obsrv/ - Observability (o11y) - Log model
- src/info-base/ - Information base (blocks, relations, resolvers, storages)
- src/sink/ - Output formatters (graph visualization)
- src/extension/ - Extension system (Module Federation, lifecycle)
- src/auth/ - Authentication (JWT)
- src/config/ - Configuration management
- src/utils/ - Utilities (vue-props, zinstance)
- src/libs/ai/ - AI provider integration (placeholder)

**Code Quality:**
- ✅ Prettier formatting (no semicolons, single quotes, 100 char width)
- ✅ ESLint v9 with TypeScript rules
- ✅ Build verified (zero errors)
- ✅ All singletons preserved (configStore, authStore, static dbApi)
- ✅ Vue integration intact (Pinia, reactive state, Vue Flow)
- ✅ Active Record pattern maintained

**API Client Consolidation:**
- Merged CoreAPIClient functionality into DBAPIClient
- Single unified client with both PostgREST (.from(), .rpc()) and custom endpoints (.get(), .post(), .request())
- Simplified initialization in models (no more separate coreApi)

**File Movements:**
- api/ → base/db-api.ts (consolidated)
- models/block.ts → info-base/block.ts
- models/relation.ts → info-base/relation.ts
- models/storage.ts → info-base/storage-model.ts
- models/client.ts → client/client.ts
- models/source.ts → source/ (split into 4 files)
- models/log.ts → obsrv/log.ts
- sinks/ → sink/ (renamed to singular)
- base.ts → utils/zinstance.ts

**Phases Completed:**
1. ✅ Code quality setup (Prettier + ESLint)
2. ✅ Directory structure creation
3. ✅ API client consolidation
4. ✅ Utils domain migration
5. ✅ Auth & config domains
6. ✅ Client domain migration
7. ✅ Source domain (1 file → 4 files)
8. ✅ Observability domain
9. ✅ Info-base domain
10. ✅ Extension domain updates
11. ✅ Sink domain (renamed)
12. ✅ Main entry point update
13. ✅ Old directory cleanup

Total: ~4,500 lines refactored across 41+ TypeScript files

* refactor(core): consolidate storage and extension modules

Three major consolidations for cleaner architecture:

1. Storage consolidation:
   - Merged info-base/storage-model.ts into info-base/storages/base.ts
   - Combined Storage protocol class with StorageType model
   - Removed @Storage.registry decorator pattern
   - Replaced with explicit Storage.register() calls
   - Fixed type signatures to accept Storage subclasses

2. Extension consolidation:
   - Renamed extension/model.ts to extension/base.ts
   - Merged extension/extension.ts into extension/base.ts
   - Renamed IExtension interface to ExtensionModule
   - Combined lifecycle states, module interface, and Extension model

3. Code quality improvements:
   - Fixed all ESLint errors (0 errors, 93 warnings)
   - Ran Prettier formatting
   - Fixed unused imports (ConfigAdapter, BlockRef)
   - Updated all import paths across codebase

Net result: -608 lines of code while maintaining full functionality

* refactor(core): merge CoreAPIClient into Client active record

Critical architectural correction: CoreAPIClient functionality now lives
in the Client active record, requiring Client instantiation for API requests.

Changes:
1. Client active record enhancements:
   - Added full HTTP request capabilities (request, get, post, put, patch, delete)
   - Added Client.getSelf() to get the configured core client (INKCRE_CLIENT_ID)
   - Supports JSON body, FormData, Blob, query parameters
   - Automatic authentication and token refresh on 401 errors
   - Schema-based response parsing
   - Complete APIError integration

2. DBAPIClient simplified to pure PostgREST:
   - Removed all Core API methods (request, get, post, put, patch, delete)
   - Removed coreBaseURL, pathPrefix, and Core API watching
   - Now purely wraps PostgREST operations (.from(), .rpc())
   - Maintains auth token injection for database operations

3. Migration of all usages:
   - Extension.coreApi removed (was static DBAPIClient instance)
   - InstallExtensionForm.install() now uses Client.getSelf()
   - Removed CoreAPIClient export (no longer exists)

Pattern for Core API requests:
```typescript
// Before: Extension.coreApi.post('/path', body)
// After:
const client = await Client.getSelf()
await client.post('/extensions/path', body)
```

Net result: -48 lines while improving architecture
- DBAPIClient: Pure PostgREST database operations only
- Client: Active record with full HTTP request capabilities

* trivias

* update todo

* Update documentation and agent configuration files (#16)

* docs: refresh AGENTS.md and add ARCHITECTURE.md, FILESYSTEM.md

- Update root AGENTS.md with concise monorepo overview
- Add ARCHITECTURE.md with system layers and patterns
- Add FILESYSTEM.md with directory structure guide
- Add .agents/README.md as index for agent resources
- Update apps/client-web/AGENTS.md with consistent format
- Update apps/client-web/src/components/AGENTS.md with quick reference
- Update extensions/AGENTS.md with extension structure
- Add packages/core/AGENTS.md with exports overview

* docs: convert tables to bullet lists for token efficiency

* docs: add writing-agent-document rules, simplify formatting

* docs: remove excessive bold, add .agents/index.md catalog

* trivias

* add pnpm-workspace back

* refactor config to metaConfig and clientConfig

* Rename devAdapter to envAdapter and make it read-only (#17)

- Renamed createDevAdapter() to createEnvAdapter()
- Renamed devAdapter export to envAdapter
- Made envAdapter read only from environment variables (removed localStorage overlay)
- Changed write method to throw error instead of writing to localStorage
- Updated all usage sites in core.ts, settings.vue, and index.ts
- Updated AdapterType definition from 'dev' to 'env'
- Updated translation files (en.json, zh-CN.json) with new adapter name

The envAdapter now only reads configuration from environment variables
and throws an error when attempting to write, making it truly read-only.

* update todo

* upd(joint-dev-vite-plugin): use Vite API instead of spwan; support static dev

* chore(config)

* trivias

* feat(resolver): implResolverCache

* feat(twitter): enhance Tweet schema with optional attachments

* feat(ContentTweet): enhance media rendering with dynamic grid layout

* trivias

* chore(dx): establish reproducible workspace baseline

- pin Node and pnpm with trusted GitHub Packages authentication
- commit the six-importer lockfile and frozen-install workflow
- capture verified baseline results in the developer-experience task packet

* docs(shared): mount v10 product docs hub

- add InKCre/docs as the read-only docs/_shared submodule
- pin the published Hub commit ad464fd9bc9f6c9a8c316e5e75bc5f16e794ecd7
- preserve the Hub-first shared-document workflow

* chore(svc): adopt v10 collaboration contract

- adopt the released SVC 10.0.1 consumer integration
- add local agent and documentation navigation plus the shared-doc wrapper
- record verified Hub and Spoke ownership in the active task packet

* build: hard-cut developer toolchain and package contracts

* feat(dx): establish static local runtime

* feat(db): consume the peer runtime contract

* fix(build): use case-correct tweet stylesheet

* docs(dx): publish peer runtime workflow

* ci: move artifact actions to Node 24

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants