kibi-opencode 0.5.4 → 0.6.1
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 +27 -14
- package/dist/config.d.ts +9 -0
- package/dist/config.js +31 -0
- 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 +14 -6
- package/package.json +1 -1
package/dist/workspace-health.js
CHANGED
|
@@ -2,6 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
// implements REQ-opencode-kibi-plugin-v1
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { getKbExistenceTargets } from "./file-filter.js";
|
|
5
|
+
import { detectPosture } from "./repo-posture.js";
|
|
5
6
|
const KB_CONFIG_FILE = ".kb/config.json";
|
|
6
7
|
// Fallback defaults used when .kb/config.json does not exist
|
|
7
8
|
const KIBI_DOC_DIRS = [
|
|
@@ -17,15 +18,19 @@ const KIBI_DOC_DIRS = [
|
|
|
17
18
|
// implements REQ-opencode-kibi-plugin-v1
|
|
18
19
|
/**
|
|
19
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.
|
|
20
23
|
*/
|
|
21
24
|
export function checkWorkspaceHealth(cwd) {
|
|
25
|
+
// Use posture detection for root-scoped classification
|
|
26
|
+
const posture = detectPosture(cwd);
|
|
22
27
|
const configPath = path.join(cwd, KB_CONFIG_FILE);
|
|
23
28
|
const missingConfig = !fs.existsSync(configPath);
|
|
24
29
|
const missingDocDirs = [];
|
|
25
30
|
if (missingConfig) {
|
|
26
31
|
// No config file: fall back to hardcoded defaults
|
|
27
32
|
for (const docDir of KIBI_DOC_DIRS) {
|
|
28
|
-
const fullPath = path.
|
|
33
|
+
const fullPath = path.resolve(cwd, docDir);
|
|
29
34
|
if (!fs.existsSync(fullPath)) {
|
|
30
35
|
missingDocDirs.push(docDir);
|
|
31
36
|
}
|
|
@@ -36,7 +41,7 @@ export function checkWorkspaceHealth(cwd) {
|
|
|
36
41
|
let hasUserPaths = false;
|
|
37
42
|
try {
|
|
38
43
|
const raw = JSON.parse(fs.readFileSync(configPath, "utf8"));
|
|
39
|
-
hasUserPaths = Boolean(raw
|
|
44
|
+
hasUserPaths = Boolean(raw?.paths);
|
|
40
45
|
}
|
|
41
46
|
catch {
|
|
42
47
|
hasUserPaths = false;
|
|
@@ -45,7 +50,7 @@ export function checkWorkspaceHealth(cwd) {
|
|
|
45
50
|
// User has custom paths: resolve targets dynamically
|
|
46
51
|
const targets = getKbExistenceTargets(cwd);
|
|
47
52
|
for (const target of targets) {
|
|
48
|
-
const fullPath = path.
|
|
53
|
+
const fullPath = path.resolve(cwd, target.relativePath);
|
|
49
54
|
if (!fs.existsSync(fullPath)) {
|
|
50
55
|
missingDocDirs.push(target.relativePath);
|
|
51
56
|
}
|
|
@@ -54,7 +59,7 @@ export function checkWorkspaceHealth(cwd) {
|
|
|
54
59
|
else {
|
|
55
60
|
// Config exists but no custom paths: use hardcoded defaults
|
|
56
61
|
for (const docDir of KIBI_DOC_DIRS) {
|
|
57
|
-
const fullPath = path.
|
|
62
|
+
const fullPath = path.resolve(cwd, docDir);
|
|
58
63
|
if (!fs.existsSync(fullPath)) {
|
|
59
64
|
missingDocDirs.push(docDir);
|
|
60
65
|
}
|
|
@@ -64,8 +69,11 @@ export function checkWorkspaceHealth(cwd) {
|
|
|
64
69
|
// Check for any evidence of Kibi usage
|
|
65
70
|
const kbDir = path.join(cwd, ".kb");
|
|
66
71
|
const hasKbEvidence = fs.existsSync(kbDir) && fs.readdirSync(kbDir).length > 0;
|
|
67
|
-
//
|
|
68
|
-
|
|
72
|
+
// Restore lenient threshold for repos that have a config but are missing a few dirs.
|
|
73
|
+
// Uninitialized repos always need bootstrap; partial repos fall back to the legacy
|
|
74
|
+
// >2 missing dirs threshold so small gaps (e.g. unused flags/events) do not nag.
|
|
75
|
+
const needsBootstrap = posture.state === "root_uninitialized" ||
|
|
76
|
+
(posture.state === "root_partial" && missingDocDirs.length > 2);
|
|
69
77
|
return {
|
|
70
78
|
needsBootstrap,
|
|
71
79
|
missingConfig,
|