stop-command
The built-in Policy stop-command, against a turn that ends with failing lint, unsaved work or an incomplete hand-off: its defaults, its options and a configuration that writes it.
To learn what it guards against and see it at work, read the guide: Stop checks and hand-off.
Defaults
| Default | Value |
|---|---|
| On by default | no: an entry turns it on |
| Fail mode | closed |
| Timeout | 300000 ms |
| Events | set by its options |
| Tools | every tool, or as its options set |
| Agent types | every agent, or as its options set |
Options
| Option | Type | Default | Description |
|---|---|---|---|
diffBase | ("session-start" | object | object)[] | — | The ways to find the diff base, the first found winning: session-start (the commit HEAD was on when the session began), { mergeBase } or { ref }; ['session-start'] when absent. |
envSetup | string | — | Shell text run before the command in the same shell, such as source "$NVM_DIR/nvm.sh" && nvm use. |
fallbackRun | string | — | The command to run on the whole tree when no diff base is found; without it the changes since HEAD are judged. |
output | object | — | How the output is shortened for the agent: maxLines (120), maxLineChars (300) and dedupe (none, or tsc to show each TypeScript error once). |
require | object | — | A file the command needs, relative to the folder; while it is missing the stop blocks with hint. |
retryOnExit | integer[] | — | Exit codes after which the command runs once more, such as 130 and 143 for an interruption. |
run | string | required | The command, run by bash in the folder the Policy works in; {diff_base} stands for the diff base commit. |
whenChanged | string[] | — | Globs, relative to that folder, of the changed files (committed since the diff base, uncommitted or untracked) that make it run; any change when absent. |
Example
A configuration that writes every option, a comment above each:
import { defineConfig } from '@microeinhundert/harness-kit';
export default defineConfig({
// The Policy entries, in the order their Decisions merge in.
policies: [
{
// The Policy's name, unique in the configuration; messages and logs name the Policy by it.
id: 'stop-command',
// The constructor's options, which it decodes.
options: {
// The ways to find the diff base, the first found winning: `session-start` (the commit
// `HEAD` was on when the session began), `{ mergeBase }` or `{ ref }`; `['session-start']`
// when absent.
diffBase: ['session-start'],
// Shell text run before the command in the same shell, such as
// `source "$NVM_DIR/nvm.sh" && nvm use`.
envSetup: 'source "$NVM_DIR/nvm.sh" && nvm use',
// The command to run on the whole tree when no diff base is found; without it the changes
// since `HEAD` are judged.
fallbackRun: 'npm run typecheck',
// How the output is shortened for the agent: `maxLines` (120), `maxLineChars` (300) and
// `dedupe` (`none`, or `tsc` to show each TypeScript error once).
output: {
// How repeated lines are folded: `none` keeps them, `tsc` shows each TypeScript error
// once; `none` when absent.
dedupe: 'none',
// The most characters of a line shown before it is cut; 300 when absent.
maxLineChars: 1,
// The most lines of output shown; 120 when absent.
maxLines: 1,
},
// A `file` the command needs, relative to the folder; while it is missing the stop blocks
// with `hint`.
require: {
// A file the command needs, relative to the folder the Policy works in.
file: 'node_modules/.bin/tsc',
// What the stop tells the agent to do while the file is missing.
hint: 'Run `npm ci` first.',
},
// Exit codes after which the command runs once more, such as 130 and 143 for an
// interruption.
retryOnExit: [1],
// The command, run by `bash` in the folder the Policy works in; `{diff_base}` stands for
// the diff base commit.
run: 'npx tsc --noEmit',
// Globs, relative to that folder, of the changed files (committed since the diff base,
// uncommitted or untracked) that make it run; any change when absent.
whenChanged: ['src/**/*.ts'],
},
// The name of the kit's Policy constructor that builds the Policy.
use: 'stop-command',
},
],
});format-on-edit
The built-in Policy format-on-edit, against edited files left unformatted: its defaults, its options and a configuration that writes it.
work-saved
The built-in Policy work-saved, against a turn that ends with failing lint, unsaved work or an incomplete hand-off: its defaults, its options and a configuration that writes it.