carto-md 1.0.12 → 1.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carto-md",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "The context layer for AI-native development.",
5
5
  "bin": {
6
6
  "carto": "src/cli/index.js"
package/src/cli/impact.js CHANGED
@@ -137,7 +137,6 @@ function run(projectRoot, fileArg) {
137
137
  * Matches by basename or partial path suffix.
138
138
  */
139
139
  function resolveFile(fileArg, imports) {
140
- // Collect all known files (keys + all values)
141
140
  const allFiles = new Set();
142
141
  for (const [file, deps] of Object.entries(imports)) {
143
142
  allFiles.add(file);
@@ -145,6 +144,7 @@ function resolveFile(fileArg, imports) {
145
144
  }
146
145
 
147
146
  const normalized = fileArg.replace(/\\/g, '/');
147
+ const hasPathSeparator = normalized.includes('/');
148
148
 
149
149
  // Exact match
150
150
  if (allFiles.has(normalized)) return normalized;
@@ -153,16 +153,17 @@ function resolveFile(fileArg, imports) {
153
153
  const matches = [...allFiles].filter(f => f.endsWith('/' + normalized) || f === normalized);
154
154
  if (matches.length === 1) return matches[0];
155
155
 
156
- // Match by basename
156
+ // If input was a path (contains /), don't fall back to basename — it's ambiguous
157
+ if (hasPathSeparator) {
158
+ if (matches.length > 1) return null;
159
+ return null;
160
+ }
161
+
162
+ // Input is just a filename — fall back to basename matching
157
163
  const byBasename = [...allFiles].filter(f => path.basename(f) === path.basename(normalized));
158
164
  if (byBasename.length === 1) return byBasename[0];
159
165
 
160
- // If multiple basename matches, prefer shortest path
161
- if (byBasename.length > 1) {
162
- byBasename.sort((a, b) => a.length - b.length);
163
- return byBasename[0];
164
- }
165
-
166
+ // Multiple basename matches — ambiguous, don't guess
166
167
  return null;
167
168
  }
168
169