heyspex 0.2.5 → 0.2.7

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 (110) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/bin/hs.mjs +349 -38
  3. package/bin/spexcode.mjs +31 -0
  4. package/dev-factory/lib/dispatch-guard.mjs +75 -0
  5. package/dev-factory/lib/local-firecrawl.mjs +294 -0
  6. package/dev-factory/lib/runner-path.mjs +51 -0
  7. package/dev-factory/lib/seat-context.mjs +20 -4
  8. package/dev-factory/model-catalog.json +222 -222
  9. package/dev-factory/spexcrawl/firecrawl-cli.mjs +755 -0
  10. package/dev-factory/spexcrawl/spexcrawl-cli.mjs +734 -0
  11. package/dist/cli/hs-connect.mjs +40 -3
  12. package/dist/cli/hs-defer.mjs +3817 -3741
  13. package/dist/cli/hs-events.mjs +1296 -0
  14. package/dist/cli/hs-export-events.mjs +1252 -0
  15. package/dist/cli/hs-handoff.mjs +2576 -0
  16. package/dist/cli/hs-index-rebuild.mjs +228 -37
  17. package/dist/cli/hs-index-reconcile.mjs +231 -40
  18. package/dist/cli/hs-init.mjs +22 -3
  19. package/dist/cli/hs-install.mjs +22 -3
  20. package/dist/cli/hs-join.mjs +40 -3
  21. package/dist/cli/hs-next-launch.mjs +2777 -0
  22. package/dist/cli/hs-pin.mjs +1336 -0
  23. package/dist/cli/hs-prereq.mjs +1380 -0
  24. package/dist/cli/hs-revalidate.mjs +3257 -0
  25. package/dist/cli/hs-spawn.mjs +12403 -0
  26. package/dist/cli/hs-test.mjs +1046 -0
  27. package/dist/cli/hs-trash.mjs +362 -0
  28. package/dist/cli/hs-trust.mjs +197 -0
  29. package/dist/cli/hs-vault-pull.mjs +233 -42
  30. package/dist/cli/hs-vault-push.mjs +231 -40
  31. package/dist/cli/hs-vault.mjs +21 -7
  32. package/dist/cli/hs-workspace.mjs +19 -1
  33. package/dist/cli-templates/customer-vault/specs/entity-model.md +1728 -1728
  34. package/dist/cli-templates/customer-vault/specs/protocols/canonical-frontmatter-templates.md +464 -464
  35. package/dist/cli-templates/customer-vault/specs/protocols/destructive-action-checklist.md +122 -122
  36. package/dist/cli-templates/customer-vault/specs/protocols/memory-protocol.md +46 -46
  37. package/dist/cli-templates/customer-vault/specs/protocols/spec-hierarchy.md +530 -530
  38. package/dist/cli-templates/customer-vault/specs/protocols/spec-summary-authoring.md +83 -83
  39. package/dist/cli-templates/harness-commands/claude/hs-backfill.md +28 -28
  40. package/dist/cli-templates/harness-commands/claude/hs-capture.md +62 -62
  41. package/dist/cli-templates/harness-commands/claude/hs-defer.md +29 -29
  42. package/dist/cli-templates/harness-commands/claude/hs-ground.md +30 -30
  43. package/dist/cli-templates/harness-commands/claude/hs-next.md +29 -29
  44. package/dist/cli-templates/harness-commands/claude/hs-promote.md +70 -70
  45. package/dist/cli-templates/harness-commands/claude/hs-push.md +35 -35
  46. package/dist/cli-templates/harness-commands/claude/hs-qc.md +27 -27
  47. package/dist/cli-templates/harness-commands/claude/hs-res.md +83 -63
  48. package/dist/cli-templates/harness-commands/claude/hs-resolve.md +23 -23
  49. package/dist/cli-templates/harness-commands/claude/hs-view.md +28 -28
  50. package/dist/cli-templates/harness-commands/claude/kill-ports.md +32 -32
  51. package/dist/cli-templates/harness-commands/claude/prototype.md +91 -91
  52. package/dist/cli-templates/harness-commands/cursor/hs-backfill.md +22 -22
  53. package/dist/cli-templates/harness-commands/cursor/hs-capture.md +56 -56
  54. package/dist/cli-templates/harness-commands/cursor/hs-defer.md +23 -23
  55. package/dist/cli-templates/harness-commands/cursor/hs-ground.md +24 -24
  56. package/dist/cli-templates/harness-commands/cursor/hs-next.md +23 -23
  57. package/dist/cli-templates/harness-commands/cursor/hs-promote.md +64 -64
  58. package/dist/cli-templates/harness-commands/cursor/hs-push.md +29 -29
  59. package/dist/cli-templates/harness-commands/cursor/hs-qc.md +21 -21
  60. package/dist/cli-templates/harness-commands/cursor/hs-res.md +78 -58
  61. package/dist/cli-templates/harness-commands/cursor/hs-resolve.md +17 -17
  62. package/dist/cli-templates/harness-commands/cursor/hs-view.md +23 -23
  63. package/dist/cli-templates/harness-commands/cursor/kill-ports.md +26 -26
  64. package/dist/cli-templates/harness-commands/cursor/prototype.md +86 -86
  65. package/docs/copilot-plugin-install.md +9 -2
  66. package/docs/mcp-client-config.md +6 -0
  67. package/package.json +266 -257
  68. package/plugins/heyspex/.claude-plugin/plugin.json +1 -1
  69. package/plugins/heyspex/.cursor-plugin/plugin.json +1 -1
  70. package/plugins/heyspex/README.md +6 -0
  71. package/plugins/heyspex/bin/launch-mcp.mjs +17 -0
  72. package/plugins/heyspex/hooks/hooks.json +418 -418
  73. package/scripts/claude-hooks/_intent-classifier-semantic.mjs +2 -2
  74. package/scripts/claude-hooks/wip-checkpoint.mjs +17 -2
  75. package/scripts/claude-statusline/statusline-command.mjs +287 -27
  76. package/scripts/hs-companion.mjs +41 -3
  77. package/scripts/install-claude-code-hooks.mjs +104 -3
  78. package/scripts/install-copilot-hooks.mjs +21 -1
  79. package/scripts/install-cursor-hooks.mjs +4 -3
  80. package/scripts/lib/capture-execution-guard.mjs +221 -0
  81. package/scripts/lib/companion-install.mjs +768 -0
  82. package/scripts/lib/customer-kit.mjs +53 -3
  83. package/scripts/lib/hs-companion-settings.mjs +26 -0
  84. package/scripts/lib/hs-source-push.mjs +386 -386
  85. package/scripts/record-grounding.mjs +38 -0
  86. package/spexharness/doctrine/baseline/SPEXCODE-DOCTRINE.baseline.json +29 -29
  87. package/spexharness/src/adapters/copilot-models.mjs +179 -0
  88. package/spexharness/src/adapters/harness-detect.mjs +148 -0
  89. package/spexharness/src/gates/directive-obligation-gate.decide.mjs +132 -132
  90. package/spexharness/src/gates/vault-write-tier-guard.decide.mjs +153 -125
  91. package/spexharness/src/seat-context.mjs +10 -5
  92. package/spexharness/src/session-bootstrap.mjs +6 -3
  93. package/vendor/heyspex-mcp/cli.mjs +6 -1
  94. package/vendor/heyspex-mcp/config-seed.yaml +15 -15
  95. package/vendor/heyspex-mcp/dev-factory-overlay.mjs +142 -0
  96. package/vendor/heyspex-mcp/http-transport.mjs +1 -1
  97. package/vendor/heyspex-mcp/memory-tools.mjs +523 -523
  98. package/vendor/heyspex-mcp/on-deck-scheduler.mjs +1708 -1708
  99. package/vendor/heyspex-mcp/procedure-handlers.mjs +327 -327
  100. package/vendor/heyspex-mcp/procedure-tools.mjs +1209 -1181
  101. package/vendor/heyspex-mcp/research-tools.mjs +22 -2
  102. package/vendor/heyspex-mcp/seat-assign-cli.mjs +242 -0
  103. package/vendor/heyspex-mcp/seat-assignment-rules.mjs +96 -0
  104. package/vendor/heyspex-mcp/seat-assignments-client.mjs +265 -0
  105. package/vendor/heyspex-mcp/seat-defaults-cli.mjs +45 -0
  106. package/vendor/heyspex-mcp/seat-defaults.mjs +232 -0
  107. package/vendor/heyspex-mcp/seat-identity.mjs +171 -0
  108. package/vendor/heyspex-mcp/test-helpers.mjs +37 -23
  109. package/vendor/heyspex-mcp/vault-io.mjs +720 -720
  110. package/bin/postinstall.mjs +0 -88
@@ -209,7 +209,7 @@ export const COMMAND_SCOPES = Object.freeze({
209
209
  'hs-promote.md': { scope: 'customer', why: 'Capture → research → milestone promotion.' },
210
210
  'hs-push.md': { scope: 'customer', why: 'Push an epic plan into the vault.' },
211
211
  'hs-qc.md': { scope: 'customer', why: 'Post-plan QC gate.' },
212
- 'hs-res.md': { scope: 'customer', why: 'Research method entrypoint (SpexCrawl/DeepSeek).' },
212
+ 'hs-res.md': { scope: 'customer', why: 'Research method entrypoint (local Docker Firecrawl search + SpexCrawl/Firecrawl fetch; DeepSeek on the platform).' },
213
213
  'hs-resolve.md': { scope: 'customer', why: 'Resolution lane.' },
214
214
  'hs-review.md': { scope: 'customer', why: 'Review queue.' },
215
215
  'hs-view.md': { scope: 'customer', why: 'Open a console surface.' },
@@ -860,13 +860,15 @@ export function githubHookNames() {
860
860
  }
861
861
 
862
862
  /**
863
- * The bash command for one hook: resolve the runtime from node_modules/heyspex first, then the checkout's own
864
- * scripts/, else exit 0 (fail open; Copilot turns any non-zero exit into a deny).
863
+ * The bash command for one hook: stamp the harness (HS-OMQF: these commands only ever run under Copilot, so
864
+ * HEYSPEX_HARNESS=copilot unless the developer already set one), resolve the runtime from node_modules/heyspex
865
+ * first, then the checkout's own scripts/, else exit 0 (fail open; Copilot turns any non-zero exit into a deny).
865
866
  * @param {{ hook: string, args?: string[] }} row
866
867
  */
867
868
  export function githubHookCommand(row) {
868
869
  const tail = hookTail(row);
869
870
  return (
871
+ 'export HEYSPEX_HARNESS="${HEYSPEX_HARNESS:-copilot}"; ' +
870
872
  'R=node_modules/heyspex/scripts/claude-hooks/_run.mjs; ' +
871
873
  '[ -f "$R" ] || R=./scripts/claude-hooks/_run.mjs; ' +
872
874
  '[ -f "$R" ] || exit 0; ' +
@@ -1326,6 +1328,54 @@ export function auditCustomerKit({ targetRoot, platformRoot, deps = fsDeps }) {
1326
1328
  return report;
1327
1329
  }
1328
1330
 
1331
+ // ---------------------------------------------------------------------------
1332
+ // Which repo `hs setup <agent>` writes into
1333
+ // ---------------------------------------------------------------------------
1334
+
1335
+ /**
1336
+ * The project root a setup verb acts on: the nearest directory at/above
1337
+ * `start` holding `.git` or `heyspex.yaml`, else `start` itself. Same walk
1338
+ * `hs setup copilot` uses.
1339
+ * @param {string} start
1340
+ */
1341
+ export function findProjectRoot(start) {
1342
+ let dir = path.resolve(start);
1343
+ for (;;) {
1344
+ if (fs.existsSync(path.join(dir, '.git')) || fs.existsSync(path.join(dir, 'heyspex.yaml'))) return dir;
1345
+ const up = path.dirname(dir);
1346
+ if (up === dir) return path.resolve(start);
1347
+ dir = up;
1348
+ }
1349
+ }
1350
+
1351
+ /**
1352
+ * True when `platformRoot` is an installed `heyspex` package (under a
1353
+ * node_modules/ folder, or missing the source-checkout-only
1354
+ * scripts/heyspex-doctor.mjs) rather than a HeySpex source checkout.
1355
+ * @param {string} platformRoot
1356
+ * @param {(p: string) => boolean} [exists]
1357
+ */
1358
+ export function isInstalledPackageRoot(platformRoot, exists = fs.existsSync) {
1359
+ if (toPosixPath(path.resolve(platformRoot)).includes('/node_modules/')) return true;
1360
+ return !exists(path.join(platformRoot, 'scripts', 'heyspex-doctor.mjs'));
1361
+ }
1362
+
1363
+ /**
1364
+ * The repo a hook installer (`install-claude-code-hooks.mjs`,
1365
+ * `install-cursor-hooks.mjs`) writes into. An explicit HS_SETUP_TARGET (what
1366
+ * `hs setup` / `hs doctor --fix` pass) wins; with none, a source checkout
1367
+ * targets itself (the dev `npm install` / `npm run hooks:*` path) but an
1368
+ * INSTALLED package targets the customer's project found from cwd -- never
1369
+ * its own package folder under node_modules/.
1370
+ * @param {{ platformRoot: string, env?: Record<string, string | undefined>, cwd?: string, exists?: (p: string) => boolean }} opts
1371
+ */
1372
+ export function resolveSetupTarget({ platformRoot, env = process.env, cwd = process.cwd(), exists = fs.existsSync }) {
1373
+ const explicit = env.HS_SETUP_TARGET?.trim();
1374
+ if (explicit) return path.resolve(explicit);
1375
+ if (isInstalledPackageRoot(platformRoot, exists)) return findProjectRoot(cwd);
1376
+ return path.resolve(platformRoot);
1377
+ }
1378
+
1329
1379
  // ---------------------------------------------------------------------------
1330
1380
  // CLI: regenerate plugins/heyspex/hooks/hooks.json
1331
1381
  // ---------------------------------------------------------------------------
@@ -105,6 +105,31 @@ export const COMPANION_ALIASES = {
105
105
 
106
106
  export const HOST_COMMANDS = ["start", "stop", "status", "build"];
107
107
 
108
+ /**
109
+ * What `hs companion start|stop|status|build` prints when run from an
110
+ * installed `heyspex` npm package: the tray app's source (companion/) is not
111
+ * in the tarball, so there is no start.ps1 to run. Says plainly that the
112
+ * Companion is not distributed through npm yet (a Windows installer is
113
+ * planned, research HS-AUY9) and what degrades without it, with the
114
+ * workaround for each. The dev (repo checkout) path never reaches this.
115
+ * @param {string} sub the host subcommand the caller asked for
116
+ */
117
+ export function renderCompanionNotDistributed(sub) {
118
+ return [
119
+ `hs companion ${sub}: the HeySpex Companion (desktop tray app) is not distributed through the`,
120
+ "heyspex npm package yet; a Windows installer is planned (research HS-AUY9).",
121
+ "",
122
+ "Everything else in this package works without it. What you lose until then:",
123
+ " - Automatic vault mirror (cloud <-> disk sync): run `npx hs pull --apply` to bring",
124
+ " cloud-written specs down (and `npx hs push --apply` to send local edits up).",
125
+ " - SpexVoice (voice capture and spoken commands): not available.",
126
+ " - SpexCrawl research gather (/hs-res): its gather jobs need the Companion, so they",
127
+ " report SPEXCRAWL_UNAVAILABLE.",
128
+ "",
129
+ "`hs companion settings ...` (console-backed) still works.",
130
+ ].join("\n");
131
+ }
132
+
108
133
  const TRUE_WORDS = new Set(["true", "on", "yes", "1", "enabled"]);
109
134
  const FALSE_WORDS = new Set(["false", "off", "no", "0", "disabled"]);
110
135
  const NULL_WORDS = new Set(["null", "none"]);
@@ -464,6 +489,7 @@ export function renderHelp(topic = "companion") {
464
489
  " hs companion stop Quit the tray app",
465
490
  " hs companion status Is it running?",
466
491
  " hs companion build dotnet build Debug",
492
+ " hs companion install [--quiet] [--dry-run] Download, verify and run the signed SpexCompanion setup (Windows x64)",
467
493
  "",
468
494
  ...settingsLines,
469
495
  "",