@harnessforce/claude-code-plugin 0.0.0-bootstrap.0 → 0.1.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.
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "harnessforce",
3
+ "version": "0.1.0",
4
+ "description": "Harnessforce plugin for Claude Code",
5
+ "author": {
6
+ "name": "Lambda Script"
7
+ },
8
+ "homepage": "https://github.com/lambda-script/harnessforce-agent",
9
+ "repository": "https://github.com/lambda-script/harnessforce-agent",
10
+ "license": "Apache-2.0"
11
+ }
package/.mcp.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "mcpServers": {
3
+ "harnessforce": {
4
+ "type": "http",
5
+ "url": "${HARNESSFORCE_URL:-https://harnessforce.dev}/mcp"
6
+ }
7
+ }
8
+ }
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # harnessforce plugin for Claude Code
2
+
3
+ The `harnessforce` Claude Code plugin links your Claude Code sessions to
4
+ [Harnessforce](https://github.com/lambda-script/harnessforce-agent) Issues. It is distributed through
5
+ the `harnessforce-agent` marketplace in this repository and as the npm package
6
+ `@harnessforce/claude-code-plugin`, which holds the plugin built against the production connection URL
7
+ and does not bundle the CLI (`/harnessforce:setup` installs `@harnessforce/cli` from npm).
8
+
9
+ ## What it contains
10
+
11
+ | Part | Purpose |
12
+ | --- | --- |
13
+ | `SessionStart` and `UserPromptSubmit` hooks | Register each session and its config snapshot with Harnessforce |
14
+ | `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 record plans, decisions and the Definition of Done |
16
+ | 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 call those tools |
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`, offers (unchecked by default) to share your usage limits with `harnessforce usage-limits on --yes`, and confirms the first event after a restart |
19
+ | 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 |
20
+ | 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
+
22
+ The hooks and the MCP server exist only in the build output, because their scripts and connection URL
23
+ come from the build. The copy of the plugin in this repository has no hooks and no MCP server. See
24
+ [Building the local marketplace](../../docs/runbooks/local-marketplace.md).
25
+
26
+ ## Install
27
+
28
+ Public distribution starts once the production domain of Harnessforce is decided. After that:
29
+
30
+ ```text
31
+ /plugin marketplace add lambda-script/harnessforce-agent
32
+ /plugin install harnessforce@harnessforce-agent
33
+ /harnessforce:setup
34
+ ```
35
+
36
+ Until then, install the [local marketplace build](../../docs/runbooks/local-marketplace.md).
37
+
38
+ ## Requirements
39
+
40
+ Node.js 18 or later on `PATH`. Without it, Claude Code shows a non-blocking `hook error` and the session
41
+ continues without sending anything.
42
+
43
+ ## Warnings
44
+
45
+ When a hook cannot send, it shows one line in the session instead of staying silent: Node.js older than 18,
46
+ a failed restart of the hook process, sending not set up (`/harnessforce:setup`), an endpoint that is set
47
+ but not allowed, and a session registration that failed with anything other than 401. The line appears
48
+ only at a session start that registers (`startup`, `clear`, `fork`), except for the two startup failures,
49
+ which appear at every session start. A missing key while `HARNESSFORCE_WORKSPACE_ID` is set shows nothing.
50
+
51
+ ## Session registration hooks
52
+
53
+ The `harnessforce` plugin registers each Claude Code session with Harnessforce so that runs can be
54
+ linked to issues. On `SessionStart` (`startup`, `clear`, `fork`) it sends the session ID and the git
55
+ 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. Prompts, responses and file
57
+ contents are never sent.
58
+
59
+ - For an organization, set `HARNESSFORCE_ENDPOINT` (the ingest base URL; `https:`, or `http:` only
60
+ for `localhost`, `127.0.0.1` and `[::1]`) and `HARNESSFORCE_INGEST_KEY` (a Workspace ingest key) in
61
+ the `env` of the managed settings file (`managed-settings.json` or `managed-settings.d/*.json` in
62
+ the managed directory). The hook reads the Workspace key and its endpoint only from those files,
63
+ never from the process environment, because a repository's `.claude/settings.json` can set
64
+ environment variables. Values distributed through MDM or server-managed settings are not read.
65
+ Hooks do not receive `OTEL_*` variables, so these are separate.
66
+ - Without a managed Workspace key, the hook sends to `HARNESSFORCE_ENDPOINT` from the environment with
67
+ the user ingest key that `harnessforce init` stored for
68
+ `HARNESSFORCE_WORKSPACE_ID`, reading it by running `harnessforce otel-headers` from `PATH` (1 second limit).
69
+ With a user key and `HARNESSFORCE_ISSUE` (set by `harnessforce run`), the registration claims `source=cli`
70
+ with that issue identifier. A Workspace key never claims `source=cli`.
71
+ - Requires Node.js 18 or later on `PATH`. The hook always exits 0: outside a git repository, without
72
+ configuration, on errors, or after 2 seconds it gives up quietly and writes the reason to stderr
73
+ (Claude Code's debug log). Without Node.js, Claude Code shows a non-blocking `hook error`.
74
+ - If the key is revoked, Claude Code shows once per session:
75
+ 組織の送信キーが失効しています。Workspaceの管理者に連絡してください (Workspace key) or
76
+ 送信キーが失効しています。`harnessforce init`を実行してください (user key)
77
+
78
+ ## Config snapshot
79
+
80
+ At the same `SessionStart`, the hook also sends a config snapshot to
81
+ `POST <HARNESSFORCE_ENDPOINT>/v1/config-snapshots`, including outside a git repository. The snapshot
82
+ describes the agent configuration as a list of components. Each component has a kind, a scope and
83
+ an identifier, plus a SHA-256 hash:
84
+
85
+ - CLAUDE.md files and rules, skills, agents, commands and workflows, from the managed directory,
86
+ `~/.claude` and the repository root.
87
+ - `hooks`, `permissions` and `model` from each settings file.
88
+ - MCP servers from `.mcp.json`, `~/.claude.json` and `managed-mcp.json`.
89
+ - The same kinds of component from enabled marketplace plugins in the plugin cache.
90
+
91
+ File contents, settings values and MCP server configuration (URLs, headers, environment) are never
92
+ sent, only their hashes. Nothing is sent when there are no components, and the snapshot is skipped
93
+ when collection takes over 1 second or finds more than 1,000 components. The collector lives in
94
+ `packages/agent-core/src/config`, shared with `harnessforce run` so it can compute the same snapshot ID.
95
+
96
+ ## Session usage summary
97
+
98
+ The hooks count, per session, the calls and failures of skills (started through the Skill tool),
99
+ commands (typed by you), subagents (started through the Agent tool) and MCP servers, plus permission
100
+ requests and compactions, and send one summary per session to
101
+ `POST <HARNESSFORCE_ENDPOINT>/v1/session-usage`. Claude Code's telemetry hides the names of your own
102
+ skills, commands, subagents and MCP servers, and the setting that reveals them also sends Bash
103
+ commands and file paths, so the hooks count the names themselves.
104
+
105
+ - Only names that are identifiers in the session's config snapshot are sent; other calls, such as
106
+ built-in subagents, are added to an `other` count. Each list keeps the 200 most called names. Prompts,
107
+ command arguments, tool inputs and results, error messages, compaction summaries and file paths are
108
+ never read into the record or sent. The MCP tool name is reduced to its server.
109
+ - The record lives in `${CLAUDE_PLUGIN_DATA}/usage/`: `<session_id>.jsonl` holds one line per counted
110
+ call (time, prompt ID, kind, identifier, failure) and `<session_id>.json` holds the Workspace, the
111
+ session's identifiers and how much of the record was sent. `SessionStart` creates them when it has a
112
+ destination and a key, and removes files unchanged for 30 days, up to 100 at a time.
113
+ - With a Workspace key from managed settings, `SessionEnd` sends the summary within 1 second of its
114
+ start, without running `harnessforce otel-headers`, because Claude Code gives all `SessionEnd` hooks 1.5 seconds
115
+ together. With a user key, or when that send fails, the next `SessionStart` sends up to 20 summaries of
116
+ other sessions of the same Workspace whose record has not changed for 10 minutes, oldest first.
117
+ - The counting hooks run asynchronously and never delay the agent. Failures are written to stderr as
118
+ `harnessforce: session usage failed (<reason>)`; a `401` at `SessionStart` shows the revoked-key
119
+ notice like the registration does.
120
+
121
+ ## License
122
+
123
+ [Apache-2.0](../../LICENSE)
@@ -0,0 +1,83 @@
1
+ ---
2
+ description: Harnessforceのsetup。Node.jsの確認、本文データを送るかの選択、CLIの導入、harnessforce init、過去のsessionの取り込み、利用枠を共有するかの選択、再起動後の最初のイベントの確認までを対話で進める
3
+ disable-model-invocation: true
4
+ ---
5
+
6
+ # Harnessforceのsetup
7
+
8
+ 次の手順を順に、利用者と対話しながら進める。commandが失敗したら、その出力を利用者へ示し、以降の手順へ進まずに止まる。
9
+
10
+ ## 1. Node.jsを確かめる
11
+
12
+ 最初に`node --version`を実行する。commandが見つからない、またはversionが18未満なら、CLIの導入へ進まずに次の文言をそのまま表示して終わる。
13
+
14
+ > プラグインのフックにはNode.js 18以上が必要です。Node.jsを導入してからClaude Codeを再起動し、もう一度`/harnessforce:setup`を実行してください
15
+
16
+ ## 2. 再起動後の実行かを確かめる
17
+
18
+ `harnessforce --version`が成功し、かつこのsessionの環境変数`HARNESSFORCE_WORKSPACE_ID`が空でなければ、`harnessforce init`の後に再起動したsessionである。手順3から8を行わずに手順9へ進む。
19
+
20
+ ## 3. CLIを導入する
21
+
22
+ 次を実行し、続けて`harnessforce --version`で導入できたことを確かめる。
23
+
24
+ ```sh
25
+ npm install -g @harnessforce/cli
26
+ ```
27
+
28
+ ## 4. 本文データを送るかを選ぶ
29
+
30
+ `harnessforce init`の前に、本文データを送る設定の選択肢を、既定では選ばれない状態で利用者に示す。この時点ではログインが済んでおらず、接続するWorkspaceもそのopt-inの状態も分からないため、opt-inの有無で表示を変えない。
31
+
32
+ 選択肢には次を併せて示す。
33
+
34
+ - 選ぶと、agentに入力した指示(prompt)の本文がこのWorkspaceへ届き、secretのパターンとメールアドレス・電話番号を`[REDACTED:種類]`に置き換えたうえで保存され、本文データの保持期間(最大30日)で削除される。パターンに一致しない秘密値と個人情報は伏せ字にならず、すべてを検出できるとは限らない。保存した本文は、Workspaceのメンバーの中では送った本人だけが読め、OwnerとAdminも読めない。本人は「自分のやり方」でいつでも自分の本文を削除できる。
35
+ - 本文が保存されるのは、端末のこの設定とWorkspaceのopt-inの2つがそろう場合だけ。Workspaceのopt-inを解除すると、それ以降の本文は受信時に破棄され、既存の本文データも読めなくなる。この設定はモデルの応答やツールの入出力を送る設定を有効にしない。
36
+ - 選んだ場合は`harnessforce init --send-content`、選ばない場合は`harnessforce init`を実行する(手順5)。この設定はClaude Codeのuser settingsの`env`に書き、project(`.claude/settings.json`)とlocal(`.claude/settings.local.json`)の`env`には書かない。その2つのfileの`env`では本文の変数が無視されるため。
37
+ - 選んだ後で止めるときは、user settingsの`env`の`OTEL_LOG_USER_PROMPTS`を`0`にする。止める値はprojectとlocalの`env`でも効く。
38
+
39
+ 選択肢の文言は次をそのまま使う。
40
+
41
+ > 入力した指示の本文を送って分析に使えます(既定では無効。Workspaceが指示本文をオプトインしている場合だけ有効になります)。有効にすると、エージェントに入力した指示の本文がこのWorkspaceへ届き、保存されます。パターンに一致した秘密値と個人情報は`[REDACTED:種類]`に置き換えますが、すべてを検出できるとは限りません。本文データの保持期間(最大30日)で削除し、Workspaceのメンバーの中では、読めるのは送ったあなただけです。自分のやり方の画面からいつでも削除できます。有効にしますか?
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.
48
+
49
+ ## 5. Harnessforceに接続する
50
+
51
+ 手順4の選択に従い、選んだ場合は`harnessforce init --send-content`、選ばない場合は`harnessforce init`を実行する。ブラウザでHarnessforceにログインし、接続するWorkspaceを1つ選ぶよう利用者へ伝える。ブラウザが開かなければ、`harnessforce init`が表示するURLを利用者へ示す。ログインの完了を最大5分待つため、Bashのtimeoutを10分にして実行する。
52
+
53
+ opt-inしていないWorkspaceでは`harnessforce init --send-content`は本文の設定を書かず、その旨とWorkspaceの設定のデータの保持への案内を表示して終了コード0で終わる。失敗として扱わず、表示された文言をそのまま利用者へ示す。
54
+
55
+ ## 6. 過去のsessionを取り込む
56
+
57
+ `harnessforce import`を実行し、送信した件数と読み飛ばした件数を利用者へ伝える。
58
+
59
+ ## 7. 利用枠を共有するかを選ぶ
60
+
61
+ `harnessforce init`の後に、`harnessforce usage-limits status`を実行する。表示のWorkspaceのopt-inが「有効」でなければ(「無効」「確認できません」を含む)、利用枠の選択肢を示さず手順8へ進む。「有効」なら、利用枠(Claude Codeの5時間と7日の枠の使用率とリセット時刻)をこのWorkspaceのメンバーと共有する選択肢を、既定では選ばれない状態で利用者に示す。選ばれなければ、何も実行せず手順8へ進む。
62
+
63
+ 選択肢の文言は次をそのまま使う。
64
+
65
+ > 利用枠を共有できます(既定では共有しません)。共有すると、あなたの名前とともに、あなたの利用枠(5時間・7日などの窓の使用率とリセット時刻だけ)を、このWorkspaceのメンバー全員が見られます。プロンプトなどの本文は送りません。いつでもやめられ、やめると保存済みの値も削除します。メンバーの順位づけには使いません。共有しますか?
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`.
72
+
73
+ 共有を選んだ場合だけ、利用者自身が同意の文面に答えるため、`!harnessforce usage-limits on`を利用者に入力してもらう。`--yes`は付けず、agentが同意を代行しない。同意の文面に`y`と答えると、既にstatusLineを使っている場合(claude-hudなど)は、そのcommandを包んで表示と終了コードを変えずに残す。Windowsや、組み込めないstatusLineでは、このcommandは何も変えずに理由を表示して0以外で終わる。その表示を利用者へそのまま示し、他の手順は続ける。やめるときは`harnessforce usage-limits off`を案内する。
74
+
75
+ ## 8. 再起動を案内する
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分待っても届かなければ、待機画面が示す原因ごとの確認手順に沿って確かめるよう伝える。
@@ -0,0 +1,39 @@
1
+ ---
2
+ description: 自分の過去のsessionを分析し、分析結果、前回の提案の前後と、人の介入、ループにできる繰り返し、MCP server、使い方の改善の提案を表示する。ファイルは書き換えない
3
+ argument-hint: "[--all] [--no-send]"
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # 過去のsessionの分析と改善の提案
8
+
9
+ 次の手順を順に進める。この実行では、利用者のファイル、設定、repository、managed settingsを書き換えない。書き込むのは`harnessforce tune`と`harnessforce tune record`が`~/.harnessforce/tune/`へ書くものだけである。
10
+
11
+ ## 1. modelのproviderへ渡ることを伝える
12
+
13
+ 何かを実行する前に、次の文言をそのまま表示する。
14
+
15
+ > この実行では、提案を作るために、この端末のsessionの記録の一部をagentが読みます。読んだ内容は、ふだんこのagentに使っているmodelのproviderへ、通常のsessionと同じ経路で渡ります。Harnessforceへは渡りません。Harnessforceへ送るのは、公開の規則で数えた分析結果の値だけです。
16
+
17
+ ## 2. 分析する
18
+
19
+ 次を実行する。`harnessforce tune --json`を起動し、分析結果と、提案を作る条件を対象ごとに判定した結果を表示する。送信と未送信の分の再送を含むため、Bashのtimeoutを10分にする。
20
+
21
+ ```sh
22
+ node "${CLAUDE_PLUGIN_ROOT}/skills/propose-improvements/scripts/summarize.mjs" $ARGUMENTS
23
+ ```
24
+
25
+ - stderrの行は`harnessforce tune`の文言である。省略も言い換えもせずに、すべてそのまま表示する。
26
+ - stdoutの分析結果(人の介入、ループにできる繰り返し、MCP server、使い方)をそのまま表示する。「未計測」を0と言い換えない。使い方は端末だけの値であり、Harnessforceへ送られない。
27
+ - 「前回の提案の前後」の行があれば、新しい提案の前に「前回の提案の前後」としてそのまま表示し、「前後の差(因果を示しません)」と「起点は適用を検出した時刻です」を省略しない。「比較データなし」を差0と言い換えない。
28
+ - 終了コードが0と3以外なら、提案を作らずに終わる。`harnessforce`が見つからない旨の文言が出た場合も同じである。
29
+ - 「データ不足のため提案を作りません」の行があれば、その行を表示し、提案を作らずに終わる。
30
+
31
+ ## 3. 提案を作る
32
+
33
+ 「提案の対象」の行をすべて表示する。「データ不足」と「未計測のため提案しません」の行は、あと何が必要かを含めてそのまま表示し、その対象の提案を作らない。
34
+
35
+ 「提案を作れます」の対象について、このpluginの`propose-improvements`のskillの手順に従って提案を作り、`harnessforce tune record`で記録してから表示する。記録が終了コード0で終わらなかった提案は表示しない。
36
+
37
+ ## 4. 適用の仕方を伝える
38
+
39
+ 最後に、提案の適用は利用者が行うことを伝える。手で編集する、`git apply`する、自分のsessionでagentに適用を指示する、のいずれかで適用する。このcommandは適用しない。適用した提案は、次の`/harnessforce:tune`の実行で検出され、件数だけがHarnessforceへ送られる。
@@ -0,0 +1,127 @@
1
+ {
2
+ "description": "Register Claude Code sessions with Harnessforce and send their usage summaries",
3
+ "hooks": {
4
+ "SessionStart": [
5
+ {
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "node",
10
+ "args": [
11
+ "${CLAUDE_PLUGIN_ROOT}/scripts/harnessforce-hook.cjs",
12
+ "session-start"
13
+ ],
14
+ "timeout": 10
15
+ }
16
+ ]
17
+ }
18
+ ],
19
+ "UserPromptSubmit": [
20
+ {
21
+ "hooks": [
22
+ {
23
+ "type": "command",
24
+ "command": "node",
25
+ "args": [
26
+ "${CLAUDE_PLUGIN_ROOT}/scripts/harnessforce-hook.cjs",
27
+ "user-prompt-submit"
28
+ ],
29
+ "timeout": 10
30
+ }
31
+ ]
32
+ }
33
+ ],
34
+ "SessionEnd": [
35
+ {
36
+ "hooks": [
37
+ {
38
+ "type": "command",
39
+ "command": "node",
40
+ "args": [
41
+ "${CLAUDE_PLUGIN_ROOT}/scripts/harnessforce-hook.cjs",
42
+ "session-end"
43
+ ],
44
+ "timeout": 10
45
+ }
46
+ ]
47
+ }
48
+ ],
49
+ "PostToolUse": [
50
+ {
51
+ "matcher": "^(Skill|Agent|Task)$|^mcp__",
52
+ "hooks": [
53
+ {
54
+ "type": "command",
55
+ "command": "node",
56
+ "args": [
57
+ "${CLAUDE_PLUGIN_ROOT}/scripts/harnessforce-hook.cjs",
58
+ "post-tool-use"
59
+ ],
60
+ "async": true
61
+ }
62
+ ]
63
+ }
64
+ ],
65
+ "PostToolUseFailure": [
66
+ {
67
+ "matcher": "^(Skill|Agent|Task)$|^mcp__",
68
+ "hooks": [
69
+ {
70
+ "type": "command",
71
+ "command": "node",
72
+ "args": [
73
+ "${CLAUDE_PLUGIN_ROOT}/scripts/harnessforce-hook.cjs",
74
+ "post-tool-use-failure"
75
+ ],
76
+ "async": true
77
+ }
78
+ ]
79
+ }
80
+ ],
81
+ "UserPromptExpansion": [
82
+ {
83
+ "hooks": [
84
+ {
85
+ "type": "command",
86
+ "command": "node",
87
+ "args": [
88
+ "${CLAUDE_PLUGIN_ROOT}/scripts/harnessforce-hook.cjs",
89
+ "user-prompt-expansion"
90
+ ],
91
+ "async": true
92
+ }
93
+ ]
94
+ }
95
+ ],
96
+ "PermissionRequest": [
97
+ {
98
+ "hooks": [
99
+ {
100
+ "type": "command",
101
+ "command": "node",
102
+ "args": [
103
+ "${CLAUDE_PLUGIN_ROOT}/scripts/harnessforce-hook.cjs",
104
+ "permission-request"
105
+ ],
106
+ "async": true
107
+ }
108
+ ]
109
+ }
110
+ ],
111
+ "PostCompact": [
112
+ {
113
+ "hooks": [
114
+ {
115
+ "type": "command",
116
+ "command": "node",
117
+ "args": [
118
+ "${CLAUDE_PLUGIN_ROOT}/scripts/harnessforce-hook.cjs",
119
+ "post-compact"
120
+ ],
121
+ "async": true
122
+ }
123
+ ]
124
+ }
125
+ ]
126
+ }
127
+ }
package/package.json CHANGED
@@ -1,11 +1,29 @@
1
1
  {
2
2
  "name": "@harnessforce/claude-code-plugin",
3
- "version": "0.0.0-bootstrap.0",
4
- "description": "Placeholder to attach npm trusted publishing. Not for use.",
3
+ "version": "0.1.0",
4
+ "description": "Harnessforce plugin for Claude Code",
5
+ "keywords": [
6
+ "harnessforce",
7
+ "claude-code",
8
+ "claude-code-plugin",
9
+ "opentelemetry",
10
+ "ai-agents"
11
+ ],
5
12
  "license": "Apache-2.0",
13
+ "homepage": "https://github.com/lambda-script/harnessforce-agent/tree/main/plugins/harnessforce#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/lambda-script/harnessforce-agent/issues"
16
+ },
6
17
  "repository": {
7
18
  "type": "git",
8
19
  "url": "git+https://github.com/lambda-script/harnessforce-agent.git",
9
20
  "directory": "plugins/harnessforce"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public",
24
+ "provenance": true
25
+ },
26
+ "engines": {
27
+ "node": ">=18"
10
28
  }
11
- }
29
+ }