kld-sdd 2.6.16 → 2.6.21
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/bin/kld-sdd-init.js +10 -0
- package/kld-sdd-guide.html +22 -0
- package/lib/device-auth-cli.js +130 -0
- package/lib/device-auth.js +345 -0
- package/lib/init-account-binding.js +108 -0
- package/lib/init.js +238 -55
- package/lib/skills-bundle.js +20 -1
- package/lib/tool-profiles.js +8 -0
- package/package.json +7 -3
- package/skywalk-sdd/apply-worktree-finish.cjs +2 -23
- package/skywalk-sdd/context-client.cjs +38 -87
- package/skywalk-sdd/index.cjs +860 -132
- package/skywalk-sdd/kb-sync-identity.cjs +780 -0
- package/skywalk-sdd/kb-upload.cjs +505 -0
- package/skywalk-sdd/lib/shared.cjs +811 -0
- package/skywalk-sdd/lib/usage-contract.cjs +276 -0
- package/skywalk-sdd/lib/usage-reporter.cjs +354 -0
- package/skywalk-sdd/lib/user-config.cjs +157 -0
- package/skywalk-sdd/metrics-v3.cjs +138 -8
- package/skywalk-sdd/ontology/archive-package.cjs +19 -34
- package/skywalk-sdd/ontology/change-lock.cjs +3 -7
- package/skywalk-sdd/ontology/external-key.cjs +18 -4
- package/skywalk-sdd/ontology/id.cjs +26 -5
- package/skywalk-sdd/ontology/identity-index.cjs +3 -7
- package/skywalk-sdd/ontology/resolve-spec-root.cjs +20 -6
- package/skywalk-sdd/ontology/runtime.cjs +16 -12
- package/skywalk-sdd/ontology/traceability-validator.cjs +7 -4
- package/skywalk-sdd/reporting/change-report-markdown.cjs +137 -19
- package/skywalk-sdd/reporting/change-report-model.cjs +993 -14
- package/skywalk-sdd/reporting/change-report-renderer.cjs +106 -41
- package/skywalk-sdd/reporting/change-report-view-model.cjs +272 -43
- package/skywalk-sdd/reporting/core-metric-definitions.cjs +192 -0
- package/skywalk-sdd/spec-root.cjs +31 -0
- package/templates/git-hooks/pre-commit-consistency-check.cjs +271 -116
- package/templates/git-hooks/pre-push-consistency-check.cjs +252 -123
- package/templates/hooks/codebuddy/hooks/hook-gate-core.cjs +327 -0
- package/templates/hooks/codebuddy/hooks/sdd-apply-test-gate.cjs +54 -9
- package/templates/hooks/codebuddy/hooks/sdd-mid-checkpoint.cjs +63 -6
- package/templates/hooks/codebuddy/hooks/sdd-tdd-rhythm-gate.cjs +113 -65
- package/templates/openspec/proposal.md +7 -3
- package/templates/openspec/spec.md +3 -3
- package/templates/skills/kld-sdd/opsx-apply/SKILL.md +8 -6
- package/templates/skills/kld-sdd/opsx-apply/checklist.md +2 -0
- package/templates/skills/kld-sdd/opsx-apply/reference.md +29 -7
- package/templates/skills/kld-sdd/opsx-archive/SKILL.md +6 -5
- package/templates/skills/kld-sdd/opsx-check/SKILL.md +49 -17
- package/templates/skills/kld-sdd/opsx-check/checklist.md +4 -2
- package/templates/skills/kld-sdd/opsx-consistency-check/SKILL.md +187 -257
- package/templates/skills/kld-sdd/opsx-consistency-check/reference.md +129 -0
- package/templates/skills/kld-sdd/opsx-design/SKILL.md +2 -2
- package/templates/skills/kld-sdd/opsx-explore/SKILL.md +2 -2
- package/templates/skills/kld-sdd/opsx-kb-config/SKILL.md +185 -0
- package/templates/skills/kld-sdd/opsx-kb-config/reference.md +127 -0
- package/templates/skills/kld-sdd/opsx-kb-ingest/SKILL.md +218 -53
- package/templates/skills/kld-sdd/opsx-kb-ingest/reference.md +51 -9
- package/templates/skills/kld-sdd/opsx-ontology-query/SKILL.md +12 -50
- package/templates/skills/kld-sdd/opsx-ontology-query/phase-3-postchange.md +2 -2
- package/templates/skills/kld-sdd/opsx-ontology-query/reference.md +1 -1
- package/templates/skills/kld-sdd/opsx-propose/SKILL.md +35 -23
- package/templates/skills/kld-sdd/opsx-propose/checklist.md +2 -0
- package/templates/skills/kld-sdd/opsx-propose/reference.md +22 -17
- package/templates/skills/kld-sdd/opsx-rules/SKILL.md +2 -2
- package/templates/skills/kld-sdd/opsx-spec/SKILL.md +19 -15
- package/templates/skills/kld-sdd/opsx-spec/checklist.md +2 -0
- package/templates/skills/kld-sdd/opsx-task/SKILL.md +2 -4
- package/templates/skills/kld-sdd/opsx-test/SKILL.md +2 -2
- package/templates/skills/kld-sdd/tdd-core/reference.md +1 -1
- package/templates/skills/kld-sdd/tdd-rules/rules/test-skeleton-telemetry.md +1 -1
- package/templates/skills/kld-sdd/opsx-kb-ingest/state.example.json +0 -7
- package/templates/skills/kld-sdd/opsx-ontology-query/state.example.json +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kld-sdd",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.21",
|
|
4
4
|
"description": "KLD SDD OpenSpec 项目初始化工具 - 一键部署 SDD skills",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"kld-sdd-init": "bin/kld-sdd-init.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"test": "node test/external-key.cjs && node test/change-key.cjs && node test/modules-and-sdd-config.cjs && node test/active-changes.cjs && node test/hook-layouts.cjs && node test/spec-package-init.cjs && node test/workspace-layout.cjs && node test/ontology-release-blockers.cjs && node test/ontology-semantic-core.cjs && node test/ontology-identity-versioning.cjs && node test/ontology-identity-continuity.cjs && node test/ontology-state-transaction.cjs && node test/ontology-process-concurrency.cjs && node test/ontology-observer-convergence.cjs && node test/ontology-working-runtime.cjs && node test/ontology-stage-materialization.cjs && node test/ontology-template-contract.cjs && node test/ontology-cli-archive.cjs && node test/archive-package-producer.cjs && node --test test/evidence-integrity-oracle.cjs test/evidence-integrity-wiring.cjs test/change-report-correctness.cjs test/report-metrics-correctness.cjs test/change-report-model-ui.cjs && node test/validate-skills-bundle.cjs && node test/tool-profiles.cjs && node test/settings-merge.cjs && node test/command-bridge.cjs && node test/codebuddy-hooks.cjs && node test/skill-content-contract.cjs && node test/init-agent-profiles.cjs && node test/init-report-runtime.cjs"
|
|
11
|
+
"test": "node test/external-key.cjs && node test/change-key.cjs && node test/modules-and-sdd-config.cjs && node test/active-changes.cjs && node test/hook-layouts.cjs && node test/spec-package-init.cjs && node test/workspace-layout.cjs && node test/ontology-release-blockers.cjs && node test/ontology-semantic-core.cjs && node test/ontology-identity-versioning.cjs && node test/ontology-identity-continuity.cjs && node test/ontology-state-transaction.cjs && node test/ontology-process-concurrency.cjs && node test/ontology-observer-convergence.cjs && node test/ontology-working-runtime.cjs && node test/ontology-stage-materialization.cjs && node test/ontology-template-contract.cjs && node test/ontology-cli-archive.cjs && node test/archive-package-producer.cjs && node --test test/evidence-integrity-oracle.cjs test/evidence-integrity-wiring.cjs test/change-report-correctness.cjs test/report-metrics-correctness.cjs test/change-report-model-ui.cjs && node test/validate-skills-bundle.cjs && node test/tool-profiles.cjs && node test/settings-merge.cjs && node test/command-bridge.cjs && node test/codebuddy-hooks.cjs && node test/skill-content-contract.cjs && node test/init-agent-profiles.cjs && node test/init-report-runtime.cjs && node test/init-output-verbosity.cjs && node test/init-account-binding.cjs && node --test test/usage-contract.test.cjs test/user-config.test.cjs test/device-auth.test.cjs test/usage-runtime-removal.test.cjs skywalk-sdd/usage-reporter.test.cjs skywalk-sdd/usage-reporting.test.cjs && node test/progress-package-artifact.test.cjs"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
14
|
"kld",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"author": "KLD Team",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"engines": {
|
|
27
|
-
"node": ">=14.
|
|
27
|
+
"node": ">=14.18.0"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
30
|
"bin/",
|
|
@@ -39,6 +39,10 @@
|
|
|
39
39
|
"skywalk-sdd/openspec-shim.cjs",
|
|
40
40
|
"skywalk-sdd/ontology/",
|
|
41
41
|
"skywalk-sdd/apply-worktree-finish.cjs",
|
|
42
|
+
"skywalk-sdd/spec-root.cjs",
|
|
43
|
+
"skywalk-sdd/lib/",
|
|
44
|
+
"skywalk-sdd/kb-upload.cjs",
|
|
45
|
+
"skywalk-sdd/kb-sync-identity.cjs",
|
|
42
46
|
"README.md"
|
|
43
47
|
]
|
|
44
48
|
}
|
|
@@ -11,32 +11,11 @@
|
|
|
11
11
|
const fs = require('fs');
|
|
12
12
|
const path = require('path');
|
|
13
13
|
const { execFileSync } = require('child_process');
|
|
14
|
+
const { parseArgs } = require('./lib/shared.cjs');
|
|
14
15
|
|
|
15
16
|
const TEMP_DIR_NAMES = ['node_modules', 'dist', '.turbo', '.next', 'coverage', 'build'];
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
const args = {};
|
|
19
|
-
for (let i = 2; i < argv.length; i++) {
|
|
20
|
-
const token = argv[i];
|
|
21
|
-
if (token === '--') continue;
|
|
22
|
-
if (token.startsWith('--')) {
|
|
23
|
-
const eq = token.indexOf('=');
|
|
24
|
-
if (eq !== -1) {
|
|
25
|
-
args[token.slice(2, eq)] = token.slice(eq + 1);
|
|
26
|
-
} else {
|
|
27
|
-
const key = token.slice(2);
|
|
28
|
-
const next = argv[i + 1];
|
|
29
|
-
if (next && !next.startsWith('--')) {
|
|
30
|
-
args[key] = next;
|
|
31
|
-
i++;
|
|
32
|
-
} else {
|
|
33
|
-
args[key] = true;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return args;
|
|
39
|
-
}
|
|
18
|
+
// parseArgs 已迁移至 lib/shared.cjs
|
|
40
19
|
|
|
41
20
|
function git(cwd, gitArgs, opts = {}) {
|
|
42
21
|
return execFileSync('git', gitArgs, {
|
|
@@ -6,17 +6,18 @@ const http = require('http');
|
|
|
6
6
|
const https = require('https');
|
|
7
7
|
const { URL } = require('url');
|
|
8
8
|
const path = require('path');
|
|
9
|
+
const {
|
|
10
|
+
parseArgs,
|
|
11
|
+
requestJson: sharedRequestJson,
|
|
12
|
+
loadKbState,
|
|
13
|
+
resolveKbParams,
|
|
14
|
+
stripBom,
|
|
15
|
+
} = require('./lib/shared.cjs');
|
|
9
16
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const equal = item.indexOf('=');
|
|
15
|
-
if (equal < 0) args[item.slice(2)] = true;
|
|
16
|
-
else args[item.slice(2, equal)] = item.slice(equal + 1);
|
|
17
|
-
}
|
|
18
|
-
return args;
|
|
19
|
-
}
|
|
17
|
+
// Re-export requestJson for external callers (API compatibility)
|
|
18
|
+
const requestJson = sharedRequestJson;
|
|
19
|
+
|
|
20
|
+
// parseArgs 已迁移至 lib/shared.cjs(统一 5 份实现)
|
|
20
21
|
|
|
21
22
|
function queryFromArgs(args) {
|
|
22
23
|
if (typeof args.query === 'string' && args.query.trim()) {
|
|
@@ -38,60 +39,8 @@ function buildEndpoint(apiBase, spaceId, kbId, mode) {
|
|
|
38
39
|
return `${base}/v1/spaces/${space}/knowledge-bases/${kb}/context/match-requirement`;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const target = new URL(url);
|
|
44
|
-
const transport = target.protocol === 'https:' ? https : http;
|
|
45
|
-
const body = JSON.stringify(payload);
|
|
46
|
-
const headers = {
|
|
47
|
-
Accept: 'application/json',
|
|
48
|
-
'Content-Type': 'application/json',
|
|
49
|
-
'Content-Length': Buffer.byteLength(body),
|
|
50
|
-
};
|
|
51
|
-
if (token) headers.Authorization = `Bearer ${token}`;
|
|
52
|
-
|
|
53
|
-
const request = transport.request(
|
|
54
|
-
{
|
|
55
|
-
hostname: target.hostname,
|
|
56
|
-
port: target.port || (target.protocol === 'https:' ? 443 : 80),
|
|
57
|
-
path: target.pathname + target.search,
|
|
58
|
-
method: 'POST',
|
|
59
|
-
headers,
|
|
60
|
-
timeout: timeoutMs,
|
|
61
|
-
},
|
|
62
|
-
(response) => {
|
|
63
|
-
let responseBody = '';
|
|
64
|
-
response.on('data', (chunk) => {
|
|
65
|
-
responseBody += chunk;
|
|
66
|
-
});
|
|
67
|
-
response.on('end', () => {
|
|
68
|
-
let parsed;
|
|
69
|
-
try {
|
|
70
|
-
parsed = responseBody ? JSON.parse(responseBody) : null;
|
|
71
|
-
} catch {
|
|
72
|
-
reject(new Error(`knowledge base returned invalid JSON (HTTP ${response.statusCode})`));
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (response.statusCode >= 400) {
|
|
76
|
-
reject(new Error(parsed?.message || `knowledge base HTTP ${response.statusCode}`));
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
// code 字段仅当存在且不为 0 时才视为业务错误(health/ingest 等管理 API 返回 code,
|
|
80
|
-
// 但 resolve/search 等 context API 直接返回 data,不包含 code 字段)
|
|
81
|
-
if (parsed?.code != null && parsed.code !== 0) {
|
|
82
|
-
reject(new Error(parsed?.message || `knowledge base error code ${parsed.code}`));
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
resolve(parsed.data);
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
);
|
|
89
|
-
request.on('timeout', () => request.destroy(new Error(`knowledge base timeout after ${timeoutMs}ms`)));
|
|
90
|
-
request.on('error', reject);
|
|
91
|
-
request.write(body);
|
|
92
|
-
request.end();
|
|
93
|
-
});
|
|
94
|
-
}
|
|
42
|
+
// requestJson 已迁移至 lib/shared.cjs(统一 HTTP 请求逻辑)
|
|
43
|
+
// 保留 const requestJson = sharedRequestJson 以维持 API 兼容
|
|
95
44
|
|
|
96
45
|
function compactContext(data, includeCandidates, mode = 'match') {
|
|
97
46
|
if (includeCandidates) return data;
|
|
@@ -157,33 +106,35 @@ function buildPayload(args, mode) {
|
|
|
157
106
|
|
|
158
107
|
async function retrieveContext(args = parseArgs(process.argv), env = process.env) {
|
|
159
108
|
// 优先从共享 state 文件读取配置(与 opsx-ontology-query / opsx-kb-ingest 共用)
|
|
160
|
-
// 搜索多个可能的 IDE skills 目录(.codebuddy / .claude / .cursor 等)
|
|
161
109
|
let stateConfig = {};
|
|
162
110
|
const stateFile = args['state-file'] || env.SDD_KB_STATE_FILE;
|
|
163
|
-
|
|
164
|
-
if (stateFile)
|
|
165
|
-
|
|
166
|
-
const ideDirs = ['.codebuddy', '.claude', '.cursor', '.vscode'];
|
|
167
|
-
for (const ide of ideDirs) {
|
|
168
|
-
candidatePaths.push(path.join(__dirname, '..', ide, 'skills', '.shared', 'kb-state.json'));
|
|
169
|
-
}
|
|
170
|
-
// 也检查 skywalk-sdd 同级的 .shared
|
|
171
|
-
candidatePaths.push(path.join(__dirname, '.shared', 'kb-state.json'));
|
|
172
|
-
for (const p of candidatePaths) {
|
|
111
|
+
|
|
112
|
+
if (stateFile) {
|
|
113
|
+
// 显式指定路径,直接读取
|
|
173
114
|
try {
|
|
174
|
-
if (fs.existsSync(
|
|
175
|
-
|
|
176
|
-
|
|
115
|
+
if (fs.existsSync(stateFile)) {
|
|
116
|
+
let raw = fs.readFileSync(stateFile, 'utf8');
|
|
117
|
+
raw = stripBom(raw);
|
|
118
|
+
stateConfig = JSON.parse(raw);
|
|
177
119
|
}
|
|
178
|
-
} catch (
|
|
120
|
+
} catch (e) {
|
|
121
|
+
console.error(`⚠️ kb-state.json 解析失败 (${stateFile}): ${e.message}`);
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
// 从 __dirname 逐层向上搜索(复用 shared.cjs 的 loadKbState)
|
|
125
|
+
const { config, warnings } = loadKbState(__dirname, env);
|
|
126
|
+
if (warnings.length > 0) {
|
|
127
|
+
for (const w of warnings) console.error(`⚠️ ${w}`);
|
|
128
|
+
}
|
|
129
|
+
stateConfig = config || {};
|
|
179
130
|
}
|
|
180
131
|
|
|
181
|
-
const apiBase
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
|
|
132
|
+
const { apiBase: kbApiBase, token: kbToken, spaceId: kbSpaceId, kbId: kbKbId, targets: kbTargets } = resolveKbParams(stateConfig, env);
|
|
133
|
+
|
|
134
|
+
const apiBase = args['api-base'] || kbApiBase;
|
|
135
|
+
const token = args.token || kbToken;
|
|
136
|
+
const spaceId = args['space-id'] || kbSpaceId;
|
|
137
|
+
const kbId = args['kb-id'] || kbKbId;
|
|
187
138
|
|
|
188
139
|
// --check-only: 只检查 KB 配置是否就绪,不发起 API 请求
|
|
189
140
|
// 用于 SDD 各阶段(propose/spec/design/task/check)统一检测 KB 可用性,消除相对路径歧义
|
|
@@ -197,13 +148,13 @@ async function retrieveContext(args = parseArgs(process.argv), env = process.env
|
|
|
197
148
|
available: false,
|
|
198
149
|
reason: 'engineering_kb_not_configured',
|
|
199
150
|
missing,
|
|
200
|
-
hint: 'Run opsx-
|
|
151
|
+
hint: 'Run /opsx-kb-config to configure kb-state.json (in spec root)',
|
|
201
152
|
};
|
|
202
153
|
}
|
|
203
154
|
return {
|
|
204
155
|
available: true,
|
|
205
156
|
api: apiBase,
|
|
206
|
-
targets:
|
|
157
|
+
targets: kbTargets,
|
|
207
158
|
};
|
|
208
159
|
}
|
|
209
160
|
|