@knowledge-bus/opencode 0.5.0 → 0.8.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,6 @@
1
+ {
2
+ "id": "@knowledge-bus/explorer",
3
+ "version": "0.1.0",
4
+ "digest": "sha256:9c18839590e8974c94c87a51d15914619745a82a62e36266c3c0ce1662e669f8",
5
+ "bytes": 263859
6
+ }
package/runtime/kbp.py CHANGED
@@ -49,6 +49,8 @@ def command(arguments, runtime=None, environ=None):
49
49
  raise ValueError("The runtime cache must be outside the installed plugin.")
50
50
  env["UV_CACHE_DIR"] = str(cache)
51
51
  env["UV_PYTHON_DOWNLOADS"] = "never"
52
+ env["UV_OFFLINE"] = "1"
53
+ env["UV_NO_INDEX"] = "1"
52
54
  env["PYTHONDONTWRITEBYTECODE"] = "1"
53
55
  for key in (
54
56
  "UV_PROJECT_ENVIRONMENT",
@@ -60,11 +62,29 @@ def command(arguments, runtime=None, environ=None):
60
62
  "VIRTUAL_ENV",
61
63
  "PYTHONPATH",
62
64
  "PYTHONHOME",
65
+ "KNOWLEDGE_BUS_EXPLORER_BUNDLE",
66
+ "KNOWLEDGE_BUS_EXPLORER_BUNDLE_MANIFEST",
63
67
  ):
64
68
  env.pop(key, None)
69
+ viewer = runtime / "explorer-viewer.js"
70
+ viewer_manifest = runtime / "explorer-viewer.json"
71
+ if viewer.is_file() or viewer_manifest.is_file():
72
+ if not viewer.is_file() or not viewer_manifest.is_file():
73
+ raise ValueError("Bundled Explorer viewer is incomplete.")
74
+ declared = json.loads(viewer_manifest.read_text())
75
+ actual = "sha256:" + hashlib.sha256(viewer.read_bytes()).hexdigest()
76
+ if (
77
+ declared.get("digest") != actual
78
+ or declared.get("bytes") != viewer.stat().st_size
79
+ ):
80
+ raise ValueError("Bundled Explorer viewer does not match its manifest.")
81
+ env["KNOWLEDGE_BUS_EXPLORER_BUNDLE"] = str(viewer)
82
+ env["KNOWLEDGE_BUS_EXPLORER_BUNDLE_MANIFEST"] = str(viewer_manifest)
65
83
  args = [
66
84
  uv,
67
85
  "run",
86
+ "--offline",
87
+ "--no-index",
68
88
  "--no-project",
69
89
  "--no-config",
70
90
  "--isolated",
@@ -1,9 +1,7 @@
1
1
  {
2
- "version": "0.5.0",
3
- "wheel": "knowledge_bus-0.5.0-py3-none-any.whl",
2
+ "version": "0.8.0",
3
+ "wheel": "knowledge_bus-0.8.0-py3-none-any.whl",
4
4
  "requires_python": ">=3.14",
5
- "sha256": "9334bb61f23ba979e1a8466cce06a37388d71d38578870f9a8c8dff00c13cfc8",
6
- "dependencies": [
7
- "PyYAML==6.0.3"
8
- ]
5
+ "sha256": "93563734c693aff63a44edda8bd941d45ce7a3388e6055045de3f8cd792727b9",
6
+ "dependencies": []
9
7
  }
@@ -15,7 +15,7 @@ description: Validate Knowledge Bus definitions and guidance after edits, and ex
15
15
 
16
16
  - **3. Interpret.** Every refusal names its clause. Translate each into the edit it calls for; see [Checker for Agent Workflows](../../references/agent-runtime.md) for the clause families.
17
17
 
18
- - **4. Report.** Per-file pass/fail, then refusals grouped by fix, not by file.
18
+ - **4. Report.** Per-file pass/fail, then refusals grouped by fix, not by file. If Explorer inspection was also requested, report renderability separately.
19
19
 
20
20
  ## Common failures
21
21
 
@@ -7,10 +7,11 @@ description: Add or re-examine document types in a Knowledge Bus universe, groun
7
7
 
8
8
  **Purpose — add a type the spec does not carry, or deepen one it already declares, so that every declaration is earned by evidence, every refusal is recorded with its reason, and the framework stays cohesive rather than locally patched.**
9
9
 
10
- Two entry points share one spine. Run the spine; take the branch that applies.
10
+ Run the shared spine through the path that applies.
11
11
 
12
12
  - **Path A — new type.** A form exists in the world and the spec does not carry it. Governing question: *does it enable something no declared type enables?*
13
13
  - **Path B — re-evaluation.** A declared type is about to become load-bearing and its basis is unexamined. Governing question: *what in this type is inherited rather than earned?*
14
+ - **Path C — greenfield or adaptation.** Start from what the user needs to understand, decide, or do. External references are optional.
14
15
 
15
16
  ## Knowledge Bus Directory
16
17
 
@@ -30,10 +31,11 @@ Follow [Knowledge Bus Directory](../../references/knowledge-bus-directory.md). U
30
31
  - **1. State the suspicion before searching.** Write down what you expect to find wrong, then go looking. This is what stops a first-hit lineage from being confirmed rather than tested.
31
32
  - **A:** name the form and the gap it claims to fill.
32
33
  - **B:** name what looks inherited — a word in the id, a single-tradition guidance base, a question doing more than one job, an enablement promising something no element delivers.
34
+ - **C:** name the intended decision, action, or understanding and the smallest suspected set of questions.
33
35
 
34
36
  - **2. Group candidate sources by enablement, not by discipline.** Families are "what does this let someone *do*" — decide, know-what-stands, calibrate, follow-an-argument. Discipline groupings smuggle in the lineage you are trying to test.
35
37
 
36
- - **3. Fetch primary sources. Record every failed or degraded fetch.** Paywalled, rescinded, image-only, redirected — say so, and carry the caveat into the citation itself rather than leaving it for a reader to discover.
38
+ - **3. Gather proportionate evidence.** Prefer primary sources for reference-led work and record access limitations. For greenfield work, use the user's intent and reviewed local examples without inventing a lineage.
37
39
 
38
40
  - **4. Run the artifact test per family.** Identity is `(action, actor)`; add timing to break ties.
39
41
  - **A:** if the enablement duplicates a declared type's, fold the form in as an alias — do not add a row.
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: kb-explore
3
+ description: Inspect a Knowledge Bus universe and optionally create or open its offline Explorer.
4
+ ---
5
+
6
+ # Explore a Universe
7
+
8
+ Use this procedure to understand or present declared Knowledge Bus definitions. Explorer is an optional read-only consumer; it does not author definitions or decide whether their contents are true, useful, approved, or applicable to a situation.
9
+
10
+ ## Select and inspect
11
+
12
+ Follow [Knowledge Bus Directory](../../references/knowledge-bus-directory.md). An explicit universe file, knowledge-base folder, or its `.knowledge-bus/` folder takes precedence; otherwise use the nearest `.knowledge-bus/` and never fall through an empty nearer scope. Run the bundled command described in [Checker for Agent Workflows](../../references/agent-runtime.md):
13
+
14
+ ```sh
15
+ python3 /absolute/runtime/kbp.py --inspect /absolute/target/.knowledge-bus/
16
+ ```
17
+
18
+ Inspection writes nothing. A sole universe may be selected automatically. If the scope contains several, list the candidates and ask the user to select an id or universe file; never choose by filename or sort order. Explain the universe through its questions, artifact purposes, relationships, guidance, and presentation marks. Report conformance and renderability separately.
19
+
20
+ ## Optional static artifact
21
+
22
+ Before writing, tell the user the proposed destination. The conventional local path is `.knowledge-bus/explorer/<universe-id>/`, but generation always receives an explicit destination:
23
+
24
+ ```sh
25
+ python3 /absolute/runtime/kbp.py --explore --universe <id> --output /absolute/destination /absolute/target/.knowledge-bus/
26
+ ```
27
+
28
+ Do not replace an existing destination unless the user asks; then add `--replace`. Before recommending replacement, compare the receipt with the current inspection and viewer. Refresh when the definitions, guidance, marks, viewer, or requested presentation changed. A package release alone is not a reason to refresh.
29
+
30
+ Generation uses bundled files and works offline. Open `index.html` only when requested or useful. Users can export SVG from the viewer; automated export remains contributor and release tooling.
31
+
32
+ If visualization is unavailable, provide the inspected model or a concise text explanation. Never change definitions, evaluate context, reconstruct an institution, promote descriptive material into an authorized state, or silently ignore invalid or mismatched inputs.
@@ -24,16 +24,12 @@ description: Map existing notes or documents into Knowledge Bus definitions and
24
24
  convention. Inspect that directory if it already exists; the domain phrase is proposed after the survey and confirmed, never requested cold.
25
25
 
26
26
  - **2. Survey before reading.** Inventory files, dates, and formats; report counts to the user before any deep read.
27
- Three staleness marks: **contradicted** (a newer source disputes it — mechanical), **unconfirmed**
27
+ Three staleness marks: **contradicted** (sources disagree), **unconfirmed**
28
28
  (older than the corpus's age threshold, nothing disputes it), **confirmed** (cleared during the interview).
29
29
  Confirmation questions come batched and informed — reason through the whole survey first so the user rules
30
30
  on genuine uncertainty, not on what the corpus already settles.
31
31
 
32
- - **3. Position the domain, then choose the spec.** Locate the starter using [Checker for Agent Workflows](../../references/agent-runtime.md). Reason over the folder
33
- and whatever the user supplied, clarifying unclear questions by probing what answering each would enable and checking for overlap,
34
- then interview to place the domain against the product-agnostic built-in: how regulated or commercial
35
- versus DIY, and where the abstraction layer sits — industry, company, product, or feature. Adopt, trim,
36
- or derive follows from that placement; structural changes require the user's review. If `kb-evolve` is installed, offer it; otherwise explain the proposed change and stop before changing the structure.
32
+ - **3. Choose the definitions.** Use supplied definitions when they fit. Treat the bundled starter as an optional reference, not a universal lens. If no set fits, propose an adaptation for review. Structural changes require the user's approval. Use `kb-evolve` when available; otherwise explain the proposed change and stop.
37
33
 
38
34
  - **4. Extract answers.** Map each document section to a declared question; one answer per question per party and time.
39
35
  A collision — two docs answering the same question — is never resolved by recency. The older doc may be the
@@ -15,7 +15,7 @@ Follow [Knowledge Bus Directory](../../references/knowledge-bus-directory.md). U
15
15
 
16
16
  - **Past tense throughout.** What was live, not what is sensible now.
17
17
  - **Reconstruction is flagged as reconstruction.** Memory is not evidence.
18
- - **A decision with no reversal condition is not fully recovered.**
18
+ - **Do not fill missing history.**
19
19
 
20
20
  ## The flow
21
21
 
@@ -27,6 +27,6 @@ Follow [Knowledge Bus Directory](../../references/knowledge-bus-directory.md). U
27
27
 
28
28
  - **4. Recover the binding constraints.** What ruled options out, in force at the time.
29
29
 
30
- - **5. Name the reversal condition.** What changing would reopen this.
30
+ - **5. Seek the reversal condition.** Record it when supported; otherwise mark it unknown.
31
31
 
32
- - **6. File as answers** against declared questions; flag what stayed ambiguous.
32
+ - **6. File as answers** against declared questions; label fact, recollection, reconstruction, and missing evidence. Flag what stayed ambiguous.
@@ -22,7 +22,7 @@ Follow [Knowledge Bus Directory](../../references/knowledge-bus-directory.md). U
22
22
 
23
23
  ## The loop
24
24
 
25
- Every round runs the same shape. Loop until a round changes nothing.
25
+ Repeat only while a follow-up can resolve stated uncertainty. Stop when the tests settle the candidate or when resolution requires missing evidence or another person.
26
26
 
27
27
  - **1. Reason first.** Re-read everything held — the material, prior answers, every declared question. Draft what the next batch must uncover; discard whatever the record already settles.
28
28
 
@@ -30,6 +30,6 @@ Every round runs the same shape. Loop until a round changes nothing.
30
30
 
31
31
  - **3. Reflect and test.** Against the answers, run the tests: an enablement a declared question already covers is a collision — rule *sharpen existing / new / refused*; two jobs is a split; a candidate with no honest empty answer is not load-bearing.
32
32
 
33
- - **4. Follow up or converge.** Where a test left ambiguity, ask a follow-up batch in the same sitting. A round that changes nothing ends the loop.
33
+ - **4. Follow up or stop.** Ask another batch only when it can resolve stated ambiguity. A round that changes nothing ends the loop; unresolved uncertainty stays unresolved.
34
34
 
35
35
  - **5. Declare.** Freeze the wording last. Mint a code using [Checker for Agent Workflows](../../references/agent-runtime.md); record every refusal with its reason.