@mnemonik/shared 5.100.2 → 5.131.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hookTimeouts.d.ts +14 -1
- package/dist/hookTimeouts.d.ts.map +1 -1
- package/dist/hookTimeouts.js +14 -1
- package/dist/hookTimeouts.js.map +1 -1
- package/dist/instructions.d.ts +55 -3
- package/dist/instructions.d.ts.map +1 -1
- package/dist/instructions.js +55 -20
- package/dist/instructions.js.map +1 -1
- package/package.json +1 -1
- package/src/hookTimeouts.ts +14 -1
- package/src/instructions.ts +55 -20
package/dist/hookTimeouts.d.ts
CHANGED
|
@@ -13,7 +13,20 @@
|
|
|
13
13
|
* function. No fetch wrappers here — request shaping stays per-package
|
|
14
14
|
* because each host expresses its hook payloads differently.
|
|
15
15
|
*/
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Snapshot / file-context / policy-reminder / injections fetch budget. Critical-path.
|
|
18
|
+
*
|
|
19
|
+
* The bootstrap digest is delivered over `injections`, so it rides this 2s
|
|
20
|
+
* budget. That is intentional and sufficient: the server side
|
|
21
|
+
* (HooksDispatcher.buildBootstrapDigestPayload) only ever does a Redis GET on
|
|
22
|
+
* the delivery path — a cold synthesis build is fired in the background
|
|
23
|
+
* (fire-and-forget) and never awaited, so delivery is always sub-10ms. A cold
|
|
24
|
+
* cache returns the static `session_bootstrap` directive within this budget
|
|
25
|
+
* (the "cold-prompt" floor), never a blocked/empty response.
|
|
26
|
+
*
|
|
27
|
+
* Invariant: no endpoint on a hook's critical path may await an LLM synthesis
|
|
28
|
+
* call; client timeouts here only ever need to cover a Redis/DB read.
|
|
29
|
+
*/
|
|
17
30
|
export declare const FETCH_TIMEOUT_MS = 2000;
|
|
18
31
|
/** Telemetry fan-out budget. Drop the metric rather than hold the user. */
|
|
19
32
|
export declare const TELEMETRY_TIMEOUT_MS = 500;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hookTimeouts.d.ts","sourceRoot":"","sources":["../src/hookTimeouts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH
|
|
1
|
+
{"version":3,"file":"hookTimeouts.d.ts","sourceRoot":"","sources":["../src/hookTimeouts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC,2EAA2E;AAC3E,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,2FAA2F;AAC3F,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAEzC,+GAA+G;AAC/G,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAIxF"}
|
package/dist/hookTimeouts.js
CHANGED
|
@@ -13,7 +13,20 @@
|
|
|
13
13
|
* function. No fetch wrappers here — request shaping stays per-package
|
|
14
14
|
* because each host expresses its hook payloads differently.
|
|
15
15
|
*/
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Snapshot / file-context / policy-reminder / injections fetch budget. Critical-path.
|
|
18
|
+
*
|
|
19
|
+
* The bootstrap digest is delivered over `injections`, so it rides this 2s
|
|
20
|
+
* budget. That is intentional and sufficient: the server side
|
|
21
|
+
* (HooksDispatcher.buildBootstrapDigestPayload) only ever does a Redis GET on
|
|
22
|
+
* the delivery path — a cold synthesis build is fired in the background
|
|
23
|
+
* (fire-and-forget) and never awaited, so delivery is always sub-10ms. A cold
|
|
24
|
+
* cache returns the static `session_bootstrap` directive within this budget
|
|
25
|
+
* (the "cold-prompt" floor), never a blocked/empty response.
|
|
26
|
+
*
|
|
27
|
+
* Invariant: no endpoint on a hook's critical path may await an LLM synthesis
|
|
28
|
+
* call; client timeouts here only ever need to cover a Redis/DB read.
|
|
29
|
+
*/
|
|
17
30
|
export const FETCH_TIMEOUT_MS = 2000;
|
|
18
31
|
/** Telemetry fan-out budget. Drop the metric rather than hold the user. */
|
|
19
32
|
export const TELEMETRY_TIMEOUT_MS = 500;
|
package/dist/hookTimeouts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hookTimeouts.js","sourceRoot":"","sources":["../src/hookTimeouts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH
|
|
1
|
+
{"version":3,"file":"hookTimeouts.js","sourceRoot":"","sources":["../src/hookTimeouts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAErC,2EAA2E;AAC3E,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAExC,2FAA2F;AAC3F,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAEzC,+GAA+G;AAC/G,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,EAAU;IACxC,MAAM,EAAE,GAAG,IAAI,eAAe,EAAE,CAAC;IACjC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;IAC/C,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;AACnE,CAAC"}
|
package/dist/instructions.d.ts
CHANGED
|
@@ -4,8 +4,60 @@
|
|
|
4
4
|
* This is the SINGLE SOURCE OF TRUTH for MCP instructions.
|
|
5
5
|
* Shared instruction content imported by the server.
|
|
6
6
|
*
|
|
7
|
-
* Version: 2.
|
|
8
|
-
* Updated: 2026-
|
|
7
|
+
* Version: 2.102
|
|
8
|
+
* Updated: 2026-06-29
|
|
9
|
+
*
|
|
10
|
+
* v2.102 — Strengthened the self-bootstrap trigger to a compelling imperative.
|
|
11
|
+
* The v2.101 phrasing ("At the start of a session, unless ... call ...")
|
|
12
|
+
* was too soft; agents on a blind first turn skipped it. Real-world hole
|
|
13
|
+
* it must cover: Cursor's FIRST chat after an IDE open fires no
|
|
14
|
+
* sessionStart (confirmed by hook-stdin capture), and beforeSubmitPrompt
|
|
15
|
+
* has NO model-facing output field (only user_message, shown to the
|
|
16
|
+
* human) — so neither the silent digest nor the hook's
|
|
17
|
+
* session_bootstrap_required directive reaches the model. The MCP
|
|
18
|
+
* instruction is the ONLY model-facing channel left for that turn, so it
|
|
19
|
+
* now leads with the blind-state check + a hard "FIRST action MUST be
|
|
20
|
+
* session_bootstrap, before you reply" and an explicit cwd-REQUIRED
|
|
21
|
+
* clause. Still self-scoping: skips when the "Mnemonik project context"
|
|
22
|
+
* block is already present (working hook/proxy delivery), so config-B/C
|
|
23
|
+
* with live delivery don't double-call. cwd stays host-agnostic — the
|
|
24
|
+
* agent passes the project root it is working in (Cursor exposes the
|
|
25
|
+
* working dir to HOOKS via the stdin `workspace_roots[0]`, which cwdOf
|
|
26
|
+
* already reads; it is NOT an agent-readable env var, so the instruction
|
|
27
|
+
* must not name one).
|
|
28
|
+
*
|
|
29
|
+
* v2.101 — Stripped to a single instruction: the session_bootstrap trigger.
|
|
30
|
+
* MCP instructions are set at Server construction (initialize), before
|
|
31
|
+
* the server knows the client, so they cannot be scoped per-IDE — and
|
|
32
|
+
* IDE != config (a Claude Code user may be config-B or -C). The content
|
|
33
|
+
* is therefore universal and SELF-SCOPING: it conditions on whether a
|
|
34
|
+
* "Mnemonik project context" block is already present (config-B/C with
|
|
35
|
+
* working delivery → skip; config-A and any host where hook/proxy
|
|
36
|
+
* delivery missed → call). Re-enabled in production
|
|
37
|
+
* (MNEMONIK_INSTRUCTIONS_ENABLED=true in both ECS task defs). This is the
|
|
38
|
+
* reliable trigger that makes the agent self-bootstrap — tool results
|
|
39
|
+
* always reach the model, which hook injection cannot guarantee on a
|
|
40
|
+
* no-tool-call turn (e.g. Cursor "hello").
|
|
41
|
+
*
|
|
42
|
+
* v2.100 — Skill + IDE rule templates retired entirely. They were the
|
|
43
|
+
* file-written home of the workflow; agents followed them unreliably and
|
|
44
|
+
* forgot them over long sessions (the same fate these MCP instructions
|
|
45
|
+
* suffer), so they are gone. `filesToWrite` now carries only
|
|
46
|
+
* `.mnemonik.json`. Dropped the trailing pointer that sent agents to
|
|
47
|
+
* read a skill that no longer exists. Behavioral alignment now rides the
|
|
48
|
+
* orchestration layer (host hooks + proxy); these instructions stay lean
|
|
49
|
+
* and are the Config-A fallback only.
|
|
50
|
+
*
|
|
51
|
+
* v2.99 — Orchestration-aware framing. These static MCP instructions are
|
|
52
|
+
* delivered at `initialize`, before the server knows the actor's tier
|
|
53
|
+
* (no project/proxy/hooks state yet), so they cannot be served per-tier.
|
|
54
|
+
* Instead the CONTENT is now tier-correct: the self-drive calls
|
|
55
|
+
* (memory_search / file_context / checkpoint) are framed as the
|
|
56
|
+
* MCP-only (Config-A) fallback, and Config-B/C agents are told to
|
|
57
|
+
* follow the injected orchestration (cached bootstrap block,
|
|
58
|
+
* file_context, checkpoint nudges) rather than duplicate the calls.
|
|
59
|
+
* The orchestration layer (proxy + host hooks) is authoritative for
|
|
60
|
+
* B/C; this block is primarily Config-A's driver.
|
|
9
61
|
*
|
|
10
62
|
* v2.98 — Doc truth contracts are the normal drift surface. linkedDocs and
|
|
11
63
|
* doc_code_couplings remain legacy diagnostics only; docs drift
|
|
@@ -44,7 +96,7 @@ export declare function getMcpInstructions(): string;
|
|
|
44
96
|
* Raw instructions content (always returns the content, ignores env var).
|
|
45
97
|
* Use getMcpInstructions() for production code.
|
|
46
98
|
*/
|
|
47
|
-
export declare const MCP_INSTRUCTIONS_RAW = "
|
|
99
|
+
export declare const MCP_INSTRUCTIONS_RAW = "If your context does not contain a block beginning \"Mnemonik project context (cached\", call session_bootstrap before replying or taking any other action \u2014 e.g. session_bootstrap({ cwd: \"/absolute/path/to/project\" }), where cwd is the real absolute path to the project root you are working in (required; the call fails without it \u2014 substitute your actual path, not the example). It loads this project's prior decisions, open tasks, and policies. If that block is already present, do not call session_bootstrap; the context is already loaded.";
|
|
48
100
|
/**
|
|
49
101
|
* Default export for convenience.
|
|
50
102
|
* Note: This respects the MNEMONIK_INSTRUCTIONS_ENABLED env var.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"instructions.d.ts","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AAIH;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAO3C;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,+iBAAuB,CAAC;AAEzD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAAuB,CAAC"}
|
package/dist/instructions.js
CHANGED
|
@@ -4,8 +4,60 @@
|
|
|
4
4
|
* This is the SINGLE SOURCE OF TRUTH for MCP instructions.
|
|
5
5
|
* Shared instruction content imported by the server.
|
|
6
6
|
*
|
|
7
|
-
* Version: 2.
|
|
8
|
-
* Updated: 2026-
|
|
7
|
+
* Version: 2.102
|
|
8
|
+
* Updated: 2026-06-29
|
|
9
|
+
*
|
|
10
|
+
* v2.102 — Strengthened the self-bootstrap trigger to a compelling imperative.
|
|
11
|
+
* The v2.101 phrasing ("At the start of a session, unless ... call ...")
|
|
12
|
+
* was too soft; agents on a blind first turn skipped it. Real-world hole
|
|
13
|
+
* it must cover: Cursor's FIRST chat after an IDE open fires no
|
|
14
|
+
* sessionStart (confirmed by hook-stdin capture), and beforeSubmitPrompt
|
|
15
|
+
* has NO model-facing output field (only user_message, shown to the
|
|
16
|
+
* human) — so neither the silent digest nor the hook's
|
|
17
|
+
* session_bootstrap_required directive reaches the model. The MCP
|
|
18
|
+
* instruction is the ONLY model-facing channel left for that turn, so it
|
|
19
|
+
* now leads with the blind-state check + a hard "FIRST action MUST be
|
|
20
|
+
* session_bootstrap, before you reply" and an explicit cwd-REQUIRED
|
|
21
|
+
* clause. Still self-scoping: skips when the "Mnemonik project context"
|
|
22
|
+
* block is already present (working hook/proxy delivery), so config-B/C
|
|
23
|
+
* with live delivery don't double-call. cwd stays host-agnostic — the
|
|
24
|
+
* agent passes the project root it is working in (Cursor exposes the
|
|
25
|
+
* working dir to HOOKS via the stdin `workspace_roots[0]`, which cwdOf
|
|
26
|
+
* already reads; it is NOT an agent-readable env var, so the instruction
|
|
27
|
+
* must not name one).
|
|
28
|
+
*
|
|
29
|
+
* v2.101 — Stripped to a single instruction: the session_bootstrap trigger.
|
|
30
|
+
* MCP instructions are set at Server construction (initialize), before
|
|
31
|
+
* the server knows the client, so they cannot be scoped per-IDE — and
|
|
32
|
+
* IDE != config (a Claude Code user may be config-B or -C). The content
|
|
33
|
+
* is therefore universal and SELF-SCOPING: it conditions on whether a
|
|
34
|
+
* "Mnemonik project context" block is already present (config-B/C with
|
|
35
|
+
* working delivery → skip; config-A and any host where hook/proxy
|
|
36
|
+
* delivery missed → call). Re-enabled in production
|
|
37
|
+
* (MNEMONIK_INSTRUCTIONS_ENABLED=true in both ECS task defs). This is the
|
|
38
|
+
* reliable trigger that makes the agent self-bootstrap — tool results
|
|
39
|
+
* always reach the model, which hook injection cannot guarantee on a
|
|
40
|
+
* no-tool-call turn (e.g. Cursor "hello").
|
|
41
|
+
*
|
|
42
|
+
* v2.100 — Skill + IDE rule templates retired entirely. They were the
|
|
43
|
+
* file-written home of the workflow; agents followed them unreliably and
|
|
44
|
+
* forgot them over long sessions (the same fate these MCP instructions
|
|
45
|
+
* suffer), so they are gone. `filesToWrite` now carries only
|
|
46
|
+
* `.mnemonik.json`. Dropped the trailing pointer that sent agents to
|
|
47
|
+
* read a skill that no longer exists. Behavioral alignment now rides the
|
|
48
|
+
* orchestration layer (host hooks + proxy); these instructions stay lean
|
|
49
|
+
* and are the Config-A fallback only.
|
|
50
|
+
*
|
|
51
|
+
* v2.99 — Orchestration-aware framing. These static MCP instructions are
|
|
52
|
+
* delivered at `initialize`, before the server knows the actor's tier
|
|
53
|
+
* (no project/proxy/hooks state yet), so they cannot be served per-tier.
|
|
54
|
+
* Instead the CONTENT is now tier-correct: the self-drive calls
|
|
55
|
+
* (memory_search / file_context / checkpoint) are framed as the
|
|
56
|
+
* MCP-only (Config-A) fallback, and Config-B/C agents are told to
|
|
57
|
+
* follow the injected orchestration (cached bootstrap block,
|
|
58
|
+
* file_context, checkpoint nudges) rather than duplicate the calls.
|
|
59
|
+
* The orchestration layer (proxy + host hooks) is authoritative for
|
|
60
|
+
* B/C; this block is primarily Config-A's driver.
|
|
9
61
|
*
|
|
10
62
|
* v2.98 — Doc truth contracts are the normal drift surface. linkedDocs and
|
|
11
63
|
* doc_code_couplings remain legacy diagnostics only; docs drift
|
|
@@ -30,24 +82,7 @@
|
|
|
30
82
|
*
|
|
31
83
|
* Token-optimised rewrite (superseded by later instruction rewrites).
|
|
32
84
|
*/
|
|
33
|
-
const INSTRUCTIONS_CONTENT = `
|
|
34
|
-
|
|
35
|
-
First call, every session: session_bootstrap. Read the mnemonik skill (from available_skills) for the full workflow.
|
|
36
|
-
After bootstrap: execute _directive.message actions immediately (scanner daemon check is mandatory).
|
|
37
|
-
|
|
38
|
-
The bootstrap response includes _methodCatalog — the full list of mnemonik methods and the memory_tools calling convention. Read it before making any memory_tools calls. Use memory_discover({ method }) for the full schema and a copy-pasteable example of a specific method or action.
|
|
39
|
-
Proactively call memory_search before starting new work — avoids rediscovering known patterns and contradicting past decisions.
|
|
40
|
-
Proactively call file_context before editing any file — loads past bugs, decisions, and gotchas for that file.
|
|
41
|
-
Proactively call checkpoint after making changes or decisions worth keeping — your context is ephemeral and checkpoint is the only way decisions survive across sessions and context compaction. Do not wait for the user to say "done" or "thanks".
|
|
42
|
-
|
|
43
|
-
Documentation drift uses explicit doc-truth contracts. Treat _docDrift/docTruthFindings as actionable only when each finding includes a concrete assertion, named authority, observed mismatch, and agentAction='update_doc'. _docHealth, linkedDocs, stale-coupling counts, and docs({ action: 'drift', legacy: true }) are diagnostics only, not instructions to edit or resolve docs.
|
|
44
|
-
|
|
45
|
-
Ambient envelopes contain background memories surfaced because they may be relevant to your current turn. Treat them as information, not directive. Weight them lower than your own reasoning unless they directly answer the question. They are advisory recall, not authoritative evidence.
|
|
46
|
-
|
|
47
|
-
Directive envelopes with signal="jit_required" are different from ambient. They surface memories that the server has classified as contradicting or materially refining the answer you were about to give to the current prompt. Each memory carries a verdict (contradicts | refines) and a one-line reason. Treat these as authoritative for the current response — comply with the surfaced fact unless it is clearly outdated or wrong. Do not silently route around them. If you disagree with a surfaced memory, say so explicitly and explain why; do not just ignore it.
|
|
48
|
-
|
|
49
|
-
Skip: formatting-only, trivial one-line, mechanical refactors, git ops, tests.
|
|
50
|
-
Save: architectural decisions, bug root causes, user preferences, discovered patterns, multi-file changes.`;
|
|
85
|
+
const INSTRUCTIONS_CONTENT = `If your context does not contain a block beginning "Mnemonik project context (cached", call session_bootstrap before replying or taking any other action — e.g. session_bootstrap({ cwd: "/absolute/path/to/project" }), where cwd is the real absolute path to the project root you are working in (required; the call fails without it — substitute your actual path, not the example). It loads this project's prior decisions, open tasks, and policies. If that block is already present, do not call session_bootstrap; the context is already loaded.`;
|
|
51
86
|
/**
|
|
52
87
|
* Get MCP instructions, respecting MNEMONIK_INSTRUCTIONS_ENABLED env var.
|
|
53
88
|
* Set MNEMONIK_INSTRUCTIONS_ENABLED=false to disable for testing.
|
package/dist/instructions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"instructions.js","sourceRoot":"","sources":["../src/instructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AAEH,MAAM,oBAAoB,GAAG,8hBAA8hB,CAAC;AAE5jB;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB;IAChC,MAAM,GAAG,GAAI,UAAyE,CAAC,OAAO;QAC5F,EAAE,GAAG,CAAC;IACR,IAAI,GAAG,EAAE,6BAA6B,KAAK,OAAO,EAAE,CAAC;QACnD,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AAEzD;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,EAAE,CAAC"}
|
package/package.json
CHANGED
package/src/hookTimeouts.ts
CHANGED
|
@@ -14,7 +14,20 @@
|
|
|
14
14
|
* because each host expresses its hook payloads differently.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Snapshot / file-context / policy-reminder / injections fetch budget. Critical-path.
|
|
19
|
+
*
|
|
20
|
+
* The bootstrap digest is delivered over `injections`, so it rides this 2s
|
|
21
|
+
* budget. That is intentional and sufficient: the server side
|
|
22
|
+
* (HooksDispatcher.buildBootstrapDigestPayload) only ever does a Redis GET on
|
|
23
|
+
* the delivery path — a cold synthesis build is fired in the background
|
|
24
|
+
* (fire-and-forget) and never awaited, so delivery is always sub-10ms. A cold
|
|
25
|
+
* cache returns the static `session_bootstrap` directive within this budget
|
|
26
|
+
* (the "cold-prompt" floor), never a blocked/empty response.
|
|
27
|
+
*
|
|
28
|
+
* Invariant: no endpoint on a hook's critical path may await an LLM synthesis
|
|
29
|
+
* call; client timeouts here only ever need to cover a Redis/DB read.
|
|
30
|
+
*/
|
|
18
31
|
export const FETCH_TIMEOUT_MS = 2000;
|
|
19
32
|
|
|
20
33
|
/** Telemetry fan-out budget. Drop the metric rather than hold the user. */
|
package/src/instructions.ts
CHANGED
|
@@ -4,8 +4,60 @@
|
|
|
4
4
|
* This is the SINGLE SOURCE OF TRUTH for MCP instructions.
|
|
5
5
|
* Shared instruction content imported by the server.
|
|
6
6
|
*
|
|
7
|
-
* Version: 2.
|
|
8
|
-
* Updated: 2026-
|
|
7
|
+
* Version: 2.102
|
|
8
|
+
* Updated: 2026-06-29
|
|
9
|
+
*
|
|
10
|
+
* v2.102 — Strengthened the self-bootstrap trigger to a compelling imperative.
|
|
11
|
+
* The v2.101 phrasing ("At the start of a session, unless ... call ...")
|
|
12
|
+
* was too soft; agents on a blind first turn skipped it. Real-world hole
|
|
13
|
+
* it must cover: Cursor's FIRST chat after an IDE open fires no
|
|
14
|
+
* sessionStart (confirmed by hook-stdin capture), and beforeSubmitPrompt
|
|
15
|
+
* has NO model-facing output field (only user_message, shown to the
|
|
16
|
+
* human) — so neither the silent digest nor the hook's
|
|
17
|
+
* session_bootstrap_required directive reaches the model. The MCP
|
|
18
|
+
* instruction is the ONLY model-facing channel left for that turn, so it
|
|
19
|
+
* now leads with the blind-state check + a hard "FIRST action MUST be
|
|
20
|
+
* session_bootstrap, before you reply" and an explicit cwd-REQUIRED
|
|
21
|
+
* clause. Still self-scoping: skips when the "Mnemonik project context"
|
|
22
|
+
* block is already present (working hook/proxy delivery), so config-B/C
|
|
23
|
+
* with live delivery don't double-call. cwd stays host-agnostic — the
|
|
24
|
+
* agent passes the project root it is working in (Cursor exposes the
|
|
25
|
+
* working dir to HOOKS via the stdin `workspace_roots[0]`, which cwdOf
|
|
26
|
+
* already reads; it is NOT an agent-readable env var, so the instruction
|
|
27
|
+
* must not name one).
|
|
28
|
+
*
|
|
29
|
+
* v2.101 — Stripped to a single instruction: the session_bootstrap trigger.
|
|
30
|
+
* MCP instructions are set at Server construction (initialize), before
|
|
31
|
+
* the server knows the client, so they cannot be scoped per-IDE — and
|
|
32
|
+
* IDE != config (a Claude Code user may be config-B or -C). The content
|
|
33
|
+
* is therefore universal and SELF-SCOPING: it conditions on whether a
|
|
34
|
+
* "Mnemonik project context" block is already present (config-B/C with
|
|
35
|
+
* working delivery → skip; config-A and any host where hook/proxy
|
|
36
|
+
* delivery missed → call). Re-enabled in production
|
|
37
|
+
* (MNEMONIK_INSTRUCTIONS_ENABLED=true in both ECS task defs). This is the
|
|
38
|
+
* reliable trigger that makes the agent self-bootstrap — tool results
|
|
39
|
+
* always reach the model, which hook injection cannot guarantee on a
|
|
40
|
+
* no-tool-call turn (e.g. Cursor "hello").
|
|
41
|
+
*
|
|
42
|
+
* v2.100 — Skill + IDE rule templates retired entirely. They were the
|
|
43
|
+
* file-written home of the workflow; agents followed them unreliably and
|
|
44
|
+
* forgot them over long sessions (the same fate these MCP instructions
|
|
45
|
+
* suffer), so they are gone. `filesToWrite` now carries only
|
|
46
|
+
* `.mnemonik.json`. Dropped the trailing pointer that sent agents to
|
|
47
|
+
* read a skill that no longer exists. Behavioral alignment now rides the
|
|
48
|
+
* orchestration layer (host hooks + proxy); these instructions stay lean
|
|
49
|
+
* and are the Config-A fallback only.
|
|
50
|
+
*
|
|
51
|
+
* v2.99 — Orchestration-aware framing. These static MCP instructions are
|
|
52
|
+
* delivered at `initialize`, before the server knows the actor's tier
|
|
53
|
+
* (no project/proxy/hooks state yet), so they cannot be served per-tier.
|
|
54
|
+
* Instead the CONTENT is now tier-correct: the self-drive calls
|
|
55
|
+
* (memory_search / file_context / checkpoint) are framed as the
|
|
56
|
+
* MCP-only (Config-A) fallback, and Config-B/C agents are told to
|
|
57
|
+
* follow the injected orchestration (cached bootstrap block,
|
|
58
|
+
* file_context, checkpoint nudges) rather than duplicate the calls.
|
|
59
|
+
* The orchestration layer (proxy + host hooks) is authoritative for
|
|
60
|
+
* B/C; this block is primarily Config-A's driver.
|
|
9
61
|
*
|
|
10
62
|
* v2.98 — Doc truth contracts are the normal drift surface. linkedDocs and
|
|
11
63
|
* doc_code_couplings remain legacy diagnostics only; docs drift
|
|
@@ -31,24 +83,7 @@
|
|
|
31
83
|
* Token-optimised rewrite (superseded by later instruction rewrites).
|
|
32
84
|
*/
|
|
33
85
|
|
|
34
|
-
const INSTRUCTIONS_CONTENT = `
|
|
35
|
-
|
|
36
|
-
First call, every session: session_bootstrap. Read the mnemonik skill (from available_skills) for the full workflow.
|
|
37
|
-
After bootstrap: execute _directive.message actions immediately (scanner daemon check is mandatory).
|
|
38
|
-
|
|
39
|
-
The bootstrap response includes _methodCatalog — the full list of mnemonik methods and the memory_tools calling convention. Read it before making any memory_tools calls. Use memory_discover({ method }) for the full schema and a copy-pasteable example of a specific method or action.
|
|
40
|
-
Proactively call memory_search before starting new work — avoids rediscovering known patterns and contradicting past decisions.
|
|
41
|
-
Proactively call file_context before editing any file — loads past bugs, decisions, and gotchas for that file.
|
|
42
|
-
Proactively call checkpoint after making changes or decisions worth keeping — your context is ephemeral and checkpoint is the only way decisions survive across sessions and context compaction. Do not wait for the user to say "done" or "thanks".
|
|
43
|
-
|
|
44
|
-
Documentation drift uses explicit doc-truth contracts. Treat _docDrift/docTruthFindings as actionable only when each finding includes a concrete assertion, named authority, observed mismatch, and agentAction='update_doc'. _docHealth, linkedDocs, stale-coupling counts, and docs({ action: 'drift', legacy: true }) are diagnostics only, not instructions to edit or resolve docs.
|
|
45
|
-
|
|
46
|
-
Ambient envelopes contain background memories surfaced because they may be relevant to your current turn. Treat them as information, not directive. Weight them lower than your own reasoning unless they directly answer the question. They are advisory recall, not authoritative evidence.
|
|
47
|
-
|
|
48
|
-
Directive envelopes with signal="jit_required" are different from ambient. They surface memories that the server has classified as contradicting or materially refining the answer you were about to give to the current prompt. Each memory carries a verdict (contradicts | refines) and a one-line reason. Treat these as authoritative for the current response — comply with the surfaced fact unless it is clearly outdated or wrong. Do not silently route around them. If you disagree with a surfaced memory, say so explicitly and explain why; do not just ignore it.
|
|
49
|
-
|
|
50
|
-
Skip: formatting-only, trivial one-line, mechanical refactors, git ops, tests.
|
|
51
|
-
Save: architectural decisions, bug root causes, user preferences, discovered patterns, multi-file changes.`;
|
|
86
|
+
const INSTRUCTIONS_CONTENT = `If your context does not contain a block beginning "Mnemonik project context (cached", call session_bootstrap before replying or taking any other action — e.g. session_bootstrap({ cwd: "/absolute/path/to/project" }), where cwd is the real absolute path to the project root you are working in (required; the call fails without it — substitute your actual path, not the example). It loads this project's prior decisions, open tasks, and policies. If that block is already present, do not call session_bootstrap; the context is already loaded.`;
|
|
52
87
|
|
|
53
88
|
/**
|
|
54
89
|
* Get MCP instructions, respecting MNEMONIK_INSTRUCTIONS_ENABLED env var.
|