Skip to content

feat(dsh): set up any DSH profile in any DSH home - #2968

Open
Fengzdadi wants to merge 1 commit into
oceanbase:masterfrom
Fengzdadi:fix/dsh-any-profile-home
Open

Fengzdadi wants to merge 1 commit into
oceanbase:masterfrom
Fengzdadi:fix/dsh-any-profile-home

Conversation

@Fengzdadi

Copy link
Copy Markdown
Collaborator

Which issue or RFC does this PR close?

No PowerContext issue tracks this. LodyAI/Lody#3460 proposes PowerContext as a Lody memory provider. Lody runs DSH with its own DSH_HOME (<Lody data>/dsh/providers/<provider id>) and the profile lody-acp, so the provider can connect DSH only if powercontext setup dsh accepts that profile and keeps that home's connection apart from the user's ~/.dsh. This builds on setup --remove (#2889).

Rationale for this change

powercontext setup dsh accepts only the web and desktop profiles, and doctor's DSH check always inspects web. An application that runs DSH under its own profile can't be connected.

The Client settings keep one hosts.dsh record with one profile and no DSH home. Setting up DSH under another DSH_HOME replaces the user's ~/.dsh record. Doctor and removal then read the wrong profile for each home. Removing PowerContext from one home also drops the other home's saved connection.

What changes are included in this PR?

  • Any profile. setup dsh, setup dsh --remove, doctor dsh, and config agent dsh accept any DSH profile name.
    • Valid names start with a letter or digit and contain only letters, digits, ., _, and -. A case variant of desktop is rejected.
    • Profiles other than desktop register through the DSH CLI the same way Web does: with the dsh on PATH, or with --dsh-command.
    • Doctor runs dsh --profile <profile> --dump-config and names the profile it checked, instead of always checking web.
    • A single --profile with both dsh and kimi-code selected still exits with code 2 before any write. Before, no value was valid for both agents. Now full would be a valid DSH profile name, so the combination is rejected explicitly.
  • One record per DSH home in hosts.dsh.
    • The default home ~/.dsh keeps the top-level profile and dsh_command fields, the format that earlier releases write and read.
    • Every other home gets hosts.dsh.homes["<resolved absolute path>"] = {"profile", "dsh_command"}.
    • The Server URL and allow_insecure_http stay shared at the top level, because the DSH plugin reads them without knowing its home.
    • Credentials and the Skill were already per home ($DSH_HOME/powercontext/credentials.json, $DSH_HOME/skills/...).
  • Which record each command uses. Setup, doctor, removal, and config agent use the record of the home that DSH_HOME selects (~/.dsh when unset).
    • Removal drops only that home's record and credential. The shared URL and consent go with the last home's record.
    • powercontext doctor without agent names includes DSH only when the selected home has a record. Another home's connection therefore doesn't show up as a failed ~/.dsh check.
  • Existing records.
    • A hosts.dsh record without homes is the default home's. That includes a record that has only the Server URL, from releases before profile selection.
    • When setup first records another home next to such an endpoint-only record, it writes profile: "web" at the top level, which is what the record already meant. Removing the other home later then can't treat the default home's connection as unused.
  • Checkout retention across homes. Removal already keeps a cloned source checkout that any DSH profile still links to. It now also reads the profiles of every other home that hosts.dsh records.
  • Docs (en and zh).
    • The DSH guide gets an "Other DSH homes" section with the hosts.dsh shape and the compatibility rule.
    • The guide's profile and removal text and develop/interfaces.md are updated.
    • The guide no longer says interactive setup asks for web or desktop; the CLI has no such prompt.

Are there any user-facing changes?

Yes.

  • --profile for DSH accepts any valid profile name, and DSH can be connected in several homes at once.
  • The persisted format of hosts.dsh gains an optional homes object. Older releases ignore it and keep reading the default home's top-level fields.
  • Compatibility edge. A record that an earlier release saved while DSH_HOME pointed somewhere other than ~/.dsh is now read as the default home's. With that DSH_HOME set, doctor and removal no longer find it until powercontext setup dsh runs again with that DSH_HOME and the same --profile, plus --dsh-command if the original setup used one. Without --profile, setup records web for a home that has no record, so a home set up as desktop or a custom profile needs the flag. The docs say this. The old record also stays the default home's, so even after that rerun a plain powercontext doctor without DSH_HOME still checks DSH in ~/.dsh.
  • For a partial removal, the result.removed entry reads <clients.json> hosts.dsh record for DSH home <home> instead of <clients.json> hosts.dsh.

Follow-up, out of scope here: which dsh registers the plugin in Lody's home. Lody's DSH has no stable path to pass as --dsh-command. Lody also holds a provider-home lock that an external dsh plugin call doesn't take. Until that is settled, setup in Lody's home needs a dsh on PATH that can manage that home.

How was this change tested?

New tests, all through the CLI. Each fails on master at edd90eb85 and passes here; the revert check ran the new tests against master's src:

  • tests/test_dsh_profiles.py::test_custom_profile_in_another_dsh_home_sets_up_checks_and_removes: setup, doctor, and removal of lody-acp under a Lody-style DSH_HOME. The default home stays untouched, and a saved-connection doctor without DSH_HOME leaves DSH out.
  • tests/test_dsh_profiles.py::test_default_and_provider_homes_keep_separate_connections: ~/.dsh (web) and a provider home (lody-acp). Neither setup overwrites the other's record or credential. Doctor in each home checks its own profile. Removing the provider home leaves the user's record, credential, and registration.
  • tests/test_dsh_profiles.py::test_a_record_without_a_home_stays_the_default_home_connection[profile-without-home|endpoint-only]: an existing record without a home survives removal, setup, and removal in another home, and stays the default home's.
  • tests/test_setup_remove.py::test_dsh_remove_keeps_a_checkout_that_another_dsh_home_links_into.

Updated tests:

  • tests/test_setup_remove.py: the DSH removal tests save a record without a home, so they now run in the default home (HOME under tmp_path, home tmp_path/.dsh). --profile mobile became --profile ../web as the invalid name.
  • tests/test_cli_kimi_code.py: the combined dsh + kimi-code --profile rejection asserts the new message. One stub stops reading .value from the profile, which is now a plain string.

Commands, all offline (UV_OFFLINE=1 UV_NO_SYNC=1):

  • make check: passed.

  • pytest tests/test_setup_remove.py tests/test_dsh_cli.py tests/test_dsh_profiles.py tests/test_dsh_transport.py tests/test_system_cli.py: 245 passed, 141 skipped (Windows-only cases and native DSH tests that need DSH_TEST_EXECUTABLE).

  • The 33 top-level test files that mention DSH, the Client settings, or --profile, run normally and again with GITHUB_ACTIONS=true: 1415 passed, 147 skipped in each run.

    pytest $(grep -lE 'dsh|clients\.json|client_config|--profile' tests/*.py)
  • On a merge with master at 0b60e52ac, the five files above: 245 passed, 141 skipped.

Not run:

  • A real DSH CLI: the native DSH composition tests skip without DSH_TEST_EXECUTABLE.
  • Lody itself.
  • make unit-test and tox.

AI usage statement

Claude Code (Claude Opus 5.5) wrote the change, the tests, the docs and this description, and ran the checks listed above. Another Claude Code session (Claude Opus 5.5) reviewed the change before the PR was opened, once for the implementation and once for users and the documented contract, checked this description's claims, reran make check on the branch, and ran the five focused test files on a merge with master 0b60e52ac.

`setup dsh`, `setup dsh --remove`, `doctor dsh` and `config agent dsh` accept
any DSH profile name; profiles other than desktop register through the DSH CLI
the way Web does, and doctor checks the selected profile instead of web.

The Client settings record each DSH home's profile and command: the default
~/.dsh keeps the top-level fields of hosts.dsh, and every other home gets a
record under hosts.dsh.homes keyed by its resolved path. Setup, doctor and
removal use the record of the home DSH_HOME selects, so connecting an
application's own DSH home no longer replaces the user's ~/.dsh connection.
Removal drops only its home's record; the shared endpoint goes with the last
one. A record without homes stays the default home's. Doctor without agent
names checks DSH only when the selected home has a record, and removal keeps
a checkout that a profile in any saved home still links to.
@hidb4ai hidb4ai added the module:core Core: PR changes under src/ label Dec 2, 2026

@hidb4ai hidb4ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the per-home target persistence, profile validation, removal boundaries, and documented compatibility edge. Actual DSH CLI setup/doctor/removal across two isolated homes passed against a running Server, including continued operation after removing the other home. No actionable defect found. This does not qualify the separate Lody application integration.

@hireview001

Copy link
Copy Markdown
Collaborator

The affected modules are Core. @hidb4ai, please coordinate follow-up. Core: @hidb4ai @frf12 @Fengzdadi @beatenevo. Please coordinate the review of the affected changes.

plugin, run, inspect = setup_boundary
inspect.return_value = {"memoryProtocol": "atomic-artifact-v1"}
monkeypatch.setattr(dsh_pet, "read_dsh_settings", inspect)
monkeypatch.setenv("HOME", str(tmp_path))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] Isolate the default DSH home on Windows

On Windows, Path.home() ignores HOME, so clearing DSH_HOME here makes test_default_and_provider_homes_keep_separate_connections rewrite the real user's DSH registration, Skill, and credential. Mock Path.home() or also redirect USERPROFILE in this fixture and the analogous client_config fixture in tests/test_setup_remove.py to keep writes inside the temporary home.

This branch has not been deployed

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

Labels

module:core Core: PR changes under src/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants