Contributing
August 14, 2026 ยท View on GitHub
Thanks for your interest in dsh-tool-git! This guide covers development setup, conventions, testing, and the contribution workflow.
Development setup
Requirements:
- Node.js โฅ 22
- pnpm โฅ 11 (the lockfile is generated by pnpm 11.3.0;
pnpm install --frozen-lockfileis used in CI) - git (obviously ๐)
git clone git@github.com:Huasfan/dsh-tool-git.git
cd dsh-tool-git
pnpm install # all dev dependencies come from npm; no local dsh install needed
pnpm typecheck # tsc --noEmit (strict)
pnpm test # vitest โ 28 tests
pnpm build # esbuild bundle โ lib/index.js
To try the plugin in a real harness:
# bundle layer
dsh --profile web --patch /abs/path/to/dsh-tool-git/cordis.patch.yml
# or load the TypeScript source directly (the loader supports .ts)
# name: '/abs/path/to/dsh-tool-git/src/index.ts'
Repository layout
src/ plugin entry (index.ts), git runner (git.ts),
porcelain-v2 parser (status.ts), tool definitions (tools.ts)
tests/ vitest suites
scripts/build.mjs prepare build (esbuild bundle)
cordis.patch.yml dsh bundle layer
Conventions
- TypeScript, strict, erasable-only syntax (no enums / namespaces / parameter properties) โ the source must stay loadable by Node's type stripping.
- Follow the tool contract (per the official tool authoring reference):
executereturns exactly one canonical JSON value declared byoutput.schema;- human-readable prose lives in
output.render, never in the canonical value; - non-zero git exits are domain outcomes (
ok: false+error), infrastructure failures throw; - honor
exec.signalfor cooperative cancellation.
- No shell interpolation โ always pass argument arrays to
execFile. - Keep schemas,
execute, andrenderin sync; add or update tests with every behavior change.
Testing
- Parser changes โ unit tests in
tests/status.test.ts(fixtures are real captured outputs). - Tool behavior โ integration tests in
tests/tools.test.tsagainst throwaway repositories created in a temp directory. - Never run git commands against a real working tree in tests. Always pass an explicit
workdirpointing at the scratch repo โ without it, git acts on the test process's cwd (this has bitten us before). - Run the full suite before pushing:
pnpm testmust pass, pluspnpm typecheckandpnpm build.
Commit & pull request workflow
- Create a branch:
git checkout -b feat/your-change. - Make focused commits with clear messages (English preferred, conventional style:
feat:,fix:,chore:,docs:,test:). - Update the bilingual READMEs / release notes if your change is user-facing (keep
README.mdandREADME.zh.mdin sync). - Open a pull request against
main; the CI checks (typecheck / test / build / real-harness load) must pass. - In the PR description, mention:
- what the change does and why;
- which dsh version you tested against;
- any compatibility impact (dsh is in preview โ interface changes are expected).
Compatibility policy
dshis still pre-1.0; peer/dev dependencies are pinned exactly to the packages shipped with the tested dsh version.- When you upgrade the tested dsh version, bump the pins in
package.json, update the Compatibility section in both READMEs, and re-run the full suite. - If an upstream interface change breaks this plugin, prefer fixing here and documenting the required dsh version over silent workarounds.
Reporting issues
- Use GitHub Issues: include the dsh version, git version, OS, the exact steps to reproduce, and any relevant logs (e.g., the
[git-tool] loadedline and tool errors from thedsh webterminal). - Feature requests and discussions are welcome in Issues too.
License
By contributing you agree that your contributions are licensed under the MIT License (see LICENSE).