allowed-paths
The built-in Policy allowed-paths, against writes to files that must not be edited, or outside where they belong: its defaults, its options and a configuration that writes it.
To learn what it guards against and see it at work, read the guide: Paths and new files.
Defaults
| Default | Value |
|---|---|
| On by default | no: an entry turns it on |
| Fail mode | closed |
| Timeout | 2000 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 |
|---|---|---|---|
allowOnly | string[] | required | Globs relative to the folder the Policy works in; a change inside it that none matches is refused. |
hint | string | — | The step that clears a refusal, in place of the kit's own. |
outsideRoot | "allow" | "deny" | "allow" | What a change outside that folder gets: allow or deny. |
resolveSymlinks | boolean | true | Whether a path is judged where the file system puts it, every symbolic link followed, or as written. |
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: 'allowed-paths',
// The constructor's options, which it decodes.
options: {
// Globs relative to the folder the Policy works in; a change inside it that none matches is
// refused.
allowOnly: ['apps/**'],
// The step that clears a refusal, in place of the kit's own.
hint: 'Edit only the folders under apps/ or clusters/.',
// What a change outside that folder gets: `allow` or `deny`.
outsideRoot: 'allow',
// Whether a path is judged where the file system puts it, every symbolic link followed, or
// as written.
resolveSymlinks: true,
},
// The name of the kit's Policy constructor that builds the Policy.
use: 'allowed-paths',
},
],
});generated-paths
The built-in Policy generated-paths, against writes to files that must not be edited, or outside where they belong: its defaults, its options and a configuration that writes it.
new-file
The built-in Policy new-file, against writes to files that must not be edited, or outside where they belong: its defaults, its options and a configuration that writes it.