@stigmer/coding-agent-plugin 0.3.1 → 0.4.0

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/README.md CHANGED
@@ -54,15 +54,26 @@ one is for the coding agent on a person's laptop.
54
54
  first, a service account's key saved to a file and never shown.
55
55
  - `plugin/.mcp.json`: the bundled `stigmer mcp-server`, for making, running and
56
56
  reading agents once setup is done.
57
- - `plugin/hooks/`: the guard. `hooks.json` is Claude Code's: a `PreToolUse`
58
- hook (`guard.mjs`, deciding in `decide.mjs`) that asks the person before a
59
- destructive tool, before answering a run's approval with allow, and before a
60
- `stigmer` command forced past its own question, even after they allowed the
61
- plugin's tools. Codex and Cursor each load `hooks/hooks.json` when their
62
- manifest names no hooks file, and would run Claude Code's hook wrongly, so
63
- their manifests name an empty file each (`codex-hooks.json`,
64
- `cursor-hooks.json`). Codex asks before the tools from their marks
65
- (`mcp-server/src/domains/toolmarks.ts`).
57
+ - `plugin/hooks/`: the guard. It asks the person before a destructive tool,
58
+ before answering a run's approval with allow, and before a `stigmer` command
59
+ forced past its own question, even after they allowed the plugin's tools.
60
+ `decide.mjs` holds the one decision (`reasonFor`) and each tool's side:
61
+ - `hooks.json` is Claude Code's: a `PreToolUse` hook (`guard.mjs`, through
62
+ `decide`);
63
+ - `cursor-hooks.json` is Cursor's: `beforeShellExecution` alone
64
+ (`cursor-guard.mjs`, through `decideCursor`), the one event on which Cursor
65
+ turns an `ask` into a prompt. Its MCP executor acts on a
66
+ `beforeMCPExecution` answer only when it is `deny`, and any MCP hook makes it
67
+ refuse every server's call that carries a file path, so the plugin hooks no
68
+ MCP call there and Cursor's own tool approval asks before the tool server's
69
+ tools. Both entries fail open. A Cursor run that allows every command
70
+ (`agent -p --force`) passes over an ask, as the person chose;
71
+ - Codex's hooks cannot ask, so `codex-hooks.json` is empty and Codex asks
72
+ before the tools from their marks (`mcp-server/src/domains/toolmarks.ts`).
73
+
74
+ Each tool would load `hooks/hooks.json` when its manifest names no hooks
75
+ file, and would run Claude Code's hook wrongly, so Codex's and Cursor's
76
+ manifests each name their own file.
66
77
  - The manifests and marketplace files of each tool, one plugin named `stigmer`
67
78
  at the folder's root: `.claude-plugin/` (Claude Code), `.cursor-plugin/`
68
79
  (Cursor), `.codex-plugin/plugin.json` and `.agents/plugins/marketplace.json`
@@ -143,12 +154,11 @@ the person's words, and `graders/`:
143
154
  opposite, denies it or warns against it does not do it:", then names the
144
155
  wrong claim exactly. A line that is a judgement ("runs Claude Managed
145
156
  Agents down", "a price other than these") says in its point what does not
146
- count ("saying plainly what it lacks", "leaving a price out"). Cases whose
147
- job has not been re-probed since still open with the older "PASS unless
148
- the answer does this:"; a job moves when its cases are next scored, after
149
- the same probe: its misgraded answers and a wrong answer for each line,
150
- through `claude plugin eval` on a scratch plugin whose case repeats a
151
- given answer word for word;
157
+ count ("saying plainly what it lacks", "leaving a price out"). The question
158
+ was probed once (misgraded answers and a wrong answer for each line,
159
+ through `claude plugin eval` on a scratch plugin whose case repeats a given
160
+ answer word for word); every job then moved to it, each line re-read
161
+ against the docs and the job scored by the bank;
152
162
  - `cites-the-page.md`: the answer links a page that answers it, as published
153
163
  (`stigmer\.ai/docs/<page>`, or several as `stigmer\.ai/docs/(<page>|<page>)`;
154
164
  a link to the docs' source on GitHub doesn't count). The list names every
@@ -165,7 +175,10 @@ the person's words, and `graders/`:
165
175
  when the agent asks the person first.
166
176
 
167
177
  `make bank-coding-agent` (`test/install/coding-agent-bank.mjs`) runs the bank
168
- in Claude Code, with the plugin and without it, against a hermetic local
178
+ in Claude Code, with the plugin and without it, on the plugin as a release
179
+ publishes it (the CLI's pack carries the package, and the plugin is copied
180
+ from the stage's own `node_modules/@stigmer/coding-agent-plugin/plugin/`,
181
+ stamped with the pack's version), against a hermetic local
169
182
  Stigmer seeded with `evals/_fixture/` (an agent with a finished run, one whose
170
183
  runs fail, a skill), its runner on the fake model, and prints the score per
171
184
  job. An acting try starts in a set-up person's project: the fixture agents'
@@ -176,7 +189,17 @@ and the command exits non-zero, so such a run is never taken as a score. It
176
189
  calls a real
177
190
  model on your own Claude Code sign-in, so it is by hand, in no lane;
178
191
  `BANK_ARGS` narrows it (`--tag=<job>`, `--case=<glob>`, `--runs=<n>`) and
179
- bounds it (`--max-cost-usd`, default $60 API-equivalent).
192
+ bounds it (`--max-cost-usd`, default $60 API-equivalent). When passing a
193
+ `{a,b}` glob through `make`, quote it or call the script directly: the shell
194
+ expands an unquoted brace into separate `--case` arguments and only the last
195
+ is kept.
196
+
197
+ The bank is proven in one coding agent, Claude Code. Codex and Cursor read the
198
+ same skills, tool server and docs, so an answer proven there carries over; what
199
+ differs between the tools is how each loads the plugin (its manifest, its hooks
200
+ file), and that is held by this package's unit tests, not by a bank run in each
201
+ tool. A problem a person reports in Codex or Cursor is fixed when it is
202
+ reported.
180
203
 
181
204
  To add a case: write the question in the person's own words under its job's
182
205
  folder, read the docs page that answers it, and write the rubric from that
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stigmer/coding-agent-plugin",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Stigmer's plugin for coding agents (Claude Code, Codex, Cursor): a skill that answers questions about Stigmer from its live docs, the guide that sets Stigmer up for a project, the bundled stigmer mcp-server and a guard that asks before what can't be undone, published at the CLI's own version so `stigmer coding-agent` prints the guide its CLI follows",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stigmer",
3
3
  "displayName": "Stigmer",
4
- "version": "0.3.1",
4
+ "version": "0.4.0",
5
5
  "description": "Stigmer in your coding agent: answers any question about Stigmer from its live docs, citing the page; sets Stigmer up for your project; designs, runs and fixes agents and reads their results; puts them in your own product; and runs your own server and organization. It asks you before anything that can't be undone.",
6
6
  "author": {
7
7
  "name": "Stigmer",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stigmer",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Stigmer in your coding agent: answers any question about Stigmer from its live docs, citing the page; sets Stigmer up for your project; designs, runs and fixes agents and reads their results; puts them in your own product; and runs your own server and organization. It asks you before anything that can't be undone.",
5
5
  "author": {
6
6
  "name": "Stigmer",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stigmer",
3
3
  "displayName": "Stigmer",
4
- "version": "0.3.1",
4
+ "version": "0.4.0",
5
5
  "description": "Stigmer in your coding agent: answers any question about Stigmer from its live docs, citing the page; sets Stigmer up for your project; designs, runs and fixes agents and reads their results; puts them in your own product; and runs your own server and organization. It asks you before anything that can't be undone.",
6
6
  "author": {
7
7
  "name": "Stigmer"
package/plugin/README.md CHANGED
@@ -56,9 +56,12 @@ hosted server instead: https://stigmer.ai/docs/guides/editors/connect-mcp
56
56
  (`*.stigmer.ai`), your own server at its own address, or `stigmer up` on your
57
57
  machine. They use that sign-in; the plugin holds no credential.
58
58
  - **stigmer.ai**, for the docs it reads and cites.
59
- - **A Node script** (`hooks/guard.mjs`, in Claude Code) that reads the call your
60
- coding agent is about to make and, for the acts above, asks you first. It reads
61
- nothing else, writes nothing and reaches no network.
59
+ - **A Node script** that reads the call your coding agent is about to make and, for
60
+ the acts above, asks you first: `hooks/guard.mjs` in Claude Code, for the tool
61
+ server's tools and `stigmer` commands; `hooks/cursor-guard.mjs` in Cursor, for
62
+ `stigmer` commands, where Cursor's own tool approval covers the tool server's
63
+ tools. It reads nothing else, writes nothing and reaches no network. Codex asks
64
+ from the tools' own marks.
62
65
  - **Skills**: Markdown instructions your coding agent reads.
63
66
 
64
67
  Nothing else. The manifest's `network.hosts` names stigmer.ai; your own server's
@@ -0,0 +1,23 @@
1
+ // Cursor's beforeShellExecution hook for Stigmer's plugin: reads the shell
2
+ // line from stdin and prints decideCursor()'s answer
3
+ // (decide.mjs). It fails open: on any error of its own it prints `{}`, which
4
+ // leaves the call to Cursor's own permissions, and exits 0. `failClosed`
5
+ // stays off in cursor-hooks.json for the same reason: a fault in the guard
6
+ // must not stop every `stigmer` command.
7
+ import { decideCursor } from "./decide.mjs";
8
+
9
+ /* v8 ignore start -- @preserve: Cursor's entry, which __tests__/guard.test.ts runs in a child process that this suite's coverage can't see */
10
+ let input = "";
11
+ process.stdin.setEncoding("utf8");
12
+ process.stdin.on("data", (chunk) => (input += chunk));
13
+ process.stdin.on("end", () => {
14
+ let answer = {};
15
+ try {
16
+ answer = decideCursor(JSON.parse(input));
17
+ } catch {
18
+ // Fail open: Cursor's own permissions still decide.
19
+ }
20
+ process.stdout.write(`${JSON.stringify(answer)}\n`);
21
+ process.exitCode = 0;
22
+ });
23
+ /* v8 ignore stop */
@@ -1 +1,6 @@
1
- {"version": 1, "hooks": {}}
1
+ {
2
+ "version": 1,
3
+ "hooks": {
4
+ "beforeShellExecution": [{ "command": "node \"${CURSOR_PLUGIN_ROOT}/hooks/cursor-guard.mjs\"" }]
5
+ }
6
+ }
@@ -1,6 +1,15 @@
1
- // What the plugin's Claude Code guard (guard.mjs, a PreToolUse hook) decides
2
- // about one tool call: ask the person first, or say nothing and let Claude
3
- // Code's own permissions decide.
1
+ // What the plugin's guard decides about one call: ask the person first, or
2
+ // say nothing and let the coding agent's own permissions decide. The
3
+ // decision is the tool's own (reasonFor); each coding agent's side reads its
4
+ // hook input and writes its answer: decide() for Claude Code's PreToolUse
5
+ // hook (guard.mjs), decideCursor() for Cursor's beforeShellExecution hook
6
+ // (cursor-guard.mjs). Cursor turns a shell hook's `ask` into a prompt, but
7
+ // acts on a beforeMCPExecution answer only when it is `deny`, and any MCP
8
+ // hook makes it refuse every server's tool call that carries a file path
9
+ // (read in cursor-agent 2026.11.19's bundled executor), so the plugin hooks
10
+ // no MCP call there: Cursor's own tool approval asks before the tool
11
+ // server's tools. Codex's hooks cannot ask, so Codex asks from the tool
12
+ // server's own marks.
4
13
  //
5
14
  // It asks before an act that can't be undone, or that is the person's to
6
15
  // give, even when they once chose "always allow" for the plugin's tools:
@@ -58,8 +67,20 @@ const VALUE_GLOBALS = new Set(["--org", "--api-key"]);
58
67
  const AGENT_LINE = "If the person hasn't approved exactly this in the conversation, stop and ask them first.";
59
68
 
60
69
  /**
61
- * The hook's answer to one PreToolUse input: an `ask` with its reason, or
62
- * `null` to say nothing. Never throws.
70
+ * Why to ask before one call, whichever coding agent makes it, or null:
71
+ * `{ kind: "tool", name, args }` for a tool of this plugin's server (`name`
72
+ * bare, as the server names it), `{ kind: "shell", command }` for a shell
73
+ * line. Throws only on hostile input; each side catches.
74
+ */
75
+ export function reasonFor(call) {
76
+ if (call.kind === "shell") return shellReason(call.command);
77
+ if (call.kind === "tool") return toolReason(call.name, call.args);
78
+ return null;
79
+ }
80
+
81
+ /**
82
+ * Claude Code's side: the answer to one PreToolUse input, an `ask` with its
83
+ * reason, or `null` to say nothing. Never throws.
63
84
  */
64
85
  export function decide(input) {
65
86
  try {
@@ -68,17 +89,34 @@ export function decide(input) {
68
89
  const args = input.tool_input !== null && typeof input.tool_input === "object" ? input.tool_input : {};
69
90
  if (tool === "Bash") {
70
91
  const command = typeof args.command === "string" ? args.command : "";
71
- const reason = shellReason(command);
92
+ const reason = reasonFor({ kind: "shell", command });
72
93
  return reason === null ? null : ask(reason);
73
94
  }
74
95
  if (!tool.startsWith(TOOL_PREFIX)) return null;
75
- const reason = toolReason(tool.slice(TOOL_PREFIX.length), args);
96
+ const reason = reasonFor({ kind: "tool", name: tool.slice(TOOL_PREFIX.length), args });
76
97
  return reason === null ? null : ask(reason);
77
98
  } catch {
78
99
  return null;
79
100
  }
80
101
  }
81
102
 
103
+ /**
104
+ * Cursor's side: the answer to one beforeShellExecution input, `{
105
+ * permission: "ask", user_message, agent_message }`, or `{}` to say
106
+ * nothing. Any other event says nothing. Never throws. Cursor asks the
107
+ * person in its window; a run that allows every command (`--force`) passes
108
+ * over an ask, which is the person's own choice.
109
+ */
110
+ export function decideCursor(input) {
111
+ try {
112
+ if (input === null || typeof input !== "object" || input.hook_event_name !== "beforeShellExecution") return {};
113
+ const reason = reasonFor({ kind: "shell", command: typeof input.command === "string" ? input.command : "" });
114
+ return reason === null ? {} : { permission: "ask", user_message: reason, agent_message: `${reason} ${AGENT_LINE}` };
115
+ } catch {
116
+ return {};
117
+ }
118
+ }
119
+
82
120
  function ask(reason) {
83
121
  return {
84
122
  hookSpecificOutput: {
@@ -1,21 +1,21 @@
1
1
  ---
2
2
  name: stigmer-integrate
3
3
  description: >
4
- Puts the person's Stigmer agent into their own product, whatever their
5
- stack: calls it from their backend (TypeScript, Python, Go or Java),
6
- streams its reply to their page, puts the chat in their React app and
7
- makes it wear their brand, signs their users in (their own sign-in,
8
- Auth0, Okta, Clerk), decides whose conversation a run becomes, walls
9
- each business customer off in an organization of its own, answers
10
- approvals in their own screens, and moves code off Claude Managed
11
- Agents. Use when the person says "call our agent from our backend",
12
- "when a customer uploads X, run the agent on it", "stream the reply to
13
- the page", "put the chat in our app", "make it look like us", "our
14
- users are signed in with Auth0", "each customer must be separate",
15
- "approve in our own dashboard" or "we're on Claude Managed Agents". To
16
- set Stigmer up first, use the stigmer-setup skill; to run an agent or
17
- read its runs, the stigmer-run skill; for questions about Stigmer
18
- itself, the stigmer skill.
4
+ Puts the person's Stigmer agent into their own product: calls it from
5
+ their backend (TypeScript, Python, Go or Java), streams its reply to
6
+ their page, puts the chat in their React app with their own look, cards
7
+ and tools, signs their users in (their own sign-in, Auth0, Okta, Clerk),
8
+ decides whose conversation a run becomes, walls each business customer
9
+ off in an organization of its own, answers approvals in their own
10
+ screens, and moves code off Claude Managed Agents. Use when the person
11
+ says "call our agent from our backend", "when a customer uploads X, run
12
+ the agent on it", "stream the reply to the page", "make the chat look
13
+ and act like ours", "show our own card when our tool runs", "let the
14
+ agent open our screens", "our users are signed in with Auth0", "each
15
+ customer must be separate", "approve in our own dashboard" or "we're on
16
+ Claude Managed Agents". To set Stigmer up, use the stigmer-setup skill;
17
+ to run an agent or read its runs, the stigmer-run skill; for questions
18
+ about Stigmer, the stigmer skill.
19
19
  ---
20
20
 
21
21
  # Putting a Stigmer agent in the person's product
@@ -55,7 +55,7 @@ Find these before you answer or write anything. Each one changes the code.
55
55
  request names the signed-in user.
56
56
 
57
57
  Then check what their installed SDK has before you write against it:
58
- `npm ls @stigmer/client`, `pip show stigmer-sdk`, the `go.stigmer.ai/sdk`
58
+ `npm ls @stigmer/client @stigmer/react-sdk`, `pip show stigmer-sdk`, the `go.stigmer.ai/sdk`
59
59
  line in `go.mod`, the `stigmer-sdk` dependency in their build file. The
60
60
  docs follow Stigmer's newest code: when a page shows something their
61
61
  installed SDK lacks, say it is newer than their version and that upgrading
@@ -154,19 +154,52 @@ https://stigmer.ai/docs/getting-started/embed-agent, https://stigmer.ai/docs/gui
154
154
  - Allowed origins in the embedding settings restrict which pages may use
155
155
  the tokens.
156
156
 
157
- ### Make the chat wear their brand
158
-
159
- Their colours, font and dark mode go on a theme class that overrides the
160
- `--stgm-*` tokens, applied through `StigmerProvider`; dark mode follows
161
- their own toggle through `colorMode`, and every token they override needs a
162
- dark value too. Parts of the chat (the approval card, message rows) are
163
- replaced through slots (`threadSlots` on `AgentChat`), each receiving the
164
- built-in's props; a chat in markup entirely their own is built from the
165
- `@stigmer/react-core` hooks. Pages: https://stigmer.ai/docs/sdk/theme/theming, https://stigmer.ai/docs/sdk/theme/presets,
166
- https://stigmer.ai/docs/sdk/theme/tokens, https://stigmer.ai/docs/sdk/react-core/build-a-chat.
157
+ ### Make the chat their own
158
+
159
+ Climb only as far as the ask needs; each level keeps everything below it
160
+ Stigmer's. Pages: https://stigmer.ai/docs/getting-started/make-the-chat-your-own,
161
+ https://stigmer.ai/docs/sdk/theme/theming,
162
+ https://stigmer.ai/docs/guides/channels/embed-an-agent,
163
+ https://stigmer.ai/docs/sdk/react-core/build-a-chat,
164
+ https://stigmer.ai/docs/sdk/streaming.
165
+
166
+ 1. **Their look**: a theme class overriding the `--stgm-*` tokens (color
167
+ with its `-foreground` partner, font, radius), passed as `className` to
168
+ `StigmerProvider`, with `colorMode` from their own toggle or `"system"`;
169
+ every token they override needs a dark value too.
170
+ 2. **Their card or their button on our parts**: a card for one of their
171
+ tools goes in `toolCards` on `StigmerProvider`, keyed by the tool's name
172
+ as the agent sees it (`mcp__<server>__<tool>` for a connected server's
173
+ tool, the declared name for one of the app's own). It replaces only what
174
+ opens under our row: the row's step line (running, done or failed) and
175
+ any approval stay ours. It is drawn from the call's start, so it draws
176
+ every state (`call.state`: running, completed, failed, stopped), never
177
+ only a result. An action on a message
178
+ (`messageActions` on `AgentChat`) is a function from the message's info,
179
+ `isFinalAnswer` included, to their actions, drawn beside Copy.
180
+ 3. **Tools their app answers**: the agent calls the app's own tools,
181
+ declared with `defineCustomTool` (`@stigmer/client`) in `AgentChat`'s
182
+ `customTools`. A call waits until the app answers: the card's `answer`,
183
+ `onCustomToolUse` for a panel of their own, or `answerCustomToolUse`
184
+ from their backend. The agent reads the answer; `isError` tells it the
185
+ tool failed.
186
+ 4. **One of our parts swapped**: `threadSlots` replaces a part (the
187
+ person's bubble, the approval card) with theirs, which hands every case
188
+ it doesn't draw back to the built-in, exported from
189
+ `@stigmer/react-sdk/chat` too.
190
+ 5. **Their whole screen**: their own markup from the `@stigmer/react-core`
191
+ hooks (`useSessionConversation`); then the TypeScript SDK alone.
167
192
 
168
193
  - Never override the kit's internal class names, use `!important`, or fork
169
- the kit: tokens and slots are the contract.
194
+ the kit; nor invent a `renderTool`, `onToolCall` or other prop the pages
195
+ don't name.
196
+ - Built-in tools (shell, files, search) take no card; only theirs do.
197
+ - Define cards and slots at module level, not inside a component.
198
+ - An approval's decision is Stigmer's: a step that needs one keeps Allow
199
+ and Deny, and a replaced approval card answers through the slot's
200
+ wiring. Only its look is theirs.
201
+ - Only the conversation's owner answers a waiting call; `customTools` are
202
+ read once, when the conversation is created.
170
203
  - Their page loads their font itself; the token only names it.
171
204
 
172
205
  ### One organization per business customer
@@ -213,8 +246,11 @@ https://stigmer.ai/docs/concepts/coming-from-claude-managed-agents, https://stig
213
246
  tool confirmations included.
214
247
  - Creating Sessions does not: they are created through Stigmer's SDK or
215
248
  console, and their ids then used with Anthropic's SDK.
216
- - Custom tools have no counterpart (Stigmer runs every tool; serve it from
217
- an MCP server), and neither do outcomes (Scores grade a finished run).
249
+ - Custom tools carry over: the app declares them on the Session it creates
250
+ (`custom_tools` through Stigmer's SDK, not `agent_with_overrides`), and
251
+ `agent.custom_tool_use` and `user.custom_tool_result` keep their shape, so
252
+ the handler stays. The answer is text, and only the Session's owner sends
253
+ it. Outcomes have no counterpart (Scores grade a finished run).
218
254
  - Name only the SDK versions the page names as tested.
219
255
 
220
256
  ## Before calling it done