@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
package/dist/knowledge/query.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.KnowledgeQuery = exports.EXTERNAL_SOURCE_MARKER = void 0;
|
|
10
|
+
const store_1 = require("./store");
|
|
10
11
|
const lifecycle_1 = require("./lifecycle");
|
|
11
12
|
const token_estimate_1 = require("./token-estimate");
|
|
12
13
|
const attempt_1 = require("../utils/attempt");
|
|
@@ -55,16 +56,28 @@ class KnowledgeQuery {
|
|
|
55
56
|
types: budget.focusTypes.length > 0 ? budget.focusTypes : filter?.types,
|
|
56
57
|
excludeArchived: filter?.excludeArchived ?? true,
|
|
57
58
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const
|
|
59
|
+
// D7:新索引(候选全带 tokenCount 元数据)先经 index 过滤/排序/截断,
|
|
60
|
+
// 只物化最终返回集;旧索引/外部自定义 store 走 list+applyBudget 兼容路径
|
|
61
|
+
const fromIndex = this.queryFromIndex(mergedFilter, budget);
|
|
62
|
+
let entries;
|
|
63
|
+
let tokensUsed;
|
|
64
|
+
let truncated;
|
|
65
|
+
if (fromIndex) {
|
|
66
|
+
({ entries, tokensUsed, truncated } = fromIndex);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const candidates = this.store.list(mergedFilter);
|
|
70
|
+
const sorted = this.sortEntries(candidates);
|
|
71
|
+
({ entries, tokensUsed, truncated } = this.applyBudget(sorted, budget));
|
|
72
|
+
}
|
|
61
73
|
const result = { entries, tokensUsed, truncated, fromCache: false };
|
|
62
74
|
this.cache.set(cacheKey, { result, timestamp: Date.now() });
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
// P1.3: 一次 query 的全部引用经生命周期批量记账、一次 applyAll 落盘
|
|
76
|
+
// (不再逐条 recordReference→update→全量重写 index.json)
|
|
77
|
+
// D7: 本次已物化条目作为预载传入——记账查线与合并基线零重复读取
|
|
78
|
+
// 显式 fail-open(attempt):引用记账是查询的副作用,失败不影响查询结果返回
|
|
79
|
+
const preloaded = new Map(entries.map(e => [e.id, e]));
|
|
80
|
+
(0, attempt_1.attempt)(() => this.lifecycle.recordReferences(entries.map(e => e.id), undefined, undefined, undefined, preloaded), () => undefined);
|
|
68
81
|
return result;
|
|
69
82
|
}
|
|
70
83
|
/**
|
|
@@ -150,6 +163,45 @@ class KnowledgeQuery {
|
|
|
150
163
|
}
|
|
151
164
|
// ── Internal ───────────────────────────────────────────────
|
|
152
165
|
// ── Internal ───────────────────────────────────────────────
|
|
166
|
+
/**
|
|
167
|
+
* D7 按需物化路径:候选只经 index 元数据过滤/排序/截断——被过滤排除与
|
|
168
|
+
* budget 截断掉的溢出候选全文零读取,最终返回子集才经 materializeByIndex 回读
|
|
169
|
+
* (漂移错误与 list 同一正本)。tokenCount 写入时已按 estimateTokens 两次 ceil
|
|
170
|
+
* 口径算好,tokensUsed 与兼容路径逐字相等。
|
|
171
|
+
*
|
|
172
|
+
* 返回 undefined = 走兼容路径:store 未提供 materializeByIndex(外部自定义 store)
|
|
173
|
+
* 或过滤后候选存在无 tokenCount 的旧格式条目(readIndex 会打一行 rebuildIndex 提示)。
|
|
174
|
+
*/
|
|
175
|
+
queryFromIndex(filter, budget) {
|
|
176
|
+
const materialize = this.store.materializeByIndex;
|
|
177
|
+
if (typeof materialize !== 'function')
|
|
178
|
+
return undefined;
|
|
179
|
+
const filtered = (0, store_1.filterIndexEntries)(this.store.readIndex(), filter);
|
|
180
|
+
if (!filtered.every(e => (0, store_1.indexEntryTokenCount)(e) !== undefined))
|
|
181
|
+
return undefined;
|
|
182
|
+
// 排序口径与 sortEntries 一致:maturity desc → lastReferenced desc
|
|
183
|
+
const sorted = [...filtered].sort((a, b) => {
|
|
184
|
+
const maturityDiff = MATURITY_RANK[b.maturity] - MATURITY_RANK[a.maturity];
|
|
185
|
+
if (maturityDiff !== 0)
|
|
186
|
+
return maturityDiff;
|
|
187
|
+
return (b.lastReferenced || '').localeCompare(a.lastReferenced || '');
|
|
188
|
+
});
|
|
189
|
+
const picked = [];
|
|
190
|
+
let tokensUsed = 0;
|
|
191
|
+
for (const entry of sorted) {
|
|
192
|
+
if (picked.length >= budget.maxEntries)
|
|
193
|
+
break;
|
|
194
|
+
const entryTokens = (0, store_1.indexEntryTokenCount)(entry);
|
|
195
|
+
if (entryTokens === undefined)
|
|
196
|
+
break; // 候选全带 tokenCount 已由上方 every 闸保证
|
|
197
|
+
if (tokensUsed + entryTokens > budget.maxTokens)
|
|
198
|
+
break;
|
|
199
|
+
picked.push(entry);
|
|
200
|
+
tokensUsed += entryTokens;
|
|
201
|
+
}
|
|
202
|
+
const entries = materialize.call(this.store, picked);
|
|
203
|
+
return { entries, tokensUsed, truncated: picked.length < sorted.length };
|
|
204
|
+
}
|
|
153
205
|
sortEntries(entries) {
|
|
154
206
|
return [...entries].sort((a, b) => {
|
|
155
207
|
// Primary: maturity descending
|
|
@@ -6,6 +6,22 @@
|
|
|
6
6
|
* An index.json provides fast listing without reading all files.
|
|
7
7
|
*/
|
|
8
8
|
import type { KnowledgeEntry, IndexEntry, QueryFilter, ConsumptionStats, SnapshotSurvival, StoreUpdate } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* D7:运行时 index.json 的内部扩展条目——公共 IndexEntry 不变,tokenCount 仅经
|
|
11
|
+
* store 的写路径(toIndexEntry)落盘、读路径窄化取用,属包内私有交叉类型。
|
|
12
|
+
* tokenCount = estimateTokens(content) + estimateTokens(title)(两次 ceil 的现有口径,
|
|
13
|
+
* 写入时算好,普通 query 截断就不必为被排除条目回读全文)。
|
|
14
|
+
*/
|
|
15
|
+
export type IndexEntryTokens = IndexEntry & {
|
|
16
|
+
tokenCount?: number;
|
|
17
|
+
};
|
|
18
|
+
/** 从 index 条目窄化取 tokenCount:非数字(旧格式/手改坏值)一律 undefined → 调用方走兼容路径 */
|
|
19
|
+
export declare function indexEntryTokenCount(entry: IndexEntry): number | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* D7:index 元数据过滤的唯一实现(QueryFilter 全字段)。
|
|
22
|
+
* store.list 与 KnowledgeQuery.query 共用,不各写一套过滤正本。
|
|
23
|
+
*/
|
|
24
|
+
export declare function filterIndexEntries(entries: IndexEntry[], filter: QueryFilter): IndexEntry[];
|
|
9
25
|
/**
|
|
10
26
|
* KnowledgeStore interface — abstract contract for knowledge storage.
|
|
11
27
|
*/
|
|
@@ -22,8 +38,12 @@ export interface KnowledgeStore {
|
|
|
22
38
|
/**
|
|
23
39
|
* 按 id 批量部分更新(harness#134):`update(id, partial)` 的批量形,语义与逐条一致
|
|
24
40
|
* (读不到该 id 即跳过),循环内只更新内存索引、结束一次 writeIndex。空批零读写。
|
|
41
|
+
*
|
|
42
|
+
* D7 可选第二参 `bases`:调用方已持有的 id → 完整条目预载基线(引用记账复用
|
|
43
|
+
* query 已物化条目时经此消除层间重复 get)。缺省/缺项走原 `get(id)` 读盘;
|
|
44
|
+
* 外部自定义 store 的一参实现编译与运行均兼容(多余实参被忽略)。
|
|
25
45
|
*/
|
|
26
|
-
applyAll(updates: StoreUpdate[]): void;
|
|
46
|
+
applyAll(updates: StoreUpdate[], bases?: ReadonlyMap<string, KnowledgeEntry>): void;
|
|
27
47
|
delete(id: string): boolean;
|
|
28
48
|
update(id: string, partial: Partial<KnowledgeEntry>): KnowledgeEntry | undefined;
|
|
29
49
|
rebuildIndex(): void;
|
|
@@ -37,6 +57,14 @@ export interface KnowledgeStore {
|
|
|
37
57
|
* 文件缺失或损坏 = undefined(无数据,不是零消费)
|
|
38
58
|
*/
|
|
39
59
|
getConsumptionStats(): ConsumptionStats | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* D7 按需物化可选能力:把 index 元数据条目回读为完整条目。
|
|
62
|
+
* 普通 query 先经 `readIndex()` + `filterIndexEntries` 过滤/排序/截断,
|
|
63
|
+
* 只对本方法传入最终返回子集——被过滤/截断排除的条目全文零读取。
|
|
64
|
+
* 「索引在册但条目文件缺失」的漂移错误在此实现(与 list 同一正本)。
|
|
65
|
+
* 外部自定义 store 未实现时,KnowledgeQuery 走 list+applyBudget 兼容路径。
|
|
66
|
+
*/
|
|
67
|
+
materializeByIndex?(indexEntries: IndexEntry[]): KnowledgeEntry[];
|
|
40
68
|
}
|
|
41
69
|
/**
|
|
42
70
|
* FileKnowledgeStore — file-based implementation of KnowledgeStore.
|
|
@@ -53,12 +81,20 @@ export declare class FileKnowledgeStore implements KnowledgeStore {
|
|
|
53
81
|
* 文件变更(含外部进程改写、删除)自动失效。
|
|
54
82
|
*/
|
|
55
83
|
private indexCache;
|
|
84
|
+
/** 旧格式 index(无 tokenCount)提示的实例级 once 闸(D7):不重复刷屏 */
|
|
85
|
+
private oldIndexHintShown;
|
|
56
86
|
constructor(config?: {
|
|
57
87
|
baseDir?: string;
|
|
58
88
|
});
|
|
59
89
|
getBaseDir(): string;
|
|
60
90
|
get(id: string): KnowledgeEntry | undefined;
|
|
61
91
|
list(filter?: QueryFilter): KnowledgeEntry[];
|
|
92
|
+
/**
|
|
93
|
+
* D7 按需物化:把 index 子集回读为完整条目(普通 query 截断后只物化最终返回集)。
|
|
94
|
+
* 「索引在册但条目文件缺失/不可解析」的漂移错误只在此实现一份,list() 与本方法共用;
|
|
95
|
+
* get 继续走 D6 entryPath(findFile → entryPath),不另起路径构造。
|
|
96
|
+
*/
|
|
97
|
+
materializeByIndex(indexEntries: IndexEntry[]): KnowledgeEntry[];
|
|
62
98
|
save(entry: KnowledgeEntry): void;
|
|
63
99
|
/**
|
|
64
100
|
* 写入闸(E1 复盘修正 M1):maturity/layer 是声明枚举(值域正本在 types.ts),
|
|
@@ -68,7 +104,7 @@ export declare class FileKnowledgeStore implements KnowledgeStore {
|
|
|
68
104
|
*/
|
|
69
105
|
private assertEnumFields;
|
|
70
106
|
saveAll(entries: KnowledgeEntry[]): void;
|
|
71
|
-
applyAll(updates: StoreUpdate[]): void;
|
|
107
|
+
applyAll(updates: StoreUpdate[], bases?: ReadonlyMap<string, KnowledgeEntry>): void;
|
|
72
108
|
delete(id: string): boolean;
|
|
73
109
|
update(id: string, partial: Partial<KnowledgeEntry>): KnowledgeEntry | undefined;
|
|
74
110
|
rebuildIndex(): void;
|
|
@@ -79,6 +115,18 @@ export declare class FileKnowledgeStore implements KnowledgeStore {
|
|
|
79
115
|
readEntriesFromDisk(): KnowledgeEntry[];
|
|
80
116
|
private ensureDirectory;
|
|
81
117
|
private entryPath;
|
|
118
|
+
/** 条目 id/type 的路径分量预校验(saveAll/applyAll 整批预校验用;落盘时 entryPath 仍会复检) */
|
|
119
|
+
private assertEntryPathSafe;
|
|
120
|
+
/**
|
|
121
|
+
* 非法路径分量判定(D6 唯一实现):id/type 只允许 baseDir 内的单文件名分量——
|
|
122
|
+
* 非空、非 '.'/'..'、不含路径分隔符(含 Windows 反斜杠)与 NUL。
|
|
123
|
+
* entryPath/findFile/save 批量预校验与 readIndex 在册校验共用此规则,不各写一套。
|
|
124
|
+
* 命中即 fail-fast 抛错,不做 basename 静默修正
|
|
125
|
+
* (旧行为会把 "../../x" 修正成 "x" 写到库内另一位置,读删路径对不上)。
|
|
126
|
+
*/
|
|
127
|
+
private isUnsafePathComponent;
|
|
128
|
+
/** 路径分量闸(写入/查询入口):命中非法分量按条目错误风格 fail-fast 抛错 */
|
|
129
|
+
private assertSafePathComponent;
|
|
82
130
|
/** 条目文件正文的唯一落盘写法(save / saveAll / applyAll 三条路径共用,#134) */
|
|
83
131
|
private writeEntryFile;
|
|
84
132
|
private findFile;
|
|
@@ -88,7 +136,6 @@ export declare class FileKnowledgeStore implements KnowledgeStore {
|
|
|
88
136
|
/** canonical 字段序是 store 的私有策略(harness#89 裁决 3),包裹格式交给 joinFrontmatter */
|
|
89
137
|
private toFrontmatter;
|
|
90
138
|
private toIndexEntry;
|
|
91
|
-
private matchesFilter;
|
|
92
139
|
/**
|
|
93
140
|
* 保存当日 index.json 快照
|
|
94
141
|
*/
|
|
@@ -107,6 +154,12 @@ export declare class FileKnowledgeStore implements KnowledgeStore {
|
|
|
107
154
|
*/
|
|
108
155
|
getConsumptionStats(): ConsumptionStats | undefined;
|
|
109
156
|
readIndex(): IndexEntry[];
|
|
157
|
+
/**
|
|
158
|
+
* index.json 条目校验(D6):任何非法 id/type 明确抛错,定位条目序号/字段/值,
|
|
159
|
+
* 提示手工修正 index.json 或核对条目文件后 rebuildIndex。校验通过才进缓存。
|
|
160
|
+
* 判定规则复用 isUnsafePathComponent,与写入/查询同一套。
|
|
161
|
+
*/
|
|
162
|
+
private assertIndexEntriesValid;
|
|
110
163
|
private writeIndex;
|
|
111
164
|
private updateIndexEntry;
|
|
112
165
|
private removeFromIndex;
|
package/dist/knowledge/store.js
CHANGED
|
@@ -41,16 +41,49 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
41
41
|
})();
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
43
|
exports.FileKnowledgeStore = void 0;
|
|
44
|
+
exports.indexEntryTokenCount = indexEntryTokenCount;
|
|
45
|
+
exports.filterIndexEntries = filterIndexEntries;
|
|
44
46
|
const fs = __importStar(require("fs"));
|
|
45
47
|
const path = __importStar(require("path"));
|
|
46
48
|
const frontmatter_1 = require("../utils/frontmatter");
|
|
47
49
|
const json_doc_1 = require("../utils/json-doc");
|
|
48
50
|
const date_1 = require("../utils/date");
|
|
49
51
|
const tree_walker_1 = require("./tree-walker");
|
|
52
|
+
const token_estimate_1 = require("./token-estimate");
|
|
50
53
|
const types_1 = require("./types");
|
|
51
54
|
const DEFAULT_DIR = '.harness/knowledge';
|
|
52
55
|
const INDEX_FILE = 'index.json';
|
|
53
56
|
const CONSUMPTION_STATS_FILE = '.consumption-stats.json';
|
|
57
|
+
/** 从 index 条目窄化取 tokenCount:非数字(旧格式/手改坏值)一律 undefined → 调用方走兼容路径 */
|
|
58
|
+
function indexEntryTokenCount(entry) {
|
|
59
|
+
const tokenCount = entry.tokenCount;
|
|
60
|
+
return typeof tokenCount === 'number' && Number.isFinite(tokenCount) ? tokenCount : undefined;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* D7:index 元数据过滤的唯一实现(QueryFilter 全字段)。
|
|
64
|
+
* store.list 与 KnowledgeQuery.query 共用,不各写一套过滤正本。
|
|
65
|
+
*/
|
|
66
|
+
function filterIndexEntries(entries, filter) {
|
|
67
|
+
return entries.filter(entry => {
|
|
68
|
+
if (filter.types && filter.types.length > 0 && !filter.types.includes(entry.type))
|
|
69
|
+
return false;
|
|
70
|
+
if (filter.maturity && filter.maturity.length > 0 && !filter.maturity.includes(entry.maturity))
|
|
71
|
+
return false;
|
|
72
|
+
if (filter.layers && filter.layers.length > 0 && !filter.layers.includes(entry.layer))
|
|
73
|
+
return false;
|
|
74
|
+
if (filter.tags && filter.tags.length > 0 && !filter.tags.some(t => (entry.tags ?? []).includes(t)))
|
|
75
|
+
return false;
|
|
76
|
+
if (filter.applicablePhases && filter.applicablePhases.length > 0 && !filter.applicablePhases.some(p => (entry.applicablePhases ?? []).includes(p)))
|
|
77
|
+
return false;
|
|
78
|
+
if (filter.excludeArchived !== false && (entry.maturity === 'archived' || entry.maturity === 'deprecated'))
|
|
79
|
+
return false;
|
|
80
|
+
if (filter.consumptionModes && filter.consumptionModes.length > 0 && !filter.consumptionModes.includes(entry.consumptionMode ?? 'reference'))
|
|
81
|
+
return false;
|
|
82
|
+
if (filter.origins && filter.origins.length > 0 && !filter.origins.includes(entry.origin ?? 'agent'))
|
|
83
|
+
return false;
|
|
84
|
+
return true;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
54
87
|
/**
|
|
55
88
|
* FileKnowledgeStore — file-based implementation of KnowledgeStore.
|
|
56
89
|
* Each entry is a markdown file with YAML frontmatter.
|
|
@@ -66,6 +99,8 @@ class FileKnowledgeStore {
|
|
|
66
99
|
* 文件变更(含外部进程改写、删除)自动失效。
|
|
67
100
|
*/
|
|
68
101
|
indexCache;
|
|
102
|
+
/** 旧格式 index(无 tokenCount)提示的实例级 once 闸(D7):不重复刷屏 */
|
|
103
|
+
oldIndexHintShown = false;
|
|
69
104
|
constructor(config) {
|
|
70
105
|
this.baseDir = config?.baseDir || DEFAULT_DIR;
|
|
71
106
|
this.ensureDirectory();
|
|
@@ -81,10 +116,16 @@ class FileKnowledgeStore {
|
|
|
81
116
|
return this.readFile(filePath);
|
|
82
117
|
}
|
|
83
118
|
list(filter) {
|
|
84
|
-
const index = this.readIndex();
|
|
85
119
|
const effectiveFilter = { excludeArchived: true, ...filter };
|
|
86
|
-
|
|
87
|
-
|
|
120
|
+
return this.materializeByIndex(filterIndexEntries(this.readIndex(), effectiveFilter));
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* D7 按需物化:把 index 子集回读为完整条目(普通 query 截断后只物化最终返回集)。
|
|
124
|
+
* 「索引在册但条目文件缺失/不可解析」的漂移错误只在此实现一份,list() 与本方法共用;
|
|
125
|
+
* get 继续走 D6 entryPath(findFile → entryPath),不另起路径构造。
|
|
126
|
+
*/
|
|
127
|
+
materializeByIndex(indexEntries) {
|
|
128
|
+
return indexEntries.map(idx => {
|
|
88
129
|
const full = this.get(idx.id);
|
|
89
130
|
if (!full) {
|
|
90
131
|
// 索引在册但条目文件缺失/不可解析 = 索引漂移:抛出让它暴露,
|
|
@@ -120,8 +161,10 @@ class FileKnowledgeStore {
|
|
|
120
161
|
if (entries.length === 0)
|
|
121
162
|
return;
|
|
122
163
|
// 整批预校验(写入闸):任一脏值全批拒写,不落半个批次
|
|
123
|
-
for (const entry of entries)
|
|
164
|
+
for (const entry of entries) {
|
|
124
165
|
this.assertEnumFields(entry);
|
|
166
|
+
this.assertEntryPathSafe(entry);
|
|
167
|
+
}
|
|
125
168
|
const index = this.readIndex();
|
|
126
169
|
const position = new Map(index.map((e, i) => [e.id, i]));
|
|
127
170
|
for (const entry of entries) {
|
|
@@ -138,7 +181,7 @@ class FileKnowledgeStore {
|
|
|
138
181
|
}
|
|
139
182
|
this.writeIndex(index);
|
|
140
183
|
}
|
|
141
|
-
applyAll(updates) {
|
|
184
|
+
applyAll(updates, bases) {
|
|
142
185
|
if (updates.length === 0)
|
|
143
186
|
return;
|
|
144
187
|
// 先合并再整批预校验(写入闸):任一合并结果脏值全批拒写,不落半个批次。
|
|
@@ -147,7 +190,7 @@ class FileKnowledgeStore {
|
|
|
147
190
|
const pending = new Map(); // id → merged 下标
|
|
148
191
|
for (const { id, partial } of updates) {
|
|
149
192
|
const idx = pending.get(id);
|
|
150
|
-
const base = idx !== undefined ? merged[idx] : this.get(id);
|
|
193
|
+
const base = idx !== undefined ? merged[idx] : bases?.get(id) ?? this.get(id);
|
|
151
194
|
if (!base)
|
|
152
195
|
continue;
|
|
153
196
|
const next = { ...base, ...partial, id };
|
|
@@ -161,8 +204,10 @@ class FileKnowledgeStore {
|
|
|
161
204
|
}
|
|
162
205
|
if (merged.length === 0)
|
|
163
206
|
return;
|
|
164
|
-
for (const entry of merged)
|
|
207
|
+
for (const entry of merged) {
|
|
165
208
|
this.assertEnumFields(entry);
|
|
209
|
+
this.assertEntryPathSafe(entry);
|
|
210
|
+
}
|
|
166
211
|
const index = this.readIndex();
|
|
167
212
|
const position = new Map(index.map((e, i) => [e.id, i]));
|
|
168
213
|
for (const entry of merged) {
|
|
@@ -229,20 +274,44 @@ class FileKnowledgeStore {
|
|
|
229
274
|
}
|
|
230
275
|
}
|
|
231
276
|
entryPath(entry) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
277
|
+
this.assertEntryPathSafe(entry);
|
|
278
|
+
return path.join(this.baseDir, `${entry.type}-${entry.id}.md`);
|
|
279
|
+
}
|
|
280
|
+
/** 条目 id/type 的路径分量预校验(saveAll/applyAll 整批预校验用;落盘时 entryPath 仍会复检) */
|
|
281
|
+
assertEntryPathSafe(entry) {
|
|
282
|
+
this.assertSafePathComponent('id', entry.id, '知识条目');
|
|
283
|
+
this.assertSafePathComponent('type', entry.type, '知识条目');
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* 非法路径分量判定(D6 唯一实现):id/type 只允许 baseDir 内的单文件名分量——
|
|
287
|
+
* 非空、非 '.'/'..'、不含路径分隔符(含 Windows 反斜杠)与 NUL。
|
|
288
|
+
* entryPath/findFile/save 批量预校验与 readIndex 在册校验共用此规则,不各写一套。
|
|
289
|
+
* 命中即 fail-fast 抛错,不做 basename 静默修正
|
|
290
|
+
* (旧行为会把 "../../x" 修正成 "x" 写到库内另一位置,读删路径对不上)。
|
|
291
|
+
*/
|
|
292
|
+
isUnsafePathComponent(value) {
|
|
293
|
+
const s = String(value);
|
|
294
|
+
return s === '' || s === '.' || s === '..' || s.includes('/') || s.includes('\\') || s.includes('\0');
|
|
295
|
+
}
|
|
296
|
+
/** 路径分量闸(写入/查询入口):命中非法分量按条目错误风格 fail-fast 抛错 */
|
|
297
|
+
assertSafePathComponent(field, value, where) {
|
|
298
|
+
if (this.isUnsafePathComponent(value)) {
|
|
299
|
+
throw new Error(`[harness] ${where} ${field} 值 ${JSON.stringify(String(value))} 非法:` +
|
|
300
|
+
`不允许为空、'.'、'..' 或含路径分隔符与 NUL 字符,拒绝构造文件路径`);
|
|
301
|
+
}
|
|
235
302
|
}
|
|
236
303
|
/** 条目文件正文的唯一落盘写法(save / saveAll / applyAll 三条路径共用,#134) */
|
|
237
304
|
writeEntryFile(entry) {
|
|
238
305
|
fs.writeFileSync(this.entryPath(entry), (0, frontmatter_1.joinFrontmatter)(this.toFrontmatter(entry), entry.content), 'utf-8');
|
|
239
306
|
}
|
|
240
307
|
findFile(id) {
|
|
308
|
+
// 0. 入参闸:查询 id 先过路径分量闸,非法值 fail-fast,不落入扫描/构造
|
|
309
|
+
this.assertSafePathComponent('id', id, '知识条目');
|
|
241
310
|
// 1. Fast path: index has id→type mapping, construct exact filename
|
|
242
311
|
const index = this.readIndex();
|
|
243
312
|
const idx = index.find(e => e.id === id);
|
|
244
313
|
if (idx) {
|
|
245
|
-
const exact =
|
|
314
|
+
const exact = this.entryPath(idx);
|
|
246
315
|
if (fs.existsSync(exact))
|
|
247
316
|
return exact;
|
|
248
317
|
}
|
|
@@ -346,27 +415,10 @@ class FileKnowledgeStore {
|
|
|
346
415
|
created: entry.created,
|
|
347
416
|
consumptionMode: entry.consumptionMode,
|
|
348
417
|
origin: entry.origin,
|
|
418
|
+
// D7:写入时算好正文+标题 token(现有两次 ceil 口径),普通 query 截断零回读
|
|
419
|
+
tokenCount: (0, token_estimate_1.estimateTokens)(entry.content) + (0, token_estimate_1.estimateTokens)(entry.title),
|
|
349
420
|
};
|
|
350
421
|
}
|
|
351
|
-
matchesFilter(entry, filter) {
|
|
352
|
-
if (filter.types && filter.types.length > 0 && !filter.types.includes(entry.type))
|
|
353
|
-
return false;
|
|
354
|
-
if (filter.maturity && filter.maturity.length > 0 && !filter.maturity.includes(entry.maturity))
|
|
355
|
-
return false;
|
|
356
|
-
if (filter.layers && filter.layers.length > 0 && !filter.layers.includes(entry.layer))
|
|
357
|
-
return false;
|
|
358
|
-
if (filter.tags && filter.tags.length > 0 && !filter.tags.some(t => (entry.tags ?? []).includes(t)))
|
|
359
|
-
return false;
|
|
360
|
-
if (filter.applicablePhases && filter.applicablePhases.length > 0 && !filter.applicablePhases.some(p => (entry.applicablePhases ?? []).includes(p)))
|
|
361
|
-
return false;
|
|
362
|
-
if (filter.excludeArchived !== false && (entry.maturity === 'archived' || entry.maturity === 'deprecated'))
|
|
363
|
-
return false;
|
|
364
|
-
if (filter.consumptionModes && filter.consumptionModes.length > 0 && !filter.consumptionModes.includes(entry.consumptionMode ?? 'reference'))
|
|
365
|
-
return false;
|
|
366
|
-
if (filter.origins && filter.origins.length > 0 && !filter.origins.includes(entry.origin ?? 'agent'))
|
|
367
|
-
return false;
|
|
368
|
-
return true;
|
|
369
|
-
}
|
|
370
422
|
// ── Snapshots ────────────────────────────────────────────
|
|
371
423
|
/**
|
|
372
424
|
* 保存当日 index.json 快照
|
|
@@ -446,9 +498,35 @@ class FileKnowledgeStore {
|
|
|
446
498
|
this.indexCache = undefined;
|
|
447
499
|
return [];
|
|
448
500
|
}
|
|
501
|
+
// fail-fast(D6):index 在册条目的 id/type 必须先过路径分量闸——
|
|
502
|
+
// 非法值会在 get/list/delete 的 index 驱动路径上被拼进文件路径,越出 baseDir
|
|
503
|
+
this.assertIndexEntriesValid(entries);
|
|
504
|
+
// D7:旧格式 index(任一条目无数字 tokenCount)——普通 query 将回退全量读取。
|
|
505
|
+
// 与 query 回退判定同一份检测;实例内只提示一次,新索引路径零输出。
|
|
506
|
+
if (!this.oldIndexHintShown && entries.some(e => indexEntryTokenCount(e) === undefined)) {
|
|
507
|
+
this.oldIndexHintShown = true;
|
|
508
|
+
console.error('[harness] 知识库索引 index.json 为旧格式(无 tokenCount 元数据),普通 query 将回退全量读取;' +
|
|
509
|
+
'运行 harness knowledge index(rebuildIndex)可恢复按需物化');
|
|
510
|
+
}
|
|
449
511
|
this.indexCache = { mtimeMs: stat.mtimeMs, size: stat.size, entries };
|
|
450
512
|
return entries;
|
|
451
513
|
}
|
|
514
|
+
/**
|
|
515
|
+
* index.json 条目校验(D6):任何非法 id/type 明确抛错,定位条目序号/字段/值,
|
|
516
|
+
* 提示手工修正 index.json 或核对条目文件后 rebuildIndex。校验通过才进缓存。
|
|
517
|
+
* 判定规则复用 isUnsafePathComponent,与写入/查询同一套。
|
|
518
|
+
*/
|
|
519
|
+
assertIndexEntriesValid(entries) {
|
|
520
|
+
entries.forEach((entry, i) => {
|
|
521
|
+
for (const field of ['id', 'type']) {
|
|
522
|
+
if (this.isUnsafePathComponent(entry[field])) {
|
|
523
|
+
throw new Error(`[harness] 知识库索引 index.json 第 ${i + 1} 条目的 ${field} 值 ${JSON.stringify(String(entry[field]))} 非法` +
|
|
524
|
+
`(不允许为空、'.'、'..' 或含路径分隔符与 NUL 字符);` +
|
|
525
|
+
`修复:手工修正 index.json 该字段,或核对对应条目文件后运行 harness knowledge index(rebuildIndex)`);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
}
|
|
452
530
|
writeIndex(entries) {
|
|
453
531
|
const indexPath = path.join(this.baseDir, INDEX_FILE);
|
|
454
532
|
fs.writeFileSync(indexPath, JSON.stringify(entries, null, 2), 'utf-8');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 检查点类型定义
|
|
3
3
|
*/
|
|
4
|
+
import type { CommandExecutionPolicy } from './command-execution-policy';
|
|
4
5
|
/**
|
|
5
6
|
* 检查类型
|
|
6
7
|
*/
|
|
@@ -150,6 +151,15 @@ export interface CheckResult {
|
|
|
150
151
|
checkId: string;
|
|
151
152
|
/** 是否通过 */
|
|
152
153
|
passed: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* 是否未评估(D3 read-only:项目声明的命令被跳过、未执行)
|
|
156
|
+
*
|
|
157
|
+
* skipped 时 passed 恒为 false(未通过——根本没查),但不计失败;
|
|
158
|
+
* 跳过原因随 skipReason。除 read-only 策略外不产生 skipped。
|
|
159
|
+
*/
|
|
160
|
+
skipped?: boolean;
|
|
161
|
+
/** 未评估原因(D3;仅 skipped=true 时携带,进 CLI 跳过清单) */
|
|
162
|
+
skipReason?: string;
|
|
153
163
|
/** 消息 */
|
|
154
164
|
message?: string;
|
|
155
165
|
/** 错误详情 */
|
|
@@ -165,8 +175,17 @@ export interface CheckResult {
|
|
|
165
175
|
export interface CheckpointResult {
|
|
166
176
|
/** 检查点 ID */
|
|
167
177
|
checkpointId: string;
|
|
168
|
-
/**
|
|
178
|
+
/** 是否全部通过(存在未评估项时不算通过,见 skipped) */
|
|
169
179
|
passed: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* 是否含未评估项(D3 read-only:声明命令未执行)
|
|
182
|
+
*
|
|
183
|
+
* 无失败但有跳过时置位:passed=false 且不判失败——「未完整验证」三态,
|
|
184
|
+
* 不把跳过当验证通过(假绿防线);与失败并存时失败优先,不置位。
|
|
185
|
+
*/
|
|
186
|
+
skipped?: boolean;
|
|
187
|
+
/** 未评估说明(D3;仅 skipped=true 时携带) */
|
|
188
|
+
skipReason?: string;
|
|
170
189
|
/** 各项检查结果 */
|
|
171
190
|
checks: CheckResult[];
|
|
172
191
|
/** 消息 */
|
|
@@ -193,5 +212,13 @@ export interface CheckpointContext {
|
|
|
193
212
|
* 缺省 = 真定时器;测试可注入零等待替身,据此断言重试语义而不必真等
|
|
194
213
|
*/
|
|
195
214
|
sleep?: (ms: number) => Promise<void>;
|
|
215
|
+
/**
|
|
216
|
+
* 命令执行策略(D3 P0.5 Phase 1;缺省 = 默认执行,库调用兼容)
|
|
217
|
+
*
|
|
218
|
+
* readOnly = true 时 command_* / 带 command 的 output_* 族不执行声明命令,
|
|
219
|
+
* 返回三态 skipped(skipReason 由策略统一措辞)。http_* 的 fetch 是网络请求,
|
|
220
|
+
* 不属于本策略的命令执行通道,不受影响。
|
|
221
|
+
*/
|
|
222
|
+
commandPolicy?: CommandExecutionPolicy;
|
|
196
223
|
}
|
|
197
224
|
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 统一命令执行策略类型(D3,P0.5 Phase 1 副作用授权)
|
|
3
|
+
*
|
|
4
|
+
* check / validate / report 共用同一授权与跳过语义:
|
|
5
|
+
* - 授权来源只有 CLI flag --read-only;仓内 YAML 只声明命令,不作为授权来源
|
|
6
|
+
* (不新增 exec: allowed 之类自证可信配置)
|
|
7
|
+
* - readOnly = true:消费方不得执行任何项目 YAML 声明的命令,结果以三态 skipped
|
|
8
|
+
* 上报(skipReason 统一由策略措辞),不产生「已检查」假绿
|
|
9
|
+
* - execute 是注入执行缝:普通模式下消费方经它执行;read-only 下保证零调用。
|
|
10
|
+
* 缺省(无策略)= 库调用保持默认执行(行为兼容)
|
|
11
|
+
*
|
|
12
|
+
* 类型住 types 层:CheckpointContext(types/checkpoint.ts)与 CheckEnv
|
|
13
|
+
* (core/constraints/checkers/types.ts)都引用本策略,types 不能上行 import core。
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* 命令执行结果(执行缝统一形状)
|
|
17
|
+
*
|
|
18
|
+
* 与 exec 模板的 spawn 执行语义同形:退出码 / 信号 / 超时 / 启动错误 /
|
|
19
|
+
* 截断的 stdout/stderr(各流有界保留,超出只记截断标记)。
|
|
20
|
+
*/
|
|
21
|
+
export interface ExecutedCommand {
|
|
22
|
+
/** 退出码(被信号杀死/启动失败时为 null) */
|
|
23
|
+
code: number | null;
|
|
24
|
+
/** 终止信号(无 = null) */
|
|
25
|
+
signal: NodeJS.Signals | null;
|
|
26
|
+
/** 是否超时被杀 */
|
|
27
|
+
timedOut: boolean;
|
|
28
|
+
/** spawn 启动错误文本(如 shell 不可用) */
|
|
29
|
+
spawnError?: string;
|
|
30
|
+
/** stdout(有界截断) */
|
|
31
|
+
stdout: string;
|
|
32
|
+
/** stderr(有界截断) */
|
|
33
|
+
stderr: string;
|
|
34
|
+
/** 输出是否被截断 */
|
|
35
|
+
truncated: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 命令执行回调(执行缝)
|
|
39
|
+
*
|
|
40
|
+
* 参数:命令行(经 shell 执行)、工作目录、超时毫秒数。
|
|
41
|
+
*/
|
|
42
|
+
export type CommandExecutor = (command: string, cwd: string, timeoutMs: number) => Promise<ExecutedCommand>;
|
|
43
|
+
/**
|
|
44
|
+
* 统一命令执行策略(D3)
|
|
45
|
+
*
|
|
46
|
+
* 一次 check / validate / report 运行一份,由 CLI 组合根创建并沿调用链显式传递
|
|
47
|
+
* (照 RunEnv / GitEvidence 同形:入口构造、沿链传递、不做模块级全局)。
|
|
48
|
+
*/
|
|
49
|
+
export interface CommandExecutionPolicy {
|
|
50
|
+
/** read-only 模式:true = 不执行任何项目声明命令 */
|
|
51
|
+
readonly readOnly: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* read-only 跳过原因的唯一措辞来源(消费方只透传进 skipped.skipReason,
|
|
54
|
+
* 不各自措辞)——含 --read-only 标记与命令原文
|
|
55
|
+
*/
|
|
56
|
+
skipReason(command: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* 真实执行回调:普通模式下消费方的唯一执行口;read-only 下保证零调用。
|
|
59
|
+
* 缺省 = 真实 spawn 执行(超时杀进程组 + 流截断语义)。
|
|
60
|
+
*/
|
|
61
|
+
execute: CommandExecutor;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 项目 YAML 声明的命令清单项(执行清单的数据单元)
|
|
65
|
+
*
|
|
66
|
+
* source = 声明来源(约束 id / `<检查点id>/<检查id>`),command = 声明的命令原文。
|
|
67
|
+
*/
|
|
68
|
+
export interface CommandPlanItem {
|
|
69
|
+
/** 声明来源 */
|
|
70
|
+
source: string;
|
|
71
|
+
/** 命令原文 */
|
|
72
|
+
command: string;
|
|
73
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 统一命令执行策略类型(D3,P0.5 Phase 1 副作用授权)
|
|
4
|
+
*
|
|
5
|
+
* check / validate / report 共用同一授权与跳过语义:
|
|
6
|
+
* - 授权来源只有 CLI flag --read-only;仓内 YAML 只声明命令,不作为授权来源
|
|
7
|
+
* (不新增 exec: allowed 之类自证可信配置)
|
|
8
|
+
* - readOnly = true:消费方不得执行任何项目 YAML 声明的命令,结果以三态 skipped
|
|
9
|
+
* 上报(skipReason 统一由策略措辞),不产生「已检查」假绿
|
|
10
|
+
* - execute 是注入执行缝:普通模式下消费方经它执行;read-only 下保证零调用。
|
|
11
|
+
* 缺省(无策略)= 库调用保持默认执行(行为兼容)
|
|
12
|
+
*
|
|
13
|
+
* 类型住 types 层:CheckpointContext(types/checkpoint.ts)与 CheckEnv
|
|
14
|
+
* (core/constraints/checkers/types.ts)都引用本策略,types 不能上行 import core。
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/utils/exec.d.ts
CHANGED
|
@@ -2,12 +2,18 @@
|
|
|
2
2
|
* 通用工具模块
|
|
3
3
|
*
|
|
4
4
|
* 提供命令执行的公共函数,减少各子系统重复代码。
|
|
5
|
+
* 两个出口分工:`execAsync` = shell 字符串(仅消费方自己控制完整命令串时用);
|
|
6
|
+
* `execFileAsync` = argv 数组(外部路径/参数不经 shell 插值,P0.3 起的外部输入一律走这里)。
|
|
5
7
|
* 约束域谓词不在本模块(harness#137:`normalizeTriggers`/`matchesTrigger` 已迁
|
|
6
8
|
* `core/constraints/triggers.ts`;`isCommandAvailable`/`delay` 双仓零生产消费者,已删;
|
|
7
9
|
* `runCommand` 零生产调用点且不在包公共面,按 ADR-0022 同判据随 harness#162 删除)。
|
|
8
10
|
*/
|
|
9
|
-
import { exec } from 'child_process';
|
|
11
|
+
import { exec, execFile } from 'child_process';
|
|
10
12
|
/**
|
|
11
13
|
* Promisified exec
|
|
12
14
|
*/
|
|
13
15
|
export declare const execAsync: typeof exec.__promisify__;
|
|
16
|
+
/**
|
|
17
|
+
* Promisified execFile(argv 形状,不经 shell)
|
|
18
|
+
*/
|
|
19
|
+
export declare const execFileAsync: typeof execFile.__promisify__;
|
package/dist/utils/exec.js
CHANGED
|
@@ -3,15 +3,21 @@
|
|
|
3
3
|
* 通用工具模块
|
|
4
4
|
*
|
|
5
5
|
* 提供命令执行的公共函数,减少各子系统重复代码。
|
|
6
|
+
* 两个出口分工:`execAsync` = shell 字符串(仅消费方自己控制完整命令串时用);
|
|
7
|
+
* `execFileAsync` = argv 数组(外部路径/参数不经 shell 插值,P0.3 起的外部输入一律走这里)。
|
|
6
8
|
* 约束域谓词不在本模块(harness#137:`normalizeTriggers`/`matchesTrigger` 已迁
|
|
7
9
|
* `core/constraints/triggers.ts`;`isCommandAvailable`/`delay` 双仓零生产消费者,已删;
|
|
8
10
|
* `runCommand` 零生产调用点且不在包公共面,按 ADR-0022 同判据随 harness#162 删除)。
|
|
9
11
|
*/
|
|
10
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.execAsync = void 0;
|
|
13
|
+
exports.execFileAsync = exports.execAsync = void 0;
|
|
12
14
|
const child_process_1 = require("child_process");
|
|
13
15
|
const util_1 = require("util");
|
|
14
16
|
/**
|
|
15
17
|
* Promisified exec
|
|
16
18
|
*/
|
|
17
19
|
exports.execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
20
|
+
/**
|
|
21
|
+
* Promisified execFile(argv 形状,不经 shell)
|
|
22
|
+
*/
|
|
23
|
+
exports.execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
|