iter(g152): ua list 增加组件全览
无参仍列包,但每行带上组件数;--components 按包分组列 id / 标题 / 演示锚点。 末尾给出总数与后续命令提示,替代「没有关键词就只能肉眼猜 id」。
This commit is contained in:
@@ -1572,6 +1572,14 @@
|
|||||||
"acceptance": "MCP_TOOL_NAMES 为单一来源,cmdMcp 启动时自证注册表与之一致;verify 检查 README/AGENTS/CLI 清单逐个写出工具名,缺失即报错并指出漏了哪个(已负向实测)。",
|
"acceptance": "MCP_TOOL_NAMES 为单一来源,cmdMcp 启动时自证注册表与之一致;verify 检查 README/AGENTS/CLI 清单逐个写出工具名,缺失即报错并指出漏了哪个(已负向实测)。",
|
||||||
"notes": "",
|
"notes": "",
|
||||||
"status": "done"
|
"status": "done"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "g152",
|
||||||
|
"title": "ua list 增加组件全览模式",
|
||||||
|
"motivation": "ua list 只列 5 个包,67 个组件的 id 只能靠 ua search 猜关键词去找;没关键词时缺少「一次扫全量」的入口。",
|
||||||
|
"acceptance": "ua list 每行带上组件数;ua list --components 按包分组列出 id / 标题 / 演示锚点并给出总数与后续命令提示,原有无参输出保持可用。",
|
||||||
|
"notes": "",
|
||||||
|
"status": "open"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,12 +114,24 @@ function loadIndex() {
|
|||||||
return JSON.parse(fs.readFileSync(INDEX_FILE, 'utf8'));
|
return JSON.parse(fs.readFileSync(INDEX_FILE, 'utf8'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** 列出全部已注册包 ***/
|
/*** 列出已注册内容:默认列包,--components 改为按包分组列全部组件(id + 标题 + 现场演示锚点) ***/
|
||||||
function cmdList() {
|
function cmdList(args = []) {
|
||||||
const { packages } = loadIndex();
|
const { packages } = loadIndex();
|
||||||
if (!packages.length) return console.log('(no packages indexed)');
|
if (!packages.length) return console.log('(no packages indexed)');
|
||||||
|
if (args.includes('--components')) {
|
||||||
|
let total = 0;
|
||||||
|
for (const p of packages) {
|
||||||
|
const comps = p.docs?.components ?? [];
|
||||||
|
if (!comps.length) continue;
|
||||||
|
total += comps.length;
|
||||||
|
console.log(`\n${p.name} (${comps.length})`);
|
||||||
|
for (const c of comps) console.log(` ${String(c.id).padEnd(16)} ${c.title ?? ''}${c.demo ? ` [${c.demo}]` : ''}`);
|
||||||
|
}
|
||||||
|
return console.log(`\n共 ${total} 个组件;查参数:ua info <组件id>,模糊找:ua search <关键词>`);
|
||||||
|
}
|
||||||
for (const p of packages) {
|
for (const p of packages) {
|
||||||
console.log(`${p.name} v${p.version} [${p.type}] ${p.description}`);
|
const n = p.docs?.components?.length ?? 0;
|
||||||
|
console.log(`${p.name} v${p.version} [${p.type}] ${n} 个组件 ${p.description}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1273,7 +1285,7 @@ switch (cmd) {
|
|||||||
cmdIndex();
|
cmdIndex();
|
||||||
break;
|
break;
|
||||||
case 'list':
|
case 'list':
|
||||||
cmdList();
|
cmdList(args);
|
||||||
break;
|
break;
|
||||||
case 'search':
|
case 'search':
|
||||||
cmdSearch(args[0], args.slice(1));
|
cmdSearch(args[0], args.slice(1));
|
||||||
|
|||||||
Reference in New Issue
Block a user