@moldea.ai/cli 13.0.0 → 13.0.1

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/dist/moldea.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { A as createMoldeaCliOutputPage, C as formatMoldeaCliJsonInspectResult, D as MOLDEA_CLI_GIT_WORKING_TREE_SOURCE, E as createMoldeaCliOwnedError, F as MOLDEA_CLI_COMMANDS, M as decodeMoldeaCliCursor, N as encodeMoldeaCliCursor, O as parseMoldeaCliArguments, P as MoldeaCliOutputPageException, S as formatMoldeaCliJsonError, T as formatMoldeaCliJsonValidateResult, _ as formatMoldeaCliHumanInspectResult, a as require_semver, b as formatMoldeaCliJsonCompositionResult, c as runGitCommand, d as createMoldeaCliInspectProjection, f as createMoldeaCliValidateProjection, g as formatMoldeaCliHumanError, h as formatMoldeaCliHumanContentResult, j as calculateMoldeaCliJsonDigest, k as isRepositoryDirectoryInputValid, l as readGit, m as formatMoldeaCliHumanCompositionResult, o as MoldeaCliCompositionException, p as formatMoldeaCliHelp, s as createGitVersionPreflight, u as createMoldeaCliDiagnosticRecord, v as formatMoldeaCliHumanScopeResult, w as formatMoldeaCliJsonScopeResult, x as formatMoldeaCliJsonContentResult, y as formatMoldeaCliHumanValidateResult } from "./chunks/composition-cVui-wF_.js";
2
+ import { A as createMoldeaCliOutputPage, C as formatMoldeaCliJsonInspectResult, D as MOLDEA_CLI_GIT_WORKING_TREE_SOURCE, E as createMoldeaCliOwnedError, F as MOLDEA_CLI_COMMANDS, M as decodeMoldeaCliCursor, N as encodeMoldeaCliCursor, O as parseMoldeaCliArguments, P as MoldeaCliOutputPageException, S as formatMoldeaCliJsonError, T as formatMoldeaCliJsonValidateResult, _ as formatMoldeaCliHumanInspectResult, a as require_semver, b as formatMoldeaCliJsonCompositionResult, c as runGitCommand, d as createMoldeaCliInspectProjection, f as createMoldeaCliValidateProjection, g as formatMoldeaCliHumanError, h as formatMoldeaCliHumanContentResult, j as calculateMoldeaCliJsonDigest, k as isRepositoryDirectoryInputValid, l as readGit, m as formatMoldeaCliHumanCompositionResult, o as MoldeaCliCompositionException, p as formatMoldeaCliHelp, s as createGitVersionPreflight, u as createMoldeaCliDiagnosticRecord, v as formatMoldeaCliHumanScopeResult, w as formatMoldeaCliJsonScopeResult, x as formatMoldeaCliJsonContentResult, y as formatMoldeaCliHumanValidateResult } from "./chunks/composition-C9TNzN2e.js";
3
3
  import path from "node:path";
4
4
  import process from "node:process";
5
5
  import { fileURLToPath } from "node:url";
@@ -876,6 +876,7 @@ var GIT_IGNORED_INVENTORY_ARGUMENTS = [
876
876
  "-z",
877
877
  "--"
878
878
  ];
879
+ var GIT_INVENTORY_LISTING_SUBCOMMAND = "ls-files";
879
880
  var INSTRUCTION_PATHS = Object.freeze([
880
881
  "/AGENTS.md",
881
882
  "/CLAUDE.md",
@@ -1019,9 +1020,10 @@ var createGitContentTransformationParser = (input) => {
1019
1020
  //#endregion
1020
1021
  //#region src/git-inventory/content-transformation/classifier.ts
1021
1022
  /** Creates one immutable content-transformation classification failure. */
1022
- var createClassificationFailure = (errorCode) => Object.freeze({
1023
+ var createClassificationFailure = (errorCode, subcommand) => Object.freeze({
1023
1024
  errorCode,
1024
- kind: "failed"
1025
+ kind: "failed",
1026
+ ...subcommand === void 0 ? {} : { subcommand }
1025
1027
  });
1026
1028
  /** Maps one bounded Git attribute failure to the existing safe inventory contract. */
1027
1029
  var mapGitFailure$3 = (reason) => {
@@ -1087,7 +1089,7 @@ var createGitContentTransformationClassifier = (runGit = runGitCommand) => {
1087
1089
  maxOutputBytes: Math.max(input.maxMetadataBytes, 1),
1088
1090
  ...input.signal === void 0 ? {} : { signal: input.signal }
1089
1091
  });
1090
- if (result.kind === "failed") return createClassificationFailure(mapGitFailure$3(result.reason));
1092
+ if (result.kind === "failed") return createClassificationFailure(mapGitFailure$3(result.reason), result.subcommand);
1091
1093
  if (result.value.byteLength > input.maxMetadataBytes) return createClassificationFailure("RESOURCE_LIMIT_EXCEEDED");
1092
1094
  const parser = createGitContentTransformationParser({ paths });
1093
1095
  parser.consume(result.value);
@@ -1210,10 +1212,12 @@ var createGitInventoryEntryInspector = (inspectEntry = inspectHostEntry) => {
1210
1212
  var inspectGitInventoryEntry = createGitInventoryEntryInspector();
1211
1213
  //#endregion
1212
1214
  //#region src/git-inventory/entry-type/symlink-configuration.ts
1215
+ var GIT_CONFIG_SUBCOMMAND = "config";
1213
1216
  /** Creates one immutable effective symlink configuration failure. */
1214
- var createConfigurationFailure = (errorCode) => Object.freeze({
1217
+ var createConfigurationFailure = (errorCode, subcommand) => Object.freeze({
1215
1218
  errorCode,
1216
- kind: "failed"
1219
+ kind: "failed",
1220
+ ...subcommand === void 0 ? {} : { subcommand }
1217
1221
  });
1218
1222
  /** Maps one bounded Git configuration failure to the existing safe CLI contract. */
1219
1223
  var mapGitFailure$2 = (reason) => {
@@ -1240,8 +1244,8 @@ var createGitSymlinkConfigurationResolver = (readBoolean = readConfigBoolean) =>
1240
1244
  maxOutputBytes: Math.max(input.maxMetadataBytes, 1),
1241
1245
  timeoutSeconds: 300,
1242
1246
  ...input.signal === void 0 ? {} : { signal: input.signal }
1243
- }), input.signal);
1244
- if (result.kind === "failed") return createConfigurationFailure(mapGitFailure$2(result.reason));
1247
+ }), input.signal, GIT_CONFIG_SUBCOMMAND);
1248
+ if (result.kind === "failed") return createConfigurationFailure(mapGitFailure$2(result.reason), result.subcommand);
1245
1249
  const gitMetadataBytes = result.value ? 5 : 6;
1246
1250
  if (gitMetadataBytes > input.maxMetadataBytes) return createConfigurationFailure("RESOURCE_LIMIT_EXCEEDED");
1247
1251
  return Object.freeze({
@@ -1328,6 +1332,61 @@ var createGitInventoryEntryTypeNormalizer = (entryInspector = inspectGitInventor
1328
1332
  };
1329
1333
  };
1330
1334
  //#endregion
1335
+ //#region src/git-inventory/link-ancestors/shadower.ts
1336
+ /** Creates one immutable cancellation failure. */
1337
+ var createAbortedFailure = () => Object.freeze({
1338
+ errorCode: "GIT_OPERATION_ABORTED",
1339
+ kind: "failed"
1340
+ });
1341
+ /**
1342
+ * Lists the proper ancestor directories of one Git-relative path, shallowest first. An untracked
1343
+ * directory-boundary record keeps Git's trailing separator, which names the path itself.
1344
+ * @param candidatePath The Git-relative candidate path.
1345
+ * @returns Every directory above the candidate, such as `a` and `a/b` for `a/b/c`.
1346
+ */
1347
+ var listProperAncestors = (candidatePath) => {
1348
+ const segments = candidatePath.replace(/\/$/u, "").split("/");
1349
+ return segments.slice(0, -1).map((_segment, index) => segments.slice(0, index + 1).join("/"));
1350
+ };
1351
+ /** Determines whether a path sits beneath any recorded link. */
1352
+ var isBeneathLink = (candidatePath, links) => listProperAncestors(candidatePath).some((ancestor) => links.has(ancestor));
1353
+ /**
1354
+ * Creates link-ancestor shadowing around an injectable no-follow entry inspector. Git can list
1355
+ * entries beneath a path the working tree holds as a symlink or junction, such as the files a
1356
+ * Windows junction exposes, while every later read treats that path as a link.
1357
+ * @param inspectEntry The no-follow inspector for one Git-relative path.
1358
+ * @returns A shadower that replaces every candidate beneath a working-tree link with the link.
1359
+ */
1360
+ var createGitLinkAncestorShadower = (inspectEntry = inspectGitInventoryEntry) => {
1361
+ return async (input) => {
1362
+ if (input.signal?.aborted) return createAbortedFailure();
1363
+ const ancestors = [...new Set(input.candidates.flatMap(({ path }) => listProperAncestors(path)))].sort((left, right) => left.split("/").length - right.split("/").length);
1364
+ const links = /* @__PURE__ */ new Set();
1365
+ for (const ancestor of ancestors) {
1366
+ if (isBeneathLink(ancestor, links)) continue;
1367
+ const inspection = await inspectEntry(input.repositoryRoot, ancestor);
1368
+ if (input.signal?.aborted) return createAbortedFailure();
1369
+ if (inspection.kind === "failed") return inspection;
1370
+ if (inspection.kind === "inspected" && inspection.entryType === "symlink") links.add(ancestor);
1371
+ }
1372
+ if (links.size === 0) return Object.freeze({
1373
+ candidates: input.candidates,
1374
+ kind: "shadowed"
1375
+ });
1376
+ const remainingCandidates = input.candidates.filter(({ path }) => !isBeneathLink(path, links));
1377
+ const remainingPaths = new Set(remainingCandidates.map(({ path }) => path));
1378
+ const linkCandidates = [...links].filter((link) => !remainingPaths.has(link)).map((link) => Object.freeze({
1379
+ kind: "untracked",
1380
+ path: link
1381
+ }));
1382
+ return Object.freeze({
1383
+ candidates: Object.freeze([...remainingCandidates, ...linkCandidates]),
1384
+ kind: "shadowed"
1385
+ });
1386
+ };
1387
+ };
1388
+ var shadowGitLinkAncestors = createGitLinkAncestorShadower();
1389
+ //#endregion
1331
1390
  //#region src/git-inventory/logical-path/normalizer.ts
1332
1391
  /** Creates one immutable invalid logical-path result. */
1333
1392
  var createLogicalPathFailure = () => Object.freeze({
@@ -1867,10 +1926,11 @@ var toTrackedCandidates = (entries) => {
1867
1926
  var measureTrackedOutput = (entries) => entries.reduce((bytes, { path }) => bytes + 75 + countUtf8Bytes(path), 0);
1868
1927
  /** Measures the stdout `ls-files --others -z` wrote for the untracked paths. */
1869
1928
  var measureUntrackedOutput = (paths) => paths.reduce((bytes, path) => bytes + countUtf8Bytes(path) + 1, 0);
1870
- /** Creates one immutable inventory-probe failure. */
1871
- var createProbeFailure = (errorCode) => Object.freeze({
1929
+ /** Creates one immutable inventory-probe failure, naming the Git subcommand when Git failed. */
1930
+ var createProbeFailure = (errorCode, subcommand) => Object.freeze({
1872
1931
  errorCode,
1873
- kind: "failed"
1932
+ kind: "failed",
1933
+ ...subcommand === void 0 ? {} : { subcommand }
1874
1934
  });
1875
1935
  /** Maps one completed parser result into immutable candidates or a safe failure. */
1876
1936
  var resolveParserResult = (parserResult) => {
@@ -1886,9 +1946,10 @@ var isProbeFailure = (result) => !Array.isArray(result);
1886
1946
  * @param entryTypeNormalizer The current filesystem and Git mode entry-type normalizer.
1887
1947
  * @param contentTransformationClassifier The bounded effective Git attribute classifier.
1888
1948
  * @param logicalPathNormalizer The portable repository logical-path normalizer.
1949
+ * @param linkAncestorShadower The step that replaces candidates beneath a working-tree link.
1889
1950
  * @returns An all-or-nothing selected-repository entry probe.
1890
1951
  */
1891
- var createGitInventoryProbe = (git = GIT_INVENTORY_LISTING_READS, ownershipFilter = createGitInventoryOwnershipFilter(createGitInventoryBoundaryInspector()), entryTypeNormalizer = createGitInventoryEntryTypeNormalizer(inspectGitInventoryEntry, createGitSymlinkConfigurationResolver()), contentTransformationClassifier = createGitContentTransformationClassifier(), logicalPathNormalizer = normalizeGitInventoryLogicalPaths) => async (input) => {
1952
+ var createGitInventoryProbe = (git = GIT_INVENTORY_LISTING_READS, ownershipFilter = createGitInventoryOwnershipFilter(createGitInventoryBoundaryInspector()), entryTypeNormalizer = createGitInventoryEntryTypeNormalizer(inspectGitInventoryEntry, createGitSymlinkConfigurationResolver()), contentTransformationClassifier = createGitContentTransformationClassifier(), logicalPathNormalizer = normalizeGitInventoryLogicalPaths, linkAncestorShadower = shadowGitLinkAncestors) => async (input) => {
1892
1953
  if (input.signal?.aborted) return createProbeFailure("GIT_OPERATION_ABORTED");
1893
1954
  const selectionPaths = (input.selectionPaths ?? []).map((selectionPath) => selectionPath.slice(1));
1894
1955
  let remainingMetadataBytes = input.maxMetadataBytes;
@@ -1898,14 +1959,14 @@ var createGitInventoryProbe = (git = GIT_INVENTORY_LISTING_READS, ownershipFilte
1898
1959
  ...selectionPaths.length === 0 ? {} : { paths: selectionPaths },
1899
1960
  ...input.signal === void 0 ? {} : { signal: input.signal }
1900
1961
  });
1901
- const trackedResult = await readGit(() => git.readIndexEntries(input.repositoryRoot, createReadOptions()), input.signal);
1902
- if (trackedResult.kind === "failed") return createProbeFailure(mapGitFailure(trackedResult.reason));
1962
+ const trackedResult = await readGit(() => git.readIndexEntries(input.repositoryRoot, createReadOptions()), input.signal, GIT_INVENTORY_LISTING_SUBCOMMAND);
1963
+ if (trackedResult.kind === "failed") return createProbeFailure(mapGitFailure(trackedResult.reason), trackedResult.subcommand);
1903
1964
  remainingMetadataBytes -= measureTrackedOutput(trackedResult.value);
1904
1965
  if (trackedResult.value.length > input.maxEntries || remainingMetadataBytes < 0) return createProbeFailure("RESOURCE_LIMIT_EXCEEDED");
1905
1966
  const trackedCandidates = toTrackedCandidates(trackedResult.value);
1906
1967
  if (trackedCandidates === null) return createProbeFailure("GIT_OUTPUT_INVALID");
1907
- const untrackedResult = await readGit(() => git.listUntrackedFiles(input.repositoryRoot, createReadOptions()), input.signal);
1908
- if (untrackedResult.kind === "failed") return createProbeFailure(mapGitFailure(untrackedResult.reason));
1968
+ const untrackedResult = await readGit(() => git.listUntrackedFiles(input.repositoryRoot, createReadOptions()), input.signal, GIT_INVENTORY_LISTING_SUBCOMMAND);
1969
+ if (untrackedResult.kind === "failed") return createProbeFailure(mapGitFailure(untrackedResult.reason), untrackedResult.subcommand);
1909
1970
  remainingMetadataBytes -= measureUntrackedOutput(untrackedResult.value);
1910
1971
  if (trackedCandidates.length + untrackedResult.value.length > input.maxEntries || remainingMetadataBytes < 0) return createProbeFailure("RESOURCE_LIMIT_EXCEEDED");
1911
1972
  if (untrackedResult.value.some((path) => path.length === 0)) return createProbeFailure("GIT_OUTPUT_INVALID");
@@ -1920,7 +1981,7 @@ var createGitInventoryProbe = (git = GIT_INVENTORY_LISTING_READS, ownershipFilte
1920
1981
  maxOutputBytes: Math.max(remainingMetadataBytes, 1),
1921
1982
  ...input.signal === void 0 ? {} : { signal: input.signal }
1922
1983
  });
1923
- if (ignoredResult.kind === "failed") return createProbeFailure(mapGitFailure(ignoredResult.reason));
1984
+ if (ignoredResult.kind === "failed") return createProbeFailure(mapGitFailure(ignoredResult.reason), ignoredResult.subcommand);
1924
1985
  remainingMetadataBytes -= ignoredResult.value.byteLength;
1925
1986
  if (remainingMetadataBytes < 0) return createProbeFailure("RESOURCE_LIMIT_EXCEEDED");
1926
1987
  const ignoredParser = createUntrackedGitInventoryParser(input.maxEntries - trackedCandidates.length - untrackedCandidates.length);
@@ -1936,8 +1997,14 @@ var createGitInventoryProbe = (git = GIT_INVENTORY_LISTING_READS, ownershipFilte
1936
1997
  ...ignoredCandidates
1937
1998
  ]) });
1938
1999
  if (logicalPathFilterResult.kind === "failed") return logicalPathFilterResult;
1939
- const ownershipResult = await ownershipFilter({
2000
+ const shadowResult = await linkAncestorShadower({
1940
2001
  candidates: logicalPathFilterResult.candidates,
2002
+ repositoryRoot: input.repositoryRoot,
2003
+ ...input.signal === void 0 ? {} : { signal: input.signal }
2004
+ });
2005
+ if (shadowResult.kind === "failed") return shadowResult;
2006
+ const ownershipResult = await ownershipFilter({
2007
+ candidates: shadowResult.candidates,
1941
2008
  maxMetadataBytes: remainingMetadataBytes,
1942
2009
  repositoryRoot: input.repositoryRoot,
1943
2010
  ...input.signal === void 0 ? {} : { signal: input.signal }
@@ -2239,10 +2306,11 @@ var createWorkingTreeInstructionSourceFactory = (filesystemReaderFactory = creat
2239
2306
  var createWorkingTreeInstructionSource = createWorkingTreeInstructionSourceFactory();
2240
2307
  //#endregion
2241
2308
  //#region src/working-tree-snapshot/executor.ts
2242
- /** Creates one immutable terminal snapshot failure. */
2243
- var createSnapshotFailure = (errorCode) => Object.freeze({
2309
+ /** Creates one immutable terminal snapshot failure, keeping a failed Git inventory subcommand. */
2310
+ var createSnapshotFailure = (errorCode, subcommand) => Object.freeze({
2244
2311
  errorCode,
2245
- kind: "failed"
2312
+ kind: "failed",
2313
+ ...subcommand === void 0 ? {} : { subcommand }
2246
2314
  });
2247
2315
  /** Determines whether a source exception proves that the current reader is unusable. */
2248
2316
  var isSnapshotChanged = (error) => error instanceof RepositorySourceException && error.code === "SNAPSHOT_CHANGED";
@@ -2280,7 +2348,7 @@ var createWorkingTreeSnapshotExecutor = (identityInspector = inspectGitWorkingTr
2280
2348
  ...input.selectionPaths === void 0 ? {} : { selectionPaths: input.selectionPaths },
2281
2349
  ...input.signal === void 0 ? {} : { signal: input.signal }
2282
2350
  });
2283
- return result.kind === "failed" ? createSnapshotFailure(result.errorCode) : result;
2351
+ return result.kind === "failed" ? createSnapshotFailure(result.errorCode, result.subcommand) : result;
2284
2352
  };
2285
2353
  const probeInstructions = async () => {
2286
2354
  if (input.includeInstructions !== true) return null;
@@ -2292,7 +2360,7 @@ var createWorkingTreeSnapshotExecutor = (identityInspector = inspectGitWorkingTr
2292
2360
  selectionPaths: INSTRUCTION_PATHS,
2293
2361
  ...input.signal === void 0 ? {} : { signal: input.signal }
2294
2362
  });
2295
- return result.kind === "failed" ? createSnapshotFailure(result.errorCode) : result;
2363
+ return result.kind === "failed" ? createSnapshotFailure(result.errorCode, result.subcommand) : result;
2296
2364
  };
2297
2365
  for (let attempt = 0; attempt < 3; attempt += 1) {
2298
2366
  if (input.signal?.aborted) return createSnapshotFailure("GIT_OPERATION_ABORTED");
@@ -2526,15 +2594,15 @@ var createMoldeaCliContentExecutionResult = (pageResult, cliVersion, isJson, cur
2526
2594
  //#region src/cli-execution/command-executor.ts
2527
2595
  /** Loads isolated Core inspection only for commands that need it. */
2528
2596
  var executeLazyCoreInspection = async (input) => {
2529
- const { executeMoldeaCliCoreInspection } = await import("./chunks/core-composition-ZEZSTBMA.js");
2597
+ const { executeMoldeaCliCoreInspection } = await import("./chunks/core-composition-DeWcE7Bf.js");
2530
2598
  return executeMoldeaCliCoreInspection(input);
2531
2599
  };
2532
2600
  var loadInstalledComposition = async (input) => {
2533
- const { resolveInstalledMoldeaCliComposition } = await import("./chunks/composition-C2m6SpCI.js");
2601
+ const { resolveInstalledMoldeaCliComposition } = await import("./chunks/composition-PoYBx0Mw.js");
2534
2602
  return resolveInstalledMoldeaCliComposition(input);
2535
2603
  };
2536
2604
  /** Creates one operational error result without exposing caught failure details. */
2537
- var createOperationalErrorResult = (code, input) => createMoldeaCliErrorResult(createMoldeaCliOwnedError(code), input.invocation.command, input.packageMetadata.version, input.invocation.options.isJson, MOLDEA_CLI_EXIT_CODES.OperationalError);
2605
+ var createOperationalErrorResult = (code, input, details) => createMoldeaCliErrorResult(createMoldeaCliOwnedError(code, details), input.invocation.command, input.packageMetadata.version, input.invocation.options.isJson, MOLDEA_CLI_EXIT_CODES.OperationalError);
2538
2606
  /**
2539
2607
  * Creates command dispatch with lazy Core loading and bounded working-tree snapshots.
2540
2608
  * @param workingTreeDiscovery The Git working-tree discovery operation.
@@ -2628,7 +2696,7 @@ var createMoldeaCliCommandExecutor = (workingTreeDiscovery = discoverGitWorkingT
2628
2696
  ...command === MOLDEA_CLI_COMMANDS.Scope ? { selectionPaths: [MOLDEA_MANIFEST_PATH] } : contentPath === null ? {} : { selectionPaths: [contentPath] },
2629
2697
  ...input.signal === void 0 ? {} : { signal: input.signal }
2630
2698
  });
2631
- if (snapshotResult.kind === "failed") return createOperationalErrorResult(snapshotResult.errorCode, input);
2699
+ if (snapshotResult.kind === "failed") return createOperationalErrorResult(snapshotResult.errorCode, input, snapshotResult.subcommand === void 0 ? void 0 : { subcommand: snapshotResult.subcommand });
2632
2700
  if (command === MOLDEA_CLI_COMMANDS.Validate) return createMoldeaCliValidateExecutionResult(snapshotResult.result, input.packageMetadata.version, options.isJson, options.cursor, options.maxOutputBytes);
2633
2701
  if (command === MOLDEA_CLI_COMMANDS.Inspect) return createMoldeaCliInspectExecutionResult(snapshotResult.result, input.packageMetadata.version, options.isJson, options.cursor, options.maxOutputBytes);
2634
2702
  if (command === MOLDEA_CLI_COMMANDS.Scope) return createMoldeaCliScopeExecutionResult(snapshotResult.result, input.packageMetadata.version, options.isJson, options.cursor, options.maxOutputBytes);