structured-context 0.9.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 (112) hide show
  1. package/README.md +348 -0
  2. package/dist/commands/diagram.d.ts +5 -0
  3. package/dist/commands/diagram.js +12 -0
  4. package/dist/commands/docs.d.ts +1 -0
  5. package/dist/commands/docs.js +67 -0
  6. package/dist/commands/dump.d.ts +2 -0
  7. package/dist/commands/dump.js +6 -0
  8. package/dist/commands/plugins.d.ts +1 -0
  9. package/dist/commands/plugins.js +23 -0
  10. package/dist/commands/render.d.ts +6 -0
  11. package/dist/commands/render.js +35 -0
  12. package/dist/commands/schemas.d.ts +6 -0
  13. package/dist/commands/schemas.js +268 -0
  14. package/dist/commands/show.d.ts +4 -0
  15. package/dist/commands/show.js +7 -0
  16. package/dist/commands/spaces.d.ts +1 -0
  17. package/dist/commands/spaces.js +36 -0
  18. package/dist/commands/template-sync.d.ts +3 -0
  19. package/dist/commands/template-sync.js +13 -0
  20. package/dist/commands/validate-file.d.ts +28 -0
  21. package/dist/commands/validate-file.js +133 -0
  22. package/dist/commands/validate.d.ts +16 -0
  23. package/dist/commands/validate.js +349 -0
  24. package/dist/config.d.ts +38 -0
  25. package/dist/config.js +179 -0
  26. package/dist/constants.d.ts +6 -0
  27. package/dist/constants.js +6 -0
  28. package/dist/filter/augment-nodes.d.ts +23 -0
  29. package/dist/filter/augment-nodes.js +95 -0
  30. package/dist/filter/expand-include.d.ts +62 -0
  31. package/dist/filter/expand-include.js +181 -0
  32. package/dist/filter/filter-nodes.d.ts +21 -0
  33. package/dist/filter/filter-nodes.js +73 -0
  34. package/dist/filter/parse-expression.d.ts +20 -0
  35. package/dist/filter/parse-expression.js +60 -0
  36. package/dist/index.d.ts +3 -0
  37. package/dist/index.js +161 -0
  38. package/dist/integrations/miro/cache.d.ts +21 -0
  39. package/dist/integrations/miro/cache.js +55 -0
  40. package/dist/integrations/miro/client.d.ts +99 -0
  41. package/dist/integrations/miro/client.js +118 -0
  42. package/dist/integrations/miro/layout.d.ts +28 -0
  43. package/dist/integrations/miro/layout.js +72 -0
  44. package/dist/integrations/miro/styles.d.ts +11 -0
  45. package/dist/integrations/miro/styles.js +65 -0
  46. package/dist/integrations/miro/sync.d.ts +8 -0
  47. package/dist/integrations/miro/sync.js +347 -0
  48. package/dist/plugin-api.d.ts +12 -0
  49. package/dist/plugin-api.js +7 -0
  50. package/dist/plugins/index.d.ts +3 -0
  51. package/dist/plugins/index.js +3 -0
  52. package/dist/plugins/loader.d.ts +21 -0
  53. package/dist/plugins/loader.js +104 -0
  54. package/dist/plugins/markdown/index.d.ts +48 -0
  55. package/dist/plugins/markdown/index.js +51 -0
  56. package/dist/plugins/markdown/parse-embedded.d.ts +90 -0
  57. package/dist/plugins/markdown/parse-embedded.js +663 -0
  58. package/dist/plugins/markdown/read-space.d.ts +7 -0
  59. package/dist/plugins/markdown/read-space.js +89 -0
  60. package/dist/plugins/markdown/render-bullets.d.ts +2 -0
  61. package/dist/plugins/markdown/render-bullets.js +42 -0
  62. package/dist/plugins/markdown/render-mermaid.d.ts +2 -0
  63. package/dist/plugins/markdown/render-mermaid.js +57 -0
  64. package/dist/plugins/markdown/template-sync.d.ts +16 -0
  65. package/dist/plugins/markdown/template-sync.js +294 -0
  66. package/dist/plugins/markdown/util.d.ts +19 -0
  67. package/dist/plugins/markdown/util.js +80 -0
  68. package/dist/plugins/util.d.ts +60 -0
  69. package/dist/plugins/util.js +7 -0
  70. package/dist/read/read-space.d.ts +2 -0
  71. package/dist/read/read-space.js +22 -0
  72. package/dist/read/resolve-graph-edges.d.ts +11 -0
  73. package/dist/read/resolve-graph-edges.js +201 -0
  74. package/dist/read/wikilink-utils.d.ts +16 -0
  75. package/dist/read/wikilink-utils.js +38 -0
  76. package/dist/render/registry.d.ts +13 -0
  77. package/dist/render/registry.js +22 -0
  78. package/dist/render/render.d.ts +4 -0
  79. package/dist/render/render.js +28 -0
  80. package/dist/schema/evaluate-rule.d.ts +30 -0
  81. package/dist/schema/evaluate-rule.js +82 -0
  82. package/dist/schema/metadata-contract.d.ts +538 -0
  83. package/dist/schema/metadata-contract.js +115 -0
  84. package/dist/schema/schema-refs.d.ts +22 -0
  85. package/dist/schema/schema-refs.js +168 -0
  86. package/dist/schema/schema.d.ts +27 -0
  87. package/dist/schema/schema.js +378 -0
  88. package/dist/schema/validate-graph.d.ts +24 -0
  89. package/dist/schema/validate-graph.js +141 -0
  90. package/dist/schema/validate-rules.d.ts +10 -0
  91. package/dist/schema/validate-rules.js +51 -0
  92. package/dist/schemas/_ost_strict.json +81 -0
  93. package/dist/schemas/_sctx_base.json +72 -0
  94. package/dist/schemas/general.json +261 -0
  95. package/dist/schemas/generated/_structured_context_schema_meta.json +191 -0
  96. package/dist/schemas/knowledge_wiki.json +206 -0
  97. package/dist/schemas/strict_ost.json +97 -0
  98. package/dist/space-graph.d.ts +28 -0
  99. package/dist/space-graph.js +82 -0
  100. package/dist/types.d.ts +145 -0
  101. package/dist/types.js +0 -0
  102. package/docs/concepts.md +391 -0
  103. package/docs/config.md +140 -0
  104. package/docs/rules.md +120 -0
  105. package/docs/schemas.md +340 -0
  106. package/package.json +69 -0
  107. package/schemas/_ost_strict.json +81 -0
  108. package/schemas/_sctx_base.json +72 -0
  109. package/schemas/general.json +261 -0
  110. package/schemas/generated/_structured_context_schema_meta.json +191 -0
  111. package/schemas/knowledge_wiki.json +206 -0
  112. package/schemas/strict_ost.json +97 -0
@@ -0,0 +1,90 @@
1
+ import type { BaseNode, Relationship, SchemaMetadata } from '../../plugin-api';
2
+ /** Type values that identify a space_on_a_page container (not themselves space nodes). */
3
+ export declare const ON_A_PAGE_TYPES: string[];
4
+ type StackEntry = {
5
+ depth: number;
6
+ title: string;
7
+ /** Empty string marks an untyped heading placeholder (typed-page mode, i.e. not space_on_a_page). */
8
+ nodeType: string;
9
+ /** Preferred wikilink key used when this heading acts as a parent. */
10
+ refTarget: string;
11
+ };
12
+ /** Detect a bare wikilink `[[...]]` and return the inner target, or undefined. */
13
+ export declare function isWikilink(text: string): string | undefined;
14
+ /** Extract [key:: value] bracketed inline fields, return cleaned text and fields. */
15
+ export declare function extractBracketedFields(text: string): {
16
+ cleanText: string;
17
+ fields: Record<string, string>;
18
+ };
19
+ /**
20
+ * Extract unbracketed dataview fields (key:: value on own line).
21
+ * Keys must be identifier-style (letters, digits, hyphens, underscores - no spaces).
22
+ * Lines matching the pattern are consumed as fields; other lines kept as content.
23
+ */
24
+ export declare function extractUnbracketedFields(text: string): {
25
+ remainingText: string;
26
+ fields: Record<string, string>;
27
+ };
28
+ /**
29
+ * Extract a trailing Obsidian block anchor from heading text.
30
+ * e.g. "My Title ^anchor-id" -> { cleanText: "My Title", anchor: "anchor-id" }
31
+ */
32
+ export declare function extractAnchor(text: string): {
33
+ cleanText: string;
34
+ anchor?: string;
35
+ };
36
+ /**
37
+ * If the anchor name exactly matches a space node type (optionally followed by digits),
38
+ * return that type. Otherwise return undefined.
39
+ * Examples: "mission" -> "mission", "goal1" -> "goal", "myanchor" -> undefined
40
+ *
41
+ * Also checks relationship types (for parent-side relationships where child type may not be in hierarchy).
42
+ */
43
+ export declare function anchorToNodeType(anchor: string, hierarchy: readonly string[], relationships?: Relationship[]): string | undefined;
44
+ /**
45
+ * Turn a full heading string into an Obsidian section-target key component.
46
+ * - normalizes observed Obsidian separators (#, ^, :, \) to spaces
47
+ * - compresses whitespace runs to single spaces
48
+ * - does _NOT_ (and should not) manipulate anchors or inline fields
49
+ */
50
+ export declare function normalizeHeadingSectionTarget(rawHeadingText: string): string;
51
+ /**
52
+ * Returns the default space node type for a new heading based on its parent's effective type.
53
+ * The first heading in a document defaults to the first type in the hierarchy; each child is the next in sequence.
54
+ */
55
+ export declare function defaultNodeType(stack: StackEntry[], hierarchy: readonly string[]): string;
56
+ export interface ExtractEmbeddedOptions {
57
+ /**
58
+ * Title of the containing page. If provided (and pageType is not a space_on_a_page type),
59
+ * the page acts as a virtual depth-0 parent for first-level embedded headings.
60
+ */
61
+ pageTitle?: string;
62
+ /**
63
+ * Node type of the containing page.
64
+ * - If set to a real node type: only headings with an explicit `[type:: x]` field or a
65
+ * type-named anchor become nodes (typed-page mode).
66
+ * - If an on-a-page type (`space_on_a_page` / `ost_on_a_page`) or undefined: all headings
67
+ * become nodes with depth-based type inference ("space on a page" behaviour).
68
+ */
69
+ pageType?: string;
70
+ metadata: SchemaMetadata;
71
+ /**
72
+ * Field name remapping (file field name → canonical field name).
73
+ * Applied to all extracted inline fields, YAML blocks, and paragraph fields.
74
+ * Example: { "record_type": "type" } renames `record_type` to `type` in extracted data.
75
+ */
76
+ fieldMap?: Record<string, string>;
77
+ }
78
+ export interface ExtractEmbeddedResult {
79
+ nodes: BaseNode[];
80
+ preambleNodeCount: number;
81
+ terminatedHeadings: string[];
82
+ }
83
+ /**
84
+ * Extract space nodes from markdown body text.
85
+ *
86
+ * Used by both readSpaceOnAPage (single space_on_a_page file) and readSpaceDirectory
87
+ * (directory) to find embedded sub-nodes within a page's content.
88
+ */
89
+ export declare function extractEmbeddedNodes(body: string, options: ExtractEmbeddedOptions): ExtractEmbeddedResult;
90
+ export {};