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
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# OpenSquid — Architecture (single source of truth)
|
|
2
|
+
|
|
3
|
+
Version: 0.5.441 · Last updated: 2026-06-14
|
|
4
|
+
|
|
5
|
+
This is the **one** map of the whole system: what each part is, **how the parts depend on each
|
|
6
|
+
other**, and **what gets brittle when you change something**. opensquid is not a bag of features —
|
|
7
|
+
it is one interconnected loop. Treat this doc as the reference point before any change: find the
|
|
8
|
+
subsystem you're touching, read its relationships, then read the [Change-impact map](#change-impact-map).
|
|
9
|
+
|
|
10
|
+
Deep-dives (this doc is the entry point; these are the details):
|
|
11
|
+
`docs/pack-runtime.md` (pack format + dispatch), `docs/pack-fsm-architecture.md` (FSM engine),
|
|
12
|
+
`docs/flows.md` (FLOW templates), `docs/state-formats.md` (on-disk shapes), `docs/lexicon.md`
|
|
13
|
+
(design principles), `docs/rubric/{scope,author}.md` (gate criteria).
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 1. The thesis — one loop, not six features
|
|
18
|
+
|
|
19
|
+
opensquid is a **behavior runtime**: an orchestrator that loads **packs** (the total definition of an
|
|
20
|
+
agent's behavior — FSMs + guards + the agent-facing procedure) and runs them over every agent action,
|
|
21
|
+
backed by durable **memory**, gated by **flows**, wired by **install/setup**, with **chat** as the
|
|
22
|
+
remote I/O. The parts complement each other:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
install/setup ──writes the config+state layout everything else reads──┐
|
|
26
|
+
│ │
|
|
27
|
+
▼ ▼
|
|
28
|
+
┌──────────────────┐ threads pack content ┌──────────────────┐ reads/writes
|
|
29
|
+
│ RUNTIME │◀──(procedure/models/fsm)──│ PACKS │ ~/.opensquid/
|
|
30
|
+
│ hooks→dispatch→ │ │ manifest+skills+ │ (the shared
|
|
31
|
+
│ evaluator→ │──runs rules/gates────────▶│ fsm+rubric+ │ substrate)
|
|
32
|
+
│ primitives │ │ procedure │ ▲
|
|
33
|
+
└───────┬──────────┘ └────────┬─────────┘ │
|
|
34
|
+
│ injects recall/rubric/procedure │ DEFINES │
|
|
35
|
+
│ runs the audits, writes FSM+phase state ▼ │
|
|
36
|
+
▼ ┌──────────────────┐ │
|
|
37
|
+
┌──────────────────┐ log_phase / recall / │ FLOWS │ │
|
|
38
|
+
│ MEMORY │◀──store_lesson──────────────│ coding-flow FSM, │───────┘
|
|
39
|
+
│ RAG + lessons + │ │ gates, git gate, │
|
|
40
|
+
│ work-graph │──recall feeds each turn────▶│ request-type │
|
|
41
|
+
└───────┬──────────┘ └──────────────────┘
|
|
42
|
+
│ umbrella/namespace key is SHARED with ▼
|
|
43
|
+
┌──────────────────┐
|
|
44
|
+
│ CHAT │ remote I/O over the whole session (inbound→hooks, outbound←chat_send)
|
|
45
|
+
└──────────────────┘
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The five load-bearing connections (memorize these — they are where disconnection happens):
|
|
49
|
+
|
|
50
|
+
1. **Packs DEFINE flows.** The `coding-flow` pack's `fsm.yaml` + skills ARE the lifecycle the Flows
|
|
51
|
+
subsystem enforces. Change the pack → you change the flow.
|
|
52
|
+
2. **Flows WRITE memory.** `log_phase` writes the phase ledger; audits read the rubric docs; the
|
|
53
|
+
request-type record + FSM state are session memory the gates read.
|
|
54
|
+
3. **Memory FEEDS packs/flows.** `recall` (+ `recall_pre_inject`) is what the agent knows each turn;
|
|
55
|
+
the request-type + FSM records drive the arm decision and the stop guards.
|
|
56
|
+
4. **Runtime THREADS packs.** dispatch reads each pack's `procedure`/`models`/`fsm` and threads them
|
|
57
|
+
to primitives; the primitives run the gates and inject memory/rubric/procedure.
|
|
58
|
+
5. **Install WIRES all of it.** setup writes the hooks (`~/.claude/settings.json`), the MCP servers
|
|
59
|
+
(`~/.claude.json`), and the `~/.opensquid/` layout. Chat + memory **share** the umbrella/namespace
|
|
60
|
+
key. If setup is wrong, nothing downstream fires.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 2. A turn's data-flow (the spine)
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
user prompt
|
|
68
|
+
└─▶ UserPromptSubmit hook (runtime)
|
|
69
|
+
├─ resetTurnLedger → STATE (session ledger)
|
|
70
|
+
├─ classifyRequestType → writeRequestType → MEMORY/STATE (request-type record) [FLOWS reads it]
|
|
71
|
+
├─ recall_pre_inject ← MEMORY (top-K) → additionalContext
|
|
72
|
+
├─ rubric_pre_inject / procedure_pre_inject← PACKS (coding-flow docs) → additionalContext
|
|
73
|
+
├─ drainUmbrellaInbox ← CHAT (inbox) → additionalContext
|
|
74
|
+
└─ dispatchEvent
|
|
75
|
+
└─ walk PACKS → skills → rules → evaluator → primitives
|
|
76
|
+
├─ enter-scoping reads request-type → advance_fsm (FLOWS: scoping) → STATE (FSM)
|
|
77
|
+
└─ directives (next_action) → additionalContext
|
|
78
|
+
agent acts (Write/Edit/Bash/git/...)
|
|
79
|
+
└─▶ PreToolUse hook → dispatch
|
|
80
|
+
├─ a pre-research Write → guess-audit (spawn) → GUESS_FREE → advance_fsm → STATE (FSM)
|
|
81
|
+
├─ a spec Write → spec-audit → SPEC_COMPLETE → advance_fsm
|
|
82
|
+
└─ git commit → execute-gate (in-session NUDGE) [git gate.ts = the HARD boundary]
|
|
83
|
+
└─▶ PostToolUse hook → phase-advance (after log_phase) → STATE (FSM) + MEMORY (phase ledger)
|
|
84
|
+
agent stops
|
|
85
|
+
└─▶ Stop hook → pause-stop-guard (reads request-type + FSM), maybeDriveInbound/streamOutput (CHAT)
|
|
86
|
+
session ends
|
|
87
|
+
└─▶ SessionEnd hook → reconcile memory, compression, auto-handoff, clearFsmState
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Every arrow crosses a subsystem boundary. That is the point: a change to any node ripples along its arrows.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 3. Subsystems at a glance
|
|
95
|
+
|
|
96
|
+
| Subsystem | Owns | Key code | Deep-dive |
|
|
97
|
+
| ----------------- | ------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------- |
|
|
98
|
+
| **Install/Setup** | the npm package, the wizards, the `~/.opensquid/` + `~/.claude/` layout | `src/cli.ts`, `src/setup/`, `src/runtime/paths.ts`, `package.json` | §4.1 |
|
|
99
|
+
| **Runtime** | hooks → dispatch → evaluator → ~50 primitives; the event/verdict model | `src/runtime/hooks/`, `dispatch.ts`, `evaluator/`, `src/functions/`, `bootstrap.ts` | `pack-runtime.md` |
|
|
100
|
+
| **Packs** | pack format (manifest+skills+side-files), loader, the builtin pack set | `src/packs/`, `src/runtime/types.ts` (`Pack`), `packs/builtin/` | `pack-runtime.md` |
|
|
101
|
+
| **Flows/Gates** | the coding-flow FSM, guess/spec/phase gates, git-owned gate, request-type classifier | `packs/builtin/coding-flow/`, `src/runtime/fsm*.ts`, `src/functions/cached_audit.ts`, `src/setup/cli/gate.ts`, `src/runtime/request_type.ts` | `pack-fsm-architecture.md`, `flows.md` |
|
|
102
|
+
| **Memory** | RAG (libsql+fastembed), lessons + wedge gate, work-graph, compression/retention | `src/rag/`, `src/workgraph/`, `src/runtime/phase_ledger.ts`, `src/mcp/tools/` | `state-formats.md` |
|
|
103
|
+
| **Chat** | chat-daemon, umbrella routing, inbound watcher + drain, `chat_send` bridge | `src/channels/`, `src/runtime/chat/`, `src/mcp/chat-bridge-server.ts`, `src/chat_daemon/client.ts` | — |
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 4. Per-subsystem — owns / inputs / outputs / **touchpoints**
|
|
108
|
+
|
|
109
|
+
### 4.1 Install / Setup / State-layout
|
|
110
|
+
|
|
111
|
+
- **Owns:** the npm `bin` set (the CLI + 6 hook bins + 2 MCP servers, `package.json:12-22`); the wizards
|
|
112
|
+
(`src/setup/wizard/{settings-writer,mcp-writer,codex-hooks-writer}.ts`, `src/setup/cli/chat_*`); the
|
|
113
|
+
canonical path layout (`src/runtime/paths.ts`, `OPENSQUID_HOME()`).
|
|
114
|
+
- **Writes (the config other subsystems consume):** `~/.claude/settings.json` (hook entries, marked
|
|
115
|
+
`@opensquid:true`), `~/.claude.json` (`opensquid` + `opensquid-chat` MCP servers), `~/.codex/hooks.json`
|
|
116
|
+
(codex parity), `~/.opensquid/{active.json, models.yaml, channels.json, config.json, .env, sessions/, store/, ...}`.
|
|
117
|
+
- **Touchpoints (downstream dependents):** Runtime hooks depend on `settings.json` being present+correct;
|
|
118
|
+
the MCP tools depend on `~/.claude.json`; Packs load from `active.json` + `~/.opensquid/packs/`; Chat
|
|
119
|
+
depends on `config.json` (tokens) + `channels.json` (routing); Memory keys on the umbrella from `channels.json`.
|
|
120
|
+
- **This is the root dependency.** If setup is broken, _every_ other subsystem silently no-ops.
|
|
121
|
+
- **Verify:** `opensquid doctor {hooks,codex-hooks,memory,git-hooks,update}`.
|
|
122
|
+
|
|
123
|
+
### 4.2 Runtime (the spine)
|
|
124
|
+
|
|
125
|
+
- **Owns:** the 6 hook bins; `dispatchEvent` (walks packs→skills→rules, threads `packId/packModels/packFsm/packProcedure`
|
|
126
|
+
into the eval context, aggregates `contextInjections`+`directives`); the evaluator + `if:` interpreter;
|
|
127
|
+
the function registry (~50 primitives registered in `bootstrap.ts`); the Event (8 kinds) + Verdict (5 levels) model.
|
|
128
|
+
- **Inputs:** host hook payloads; the loaded packs; the session/FSM/memory state on disk.
|
|
129
|
+
- **Outputs:** `additionalContext` (injections+directives), `permissionDecision: deny` (block), FSM/state writes,
|
|
130
|
+
audit spawns, memory reads/writes.
|
|
131
|
+
- **Touchpoints:** threads PACK content → primitives; primitives read/write MEMORY + STATE; runs the FLOWS gates;
|
|
132
|
+
injects CHAT inbox; is installed BY setup. **Adding a primitive** = register in `bootstrap.ts` (+ thread via
|
|
133
|
+
`dispatch.ts` if it reads pack content, + register in test registries if pack rules call it — see [Change-impact](#change-impact-map)).
|
|
134
|
+
|
|
135
|
+
### 4.3 Packs
|
|
136
|
+
|
|
137
|
+
- **Owns:** `manifest.yaml` (+ `skills/*/skill.yaml`) and the optional side-files `fsm.yaml`, `team.yaml`,
|
|
138
|
+
`models.yaml`, `drift_response.yaml`, `chat_agent.yaml`, `channels.yaml`, `notifications.yaml`, **`procedure.md`**;
|
|
139
|
+
the loader (`loadPack`); the runtime `Pack` object (`types.ts:351`); the 13 builtin packs.
|
|
140
|
+
- **Touchpoints:** the `coding-flow` pack DEFINES the FLOWS FSM+gates; `models.yaml` configures MEMORY's
|
|
141
|
+
embedder/LLM aliases; side-files are threaded by RUNTIME dispatch; packs are located by SETUP
|
|
142
|
+
(`active.json`); pack rules call MEMORY (`recall`/`store_lesson`) and inject the rubric/procedure.
|
|
143
|
+
- **A pack is the unit of behavior.** Editing a pack changes the agent's flow, gates, and injected guidance at once.
|
|
144
|
+
|
|
145
|
+
### 4.4 Flows / Gates
|
|
146
|
+
|
|
147
|
+
- **Owns:** `coding-flow/fsm.yaml` (idle→SCOPE→AUTHOR→CODE, 9 states); the content gates — guess-audit
|
|
148
|
+
(SCOPE→`GUESS_FREE`), spec-audit (AUTHOR→`SPEC_COMPLETE`), phase-log (7 phases); the in-session skills
|
|
149
|
+
(entry-and-handoffs, scope-lifecycle, execute-gate, phase-advance/audit, pause-stop-guard, pause-prevention,
|
|
150
|
+
task-start); the **git-owned hard boundary** `gate.ts` (pre-commit/pre-push, binds to agents, humans pass);
|
|
151
|
+
the **request-type classifier** (research vs work, `request_type.ts`).
|
|
152
|
+
- **Touchpoints:** the FSM IS a PACK side-file; the gates run via RUNTIME primitives (`cached_audit` spawns
|
|
153
|
+
subagents); the audits read the rubric DOCS and write the FSM STATE; `log_phase` writes MEMORY (phase ledger);
|
|
154
|
+
`gate.ts` reads session STATE written by the hooks; the request-type record (written by the UPS hook) is read by
|
|
155
|
+
enter-scoping + the stop guards. **Two-layer design:** in-session gates = best-effort NUDGE; `gate.ts` = fail-closed.
|
|
156
|
+
|
|
157
|
+
### 4.5 Memory
|
|
158
|
+
|
|
159
|
+
- **Owns:** the RAG store (`libsql-fastembed` default; per-file `store/lessons/<id>.md` = git-versionable truth;
|
|
160
|
+
lexical + claude-auto-memory backends); the Lesson type (durability, retired_at, tier/namespace); recall/memorize/forget;
|
|
161
|
+
the **wedge gate** (anti-self-grading lesson promotion); the **work-graph** (event-sourced op-log + libSQL projection,
|
|
162
|
+
claim/audience); compression + 30-day retention/demote.
|
|
163
|
+
- **Touchpoints:** recall is CALLED by pack rules + injected by RUNTIME (`recall_pre_inject`); the scope **namespace**
|
|
164
|
+
comes from the active umbrella (SHARED with CHAT); `models.yaml` (PACKS) picks the embedder; `log_phase` (FLOWS)
|
|
165
|
+
writes the ledger; memorize writes are scoped by the umbrella resolved from cwd/channels.json (SETUP/CHAT).
|
|
166
|
+
- **Scope is fail-closed:** null namespace → only `shared` memory; cross-project leakage is structurally prevented.
|
|
167
|
+
|
|
168
|
+
### 4.6 Chat
|
|
169
|
+
|
|
170
|
+
- **Owns:** the long-lived `chat-daemon` (owns the bot tokens, a UDS socket, writes umbrella inbox JSONL);
|
|
171
|
+
umbrella routing (`channels.json`, pure FSM); the inbound watcher (real-time push) + Stop-hook drain (fallback);
|
|
172
|
+
outbound `chat_send` (the separate `opensquid-chat-bridge-mcp` server → daemon RPC); the live-session lease.
|
|
173
|
+
- **Touchpoints:** the daemon is configured BY setup (`config.json`/`channels.json`); inbound injects into the
|
|
174
|
+
RUNTIME hooks (UPS additionalContext / Stop drive); the **umbrella key is SHARED with MEMORY scoping** and the
|
|
175
|
+
lease; chat is the remote I/O over the WHOLE session. **Known fragility:** the inbound watcher can die silently
|
|
176
|
+
in long sessions → degrades to the turn-boundary drain (see [Stale/disconnect](#stale--disconnected)).
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## 5. Relationship matrix — "if I change ROW, it affects COLUMN"
|
|
181
|
+
|
|
182
|
+
| ↓ change / → affects | Install | Runtime | Packs | Flows | Memory | Chat |
|
|
183
|
+
| -------------------- | ------------------------------------------------------- | ----------------------------------- | -------------------------------- | ------------------------------------ | ------------------------------------ | ------------------------------ |
|
|
184
|
+
| **Install/Setup** | — | hooks must re-register | pack discovery (`active.json`) | gate install | store/scope paths | daemon tokens+routing |
|
|
185
|
+
| **Runtime** | hook bin names ↔ `package.json` `bin` + settings-writer | — | dispatch threading of side-files | primitives the gates call | recall/state primitives | inbox drain + chat_send |
|
|
186
|
+
| **Packs** | — | new side-file ⇒ thread in dispatch | — | **coding-flow pack = the FSM+gates** | models.yaml ⇒ embedder; recall rules | chat_agent.yaml |
|
|
187
|
+
| **Flows** | gate.ts ↔ git hooks | audit primitives, classifier in UPS | the coding-flow pack content | — | log_phase ⇒ ledger; rubric docs | stop-guard reads request-type |
|
|
188
|
+
| **Memory** | store/db paths | recall/recall_pre_inject shape | recall hits feed pack rules | request-type/FSM records drive gates | — | umbrella namespace = scope key |
|
|
189
|
+
| **Chat** | channels.json/config.json | inbound event → hooks | chat_agent binding | — | umbrella key = memory namespace | — |
|
|
190
|
+
|
|
191
|
+
Read a row before you change that subsystem. Each non-empty cell is a place that can break.
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## 6. Config & state layout (canonical)
|
|
196
|
+
|
|
197
|
+
The shared substrate. Detailed shapes in `docs/state-formats.md`; this is the index.
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
~/.claude/settings.json hooks: 6 opensquid-hook-* entries (@opensquid:true) ← WRITTEN BY setup; READ BY host→runtime
|
|
201
|
+
~/.claude.json mcpServers: opensquid + opensquid-chat ← WRITTEN BY setup; READ BY host
|
|
202
|
+
~/.codex/hooks.json 5 events (codex parity, absolute bin paths) ← WRITTEN BY setup
|
|
203
|
+
~/.opensquid/
|
|
204
|
+
active.json opted-in packs (user scope) ← Packs
|
|
205
|
+
models.yaml model aliases (reasoning, fast_classifier, ...) ← Packs/Memory/LLM
|
|
206
|
+
channels.json umbrella routing (members→umbrella→telegram target) ← Chat + Memory(namespace)
|
|
207
|
+
config.json chat bot tokens (chmod 600) ← Chat
|
|
208
|
+
.env API tokens (chmod 600; canonical per SHL.1) ← Chat/SDK
|
|
209
|
+
rag.sqlite / store/lessons/ RAG store + per-file git-versionable truth ← Memory
|
|
210
|
+
workgraph.db / workgraph/ work-graph projection + per-op files ← Memory
|
|
211
|
+
lessons/<status>/ wedge-gate lessons (per-file source) ← Memory
|
|
212
|
+
phase_ledger/<taskId>/ durable 7-phase audit ledger ← Flows→Memory
|
|
213
|
+
sessions/<sid>/state/ fsm-coding-flow, request-type, *-audit-cache, ledgers ← Runtime/Flows
|
|
214
|
+
sessions/<sid>/active-task.json the active task signal ← Runtime/Flows/git-gate
|
|
215
|
+
umbrellas/<id>/inbox/*.jsonl + live-session.lease ← Chat
|
|
216
|
+
chat-daemon.{sock,pid,log} daemon endpoints ← Chat
|
|
217
|
+
<project>/.opensquid/active.json + .opensquid/attestations.jsonl ← Packs / git-gate
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## 7. Change-impact map
|
|
223
|
+
|
|
224
|
+
The "what gets brittle when you touch X" reference. **Before changing a left-column item, check the right column.**
|
|
225
|
+
|
|
226
|
+
| If you change… | …re-verify (these get brittle) |
|
|
227
|
+
| --------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
228
|
+
| **`coding-flow/fsm.yaml`** (states/transitions) | every skill that `advance_fsm`; the gates that read state (execute-gate, pause-stop-guard); `gate.ts` `commitAllowedNow` (keys on `phases_complete` + 7 phases); request-type idle-return + RTC.4 stranded-scoping; the FSM-active set in `rubric_pre_inject`/`procedure_pre_inject` |
|
|
229
|
+
| **session-state shape/key** (`sessions/<sid>/state/*`) | all `read_state` consumers across packs; the audits' cache keys; the classifier record; `gate.ts` (reads FSM+phases+active-task); the request-type consumers |
|
|
230
|
+
| **a pack side-file** (add/rename, e.g. `procedure.md`) | `loadPack` (load it), `types.ts` `Pack` (field), `dispatch.ts` (thread it into eval ctx), the consuming primitive, and **test registries** (`coding-flow.test.ts`/`default-discipline.test.ts` must register any primitive a shipped rule calls — or dispatch tests break) |
|
|
231
|
+
| **a new primitive** (`src/functions/*`) | register in `bootstrap.ts`; export in `src/functions/index.ts`; if it reads pack content, add the field to `FunctionContext` + thread in `dispatch.ts`; if a shipped pack rule calls it, register it in the dispatch test registries |
|
|
232
|
+
| **the rubric** (`docs/rubric/{scope,author}.md`) | BOTH the audit pass-criteria AND the agent-injected guidance change (single-source by design — that's the point; don't add a second copy) |
|
|
233
|
+
| **hook wiring** (`package.json` `bin` ↔ `settings-writer.ts` `OPENSQUID_BIN_FOR_EVENT`) | the whole pipeline: a renamed/missing bin = that event silently no-ops; re-run `opensquid setup wizard hooks` + `doctor hooks` |
|
|
234
|
+
| **the umbrella/namespace key** (`channels.json` routing or `scope.ts`) | Chat routing AND Memory scoping AND the live-session lease all key on it together — change one, reconcile all three |
|
|
235
|
+
| **the RAG backend / Lesson schema** (`src/rag/`) | `recall`/`recall_pre_inject`, all backends (libsql/lexical/auto-memory + the fallback wrapper), per-file source round-trip, `rebuildLibsqlIndex`, the wedge store |
|
|
236
|
+
| **the git gate** (`gate.ts`) | the gate-binding model (agents armed / humans pass); `isDocsOnly`; the attestation trail (pre-commit ↔ pre-push); the in-session execute-gate must stay consistent with it |
|
|
237
|
+
| **`command_invokes` / matchers** | the git-class guards in `default-discipline` (never-amend, no-force-push-main, npm-version); `command_boundary.skill.test` (regression guard) |
|
|
238
|
+
| **the version (minor/major bump)** | the final-audit-flow gate (planned, `wg-54eef8b4927c`) + `gate.ts` version-bump detection (FA.0 positional matcher shipped) |
|
|
239
|
+
|
|
240
|
+
**Process rule that falls out of this map:** never change a subsystem in isolation. A pack edit is a flow
|
|
241
|
+
edit; a state-shape edit is a gate edit; a key edit is a chat+memory edit. Walk the arrows.
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## 8. Stale / disconnected (cleanup backlog, grounded)
|
|
246
|
+
|
|
247
|
+
Found during this mapping; each is a real disconnect to clean (drives the cleanup pass, tracked in the work-graph):
|
|
248
|
+
|
|
249
|
+
- **Pack discovery is not resilient** (`wg-a3e928b8255b`, **HIGH** — verified via CLI audit): one malformed pack in `~/.opensquid/packs/` crashes every pack-enumerating command (`schedule list`, `triggers list`, …) — `loadPack` throws on the first bad pack even when it isn't in `active.json`. Trigger here: a stale `sangmin-personal-rules.dpc6-backup/` dir. Discovery of the installed SET should fail-soft per-pack (skip+warn); an explicitly-loaded pack can still fail loud.
|
|
250
|
+
- **`dist/` ships dead code** (`wg-98a8d32127dd`, **HIGH** — ships to npm): `tsc` never cleans `dist/`, so `dist/anti-drift/*`, `dist/engine-client.js`, `dist/rag/backends/loop_engine.js`, and **56 `*.test.js`** (all with no live `src/`) accumulate and ship. Fix: `rm -rf dist` before build. (`npm/engine-*` = local cruft, not shipped.)
|
|
251
|
+
- **Install-flow holes** (`wg-5eedceaaa19f`): no `postinstall`/first-run nudge; `setup wizard mcp` `detectOpensquidRoot()` is dead code (defined, never called); the README happy-path assumes manual wizard steps; `daemon start/stop/restart` are stubs.
|
|
252
|
+
- **`~/.loop/.env` vs `~/.opensquid/.env`** — the chat wizard still references `~/.loop/.env` in places (SHL.1 made `~/.opensquid/.env` canonical); reconcile. The `~/.loop` tree is a rename remnant.
|
|
253
|
+
- **`dist/anti-drift/*`** — legacy 0.7.x monolith compiled output; superseded by `src/runtime/hooks/*` + dispatch; should not ship (and `dist/**/*.test.js` shouldn't ship either — packaging bloat).
|
|
254
|
+
- **Stale ADR paths** — `~/.opensquid/personas/` + `teams/` (ADR-0013) never built; `team.yaml` is the real mechanism (`wg-b400d5bc5ada` gap 2: docs/terminology).
|
|
255
|
+
- **Compression orchestrator** (`compression_orchestrator.ts`) — "TBD wiring"; consolidation not yet invoked at session boundary.
|
|
256
|
+
- **Chat watcher unsupervised** (`wg-83e8e91f39d2`) — dies silently in long sessions → silent fallback to turn-boundary drain; not auto-restarted.
|
|
257
|
+
- **channels.yaml / notifications.yaml** — pack side-files defined but not folded into the runtime Pack (await notification-router).
|
|
258
|
+
- **`memorize` synchronous confirm gate** (`wg-84d0d73b89c5`) — out of step with the decided records-everything + deferred-validation model (memory cluster, post-0.6.x).
|
|
259
|
+
- **Memory cluster (post-0.6.x, parked):** git-versioned memory (`wg-7f4df49787cb`), 30-day retention slices 2-3 (`wg-9e4f4eb2a40f`), stale-context durability/decay (`wg-4f91e0b5cb8c`).
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## 9. How to use this doc
|
|
264
|
+
|
|
265
|
+
- **Before a change:** find the subsystem (§4), read its touchpoints, then the [Change-impact map](#change-impact-map). Walk the arrows.
|
|
266
|
+
- **Onboarding / "what does what":** §1–§3.
|
|
267
|
+
- **Finding stale/disconnected work:** §8 (kept in sync with the work-graph).
|
|
268
|
+
- **Exact shapes/APIs:** follow the deep-dive links — this doc is the map, not the territory; keep the details single-sourced in those docs, and keep _this_ doc the authoritative map of how they connect.
|
package/docs/pack-runtime.md
CHANGED
|
@@ -631,12 +631,14 @@ rules:
|
|
|
631
631
|
kind: track_check
|
|
632
632
|
requires: [] # rule-local preconditions (peer to Skill.requires)
|
|
633
633
|
process:
|
|
634
|
-
- call:
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
634
|
+
- call: command_invokes # structural — a real `git commit --amend`, not a regex on the string
|
|
635
|
+
args:
|
|
636
|
+
program: git
|
|
637
|
+
subcommand: commit
|
|
638
|
+
flag_any: ['--amend']
|
|
639
|
+
as: amending
|
|
638
640
|
- call: verdict
|
|
639
|
-
if: '
|
|
641
|
+
if: 'amending'
|
|
640
642
|
args:
|
|
641
643
|
level: warn
|
|
642
644
|
message: 'avoid git commit --amend in shared branches'
|
|
@@ -926,13 +928,14 @@ shipped primitive by category.
|
|
|
926
928
|
|
|
927
929
|
### 5.1 Event inspection (`src/functions/event.ts`)
|
|
928
930
|
|
|
929
|
-
| Primitive | Returns | Use
|
|
930
|
-
| ------------------------ | ----------------------------- |
|
|
931
|
-
| `tool_name` | `{value: string}` | The tool being called (`Bash`, `Write`, etc.)
|
|
932
|
-
| `tool_args` | object | The tool's parsed args
|
|
933
|
-
| `cwd` | `{value: string}` | Current working directory
|
|
934
|
-
| `last_assistant_message` | `{value: string}` | Most recent assistant output
|
|
935
|
-
| `
|
|
931
|
+
| Primitive | Returns | Use |
|
|
932
|
+
| ------------------------ | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
933
|
+
| `tool_name` | `{value: string}` | The tool being called (`Bash`, `Write`, etc.) |
|
|
934
|
+
| `tool_args` | object | The tool's parsed args |
|
|
935
|
+
| `cwd` | `{value: string}` | Current working directory |
|
|
936
|
+
| `last_assistant_message` | `{value: string}` | Most recent assistant output |
|
|
937
|
+
| `command_invokes` | `bool` | **STRUCTURAL** match of a real shell command invocation — args `{program, subcommand?, flag_any?, arg_any?}`. Parses the command into shell segments and matches a GENUINE invocation: `program` (basename), optional `subcommand`, `flag_any` (any listed flag present), `arg_any` (a non-flag positional whose refspec TARGET — `src:dst`→`dst`, `+`-stripped, basename — is in the list; conjunctive with `flag_any`). Ignores prose/`echo`/`grep` mentions; compounds (`cd … && git commit`) still match. **PREFER this for command gates.** (`shell_parse.ts`, `event.ts`) |
|
|
938
|
+
| `match_command` | `{matched: bool, groups?: …}` | Regex-match against the bash command string (`args.pattern`). EVADABLE — a quoted/echoed mention false-fires and boundary-anchoring is brittle. Reserve for LOOSE / non-command string matching; for git/npm-style **command gates use `command_invokes`** (the built-in git/version gates were migrated off this in GM.1–4; `command_boundary.skill.test` guards against reverting to regex). |
|
|
936
939
|
|
|
937
940
|
### 5.2 State + FSM (`src/functions/state.ts`, `fsm.ts`, `session_tool_history.ts`)
|
|
938
941
|
|
|
@@ -32,10 +32,10 @@ The built-in `workflow` skill ships this rule in
|
|
|
32
32
|
```yaml
|
|
33
33
|
- id: phase-logged-before-commit
|
|
34
34
|
process:
|
|
35
|
-
- call:
|
|
36
|
-
args:
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
- call: command_invokes # STRUCTURAL: matches a REAL `git commit` invocation
|
|
36
|
+
args: # (program+subcommand parsed from the shell), NOT a regex on
|
|
37
|
+
program: git # the command string — so `echo "git commit"` / a prose mention
|
|
38
|
+
subcommand: commit # never false-fires, while `cd … && git commit` still matches.
|
|
39
39
|
as: committing
|
|
40
40
|
- call: read_state
|
|
41
41
|
if: committing
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opensquid",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.449",
|
|
4
4
|
"description": "Continuity layer for coding agents: durable memory, dependency-aware task state, workflow gates, and inspectable packs over MCP.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"dist",
|
|
25
25
|
"schemas",
|
|
26
26
|
"packs/builtin",
|
|
27
|
+
"docs/ARCHITECTURE.md",
|
|
27
28
|
"docs/pack-runtime.md",
|
|
28
29
|
"docs/skill-grammar-guide.md",
|
|
29
30
|
"docs/load-budget.md",
|
|
@@ -34,7 +35,8 @@
|
|
|
34
35
|
},
|
|
35
36
|
"packageManager": "pnpm@10.33.2",
|
|
36
37
|
"scripts": {
|
|
37
|
-
"
|
|
38
|
+
"clean": "rm -rf dist",
|
|
39
|
+
"build": "tsc -p tsconfig.build.json && chmod +x dist/cli.js dist/runtime/hooks/*.js dist/mcp/server.js dist/mcp/chat-bridge-server.js",
|
|
38
40
|
"typecheck": "tsc --noEmit",
|
|
39
41
|
"test": "vitest run",
|
|
40
42
|
"test:watch": "vitest",
|
|
@@ -46,7 +48,7 @@
|
|
|
46
48
|
"prepare": "bash scripts/install-git-hooks.sh",
|
|
47
49
|
"schemas": "tsx scripts/emit-schemas.ts && prettier --write 'schemas/*.json'",
|
|
48
50
|
"sync-fixtures": "tsx scripts/sync-fixtures-from-live.ts",
|
|
49
|
-
"prepublishOnly": "pnpm schemas && pnpm build"
|
|
51
|
+
"prepublishOnly": "pnpm clean && pnpm schemas && pnpm build"
|
|
50
52
|
},
|
|
51
53
|
"keywords": [
|
|
52
54
|
"mcp",
|
|
@@ -24,20 +24,14 @@ rules:
|
|
|
24
24
|
- '\bdesign\b'
|
|
25
25
|
- '\bplan\b'
|
|
26
26
|
as: intent
|
|
27
|
-
# RTC
|
|
28
|
-
#
|
|
29
|
-
# ("what's the plan here?" matches \bplan\b but
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
- call:
|
|
34
|
-
|
|
35
|
-
key: request-type
|
|
36
|
-
as: rt
|
|
37
|
-
- call: advance_fsm
|
|
38
|
-
if: 'len(intent.matched) > 0 && rt.type != "research"'
|
|
39
|
-
args:
|
|
40
|
-
event: scope_start
|
|
27
|
+
# RTC (wg-649d80e78e64): the request-type veto now lives in the arm_scope CHOKEPOINT — the
|
|
28
|
+
# single owner shared by BOTH arm producers (this rule + rearm-on-depletion), so a research-
|
|
29
|
+
# classified prompt (understand-only / a question — "what's the plan here?" matches \bplan\b but
|
|
30
|
+
# is a question) can never arm scope and no producer can reintroduce the bypass. enter-scoping
|
|
31
|
+
# just supplies its keyword-intent condition; arm_scope reads request-type and vetoes research.
|
|
32
|
+
# (Supersedes the inline RTC.2 gate, wg-3d175ec06767.)
|
|
33
|
+
- call: arm_scope
|
|
34
|
+
if: 'len(intent.matched) > 0'
|
|
41
35
|
# FU.3: record the track-type so the AUTHOR gate can consult it. RESET to the
|
|
42
36
|
# strict default (feature) on every scope entry FIRST — so a stale fix/doc/
|
|
43
37
|
# trivial value from a prior track can never under-gate a later feature task —
|
|
@@ -270,10 +264,12 @@ rules:
|
|
|
270
264
|
as: st
|
|
271
265
|
- call: open_task_count
|
|
272
266
|
as: open
|
|
273
|
-
-
|
|
267
|
+
# RTC (wg-649d80e78e64): the SECOND arm producer routes through the SAME arm_scope chokepoint,
|
|
268
|
+
# so a research/docs turn after a completed track can no longer spuriously re-arm scoping (the
|
|
269
|
+
# gate-fighting class). arm_scope owns the research veto; this rule supplies only the structural
|
|
270
|
+
# depletion condition.
|
|
271
|
+
- call: arm_scope
|
|
274
272
|
if: 'st == "phases_complete" && open.count == 0'
|
|
275
|
-
args:
|
|
276
|
-
event: scope_start
|
|
277
273
|
# Strict default for the re-armed track: a plain-language track can't be classified,
|
|
278
274
|
# so gate it at the strictest profile (feature). Mirrors enter-scoping's reset.
|
|
279
275
|
- call: write_state
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Anti-drift evaluator (0.7.34 — unified-evaluator track).
|
|
3
|
-
*
|
|
4
|
-
* Single orchestrator that replaces the per-file hook handlers in
|
|
5
|
-
* src/hooks/. Binds the 4 Claude Code hook events (PreToolUse, Stop,
|
|
6
|
-
* UserPromptSubmit, SessionEnd) to the declarative RULES list from
|
|
7
|
-
* rules.ts.
|
|
8
|
-
*
|
|
9
|
-
* Each runner:
|
|
10
|
-
* 1. Reads JSON from stdin (Claude Code's hook payload)
|
|
11
|
-
* 2. Builds a HookContext from the payload + transcript scan
|
|
12
|
-
* 3. Calls evaluateRules(ctx) to walk applicable rules
|
|
13
|
-
* 4. Aggregates verdicts per event semantic:
|
|
14
|
-
* PreToolUse → exit 2 on first block; warns → stderr + exit 0
|
|
15
|
-
* Stop → surfaces → violations.log (UPS picks up); +
|
|
16
|
-
* honesty-reconcile + heartbeat-arm legacy
|
|
17
|
-
* UPS → surfaces → stdout (Claude Code injects);
|
|
18
|
-
* + resume detection + broken-promises +
|
|
19
|
-
* heartbeat-pending consume (preexisting)
|
|
20
|
-
* SessionEnd → auto-actions only (catalog + cleanup)
|
|
21
|
-
*
|
|
22
|
-
* Lives alongside src/hooks/ until the 0.7.35 cutover deletes the
|
|
23
|
-
* old per-file handlers and points hooks-cli at this entrypoint.
|
|
24
|
-
*/
|
|
25
|
-
import { type Verdict } from "./rules.js";
|
|
26
|
-
interface HookPayload {
|
|
27
|
-
hook_event_name?: string;
|
|
28
|
-
session_id?: string;
|
|
29
|
-
transcript_path?: string;
|
|
30
|
-
cwd?: string;
|
|
31
|
-
tool_name?: string;
|
|
32
|
-
tool_input?: Record<string, unknown>;
|
|
33
|
-
prompt?: string;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* PreToolUse: walk PreToolUse rules. First block-verdict short-circuits
|
|
37
|
-
* exit 2; warns accumulate to stderr; pass through otherwise.
|
|
38
|
-
*
|
|
39
|
-
* Exported for direct testing.
|
|
40
|
-
*/
|
|
41
|
-
export declare function runPreToolUseEvaluator(payload: HookPayload): Promise<{
|
|
42
|
-
exit: 0 | 2;
|
|
43
|
-
stderr: string;
|
|
44
|
-
}>;
|
|
45
|
-
export declare function aggregatePreToolUse(verdicts: Verdict[]): {
|
|
46
|
-
exit: 0 | 2;
|
|
47
|
-
stderr: string;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Stop: walk Stop rules. Surfaces → violations.log (next UPS picks up).
|
|
51
|
-
* Always exit 0 (Stop is observational, not blocking — exit 2 would
|
|
52
|
-
* trigger Claude Code's re-prompt loop which is D9 territory).
|
|
53
|
-
*
|
|
54
|
-
* Exported for direct testing.
|
|
55
|
-
*/
|
|
56
|
-
export declare function runStopEvaluator(payload: HookPayload): Promise<{
|
|
57
|
-
stderr: string;
|
|
58
|
-
}>;
|
|
59
|
-
/**
|
|
60
|
-
* UserPromptSubmit: walk UPS rules. Surfaces → stdout (Claude Code
|
|
61
|
-
* injects into agent context). Always exit 0.
|
|
62
|
-
*
|
|
63
|
-
* Exported for direct testing.
|
|
64
|
-
*/
|
|
65
|
-
export declare function runUserPromptSubmitEvaluator(payload: HookPayload): Promise<{
|
|
66
|
-
stdout: string;
|
|
67
|
-
}>;
|
|
68
|
-
/**
|
|
69
|
-
* SessionEnd: walk SessionEnd rules (auto-actions like drift-catalog
|
|
70
|
-
* scan + state cleanup). Always exit 0.
|
|
71
|
-
*
|
|
72
|
-
* Exported for direct testing.
|
|
73
|
-
*/
|
|
74
|
-
export declare function runSessionEndEvaluator(payload: HookPayload): Promise<{
|
|
75
|
-
stderr: string;
|
|
76
|
-
}>;
|
|
77
|
-
export type HookEventName = "pre-tool-use" | "stop" | "user-prompt-submit" | "session-end";
|
|
78
|
-
/**
|
|
79
|
-
* Run the evaluator for the specified hook event by reading stdin,
|
|
80
|
-
* dispatching to the right runner, writing the output, and exiting.
|
|
81
|
-
*
|
|
82
|
-
* Wired into the CLI as `opensquid anti-drift <event>` at the 0.7.35
|
|
83
|
-
* cutover; until then, the existing `opensquid hook <event>` handlers
|
|
84
|
-
* in src/hooks/* run.
|
|
85
|
-
*/
|
|
86
|
-
export declare function runEvaluator(event: HookEventName): Promise<void>;
|
|
87
|
-
export {};
|
|
88
|
-
//# sourceMappingURL=evaluator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src.legacy/anti-drift/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAQH,OAAO,EAAmC,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAe3E,UAAU,WAAW;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAeD;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC;IAC1E,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CA0BD;AAuBD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG;IAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAexF;AAMD;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CA2FxF;AAMD;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CA2D7B;AAmDD;;;;;GAKG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAkB9F;AAMD,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,MAAM,GAAG,oBAAoB,GAAG,aAAa,CAAC;AAE3F;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCtE"}
|