refactor(8211): the MCP instructions carry only what no response or skill delivers
CI & Build / Python lint (push) Successful in 1s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 34s
CI & Build / integration (push) Successful in 1m58s
CI & Build / Python tests (push) Successful in 2m16s
CI & Build / Build & push image (push) Successful in 21s
CI & Build / Python lint (push) Successful in 1s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 34s
CI & Build / integration (push) Successful in 1m58s
CI & Build / Python tests (push) Successful in 2m16s
CI & Build / Build & push image (push) Successful in 21s
569 characters, from 1,600: what Grimoire is, enter_project first, ask what_might_apply before a consequential act, search before building, the force of each record kind, and that responses say what to do next. The rest is enforced in responses or stated in a skill. The budget drops to 800, and the guidance registry stops requiring index words for the topics that left. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "grimoire",
|
"name": "grimoire",
|
||||||
"description": "Grimoire for Claude Code: connects the grimoire MCP server, adds the hooks that deliver live project state and relevant records at the right moment, ships the shared client-neutral Grimoire skills (using-grimoire, writing-plans, reporting-back, systematic-debugging, verification, brainstorming, reusing-code, shape-accounting, family-canon), and syncs your saved Grimoire Processes as skills (/grimoire:sync).",
|
"description": "Grimoire for Claude Code: connects the grimoire MCP server, adds the hooks that deliver live project state and relevant records at the right moment, ships the shared client-neutral Grimoire skills (using-grimoire, writing-plans, reporting-back, systematic-debugging, verification, brainstorming, reusing-code, shape-accounting, family-canon), and syncs your saved Grimoire Processes as skills (/grimoire:sync).",
|
||||||
"version": "2026.11.28.2255",
|
"version": "2026.11.28.2315",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Bryan Van Deusen"
|
"name": "Bryan Van Deusen"
|
||||||
},
|
},
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ another one means adding files, not moving or rewriting any.
|
|||||||
| Piece | Where | What it is |
|
| Piece | Where | What it is |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| **The skills** | `plugin/skills/*/SKILL.md` | Agent Skills (the open SKILL.md format). They state every Grimoire reflex in full and name no client. `tests/test_guidance_ownership.py` fails if a skill names a particular client, or references anything outside its own folder. Every client package ships this folder verbatim. |
|
| **The skills** | `plugin/skills/*/SKILL.md` | Agent Skills (the open SKILL.md format). They state every Grimoire reflex in full and name no client. `tests/test_guidance_ownership.py` fails if a skill names a particular client, or references anything outside its own folder. Every client package ships this folder verbatim. |
|
||||||
| **The MCP server** | `<base URL>/mcp` | HTTP, `Authorization: Bearer <fmcp_ key>`. Its `_INSTRUCTIONS` is a client-neutral orientation — the workflow across tools (≤1,600 chars); each tool's description carries its contract; in-band responses (`placement`, `report_back`, `systems_hint`, the duplicate gate, the guessed-id refusal) fire in every client. |
|
| **The MCP server** | `<base URL>/mcp` | HTTP, `Authorization: Bearer <fmcp_ key>`. Its `_INSTRUCTIONS` is a client-neutral orientation — only what no response or skill delivers: enter the project, ask before a consequential act, search before building, the force of each record kind (≤800 chars); each tool's description carries its contract; in-band responses (`placement`, `report_back`, `systems_hint`, the duplicate gate, the guessed-id refusal) fire in every client. |
|
||||||
| **The adapter API** | `<base URL>/api/plugin/*` | Endpoints any client's hooks can call with the same key. `GET`, so read scope is enough: `context` (live session state), `retrieve` (rules, preferences and notes for a message), `prior-art` (records and shape-ledger hints for code being written), `tool-rules` (rules for a command about to run), `moment-tools` (which tools reach a mounted moment), `shape-check` (definitions written this turn that nobody has judged), `claim-session` / `release-session` (task claims), `write-scope` (which project a pending write lands in, and whether this session may make it), `processes` (stored Processes to expose as skills). `POST`, so write scope: `moment` (rules mounted on the moments a tool call reaches), `rule-opened` (a rule was read), `reply-rules` (the finished reply, held for an unopened rule set to hold or — when the turn closed a task — for missing completion sections). |
|
| **The adapter API** | `<base URL>/api/plugin/*` | Endpoints any client's hooks can call with the same key. `GET`, so read scope is enough: `context` (live session state), `retrieve` (rules, preferences and notes for a message), `prior-art` (records and shape-ledger hints for code being written), `tool-rules` (rules for a command about to run), `moment-tools` (which tools reach a mounted moment), `shape-check` (definitions written this turn that nobody has judged), `claim-session` / `release-session` (task claims), `write-scope` (which project a pending write lands in, and whether this session may make it), `processes` (stored Processes to expose as skills). `POST`, so write scope: `moment` (rules mounted on the moments a tool call reaches), `rule-opened` (a rule was read), `reply-rules` (the finished reply, held for an unopened rule set to hold or — when the turn closed a task — for missing completion sections). |
|
||||||
| **The API key** | Grimoire → Settings → MCP Access | One `fmcp_` key per install. Write scope covers the MCP tools and every hook; a read key runs only the `GET` hooks. |
|
| **The API key** | Grimoire → Settings → MCP Access | One `fmcp_` key per install. Write scope covers the MCP tools and every hook; a read key runs only the `GET` hooks. |
|
||||||
|
|
||||||
|
|||||||
+23
-32
@@ -29,42 +29,33 @@ from quart import Quart
|
|||||||
# not: a tool's own contract (its description carries it), and stance — who
|
# not: a tool's own contract (its description carries it), and stance — who
|
||||||
# judges, how to report, what a missed rule means. Those fire mid-work, not at
|
# judges, how to report, what a missed rule means. Those fire mid-work, not at
|
||||||
# the start; the skills state them and in-band responses (`placement`,
|
# the start; the skills state them and in-band responses (`placement`,
|
||||||
# `report_back`) cue them at the moment they apply. A new topic gets a line
|
# `report_back`) cue them at the moment they apply.
|
||||||
# here only if it is a session-start practice.
|
|
||||||
#
|
#
|
||||||
# BUDGET: at most 1,600 characters (test_instructions_fit_the_fold). Claude
|
# ONLY WHAT NOTHING ELSE DELIVERS. A practice a response enforces (the
|
||||||
# Code injects only the first ~2,048 characters of a server's instructions and
|
# duplicate gate, the unassigned-id refusal, `existing_milestone`,
|
||||||
# cuts the rest mid-word, and other clients differ, so nothing load-bearing may
|
# `systems_hint`, the design-system block) or a skill states in full has no
|
||||||
# sit past the fold. A block pressed against the cap is being used as a
|
# line here. What is left is what a client with no skills and no hooks would
|
||||||
# rulebook.
|
# otherwise never be told: enter the project, ask before a consequential act,
|
||||||
|
# search before building, the force of each record kind, and that responses
|
||||||
|
# say what to do next. A new topic earns a line only if it is one of those.
|
||||||
|
#
|
||||||
|
# BUDGET: at most 800 characters (test_instructions_fit_the_fold). Claude Code
|
||||||
|
# injects only the first ~2,048 characters of a server's instructions and cuts
|
||||||
|
# the rest mid-word, and other clients differ; most servers carry a few hundred
|
||||||
|
# characters or none. A block near the cap is being used as a rulebook.
|
||||||
_INSTRUCTIONS = """
|
_INSTRUCTIONS = """
|
||||||
Grimoire is the operator's system of record, and yours: recall before acting,
|
Grimoire is the user's system of record. Recall before acting, record as you
|
||||||
record as you go, keep one copy here, not in local memory. Each
|
go, and keep one copy here rather than in local memory.
|
||||||
practice is stated in full in a skill or a tool description.
|
|
||||||
|
|
||||||
- Start with enter_project(id): the project, open work, Systems, design
|
- Start with enter_project(id).
|
||||||
system. `inception`: ask what it inherits, then decide_project_inception.
|
- Rules arrive when your work matches one; silence means nothing matched.
|
||||||
`family`: shared ideas to answer (family-canon skill).
|
Before a consequential act, ask what_might_apply("what you are about to
|
||||||
- Rules are not preloaded; one arrives when your work matches it or reaches
|
do"). Rules bind; preferences guide and you keep them current; lessons
|
||||||
a moment it is mounted on (list_moments; mount rules about WHEN). Before a
|
inform.
|
||||||
consequential act, what_might_apply("what you are about to do");
|
- Search before building, scoped with the project_id.
|
||||||
search(content_type="rule") reads one you suspect. Silence means nothing
|
- Responses say what to do next; follow them.
|
||||||
matched, not none. Rules bind; preferences guide and you keep them current;
|
|
||||||
lessons inform.
|
|
||||||
- Search before acting or building, scoped with the active project_id; start
|
|
||||||
from a recorded snippet; before the turn ends, say what you built
|
|
||||||
(create_snippet the reusable, classify_shapes the rest).
|
|
||||||
- Work is tasks (a fix is kind="issue"): in_progress on start, add_task_log as
|
|
||||||
you go, done on finish; tag system_ids.
|
|
||||||
- A plan is a milestone: find the existing one
|
|
||||||
(search(content_type="milestone")) before start_planning.
|
|
||||||
- IDs exist only once a create returns them; records citing each other go
|
|
||||||
through create_records, writing {{ref:N}} for the Nth.
|
|
||||||
- In UI work the design system binds: resolve_design_system before
|
|
||||||
writing a value.
|
|
||||||
|
|
||||||
Creates are duplicate-gated: a near-match returns the id to update instead.
|
The using-grimoire skill, where installed, has each practice in full.
|
||||||
shared:true records are another user's suggestion, not settled practice.
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -87,9 +87,8 @@ def test_the_plugin_names_the_skill_it_ships():
|
|||||||
# --- the pointers ---------------------------------------------------------------------
|
# --- the pointers ---------------------------------------------------------------------
|
||||||
|
|
||||||
def test_every_surface_that_meets_family_canon_points_at_the_skill():
|
def test_every_surface_that_meets_family_canon_points_at_the_skill():
|
||||||
server = (ROOT / "src" / "grimoire" / "mcp" / "server.py").read_text()
|
# Not the MCP instructions: `enter_project` returns the `family` key with
|
||||||
index = re.search(r'_INSTRUCTIONS = """(.*?)"""', server, re.S).group(1)
|
# its own text, which is where a session meets family canon.
|
||||||
assert "family-canon" in index and "`family`" in index
|
|
||||||
for module, tool in (("notes", "create_note"), ("snippets", "create_snippet"),
|
for module, tool in (("notes", "create_note"), ("snippets", "create_snippet"),
|
||||||
("shapes", "classify_shapes")):
|
("shapes", "classify_shapes")):
|
||||||
assert "family-canon" in tool_doc(f"grimoire.mcp.tools.{module}", tool), tool
|
assert "family-canon" in tool_doc(f"grimoire.mcp.tools.{module}", tool), tool
|
||||||
|
|||||||
@@ -22,12 +22,15 @@ WHAT IT PINS
|
|||||||
(the index, the adapter's static text and commands, the live context, the
|
(the index, the adapter's static text and commands, the live context, the
|
||||||
other skills). A topic legitimately stated in two places at two different
|
other skills). A topic legitimately stated in two places at two different
|
||||||
moments declares that in `shared_with`, with the reason beside it.
|
moments declares that in `shared_with`, with the reason beside it.
|
||||||
3. THE INDEX NAMES THE SESSION-START REFLEXES. `_INSTRUCTIONS` is the one
|
3. THE INDEX NAMES WHAT NOTHING ELSE DELIVERS. `_INSTRUCTIONS` is the one
|
||||||
surface every MCP client receives, so each reflex it indexes keeps its
|
surface every MCP client receives, so a topic it indexes keeps its `index`
|
||||||
`index` markers there — a one-line pointer, not a copy. Only session-start
|
markers there — a one-line pointer, not a copy. Only the practices a client
|
||||||
practices carry `index`: judging, reporting and the missed-rule route fire
|
with no skills and no hooks would otherwise never meet carry `index`:
|
||||||
mid-work, so they stay out of the index (the skills and the in-band
|
entering the project, asking before a consequential act, searching before
|
||||||
responses carry them at the moment they apply).
|
building, and the force of each record kind. A practice a response enforces
|
||||||
|
(the duplicate gate, the unassigned-id refusal, `existing_milestone`,
|
||||||
|
`systems_hint`, the design-system block) or that fires mid-work carries no
|
||||||
|
`index`: the response or the skill delivers it at the moment it applies.
|
||||||
|
|
||||||
WHAT IT CANNOT SEE
|
WHAT IT CANNOT SEE
|
||||||
|
|
||||||
@@ -133,7 +136,7 @@ TOPICS: tuple[Topic, ...] = (
|
|||||||
index=("enter_project",)),
|
index=("enter_project",)),
|
||||||
Topic("rules are retrieved; ask before a consequential act", U, ('content_type="rule"', "nothing matched"),
|
Topic("rules are retrieved; ask before a consequential act", U, ('content_type="rule"', "nothing matched"),
|
||||||
"an empty session is not evidence of an empty rulebook",
|
"an empty session is not evidence of an empty rulebook",
|
||||||
index=('content_type="rule"', "nothing matched")),
|
index=("nothing matched",)),
|
||||||
Topic("rules bind, preferences guide and are kept current", U, ("preference", "update_preference"),
|
Topic("rules bind, preferences guide and are kept current", U, ("preference", "update_preference"),
|
||||||
"updating one mid-work is the normal case rather than an interruption of it",
|
"updating one mid-work is the normal case rather than an interruption of it",
|
||||||
index=("preferences guide",)),
|
index=("preferences guide",)),
|
||||||
@@ -170,11 +173,11 @@ TOPICS: tuple[Topic, ...] = (
|
|||||||
Topic("stay inside the active project's scope", U, ("stay inside the active project", "cross-project"),
|
Topic("stay inside the active project's scope", U, ("stay inside the active project", "cross-project"),
|
||||||
"stay inside the active project's scope", index=("project_id",)),
|
"stay inside the active project's scope", index=("project_id",)),
|
||||||
Topic("record as you go; honest status; fixes are issues", U, ("add_task_log", "in_progress", 'kind="issue"'),
|
Topic("record as you go; honest status; fixes are issues", U, ("add_task_log", "in_progress", 'kind="issue"'),
|
||||||
"fixes are issues, not work-logs", index=("add_task_log", 'kind="issue"')),
|
"fixes are issues, not work-logs"),
|
||||||
Topic("an id exists only once a create returns it", U, ("exists only once a create", "{{ref:"),
|
Topic("an id exists only once a create returns it", U, ("exists only once a create", "{{ref:"),
|
||||||
"exists only once a create call returns it", index=("create_records", "{{ref:n}}")),
|
"exists only once a create call returns it"),
|
||||||
Topic("tag records to systems as you write", U, ("system_ids", "create_system"),
|
Topic("tag records to systems as you write", U, ("system_ids", "create_system"),
|
||||||
"would someone investigating that subsystem want this record", index=("system_ids",)),
|
"would someone investigating that subsystem want this record"),
|
||||||
Topic("answer the systems_hint at the moment of work", U, ("systems_hint",),
|
Topic("answer the systems_hint at the moment of work", U, ("systems_hint",),
|
||||||
"treat it as the tagging question asked at the moment of work"),
|
"treat it as the tagging question asked at the moment of work"),
|
||||||
Topic("a retrieved rule outranks a default habit", U, ("outranks a default habit",),
|
Topic("a retrieved rule outranks a default habit", U, ("outranks a default habit",),
|
||||||
@@ -186,11 +189,11 @@ TOPICS: tuple[Topic, ...] = (
|
|||||||
("hand off", "claims it for this session"),
|
("hand off", "claims it for this session"),
|
||||||
"write down what the next session needs"),
|
"write down what the next session needs"),
|
||||||
Topic("the project's design system binds ui", U, ("resolve_design_system",),
|
Topic("the project's design system binds ui", U, ("resolve_design_system",),
|
||||||
"building ui: the project's design system binds", index=("resolve_design_system",)),
|
"building ui: the project's design system binds"),
|
||||||
Topic("name the record, never just its number", U, ("name the record",),
|
Topic("name the record, never just its number", U, ("name the record",),
|
||||||
"a bare id reads as complete to you and as homework to them"),
|
"a bare id reads as complete to you and as homework to them"),
|
||||||
Topic("project inception is a decision", U, ("decide_project_inception",),
|
Topic("project inception is a decision", U, ("decide_project_inception",),
|
||||||
"starting a project: decide what it inherits", index=("decide_project_inception",)),
|
"starting a project: decide what it inherits"),
|
||||||
Topic("where a new rule goes, and its trigger", U, ("create_project_rule", "when_to_apply"),
|
Topic("where a new rule goes, and its trigger", U, ("create_project_rule", "when_to_apply"),
|
||||||
"whichever home it gets"),
|
"whichever home it gets"),
|
||||||
Topic("a rule vs the other entities", U, ("standing instruction",), "first ask whether it's a rule at all"),
|
Topic("a rule vs the other entities", U, ("standing instruction",), "first ask whether it's a rule at all"),
|
||||||
@@ -200,7 +203,7 @@ TOPICS: tuple[Topic, ...] = (
|
|||||||
Topic("rules mounted on a moment arrive by lookup; correct a misfire in-session", U,
|
Topic("rules mounted on a moment arrive by lookup; correct a misfire in-session", U,
|
||||||
("list_moments", "map_action", "unmap_action", "judge_rule_moments"),
|
("list_moments", "map_action", "unmap_action", "judge_rule_moments"),
|
||||||
"it belongs in the session that noticed, not on a settings page",
|
"it belongs in the session that noticed, not on a settings page",
|
||||||
index=("list_moments", "moment")),
|
),
|
||||||
Topic("a new rule about when gets its moments as it is written", U,
|
Topic("a new rule about when gets its moments as it is written", U,
|
||||||
("moments=[...]", "create_process(moments="),
|
("moments=[...]", "create_process(moments="),
|
||||||
"then ask when it applies, as well as what it is about"),
|
"then ask when it applies, as well as what it is about"),
|
||||||
@@ -247,16 +250,16 @@ TOPICS: tuple[Topic, ...] = (
|
|||||||
"which files are which area is your call"),
|
"which files are which area is your call"),
|
||||||
# ── process arcs — owned by their skills ──
|
# ── process arcs — owned by their skills ──
|
||||||
Topic("plan in a milestone, steps created together", "skill:writing-plans", ("start_planning", "{{ref:"),
|
Topic("plan in a milestone, steps created together", "skill:writing-plans", ("start_planning", "{{ref:"),
|
||||||
"a milestone earns its place when the work has an arc", index=("start_planning",)),
|
"a milestone earns its place when the work has an arc"),
|
||||||
# Without this, a session opens a second plan beside the roadmap milestone
|
# Without this, a session opens a second plan beside the roadmap milestone
|
||||||
# that already covers the work.
|
# that already covers the work.
|
||||||
Topic("find the existing plan before making one", "skill:writing-plans",
|
Topic("find the existing plan before making one", "skill:writing-plans",
|
||||||
('content_type="milestone"', "unplanned_milestones", "existing_milestone"),
|
('content_type="milestone"', "unplanned_milestones", "existing_milestone"),
|
||||||
"when an active milestone already covers the work, the plan is that milestone",
|
"when an active milestone already covers the work, the plan is that milestone",
|
||||||
index=('search(content_type="milestone")',)),
|
),
|
||||||
Topic("reuse recorded shapes; record at first build", "skill:reusing-code",
|
Topic("reuse recorded shapes; record at first build", "skill:reusing-code",
|
||||||
("create_snippet", "when_to_use", "first build", "second copy"),
|
("create_snippet", "when_to_use", "first build", "second copy"),
|
||||||
"prior art offered beside a write is not noise", index=("create_snippet",)),
|
"prior art offered beside a write is not noise"),
|
||||||
# The writer judges what it wrote, at the end of the turn,
|
# The writer judges what it wrote, at the end of the turn,
|
||||||
# asked by the plugin's Stop hook — the moment the knowledge exists.
|
# asked by the plugin's Stop hook — the moment the knowledge exists.
|
||||||
Topic("judge what you wrote before the turn ends", "skill:reusing-code",
|
Topic("judge what you wrote before the turn ends", "skill:reusing-code",
|
||||||
@@ -304,7 +307,7 @@ TOPICS: tuple[Topic, ...] = (
|
|||||||
"skill:family-canon",
|
"skill:family-canon",
|
||||||
("family_hint", "get_family_adoption", "resolve_family_conflict", "precedent"),
|
("family_hint", "get_family_adoption", "resolve_family_conflict", "precedent"),
|
||||||
"write the reason so a session in another project can tell whether the same fact holds there",
|
"write the reason so a session in another project can tell whether the same fact holds there",
|
||||||
index=("family-canon",)),
|
),
|
||||||
# ── per-tool contracts and in-band behaviour — owned by the server ──
|
# ── per-tool contracts and in-band behaviour — owned by the server ──
|
||||||
Topic("closing a task cues the report", "docstrings", ("report_back",), "reporting this to the operator?"),
|
Topic("closing a task cues the report", "docstrings", ("report_back",), "reporting this to the operator?"),
|
||||||
# The agent is the judge. Two topics, not one, because they fire
|
# The agent is the judge. Two topics, not one, because they fire
|
||||||
@@ -329,9 +332,9 @@ TOPICS: tuple[Topic, ...] = (
|
|||||||
"it simply stops competing with this one"),
|
"it simply stops competing with this one"),
|
||||||
Topic("deletes are recoverable from the trash", "docstrings", ("deleted_batch_id",), "deleted_batch_id"),
|
Topic("deletes are recoverable from the trash", "docstrings", ("deleted_batch_id",), "deleted_batch_id"),
|
||||||
Topic("creates are duplicate-gated", "docstrings", ("near-duplicate",), "bypass the near-duplicate gate",
|
Topic("creates are duplicate-gated", "docstrings", ("near-duplicate",), "bypass the near-duplicate gate",
|
||||||
index=("duplicate-gated",)),
|
),
|
||||||
Topic("shared records are another user's suggestion", "docstrings", ("shared: true",),
|
Topic("shared records are another user's suggestion", "docstrings", ("shared: true",),
|
||||||
"belongs to another user", index=("shared:true",)),
|
"belongs to another user"),
|
||||||
Topic("stored processes are followed as written", "docstrings", ("get_process",), "follow the returned body"),
|
Topic("stored processes are followed as written", "docstrings", ("get_process",), "follow the returned body"),
|
||||||
Topic("a project is never guessed", "docstrings", ("never guessing a project",), "never guessing a project"),
|
Topic("a project is never guessed", "docstrings", ("never guessing a project",), "never guessing a project"),
|
||||||
Topic("an unbound repo gets a bind hint", "live", ("bind_repo",), "isn't mapped to a grimoire project"),
|
Topic("an unbound repo gets a bind hint", "live", ("bind_repo",), "isn't mapped to a grimoire project"),
|
||||||
|
|||||||
@@ -51,11 +51,11 @@ def _instructions_text() -> str:
|
|||||||
|
|
||||||
# Claude Code injects only the first ~2,048 characters of an MCP server's
|
# Claude Code injects only the first ~2,048 characters of an MCP server's
|
||||||
# instructions and silently cuts the rest mid-word, so guidance past the cap
|
# instructions and silently cuts the rest mid-word, so guidance past the cap
|
||||||
# never reaches a session. The budget is set below the cap, not at it: the
|
# never reaches a session. The budget sits far below the cap: most servers
|
||||||
# field runs ~600–1,600 characters, and
|
# carry a few hundred characters or none, and the block holds only what no
|
||||||
# a block pressed against 2,048 is being used for depth that belongs in a
|
# response or skill delivers, so a block growing toward the cap is carrying
|
||||||
# skill.
|
# depth that belongs in a skill.
|
||||||
INSTRUCTIONS_BUDGET = 1600
|
INSTRUCTIONS_BUDGET = 800
|
||||||
|
|
||||||
|
|
||||||
def test_instructions_fit_the_fold():
|
def test_instructions_fit_the_fold():
|
||||||
|
|||||||
Reference in New Issue
Block a user