@dommaker/harness 0.12.14 → 0.12.16
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/dist/cli/commands/sync-docs.d.ts.map +1 -1
- package/dist/cli/commands/sync-docs.js +191 -37
- package/dist/cli/commands/sync-docs.js.map +1 -1
- package/dist/core/constraints/checker.d.ts +18 -11
- package/dist/core/constraints/checker.d.ts.map +1 -1
- package/dist/core/constraints/checker.js +163 -103
- package/dist/core/constraints/checker.js.map +1 -1
- package/dist/core/constraints/definitions.d.ts.map +1 -1
- package/dist/core/constraints/definitions.js +15 -0
- package/dist/core/constraints/definitions.js.map +1 -1
- package/dist/core/constraints/doc-freshness/auto-fix.d.ts +23 -0
- package/dist/core/constraints/doc-freshness/auto-fix.d.ts.map +1 -0
- package/dist/core/constraints/doc-freshness/auto-fix.js +59 -0
- package/dist/core/constraints/doc-freshness/auto-fix.js.map +1 -0
- package/dist/core/constraints/doc-freshness/runner.d.ts +76 -0
- package/dist/core/constraints/doc-freshness/runner.d.ts.map +1 -0
- package/dist/core/constraints/doc-freshness/runner.js +387 -0
- package/dist/core/constraints/doc-freshness/runner.js.map +1 -0
- package/dist/core/constraints/prompt-injection.js +3 -3
- package/dist/core/constraints/prompt-injection.js.map +1 -1
- package/dist/core/validators/checkpoint.d.ts +4 -0
- package/dist/core/validators/checkpoint.d.ts.map +1 -1
- package/dist/core/validators/checkpoint.js +25 -2
- package/dist/core/validators/checkpoint.js.map +1 -1
- package/dist/types/project-config.d.ts +79 -0
- package/dist/types/project-config.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* FreshnessAutoFix — 文档新鲜度自动修复
|
|
4
|
+
*
|
|
5
|
+
* 根据 FreshnessRunner 检查结果修复文档中的过期计数。
|
|
6
|
+
* 只负责安全的 regex 替换,不处理结构性修复(如 doc_dir_check)。
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.FreshnessAutoFix = void 0;
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const path_1 = require("path");
|
|
12
|
+
/**
|
|
13
|
+
* 文档新鲜度自动修复器
|
|
14
|
+
*/
|
|
15
|
+
class FreshnessAutoFix {
|
|
16
|
+
/**
|
|
17
|
+
* 根据检查结果修复文档
|
|
18
|
+
* @returns 是否成功修复
|
|
19
|
+
*/
|
|
20
|
+
fix(check, result, projectPath) {
|
|
21
|
+
switch (check.type) {
|
|
22
|
+
case 'doc_regex_count':
|
|
23
|
+
return this.fixDocRegexCount(check, result, projectPath);
|
|
24
|
+
default:
|
|
25
|
+
// doc_dir_check / context_docs 的自动修复不在 MVP 范围内
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 修复 doc_regex_count:更新文档中的计数
|
|
31
|
+
*/
|
|
32
|
+
fixDocRegexCount(check, result, projectPath) {
|
|
33
|
+
try {
|
|
34
|
+
const docPath = (0, path_1.join)(projectPath, check.doc);
|
|
35
|
+
if (!(0, fs_1.existsSync)(docPath))
|
|
36
|
+
return false;
|
|
37
|
+
const detail = result.detail;
|
|
38
|
+
if (!detail || detail.actualCount === undefined)
|
|
39
|
+
return false;
|
|
40
|
+
const actualCount = detail.actualCount;
|
|
41
|
+
const content = (0, fs_1.readFileSync)(docPath, 'utf-8');
|
|
42
|
+
const countRegex = new RegExp(check.pattern);
|
|
43
|
+
if (!countRegex.test(content))
|
|
44
|
+
return false;
|
|
45
|
+
// regex 替换:保留原捕获组结构,只替换 (\d+) 部分
|
|
46
|
+
// 策略:匹配完整正则,然后用实际值替换第一个捕获组
|
|
47
|
+
const updated = content.replace(countRegex, (match, ...groups) => {
|
|
48
|
+
return match.replace(groups[0], String(actualCount));
|
|
49
|
+
});
|
|
50
|
+
(0, fs_1.writeFileSync)(docPath, updated, 'utf-8');
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.FreshnessAutoFix = FreshnessAutoFix;
|
|
59
|
+
//# sourceMappingURL=auto-fix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-fix.js","sourceRoot":"","sources":["../../../../src/core/constraints/doc-freshness/auto-fix.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,2BAA6D;AAC7D,+BAA4B;AAI5B;;GAEG;AACH,MAAa,gBAAgB;IAC3B;;;OAGG;IACH,GAAG,CACD,KAAyB,EACzB,MAA4B,EAC5B,WAAmB;QAEnB,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;YACnB,KAAK,iBAAiB;gBACpB,OAAO,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;YAC3D;gBACE,+CAA+C;gBAC/C,OAAO,KAAK,CAAC;QACjB,CAAC;IACH,CAAC;IAED;;OAEG;IACK,gBAAgB,CACtB,KAAyB,EACzB,MAA4B,EAC5B,WAAmB;QAEnB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAA,WAAI,EAAC,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;YAC7C,IAAI,CAAC,IAAA,eAAU,EAAC,OAAO,CAAC;gBAAE,OAAO,KAAK,CAAC;YAEvC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;YAC7B,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS;gBAAE,OAAO,KAAK,CAAC;YAE9D,MAAM,WAAW,GAAG,MAAM,CAAC,WAAqB,CAAC;YAEjD,MAAM,OAAO,GAAG,IAAA,iBAAY,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC/C,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAE7C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC;gBAAE,OAAO,KAAK,CAAC;YAE5C,iCAAiC;YACjC,2BAA2B;YAC3B,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,GAAG,MAAM,EAAE,EAAE;gBAC/D,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;YACvD,CAAC,CAAC,CAAC;YAEH,IAAA,kBAAa,EAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YACzC,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF;AArDD,4CAqDC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FreshnessRunner — 配置驱动的文档新鲜度检查引擎
|
|
3
|
+
*
|
|
4
|
+
* 所有检查是纯同步文件系统操作,零 LLM 调用。
|
|
5
|
+
* 通过 DocFreshnessConfig 配置驱动,不绑定任何项目结构。
|
|
6
|
+
*/
|
|
7
|
+
import type { DocFreshnessCheck, DocFreshnessConfig } from '../../../types/project-config';
|
|
8
|
+
/**
|
|
9
|
+
* Freshness 检查结果
|
|
10
|
+
*/
|
|
11
|
+
export interface FreshnessCheckResult {
|
|
12
|
+
/** 检查类型 */
|
|
13
|
+
type: string;
|
|
14
|
+
/** 人类可读标签 */
|
|
15
|
+
label: string;
|
|
16
|
+
/** 是否通过 */
|
|
17
|
+
pass: boolean;
|
|
18
|
+
/** 失败时的消息 */
|
|
19
|
+
message?: string;
|
|
20
|
+
/** 额外详情 */
|
|
21
|
+
detail?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* FreshnessRunner 执行上下文
|
|
25
|
+
*/
|
|
26
|
+
interface RunContext {
|
|
27
|
+
projectPath: string;
|
|
28
|
+
/** 外部提供的 required_dirs(来自 governance.context_files,用于 context_docs 检查的默认 dirs) */
|
|
29
|
+
requiredDirs?: string[];
|
|
30
|
+
/** 外部提供的约束计数(用于内置 harner harness 的 doc_regex_count) */
|
|
31
|
+
constraintCounts?: {
|
|
32
|
+
ironLaws?: number;
|
|
33
|
+
guidelines?: number;
|
|
34
|
+
tips?: number;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 配置驱动的文档新鲜度检查引擎
|
|
39
|
+
*/
|
|
40
|
+
export declare class FreshnessRunner {
|
|
41
|
+
/**
|
|
42
|
+
* 运行所有配置的文档新鲜度检查
|
|
43
|
+
*/
|
|
44
|
+
runAll(config: DocFreshnessConfig, projectPath: string, ctx?: {
|
|
45
|
+
requiredDirs?: string[];
|
|
46
|
+
constraintCounts?: {
|
|
47
|
+
ironLaws?: number;
|
|
48
|
+
guidelines?: number;
|
|
49
|
+
tips?: number;
|
|
50
|
+
};
|
|
51
|
+
}): FreshnessCheckResult[];
|
|
52
|
+
/**
|
|
53
|
+
* 执行单个检查
|
|
54
|
+
*/
|
|
55
|
+
runSingle(check: DocFreshnessCheck, context: RunContext): FreshnessCheckResult;
|
|
56
|
+
private checkChangelogVersion;
|
|
57
|
+
private checkContextDocs;
|
|
58
|
+
private checkDocDir;
|
|
59
|
+
/**
|
|
60
|
+
* 从文档目录集合推断要扫描的根目录
|
|
61
|
+
* 例如 ["src/core", "src/cli/commands"] → ["src"]
|
|
62
|
+
*/
|
|
63
|
+
private inferRootDirs;
|
|
64
|
+
private checkDocRegexCount;
|
|
65
|
+
/**
|
|
66
|
+
* 从目录中计数匹配的文件/条目
|
|
67
|
+
*/
|
|
68
|
+
countFromDir(dirPath: string, extension: string, exclude: string[], projectPath: string): number;
|
|
69
|
+
/**
|
|
70
|
+
* 从 grep 匹配中计数
|
|
71
|
+
*/
|
|
72
|
+
countFromGrep(projectPath: string, globPattern: string, pattern: string): number;
|
|
73
|
+
private escapeRegExp;
|
|
74
|
+
}
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../../src/core/constraints/doc-freshness/runner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAKnB,MAAM,+BAA+B,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,WAAW;IACX,IAAI,EAAE,MAAM,CAAC;IACb,aAAa;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW;IACX,IAAI,EAAE,OAAO,CAAC;IACd,aAAa;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW;IACX,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED;;GAEG;AACH,UAAU,UAAU;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,kFAAkF;IAClF,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,uDAAuD;IACvD,gBAAgB,CAAC,EAAE;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED;;GAEG;AACH,qBAAa,eAAe;IAC1B;;OAEG;IACH,MAAM,CACJ,MAAM,EAAE,kBAAkB,EAC1B,WAAW,EAAE,MAAM,EACnB,GAAG,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,gBAAgB,CAAC,EAAE;YAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;YAAC,UAAU,CAAC,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,GAC9G,oBAAoB,EAAE;IAazB;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,UAAU,GAAG,oBAAoB;IAsB9E,OAAO,CAAC,qBAAqB;IA0C7B,OAAO,CAAC,gBAAgB;IA+BxB,OAAO,CAAC,WAAW;IAiHnB;;;OAGG;IACH,OAAO,CAAC,aAAa;IAiCrB,OAAO,CAAC,kBAAkB;IA0E1B;;OAEG;IACH,YAAY,CACV,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EAAE,EACjB,WAAW,EAAE,MAAM,GAClB,MAAM;IA6BT;;OAEG;IACH,aAAa,CACX,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,MAAM;IA0CT,OAAO,CAAC,YAAY;CAGrB"}
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* FreshnessRunner — 配置驱动的文档新鲜度检查引擎
|
|
4
|
+
*
|
|
5
|
+
* 所有检查是纯同步文件系统操作,零 LLM 调用。
|
|
6
|
+
* 通过 DocFreshnessConfig 配置驱动,不绑定任何项目结构。
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.FreshnessRunner = void 0;
|
|
10
|
+
const fs_1 = require("fs");
|
|
11
|
+
const path_1 = require("path");
|
|
12
|
+
/**
|
|
13
|
+
* 配置驱动的文档新鲜度检查引擎
|
|
14
|
+
*/
|
|
15
|
+
class FreshnessRunner {
|
|
16
|
+
/**
|
|
17
|
+
* 运行所有配置的文档新鲜度检查
|
|
18
|
+
*/
|
|
19
|
+
runAll(config, projectPath, ctx) {
|
|
20
|
+
if (config.enabled === false)
|
|
21
|
+
return [];
|
|
22
|
+
if (!config.checks || config.checks.length === 0)
|
|
23
|
+
return [];
|
|
24
|
+
const context = {
|
|
25
|
+
projectPath,
|
|
26
|
+
requiredDirs: ctx?.requiredDirs,
|
|
27
|
+
constraintCounts: ctx?.constraintCounts,
|
|
28
|
+
};
|
|
29
|
+
return config.checks.map(check => this.runSingle(check, context));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 执行单个检查
|
|
33
|
+
*/
|
|
34
|
+
runSingle(check, context) {
|
|
35
|
+
switch (check.type) {
|
|
36
|
+
case 'changelog_version':
|
|
37
|
+
return this.checkChangelogVersion(check, context);
|
|
38
|
+
case 'context_docs':
|
|
39
|
+
return this.checkContextDocs(check, context);
|
|
40
|
+
case 'doc_dir_check':
|
|
41
|
+
return this.checkDocDir(check, context);
|
|
42
|
+
case 'doc_regex_count':
|
|
43
|
+
return this.checkDocRegexCount(check, context);
|
|
44
|
+
default:
|
|
45
|
+
return {
|
|
46
|
+
type: check.type || 'unknown',
|
|
47
|
+
label: 'Unknown',
|
|
48
|
+
pass: true,
|
|
49
|
+
message: `未知的检查类型: ${check.type}`,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// ── changelog_version ────────────────────────────────────────────
|
|
54
|
+
checkChangelogVersion(check, ctx) {
|
|
55
|
+
const changelogPath = (0, path_1.join)(ctx.projectPath, check.changelog || 'CHANGELOG.md');
|
|
56
|
+
const pkgPath = (0, path_1.join)(ctx.projectPath, check.package_json || 'package.json');
|
|
57
|
+
try {
|
|
58
|
+
if (!(0, fs_1.existsSync)(changelogPath)) {
|
|
59
|
+
return { type: 'changelog_version', label: 'CHANGELOG Version', pass: true };
|
|
60
|
+
}
|
|
61
|
+
const changelogContent = (0, fs_1.readFileSync)(changelogPath, 'utf-8');
|
|
62
|
+
const versionMatch = changelogContent.match(/##\s*\[(\d+\.\d+\.\d+)\]/);
|
|
63
|
+
if (!versionMatch) {
|
|
64
|
+
return { type: 'changelog_version', label: 'CHANGELOG Version', pass: true };
|
|
65
|
+
}
|
|
66
|
+
const changelogVersion = versionMatch[1];
|
|
67
|
+
if (!(0, fs_1.existsSync)(pkgPath)) {
|
|
68
|
+
return { type: 'changelog_version', label: 'CHANGELOG Version', pass: true };
|
|
69
|
+
}
|
|
70
|
+
const pkg = JSON.parse((0, fs_1.readFileSync)(pkgPath, 'utf-8'));
|
|
71
|
+
const pkgVersion = pkg.version;
|
|
72
|
+
const pass = changelogVersion === pkgVersion;
|
|
73
|
+
return {
|
|
74
|
+
type: 'changelog_version',
|
|
75
|
+
label: 'CHANGELOG Version',
|
|
76
|
+
pass,
|
|
77
|
+
message: pass ? undefined : `CHANGELOG.md 版本 ${changelogVersion} !== package.json 版本 ${pkgVersion}`,
|
|
78
|
+
detail: { changelogVersion, pkgVersion },
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
return { type: 'changelog_version', label: 'CHANGELOG Version', pass: true };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// ── context_docs ─────────────────────────────────────────────────
|
|
86
|
+
checkContextDocs(check, ctx) {
|
|
87
|
+
const dirs = check.dirs || ctx.requiredDirs;
|
|
88
|
+
if (!dirs || dirs.length === 0) {
|
|
89
|
+
return { type: 'context_docs', label: 'CONTEXT.md', pass: true };
|
|
90
|
+
}
|
|
91
|
+
const docName = check.doc_name || 'CONTEXT.md';
|
|
92
|
+
const missing = [];
|
|
93
|
+
for (const dir of dirs) {
|
|
94
|
+
const docPath = (0, path_1.join)(ctx.projectPath, dir, docName);
|
|
95
|
+
if (!(0, fs_1.existsSync)(docPath)) {
|
|
96
|
+
missing.push(dir);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const pass = missing.length === 0;
|
|
100
|
+
return {
|
|
101
|
+
type: 'context_docs',
|
|
102
|
+
label: 'CONTEXT.md',
|
|
103
|
+
pass,
|
|
104
|
+
message: pass ? undefined : `缺少 ${docName}: ${missing.join(', ')}`,
|
|
105
|
+
detail: { missing, doc_name: docName },
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
// ── doc_dir_check ────────────────────────────────────────────────
|
|
109
|
+
checkDocDir(check, ctx) {
|
|
110
|
+
try {
|
|
111
|
+
const docPath = (0, path_1.join)(ctx.projectPath, check.doc);
|
|
112
|
+
if (!(0, fs_1.existsSync)(docPath)) {
|
|
113
|
+
return {
|
|
114
|
+
type: 'doc_dir_check',
|
|
115
|
+
label: `${check.doc} / ${check.section}`,
|
|
116
|
+
pass: true,
|
|
117
|
+
message: `${check.doc} 不存在,跳过检查`,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const content = (0, fs_1.readFileSync)(docPath, 'utf-8');
|
|
121
|
+
// 提取目标章节($ 不要求末尾有 \n,适配无 trailing newline 的内容)
|
|
122
|
+
const sectionRegex = new RegExp(`## ${this.escapeRegExp(check.section)}\\s*\\n([\\s\\S]*?)(?=\\n## |\\n---|$)`);
|
|
123
|
+
const sectionMatch = content.match(sectionRegex);
|
|
124
|
+
if (!sectionMatch) {
|
|
125
|
+
return {
|
|
126
|
+
type: 'doc_dir_check',
|
|
127
|
+
label: `${check.doc} / ${check.section}`,
|
|
128
|
+
pass: true,
|
|
129
|
+
message: `未找到 "${check.section}" 章节`,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
const section = sectionMatch[1];
|
|
133
|
+
// 提取目录
|
|
134
|
+
const dirPattern = check.dir_pattern || '`([^`]+)`';
|
|
135
|
+
const dirRegex = new RegExp(dirPattern, 'g');
|
|
136
|
+
const docDirs = new Set();
|
|
137
|
+
let match;
|
|
138
|
+
while ((match = dirRegex.exec(section)) !== null) {
|
|
139
|
+
const dirPath = match[1].replace(/\/$/, '').trim();
|
|
140
|
+
// 只收集看起来像目录的路径(包含 / 或以特定前缀开头)
|
|
141
|
+
// 宽松匹配:任何非空字符串
|
|
142
|
+
if (dirPath.length > 0) {
|
|
143
|
+
docDirs.add(dirPath);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (docDirs.size === 0) {
|
|
147
|
+
return {
|
|
148
|
+
type: 'doc_dir_check',
|
|
149
|
+
label: `${check.doc} / ${check.section}`,
|
|
150
|
+
pass: true,
|
|
151
|
+
message: `"${check.section}" 章节中未找到目录引用`,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
const failures = [];
|
|
155
|
+
// 1. doc → fs: 文档中每个目录必须实际存在于磁盘
|
|
156
|
+
for (const dir of docDirs) {
|
|
157
|
+
if (!(0, fs_1.existsSync)((0, path_1.join)(ctx.projectPath, dir))) {
|
|
158
|
+
failures.push(`文档引用但不存在: ${dir}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// 2. fs → doc: 每个实际目录必须在文档中被覆盖
|
|
162
|
+
if (!check.skip_reverse_check) {
|
|
163
|
+
// 从文档目录中推断要扫描的根目录集
|
|
164
|
+
const rootDirs = this.inferRootDirs(docDirs, ctx.projectPath);
|
|
165
|
+
const excludeSet = new Set(check.exclude || ['__tests__', 'node_modules', 'dist']);
|
|
166
|
+
for (const rootDir of rootDirs) {
|
|
167
|
+
const absRoot = (0, path_1.join)(ctx.projectPath, rootDir);
|
|
168
|
+
if (!(0, fs_1.existsSync)(absRoot))
|
|
169
|
+
continue;
|
|
170
|
+
try {
|
|
171
|
+
const entries = (0, fs_1.readdirSync)(absRoot, { withFileTypes: true });
|
|
172
|
+
for (const entry of entries) {
|
|
173
|
+
if (!entry.isDirectory())
|
|
174
|
+
continue;
|
|
175
|
+
if (excludeSet.has(entry.name))
|
|
176
|
+
continue;
|
|
177
|
+
if (entry.name.startsWith('__') || entry.name.startsWith('.'))
|
|
178
|
+
continue;
|
|
179
|
+
const actualDir = `${rootDir}/${entry.name}`;
|
|
180
|
+
// 直接匹配 or 任何文档条目是该目录的子目录
|
|
181
|
+
if (docDirs.has(actualDir))
|
|
182
|
+
continue;
|
|
183
|
+
const covered = [...docDirs].some(d => d.startsWith(actualDir + '/'));
|
|
184
|
+
if (!covered) {
|
|
185
|
+
failures.push(`存在但未在文档中覆盖: ${actualDir}`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
// 扫描失败,跳过
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const pass = failures.length === 0;
|
|
195
|
+
return {
|
|
196
|
+
type: 'doc_dir_check',
|
|
197
|
+
label: `${check.doc} / ${check.section}`,
|
|
198
|
+
pass,
|
|
199
|
+
message: pass ? undefined : failures.join('; '),
|
|
200
|
+
detail: { docDirs: [...docDirs], failures },
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
return {
|
|
205
|
+
type: 'doc_dir_check',
|
|
206
|
+
label: `${check.doc} / ${check.section}`,
|
|
207
|
+
pass: true,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* 从文档目录集合推断要扫描的根目录
|
|
213
|
+
* 例如 ["src/core", "src/cli/commands"] → ["src"]
|
|
214
|
+
*/
|
|
215
|
+
inferRootDirs(docDirs, projectPath) {
|
|
216
|
+
const roots = new Set();
|
|
217
|
+
for (const dir of docDirs) {
|
|
218
|
+
// 取第一个路径段之前的公共部分
|
|
219
|
+
const parts = dir.split('/');
|
|
220
|
+
// 收集可能的根(单段目录如 "src/xxx" → 根是 "src")
|
|
221
|
+
if (parts.length >= 2) {
|
|
222
|
+
roots.add(parts.slice(0, parts.length - 1).join('/') || parts[0]);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// 合并为最小公共根集
|
|
226
|
+
// 简单策略:如果有 "src/a" 和 "src/b",则根是 "src"
|
|
227
|
+
const merged = new Set();
|
|
228
|
+
for (const root of roots) {
|
|
229
|
+
let isSubsumed = false;
|
|
230
|
+
for (const other of roots) {
|
|
231
|
+
if (root !== other && root.startsWith(other + '/')) {
|
|
232
|
+
isSubsumed = true;
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (!isSubsumed) {
|
|
237
|
+
merged.add(root);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return merged.size > 0 ? [...merged] : ['src'];
|
|
241
|
+
}
|
|
242
|
+
// ── doc_regex_count ──────────────────────────────────────────────
|
|
243
|
+
checkDocRegexCount(check, ctx) {
|
|
244
|
+
try {
|
|
245
|
+
const docPath = (0, path_1.join)(ctx.projectPath, check.doc);
|
|
246
|
+
if (!(0, fs_1.existsSync)(docPath)) {
|
|
247
|
+
return {
|
|
248
|
+
type: 'doc_regex_count',
|
|
249
|
+
label: `${check.doc} / ${check.label}`,
|
|
250
|
+
pass: true,
|
|
251
|
+
message: `${check.doc} 不存在,跳过检查`,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
const content = (0, fs_1.readFileSync)(docPath, 'utf-8');
|
|
255
|
+
// 从文档中提取声明的计数
|
|
256
|
+
const countRegex = new RegExp(check.pattern);
|
|
257
|
+
const countMatch = content.match(countRegex);
|
|
258
|
+
if (!countMatch || countMatch[1] === undefined) {
|
|
259
|
+
return {
|
|
260
|
+
type: 'doc_regex_count',
|
|
261
|
+
label: `${check.doc} / ${check.label}`,
|
|
262
|
+
pass: true,
|
|
263
|
+
message: `未在 ${check.doc} 中找到匹配 "${check.label}" 的计数行`,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
const docCount = parseInt(countMatch[1], 10);
|
|
267
|
+
if (isNaN(docCount)) {
|
|
268
|
+
return {
|
|
269
|
+
type: 'doc_regex_count',
|
|
270
|
+
label: `${check.doc} / ${check.label}`,
|
|
271
|
+
pass: true,
|
|
272
|
+
message: `计数解析失败: ${countMatch[1]}`,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
// 获取实际计数
|
|
276
|
+
let actualCount;
|
|
277
|
+
if (check.actual.kind === 'dir_count') {
|
|
278
|
+
actualCount = this.countFromDir(check.actual.path, check.actual.extension || '.ts', check.actual.exclude || [], ctx.projectPath);
|
|
279
|
+
}
|
|
280
|
+
else if (check.actual.kind === 'grep_count') {
|
|
281
|
+
actualCount = this.countFromGrep(ctx.projectPath, check.actual.glob, check.actual.pattern);
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
actualCount = check.actual.value;
|
|
285
|
+
}
|
|
286
|
+
if (actualCount < 0) {
|
|
287
|
+
return {
|
|
288
|
+
type: 'doc_regex_count',
|
|
289
|
+
label: `${check.doc} / ${check.label}`,
|
|
290
|
+
pass: true,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
const pass = docCount === actualCount;
|
|
294
|
+
return {
|
|
295
|
+
type: 'doc_regex_count',
|
|
296
|
+
label: `${check.doc} / ${check.label}`,
|
|
297
|
+
pass,
|
|
298
|
+
message: pass ? undefined : `${check.label}: 文档 ${docCount} → 实际 ${actualCount}`,
|
|
299
|
+
detail: { docCount, actualCount },
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
catch {
|
|
303
|
+
return {
|
|
304
|
+
type: 'doc_regex_count',
|
|
305
|
+
label: `${check.doc} / ${check.label}`,
|
|
306
|
+
pass: true,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* 从目录中计数匹配的文件/条目
|
|
312
|
+
*/
|
|
313
|
+
countFromDir(dirPath, extension, exclude, projectPath) {
|
|
314
|
+
const absDir = (0, path_1.join)(projectPath, dirPath);
|
|
315
|
+
if (!(0, fs_1.existsSync)(absDir))
|
|
316
|
+
return -1;
|
|
317
|
+
try {
|
|
318
|
+
const entries = (0, fs_1.readdirSync)(absDir, { withFileTypes: true });
|
|
319
|
+
const excludeSet = new Set(exclude);
|
|
320
|
+
let count = 0;
|
|
321
|
+
for (const entry of entries) {
|
|
322
|
+
if (excludeSet.has(entry.name))
|
|
323
|
+
continue;
|
|
324
|
+
if (entry.isDirectory() && !entry.name.startsWith('__') && !entry.name.startsWith('.')) {
|
|
325
|
+
// 目录:计 1(.ts 过滤不适用于目录)
|
|
326
|
+
count++;
|
|
327
|
+
}
|
|
328
|
+
else if (entry.isFile() && entry.name.endsWith(extension)) {
|
|
329
|
+
// 排除 .d.ts
|
|
330
|
+
if (!entry.name.endsWith('.d.ts')) {
|
|
331
|
+
count++;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return count;
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
return -1;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* 从 grep 匹配中计数
|
|
343
|
+
*/
|
|
344
|
+
countFromGrep(projectPath, globPattern, pattern) {
|
|
345
|
+
try {
|
|
346
|
+
// globPattern 如 "src/gates/*.ts"
|
|
347
|
+
const absGlob = (0, path_1.join)(projectPath, globPattern);
|
|
348
|
+
// 分离目录和文件名模式
|
|
349
|
+
const lastSlash = absGlob.lastIndexOf('/');
|
|
350
|
+
const searchDir = absGlob.substring(0, lastSlash);
|
|
351
|
+
const filePattern = absGlob.substring(lastSlash + 1);
|
|
352
|
+
if (!(0, fs_1.existsSync)(searchDir))
|
|
353
|
+
return -1;
|
|
354
|
+
// 将 glob * 转换为简单的 endsWith 检查
|
|
355
|
+
const suffix = filePattern.replace(/\*/g, '');
|
|
356
|
+
const entries = (0, fs_1.readdirSync)(searchDir, { withFileTypes: true });
|
|
357
|
+
const reg = new RegExp(pattern);
|
|
358
|
+
let count = 0;
|
|
359
|
+
for (const entry of entries) {
|
|
360
|
+
if (!entry.isFile())
|
|
361
|
+
continue;
|
|
362
|
+
if (!entry.name.endsWith(suffix))
|
|
363
|
+
continue;
|
|
364
|
+
try {
|
|
365
|
+
const content = (0, fs_1.readFileSync)((0, path_1.join)(searchDir, entry.name), 'utf-8');
|
|
366
|
+
const matches = content.match(new RegExp(pattern, 'g'));
|
|
367
|
+
if (matches) {
|
|
368
|
+
count += matches.length;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
catch {
|
|
372
|
+
// skip
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return count;
|
|
376
|
+
}
|
|
377
|
+
catch {
|
|
378
|
+
return -1;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
// ── helpers ──────────────────────────────────────────────────────
|
|
382
|
+
escapeRegExp(str) {
|
|
383
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
exports.FreshnessRunner = FreshnessRunner;
|
|
387
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../../src/core/constraints/doc-freshness/runner.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,2BAAqE;AACrE,+BAAgD;AAyChD;;GAEG;AACH,MAAa,eAAe;IAC1B;;OAEG;IACH,MAAM,CACJ,MAA0B,EAC1B,WAAmB,EACnB,GAA+G;QAE/G,IAAI,MAAM,CAAC,OAAO,KAAK,KAAK;YAAE,OAAO,EAAE,CAAC;QACxC,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAE5D,MAAM,OAAO,GAAe;YAC1B,WAAW;YACX,YAAY,EAAE,GAAG,EAAE,YAAY;YAC/B,gBAAgB,EAAE,GAAG,EAAE,gBAAgB;SACxC,CAAC;QAEF,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IACpE,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,KAAwB,EAAE,OAAmB;QACrD,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;YACnB,KAAK,mBAAmB;gBACtB,OAAO,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACpD,KAAK,cAAc;gBACjB,OAAO,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAA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AO,KAAK,CAAC;QACf,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,CAAC,CAAC;QACZ,CAAC;IACH,CAAC;IAED,oEAAoE;IAE5D,YAAY,CAAC,GAAW;QAC9B,OAAO,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;CACF;AAhbD,0CAgbC"}
|
|
@@ -13,9 +13,9 @@ const ROLE_TRIGGERS = {
|
|
|
13
13
|
executor: ['code_implementation', 'task_completion_claim', 'test_creation', 'api_change', 'file_modification', 'module_modification', 'module_creation'],
|
|
14
14
|
integration: ['code_implementation'],
|
|
15
15
|
reviewer: ['code_implementation'],
|
|
16
|
-
deploy: [],
|
|
17
|
-
monitor: [],
|
|
18
|
-
triage: [],
|
|
16
|
+
deploy: ['diagnosis'],
|
|
17
|
+
monitor: ['monitoring', 'diagnosis'],
|
|
18
|
+
triage: ['triage', 'diagnosis'],
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
21
|
* Format all applicable constraints as a prompt injection section for a given agent role.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-injection.js","sourceRoot":"","sources":["../../../src/core/constraints/prompt-injection.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAqBH,gEA4CC;AA/DD,+CAAkD;AAKlD,MAAM,aAAa,GAA2C;IAC5D,OAAO,EAAE,CAAC,gBAAgB,EAAE,YAAY,EAAE,qBAAqB,CAAC;IAChE,QAAQ,EAAE,CAAC,qBAAqB,EAAE,uBAAuB,EAAE,eAAe,EAAE,YAAY,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,iBAAiB,CAAC;IACxJ,WAAW,EAAE,CAAC,qBAAqB,CAAC;IACpC,QAAQ,EAAE,CAAC,qBAAqB,CAAC;IACjC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"prompt-injection.js","sourceRoot":"","sources":["../../../src/core/constraints/prompt-injection.ts"],"names":[],"mappings":";AAAA;;;;;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G;IACH,OAAO,CAAC,WAAW;IAOnB;;OAEG;IACH,OAAO,CAAC,eAAe;IAUvB;;OAEG;IACH,OAAO,CAAC,YAAY;CAarB;AAGD,eAAO,MAAM,mBAAmB,qBAAoC,CAAC;AAErE;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,gBAAgB,CAAC,CAE3B"}
|
|
@@ -374,6 +374,29 @@ class CheckpointValidator {
|
|
|
374
374
|
expected,
|
|
375
375
|
};
|
|
376
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* HTTP 调用重试(处理 httpbin rate-limit 503/429)
|
|
379
|
+
*/
|
|
380
|
+
async fetchWithRetry(url, init, retries = 3) {
|
|
381
|
+
let lastError;
|
|
382
|
+
for (let i = 0; i <= retries; i++) {
|
|
383
|
+
try {
|
|
384
|
+
const response = await fetch(url, init);
|
|
385
|
+
// 5xx / 429 → 重试,指数退避
|
|
386
|
+
if (!response.ok && i < retries && (response.status >= 500 || response.status === 429)) {
|
|
387
|
+
await new Promise(r => setTimeout(r, 2000 * (i + 1)));
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
return response;
|
|
391
|
+
}
|
|
392
|
+
catch (e) {
|
|
393
|
+
lastError = e;
|
|
394
|
+
if (i < retries)
|
|
395
|
+
await new Promise(r => setTimeout(r, 2000 * (i + 1)));
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
throw lastError;
|
|
399
|
+
}
|
|
377
400
|
/**
|
|
378
401
|
* 检查 HTTP 状态码
|
|
379
402
|
*/
|
|
@@ -381,7 +404,7 @@ class CheckpointValidator {
|
|
|
381
404
|
const url = check.config.url || '';
|
|
382
405
|
const expected = check.config.expectedStatus || check.config.expected || 200;
|
|
383
406
|
try {
|
|
384
|
-
const response = await
|
|
407
|
+
const response = await this.fetchWithRetry(url, { signal: AbortSignal.timeout(10000) });
|
|
385
408
|
const actual = response.status;
|
|
386
409
|
const matches = actual === expected;
|
|
387
410
|
return {
|
|
@@ -410,7 +433,7 @@ class CheckpointValidator {
|
|
|
410
433
|
const url = check.config.url || '';
|
|
411
434
|
const expected = String(check.config.expected || '');
|
|
412
435
|
try {
|
|
413
|
-
const response = await
|
|
436
|
+
const response = await this.fetchWithRetry(url, {
|
|
414
437
|
method: check.config.method || 'GET',
|
|
415
438
|
headers: check.config.headers,
|
|
416
439
|
body: check.config.body ? JSON.stringify(check.config.body) : undefined,
|