Skip to content

Latest commit

 

History

History
233 lines (161 loc) · 20 KB

CONTRIBUTING.md

File metadata and controls

233 lines (161 loc) · 20 KB

Contributing to DS Bot

English | 中文

Thank you for helping. This file explains how the team works, how to set up the plugin, how to test a change and which rules a change must follow. For what the plugin does and how users install it, see README.md.

Who can open pull requests

Collaborators of this repository push branches here and open pull requests into dev (see How we work). For now, only collaborators can open pull requests. If you are not a collaborator, please open an issue for a bug (see Report a problem) or use Discussions for a question or an idea.

A clear bug report, root-cause trace, or accepted feature idea is as valuable as a pull request. When an external issue or idea directly leads to a shipped fix or feature, the maintainer may credit its author with Co-authored-by (see Issue co-author credit).

The rules that matter most

  1. Build on DSH; never patch it. The Bot features are a DSH plugin: use the plugin APIs that DSH documents (Cordis services, the plugin client entry, profile patches). The desktop app starts DSH only through the entry points that DSH documents (@deepseek-ai/dsh/profile-boot, the dsh command). Do not patch DeepSeek Harness, and do not depend on files inside a DSH install. When a feature needs something that DSH does not offer, open an issue here first; the fix can belong in DSH.
  2. Bots run in DSH Sessions. Each Bot has its own saved profile (including model, thinking level, instructions, folder and permissions), distinct from the host's DSH profile. Its chat, group work and background tasks use separate Sessions; long context can be condensed in place or continued in a fresh part. Model Bots use DSH's agent loop and model service; local-agent routes delegate tools, model access and context to the CLI. Auxiliary model calls bypass the agent loop, and DeepSeek OCR/TTS/ASR and web search/fetch make direct service requests. Do not assume all requests use DSH model routing or add an unrelated runtime.
  3. No real secrets anywhere. Do not commit API keys, tokens, cookies, DSH_HOME folders, logs or screenshots with personal data. The tests and the test bench use a scripted mock model and need no key.
  4. Only original material. Do not copy code, text, icons, logos or other graphics from other products or websites. Code under a license compatible with Apache 2.0 is the only exception: say where it comes from and add its notice to a NOTICE file. This rule is about DS Bot's own interface. To name a third-party product that DS Bot connects to (for example the agent CLI a Bot runs on), use that product's official logo, and list it in NOTICE with its source and owner.
  5. Every change is tested. Run the unit tests and the client check for every change (see Test a change).

How we work

Anyone on the team can do any kind of work: triage, bug fixes, features, the interface, docs. Only some decisions belong to the maintainer: the direction of the product, changes to a design that is already decided, these rules, releases and the architecture. Issues and pull requests that need such a decision carry the maintainer label; wait for the maintainer's answer before you start on them. What DS Bot is meant to be is in docs/vision.md; the decided designs are in docs/plans/ and the UI standard is in docs/design/ui-standard.md (in Chinese). When you are not sure whether something is a bug or works as designed, read them first, then ask in the issue.

Branches

Branch What it is Who merges
dev Integration branch. All fixes and features go here first Every collaborator, when CI passes
main Released code only. It changes when the maintainer merges dev for a release, or merges a hotfix The maintainer
fix/<issue>-<name>, feat/<issue>-<name>, docs/<name>, chore/<name> Your work. Start it from the latest dev —
  • Do not start a branch name with dev/. Git cannot create dev/<name> while the branch dev exists.
  • To bring your branch up to date, run scripts/merge-dev.sh: it merges origin/dev, and a conflict in the generated ds-bot/client.js is taken from dev and rebuilt (on a hotfix branch, git merge main). Do not rebase a pushed branch and do not force-push.
  • main is the default branch, so GitHub suggests main as the base of a new pull request. Change the base to dev.

Issues

  1. Triage. Give each new issue a type, a priority and an area (see Labels). One priority label per issue. The steps, with a script that lists what needs triage, are in .agents/skills/issue-triage/ (in Chinese); an AI agent can follow them as well.
    • A question (how to install, how to use): select Convert to discussion and move it to the Q&A category.
    • Not enough information to find the cause: add needs-info and ask for exactly what is missing. Say that the issue is closed after 14 days without an answer.
    • A cause in DSH or in another plugin: add upstream and link the place where it belongs.
    • The same as an open issue: add duplicate, link the other issue and close this one.
  2. Claim. Assign the issue to yourself and write "I'll take this" in it before you start, so that two people do not work on the same thing. Do not take an issue that already has an assignee; ask in the issue first.
  3. Features. A new idea starts in Discussions (Ideas). When the maintainer agrees, it becomes an issue with the enhancement label. Before you build a feature, write in the issue how you plan to do it. For a large feature, add a design note in docs/plans/<date>-<topic>.md to the same pull request.
  4. Close with evidence. When you close an issue, link the pull request or commit that fixed it, the issue it duplicates, or the reason it will not be fixed. Write the comment in the language of the issue.

Labels

Kind Labels
Type bug · enhancement · documentation
Priority P0 crash, data loss or cannot use · P1 hurts daily use · P2 ordinary bug or feature · P3 suggestion or narrow case
Area area/host server side (index.js, src/host/) · area/client interface (src/client/) · area/group group chats, mentions, Bot-to-Bot messages · area/memory memory, conversation parts, context · area/browser Bot browser, page reading, web search · area/build CI, release, scripts, test bench · area/docs
Flow maintainer waits for the maintainer · needs-info waits for the reporter · upstream the cause is in DSH or another plugin · duplicate · auto-found found by automated testing
PR Agent agent/antigravity · agent/claude-code · agent/codex · agent/devin · agent/dsbot · agent/other (which AI agent opened the PR)
PR Review review/approved · review/changes-requested · review/needs-decision · review/re-review (mutually exclusive) · reviewed-by/<agent> (which AI agent reviewed the PR)

An issue that spans several areas, or none, gets no area label.

Pull requests

  1. Open the pull request into dev and fill in the template. Link the issue with Fixes #<number>; a bug fix always names the bug it fixes. When opening a pull request from a fork, keep Allow edits from maintainers turned on so that the maintainer can resolve conflicts or make small adjustments before merging.
  2. Write one sentence about what users will notice in the Changelog field of the template, or "none". Do not edit CHANGELOG.md: the maintainer writes it from these sentences at release time.
  3. When CI passes and independent review is approved (review/approved), merge into dev with Create a merge commit, then delete the branch.
  4. A fix that is merged into dev does not close its issue: Fixes #<number> acts only on the default branch. The issue stays open until the release, which means "fixed in dev, not released yet".

Keep one pull request to one issue. Split a large change into several pull requests.

Issue co-author credit

A clear bug report, root-cause trace, or well-reasoned idea is often as valuable as a pull request. When an external issue or accepted Discussion idea directly leads to a shipped fix or feature, the maintainer may credit its author with a Co-authored-by trailer on the implementing commit—or on the merge commit into dev if the branch is already pushed (do not rebase or force-push just to add a trailer):

  • Scope: Granted at the maintainer's discretion for substantive contributions (clear reproduction, root-cause analysis, or an accepted design/feature proposal). Brief one-line wishes or duplicate/low-effort reports are not credited, and commit authors do not credit themselves.

  • Format & privacy: Always use the author's GitHub noreply address—never a personal email—by looking up their numeric user ID:

    gh api users/<login> --jq '"\(.id)+\(.login)@users.noreply.github.com"'

    Add the trailer at the end of the commit message after a blank line, putting the command's output inside <...> alongside Fixes #<number> and Reported-by: @<login> (or Idea-by: @<login>) so Git history clearly distinguishes issue/idea credit from code authorship:

    Fixes #<number>
    Reported-by: @<login>
    Co-authored-by: <login> <123456+login@users.noreply.github.com>
    

    (For legacy GitHub accounts created before July 2017 whose noreply omits the numeric ID, <login>@users.noreply.github.com can be used if the ID form does not link.)

  • Opt-out: Mention the planned credit in the issue before merging when practical. If the author prefers not to be listed in Git history, omit Co-authored-by (and thank them in the release notes instead if they prefer).

  • No AI co-authors: This credit is for human issue and idea authors only. Never add an AI tool or bot as author, committer, or Co-authored-by.

Merge conflicts

  • ds-bot/client.js: never resolve it by hand. Resolve the conflicts in ds-bot/src/client/, run npm run build in ds-bot/ and commit the new client.js.
  • CHANGELOG.md: pull requests do not change it, so it should not conflict. If it does, keep both sides.

Releases (maintainer)

  1. In a pull request into dev, update the version in ds-bot/package.json, app/package.json, and the README.md / README.zh.md badges, and write the CHANGELOG.md section from the Changelog sentences of the merged pull requests.
  2. Open a pull request from dev into main titled release: vX.Y.Z. List every Fixes #<number> of the release in its description, so that these issues close when it is merged.
  3. Before you merge it, run the release checklist (in Chinese) on a real Windows machine, and on macOS when the change touches it, and post the result in the pull request. Merge it with a merge commit and publish a GitHub release vX.Y.Z on main, with "Set as the latest release" turned off: the workflow marks it latest itself once the installers, SHA256SUMS.txt and the download table are attached. The Release workflow checks that the tag matches the version and is on main, runs the checks and publishes the package to npm (a pre-release version under the npm tag next). Do not run npm publish by hand.
  4. For a hotfix, start fix/hot-<name> from main, open the pull request into main, release a patch version, then merge main into dev.

Set up

You need:

  • Node.js 22.19 or later (or 24 and later).
  • Git.
  • For the test bench only: pnpm 11 and a checkout of DeepSeek Harness at the DSH version that the plugin is tested with.
git clone https://github.com/Fei-Craft/DS-Bot.git ds-bot-repo
cd ds-bot-repo/ds-bot

# The plugin's packages and its build tool (esbuild).
npm ci

# The phone link's packages: the build bundles them into link.js, and a unit test builds it.
npm ci --prefix ../link

# The DSH packages that the unit tests and the linter load, reproducibly from dev/harness/package-lock.json.
npm run harness

For the test bench, add the DeepSeek Harness checkout next to the plugin folder (this folder is ignored by Git):

cd ..
git clone https://github.com/deepseek-ai/deepseek-harness.git
git -C deepseek-harness checkout dsh-v0.2.2-rc.5
(cd deepseek-harness && pnpm install)

If your DeepSeek Harness checkout is somewhere else, set DSH_HARNESS to its path. DSH_HARNESS also takes the place of dev/harness/ for the unit tests and the linter.

To test another DSH version, run node scripts/update-harness-lock.mjs <dsh-version> in ds-bot/. It updates dev/harness/package.json and resolves dev/harness/package-lock.json; shared packages use the versions in app/package-lock.json where the app has one unambiguous version, so the tests run against what the desktop app ships.

The @deepseek-ai/* packages are peer dependencies: in a real install, the DSH profile supplies them. ds-bot/.npmrc keeps npm from installing them into the plugin folder.

Layout

Path What it is
ds-bot/index.js, ds-bot/src/host/ The server side: Bot roster and store, tools, turns and delivery, background tasks, group chats and ledger, memory, capabilities and feature packs, connectors, IM, phone and MCP gateways, the api/bot channel
ds-bot/src/client/ The browser side: sidebar, chat, settings console, panels and dialogs, themes, 8-language i18n, characters, the Bot browser panel
ds-bot/client.js Generated from src/client/ by scripts/build-client.mjs. Committed so that Git installs need no build step
ds-bot/web-search.js The auto web-search provider. Independent of the Bot team code
ds-bot/cordis.patch.yml The profile patch that the plugin brings
ds-bot/test/, ds-bot/dev/ Unit tests, browser tests, mock model, test bench, smoke test, character generator and evaluation tools
app/ Standalone desktop app (Electron main process, start window, import and move-data, auto-updates, installers)
mobile/, link/ Mobile app (Expo React Native + browser remote export) and encrypted relay transport
browser-plugins/, docker/ Optional interactive browser plugins (refs / script / task) and Docker deployment
docs/ Docs index, vision, UI standard, decided design plans and release checklist

Test a change

Run these in ds-bot/:

npm run build                          # src/client → client.js
npm test                               # unit tests; they also fail if client.js is stale
node scripts/build-client.mjs --check  # client.js matches src/client
npm run lint                           # oxlint

CI runs npm test (sharded across Linux runners, including the generated-bundle checks) and npm run lint for pull requests to dev that touch ds-bot/, link/, or start.ps1 (Docker changes also verify Docker on PRs to dev). Cross-platform Windows, Node 22, Docker, and desktop/mobile packaging suites run on the daily dev Nightly CI, on release/hotfix pull requests to main, and on demand via manual workflow dispatch (the ci/full-package PR label also triggers Package & Native on demand). CI also scans the tracked files for keys, tokens, personal paths and e-mail addresses, and for material that must stay local. To run the scan yourself, from the repository root:

mkdir -p /tmp/ds-bot-tree && git archive HEAD | tar -x -C /tmp/ds-bot-tree && node scripts/scan.mjs /tmp/ds-bot-tree

A "must fix" finding fails CI; "can stay" findings are for reading. The branch rules require the single check Test result, which passes only when all the checks pass.

For a change to the server side (index.js, src/host/), also run the smoke test. It starts the mock model and a DSH Web with the plugin linked from your checkout, and walks through the main flows (Bots, group chats, conversation parts, condensing, settings). CONTEXT_WINDOW and CHECK_RATIO give the mock models a small window, so a few long replies reach the check line:

CONTEXT_WINDOW=100000 CHECK_RATIO=0.45 dev/bench.sh smoke 3096 8796 reset && node dev/smoke.mjs smoke 3096
dev/bench.sh smoke 3096 8796 stop

For a change to the Bot browser (src/host/browser/), also run its tests. They drive a real Chromium and check what a Bot may not do on a page without the user (pay, delete, post, upload) and that Bots do not share cookies. CI runs them on Linux. Install Chromium once, then run them:

npx playwright-core install --only-shell chromium
npm run test:browser

To try the plugin by hand, start a bench and open the address that it prints:

dev/bench.sh dev 3081 8771 reset    # mock model + DSH Web; data in ../.dsh-test-dev

The mock model answers a fixed set of commands, so a bench costs no tokens. The commands are listed at the top of dev/mock-llm.mjs. Bench data stays in .dsh-test-<name>/ next to the plugin folder and never touches your own ~/.dsh.

For a change to the context steward or its prompts (src/host/steward.js), also check it on a real model. dev/steward-eval.mjs runs its decisions on fixed conversation endings, and dev/llm-tap.mjs logs every call a real bench makes. Both cost tokens and explain their use at the top.

For a change to the Bot browser, check it in DSH Desktop. On Linux, the scripts in dev/desktop-linux/ run DSH Desktop under Xvfb; each script explains its use at the top.

Write a change

  • Keep a change to one subject.
  • Do not edit client.js by hand. Change src/client/, run npm run build and commit both.
  • In src/client/, take colors from the --bt-* variables, corner radii from the steps 4, 6, 8, 10, 12, 16, 18, 20, 22, 999px and 50%, and springs from motion.js. A unit test checks this. The places written before the test are listed in test/style-debt.json; that list only gets shorter. When you remove one, run node scripts/style-debt.mjs --write to update it.
  • Follow the style of the code around your change. Write a comment only when the reason for the code is not clear from the code itself.
  • Write commit messages in English. Use a short subject in the imperative mood ("Keep group replies visible") and explain the reason in the body.
  • The author of a commit is the person who made the change. When an AI tool helped, do not add it as an author or with a Co-authored-by line; turn that setting off in the tool. Human authors of substantive external issues or accepted ideas may still be credited as co-authors (see Issue co-author credit).
  • Do not edit CHANGELOG.md. Write the user-visible change in the Changelog field of the pull request instead.

Report a problem

The easiest way is from DS Bot itself: open Settings → About DS Bot → Feedback, write what happened and select Report on GitHub. It opens a new issue with the DS Bot and DSH versions, your system, the models and the recent errors already filled in. Copy puts the same text on the clipboard, and Download saves the full error log (<DSH_HOME>/bot/logs/diagnostics.jsonl).

If you open an issue by hand, include:

  • The DSH version (DSH Desktop or @deepseek-ai/dsh), your operating system, and whether you use DSH Desktop or DSH Web.
  • How you installed DS Bot (npm, release file, Git address or command line) and its version.
  • What you did, what you expected and what happened, with the exact error text.
  • A screenshot of the whole window, with the chat and the error.
  • The steps that make it happen again.

DS Bot removes API keys, tokens, saved secrets and your home folder from its diagnostics. Read the text before you post it, and remove personal data from screenshots.

For a security problem, do not open a public issue. Use Report a vulnerability on the repository's Security tab.

Issues are for bug reports. Questions, ideas and feature requests belong in Discussions. An idea that the maintainer accepts becomes an issue.

License

DS Bot is licensed under the Apache License 2.0. When you submit a contribution, you agree that it is licensed under the same license, as section 5 of the license says.