@nuucognition/flint-cli 0.2.0-beta.0 → 0.2.0-beta.2

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/bin/flint-prod.js CHANGED
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { fileURLToPath } from 'node:url';
3
+ process.env.BUILD_MODE = 'prod';
4
+
5
+ import { fileURLToPath, pathToFileURL } from 'node:url';
4
6
  import { dirname, join } from 'node:path';
5
7
 
6
8
  const __dirname = dirname(fileURLToPath(import.meta.url));
7
- await import(join(__dirname, '..', 'dist', 'index.js'));
9
+ await import(pathToFileURL(join(__dirname, '..', 'dist', 'index.js')).href);
package/bin/flint.js CHANGED
File without changes
@@ -1,4 +1,4 @@
1
- // ../../packages/flint/src/exports.ts
1
+ // ../../packages/flint/dist/chunk-CKCIJQXP.js
2
2
  import { readdir, readFile, mkdir, writeFile, rm, stat } from "fs/promises";
3
3
  import { join, basename, dirname, resolve, relative, sep } from "path";
4
4
  async function exists(path) {
@@ -224,6 +224,31 @@ function getDisambiguatedExportName(flintPath, sourcePath, baseName) {
224
224
  return `${baseName} (${dirLabel})`;
225
225
  }
226
226
  async function scanExports(flintPath) {
227
+ const { readFlintToml } = await import("./mesh-config-J6WB4RFV-G7RGPOZA.js");
228
+ const config = await readFlintToml(flintPath);
229
+ const declarations = config?.exports?.required;
230
+ if (declarations && declarations.length > 0) {
231
+ return scanExportsFromConfig(flintPath, declarations);
232
+ }
233
+ return scanExportsLegacy(flintPath);
234
+ }
235
+ async function scanExportsFromConfig(flintPath, declarations) {
236
+ const manifests = [];
237
+ for (const decl of declarations) {
238
+ const sourcePath = await resolveDocument(decl.file.replace(/\.md$/, ""), flintPath);
239
+ if (!sourcePath) continue;
240
+ try {
241
+ const content = await readFile(sourcePath, "utf-8");
242
+ const depth = decl.depth ?? (decl.mode === "mesh" ? 1 : 1);
243
+ const manifest = parseExportDocument(content, decl.name, sourcePath);
244
+ manifest.depth = depth;
245
+ manifests.push(manifest);
246
+ } catch {
247
+ }
248
+ }
249
+ return manifests;
250
+ }
251
+ async function scanExportsLegacy(flintPath) {
227
252
  const meshDir = join(flintPath, "Mesh");
228
253
  if (!await exists(meshDir)) {
229
254
  return [];
@@ -242,9 +267,49 @@ async function scanExports(flintPath) {
242
267
  }
243
268
  return manifests;
244
269
  }
270
+ async function scanExportEligible(flintPath) {
271
+ const meshDir = join(flintPath, "Mesh");
272
+ if (!await exists(meshDir)) return [];
273
+ const { readFlintToml } = await import("./mesh-config-J6WB4RFV-G7RGPOZA.js");
274
+ const config = await readFlintToml(flintPath);
275
+ const declared = new Set(
276
+ (config?.exports?.required || []).map((d) => d.file.replace(/\.md$/, "").toLowerCase())
277
+ );
278
+ const eligible = [];
279
+ await findExportTaggedFiles(meshDir, flintPath, declared, eligible);
280
+ return eligible;
281
+ }
282
+ async function findExportTaggedFiles(dir, flintPath, declared, results) {
283
+ try {
284
+ const entries = await readdir(dir, { withFileTypes: true });
285
+ for (const entry of entries) {
286
+ const fullPath = join(dir, entry.name);
287
+ if (entry.isDirectory()) {
288
+ await findExportTaggedFiles(fullPath, flintPath, declared, results);
289
+ } else if (entry.isFile() && entry.name.endsWith(".md")) {
290
+ try {
291
+ const content = await readFile(fullPath, "utf-8");
292
+ const fmMatch = content.match(/^---\n([\s\S]*?)\n---/);
293
+ if (!fmMatch || !fmMatch[1]) continue;
294
+ const hasExportTag = /["']#export["']/.test(fmMatch[1]);
295
+ if (!hasExportTag) continue;
296
+ const fileName = basename(fullPath, ".md");
297
+ if (declared.has(fileName.toLowerCase())) continue;
298
+ results.push({
299
+ filePath: fullPath,
300
+ fileName: entry.name,
301
+ name: fileName
302
+ });
303
+ } catch {
304
+ }
305
+ }
306
+ }
307
+ } catch {
308
+ }
309
+ }
245
310
  async function buildExport(manifest, flintPath) {
246
311
  const exportsDir = join(flintPath, "Exports");
247
- const outputDir = join(exportsDir, manifest.name);
312
+ const outputDir = join(exportsDir, `(Mesh) ${manifest.name}`);
248
313
  if (await exists(outputDir)) {
249
314
  await rm(outputDir, { recursive: true });
250
315
  }
@@ -254,13 +319,15 @@ async function buildExport(manifest, flintPath) {
254
319
  const resolvedFiles = [];
255
320
  const processedPaths = /* @__PURE__ */ new Set();
256
321
  processedPaths.add(manifest.sourcePath);
257
- for (const docRef of manifest.files) {
258
- const sourcePath = await resolveDocument(docRef, flintPath);
259
- if (!sourcePath || processedPaths.has(sourcePath)) continue;
260
- resolvedFiles.push({ sourcePath, docRef });
261
- processedPaths.add(sourcePath);
262
- }
263
322
  const depth = manifest.depth;
323
+ if (depth === -1 || depth > 0) {
324
+ for (const docRef of manifest.files) {
325
+ const sourcePath = await resolveDocument(docRef, flintPath);
326
+ if (!sourcePath || processedPaths.has(sourcePath)) continue;
327
+ resolvedFiles.push({ sourcePath, docRef });
328
+ processedPaths.add(sourcePath);
329
+ }
330
+ }
264
331
  const allReferencedFiles = /* @__PURE__ */ new Set();
265
332
  const exportContent = await readFile(manifest.sourcePath, "utf-8");
266
333
  await collectReferencedFiles(exportContent, flintPath, allReferencedFiles, new Set(processedPaths), depth, 0);
@@ -275,7 +342,7 @@ async function buildExport(manifest, flintPath) {
275
342
  }
276
343
  }
277
344
  const allExportFiles = [
278
- { sourcePath: manifest.sourcePath, baseName: manifest.name },
345
+ { sourcePath: manifest.sourcePath, baseName: basename(manifest.sourcePath, ".md") },
279
346
  ...resolvedFiles.map((f) => ({ sourcePath: f.sourcePath, baseName: basename(f.sourcePath, ".md") }))
280
347
  ];
281
348
  const baseNameCounts = /* @__PURE__ */ new Map();
@@ -317,6 +384,7 @@ async function buildExport(manifest, flintPath) {
317
384
  const manifestJson = {
318
385
  name: manifest.name,
319
386
  flint: flintName,
387
+ rootFile: rootFileName,
320
388
  builtAt: (/* @__PURE__ */ new Date()).toISOString(),
321
389
  files: copiedFiles
322
390
  };
@@ -345,11 +413,12 @@ async function cleanupStaleExports(flintPath) {
345
413
  return removed;
346
414
  }
347
415
  const manifests = await scanExports(flintPath);
348
- const validExportNames = new Set(manifests.map((m) => m.name));
416
+ const validFolderNames = new Set(manifests.map((m) => `(Mesh) ${m.name}`));
417
+ const validLegacyNames = new Set(manifests.map((m) => m.name));
349
418
  const entries = await readdir(exportsDir, { withFileTypes: true });
350
419
  for (const entry of entries) {
351
420
  if (entry.isDirectory()) {
352
- if (!validExportNames.has(entry.name)) {
421
+ if (!validFolderNames.has(entry.name) && !validLegacyNames.has(entry.name)) {
353
422
  try {
354
423
  await rm(join(exportsDir, entry.name), { recursive: true });
355
424
  removed.push(entry.name);
@@ -379,6 +448,7 @@ async function buildAllExports(flintPath) {
379
448
 
380
449
  export {
381
450
  scanExports,
451
+ scanExportEligible,
382
452
  buildExport,
383
453
  buildExportByName,
384
454
  cleanupStaleExports,
@@ -1,4 +1,4 @@
1
- // ../../packages/flint/src/mesh-config.ts
1
+ // ../../packages/flint/dist/chunk-2WZYXQX5.js
2
2
  import { readFile, writeFile, stat } from "fs/promises";
3
3
  import { join } from "path";
4
4
 
@@ -828,8 +828,15 @@ function stringify(obj, { maxDepth = 1e3, numbersAsFloat = false } = {}) {
828
828
  return str;
829
829
  }
830
830
 
831
- // ../../packages/flint/src/mesh-config.ts
831
+ // ../../packages/flint/dist/chunk-2WZYXQX5.js
832
832
  import { randomUUID } from "crypto";
833
+ function resolveShardMode(decl) {
834
+ return decl.mode;
835
+ }
836
+ function isLocalShard(decl) {
837
+ const mode = resolveShardMode(decl);
838
+ return mode === "dev" || mode === "custom";
839
+ }
833
840
  var FLINT_CONFIG_FILENAME = "flint.toml";
834
841
  var FLINT_JSON_FILENAME = "flint.json";
835
842
  var FLINT_VERSION = "0.2.0";
@@ -964,26 +971,49 @@ async function readFlintToml(flintPath) {
964
971
  throw error;
965
972
  }
966
973
  }
974
+ function tv(v) {
975
+ if (typeof v === "string") return `"${v}"`;
976
+ if (typeof v === "boolean") return v ? "true" : "false";
977
+ if (typeof v === "number") return String(v);
978
+ if (Array.isArray(v)) return `[${v.map(tv).join(", ")}]`;
979
+ return String(v);
980
+ }
981
+ function inlineTable(obj) {
982
+ const parts = Object.entries(obj).filter(([, v]) => v !== void 0 && v !== null).map(([k, v]) => `${k} = ${tv(v)}`);
983
+ return `{ ${parts.join(", ")} }`;
984
+ }
985
+ function inlineTableArray(items) {
986
+ return [
987
+ "[",
988
+ ...items.map((item) => ` ${inlineTable(item)},`),
989
+ "]"
990
+ ];
991
+ }
992
+ function stringArray(items) {
993
+ return [
994
+ "[",
995
+ ...items.map((s) => ` "${s}",`),
996
+ "]"
997
+ ];
998
+ }
967
999
  function formatFlintToml(config) {
968
1000
  const lines = [];
969
1001
  lines.push("[flint]");
970
- lines.push(`name = "${config.flint.name}"`);
971
- if (config.flint.type) {
972
- lines.push(`type = "${config.flint.type}"`);
973
- }
974
- if (config.flint.description) {
975
- lines.push(`description = "${config.flint.description}"`);
976
- }
977
- if (config.flint.tags && config.flint.tags.length > 0) {
978
- lines.push(`tags = [${config.flint.tags.map((t) => `"${t}"`).join(", ")}]`);
979
- }
1002
+ lines.push(`name = ${tv(config.flint.name)}`);
1003
+ if (config.flint.type) lines.push(`type = ${tv(config.flint.type)}`);
1004
+ if (config.flint.description) lines.push(`description = ${tv(config.flint.description)}`);
1005
+ if (config.flint.tags?.length) lines.push(`tags = ${tv(config.flint.tags)}`);
1006
+ if (config.flint.org) lines.push(`org = ${tv(config.flint.org)}`);
980
1007
  lines.push("");
981
1008
  if (config.shards) {
982
1009
  const declarations = getShardDeclarationsFromConfig(config);
983
1010
  if (Object.keys(declarations).length > 0) {
984
1011
  lines.push("[shards]");
985
1012
  for (const [shorthand, decl] of Object.entries(declarations)) {
986
- lines.push(`${shorthand} = { source = "${decl.source}"${decl.dev ? ", dev = true" : ""} }`);
1013
+ const mode = resolveShardMode(decl);
1014
+ const fields = { source: decl.source };
1015
+ if (mode) fields.mode = mode;
1016
+ lines.push(`${shorthand} = ${inlineTable(fields)}`);
987
1017
  }
988
1018
  lines.push("");
989
1019
  }
@@ -993,68 +1023,70 @@ function formatFlintToml(config) {
993
1023
  if (Object.keys(modDeclarations).length > 0) {
994
1024
  lines.push("[mods]");
995
1025
  for (const [name, decl] of Object.entries(modDeclarations)) {
996
- lines.push(`${name} = { source = "${decl.source}"${decl.dev ? ", dev = true" : ""} }`);
1026
+ const fields = { source: decl.source };
1027
+ if (decl.dev) fields.dev = true;
1028
+ lines.push(`${name} = ${inlineTable(fields)}`);
997
1029
  }
998
1030
  lines.push("");
999
1031
  }
1000
1032
  }
1001
- if (config.imports?.required && config.imports.required.length > 0) {
1033
+ if (config.exports?.required?.length) {
1034
+ lines.push("[exports]");
1035
+ const items = config.exports.required.map((e) => {
1036
+ const fields = { name: e.name, file: e.file, mode: e.mode };
1037
+ if (e.depth !== void 0 && e.depth !== 1) fields.depth = e.depth;
1038
+ return fields;
1039
+ });
1040
+ lines.push(`required = ${inlineTableArray(items).join("\n")}`);
1041
+ lines.push("");
1042
+ }
1043
+ const flintImports = config.imports?.flints || config.imports?.required || [];
1044
+ if (flintImports.length) {
1002
1045
  lines.push("[imports]");
1003
- lines.push("required = [");
1004
- for (const ref of config.imports.required) {
1005
- lines.push(` "${ref}",`);
1006
- }
1007
- lines.push("]");
1046
+ lines.push(`flints = ${stringArray(flintImports).join("\n")}`);
1008
1047
  lines.push("");
1009
1048
  }
1010
- const hasReferences = config.workspace?.references && config.workspace.references.length > 0;
1011
- const hasRepositories = config.workspace?.repositories && config.workspace.repositories.length > 0;
1012
- const hasSourceRepositories = config.workspace?.sources?.repositories && config.workspace.sources.repositories.length > 0;
1013
- if (hasReferences || hasRepositories || hasSourceRepositories) {
1049
+ const hasRefs = config.workspace?.references?.length;
1050
+ const hasRepos = config.workspace?.repositories?.length;
1051
+ const hasSrcRepos = config.workspace?.sources?.repositories?.length;
1052
+ if (hasRefs || hasRepos) {
1014
1053
  lines.push("[workspace]");
1015
- if (hasReferences) {
1016
- lines.push("references = [");
1017
- for (const ref of config.workspace.references) {
1018
- lines.push(` { name = "${ref.name}", type = "${ref.type}" },`);
1019
- }
1020
- lines.push("]");
1054
+ if (hasRefs) {
1055
+ const items = config.workspace.references.map((r) => ({ name: r.name, type: r.type }));
1056
+ lines.push(`references = ${inlineTableArray(items).join("\n")}`);
1021
1057
  }
1022
- if (hasRepositories) {
1023
- lines.push("repositories = [");
1024
- for (const repo of config.workspace.repositories) {
1025
- lines.push(` { name = "${repo.name}", url = "${repo.url}" },`);
1026
- }
1027
- lines.push("]");
1058
+ if (hasRepos) {
1059
+ const items = config.workspace.repositories.map((r) => ({ name: r.name, url: r.url }));
1060
+ lines.push(`repositories = ${inlineTableArray(items).join("\n")}`);
1028
1061
  }
1029
1062
  lines.push("");
1030
1063
  }
1031
- if (hasSourceRepositories) {
1064
+ if (hasSrcRepos) {
1032
1065
  lines.push("[workspace.sources]");
1033
- lines.push("repositories = [");
1034
- for (const repo of config.workspace.sources.repositories) {
1035
- lines.push(` { name = "${repo.name}", url = "${repo.url}" },`);
1036
- }
1037
- lines.push("]");
1066
+ const items = config.workspace.sources.repositories.map((r) => ({ name: r.name, url: r.url }));
1067
+ lines.push(`repositories = ${inlineTableArray(items).join("\n")}`);
1038
1068
  lines.push("");
1039
1069
  }
1040
- if (config.connections?.flints && config.connections.flints.length > 0) {
1070
+ if (config.connections?.flints?.length) {
1041
1071
  lines.push("[connections]");
1042
- lines.push("flints = [");
1043
- for (const conn of config.connections.flints) {
1044
- lines.push(` { name = "${conn.name}" },`);
1045
- }
1046
- lines.push("]");
1072
+ const items = config.connections.flints.map((c) => ({ name: c.name }));
1073
+ lines.push(`flints = ${inlineTableArray(items).join("\n")}`);
1074
+ lines.push("");
1075
+ }
1076
+ if (config.git?.remote) {
1077
+ lines.push("[git]");
1078
+ lines.push(`remote = ${tv(config.git.remote)}`);
1047
1079
  lines.push("");
1048
1080
  }
1049
- if (config.lattices && config.lattices.length > 0) {
1081
+ if (config.lattices?.length) {
1050
1082
  for (const lattice of config.lattices) {
1051
1083
  lines.push("[[lattices]]");
1052
- lines.push(`name = "${lattice.name}"`);
1053
- lines.push(`path = "${lattice.path}"`);
1084
+ lines.push(`name = ${tv(lattice.name)}`);
1085
+ lines.push(`path = ${tv(lattice.path)}`);
1054
1086
  lines.push("");
1055
1087
  }
1056
1088
  }
1057
- const knownKeys = /* @__PURE__ */ new Set(["flint", "shards", "mods", "imports", "workspace", "connections", "lattices"]);
1089
+ const knownKeys = /* @__PURE__ */ new Set(["flint", "shards", "mods", "exports", "imports", "workspace", "connections", "git", "lattices"]);
1058
1090
  const unknownKeys = Object.keys(config).filter((k) => !knownKeys.has(k));
1059
1091
  if (unknownKeys.length > 0) {
1060
1092
  const unknownConfig = {};
@@ -1089,7 +1121,7 @@ async function addShardToConfig(flintPath, shardName, source, options = {}) {
1089
1121
  const effectiveSource = source || kebabName;
1090
1122
  if (!existing || existing.source !== effectiveSource) {
1091
1123
  const decl = { source: effectiveSource };
1092
- if (options.dev) decl.dev = true;
1124
+ if (options.mode) decl.mode = options.mode;
1093
1125
  config.shards[kebabName] = decl;
1094
1126
  await writeFlintToml(flintPath, config);
1095
1127
  }
@@ -1378,56 +1410,100 @@ async function getLatticeReference(flintPath, name) {
1378
1410
  const normalizedName = name.toLowerCase();
1379
1411
  return config?.lattices?.find((entry) => entry.name.toLowerCase() === normalizedName) || null;
1380
1412
  }
1381
- async function addImportToConfig(flintPath, ref) {
1413
+ async function addExportToConfig(flintPath, declaration) {
1382
1414
  let config = await readFlintToml(flintPath);
1383
1415
  if (!config) {
1384
1416
  throw new Error("flint.toml not found");
1385
1417
  }
1418
+ if (!config.exports) {
1419
+ config.exports = { required: [] };
1420
+ }
1421
+ if (!config.exports.required) {
1422
+ config.exports.required = [];
1423
+ }
1424
+ const existing = config.exports.required.find(
1425
+ (e) => e.name.toLowerCase() === declaration.name.toLowerCase()
1426
+ );
1427
+ if (existing) {
1428
+ throw new Error(`Export "${declaration.name}" already declared`);
1429
+ }
1430
+ config.exports.required.push({
1431
+ name: declaration.name,
1432
+ file: declaration.file,
1433
+ mode: declaration.mode,
1434
+ ...declaration.depth !== void 0 ? { depth: declaration.depth } : {}
1435
+ });
1436
+ await writeFlintToml(flintPath, config);
1437
+ }
1438
+ async function removeExportFromConfig(flintPath, exportName) {
1439
+ let config = await readFlintToml(flintPath);
1440
+ if (!config?.exports?.required) return false;
1441
+ const index = config.exports.required.findIndex(
1442
+ (e) => e.name.toLowerCase() === exportName.toLowerCase()
1443
+ );
1444
+ if (index === -1) return false;
1445
+ config.exports.required.splice(index, 1);
1446
+ await writeFlintToml(flintPath, config);
1447
+ return true;
1448
+ }
1449
+ async function getExportDeclarations(flintPath) {
1450
+ const config = await readFlintToml(flintPath);
1451
+ return config?.exports?.required || [];
1452
+ }
1453
+ function resolveFlintImports(config) {
1454
+ return config.imports?.flints || config.imports?.required || [];
1455
+ }
1456
+ function ensureFlintImports(config) {
1386
1457
  if (!config.imports) {
1387
- config.imports = { required: [] };
1458
+ config.imports = { flints: [] };
1388
1459
  }
1389
- if (!config.imports.required) {
1390
- config.imports.required = [];
1460
+ if (config.imports.required && !config.imports.flints) {
1461
+ config.imports.flints = config.imports.required;
1391
1462
  }
1392
- if (!config.imports.required.includes(ref)) {
1393
- config.imports.required.push(ref);
1463
+ delete config.imports.required;
1464
+ if (!config.imports.flints) {
1465
+ config.imports.flints = [];
1466
+ }
1467
+ return config.imports.flints;
1468
+ }
1469
+ async function addImportToConfig(flintPath, ref) {
1470
+ let config = await readFlintToml(flintPath);
1471
+ if (!config) {
1472
+ throw new Error("flint.toml not found");
1473
+ }
1474
+ const flints = ensureFlintImports(config);
1475
+ if (!flints.includes(ref)) {
1476
+ flints.push(ref);
1394
1477
  await writeFlintToml(flintPath, config);
1395
1478
  }
1396
1479
  }
1397
1480
  async function removeImportFromConfig(flintPath, ref) {
1398
1481
  let config = await readFlintToml(flintPath);
1399
- if (!config?.imports?.required) return false;
1400
- const index = config.imports.required.indexOf(ref);
1482
+ if (!config) return false;
1483
+ const flints = ensureFlintImports(config);
1484
+ const index = flints.indexOf(ref);
1401
1485
  if (index === -1) {
1402
1486
  const lowerRef = ref.toLowerCase();
1403
- const foundIndex = config.imports.required.findIndex((r) => r.toLowerCase() === lowerRef);
1487
+ const foundIndex = flints.findIndex((r) => r.toLowerCase() === lowerRef);
1404
1488
  if (foundIndex === -1) return false;
1405
- config.imports.required.splice(foundIndex, 1);
1489
+ flints.splice(foundIndex, 1);
1406
1490
  } else {
1407
- config.imports.required.splice(index, 1);
1491
+ flints.splice(index, 1);
1408
1492
  }
1409
1493
  await writeFlintToml(flintPath, config);
1410
1494
  return true;
1411
1495
  }
1412
- async function getRequiredImports(flintPath) {
1496
+ async function getFlintImports(flintPath) {
1413
1497
  const config = await readFlintToml(flintPath);
1414
- return config?.imports?.required || [];
1415
- }
1416
- async function addWorkspaceEntry(flintPath, name, path) {
1417
- console.warn("addWorkspaceEntry is deprecated, use addWorkspaceReference instead");
1418
- }
1419
- async function removeWorkspaceEntry(flintPath, name) {
1420
- console.warn("removeWorkspaceEntry is deprecated, use removeWorkspaceReference instead");
1421
- }
1422
- async function getWorkspaceEntries(flintPath) {
1423
- return {};
1424
- }
1425
- async function getWorkspaceEntry(flintPath, name) {
1426
- return null;
1498
+ if (!config) return [];
1499
+ return resolveFlintImports(config);
1427
1500
  }
1428
1501
 
1429
1502
  export {
1430
1503
  parse,
1504
+ stringify,
1505
+ resolveShardMode,
1506
+ isLocalShard,
1431
1507
  FLINT_CONFIG_FILENAME,
1432
1508
  FLINT_JSON_FILENAME,
1433
1509
  FLINT_VERSION,
@@ -1475,13 +1551,12 @@ export {
1475
1551
  removeLatticeReference,
1476
1552
  getLatticeReferences,
1477
1553
  getLatticeReference,
1554
+ addExportToConfig,
1555
+ removeExportFromConfig,
1556
+ getExportDeclarations,
1478
1557
  addImportToConfig,
1479
1558
  removeImportFromConfig,
1480
- getRequiredImports,
1481
- addWorkspaceEntry,
1482
- removeWorkspaceEntry,
1483
- getWorkspaceEntries,
1484
- getWorkspaceEntry
1559
+ getFlintImports
1485
1560
  };
1486
1561
  /*! Bundled license information:
1487
1562
 
@@ -0,0 +1,43 @@
1
+ // ../../packages/flint/dist/chunk-STM4NXTT.js
2
+ import { access } from "fs/promises";
3
+ async function exists(path) {
4
+ try {
5
+ await access(path);
6
+ return true;
7
+ } catch {
8
+ return false;
9
+ }
10
+ }
11
+ async function runConcurrent(tasks, options = {}) {
12
+ const { concurrency = 10, onComplete, onError, onStart } = options;
13
+ const results = [];
14
+ if (tasks.length === 0) return results;
15
+ let taskIdx = 0;
16
+ async function runNext() {
17
+ while (taskIdx < tasks.length) {
18
+ const idx = taskIdx++;
19
+ const task = tasks[idx];
20
+ onStart?.(task.name);
21
+ try {
22
+ const value = await task.run();
23
+ results.push({ name: task.name, status: "ok", value });
24
+ onComplete?.(task.name, value);
25
+ } catch (err) {
26
+ const error = err instanceof Error ? err : new Error(String(err));
27
+ results.push({ name: task.name, status: "error", error });
28
+ onError?.(task.name, error);
29
+ }
30
+ }
31
+ }
32
+ const workers = [];
33
+ for (let i = 0; i < Math.min(concurrency, tasks.length); i++) {
34
+ workers.push(runNext());
35
+ }
36
+ await Promise.all(workers);
37
+ return results;
38
+ }
39
+
40
+ export {
41
+ exists,
42
+ runConcurrent
43
+ };
@@ -1,10 +1,10 @@
1
- // ../../packages/flint/src/registry.ts
1
+ // ../../packages/flint/dist/chunk-7YSFBSPS.js
2
2
  import { mkdir, readFile, writeFile } from "fs/promises";
3
3
  import { homedir } from "os";
4
4
  import { join, resolve } from "path";
5
5
  var REGISTRY_VERSION = 1;
6
6
  function getGlobalFlintDir() {
7
- return join(homedir(), ".flint");
7
+ return join(homedir(), ".nuucognition", "flint");
8
8
  }
9
9
  function getFlintRegistryPath() {
10
10
  return join(getGlobalFlintDir(), "registry.json");
@@ -58,13 +58,14 @@ async function findFlintByPath(path) {
58
58
  const flints = await getFlintRegistry();
59
59
  return flints.find((f) => f.path === resolvedPath) ?? null;
60
60
  }
61
- async function findFlintById(_id) {
62
- return null;
63
- }
64
61
  async function findFlintByName(name) {
65
62
  const flints = await getFlintRegistry();
66
63
  return flints.find((f) => f.name === name) ?? null;
67
64
  }
65
+ async function isFlintNameTaken(name) {
66
+ const flints = await getFlintRegistry();
67
+ return flints.find((f) => f.name === name);
68
+ }
68
69
  async function upsertFlintEntry(entry) {
69
70
  const normalizedEntry = { ...entry, path: resolve(entry.path) };
70
71
  const flints = await getFlintRegistry();
@@ -184,7 +185,7 @@ async function cleanRegistryFile() {
184
185
  return result;
185
186
  }
186
187
  async function registerFlintByPath(path, options) {
187
- const { readFlintToml, hasFlintToml } = await import("./mesh-config-O3UKKKAO.js");
188
+ const { readFlintToml, hasFlintToml } = await import("./mesh-config-J6WB4RFV-G7RGPOZA.js");
188
189
  const isFlint = await hasFlintToml(path);
189
190
  if (!isFlint) {
190
191
  throw new Error(`Not a valid flint: ${path}
@@ -223,8 +224,8 @@ export {
223
224
  registerFlint,
224
225
  unregisterFlint,
225
226
  findFlintByPath,
226
- findFlintById,
227
227
  findFlintByName,
228
+ isFlintNameTaken,
228
229
  upsertFlintEntry,
229
230
  updateFlintEntry,
230
231
  isPathRegistered,
@@ -3,12 +3,14 @@ import {
3
3
  buildExport,
4
4
  buildExportByName,
5
5
  cleanupStaleExports,
6
+ scanExportEligible,
6
7
  scanExports
7
- } from "./chunk-BVYUS7NX.js";
8
+ } from "./chunk-K5QP4OME.js";
8
9
  export {
9
10
  buildAllExports,
10
11
  buildExport,
11
12
  buildExportByName,
12
13
  cleanupStaleExports,
14
+ scanExportEligible,
13
15
  scanExports
14
16
  };