@mindrian_os/cli 2.0.0-beta.3 → 2.0.0-beta.31
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/.claude-plugin/plugin.json +21 -0
- package/.mcp.json +14 -0
- package/CHANGELOG.md +467 -0
- package/agents/analogy-query-fetcher.md +119 -0
- package/agents/brain-query.md +91 -0
- package/agents/competitor-watch-fetcher.md +94 -0
- package/agents/framework-runner.md +258 -0
- package/agents/grading.md +216 -0
- package/agents/grant-reviewer.md +191 -0
- package/agents/investor.md +141 -0
- package/agents/larry-extended.md +215 -0
- package/agents/meeting-perspective-extractor.md +94 -0
- package/agents/opportunity-scanner.md +105 -0
- package/agents/persona-analyst.md +201 -0
- package/agents/research.md +103 -0
- package/agents/reverse-salient-agent.md +42 -0
- package/agents/vault-section-reviewer.md +107 -0
- package/assets/banner-showcase.html +537 -0
- package/assets/fonts/BebasNeue-Regular.ttf +0 -0
- package/assets/fonts/Inter-Bold.ttf +0 -0
- package/assets/fonts/Inter-Regular.ttf +0 -0
- package/assets/logo.svg +10 -0
- package/bin/local-chain-recommender.cjs +256 -0
- package/bin/mindrian-brain-mcp-client.cjs +319 -0
- package/bin/mindrian-mcp-server.cjs +445 -0
- package/bin/mindrian-mcp-shim.cjs +100 -0
- package/bin/mindrian-tools.cjs +784 -0
- package/commands/act.md +529 -0
- package/commands/admin.md +439 -0
- package/commands/agentshield.md +49 -0
- package/commands/analyze-needs.md +78 -0
- package/commands/analyze-systems.md +73 -0
- package/commands/analyze-timing.md +98 -0
- package/commands/auto-explore.md +85 -0
- package/commands/beautiful-question.md +76 -0
- package/commands/bono.md +152 -0
- package/commands/brain-derive.md +137 -0
- package/commands/build-knowledge.md +121 -0
- package/commands/build-thesis.md +94 -0
- package/commands/causal.md +269 -0
- package/commands/challenge-assumptions.md +78 -0
- package/commands/compare-ventures.md +117 -0
- package/commands/correct-reference-now.md +88 -0
- package/commands/dashboard.md +144 -0
- package/commands/deck.md +117 -0
- package/commands/deep-grade.md +214 -0
- package/commands/diagnose.md +131 -0
- package/commands/diagnostics.md +195 -0
- package/commands/dial-memory-refresh.md +113 -0
- package/commands/diffusion.md +129 -0
- package/commands/discover.md +221 -0
- package/commands/doctor.md +271 -0
- package/commands/dogfood-flush.md +130 -0
- package/commands/dominant-designs.md +76 -0
- package/commands/eureka.md +315 -0
- package/commands/explain-decision.md +135 -0
- package/commands/explore-domains.md +78 -0
- package/commands/explore-futures.md +67 -0
- package/commands/explore-opportunity.md +172 -0
- package/commands/explore-trends.md +78 -0
- package/commands/export.md +128 -0
- package/commands/feynman-timeline-refresh.md +102 -0
- package/commands/file-meeting.md +1195 -0
- package/commands/find-analogies.md +369 -0
- package/commands/find-bottlenecks.md +108 -0
- package/commands/find-connections.md +111 -0
- package/commands/funding.md +114 -0
- package/commands/futures.md +128 -0
- package/commands/grade-grant.md +297 -0
- package/commands/grade.md +257 -0
- package/commands/graph.md +218 -0
- package/commands/hat-briefing.md +163 -0
- package/commands/heal.md +72 -0
- package/commands/help.md +176 -0
- package/commands/hmi-status.md +75 -0
- package/commands/ignite.md +229 -0
- package/commands/ingest-methodology.md +128 -0
- package/commands/intel-pipeline.md +133 -0
- package/commands/jtbd.md +262 -0
- package/commands/leadership.md +113 -0
- package/commands/lean-canvas.md +74 -0
- package/commands/macro-trends.md +88 -0
- package/commands/map-unknowns.md +76 -0
- package/commands/memory-cortex-reach.md +79 -0
- package/commands/memory.md +213 -0
- package/commands/models.md +200 -0
- package/commands/mos-reason.md +489 -0
- package/commands/mos.md +162 -0
- package/commands/mullins.md +155 -0
- package/commands/mva-brief.md +86 -0
- package/commands/mva-option.md +119 -0
- package/commands/mva-report.md +76 -0
- package/commands/new-project.md +633 -0
- package/commands/new-surface.md +116 -0
- package/commands/onboard.md +489 -0
- package/commands/operator.md +168 -0
- package/commands/opportunities.md +177 -0
- package/commands/organize.md +74 -0
- package/commands/persona.md +276 -0
- package/commands/pipeline.md +167 -0
- package/commands/present.md +125 -0
- package/commands/publish.md +227 -0
- package/commands/pws-brain.md +154 -0
- package/commands/qualify-opportunity.md +113 -0
- package/commands/query.md +70 -0
- package/commands/radar.md +110 -0
- package/commands/reanalyze.md +124 -0
- package/commands/research.md +467 -0
- package/commands/room.md +385 -0
- package/commands/rooms.md +682 -0
- package/commands/root-cause.md +77 -0
- package/commands/rs-experts.md +153 -0
- package/commands/rs-explain.md +134 -0
- package/commands/rs-fetch.md +119 -0
- package/commands/rs-thesis.md +131 -0
- package/commands/scenario-plan.md +80 -0
- package/commands/scheduled-tasks.md +308 -0
- package/commands/score-innovation.md +78 -0
- package/commands/scout.md +379 -0
- package/commands/setup.md +658 -0
- package/commands/show.md +71 -0
- package/commands/skill.md +108 -0
- package/commands/snapshot.md +179 -0
- package/commands/speakers.md +118 -0
- package/commands/splash.md +55 -0
- package/commands/stance.md +91 -0
- package/commands/status.md +109 -0
- package/commands/structure-argument.md +82 -0
- package/commands/suggest-next.md +141 -0
- package/commands/systems-thinking.md +224 -0
- package/commands/think-hats.md +86 -0
- package/commands/trending-to-absurd.md +151 -0
- package/commands/update.md +256 -0
- package/commands/user-needs.md +77 -0
- package/commands/validate.md +77 -0
- package/commands/value-proposition.md +116 -0
- package/commands/vault.md +330 -0
- package/commands/visualize.md +71 -0
- package/commands/whitespace.md +541 -0
- package/commands/wiki.md +96 -0
- package/data/ROOM.md +47 -0
- package/data/brain-census.generated.json +2617 -0
- package/data/brain-orchestration-projection.json +4973 -0
- package/data/brain-packet-schema.json +545 -0
- package/data/brain-surface-contract.json +32 -0
- package/data/capability-ledger.json +391 -0
- package/data/capability-map-registry.json +23 -0
- package/data/command-registry.json +2433 -0
- package/data/connector-coverage-ledger.json +1618 -0
- package/data/connector-out-of-spine-allowlist.json +71 -0
- package/data/connector-registry.json +3637 -0
- package/data/corpus-stats-source.json +11 -0
- package/data/corpus-stats.generated.json +10 -0
- package/data/cross-domain-analogues.json +15 -0
- package/data/deck-aliases.json +6 -0
- package/data/deck-styles.json +85 -0
- package/data/deployment-surfaces.json +69 -0
- package/data/dispatch-framework-map.json +18 -0
- package/data/doctor-modules.json +206 -0
- package/data/dual-graph-health-baseline.json +12 -0
- package/data/eureka-critic-tags.json +32 -0
- package/data/first-reward-surfaces.json +66 -0
- package/data/first-touch-surfaces.json +60 -0
- package/data/flagship-floor-set.json +37 -0
- package/data/framework-names.json +121 -0
- package/data/grant-rubric-fixtures/early-stage-pre-seed.json +18 -0
- package/data/grant-rubric-fixtures/early-stage-round-a.json +18 -0
- package/data/grant-rubric-fixtures/early-stage-seed.json +18 -0
- package/data/grant-rubric-fixtures/hybrid-seed-incentive.json +18 -0
- package/data/grant-rubric-fixtures/rd-fund.json +18 -0
- package/data/grant-rubric-fixtures/regional-innovation-incubators.json +18 -0
- package/data/grant-rubric-fixtures/technology-incubators.json +18 -0
- package/data/grant-rubric-fixtures/tnufa.json +167 -0
- package/data/grant-rubric-schema.json +33 -0
- package/data/harness-fixtures/converged-room/.context/ROOM.md +13 -0
- package/data/harness-fixtures/converged-room/.intelligence/ROOM.md +13 -0
- package/data/harness-fixtures/converged-room/.snapshots/ROOM.md +13 -0
- package/data/harness-fixtures/converged-room/MINTO.md +19 -0
- package/data/harness-fixtures/converged-room/STATE.md +73 -0
- package/data/harness-fixtures/converged-room/USER.md +23 -0
- package/data/harness-fixtures/converged-room/assets/ROOM.md +13 -0
- package/data/harness-fixtures/converged-room/business-model/CONTEXT.md +32 -0
- package/data/harness-fixtures/converged-room/business-model/ROOM.md +36 -0
- package/data/harness-fixtures/converged-room/competitive-analysis/CONTEXT.md +33 -0
- package/data/harness-fixtures/converged-room/competitive-analysis/ROOM.md +35 -0
- package/data/harness-fixtures/converged-room/financial-model/CONTEXT.md +30 -0
- package/data/harness-fixtures/converged-room/financial-model/ROOM.md +35 -0
- package/data/harness-fixtures/converged-room/funding/CONTEXT.md +41 -0
- package/data/harness-fixtures/converged-room/funding/ROOM.md +35 -0
- package/data/harness-fixtures/converged-room/legal-ip/CONTEXT.md +30 -0
- package/data/harness-fixtures/converged-room/legal-ip/ROOM.md +35 -0
- package/data/harness-fixtures/converged-room/market-analysis/CONTEXT.md +32 -0
- package/data/harness-fixtures/converged-room/market-analysis/ROOM.md +35 -0
- package/data/harness-fixtures/converged-room/opportunity-bank/CONTEXT.md +39 -0
- package/data/harness-fixtures/converged-room/opportunity-bank/ROOM.md +36 -0
- package/data/harness-fixtures/converged-room/problem-definition/CONTEXT.md +32 -0
- package/data/harness-fixtures/converged-room/problem-definition/ROOM.md +36 -0
- package/data/harness-fixtures/converged-room/references/ROOM.md +13 -0
- package/data/harness-fixtures/converged-room/references/SECTION-SCHEMA.md +213 -0
- package/data/harness-fixtures/converged-room/references/SUB-SCHEMAS.md +91 -0
- package/data/harness-fixtures/converged-room/solution-design/CONTEXT.md +36 -0
- package/data/harness-fixtures/converged-room/solution-design/ROOM.md +36 -0
- package/data/harness-fixtures/converged-room/strategy/CONTEXT.md +35 -0
- package/data/harness-fixtures/converged-room/strategy/ROOM.md +35 -0
- package/data/harness-fixtures/converged-room/team/ROOM.md +13 -0
- package/data/harness-fixtures/converged-room/team-execution/CONTEXT.md +36 -0
- package/data/harness-fixtures/converged-room/team-execution/ROOM.md +35 -0
- package/data/harness-manifest.json +74 -0
- package/data/harness-policies/CONTEXT.md +55 -0
- package/data/harness-policies/_schema.json +42 -0
- package/data/harness-policies/contract-parity-larry.json +63 -0
- package/data/harness-policies/gate-card-fire.json +13 -0
- package/data/harness-policies/gate-graph-derive-health.json +13 -0
- package/data/harness-policies/gate-shape-declaration.json +13 -0
- package/data/harness-policies/gate-tool-honesty.json +13 -0
- package/data/harness-policies/gate-worktree-hygiene.json +13 -0
- package/data/harness-policies/memory-write-policy.json +28 -0
- package/data/harness-policies/registry-drift.json +13 -0
- package/data/harness-policies/release-payload-ceiling.json +13 -0
- package/data/harness-policies/voice-backend-noun-free.json +13 -0
- package/data/harness-policies/voice-fork-as-card.json +13 -0
- package/data/harness-policies/voice-glyph-present.json +13 -0
- package/data/harness-policies/voice-hyphens-only.json +13 -0
- package/data/help-groups.json +236 -0
- package/data/hitl-shape-backfill.json +777 -0
- package/data/hitl-shape-declaration-fixtures/invalid-bad-shape.json +5 -0
- package/data/hitl-shape-declaration-fixtures/invalid-missing-why.json +4 -0
- package/data/hitl-shape-declaration-fixtures/invalid-ranker-contradiction.json +6 -0
- package/data/hitl-shape-declaration-fixtures/invalid-skill-gap.json +3 -0
- package/data/hitl-shape-declaration-fixtures/valid-multi-stage.json +7 -0
- package/data/hitl-shape-declaration-fixtures/valid-single-shape.json +5 -0
- package/data/hitl-shape-declaration-fixtures/valid-skill-exempt.json +5 -0
- package/data/hitl-shape-declaration-schema.json +34 -0
- package/data/hitl-stages-fixtures/bono.json +10 -0
- package/data/hitl-stages-fixtures/pipeline-1.json +9 -0
- package/data/hitl-stages-fixtures/pipeline-2.json +9 -0
- package/data/hitl-stages-fixtures/pipeline-3.json +10 -0
- package/data/hitl-stages-fixtures/research.json +10 -0
- package/data/hitl-stages-fixtures/rs-convergence.json +10 -0
- package/data/hitl-stages-fixtures/rs-family.json +11 -0
- package/data/hitl-stages-fixtures/rs-reverse-salient.json +10 -0
- package/data/hitl-stages-fixtures/trending-to-absurd.json +11 -0
- package/data/hitl-stages-schema.json +26 -0
- package/data/mcp-tool-connectors.json +464 -0
- package/data/mva-agent-prompts.json +31 -0
- package/data/mva-deck-template.html +15 -0
- package/data/mva-heuristic-keywords.json +35 -0
- package/data/orchestration-command-ledger.json +576 -0
- package/data/orchestration-unwired-allowlist.json +6 -0
- package/data/portfolio-ahp-matrix.json +16 -0
- package/data/publish-needs.json +76 -0
- package/data/render-coverage-registry.json +1152 -0
- package/data/research-sources.json +58 -0
- package/data/roadmap-type-chains.json +28 -0
- package/data/room-blueprints.json +156 -0
- package/data/subagent-dispatch-grants.json +150 -0
- package/hooks/hooks.json +493 -0
- package/hooks/run-hook.cmd +64 -0
- package/lib/__init__.py +0 -0
- package/lib/__pycache__/__init__.cpython-312.pyc +0 -0
- package/lib/agents/auto-explore-agent.cjs +1163 -0
- package/lib/agents/mva/brain-classic-traps.cjs +55 -0
- package/lib/agents/mva/brain-cross-domain.cjs +79 -0
- package/lib/agents/mva/brain-similar-ventures.cjs +93 -0
- package/lib/agents/mva/dashboard-graph-neighborhood.cjs +72 -0
- package/lib/agents/mva/index.cjs +42 -0
- package/lib/agents/mva/six-hats-red-black.cjs +137 -0
- package/lib/agents/mva/tavily-funding-scan.cjs +147 -0
- package/lib/agents/mva/test-all-six-agents.cjs +467 -0
- package/lib/agents/reverse-salient-agent.cjs +757 -0
- package/lib/agents/tension-hook-agent.cjs +586 -0
- package/lib/brain/ROOM.md +44 -0
- package/lib/brain/chain-recommender.cjs +784 -0
- package/lib/brain/curation-batch.cjs +519 -0
- package/lib/brain/framework-chain-slice.cjs +252 -0
- package/lib/brain/hypergraph-event-schema.cjs +184 -0
- package/lib/chat/chat-context.js +185 -0
- package/lib/chat/chat-panel.js +721 -0
- package/lib/chat/fabric-chat.cjs +288 -0
- package/lib/chat/generative-tools.js +219 -0
- package/lib/conversation/ROOM.md +39 -0
- package/lib/conversation/classifier-rules.json +38 -0
- package/lib/conversation/classifier.cjs +264 -0
- package/lib/conversation/operator-epistemic-cap.test.cjs +156 -0
- package/lib/conversation/operator.cjs +492 -0
- package/lib/conversation/operator.test.cjs +160 -0
- package/lib/copy/115-spec-strings.cjs +55 -0
- package/lib/core/__init__.py +0 -0
- package/lib/core/__nav-stub.cjs +14 -0
- package/lib/core/__pycache__/__init__.cpython-312.pyc +0 -0
- package/lib/core/__pycache__/rs-math.cpython-312.pyc +0 -0
- package/lib/core/__pycache__/rs_cache.cpython-312.pyc +0 -0
- package/lib/core/__pycache__/rs_corpus.cpython-312.pyc +0 -0
- package/lib/core/__pycache__/rs_corpus_exclude.cpython-312.pyc +0 -0
- package/lib/core/__pycache__/rs_hybrid.cpython-312.pyc +0 -0
- package/lib/core/__pycache__/rs_math.cpython-312.pyc +0 -0
- package/lib/core/__pycache__/rs_rooms.cpython-312.pyc +0 -0
- package/lib/core/abstraction-gate.cjs +133 -0
- package/lib/core/act-jtbd-blurb.cjs +231 -0
- package/lib/core/artifact-id.cjs +148 -0
- package/lib/core/asset-ops.cjs +151 -0
- package/lib/core/auto-commit-throttle.cjs +129 -0
- package/lib/core/bearer-token.cjs +199 -0
- package/lib/core/behavioral/observation-schema.cjs +86 -0
- package/lib/core/bono/cell-fanout.cjs +305 -0
- package/lib/core/bono/debate-composition.cjs +495 -0
- package/lib/core/bono/hat-governance.cjs +367 -0
- package/lib/core/bono/persona-research.cjs +288 -0
- package/lib/core/bono/reviewer-governance.cjs +331 -0
- package/lib/core/brain-client.cjs +2365 -0
- package/lib/core/brain-derivation-prompts.cjs +331 -0
- package/lib/core/brain-derivation-queue.cjs +535 -0
- package/lib/core/brain-derivation.cjs +740 -0
- package/lib/core/brain-md-schema.cjs +528 -0
- package/lib/core/brain-md-staleness.cjs +357 -0
- package/lib/core/brain-response-sanitize.cjs +396 -0
- package/lib/core/breakthrough/canary.cjs +134 -0
- package/lib/core/breakthrough/canary.test.cjs +136 -0
- package/lib/core/breakthrough/detectors.cjs +359 -0
- package/lib/core/breakthrough/detectors.test.cjs +333 -0
- package/lib/core/breakthrough/ethics-fence.cjs +129 -0
- package/lib/core/breakthrough/ethics-fence.test.cjs +178 -0
- package/lib/core/breakthrough/resurfacing.cjs +150 -0
- package/lib/core/breakthrough/resurfacing.test.cjs +233 -0
- package/lib/core/breakthrough/review-queue.cjs +168 -0
- package/lib/core/breakthrough/review-queue.test.cjs +160 -0
- package/lib/core/breakthrough/scanner-d17-d18.test.cjs +229 -0
- package/lib/core/breakthrough/scanner.cjs +435 -0
- package/lib/core/breakthrough/scanner.test.cjs +267 -0
- package/lib/core/breakthrough/schema.cjs +180 -0
- package/lib/core/breakthrough/schema.test.cjs +256 -0
- package/lib/core/breakthrough/scoring.cjs +293 -0
- package/lib/core/breakthrough/scoring.test.cjs +423 -0
- package/lib/core/breakthrough/verb-dispatch.cjs +230 -0
- package/lib/core/breakthrough/verb-dispatch.test.cjs +185 -0
- package/lib/core/breakthrough/voice-scaffold.cjs +249 -0
- package/lib/core/breakthrough/voice-scaffold.test.cjs +251 -0
- package/lib/core/bridge-writer.cjs +477 -0
- package/lib/core/cache-prune.cjs +314 -0
- package/lib/core/card-fire-gate.cjs +107 -0
- package/lib/core/card-fire-sidechannel.cjs +518 -0
- package/lib/core/chain-executor.cjs +939 -0
- package/lib/core/chain-retry.cjs +214 -0
- package/lib/core/chain-step-dispatcher.cjs +397 -0
- package/lib/core/chat-context-builder.cjs +253 -0
- package/lib/core/check-plugin-enabled.cjs +145 -0
- package/lib/core/close-loop-writer.cjs +492 -0
- package/lib/core/command-registration-check.cjs +246 -0
- package/lib/core/correlation-label-index.cjs +230 -0
- package/lib/core/correlation.cjs +112 -0
- package/lib/core/coverage-monitor.cjs +183 -0
- package/lib/core/coverage-rollup.cjs +232 -0
- package/lib/core/cross-room-aggregator.cjs +1127 -0
- package/lib/core/cross-room-store.cjs +292 -0
- package/lib/core/cross-room-triggers.cjs +222 -0
- package/lib/core/daily-briefing.cjs +438 -0
- package/lib/core/decision-axes.cjs +178 -0
- package/lib/core/decision-capture.cjs +618 -0
- package/lib/core/deck-design-rules.cjs +211 -0
- package/lib/core/deep-links.cjs +82 -0
- package/lib/core/directive-envelope.cjs +217 -0
- package/lib/core/directive-envelope.test.cjs +225 -0
- package/lib/core/dispatch-optimizer.cjs +354 -0
- package/lib/core/doc-text-extractor.cjs +133 -0
- package/lib/core/doctor/capability-ledger-module.cjs +170 -0
- package/lib/core/doctor/card-fire-health-module.cjs +159 -0
- package/lib/core/doctor/cascade-rooms-active-module.cjs +127 -0
- package/lib/core/doctor/cascade-rooms-module.cjs +184 -0
- package/lib/core/doctor/class-m-brain-smoke.cjs +479 -0
- package/lib/core/doctor/class-m-brain-smoke.test.cjs +448 -0
- package/lib/core/doctor/class-s-eureka-smoke.cjs +380 -0
- package/lib/core/doctor/deployment-surfaces-module.cjs +408 -0
- package/lib/core/doctor/deprecated-usage-module.cjs +155 -0
- package/lib/core/doctor/eureka-fts-health-module.cjs +236 -0
- package/lib/core/doctor/graph-derive-heal-retrofit-module.cjs +148 -0
- package/lib/core/doctor/graph-derive-health-module.cjs +486 -0
- package/lib/core/doctor/install-incomplete-module.cjs +320 -0
- package/lib/core/doctor/install-state-module.cjs +503 -0
- package/lib/core/doctor/mcp-surface-module.cjs +369 -0
- package/lib/core/doctor/mode-select-checkpoint-module.cjs +113 -0
- package/lib/core/doctor/plugin-enabled-state-module.cjs +86 -0
- package/lib/core/doctor/room-graph-density-module.cjs +181 -0
- package/lib/core/doctor/room-md-module.cjs +198 -0
- package/lib/core/doctor/shared.cjs +555 -0
- package/lib/core/doctor/stale-first-touch-copy-module.cjs +83 -0
- package/lib/core/doctor/statusline-visibility-module.cjs +295 -0
- package/lib/core/doctor/ui-compliance-module.cjs +223 -0
- package/lib/core/doctor/umbilical-module.cjs +486 -0
- package/lib/core/doctor/verify-surface-module.cjs +82 -0
- package/lib/core/doctor/voice-style-log-module.cjs +146 -0
- package/lib/core/domain-insight-sweep.cjs +224 -0
- package/lib/core/drift-baseline.cjs +362 -0
- package/lib/core/drift-runtime-reachability.cjs +283 -0
- package/lib/core/dual-path-detector.cjs +84 -0
- package/lib/core/dual-path-detector.test.cjs +334 -0
- package/lib/core/enrichment-queue.cjs +636 -0
- package/lib/core/eureka/ahp-weights.cjs +232 -0
- package/lib/core/eureka/analogy-fitness.cjs +326 -0
- package/lib/core/eureka/compression-meter.cjs +165 -0
- package/lib/core/eureka/embedding-classifier.cjs +226 -0
- package/lib/core/eureka/embedding-spine.cjs +563 -0
- package/lib/core/eureka/entity-classifier.cjs +232 -0
- package/lib/core/eureka/entity-extractor.cjs +356 -0
- package/lib/core/eureka/eureka-enable.cjs +228 -0
- package/lib/core/eureka/eureka-offer.cjs +225 -0
- package/lib/core/eureka/eureka-reach-runner.cjs +430 -0
- package/lib/core/eureka/explore-chain.cjs +834 -0
- package/lib/core/eureka/explored-artifact.cjs +456 -0
- package/lib/core/eureka/fts-index-lifecycle.cjs +265 -0
- package/lib/core/eureka/grade-grant-examine.cjs +544 -0
- package/lib/core/eureka/grade-grant.cjs +596 -0
- package/lib/core/eureka/hybrid-retrieve.cjs +256 -0
- package/lib/core/eureka/lateral-engine-adapter.cjs +118 -0
- package/lib/core/eureka/lexical-overlap.cjs +98 -0
- package/lib/core/eureka/online-pattern-query.cjs +142 -0
- package/lib/core/eureka/opportunity-harvest.cjs +752 -0
- package/lib/core/eureka/opportunity-statement.cjs +519 -0
- package/lib/core/eureka/portfolio-dimensions.cjs +255 -0
- package/lib/core/eureka/qualify-opportunity.cjs +607 -0
- package/lib/core/eureka/reasoning-mode.cjs +481 -0
- package/lib/core/eureka/report-html.cjs +368 -0
- package/lib/core/eureka/research-filing.cjs +547 -0
- package/lib/core/eureka/room-native-substrate.cjs +343 -0
- package/lib/core/eureka/tail-quadrant.cjs +177 -0
- package/lib/core/eureka/tri-modal-index.cjs +564 -0
- package/lib/core/eureka/vector-store.cjs +414 -0
- package/lib/core/eureka-critic.cjs +733 -0
- package/lib/core/eureka-deps-resolver.cjs +179 -0
- package/lib/core/expert-genesis.cjs +437 -0
- package/lib/core/expert-library.cjs +303 -0
- package/lib/core/exports-log.cjs +79 -0
- package/lib/core/feynman/ROOM.md +25 -0
- package/lib/core/feynman/dial-memory-renderer.cjs +279 -0
- package/lib/core/feynman/dial-memory-runner.cjs +173 -0
- package/lib/core/feynman/feynman-seed-writer.cjs +187 -0
- package/lib/core/feynman/timeline-renderer.cjs +197 -0
- package/lib/core/feynman/timeline-runner.cjs +281 -0
- package/lib/core/feynman-minto-invariants.cjs +609 -0
- package/lib/core/findings-wirer.cjs +360 -0
- package/lib/core/first-touch-version-stamper.cjs +113 -0
- package/lib/core/folder-memory-async.cjs +424 -0
- package/lib/core/folder-memory-shared.cjs +890 -0
- package/lib/core/folder-memory.cjs +546 -0
- package/lib/core/framework-chain-composer.cjs +583 -0
- package/lib/core/frontmatter-schemas.cjs +468 -0
- package/lib/core/fusion-router.cjs +540 -0
- package/lib/core/futures/causal-cue.cjs +91 -0
- package/lib/core/futures/orchestrator.cjs +1391 -0
- package/lib/core/futures/subsystem-render.cjs +164 -0
- package/lib/core/gate-relevance.cjs +278 -0
- package/lib/core/git-ops.cjs +141 -0
- package/lib/core/graph-backfill.cjs +562 -0
- package/lib/core/graph-candidate-producer.cjs +235 -0
- package/lib/core/graph-derivation.cjs +546 -0
- package/lib/core/graph-derive-classifier.cjs +352 -0
- package/lib/core/graph-ops.cjs +274 -0
- package/lib/core/graph-refine-loop.cjs +194 -0
- package/lib/core/graph-self-heal.cjs +289 -0
- package/lib/core/greeting-intent-detector.cjs +201 -0
- package/lib/core/grill-engine.cjs +459 -0
- package/lib/core/hat-persistence.cjs +274 -0
- package/lib/core/hsi-engine.cjs +439 -0
- package/lib/core/hsi-lsa.cjs +246 -0
- package/lib/core/hsi-spectral.cjs +554 -0
- package/lib/core/hsi-to-graph.test.cjs +168 -0
- package/lib/core/icm-forest.cjs +703 -0
- package/lib/core/ignite-branch-gate.cjs +66 -0
- package/lib/core/index.cjs +60 -0
- package/lib/core/insight-sensors.cjs +1000 -0
- package/lib/core/install-state.cjs +242 -0
- package/lib/core/integration-registry.cjs +232 -0
- package/lib/core/intel-pipeline.cjs +545 -0
- package/lib/core/intelligence-cascade.cjs +852 -0
- package/lib/core/issue-tree.cjs +269 -0
- package/lib/core/larry-thinness-acknowledgment.cjs +64 -0
- package/lib/core/larry-thinness-acknowledgment.test.cjs +97 -0
- package/lib/core/lazygraph-ops.cjs +1453 -0
- package/lib/core/lens-engine.cjs +434 -0
- package/lib/core/leverage-scan.cjs +218 -0
- package/lib/core/llm-name-suggester.cjs +194 -0
- package/lib/core/llm-name-suggester.test.cjs +132 -0
- package/lib/core/lru-cache.cjs +139 -0
- package/lib/core/mcp-dep-heal.cjs +475 -0
- package/lib/core/mcp-dep-heal.test.cjs +253 -0
- package/lib/core/mcp-profiles.cjs +185 -0
- package/lib/core/meeting-ops.cjs +54 -0
- package/lib/core/memory/governance-candidate-raiser.cjs +205 -0
- package/lib/core/memory/governance-candidate.cjs +95 -0
- package/lib/core/memory/reconcile-memory-runner.cjs +653 -0
- package/lib/core/memory-ops.cjs +641 -0
- package/lib/core/meter/gate-density-reader.cjs +112 -0
- package/lib/core/meter/transfer-reader.cjs +276 -0
- package/lib/core/meter/two-gauge.cjs +245 -0
- package/lib/core/methodology-ingest.cjs +346 -0
- package/lib/core/metrics/larryreach-loop-health.cjs +142 -0
- package/lib/core/migration-snapshot.cjs +287 -0
- package/lib/core/migration-snapshot.test.cjs +174 -0
- package/lib/core/migrations/ROOM.md +33 -0
- package/lib/core/migrations/phase-109-nodes-provenance.cjs +400 -0
- package/lib/core/migrations/phase-109-session-focus.cjs +99 -0
- package/lib/core/migrations/phase-160-nodes-bitemporal.cjs +168 -0
- package/lib/core/migrations/phase-160-nodes-bitemporal.test.cjs +140 -0
- package/lib/core/migrations/phase-162-section-nodes.cjs +156 -0
- package/lib/core/migrations/phase-222-ranker-weights.cjs +62 -0
- package/lib/core/migrations/phase-224-edge-review-status.cjs +87 -0
- package/lib/core/mindrian-brain-shim.test.cjs +221 -0
- package/lib/core/mode-select-sidechannel.cjs +259 -0
- package/lib/core/model-profiles.cjs +246 -0
- package/lib/core/mullins-scaffold.cjs +258 -0
- package/lib/core/mullins-scaffold.test.cjs +128 -0
- package/lib/core/mva-agent-contract.cjs +170 -0
- package/lib/core/mva-agent-contract.test.cjs +169 -0
- package/lib/core/mva-budget.cjs +75 -0
- package/lib/core/mva-budget.test.cjs +68 -0
- package/lib/core/mva-classifier.cjs +392 -0
- package/lib/core/mva-classifier.test.cjs +248 -0
- package/lib/core/mva-deck-builder.cjs +452 -0
- package/lib/core/mva-deck-builder.test.cjs +287 -0
- package/lib/core/mva-detect.smoke.test.cjs +209 -0
- package/lib/core/mva-dispatcher.cjs +110 -0
- package/lib/core/mva-dispatcher.test.cjs +216 -0
- package/lib/core/mva-option-router.cjs +414 -0
- package/lib/core/mva-option-router.test.cjs +483 -0
- package/lib/core/mva-orchestrator.cjs +365 -0
- package/lib/core/mva-orchestrator.test.cjs +916 -0
- package/lib/core/mva-progressive-renderer.cjs +194 -0
- package/lib/core/mva-progressive-renderer.test.cjs +157 -0
- package/lib/core/mva-rule-linter.cjs +458 -0
- package/lib/core/mva-rule-linter.test.cjs +484 -0
- package/lib/core/mva-state.cjs +159 -0
- package/lib/core/mva-telemetry.cjs +58 -0
- package/lib/core/mva-telemetry.test.cjs +196 -0
- package/lib/core/mva-vercel-deploy.cjs +168 -0
- package/lib/core/mva-vercel-deploy.test.cjs +239 -0
- package/lib/core/nav-dial.cjs +440 -0
- package/lib/core/navigation/ROOM.md +15 -0
- package/lib/core/navigation/abstraction-claim.cjs +185 -0
- package/lib/core/navigation/calibration-gate.cjs +284 -0
- package/lib/core/navigation/calibration-log.cjs +141 -0
- package/lib/core/navigation/confirm-node.cjs +73 -0
- package/lib/core/navigation/dashboard-helpers.cjs +145 -0
- package/lib/core/navigation/edges.cjs +1150 -0
- package/lib/core/navigation/evidence-claim.cjs +186 -0
- package/lib/core/navigation/explanation.cjs +48 -0
- package/lib/core/navigation/file-evidence-readback.cjs +242 -0
- package/lib/core/navigation/focus.cjs +155 -0
- package/lib/core/navigation/get-domains-for-trends.cjs +277 -0
- package/lib/core/navigation/governance.cjs +101 -0
- package/lib/core/navigation/grant-rubric.cjs +218 -0
- package/lib/core/navigation/graph-export.cjs +325 -0
- package/lib/core/navigation/ingestion.cjs +109 -0
- package/lib/core/navigation/insights-stale.test.cjs +127 -0
- package/lib/core/navigation/insights.cjs +574 -0
- package/lib/core/navigation/lens-nodes.cjs +315 -0
- package/lib/core/navigation/memory-artifacts.cjs +437 -0
- package/lib/core/navigation/memory-cortex-packet.cjs +274 -0
- package/lib/core/navigation/memory-events.cjs +811 -0
- package/lib/core/navigation/neighborhood.cjs +79 -0
- package/lib/core/navigation/packet.cjs +420 -0
- package/lib/core/navigation/planning-artifacts.cjs +219 -0
- package/lib/core/navigation/projections.cjs +295 -0
- package/lib/core/navigation/ranker-weights.cjs +133 -0
- package/lib/core/navigation/reasoning-write.cjs +211 -0
- package/lib/core/navigation/reconcile-guard.cjs +98 -0
- package/lib/core/navigation/reified-claim.cjs +287 -0
- package/lib/core/navigation/research-preflight.cjs +156 -0
- package/lib/core/navigation/room-birth.cjs +1213 -0
- package/lib/core/navigation/room-context.cjs +380 -0
- package/lib/core/navigation/room-home.cjs +142 -0
- package/lib/core/navigation/spine-events.cjs +548 -0
- package/lib/core/navigation/synthetic-expert.cjs +177 -0
- package/lib/core/navigation/transitions.cjs +253 -0
- package/lib/core/navigation/typed-claim.cjs +208 -0
- package/lib/core/navigation/typed-domain.cjs +249 -0
- package/lib/core/navigation/typed-entity.cjs +236 -0
- package/lib/core/navigation/typed-frame.cjs +257 -0
- package/lib/core/navigation/typed-open-question.cjs +130 -0
- package/lib/core/navigation/typed-opportunity.cjs +418 -0
- package/lib/core/navigation-engine-offer.cjs +776 -0
- package/lib/core/navigation-engine-shared.cjs +256 -0
- package/lib/core/navigation-engine.cjs +1696 -0
- package/lib/core/navigation.cjs +686 -0
- package/lib/core/nl-graph-queries.cjs +164 -0
- package/lib/core/node-insert-epistemic.test.cjs +212 -0
- package/lib/core/node-insert-overrides.test.cjs +273 -0
- package/lib/core/node-insert.cjs +274 -0
- package/lib/core/npm-cli-resolve.cjs +151 -0
- package/lib/core/npm-cli-resolve.test.cjs +153 -0
- package/lib/core/npm-install-lock.cjs +326 -0
- package/lib/core/npm-install-lock.test.cjs +379 -0
- package/lib/core/numeric/sklearn-stopwords-v1.json +325 -0
- package/lib/core/numeric/svd.cjs +377 -0
- package/lib/core/numeric/tfidf.cjs +241 -0
- package/lib/core/offer-presenter.cjs +406 -0
- package/lib/core/opportunity-extractor.cjs +183 -0
- package/lib/core/opportunity-ops.cjs +1423 -0
- package/lib/core/orchestration-candidate-lift.cjs +284 -0
- package/lib/core/part8-egress-guard.cjs +536 -0
- package/lib/core/part8-egress-guard.test.cjs +194 -0
- package/lib/core/part8-egress-ontology.cjs +174 -0
- package/lib/core/part8-egress-ontology.test.cjs +133 -0
- package/lib/core/persona-ops.cjs +692 -0
- package/lib/core/persona-override.cjs +327 -0
- package/lib/core/persona-taxonomy.cjs +328 -0
- package/lib/core/pinecone-inference.cjs +176 -0
- package/lib/core/pitch-feedback-schemas.cjs +303 -0
- package/lib/core/planning/artifact-brain-packet.cjs +212 -0
- package/lib/core/planning/reconcile-runner.cjs +347 -0
- package/lib/core/platform-gates.cjs +120 -0
- package/lib/core/platform.cjs +257 -0
- package/lib/core/proactive-intelligence.cjs +528 -0
- package/lib/core/problem-type-router.cjs +315 -0
- package/lib/core/publish-needs-default-lane.cjs +110 -0
- package/lib/core/ralph-loop-gate.cjs +48 -0
- package/lib/core/reader/ab-harness.cjs +177 -0
- package/lib/core/reader/decide-projection-reader.cjs +358 -0
- package/lib/core/reasoning-ops.cjs +639 -0
- package/lib/core/recipe-maps.cjs +442 -0
- package/lib/core/recovery/case-file.cjs +358 -0
- package/lib/core/recovery/controller.cjs +1008 -0
- package/lib/core/recovery/dispatcher.cjs +533 -0
- package/lib/core/recovery/result-semantics.cjs +488 -0
- package/lib/core/recovery/stage-envelope.cjs +338 -0
- package/lib/core/refusal-messaging.cjs +569 -0
- package/lib/core/refusal-messaging.test.cjs +220 -0
- package/lib/core/repo-version.cjs +134 -0
- package/lib/core/research-cache.cjs +165 -0
- package/lib/core/research-cache.test.cjs +137 -0
- package/lib/core/research-context-extractor.cjs +283 -0
- package/lib/core/research-corpus.cjs +814 -0
- package/lib/core/research-corpus.test.cjs +280 -0
- package/lib/core/research-filing-selector.cjs +189 -0
- package/lib/core/resolve-active-room.cjs +602 -0
- package/lib/core/resolve-brain-key.cjs +273 -0
- package/lib/core/resolve-umbilical-target.cjs +288 -0
- package/lib/core/resolve-vercel-key.cjs +107 -0
- package/lib/core/resolve-vercel-key.test.cjs +137 -0
- package/lib/core/reverse-salient-persona-suffix.cjs +115 -0
- package/lib/core/room-auto-create.cjs +318 -0
- package/lib/core/room-auto-create.test.cjs +198 -0
- package/lib/core/room-chooser.cjs +244 -0
- package/lib/core/room-classifier-strict-mode.cjs +235 -0
- package/lib/core/room-db.cjs +348 -0
- package/lib/core/room-discard-cascade.cjs +238 -0
- package/lib/core/room-discard-cascade.test.cjs +135 -0
- package/lib/core/room-name-validator.cjs +132 -0
- package/lib/core/room-name-validator.test.cjs +156 -0
- package/lib/core/room-naming-selector.cjs +357 -0
- package/lib/core/room-naming-selector.test.cjs +277 -0
- package/lib/core/room-open.cjs +259 -0
- package/lib/core/room-ops-async.cjs +92 -0
- package/lib/core/room-ops-shared.cjs +64 -0
- package/lib/core/room-ops-sync.cjs +70 -0
- package/lib/core/room-ops.cjs +32 -0
- package/lib/core/room-receipt-emit.cjs +63 -0
- package/lib/core/room-root.cjs +93 -0
- package/lib/core/room-skeleton-scaffold.cjs +669 -0
- package/lib/core/room-skeleton-scaffold.test.cjs +296 -0
- package/lib/core/room-type-detector.cjs +386 -0
- package/lib/core/rs-backend-dispatch.cjs +64 -0
- package/lib/core/rs-brain-substrate-prompts.cjs +129 -0
- package/lib/core/rs-brain-substrate.cjs +570 -0
- package/lib/core/rs-breakthrough-scorer.cjs +255 -0
- package/lib/core/rs-canon-violations.cjs +82 -0
- package/lib/core/rs-chain-feeder.cjs +381 -0
- package/lib/core/rs-commercial-assessor.cjs +280 -0
- package/lib/core/rs-corpus-quality-gate.cjs +62 -0
- package/lib/core/rs-differential-scorer.cjs +629 -0
- package/lib/core/rs-domain-analyzer.cjs +385 -0
- package/lib/core/rs-egress-prompts.cjs +113 -0
- package/lib/core/rs-egress-telemetry.cjs +225 -0
- package/lib/core/rs-egress-violations.cjs +53 -0
- package/lib/core/rs-engine.cjs +597 -0
- package/lib/core/rs-expert-brain-projection.cjs +280 -0
- package/lib/core/rs-expert-mapper.cjs +467 -0
- package/lib/core/rs-fetcher-academic.cjs +697 -0
- package/lib/core/rs-fetcher-experts.cjs +314 -0
- package/lib/core/rs-fetcher-industry.cjs +731 -0
- package/lib/core/rs-fetcher-patents.cjs +564 -0
- package/lib/core/rs-innovation-classifier.cjs +194 -0
- package/lib/core/rs-math.cjs +458 -0
- package/lib/core/rs-mind-map.cjs +656 -0
- package/lib/core/rs-neo4j-writer.cjs +388 -0
- package/lib/core/rs-nl-to-query.cjs +435 -0
- package/lib/core/rs-pinecone-bridge.cjs +344 -0
- package/lib/core/rs-preprocessor.cjs +350 -0
- package/lib/core/rs-query-matrix.cjs +316 -0
- package/lib/core/rs-query-to-text.cjs +438 -0
- package/lib/core/rs-sqlite-mirror.cjs +495 -0
- package/lib/core/rs-thesis-generator.cjs +188 -0
- package/lib/core/rs_cache.py +635 -0
- package/lib/core/rs_corpus.py +562 -0
- package/lib/core/rs_corpus_exclude.py +62 -0
- package/lib/core/rs_hybrid.py +589 -0
- package/lib/core/rs_math.py +287 -0
- package/lib/core/rs_rooms.py +196 -0
- package/lib/core/salient-governance.cjs +315 -0
- package/lib/core/scheduled-scanner.cjs +658 -0
- package/lib/core/scratchpad-ops.cjs +316 -0
- package/lib/core/seam-liveness.cjs +191 -0
- package/lib/core/seam-liveness.test.cjs +177 -0
- package/lib/core/section-8-trace-schema.cjs +138 -0
- package/lib/core/section-registry.cjs +167 -0
- package/lib/core/security/agentshield-adapters.test.cjs +104 -0
- package/lib/core/security/agentshield-run.cjs +343 -0
- package/lib/core/security/agentshield-scanner.cjs +314 -0
- package/lib/core/security/agentshield-scanner.test.cjs +259 -0
- package/lib/core/sensors/hat-scoping-table.cjs +103 -0
- package/lib/core/sensors/sensor-circularity.cjs +278 -0
- package/lib/core/sensors/sensor-content-relevance.cjs +407 -0
- package/lib/core/sensors/sensor-diffusion-adoption.cjs +230 -0
- package/lib/core/sensors/sensor-eureka.cjs +208 -0
- package/lib/core/sensors/sensor-expert-skill.cjs +293 -0
- package/lib/core/sensors/sensor-external-fact.cjs +184 -0
- package/lib/core/sensors/sensor-gate-approach.cjs +104 -0
- package/lib/core/sensors/sensor-jtbd-reweight.cjs +141 -0
- package/lib/core/sensors/sensor-lagging-component.cjs +115 -0
- package/lib/core/sensors/sensor-memory-cortex.cjs +111 -0
- package/lib/core/sensors/sensor-methodology-decision.cjs +131 -0
- package/lib/core/sensors/sensor-opportunity-harvest.cjs +195 -0
- package/lib/core/sensors/sensor-perspective-lock.cjs +174 -0
- package/lib/core/sensors/sensor-priority.cjs +183 -0
- package/lib/core/sensors/sensor-recency.cjs +151 -0
- package/lib/core/sensors/sensor-roadmap-type.cjs +421 -0
- package/lib/core/sensors/sensor-room-pick.cjs +238 -0
- package/lib/core/sensors/sensor-show-share.cjs +215 -0
- package/lib/core/sensors/sensor-temporal-blindness.cjs +123 -0
- package/lib/core/sensors/sensor-types.cjs +294 -0
- package/lib/core/sensors/sensor-url-ingest.cjs +234 -0
- package/lib/core/session-binding.cjs +208 -0
- package/lib/core/session-presence.cjs +404 -0
- package/lib/core/session-register.cjs +138 -0
- package/lib/core/session-state.cjs +144 -0
- package/lib/core/shallow-doc-parser.cjs +353 -0
- package/lib/core/shallow-doc-parser.test.cjs +226 -0
- package/lib/core/skill-activation-router.cjs +284 -0
- package/lib/core/skillopt-schemas.cjs +509 -0
- package/lib/core/stale-copy-scanner.cjs +190 -0
- package/lib/core/stance-state.cjs +153 -0
- package/lib/core/state-aware-router.cjs +78 -0
- package/lib/core/state-ops.cjs +80 -0
- package/lib/core/state-version.cjs +350 -0
- package/lib/core/statusline-cache.cjs +266 -0
- package/lib/core/statusline-liveness-gate.cjs +105 -0
- package/lib/core/surface-fence.cjs +127 -0
- package/lib/core/synthesizers/comparison-matrix.cjs +82 -0
- package/lib/core/synthesizers/convergence-map.cjs +107 -0
- package/lib/core/synthesizers/domain-hierarchy.cjs +138 -0
- package/lib/core/synthesizers/source-comparison.cjs +56 -0
- package/lib/core/synthesizers/tension-map.cjs +119 -0
- package/lib/core/synthetic-expert-behavior-gate.cjs +99 -0
- package/lib/core/synthetic-expert-construction-gate.cjs +170 -0
- package/lib/core/telemetry/schema.cjs +168 -0
- package/lib/core/telemetry/schema.test.cjs +124 -0
- package/lib/core/telemetry/validator.cjs +200 -0
- package/lib/core/telemetry/validator.test.cjs +188 -0
- package/lib/core/telemetry/writer.cjs +141 -0
- package/lib/core/telemetry/writer.test.cjs +331 -0
- package/lib/core/temporal/date-sync-gate.cjs +256 -0
- package/lib/core/temporal/date-sync-gate.test.cjs +191 -0
- package/lib/core/temporal/dual-stamp.cjs +172 -0
- package/lib/core/temporal/dual-stamp.test.cjs +172 -0
- package/lib/core/temporal/point-in-time.cjs +76 -0
- package/lib/core/temporal/point-in-time.test.cjs +169 -0
- package/lib/core/temporal/recency-decay.cjs +119 -0
- package/lib/core/temporal/recency-decay.test.cjs +140 -0
- package/lib/core/temporal/reference-now.cjs +281 -0
- package/lib/core/temporal/reference-now.test.cjs +225 -0
- package/lib/core/temporal/resolve-relative-time.cjs +116 -0
- package/lib/core/temporal/resolve-relative-time.test.cjs +138 -0
- package/lib/core/temporal/supersession.cjs +250 -0
- package/lib/core/temporal/supersession.test.cjs +103 -0
- package/lib/core/terminal-capability.cjs +88 -0
- package/lib/core/token-estimator.cjs +348 -0
- package/lib/core/tone-filter.cjs +147 -0
- package/lib/core/trending-to-absurd/orchestrator.cjs +341 -0
- package/lib/core/trending-to-absurd/stage7-roadmap.cjs +317 -0
- package/lib/core/trending-to-absurd/variance.cjs +169 -0
- package/lib/core/unknowns/bandit.cjs +332 -0
- package/lib/core/unknowns/corpus-adapter.cjs +327 -0
- package/lib/core/unknowns/dsp.cjs +356 -0
- package/lib/core/unknowns/edge-writer.cjs +211 -0
- package/lib/core/unknowns/iface.cjs +212 -0
- package/lib/core/unknowns/orchestrator.cjs +375 -0
- package/lib/core/unknowns/pattern-miner.cjs +214 -0
- package/lib/core/unknowns/rumsfeld-matrix.cjs +155 -0
- package/lib/core/unknowns/verdict.cjs +254 -0
- package/lib/core/update-path.cjs +57 -0
- package/lib/core/url-ingest.cjs +568 -0
- package/lib/core/user-archetype.cjs +284 -0
- package/lib/core/user-md-ops.cjs +578 -0
- package/lib/core/venture-shape-nudge.cjs +178 -0
- package/lib/core/venture-shape-nudge.test.cjs +266 -0
- package/lib/core/verb-reach-affinity.cjs +299 -0
- package/lib/core/visual-ops.cjs +692 -0
- package/lib/core/voice-transition-detector.cjs +125 -0
- package/lib/core/watched-sources.cjs +237 -0
- package/lib/core/write-lock.cjs +149 -0
- package/lib/graph/canvas-graph.js +467 -0
- package/lib/graph/constellation-config.cjs +299 -0
- package/lib/graph/graph-detail-panel.js +165 -0
- package/lib/hmi/ROOM.md +47 -0
- package/lib/hmi/across-session-memory.cjs +669 -0
- package/lib/hmi/agentshield-drift-gate.cjs +142 -0
- package/lib/hmi/brain-review-packet.cjs +221 -0
- package/lib/hmi/cortex-reach-adapter.cjs +271 -0
- package/lib/hmi/cross-room-memory.cjs +618 -0
- package/lib/hmi/decoy-tier.cjs +395 -0
- package/lib/hmi/depth-state.cjs +164 -0
- package/lib/hmi/dial-label-composer.cjs +410 -0
- package/lib/hmi/dial-presenter.cjs +508 -0
- package/lib/hmi/dial-reach-orchestrator.cjs +377 -0
- package/lib/hmi/dial-selector.cjs +239 -0
- package/lib/hmi/f1-pick-capture-cli.cjs +131 -0
- package/lib/hmi/f3-depth-capture-cli.cjs +77 -0
- package/lib/hmi/f4-scope-capture-cli.cjs +86 -0
- package/lib/hmi/f8-action-capture-cli.cjs +145 -0
- package/lib/hmi/f8-capture.test.cjs +77 -0
- package/lib/hmi/f9-ordered-capture-cli.cjs +138 -0
- package/lib/hmi/harvest-scope-state.cjs +202 -0
- package/lib/hmi/hats-persona-cache.cjs +142 -0
- package/lib/hmi/jtbd-classifier.cjs +219 -0
- package/lib/hmi/jtbd-state.cjs +263 -0
- package/lib/hmi/jtbd-taxonomy.json +402 -0
- package/lib/hmi/mindrian-ascii-logo.cjs +96 -0
- package/lib/hmi/part8-egress-gate.cjs +149 -0
- package/lib/hmi/reach-component-map.json +47 -0
- package/lib/hmi/reach-relevance-gate.cjs +147 -0
- package/lib/hmi/selector-dispatcher.cjs +1201 -0
- package/lib/hmi/selector-dispatcher.test.cjs +141 -0
- package/lib/hmi/selector-telemetry.cjs +269 -0
- package/lib/hmi/shape-f0-renderer.cjs +145 -0
- package/lib/hmi/shape-f1-fallback.cjs +80 -0
- package/lib/hmi/shape-f1-renderer.cjs +219 -0
- package/lib/hmi/shape-f2-renderer.cjs +132 -0
- package/lib/hmi/shape-f3-parity.test.cjs +64 -0
- package/lib/hmi/shape-f3-renderer.cjs +66 -0
- package/lib/hmi/shape-f4-parity.test.cjs +72 -0
- package/lib/hmi/shape-f4-renderer.cjs +72 -0
- package/lib/hmi/shape-f5-renderer.cjs +155 -0
- package/lib/hmi/shape-f6-plan-review-renderer.cjs +324 -0
- package/lib/hmi/shape-f6-renderer.cjs +144 -0
- package/lib/hmi/shape-f7-breakthrough-renderer.cjs +234 -0
- package/lib/hmi/shape-f7-breakthrough-renderer.test.cjs +233 -0
- package/lib/hmi/shape-f8-renderer.cjs +150 -0
- package/lib/hmi/shape-f8-renderer.test.cjs +70 -0
- package/lib/hmi/shape-f9-renderer.cjs +187 -0
- package/lib/hmi/shape-f9-renderer.test.cjs +80 -0
- package/lib/hmi/shape-g-renderer.cjs +219 -0
- package/lib/hmi/shape-h-renderer.cjs +222 -0
- package/lib/hmi/tier-check.cjs +63 -0
- package/lib/hmi/turn-text.cjs +268 -0
- package/lib/hmi/voice-color-mark.cjs +318 -0
- package/lib/hmi/voice-style-log.cjs +276 -0
- package/lib/import/PRECONDITIONS.md +41 -0
- package/lib/import/branding.cjs +210 -0
- package/lib/import/branding.test.cjs +235 -0
- package/lib/import/classifications-sync.cjs +104 -0
- package/lib/import/classifications-sync.test.cjs +129 -0
- package/lib/import/enricher.cjs +296 -0
- package/lib/import/enricher.test.cjs +273 -0
- package/lib/import/integration.test.cjs +376 -0
- package/lib/import/manifest.cjs +129 -0
- package/lib/import/manifest.schema.json +185 -0
- package/lib/import/manifest.test.cjs +123 -0
- package/lib/import/meeting-detector.cjs +92 -0
- package/lib/import/meeting-detector.test.cjs +100 -0
- package/lib/import/person-detector.cjs +229 -0
- package/lib/import/person-detector.test.cjs +149 -0
- package/lib/import/report.cjs +186 -0
- package/lib/import/report.test.cjs +186 -0
- package/lib/import/room-md-scaffolder.cjs +49 -0
- package/lib/import/router.cjs +224 -0
- package/lib/import/router.test.cjs +356 -0
- package/lib/import/run-all-tests.cjs +36 -0
- package/lib/import/smoke-test.cjs +213 -0
- package/lib/import/smoke-test.test.cjs +148 -0
- package/lib/import/undo.test.cjs +199 -0
- package/lib/import/vault-scanner.cjs +105 -0
- package/lib/import/vault-scanner.test.cjs +67 -0
- package/lib/lens-engine/correlation-resolver.cjs +174 -0
- package/lib/lens-engine/source-lens-driver.cjs +736 -0
- package/lib/mcp/adapter-client.cjs +103 -0
- package/lib/mcp/app-html/dashboard.html +316 -0
- package/lib/mcp/app-html/graph.html +428 -0
- package/lib/mcp/app-html/mindrian-platform.html +1841 -0
- package/lib/mcp/app-html/wiki.html +383 -0
- package/lib/mcp/app-views.cjs +322 -0
- package/lib/mcp/brain-composition-census.cjs +184 -0
- package/lib/mcp/brain-router.cjs +530 -0
- package/lib/mcp/capability-registry.cjs +62 -0
- package/lib/mcp/contract-version.cjs +59 -0
- package/lib/mcp/daemon-lifecycle.cjs +324 -0
- package/lib/mcp/gate-dedup.cjs +120 -0
- package/lib/mcp/gate-ledger.cjs +145 -0
- package/lib/mcp/gate-render.cjs +483 -0
- package/lib/mcp/hook-adapter-audit.cjs +199 -0
- package/lib/mcp/larry-context.cjs +42 -0
- package/lib/mcp/mcp-first-flag.cjs +147 -0
- package/lib/mcp/no-instructions.test.cjs +270 -0
- package/lib/mcp/pipeline-state.cjs +424 -0
- package/lib/mcp/prompts.cjs +421 -0
- package/lib/mcp/register-core-tools.cjs +78 -0
- package/lib/mcp/resources.cjs +359 -0
- package/lib/mcp/runtime-instructions.cjs +38 -0
- package/lib/mcp/session-catchup.cjs +349 -0
- package/lib/mcp/session-registry.cjs +113 -0
- package/lib/mcp/session-room.cjs +124 -0
- package/lib/mcp/sse-event-bus.cjs +98 -0
- package/lib/mcp/stop-gate-handler.cjs +589 -0
- package/lib/mcp/surface-detect.cjs +186 -0
- package/lib/mcp/tool-router.cjs +2113 -0
- package/lib/mcp/tools/chain.cjs +674 -0
- package/lib/mcp/tools/claim.cjs +180 -0
- package/lib/mcp/tools/context.cjs +92 -0
- package/lib/mcp/tools/dual-path.cjs +79 -0
- package/lib/mcp/tools/gate.cjs +392 -0
- package/lib/mcp/tools/graph-reason.cjs +130 -0
- package/lib/mcp/tools/graph.cjs +321 -0
- package/lib/mcp/tools/identity.cjs +174 -0
- package/lib/mcp/tools/room.cjs +449 -0
- package/lib/mcp/tools/sensors.cjs +450 -0
- package/lib/mcp/tools/status.cjs +183 -0
- package/lib/mcp/tools/stop-gate.cjs +103 -0
- package/lib/mcp/tools/views.cjs +382 -0
- package/lib/mcp/tree-watcher.cjs +199 -0
- package/lib/memory/.mindrian/auto-explore-mat-test-001.json +11 -0
- package/lib/memory/aaak-compress.cjs +403 -0
- package/lib/memory/aaak-compress.test.cjs +288 -0
- package/lib/memory/async-artifact-auto-commit.test.cjs +223 -0
- package/lib/memory/bearer-token.test.cjs +315 -0
- package/lib/memory/body-shape-coverage.test.cjs +268 -0
- package/lib/memory/brain-cache-lru.test.cjs +259 -0
- package/lib/memory/brain-client-query-shape.test.cjs +160 -0
- package/lib/memory/brain-cypher-chain-slice.test.cjs +368 -0
- package/lib/memory/brain-derivation-graceful-degradation.test.cjs +1019 -0
- package/lib/memory/brain-derivation-queue.test.cjs +553 -0
- package/lib/memory/brain-derivation.test.cjs +639 -0
- package/lib/memory/brain-derive-command.test.cjs +534 -0
- package/lib/memory/brain-derive-curation.test.cjs +243 -0
- package/lib/memory/brain-md-invariants-validator.test.cjs +704 -0
- package/lib/memory/brain-md-schema.test.cjs +467 -0
- package/lib/memory/brain-md-staleness.test.cjs +525 -0
- package/lib/memory/brain-server-resolution.test.cjs +314 -0
- package/lib/memory/brain-suggestion-template.test.cjs +200 -0
- package/lib/memory/chain-recommender-canonical.test.cjs +208 -0
- package/lib/memory/chain-recommender.test.cjs +233 -0
- package/lib/memory/chat-context.test.cjs +128 -0
- package/lib/memory/command-registry.test.cjs +220 -0
- package/lib/memory/connector-registry.test.cjs +94 -0
- package/lib/memory/correlation-label-index.test.cjs +119 -0
- package/lib/memory/correlation.test.cjs +253 -0
- package/lib/memory/cross-room-aggregator.test.cjs +909 -0
- package/lib/memory/curation-132-03-dedup-held-rename.test.cjs +251 -0
- package/lib/memory/curation-132-05-pseudonymize.test.cjs +205 -0
- package/lib/memory/curation-batch.test.cjs +213 -0
- package/lib/memory/dashboard-server.test.cjs +256 -0
- package/lib/memory/debouncer-drain-at-prompt.test.cjs +389 -0
- package/lib/memory/decision-capture.test.cjs +632 -0
- package/lib/memory/decision-capture.worker.cjs +70 -0
- package/lib/memory/doctor-deprecation-surface.test.cjs +188 -0
- package/lib/memory/dual-graph-health.test.cjs +485 -0
- package/lib/memory/explain-decision-command.test.cjs +521 -0
- package/lib/memory/explain-decision-footer.test.cjs +316 -0
- package/lib/memory/explored-materials-store.cjs +392 -0
- package/lib/memory/f-selector-ranker.test.cjs +593 -0
- package/lib/memory/feynman-minto-guardian.test.cjs +863 -0
- package/lib/memory/feynman-minto-invariants.test.cjs +554 -0
- package/lib/memory/feynman-prompts-drift.test.cjs +144 -0
- package/lib/memory/feynman-prompts.cjs +151 -0
- package/lib/memory/feynman-prompts.test.cjs +96 -0
- package/lib/memory/first-touch-version.test.cjs +198 -0
- package/lib/memory/folder-memory-quadruple.test.cjs +548 -0
- package/lib/memory/folder-memory.test.cjs +503 -0
- package/lib/memory/framework-chain-composer.test.cjs +549 -0
- package/lib/memory/frontmatter-schema-validator.test.cjs +344 -0
- package/lib/memory/guardian-onstop-reaches-user.test.cjs +396 -0
- package/lib/memory/heal-command.test.cjs +604 -0
- package/lib/memory/help-coverage.test.cjs +108 -0
- package/lib/memory/help-renderer.test.cjs +145 -0
- package/lib/memory/huji-run-one-async-parity.test.cjs +242 -0
- package/lib/memory/hypergraph-event-schema.test.cjs +116 -0
- package/lib/memory/index-artifact-transaction.test.cjs +333 -0
- package/lib/memory/lazygraph-rs-discoveries-view.test.cjs +122 -0
- package/lib/memory/local-chain-recommender.test.cjs +172 -0
- package/lib/memory/mcp-input-validation.test.cjs +240 -0
- package/lib/memory/mcp-server-brain-deps.test.cjs +270 -0
- package/lib/memory/mcp-stack-fallback.test.cjs +433 -0
- package/lib/memory/minto-debounce-consumer-census.test.cjs +567 -0
- package/lib/memory/minto-debouncer.test.cjs +407 -0
- package/lib/memory/minto-debouncer.worker.cjs +46 -0
- package/lib/memory/minto-migration-v88.test.cjs +265 -0
- package/lib/memory/minto-schema-v88.test.cjs +390 -0
- package/lib/memory/mos-status-renderer.test.cjs +631 -0
- package/lib/memory/narrative-schema.cjs +376 -0
- package/lib/memory/narrative-schema.test.cjs +209 -0
- package/lib/memory/nav-dial.test.cjs +414 -0
- package/lib/memory/navigation-engine-core.test.cjs +712 -0
- package/lib/memory/navigation-engine-offer.test.cjs +404 -0
- package/lib/memory/navigation-hook-resolver.test.cjs +177 -0
- package/lib/memory/navigation-invariants.test.cjs +483 -0
- package/lib/memory/navigation-projections.test.cjs +241 -0
- package/lib/memory/navigation-write-edge.test.cjs +206 -0
- package/lib/memory/offer-closer.test.cjs +258 -0
- package/lib/memory/offer-presenter.test.cjs +554 -0
- package/lib/memory/on-stop-snapshot.test.cjs +404 -0
- package/lib/memory/orchestration-projection.test.cjs +706 -0
- package/lib/memory/packet-chain-hint.test.cjs +407 -0
- package/lib/memory/packet-schema-validation.test.cjs +317 -0
- package/lib/memory/palette-consistency.test.cjs +127 -0
- package/lib/memory/pending-tension-store.cjs +453 -0
- package/lib/memory/per-command-jtbd-derivation.test.cjs +130 -0
- package/lib/memory/per-command-teaching.test.cjs +110 -0
- package/lib/memory/post-compact-reinjection.test.cjs +854 -0
- package/lib/memory/post-write-triple.test.cjs +317 -0
- package/lib/memory/pre-compact-snapshot.test.cjs +495 -0
- package/lib/memory/precommit-real-commit.test.cjs +301 -0
- package/lib/memory/problem-type-router.test.cjs +656 -0
- package/lib/memory/query-efficiency-telemetry.test.cjs +612 -0
- package/lib/memory/recompile-room-references.test.cjs +392 -0
- package/lib/memory/recompile-room-references.worker.cjs +42 -0
- package/lib/memory/record-decision-dual-write.test.cjs +454 -0
- package/lib/memory/render-v2-disposition.test.cjs +199 -0
- package/lib/memory/room-classifier-strict-mode.test.cjs +430 -0
- package/lib/memory/room-minto-hook.test.cjs +398 -0
- package/lib/memory/rs-discovery-engine.test.cjs +323 -0
- package/lib/memory/run-feynman-tests.cjs +2101 -0
- package/lib/memory/security-trifecta.test.cjs +329 -0
- package/lib/memory/selector-alias-map.test.cjs +172 -0
- package/lib/memory/selector-decisions.test.cjs +417 -0
- package/lib/memory/selector-miss.test.cjs +290 -0
- package/lib/memory/session-start-brain-staleness.test.cjs +363 -0
- package/lib/memory/session-start-triple-injection.test.cjs +514 -0
- package/lib/memory/sessionstart-banner-formatter.cjs +318 -0
- package/lib/memory/sessionstart-coordinator.test.cjs +446 -0
- package/lib/memory/sessionstart-minto-banner.test.cjs +373 -0
- package/lib/memory/skill-activation-router.test.cjs +465 -0
- package/lib/memory/skill-vs-code-drift.test.cjs +257 -0
- package/lib/memory/soft-alias.test.cjs +144 -0
- package/lib/memory/spine-events-correlation.test.cjs +198 -0
- package/lib/memory/stale-copy-scanner.test.cjs +294 -0
- package/lib/memory/stamp-artifact-write.test.cjs +304 -0
- package/lib/memory/state-aware-router.test.cjs +90 -0
- package/lib/memory/statusline-active-room-write.test.cjs +245 -0
- package/lib/memory/statusline-active-room.test.cjs +315 -0
- package/lib/memory/statusline-minto-segment.test.cjs +292 -0
- package/lib/memory/statusline-two-row.test.cjs +338 -0
- package/lib/memory/suggest-next-workflow.test.cjs +176 -0
- package/lib/memory/sync-async-entry-points.test.cjs +204 -0
- package/lib/memory/terminal-capability.test.cjs +155 -0
- package/lib/memory/test-bridge-writer-enhanced.cjs +452 -0
- package/lib/memory/test-rs-brain-substrate-shape.cjs +529 -0
- package/lib/memory/test-rs-brain-substrate.cjs +636 -0
- package/lib/memory/test-rs-breakthrough-scorer.cjs +375 -0
- package/lib/memory/test-rs-canon-violations.cjs +218 -0
- package/lib/memory/test-rs-chain-feeder-core.cjs +344 -0
- package/lib/memory/test-rs-chain-feeder-skill-spawn.cjs +297 -0
- package/lib/memory/test-rs-commercial-assessor.cjs +385 -0
- package/lib/memory/test-rs-differential-scorer.cjs +480 -0
- package/lib/memory/test-rs-discovery-engine.cjs +648 -0
- package/lib/memory/test-rs-domain-analyzer.cjs +492 -0
- package/lib/memory/test-rs-egress-primitives.cjs +420 -0
- package/lib/memory/test-rs-expert-mapper.cjs +547 -0
- package/lib/memory/test-rs-explain-command.cjs +443 -0
- package/lib/memory/test-rs-fetcher-academic.cjs +848 -0
- package/lib/memory/test-rs-fetcher-experts.cjs +496 -0
- package/lib/memory/test-rs-fetcher-industry.cjs +702 -0
- package/lib/memory/test-rs-fetcher-patents.cjs +674 -0
- package/lib/memory/test-rs-innovation-classifier.cjs +301 -0
- package/lib/memory/test-rs-mind-map.cjs +646 -0
- package/lib/memory/test-rs-neo4j-writer.cjs +518 -0
- package/lib/memory/test-rs-nl-to-query.cjs +449 -0
- package/lib/memory/test-rs-pinecone-bridge.cjs +282 -0
- package/lib/memory/test-rs-preprocessor.cjs +433 -0
- package/lib/memory/test-rs-query-matrix.cjs +391 -0
- package/lib/memory/test-rs-query-to-text.cjs +551 -0
- package/lib/memory/test-rs-sqlite-mirror.cjs +649 -0
- package/lib/memory/test-rs-thesis-generator.cjs +360 -0
- package/lib/memory/triple-context-formatter.cjs +473 -0
- package/lib/memory/triple-context-formatter.test.cjs +442 -0
- package/lib/memory/user-md-persona.test.cjs +565 -0
- package/lib/memory/userpromptsubmit-integration.test.cjs +787 -0
- package/lib/memory/validators/README.md +157 -0
- package/lib/memory/validators/brain-md-invariants.cjs +475 -0
- package/lib/memory/validators/brain-substrate-invariants.cjs +285 -0
- package/lib/memory/validators/external-academic-invariants.cjs +249 -0
- package/lib/memory/validators/external-industry-invariants.cjs +271 -0
- package/lib/memory/validators/external-patents-invariants.cjs +266 -0
- package/lib/memory/validators/minto-invariants.cjs +62 -0
- package/lib/memory/validators/navigation-invariants.cjs +340 -0
- package/lib/memory/validators/queue-health.cjs +95 -0
- package/lib/memory/validators/snapshot-integrity.cjs +129 -0
- package/lib/memory/validators/stale-lifecycle.cjs +116 -0
- package/lib/memory/vault-section-minto-generator-atomic.test.cjs +556 -0
- package/lib/memory/vault-section-minto-generator-atomic.worker.cjs +73 -0
- package/lib/memory/workflow-layer-e2e.test.cjs +262 -0
- package/lib/memory/write-lock-atomic.test.cjs +137 -0
- package/lib/memory/write-lock-atomic.worker.cjs +55 -0
- package/lib/parity/check-parity.cjs +83 -0
- package/lib/presentation/presentation-server.cjs +101 -0
- package/lib/presentation/presentation-watcher.cjs +123 -0
- package/lib/quickview/hub-server.cjs +719 -0
- package/lib/quickview/server.cjs +533 -0
- package/lib/render/JTBD-PALETTES.md +145 -0
- package/lib/render/ROOM.md +111 -0
- package/lib/render/render-v2.cjs +532 -0
- package/lib/render/render-v2.test.cjs +267 -0
- package/lib/render/render.cjs +65 -0
- package/lib/sessionstart/budget-compressor.cjs +130 -0
- package/lib/sessionstart/contributor-interface.cjs +134 -0
- package/lib/sessionstart/contributor-isolator.cjs +128 -0
- package/lib/sessionstart/precedence-ladder.cjs +47 -0
- package/lib/state/ROOM.md +46 -0
- package/lib/state/state-md-parser.cjs +215 -0
- package/lib/statusline/ROOM.md +38 -0
- package/lib/statusline/banner-suppression.cjs +50 -0
- package/lib/statusline/cockpit-renderer.cjs +443 -0
- package/lib/statusline/cockpit-signals.cjs +312 -0
- package/lib/statusline/cockpit-telemetry.cjs +152 -0
- package/lib/statusline/ctx-window.cjs +135 -0
- package/lib/statusline/governing-thought-truncator.cjs +45 -0
- package/lib/statusline/next-move-cache.cjs +235 -0
- package/lib/statusline/ratification-next.cjs +164 -0
- package/lib/statusline/room-health-cache.cjs +200 -0
- package/lib/statusline/surface-detect.cjs +85 -0
- package/lib/statusline/two-row-renderer.cjs +207 -0
- package/lib/statusline/version-resolver.cjs +81 -0
- package/lib/ui/design-system.cjs +19 -0
- package/lib/update-bootstrap.sh.template +145 -0
- package/lib/vault/frontmatter-schema.cjs +297 -0
- package/lib/vault/room-scanner.cjs +365 -0
- package/lib/vault/wikilink-builder.cjs +231 -0
- package/lib/vault/wikilink-builder.test.cjs +182 -0
- package/lib/wiki/briefing.cjs +193 -0
- package/lib/wiki/editor-dist/wiki-editor.css +1 -0
- package/lib/wiki/editor-dist/wiki-editor.js +1327 -0
- package/lib/wiki/graph-links.cjs +281 -0
- package/lib/wiki/page-renderer.cjs +229 -0
- package/lib/wiki/room-home.cjs +353 -0
- package/lib/wiki/wiki-chat.cjs +81 -0
- package/lib/wiki/wiki-export.cjs +364 -0
- package/lib/wiki/wiki-layout.cjs +1143 -0
- package/lib/wiki/wiki-search.cjs +142 -0
- package/lib/wiki/wiki-server.cjs +748 -0
- package/lib/wiki/wiki-watcher.cjs +105 -0
- package/lib/workflow/ROOM.md +47 -0
- package/lib/workflow/chain-source.cjs +179 -0
- package/lib/workflow/command-resolver.cjs +155 -0
- package/lib/workflow/command-resolver.test.cjs +235 -0
- package/lib/workflow/cross-room-umbilical-closer.cjs +364 -0
- package/lib/workflow/dial-close-reach.cjs +405 -0
- package/lib/workflow/f-selector-ranker.cjs +1148 -0
- package/lib/workflow/f1-pick-consumer.cjs +232 -0
- package/lib/workflow/f3-depth-consumer.cjs +98 -0
- package/lib/workflow/f4-scope-consumer.cjs +112 -0
- package/lib/workflow/f8-consumer.test.cjs +82 -0
- package/lib/workflow/f8-fanout-consumer.cjs +208 -0
- package/lib/workflow/f9-consumer.test.cjs +71 -0
- package/lib/workflow/f9-ordered-consumer.cjs +199 -0
- package/lib/workflow/local-chain-recommender.cjs +330 -0
- package/lib/workflow/memory-cascade-f9-adapter.cjs +273 -0
- package/lib/workflow/memory-governance-closer.cjs +384 -0
- package/lib/workflow/offer-closer.cjs +407 -0
- package/lib/workflow/reach-hedge-ranker.cjs +809 -0
- package/lib/workflow/reach-reject-reader.cjs +372 -0
- package/lib/workflow/reconcile-f9-adapter.cjs +299 -0
- package/lib/workflow/selector-decisions.cjs +478 -0
- package/lib/workflow/session-binding-consumer.cjs +249 -0
- package/npm-shrinkwrap.json +1544 -0
- package/output-styles/destijl.md +67 -0
- package/package.json +22 -4
- package/pipelines/PWS_grading/01-deep-grade.md +48 -0
- package/pipelines/PWS_grading/02-mullins.md +50 -0
- package/pipelines/PWS_grading/03-build-thesis.md +60 -0
- package/pipelines/PWS_grading/04-structure-argument.md +77 -0
- package/pipelines/PWS_grading/CHAIN.md +79 -0
- package/pipelines/analogy/01-decompose.md +80 -0
- package/pipelines/analogy/02-abstract.md +87 -0
- package/pipelines/analogy/03-search.md +135 -0
- package/pipelines/analogy/04-transfer.md +101 -0
- package/pipelines/analogy/05-validate.md +106 -0
- package/pipelines/analogy/CHAIN.md +73 -0
- package/pipelines/discovery/01-explore-domains.md +44 -0
- package/pipelines/discovery/02-think-hats.md +50 -0
- package/pipelines/discovery/03-analyze-needs.md +54 -0
- package/pipelines/discovery/CHAIN.md +48 -0
- package/pipelines/thesis/01-structure-argument.md +45 -0
- package/pipelines/thesis/02-challenge-assumptions.md +48 -0
- package/pipelines/thesis/03-build-thesis.md +54 -0
- package/pipelines/thesis/CHAIN.md +48 -0
- package/references/brain/causal-directives.md +91 -0
- package/references/brain/causal-enrichment.cypher +165 -0
- package/references/brain/command-triggers-schema.md +15 -0
- package/references/brain/graph-architecture.md +317 -0
- package/references/brain/query-patterns.md +504 -0
- package/references/brain/room-hierarchy-schema.md +218 -0
- package/references/brain/schema.md +86 -0
- package/references/capability-radar/capabilities-index.md +269 -0
- package/references/capability-radar/changelog-cache.md +95 -0
- package/references/causal/causal-schema.md +103 -0
- package/references/design/email-template-standard.md +169 -0
- package/references/design/graph-visualization-standard.md +178 -0
- package/references/design/newsletter-email-template.html +307 -0
- package/references/document-generation.md +179 -0
- package/references/hsi/HSI-TOOLS-REFERENCE.md +222 -0
- package/references/import-config.md +141 -0
- package/references/integrations/detection-patterns.md +101 -0
- package/references/meeting/artifact-template.md +377 -0
- package/references/meeting/cross-meeting-intelligence.md +216 -0
- package/references/meeting/cross-relationship-patterns.md +202 -0
- package/references/meeting/extraction-perspectives.md +225 -0
- package/references/meeting/filing-protocol.md +222 -0
- package/references/meeting/knowledge-typing.md +242 -0
- package/references/meeting/live-join-interface.md +244 -0
- package/references/meeting/section-mapping.md +192 -0
- package/references/meeting/segment-classification.md +258 -0
- package/references/meeting/speaker-profile-template.md +219 -0
- package/references/meeting/summary-template.md +348 -0
- package/references/meeting/transcript-patterns.md +226 -0
- package/references/methodology/analyze-needs.md +135 -0
- package/references/methodology/analyze-systems.md +121 -0
- package/references/methodology/analyze-timing.md +149 -0
- package/references/methodology/beautiful-question.md +109 -0
- package/references/methodology/build-knowledge.md +161 -0
- package/references/methodology/build-thesis-scored.md +60 -0
- package/references/methodology/build-thesis.md +237 -0
- package/references/methodology/causal-loop-diagrams.md +65 -0
- package/references/methodology/challenge-assumptions.md +127 -0
- package/references/methodology/diagnose.md +169 -0
- package/references/methodology/dominant-designs.md +212 -0
- package/references/methodology/explore-domains.md +147 -0
- package/references/methodology/explore-futures.md +163 -0
- package/references/methodology/explore-trends.md +129 -0
- package/references/methodology/find-bottlenecks.md +131 -0
- package/references/methodology/grade.md +211 -0
- package/references/methodology/huji-stage-a-intake.md +246 -0
- package/references/methodology/index.md +34 -0
- package/references/methodology/leadership.md +200 -0
- package/references/methodology/lean-canvas.md +116 -0
- package/references/methodology/leverage-scan-signatures.md +83 -0
- package/references/methodology/macro-trends.md +192 -0
- package/references/methodology/map-unknowns.md +137 -0
- package/references/methodology/mullins-7-domains.md +104 -0
- package/references/methodology/problem-types.md +65 -0
- package/references/methodology/root-cause.md +178 -0
- package/references/methodology/rubric-huji.md +160 -0
- package/references/methodology/sapphire-encoding.md +355 -0
- package/references/methodology/scenario-plan.md +190 -0
- package/references/methodology/score-innovation.md +154 -0
- package/references/methodology/skillopt-judge-rubric.md +48 -0
- package/references/methodology/skillopt-queries-rubric.md +60 -0
- package/references/methodology/skillopt-refute-rubric.md +59 -0
- package/references/methodology/skillopt-review-rubric.md +72 -0
- package/references/methodology/skillopt-revise-rubric.md +48 -0
- package/references/methodology/structure-argument.md +158 -0
- package/references/methodology/systems-thinking.md +231 -0
- package/references/methodology/think-hats.md +147 -0
- package/references/methodology/triz-matrix.json +751 -0
- package/references/methodology/triz-principles.md +501 -0
- package/references/methodology/user-needs.md +199 -0
- package/references/methodology/validate.md +163 -0
- package/references/methodology/value-proposition.md +244 -0
- package/references/opportunities/funding-lifecycle.md +103 -0
- package/references/opportunities/grant-api-patterns.md +99 -0
- package/references/opportunities/opportunity-template.md +84 -0
- package/references/opportunities/tnufa-rubric.md +81 -0
- package/references/personality/assessment-philosophy.md +72 -0
- package/references/personality/lexicon.md +100 -0
- package/references/personality/persona-chains.md +56 -0
- package/references/personality/pws-lexicon-full.md +499 -0
- package/references/personality/voice-dna.md +156 -0
- package/references/personas/hat-perspectives.md +76 -0
- package/references/personas/persona-template.md +63 -0
- package/references/pipeline/act-output-contract.md +88 -0
- package/references/pipeline/chains-index.md +39 -0
- package/references/pws-profile-generation.md +79 -0
- package/references/reasoning/reasoning-schema.md +143 -0
- package/references/reasoning/reasoning-template.md +68 -0
- package/references/reasoning/run-template.md +38 -0
- package/references/research/RESEARCH_14_CLAUDE_CODE_SOURCE_ARCHITECTURE.md +209 -0
- package/references/research/RESEARCH_15_V1.8_OPTIMIZATION_JTBD.md +375 -0
- package/references/research/RESEARCH_16_NATIVE_FIRST_PLUGIN_ARCHITECTURE.md +575 -0
- package/references/research/RESEARCH_17_MCP_UI_FRAMEWORKS.md +272 -0
- package/references/security/agentshield-baseline.json +8 -0
- package/references/security/cve-db.json +220 -0
- package/references/taxonomy/TAXONOMY.md +192 -0
- package/references/templates/MINTO.md +36 -0
- package/references/user-research/2026-04-05-leah-lawrence-session.md +202 -0
- package/references/vault-kit/README.md +35 -0
- package/references/vault-kit/app.json +12 -0
- package/references/vault-kit/appearance.json +12 -0
- package/references/vault-kit/graph.json +35 -0
- package/references/vault-kit/snippets/mindrian-destijl.css +297 -0
- package/references/vault-kit/templates/new-artifact.md +37 -0
- package/references/vault-kit/templates/new-meeting-note.md +35 -0
- package/references/vault-kit/templates/new-team-profile.md +29 -0
- package/references/vault-kit/templates/new-xref.md +35 -0
- package/references/visual/ROOM.md +55 -0
- package/references/visual/palette.json +54 -0
- package/references/visual/symbol-system.md +151 -0
- package/scripts/189-plurai-gate-check.cjs +88 -0
- package/scripts/198-plurai-gate-check.cjs +118 -0
- package/scripts/198-rollback-rehearsal.cjs +233 -0
- package/scripts/83-scope-injection.test.cjs +648 -0
- package/scripts/PYTHON_GATES.md +78 -0
- package/scripts/__pycache__/compute-hsi.cpython-312.pyc +0 -0
- package/scripts/__pycache__/detect-reverse-salients.cpython-312.pyc +0 -0
- package/scripts/__pycache__/rs-engine.cpython-312.pyc +0 -0
- package/scripts/act-command.cjs +518 -0
- package/scripts/admin-brain-write.cjs +442 -0
- package/scripts/admin-command-gate.cjs +178 -0
- package/scripts/agentshield-scan-cli.cjs +226 -0
- package/scripts/agentshield-sessionstart-scan.cjs +282 -0
- package/scripts/analogy-fitness-report.cjs +266 -0
- package/scripts/analyze-room +1079 -0
- package/scripts/apply-teaching-content.cjs +298 -0
- package/scripts/async-artifact-auto-commit.cjs +485 -0
- package/scripts/audit-active-phase-resolver.cjs +160 -0
- package/scripts/audit-body-shape-coverage.cjs +213 -0
- package/scripts/auto-explore-drain.cjs +274 -0
- package/scripts/auto-explore-fingerprint.cjs +354 -0
- package/scripts/auto-explore-fire.cjs +359 -0
- package/scripts/backfill-correlation-id.cjs +425 -0
- package/scripts/backfill-hitl-shape.cjs +276 -0
- package/scripts/backfill-hitl-shape.test.cjs +307 -0
- package/scripts/backup-modifications +68 -0
- package/scripts/banner +182 -0
- package/scripts/brain-derivation-drain.cjs +291 -0
- package/scripts/brain-derive-command.cjs +846 -0
- package/scripts/brain-normalize-books.cypher +505 -0
- package/scripts/brain-normalize-final.cypher +1355 -0
- package/scripts/brain-normalize-problemtype.cypher +475 -0
- package/scripts/brain-normalize-supplement.cypher +449 -0
- package/scripts/brain-normalize-targeted.cypher +344 -0
- package/scripts/brain-normalize-v194.cypher +61 -0
- package/scripts/brain-normalize.cypher +530 -0
- package/scripts/brain-response-sanitize-hook.cjs +165 -0
- package/scripts/build-brain-census.cjs +957 -0
- package/scripts/build-brain-packet-schema.cjs +225 -0
- package/scripts/build-command-registry.cjs +587 -0
- package/scripts/build-connector-registry.cjs +1331 -0
- package/scripts/build-corpus-stats.cjs +408 -0
- package/scripts/build-dist-bundles.cjs +495 -0
- package/scripts/build-ecosystem-graph.cjs +490 -0
- package/scripts/build-graph +1462 -0
- package/scripts/build-graph-from-sqlite.cjs +97 -0
- package/scripts/build-harness-manifest.cjs +1090 -0
- package/scripts/build-jtbd-nudges +205 -0
- package/scripts/build-new-surface.cjs +805 -0
- package/scripts/build-orchestration-projection.cjs +1221 -0
- package/scripts/build-render-coverage.cjs +637 -0
- package/scripts/build-skill-mirrors.cjs +681 -0
- package/scripts/cache-hitrate-report.cjs +216 -0
- package/scripts/causal-to-graph.cjs +163 -0
- package/scripts/check-abstraction-fixture-neutral.cjs +160 -0
- package/scripts/check-admin-identity.cjs +212 -0
- package/scripts/check-brain-tool-liveness.cjs +502 -0
- package/scripts/check-card-fire.cjs +1809 -0
- package/scripts/check-cirs-declaration.cjs +279 -0
- package/scripts/check-deck-design.cjs +104 -0
- package/scripts/check-dual-graph-health.cjs +645 -0
- package/scripts/check-first-touch-drift.cjs +220 -0
- package/scripts/check-flagship-floor.cjs +391 -0
- package/scripts/check-framework-vocabulary-drift.cjs +563 -0
- package/scripts/check-gate-seam.cjs +178 -0
- package/scripts/check-graph-derive-health.cjs +208 -0
- package/scripts/check-graph-export-typemap.cjs +118 -0
- package/scripts/check-help-coverage.cjs +290 -0
- package/scripts/check-hitl-stages.cjs +219 -0
- package/scripts/check-hook-schema-compatibility.cjs +231 -0
- package/scripts/check-hsi-deps +42 -0
- package/scripts/check-kuzu-reintroduction.cjs +251 -0
- package/scripts/check-onboard +43 -0
- package/scripts/check-onboard-statusline.cjs +363 -0
- package/scripts/check-palette-consistency.cjs +106 -0
- package/scripts/check-pending-ambiguous.cjs +244 -0
- package/scripts/check-pending-breakthrough.cjs +189 -0
- package/scripts/check-pending-breakthrough.test.cjs +166 -0
- package/scripts/check-pending-naming-decision.cjs +97 -0
- package/scripts/check-plugin-path-anchoring.cjs +830 -0
- package/scripts/check-publish-needs.cjs +126 -0
- package/scripts/check-registry-drift.cjs +206 -0
- package/scripts/check-release-payload-ceiling.cjs +269 -0
- package/scripts/check-render-coverage.cjs +558 -0
- package/scripts/check-research-isomorphism.cjs +446 -0
- package/scripts/check-reward-before-investment.cjs +261 -0
- package/scripts/check-room-blueprints.cjs +213 -0
- package/scripts/check-schema-aliases.cjs +532 -0
- package/scripts/check-shape-declaration.cjs +958 -0
- package/scripts/check-shape-declaration.test.cjs +185 -0
- package/scripts/check-skill-spec.cjs +312 -0
- package/scripts/check-skill-vs-code-drift.cjs +178 -0
- package/scripts/check-substrate.cjs +513 -0
- package/scripts/check-tool-honesty.cjs +1601 -0
- package/scripts/check-update +60 -0
- package/scripts/check-version-and-sha.cjs +366 -0
- package/scripts/check-voice-style.cjs +184 -0
- package/scripts/check-worktree-hygiene.cjs +530 -0
- package/scripts/classify-insight +59 -0
- package/scripts/coherence-smoke-test.cjs +489 -0
- package/scripts/compute-bayesian-surprise.py +175 -0
- package/scripts/compute-blindspot-mass.py +209 -0
- package/scripts/compute-disruption-index.py +211 -0
- package/scripts/compute-element-novelty.py +254 -0
- package/scripts/compute-external-whitespace.py +563 -0
- package/scripts/compute-hsi.py +947 -0
- package/scripts/compute-meetings-intelligence +716 -0
- package/scripts/compute-opportunity-state +17 -0
- package/scripts/compute-state +393 -0
- package/scripts/compute-team +1112 -0
- package/scripts/compute-whitespace-embeddings.py +464 -0
- package/scripts/compute-whitespace-gaps.py +562 -0
- package/scripts/compute_topic_forest.py +684 -0
- package/scripts/consolidate-pinecone.py +265 -0
- package/scripts/context-monitor +943 -0
- package/scripts/create-speaker-profile +311 -0
- package/scripts/cross-room-detect.cjs +195 -0
- package/scripts/csv-to-idea-graph.cjs +755 -0
- package/scripts/ctxl-eval.cjs +846 -0
- package/scripts/curation-132-03-dedup-held-rename.cjs +395 -0
- package/scripts/curation-132-05-pseudonymize.cjs +189 -0
- package/scripts/derive-verb-reach-affinity.cjs +507 -0
- package/scripts/detect-reverse-salients.py +242 -0
- package/scripts/diagnostics-command.cjs +345 -0
- package/scripts/dial-memory-refresh-command.cjs +147 -0
- package/scripts/discover-analogy-whitespace.py +433 -0
- package/scripts/discover-hsi-whitespace.py +352 -0
- package/scripts/discover-rs-whitespace.py +327 -0
- package/scripts/discovery-cycle.cjs +625 -0
- package/scripts/disposition-render-v2.cjs +229 -0
- package/scripts/doctor-preflight-format.cjs +101 -0
- package/scripts/doctor.cjs +4327 -0
- package/scripts/dogfood-bridge/append-to-queue.sh +59 -0
- package/scripts/dogfood-bridge/path-filter.cjs +86 -0
- package/scripts/dogfood-derive.cjs +158 -0
- package/scripts/dogfood-emit.cjs +126 -0
- package/scripts/empathy-observation-emit.cjs +108 -0
- package/scripts/enrichment-queue-append.cjs +157 -0
- package/scripts/ensure-brain-baseline.cjs +117 -0
- package/scripts/entity-extract.cjs +1135 -0
- package/scripts/eureka-command.cjs +687 -0
- package/scripts/eureka-critic-run.cjs +662 -0
- package/scripts/eureka-portfolio-report.cjs +2038 -0
- package/scripts/eureka-room-report.cjs +419 -0
- package/scripts/explain-decision-command.cjs +499 -0
- package/scripts/export-pinecone-embeddings.cjs +516 -0
- package/scripts/extract-room-intelligence.cjs +714 -0
- package/scripts/fetch-brain-baseline.cjs +190 -0
- package/scripts/fetch-brain-baseline.py +360 -0
- package/scripts/feynman-minto-guardian.cjs +672 -0
- package/scripts/feynman-timeline-refresh-command.cjs +270 -0
- package/scripts/file-asset +253 -0
- package/scripts/fire-sensor-event.cjs +83 -0
- package/scripts/first-install-router.cjs +968 -0
- package/scripts/frontmatter-schema-validator.cjs +339 -0
- package/scripts/fts-index-drain.cjs +221 -0
- package/scripts/generate-chat-embed.cjs +179 -0
- package/scripts/generate-deck.cjs +322 -0
- package/scripts/generate-export.cjs +474 -0
- package/scripts/generate-hub.cjs +2553 -0
- package/scripts/generate-lobby.cjs +718 -0
- package/scripts/generate-presentation.cjs +988 -0
- package/scripts/generate-presentation.test.cjs +405 -0
- package/scripts/generate-section-intelligence.cjs +330 -0
- package/scripts/generate-snapshot.cjs +1410 -0
- package/scripts/generate-standalone +159 -0
- package/scripts/git-ops +211 -0
- package/scripts/graph-heal-pipeline.cjs +321 -0
- package/scripts/gsd-artifact-graph-hook.cjs +219 -0
- package/scripts/gsd-graph-derive-drain.cjs +571 -0
- package/scripts/gsd-graph-derive-sweep.cjs +195 -0
- package/scripts/heal-command.cjs +1365 -0
- package/scripts/hedge-refit-pipeline.cjs +207 -0
- package/scripts/help-renderer.cjs +303 -0
- package/scripts/hmi-compliance-poll.cjs +451 -0
- package/scripts/hmi-status-command.cjs +510 -0
- package/scripts/hooked-rescore-117.cjs +224 -0
- package/scripts/hooks/pre-commit +533 -0
- package/scripts/hooks/pre-commit-room-minto-guard.cmd +43 -0
- package/scripts/hooks/pre-commit-room-minto-guard.sh +533 -0
- package/scripts/hsi-to-graph.cjs +194 -0
- package/scripts/huji-batch.cjs +821 -0
- package/scripts/huji-eval.cjs +1158 -0
- package/scripts/huji-intake.cjs +563 -0
- package/scripts/huji-pin-smoketest.cjs +454 -0
- package/scripts/huji-run-one-async.cjs +305 -0
- package/scripts/huji-run-one.cjs +671 -0
- package/scripts/install-pre-commit.sh +113 -0
- package/scripts/intent-classifier +106 -0
- package/scripts/intent-classifier.cjs +3620 -0
- package/scripts/interpret-whitespace.cjs +691 -0
- package/scripts/jtbd-command.cjs +810 -0
- package/scripts/jtbd-update.cjs +299 -0
- package/scripts/label-topic-forest.cjs +667 -0
- package/scripts/learn-from-usage +168 -0
- package/scripts/lib/__pycache__/ensure_ml_deps.cpython-312.pyc +0 -0
- package/scripts/lib/ensure_ml_deps.py +97 -0
- package/scripts/load-embeddings-into-neo4j.cjs +569 -0
- package/scripts/memory-artifact-graph-hook.cjs +191 -0
- package/scripts/memory-command.cjs +687 -0
- package/scripts/memory-completion-detector.cjs +217 -0
- package/scripts/memory-lifecycle.cjs +620 -0
- package/scripts/memory-resume-nudge.cjs +233 -0
- package/scripts/methodology-ingest-local.sh +36 -0
- package/scripts/migrate-brain-mcp-from-http-to-stdio.cjs +190 -0
- package/scripts/migrate-brain-mcp-from-http-to-stdio.test.cjs +242 -0
- package/scripts/migrate-hats-to-roomdb.cjs +217 -0
- package/scripts/migrate-lazygraph.cjs +250 -0
- package/scripts/migrate-minto-schema-v88.cjs +296 -0
- package/scripts/migrate-plugin-root-refs.cjs +168 -0
- package/scripts/migrate-room-sections-v275.cjs +556 -0
- package/scripts/migrate-rooms +417 -0
- package/scripts/migrate-skill-frontmatter.cjs +472 -0
- package/scripts/migrate-stale-user-settings.cjs +296 -0
- package/scripts/migrate-telemetry-v1.cjs +384 -0
- package/scripts/migrate-telemetry-v1.test.cjs +356 -0
- package/scripts/minto-debouncer.cjs +428 -0
- package/scripts/mos-status.cjs +622 -0
- package/scripts/mva-detect.cjs +229 -0
- package/scripts/mva-run.cjs +36 -0
- package/scripts/on-agent-complete +163 -0
- package/scripts/on-cwd-changed +149 -0
- package/scripts/on-file-changed +68 -0
- package/scripts/on-stop +617 -0
- package/scripts/on-task-complete +194 -0
- package/scripts/operator-command.cjs +858 -0
- package/scripts/operator-update.cjs +308 -0
- package/scripts/part8-egress-guard-hook.cjs +229 -0
- package/scripts/pipeline-command.cjs +271 -0
- package/scripts/post-compact +383 -0
- package/scripts/post-update-activation.cjs +339 -0
- package/scripts/post-write +283 -0
- package/scripts/power-demo-prompt.md +621 -0
- package/scripts/pre-compact +273 -0
- package/scripts/preflight-auto-explore.cjs +314 -0
- package/scripts/preflight-doctor.cjs +225 -0
- package/scripts/preflight-release-drift.cjs +168 -0
- package/scripts/preflight-tension-surface.cjs +414 -0
- package/scripts/probe-brain-contract.cjs +502 -0
- package/scripts/publish-ops +346 -0
- package/scripts/query-efficiency-telemetry.cjs +364 -0
- package/scripts/query-semantic-scholar.cjs +545 -0
- package/scripts/reapply-modifications +49 -0
- package/scripts/reassign-primary.cjs +125 -0
- package/scripts/recompile-room-references.cjs +601 -0
- package/scripts/release-beta-preflight.sh +69 -0
- package/scripts/render-pdf +588 -0
- package/scripts/render-viz +190 -0
- package/scripts/research-speaker +239 -0
- package/scripts/resolve-room +204 -0
- package/scripts/restore-post-compact-context.cjs +320 -0
- package/scripts/room-auto-create-nudge.cjs +136 -0
- package/scripts/room-naming-selector.cjs +201 -0
- package/scripts/room-registry +767 -0
- package/scripts/rs-discovery-engine.cjs +725 -0
- package/scripts/rs-engine.py +2073 -0
- package/scripts/rs-experts-command.cjs +300 -0
- package/scripts/rs-explain-command.cjs +323 -0
- package/scripts/rs-fetch-command.cjs +170 -0
- package/scripts/rs-thesis-command.cjs +203 -0
- package/scripts/rs-vector-bridge.cjs +410 -0
- package/scripts/run-harness.cjs +890 -0
- package/scripts/scout-cadence-guard.cjs +323 -0
- package/scripts/scout-cadence-runner.cjs +509 -0
- package/scripts/scout-telemetry-aggregator.cjs +268 -0
- package/scripts/sealed-walker.py +96 -0
- package/scripts/seed-brain-commands.cjs +324 -0
- package/scripts/self-update +105 -0
- package/scripts/sentinel-deadline-monitor +241 -0
- package/scripts/sentinel-health-check +198 -0
- package/scripts/sentinel-snapshot +42 -0
- package/scripts/serve-dashboard +103 -0
- package/scripts/serve-dashboard-live +932 -0
- package/scripts/serve-presentation +97 -0
- package/scripts/serve-wiki +90 -0
- package/scripts/session-end-presence.cjs +79 -0
- package/scripts/session-start +1942 -0
- package/scripts/sessionstart-coordinator.cjs +249 -0
- package/scripts/sessionstart-npm-reconcile.cjs +111 -0
- package/scripts/sessionstart-post-update-preflight.cjs +303 -0
- package/scripts/sessionstart-reference-now-seed.cjs +137 -0
- package/scripts/setup-hooks.sh +112 -0
- package/scripts/skillopt-codereview.cjs +830 -0
- package/scripts/skillopt-eval.cjs +519 -0
- package/scripts/skillopt-funnel.cjs +1076 -0
- package/scripts/skillopt-genqueries.cjs +571 -0
- package/scripts/skillopt-inventory.cjs +319 -0
- package/scripts/skillopt-merge.cjs +656 -0
- package/scripts/skillopt-triggerloop.cjs +1126 -0
- package/scripts/soft-alias-runner.cjs +116 -0
- package/scripts/stamp-artifact-write.cjs +276 -0
- package/scripts/stamp-firing-block.cjs +325 -0
- package/scripts/state-write.cjs +97 -0
- package/scripts/statusline-fallback-echo.cjs +297 -0
- package/scripts/statusline-mos +116 -0
- package/scripts/statusline-mos-dispatch +127 -0
- package/scripts/suggest-next-command.cjs +416 -0
- package/scripts/sweep-skill-descriptions.cjs +263 -0
- package/scripts/sync-rooms-brain +438 -0
- package/scripts/sync-rooms-graph +264 -0
- package/scripts/telemetry-command-invocation.cjs +120 -0
- package/scripts/test-doctor-recovery.cjs +242 -0
- package/scripts/test-fresh-install.md +140 -0
- package/scripts/track-analytics +156 -0
- package/scripts/transcribe-audio +148 -0
- package/scripts/transcript-ingest.cjs +225 -0
- package/scripts/update-icm-index +153 -0
- package/scripts/v182-brain-optimize.cypher +1191 -0
- package/scripts/validate-model-profiles +93 -0
- package/scripts/vault-content-reformatter.cjs +581 -0
- package/scripts/vault-export-orchestrator.cjs +400 -0
- package/scripts/vault-footer-injector.cjs +315 -0
- package/scripts/vault-import.cjs +839 -0
- package/scripts/vault-integration-test.cjs +318 -0
- package/scripts/vault-regenerate-all.cjs +216 -0
- package/scripts/vault-regenerate-all.test.cjs +138 -0
- package/scripts/vault-rules-generator.cjs +220 -0
- package/scripts/vault-section-minto-generator.cjs +1642 -0
- package/scripts/vault-section-minto-generator.integration.test.cjs +576 -0
- package/scripts/vault-section-minto-generator.test.cjs +291 -0
- package/scripts/vault-section-state-generator.cjs +385 -0
- package/scripts/vault-welcome-generator.cjs +403 -0
- package/scripts/vault-wikilink-injector.cjs +449 -0
- package/scripts/verify-phase-132.cjs +338 -0
- package/scripts/verify-release +744 -0
- package/scripts/whitespace-command.cjs +831 -0
- package/scripts/whitespace-to-brain.cjs +383 -0
- package/scripts/whitespace-to-graph.cjs +220 -0
- package/scripts/wikilink-batch.cjs +102 -0
- package/scripts/wikilink-file.cjs +139 -0
- package/scripts/write-bridge-artifacts.cjs +140 -0
- package/scripts/write-scope-check +12 -0
- package/scripts/write-scope-check.cjs +461 -0
- package/scripts/write-whitespace-sections.cjs +483 -0
- package/settings.json +7 -0
- package/skills/act/SKILL.md +523 -0
- package/skills/admin/SKILL.md +437 -0
- package/skills/agentshield/SKILL.md +50 -0
- package/skills/analyze-needs/SKILL.md +74 -0
- package/skills/analyze-systems/SKILL.md +69 -0
- package/skills/analyze-timing/SKILL.md +94 -0
- package/skills/auto-explore/SKILL.md +84 -0
- package/skills/beautiful-question/SKILL.md +72 -0
- package/skills/bono/SKILL.md +146 -0
- package/skills/brain-connector/SKILL.md +206 -0
- package/skills/brain-derive/SKILL.md +140 -0
- package/skills/build-knowledge/SKILL.md +118 -0
- package/skills/build-thesis/SKILL.md +90 -0
- package/skills/causal/SKILL.md +265 -0
- package/skills/challenge-assumptions/SKILL.md +74 -0
- package/skills/client-discovery-interview/SKILL.md +94 -0
- package/skills/client-discovery-interview/discovery-scaffold.json +41 -0
- package/skills/client-discovery-interview/question-bank.md +149 -0
- package/skills/compare-ventures/SKILL.md +113 -0
- package/skills/context-engine/SKILL.md +169 -0
- package/skills/conversation-mode/SKILL.md +189 -0
- package/skills/correct-reference-now/SKILL.md +86 -0
- package/skills/dashboard/SKILL.md +142 -0
- package/skills/deck/SKILL.md +113 -0
- package/skills/deep-grade/SKILL.md +210 -0
- package/skills/diagnose/SKILL.md +128 -0
- package/skills/diagnostics/SKILL.md +193 -0
- package/skills/dial-memory-refresh/SKILL.md +116 -0
- package/skills/diffusion/SKILL.md +125 -0
- package/skills/discover/SKILL.md +216 -0
- package/skills/doctor/SKILL.md +269 -0
- package/skills/dogfood-flush/SKILL.md +133 -0
- package/skills/dominant-designs/SKILL.md +72 -0
- package/skills/eureka/SKILL.md +313 -0
- package/skills/explain-decision/SKILL.md +138 -0
- package/skills/explore-domains/SKILL.md +74 -0
- package/skills/explore-futures/SKILL.md +64 -0
- package/skills/explore-opportunity/SKILL.md +168 -0
- package/skills/explore-trends/SKILL.md +74 -0
- package/skills/export/SKILL.md +126 -0
- package/skills/feynman-timeline-refresh/SKILL.md +105 -0
- package/skills/file-meeting/SKILL.md +1190 -0
- package/skills/find-analogies/SKILL.md +360 -0
- package/skills/find-bottlenecks/SKILL.md +104 -0
- package/skills/find-connections/SKILL.md +108 -0
- package/skills/funding/SKILL.md +110 -0
- package/skills/futures/SKILL.md +124 -0
- package/skills/grade/SKILL.md +252 -0
- package/skills/grade-grant/SKILL.md +293 -0
- package/skills/graph/SKILL.md +216 -0
- package/skills/hat-briefing/SKILL.md +160 -0
- package/skills/heal/SKILL.md +69 -0
- package/skills/help/SKILL.md +172 -0
- package/skills/hmi-status/SKILL.md +73 -0
- package/skills/ignite/SKILL.md +225 -0
- package/skills/ingest-methodology/SKILL.md +125 -0
- package/skills/intel-pipeline/SKILL.md +128 -0
- package/skills/intelligence-orchestrator/SKILL.md +262 -0
- package/skills/jtbd/SKILL.md +261 -0
- package/skills/larry-personality/SKILL.md +570 -0
- package/skills/larry-personality/framework-chains.md +92 -0
- package/skills/larry-personality/mode-engine.md +185 -0
- package/skills/leadership/SKILL.md +109 -0
- package/skills/lean-canvas/SKILL.md +70 -0
- package/skills/macro-trends/SKILL.md +84 -0
- package/skills/map-unknowns/SKILL.md +72 -0
- package/skills/memory/SKILL.md +212 -0
- package/skills/memory-cortex-reach/SKILL.md +80 -0
- package/skills/models/SKILL.md +197 -0
- package/skills/mos/SKILL.md +160 -0
- package/skills/mos-deck-engine/SKILL.md +329 -0
- package/skills/mos-reason/SKILL.md +484 -0
- package/skills/mullins/SKILL.md +151 -0
- package/skills/mullins-scaffold/SKILL.md +132 -0
- package/skills/mullins-scaffold/scaffold.json +223 -0
- package/skills/mva-brief/SKILL.md +87 -0
- package/skills/mva-option/SKILL.md +120 -0
- package/skills/mva-pipeline/SKILL.md +158 -0
- package/skills/mva-report/SKILL.md +79 -0
- package/skills/new-project/SKILL.md +629 -0
- package/skills/new-surface/SKILL.md +112 -0
- package/skills/onboard/SKILL.md +485 -0
- package/skills/operator/SKILL.md +167 -0
- package/skills/opportunities/SKILL.md +171 -0
- package/skills/organize/SKILL.md +69 -0
- package/skills/persona/SKILL.md +272 -0
- package/skills/pipeline/SKILL.md +164 -0
- package/skills/present/SKILL.md +123 -0
- package/skills/publish/SKILL.md +224 -0
- package/skills/pws-brain/SKILL.md +152 -0
- package/skills/pws-methodology/SKILL.md +92 -0
- package/skills/qualify-opportunity/SKILL.md +111 -0
- package/skills/query/SKILL.md +68 -0
- package/skills/radar/SKILL.md +106 -0
- package/skills/reanalyze/SKILL.md +122 -0
- package/skills/research/SKILL.md +462 -0
- package/skills/room/SKILL.md +381 -0
- package/skills/room-passive/SKILL.md +174 -0
- package/skills/room-proactive/SKILL.md +344 -0
- package/skills/rooms/SKILL.md +678 -0
- package/skills/root-cause/SKILL.md +73 -0
- package/skills/rs-experts/SKILL.md +151 -0
- package/skills/rs-explain/SKILL.md +130 -0
- package/skills/rs-fetch/SKILL.md +115 -0
- package/skills/rs-thesis/SKILL.md +129 -0
- package/skills/scenario-plan/SKILL.md +76 -0
- package/skills/scheduled-tasks/SKILL.md +301 -0
- package/skills/score-innovation/SKILL.md +74 -0
- package/skills/scout/SKILL.md +370 -0
- package/skills/setup/SKILL.md +654 -0
- package/skills/show/SKILL.md +68 -0
- package/skills/skill/SKILL.md +104 -0
- package/skills/snapshot/SKILL.md +178 -0
- package/skills/speakers/SKILL.md +116 -0
- package/skills/splash/SKILL.md +54 -0
- package/skills/stance/SKILL.md +89 -0
- package/skills/status/SKILL.md +107 -0
- package/skills/structure-argument/SKILL.md +78 -0
- package/skills/suggest-next/SKILL.md +137 -0
- package/skills/systems-thinking/SKILL.md +220 -0
- package/skills/think-hats/SKILL.md +82 -0
- package/skills/trending-to-absurd/SKILL.md +100 -0
- package/skills/ui-system/SKILL.md +474 -0
- package/skills/ui-system/design-system/M-OS-DESIGN-SYSTEM.md +273 -0
- package/skills/ui-system/design-system/SPEC.md +72 -0
- package/skills/ui-system/design-system/image-prompt-style.md +29 -0
- package/skills/ui-system/design-system/mos-design-system.css +240 -0
- package/skills/ui-system/rules/design-system.md +60 -0
- package/skills/ui-system/rules/dual-palette.md +156 -0
- package/skills/ui-system/rules/glyph-disambiguation.md +171 -0
- package/skills/ui-system/rules/shape-f-zero-and-six.md +169 -0
- package/skills/update/SKILL.md +254 -0
- package/skills/user-needs/SKILL.md +73 -0
- package/skills/validate/SKILL.md +73 -0
- package/skills/value-proposition/SKILL.md +141 -0
- package/skills/vault/SKILL.md +326 -0
- package/skills/visualize/SKILL.md +69 -0
- package/skills/whitespace/SKILL.md +539 -0
- package/skills/wiki/SKILL.md +94 -0
- package/templates/_base.html +20 -0
- package/templates/chat-panel.html +205 -0
- package/templates/constellation-chat-hooks.js +89 -0
- package/templates/constellation.html +1272 -0
- package/templates/destijl-base.css +268 -0
- package/templates/discovery/discovery-brief-template.md +97 -0
- package/templates/due-diligence.html +49 -0
- package/templates/executive-summary.html +40 -0
- package/templates/icm/CLAUDE.md +31 -0
- package/templates/icm/GROUP-CLAUDE.md +33 -0
- package/templates/icm/INDEX.md +26 -0
- package/templates/import/stage-contracts/01-ingest.md +34 -0
- package/templates/import/stage-contracts/02-classify.md +48 -0
- package/templates/import/stage-contracts/03-route.md +42 -0
- package/templates/import/stage-contracts/04-enrich.md +40 -0
- package/templates/investment-thesis.html +25 -0
- package/templates/meeting-report.html +361 -0
- package/templates/presentation/dashboard.html +1150 -0
- package/templates/presentation/deck.html +540 -0
- package/templates/presentation/diagrams.html +437 -0
- package/templates/presentation/graph.html +391 -0
- package/templates/presentation/insights.html +548 -0
- package/templates/presentation/wiki.html +533 -0
- package/templates/profile.html +136 -0
- package/templates/room-context/last-session.md +56 -0
- package/templates/room-context/methodology-history.md +28 -0
- package/templates/room-context/rejection-log.md +25 -0
- package/templates/room-context/weekly-digest.md +54 -0
- package/templates/room-skeleton/MINTO.md.tmpl +19 -0
- package/templates/room-skeleton/ROOM.md.identity.tmpl +13 -0
- package/templates/room-skeleton/ROOM.md.section.tmpl +33 -0
- package/templates/room-skeleton/STATE.md.tmpl +33 -0
- package/templates/room-skeleton/USER.md.tmpl +23 -0
- package/templates/room-skeleton/references/.gitkeep +0 -0
- package/templates/room-skeleton/references/SECTION-SCHEMA.md +213 -0
- package/templates/room-skeleton/references/SUB-SCHEMAS.md +91 -0
- package/templates/room-skeleton/section-contracts/.gitkeep +0 -0
- package/templates/room-skeleton/section-contracts/business-model.md +32 -0
- package/templates/room-skeleton/section-contracts/competitive-analysis.md +33 -0
- package/templates/room-skeleton/section-contracts/financial-model.md +30 -0
- package/templates/room-skeleton/section-contracts/funding.md +41 -0
- package/templates/room-skeleton/section-contracts/legal-ip.md +30 -0
- package/templates/room-skeleton/section-contracts/market-analysis.md +32 -0
- package/templates/room-skeleton/section-contracts/opportunity-bank.md +39 -0
- package/templates/room-skeleton/section-contracts/problem-definition.md +32 -0
- package/templates/room-skeleton/section-contracts/solution-design.md +36 -0
- package/templates/room-skeleton/section-contracts/strategy.md +35 -0
- package/templates/room-skeleton/section-contracts/team-execution.md +36 -0
- package/templates/shared.css +427 -0
- package/templates/showcase/blueprint.html +432 -0
- package/templates/showcase/library.html +571 -0
- package/templates/showcase/narrative.html +361 -0
- package/templates/showcase/overview.html +468 -0
- package/templates/showcase/synthesis.html +473 -0
- package/templates/signature-footer.html +34 -0
|
@@ -0,0 +1,1942 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# session-start: SessionStart hook handler for MindrianOS
|
|
3
|
+
# Loads room context into Claude's additionalContext for session continuity
|
|
4
|
+
# Must complete in under 2 seconds
|
|
5
|
+
#
|
|
6
|
+
# Phase 88-07 addition: after Phase 83 ACTIVE ROOM CONTEXT, inject a
|
|
7
|
+
# TRIPLE_CONTEXT block per active section via lib/memory/triple-context-
|
|
8
|
+
# formatter.cjs. Reads .mindrian/session-snapshot.json (88-06 producer)
|
|
9
|
+
# with fallback to live folder-memory.readTriple walk. Budget-capped via
|
|
10
|
+
# SESSION_START_BUDGET_TOKENS env var (default 5000).
|
|
11
|
+
|
|
12
|
+
set -euo pipefail
|
|
13
|
+
|
|
14
|
+
# ---------------------------------------------------------------------------
|
|
15
|
+
# Workspace guard (added 2026-04-13 after wrong-workspace incident).
|
|
16
|
+
# See docs/autopsies/2026-04-13-wrong-workspace-incident.md
|
|
17
|
+
#
|
|
18
|
+
# ~/.claude/plugins/ is where Claude Code installs plugins for READ access.
|
|
19
|
+
# It is NOT a dev workspace. Dev work must happen in ~/MindrianOS-Plugin/.
|
|
20
|
+
# Commits to the plugin cache directory never reach github and silently
|
|
21
|
+
# diverge from the real release pipeline. We prevent that here.
|
|
22
|
+
# ---------------------------------------------------------------------------
|
|
23
|
+
if [[ "${PWD}" == "${HOME}/.claude/plugins/"* ]] \
|
|
24
|
+
|| [[ "${PWD}" == "/home/jsagi/.claude/plugins/"* ]] \
|
|
25
|
+
|| [[ "${PWD}" == "/Users/"*"/.claude/plugins/"* ]]; then
|
|
26
|
+
cat >&2 <<'EOF'
|
|
27
|
+
|
|
28
|
+
WORKSPACE GUARD TRIPPED
|
|
29
|
+
|
|
30
|
+
You are running MindrianOS session-start from inside the plugin cache
|
|
31
|
+
directory. This is the install location, not a dev workspace.
|
|
32
|
+
|
|
33
|
+
Dev work must happen in ~/MindrianOS-Plugin/.
|
|
34
|
+
|
|
35
|
+
If you are developing: cd ~/MindrianOS-Plugin && claude
|
|
36
|
+
If you are a user reading the plugin: you are in the right place but
|
|
37
|
+
should not be running scripts manually here.
|
|
38
|
+
|
|
39
|
+
See docs/autopsies/2026-04-13-wrong-workspace-incident.md
|
|
40
|
+
|
|
41
|
+
EOF
|
|
42
|
+
exit 1
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
# ---------------------------------------------------------------------------
|
|
46
|
+
# Node version preflight (added 2026-04-15 for v1.10.9, plan 85-01).
|
|
47
|
+
#
|
|
48
|
+
# MindrianOS v1.10.9+ requires Node >= 22.5.0 for node:sqlite. If the
|
|
49
|
+
# installed Node is older, print a friendly upgrade message and exit 0.
|
|
50
|
+
# This is a SOFT fail: session-start is non-critical and must NEVER hard-
|
|
51
|
+
# fail the Claude Code launch. The plugin continues with reduced
|
|
52
|
+
# functionality (banner may show unknown, memory layer may no-op) rather
|
|
53
|
+
# than crashing the user's shell. SESSION_START_NODE_PREFLIGHT_SKIP=1
|
|
54
|
+
# bypasses this check for the preflight test fixture.
|
|
55
|
+
# ---------------------------------------------------------------------------
|
|
56
|
+
if [ -z "${SESSION_START_NODE_PREFLIGHT_SKIP:-}" ]; then
|
|
57
|
+
NODE_VERSION_RAW=$(node -e "process.stdout.write(process.versions.node)" 2>/dev/null || echo "")
|
|
58
|
+
if [ -n "$NODE_VERSION_RAW" ]; then
|
|
59
|
+
NODE_OK=$(node -e "
|
|
60
|
+
var v = (process.env.FORCE_NODE_VERSION || process.versions.node).split('.').map(Number);
|
|
61
|
+
var major = v[0] || 0, minor = v[1] || 0;
|
|
62
|
+
process.stdout.write((major > 22 || (major === 22 && minor >= 5)) ? 'ok' : 'old');
|
|
63
|
+
" 2>/dev/null || echo "ok")
|
|
64
|
+
if [ "$NODE_OK" = "old" ]; then
|
|
65
|
+
DETECTED="${FORCE_NODE_VERSION:-$NODE_VERSION_RAW}"
|
|
66
|
+
echo "MindrianOS v1.10.9+ requires Node >= 22.5.0. You are running Node ${DETECTED}. Please upgrade Node (nvm install 22, fnm install 22, or your package manager) and restart Claude Code. Plugin will continue with reduced functionality until Node is upgraded." >&2
|
|
67
|
+
exit 0
|
|
68
|
+
fi
|
|
69
|
+
fi
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
# Cross-platform file modification time (epoch seconds)
|
|
73
|
+
portable_stat_mtime() {
|
|
74
|
+
local file="$1"
|
|
75
|
+
if [ "$(uname -s)" = "Darwin" ]; then
|
|
76
|
+
stat -f %m "$file" 2>/dev/null || echo 0
|
|
77
|
+
else
|
|
78
|
+
stat -c %Y "$file" 2>/dev/null || echo 0
|
|
79
|
+
fi
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
83
|
+
PLUGIN_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
84
|
+
# 2026-07-05 Windows/git-bash fix: under git-bash (MSYS), `pwd` above returns an
|
|
85
|
+
# MSYS-style path (e.g. /c/Users/jsagi/...). Every `node -e "...require('$PLUGIN_ROOT/...')..."`
|
|
86
|
+
# call below passes this string straight into Node's require(), but Windows-native
|
|
87
|
+
# node.exe does not understand MSYS paths -- it reads /c/Users/... literally and
|
|
88
|
+
# fails with "Cannot find module", which the version-resolution catch (below) then
|
|
89
|
+
# silently degrades to "unknown" (the confirmed live root cause of the
|
|
90
|
+
# "[MindrianOS vunknown]" banner on a real Windows machine, 2026-07-05). Normalize
|
|
91
|
+
# ONCE here to the Windows-native mixed form (C:/Users/... -- forward slashes, so
|
|
92
|
+
# no backslash-escaping needed inside the node -e JS string literals below) via
|
|
93
|
+
# git-bash's own cygpath, and use PLUGIN_ROOT_FOR_NODE everywhere a path gets
|
|
94
|
+
# passed into a `require()` call. On Linux/macOS (no cygpath), this is a no-op.
|
|
95
|
+
if command -v cygpath >/dev/null 2>&1; then
|
|
96
|
+
PLUGIN_ROOT_FOR_NODE="$(cygpath -m "$PLUGIN_ROOT" 2>/dev/null || echo "$PLUGIN_ROOT")"
|
|
97
|
+
else
|
|
98
|
+
PLUGIN_ROOT_FOR_NODE="$PLUGIN_ROOT"
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
# Determine working directory (where user's project is)
|
|
102
|
+
WORK_DIR="${PWD}"
|
|
103
|
+
ROOM_DIR=$("${SCRIPT_DIR}/resolve-room" "$WORK_DIR") || ROOM_DIR=""
|
|
104
|
+
|
|
105
|
+
# Read current version from plugin.json via platform.cjs (plan 85-06 sweep).
|
|
106
|
+
# python3 is a Microsoft Store alias stub on Windows and produces "vunknown".
|
|
107
|
+
# platform.cjs.readPluginJsonVersion is a fail-safe Node-native read.
|
|
108
|
+
# 2026-07-05 fix: the catch previously swallowed the real error and printed
|
|
109
|
+
# only 'unknown' to stdout, hiding WHY resolution failed. That logging fix
|
|
110
|
+
# then revealed the ACTUAL cause live on a real Windows machine: an MSYS-style
|
|
111
|
+
# path (/c/Users/...) reaching node's require(), which node.exe cannot resolve
|
|
112
|
+
# -- now fixed at the source via PLUGIN_ROOT_FOR_NODE above (cygpath -m
|
|
113
|
+
# normalization). Both fixes land together: the path is correct AND, if
|
|
114
|
+
# anything else ever throws here, the real error is logged instead of hidden.
|
|
115
|
+
PLUGIN_VERSION=$(node -e "try{process.stdout.write(require('$PLUGIN_ROOT_FOR_NODE/lib/core/platform.cjs').readPluginJsonVersion('$PLUGIN_ROOT_FOR_NODE'))}catch(e){process.stderr.write('[session-start] PLUGIN_VERSION resolution failed: '+(e&&e.stack||e)+'\n');process.stdout.write('unknown')}" 2>>"${TMPDIR:-/tmp}/mindrian-session-start-version-errors.log" || echo "unknown")
|
|
116
|
+
|
|
117
|
+
# plan 85-06 (WIN-FIX-H-02): resolve banner script path via platform.cjs so
|
|
118
|
+
# future .cmd wrappers on win32 can be substituted without editing session-
|
|
119
|
+
# start. On linux/darwin this returns ${PLUGIN_ROOT}/scripts/banner with a
|
|
120
|
+
# forward slash; on win32 it returns the same with a backslash.
|
|
121
|
+
BANNER_SCRIPT=$(node -e "try{process.stdout.write(require('$PLUGIN_ROOT_FOR_NODE/lib/core/platform.cjs').resolveHookScript('banner','$PLUGIN_ROOT_FOR_NODE'))}catch(e){process.stdout.write('$SCRIPT_DIR/banner')}" 2>/dev/null || echo "${SCRIPT_DIR}/banner")
|
|
122
|
+
|
|
123
|
+
# Version marker for update detection (D-01, D-02)
|
|
124
|
+
LAST_VERSION_FILE="$HOME/.mindrian-last-version"
|
|
125
|
+
LAST_VERSION=""
|
|
126
|
+
if [ -f "$LAST_VERSION_FILE" ]; then
|
|
127
|
+
LAST_VERSION=$(cat "$LAST_VERSION_FILE" 2>/dev/null || echo "")
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
# --- BEGIN Phase 126 Plan 07 install-state migration (BEFORE Phase 123 writer) ---
|
|
131
|
+
# Phase 126 Plan 07. The migration is ADDITIVE only (CONTEXT.md D3): v1 -> v2
|
|
132
|
+
# adds schema_version + topology_class + last_acceptance_run +
|
|
133
|
+
# renderer_contract_version while preserving v1 fields byte-identical.
|
|
134
|
+
# Future-version (schema_version > 2) emits a stderr warn + defers to
|
|
135
|
+
# `/mos:doctor --fix`; the file is NEVER downgraded silently.
|
|
136
|
+
#
|
|
137
|
+
# This block runs BEFORE the Phase 123 install-state record block below so
|
|
138
|
+
# downstream readers see the v2 shape. Errors here NEVER crash session-start
|
|
139
|
+
# (the script is a hook; soft-fail is the contract). Stderr passes through so
|
|
140
|
+
# users see the future-version deferral message; stdout is suppressed so the
|
|
141
|
+
# block does not pollute the additionalContext JSON.
|
|
142
|
+
#
|
|
143
|
+
# Canon Part 8: LOCAL only -- the module reads/writes $HOME/.mindrian/ ; the
|
|
144
|
+
# node -e shim below makes ZERO network calls. Verified in the lib/core
|
|
145
|
+
# /install-state.cjs source (see file header).
|
|
146
|
+
if [ -f "$PLUGIN_ROOT/lib/core/install-state.cjs" ]; then
|
|
147
|
+
env \
|
|
148
|
+
INSTALL_STATE_MOD_PATH="$PLUGIN_ROOT/lib/core/install-state.cjs" \
|
|
149
|
+
node -e '
|
|
150
|
+
try {
|
|
151
|
+
var m = require(process.env.INSTALL_STATE_MOD_PATH);
|
|
152
|
+
var r = m.migrateIfNeeded({ home: process.env.HOME });
|
|
153
|
+
if (r && r.migrated) {
|
|
154
|
+
process.stderr.write("[session-start] install-state migrated v" + r.fromVersion + " -> v" + r.toVersion + "\n");
|
|
155
|
+
} else if (r && r.futureVersion) {
|
|
156
|
+
process.stderr.write("[session-start] install-state future-version detected (schema_version=" + r.currentVersion + "); deferring to /mos:doctor --fix\n");
|
|
157
|
+
}
|
|
158
|
+
} catch (e) {
|
|
159
|
+
process.stderr.write("[session-start] install-state migration error: " + (e && e.message) + " (continuing with existing path)\n");
|
|
160
|
+
}
|
|
161
|
+
' >/dev/null || true
|
|
162
|
+
fi
|
|
163
|
+
# --- END Phase 126 Plan 07 install-state migration ---
|
|
164
|
+
|
|
165
|
+
# --- BEGIN install-state record (Phase 123, single writer, EARLY -- before Step A/B) ---
|
|
166
|
+
# Phase 123 Plan-02 (HARNESS-123-05). Canon Part 8: LOCAL only -- no fetch/http/
|
|
167
|
+
# curl/brain.mindrian/tavily anywhere in this block. Per D-03 + RESEARCH Override
|
|
168
|
+
# 4: the write happens BEFORE Step A's statusline migration (at ~L1078) so the
|
|
169
|
+
# record is on disk before any downstream consumer reads it. The
|
|
170
|
+
# `~/.mindrian-last-version` write folds into this same step so there is no
|
|
171
|
+
# window where one is fresh and the other is stale (Pitfall 7 fix: the old
|
|
172
|
+
# line-419 write only fired on cold start, leaving the file stale on every
|
|
173
|
+
# session that had an active room).
|
|
174
|
+
#
|
|
175
|
+
# Field defaults at this offset:
|
|
176
|
+
# - statusline_renders_version defaults to "unknown" -- WRAPPER_DST is not set
|
|
177
|
+
# until Step A (~L1079), and doctor's class-I (Plan-03) computes it live
|
|
178
|
+
# from the deployed shim. An optional best-effort refresh after Step A may
|
|
179
|
+
# update just this one field; it NEVER gates this early write.
|
|
180
|
+
# - last_version_file_value captures the PREVIOUS ~/.mindrian-last-version
|
|
181
|
+
# value (read at $LAST_VERSION_FILE above, ~L101-104). The transition-banner
|
|
182
|
+
# block at ~L401-407 still has access to $LAST_VERSION via the shell
|
|
183
|
+
# variable -- read-before-write ordering is preserved.
|
|
184
|
+
_INSTALL_STATE_DIR="$HOME/.mindrian"
|
|
185
|
+
_INSTALL_STATE_JSON="$_INSTALL_STATE_DIR/install-state.json"
|
|
186
|
+
mkdir -p "$_INSTALL_STATE_DIR" 2>/dev/null || true
|
|
187
|
+
env \
|
|
188
|
+
PLUGIN_ROOT_FOR_RESOLVE="$PLUGIN_ROOT_FOR_NODE" \
|
|
189
|
+
PLUGIN_VERSION_FOR_RESOLVE="$PLUGIN_VERSION" \
|
|
190
|
+
INSTALL_STATE_JSON_PATH="$_INSTALL_STATE_JSON" \
|
|
191
|
+
LAST_VERSION_FILE_FOR_RESOLVE="$LAST_VERSION_FILE" \
|
|
192
|
+
node -e '
|
|
193
|
+
var fs = require("fs"); var os = require("os"); var path = require("path");
|
|
194
|
+
var home = os.homedir();
|
|
195
|
+
var r = { root: null, source: "not-found", topology: "not-found" };
|
|
196
|
+
try {
|
|
197
|
+
r = require(process.env.PLUGIN_ROOT_FOR_RESOLVE + "/lib/core/active-plugin-root.cjs").resolveActivePluginRoot();
|
|
198
|
+
} catch (_) { /* swallow */ }
|
|
199
|
+
var installedPluginsVersion = "unknown";
|
|
200
|
+
try {
|
|
201
|
+
var ip = JSON.parse(fs.readFileSync(path.join(home, ".claude/plugins/installed_plugins.json"), "utf8"));
|
|
202
|
+
var keys = Object.keys((ip && ip.plugins) || {});
|
|
203
|
+
for (var i = 0; i < keys.length; i++) {
|
|
204
|
+
var name = String(keys[i]).split("@")[0];
|
|
205
|
+
if (name !== "mos" && name !== "mindrian-os") continue;
|
|
206
|
+
var entry = ip.plugins[keys[i]];
|
|
207
|
+
if (Array.isArray(entry)) entry = entry[0];
|
|
208
|
+
if (entry && entry.version) { installedPluginsVersion = entry.version; break; }
|
|
209
|
+
}
|
|
210
|
+
} catch (_) { /* swallow */ }
|
|
211
|
+
var lastVersionFile = process.env.LAST_VERSION_FILE_FOR_RESOLVE || path.join(home, ".mindrian-last-version");
|
|
212
|
+
var lastVersionFileValue = null;
|
|
213
|
+
try { lastVersionFileValue = fs.readFileSync(lastVersionFile, "utf8").trim() || null; } catch (_) { /* absent ok */ }
|
|
214
|
+
var pathBinVersion = "unknown";
|
|
215
|
+
try {
|
|
216
|
+
var m = String(process.env.PATH || "").match(/[/\\\\](?:mos|mindrian-os)[/\\\\]([^/\\\\:]+)[/\\\\]bin(?::|;|$)/);
|
|
217
|
+
if (m) pathBinVersion = m[1];
|
|
218
|
+
} catch (_) { /* swallow */ }
|
|
219
|
+
// Plan 123-02 amendment (HARNESS-123-05 fix, surfaced 2026-05-13 by Plan-06 pre-flight
|
|
220
|
+
// class-I --pre-tag gate): prefer the resolver root basename = what Claude Code actually
|
|
221
|
+
// has installed per active-plugin-root.cjs resolution chain, NOT the dev-workspace
|
|
222
|
+
// plugin.json version (which can lead or lag the live install). The record reflects the
|
|
223
|
+
// LIVE install; class I catches drift, doctor --fix recovers. Fallbacks in order:
|
|
224
|
+
// resolver-root-basename -> installed_plugins.json entry -> dev-workspace plugin.json -> "unknown".
|
|
225
|
+
var activeVersion = (r.root && path.basename(r.root)) || installedPluginsVersion || process.env.PLUGIN_VERSION_FOR_RESOLVE || "unknown";
|
|
226
|
+
// surfaces[] -- walk the static manifest, record observed/ok per surface.
|
|
227
|
+
var surfaces = [];
|
|
228
|
+
try {
|
|
229
|
+
var man = JSON.parse(fs.readFileSync(process.env.PLUGIN_ROOT_FOR_RESOLVE + "/data/deployment-surfaces.json", "utf8"));
|
|
230
|
+
var expand = function(p) {
|
|
231
|
+
return p.replace(/\$HOME/g, home)
|
|
232
|
+
.replace(/<active_root>/g, r.root || "")
|
|
233
|
+
.replace(/<dev_clone_root>/g, r.topology === "dev-clone" ? (r.root || "") : "");
|
|
234
|
+
};
|
|
235
|
+
for (var j = 0; j < (man.surfaces || []).length; j++) {
|
|
236
|
+
var s = man.surfaces[j];
|
|
237
|
+
if (s.topology_scope === "dev-clone" && r.topology !== "dev-clone") {
|
|
238
|
+
surfaces.push({ id: s.id, path: null, check_kind: s.check_kind, expected: s.expected, observed: "skipped-non-dev-clone", ok: null });
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
if (s.id === "install-state-record") {
|
|
242
|
+
// Self -- excluded from its own check (D-08).
|
|
243
|
+
surfaces.push({ id: s.id, path: expand(s.path), check_kind: s.check_kind, expected: s.expected, observed: "self-excluded", ok: null });
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
var fp = expand(s.path);
|
|
247
|
+
var observed = null, ok = null;
|
|
248
|
+
try {
|
|
249
|
+
if (s.check_kind === "marker") {
|
|
250
|
+
var content = fs.readFileSync(fp, "utf8");
|
|
251
|
+
observed = content.indexOf(s.expected) !== -1 ? s.expected : null;
|
|
252
|
+
ok = !!observed;
|
|
253
|
+
} else if (s.check_kind === "exact-value") {
|
|
254
|
+
var c = "";
|
|
255
|
+
try { c = fs.readFileSync(fp, "utf8"); } catch (_) { /* missing -> ok=false */ }
|
|
256
|
+
var exp = (s.expected === "<active_version>") ? activeVersion : String(s.expected).replace(/\$HOME/g, home);
|
|
257
|
+
observed = c.trim();
|
|
258
|
+
ok = c.indexOf(exp) !== -1;
|
|
259
|
+
} else {
|
|
260
|
+
// observed-only
|
|
261
|
+
observed = fs.existsSync(fp) ? "present" : "absent";
|
|
262
|
+
ok = null;
|
|
263
|
+
}
|
|
264
|
+
} catch (_) {
|
|
265
|
+
observed = "absent";
|
|
266
|
+
ok = (s.check_kind === "observed-only") ? null : false;
|
|
267
|
+
}
|
|
268
|
+
surfaces.push({ id: s.id, path: fp, check_kind: s.check_kind, expected: s.expected, observed: observed, ok: ok });
|
|
269
|
+
}
|
|
270
|
+
} catch (_) { /* manifest unreadable -- surfaces stays [] */ }
|
|
271
|
+
var rec = {
|
|
272
|
+
active_version: activeVersion,
|
|
273
|
+
active_root: r.root,
|
|
274
|
+
topology: r.topology,
|
|
275
|
+
resolved_at: new Date().toISOString(),
|
|
276
|
+
surfaces: surfaces,
|
|
277
|
+
installed_plugins_version: installedPluginsVersion,
|
|
278
|
+
statusline_renders_version: "unknown",
|
|
279
|
+
last_version_file_value: lastVersionFileValue,
|
|
280
|
+
path_bin_version: pathBinVersion
|
|
281
|
+
};
|
|
282
|
+
// Phase 126 Plan 07: preserve v2 schema fields across the Phase 123 record
|
|
283
|
+
// rewrite. CONTEXT.md D3 invariant: NEVER downgrade. If the existing file
|
|
284
|
+
// has schema_version > 2 (a future-version file from a newer beta the user
|
|
285
|
+
// previously installed then rolled back from), SKIP the write entirely so
|
|
286
|
+
// the file stays untouched until `/mos:doctor --fix` runs. Otherwise,
|
|
287
|
+
// additively merge schema_version + topology_class + last_acceptance_run
|
|
288
|
+
// + renderer_contract_version from the existing file onto the freshly-
|
|
289
|
+
// derived record. The Phase 126 migrator at the top of session-start
|
|
290
|
+
// populates these fields for v1 installs before this block runs; for
|
|
291
|
+
// already-v2 installs the merge is a no-op preservation.
|
|
292
|
+
var skipWrite = false;
|
|
293
|
+
var existing = null;
|
|
294
|
+
try {
|
|
295
|
+
if (fs.existsSync(process.env.INSTALL_STATE_JSON_PATH)) {
|
|
296
|
+
existing = JSON.parse(fs.readFileSync(process.env.INSTALL_STATE_JSON_PATH, "utf8"));
|
|
297
|
+
}
|
|
298
|
+
} catch (_) { /* corrupt -- treat as if absent */ }
|
|
299
|
+
if (existing && typeof existing.schema_version === "number" && existing.schema_version > 2) {
|
|
300
|
+
// Future-version: do NOT downgrade. Leave the file alone.
|
|
301
|
+
skipWrite = true;
|
|
302
|
+
} else {
|
|
303
|
+
// Merge v2 fields onto the new record. Defaults are applied when the
|
|
304
|
+
// existing file lacks a field (covers the edge case where the migrator
|
|
305
|
+
// did not run first -- e.g., a stale install where lib/core/install-
|
|
306
|
+
// state.cjs is missing on disk).
|
|
307
|
+
rec.schema_version = 2;
|
|
308
|
+
rec.topology_class = (existing && existing.topology_class) || (function (t) {
|
|
309
|
+
switch (t) {
|
|
310
|
+
case "marketplace-cache": return "healthy";
|
|
311
|
+
case "direct": return "healthy";
|
|
312
|
+
case "dev-clone": return "healthy";
|
|
313
|
+
case "not-found": return "missing";
|
|
314
|
+
case "legacy": return "drifted";
|
|
315
|
+
default: return "drifted";
|
|
316
|
+
}
|
|
317
|
+
})(r.topology);
|
|
318
|
+
rec.last_acceptance_run = (existing && Object.prototype.hasOwnProperty.call(existing, "last_acceptance_run"))
|
|
319
|
+
? existing.last_acceptance_run : null;
|
|
320
|
+
rec.renderer_contract_version = (existing && existing.renderer_contract_version) || "unknown";
|
|
321
|
+
}
|
|
322
|
+
if (!skipWrite) {
|
|
323
|
+
try { fs.writeFileSync(process.env.INSTALL_STATE_JSON_PATH, JSON.stringify(rec, null, 2) + "\n"); } catch (_) { /* swallow */ }
|
|
324
|
+
}
|
|
325
|
+
try { fs.writeFileSync(lastVersionFile, activeVersion + "\n"); } catch (_) { /* swallow */ }
|
|
326
|
+
' 2>/dev/null || true
|
|
327
|
+
# --- END install-state record ---
|
|
328
|
+
|
|
329
|
+
# =============================================================================
|
|
330
|
+
# STABLE PREFIX (identical across sessions -- enables prompt cache hits)
|
|
331
|
+
# This section MUST NOT change between sessions. Any edits here bust the cache.
|
|
332
|
+
# =============================================================================
|
|
333
|
+
|
|
334
|
+
stable_prefix="[MindrianOS v${PLUGIN_VERSION}] You are Larry.
|
|
335
|
+
|
|
336
|
+
## Identity (STABLE)
|
|
337
|
+
MindrianOS is a commercial Claude Code + Cowork plugin delivering PWS methodology as installable skills, commands, agents, and hooks. Users get Larry (AI teaching personality) plus a structured Data Room that passively captures insights and proactively surfaces gaps, contradictions, and convergence signals.
|
|
338
|
+
|
|
339
|
+
## UI Enforcement (MANDATORY)
|
|
340
|
+
All /mos: command output MUST follow the 4-zone anatomy from skills/ui-system/SKILL.md:
|
|
341
|
+
1. Header Panel (room name, command, venture stage)
|
|
342
|
+
2. Content Body (use the body_shape declared in the command's frontmatter)
|
|
343
|
+
3. Intelligence Strip (conditional -- show if proactive findings exist)
|
|
344
|
+
4. Action Footer (NEVER omit -- always suggest 2-3 next commands)
|
|
345
|
+
|
|
346
|
+
Symbol vocabulary: use ONLY these glyphs: ■ ▼ ▶ ▷ ├─ └─ ✓ • ⚠ ⚡ ⬜ →
|
|
347
|
+
Colors: green=success, cyan=info, yellow=warning, red=critical, gray=muted
|
|
348
|
+
NO EMOJI anywhere in output. NO exceptions.
|
|
349
|
+
|
|
350
|
+
## Dashboard Export Integrity (MANDATORY)
|
|
351
|
+
When generating a dashboard, room export, or standalone HTML visualization:
|
|
352
|
+
- ALWAYS use scripts/generate-standalone or scripts/serve-dashboard
|
|
353
|
+
- NEVER generate HTML by hand -- the template at dashboard/index.html has full Cytoscape.js graph, De Stijl styling, intelligence panel, layer toggles, and chat UI
|
|
354
|
+
- Improvised HTML will always be inferior to the real template
|
|
355
|
+
|
|
356
|
+
## JTBD-context-only (Phase 114 -- precedence: initialPrompt wins)
|
|
357
|
+
The agent frontmatter declares initialPrompt, which the platform auto-submits as turn 1. Larry's response to initialPrompt IS the greeting -- do NOT render an additional greeting block on top.
|
|
358
|
+
Treat the room-state context below (venture stage, entry counts, section names, MINTO health, JTBD nudges) as awareness Larry already has. Use it to inform the response to initialPrompt -- reference specific state where natural, do not list it.
|
|
359
|
+
Nudge content (when used) remains calibrated -- preserve wording exactly. Max 2-3 nudges woven into the response, never as a bulleted list at the top.
|
|
360
|
+
NEVER describe features or slash commands abstractly. Every reference must connect to what the user HAS in their room and what they will GET from the action.
|
|
361
|
+
Command menu rendering: only show the menu after the agent's response to initialPrompt completes (i.e., the menu is the closer, not the opener).
|
|
362
|
+
On Desktop and Cowork, no SessionStart hook fires -- this block does not appear; initialPrompt + preloaded substrate carry the entire turn.
|
|
363
|
+
Per Canon Part 10 sub-claim 1, conversation IS the surface; commands are internals -- this rule operationalizes that at the activation layer."
|
|
364
|
+
|
|
365
|
+
# =============================================================================
|
|
366
|
+
# DYNAMIC SUFFIX (changes per session -- room state, proactive signals, nudges)
|
|
367
|
+
# =============================================================================
|
|
368
|
+
|
|
369
|
+
context=""
|
|
370
|
+
|
|
371
|
+
if [ -d "$ROOM_DIR" ]; then
|
|
372
|
+
# Fire-and-forget room hierarchy graph sync (Phase 59.2, D-16: never blocks)
|
|
373
|
+
ROOMS_HOME="${MINDRIAN_ROOMS_HOME:-$HOME/MindrianRooms}"
|
|
374
|
+
node "${SCRIPT_DIR}/sync-rooms-graph" "$ROOMS_HOME" >/dev/null 2>&1 &
|
|
375
|
+
node "${SCRIPT_DIR}/sync-rooms-brain" "$ROOMS_HOME" >/dev/null 2>&1 &
|
|
376
|
+
|
|
377
|
+
# =============================================================================
|
|
378
|
+
# CONTEXT INTELLIGENCE: Archetype detection + tiered loading (CTX-01, CTX-02, CTX-05)
|
|
379
|
+
# =============================================================================
|
|
380
|
+
|
|
381
|
+
# Detect user archetype and session count
|
|
382
|
+
ARCHETYPE_JSON=$(node "${PLUGIN_ROOT}/lib/core/user-archetype.cjs" "$ROOM_DIR" 2>/dev/null || echo '{"archetype":"default","confidence":"low","signals":[],"sessionCount":0,"domain":null}')
|
|
383
|
+
USER_ARCHETYPE=$(echo "$ARCHETYPE_JSON" | node -e "process.stdin.on('data',d=>{try{console.log(JSON.parse(d).archetype)}catch(_){console.log('default')}})" 2>/dev/null || echo "default")
|
|
384
|
+
SESSION_COUNT=$(echo "$ARCHETYPE_JSON" | node -e "process.stdin.on('data',d=>{try{console.log(JSON.parse(d).sessionCount||0)}catch(_){console.log(0)}})" 2>/dev/null || echo "0")
|
|
385
|
+
ROOM_DOMAIN=$(echo "$ARCHETYPE_JSON" | node -e "process.stdin.on('data',d=>{try{const j=JSON.parse(d);console.log(j.domain||'')}catch(_){console.log('')}})" 2>/dev/null || echo "")
|
|
386
|
+
|
|
387
|
+
# Get MCP session profile recommendation
|
|
388
|
+
MCP_PROFILE_JSON=$(node "${PLUGIN_ROOT}/lib/core/mcp-profiles.cjs" get "$USER_ARCHETYPE" 2>/dev/null || echo '{"profile":"think","servers":["mindrian"],"maxTools":15}')
|
|
389
|
+
MCP_PROFILE=$(echo "$MCP_PROFILE_JSON" | node -e "process.stdin.on('data',d=>{try{console.log(JSON.parse(d).profile)}catch(_){console.log('think')}})" 2>/dev/null || echo "think")
|
|
390
|
+
|
|
391
|
+
# Read context bridge file for budget-aware tiering
|
|
392
|
+
CTX_PCT_RAW=""
|
|
393
|
+
BRIDGE_FILE="/tmp/mindrian-context-state"
|
|
394
|
+
if [ -f "$BRIDGE_FILE" ]; then
|
|
395
|
+
BRIDGE_AGE=$(( $(date +%s) - $(portable_stat_mtime "$BRIDGE_FILE") ))
|
|
396
|
+
if [ "$BRIDGE_AGE" -lt 300 ]; then
|
|
397
|
+
CTX_PCT_RAW=$(node -e "try{const d=require('fs').readFileSync('$BRIDGE_FILE','utf8');console.log(JSON.parse(d).ctx_pct||0)}catch(_){console.log(0)}" 2>/dev/null || echo "0")
|
|
398
|
+
fi
|
|
399
|
+
fi
|
|
400
|
+
CTX_PCT_INT="${CTX_PCT_RAW%.*}"
|
|
401
|
+
CTX_PCT_INT="${CTX_PCT_INT:-0}"
|
|
402
|
+
|
|
403
|
+
# Determine context tier based on budget and archetype (CTX-02)
|
|
404
|
+
# Tiers: minimal (~500 tokens) / balanced (~2K tokens) / rich (~5K tokens)
|
|
405
|
+
CONTEXT_TIER="balanced"
|
|
406
|
+
if [ "$CTX_PCT_INT" -ge 70 ]; then
|
|
407
|
+
CONTEXT_TIER="minimal"
|
|
408
|
+
elif [ "$CTX_PCT_INT" -lt 30 ] || [ "$USER_ARCHETYPE" = "venturist" ]; then
|
|
409
|
+
CONTEXT_TIER="rich"
|
|
410
|
+
fi
|
|
411
|
+
# Students default to minimal unless budget is wide open
|
|
412
|
+
if [ "$USER_ARCHETYPE" = "student" ] && [ "$CTX_PCT_INT" -ge 30 ]; then
|
|
413
|
+
CONTEXT_TIER="minimal"
|
|
414
|
+
fi
|
|
415
|
+
|
|
416
|
+
# Room exists -- compute state and build context
|
|
417
|
+
state_output=$("${SCRIPT_DIR}/compute-state" "$ROOM_DIR" 2>/dev/null || echo "Could not compute room state. Your room exists but state analysis failed. Try /mos:status to diagnose.")
|
|
418
|
+
|
|
419
|
+
# Read USER.md if exists
|
|
420
|
+
user_context=""
|
|
421
|
+
if [ -f "${ROOM_DIR}/USER.md" ]; then
|
|
422
|
+
user_context=$(cat "${ROOM_DIR}/USER.md" 2>/dev/null || true)
|
|
423
|
+
fi
|
|
424
|
+
|
|
425
|
+
# Read existing STATE.md if exists (last persisted state)
|
|
426
|
+
state_md=""
|
|
427
|
+
if [ -f "${ROOM_DIR}/STATE.md" ]; then
|
|
428
|
+
state_md=$(cat "${ROOM_DIR}/STATE.md" 2>/dev/null || true)
|
|
429
|
+
fi
|
|
430
|
+
|
|
431
|
+
# =============================================================================
|
|
432
|
+
# RETURNING USER GREETING (CTX-05)
|
|
433
|
+
# Session count > 3 triggers domain-specific greeting instead of full intro
|
|
434
|
+
# =============================================================================
|
|
435
|
+
RETURNING_USER_HINT=""
|
|
436
|
+
if [ "$SESSION_COUNT" -gt 3 ] && [ -n "$ROOM_DOMAIN" ]; then
|
|
437
|
+
RETURNING_USER_HINT="[Returning User] This is session #${SESSION_COUNT}. Skip the full introduction. Greet with domain awareness: \"I see you're continuing work on ${ROOM_DOMAIN}.\" Then go straight to actionable nudges."
|
|
438
|
+
fi
|
|
439
|
+
|
|
440
|
+
# =============================================================================
|
|
441
|
+
# OPPORTUNITY BANK SUMMARY (ONBD-04)
|
|
442
|
+
# Surface banked opportunities in returning user greeting
|
|
443
|
+
# =============================================================================
|
|
444
|
+
OPP_BANK_SUMMARY=""
|
|
445
|
+
OPP_BANK_DIR="${ROOM_DIR}/opportunity-bank"
|
|
446
|
+
if [ -d "$OPP_BANK_DIR" ]; then
|
|
447
|
+
OPP_BANK_JSON=$(node -e "
|
|
448
|
+
const ops = require('${PLUGIN_ROOT_FOR_NODE}/lib/core/opportunity-ops.cjs');
|
|
449
|
+
const result = ops.listOpportunities('${ROOM_DIR}');
|
|
450
|
+
const opps = result.opportunities || [];
|
|
451
|
+
if (opps.length === 0) { console.log(''); process.exit(0); }
|
|
452
|
+
const sorted = opps.sort((a,b) => (b.frontmatter.confidence||0) - (a.frontmatter.confidence||0));
|
|
453
|
+
const top = sorted[0];
|
|
454
|
+
console.log(JSON.stringify({
|
|
455
|
+
count: opps.length,
|
|
456
|
+
top_problem: (top.frontmatter.problem || '').substring(0, 100),
|
|
457
|
+
top_confidence: top.frontmatter.confidence || 0,
|
|
458
|
+
uncertainty_count: opps.filter(o => o.frontmatter.knight_position === 'uncertainty').length,
|
|
459
|
+
risk_count: opps.filter(o => o.frontmatter.knight_position === 'risk').length
|
|
460
|
+
}));
|
|
461
|
+
" 2>/dev/null || echo "")
|
|
462
|
+
|
|
463
|
+
if [ -n "$OPP_BANK_JSON" ]; then
|
|
464
|
+
OPP_COUNT=$(echo "$OPP_BANK_JSON" | node -e "process.stdin.on('data',d=>{try{console.log(JSON.parse(d).count||0)}catch(_){console.log(0)}})" 2>/dev/null || echo "0")
|
|
465
|
+
if [ "$OPP_COUNT" -gt 0 ] 2>/dev/null; then
|
|
466
|
+
OPP_TOP=$(echo "$OPP_BANK_JSON" | node -e "process.stdin.on('data',d=>{try{console.log(JSON.parse(d).top_problem||'')}catch(_){console.log('')}})" 2>/dev/null || echo "")
|
|
467
|
+
OPP_CONF=$(echo "$OPP_BANK_JSON" | node -e "process.stdin.on('data',d=>{try{console.log(JSON.parse(d).top_confidence||0)}catch(_){console.log(0)}})" 2>/dev/null || echo "0")
|
|
468
|
+
OPP_UNC=$(echo "$OPP_BANK_JSON" | node -e "process.stdin.on('data',d=>{try{console.log(JSON.parse(d).uncertainty_count||0)}catch(_){console.log(0)}})" 2>/dev/null || echo "0")
|
|
469
|
+
OPP_RISK=$(echo "$OPP_BANK_JSON" | node -e "process.stdin.on('data',d=>{try{console.log(JSON.parse(d).risk_count||0)}catch(_){console.log(0)}})" 2>/dev/null || echo "0")
|
|
470
|
+
OPP_BANK_SUMMARY="[Opportunity Bank] ${OPP_COUNT} banked opportunities (${OPP_RISK} risk, ${OPP_UNC} uncertainty). Strongest: \"${OPP_TOP}\" (confidence: ${OPP_CONF}). Reference in greeting: mention the count and strongest opportunity. Suggest /mos:opportunities to review the bank."
|
|
471
|
+
fi
|
|
472
|
+
fi
|
|
473
|
+
fi
|
|
474
|
+
|
|
475
|
+
# =============================================================================
|
|
476
|
+
# TIERED CONTEXT LOADING (CTX-02)
|
|
477
|
+
# minimal: state summary only (~500 tokens)
|
|
478
|
+
# balanced: state + user + brief proactive (~2K tokens)
|
|
479
|
+
# rich: state + user + full proactive + learnings (~5K tokens)
|
|
480
|
+
# =============================================================================
|
|
481
|
+
|
|
482
|
+
if [ "$CONTEXT_TIER" = "minimal" ]; then
|
|
483
|
+
# ~500 tokens: just state summary, no proactive analysis
|
|
484
|
+
context="\n\n--- DYNAMIC SESSION CONTEXT ---\n\n[Context Tier: minimal | Archetype: ${USER_ARCHETYPE} | MCP Profile: ${MCP_PROFILE}]\n\n[Room State]\n${state_output}"
|
|
485
|
+
if [ -n "$RETURNING_USER_HINT" ]; then
|
|
486
|
+
context="${context}\n\n${RETURNING_USER_HINT}"
|
|
487
|
+
fi
|
|
488
|
+
if [ -n "$OPP_BANK_SUMMARY" ]; then
|
|
489
|
+
context="${context}\n\n${OPP_BANK_SUMMARY}"
|
|
490
|
+
fi
|
|
491
|
+
elif [ "$CONTEXT_TIER" = "rich" ]; then
|
|
492
|
+
# ~5K tokens: full context with proactive analysis, learnings, and detailed nudges
|
|
493
|
+
proactive_output=$("${SCRIPT_DIR}/analyze-room" "$ROOM_DIR" 2>/dev/null || echo "")
|
|
494
|
+
context="\n\n--- DYNAMIC SESSION CONTEXT ---\n\n[Context Tier: rich | Archetype: ${USER_ARCHETYPE} | MCP Profile: ${MCP_PROFILE}]\n\n[Room State]\n${state_output}"
|
|
495
|
+
if [ -n "$RETURNING_USER_HINT" ]; then
|
|
496
|
+
context="${context}\n\n${RETURNING_USER_HINT}"
|
|
497
|
+
fi
|
|
498
|
+
if [ -n "$OPP_BANK_SUMMARY" ]; then
|
|
499
|
+
context="${context}\n\n${OPP_BANK_SUMMARY}"
|
|
500
|
+
fi
|
|
501
|
+
if [ -n "$user_context" ]; then
|
|
502
|
+
context="${context}\n\nUser context:\n${user_context}"
|
|
503
|
+
fi
|
|
504
|
+
if [ -n "$proactive_output" ] && [ "$proactive_output" != "NO_ROOM" ]; then
|
|
505
|
+
context="${context}\n\n## Proactive Room Intelligence\n${proactive_output}"
|
|
506
|
+
fi
|
|
507
|
+
else
|
|
508
|
+
# balanced (~2K tokens): state + user + brief proactive
|
|
509
|
+
proactive_output=$("${SCRIPT_DIR}/analyze-room" "$ROOM_DIR" 2>/dev/null || echo "")
|
|
510
|
+
context="\n\n--- DYNAMIC SESSION CONTEXT ---\n\n[Context Tier: balanced | Archetype: ${USER_ARCHETYPE} | MCP Profile: ${MCP_PROFILE}]\n\n[Room State]\n${state_output}"
|
|
511
|
+
if [ -n "$RETURNING_USER_HINT" ]; then
|
|
512
|
+
context="${context}\n\n${RETURNING_USER_HINT}"
|
|
513
|
+
fi
|
|
514
|
+
if [ -n "$OPP_BANK_SUMMARY" ]; then
|
|
515
|
+
context="${context}\n\n${OPP_BANK_SUMMARY}"
|
|
516
|
+
fi
|
|
517
|
+
if [ -n "$user_context" ]; then
|
|
518
|
+
context="${context}\n\nUser context:\n${user_context}"
|
|
519
|
+
fi
|
|
520
|
+
if [ -n "$proactive_output" ] && [ "$proactive_output" != "NO_ROOM" ]; then
|
|
521
|
+
# Truncate proactive output for balanced tier (first 30 lines max)
|
|
522
|
+
proactive_brief=$(echo "$proactive_output" | head -30)
|
|
523
|
+
context="${context}\n\n## Proactive Room Intelligence (summary)\n${proactive_brief}"
|
|
524
|
+
fi
|
|
525
|
+
fi
|
|
526
|
+
|
|
527
|
+
# Read context bridge file for budget display (reuses BRIDGE_FILE read from tiering)
|
|
528
|
+
CTX_BUDGET=""
|
|
529
|
+
if [ -f "$BRIDGE_FILE" ]; then
|
|
530
|
+
BRIDGE_AGE_DISP=$(( $(date +%s) - $(portable_stat_mtime "$BRIDGE_FILE") ))
|
|
531
|
+
if [ "$BRIDGE_AGE_DISP" -lt 300 ]; then
|
|
532
|
+
CTX_MODEL=$(node -e "try{const d=require('fs').readFileSync('$BRIDGE_FILE','utf8');console.log(JSON.parse(d).model_name||'unknown')}catch(_){console.log('unknown')}" 2>/dev/null || echo "unknown")
|
|
533
|
+
CTX_PCT=$(node -e "try{const d=require('fs').readFileSync('$BRIDGE_FILE','utf8');console.log(JSON.parse(d).ctx_pct||0)}catch(_){console.log(0)}" 2>/dev/null || echo "0")
|
|
534
|
+
CTX_SIZE=$(node -e "try{const d=require('fs').readFileSync('$BRIDGE_FILE','utf8');console.log(JSON.parse(d).ctx_size||200000)}catch(_){console.log(200000)}" 2>/dev/null || echo "200000")
|
|
535
|
+
if [ -n "$CTX_PCT" ]; then
|
|
536
|
+
CTX_BUDGET="[Context Budget] Model: ${CTX_MODEL:-unknown}, Usage: ${CTX_PCT}%, Window: ${CTX_SIZE:-200000} tokens, Tier: ${CONTEXT_TIER}"
|
|
537
|
+
# Add warning if above threshold
|
|
538
|
+
CTX_INT="${CTX_PCT%.*}"
|
|
539
|
+
if [ "${CTX_INT:-0}" -ge 85 ]; then
|
|
540
|
+
CTX_BUDGET="${CTX_BUDGET} -- CRITICAL: Consider suggesting /clear"
|
|
541
|
+
elif [ "${CTX_INT:-0}" -ge 70 ]; then
|
|
542
|
+
CTX_BUDGET="${CTX_BUDGET} -- WARNING: Context getting tight"
|
|
543
|
+
fi
|
|
544
|
+
fi
|
|
545
|
+
fi
|
|
546
|
+
fi
|
|
547
|
+
|
|
548
|
+
if [ -n "$CTX_BUDGET" ]; then
|
|
549
|
+
context="${context}\n\n${CTX_BUDGET}"
|
|
550
|
+
fi
|
|
551
|
+
|
|
552
|
+
# Detect integrations
|
|
553
|
+
INTEG_OUTPUT=$(node "${PLUGIN_ROOT}/bin/mindrian-tools.cjs" detect-integrations 2>/dev/null || echo "{}")
|
|
554
|
+
INTEG_COUNT=$(echo "$INTEG_OUTPUT" | node -e "let s='';process.stdin.on('data',c=>s+=c);process.stdin.on('end',()=>{try{const d=JSON.parse(s);console.log(Object.values(d).filter(v=>v&&v.status==='connected').length)}catch(_){console.log(0)}})" 2>/dev/null || echo "0")
|
|
555
|
+
|
|
556
|
+
if [ "$INTEG_COUNT" -gt 0 ]; then
|
|
557
|
+
context="${context}\n\nIntegrations: ${INTEG_COUNT} connected"
|
|
558
|
+
fi
|
|
559
|
+
|
|
560
|
+
# Track session analytics
|
|
561
|
+
bash "${SCRIPT_DIR}/track-analytics" session-start 2>/dev/null &
|
|
562
|
+
|
|
563
|
+
# Generate learnings from usage patterns
|
|
564
|
+
bash "${SCRIPT_DIR}/learn-from-usage" 2>/dev/null
|
|
565
|
+
|
|
566
|
+
# Load learnings if available (skip on minimal tier to save tokens)
|
|
567
|
+
if [ "$CONTEXT_TIER" != "minimal" ] && [ -f "${ROOM_DIR}/.learnings.md" ]; then
|
|
568
|
+
learnings=$(cat "${ROOM_DIR}/.learnings.md" 2>/dev/null || true)
|
|
569
|
+
if [ -n "$learnings" ]; then
|
|
570
|
+
context="${context}\n\n## Usage Learnings (adapt your behavior accordingly)\n${learnings}"
|
|
571
|
+
fi
|
|
572
|
+
fi
|
|
573
|
+
|
|
574
|
+
# Student learning progress injection (CTX-06 - read)
|
|
575
|
+
if [ "$USER_ARCHETYPE" = "student" ] && [ -f "${ROOM_DIR}/.context/learning-progress.md" ]; then
|
|
576
|
+
progress_summary=$(head -10 "${ROOM_DIR}/.context/learning-progress.md" 2>/dev/null || true)
|
|
577
|
+
if [ -n "$progress_summary" ]; then
|
|
578
|
+
context="${context}\n\n## Learning Progress\n${progress_summary}"
|
|
579
|
+
fi
|
|
580
|
+
fi
|
|
581
|
+
|
|
582
|
+
# Multi-room context (ROOM-05)
|
|
583
|
+
REGISTRY="${WORK_DIR}/.rooms/registry.json"
|
|
584
|
+
if [ -f "$REGISTRY" ]; then
|
|
585
|
+
room_count=$(node -e "try{const r=require('$REGISTRY');console.log(Object.keys(r.rooms||{}).length)}catch(_){console.log(0)}" 2>/dev/null || echo "0")
|
|
586
|
+
|
|
587
|
+
if [ "$room_count" -gt 1 ]; then
|
|
588
|
+
other_rooms=$(node -e "
|
|
589
|
+
try {
|
|
590
|
+
const r = require('$REGISTRY');
|
|
591
|
+
const active = r.active || '';
|
|
592
|
+
const rooms = r.rooms || {};
|
|
593
|
+
const lines = [];
|
|
594
|
+
for (const name of Object.keys(rooms)) {
|
|
595
|
+
if (name === active) continue;
|
|
596
|
+
const room = rooms[name] || {};
|
|
597
|
+
const status = room.status || 'parked';
|
|
598
|
+
const sym = status === 'parked' ? String.fromCharCode(9654) : String.fromCharCode(9655);
|
|
599
|
+
const display = room.venture_name || name;
|
|
600
|
+
lines.push(' ' + sym + ' ' + display.padEnd(25).slice(0, 25) + ' ' + status);
|
|
601
|
+
}
|
|
602
|
+
if (lines.length) console.log(lines.slice(0, 5).join('\n'));
|
|
603
|
+
if (lines.length > 5) console.log(' ...and ' + (lines.length - 5) + ' more (/mos:rooms list)');
|
|
604
|
+
} catch (_) {}
|
|
605
|
+
" 2>/dev/null || echo "")
|
|
606
|
+
|
|
607
|
+
if [ -n "$other_rooms" ]; then
|
|
608
|
+
context="${context}\n\n Other rooms detected -- fire the AskUserQuestion card (the room-chooser) offering these as options; never render this as a prose list (SEED-021):\n${other_rooms}\n\n ▷ /mos:rooms Manage your rooms (non-option footer, not part of the card)"
|
|
609
|
+
fi
|
|
610
|
+
fi
|
|
611
|
+
fi
|
|
612
|
+
|
|
613
|
+
# Generate JTBD nudges + dynamic command menu
|
|
614
|
+
jtbd_output=$("${SCRIPT_DIR}/build-jtbd-nudges" "$ROOM_DIR" "$PLUGIN_ROOT" 2>/dev/null || echo "")
|
|
615
|
+
|
|
616
|
+
# Add nudges to dynamic context
|
|
617
|
+
context="${context}\n\n## Your Nudges for This Session\n${jtbd_output}"
|
|
618
|
+
|
|
619
|
+
# Combine: stable prefix + dynamic suffix
|
|
620
|
+
context="${stable_prefix}${context}\n\nThe user has an active Data Room."
|
|
621
|
+
else
|
|
622
|
+
# Cold start: show De Stijl Mondrian banner on EVERY cold start (no room detected).
|
|
623
|
+
# Banner path resolved via platform.cjs.resolveHookScript (plan 85-06).
|
|
624
|
+
if [ -n "$LAST_VERSION" ] && [ "$LAST_VERSION" != "$PLUGIN_VERSION" ]; then
|
|
625
|
+
# Plugin was updated -- show version transition banner
|
|
626
|
+
bash "${BANNER_SCRIPT}" "$PLUGIN_VERSION" "$LAST_VERSION" >&2 2>/dev/null || true
|
|
627
|
+
else
|
|
628
|
+
# Standard cold start or first install -- show current version banner
|
|
629
|
+
bash "${BANNER_SCRIPT}" "$PLUGIN_VERSION" >&2 2>/dev/null || true
|
|
630
|
+
fi
|
|
631
|
+
|
|
632
|
+
# Determine onboarding type from LAST_VERSION markers (kept separate from banner)
|
|
633
|
+
if [ -z "$LAST_VERSION" ]; then
|
|
634
|
+
# First-ever cold start -- no marker file exists
|
|
635
|
+
:
|
|
636
|
+
elif [ "$LAST_VERSION" != "$PLUGIN_VERSION" ]; then
|
|
637
|
+
# Plugin was updated
|
|
638
|
+
:
|
|
639
|
+
fi
|
|
640
|
+
# Phase 123 Plan-02 (HARNESS-123-05): the line-419 cold-start-only
|
|
641
|
+
# ~/.mindrian-last-version write was REMOVED. The single writer is now the
|
|
642
|
+
# EARLY install-state record block at ~L107-220 (right after LAST_VERSION_FILE
|
|
643
|
+
# is read), which rewrites ~/.mindrian-last-version unconditionally per D-03
|
|
644
|
+
# + RESEARCH Override 4. Pitfall 7 fix.
|
|
645
|
+
|
|
646
|
+
# Check onboarding status (per ONBOARD-01)
|
|
647
|
+
ONBOARD_STATUS=$("${SCRIPT_DIR}/check-onboard" 2>/dev/null || echo "CURRENT")
|
|
648
|
+
ONBOARD_TYPE=$(echo "$ONBOARD_STATUS" | head -1)
|
|
649
|
+
|
|
650
|
+
# Command count computed LIVE (was a hardcoded "45" literal that drifted
|
|
651
|
+
# stale across every command-count-adding phase -- confirmed 2026-07-05 via
|
|
652
|
+
# a real Windows cross-check: disk had 107 clean commands/*.md, the banner
|
|
653
|
+
# still advertised 45, and doc archaeology showed the same literal frozen at
|
|
654
|
+
# 71/66/72/83 at various earlier points. Never recompute by hand again.
|
|
655
|
+
LIVE_COMMAND_COUNT=$(ls -1 "${PLUGIN_ROOT}/commands/"*.md 2>/dev/null | wc -l | tr -d ' ')
|
|
656
|
+
if [ -z "$LIVE_COMMAND_COUNT" ] || [ "$LIVE_COMMAND_COUNT" = "0" ]; then LIVE_COMMAND_COUNT="all"; fi
|
|
657
|
+
# FIRST-REWARD DECLARATION (Phase 267.3, ruling D-A). This branch is declared
|
|
658
|
+
# in data/first-reward-surfaces.json as id `session-start:COLD_START_MENU`,
|
|
659
|
+
# interactive_first_reward `--none (diagnostic surface)`. A bash hook has no
|
|
660
|
+
# frontmatter block, so the declaration lives in that registry instead and is
|
|
661
|
+
# validated by `node scripts/check-reward-before-investment.cjs --surfaces .`,
|
|
662
|
+
# wired fail-closed as gate 10d of scripts/verify-release. Change the prose
|
|
663
|
+
# below and you must revisit the record: the registry's `anchor` field points
|
|
664
|
+
# at a literal inside this assignment, and tests/test-267.3-session-start-
|
|
665
|
+
# declaration.cjs reds the moment that literal stops existing.
|
|
666
|
+
COLD_START_MENU="---\nGet started:\n /mos:new-project .... Start a new venture project\n /mos:help ........... See what Larry can help with\n /mos:diagnose ....... Classify your problem type\n\nOr just talk -- Larry is a thinking partner first.\nType /mos: to see ${LIVE_COMMAND_COUNT} commands.\n /mos:update ......... Check for latest features\n---"
|
|
667
|
+
|
|
668
|
+
# FIRST_INSTALL_HANDOFF (Phase 267.2 W1, HOOK-09): the FIRST_INSTALL
|
|
669
|
+
# branch's own trailing block, replacing that branch's use of
|
|
670
|
+
# ${COLD_START_MENU} (decision D-F: the COLD_START_MENU variable itself
|
|
671
|
+
# stays byte-identical and is still interpolated by the UPDATE and
|
|
672
|
+
# MODE_ROUTING branches below). Names the one open question as the next
|
|
673
|
+
# move and hands the rest of the turn to scripts/first-install-router.cjs,
|
|
674
|
+
# which classifies the user's free-text answer locally and routes it.
|
|
675
|
+
FIRST_INSTALL_HANDOFF="---\nThat one question is the whole ask. scripts/first-install-router.cjs is already listening on this turn -- it classifies your answer locally and routes what happens next, no menu required.\n---"
|
|
676
|
+
|
|
677
|
+
# Enable auto-update by default for new installs
|
|
678
|
+
if [ "$ONBOARD_TYPE" = "FIRST_INSTALL" ]; then
|
|
679
|
+
mkdir -p "$HOME/.mindrian" 2>/dev/null
|
|
680
|
+
touch "$HOME/.mindrian/auto-update" 2>/dev/null
|
|
681
|
+
fi
|
|
682
|
+
|
|
683
|
+
# FIRST-REWARD DECLARATION (Phase 267.3, ruling D-A; rewritten Phase 267.2
|
|
684
|
+
# W1, HOOK-09). Declared in data/first-reward-surfaces.json as id
|
|
685
|
+
# `session-start:FIRST_INSTALL`, interactive_first_reward `instant_brief`.
|
|
686
|
+
# This branch no longer promises a reward in prose: it hands first contact
|
|
687
|
+
# to scripts/first-install-router.cjs, which classifies the user's one-
|
|
688
|
+
# sentence free-text answer locally and, on the venture-shaped path, fires
|
|
689
|
+
# the room-free Instant Brief pipeline (lib/core/mva-orchestrator.cjs) out
|
|
690
|
+
# of band, draining the rendered result as additionalContext one turn
|
|
691
|
+
# later (closing GAP R-1, .planning/research/2026-08-27-hooked-first-
|
|
692
|
+
# install-audit.md). The registry record was updated in this same change.
|
|
693
|
+
# Change the prose below and you must revisit the record: the registry's
|
|
694
|
+
# `anchor` field points at a literal inside this assignment, and
|
|
695
|
+
# tests/test-267.3-session-start-declaration.cjs reds the moment that
|
|
696
|
+
# literal stops existing.
|
|
697
|
+
if [ "$ONBOARD_TYPE" = "FIRST_INSTALL" ]; then
|
|
698
|
+
context="${stable_prefix}\n\n--- DYNAMIC SESSION CONTEXT ---\n\n[MindrianOS Onboarding] First install detected.\n\nThis is the user's very first session with MindrianOS. Welcome them warmly using one of your signature openers (\"Very simply...\", \"Here's the thing...\", \"One thing I've learned...\"). Be conversational and direct. No emoji. No filler phrases like \"I'd be happy to help\" or \"Great question!\". Your turn wears exactly one De Stijl glyph, per Canon Part 12.\n\nAsk ONE open question, in your own voice, about what they are working on or what brought them here today, and accept a free-text answer. Do NOT render a command menu, an options card, or a numbered list on this turn: scripts/first-install-router.cjs classifies that free-text answer and injects the routing instruction itself, so nothing here needs to be chosen or offered by the model.\n\nAfter the user answers, present capabilities as natural actions (not slash commands):\n- You can tell Larry about a meeting you had and he will file and analyze it\n- You can ask Larry to diagnose what type of problem you are working on\n- You can ask Larry to grade your venture honestly\n- You can ask Larry to find relevant grants and opportunities\n- You can ask Larry to get 6 different perspectives on your work\n- You can ask Larry to query your knowledge graph\n- You can start a new project and Larry will set up your Data Room\n\nAfter the onboarding conversation completes or the user skips, run: bash \"${PLUGIN_ROOT}/scripts/check-onboard\" --write\n\n${FIRST_INSTALL_HANDOFF}"
|
|
699
|
+
|
|
700
|
+
# FIRST-REWARD DECLARATION (Phase 267.3, ruling D-A). Declared in
|
|
701
|
+
# data/first-reward-surfaces.json as id `session-start:UPDATE`,
|
|
702
|
+
# interactive_first_reward `--none (diagnostic surface)`. The what-is-new
|
|
703
|
+
# digest below is real machinery reading CHANGELOG.md, but its output is fully
|
|
704
|
+
# predictable given the version pair, which is the "a state report is not a
|
|
705
|
+
# reward" case docs/reward-before-investment-rule.md:59-60 already names. This
|
|
706
|
+
# opt-out is honest, not a deferred gap; nothing is queued against it.
|
|
707
|
+
elif [ "$ONBOARD_TYPE" = "UPDATE" ]; then
|
|
708
|
+
PREV_VER=$(echo "$ONBOARD_STATUS" | grep "^PREVIOUS=" | cut -d= -f2)
|
|
709
|
+
CHANGELOG_DIFF=$(sed -n "/^## \[${PLUGIN_VERSION}\]/,/^## \[${PREV_VER}\]/p" "$PLUGIN_ROOT/CHANGELOG.md" 2>/dev/null | head -n -1 | grep "^- " || echo "")
|
|
710
|
+
ONBOARD_STEPS=$(sed -n "/^## \[${PLUGIN_VERSION}\]/,/^## \[/{ /^ - \"/p; }" "$PLUGIN_ROOT/CHANGELOG.md" 2>/dev/null | sed 's/^ - "//;s/"$//' || echo "")
|
|
711
|
+
|
|
712
|
+
WHATS_NEW=""
|
|
713
|
+
if [ -n "$ONBOARD_STEPS" ]; then
|
|
714
|
+
WHATS_NEW="$ONBOARD_STEPS"
|
|
715
|
+
elif [ -n "$CHANGELOG_DIFF" ]; then
|
|
716
|
+
WHATS_NEW="$CHANGELOG_DIFF"
|
|
717
|
+
fi
|
|
718
|
+
|
|
719
|
+
context="${stable_prefix}\n\n--- DYNAMIC SESSION CONTEXT ---\n\n[Update] v${PREV_VER} -> v${PLUGIN_VERSION}.\n\nWelcome back. The user has updated from v${PREV_VER} to v${PLUGIN_VERSION}. Greet them warmly using a signature opener. No emoji. No filler.\n\nSince they last checked in, here is what you learned to do:\n${WHATS_NEW}\n\nCRITICAL: Frame EVERY new capability using the JTBD formula:\n\"When [situation the user faces], you want to [progress they are trying to make], so you can [outcome]. Now you can: /mos:command\"\n\nDo NOT list features technically. Instead, for each new capability:\n1. Name a REAL struggling moment the user has (based on what venture builders actually face)\n2. Show how this capability REMOVES that struggle\n3. End with the specific command and time estimate\n\nExample for model routing: \"When you are running deep methodology sessions and burning through tokens, you want to control cost without sacrificing teaching quality. Now you can: /mos:models set balanced -- Opus for teaching, Haiku for scanning, 66% less cost.\"\n\nExample for parallel agents: \"When you have 3 weak Sections and only 30 minutes before a meeting, you want to fill all the gaps at once. Now you can: /mos:act --swarm -- 3 frameworks in parallel, 5 minutes instead of 45.\"\n\nAfter showing what is new with JTBD framing, offer the full tour: \"Want to see everything? /mos:onboard -- 7 steps, 3 minutes.\"\n\nThen run: bash \"${PLUGIN_ROOT}/scripts/check-onboard\" --write\n\nThen show the command menu below.\n\n${COLD_START_MENU}"
|
|
720
|
+
|
|
721
|
+
else
|
|
722
|
+
# CURRENT -- returning no-room user with mode routing
|
|
723
|
+
|
|
724
|
+
# Read scratchpad for cross-session continuity (CONV-06)
|
|
725
|
+
SCRATCHPAD_SUMMARY=""
|
|
726
|
+
SCRATCHPAD_JSON=$(node -e "const sp = require('${PLUGIN_ROOT_FOR_NODE}/lib/core/scratchpad-ops.cjs'); console.log(JSON.stringify(sp.readScratchpad()))" 2>/dev/null || echo "")
|
|
727
|
+
if [ -n "$SCRATCHPAD_JSON" ]; then
|
|
728
|
+
SP_OPP_COUNT=$(echo "$SCRATCHPAD_JSON" | node -e "process.stdin.on('data',d=>{try{console.log(JSON.parse(d).opportunities.length||0)}catch(_){console.log(0)}})" 2>/dev/null || echo "0")
|
|
729
|
+
SP_PERSONA=$(echo "$SCRATCHPAD_JSON" | node -e "process.stdin.on('data',d=>{try{console.log(JSON.parse(d).persona||'')}catch(_){console.log('')}})" 2>/dev/null || echo "")
|
|
730
|
+
SP_LAST=$(echo "$SCRATCHPAD_JSON" | node -e "process.stdin.on('data',d=>{try{console.log(JSON.parse(d).last_updated||'')}catch(_){console.log('')}})" 2>/dev/null || echo "")
|
|
731
|
+
if [ "$SP_OPP_COUNT" -gt 0 ] 2>/dev/null; then
|
|
732
|
+
SCRATCHPAD_SUMMARY="[Scratchpad] ${SP_OPP_COUNT} banked opportunities from previous sessions."
|
|
733
|
+
if [ -n "$SP_PERSONA" ]; then
|
|
734
|
+
SCRATCHPAD_SUMMARY="${SCRATCHPAD_SUMMARY} Detected persona: ${SP_PERSONA}."
|
|
735
|
+
fi
|
|
736
|
+
if [ -n "$SP_LAST" ]; then
|
|
737
|
+
SCRATCHPAD_SUMMARY="${SCRATCHPAD_SUMMARY} Last active: ${SP_LAST}."
|
|
738
|
+
fi
|
|
739
|
+
SCRATCHPAD_SUMMARY="${SCRATCHPAD_SUMMARY} Reference these in your greeting: 'Last time we captured ${SP_OPP_COUNT} opportunities. Want to continue exploring, or are you ready to build a room?'"
|
|
740
|
+
fi
|
|
741
|
+
fi
|
|
742
|
+
|
|
743
|
+
# MODE_ROUTING: Three entry modes for no-room sessions
|
|
744
|
+
#
|
|
745
|
+
# FIRST-REWARD DECLARATION (Phase 267.3, ruling D-A). Declared in
|
|
746
|
+
# data/first-reward-surfaces.json as id `session-start:MODE_ROUTING`,
|
|
747
|
+
# interactive_first_reward `--none (diagnostic surface)`. This branch asks
|
|
748
|
+
# the user to pick an entry mode before handing anything back, which is
|
|
749
|
+
# investment before reward, the exact ordering the rule exists to prevent.
|
|
750
|
+
# No reward member of the closed vocabulary would be a true statement about
|
|
751
|
+
# it, so it declares the opt-out. Fixing the ordering is Phase 267.2's
|
|
752
|
+
# onboarding-flow work, not a declaration change.
|
|
753
|
+
MODE_MENU="Fire the AskUserQuestion card with these three modes as the options; never render this menu as text (SEED-021).\n\n [1] Just Talk\n \"Help me think through something -- no strings attached\"\n Larry explores with you. Nothing saved. Pure thinking partner.\n\n [2] Explore + Capture\n \"Help me explore -- and catch the structure as it emerges\"\n Larry talks AND detects patterns, personas, opportunities.\n When you are ready, everything seeds a Data Room.\n\n [3] Build a Room\n \"I know what I am building -- let me set up the room first\"\n Jump straight to /mos:new-project and start working.\n\nDefault to Just Talk if the navigator starts talking instead of picking."
|
|
754
|
+
|
|
755
|
+
context="${stable_prefix}\n\n--- DYNAMIC SESSION CONTEXT ---\n\n[MindrianOS Mode Routing] No room detected. Fire the AskUserQuestion card with the three modes below as options; default to Just Talk if the navigator starts talking instead of picking; never render this menu as text (SEED-021).\n\n${MODE_MENU}"
|
|
756
|
+
|
|
757
|
+
# Inject scratchpad context if present (CONV-06)
|
|
758
|
+
if [ -n "$SCRATCHPAD_SUMMARY" ]; then
|
|
759
|
+
context="${context}\n\n${SCRATCHPAD_SUMMARY}"
|
|
760
|
+
fi
|
|
761
|
+
|
|
762
|
+
context="${context}\n\n## Mode Behavior Instructions\n\nAfter the user selects a mode (or defaults to Mode 1 by just talking):\n\n**Mode 1 (Just Talk):** You are a thinking partner. No methodology routing, no filing, no room creation suggestions unless the user explicitly asks. Use the Ask-Tell Dial naturally. Do NOT suggest /mos:new-project unprompted.\n\n**Mode 2 (Explore+Capture):** You are a thinking partner who ALSO detects persona (TTO/Researcher/Business) within the first 2-3 exchanges. Once persona is detected, follow the corresponding Brain framework chain (see conversation-mode skill). Actively look for well-defined problems and mirror solutions to bank as opportunities. Tell the user when you spot one.\n\n**Mode 3 (Build a Room):** Immediately route to /mos:new-project. Say: Let us set up your Data Room. Tell me about what you are building. Then follow the new-project flow.\n\n**Default:** If the user just starts talking without selecting a mode number, treat as Mode 1. If they mention technologies, patents, research, or business opportunities within the first 2 exchanges, suggest upgrading to Mode 2: Sounds like there is real structure here. Want me to start capturing it? (That is Mode 2.)\n\nAFTER showing the mode menu, show the command menu:\n\n${COLD_START_MENU}"
|
|
763
|
+
fi
|
|
764
|
+
fi
|
|
765
|
+
|
|
766
|
+
# ---------------------------------------------------------------------------
|
|
767
|
+
# ACTIVE ROOM CONTEXT injection (Phase 83-02, SCOPE-INJ-01/03)
|
|
768
|
+
#
|
|
769
|
+
# Reads ~/MindrianRooms/.rooms/registry.json "active" field, resolves the
|
|
770
|
+
# room path and project name from its STATE.md, and appends a locked
|
|
771
|
+
# ACTIVE ROOM CONTEXT + CROSS-ROOM POLICY block to $context. Graceful
|
|
772
|
+
# no-registry / no-active fallback: block is omitted silently, no error.
|
|
773
|
+
# See .planning/phases/83-cross-session-scope-injection/83-02-PLAN.md
|
|
774
|
+
# ---------------------------------------------------------------------------
|
|
775
|
+
inject_active_room_context() {
|
|
776
|
+
# Resolve MindrianRooms root (3-way fallback).
|
|
777
|
+
local rooms_root=""
|
|
778
|
+
if [ -n "${MINDRIAN_ROOMS_ROOT:-}" ]; then
|
|
779
|
+
rooms_root="${MINDRIAN_ROOMS_ROOT}"
|
|
780
|
+
elif [ -d "${HOME}/MindrianRooms" ]; then
|
|
781
|
+
rooms_root="${HOME}/MindrianRooms"
|
|
782
|
+
else
|
|
783
|
+
local found
|
|
784
|
+
found=$(find "${HOME}" -maxdepth 2 -type d -name MindrianRooms 2>/dev/null | head -1 || true)
|
|
785
|
+
if [ -n "$found" ]; then
|
|
786
|
+
rooms_root="$found"
|
|
787
|
+
fi
|
|
788
|
+
fi
|
|
789
|
+
|
|
790
|
+
if [ -z "$rooms_root" ]; then
|
|
791
|
+
echo "[scope-injection] no MindrianRooms root resolved, skipping" >&2
|
|
792
|
+
return 0
|
|
793
|
+
fi
|
|
794
|
+
|
|
795
|
+
local registry="${rooms_root}/.rooms/registry.json"
|
|
796
|
+
if [ ! -f "$registry" ]; then
|
|
797
|
+
echo "[scope-injection] no registry at ${registry}, skipping" >&2
|
|
798
|
+
return 0
|
|
799
|
+
fi
|
|
800
|
+
|
|
801
|
+
# Extract active field via node (python3 is a Microsoft Store alias
|
|
802
|
+
# stub on Windows; node is a hard plugin dependency so it works
|
|
803
|
+
# everywhere). Ported from inline python3 in plan 85-01.
|
|
804
|
+
local active
|
|
805
|
+
active=$(node -e "try{const d=require(process.argv[1]);const a=(d.active||'').toString();process.stdout.write(a.trim())}catch(_){}" "$registry" 2>/dev/null || echo "")
|
|
806
|
+
|
|
807
|
+
if [ -z "$active" ]; then
|
|
808
|
+
echo "[scope-injection] registry active field empty, skipping" >&2
|
|
809
|
+
return 0
|
|
810
|
+
fi
|
|
811
|
+
|
|
812
|
+
local active_path="${rooms_root}/${active}"
|
|
813
|
+
if [ ! -d "$active_path" ]; then
|
|
814
|
+
echo "[scope-injection] active room directory missing: ${active_path}, skipping" >&2
|
|
815
|
+
return 0
|
|
816
|
+
fi
|
|
817
|
+
|
|
818
|
+
# Parse project name from STATE.md frontmatter (bounded read, prompt-injection safe).
|
|
819
|
+
local project="unspecified"
|
|
820
|
+
local state_md="${active_path}/STATE.md"
|
|
821
|
+
if [ -f "$state_md" ]; then
|
|
822
|
+
local raw
|
|
823
|
+
raw=$(head -n 30 "$state_md" 2>/dev/null | grep -m1 '^project:' | sed 's/^project:[[:space:]]*//' || true)
|
|
824
|
+
# Strip backticks, newlines, and trim whitespace. Cap at 120 chars.
|
|
825
|
+
raw=$(printf '%s' "$raw" | tr -d '`' | tr -d '\r\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | cut -c1-120)
|
|
826
|
+
if [ -n "$raw" ]; then
|
|
827
|
+
project="$raw"
|
|
828
|
+
fi
|
|
829
|
+
fi
|
|
830
|
+
|
|
831
|
+
# Section focus from statusline tracking file if present.
|
|
832
|
+
local section_focus="no current section"
|
|
833
|
+
local tracking="${HOME}/.mindrian/statusline-section"
|
|
834
|
+
if [ -f "$tracking" ]; then
|
|
835
|
+
local sraw
|
|
836
|
+
sraw=$(head -n 1 "$tracking" 2>/dev/null | tr -d '\r\n' | cut -c1-120 || true)
|
|
837
|
+
if [ -n "$sraw" ]; then
|
|
838
|
+
section_focus="$sraw"
|
|
839
|
+
fi
|
|
840
|
+
fi
|
|
841
|
+
|
|
842
|
+
# Build and append the locked block. Format is mandated by
|
|
843
|
+
# 83-02-PLAN.md section 5 and 83-CONTEXT.md REVISION 2.
|
|
844
|
+
local block
|
|
845
|
+
block="\n\n## ACTIVE ROOM CONTEXT\n\nYou are scoped to the room: ${active}\nPath: ${active_path}\nProject: ${project}\nSection focus: ${section_focus}\n\n## CROSS-ROOM POLICY\n\nWhen the user mentions a room name or topic that maps to a different\nroom than the active one, you must:\n1. Acknowledge the mismatch out loud and name both rooms\n2. Ask whether to switch the active room or continue in the current scope\n3. Refuse to draft artifacts that belong to a different room without\n explicit user confirmation of intent\n4. Never file content derived from another room into the active room"
|
|
846
|
+
|
|
847
|
+
context="${context}${block}"
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
inject_active_room_context || true
|
|
851
|
+
|
|
852
|
+
# ---------------------------------------------------------------------------
|
|
853
|
+
# Phase 88.1-06: SessionStart MINTO banner (navigator re-entry affordance)
|
|
854
|
+
#
|
|
855
|
+
# Emits a compact 4-line banner AFTER the Phase 83 ACTIVE ROOM CONTEXT
|
|
856
|
+
# block and BEFORE the Phase 88-07 TRIPLE_CONTEXT block. Format:
|
|
857
|
+
#
|
|
858
|
+
# MindrianOS v${version}
|
|
859
|
+
# Room: ${room_slug}
|
|
860
|
+
# Focus (top 3 recently-active sections):
|
|
861
|
+
# ${glyph1} ${section1}: "${gt1_truncated}"
|
|
862
|
+
# ${glyph2} ${section2}: "${gt2_truncated}"
|
|
863
|
+
# ${glyph3} ${section3}: "${gt3_truncated}"
|
|
864
|
+
#
|
|
865
|
+
# Ordering contract: identity (ACTIVE ROOM) -> focus snapshot (this
|
|
866
|
+
# banner) -> full per-section memory (TRIPLE_CONTEXT). The banner is
|
|
867
|
+
# the re-entry affordance per Canon Part 1; TRIPLE_CONTEXT below is
|
|
868
|
+
# the full LOCAL context per Canon Part 3.
|
|
869
|
+
#
|
|
870
|
+
# Budget policy: banner reserves ~200 tokens when all 3 rows render.
|
|
871
|
+
# Under tight SESSION_START_BUDGET_TOKENS the formatter drops rows in
|
|
872
|
+
# reverse order (3rd -> 2nd -> 1st), then drops the focus-header
|
|
873
|
+
# entirely, leaving brand + room visible. TRIPLE_CONTEXT below honors
|
|
874
|
+
# its own 5000-token default budget independently.
|
|
875
|
+
#
|
|
876
|
+
# Soft-fail contract: `env node -e ... 2>/dev/null || echo ""` means
|
|
877
|
+
# any internal failure (malformed triple, missing module, stat error)
|
|
878
|
+
# emits nothing and session-start continues. Banner errors NEVER block
|
|
879
|
+
# startup.
|
|
880
|
+
#
|
|
881
|
+
# Part 8 boundary: triples are read via lib/core/folder-memory.cjs
|
|
882
|
+
# readTriple (the canonical Phase 88-01 contract). Version is read from
|
|
883
|
+
# .claude-plugin/plugin.json (LOCAL). Zero Brain / fetch / external
|
|
884
|
+
# calls in the payload.
|
|
885
|
+
#
|
|
886
|
+
# Plan 88.1-04 cache reuse: the formatter's classifyHealth +
|
|
887
|
+
# truncateGoverningThought come from lib/core/statusline-cache.cjs so
|
|
888
|
+
# the banner glyph is byte-identical with statusline + /mos:status.
|
|
889
|
+
# ---------------------------------------------------------------------------
|
|
890
|
+
if [ -n "${ROOM_DIR}" ] && [ -d "${ROOM_DIR}" ]; then
|
|
891
|
+
BANNER_MINTO=$(env ROOM_DIR_ENV="${ROOM_DIR}" PLUGIN_ROOT_ENV="${PLUGIN_ROOT}" node -e '
|
|
892
|
+
"use strict";
|
|
893
|
+
const fs = require("fs");
|
|
894
|
+
const path = require("path");
|
|
895
|
+
const roomDir = process.env.ROOM_DIR_ENV;
|
|
896
|
+
const pluginRoot = process.env.PLUGIN_ROOT_ENV;
|
|
897
|
+
try {
|
|
898
|
+
const fmt = require(path.join(pluginRoot, "lib", "memory", "sessionstart-banner-formatter.cjs"));
|
|
899
|
+
const fm = require(path.join(pluginRoot, "lib", "core", "folder-memory.cjs"));
|
|
900
|
+
// Plan 88.1-04 cache reuse: warm statusline-cache for the top-3
|
|
901
|
+
// sections so the next statusline tick hits the cache. Cache module
|
|
902
|
+
// is optional; banner still renders without it.
|
|
903
|
+
let cache = null;
|
|
904
|
+
try {
|
|
905
|
+
cache = require(path.join(pluginRoot, "lib", "core", "statusline-cache.cjs"));
|
|
906
|
+
} catch (_e) { cache = null; }
|
|
907
|
+
|
|
908
|
+
// Derive room slug from the room directory basename. Callers can
|
|
909
|
+
// override via MINDRIAN_ROOM_SLUG but default is reliable.
|
|
910
|
+
const roomSlug = process.env.MINDRIAN_ROOM_SLUG || path.basename(roomDir);
|
|
911
|
+
|
|
912
|
+
// Enumerate subdirs with ROOM.md; compute effective activity mtime
|
|
913
|
+
// per section as max(section_root_mtime, MINTO.md mtime, max
|
|
914
|
+
// artifact .md mtime). Caller owns fs reads so the formatter stays
|
|
915
|
+
// pure (Part 8).
|
|
916
|
+
let entries = [];
|
|
917
|
+
try {
|
|
918
|
+
entries = fs.readdirSync(roomDir, { withFileTypes: true })
|
|
919
|
+
.filter((d) => d.isDirectory() && d.name[0] !== ".");
|
|
920
|
+
} catch (_e) { entries = []; }
|
|
921
|
+
|
|
922
|
+
const triples = {};
|
|
923
|
+
for (const d of entries) {
|
|
924
|
+
const sp = path.join(roomDir, d.name);
|
|
925
|
+
try {
|
|
926
|
+
if (!fs.existsSync(path.join(sp, "ROOM.md"))) continue;
|
|
927
|
+
// Warm-cache lookup first; fall through to readTriple on miss.
|
|
928
|
+
let t = null;
|
|
929
|
+
if (cache && typeof cache.getCached === "function") {
|
|
930
|
+
const hit = cache.getCached(roomDir, sp);
|
|
931
|
+
if (hit && hit.fresh && hit.value) t = hit.value;
|
|
932
|
+
}
|
|
933
|
+
if (!t) {
|
|
934
|
+
t = fm.readTriple(sp);
|
|
935
|
+
if (cache && typeof cache.setCached === "function") {
|
|
936
|
+
try { cache.setCached(roomDir, sp, t); } catch (_e) {}
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
// Compute effective activity mtime.
|
|
941
|
+
let mtime = 0;
|
|
942
|
+
try {
|
|
943
|
+
const sstat = fs.statSync(sp);
|
|
944
|
+
if (sstat && sstat.mtimeMs) mtime = Math.max(mtime, sstat.mtimeMs);
|
|
945
|
+
} catch (_e) {}
|
|
946
|
+
try {
|
|
947
|
+
const mpath = path.join(sp, "MINTO.md");
|
|
948
|
+
if (fs.existsSync(mpath)) {
|
|
949
|
+
const mst = fs.statSync(mpath);
|
|
950
|
+
if (mst && mst.mtimeMs) mtime = Math.max(mtime, mst.mtimeMs);
|
|
951
|
+
}
|
|
952
|
+
} catch (_e) {}
|
|
953
|
+
try {
|
|
954
|
+
const items = fs.readdirSync(sp);
|
|
955
|
+
for (const n of items) {
|
|
956
|
+
if (n[0] === ".") continue;
|
|
957
|
+
if (!n.endsWith(".md")) continue;
|
|
958
|
+
if (n === "ROOM.md" || n === "STATE.md" || n === "MINTO.md" || n === "TEAM-STATE.md") continue;
|
|
959
|
+
const fst = fs.statSync(path.join(sp, n));
|
|
960
|
+
if (fst && fst.mtimeMs) mtime = Math.max(mtime, fst.mtimeMs);
|
|
961
|
+
}
|
|
962
|
+
} catch (_e) {}
|
|
963
|
+
|
|
964
|
+
// Attach the effective mtime onto the reasoning payload for
|
|
965
|
+
// the formatter top-3 selector. Non-destructive decoration.
|
|
966
|
+
if (t && t.reasoning && typeof t.reasoning === "object") {
|
|
967
|
+
t.reasoning._mtime = mtime;
|
|
968
|
+
}
|
|
969
|
+
triples[d.name] = t;
|
|
970
|
+
} catch (_e) { /* skip this section */ }
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
// Resolve version dynamically (never hardcoded; release-safe).
|
|
974
|
+
const version = fmt.readPluginVersion(pluginRoot);
|
|
975
|
+
|
|
976
|
+
// Budget: reserve ~200 tokens for the banner. Under very tight
|
|
977
|
+
// total budget the formatter drops rows to fit.
|
|
978
|
+
let budget = fmt.BANNER_RESERVE_TOKENS || 200;
|
|
979
|
+
const envBudget = parseInt(process.env.SESSION_START_BUDGET_TOKENS || "", 10);
|
|
980
|
+
if (Number.isFinite(envBudget) && envBudget > 0 && envBudget < 1000) {
|
|
981
|
+
// Under very tight total budget (< 1000), proportionally shrink
|
|
982
|
+
// the banner share so TRIPLE_CONTEXT still has room downstream.
|
|
983
|
+
budget = Math.max(50, Math.floor(envBudget * 0.2));
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
const out = fmt.formatBanner({
|
|
987
|
+
roomRoot: roomDir,
|
|
988
|
+
roomSlug: roomSlug,
|
|
989
|
+
triples: triples,
|
|
990
|
+
version: version,
|
|
991
|
+
budget: budget,
|
|
992
|
+
});
|
|
993
|
+
process.stdout.write(out || "");
|
|
994
|
+
} catch (_e) { /* soft-fail: emit nothing */ }
|
|
995
|
+
' 2>/dev/null || echo "")
|
|
996
|
+
if [ -n "${BANNER_MINTO}" ]; then
|
|
997
|
+
context="${context}
|
|
998
|
+
|
|
999
|
+
${BANNER_MINTO}"
|
|
1000
|
+
fi
|
|
1001
|
+
fi
|
|
1002
|
+
# --- end Phase 88.1-06 banner ---
|
|
1003
|
+
|
|
1004
|
+
# ---------------------------------------------------------------------------
|
|
1005
|
+
# Phase 88-07: TRIPLE_CONTEXT injection (per-section memory triple)
|
|
1006
|
+
#
|
|
1007
|
+
# Wakes Larry up per-section with what references belong, what state the
|
|
1008
|
+
# section is in, what the governing thought is, what arguments support it,
|
|
1009
|
+
# and what decisions the user has already made. Consumes 88-06's
|
|
1010
|
+
# .mindrian/session-snapshot.json when present; falls back to live
|
|
1011
|
+
# folder-memory.readTriple walk when the snapshot is missing (e.g. first
|
|
1012
|
+
# session after install, or the room was modified outside a previous Stop).
|
|
1013
|
+
#
|
|
1014
|
+
# Ordering contract: this block MUST appear AFTER the Phase 83 ACTIVE ROOM
|
|
1015
|
+
# CONTEXT block (which anchors the room identity) and BEFORE the SEALED
|
|
1016
|
+
# ROOMS walker (which scopes cross-room policy). Test 7 asserts the
|
|
1017
|
+
# ACTIVE ROOM CONTEXT -> TRIPLE_CONTEXT sequence.
|
|
1018
|
+
#
|
|
1019
|
+
# Budget: the formatter enforces DEFAULT_BUDGET_TOKENS = 5000 (grounded in
|
|
1020
|
+
# a measured baseline ~3825-token session-start emission; see
|
|
1021
|
+
# .planning/phases/88-feynman-minto-memory-layer/88-07-SUMMARY.md). Users
|
|
1022
|
+
# override via SESSION_START_BUDGET_TOKENS env var; the env propagates into
|
|
1023
|
+
# the node -e subshell automatically (process.env inheritance).
|
|
1024
|
+
#
|
|
1025
|
+
# Soft-fail contract: the || echo "" + 2>/dev/null on the outer node
|
|
1026
|
+
# invocation means any failure inside the Node payload (malformed JSON,
|
|
1027
|
+
# readTriple throw, formatter crash) emits nothing and the hook exits 0.
|
|
1028
|
+
# See lib/memory/session-start-triple-injection.test.cjs Test 8.
|
|
1029
|
+
#
|
|
1030
|
+
# No direct MINTO.md reads: goes through lib/core/folder-memory.cjs per
|
|
1031
|
+
# the 88-01 read contract (Phase 88 decision: readTriple is the ONLY
|
|
1032
|
+
# supported way to read the triple).
|
|
1033
|
+
# ---------------------------------------------------------------------------
|
|
1034
|
+
if [ -n "${ROOM_DIR}" ] && [ -d "${ROOM_DIR}" ] && [ -d "${ROOM_DIR}/.mindrian" ]; then
|
|
1035
|
+
# env-prefix inside a command substitution does NOT propagate; we use `env`
|
|
1036
|
+
# to set ROOM_DIR_ENV + PLUGIN_ROOT_ENV for the node -e subshell only.
|
|
1037
|
+
# SESSION_START_BUDGET_TOKENS is inherited automatically via the outer
|
|
1038
|
+
# process env (no explicit forwarding needed).
|
|
1039
|
+
#
|
|
1040
|
+
# Phase 90-03: this block now ALSO computes Brain staleness per section
|
|
1041
|
+
# via lib/core/brain-md-staleness.cjs and enqueues regen for stale
|
|
1042
|
+
# sections through lib/core/brain-derivation-queue.cjs. The scan is
|
|
1043
|
+
# LOCAL-only per Canon Part 8 (no content queries to Brain). Feature
|
|
1044
|
+
# flag: BRAIN_STALENESS_SKIP=1 disables the Brain annotation and enqueue
|
|
1045
|
+
# paths, restoring pre-90-03 behavior byte-for-byte (emergency disable).
|
|
1046
|
+
TRIPLE_CONTEXT=$(env ROOM_DIR_ENV="${ROOM_DIR}" PLUGIN_ROOT_ENV="${PLUGIN_ROOT}" node -e '
|
|
1047
|
+
"use strict";
|
|
1048
|
+
const fs = require("fs");
|
|
1049
|
+
const path = require("path");
|
|
1050
|
+
const roomDir = process.env.ROOM_DIR_ENV;
|
|
1051
|
+
const pluginRoot = process.env.PLUGIN_ROOT_ENV;
|
|
1052
|
+
try {
|
|
1053
|
+
const fm = require(path.join(pluginRoot, "lib", "core", "folder-memory.cjs"));
|
|
1054
|
+
const fmt = require(path.join(pluginRoot, "lib", "memory", "triple-context-formatter.cjs"));
|
|
1055
|
+
// Phase 90-03 integration modules (loaded lazily; soft-fail if unavailable).
|
|
1056
|
+
let brainStale = null;
|
|
1057
|
+
let brainQueue = null;
|
|
1058
|
+
if (process.env.BRAIN_STALENESS_SKIP !== "1") {
|
|
1059
|
+
try { brainStale = require(path.join(pluginRoot, "lib", "core", "brain-md-staleness.cjs")); }
|
|
1060
|
+
catch (_e) { brainStale = null; }
|
|
1061
|
+
try { brainQueue = require(path.join(pluginRoot, "lib", "core", "brain-derivation-queue.cjs")); }
|
|
1062
|
+
catch (_e) { brainQueue = null; }
|
|
1063
|
+
}
|
|
1064
|
+
// 1. Try snapshot-first (88-06 producer contract). Falls through to
|
|
1065
|
+
// live readTriple walk if snapshot is missing or malformed.
|
|
1066
|
+
let sections = {};
|
|
1067
|
+
try {
|
|
1068
|
+
const snapPath = path.join(roomDir, ".mindrian", "session-snapshot.json");
|
|
1069
|
+
if (fs.existsSync(snapPath)) {
|
|
1070
|
+
const raw = fs.readFileSync(snapPath, "utf8");
|
|
1071
|
+
const parsed = JSON.parse(raw);
|
|
1072
|
+
if (parsed && parsed.sections && typeof parsed.sections === "object") {
|
|
1073
|
+
sections = parsed.sections;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
} catch (_e) { /* malformed snapshot -> fallback below */ }
|
|
1077
|
+
// 2. Fallback: walk sections via folder-memory.readTriple. Triggered
|
|
1078
|
+
// when snapshot is absent, unparseable, or empty.
|
|
1079
|
+
if (!sections || Object.keys(sections).length === 0) {
|
|
1080
|
+
let entries = [];
|
|
1081
|
+
try {
|
|
1082
|
+
entries = fs.readdirSync(roomDir, { withFileTypes: true })
|
|
1083
|
+
.filter((d) => d.isDirectory() && d.name[0] !== ".");
|
|
1084
|
+
} catch (_e) { entries = []; }
|
|
1085
|
+
sections = {};
|
|
1086
|
+
for (const d of entries) {
|
|
1087
|
+
const sp = path.join(roomDir, d.name);
|
|
1088
|
+
try {
|
|
1089
|
+
if (!fs.existsSync(path.join(sp, "ROOM.md"))) continue;
|
|
1090
|
+
sections[d.name] = fm.readTriple(sp);
|
|
1091
|
+
} catch (_e) { /* skip this section */ }
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
// 3. Read optional pending-tier1-regen.json (88-05 producer).
|
|
1095
|
+
let pendingTier1 = null;
|
|
1096
|
+
try {
|
|
1097
|
+
const ptp = path.join(roomDir, ".mindrian", "pending-tier1-regen.json");
|
|
1098
|
+
if (fs.existsSync(ptp)) {
|
|
1099
|
+
const pj = JSON.parse(fs.readFileSync(ptp, "utf8"));
|
|
1100
|
+
pendingTier1 = Array.isArray(pj) ? pj : (pj && pj.pending) || [];
|
|
1101
|
+
}
|
|
1102
|
+
} catch (_e) { pendingTier1 = null; }
|
|
1103
|
+
// 4. Read optional minto-stale.json (88-06 producer).
|
|
1104
|
+
let staleReport = null;
|
|
1105
|
+
try {
|
|
1106
|
+
const msp = path.join(roomDir, ".mindrian", "minto-stale.json");
|
|
1107
|
+
if (fs.existsSync(msp)) {
|
|
1108
|
+
const sj = JSON.parse(fs.readFileSync(msp, "utf8"));
|
|
1109
|
+
staleReport = Array.isArray(sj) ? sj : (sj && sj.sections) || [];
|
|
1110
|
+
}
|
|
1111
|
+
} catch (_e) { staleReport = null; }
|
|
1112
|
+
// 5. Phase 90-03: compute Brain staleness per section, attach to
|
|
1113
|
+
// sections[name].brain, and enqueue regen for sections whose
|
|
1114
|
+
// recommended_action === "enqueue_regen". Enqueue is fired-and-forget:
|
|
1115
|
+
// the drain runs on next UserPromptSubmit (Phase 90-02). Brain-offline
|
|
1116
|
+
// suppresses enqueue. Room-wide suppression: if NO section has a
|
|
1117
|
+
// BRAIN.md on disk, we do not render any Brain line (backward-compat
|
|
1118
|
+
// for users who have never run a derivation yet).
|
|
1119
|
+
//
|
|
1120
|
+
// brain-md-staleness is an async module, so we run an async IIFE.
|
|
1121
|
+
// When skipped (BRAIN_STALENESS_SKIP=1 or module unavailable), we
|
|
1122
|
+
// still need to format + emit the TRIPLE_CONTEXT block synchronously
|
|
1123
|
+
// (no Brain annotations attached).
|
|
1124
|
+
(async function () {
|
|
1125
|
+
if (brainStale) {
|
|
1126
|
+
const enqueueJobs = [];
|
|
1127
|
+
let anyBrainMdSeen = false;
|
|
1128
|
+
for (const name of Object.keys(sections)) {
|
|
1129
|
+
const sp = path.join(roomDir, name);
|
|
1130
|
+
let brainRes = null;
|
|
1131
|
+
try {
|
|
1132
|
+
// readTriple is the source of truth for governing_thought.
|
|
1133
|
+
// Snapshot path may have a pre-fetched triple; refresh via
|
|
1134
|
+
// readTriple for the most-current hash.
|
|
1135
|
+
const triple = fm.readTriple(sp);
|
|
1136
|
+
brainRes = await brainStale.computeBrainStaleness(sp, triple);
|
|
1137
|
+
if (brainRes && brainRes.exists === true) anyBrainMdSeen = true;
|
|
1138
|
+
} catch (_e) { brainRes = null; }
|
|
1139
|
+
if (brainRes) {
|
|
1140
|
+
sections[name] = sections[name] || {};
|
|
1141
|
+
sections[name].brain = brainRes;
|
|
1142
|
+
if (brainRes.recommended_action === "enqueue_regen" && brainQueue) {
|
|
1143
|
+
enqueueJobs.push({ section: name, sectionPath: sp, brainRes: brainRes });
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
// Backward-compat: suppress "absent" lines when no section has
|
|
1148
|
+
// ever been derived. Rooms with zero BRAIN.md would otherwise
|
|
1149
|
+
// see noisy "Brain derivation: absent" annotations everywhere.
|
|
1150
|
+
if (!anyBrainMdSeen) {
|
|
1151
|
+
for (const name of Object.keys(sections)) {
|
|
1152
|
+
if (sections[name] && sections[name].brain && sections[name].brain.staleness === "absent") {
|
|
1153
|
+
delete sections[name].brain;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
// Fire-and-forget enqueues (advisory; do not block).
|
|
1158
|
+
for (const job of enqueueJobs) {
|
|
1159
|
+
try {
|
|
1160
|
+
const triple = fm.readTriple(job.sectionPath);
|
|
1161
|
+
const currentGt = (triple && triple.reasoning && triple.reasoning.governing_thought != null)
|
|
1162
|
+
? String(triple.reasoning.governing_thought) : "";
|
|
1163
|
+
const cryp = require("crypto");
|
|
1164
|
+
const newHash = "sha256:" + cryp.createHash("sha256").update(currentGt.normalize("NFC")).digest("hex");
|
|
1165
|
+
const prevHash = job.brainRes.stale_reason === "governing_thought_changed"
|
|
1166
|
+
? null
|
|
1167
|
+
: newHash;
|
|
1168
|
+
brainQueue.enqueue(roomDir, job.section, prevHash, newHash, "session_start_stale");
|
|
1169
|
+
} catch (_e) { /* advisory; do not block session-start */ }
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
// 6. Format and emit (always runs, even when Brain staleness skipped).
|
|
1173
|
+
const block = fmt.formatTripleContext({
|
|
1174
|
+
sections: sections,
|
|
1175
|
+
pendingTier1: pendingTier1,
|
|
1176
|
+
staleReport: staleReport,
|
|
1177
|
+
});
|
|
1178
|
+
process.stdout.write(block || "");
|
|
1179
|
+
})().catch(function (_e) { /* soft-fail: emit nothing */ });
|
|
1180
|
+
} catch (_e) { /* soft-fail: emit nothing */ }
|
|
1181
|
+
' 2>/dev/null || echo "")
|
|
1182
|
+
if [ -n "${TRIPLE_CONTEXT}" ]; then
|
|
1183
|
+
context="${context}
|
|
1184
|
+
|
|
1185
|
+
${TRIPLE_CONTEXT}"
|
|
1186
|
+
fi
|
|
1187
|
+
fi
|
|
1188
|
+
# --- end Phase 88-07 / Phase 90-03 ---
|
|
1189
|
+
|
|
1190
|
+
# ---------------------------------------------------------------------------
|
|
1191
|
+
# Phase 88-13: Feynman-MINTO guardian, session-start health check.
|
|
1192
|
+
#
|
|
1193
|
+
# Walks active sections, runs every registered validator, enqueues regen
|
|
1194
|
+
# intents via the debouncer for any critical violation, and cleans orphan
|
|
1195
|
+
# tmp files left behind by 88-04-B mid-write crashes. BACKGROUNDED with
|
|
1196
|
+
# soft-fail so the guardian can NEVER block session-start under its 10s
|
|
1197
|
+
# budget. Guardian is advisory at runtime; only pre-commit mode exits 2.
|
|
1198
|
+
# See .planning/phases/88-feynman-minto-memory-layer/88-13-SUMMARY.md
|
|
1199
|
+
# ---------------------------------------------------------------------------
|
|
1200
|
+
if [ -n "${ROOM_DIR}" ] && [ -d "${ROOM_DIR}" ]; then
|
|
1201
|
+
( node "${PLUGIN_ROOT}/scripts/feynman-minto-guardian.cjs" session-start "${ROOM_DIR}" >/dev/null 2>&1 || true ) &
|
|
1202
|
+
( node "${PLUGIN_ROOT}/scripts/feynman-minto-guardian.cjs" clean-tmp "${ROOM_DIR}" >/dev/null 2>&1 || true ) &
|
|
1203
|
+
fi
|
|
1204
|
+
# --- end Phase 88-13 guardian session-start ---
|
|
1205
|
+
|
|
1206
|
+
# ---------------------------------------------------------------------------
|
|
1207
|
+
# SEALED ROOMS walker (Phase 83-03, SCOPE-INJ-02/06)
|
|
1208
|
+
#
|
|
1209
|
+
# Walks the MindrianRooms root at top level for any subdirectory containing
|
|
1210
|
+
# a GUARDRAIL.md file, parses the first 3 prose lines (after stripping
|
|
1211
|
+
# frontmatter, h1 title, code fences), and appends a locked SEALED ROOMS
|
|
1212
|
+
# block to $context. Treats GUARDRAIL.md content as untrusted user data:
|
|
1213
|
+
# strip backticks, newlines, fences; join 3 lines with " | " separator.
|
|
1214
|
+
# Alphabetical order, cap at 10 rooms with "and N more" suffix. Hard 500ms
|
|
1215
|
+
# budget via background subshell + wait loop; partial results on timeout.
|
|
1216
|
+
# Graceful empty fallback: block omitted entirely, no error.
|
|
1217
|
+
# See .planning/phases/83-cross-session-scope-injection/83-03-PLAN.md
|
|
1218
|
+
# ---------------------------------------------------------------------------
|
|
1219
|
+
walk_sealed_rooms() {
|
|
1220
|
+
# Resolve MindrianRooms root (same 3-way fallback as 83-02).
|
|
1221
|
+
local rooms_root=""
|
|
1222
|
+
if [ -n "${MINDRIAN_ROOMS_ROOT:-}" ]; then
|
|
1223
|
+
rooms_root="${MINDRIAN_ROOMS_ROOT}"
|
|
1224
|
+
elif [ -d "${HOME}/MindrianRooms" ]; then
|
|
1225
|
+
rooms_root="${HOME}/MindrianRooms"
|
|
1226
|
+
else
|
|
1227
|
+
local found
|
|
1228
|
+
found=$(find "${HOME}" -maxdepth 2 -type d -name MindrianRooms 2>/dev/null | head -1 || true)
|
|
1229
|
+
if [ -n "$found" ]; then
|
|
1230
|
+
rooms_root="$found"
|
|
1231
|
+
fi
|
|
1232
|
+
fi
|
|
1233
|
+
|
|
1234
|
+
if [ -z "$rooms_root" ] || [ ! -d "$rooms_root" ]; then
|
|
1235
|
+
echo "[sealed-walker] no MindrianRooms root resolved, skipping" >&2
|
|
1236
|
+
return 0
|
|
1237
|
+
fi
|
|
1238
|
+
|
|
1239
|
+
# Run the walk + parse in a background subshell, write result to tempfile,
|
|
1240
|
+
# enforce a 500ms hard cap via a wait loop. Partial results are acceptable.
|
|
1241
|
+
local tmp
|
|
1242
|
+
tmp=$(mktemp 2>/dev/null || echo "/tmp/mos-sealed-$$")
|
|
1243
|
+
: > "$tmp"
|
|
1244
|
+
|
|
1245
|
+
# Gate the GUARDRAIL parser on python3 availability. On Windows without
|
|
1246
|
+
# real python3 (e.g. Microsoft Store alias stub), the sealed-room walker
|
|
1247
|
+
# is a no-op and the session-start hook continues without sealed-room
|
|
1248
|
+
# context. Plan 85-06 will replace this with a node-native walker.
|
|
1249
|
+
if ! command -v python3 >/dev/null 2>&1; then
|
|
1250
|
+
echo "[skip] python3 feature gated: sealed-room GUARDRAIL walker" >&2
|
|
1251
|
+
return 0
|
|
1252
|
+
fi
|
|
1253
|
+
|
|
1254
|
+
(
|
|
1255
|
+
# List top-level GUARDRAIL.md files, maxdepth 2 (root/<room>/GUARDRAIL.md).
|
|
1256
|
+
# Do NOT follow symlinks (no -L) to avoid loops. Parser body lives in
|
|
1257
|
+
# scripts/sealed-walker.py (extracted in plan 85-01 so session-start
|
|
1258
|
+
# stays free of inline python invocations).
|
|
1259
|
+
find "$rooms_root" -maxdepth 2 -mindepth 2 -type f -name GUARDRAIL.md -print0 2>/dev/null \
|
|
1260
|
+
| python3 "${SCRIPT_DIR}/sealed-walker.py" > "$tmp" 2>/dev/null
|
|
1261
|
+
) &
|
|
1262
|
+
local walker_pid=$!
|
|
1263
|
+
|
|
1264
|
+
# 500ms wait loop (10 x 50ms). Kill if still running.
|
|
1265
|
+
local waited=0
|
|
1266
|
+
while [ $waited -lt 10 ]; do
|
|
1267
|
+
if ! kill -0 "$walker_pid" 2>/dev/null; then
|
|
1268
|
+
break
|
|
1269
|
+
fi
|
|
1270
|
+
sleep 0.05
|
|
1271
|
+
waited=$((waited + 1))
|
|
1272
|
+
done
|
|
1273
|
+
if kill -0 "$walker_pid" 2>/dev/null; then
|
|
1274
|
+
kill "$walker_pid" 2>/dev/null || true
|
|
1275
|
+
echo "[sealed-walker] 500ms budget exceeded, using partial results" >&2
|
|
1276
|
+
fi
|
|
1277
|
+
wait "$walker_pid" 2>/dev/null || true
|
|
1278
|
+
|
|
1279
|
+
# Read the tempfile and build the block.
|
|
1280
|
+
if [ ! -s "$tmp" ]; then
|
|
1281
|
+
rm -f "$tmp" 2>/dev/null || true
|
|
1282
|
+
return 0
|
|
1283
|
+
fi
|
|
1284
|
+
|
|
1285
|
+
local body=""
|
|
1286
|
+
local more_line=""
|
|
1287
|
+
while IFS=$'\t' read -r name rel rules; do
|
|
1288
|
+
if [ "$name" = "__MORE__" ]; then
|
|
1289
|
+
more_line="... and ${rel} more sealed rooms (run /mos:rooms list-sealed for the full set)"
|
|
1290
|
+
continue
|
|
1291
|
+
fi
|
|
1292
|
+
if [ -z "$name" ]; then
|
|
1293
|
+
continue
|
|
1294
|
+
fi
|
|
1295
|
+
if [ -z "$rules" ]; then
|
|
1296
|
+
rules="(no hard rules parsed)"
|
|
1297
|
+
fi
|
|
1298
|
+
body="${body}\n- ${name} (path: ${rel})\n Hard rules: ${rules}"
|
|
1299
|
+
done < "$tmp"
|
|
1300
|
+
rm -f "$tmp" 2>/dev/null || true
|
|
1301
|
+
|
|
1302
|
+
if [ -z "$body" ]; then
|
|
1303
|
+
return 0
|
|
1304
|
+
fi
|
|
1305
|
+
|
|
1306
|
+
local header="## SEALED ROOMS (DO NOT LEAK CONTENT INTO THIS SESSION)\n\nThe following rooms exist on this machine and are sealed by GUARDRAIL.md.\nYou must NOT pull content from them, draft artifacts about them, or\nreference them in this session unless the user explicitly switches to\none of them via /mos:rooms switch <name>."
|
|
1307
|
+
|
|
1308
|
+
local block="\n\n${header}\n${body}"
|
|
1309
|
+
if [ -n "$more_line" ]; then
|
|
1310
|
+
block="${block}\n${more_line}"
|
|
1311
|
+
fi
|
|
1312
|
+
|
|
1313
|
+
context="${context}${block}"
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
# Export rooms_root into env for the python subshell via SEALED_ROOMS_ROOT.
|
|
1317
|
+
if [ -n "${MINDRIAN_ROOMS_ROOT:-}" ]; then
|
|
1318
|
+
export SEALED_ROOMS_ROOT="${MINDRIAN_ROOMS_ROOT}"
|
|
1319
|
+
elif [ -d "${HOME}/MindrianRooms" ]; then
|
|
1320
|
+
export SEALED_ROOMS_ROOT="${HOME}/MindrianRooms"
|
|
1321
|
+
fi
|
|
1322
|
+
walk_sealed_rooms || true
|
|
1323
|
+
unset SEALED_ROOMS_ROOT
|
|
1324
|
+
|
|
1325
|
+
# ---------------------------------------------------------------------------
|
|
1326
|
+
# Phase 84-03: RECENT SESSIONS IN THIS ROOM injection (additive to Phase 83).
|
|
1327
|
+
#
|
|
1328
|
+
# Calls scripts/memory-lifecycle.cjs session-start which:
|
|
1329
|
+
# 1. Resolves the active room from ~/MindrianRooms/.rooms/registry.json
|
|
1330
|
+
# (same registry Phase 83 ACTIVE ROOM CONTEXT block uses)
|
|
1331
|
+
# 2. Opens room/.mindrian/room.db via lib/core/room-db.cjs (lazygraph +
|
|
1332
|
+
# memory schema in a single idempotent call)
|
|
1333
|
+
# 3. Inserts a new sessions row and writes .mindrian/current-session.json
|
|
1334
|
+
# 4. Formats the previous N sessions into a RECENT SESSIONS markdown
|
|
1335
|
+
# block and prints it to stdout
|
|
1336
|
+
#
|
|
1337
|
+
# The output is appended to $context AFTER the Phase 83 ACTIVE ROOM CONTEXT
|
|
1338
|
+
# block. If no active room, no registry, or first session in the room, the
|
|
1339
|
+
# output is empty and the concatenation is a no-op. Phase 83 block remains
|
|
1340
|
+
# byte-identical. See .planning/phases/84-smart-notebook/84-03-PLAN.md
|
|
1341
|
+
# ---------------------------------------------------------------------------
|
|
1342
|
+
memory_block=""
|
|
1343
|
+
if [ -x "$(command -v node)" ] && [ -f "${PLUGIN_ROOT}/scripts/memory-lifecycle.cjs" ]; then
|
|
1344
|
+
memory_block=$(node "${PLUGIN_ROOT}/scripts/memory-lifecycle.cjs" session-start 2>/dev/null || true)
|
|
1345
|
+
fi
|
|
1346
|
+
if [ -n "$memory_block" ]; then
|
|
1347
|
+
context="${context}\n\n${memory_block}"
|
|
1348
|
+
fi
|
|
1349
|
+
|
|
1350
|
+
# Auto-configure statusline: deploy the statusline DISPATCHER shim and point
|
|
1351
|
+
# settings.json at it. The shim (scripts/statusline-mos-dispatch) carries zero
|
|
1352
|
+
# logic -- it resolves the active plugin version at runtime and exec's that
|
|
1353
|
+
# version's scripts/statusline-mos, which does the real work. So a wrapper fix
|
|
1354
|
+
# in plugin vN+1 takes effect next session with no further re-stamp, and a
|
|
1355
|
+
# wrapper bug never sits stale on the deployment surface. See
|
|
1356
|
+
# scripts/statusline-mos-dispatch, scripts/statusline-mos, lib/core/active-plugin-root.cjs.
|
|
1357
|
+
CLAUDE_CONFIG_DIR="${CLAUDE_CONFIG_DIR:-$HOME/.claude}"
|
|
1358
|
+
CLAUDE_SETTINGS="${CLAUDE_CONFIG_DIR}/settings.json"
|
|
1359
|
+
WRAPPER_DST="${CLAUDE_CONFIG_DIR}/statusline-mos"
|
|
1360
|
+
DISPATCH_SRC="${PLUGIN_ROOT}/scripts/statusline-mos-dispatch"
|
|
1361
|
+
|
|
1362
|
+
# Step A: deploy / migrate the dispatcher shim. One-time migration from an old
|
|
1363
|
+
# logic-bearing wrapper; no-op once it's already the dispatcher; never touches a
|
|
1364
|
+
# non-MindrianOS file at that path (don't clobber a user customization).
|
|
1365
|
+
if [ -f "$DISPATCH_SRC" ]; then
|
|
1366
|
+
_need_statusline_restamp="yes"
|
|
1367
|
+
if [ -f "$WRAPPER_DST" ]; then
|
|
1368
|
+
if grep -q 'MINDRIAN-STATUSLINE-DISPATCH' "$WRAPPER_DST" 2>/dev/null; then
|
|
1369
|
+
_need_statusline_restamp="no" # already the dispatcher
|
|
1370
|
+
elif ! grep -q 'MindrianOS statusline' "$WRAPPER_DST" 2>/dev/null; then
|
|
1371
|
+
_need_statusline_restamp="no" # not a MindrianOS file -- leave it
|
|
1372
|
+
fi
|
|
1373
|
+
fi
|
|
1374
|
+
if [ "$_need_statusline_restamp" = "yes" ]; then
|
|
1375
|
+
mkdir -p "$CLAUDE_CONFIG_DIR" 2>/dev/null || true
|
|
1376
|
+
cp "$DISPATCH_SRC" "$WRAPPER_DST" 2>/dev/null || true
|
|
1377
|
+
chmod +x "$WRAPPER_DST" 2>/dev/null || true
|
|
1378
|
+
fi
|
|
1379
|
+
fi
|
|
1380
|
+
# Fallback for plugin versions before the dispatcher existed: if the dispatcher
|
|
1381
|
+
# source is absent (older PLUGIN_ROOT) but the legacy full wrapper is present,
|
|
1382
|
+
# keep the prior behavior so we don't leave the user with no statusline.
|
|
1383
|
+
if [ ! -f "$DISPATCH_SRC" ] && [ -f "${PLUGIN_ROOT}/scripts/statusline-mos" ]; then
|
|
1384
|
+
mkdir -p "$CLAUDE_CONFIG_DIR" 2>/dev/null || true
|
|
1385
|
+
cp "${PLUGIN_ROOT}/scripts/statusline-mos" "$WRAPPER_DST" 2>/dev/null || true
|
|
1386
|
+
chmod +x "$WRAPPER_DST" 2>/dev/null || true
|
|
1387
|
+
fi
|
|
1388
|
+
|
|
1389
|
+
# Step B: detection-driven settings.json migration.
|
|
1390
|
+
# Only rewrite when the current statusLine command contains "context-monitor"
|
|
1391
|
+
# but does NOT already contain "statusline-mos". This preserves user
|
|
1392
|
+
# customizations and is idempotent across repeated session starts.
|
|
1393
|
+
if [ -f "$CLAUDE_SETTINGS" ] && [ -f "$WRAPPER_DST" ]; then
|
|
1394
|
+
CURRENT_STATUSLINE=$(node -e "try{const d=require('$CLAUDE_SETTINGS');const sl=d.statusLine||{};process.stdout.write((sl.command||'').toString())}catch(_){}" 2>/dev/null || echo "")
|
|
1395
|
+
if [[ "$CURRENT_STATUSLINE" == *"context-monitor"* ]] && [[ "$CURRENT_STATUSLINE" != *"statusline-mos"* ]]; then
|
|
1396
|
+
node -e "
|
|
1397
|
+
try {
|
|
1398
|
+
const fs = require('fs');
|
|
1399
|
+
const wrapper = process.argv[1];
|
|
1400
|
+
const settings = process.argv[2];
|
|
1401
|
+
const d = JSON.parse(fs.readFileSync(settings, 'utf8'));
|
|
1402
|
+
const cur = d.statusLine || {};
|
|
1403
|
+
const curCmd = (cur && typeof cur === 'object') ? (cur.command || '') : '';
|
|
1404
|
+
if (curCmd.indexOf('context-monitor') !== -1 && curCmd.indexOf('statusline-mos') === -1) {
|
|
1405
|
+
if (!('_savedStatusLine' in d)) d._savedStatusLine = cur;
|
|
1406
|
+
d.statusLine = { type: 'command', command: 'bash \"' + wrapper + '\"' };
|
|
1407
|
+
fs.writeFileSync(settings, JSON.stringify(d, null, 2));
|
|
1408
|
+
}
|
|
1409
|
+
} catch (_) {}
|
|
1410
|
+
" "$WRAPPER_DST" "$CLAUDE_SETTINGS" 2>/dev/null || true
|
|
1411
|
+
fi
|
|
1412
|
+
fi
|
|
1413
|
+
|
|
1414
|
+
# --- BEGIN install-state manifest reconcile (Phase 123, on-version-change) ---
|
|
1415
|
+
# Phase 123 Plan-02 (HARNESS-123-06). Canon Part 8: LOCAL only.
|
|
1416
|
+
# Walk data/deployment-surfaces.json for owned (owner=session-start) surfaces
|
|
1417
|
+
# whose reconcile == on-version-change. Step A above already re-stamps the
|
|
1418
|
+
# statusline-dispatch-shim surface unconditionally (cheap + idempotent); Step B
|
|
1419
|
+
# rewrites the settings-statusline-command surface. The ~/.mindrian-last-version
|
|
1420
|
+
# surface is rewritten in the EARLY install-state record block. The one
|
|
1421
|
+
# remaining manifest-driven action is the dev-clone-pre-commit-hook surface:
|
|
1422
|
+
# on a dev-clone topology + version change, idempotently install/update the
|
|
1423
|
+
# Phase 108 schema-alias drift-guard pre-commit hook via scripts/install-pre-
|
|
1424
|
+
# commit.sh. Skipped entirely on a non-dev-clone box.
|
|
1425
|
+
if [ "$PLUGIN_VERSION" != "$LAST_VERSION" ] || [ -z "$LAST_VERSION" ]; then
|
|
1426
|
+
_MOS_TOPOLOGY=$(node -e 'try { var r = require(process.env.PLUGIN_ROOT_FOR_RESOLVE + "/lib/core/active-plugin-root.cjs").resolveActivePluginRoot(); process.stdout.write(r.topology || "not-found"); } catch (_) { process.stdout.write("not-found"); }' PLUGIN_ROOT_FOR_RESOLVE="$PLUGIN_ROOT_FOR_NODE" 2>/dev/null)
|
|
1427
|
+
if [ "$_MOS_TOPOLOGY" = "dev-clone" ] && [ -x "$PLUGIN_ROOT/scripts/install-pre-commit.sh" ]; then
|
|
1428
|
+
# Idempotent: scripts/install-pre-commit.sh checks for the marker before
|
|
1429
|
+
# appending; a hook that already invokes check-schema-aliases.cjs is a no-op.
|
|
1430
|
+
bash "$PLUGIN_ROOT/scripts/install-pre-commit.sh" >/dev/null 2>&1 || true
|
|
1431
|
+
fi
|
|
1432
|
+
fi
|
|
1433
|
+
# --- END install-state manifest reconcile ---
|
|
1434
|
+
|
|
1435
|
+
# --- BEGIN cache prune (Phase 123, on version change) ---
|
|
1436
|
+
# Phase 123 Plan-05 (HARNESS-123-13). Canon Part 8: LOCAL only -- pure fs ops.
|
|
1437
|
+
# Prune stale marketplace-cache version dirs on version change: keep the
|
|
1438
|
+
# active version + N=2 most-recent non-active by mtime; everything else gets
|
|
1439
|
+
# rmSync'd. NEVER touches the active dir (belt + suspenders inside the
|
|
1440
|
+
# helper). Skips entirely if installed_plugins.json is unreadable -- never
|
|
1441
|
+
# guesses. Placed AFTER the manifest reconcile so owned surfaces are fresh
|
|
1442
|
+
# BEFORE sibling cache dirs get touched. Best-effort: a prune failure
|
|
1443
|
+
# (`|| true`) never blocks session startup.
|
|
1444
|
+
if [ "$PLUGIN_VERSION" != "$LAST_VERSION" ] || [ -z "$LAST_VERSION" ]; then
|
|
1445
|
+
env PLUGIN_ROOT_FOR_PRUNE="$PLUGIN_ROOT_FOR_NODE" HOME_FOR_PRUNE="$HOME" node -e '
|
|
1446
|
+
try {
|
|
1447
|
+
var mod = require(process.env.PLUGIN_ROOT_FOR_PRUNE + "/lib/core/cache-prune.cjs");
|
|
1448
|
+
var r = mod.pruneMarketplaceCache({ home: process.env.HOME_FOR_PRUNE });
|
|
1449
|
+
if (r.skipped) {
|
|
1450
|
+
process.stderr.write("cache-prune skipped: " + r.reason + "\n");
|
|
1451
|
+
} else if (r.removed.length > 0) {
|
|
1452
|
+
process.stderr.write("cache-prune removed: " + r.removed.join(", ") + " (kept: " + r.kept.join(", ") + ")\n");
|
|
1453
|
+
}
|
|
1454
|
+
} catch (e) {
|
|
1455
|
+
process.stderr.write("cache-prune failed: " + (e && e.message) + "\n");
|
|
1456
|
+
}
|
|
1457
|
+
' 2>/dev/null || true
|
|
1458
|
+
fi
|
|
1459
|
+
# --- END cache prune ---
|
|
1460
|
+
|
|
1461
|
+
# --- BEGIN feynman timeline refresh (Phase 124, best-effort) ---
|
|
1462
|
+
# Phase 124-03 (TEMPORAL-124-03). Canon Part 8: LOCAL only -- the timeline-runner
|
|
1463
|
+
# reads ONLY room.db via lib/core/navigation.cjs (D-03). Refreshes every section's
|
|
1464
|
+
# FEYNMAN.md `## Timeline (auto)` block when the SQL is newer than the rendered
|
|
1465
|
+
# watermark (D-09). Best-effort: a failure (`|| true`) never blocks session startup.
|
|
1466
|
+
# Mirrors the cache-prune cascade pattern verbatim. The slot is a no-op when no
|
|
1467
|
+
# active room is resolvable. The active room is resolved via the same registry
|
|
1468
|
+
# resolver used by scripts/brain-derive-command.cjs so the slot works even when
|
|
1469
|
+
# the surrounding session-start state does not export ROOM_DIR at this point.
|
|
1470
|
+
env PLUGIN_ROOT_FOR_FEYNMAN="$PLUGIN_ROOT_FOR_NODE" ACTIVE_ROOM_FOR_FEYNMAN="${ROOM_DIR:-}" node -e '
|
|
1471
|
+
try {
|
|
1472
|
+
var fs = require("node:fs");
|
|
1473
|
+
var path = require("node:path");
|
|
1474
|
+
var os = require("node:os");
|
|
1475
|
+
// Resolve active room: prefer the surrounding shell ROOM_DIR; otherwise fall
|
|
1476
|
+
// back to the registry resolver (mirror of scripts/brain-derive-command.cjs).
|
|
1477
|
+
var roomDir = process.env.ACTIVE_ROOM_FOR_FEYNMAN || "";
|
|
1478
|
+
if (!roomDir) {
|
|
1479
|
+
var roomsRoot = process.env.MINDRIAN_ROOMS_ROOT
|
|
1480
|
+
|| process.env.MINDRIAN_ROOMS_HOME
|
|
1481
|
+
|| path.join(os.homedir(), "MindrianRooms");
|
|
1482
|
+
var regPath = path.join(roomsRoot, ".rooms", "registry.json");
|
|
1483
|
+
if (!fs.existsSync(regPath)) process.exit(0);
|
|
1484
|
+
var reg = JSON.parse(fs.readFileSync(regPath, "utf8"));
|
|
1485
|
+
if (!reg || !reg.active || !reg.rooms || !reg.rooms[reg.active]) process.exit(0);
|
|
1486
|
+
roomDir = path.resolve(roomsRoot, reg.rooms[reg.active].path || reg.active);
|
|
1487
|
+
}
|
|
1488
|
+
if (!fs.existsSync(roomDir)) process.exit(0);
|
|
1489
|
+
// Try to open room.db so the runner can do the watermark check + memory_event log.
|
|
1490
|
+
var db = null;
|
|
1491
|
+
try {
|
|
1492
|
+
var dbPath = path.join(roomDir, ".mindrian", "room.db");
|
|
1493
|
+
if (fs.existsSync(dbPath)) {
|
|
1494
|
+
var sqlite = require("node:sqlite");
|
|
1495
|
+
db = new sqlite.DatabaseSync(dbPath);
|
|
1496
|
+
}
|
|
1497
|
+
} catch (_) { db = null; }
|
|
1498
|
+
var runner = require(process.env.PLUGIN_ROOT_FOR_FEYNMAN + "/lib/core/feynman/timeline-runner.cjs");
|
|
1499
|
+
var result = runner.refreshAll(roomDir, { db: db });
|
|
1500
|
+
if (db) { try { db.close(); } catch (_) {} }
|
|
1501
|
+
if (result && result.refreshed && result.refreshed.length > 0) {
|
|
1502
|
+
process.stderr.write("feynman-timeline-refresh: " + result.refreshed.length + " section(s) refreshed\n");
|
|
1503
|
+
}
|
|
1504
|
+
} catch (e) {
|
|
1505
|
+
process.stderr.write("feynman-timeline-refresh failed: " + (e && e.message) + "\n");
|
|
1506
|
+
}
|
|
1507
|
+
' 2>/dev/null || true
|
|
1508
|
+
# --- END feynman timeline refresh ---
|
|
1509
|
+
|
|
1510
|
+
# --- BEGIN dial memory refresh (Phase 143.1-05, best-effort) ---
|
|
1511
|
+
# Phase 143.1-05 (MEMDIAL-02 runner half). Canon Part 8: LOCAL only -- the
|
|
1512
|
+
# dial-memory-runner is a THIN SHIM over the Phase 124 timeline-runner and reads
|
|
1513
|
+
# ONLY room.db via lib/core/navigation.cjs (D-03). Refreshes every section's
|
|
1514
|
+
# `## Dial Memory (auto)` block FROM the graph (SELECTED_REACH / PIVOTED / DRSCH
|
|
1515
|
+
# relationship layer), the human-authored body byte-preserved (D-02). Fired on the
|
|
1516
|
+
# SAME hybrid trigger as the Phase 124 timeline (session-start cascade + the
|
|
1517
|
+
# /mos:dial-memory-refresh manual command). Best-effort: a failure (`|| true`)
|
|
1518
|
+
# never blocks session startup. The slot is a no-op when no active room resolves.
|
|
1519
|
+
env PLUGIN_ROOT_FOR_DIAL="$PLUGIN_ROOT_FOR_NODE" ACTIVE_ROOM_FOR_DIAL="${ROOM_DIR:-}" node -e '
|
|
1520
|
+
try {
|
|
1521
|
+
var fs = require("node:fs");
|
|
1522
|
+
var path = require("node:path");
|
|
1523
|
+
var os = require("node:os");
|
|
1524
|
+
var roomDir = process.env.ACTIVE_ROOM_FOR_DIAL || "";
|
|
1525
|
+
if (!roomDir) {
|
|
1526
|
+
var roomsRoot = process.env.MINDRIAN_ROOMS_ROOT
|
|
1527
|
+
|| process.env.MINDRIAN_ROOMS_HOME
|
|
1528
|
+
|| path.join(os.homedir(), "MindrianRooms");
|
|
1529
|
+
var regPath = path.join(roomsRoot, ".rooms", "registry.json");
|
|
1530
|
+
if (!fs.existsSync(regPath)) process.exit(0);
|
|
1531
|
+
var reg = JSON.parse(fs.readFileSync(regPath, "utf8"));
|
|
1532
|
+
if (!reg || !reg.active || !reg.rooms || !reg.rooms[reg.active]) process.exit(0);
|
|
1533
|
+
roomDir = path.resolve(roomsRoot, reg.rooms[reg.active].path || reg.active);
|
|
1534
|
+
}
|
|
1535
|
+
if (!fs.existsSync(roomDir)) process.exit(0);
|
|
1536
|
+
var db = null;
|
|
1537
|
+
try {
|
|
1538
|
+
var dbPath = path.join(roomDir, ".mindrian", "room.db");
|
|
1539
|
+
if (fs.existsSync(dbPath)) {
|
|
1540
|
+
var sqlite = require("node:sqlite");
|
|
1541
|
+
db = new sqlite.DatabaseSync(dbPath);
|
|
1542
|
+
}
|
|
1543
|
+
} catch (_) { db = null; }
|
|
1544
|
+
var runner = require(process.env.PLUGIN_ROOT_FOR_DIAL + "/lib/core/feynman/dial-memory-runner.cjs");
|
|
1545
|
+
var result = runner.refreshAll(roomDir, { db: db });
|
|
1546
|
+
if (db) { try { db.close(); } catch (_) {} }
|
|
1547
|
+
if (result && result.refreshed && result.refreshed.length > 0) {
|
|
1548
|
+
process.stderr.write("dial-memory-refresh: " + result.refreshed.length + " section(s) refreshed\n");
|
|
1549
|
+
}
|
|
1550
|
+
} catch (e) {
|
|
1551
|
+
process.stderr.write("dial-memory-refresh failed: " + (e && e.message) + "\n");
|
|
1552
|
+
}
|
|
1553
|
+
' 2>/dev/null || true
|
|
1554
|
+
# --- END dial memory refresh ---
|
|
1555
|
+
|
|
1556
|
+
# --- BEGIN gsd planning-artifact reconcile (Phase 149, best-effort) ---
|
|
1557
|
+
# Phase 149-02 (GAM-02 / GAM-05 / GAM-07). Canon Part 8: LOCAL only -- the
|
|
1558
|
+
# reconcile-runner reads room DATA ONLY via lib/core/navigation.cjs (the Phase 109
|
|
1559
|
+
# chokepoint) and writes planning_artifact + requirement nodes + FEEDS_INTO /
|
|
1560
|
+
# INFORMS / VALIDATES lineage edges; the .planning markdown is the source-of-meaning
|
|
1561
|
+
# read, never egressed. Idempotent: backfill on first run, diff-and-upsert on every
|
|
1562
|
+
# session-start (D-01 universal safety net + D-02 session-start IS the reconcile
|
|
1563
|
+
# trigger). Tri-polar: Desktop / Cowork land here since they have no PostToolUse
|
|
1564
|
+
# hook. Best-effort: a failure (`|| true`) never blocks session startup. Mirrors the
|
|
1565
|
+
# Phase 124 timeline-refresh + Phase 143.1 dial-memory slots verbatim. The slot is a
|
|
1566
|
+
# no-op when no active room resolves. The plugin dog-foods its own .planning by
|
|
1567
|
+
# pointing opts.planningDir at PLUGIN_ROOT/.planning when the active room is the
|
|
1568
|
+
# mindrianOS plugin room (same registry resolver, no new resolver added).
|
|
1569
|
+
env PLUGIN_ROOT_FOR_GSD="$PLUGIN_ROOT" ACTIVE_ROOM_FOR_GSD="${ROOM_DIR:-}" node -e '
|
|
1570
|
+
try {
|
|
1571
|
+
var fs = require("node:fs");
|
|
1572
|
+
var path = require("node:path");
|
|
1573
|
+
var os = require("node:os");
|
|
1574
|
+
// Resolve active room: prefer the surrounding shell ROOM_DIR; otherwise fall
|
|
1575
|
+
// back to the registry resolver (mirror of the Phase 124 timeline slot).
|
|
1576
|
+
var roomDir = process.env.ACTIVE_ROOM_FOR_GSD || "";
|
|
1577
|
+
if (!roomDir) {
|
|
1578
|
+
var roomsRoot = process.env.MINDRIAN_ROOMS_ROOT
|
|
1579
|
+
|| process.env.MINDRIAN_ROOMS_HOME
|
|
1580
|
+
|| path.join(os.homedir(), "MindrianRooms");
|
|
1581
|
+
var regPath = path.join(roomsRoot, ".rooms", "registry.json");
|
|
1582
|
+
if (!fs.existsSync(regPath)) process.exit(0);
|
|
1583
|
+
var reg = JSON.parse(fs.readFileSync(regPath, "utf8"));
|
|
1584
|
+
if (!reg || !reg.active || !reg.rooms || !reg.rooms[reg.active]) process.exit(0);
|
|
1585
|
+
roomDir = path.resolve(roomsRoot, reg.rooms[reg.active].path || reg.active);
|
|
1586
|
+
}
|
|
1587
|
+
if (!fs.existsSync(roomDir)) process.exit(0);
|
|
1588
|
+
// Try to open room.db so the reconcile can upsert nodes + edges.
|
|
1589
|
+
var db = null;
|
|
1590
|
+
try {
|
|
1591
|
+
var dbPath = path.join(roomDir, ".mindrian", "room.db");
|
|
1592
|
+
if (fs.existsSync(dbPath)) {
|
|
1593
|
+
var sqlite = require("node:sqlite");
|
|
1594
|
+
db = new sqlite.DatabaseSync(dbPath);
|
|
1595
|
+
}
|
|
1596
|
+
} catch (_) { db = null; }
|
|
1597
|
+
if (!db) process.exit(0);
|
|
1598
|
+
var pluginRoot = process.env.PLUGIN_ROOT_FOR_GSD || "";
|
|
1599
|
+
var runner = require(pluginRoot + "/lib/core/planning/reconcile-runner.cjs");
|
|
1600
|
+
// Dog-food: when the active room IS the plugin workspace, reconcile the
|
|
1601
|
+
// plugins OWN .planning tree (it lives at PLUGIN_ROOT/.planning, not
|
|
1602
|
+
// ROOM_DIR/.planning). Detect by comparing resolved paths.
|
|
1603
|
+
var reconcileOpts = { db: db };
|
|
1604
|
+
try {
|
|
1605
|
+
if (pluginRoot && path.resolve(roomDir) === path.resolve(pluginRoot)) {
|
|
1606
|
+
reconcileOpts.planningDir = path.join(pluginRoot, ".planning");
|
|
1607
|
+
}
|
|
1608
|
+
} catch (_) {}
|
|
1609
|
+
var result = runner.reconcilePlanningArtifacts(roomDir, reconcileOpts);
|
|
1610
|
+
try { db.close(); } catch (_) {}
|
|
1611
|
+
if (result && result.upserted > 0) {
|
|
1612
|
+
process.stderr.write("gsd-planning-reconcile: " + result.upserted + " artifact node(s) upserted, "
|
|
1613
|
+
+ result.requirement_nodes + " requirement node(s), " + result.edges + " lineage edge(s)\n");
|
|
1614
|
+
}
|
|
1615
|
+
} catch (e) {
|
|
1616
|
+
process.stderr.write("gsd-planning-reconcile failed: " + (e && e.message) + "\n");
|
|
1617
|
+
}
|
|
1618
|
+
' 2>/dev/null || true
|
|
1619
|
+
# --- END gsd planning-artifact reconcile ---
|
|
1620
|
+
|
|
1621
|
+
# --- BEGIN memory-cortex reconcile (Phase 150, best-effort) ---
|
|
1622
|
+
# Phase 150-03 (MEM-01). Canon Part 8: LOCAL only -- the reconcile-memory-runner
|
|
1623
|
+
# reads room DATA ONLY via lib/core/navigation.cjs (the Phase 109 chokepoint) and
|
|
1624
|
+
# writes memory_artifact nodes + governing_thought / navigator_persona / decision
|
|
1625
|
+
# projections + STATES / DESCRIBES / INFORMS cortex edges; the per-folder memory
|
|
1626
|
+
# markdown is the source-of-meaning read, never egressed. Idempotent: backfill on
|
|
1627
|
+
# first run, diff-and-upsert on every session-start (D-01 universal safety net +
|
|
1628
|
+
# D-02 session-start IS the reconcile trigger). Tri-polar: Desktop / Cowork land
|
|
1629
|
+
# here since they have no PostToolUse hook. Best-effort: a failure (`|| true`)
|
|
1630
|
+
# never blocks session startup. Mirrors the Phase 149 planning-artifact reconcile
|
|
1631
|
+
# slot verbatim. The slot is a no-op when no active room resolves. The plugin
|
|
1632
|
+
# dog-foods its own per-folder memory files by pointing opts.sectionRoot at
|
|
1633
|
+
# PLUGIN_ROOT when the active room is the mindrianOS plugin room (same registry
|
|
1634
|
+
# resolver, no new resolver added).
|
|
1635
|
+
env PLUGIN_ROOT_FOR_MEM="$PLUGIN_ROOT" ACTIVE_ROOM_FOR_MEM="${ROOM_DIR:-}" node -e '
|
|
1636
|
+
try {
|
|
1637
|
+
var fs = require("node:fs");
|
|
1638
|
+
var path = require("node:path");
|
|
1639
|
+
var os = require("node:os");
|
|
1640
|
+
// Resolve active room: prefer the surrounding shell ROOM_DIR; otherwise fall
|
|
1641
|
+
// back to the registry resolver (mirror of the Phase 149 reconcile slot).
|
|
1642
|
+
var roomDir = process.env.ACTIVE_ROOM_FOR_MEM || "";
|
|
1643
|
+
if (!roomDir) {
|
|
1644
|
+
var roomsRoot = process.env.MINDRIAN_ROOMS_ROOT
|
|
1645
|
+
|| process.env.MINDRIAN_ROOMS_HOME
|
|
1646
|
+
|| path.join(os.homedir(), "MindrianRooms");
|
|
1647
|
+
var regPath = path.join(roomsRoot, ".rooms", "registry.json");
|
|
1648
|
+
if (!fs.existsSync(regPath)) process.exit(0);
|
|
1649
|
+
var reg = JSON.parse(fs.readFileSync(regPath, "utf8"));
|
|
1650
|
+
if (!reg || !reg.active || !reg.rooms || !reg.rooms[reg.active]) process.exit(0);
|
|
1651
|
+
roomDir = path.resolve(roomsRoot, reg.rooms[reg.active].path || reg.active);
|
|
1652
|
+
}
|
|
1653
|
+
if (!fs.existsSync(roomDir)) process.exit(0);
|
|
1654
|
+
// Try to open room.db so the reconcile can upsert nodes + edges.
|
|
1655
|
+
var db = null;
|
|
1656
|
+
try {
|
|
1657
|
+
var dbPath = path.join(roomDir, ".mindrian", "room.db");
|
|
1658
|
+
if (fs.existsSync(dbPath)) {
|
|
1659
|
+
var sqlite = require("node:sqlite");
|
|
1660
|
+
db = new sqlite.DatabaseSync(dbPath);
|
|
1661
|
+
}
|
|
1662
|
+
} catch (_) { db = null; }
|
|
1663
|
+
if (!db) process.exit(0);
|
|
1664
|
+
var pluginRoot = process.env.PLUGIN_ROOT_FOR_MEM || "";
|
|
1665
|
+
var runner = require(pluginRoot + "/lib/core/memory/reconcile-memory-runner.cjs");
|
|
1666
|
+
// Dog-food: when the active room IS the plugin workspace, reconcile the
|
|
1667
|
+
// plugins OWN per-folder memory files (PLUGIN_ROOT as the section root, not
|
|
1668
|
+
// ROOM_DIR). Detect by comparing resolved paths.
|
|
1669
|
+
var reconcileOpts = { db: db };
|
|
1670
|
+
try {
|
|
1671
|
+
if (pluginRoot && path.resolve(roomDir) === path.resolve(pluginRoot)) {
|
|
1672
|
+
reconcileOpts.sectionRoot = pluginRoot;
|
|
1673
|
+
}
|
|
1674
|
+
} catch (_) {}
|
|
1675
|
+
var result = runner.reconcileMemoryArtifacts(roomDir, reconcileOpts);
|
|
1676
|
+
try { db.close(); } catch (_) {}
|
|
1677
|
+
if (result && result.upserted > 0) {
|
|
1678
|
+
process.stderr.write("memory-cortex-reconcile: " + result.upserted + " memory node(s) upserted, "
|
|
1679
|
+
+ (result.unchanged || 0) + " unchanged, "
|
|
1680
|
+
+ result.decision_nodes + " decision node(s), " + result.edges + " cortex edge(s)\n");
|
|
1681
|
+
}
|
|
1682
|
+
} catch (e) {
|
|
1683
|
+
process.stderr.write("memory-cortex-reconcile failed: " + (e && e.message) + "\n");
|
|
1684
|
+
}
|
|
1685
|
+
' 2>/dev/null || true
|
|
1686
|
+
# --- END memory-cortex reconcile ---
|
|
1687
|
+
|
|
1688
|
+
# --- BEGIN Phase 145 scout cadence (best-effort, self-throttled) ---
|
|
1689
|
+
# Phase 145-02 (SCHED-01 CLI default). Canon Part 8: LOCAL only -- the
|
|
1690
|
+
# scout-cadence-runner is zero-egress (Plan 01 T-145-01/02): it makes NO Brain
|
|
1691
|
+
# query and NO web fetch; HSI / whitespace / reverse-salient / opportunity scans
|
|
1692
|
+
# are all LOCAL compute, and competitor-watch is emitted as a public-SIGNAL query
|
|
1693
|
+
# plan for the surface layer, never fetched here. Soft-fail contract: a failure in
|
|
1694
|
+
# the scout cadence NEVER blocks or aborts session startup (`|| true`, stderr+stdout
|
|
1695
|
+
# to /dev/null, no-op when no room resolves). The throttle lives INSIDE the runner's
|
|
1696
|
+
# Plan-01 guard (last-run timestamp keyed by room-path hash), so the cadence is
|
|
1697
|
+
# at-most-once-per-interval (default 24h): most sessions are a sub-millisecond
|
|
1698
|
+
# throttle short-circuit and add no foreground work to startup. We deliberately do
|
|
1699
|
+
# NOT pass --force here -- session-start owns the throttled DEFAULT path; cron owns
|
|
1700
|
+
# the --force path (see commands/scout.md). Emergency disable: SCOUT_CADENCE_SKIP=1
|
|
1701
|
+
# skips the slot entirely, mirroring the BRAIN_STALENESS_SKIP convention.
|
|
1702
|
+
if [ "${SCOUT_CADENCE_SKIP:-}" != "1" ] && [ -n "${ROOM_DIR:-}" ] && [ -d "${ROOM_DIR}" ]; then
|
|
1703
|
+
( node "${PLUGIN_ROOT}/scripts/scout-cadence-runner.cjs" "${ROOM_DIR}" >/dev/null 2>&1 || true ) &
|
|
1704
|
+
fi
|
|
1705
|
+
# --- END Phase 145 scout cadence ---
|
|
1706
|
+
|
|
1707
|
+
# ---------------------------------------------------------------------------
|
|
1708
|
+
# Phase 87-01a (SEC-04): ensure ROOM.md + MINTO.md pre-commit hook installed.
|
|
1709
|
+
# Self-healing: re-installs if missing or drifted. Worktree-aware via
|
|
1710
|
+
# `git rev-parse --git-path hooks/pre-commit` (R-87-01a-WIN). This defeats
|
|
1711
|
+
# the "--no-verify slipped through once and now the hook file is gone"
|
|
1712
|
+
# anti-pattern. On subsequent sessions the hook is always restored.
|
|
1713
|
+
# Non-fatal: any failure is swallowed so session-start never blocks startup.
|
|
1714
|
+
# ---------------------------------------------------------------------------
|
|
1715
|
+
if command -v git >/dev/null 2>&1; then
|
|
1716
|
+
SETUP_HOOKS_REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
|
|
1717
|
+
if [ -n "$SETUP_HOOKS_REPO_ROOT" ] && [ -x "$SETUP_HOOKS_REPO_ROOT/scripts/setup-hooks.sh" ]; then
|
|
1718
|
+
GUARD_SRC="$SETUP_HOOKS_REPO_ROOT/scripts/hooks/pre-commit-room-minto-guard.sh"
|
|
1719
|
+
# R-87-01a-WIN: use --git-path so worktrees resolve the correct hooks dir
|
|
1720
|
+
HOOK_REL=$(git rev-parse --git-path hooks/pre-commit 2>/dev/null || echo "")
|
|
1721
|
+
if [ -n "$HOOK_REL" ]; then
|
|
1722
|
+
case "$HOOK_REL" in
|
|
1723
|
+
/*) HOOK_DST="$HOOK_REL" ;;
|
|
1724
|
+
*) HOOK_DST="$SETUP_HOOKS_REPO_ROOT/$HOOK_REL" ;;
|
|
1725
|
+
esac
|
|
1726
|
+
else
|
|
1727
|
+
HOOK_DST="$SETUP_HOOKS_REPO_ROOT/.git/hooks/pre-commit"
|
|
1728
|
+
fi
|
|
1729
|
+
if [ ! -f "$HOOK_DST" ] || ! cmp -s "$GUARD_SRC" "$HOOK_DST" 2>/dev/null; then
|
|
1730
|
+
bash "$SETUP_HOOKS_REPO_ROOT/scripts/setup-hooks.sh" >/dev/null 2>&1 || true
|
|
1731
|
+
fi
|
|
1732
|
+
fi
|
|
1733
|
+
fi
|
|
1734
|
+
|
|
1735
|
+
# Check for updates (async, non-blocking, max 3 second timeout)
|
|
1736
|
+
# Only check once per day - cache result
|
|
1737
|
+
UPDATE_CACHE="/tmp/mindrian-update-check"
|
|
1738
|
+
TODAY=$(date -u +"%Y-%m-%d")
|
|
1739
|
+
SHOULD_CHECK=true
|
|
1740
|
+
|
|
1741
|
+
if [ -f "$UPDATE_CACHE" ]; then
|
|
1742
|
+
CACHE_DATE=$(head -1 "$UPDATE_CACHE" 2>/dev/null || echo "")
|
|
1743
|
+
if [ "$CACHE_DATE" = "$TODAY" ]; then
|
|
1744
|
+
SHOULD_CHECK=false
|
|
1745
|
+
# Read cached result
|
|
1746
|
+
CACHED_STATUS=$(sed -n '2p' "$UPDATE_CACHE" 2>/dev/null || echo "")
|
|
1747
|
+
if [ "$CACHED_STATUS" = "UPDATE_AVAILABLE" ]; then
|
|
1748
|
+
CACHED_LATEST=$(sed -n '3p' "$UPDATE_CACHE" 2>/dev/null || echo "")
|
|
1749
|
+
# Auto-update: apply update silently if consent exists
|
|
1750
|
+
AUTO_UPDATE_FLAG="$HOME/.mindrian/auto-update"
|
|
1751
|
+
if [ -f "$AUTO_UPDATE_FLAG" ]; then
|
|
1752
|
+
AUTO_RESULT=$("${SCRIPT_DIR}/self-update" install 2>/dev/null | head -1 || echo "UPDATE_FAILED")
|
|
1753
|
+
if [ "$AUTO_RESULT" = "UPDATED" ]; then
|
|
1754
|
+
context="${context}\n\n[Auto-Updated] MindrianOS updated to ${CACHED_LATEST}. Run /mos:update to see what's new."
|
|
1755
|
+
echo "$TODAY" > "$UPDATE_CACHE"
|
|
1756
|
+
echo "UP_TO_DATE" >> "$UPDATE_CACHE"
|
|
1757
|
+
else
|
|
1758
|
+
context="${context}\n\n[Update Available] MindrianOS ${CACHED_LATEST} is available. Auto-update failed -- run /mos:update manually."
|
|
1759
|
+
fi
|
|
1760
|
+
else
|
|
1761
|
+
context="${context}\n\n[Update Available] MindrianOS ${CACHED_LATEST} is available. Run /mos:update to see what's new.\nEnable auto-updates: mkdir -p ~/.mindrian && touch ~/.mindrian/auto-update"
|
|
1762
|
+
fi
|
|
1763
|
+
fi
|
|
1764
|
+
fi
|
|
1765
|
+
fi
|
|
1766
|
+
|
|
1767
|
+
if $SHOULD_CHECK; then
|
|
1768
|
+
# Run check in background, cache result
|
|
1769
|
+
(
|
|
1770
|
+
UPDATE_RESULT=$("${SCRIPT_DIR}/check-update" 2>/dev/null || echo "CHECK_FAILED")
|
|
1771
|
+
STATUS=$(echo "$UPDATE_RESULT" | head -1)
|
|
1772
|
+
echo "$TODAY" > "$UPDATE_CACHE"
|
|
1773
|
+
echo "$STATUS" >> "$UPDATE_CACHE"
|
|
1774
|
+
if [ "$STATUS" = "UPDATE_AVAILABLE" ]; then
|
|
1775
|
+
LATEST=$(echo "$UPDATE_RESULT" | grep "^LATEST=" | cut -d= -f2)
|
|
1776
|
+
echo "$LATEST" >> "$UPDATE_CACHE"
|
|
1777
|
+
fi
|
|
1778
|
+
) &
|
|
1779
|
+
fi
|
|
1780
|
+
|
|
1781
|
+
# Phase 251-01 (CACHE-02b, skeleton-to-SessionStart): the FIRE-IF-FORK
|
|
1782
|
+
# imperative (~330 B/turn) moves here from the per-turn engine block
|
|
1783
|
+
# (scripts/intent-classifier.cjs's renderEngineDecisionWithDial concatenation
|
|
1784
|
+
# no longer appends it). Delivery mechanism: SessionStart additionalContext
|
|
1785
|
+
# is the sanctioned mechanism (tier0-removal handoff Section 6: no always-on
|
|
1786
|
+
# skill primitive exists); the hooks.json SessionStart matcher
|
|
1787
|
+
# 'startup|clear|compact' re-seeds this doctrine after every compaction,
|
|
1788
|
+
# which resolves the measurement's survives-compaction caveat. PostCompact
|
|
1789
|
+
# cannot carry hookSpecificOutput (95-RESEARCH.md), so the compact re-seed
|
|
1790
|
+
# rides SessionStart(compact), not post-compact. Appended unconditionally
|
|
1791
|
+
# (paid once at 1.25x cache-write, then read at 0.1x for the rest of the
|
|
1792
|
+
# session); the per-turn block keeps only the byte-frozen marker.
|
|
1793
|
+
NAV_CARD_FIRE_DOCTRINE="\n\n## NAVIGATION CARD-FIRE CONTRACT (session doctrine)\n\nEvery per-turn NAVIGATION DECISION block ends with the frozen line [AskUserQuestion contract: shape=F.X verbs=N]. That marker is the per-turn gate flag; only the imperative below moved here.\n\n[FIRE-IF-FORK]: if the fork shown in the option rows above the marker is genuinely unanswered and relevant to the current conversation, call the AskUserQuestion tool in THAT response with the options shown. If the navigator already answered in plain text or the gate is unrelated, do NOT fire it -- acknowledge and proceed instead. Never reproduce the block as text (SEED-021).\n\nThe [AskUserQuestion payload: ...] line carries shape, mode, verb_count, recommended; the option labels are the rows above it.\n\nA line reading [NAV DECISION unchanged - prior block stands] means the previous turn's decision still applies."
|
|
1794
|
+
context="${context}${NAV_CARD_FIRE_DOCTRINE}"
|
|
1795
|
+
|
|
1796
|
+
# Escape string for JSON embedding
|
|
1797
|
+
escape_for_json() {
|
|
1798
|
+
local s="$1"
|
|
1799
|
+
s="${s//\\/\\\\}"
|
|
1800
|
+
s="${s//\"/\\\"}"
|
|
1801
|
+
s="${s//$'\n'/\\n}"
|
|
1802
|
+
s="${s//$'\r'/\\r}"
|
|
1803
|
+
s="${s//$'\t'/\\t}"
|
|
1804
|
+
printf '%s' "$s"
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
escaped_context=$(escape_for_json "$context")
|
|
1808
|
+
|
|
1809
|
+
# 88.1-03: systemMessage retrofit.
|
|
1810
|
+
# Compute a tight one-line status string the user sees alongside the
|
|
1811
|
+
# additionalContext injection. Reports room slug + active section count +
|
|
1812
|
+
# aggregate MINTO health glyph (Canon Part 2 vocabulary: check/warn/low/--).
|
|
1813
|
+
# LOCAL-only (Canon Part 8): never references Brain endpoints. Soft-fail
|
|
1814
|
+
# at every boundary -- on any failure the systemMessage is "loaded room:
|
|
1815
|
+
# <slug>" with unknown section count / health glyph, and session-start
|
|
1816
|
+
# still exits 0 with its additionalContext payload intact.
|
|
1817
|
+
SYSTEM_MESSAGE=""
|
|
1818
|
+
if [ -n "${ROOM_DIR:-}" ] && [ -d "${ROOM_DIR}" ]; then
|
|
1819
|
+
ROOM_SLUG=$(basename "${ROOM_DIR}" 2>/dev/null || echo "unknown")
|
|
1820
|
+
SESSION_START_SM=$(env ROOM_DIR_ENV="${ROOM_DIR}" PLUGIN_ROOT_ENV="${PLUGIN_ROOT}" node -e '
|
|
1821
|
+
"use strict";
|
|
1822
|
+
try {
|
|
1823
|
+
const fs = require("fs");
|
|
1824
|
+
const path = require("path");
|
|
1825
|
+
const roomDir = process.env.ROOM_DIR_ENV;
|
|
1826
|
+
const pluginRoot = process.env.PLUGIN_ROOT_ENV;
|
|
1827
|
+
const fm = require(path.join(pluginRoot, "lib", "core", "folder-memory.cjs"));
|
|
1828
|
+
const fmt = require(path.join(pluginRoot, "lib", "memory", "triple-context-formatter.cjs"));
|
|
1829
|
+
let entries = [];
|
|
1830
|
+
try {
|
|
1831
|
+
entries = fs.readdirSync(roomDir, { withFileTypes: true })
|
|
1832
|
+
.filter((d) => d.isDirectory() && d.name[0] !== ".");
|
|
1833
|
+
} catch (_e) { entries = []; }
|
|
1834
|
+
const scores = [];
|
|
1835
|
+
let sectionCount = 0;
|
|
1836
|
+
for (const d of entries) {
|
|
1837
|
+
const sp = path.join(roomDir, d.name);
|
|
1838
|
+
try {
|
|
1839
|
+
if (!fs.existsSync(path.join(sp, "ROOM.md"))) continue;
|
|
1840
|
+
sectionCount += 1;
|
|
1841
|
+
const t = fm.readTriple(sp);
|
|
1842
|
+
if (t && t.reasoning && typeof t.reasoning.reasoning_health_score === "number") {
|
|
1843
|
+
scores.push(t.reasoning.reasoning_health_score);
|
|
1844
|
+
}
|
|
1845
|
+
} catch (_e) { /* skip this section */ }
|
|
1846
|
+
}
|
|
1847
|
+
let median = null;
|
|
1848
|
+
if (scores.length > 0) {
|
|
1849
|
+
const sorted = scores.slice().sort((a, b) => a - b);
|
|
1850
|
+
const mid = Math.floor(sorted.length / 2);
|
|
1851
|
+
median = sorted.length % 2 === 0
|
|
1852
|
+
? (sorted[mid - 1] + sorted[mid]) / 2
|
|
1853
|
+
: sorted[mid];
|
|
1854
|
+
}
|
|
1855
|
+
const glyph = fmt.classifyHealth(median);
|
|
1856
|
+
process.stdout.write(sectionCount + "|" + glyph);
|
|
1857
|
+
} catch (_e) { process.stdout.write("0|--"); }
|
|
1858
|
+
' 2>/dev/null || echo "0|--")
|
|
1859
|
+
SECTION_COUNT="${SESSION_START_SM%|*}"
|
|
1860
|
+
HEALTH_GLYPH="${SESSION_START_SM##*|}"
|
|
1861
|
+
SYSTEM_MESSAGE="loaded room: ${ROOM_SLUG}, ${SECTION_COUNT} active sections, MINTO health ${HEALTH_GLYPH}"
|
|
1862
|
+
else
|
|
1863
|
+
SYSTEM_MESSAGE="session-start: no active room"
|
|
1864
|
+
fi
|
|
1865
|
+
escaped_sysmsg=$(escape_for_json "$SYSTEM_MESSAGE")
|
|
1866
|
+
|
|
1867
|
+
# --- BEGIN Brain status (Phase 123, Plan-7) ---
|
|
1868
|
+
#
|
|
1869
|
+
# Brain status emission. Replaces the pre-Plan-7 MCP-centric drift check, which
|
|
1870
|
+
# tested only the shell env var MINDRIAN_BRAIN_KEY and missed the standard
|
|
1871
|
+
# install (key in ~/.mindrian.env); on an HTTP-path install it also emitted a
|
|
1872
|
+
# misleading MCP-server-not-found WARN even when the HTTP client was perfectly
|
|
1873
|
+
# healthy. The block below replaces that drift check entirely.
|
|
1874
|
+
#
|
|
1875
|
+
# This block shells out to lib/core/resolve-brain-key.cjs (the single Brain-key
|
|
1876
|
+
# resolver) and emits ONE of three positive status lines:
|
|
1877
|
+
#
|
|
1878
|
+
# - "Brain: HTTP client active" -- key resolved (host dropped from the
|
|
1879
|
+
# banner as of phase 339, 2026-09-03; see the comment below).
|
|
1880
|
+
# - "Brain: NOT loaded -- permissions too open: ... (run: chmod 600 ~/.mindrian.env)"
|
|
1881
|
+
# -- SEC-02 POSIX permission rejection (POSIX-only -- no-op on Windows).
|
|
1882
|
+
# - "Brain: not configured (Tier 0)" -- no key found anywhere.
|
|
1883
|
+
#
|
|
1884
|
+
# The SEC-02 rejection routes through this same status channel -- never bare
|
|
1885
|
+
# stderr. The resolver returns { key, source, available, reason } as JSON;
|
|
1886
|
+
# we parse it with a tiny inline node one-liner (bash has no JSON parser and
|
|
1887
|
+
# adding jq as a dependency would couple session-start to a system package).
|
|
1888
|
+
#
|
|
1889
|
+
# Canon Part 8: the block is purely LOCAL -- the resolver only CHECKS for a
|
|
1890
|
+
# key, never calls Brain. The status line no longer names a host (phase
|
|
1891
|
+
# 339, 2026-09-03): this banner is prose a user reads on EVERY session
|
|
1892
|
+
# start, so a wrong host here would be a lie repeated constantly across an
|
|
1893
|
+
# origin change. Deriving it would mean shelling out to node from this bash
|
|
1894
|
+
# script on the session start path, adding a node spawn to print a hostname
|
|
1895
|
+
# for a purely cosmetic gain in startup latency paid on every session. The
|
|
1896
|
+
# origin already has one authoritative reporter: `node scripts/doctor.cjs`
|
|
1897
|
+
# class M layer 6.
|
|
1898
|
+
# ---------------------------------------------------------------------------
|
|
1899
|
+
_BRAIN_KEY_JSON="$(node "$PLUGIN_ROOT/lib/core/resolve-brain-key.cjs" 2>/dev/null || echo '{"available":false,"reason":"resolver failed"}')"
|
|
1900
|
+
_BRAIN_AVAILABLE="$(printf '%s' "$_BRAIN_KEY_JSON" | node -e "let s='';process.stdin.on('data',c=>s+=c).on('end',()=>{try{process.stdout.write(String(JSON.parse(s).available));}catch(_){process.stdout.write('false');}})" 2>/dev/null)"
|
|
1901
|
+
_BRAIN_REASON="$(printf '%s' "$_BRAIN_KEY_JSON" | node -e "let s='';process.stdin.on('data',c=>s+=c).on('end',()=>{try{const j=JSON.parse(s);process.stdout.write(j.reason||'');}catch(_){process.stdout.write('');}})" 2>/dev/null)"
|
|
1902
|
+
if [ "$_BRAIN_AVAILABLE" = "true" ]; then
|
|
1903
|
+
echo "Brain: HTTP client active" >&2
|
|
1904
|
+
elif [ -n "$_BRAIN_REASON" ] && printf '%s' "$_BRAIN_REASON" | grep -q "permissions too open"; then
|
|
1905
|
+
echo "Brain: NOT loaded -- $_BRAIN_REASON (run: chmod 600 ~/.mindrian.env)" >&2
|
|
1906
|
+
else
|
|
1907
|
+
echo "Brain: not configured (Tier 0)" >&2
|
|
1908
|
+
fi
|
|
1909
|
+
unset _BRAIN_KEY_JSON _BRAIN_AVAILABLE _BRAIN_REASON
|
|
1910
|
+
# --- END Brain status ---
|
|
1911
|
+
|
|
1912
|
+
# ---------------------------------------------------------------------------
|
|
1913
|
+
# 260517-dcw dogfood-bridge drain (Canon Part 6 Product-as-Venture)
|
|
1914
|
+
# ---------------------------------------------------------------------------
|
|
1915
|
+
# Drain ~/.mindrian/dogfood-queue.jsonl into ~/MindrianRooms/mindrian/room.db
|
|
1916
|
+
# via the Phase 109 navigation chokepoint, then regenerate STATE.md ## Live (auto).
|
|
1917
|
+
# Soft-fail on every step -- session-start MUST NEVER crash. Per Canon Part 8 the
|
|
1918
|
+
# entire pipeline is LOCAL-only (no network surface anywhere in the two scripts).
|
|
1919
|
+
# The MINDRIAN_DOGFOOD_DRAIN_SKIP=1 env var bypasses for CI / preflight test fixtures.
|
|
1920
|
+
# Output redirected to /dev/null so the drain never pollutes the additionalContext
|
|
1921
|
+
# JSON envelope below.
|
|
1922
|
+
if [ -z "${MINDRIAN_DOGFOOD_DRAIN_SKIP:-}" ] && [ -f "$PLUGIN_ROOT/scripts/dogfood-emit.cjs" ]; then
|
|
1923
|
+
node "$PLUGIN_ROOT/scripts/dogfood-emit.cjs" >/dev/null 2>&1 || true
|
|
1924
|
+
node "$PLUGIN_ROOT/scripts/dogfood-derive.cjs" >/dev/null 2>&1 || true
|
|
1925
|
+
fi
|
|
1926
|
+
# --- end 260517-dcw dogfood-bridge drain ---
|
|
1927
|
+
|
|
1928
|
+
# Output context injection as JSON
|
|
1929
|
+
# Cursor hooks expect additional_context
|
|
1930
|
+
# Claude Code hooks expect hookSpecificOutput.additionalContext
|
|
1931
|
+
# Only emit the field consumed by the current platform to avoid double injection
|
|
1932
|
+
# 88.1-03: systemMessage is a sibling field on the JSON envelope per the
|
|
1933
|
+
# Claude Code 2.1.x hook spec; rendered as a one-line status to the user.
|
|
1934
|
+
if [ -n "${CURSOR_PLUGIN_ROOT:-}" ]; then
|
|
1935
|
+
printf '{\n "additional_context": "%s",\n "systemMessage": "%s"\n}\n' "$escaped_context" "$escaped_sysmsg"
|
|
1936
|
+
elif [ -n "${CLAUDE_PLUGIN_ROOT:-}" ]; then
|
|
1937
|
+
printf '{\n "hookSpecificOutput": {\n "hookEventName": "SessionStart",\n "additionalContext": "%s"\n },\n "systemMessage": "%s"\n}\n' "$escaped_context" "$escaped_sysmsg"
|
|
1938
|
+
else
|
|
1939
|
+
printf '{\n "additional_context": "%s",\n "systemMessage": "%s"\n}\n' "$escaped_context" "$escaped_sysmsg"
|
|
1940
|
+
fi
|
|
1941
|
+
|
|
1942
|
+
exit 0
|