focus-guard 3.5.3 → 3.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/README.zh-CN.md +1 -1
- package/assets/NOTICE.md +1 -1
- package/docs/ARCH-MAP.md +298 -83
- package/docs/BENCH.md +10 -4
- package/docs/RELEASE-POLICY.md +25 -12
- package/docs/RULES.md +34 -16
- package/docs/THREAT-MODEL.md +3 -3
- package/docs/WRITING-STYLE.md +40 -2
- package/package.json +1 -1
- package/skills/focus-rules/SKILL.md +9 -9
- package/skills/focus-thinking/SKILL.md +3 -3
- package/src/adapters/dsh/eligibility-gate.mjs +32 -12
- package/src/{dsh → adapters/dsh}/toolName.mjs +6 -0
- package/src/core/auditActions.mjs +214 -0
- package/src/core/checkEligibility.mjs +3 -1
- package/src/core/constants.mjs +8 -4
- package/src/core/env.mjs +21 -4
- package/src/core/profileLoader.mjs +96 -3
- package/src/core/scratch.mjs +288 -0
- package/src/core/state.mjs +3 -3
- package/src/dsh/audit.mjs +24 -163
- package/src/dsh/cost-ledger.mjs +174 -0
- package/src/dsh/guard/authz.mjs +1 -1
- package/src/dsh/guard/evidence.mjs +19 -0
- package/src/dsh/guard/tooling.mjs +15 -4
- package/src/dsh/{value-gate.mjs → guard/value-gate.mjs} +6 -0
- package/src/dsh/index.js +1 -1
- package/src/dsh/pipeline.mjs +6 -3
- package/src/dsh/postProgress.mjs +81 -40
- package/src/dsh/preGuard.mjs +1 -1
- package/src/dsh/seams/pre-step.mjs +74 -23
- package/src/dsh/seams/prompt-rules.mjs +91 -5
- package/src/dsh/{guard → seams}/runtime.mjs +12 -6
- package/src/dsh/seams/session-start.mjs +14 -0
- package/src/dsh/tools.mjs +1 -1
- package/src/memory/index.mjs +3 -1
- package/src/profiles/deepseek-flash.mjs +10 -8
- package/src/profiles/deepseek-pro.mjs +9 -8
- package/src/profiles/default.mjs +14 -8
- package/src/profiles/glm.mjs +9 -8
- package/src/profiles/gpt-astra.mjs +11 -9
- package/tools/audit-chain.mjs +29 -4
- package/tools/docs-drift.mjs +7 -29
- package/tools/docs-lint.mjs +54 -11
- package/tools/docs-refs.mjs +343 -0
- package/tools/handoff.mjs +1 -1
- package/tools/index-stale.mjs +124 -0
- package/tools/knowledge.mjs +53 -4
- package/tools/lib/book-style.mjs +42 -1
- package/tools/lib/case-tool.mjs +1 -1
- package/tools/lib/cli.mjs +35 -0
- package/tools/lib/docs-ack.mjs +4 -2
- package/tools/lib/docs-core.mjs +46 -23
- package/tools/lib/docs-scope.mjs +46 -0
- package/tools/lib/docs-status.mjs +8 -3
- package/tools/lib/docs-typography.mjs +91 -0
- package/tools/lib/docs-version.mjs +8 -5
- package/tools/lib/dup-block.mjs +117 -0
- package/tools/lib/index-io.mjs +4 -4
- package/tools/lib/index-registry.mjs +101 -0
- package/tools/lib/modules-doc.mjs +8 -1
- package/tools/lib/modules-list.mjs +22 -8
- package/tools/lib/modules.mjs +57 -9
- package/tools/lib/mutation-ops.mjs +63 -0
- package/tools/lib/parse-block.mjs +58 -0
- package/tools/lib/ratchet.mjs +22 -8
- package/tools/lib/release-faces.mjs +144 -0
- package/tools/lib/repo-copy.mjs +34 -0
- package/tools/lib/survey-report.mjs +57 -0
- package/tools/lib/where.mjs +139 -0
- package/tools/library-build.mjs +15 -3
- package/tools/lint.mjs +19 -13
- package/tools/log-audit.mjs +76 -0
- package/tools/memory-distill.mjs +14 -1
- package/tools/modules-audit.mjs +11 -9
- package/tools/mutate.mjs +120 -74
- package/tools/prefix-drift.mjs +1 -1
- package/tools/registry-check.mjs +16 -10
- package/tools/release.mjs +54 -106
- package/tools/smells.mjs +97 -139
- package/src/core/staleCleanup.mjs +0 -224
- package/src/dsh/workspace.mjs +0 -5
- package/tools/library-index.mjs +0 -91
package/tools/library-index.mjs
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* 【私有工具】资料积木索引(2026-10-31)
|
|
4
|
-
*
|
|
5
|
-
* 读 `.ai/output/library/*.md` 的文件名,落一份 `index.json` 当目录。
|
|
6
|
-
* 产物落 `.ai/output/`——私有面,不入库、不随 npm 分发。
|
|
7
|
-
*
|
|
8
|
-
* ## 为什么只做文件名索引,不做内容索引
|
|
9
|
-
*
|
|
10
|
-
* 实测:118 份源文件 174,479 字,全量读一遍 ≈ 12 万 token,而 compaction 阈值 0.3,
|
|
11
|
-
* 读不完。但积木的文件名本身已经是「编号-主题-来源」——索引项早就存在,只是没人读它。
|
|
12
|
-
* 29 项合计 638 字符,比 118 条机器摘要(约 2,360 字)便宜四倍,且不会抽错主题。
|
|
13
|
-
*
|
|
14
|
-
* 内容级索引留到真有检索痛点再做。两套索引源 = 两个真相源,那是 3.3 修过的病。
|
|
15
|
-
*
|
|
16
|
-
* ## 命名规律(实测 28 块)
|
|
17
|
-
*
|
|
18
|
-
* B001-s-级-改改措辞就能进-rules-注入前缀.md 分级结论:s/a/b 级
|
|
19
|
-
* B006-核心机制-anthropic.md 主题 + 来源
|
|
20
|
-
*
|
|
21
|
-
* 认不出的写法不猜:整段原样进 `topic`,`grade`/`source` 留 null。
|
|
22
|
-
*
|
|
23
|
-
* ## 用法
|
|
24
|
-
*
|
|
25
|
-
* node tools/library-index.mjs 重建 index.json
|
|
26
|
-
* node tools/library-index.mjs --check 只比对,不写;漂移则退 1
|
|
27
|
-
*/
|
|
28
|
-
import { existsSync, readFileSync, readdirSync } from 'node:fs'
|
|
29
|
-
import { join } from 'node:path'
|
|
30
|
-
import { diffKeys, runIndexTool } from './lib/index-io.mjs'
|
|
31
|
-
|
|
32
|
-
const DIR = '.ai/output/library'
|
|
33
|
-
const OUT = join(DIR, 'index.json')
|
|
34
|
-
const SOURCES = ['anthropic', 'google', 'misc', 'openai', 'others', 'xai']
|
|
35
|
-
|
|
36
|
-
/** 文件名 → 索引项。认不出的一律不猜,整段当 topic。 */
|
|
37
|
-
export function parseBlock(file, chars) {
|
|
38
|
-
const m = /^B(\d{3})-(.+)\.md$/.exec(file)
|
|
39
|
-
if (!m) return null
|
|
40
|
-
const [, num, rest] = m
|
|
41
|
-
const item = { id: `B${num}`, file, grade: null, topic: rest, source: null, chars }
|
|
42
|
-
const graded = /^([sab])-级-(.+)$/.exec(rest)
|
|
43
|
-
if (graded) {
|
|
44
|
-
item.grade = graded[1]
|
|
45
|
-
item.topic = graded[2]
|
|
46
|
-
return item
|
|
47
|
-
}
|
|
48
|
-
const tail = new RegExp(`^(.+)-(${SOURCES.join('|')})$`).exec(rest)
|
|
49
|
-
if (tail) {
|
|
50
|
-
item.topic = tail[1]
|
|
51
|
-
item.source = tail[2]
|
|
52
|
-
}
|
|
53
|
-
return item
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** 扫目录,出索引对象。不写盘。 */
|
|
57
|
-
export function buildIndex(dir = DIR) {
|
|
58
|
-
if (!existsSync(dir)) return { dir, blocks: [] }
|
|
59
|
-
const blocks = readdirSync(dir)
|
|
60
|
-
.filter((f) => /^B\d{3}-.+\.md$/.test(f))
|
|
61
|
-
.sort()
|
|
62
|
-
.map((f) => parseBlock(f, readFileSync(join(dir, f), 'utf8').length))
|
|
63
|
-
.filter(Boolean)
|
|
64
|
-
return { dir, blocks }
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** 零漂移判据:id/file/chars 三者全等。少一块、多一块、改一个字都算。 */
|
|
68
|
-
const KEY = (b) => `${b.id}|${b.file}|${b.chars}`
|
|
69
|
-
export function diffIndex(expected, actual) {
|
|
70
|
-
return diffKeys(expected, actual, KEY, 'blocks')
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function main() {
|
|
74
|
-
runIndexTool({
|
|
75
|
-
argv: process.argv.slice(2),
|
|
76
|
-
build: buildIndex,
|
|
77
|
-
field: 'blocks',
|
|
78
|
-
out: OUT,
|
|
79
|
-
label: 'index.json',
|
|
80
|
-
keyOf: KEY,
|
|
81
|
-
prefix: '[library-index]',
|
|
82
|
-
empty: `${DIR} 下没有积木,先跑 library-build`,
|
|
83
|
-
summary: (i) => {
|
|
84
|
-
const graded = i.blocks.filter((b) => b.grade).length
|
|
85
|
-
const total = i.blocks.reduce((n, b) => n + b.chars, 0)
|
|
86
|
-
return `${i.blocks.length} 块(分级结论 ${graded})/ ${total} 字 → ${OUT}`
|
|
87
|
-
},
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (process.argv[1] && process.argv[1].endsWith('library-index.mjs')) main()
|