opensquid 0.5.441 → 0.5.449
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 +1 -0
- package/dist/functions/arm_scope.d.ts +27 -0
- package/dist/functions/arm_scope.d.ts.map +1 -0
- package/dist/functions/arm_scope.js +52 -0
- package/dist/functions/arm_scope.js.map +1 -0
- package/dist/functions/index.d.ts +1 -0
- package/dist/functions/index.d.ts.map +1 -1
- package/dist/functions/index.js +1 -0
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/recall_pre_inject.d.ts.map +1 -1
- package/dist/functions/recall_pre_inject.js +12 -0
- package/dist/functions/recall_pre_inject.js.map +1 -1
- package/dist/rag/store_git.d.ts +23 -0
- package/dist/rag/store_git.d.ts.map +1 -0
- package/dist/rag/store_git.js +57 -0
- package/dist/rag/store_git.js.map +1 -0
- package/dist/runtime/bootstrap.d.ts.map +1 -1
- package/dist/runtime/bootstrap.js +2 -0
- package/dist/runtime/bootstrap.js.map +1 -1
- package/dist/runtime/handoff/render.d.ts +5 -4
- package/dist/runtime/handoff/render.d.ts.map +1 -1
- package/dist/runtime/handoff/render.js +7 -7
- package/dist/runtime/handoff/render.js.map +1 -1
- package/dist/runtime/hooks/active_task_mirror.js +0 -0
- package/dist/runtime/hooks/apply_patch.js +0 -0
- package/dist/runtime/hooks/dispatch.js +0 -0
- package/dist/runtime/hooks/hook_output.js +0 -0
- package/dist/runtime/hooks/memory_reconcile.js +0 -0
- package/dist/runtime/hooks/new_project_detect.js +0 -0
- package/dist/runtime/hooks/profession_resolver.js +0 -0
- package/dist/runtime/hooks/scope_intent.js +0 -0
- package/dist/runtime/hooks/session-end.js +11 -0
- package/dist/runtime/hooks/session-end.js.map +1 -1
- package/dist/runtime/hooks/session_id.js +0 -0
- package/dist/runtime/hooks/session_liveness.js +0 -0
- package/dist/runtime/hooks/stop_drive.js +0 -0
- package/dist/runtime/hooks/stop_stream.js +0 -0
- package/dist/runtime/hooks/subagent_guard.js +0 -0
- package/dist/runtime/hooks/transcript.js +0 -0
- package/dist/runtime/hooks/transcript_tasks.js +0 -0
- package/dist/runtime/ralph/orchestrator.d.ts.map +1 -1
- package/dist/runtime/ralph/orchestrator.js +2 -1
- package/dist/runtime/ralph/orchestrator.js.map +1 -1
- package/dist/setup/cli/limits_state.d.ts.map +1 -1
- package/dist/setup/cli/limits_state.js +6 -40
- package/dist/setup/cli/limits_state.js.map +1 -1
- package/dist/setup/cli/pack_walk.d.ts +32 -0
- package/dist/setup/cli/pack_walk.d.ts.map +1 -0
- package/dist/setup/cli/pack_walk.js +76 -0
- package/dist/setup/cli/pack_walk.js.map +1 -0
- package/dist/setup/cli/permissions_state.d.ts.map +1 -1
- package/dist/setup/cli/permissions_state.js +6 -37
- package/dist/setup/cli/permissions_state.js.map +1 -1
- package/dist/setup/cli/triggers_state.d.ts.map +1 -1
- package/dist/setup/cli/triggers_state.js +3 -29
- package/dist/setup/cli/triggers_state.js.map +1 -1
- package/dist/workgraph/events.d.ts.map +1 -1
- package/dist/workgraph/events.js +10 -0
- package/dist/workgraph/events.js.map +1 -1
- package/dist/workgraph/store.d.ts.map +1 -1
- package/dist/workgraph/store.js +5 -0
- package/dist/workgraph/store.js.map +1 -1
- package/dist/workgraph/types.d.ts +2 -1
- package/dist/workgraph/types.d.ts.map +1 -1
- package/docs/ARCHITECTURE.md +268 -0
- package/docs/pack-runtime.md +15 -12
- package/docs/skill-grammar-guide.md +4 -4
- package/package.json +5 -3
- package/packs/builtin/coding-flow/skills/entry-and-handoffs/skill.yaml +13 -17
- package/dist/anti-drift/evaluator.d.ts +0 -88
- package/dist/anti-drift/evaluator.d.ts.map +0 -1
- package/dist/anti-drift/evaluator.js +0 -417
- package/dist/anti-drift/evaluator.js.map +0 -1
- package/dist/anti-drift/evaluator.test.js +0 -78
- package/dist/anti-drift/rules.d.ts +0 -80
- package/dist/anti-drift/rules.d.ts.map +0 -1
- package/dist/anti-drift/rules.js +0 -368
- package/dist/anti-drift/rules.js.map +0 -1
- package/dist/anti-drift/rules.test.js +0 -213
- package/dist/anti-drift/state.d.ts +0 -107
- package/dist/anti-drift/state.d.ts.map +0 -1
- package/dist/anti-drift/state.js +0 -177
- package/dist/anti-drift/state.js.map +0 -1
- package/dist/anti-drift/state.test.js +0 -120
- package/dist/chat/adapters/discord.d.ts +0 -41
- package/dist/chat/adapters/discord.d.ts.map +0 -1
- package/dist/chat/adapters/discord.js +0 -176
- package/dist/chat/adapters/discord.js.map +0 -1
- package/dist/chat/adapters/discord.test.js +0 -25
- package/dist/chat/adapters/slack.d.ts +0 -43
- package/dist/chat/adapters/slack.d.ts.map +0 -1
- package/dist/chat/adapters/slack.js +0 -172
- package/dist/chat/adapters/slack.js.map +0 -1
- package/dist/chat/adapters/slack.test.js +0 -30
- package/dist/chat/adapters/telegram.d.ts +0 -148
- package/dist/chat/adapters/telegram.d.ts.map +0 -1
- package/dist/chat/adapters/telegram.js +0 -498
- package/dist/chat/adapters/telegram.js.map +0 -1
- package/dist/chat/adapters/telegram.test.js +0 -94
- package/dist/chat/config.d.ts +0 -98
- package/dist/chat/config.d.ts.map +0 -1
- package/dist/chat/config.js +0 -185
- package/dist/chat/config.js.map +0 -1
- package/dist/chat/daemon/active-project.d.ts +0 -17
- package/dist/chat/daemon/active-project.d.ts.map +0 -1
- package/dist/chat/daemon/active-project.js +0 -23
- package/dist/chat/daemon/active-project.js.map +0 -1
- package/dist/chat/daemon/autospawn.d.ts +0 -40
- package/dist/chat/daemon/autospawn.d.ts.map +0 -1
- package/dist/chat/daemon/autospawn.js +0 -129
- package/dist/chat/daemon/autospawn.js.map +0 -1
- package/dist/chat/daemon/autospawn.test.js +0 -112
- package/dist/chat/daemon/cli.d.ts +0 -18
- package/dist/chat/daemon/cli.d.ts.map +0 -1
- package/dist/chat/daemon/cli.js +0 -71
- package/dist/chat/daemon/cli.js.map +0 -1
- package/dist/chat/daemon/collisions.js +0 -384
- package/dist/chat/daemon/health-check.d.ts +0 -69
- package/dist/chat/daemon/health-check.d.ts.map +0 -1
- package/dist/chat/daemon/health-check.js +0 -112
- package/dist/chat/daemon/health-check.js.map +0 -1
- package/dist/chat/daemon/inbox-read.d.ts +0 -35
- package/dist/chat/daemon/inbox-read.d.ts.map +0 -1
- package/dist/chat/daemon/inbox-read.js +0 -75
- package/dist/chat/daemon/inbox-read.js.map +0 -1
- package/dist/chat/daemon/inbox-read.test.js +0 -97
- package/dist/chat/daemon/inbox.d.ts +0 -63
- package/dist/chat/daemon/inbox.d.ts.map +0 -1
- package/dist/chat/daemon/inbox.js +0 -56
- package/dist/chat/daemon/inbox.js.map +0 -1
- package/dist/chat/daemon/inbox.test.js +0 -110
- package/dist/chat/daemon/lifecycle.d.ts +0 -71
- package/dist/chat/daemon/lifecycle.d.ts.map +0 -1
- package/dist/chat/daemon/lifecycle.js +0 -221
- package/dist/chat/daemon/lifecycle.js.map +0 -1
- package/dist/chat/daemon/lifecycle.test.js +0 -163
- package/dist/chat/daemon/protocol.d.ts +0 -107
- package/dist/chat/daemon/protocol.d.ts.map +0 -1
- package/dist/chat/daemon/protocol.js +0 -54
- package/dist/chat/daemon/protocol.js.map +0 -1
- package/dist/chat/daemon/routing.d.ts +0 -140
- package/dist/chat/daemon/routing.d.ts.map +0 -1
- package/dist/chat/daemon/routing.js +0 -198
- package/dist/chat/daemon/routing.js.map +0 -1
- package/dist/chat/daemon/routing.test.js +0 -259
- package/dist/chat/daemon/rpc-client.d.ts +0 -45
- package/dist/chat/daemon/rpc-client.d.ts.map +0 -1
- package/dist/chat/daemon/rpc-client.js +0 -133
- package/dist/chat/daemon/rpc-client.js.map +0 -1
- package/dist/chat/daemon/rpc-server.d.ts +0 -39
- package/dist/chat/daemon/rpc-server.d.ts.map +0 -1
- package/dist/chat/daemon/rpc-server.js +0 -385
- package/dist/chat/daemon/rpc-server.js.map +0 -1
- package/dist/chat/daemon/rpc.test.js +0 -177
- package/dist/chat/daemon/subscribers.js +0 -257
- package/dist/chat/daemon/worker.d.ts +0 -27
- package/dist/chat/daemon/worker.d.ts.map +0 -1
- package/dist/chat/daemon/worker.js +0 -313
- package/dist/chat/daemon/worker.js.map +0 -1
- package/dist/chat/daemon/workspace-topic.js +0 -324
- package/dist/chat/env-token.d.ts +0 -60
- package/dist/chat/env-token.d.ts.map +0 -1
- package/dist/chat/env-token.js +0 -137
- package/dist/chat/env-token.js.map +0 -1
- package/dist/chat/env-token.test.js +0 -160
- package/dist/chat/factory.d.ts +0 -30
- package/dist/chat/factory.d.ts.map +0 -1
- package/dist/chat/factory.js +0 -50
- package/dist/chat/factory.js.map +0 -1
- package/dist/chat/factory.test.js +0 -55
- package/dist/chat/gateway.d.ts +0 -176
- package/dist/chat/gateway.d.ts.map +0 -1
- package/dist/chat/gateway.js +0 -146
- package/dist/chat/gateway.js.map +0 -1
- package/dist/chat/gateway.test.js +0 -192
- package/dist/claude-md.d.ts +0 -39
- package/dist/claude-md.d.ts.map +0 -1
- package/dist/claude-md.js +0 -113
- package/dist/claude-md.js.map +0 -1
- package/dist/claude-md.test.js +0 -91
- package/dist/codex/activate.d.ts +0 -66
- package/dist/codex/activate.d.ts.map +0 -1
- package/dist/codex/activate.js +0 -329
- package/dist/codex/activate.js.map +0 -1
- package/dist/codex/activate.test.js +0 -229
- package/dist/codex/bundled-default/bundled-default.test.js +0 -161
- package/dist/codex/cli-publish.test.js +0 -133
- package/dist/codex/cli.d.ts +0 -35
- package/dist/codex/cli.d.ts.map +0 -1
- package/dist/codex/cli.js +0 -554
- package/dist/codex/cli.js.map +0 -1
- package/dist/codex/cli.test.js +0 -277
- package/dist/codex/import-skill-md.d.ts +0 -53
- package/dist/codex/import-skill-md.d.ts.map +0 -1
- package/dist/codex/import-skill-md.js +0 -236
- package/dist/codex/import-skill-md.js.map +0 -1
- package/dist/codex/import-skill-md.test.js +0 -225
- package/dist/codex/loader.d.ts +0 -27
- package/dist/codex/loader.d.ts.map +0 -1
- package/dist/codex/loader.js +0 -86
- package/dist/codex/loader.js.map +0 -1
- package/dist/codex/loader.test.js +0 -75
- package/dist/codex/parse.d.ts +0 -28
- package/dist/codex/parse.d.ts.map +0 -1
- package/dist/codex/parse.js +0 -309
- package/dist/codex/parse.js.map +0 -1
- package/dist/codex/parse.test.js +0 -241
- package/dist/codex/store.d.ts +0 -87
- package/dist/codex/store.d.ts.map +0 -1
- package/dist/codex/store.js +0 -205
- package/dist/codex/store.js.map +0 -1
- package/dist/codex/store.test.js +0 -242
- package/dist/codex/types.d.ts +0 -398
- package/dist/codex/types.d.ts.map +0 -1
- package/dist/codex/types.js +0 -21
- package/dist/codex/types.js.map +0 -1
- package/dist/config.d.ts +0 -53
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -202
- package/dist/config.js.map +0 -1
- package/dist/config.test.js +0 -117
- package/dist/engine/cli.d.ts +0 -14
- package/dist/engine/cli.d.ts.map +0 -1
- package/dist/engine/cli.js +0 -171
- package/dist/engine/cli.js.map +0 -1
- package/dist/engine/client.d.ts +0 -219
- package/dist/engine/client.d.ts.map +0 -1
- package/dist/engine/client.js +0 -312
- package/dist/engine/client.js.map +0 -1
- package/dist/engine/config.d.ts +0 -62
- package/dist/engine/config.d.ts.map +0 -1
- package/dist/engine/config.js +0 -223
- package/dist/engine/config.js.map +0 -1
- package/dist/engine/index.d.ts +0 -17
- package/dist/engine/index.d.ts.map +0 -1
- package/dist/engine/index.js +0 -16
- package/dist/engine/index.js.map +0 -1
- package/dist/engine/resolver.d.ts +0 -62
- package/dist/engine/resolver.d.ts.map +0 -1
- package/dist/engine/resolver.js +0 -103
- package/dist/engine/resolver.js.map +0 -1
- package/dist/engine/singleton.d.ts +0 -95
- package/dist/engine/singleton.d.ts.map +0 -1
- package/dist/engine/singleton.js +0 -325
- package/dist/engine/singleton.js.map +0 -1
- package/dist/engine/types.d.ts +0 -402
- package/dist/engine/types.d.ts.map +0 -1
- package/dist/engine/types.js +0 -22
- package/dist/engine/types.js.map +0 -1
- package/dist/engine-binary-resolver.js +0 -110
- package/dist/engine-binary-resolver.test.js +0 -61
- package/dist/engine-cli.js +0 -60
- package/dist/engine-client.js +0 -301
- package/dist/engine-client.test.js +0 -118
- package/dist/functions/chain_state.d.ts +0 -51
- package/dist/functions/chain_state.d.ts.map +0 -1
- package/dist/functions/chain_state.js +0 -59
- package/dist/functions/chain_state.js.map +0 -1
- package/dist/hooks/drift-catalog.d.ts +0 -68
- package/dist/hooks/drift-catalog.d.ts.map +0 -1
- package/dist/hooks/drift-catalog.js +0 -184
- package/dist/hooks/drift-catalog.js.map +0 -1
- package/dist/hooks/drift-catalog.test.js +0 -154
- package/dist/hooks/drift-patterns.d.ts +0 -110
- package/dist/hooks/drift-patterns.d.ts.map +0 -1
- package/dist/hooks/drift-patterns.js +0 -289
- package/dist/hooks/drift-patterns.js.map +0 -1
- package/dist/hooks/drift-patterns.test.js +0 -325
- package/dist/hooks/engine-vocab-gate.d.ts +0 -108
- package/dist/hooks/engine-vocab-gate.d.ts.map +0 -1
- package/dist/hooks/engine-vocab-gate.js +0 -225
- package/dist/hooks/engine-vocab-gate.js.map +0 -1
- package/dist/hooks/engine-vocab-gate.test.js +0 -170
- package/dist/hooks/heartbeat.d.ts +0 -107
- package/dist/hooks/heartbeat.d.ts.map +0 -1
- package/dist/hooks/heartbeat.js +0 -316
- package/dist/hooks/heartbeat.js.map +0 -1
- package/dist/hooks/heartbeat.test.js +0 -393
- package/dist/hooks/honesty-ledger-session-scope.test.js +0 -100
- package/dist/hooks/honesty-ledger.d.ts +0 -123
- package/dist/hooks/honesty-ledger.d.ts.map +0 -1
- package/dist/hooks/honesty-ledger.js +0 -226
- package/dist/hooks/honesty-ledger.js.map +0 -1
- package/dist/hooks/honesty-ledger.test.js +0 -466
- package/dist/hooks/inline-report-check.d.ts +0 -63
- package/dist/hooks/inline-report-check.d.ts.map +0 -1
- package/dist/hooks/inline-report-check.js +0 -88
- package/dist/hooks/inline-report-check.js.map +0 -1
- package/dist/hooks/inline-report-check.test.js +0 -96
- package/dist/hooks/pre-tool-use.d.ts +0 -62
- package/dist/hooks/pre-tool-use.d.ts.map +0 -1
- package/dist/hooks/pre-tool-use.js +0 -342
- package/dist/hooks/pre-tool-use.js.map +0 -1
- package/dist/hooks/pre-tool-use.test.js +0 -134
- package/dist/hooks/session-end.d.ts +0 -15
- package/dist/hooks/session-end.d.ts.map +0 -1
- package/dist/hooks/session-end.js +0 -60
- package/dist/hooks/session-end.js.map +0 -1
- package/dist/hooks/session-end.test.js +0 -52
- package/dist/hooks/stop.d.ts +0 -35
- package/dist/hooks/stop.d.ts.map +0 -1
- package/dist/hooks/stop.js +0 -136
- package/dist/hooks/stop.js.map +0 -1
- package/dist/hooks/transcript-active-task.test.js +0 -342
- package/dist/hooks/transcript.d.ts +0 -26
- package/dist/hooks/transcript.d.ts.map +0 -1
- package/dist/hooks/transcript.js +0 -266
- package/dist/hooks/transcript.js.map +0 -1
- package/dist/hooks/transcript.test.js +0 -103
- package/dist/hooks/user-prompt-submit.d.ts +0 -74
- package/dist/hooks/user-prompt-submit.d.ts.map +0 -1
- package/dist/hooks/user-prompt-submit.js +0 -256
- package/dist/hooks/user-prompt-submit.js.map +0 -1
- package/dist/hooks/user-prompt-submit.test.js +0 -118
- package/dist/hooks/versioning-gate.d.ts +0 -101
- package/dist/hooks/versioning-gate.d.ts.map +0 -1
- package/dist/hooks/versioning-gate.js +0 -245
- package/dist/hooks/versioning-gate.js.map +0 -1
- package/dist/hooks/versioning-gate.test.js +0 -368
- package/dist/hooks/workflow-gate.d.ts +0 -64
- package/dist/hooks/workflow-gate.d.ts.map +0 -1
- package/dist/hooks/workflow-gate.js +0 -152
- package/dist/hooks/workflow-gate.js.map +0 -1
- package/dist/hooks/workflow-gate.test.js +0 -197
- package/dist/hooks-cli.d.ts +0 -25
- package/dist/hooks-cli.d.ts.map +0 -1
- package/dist/hooks-cli.js +0 -286
- package/dist/hooks-cli.js.map +0 -1
- package/dist/hooks-cli.test.js +0 -148
- package/dist/origin.d.ts +0 -16
- package/dist/origin.d.ts.map +0 -1
- package/dist/origin.js +0 -92
- package/dist/origin.js.map +0 -1
- package/dist/packs/seed_lessons_ingest.d.ts +0 -30
- package/dist/packs/seed_lessons_ingest.d.ts.map +0 -1
- package/dist/packs/seed_lessons_ingest.js +0 -107
- package/dist/packs/seed_lessons_ingest.js.map +0 -1
- package/dist/project-cli.d.ts +0 -7
- package/dist/project-cli.d.ts.map +0 -1
- package/dist/project-cli.js +0 -145
- package/dist/project-cli.js.map +0 -1
- package/dist/project.d.ts +0 -127
- package/dist/project.d.ts.map +0 -1
- package/dist/project.js +0 -281
- package/dist/project.js.map +0 -1
- package/dist/project.test.js +0 -287
- package/dist/rag/backends/loop_engine.d.ts +0 -61
- package/dist/rag/backends/loop_engine.d.ts.map +0 -1
- package/dist/rag/backends/loop_engine.js +0 -160
- package/dist/rag/backends/loop_engine.js.map +0 -1
- package/dist/recall.d.ts +0 -82
- package/dist/recall.d.ts.map +0 -1
- package/dist/recall.js +0 -81
- package/dist/recall.js.map +0 -1
- package/dist/runtime/agent_bridge/autospawn.d.ts +0 -131
- package/dist/runtime/agent_bridge/autospawn.d.ts.map +0 -1
- package/dist/runtime/agent_bridge/autospawn.js +0 -251
- package/dist/runtime/agent_bridge/autospawn.js.map +0 -1
- package/dist/runtime/chain_state.d.ts +0 -124
- package/dist/runtime/chain_state.d.ts.map +0 -1
- package/dist/runtime/chain_state.js +0 -189
- package/dist/runtime/chain_state.js.map +0 -1
- package/dist/runtime/hooks/permission_decision.d.ts +0 -34
- package/dist/runtime/hooks/permission_decision.d.ts.map +0 -1
- package/dist/runtime/hooks/permission_decision.js +0 -39
- package/dist/runtime/hooks/permission_decision.js.map +0 -1
- package/dist/runtime/workflow_fsm.d.ts +0 -21
- package/dist/runtime/workflow_fsm.d.ts.map +0 -1
- package/dist/runtime/workflow_fsm.js +0 -25
- package/dist/runtime/workflow_fsm.js.map +0 -1
- package/dist/runtime/workflow_map.d.ts +0 -26
- package/dist/runtime/workflow_map.d.ts.map +0 -1
- package/dist/runtime/workflow_map.js +0 -38
- package/dist/runtime/workflow_map.js.map +0 -1
- package/dist/scope.d.ts +0 -48
- package/dist/scope.d.ts.map +0 -1
- package/dist/scope.js +0 -111
- package/dist/scope.js.map +0 -1
- package/dist/setup/cli/topic_create_step.d.ts +0 -84
- package/dist/setup/cli/topic_create_step.d.ts.map +0 -1
- package/dist/setup/cli/topic_create_step.js +0 -213
- package/dist/setup/cli/topic_create_step.js.map +0 -1
- package/dist/system-export.d.ts +0 -65
- package/dist/system-export.d.ts.map +0 -1
- package/dist/system-export.js +0 -194
- package/dist/system-export.js.map +0 -1
- package/dist/utterance/classifier.d.ts +0 -53
- package/dist/utterance/classifier.d.ts.map +0 -1
- package/dist/utterance/classifier.js +0 -184
- package/dist/utterance/classifier.js.map +0 -1
- package/dist/utterance/classifier.test.js +0 -147
package/dist/hooks-cli.js
DELETED
|
@@ -1,286 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `opensquid hooks <subcommand>` — Claude Code settings.json hooks
|
|
3
|
-
* installer.
|
|
4
|
-
*
|
|
5
|
-
* Subcommands:
|
|
6
|
-
* install — append the opensquid PreToolUse hook to
|
|
7
|
-
* ~/.claude/settings.json (idempotent — re-running
|
|
8
|
-
* refreshes the hook command pointer without disturbing
|
|
9
|
-
* other hooks)
|
|
10
|
-
* uninstall — remove the opensquid PreToolUse hook
|
|
11
|
-
* doctor — report what's currently installed
|
|
12
|
-
*
|
|
13
|
-
* The PreToolUse hook runs the local opensquid build's `hook
|
|
14
|
-
* pre-tool-use` handler (see src/hooks/pre-tool-use.ts), which
|
|
15
|
-
* intercepts known-anti-pattern actions (amend, push, substrate-impure
|
|
16
|
-
* engine commits) before Claude Code executes them.
|
|
17
|
-
*/
|
|
18
|
-
import { promises as fs } from "node:fs";
|
|
19
|
-
import * as os from "node:os";
|
|
20
|
-
import * as path from "node:path";
|
|
21
|
-
import * as url from "node:url";
|
|
22
|
-
export class HooksCliError extends Error {
|
|
23
|
-
hint;
|
|
24
|
-
constructor(message, hint) {
|
|
25
|
-
super(message);
|
|
26
|
-
this.hint = hint;
|
|
27
|
-
this.name = "HooksCliError";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Per-event opensquid hook id. Was a single shared id pre-#118, which
|
|
32
|
-
* meant uninstall could not selectively target one event AND legacy
|
|
33
|
-
* entries written by older opensquid versions never got recognized
|
|
34
|
-
* (since they had a different id, or none at all).
|
|
35
|
-
*/
|
|
36
|
-
const HOOK_IDS = {
|
|
37
|
-
PreToolUse: "opensquid-pre-tool-use",
|
|
38
|
-
Stop: "opensquid-stop",
|
|
39
|
-
StopFalseStopGuard: "opensquid-stop-false-stop-guard",
|
|
40
|
-
UserPromptSubmit: "opensquid-user-prompt-submit",
|
|
41
|
-
SessionEnd: "opensquid-session-end",
|
|
42
|
-
};
|
|
43
|
-
/** Legacy id used through 2026-05-15 — purgeOurHook still recognizes it. */
|
|
44
|
-
const LEGACY_HOOK_ID = "opensquid-drift-pretooluse";
|
|
45
|
-
/**
|
|
46
|
-
* Path-substring fallback that identifies opensquid hook entries even
|
|
47
|
-
* when no `_id` marker is present (older installs, manual edits, etc.).
|
|
48
|
-
* Matches anything that runs `opensquid/dist/index.js`, regardless of
|
|
49
|
-
* whether the subcommand is the legacy `hook <event>` (≤0.7.34) or the
|
|
50
|
-
* new unified `anti-drift <event>` (0.7.35+).
|
|
51
|
-
*/
|
|
52
|
-
const COMMAND_FINGERPRINT = "/opensquid/dist/index.js";
|
|
53
|
-
/**
|
|
54
|
-
* D9 false-stop guard prompt — fires as a `type: "prompt"` Stop hook
|
|
55
|
-
* alongside the existing `type: "command"` Stop hook. Claude Code
|
|
56
|
-
* evaluates this prompt against the assistant's just-completed turn
|
|
57
|
-
* via the configured model and uses the YES/NO answer to allow or
|
|
58
|
-
* block the stop. When blocked, the agent is re-prompted to continue.
|
|
59
|
-
*
|
|
60
|
-
* The prompt is intentionally framed so the default (YES, allow stop)
|
|
61
|
-
* fires on the vast majority of turns; only trailing politeness
|
|
62
|
-
* reflexes ("Run it?", "Want me to start B4?", "Should I continue?")
|
|
63
|
-
* tip it to NO.
|
|
64
|
-
*
|
|
65
|
-
* Catches drift D9 per loop/docs/opensquid-anti-drift-unified-evaluator-design.md
|
|
66
|
-
* rule #10b. Locked 2026-05-17 — user requirement: complete prevention.
|
|
67
|
-
*/
|
|
68
|
-
const FALSE_STOP_GUARD_PROMPT = `The assistant just finished a turn with this message:
|
|
69
|
-
|
|
70
|
-
$ARGUMENTS
|
|
71
|
-
|
|
72
|
-
Did the assistant message above end with a REAL blocking question that requires user input before the agent can continue? Most messages end normally (no question, or with a question mark that's part of a real decision the user must make) and should answer YES (allow the stop).
|
|
73
|
-
|
|
74
|
-
Only answer NO when the message ends with a politeness reflex or suggestion the agent should just execute past — patterns like "Run it?", "Want me to do X?", "Should I continue?", "Ready for the next step?", "Want me to start Y?". These are forbidden by the user's locked automation-mode rule.
|
|
75
|
-
|
|
76
|
-
OUTPUT FORMAT (required): Begin your response with the literal prefix "🦑 [opensquid D9-guard] " so the user can visually identify this as an automated hook output (not agent text). After the prefix, respond YES or NO followed by a one-sentence justification.
|
|
77
|
-
|
|
78
|
-
Examples of well-formed responses:
|
|
79
|
-
- "🦑 [opensquid D9-guard] YES — message ends with a factual statement of completion, not a question."
|
|
80
|
-
- "🦑 [opensquid D9-guard] NO — message ends with 'Want me to start B4?' which is a politeness reflex the agent should execute past."`;
|
|
81
|
-
const FALSE_STOP_GUARD_MODEL = "claude-haiku-4-5";
|
|
82
|
-
function settingsPath() {
|
|
83
|
-
return path.join(os.homedir(), ".claude", "settings.json");
|
|
84
|
-
}
|
|
85
|
-
async function loadSettings() {
|
|
86
|
-
try {
|
|
87
|
-
const raw = await fs.readFile(settingsPath(), "utf8");
|
|
88
|
-
const parsed = JSON.parse(raw);
|
|
89
|
-
return parsed && typeof parsed === "object" ? parsed : {};
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
return {};
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
async function saveSettings(settings) {
|
|
96
|
-
const p = settingsPath();
|
|
97
|
-
await fs.mkdir(path.dirname(p), { recursive: true });
|
|
98
|
-
await fs.writeFile(p, JSON.stringify(settings, null, 2) + "\n", "utf8");
|
|
99
|
-
}
|
|
100
|
-
/** Absolute path to the opensquid CLI binary that hosts this code. */
|
|
101
|
-
function opensquidBinPath() {
|
|
102
|
-
// import.meta.url points at dist/hooks-cli.js after build; the entry
|
|
103
|
-
// point is dist/index.js in the same directory.
|
|
104
|
-
const here = url.fileURLToPath(import.meta.url);
|
|
105
|
-
return path.join(path.dirname(here), "index.js");
|
|
106
|
-
}
|
|
107
|
-
function buildHookCommand(hookName) {
|
|
108
|
-
// 0.7.35 cutover: register hooks pointing at the unified anti-drift
|
|
109
|
-
// evaluator (src/anti-drift/evaluator.ts) instead of the per-file
|
|
110
|
-
// legacy handlers (src/hooks/<event>.ts). The legacy `hook <event>`
|
|
111
|
-
// dispatch is preserved in index.ts for backward compat with
|
|
112
|
-
// settings.json entries that haven't been re-installed yet.
|
|
113
|
-
return `node ${opensquidBinPath()} anti-drift ${hookName}`;
|
|
114
|
-
}
|
|
115
|
-
/** True when a hook entry is recognizably opensquid's. */
|
|
116
|
-
export function isOurHook(h) {
|
|
117
|
-
if (h._id === LEGACY_HOOK_ID)
|
|
118
|
-
return true;
|
|
119
|
-
for (const id of Object.values(HOOK_IDS)) {
|
|
120
|
-
if (h._id === id)
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
// Fallback: command-path fingerprint catches un-marked legacy entries
|
|
124
|
-
// that purgeOurHook used to silently skip (the bug from #118 dogfood).
|
|
125
|
-
// Case-insensitive — macOS APFS default is case-preserving but case-
|
|
126
|
-
// insensitive, so an install at /projects/OpenSquid/ should match too.
|
|
127
|
-
// Prompt-typed hooks have no command field — they're recognized only
|
|
128
|
-
// by their _id (handled above); manual / unmarked prompt entries are
|
|
129
|
-
// not our concern (no installer wrote them).
|
|
130
|
-
if (h.type === "command" &&
|
|
131
|
-
typeof h.command === "string" &&
|
|
132
|
-
h.command.toLowerCase().includes(COMMAND_FINGERPRINT.toLowerCase())) {
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
/** Remove any existing opensquid hook from a matcher list. */
|
|
138
|
-
function purgeOurHook(matchers) {
|
|
139
|
-
return matchers
|
|
140
|
-
.map((m) => ({
|
|
141
|
-
...m,
|
|
142
|
-
hooks: m.hooks.filter((h) => !isOurHook(h)),
|
|
143
|
-
}))
|
|
144
|
-
.filter((m) => m.hooks.length > 0);
|
|
145
|
-
}
|
|
146
|
-
async function cmdInstall() {
|
|
147
|
-
const settings = await loadSettings();
|
|
148
|
-
const hooks = settings.hooks ?? {};
|
|
149
|
-
// PreToolUse — single matcher ".*" is sufficient. It catches Bash
|
|
150
|
-
// (drift checks live in pre-tool-use.ts handler keyed off tool_name)
|
|
151
|
-
// AND every other tool (so the honesty ledger has full evidence for
|
|
152
|
-
// Stop-hook reconciliation). Pre-#118 we registered TWO matchers
|
|
153
|
-
// (Bash + .*) which double-fired on Bash and caused duplicate ledger
|
|
154
|
-
// entries.
|
|
155
|
-
const preToolUse = purgeOurHook(hooks.PreToolUse ?? []);
|
|
156
|
-
preToolUse.push({
|
|
157
|
-
matcher: ".*",
|
|
158
|
-
hooks: [
|
|
159
|
-
{
|
|
160
|
-
type: "command",
|
|
161
|
-
command: buildHookCommand("pre-tool-use"),
|
|
162
|
-
_id: HOOK_IDS.PreToolUse,
|
|
163
|
-
},
|
|
164
|
-
],
|
|
165
|
-
});
|
|
166
|
-
// Stop — claim-vs-action reconciliation + auto-classify spawn at turn end.
|
|
167
|
-
const stop = purgeOurHook(hooks.Stop ?? []);
|
|
168
|
-
stop.push({
|
|
169
|
-
hooks: [{ type: "command", command: buildHookCommand("stop"), _id: HOOK_IDS.Stop }],
|
|
170
|
-
});
|
|
171
|
-
// D9 false-stop guard — fires as a native `type: "prompt"` hook so
|
|
172
|
-
// Claude Code's framework handles the LLM evaluation (no subprocess
|
|
173
|
-
// wrapper needed in opensquid). Catches trailing politeness reflexes
|
|
174
|
-
// like "Run it?" / "Want me to start B4?" and blocks the stop,
|
|
175
|
-
// re-prompting the agent to continue per the user's locked
|
|
176
|
-
// automation-mode rule. Counts against the user's Claude Code
|
|
177
|
-
// subscription model quota (haiku-class, cheap). 0.7.20 / drift D9.
|
|
178
|
-
stop.push({
|
|
179
|
-
hooks: [
|
|
180
|
-
{
|
|
181
|
-
type: "prompt",
|
|
182
|
-
prompt: FALSE_STOP_GUARD_PROMPT,
|
|
183
|
-
model: FALSE_STOP_GUARD_MODEL,
|
|
184
|
-
_id: HOOK_IDS.StopFalseStopGuard,
|
|
185
|
-
},
|
|
186
|
-
],
|
|
187
|
-
});
|
|
188
|
-
// UserPromptSubmit — surface previous turn's broken promises +
|
|
189
|
-
// auto-classify candidates at the start of the next turn.
|
|
190
|
-
const ups = purgeOurHook(hooks.UserPromptSubmit ?? []);
|
|
191
|
-
ups.push({
|
|
192
|
-
hooks: [
|
|
193
|
-
{
|
|
194
|
-
type: "command",
|
|
195
|
-
command: buildHookCommand("user-prompt-submit"),
|
|
196
|
-
_id: HOOK_IDS.UserPromptSubmit,
|
|
197
|
-
},
|
|
198
|
-
],
|
|
199
|
-
});
|
|
200
|
-
// SessionEnd — clearSession to bound disk usage from per-session
|
|
201
|
-
// ledger accumulation.
|
|
202
|
-
const sessionEnd = purgeOurHook(hooks.SessionEnd ?? []);
|
|
203
|
-
sessionEnd.push({
|
|
204
|
-
hooks: [
|
|
205
|
-
{
|
|
206
|
-
type: "command",
|
|
207
|
-
command: buildHookCommand("session-end"),
|
|
208
|
-
_id: HOOK_IDS.SessionEnd,
|
|
209
|
-
},
|
|
210
|
-
],
|
|
211
|
-
});
|
|
212
|
-
settings.hooks = {
|
|
213
|
-
...hooks,
|
|
214
|
-
PreToolUse: preToolUse,
|
|
215
|
-
Stop: stop,
|
|
216
|
-
UserPromptSubmit: ups,
|
|
217
|
-
SessionEnd: sessionEnd,
|
|
218
|
-
};
|
|
219
|
-
await saveSettings(settings);
|
|
220
|
-
console.log(`[opensquid hooks install] wrote ${settingsPath()}`);
|
|
221
|
-
console.log(` PreToolUse → ${buildHookCommand("pre-tool-use")}`);
|
|
222
|
-
console.log(` Stop → ${buildHookCommand("stop")}`);
|
|
223
|
-
console.log(` Stop (D9 guard) → type:prompt model:${FALSE_STOP_GUARD_MODEL}`);
|
|
224
|
-
console.log(` UserPromptSubmit → ${buildHookCommand("user-prompt-submit")}`);
|
|
225
|
-
console.log(` SessionEnd → ${buildHookCommand("session-end")}`);
|
|
226
|
-
console.log(` next: restart Claude Code so the new settings load.`);
|
|
227
|
-
}
|
|
228
|
-
async function cmdUninstall() {
|
|
229
|
-
const settings = await loadSettings();
|
|
230
|
-
const hooks = settings.hooks;
|
|
231
|
-
if (!hooks) {
|
|
232
|
-
console.log(`[opensquid hooks uninstall] no hooks configured`);
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
let totalRemoved = 0;
|
|
236
|
-
for (const event of ["PreToolUse", "Stop", "UserPromptSubmit", "SessionEnd"]) {
|
|
237
|
-
const matchers = hooks[event];
|
|
238
|
-
if (!matchers)
|
|
239
|
-
continue;
|
|
240
|
-
totalRemoved += countOurHooks(matchers);
|
|
241
|
-
const purged = purgeOurHook(matchers);
|
|
242
|
-
if (purged.length === 0) {
|
|
243
|
-
delete hooks[event];
|
|
244
|
-
}
|
|
245
|
-
else {
|
|
246
|
-
hooks[event] = purged;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
await saveSettings(settings);
|
|
250
|
-
console.log(`[opensquid hooks uninstall] removed ${totalRemoved} opensquid hook(s)`);
|
|
251
|
-
}
|
|
252
|
-
async function cmdDoctor() {
|
|
253
|
-
const settings = await loadSettings();
|
|
254
|
-
const hooks = settings.hooks ?? {};
|
|
255
|
-
console.log(`[opensquid hooks doctor]`);
|
|
256
|
-
console.log(` settings.json: ${settingsPath()}`);
|
|
257
|
-
for (const event of ["PreToolUse", "Stop", "UserPromptSubmit", "SessionEnd"]) {
|
|
258
|
-
const matchers = hooks[event] ?? [];
|
|
259
|
-
const ours = countOurHooks(matchers);
|
|
260
|
-
console.log(` ${event.padEnd(18)} total=${matchers.length} opensquid=${ours}`);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
function countOurHooks(matchers) {
|
|
264
|
-
let n = 0;
|
|
265
|
-
for (const m of matchers) {
|
|
266
|
-
for (const h of m.hooks) {
|
|
267
|
-
if (isOurHook(h))
|
|
268
|
-
n++;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
return n;
|
|
272
|
-
}
|
|
273
|
-
export async function runHooksCli(cmd, _argv) {
|
|
274
|
-
switch (cmd) {
|
|
275
|
-
case "install":
|
|
276
|
-
await cmdInstall();
|
|
277
|
-
return;
|
|
278
|
-
case "uninstall":
|
|
279
|
-
await cmdUninstall();
|
|
280
|
-
return;
|
|
281
|
-
case "doctor":
|
|
282
|
-
await cmdDoctor();
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
//# sourceMappingURL=hooks-cli.js.map
|
package/dist/hooks-cli.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-cli.js","sourceRoot":"","sources":["../src.legacy/hooks-cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAEhC,MAAM,OAAO,aAAc,SAAQ,KAAK;IAGpB;IAFlB,YACE,OAAe,EACC,IAAa;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QAFC,SAAI,GAAJ,IAAI,CA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
-
/**
|
|
2
|
-
* Tests for #118 — hooks-cli legacy entry detection + per-event HOOK_IDs.
|
|
3
|
-
*
|
|
4
|
-
* Covers `isOurHook` directly: recognition by per-event id, by legacy id,
|
|
5
|
-
* by command-path fingerprint (un-marked entries from older installs),
|
|
6
|
-
* and rejection of non-opensquid hooks.
|
|
7
|
-
*
|
|
8
|
-
* The install/uninstall integration tests are deferred — they touch the
|
|
9
|
-
* user's real ~/.claude/settings.json and would need test-isolation
|
|
10
|
-
* infrastructure that the hooks-cli module doesn't currently expose.
|
|
11
|
-
*/
|
|
12
|
-
import { describe, expect, it } from "vitest";
|
|
13
|
-
import { isOurHook } from "./hooks-cli.js";
|
|
14
|
-
describe("isOurHook — per-event marker detection", () => {
|
|
15
|
-
it("recognizes the PreToolUse marker", () => {
|
|
16
|
-
expect(isOurHook({
|
|
17
|
-
type: "command",
|
|
18
|
-
command: "node /path/to/something/dist/index.js hook pre-tool-use",
|
|
19
|
-
_id: "opensquid-pre-tool-use",
|
|
20
|
-
})).toBe(true);
|
|
21
|
-
});
|
|
22
|
-
it("recognizes the Stop marker", () => {
|
|
23
|
-
expect(isOurHook({
|
|
24
|
-
type: "command",
|
|
25
|
-
command: "node /path/to/something/dist/index.js hook stop",
|
|
26
|
-
_id: "opensquid-stop",
|
|
27
|
-
})).toBe(true);
|
|
28
|
-
});
|
|
29
|
-
it("recognizes the UserPromptSubmit marker", () => {
|
|
30
|
-
expect(isOurHook({
|
|
31
|
-
type: "command",
|
|
32
|
-
command: "node /path/to/something/dist/index.js hook user-prompt-submit",
|
|
33
|
-
_id: "opensquid-user-prompt-submit",
|
|
34
|
-
})).toBe(true);
|
|
35
|
-
});
|
|
36
|
-
it("recognizes the SessionEnd marker", () => {
|
|
37
|
-
expect(isOurHook({
|
|
38
|
-
type: "command",
|
|
39
|
-
command: "node /path/to/something/dist/index.js hook session-end",
|
|
40
|
-
_id: "opensquid-session-end",
|
|
41
|
-
})).toBe(true);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
describe("isOurHook — legacy marker detection (pre-#118)", () => {
|
|
45
|
-
it("recognizes the legacy opensquid-drift-pretooluse id even on Stop entries", () => {
|
|
46
|
-
expect(isOurHook({
|
|
47
|
-
type: "command",
|
|
48
|
-
command: "node /opt/foo/opensquid/dist/index.js hook stop",
|
|
49
|
-
_id: "opensquid-drift-pretooluse",
|
|
50
|
-
})).toBe(true);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
describe("isOurHook — command-path fallback (un-marked legacy entries)", () => {
|
|
54
|
-
it("recognizes un-marked entries by command-path fingerprint", () => {
|
|
55
|
-
expect(isOurHook({
|
|
56
|
-
type: "command",
|
|
57
|
-
command: "node /Users/alice/projects/opensquid/dist/index.js hook pre-tool-use",
|
|
58
|
-
// No _id — the bug from #118 dogfood that left these undetected.
|
|
59
|
-
})).toBe(true);
|
|
60
|
-
});
|
|
61
|
-
it("recognizes un-marked entries with absolute paths", () => {
|
|
62
|
-
expect(isOurHook({
|
|
63
|
-
type: "command",
|
|
64
|
-
command: "/usr/local/bin/node /opt/opensquid/dist/index.js hook stop",
|
|
65
|
-
})).toBe(true);
|
|
66
|
-
});
|
|
67
|
-
it("matches case-insensitively (macOS APFS case-preserving)", () => {
|
|
68
|
-
expect(isOurHook({
|
|
69
|
-
type: "command",
|
|
70
|
-
command: "node /Users/alice/projects/OpenSquid/dist/index.js hook pre-tool-use",
|
|
71
|
-
})).toBe(true);
|
|
72
|
-
expect(isOurHook({
|
|
73
|
-
type: "command",
|
|
74
|
-
command: "node /OPENSQUID/dist/index.js hook stop",
|
|
75
|
-
})).toBe(true);
|
|
76
|
-
});
|
|
77
|
-
it("does NOT match commands that incidentally contain 'opensquid' in unrelated context", () => {
|
|
78
|
-
expect(isOurHook({
|
|
79
|
-
type: "command",
|
|
80
|
-
command: "echo 'I love opensquid'",
|
|
81
|
-
})).toBe(false);
|
|
82
|
-
});
|
|
83
|
-
it("does NOT match similarly-named third-party tools", () => {
|
|
84
|
-
expect(isOurHook({
|
|
85
|
-
type: "command",
|
|
86
|
-
command: "node /opt/some-other/dist/index.js hook stop",
|
|
87
|
-
})).toBe(false);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
describe("FALSE_STOP_GUARD_PROMPT content (0.7.31 — squid emoji prefix)", () => {
|
|
91
|
-
it("install writes a Stop prompt hook whose prompt instructs Haiku to prefix with 🦑 [opensquid D9-guard]", async () => {
|
|
92
|
-
// Indirect: re-load the source file content via the install module
|
|
93
|
-
// and verify the embedded prompt string contains the marker. Avoids
|
|
94
|
-
// monkeypatching ~/.claude/settings.json in CI.
|
|
95
|
-
const fs = await import("node:fs/promises");
|
|
96
|
-
const path = await import("node:path");
|
|
97
|
-
const url = await import("node:url");
|
|
98
|
-
const here = url.fileURLToPath(import.meta.url);
|
|
99
|
-
const sourcePath = path.join(path.dirname(here), "hooks-cli.ts");
|
|
100
|
-
const src = await fs.readFile(sourcePath, "utf8");
|
|
101
|
-
expect(src).toContain("🦑 [opensquid D9-guard]");
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
describe("isOurHook — prompt-type Stop guard (0.7.20 / drift D9)", () => {
|
|
105
|
-
it("recognizes the false-stop guard prompt hook by _id", () => {
|
|
106
|
-
expect(isOurHook({
|
|
107
|
-
type: "prompt",
|
|
108
|
-
prompt: "any prompt text",
|
|
109
|
-
model: "claude-haiku-4-5",
|
|
110
|
-
_id: "opensquid-stop-false-stop-guard",
|
|
111
|
-
})).toBe(true);
|
|
112
|
-
});
|
|
113
|
-
it("rejects a prompt-type entry with a foreign _id (no command fingerprint to fall back on)", () => {
|
|
114
|
-
expect(isOurHook({
|
|
115
|
-
type: "prompt",
|
|
116
|
-
prompt: "some other prompt",
|
|
117
|
-
model: "claude-haiku-4-5",
|
|
118
|
-
_id: "other-tool-prompt-hook",
|
|
119
|
-
})).toBe(false);
|
|
120
|
-
});
|
|
121
|
-
it("rejects an unmarked prompt-type entry (no _id, no command field)", () => {
|
|
122
|
-
expect(isOurHook({
|
|
123
|
-
type: "prompt",
|
|
124
|
-
prompt: "unmarked prompt",
|
|
125
|
-
})).toBe(false);
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
describe("isOurHook — rejection of foreign hooks", () => {
|
|
129
|
-
it("rejects entries with a different _id and a non-matching command", () => {
|
|
130
|
-
expect(isOurHook({
|
|
131
|
-
type: "command",
|
|
132
|
-
command: "bun run /Users/slee/claude-memory/scripts/sync-to-supabase.ts",
|
|
133
|
-
_id: "memory-sync",
|
|
134
|
-
})).toBe(false);
|
|
135
|
-
});
|
|
136
|
-
it("rejects entries with no _id and a non-matching command", () => {
|
|
137
|
-
expect(isOurHook({
|
|
138
|
-
type: "command",
|
|
139
|
-
command: "/usr/local/bin/some-other-hook --flag",
|
|
140
|
-
})).toBe(false);
|
|
141
|
-
});
|
|
142
|
-
it("rejects empty command", () => {
|
|
143
|
-
expect(isOurHook({
|
|
144
|
-
type: "command",
|
|
145
|
-
command: "",
|
|
146
|
-
})).toBe(false);
|
|
147
|
-
});
|
|
148
|
-
});
|
package/dist/origin.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { MemoryOrigin } from "./engine-client.js";
|
|
2
|
-
/**
|
|
3
|
-
* Build a `MemoryOrigin` block describing the current opensquid
|
|
4
|
-
* process. Called once per `memorize`; cheap (env reads + base
|
|
5
|
-
* conversions). Returns a typed object with all detected fields
|
|
6
|
-
* populated; absent fields stay `undefined` so engine-side
|
|
7
|
-
* `skip_serializing_if = "Option::is_none"` keeps the on-disk YAML
|
|
8
|
-
* tight.
|
|
9
|
-
*/
|
|
10
|
-
export declare function detectOrigin(): MemoryOrigin;
|
|
11
|
-
/**
|
|
12
|
-
* Test seam: re-export the stable fallback session id so suites can
|
|
13
|
-
* assert determinism across calls within one process.
|
|
14
|
-
*/
|
|
15
|
-
export declare function fallbackSessionId(): string;
|
|
16
|
-
//# sourceMappingURL=origin.d.ts.map
|
package/dist/origin.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"origin.d.ts","sourceRoot":"","sources":["../src.legacy/origin.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AA8CvD;;;;;;;GAOG;AACH,wBAAgB,YAAY,IAAI,YAAY,CAU3C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C"}
|
package/dist/origin.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Origination metadata auto-detection — v0.4 Phase 1.
|
|
3
|
-
*
|
|
4
|
-
* Builds the `MemoryOrigin` block opensquid attaches to every
|
|
5
|
-
* `memorize` call. The engine treats it as opaque-ish data (typed
|
|
6
|
-
* struct with all-optional fields); the wedge gate consumes
|
|
7
|
-
* `session_id` for v0.4+ multi-session reproducibility scoring.
|
|
8
|
-
*
|
|
9
|
-
* Detection priority per field:
|
|
10
|
-
*
|
|
11
|
-
* - `host` — `OPENSQUID_HOST` env (explicit override) ->
|
|
12
|
-
* `claude-code` heuristic (CLAUDE_CODE_* / ANTHROPIC_*
|
|
13
|
-
* env presence) -> `unknown`.
|
|
14
|
-
* - `session_id` — `CLAUDE_SESSION_ID` env -> fallback opaque
|
|
15
|
-
* `sha1(start_time + pid)[:8]` (stable per
|
|
16
|
-
* process, not per conversation — documented).
|
|
17
|
-
* - `model` — `OPENSQUID_MODEL` env -> `ANTHROPIC_MODEL` env ->
|
|
18
|
-
* undefined (omitted).
|
|
19
|
-
* - `cwd_basename` — `path.basename(process.cwd())` always.
|
|
20
|
-
* - `written_at` — `new Date().toISOString()` always.
|
|
21
|
-
*
|
|
22
|
-
* Privacy invariant (mirrors engine-side docs): NEVER emit full file
|
|
23
|
-
* paths, raw transcript content, or user identity. `session_id` is
|
|
24
|
-
* opaque — the raw transcript path is hashed before truncation.
|
|
25
|
-
*/
|
|
26
|
-
import { createHash } from "node:crypto";
|
|
27
|
-
import * as path from "node:path";
|
|
28
|
-
/**
|
|
29
|
-
* Process-lifetime fallback session id. Computed once at module load
|
|
30
|
-
* so all memorize calls from one opensquid subprocess share the same
|
|
31
|
-
* id when no host-provided id is available.
|
|
32
|
-
*/
|
|
33
|
-
const FALLBACK_SESSION_ID = computeFallbackSessionId();
|
|
34
|
-
function computeFallbackSessionId() {
|
|
35
|
-
const seed = `${Date.now()}.${process.pid}.${Math.random()}`;
|
|
36
|
-
return createHash("sha1").update(seed).digest("hex").slice(0, 8);
|
|
37
|
-
}
|
|
38
|
-
function detectHost() {
|
|
39
|
-
if (process.env.OPENSQUID_HOST)
|
|
40
|
-
return process.env.OPENSQUID_HOST;
|
|
41
|
-
// Claude Code exposes a handful of CLAUDE_* env vars when it spawns
|
|
42
|
-
// an MCP child. Probe for any of them as a soft signal.
|
|
43
|
-
if (process.env.CLAUDE_CODE_VERSION ||
|
|
44
|
-
process.env.CLAUDE_PROJECT_DIR ||
|
|
45
|
-
process.env.CLAUDE_SESSION_ID) {
|
|
46
|
-
return "claude-code";
|
|
47
|
-
}
|
|
48
|
-
return "unknown";
|
|
49
|
-
}
|
|
50
|
-
function detectSessionId() {
|
|
51
|
-
const raw = process.env.CLAUDE_SESSION_ID?.trim();
|
|
52
|
-
if (raw) {
|
|
53
|
-
// Hash + truncate so the on-disk id is opaque (not the raw UUID
|
|
54
|
-
// visible elsewhere on the system). Privacy invariant.
|
|
55
|
-
return createHash("sha1").update(raw).digest("hex").slice(0, 8);
|
|
56
|
-
}
|
|
57
|
-
return FALLBACK_SESSION_ID;
|
|
58
|
-
}
|
|
59
|
-
function detectModel() {
|
|
60
|
-
return process.env.OPENSQUID_MODEL?.trim() || process.env.ANTHROPIC_MODEL?.trim() || undefined;
|
|
61
|
-
}
|
|
62
|
-
function detectCwdBasename() {
|
|
63
|
-
return path.basename(process.cwd());
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Build a `MemoryOrigin` block describing the current opensquid
|
|
67
|
-
* process. Called once per `memorize`; cheap (env reads + base
|
|
68
|
-
* conversions). Returns a typed object with all detected fields
|
|
69
|
-
* populated; absent fields stay `undefined` so engine-side
|
|
70
|
-
* `skip_serializing_if = "Option::is_none"` keeps the on-disk YAML
|
|
71
|
-
* tight.
|
|
72
|
-
*/
|
|
73
|
-
export function detectOrigin() {
|
|
74
|
-
const origin = {
|
|
75
|
-
host: detectHost(),
|
|
76
|
-
session_id: detectSessionId(),
|
|
77
|
-
cwd_basename: detectCwdBasename(),
|
|
78
|
-
written_at: new Date().toISOString(),
|
|
79
|
-
};
|
|
80
|
-
const model = detectModel();
|
|
81
|
-
if (model)
|
|
82
|
-
origin.model = model;
|
|
83
|
-
return origin;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Test seam: re-export the stable fallback session id so suites can
|
|
87
|
-
* assert determinism across calls within one process.
|
|
88
|
-
*/
|
|
89
|
-
export function fallbackSessionId() {
|
|
90
|
-
return FALLBACK_SESSION_ID;
|
|
91
|
-
}
|
|
92
|
-
//# sourceMappingURL=origin.js.map
|
package/dist/origin.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"origin.js","sourceRoot":"","sources":["../src.legacy/origin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAIlC;;;;GAIG;AACH,MAAM,mBAAmB,GAAG,wBAAwB,EAAE,CAAC;AAEvD,SAAS,wBAAwB;IAC/B,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;IAC7D,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE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K,GAAG,WAAW,EAAE,CAAC;IAC5B,IAAI,KAAK;QAAE,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;IAChC,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB;IAC/B,OAAO,mBAAmB,CAAC;AAC7B,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { EngineClient } from '../engine/client.js';
|
|
2
|
-
import type { SeedLesson } from './schemas/manifest.js';
|
|
3
|
-
export interface IngestResult {
|
|
4
|
-
ingested: number;
|
|
5
|
-
skipped: number;
|
|
6
|
-
failed: readonly {
|
|
7
|
-
title: string;
|
|
8
|
-
error: string;
|
|
9
|
-
}[];
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Ingest `seeds` into the engine. Returns `{ingested, skipped, failed}`:
|
|
13
|
-
* - `ingested`: seeds that the engine accepted as NEW rows
|
|
14
|
-
* (`result.updated === false`)
|
|
15
|
-
* - `skipped`: seeds the engine UPSERTed onto an existing row
|
|
16
|
-
* (`result.updated === true`) — idempotent re-ingest
|
|
17
|
-
* - `failed`: per-seed RPC errors (engine down, validation error,
|
|
18
|
-
* network blip). Never thrown — callers log.
|
|
19
|
-
*/
|
|
20
|
-
export declare function ingestSeedLessons(packName: string, packVersion: string, seeds: readonly SeedLesson[], engine: EngineClient, packDir: string): Promise<IngestResult>;
|
|
21
|
-
/**
|
|
22
|
-
* sha256-derived external_id for engine UPSERT.
|
|
23
|
-
*
|
|
24
|
-
* Stable across opensquid processes for the same (pack@version + title),
|
|
25
|
-
* collision-resistant under pack-author discipline (no two seeds in one
|
|
26
|
-
* pack share a title). Different packs that happen to use the same title
|
|
27
|
-
* produce distinct external_ids because pack name is part of the input.
|
|
28
|
-
*/
|
|
29
|
-
export declare function makeExternalId(packName: string, packVersion: string, title: string): string;
|
|
30
|
-
//# sourceMappingURL=seed_lessons_ingest.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"seed_lessons_ingest.d.ts","sourceRoot":"","sources":["../../src/packs/seed_lessons_ingest.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACrD;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,SAAS,UAAU,EAAE,EAC5B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,YAAY,CAAC,CA2BvB;AAiCD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAG3F"}
|