DeepSeek Harness (DSH) workspace code is usually managed locally. To publish it to GitHub, you typically need to manually create a repository, initialize git, configure credentials, and push. The dsh-github-sync plugin manages GitHub Personal Access Tokens (PATs) through the DSH credential store and automates repository creation, initialization, committing, and pushing. The plugin is maintained by s-huizhuy-u and uses the MIT License.

Core Features

The plugin provides the following capabilities:

  1. Create a repository: Create it if it does not exist on GitHub; reuse it if it already exists.
  2. Initialize git: Preserve the project’s current branch; use main by default for a new repository.
  3. Commit: Stage and commit the entire worktree; if there are no changes, reuse the existing HEAD instead of failing.
  4. Push: If histories have diverged, first fetch, then rebase, then push.
  5. Automatic configuration: Write the account’s commit identity and record the branch upstream.
  6. Read-only preview: github_status reports what synchronization will do without changing anything.

Installation and Activation

Copy the plugin package to the DSH profile directory and run the installation script:

node scripts/install.mjs

The script locates the DSH home directory, copies the plugin to <profile>/.local-plugins/ and <profile>/node_modules/, and updates dsh.profile.bundles and cordis.patch.yml. Restart DSH after installation.

Environment Requirements

Running this plugin requires the following:

  • DeepSeek Harness 0.1.5-rc.2 or later
  • Node.js 20.12+ (requires AbortSignal.any)
  • A git executable available in PATH

Typical Usage

The plugin provides three main tools:

  • github_sync: Publish the current workspace.
  • github_status: Report what synchronization will do.
  • github_configure: Validate and store a token with the GitHub API.

Example Interaction

The user instructs the assistant:

You: Publish this project to GitHub

After the assistant runs github_sync, it responds:

DSH: Synchronized 12 changed files to octocat/my-project (branch main).
Repository: https://github.com/octocat/my-project

Authentication Configuration

Before use, a GitHub Personal Access Token (PAT) is required.

Provision Methods

There are three ways to provide a token:

  1. Environment variable: Set GITHUB_TOKEN or GH_TOKEN. This is the best option for CI and shared machines, leaving no trace on disk.
  2. Assistant storage: Say “Save my GitHub token”, and the assistant will use github_configure to store it.
  3. HTTP API: Send a request to POST /api/github-sync.token with the body {"token": "..."}.

Permission Requirements

Token type Required permissions
classic repo (public_repo can be used only for publishing public repositories)
fine-grained Contents: Read and write; to create repositories, also Administration: Read and write

Important note: Stored tokens are kept in the DSH credential store, not in settings.yaml. All tokens are redacted in logs and conversation records.

Design Trade-offs

For security and stability, the plugin makes the following design decisions:

  1. Tokens are never written to disk: origin stores a clean repository URL; credentials are used only for a single git push. Tokens do not enter .git/config.
  2. Git never prompts: Each invocation sets GIT_TERMINAL_PROMPT=0, GIT_ASKPASS=, and GCM_INTERACTIVE=never to prevent the call from hanging when authentication fails.
  3. Remote divergence is coordinated: On conflict, use git rebase --abort to roll back; the worktree remains unchanged, and conflicts must be resolved manually or force must be explicitly enabled to overwrite.
  4. Not concurrency-safe: Multiple git operations on the same workspace may contend on the index lock.

Troubleshooting

Symptom Cause and resolution
No GitHub token is configured Set the GITHUB_TOKEN environment variable, or use github_configure to store a token and restart DSH
GitHub rejected the request (HTTP 401) The token has expired or is incorrect; reissue it
HTTP 403 with a permission hint Check the token permissions. A fine-grained token must select the repository and be granted write permissions for Contents and Administration
TLS_UNTRUSTED If using a GitHub accelerator (such as Watt Toolkit or FastGithub), configure NODE_EXTRA_CA_CERTS
git push failed … non-fast-forward The remote has newer commits; retry or pass the force parameter to overwrite