@rahmantech/knl-view 0.0.0-stage → 0.1.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.
Files changed (115) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +398 -2
  3. package/bin/knl-view.js +943 -0
  4. package/dist/assets/abnfDiagram-WEYOIA3C-B1gaBaSI.js +1 -0
  5. package/dist/assets/arc-NZ9uRaCl.js +1 -0
  6. package/dist/assets/architecture-WOLXFQ4H-8MalLwTd.js +1 -0
  7. package/dist/assets/architectureDiagram-ZHVYKT53-eZ8i5cl4.js +36 -0
  8. package/dist/assets/array-BifhSqXX.js +1 -0
  9. package/dist/assets/blockDiagram-RJAE7QA3-BavOE8BM.js +140 -0
  10. package/dist/assets/c4Diagram-XDPPPE54-DqMaTAzx.js +38 -0
  11. package/dist/assets/channel-BZ2_TTTJ.js +1 -0
  12. package/dist/assets/chunk-2E7WHVMD-B1Hj2BjJ.js +88 -0
  13. package/dist/assets/chunk-2Q5K7J3B-C1jixKkw.js +1 -0
  14. package/dist/assets/chunk-4EMNKR2T-HDscrCiq.js +1 -0
  15. package/dist/assets/chunk-55XCU76K-QR_ARj8I.js +1 -0
  16. package/dist/assets/chunk-5VM5RSS4-ZNzvKenW.js +15 -0
  17. package/dist/assets/chunk-7S6XSTFO-B0p3o547.js +2 -0
  18. package/dist/assets/chunk-AQDTSKZB-CCxwNyyA.js +72 -0
  19. package/dist/assets/chunk-DSNLSHJZ-BM5PBFmz.js +129 -0
  20. package/dist/assets/chunk-DUW6YSOI-Dgx8z5s3.js +1 -0
  21. package/dist/assets/chunk-HAGFOTED-UCDVFuN_.js +62 -0
  22. package/dist/assets/chunk-HNE4Q36P-C_1sakp2.js +1 -0
  23. package/dist/assets/chunk-J5ZVWO5B-oDCd-gWO.js +1 -0
  24. package/dist/assets/chunk-JWPE2WC7-DVXcaiue.js +1 -0
  25. package/dist/assets/chunk-NGNAAXSQ-C2Wy9Xmz.js +136 -0
  26. package/dist/assets/chunk-NQOKRVIF-b2D1Z4oK.js +213 -0
  27. package/dist/assets/chunk-UHW7PFBP-CJs0VwBY.js +1 -0
  28. package/dist/assets/chunk-VQ5W62QI-DQxjgE4_.js +1 -0
  29. package/dist/assets/chunk-WQQL4CDK-DcjPeAfQ.js +10 -0
  30. package/dist/assets/chunk-XXDRQBXY-glA0kB5s.js +1 -0
  31. package/dist/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +1 -0
  32. package/dist/assets/chunk-YZO67HFG-DJqACL5V.js +1 -0
  33. package/dist/assets/chunk-ZAUX2LTX-CWfaYtwb.js +1 -0
  34. package/dist/assets/chunk-ZCHMQSOR-BGX73Hho.js +2 -0
  35. package/dist/assets/classDiagram-v2-4MYWR3UA-BpYXPz-e.js +217 -0
  36. package/dist/assets/cose-bilkent-JH36ORCC-e1quKm0Q.js +1 -0
  37. package/dist/assets/cynefin-EF2NZ3EQ-hb3oUmFO.js +1 -0
  38. package/dist/assets/cynefinDiagram-WF24UDRP-CnMQvLqi.js +62 -0
  39. package/dist/assets/cytoscape.esm-BegBNzOV.js +321 -0
  40. package/dist/assets/dagre-NK4GIZVX-BH_Y8y3F.js +4 -0
  41. package/dist/assets/defaultLocale-BFoDCU3G.js +1 -0
  42. package/dist/assets/diagram-CBK3MWTC-Dh79VetZ.js +24 -0
  43. package/dist/assets/diagram-I5XIIV2D-D3u-o1RV.js +24 -0
  44. package/dist/assets/diagram-ODIL2UCW-Bfuo-OKS.js +30 -0
  45. package/dist/assets/diagram-PFBEJUXE-CwHasIbs.js +3 -0
  46. package/dist/assets/diagram-RJA3I4VV-D8ttmuE8.js +41 -0
  47. package/dist/assets/diagram-TYUNFSNR-CzC-8RZ0.js +200 -0
  48. package/dist/assets/dist-CUJYGnnI.js +1 -0
  49. package/dist/assets/ebnfDiagram-V4P3TTPT-9AAhU7In.js +1 -0
  50. package/dist/assets/elk-QONTBCTQ-BgvnD1v_.js +27 -0
  51. package/dist/assets/erDiagram-KYQIGQAA-RLtbiLlP.js +99 -0
  52. package/dist/assets/eventmodeling-K75KTNOO-DVY22vNZ.js +1 -0
  53. package/dist/assets/flowDiagram-IUGLLWBU-l7L5DTb5.js +1 -0
  54. package/dist/assets/ganttDiagram-R7GPNTJY-hHiBGa9W.js +292 -0
  55. package/dist/assets/gitGraph-VSP46ZUC-Cvxay1wh.js +1 -0
  56. package/dist/assets/gitGraphDiagram-PDYL7XHY-AOhlpSqg.js +106 -0
  57. package/dist/assets/graphlib-DS17s2tU.js +1 -0
  58. package/dist/assets/index-CBLNQvK3.js +76 -0
  59. package/dist/assets/index-DLgMsUs2.css +1 -0
  60. package/dist/assets/info-OHQRW6UA-CJ8EUO1m.js +1 -0
  61. package/dist/assets/infoDiagram-MVDRKAX5-DOQu7oYI.js +2 -0
  62. package/dist/assets/init-C-OQMol4.js +1 -0
  63. package/dist/assets/ishikawaDiagram-HPEHV2GE-DcVMvGmx.js +70 -0
  64. package/dist/assets/journeyDiagram-BOSHW7O7-luMeqEqz.js +139 -0
  65. package/dist/assets/kanban-definition-FNSA4HC5-KTZbmrW2.js +89 -0
  66. package/dist/assets/katex-B_JcIwqj.js +257 -0
  67. package/dist/assets/line-CmPHiOVm.js +1 -0
  68. package/dist/assets/linear-DHYlKXBA.js +1 -0
  69. package/dist/assets/mermaid-parser.core-BRDI-WhC.js +7 -0
  70. package/dist/assets/mermaid.core-DPTRaYLy.js +44 -0
  71. package/dist/assets/mindmap-definition-6OY57UG3-70EN5Kw_.js +98 -0
  72. package/dist/assets/ordinal-BDEzSJ7C.js +1 -0
  73. package/dist/assets/packet-JDAUHWVQ-CXWz83oS.js +1 -0
  74. package/dist/assets/path-fybaL0A-.js +1 -0
  75. package/dist/assets/pegDiagram-ECIUJNBX-z5UXKmp4.js +1 -0
  76. package/dist/assets/pie-XZMESJXO-rWI1HIQ7.js +1 -0
  77. package/dist/assets/pieDiagram-GNMPY74T-Bh4Kv3NQ.js +39 -0
  78. package/dist/assets/quadrantDiagram-D57K4MC3-wGM4Ckig.js +7 -0
  79. package/dist/assets/radar-ABXABTNO-CIJ92p5N.js +1 -0
  80. package/dist/assets/railroad-I3PHUGI6-8bxua-Hf.js +1 -0
  81. package/dist/assets/railroad-abnf-LNEFI6M7-B9KVI10m.js +1 -0
  82. package/dist/assets/railroad-ebnf-DWYD2UWJ-Bt73rnyJ.js +1 -0
  83. package/dist/assets/railroad-peg-JR7BVNR7-Cie82UPT.js +1 -0
  84. package/dist/assets/railroadDiagram-Y72NRBL7-C1nmi_tl.js +1 -0
  85. package/dist/assets/requirementDiagram-EQYSW5RA-BSianW40.js +84 -0
  86. package/dist/assets/rough.esm-Dy-Kn_BL.js +1 -0
  87. package/dist/assets/sankeyDiagram-SY24JHO5-DIa11-h7.js +40 -0
  88. package/dist/assets/sequenceDiagram-BLEHNHQU-Df5rZKz2.js +169 -0
  89. package/dist/assets/sizeCapture-INFHLROL-3uHXrFqA.js +1 -0
  90. package/dist/assets/src-dClg85lX.js +1 -0
  91. package/dist/assets/stateDiagram-v2-A6IESKWZ-B15PTSvX.js +291 -0
  92. package/dist/assets/swimlanes-B3ENRKFQ-C9mgRCMi.js +1 -0
  93. package/dist/assets/swimlanesDiagram-AYQRV4AK-BGFq4t7O.js +8 -0
  94. package/dist/assets/timeline-definition-JXYKGLGB-BDVf_mIv.js +120 -0
  95. package/dist/assets/treeView-D4JQ5SDB-BbBK-25J.js +1 -0
  96. package/dist/assets/treemap-SAJKECNS-CEDX8apk.js +1 -0
  97. package/dist/assets/usecaseDiagram-WPOLBNNX-D1QkwFF8.js +328 -0
  98. package/dist/assets/vennDiagram-Q3Y3IDCW-5PeGZvEO.js +34 -0
  99. package/dist/assets/wardley-7MLQ67FV-BatN94pO.js +1 -0
  100. package/dist/assets/wardleyDiagram-IVAIDKWA-DyCcDS3Y.js +78 -0
  101. package/dist/assets/xychartDiagram-4URNHDU4-CbCXcRlg.js +7 -0
  102. package/dist/index.html +22 -0
  103. package/package.json +46 -4
  104. package/server/config.js +263 -0
  105. package/server/consensus.js +175 -0
  106. package/server/graph/anchordb_client.js +253 -0
  107. package/server/graph/model.js +157 -0
  108. package/server/graph/parser.js +326 -0
  109. package/server/graph/sources.js +660 -0
  110. package/server/graph/syntax.js +257 -0
  111. package/server/index.js +679 -0
  112. package/server/install.js +97 -0
  113. package/server/map.js +126 -0
  114. package/server/models_registry.js +84 -0
  115. package/server/scaffold.js +376 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Muhammad Abdurrahman
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,399 @@
1
- # Temporary Holding Version
1
+ # knl-view
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A local viewer for `.knowledges` knowledge bases: a CLI that serves a small web
4
+ app over a plain folder of Markdown files. The disk is the source of truth;
5
+ `map.json` is optional decoration.
6
+
7
+ ```
8
+ knl-view --port 8086 --path=.knowledges
9
+ ```
10
+
11
+ ## What it does
12
+
13
+ - Serves a web viewer over any folder of Markdown files. No database, no build
14
+ step for your content, no account.
15
+ - Sidebar tree with a fixed `index` entry (the root `README.md`) and a
16
+ `contents` entry that lists the whole base on one page.
17
+ - Folders open their own `README.md`, rendered the same way as a normal document.
18
+ - `map.json` (optional) relabels, reorders, or hides entries in the menu. It
19
+ never creates, moves, or deletes files. Entries pointing at paths that are not
20
+ on disk are ignored silently.
21
+ - Markdown with GFM tables, and triple-backtick fences tagged `mermaid` rendered
22
+ as diagrams. The mermaid bundle is served locally and loaded only when a
23
+ document contains a diagram; nothing is fetched from a CDN.
24
+ - Per-diagram controls: toggle between diagram and source, and a zoom modal
25
+ (wheel zoom, drag to pan, +/−/Reset, Esc to close).
26
+ - Table of contents per document, breadcrumb, and a filter box in the sidebar
27
+ that narrows the index by file title or path.
28
+ - Interface in English or Indonesian, switchable in the top bar. English is the
29
+ default.
30
+
31
+ ## Requirements
32
+
33
+ - Node.js 20.19 or newer.
34
+ - A built frontend. `dist/` is committed to this repository, so an install from
35
+ GitHub already has it. The CLI refuses to start without it and tells you so.
36
+
37
+ ## Install
38
+
39
+ ```sh
40
+ npm install -g @rahmantech/knl-view
41
+ ```
42
+
43
+ That puts the `knl-view` command into Node's global bin,
44
+ `$(npm prefix -g)/bin`. If that directory is not on your PATH, link the
45
+ command somewhere that is:
46
+
47
+ ```sh
48
+ ln -s "$(npm prefix -g)/bin/knl-view" ~/.local/bin/knl-view
49
+ ```
50
+
51
+ The published tarball ships the built `dist/`, so the install compiles
52
+ nothing.
53
+
54
+ Run it once without installing:
55
+
56
+ ```sh
57
+ npx @rahmantech/knl-view
58
+ ```
59
+
60
+ Or install from source, for a local checkout or an unreleased commit:
61
+
62
+ ```sh
63
+ git clone https://github.com/rachmanzz/knl-view.git
64
+ cd knl-view
65
+ npm install
66
+ npm run build
67
+ npm link
68
+ ```
69
+
70
+ `npm link` puts `knl-view` on your PATH from the checkout. To install a
71
+ GitHub commit without cloning, run
72
+ `npm install -g github:rachmanzz/knl-view --install-links`; without
73
+ `--install-links`, npm 11 links against a temporary clone it deletes
74
+ afterwards, which leaves a broken install.
75
+
76
+ ## Usage
77
+
78
+ ```sh
79
+ knl-view # serve ./.knowledges on 127.0.0.1:8085
80
+ knl-view --path=../other-project/.knowledges
81
+ knl-view --port 8086 --host 0.0.0.0 # expose on the network
82
+ knl-view graph trace --target=README.md # query on-demand subgraph for AI
83
+ knl-view graph trace --target=DEC-20261030-135001 --hops=1
84
+ knl-view --init # scaffold a new base (wizard, no server)
85
+ knl-view --seed-skill=knl-view --dir=global --yes
86
+ ```
87
+
88
+ | Flag | Default | What it does |
89
+ | --- | --- | --- |
90
+ | `--port`, `-p` | `8085` | HTTP port |
91
+ | `--path` | `.knowledges` | Folder to serve, relative to the working directory |
92
+ | `--host` | `127.0.0.1` | Bind address |
93
+ | `--anchordb` | none | AnchorWire URL (`wire://host:port?token=...`) for this session; overrides the global config block |
94
+ | `--target` | none | Target node ID for CLI subgraph trace (`knl-view graph trace`) |
95
+ | `--hops` | `2` | Traversal depth radius for subgraph extraction |
96
+ | `--init` | off | Scaffold a new base interactively; does not start the server |
97
+ | `--structure` | `standard` | Layout for a non-interactive `--init`: `standard`, `empty`, or `custom` |
98
+ | `--folders` | none | Comma-separated folder names for `--structure=custom` |
99
+ | `--seed-skill=knl-view` | off | Write the `knl-view` skill for coding agents; skipped if it already exists |
100
+ | `--dir` | `project` | Skill location: `project` (`.agents/skills`) or `global` (`~/.config/opencode/skills`) |
101
+ | `--yes`, `-y` | off | Accept every default in `--init` / `--seed-skill`, no questions asked |
102
+ | `--help`, `-h` | | Show help |
103
+ | `--version`, `-v` | | Show version |
104
+
105
+ The server binds to `127.0.0.1` by default, so it is reachable only from your
106
+ machine unless you pass `--host` yourself. There is no authentication; treat
107
+ `--host 0.0.0.0` as a decision you are making on purpose.
108
+
109
+ ## Configuration
110
+
111
+ Two optional config files. A missing file is never an error; a broken file is
112
+ ignored with one warning on stderr. CLI flags always win over config values.
113
+
114
+ **Global (`~/.knlview/knl-config.json`)**: shared by every project on the
115
+ machine. Holds the `anchordb` block. Without it, AnchorDB stays completely
116
+ off and the viewer runs fully local:
117
+
118
+ ```json
119
+ {
120
+ "anchordb": {
121
+ "url": "wire://127.0.0.1:7448",
122
+ "token": "your-token",
123
+ "sync": true
124
+ }
125
+ }
126
+ ```
127
+
128
+ **Per project: `knl-config.json` at the project root** (gitignored): only
129
+ `path`, `port`, `host`, and a `models` map, never the anchordb connection:
130
+
131
+ ```json
132
+ {
133
+ "port": 8091,
134
+ "models": {
135
+ "knowledges": "vez0vqrp",
136
+ "consensus": "n0qrnmsz"
137
+ }
138
+ }
139
+ ```
140
+
141
+ Model names are owned by the `models` map: role → name, and the name can
142
+ be anything (random names are fine; the map records what each name is
143
+ *for*). Names stay stable even if the project folder is renamed. knl-view
144
+ never invents names by itself: create them with
145
+ `knl-view model new <role>` (writes the map and the global registry), and
146
+ inspect ownership with `knl-view model check`.
147
+
148
+ The global registry `~/.knlview/models.json` records every name's owner
149
+ (project, role, path) and warns when two projects claim the same name. A
150
+ project whose map has no entry for a role runs fully local: AnchorDB is
151
+ touched only once the role is mapped.
152
+
153
+ ## Installing AnchorDB (optional)
154
+
155
+ AnchorDB is an optional layer. Without it the viewer runs fully local:
156
+ everything (browsing, search, the graph engine, and `knl-view graph trace`)
157
+ works with zero setup. Installing AnchorDB only adds persistent causal
158
+ tracing across sessions and shared sync between machines.
159
+
160
+ `knl-view install anchordb` installs AnchorDB and writes the `anchordb`
161
+ block into the global config:
162
+
163
+ - **Linux and macOS**: downloads the native binary from
164
+ [GitHub Releases](https://github.com/rachmanzz/anchordb/releases),
165
+ verifies it against the release's `SHA256SUMS.txt`, installs to
166
+ `~/.knlview/bin/`, and starts `anchordb-server` detached (logs in
167
+ `~/.knlview/anchordb.log`, data in `~/.knlview/anchordb-data`).
168
+ - **Other platforms**: a Linux container from
169
+ `ghcr.io/rachmanzz/anchordb` via docker or podman; the command refuses
170
+ to continue if neither is installed.
171
+
172
+ Non-interactive (CI/scripts): add `--yes`. Explicit method: `--method=binary`
173
+ or `--method=container`. Fixed token instead of a random one: `--token=...`.
174
+ If a container named `anchordb-knlview` already exists, the installer stops
175
+ instead of removing it: data must not disappear by accident.
176
+
177
+ ## How a base is read
178
+
179
+ A base is an ordinary folder:
180
+
181
+ ```
182
+ .knowledges/
183
+ README.md # the index document
184
+ map.json # optional
185
+ roadmap/
186
+ README.md
187
+ q1.md
188
+ features/
189
+ auth.md
190
+ ```
191
+
192
+ Reading order: the root `README.md`, then `map.json` when present, then the
193
+ structure on disk. Without `map.json`, menu labels fall back to the first
194
+ `# heading` of each file, then to the plain file name (files before folders).
195
+
196
+ ### map.json
197
+
198
+ Every entry is decoration. Nothing in it can invent a file that is not on disk.
199
+
200
+ ```json
201
+ {
202
+ "title": "Base title shown in the masthead",
203
+ "sections": {
204
+ "roadmap": { "title": "Roadmap", "order": 1, "meta": "Where this is going" }
205
+ },
206
+ "docs": {
207
+ "coding-rules.md": { "title": "Coding rules", "order": 1 }
208
+ },
209
+ "files": {
210
+ "rahasia.md": { "ignore": true }
211
+ },
212
+ "dirs": {
213
+ "draft-lama": { "ignore": true }
214
+ }
215
+ }
216
+ ```
217
+
218
+ | Field | Applies to | Effect |
219
+ | --- | --- | --- |
220
+ | `title` | the whole file | Masthead title; wins over the README heading |
221
+ | `sections.<dir>` / `dirs.<path>` | a directory | `title` is the menu label, `meta` is a short note |
222
+ | `docs.<file>` / `files.<path>` | a file | `title` is the menu label |
223
+ | `order` | any entry | Ascending menu order; entries without `order` follow, files before folders |
224
+ | `ignore` (or `hidden`) | any entry | `true` hides it from the menu, lists, search, home, and contents |
225
+
226
+ Paths are relative to the `.knowledges` root, use `/` separators, and must
227
+ match the on-disk path exactly, for example `features/auth.md`. `ignore` is
228
+ view-only: the file stays on disk. Remove the flag to bring it back.
229
+
230
+ The full field reference lives in the bundled skill:
231
+ `.agents/skills/knl-view/SKILL.md`.
232
+
233
+ ## AI Graph & Decision Tracing
234
+
235
+ `knl-view` includes an AI-native directed acyclic graph (DAG) engine built directly into the CLI and server. It connects knowledge documents (`.knowledges/*.md`) and architectural decision records (`.knowledges/decisions/*.md`) into a unified graph:
236
+
237
+ - **Zero Intermediary File**: Fully on-the-fly in-memory processing. Markdown files remain the sole source of truth without generating out-of-sync `graph.json` cache files.
238
+ - **Decision Lineage Tracking**: Automatically discovers `supersedes`, `related_to`, and `affects_knowledge` edges from `decisionskills` decision blocks.
239
+ - **Low-Token Subgraphs for AI**: Instead of loading an entire knowledge base into LLM context, query exact $N$-hop subgraphs in sub-milliseconds (< 1 ms).
240
+
241
+ This engine is fully local: it needs no AnchorDB and no network. AnchorDB
242
+ (see the optional install above) adds persistence on top: edges survive
243
+ across sessions, are synced incrementally, and can be traced from any
244
+ machine pointing at the same server.
245
+
246
+ ### Two-way lineage
247
+
248
+ Traces walk in a mechanically defined direction relative to the edges,
249
+ never interpreted as cause and effect (`depends_on` edges *leave* a
250
+ decision while pointing at its upstream, so up/down labels would lie):
251
+
252
+ - `direction=out`: edges leaving the target: what it supersedes,
253
+ `depends_on`, or affects.
254
+ - `direction=in`: edges entering the target: what references or
255
+ replaces it.
256
+ - `direction=both`: the default for the local graph trace; the full
257
+ neighborhood.
258
+
259
+ Every returned node carries `via` (`center`, `in`, `out`, or `in+out`)
260
+ telling how it connects to the trace center.
261
+
262
+ CLI: `knl-view graph trace --target=<id> --direction=out`
263
+ HTTP: `GET /api/graph/trace?target=<id>&direction=in`
264
+
265
+ The AnchorDB endpoint adds the same parameter,
266
+ `GET /api/anchordb/trace?target=<id>&direction=in|out|both` (default
267
+ `out`): `out` is scored server-side via `causalChain`; `in` is walked
268
+ backwards from the local sync mirror; the wire protocol has no reverse
269
+ query, and the mirror holds every edge this project ever linked, so it
270
+ is exactly the inbound map for this project's model. Mirror results
271
+ carry score 1 and the response reports `mirrored: true`/`false` so
272
+ consumers know which half came from where.
273
+
274
+ ### Consensus (claims)
275
+
276
+ A second AnchorDB model, the `consensus` role in the project's models map,
277
+ holds agreement and conflict between *claims*: short statements that are
278
+ content-addressed (`c-` + 16 hex chars of the statement's hash), so the same
279
+ text is the same claim on every machine. Claims relate only to other claims,
280
+ through two fixed relation types: `agrees_with` and `contradicts`. The
281
+ consensus structure lives purely in AnchorDB; the local artifacts (claim
282
+ index in `~/.knlview/claims/`, edge mirror in `~/.knlview/sync-state/`) are
283
+ caches that degrade convenience, never the data.
284
+
285
+ A claim's status is derived from who points at it: any incoming `contradicts`
286
+ makes it `disputed`, otherwise any incoming `agrees_with` makes it
287
+ `consensus`, otherwise it is `uncontested`.
288
+
289
+ ```sh
290
+ knl-view consensus claim "We use bcrypt for password hashing"
291
+ knl-view consensus agree c-a1b2c3d4e5f6a1b2 c-437ff9f10f83edde
292
+ knl-view consensus contradict c-a1b2c3d4e5f6a1b2 c-437ff9f10f83edde
293
+ knl-view consensus retract c-a1b2c3d4e5f6a1b2 c-437ff9f10f83edde
294
+ knl-view consensus status c-437ff9f10f83edde
295
+ knl-view consensus list
296
+ ```
297
+
298
+ Mutations are CLI-only on purpose: one write path, one mirror kept honest.
299
+ The read-only HTTP endpoint answers "is this claim settled?":
300
+
301
+ `GET /api/consensus?target=<claimId>` returns the claim's `status`,
302
+ `supporters`, `objectors`, its own `stance`, `mirrored` (whether a valid
303
+ local mirror backs the inbound half), and a `statements` map of the
304
+ claim texts involved. Returns `503` when AnchorDB is off or the
305
+ `consensus` role is not mapped.
306
+
307
+ ### Sources graph (whole project)
308
+
309
+ A third AnchorDB model, the `sources` role in the models map, holds the
310
+ dependency graph of the whole project, not just `.knowledges`. Every file
311
+ becomes a node (id = repo-relative path; hidden folders are skipped except
312
+ `.github`, and `node_modules`, `dist`, and `.gitignore` patterns are
313
+ ignored). Import edges are extracted with tree-sitter syntax parsing (the
314
+ JS family and Go today, one grammar package per language) and stored in
315
+ both directions (`imports`, `imported_by`) so lineage works without any
316
+ local mirror: sync is server-authoritative, enumerating the server's own
317
+ records and edges before applying the difference from a fresh disk scan.
318
+
319
+ Each file also defines **symbol nodes**, extracted from the same parse:
320
+
321
+ - Symbol ids are `<path>#<name>`; class methods are `Class.method`. A name
322
+ defined more than once in one file gets a line suffix
323
+ (`<path>#<name>@<line>`), so duplicate helpers stay distinct records.
324
+ - Kinds: `function`, `class`, `method`, `type` (Go type declarations).
325
+ - Edges: `defines`/`defined_in` (file → symbol) and `calls`/`called_by`
326
+ (symbol → symbol), each stored in both directions because causalChain
327
+ walks forward only.
328
+ - Call resolution is conservative: a call belongs to its innermost
329
+ enclosing symbol, and the callee must match exactly one definition
330
+ project-wide (same package directory preferred in Go). A receiver-qualified
331
+ call (`obj.Method()`) resolves only when the receiver is an import
332
+ binding of the file, otherwise it is skipped, never guessed.
333
+ - Label text (symbol names and kinds; AnchorDB attributes are
334
+ numeric-only) is written to `.knowledges/.knl-data/<path>.md`, one file
335
+ per source file that has symbols; override the location with `labelDir`
336
+ in the project config. Labels are regenerated and pruned on every sync.
337
+
338
+ ```sh
339
+ knl-view model new sources
340
+ knl-view sources sync
341
+ knl-view sources collect
342
+ knl-view sources trace --target=server/index.js --direction=out --hops=2
343
+ knl-view sources trace --target=server/index.js#handleTrace --direction=in
344
+ ```
345
+
346
+ `sync` is idempotent: run it again after refactoring and only the
347
+ difference is applied. A target containing `#` traces symbol lineage over
348
+ `calls`/`called_by`; a plain path traces file lineage over
349
+ `imports`/`imported_by`. Records the disk no longer has are archived with
350
+ the native lifecycle opcode 2 (TOMBSTONE: the server hides them from list
351
+ and lookups) after their edges are unlinked, and the `tombstone = 2`
352
+ attribute stays as a marker for servers that predate opcode support.
353
+ `sync` then asks the REST collector to purge those records physically
354
+ (scoped to the model); run `knl-view sources collect` by hand if the REST
355
+ endpoint was unreachable at that moment. A reappearing file revives the
356
+ record with a normal save and relinks its edges. Sync reports
357
+ `ORPHAN EDGES` when an edge endpoint failed to save, so a broken sync is
358
+ never silent. The read-only HTTP endpoint answers the same queries:
359
+ `GET /api/sources/trace?target=<id>&direction=in|out|both&hops=N`.
360
+
361
+ ### CLI Query
362
+
363
+ ```sh
364
+ knl-view graph trace --target=DEC-20261030-135001 --hops=1
365
+ ```
366
+
367
+ Outputs a compact JSON subgraph to `stdout` containing the focal node and all direct dependencies/impacted components.
368
+
369
+ ### HTTP Endpoints
370
+
371
+ When `knl-view` is running as a local server:
372
+ - `GET /api/graph`: Returns the entire knowledge and decision graph structure.
373
+ - `GET /api/graph/trace?target=<id>&hops=2`: Returns an isolated $N$-hop neighborhood subgraph for AI agents or interactive visualization.
374
+ - `GET /api/anchordb/trace?target=<id>&hops=2`: Returns a causal chain traced on the AnchorDB server (requires the global `anchordb` config block). Returns `503` when AnchorDB is off or unreachable.
375
+ - `GET /api/consensus?target=<claimId>`: Read-only consensus status for one claim (requires AnchorDB and a mapped `consensus` role). Returns `503` when AnchorDB is off or the role is unmapped, `400` without a target.
376
+ - `GET /api/sources/trace?target=<path>&direction=in|out&hops=2`: Read-only file lineage over the whole-project sources graph (requires AnchorDB and a mapped `sources` role). Returns `503` when unavailable, `400` without a target or with a bad direction.
377
+
378
+ ## Development
379
+
380
+ ```sh
381
+ npm run dev
382
+ ```
383
+
384
+ Starts the API on port 8085 (override with `PORT`) and the Vite dev server on
385
+ 5173 (override with `WEB_PORT`). Pass a base folder as the first argument:
386
+
387
+ ```sh
388
+ npm run dev -- ../some-project/.knowledges
389
+ ```
390
+
391
+ `dist/` is committed to this repository so that installs straight from GitHub
392
+ keep working, because npm runs no build step for a git install without a
393
+ `prepare` script. After changing the frontend, run `npm run build` and commit
394
+ the result together with the source, or those installs stay on the previous
395
+ build.
396
+
397
+ ## License
398
+
399
+ Apache-2.0. See [LICENSE](LICENSE).