hippo-memory 1.60.0 → 1.62.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/README.md +29 -54
- package/dist/ablation.js +9 -27
- package/dist/agent-memories/apply.d.ts +1 -1
- package/dist/agent-memories/apply.js +4 -1
- package/dist/agent-memories/claude-code.d.ts +3 -1
- package/dist/agent-memories/claude-code.js +54 -10
- package/dist/agent-memories/codex.js +1 -1
- package/dist/agent-memories/gemini.js +1 -1
- package/dist/agent-memories/legacy.js +1 -1
- package/dist/agent-memories/source.js +1 -1
- package/dist/agent-memories/sync.d.ts +3 -3
- package/dist/agent-memories/sync.js +22 -9
- package/dist/agent-memories/types.d.ts +0 -2
- package/dist/ambient-store.d.ts +14 -0
- package/dist/ambient-store.js +90 -0
- package/dist/ambient.d.ts +23 -0
- package/dist/ambient.js +72 -50
- package/dist/api/assemble.d.ts +93 -0
- package/dist/api/assemble.js +153 -0
- package/dist/api/audit.d.ts +17 -0
- package/dist/api/audit.js +23 -0
- package/dist/api/auth.d.ts +79 -0
- package/dist/api/auth.js +178 -0
- package/dist/api/context-select.d.ts +49 -0
- package/dist/api/context-select.js +344 -0
- package/dist/api/context-types.d.ts +105 -0
- package/dist/api/context-types.js +3 -0
- package/dist/api/context.d.ts +31 -0
- package/dist/api/context.js +378 -0
- package/dist/api/dormant.d.ts +30 -0
- package/dist/api/dormant.js +140 -0
- package/dist/api/drill-down.d.ts +84 -0
- package/dist/api/drill-down.js +126 -0
- package/dist/api/forget.d.ts +57 -0
- package/dist/api/forget.js +87 -0
- package/dist/api/goals.d.ts +18 -0
- package/dist/api/goals.js +33 -0
- package/dist/api/learn.d.ts +31 -0
- package/dist/api/learn.js +88 -0
- package/dist/api/outcome.d.ts +61 -0
- package/dist/api/outcome.js +66 -0
- package/dist/api/promote.d.ts +54 -0
- package/dist/api/promote.js +192 -0
- package/dist/api/quarantine.d.ts +24 -0
- package/dist/api/quarantine.js +121 -0
- package/dist/api/recall-types.d.ts +390 -0
- package/dist/api/recall-types.js +3 -0
- package/dist/api/recall.d.ts +36 -0
- package/dist/api/recall.js +499 -0
- package/dist/api/remember.d.ts +35 -0
- package/dist/api/remember.js +43 -0
- package/dist/api/sleep.d.ts +136 -0
- package/dist/api/sleep.js +256 -0
- package/dist/api/tokens.d.ts +26 -0
- package/dist/api/tokens.js +60 -0
- package/dist/api/types.d.ts +56 -0
- package/dist/api/types.js +38 -0
- package/dist/api.d.ts +20 -1262
- package/dist/api.js +25 -2727
- package/dist/audit.d.ts +3 -0
- package/dist/audit.js +6 -3
- package/dist/auth.d.ts +45 -4
- package/dist/auth.js +125 -48
- package/dist/autolearn.js +2 -2
- package/dist/capture/command.d.ts +33 -0
- package/dist/capture/command.js +264 -0
- package/dist/capture/compact.d.ts +44 -0
- package/dist/capture/compact.js +354 -0
- package/dist/capture/extract.d.ts +21 -0
- package/dist/capture/extract.js +464 -0
- package/dist/capture/transcript.d.ts +40 -0
- package/dist/capture/transcript.js +193 -0
- package/dist/capture-error.js +2 -1
- package/dist/churn-git.js +4 -2
- package/dist/cli/audit.d.ts +3 -0
- package/dist/cli/audit.js +159 -0
- package/dist/cli/auth.d.ts +2 -0
- package/dist/cli/auth.js +171 -0
- package/dist/cli/briefs.d.ts +4 -0
- package/dist/cli/briefs.js +453 -0
- package/dist/cli/card.d.ts +3 -0
- package/dist/cli/card.js +333 -0
- package/dist/cli/context.d.ts +15 -0
- package/dist/cli/context.js +376 -0
- package/dist/cli/continuity.d.ts +6 -0
- package/dist/cli/continuity.js +457 -0
- package/dist/cli/curate.d.ts +19 -0
- package/dist/cli/curate.js +556 -0
- package/dist/cli/dag.d.ts +5 -0
- package/dist/cli/dag.js +177 -0
- package/dist/cli/decisions.d.ts +4 -0
- package/dist/cli/decisions.js +528 -0
- package/dist/cli/eval.d.ts +5 -0
- package/dist/cli/eval.js +213 -0
- package/dist/cli/explain.d.ts +4 -0
- package/dist/cli/explain.js +156 -0
- package/dist/cli/goals.d.ts +2 -0
- package/dist/cli/goals.js +196 -0
- package/dist/cli/hook-blocks.d.ts +18 -0
- package/dist/cli/hook-blocks.js +233 -0
- package/dist/cli/init.d.ts +2 -0
- package/dist/cli/init.js +305 -0
- package/dist/cli/maintenance.d.ts +4 -0
- package/dist/cli/maintenance.js +190 -0
- package/dist/cli/playbooks.d.ts +4 -0
- package/dist/cli/playbooks.js +573 -0
- package/dist/cli/projects.js +9 -6
- package/dist/cli/recall.d.ts +7 -0
- package/dist/cli/recall.js +582 -0
- package/dist/cli/remember.d.ts +5 -0
- package/dist/cli/remember.js +485 -0
- package/dist/cli/serve.d.ts +5 -0
- package/dist/cli/serve.js +40 -0
- package/dist/cli/session-hooks.d.ts +29 -0
- package/dist/cli/session-hooks.js +647 -0
- package/dist/cli/setup.d.ts +4 -0
- package/dist/cli/setup.js +397 -0
- package/dist/cli/shared.d.ts +15 -19
- package/dist/cli/shared.js +50 -341
- package/dist/cli/slack.d.ts +2 -0
- package/dist/cli/slack.js +171 -0
- package/dist/cli/status.d.ts +18 -0
- package/dist/cli/status.js +409 -0
- package/dist/cli/transfer.d.ts +10 -0
- package/dist/cli/transfer.js +424 -0
- package/dist/cli/usage.d.ts +85 -0
- package/dist/cli/usage.js +741 -0
- package/dist/cli.d.ts +71 -120
- package/dist/cli.js +170 -8469
- package/dist/client.js +15 -8
- package/dist/compaction-record.d.ts +0 -2
- package/dist/compaction-record.js +7 -5
- package/dist/connectors/github/backfill.js +94 -87
- package/dist/connectors/github/cli-impl.js +4 -3
- package/dist/connectors/github/dlq.js +67 -54
- package/dist/connectors/github/ingest.js +34 -35
- package/dist/connectors/github/tenant-routing.js +3 -2
- package/dist/connectors/github/webhook.js +135 -216
- package/dist/connectors/slack/dlq.js +49 -61
- package/dist/connectors/slack/ingest.js +55 -48
- package/dist/connectors/slack/tenant-routing.js +4 -3
- package/dist/connectors/slack/webhook.js +72 -74
- package/dist/consolidate/conflicts.d.ts +10 -0
- package/dist/consolidate/conflicts.js +178 -0
- package/dist/consolidate/decay.d.ts +12 -0
- package/dist/consolidate/decay.js +145 -0
- package/dist/consolidate/llm-passes.d.ts +3 -0
- package/dist/consolidate/llm-passes.js +141 -0
- package/dist/consolidate/merge.d.ts +7 -0
- package/dist/consolidate/merge.js +251 -0
- package/dist/consolidate/physics-pass.d.ts +3 -0
- package/dist/consolidate/physics-pass.js +60 -0
- package/dist/consolidate/run.d.ts +69 -0
- package/dist/consolidate/run.js +76 -0
- package/dist/consolidate/sleep.d.ts +18 -0
- package/dist/consolidate/sleep.js +209 -0
- package/dist/consolidate/traces.d.ts +4 -0
- package/dist/consolidate/traces.js +178 -0
- package/dist/context-auto.js +7 -11
- package/dist/context-render.d.ts +1 -1
- package/dist/context-render.js +1 -1
- package/dist/customer-notes.d.ts +3 -0
- package/dist/customer-notes.js +83 -72
- package/dist/dag.js +225 -188
- package/dist/dashboard-actions.d.ts +20 -0
- package/dist/dashboard-actions.js +88 -0
- package/dist/dashboard-params.d.ts +45 -0
- package/dist/dashboard-params.js +127 -0
- package/dist/dashboard-queries.d.ts +15 -0
- package/dist/dashboard-queries.js +355 -0
- package/dist/dashboard-snapshot.d.ts +138 -0
- package/dist/dashboard-snapshot.js +308 -0
- package/dist/dashboard-types.d.ts +163 -0
- package/dist/dashboard-types.js +3 -0
- package/dist/dashboard.d.ts +6 -7
- package/dist/dashboard.js +228 -202
- package/dist/db/busy.d.ts +5 -0
- package/dist/db/busy.js +24 -0
- package/dist/db/continuity.d.ts +5 -0
- package/dist/db/continuity.js +145 -0
- package/dist/db/meta.d.ts +8 -0
- package/dist/db/meta.js +35 -0
- package/dist/db/migrate.d.ts +9 -0
- package/dist/db/migrate.js +138 -0
- package/dist/db/migrations/index.d.ts +5 -0
- package/dist/db/migrations/index.js +109 -0
- package/dist/db/migrations/types.d.ts +14 -0
- package/dist/db/migrations/types.js +2 -0
- package/dist/db/migrations/v01.d.ts +3 -0
- package/dist/db/migrations/v01.js +38 -0
- package/dist/db/migrations/v02.d.ts +3 -0
- package/dist/db/migrations/v02.js +21 -0
- package/dist/db/migrations/v03.d.ts +3 -0
- package/dist/db/migrations/v03.js +22 -0
- package/dist/db/migrations/v04.d.ts +3 -0
- package/dist/db/migrations/v04.js +28 -0
- package/dist/db/migrations/v05.d.ts +3 -0
- package/dist/db/migrations/v05.js +21 -0
- package/dist/db/migrations/v06.d.ts +3 -0
- package/dist/db/migrations/v06.js +25 -0
- package/dist/db/migrations/v07.d.ts +3 -0
- package/dist/db/migrations/v07.js +13 -0
- package/dist/db/migrations/v08.d.ts +3 -0
- package/dist/db/migrations/v08.js +8 -0
- package/dist/db/migrations/v09.d.ts +3 -0
- package/dist/db/migrations/v09.js +13 -0
- package/dist/db/migrations/v10.d.ts +3 -0
- package/dist/db/migrations/v10.js +17 -0
- package/dist/db/migrations/v11.d.ts +3 -0
- package/dist/db/migrations/v11.js +15 -0
- package/dist/db/migrations/v12.d.ts +3 -0
- package/dist/db/migrations/v12.js +11 -0
- package/dist/db/migrations/v13.d.ts +3 -0
- package/dist/db/migrations/v13.js +15 -0
- package/dist/db/migrations/v14.d.ts +3 -0
- package/dist/db/migrations/v14.js +66 -0
- package/dist/db/migrations/v15.d.ts +3 -0
- package/dist/db/migrations/v15.js +42 -0
- package/dist/db/migrations/v16.d.ts +3 -0
- package/dist/db/migrations/v16.js +61 -0
- package/dist/db/migrations/v17.d.ts +3 -0
- package/dist/db/migrations/v17.js +46 -0
- package/dist/db/migrations/v18.d.ts +3 -0
- package/dist/db/migrations/v18.js +60 -0
- package/dist/db/migrations/v19.d.ts +3 -0
- package/dist/db/migrations/v19.js +28 -0
- package/dist/db/migrations/v20.d.ts +3 -0
- package/dist/db/migrations/v20.js +42 -0
- package/dist/db/migrations/v21.d.ts +3 -0
- package/dist/db/migrations/v21.js +16 -0
- package/dist/db/migrations/v22.d.ts +3 -0
- package/dist/db/migrations/v22.js +82 -0
- package/dist/db/migrations/v23.d.ts +3 -0
- package/dist/db/migrations/v23.js +48 -0
- package/dist/db/migrations/v24.d.ts +3 -0
- package/dist/db/migrations/v24.js +72 -0
- package/dist/db/migrations/v25.d.ts +3 -0
- package/dist/db/migrations/v25.js +46 -0
- package/dist/db/migrations/v26.d.ts +3 -0
- package/dist/db/migrations/v26.js +23 -0
- package/dist/db/migrations/v27.d.ts +3 -0
- package/dist/db/migrations/v27.js +57 -0
- package/dist/db/migrations/v28.d.ts +3 -0
- package/dist/db/migrations/v28.js +38 -0
- package/dist/db/migrations/v29.d.ts +3 -0
- package/dist/db/migrations/v29.js +78 -0
- package/dist/db/migrations/v30.d.ts +3 -0
- package/dist/db/migrations/v30.js +92 -0
- package/dist/db/migrations/v31.d.ts +3 -0
- package/dist/db/migrations/v31.js +74 -0
- package/dist/db/migrations/v32.d.ts +3 -0
- package/dist/db/migrations/v32.js +102 -0
- package/dist/db/migrations/v33.d.ts +3 -0
- package/dist/db/migrations/v33.js +104 -0
- package/dist/db/migrations/v34.d.ts +3 -0
- package/dist/db/migrations/v34.js +93 -0
- package/dist/db/migrations/v35.d.ts +3 -0
- package/dist/db/migrations/v35.js +98 -0
- package/dist/db/migrations/v36.d.ts +3 -0
- package/dist/db/migrations/v36.js +98 -0
- package/dist/db/migrations/v37.d.ts +3 -0
- package/dist/db/migrations/v37.js +219 -0
- package/dist/db/migrations/v38.d.ts +3 -0
- package/dist/db/migrations/v38.js +277 -0
- package/dist/db/migrations/v39.d.ts +3 -0
- package/dist/db/migrations/v39.js +59 -0
- package/dist/db/migrations/v40.d.ts +3 -0
- package/dist/db/migrations/v40.js +74 -0
- package/dist/db/migrations/v41.d.ts +3 -0
- package/dist/db/migrations/v41.js +43 -0
- package/dist/db/migrations/v42.d.ts +3 -0
- package/dist/db/migrations/v42.js +41 -0
- package/dist/db/migrations/v43.d.ts +3 -0
- package/dist/db/migrations/v43.js +67 -0
- package/dist/db/migrations/v44.d.ts +3 -0
- package/dist/db/migrations/v44.js +28 -0
- package/dist/db/migrations/v45.d.ts +3 -0
- package/dist/db/migrations/v45.js +30 -0
- package/dist/db/migrations/v46.d.ts +3 -0
- package/dist/db/migrations/v46.js +25 -0
- package/dist/db/migrations/v47.d.ts +3 -0
- package/dist/db/migrations/v47.js +17 -0
- package/dist/db/migrations/v48.d.ts +3 -0
- package/dist/db/migrations/v48.js +10 -0
- package/dist/db/migrations/v49.d.ts +3 -0
- package/dist/db/migrations/v49.js +31 -0
- package/dist/db/migrations/v50.d.ts +3 -0
- package/dist/db/migrations/v50.js +67 -0
- package/dist/db/migrations/v51.d.ts +3 -0
- package/dist/db/migrations/v51.js +14 -0
- package/dist/db/migrations/v52.d.ts +3 -0
- package/dist/db/migrations/v52.js +7 -0
- package/dist/db/open.d.ts +23 -0
- package/dist/db/open.js +146 -0
- package/dist/db/sqlite.d.ts +21 -0
- package/dist/db/sqlite.js +8 -0
- package/dist/db/tables.d.ts +7 -0
- package/dist/db/tables.js +38 -0
- package/dist/db.d.ts +6 -46
- package/dist/db.js +5 -3049
- package/dist/decisions.d.ts +4 -1
- package/dist/decisions.js +102 -83
- package/dist/dedupe.js +3 -2
- package/dist/delivery-recorder.js +4 -1
- package/dist/doctor.js +14 -10
- package/dist/embedding-provider.d.ts +1 -1
- package/dist/embedding-provider.js +4 -3
- package/dist/embeddings.d.ts +9 -52
- package/dist/embeddings.js +43 -297
- package/dist/env.d.ts +75 -0
- package/dist/env.js +119 -0
- package/dist/eval-suite.js +1 -1
- package/dist/eval.js +2 -2
- package/dist/extract.js +1 -1
- package/dist/gated-write.js +3 -1
- package/dist/goals.d.ts +3 -1
- package/dist/goals.js +117 -86
- package/dist/graph/read.d.ts +73 -0
- package/dist/graph/read.js +325 -0
- package/dist/graph/rows.d.ts +45 -0
- package/dist/graph/rows.js +51 -0
- package/dist/graph/types.d.ts +83 -0
- package/dist/graph/types.js +11 -0
- package/dist/graph/write.d.ts +93 -0
- package/dist/{graph.js → graph/write.js} +6 -384
- package/dist/graph-extract.js +2 -1
- package/dist/graph-recall.d.ts +1 -1
- package/dist/graph-recall.js +2 -2
- package/dist/graph-stream.js +1 -1
- package/dist/graph-view.d.ts +1 -1
- package/dist/graph-view.js +1 -1
- package/dist/half-life-migration.d.ts +1 -1
- package/dist/half-life-migration.js +2 -1
- package/dist/hooks/codex-session.d.ts +8 -0
- package/dist/hooks/codex-session.js +76 -0
- package/dist/hooks/codex-wrapper.d.ts +55 -0
- package/dist/hooks/codex-wrapper.js +288 -0
- package/dist/hooks/json-hooks.d.ts +63 -0
- package/dist/hooks/json-hooks.js +356 -0
- package/dist/hooks/opencode.d.ts +50 -0
- package/dist/hooks/opencode.js +202 -0
- package/dist/hooks/shared.d.ts +54 -0
- package/dist/hooks/shared.js +77 -0
- package/dist/http-retry.d.ts +2 -0
- package/dist/http-retry.js +4 -3
- package/dist/http-util.d.ts +3 -0
- package/dist/http-util.js +10 -0
- package/dist/{importers.d.ts → importers/core.d.ts} +13 -17
- package/dist/importers/core.js +141 -0
- package/dist/importers/markdown-parse.d.ts +41 -0
- package/dist/importers/markdown-parse.js +132 -0
- package/dist/importers/markdown.d.ts +3 -0
- package/dist/importers/markdown.js +92 -0
- package/dist/importers/sources.d.ts +7 -0
- package/dist/importers/sources.js +229 -0
- package/dist/importers/vault.d.ts +11 -0
- package/dist/importers/vault.js +352 -0
- package/dist/incidents.d.ts +3 -0
- package/dist/incidents.js +52 -43
- package/dist/index.d.ts +25 -6
- package/dist/index.js +23 -6
- package/dist/invalidation.js +2 -1
- package/dist/judgment.js +2 -1
- package/dist/keyset.d.ts +13 -0
- package/dist/keyset.js +8 -0
- package/dist/local-embedding.d.ts +13 -0
- package/dist/local-embedding.js +165 -0
- package/dist/log.d.ts +7 -0
- package/dist/log.js +19 -1
- package/dist/mcp/admin-tools.d.ts +8 -0
- package/dist/mcp/admin-tools.js +116 -0
- package/dist/mcp/format.d.ts +27 -0
- package/dist/mcp/format.js +135 -0
- package/dist/mcp/memory-tools.d.ts +5 -0
- package/dist/mcp/memory-tools.js +83 -0
- package/dist/mcp/protocol.d.ts +83 -0
- package/dist/mcp/protocol.js +55 -0
- package/dist/mcp/recall-tools.d.ts +6 -0
- package/dist/mcp/recall-tools.js +320 -0
- package/dist/mcp/request.d.ts +10 -0
- package/dist/mcp/request.js +163 -0
- package/dist/mcp/server.d.ts +4 -75
- package/dist/mcp/server.js +7 -1190
- package/dist/mcp/session-state.d.ts +11 -0
- package/dist/mcp/session-state.js +28 -0
- package/dist/mcp/stdio.d.ts +8 -0
- package/dist/mcp/stdio.js +79 -0
- package/dist/mcp/tools.d.ts +11 -0
- package/dist/mcp/tools.js +247 -0
- package/dist/memory.d.ts +3 -0
- package/dist/memory.js +27 -1
- package/dist/multihop.d.ts +1 -1
- package/dist/multihop.js +2 -1
- package/dist/owner-validation.js +2 -1
- package/dist/physics-state.js +10 -7
- package/dist/policies.d.ts +3 -0
- package/dist/policies.js +93 -74
- package/dist/postinstall.js +3 -2
- package/dist/predictions/planning-fallacy.d.ts +100 -0
- package/dist/predictions/planning-fallacy.js +190 -0
- package/dist/{predictions.d.ts → predictions/store.d.ts} +7 -102
- package/dist/predictions/store.js +434 -0
- package/dist/processes.d.ts +3 -0
- package/dist/processes.js +94 -76
- package/dist/project-briefs.d.ts +3 -0
- package/dist/project-briefs.js +142 -113
- package/dist/project-identity.js +3 -2
- package/dist/project-merge.d.ts +12 -4
- package/dist/project-merge.js +132 -45
- package/dist/quarantine.d.ts +2 -1
- package/dist/quarantine.js +8 -5
- package/dist/raw-archive.js +1 -1
- package/dist/recall-history.js +3 -2
- package/dist/recall-pipeline.d.ts +2 -2
- package/dist/recall-pipeline.js +16 -8
- package/dist/recall-scope.js +1 -1
- package/dist/recall-trace.d.ts +1 -1
- package/dist/refine-llm.js +2 -1
- package/dist/reject-flow.js +6 -1
- package/dist/rerankers/clef.js +6 -5
- package/dist/rerankers/jev.d.ts +1 -1
- package/dist/rerankers/jev.js +4 -4
- package/dist/rerankers/llm.d.ts +4 -2
- package/dist/rerankers/llm.js +58 -38
- package/dist/rerankers/types.d.ts +1 -1
- package/dist/salience.js +1 -1
- package/dist/scheduler.d.ts +1 -0
- package/dist/scheduler.js +26 -4
- package/dist/scope.js +4 -3
- package/dist/search/as-of.d.ts +10 -0
- package/dist/search/as-of.js +22 -0
- package/dist/search/bm25-search.d.ts +14 -0
- package/dist/search/bm25-search.js +43 -0
- package/dist/search/bm25.d.ts +15 -0
- package/dist/search/bm25.js +54 -0
- package/dist/search/boosts.d.ts +54 -0
- package/dist/search/boosts.js +94 -0
- package/dist/search/breakdown.d.ts +7 -0
- package/dist/search/breakdown.js +20 -0
- package/dist/search/explain.d.ts +25 -0
- package/dist/search/explain.js +31 -0
- package/dist/search/finalize.d.ts +8 -0
- package/dist/search/finalize.js +52 -0
- package/dist/search/fusion.d.ts +27 -0
- package/dist/search/fusion.js +42 -0
- package/dist/search/hybrid-score.d.ts +20 -0
- package/dist/search/hybrid-score.js +73 -0
- package/dist/search/hybrid.d.ts +46 -0
- package/dist/search/hybrid.js +64 -0
- package/dist/search/physics-search.d.ts +29 -0
- package/dist/search/physics-search.js +162 -0
- package/dist/search/rerank.d.ts +10 -0
- package/dist/search/rerank.js +72 -0
- package/dist/search/temporal.d.ts +15 -0
- package/dist/search/temporal.js +45 -0
- package/dist/search/types.d.ts +91 -0
- package/dist/search/types.js +2 -0
- package/dist/search/vector.d.ts +30 -0
- package/dist/search/vector.js +71 -0
- package/dist/secret-detect.d.ts +2 -0
- package/dist/secret-detect.js +2 -1
- package/dist/server/auth.d.ts +52 -0
- package/dist/server/auth.js +221 -0
- package/dist/server/client-ip.d.ts +25 -0
- package/dist/server/client-ip.js +92 -0
- package/dist/server/cursor.d.ts +23 -0
- package/dist/server/cursor.js +58 -0
- package/dist/server/lifecycle.d.ts +7 -0
- package/dist/server/lifecycle.js +29 -0
- package/dist/server/mcp-http.d.ts +5 -0
- package/dist/server/mcp-http.js +199 -0
- package/dist/server/request.d.ts +33 -0
- package/dist/server/request.js +103 -0
- package/dist/server/routes/admin.d.ts +9 -0
- package/dist/server/routes/admin.js +158 -0
- package/dist/server/routes/customer-notes.d.ts +7 -0
- package/dist/server/routes/customer-notes.js +112 -0
- package/dist/server/routes/decisions.d.ts +7 -0
- package/dist/server/routes/decisions.js +133 -0
- package/dist/server/routes/incidents.d.ts +7 -0
- package/dist/server/routes/incidents.js +126 -0
- package/dist/server/routes/memories.d.ts +10 -0
- package/dist/server/routes/memories.js +179 -0
- package/dist/server/routes/policies.d.ts +8 -0
- package/dist/server/routes/policies.js +151 -0
- package/dist/server/routes/predictions.d.ts +7 -0
- package/dist/server/routes/predictions.js +164 -0
- package/dist/server/routes/processes.d.ts +7 -0
- package/dist/server/routes/processes.js +161 -0
- package/dist/server/routes/project-briefs.d.ts +8 -0
- package/dist/server/routes/project-briefs.js +136 -0
- package/dist/server/routes/recall.d.ts +8 -0
- package/dist/server/routes/recall.js +340 -0
- package/dist/server/routes/skills.d.ts +8 -0
- package/dist/server/routes/skills.js +150 -0
- package/dist/server/types.d.ts +56 -0
- package/dist/server/types.js +2 -0
- package/dist/server/validation.d.ts +14 -0
- package/dist/server/validation.js +91 -0
- package/dist/server.d.ts +7 -61
- package/dist/server.js +69 -2362
- package/dist/session-digest.d.ts +1 -1
- package/dist/session-digest.js +9 -2
- package/dist/shared.d.ts +12 -1
- package/dist/shared.js +33 -27
- package/dist/skills.d.ts +3 -0
- package/dist/skills.js +88 -70
- package/dist/stdin.js +2 -2
- package/dist/store/audit-event.d.ts +19 -0
- package/dist/store/audit-event.js +33 -0
- package/dist/store/candidates.d.ts +42 -0
- package/dist/store/candidates.js +152 -0
- package/dist/store/conflicts.d.ts +44 -0
- package/dist/store/conflicts.js +444 -0
- package/dist/store/delete-and-batch.d.ts +63 -0
- package/dist/store/delete-and-batch.js +310 -0
- package/dist/store/entry-reads.d.ts +92 -0
- package/dist/store/entry-reads.js +255 -0
- package/dist/store/entry-row.d.ts +67 -0
- package/dist/store/entry-row.js +208 -0
- package/dist/store/entry-writes.d.ts +46 -0
- package/dist/store/entry-writes.js +148 -0
- package/dist/store/handoffs.d.ts +26 -0
- package/dist/store/handoffs.js +184 -0
- package/dist/store/index-and-stats.d.ts +52 -0
- package/dist/store/index-and-stats.js +214 -0
- package/dist/store/markdown.d.ts +10 -0
- package/dist/store/markdown.js +108 -0
- package/dist/store/mirrors.d.ts +49 -0
- package/dist/store/mirrors.js +312 -0
- package/dist/store/open.d.ts +15 -0
- package/dist/store/open.js +223 -0
- package/dist/store/rows.d.ts +178 -0
- package/dist/store/rows.js +158 -0
- package/dist/store/search-rows.d.ts +86 -0
- package/dist/store/search-rows.js +260 -0
- package/dist/store/sessions.d.ts +83 -0
- package/dist/store/sessions.js +272 -0
- package/dist/store/summaries.d.ts +94 -0
- package/dist/store/summaries.js +377 -0
- package/dist/store/tenant-lookup.d.ts +12 -0
- package/dist/store/tenant-lookup.js +16 -0
- package/dist/store-cards.js +2 -1
- package/dist/summary-dirty.d.ts +4 -0
- package/dist/summary-dirty.js +32 -0
- package/dist/support-bundle.js +4 -3
- package/dist/tenant.js +2 -2
- package/dist/tokenize.d.ts +2 -0
- package/dist/tokenize.js +16 -0
- package/dist/transcript-tail.d.ts +7 -0
- package/dist/transcript-tail.js +48 -0
- package/dist/vector-store.d.ts +27 -0
- package/dist/vector-store.js +210 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +2 -2
- package/dist/working-memory.js +1 -1
- package/dist/yaml.js +36 -11
- package/dist-ui/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- package/dist-ui/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/dist-ui/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/dist-ui/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/dist-ui/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
- package/dist-ui/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-400-normal-CDDApCn2.woff2 +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-400-normal-CYLoc0-x.woff +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-500-normal-6ng42L7E.woff2 +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-500-normal-BgVn5rGT.woff +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-600-normal-Cu4Hd6ag.woff +0 -0
- package/dist-ui/assets/ibm-plex-sans-latin-600-normal-CuJfVYMP.woff2 +0 -0
- package/dist-ui/assets/index-DPN7cP19.js +33 -0
- package/dist-ui/assets/index-dFloKRVr.css +1 -0
- package/dist-ui/index.html +3 -25
- package/extensions/openclaw-plugin/openclaw.plugin.json +1 -1
- package/extensions/openclaw-plugin/package.json +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/dist/capture.d.ts +0 -155
- package/dist/capture.js +0 -1295
- package/dist/consolidate.d.ts +0 -58
- package/dist/consolidate.js +0 -1124
- package/dist/graph.d.ts +0 -245
- package/dist/hooks.d.ts +0 -208
- package/dist/hooks.js +0 -1076
- package/dist/importers.js +0 -900
- package/dist/predictions.js +0 -620
- package/dist/search.d.ts +0 -320
- package/dist/search.js +0 -970
- package/dist/store.d.ts +0 -776
- package/dist/store.js +0 -3473
- package/dist-ui/assets/d3-BiWEKnn4.js +0 -1
- package/dist-ui/assets/index-BhT8RvO6.js +0 -61
- package/dist-ui/assets/index-RoXXJ5dq.css +0 -1
- package/dist-ui/assets/three-BDgTxR1l.js +0 -4112
package/dist/hooks.js
DELETED
|
@@ -1,1076 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook install/uninstall for AI coding tools.
|
|
3
|
-
*
|
|
4
|
-
* Two integration models live in this file:
|
|
5
|
-
*
|
|
6
|
-
* 1. JSON-hook install (Claude Code only). Writes a `hooks` block into the
|
|
7
|
-
* tool's settings.json with two entries:
|
|
8
|
-
* - SessionEnd: `hippo session-end --log-file <path>` - spawns a detached
|
|
9
|
-
* child that runs `hippo sleep` then `hippo capture --last-session` in
|
|
10
|
-
* sequence, writing both outputs to the log file. The parent returns in
|
|
11
|
-
* <100ms so the TUI teardown can't kill the child before it finishes.
|
|
12
|
-
* - SessionStart: `hippo last-sleep --path <path>` - prints the log
|
|
13
|
-
* written by the previous session's detached worker to stderr, which
|
|
14
|
-
* keeps it out of the model's context, and then clears it.
|
|
15
|
-
* Earlier Claude Code forms are detected and migrated automatically:
|
|
16
|
-
* - < 0.20.2: `Stop` hook firing `hippo sleep` on every assistant turn.
|
|
17
|
-
* - < 0.21.0: bare `hippo sleep` in SessionEnd, no `--log-file`.
|
|
18
|
-
* - 0.22.x: separate sleep + capture SessionEnd entries.
|
|
19
|
-
* PreCompact and PostCompact entries go in too: the first records the compaction and
|
|
20
|
-
* asks the summariser for a "Memories for hippo" list, the second saves that list.
|
|
21
|
-
* Codex's hooks.json gets only two groups (per-prompt memory and
|
|
22
|
-
* compact-resume); see installCodexHooks.
|
|
23
|
-
*
|
|
24
|
-
* 2. Plugin install (OpenCode only). OpenCode does NOT share Claude Code's
|
|
25
|
-
* JSON-hook schema — its config has `additionalProperties: false` and no
|
|
26
|
-
* `hooks` key, so v1.10.x-v1.11.1's JSON-hook installer broke opencode
|
|
27
|
-
* launch (issue #24). Hippo now installs a TypeScript plugin at
|
|
28
|
-
* `~/.config/opencode/plugins/hippo.ts` subscribing to opencode's
|
|
29
|
-
* `session.idle` (→ `hippo session-end`) and `session.created` (→
|
|
30
|
-
* `hippo last-sleep`) events. See OPENCODE_PLUGIN_SOURCE below for the
|
|
31
|
-
* plugin file content + design rationale; see installOpencodePlugin for
|
|
32
|
-
* the installer + the migration that removes any pre-existing broken
|
|
33
|
-
* `hooks` block from opencode.json.
|
|
34
|
-
*/
|
|
35
|
-
import * as fs from 'fs';
|
|
36
|
-
import * as os from 'os';
|
|
37
|
-
import * as path from 'path';
|
|
38
|
-
import { fileURLToPath } from 'url';
|
|
39
|
-
/** JSON-value string check. `constructor` narrows a primitive via its boxed wrapper
|
|
40
|
-
* instead of inspecting the `typeof` tag (anti-slop/no-runtime-typeof); equivalent to
|
|
41
|
-
* `typeof value === 'string'` for every value JSON.parse can ever produce. */
|
|
42
|
-
function isJsonString(value) {
|
|
43
|
-
return value !== undefined && value !== null && value.constructor === String;
|
|
44
|
-
}
|
|
45
|
-
/** JSON-value plain-object check (excludes arrays and null), typeof-free for the same
|
|
46
|
-
* reason as isJsonString above. */
|
|
47
|
-
export function isJsonObject(value) {
|
|
48
|
-
return value !== undefined && value !== null && !Array.isArray(value) && value.constructor === Object;
|
|
49
|
-
}
|
|
50
|
-
const HIPPO_SLEEP_MARKER = 'hippo sleep';
|
|
51
|
-
const HIPPO_LAST_SLEEP_MARKER = 'hippo last-sleep';
|
|
52
|
-
const HIPPO_CAPTURE_MARKER = 'hippo capture --last-session';
|
|
53
|
-
const HIPPO_SESSION_END_MARKER = 'hippo session-end';
|
|
54
|
-
const HIPPO_PINNED_INJECT_MARKER = 'hippo context --pinned-only';
|
|
55
|
-
const HIPPO_PINNED_INJECT_COMMAND = 'hippo context --pinned-only --include-recent 5 --format additional-context';
|
|
56
|
-
const HIPPO_CODEX_WRAPPER_MARKER = 'hippo codex wrapper';
|
|
57
|
-
const HIPPO_PRE_COMPACT_MARKER = 'hippo pre-compact';
|
|
58
|
-
const HIPPO_COMPACT_RESUME_MARKER = 'hippo compact-resume';
|
|
59
|
-
const HIPPO_CAPTURE_ERROR_MARKER = 'hippo capture-error';
|
|
60
|
-
const HIPPO_POST_COMPACT_MARKER = 'hippo post-compact';
|
|
61
|
-
const HIPPO_OPENCODE_PLUGIN_MARKER = 'HIPPO_OPENCODE_PLUGIN_V1';
|
|
62
|
-
/**
|
|
63
|
-
* The opencode plugin file we install at ~/.config/opencode/plugins/hippo.ts.
|
|
64
|
-
*
|
|
65
|
-
* Per https://opencode.ai/docs/plugins/, plugins are TS/JS modules exporting an
|
|
66
|
-
* async function returning hooks. We subscribe to `event` and route:
|
|
67
|
-
* session.idle → `hippo session-end` (Claude Code's SessionEnd equiv)
|
|
68
|
-
* session.created → `hippo last-sleep` (Claude Code's SessionStart equiv)
|
|
69
|
-
*
|
|
70
|
-
* Design choices forced by plan-eng-critic Rev 0 review (2026-05-23):
|
|
71
|
-
*
|
|
72
|
-
* 1. No `import type { Plugin } from "@opencode-ai/plugin"`. The package's npm
|
|
73
|
-
* publication status was unverifiable from the build sandbox (npmjs.com
|
|
74
|
-
* returned 403); an unresolved type-only import would still crash the TS
|
|
75
|
-
* runtime opencode uses to load the plugin. opencode infers plugin shape
|
|
76
|
-
* from the returned object, so the type was convenience-only.
|
|
77
|
-
*
|
|
78
|
-
* 2. Defensive `typeof $ !== 'function'` guard. opencode runs in Bun (where
|
|
79
|
-
* `$` is the shell-template helper), but a future Node-mode deployment
|
|
80
|
-
* would have `$` undefined in the destructured context and the plugin
|
|
81
|
-
* would throw on every session.idle, killing opencode sessions in a
|
|
82
|
-
* hard-to-recover way (the idempotence marker prevents auto-reinstall).
|
|
83
|
-
* Fail closed, let opencode continue.
|
|
84
|
-
*
|
|
85
|
-
* 3. `.quiet().nothrow()` on each `$\`...\`` so a missing hippo binary
|
|
86
|
-
* (e.g. PATH-misconfigured user) does NOT throw out of the event handler.
|
|
87
|
-
* The surrounding try/catch is belt-and-braces.
|
|
88
|
-
*
|
|
89
|
-
* 4. UserPromptSubmit equivalent NOT wired. opencode's `message.updated`
|
|
90
|
-
* fires per-token, not per-prompt-submit; no clean per-prompt event.
|
|
91
|
-
* Users wanting pinned-context auto-injection can call `hippo context`
|
|
92
|
-
* via the MCP server (`hippo mcp`).
|
|
93
|
-
*
|
|
94
|
-
* 5. Versioned marker `HIPPO_OPENCODE_PLUGIN_V1` allows future versions to
|
|
95
|
-
* overwrite cleanly. The installer's idempotence check requires BOTH
|
|
96
|
-
* marker match AND content equality, so a plugin-source revision under
|
|
97
|
-
* the same V1 marker re-writes the file on next install.
|
|
98
|
-
*/
|
|
99
|
-
export const OPENCODE_PLUGIN_SOURCE = `// ${HIPPO_OPENCODE_PLUGIN_MARKER}
|
|
100
|
-
// hippo-memory opencode plugin. DO NOT EDIT — regenerated on every
|
|
101
|
-
// \`hippo hook install opencode\` from src/hooks.ts OPENCODE_PLUGIN_SOURCE
|
|
102
|
-
// in https://github.com/kitfunso/hippo-memory. Local changes will be lost.
|
|
103
|
-
|
|
104
|
-
export const HippoPlugin = async ({ $ }) => {
|
|
105
|
-
return {
|
|
106
|
-
event: async ({ event }) => {
|
|
107
|
-
// Defense in depth: opencode currently runs in Bun where $ is the shell
|
|
108
|
-
// template helper. A non-Bun runtime would have $ as undefined; fail
|
|
109
|
-
// closed instead of crashing the host session.
|
|
110
|
-
if (typeof $ !== "function") return;
|
|
111
|
-
try {
|
|
112
|
-
if (event.type === "session.idle") {
|
|
113
|
-
await $\`hippo session-end\`.quiet().nothrow();
|
|
114
|
-
} else if (event.type === "session.created") {
|
|
115
|
-
await $\`hippo last-sleep\`.quiet().nothrow();
|
|
116
|
-
}
|
|
117
|
-
} catch {
|
|
118
|
-
// hippo CLI not on PATH or other failure — never crash the host session.
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
`;
|
|
124
|
-
export { HIPPO_OPENCODE_PLUGIN_MARKER };
|
|
125
|
-
function homeDir() {
|
|
126
|
-
return process.env.HOME || process.env.USERPROFILE || os.homedir();
|
|
127
|
-
}
|
|
128
|
-
/** Codex's config folder: $CODEX_HOME, else ~/.codex, as the Codex hooks docs describe. */
|
|
129
|
-
export function codexHomeDir(home = homeDir(), env = process.env) {
|
|
130
|
-
return env.CODEX_HOME || path.join(home, '.codex');
|
|
131
|
-
}
|
|
132
|
-
/** Codex counts as installed only when its config folder exists: Codex itself refuses a CODEX_HOME that is not a folder. */
|
|
133
|
-
export function isCodexPresent(home = homeDir()) {
|
|
134
|
-
return fs.statSync(codexHomeDir(home), { throwIfNoEntry: false })?.isDirectory() === true;
|
|
135
|
-
}
|
|
136
|
-
/** Codex hashes each hook and skips new or changed ones until the user reviews them in `/hooks`, so the reminder says what they would trust. */
|
|
137
|
-
export const CODEX_TRUST_LINE = "The per-prompt hook sends your pinned memories plus up to 5 that match the prompt. Codex runs hippo's hooks only after you trust them once in `/hooks`.";
|
|
138
|
-
/**
|
|
139
|
-
* Default log path consumed by `hippo last-sleep`. Shared fallback when
|
|
140
|
-
* a caller doesn't pass --path explicitly.
|
|
141
|
-
*/
|
|
142
|
-
export function defaultSleepLogPath() {
|
|
143
|
-
return path.join(homeDir(), '.hippo', 'logs', 'last-sleep.log');
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Diagnostic-only log path for `hippo pre-compact`. Deliberately separate
|
|
147
|
-
* from the SessionEnd sleep log: `hippo last-sleep` truncates that file on
|
|
148
|
-
* every SessionStart, which would wipe pre-compact lines before anyone
|
|
149
|
-
* could read them. Nothing consumes this file programmatically — it exists
|
|
150
|
-
* for manual troubleshooting only. Overridden by `--log-file`.
|
|
151
|
-
*/
|
|
152
|
-
export function defaultPreCompactLogPath() {
|
|
153
|
-
return path.join(homeDir(), '.hippo', 'logs', 'pre-compact.log');
|
|
154
|
-
}
|
|
155
|
-
export function resolveCodexWrapperPaths() {
|
|
156
|
-
const home = homeDir();
|
|
157
|
-
const codexHome = codexHomeDir(home);
|
|
158
|
-
const wrapperDir = path.join(home, '.hippo', 'bin');
|
|
159
|
-
return {
|
|
160
|
-
wrapperDir,
|
|
161
|
-
metadataPath: path.join(home, '.hippo', 'integrations', 'codex.json'),
|
|
162
|
-
wrapperCmdPath: path.join(wrapperDir, 'codex.cmd'),
|
|
163
|
-
wrapperPs1Path: path.join(wrapperDir, 'codex.ps1'),
|
|
164
|
-
wrapperShPath: path.join(wrapperDir, 'codex'),
|
|
165
|
-
logFile: path.join(home, '.hippo', 'logs', 'codex-sleep.log'),
|
|
166
|
-
runsDir: path.join(home, '.hippo', 'runs', 'codex'),
|
|
167
|
-
codexHome,
|
|
168
|
-
historyPath: path.join(codexHome, 'history.jsonl'),
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
function pathEquals(a, b) {
|
|
172
|
-
return path.resolve(a).toLowerCase() === path.resolve(b).toLowerCase();
|
|
173
|
-
}
|
|
174
|
-
function readCodexWrapperMetadata() {
|
|
175
|
-
const { metadataPath } = resolveCodexWrapperPaths();
|
|
176
|
-
if (!fs.existsSync(metadataPath))
|
|
177
|
-
return null;
|
|
178
|
-
try {
|
|
179
|
-
// This optimistic parse is never trusted directly — every call site reads fields off
|
|
180
|
-
// the result only after isCodexWrapperMetadataValid has runtime-checked each string
|
|
181
|
-
// field and the referenced paths.
|
|
182
|
-
const parsed = JSON.parse(fs.readFileSync(metadataPath, 'utf8'));
|
|
183
|
-
return parsed;
|
|
184
|
-
}
|
|
185
|
-
catch {
|
|
186
|
-
// Unreadable metadata is treated like the missing-file case above.
|
|
187
|
-
return null;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
function readTextFile(filePath) {
|
|
191
|
-
try {
|
|
192
|
-
return fs.readFileSync(filePath, 'utf8');
|
|
193
|
-
}
|
|
194
|
-
catch {
|
|
195
|
-
// Callers treat an unreadable file as absent.
|
|
196
|
-
return null;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
function isHippoCodexWrapperFile(filePath) {
|
|
200
|
-
if (!fs.existsSync(filePath))
|
|
201
|
-
return false;
|
|
202
|
-
const text = readTextFile(filePath);
|
|
203
|
-
return text !== null && text.includes(HIPPO_CODEX_WRAPPER_MARKER);
|
|
204
|
-
}
|
|
205
|
-
function isCodexWrapperMetadataValid(metadata) {
|
|
206
|
-
if (!metadata)
|
|
207
|
-
return false;
|
|
208
|
-
return (isJsonString(metadata.originalCodexPath) &&
|
|
209
|
-
isJsonString(metadata.realCodexPath) &&
|
|
210
|
-
isJsonString(metadata.commandPath) &&
|
|
211
|
-
isJsonString(metadata.backupPath) &&
|
|
212
|
-
fs.existsSync(metadata.realCodexPath) &&
|
|
213
|
-
fs.existsSync(metadata.backupPath) &&
|
|
214
|
-
isHippoCodexWrapperFile(metadata.commandPath));
|
|
215
|
-
}
|
|
216
|
-
function resolveHippoCliPath() {
|
|
217
|
-
return fileURLToPath(new URL('../bin/hippo.js', import.meta.url));
|
|
218
|
-
}
|
|
219
|
-
function quoteForShell(value) {
|
|
220
|
-
return `"${value.replace(/(["\\$`])/g, '\\$1')}"`;
|
|
221
|
-
}
|
|
222
|
-
function quoteForPowerShell(value) {
|
|
223
|
-
return `'${value.replace(/'/g, "''")}'`;
|
|
224
|
-
}
|
|
225
|
-
function quoteForCmd(value) {
|
|
226
|
-
return `"${value.replace(/"/g, '""')}"`;
|
|
227
|
-
}
|
|
228
|
-
function resolveCodexInstallPlan(originalCodexPath) {
|
|
229
|
-
const dir = path.dirname(originalCodexPath);
|
|
230
|
-
const ext = path.extname(originalCodexPath).toLowerCase();
|
|
231
|
-
const name = path.basename(originalCodexPath, ext);
|
|
232
|
-
const backupPath = path.join(dir, `${name}.hippo-real${ext}`);
|
|
233
|
-
if (process.platform === 'win32' && ext === '.exe') {
|
|
234
|
-
return {
|
|
235
|
-
commandPath: path.join(dir, `${name}.cmd`),
|
|
236
|
-
backupPath,
|
|
237
|
-
installMode: 'cmd-shim',
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
return {
|
|
241
|
-
commandPath: originalCodexPath,
|
|
242
|
-
backupPath,
|
|
243
|
-
installMode: 'same-path',
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
function writeCodexLauncherWrapper(commandPath) {
|
|
247
|
-
const ext = path.extname(commandPath).toLowerCase();
|
|
248
|
-
const nodePath = process.execPath;
|
|
249
|
-
const hippoCliPath = resolveHippoCliPath();
|
|
250
|
-
if (process.platform === 'win32' && ext === '.ps1') {
|
|
251
|
-
writeExecutableFile(commandPath, [
|
|
252
|
-
`# ${HIPPO_CODEX_WRAPPER_MARKER}`,
|
|
253
|
-
`& ${quoteForPowerShell(nodePath)} ${quoteForPowerShell(hippoCliPath)} codex-run -- @args`,
|
|
254
|
-
'',
|
|
255
|
-
].join('\n'));
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
if (process.platform === 'win32' && (ext === '.cmd' || ext === '.bat')) {
|
|
259
|
-
writeExecutableFile(commandPath, [
|
|
260
|
-
'@echo off',
|
|
261
|
-
`REM ${HIPPO_CODEX_WRAPPER_MARKER}`,
|
|
262
|
-
`${quoteForCmd(nodePath)} ${quoteForCmd(hippoCliPath)} codex-run -- %*`,
|
|
263
|
-
'',
|
|
264
|
-
].join('\r\n'));
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
writeExecutableFile(commandPath, [
|
|
268
|
-
'#!/usr/bin/env sh',
|
|
269
|
-
`# ${HIPPO_CODEX_WRAPPER_MARKER}`,
|
|
270
|
-
`exec ${quoteForShell(nodePath)} ${quoteForShell(hippoCliPath)} codex-run -- "$@"`,
|
|
271
|
-
'',
|
|
272
|
-
].join('\n'));
|
|
273
|
-
}
|
|
274
|
-
function cleanupLegacyCodexPathWrappers(paths) {
|
|
275
|
-
for (const filePath of [paths.wrapperCmdPath, paths.wrapperPs1Path, paths.wrapperShPath]) {
|
|
276
|
-
if (fs.existsSync(filePath))
|
|
277
|
-
fs.rmSync(filePath, { force: true });
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
export function detectRealCodexPath() {
|
|
281
|
-
const metadata = readCodexWrapperMetadata();
|
|
282
|
-
if (isCodexWrapperMetadataValid(metadata))
|
|
283
|
-
return metadata.realCodexPath;
|
|
284
|
-
const { wrapperDir } = resolveCodexWrapperPaths();
|
|
285
|
-
const entries = (process.env.PATH ?? '')
|
|
286
|
-
.split(path.delimiter)
|
|
287
|
-
.map((entry) => entry.trim())
|
|
288
|
-
.filter(Boolean)
|
|
289
|
-
.filter((entry) => !pathEquals(entry, wrapperDir));
|
|
290
|
-
const names = process.platform === 'win32'
|
|
291
|
-
? ['codex.cmd', 'codex.ps1', 'codex.exe', 'codex']
|
|
292
|
-
: ['codex'];
|
|
293
|
-
for (const entry of entries) {
|
|
294
|
-
for (const name of names) {
|
|
295
|
-
const candidate = path.join(entry, name);
|
|
296
|
-
if (fs.existsSync(candidate))
|
|
297
|
-
return candidate;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return null;
|
|
301
|
-
}
|
|
302
|
-
function ensureDir(dir) {
|
|
303
|
-
if (!fs.existsSync(dir))
|
|
304
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
305
|
-
}
|
|
306
|
-
function writeExecutableFile(filePath, content) {
|
|
307
|
-
fs.writeFileSync(filePath, content, 'utf8');
|
|
308
|
-
try {
|
|
309
|
-
fs.chmodSync(filePath, 0o755);
|
|
310
|
-
}
|
|
311
|
-
catch {
|
|
312
|
-
// chmod is best-effort on Windows
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
export function installCodexWrapper(realCodexPath) {
|
|
316
|
-
const existingMetadata = readCodexWrapperMetadata();
|
|
317
|
-
if (isCodexWrapperMetadataValid(existingMetadata) && !realCodexPath) {
|
|
318
|
-
cleanupLegacyCodexPathWrappers(resolveCodexWrapperPaths());
|
|
319
|
-
return {
|
|
320
|
-
installed: true,
|
|
321
|
-
metadataPath: resolveCodexWrapperPaths().metadataPath,
|
|
322
|
-
realCodexPath: existingMetadata.realCodexPath,
|
|
323
|
-
commandPath: existingMetadata.commandPath,
|
|
324
|
-
backupPath: existingMetadata.backupPath,
|
|
325
|
-
installMode: existingMetadata.installMode,
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
const resolvedRealCodexPath = realCodexPath ?? detectRealCodexPath();
|
|
329
|
-
if (!resolvedRealCodexPath) {
|
|
330
|
-
throw new Error('Could not locate the real Codex executable on PATH.');
|
|
331
|
-
}
|
|
332
|
-
const paths = resolveCodexWrapperPaths();
|
|
333
|
-
ensureDir(path.dirname(paths.metadataPath));
|
|
334
|
-
ensureDir(path.dirname(paths.logFile));
|
|
335
|
-
ensureDir(paths.runsDir);
|
|
336
|
-
cleanupLegacyCodexPathWrappers(paths);
|
|
337
|
-
const plan = resolveCodexInstallPlan(resolvedRealCodexPath);
|
|
338
|
-
ensureDir(path.dirname(plan.commandPath));
|
|
339
|
-
if (isCodexWrapperMetadataValid(existingMetadata)) {
|
|
340
|
-
uninstallCodexWrapper();
|
|
341
|
-
}
|
|
342
|
-
if (!fs.existsSync(plan.backupPath)) {
|
|
343
|
-
fs.renameSync(resolvedRealCodexPath, plan.backupPath);
|
|
344
|
-
}
|
|
345
|
-
writeCodexLauncherWrapper(plan.commandPath);
|
|
346
|
-
const metadata = {
|
|
347
|
-
originalCodexPath: resolvedRealCodexPath,
|
|
348
|
-
realCodexPath: plan.backupPath,
|
|
349
|
-
commandPath: plan.commandPath,
|
|
350
|
-
backupPath: plan.backupPath,
|
|
351
|
-
installMode: plan.installMode,
|
|
352
|
-
logFile: paths.logFile,
|
|
353
|
-
installedAt: new Date().toISOString(),
|
|
354
|
-
};
|
|
355
|
-
fs.writeFileSync(paths.metadataPath, JSON.stringify(metadata, null, 2) + '\n', 'utf8');
|
|
356
|
-
return {
|
|
357
|
-
installed: true,
|
|
358
|
-
metadataPath: paths.metadataPath,
|
|
359
|
-
realCodexPath: metadata.realCodexPath,
|
|
360
|
-
commandPath: metadata.commandPath,
|
|
361
|
-
backupPath: metadata.backupPath,
|
|
362
|
-
installMode: metadata.installMode,
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
export function uninstallCodexWrapper() {
|
|
366
|
-
const paths = resolveCodexWrapperPaths();
|
|
367
|
-
let changed = false;
|
|
368
|
-
const metadata = readCodexWrapperMetadata();
|
|
369
|
-
if (metadata) {
|
|
370
|
-
if (fs.existsSync(metadata.commandPath) && isHippoCodexWrapperFile(metadata.commandPath)) {
|
|
371
|
-
fs.rmSync(metadata.commandPath, { force: true });
|
|
372
|
-
changed = true;
|
|
373
|
-
}
|
|
374
|
-
if (fs.existsSync(metadata.backupPath)) {
|
|
375
|
-
fs.renameSync(metadata.backupPath, metadata.originalCodexPath);
|
|
376
|
-
changed = true;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
cleanupLegacyCodexPathWrappers(paths);
|
|
380
|
-
if (fs.existsSync(paths.metadataPath)) {
|
|
381
|
-
fs.rmSync(paths.metadataPath, { force: true });
|
|
382
|
-
changed = true;
|
|
383
|
-
}
|
|
384
|
-
return changed;
|
|
385
|
-
}
|
|
386
|
-
export function ensureCodexWrapperInstalled() {
|
|
387
|
-
const metadata = readCodexWrapperMetadata();
|
|
388
|
-
if (isCodexWrapperMetadataValid(metadata)) {
|
|
389
|
-
cleanupLegacyCodexPathWrappers(resolveCodexWrapperPaths());
|
|
390
|
-
return {
|
|
391
|
-
status: 'already-installed',
|
|
392
|
-
metadataPath: resolveCodexWrapperPaths().metadataPath,
|
|
393
|
-
realCodexPath: metadata.realCodexPath,
|
|
394
|
-
commandPath: metadata.commandPath,
|
|
395
|
-
backupPath: metadata.backupPath,
|
|
396
|
-
};
|
|
397
|
-
}
|
|
398
|
-
if (metadata) {
|
|
399
|
-
uninstallCodexWrapper();
|
|
400
|
-
}
|
|
401
|
-
const detectedRealCodexPath = detectRealCodexPath();
|
|
402
|
-
if (!detectedRealCodexPath) {
|
|
403
|
-
return { status: 'not-found' };
|
|
404
|
-
}
|
|
405
|
-
const result = installCodexWrapper(detectedRealCodexPath);
|
|
406
|
-
return {
|
|
407
|
-
status: 'installed',
|
|
408
|
-
metadataPath: result.metadataPath,
|
|
409
|
-
realCodexPath: result.realCodexPath,
|
|
410
|
-
commandPath: result.commandPath,
|
|
411
|
-
backupPath: result.backupPath,
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
/**
|
|
415
|
-
* True if Codex wrapper metadata exists on this machine, i.e. the user opted
|
|
416
|
-
* in to the wrapper at some point (via `hippo hook install codex`).
|
|
417
|
-
*/
|
|
418
|
-
export function isCodexWrapperInstalled() {
|
|
419
|
-
return readCodexWrapperMetadata() !== null;
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* Repair-only variant of `ensureCodexWrapperInstalled`: re-ensures the wrapper
|
|
423
|
-
* ONLY when wrapper metadata already exists — that metadata is the user's
|
|
424
|
-
* opt-in record. Never performs a first install. Replacing another vendor's
|
|
425
|
-
* binary must stay behind the explicit `hippo hook install codex` command;
|
|
426
|
-
* doing it from postinstall or routine commands is a consent violation and
|
|
427
|
-
* reads as binary hijacking to security scanners (issue #133).
|
|
428
|
-
*/
|
|
429
|
-
export function repairCodexWrapperIfInstalled(hippoCliPath = resolveHippoCliPath()) {
|
|
430
|
-
if (readCodexWrapperMetadata() === null) {
|
|
431
|
-
return { status: 'not-found' };
|
|
432
|
-
}
|
|
433
|
-
// A checkout's own `npm install` or CLI would point the user's launcher at a folder that may be deleted.
|
|
434
|
-
// SHORTCUT: any node_modules copy (npx cache, a project dependency) still repairs; record the opted-in CLI path in the metadata to close that.
|
|
435
|
-
const packageDir = path.dirname(path.dirname(hippoCliPath));
|
|
436
|
-
if (path.basename(path.dirname(packageDir)).toLowerCase() !== 'node_modules') {
|
|
437
|
-
return { status: 'source-checkout' };
|
|
438
|
-
}
|
|
439
|
-
return ensureCodexWrapperInstalled();
|
|
440
|
-
}
|
|
441
|
-
function collectFiles(dir) {
|
|
442
|
-
if (!fs.existsSync(dir))
|
|
443
|
-
return [];
|
|
444
|
-
const out = [];
|
|
445
|
-
const stack = [dir];
|
|
446
|
-
while (stack.length > 0) {
|
|
447
|
-
const current = stack.pop();
|
|
448
|
-
if (current === undefined)
|
|
449
|
-
break;
|
|
450
|
-
for (const entry of fs.readdirSync(current, { withFileTypes: true })) {
|
|
451
|
-
const full = path.join(current, entry.name);
|
|
452
|
-
if (entry.isDirectory()) {
|
|
453
|
-
stack.push(full);
|
|
454
|
-
}
|
|
455
|
-
else if (entry.isFile()) {
|
|
456
|
-
out.push(full);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
return out;
|
|
461
|
-
}
|
|
462
|
-
function readCodexSessionIdsFromHistoryDelta(historyPath, startOffsetBytes) {
|
|
463
|
-
if (!fs.existsSync(historyPath))
|
|
464
|
-
return [];
|
|
465
|
-
const raw = fs.readFileSync(historyPath);
|
|
466
|
-
if (startOffsetBytes >= raw.length)
|
|
467
|
-
return [];
|
|
468
|
-
const delta = raw.subarray(startOffsetBytes).toString('utf8');
|
|
469
|
-
const seen = new Set();
|
|
470
|
-
const ordered = [];
|
|
471
|
-
for (const line of delta.split('\n')) {
|
|
472
|
-
if (!line.trim())
|
|
473
|
-
continue;
|
|
474
|
-
try {
|
|
475
|
-
const parsed = JSON.parse(line);
|
|
476
|
-
const sessionId = parsed.session_id;
|
|
477
|
-
if (isJsonString(sessionId) && sessionId && !seen.has(sessionId)) {
|
|
478
|
-
seen.add(sessionId);
|
|
479
|
-
ordered.push(sessionId);
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
catch {
|
|
483
|
-
// ignore malformed JSONL lines
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
return ordered;
|
|
487
|
-
}
|
|
488
|
-
function findCodexTranscriptBySessionId(sessionsDir, sessionId) {
|
|
489
|
-
const matches = collectFiles(sessionsDir).filter((filePath) => filePath.endsWith('.jsonl') && filePath.includes(sessionId));
|
|
490
|
-
if (matches.length === 0)
|
|
491
|
-
return null;
|
|
492
|
-
matches.sort((a, b) => fs.statSync(b).mtimeMs - fs.statSync(a).mtimeMs);
|
|
493
|
-
return matches[0];
|
|
494
|
-
}
|
|
495
|
-
function findNewestCodexTranscriptSince(sessionsDir, startedAtMs) {
|
|
496
|
-
const matches = collectFiles(sessionsDir)
|
|
497
|
-
.filter((filePath) => filePath.endsWith('.jsonl'))
|
|
498
|
-
.map((filePath) => ({ filePath, mtimeMs: fs.statSync(filePath).mtimeMs }))
|
|
499
|
-
.filter((entry) => entry.mtimeMs >= startedAtMs)
|
|
500
|
-
.sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
501
|
-
return matches[0]?.filePath ?? null;
|
|
502
|
-
}
|
|
503
|
-
export function resolveCodexSessionTranscript(options) {
|
|
504
|
-
const { codexHome, historyPath, startOffsetBytes, startedAtMs } = options;
|
|
505
|
-
const sessionsDir = path.join(codexHome, 'sessions');
|
|
506
|
-
for (const sessionId of readCodexSessionIdsFromHistoryDelta(historyPath, startOffsetBytes).reverse()) {
|
|
507
|
-
const transcript = findCodexTranscriptBySessionId(sessionsDir, sessionId);
|
|
508
|
-
if (transcript)
|
|
509
|
-
return transcript;
|
|
510
|
-
}
|
|
511
|
-
return findNewestCodexTranscriptSince(sessionsDir, startedAtMs);
|
|
512
|
-
}
|
|
513
|
-
export function resolveJsonHookPaths(target) {
|
|
514
|
-
const home = homeDir();
|
|
515
|
-
const logsDir = path.join(home, '.hippo', 'logs');
|
|
516
|
-
switch (target) {
|
|
517
|
-
case 'claude-code':
|
|
518
|
-
return {
|
|
519
|
-
settings: path.join(home, '.claude', 'settings.json'),
|
|
520
|
-
logFile: path.join(logsDir, 'claude-code-sleep.log'),
|
|
521
|
-
display: 'Claude Code',
|
|
522
|
-
};
|
|
523
|
-
case 'codex':
|
|
524
|
-
return {
|
|
525
|
-
settings: path.join(codexHomeDir(home), 'hooks.json'),
|
|
526
|
-
logFile: path.join(logsDir, 'codex-sleep.log'),
|
|
527
|
-
display: 'Codex',
|
|
528
|
-
};
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
function hookArrayContains(hookArray, marker) {
|
|
532
|
-
if (!Array.isArray(hookArray))
|
|
533
|
-
return false;
|
|
534
|
-
return JSON.stringify(hookArray).includes(marker);
|
|
535
|
-
}
|
|
536
|
-
function addIncludeRecentToPinnedCommand(command) {
|
|
537
|
-
if (!command.includes(HIPPO_PINNED_INJECT_MARKER) || command.includes('--include-recent'))
|
|
538
|
-
return command;
|
|
539
|
-
return command.includes(' --format ')
|
|
540
|
-
? command.replace(' --format ', ' --include-recent 5 --format ')
|
|
541
|
-
: `${command} --include-recent 5`;
|
|
542
|
-
}
|
|
543
|
-
function migratePinnedInjectRecentCommands(hookArray) {
|
|
544
|
-
if (!Array.isArray(hookArray))
|
|
545
|
-
return false;
|
|
546
|
-
let changed = false;
|
|
547
|
-
for (const entry of hookArray) {
|
|
548
|
-
if (!isJsonObject(entry))
|
|
549
|
-
continue;
|
|
550
|
-
const innerHooks = entry.hooks;
|
|
551
|
-
if (!Array.isArray(innerHooks))
|
|
552
|
-
continue;
|
|
553
|
-
for (const hook of innerHooks) {
|
|
554
|
-
if (!isJsonObject(hook))
|
|
555
|
-
continue;
|
|
556
|
-
if (!isJsonString(hook.command))
|
|
557
|
-
continue;
|
|
558
|
-
const next = addIncludeRecentToPinnedCommand(hook.command);
|
|
559
|
-
if (next !== hook.command) {
|
|
560
|
-
hook.command = next;
|
|
561
|
-
changed = true;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
return changed;
|
|
566
|
-
}
|
|
567
|
-
function hasCurrentSessionEnd(hookArray) {
|
|
568
|
-
return hookArrayContains(hookArray, HIPPO_SESSION_END_MARKER);
|
|
569
|
-
}
|
|
570
|
-
/**
|
|
571
|
-
* Returns true when `hooks.SessionEnd` still contains either of the legacy
|
|
572
|
-
* v0.22.x split entries (bare `hippo sleep` / `hippo capture --last-session`)
|
|
573
|
-
* without the current consolidated `hippo session-end` entry.
|
|
574
|
-
*/
|
|
575
|
-
function hasLegacySplitSessionEnd(hookArray) {
|
|
576
|
-
if (!Array.isArray(hookArray))
|
|
577
|
-
return false;
|
|
578
|
-
const serialized = JSON.stringify(hookArray);
|
|
579
|
-
const hasSleep = serialized.includes(HIPPO_SLEEP_MARKER);
|
|
580
|
-
const hasCapture = serialized.includes(HIPPO_CAPTURE_MARKER);
|
|
581
|
-
return (hasSleep || hasCapture) && !serialized.includes(HIPPO_SESSION_END_MARKER);
|
|
582
|
-
}
|
|
583
|
-
function nothingInstalled(target, settingsPath) {
|
|
584
|
-
return {
|
|
585
|
-
target,
|
|
586
|
-
settingsPath,
|
|
587
|
-
installedSessionEnd: false,
|
|
588
|
-
installedSessionStart: false,
|
|
589
|
-
installedUserPromptSubmit: false,
|
|
590
|
-
installedPreCompact: false,
|
|
591
|
-
installedCompactResume: false,
|
|
592
|
-
installedPostCompact: false,
|
|
593
|
-
installedCaptureError: false,
|
|
594
|
-
migratedPinnedInjectRecent: false,
|
|
595
|
-
migratedFromStop: false,
|
|
596
|
-
migratedLegacySessionEnd: false,
|
|
597
|
-
migratedSplitSessionEnd: false,
|
|
598
|
-
invalidJson: false,
|
|
599
|
-
};
|
|
600
|
-
}
|
|
601
|
-
/** A command hook with a Windows form: Codex runs hooks in PowerShell there, whose execution policy can block npm's hippo.ps1. */
|
|
602
|
-
function codexCommandHook(command, timeout) {
|
|
603
|
-
return { type: 'command', command, commandWindows: command.replace(/^hippo /, 'hippo.cmd '), timeout };
|
|
604
|
-
}
|
|
605
|
-
/** Codex keys trust to each hook's position and hash and re-asks for a changed one, so hippo only appends and never edits an entry. */
|
|
606
|
-
function installCodexHooks(settingsPath, settings) {
|
|
607
|
-
const result = nothingInstalled('codex', settingsPath);
|
|
608
|
-
if (!isJsonObject(settings))
|
|
609
|
-
return { ...result, invalidJson: true };
|
|
610
|
-
if (settings.hooks === undefined)
|
|
611
|
-
settings.hooks = {};
|
|
612
|
-
const hooks = settings.hooks;
|
|
613
|
-
const events = ['UserPromptSubmit', 'SessionStart'];
|
|
614
|
-
if (!isJsonObject(hooks) || events.some((e) => hooks[e] !== undefined && !Array.isArray(hooks[e]))) {
|
|
615
|
-
return { ...result, invalidJson: true };
|
|
616
|
-
}
|
|
617
|
-
const append = (event, marker, group) => {
|
|
618
|
-
const groups = hooks[event];
|
|
619
|
-
if (hookArrayContains(groups, marker))
|
|
620
|
-
return false;
|
|
621
|
-
hooks[event] = [...(Array.isArray(groups) ? groups : []), group];
|
|
622
|
-
return true;
|
|
623
|
-
};
|
|
624
|
-
const installedUserPromptSubmit = append('UserPromptSubmit', HIPPO_PINNED_INJECT_MARKER, {
|
|
625
|
-
hooks: [codexCommandHook(HIPPO_PINNED_INJECT_COMMAND, 5)],
|
|
626
|
-
});
|
|
627
|
-
const installedCompactResume = append('SessionStart', HIPPO_COMPACT_RESUME_MARKER, {
|
|
628
|
-
matcher: 'compact',
|
|
629
|
-
hooks: [codexCommandHook(HIPPO_COMPACT_RESUME_MARKER, 10)],
|
|
630
|
-
});
|
|
631
|
-
if (installedUserPromptSubmit || installedCompactResume) {
|
|
632
|
-
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n', 'utf8');
|
|
633
|
-
}
|
|
634
|
-
return { ...result, installedUserPromptSubmit, installedCompactResume };
|
|
635
|
-
}
|
|
636
|
-
export function installJsonHooks(target) {
|
|
637
|
-
const { settings: settingsPath, logFile } = resolveJsonHookPaths(target);
|
|
638
|
-
const dir = path.dirname(settingsPath);
|
|
639
|
-
if (!fs.existsSync(dir))
|
|
640
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
641
|
-
let settings = {};
|
|
642
|
-
if (fs.existsSync(settingsPath)) {
|
|
643
|
-
try {
|
|
644
|
-
settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
645
|
-
}
|
|
646
|
-
catch {
|
|
647
|
-
return { ...nothingInstalled(target, settingsPath), invalidJson: true };
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
if (target === 'codex')
|
|
651
|
-
return installCodexHooks(settingsPath, settings);
|
|
652
|
-
if (!settings.hooks)
|
|
653
|
-
settings.hooks = {};
|
|
654
|
-
// SAFETY: settings.hooks is either freshly initialised to {} on the line above, or an
|
|
655
|
-
// existing value from settings.json — Claude Code's own schema always writes an object
|
|
656
|
-
// there; each event key below is still re-validated with Array.isArray before use.
|
|
657
|
-
const hooks = settings.hooks;
|
|
658
|
-
let migratedFromStop = false;
|
|
659
|
-
if (Array.isArray(hooks.Stop) && hookArrayContains(hooks.Stop, HIPPO_SLEEP_MARKER)) {
|
|
660
|
-
hooks.Stop = hooks.Stop.filter((entry) => !JSON.stringify(entry).includes(HIPPO_SLEEP_MARKER));
|
|
661
|
-
if (hooks.Stop.length === 0)
|
|
662
|
-
delete hooks.Stop;
|
|
663
|
-
migratedFromStop = true;
|
|
664
|
-
}
|
|
665
|
-
// Migrate legacy SessionEnd forms:
|
|
666
|
-
// - pre-0.21 bare `hippo sleep`
|
|
667
|
-
// - 0.21.x+ `hippo sleep --log-file` split across two entries
|
|
668
|
-
// - 0.22.x `hippo capture --last-session --log-file` second entry
|
|
669
|
-
// All of these get collapsed into the single `hippo session-end` entry.
|
|
670
|
-
let migratedLegacySessionEnd = false;
|
|
671
|
-
let migratedSplitSessionEnd = false;
|
|
672
|
-
if (Array.isArray(hooks.SessionEnd) && hasLegacySplitSessionEnd(hooks.SessionEnd)) {
|
|
673
|
-
const before = hooks.SessionEnd.length;
|
|
674
|
-
hooks.SessionEnd = hooks.SessionEnd.filter((entry) => {
|
|
675
|
-
const s = JSON.stringify(entry);
|
|
676
|
-
return !s.includes(HIPPO_SLEEP_MARKER) && !s.includes(HIPPO_CAPTURE_MARKER);
|
|
677
|
-
});
|
|
678
|
-
if (hooks.SessionEnd.length === 0)
|
|
679
|
-
delete hooks.SessionEnd;
|
|
680
|
-
// If the removed entries used the log-file pattern (0.21.x-0.22.x) we
|
|
681
|
-
// call it a "split" migration; otherwise it was the older bare form.
|
|
682
|
-
migratedSplitSessionEnd = true;
|
|
683
|
-
migratedLegacySessionEnd = before > 1;
|
|
684
|
-
}
|
|
685
|
-
let installedSessionEnd = false;
|
|
686
|
-
if (!hasCurrentSessionEnd(hooks.SessionEnd)) {
|
|
687
|
-
if (!Array.isArray(hooks.SessionEnd))
|
|
688
|
-
hooks.SessionEnd = [];
|
|
689
|
-
hooks.SessionEnd.push({
|
|
690
|
-
hooks: [
|
|
691
|
-
{
|
|
692
|
-
type: 'command',
|
|
693
|
-
command: `hippo session-end --log-file "${logFile}"`,
|
|
694
|
-
timeout: 5,
|
|
695
|
-
},
|
|
696
|
-
],
|
|
697
|
-
});
|
|
698
|
-
installedSessionEnd = true;
|
|
699
|
-
}
|
|
700
|
-
let installedSessionStart = false;
|
|
701
|
-
if (!hookArrayContains(hooks.SessionStart, HIPPO_LAST_SLEEP_MARKER)) {
|
|
702
|
-
if (!Array.isArray(hooks.SessionStart))
|
|
703
|
-
hooks.SessionStart = [];
|
|
704
|
-
hooks.SessionStart.push({
|
|
705
|
-
hooks: [
|
|
706
|
-
{
|
|
707
|
-
type: 'command',
|
|
708
|
-
command: `hippo last-sleep --path "${logFile}"`,
|
|
709
|
-
timeout: 5,
|
|
710
|
-
},
|
|
711
|
-
],
|
|
712
|
-
});
|
|
713
|
-
installedSessionStart = true;
|
|
714
|
-
}
|
|
715
|
-
// Mid-session pinned-rule re-injection: UserPromptSubmit runs every turn,
|
|
716
|
-
// so pinned memories stay in context even after the model would otherwise
|
|
717
|
-
// "forget" them in a long session. Include the fresh write tail so lessons
|
|
718
|
-
// saved earlier in the same session become visible on the next prompt even
|
|
719
|
-
// before the user pins them explicitly.
|
|
720
|
-
let installedUserPromptSubmit = false;
|
|
721
|
-
const migratedPinnedInjectRecent = migratePinnedInjectRecentCommands(hooks.UserPromptSubmit);
|
|
722
|
-
if (!hookArrayContains(hooks.UserPromptSubmit, HIPPO_PINNED_INJECT_MARKER)) {
|
|
723
|
-
if (!Array.isArray(hooks.UserPromptSubmit))
|
|
724
|
-
hooks.UserPromptSubmit = [];
|
|
725
|
-
hooks.UserPromptSubmit.push({
|
|
726
|
-
hooks: [
|
|
727
|
-
{
|
|
728
|
-
type: 'command',
|
|
729
|
-
command: HIPPO_PINNED_INJECT_COMMAND,
|
|
730
|
-
timeout: 5,
|
|
731
|
-
},
|
|
732
|
-
],
|
|
733
|
-
});
|
|
734
|
-
installedUserPromptSubmit = true;
|
|
735
|
-
}
|
|
736
|
-
// PreCompact: fires on manual AND auto compaction (no matcher). Records the compaction, asks the
|
|
737
|
-
// summariser for a "Memories for hippo" list and saves a working-state snapshot before the summary drops detail.
|
|
738
|
-
// Exit-0 contract lives in the verb itself (src/capture.ts cmdPreCompact),
|
|
739
|
-
// not here — this is install-time wiring only.
|
|
740
|
-
let installedPreCompact = false;
|
|
741
|
-
if (!hookArrayContains(hooks.PreCompact, HIPPO_PRE_COMPACT_MARKER)) {
|
|
742
|
-
if (!Array.isArray(hooks.PreCompact))
|
|
743
|
-
hooks.PreCompact = [];
|
|
744
|
-
hooks.PreCompact.push({
|
|
745
|
-
hooks: [
|
|
746
|
-
{
|
|
747
|
-
type: 'command',
|
|
748
|
-
command: `hippo pre-compact --log-file "${defaultPreCompactLogPath()}"`,
|
|
749
|
-
timeout: 30,
|
|
750
|
-
},
|
|
751
|
-
],
|
|
752
|
-
});
|
|
753
|
-
installedPreCompact = true;
|
|
754
|
-
}
|
|
755
|
-
// SessionStart(compact): a SECOND SessionStart entry alongside the
|
|
756
|
-
// un-matched last-sleep entry above. The matcher is an optimization, not
|
|
757
|
-
// a dependency — compact-resume itself checks payload.source too, so an
|
|
758
|
-
// older Claude Code that ignores the matcher just runs a silent no-op on
|
|
759
|
-
// normal starts. Marker check keys on the command string, so this stays
|
|
760
|
-
// idempotent alongside the sibling last-sleep entry.
|
|
761
|
-
let installedCompactResume = false;
|
|
762
|
-
if (!hookArrayContains(hooks.SessionStart, HIPPO_COMPACT_RESUME_MARKER)) {
|
|
763
|
-
if (!Array.isArray(hooks.SessionStart))
|
|
764
|
-
hooks.SessionStart = [];
|
|
765
|
-
hooks.SessionStart.push({
|
|
766
|
-
matcher: 'compact',
|
|
767
|
-
hooks: [
|
|
768
|
-
{
|
|
769
|
-
type: 'command',
|
|
770
|
-
command: 'hippo compact-resume',
|
|
771
|
-
timeout: 10,
|
|
772
|
-
},
|
|
773
|
-
],
|
|
774
|
-
});
|
|
775
|
-
installedCompactResume = true;
|
|
776
|
-
}
|
|
777
|
-
// PostCompact: saves the memories the summariser listed and prints one line, which Claude Code only shows.
|
|
778
|
-
// PreCompact stdout, by contrast, is handed to the summariser as instructions, so pre-compact prints just the request.
|
|
779
|
-
let installedPostCompact = false;
|
|
780
|
-
if (!hookArrayContains(hooks.PostCompact, HIPPO_POST_COMPACT_MARKER)) {
|
|
781
|
-
if (!Array.isArray(hooks.PostCompact))
|
|
782
|
-
hooks.PostCompact = [];
|
|
783
|
-
hooks.PostCompact.push({
|
|
784
|
-
hooks: [
|
|
785
|
-
{
|
|
786
|
-
type: 'command',
|
|
787
|
-
command: `hippo post-compact --log-file "${defaultPreCompactLogPath()}"`,
|
|
788
|
-
timeout: 10,
|
|
789
|
-
},
|
|
790
|
-
],
|
|
791
|
-
});
|
|
792
|
-
installedPostCompact = true;
|
|
793
|
-
}
|
|
794
|
-
// PostToolUseFailure: a failed tool call becomes an error memory, after
|
|
795
|
-
// `hippo capture-error` drops routine failures (interrupts, declined
|
|
796
|
-
// permissions, empty searches) and repeats. Same hook the plugin ships.
|
|
797
|
-
let installedCaptureError = false;
|
|
798
|
-
if (!hookArrayContains(hooks.PostToolUseFailure, HIPPO_CAPTURE_ERROR_MARKER)) {
|
|
799
|
-
if (!Array.isArray(hooks.PostToolUseFailure))
|
|
800
|
-
hooks.PostToolUseFailure = [];
|
|
801
|
-
hooks.PostToolUseFailure.push({
|
|
802
|
-
matcher: '.*',
|
|
803
|
-
hooks: [
|
|
804
|
-
{
|
|
805
|
-
type: 'command',
|
|
806
|
-
command: 'hippo capture-error',
|
|
807
|
-
timeout: 10,
|
|
808
|
-
},
|
|
809
|
-
],
|
|
810
|
-
});
|
|
811
|
-
installedCaptureError = true;
|
|
812
|
-
}
|
|
813
|
-
if (installedSessionEnd ||
|
|
814
|
-
installedSessionStart ||
|
|
815
|
-
installedUserPromptSubmit ||
|
|
816
|
-
installedPreCompact ||
|
|
817
|
-
installedCompactResume ||
|
|
818
|
-
installedPostCompact ||
|
|
819
|
-
installedCaptureError ||
|
|
820
|
-
migratedPinnedInjectRecent ||
|
|
821
|
-
migratedFromStop ||
|
|
822
|
-
migratedLegacySessionEnd ||
|
|
823
|
-
migratedSplitSessionEnd) {
|
|
824
|
-
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n', 'utf8');
|
|
825
|
-
}
|
|
826
|
-
return {
|
|
827
|
-
target,
|
|
828
|
-
settingsPath,
|
|
829
|
-
installedSessionEnd,
|
|
830
|
-
installedSessionStart,
|
|
831
|
-
installedUserPromptSubmit,
|
|
832
|
-
installedPreCompact,
|
|
833
|
-
installedCompactResume,
|
|
834
|
-
installedPostCompact,
|
|
835
|
-
installedCaptureError,
|
|
836
|
-
migratedPinnedInjectRecent,
|
|
837
|
-
migratedFromStop,
|
|
838
|
-
migratedLegacySessionEnd,
|
|
839
|
-
migratedSplitSessionEnd,
|
|
840
|
-
invalidJson: false,
|
|
841
|
-
};
|
|
842
|
-
}
|
|
843
|
-
/** The exact command hippo writes for each Codex event; uninstall removes only these handlers. */
|
|
844
|
-
const CODEX_HOOK_COMMANDS = [
|
|
845
|
-
['UserPromptSubmit', HIPPO_PINNED_INJECT_COMMAND],
|
|
846
|
-
['SessionStart', HIPPO_COMPACT_RESUME_MARKER],
|
|
847
|
-
];
|
|
848
|
-
/** A group loses only hippo's handlers and goes only once empty, so a user's hook beside or like hippo's stays. */
|
|
849
|
-
function uninstallCodexHooks(hooks) {
|
|
850
|
-
let changed = false;
|
|
851
|
-
for (const [event, command] of CODEX_HOOK_COMMANDS) {
|
|
852
|
-
const groups = hooks[event];
|
|
853
|
-
if (!Array.isArray(groups))
|
|
854
|
-
continue;
|
|
855
|
-
let removed = false;
|
|
856
|
-
const kept = groups.flatMap((group) => {
|
|
857
|
-
if (!isJsonObject(group) || !Array.isArray(group.hooks))
|
|
858
|
-
return [group];
|
|
859
|
-
const handlers = group.hooks.filter((h) => !(isJsonObject(h) && h.command === command));
|
|
860
|
-
if (handlers.length === group.hooks.length)
|
|
861
|
-
return [group];
|
|
862
|
-
removed = true;
|
|
863
|
-
return handlers.length > 0 ? [{ ...group, hooks: handlers }] : [];
|
|
864
|
-
});
|
|
865
|
-
if (!removed)
|
|
866
|
-
continue;
|
|
867
|
-
changed = true;
|
|
868
|
-
if (kept.length > 0)
|
|
869
|
-
hooks[event] = kept;
|
|
870
|
-
else
|
|
871
|
-
delete hooks[event];
|
|
872
|
-
}
|
|
873
|
-
return changed;
|
|
874
|
-
}
|
|
875
|
-
export function uninstallJsonHooks(target) {
|
|
876
|
-
const { settings: settingsPath } = resolveJsonHookPaths(target);
|
|
877
|
-
if (!fs.existsSync(settingsPath))
|
|
878
|
-
return false;
|
|
879
|
-
let settings;
|
|
880
|
-
try {
|
|
881
|
-
settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
882
|
-
}
|
|
883
|
-
catch {
|
|
884
|
-
// Never rewrite a settings file we cannot parse; report nothing uninstalled.
|
|
885
|
-
return false;
|
|
886
|
-
}
|
|
887
|
-
if (!isJsonObject(settings) || !isJsonObject(settings.hooks))
|
|
888
|
-
return false;
|
|
889
|
-
const changed = target === 'codex' ? uninstallCodexHooks(settings.hooks) : uninstallClaudeCodeHooks(settings.hooks);
|
|
890
|
-
if (!changed)
|
|
891
|
-
return false;
|
|
892
|
-
if (Object.keys(settings.hooks).length === 0)
|
|
893
|
-
delete settings.hooks;
|
|
894
|
-
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n', 'utf8');
|
|
895
|
-
return true;
|
|
896
|
-
}
|
|
897
|
-
function uninstallClaudeCodeHooks(settingsHooks) {
|
|
898
|
-
// SAFETY: each event key below is re-validated with Array.isArray before use.
|
|
899
|
-
const hooks = settingsHooks;
|
|
900
|
-
let changed = false;
|
|
901
|
-
const markersByKey = {
|
|
902
|
-
SessionEnd: [HIPPO_SESSION_END_MARKER, HIPPO_SLEEP_MARKER, HIPPO_CAPTURE_MARKER],
|
|
903
|
-
// Both the un-matched last-sleep entry and the matcher:'compact'
|
|
904
|
-
// compact-resume entry live under the SessionStart key; the matcher
|
|
905
|
-
// field doesn't affect this substring match, so removal covers both.
|
|
906
|
-
SessionStart: [HIPPO_LAST_SLEEP_MARKER, HIPPO_COMPACT_RESUME_MARKER],
|
|
907
|
-
UserPromptSubmit: [HIPPO_PINNED_INJECT_MARKER],
|
|
908
|
-
PreCompact: [HIPPO_PRE_COMPACT_MARKER],
|
|
909
|
-
PostCompact: [HIPPO_POST_COMPACT_MARKER],
|
|
910
|
-
PostToolUseFailure: [HIPPO_CAPTURE_ERROR_MARKER],
|
|
911
|
-
Stop: [HIPPO_SLEEP_MARKER],
|
|
912
|
-
};
|
|
913
|
-
for (const [key, markers] of Object.entries(markersByKey)) {
|
|
914
|
-
if (!Array.isArray(hooks[key]))
|
|
915
|
-
continue;
|
|
916
|
-
const before = hooks[key].length;
|
|
917
|
-
hooks[key] = hooks[key].filter((entry) => !markers.some((m) => JSON.stringify(entry).includes(m)));
|
|
918
|
-
if (hooks[key].length !== before) {
|
|
919
|
-
changed = true;
|
|
920
|
-
if (hooks[key].length === 0)
|
|
921
|
-
delete hooks[key];
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
return changed;
|
|
925
|
-
}
|
|
926
|
-
export function resolveOpencodePluginPath() {
|
|
927
|
-
return path.join(homeDir(), '.config', 'opencode', 'plugins', 'hippo.ts');
|
|
928
|
-
}
|
|
929
|
-
function resolveOpencodeConfigPath() {
|
|
930
|
-
return path.join(homeDir(), '.config', 'opencode', 'opencode.json');
|
|
931
|
-
}
|
|
932
|
-
/**
|
|
933
|
-
* Return true iff a single hook-array entry's command string starts with
|
|
934
|
-
* `hippo ` (the verb-prefix). Used to surgically remove only hippo-owned
|
|
935
|
-
* commands when migrating an opencode.json. We own the install side, so only
|
|
936
|
-
* the canonical `hippo <verb>` form needs to match — and only canonical verbs
|
|
937
|
-
* hippo itself installs (session-end, last-sleep, sleep, capture, context),
|
|
938
|
-
* not any third-party tool that happens to be named `hippo`.
|
|
939
|
-
*
|
|
940
|
-
* Critic-mandated structural check (Rev 0): substring matching against
|
|
941
|
-
* arbitrary user content is unsafe — a user's
|
|
942
|
-
* `echo "remember to hippo sleep your laptop"` is not a hippo-owned hook.
|
|
943
|
-
*
|
|
944
|
-
* Per-hook (not per-entry) granularity (Rev 1 review): an entry whose inner
|
|
945
|
-
* hooks array mixes hippo-installed commands with user-authored commands
|
|
946
|
-
* must NOT lose the user-authored commands. The migration filters the inner
|
|
947
|
-
* array per-hook, then drops the entry only when its inner array is empty.
|
|
948
|
-
*/
|
|
949
|
-
const HIPPO_OWNED_COMMAND_RE = /^\s*hippo\s+(session-end|last-sleep|sleep|capture|context)\b/;
|
|
950
|
-
function hookIsHippoOwned(hook) {
|
|
951
|
-
if (!isJsonObject(hook))
|
|
952
|
-
return false;
|
|
953
|
-
const cmd = hook.command;
|
|
954
|
-
return isJsonString(cmd) && HIPPO_OWNED_COMMAND_RE.test(cmd);
|
|
955
|
-
}
|
|
956
|
-
/**
|
|
957
|
-
* Structurally strip every hippo-owned hook from opencode.json's hooks key.
|
|
958
|
-
* Returns one of:
|
|
959
|
-
* { migrated: true, jsonRepairFailed: false } — at least one hook removed.
|
|
960
|
-
* { migrated: false, jsonRepairFailed: false } — file fine, nothing to do.
|
|
961
|
-
* { migrated: false, jsonRepairFailed: true } — file present but unparseable.
|
|
962
|
-
*
|
|
963
|
-
* Per-hook surgery:
|
|
964
|
-
* - For each entry in each event-key array, filter the inner `hooks` array
|
|
965
|
-
* to remove hippo-owned hooks only. User-authored hooks in the same
|
|
966
|
-
* inner array are preserved.
|
|
967
|
-
* - When an entry's inner `hooks` array becomes empty, that entry is
|
|
968
|
-
* removed from the outer array.
|
|
969
|
-
* - When an event-key array becomes empty, the key is deleted.
|
|
970
|
-
* - When the top-level `hooks` object becomes empty, it is deleted.
|
|
971
|
-
* - Other keys (theme, etc.) are always preserved.
|
|
972
|
-
*/
|
|
973
|
-
function migrateLegacyOpencodeHooksBlock() {
|
|
974
|
-
const configPath = resolveOpencodeConfigPath();
|
|
975
|
-
if (!fs.existsSync(configPath))
|
|
976
|
-
return { migrated: false, jsonRepairFailed: false };
|
|
977
|
-
let settings;
|
|
978
|
-
try {
|
|
979
|
-
settings = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
980
|
-
}
|
|
981
|
-
catch {
|
|
982
|
-
return { migrated: false, jsonRepairFailed: true };
|
|
983
|
-
}
|
|
984
|
-
const hooks = settings.hooks;
|
|
985
|
-
// Non-object hooks values (string, array, null) are user content we don't
|
|
986
|
-
// recognise — leave them alone, return migrated=false.
|
|
987
|
-
if (!isJsonObject(hooks)) {
|
|
988
|
-
return { migrated: false, jsonRepairFailed: false };
|
|
989
|
-
}
|
|
990
|
-
const hooksObj = hooks;
|
|
991
|
-
let changed = false;
|
|
992
|
-
for (const key of Object.keys(hooksObj)) {
|
|
993
|
-
if (!Array.isArray(hooksObj[key]))
|
|
994
|
-
continue;
|
|
995
|
-
const survivingEntries = [];
|
|
996
|
-
for (const entry of hooksObj[key]) {
|
|
997
|
-
if (!isJsonObject(entry)) {
|
|
998
|
-
survivingEntries.push(entry);
|
|
999
|
-
continue;
|
|
1000
|
-
}
|
|
1001
|
-
const innerHooks = entry.hooks;
|
|
1002
|
-
if (!Array.isArray(innerHooks)) {
|
|
1003
|
-
survivingEntries.push(entry);
|
|
1004
|
-
continue;
|
|
1005
|
-
}
|
|
1006
|
-
const beforeInner = innerHooks.length;
|
|
1007
|
-
const survivingInner = innerHooks.filter((h) => !hookIsHippoOwned(h));
|
|
1008
|
-
if (survivingInner.length !== beforeInner)
|
|
1009
|
-
changed = true;
|
|
1010
|
-
if (survivingInner.length === 0)
|
|
1011
|
-
continue; // drop entry, nothing left
|
|
1012
|
-
entry.hooks = survivingInner;
|
|
1013
|
-
survivingEntries.push(entry);
|
|
1014
|
-
}
|
|
1015
|
-
if (survivingEntries.length !== hooksObj[key].length)
|
|
1016
|
-
changed = true;
|
|
1017
|
-
hooksObj[key] = survivingEntries;
|
|
1018
|
-
if (hooksObj[key].length === 0)
|
|
1019
|
-
delete hooksObj[key];
|
|
1020
|
-
}
|
|
1021
|
-
if (!changed)
|
|
1022
|
-
return { migrated: false, jsonRepairFailed: false };
|
|
1023
|
-
if (Object.keys(hooksObj).length === 0)
|
|
1024
|
-
delete settings.hooks;
|
|
1025
|
-
fs.writeFileSync(configPath, JSON.stringify(settings, null, 2) + '\n', 'utf8');
|
|
1026
|
-
return { migrated: true, jsonRepairFailed: false };
|
|
1027
|
-
}
|
|
1028
|
-
export function installOpencodePlugin() {
|
|
1029
|
-
const pluginPath = resolveOpencodePluginPath();
|
|
1030
|
-
const { migrated, jsonRepairFailed } = migrateLegacyOpencodeHooksBlock();
|
|
1031
|
-
// Idempotence: skip the write only if BOTH the marker is present AND the
|
|
1032
|
-
// content matches the current source. Marker-only matches (with stale
|
|
1033
|
-
// content) overwrite cleanly so future plugin-source patches reach
|
|
1034
|
-
// existing installs.
|
|
1035
|
-
if (fs.existsSync(pluginPath)) {
|
|
1036
|
-
const existing = fs.readFileSync(pluginPath, 'utf8');
|
|
1037
|
-
if (existing.includes(HIPPO_OPENCODE_PLUGIN_MARKER) && existing === OPENCODE_PLUGIN_SOURCE) {
|
|
1038
|
-
return { installed: false, pluginPath, migratedLegacyHooks: migrated, jsonRepairFailed };
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
fs.mkdirSync(path.dirname(pluginPath), { recursive: true });
|
|
1042
|
-
fs.writeFileSync(pluginPath, OPENCODE_PLUGIN_SOURCE, 'utf8');
|
|
1043
|
-
return { installed: true, pluginPath, migratedLegacyHooks: migrated, jsonRepairFailed };
|
|
1044
|
-
}
|
|
1045
|
-
export function uninstallOpencodePlugin() {
|
|
1046
|
-
const pluginPath = resolveOpencodePluginPath();
|
|
1047
|
-
let removedFile = false;
|
|
1048
|
-
if (fs.existsSync(pluginPath)) {
|
|
1049
|
-
const existing = fs.readFileSync(pluginPath, 'utf8');
|
|
1050
|
-
if (existing.includes(HIPPO_OPENCODE_PLUGIN_MARKER)) {
|
|
1051
|
-
fs.unlinkSync(pluginPath);
|
|
1052
|
-
removedFile = true;
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
// Always run the legacy migration on uninstall — the downgrade path (user
|
|
1056
|
-
// removing hippo entirely) must leave opencode launchable.
|
|
1057
|
-
const { migrated } = migrateLegacyOpencodeHooksBlock();
|
|
1058
|
-
return removedFile || migrated;
|
|
1059
|
-
}
|
|
1060
|
-
/**
|
|
1061
|
-
* Detect which AI coding tools are installed based on config directory presence.
|
|
1062
|
-
* Used by `hippo setup` to decide which JSON-hook installs to run.
|
|
1063
|
-
*/
|
|
1064
|
-
export function detectInstalledTools() {
|
|
1065
|
-
const home = homeDir();
|
|
1066
|
-
const exists = (...parts) => fs.existsSync(path.join(home, ...parts));
|
|
1067
|
-
return [
|
|
1068
|
-
{ name: 'claude-code', configDir: '~/.claude', detected: exists('.claude'), kind: 'json-hook' },
|
|
1069
|
-
{ name: 'opencode', configDir: '~/.config/opencode', detected: exists('.config', 'opencode'), kind: 'plugin', notes: 'installs a TS plugin at ~/.config/opencode/plugins/hippo.ts' },
|
|
1070
|
-
{ name: 'openclaw', configDir: '~/.openclaw', detected: exists('.openclaw'), kind: 'plugin', notes: 'install via `openclaw plugins install hippo-memory`' },
|
|
1071
|
-
{ name: 'codex', configDir: '~/.codex', detected: isCodexPresent(home), kind: 'wrapper', notes: 'memory hooks in hooks.json, and wraps the detected codex launcher for session-end consolidation' },
|
|
1072
|
-
{ name: 'cursor', configDir: '~/.cursor', detected: exists('.cursor'), kind: 'markdown-instruction', notes: 'no hook API - patches AGENTS.md in the project' },
|
|
1073
|
-
{ name: 'pi', configDir: '~/.pi', detected: exists('.pi'), kind: 'markdown-instruction', notes: 'no hook API - patches AGENTS.md in the project' },
|
|
1074
|
-
];
|
|
1075
|
-
}
|
|
1076
|
-
//# sourceMappingURL=hooks.js.map
|