@harnesspm/cli 0.0.0-snapshot.412a718 → 0.0.0-stage

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.
Files changed (80) hide show
  1. package/README.md +2 -69
  2. package/package.json +4 -71
  3. package/CHANGELOG.md +0 -259
  4. package/LICENSE +0 -21
  5. package/dist/added.d.ts +0 -51
  6. package/dist/added.js +0 -192
  7. package/dist/check.d.ts +0 -14
  8. package/dist/check.js +0 -263
  9. package/dist/cli.d.ts +0 -2
  10. package/dist/cli.js +0 -218
  11. package/dist/commands.d.ts +0 -58
  12. package/dist/commands.js +0 -1299
  13. package/dist/config.d.ts +0 -15
  14. package/dist/config.js +0 -45
  15. package/dist/deliver.d.ts +0 -1
  16. package/dist/deliver.js +0 -31
  17. package/dist/doctor.d.ts +0 -18
  18. package/dist/doctor.js +0 -99
  19. package/dist/exec-outputs.d.ts +0 -75
  20. package/dist/exec-outputs.js +0 -425
  21. package/dist/exec-units.d.ts +0 -68
  22. package/dist/exec-units.js +0 -151
  23. package/dist/fetch.d.ts +0 -16
  24. package/dist/fetch.js +0 -145
  25. package/dist/frontmatter.d.ts +0 -16
  26. package/dist/frontmatter.js +0 -49
  27. package/dist/homes.d.ts +0 -7
  28. package/dist/homes.js +0 -21
  29. package/dist/lock.d.ts +0 -47
  30. package/dist/lock.js +0 -245
  31. package/dist/manifest.d.ts +0 -78
  32. package/dist/manifest.js +0 -169
  33. package/dist/new.d.ts +0 -33
  34. package/dist/new.js +0 -228
  35. package/dist/outputs.d.ts +0 -124
  36. package/dist/outputs.js +0 -875
  37. package/dist/parent.d.ts +0 -41
  38. package/dist/parent.js +0 -182
  39. package/dist/render.d.ts +0 -91
  40. package/dist/render.js +0 -221
  41. package/dist/resolve.d.ts +0 -132
  42. package/dist/resolve.js +0 -522
  43. package/dist/reviewed.d.ts +0 -15
  44. package/dist/reviewed.js +0 -41
  45. package/dist/run.d.ts +0 -18
  46. package/dist/run.js +0 -133
  47. package/dist/sections.d.ts +0 -32
  48. package/dist/sections.js +0 -121
  49. package/dist/telemetry-api.d.ts +0 -26
  50. package/dist/telemetry-api.js +0 -60
  51. package/dist/telemetry.d.ts +0 -119
  52. package/dist/telemetry.js +0 -401
  53. package/dist/user-outputs.d.ts +0 -30
  54. package/dist/user-outputs.js +0 -239
  55. package/dist/util.d.ts +0 -137
  56. package/dist/util.js +0 -370
  57. package/dist/workspaces.d.ts +0 -2
  58. package/dist/workspaces.js +0 -62
  59. package/docs/spec/01-overview.md +0 -149
  60. package/docs/spec/02-package-format.md +0 -252
  61. package/docs/spec/03-resolution.md +0 -108
  62. package/docs/spec/04-outputs.md +0 -194
  63. package/docs/spec/05-executables.md +0 -170
  64. package/docs/spec/06-trust.md +0 -88
  65. package/docs/spec/07-added.md +0 -109
  66. package/docs/spec/08-improving.md +0 -79
  67. package/docs/spec/09-cloud.md +0 -68
  68. package/docs/spec/10-cli.md +0 -181
  69. package/docs/spec/11-standards.md +0 -52
  70. package/docs/spec/12-dogfooding.md +0 -51
  71. package/docs/spec/13-open-questions.md +0 -97
  72. package/docs/spec/14-telemetry.md +0 -199
  73. package/docs/spec/README.md +0 -33
  74. package/harness/dev.harnesspm/rules/generated-files.md +0 -9
  75. package/harness/dev.harnesspm/rules/harnesspm-config.md +0 -12
  76. package/harness/plugin.json +0 -13
  77. package/harness/skills/harnesspm-export/SKILL.md +0 -43
  78. package/harness/skills/harnesspm-import/SKILL.md +0 -40
  79. package/harness/skills/harnesspm-improve/SKILL.md +0 -38
  80. package/schema/harnesspm.schema.json +0 -58
@@ -1,194 +0,0 @@
1
- # 4. Outputs
2
-
3
- **In short**
4
-
5
- - harnesspm writes each agent's **native** files, where the agent already looks.
6
- - Of the outputs, only the managed blocks in `AGENTS.md`, the `@AGENTS.md` lines in `CLAUDE.md` files and `harnesspm.lock.json` are committed. Everything else is written on each machine and kept out of git.
7
- - People never edit outputs. Every output names its source.
8
- - The docs of dependencies are copied into `.harnesspm/docs/` at the project root, and a `.rgignore` lets agents' search tools into that folder ([4.3](#43-project-outputs), note 8).
9
- - A session that starts in a folder above the repositories gets their hooks and a pointer to their harness after a `sync` in that folder ([4.10](#410-sessions-that-start-in-a-parent-folder)).
10
-
11
- Package authors do not need this chapter. It defines what implementations write.
12
-
13
- ## 4.1 Principles
14
-
15
- 1. **Native files only.** No agent has to understand a harnesspm format.
16
- 2. **Commit only what reviewers need.** The managed block in `AGENTS.md` shows rule changes in pull requests. The lock shows every other unit change. All other outputs are per machine.
17
- 3. **Per-machine outputs are excluded through `.git/info/exclude`.** That file belongs to the clone, is never committed, and is shared by worktrees. harnesspm never edits `.gitignore`. `harnesspm doctor` checks that every per-machine file is ignored and untracked ([10.5](10-cli.md#105-doctor)). Its patterns start at the git root, so a project below it, such as `docs-site/`, puts its folder in front of each entry (`/docs-site/.claude/skills/…`) and keeps them in a section of its own, named after its folder. Two projects in one repository never touch each other's entries.
18
- 4. **Units of added harnesses never enter a tracked file.** harnesspm MUST refuse to write one there.
19
- 5. **Outputs are marked.** Each generated file or block says it is generated and names the sources to edit.
20
- 6. **harnesspm edits only its own entries** in files that people or agents also write, and keeps the rest unchanged.
21
-
22
- ## 4.2 Stable package paths
23
-
24
- Package managers place packages at paths that differ between machines. harnesspm creates one stable link per harness package and uses only these paths in outputs:
25
-
26
- ```
27
- node_modules/.harnesspm/pkgs/@tenphi/tasty → <real location of the package>
28
- ```
29
-
30
- A job that does not install dependencies, such as a review bot, runs `npx -y @harnesspm/cli fetch`. It downloads only the harness packages in the lock with `npm pack`, checks each tarball against the lock's integrity, and fills these paths, the generated files and the docs copies, so pointers in the committed block work there too. It writes the docs copies only where git ignores them, and the `.rgignore` that lets search tools into them only once `.git/info/exclude` lists it: a sandbox may keep `.git` read-only ([4.3](#43-project-outputs), note 8). It reuses installed copies and writes no agent settings. `fetch` itself never runs package code: `run` stays the separate, explicit step that does, and it can run a script from a fetched package ([5.1](05-executables.md#the-runner)). `help` fetches by itself when a project has neither an install nor fetched packages ([10.1](10-cli.md#101-projects)). When the lock has no integrity for a package, `fetch` looks in the package manager's lockfile. When neither has one, it still downloads the package and warns, naming it.
31
-
32
- ## 4.3 Project outputs
33
-
34
- These hold the dependency and project layers, plus added harnesses with local scope and the project entries of all added harnesses.
35
-
36
- | Unit | Claude Code | Codex |
37
- | --- | --- | --- |
38
- | Always-on rules, docs index, script list (team) | Managed block in `AGENTS.md` (committed), reached through `@AGENTS.md` in `CLAUDE.md`. One line per rule: `harnesspm help <package>` prints the text ([4.6](#46-managed-blocks)). | Managed block in `AGENTS.md` (committed), the same lines |
39
- | Always-on rules (added harnesses) | Managed block in `CLAUDE.local.md` | `developer_instructions` in `.codex/config.toml` |
40
- | File-scoped rules | Link in `.claude/rules/harnesspm/<plugin>/` with `paths`, plus a pointer line in the block | Pointer line in the block |
41
- | On-demand rules | Pointer line with its description | Pointer line with its description |
42
- | Skills | Link in `.claude/skills/<name>`, plus `Skill(<name>)` in `permissions.allow` of `.claude/settings.local.json` for skills from the project, an added harness or a trusted package. An untrusted package's skill with `allowed-tools` or `hooks` links to a copy without them in `node_modules/.harnesspm/skills/` ([6.1](06-trust.md#61-what-needs-trust)). | Link in `.agents/skills/<name>`, to the same copy |
43
- | Docs of dependencies | Copies of the pages and `llms.txt` in `.harnesspm/docs/<plugin name>/`, and a `.rgignore` that lets search tools into that folder (note 8) | The same files |
44
- | Sub-agents | Generated `.claude/agents/<name>.md` | Generated `.codex/agents/<name>.toml` |
45
- | Hooks, permissions | Entries in `.claude/settings.local.json` | `.codex/hooks.json`, `.codex/rules/harnesspm.rules` |
46
- | MCP servers | Local scope: `projects.<project>.mcpServers` in `~/.claude.json`, where `claude mcp add-json --scope local` writes them | `[mcp_servers.<id>]` in `.codex/config.toml` |
47
-
48
- Notes:
49
-
50
- 1. `CLAUDE.local.md` counts as a `CLAUDE.md` for Claude Code. In a repository with only `AGENTS.md`, harnesspm MUST start `CLAUDE.local.md` with `@AGENTS.md`, or Claude would stop reading `AGENTS.md`.
51
- 2. harnesspm owns `.codex/` and writes it on each machine. If a team already commits `.codex/config.toml`, harnesspm does not touch it and `harnesspm status` lists the units Codex is missing. The team moves those settings into `harness/`, which feeds both agents.
52
- 3. A file-scoped rule has two outputs for Claude Code on purpose: the link activates it natively on matching files, and the pointer line in the shared block serves Codex. If an override changes its text in only some workspaces, both agents use the workspace blocks.
53
- 4. File-scoped and on-demand rules of added harnesses are pointer lines with absolute paths, in `CLAUDE.local.md` and the user-level blocks. So are their `Docs:` lines, and the pages a generated docs index lists. The agent reads them from whatever folder it works in, and the working copies of git and npm sources sit in `~/.harnesspm/`. They get no `.claude/rules/` link, because Claude Code treats a link to a file outside the working folder as an external import that needs approval. Patched rules and docs indexes of added harnesses are generated into `~/.harnesspm/generated/`, because a repository may have no `node_modules`.
54
- 5. An added harness's `exclude` or `patch` of a team always-on rule cannot change committed text. harnesspm writes the change into the local block instead ("ignore rule X", or "in rule X, section Y now says: …"), which both agents read after the team block.
55
- 6. With agent events on, harnesspm also writes its own telemetry hooks into the same hook files, and the index they read into `node_modules/.harnesspm/telemetry.json` ([14.4](14-telemetry.md#144-agent-events)).
56
- 7. Claude Code reads a nested `AGENTS.md` only when no `CLAUDE.md`, `.claude/CLAUDE.md` or `CLAUDE.local.md` exists in its folder or above, and the root `CLAUDE.md` that imports the block is one ([research](https://github.com/tenphi/harnesspm/blob/main/docs/research/agent-capabilities.md#instructions)). So every nested `AGENTS.md` that git tracks, outside `node_modules`, gets an `@AGENTS.md` line in a `CLAUDE.md` in the same folder. harnesspm creates that file, or adds the line at the top of an existing one. A folder whose `.claude/CLAUDE.md` already has `@../AGENTS.md` keeps it and gets no second import. These files are committed outputs: `sync --check` and `doctor` report a missing line.
57
- 8. Agents also look for docs by searching, not only through the block. Their search tools skip what git ignores and do not follow links, and plain `rg` also skips hidden folders: Claude Code's Grep and plain `rg` found no page in `node_modules`, under `node_modules/.harnesspm/pkgs/`, or behind a committed link into `node_modules` ([research](https://github.com/tenphi/harnesspm/blob/main/docs/research/agent-capabilities.md#search)). So `sync` and `fetch` copy each dependency's pages (`.md`, `.mdx`, a linked one too) and `llms.txt` into `.harnesspm/docs/<plugin name>/` at the project root, leaving out what git ignores ([2.7](02-package-format.md#27-docs)). Other files, such as images, are not copied. A link in a copied page that leaves the docs folder, such as `../README.md`, would lead nowhere in the copy, so the copy points it at that file under `node_modules/.harnesspm/pkgs/<package>/`, in the installed package. The package keeps its own link, which its other readers need: a docs site may render the README as a page, as Tasty's does ([research](https://github.com/tenphi/harnesspm/blob/main/docs/research/motivating-case.md#docs-sites)).
58
- - Every dependency is copied, a workspace package too, so the committed pointer never depends on whether a package manager links or copies a package.
59
- - The copies sit outside `node_modules`, with the project's own files. Git ignores the folder through `/.harnesspm/` in `.git/info/exclude` (4.1, principle 3). Formatters such as Prettier skip what `.gitignore` lists but not what `.git/info/exclude` lists ([research](https://github.com/tenphi/harnesspm/blob/main/docs/research/agent-capabilities.md#search)), so `sync` warns until a `.gitignore` in the repository ignores the folder, and names the one in the project folder when the project is below the git root. A global excludes file does not count, since Prettier does not read it.
60
- - `sync` and `fetch` write the copies only where git ignores the folder `.harnesspm/docs/`, so that an agent's `git add -A` never takes them. They write the copies after `.git/info/exclude`, so a sandbox that keeps `.git` read-only gets copies only when `.gitignore` lists the folder. A pattern that ignores some of the files, such as `*.txt`, does not count. When git fails inside a repository, as in one another user owns, nothing is known to be ignored, so they write no copies.
61
- - A sync removes the copies that harnesspm 0.13 wrote in `node_modules/.harnesspm/docs/`.
62
- - A `.rgignore` in the project folder lets ripgrep, and the search tools built on it, into that one folder, because its lines outrank git's ignore rules for ripgrep: `!/.harnesspm/`, `/.harnesspm/*` and `!/.harnesspm/docs/`, after a line that says harnesspm wrote it. The rest of `.harnesspm/`, such as a telemetry file, stays out of search. The `.rgignore` is listed in `.git/info/exclude`.
63
- - When the repository has a `.rgignore` of its own, harnesspm leaves it as it is, and `sync` warns until it has these lines. Without docs copies, `sync` removes its own `.rgignore`.
64
-
65
- ## 4.4 Outputs of added harnesses, user scope
66
-
67
- These go to the agents' user-level folders, so they work in every repository, including ones without harnesspm.
68
-
69
- | Unit | Claude Code | Codex |
70
- | --- | --- | --- |
71
- | Rules | Managed block in `~/.claude/CLAUDE.md` | Managed block in `~/.codex/AGENTS.md` |
72
- | Skills | Link in `~/.claude/skills/`, plus `Skill(<name>)` in `permissions.allow` of `~/.claude/settings.json` | Link in `~/.agents/skills/` |
73
- | Sub-agents | Generated in `~/.claude/agents/` | Generated in `~/.codex/agents/` |
74
- | Hooks, permissions | Entries in `~/.claude/settings.json` | `~/.codex/hooks.json`, `~/.codex/rules/harnesspm.rules` |
75
- | MCP servers | User scope: `mcpServers` in `~/.claude.json` | `[mcp_servers.<id>]` in a managed block at the end of `~/.codex/config.toml` |
76
- | Write access to the working copies of added harnesses | `permissions.additionalDirectories` | `sandbox_workspace_write.writable_roots` |
77
- | The hook that applies added harnesses in each repository ([07-added.md](07-added.md#75-applying-in-every-repository)) | `SessionStart` entry in `~/.claude/settings.json` | `SessionStart` entry in `~/.codex/hooks.json` |
78
-
79
- ## 4.5 Monorepos
80
-
81
- 1. A workspace with its own units gets a managed block in `<workspace>/AGENTS.md`. Codex joins `AGENTS.md` files from the root down to the current folder. Paths in a workspace's block are relative to its folder. A block that becomes empty is removed, and so is a file that held only the block.
82
- 2. A workspace's `AGENTS.md` gets a `CLAUDE.md` that imports it, like every nested `AGENTS.md` ([4.3](#43-project-outputs), note 7). Both files are committed.
83
- 3. Skills and executable units are written at the root.
84
- 4. The root block starts with a `## Workspaces` section that names each workspace with a block of its own. Claude Code loads a workspace's block only when the agent opens a file there with its file tools, and Codex only when it starts in that folder ([research](https://github.com/tenphi/harnesspm/blob/main/docs/research/agent-capabilities.md#instructions)). The root block is always on, so an agent that works through the shell still learns that the block exists.
85
- 5. When a rule's text differs, each workspace's block points to its version. Patched versions that agents read from files have distinct paths. A workspace block with nested workspaces tells agents to use the nested workspace's rules when editing its files.
86
-
87
- ## 4.6 Managed blocks
88
-
89
- A managed block is the only part of a Markdown file harnesspm owns. Text outside it never changes. Without markers, harnesspm appends a block at the end.
90
-
91
- The committed block is **compact**: the block commands at the top, then one line per unit. Each always-on rule gets a line with its title and a summary, and `harnesspm help <package>` prints its text ([10.1](10-cli.md#help-for-a-package-a-rule-or-a-tool)). So the block stays small with many packages and many workspaces, inside Codex's limit ([4.9](#49-size-limits)).
92
-
93
- ```markdown
94
- <!-- BEGIN:harnesspm — generated by `harnesspm sync`. Do not edit. To change a rule, run `npx -y @harnesspm/cli why <ID>`. -->
95
-
96
- - Every package of this harness: `npx -y @harnesspm/cli help`. A package's rules and tools in full: `npx -y @harnesspm/cli help <package>`.
97
- - Run a tool: `npx -y @harnesspm/cli run <tool> [args]`. Its options: `npx -y @harnesspm/cli help <tool>`.
98
- - From outside this folder, add `-C <path to this folder>` before `help` or `run`.
99
-
100
- ## @tenphi/tasty (via @cube-dev/ui-kit)
101
-
102
- - Always-on rule: Style values — Tokens, Dynamic values. Read it with `help @tenphi/tasty` (tasty:rules/style-values)
103
- - When editing `**/*.tsx`, read node_modules/.harnesspm/pkgs/@tenphi/tasty/harness/dev.harnesspm/rules/state-maps.md — How to write state maps in Tasty styles (tasty:rules/state-maps)
104
- - Docs: .harnesspm/docs/tasty/llms.txt (tasty:docs)
105
-
106
- ## @cube-dev/ui-kit
107
-
108
- - Always-on rule: Forms — Controllers, Validation. Read it with `help @cube-dev/ui-kit` (uikit:rules/forms)
109
- - Tool: `uikit:probe` — Capture a story's DOM and computed CSS (uikit:scripts/probe)
110
-
111
- <!-- END:harnesspm -->
112
- ```
113
-
114
- | Unit | In the committed block |
115
- | --- | --- |
116
- | Block commands, first in a committed block with units | The three lines above, in every block: the root's and each workspace's. They replace the single "outside line" of earlier versions. |
117
- | Package | A `##` heading with its name, and `(via <package>)` when it comes through `extends`. Upstream packages come first. No version: the lock records it, so an upgrade that keeps the harness the same changes only the lock. |
118
- | Always-on rule | ``- Always-on rule: <title> — <summary>. Read it with `help <package>` (<ID>)``. The summary is the rule's `description`, else its `##` and `###` headings in order. A rule without them has the title alone. `<package>` is the npm name, or the plugin name of an added harness. |
119
- | File-scoped rule | `- When editing <globs>, read <file> — <description> (<ID>)` |
120
- | On-demand rule | `- <description>: read <file> (<ID>)` |
121
- | Docs | `- Docs: <index> (<ID>)`. For a dependency, the index is the `llms.txt` of its [docs copy](#43-project-outputs) in `.harnesspm/docs/<plugin name>/`: the package's own, or one harnesspm generates that lists the copied pages. For the project's own docs, it is their `llms.txt`, or one generated in the same folder that lists the pages where they are. |
122
- | Script with a `description`, from the project or a trusted package | ``- Tool: `<plugin name>:<script>` — <description> (<ID>)``. The block commands say how to run it and how to see its options. |
123
- | Hooks that check file edits, from the project or a trusted package | ``- Edit files with your file tools, not shell commands such as `sed`, so the hook that checks each edit runs (<IDs>)``, once per package. A hook counts when it runs before or after a tool and its matcher, read as each agent reads it, matches an edit tool: `Edit`, `Write` or `MultiEdit` for Claude Code, `apply_patch`, `Edit` or `Write` for Codex. A matcher that matches every tool does not count. An edit through the shell skips it. |
124
- | Workspaces with blocks of their own, in the root block of a monorepo | A `## Workspaces` section after the block commands, naming each folder ([4.5](#45-monorepos)) |
125
-
126
- The commands use `npx -y @harnesspm/cli` in every block. Inside the project, npx runs the installed harnesspm. Outside it, the agent adds `-C <path>`. The bare `npx harnesspm` fails outside a project, because `harnesspm` is not a published package name ([research](https://github.com/tenphi/harnesspm/blob/main/docs/research/agent-capabilities.md#outside-the-start-folder)).
127
-
128
- **What a reviewer sees.** A dependency upgrade that changes a rule's text changes the unit's hash in the lock. The block changes only when the rule's title, headings or `description` change. `harnesspm help <package>` prints the new text.
129
-
130
- **Blocks that stay in full.** Blocks in `CLAUDE.local.md` and user-level files hold added harnesses, which only an agent in the project, or on that machine, reads. They have no block commands, inline each always-on rule as a `###` heading with its title and ID, then its text with headings moved down two levels, and list a script as ``- Script: `npx -y @harnesspm/cli run <plugin name>:<script>` — <description> (<ID>)``. The changes that added harnesses make to the repository's rules go there in full too ([4.3](#43-project-outputs), note 5), and `help` prints the changed text on that machine.
131
-
132
- Every heading and line of a unit carries its ID, so an agent can find the source with `harnesspm why`.
133
-
134
- **Position.** Agents often read only the top of `AGENTS.md`, such as with `head -30` ([research](https://github.com/tenphi/harnesspm/blob/main/docs/research/agent-capabilities.md#outside-the-start-folder)), so the block commands come first. A new file gets the block at its top. In an existing file without markers, the block goes at the end, and a person can move it up: `sync` keeps it where it is. `harnesspm status` and `doctor` warn when a committed block starts past the first 30 lines of its file.
135
-
136
- A blank line follows the BEGIN marker and comes before the END marker, so Markdown formatters such as Prettier leave the block as it is. A block written without them, as harnesspm 0.3 did, still counts as up to date, and the next `sync` rewrites it once.
137
-
138
- ## 4.7 Files shared with people
139
-
140
- `CLAUDE.md` files, `~/.codex/AGENTS.md`, `.claude/settings.local.json` and `~/.claude/settings.json` are also written by people, or by the agent itself (Claude Code saves "don't ask again" approvals into `.claude/settings.local.json`). In these files, and in `~/.claude.json`, `.codex/hooks.json` and `~/.codex/config.toml`, harnesspm changes only its managed block or the entries it created. It records its entries in a per-machine state file, so it can remove them later: `harnesspm/state.json` in the clone's git folder for project outputs (`harnesspm/<folder>/state.json` for a project below the git root), and `~/.harnesspm/state.json` for user-level ones. An entry that is already in the file is not added twice, so a state file that is lost never doubles a hook. In a folder that is not a git repository, project outputs use `~/.harnesspm/state/<folder>-<hash>.json`, so harnesspm never creates a `.git` folder. The entries of each project in a parent folder ([4.10](#410-sessions-that-start-in-a-parent-folder)) use `~/.harnesspm/state/parents/<folder>-<hash>/<project>-<hash>.json`, so two projects never take each other's. A settings file that held only harnesspm's entries is deleted with them.
141
-
142
- ## 4.8 Why native files and not plugins
143
-
144
- Both agents have plugin systems. harnesspm does not generate plugins in v1, because Claude Code cloud sessions do not install plugins that a repository declares, and plugins hide changes from pull request review. See [13-open-questions.md](13-open-questions.md#135-plugin-output-mode).
145
-
146
- ## 4.9 Size limits
147
-
148
- | Agent | Limit |
149
- | --- | --- |
150
- | Codex | `AGENTS.md` files are joined up to `project_doc_max_bytes`, 32 KiB by default. The rest is cut off. |
151
- | Claude Code | No hard limit. The vendor advises under about 200 lines per `CLAUDE.md`. |
152
-
153
- `harnesspm status` reports the always-on size per agent, warns near a limit, and says when `AGENTS.md` is over Codex's. `harnesspm doctor` warns under Outputs when `AGENTS.md` is over 32 KiB, because Codex then reads only its first 32 KiB.
154
-
155
- The committed block holds one line per unit, not the text of always-on rules ([4.6](#46-managed-blocks)). The always-on size that `status` reports is that of the files the agents load. The text that agents get with `help <package>` does not count toward it.
156
-
157
- Codex reads one file per folder, `AGENTS.override.md` before `AGENTS.md`, from its project root, usually the git root, down to the folder it starts in, and only the files' bytes count toward the limit ([research](https://github.com/tenphi/harnesspm/blob/main/docs/research/agent-capabilities.md#codex)). So `status` and `doctor` also name each managed block that Codex never reads, or reads only in part, with where it starts or ends in the joined files. Each warning adds that agents can still get what the block holds with `npx -y @harnesspm/cli help <package>`:
158
-
159
- - a root block after long hand-written text;
160
- - a workspace block below a long root `AGENTS.md`;
161
- - a block in a folder that has an `AGENTS.override.md`.
162
-
163
- A new block goes at the end of its file, and `sync` keeps a block where it is. So moving the root block to the top of `AGENTS.md` keeps it in the part Codex reads.
164
-
165
- ## 4.10 Sessions that start in a parent folder
166
-
167
- A session often starts in a folder above the repositories it works on: a Claude Code cloud session with several repositories starts in `/home/user`, a person opens their folder of clones, and a job runner starts in its work folder. Claude Code reads settings only from the folder a session starts in, and Codex reads `AGENTS.md` only from its project root down to that folder ([research](https://github.com/tenphi/harnesspm/blob/main/docs/research/agent-capabilities.md#outside-the-start-folder)). So no hook of the repositories runs, and their rules do not load at the start.
168
-
169
- `npx -y @harnesspm/cli sync` in a **parent folder** fixes that. A parent folder is not in a git repository and has projects right below it: subfolders with a `harnesspm.json`. Its sync writes, for each project:
170
-
171
- | Output | Where | What |
172
- | --- | --- | --- |
173
- | Hooks | `.claude/settings.local.json` and `.codex/hooks.json` of the parent folder | The project's hooks and telemetry hooks with the same events, matchers and timeouts. Each starts harnesspm with `-C <project>`. |
174
- | Pointer block | A managed block in the parent folder's `AGENTS.md`, and `@AGENTS.md` in its `CLAUDE.md` | Each project's name and absolute path, its `AGENTS.md`, and `npx -y @harnesspm/cli -C <path> help`. A project that is not installed is listed too: `help` fetches its harness. |
175
-
176
- Rules:
177
-
178
- 1. **Explicit.** Only a sync in the parent folder starts these outputs. Then each project's own sync, such as an install's, keeps its entries there current. A project never writes into a folder above it that has no pointer block. A project linked into the folder is found by its real path, so only a sync in the folder updates its entries.
179
- 2. **Clean.** A sync in the folder removes the entries of projects that are gone. When none is left, it removes the block and the import it added too.
180
- 3. **Hooks only.** Allow rules, MCP servers, sub-agents and skills stay in the project, because they name commands and files that work only from there. The pointer block says how to reach them.
181
- 4. **The runner.** A hook starts the project's installed CLI file with `node` when that harnesspm runs parent hooks (0.11.0 or later), else `npx -y @harnesspm/cli`. A newer harnesspm may sync the parent folder than the one the project installed.
182
- 5. **Trust.** The project's trust applies as in the project ([06-trust.md](06-trust.md#62-trusting-a-package)). A sync by the agent's model writes the pointer block, and keeps or removes hooks, but adds none: not even what the project's default branch records, which [6.2](06-trust.md#62-trusting-a-package), rule 4, allows in the project. The folder is the person's, and the agent may have cloned the project itself. The environment's setup script runs as a person, so a cloud session starts with the hooks. With `CI=true` the outputs are written too: they are per machine.
183
- 6. **Paths.** Every path is absolute. These files are per machine: a parent folder is not in a git repository. The home folder is never a parent folder, because its `.claude/` and `.codex/` hold the user-level settings of every session.
184
- 7. **Where hooks run.** A session in the parent folder edits files of every repository below it, so every project's hook sees them. A hook that `-C` starts from outside its project runs in the project, as in a session there, and harnesspm skips it when its JSON names a file outside the project (`tool_input.file_path` or `notebook_path`).
185
- 8. **Inside a repository.** Claude Code also reads the `CLAUDE.md` files above the folder a session starts in, so a session inside one of the repositories sees the block too. It names the repositories next to it. Their hooks stay in the parent folder's settings, which that session does not read.
186
-
187
- A job runner that clones during the session writes these outputs after the session started. Claude Code reads them at the next start or resume of the session. Tools work at once: the agent reads the clone's `AGENTS.md`, whose block commands say how to use `-C` (S18).
188
-
189
- **Added harnesses.** A sync in a folder that is not in a git repository, and is not the home folder, also applies the person's added harnesses in each git repository right below it, with or without a `harnesspm.json`. The `SessionStart` hook of an added harness runs this sync in the folder a session starts in ([7.5](07-added.md#75-applying-in-every-repository)), so a session with several repositories gets every project entry.
190
-
191
- - **Only the added layer.** Each repository gets the per-machine outputs of the added harnesses ([4.3](#43-project-outputs)): the managed block in `CLAUDE.local.md`, their skill links, their entries in `.claude/settings.local.json` and their lines in `.git/info/exclude`. The repository's own outputs, committed and per machine, stay as its own sync wrote them, as before its install: that install may run another harnesspm version than the one in the folder above. So the block lists the entry's own rules, not its changes to the repository's rules (`patch`, `replace`, `exclude`): a sync inside the repository adds those.
192
- - **One level.** Only the folders right below are checked. A folder that is not a git repository gets nothing.
193
- - **Only with added harnesses.** Without one, and with `CI=true`, the sync does what it did before.
194
- - **What a session in the parent folder reads.** Claude Code reads each repository's `CLAUDE.md` and `CLAUDE.local.md`, and its skills, but no settings ([research](https://github.com/tenphi/harnesspm/blob/main/docs/research/agent-capabilities.md#cloud-sessions)). So the entry's rules and skills apply, and its hooks and permissions apply only in a session that starts in the repository. harnesspm does not move them into the parent folder's settings, because there they would apply to every repository below it ([13.14](13-open-questions.md#1314-entry-hooks-in-a-parent-folder)).
@@ -1,170 +0,0 @@
1
- # 5. Executables
2
-
3
- **In short**
4
-
5
- - A package declares **scripts**. Agents run them through one command: `npx -y @harnesspm/cli run <plugin>:<script>`, with `-C <dir>` from outside the project. Hooks use the same `run`. MCP servers start through `harnesspm mcp <plugin>:<server>`.
6
- - Hooks and MCP servers are written once and translated for each agent.
7
- - A package can allow only its own scripts. It can always restrict (deny, ask).
8
- - Nothing executable runs unless the project trusts the package ([06-trust.md](06-trust.md)).
9
-
10
- ## 5.1 Scripts
11
-
12
- A script is a file a package ships for agents, hooks or MCP servers to run.
13
-
14
- ```json
15
- "scripts": {
16
- "probe": {
17
- "file": "./dev.harnesspm/scripts/probe.mjs",
18
- "description": "Capture a story's DOM and computed CSS",
19
- "usage": "--story <id> [--json]",
20
- "allow": true
21
- }
22
- }
23
- ```
24
-
25
- | Field | Required | Meaning |
26
- | --- | --- | --- |
27
- | `file` | yes | Path inside `harness/`, starting with `./`. |
28
- | `description` | no | Shown to the agent in the script list. Without it, the script is hidden from the agent and only hooks and MCP servers use it. |
29
- | `usage` | no | The arguments and options the script takes, such as `--story <id> [--json]`. One line or several. `harnesspm help <plugin>:<script>` prints it with the run command, without running the script, so an agent learns the options also without an install ([10.1](10-cli.md#help-for-a-package-a-rule-or-a-tool)). Without it, `help` says that no usage is declared. |
30
- | `answers` | no | Exit codes from `1` to `255` that are **answers**, not failures, such as `[1]` for a lint that exits `1` when it finds problems, or `[2]` for a hook that exits `2` to block the agent. A `run` event then has `outcome` `answer` for them, not `failed` ([14.2](14-telemetry.md#142-events)), and `help <plugin>:<script>` prints them. Without it, every non-zero exit is a failure. |
31
- | `allow` | no | The producer suggests that agents may run it without asking. Takes effect only when the consumer trusts the package. See [5.4](#54-permissions). |
32
-
33
- ### The runner
34
-
35
- Every script runs through one command:
36
-
37
- ```bash
38
- npx -y @harnesspm/cli run uikit:probe -- --story Button
39
- npx -y @harnesspm/cli -C work/app run uikit:probe -- --story Button # from outside the project
40
- ```
41
-
42
- The runner:
43
-
44
- 1. finds the package through the stable path in `node_modules/.harnesspm/pkgs/`, so the installed version always runs. A project without an install uses its [fetched packages](01-overview.md#15-terms) instead. When it has neither, the runner says so and names both `harnesspm fetch` and the project's install, never `No script`;
45
- 2. refuses the script when its package is not trusted, when the installed version differs from the lock, or when a `"pin"` package has a version nobody approved. For a version that differs, the refusal names both remedies: reinstall the dependencies when the install is out of date, as in a cached cloud environment, or run `harnesspm sync` when the lock is. A sync on an old install would write its versions into the lock;
46
- 3. picks the interpreter from the file: `node` for `.js`, `.mjs` and `.cjs`, `sh` for `.sh`, otherwise the file itself;
47
- 4. runs the script in the caller's folder, also with `-C`, so file arguments stay valid;
48
- 5. sets these environment variables:
49
-
50
- | Variable | Value |
51
- | --- | --- |
52
- | `PLUGIN_ROOT` | The package's `harness/` folder (same meaning as in Agent Plugins) |
53
- | `PLUGIN_DATA` | `~/.harnesspm/data/<plugin name>/`, kept across updates (same meaning as in Agent Plugins) |
54
- | `HARNESSPM_PROJECT_DIR` | The project root: the project that `-C` names, or the one harnesspm started in |
55
- | `HARNESSPM_AGENT` | `claude`, `codex`, or empty when a person runs it. harnesspm puts it into the hook and MCP commands it writes, and reads the agent's marker for a script an agent runs ([06-trust.md](06-trust.md#62-trusting-a-package), rule 4). |
56
-
57
- The runner must start fast, because hooks call it on every matching tool call. With telemetry on, it sends a `run` event to the project's handler when the script ends ([14.2](14-telemetry.md#142-events)). With `-C`, that is the named project's handler.
58
-
59
- A fetched package has no dependencies of its own. A self-contained script runs from it. When a script there fails to load a package (Node.js's `ERR_MODULE_NOT_FOUND` or `MODULE_NOT_FOUND`), the runner passes the script's own error through and ends with a line that says the script needs the project's install, with the command. stdout streams as it is.
60
-
61
- Why a runner instead of file paths:
62
-
63
- - one command works with every package manager and folder layout;
64
- - permission rules match one stable prefix in both agents;
65
- - hooks, MCP servers and skills use the same command, so a `SKILL.md` works on every machine.
66
-
67
- ## 5.2 Hooks
68
-
69
- Claude Code and Codex use nearly the same hook model: event → matcher → command, JSON on stdin, exit code `0` to continue and `2` to block with the reason on stderr. harnesspm's format keeps that shape.
70
-
71
- ```json
72
- {
73
- "hooks": {
74
- "PostToolUse": [
75
- {
76
- "id": "check-styles",
77
- "matcher": { "claude": "Edit|Write" },
78
- "run": "check-styles",
79
- "timeout": 30
80
- }
81
- ]
82
- }
83
- }
84
- ```
85
-
86
- | Field | Required | Meaning |
87
- | --- | --- | --- |
88
- | `id` | yes | Unit name. The ID becomes `<plugin>:hooks/<id>`. |
89
- | `run` | yes | A script name from `scripts`. harnesspm writes the full command for each agent. |
90
- | `matcher` | no | A string for both agents, or an object with a `claude` key, a `codex` key or both. With an object, the hook is written only for the agents it names. Tool names differ between agents (for example, file edits), so an object is common. Without a matcher, the hook matches every tool in both agents. |
91
- | `timeout` | no | Seconds. |
92
-
93
- harnesspm writes each hook as `<prefix> run --agent <agent> <plugin name>:<script>`. In a project, the prefix is `node` with the CLI file that the project installed, `<project>/node_modules/@harnesspm/cli/dist/cli.js` (the `bin` of its package.json), as an absolute path, when it exists. Until harnesspm 1.0, the same file under the earlier name, `@tenphi/harnesspm`, counts too ([10.1](10-cli.md#moving-from-tenphiharnesspm)). `node` runs the file whatever its mode: Yarn 4 drops the executable bit on an upgrade in place ([research](https://github.com/tenphi/harnesspm/blob/main/docs/research/package-managers.md#the-cli-files-mode)). npx costs about 0.4 seconds per call, and an agent waits for a hook on file edits at every edit ([research](https://github.com/tenphi/harnesspm/blob/main/docs/research/agent-capabilities.md#settings-hooks-permissions)). Hooks are in per-machine files, so an absolute path is fine there. Without that file, and on Windows, the prefix is `npx -y @harnesspm/cli`, or `npx -y @harnesspm/cli` where the project does not depend on harnesspm. User-level files serve every repository, so they always use `npx -y @harnesspm/cli`. The same prefix starts stdio MCP servers ([5.3](#53-mcp-servers)) and harnesspm's telemetry hooks ([14.4](14-telemetry.md#144-agent-events)).
94
-
95
- ### Events
96
-
97
- Portable events, supported by both agents: `SessionStart`, `SessionEnd`, `UserPromptSubmit`, `PreToolUse`, `PermissionRequest`, `PostToolUse`, `PreCompact`, `PostCompact`, `SubagentStart`, `SubagentStop`, `Stop`.
98
-
99
- harnesspm writes a hook only for the agents that support its event.
100
-
101
- ### Contract for hook scripts
102
-
103
- 1. The script reads the agent's own JSON on stdin. `HARNESSPM_AGENT` says which agent sent it.
104
- 2. Exit `0` continues. Exit `2` blocks, for events that support blocking, with the reason on stderr.
105
- 3. JSON on stdout, such as `hookSpecificOutput.permissionDecision`, follows the agent's own format.
106
- 4. A hook may run in a session that starts in a parent folder ([4.10](04-outputs.md#410-sessions-that-start-in-a-parent-folder)). harnesspm then runs it in its project, as in a session there, and does not run it for a file outside the project, which such a session also edits. A file the hook's JSON does not name, such as in a Codex `apply_patch`, reaches the script: it checks `HARNESSPM_PROJECT_DIR`.
107
-
108
- Agent Plugins has an open proposal for portable hooks ([PR #89](https://github.com/agentplugins/agent-plugins-spec/pull/89)). If it becomes part of the standard, harnesspm reads the standard file as well and keeps its own format working during a migration period.
109
-
110
- ## 5.3 MCP servers
111
-
112
- MCP servers use the Agent Plugins `mcp.json` format.
113
-
114
- ```json
115
- {
116
- "$schema": "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json",
117
- "mcpServers": {
118
- "docs": {
119
- "type": "stdio",
120
- "command": "node",
121
- "args": ["${PLUGIN_ROOT}/dev.harnesspm/scripts/docs-mcp.mjs"]
122
- },
123
- "figma": { "type": "streamable-http", "url": "https://example.com/mcp" }
124
- }
125
- }
126
- ```
127
-
128
- harnesspm writes each server under the name `<plugin name>-<server>`, such as `uikit-docs`. For a server from the project, an added harness or a trusted package, it also writes an allow rule for its tools in Claude Code (`mcp__uikit-docs`), because MCP tool calls ask for approval even in cloud sessions. A trusted server already runs the package's code, so its tools need no opt-in of their own. Codex gets no rule.
129
-
130
- - **stdio servers** are written as `harnesspm mcp uikit:docs`, with the prefix that hooks use ([5.2](#52-hooks)). The runner expands `${PLUGIN_ROOT}` and `${PLUGIN_DATA}`, sets the environment from [5.1](#51-scripts) and starts the server. Both agents get the same command.
131
- - **Remote servers** are written as they are. Secrets never go into `mcp.json`. Authentication stays with the agent.
132
-
133
- ## 5.4 Permissions
134
-
135
- A dependency MUST NOT be able to grant itself broad rights. harnesspm writes allow rules only for units from the project, an added harness or a trusted package, and only for three things: skills, scripts with `"allow": true`, and MCP servers ([5.3](#53-mcp-servers)). Deny and ask rules pass through freely.
136
-
137
- **Skills get an allow rule to run unattended.** Outside cloud sessions, Claude Code asks before it invokes a skill, and a headless run denies the call. For each skill from the project's own harness, an added harness or a trusted package, harnesspm writes `Skill(<name>)` into `permissions.allow`. The `allowed-tools` field inside a `SKILL.md` does not replace this: it only pre-approves tools while the skill runs. In cloud sessions the rule changes nothing ([5.5](#55-what-the-agents-still-decide)).
138
-
139
- **Scripts get an allow rule when they ask for one.** When a script has `"allow": true` and the consumer trusts the package, harnesspm writes:
140
-
141
- | Agent | Rule |
142
- | --- | --- |
143
- | Claude Code | `Bash(npx -y @harnesspm/cli run uikit:probe *)` in `permissions.allow` |
144
- | Codex | `prefix_rule(pattern=["npx", "-y", "@harnesspm/cli", "run", "uikit:probe"], decision="allow")` |
145
-
146
- An allow rule keeps the npx form of the tool line ([4.6](04-outputs.md#46-managed-blocks)), also where hooks start the installed CLI file, because it must match the command the agent types. For a project's own and its dependencies' scripts, harnesspm also writes the rule for the bare form, `npx harnesspm run uikit:probe`, until 1.0, because some packages' text still types it. Inside the project, npx runs the installed command for it. The forms run the same unit, and so does `npx -y @tenphi/harnesspm run uikit:probe` under the earlier package name ([10.1](10-cli.md#moving-from-tenphiharnesspm)). So a model run that had one may write another ([06-trust.md](06-trust.md#62-trusting-a-package), rule 4). From outside the project, with `-C`, no allow rule applies: the session's own settings decide.
147
-
148
- **Deny and ask rules** only restrict. They are written as command prefixes:
149
-
150
- ```json
151
- {
152
- "deny": [["git", "push", "--force"]],
153
- "ask": [["npm", "publish"]]
154
- }
155
- ```
156
-
157
- | Neutral | Claude Code | Codex |
158
- | --- | --- | --- |
159
- | `deny` | `Bash(git push --force *)` in `permissions.deny` | `prefix_rule(…, decision="forbidden")` |
160
- | `ask` | `Bash(npm publish *)` in `permissions.ask` | `prefix_rule(…, decision="prompt")` |
161
-
162
- ## 5.5 What the agents still decide
163
-
164
- harnesspm adds a gate. It does not remove the agents' own gates:
165
-
166
- | Agent | Own gate |
167
- | --- | --- |
168
- | Claude Code | Allow rules in the untracked `.claude/settings.local.json` apply without the workspace trust step, because the file belongs to the person. harnesspm's trust is the main gate here. |
169
- | Claude Code cloud sessions | A platform rule approves built-in tools, even in default mode, but not MCP tools. Deny rules from settings still apply and win. The gates are harnesspm's trust, which decides which hooks, MCP servers and scripts exist, the lock check in `harnesspm run`, and deny rules. |
170
- | Codex | Project `.codex/` files load only when the project is trusted. Each hook is reviewed by its hash in `/hooks`. |
@@ -1,88 +0,0 @@
1
- # 6. Trust and lock
2
-
3
- **In short**
4
-
5
- - Text units (rules, docs, skills, sub-agents) need no trust. Executable units, allow rules, and the keys in skills and sub-agents that run code or skip a prompt do.
6
- - A project trusts a package in `harnesspm.json`. Adding a harness on top is the person trusting it. Trust never passes through `extends`.
7
- - An agent never grants permissions through harnesspm: new allow rules, hooks and MCP servers wait for a person. The exception is what a person already reviewed: an agent's install writes what the default branch records.
8
- - `harnesspm.lock.json` records every unit's hash, so pull requests show what changed.
9
-
10
- ## 6.1 What needs trust
11
-
12
- | Unit | Needs trust? | Why |
13
- | --- | --- | --- |
14
- | Rules, docs, sub-agent definitions, skills | No | Text. The agent still asks before running commands, unless a permission allows them. |
15
- | Keys in a sub-agent or a `SKILL.md` that run code or skip a prompt: `hooks`, `mcpServers` and `permissionMode` in a Claude Code sub-agent, `sandbox_mode` and `approval_policy` in a Codex one, `allowed-tools` and `hooks` in a skill | **Yes** | Claude Code runs a project sub-agent's hooks and MCP servers once the folder is trusted, and applies a skill's `allowed-tools` even in a folder nobody trusted. It ignores the same sub-agent keys in plugins, for security ([research](https://github.com/tenphi/harnesspm/blob/main/docs/research/agent-capabilities.md#skills-sub-agents-mcp-memory)). For an untrusted package, a sub-agent is written without them, and a skill is linked as a generated copy without them ([4.3](04-outputs.md#43-project-outputs)). `sync` names each key it leaves out. A replaced skill counts as the files of the package that replaced it, or of the project for `harnesspm.json`. |
16
- | The `Skill(<name>)` allow rule that lets an unattended session run a skill | **Yes** | It removes a prompt. Written only for skills from the project, an added harness or a trusted package, by the package whose files the skill uses. |
17
- | Scripts, hooks, MCP servers | **Yes** | They run code, some of them automatically. |
18
- | Allow permissions | **Yes** | They remove a prompt. |
19
- | Deny and ask permissions | No | They only restrict. |
20
- | The telemetry handler | **Yes** | It runs a command on every machine of the team. Recorded in the lock by a person's sync ([14.5](14-telemetry.md#145-trust)). |
21
-
22
- ## 6.2 Trusting a package
23
-
24
- ```json
25
- {
26
- "trust": {
27
- "@cube-dev/ui-kit": true,
28
- "some-third-party": "pin"
29
- }
30
- }
31
- ```
32
-
33
- | Value | Meaning |
34
- | --- | --- |
35
- | `true` | Executable units are active, also after upgrades. The lock diff shows changes. For the team's own packages. |
36
- | `"pin"` | Active only in the version approved in the lock. Adding the entry approves the installed version. A new version stays off until `harnesspm approve`. For packages the team does not control. |
37
- | missing | Executable units stay off. `harnesspm sync` lists them as **pending** and does not fail. |
38
-
39
- Rules:
40
-
41
- 1. Trust MUST NOT pass through `extends`. Trusting UI Kit does not trust Tasty.
42
- 2. `harnesspm add` is the person's trust decision for that harness. Added harnesses need no `trust` entry.
43
- 3. `harnesspm run` checks the lock before running a script, so the rules also hold when an agent calls a script directly.
44
- 4. harnesspm MUST NOT add or widen allow rules, hooks or MCP servers when the agent's model runs it, for example through an install the model starts, unless a person already reviewed them. Agents keep the model from granting itself permissions, and harnesspm must not be a way around that.
45
- - Claude Code marks who runs a command: `AI_AGENT` ends in `_agent` for commands the model runs and in `_harness` for hooks and MCP servers. Setup scripts get neither. harnesspm treats `_agent`, or `CLAUDECODE=1` without `AI_AGENT`, as a model run.
46
- - Codex sets `CODEX_CI=1` and `CODEX_TOOL_CALL_ID` in commands the model runs, and in neither hooks nor commands a person runs. harnesspm treats either as a model run. Codex's workspace-write sandbox also keeps `.codex/` and `~/.codex` read-only for model runs ([research](https://github.com/tenphi/harnesspm/blob/main/docs/research/agent-capabilities.md#codex)).
47
- - These markers are advisory: a model can unset them. They stop accidents, such as an install the model starts, not a model that works around them.
48
- - A hook runs from settings a person wrote, so a hook run may add entries.
49
- - A model run keeps the entries a person granted before, and never removes a deny or ask rule. Held-back entries stay pending until a person runs `harnesspm sync` or `harnesspm approve`, a setup script or a hook runs harnesspm, or the repository is in its reviewed state. Text units, skill links and other removals are written as usual.
50
- - **Reviewed state.** A model run writes the repository's entries as a person's run does when the repository is in its reviewed state, that is, when all of these hold. Then a teammate's merged change reaches every machine with the next install, and the agent's own edits still wait for review.
51
- 1. The trust inputs are the same as at the merge base of `HEAD` and the remote default branch (`origin/HEAD`): `harnesspm.json`, `harnesspm.lock.json`, the project's `harness/` and `harnesspm/patches/`, and each workspace's `harness/` and `harnesspm/patches/`. An uncommitted change, a commit on the branch, or an untracked file there fails the check.
52
- 2. The sync computes the committed lock, so every unit hash, package version and `"pin"` approval is what the review saw. An install that the lock does not record, such as `pnpm add <pkg>@next`, fails the check.
53
- 3. It covers only the repository's layers. Added harnesses are not locked, and a person grants them with `add` (rule 2).
54
- - The check reads local refs only, so it costs a few git commands and no network. A stale `origin/HEAD` means an older reviewed state. Like the markers, it is advisory: a model can move a ref. It assumes that changes reach the default branch only through review.
55
- - Without `origin/HEAD` (`git remote set-head origin --auto` sets it), and in a Codex run, a model run holds back as before. Codex's sandbox keeps `.codex/` read-only, and Codex asks a person to review each new hook anyway.
56
- - A hook whose command changes only in its prefix, such as `node` with the installed CLI file in place of npx ([5.2](05-executables.md#52-hooks)), runs the same script. A model run writes it too.
57
- - A model run also keeps the telemetry handler that the lock has. A new or changed handler is held the same way ([14.5](14-telemetry.md#145-trust)).
58
- - `sync` lists the entries it held back, and why the repository is not in its reviewed state, such as `harnesspm.json differs from origin/main` or `the installed packages do not match harnesspm.lock.json`. So the person knows whether a review or an install is due. `status` and `doctor` list the same entries, counted the same way, with a held telemetry handler first. When the repository is in its reviewed state but this machine lacks entries, they say that a sync writes them. Outside a cloud session, they ask the person to run `sync` or `approve` in their own terminal. In a Claude Code cloud session (`CLAUDE_CODE_REMOTE=true`), the person has no terminal there, so they print the line for the environment's setup script instead ([9.1](09-cloud.md#91-the-repositorys-harness)).
59
-
60
- ## 6.3 The lock
61
-
62
- `harnesspm.lock.json` is committed. It covers the dependency and project layers and records:
63
-
64
- - every harness package: name, version, plugin name, tarball URL and integrity, so `harnesspm fetch` can download it without an install; for a `"pin"` package, also the approved version. The URL and integrity come from `package-lock.json`, `pnpm-lock.yaml` or Yarn 1's `yarn.lock`. pnpm records a URL only for a package outside the registry;
65
- - the project's own harness, and each workspace's: name, plugin name and `"project": true`, without a version. The project layer is always trusted and its unit hashes show every change, so a release that raises the project's version leaves the lock as it is. A lock with that version, as harnesspm 0.3 wrote it, still counts as up to date, and the next `sync` drops it;
66
- - every unit: ID, kind, content hash. A docs unit's content is its `llms.txt` and its `.md` and `.mdx` pages that git does not ignore ([2.7](02-package-format.md#27-docs)), so a change to another file in its folder, such as source code next to the pages, leaves the lock as it is;
67
- - every patch: a hash of each section it replaces or removes, so an upgrade that changes one is reported. A rule or patched section with different text across workspaces has a hash that covers each workspace's version;
68
- - the telemetry handler that a person's sync recorded ([14.5](14-telemetry.md#145-trust)).
69
-
70
- The lock holds no per-machine state, so every machine writes the same lock. `harnesspm status` shows which executable units are pending on this machine, and why.
71
-
72
- People do not edit it. Added harnesses are not locked. They follow their branch or version range, and `harnesspm update` refreshes them.
73
-
74
- ## 6.4 CI
75
-
76
- `harnesspm sync --check` and every run with `CI=true` ignore added harnesses. `--check` writes nothing and fails when:
77
-
78
- - a committed output or the lock is out of date, including a telemetry handler that differs from `harnesspm.json`;
79
- - a `"pin"` package has a version that nobody approved.
80
-
81
- With `CI=true`, `sync` also leaves the committed outputs as they are. An install runs `sync` from `prepare` or `postinstall`, and if that sync rewrote them, a later `sync --check` would compare fresh files and pass while the pull request missed a sync. So in CI, `sync` writes only the per-machine outputs, such as stable package paths, docs copies and skill links, which jobs and review bots read. It says so in one line. A job that commits the result runs `sync --write`.
82
-
83
- ## 6.5 Not covered
84
-
85
- - **A trusted package is compromised.** `true` follows new versions. The lock diff and normal dependency review are the protection. Use `"pin"` for packages the team does not control.
86
- - **Prompt injection in text units.** Rules and skills are instructions. Review them like code.
87
- - **Commands in an untrusted skill.** A `` !`command` `` in a `SKILL.md` runs when the skill loads, if the person's permission rules allow it. Without `allowed-tools`, a command they don't allow stops the skill, except in auto mode, where the agent's own check decides ([research](https://github.com/tenphi/harnesspm/blob/main/docs/research/agent-capabilities.md#skills-sub-agents-mcp-memory)).
88
- - **An agent ignores a rule.** harnesspm delivers instructions. Hooks and deny permissions can enforce some of them.
@@ -1,109 +0,0 @@
1
- # 7. Added harnesses
2
-
3
- **In short**
4
-
5
- - An **added harness** is an ordinary harness that a person adds on their machine, on top of the repository's. It is never committed.
6
- - Add any number, in order: for example, your team's shared harness, then your own. A later one wins on a skill name.
7
- - **User scope** applies a harness in every repository on the machine, including its entries for single repositories. **Local scope** applies it in one repository.
8
- - Each session starts with the harness's newest commits: the hook that `add` installs runs `update` ([7.5](#75-applying-in-every-repository)).
9
- - Agents can improve an added harness, as described in [08-improving.md](08-improving.md).
10
-
11
- ## 7.1 What goes in it
12
-
13
- An added harness holds what should not live in every project repository:
14
-
15
- | Content | Unit kind | Example |
16
- | --- | --- | --- |
17
- | How a team or a person works | Always-on rule | Commit style, review habits, preferred tools |
18
- | Context the agent reads when needed | Docs (notes) | Which repositories exist and how they relate, environments, people to ask |
19
- | Repeated workflows | Skills | Releasing a package, preparing a weekly update |
20
- | Tools | Scripts, hooks, MCP servers | A script that opens a local preview of linked repositories |
21
- | Changes for one repository | Project entry | A local staging address, a replaced team rule |
22
-
23
- A team's harness and a person's own harness use the same format and the same commands. Only their owners differ, and each owner's rules decide how its changes are saved ([08-improving.md](08-improving.md#83-the-owner-decides-how-to-save)). To give a harness to everyone who works on a repository, make it a dependency instead (S6).
24
-
25
- A person's own added harness is the "memory" they keep across projects and machines. Notes that an agent saves by itself, such as Claude Code auto memory, stay with the agent and are not part of harnesspm.
26
-
27
- ## 7.2 Example
28
-
29
- ```text
30
- alex-harness/ a git repository, on any host
31
- ├── AGENTS.md how to change this repository, including how to save changes
32
- └── harness/
33
- ├── plugin.json
34
- ├── dev.harnesspm/rules/
35
- │ └── workflow.md always on
36
- ├── notes/ read on demand
37
- │ ├── llms.txt index of the notes
38
- │ └── projects.md repositories and how they relate
39
- ├── skills/
40
- │ └── alex-release/SKILL.md
41
- └── projects/
42
- └── cube-ui-kit/ same layout as harness/; plugin.json is optional
43
- └── dev.harnesspm/rules/local-setup.md
44
- ```
45
-
46
- ```json
47
- {
48
- "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
49
- "name": "alex",
50
- "extensions": {
51
- "dev.harnesspm": {
52
- "docs": "./notes",
53
- "projects": {
54
- "github.com/cube-js/cube-ui-kit": "./projects/cube-ui-kit"
55
- }
56
- }
57
- }
58
- }
59
- ```
60
-
61
- A project entry is matched by the repository's `origin` remote, written as `<host>/<path>` without `.git`, for SSH and HTTPS URLs alike. So it also works in a fresh clone in a cloud session.
62
-
63
- Units in an entry belong to the added harness, so their IDs start with its plugin name. An entry's unit wins over one with the same ID in the rest of the harness. The entry's optional `plugin.json` uses the same name and may hold `exclude`, `replace` and `patch` for the repository's units.
64
-
65
- ## 7.3 Sources
66
-
67
- | Source | Example | Editable | Where it lives |
68
- | --- | --- | --- | --- |
69
- | Git repository | `github:alex/harness`, `git:https://git.example.com/team/harness.git` | yes | A working copy in `~/.harnesspm/harnesses/<name>/` |
70
- | Folder | `~/dev/alex-harness` | yes | In place |
71
- | npm package | `npm:@alex/harness` | no | A cache in `~/.harnesspm/cache/` |
72
-
73
- Git sources work with any host. npm and git sources never touch the project's `package.json` or lockfile.
74
-
75
- ## 7.4 Scopes and order
76
-
77
- | Scope | How to add | Recorded in | Outputs |
78
- | --- | --- | --- | --- |
79
- | **User** | `npx -y @harnesspm/cli add <source>` | `~/.harnesspm/config.json` | User-level folders, see [04-outputs.md](04-outputs.md#44-outputs-of-added-harnesses-user-scope) |
80
- | **Local** | `npx -y @harnesspm/cli add <source> --local` | `harnesspm.local.json` in the repository, excluded from git | Project outputs, see [04-outputs.md](04-outputs.md#43-project-outputs) |
81
-
82
- Both files have one field:
83
-
84
- ```json
85
- { "harnesses": ["github:cube-js/frontend-harness", "github:alex/harness"] }
86
- ```
87
-
88
- `add` appends, so harnesses apply in the order they were added: user scope first, then local scope. A project entry comes right after its harness. `harnesspm new --to <plugin>` names the harness to write into.
89
-
90
- ## 7.5 Applying in every repository
91
-
92
- `harnesspm add` also installs one user-level `SessionStart` hook for each agent. The hook runs `npx -y @harnesspm/cli update` at the start of every session: it fetches the newest commits or version of each added harness, then syncs. In a repository that does not use harnesspm, or whose dependencies are not installed yet, `sync` writes only the per-machine outputs of added harnesses, including their project entries, and changes only git-excluded files.
93
-
94
- - **Fetching never blocks a session.** Nobody can answer a prompt in a hook, so git never asks for credentials there, and a fetch that takes over 30 seconds is stopped. A fetch that fails prints a warning, and the session starts with what is on the machine.
95
- - **Local work stays.** A working copy with uncommitted changes or unpushed commits is not fetched ([8.7](08-improving.md#87-shared-working-copies)), so an improvement in progress is never overwritten.
96
- - **New commits apply, executables included.** Claude Code runs the hook with `AI_AGENT=…_harness`, so this run may write hooks and permissions ([06-trust.md](06-trust.md#62-trusting-a-package), rule 4). Adding a harness trusts its future commits, as `"trust": true` trusts a team's own package after upgrades. A push to the harness's remote reaches the machine at the next session start. For a harness whose pushes you do not control, add an npm source with a fixed version, such as `npm:@acme/harness@1.2.0`, or pass `--no-hook` and run `update` yourself ([13.13](13-open-questions.md#1313-the-reviewed-state-in-hook-runs)).
97
- - **Several repositories.** A session that starts above several repositories, such as a cloud session with more than one, runs the hook in that folder. It applies each repository's entry there, as a sync in it would ([4.10](04-outputs.md#410-sessions-that-start-in-a-parent-folder)). Such a session reads the entries' rules and skills, not their hooks and permissions.
98
- - **Older hooks.** harnesspm 0.14 and earlier installed a hook that ran `sync`, and 0.16 and earlier named the package `@tenphi/harnesspm` ([10.1](10-cli.md#moving-from-tenphiharnesspm)). The next `sync` or `update` by a person or a hook turns it into today's hook, in place. A run of the agent's model leaves it, because the new command also fetches.
99
- - Claude Code uses what the hook writes in the same session: a `CLAUDE.local.md` and a `.claude/settings.local.json` written by a `SessionStart` hook were both read in cloud sessions.
100
- - Codex asks the person to review a new hook once, in `/hooks`.
101
- - `--no-hook` skips the hook. Project entries then apply only where `harnesspm sync` runs, and new commits only when you run `update`.
102
- - `harnesspm remove` takes the hook away with the last harness with user scope.
103
-
104
- ## 7.6 Keeping the project clean
105
-
106
- 1. Added units are never written into tracked files. Per-machine files are excluded through `.git/info/exclude`. `harnesspm doctor` shows whether a repository is ready for a harness of your own, and finds a per-machine file that a commit could include ([10.5](10-cli.md#105-doctor)).
107
- 2. CI ignores added harnesses. With `CI=true`, `sync` writes only per-machine outputs ([06-trust.md](06-trust.md#64-ci)).
108
- 3. `harnesspm status` lists every change that an added harness makes to the repository's units, so it stays visible.
109
- 4. In a cloud environment shared by several people, add harnesses in your own environment. See [09-cloud.md](09-cloud.md).