@aigne/afs 1.11.0-beta → 1.11.0-beta.10

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 (164) hide show
  1. package/LICENSE.md +17 -84
  2. package/README.md +4 -13
  3. package/dist/_virtual/rolldown_runtime.mjs +7 -0
  4. package/dist/afs.cjs +1330 -0
  5. package/dist/afs.d.cts +275 -0
  6. package/dist/afs.d.cts.map +1 -0
  7. package/dist/afs.d.mts +275 -0
  8. package/dist/afs.d.mts.map +1 -0
  9. package/dist/afs.mjs +1331 -0
  10. package/dist/afs.mjs.map +1 -0
  11. package/dist/capabilities/index.d.mts +2 -0
  12. package/dist/capabilities/types.d.cts +100 -0
  13. package/dist/capabilities/types.d.cts.map +1 -0
  14. package/dist/capabilities/types.d.mts +100 -0
  15. package/dist/capabilities/types.d.mts.map +1 -0
  16. package/dist/capabilities/world-mapping.cjs +20 -0
  17. package/dist/capabilities/world-mapping.d.cts +139 -0
  18. package/dist/capabilities/world-mapping.d.cts.map +1 -0
  19. package/dist/capabilities/world-mapping.d.mts +139 -0
  20. package/dist/capabilities/world-mapping.d.mts.map +1 -0
  21. package/dist/capabilities/world-mapping.mjs +20 -0
  22. package/dist/capabilities/world-mapping.mjs.map +1 -0
  23. package/dist/error.cjs +63 -0
  24. package/dist/error.d.cts +39 -0
  25. package/dist/error.d.cts.map +1 -0
  26. package/dist/error.d.mts +39 -0
  27. package/dist/error.d.mts.map +1 -0
  28. package/dist/error.mjs +59 -0
  29. package/dist/error.mjs.map +1 -0
  30. package/dist/index.cjs +72 -345
  31. package/dist/index.d.cts +18 -300
  32. package/dist/index.d.mts +20 -300
  33. package/dist/index.mjs +16 -342
  34. package/dist/loader/index.cjs +110 -0
  35. package/dist/loader/index.d.cts +48 -0
  36. package/dist/loader/index.d.cts.map +1 -0
  37. package/dist/loader/index.d.mts +48 -0
  38. package/dist/loader/index.d.mts.map +1 -0
  39. package/dist/loader/index.mjs +110 -0
  40. package/dist/loader/index.mjs.map +1 -0
  41. package/dist/meta/index.cjs +4 -0
  42. package/dist/meta/index.mjs +6 -0
  43. package/dist/meta/kind.cjs +161 -0
  44. package/dist/meta/kind.d.cts +134 -0
  45. package/dist/meta/kind.d.cts.map +1 -0
  46. package/dist/meta/kind.d.mts +134 -0
  47. package/dist/meta/kind.d.mts.map +1 -0
  48. package/dist/meta/kind.mjs +157 -0
  49. package/dist/meta/kind.mjs.map +1 -0
  50. package/dist/meta/path.cjs +116 -0
  51. package/dist/meta/path.d.cts +43 -0
  52. package/dist/meta/path.d.cts.map +1 -0
  53. package/dist/meta/path.d.mts +43 -0
  54. package/dist/meta/path.d.mts.map +1 -0
  55. package/dist/meta/path.mjs +112 -0
  56. package/dist/meta/path.mjs.map +1 -0
  57. package/dist/meta/type.d.cts +96 -0
  58. package/dist/meta/type.d.cts.map +1 -0
  59. package/dist/meta/type.d.mts +96 -0
  60. package/dist/meta/type.d.mts.map +1 -0
  61. package/dist/meta/validation.cjs +77 -0
  62. package/dist/meta/validation.d.cts +19 -0
  63. package/dist/meta/validation.d.cts.map +1 -0
  64. package/dist/meta/validation.d.mts +19 -0
  65. package/dist/meta/validation.d.mts.map +1 -0
  66. package/dist/meta/validation.mjs +77 -0
  67. package/dist/meta/validation.mjs.map +1 -0
  68. package/dist/meta/well-known-kinds.cjs +228 -0
  69. package/dist/meta/well-known-kinds.d.cts +52 -0
  70. package/dist/meta/well-known-kinds.d.cts.map +1 -0
  71. package/dist/meta/well-known-kinds.d.mts +52 -0
  72. package/dist/meta/well-known-kinds.d.mts.map +1 -0
  73. package/dist/meta/well-known-kinds.mjs +219 -0
  74. package/dist/meta/well-known-kinds.mjs.map +1 -0
  75. package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.cts +141 -0
  76. package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.cts.map +1 -0
  77. package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.mts +141 -0
  78. package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.mts.map +1 -0
  79. package/dist/path.cjs +255 -0
  80. package/dist/path.d.cts +93 -0
  81. package/dist/path.d.cts.map +1 -0
  82. package/dist/path.d.mts +93 -0
  83. package/dist/path.d.mts.map +1 -0
  84. package/dist/path.mjs +249 -0
  85. package/dist/path.mjs.map +1 -0
  86. package/dist/provider/base.cjs +425 -0
  87. package/dist/provider/base.d.cts +175 -0
  88. package/dist/provider/base.d.cts.map +1 -0
  89. package/dist/provider/base.d.mts +175 -0
  90. package/dist/provider/base.d.mts.map +1 -0
  91. package/dist/provider/base.mjs +426 -0
  92. package/dist/provider/base.mjs.map +1 -0
  93. package/dist/provider/decorators.cjs +268 -0
  94. package/dist/provider/decorators.d.cts +244 -0
  95. package/dist/provider/decorators.d.cts.map +1 -0
  96. package/dist/provider/decorators.d.mts +244 -0
  97. package/dist/provider/decorators.d.mts.map +1 -0
  98. package/dist/provider/decorators.mjs +256 -0
  99. package/dist/provider/decorators.mjs.map +1 -0
  100. package/dist/provider/index.cjs +19 -0
  101. package/dist/provider/index.d.cts +5 -0
  102. package/dist/provider/index.d.mts +5 -0
  103. package/dist/provider/index.mjs +5 -0
  104. package/dist/provider/router.cjs +185 -0
  105. package/dist/provider/router.d.cts +50 -0
  106. package/dist/provider/router.d.cts.map +1 -0
  107. package/dist/provider/router.d.mts +50 -0
  108. package/dist/provider/router.d.mts.map +1 -0
  109. package/dist/provider/router.mjs +185 -0
  110. package/dist/provider/router.mjs.map +1 -0
  111. package/dist/provider/types.d.cts +113 -0
  112. package/dist/provider/types.d.cts.map +1 -0
  113. package/dist/provider/types.d.mts +113 -0
  114. package/dist/provider/types.d.mts.map +1 -0
  115. package/dist/registry.cjs +358 -0
  116. package/dist/registry.d.cts +96 -0
  117. package/dist/registry.d.cts.map +1 -0
  118. package/dist/registry.d.mts +96 -0
  119. package/dist/registry.d.mts.map +1 -0
  120. package/dist/registry.mjs +360 -0
  121. package/dist/registry.mjs.map +1 -0
  122. package/dist/type.cjs +34 -0
  123. package/dist/type.d.cts +420 -0
  124. package/dist/type.d.cts.map +1 -0
  125. package/dist/type.d.mts +420 -0
  126. package/dist/type.d.mts.map +1 -0
  127. package/dist/type.mjs +33 -0
  128. package/dist/type.mjs.map +1 -0
  129. package/dist/utils/camelize.d.cts.map +1 -1
  130. package/dist/utils/camelize.d.mts.map +1 -1
  131. package/dist/utils/schema.cjs +129 -0
  132. package/dist/utils/schema.d.cts +65 -0
  133. package/dist/utils/schema.d.cts.map +1 -0
  134. package/dist/utils/schema.d.mts +65 -0
  135. package/dist/utils/schema.d.mts.map +1 -0
  136. package/dist/utils/schema.mjs +124 -0
  137. package/dist/utils/schema.mjs.map +1 -0
  138. package/dist/utils/type-utils.d.cts.map +1 -1
  139. package/dist/utils/type-utils.d.mts.map +1 -1
  140. package/dist/utils/uri-template.cjs +123 -0
  141. package/dist/utils/uri-template.d.cts +48 -0
  142. package/dist/utils/uri-template.d.cts.map +1 -0
  143. package/dist/utils/uri-template.d.mts +48 -0
  144. package/dist/utils/uri-template.d.mts.map +1 -0
  145. package/dist/utils/uri-template.mjs +120 -0
  146. package/dist/utils/uri-template.mjs.map +1 -0
  147. package/dist/utils/uri.cjs +49 -0
  148. package/dist/utils/uri.d.cts +34 -0
  149. package/dist/utils/uri.d.cts.map +1 -0
  150. package/dist/utils/uri.d.mts +34 -0
  151. package/dist/utils/uri.d.mts.map +1 -0
  152. package/dist/utils/uri.mjs +49 -0
  153. package/dist/utils/uri.mjs.map +1 -0
  154. package/dist/utils/zod.cjs +6 -8
  155. package/dist/utils/zod.d.cts +2 -2
  156. package/dist/utils/zod.d.cts.map +1 -1
  157. package/dist/utils/zod.d.mts +2 -2
  158. package/dist/utils/zod.d.mts.map +1 -1
  159. package/dist/utils/zod.mjs +6 -8
  160. package/dist/utils/zod.mjs.map +1 -1
  161. package/package.json +27 -4
  162. package/dist/index.d.cts.map +0 -1
  163. package/dist/index.d.mts.map +0 -1
  164. package/dist/index.mjs.map +0 -1
@@ -0,0 +1,77 @@
1
+ import { minimatch } from "minimatch";
2
+
3
+ //#region src/meta/validation.ts
4
+ /**
5
+ * Validation utilities for AFS Meta System.
6
+ *
7
+ * Provides:
8
+ * - Node constraint validation (required/optional nodes, glob patterns)
9
+ * - Validation result types
10
+ */
11
+ /**
12
+ * Validate a list of node names against NodesConstraints.
13
+ *
14
+ * @param basePath - Base path for error reporting (e.g., "/project")
15
+ * @param nodeNames - List of node names in the directory
16
+ * @param constraints - NodesConstraints to validate against
17
+ * @returns ValidationResult with valid flag and any errors
18
+ */
19
+ function validateNodes(basePath, nodeNames, constraints) {
20
+ const errors = [];
21
+ if (!constraints) return {
22
+ valid: true,
23
+ errors: []
24
+ };
25
+ const matchedNodes = /* @__PURE__ */ new Set();
26
+ if (constraints.required) for (const constraint of constraints.required) {
27
+ const pattern = constraint.path;
28
+ let found = false;
29
+ for (const nodeName of nodeNames) if (matchesPattern(nodeName, pattern)) {
30
+ found = true;
31
+ matchedNodes.add(nodeName);
32
+ break;
33
+ }
34
+ if (!found) errors.push({
35
+ path: `${basePath}/${pattern}`,
36
+ message: `Required node "${pattern}" not found in ${basePath}`,
37
+ code: "REQUIRED_NODE_MISSING"
38
+ });
39
+ }
40
+ if (constraints.optional) for (const constraint of constraints.optional) {
41
+ const pattern = constraint.path;
42
+ for (const nodeName of nodeNames) if (matchesPattern(nodeName, pattern)) matchedNodes.add(nodeName);
43
+ }
44
+ if (constraints.allowOther === false) {
45
+ for (const nodeName of nodeNames) if (!matchedNodes.has(nodeName)) errors.push({
46
+ path: `${basePath}/${nodeName}`,
47
+ message: `Unexpected node "${nodeName}" in ${basePath} (allowOther is false)`,
48
+ code: "UNEXPECTED_NODE"
49
+ });
50
+ }
51
+ return {
52
+ valid: errors.length === 0,
53
+ errors
54
+ };
55
+ }
56
+ /**
57
+ * Check if a node name matches a pattern (supports glob).
58
+ */
59
+ function matchesPattern(nodeName, pattern) {
60
+ if (nodeName === pattern) return true;
61
+ if (pattern.includes("*")) return minimatch(nodeName, pattern, { dot: true });
62
+ return false;
63
+ }
64
+ /**
65
+ * Combine multiple ValidationResults into one.
66
+ */
67
+ function combineValidationResults(...results) {
68
+ const allErrors = results.flatMap((r) => r.errors);
69
+ return {
70
+ valid: allErrors.length === 0,
71
+ errors: allErrors
72
+ };
73
+ }
74
+
75
+ //#endregion
76
+ export { combineValidationResults, validateNodes };
77
+ //# sourceMappingURL=validation.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.mjs","names":[],"sources":["../../src/meta/validation.ts"],"sourcesContent":["/**\n * Validation utilities for AFS Meta System.\n *\n * Provides:\n * - Node constraint validation (required/optional nodes, glob patterns)\n * - Validation result types\n */\n\nimport { minimatch } from \"minimatch\";\nimport type { NodesConstraints, ValidationError, ValidationResult } from \"./type.js\";\n\n/**\n * Validate a list of node names against NodesConstraints.\n *\n * @param basePath - Base path for error reporting (e.g., \"/project\")\n * @param nodeNames - List of node names in the directory\n * @param constraints - NodesConstraints to validate against\n * @returns ValidationResult with valid flag and any errors\n */\nexport function validateNodes(\n basePath: string,\n nodeNames: string[],\n constraints: NodesConstraints | undefined,\n): ValidationResult {\n const errors: ValidationError[] = [];\n\n // No constraints means everything is valid\n if (!constraints) {\n return { valid: true, errors: [] };\n }\n\n const matchedNodes = new Set<string>();\n\n // Check required nodes\n if (constraints.required) {\n for (const constraint of constraints.required) {\n const pattern = constraint.path;\n let found = false;\n\n // Check if any node matches the pattern (could be glob)\n for (const nodeName of nodeNames) {\n if (matchesPattern(nodeName, pattern)) {\n found = true;\n matchedNodes.add(nodeName);\n break;\n }\n }\n\n if (!found) {\n errors.push({\n path: `${basePath}/${pattern}`,\n message: `Required node \"${pattern}\" not found in ${basePath}`,\n code: \"REQUIRED_NODE_MISSING\",\n });\n }\n }\n }\n\n // Track optional nodes that match\n if (constraints.optional) {\n for (const constraint of constraints.optional) {\n const pattern = constraint.path;\n for (const nodeName of nodeNames) {\n if (matchesPattern(nodeName, pattern)) {\n matchedNodes.add(nodeName);\n }\n }\n }\n }\n\n // Check for unexpected nodes if allowOther is false\n if (constraints.allowOther === false) {\n for (const nodeName of nodeNames) {\n if (!matchedNodes.has(nodeName)) {\n errors.push({\n path: `${basePath}/${nodeName}`,\n message: `Unexpected node \"${nodeName}\" in ${basePath} (allowOther is false)`,\n code: \"UNEXPECTED_NODE\",\n });\n }\n }\n }\n\n return {\n valid: errors.length === 0,\n errors,\n };\n}\n\n/**\n * Check if a node name matches a pattern (supports glob).\n */\nfunction matchesPattern(nodeName: string, pattern: string): boolean {\n // Exact match\n if (nodeName === pattern) {\n return true;\n }\n\n // Glob match\n if (pattern.includes(\"*\")) {\n return minimatch(nodeName, pattern, { dot: true });\n }\n\n return false;\n}\n\n/**\n * Combine multiple ValidationResults into one.\n */\nexport function combineValidationResults(...results: ValidationResult[]): ValidationResult {\n const allErrors = results.flatMap((r) => r.errors);\n return {\n valid: allErrors.length === 0,\n errors: allErrors,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,SAAgB,cACd,UACA,WACA,aACkB;CAClB,MAAM,SAA4B,EAAE;AAGpC,KAAI,CAAC,YACH,QAAO;EAAE,OAAO;EAAM,QAAQ,EAAE;EAAE;CAGpC,MAAM,+BAAe,IAAI,KAAa;AAGtC,KAAI,YAAY,SACd,MAAK,MAAM,cAAc,YAAY,UAAU;EAC7C,MAAM,UAAU,WAAW;EAC3B,IAAI,QAAQ;AAGZ,OAAK,MAAM,YAAY,UACrB,KAAI,eAAe,UAAU,QAAQ,EAAE;AACrC,WAAQ;AACR,gBAAa,IAAI,SAAS;AAC1B;;AAIJ,MAAI,CAAC,MACH,QAAO,KAAK;GACV,MAAM,GAAG,SAAS,GAAG;GACrB,SAAS,kBAAkB,QAAQ,iBAAiB;GACpD,MAAM;GACP,CAAC;;AAMR,KAAI,YAAY,SACd,MAAK,MAAM,cAAc,YAAY,UAAU;EAC7C,MAAM,UAAU,WAAW;AAC3B,OAAK,MAAM,YAAY,UACrB,KAAI,eAAe,UAAU,QAAQ,CACnC,cAAa,IAAI,SAAS;;AAOlC,KAAI,YAAY,eAAe,OAC7B;OAAK,MAAM,YAAY,UACrB,KAAI,CAAC,aAAa,IAAI,SAAS,CAC7B,QAAO,KAAK;GACV,MAAM,GAAG,SAAS,GAAG;GACrB,SAAS,oBAAoB,SAAS,OAAO,SAAS;GACtD,MAAM;GACP,CAAC;;AAKR,QAAO;EACL,OAAO,OAAO,WAAW;EACzB;EACD;;;;;AAMH,SAAS,eAAe,UAAkB,SAA0B;AAElE,KAAI,aAAa,QACf,QAAO;AAIT,KAAI,QAAQ,SAAS,IAAI,CACvB,QAAO,UAAU,UAAU,SAAS,EAAE,KAAK,MAAM,CAAC;AAGpD,QAAO;;;;;AAMT,SAAgB,yBAAyB,GAAG,SAA+C;CACzF,MAAM,YAAY,QAAQ,SAAS,MAAM,EAAE,OAAO;AAClD,QAAO;EACL,OAAO,UAAU,WAAW;EAC5B,QAAQ;EACT"}
@@ -0,0 +1,228 @@
1
+
2
+ //#region src/meta/well-known-kinds.ts
3
+ /**
4
+ * Common meta properties that can apply to any node.
5
+ * Providers can extend their kinds with these properties.
6
+ */
7
+ const commonMetaSchema = {
8
+ type: "object",
9
+ properties: {
10
+ icon: {
11
+ type: "string",
12
+ description: "Display icon for this node"
13
+ },
14
+ label: {
15
+ type: "string",
16
+ description: "Human-readable display name"
17
+ },
18
+ color: {
19
+ type: "string",
20
+ description: "Display color for this node"
21
+ },
22
+ tags: {
23
+ type: "array",
24
+ items: { type: "string" },
25
+ description: "Tags for categorization and filtering"
26
+ },
27
+ description: {
28
+ type: "string",
29
+ description: "Description of this node"
30
+ }
31
+ }
32
+ };
33
+ /**
34
+ * Base node kind - the root of all kinds.
35
+ * All AFS nodes are just "nodes" - there's no file/directory distinction at the kind level.
36
+ * Whether a node has children is determined by childrenCount at runtime.
37
+ */
38
+ const afsNode = {
39
+ name: "afs:node",
40
+ description: "Base kind for all AFS nodes",
41
+ meta: {
42
+ type: "object",
43
+ properties: {
44
+ ...commonMetaSchema.properties,
45
+ childrenCount: {
46
+ type: "integer",
47
+ minimum: 0,
48
+ description: "Number of children (undefined=unknown, 0=none currently, >0=has children)"
49
+ },
50
+ mimeType: {
51
+ type: "string",
52
+ description: "MIME type (e.g., text/plain, application/json)"
53
+ },
54
+ expanded: {
55
+ type: "boolean",
56
+ description: "Whether to show expanded by default in UI"
57
+ },
58
+ sortOrder: {
59
+ type: "string",
60
+ enum: [
61
+ "name",
62
+ "date",
63
+ "size",
64
+ "type",
65
+ "custom"
66
+ ],
67
+ description: "How to sort children in listings"
68
+ }
69
+ }
70
+ }
71
+ };
72
+ /**
73
+ * Document kind (text, markdown, etc.).
74
+ */
75
+ const afsDocument = {
76
+ name: "afs:document",
77
+ extends: "afs:node",
78
+ description: "Document (text, markdown, rich text)",
79
+ meta: {
80
+ type: "object",
81
+ properties: {
82
+ title: {
83
+ type: "string",
84
+ description: "Document title"
85
+ },
86
+ author: {
87
+ type: "string",
88
+ description: "Author of the document"
89
+ },
90
+ format: {
91
+ type: "string",
92
+ enum: [
93
+ "text",
94
+ "markdown",
95
+ "html",
96
+ "rst",
97
+ "asciidoc"
98
+ ],
99
+ description: "Document format"
100
+ }
101
+ }
102
+ }
103
+ };
104
+ /**
105
+ * Image kind.
106
+ */
107
+ const afsImage = {
108
+ name: "afs:image",
109
+ extends: "afs:node",
110
+ description: "Image (png, jpg, gif, etc.)",
111
+ meta: {
112
+ type: "object",
113
+ properties: {
114
+ width: {
115
+ type: "integer",
116
+ minimum: 0,
117
+ description: "Image width in pixels"
118
+ },
119
+ height: {
120
+ type: "integer",
121
+ minimum: 0,
122
+ description: "Image height in pixels"
123
+ },
124
+ format: {
125
+ type: "string",
126
+ enum: [
127
+ "png",
128
+ "jpg",
129
+ "jpeg",
130
+ "gif",
131
+ "webp",
132
+ "svg",
133
+ "ico",
134
+ "bmp"
135
+ ],
136
+ description: "Image format"
137
+ },
138
+ alt: {
139
+ type: "string",
140
+ description: "Alternative text for accessibility"
141
+ }
142
+ }
143
+ }
144
+ };
145
+ /**
146
+ * Executable or script kind.
147
+ */
148
+ const afsExecutable = {
149
+ name: "afs:executable",
150
+ extends: "afs:node",
151
+ description: "Executable or script",
152
+ meta: {
153
+ type: "object",
154
+ properties: {
155
+ runtime: {
156
+ type: "string",
157
+ description: "Runtime environment (e.g., node, python, bash)"
158
+ },
159
+ command: {
160
+ type: "string",
161
+ description: "Command to execute"
162
+ },
163
+ inputSchema: {
164
+ type: "object",
165
+ description: "JSON Schema describing expected input parameters"
166
+ },
167
+ outputSchema: {
168
+ type: "object",
169
+ description: "JSON Schema describing expected output format"
170
+ }
171
+ }
172
+ }
173
+ };
174
+ /**
175
+ * Link/symlink kind.
176
+ */
177
+ const afsLink = {
178
+ name: "afs:link",
179
+ extends: "afs:node",
180
+ description: "Symbolic link or reference to another node",
181
+ meta: {
182
+ type: "object",
183
+ properties: { target: {
184
+ type: "string",
185
+ description: "Path to the target node"
186
+ } }
187
+ }
188
+ };
189
+ /**
190
+ * All well-known kinds as an array.
191
+ * Note: No separate file/directory kinds - all are nodes.
192
+ * Whether a node has children is determined by childrenCount at runtime.
193
+ */
194
+ const WELL_KNOWN_KINDS = [
195
+ afsNode,
196
+ afsDocument,
197
+ afsImage,
198
+ afsExecutable,
199
+ afsLink
200
+ ];
201
+ /**
202
+ * Well-known kinds as a map for quick lookup.
203
+ */
204
+ const WELL_KNOWN_KINDS_MAP = new Map(WELL_KNOWN_KINDS.map((k) => [k.name, k]));
205
+ /**
206
+ * Get a well-known kind by name.
207
+ */
208
+ function getWellKnownKind(name) {
209
+ return WELL_KNOWN_KINDS_MAP.get(name);
210
+ }
211
+ /**
212
+ * Check if a kind name is a well-known kind.
213
+ */
214
+ function isWellKnownKind(name) {
215
+ return WELL_KNOWN_KINDS_MAP.has(name);
216
+ }
217
+
218
+ //#endregion
219
+ exports.WELL_KNOWN_KINDS = WELL_KNOWN_KINDS;
220
+ exports.WELL_KNOWN_KINDS_MAP = WELL_KNOWN_KINDS_MAP;
221
+ exports.afsDocument = afsDocument;
222
+ exports.afsExecutable = afsExecutable;
223
+ exports.afsImage = afsImage;
224
+ exports.afsLink = afsLink;
225
+ exports.afsNode = afsNode;
226
+ exports.commonMetaSchema = commonMetaSchema;
227
+ exports.getWellKnownKind = getWellKnownKind;
228
+ exports.isWellKnownKind = isWellKnownKind;
@@ -0,0 +1,52 @@
1
+ import { JSONSchema7 } from "../node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.cjs";
2
+ import { KindSchema } from "./type.cjs";
3
+
4
+ //#region src/meta/well-known-kinds.d.ts
5
+ /**
6
+ * Common meta properties that can apply to any node.
7
+ * Providers can extend their kinds with these properties.
8
+ */
9
+ declare const commonMetaSchema: JSONSchema7;
10
+ /**
11
+ * Base node kind - the root of all kinds.
12
+ * All AFS nodes are just "nodes" - there's no file/directory distinction at the kind level.
13
+ * Whether a node has children is determined by childrenCount at runtime.
14
+ */
15
+ declare const afsNode: KindSchema;
16
+ /**
17
+ * Document kind (text, markdown, etc.).
18
+ */
19
+ declare const afsDocument: KindSchema;
20
+ /**
21
+ * Image kind.
22
+ */
23
+ declare const afsImage: KindSchema;
24
+ /**
25
+ * Executable or script kind.
26
+ */
27
+ declare const afsExecutable: KindSchema;
28
+ /**
29
+ * Link/symlink kind.
30
+ */
31
+ declare const afsLink: KindSchema;
32
+ /**
33
+ * All well-known kinds as an array.
34
+ * Note: No separate file/directory kinds - all are nodes.
35
+ * Whether a node has children is determined by childrenCount at runtime.
36
+ */
37
+ declare const WELL_KNOWN_KINDS: KindSchema[];
38
+ /**
39
+ * Well-known kinds as a map for quick lookup.
40
+ */
41
+ declare const WELL_KNOWN_KINDS_MAP: Map<string, KindSchema>;
42
+ /**
43
+ * Get a well-known kind by name.
44
+ */
45
+ declare function getWellKnownKind(name: string): KindSchema | undefined;
46
+ /**
47
+ * Check if a kind name is a well-known kind.
48
+ */
49
+ declare function isWellKnownKind(name: string): boolean;
50
+ //#endregion
51
+ export { WELL_KNOWN_KINDS, WELL_KNOWN_KINDS_MAP, afsDocument, afsExecutable, afsImage, afsLink, afsNode, commonMetaSchema, getWellKnownKind, isWellKnownKind };
52
+ //# sourceMappingURL=well-known-kinds.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"well-known-kinds.d.cts","names":[],"sources":["../../src/meta/well-known-kinds.ts"],"mappings":";;;;;;;;cAoBa,gBAAA,EAAkB,WAAA;;;;;AAmH/B;cA1Ea,OAAA,EAAS,UAAA;;;;cA4CT,WAAA,EAAa,UAAA;;;;cA8Bb,QAAA,EAAU,UAAA;AAuEvB;;;AAAA,cAlCa,aAAA,EAAe,UAAA;;AA2D5B;;cAzBa,OAAA,EAAS,UAAA;;;AAoCtB;;;cAXa,gBAAA,EAAkB,UAAA;;AAkB/B;;cAPa,oBAAA,EAAsB,GAAA,SAAY,UAAA;;;AAc/C;iBAPgB,gBAAA,CAAiB,IAAA,WAAe,UAAA;;;;iBAOhC,eAAA,CAAgB,IAAA"}
@@ -0,0 +1,52 @@
1
+ import { JSONSchema7 } from "../node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.mjs";
2
+ import { KindSchema } from "./type.mjs";
3
+
4
+ //#region src/meta/well-known-kinds.d.ts
5
+ /**
6
+ * Common meta properties that can apply to any node.
7
+ * Providers can extend their kinds with these properties.
8
+ */
9
+ declare const commonMetaSchema: JSONSchema7;
10
+ /**
11
+ * Base node kind - the root of all kinds.
12
+ * All AFS nodes are just "nodes" - there's no file/directory distinction at the kind level.
13
+ * Whether a node has children is determined by childrenCount at runtime.
14
+ */
15
+ declare const afsNode: KindSchema;
16
+ /**
17
+ * Document kind (text, markdown, etc.).
18
+ */
19
+ declare const afsDocument: KindSchema;
20
+ /**
21
+ * Image kind.
22
+ */
23
+ declare const afsImage: KindSchema;
24
+ /**
25
+ * Executable or script kind.
26
+ */
27
+ declare const afsExecutable: KindSchema;
28
+ /**
29
+ * Link/symlink kind.
30
+ */
31
+ declare const afsLink: KindSchema;
32
+ /**
33
+ * All well-known kinds as an array.
34
+ * Note: No separate file/directory kinds - all are nodes.
35
+ * Whether a node has children is determined by childrenCount at runtime.
36
+ */
37
+ declare const WELL_KNOWN_KINDS: KindSchema[];
38
+ /**
39
+ * Well-known kinds as a map for quick lookup.
40
+ */
41
+ declare const WELL_KNOWN_KINDS_MAP: Map<string, KindSchema>;
42
+ /**
43
+ * Get a well-known kind by name.
44
+ */
45
+ declare function getWellKnownKind(name: string): KindSchema | undefined;
46
+ /**
47
+ * Check if a kind name is a well-known kind.
48
+ */
49
+ declare function isWellKnownKind(name: string): boolean;
50
+ //#endregion
51
+ export { WELL_KNOWN_KINDS, WELL_KNOWN_KINDS_MAP, afsDocument, afsExecutable, afsImage, afsLink, afsNode, commonMetaSchema, getWellKnownKind, isWellKnownKind };
52
+ //# sourceMappingURL=well-known-kinds.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"well-known-kinds.d.mts","names":[],"sources":["../../src/meta/well-known-kinds.ts"],"mappings":";;;;;;;;cAoBa,gBAAA,EAAkB,WAAA;;;;;AAmH/B;cA1Ea,OAAA,EAAS,UAAA;;;;cA4CT,WAAA,EAAa,UAAA;;;;cA8Bb,QAAA,EAAU,UAAA;AAuEvB;;;AAAA,cAlCa,aAAA,EAAe,UAAA;;AA2D5B;;cAzBa,OAAA,EAAS,UAAA;;;AAoCtB;;;cAXa,gBAAA,EAAkB,UAAA;;AAkB/B;;cAPa,oBAAA,EAAsB,GAAA,SAAY,UAAA;;;AAc/C;iBAPgB,gBAAA,CAAiB,IAAA,WAAe,UAAA;;;;iBAOhC,eAAA,CAAgB,IAAA"}
@@ -0,0 +1,219 @@
1
+ //#region src/meta/well-known-kinds.ts
2
+ /**
3
+ * Common meta properties that can apply to any node.
4
+ * Providers can extend their kinds with these properties.
5
+ */
6
+ const commonMetaSchema = {
7
+ type: "object",
8
+ properties: {
9
+ icon: {
10
+ type: "string",
11
+ description: "Display icon for this node"
12
+ },
13
+ label: {
14
+ type: "string",
15
+ description: "Human-readable display name"
16
+ },
17
+ color: {
18
+ type: "string",
19
+ description: "Display color for this node"
20
+ },
21
+ tags: {
22
+ type: "array",
23
+ items: { type: "string" },
24
+ description: "Tags for categorization and filtering"
25
+ },
26
+ description: {
27
+ type: "string",
28
+ description: "Description of this node"
29
+ }
30
+ }
31
+ };
32
+ /**
33
+ * Base node kind - the root of all kinds.
34
+ * All AFS nodes are just "nodes" - there's no file/directory distinction at the kind level.
35
+ * Whether a node has children is determined by childrenCount at runtime.
36
+ */
37
+ const afsNode = {
38
+ name: "afs:node",
39
+ description: "Base kind for all AFS nodes",
40
+ meta: {
41
+ type: "object",
42
+ properties: {
43
+ ...commonMetaSchema.properties,
44
+ childrenCount: {
45
+ type: "integer",
46
+ minimum: 0,
47
+ description: "Number of children (undefined=unknown, 0=none currently, >0=has children)"
48
+ },
49
+ mimeType: {
50
+ type: "string",
51
+ description: "MIME type (e.g., text/plain, application/json)"
52
+ },
53
+ expanded: {
54
+ type: "boolean",
55
+ description: "Whether to show expanded by default in UI"
56
+ },
57
+ sortOrder: {
58
+ type: "string",
59
+ enum: [
60
+ "name",
61
+ "date",
62
+ "size",
63
+ "type",
64
+ "custom"
65
+ ],
66
+ description: "How to sort children in listings"
67
+ }
68
+ }
69
+ }
70
+ };
71
+ /**
72
+ * Document kind (text, markdown, etc.).
73
+ */
74
+ const afsDocument = {
75
+ name: "afs:document",
76
+ extends: "afs:node",
77
+ description: "Document (text, markdown, rich text)",
78
+ meta: {
79
+ type: "object",
80
+ properties: {
81
+ title: {
82
+ type: "string",
83
+ description: "Document title"
84
+ },
85
+ author: {
86
+ type: "string",
87
+ description: "Author of the document"
88
+ },
89
+ format: {
90
+ type: "string",
91
+ enum: [
92
+ "text",
93
+ "markdown",
94
+ "html",
95
+ "rst",
96
+ "asciidoc"
97
+ ],
98
+ description: "Document format"
99
+ }
100
+ }
101
+ }
102
+ };
103
+ /**
104
+ * Image kind.
105
+ */
106
+ const afsImage = {
107
+ name: "afs:image",
108
+ extends: "afs:node",
109
+ description: "Image (png, jpg, gif, etc.)",
110
+ meta: {
111
+ type: "object",
112
+ properties: {
113
+ width: {
114
+ type: "integer",
115
+ minimum: 0,
116
+ description: "Image width in pixels"
117
+ },
118
+ height: {
119
+ type: "integer",
120
+ minimum: 0,
121
+ description: "Image height in pixels"
122
+ },
123
+ format: {
124
+ type: "string",
125
+ enum: [
126
+ "png",
127
+ "jpg",
128
+ "jpeg",
129
+ "gif",
130
+ "webp",
131
+ "svg",
132
+ "ico",
133
+ "bmp"
134
+ ],
135
+ description: "Image format"
136
+ },
137
+ alt: {
138
+ type: "string",
139
+ description: "Alternative text for accessibility"
140
+ }
141
+ }
142
+ }
143
+ };
144
+ /**
145
+ * Executable or script kind.
146
+ */
147
+ const afsExecutable = {
148
+ name: "afs:executable",
149
+ extends: "afs:node",
150
+ description: "Executable or script",
151
+ meta: {
152
+ type: "object",
153
+ properties: {
154
+ runtime: {
155
+ type: "string",
156
+ description: "Runtime environment (e.g., node, python, bash)"
157
+ },
158
+ command: {
159
+ type: "string",
160
+ description: "Command to execute"
161
+ },
162
+ inputSchema: {
163
+ type: "object",
164
+ description: "JSON Schema describing expected input parameters"
165
+ },
166
+ outputSchema: {
167
+ type: "object",
168
+ description: "JSON Schema describing expected output format"
169
+ }
170
+ }
171
+ }
172
+ };
173
+ /**
174
+ * Link/symlink kind.
175
+ */
176
+ const afsLink = {
177
+ name: "afs:link",
178
+ extends: "afs:node",
179
+ description: "Symbolic link or reference to another node",
180
+ meta: {
181
+ type: "object",
182
+ properties: { target: {
183
+ type: "string",
184
+ description: "Path to the target node"
185
+ } }
186
+ }
187
+ };
188
+ /**
189
+ * All well-known kinds as an array.
190
+ * Note: No separate file/directory kinds - all are nodes.
191
+ * Whether a node has children is determined by childrenCount at runtime.
192
+ */
193
+ const WELL_KNOWN_KINDS = [
194
+ afsNode,
195
+ afsDocument,
196
+ afsImage,
197
+ afsExecutable,
198
+ afsLink
199
+ ];
200
+ /**
201
+ * Well-known kinds as a map for quick lookup.
202
+ */
203
+ const WELL_KNOWN_KINDS_MAP = new Map(WELL_KNOWN_KINDS.map((k) => [k.name, k]));
204
+ /**
205
+ * Get a well-known kind by name.
206
+ */
207
+ function getWellKnownKind(name) {
208
+ return WELL_KNOWN_KINDS_MAP.get(name);
209
+ }
210
+ /**
211
+ * Check if a kind name is a well-known kind.
212
+ */
213
+ function isWellKnownKind(name) {
214
+ return WELL_KNOWN_KINDS_MAP.has(name);
215
+ }
216
+
217
+ //#endregion
218
+ export { WELL_KNOWN_KINDS, WELL_KNOWN_KINDS_MAP, afsDocument, afsExecutable, afsImage, afsLink, afsNode, commonMetaSchema, getWellKnownKind, isWellKnownKind };
219
+ //# sourceMappingURL=well-known-kinds.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"well-known-kinds.mjs","names":[],"sources":["../../src/meta/well-known-kinds.ts"],"sourcesContent":["/**\n * Well-known Kind definitions for @aigne/afs core package.\n *\n * These are common types that all providers can use or extend.\n *\n * Naming convention:\n * - Well-known: \"afs:*\" (defined here)\n * - Provider-specific: \"{provider}:{kind}\" (e.g., \"chamber:project\")\n */\n\nimport type { JSONSchema7, KindSchema } from \"./type.js\";\n\n// =============================================================================\n// Common JSON Schema definitions (reusable across kinds)\n// =============================================================================\n\n/**\n * Common meta properties that can apply to any node.\n * Providers can extend their kinds with these properties.\n */\nexport const commonMetaSchema: JSONSchema7 = {\n type: \"object\",\n properties: {\n /** Display icon (path, URL, or icon identifier like \"folder\", \"file-text\") */\n icon: {\n type: \"string\",\n description: \"Display icon for this node\",\n },\n /** Display label (alternative to file/directory name) */\n label: {\n type: \"string\",\n description: \"Human-readable display name\",\n },\n /** Color for UI display (hex, rgb, or named color) */\n color: {\n type: \"string\",\n description: \"Display color for this node\",\n },\n /** Tags for categorization */\n tags: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Tags for categorization and filtering\",\n },\n /** Human-readable description */\n description: {\n type: \"string\",\n description: \"Description of this node\",\n },\n },\n};\n\n// =============================================================================\n// Well-known Kind Schemas\n// =============================================================================\n\n/**\n * Base node kind - the root of all kinds.\n * All AFS nodes are just \"nodes\" - there's no file/directory distinction at the kind level.\n * Whether a node has children is determined by childrenCount at runtime.\n */\nexport const afsNode: KindSchema = {\n name: \"afs:node\",\n description: \"Base kind for all AFS nodes\",\n meta: {\n type: \"object\",\n properties: {\n ...commonMetaSchema.properties,\n /**\n * Number of children this node has.\n * - undefined: unknown (not yet loaded)\n * - 0: no children currently (but may have children in the future)\n * - >0: has children\n *\n * Note: This is a runtime value. There is no file/directory distinction -\n * all nodes can potentially have children.\n */\n childrenCount: {\n type: \"integer\",\n minimum: 0,\n description: \"Number of children (undefined=unknown, 0=none currently, >0=has children)\",\n },\n /** MIME type (for content nodes) */\n mimeType: {\n type: \"string\",\n description: \"MIME type (e.g., text/plain, application/json)\",\n },\n /** Whether this node should be shown expanded by default in UI */\n expanded: {\n type: \"boolean\",\n description: \"Whether to show expanded by default in UI\",\n },\n /** Sort order for children */\n sortOrder: {\n type: \"string\",\n enum: [\"name\", \"date\", \"size\", \"type\", \"custom\"],\n description: \"How to sort children in listings\",\n },\n },\n },\n};\n\n/**\n * Document kind (text, markdown, etc.).\n */\nexport const afsDocument: KindSchema = {\n name: \"afs:document\",\n extends: \"afs:node\",\n description: \"Document (text, markdown, rich text)\",\n meta: {\n type: \"object\",\n properties: {\n /** Document title */\n title: {\n type: \"string\",\n description: \"Document title\",\n },\n /** Author name */\n author: {\n type: \"string\",\n description: \"Author of the document\",\n },\n /** Document format */\n format: {\n type: \"string\",\n enum: [\"text\", \"markdown\", \"html\", \"rst\", \"asciidoc\"],\n description: \"Document format\",\n },\n },\n },\n};\n\n/**\n * Image kind.\n */\nexport const afsImage: KindSchema = {\n name: \"afs:image\",\n extends: \"afs:node\",\n description: \"Image (png, jpg, gif, etc.)\",\n meta: {\n type: \"object\",\n properties: {\n /** Image width in pixels */\n width: {\n type: \"integer\",\n minimum: 0,\n description: \"Image width in pixels\",\n },\n /** Image height in pixels */\n height: {\n type: \"integer\",\n minimum: 0,\n description: \"Image height in pixels\",\n },\n /** Image format */\n format: {\n type: \"string\",\n enum: [\"png\", \"jpg\", \"jpeg\", \"gif\", \"webp\", \"svg\", \"ico\", \"bmp\"],\n description: \"Image format\",\n },\n /** Alternative text for accessibility */\n alt: {\n type: \"string\",\n description: \"Alternative text for accessibility\",\n },\n },\n },\n};\n\n/**\n * Executable or script kind.\n */\nexport const afsExecutable: KindSchema = {\n name: \"afs:executable\",\n extends: \"afs:node\",\n description: \"Executable or script\",\n meta: {\n type: \"object\",\n properties: {\n /** Runtime environment */\n runtime: {\n type: \"string\",\n description: \"Runtime environment (e.g., node, python, bash)\",\n },\n /** Entry command or script */\n command: {\n type: \"string\",\n description: \"Command to execute\",\n },\n /** Input schema (JSON Schema format) */\n inputSchema: {\n type: \"object\",\n description: \"JSON Schema describing expected input parameters\",\n },\n /** Output schema (JSON Schema format) */\n outputSchema: {\n type: \"object\",\n description: \"JSON Schema describing expected output format\",\n },\n },\n },\n};\n\n/**\n * Link/symlink kind.\n */\nexport const afsLink: KindSchema = {\n name: \"afs:link\",\n extends: \"afs:node\",\n description: \"Symbolic link or reference to another node\",\n meta: {\n type: \"object\",\n properties: {\n /** Target path */\n target: {\n type: \"string\",\n description: \"Path to the target node\",\n },\n },\n },\n};\n\n// =============================================================================\n// Registry\n// =============================================================================\n\n/**\n * All well-known kinds as an array.\n * Note: No separate file/directory kinds - all are nodes.\n * Whether a node has children is determined by childrenCount at runtime.\n */\nexport const WELL_KNOWN_KINDS: KindSchema[] = [\n afsNode,\n afsDocument,\n afsImage,\n afsExecutable,\n afsLink,\n];\n\n/**\n * Well-known kinds as a map for quick lookup.\n */\nexport const WELL_KNOWN_KINDS_MAP: Map<string, KindSchema> = new Map(\n WELL_KNOWN_KINDS.map((k) => [k.name, k]),\n);\n\n/**\n * Get a well-known kind by name.\n */\nexport function getWellKnownKind(name: string): KindSchema | undefined {\n return WELL_KNOWN_KINDS_MAP.get(name);\n}\n\n/**\n * Check if a kind name is a well-known kind.\n */\nexport function isWellKnownKind(name: string): boolean {\n return WELL_KNOWN_KINDS_MAP.has(name);\n}\n"],"mappings":";;;;;AAoBA,MAAa,mBAAgC;CAC3C,MAAM;CACN,YAAY;EAEV,MAAM;GACJ,MAAM;GACN,aAAa;GACd;EAED,OAAO;GACL,MAAM;GACN,aAAa;GACd;EAED,OAAO;GACL,MAAM;GACN,aAAa;GACd;EAED,MAAM;GACJ,MAAM;GACN,OAAO,EAAE,MAAM,UAAU;GACzB,aAAa;GACd;EAED,aAAa;GACX,MAAM;GACN,aAAa;GACd;EACF;CACF;;;;;;AAWD,MAAa,UAAsB;CACjC,MAAM;CACN,aAAa;CACb,MAAM;EACJ,MAAM;EACN,YAAY;GACV,GAAG,iBAAiB;GAUpB,eAAe;IACb,MAAM;IACN,SAAS;IACT,aAAa;IACd;GAED,UAAU;IACR,MAAM;IACN,aAAa;IACd;GAED,UAAU;IACR,MAAM;IACN,aAAa;IACd;GAED,WAAW;IACT,MAAM;IACN,MAAM;KAAC;KAAQ;KAAQ;KAAQ;KAAQ;KAAS;IAChD,aAAa;IACd;GACF;EACF;CACF;;;;AAKD,MAAa,cAA0B;CACrC,MAAM;CACN,SAAS;CACT,aAAa;CACb,MAAM;EACJ,MAAM;EACN,YAAY;GAEV,OAAO;IACL,MAAM;IACN,aAAa;IACd;GAED,QAAQ;IACN,MAAM;IACN,aAAa;IACd;GAED,QAAQ;IACN,MAAM;IACN,MAAM;KAAC;KAAQ;KAAY;KAAQ;KAAO;KAAW;IACrD,aAAa;IACd;GACF;EACF;CACF;;;;AAKD,MAAa,WAAuB;CAClC,MAAM;CACN,SAAS;CACT,aAAa;CACb,MAAM;EACJ,MAAM;EACN,YAAY;GAEV,OAAO;IACL,MAAM;IACN,SAAS;IACT,aAAa;IACd;GAED,QAAQ;IACN,MAAM;IACN,SAAS;IACT,aAAa;IACd;GAED,QAAQ;IACN,MAAM;IACN,MAAM;KAAC;KAAO;KAAO;KAAQ;KAAO;KAAQ;KAAO;KAAO;KAAM;IAChE,aAAa;IACd;GAED,KAAK;IACH,MAAM;IACN,aAAa;IACd;GACF;EACF;CACF;;;;AAKD,MAAa,gBAA4B;CACvC,MAAM;CACN,SAAS;CACT,aAAa;CACb,MAAM;EACJ,MAAM;EACN,YAAY;GAEV,SAAS;IACP,MAAM;IACN,aAAa;IACd;GAED,SAAS;IACP,MAAM;IACN,aAAa;IACd;GAED,aAAa;IACX,MAAM;IACN,aAAa;IACd;GAED,cAAc;IACZ,MAAM;IACN,aAAa;IACd;GACF;EACF;CACF;;;;AAKD,MAAa,UAAsB;CACjC,MAAM;CACN,SAAS;CACT,aAAa;CACb,MAAM;EACJ,MAAM;EACN,YAAY,EAEV,QAAQ;GACN,MAAM;GACN,aAAa;GACd,EACF;EACF;CACF;;;;;;AAWD,MAAa,mBAAiC;CAC5C;CACA;CACA;CACA;CACA;CACD;;;;AAKD,MAAa,uBAAgD,IAAI,IAC/D,iBAAiB,KAAK,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CACzC;;;;AAKD,SAAgB,iBAAiB,MAAsC;AACrE,QAAO,qBAAqB,IAAI,KAAK;;;;;AAMvC,SAAgB,gBAAgB,MAAuB;AACrD,QAAO,qBAAqB,IAAI,KAAK"}