Skip to content

Add Code Link npm strategy modes#643

Merged
huntercaron merged 22 commits into
mainfrom
cursor/code-link-npm-strategy-modes
May 13, 2026
Merged

Add Code Link npm strategy modes#643
huntercaron merged 22 commits into
mainfrom
cursor/code-link-npm-strategy-modes

Conversation

@huntercaron
Copy link
Copy Markdown
Collaborator

@huntercaron huntercaron commented May 6, 2026

Description

Adds Code Link npm strategy handling so unsupported npm can run in acquire-types mode or package-manager mode. Package-manager mode reads codeLinkNpmStrategy/lockfiles, skips ATA writes into node_modules, and asks the plugin for Framer dependency versions to keep package.json dependencies current.

Changelog

  • Improve npm dependency type-fetching strategy

Testing

  • QA acquire-types mode
    • Run the Code Link plugin locally from plugins/code-link.
    • Use the alpha CLI with --unsupported-npm=acquire-types and verify unsupported package types are acquired.
  • QA package-manager mode
    • Run the Code Link plugin locally from plugins/code-link.
    • Use the alpha CLI with --unsupported-npm=package-manager, verify package.json updates, then run your package manager.

Co-authored-by: Cursor <cursoragent@cursor.com>
@huntercaron huntercaron requested a review from iamakulov May 6, 2026 09:06
huntercaron and others added 4 commits May 6, 2026 13:08
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@huntercaron huntercaron marked this pull request as ready for review May 7, 2026 11:13
Copilot AI review requested due to automatic review settings May 7, 2026 11:13
@github-actions github-actions Bot added the Auto submit to Marketplace on merge Submits the plugin to the marketplace after merging label May 7, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.json dependencies current in package-manager mode.
  • Migrates legacy Code Link package.json metadata fields into codeLink.* and updates framer-plugin dependency/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.

Comment thread packages/code-link-cli/src/index.ts Outdated
Comment thread packages/code-link-cli/src/helpers/npm-strategy.ts Outdated
Comment thread packages/code-link-cli/src/helpers/installer.ts
Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown
Contributor

@iamakulov iamakulov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.json should be pinned, not ^. we pin your dependency versions in framer, and the package.json should 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 into package.json. haven’t debugged why.

Comment thread packages/code-link-cli/src/helpers/installer.ts Outdated
Comment thread packages/code-link-cli/src/helpers/installer.ts Outdated
Comment thread packages/code-link-cli/src/helpers/installer.ts
Comment thread packages/code-link-cli/src/helpers/installer.ts Outdated
Comment thread packages/code-link-cli/src/helpers/installer.ts Outdated
Comment thread packages/code-link-cli/src/index.ts Outdated
Comment thread packages/code-link-cli/src/index.ts Outdated
Comment thread packages/code-link-cli/src/index.ts Outdated
Comment thread packages/code-link-cli/src/helpers/installer.ts Outdated
Comment thread packages/code-link-cli/src/helpers/installer.ts Outdated
Comment thread packages/code-link-cli/src/helpers/installer.ts Outdated
huntercaron and others added 5 commits May 8, 2026 09:48
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)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive by switch to readdir with recursive as mentioned in another comment!

huntercaron and others added 6 commits May 8, 2026 12:44
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>
@huntercaron
Copy link
Copy Markdown
Collaborator Author

huntercaron commented May 8, 2026

@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>
@huntercaron huntercaron requested a review from iamakulov May 8, 2026 11:21
Comment thread packages/code-link-cli/src/helpers/installer.ts Outdated
Comment thread packages/code-link-cli/src/index.ts Outdated
Copy link
Copy Markdown
Contributor

@iamakulov iamakulov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@huntercaron huntercaron added this pull request to the merge queue May 13, 2026
@huntercaron huntercaron removed this pull request from the merge queue due to a manual request May 13, 2026
@huntercaron huntercaron enabled auto-merge May 13, 2026 15:33
@huntercaron huntercaron added this pull request to the merge queue May 13, 2026
Merged via the queue into main with commit 6946f1d May 13, 2026
9 checks passed
@huntercaron huntercaron deleted the cursor/code-link-npm-strategy-modes branch May 13, 2026 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auto submit to Marketplace on merge Submits the plugin to the marketplace after merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants