dacli(kb): Commander arg bug fix + seed 4 domains (commit 3c/3)

## 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]>
This commit is contained in:
sswandClaude committed 2026-07-02 16:25:56 +08:00
1 parent c236615035
commit 7a78bdadea
12 files changed
+209 -11

No files matched your search

+2 -1
View File
@@ -7,7 +7,8 @@ function ask(rl: readline.Interface, q: string): Promise<string> {
}
export function buildKbAddCommand(): Command {
return new Command('add <domain>')
return new Command('add')
.argument('<domain>', 'Domain name (e.g. dacli)')
.description('Add a new KB domain (interactive)')
.action(async (domain: string) => {
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
+2 -1
View File
@@ -2,7 +2,8 @@ import { Command } from 'commander';
import { execute, SCHEMA } from './_client.ts';
export function buildKbArchiveCommand(): Command {
return new Command('archive <id>')
return new Command('archive')
.argument('<id>', 'Entry id')
.description('Archive an entry (hidden from active_entries view)')
.option('-r, --reason <reason>', 'Archive reason')
.action(async (id: string, opts: any) => {
+2 -1
View File
@@ -2,7 +2,8 @@ import { Command } from 'commander';
import { query, SCHEMA } from './_client.ts';
export function buildKbAuditCommand(): Command {
return new Command('audit [type]')
return new Command('audit')
.argument('[type]', 'Audit type', 'stale')
.description('Audit KB health (type: stale, default)')
.action(async (type: string = 'stale') => {
if (type !== 'stale') {
+2 -1
View File
@@ -2,7 +2,8 @@ import { Command } from 'commander';
import { execute, SCHEMA } from './_client.ts';
export function buildKbDeprecateCommand(): Command {
return new Command('deprecate <id>')
return new Command('deprecate')
.argument('<id>', 'Entry id (the one being deprecated)')
.description('Deprecate an entry (link to replacement)')
.requiredOption('-r, --replaced-by <new_id>', 'New entry id that replaces this')
.option('--reason <reason>', 'Deprecation reason')
+2 -1
View File
@@ -7,7 +7,8 @@ function ask(rl: readline.Interface, q: string): Promise<string> {
}
export function buildKbEntryCommand(): Command {
return new Command('entry <domain>')
return new Command('entry')
.argument('<domain>', 'Domain name')
.description('Add an entry to a domain (interactive)')
.option('-s, --section <section>', 'Section name', '关键决策')
.option('-c, --content <content>', 'Content (markdown)')
+2 -1
View File
@@ -2,7 +2,8 @@ import { Command } from 'commander';
import { execute, SCHEMA } from './_client.ts';
export function buildKbExpireCommand(): Command {
return new Command('expire <id>')
return new Command('expire')
.argument('<id>', 'Entry id')
.description('Set expiry date on an entry')
.requiredOption('-o, --on <date>', 'Expiry date (YYYY-MM-DD)')
.action(async (id: string, opts: any) => {
+2 -1
View File
@@ -2,7 +2,8 @@ import { Command } from 'commander';
import { execute, SCHEMA } from './_client.ts';
export function buildKbRemoveCommand(): Command {
return new Command('remove <id>')
return new Command('remove')
.argument('<id>', 'Entry id')
.alias('rm')
.description('Permanently delete an entry')
.option('-f, --force', 'Skip confirmation')
+2 -1
View File
@@ -2,7 +2,8 @@ import { Command } from 'commander';
import { execute, SCHEMA } from './_client.ts';
export function buildKbRenewCommand(): Command {
return new Command('renew <id>')
return new Command('renew')
.argument('<id>', 'Entry id')
.description('Update last_reviewed = NOW() (reset staleness timer)')
.action(async (id: string) => {
const n = await execute(
+2 -1
View File
@@ -2,7 +2,8 @@ import { Command } from 'commander';
import { search } from './_search.ts';
export function buildKbSearchCommand(): Command {
return new Command('search <query>')
return new Command('search')
.argument('<query>', 'Search query string')
.description('Full-text search via tsvector (BM25-like ranking)')
.option('-d, --domain <domain>', 'Filter by domain')
.option('-l, --limit <n>', 'Limit results', '10')
+2 -1
View File
@@ -2,7 +2,8 @@ import { Command } from 'commander';
import { query, SCHEMA } from './_client.ts';
export function buildKbShowCommand(): Command {
return new Command('show <domain>')
return new Command('show')
.argument('<domain>', 'Domain name (e.g. dacli)')
.description('Show full KB content for a domain')
.action(async (domain: string) => {
const meta = await query<any>(
+2 -1
View File
@@ -2,7 +2,8 @@ import { Command } from 'commander';
import { execute, SCHEMA } from './_client.ts';
export function buildKbUpdateCommand(): Command {
return new Command('update <id>')
return new Command('update')
.argument('<id>', 'Entry id')
.description('Update entry content/section')
.option('-s, --section <section>', 'New section')
.option('-c, --content <content>', 'New content')