@harnesspm/cli 0.17.0 → 0.18.1

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.18.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#95](https://github.com/tenphi/harnesspm/pull/95) [`92e4db0`](https://github.com/tenphi/harnesspm/commit/92e4db0e406306c90fbfb3fb153b6ca9b84936d3) Thanks [@tenphi](https://github.com/tenphi)! - In a Claude Code cloud session, the step that turns on a package's tools now says why it differs: the session gives the person no terminal, so the environment's setup script grants it before each new session. `init`'s report there asks the person to commit the trust change and to add the project's install to the setup script, without the unrelated `add <source>`.
8
+
9
+ ## 0.18.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#93](https://github.com/tenphi/harnesspm/pull/93) [`11d3b41`](https://github.com/tenphi/harnesspm/commit/11d3b410a123425ff02e44bc1207d6453985ac44) Thanks [@tenphi](https://github.com/tenphi)! - Every task starts with one command. `npx -y @harnesspm/cli` in a folder that does not use harnesspm says what the folder is and names the command for each task; in a project it prints the project's report, which `status` and `doctor` now share (`doctor` still exits 1 when a check fails). `init` installs `@harnesspm/cli` as a dev dependency with the project's package manager (it stops on Yarn Plug'n'Play), adds `/.harnesspm/` to `.gitignore` once, and ends with a report: the tools that wait for the person's trust, with what each does and whether it runs without a prompt, the files to commit and the check for CI. Every step for a person is now `approve`, listed under one "Waiting for a person" heading in `sync`, `init` and the report. `help` in a project leads with its packages and marks tools that run without a prompt, `--help` lists every command, and `new` names the next step for the folder: publishing a library's harness, or adding a harness of your own.
14
+
3
15
  ## 0.17.0
4
16
 
5
17
  ### Minor Changes
package/README.md CHANGED
@@ -11,7 +11,7 @@ A **harness** is everything a coding agent needs to use a library well: rules, d
11
11
  | Flow | Who | What they do |
12
12
  | --- | --- | --- |
13
13
  | 📤 **Share** | A library | Adds a `harness/` folder to its npm package. It can pass on the harness of the libraries it builds on (`extends`). |
14
- | 📥 **Use** | A project | `npm i -D @harnesspm/cli` and `npx -y @harnesspm/cli init`. After every install, Claude Code and Codex see the harness of the installed versions. |
14
+ | 📥 **Use** | A project | `npx -y @harnesspm/cli init`. After every install, Claude Code and Codex see the harness of the installed versions. |
15
15
  | ➕ **Add on top** | A person | `npx -y @harnesspm/cli add github:me/harness`. A team's or their own workflow, context and tools apply on top, without changing the project's repository. |
16
16
  | 🛠️ **Improve** | An agent | `npx -y @harnesspm/cli why <unit>` finds the source. The agent edits it and saves the change the way the owner's rules say, by default with a pull request. |
17
17
 
@@ -25,24 +25,27 @@ added (harnesses you add: your team's, your own) → per-machine fi
25
25
 
26
26
  ## Quick start
27
27
 
28
+ Every task starts with one command. In any folder, it says what the folder is and names the command for each task:
29
+
30
+ ```bash
31
+ npx -y @harnesspm/cli
32
+ ```
33
+
28
34
  In a project:
29
35
 
30
36
  ```bash
31
- npm i -D @harnesspm/cli
32
37
  npx -y @harnesspm/cli init
33
38
  ```
34
39
 
35
- `init` creates `harnesspm.json` and runs `harnesspm sync` after every full install. Commit `AGENTS.md`, `CLAUDE.md`, `harnesspm.json` and `harnesspm.lock.json`. Or ask your agent to do it: [Get started](https://harnesspm.tenphi.me/guides/setup/) has the prompt.
40
+ `init` installs harnesspm as a dev dependency, creates `harnesspm.json` and runs `harnesspm sync` after every full install. Commit what it lists. Or ask your agent: "Run `npx -y @harnesspm/cli init` in this project and do what it prints." [Get started](https://harnesspm.tenphi.me/guides/setup/) has every step.
36
41
 
37
42
  In a library, to share its harness:
38
43
 
39
44
  ```bash
40
- npm i -D @harnesspm/cli
41
45
  npx -y @harnesspm/cli new rule usage
42
- npx -y @harnesspm/cli check
43
46
  ```
44
47
 
45
- Add `"harness"` to the `files` field of `package.json`. [Share a harness from your library](https://harnesspm.tenphi.me/guides/share/) has the prompt for your agent. To add your own or your team's harness on top of every repository on your machine:
48
+ It prints the next steps: `check`, and what goes into `package.json` to publish the harness. [Share a harness from your library](https://harnesspm.tenphi.me/guides/share/) has every step. To add your own or your team's harness on top of every repository on your machine:
46
49
 
47
50
  ```bash
48
51
  npx -y @harnesspm/cli add github:<owner>/<repo>
@@ -50,7 +53,7 @@ npx -y @harnesspm/cli add github:<owner>/<repo>
50
53
 
51
54
  To see how agents use the harness, a team can turn on telemetry in `harnesspm.json`. It is off by default, sends events only to the team's own handler (a command or a file), and never sends arguments or file contents. See [chapter 14](docs/spec/14-telemetry.md).
52
55
 
53
- `npx -y @harnesspm/cli help` lists every command, and `npx -y @harnesspm/cli <command> --help` shows one. [CHANGELOG.md](CHANGELOG.md) lists the changes.
56
+ `npx -y @harnesspm/cli --help` lists every command, and `npx -y @harnesspm/cli <command> --help` shows one. [CHANGELOG.md](CHANGELOG.md) lists the changes.
54
57
 
55
58
  ## Requirements
56
59
 
package/dist/cli.js CHANGED
@@ -19,25 +19,27 @@ async function main() {
19
19
  }
20
20
  const HELP = `harnesspm — the harness package manager
21
21
 
22
- Usage: harnesspm [-C <dir>] <command>
22
+ Usage: npx -y @harnesspm/cli [-C <dir>] [<command>]
23
+ harnesspm where to start: the tasks for this folder, or this project's report
23
24
  -C <dir> act on the project in <dir>, such as a repository you cloned. \`run\` keeps
24
25
  the current folder for the script, so file arguments stay valid
25
- harnesspm help these commands, and the project's packages, one line each
26
+ harnesspm help the project's packages, one line each; outside a project, these commands
26
27
  harnesspm help <package | rule ID | tool>
27
28
  a package's rules, docs, tools, MCP servers, skills and hooks in full,
28
29
  one rule, or a tool's usage and run command. Needs no install
29
30
 
30
31
  Projects
31
- harnesspm init set up harnesspm in this project
32
+ harnesspm init set up harnesspm in this project: install it, write its files and sync
32
33
  harnesspm sync [--check | --write]
33
34
  write the agent files (--check: compare only, for CI;
34
35
  --write: committed files too when CI=true)
35
- harnesspm status layers, packages and always-on size
36
- harnesspm doctor check that local files stay out of git and the outputs are in place
36
+ harnesspm status the project's report: packages, checks, and what waits for a person
37
+ harnesspm doctor the same report, which exits 1 when a check fails
37
38
  harnesspm why <ID> where a unit comes from and how to change it
38
39
  harnesspm run <plugin>:<script> [-- args]
39
40
  run a script of a trusted package
40
- harnesspm approve [<package>] approve a "pin" package's new version, and write what an agent could not
41
+ harnesspm approve [<package>] a person's step: write what an agent could not grant, and approve
42
+ a "pin" package's new version
41
43
  harnesspm fetch download the harness packages in the lock, for jobs without an install
42
44
 
43
45
  Harnesses on top of the repository's (your team's, your own)
@@ -56,7 +58,7 @@ Authors
56
58
  /** Details for a command whose usage line is not enough. */
57
59
  const DETAILS = {
58
60
  new: `Kinds: rule, skill, agent, script, hook, mcp. \`new patch\` takes a rule ID, such as acme-ui:rules/usage.
59
- --to <plugin> write into a harness you added (\`harnesspm status\` lists them), not the project's own harness/
61
+ --to <plugin> write into a harness you added (\`npx -y @harnesspm/cli status\` lists them), not the project's own harness/
60
62
  --entry with --to: write into that harness's entry for this repository`,
61
63
  };
62
64
  /** Help for one command: its lines in HELP and its details. Undefined for a word that is not a command. */
@@ -76,7 +78,7 @@ function commandHelp(command) {
76
78
  if (picked.length === 0)
77
79
  return undefined;
78
80
  const details = DETAILS[command];
79
- return [...picked, ...(details !== undefined ? ['', details] : []), '', 'Every command: harnesspm help. Every option: https://harnesspm.tenphi.me/reference/cli/'].join('\n');
81
+ return [...picked, ...(details !== undefined ? ['', details] : []), '', 'Every command: npx -y @harnesspm/cli --help. Every option: https://harnesspm.tenphi.me/reference/cli/'].join('\n');
80
82
  }
81
83
  const out = {
82
84
  log: (line) => console.log(line),
@@ -97,7 +99,7 @@ function projectFolder(argv) {
97
99
  throw new HarnessError(`-C ${dir}: no such folder`);
98
100
  return { cwd, named: true, argv: argv.slice(2) };
99
101
  }
100
- function dispatch(argvIn, { add, approve, check, doctor, fetch, init, mcp, newUnit, projectHelp, remove, run, status, sync, targetHelp, update, why }) {
102
+ function dispatch(argvIn, { add, approve, check, doctor, fetch, init, mcp, newUnit, notAProject, projectHelp, remove, run, start, status, sync, targetHelp, update, why }) {
101
103
  const { cwd, named, argv } = projectFolder(argvIn);
102
104
  const [command, ...rest] = argv;
103
105
  const isHelp = (arg) => arg === '--help' || arg === '-h';
@@ -186,11 +188,15 @@ function dispatch(argvIn, { add, approve, check, doctor, fetch, init, mcp, newUn
186
188
  console.log(pkg.version);
187
189
  return 0;
188
190
  }
189
- case 'help':
190
191
  case undefined:
192
+ // Every task starts here: the project's report, or the tasks for this folder (spec 10.1).
193
+ return start(cwd, out);
191
194
  case '--help':
192
195
  case '-h':
193
- if (command === 'help' && args[0] !== undefined) {
196
+ console.log(HELP.trimEnd());
197
+ return 0;
198
+ case 'help': {
199
+ if (args[0] !== undefined) {
194
200
  // A command first, then a package, rule or tool of the project (spec 10.1).
195
201
  const text = commandHelp(args[0]);
196
202
  if (text !== undefined) {
@@ -199,11 +205,17 @@ function dispatch(argvIn, { add, approve, check, doctor, fetch, init, mcp, newUn
199
205
  }
200
206
  return targetHelp(cwd, args[0], out);
201
207
  }
208
+ // Inside a project, or with -C, the project's packages lead. Elsewhere, the commands.
209
+ const code = projectHelp(cwd, out);
210
+ if (code !== undefined)
211
+ return code;
202
212
  console.log(HELP.trimEnd());
203
- // Inside a project, or with -C, the project's own harness follows.
204
- return projectHelp(cwd, out, named);
213
+ if (named)
214
+ console.log(`\n${notAProject(cwd)}`);
215
+ return 0;
216
+ }
205
217
  default:
206
- throw new HarnessError(`Unknown command "${command}". Run \`harnesspm help\`.`);
218
+ throw new HarnessError(`Unknown command "${command}". Every command: \`npx -y @harnesspm/cli --help\`.`);
207
219
  }
208
220
  }
209
221
  // Agent hooks call `harnesspm track` on every matching tool call, so it loads only what it needs (spec 14.4). A hook in a
@@ -13,6 +13,11 @@ export declare function sync(cwd: string, out: Output, options?: {
13
13
  write?: boolean;
14
14
  quiet?: boolean;
15
15
  }): number;
16
+ /**
17
+ * `harnesspm init` (spec 10.1): installs harnesspm when the project does not list it, writes the configuration, the
18
+ * install hook, the import in CLAUDE.md and the `.gitignore` line, syncs, and reports what waits for a person and what
19
+ * to commit.
20
+ */
16
21
  export declare function init(projectDir: string, out: Output): number;
17
22
  export declare function add(cwd: string, spec: string, out: Output, options?: {
18
23
  local?: boolean;
@@ -27,22 +32,27 @@ export declare function remove(cwd: string, spec: string, out: Output, options?:
27
32
  * prompts and a slow fetch is stopped.
28
33
  */
29
34
  export declare function update(cwd: string, out: Output): number;
35
+ /** `harnesspm status`: the project's report (spec 10.5). It always exits 0. */
30
36
  export declare function status(cwd: string, out: Output): number;
37
+ /** `harnesspm doctor`: the same report, which exits 1 when a check fails; what waits for a person does not fail. */
38
+ export declare function doctor(cwd: string, out: Output): number;
31
39
  /**
32
- * `harnesspm doctor`: whether this repository is ready for harnesses, its own and a person's (spec 10.1).
33
- * It changes nothing. Exits 1 when a check fails; warnings do not fail.
40
+ * The bare command (spec 10.1): in a project that uses harnesspm, its report; elsewhere, what the folder is and the
41
+ * tasks for it, each with the one command that starts it.
34
42
  */
35
- export declare function doctor(cwd: string, out: Output): number;
43
+ export declare function start(cwd: string, out: Output): number;
36
44
  export declare function why(cwd: string, id: string, out: Output): number;
37
45
  /** The command that runs the project's tools from where harnesspm started: with `-C` from outside it (spec 10.1). */
38
46
  export declare function toolCommand(projectDir: string): string;
39
47
  export declare function run(cwd: string, ref: string, args: string[], agent: string | undefined): Promise<number>;
40
48
  export declare function mcp(cwd: string, ref: string, agent: string | undefined): number;
41
49
  /**
42
- * The project's part of `help` (spec 10.1): one line per package, across workspaces, with what it covers and the
43
- * `help <package>` command that prints the rest.
50
+ * `help` in a project (spec 10.1): one line per package, across workspaces, with what it covers and the
51
+ * `help <package>` command that prints the rest. Undefined outside a project that uses harnesspm.
44
52
  */
45
- export declare function projectHelp(cwd: string, out: Output, named: boolean): number;
53
+ export declare function projectHelp(cwd: string, out: Output): number | undefined;
54
+ /** Where `help` says that a folder named with `-C` does not use harnesspm. */
55
+ export declare function notAProject(cwd: string): string;
46
56
  /**
47
57
  * `help <target>`: a package or plugin, a rule ID, or a tool by `<plugin>:<script>` or its ID (spec 10.1). It works
48
58
  * without an install, like `help`, and sends a `help` event (spec 14.2).