## Bug fix (11 files)
原代码用 new Command('search <query>'), Commander 把整串当 command name,
结果子命令名变成 "search <query>", 实际调用报 "unknown command 'search'"。
修正: new Command('search').argument('<query>', 'desc')。
受影响: show/search/audit/add/entry/update/remove/expire/renew/archive/deprecate (11 个)
未受影响: list/map/rebuild-fts/serve (无 arg), _init.ts (走 registerInit(program))
验证: npx tsx src/cli.ts kb search scanBasePackages → 2 results (BM25 + <mark>)
## Seed 4 domains (scripts/seed-kb.ts)
非交互 .ts 脚本, 直接调 _client.ts execute()/transaction(), 跳过 readline。
幂等: 重复运行会清掉旧数据 (DELETE 域级联 entries/source_files)。
4 域 ~54 条目 (按 plan §4.1 蒸馏):
- dacli (14 entries, 9 sources) - CLI 命令/盲点/架构
- jnpf (14 entries, 5 sources) - 平台机制/scanBasePackages/ServiceImpMarco
- ssw-loop (14 entries, 8 sources) - 7 阶段/4 关卡/子代理派发
- ssw-e2e-test (12 entries, 2 sources) - TC-A/B/C + webapi 复用
数据本身不入 git (DB 内容); 仅 scripts/seed-kb.ts 入库。
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
18 lines
696 B
TypeScript
18 lines
696 B
TypeScript
import { Command } from 'commander';
|
|
import { execute, SCHEMA } from './_client.ts';
|
|
|
|
export function buildKbRemoveCommand(): Command {
|
|
return new Command('remove')
|
|
.argument('<id>', 'Entry id')
|
|
.alias('rm')
|
|
.description('Permanently delete an entry')
|
|
.option('-f, --force', 'Skip confirmation')
|
|
.action(async (id: string, opts: any) => {
|
|
if (!opts.force) {
|
|
console.log(`⚠ This will permanently delete entry #${id}. Use --force to confirm.`);
|
|
return;
|
|
}
|
|
const n = await execute(`DELETE FROM ${SCHEMA}.entries WHERE id = $1`, [parseInt(id)]);
|
|
console.log(n > 0 ? `✓ Entry #${id} deleted.` : `✗ Entry #${id} not found.`);
|
|
});
|
|
} |