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.
- package/README.md +85 -25
- package/dist/api.d.ts +25 -5
- package/dist/api.js +22 -2
- package/dist/commands/diagram.d.ts +1 -0
- package/dist/commands/diagram.js +7 -1
- package/dist/commands/dump.d.ts +15 -2
- package/dist/commands/dump.js +18 -4
- package/dist/commands/miro-sync.d.ts +3 -0
- package/dist/commands/miro-sync.js +8 -0
- package/dist/commands/render.d.ts +4 -0
- package/dist/commands/render.js +64 -9
- package/dist/commands/schemas.d.ts +2 -2
- package/dist/commands/schemas.js +117 -24
- package/dist/commands/show.d.ts +1 -0
- package/dist/commands/show.js +7 -1
- package/dist/commands/spaces.d.ts +3 -1
- package/dist/commands/spaces.js +11 -4
- package/dist/commands/validate-file.js +20 -5
- package/dist/commands/validate.js +54 -21
- package/dist/config.d.ts +26 -13
- package/dist/config.js +104 -31
- package/dist/filter/augment-nodes.d.ts +3 -1
- package/dist/filter/augment-nodes.js +12 -7
- package/dist/filter/filter-nodes.js +1 -1
- package/dist/index.js +51 -35
- package/dist/load-space-graph.d.ts +42 -0
- package/dist/load-space-graph.js +53 -0
- package/dist/plugins/index.js +3 -1
- package/dist/plugins/loader.js +4 -4
- package/dist/plugins/markdown/extract-content-links.d.ts +23 -0
- package/dist/plugins/markdown/extract-content-links.js +123 -0
- package/dist/plugins/markdown/index.js +5 -5
- package/dist/plugins/markdown/parse-embedded.d.ts +6 -0
- package/dist/plugins/markdown/parse-embedded.js +50 -7
- package/dist/plugins/markdown/read-space.js +41 -5
- package/dist/plugins/markdown/render-directory.d.ts +11 -0
- package/dist/plugins/markdown/render-directory.js +130 -0
- package/dist/plugins/mermaid/index.d.ts +2 -0
- package/dist/plugins/mermaid/index.js +14 -0
- package/dist/plugins/{markdown → mermaid}/render-mermaid.js +17 -15
- package/dist/{integrations → plugins}/miro/cache.d.ts +1 -1
- package/dist/plugins/miro/index.d.ts +2 -0
- package/dist/plugins/miro/index.js +27 -0
- package/dist/{integrations → plugins}/miro/layout.d.ts +2 -2
- package/dist/{integrations → plugins}/miro/layout.js +3 -16
- package/dist/{integrations → plugins}/miro/styles.d.ts +2 -2
- package/dist/plugins/miro/sync.d.ts +7 -0
- package/dist/{integrations → plugins}/miro/sync.js +22 -39
- package/dist/plugins/util.d.ts +48 -1
- package/dist/plugins/util.js +143 -0
- package/dist/read/resolve-graph-edges.d.ts +1 -1
- package/dist/read/resolve-graph-edges.js +78 -27
- package/dist/read/wikilink-utils.d.ts +17 -0
- package/dist/read/wikilink-utils.js +40 -0
- package/dist/render/render.d.ts +4 -1
- package/dist/render/render.js +20 -16
- package/dist/schema/evaluate-rule.js +1 -0
- package/dist/schema/meta-schemas.d.ts +13 -0
- package/dist/schema/meta-schemas.js +50 -0
- package/dist/schema/metadata-contract.d.ts +343 -187
- package/dist/schema/metadata-contract.js +68 -30
- package/dist/schema/schema.d.ts +17 -9
- package/dist/schema/schema.js +283 -200
- package/dist/schema/validate-graph.d.ts +2 -1
- package/dist/schema/validate-graph.js +40 -23
- package/dist/schema/validate-rules.d.ts +5 -1
- package/dist/schema/validate-rules.js +20 -1
- package/dist/schemas/_knowledge_wiki.json +21 -21
- package/dist/schemas/_ost_strict.json +2 -2
- package/dist/schemas/_sctx_base.json +2 -2
- package/dist/schemas/_strategy_general.json +38 -38
- package/dist/schemas/generated/0.12.0/_structured_context_schema_meta.json +229 -0
- package/dist/schemas/generated/latest/_structured_context_schema_meta.json +229 -0
- package/dist/schemas/knowledge_wiki.json +10 -9
- package/dist/schemas/strategy_general.json +15 -14
- package/dist/schemas/strict_ost.json +17 -16
- package/dist/space-context.d.ts +27 -0
- package/dist/space-context.js +46 -0
- package/dist/space-graph.d.ts +9 -7
- package/dist/space-graph.js +7 -5
- package/dist/testing.d.ts +33 -0
- package/dist/testing.js +72 -0
- package/dist/types.d.ts +101 -8
- package/dist/validate.d.ts +15 -3
- package/dist/validate.js +55 -20
- package/docs/concepts.md +37 -4
- package/docs/config.md +10 -0
- package/docs/rules.md +49 -22
- package/docs/schemas.md +110 -35
- package/package.json +13 -8
- package/schemas/_knowledge_wiki.json +21 -21
- package/schemas/_ost_strict.json +2 -2
- package/schemas/_sctx_base.json +2 -2
- package/schemas/_strategy_general.json +38 -38
- package/schemas/generated/0.12.0/_structured_context_schema_meta.json +229 -0
- package/schemas/generated/latest/_structured_context_schema_meta.json +229 -0
- package/schemas/knowledge_wiki.json +10 -9
- package/schemas/strategy_general.json +15 -14
- package/schemas/strict_ost.json +17 -16
- package/dist/integrations/miro/sync.d.ts +0 -8
- package/dist/schemas/generated/_structured_context_schema_meta.json +0 -191
- package/schemas/generated/_structured_context_schema_meta.json +0 -191
- /package/dist/plugins/{markdown → mermaid}/render-mermaid.d.ts +0 -0
- /package/dist/{integrations → plugins}/miro/cache.js +0 -0
- /package/dist/{integrations → plugins}/miro/client.d.ts +0 -0
- /package/dist/{integrations → plugins}/miro/client.js +0 -0
- /package/dist/{integrations → plugins}/miro/styles.js +0 -0
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/** The JSON Schema dialect the structured-context dialect extends. */
|
|
2
|
+
export const JSON_SCHEMA_DIALECT = 'https://json-schema.org/draft/2020-12/schema';
|
|
3
|
+
export const SCHEMA_META_BASE_URL = 'https://raw.githubusercontent.com/mindsocket/structured-context/main/schemas/generated';
|
|
4
|
+
export const SCHEMA_META_FILE = '_structured_context_schema_meta.json';
|
|
5
|
+
/** Meta-schema `$id` for a dialect version folder, e.g. `.../generated/0.12.0/_structured_context_schema_meta.json`. */
|
|
6
|
+
export function schemaMetaId(folder) {
|
|
7
|
+
return `${SCHEMA_META_BASE_URL}/${folder}/${SCHEMA_META_FILE}`;
|
|
8
|
+
}
|
|
9
|
+
/** The URL schemas set as `$schema` to follow the newest dialect. Resolves to the newest versioned meta-schema. */
|
|
10
|
+
export const SCHEMA_META_ID = schemaMetaId('latest');
|
|
2
11
|
/** Graph edge routing fields shared by hierarchy levels and relationships. */
|
|
3
12
|
const EDGE_PROPS = {
|
|
4
13
|
field: { type: 'string', minLength: 1 },
|
|
@@ -39,6 +48,7 @@ const RULE_SCHEMA = {
|
|
|
39
48
|
properties: {
|
|
40
49
|
id: { type: 'string', minLength: 1 },
|
|
41
50
|
category: { enum: ['validation', 'coherence', 'workflow', 'best-practice'] },
|
|
51
|
+
severity: { enum: ['error', 'warning', 'info'] },
|
|
42
52
|
description: { type: 'string', minLength: 1 },
|
|
43
53
|
check: { type: 'string', minLength: 1 },
|
|
44
54
|
type: { type: 'string', minLength: 1 },
|
|
@@ -48,7 +58,7 @@ const RULE_SCHEMA = {
|
|
|
48
58
|
required: ['id', 'category', 'description', 'check'],
|
|
49
59
|
additionalProperties: false,
|
|
50
60
|
};
|
|
51
|
-
const
|
|
61
|
+
const REF_SCHEMA = {
|
|
52
62
|
type: 'object',
|
|
53
63
|
properties: {
|
|
54
64
|
$ref: { type: 'string', minLength: 1 },
|
|
@@ -56,6 +66,23 @@ const RULE_REF_SCHEMA = {
|
|
|
56
66
|
required: ['$ref'],
|
|
57
67
|
additionalProperties: false,
|
|
58
68
|
};
|
|
69
|
+
const HIERARCHY_SCHEMA = {
|
|
70
|
+
type: 'object',
|
|
71
|
+
properties: {
|
|
72
|
+
name: { type: 'string', minLength: 1 },
|
|
73
|
+
override: { type: 'boolean' },
|
|
74
|
+
levels: {
|
|
75
|
+
type: 'array',
|
|
76
|
+
minItems: 1,
|
|
77
|
+
items: {
|
|
78
|
+
oneOf: [{ type: 'string', minLength: 1 }, HIERARCHY_LEVEL_SCHEMA],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
allowSkipLevels: { type: 'boolean' },
|
|
82
|
+
},
|
|
83
|
+
required: ['levels'],
|
|
84
|
+
additionalProperties: false,
|
|
85
|
+
};
|
|
59
86
|
const RELATIONSHIP_SCHEMA = {
|
|
60
87
|
type: 'object',
|
|
61
88
|
properties: {
|
|
@@ -63,53 +90,64 @@ const RELATIONSHIP_SCHEMA = {
|
|
|
63
90
|
type: { type: 'string', minLength: 1 },
|
|
64
91
|
...EDGE_PROPS,
|
|
65
92
|
...EMBEDDING_PROPS,
|
|
93
|
+
override: { type: 'boolean' },
|
|
66
94
|
},
|
|
67
95
|
required: ['parent', 'type'],
|
|
68
96
|
additionalProperties: false,
|
|
69
97
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
98
|
+
/** An alias target: a type name, or `{ type, override: true }` to replace an imported alias. */
|
|
99
|
+
const ALIAS_SCHEMA = {
|
|
100
|
+
oneOf: [
|
|
101
|
+
{ type: 'string', minLength: 1 },
|
|
102
|
+
{
|
|
74
103
|
type: 'object',
|
|
75
104
|
properties: {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
minItems: 1,
|
|
79
|
-
items: {
|
|
80
|
-
oneOf: [{ type: 'string', minLength: 1 }, HIERARCHY_LEVEL_SCHEMA],
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
allowSkipLevels: { type: 'boolean' },
|
|
105
|
+
type: { type: 'string', minLength: 1 },
|
|
106
|
+
override: { type: 'boolean' },
|
|
84
107
|
},
|
|
85
|
-
required: ['
|
|
108
|
+
required: ['type'],
|
|
86
109
|
additionalProperties: false,
|
|
87
110
|
},
|
|
111
|
+
],
|
|
112
|
+
};
|
|
113
|
+
export const METADATA_SCHEMA = {
|
|
114
|
+
type: 'object',
|
|
115
|
+
properties: {
|
|
116
|
+
// $ids of schemas whose metadata (and their imports' metadata) is merged into this schema's.
|
|
117
|
+
imports: {
|
|
118
|
+
type: 'array',
|
|
119
|
+
items: { type: 'string', minLength: 1 },
|
|
120
|
+
},
|
|
121
|
+
// Either declares this schema's hierarchy, or (root schema only) selects an imported one via $ref.
|
|
122
|
+
hierarchy: {
|
|
123
|
+
oneOf: [HIERARCHY_SCHEMA, REF_SCHEMA],
|
|
124
|
+
},
|
|
88
125
|
relationships: {
|
|
89
126
|
type: 'array',
|
|
90
127
|
items: RELATIONSHIP_SCHEMA,
|
|
91
128
|
},
|
|
92
129
|
aliases: {
|
|
93
130
|
type: 'object',
|
|
94
|
-
additionalProperties:
|
|
131
|
+
additionalProperties: ALIAS_SCHEMA,
|
|
95
132
|
},
|
|
96
133
|
rules: {
|
|
97
134
|
type: 'array',
|
|
98
|
-
items:
|
|
99
|
-
oneOf: [RULE_SCHEMA, RULE_REF_SCHEMA],
|
|
100
|
-
},
|
|
135
|
+
items: RULE_SCHEMA,
|
|
101
136
|
},
|
|
102
137
|
},
|
|
103
138
|
additionalProperties: false,
|
|
104
139
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
$
|
|
114
|
-
|
|
115
|
-
|
|
140
|
+
/** The dialect meta-schema, published under `$id`. */
|
|
141
|
+
export function buildDialectMetaSchema(id) {
|
|
142
|
+
return {
|
|
143
|
+
$schema: JSON_SCHEMA_DIALECT,
|
|
144
|
+
$id: id,
|
|
145
|
+
title: 'structured-context schema dialect',
|
|
146
|
+
description: 'Extends JSON Schema 2020-12 with top-level $metadata for imports, hierarchy, relationships, aliases and rules.',
|
|
147
|
+
type: 'object',
|
|
148
|
+
allOf: [{ $ref: JSON_SCHEMA_DIALECT }],
|
|
149
|
+
properties: {
|
|
150
|
+
$metadata: METADATA_SCHEMA,
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
package/dist/schema/schema.d.ts
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AnySchemaObject, ValidateFunction } from 'ajv';
|
|
2
2
|
import type { SchemaMetadata, SchemaWithMetadata } from '../types';
|
|
3
|
-
export declare
|
|
3
|
+
export declare let bundledSchemasDir: string;
|
|
4
|
+
/** Override the bundled schemas directory (e.g. when running in a bundled context). */
|
|
5
|
+
export declare function setBundledSchemasDir(dir: string): void;
|
|
4
6
|
export declare function readRawSchema(schemaPath: string): AnySchemaObject;
|
|
7
|
+
export declare const CORE_SCHEMA_PREFIX = "sctx://core/";
|
|
8
|
+
export type PluginSchemaSource = {
|
|
9
|
+
pluginName: string;
|
|
10
|
+
schemasDir: string;
|
|
11
|
+
};
|
|
5
12
|
/**
|
|
6
|
-
* Build the full
|
|
13
|
+
* Build the full multi-layer registry for a schema path:
|
|
7
14
|
* - Layer 1: bundled schemas/ dir (partials only, as fallback)
|
|
8
|
-
* - Layer 2: schema
|
|
9
|
-
*
|
|
15
|
+
* - Layer 2: plugin schema dirs (partials + target file if schemaPath is in this plugin's schemasDir)
|
|
16
|
+
* - Layer 3: schema's own dir (partials + target file)
|
|
17
|
+
* Throws if a lower-precedence schema collides with a reserved $id or violates namespace rules.
|
|
10
18
|
*/
|
|
11
|
-
export declare function buildFullRegistry(schemaPath: string): Map<string, AnySchemaObject>;
|
|
12
|
-
export declare function createValidator(schemaPath: string): ValidateFunction;
|
|
19
|
+
export declare function buildFullRegistry(schemaPath: string, pluginSchemas?: PluginSchemaSource[]): Map<string, AnySchemaObject>;
|
|
20
|
+
export declare function createValidator(schemaPath: string, pluginSchemas?: PluginSchemaSource[]): ValidateFunction;
|
|
13
21
|
export declare function resolveNodeType(type: string, typeAliases: Record<string, string> | undefined): string;
|
|
14
22
|
export interface EntityInfo {
|
|
15
23
|
type: string;
|
|
@@ -18,10 +26,10 @@ export interface EntityInfo {
|
|
|
18
26
|
}
|
|
19
27
|
export declare function extractEntityInfo(schema: SchemaWithMetadata, schemaRefRegistry: Map<string, AnySchemaObject>): EntityInfo[];
|
|
20
28
|
export declare function extractSchemaTypeNames(schema: SchemaWithMetadata, schemaRefRegistry: Map<string, AnySchemaObject>): Set<string>;
|
|
21
|
-
export declare function loadMetadata(schemaPath: string): SchemaMetadata;
|
|
29
|
+
export declare function loadMetadata(schemaPath: string, pluginSchemas?: PluginSchemaSource[]): SchemaMetadata;
|
|
22
30
|
export interface LoadedSchema {
|
|
23
31
|
schema: SchemaWithMetadata;
|
|
24
32
|
schemaRefRegistry: Map<string, AnySchemaObject>;
|
|
25
33
|
schemaValidator: ValidateFunction;
|
|
26
34
|
}
|
|
27
|
-
export declare function loadSchema(schemaPath: string): LoadedSchema;
|
|
35
|
+
export declare function loadSchema(schemaPath: string, pluginSchemas?: PluginSchemaSource[]): LoadedSchema;
|