heyspex 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +10 -0
  2. package/bin/hs-vault-binding.mjs +157 -0
  3. package/bin/hs.mjs +99 -81
  4. package/bin/spexcode.mjs +91 -0
  5. package/dev-factory/engine/worktree.mjs +36 -7
  6. package/dev-factory/lib/epic-detect.mjs +2 -2
  7. package/dev-factory/lib/fleet-readiness.mjs +3 -5
  8. package/dev-factory/lib/fleet-state.mjs +2 -2
  9. package/dev-factory/lib/sufficiency-score.mjs +3 -5
  10. package/dist/cli/hs-check.mjs +76 -46
  11. package/dist/cli/hs-claim.mjs +63 -33
  12. package/dist/cli/hs-connect.mjs +520 -214
  13. package/dist/cli/hs-defer.mjs +161 -19
  14. package/dist/cli/hs-dev.mjs +11 -5
  15. package/dist/cli/hs-env.mjs +187 -161
  16. package/dist/cli/hs-index-rebuild.mjs +123 -78
  17. package/dist/cli/hs-index-reconcile.mjs +203 -107
  18. package/dist/cli/hs-init.mjs +426 -179
  19. package/dist/cli/hs-install.mjs +759 -437
  20. package/dist/cli/hs-join.mjs +590 -383
  21. package/dist/cli/hs-vault-pull.mjs +359 -254
  22. package/dist/cli/hs-vault-push.mjs +151 -113
  23. package/dist/cli/hs-vault.mjs +271 -104
  24. package/dist/cli/hs-workspace.mjs +90 -57
  25. package/dist/cli-templates/customer-vault/specs/protocols/session-close-protocol.md +178 -91
  26. package/docs/copilot-plugin-install.md +189 -162
  27. package/docs/driving-heyspex-from-copilot.md +174 -165
  28. package/docs/mcp-client-config.md +93 -25
  29. package/package.json +255 -249
  30. package/plugins/heyspex/.mcp.json +3 -4
  31. package/plugins/heyspex/README.md +323 -309
  32. package/plugins/heyspex/bin/launch-mcp.mjs +21 -7
  33. package/plugins/heyspex/mcp.json +12 -13
  34. package/scripts/check-mcp-freshness.mjs +6 -4
  35. package/scripts/claude-hooks/_intent-classifier-router.mjs +518 -456
  36. package/scripts/claude-hooks/intent-classifier-trigger.mjs +305 -279
  37. package/scripts/claude-hooks/research-method-guard.mjs +2 -2
  38. package/scripts/claude-hooks/wip-checkpoint.mjs +33 -9
  39. package/scripts/claude-statusline/fonts/HeySpexIcons.ttf +0 -0
  40. package/scripts/claude-statusline/statusline-command.mjs +1058 -0
  41. package/scripts/dev-server-status.mjs +3 -2
  42. package/scripts/dev-server-stop.mjs +3 -2
  43. package/scripts/hs-capture-cli.mjs +2 -2
  44. package/scripts/hs-settings.mjs +2 -2
  45. package/scripts/hs-view.mjs +3 -2
  46. package/scripts/install-copilot-hooks.mjs +318 -0
  47. package/scripts/lib/copilot-cli.mjs +108 -0
  48. package/scripts/lib/customer-kit.mjs +223 -30
  49. package/scripts/lib/dev-mode.mjs +28 -2
  50. package/scripts/lib/shared-path-helpers.mjs +32 -0
  51. package/scripts/lib/standalone-doctor.mjs +131 -32
  52. package/scripts/wip-ledger-health.mjs +3 -2
  53. package/spexharness/src/gates/vault-mirror-catchup.mjs +113 -24
  54. package/spexharness/src/gates/vault-mirror-catchup.runner.mjs +52 -0
  55. package/spexharness/src/intent-directive.mjs +839 -626
  56. package/spexharness/src/rule-table.mjs +1 -1
  57. package/vendor/heyspex-mcp/cli-verbs.mjs +16 -2
  58. package/vendor/heyspex-mcp/cli.mjs +20 -4
  59. package/vendor/heyspex-mcp/console-fetch.mjs +15 -3
  60. package/vendor/heyspex-mcp/dev-tools.mjs +11 -4
  61. package/vendor/heyspex-mcp/events-tools.mjs +1 -1
  62. package/vendor/heyspex-mcp/factory-run-status.mjs +42 -0
  63. package/vendor/heyspex-mcp/mcp-config.mjs +4 -2
  64. package/vendor/heyspex-mcp/spec-edit-tools.mjs +26 -1
  65. package/vendor/heyspex-mcp/test-helpers.mjs +5 -2
  66. package/vendor/heyspex-mcp/tool-catalog.mjs +12 -0
  67. package/vendor/heyspex-mcp/tool-dispatch.mjs +59 -23
  68. package/vendor/heyspex-mcp/usable-dir-env.mjs +82 -0
  69. package/vendor/heyspex-mcp/vault-binding.mjs +839 -0
  70. package/vendor/heyspex-mcp/vault-resolve.mjs +353 -245
@@ -1,162 +1,189 @@
1
- # Installing the HeySpex (SpexCode) plugin in GitHub Copilot CLI
2
-
3
- Instructions written to be handed verbatim to a GitHub Copilot CLI agent. Follow the steps in
4
- order and stop at any step that fails, reporting the exact output.
5
-
6
- This guide is for a team that installs only the `heyspex` npm package. The heyspex-app repository
7
- is not needed and is not available to customers.
8
-
9
- Source of truth for the Copilot commands and file layout:
10
- <https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-plugin-reference>.
11
- Hook behaviour under Copilot: <https://docs.github.com/en/copilot/reference/hooks-configuration>.
12
- Both pages were read on 2026-10-16. The plugin itself is documented in `node_modules/heyspex/plugins/heyspex/README.md`.
13
-
14
- ## 1. Prerequisites
15
-
16
- The heyspex-app repository is not required and is not available to customers. Everything below
17
- works from the published npm package `heyspex` (or a tarball your HeySpex contact hands you), which
18
- carries the plugin, the marketplace manifest, the hooks and the MCP server.
19
-
20
- - Node.js 20 or newer on PATH (`node --version`).
21
- - GitHub Copilot CLI installed and signed in (`copilot --version`).
22
- - A git repo of your own (the one you want governed). From its root, install the package:
23
-
24
- ```bash
25
- npm install heyspex
26
- # or, from a tarball you were given:
27
- npm install ./heyspex-0.2.0.tgz
28
- ```
29
-
30
- - Sign the machine in to the HeySpex console so hooks and MCP tools can reach the vault:
31
-
32
- ```bash
33
- npx hs login
34
- ```
35
-
36
- ## 2. Pick ONE: the plugin or the repo hooks (never both)
37
-
38
- Copilot reads hooks from an installed plugin and from `.github/hooks/` in the repo. With both,
39
- every hook runs twice. Choose one.
40
-
41
- **Option A: the plugin (recommended).** One command registers the marketplace shipped inside the
42
- package and installs the plugin:
43
-
44
- ```bash
45
- npx hs install --target . --copilot-plugin-apply
46
- ```
47
-
48
- Without `npx hs`, the equivalent Copilot commands are:
49
-
50
- ```bash
51
- copilot plugin marketplace add ./node_modules/heyspex
52
- copilot plugin install heyspex@heyspex-marketplace
53
- copilot plugin list
54
- ```
55
-
56
- `./node_modules/heyspex/.claude-plugin/marketplace.json` is a Claude-format marketplace named
57
- `heyspex-marketplace`; its plugin `source` (`./plugins/heyspex`) resolves inside the package.
58
- `npx hs install --target . --copilot-plugin` (no `-apply`) only prints these commands.
59
-
60
- **Option B: repo hooks, for teammates and the Copilot cloud agent.** Writes
61
- `.github/hooks/heyspex.json` into your repo; commit it. Each command runs
62
- `node_modules/heyspex/scripts/claude-hooks/_run.mjs` and exits 0 if the package is not installed,
63
- so a checkout without `npm install` is never blocked.
64
-
65
- ```bash
66
- npx hs install --target . --copilot-hooks
67
- ```
68
-
69
- If you pass `--copilot-hooks` together with `--copilot-plugin[-apply]`, the installer warns and
70
- skips the hooks file.
71
-
72
- Then restart the Copilot session (`/restart`) so hooks load, and verify:
73
-
74
- ```bash
75
- copilot plugin list # Option A: heyspex is enabled
76
- npx hs doctor # MCP, hooks and account surfaces healthy
77
- ```
78
-
79
- ## 3. What the plugin loads
80
-
81
- | Component | Source | Behaviour under Copilot |
82
- | --- | --- | --- |
83
- | Hooks | `node_modules/heyspex/plugins/heyspex/hooks/hooks.json` | PreToolUse, PostToolUse, Stop, UserPromptSubmit and SessionStart gates. Every command locates the runtime itself and exits 0 if it cannot, so a missing variable never denies a tool call. A real deny arrives as a top-level `permissionDecision` with a reason. |
84
- | MCP server | `node_modules/heyspex/plugins/heyspex/.mcp.json` | The `heyspex_*` vault tools and `hs-*` prompts. |
85
- | Slash commands | not loaded | Claude Code commands are not a Copilot component. Use MCP prompts or the `hs` CLI. |
86
-
87
- ## 4. Verify the install
88
-
89
- 1. In a Copilot session inside any repo, run a harmless tool call, for example read a file. It
90
- must succeed. A message containing "Denied by preToolUse hook" means a hook failed; go to
91
- section 7.
92
- 2. Confirm the MCP server is up by listing MCP servers in Copilot (`/mcp`) and calling
93
- `heyspex_recall_memories` with `{ "limit": 3 }`. If the server is missing, go to section 7.
94
- 3. Confirm the gates work: send a prompt that contains a new product idea of more than 60
95
- characters, then try to edit a source file without capturing. The edit should be refused with a
96
- reason that names `directive-obligation-gate`. Call `heyspex_update_capture` with the prompt
97
- text, then retry the edit. It should pass.
98
-
99
- ## 5. Turning HeySpex off and on
100
-
101
- Run from the repo you are working in:
102
-
103
- ```bash
104
- hs mode status # on | off, and why
105
- hs mode off # every hook exits 0 immediately, no restart needed
106
- hs mode on
107
- hs mode toggle
108
- ```
109
-
110
- Use `npx hs mode off` when `hs` is not on PATH. The switch writes
111
- `.heyspex/mode.json` in the project and is git-ignored.
112
-
113
- Per-shell variants that touch no files:
114
-
115
- | Variable | Effect |
116
- | --- | --- |
117
- | `HEYSPEX_MODE=off` | Silences hooks for every harness in that shell |
118
- | `HEYSPEX_COPILOT_HOOKS_OFF=1` | Silences hooks only when the caller is Copilot; Claude Code and Cursor keep theirs |
119
-
120
- The config twin of the Copilot switch is `agent_behaviors.harness_hooks.copilot.enabled: false` in
121
- the vault's `.heyspex/config.yaml`.
122
-
123
- Four security gates ignore all of these by design: `env-vault-guard`, `research-method-guard`,
124
- `research-protocol-gate` and `git-identity-guard`. They only act on secret writes, built-in
125
- deep-research skills, unprotocolled web research and git identity changes.
126
-
127
- ## 6. Everyday loop
128
-
129
- With MCP available: `heyspex_next_on_deck`, `heyspex_claim_spec`, `heyspex_report_progress`,
130
- `heyspex_submit_for_review`. Without MCP, the `hs` CLI (`npx hs`) covers the same loop; see
131
- `docs/driving-heyspex-from-copilot.md`.
132
-
133
- ## 7. Troubleshooting
134
-
135
- - **Every tool call is denied.** Run `hs mode off` to unblock immediately, then capture the exact
136
- deny text and the hook command it names. If the command still starts with
137
- `node "$CLAUDE_PROJECT_DIR/...`, the package is old; run `npm install heyspex@latest` and reinstall the plugin.
138
- - **MCP server does not start.** Copilot documents `${PLUGIN_ROOT}` for its own plugin format, and
139
- whether it expands `${CLAUDE_PLUGIN_ROOT}` in a Claude-format plugin is unverified. Register the
140
- server explicitly:
141
-
142
- ```bash
143
- copilot mcp add heyspex -- node ./node_modules/heyspex/plugins/heyspex/bin/launch-mcp.mjs
144
- ```
145
-
146
- - **A hook denies with no reason shown.** That is a hook exiting 2 the old way. Report the hook
147
- name; it should be answering in Copilot's JSON format.
148
- - **Hooks run twice.** The repo you are in also carries HeySpex rows in its own
149
- `.claude/settings.json` from `hs install`. Use either the plugin or the install kit (or `.github/hooks`) in one repo,
150
- not both.
151
-
152
- ## 8. Report back
153
-
154
- State the Copilot CLI version, the output of `copilot plugin list`, the result of the three checks
155
- in section 4, and the exact text of any deny or MCP error.
156
-
157
- ## Status of this document
158
-
159
- The install commands come from GitHub's plugin reference, and the hook behaviour was verified by
160
- replaying Copilot-shaped payloads through the registered commands, not by a live Copilot session.
161
- The first agent that completes section 4 is the real test. Fix history: diagnose HS-20SW and
162
- capture HS-HNO1 (2026-10-16).
1
+ # Installing the HeySpex (SpexCode) plugin in GitHub Copilot CLI
2
+
3
+ Instructions written to be handed verbatim to a GitHub Copilot CLI agent. Follow the steps in
4
+ order and stop at any step that fails, reporting the exact output.
5
+
6
+ This guide is for a team that installs only the `heyspex` npm package. The heyspex-app repository
7
+ is not needed and is not available to customers.
8
+
9
+ Source of truth for the Copilot commands and file layout:
10
+ <https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-plugin-reference>.
11
+ Hook behaviour under Copilot: <https://docs.github.com/en/copilot/reference/hooks-configuration>.
12
+ Both pages were read on 2026-10-16. The plugin itself is documented in `node_modules/heyspex/plugins/heyspex/README.md`.
13
+
14
+ ## 0. The short version
15
+
16
+ From the root of your repo, after `npm install heyspex`:
17
+
18
+ ```bash
19
+ npx heyspex setup copilot # plugin route (Copilot CLI): registers the marketplace and installs the plugin
20
+ npx heyspex setup copilot --hooks # hooks route (Copilot cloud agent / no plugin): writes .github/hooks/heyspex.json
21
+ npx heyspex setup copilot --check # which route is active; warns if both are
22
+ npx heyspex setup copilot --uninstall
23
+ ```
24
+
25
+ To have an agent do it, paste it the output of `npx heyspex setup copilot --print` (this document,
26
+ preceded by the exact next command). If no Copilot CLI can be found (PATH, then the Copilot app's bundled copy), the plugin route
27
+ installs nothing, prints the prerequisite and the two commands, and exits 1. Pick ONE route, never both. The manual commands below remain the fallback.
28
+
29
+ ## 1. Prerequisites
30
+
31
+ The heyspex-app repository is not required and is not available to customers. Everything below
32
+ works from the published npm package `heyspex` (or a tarball your HeySpex contact hands you), which
33
+ carries the plugin, the marketplace manifest, the hooks and the MCP server.
34
+
35
+ - Node.js 20 or newer on PATH (`node --version`).
36
+ - GitHub Copilot CLI installed and signed in. Any one of: the GitHub Copilot app (its bundled
37
+ `%LOCALAPPDATA%\github-copilot-sdk\cli\<version>\copilot.exe` is auto-detected, newest version
38
+ wins, no PATH entry needed), `npm install -g @github/copilot`, or `winget install GitHub.Copilot`.
39
+ `npx heyspex setup copilot` looks on PATH first, then for the app copy; if neither exists it
40
+ installs nothing and exits non-zero. `COPILOT_HOME` (Copilot's settings-dir override) is honoured.
41
+ - A git repo of your own (the one you want governed). From its root, install the package:
42
+
43
+ ```bash
44
+ npm install heyspex
45
+ # or, from a tarball you were given:
46
+ npm install ./heyspex-0.2.0.tgz
47
+ ```
48
+
49
+ - Sign the machine in to the HeySpex console so hooks and MCP tools can reach the vault:
50
+
51
+ ```bash
52
+ npx hs login
53
+ ```
54
+
55
+ ## 2. Pick ONE: the plugin or the repo hooks (never both)
56
+
57
+ Copilot reads hooks from an installed plugin and from `.github/hooks/` in the repo. With both,
58
+ every hook runs twice. Choose one.
59
+
60
+ The `.claude/settings.json` rows `hs install` commits are the exception that needs no choice: they
61
+ route through the committed launcher `.claude/heyspex/run-hook.mjs` (marker `// yields-to-plugin: v1`),
62
+ which exits 0 silently when a heyspex plugin is enabled on the machine running it, so the plugin's
63
+ copy of the hook is the only one that fires. The launcher reads the same plugin evidence `hs doctor`'s
64
+ `hook-double-fire` check does; `enabledPlugins["heyspex@..."] === false` keeps the repo rows running,
65
+ and `HEYSPEX_REPO_HOOKS=1` forces them. `.github/hooks/*.json` rows do not use the launcher, so for
66
+ those the plugin-or-hooks choice below stands.
67
+
68
+ **Option A: the plugin (recommended).** One command registers the marketplace shipped inside the
69
+ package and installs the plugin:
70
+
71
+ ```bash
72
+ npx heyspex setup copilot
73
+ ```
74
+
75
+ (`npx hs install --target . --copilot-plugin-apply` does the same.) By hand, the equivalent Copilot commands are:
76
+
77
+ ```bash
78
+ copilot plugin marketplace add ./node_modules/heyspex
79
+ copilot plugin install heyspex@heyspex-marketplace
80
+ copilot plugin list
81
+ ```
82
+
83
+ `./node_modules/heyspex/.claude-plugin/marketplace.json` is a Claude-format marketplace named
84
+ `heyspex-marketplace`; its plugin `source` (`./plugins/heyspex`) resolves inside the package.
85
+ `npx hs install --target . --copilot-plugin` (no `-apply`) only prints these commands.
86
+
87
+ **Option B: repo hooks, for teammates and the Copilot cloud agent.** Writes
88
+ `.github/hooks/heyspex.json` into your repo; commit it. Each command runs
89
+ `node_modules/heyspex/scripts/claude-hooks/_run.mjs` and exits 0 if the package is not installed,
90
+ so a checkout without `npm install` is never blocked.
91
+
92
+ ```bash
93
+ npx heyspex setup copilot --hooks
94
+ ```
95
+
96
+ (`npx hs install --target . --copilot-hooks` does the same.) `setup copilot --hooks` refuses when the plugin is already installed. If you pass `--copilot-hooks` together with `--copilot-plugin[-apply]`, the installer warns and
97
+ skips the hooks file.
98
+
99
+ Then restart the Copilot session (`/restart`) so hooks load, and verify:
100
+
101
+ ```bash
102
+ copilot plugin list # Option A: heyspex is enabled
103
+ npx hs doctor # MCP, hooks and account surfaces healthy
104
+ ```
105
+
106
+ ## 3. What the plugin loads
107
+
108
+ | Component | Source | Behaviour under Copilot |
109
+ | --- | --- | --- |
110
+ | Hooks | `node_modules/heyspex/plugins/heyspex/hooks/hooks.json` | PreToolUse, PostToolUse, Stop, UserPromptSubmit and SessionStart gates. Every command locates the runtime itself and exits 0 if it cannot, so a missing variable never denies a tool call. A real deny arrives as a top-level `permissionDecision` with a reason. |
111
+ | MCP server | `node_modules/heyspex/plugins/heyspex/.mcp.json` | The `heyspex_*` vault tools and `hs-*` prompts. |
112
+ | Slash commands | not loaded | Claude Code commands are not a Copilot component. Use MCP prompts or the `hs` CLI. |
113
+
114
+ ## 4. Verify the install
115
+
116
+ 1. In a Copilot session inside any repo, run a harmless tool call, for example read a file. It
117
+ must succeed. A message containing "Denied by preToolUse hook" means a hook failed; go to
118
+ section 7.
119
+ 2. Confirm the MCP server is up by listing MCP servers in Copilot (`/mcp`) and calling
120
+ `heyspex_recall_memories` with `{ "limit": 3 }`. If the server is missing, go to section 7.
121
+ 3. Confirm the gates work: send a prompt that contains a new product idea of more than 60
122
+ characters, then try to edit a source file without capturing. The edit should be refused with a
123
+ reason that names `directive-obligation-gate`. Call `heyspex_update_capture` with the prompt
124
+ text, then retry the edit. It should pass.
125
+
126
+ ## 5. Turning HeySpex off and on
127
+
128
+ Run from the repo you are working in:
129
+
130
+ ```bash
131
+ hs mode status # on | off, and why
132
+ hs mode off # every hook exits 0 immediately, no restart needed
133
+ hs mode on
134
+ hs mode toggle
135
+ ```
136
+
137
+ Use `npx hs mode off` when `hs` is not on PATH. The switch writes
138
+ `.heyspex/mode.json` in the project and is git-ignored.
139
+
140
+ Per-shell variants that touch no files:
141
+
142
+ | Variable | Effect |
143
+ | --- | --- |
144
+ | `HEYSPEX_MODE=off` | Silences hooks for every harness in that shell |
145
+ | `HEYSPEX_COPILOT_HOOKS_OFF=1` | Silences hooks only when the caller is Copilot; Claude Code and Cursor keep theirs |
146
+
147
+ The config twin of the Copilot switch is `agent_behaviors.harness_hooks.copilot.enabled: false` in
148
+ the vault's `.heyspex/config.yaml`.
149
+
150
+ Four security gates ignore all of these by design: `env-vault-guard`, `research-method-guard`,
151
+ `research-protocol-gate` and `git-identity-guard`. They only act on secret writes, built-in
152
+ deep-research skills, unprotocolled web research and git identity changes.
153
+
154
+ ## 6. Everyday loop
155
+
156
+ With MCP available: `heyspex_next_on_deck`, `heyspex_claim_spec`, `heyspex_report_progress`,
157
+ `heyspex_submit_for_review`. Without MCP, the `hs` CLI (`npx hs`) covers the same loop; see
158
+ `docs/driving-heyspex-from-copilot.md`.
159
+
160
+ ## 7. Troubleshooting
161
+
162
+ - **Every tool call is denied.** Run `hs mode off` to unblock immediately, then capture the exact
163
+ deny text and the hook command it names. If the command still starts with
164
+ `node "$CLAUDE_PROJECT_DIR/...`, the package is old; run `npm install heyspex@latest` and reinstall the plugin.
165
+ - **MCP server does not start.** Copilot documents `${PLUGIN_ROOT}` for its own plugin format, and
166
+ whether it expands `${CLAUDE_PLUGIN_ROOT}` in a Claude-format plugin is unverified. Register the
167
+ server explicitly:
168
+
169
+ ```bash
170
+ copilot mcp add heyspex -- node ./node_modules/heyspex/plugins/heyspex/bin/launch-mcp.mjs
171
+ ```
172
+
173
+ - **A hook denies with no reason shown.** That is a hook exiting 2 the old way. Report the hook
174
+ name; it should be answering in Copilot's JSON format.
175
+ - **Hooks run twice.** The repo you are in also carries HeySpex rows in its own
176
+ `.claude/settings.json` from `hs install`. Use either the plugin or the install kit (or `.github/hooks`) in one repo,
177
+ not both.
178
+
179
+ ## 8. Report back
180
+
181
+ State the Copilot CLI version, the output of `copilot plugin list`, the result of the three checks
182
+ in section 4, and the exact text of any deny or MCP error.
183
+
184
+ ## Status of this document
185
+
186
+ The install commands come from GitHub's plugin reference, and the hook behaviour was verified by
187
+ replaying Copilot-shaped payloads through the registered commands, not by a live Copilot session.
188
+ The first agent that completes section 4 is the real test. Fix history: diagnose HS-20SW and
189
+ capture HS-HNO1 (2026-10-16).