Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/memhub/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "memhub",
"description": "Auto-capture Claude Code sessions into MemHub team memory. A Stop hook ships each turn as it happens \u2014 sending only the transcript bytes written since the last successful flush, so a session is captured even if it never reaches a clean exit \u2014 alongside flushes on commit/PR events (PostToolUse hooks) and a SessionEnd backstop. The memhub MCP runs tool-aware (agentic) extraction of facts, episodes, and artifacts with watermark-based delta dedup, batching extraction so per-turn capture doesn't fragment episodes. A PreToolUse hook surfaces situated team directives (lessons/procedures) before each Edit/Write/Bash by firing the memhub recall_directives symbol-tripwire on the in-flight call and injecting any hits as context (a client-side precision gate drops directives whose triggers don't concretely match the call, e.g. an over-broad repo-name trigger). Includes skills for: plugin install/health (setup), plugin authentication with its own hook credential (login), repo brain creation and seeding (onboard), terminal artifact uploads (save-artifact), on-demand session import (import-session), team-memory recall (search-memory), teammate session handoff (handoff-session), git-authored spec development with ownership frontmatter (spec), Rulebook rule authoring (create-rule), rules proposed from CLAUDE.md and past sessions in one run (start-rulebook), and PR babysitting (pr-babysit) \u2014 a hook arms a self-paced loop after `gh pr create` that fixes review-bot findings and saves the fixing process to the repo's agent brain. Rules live in RULEBOOKS \u2014 containers with their own membership, so a rule reaches exactly the people its book binds, and one person can be bound by several (their org's book plus their team's): the authoring skills resolve which book a rule lands in and offer to create one when there is none, the hooks cache every book that binds you, and when two books fire on one call the wider book's rule is the one the per-call cap keeps. A PostToolUse hook reminds authors when an edited file belongs to a git-authored spec. Spec ownership frontmatter replaces the retired artifact map; the backend maintains read-only mirrors and opens bootstrap or audit PRs. Sessions are named with the title their own host shows \u2014 Claude Code's generated title, or on Codex the thread_name Codex generated (from the rollout, else ~/.codex/session_index.jsonl), passed through verbatim so MemHub's sessions list matches the editor's; a session its host never named falls back to a title derived from its first prompt \u2014 and route into the repo's own agent brain via a per-user room cache (~/.config/memhub-plugin/rooms.json, never written into the repo) \u2014 resolved once by /memhub:onboard and read by every writer, including the two automatic capture paths, so team memory lands in the repo's room instead of personal memory. Session \u2194 PR linking: after a call that addresses GitHub (`gh pr \u2026`, a `curl`/`gh api` REST request, or a GitHub MCP tool) whose output names exactly one pull request, a PostToolUse hook asks the backend one question and injects one instruction \u2014 a session that ran `gh pr create` \u2014 or the GitHub MCP create tool \u2014 links itself unconditionally (opening it is work the session did, and a PR has many sessions), while every other GitHub call, a hand-rolled `curl` POST included, leaves the authorship judgment to the agent, and an org with no GitHub integration is told once that connecting it is what links sessions to shipped code. The hook is stateless apart from one short-lived negative answer (an enabled org with GitHub disconnected, cached 30 minutes per credential, and never inferred from a reply that merely says the feature is off) and degrades to silence on every failure. Two skills complete it: link-pr (link this or a named session by hand \u2014 also the answer for a PR opened by a script or CI helper, which is deliberately not detected) and find-contributing-sessions (map your own unlinked PRs, or the ones you name, to the sessions on this machine that wrote their code: scan local session history once, rank the candidates per PR by the evidence that matched, and link the ones you approve). Every rulebook fire is now disclosed to the user in a fixed shape on two channels: the hook's own terminal line leads with `\ud83d\udccf Rule fired: <the rule>` (`\u26d4\ufe0f` when a gate actually blocked the call) above the detail line it already showed, and the agent is told to echo that same byte-identical line at the top of its reply so the fire reaches the transcript everything downstream reads. Session start now says what rules ARE \u2014 standing instructions from teammates carrying CLAUDE.md's weight \u2014 before listing them. The agent records ONE work type for a pull request it links (feat, fix, chore, docs, perf, refactor, other), and only when the PR has none yet \u2014 the first label is permanent, and asking again would cost the link, not just the type. Spec workflows: spec-work guides implementation, spec-check freshly reviews changes, and spec-maintain offers local/cloud bootstrap and reviewable Git or Brain proposals through the shared spec entry point. A companion animal draws what the plugin is doing in the band above the prompt: asleep while the session is idle, awake and watching while Claude answers or the person types, and up announcing each Rulebook rule that fires \u2014 crossly when one blocked the call. It needs Claude Code's function-hook runtime, which /memhub:companion turns on and persists.",
"version": "0.87.0",
"version": "0.88.0",
"license": "Apache-2.0",
"hooks": ["./hooks/claude-hooks.json", "./companion/hooks.json"],
"author": {
Expand Down
2 changes: 1 addition & 1 deletion plugins/memhub/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "memhub",
"description": "XTrace MemHub team memory in Codex: automatic session capture, situated directive recall, artifact sync, plus skills for setup, login, onboarding, artifact upload, session import, search, handoff, spec-driven development, Rulebook rule authoring (create-rule) and a team's first Rulebook — tested starter rules fitted to the repo, and rules proposed from CLAUDE.md + past sessions (start-rulebook), and PR babysitting. A rule lives in a RULEBOOK \u2014 a container with its own membership, so it reaches exactly the people that book binds; the authoring skills resolve which book it lands in and offer to create one when there is none. Run memhub:setup to verify hook routing and authentication. Current desktop builds support bundled hooks; older hosts need the user bridge. Bundled handlers defer to matching installed user bridge handlers, which require trust. Codex's own threads are not captured as your sessions: spawned subagents, guardian action-reviews and memory consolidation are recognised from the rollout's thread_source and skipped by name, while every other kind \u2014 including a product surface we have not seen, since Codex's ThreadSource type is open-ended \u2014 is captured, because refusing an unknown kind would silently and unrecoverably drop real work. Every rule fire is reported under the same namespaced session id capture uploads, so a fire is linked to the Codex session it fired in. Session \u2194 PR linking: after a call that addresses GitHub (`gh pr \u2026`, a `curl`/`gh api` REST request, or a GitHub MCP tool) whose output names exactly one pull request, a PostToolUse hook asks the backend one question and injects one instruction \u2014 a session that ran `gh pr create` \u2014 or the GitHub MCP create tool \u2014 links itself unconditionally (opening it is work the session did, and a PR has many sessions), while every other GitHub call, a hand-rolled `curl` POST included, leaves the authorship judgment to the agent, and an org with no GitHub integration is told once that connecting it is what links sessions to shipped code. The hook is stateless apart from one short-lived negative answer (an enabled org with GitHub disconnected, cached 30 minutes per credential, and never inferred from a reply that merely says the feature is off) and degrades to silence on every failure. Two skills complete it: link-pr (link this or a named session by hand \u2014 also the answer for a PR opened by a script or CI helper, which is deliberately not detected) and find-contributing-sessions (map your own unlinked PRs, or the ones you name, to the sessions on this machine that wrote their code: scan local session history once, rank the candidates per PR by the evidence that matched, and link the ones you approve). The agent records ONE work type for a pull request it links (feat, fix, chore, docs, perf, refactor, other), and only when the PR has none yet \u2014 the first label is permanent, and asking again would cost the link, not just the type. Spec workflows: spec-work guides implementation, spec-check freshly reviews changes, and spec-maintain offers local/cloud bootstrap and reviewable Git or Brain proposals through the shared spec entry point. A companion animal draws what the plugin is doing in the band above the prompt: asleep while the session is idle, awake and watching while Claude answers or the person types, and up announcing each Rulebook rule that fires \u2014 crossly when one blocked the call. It needs Claude Code's function-hook runtime, which /memhub:companion turns on and persists.",
"version": "0.87.0",
"version": "0.88.0",
"license": "Apache-2.0",
"author": {
"name": "XTrace",
Expand Down
2 changes: 1 addition & 1 deletion plugins/memhub/.cursor-plugin/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "memhub",
"displayName": "MemHub",
"description": "XTrace MemHub team memory in Cursor: search_memory / save_artifact / import_conversation tools plus skills for setup, login, onboarding, artifact upload, session import, recall, handoff, spec-driven development, Rulebook rule authoring (create-rule) and a team's first Rulebook — tested starter rules fitted to the repo, and rules proposed from CLAUDE.md + past sessions (start-rulebook), and PR babysitting. A rule lives in a RULEBOOK \u2014 a container with its own membership, so it reaches exactly the people that book binds; the authoring skills resolve which book it lands in and offer to create one when there is none. Sessions are captured automatically. Session \u2194 PR linking ships as skills on Cursor: link-pr and find-contributing-sessions. Cursor's shell hooks are observational \u2014 `afterShellExecution` defines no reply the agent can see \u2014 so the automatic post-`gh pr create` link that Claude Code and Codex get is not available here. The agent records ONE work type for a pull request it links (feat, fix, chore, docs, perf, refactor, other), and only when the PR has none yet \u2014 the first label is permanent, and asking again would cost the link, not just the type. Spec workflows: spec-work guides implementation, spec-check freshly reviews changes, and spec-maintain offers local/cloud bootstrap and reviewable Git or Brain proposals through the shared spec entry point. A companion animal draws what the plugin is doing in the band above the prompt: asleep while the session is idle, awake and watching while Claude answers or the person types, and up announcing each Rulebook rule that fires \u2014 crossly when one blocked the call. It needs Claude Code's function-hook runtime, which /memhub:companion turns on and persists.",
"version": "0.87.0",
"version": "0.88.0",
"license": "Apache-2.0",
"author": {
"name": "XTrace"
Expand Down
2 changes: 1 addition & 1 deletion plugins/memhub/.mcp.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "http",
"url": "https://api.memhub.xtrace.ai/mcp-server/mcp",
"headers": {
"X-MemHub-Plugin-Version": "0.87.0"
"X-MemHub-Plugin-Version": "0.88.0"
},
"headersHelper": "python3 -s -E \"${CLAUDE_PLUGIN_ROOT}/scripts/mcp_headers.py\"",
"auth": {
Expand Down
2 changes: 1 addition & 1 deletion plugins/memhub/mcp.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "streamable-http",
"url": "https://api.memhub.xtrace.ai/mcp-server/mcp",
"headers": {
"X-MemHub-Plugin-Version": "0.87.0"
"X-MemHub-Plugin-Version": "0.88.0"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/memhub/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
"name": "memhub",
"description": "XTrace MemHub team memory: search_memory / save_artifact / import_conversation MCP tools plus skills for setup, login, onboarding, artifact upload, session import, team-memory recall, session handoff, spec-driven development, Rulebook rule authoring (create-rule) and a team's first Rulebook — tested starter rules fitted to the repo, and rules proposed from CLAUDE.md + past sessions (start-rulebook), and PR babysitting. A rule lives in a RULEBOOK \u2014 a container with its own membership, so it reaches exactly the people that book binds; the authoring skills resolve which book it lands in and offer to create one when there is none. Session auto-capture ships through the host-native plugin layer (hooks are outside the Agent Plugins spec). Session \u2194 PR linking: after a call that addresses GitHub (`gh pr \u2026`, a `curl`/`gh api` REST request, or a GitHub MCP tool) whose output names exactly one pull request, a PostToolUse hook asks the backend one question and injects one instruction \u2014 a session that ran `gh pr create` \u2014 or the GitHub MCP create tool \u2014 links itself unconditionally (opening it is work the session did, and a PR has many sessions), while every other GitHub call, a hand-rolled `curl` POST included, leaves the authorship judgment to the agent, and an org with no GitHub integration is told once that connecting it is what links sessions to shipped code. The hook is stateless apart from one short-lived negative answer (an enabled org with GitHub disconnected, cached 30 minutes per credential, and never inferred from a reply that merely says the feature is off) and degrades to silence on every failure. Two skills complete it: link-pr (link this or a named session by hand \u2014 also the answer for a PR opened by a script or CI helper, which is deliberately not detected) and find-contributing-sessions (map your own unlinked PRs, or the ones you name, to the sessions on this machine that wrote their code: scan local session history once, rank the candidates per PR by the evidence that matched, and link the ones you approve). The agent records ONE work type for a pull request it links (feat, fix, chore, docs, perf, refactor, other), and only when the PR has none yet \u2014 the first label is permanent, and asking again would cost the link, not just the type. Spec workflows: spec-work guides implementation, spec-check freshly reviews changes, and spec-maintain offers local/cloud bootstrap and reviewable Git or Brain proposals through the shared spec entry point. A companion animal draws what the plugin is doing in the band above the prompt: asleep while the session is idle, awake and watching while Claude answers or the person types, and up announcing each Rulebook rule that fires \u2014 crossly when one blocked the call. It needs Claude Code's function-hook runtime, which /memhub:companion turns on and persists.",
"version": "0.87.0",
"version": "0.88.0",
"license": "Apache-2.0",
"author": {
"name": "XTrace",
Expand Down
15 changes: 12 additions & 3 deletions plugins/memhub/scripts/rulebook_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,13 @@ def matcher_unsupported(m):

_RX_KEYS = ("rx", "not_rx", "body_rx", "cmd_rx", "cmd_not_rx", "path_rx", "path_not_rx",
"content_rx", "content_not_rx", "exclude_rx", "converted_rx")
_RX_MAX = 400
# Length is a bound on what one rule can cost to compile and store, NOT the
# backtracking guard — `_RX_NESTED` below is. A 60-character pattern can stall
# and a 1,500-character alternation of literal paths cannot, so the bound is
# wide enough for the second. It was 400 before 0.88.0: a hook older than that
# drops any rule carrying a longer pattern, which is why the server floors such
# a rule at `min_hook_version` 0.88.0.
_RX_MAX = 2000

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Synchronize the authoring tools with the new regex limit

Raising only the hook limit leaves the shipped authoring flow enforcing the old value: plugins/memhub/skills/start-rulebook/scripts/starter_rulebook.py:51,96-103,694-696 still truncates repo-derived alternations around 360 characters and reports every seeded pattern over 400 as a load failure. Consequently, repositories with enough generated/ignored/secret paths cannot benefit from the newly supported 401–2000-character patterns—the generator either omits paths or rejects an otherwise loadable rule. The create-rule guidance at plugins/memhub/skills/create-rule/SKILL.md:460-463 also still tells authors that such patterns are silently dropped.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 8d6d768: starter_rulebook.py RX_MAX is 2000 and _fit cites it instead of a literal; create-rule SKILL.md LOAD line says 2000.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Catch parser recursion before raising the regex limit

Raising this bound newly lets deeply nested patterns reach re.compile, but rx_ok catches only re.error; for example, "(" * 500 + "a" + ")" * 500 is 1,001 characters and raises RecursionError on supported Python versions. The live loader happens to swallow this through to_hook_rule's outer exception handler, but rulebook_verify.py::_load_failure calls H.rx_ok directly, so verifying such a candidate now terminates with a traceback instead of reporting LOAD FAIL. Catch RecursionError (or otherwise bound nesting) before accepting the expanded length range.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed on 3.9 and 3.12: the 1,001-char nested pattern raises RecursionError, not re.error. rx_ok now catches both; covered in rulebook_hook_test.py (rule drops, no traceback) and rulebook_verify_test.py (reports LOAD FAIL, no traceback). 8d6d768.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject optional-token regexes that backtrack catastrophically

With the new bound, a rule such as command_rx = "a?" * 134 + "a" * 134 + "$" is 403 characters and passes both rx_ok and _RX_NESTED, although matching it against a command of 134 as causes exponential backtracking in evaluate's synchronous re.search. It was rejected by the old 400-character check; now it can make each PreToolUse check run until the 5-second hook timeout (and skip enforcement), so the newly allowed range needs a safe matching limit or lint that rejects this shape.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Real shape, but not one the length bound ever guarded: "a?" * n + "a" * n + "$" at n=22 is 67 characters and already takes 0.33s against 22 a-characters; n=26 (79 chars) clears the 5-second hook timeout. The 400 bound refused the 403-character example while admitting the 79-character one — which is the PR premise: length is not the backtracking guard, _RX_NESTED is a denylist and the hook comment names a bounded matcher (worker + wall clock, §5.1 Phase 2) as the real fix. Not changed here; the bounded matcher is its own PR.

# (a+)+, (\d+)+$, (a|a)+, (.*), .*.* — the classic backtracking shapes. A
# denylist, not a proof: stdlib `re` has no timeout, and a bounded matcher
# (worker + wall clock) is the Phase 2 answer named in §5.1.
Expand All @@ -1933,14 +1939,17 @@ def matcher_unsupported(m):

def rx_ok(pat):
"""Load-time lint for a pattern that came off the wire (§5.1 fallback):
must compile, stay short, and avoid the nested-quantifier shapes that
must compile, stay under `_RX_MAX`, and avoid the nested-quantifier shapes that
backtrack catastrophically. A rejected pattern drops the RULE, never the
hook — a server book can advise, it cannot stall a tool call."""
if not isinstance(pat, str) or len(pat) > _RX_MAX or _RX_NESTED.search(pat):
return False
try:
re.compile(pat)
except re.error:
except Exception:
# Not only `re.error`: a deeply nested pattern raises RecursionError
# and `a{99999999999}` raises OverflowError. Whatever the parser
# objects to, the answer is the same — this pattern does not load.
return False
return True

Expand Down
2 changes: 1 addition & 1 deletion plugins/memhub/skills/create-rule/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ raised the subject.
It exits non-zero until every case behaves. **Do not file a rule while it
exits non-zero, and show the table to the user.** What each line means:

- **LOAD** — whether the hook would load the rule at all. A pattern over 400
- **LOAD** — whether the hook would load the rule at all. A pattern over 2000
characters, one that does not compile, or one that backtracks is dropped
*silently* on every teammate's machine: the rule exists, is active, and
never fires. This line is the only warning you get.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
# Written without a quantified group: the hook's load lint drops those.
# `/usr/bin/git` is the same program: a path in front of it is not a way round every git rule.
GIT = CMD + r"(?:sudo\s+)?(?:\S*/)?git\s+(?:-[cC]\s*\S+\s+)?"
RX_MAX = 400
RX_MAX = 2000 # the hook's `_RX_MAX` since 0.88.0; the server floors a pattern over 400 at that version
# Appended to a command pattern to make it a RECEIPT: the command, but not an invocation that exits 0
# having done none of the work — `pytest --version`, `eslint --help`, `pytest --collect-only`.
_RAN_NOTHING = (r"\b(?![^|;&]*\s(?:--version|-V|--help|-h|--collect-only|--co|--fixtures|--markers|--setup-plan"
Expand Down Expand Up @@ -96,7 +96,7 @@ def _alt(parts) -> str:

def _fit(prefix: str, extras: list[str], suffix: str = "") -> str:
"""Append alternatives while the whole pattern stays loadable. The hook
drops a rule whose pattern passes 400 characters, silently, so a long
drops a rule whose pattern passes `RX_MAX` characters, silently, so a long
repo-derived list is cut here rather than shipped dead."""
rx = prefix
for e in extras:
Expand Down
Loading
Loading