structured-context 0.10.0 → 0.12.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 (107) hide show
  1. package/README.md +85 -25
  2. package/dist/api.d.ts +25 -5
  3. package/dist/api.js +22 -2
  4. package/dist/commands/diagram.d.ts +1 -0
  5. package/dist/commands/diagram.js +7 -1
  6. package/dist/commands/dump.d.ts +15 -2
  7. package/dist/commands/dump.js +18 -4
  8. package/dist/commands/miro-sync.d.ts +3 -0
  9. package/dist/commands/miro-sync.js +8 -0
  10. package/dist/commands/render.d.ts +4 -0
  11. package/dist/commands/render.js +64 -9
  12. package/dist/commands/schemas.d.ts +2 -2
  13. package/dist/commands/schemas.js +117 -24
  14. package/dist/commands/show.d.ts +1 -0
  15. package/dist/commands/show.js +7 -1
  16. package/dist/commands/spaces.d.ts +3 -1
  17. package/dist/commands/spaces.js +11 -4
  18. package/dist/commands/validate-file.js +20 -5
  19. package/dist/commands/validate.js +54 -21
  20. package/dist/config.d.ts +26 -13
  21. package/dist/config.js +104 -31
  22. package/dist/filter/augment-nodes.d.ts +3 -1
  23. package/dist/filter/augment-nodes.js +12 -7
  24. package/dist/filter/filter-nodes.js +1 -1
  25. package/dist/index.js +51 -35
  26. package/dist/load-space-graph.d.ts +42 -0
  27. package/dist/load-space-graph.js +53 -0
  28. package/dist/plugins/index.js +3 -1
  29. package/dist/plugins/loader.js +4 -4
  30. package/dist/plugins/markdown/extract-content-links.d.ts +23 -0
  31. package/dist/plugins/markdown/extract-content-links.js +123 -0
  32. package/dist/plugins/markdown/index.js +5 -5
  33. package/dist/plugins/markdown/parse-embedded.d.ts +6 -0
  34. package/dist/plugins/markdown/parse-embedded.js +50 -7
  35. package/dist/plugins/markdown/read-space.js +41 -5
  36. package/dist/plugins/markdown/render-directory.d.ts +11 -0
  37. package/dist/plugins/markdown/render-directory.js +130 -0
  38. package/dist/plugins/mermaid/index.d.ts +2 -0
  39. package/dist/plugins/mermaid/index.js +14 -0
  40. package/dist/plugins/{markdown → mermaid}/render-mermaid.js +17 -15
  41. package/dist/{integrations → plugins}/miro/cache.d.ts +1 -1
  42. package/dist/plugins/miro/index.d.ts +2 -0
  43. package/dist/plugins/miro/index.js +27 -0
  44. package/dist/{integrations → plugins}/miro/layout.d.ts +2 -2
  45. package/dist/{integrations → plugins}/miro/layout.js +3 -16
  46. package/dist/{integrations → plugins}/miro/styles.d.ts +2 -2
  47. package/dist/plugins/miro/sync.d.ts +7 -0
  48. package/dist/{integrations → plugins}/miro/sync.js +22 -39
  49. package/dist/plugins/util.d.ts +48 -1
  50. package/dist/plugins/util.js +143 -0
  51. package/dist/read/resolve-graph-edges.d.ts +1 -1
  52. package/dist/read/resolve-graph-edges.js +78 -27
  53. package/dist/read/wikilink-utils.d.ts +17 -0
  54. package/dist/read/wikilink-utils.js +40 -0
  55. package/dist/render/render.d.ts +4 -1
  56. package/dist/render/render.js +20 -16
  57. package/dist/schema/evaluate-rule.js +1 -0
  58. package/dist/schema/meta-schemas.d.ts +13 -0
  59. package/dist/schema/meta-schemas.js +50 -0
  60. package/dist/schema/metadata-contract.d.ts +343 -187
  61. package/dist/schema/metadata-contract.js +68 -30
  62. package/dist/schema/schema.d.ts +17 -9
  63. package/dist/schema/schema.js +283 -200
  64. package/dist/schema/validate-graph.d.ts +2 -1
  65. package/dist/schema/validate-graph.js +40 -23
  66. package/dist/schema/validate-rules.d.ts +5 -1
  67. package/dist/schema/validate-rules.js +20 -1
  68. package/dist/schemas/_knowledge_wiki.json +21 -21
  69. package/dist/schemas/_ost_strict.json +2 -2
  70. package/dist/schemas/_sctx_base.json +2 -2
  71. package/dist/schemas/_strategy_general.json +38 -38
  72. package/dist/schemas/generated/0.12.0/_structured_context_schema_meta.json +229 -0
  73. package/dist/schemas/generated/latest/_structured_context_schema_meta.json +229 -0
  74. package/dist/schemas/knowledge_wiki.json +10 -9
  75. package/dist/schemas/strategy_general.json +15 -14
  76. package/dist/schemas/strict_ost.json +17 -16
  77. package/dist/space-context.d.ts +27 -0
  78. package/dist/space-context.js +46 -0
  79. package/dist/space-graph.d.ts +9 -7
  80. package/dist/space-graph.js +7 -5
  81. package/dist/testing.d.ts +33 -0
  82. package/dist/testing.js +72 -0
  83. package/dist/types.d.ts +101 -8
  84. package/dist/validate.d.ts +15 -3
  85. package/dist/validate.js +55 -20
  86. package/docs/concepts.md +37 -4
  87. package/docs/config.md +10 -0
  88. package/docs/rules.md +49 -22
  89. package/docs/schemas.md +110 -35
  90. package/package.json +13 -8
  91. package/schemas/_knowledge_wiki.json +21 -21
  92. package/schemas/_ost_strict.json +2 -2
  93. package/schemas/_sctx_base.json +2 -2
  94. package/schemas/_strategy_general.json +38 -38
  95. package/schemas/generated/0.12.0/_structured_context_schema_meta.json +229 -0
  96. package/schemas/generated/latest/_structured_context_schema_meta.json +229 -0
  97. package/schemas/knowledge_wiki.json +10 -9
  98. package/schemas/strategy_general.json +15 -14
  99. package/schemas/strict_ost.json +17 -16
  100. package/dist/integrations/miro/sync.d.ts +0 -8
  101. package/dist/schemas/generated/_structured_context_schema_meta.json +0 -191
  102. package/schemas/generated/_structured_context_schema_meta.json +0 -191
  103. /package/dist/plugins/{markdown → mermaid}/render-mermaid.d.ts +0 -0
  104. /package/dist/{integrations → plugins}/miro/cache.js +0 -0
  105. /package/dist/{integrations → plugins}/miro/client.d.ts +0 -0
  106. /package/dist/{integrations → plugins}/miro/client.js +0 -0
  107. /package/dist/{integrations → plugins}/miro/styles.js +0 -0
@@ -0,0 +1,229 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://raw.githubusercontent.com/mindsocket/structured-context/main/schemas/generated/0.12.0/_structured_context_schema_meta.json",
4
+ "title": "structured-context schema dialect",
5
+ "description": "Extends JSON Schema 2020-12 with top-level $metadata for imports, hierarchy, relationships, aliases and rules.",
6
+ "type": "object",
7
+ "allOf": [
8
+ {
9
+ "$ref": "https://json-schema.org/draft/2020-12/schema"
10
+ }
11
+ ],
12
+ "properties": {
13
+ "$metadata": {
14
+ "type": "object",
15
+ "properties": {
16
+ "imports": {
17
+ "type": "array",
18
+ "items": {
19
+ "type": "string",
20
+ "minLength": 1
21
+ }
22
+ },
23
+ "hierarchy": {
24
+ "oneOf": [
25
+ {
26
+ "type": "object",
27
+ "properties": {
28
+ "name": {
29
+ "type": "string",
30
+ "minLength": 1
31
+ },
32
+ "override": {
33
+ "type": "boolean"
34
+ },
35
+ "levels": {
36
+ "type": "array",
37
+ "minItems": 1,
38
+ "items": {
39
+ "oneOf": [
40
+ {
41
+ "type": "string",
42
+ "minLength": 1
43
+ },
44
+ {
45
+ "type": "object",
46
+ "properties": {
47
+ "type": {
48
+ "type": "string",
49
+ "minLength": 1
50
+ },
51
+ "field": {
52
+ "type": "string",
53
+ "minLength": 1
54
+ },
55
+ "fieldOn": {
56
+ "enum": ["child", "parent"]
57
+ },
58
+ "multiple": {
59
+ "type": "boolean"
60
+ },
61
+ "templateFormat": {
62
+ "enum": ["heading", "list", "table", "page"]
63
+ },
64
+ "matchers": {
65
+ "type": "array",
66
+ "items": {
67
+ "type": "string",
68
+ "minLength": 1
69
+ },
70
+ "minItems": 1
71
+ },
72
+ "embeddedTemplateFields": {
73
+ "type": "array",
74
+ "items": {
75
+ "type": "string",
76
+ "minLength": 1
77
+ }
78
+ },
79
+ "selfRef": {
80
+ "type": "boolean"
81
+ },
82
+ "selfRefField": {
83
+ "type": "string",
84
+ "minLength": 1
85
+ }
86
+ },
87
+ "required": ["type"],
88
+ "additionalProperties": false
89
+ }
90
+ ]
91
+ }
92
+ },
93
+ "allowSkipLevels": {
94
+ "type": "boolean"
95
+ }
96
+ },
97
+ "required": ["levels"],
98
+ "additionalProperties": false
99
+ },
100
+ {
101
+ "type": "object",
102
+ "properties": {
103
+ "$ref": {
104
+ "type": "string",
105
+ "minLength": 1
106
+ }
107
+ },
108
+ "required": ["$ref"],
109
+ "additionalProperties": false
110
+ }
111
+ ]
112
+ },
113
+ "relationships": {
114
+ "type": "array",
115
+ "items": {
116
+ "type": "object",
117
+ "properties": {
118
+ "parent": {
119
+ "type": "string",
120
+ "minLength": 1
121
+ },
122
+ "type": {
123
+ "type": "string",
124
+ "minLength": 1
125
+ },
126
+ "field": {
127
+ "type": "string",
128
+ "minLength": 1
129
+ },
130
+ "fieldOn": {
131
+ "enum": ["child", "parent"]
132
+ },
133
+ "multiple": {
134
+ "type": "boolean"
135
+ },
136
+ "templateFormat": {
137
+ "enum": ["heading", "list", "table", "page"]
138
+ },
139
+ "matchers": {
140
+ "type": "array",
141
+ "items": {
142
+ "type": "string",
143
+ "minLength": 1
144
+ },
145
+ "minItems": 1
146
+ },
147
+ "embeddedTemplateFields": {
148
+ "type": "array",
149
+ "items": {
150
+ "type": "string",
151
+ "minLength": 1
152
+ }
153
+ },
154
+ "override": {
155
+ "type": "boolean"
156
+ }
157
+ },
158
+ "required": ["parent", "type"],
159
+ "additionalProperties": false
160
+ }
161
+ },
162
+ "aliases": {
163
+ "type": "object",
164
+ "additionalProperties": {
165
+ "oneOf": [
166
+ {
167
+ "type": "string",
168
+ "minLength": 1
169
+ },
170
+ {
171
+ "type": "object",
172
+ "properties": {
173
+ "type": {
174
+ "type": "string",
175
+ "minLength": 1
176
+ },
177
+ "override": {
178
+ "type": "boolean"
179
+ }
180
+ },
181
+ "required": ["type"],
182
+ "additionalProperties": false
183
+ }
184
+ ]
185
+ }
186
+ },
187
+ "rules": {
188
+ "type": "array",
189
+ "items": {
190
+ "type": "object",
191
+ "properties": {
192
+ "id": {
193
+ "type": "string",
194
+ "minLength": 1
195
+ },
196
+ "category": {
197
+ "enum": ["validation", "coherence", "workflow", "best-practice"]
198
+ },
199
+ "severity": {
200
+ "enum": ["error", "warning", "info"]
201
+ },
202
+ "description": {
203
+ "type": "string",
204
+ "minLength": 1
205
+ },
206
+ "check": {
207
+ "type": "string",
208
+ "minLength": 1
209
+ },
210
+ "type": {
211
+ "type": "string",
212
+ "minLength": 1
213
+ },
214
+ "scope": {
215
+ "enum": ["global"]
216
+ },
217
+ "override": {
218
+ "type": "boolean"
219
+ }
220
+ },
221
+ "required": ["id", "category", "description", "check"],
222
+ "additionalProperties": false
223
+ }
224
+ }
225
+ },
226
+ "additionalProperties": false
227
+ }
228
+ }
229
+ }
@@ -0,0 +1,229 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://raw.githubusercontent.com/mindsocket/structured-context/main/schemas/generated/0.12.0/_structured_context_schema_meta.json",
4
+ "title": "structured-context schema dialect",
5
+ "description": "Extends JSON Schema 2020-12 with top-level $metadata for imports, hierarchy, relationships, aliases and rules.",
6
+ "type": "object",
7
+ "allOf": [
8
+ {
9
+ "$ref": "https://json-schema.org/draft/2020-12/schema"
10
+ }
11
+ ],
12
+ "properties": {
13
+ "$metadata": {
14
+ "type": "object",
15
+ "properties": {
16
+ "imports": {
17
+ "type": "array",
18
+ "items": {
19
+ "type": "string",
20
+ "minLength": 1
21
+ }
22
+ },
23
+ "hierarchy": {
24
+ "oneOf": [
25
+ {
26
+ "type": "object",
27
+ "properties": {
28
+ "name": {
29
+ "type": "string",
30
+ "minLength": 1
31
+ },
32
+ "override": {
33
+ "type": "boolean"
34
+ },
35
+ "levels": {
36
+ "type": "array",
37
+ "minItems": 1,
38
+ "items": {
39
+ "oneOf": [
40
+ {
41
+ "type": "string",
42
+ "minLength": 1
43
+ },
44
+ {
45
+ "type": "object",
46
+ "properties": {
47
+ "type": {
48
+ "type": "string",
49
+ "minLength": 1
50
+ },
51
+ "field": {
52
+ "type": "string",
53
+ "minLength": 1
54
+ },
55
+ "fieldOn": {
56
+ "enum": ["child", "parent"]
57
+ },
58
+ "multiple": {
59
+ "type": "boolean"
60
+ },
61
+ "templateFormat": {
62
+ "enum": ["heading", "list", "table", "page"]
63
+ },
64
+ "matchers": {
65
+ "type": "array",
66
+ "items": {
67
+ "type": "string",
68
+ "minLength": 1
69
+ },
70
+ "minItems": 1
71
+ },
72
+ "embeddedTemplateFields": {
73
+ "type": "array",
74
+ "items": {
75
+ "type": "string",
76
+ "minLength": 1
77
+ }
78
+ },
79
+ "selfRef": {
80
+ "type": "boolean"
81
+ },
82
+ "selfRefField": {
83
+ "type": "string",
84
+ "minLength": 1
85
+ }
86
+ },
87
+ "required": ["type"],
88
+ "additionalProperties": false
89
+ }
90
+ ]
91
+ }
92
+ },
93
+ "allowSkipLevels": {
94
+ "type": "boolean"
95
+ }
96
+ },
97
+ "required": ["levels"],
98
+ "additionalProperties": false
99
+ },
100
+ {
101
+ "type": "object",
102
+ "properties": {
103
+ "$ref": {
104
+ "type": "string",
105
+ "minLength": 1
106
+ }
107
+ },
108
+ "required": ["$ref"],
109
+ "additionalProperties": false
110
+ }
111
+ ]
112
+ },
113
+ "relationships": {
114
+ "type": "array",
115
+ "items": {
116
+ "type": "object",
117
+ "properties": {
118
+ "parent": {
119
+ "type": "string",
120
+ "minLength": 1
121
+ },
122
+ "type": {
123
+ "type": "string",
124
+ "minLength": 1
125
+ },
126
+ "field": {
127
+ "type": "string",
128
+ "minLength": 1
129
+ },
130
+ "fieldOn": {
131
+ "enum": ["child", "parent"]
132
+ },
133
+ "multiple": {
134
+ "type": "boolean"
135
+ },
136
+ "templateFormat": {
137
+ "enum": ["heading", "list", "table", "page"]
138
+ },
139
+ "matchers": {
140
+ "type": "array",
141
+ "items": {
142
+ "type": "string",
143
+ "minLength": 1
144
+ },
145
+ "minItems": 1
146
+ },
147
+ "embeddedTemplateFields": {
148
+ "type": "array",
149
+ "items": {
150
+ "type": "string",
151
+ "minLength": 1
152
+ }
153
+ },
154
+ "override": {
155
+ "type": "boolean"
156
+ }
157
+ },
158
+ "required": ["parent", "type"],
159
+ "additionalProperties": false
160
+ }
161
+ },
162
+ "aliases": {
163
+ "type": "object",
164
+ "additionalProperties": {
165
+ "oneOf": [
166
+ {
167
+ "type": "string",
168
+ "minLength": 1
169
+ },
170
+ {
171
+ "type": "object",
172
+ "properties": {
173
+ "type": {
174
+ "type": "string",
175
+ "minLength": 1
176
+ },
177
+ "override": {
178
+ "type": "boolean"
179
+ }
180
+ },
181
+ "required": ["type"],
182
+ "additionalProperties": false
183
+ }
184
+ ]
185
+ }
186
+ },
187
+ "rules": {
188
+ "type": "array",
189
+ "items": {
190
+ "type": "object",
191
+ "properties": {
192
+ "id": {
193
+ "type": "string",
194
+ "minLength": 1
195
+ },
196
+ "category": {
197
+ "enum": ["validation", "coherence", "workflow", "best-practice"]
198
+ },
199
+ "severity": {
200
+ "enum": ["error", "warning", "info"]
201
+ },
202
+ "description": {
203
+ "type": "string",
204
+ "minLength": 1
205
+ },
206
+ "check": {
207
+ "type": "string",
208
+ "minLength": 1
209
+ },
210
+ "type": {
211
+ "type": "string",
212
+ "minLength": 1
213
+ },
214
+ "scope": {
215
+ "enum": ["global"]
216
+ },
217
+ "override": {
218
+ "type": "boolean"
219
+ }
220
+ },
221
+ "required": ["id", "category", "description", "check"],
222
+ "additionalProperties": false
223
+ }
224
+ }
225
+ },
226
+ "additionalProperties": false
227
+ }
228
+ }
229
+ }
@@ -1,15 +1,16 @@
1
1
  {
2
- "$schema": "https://raw.githubusercontent.com/mindsocket/structured-context/main/schemas/generated/_structured_context_schema_meta.json",
3
- "$id": "sctx://knowledge_wiki",
2
+ "$schema": "https://raw.githubusercontent.com/mindsocket/structured-context/main/schemas/generated/latest/_structured_context_schema_meta.json",
3
+ "$id": "sctx://core/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
- "allOf": [{ "$ref": "sctx://_knowledge_wiki" }],
6
+ "$metadata": { "imports": ["sctx://core/_knowledge_wiki"] },
7
+ "allOf": [{ "$ref": "sctx://core/_knowledge_wiki" }],
7
8
  "oneOf": [
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" }
9
+ { "$ref": "sctx://core/_knowledge_wiki#/$defs/source" },
10
+ { "$ref": "sctx://core/_knowledge_wiki#/$defs/concept" },
11
+ { "$ref": "sctx://core/_knowledge_wiki#/$defs/entity" },
12
+ { "$ref": "sctx://core/_knowledge_wiki#/$defs/synthesis" },
13
+ { "$ref": "sctx://core/_knowledge_wiki#/$defs/note" },
14
+ { "$ref": "sctx://core/_knowledge_wiki#/$defs/index" }
14
15
  ]
15
16
  }
@@ -1,19 +1,20 @@
1
1
  {
2
- "$schema": "https://raw.githubusercontent.com/mindsocket/structured-context/main/schemas/generated/_structured_context_schema_meta.json",
3
- "$id": "sctx://strategy_general",
2
+ "$schema": "https://raw.githubusercontent.com/mindsocket/structured-context/main/schemas/generated/latest/_structured_context_schema_meta.json",
3
+ "$id": "sctx://core/strategy_general",
4
4
  "title": "Strategy and opportunity ladder",
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" }],
5
+ "description": "Validates frontmatter for space node files. Composes strategy_general entities from the bundled partial. Imports the partial's hierarchy, aliases, relationships and rules.",
6
+ "$metadata": { "imports": ["sctx://core/_strategy_general"] },
7
+ "allOf": [{ "$ref": "sctx://core/_strategy_general" }],
7
8
  "oneOf": [
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" }
9
+ { "$ref": "sctx://core/_strategy_general#/$defs/dashboard" },
10
+ { "$ref": "sctx://core/_strategy_general#/$defs/ost_on_a_page" },
11
+ { "$ref": "sctx://core/_strategy_general#/$defs/vision" },
12
+ { "$ref": "sctx://core/_strategy_general#/$defs/mission" },
13
+ { "$ref": "sctx://core/_strategy_general#/$defs/goal" },
14
+ { "$ref": "sctx://core/_strategy_general#/$defs/opportunity" },
15
+ { "$ref": "sctx://core/_strategy_general#/$defs/solution" },
16
+ { "$ref": "sctx://core/_strategy_general#/$defs/experiment" },
17
+ { "$ref": "sctx://core/_strategy_general#/$defs/assumption" },
18
+ { "$ref": "sctx://core/_strategy_general#/$defs/problem_statement" }
18
19
  ]
19
20
  }
@@ -1,18 +1,19 @@
1
1
  {
2
- "$schema": "https://raw.githubusercontent.com/mindsocket/structured-context/main/schemas/generated/_structured_context_schema_meta.json",
3
- "$id": "sctx://strict_ost",
2
+ "$schema": "https://raw.githubusercontent.com/mindsocket/structured-context/main/schemas/generated/latest/_structured_context_schema_meta.json",
3
+ "$id": "sctx://core/strict_ost",
4
4
  "title": "Opportunity Solution Tree (Strict)",
5
5
  // Follows Teresa Torres' 4-level OST structure as described in "Continuous Discovery Habits" (2021)
6
6
  // and at producttalk.org.
7
7
  // Structure: outcome → opportunity → solution → assumption test
8
8
  "description": "Validates frontmatter for space node files following the canonical 4-level OST structure: outcome → opportunity → solution → assumption test",
9
+ "$metadata": { "imports": ["sctx://core/_ost_strict"] },
9
10
  "oneOf": [
10
11
  {
11
12
  "type": "object",
12
13
  "allOf": [
13
- { "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" },
14
- { "$ref": "sctx://_sctx_base#/$defs/ostEntityProps" },
15
- { "$ref": "sctx://_ost_strict#/$defs/outcomeProps" }
14
+ { "$ref": "sctx://core/_sctx_base#/$defs/baseNodeProps" },
15
+ { "$ref": "sctx://core/_sctx_base#/$defs/ostEntityProps" },
16
+ { "$ref": "sctx://core/_ost_strict#/$defs/outcomeProps" }
16
17
  ],
17
18
  "properties": {
18
19
  "type": { "const": "outcome" }
@@ -31,10 +32,10 @@
31
32
  {
32
33
  "type": "object",
33
34
  "allOf": [
34
- { "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" },
35
- { "$ref": "sctx://_sctx_base#/$defs/parentNodeProps" },
36
- { "$ref": "sctx://_sctx_base#/$defs/ostEntityProps" },
37
- { "$ref": "sctx://_ost_strict#/$defs/opportunityProps" }
35
+ { "$ref": "sctx://core/_sctx_base#/$defs/baseNodeProps" },
36
+ { "$ref": "sctx://core/_sctx_base#/$defs/parentNodeProps" },
37
+ { "$ref": "sctx://core/_sctx_base#/$defs/ostEntityProps" },
38
+ { "$ref": "sctx://core/_ost_strict#/$defs/opportunityProps" }
38
39
  ],
39
40
  "properties": {
40
41
  "type": { "const": "opportunity" }
@@ -53,9 +54,9 @@
53
54
  {
54
55
  "type": "object",
55
56
  "allOf": [
56
- { "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" },
57
- { "$ref": "sctx://_sctx_base#/$defs/parentNodeProps" },
58
- { "$ref": "sctx://_sctx_base#/$defs/ostEntityProps" }
57
+ { "$ref": "sctx://core/_sctx_base#/$defs/baseNodeProps" },
58
+ { "$ref": "sctx://core/_sctx_base#/$defs/parentNodeProps" },
59
+ { "$ref": "sctx://core/_sctx_base#/$defs/ostEntityProps" }
59
60
  ],
60
61
  "properties": {
61
62
  "type": { "const": "solution" }
@@ -73,10 +74,10 @@
73
74
  {
74
75
  "type": "object",
75
76
  "allOf": [
76
- { "$ref": "sctx://_sctx_base#/$defs/baseNodeProps" },
77
- { "$ref": "sctx://_sctx_base#/$defs/parentNodeProps" },
78
- { "$ref": "sctx://_sctx_base#/$defs/ostEntityProps" },
79
- { "$ref": "sctx://_ost_strict#/$defs/assumptionTestProps" }
77
+ { "$ref": "sctx://core/_sctx_base#/$defs/baseNodeProps" },
78
+ { "$ref": "sctx://core/_sctx_base#/$defs/parentNodeProps" },
79
+ { "$ref": "sctx://core/_sctx_base#/$defs/ostEntityProps" },
80
+ { "$ref": "sctx://core/_ost_strict#/$defs/assumptionTestProps" }
80
81
  ],
81
82
  "properties": {
82
83
  "type": { "const": "assumption_test" }
@@ -0,0 +1,27 @@
1
+ import { type Config } from './config';
2
+ import type { SpaceContext } from './types';
3
+ /** Thrown by createSpaceContext when no space matches the given name. */
4
+ export declare class SpaceNotFoundError extends Error {
5
+ readonly spaceName: string;
6
+ constructor(spaceName: string);
7
+ }
8
+ export interface CreateSpaceContextOptions {
9
+ /**
10
+ * Directory to anchor relative plugin-config paths against. Defaults to the source
11
+ * directory recorded by loadConfig (space.sourceDir). Required for a hand-assembled
12
+ * Config, which has no source file — pass e.g. process.cwd(), or the directory the
13
+ * paths are relative to.
14
+ */
15
+ configDir?: string;
16
+ }
17
+ /**
18
+ * Build a SpaceContext for a named space from an already-loaded config.
19
+ *
20
+ * Synchronously resolves schemas (including plugin-contributed schemas),
21
+ * indexes partials into the registry, and compiles the schema validator.
22
+ *
23
+ * Library-safe: throws {@link SpaceNotFoundError} on an unknown space rather than
24
+ * writing to the console or exiting the process. CLI callers that want the
25
+ * exit-on-error behaviour should wrap this (see buildSpaceContext in index.ts).
26
+ */
27
+ export declare function createSpaceContext(spaceName: string, config: Config, options?: CreateSpaceContextOptions): SpaceContext;
@@ -0,0 +1,46 @@
1
+ import { resolveSchema } from './config';
2
+ import { resolveSpacePluginSchemas } from './plugins/util';
3
+ import { loadSchema } from './schema/schema';
4
+ /** Thrown by createSpaceContext when no space matches the given name. */
5
+ export class SpaceNotFoundError extends Error {
6
+ spaceName;
7
+ constructor(spaceName) {
8
+ super(`Unknown space "${spaceName}"`);
9
+ this.spaceName = spaceName;
10
+ this.name = 'SpaceNotFoundError';
11
+ }
12
+ }
13
+ /**
14
+ * Build a SpaceContext for a named space from an already-loaded config.
15
+ *
16
+ * Synchronously resolves schemas (including plugin-contributed schemas),
17
+ * indexes partials into the registry, and compiles the schema validator.
18
+ *
19
+ * Library-safe: throws {@link SpaceNotFoundError} on an unknown space rather than
20
+ * writing to the console or exiting the process. CLI callers that want the
21
+ * exit-on-error behaviour should wrap this (see buildSpaceContext in index.ts).
22
+ */
23
+ export function createSpaceContext(spaceName, config, options = {}) {
24
+ const space = config.spaces.find((s) => s.name === spaceName);
25
+ if (!space) {
26
+ throw new SpaceNotFoundError(spaceName);
27
+ }
28
+ const configDir = options.configDir ?? space.sourceDir;
29
+ if (configDir === undefined) {
30
+ throw new Error(`Cannot resolve a config directory for space "${spaceName}": its Config was not loaded from a ` +
31
+ `file. Pass options.configDir (e.g. process.cwd()) to anchor relative plugin paths, or load ` +
32
+ `the config with loadConfig().`);
33
+ }
34
+ const resolvedSchemaPath = resolveSchema(config, space, { configDir });
35
+ const pluginSchemas = resolveSpacePluginSchemas(space, config, configDir);
36
+ const { schema, schemaRefRegistry, schemaValidator } = loadSchema(resolvedSchemaPath, pluginSchemas);
37
+ return {
38
+ space,
39
+ config,
40
+ resolvedSchemaPath,
41
+ schema,
42
+ schemaRefRegistry,
43
+ schemaValidator,
44
+ configDir,
45
+ };
46
+ }