@boyingliu01/xp-gate 0.37.3 → 0.38.0
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/adapter-common.sh +12 -2
- package/adapters/csharp.sh +73 -2
- package/adapters/dart.sh +13 -0
- package/adapters/go.sh +5 -0
- package/adapters/iac.sh +46 -3
- package/adapters/java.sh +6 -0
- package/adapters/kotlin.sh +6 -0
- package/adapters/shell.sh +119 -34
- package/adapters/swift.sh +6 -0
- package/adapters/typescript.sh +98 -34
- package/bin/xp-gate.js +48 -2
- package/gate-10.sh +99 -26
- package/gate-12-file-hygiene.sh +13 -1
- package/gate-registry.sh +197 -0
- package/gates/python-health.ts +67 -29
- package/hooks/adapter-common.sh +12 -2
- package/hooks/deploy-manifest.sh +100 -0
- package/hooks/gate-10.sh +99 -26
- package/hooks/gate-12-file-hygiene.sh +13 -1
- package/hooks/gate-driver.sh +120 -0
- package/hooks/gate-entries/gate-0-entry.sh +825 -0
- package/hooks/gate-entries/gate-1-entry.sh +767 -0
- package/hooks/gate-entries/gate-10-entry.sh +52 -0
- package/hooks/gate-entries/gate-11-entry.sh +120 -0
- package/hooks/gate-entries/gate-12-entry.sh +44 -0
- package/hooks/gate-entries/gate-12b-entry.sh +178 -0
- package/hooks/gate-entries/gate-12c-entry.sh +80 -0
- package/hooks/gate-entries/gate-13-entry.sh +584 -0
- package/hooks/gate-entries/gate-2-entry.sh +199 -0
- package/hooks/gate-entries/gate-3-entry.sh +53 -0
- package/hooks/gate-entries/gate-4-entry.sh +46 -0
- package/hooks/gate-entries/gate-5-entry.sh +1729 -0
- package/hooks/gate-entries/gate-6-entry.sh +658 -0
- package/hooks/gate-entries/gate-7-entry.sh +41 -0
- package/hooks/gate-entries/gate-8-entry.sh +33 -0
- package/hooks/gate-entries/gate-9-entry.sh +307 -0
- package/hooks/gate-entries/subdir-restore.sh +27 -0
- package/hooks/gate-registry.sh +51 -15
- package/hooks/hook-module-resolution.sh +73 -0
- package/hooks/install.sh +135 -0
- package/hooks/lib/now-ms.sh +55 -19
- package/hooks/lib/toolchain-path.sh +50 -6
- package/hooks/pre-commit +256 -5091
- package/hooks/pre-push +212 -25
- package/lib/__tests__/arch-config-template.test.js +190 -0
- package/lib/__tests__/baseline-shell-scope.test.js +60 -0
- package/lib/__tests__/crap-cli.test.js +14 -3
- package/lib/__tests__/deploy-manifest-check-wired.test.js +138 -0
- package/lib/__tests__/deploy-manifest-completeness.test.js +151 -0
- package/lib/__tests__/deploy-manifest-consumers-adapter-uninstall.test.js +40 -0
- package/lib/__tests__/deploy-manifest-consumers-no-private-lists.test.js +74 -0
- package/lib/__tests__/deploy-manifest-projection.test.js +66 -0
- package/lib/__tests__/deploy-manifest-shell-parity.test.js +108 -0
- package/lib/__tests__/deploy-manifest.test.js +97 -0
- package/lib/__tests__/doctor.test.js +51 -7
- package/lib/__tests__/gate-coverage.test.js +79 -12
- package/lib/__tests__/gate-numbering.test.js +28 -1
- package/lib/__tests__/install-sh-deploy-manifest.test.js +80 -0
- package/lib/__tests__/mirror-sync.test.js +45 -3
- package/lib/__tests__/npm-package.test.js +10 -7
- package/lib/__tests__/sastd-client.test.js +452 -0
- package/lib/__tests__/shared-utils-copyHooks-manifest.test.js +69 -0
- package/lib/__tests__/sprint-status-rework.test.js +1 -0
- package/lib/arch-config-template.js +87 -0
- package/lib/baseline.js +54 -2
- package/lib/deploy-manifest.js +174 -0
- package/lib/doctor.js +46 -14
- package/lib/gate-capability.js +291 -0
- package/lib/gate-coverage.js +194 -74
- package/lib/gate-identity.js +349 -0
- package/lib/gate-runner.js +11 -1
- package/lib/hook-module-resolution.js +27 -0
- package/lib/init.js +72 -5
- package/lib/mattpocock-license-verdict.json +1 -1
- package/lib/sastd-client.js +534 -0
- package/lib/shared-utils.js +31 -9
- package/lib/uninstall.js +10 -7
- package/lib/update-hooks.js +27 -18
- package/mock-policy/AGENTS.md +1 -1
- package/mutation/AGENTS.md +1 -1
- package/package.json +3 -1
- package/plugins/claude-code/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/claude-code/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/claude-code/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/dsh/package.json +1 -1
- package/plugins/dsh/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/dsh/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/dsh/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/opencode/package.json +1 -1
- package/plugins/opencode/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/opencode/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/opencode/skills/test-specification-alignment/AGENTS.md +1 -1
- package/plugins/qoder/plugin.json +1 -1
- package/plugins/qoder/skills/delphi-review/AGENTS.md +1 -1
- package/plugins/qoder/skills/sprint-flow/AGENTS.md +1 -1
- package/plugins/qoder/skills/test-specification-alignment/AGENTS.md +1 -1
- package/principles/AGENTS.md +1 -1
- package/principles/__tests__/analyzer.test.ts +2 -1
- package/principles/__tests__/config-enforcement.test.ts +1 -0
- package/principles/__tests__/types.test.ts +1 -0
- package/principles/adapters/base.ts +14 -1
- package/principles/adapters/duplication.ts +134 -0
- package/principles/rules/__tests__/clean-code/large-file.test.ts +2 -1
- package/principles/rules/clean-code/code-duplication.ts +75 -9
- package/principles/types.ts +39 -0
- package/scripts/__tests__/check-mattpocock-license.test.js +36 -3
- package/scripts/__tests__/sync-package-content.test.js +12 -2
- package/scripts/generate-mirrors.cjs +125 -0
- package/scripts/sync-package-content.js +64 -20
- package/skills/delphi-review/AGENTS.md +1 -1
- package/skills/sprint-flow/AGENTS.md +1 -1
- package/skills/test-specification-alignment/AGENTS.md +1 -1
- package/adapters/gate-9.sh +0 -245
- package/gate-9.sh +0 -245
- package/hooks/gate-9.sh +0 -245
package/lib/baseline.js
CHANGED
|
@@ -58,6 +58,7 @@ function findFilesByExt(extensions) {
|
|
|
58
58
|
const result = execSync(`git ls-files ${patterns}`, {
|
|
59
59
|
encoding: 'utf8',
|
|
60
60
|
maxBuffer: 5 * 1024 * 1024,
|
|
61
|
+
cwd: process.cwd(),
|
|
61
62
|
}).trim();
|
|
62
63
|
return result ? result.split('\n') : [];
|
|
63
64
|
} catch {
|
|
@@ -65,6 +66,57 @@ function findFilesByExt(extensions) {
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
// Git hooks carry no .sh extension, so an extension glob cannot see them -- and
|
|
70
|
+
// they are the largest shell programs in a gates repository. Same rule as the
|
|
71
|
+
// adapter (githooks/adapters/shell.sh): a file is a shell script when it has a
|
|
72
|
+
// shell extension OR a shell shebang.
|
|
73
|
+
const SHELL_HOOK_NAMES = [
|
|
74
|
+
'pre-commit', 'pre-push', 'post-commit', 'post-merge',
|
|
75
|
+
'post-checkout', 'commit-msg', 'prepare-commit-msg',
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Collect every shell script in the project: *.sh / *.bash plus git hooks,
|
|
80
|
+
* matched at any depth. Mirrors `_shell_script_files()` in the shell adapter so
|
|
81
|
+
* the baseline denominator and the gate numerator describe the same set --
|
|
82
|
+
* a baseline that measures fewer files than the gate reports can only ever
|
|
83
|
+
* conclude "debt unchanged".
|
|
84
|
+
*
|
|
85
|
+
* @returns {string[]} project-relative paths; empty when not in a git work tree
|
|
86
|
+
*/
|
|
87
|
+
function findShellScripts() {
|
|
88
|
+
// Both lookups run with cwd=process.cwd() for the same reason `handleBaseline`
|
|
89
|
+
// overrides process.cwd in tests: a bare execSync inherits the caller's cwd,
|
|
90
|
+
// so outside a work tree it would walk up into whatever repository happens to
|
|
91
|
+
// contain the temp directory and report that repo's files as this project's.
|
|
92
|
+
const cwd = process.cwd();
|
|
93
|
+
const byExt = findFilesByExt(['.sh', '.bash']).filter(f => !path.isAbsolute(f));
|
|
94
|
+
const hookPatterns = SHELL_HOOK_NAMES
|
|
95
|
+
.map(name => `"**/${name}" "${name}"`)
|
|
96
|
+
.join(' ');
|
|
97
|
+
|
|
98
|
+
let hooks = [];
|
|
99
|
+
try {
|
|
100
|
+
const result = execSync(`git ls-files ${hookPatterns}`, {
|
|
101
|
+
encoding: 'utf8',
|
|
102
|
+
maxBuffer: 5 * 1024 * 1024,
|
|
103
|
+
cwd,
|
|
104
|
+
}).trim();
|
|
105
|
+
hooks = result ? result.split('\n') : [];
|
|
106
|
+
} catch {
|
|
107
|
+
hooks = [];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const seen = new Set();
|
|
111
|
+
const files = [];
|
|
112
|
+
for (const f of [...byExt, ...hooks]) {
|
|
113
|
+
if (!f || seen.has(f)) continue;
|
|
114
|
+
seen.add(f);
|
|
115
|
+
files.push(f);
|
|
116
|
+
}
|
|
117
|
+
return files;
|
|
118
|
+
}
|
|
119
|
+
|
|
68
120
|
/**
|
|
69
121
|
* Create baseline: scan all source files with available lint tools.
|
|
70
122
|
* Called by: xp-gate baseline create|reset
|
|
@@ -178,7 +230,7 @@ async function createBaseline() {
|
|
|
178
230
|
}
|
|
179
231
|
|
|
180
232
|
// Shell — shellcheck
|
|
181
|
-
const shFiles =
|
|
233
|
+
const shFiles = findShellScripts();
|
|
182
234
|
if (shFiles.length > 0) {
|
|
183
235
|
try {
|
|
184
236
|
execSync('shellcheck --version', { encoding: 'utf8' });
|
|
@@ -416,4 +468,4 @@ Examples:
|
|
|
416
468
|
}
|
|
417
469
|
}
|
|
418
470
|
|
|
419
|
-
module.exports = { handleBaseline, createBaseline, showBaseline, resetBaseline, diffBaseline, countBaselineByTool, compareBaselines };
|
|
471
|
+
module.exports = { handleBaseline, createBaseline, showBaseline, resetBaseline, diffBaseline, countBaselineByTool, compareBaselines, findShellScripts };
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* deploy-manifest.js — 部署文件清单的单一事实源(REQ-DEPLOY-001,#789 根因②)
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS FILE EXISTS
|
|
5
|
+
* --------------------
|
|
6
|
+
* 同一份"安装时要部署哪些文件"的清单曾手写四处且互不一致:
|
|
7
|
+
* - shared-utils.copyHooks 枚举 5 个 hook(缺 adapter-common.sh)
|
|
8
|
+
* - update-hooks.copyHooks 枚举 3 个 hook(缺 post-commit + hook-module-resolution.sh)
|
|
9
|
+
* - install.sh HOOKS_LIST 枚举 3 个 hook(缺 post-commit)+ GATE_SCRIPTS 枚举 7 个
|
|
10
|
+
* gate(漏 gate-6-layers/gate-registry/gate-12-file-hygiene)
|
|
11
|
+
* - doctor EXPECTED_GATE_SCRIPTS 枚举 6 个 gate(漏 registry + gate-6-layers)
|
|
12
|
+
* 每加一个文件都要记得同步改这四处,忘了就是静默不部署(post-commit 与
|
|
13
|
+
* hook-module-resolution.sh 都曾这样漏过,#783 的 gate-6-layers.sh 是第三次重演)。
|
|
14
|
+
*
|
|
15
|
+
* 本模块是唯一事实源:所有安装/更新/卸载/诊断链路都从这里取文件列表,禁止持有
|
|
16
|
+
* 私有字面量清单(AC-DEPLOY-07 的 AST+标记块静态断言在测试中强制这一点)。
|
|
17
|
+
* 新增一个待部署文件时只需改这里 + 同步生成的 githooks/deploy-manifest.sh 投影
|
|
18
|
+
* (scripts/generate-deploy-manifest.cjs --check 在 CI 拦截双投影漂移)。
|
|
19
|
+
*
|
|
20
|
+
* 与 hook-module-resolution.js 正交:后者管"运行时解析顺序"(哪个目录的副本优先),
|
|
21
|
+
* 本模块管"部署哪些文件"(安装时拷什么)。两者无共享状态。
|
|
22
|
+
*
|
|
23
|
+
* 数据契约 v1(冻结;破坏性变更需升版本并同步 specification.yaml):
|
|
24
|
+
* HOOK_FILES 随 hook 部署到 hooks 目标目录的脚本(平铺,无子目录)
|
|
25
|
+
* GATE_FILES 门禁脚本(10 个 gate-*.sh + sprint-gate.sh)。部署目标依链路而异:
|
|
26
|
+
* 全局 copyAdapters → ~/.config/xp-gate/adapters/(pre-commit GATE_DIR
|
|
27
|
+
* 的 gate_adapter_dir tier 搜 adapters/);项目内 install.sh →
|
|
28
|
+
* .git/hooks/(gate_script_dir tier)。copyHooks 不拷 gate 是正确的
|
|
29
|
+
* ——GATE_DIR 不搜 hooks/。
|
|
30
|
+
* ADAPTER_COMMON adapter-common.sh(适配器基础设施,单独字段,部署到 adapters/)
|
|
31
|
+
* HOOKS_LIB hooks/lib/(now-ms.sh 等,被 pre-commit 运行时 source)
|
|
32
|
+
*
|
|
33
|
+
* 防漏改:deploy-manifest.test.js 遍历 canonical githooks/ 比对 HOOK_FILES/GATE_FILES,
|
|
34
|
+
* 新增 hook/gate 脚本忘改本清单 → 测试红(#783 建议②的回归测试)。
|
|
35
|
+
*/
|
|
36
|
+
'use strict';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 随 hook 部署到 hooks 目标目录的脚本(平铺,无子目录)。
|
|
40
|
+
* hook-module-resolution.sh 是 #505 生成的解析表,pre-commit 顶部 source 它
|
|
41
|
+
* (缺失则 fail-closed FATAL),必须随 hook 一起部署。
|
|
42
|
+
*/
|
|
43
|
+
const HOOK_FILES = Object.freeze([
|
|
44
|
+
'pre-commit',
|
|
45
|
+
'pre-push',
|
|
46
|
+
'post-commit',
|
|
47
|
+
'post-merge',
|
|
48
|
+
'hook-module-resolution.sh',
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 门禁脚本全集(11 个 = 10 个 gate-*.sh + sprint-gate.sh)。
|
|
53
|
+
* sprint-gate.sh(Gate S)与 gate 套件一起部署(copyAdapters/update-hooks 都拷它,
|
|
54
|
+
* pre-push Gate S 搜 4 个 tier 兼容 hooks/ 与 adapters/ 两种落点)。
|
|
55
|
+
*/
|
|
56
|
+
const GATE_FILES = Object.freeze([
|
|
57
|
+
'gate-3.sh',
|
|
58
|
+
'gate-4.sh',
|
|
59
|
+
'gate-6-layers.sh',
|
|
60
|
+
'gate-7.sh',
|
|
61
|
+
'gate-8.sh',
|
|
62
|
+
'gate-10.sh',
|
|
63
|
+
'gate-12-file-hygiene.sh',
|
|
64
|
+
'gate-13-compiler-strictness.sh',
|
|
65
|
+
'gate-registry.sh',
|
|
66
|
+
'sprint-gate.sh',
|
|
67
|
+
]);
|
|
68
|
+
|
|
69
|
+
/** 适配器基础设施(detect_project_lang/route_to_adapter),部署到 adapters/。 */
|
|
70
|
+
const ADAPTER_COMMON = 'adapter-common.sh';
|
|
71
|
+
|
|
72
|
+
/** hooks/lib/(now-ms.sh 等,被 pre-commit 运行时 source),整目录部署。 */
|
|
73
|
+
const HOOKS_LIB = 'lib';
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 既非「无扩展名的普通 hook」也非 `gate-*.sh` 的部署脚本(REQ-DEPLOY-002)。
|
|
77
|
+
*
|
|
78
|
+
* WHY A THIRD LIST IS NEEDED
|
|
79
|
+
* --------------------------
|
|
80
|
+
* 既有断言按类别检查:`HOOK_FILES` 覆盖「顶层无扩展名的普通文件」,
|
|
81
|
+
* `GATE_FILES` 覆盖 `gate-*.sh` + `sprint-gate.sh`。于是下面这些文件落进了
|
|
82
|
+
* 类别的缝里——它们既不是普通 hook,也不是 gate-*.sh,因此从来没有任何一条
|
|
83
|
+
* 断言问过「它们在哪份清单里」,而它们确实在 `src/npm-package/hooks/` 下:
|
|
84
|
+
*
|
|
85
|
+
* adapter-common.sh 适配器基础设施(被 pre-commit/pre-push source)
|
|
86
|
+
* deploy-manifest.sh 本清单自身的 shell 投影(供 shell 侧安装器读取)
|
|
87
|
+
* install.sh 项目内安装器
|
|
88
|
+
* lib/** hooks/lib/ 下被运行时 source 的模块
|
|
89
|
+
*
|
|
90
|
+
* 「按类别断言」的失效方式很隐蔽:新增一类文件时,它不匹配任何既有类别,
|
|
91
|
+
* 于是所有断言继续通过,而文件不被部署。这正是 #783 第三次重演的机制。
|
|
92
|
+
*
|
|
93
|
+
* 因此本清单的断言方式是**枚举目录**(见 deploy-manifest-completeness.test.js),
|
|
94
|
+
* 不比对手写清单:漏了一项就是红的,不需要有人记得加断言。
|
|
95
|
+
*
|
|
96
|
+
* 路径一律相对 `src/npm-package/hooks/`,正斜杠分隔。
|
|
97
|
+
* `lib/` 下逐个文件列出(而不是写目录名 'lib')——写目录名会让「目录里新增
|
|
98
|
+
* 一个模块」再次逃脱断言,正是本清单要消灭的那种漏。
|
|
99
|
+
*/
|
|
100
|
+
const MODULE_FILES = Object.freeze([
|
|
101
|
+
ADAPTER_COMMON,
|
|
102
|
+
'deploy-manifest.sh',
|
|
103
|
+
'install.sh',
|
|
104
|
+
// #798: the ordered gate chain. `gate-driver.sh` holds XP_GATE_ORDER and the
|
|
105
|
+
// loader/runner; `gate-entries/` holds one body per gate. pre-commit FATALs
|
|
106
|
+
// when either is missing, so a consumer repo that receives hooks without
|
|
107
|
+
// these has a hook that cannot run a single gate -- the failure #783 kept
|
|
108
|
+
// producing by adding a new file category nobody had an assertion for.
|
|
109
|
+
'gate-driver.sh',
|
|
110
|
+
'gate-entries/gate-0-entry.sh',
|
|
111
|
+
'gate-entries/gate-1-entry.sh',
|
|
112
|
+
'gate-entries/gate-2-entry.sh',
|
|
113
|
+
'gate-entries/gate-3-entry.sh',
|
|
114
|
+
'gate-entries/gate-4-entry.sh',
|
|
115
|
+
'gate-entries/gate-5-entry.sh',
|
|
116
|
+
'gate-entries/gate-6-entry.sh',
|
|
117
|
+
'gate-entries/gate-7-entry.sh',
|
|
118
|
+
'gate-entries/gate-8-entry.sh',
|
|
119
|
+
'gate-entries/gate-9-entry.sh',
|
|
120
|
+
'gate-entries/gate-10-entry.sh',
|
|
121
|
+
'gate-entries/gate-11-entry.sh',
|
|
122
|
+
'gate-entries/gate-12-entry.sh',
|
|
123
|
+
'gate-entries/gate-12b-entry.sh',
|
|
124
|
+
'gate-entries/gate-12c-entry.sh',
|
|
125
|
+
'gate-entries/gate-13-entry.sh',
|
|
126
|
+
'gate-entries/subdir-restore.sh',
|
|
127
|
+
'lib/Measure-PowerShellComplexity.ps1',
|
|
128
|
+
'lib/assertion-quality.sh',
|
|
129
|
+
'lib/audit-sanitize.sh',
|
|
130
|
+
'lib/ccn-ratchet.sh',
|
|
131
|
+
'lib/coverage-total.sh',
|
|
132
|
+
'lib/diff-coverage.sh',
|
|
133
|
+
'lib/docs-only.sh',
|
|
134
|
+
'lib/gate-5c-alignment.sh',
|
|
135
|
+
'lib/java-test-selection.sh',
|
|
136
|
+
'lib/jscpd-run.sh',
|
|
137
|
+
'lib/layer-baseline.cjs',
|
|
138
|
+
'lib/native-path.sh',
|
|
139
|
+
'lib/now-ms.sh',
|
|
140
|
+
'lib/prepush-score.py',
|
|
141
|
+
'lib/python-incremental-typecheck.sh',
|
|
142
|
+
'lib/python-test-selection.sh',
|
|
143
|
+
'lib/sprint-gate-report.sh',
|
|
144
|
+
'lib/test-failure.sh',
|
|
145
|
+
'lib/toolchain-path.sh',
|
|
146
|
+
'lib/typecheck.sh',
|
|
147
|
+
'lib/validate-code-walkthrough.cjs',
|
|
148
|
+
]);
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* `src/npm-package/hooks/` 下**确实不该部署**的文件。
|
|
152
|
+
*
|
|
153
|
+
* 实测结论:当前为空。`hooks/` 下 39 个文件(递归)每一个都应该被部署,
|
|
154
|
+
* 没有例外——这不是假设,是 `find src/npm-package/hooks -type f` 的实测结果。
|
|
155
|
+
*
|
|
156
|
+
* 保留这个空数组而不是删掉概念,是因为「不需要豁免」本身是需要被断言的:
|
|
157
|
+
* 一旦有人往这里加一项,测试会同时检查三件事——
|
|
158
|
+
* (a) 名单逐项等于期望值(现在是空,加一项就红,迫使那次决策被显式做出);
|
|
159
|
+
* (b) 名单里不含 .sh、不含非点开头的文件;
|
|
160
|
+
* (c) 名单里的每一项都真实存在于 hooks/ 下(防死字符串式豁免)。
|
|
161
|
+
*
|
|
162
|
+
* 初版曾把 `.DS_Store` / `.gitkeep` 写在这里,但 `hooks/` 下并没有这两个文件
|
|
163
|
+
* ——那正是 (c) 要抓的「豁免了不存在的东西,等于豁免失效却看不出来」。
|
|
164
|
+
*/
|
|
165
|
+
const NON_DEPLOYABLE = Object.freeze([]);
|
|
166
|
+
|
|
167
|
+
module.exports = Object.freeze({
|
|
168
|
+
HOOK_FILES,
|
|
169
|
+
GATE_FILES,
|
|
170
|
+
MODULE_FILES,
|
|
171
|
+
NON_DEPLOYABLE,
|
|
172
|
+
ADAPTER_COMMON,
|
|
173
|
+
HOOKS_LIB,
|
|
174
|
+
});
|
package/lib/doctor.js
CHANGED
|
@@ -451,8 +451,16 @@ function pathsEquivalent(a, b) {
|
|
|
451
451
|
* exist on both sides are compared, so a repo without post-merge is not flagged.
|
|
452
452
|
* The lib/ shared libraries (sourced by pre-commit at runtime) are covered
|
|
453
453
|
* separately by diagnoseHookDrift/syncGlobalHooksFromRepo (#488).
|
|
454
|
+
*
|
|
455
|
+
* Selected by name from the deploy manifest rather than retyped (REQ-DEPLOY-001):
|
|
456
|
+
* post-commit and hook-module-resolution.sh are deliberately excluded — the
|
|
457
|
+
* former is written only at install time, the latter is generated on both sides
|
|
458
|
+
* from the same source, so comparing them reports drift that does not exist.
|
|
454
459
|
*/
|
|
455
|
-
const
|
|
460
|
+
const DRIFT_EXCLUDED_HOOKS = new Set(['post-commit', 'hook-module-resolution.sh']);
|
|
461
|
+
const DRIFT_COMPARED_HOOKS = require('./deploy-manifest.js').HOOK_FILES.filter(
|
|
462
|
+
h => !DRIFT_EXCLUDED_HOOKS.has(h),
|
|
463
|
+
);
|
|
456
464
|
|
|
457
465
|
/**
|
|
458
466
|
* Classify the contents of an installed hooks directory (#664).
|
|
@@ -530,8 +538,26 @@ function gitLfsHookSource(filePath) {
|
|
|
530
538
|
* the hooks source them and die without them:
|
|
531
539
|
* - hook-module-resolution.sh (#505): pre-commit aborts FATAL when the module
|
|
532
540
|
* resolution order is missing. It is generated from lib/hook-module-resolution.js.
|
|
533
|
-
|
|
534
|
-
|
|
541
|
+
* - gate-driver.sh and gate-entries/*.sh (#798): pre-commit now loads its gate
|
|
542
|
+
* chain from the driver, so an installed copy without them aborts with
|
|
543
|
+
* "FATAL: could not load gate-driver.sh" and NO commit can land at all.
|
|
544
|
+
*
|
|
545
|
+
* The #798 entries are DERIVED from the deploy manifest, not listed here. A
|
|
546
|
+
* hand-maintained list is precisely how this drifted: the driver and its entries
|
|
547
|
+
* were added to HOOK_FILES/MODULE_FILES and to the mirror check, but this module
|
|
548
|
+
* kept its own one-element list, so `doctor --sync-hooks` reported success while
|
|
549
|
+
* leaving the installed copy unable to run a single gate. Deriving removes the
|
|
550
|
+
* second declaration of the same fact.
|
|
551
|
+
*/
|
|
552
|
+
const HOOK_SUPPORT_FILES = [
|
|
553
|
+
'hook-module-resolution.sh',
|
|
554
|
+
// #798: the driver, its gate entries, and the lib/ helpers they source
|
|
555
|
+
// (now-ms.sh is required by both hooks for the single-clock duration rule).
|
|
556
|
+
// Derived from the deploy manifest so this list cannot fall behind it.
|
|
557
|
+
...require('./deploy-manifest.js').MODULE_FILES.filter(
|
|
558
|
+
(rel) => rel === 'gate-driver.sh' || rel.startsWith('gate-entries/') || rel.startsWith('lib/'),
|
|
559
|
+
),
|
|
560
|
+
];
|
|
535
561
|
|
|
536
562
|
/**
|
|
537
563
|
* Compare the hooks that actually execute (the installed copy under
|
|
@@ -1636,6 +1662,12 @@ function syncGlobalHooksFromRepo(ctx = {}) {
|
|
|
1636
1662
|
}
|
|
1637
1663
|
const backup = backupBeforeOverwrite(target, backupsDir);
|
|
1638
1664
|
if (backup) backups.push(backup);
|
|
1665
|
+
// #798: support files may live in a subdirectory (gate-entries/*.sh). The
|
|
1666
|
+
// install directory has no such subdirectory yet on an upgraded install, and
|
|
1667
|
+
// copyFileSync does not create parents -- the entries failed with ENOENT
|
|
1668
|
+
// while gate-driver.sh succeeded, leaving a half-synced hook that dies on
|
|
1669
|
+
// its first gate instead of before any.
|
|
1670
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
1639
1671
|
fs.copyFileSync(source, target);
|
|
1640
1672
|
appendDeployLogEntry(deployLog, { file: name, version, backup });
|
|
1641
1673
|
synced.push(name);
|
|
@@ -1759,16 +1791,16 @@ function shouldParseCheck(hookPath) {
|
|
|
1759
1791
|
|
|
1760
1792
|
/**
|
|
1761
1793
|
* Expected gate scripts that should be present in the adapters directory.
|
|
1762
|
-
*
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
'gate-
|
|
1771
|
-
|
|
1794
|
+
* Derived from the deploy manifest (REQ-DEPLOY-001, AC-DEPLOY-07): doctor can
|
|
1795
|
+
* only report "missing gate scripts" for gates that something actually tries to
|
|
1796
|
+
* deploy, and that set lives in exactly one place.
|
|
1797
|
+
*
|
|
1798
|
+
* The gate registry is excluded on purpose — it is the routing table the hooks
|
|
1799
|
+
* source, and is validated by its own check rather than by presence here.
|
|
1800
|
+
*/
|
|
1801
|
+
const EXPECTED_GATE_SCRIPTS = require('./deploy-manifest.js').GATE_FILES.filter(
|
|
1802
|
+
g => g !== 'gate-registry.sh',
|
|
1803
|
+
);
|
|
1772
1804
|
|
|
1773
1805
|
async function checkAdapters(checks, mode, gitDirPromise) {
|
|
1774
1806
|
const gitDir = typeof gitDirPromise === 'string' ? gitDirPromise : await gitDirPromise;
|
|
@@ -2755,7 +2787,7 @@ function fixStaleHooks(config) {
|
|
|
2755
2787
|
* the very installer residue #500 is about (#495 Round 3).
|
|
2756
2788
|
*/
|
|
2757
2789
|
function staleSyncEntries(label, srcDir, hooksDestDir, adaptersDestDir) {
|
|
2758
|
-
if (
|
|
2790
|
+
if (DRIFT_COMPARED_HOOKS.includes(label) || label === 'sprint-gate.sh') {
|
|
2759
2791
|
const hooksSource = label === 'sprint-gate.sh'
|
|
2760
2792
|
? path.join(srcDir, label)
|
|
2761
2793
|
: path.join(srcDir, 'hooks', label);
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module gate-capability
|
|
3
|
+
* @test REQ-D2
|
|
4
|
+
* @intent Publish which execution path can run which gate, derived from
|
|
5
|
+
* `githooks/gate-registry.sh` rather than declared a second time.
|
|
6
|
+
*
|
|
7
|
+
* WHY THIS EXISTS. Before it, the only statement of what the CLI could
|
|
8
|
+
* run was a footnote in a design document, and it was wrong in both
|
|
9
|
+
* directions: it said the CLI was "structurally missing 0/1/5/9/11/12/13"
|
|
10
|
+
* while the CLI in fact offered all fourteen subcommands and silently
|
|
11
|
+
* declined seven of them. A reader could not tell "the CLI cannot run
|
|
12
|
+
* this gate" from "the CLI ran it and it passed", because both looked
|
|
13
|
+
* identical on the one signal that matters -- the exit code.
|
|
14
|
+
*
|
|
15
|
+
* The fixed points are:
|
|
16
|
+
*
|
|
17
|
+
* 1. Capability is DERIVED. Each registry row declares a `hook` and
|
|
18
|
+
* whether the gate is `inline` (living inside the hook) or a separate
|
|
19
|
+
* script. A gate that lives inside the hook cannot be executed on its
|
|
20
|
+
* own, so it is `hook-only`; anything with its own implementation is
|
|
21
|
+
* `runnable`. Nothing here lists gate numbers.
|
|
22
|
+
*
|
|
23
|
+
* 2. `hook-only` is a first-class verdict, not a footnote: it maps to
|
|
24
|
+
* GATE_NOT_RUN and exit 2, so a caller reading only the exit status
|
|
25
|
+
* still cannot mistake it for a pass.
|
|
26
|
+
*
|
|
27
|
+
* 3. The vocabulary is closed (`runnable` | `hook-only`). An open one
|
|
28
|
+
* would let a new gate appear as "unknown" and be read as "fine".
|
|
29
|
+
*
|
|
30
|
+
* Not here on purpose: the pre-push gates (M/M2/ML/UI/MW/S). They have
|
|
31
|
+
* no CLI subcommand at all, so reporting them as `runnable` would be a
|
|
32
|
+
* second false claim of the same kind.
|
|
33
|
+
*/
|
|
34
|
+
'use strict';
|
|
35
|
+
|
|
36
|
+
const { loadRegistry, parseRegistry, deriveGateTable } = require('./gate-identity');
|
|
37
|
+
|
|
38
|
+
/** The only capability values the code can honour. */
|
|
39
|
+
const CAPABILITY = Object.freeze({
|
|
40
|
+
/** A separate process can run this gate on its own and produce a verdict. */
|
|
41
|
+
RUNNABLE: 'runnable',
|
|
42
|
+
/** Runs during `git commit` only: needs the staged set, which no other caller has. */
|
|
43
|
+
COMMIT_ONLY: 'commit-only',
|
|
44
|
+
/** Runs during `git push`. Executes outside a hook like any gate, but has no subcommand. */
|
|
45
|
+
PUSH_ONLY: 'push-only',
|
|
46
|
+
/** Registered nowhere: say so rather than implying a surface can run it. */
|
|
47
|
+
UNREACHABLE: 'unreachable',
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const ALL_CAPABILITIES = Object.freeze(Object.values(CAPABILITY));
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Derive one capability row per registry entry.
|
|
54
|
+
*
|
|
55
|
+
* THE TRAP THIS AVOIDS. The obvious derivation is "`impl: inline` means the body
|
|
56
|
+
* lives inside the hook, therefore the CLI cannot run it". That is WRONG, and
|
|
57
|
+
* measuring caught it: gate 2 is declared `inline` in the registry and the CLI
|
|
58
|
+
* runs it perfectly well (`xp-gate gate-2` executes jscpd). `impl` answers "which
|
|
59
|
+
* file owns this gate's implementation"; CLI runnability answers "can a separate
|
|
60
|
+
* process run it". Those are orthogonal, and deriving one from the other would
|
|
61
|
+
* have produced a matrix that contradicted the binary it describes -- a prettier
|
|
62
|
+
* version of the footnote this module replaces.
|
|
63
|
+
*
|
|
64
|
+
* So runnability is asked of the thing that decides it: the runner's own
|
|
65
|
+
* `preCommitOnly` declaration, which exists precisely because those gates need
|
|
66
|
+
* git-staged context. The registry supplies the identity and the hook; the runner
|
|
67
|
+
* supplies the capability. Neither is restated here.
|
|
68
|
+
*
|
|
69
|
+
* @param {Array<object>} rows registry rows
|
|
70
|
+
* @param {Map<string, object>} runnerRegistry the runner's per-gate declarations
|
|
71
|
+
* @returns {Array<{gate: string, slug: string, hook: string, impl: string, capability: string, reason: string|null}>}
|
|
72
|
+
*/
|
|
73
|
+
function deriveCapability(rows, runnerRegistry) {
|
|
74
|
+
return rows.map((row) => {
|
|
75
|
+
const isPreCommit = row.hook === 'pre-commit';
|
|
76
|
+
|
|
77
|
+
// Pre-push gates are NOT "hook-only". They run outside a hook like any gate
|
|
78
|
+
// -- `git push` invokes them -- they simply have no `xp-gate` subcommand. The
|
|
79
|
+
// first version of this module called them hook-only and explained the
|
|
80
|
+
// difference in a reason string, which is exactly the kind of conflation the
|
|
81
|
+
// module exists to remove: a closed enum whose `--json` output is wrong on six
|
|
82
|
+
// of twenty entries is worse than no enum, because a machine reads it.
|
|
83
|
+
if (!isPreCommit) {
|
|
84
|
+
const hasSubcommand = Boolean(runnerRegistry && runnerRegistry[String(row.number)]);
|
|
85
|
+
return {
|
|
86
|
+
gate: row.number,
|
|
87
|
+
slug: row.name,
|
|
88
|
+
hook: row.hook,
|
|
89
|
+
impl: row.impl,
|
|
90
|
+
capability: hasSubcommand ? CAPABILITY.RUNNABLE : CAPABILITY.PUSH_ONLY,
|
|
91
|
+
reason: hasSubcommand ? null : 'runs on git push; no xp-gate subcommand is registered for it',
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const runnerGate = runnerRegistry ? runnerRegistry[String(row.number)] : null;
|
|
96
|
+
|
|
97
|
+
if (!runnerGate) {
|
|
98
|
+
// Registered in the hook but unknown to the runner: a definition fault, not
|
|
99
|
+
// a capability. Reporting `commit-only` here would hide a gate that runs at
|
|
100
|
+
// commit time but that the CLI cannot even name.
|
|
101
|
+
return {
|
|
102
|
+
gate: row.number,
|
|
103
|
+
slug: row.name,
|
|
104
|
+
hook: row.hook,
|
|
105
|
+
impl: row.impl,
|
|
106
|
+
capability: CAPABILITY.UNREACHABLE,
|
|
107
|
+
reason: 'declared in the registry with no CLI runner registered for it',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (runnerGate.preCommitOnly) {
|
|
112
|
+
return {
|
|
113
|
+
gate: row.number,
|
|
114
|
+
slug: row.name,
|
|
115
|
+
hook: row.hook,
|
|
116
|
+
impl: row.impl,
|
|
117
|
+
capability: CAPABILITY.COMMIT_ONLY,
|
|
118
|
+
reason: runnerGate.reason || 'needs the git-staged set, which exists only during git commit',
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
gate: row.number,
|
|
124
|
+
slug: row.name,
|
|
125
|
+
hook: row.hook,
|
|
126
|
+
impl: row.impl,
|
|
127
|
+
capability: CAPABILITY.RUNNABLE,
|
|
128
|
+
reason: null,
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Check the two sources against each other and report disagreement.
|
|
135
|
+
*
|
|
136
|
+
* WHY THIS EXISTS. Capability needs two facts: which hook owns a gate (the
|
|
137
|
+
* registry) and whether a separate process can run it (the runner's
|
|
138
|
+
* `preCommitOnly`). Reading one and inferring the other was measured wrong --
|
|
139
|
+
* gate 2 is declared `impl:inline` and the CLI runs it fine. Keeping both is
|
|
140
|
+
* therefore correct, but two sources with no cross-check is how the footnote this
|
|
141
|
+
* module replaces went stale unnoticed.
|
|
142
|
+
*
|
|
143
|
+
* The invariant runs in BOTH directions. Checking only registry->runner leaves the
|
|
144
|
+
* opposite rot invisible: a runner gate with no registry row would be offered as a
|
|
145
|
+
* subcommand, run, and appear nowhere in this report -- so the report would say
|
|
146
|
+
* "20 gates, 7 runnable" while the binary offers 21. One direction only is the
|
|
147
|
+
* shape of check that looks thorough and covers half the failure.
|
|
148
|
+
*
|
|
149
|
+
* A pre-push registry row deliberately has no runner entry (there is no
|
|
150
|
+
* subcommand), so that direction is scoped to pre-commit rows; the reverse
|
|
151
|
+
* direction is scoped to runner ids that the registry does not declare at all.
|
|
152
|
+
*
|
|
153
|
+
* @param {Array<object>} rows registry rows
|
|
154
|
+
* @param {Map<string, object>|null} runnerRegistry
|
|
155
|
+
* @returns {Array<{gate: string, slug: string, problem: string}>}
|
|
156
|
+
*/
|
|
157
|
+
function detectSourceDrift(rows, runnerRegistry) {
|
|
158
|
+
if (!runnerRegistry) {
|
|
159
|
+
return [{ gate: '*', slug: '*', problem: 'the runner registry could not be loaded at all' }];
|
|
160
|
+
}
|
|
161
|
+
const problems = [];
|
|
162
|
+
const declared = new Set(rows.map((row) => String(row.number)));
|
|
163
|
+
|
|
164
|
+
// Direction 1: registry says a gate runs at commit time, runner has never heard
|
|
165
|
+
// of it -> the report cannot describe it, and it would be `unreachable`.
|
|
166
|
+
for (const row of rows) {
|
|
167
|
+
if (row.hook !== 'pre-commit') continue;
|
|
168
|
+
if (!runnerRegistry[String(row.number)]) {
|
|
169
|
+
problems.push({
|
|
170
|
+
gate: row.number,
|
|
171
|
+
slug: row.name,
|
|
172
|
+
problem: 'declared in githooks/gate-registry.sh for pre-commit, absent from gate-runner GATE_REGISTRY',
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Direction 2: runner offers a gate the registry never declares -> the CLI has a
|
|
178
|
+
// subcommand for a gate with no identity, so it is missing from this report
|
|
179
|
+
// while remaining executable.
|
|
180
|
+
//
|
|
181
|
+
// SCOPED TO NUMBERED GATES, and measuring is why. The runner also registers
|
|
182
|
+
// standalone ANALYSERS that are not part of the numbered gate chain --
|
|
183
|
+
// `python-health`, `test-layers`, `pbt`. They are reached through
|
|
184
|
+
// `check --gates=<alias>`, they are not gate N of anything, and the registry has
|
|
185
|
+
// no row to give them because there is no number to give. Counting them as drift
|
|
186
|
+
// would make this check report three permanent false positives in a healthy
|
|
187
|
+
// checkout, and a check that always fires teaches its reader to ignore it -- the
|
|
188
|
+
// same fate as the footnote. A numbered runner id with no registry row is the
|
|
189
|
+
// real defect: it is `xp-gate gate-N` with no identity behind the N.
|
|
190
|
+
for (const id of Object.keys(runnerRegistry)) {
|
|
191
|
+
if (!/^\d+$/.test(String(id))) continue;
|
|
192
|
+
if (declared.has(String(id))) continue;
|
|
193
|
+
const runnerGate = runnerRegistry[id] || {};
|
|
194
|
+
problems.push({
|
|
195
|
+
gate: String(id),
|
|
196
|
+
slug: runnerGate.name || String(id),
|
|
197
|
+
problem: 'numbered gate present in gate-runner GATE_REGISTRY, absent from githooks/gate-registry.sh '
|
|
198
|
+
+ '(the CLI offers a gate-N with no identity behind the number)',
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return problems;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* The full capability matrix for this checkout.
|
|
206
|
+
* @param {Map<string, object>} [runnerRegistry]
|
|
207
|
+
* @returns {{schemaVersion: string, gates: Array<object>, summary: object}}
|
|
208
|
+
*/
|
|
209
|
+
function capabilityMatrix(runnerRegistry) {
|
|
210
|
+
const registry = loadRegistry();
|
|
211
|
+
const rows = parseRegistry(registry.text);
|
|
212
|
+
const resolvedRunner = runnerRegistry === undefined ? loadRunnerRegistry() : runnerRegistry;
|
|
213
|
+
const gates = deriveCapability(rows, resolvedRunner);
|
|
214
|
+
const drift = detectSourceDrift(rows, resolvedRunner);
|
|
215
|
+
|
|
216
|
+
const summary = gates.reduce((acc, gate) => {
|
|
217
|
+
acc[gate.capability] = (acc[gate.capability] || 0) + 1;
|
|
218
|
+
return acc;
|
|
219
|
+
}, {});
|
|
220
|
+
|
|
221
|
+
return {
|
|
222
|
+
schemaVersion: '1.1',
|
|
223
|
+
// Which source answers which question, stated in the output itself so a
|
|
224
|
+
// reader does not have to infer the authority from the code.
|
|
225
|
+
sources: {
|
|
226
|
+
identity: 'githooks/gate-registry.sh (owns name, number, hook, impl)',
|
|
227
|
+
runnability: 'src/npm-package/lib/gate-runner.js GATE_REGISTRY.preCommitOnly (owns whether a separate process can run it)',
|
|
228
|
+
note: 'These are orthogonal: gate 2 is `impl:inline` in the registry AND runnable by the CLI. '
|
|
229
|
+
+ 'Neither source is derived from the other; detectSourceDrift cross-checks them in both directions.',
|
|
230
|
+
// `unreachable` living inside a capability enum needs its justification in
|
|
231
|
+
// the machine-readable output, not only in a comment: it is the one value
|
|
232
|
+
// that is a defect report rather than a capability, and it is only tolerable
|
|
233
|
+
// because it is required to be zero.
|
|
234
|
+
unreachableMeans: 'A gate declared in the registry with no runner. Always a defect, never a '
|
|
235
|
+
+ 'normal state: a healthy checkout reports 0.',
|
|
236
|
+
// The sentinel hazard, stated where a consumer of this JSON will read it.
|
|
237
|
+
sentinel: 'runGate() returns GATE_NOT_RUN (a string) for "did not run" and a number '
|
|
238
|
+
+ 'otherwise. Compare with === against the sentinel or coerce explicitly; arithmetic or '
|
|
239
|
+
+ '`=== 0` on the return value will silently misread it.',
|
|
240
|
+
},
|
|
241
|
+
registry: registry.copies[0],
|
|
242
|
+
summary: {
|
|
243
|
+
total: gates.length,
|
|
244
|
+
runnable: summary[CAPABILITY.RUNNABLE] || 0,
|
|
245
|
+
commitOnly: summary[CAPABILITY.COMMIT_ONLY] || 0,
|
|
246
|
+
pushOnly: summary[CAPABILITY.PUSH_ONLY] || 0,
|
|
247
|
+
unreachable: summary[CAPABILITY.UNREACHABLE] || 0,
|
|
248
|
+
},
|
|
249
|
+
// Empty means the two sources agree. Non-empty is a defect report, not a
|
|
250
|
+
// capability report, and is surfaced first in the rendered output.
|
|
251
|
+
drift,
|
|
252
|
+
gates,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* The runner's own gate declarations. Loaded lazily so this module can be
|
|
258
|
+
* imported by a test that only wants `deriveCapability` with injected inputs.
|
|
259
|
+
* @returns {Map<string, object>|null}
|
|
260
|
+
*/
|
|
261
|
+
function loadRunnerRegistry() {
|
|
262
|
+
try {
|
|
263
|
+
return require('./gate-runner').GATE_REGISTRY;
|
|
264
|
+
} catch {
|
|
265
|
+
// A packaging fault in the runner should not make the capability report
|
|
266
|
+
// explode; an empty map yields "no CLI runner registered" for every gate,
|
|
267
|
+
// which is a visible, honest answer.
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Capability of one gate, looked up by number or slug.
|
|
274
|
+
* @param {string} gateId
|
|
275
|
+
* @returns {object|null}
|
|
276
|
+
*/
|
|
277
|
+
function capabilityOf(gateId) {
|
|
278
|
+
const wanted = String(gateId);
|
|
279
|
+
const { gates } = capabilityMatrix();
|
|
280
|
+
return gates.find((gate) => gate.gate === wanted || gate.slug === wanted) || null;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
module.exports = {
|
|
284
|
+
CAPABILITY,
|
|
285
|
+
ALL_CAPABILITIES,
|
|
286
|
+
deriveCapability,
|
|
287
|
+
detectSourceDrift,
|
|
288
|
+
capabilityMatrix,
|
|
289
|
+
capabilityOf,
|
|
290
|
+
deriveGateTable,
|
|
291
|
+
};
|