kibi-opencode 0.5.3 → 0.6.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/README.md +31 -2
- package/dist/config.d.ts +9 -0
- package/dist/config.js +31 -0
- package/dist/file-filter.d.ts +10 -0
- package/dist/file-filter.js +57 -9
- package/dist/guidance-cache.d.ts +75 -0
- package/dist/guidance-cache.js +145 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +428 -56
- package/dist/logger.d.ts +4 -3
- package/dist/logger.js +14 -18
- package/dist/path-kind.d.ts +2 -2
- package/dist/path-kind.js +12 -4
- package/dist/prompt.d.ts +22 -1
- package/dist/prompt.js +297 -121
- package/dist/repo-posture.d.ts +12 -0
- package/dist/repo-posture.js +196 -0
- package/dist/risk-classifier.d.ts +39 -0
- package/dist/risk-classifier.js +111 -0
- package/dist/smart-enforcement.d.ts +41 -0
- package/dist/smart-enforcement.js +48 -0
- package/dist/source-linked-guidance.d.ts +10 -0
- package/dist/source-linked-guidance.js +164 -0
- package/dist/workspace-health.d.ts +2 -0
- package/dist/workspace-health.js +51 -6
- package/package.json +1 -1
package/dist/workspace-health.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
// implements REQ-opencode-kibi-plugin-v1
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { getKbExistenceTargets } from "./file-filter.js";
|
|
5
|
+
import { detectPosture } from "./repo-posture.js";
|
|
4
6
|
const KB_CONFIG_FILE = ".kb/config.json";
|
|
7
|
+
// Fallback defaults used when .kb/config.json does not exist
|
|
5
8
|
const KIBI_DOC_DIRS = [
|
|
6
9
|
"documentation/requirements",
|
|
7
10
|
"documentation/scenarios",
|
|
@@ -12,24 +15,66 @@ const KIBI_DOC_DIRS = [
|
|
|
12
15
|
"documentation/facts",
|
|
13
16
|
"documentation/symbols.yaml",
|
|
14
17
|
];
|
|
18
|
+
// implements REQ-opencode-kibi-plugin-v1
|
|
15
19
|
/**
|
|
16
20
|
* Analyze workspace health for Kibi bootstrap and initialization.
|
|
21
|
+
* Uses detectPosture() for root-scoped classification and delegates
|
|
22
|
+
* bootstrap-needs to the posture result.
|
|
17
23
|
*/
|
|
18
24
|
export function checkWorkspaceHealth(cwd) {
|
|
25
|
+
// Use posture detection for root-scoped classification
|
|
26
|
+
const posture = detectPosture(cwd);
|
|
19
27
|
const configPath = path.join(cwd, KB_CONFIG_FILE);
|
|
20
28
|
const missingConfig = !fs.existsSync(configPath);
|
|
21
29
|
const missingDocDirs = [];
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
if (missingConfig) {
|
|
31
|
+
// No config file: fall back to hardcoded defaults
|
|
32
|
+
for (const docDir of KIBI_DOC_DIRS) {
|
|
33
|
+
const fullPath = path.join(cwd, docDir);
|
|
34
|
+
if (!fs.existsSync(fullPath)) {
|
|
35
|
+
missingDocDirs.push(docDir);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// Config exists: check if user specified custom paths
|
|
41
|
+
let hasUserPaths = false;
|
|
42
|
+
try {
|
|
43
|
+
const raw = JSON.parse(fs.readFileSync(configPath, "utf8"));
|
|
44
|
+
hasUserPaths = Boolean(raw?.paths);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
hasUserPaths = false;
|
|
48
|
+
}
|
|
49
|
+
if (hasUserPaths) {
|
|
50
|
+
// User has custom paths: resolve targets dynamically
|
|
51
|
+
const targets = getKbExistenceTargets(cwd);
|
|
52
|
+
for (const target of targets) {
|
|
53
|
+
const fullPath = path.join(cwd, target.relativePath);
|
|
54
|
+
if (!fs.existsSync(fullPath)) {
|
|
55
|
+
missingDocDirs.push(target.relativePath);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// Config exists but no custom paths: use hardcoded defaults
|
|
61
|
+
for (const docDir of KIBI_DOC_DIRS) {
|
|
62
|
+
const fullPath = path.join(cwd, docDir);
|
|
63
|
+
if (!fs.existsSync(fullPath)) {
|
|
64
|
+
missingDocDirs.push(docDir);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
26
67
|
}
|
|
27
68
|
}
|
|
28
69
|
// Check for any evidence of Kibi usage
|
|
29
70
|
const kbDir = path.join(cwd, ".kb");
|
|
30
71
|
const hasKbEvidence = fs.existsSync(kbDir) && fs.readdirSync(kbDir).length > 0;
|
|
31
|
-
//
|
|
32
|
-
|
|
72
|
+
// Delegate needsBootstrap entirely to posture detection:
|
|
73
|
+
// - root_uninitialized → true
|
|
74
|
+
// - root_partial → true
|
|
75
|
+
// - vendored_only → false (nested tree handles its own KB)
|
|
76
|
+
// - root_active / hybrid_root_plus_vendored → false
|
|
77
|
+
const needsBootstrap = posture.needsBootstrap;
|
|
33
78
|
return {
|
|
34
79
|
needsBootstrap,
|
|
35
80
|
missingConfig,
|