Add Code Link npm strategy modes#643
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Pull request overview
Adds support for “unsupported npm” handling in Code Link by introducing explicit npm strategy modes, enabling either ATA-based type acquisition or a package-manager–driven workflow that updates package.json and defers installs to the user’s package manager.
Changes:
- Introduces
NpmStrategy(none/acquire-types/package-manager) with CLI flag parsing and project-level resolution (package.json + lockfile detection). - Adds a new CLI↔Plugin message pair to request dependency versions from the plugin, used to keep
package.jsondependencies current in package-manager mode. - Migrates legacy Code Link
package.jsonmetadata fields intocodeLink.*and updatesframer-plugindependency/version pins.
Reviewed changes
Copilot reviewed 17 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| yarn.lock | Updates lockfile entries for framer-plugin@3.11.0-alpha.14. |
| plugins/code-link/src/messages.ts | Handles new request-dependency-versions message and replies with dependency-versions. |
| plugins/code-link/src/api.ts | Adds fetchDependencyVersions() using the Framer plugin API. |
| plugins/code-link/package.json | Bumps framer-plugin dependency to 3.11.0-alpha.14. |
| packages/code-link-shared/src/types.ts | Adds DependencyVersions and new CLI↔Plugin message types. |
| packages/code-link-shared/src/index.ts | Re-exports DependencyVersions. |
| packages/code-link-cli/src/utils/project.ts | Adds readAndMigratePackageJson() and migrates Code Link metadata under package.json.codeLink. |
| packages/code-link-cli/src/utils/project.test.ts | Updates existing expectations to codeLink.* and adds migration tests. |
| packages/code-link-cli/src/types.ts | Replaces allowUnsupportedNpm with npmStrategy and adds NpmStrategy type. |
| packages/code-link-cli/src/index.ts | Adds --unsupported-npm [mode] parsing and wires npmStrategy into config. |
| packages/code-link-cli/src/helpers/npm-strategy.ts | New helper to resolve strategy from CLI flag / package.json / lockfiles. |
| packages/code-link-cli/src/helpers/installer.ts | Implements package-manager mode (dependency collection + package.json refresh) and strategy-aware ATA behavior. |
| packages/code-link-cli/src/controller.ts | Resolves npm strategy at runtime, adds dependency version request/response flow. |
| packages/code-link-cli/src/controller.rename.test.ts | Updates config shape for new npmStrategy. |
| packages/code-link-cli/src/controller.once.test.ts | Updates config shape for new npmStrategy. |
| packages/code-link-cli/src/controller.integration.test.ts | Updates config shape and adjusts sync-status message field typing in test parsing. |
| packages/code-link-cli/src/controller.apply.test.ts | Updates config shape for new npmStrategy. |
| packages/code-link-cli/package.json | Bumps CLI version and adds stableVersion metadata. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Cursor <cursoragent@cursor.com>
iamakulov
left a comment
There was a problem hiding this comment.
Sorry, this is a big review, but a big chunk of it is about code complexity or DX. Feel free to skip those if it blocks shipping!
Some extra notes from QA/Slack:
- [dx] the version ranges that we set in
package.jsonshould be pinned, not^. we pin your dependency versions in framer, and thepackage.jsonshould reflect that - [bug] with this project, dependency syncing simply doesn’t happen. (reproduced with
npx framer-code-link@alpha --unsupported-npm=package-manager A8ekr3Wn.) files sync, but deps aren’t added intopackage.json. haven’t debugged why.
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Replaces manual walk recursion with the built-in recursive readdir for simpler code. Co-authored-by: Cursor <cursoragent@cursor.com>
- Use Commander Option preset so `--unsupported-npm` (no arg) maps to `acquire-types` instead of silently becoming `true` and falling back to no-op behavior. - Switch installer to batch processFiles, parse imports via `parse-imports`, drop the local imports utility, and rename SUPPORTED_PACKAGES to DEFAULT_PACKAGES. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
| modifiedAt: stats.mtimeMs, | ||
| }) | ||
| } catch (err) { | ||
| warn(`Failed to read ${entryPath}:`, err) |
There was a problem hiding this comment.
Drive by switch to readdir with recursive as mentioned in another comment!
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
parse-imports/es-module-lexer didn't understand TSX, so a single unparseable file caused package-manager mode to skip every dependency update. ts.preProcessFile is tolerant of TSX/JSX and partial syntax errors, and we already depend on typescript via ATA. Also bump CLI to 0.21.0-alpha.4 and switch the package.json sync message to the green success log. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@iamakulov ty for all the feedback! I've simplified it quite a bit by plugging into our existing lifecycles/queues and listFiles, etc functions rather than doing all that on its own |
Co-authored-by: Cursor <cursoragent@cursor.com>
iamakulov
left a comment
There was a problem hiding this comment.
Skimmed a bit less deeply in my second review, didn’t look at complexity. Looks good, left a couple of copy nits ❤️
Extend the package.json migration to fill in codeLink.shortProjectHash and codeLink.framerProjectName defaults when missing, and run it for explicit --dir directories. Also clarifies the --unsupported-npm help.
Description
Adds Code Link npm strategy handling so unsupported npm can run in
acquire-typesmode orpackage-managermode. Package-manager mode readscodeLinkNpmStrategy/lockfiles, skips ATA writes intonode_modules, and asks the plugin for Framer dependency versions to keeppackage.jsondependencies current.Changelog
Testing
acquire-typesmodeplugins/code-link.--unsupported-npm=acquire-typesand verify unsupported package types are acquired.package-managermodeplugins/code-link.--unsupported-npm=package-manager, verifypackage.jsonupdates, then run your package manager.