@dommaker/harness 4.0.1 → 4.0.2
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/bootstrap/bootstrap.d.ts +15 -0
- package/dist/bootstrap/bootstrap.js +18 -1
- package/dist/bootstrap/index.d.ts +2 -2
- package/dist/bootstrap/index.js +3 -2
- package/dist/cli/commands/acceptance.d.ts +8 -0
- package/dist/cli/commands/acceptance.js +45 -24
- package/dist/cli/commands/check.d.ts +2 -0
- package/dist/cli/commands/check.js +36 -5
- package/dist/cli/commands/command.js +1 -1
- package/dist/cli/commands/definitions.js +3 -0
- package/dist/cli/commands/release.d.ts +11 -3
- package/dist/cli/commands/release.js +159 -52
- package/dist/cli/commands/report.d.ts +2 -0
- package/dist/cli/commands/report.js +54 -6
- package/dist/cli/commands/security.d.ts +3 -3
- package/dist/cli/commands/security.js +3 -2
- package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts +3 -40
- package/dist/cli/commands/sync-docs/capabilities-syncer.js +5 -159
- package/dist/cli/commands/sync-docs/compact.js +2 -2
- package/dist/cli/commands/sync-docs/context-syncer.d.ts +4 -36
- package/dist/cli/commands/sync-docs/context-syncer.js +4 -221
- package/dist/cli/commands/sync-docs/index.d.ts +8 -8
- package/dist/cli/commands/sync-docs/index.js +8 -8
- package/dist/cli/commands/sync-docs/main-flow.d.ts +5 -4
- package/dist/cli/commands/sync-docs/main-flow.js +6 -5
- package/dist/cli/commands/sync-docs/sync-output.d.ts +1 -1
- package/dist/cli/commands/sync-docs/sync-output.js +4 -0
- package/dist/cli/commands/sync-docs/sync-writes.d.ts +1 -1
- package/dist/cli/commands/validate.d.ts +2 -0
- package/dist/cli/commands/validate.js +40 -1
- package/dist/core/command-execution-policy.d.ts +59 -0
- package/dist/core/command-execution-policy.js +167 -0
- package/dist/core/constraints/capabilities-parser.d.ts +2 -1
- package/dist/core/constraints/capabilities-parser.js +2 -1
- package/dist/core/constraints/checker.d.ts +17 -5
- package/dist/core/constraints/checker.js +20 -10
- package/dist/core/constraints/checkers/no-hardcoded-credentials.js +14 -15
- package/dist/core/constraints/checkers/no-test-simplification.js +8 -6
- package/dist/core/constraints/checkers/templated/exec.d.ts +4 -0
- package/dist/core/constraints/checkers/templated/exec.js +11 -48
- package/dist/core/constraints/checkers/templated/file-exists.js +7 -4
- package/dist/core/constraints/checkers/templated/regex-scan.js +11 -15
- package/dist/core/constraints/checkers/types.d.ts +13 -2
- package/dist/core/constraints/checkers/types.js +5 -2
- package/dist/core/constraints/construction-sites.d.ts +1 -1
- package/dist/core/constraints/construction-sites.js +1 -1
- package/dist/core/constraints/injection-writer.d.ts +1 -1
- package/dist/core/constraints/injection-writer.js +1 -1
- package/dist/core/constraints/project-snapshot.d.ts +43 -0
- package/dist/core/constraints/project-snapshot.js +103 -0
- package/dist/core/constraints/run-env.d.ts +35 -0
- package/dist/core/constraints/run-env.js +36 -0
- package/dist/{cli/commands/sync-docs → core/docs-sync}/agents-syncer.d.ts +2 -0
- package/dist/{cli/commands/sync-docs → core/docs-sync}/agents-syncer.js +5 -3
- package/dist/core/docs-sync/capabilities-table.d.ts +46 -0
- package/dist/core/docs-sync/capabilities-table.js +200 -0
- package/dist/core/docs-sync/context-collector.d.ts +40 -0
- package/dist/core/docs-sync/context-collector.js +227 -0
- package/dist/{cli/commands/sync-docs → core/docs-sync}/project-reader.d.ts +5 -1
- package/dist/{cli/commands/sync-docs → core/docs-sync}/project-reader.js +10 -6
- package/dist/{cli/commands/sync-docs → core/docs-sync}/sync-state.d.ts +15 -9
- package/dist/{cli/commands/sync-docs → core/docs-sync}/sync-state.js +26 -29
- package/dist/core/validators/check-handlers/command.js +22 -0
- package/dist/core/validators/check-handlers/output.js +26 -3
- package/dist/core/validators/checkpoint.d.ts +4 -0
- package/dist/core/validators/checkpoint.js +10 -2
- package/dist/gates/acceptance.d.ts +8 -3
- package/dist/gates/acceptance.js +76 -13
- package/dist/gates/command.d.ts +3 -3
- package/dist/gates/command.js +2 -2
- package/dist/gates/contract.d.ts +3 -3
- package/dist/gates/performance.d.ts +10 -3
- package/dist/gates/performance.js +49 -4
- package/dist/gates/review.d.ts +3 -3
- package/dist/gates/security.d.ts +3 -3
- package/dist/gates/security.js +26 -18
- package/dist/gates/types.d.ts +45 -16
- package/dist/knowledge/ingest.d.ts +31 -0
- package/dist/knowledge/ingest.js +192 -52
- package/dist/knowledge/lifecycle.d.ts +15 -0
- package/dist/knowledge/lifecycle.js +62 -0
- package/dist/knowledge/query.d.ts +10 -0
- package/dist/knowledge/query.js +60 -8
- package/dist/knowledge/store.d.ts +56 -3
- package/dist/knowledge/store.js +108 -30
- package/dist/types/checkpoint.d.ts +28 -1
- package/dist/types/command-execution-policy.d.ts +73 -0
- package/dist/types/command-execution-policy.js +16 -0
- package/dist/utils/exec.d.ts +7 -1
- package/dist/utils/exec.js +7 -1
- package/package.json +1 -1
- package/dist/core/constraints/check-cache.d.ts +0 -43
- package/dist/core/constraints/check-cache.js +0 -77
- package/dist/core/constraints/checkers/templated/glob.d.ts +0 -8
- package/dist/core/constraints/checkers/templated/glob.js +0 -14
- /package/dist/{cli/commands/sync-docs → core/docs-sync}/preserve-block.d.ts +0 -0
- /package/dist/{cli/commands/sync-docs → core/docs-sync}/preserve-block.js +0 -0
|
@@ -21,10 +21,14 @@
|
|
|
21
21
|
* ADR-0040 Phase 3:目录正名 `hooks/` → `bootstrap/`(职责是组合根,目录名不再沿用
|
|
22
22
|
* 历史);`loadConfigAsync` 假 async(async 壳包纯同步调用)改同步 `loadConfig`,
|
|
23
23
|
* 两个入口的逐字重复装配并为一枚 `assembleHarness`。
|
|
24
|
+
*
|
|
25
|
+
* P1.1:checker 的 trace 接线收进唯一装配函数 `assembleConstraintChecker`——
|
|
26
|
+
* CLI check/report 与 bootstrapHarness 共用,接线只写一次。
|
|
24
27
|
*/
|
|
25
28
|
import { ConstraintChecker } from '../core/constraints/checker';
|
|
26
29
|
import { SessionManager } from '../context/session-manager';
|
|
27
30
|
import type { MergedConstraintsConfig } from '../types/project-config';
|
|
31
|
+
import type { CommandExecutionPolicy } from '../types/command-execution-policy';
|
|
28
32
|
/**
|
|
29
33
|
* Bootstrap 结果
|
|
30
34
|
*
|
|
@@ -42,6 +46,17 @@ export interface HarnessBootstrap {
|
|
|
42
46
|
/** 合并后的约束配置 */
|
|
43
47
|
mergedConstraints: MergedConstraintsConfig;
|
|
44
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* 生产侧唯一 checker 装配点(P1.1):trace 记录器锚根接线只写一次
|
|
51
|
+
*
|
|
52
|
+
* harness#88:core 不上行依赖 monitoring,故接线住组合根本层;
|
|
53
|
+
* #139:落点跟根走,不落调用方 cwd。CLI check/report 与 bootstrapHarness
|
|
54
|
+
* 全部经本函数取接线好的 checker——源形状闸见 src/__tests__/unique-assembly.test.ts。
|
|
55
|
+
*
|
|
56
|
+
* commandPolicy(D3 P0.5 Phase 1):一次运行的统一命令执行策略,透传 checker
|
|
57
|
+
* (read-only 下 exec 模板 checker 三态跳过项目声明命令);缺省 = 默认执行。
|
|
58
|
+
*/
|
|
59
|
+
export declare function assembleConstraintChecker(projectPath: string, commandPolicy?: CommandExecutionPolicy): ConstraintChecker;
|
|
45
60
|
/**
|
|
46
61
|
* 初始化 harness 运行环境(异步面:配置读取是同步 fs,async 仅为公共签名兼容)
|
|
47
62
|
*
|
|
@@ -22,8 +22,12 @@
|
|
|
22
22
|
* ADR-0040 Phase 3:目录正名 `hooks/` → `bootstrap/`(职责是组合根,目录名不再沿用
|
|
23
23
|
* 历史);`loadConfigAsync` 假 async(async 壳包纯同步调用)改同步 `loadConfig`,
|
|
24
24
|
* 两个入口的逐字重复装配并为一枚 `assembleHarness`。
|
|
25
|
+
*
|
|
26
|
+
* P1.1:checker 的 trace 接线收进唯一装配函数 `assembleConstraintChecker`——
|
|
27
|
+
* CLI check/report 与 bootstrapHarness 共用,接线只写一次。
|
|
25
28
|
*/
|
|
26
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.assembleConstraintChecker = assembleConstraintChecker;
|
|
27
31
|
exports.bootstrapHarness = bootstrapHarness;
|
|
28
32
|
exports.bootstrapHarnessSync = bootstrapHarnessSync;
|
|
29
33
|
const checker_1 = require("../core/constraints/checker");
|
|
@@ -44,13 +48,26 @@ function loadConfig(projectPath) {
|
|
|
44
48
|
mergedConstraints: loader.mergeConstraints(),
|
|
45
49
|
};
|
|
46
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* 生产侧唯一 checker 装配点(P1.1):trace 记录器锚根接线只写一次
|
|
53
|
+
*
|
|
54
|
+
* harness#88:core 不上行依赖 monitoring,故接线住组合根本层;
|
|
55
|
+
* #139:落点跟根走,不落调用方 cwd。CLI check/report 与 bootstrapHarness
|
|
56
|
+
* 全部经本函数取接线好的 checker——源形状闸见 src/__tests__/unique-assembly.test.ts。
|
|
57
|
+
*
|
|
58
|
+
* commandPolicy(D3 P0.5 Phase 1):一次运行的统一命令执行策略,透传 checker
|
|
59
|
+
* (read-only 下 exec 模板 checker 三态跳过项目声明命令);缺省 = 默认执行。
|
|
60
|
+
*/
|
|
61
|
+
function assembleConstraintChecker(projectPath, commandPolicy) {
|
|
62
|
+
return new checker_1.ConstraintChecker(new traces_1.TraceCollector({ projectPath }), commandPolicy);
|
|
63
|
+
}
|
|
47
64
|
/**
|
|
48
65
|
* 装配 harness 运行环境(两个入口共用的一段):
|
|
49
66
|
* trace 记录器锚根构造(#139):入口本就收 projectPath,落点必须跟着根走
|
|
50
67
|
*/
|
|
51
68
|
function assembleHarness(resolvedPath, mergedConstraints) {
|
|
52
69
|
return {
|
|
53
|
-
checker:
|
|
70
|
+
checker: assembleConstraintChecker(resolvedPath),
|
|
54
71
|
sessions: new session_manager_1.SessionManager(resolvedPath),
|
|
55
72
|
projectPath: resolvedPath,
|
|
56
73
|
mergedConstraints,
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* ADR-0027(#170)起本层只剩 `bootstrap.ts` 一个面:通用 hook 管线
|
|
5
5
|
* (registry / pipeline / config / types 四文件)双仓零生产消费者,整体删除。
|
|
6
|
-
* 目录原名 hooks/ 沿用历史,ADR-
|
|
6
|
+
* 目录原名 hooks/ 沿用历史,ADR-0041 Phase 3 正名 bootstrap/——职责是
|
|
7
7
|
* harness 运行环境的组合根。
|
|
8
8
|
*/
|
|
9
|
-
export { bootstrapHarness, bootstrapHarnessSync } from './bootstrap';
|
|
9
|
+
export { bootstrapHarness, bootstrapHarnessSync, assembleConstraintChecker } from './bootstrap';
|
|
10
10
|
export type { HarnessBootstrap } from './bootstrap';
|
package/dist/bootstrap/index.js
CHANGED
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
*
|
|
5
5
|
* ADR-0027(#170)起本层只剩 `bootstrap.ts` 一个面:通用 hook 管线
|
|
6
6
|
* (registry / pipeline / config / types 四文件)双仓零生产消费者,整体删除。
|
|
7
|
-
* 目录原名 hooks/ 沿用历史,ADR-
|
|
7
|
+
* 目录原名 hooks/ 沿用历史,ADR-0041 Phase 3 正名 bootstrap/——职责是
|
|
8
8
|
* harness 运行环境的组合根。
|
|
9
9
|
*/
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.bootstrapHarnessSync = exports.bootstrapHarness = void 0;
|
|
11
|
+
exports.assembleConstraintChecker = exports.bootstrapHarnessSync = exports.bootstrapHarness = void 0;
|
|
12
12
|
var bootstrap_1 = require("./bootstrap");
|
|
13
13
|
Object.defineProperty(exports, "bootstrapHarness", { enumerable: true, get: function () { return bootstrap_1.bootstrapHarness; } });
|
|
14
14
|
Object.defineProperty(exports, "bootstrapHarnessSync", { enumerable: true, get: function () { return bootstrap_1.bootstrapHarnessSync; } });
|
|
15
|
+
Object.defineProperty(exports, "assembleConstraintChecker", { enumerable: true, get: function () { return bootstrap_1.assembleConstraintChecker; } });
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* harness acceptance 命令
|
|
3
3
|
*
|
|
4
4
|
* 验收标准门控,检查任务是否满足验收标准
|
|
5
|
+
*
|
|
6
|
+
* D5:list 子命令与 SpecAcceptanceGate 共同消费 gates/tasks-file 的
|
|
7
|
+
* parseTasksFile——tasks.yml 的 YAML 解析、形状校验与错误语义只有一份正本。
|
|
8
|
+
* 解析失败 fail-fast(kind:fail,bin 退出 1),不存在静默 skip/空列表。
|
|
5
9
|
*/
|
|
6
10
|
import { type CommandIO, type CommandResult } from '../command-contract';
|
|
7
11
|
export interface AcceptanceOptions {
|
|
@@ -22,5 +26,9 @@ export interface AcceptanceOptions {
|
|
|
22
26
|
export declare function acceptance(options: AcceptanceOptions, io?: CommandIO): Promise<CommandResult>;
|
|
23
27
|
/**
|
|
24
28
|
* 列出所有任务及其验收标准
|
|
29
|
+
*
|
|
30
|
+
* 与门禁同一解析契约:读取失败里只有 ENOENT 走「无 tasks.yml 即跳过」(与门禁
|
|
31
|
+
* passed:true 的跳过语义一致,kind:skip → 退出 0);其余读取失败与一切解析/
|
|
32
|
+
* 形状错误一律 fail-fast(kind:fail → 退出 1),不静默 skip、不返回空列表。
|
|
25
33
|
*/
|
|
26
34
|
export declare function listAcceptanceCriteria(options: AcceptanceOptions, io?: CommandIO): Promise<CommandResult>;
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* harness acceptance 命令
|
|
4
4
|
*
|
|
5
5
|
* 验收标准门控,检查任务是否满足验收标准
|
|
6
|
+
*
|
|
7
|
+
* D5:list 子命令与 SpecAcceptanceGate 共同消费 gates/tasks-file 的
|
|
8
|
+
* parseTasksFile——tasks.yml 的 YAML 解析、形状校验与错误语义只有一份正本。
|
|
9
|
+
* 解析失败 fail-fast(kind:fail,bin 退出 1),不存在静默 skip/空列表。
|
|
6
10
|
*/
|
|
7
11
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
12
|
if (k2 === undefined) k2 = k;
|
|
@@ -48,6 +52,8 @@ const fs = __importStar(require("fs/promises"));
|
|
|
48
52
|
const path = __importStar(require("path"));
|
|
49
53
|
const yaml = __importStar(require("../../utils/yaml"));
|
|
50
54
|
const acceptance_1 = require("../../gates/acceptance");
|
|
55
|
+
const tasks_file_1 = require("../../gates/tasks-file");
|
|
56
|
+
const guards_1 = require("../../utils/guards");
|
|
51
57
|
const error_1 = require("../../utils/error");
|
|
52
58
|
const command_contract_1 = require("../command-contract");
|
|
53
59
|
const gate_command_1 = require("../gate-command");
|
|
@@ -88,38 +94,53 @@ async function acceptance(options, io = command_contract_1.processIO) {
|
|
|
88
94
|
}
|
|
89
95
|
/**
|
|
90
96
|
* 列出所有任务及其验收标准
|
|
97
|
+
*
|
|
98
|
+
* 与门禁同一解析契约:读取失败里只有 ENOENT 走「无 tasks.yml 即跳过」(与门禁
|
|
99
|
+
* passed:true 的跳过语义一致,kind:skip → 退出 0);其余读取失败与一切解析/
|
|
100
|
+
* 形状错误一律 fail-fast(kind:fail → 退出 1),不静默 skip、不返回空列表。
|
|
91
101
|
*/
|
|
92
102
|
async function listAcceptanceCriteria(options, io = command_contract_1.processIO) {
|
|
93
103
|
(0, command_contract_1.log)(io, chalk_1.default.blue('📋 任务验收标准列表...\n'));
|
|
94
104
|
const projectPath = options.projectPath || process.cwd();
|
|
95
|
-
|
|
105
|
+
// 与 SpecAcceptanceGate.check() 同一锚定规则:相对值一律锚 projectPath
|
|
106
|
+
const tasksPath = path.resolve(projectPath, options.tasksPath ?? 'tasks.yml');
|
|
107
|
+
let content;
|
|
96
108
|
try {
|
|
97
|
-
|
|
98
|
-
const tasks = yaml.load(content);
|
|
99
|
-
if (typeof tasks !== 'object' || tasks === null) {
|
|
100
|
-
(0, command_contract_1.log)(io, chalk_1.default.yellow('⚠️ 未找到任务定义'));
|
|
101
|
-
return { kind: 'skip', reason: `未找到任务定义: ${tasksPath}` };
|
|
102
|
-
}
|
|
103
|
-
for (const [taskId, task] of Object.entries(tasks)) {
|
|
104
|
-
if (typeof task === 'object' && task !== null) {
|
|
105
|
-
(0, command_contract_1.log)(io, chalk_1.default.cyan(`${taskId}:`));
|
|
106
|
-
const criteria = task.acceptanceCriteria;
|
|
107
|
-
if (Array.isArray(criteria)) {
|
|
108
|
-
criteria.forEach((c, i) => {
|
|
109
|
-
(0, command_contract_1.log)(io, chalk_1.default.gray(` ${i + 1}. ${String(c)}`));
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
(0, command_contract_1.log)(io, chalk_1.default.gray(' (无验收标准)'));
|
|
114
|
-
}
|
|
115
|
-
(0, command_contract_1.log)(io);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return { kind: 'ok' };
|
|
109
|
+
content = await fs.readFile(tasksPath, 'utf-8');
|
|
119
110
|
}
|
|
120
111
|
catch (error) {
|
|
121
112
|
const message = (0, error_1.errorMessage)(error);
|
|
113
|
+
if ((0, guards_1.isRecord)(error) && error.code === 'ENOENT') {
|
|
114
|
+
(0, command_contract_1.log)(io, chalk_1.default.yellow(`⚠️ 未找到 tasks.yml: ${tasksPath}`));
|
|
115
|
+
return { kind: 'skip', reason: `未找到 tasks.yml: ${tasksPath}` };
|
|
116
|
+
}
|
|
122
117
|
(0, command_contract_1.log)(io, chalk_1.default.red(`❌ 读取 tasks.yml 失败: ${message}`));
|
|
123
|
-
return { kind: '
|
|
118
|
+
return { kind: 'fail', reason: `读取 tasks.yml 失败: ${message}` };
|
|
119
|
+
}
|
|
120
|
+
// 单一解析正本:非法 YAML/形状/任务/验收条件在此抛错(fail-fast → fail,不静默 skip)
|
|
121
|
+
let tasks;
|
|
122
|
+
try {
|
|
123
|
+
tasks = (0, tasks_file_1.parseTasksFile)(yaml.load(content), tasksPath);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
const message = (0, error_1.errorMessage)(error);
|
|
127
|
+
(0, command_contract_1.log)(io, chalk_1.default.red(`❌ tasks.yml 解析失败: ${message}`));
|
|
128
|
+
return { kind: 'fail', reason: `tasks.yml 解析失败: ${message}` };
|
|
129
|
+
}
|
|
130
|
+
for (const task of tasks.tasks) {
|
|
131
|
+
(0, command_contract_1.log)(io, chalk_1.default.cyan(`${task.id}:`));
|
|
132
|
+
if (task.acceptance && task.acceptance.length > 0) {
|
|
133
|
+
task.acceptance.forEach((c, i) => {
|
|
134
|
+
const e2e = c.e2e_test
|
|
135
|
+
? ` (e2e: ${c.e2e_test}${c.test_name ? `, -g ${c.test_name}` : ''})`
|
|
136
|
+
: '';
|
|
137
|
+
(0, command_contract_1.log)(io, chalk_1.default.gray(` ${i + 1}. ${c.checked ? '[✓]' : '[ ]'} ${c.description}${e2e}`));
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
(0, command_contract_1.log)(io, chalk_1.default.gray(' (无验收标准)'));
|
|
142
|
+
}
|
|
143
|
+
(0, command_contract_1.log)(io);
|
|
124
144
|
}
|
|
145
|
+
return { kind: 'ok' };
|
|
125
146
|
}
|
|
@@ -49,13 +49,13 @@ exports.check = check;
|
|
|
49
49
|
exports.listLaws = listLaws;
|
|
50
50
|
const chalk_1 = __importDefault(require("chalk"));
|
|
51
51
|
const path = __importStar(require("path"));
|
|
52
|
-
const
|
|
52
|
+
const bootstrap_1 = require("../../bootstrap");
|
|
53
53
|
const definitions_1 = require("../../core/constraints/definitions");
|
|
54
54
|
const effective_constraints_1 = require("../../core/effective-constraints");
|
|
55
|
+
const command_execution_policy_1 = require("../../core/command-execution-policy");
|
|
55
56
|
const context_builder_1 = require("../../core/constraints/context-builder");
|
|
56
57
|
const git_evidence_1 = require("../../core/constraints/git-evidence");
|
|
57
58
|
const run_env_1 = require("../../core/constraints/run-env");
|
|
58
|
-
const traces_1 = require("../../monitoring/traces");
|
|
59
59
|
const jsonl_1 = require("../../utils/jsonl");
|
|
60
60
|
const trace_1 = require("../../types/trace");
|
|
61
61
|
const constraint_1 = require("../../types/constraint");
|
|
@@ -107,6 +107,8 @@ async function check(options, io = command_contract_1.processIO) {
|
|
|
107
107
|
// 构建上下文(工单 23:触发条件与证据检测收敛至 core/constraints/context-builder)
|
|
108
108
|
// #87:一次 run 一份 git 证据——context-builder 与 checker 层共用同一实例
|
|
109
109
|
// ADR-0023:一次 run 一份运行级观察面——配置、源根探测全部共用同一份读取
|
|
110
|
+
// 必须先于运行前清单构造:清单按 context 的 operation/extraTriggers 过滤
|
|
111
|
+
// (与 checker 分发同口径,trigger 不匹配的约束不进清单)
|
|
110
112
|
const context = (0, context_builder_1.buildConstraintContext)({
|
|
111
113
|
projectPath: options.projectPath,
|
|
112
114
|
staged: options.staged,
|
|
@@ -114,15 +116,30 @@ async function check(options, io = command_contract_1.processIO) {
|
|
|
114
116
|
evidence,
|
|
115
117
|
runEnv,
|
|
116
118
|
});
|
|
119
|
+
// 运行前清单(D3 P0.5 Phase 1):列出本次将执行的项目声明命令;--read-only 下列出被跳过的。
|
|
120
|
+
// 授权只来自 CLI flag——仓内 YAML 只声明命令,不作为授权来源。
|
|
121
|
+
const commandPlan = (0, command_execution_policy_1.planCommandsFromConstraints)(merged.constraints, context);
|
|
122
|
+
if (commandPlan.length > 0) {
|
|
123
|
+
if (options.readOnly) {
|
|
124
|
+
(0, command_contract_1.log)(io, chalk_1.default.gray(`⏭️ --read-only:跳过 ${commandPlan.length} 条项目声明命令(未执行):`));
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
(0, command_contract_1.log)(io, chalk_1.default.yellow(`⚠️ 本次将执行 ${commandPlan.length} 条项目声明命令:`));
|
|
128
|
+
}
|
|
129
|
+
(0, command_execution_policy_1.formatCommandPlan)(commandPlan).forEach(line => (0, command_contract_1.log)(io, chalk_1.default.gray(line)));
|
|
130
|
+
}
|
|
117
131
|
const changedFiles = context.changedFiles ?? [];
|
|
118
132
|
if (changedFiles.length > 0) {
|
|
119
133
|
(0, command_contract_1.log)(io, chalk_1.default.gray(`变更文件: ${changedFiles.length} 个`));
|
|
120
134
|
}
|
|
121
135
|
(0, command_contract_1.log)(io, chalk_1.default.gray(`触发条件: ${[context.operation, ...(context.extraTriggers ?? [])].join(', ')}`));
|
|
122
136
|
// 执行约束检查(per-request 传 customConfig,避免单例状态污染;证据同 run 同源)
|
|
123
|
-
// trace
|
|
124
|
-
//
|
|
125
|
-
|
|
137
|
+
// checker 经唯一装配函数取(P1.1):trace 接线只写一次,收集器锚根构造
|
|
138
|
+
// (#139:不传 projectPath 时 trace 会落进调用方 cwd,B 侧读不到)
|
|
139
|
+
// commandPolicy(D3):本 run 的统一执行策略,read-only 下 exec 模板 checker
|
|
140
|
+
// 三态跳过声明命令;缺省 = 默认执行
|
|
141
|
+
const policy = (0, command_execution_policy_1.createCommandExecutionPolicy)({ readOnly: options.readOnly });
|
|
142
|
+
const checker = (0, bootstrap_1.assembleConstraintChecker)(projectPath, policy);
|
|
126
143
|
const result = await checker.checkConstraints(context, merged, evidence, runEnv);
|
|
127
144
|
// 输出结果
|
|
128
145
|
(0, command_contract_1.log)(io);
|
|
@@ -182,6 +199,20 @@ async function check(options, io = command_contract_1.processIO) {
|
|
|
182
199
|
(0, command_contract_1.log)(io, chalk_1.default.gray(` - ${r.id}${r.skipReason ? `:${r.skipReason}` : ''}`));
|
|
183
200
|
});
|
|
184
201
|
}
|
|
202
|
+
// read-only 且本 run 有声明命令被策略跳过:不产出「已检查」结论(假绿防线)。
|
|
203
|
+
// 只认策略跳过(清单来源 ∩ 跳过结果)——其他原因(证据未接线等)的跳过维持原 ok 语义。
|
|
204
|
+
if (options.readOnly) {
|
|
205
|
+
const planSources = new Set(commandPlan.map(p => p.source));
|
|
206
|
+
const policySkipped = skippedResults.filter(r => planSources.has(r.id));
|
|
207
|
+
if (policySkipped.length > 0) {
|
|
208
|
+
(0, command_contract_1.log)(io);
|
|
209
|
+
(0, command_contract_1.log)(io, chalk_1.default.gray(`⏭️ read-only:${policySkipped.length} 条约束未评估(命令未执行),不产出「已检查」结论`));
|
|
210
|
+
return {
|
|
211
|
+
kind: 'skip',
|
|
212
|
+
reason: `--read-only: ${policySkipped.length} constraints not evaluated (commands not executed)`,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
185
216
|
(0, command_contract_1.log)(io);
|
|
186
217
|
(0, command_contract_1.log)(io, chalk_1.default.green('✅ 约束检查通过'));
|
|
187
218
|
// 智能提示
|
|
@@ -58,7 +58,7 @@ async function executeCommand(cmd, options, io = command_contract_1.processIO) {
|
|
|
58
58
|
return { kind: 'usage-error', reason: '缺少要检查的命令参数' };
|
|
59
59
|
}
|
|
60
60
|
const gate = (0, command_1.createCommandGate)();
|
|
61
|
-
// 命令门禁只判命令串、不读项目根;
|
|
61
|
+
// 命令门禁只判命令串、不读项目根;CommandGateContext 仍要求项目根——本命令无 -p 旗帜,取真实 cwd
|
|
62
62
|
const decision = await gate.evaluate({ projectPath: process.cwd(), command: cmd });
|
|
63
63
|
const result = decision.result;
|
|
64
64
|
if (options.level) {
|
|
@@ -32,6 +32,7 @@ exports.COMMAND_DEFINITIONS = [
|
|
|
32
32
|
{ flags: '-s, --staged', description: '只检查暂存文件', defaultValue: false },
|
|
33
33
|
{ flags: '-t, --trigger <trigger>', description: '触发条件' },
|
|
34
34
|
{ flags: '--project-path <path>', description: '项目路径' },
|
|
35
|
+
{ flags: '--read-only', description: '跳过项目 YAML 声明的命令执行(未评估条目明确列出,不产生「已检查」结论;D3)', defaultValue: false },
|
|
35
36
|
{ flags: '--list', description: '列出所有约束' },
|
|
36
37
|
],
|
|
37
38
|
action: { module: 'check', export: 'check' },
|
|
@@ -45,6 +46,7 @@ exports.COMMAND_DEFINITIONS = [
|
|
|
45
46
|
options: [
|
|
46
47
|
{ flags: '-f, --file <path>', description: '检查点文件路径' },
|
|
47
48
|
{ flags: '-p, --project-path <path>', description: '项目路径' },
|
|
49
|
+
{ flags: '--read-only', description: '跳过检查点声明的命令执行(未评估条目明确列出,不把跳过当验证通过;D3)', defaultValue: false },
|
|
48
50
|
],
|
|
49
51
|
action: { module: 'validate', export: 'validate' },
|
|
50
52
|
},
|
|
@@ -86,6 +88,7 @@ exports.COMMAND_DEFINITIONS = [
|
|
|
86
88
|
{ flags: '-o, --output <path>', description: '输出文件路径' },
|
|
87
89
|
{ flags: '-f, --format <format>', description: '输出格式 (json/markdown)', defaultValue: 'markdown' },
|
|
88
90
|
{ flags: '-p, --project-path <path>', description: '项目路径' },
|
|
91
|
+
{ flags: '--read-only', description: '跳过项目 YAML 声明的命令执行(报告明确标记 skipped/未执行;D3)', defaultValue: false },
|
|
89
92
|
],
|
|
90
93
|
action: { module: 'report', export: 'report' },
|
|
91
94
|
},
|
|
@@ -8,17 +8,25 @@
|
|
|
8
8
|
* 流程:
|
|
9
9
|
* 1. Verify package
|
|
10
10
|
* 2. Check branch (must be master/main) + remote sync + clean tree
|
|
11
|
-
* 3. tsc build
|
|
11
|
+
* 3. tsc build(项目本地确定的 TypeScript 可执行文件;缺失即失败,不做隐式下载)
|
|
12
12
|
* 4. Verify dist files
|
|
13
13
|
* 5. Bump version (npm version → commit + tag)
|
|
14
14
|
* 6. Push (protected branch → create release PR instead)
|
|
15
15
|
* 7. Check private flag
|
|
16
16
|
* 8. npm publish (or skip if PR flow)
|
|
17
|
-
* 9. GitHub Release
|
|
17
|
+
* 9. GitHub Release(非致命告警,既有终态保留)
|
|
18
18
|
*
|
|
19
|
-
* 判定经返回值外溢(架构评审候选7
|
|
19
|
+
* 判定经返回值外溢(架构评审候选7):前置闸门维持**首败即停**,每个闸门失败
|
|
20
20
|
* 返回 `gate <id>: <原因>`;退出码映射在 bin/harness.js 唯一一处。输出经注入 io
|
|
21
21
|
* 流式打印(分钟级子进程阶段不能静默)。
|
|
22
|
+
* 步骤判负统一按子进程退出码(D2):私有 run helper 返回 { code, stdout, stderr },
|
|
23
|
+
* code !== 0 即失败(ENOENT/超时等无数字退出码取非零缺省),不再以 stderr 文本内容
|
|
24
|
+
* 猜测成败——发布链全部会改变状态/取证的命令(git 证据命令、npm version/publish、
|
|
25
|
+
* 各次 git push、PR 流程 checkout)无一例外;仅 GitHub Release 保持既有非致命告警
|
|
26
|
+
* 终态、成功后 remote URL 查询保持装饰性降级。GH006 保护分支识别仍在非零 push 后
|
|
27
|
+
* 查看 stderr。
|
|
28
|
+
* 子进程一律 argv 形状(utils/exec 的 execFileAsync),不拼 shell 字符串;
|
|
29
|
+
* npm publish 自带 --registry,publish 前后不读写用户 npm 配置(P0.3)。
|
|
22
30
|
*/
|
|
23
31
|
import { type CommandIO, type CommandResult } from '../command-contract';
|
|
24
32
|
export interface ReleaseOptions {
|