# Contributing

Thank you for helping. Bug reports, fixes and small improvements are welcome.

## Before you start

- **For a bug**, open an [issue](https://github.com/instruction-md/specification/issues). Include:
  - the command you ran;
  - the agent's app and its version (for example Claude Code 2.1.330, Codex 0.170.0);
  - what happened, and what you expected.

  For a hook, the event JSON you piped in is the best report. Remove any tokens from it first.
- **For a new command, flag or host**, open an issue first, so we can agree on the shape before you write it.
- **Hooks must never break a prompt.** `hook` and `turn` exit 0 and say problems on stderr. They wait at most a
  deadline, and they read without subscribing. Changes that block a prompt by default won't be accepted.
- **Keep earlier names working.** Old command names (`connect --with-hooks`, `sync`, `fleet`, `doctor`) and hook
  settings that projects already committed must keep running.

## Develop

You need Node.js 18 or later and [pnpm](https://pnpm.io/). For now the package is developed inside instruction.md's
monorepo: it depends on workspace packages (`instruction.md`, and the private `@instruction-md/spec` and
`@instruction-md/mcp-client`, given as `workspace:^`), and its build runs the monorepo's `scripts/build-library.mjs`.
So `npm install` in this folder alone fails (`EUNSUPPORTEDPROTOCOL … "workspace:"`). From the repository's root:

```sh
pnpm install
pnpm --filter @instruction.md/agents test        # Node's test runner, through tsx
pnpm --filter @instruction.md/agents typecheck   # tsc --noEmit
pnpm --filter @instruction.md/agents build       # dist/, what is published
```

The tests need no network and no account. They use fakes:

- a fake registry client for `run` and `apply`;
- a fake ACP agent (`test/fixtures/acp/`);
- sample events for each host's hook.

Don't set `XDG_CONFIG_HOME` or `INSTRUCTION_MD_ACCOUNTS` while you run them: some tests expect the default accounts
path. Add a test for every behaviour you change.

To try the command from source, run `node bin/instruction-agents.js <command>` in this folder. It runs the TypeScript
through tsx. To try it as a user would, `pnpm pack` it (and `instruction.md` and `@instruction.md/seal`, which it
depends on) and install the tarballs in an empty project.

## Pull requests

- One change per pull request, with a short description of why.
- Update `README.md` when you change something a user sees: a command, a flag, a default, a file written, or an
  environment variable.
- Add a line to `CHANGELOG.md`.
- By sending a pull request, you agree that your contribution is licensed under the MIT License of this project.

## Security

Don't report a vulnerability in a public issue. See [SECURITY.md](./SECURITY.md).
