Repository navigation
feat(mcpx): resolve missing imports into dependency sets - #5637
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 2 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9847d5062b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| name = strings.Join(parts[:2], "/") | ||
| rest := strings.TrimPrefix(spec, name) | ||
| if strings.HasPrefix(rest, "@") { | ||
| version = strings.SplitN(strings.TrimPrefix(rest, "@"), "/", 2)[0] |
There was a problem hiding this comment.
Separate version suffixes from scoped package names
For an explicit declaration such as @scope/pkg@1.2.3, joining the first two slash-separated components includes the version in name, leaving rest empty. A missing import of @scope/pkg therefore never matches that explicit pin and falls back to a manifest or npm latest, or fails when networking is disabled. The same parser also misreads versioned scoped npm targets loaded from deno.json. Split the version suffix out of the package component before constructing the scoped name.
Useful? React with 👍 / 👎.
| add := func(dst map[string]ResolvedPackage, p ResolvedPackage) { | ||
| if current, ok := dst[p.Name]; !ok || (current.Version == "" && p.Version != "") { | ||
| dst[p.Name] = p |
There was a problem hiding this comment.
Preserve explicit pins in foreign dependency sets
When a file edge enters a foreign project declaring foo@1, the boundary loop populates its dependency subset with that version before processing missing imports. If a missing import of foo has an explicit foo@2 declaration, the resolver selects version 2 but this first-write-wins helper discards it because version 1 is already present. Both isolate and merge modes consequently return the manifest version instead of the explicit pin, while the resolution diagnostic announces version 2. Allow the higher-precedence explicit resolution to replace the manifest-derived entry.
Useful? React with 👍 / 👎.
| if filepath.Ext(path) == ".jsonc" { | ||
| b = deps.StripJSONC(b) | ||
| } |
There was a problem hiding this comment.
Normalize JSONC syntax in deno.json before parsing
For a project whose deno.json contains comments or trailing commas, default import preflight now fails even when every import resolves. Discovery reads the config, but this extension check skips normalization for deno.json, so json.Unmarshal fails and ResolveGraph returns a fatal manifest-reading error. The existing project-config loader in internal/runner/deps.go handles these files with deps.StripJSONC(raw) regardless of which Deno filename is used. Apply the same normalization here so previously accepted project configs do not prevent scripts from running.
Useful? React with 👍 / 👎.
| if err == nil && rel != ".." && !strings.HasPrefix(rel, ".."+string(filepath.Separator)) && (best == nil || len(m.Dir) > len(best.Dir)) { | ||
| best = m |
There was a problem hiding this comment.
Retain npm declarations alongside same-directory Deno configs
When a project contains both deno.json and package.json, discovery sorts the Deno config first, and this strict-depth comparison never considers the npm manifest at the same directory depth. For example, importing a foreign project with deno.json containing {} and dependencies declared in package.json produces an empty isolated dependency subset. Missing imports from that project also ignore its npm version declarations and instead query latest or fail with networking disabled. Combine the applicable same-directory declarations rather than letting the first manifest hide the other.
Useful? React with 👍 / 👎.
| } | ||
|
|
||
| func nearestManifest(file string, manifests []PackageManifest) *PackageManifest { | ||
| path := fileURLToPath(file) |
There was a problem hiding this comment.
Decode file URLs before matching project directories
For a project directory containing spaces or other URL-escaped characters, fileURLToPath only removes the file:// prefix, so a graph URL such as file:///work/my%20project/main.ts does not match the discovered manifest directory /work/my project. This newly added filesystem lookup consequently ignores the project's declared versions, selecting npm latest or rejecting resolution when networking is disabled, and can omit foreign dependency subsets. Decode file URLs before converting them into filesystem paths, including the roots and edges already converted by ParseGraph.
Useful? React with 👍 / 👎.
Summary
Registers and wires the five
script.imports*settings through CLI, exec service, daemon, and runner. Resolve is data-only: it does not install packages, rewrite manifests, or write lockfiles; stage 3 remains out of scope. Refs #1915.Evidence
go test ./internal/preflightpasses, including pin precedence, latest announcement, subset separation, and policy tests.go test ./internal/runner ./internal/execsvc ./internal/cli ./internal/daemonpasses. Settings docs are regenerated.proto.elicitationPerMinute,proto.samplingPerMinute,proto.samplingSessionPerMinute), reproduced on cleanmain.Merge Danger
Door: two-way
Blast Radius: moderate — preflight report behavior and settings propagation; no package installation or project mutation.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.