Skip to Content
harness-kit

Configuration

Every key of harness.config.ts, with an example of each option, generated from the configuration Schema the kit decodes it with.

A configuration is the default export of harness.config.ts (typed by defineConfig) or the content of harness.config.json. The kit decodes it and refuses any other key. Each example below writes one key with every option it takes; a comment above an option says what it does, and an option a configuration may leave out says what holds without it.

adapters

Optional. The adapters by name, such as forge or tracker, each an executable that answers capabilities or one of the kit's own ({ use: 'github', options }). A configuration that extends another may add adapters but not change one of its.

import { defineConfig } from '@microeinhundert/harness-kit';

export default defineConfig({
  policies: [],
  adapters: {
    tracker: {
      // The adapter's path, relative to the configuration's folder when it starts with `.`, else a
      // program on `PATH` or an absolute path.
      executable: './adapters/linear.mjs',
      // How many milliseconds one call may take; 10 seconds when absent.
      timeoutMillis: 10000,
    },
  },
});

extend

Optional. The path of a central configuration, relative to this file, that this one tightens: its Policies all stay, an entry with the id of one of them may only tighten it, and the other entries add Policies.

import { defineConfig } from '@microeinhundert/harness-kit';

export default defineConfig({
  policies: [],
  extend: './central/harness.config.json',
});

gates

Optional. The gates the working copy calls for, added by harness-kit gates resolve; replaces those of the configuration it extends.

import { defineConfig } from '@microeinhundert/harness-kit';

export default defineConfig({
  policies: [],
  gates: {
    // The gates the working copy calls for, added after the project's own or its kind's, in order.
    derived: [
      {
        // The gate to add: a command line, or an object with its name, command line, exclusivity
        // and time limit.
        gate: 'npm run lint',
        // The condition under which the gate is added.
        when: {
          // The JSON file of the repository root to read.
          file: 'package.json',
          // The keys, from the top, of the value to look for; the gate is added when it is neither
          // `null` nor `false`, as a `jq` query reads it.
          path: ['scripts'],
        },
      },
    ],
  },
});

hookBin

Optional. The kit's bundled bin the hook entries harness-kit settings sync writes run, relative to the folder the settings belong to or absolute, in place of the installed package's dist/cli.mjs; replaces the one of the configuration it extends.

import { defineConfig } from '@microeinhundert/harness-kit';

export default defineConfig({
  policies: [],
  hookBin: './node_modules/@acme/harness/dist/cli.mjs',
});

packageManager

Optional. The project's package manager, in place of the one the kit detects from the packageManager field of package.json and the lockfiles.

import { defineConfig } from '@microeinhundert/harness-kit';

export default defineConfig({
  policies: [],
  packageManager: 'bun',
});

policies

Required. The Policy entries, in the order their Decisions merge in.

import { defineConfig } from '@microeinhundert/harness-kit';

export default defineConfig({
  policies: [
    {
      // What the Policy's hook call answers when the Policy fails, dies or runs out of time: `open`
      // lets the call through, `closed` refuses it.
      failMode: 'closed',
      // The Policy's name, unique in the configuration; messages and logs name the Policy by it.
      id: 'push-target',
      // A stack of the configuration's `stacks`; the Policy runs only where the nearest folder
      // holds a marker of that stack. Everywhere when absent; give at most one of `stack` and
      // `whenFile`.
      stack: 'node',
      // How many milliseconds the Policy may run before it counts as failed; the constructor's
      // default when absent.
      timeoutMillis: 5000,
      // The name of the kit's Policy constructor that builds the Policy.
      use: 'push-target',
      // A file name; the Policy runs only where the nearest folder holds that file. Everywhere when
      // absent; give at most one of `stack` and `whenFile`.
      // whenFile: 'package.json',
      // The constructor's options, which it decodes.
      // options: {},
      // How a person may loosen the Policy on purpose: an environment variable or a user-level
      // allow file.
      // override: {
      //   allowFile: '~/.config/harness-kit/allow',
      //   env: 'ALLOW_PUSH_TARGET',
      // },
    },
  ],
});

projects

Optional. Where the projects come from and how a repository is named in them; replaces the one of the configuration it extends.

import { defineConfig } from '@microeinhundert/harness-kit';

export default defineConfig({
  policies: [],
  projects: {
    // How a repository is named when looked up in the catalog: `origin-basename` (the last segment
    // of the `origin` remote's URL without `.git`, else the root folder's name), `dirname` (the
    // root folder's name), `remote-url` (the `origin` URL itself, else the root folder's name) or
    // `{ explicit }`, a name. `origin-basename` when absent.
    identity: 'dirname',
    // Where the projects come from: a static map in the configuration (`catalog`), a JSON file
    // holding the same map (`file`), or a command (`command`) that resolves a project.
    source: {
      // A static map of the projects, written in the configuration.
      catalog: {},
    },
  },
});

stacks

Optional. The stacks by name and the markers that detect them, in detection order, in place of the defaults; replaces those of the configuration it extends.

import { defineConfig } from '@microeinhundert/harness-kit';

export default defineConfig({
  policies: [],
  stacks: {
    web: {
      // The markers that detect the stack, any of which is enough.
      detect: [
        {
          // How many folder levels below the folder the file may be; 0, the folder alone, when
          // absent.
          depth: 1,
          // The name of a file the folder holds, such as `package.json`, that marks the stack.
          file: 'package.json',
        },
      ],
    },
  },
});

tracker

Optional. What harness-kit tracker reads beside the tracker itself; replaces the one of the configuration it extends.

import { defineConfig } from '@microeinhundert/harness-kit';

export default defineConfig({
  policies: [],
  tracker: {
    // How many minutes back `create` looks for an issue with the same title before it creates one,
    // and after a create whose outcome it cannot tell; 60 when absent.
    dedupeWindowMinutes: 30,
    // The rule `create` enforces on a new issue title before it asks the tracker anything: a title
    // that starts with an emoji may have at most `emojiPrefixMaxWords` words after it. None when
    // absent.
    titleRule: {
      // How many words may follow a first word that has no letter or digit (an emoji) in a new
      // issue title.
      emojiPrefixMaxWords: 8,
    },
  },
});

On this page