@profullstack/chat-plugins 0.2.0 → 0.3.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
@@ -125,3 +125,22 @@ const tools = applyPolicy(policy, await listTools(plugin), plugin.tradingMode ??
125
125
  moomoo in paper mode offers reads plus `sim_trade_*` orders only; live order
126
126
  tools appear only in `"live"` mode, and still ask. `redactLog()` masks tokens,
127
127
  long digit runs and amounts before anything reaches a log.
128
+
129
+ ## Docs plugins (0.3.0)
130
+
131
+ `DOCS_CATALOG` lists public, read-only documentation servers that need no
132
+ sign-in. It ships Microsoft Learn (`https://learn.microsoft.com/api/mcp`:
133
+ docs search, code sample search, page fetch), on by default.
134
+
135
+ `DEFAULT_PLUGINS` now holds every default: the money plugins, then the docs
136
+ plugins. A docs entry carries `auth: "none"`; seed it as ready to use, not as
137
+ "needs sign-in":
138
+
139
+ ```js
140
+ import { DEFAULT_PLUGINS, DOCS_CATALOG, mcpAddCommand } from "@profullstack/chat-plugins";
141
+
142
+ for (const d of DEFAULT_PLUGINS) seed(userId, d, d.auth === "none" ? "none" : "sign-in-on-first-use");
143
+
144
+ mcpAddCommand(DOCS_CATALOG[0]); // claude mcp add --transport http microsoft-learn https://learn.microsoft.com/api/mcp
145
+ mcpAddCommand(DOCS_CATALOG[0], "codex"); // codex mcp add microsoft-learn --url https://learn.microsoft.com/api/mcp
146
+ ```
package/index.d.ts CHANGED
@@ -341,6 +341,12 @@ export interface FinanceCatalogEntry {
341
341
  icon: string;
342
342
  /** On for every account (listed and switched on, not signed in). */
343
343
  default: boolean;
344
+ /** "none": the server needs no sign-in, so a seeded row is ready to use. Absent: sign-in on first use. */
345
+ auth?: "none";
346
+ }
347
+ /** A public, read-only documentation server that needs no sign-in. */
348
+ export interface DocsCatalogEntry extends FinanceCatalogEntry {
349
+ auth: "none";
344
350
  }
345
351
  export interface ActionSummary {
346
352
  title: string;
@@ -350,7 +356,11 @@ export interface ActionSummary {
350
356
  }
351
357
  export const MODEL_CAN_BE_WRONG: string;
352
358
  export const FINANCE_CATALOG: readonly FinanceCatalogEntry[];
359
+ /** Everything on for every account: money plugins (sign-in on first use), then docs plugins (auth "none"). */
353
360
  export const DEFAULT_PLUGINS: readonly FinanceCatalogEntry[];
361
+ export const DOCS_CATALOG: readonly DocsCatalogEntry[];
362
+ /** The one-line CLI command that registers an entry, e.g. `claude mcp add --transport http <slug> <url>`. */
363
+ export function mcpAddCommand(entry: { slug: string; url: string }, cli?: "claude" | "gemini" | "qwen" | "codex" | "opencode"): string;
354
364
  export const POLICIES: Record<string, PluginPolicy>;
355
365
  export function policyFor(url: string): PluginPolicy | null;
356
366
  export function needsConfirmation(policy: PluginPolicy, tool: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profullstack/chat-plugins",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "Chat plugins = remote MCP servers, with less hoops than connectors: paste a URL or pick from a catalog, sign-in is automatic (OAuth 2.1 + DCR + PKCE), and an agent loop runs the tools even on models with no native tool calling. Zero dependencies.",
6
6
  "keywords": [
package/src/docs.js ADDED
@@ -0,0 +1,43 @@
1
+ // Docs plugins: public, read-only documentation servers that need no sign-in.
2
+ // Entries with `default: true` are on for every account in apps that seed
3
+ // DEFAULT_PLUGINS (c0mpute chat, Infernet chat). `auth: "none"` tells the app
4
+ // to seed the row as ready to use, not as "needs sign-in".
5
+ //
6
+ // No Node imports: this also runs in the browser.
7
+
8
+ /** @type {readonly import("../index.js").DocsCatalogEntry[]} */
9
+ export const DOCS_CATALOG = Object.freeze([
10
+ Object.freeze({
11
+ slug: "microsoft-learn",
12
+ name: "Microsoft Learn (docs)",
13
+ url: "https://learn.microsoft.com/api/mcp",
14
+ description:
15
+ "Official Microsoft and Azure documentation in chat: search the docs, find code samples and read full pages as markdown. Read-only, no sign-in.",
16
+ homepage: "https://learn.microsoft.com",
17
+ icon: "https://learn.microsoft.com/favicon.ico",
18
+ default: true,
19
+ auth: "none",
20
+ }),
21
+ ]);
22
+
23
+ /**
24
+ * The one-line command that registers a catalog entry in a coding agent's CLI,
25
+ * e.g. `claude mcp add --transport http microsoft-learn https://learn.microsoft.com/api/mcp`.
26
+ * @param {{ slug: string, url: string }} entry
27
+ * @param {"claude" | "gemini" | "qwen" | "codex" | "opencode"} [cli]
28
+ */
29
+ export function mcpAddCommand(entry, cli = "claude") {
30
+ const slug = String(entry?.slug || "");
31
+ const url = String(entry?.url || "");
32
+ if (!/^[a-z0-9][a-z0-9_-]*$/i.test(slug)) throw new Error("mcpAddCommand: bad slug");
33
+ let parsed;
34
+ try {
35
+ parsed = new URL(url);
36
+ } catch {
37
+ throw new Error("mcpAddCommand: bad url");
38
+ }
39
+ if (parsed.protocol !== "https:" || /[\s'"`$\;&|<>()]/.test(url)) throw new Error("mcpAddCommand: bad url");
40
+ if (cli === "codex" || cli === "opencode") return `${cli} mcp add ${slug} --url ${url}`;
41
+ if (cli === "claude" || cli === "gemini" || cli === "qwen") return `${cli} mcp add --transport http ${slug} ${url}`;
42
+ throw new Error(`mcpAddCommand: unknown cli ${cli}`);
43
+ }
package/src/index.js CHANGED
@@ -39,3 +39,4 @@ export {
39
39
  describeAction,
40
40
  redactLog,
41
41
  } from "./money.js";
42
+ export { DOCS_CATALOG, mcpAddCommand } from "./docs.js";
package/src/money.js CHANGED
@@ -12,6 +12,8 @@
12
12
  // Shared by c0mpute chat and Infernet chat so the two cannot drift. No Node
13
13
  // imports: describeAction() also runs in the browser.
14
14
 
15
+ import { DOCS_CATALOG } from "./docs.js";
16
+
15
17
  export const MODEL_CAN_BE_WRONG = "The model can be wrong. You decide: nothing here runs until you approve it.";
16
18
  export const FINANCE_CATALOG = Object.freeze([
17
19
  {
@@ -42,7 +44,9 @@ export const FINANCE_CATALOG = Object.freeze([
42
44
  default: false
43
45
  }
44
46
  ]);
45
- export const DEFAULT_PLUGINS = FINANCE_CATALOG.filter((e) => e.default);
47
+ // Everything apps switch on for every account: the money plugins each person
48
+ // signs in to, then the docs plugins that need no sign-in (auth: "none").
49
+ export const DEFAULT_PLUGINS = Object.freeze([...FINANCE_CATALOG.filter((e) => e.default), ...DOCS_CATALOG.filter((e) => e.default)]);
46
50
  const MERCURY_READ = new Set([
47
51
  "getCurrentDate",
48
52
  "getAccount",