mirror of
https://github.com/jackwener/OpenCLI.git
synced 2026-09-14 18:25:42 +08:00
36d22ef4d3
- 新增 `clis/codex/sidebar.js` 共享 helper,使用 `data-app-action-sidebar-*` DOM 属性 + native click 触发侧边栏导航 - 新增 `clis/codex/projects.js` 与 `clis/codex/history.js`:列表/详情双契约 - typed fail-fast 收口: * projects/history 空列表 → EmptyResultError * limit/timeout/index/thread-id 非法 → ArgumentError(拒绝 silent-clamp) * 目标项找不到 → EmptyResultError * sidebar DOM 缺失 → CommandExecutionError - 新增 8 条 regression 单测(`clis/codex/sidebar.test.js`) - B 组 codex-mini1 lead green + First-principles-1 aux green on `bcfd88ae` Round 13 close-out.
29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
import { cli, Strategy } from '@jackwener/opencli/registry';
|
|
import { EmptyResultError } from '@jackwener/opencli/errors';
|
|
import { flattenCodexProjects, readCodexProjects } from './sidebar.js';
|
|
|
|
export const projectsCommand = cli({
|
|
site: 'codex',
|
|
name: 'projects',
|
|
access: 'read',
|
|
description: 'List Codex projects and visible conversations from the sidebar',
|
|
domain: 'localhost',
|
|
strategy: Strategy.UI,
|
|
browser: true,
|
|
args: [
|
|
{ name: 'project', required: false, help: 'Filter by project label or path' },
|
|
{ name: 'limit', required: false, help: 'Max conversations per project' },
|
|
],
|
|
columns: ['Project', 'Index', 'Title', 'Updated', 'Active'],
|
|
func: async (page, kwargs) => {
|
|
const projects = await readCodexProjects(page);
|
|
const rows = flattenCodexProjects(projects, kwargs);
|
|
if (rows.length === 0) {
|
|
throw new EmptyResultError('codex projects', kwargs.project
|
|
? `No Codex projects matched "${kwargs.project}".`
|
|
: 'No Codex projects were visible. Open the Codex sidebar and retry.');
|
|
}
|
|
return rows;
|
|
},
|
|
});
|