@harnessforce/claude-code-plugin 0.1.0 → 0.3.0
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/.claude-plugin/plugin.json +1 -1
- package/README.md +53 -15
- package/commands/help.md +31 -0
- package/commands/import.md +18 -0
- package/commands/run.md +25 -0
- package/commands/setup.md +30 -50
- package/commands/status.md +26 -0
- package/commands/tune.md +18 -18
- package/hooks/hooks.json +45 -1
- package/package.json +1 -1
- package/scripts/harnessforce-hook-main.cjs +703 -204
- package/scripts/harnessforce-hook.cjs +2 -1
- package/skills/propose-improvements/SKILL.md +69 -69
- package/skills/propose-improvements/scripts/summarize.mjs +59 -57
- package/skills/record-run/SKILL.md +14 -51
- package/skills/using-harnessforce/SKILL.md +34 -32
package/README.md
CHANGED
|
@@ -11,12 +11,17 @@ and does not bundle the CLI (`/harnessforce:setup` installs `@harnessforce/cli`
|
|
|
11
11
|
| Part | Purpose |
|
|
12
12
|
| --- | --- |
|
|
13
13
|
| `SessionStart` and `UserPromptSubmit` hooks | Register each session and its config snapshot with Harnessforce |
|
|
14
|
+
| `CwdChanged`, `Stop` and `PostToolUse` (`Write` and `Edit`) hooks | Record the repository and branch of the Git working trees a session works in, and send them at the end of a turn in which they changed |
|
|
14
15
|
| `PostToolUse`, `PostToolUseFailure`, `UserPromptExpansion`, `PermissionRequest`, `PostCompact` and `SessionEnd` hooks | Count the configured skills, commands, subagents and MCP servers a session uses, and send the session usage summary |
|
|
15
|
-
| MCP server `harnessforce` (`<connection URL>/mcp`, HTTP) | Tools to start a run, read an Issue, and
|
|
16
|
+
| MCP server `harnessforce` (`<connection URL>/mcp`, HTTP) | Tools to start a run, read an Issue, and complete a run |
|
|
16
17
|
| Skill `using-harnessforce` | What Harnessforce records and does not collect, which hook sends what, and when to use the other skills. The `SessionStart` hook injects its body into the context of every session (the build embeds the same text into the hook and the CLI) |
|
|
17
|
-
| Skill `record-run` | Tells the agent when to
|
|
18
|
-
| Command `/harnessforce:setup` | Checks Node.js, installs the `harnessforce` CLI, asks whether to send content, runs `harnessforce init` (`--send-content` when chosen) and `harnessforce import`,
|
|
18
|
+
| Skill `record-run` | Tells the agent when to start and complete a run |
|
|
19
|
+
| Command `/harnessforce:setup` | Checks Node.js, installs the `harnessforce` CLI, asks whether to send content, runs `harnessforce init` (`--send-content` when chosen) and `harnessforce import`, and confirms the first event after a restart |
|
|
19
20
|
| Command `/harnessforce:tune` | Tells you that the agent reads parts of your transcripts through your model provider, runs `harnessforce tune --json`, shows the analysis and the before and after of earlier applied proposals, and makes proposals for the targets with enough data |
|
|
21
|
+
| Command `/harnessforce:status` | Runs `harnessforce top --once --json` and summarizes the sessions on this machine. Read-only |
|
|
22
|
+
| Command `/harnessforce:import` | Runs `harnessforce import` and shows the imported count and why sessions were skipped |
|
|
23
|
+
| Command `/harnessforce:run <issue>` | Shows how to start an agent on an Issue with `harnessforce run --issue <issue> -- <agent>` in a terminal, and how `HARNESSFORCE_ISSUE` ties a session to an Issue. Runs nothing |
|
|
24
|
+
| Command `/harnessforce:help` | Lists the CLI commands (`harnessforce --help`) and these commands, and says which ones are not wrapped (`init`, the interactive `top`) |
|
|
20
25
|
| Skill `propose-improvements` | How the agent writes a proposal (evidence, diff or pull request draft, expected effect, how to measure), keeps permissions minimal and loops bounded, and records it with `harnessforce tune record` before showing it |
|
|
21
26
|
|
|
22
27
|
The hooks and the MCP server exist only in the build output, because their scripts and connection URL
|
|
@@ -25,7 +30,8 @@ come from the build. The copy of the plugin in this repository has no hooks and
|
|
|
25
30
|
|
|
26
31
|
## Install
|
|
27
32
|
|
|
28
|
-
|
|
33
|
+
The marketplace installs the plugin from npm, with no version pinned, so you get the latest
|
|
34
|
+
published version:
|
|
29
35
|
|
|
30
36
|
```text
|
|
31
37
|
/plugin marketplace add lambda-script/harnessforce-agent
|
|
@@ -33,7 +39,8 @@ Public distribution starts once the production domain of Harnessforce is decided
|
|
|
33
39
|
/harnessforce:setup
|
|
34
40
|
```
|
|
35
41
|
|
|
36
|
-
|
|
42
|
+
To connect to a staging or local `apps/web` instead, install the
|
|
43
|
+
[local marketplace build](../../docs/runbooks/local-marketplace.md).
|
|
37
44
|
|
|
38
45
|
## Requirements
|
|
39
46
|
|
|
@@ -44,20 +51,33 @@ continues without sending anything.
|
|
|
44
51
|
|
|
45
52
|
When a hook cannot send, it shows one line in the session instead of staying silent: Node.js older than 18,
|
|
46
53
|
a failed restart of the hook process, sending not set up (`/harnessforce:setup`), an endpoint that is set
|
|
47
|
-
but not allowed,
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
but not allowed, no ingest key in the keychain (for example after a reboot cleared the kernel keyring), a
|
|
55
|
+
destination that differs from the one `harnessforce init` saved, the Claude Code telemetry settings that
|
|
56
|
+
`harnessforce init` wrote missing from the user settings, a keychain that could not be read, and a session
|
|
57
|
+
registration that failed with anything other than 401. The line appears only at a session start that
|
|
58
|
+
registers (`startup`, `clear`, `fork`), except for the two startup failures, which appear at every session
|
|
59
|
+
start. Nothing is shown while sending works, and nothing is checked again later in the session. When
|
|
60
|
+
`harnessforce` is not on `PATH`, the hook shows nothing: Claude Code reports that `otelHeadersHelper` failed.
|
|
61
|
+
|
|
62
|
+
## Updates
|
|
63
|
+
|
|
64
|
+
The hooks send `User-Agent: harnessforce-claude-code-plugin/<version>` and keep the update status the
|
|
65
|
+
server returns in `${CLAUDE_PLUGIN_DATA}/update-status.json`. When a session starts they show one line
|
|
66
|
+
for a newer version (once a day, and not while Claude Code updates the plugin automatically), for the
|
|
67
|
+
date a version stops sending after a security fix, or for an unsupported version. An unsupported version
|
|
68
|
+
sends nothing until you run `claude plugin update harnessforce@harnessforce-agent`; the session keeps
|
|
69
|
+
running. `harnessforce init` turns on automatic updates for the `harnessforce-agent` marketplace.
|
|
50
70
|
|
|
51
71
|
## Session registration hooks
|
|
52
72
|
|
|
53
73
|
The `harnessforce` plugin registers each Claude Code session with Harnessforce so that runs can be
|
|
54
74
|
linked to issues. On `SessionStart` (`startup`, `clear`, `fork`) it sends the session ID and the git
|
|
55
75
|
repository, branch and commit of `cwd` to `POST <HARNESSFORCE_ENDPOINT>/v1/sessions`. On the first
|
|
56
|
-
prompt it sends the same registration again with the prompt ID.
|
|
57
|
-
contents are
|
|
76
|
+
prompt it sends the same registration again with the prompt ID. The hook never sends prompts,
|
|
77
|
+
responses or file contents; they are sent only through the OTel settings you choose.
|
|
58
78
|
|
|
59
|
-
- For an organization, set `HARNESSFORCE_ENDPOINT` (the ingest base URL
|
|
60
|
-
|
|
79
|
+
- For an organization, set `HARNESSFORCE_ENDPOINT` (the ingest base URL, `https:`) and
|
|
80
|
+
`HARNESSFORCE_INGEST_KEY` (a Workspace ingest key) in
|
|
61
81
|
the `env` of the managed settings file (`managed-settings.json` or `managed-settings.d/*.json` in
|
|
62
82
|
the managed directory). The hook reads the Workspace key and its endpoint only from those files,
|
|
63
83
|
never from the process environment, because a repository's `.claude/settings.json` can set
|
|
@@ -72,8 +92,24 @@ contents are never sent.
|
|
|
72
92
|
configuration, on errors, or after 2 seconds it gives up quietly and writes the reason to stderr
|
|
73
93
|
(Claude Code's debug log). Without Node.js, Claude Code shows a non-blocking `hook error`.
|
|
74
94
|
- If the key is revoked, Claude Code shows once per session:
|
|
75
|
-
|
|
76
|
-
|
|
95
|
+
"The organization's ingest key has been revoked. Contact a Workspace administrator" (Workspace key) or
|
|
96
|
+
"Your ingest key has been revoked. Run `harnessforce init`" (user key)
|
|
97
|
+
|
|
98
|
+
## Work location hooks
|
|
99
|
+
|
|
100
|
+
A session often starts in the repository's main checkout and then works in a worktree or on a new
|
|
101
|
+
branch. To link such runs to their pull requests, the plugin records the repository and branch of
|
|
102
|
+
each Git working tree the session works in, at the time it observes it: the new working directory on
|
|
103
|
+
`CwdChanged`, the directory of the file on `PostToolUse` of `Write` and `Edit`, and `cwd` on `Stop`.
|
|
104
|
+
At the end of each turn (`Stop`), when these pairs differ from the pairs sent last, it sends them to
|
|
105
|
+
`POST <HARNESSFORCE_ENDPOINT>/v1/sessions/locations`.
|
|
106
|
+
|
|
107
|
+
- It sends only the agent, the session ID and up to 10 pairs of repository and branch. Paths,
|
|
108
|
+
commits, file names and the content of edits are never sent. The record lives in
|
|
109
|
+
`scratchpad_dir` (`locations-<session_id>.json`); without `scratchpad_dir` nothing is recorded.
|
|
110
|
+
- The hooks run asynchronously and never delay a turn. A failure writes
|
|
111
|
+
`harnessforce: session location failed (<reason>)` to stderr and is retried at the next turn; after a
|
|
112
|
+
`401` the session stops sending. `CwdChanged` writes nothing to stderr.
|
|
77
113
|
|
|
78
114
|
## Config snapshot
|
|
79
115
|
|
|
@@ -89,7 +125,9 @@ an identifier, plus a SHA-256 hash:
|
|
|
89
125
|
- The same kinds of component from enabled marketplace plugins in the plugin cache.
|
|
90
126
|
|
|
91
127
|
File contents, settings values and MCP server configuration (URLs, headers, environment) are never
|
|
92
|
-
sent, only their hashes.
|
|
128
|
+
sent, only their hashes. The hashes of hooks and MCP servers leave out the values that can carry
|
|
129
|
+
credentials: `env` and `headers` values, `args`, and the userinfo, query and fragment of URLs, so a
|
|
130
|
+
hash cannot be brute-forced back to a short secret. Nothing is sent when there are no components, and the snapshot is skipped
|
|
93
131
|
when collection takes over 1 second or finds more than 1,000 components. The collector lives in
|
|
94
132
|
`packages/agent-core/src/config`, shared with `harnessforce run` so it can compute the same snapshot ID.
|
|
95
133
|
|
package/commands/help.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: List the harnessforce CLI commands and the /harnessforce:* commands, and say which one to use for what
|
|
3
|
+
disable-model-invocation: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Harnessforce help
|
|
7
|
+
|
|
8
|
+
Show the user this guide. To list the CLI commands with a one-line description each, run:
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
harnessforce --help
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
If the command is not found, tell the user to run `/harnessforce:setup`. `harnessforce <command> --help` shows what a command does, what it sends and does not send, and its exit codes.
|
|
15
|
+
|
|
16
|
+
## Commands in a session
|
|
17
|
+
|
|
18
|
+
| Command | What it does |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
| `/harnessforce:setup` | Installs the CLI, connects to Harnessforce with `harnessforce init`, imports past sessions and confirms the first event. |
|
|
21
|
+
| `/harnessforce:status` | Summarizes the sessions on this machine (read-only). |
|
|
22
|
+
| `/harnessforce:import` | Imports past sessions. |
|
|
23
|
+
| `/harnessforce:tune` | Analyzes your past sessions and proposes improvements. |
|
|
24
|
+
| `/harnessforce:run <issue>` | Shows how to start an agent on an Issue. |
|
|
25
|
+
|
|
26
|
+
## Not wrapped
|
|
27
|
+
|
|
28
|
+
- `harnessforce init` opens a browser to log in and takes up to 5 minutes, so it is not wrapped as its own command. `/harnessforce:setup` runs it for you.
|
|
29
|
+
- `harnessforce top` without `--once` is an interactive view that needs a terminal. Run it in a terminal.
|
|
30
|
+
- `harnessforce run` starts an agent as a new process. See `/harnessforce:run`.
|
|
31
|
+
- `harnessforce otel-headers` and `harnessforce hook` are run by the agents, not by you.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Import your past sessions on this machine into Harnessforce and report how many were imported and why others were skipped
|
|
3
|
+
disable-model-invocation: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Import past sessions
|
|
7
|
+
|
|
8
|
+
`harnessforce import` sends a summary of each past session of the repositories connected to your Workspace, inside the import window. It sends no prompt text, responses, tool inputs or results, or code. It is safe to run again, because sessions that were already sent are skipped.
|
|
9
|
+
|
|
10
|
+
Run it:
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
harnessforce import
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- If the command is not found, tell the user to run `/harnessforce:setup` and stop.
|
|
17
|
+
- If it reports that you are not logged in, tell the user to run `/harnessforce:setup` (it runs `harnessforce init`, which needs a browser) and stop.
|
|
18
|
+
- Show the imported count and the breakdown of skipped sessions with the next action, exactly as printed. Do not leave out the reason when nothing was imported.
|
package/commands/run.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Explain how to start an agent on a Harnessforce Issue with harnessforce run, because a session cannot start its own agent
|
|
3
|
+
argument-hint: "<issue-identifier>"
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Run an agent on an Issue
|
|
8
|
+
|
|
9
|
+
`harnessforce run` starts an agent for an Issue. It has to start that agent as a new process in a terminal, so this command cannot do it from inside a session. It runs nothing. It only shows the steps.
|
|
10
|
+
|
|
11
|
+
Take the Issue identifier from `$ARGUMENTS` (for example `ABC-123`). If it is empty, ask the user for it.
|
|
12
|
+
|
|
13
|
+
## Start the agent in a terminal
|
|
14
|
+
|
|
15
|
+
Tell the user to run this in a terminal, outside this session. Replace `claude` with the agent to start (for example `codex`).
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
harnessforce run --issue <identifier> -- claude
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Everything after `--` is passed to the agent unchanged. The agent's exit code becomes the exit code of `harnessforce run`. It needs `harnessforce init` to have been done; if not, run `/harnessforce:setup` first.
|
|
22
|
+
|
|
23
|
+
## Already in a session?
|
|
24
|
+
|
|
25
|
+
The plugin's hooks tie a session to an Issue when the environment variable `HARNESSFORCE_ISSUE` is set to the identifier before the agent starts. `harnessforce run` sets it for you. This session was started without it unless the user set it, and an environment variable cannot be added to a running session. To work on the Issue, start a new session as above.
|
package/commands/setup.md
CHANGED
|
@@ -1,83 +1,63 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Harnessforce
|
|
2
|
+
description: Harnessforce setup. Walks through checking Node.js, choosing whether to send session content, installing the CLI, running harnessforce init, importing past sessions, and confirming the first event after the restart
|
|
3
3
|
disable-model-invocation: true
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Harnessforce
|
|
6
|
+
# Harnessforce setup
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Go through the steps below in order, interacting with the user. If a command fails, show its output to the user and stop without moving on to the later steps.
|
|
9
9
|
|
|
10
|
-
## 1. Node.js
|
|
10
|
+
## 1. Check Node.js
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
First run `node --version`. If the command is not found, or the version is below 18, do not move on to installing the CLI. Show the following text as it is and stop.
|
|
13
13
|
|
|
14
|
-
>
|
|
14
|
+
> Harnessforce hooks require Node.js 18 or later. Install Node.js, restart Claude Code, then run `/harnessforce:setup` again.
|
|
15
15
|
|
|
16
|
-
## 2.
|
|
16
|
+
## 2. Check whether this run is after the restart
|
|
17
17
|
|
|
18
|
-
`harnessforce --version
|
|
18
|
+
If `harnessforce --version` succeeds and the environment variable `HARNESSFORCE_WORKSPACE_ID` of this session is not empty, this is a session restarted after `harnessforce init`. Skip steps 3 to 7 and go to step 8.
|
|
19
19
|
|
|
20
|
-
## 3. CLI
|
|
20
|
+
## 3. Install the CLI
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Run the following, then confirm the install with `harnessforce --version`.
|
|
23
23
|
|
|
24
24
|
```sh
|
|
25
25
|
npm install -g @harnessforce/cli
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
## 4.
|
|
28
|
+
## 4. Choose whether to send content
|
|
29
29
|
|
|
30
|
-
`harnessforce init
|
|
30
|
+
Before `harnessforce init`, present the option to send the content of the user's sessions, with "send" selected by default. The login is not done yet at this point, so neither the Workspace to connect nor what it stores is known. Do not change what you show depending on the Workspace; `harnessforce init` decides each category from the Workspace it connects, and writes `0` for a category the Workspace does not store.
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
Present the option together with the following.
|
|
33
33
|
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
34
|
+
- If selected, the prompts the user types, model responses, and tool input and output (including Bash commands and file paths) are delivered to this Workspace for the categories the Workspace stores. Secret patterns, email addresses, and phone numbers are replaced with `[REDACTED:kind]` before storing, and the content is deleted after the content retention period (30 days by default, at most 30 days). Secrets and personal information that do not match a pattern are not masked, and not everything can be detected. Who can read the stored content follows the Workspace setting (everyone in the Workspace by default); `harnessforce init` shows the setting of the Workspace it connects. The user can delete their own content from the account settings, and the sender, owners and admins can delete a session's content at any time.
|
|
35
|
+
- Content is stored only when both this setting on the device and the Workspace's storing of that category are in place. If the Workspace stops storing a category, later content is discarded on receipt.
|
|
36
|
+
- If selected, run `harnessforce init --send-content`; if not, run `harnessforce init` (step 5). Write this setting to the `env` of the Claude Code user settings, and do not write it to the `env` of the project (`.claude/settings.json`) or local (`.claude/settings.local.json`) files, because the content variables are ignored in the `env` of those two files. A restart is needed after `harnessforce init` for the setting to take effect.
|
|
37
|
+
- To stop afterwards, run `harnessforce init` again without `--send-content`. It rewrites the content variables to `0`.
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
Use the following option text as it is.
|
|
40
40
|
|
|
41
|
-
>
|
|
42
|
-
>
|
|
43
|
-
> You can send the prompts you type for analysis (off by default; it takes effect only if the workspace has opted in to prompts you typed). If enabled, the prompts you type to the agent are delivered to this workspace and stored. Values that match known patterns for secrets and personal information are replaced with `[REDACTED:kind]`, but not everything can be detected. Content is deleted after the content retention period (at most 30 days), and within the workspace only you can read it. You can delete it at any time from My practices. Enable this?
|
|
44
|
-
>
|
|
45
|
-
> 本文を送りません(既定)。後から設定できます
|
|
46
|
-
>
|
|
47
|
-
> Content is not sent (by default). You can enable it later.
|
|
41
|
+
> Send the content of your sessions (on by default). The prompts you type, model responses and tool input and output (including Bash commands and file paths) are delivered to this workspace and stored for the categories the workspace stores. Values that match known patterns for secrets and personal information are replaced with `[REDACTED:kind]`, but not everything can be detected. Content is deleted after the content retention period (30 days by default, at most 30 days). Who can read it follows the workspace setting (everyone in the workspace by default); `harnessforce init` shows the setting of the workspace you connect. You can delete your own content from your account settings, and the sender, owners and admins can delete a session's content at any time.
|
|
48
42
|
|
|
49
|
-
## 5. Harnessforce
|
|
43
|
+
## 5. Connect to Harnessforce
|
|
50
44
|
|
|
51
|
-
|
|
45
|
+
Follow the choice in step 4: run `harnessforce init --send-content` if selected, or `harnessforce init` if not. Tell the user to log in to Harnessforce in the browser and choose one Workspace to connect. If the browser does not open, show the user the URL that `harnessforce init` prints. The command waits up to 5 minutes for the login to complete, so run it with a Bash timeout of 10 minutes.
|
|
52
46
|
|
|
53
|
-
|
|
47
|
+
For a Workspace that stores no content, `harnessforce init --send-content` writes the content variables as `0`. It prints a message about that and about Collection & retention in the Workspace settings, and exits with code 0. Do not treat this as a failure; show the printed text to the user as it is.
|
|
54
48
|
|
|
55
|
-
## 6.
|
|
49
|
+
## 6. Import past sessions
|
|
56
50
|
|
|
57
|
-
`harnessforce import
|
|
51
|
+
Run `harnessforce import` and tell the user, as it is, the imported count it prints, along with the breakdown of sessions that were not imported and the guidance. Do not omit the printed reason and the next action even when the count is 0.
|
|
58
52
|
|
|
59
|
-
## 7.
|
|
53
|
+
## 7. Ask for a restart
|
|
60
54
|
|
|
61
|
-
|
|
55
|
+
Tell the user the following and stop.
|
|
62
56
|
|
|
63
|
-
|
|
57
|
+
> Harnessforce setup, part 1 of 2, is done. Restart Claude Code, then run `/harnessforce:setup` again in the new session. Part 2 checks that the first event arrived.
|
|
64
58
|
|
|
65
|
-
|
|
66
|
-
>
|
|
67
|
-
> You can share your usage limits (not shared by default). If shared, everyone in this workspace can see your usage limits together with your name (only the usage percentage and reset time of each window, such as 5 hours and 7 days). No prompt or other content is sent. You can stop at any time, and stopping deletes the stored values. They are not used to rank members. Share them?
|
|
68
|
-
>
|
|
69
|
-
> 共有しません(既定)。後から`harnessforce usage-limits on`で設定できます
|
|
70
|
-
>
|
|
71
|
-
> Not shared (by default). You can set it up later with `harnessforce usage-limits on`.
|
|
59
|
+
## 8. Confirm the first event
|
|
72
60
|
|
|
73
|
-
|
|
61
|
+
At the start of this session, the plugin hook sent the session to Harnessforce. Tell the user to open the Harnessforce Home in the browser (the URL in the environment variable `HARNESSFORCE_URL`) and confirm on the waiting screen for the first Run that it was received. If nothing arrives after 15 minutes, tell the user to follow the checks for each cause shown on the waiting screen. Finish with the following line.
|
|
74
62
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
次を利用者へ伝えて終わる。
|
|
78
|
-
|
|
79
|
-
> Claude Codeを再起動すると設定が反映されます。再起動したsessionで、もう一度`/harnessforce:setup`を実行してください。最初のイベントが届いたかを確認します。
|
|
80
|
-
|
|
81
|
-
## 9. 最初のイベントを確認する
|
|
82
|
-
|
|
83
|
-
このsessionの開始時に、pluginのhookがsessionをHarnessforceへ送っている。利用者に、ブラウザでHarnessforceのHome(環境変数`HARNESSFORCE_URL`のURL)を開き、最初のRunの待機画面で受信を確認するよう伝える。15分待っても届かなければ、待機画面が示す原因ごとの確認手順に沿って確かめるよう伝える。
|
|
63
|
+
> Harnessforce setup is complete.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Show the running and recent agent sessions on this machine as a short summary, using a read-only snapshot of harnessforce top
|
|
3
|
+
disable-model-invocation: true
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Session status
|
|
7
|
+
|
|
8
|
+
This command only reads. It changes no file, setting or Workspace data, and sends nothing to Harnessforce.
|
|
9
|
+
|
|
10
|
+
## 1. Take a snapshot
|
|
11
|
+
|
|
12
|
+
Run this once. It prints one snapshot as JSON and exits, so it does not open the interactive view.
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
harnessforce top --once --json
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
If the command is not found, tell the user to run `/harnessforce:setup` and stop. If it fails, show its output as is and stop.
|
|
19
|
+
|
|
20
|
+
## 2. Summarize
|
|
21
|
+
|
|
22
|
+
Summarize the snapshot for the user in a few lines: how many sessions are running, which agent and repository each belongs to, and any recent sessions that ended. Report only values that are in the JSON. Do not guess a value that is missing, and do not turn a missing value into 0.
|
|
23
|
+
|
|
24
|
+
## 3. Point to the live view
|
|
25
|
+
|
|
26
|
+
The interactive view needs a terminal, so this command does not start it. Tell the user to run `harnessforce top` in a terminal when they want the live view.
|
package/commands/tune.md
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: Analyze your past sessions and show the analysis results, the before and after of the previous suggestion, and suggested improvements for human interventions, repeatable loops, MCP servers, and usage. Does not modify files
|
|
3
3
|
argument-hint: "[--all] [--no-send]"
|
|
4
4
|
disable-model-invocation: true
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
#
|
|
7
|
+
# Analyze past sessions and suggest improvements
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Go through the steps below in order. This run does not modify the user's files, settings, repository, or managed settings. The only things written are what `harnessforce tune` and `harnessforce tune record` write to `~/.harnessforce/tune/`.
|
|
10
10
|
|
|
11
|
-
## 1. model
|
|
11
|
+
## 1. Say that content goes to the model provider
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Before running anything, show the following text as it is.
|
|
14
14
|
|
|
15
|
-
>
|
|
15
|
+
> To make suggestions, the agent reads part of the session records on this device in this run. What it reads goes to the provider of the model you normally use with this agent, through the same path as a normal session. It does not go to Harnessforce. Harnessforce receives only the analysis result values counted by the public rules.
|
|
16
16
|
|
|
17
|
-
## 2.
|
|
17
|
+
## 2. Analyze
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Run the following. It starts `harnessforce tune --json` and shows the analysis results and, for each target, the result of checking the conditions for making a suggestion. It includes sending and resending unsent results, so set the Bash timeout to 10 minutes.
|
|
20
20
|
|
|
21
21
|
```sh
|
|
22
22
|
node "${CLAUDE_PLUGIN_ROOT}/skills/propose-improvements/scripts/summarize.mjs" $ARGUMENTS
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
- stderr
|
|
26
|
-
- stdout
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
25
|
+
- The lines on stderr are the messages of `harnessforce tune`. Show all of them as they are, without omitting or rephrasing them.
|
|
26
|
+
- Show the analysis results on stdout (human interventions, repeatable loops, MCP servers, usage) as they are. Do not rephrase "not measured" as 0. Usage values stay on this device and are not sent to Harnessforce.
|
|
27
|
+
- If there is a "Before and after the previous suggestion" section, show it as it is before the new suggestions, and do not omit "Before/after difference (does not show causation)" or "The starting point is the time the application was detected". Do not rephrase "No comparison data" as a difference of 0.
|
|
28
|
+
- If the exit code is anything other than 0 or 3, finish without making suggestions. The same applies when the message says `harnessforce` was not found.
|
|
29
|
+
- If there is a "Not enough data, so no suggestions are made" line, show that line and finish without making suggestions.
|
|
30
30
|
|
|
31
|
-
## 3.
|
|
31
|
+
## 3. Make suggestions
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
Show all the "Targets for suggestions" lines. Show the "Not enough data" and "not measured, so no suggestion is made" lines as they are, including what is still needed, and make no suggestion for those targets.
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
For the targets marked "a suggestion can be made", make suggestions by following the `propose-improvements` skill of this plugin, record them with `harnessforce tune record`, and then show them. Do not show a suggestion whose recording did not end with exit code 0.
|
|
36
36
|
|
|
37
|
-
## 4.
|
|
37
|
+
## 4. Explain how to apply
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
Finally, tell the user that applying the suggestions is up to the user. They apply them by editing by hand, running `git apply`, or telling the agent in their own session to apply them. This command does not apply them. A suggestion that was applied is detected in the next run of `/harnessforce:tune`, and only counts are sent to Harnessforce.
|
package/hooks/hooks.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"description": "Register Claude Code sessions with Harnessforce and send their usage summaries",
|
|
2
|
+
"description": "Register Claude Code sessions with Harnessforce and send their usage summaries and work locations",
|
|
3
3
|
"hooks": {
|
|
4
4
|
"SessionStart": [
|
|
5
5
|
{
|
|
@@ -60,6 +60,20 @@
|
|
|
60
60
|
"async": true
|
|
61
61
|
}
|
|
62
62
|
]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"matcher": "^(Write|Edit)$",
|
|
66
|
+
"hooks": [
|
|
67
|
+
{
|
|
68
|
+
"type": "command",
|
|
69
|
+
"command": "node",
|
|
70
|
+
"args": [
|
|
71
|
+
"${CLAUDE_PLUGIN_ROOT}/scripts/harnessforce-hook.cjs",
|
|
72
|
+
"work-location"
|
|
73
|
+
],
|
|
74
|
+
"async": true
|
|
75
|
+
}
|
|
76
|
+
]
|
|
63
77
|
}
|
|
64
78
|
],
|
|
65
79
|
"PostToolUseFailure": [
|
|
@@ -122,6 +136,36 @@
|
|
|
122
136
|
}
|
|
123
137
|
]
|
|
124
138
|
}
|
|
139
|
+
],
|
|
140
|
+
"CwdChanged": [
|
|
141
|
+
{
|
|
142
|
+
"hooks": [
|
|
143
|
+
{
|
|
144
|
+
"type": "command",
|
|
145
|
+
"command": "node",
|
|
146
|
+
"args": [
|
|
147
|
+
"${CLAUDE_PLUGIN_ROOT}/scripts/harnessforce-hook.cjs",
|
|
148
|
+
"cwd-changed"
|
|
149
|
+
],
|
|
150
|
+
"async": true
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
"Stop": [
|
|
156
|
+
{
|
|
157
|
+
"hooks": [
|
|
158
|
+
{
|
|
159
|
+
"type": "command",
|
|
160
|
+
"command": "node",
|
|
161
|
+
"args": [
|
|
162
|
+
"${CLAUDE_PLUGIN_ROOT}/scripts/harnessforce-hook.cjs",
|
|
163
|
+
"stop"
|
|
164
|
+
],
|
|
165
|
+
"async": true
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
}
|
|
125
169
|
]
|
|
126
170
|
}
|
|
127
171
|
}
|