omp packages

@algotao/uiscope0.1.4

Static Vue/React UI scan: component trees, style overrides, UX facets, and agent skill install.

soulvue Published 1 day ago MIT ~0 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

UIScope

UIScope 对 Vue 3 与 React 界面源码做静态分析,输出标准结构 ScanResult(JSON / Markdown),包括组件嵌套、设计类样式覆盖与溯源、界面 切面(如筛选区、列表区、表单区)以及 UX 契约项。

适用于 CI 门禁、维护报告与 编码 Agent 工作流。推荐先执行 npx -y @algotao/uiscope install 安装技能(见快速上手);包形态对齐 Modern Web Guidance pi-package。设计库通过 --preset <id> 接入,扫描内核不写死厂商实现。

快速上手 · 为何需要 · 你能得到什么 · 关键特性 · 适合谁 · CLI · API

Node.js License: MIT npm package

English | 简体中文 · 仓库


为何需要

前端质量信号常常分散在互不打通的工具里:

信号 常见来源 空缺
语法与依赖 ESLint、TypeScript 很少反映组合深度与设计库用法
视觉 截图、Storybook 难进 CI,难做可比对结论
样式 设计稿 token 缺少 token → 仓库内覆盖点 的自动映射
结构 / UX 产品文档 很少对照真实组件树做契约检查

于是架构类问题往往靠人工碎片回答:「库组件嵌了多深?」「这页是三个区域还是一整块模板?」「同一个 class 是否在几十个文件里被覆盖?」UIScope 一次解析 SFC、CSS、JSX,为人、流水线和 Agent 产出同一套结构化结果,本地与 CI 命令形态一致。


你能得到什么

产出 回答的问题
组件树 库 / 站点封装 / DOM;嵌套深度与 import 来源
样式重载 白名单 class 在消费方 CSS 中的重复与 溯源链
切面(Facet) 可交互区域类型(如 filter-bar、list-region)、模板化与布局线索
UX 结论 core-ux 契约规则 + 可选增强(--enhance)
ScanResult 统一 JSON:trees、facetReports、uxFindings、warnings、stats 等

设计库相关配置见 presets/README.md(英文):import 前缀、样式白名单、组件 角色 由 preset 注入。


关键特性

特性 说明
Vue + React 一次跑完 @algotao/uiscope/vue、/react;默认在 --root 下同时扫描
按深度选模式 ux 偏快(切面 + 规则);all 含树、样式、切面与 core-ux
CI 可门禁 --fail-on-warn 有告警时退出码 1
Agent 友好体量 --json、--out(附同名 .json);read 先计数再按区段读取
Preset 扩展 --preset <id> 加载包内或 npm preset,core 不写死库名
Skill + CLI uiscope 与 uiscope-ux-optimize 双入口

适合谁

角色 典型用法
设计体系 / 组件库团队 重构前看清消费方覆盖与库嵌套深度
平台 / 业务工程 合并前用切面与 UX 契约做门禁
维护者 report 与 Markdown 做白名单、场景对比
Agent 工作流 将 ScanResult 或切片喂给评审与重构技能

快速上手

环境: Node.js >= 18,npm 7+。扫描 --root 下的 .vue、.tsx、.jsx 及相关样式。

编码 Agent(推荐)

在应用仓库根目录执行:

npx -y @algotao/uiscope install

默认与 Modern Web Guidance 相同:在 Node.js 22+(建议)下内部走 skills add AlgoTao-dev/UIScope,由 Vercel skills 交互选择安装位置与 Agent。包本身要求 Node ≥ 18;低于 22 时 install 会 builtin 直拷(可用 -a / -g / --all 指定目标)。

npx -y @algotao/uiscope install                   # 22+:交互向导;18–21:直拷 + 提示
npx -y @algotao/uiscope install -g -a cursor -y   # 非交互,参数转发给 skills(22+)
npx -y @algotao/uiscope install --builtin -a cursor # 始终直拷(18+)

亦可直接:npx skills add AlgoTao-dev/UIScope --skill uiscope-ux-optimize、pi install npm:@algotao/uiscope。

Claude Code(技能目录 .claude/skills/,发布物含 .claude-plugin/):

/plugin marketplace add AlgoTao-dev/UIScope
/plugin install uiscope-ux-optimize@algotao-dev

或 npx -y @algotao/uiscope install -a claude-code(别名 -a claude)。

OpenAI Codex(技能目录 .agents/skills/,发布物含 .codex-plugin/):

codex plugin marketplace add AlgoTao-dev/UIScope
codex plugin add uiscope-ux-optimize@algotao-dev

说明:npx -y @algotao/uiscope install --help。

不添加 devDependency 的扫描

npx -y @algotao/uiscope ux --root src --json

将 CLI 装进项目

npm install --save-dev @algotao/uiscope
uiscope all --root app --fail-on-warn
场景 命令
快速 UX + 切面 uiscope ux --root <dir>
全量门禁 uiscope all --root <dir> --fail-on-warn
设计库默认项 uiscope all --preset <id> --root <dir>
仅用 CLI 旗标 追加 --no-config
库无关(不自动 preset) uiscope ux --no-auto-preset
自动组件库扩展 扫描 package.json 依赖 → 各 preset 的 detectPackages / @algotao/preset-<id>;stderr 打印 auto-preset

--json 输出中的 stats 片段示例(仅示意结构):

{
  "stats": {
    "vueFilesScanned": 24,
    "reactFilesScanned": 6,
    "facetRegions": 11,
    "warnings": 2
  }
}

CI

- uses: actions/setup-node@v4
  with:
    node-version: '20'
- run: npm ci
- run: npx uiscope all --root app --fail-on-warn

CLI 参考

uiscope [子命令] [选项]
uiscope -h

安装后用 uiscope …;未安装时用 npx -y @algotao/uiscope …,参数相同。

子命令

子命令 说明
install 默认 skills add 交互安装;--builtin 直拷;-a / -g / -y / agents
tree 组件嵌套(库 / 封装 / HTML)
styles 白名单 class 重载统计与溯源链
facets 切面 + core-ux 契约
ux 切面 + UX 规则;默认不扫样式
all 树 + 样式 + 切面 + core-ux(默认)
report 维护向多场景 Markdown
read 已落盘 .json / .md 报告切片

常用选项

选项 说明
--root <dir> 扫描根(可重复),相对 cwd
--fail-on-warn 有告警时退出码 1(CI)
--preset <id|@pkg> 包内 presets/<id>/ 或 npm preset(可重复)
--no-config 不自动加载已发现配置文件
--config <file> 显式配置路径
--framework vue|react 可重复;默认两者
--json 标准输出完整 ScanResult
--all-files 忽略「仅库消费方」收窄
--enhance <id> / --enhance-all 可选 UX 增强
--with-styles ux 模式下包含样式
--out <file> 写 Markdown(ux / facets 另生成同名 .json)
--facet-limit <n> 终端切面文件列表上限(0 为全量)
--quiet, -q 不输出 stderr 进度

完整选项:uiscope -h。历史别名 --include-non-ocp 等同 --all-files。

示例

uiscope all --root app --fail-on-warn
uiscope styles --style-exclude '**/assets/css/site-layout.css' --threshold 6
uiscope ux --enhance-all --out .local/uiscope-ux-report.md
uiscope read --file .local/uiscope-ux-report.json --section uxFindings --offset 0 --limit 40

可选配置

import type { UiscopeConfig } from '@algotao/uiscope';

export default {
  roots: ['app', 'src'],
  frameworks: ['vue'],
  presets: ['my-ui'],
  libraryImportSources: ['@acme/ui-vue'],
  onlyLibraryConsumers: true,
  consumerWrapperTags: ['AppButton'],
  thresholds: {
    style: { overrideRuleCount: 6 },
    tree: { maxLibraryNestDepth: 5 },
  },
} satisfies Partial<UiscopeConfig>;

Preset 加载顺序:presetModules → 包内 presets/<id>/ → npm @algotao/preset-<id>。

局限: 自动导入标签可能为 unknown;v-for / 部分列表 JSX 覆盖不完整;样式溯源偏 Vue 模板锚点。


程序化 API

import {
  runScan,
  loadScanConfig,
  applyPresets,
  createTerminalProgressReporter,
  getScanReportCountsFromFile,
  readScanReportSectionFromFile,
  readTextReportLines,
  sliceScanReportSection,
} from '@algotao/uiscope';

runScan({ cwd, config, mode, … }) 返回 ScanResult。


Agent 技能

安装:npx -y @algotao/uiscope install。技能定义:skills/uiscope-ux-optimize/SKILL.md;运行器可用 bin uiscope-ux-optimize。插件清单见 plugin.json、.cursor-plugin/、.agents/plugins/(形态同 Modern Web Guidance)。


目录结构

路径 职责
src/ 内核、CLI、增强、报告
src/adapters/vue · react 框架适配
presets/<id>/ 可选设计库 preset
skills/ Agent 技能包

导出:@algotao/uiscope、@algotao/uiscope/vue、@algotao/uiscope/react。

开发

npm run check

对外约定:本文与 uiscope -h。