lean-agent-harness 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/GLOSSARY.md +2 -1
- package/README.md +2 -2
- package/bin/cli.js +8 -3
- package/guard/claude/merge-settings.js +5 -40
- package/guard/json-config.js +56 -0
- package/guard/opencode/merge-permission.js +63 -0
- package/guard/opencode/permission.json +72 -0
- package/install.sh +3 -2
- package/manifest.tsv +2 -0
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@ All notable changes to this project are documented here. Format based on [Keep a
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [1.3.2] - 2026-10-31
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- OpenCode guard: `--global --guard` also merges permission rules into `~/.config/opencode/opencode.json`, generated from `guard/policy.json`: secret files denied for `read` and `edit` (`.env.example` allowed), destructive commands set to `ask` with the flag before or after other arguments. Your own rules are kept; ours are moved last because OpenCode applies the last matching rule. A previous file is saved as `.bak`, a second run changes nothing, and an `opencode.json` that is not a JSON object is never touched. Follows the documented format; not yet run against a live OpenCode.
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- The read, validate and backup logic for user JSON files moved to `guard/json-config.js`, shared by the Claude Code and OpenCode merges.
|
|
16
|
+
|
|
7
17
|
## [1.3.1] - 2026-10-31
|
|
8
18
|
|
|
9
19
|
### Fixed
|
package/GLOSSARY.md
CHANGED
|
@@ -29,9 +29,10 @@ Single source of truth for the domain vocabulary of this project. Both human eng
|
|
|
29
29
|
| **Seed Glossary** | Minimal domain-glossary template deployed to client projects when they have none. | `templates/GLOSSARY.md` | At most 1500 bytes (token budget test); never overwrites an existing `GLOSSARY.md`. |
|
|
30
30
|
| **Source Override** | Testability hook: installers use `LAH_SOURCE` (shell) or `LAH_FAKE_HOME`/`LAH_FAKE_CWD` (CLI exports) in tests. | `install.sh`, `bin/cli.js` | Must never alter default behavior when unset. |
|
|
31
31
|
| **Pinned Download** | A `curl` install fixed to a release and verified: `LAH_VERSION` selects the tag `vX.Y.Z` (default: the branch), `LAH_SHA256` makes `install.sh` abort before deploying when the archive differs, `LAH_ARCHIVE_URL` replaces the download URL (mirrors, tests). | `install.sh` | Without `LAH_SHA256` the archive is installed unverified and the installer says so. GitHub archives are not guaranteed byte-stable: recompute a stale checksum from a trusted copy before assuming tampering. |
|
|
32
|
-
| **Guard** | Opt-in enforcement of the `AGENTS.md` Hard Rules that a tool can check mechanically (secret files, destructive commands): a Claude Code `PreToolUse` hook, a Pi extension and Codex command rules. Deployed only by `--global --guard`. | `guard/`, `global-guard` rows in `manifest.tsv` | Executes code inside the agent, so it is never on by default and never project-local (Pi loads project extensions only after the project is trusted). Best effort, not a sandbox: it does not see commands built through an interpreter. |
|
|
32
|
+
| **Guard** | Opt-in enforcement of the `AGENTS.md` Hard Rules that a tool can check mechanically (secret files, destructive commands): a Claude Code `PreToolUse` hook, OpenCode permission rules, a Pi extension and Codex command rules. Deployed only by `--global --guard`. | `guard/`, `global-guard` rows in `manifest.tsv` | Executes code inside the agent, so it is never on by default and never project-local (Pi loads project extensions only after the project is trusted). Best effort, not a sandbox: it does not see commands built through an interpreter. |
|
|
33
33
|
| **Guard Policy** | The single list of protected secret files and destructive commands, each with a decision: `ask` (human confirms; blocked when nobody can answer) or `deny`. | `guard/policy.json` | Every guard artifact is generated from it by `guard/build.js` (including the `core.js` matcher copied beside the Pi and Claude Code guards); a test fails when a committed artifact drifts. |
|
|
34
34
|
| **Guard Matcher** | The shared logic that decides whether a path is a secret and which shell rule a command hits, built from the Guard Policy. Names, directories and the executable (`/bin/CAT` is `cat`) compare case-insensitively (the default macOS and Windows file systems open `.ENV` as `.env`), and brace patterns (`*.{env,pem}`) are expanded. | `guard/core.js` | One source, copied by `guard/build.js` beside each guard because each deploys on its own. |
|
|
35
|
+
| **OpenCode Permission** | A manifest row of kind `opencode-permission`: merges the rules generated from the Guard Policy into the `permission` of `~/.config/opencode/opencode.json`. | `manifest.tsv`, `guard/opencode/permission.json`, `guard/opencode/merge-permission.js` | OpenCode applies the last matching rule, so each pattern is moved to the end and replaces a user rule with the same pattern; a text value (`"allow"`) is kept as `{"*": "allow"}`. Same backup and invalid-JSON rules as the Settings Hook (`guard/json-config.js`). |
|
|
35
36
|
| **Settings Hook** | A manifest row of kind `settings-hook`: registers the Claude Code guard hook in `~/.claude/settings.json` by merge instead of copying a file. | `manifest.tsv`, `guard/claude/hook.json`, `guard/claude/merge-settings.js` | Idempotent. Keeps every other key, saves the previous file as `.bak` (or `.bak.N`) when it changes, and never touches a `settings.json` that is not valid JSON. |
|
|
36
37
|
|
|
37
38
|
---
|
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ curl -fsSL https://raw.githubusercontent.com/lnardev/lean-agent-harness/main/ins
|
|
|
46
46
|
**Pinning and verifying the `curl` install.** The one-liner runs the `main` branch unless you pin it:
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
|
-
curl -fsSL https://raw.githubusercontent.com/lnardev/lean-agent-harness/main/install.sh | LAH_VERSION=1.3.
|
|
49
|
+
curl -fsSL https://raw.githubusercontent.com/lnardev/lean-agent-harness/main/install.sh | LAH_VERSION=1.3.2 LAH_SHA256=<sha256-of-the-archive> bash -s -- --global --auto
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
`LAH_VERSION` downloads that release tag. `LAH_SHA256` makes the installer abort, before deploying anything, if the archive does not match. Without it the installer says that the checksum is not verified. GitHub does not publish archive checksums, so compute the value once from a copy you trust, for example `shasum -a 256` on the archive of that tag. GitHub's generated archives are not guaranteed to stay byte-identical over time, so if a previously valid checksum stops matching, recompute it from a trusted copy before assuming tampering.
|
|
@@ -57,7 +57,7 @@ curl -fsSL https://raw.githubusercontent.com/lnardev/lean-agent-harness/main/ins
|
|
|
57
57
|
npx lean-agent-harness --global --profile core
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
**Guard (opt-in).** `AGENTS.md` is advice the model may ignore. `--global --guard` adds enforcement where the tool supports it, all generated from `guard/policy.json`: a `PreToolUse` hook for Claude Code (registered in `~/.claude/settings.json` by merge, with a `.bak` of the previous file), an extension for Pi and command rules for Codex. Secret files (`.env*`, `*.pem`, `*.key`, `.ssh/`) are denied; `rm -r`, `git reset --hard`, `git push --force` and `sudo` ask first. Best effort, not a sandbox: commands built through an interpreter (`python -c`) are not seen, and a `Grep` aimed at a whole directory can still reach a secret file inside it.
|
|
60
|
+
**Guard (opt-in).** `AGENTS.md` is advice the model may ignore. `--global --guard` adds enforcement where the tool supports it, all generated from `guard/policy.json`: a `PreToolUse` hook for Claude Code (registered in `~/.claude/settings.json` by merge, with a `.bak` of the previous file), permission rules for OpenCode (merged into `~/.config/opencode/opencode.json`, your own rules kept), an extension for Pi and command rules for Codex. Secret files (`.env*`, `*.pem`, `*.key`, `.ssh/`) are denied; `rm -r`, `git reset --hard`, `git push --force` and `sudo` ask first. Best effort, not a sandbox: commands built through an interpreter (`python -c`) are not seen, and a `Grep` aimed at a whole directory can still reach a secret file inside it. The OpenCode rules follow its documented permission format but have not been run against a live OpenCode. Cursor, Copilot and CommandCode have no guard. `install.sh --guard` needs `node`.
|
|
61
61
|
|
|
62
62
|
```bash
|
|
63
63
|
npx lean-agent-harness --global --guard
|
package/bin/cli.js
CHANGED
|
@@ -20,13 +20,16 @@ const path = require("path");
|
|
|
20
20
|
|
|
21
21
|
const { version } = require("../package.json");
|
|
22
22
|
const { mergeHook } = require("../guard/claude/merge-settings.js");
|
|
23
|
+
const { mergePermission } = require("../guard/opencode/merge-permission.js");
|
|
23
24
|
|
|
24
25
|
const PKG_ROOT = path.resolve(__dirname, "..");
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* @typedef {Object} Entry
|
|
28
|
-
* @property {"file"|"dir"|"settings-hook"} kind
|
|
29
|
-
*
|
|
29
|
+
* @property {"file"|"dir"|"settings-hook"|"opencode-permission"} kind
|
|
30
|
+
* file = instruction file (.bak on divergence); dir = mirrored directory;
|
|
31
|
+
* settings-hook = merge a hook into a Claude Code settings.json;
|
|
32
|
+
* opencode-permission = merge permission rules into an OpenCode opencode.json
|
|
30
33
|
* @property {string} src Path relative to the package root
|
|
31
34
|
* @property {string} dest Path relative to the target base
|
|
32
35
|
* @property {string} mode "" or "if-missing" (file kind: never overwrite an existing dest)
|
|
@@ -48,6 +51,7 @@ const LABELS = {
|
|
|
48
51
|
commandcode: "CommandCode",
|
|
49
52
|
"pi-guard": "Pi guard",
|
|
50
53
|
"claude-guard": "Claude Code guard",
|
|
54
|
+
"opencode-guard": "OpenCode guard",
|
|
51
55
|
"codex-guard": "Codex guard",
|
|
52
56
|
};
|
|
53
57
|
|
|
@@ -195,6 +199,7 @@ function deployTarget(t, exclude = new Set()) {
|
|
|
195
199
|
const to = path.join(t.base, dest);
|
|
196
200
|
if (kind === "file") writeInstruction(from, to, mode);
|
|
197
201
|
else if (kind === "settings-hook") mergeHook(from, to);
|
|
202
|
+
else if (kind === "opencode-permission") mergePermission(from, to);
|
|
198
203
|
else copyDir(from, to, src === "skills" ? exclude : new Set());
|
|
199
204
|
}
|
|
200
205
|
const label = t.base.replace(process.env.LAH_FAKE_HOME || os.homedir(), "~");
|
|
@@ -242,7 +247,7 @@ Flags:
|
|
|
242
247
|
-l, --local Desplegar en el proyecto actual (comportamiento por defecto)
|
|
243
248
|
-g, --global Desplegar en carpetas de usuario (~/)
|
|
244
249
|
--profile <p> core = sin skills extra (ver profile-extras.txt) | full (por defecto)
|
|
245
|
-
--guard Con --global: instala el guard (hook de Claude Code, extensión de Pi y reglas de Codex) que bloquea
|
|
250
|
+
--guard Con --global: instala el guard (hook de Claude Code, permisos de OpenCode, extensión de Pi y reglas de Codex) que bloquea
|
|
246
251
|
secretos y comandos destructivos. Ejecuta código en el agente: es opt-in
|
|
247
252
|
-h, --help Mostrar esta ayuda
|
|
248
253
|
-v, --version Mostrar versión
|
|
@@ -5,45 +5,12 @@
|
|
|
5
5
|
* Registers the lah guard hook in a Claude Code settings.json without touching anything else.
|
|
6
6
|
* Used by bin/cli.js (require) and install.sh (`node merge-settings.js <hook.json> <settings.json>`).
|
|
7
7
|
*
|
|
8
|
-
* A settings.json
|
|
9
|
-
*
|
|
8
|
+
* A settings.json whose `hooks` have an unexpected shape is never modified (see json-config.js for
|
|
9
|
+
* the invalid-JSON and backup rules).
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
const fs = require("node:fs");
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
/** @param {unknown} value @returns {value is Record<string, unknown>} */
|
|
16
|
-
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @param {string} settingsPath
|
|
20
|
-
* @returns {{raw: string | null, settings: Record<string, unknown>}} raw is null when the file does not exist yet
|
|
21
|
-
*/
|
|
22
|
-
function readSettings(settingsPath) {
|
|
23
|
-
let raw = null;
|
|
24
|
-
try {
|
|
25
|
-
raw = fs.readFileSync(settingsPath, "utf8");
|
|
26
|
-
} catch (err) {
|
|
27
|
-
if (err.code !== "ENOENT") throw err;
|
|
28
|
-
}
|
|
29
|
-
if (raw === null) return { raw, settings: {} };
|
|
30
|
-
|
|
31
|
-
let settings;
|
|
32
|
-
try {
|
|
33
|
-
settings = JSON.parse(raw);
|
|
34
|
-
} catch (err) {
|
|
35
|
-
throw new Error(`${settingsPath} is not valid JSON (${err.message}); fix it and run again`);
|
|
36
|
-
}
|
|
37
|
-
if (!isObject(settings)) throw new Error(`${settingsPath} is not a JSON object; fix it and run again`);
|
|
38
|
-
return { raw, settings };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** @param {string} settingsPath */
|
|
42
|
-
function keepBackup(settingsPath) {
|
|
43
|
-
let backup = `${settingsPath}.bak`;
|
|
44
|
-
for (let n = 1; fs.existsSync(backup); n++) backup = `${settingsPath}.bak.${n}`;
|
|
45
|
-
fs.copyFileSync(settingsPath, backup);
|
|
46
|
-
}
|
|
13
|
+
const { isObject, readJsonObject, writeJsonObject } = require("../json-config.js");
|
|
47
14
|
|
|
48
15
|
/**
|
|
49
16
|
* @param {string} hookPath JSON file with {event, entry}
|
|
@@ -52,7 +19,7 @@ function keepBackup(settingsPath) {
|
|
|
52
19
|
*/
|
|
53
20
|
function mergeHook(hookPath, settingsPath) {
|
|
54
21
|
const { event, entry } = JSON.parse(fs.readFileSync(hookPath, "utf8"));
|
|
55
|
-
const { raw, settings } =
|
|
22
|
+
const { raw, value: settings } = readJsonObject(settingsPath);
|
|
56
23
|
|
|
57
24
|
const hooks = settings.hooks ?? {};
|
|
58
25
|
const entries = isObject(hooks) ? hooks[event] ?? [] : null;
|
|
@@ -64,9 +31,7 @@ function mergeHook(hookPath, settingsPath) {
|
|
|
64
31
|
const registered = entries.some((existing) => Array.isArray(existing?.hooks) && existing.hooks.some((hook) => hook?.command === command));
|
|
65
32
|
if (registered) return false;
|
|
66
33
|
|
|
67
|
-
|
|
68
|
-
fs.mkdirSync(path.dirname(settingsPath), { recursive: true });
|
|
69
|
-
fs.writeFileSync(settingsPath, `${JSON.stringify({ ...settings, hooks: { ...hooks, [event]: [...entries, entry] } }, null, 2)}\n`);
|
|
34
|
+
writeJsonObject(settingsPath, raw, { ...settings, hooks: { ...hooks, [event]: [...entries, entry] } });
|
|
70
35
|
return true;
|
|
71
36
|
}
|
|
72
37
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Read and write a JSON config file that belongs to the user (Claude Code settings.json, OpenCode
|
|
5
|
+
* opencode.json) without ever damaging it. Shared by guard/claude/merge-settings.js and
|
|
6
|
+
* guard/opencode/merge-permission.js.
|
|
7
|
+
*
|
|
8
|
+
* A file that is not valid JSON, or not a JSON object, is never modified. When a write changes an
|
|
9
|
+
* existing file, the previous one is kept as "<name>.bak" (or the next free .bak.N).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const fs = require("node:fs");
|
|
13
|
+
const path = require("node:path");
|
|
14
|
+
|
|
15
|
+
/** @param {unknown} value @returns {value is Record<string, unknown>} */
|
|
16
|
+
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} filePath
|
|
20
|
+
* @returns {{raw: string | null, value: Record<string, unknown>}} raw is null when the file does not exist yet
|
|
21
|
+
*/
|
|
22
|
+
function readJsonObject(filePath) {
|
|
23
|
+
let raw = null;
|
|
24
|
+
try {
|
|
25
|
+
raw = fs.readFileSync(filePath, "utf8");
|
|
26
|
+
} catch (err) {
|
|
27
|
+
if (err.code !== "ENOENT") throw err;
|
|
28
|
+
}
|
|
29
|
+
if (raw === null) return { raw, value: {} };
|
|
30
|
+
|
|
31
|
+
let value;
|
|
32
|
+
try {
|
|
33
|
+
value = JSON.parse(raw);
|
|
34
|
+
} catch (err) {
|
|
35
|
+
throw new Error(`${filePath} is not valid JSON (${err.message}); fix it and run again`);
|
|
36
|
+
}
|
|
37
|
+
if (!isObject(value)) throw new Error(`${filePath} is not a JSON object; fix it and run again`);
|
|
38
|
+
return { raw, value };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {string} filePath
|
|
43
|
+
* @param {string | null} raw what readJsonObject returned: null means there is nothing to back up
|
|
44
|
+
* @param {Record<string, unknown>} value
|
|
45
|
+
*/
|
|
46
|
+
function writeJsonObject(filePath, raw, value) {
|
|
47
|
+
if (raw !== null) {
|
|
48
|
+
let backup = `${filePath}.bak`;
|
|
49
|
+
for (let n = 1; fs.existsSync(backup); n++) backup = `${filePath}.bak.${n}`;
|
|
50
|
+
fs.copyFileSync(filePath, backup);
|
|
51
|
+
}
|
|
52
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
53
|
+
fs.writeFileSync(filePath, `${JSON.stringify(value, null, 2)}\n`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
module.exports = { isObject, readJsonObject, writeJsonObject };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Merges the lah guard permissions into an OpenCode opencode.json without touching anything else.
|
|
6
|
+
* Used by bin/cli.js (require) and install.sh (`node merge-permission.js <permission.json> <opencode.json>`).
|
|
7
|
+
*
|
|
8
|
+
* OpenCode applies the last matching rule, so each of our patterns is moved to the end of its tool's
|
|
9
|
+
* rules: it replaces a user rule with the same pattern and wins over earlier, broader ones. A text
|
|
10
|
+
* value such as `"permission": "allow"` or `"read": "allow"` is kept as `{"*": "allow"}`.
|
|
11
|
+
* See json-config.js for the invalid-JSON and backup rules.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const fs = require("node:fs");
|
|
15
|
+
const { isObject, readJsonObject, writeJsonObject } = require("../json-config.js");
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {unknown} value a `permission` or `permission.<tool>` value from the user's config
|
|
19
|
+
* @param {string} where for the error message
|
|
20
|
+
* @returns {Record<string, unknown>} the same rules as an object
|
|
21
|
+
*/
|
|
22
|
+
function asRules(value, where) {
|
|
23
|
+
if (value === undefined) return {};
|
|
24
|
+
if (typeof value === "string") return { "*": value };
|
|
25
|
+
if (isObject(value)) return { ...value };
|
|
26
|
+
throw new Error(`${where} has an unexpected shape; fix it and run again`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {string} fragmentPath JSON file with {permission: {<tool>: {<pattern>: <decision>}}}
|
|
31
|
+
* @param {string} configPath
|
|
32
|
+
* @returns {boolean} true when opencode.json was written
|
|
33
|
+
*/
|
|
34
|
+
function mergePermission(fragmentPath, configPath) {
|
|
35
|
+
const { permission: ours } = JSON.parse(fs.readFileSync(fragmentPath, "utf8"));
|
|
36
|
+
const { raw, value: config } = readJsonObject(configPath);
|
|
37
|
+
|
|
38
|
+
const permission = asRules(config.permission, `${configPath} "permission"`);
|
|
39
|
+
for (const [tool, rules] of Object.entries(ours)) {
|
|
40
|
+
const merged = asRules(permission[tool], `${configPath} "permission.${tool}"`);
|
|
41
|
+
for (const [pattern, decision] of Object.entries(rules)) {
|
|
42
|
+
delete merged[pattern];
|
|
43
|
+
merged[pattern] = decision;
|
|
44
|
+
}
|
|
45
|
+
permission[tool] = merged;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const next = { ...config, permission };
|
|
49
|
+
if (JSON.stringify(next) === JSON.stringify(config)) return false;
|
|
50
|
+
writeJsonObject(configPath, raw, next);
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (require.main === module) {
|
|
55
|
+
try {
|
|
56
|
+
mergePermission(process.argv[2], process.argv[3]);
|
|
57
|
+
} catch (err) {
|
|
58
|
+
process.stderr.write(`${err.message}\n`);
|
|
59
|
+
process.exitCode = 1;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = { mergePermission };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permission": {
|
|
3
|
+
"read": {
|
|
4
|
+
"*.env": "deny",
|
|
5
|
+
"*.env.*": "deny",
|
|
6
|
+
"*.pem": "deny",
|
|
7
|
+
"*.key": "deny",
|
|
8
|
+
"*id_rsa": "deny",
|
|
9
|
+
"*id_ed25519": "deny",
|
|
10
|
+
"*/.ssh/*": "deny",
|
|
11
|
+
"*.env.example": "allow"
|
|
12
|
+
},
|
|
13
|
+
"edit": {
|
|
14
|
+
"*.env": "deny",
|
|
15
|
+
"*.env.*": "deny",
|
|
16
|
+
"*.pem": "deny",
|
|
17
|
+
"*.key": "deny",
|
|
18
|
+
"*id_rsa": "deny",
|
|
19
|
+
"*id_ed25519": "deny",
|
|
20
|
+
"*/.ssh/*": "deny",
|
|
21
|
+
"*.env.example": "allow"
|
|
22
|
+
},
|
|
23
|
+
"bash": {
|
|
24
|
+
"rm -rf": "ask",
|
|
25
|
+
"rm -rf *": "ask",
|
|
26
|
+
"rm * -rf": "ask",
|
|
27
|
+
"rm * -rf *": "ask",
|
|
28
|
+
"rm -fr": "ask",
|
|
29
|
+
"rm -fr *": "ask",
|
|
30
|
+
"rm * -fr": "ask",
|
|
31
|
+
"rm * -fr *": "ask",
|
|
32
|
+
"rm -rF": "ask",
|
|
33
|
+
"rm -rF *": "ask",
|
|
34
|
+
"rm * -rF": "ask",
|
|
35
|
+
"rm * -rF *": "ask",
|
|
36
|
+
"rm -Rf": "ask",
|
|
37
|
+
"rm -Rf *": "ask",
|
|
38
|
+
"rm * -Rf": "ask",
|
|
39
|
+
"rm * -Rf *": "ask",
|
|
40
|
+
"rm -fR": "ask",
|
|
41
|
+
"rm -fR *": "ask",
|
|
42
|
+
"rm * -fR": "ask",
|
|
43
|
+
"rm * -fR *": "ask",
|
|
44
|
+
"rm -r": "ask",
|
|
45
|
+
"rm -r *": "ask",
|
|
46
|
+
"rm * -r": "ask",
|
|
47
|
+
"rm * -r *": "ask",
|
|
48
|
+
"rm -R": "ask",
|
|
49
|
+
"rm -R *": "ask",
|
|
50
|
+
"rm * -R": "ask",
|
|
51
|
+
"rm * -R *": "ask",
|
|
52
|
+
"rm --recursive": "ask",
|
|
53
|
+
"rm --recursive *": "ask",
|
|
54
|
+
"rm * --recursive": "ask",
|
|
55
|
+
"rm * --recursive *": "ask",
|
|
56
|
+
"git reset --hard": "ask",
|
|
57
|
+
"git reset --hard *": "ask",
|
|
58
|
+
"git reset * --hard": "ask",
|
|
59
|
+
"git reset * --hard *": "ask",
|
|
60
|
+
"git push --force": "ask",
|
|
61
|
+
"git push --force *": "ask",
|
|
62
|
+
"git push * --force": "ask",
|
|
63
|
+
"git push * --force *": "ask",
|
|
64
|
+
"git push -f": "ask",
|
|
65
|
+
"git push -f *": "ask",
|
|
66
|
+
"git push * -f": "ask",
|
|
67
|
+
"git push * -f *": "ask",
|
|
68
|
+
"sudo": "ask",
|
|
69
|
+
"sudo *": "ask"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
package/install.sh
CHANGED
|
@@ -39,7 +39,7 @@ if [ "$GUARD" = true ] && [ "$TARGET_MODE" != "global" ]; then
|
|
|
39
39
|
fi
|
|
40
40
|
|
|
41
41
|
if [ "$GUARD" = true ] && ! command -v node >/dev/null 2>&1; then
|
|
42
|
-
echo "--guard necesita node para registrar el hook
|
|
42
|
+
echo "--guard necesita node para registrar el hook de Claude Code y los permisos de OpenCode (y para que el hook funcione)." >&2
|
|
43
43
|
exit 1
|
|
44
44
|
fi
|
|
45
45
|
|
|
@@ -194,7 +194,7 @@ case "$STRATEGY" in
|
|
|
194
194
|
esac
|
|
195
195
|
|
|
196
196
|
# The guard is opt-in and independent of environment detection: --guard always deploys every guard target.
|
|
197
|
-
if [ "$GUARD" = true ]; then SELECTED="$SELECTED pi-guard codex-guard claude-guard"; fi
|
|
197
|
+
if [ "$GUARD" = true ]; then SELECTED="$SELECTED pi-guard codex-guard claude-guard opencode-guard"; fi
|
|
198
198
|
|
|
199
199
|
# 4. Deployment helpers (semantics mirror bin/cli.js: manifest.tsv is the SSOT)
|
|
200
200
|
MANIFEST="$SRC/manifest.tsv"
|
|
@@ -252,6 +252,7 @@ while IFS="$TAB" read -r scope tgt kind src dest mode; do
|
|
|
252
252
|
case "$kind" in
|
|
253
253
|
file) write_instruction "$SRC/$src" "$BASE_DIR/$dest" "${mode:-}" ;;
|
|
254
254
|
settings-hook) node "$SRC/guard/claude/merge-settings.js" "$SRC/$src" "$BASE_DIR/$dest" ;;
|
|
255
|
+
opencode-permission) node "$SRC/guard/opencode/merge-permission.js" "$SRC/$src" "$BASE_DIR/$dest" ;;
|
|
255
256
|
dir)
|
|
256
257
|
if [ "$src" = "skills" ]; then copy_dir "$SRC/$src" "$BASE_DIR/$dest" skip-extras
|
|
257
258
|
else copy_dir "$SRC/$src" "$BASE_DIR/$dest"; fi
|
package/manifest.tsv
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
# | global-guard (dest relative to $HOME; deployed only with --global --guard)
|
|
5
5
|
# kind: file (instruction file; a divergent existing dest is saved as .bak) | dir (mirror directory)
|
|
6
6
|
# | settings-hook (merge the hook in src into the Claude Code settings.json at dest)
|
|
7
|
+
# | opencode-permission (merge the permission rules in src into the OpenCode opencode.json at dest)
|
|
7
8
|
# mode: if-missing (file kind only: never overwrite an existing dest)
|
|
8
9
|
# Target "agents" = the cross-tool Agent Skills location (.agents/skills), read natively by
|
|
9
10
|
# Pi, OpenCode, Codex, Copilot and Cursor. Claude Code reads .claude/skills instead.
|
|
@@ -28,4 +29,5 @@ global commandcode dir skills .commandcode/skills
|
|
|
28
29
|
global-guard pi-guard dir guard/pi/lah-guard .pi/agent/extensions/lah-guard
|
|
29
30
|
global-guard claude-guard dir guard/claude/lah-guard .claude/hooks/lah-guard
|
|
30
31
|
global-guard claude-guard settings-hook guard/claude/hook.json .claude/settings.json
|
|
32
|
+
global-guard opencode-guard opencode-permission guard/opencode/permission.json .config/opencode/opencode.json
|
|
31
33
|
global-guard codex-guard file guard/codex/lah.rules .codex/rules/lah.rules
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lean-agent-harness",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Zero-bloat, token-efficient agent harness for Claude Code, Cursor, OpenCode, Pi, Codex, and CommandCode.",
|
|
5
5
|
"author": "lnardev",
|
|
6
6
|
"bin": {
|
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
"adapters/",
|
|
25
25
|
"skills/",
|
|
26
26
|
"guard/claude/",
|
|
27
|
+
"guard/json-config.js",
|
|
28
|
+
"guard/opencode/",
|
|
27
29
|
"guard/pi/",
|
|
28
30
|
"guard/codex/",
|
|
29
31
|
"AGENTS.md",
|