@c4a/extract 0.6.3 → 0.6.4

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.
@@ -13919,15 +13919,17 @@ var MANIFEST_FILES = [
13919
13919
  "pom.xml",
13920
13920
  "build.gradle"
13921
13921
  ];
13922
- var findManifestFile = async (dirPath) => {
13922
+ var findManifestFiles = async (dirPath) => {
13923
+ const manifests = [];
13923
13924
  for (const file of MANIFEST_FILES) {
13924
13925
  try {
13925
13926
  await access(join(dirPath, file));
13926
- return file;
13927
+ manifests.push(file);
13927
13928
  } catch {}
13928
13929
  }
13929
- return null;
13930
+ return manifests;
13930
13931
  };
13932
+ var findManifestFile = async (dirPath) => (await findManifestFiles(dirPath))[0] ?? null;
13931
13933
  var readModuleName = async (dirPath, manifestFile) => {
13932
13934
  try {
13933
13935
  const content = await readFile(join(dirPath, manifestFile), "utf-8");
@@ -14083,7 +14085,8 @@ var detectModules = async (repoPath, ref, pathFilter2) => {
14083
14085
  const gitFiles = await tryGitListFiles(repoRoot, ref);
14084
14086
  const subModuleDirs = await findSubModuleDirs(repoRoot, undefined, gitFiles, pathFilter2);
14085
14087
  const subModuleDirSet = new Set(subModuleDirs.map((d) => resolve(d)));
14086
- const rootManifest = await findManifestFile(repoRoot);
14088
+ const rootManifests = await findManifestFiles(repoRoot);
14089
+ const rootManifest = rootManifests[0] ?? null;
14087
14090
  if (rootManifest) {
14088
14091
  const rootName = await readModuleName(repoRoot, rootManifest) ?? basename(repoRoot);
14089
14092
  modules.push(await buildModule(repoRoot, repoRoot, rootName, subModuleDirSet, ref, pathFilter2, gitFiles));
@@ -14106,18 +14109,21 @@ var detectModuleBoundaries = async (repoPath, ref, pathFilter2) => {
14106
14109
  const gitFiles = await tryGitListFiles(repoRoot, ref);
14107
14110
  const subModuleDirs = await findSubModuleDirs(repoRoot, undefined, gitFiles, pathFilter2);
14108
14111
  const boundaries = [];
14109
- const rootManifest = await findManifestFile(repoRoot);
14112
+ const rootManifests = await findManifestFiles(repoRoot);
14113
+ const rootManifest = rootManifests[0] ?? null;
14110
14114
  if (rootManifest) {
14111
14115
  const version2 = await readModuleVersion(repoRoot, rootManifest);
14112
14116
  boundaries.push({
14113
14117
  name: await readModuleName(repoRoot, rootManifest) ?? basename(repoRoot),
14114
14118
  path: ".",
14115
14119
  manifest: rootManifest,
14120
+ manifests: rootManifests,
14116
14121
  ...version2 !== null ? { version: version2 } : {}
14117
14122
  });
14118
14123
  }
14119
14124
  for (const subDir of subModuleDirs) {
14120
- const manifest = await findManifestFile(subDir);
14125
+ const manifests = await findManifestFiles(subDir);
14126
+ const manifest = manifests[0] ?? null;
14121
14127
  if (!manifest)
14122
14128
  continue;
14123
14129
  const version2 = await readModuleVersion(subDir, manifest);
@@ -14125,6 +14131,7 @@ var detectModuleBoundaries = async (repoPath, ref, pathFilter2) => {
14125
14131
  name: await readModuleName(subDir, manifest) ?? basename(subDir),
14126
14132
  path: toPosixPath(relative(repoRoot, subDir)) || ".",
14127
14133
  manifest,
14134
+ manifests,
14128
14135
  ...version2 !== null ? { version: version2 } : {}
14129
14136
  });
14130
14137
  }
@@ -14135,7 +14142,7 @@ var detectModuleAt = async (repoPath, modulePath, ref, pathFilter2) => {
14135
14142
  const moduleDir = modulePath === "." ? repoRoot : resolve(repoRoot, modulePath);
14136
14143
  if (modulePath !== "." && pathFilter2?.code?.exclude?.length) {
14137
14144
  const matcher = createPathMatcher({ include: ["**/*"], exclude: pathFilter2.code.exclude });
14138
- if (!matcher(modulePath + "/index.ts"))
14145
+ if (!matcher(modulePath + "/.context-module"))
14139
14146
  return null;
14140
14147
  }
14141
14148
  const manifest = await findManifestFile(moduleDir);
@@ -14164,6 +14171,7 @@ class ExtractionInputError extends Error {
14164
14171
 
14165
14172
  // src/repository.ts
14166
14173
  var PACKAGE_JSON = "package.json";
14174
+ var GO_MOD = "go.mod";
14167
14175
  var toPosixPath2 = (value) => value.split(path2.sep).join("/");
14168
14176
  function safeSourceRelativePath(value) {
14169
14177
  const slashPath = value.trim().replace(/\\/gu, "/");
@@ -14185,7 +14193,7 @@ function moduleRelativeEntryPath(modulePath, sourcePath) {
14185
14193
  function entrySubpath(filePath, index) {
14186
14194
  if (index === 0)
14187
14195
  return ".";
14188
- const withoutExtension = filePath.replace(/\.(?:d\.)?(?:ts|tsx|mts|cts)$/u, "");
14196
+ const withoutExtension = filePath.replace(/\.(?:d\.)?(?:ts|tsx|mts|cts|go)$/u, "");
14189
14197
  return `./${withoutExtension}`;
14190
14198
  }
14191
14199
  function selectedEntryFiles(input) {
@@ -14193,7 +14201,7 @@ function selectedEntryFiles(input) {
14193
14201
  const includedSourceFiles = new Set(input.module.files.map(safeSourceRelativePath));
14194
14202
  if (selection.mode === "auto") {
14195
14203
  if (input.detected.entries.length === 0) {
14196
- throw new ExtractionInputError(NO_ENTRY_DETECTED, 'No TypeScript entry files were detected from package.json. Configure extractTs entries in the Context project, or use mode: "scan"; do not modify the source repository solely for Context.', { mode: "auto", module: input.module.path });
14204
+ throw new ExtractionInputError(NO_ENTRY_DETECTED, `No ${input.detected.package.language} entry files were detected from the module manifest. Configure entries in the Context project, or use scan mode; do not modify the source repository solely for Context.`, { mode: "auto", module: input.module.path });
14197
14205
  }
14198
14206
  for (const entry of input.detected.entries) {
14199
14207
  const sourcePath = input.module.path === "." ? safeSourceRelativePath(entry.path) : safeSourceRelativePath(`${input.module.path}/${entry.path}`);
@@ -14205,7 +14213,7 @@ function selectedEntryFiles(input) {
14205
14213
  }
14206
14214
  const sourceEntries = selection.mode === "scan" ? [...includedSourceFiles].sort() : [...new Set(selection.entries.map(safeSourceRelativePath))];
14207
14215
  if (sourceEntries.length === 0) {
14208
- throw new ExtractionInputError(NO_ENTRY_DETECTED, selection.mode === "scan" ? "No TypeScript files match extractTs include for scan mode." : "extractTs entries must contain at least one source-relative file path.", { mode: selection.mode, module: input.module.path });
14216
+ throw new ExtractionInputError(NO_ENTRY_DETECTED, selection.mode === "scan" ? `No ${input.detected.package.language} files match the extraction include for scan mode.` : "Extraction entries must contain at least one source-relative file path.", { mode: selection.mode, module: input.module.path });
14209
14217
  }
14210
14218
  return sourceEntries.map((sourcePath, index) => {
14211
14219
  if (!includedSourceFiles.has(sourcePath)) {
@@ -14269,10 +14277,17 @@ var loadSourceInfo = async (modulePath, fs) => {
14269
14277
  content: await fs.readJson(PACKAGE_JSON)
14270
14278
  });
14271
14279
  }
14280
+ if (await fs.exists(GO_MOD)) {
14281
+ manifests.push({
14282
+ type: "go.mod",
14283
+ path: GO_MOD,
14284
+ content: { raw: await fs.readFile(GO_MOD) }
14285
+ });
14286
+ }
14272
14287
  return {
14273
14288
  path: normalizeRelativePath(modulePath),
14274
14289
  manifests,
14275
- ...manifests.some((manifest) => manifest.type === PACKAGE_JSON) ? { language: "typescript" } : {}
14290
+ ...manifests.some((manifest) => manifest.type === GO_MOD) ? { language: "go" } : manifests.some((manifest) => manifest.type === PACKAGE_JSON) ? { language: "typescript" } : {}
14276
14291
  };
14277
14292
  };
14278
14293
  var prefixSymbolPaths = (symbol, modulePath) => ({
@@ -14326,7 +14341,7 @@ var extractModuleDoc = async (entryDetection, fs) => {
14326
14341
  var noModuleError = (modulePath, repoPath) => ({
14327
14342
  module_name: modulePath,
14328
14343
  module_path: modulePath,
14329
- error: `No indexable code module detected at "${modulePath}" under ${repoPath}. ` + "A TypeScript module must have a package.json."
14344
+ error: `No indexable code module detected at "${modulePath}" under ${repoPath}. ` + "A supported module must have a recognized manifest such as package.json or go.mod."
14330
14345
  });
14331
14346
  var resolveRequestedModules = async (repoPath, modulePaths, ref, pathFilter2) => {
14332
14347
  if (!modulePaths || modulePaths.length === 0) {
package/index.js CHANGED
@@ -14526,15 +14526,17 @@ var MANIFEST_FILES = [
14526
14526
  "pom.xml",
14527
14527
  "build.gradle"
14528
14528
  ];
14529
- var findManifestFile = async (dirPath) => {
14529
+ var findManifestFiles = async (dirPath) => {
14530
+ const manifests = [];
14530
14531
  for (const file of MANIFEST_FILES) {
14531
14532
  try {
14532
14533
  await access(join(dirPath, file));
14533
- return file;
14534
+ manifests.push(file);
14534
14535
  } catch {}
14535
14536
  }
14536
- return null;
14537
+ return manifests;
14537
14538
  };
14539
+ var findManifestFile = async (dirPath) => (await findManifestFiles(dirPath))[0] ?? null;
14538
14540
  var readModuleName = async (dirPath, manifestFile) => {
14539
14541
  try {
14540
14542
  const content = await readFile(join(dirPath, manifestFile), "utf-8");
@@ -14690,7 +14692,8 @@ var detectModules = async (repoPath, ref, pathFilter2) => {
14690
14692
  const gitFiles = await tryGitListFiles(repoRoot, ref);
14691
14693
  const subModuleDirs = await findSubModuleDirs(repoRoot, undefined, gitFiles, pathFilter2);
14692
14694
  const subModuleDirSet = new Set(subModuleDirs.map((d) => resolve(d)));
14693
- const rootManifest = await findManifestFile(repoRoot);
14695
+ const rootManifests = await findManifestFiles(repoRoot);
14696
+ const rootManifest = rootManifests[0] ?? null;
14694
14697
  if (rootManifest) {
14695
14698
  const rootName = await readModuleName(repoRoot, rootManifest) ?? basename(repoRoot);
14696
14699
  modules.push(await buildModule(repoRoot, repoRoot, rootName, subModuleDirSet, ref, pathFilter2, gitFiles));
@@ -14713,18 +14716,21 @@ var detectModuleBoundaries = async (repoPath, ref, pathFilter2) => {
14713
14716
  const gitFiles = await tryGitListFiles(repoRoot, ref);
14714
14717
  const subModuleDirs = await findSubModuleDirs(repoRoot, undefined, gitFiles, pathFilter2);
14715
14718
  const boundaries = [];
14716
- const rootManifest = await findManifestFile(repoRoot);
14719
+ const rootManifests = await findManifestFiles(repoRoot);
14720
+ const rootManifest = rootManifests[0] ?? null;
14717
14721
  if (rootManifest) {
14718
14722
  const version2 = await readModuleVersion(repoRoot, rootManifest);
14719
14723
  boundaries.push({
14720
14724
  name: await readModuleName(repoRoot, rootManifest) ?? basename(repoRoot),
14721
14725
  path: ".",
14722
14726
  manifest: rootManifest,
14727
+ manifests: rootManifests,
14723
14728
  ...version2 !== null ? { version: version2 } : {}
14724
14729
  });
14725
14730
  }
14726
14731
  for (const subDir of subModuleDirs) {
14727
- const manifest = await findManifestFile(subDir);
14732
+ const manifests = await findManifestFiles(subDir);
14733
+ const manifest = manifests[0] ?? null;
14728
14734
  if (!manifest)
14729
14735
  continue;
14730
14736
  const version2 = await readModuleVersion(subDir, manifest);
@@ -14732,6 +14738,7 @@ var detectModuleBoundaries = async (repoPath, ref, pathFilter2) => {
14732
14738
  name: await readModuleName(subDir, manifest) ?? basename(subDir),
14733
14739
  path: toPosixPath(relative(repoRoot, subDir)) || ".",
14734
14740
  manifest,
14741
+ manifests,
14735
14742
  ...version2 !== null ? { version: version2 } : {}
14736
14743
  });
14737
14744
  }
@@ -14742,7 +14749,7 @@ var detectModuleAt = async (repoPath, modulePath, ref, pathFilter2) => {
14742
14749
  const moduleDir = modulePath === "." ? repoRoot : resolve(repoRoot, modulePath);
14743
14750
  if (modulePath !== "." && pathFilter2?.code?.exclude?.length) {
14744
14751
  const matcher = createPathMatcher({ include: ["**/*"], exclude: pathFilter2.code.exclude });
14745
- if (!matcher(modulePath + "/index.ts"))
14752
+ if (!matcher(modulePath + "/.context-module"))
14746
14753
  return null;
14747
14754
  }
14748
14755
  const manifest = await findManifestFile(moduleDir);
@@ -14771,6 +14778,7 @@ class ExtractionInputError extends Error {
14771
14778
 
14772
14779
  // src/repository.ts
14773
14780
  var PACKAGE_JSON = "package.json";
14781
+ var GO_MOD = "go.mod";
14774
14782
  var toPosixPath2 = (value) => value.split(path2.sep).join("/");
14775
14783
  function safeSourceRelativePath(value) {
14776
14784
  const slashPath = value.trim().replace(/\\/gu, "/");
@@ -14792,7 +14800,7 @@ function moduleRelativeEntryPath(modulePath, sourcePath) {
14792
14800
  function entrySubpath(filePath, index) {
14793
14801
  if (index === 0)
14794
14802
  return ".";
14795
- const withoutExtension = filePath.replace(/\.(?:d\.)?(?:ts|tsx|mts|cts)$/u, "");
14803
+ const withoutExtension = filePath.replace(/\.(?:d\.)?(?:ts|tsx|mts|cts|go)$/u, "");
14796
14804
  return `./${withoutExtension}`;
14797
14805
  }
14798
14806
  function selectedEntryFiles(input) {
@@ -14800,7 +14808,7 @@ function selectedEntryFiles(input) {
14800
14808
  const includedSourceFiles = new Set(input.module.files.map(safeSourceRelativePath));
14801
14809
  if (selection.mode === "auto") {
14802
14810
  if (input.detected.entries.length === 0) {
14803
- throw new ExtractionInputError(NO_ENTRY_DETECTED, 'No TypeScript entry files were detected from package.json. Configure extractTs entries in the Context project, or use mode: "scan"; do not modify the source repository solely for Context.', { mode: "auto", module: input.module.path });
14811
+ throw new ExtractionInputError(NO_ENTRY_DETECTED, `No ${input.detected.package.language} entry files were detected from the module manifest. Configure entries in the Context project, or use scan mode; do not modify the source repository solely for Context.`, { mode: "auto", module: input.module.path });
14804
14812
  }
14805
14813
  for (const entry of input.detected.entries) {
14806
14814
  const sourcePath = input.module.path === "." ? safeSourceRelativePath(entry.path) : safeSourceRelativePath(`${input.module.path}/${entry.path}`);
@@ -14812,7 +14820,7 @@ function selectedEntryFiles(input) {
14812
14820
  }
14813
14821
  const sourceEntries = selection.mode === "scan" ? [...includedSourceFiles].sort() : [...new Set(selection.entries.map(safeSourceRelativePath))];
14814
14822
  if (sourceEntries.length === 0) {
14815
- throw new ExtractionInputError(NO_ENTRY_DETECTED, selection.mode === "scan" ? "No TypeScript files match extractTs include for scan mode." : "extractTs entries must contain at least one source-relative file path.", { mode: selection.mode, module: input.module.path });
14823
+ throw new ExtractionInputError(NO_ENTRY_DETECTED, selection.mode === "scan" ? `No ${input.detected.package.language} files match the extraction include for scan mode.` : "Extraction entries must contain at least one source-relative file path.", { mode: selection.mode, module: input.module.path });
14816
14824
  }
14817
14825
  return sourceEntries.map((sourcePath, index) => {
14818
14826
  if (!includedSourceFiles.has(sourcePath)) {
@@ -14876,10 +14884,17 @@ var loadSourceInfo = async (modulePath, fs) => {
14876
14884
  content: await fs.readJson(PACKAGE_JSON)
14877
14885
  });
14878
14886
  }
14887
+ if (await fs.exists(GO_MOD)) {
14888
+ manifests.push({
14889
+ type: "go.mod",
14890
+ path: GO_MOD,
14891
+ content: { raw: await fs.readFile(GO_MOD) }
14892
+ });
14893
+ }
14879
14894
  return {
14880
14895
  path: normalizeRelativePath(modulePath),
14881
14896
  manifests,
14882
- ...manifests.some((manifest) => manifest.type === PACKAGE_JSON) ? { language: "typescript" } : {}
14897
+ ...manifests.some((manifest) => manifest.type === GO_MOD) ? { language: "go" } : manifests.some((manifest) => manifest.type === PACKAGE_JSON) ? { language: "typescript" } : {}
14883
14898
  };
14884
14899
  };
14885
14900
  var prefixSymbolPaths = (symbol, modulePath) => ({
@@ -14933,7 +14948,7 @@ var extractModuleDoc = async (entryDetection, fs) => {
14933
14948
  var noModuleError = (modulePath, repoPath) => ({
14934
14949
  module_name: modulePath,
14935
14950
  module_path: modulePath,
14936
- error: `No indexable code module detected at "${modulePath}" under ${repoPath}. ` + "A TypeScript module must have a package.json."
14951
+ error: `No indexable code module detected at "${modulePath}" under ${repoPath}. ` + "A supported module must have a recognized manifest such as package.json or go.mod."
14937
14952
  });
14938
14953
  var resolveRequestedModules = async (repoPath, modulePaths, ref, pathFilter2) => {
14939
14954
  if (!modulePaths || modulePaths.length === 0) {
@@ -15677,6 +15692,7 @@ export {
15677
15692
  SCAN_EXCLUDED_DIRS,
15678
15693
  PACKAGE_JSON,
15679
15694
  NO_ENTRY_DETECTED,
15695
+ GO_MOD,
15680
15696
  ExtractionPluginRegistry,
15681
15697
  ExtractionInputError,
15682
15698
  DOCUMENT_SNAPSHOT_MANIFEST_SCHEMA_VERSION,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c4a/extract",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "type": "module",
5
5
  "description": "Code extraction engine — Tree-sitter AST parsing and structural analysis",
6
6
  "license": "MIT",