@harnesspm/cli 0.0.0-snapshot.412a718 → 0.0.0-snapshot.5e392dd
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 +22 -0
- package/README.md +12 -9
- package/dist/cli.js +26 -14
- package/dist/commands.d.ts +16 -6
- package/dist/commands.js +324 -162
- package/dist/exec-outputs.d.ts +2 -0
- package/dist/exec-outputs.js +5 -4
- package/dist/fetch.js +2 -1
- package/dist/outputs.d.ts +5 -0
- package/dist/outputs.js +34 -0
- package/dist/run.js +1 -1
- package/dist/start.d.ts +18 -0
- package/dist/start.js +136 -0
- package/docs/spec/01-overview.md +13 -6
- package/docs/spec/04-outputs.md +7 -5
- package/docs/spec/06-trust.md +1 -1
- package/docs/spec/07-added.md +2 -2
- package/docs/spec/09-cloud.md +1 -1
- package/docs/spec/10-cli.md +66 -31
- package/harness/dev.harnesspm/rules/harnesspm-config.md +1 -1
- package/harness/skills/harnesspm-export/SKILL.md +1 -1
- package/harness/skills/harnesspm-import/SKILL.md +10 -18
- package/package.json +1 -1
package/dist/exec-outputs.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export type Group = 'team' | 'added';
|
|
|
5
5
|
export interface TrustState {
|
|
6
6
|
trusted: boolean;
|
|
7
7
|
reason?: string;
|
|
8
|
+
/** The person's step that turns the units on. */
|
|
9
|
+
action?: string;
|
|
8
10
|
}
|
|
9
11
|
/** Trust of a package's executable units (spec 6.2). The project and added harnesses are trusted. */
|
|
10
12
|
export declare function trustOf(pkg: ResolvedPackage, res: Resolution, lock: Lock | undefined): TrustState;
|
package/dist/exec-outputs.js
CHANGED
|
@@ -17,10 +17,10 @@ export function trustOf(pkg, res, lock) {
|
|
|
17
17
|
const approved = lock?.packages[pkg.name]?.approved;
|
|
18
18
|
if (approved === undefined || approved === pkg.version)
|
|
19
19
|
return { trusted: true };
|
|
20
|
-
return { trusted: false, reason: `version ${pkg.version} is not approved
|
|
20
|
+
return { trusted: false, reason: `version ${pkg.version} is not approved; approved: ${approved}`, action: `A person runs \`${NPX_ANY} approve ${pkg.name}\`.` };
|
|
21
21
|
}
|
|
22
|
-
// Trust is the person's decision (spec 6.2). The
|
|
23
|
-
return { trusted: false, reason:
|
|
22
|
+
// Trust is the person's decision (spec 6.2). The action says who acts, so an agent does not take it as its next step.
|
|
23
|
+
return { trusted: false, reason: 'not trusted', action: `A person adds "${pkg.name}": true to "trust" in harnesspm.json, then runs \`${NPX_ANY} approve\`.` };
|
|
24
24
|
}
|
|
25
25
|
export function emptyEntries() {
|
|
26
26
|
return { claude: { allow: [], deny: [], ask: [], hooks: [], mcp: {} }, codex: { hooks: [], rules: [], mcp: {} }, agentFiles: new Map(), pending: [], warnings: [] };
|
|
@@ -170,7 +170,8 @@ export function desiredEntries(res, packages, trust, where) {
|
|
|
170
170
|
}
|
|
171
171
|
for (const [pkg, counts] of pendingCounts) {
|
|
172
172
|
const what = [...counts].map(([kind, n]) => `${n} ${kind}${n === 1 ? '' : 's'}`).join(', ');
|
|
173
|
-
|
|
173
|
+
const state = trust(pkg);
|
|
174
|
+
entries.pending.push(`${pkg.name}: ${what} (${state.reason}). ${state.action}`);
|
|
174
175
|
}
|
|
175
176
|
return entries;
|
|
176
177
|
}
|
package/dist/fetch.js
CHANGED
|
@@ -5,7 +5,7 @@ import * as fs from 'node:fs';
|
|
|
5
5
|
import * as os from 'node:os';
|
|
6
6
|
import * as path from 'node:path';
|
|
7
7
|
import { LOCK_FILE, packageManagerLock, readLock } from './lock.js';
|
|
8
|
-
import { addExcludes, computePlan, DOCS_DIR, DOCS_EXCLUDE, DOCS_PROBE, docsIgnoreAdvice, RGIGNORE_EXCLUDE, STATE_DIR, writeRgignore } from './outputs.js';
|
|
8
|
+
import { addExcludes, computePlan, DOCS_DIR, DOCS_EXCLUDE, DOCS_PROBE, docsIgnoreAdvice, prunePackageLinks, RGIGNORE_EXCLUDE, STATE_DIR, writeRgignore } from './outputs.js';
|
|
9
9
|
import { extractBlock } from './render.js';
|
|
10
10
|
import { resolve, resolvePackageDir } from './resolve.js';
|
|
11
11
|
import { HarnessError, NPX_ANY, ensureDir, gitKeepsOut, isInside, isRecord, linkIfChanged, readJsonIfExists, readTextIfExists, writeIfChanged } from './util.js';
|
|
@@ -131,6 +131,7 @@ export function fetchLocked(projectDir) {
|
|
|
131
131
|
for (const [link, target] of plan.links)
|
|
132
132
|
if (isInside(path.join(state, 'pkgs'), link))
|
|
133
133
|
linkIfChanged(link, target);
|
|
134
|
+
prunePackageLinks(projectDir, plan.links);
|
|
134
135
|
if (copies && (typeof plan.rgignore !== 'string' || excluded([RGIGNORE_EXCLUDE]))) {
|
|
135
136
|
try {
|
|
136
137
|
writeRgignore(projectDir, plan);
|
package/dist/outputs.d.ts
CHANGED
|
@@ -89,6 +89,11 @@ export declare function computePlan(team: Resolution | undefined, full: Resoluti
|
|
|
89
89
|
}): Plan;
|
|
90
90
|
/** The per-machine paths that harnesspm's last sync listed in .git/info/exclude, from the project folder, such as `/CLAUDE.local.md`. */
|
|
91
91
|
export declare function excludedBySync(projectDir: string): string[];
|
|
92
|
+
/**
|
|
93
|
+
* Removes the links in node_modules/.harnesspm/pkgs that `links` no longer names, such as a dependency the project
|
|
94
|
+
* dropped or a package's earlier name (spec 4.2), and returns them. Anything there that is not a link stays.
|
|
95
|
+
*/
|
|
96
|
+
export declare function prunePackageLinks(projectDir: string, links: Map<string, string>): string[];
|
|
92
97
|
/**
|
|
93
98
|
* The per-machine record of the entries harnesspm wrote for this project (spec 4.7): in the clone's git folder, or,
|
|
94
99
|
* in a folder that is not a git repository, in ~/.harnesspm/state/, so sync never creates a `.git` folder there.
|
package/dist/outputs.js
CHANGED
|
@@ -657,6 +657,36 @@ function unlinkAndPrune(target, stopAt) {
|
|
|
657
657
|
}
|
|
658
658
|
}
|
|
659
659
|
}
|
|
660
|
+
/**
|
|
661
|
+
* Removes the links in node_modules/.harnesspm/pkgs that `links` no longer names, such as a dependency the project
|
|
662
|
+
* dropped or a package's earlier name (spec 4.2), and returns them. Anything there that is not a link stays.
|
|
663
|
+
*/
|
|
664
|
+
export function prunePackageLinks(projectDir, links) {
|
|
665
|
+
const root = path.join(projectDir, STATE_DIR, 'pkgs');
|
|
666
|
+
const removed = [];
|
|
667
|
+
const visit = (dir, scope) => {
|
|
668
|
+
let names;
|
|
669
|
+
try {
|
|
670
|
+
names = fs.readdirSync(dir);
|
|
671
|
+
}
|
|
672
|
+
catch {
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
for (const name of names) {
|
|
676
|
+
const entry = path.join(dir, name);
|
|
677
|
+
if (isSymlink(entry)) {
|
|
678
|
+
if (links.has(entry))
|
|
679
|
+
continue;
|
|
680
|
+
unlinkAndPrune(entry, root);
|
|
681
|
+
removed.push(entry);
|
|
682
|
+
}
|
|
683
|
+
else if (scope && name.startsWith('@'))
|
|
684
|
+
visit(entry, false);
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
visit(root, true);
|
|
688
|
+
return removed;
|
|
689
|
+
}
|
|
660
690
|
/**
|
|
661
691
|
* The per-machine record of the entries harnesspm wrote for this project (spec 4.7): in the clone's git folder, or,
|
|
662
692
|
* in a folder that is not a git repository, in ~/.harnesspm/state/, so sync never creates a `.git` folder there.
|
|
@@ -732,6 +762,10 @@ export function applyPlan(projectDir, plan, options = {}) {
|
|
|
732
762
|
writeIfChanged(file, content);
|
|
733
763
|
for (const [linkPath, target] of plan.links)
|
|
734
764
|
note(linkPath, linkIfChanged(linkPath, target));
|
|
765
|
+
// Without the repository's layers, the plan names no package links, so it cannot tell which are stale.
|
|
766
|
+
if (plan.teamExcludes)
|
|
767
|
+
for (const link of prunePackageLinks(projectDir, plan.links))
|
|
768
|
+
note(link, true);
|
|
735
769
|
// Executable entries in shared files, before the excludes so that every written file is listed.
|
|
736
770
|
const person = caller() !== 'model';
|
|
737
771
|
const targets = repoTargets(projectDir, plan);
|
package/dist/run.js
CHANGED
|
@@ -20,7 +20,7 @@ function checkPackage(pkg, res, what) {
|
|
|
20
20
|
const lock = readLock(res.projectDir);
|
|
21
21
|
const trust = trustOf(pkg, res, lock);
|
|
22
22
|
if (!trust.trusted)
|
|
23
|
-
throw new Refused(`${what} of ${pkg.name} is refused: ${trust.reason}`);
|
|
23
|
+
throw new Refused(`${what} of ${pkg.name} is refused: ${trust.reason}. ${trust.action}`);
|
|
24
24
|
if (pkg.layer === 'dependencies') {
|
|
25
25
|
const locked = lock?.packages[pkg.name]?.version;
|
|
26
26
|
// Either side can be stale. A cached environment's install can be older than the lock, and a sync there would
|
package/dist/start.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const DOCS_URL = "https://harnesspm.tenphi.me";
|
|
2
|
+
/** The version of the running harnesspm. */
|
|
3
|
+
export declare function version(): string;
|
|
4
|
+
/** Who decides, said once under every list of tasks. */
|
|
5
|
+
export declare const PERSON_DECIDES = "A person decides what runs: they add a harness and trust a package. An agent asks first.";
|
|
6
|
+
export declare const EVERY_COMMAND = "Every command: `npx -y @harnesspm/cli --help`";
|
|
7
|
+
/**
|
|
8
|
+
* What the bare command prints in a folder that does not use harnesspm: what the folder is, and the tasks for it, the
|
|
9
|
+
* likeliest first. Each task names the one command that starts it, and that command prints the next step.
|
|
10
|
+
*/
|
|
11
|
+
export declare function startText(dir: string): string[];
|
|
12
|
+
/** The steps after `init` wrote and synced: what to commit, the check for CI, and what the agent does now. */
|
|
13
|
+
export declare function afterInit(toCommit: string[], waiting: boolean): string[];
|
|
14
|
+
/**
|
|
15
|
+
* What to do after `new`, by the folder (spec 10.2): an added harness saves the owner's way, a project that uses
|
|
16
|
+
* harnesspm syncs, a package publishes the harness, and a harness of one's own is added by a person.
|
|
17
|
+
*/
|
|
18
|
+
export declare function nextAfterNew(projectDir: string, added: boolean): string[];
|
package/dist/start.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Where every task starts (spec 10.1): the bare command's tasks for a folder, and the next steps that `init`, `new` and
|
|
2
|
+
// errors print. One source, so the site only shows the command and the CLI, versioned with the package, holds the steps.
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { CONFIG_FILE } from './config.js';
|
|
6
|
+
import { childProjects, isParentFolder } from './parent.js';
|
|
7
|
+
import { resolve } from './resolve.js';
|
|
8
|
+
import { HarnessError, NPX_ANY, PACKAGE_NAME, PACKAGE_NAMES, isDir, isFile, isRecord, readJson, readJsonIfExists, relPosix, shellWord } from './util.js';
|
|
9
|
+
export const DOCS_URL = 'https://harnesspm.tenphi.me';
|
|
10
|
+
/** The version of the running harnesspm. */
|
|
11
|
+
export function version() {
|
|
12
|
+
const pkg = readJson(fileURLToPath(new URL('../package.json', import.meta.url)));
|
|
13
|
+
return isRecord(pkg) && typeof pkg['version'] === 'string' ? pkg['version'] : 'unknown';
|
|
14
|
+
}
|
|
15
|
+
const ADD = { what: "Add your own or your team's harness, on every repo", command: `${NPX_ANY} add <github:owner/repo | folder>` };
|
|
16
|
+
const OWN = { what: 'Start a harness of your own, in an empty folder', command: `${NPX_ANY} new rule workflow` };
|
|
17
|
+
/** Who decides, said once under every list of tasks. */
|
|
18
|
+
export const PERSON_DECIDES = 'A person decides what runs: they add a harness and trust a package. An agent asks first.';
|
|
19
|
+
export const EVERY_COMMAND = `Every command: \`${NPX_ANY} --help\``;
|
|
20
|
+
/** The dependencies of a package folder that ship a harness, harnesspm's own left out. */
|
|
21
|
+
function shipping(dir) {
|
|
22
|
+
try {
|
|
23
|
+
const packages = resolve(dir, { team: true }).packages.filter((p) => p.layer === 'dependencies' && !PACKAGE_NAMES.includes(p.name));
|
|
24
|
+
// The ones the project lists first, then those they pass on.
|
|
25
|
+
const names = [...packages.filter((p) => p.direct), ...packages.filter((p) => !p.direct)].map((p) => p.name);
|
|
26
|
+
if (names.length === 0)
|
|
27
|
+
return isDir(path.join(dir, 'node_modules')) ? 'No installed dependency ships a harness yet.' : 'Its dependencies are not installed yet.';
|
|
28
|
+
return `${names.length === 1 ? '1 dependency ships' : `${names.length} dependencies ship`} a harness: ${names.join(', ')}.`;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (error instanceof HarnessError)
|
|
32
|
+
return '';
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* What the bare command prints in a folder that does not use harnesspm: what the folder is, and the tasks for it, the
|
|
38
|
+
* likeliest first. Each task names the one command that starts it, and that command prints the next step.
|
|
39
|
+
*/
|
|
40
|
+
export function startText(dir) {
|
|
41
|
+
const name = path.basename(dir);
|
|
42
|
+
const isPackage = isRecord(readJsonIfExists(path.join(dir, 'package.json')));
|
|
43
|
+
const hasHarness = isFile(path.join(dir, 'harness', 'plugin.json'));
|
|
44
|
+
let about;
|
|
45
|
+
let tasks;
|
|
46
|
+
if (isPackage && hasHarness) {
|
|
47
|
+
about = `This package (${name}) shares a harness and does not use harnesspm itself.`;
|
|
48
|
+
tasks = [
|
|
49
|
+
{ what: 'Check the harness this package shares', command: `${NPX_ANY} check` },
|
|
50
|
+
{ what: "See it as its users' agents will, in AGENTS.md", command: `${NPX_ANY} init` },
|
|
51
|
+
{ what: 'Add a rule, skill or tool to it', command: `${NPX_ANY} new <kind> <name>` },
|
|
52
|
+
ADD,
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
else if (isPackage) {
|
|
56
|
+
about = `This folder (${name}) does not use harnesspm. ${shipping(dir)}`.trimEnd();
|
|
57
|
+
tasks = [
|
|
58
|
+
{ what: "Give this project's agents its dependencies' harness", command: `${NPX_ANY} init` },
|
|
59
|
+
{ what: 'Share a harness from this package', command: `${NPX_ANY} new rule usage` },
|
|
60
|
+
ADD,
|
|
61
|
+
OWN,
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
else if (isParentFolder(dir)) {
|
|
65
|
+
const projects = childProjects(dir).map((p) => path.basename(p));
|
|
66
|
+
about = `This folder is above ${projects.length === 1 ? '1 project' : `${projects.length} projects`} that use harnesspm: ${projects.join(', ')}.`;
|
|
67
|
+
tasks = [
|
|
68
|
+
{ what: 'Give sessions that start here their hooks', command: `${NPX_ANY} sync` },
|
|
69
|
+
{ what: "List a project's packages from here", command: `${NPX_ANY} -C ${shellWord(projects[0])} help` },
|
|
70
|
+
ADD,
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
else if (hasHarness) {
|
|
74
|
+
about = `This folder (${name}) is a harness, not a project: it has no package.json.`;
|
|
75
|
+
tasks = [
|
|
76
|
+
{ what: 'Check it', command: `${NPX_ANY} check` },
|
|
77
|
+
{ what: 'Add a rule, skill or tool to it', command: `${NPX_ANY} new <kind> <name>` },
|
|
78
|
+
{ what: 'Add it on this machine (a person does this)', command: `${NPX_ANY} add ${shellWord(dir)}` },
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
about = `This folder (${name}) is not a project: it has no package.json.`;
|
|
83
|
+
tasks = [
|
|
84
|
+
{ ...OWN, what: 'Start a harness of your own, in this folder' },
|
|
85
|
+
ADD,
|
|
86
|
+
{ what: "Give a project's agents its dependencies' harness, in it", command: `${NPX_ANY} init` },
|
|
87
|
+
{ what: 'Share a harness from a package, in it', command: `${NPX_ANY} new rule usage` },
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
const width = Math.max(...tasks.map((t) => t.what.length)) + 3;
|
|
91
|
+
return [
|
|
92
|
+
`harnesspm ${version()}: rules, docs, skills and tools from npm packages, for Claude Code and Codex.`,
|
|
93
|
+
about,
|
|
94
|
+
'',
|
|
95
|
+
'Pick the task, run its command, and follow what it prints:',
|
|
96
|
+
...tasks.map((t) => ` ${t.what.padEnd(width)}${t.command}`),
|
|
97
|
+
'',
|
|
98
|
+
PERSON_DECIDES,
|
|
99
|
+
`Every command: ${NPX_ANY} --help · Docs: ${DOCS_URL}`,
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
/** The steps after `init` wrote and synced: what to commit, the check for CI, and what the agent does now. */
|
|
103
|
+
export function afterInit(toCommit, waiting) {
|
|
104
|
+
return [
|
|
105
|
+
...(toCommit.length > 0 ? [`To commit: ${toCommit.join(', ')}`] : []),
|
|
106
|
+
`In CI, after the install: ${NPX_ANY} sync --check`,
|
|
107
|
+
waiting ? 'Agent: report this to the person and wait for their trust decision.' : 'Agent: report this to the person.',
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
/** The harnesspm-export skill: the copy the project installed, else the one that ships with this harnesspm. */
|
|
111
|
+
function exportSkill(projectDir) {
|
|
112
|
+
const rel = path.join('harness', 'skills', 'harnesspm-export', 'SKILL.md');
|
|
113
|
+
const installed = path.join(projectDir, 'node_modules', PACKAGE_NAME, rel);
|
|
114
|
+
return isFile(installed) ? relPosix(projectDir, installed) : fileURLToPath(new URL(`../${rel.split(path.sep).join('/')}`, import.meta.url));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* What to do after `new`, by the folder (spec 10.2): an added harness saves the owner's way, a project that uses
|
|
118
|
+
* harnesspm syncs, a package publishes the harness, and a harness of one's own is added by a person.
|
|
119
|
+
*/
|
|
120
|
+
export function nextAfterNew(projectDir, added) {
|
|
121
|
+
if (added)
|
|
122
|
+
return [`Next: edit it, run \`${NPX_ANY} sync\`, then save the change the way that harness's own AGENTS.md or CONTRIBUTING.md says.`];
|
|
123
|
+
if (isFile(path.join(projectDir, CONFIG_FILE)))
|
|
124
|
+
return [`Next: edit it, then run \`${NPX_ANY} sync\` and \`${NPX_ANY} check\`.`];
|
|
125
|
+
if (!isFile(path.join(projectDir, 'package.json'))) {
|
|
126
|
+
return [
|
|
127
|
+
`Next: edit it, run \`${NPX_ANY} check\`, and commit.`,
|
|
128
|
+
`A person adds it on their machine, in their own terminal: \`${NPX_ANY} add ${shellWord(projectDir)}\`, or \`add github:<owner>/<repo>\` once it is pushed.`,
|
|
129
|
+
];
|
|
130
|
+
}
|
|
131
|
+
return [
|
|
132
|
+
`Next: edit it, then run \`${NPX_ANY} check\`.`,
|
|
133
|
+
`To publish it, add "harness" to "files" in package.json, and "prepack": "harnesspm check" with ${PACKAGE_NAME} as a dev dependency.`,
|
|
134
|
+
`Every step, and what goes into a harness: the harnesspm-export skill, ${exportSkill(projectDir)}`,
|
|
135
|
+
];
|
|
136
|
+
}
|
package/docs/spec/01-overview.md
CHANGED
|
@@ -34,14 +34,21 @@ my-lib/
|
|
|
34
34
|
└── rules/… Markdown rules
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
+
### Start
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npx -y @harnesspm/cli
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Every task starts with this one command. In a project it prints the project's report. Elsewhere it says what the folder is and names the command that starts each task, and that command prints the next step ([10.1](10-cli.md#where-every-task-starts)).
|
|
44
|
+
|
|
37
45
|
### Use (import)
|
|
38
46
|
|
|
39
47
|
```bash
|
|
40
|
-
npm i -D @harnesspm/cli
|
|
41
48
|
npx -y @harnesspm/cli init
|
|
42
49
|
```
|
|
43
50
|
|
|
44
|
-
Every full install, such as `npm install` or `pnpm install`, then runs `harnesspm sync`. It finds the harness of each dependency, follows `extends` chains, applies the project's changes, and writes each agent's native files. The project commits the generated block in `AGENTS.md` and `harnesspm.lock.json`, so upgrades show up in pull requests.
|
|
51
|
+
`init` installs `@harnesspm/cli` as a dev dependency, then sets the project up. Every full install, such as `npm install` or `pnpm install`, then runs `harnesspm sync`. It finds the harness of each dependency, follows `extends` chains, applies the project's changes, and writes each agent's native files. The project commits the generated block in `AGENTS.md` and `harnesspm.lock.json`, so upgrades show up in pull requests.
|
|
45
52
|
|
|
46
53
|
### Add on top
|
|
47
54
|
|
|
@@ -120,7 +127,7 @@ Every feature serves at least one of these. Each must take as few steps as possi
|
|
|
120
127
|
| --- | --- | --- |
|
|
121
128
|
| S1 | A library shares its harness | Adds `harness/` and lists it in `files`. |
|
|
122
129
|
| S2 | A library builds on upstream harness | Lists the upstream packages in `extends`, adds its own units. |
|
|
123
|
-
| S3 | A project uses the harness of its dependencies | `
|
|
130
|
+
| S3 | A project uses the harness of its dependencies | `npx -y @harnesspm/cli init`, once. It installs harnesspm, and its report says what to commit and what waits for the person. |
|
|
124
131
|
| S4 | A project changes one upstream rule | One `patch` for a few sections, or one `replace` or `exclude` entry. |
|
|
125
132
|
| S5 | A project upgrades a dependency | Nothing after a full install. After `npm install <pkg>` or `pnpm add`, `npx -y @harnesspm/cli sync`. The pull request shows what changed. |
|
|
126
133
|
| S6 | Several repositories share a policy | A harness-only package, added as a dev dependency. |
|
|
@@ -133,12 +140,12 @@ Every feature serves at least one of these. Each must take as few steps as possi
|
|
|
133
140
|
| S13 | A job reads the harness without an install, such as a review bot | `npx -y @harnesspm/cli fetch`. |
|
|
134
141
|
| S14 | A team sees how agents use its harnesses | `telemetry` in `harnesspm.json` with a handler, then `npx -y @harnesspm/cli sync`. |
|
|
135
142
|
| S15 | An agent finds a harness unit that is wrong, missing or failing | Nothing in harnesspm. The project's own rule tells agents where to report, and `harnesspm why` gives the details. |
|
|
136
|
-
| S16 | A person checks that a repository is ready for a harness of their own, and that no per-machine file can reach a commit | `npx -y @harnesspm/cli doctor
|
|
143
|
+
| S16 | A person checks that a repository is ready for a harness of their own, and that no per-machine file can reach a commit | `npx -y @harnesspm/cli doctor`, or the bare command in a project, which prints the same report. |
|
|
137
144
|
| S17 | A teammate's merged change adds a hook, an MCP server or an allow rule | Nothing. The next install writes it on every machine, also when an agent runs the install. |
|
|
138
145
|
| S18 | An agent clones the repositories its task needs, such as into `work/app`, and uses their harnesses from its own folder | Nothing in the cloning repository. The block commands in the clone's `AGENTS.md` say how: `npx -y @harnesspm/cli -C work/app help` lists its packages, `-C work/app help <package>` prints one, and `-C work/app run <unit>` runs a tool, also before the clone is installed. Hooks of the clone run there only after a `sync` in that folder (S20). |
|
|
139
146
|
| S19 | A repository has many harness packages or workspaces, and its `AGENTS.md` must stay inside the agents' limits | Nothing. The managed block names each rule and tool in one line. Agents print a package's rules with `help <package>` and a tool's options with `help <tool>`. |
|
|
140
147
|
| S20 | A session starts in a folder above several repositories, such as a Claude Code cloud session with more than one, a person's folder of clones, or a job runner's work folder | `npx -y @harnesspm/cli sync` in that folder, after the installs: in the environment's setup script, once on a person's machine, or in the runner's checkout step. Each repository's hooks run there, and a block in that folder's `AGENTS.md` names each repository and its `help` command. A later sync of a repository keeps its entries there current. The `SessionStart` hook of an added harness syncs that folder too, so each repository gets its project entry. |
|
|
141
|
-
| S21 | An agent looks for a dependency's docs with its search tool, not through the block |
|
|
148
|
+
| S21 | An agent looks for a dependency's docs with its search tool, not through the block | Nothing: `init` adds one `/.harnesspm/` line to `.gitignore`, so formatters skip the copies. `sync` and `fetch` copy every dependency's docs into `.harnesspm/docs/`, and a `.rgignore` that git ignores lets search tools in. |
|
|
142
149
|
|
|
143
150
|
## 1.7 What is committed
|
|
144
151
|
|
|
@@ -146,4 +153,4 @@ Every feature serves at least one of these. Each must take as few steps as possi
|
|
|
146
153
|
| --- | --- |
|
|
147
154
|
| `harnesspm.json`, `harnesspm.lock.json`, the managed blocks in `AGENTS.md`, the `@AGENTS.md` lines in `CLAUDE.md` files (at the root and next to each nested `AGENTS.md`) | Everything else: links, docs copies, agent settings, `.codex/`, outputs of added harnesses |
|
|
148
155
|
|
|
149
|
-
Committed files depend only on the dependency and project layers, so every teammate and CI produce the same result.
|
|
156
|
+
Committed files depend only on the dependency and project layers, so every teammate and CI produce the same result. Only `init` edits `.gitignore`: it adds the one line `/.harnesspm/` when no `.gitignore` ignores that folder, and `.gitignore` is then among the files to commit. `sync` never edits it, and warns while the line is missing.
|
package/docs/spec/04-outputs.md
CHANGED
|
@@ -14,7 +14,7 @@ Package authors do not need this chapter. It defines what implementations write.
|
|
|
14
14
|
|
|
15
15
|
1. **Native files only.** No agent has to understand a harnesspm format.
|
|
16
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.
|
|
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. Only `init` edits `.gitignore`, with one line for the docs copies (note 8 in [4.3](#43-project-outputs)). `harnesspm doctor` checks that every per-machine file is ignored and untracked ([10.5](10-cli.md#105-the-report)). 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
18
|
4. **Units of added harnesses never enter a tracked file.** harnesspm MUST refuse to write one there.
|
|
19
19
|
5. **Outputs are marked.** Each generated file or block says it is generated and names the sources to edit.
|
|
20
20
|
6. **harnesspm edits only its own entries** in files that people or agents also write, and keeps the rest unchanged.
|
|
@@ -27,6 +27,8 @@ Package managers place packages at paths that differ between machines. harnesspm
|
|
|
27
27
|
node_modules/.harnesspm/pkgs/@tenphi/tasty → <real location of the package>
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
`sync` and `fetch` remove a link there that they no longer write, such as one for a dependency the project dropped or for a package's earlier name. Anything there that is not a link stays.
|
|
31
|
+
|
|
30
32
|
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
33
|
|
|
32
34
|
## 4.3 Project outputs
|
|
@@ -56,7 +58,7 @@ Notes:
|
|
|
56
58
|
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
59
|
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
60
|
- 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,
|
|
61
|
+
- 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 `init` adds `/.harnesspm/` to the `.gitignore` of the project folder, and `sync` warns until a `.gitignore` in the repository ignores the folder, naming 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
62
|
- `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
63
|
- A sync removes the copies that harnesspm 0.13 wrote in `node_modules/.harnesspm/docs/`.
|
|
62
64
|
- 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`.
|
|
@@ -131,7 +133,7 @@ The commands use `npx -y @harnesspm/cli` in every block. Inside the project, npx
|
|
|
131
133
|
|
|
132
134
|
Every heading and line of a unit carries its ID, so an agent can find the source with `harnesspm why`.
|
|
133
135
|
|
|
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. `
|
|
136
|
+
**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. The report of `status` and `doctor` warns when a committed block starts past the first 30 lines of its file.
|
|
135
137
|
|
|
136
138
|
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
139
|
|
|
@@ -150,11 +152,11 @@ Both agents have plugin systems. harnesspm does not generate plugins in v1, beca
|
|
|
150
152
|
| Codex | `AGENTS.md` files are joined up to `project_doc_max_bytes`, 32 KiB by default. The rest is cut off. |
|
|
151
153
|
| Claude Code | No hard limit. The vendor advises under about 200 lines per `CLAUDE.md`. |
|
|
152
154
|
|
|
153
|
-
`
|
|
155
|
+
The report of `status` and `doctor` gives the always-on size per agent, and warns under Outputs when `AGENTS.md` is close to or over 32 KiB, because Codex then reads only its first 32 KiB.
|
|
154
156
|
|
|
155
157
|
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
158
|
|
|
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
|
|
159
|
+
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 the report also names 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
160
|
|
|
159
161
|
- a root block after long hand-written text;
|
|
160
162
|
- a workspace block below a long root `AGENTS.md`;
|
package/docs/spec/06-trust.md
CHANGED
|
@@ -55,7 +55,7 @@ Rules:
|
|
|
55
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
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
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
|
|
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, under "Waiting for a person". When the repository is in its reviewed state but this machine lacks entries, they say under Outputs that a sync writes them: that is not a person's step. Outside a cloud session, they name the person's step: `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
59
|
|
|
60
60
|
## 6.3 The lock
|
|
61
61
|
|
package/docs/spec/07-added.md
CHANGED
|
@@ -95,7 +95,7 @@ Both files have one field:
|
|
|
95
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
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
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.
|
|
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 hook under the earlier name runs the earlier package, which cannot do this, so a person runs `npx -y @harnesspm/cli update` once on each machine. A run of the agent's model leaves it, because the new command also fetches.
|
|
99
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
100
|
- Codex asks the person to review a new hook once, in `/hooks`.
|
|
101
101
|
- `--no-hook` skips the hook. Project entries then apply only where `harnesspm sync` runs, and new commits only when you run `update`.
|
|
@@ -103,7 +103,7 @@ Both files have one field:
|
|
|
103
103
|
|
|
104
104
|
## 7.6 Keeping the project clean
|
|
105
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-
|
|
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-the-report)).
|
|
107
107
|
2. CI ignores added harnesses. With `CI=true`, `sync` writes only per-machine outputs ([06-trust.md](06-trust.md#64-ci)).
|
|
108
108
|
3. `harnesspm status` lists every change that an added harness makes to the repository's units, so it stays visible.
|
|
109
109
|
4. In a cloud environment shared by several people, add harnesses in your own environment. See [09-cloud.md](09-cloud.md).
|
package/docs/spec/09-cloud.md
CHANGED
|
@@ -19,7 +19,7 @@ cd /home/user/<repo> && npm ci
|
|
|
19
19
|
- **Several repositories.** A session with more than one repository starts in `/home/user`, above the clones, and reads no settings from them ([research](https://github.com/tenphi/harnesspm/blob/main/docs/research/agent-capabilities.md#cloud-sessions)). After the installs, add `cd /home/user && npx -y @harnesspm/cli sync || true`. It writes each repository's hooks and a pointer block for sessions that start there ([4.10](04-outputs.md#410-sessions-that-start-in-a-parent-folder)). A session with one repository starts in its clone and runs that clone's own hooks. Claude Code also reads the `CLAUDE.md` files above its start folder, so it sees the block, which names the repositories next to it. The hook of an added harness applies its project entries in each clone too: the session reads their rules (`CLAUDE.local.md`) and skills, but not their hooks and permissions, which only a one-repository session gets.
|
|
20
20
|
- **In every person's environment.** Environments are personal unless an organization Owner shares one. A team commits its script and gives people the lines to paste.
|
|
21
21
|
|
|
22
|
-
The install runs as a person's would, before Claude Code starts, so nothing is held back, and its hooks work from the first session ([9.5](#95-what-real-sessions-confirmed)). To check, `harnesspm status` in a new session
|
|
22
|
+
The install runs as a person's would, before Claude Code starts, so nothing is held back, and its hooks work from the first session ([9.5](#95-what-real-sessions-confirmed)). To check, `harnesspm status` in a new session lists no entries that an agent cannot grant.
|
|
23
23
|
|
|
24
24
|
A later install by the agent, such as after a pull, writes what the default branch records only when the clone has `origin/HEAD` ([06-trust.md](06-trust.md#62-trusting-a-package), rule 4). The cloud clones seen so far had none ([research](https://github.com/tenphi/harnesspm/blob/main/docs/research/agent-capabilities.md#cloud-sessions)). The setup script can set it without network: `git -C /home/user/<repo> remote set-head origin main || true`, with the repository's default branch.
|
|
25
25
|
|