Repository navigation
feat(claude/mcp): optional capability filter for genesis-tools MCP #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 13 commits
da0e69a
c26a6df
bc15f8e
de07733
81efb07
0003c2d
62290fd
bf6f20e
6db0de8
19006f0
349a889
6c7d370
76d8e34
d067c01
ac0b854
1823d38
49a794d
31338c4
8bffeaa
85d9376
fa0bc35
07a34aa
22443ad
abd38b7
7ac1ddb
067d76f
8934c32
bcd1dad
b846302
b41b588
2d35604
7035376
8f37b06
6cf5b35
ce8652b
5282fc8
1d4d655
9fbb051
3069477
24bd2ad
6524a96
7c05da0
14ae9ca
806d181
2bb177f
a10f9b5
3c42643
651c3a1
ffc226d
de94c61
147699e
b0d6945
504eae1
dd661b9
16c5b71
294d47b
78858b4
4fc47c9
5a09bde
920c38b
2f38a93
3561061
dd9f83d
be01db4
f5ab3ab
6d64a48
42cc631
c43a5f8
360cf71
d144f63
2d66170
0e381a5
6d6e6da
3049291
282861a
7840cf4
b681abf
a06ff53
087a7af
dd78a66
67b7540
157d611
edf3f62
9d68e6e
8b01f4c
e895468
c6740f4
19989f7
9b50884
21056d2
ef5bfda
02db08d
6f64e57
d580ff2
3c524d9
eea848f
33eb63e
59b864f
5eaf47d
604675c
9cd2bde
edc130e
7beb84d
5c25f43
67b89b5
d312eac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,4 @@ | ||||||||||||||||||||||||||||||||||
| import { readFileSync } from "node:fs"; | ||||||||||||||||||||||||||||||||||
| import { logger, out } from "@app/logger"; | ||||||||||||||||||||||||||||||||||
| import { SafeJSON } from "@app/utils/json"; | ||||||||||||||||||||||||||||||||||
| import type { Command } from "commander"; | ||||||||||||||||||||||||||||||||||
|
|
@@ -16,12 +17,25 @@ interface MessageOpts { | |||||||||||||||||||||||||||||||||
| from?: string; | ||||||||||||||||||||||||||||||||||
| to?: string; | ||||||||||||||||||||||||||||||||||
| body?: string; | ||||||||||||||||||||||||||||||||||
| bodyFile?: string; | ||||||||||||||||||||||||||||||||||
| reply?: string; | ||||||||||||||||||||||||||||||||||
| meta?: string; | ||||||||||||||||||||||||||||||||||
| private?: boolean; | ||||||||||||||||||||||||||||||||||
| session?: string; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| function resolveBody(opts: MessageOpts): string | undefined { | ||||||||||||||||||||||||||||||||||
| if (opts.bodyFile) { | ||||||||||||||||||||||||||||||||||
| if (opts.body) { | ||||||||||||||||||||||||||||||||||
| throw new FriendlyError("--body and --body-file are mutually exclusive", "Pass only one."); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| return readFileSync(opts.bodyFile, "utf8"); | ||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win Normalize the file path and preserve friendly read errors. The new path is passed directly to As per coding guidelines, 🤖 Prompt for AI AgentsSource: Coding guidelines |
||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+27
to
+34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Use option-presence checks, not truthiness.
Proposed fix- if (opts.bodyFile) {
- if (opts.body) {
+ if (opts.bodyFile !== undefined) {
+ if (opts.body !== undefined) {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| return opts.body; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| function parseMeta(raw: string | undefined): Record<string, unknown> { | ||||||||||||||||||||||||||||||||||
| if (!raw) { | ||||||||||||||||||||||||||||||||||
| return {}; | ||||||||||||||||||||||||||||||||||
|
|
@@ -37,7 +51,8 @@ function parseMeta(raw: string | undefined): Record<string, unknown> { | |||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| async function runMessageImpl(opts: MessageOpts): Promise<void> { | ||||||||||||||||||||||||||||||||||
| const hasBody = typeof opts.body === "string" && opts.body.length > 0; | ||||||||||||||||||||||||||||||||||
| const body = resolveBody(opts); | ||||||||||||||||||||||||||||||||||
| const hasBody = typeof body === "string" && body.length > 0; | ||||||||||||||||||||||||||||||||||
| const isAck = !hasBody && Boolean(opts.reply); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if (!hasBody && !isAck) { | ||||||||||||||||||||||||||||||||||
|
|
@@ -94,7 +109,7 @@ async function runMessageImpl(opts: MessageOpts): Promise<void> { | |||||||||||||||||||||||||||||||||
| from_agent_id: sender.agent_id, | ||||||||||||||||||||||||||||||||||
| from_agent_name: sender.agent_name, | ||||||||||||||||||||||||||||||||||
| to_agent_ids: toIds, | ||||||||||||||||||||||||||||||||||
| body: hasBody ? (opts.body as string) : "", | ||||||||||||||||||||||||||||||||||
| body: hasBody ? (body as string) : "", | ||||||||||||||||||||||||||||||||||
| meta, | ||||||||||||||||||||||||||||||||||
| private: Boolean(opts.private), | ||||||||||||||||||||||||||||||||||
| ...(opts.reply ? { in_reply_to: opts.reply } : {}), | ||||||||||||||||||||||||||||||||||
|
|
@@ -112,6 +127,7 @@ async function runMessageImpl(opts: MessageOpts): Promise<void> { | |||||||||||||||||||||||||||||||||
| kind: opts.reply ? (hasBody ? "reply" : "ack") : isBroadcast ? "broadcast" : "direct", | ||||||||||||||||||||||||||||||||||
| in_reply_to: opts.reply ?? null, | ||||||||||||||||||||||||||||||||||
| recipients: isBroadcast ? "(all peers except sender)" : event.to_agent_ids, | ||||||||||||||||||||||||||||||||||
| body_length: event.body.length, | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| { strict: true } | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
|
|
@@ -161,6 +177,10 @@ export function registerMessageCommand(program: Command): void { | |||||||||||||||||||||||||||||||||
| .option("--from <token>", "Sender agent — name or id") | ||||||||||||||||||||||||||||||||||
| .option("--to <csv>", "Recipient agents — comma-separated names or ids; empty = broadcast") | ||||||||||||||||||||||||||||||||||
| .option("--body <text>", "Message body (omit + --reply for pure ack)") | ||||||||||||||||||||||||||||||||||
| .option( | ||||||||||||||||||||||||||||||||||
| "--body-file <path>", | ||||||||||||||||||||||||||||||||||
| "Read message body from a file instead of --body (avoids shell-quoting issues with long/multi-line bodies)" | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+180
to
+183
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Mention The new option is accepted here, but the validation message at Lines 61-62 still says only 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| .option("--reply <msg-id>", "Mark this as a reply to a previous message_id (auto-routes to original sender)") | ||||||||||||||||||||||||||||||||||
| .option("--meta <json>", "Optional JSON object") | ||||||||||||||||||||||||||||||||||
| .option("--private", "Mark as private (v1: stored, not enforced)") | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,23 +8,29 @@ export type ShutdownHandler = (reason: ShutdownReason) => Promise<void> | void; | |
|
|
||
| const handlers: ShutdownHandler[] = []; | ||
| let signalsInstalled = false; | ||
| let shuttingDown = false; | ||
|
|
||
| async function runHandlers(reason: ShutdownReason): Promise<void> { | ||
| if (shuttingDown) { | ||
| return; | ||
| let shutdownRun: Promise<void> | null = null; | ||
|
|
||
| // A single shared promise (not a boolean guard) so a second signal delivered | ||
| // mid-shutdown awaits the in-flight handlers instead of returning immediately | ||
| // and calling process.exit() while they're still running — that killed the | ||
| // process before releaseSlot(), orphaning the PID lock until an unrelated | ||
| // agent's stale-lock sweep reaped it. | ||
| function runHandlers(reason: ShutdownReason): Promise<void> { | ||
| if (!shutdownRun) { | ||
| shutdownRun = (async () => { | ||
| const ordered = [...handlers].reverse(); | ||
|
|
||
| for (const handler of ordered) { | ||
| try { | ||
| await handler(reason); | ||
| } catch (err) { | ||
| log.warn({ err }, "shutdown handler threw"); | ||
| } | ||
| } | ||
| })(); | ||
| } | ||
|
|
||
| shuttingDown = true; | ||
| const ordered = [...handlers].reverse(); | ||
|
|
||
| for (const handler of ordered) { | ||
| try { | ||
| await handler(reason); | ||
| } catch (err) { | ||
| log.warn({ err }, "shutdown handler threw"); | ||
| } | ||
| } | ||
| return shutdownRun; | ||
| } | ||
|
Comment on lines
+11
to
34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win Shared-promise fix looks correct; add a regression test. The synchronous assignment of Since this fixes a subtle concurrency bug, consider adding a unit test (e.g., push two async handlers, call 🤖 Prompt for AI Agents |
||
|
|
||
| function installSignals(): void { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Clarify the shell-quoting explanation.
Backticks and
$(...)are not evaluated inside single-quoted shell arguments; an embedded apostrophe is the character that directly breaks that form. Reword this to avoid implying all three characters behave identically.Suggested wording
📝 Committable suggestion
🧰 Tools
🪛 SkillSpector (2.3.11)
[warning] 77: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.
Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.
(Memory Poisoning (MP2))
[warning] 78: [MP2] Context Window Stuffing: Skill attempts to fill the context window with filler content, displacing legitimate instructions and safety constraints. This can degrade agent performance or bypass safety boundaries.
Remediation: Implement context-window management that detects and rejects padding or stuffing attempts. Prioritize system instructions over user-injected content.
(Memory Poisoning (MP2))
🤖 Prompt for AI Agents