minecodex 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DESIGN.md +149 -0
- package/apps/dashboard/DESIGN.md +45 -0
- package/features/images/DESIGN.md +71 -0
- package/features/images/README.md +2 -0
- package/features/images/codex-feature.json +2 -1
- package/features/images/src/adapters/codex/cloud-import.mjs +52 -0
- package/features/images/src/adapters/codex/image-prompt.mjs +22 -0
- package/features/images/src/adapters/codex/library-api.mjs +55 -0
- package/features/images/src/adapters/codex/library-viewer.mjs +18 -0
- package/features/images/src/adapters/codex/prompt-resolver-source.mjs +8 -0
- package/features/images/src/backend/cloud-library.mjs +10 -0
- package/features/images/src/domain/library-prompt.mjs +7 -0
- package/features/images/src/library-prompt-page.mjs +7 -75
- package/features/images/src/library-prompt-source.mjs +10 -0
- package/features/images/web/app.js +9 -9
- package/features/images/web/styles.css +219 -219
- package/features/model-slider/DESIGN.md +34 -0
- package/features/model-slider/src/adapters/codex/controller.mjs +93 -0
- package/features/model-slider/src/domain/model-rules.mjs +143 -0
- package/features/model-slider/src/frontend/install.mjs +2110 -0
- package/features/model-slider/src/injection-source.mjs +10 -0
- package/features/notes/DESIGN.md +13 -15
- package/features/notes/README.md +7 -1
- package/features/notes/assets/icons/book-open-nav-fill.svg +1 -0
- package/features/notes/codex-feature.json +5 -1
- package/features/notes/src/{default-prompts.mjs → backend/default-prompts.mjs} +1 -1
- package/features/notes/src/{product.mjs → backend/product.mjs} +1 -1
- package/features/notes/src/{quick-prompts-server.mjs → backend/quick-prompts-server.mjs} +2 -2
- package/features/notes/src/{quick-prompts-page.mjs → frontend/entry.mjs} +64 -257
- package/features/notes/src/frontend/icons.json +13 -0
- package/features/notes/src/frontend/styles.css +110 -0
- package/features/notes/src/main.mjs +2 -2
- package/features/notes/vendor/phosphor-LICENSE +21 -0
- package/features/session-status/DESIGN.md +7 -7
- package/features/session-status/README.md +4 -0
- package/features/session-status/codex-feature.json +1 -1
- package/features/session-status/src/adapters/codex/context-usage.mjs +39 -0
- package/features/session-status/src/adapters/codex/session-log.mjs +81 -0
- package/features/session-status/src/adapters/codex/session-reader.mjs +106 -0
- package/features/session-status/src/domain/session-stats.mjs +141 -0
- package/features/session-status/src/injection-source.mjs +6 -0
- package/features/session-status/src/session-status.mjs +41 -101
- package/features/sidebar-focus/DESIGN.md +6 -5
- package/features/sidebar-focus/codex-feature.json +2 -1
- package/features/sidebar-focus/src/adapters/codex/renderer.mjs +28 -0
- package/features/sidebar-focus/src/injection-source.mjs +6 -0
- package/features/sidebar-focus/src/sidebar-focus.mjs +19 -66
- package/features/sites/DESIGN.md +60 -0
- package/features/sites/README.md +27 -0
- package/features/sites/codex-feature.json +28 -0
- package/features/sites/src/adapters/codex/catalog.mjs +26 -0
- package/features/sites/src/adapters/codex/renderer.mjs +83 -0
- package/features/sites/src/backend/discovery.mjs +73 -0
- package/features/sites/src/backend/project-sites.mjs +34 -0
- package/features/sites/src/backend/site-launcher.mjs +54 -0
- package/features/sites/src/backend/sites-preview.mjs +53 -0
- package/features/sites/src/backend/sites-service.mjs +162 -0
- package/features/sites/src/domain/site.mjs +40 -0
- package/features/sites/src/frontend/entry.mjs +383 -0
- package/features/sites/src/frontend/icons.json +12 -0
- package/features/sites/src/frontend/styles.css +72 -0
- package/features/sites/src/injection-source.mjs +7 -0
- package/features/sites/vendor/lucide-LICENSE +35 -0
- package/features/unread-inbox/DESIGN.md +6 -2
- package/features/unread-inbox/codex-feature.json +2 -1
- package/features/unread-inbox/src/adapters/codex/renderer.mjs +66 -0
- package/features/unread-inbox/src/injection-source.mjs +6 -0
- package/features/unread-inbox/src/unread-inbox.mjs +34 -89
- package/features/usage-meter/DESIGN.md +9 -9
- package/features/usage-meter/README.md +2 -1
- package/features/usage-meter/codex-feature.json +3 -3
- package/features/usage-meter/src/adapters/codex/renderer.mjs +61 -0
- package/features/usage-meter/src/injection-source.mjs +6 -0
- package/features/usage-meter/src/usage-meter.mjs +27 -66
- package/package.json +17 -4
- package/packages/cli/src/config.mjs +2 -1
- package/packages/codex-adapter/README.md +15 -0
- package/packages/codex-adapter/package.json +1 -0
- package/packages/codex-adapter/src/renderer/environment.mjs +53 -0
- package/packages/runtime-host/README.md +27 -0
- package/packages/runtime-host/src/codex-injection.mjs +32 -2393
- package/packages/runtime-host/src/codex-runtime.mjs +21 -3
- package/packages/runtime-host/src/feature-registry.mjs +28 -3
- package/packages/ui/DESIGN.md +31 -0
- package/packages/ui/package.json +8 -0
- package/packages/ui/src/components/button.mjs +21 -0
- package/packages/ui/src/components/composer-menu.mjs +18 -0
- package/packages/ui/src/components/dialog.mjs +55 -0
- package/packages/ui/src/components/navigation-rail.mjs +77 -0
- package/packages/ui/src/components/page.mjs +8 -0
- package/packages/ui/src/components/tooltip.mjs +96 -0
- package/packages/ui/src/foundation/layers.mjs +14 -0
- package/packages/ui/src/foundation/surfaces.mjs +34 -0
- package/packages/ui/src/install.mjs +22 -0
- package/packages/ui/src/native/navigation-rail.mjs +33 -0
- package/packages/ui/src/native/theme.mjs +35 -0
- package/packages/{runtime-host/src/codex-design-contract.mjs → ui/src/native/tokens.mjs} +67 -24
- package/packages/runtime-host/src/cloud-images.mjs +0 -123
- package/packages/runtime-host/src/feature-tooltips.mjs +0 -65
- package/packages/runtime-host/src/session-status-reader.mjs +0 -340
- /package/features/notes/src/{prompt-schema.mjs → backend/prompt-schema.mjs} +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Codex 公共环境适配
|
|
2
|
+
|
|
3
|
+
该私有 workspace 隔离多个插件共同依赖的 Codex Renderer 机制。专有业务协议放在插件的 `src/adapters/codex/`;视觉适配放在 UI 的 `src/native/`。完整层次与文件导航见根 ARCHITECTURE.md 和 AGENTS.md。
|
|
4
|
+
|
|
5
|
+
`createCodexEnvironment()` 是可显式序列化的工厂,无 Node 闭包和 IO imports。宿主按 Renderer 生命周期创建一个实例,通过 `config.codex` 提供给插件,卸载/重注入时重新创建。
|
|
6
|
+
|
|
7
|
+
| 接口 | 结果与约束 |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| `composer(element?, {threadOnly}?)` | 默认仅可见的 thread 输入框;Prompts 显式传 false 支持首页输入框。返回 editable/root/body/add/threadId;非thread不提供身份,隐藏祖先返回 null |
|
|
10
|
+
| `currentThreadId(element?)` | 从合格输入框取得 UUID;不从残留 sidebar 选中项猜当前线程 |
|
|
11
|
+
| `rail()` / `railSlot(ownGroup)` | 可见原生 rail 与模板/滚动区/固定组句柄;不包含插件菜单策略 |
|
|
12
|
+
| `currentFiber(element)` / `props(element,predicate,limit?)` | 仅供 native Adapter 使用;优先匹配当前 committed props,支持最近祖先的 scope |
|
|
13
|
+
| `report(name,available,reason?)` / `diagnostics()` | 最新能力状态的副本;不持有凭据、原始账户数据或用户内容 |
|
|
14
|
+
|
|
15
|
+
不要增加一个包含所有插件的 CodexGateway。新契约只有在被多个模块实际共用时进入这里。选择器、React 机制改动在本模块验证;插件专有协议改动在所属 Adapter 验证。正常界面不暴露内部诊断。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"@minecodex/codex-adapter","private":true,"type":"module"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Codex 的公共原生契约只在此解释;返回锚点句柄与内部身份。
|
|
2
|
+
export function createCodexEnvironment() {
|
|
3
|
+
const capabilities = new Map();
|
|
4
|
+
function report(name, available, reason = null) {
|
|
5
|
+
capabilities.set(name, { name, available, reason });
|
|
6
|
+
}
|
|
7
|
+
function currentFiber(element) {
|
|
8
|
+
while (element && !Object.getOwnPropertyNames(element).some(key=>key.startsWith("__reactFiber"))) element=element.parentElement;
|
|
9
|
+
const keys = Object.getOwnPropertyNames(element ?? {});
|
|
10
|
+
let fiber = element?.[keys.find(key => key.startsWith("__reactFiber"))];
|
|
11
|
+
const props = element?.[keys.find(key => key.startsWith("__reactProps"))];
|
|
12
|
+
if (props && fiber?.alternate?.memoizedProps === props && fiber.memoizedProps !== props) fiber = fiber.alternate;
|
|
13
|
+
return fiber;
|
|
14
|
+
}
|
|
15
|
+
function props(element, predicate, limit = 200) {
|
|
16
|
+
for (let fiber = currentFiber(element), depth = 0; fiber && depth < limit; fiber = fiber.return, depth++) {
|
|
17
|
+
if (predicate(fiber.memoizedProps ?? {})) return fiber.memoizedProps;
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
function composer(element = null, {threadOnly=true} = {}) {
|
|
22
|
+
const candidates = element ? [element] : document.querySelectorAll('[data-codex-composer="true"][contenteditable="true"]');
|
|
23
|
+
for (const editable of candidates) {
|
|
24
|
+
const root = editable.closest('[data-codex-composer-root]');
|
|
25
|
+
if (!editable.isConnected || !root || (threadOnly && root.getAttribute('data-composer-placement') !== 'thread')
|
|
26
|
+
|| editable.closest('[hidden], [inert], [aria-hidden="true"], [data-floating-chat-surface], [data-right-panel-composer-overlay-content]')
|
|
27
|
+
|| !editable.checkVisibility({ visibilityProperty:true })) continue;
|
|
28
|
+
const value = root.getAttribute('data-composer-placement') === 'thread' ? root.querySelector('[data-above-composer-portal]')?.getAttribute('data-above-composer-conversation-id') : null;
|
|
29
|
+
const threadId = value?.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i)?.[0] ?? null;
|
|
30
|
+
report("composer", true);
|
|
31
|
+
return { editable, root, body:editable.closest('[data-composer-body]'), threadId,
|
|
32
|
+
add:root.querySelector('[data-composer-navigation-target="add-context"]') };
|
|
33
|
+
}
|
|
34
|
+
report("composer", false, "active-thread-composer-unavailable");
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
function rail() {
|
|
38
|
+
const node = [...document.querySelectorAll('[data-app-navigation-rail]')].find(node => node.getBoundingClientRect().width > 0) ?? null;
|
|
39
|
+
report("navigation-rail", Boolean(node), node ? null : "rail-unavailable");
|
|
40
|
+
return node;
|
|
41
|
+
}
|
|
42
|
+
function railSlot(ownGroup) {
|
|
43
|
+
const node = rail();
|
|
44
|
+
const template = node?.querySelector('[data-sidebar-destination="builtin:projects"]')
|
|
45
|
+
?? node?.querySelector('[data-sidebar-destination="builtin:library"]');
|
|
46
|
+
const scroll = node?.querySelector('.overflow-y-auto');
|
|
47
|
+
const group = [...(scroll?.children ?? [])].find(child => child !== ownGroup && child.classList.contains('flex-col') && child.classList.contains('shrink-0'));
|
|
48
|
+
return node && template && scroll ? { rail:node, template, scroll, group } : null;
|
|
49
|
+
}
|
|
50
|
+
return { composer, rail, railSlot, currentThreadId:element => composer(element)?.threadId ?? null,
|
|
51
|
+
// 仅供 UI/插件 native Adapter 使用,交互层不读取 React props。
|
|
52
|
+
currentFiber, props, report, diagnostics:() => [...capabilities.values()].map(item => ({...item})) };
|
|
53
|
+
}
|
|
@@ -175,3 +175,30 @@ Host 会再次发送当前状态。功能页面可据此暂停隐藏状态下的
|
|
|
175
175
|
|
|
176
176
|
这是非官方 CDP / DOM Adapter,不是公开的 Codex Contribution API。Codex 更新后应只
|
|
177
177
|
在这个宿主中修复;各功能的数据和 Web UI不需要跟随重写。
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
## 共享弹窗与浮层
|
|
181
|
+
|
|
182
|
+
通用视觉、原生材质分支、遮罩及层级的权威来源为根 [DESIGN.md](../../DESIGN.md),内部文件导航见 [AGENTS.md](../../AGENTS.md)。组件库目标与现有实现归属见 [UI 架构](../ui/ARCHITECTURE.md)。本节只说明当前接入契约。
|
|
183
|
+
|
|
184
|
+
`packages/ui/src/install.mjs` 组装共享组件源码,在 Renderer 中只安装一次,由 page-script 的 `config.ui` 调用:
|
|
185
|
+
|
|
186
|
+
```js
|
|
187
|
+
config.ui.heading(dialog, { title, closeLabel, onClose, back });
|
|
188
|
+
const actions = config.ui.footer(document.createElement("div"));
|
|
189
|
+
actions.append(config.ui.action(saveButton, "primary"));
|
|
190
|
+
config.ui.overlay(backdrop);
|
|
191
|
+
config.ui.surface(popover); // 只统一材质,保留功能的定位与内容
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
`heading` 标记 dialog 并创建标题及 Close;`back` 是可选的已有按钮节点。容器宽高、内容、原生 dialog 或自定义焦点管理、关闭后的焦点恢复继续由功能负责。`footer` 只装饰直接子按钮,`action` 的 tone 为 ghost / secondary / primary / danger。不要再在插件中复制背景、阴影、标题和底部按钮规则。
|
|
195
|
+
|
|
196
|
+
共享组件已迁入 UI workspace。Prompts 与 Sites 管理弹窗选用 opaque / Sites Share;Quick Prompts 使用 ComposerMenu;管理菜单和模型列表选择 Dropdown,Session Status 与任务切换选择 Popover。组件库负责各分支视觉,宿主不复制实现。
|
|
197
|
+
|
|
198
|
+
page-script 可以用 manifest 的 `entry.resources` 声明本功能内的 CSS/图标资源,宿主读取后通过 `config.resources` 一次传入。JSON 作为数据、其他文件作为文本;越出功能目录的路径会被拒绝。它不改变 host action、服务启动或消息协议。
|
|
199
|
+
|
|
200
|
+
Images 提示词面板沿用原生 Version history 的特殊结构;iframe 页面继续通过宿主接收主题。会话统计与云 Library 业务归所属插件,Runtime Host 只组合业务能力和外部连接。领域规则与架构层参见根 [ARCHITECTURE.md](../../ARCHITECTURE.md)。
|
|
201
|
+
|
|
202
|
+
`entry.sourceFactory` 可声明本插件内的源码工厂,导出 `createPageScriptSource()` 并返回 Renderer 函数体字符串。工厂路径不能越出插件;纯领域函数由插件工厂序列化,宿主不维护规则副本。Images 使用这一接口共享图片提示词溯源规则。
|
|
203
|
+
|
|
204
|
+
Model Slider 的模型规则、原生控制器适配和专有呈现位于插件 `src/domain` / `src/frontend`,安装源码由插件工厂组装。宿主仅提供配置、locale、共享 UI、图标与刷新调度,维护 ensure/dispose 接线;原生菜单开合和节点恢复由插件负责。
|