unknown-knowledge 2.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.
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +167 -0
- package/cli/.gitkeep +0 -0
- package/cli/commands/init-copy.js +90 -0
- package/cli/commands/init.js +386 -0
- package/cli/init-copy.js +24 -0
- package/cli/init.js +24 -0
- package/cli/kit.manifest.yaml +256 -0
- package/cli/lib/copy-payload.js +334 -0
- package/cli/lib/generate-wrappers.js +162 -0
- package/package.json +36 -0
- package/payload/adapter-fixtures/README.md +53 -0
- package/payload/adapter-fixtures/html/EXPECTED.yaml +50 -0
- package/payload/adapter-fixtures/html/sample.html +38 -0
- package/payload/adapter-fixtures/md/EXPECTED.yaml +65 -0
- package/payload/adapter-fixtures/md/sample.md +32 -0
- package/payload/adapter-fixtures/pdf/EXPECTED.yaml +45 -0
- package/payload/adapter-fixtures/pdf/sample.pdf +0 -0
- package/payload/adapter-fixtures/txt/EXPECTED.yaml +31 -0
- package/payload/adapter-fixtures/txt/sample.txt +18 -0
- package/payload/docs/README.md +102 -0
- package/payload/docs/boundaries.md +60 -0
- package/payload/docs/ci-wiring.md +109 -0
- package/payload/docs/steward-guide.md +238 -0
- package/payload/engine/audit.js +34 -0
- package/payload/engine/commands/audit.js +289 -0
- package/payload/engine/commands/derive.js +334 -0
- package/payload/engine/commands/ingest.js +124 -0
- package/payload/engine/commands/log-entry.js +85 -0
- package/payload/engine/commands/phoenix.js +206 -0
- package/payload/engine/commands/preflight.js +530 -0
- package/payload/engine/commands/resolve.js +1678 -0
- package/payload/engine/commands/survey-map.js +351 -0
- package/payload/engine/commands/validate-values.js +315 -0
- package/payload/engine/commands/validate.js +1426 -0
- package/payload/engine/derive.js +34 -0
- package/payload/engine/ingest.js +34 -0
- package/payload/engine/lib/anchor-signatures.js +126 -0
- package/payload/engine/lib/boot.js +39 -0
- package/payload/engine/lib/call-numbers.js +133 -0
- package/payload/engine/lib/cli.js +147 -0
- package/payload/engine/lib/coverage.js +849 -0
- package/payload/engine/lib/decomposition.js +225 -0
- package/payload/engine/lib/derived.js +494 -0
- package/payload/engine/lib/engine-refusal.js +40 -0
- package/payload/engine/lib/exit-codes.js +14 -0
- package/payload/engine/lib/extractor-kinds.js +955 -0
- package/payload/engine/lib/format-adapters.js +802 -0
- package/payload/engine/lib/id-grammars.js +178 -0
- package/payload/engine/lib/iso-date.js +55 -0
- package/payload/engine/lib/kit-root.js +101 -0
- package/payload/engine/lib/load-stores.js +1624 -0
- package/payload/engine/lib/log-entry.js +196 -0
- package/payload/engine/lib/phoenix.js +628 -0
- package/payload/engine/lib/scoring.js +150 -0
- package/payload/engine/lib/suppressions.js +172 -0
- package/payload/engine/lib/time-verdicts.js +282 -0
- package/payload/engine/lib/usage-error.js +14 -0
- package/payload/engine/lib/validate-record.js +504 -0
- package/payload/engine/log-entry.js +34 -0
- package/payload/engine/phoenix.js +39 -0
- package/payload/engine/preflight.js +34 -0
- package/payload/engine/resolve.js +34 -0
- package/payload/engine/survey-map.js +34 -0
- package/payload/engine/validate-values.js +34 -0
- package/payload/engine/validate.js +34 -0
- package/payload/extractor-fixtures/.gitkeep +0 -0
- package/payload/extractor-fixtures/README.md +29 -0
- package/payload/extractor-fixtures/swift/strings-keys/EXPECTED.yaml +8 -0
- package/payload/extractor-fixtures/swift/strings-keys/sample.strings +15 -0
- package/payload/extractor-fixtures/swift/swift-const-array/EXPECTED.yaml +7 -0
- package/payload/extractor-fixtures/swift/swift-const-array/sample.swift +21 -0
- package/payload/extractor-fixtures/swift/swift-enum/EXPECTED.yaml +8 -0
- package/payload/extractor-fixtures/swift/swift-enum/sample.swift +30 -0
- package/payload/extractor-fixtures/swift/yaml-keys/EXPECTED.yaml +6 -0
- package/payload/extractor-fixtures/swift/yaml-keys/sample.yaml +23 -0
- package/payload/extractor-fixtures/swift/yaml-map-keys/EXPECTED.yaml +7 -0
- package/payload/extractor-fixtures/swift/yaml-map-keys/sample.yaml +15 -0
- package/payload/extractor-fixtures/ts/dir-modules/EXPECTED.yaml +12 -0
- package/payload/extractor-fixtures/ts/dir-modules/sample-modules/alpha.widget.ts +1 -0
- package/payload/extractor-fixtures/ts/dir-modules/sample-modules/beta.widget.ts +1 -0
- package/payload/extractor-fixtures/ts/dir-modules/sample-modules/gamma.widget.ts +1 -0
- package/payload/extractor-fixtures/ts/dir-modules/sample-modules/helpers/format.ts +3 -0
- package/payload/extractor-fixtures/ts/dir-modules/sample-modules/widgets.test.ts +2 -0
- package/payload/extractor-fixtures/ts/json-keys/EXPECTED.yaml +7 -0
- package/payload/extractor-fixtures/ts/json-keys/sample.json +5 -0
- package/payload/extractor-fixtures/ts/json-map-keys/EXPECTED.yaml +7 -0
- package/payload/extractor-fixtures/ts/json-map-keys/sample.json +13 -0
- package/payload/extractor-fixtures/ts/ts-const-array/EXPECTED.yaml +6 -0
- package/payload/extractor-fixtures/ts/ts-const-array/sample.ts +13 -0
- package/payload/extractor-fixtures/ts/ts-enum/EXPECTED.yaml +7 -0
- package/payload/extractor-fixtures/ts/ts-enum/sample.ts +11 -0
- package/payload/extractor-fixtures/ts/ts-object-keys/EXPECTED.yaml +6 -0
- package/payload/extractor-fixtures/ts/ts-object-keys/sample.tsx +23 -0
- package/payload/extractor-fixtures/ts/ts-union/EXPECTED.yaml +5 -0
- package/payload/extractor-fixtures/ts/ts-union/sample.ts +9 -0
- package/payload/hooks/pre-commit +37 -0
- package/payload/hooks/reverse-lookup +66 -0
- package/payload/package.json +3 -0
- package/payload/protocol/.gitkeep +0 -0
- package/payload/protocol/AGENTS.md +239 -0
- package/payload/protocol/derived-layer.md +174 -0
- package/payload/protocol/new-kind-pipeline.md +179 -0
- package/payload/protocol/registry-warrant.md +162 -0
- package/payload/protocol/skills/kb-build.md +303 -0
- package/payload/protocol/skills/knowledge-audit.md +183 -0
- package/payload/protocol/skills/knowledge-bootstrap.md +229 -0
- package/payload/protocol/skills/knowledge-reflect.md +397 -0
- package/payload/schemas/catalog.schema.json +32 -0
- package/payload/schemas/decision-entry.schema.json +122 -0
- package/payload/schemas/finding.schema.json +77 -0
- package/payload/schemas/gap.schema.json +52 -0
- package/payload/schemas/graduation-categories.schema.json +64 -0
- package/payload/schemas/knowledge-leaf.schema.json +194 -0
- package/payload/schemas/miss.schema.json +45 -0
- package/payload/schemas/ontology-concept.schema.json +115 -0
- package/payload/schemas/phoenix-event.schema.json +76 -0
- package/payload/schemas/registry.schema.json +57 -0
- package/payload/schemas/rules.schema.json +14 -0
- package/payload/schemas/survey-scope.schema.json +23 -0
- package/payload/templates/decisions/_catalog.yaml +7 -0
- package/payload/templates/decisions/_registries/graduation-categories.yaml +42 -0
- package/payload/templates/decisions/phoenix-event.yaml +74 -0
- package/payload/templates/decisions/reflect-mint-proposal.yaml +100 -0
- package/payload/templates/decisions/registry-minting.yaml +58 -0
- package/payload/templates/decisions/trust-graduation.yaml +120 -0
- package/payload/templates/decisions/trust-revocation.yaml +106 -0
- package/payload/templates/knowledge/_catalog.yaml +9 -0
- package/payload/templates/knowledge/_registries/anchor.yaml +42 -0
- package/payload/templates/knowledge/_registries/authority-tiers.yaml +32 -0
- package/payload/templates/knowledge/_registries/domains.yaml +43 -0
- package/payload/templates/knowledge/_registries/form.yaml +38 -0
- package/payload/templates/knowledge/_registries/jurisdictions.yaml +20 -0
- package/payload/templates/knowledge/_registries/operations.yaml +18 -0
- package/payload/templates/knowledge/_registries/stage.yaml +53 -0
- package/payload/templates/knowledge/_rules.yaml +6 -0
- package/payload/templates/new-kind/README.md +107 -0
- package/payload/templates/new-kind/descriptor.example.yaml +18 -0
- package/payload/templates/new-kind/fixture/EXPECTED.yaml +6 -0
- package/payload/templates/new-kind/fixture/demo-anchor.list +2 -0
- package/payload/templates/new-kind/fixture/sample.list +7 -0
- package/payload/templates/new-kind/parser.example.js +98 -0
- package/payload/templates/ontology/_catalog.yaml +6 -0
- package/payload/templates/ontology/_rules.yaml +6 -0
- package/payload/wrappers/cursor.mdc +15 -0
- package/payload/wrappers/pointer.md +10 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# unknown-knowledge
|
|
2
|
+
|
|
3
|
+
A free, open-source CLI that stands up a self-improving knowledge base in any
|
|
4
|
+
codebase, and a deterministic engine that keeps it honest.
|
|
5
|
+
|
|
6
|
+
**The map is never the fact.** The stores hold claims and pointers; your source
|
|
7
|
+
files hold the facts. The engine's only job is to diff the two and say exactly
|
|
8
|
+
where they disagree — so an agent reading the knowledge base is reading
|
|
9
|
+
something that was checked, not something somebody remembered.
|
|
10
|
+
|
|
11
|
+
Nothing here is a service. There is no runtime, no daemon, no network call, and
|
|
12
|
+
no update channel. Everything is YAML and JavaScript files in your repo,
|
|
13
|
+
branched and merged by your normal PRs.
|
|
14
|
+
|
|
15
|
+
## Quickstart
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
cd your-repo
|
|
19
|
+
npx unknown-knowledge init # seeds unknown-knowledge/ and an agent wrapper
|
|
20
|
+
npm install --save-dev js-yaml # the engine's one runtime dependency
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Then run `/knowledge-bootstrap` in your coding agent. Phase 2 surveys the repo,
|
|
24
|
+
proposes Anchor candidates, and you approve each Concept. Nothing is captured
|
|
25
|
+
automatically — a fact nobody approved is a fact nobody checked.
|
|
26
|
+
|
|
27
|
+
## What you get
|
|
28
|
+
|
|
29
|
+
Three governed YAML stores, split by **truth anchor** — who is allowed to say a
|
|
30
|
+
thing is true:
|
|
31
|
+
|
|
32
|
+
| Store | Holds | Anchored to |
|
|
33
|
+
| --- | --- | --- |
|
|
34
|
+
| `ontology/` | what the system *is* | your source files |
|
|
35
|
+
| `knowledge/` | what the team *knows* | cited evidence |
|
|
36
|
+
| `decisions/` | what was *chosen*, and why | the team |
|
|
37
|
+
|
|
38
|
+
An **Ontology Concept** names a closed set of values and points at the file that
|
|
39
|
+
owns them. An **Extractor kind** re-derives that set by reading the file
|
|
40
|
+
lexically, and the value validator diffs the two. When someone adds a case to an
|
|
41
|
+
enum and forgets the store, the diff says so.
|
|
42
|
+
|
|
43
|
+
Thirteen extractor kinds ship — across TypeScript, Swift, JSON, YAML,
|
|
44
|
+
`.strings`, and newline-delimited lists. Twelve of them the survey map can
|
|
45
|
+
propose for you by signature; the thirteenth is reachable only when a human
|
|
46
|
+
names it, because "a file of lines" describes every text file ever written.
|
|
47
|
+
|
|
48
|
+
They **refuse rather than guess**: a kind that meets a spread, a
|
|
49
|
+
computed key, or a re-export barrel raises a hard error, because a confident
|
|
50
|
+
wrong parse is a false all-clear. What it could not read is recorded in
|
|
51
|
+
`logs/misses/` for a human to decide about.
|
|
52
|
+
|
|
53
|
+
## The engine
|
|
54
|
+
|
|
55
|
+
Ten command-line surfaces. JavaScript with JSDoc types, zero build step, one
|
|
56
|
+
dependency (D-022).
|
|
57
|
+
|
|
58
|
+
| Command | Answers |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| `validate.js` | is the store structurally sound? |
|
|
61
|
+
| `validate-values.js` | do the Concepts still match the code they point at? |
|
|
62
|
+
| `preflight.js` | which Concepts may this agent trust, right now? |
|
|
63
|
+
| `resolve.js` | what does the store know about these terms or paths? |
|
|
64
|
+
| `survey-map.js` | what is in this repo, and what could not be surveyed? |
|
|
65
|
+
| `audit.js` | what looks like knowledge but was never written down? |
|
|
66
|
+
| `log-entry.js` | append a finding, miss or gap — never by hand-editing YAML |
|
|
67
|
+
| `ingest.js` | normalize a document (md, txt, html, pdf) to one intermediate representation |
|
|
68
|
+
| `phoenix.js` | apply a phoenix event: re-file a drifted subtree in bulk, in full or not at all |
|
|
69
|
+
| `derive.js` | regenerate the derived layer: plural browse trees, call numbers, resolution index |
|
|
70
|
+
|
|
71
|
+
### Exit codes are a contract
|
|
72
|
+
|
|
73
|
+
Every surface obeys the same three codes, and agents ride them:
|
|
74
|
+
|
|
75
|
+
| Code | Means |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| `0` | the check ran and found nothing |
|
|
78
|
+
| `1` | the check ran and **found something** |
|
|
79
|
+
| `2` | the check **did not run** — an engine failure |
|
|
80
|
+
|
|
81
|
+
The distinction between `1` and `2` is the load-bearing one. An agent that reads
|
|
82
|
+
`1` quarantines the affected Concepts and continues. If a crashed command could
|
|
83
|
+
exit `1`, that agent would walk straight past a check that never happened. So a
|
|
84
|
+
crash always exits `2`, and a test enumerates every surface, forces a bug into
|
|
85
|
+
each, and proves it.
|
|
86
|
+
|
|
87
|
+
The reverse audit is advisory: its findings are proposals for human review, and
|
|
88
|
+
never a gate. A human may opt in with `--fail-on-findings`, and that is never a
|
|
89
|
+
shipped CI default.
|
|
90
|
+
|
|
91
|
+
## Guarantees
|
|
92
|
+
|
|
93
|
+
- **The engine never executes your code** (D-014). No `eval`, no importing your
|
|
94
|
+
modules, no spawning your build. Parsing is lexical; the one subprocess it
|
|
95
|
+
runs is `git ls-files`.
|
|
96
|
+
- **No network, ever.** Nothing is uploaded, and nothing is fetched.
|
|
97
|
+
- **Deterministic.** Same tree in, byte-identical output out. Dates are
|
|
98
|
+
injected, never read from the wall clock, so a report is reproducible from
|
|
99
|
+
its inputs.
|
|
100
|
+
- **Nothing ships by omission** (D-007). An explicit manifest lists every file
|
|
101
|
+
`init` seeds; a file it does not name is never copied.
|
|
102
|
+
|
|
103
|
+
## Hooks — the protocol, enforced mechanically
|
|
104
|
+
|
|
105
|
+
Two POSIX-sh hooks seed under `hooks/`: `pre-commit` runs the blocking
|
|
106
|
+
validator before a commit exists, and `reverse-lookup` runs the `--paths`
|
|
107
|
+
lookup over your staged diff, so the knowledge governing the files you touched
|
|
108
|
+
surfaces without anyone remembering to ask. Each is a thin wrapper — it invokes
|
|
109
|
+
one engine command and exits with its code, unchanged — and neither reads a
|
|
110
|
+
bypass variable, because a hook with an off switch enforces nothing.
|
|
111
|
+
|
|
112
|
+
They **seed but do not install**: `init` never writes `.git/`, so wiring them is
|
|
113
|
+
your act, not the kit's. Git runs a hook only if it is executable, and the copy
|
|
114
|
+
engine seeds bytes rather than modes — so set the bit when you wire it:
|
|
115
|
+
|
|
116
|
+
```sh
|
|
117
|
+
chmod +x unknown-knowledge/hooks/*
|
|
118
|
+
ln -s ../../unknown-knowledge/hooks/pre-commit .git/hooks/pre-commit
|
|
119
|
+
ln -s ../../unknown-knowledge/hooks/reverse-lookup .git/hooks/prepare-commit-msg
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Note the second symlink's name. Git runs a hook only if its filename is one of
|
|
123
|
+
the events git fires, and `reverse-lookup` is not one of them —
|
|
124
|
+
`prepare-commit-msg` runs after the index is staged and before the message
|
|
125
|
+
editor opens, which is when attribution is still actionable. (Git passes that
|
|
126
|
+
hook the message file and source as arguments; the script ignores them and
|
|
127
|
+
reads the staged diff itself.) The same rule bites harder under
|
|
128
|
+
`core.hooksPath` pointed at the seeded directory: git looks there for
|
|
129
|
+
event-named files only, so `reverse-lookup` would sit beside `pre-commit` and
|
|
130
|
+
never fire. Under that wiring, call it explicitly from your `pre-commit`.
|
|
131
|
+
|
|
132
|
+
## Seeded once, then owned
|
|
133
|
+
|
|
134
|
+
After `init`, the seeded directory has no relationship to this kit (D-001).
|
|
135
|
+
There is no update channel and there never will be one. You own the engine, you
|
|
136
|
+
can read it, and you can change it — it is JavaScript, not a binary.
|
|
137
|
+
|
|
138
|
+
The seed stamps the kit version into `unknown-knowledge/kit.manifest.yaml`. That
|
|
139
|
+
stamp is a **birth certificate, not a dependency pin**: it records the schema
|
|
140
|
+
revision, extractor-kind set and fixture vintage the seed was born with. It
|
|
141
|
+
never implies an update channel — upgrading an existing seed is deferred by
|
|
142
|
+
design.
|
|
143
|
+
|
|
144
|
+
## Versioning
|
|
145
|
+
|
|
146
|
+
Semver, with kit-specific semantics (D-021): **MAJOR** is a store
|
|
147
|
+
schema-version bump or a breaking change to the engine CLI contract (commands,
|
|
148
|
+
flags, exit codes, output consumed by wrappers); **MINOR** is new extractor
|
|
149
|
+
kinds, new engine surfaces, or a new fixture vintage; **PATCH** is fixes and
|
|
150
|
+
documentation. Changes are tracked in [CHANGELOG.md](CHANGELOG.md) (Keep a
|
|
151
|
+
Changelog form).
|
|
152
|
+
|
|
153
|
+
## Reading further
|
|
154
|
+
|
|
155
|
+
- [CONTEXT.md](CONTEXT.md) — the domain glossary. Start here.
|
|
156
|
+
- [decisions/](decisions/) — the kit records its own decisions, in the same
|
|
157
|
+
format it asks you to use. It eats its own cooking.
|
|
158
|
+
- [docs/publishing.md](docs/publishing.md) — release and supply-chain process
|
|
159
|
+
(npm provenance, 2FA).
|
|
160
|
+
|
|
161
|
+
## License and contributing
|
|
162
|
+
|
|
163
|
+
Licensed under [Apache-2.0](LICENSE) (D-020); redistribution carries the
|
|
164
|
+
[NOTICE](NOTICE) file. Contributions are welcome — especially new extractor
|
|
165
|
+
kinds, and field reports of anchors the extractors could not read. See
|
|
166
|
+
[CONTRIBUTING.md](CONTRIBUTING.md) for the gate (parser + fixture + demo run,
|
|
167
|
+
D-005) and PR expectations.
|
package/cli/.gitkeep
ADDED
|
File without changes
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* init-copy (KK-17) — thin, flags-only CLI over the payload copy engine
|
|
3
|
+
* (cli/lib/copy-payload.js). This is the deterministic Phase-1 copy step of
|
|
4
|
+
* PRD §6 minus the prompts: KK-19's `npx unknown-knowledge init` wraps it
|
|
5
|
+
* with the interactive UX (root-name prompt, platform multi-select, stack
|
|
6
|
+
* auto-detection) and the git check-ignore sweep.
|
|
7
|
+
*
|
|
8
|
+
* Exit codes (engine contract, payload/engine/lib/exit-codes.js):
|
|
9
|
+
* 0 — seeded clean. Wrapper collisions that skip-and-report (§6) are
|
|
10
|
+
* reported results, not failures — the seed happened.
|
|
11
|
+
* 2 — refusal (existing/partial seed, dotted root), usage error (incl.
|
|
12
|
+
* unknown platform/stack — checked BEFORE seeding), or any engine
|
|
13
|
+
* failure. A seed that did not happen is never a silent pass.
|
|
14
|
+
* (1 is unused here: copying has no findings/quarantine middle ground.)
|
|
15
|
+
*
|
|
16
|
+
* Usage: node cli/init-copy.js --target <dir> [--root <name>]
|
|
17
|
+
* [--stacks <s1,s2>] [--platforms <p1,p2>]
|
|
18
|
+
* [--json]
|
|
19
|
+
*/
|
|
20
|
+
import { fileURLToPath } from 'node:url';
|
|
21
|
+
import { resolve } from 'node:path';
|
|
22
|
+
import process from 'node:process';
|
|
23
|
+
import { copyPayload, loadManifest, DEFAULT_ROOT, SeedRefusal } from '../lib/copy-payload.js';
|
|
24
|
+
import { assertKnownPlatforms, generateWrappers } from '../lib/generate-wrappers.js';
|
|
25
|
+
import { EXIT_CODES } from '../../payload/engine/lib/exit-codes.js';
|
|
26
|
+
import { parseArgs as parseFlags, rethrowIfBug, UsageError } from '../../payload/engine/lib/cli.js';
|
|
27
|
+
|
|
28
|
+
export const USAGE = 'usage: node cli/init-copy.js --target <dir> [--root <name>] [--stacks <s1,s2>] [--platforms <p1,p2>] [--json]';
|
|
29
|
+
// The kit root, two levels up: cli/commands/<this>.js (UCS-950).
|
|
30
|
+
const kitRoot = fileURLToPath(new URL('../..', import.meta.url));
|
|
31
|
+
|
|
32
|
+
/** `a, b,,c` → ['a','b','c']; absent → []. */
|
|
33
|
+
const splitList = (value) => (value ?? '').split(',').map((s) => s.trim()).filter(Boolean);
|
|
34
|
+
|
|
35
|
+
function parseArgs(argv) {
|
|
36
|
+
const { options } = parseFlags(argv, {
|
|
37
|
+
boolean: ['json'],
|
|
38
|
+
value: ['target', 'root', 'stacks', 'platforms'],
|
|
39
|
+
});
|
|
40
|
+
if (options.target === undefined) throw new UsageError('--target is required');
|
|
41
|
+
return {
|
|
42
|
+
target: options.target,
|
|
43
|
+
root: options.root ?? DEFAULT_ROOT,
|
|
44
|
+
stacks: splitList(options.stacks),
|
|
45
|
+
platforms: splitList(options.platforms),
|
|
46
|
+
json: !!options.json,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function main(argv) {
|
|
51
|
+
const opts = parseArgs(argv); // a UsageError reaches the harness
|
|
52
|
+
try {
|
|
53
|
+
// Unknown platform ids refuse BEFORE the seed — a failed multi-select
|
|
54
|
+
// must not leave a half-initialized target behind.
|
|
55
|
+
assertKnownPlatforms(loadManifest(kitRoot), opts.platforms);
|
|
56
|
+
const result = copyPayload({
|
|
57
|
+
kitRoot, targetDir: opts.target, rootName: opts.root, stacks: opts.stacks,
|
|
58
|
+
});
|
|
59
|
+
let wrappers;
|
|
60
|
+
try {
|
|
61
|
+
wrappers = generateWrappers({
|
|
62
|
+
kitRoot, targetDir: opts.target, rootName: opts.root, platforms: opts.platforms,
|
|
63
|
+
});
|
|
64
|
+
} catch (error) {
|
|
65
|
+
// The seed already landed; shared files may carry sentinel appends, so
|
|
66
|
+
// a silent rollback could destroy user bytes — name the partial state
|
|
67
|
+
// instead (a retry refuses on the existing root by design, §6).
|
|
68
|
+
error.message = `${error.message}\n the store seed was already created at ${result.root} — remove it (and any wrapper sentinel blocks) before retrying; init refuses on an existing root`;
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
if (opts.json) {
|
|
72
|
+
process.stdout.write(`${JSON.stringify({ ok: true, ...result, wrappers }, null, 2)}\n`);
|
|
73
|
+
} else {
|
|
74
|
+
process.stdout.write(
|
|
75
|
+
`seeded ${result.rootName}/ (kit ${result.version}, stacks: ${result.stacks.join(', ') || 'none'}) `
|
|
76
|
+
+ `— ${result.files.length} files at ${result.root}\n`);
|
|
77
|
+
for (const w of wrappers) {
|
|
78
|
+
process.stdout.write(w.action === 'skipped'
|
|
79
|
+
? `wrapper ${w.platform}: skipped ${w.target} — ${w.reason}\n`
|
|
80
|
+
: `wrapper ${w.platform}: ${w.action} ${w.target}\n`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return EXIT_CODES.CLEAN;
|
|
84
|
+
} catch (error) {
|
|
85
|
+
const kind = error instanceof SeedRefusal ? 'refused' : 'error';
|
|
86
|
+
process.stderr.write(`init-copy: ${kind}: ${error.message}\n`);
|
|
87
|
+
rethrowIfBug(error); // a bug is not a refusal — the harness prints its stack
|
|
88
|
+
return EXIT_CODES.FAILURE;
|
|
89
|
+
}
|
|
90
|
+
}
|