@mickey-kras/hindsight-memory-router-coding-agents 0.0.0-stage → 0.8.2

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 (71) hide show
  1. package/DEVIATIONS.md +49 -0
  2. package/LICENSE +23 -0
  3. package/README.md +57 -2
  4. package/UPSTREAM.json +263 -0
  5. package/cordis.patch.yml +18 -0
  6. package/dist/antigravity-hook.js +5661 -0
  7. package/dist/antigravity-statusline.js +1329 -0
  8. package/dist/antigravity-stop-hook.js +5854 -0
  9. package/dist/claude-hook.js +5661 -0
  10. package/dist/claude-sessionstart-hook.js +6344 -0
  11. package/dist/claude-stop-hook.js +5854 -0
  12. package/dist/cline.js +24927 -0
  13. package/dist/codebuddy-hook.js +5661 -0
  14. package/dist/codebuddy-sessionstart-hook.js +6344 -0
  15. package/dist/codebuddy-stop-hook.js +5854 -0
  16. package/dist/codex-hook.js +5661 -0
  17. package/dist/codex-sessionstart-hook.js +6344 -0
  18. package/dist/codex-stop-hook.js +5854 -0
  19. package/dist/copilot-hook.js +5661 -0
  20. package/dist/copilot-sessionstart-hook.js +6344 -0
  21. package/dist/copilot-stop-hook.js +5854 -0
  22. package/dist/cursor-hook.js +5661 -0
  23. package/dist/cursor-sessionstart-hook.js +6344 -0
  24. package/dist/cursor-stop-hook.js +5854 -0
  25. package/dist/daemon-start.js +13 -0
  26. package/dist/dcode-hook.js +5661 -0
  27. package/dist/dcode-sessionstart-hook.js +6344 -0
  28. package/dist/dcode-stop-hook.js +5854 -0
  29. package/dist/deepen.js +3115 -0
  30. package/dist/devin-hook.js +5661 -0
  31. package/dist/devin-sessionstart-hook.js +6344 -0
  32. package/dist/devin-stop-hook.js +5854 -0
  33. package/dist/droid-hook.js +5661 -0
  34. package/dist/droid-sessionstart-hook.js +6344 -0
  35. package/dist/droid-stop-hook.js +5854 -0
  36. package/dist/dsh.js +25049 -0
  37. package/dist/grok-hook.js +5661 -0
  38. package/dist/grok-sessionstart-hook.js +6344 -0
  39. package/dist/grok-stop-hook.js +5854 -0
  40. package/dist/hindsight-seed.js +1131 -0
  41. package/dist/index.d.ts +5 -0
  42. package/dist/index.js +37456 -0
  43. package/dist/installer.js +9025 -0
  44. package/dist/kilo.js +37456 -0
  45. package/dist/kimi-hook.js +5661 -0
  46. package/dist/kimi-sessionstart-hook.js +6344 -0
  47. package/dist/kimi-stop-hook.js +5854 -0
  48. package/dist/mcp-server.js +39650 -0
  49. package/dist/opencode2.js +37415 -0
  50. package/dist/pi.js +24995 -0
  51. package/dist/prime-agent.js +24995 -0
  52. package/dist/qwen-hook.js +5661 -0
  53. package/dist/qwen-sessionstart-hook.js +6344 -0
  54. package/dist/qwen-stop-hook.js +5854 -0
  55. package/dist/status.js +2516 -0
  56. package/dist/survey-supervisor.js +81 -0
  57. package/dist/traecode-hook.js +5661 -0
  58. package/dist/traecode-sessionstart-hook.js +6344 -0
  59. package/dist/traecode-stop-hook.js +5854 -0
  60. package/dist/workbuddy-hook.js +5661 -0
  61. package/dist/workbuddy-sessionstart-hook.js +6344 -0
  62. package/dist/workbuddy-stop-hook.js +5854 -0
  63. package/dist/zcode-hook.js +5661 -0
  64. package/dist/zcode-sessionstart-hook.js +6344 -0
  65. package/dist/zcode-stop-hook.js +5854 -0
  66. package/hooks/hooks.json +37 -0
  67. package/index.js +10 -0
  68. package/npm-shrinkwrap.json +7354 -0
  69. package/package.json +123 -4
  70. package/plugin.json +16 -0
  71. package/skill/SKILL.md +134 -0
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/core/survey-lease.ts
4
+ import { spawn as realSpawn } from "child_process";
5
+ import { randomUUID } from "crypto";
6
+ import {
7
+ mkdirSync,
8
+ mkdtempSync,
9
+ readdirSync,
10
+ renameSync,
11
+ rmdirSync,
12
+ rmSync,
13
+ statSync,
14
+ unlinkSync,
15
+ utimesSync,
16
+ writeFileSync
17
+ } from "fs";
18
+ import { join } from "path";
19
+ var LEASE_HEARTBEAT_MS = 5e3;
20
+ var SURVEY_SPEC_ENV = "HINDSIGHT_SURVEY_SPEC";
21
+ function releaseLease(lease) {
22
+ try {
23
+ unlinkSync(join(lease.directory, lease.owner));
24
+ } catch {
25
+ return;
26
+ }
27
+ try {
28
+ rmdirSync(lease.directory);
29
+ } catch {
30
+ }
31
+ }
32
+ function heartbeatLease(lease) {
33
+ try {
34
+ const now = /* @__PURE__ */ new Date();
35
+ utimesSync(join(lease.directory, lease.owner), now, now);
36
+ return true;
37
+ } catch (error) {
38
+ return error.code !== "ENOENT";
39
+ }
40
+ }
41
+ function superviseSurvey(spec2, spawnFn = realSpawn) {
42
+ let stop = () => {
43
+ };
44
+ const done = new Promise((resolve) => {
45
+ if (!heartbeatLease(spec2.lease)) return resolve();
46
+ let child;
47
+ try {
48
+ child = spawnFn(spec2.bin, spec2.args, { stdio: "ignore", windowsHide: true });
49
+ } catch {
50
+ releaseLease(spec2.lease);
51
+ return resolve();
52
+ }
53
+ let finished = false;
54
+ const finish = (release) => {
55
+ if (finished) return;
56
+ finished = true;
57
+ clearInterval(timer);
58
+ if (release) releaseLease(spec2.lease);
59
+ resolve();
60
+ };
61
+ const timer = setInterval(() => {
62
+ if (heartbeatLease(spec2.lease)) return;
63
+ child.kill();
64
+ finish(false);
65
+ }, spec2.heartbeatMs ?? LEASE_HEARTBEAT_MS);
66
+ child.on("error", () => finish(true));
67
+ child.once("exit", () => finish(true));
68
+ stop = () => {
69
+ child.kill();
70
+ finish(true);
71
+ };
72
+ });
73
+ return { done, stop: () => stop() };
74
+ }
75
+
76
+ // src/survey-supervisor.ts
77
+ var spec = JSON.parse(process.env[SURVEY_SPEC_ENV] ?? "");
78
+ delete process.env[SURVEY_SPEC_ENV];
79
+ var run = superviseSurvey(spec);
80
+ for (const signal of ["SIGTERM", "SIGINT", "SIGHUP"]) process.once(signal, run.stop);
81
+ void run.done;