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.
@@ -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.join(cwd, docDir);
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 && raw.paths);
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.join(cwd, target.relativePath);
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.join(cwd, docDir);
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
- // If missing config or more than 2 doc dirs are missing, suggest bootstrap
68
- const needsBootstrap = missingConfig || missingDocDirs.length > 2;
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kibi-opencode",
3
- "version": "0.5.4",
3
+ "version": "0.6.1",
4
4
  "description": "Kibi OpenCode plugin - thin adapter to integrate Kibi with OpenCode sessions",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",