@nuucognition/flint-cli 0.3.0-alpha.1 → 0.4.0-alpha.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 CHANGED
@@ -201,10 +201,19 @@ flint git init
201
201
 
202
202
  #### `flint git sync`
203
203
 
204
- Update `.gitignore` with workspace entries.
204
+ Run the collaboration flow for a Flint repository: `flint sync`, stage all changes, commit with an identity-stamped sync message, pull with rebase, and push.
205
205
 
206
206
  ```bash
207
207
  flint git sync
208
+ flint git sync -m "custom message"
209
+ ```
210
+
211
+ #### `flint git publish <url>`
212
+
213
+ Initialize git if needed, run `flint sync`, configure `origin`, create the initial commit if needed, and push to `main`.
214
+
215
+ ```bash
216
+ flint git publish <url>
208
217
  ```
209
218
 
210
219
  #### `flint git <command>`
@@ -227,14 +236,15 @@ flint export build
227
236
  flint export build <name>
228
237
  ```
229
238
 
230
- ### `flint import`
239
+ ### `flint source`
231
240
 
232
- Manage imports from other registered flints.
241
+ Manage external sources declared by the Flint.
233
242
 
234
243
  ```bash
235
- flint import list
236
- flint import add "NUU Flint/Guide"
237
- flint import remove "NUU Flint/Guide"
244
+ flint source repo add "Reference Repo" <url>
245
+ flint source repo list
246
+ flint source meshexport add "NUU Flint/Guide"
247
+ flint source meshexport list
238
248
  ```
239
249
 
240
250
  ## Configuration
@@ -255,7 +265,7 @@ required = ["core"]
255
265
  required = ["git"]
256
266
  ```
257
267
 
258
- Optional sections include `[imports]` and `[workspace]` declarations.
268
+ Optional sections include `[sources]` and `[workspace]` declarations.
259
269
 
260
270
  ### flint.lock
261
271
 
@@ -1,6 +1,10 @@
1
- // ../../packages/flint/dist/chunk-HCE4DXJK.js
2
- import { readdir, readFile, mkdir, writeFile, rm, stat } from "fs/promises";
3
- import { join, basename, dirname, resolve, relative, sep } from "path";
1
+ import {
2
+ readFlintToml
3
+ } from "./chunk-GQSLJAUU.js";
4
+
5
+ // ../../packages/flint/dist/chunk-RLEEB7QI.js
6
+ import { readdir, readFile, mkdir, writeFile, rm, stat, copyFile } from "fs/promises";
7
+ import { join, basename, dirname, resolve, relative, sep, extname } from "path";
4
8
  async function exists(path) {
5
9
  try {
6
10
  await stat(path);
@@ -84,7 +88,7 @@ ${quotedContent}`;
84
88
  }
85
89
  return result;
86
90
  }
87
- async function rewriteWikilinks(content, flintName, flintPath, exportNameBySourcePath, resolveCache) {
91
+ async function rewriteWikilinks(content, flintName, exportName, flintPath, exportNameBySourcePath, resolveCache) {
88
92
  const wikilinkRegex = /\[\[([^\]|#]+)(#[^\]|]*)?((\|)([^\]]*))?\]\]/g;
89
93
  let result = "";
90
94
  let lastIndex = 0;
@@ -103,9 +107,9 @@ async function rewriteWikilinks(content, flintName, flintPath, exportNameBySourc
103
107
  const resolvedPath = await resolveDocumentCached(target, flintPath, resolveCache);
104
108
  const exportBaseName = resolvedPath ? exportNameBySourcePath.get(resolvedPath) : void 0;
105
109
  if (exportBaseName) {
106
- const prefixedName = `Export - (${flintName}) ${exportBaseName}`;
110
+ const dotName = `(Flint) ${flintName} . (Mesh Export) ${exportName} - ${exportBaseName}`;
107
111
  const displayAlias = alias || target;
108
- result += `[[${prefixedName}${section}|${displayAlias}]]`;
112
+ result += `[[${dotName}${section}|${displayAlias}]]`;
109
113
  } else {
110
114
  result += match[0];
111
115
  }
@@ -208,8 +212,8 @@ function getDisambiguatedExportName(flintPath, sourcePath, baseName) {
208
212
  return `${baseName} (${dirLabel})`;
209
213
  }
210
214
  async function scanExports(flintPath) {
211
- const { readFlintToml } = await import("./mesh-config-7GOTOVCM-TZEJ43E5.js");
212
- const config = await readFlintToml(flintPath);
215
+ const { readFlintToml: readFlintToml2 } = await import("./mesh-config-TEPKR6QZ-TINWSM6H.js");
216
+ const config = await readFlintToml2(flintPath);
213
217
  const declarations = config?.exports?.required;
214
218
  if (!declarations || declarations.length === 0) {
215
219
  return [];
@@ -223,7 +227,7 @@ async function scanExportsFromConfig(flintPath, declarations) {
223
227
  if (!sourcePath) continue;
224
228
  try {
225
229
  const content = await readFile(sourcePath, "utf-8");
226
- const depth = decl.depth ?? (decl.mode === "mesh" ? 1 : 1);
230
+ const depth = decl.depth ?? 1;
227
231
  const manifest = parseExportDocument(content, decl.name, sourcePath);
228
232
  manifest.depth = depth;
229
233
  manifests.push(manifest);
@@ -235,8 +239,8 @@ async function scanExportsFromConfig(flintPath, declarations) {
235
239
  async function scanExportEligible(flintPath) {
236
240
  const meshDir = join(flintPath, "Mesh");
237
241
  if (!await exists(meshDir)) return [];
238
- const { readFlintToml } = await import("./mesh-config-7GOTOVCM-TZEJ43E5.js");
239
- const config = await readFlintToml(flintPath);
242
+ const { readFlintToml: readFlintToml2 } = await import("./mesh-config-TEPKR6QZ-TINWSM6H.js");
243
+ const config = await readFlintToml2(flintPath);
240
244
  const declared = new Set(
241
245
  (config?.exports?.required || []).map((d) => d.file.replace(/\.md$/, "").toLowerCase())
242
246
  );
@@ -272,15 +276,40 @@ async function findExportTaggedFiles(dir, flintPath, declared, results) {
272
276
  } catch {
273
277
  }
274
278
  }
279
+ async function collectMediaFiles(content, flintPath, collected) {
280
+ const contentBody = getContentWithoutFrontmatter(content);
281
+ const embedRegex = /!\[\[([^\]|#]+)(?:#[^\]|]*)?(?:\|[^\]]*)?\]\]/g;
282
+ let match;
283
+ while ((match = embedRegex.exec(contentBody)) !== null) {
284
+ const target = match[1]?.trim();
285
+ if (!target) continue;
286
+ if (target.endsWith(".md") || !target.includes(".")) continue;
287
+ const mediaPath = join(flintPath, "Media", target);
288
+ if (await exists(mediaPath)) {
289
+ collected.add(mediaPath);
290
+ continue;
291
+ }
292
+ const mediaDir = join(flintPath, "Media");
293
+ if (await exists(mediaDir)) {
294
+ const matches = await findFilesRecursively(mediaDir, basename(target));
295
+ if (matches.length > 0 && matches[0]) {
296
+ collected.add(matches[0]);
297
+ }
298
+ }
299
+ }
300
+ }
275
301
  async function buildExport(manifest, flintPath) {
276
302
  const exportsDir = join(flintPath, "Exports");
277
- const outputDir = join(exportsDir, `(Mesh) ${manifest.name}`);
303
+ const outputDir = join(exportsDir, `(Mesh Export) ${manifest.name}`);
304
+ const meshOutputDir = join(outputDir, "Mesh");
305
+ const mediaOutputDir = join(outputDir, "Media");
278
306
  if (await exists(outputDir)) {
279
307
  await rm(outputDir, { recursive: true });
280
308
  }
281
- await mkdir(outputDir, { recursive: true });
309
+ await mkdir(meshOutputDir, { recursive: true });
310
+ const config = await readFlintToml(flintPath);
282
311
  const folderName = basename(flintPath);
283
- const flintName = folderName.replace(/^\(Mesh\)\s*/, "").replace(/^\(Flint\)\s*/, "");
312
+ const flintName = config?.flint?.name || folderName.replace(/^\(Mesh\)\s*/, "").replace(/^\(Flint\)\s*/, "");
284
313
  const resolvedFiles = [];
285
314
  const processedPaths = /* @__PURE__ */ new Set();
286
315
  processedPaths.add(manifest.sourcePath);
@@ -306,6 +335,12 @@ async function buildExport(manifest, flintPath) {
306
335
  processedPaths.add(refPath);
307
336
  }
308
337
  }
338
+ const mediaFiles = /* @__PURE__ */ new Set();
339
+ await collectMediaFiles(exportContent, flintPath, mediaFiles);
340
+ for (const { sourcePath } of resolvedFiles) {
341
+ const content = await readFile(sourcePath, "utf-8");
342
+ await collectMediaFiles(content, flintPath, mediaFiles);
343
+ }
309
344
  const allExportFiles = [
310
345
  { sourcePath: manifest.sourcePath, baseName: basename(manifest.sourcePath, ".md") },
311
346
  ...resolvedFiles.map((f) => ({ sourcePath: f.sourcePath, baseName: basename(f.sourcePath, ".md") }))
@@ -319,37 +354,48 @@ async function buildExport(manifest, flintPath) {
319
354
  );
320
355
  const exportNameBySourcePath = /* @__PURE__ */ new Map();
321
356
  for (const { sourcePath, baseName } of allExportFiles) {
322
- const exportName = duplicateBaseNames.has(baseName) ? getDisambiguatedExportName(flintPath, sourcePath, baseName) : baseName;
323
- exportNameBySourcePath.set(sourcePath, exportName);
357
+ const name = duplicateBaseNames.has(baseName) ? getDisambiguatedExportName(flintPath, sourcePath, baseName) : baseName;
358
+ exportNameBySourcePath.set(sourcePath, name);
324
359
  }
360
+ const dotPrefix = `(Flint) ${flintName} . (Mesh Export) ${manifest.name}`;
325
361
  let filesCopied = 0;
326
362
  const copiedFiles = [];
327
363
  const resolveCache = /* @__PURE__ */ new Map();
328
364
  let rootContent = await readFile(manifest.sourcePath, "utf-8");
329
365
  rootContent = stripFrontmatter(rootContent);
330
366
  rootContent = await expandEmbeds(rootContent, flintPath, /* @__PURE__ */ new Set([manifest.sourcePath]));
331
- rootContent = await rewriteWikilinks(rootContent, flintName, flintPath, exportNameBySourcePath, resolveCache);
367
+ rootContent = await rewriteWikilinks(rootContent, flintName, manifest.name, flintPath, exportNameBySourcePath, resolveCache);
332
368
  const rootExportName = exportNameBySourcePath.get(manifest.sourcePath) || manifest.name;
333
- const rootFileName = `Export - (${flintName}) ${rootExportName}.md`;
334
- await writeFile(join(outputDir, rootFileName), rootContent);
335
- copiedFiles.push(rootFileName);
369
+ const rootFileName = `${dotPrefix} - ${rootExportName}.md`;
370
+ await writeFile(join(meshOutputDir, rootFileName), rootContent);
371
+ copiedFiles.push(`Mesh/${rootFileName}`);
336
372
  filesCopied++;
337
373
  for (const { sourcePath } of resolvedFiles) {
338
374
  const exportBaseName = exportNameBySourcePath.get(sourcePath) || basename(sourcePath, ".md");
339
- const prefixedName = `Export - (${flintName}) ${exportBaseName}.md`;
340
- const destPath = join(outputDir, prefixedName);
375
+ const fileName = `${dotPrefix} - ${exportBaseName}.md`;
376
+ const destPath = join(meshOutputDir, fileName);
341
377
  let content = await readFile(sourcePath, "utf-8");
342
378
  content = stripFrontmatter(content);
343
379
  content = await expandEmbeds(content, flintPath, /* @__PURE__ */ new Set([sourcePath]));
344
- content = await rewriteWikilinks(content, flintName, flintPath, exportNameBySourcePath, resolveCache);
380
+ content = await rewriteWikilinks(content, flintName, manifest.name, flintPath, exportNameBySourcePath, resolveCache);
345
381
  await writeFile(destPath, content);
346
- copiedFiles.push(prefixedName);
382
+ copiedFiles.push(`Mesh/${fileName}`);
347
383
  filesCopied++;
348
384
  }
385
+ if (mediaFiles.size > 0) {
386
+ await mkdir(mediaOutputDir, { recursive: true });
387
+ for (const mediaPath of mediaFiles) {
388
+ const originalName = basename(mediaPath);
389
+ const mediaFileName = `${dotPrefix} - ${originalName}`;
390
+ await copyFile(mediaPath, join(mediaOutputDir, mediaFileName));
391
+ copiedFiles.push(`Media/${mediaFileName}`);
392
+ filesCopied++;
393
+ }
394
+ }
349
395
  const manifestJson = {
350
396
  name: manifest.name,
351
397
  flint: flintName,
352
- rootFile: rootFileName,
398
+ rootFile: `Mesh/${rootFileName}`,
353
399
  builtAt: (/* @__PURE__ */ new Date()).toISOString(),
354
400
  files: copiedFiles
355
401
  };
@@ -378,22 +424,13 @@ async function cleanupStaleExports(flintPath) {
378
424
  return removed;
379
425
  }
380
426
  const manifests = await scanExports(flintPath);
381
- const validFolderNames = new Set(manifests.map((m) => `(Mesh) ${m.name}`));
382
- const validLegacyNames = new Set(manifests.map((m) => m.name));
427
+ const validFolderNames = new Set(manifests.map((m) => `(Mesh Export) ${m.name}`));
383
428
  const entries = await readdir(exportsDir, { withFileTypes: true });
384
429
  for (const entry of entries) {
385
- if (entry.isDirectory()) {
386
- if (!validFolderNames.has(entry.name) && !validLegacyNames.has(entry.name)) {
387
- try {
388
- await rm(join(exportsDir, entry.name), { recursive: true });
389
- removed.push(entry.name);
390
- } catch {
391
- }
392
- }
393
- } else if (entry.isFile() && entry.name.endsWith(".md")) {
430
+ if (entry.isDirectory() && !validFolderNames.has(entry.name)) {
394
431
  try {
395
- await rm(join(exportsDir, entry.name));
396
- removed.push(`${entry.name} (legacy manifest)`);
432
+ await rm(join(exportsDir, entry.name), { recursive: true });
433
+ removed.push(entry.name);
397
434
  } catch {
398
435
  }
399
436
  }
@@ -1,7 +1,3 @@
1
- // ../../packages/flint/dist/chunk-HP5CLO2G.js
2
- import { readFile, writeFile, stat, mkdir } from "fs/promises";
3
- import { join as pathJoin } from "path";
4
-
5
1
  // ../../node_modules/.pnpm/smol-toml@1.6.0/node_modules/smol-toml/dist/error.js
6
2
  function getLineColFromPtr(string, ptr) {
7
3
  let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
@@ -828,7 +824,9 @@ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
828
824
  return str;
829
825
  }
830
826
 
831
- // ../../packages/flint/dist/chunk-HP5CLO2G.js
827
+ // ../../packages/flint/dist/chunk-2MJMC5SY.js
828
+ import { readFile, writeFile, stat, mkdir } from "fs/promises";
829
+ import { join as pathJoin } from "path";
832
830
  import { randomUUID } from "crypto";
833
831
  var join = pathJoin;
834
832
  function resolveShardMode(decl) {
@@ -840,10 +838,20 @@ function isLocalShard(decl) {
840
838
  }
841
839
  var FLINT_CONFIG_FILENAME = "flint.toml";
842
840
  var FLINT_JSON_FILENAME = "flint.json";
843
- var FLINT_VERSION = "0.3.0";
841
+ var FLINT_VERSION = "0.4.0";
844
842
  function toKebabCase(name) {
845
843
  return name.replace(/\([^)]*\)\s*/g, "").toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "").replace(/^-+|-+$/g, "");
846
844
  }
845
+ function toSnakeCase(name) {
846
+ return name.replace(/\([^)]*\)\s*/g, "").toLowerCase().replace(/\s+/g, "_").replace(/[^a-z0-9_]/g, "").replace(/^_+|_+$/g, "");
847
+ }
848
+ function nameFormats(name) {
849
+ return {
850
+ proper: name,
851
+ slug: toKebabCase(name),
852
+ snake: toSnakeCase(name)
853
+ };
854
+ }
847
855
  function getFlintConfigPath(flintPath) {
848
856
  return join(flintPath, FLINT_CONFIG_FILENAME);
849
857
  }
@@ -1001,6 +1009,7 @@ function formatFlintToml(config) {
1001
1009
  for (const [shorthand, decl] of Object.entries(declarations)) {
1002
1010
  const mode = resolveShardMode(decl);
1003
1011
  const fields = { source: decl.source };
1012
+ if (decl.version) fields.version = decl.version;
1004
1013
  if (mode) fields.mode = mode;
1005
1014
  lines.push(`${shorthand} = ${inlineTable(fields)}`);
1006
1015
  }
@@ -1017,42 +1026,37 @@ function formatFlintToml(config) {
1017
1026
  lines.push(`required = ${inlineTableArray(items).join("\n")}`);
1018
1027
  lines.push("");
1019
1028
  }
1020
- const flintImports = config.imports?.flints || config.imports?.required || [];
1021
- if (flintImports.length) {
1022
- lines.push("[imports]");
1023
- lines.push(`flints = ${stringArray(flintImports).join("\n")}`);
1024
- lines.push("");
1025
- }
1026
- const hasRefs = config.workspace?.references?.length;
1027
- const hasRepos = config.workspace?.repositories?.length;
1028
- const hasSrcRepos = config.workspace?.sources?.repositories?.length;
1029
- if (hasRefs || hasRepos) {
1030
- lines.push("[workspace]");
1031
- if (hasRefs) {
1032
- const items = config.workspace.references.map((r) => ({ name: r.name, type: r.type }));
1033
- lines.push(`references = ${inlineTableArray(items).join("\n")}`);
1034
- }
1035
- if (hasRepos) {
1036
- const items = config.workspace.repositories.map((r) => ({ name: r.name, url: r.url }));
1029
+ const hasSourceRepositories = Boolean(config.sources?.repositories?.length);
1030
+ const hasMeshExportSources = Boolean(config.sources?.meshexports?.length);
1031
+ if (hasSourceRepositories || hasMeshExportSources) {
1032
+ lines.push("[sources]");
1033
+ if (hasSourceRepositories) {
1034
+ const items = config.sources.repositories.map((r) => ({ name: r.name, url: r.url }));
1037
1035
  lines.push(`repositories = ${inlineTableArray(items).join("\n")}`);
1038
1036
  }
1037
+ if (hasMeshExportSources) {
1038
+ lines.push(`meshexports = ${stringArray(config.sources.meshexports).join("\n")}`);
1039
+ }
1039
1040
  lines.push("");
1040
1041
  }
1041
- if (hasSrcRepos) {
1042
- lines.push("[workspace.sources]");
1043
- const items = config.workspace.sources.repositories.map((r) => ({ name: r.name, url: r.url }));
1042
+ if (config.workspace?.repositories?.length) {
1043
+ lines.push("[workspace]");
1044
+ const items = config.workspace.repositories.map((r) => ({ name: r.name, url: r.url }));
1044
1045
  lines.push(`repositories = ${inlineTableArray(items).join("\n")}`);
1045
1046
  lines.push("");
1046
1047
  }
1047
- if (config.connections?.flints?.length) {
1048
- lines.push("[connections]");
1049
- const items = config.connections.flints.map((c) => ({ name: c.name }));
1050
- lines.push(`flints = ${inlineTableArray(items).join("\n")}`);
1051
- lines.push("");
1052
- }
1053
- if (config.git?.remote) {
1054
- lines.push("[git]");
1055
- lines.push(`remote = ${tv(config.git.remote)}`);
1048
+ const hasRefCodebases = config.references?.codebases?.length;
1049
+ const hasRefFlints = config.references?.flints?.length;
1050
+ if (hasRefCodebases || hasRefFlints) {
1051
+ lines.push("[references]");
1052
+ if (hasRefCodebases) {
1053
+ const items = config.references.codebases.map((c) => ({ name: c.name }));
1054
+ lines.push(`codebases = ${inlineTableArray(items).join("\n")}`);
1055
+ }
1056
+ if (hasRefFlints) {
1057
+ const items = config.references.flints.map((f) => ({ name: f.name }));
1058
+ lines.push(`flints = ${inlineTableArray(items).join("\n")}`);
1059
+ }
1056
1060
  lines.push("");
1057
1061
  }
1058
1062
  if (config.lattices?.references?.length) {
@@ -1061,7 +1065,7 @@ function formatFlintToml(config) {
1061
1065
  lines.push(`references = ${inlineTableArray(items).join("\n")}`);
1062
1066
  lines.push("");
1063
1067
  }
1064
- const knownKeys = /* @__PURE__ */ new Set(["flint", "shards", "exports", "imports", "workspace", "connections", "git", "lattices"]);
1068
+ const knownKeys = /* @__PURE__ */ new Set(["flint", "shards", "exports", "imports", "sources", "workspace", "connections", "references", "lattices"]);
1065
1069
  const unknownKeys = Object.keys(config).filter((k) => !knownKeys.has(k));
1066
1070
  if (unknownKeys.length > 0) {
1067
1071
  const unknownConfig = {};
@@ -1094,8 +1098,9 @@ async function addShardToConfig(flintPath, shardName, source, options = {}) {
1094
1098
  const declarations = getShardDeclarationsFromConfig(config);
1095
1099
  const existing = declarations[kebabName];
1096
1100
  const effectiveSource = source || kebabName;
1097
- if (!existing || existing.source !== effectiveSource) {
1101
+ if (!existing || existing.source !== effectiveSource || options.version !== existing?.version) {
1098
1102
  const decl = { source: effectiveSource };
1103
+ if (options.version) decl.version = options.version;
1099
1104
  if (options.mode) decl.mode = options.mode;
1100
1105
  config.shards[kebabName] = decl;
1101
1106
  await writeFlintToml(flintPath, config);
@@ -1173,43 +1178,6 @@ async function hasFlintToml(flintPath) {
1173
1178
  async function isFlint(flintPath) {
1174
1179
  return hasFlintToml(flintPath);
1175
1180
  }
1176
- async function addWorkspaceReference(flintPath, name, type = "codebase") {
1177
- let config = await readFlintToml(flintPath);
1178
- if (!config) {
1179
- throw new Error("flint.toml not found");
1180
- }
1181
- if (!config.workspace) {
1182
- config.workspace = {};
1183
- }
1184
- if (!config.workspace.references) {
1185
- config.workspace.references = [];
1186
- }
1187
- const existing = config.workspace.references.find((r) => r.name.toLowerCase() === name.toLowerCase());
1188
- if (existing) {
1189
- throw new Error(`Workspace reference "${name}" already exists`);
1190
- }
1191
- config.workspace.references.push({ name, type });
1192
- await writeFlintToml(flintPath, config);
1193
- }
1194
- async function removeWorkspaceReference(flintPath, name) {
1195
- let config = await readFlintToml(flintPath);
1196
- if (!config?.workspace?.references) return false;
1197
- const normalizedName = name.toLowerCase();
1198
- const index = config.workspace.references.findIndex((r) => r.name.toLowerCase() === normalizedName);
1199
- if (index === -1) return false;
1200
- config.workspace.references.splice(index, 1);
1201
- await writeFlintToml(flintPath, config);
1202
- return true;
1203
- }
1204
- async function getWorkspaceReferences(flintPath) {
1205
- const config = await readFlintToml(flintPath);
1206
- return config?.workspace?.references || [];
1207
- }
1208
- async function getWorkspaceReference(flintPath, name) {
1209
- const config = await readFlintToml(flintPath);
1210
- const normalizedName = name.toLowerCase();
1211
- return config?.workspace?.references?.find((r) => r.name.toLowerCase() === normalizedName) || null;
1212
- }
1213
1181
  async function addWorkspaceRepository(flintPath, name, url) {
1214
1182
  let config = await readFlintToml(flintPath);
1215
1183
  if (!config) {
@@ -1247,45 +1215,42 @@ async function getWorkspaceRepository(flintPath, name) {
1247
1215
  const normalizedName = name.toLowerCase();
1248
1216
  return config?.workspace?.repositories?.find((r) => r.name.toLowerCase() === normalizedName) || null;
1249
1217
  }
1250
- async function addWorkspaceSourceRepository(flintPath, name, url) {
1251
- let config = await readFlintToml(flintPath);
1218
+ async function addSourceRepository(flintPath, name, url) {
1219
+ const config = await readFlintToml(flintPath);
1252
1220
  if (!config) {
1253
1221
  throw new Error("flint.toml not found");
1254
1222
  }
1255
- if (!config.workspace) {
1256
- config.workspace = {};
1257
- }
1258
- if (!config.workspace.sources) {
1259
- config.workspace.sources = {};
1223
+ if (!config.sources) {
1224
+ config.sources = {};
1260
1225
  }
1261
- if (!config.workspace.sources.repositories) {
1262
- config.workspace.sources.repositories = [];
1226
+ if (!config.sources.repositories) {
1227
+ config.sources.repositories = [];
1263
1228
  }
1264
- const existing = config.workspace.sources.repositories.find((r) => r.name.toLowerCase() === name.toLowerCase());
1229
+ const existing = config.sources.repositories.find((r) => r.name.toLowerCase() === name.toLowerCase());
1265
1230
  if (existing) {
1266
1231
  throw new Error(`Source repository "${name}" already exists`);
1267
1232
  }
1268
- config.workspace.sources.repositories.push({ name, url });
1233
+ config.sources.repositories.push({ name, url });
1269
1234
  await writeFlintToml(flintPath, config);
1270
1235
  }
1271
- async function removeWorkspaceSourceRepository(flintPath, name) {
1272
- let config = await readFlintToml(flintPath);
1273
- if (!config?.workspace?.sources?.repositories) return false;
1236
+ async function removeSourceRepository(flintPath, name) {
1237
+ const config = await readFlintToml(flintPath);
1238
+ if (!config?.sources?.repositories) return false;
1274
1239
  const normalizedName = name.toLowerCase();
1275
- const index = config.workspace.sources.repositories.findIndex((r) => r.name.toLowerCase() === normalizedName);
1240
+ const index = config.sources.repositories.findIndex((r) => r.name.toLowerCase() === normalizedName);
1276
1241
  if (index === -1) return false;
1277
- config.workspace.sources.repositories.splice(index, 1);
1242
+ config.sources.repositories.splice(index, 1);
1278
1243
  await writeFlintToml(flintPath, config);
1279
1244
  return true;
1280
1245
  }
1281
- async function getWorkspaceSourceRepositories(flintPath) {
1246
+ async function getSourceRepositories(flintPath) {
1282
1247
  const config = await readFlintToml(flintPath);
1283
- return config?.workspace?.sources?.repositories || [];
1248
+ return config?.sources?.repositories || [];
1284
1249
  }
1285
- async function getWorkspaceSourceRepository(flintPath, name) {
1250
+ async function getSourceRepository(flintPath, name) {
1286
1251
  const config = await readFlintToml(flintPath);
1287
1252
  const normalizedName = name.toLowerCase();
1288
- return config?.workspace?.sources?.repositories?.find((r) => r.name.toLowerCase() === normalizedName) || null;
1253
+ return config?.sources?.repositories?.find((r) => r.name.toLowerCase() === normalizedName) || null;
1289
1254
  }
1290
1255
  function getLatticesStatePath(flintPath) {
1291
1256
  return pathJoin(flintPath, ".flint", "lattices.json");
@@ -1422,54 +1387,42 @@ async function getExportDeclarations(flintPath) {
1422
1387
  const config = await readFlintToml(flintPath);
1423
1388
  return config?.exports?.required || [];
1424
1389
  }
1425
- function resolveFlintImports(config) {
1426
- return config.imports?.flints || config.imports?.required || [];
1427
- }
1428
- function ensureFlintImports(config) {
1429
- if (!config.imports) {
1430
- config.imports = { flints: [] };
1431
- }
1432
- if (config.imports.required && !config.imports.flints) {
1433
- config.imports.flints = config.imports.required;
1434
- }
1435
- delete config.imports.required;
1436
- if (!config.imports.flints) {
1437
- config.imports.flints = [];
1438
- }
1439
- return config.imports.flints;
1390
+ async function getMeshExportSources(flintPath) {
1391
+ const config = await readFlintToml(flintPath);
1392
+ return config?.sources?.meshexports || [];
1440
1393
  }
1441
- async function addImportToConfig(flintPath, ref) {
1442
- let config = await readFlintToml(flintPath);
1394
+ async function addMeshExportToConfig(flintPath, ref) {
1395
+ const config = await readFlintToml(flintPath);
1443
1396
  if (!config) {
1444
1397
  throw new Error("flint.toml not found");
1445
1398
  }
1446
- const flints = ensureFlintImports(config);
1447
- if (!flints.includes(ref)) {
1448
- flints.push(ref);
1399
+ if (!config.sources) {
1400
+ config.sources = {};
1401
+ }
1402
+ if (!config.sources.meshexports) {
1403
+ config.sources.meshexports = [];
1404
+ }
1405
+ if (!config.sources.meshexports.includes(ref)) {
1406
+ config.sources.meshexports.push(ref);
1449
1407
  await writeFlintToml(flintPath, config);
1450
1408
  }
1451
1409
  }
1452
- async function removeImportFromConfig(flintPath, ref) {
1453
- let config = await readFlintToml(flintPath);
1454
- if (!config) return false;
1455
- const flints = ensureFlintImports(config);
1456
- const index = flints.indexOf(ref);
1410
+ async function removeMeshExportFromConfig(flintPath, ref) {
1411
+ const config = await readFlintToml(flintPath);
1412
+ if (!config?.sources?.meshexports) return false;
1413
+ const meshexports = config.sources.meshexports;
1414
+ const index = meshexports.indexOf(ref);
1457
1415
  if (index === -1) {
1458
1416
  const lowerRef = ref.toLowerCase();
1459
- const foundIndex = flints.findIndex((r) => r.toLowerCase() === lowerRef);
1417
+ const foundIndex = meshexports.findIndex((r) => r.toLowerCase() === lowerRef);
1460
1418
  if (foundIndex === -1) return false;
1461
- flints.splice(foundIndex, 1);
1419
+ meshexports.splice(foundIndex, 1);
1462
1420
  } else {
1463
- flints.splice(index, 1);
1421
+ meshexports.splice(index, 1);
1464
1422
  }
1465
1423
  await writeFlintToml(flintPath, config);
1466
1424
  return true;
1467
1425
  }
1468
- async function getFlintImports(flintPath) {
1469
- const config = await readFlintToml(flintPath);
1470
- if (!config) return [];
1471
- return resolveFlintImports(config);
1472
- }
1473
1426
 
1474
1427
  export {
1475
1428
  parse,
@@ -1480,6 +1433,8 @@ export {
1480
1433
  FLINT_JSON_FILENAME,
1481
1434
  FLINT_VERSION,
1482
1435
  toKebabCase,
1436
+ toSnakeCase,
1437
+ nameFormats,
1483
1438
  getFlintConfigPath,
1484
1439
  getFlintJsonPath,
1485
1440
  createFlintToml,
@@ -1502,18 +1457,14 @@ export {
1502
1457
  migrateShardConfig,
1503
1458
  hasFlintToml,
1504
1459
  isFlint,
1505
- addWorkspaceReference,
1506
- removeWorkspaceReference,
1507
- getWorkspaceReferences,
1508
- getWorkspaceReference,
1509
1460
  addWorkspaceRepository,
1510
1461
  removeWorkspaceRepository,
1511
1462
  getWorkspaceRepositories,
1512
1463
  getWorkspaceRepository,
1513
- addWorkspaceSourceRepository,
1514
- removeWorkspaceSourceRepository,
1515
- getWorkspaceSourceRepositories,
1516
- getWorkspaceSourceRepository,
1464
+ addSourceRepository,
1465
+ removeSourceRepository,
1466
+ getSourceRepositories,
1467
+ getSourceRepository,
1517
1468
  readLatticesState,
1518
1469
  addLatticeDeclaration,
1519
1470
  removeLatticeDeclaration,
@@ -1528,9 +1479,9 @@ export {
1528
1479
  addExportToConfig,
1529
1480
  removeExportFromConfig,
1530
1481
  getExportDeclarations,
1531
- addImportToConfig,
1532
- removeImportFromConfig,
1533
- getFlintImports
1482
+ getMeshExportSources,
1483
+ addMeshExportToConfig,
1484
+ removeMeshExportFromConfig
1534
1485
  };
1535
1486
  /*! Bundled license information:
1536
1487