@dommaker/harness 4.0.0 → 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.
Files changed (102) hide show
  1. package/dist/bootstrap/bootstrap.d.ts +15 -0
  2. package/dist/bootstrap/bootstrap.js +18 -1
  3. package/dist/bootstrap/index.d.ts +2 -2
  4. package/dist/bootstrap/index.js +3 -2
  5. package/dist/cli/commands/acceptance.d.ts +8 -0
  6. package/dist/cli/commands/acceptance.js +45 -24
  7. package/dist/cli/commands/check.d.ts +2 -0
  8. package/dist/cli/commands/check.js +36 -5
  9. package/dist/cli/commands/command.js +1 -1
  10. package/dist/cli/commands/definitions.js +3 -0
  11. package/dist/cli/commands/init/ci-platform.d.ts +3 -5
  12. package/dist/cli/commands/init/ci-platform.js +3 -8
  13. package/dist/cli/commands/init/index.js +78 -11
  14. package/dist/cli/commands/release.d.ts +11 -3
  15. package/dist/cli/commands/release.js +159 -52
  16. package/dist/cli/commands/report.d.ts +2 -0
  17. package/dist/cli/commands/report.js +54 -6
  18. package/dist/cli/commands/security.d.ts +3 -3
  19. package/dist/cli/commands/security.js +3 -2
  20. package/dist/cli/commands/sync-docs/capabilities-syncer.d.ts +3 -40
  21. package/dist/cli/commands/sync-docs/capabilities-syncer.js +5 -159
  22. package/dist/cli/commands/sync-docs/compact.js +2 -2
  23. package/dist/cli/commands/sync-docs/context-syncer.d.ts +4 -36
  24. package/dist/cli/commands/sync-docs/context-syncer.js +4 -221
  25. package/dist/cli/commands/sync-docs/index.d.ts +8 -8
  26. package/dist/cli/commands/sync-docs/index.js +8 -8
  27. package/dist/cli/commands/sync-docs/main-flow.d.ts +5 -4
  28. package/dist/cli/commands/sync-docs/main-flow.js +6 -5
  29. package/dist/cli/commands/sync-docs/sync-output.d.ts +1 -1
  30. package/dist/cli/commands/sync-docs/sync-output.js +4 -0
  31. package/dist/cli/commands/sync-docs/sync-writes.d.ts +1 -1
  32. package/dist/cli/commands/validate.d.ts +2 -0
  33. package/dist/cli/commands/validate.js +40 -1
  34. package/dist/core/command-execution-policy.d.ts +59 -0
  35. package/dist/core/command-execution-policy.js +167 -0
  36. package/dist/core/constraints/capabilities-parser.d.ts +2 -1
  37. package/dist/core/constraints/capabilities-parser.js +2 -1
  38. package/dist/core/constraints/checker.d.ts +17 -5
  39. package/dist/core/constraints/checker.js +20 -10
  40. package/dist/core/constraints/checkers/no-hardcoded-credentials.js +14 -15
  41. package/dist/core/constraints/checkers/no-test-simplification.js +8 -6
  42. package/dist/core/constraints/checkers/templated/exec.d.ts +4 -0
  43. package/dist/core/constraints/checkers/templated/exec.js +11 -48
  44. package/dist/core/constraints/checkers/templated/file-exists.js +7 -4
  45. package/dist/core/constraints/checkers/templated/regex-scan.js +11 -15
  46. package/dist/core/constraints/checkers/types.d.ts +13 -2
  47. package/dist/core/constraints/checkers/types.js +5 -2
  48. package/dist/core/constraints/construction-sites.d.ts +1 -1
  49. package/dist/core/constraints/construction-sites.js +1 -1
  50. package/dist/core/constraints/injection-writer.d.ts +1 -1
  51. package/dist/core/constraints/injection-writer.js +1 -1
  52. package/dist/core/constraints/project-snapshot.d.ts +43 -0
  53. package/dist/core/constraints/project-snapshot.js +103 -0
  54. package/dist/core/constraints/run-env.d.ts +35 -0
  55. package/dist/core/constraints/run-env.js +36 -0
  56. package/dist/{cli/commands/sync-docs → core/docs-sync}/agents-syncer.d.ts +2 -0
  57. package/dist/{cli/commands/sync-docs → core/docs-sync}/agents-syncer.js +5 -3
  58. package/dist/core/docs-sync/capabilities-table.d.ts +46 -0
  59. package/dist/core/docs-sync/capabilities-table.js +200 -0
  60. package/dist/core/docs-sync/context-collector.d.ts +40 -0
  61. package/dist/core/docs-sync/context-collector.js +227 -0
  62. package/dist/{cli/commands/sync-docs → core/docs-sync}/project-reader.d.ts +5 -1
  63. package/dist/{cli/commands/sync-docs → core/docs-sync}/project-reader.js +10 -6
  64. package/dist/{cli/commands/sync-docs → core/docs-sync}/sync-state.d.ts +15 -9
  65. package/dist/{cli/commands/sync-docs → core/docs-sync}/sync-state.js +26 -29
  66. package/dist/core/validators/check-handlers/command.js +22 -0
  67. package/dist/core/validators/check-handlers/output.js +26 -3
  68. package/dist/core/validators/checkpoint.d.ts +4 -0
  69. package/dist/core/validators/checkpoint.js +10 -2
  70. package/dist/gates/acceptance.d.ts +8 -3
  71. package/dist/gates/acceptance.js +76 -13
  72. package/dist/gates/command.d.ts +3 -3
  73. package/dist/gates/command.js +2 -2
  74. package/dist/gates/contract.d.ts +3 -3
  75. package/dist/gates/performance.d.ts +10 -3
  76. package/dist/gates/performance.js +49 -4
  77. package/dist/gates/review.d.ts +3 -3
  78. package/dist/gates/security.d.ts +3 -3
  79. package/dist/gates/security.js +26 -18
  80. package/dist/gates/types.d.ts +45 -16
  81. package/dist/knowledge/ingest.d.ts +31 -0
  82. package/dist/knowledge/ingest.js +192 -52
  83. package/dist/knowledge/lifecycle.d.ts +15 -0
  84. package/dist/knowledge/lifecycle.js +62 -0
  85. package/dist/knowledge/query.d.ts +10 -0
  86. package/dist/knowledge/query.js +60 -8
  87. package/dist/knowledge/store.d.ts +56 -3
  88. package/dist/knowledge/store.js +108 -30
  89. package/dist/types/checkpoint.d.ts +28 -1
  90. package/dist/types/command-execution-policy.d.ts +73 -0
  91. package/dist/types/command-execution-policy.js +16 -0
  92. package/dist/utils/exec.d.ts +7 -1
  93. package/dist/utils/exec.js +7 -1
  94. package/dist/utils/yaml.d.ts +10 -0
  95. package/dist/utils/yaml.js +11 -0
  96. package/package.json +1 -1
  97. package/dist/core/constraints/check-cache.d.ts +0 -43
  98. package/dist/core/constraints/check-cache.js +0 -77
  99. package/dist/core/constraints/checkers/templated/glob.d.ts +0 -8
  100. package/dist/core/constraints/checkers/templated/glob.js +0 -14
  101. /package/dist/{cli/commands/sync-docs → core/docs-sync}/preserve-block.d.ts +0 -0
  102. /package/dist/{cli/commands/sync-docs → core/docs-sync}/preserve-block.js +0 -0
@@ -4,16 +4,27 @@
4
4
  *
5
5
  * 全仓唯一 import 'yaml' 的模块;调用方一律经本模块,不允许直接依赖 yaml 包。
6
6
  * merge:true 对齐 js-yaml 的合并键(<<)默认展开口径;空文档返回 null(js-yaml 为 undefined)。
7
+ * 需保留注释的读-改-写走 loadDocument / dumpDocument(harness#210),普通值投影仍走 load / dump。
7
8
  */
8
9
  Object.defineProperty(exports, "__esModule", { value: true });
9
10
  exports.load = load;
11
+ exports.loadDocument = loadDocument;
10
12
  exports.dump = dump;
13
+ exports.dumpDocument = dumpDocument;
11
14
  const yaml_1 = require("yaml");
12
15
  /** 解析 YAML 文本(合并键展开;空文档返回 null) */
13
16
  function load(text) {
14
17
  return (0, yaml_1.parse)(text, { merge: true });
15
18
  }
19
+ /** 解析为保留注释的 YAML Document(供读-改-写受管键) */
20
+ function loadDocument(text) {
21
+ return (0, yaml_1.parseDocument)(text, { merge: true });
22
+ }
16
23
  /** 序列化为 YAML 文本(options 透传给 yaml@2 stringify) */
17
24
  function dump(value, options) {
18
25
  return (0, yaml_1.stringify)(value, options);
19
26
  }
27
+ /** 序列化保留注释的 YAML Document */
28
+ function dumpDocument(document, options) {
29
+ return document.toString(options);
30
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dommaker/harness",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "通用工程约束框架 - 约束检查(severity 分级)、检查点验证、测试门控",
5
5
  "keywords": [
6
6
  "harness",
@@ -1,43 +0,0 @@
1
- /**
2
- * CheckCache — 约束检查缓存(S7)
3
- *
4
- * 缓存 git diff 和 src/ 递归扫描结果,减少重复 I/O。
5
- * 同一请求内多次 checkConstraints 调用共享缓存。
6
- *
7
- * 用法:
8
- * ```typescript
9
- * const cache = new CheckCache({ ttlMs: 5000 });
10
- * const diff = await cache.get('git_diff', projectPath, () => createGitEvidence(projectPath).stagedDiff());
11
- * ```
12
- */
13
- /**
14
- * CheckCache 构造配置
15
- */
16
- export interface CheckCacheConfig {
17
- /** 缓存 TTL(毫秒),默认 5000 */
18
- ttlMs: number;
19
- }
20
- /**
21
- * 约束检查缓存:TTL 缓存
22
- */
23
- export declare class CheckCache {
24
- private store;
25
- private ttlMs;
26
- constructor(config?: CheckCacheConfig);
27
- /**
28
- * 获取缓存值(miss 时执行 fn 并缓存结果)
29
- *
30
- * @param namespace 命名空间(如 'git_diff', 'src_scan')
31
- * @param key 缓存键(如 projectPath)
32
- * @param fn miss 时的计算函数
33
- */
34
- get<T>(namespace: string, key: string, fn: () => Promise<T>): Promise<T>;
35
- /**
36
- * 同步版本(用于 readdirSync 等同步操作)
37
- */
38
- getSync<T>(namespace: string, key: string, fn: () => T): T;
39
- /**
40
- * 使指定命名空间缓存失效
41
- */
42
- invalidate(namespace?: string): void;
43
- }
@@ -1,77 +0,0 @@
1
- "use strict";
2
- /**
3
- * CheckCache — 约束检查缓存(S7)
4
- *
5
- * 缓存 git diff 和 src/ 递归扫描结果,减少重复 I/O。
6
- * 同一请求内多次 checkConstraints 调用共享缓存。
7
- *
8
- * 用法:
9
- * ```typescript
10
- * const cache = new CheckCache({ ttlMs: 5000 });
11
- * const diff = await cache.get('git_diff', projectPath, () => createGitEvidence(projectPath).stagedDiff());
12
- * ```
13
- */
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.CheckCache = void 0;
16
- /**
17
- * 约束检查缓存:TTL 缓存
18
- */
19
- class CheckCache {
20
- store = new Map();
21
- ttlMs;
22
- constructor(config) {
23
- this.ttlMs = config?.ttlMs ?? 5000;
24
- }
25
- /**
26
- * 获取缓存值(miss 时执行 fn 并缓存结果)
27
- *
28
- * @param namespace 命名空间(如 'git_diff', 'src_scan')
29
- * @param key 缓存键(如 projectPath)
30
- * @param fn miss 时的计算函数
31
- */
32
- async get(namespace, key, fn) {
33
- const cacheKey = `${namespace}:${key}`;
34
- const entry = this.store.get(cacheKey);
35
- if (entry && Date.now() < entry.expiresAt) {
36
- return entry.value;
37
- }
38
- const value = await fn();
39
- this.store.set(cacheKey, {
40
- value,
41
- expiresAt: Date.now() + this.ttlMs,
42
- });
43
- return value;
44
- }
45
- /**
46
- * 同步版本(用于 readdirSync 等同步操作)
47
- */
48
- getSync(namespace, key, fn) {
49
- const cacheKey = `${namespace}:${key}`;
50
- const entry = this.store.get(cacheKey);
51
- if (entry && Date.now() < entry.expiresAt) {
52
- return entry.value;
53
- }
54
- const value = fn();
55
- this.store.set(cacheKey, {
56
- value,
57
- expiresAt: Date.now() + this.ttlMs,
58
- });
59
- return value;
60
- }
61
- /**
62
- * 使指定命名空间缓存失效
63
- */
64
- invalidate(namespace) {
65
- if (namespace) {
66
- for (const key of this.store.keys()) {
67
- if (key.startsWith(`${namespace}:`)) {
68
- this.store.delete(key);
69
- }
70
- }
71
- }
72
- else {
73
- this.store.clear();
74
- }
75
- }
76
- }
77
- exports.CheckCache = CheckCache;
@@ -1,8 +0,0 @@
1
- /**
2
- * 模板侧轻量 glob 匹配(支持 `**`、`*`、`?`,纯字符串判定,不碰文件系统)
3
- *
4
- * glob→正则正本在 `utils/glob-match.ts`(与 completion-checkers 同一匹配语义,
5
- * utils 下游白名单内,分层守卫(harness#88)不违)。
6
- */
7
- /** 单 glob 匹配(相对路径正斜杠口径) */
8
- export declare function matchGlob(file: string, glob: string): boolean;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- /**
3
- * 模板侧轻量 glob 匹配(支持 `**`、`*`、`?`,纯字符串判定,不碰文件系统)
4
- *
5
- * glob→正则正本在 `utils/glob-match.ts`(与 completion-checkers 同一匹配语义,
6
- * utils 下游白名单内,分层守卫(harness#88)不违)。
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.matchGlob = matchGlob;
10
- const glob_match_1 = require("../../../../utils/glob-match");
11
- /** 单 glob 匹配(相对路径正斜杠口径) */
12
- function matchGlob(file, glob) {
13
- return (0, glob_match_1.globToRegExp)(glob).test(file);
14
- }