kibi-opencode 0.13.0 → 0.15.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.
@@ -0,0 +1,104 @@
1
+ // Directories whose contents are always ignored for KB freshness.
2
+ const IGNORED_DIRECTORIES = [
3
+ ".git",
4
+ ".sisyphus",
5
+ "node_modules",
6
+ "vendor",
7
+ "third_party",
8
+ "dist",
9
+ "coverage",
10
+ ];
11
+ // Filenames that are advisory-only (lockfiles).
12
+ const ADVISORY_FILENAMES = new Set([
13
+ "bun.lock",
14
+ "bun.lockb",
15
+ "package-lock.json",
16
+ "pnpm-lock.yaml",
17
+ "yarn.lock",
18
+ ]);
19
+ // PathKind values that always require KB evidence.
20
+ const MEANINGFUL_PATH_KINDS = new Set([
21
+ "code",
22
+ "requirement",
23
+ "scenario",
24
+ "test",
25
+ "adr",
26
+ "fact",
27
+ "flag",
28
+ "event",
29
+ "symbol",
30
+ "kb",
31
+ ]);
32
+ // Risk classes that upgrade the classification to requires-kb-evidence.
33
+ const UPGRADE_RISK_CLASSES = new Set([
34
+ "behavior_candidate",
35
+ "traceability_candidate",
36
+ "req_policy_candidate",
37
+ ]);
38
+ function isIgnoredPath(normalizedPath, pathKind) {
39
+ // Check extension-based ignored patterns.
40
+ if (normalizedPath.endsWith(".tsbuildinfo") ||
41
+ normalizedPath.endsWith(".map")) {
42
+ return true;
43
+ }
44
+ // Check directory-based ignored patterns.
45
+ for (const dir of IGNORED_DIRECTORIES) {
46
+ if (normalizedPath.startsWith(`${dir}/`) ||
47
+ normalizedPath.includes(`/${dir}/`)) {
48
+ return true;
49
+ }
50
+ }
51
+ // Special handling for .kb/ — only ignored when pathKind is NOT "kb".
52
+ // Actual KB entity files (pathKind=kb) should still require evidence.
53
+ if (pathKind !== "kb") {
54
+ if (normalizedPath.startsWith(".kb/") ||
55
+ normalizedPath.includes("/.kb/")) {
56
+ return true;
57
+ }
58
+ }
59
+ return false;
60
+ }
61
+ function getFilename(normalizedPath) {
62
+ const lastSlash = normalizedPath.lastIndexOf("/");
63
+ return lastSlash === -1
64
+ ? normalizedPath
65
+ : normalizedPath.slice(lastSlash + 1);
66
+ }
67
+ /**
68
+ * Classify whether a file change requires KB freshness evidence.
69
+ *
70
+ * Rules (first match wins):
71
+ * 1. Ignored paths (build artifacts, vendor dirs) → `ignored`
72
+ * 2. Advisory paths (lockfiles) → `advisory`
73
+ * 3. Meaningful pathKinds (code, requirements, KB docs, etc.) → `requires-kb-evidence`
74
+ * 4. Risk-based upgrade (behavior/traceability/req_policy candidates) → `requires-kb-evidence`
75
+ * 5. `safe_docs_only` risk + `unknown` pathKind → `advisory`
76
+ * 6. Default → `requires-kb-evidence` (safety default)
77
+ */
78
+ export function classifyMeaningfulChange(params) {
79
+ const { normalizedPath, pathKind, lifecycle: _lifecycle, riskClass } = params;
80
+ // 1. IGNORED paths (for freshness contract)
81
+ if (isIgnoredPath(normalizedPath, pathKind)) {
82
+ return "ignored";
83
+ }
84
+ // 2. ADVISORY paths (low-risk lockfiles)
85
+ const filename = getFilename(normalizedPath);
86
+ if (ADVISORY_FILENAMES.has(filename)) {
87
+ return "advisory";
88
+ }
89
+ // 3. REQUIRES-KB-EVIDENCE by pathKind
90
+ if (MEANINGFUL_PATH_KINDS.has(pathKind)) {
91
+ return "requires-kb-evidence";
92
+ }
93
+ // 4. RISK-BASED UPGRADE
94
+ if (riskClass) {
95
+ if (UPGRADE_RISK_CLASSES.has(riskClass)) {
96
+ return "requires-kb-evidence";
97
+ }
98
+ if (riskClass === "safe_docs_only" && pathKind === "unknown") {
99
+ return "advisory";
100
+ }
101
+ }
102
+ // 5. DEFAULT — safety default for unknown paths
103
+ return "requires-kb-evidence";
104
+ }
package/dist/plugin.d.ts CHANGED
@@ -3,6 +3,7 @@ export interface PluginInput {
3
3
  worktree: string;
4
4
  directory: string;
5
5
  sessionId?: string;
6
+ agentIdentity?: string;
6
7
  serverUrl?: unknown;
7
8
  workspace?: string;
8
9
  project?: unknown;