structured-context 0.9.2 → 0.9.3

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.
@@ -3,243 +3,13 @@
3
3
  "$id": "sctx://knowledge_wiki",
4
4
  "title": "Knowledge Wiki",
5
5
  "description": "Lightweight schema for LLM-maintained knowledge wikis. Supports source pages, concept pages, syntheses, and notes. Designed for compounding knowledge bases where the LLM creates and maintains wiki pages from raw sources.\n\nFlat entity model — no hierarchy, no required parent links. Wikilinks between any pages are valid for arbitrary cross-referencing. The schema validates structure and provenance; it does not constrain meaning.\n\nBased on the pattern described in Karpathy's LLM Wiki (2026).",
6
- "$metadata": {
7
- "aliases": {
8
- "source_summary": "source",
9
- "study": "source",
10
- "article": "source",
11
- "paper": "source",
12
- "research": "source",
13
- "comparison": "synthesis",
14
- "query": "synthesis"
15
- },
16
- "relationships": [
17
- {
18
- "parent": "source",
19
- "type": "source",
20
- "field": "sources",
21
- "fieldOn": "child",
22
- "multiple": true
23
- },
24
- {
25
- "parent": "source",
26
- "type": "synthesis",
27
- "field": "sources",
28
- "fieldOn": "child",
29
- "multiple": true
30
- },
31
- {
32
- "parent": "source",
33
- "type": "entity",
34
- "field": "sources",
35
- "fieldOn": "child",
36
- "multiple": true
37
- },
38
- {
39
- "parent": "concept",
40
- "type": "synthesis",
41
- "field": "concepts",
42
- "fieldOn": "child",
43
- "multiple": true
44
- }
45
- ],
46
- "rules": [
47
- {
48
- "id": "synthesis-references-sources",
49
- "category": "coherence",
50
- "description": "Syntheses should reference at least one contributing source in their sources array",
51
- "type": "synthesis",
52
- "check": "$exists(current.sources) and $count(current.sources) >= 1"
53
- },
54
- {
55
- "id": "concept-has-summary",
56
- "category": "best-practice",
57
- "description": "Concept pages should have a short summary for index discoverability",
58
- "type": "concept",
59
- "check": "$exists(current.summary) and $length(current.summary) > 0"
60
- }
61
- ]
62
- },
6
+ "allOf": [{ "$ref": "sctx://_knowledge_wiki" }],
63
7
  "oneOf": [
64
- {
65
- "type": "object",
66
- "description": "A processed summary of a raw source (article, paper, book, video, thread, podcast, etc.). Captures key information from the source in structured form with provenance.",
67
- "allOf": [{ "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" }],
68
- "properties": {
69
- "type": { "const": "source" },
70
- "summary": {
71
- "$ref": "sctx://_sctx_base#/$defs/summary"
72
- },
73
- "url": {
74
- "type": "string",
75
- "description": "URL of the original source"
76
- },
77
- "local_copy": {
78
- "$ref": "sctx://_sctx_base#/$defs/wikilink",
79
- "description": "Wikilink to a local copy of the source (e.g. a saved PDF or clipped note)"
80
- },
81
- "author": {
82
- "type": "string",
83
- "description": "Author or creator of the source"
84
- },
85
- "book": {
86
- "type": "string",
87
- "description": "Book title and author if the source is a book"
88
- },
89
- "published_date": {
90
- "type": "string",
91
- "format": "date",
92
- "description": "Original publication date"
93
- },
94
- "source_type": {
95
- "type": "string",
96
- "description": "Kind of source material. Free-form — common values include article, paper, book, video, podcast, thread, substack, tweet, website. Not enum-constrained to allow evolving vocabulary."
97
- },
98
- "sources": {
99
- "type": "array",
100
- "items": { "$ref": "sctx://_sctx_base#/$defs/wikilink" },
101
- "description": "Wikilinks to other source pages that this one references or extends"
102
- }
103
- },
104
- "required": ["type", "url"],
105
- "additionalProperties": true,
106
- "examples": [
107
- {
108
- "type": "source",
109
- "author": "Joe Bloggs",
110
- "url": "https://example.com/design-of-yesterday-things",
111
- "source_type": "book",
112
- "tags": ["design", "ux", "psychology"]
113
- }
114
- ]
115
- },
116
- {
117
- "type": "object",
118
- "description": "A concept or entity page — defines and frames a specific idea, mechanism, or domain term. May draw from multiple sources. The building blocks of the wiki's knowledge graph.",
119
- "allOf": [{ "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" }],
120
- "properties": {
121
- "type": { "const": "concept" },
122
- "summary": {
123
- "$ref": "sctx://_sctx_base#/$defs/summary"
124
- },
125
- "sources": {
126
- "type": "array",
127
- "items": { "$ref": "sctx://_sctx_base#/$defs/wikilink" },
128
- "description": "Wikilinks to source pages that contributed to this concept"
129
- },
130
- "related": {
131
- "type": "array",
132
- "items": { "$ref": "sctx://_sctx_base#/$defs/wikilink" },
133
- "description": "Wikilinks to related concept or synthesis pages"
134
- }
135
- },
136
- "required": ["type"],
137
- "additionalProperties": true,
138
- "examples": [
139
- {
140
- "type": "concept",
141
- "summary": "A property of an object that signals how it can be used, first described by Gibson and popularised in design by Norman",
142
- "tags": ["design", "ux"]
143
- }
144
- ]
145
- },
146
- {
147
- "type": "object",
148
- "description": "A concrete entity — a person, organisation, product, model, or other named thing. The building blocks of the wiki's knowledge graph alongside concepts. Entities are distinct from concepts: a concept frames an idea or mechanism; an entity is a specific, identifiable thing in the world.",
149
- "allOf": [{ "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" }],
150
- "properties": {
151
- "type": { "const": "entity" },
152
- "summary": {
153
- "$ref": "sctx://_sctx_base#/$defs/summary"
154
- },
155
- "sources": {
156
- "type": "array",
157
- "items": { "$ref": "sctx://_sctx_base#/$defs/wikilink" },
158
- "description": "Wikilinks to source pages that contributed to this entity page"
159
- },
160
- "related": {
161
- "type": "array",
162
- "items": { "$ref": "sctx://_sctx_base#/$defs/wikilink" },
163
- "description": "Wikilinks to related entity, concept, or synthesis pages"
164
- }
165
- },
166
- "required": ["type"],
167
- "additionalProperties": true,
168
- "examples": [
169
- {
170
- "type": "entity",
171
- "summary": "AI safety research lab founded by Dario Amodei and Daniela Amodei",
172
- "tags": ["company", "ai", "safety"]
173
- }
174
- ]
175
- },
176
- {
177
- "type": "object",
178
- "description": "A synthesis page — connects multiple concepts and sources into a coherent model, framework, or thesis. The highest-value pages in a knowledge wiki. Must reference contributing sources.",
179
- "allOf": [{ "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" }],
180
- "properties": {
181
- "type": { "const": "synthesis" },
182
- "summary": {
183
- "$ref": "sctx://_sctx_base#/$defs/summary"
184
- },
185
- "sources": {
186
- "type": "array",
187
- "items": { "$ref": "sctx://_sctx_base#/$defs/wikilink" },
188
- "description": "Wikilinks to source pages this synthesis draws from"
189
- },
190
- "concepts": {
191
- "type": "array",
192
- "items": { "$ref": "sctx://_sctx_base#/$defs/wikilink" },
193
- "description": "Wikilinks to concept pages this synthesis connects"
194
- }
195
- },
196
- "required": ["type"],
197
- "additionalProperties": true,
198
- "examples": [
199
- {
200
- "type": "synthesis",
201
- "summary": "How Norman's affordance model and feedback principles combine to explain intuitive vs confusing interfaces",
202
- "sources": ["[[The Design of Everyday Things - Don Norman]]"],
203
- "concepts": ["[[Affordance]]", "[[Feedback loop]]"]
204
- }
205
- ]
206
- },
207
- {
208
- "type": "object",
209
- "description": "Personal notes, journal entries, appointments, experiential records. Your own data about your journey — not sourced from external material.",
210
- "allOf": [{ "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" }],
211
- "properties": {
212
- "type": { "const": "note" },
213
- "date": {
214
- "type": "string",
215
- "format": "date",
216
- "description": "Date this entry was created or relates to"
217
- }
218
- },
219
- "required": ["type"],
220
- "additionalProperties": true,
221
- "examples": [
222
- {
223
- "type": "note",
224
- "date": "2024-03-15",
225
- "tags": ["reading-log"]
226
- }
227
- ]
228
- },
229
- {
230
- "type": "object",
231
- "description": "The wiki index — a catalog of all pages with links, summaries, and metadata. Updated by the agent on ingest. Used as the primary navigation entry point.",
232
- "allOf": [{ "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" }],
233
- "properties": {
234
- "type": { "const": "index" }
235
- },
236
- "required": ["type"],
237
- "additionalProperties": true,
238
- "examples": [
239
- {
240
- "type": "index"
241
- }
242
- ]
243
- }
8
+ { "$ref": "sctx://_knowledge_wiki#/$defs/source" },
9
+ { "$ref": "sctx://_knowledge_wiki#/$defs/concept" },
10
+ { "$ref": "sctx://_knowledge_wiki#/$defs/entity" },
11
+ { "$ref": "sctx://_knowledge_wiki#/$defs/synthesis" },
12
+ { "$ref": "sctx://_knowledge_wiki#/$defs/note" },
13
+ { "$ref": "sctx://_knowledge_wiki#/$defs/index" }
244
14
  ]
245
15
  }
@@ -2,260 +2,18 @@
2
2
  "$schema": "https://raw.githubusercontent.com/mindsocket/structured-context/main/schemas/generated/_structured_context_schema_meta.json",
3
3
  "$id": "sctx://strategy_general",
4
4
  "title": "Strategy and opportunity ladder",
5
- "description": "Validates frontmatter for space node files",
6
- "$metadata": {
7
- "hierarchy": {
8
- "levels": [
9
- "vision",
10
- "mission",
11
- { "type": "goal", "selfRef": true, "matchers": ["Goals"] },
12
- { "type": "opportunity", "selfRef": true, "matchers": ["Opportunities"] },
13
- {
14
- "type": "solution",
15
- "selfRef": true,
16
- "matchers": ["Solutions", "Potential solutions", "Solutions considered", "Possible solutions"]
17
- },
18
- "experiment"
19
- ]
20
- },
21
- "aliases": {
22
- "outcome": "goal",
23
- "assumption_test": "experiment",
24
- "test": "experiment"
25
- },
26
- "relationships": [
27
- {
28
- "parent": "opportunity",
29
- "type": "problem_statement",
30
- "templateFormat": "heading",
31
- "matchers": ["Problem statement", "What problem are we solving?"],
32
- "multiple": false
33
- },
34
- {
35
- "parent": "opportunity",
36
- "type": "assumption",
37
- "templateFormat": "table",
38
- "matchers": ["Assumptions", "^Assumptions?$"],
39
- "embeddedTemplateFields": ["assumption", "status", "confidence"],
40
- "multiple": true
41
- }
42
- ]
43
- },
5
+ "description": "Validates frontmatter for space node files. Composes strategy_general entities from the bundled partial. Override the hierarchy in $metadata to customize the level structure.",
6
+ "allOf": [{ "$ref": "sctx://_strategy_general" }],
44
7
  "oneOf": [
45
- {
46
- "type": "object",
47
- "allOf": [{ "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" }],
48
- "properties": {
49
- "type": { "const": "dashboard" }
50
- },
51
- "required": ["type"],
52
- "additionalProperties": true
53
- },
54
- {
55
- "type": "object",
56
- "allOf": [{ "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" }],
57
- "properties": {
58
- "type": { "enum": ["ost_on_a_page", "space_on_a_page"] }
59
- },
60
- "required": ["type"],
61
- "additionalProperties": true
62
- },
63
- {
64
- "type": "object",
65
- "allOf": [
66
- { "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" },
67
- { "$ref": "sctx://_sctx_base#/$defs/ostEntityProps" }
68
- ],
69
- "properties": {
70
- "type": { "const": "vision" }
71
- },
72
- "required": ["type"],
73
- "not": { "required": ["parent"] },
74
- "additionalProperties": true,
75
- "examples": [
76
- {
77
- "type": "vision",
78
- "status": "active"
79
- }
80
- ]
81
- },
82
- {
83
- "type": "object",
84
- "allOf": [
85
- { "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" },
86
- { "$ref": "sctx://_sctx_base#/$defs/parentNodeProps" },
87
- { "$ref": "sctx://_sctx_base#/$defs/ostEntityProps" }
88
- ],
89
- "properties": {
90
- "type": { "const": "mission" }
91
- },
92
- "required": ["type"],
93
- "additionalProperties": true,
94
- "examples": [
95
- {
96
- "type": "mission",
97
- "status": "active",
98
- "parent": "[[Personal Vision]]"
99
- }
100
- ]
101
- },
102
- {
103
- "type": "object",
104
- "allOf": [
105
- { "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" },
106
- { "$ref": "sctx://_sctx_base#/$defs/parentNodeProps" },
107
- { "$ref": "sctx://_sctx_base#/$defs/ostEntityProps" }
108
- ],
109
- "properties": {
110
- "type": { "enum": ["goal", "outcome"] },
111
- "priority": { "$ref": "sctx://_sctx_base#/$defs/priority" }
112
- },
113
- "required": ["type"],
114
- "additionalProperties": true,
115
- "examples": [
116
- {
117
- "type": "goal",
118
- "status": "active",
119
- "parent": "[[My Mission (2026)]]",
120
- "priority": "p2"
121
- }
122
- ]
123
- },
124
- {
125
- "type": "object",
126
- "allOf": [
127
- { "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" },
128
- { "$ref": "sctx://_sctx_base#/$defs/parentNodeProps" },
129
- { "$ref": "sctx://_sctx_base#/$defs/ostEntityProps" }
130
- ],
131
- "properties": {
132
- "type": { "const": "opportunity" },
133
- "priority": { "$ref": "sctx://_sctx_base#/$defs/priority" },
134
- "impact": { "$ref": "sctx://_sctx_base#/$defs/assessment" },
135
- "feasibility": { "$ref": "sctx://_sctx_base#/$defs/assessment" },
136
- "resources": { "$ref": "sctx://_sctx_base#/$defs/assessment" },
137
- "timeline": {
138
- "type": "string",
139
- "description": "Timeline estimate (e.g., S-M, M-L)"
140
- },
141
- "next_steps": {
142
- "type": "string",
143
- "description": "Next steps for this opportunity"
144
- }
145
- },
146
- "required": ["type"],
147
- "additionalProperties": true,
148
- "examples": [
149
- {
150
- "type": "opportunity",
151
- "status": "identified",
152
- "parent": "[[Career Growth]]",
153
- "priority": "p2"
154
- }
155
- ]
156
- },
157
- {
158
- "type": "object",
159
- "allOf": [
160
- { "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" },
161
- { "$ref": "sctx://_sctx_base#/$defs/parentNodeProps" },
162
- { "$ref": "sctx://_sctx_base#/$defs/ostEntityProps" }
163
- ],
164
- "properties": {
165
- "type": { "const": "solution" },
166
- "priority": { "$ref": "sctx://_sctx_base#/$defs/priority" },
167
- "impact": { "$ref": "sctx://_sctx_base#/$defs/assessment" },
168
- "feasibility": { "$ref": "sctx://_sctx_base#/$defs/assessment" },
169
- "resources": { "$ref": "sctx://_sctx_base#/$defs/assessment" },
170
- "timeline": {
171
- "type": "string",
172
- "description": "Timeline estimate (e.g., S-M, M-L)"
173
- },
174
- "next_steps": {
175
- "type": "string",
176
- "description": "Next steps for this solution"
177
- }
178
- },
179
- "required": ["type"],
180
- "additionalProperties": true,
181
- "examples": [
182
- {
183
- "type": "solution",
184
- "status": "identified",
185
- "parent": "[[Some Opportunity]]",
186
- "priority": "p3"
187
- }
188
- ]
189
- },
190
- {
191
- "type": "object",
192
- "allOf": [
193
- { "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" },
194
- { "$ref": "sctx://_sctx_base#/$defs/parentNodeProps" },
195
- { "$ref": "sctx://_sctx_base#/$defs/ostEntityProps" }
196
- ],
197
- "properties": {
198
- "type": { "enum": ["experiment", "assumption_test", "test"] }
199
- },
200
- "required": ["type"],
201
- "additionalProperties": true,
202
- "examples": [
203
- {
204
- "type": "experiment",
205
- "status": "exploring",
206
- "parent": "[[Build a Side Project]]"
207
- },
208
- {
209
- "type": "test",
210
- "status": "active",
211
- "parent": "[[Mobile App Solution]]"
212
- }
213
- ]
214
- },
215
- {
216
- "type": "object",
217
- "allOf": [
218
- { "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" },
219
- { "$ref": "sctx://_sctx_base#/$defs/parentNodeProps" },
220
- { "$ref": "sctx://_sctx_base#/$defs/ostEntityProps" }
221
- ],
222
- "properties": {
223
- "type": { "const": "assumption" },
224
- "confidence": {
225
- "type": "string",
226
- "enum": ["low", "medium", "high"],
227
- "description": "Confidence level in this assumption"
228
- }
229
- },
230
- "required": ["type"],
231
- "additionalProperties": true,
232
- "examples": [
233
- {
234
- "type": "assumption",
235
- "status": "identified",
236
- "parent": "[[Some Opportunity]]",
237
- "confidence": "medium"
238
- }
239
- ]
240
- },
241
- {
242
- "type": "object",
243
- "allOf": [
244
- { "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" },
245
- { "$ref": "sctx://_sctx_base#/$defs/parentNodeProps" },
246
- { "$ref": "sctx://_sctx_base#/$defs/ostEntityProps" }
247
- ],
248
- "properties": {
249
- "type": { "const": "problem_statement" }
250
- },
251
- "required": ["type"],
252
- "additionalProperties": true,
253
- "examples": [
254
- {
255
- "type": "problem_statement",
256
- "status": "identified"
257
- }
258
- ]
259
- }
8
+ { "$ref": "sctx://_strategy_general#/$defs/dashboard" },
9
+ { "$ref": "sctx://_strategy_general#/$defs/ost_on_a_page" },
10
+ { "$ref": "sctx://_strategy_general#/$defs/vision" },
11
+ { "$ref": "sctx://_strategy_general#/$defs/mission" },
12
+ { "$ref": "sctx://_strategy_general#/$defs/goal" },
13
+ { "$ref": "sctx://_strategy_general#/$defs/opportunity" },
14
+ { "$ref": "sctx://_strategy_general#/$defs/solution" },
15
+ { "$ref": "sctx://_strategy_general#/$defs/experiment" },
16
+ { "$ref": "sctx://_strategy_general#/$defs/assumption" },
17
+ { "$ref": "sctx://_strategy_general#/$defs/problem_statement" }
260
18
  ]
261
19
  }
package/docs/schemas.md CHANGED
@@ -258,8 +258,9 @@ Metadata is composed across the `$ref` graph with deterministic behavior:
258
258
  2. Apply root schema metadata last.
259
259
 
260
260
  Merge rules:
261
- - `hierarchy`: zero or one provider allowed. Multiple providers error.
262
- - `aliases`: shallow merged; later provider wins per key.
261
+ - `hierarchy`: may be defined in partials; **last one wins**. This allows partials to define a default hierarchy that composing schemas can override.
262
+ - `aliases`: shallow merged; later file wins per key.
263
+ - `relationships`: collected from all files; order preserved.
263
264
  - `rules`: merged by `id`.
264
265
  - Duplicate rule `id` with different payload errors by default.
265
266
  - A later rule may replace an earlier one only with `"override": true`.
@@ -309,6 +310,8 @@ Imported rules are normalized into one executable flat list before validation.
309
310
  - Local partial `$id` values must not collide with bundled IDs.
310
311
  - `$ref` resolution is transitive across files.
311
312
  - Partials with no `$metadata` should prefer `$schema: "http://json-schema.org/draft-07/schema#"` so they validate standalone as plain JSON Schema fragments.
313
+ - **Bundled partials as entity libraries**: `_sctx_base.json`, `_strategy_general.json`, `_knowledge_wiki.json`, and `_ost_strict.json` provide reusable entity definitions and metadata. Composing schemas can reference these via `$ref` rather than redefining common entity types.
314
+ - **Partials can carry metadata**: Partials may include `$metadata` (hierarchy, aliases, relationships, rules). This makes them self-contained units that bundle both type definitions and behavioral metadata.
312
315
 
313
316
  ## Editor expectations
314
317
 
@@ -328,7 +331,7 @@ For schemas migrating from older metadata structure:
328
331
  3. Move `allowSkipLevels` under `hierarchy`.
329
332
  4. Convert grouped rule containers to flat `rules[]` with per-rule `category`.
330
333
  5. If duplicate rule IDs are intentional, mark later rules with `override: true`.
331
- 6. Re-run `bunx structured-context schemas show --space <name>` and `validate` to confirm merged metadata/rules.
334
+ 6. Re-run `sctx schemas show --space <name>` and `validate` to confirm merged metadata/rules.
332
335
 
333
336
  ## JSON5 support
334
337
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "structured-context",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "Tools for working with Opportunity Solution Tree structures and other product management and strategy frameworks",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",