SLOPSHOPPER

ProvenMap Workspace

Work across your whole ProvenMap workspace — explore the board graph, review insights, and author work items from Claude Cowork, Claude Code, or Codex…

guard
A shopper browsing a rack in a slop shop
README

ProvenMap Workspace

Your whole ProvenMap workspace, from Claude Code. Explore the board graph, review insights, and author work items — living specs — with the platform keeping governance: writes gather in your working copy, and committing generates a reviewable plan (one work item per governed app) in ProvenMap — never direct truth.

Where the ProvenMap code plugins serve developers (analyze a codebase or document set → push boards → implement work items), this plugin serves architects and leads: the people reasoning over boards, deciding what the architecture should become, and turning insights and documents into work.

Published as pmap-architect until 2026-10: if that is installed, install pmap-workspace and uninstall it. Your login carries over, and every command keeps its name (/setup-workspace is /setup now).

Install

Add the ProvenMap marketplace once, then install the plugin:

/plugin marketplace add provenmap/pmap-claude
/plugin install pmap-workspace@provenmap

Restart Claude Code so the commands load. Scope the install with --scope user (default), --scope project, or --scope local. Claude Cowork installs from the same marketplace.

Connect

The plugin talks to the ProvenMap MCP server with a workspace-scoped bearer token (pmap_mcp_live_…) — no repo binding, no project files:

  1. Run /pmap-workspace:login — sign in through the browser, pick workspace, scope (read or read_write) and an optional board-subtree restriction there. The token is stored for you and wired into this host's MCP config; it never transits the chat.
  2. Restart the session so the MCP server loads.
  3. Verify with /pmap-workspace:status.

No browser, or no admin permission to approve? Mint a token in ProvenMap (workspace command center (hub) → Workspace agent access), set it as PMAP_MCP_TOKEN in your environment, and run /pmap-workspace:configure.

Commands

CommandWhat it does
/pmap-workspace:start [ask]Start here — the surfaces card, the ranked next step, and a menu to run it; routes any open-ended ask
/pmap-workspace:setupBootstrap an empty workspace: estate interview → landscape → app boards → binding handoff
/pmap-workspace:new-app <idea>Plan a new system on the landscape: grill, place, sketch the target, draft the founding work item
/pmap-workspace:prepare-appTake a new app from placed to build-ready — spec work items + skills, resumable any time
/pmap-workspace:author-work-item [slug]Guided work item authoring: context pull, the grill, a well-grounded draft work item
/pmap-workspace:adopt-adrAdopt a decision: durable record + compliance review + per-app remediation work items
/pmap-workspace:work-itemsTurn anything into governed, well-anchored work; manage the queue
/pmap-workspace:ask-board <question>Ask the architecture a question — slug-grounded answer or highlighted subgraph
/pmap-workspace:assessStructured review: frame, sweep, defend the insights, record the batch
/pmap-workspace:insightsReview insight batches; promote reviewed insights into draft work items
/pmap-workspace:board [slug]Work a board conversationally — portfolio view on the landscape, canvas elsewhere
/pmap-workspace:hubThe command center, attention-first: what needs you, then the portfolio
/pmap-workspace:login :configure :status :logoutConnection lifecycle (MCP token)
/pmap-workspace:help :updateCommand reference · plugin update

How governance works

Reads are unrestricted within the token's workspace (and board restriction, if set). The token acts as you: writes join your one workspace working copy — the same session the ProvenMap web app shows — where they stay undoable until you decide. Committing the working copy generates a reviewable plan: one board_diff work item per governed app, named by your commit message; discarding reverts everything since the last decision. Deleting a draft work item removes it; the board keeps what you committed. Architects propose; the platform review decides.

Working with documents

Drop a PRD, RFC, or design doc into the session and ask for it to become board work: the plugin reads it directly, drafts work items anchored to the right board elements, and everything still gathers in your working copy for a reviewed commit. Documents bound to a board are also readable server-side.

Source 1 files
hooks/pmap-guard.js 302 lines
1// ProvenMap guard: a Claude Code mod (hooks.json "modules"), shipped as authored.
2//
3// It enforces two rules the shipped content only states in prose, at the tool call:
4//   1. Secrets never enter the chat. No Read, Grep or shell command touches the
5//      ProvenMap credential files or the PMAP_* secret variables, and any ProvenMap
6//      secret in what a tool returns (a credential pasted into config.json, an MCP
7//      entry in a host config) reaches Claude masked to its prefix.
8//   2. Script-owned state is written only by the scripts. No Edit, Write or shell
9//      write touches the element and evidence stores, the board manifest or the
10//      tree plan, whose hashes and records the scripts own.
11//   3. The workspace (root) board is drawn only from a plan the architect approved.
12//      A create_nodes / create_edges on root goes through only after a
13//      `pmap-architect.js --render-plan` succeeded and the architect answered its
14//      go-ahead (the AskUserQuestion offering "Draw it", its preview showing the
15//      rendered sketch): "Draw it" approves everything that plan shows; "Let me
16//      pick" approves what it confirmed plus the suggestions they tick in the pick
17//      rounds that follow. A new render, failed or not, revokes the approval.
18//
19// Claude Code only: Codex and Cursor have no mods, so there the prose is the rule.
20// A user-scope plugin's mod runs in every session, ProvenMap repo or not, so each
21// rule needs a `.provenmap/` path or a PMAP_ name before it fires. Every deny tells
22// Claude what to run instead. A rule that throws lets the call through (fails open),
23// like the settings-hook scripts; the output is masked either way (see `recover`).
24
25const SECRET_FILE =
26  /(^|\/)\.provenmap\/(credentials\.json|login-state\.json|login-state(\/|$)|architect-mcp\.json)/;
27const SECRET_ENV = /\bPMAP_(API_SECRET|BINDING_TOKEN)\b/;
28// Every ProvenMap secret names its family up front: pmap_<kind>_<env>_<body> (cp, mcp,
29// sess, share, app, …), or the older ck_[<kind>_]live_<body>. This is the platform's
30// own redaction pattern (its credential registry): loose enough for a truncated
31// secret, while a bare prefix (`pmap_cp_live_…`) or a short fixture stays readable.
32const SECRET_VALUE = /\b((?:pmap|ck)_(?:[a-z]+_)?(?:live|test)_)[0-9A-Za-z_-]{16,}/g;
33const SCRIPT_OWNED =
34  /(^|\/)\.provenmap\/(boards\/manifest\.json|boards\/stores\/[^/]+\.(store|evidence)\.json|tree-plan\.json|plan-run\.json)$/;
35
36// A Grep or shell read rooted at these directories (or a glob in them) reads the
37// credential files inside them.
38const SECRET_DIR = /(^|\/)\.provenmap(\/login-state)?\/?(\*[^/]*)?$/;
39
40// Programs that can name a credential path without printing the file.
41const SAFE_PROGRAM = /^(ls|stat|test|\[|chmod|find|mkdir|cd|touch|echo|printf|true|false)$/;
42const SECRET_NAME = /credentials\.json|login-state|architect-mcp\.json/;
43
44function normalise(p) {
45  return typeof p === "string" ? p.replace(/\\/g, "/") : "";
46}
47
48function unquote(word) {
49  return normalise(word.replace(/^["']|["']$/g, ""));
50}
51
52function shellSegments(command) {
53  return command.split(/&&|\|\||[;|\n]/);
54}
55
56function secretDeny(target) {
57  const architect = /architect-mcp\.json/.test(target);
58  return [
59    `ProvenMap guard: ${target} holds a ProvenMap credential, and credentials never enter the chat.`,
60    architect
61      ? "Run /pmap-workspace:status to check the token, or /pmap-workspace:login to replace it."
62      : "Run /pmap-code:configure to check the credentials (its script reports each field's shape and the masked secret), or /pmap-code:login to replace them. The user edits the file by hand, never through the chat.",
63  ].join(" ");
64}
65
66function scriptOwnedDeny(target) {
67  const store = /\.(store|evidence)\.json$/.test(target);
68  return [
69    `ProvenMap guard: ${target} is written only by the ProvenMap scripts, and a hand edit breaks the record they verify.`,
70    store
71      ? "Run /pmap-code:sync to update the element store, or /pmap-code:ground for the evidence store."
72      : "Change the board files instead and let the scripts rewrite it; run /pmap-code:analyze to rebuild the plan (--clean starts over).",
73  ].join(" ");
74}
75
76function mentionsSecret(text) {
77  return (
78    (/\.provenmap/.test(normalise(text)) && SECRET_NAME.test(text)) ||
79    text.split(/[\s;&|<>()`]+/).some((w) => SECRET_DIR.test(unquote(w)))
80  );
81}
82
83// A shell command that could print a credential: a substitution around one, or a
84// segment naming one whose program reads files (or reads it through `<`). Once the
85// command names .provenmap, a bare file name counts too (`cd .provenmap && cat …`).
86function shellReadsSecret(command) {
87  if (!mentionsSecret(command)) return false;
88  if (/`|\$\(/.test(command)) return true;
89  return shellSegments(command).some((segment) => {
90    if (!SECRET_NAME.test(segment) && !mentionsSecret(segment)) return false;
91    const [program, ...args] = segment.trim().split(/\s+/);
92    if (program === "git") return args[0] !== "check-ignore";
93    return !SAFE_PROGRAM.test(program) || segment.includes("<");
94  });
95}
96
97// A shell write into a script-owned file: a redirect target, or an argument of a
98// program that changes the files it names (cp only writes its last one).
99function shellWriteTarget(command) {
100  for (const m of command.matchAll(/>>?\s*["']?([^\s;&|"'<>]+)/g)) {
101    if (SCRIPT_OWNED.test(normalise(m[1]))) return normalise(m[1]);
102  }
103  for (const segment of shellSegments(command)) {
104    const [program, ...args] = segment.trim().split(/\s+/).map(unquote);
105    const inPlace = /^(sed|perl)$/.test(program) && args.some((a) => /^-[a-zA-Z]*i/.test(a));
106    const targets =
107      program === "cp" ? args.slice(-1) : ["rm", "mv", "tee", "truncate"].includes(program) || inPlace ? args : [];
108    const hit = targets.find((w) => SCRIPT_OWNED.test(w));
109    if (hit) return hit;
110  }
111  return null;
112}
113
114// The go-ahead's answers — the labels landscape-plan.ts renders (a test pins them).
115const DRAW_ALL = "Draw it";
116const PICK = "Let me pick";
117const ROOT_DRAW = /^mcp__.*provenmap.*__(create_nodes|create_edges)$/i;
118
119function parseJson(text) {
120  if (typeof text !== "string") return null;
121  try {
122    return JSON.parse(text);
123  } catch {
124    const m = text.match(/\{[\s\S]*\}/);
125    try {
126      return m ? JSON.parse(m[0]) : null;
127    } catch {
128      return null;
129    }
130  }
131}
132
133const edgeKey = (e) => `${e?.sourceSlug ?? ""}>${e?.targetSlug ?? ""}`;
134
135/**
136 * Rule 3's memory for one session: the last plan --render-plan rendered and what
137 * the architect's answers approved — the confirmed elements, the suggestions kept
138 * (all on "Draw it", the ticked ones on "Let me pick"), and the connections whose
139 * suggested ends were all kept.
140 * `observe` reads each finished call; `check` is the deny text for a root draw,
141 * or null. Exported for the plugin repo's tests.
142 */
143export function planGate() {
144  let rendered = null;
145  let approved = null;
146  const approve = (keptLabels) => {
147    const kept = rendered.suggestions.filter((s) => keptLabels.has(s.label));
148    const dropped = new Set(rendered.suggestions.filter((s) => s.node && !keptLabels.has(s.label)).map((s) => s.node));
149    const clear = (pair) => pair.split(">").every((slug) => !dropped.has(slug));
150    return {
151      nodes: new Set([...rendered.nodes, ...kept.filter((s) => s.node).map((s) => s.node)]),
152      edges: new Set([
153        ...rendered.edges,
154        ...rendered.conditional.filter(clear),
155        ...kept.filter((s) => s.edge && clear(s.edge)).map((s) => s.edge),
156      ]),
157    };
158  };
159  // After "Let me pick": each pick question's ticked labels, by question (a re-ask replaces its answer).
160  let picks = null;
161  return {
162    observe(tool, input, outcome) {
163      if ((tool === "Bash" || tool === "PowerShell") && /--render-plan\b/.test(String(input?.command ?? ""))) {
164        rendered = null;
165        approved = null;
166        picks = null;
167        const out = outcome && !outcome.deny ? parseJson(outcome.text) : null;
168        if (out?.success && Array.isArray(out.goAhead?.questions) && out.approval)
169          rendered = {
170            preview: out.goAhead.questions[0]?.options?.[0]?.preview ?? "",
171            nodes: out.approval.nodes ?? [],
172            edges: out.approval.edges ?? [],
173            conditional: out.approval.conditional ?? [],
174            suggestions: out.approval.suggestions ?? [],
175          };
176        return;
177      }
178      if (tool !== "AskUserQuestion" || !rendered || !outcome || outcome.deny) return;
179      const questions = Array.isArray(input?.questions) ? input.questions : [];
180      const answers = outcome.result?.answers ?? {};
181      const labels = new Set(rendered.suggestions.map((s) => s.label));
182      // The go-ahead is the asked question offering "Draw it" (only the go-ahead does),
183      // matched by its options so a reworded question still counts.
184      const go = questions.find((q) => (q?.options ?? []).some((o) => o?.label === DRAW_ALL));
185      if (go && answers[go.question] !== undefined) {
186        // The dialog must have shown the plan: "Draw it" carries the render's sketch as its preview.
187        const shown = go.options.find((o) => o?.label === DRAW_ALL)?.preview ?? "";
188        const answer = shown.trim() === rendered.preview.trim() ? answers[go.question] : null;
189        picks = answer === PICK && labels.size > 0 ? new Map() : null;
190        approved = answer === DRAW_ALL ? approve(labels) : picks ? approve(new Set()) : null;
191        return;
192      }
193      // A pick round: the questions whose options are this render's suggestions.
194      if (!picks) return;
195      for (const q of questions.filter((q) => (q?.options ?? []).some((o) => labels.has(o?.label))))
196        if (answers[q.question] !== undefined)
197          picks.set(q.question, String(answers[q.question]).split(", ").filter((l) => labels.has(l)));
198      approved = approve(new Set([...picks.values()].flat()));
199    },
200    check(tool, input) {
201      if (!ROOT_DRAW.test(tool) || input?.workBoardSlug !== "root") return null;
202      if (!approved)
203        return "ProvenMap guard: the workspace board is drawn only from a plan the architect approved. Run pmap-architect.js --render-plan, print its display, ask its goAhead question with AskUserQuestion as given (and on \"Let me pick\" its pick rounds), then --plan-approve with the answers and draw the wire file it names.";
204      const nodes = /create_nodes$/i.test(tool);
205      const items = nodes
206        ? (Array.isArray(input.nodes) ? input.nodes : []).map((n) => n?.slug ?? "")
207        : (Array.isArray(input.edges) ? input.edges : []).map(edgeKey);
208      const outside = items.filter((k) => !(nodes ? approved.nodes : approved.edges).has(k));
209      return outside.length === 0
210        ? null
211        : `ProvenMap guard: ${outside.map((k) => `\`${k}\``).join(", ")} ${outside.length === 1 ? "is" : "are"} not in what the architect approved. Draw the wire file --plan-approve wrote, or add ${outside.length === 1 ? "it" : "them"} to the plan, re-render and ask again.`;
212    },
213  };
214}
215
216/**
217 * The deny text for one tool call, or null to let it through. Exported for the
218 * plugin repo's tests; the engine only calls `register`.
219 */
220export function guard(tool, input) {
221  if (!input || typeof input !== "object") return null;
222  if (tool === "Read") {
223    const p = normalise(input.file_path);
224    return SECRET_FILE.test(p) ? secretDeny(p) : null;
225  }
226  if (tool === "Grep") {
227    const p = normalise(input.path);
228    return SECRET_FILE.test(p) || SECRET_DIR.test(p) ? secretDeny(p) : null;
229  }
230  if (tool === "Edit" || tool === "Write" || tool === "NotebookEdit") {
231    const p = normalise(input.file_path ?? input.notebook_path);
232    if (SECRET_FILE.test(p)) return secretDeny(p);
233    return SCRIPT_OWNED.test(p) ? scriptOwnedDeny(p) : null;
234  }
235  if (tool === "Bash" || tool === "PowerShell") {
236    const command = typeof input.command === "string" ? input.command : "";
237    if (SECRET_ENV.test(command)) return secretDeny(command.match(SECRET_ENV)[0]);
238    if (shellReadsSecret(command)) return secretDeny((command.match(SECRET_NAME) ?? [".provenmap/"])[0]);
239    const written = shellWriteTarget(command);
240    return written ? scriptOwnedDeny(written) : null;
241  }
242  return null;
243}
244
245function redactText(text) {
246  return text.replace(SECRET_VALUE, "$1****");
247}
248
249function redactDeep(value) {
250  if (typeof value === "string") return redactText(value);
251  if (Array.isArray(value)) return value.map(redactDeep);
252  if (value && typeof value === "object") {
253    return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, redactDeep(v)]));
254  }
255  return value;
256}
257
258/**
259 * What a tool call resolved to, with every ProvenMap secret masked, or the same
260 * object when it holds none (so core keeps its own rendering). A rewritten result
261 * drops `ref` and `text`, which name the unmasked output, and core re-renders it.
262 */
263export function redact(outcome) {
264  if (!outcome || outcome.deny !== undefined) return outcome;
265  const seen = typeof outcome.text === "string" ? outcome.text : JSON.stringify(outcome.result) ?? "";
266  if (!seen.match(SECRET_VALUE)) return outcome;
267  if (outcome.isError) return { deny: redactText(seen) };
268  return {
269    result: redactDeep(outcome.result),
270    ...(outcome.context ? { context: outcome.context.map(redactText) } : {}),
271  };
272}
273
274/**
275 * When the hook fails, the call goes through (a broken rule must not block every
276 * tool in every session), but its output is still masked, and output that cannot
277 * be masked is masked as text or withheld. `next` here replays a call already made.
278 */
279export async function recover($, e, next) {
280  const outcome = await next(e);
281  try {
282    return redact(outcome);
283  } catch {
284    return typeof outcome?.text === "string"
285      ? { deny: redactText(outcome.text) }
286      : { deny: "ProvenMap guard could not check this output for ProvenMap secrets, so it was withheld." };
287  }
288}
289
290/** @type {import('claude-code').Register} */
291export const register = (on) => {
292  // One gate per load: a plugin reload starts it over, so an approval never outlives the code that gave it.
293  const gate = planGate();
294  on("tool.call", async ($, e, next) => {
295    const deny = guard(e.tool, e) ?? gate.check(e.tool, e);
296    if (deny) return { deny };
297    const outcome = await next(e);
298    gate.observe(e.tool, e, outcome);
299    return redact(outcome);
300  }).catch(recover);
301};
302