Skip to content

feat(deeplink): add deeplink command importing provider/mcp/prompt/skill#226

Open
LeonardoTan19 wants to merge 8 commits into
SaladDay:mainfrom
LeonardoTan19:main
Open

feat(deeplink): add deeplink command importing provider/mcp/prompt/skill#226
LeonardoTan19 wants to merge 8 commits into
SaladDay:mainfrom
LeonardoTan19:main

Conversation

@LeonardoTan19

Copy link
Copy Markdown

Summary

  • Port MCP/prompt/skill import handlers from upstream (farion1231/cc-switch), adding library-level deeplink import for resource types beyond provider.
  • Wire the ported handlers into the deeplink parser and expose a top-level cc-switch deeplink <url> command that dispatches by resource type (provider/mcp/prompt/skill), with the deep link's own app/apps parameters driving the target.
  • Align imported-prompt timestamps to seconds to match the prompt store (upstream used milliseconds).
  • Add integration tests covering MCP server persistence with merged app flags, prompt import with enabled/disabled states, skill repo registration, and malformed-repo rejection.

Test plan

  • cargo test deeplink passes all integration tests
  • cargo fmt --check and cargo clippy clean

Pull src/deeplink/{mcp,prompt,skill}.rs from farion1231/cc-switch.
These implement library-level deeplink import for resource types beyond
provider; parser dispatch and CLI wiring follow in subsequent commits.
…skill

Wire the ported mcp/prompt/skill handlers into the deeplink parser and
re-exports, then expose a top-level `cc-switch deeplink <url>` command
that dispatches by the URL's `resource` type. The deep link's own
`app`/`apps` parameters drive the target, so the global `--app` flag is
ignored here.

Also align imported-prompt timestamps to seconds to match the prompt
store (upstream used milliseconds, which rendered far-future dates).
Add integration tests for the new resource types: MCP server persistence
with merged app flags, prompt import with enabled/disabled states, and
skill repo registration, plus a malformed-repo rejection case.
- Align parser.rs with upstream cc-switch: add hermes to provider app
  validation, use local variable extraction style consistently
- Fix MCP import merge logic missing opencode/hermes app flags for
  existing servers
- Remove misleading hint message that referenced non-existent command
@LeonardoTan19

Copy link
Copy Markdown
Author

@SaladDay --app 是个全局的参数,跟deeplink不是很搭,应该对其采取什么样的处理方式呢?

… dispatch/MCP/parser/cross-app coverage

- Merge three OpenClaw config rejection tests into one parameterized test
- Add command dispatch test covering all four resource types via execute()
- Add MCP apps=openclaw-only late-error behavior test
- Add cross-app prompt import test for codex
- Add parser error tests: unknown resource, missing params, invalid MCP app
- 17 tests total, zero semantic changes
@SaladDay

Copy link
Copy Markdown
Owner

@LeonardoTan19 I think the cleanest behavior is to make the deeplink URL the single source of truth for target apps. So --app should not override the URL, and we should not silently ignore it either.

If users run something like:

cc-switch --app codex deeplink "ccswitch://v1/import?resource=provider&app=claude..."

we should fail fast with a clear message, for example:

`--app` cannot be used with `deeplink`; target app(s) must be encoded in the URL via `app` or `apps`.

That keeps the protocol reproducible for scripts/geeks, and avoids surprising behavior for beginners.

@LeonardoTan19

Copy link
Copy Markdown
Author

@SaladDay Thanks for your suggestion! I agree on it. I'll get this implemented as soon as possible.

@SaladDay

Copy link
Copy Markdown
Owner

Wowwww!! Thanks you for your contribution!!

@LeonardoTan19

Copy link
Copy Markdown
Author

I have fully replicated the cc-switch behavior for handling deeplinks. This command enables CLI-based deeplink imports. Since it reuses utils.rs, prompt.rs, etc., pulled directly from cc-switch, it shares the exact same Base64 decoding logic—meaning the issue with %20(blankspace) parsing errors is also reproduced here. Hope this bug can be solved in the future.

While I believe we could allow deeplinks to directly trigger the TUI interface in the future, that is out of scope for this PR.

This is now ready for review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants