@mrclrchtr/supi-web 1.6.0 → 1.8.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-core",
3
- "version": "1.6.0",
3
+ "version": "1.8.0",
4
4
  "description": "SuPi core — shared infrastructure for SuPi extensions (XML context tags, config system)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -20,7 +20,8 @@
20
20
  ],
21
21
  "peerDependencies": {
22
22
  "@earendil-works/pi-coding-agent": "*",
23
- "@earendil-works/pi-tui": "*"
23
+ "@earendil-works/pi-tui": "*",
24
+ "typebox": "*"
24
25
  },
25
26
  "peerDependenciesMeta": {
26
27
  "@earendil-works/pi-coding-agent": {
@@ -28,13 +29,27 @@
28
29
  },
29
30
  "@earendil-works/pi-tui": {
30
31
  "optional": true
32
+ },
33
+ "typebox": {
34
+ "optional": true
31
35
  }
32
36
  },
33
37
  "main": "src/api.ts",
34
38
  "exports": {
35
39
  "./api": "./src/api.ts",
40
+ "./config": "./src/config.ts",
41
+ "./context": "./src/context.ts",
42
+ "./debug": "./src/debug-registry.ts",
36
43
  "./extension": "./src/extension.ts",
37
- "./package.json": "./package.json"
44
+ "./package.json": "./package.json",
45
+ "./path": "./src/path.ts",
46
+ "./project": "./src/project.ts",
47
+ "./session": "./src/session.ts",
48
+ "./settings": "./src/settings.ts",
49
+ "./settings-ui": "./src/settings-ui.ts",
50
+ "./terminal": "./src/terminal.ts",
51
+ "./tool-framework": "./src/tool-framework.ts",
52
+ "./types": "./src/types.ts"
38
53
  },
39
54
  "pi": {
40
55
  "extensions": [
@@ -1,85 +1,30 @@
1
1
  // supi-core — shared infrastructure for SuPi extensions.
2
2
  // Provides XML context tag wrapping, unified config system, context-message utilities,
3
- // and settings registry for supi-wide TUI settings.
3
+ // settings registry for supi-wide TUI settings, and a shared tool-spec/registration framework.
4
+ //
5
+ // Convenience barrel — re-exports all domain entry points.
6
+ // For lighter imports, use one of the domain subpaths directly
7
+ // (e.g. @mrclrchtr/supi-core/config, @mrclrchtr/supi-core/context).
4
8
 
5
- export type { SupiConfigLocation, SupiConfigOptions } from "./config/config.ts";
6
- export {
7
- loadSupiConfig,
8
- loadSupiConfigForScope,
9
- removeSupiConfigKey,
10
- writeSupiConfig,
11
- } from "./config/config.ts";
12
- export type { ConfigSettingsHelpers, ConfigSettingsOptions } from "./config/config-settings.ts";
13
- export { registerConfigSettings } from "./config/config-settings.ts";
14
- export type { ContextMessageLike } from "./context/context-messages.ts";
15
- export {
16
- findLastUserMessageIndex,
17
- getContextToken,
18
- getPromptContent,
19
- pruneAndReorderContextMessages,
20
- restorePromptContent,
21
- } from "./context/context-messages.ts";
22
- export type { ContextProvider } from "./context/context-provider-registry.ts";
23
- export {
24
- clearRegisteredContextProviders,
25
- getRegisteredContextProviders,
26
- registerContextProvider,
27
- } from "./context/context-provider-registry.ts";
28
- export { wrapExtensionContext } from "./context/context-tag.ts";
29
- export type {
30
- DebugAgentAccess,
31
- DebugEvent,
32
- DebugEventInput,
33
- DebugEventQuery,
34
- DebugEventQueryResult,
35
- DebugEventView,
36
- DebugLevel,
37
- DebugNotifyLevel,
38
- DebugRegistryConfig,
39
- DebugSummary,
40
- } from "./debug-registry.ts";
41
- export {
42
- clearDebugEvents,
43
- configureDebugRegistry,
44
- DEBUG_REGISTRY_DEFAULTS,
45
- getDebugEvents,
46
- getDebugRegistryConfig,
47
- getDebugSummary,
48
- recordDebugEvent,
49
- redactDebugData,
50
- resetDebugRegistry,
51
- } from "./debug-registry.ts";
52
- export { fileToUri, resolveToolPath, stripToolPathPrefix, uriToFile } from "./path-utils.ts";
53
- export type { KnownRootEntry } from "./project-roots.ts";
54
- export {
55
- buildKnownRootsMap,
56
- byPathDepth,
57
- dedupeTopmostRoots,
58
- findProjectRoot,
59
- isWithin,
60
- isWithinOrEqual,
61
- mergeKnownRoots,
62
- resolveKnownRoot,
63
- segmentCount,
64
- sortRootsBySpecificity,
65
- walkProject,
66
- } from "./project-roots.ts";
67
- export { createRegistry, createSessionStateRegistry } from "./registry-utils.ts";
68
- export { getActiveBranchEntries } from "./session-utils.ts";
69
- export { registerSettingsCommand } from "./settings/settings-command.ts";
70
- export type { SettingsScope, SettingsSection } from "./settings/settings-registry.ts";
71
- export {
72
- clearRegisteredSettings,
73
- getRegisteredSettings,
74
- registerSettings,
75
- } from "./settings/settings-registry.ts";
76
- export { createInputSubmenu, openSettingsOverlay } from "./settings/settings-ui.ts";
77
- export type { TitleTarget } from "./terminal.ts";
78
- export {
79
- DONE_SYMBOL,
80
- formatTitle,
81
- signalBell,
82
- signalDone,
83
- signalWaiting,
84
- WAITING_SYMBOL,
85
- } from "./terminal.ts";
9
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
10
+ export * from "./config.ts";
11
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
12
+ export * from "./context.ts";
13
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
14
+ export * from "./debug-registry.ts";
15
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
16
+ export * from "./path.ts";
17
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
18
+ export * from "./project.ts";
19
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
20
+ export * from "./session.ts";
21
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
22
+ export * from "./settings.ts";
23
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
24
+ export * from "./settings-ui.ts";
25
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
26
+ export * from "./terminal.ts";
27
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
28
+ export * from "./tool-framework.ts";
29
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
30
+ export * from "./types.ts";
@@ -20,7 +20,7 @@ function getProjectConfigPath(cwd: string): string {
20
20
  return path.join(cwd, PROJECT_CONFIG_DIR, CONFIG_FILE);
21
21
  }
22
22
 
23
- function readJsonFile(filePath: string): Record<string, unknown> | null {
23
+ export function readJsonFile(filePath: string): Record<string, unknown> | null {
24
24
  let content: string;
25
25
  try {
26
26
  content = fs.readFileSync(filePath, "utf-8");
@@ -0,0 +1,11 @@
1
+ // supi-core config domain — config loading and config-settings helpers.
2
+ export type { SupiConfigLocation, SupiConfigOptions } from "./config/config.ts";
3
+ export {
4
+ loadSupiConfig,
5
+ loadSupiConfigForScope,
6
+ readJsonFile,
7
+ removeSupiConfigKey,
8
+ writeSupiConfig,
9
+ } from "./config/config.ts";
10
+ export type { ConfigSettingsHelpers, ConfigSettingsOptions } from "./config/config-settings.ts";
11
+ export { registerConfigSettings } from "./config/config-settings.ts";
@@ -0,0 +1,16 @@
1
+ // supi-core context domain — context messages, providers, and XML tags.
2
+ export type { ContextMessageLike } from "./context/context-messages.ts";
3
+ export {
4
+ findLastUserMessageIndex,
5
+ getContextToken,
6
+ getPromptContent,
7
+ pruneAndReorderContextMessages,
8
+ restorePromptContent,
9
+ } from "./context/context-messages.ts";
10
+ export type { ContextProvider } from "./context/context-provider-registry.ts";
11
+ export {
12
+ clearRegisteredContextProviders,
13
+ getRegisteredContextProviders,
14
+ registerContextProvider,
15
+ } from "./context/context-provider-registry.ts";
16
+ export { wrapExtensionContext } from "./context/context-tag.ts";
@@ -1,85 +1,30 @@
1
1
  // supi-core — shared infrastructure for SuPi extensions.
2
2
  // Provides XML context tag wrapping, unified config system, context-message utilities,
3
- // and settings registry for supi-wide TUI settings.
3
+ // settings registry for supi-wide TUI settings, and a shared tool-spec/registration framework.
4
+ //
5
+ // Convenience barrel — re-exports all domain entry points.
6
+ // For lighter imports, use one of the domain subpaths directly
7
+ // (e.g. @mrclrchtr/supi-core/config, @mrclrchtr/supi-core/context).
4
8
 
5
- export type { SupiConfigLocation, SupiConfigOptions } from "./config/config.ts";
6
- export {
7
- loadSupiConfig,
8
- loadSupiConfigForScope,
9
- removeSupiConfigKey,
10
- writeSupiConfig,
11
- } from "./config/config.ts";
12
- export type { ConfigSettingsHelpers, ConfigSettingsOptions } from "./config/config-settings.ts";
13
- export { registerConfigSettings } from "./config/config-settings.ts";
14
- export type { ContextMessageLike } from "./context/context-messages.ts";
15
- export {
16
- findLastUserMessageIndex,
17
- getContextToken,
18
- getPromptContent,
19
- pruneAndReorderContextMessages,
20
- restorePromptContent,
21
- } from "./context/context-messages.ts";
22
- export type { ContextProvider } from "./context/context-provider-registry.ts";
23
- export {
24
- clearRegisteredContextProviders,
25
- getRegisteredContextProviders,
26
- registerContextProvider,
27
- } from "./context/context-provider-registry.ts";
28
- export { wrapExtensionContext } from "./context/context-tag.ts";
29
- export type {
30
- DebugAgentAccess,
31
- DebugEvent,
32
- DebugEventInput,
33
- DebugEventQuery,
34
- DebugEventQueryResult,
35
- DebugEventView,
36
- DebugLevel,
37
- DebugNotifyLevel,
38
- DebugRegistryConfig,
39
- DebugSummary,
40
- } from "./debug-registry.ts";
41
- export {
42
- clearDebugEvents,
43
- configureDebugRegistry,
44
- DEBUG_REGISTRY_DEFAULTS,
45
- getDebugEvents,
46
- getDebugRegistryConfig,
47
- getDebugSummary,
48
- recordDebugEvent,
49
- redactDebugData,
50
- resetDebugRegistry,
51
- } from "./debug-registry.ts";
52
- export { fileToUri, resolveToolPath, stripToolPathPrefix, uriToFile } from "./path-utils.ts";
53
- export type { KnownRootEntry } from "./project-roots.ts";
54
- export {
55
- buildKnownRootsMap,
56
- byPathDepth,
57
- dedupeTopmostRoots,
58
- findProjectRoot,
59
- isWithin,
60
- isWithinOrEqual,
61
- mergeKnownRoots,
62
- resolveKnownRoot,
63
- segmentCount,
64
- sortRootsBySpecificity,
65
- walkProject,
66
- } from "./project-roots.ts";
67
- export { createRegistry, createSessionStateRegistry } from "./registry-utils.ts";
68
- export { getActiveBranchEntries } from "./session-utils.ts";
69
- export { registerSettingsCommand } from "./settings/settings-command.ts";
70
- export type { SettingsScope, SettingsSection } from "./settings/settings-registry.ts";
71
- export {
72
- clearRegisteredSettings,
73
- getRegisteredSettings,
74
- registerSettings,
75
- } from "./settings/settings-registry.ts";
76
- export { createInputSubmenu, openSettingsOverlay } from "./settings/settings-ui.ts";
77
- export type { TitleTarget } from "./terminal.ts";
78
- export {
79
- DONE_SYMBOL,
80
- formatTitle,
81
- signalBell,
82
- signalDone,
83
- signalWaiting,
84
- WAITING_SYMBOL,
85
- } from "./terminal.ts";
9
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
10
+ export * from "./config.ts";
11
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
12
+ export * from "./context.ts";
13
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
14
+ export * from "./debug-registry.ts";
15
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
16
+ export * from "./path.ts";
17
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
18
+ export * from "./project.ts";
19
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
20
+ export * from "./session.ts";
21
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
22
+ export * from "./settings.ts";
23
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
24
+ export * from "./settings-ui.ts";
25
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
26
+ export * from "./terminal.ts";
27
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
28
+ export * from "./tool-framework.ts";
29
+ // biome-ignore lint/performance/noReExportAll: intentional convenience barrel
30
+ export * from "./types.ts";
@@ -0,0 +1,2 @@
1
+ // supi-core path domain — file and URI path utilities.
2
+ export { fileToUri, resolveToolPath, stripToolPathPrefix, uriToFile } from "./path-utils.ts";
@@ -0,0 +1,15 @@
1
+ // supi-core project domain — project root discovery and traversal.
2
+ export type { KnownRootEntry } from "./project-roots.ts";
3
+ export {
4
+ buildKnownRootsMap,
5
+ byPathDepth,
6
+ dedupeTopmostRoots,
7
+ findProjectRoot,
8
+ isWithin,
9
+ isWithinOrEqual,
10
+ mergeKnownRoots,
11
+ resolveKnownRoot,
12
+ segmentCount,
13
+ sortRootsBySpecificity,
14
+ walkProject,
15
+ } from "./project-roots.ts";
@@ -0,0 +1,4 @@
1
+ // supi-core session domain — session utilities and registries.
2
+
3
+ export { createRegistry, createSessionStateRegistry } from "./registry-utils.ts";
4
+ export { getActiveBranchEntries } from "./session-utils.ts";
@@ -0,0 +1,2 @@
1
+ // supi-core settings-ui domain — settings TUI components (imports pi-tui at runtime, heavy).
2
+ export { createInputSubmenu, openSettingsOverlay } from "./settings/settings-ui.ts";
@@ -0,0 +1,9 @@
1
+ // supi-core settings domain — settings registry (lightweight, type-only pi-tui import).
2
+
3
+ export { registerSettingsCommand } from "./settings/settings-command.ts";
4
+ export type { SettingsScope, SettingsSection } from "./settings/settings-registry.ts";
5
+ export {
6
+ clearRegisteredSettings,
7
+ getRegisteredSettings,
8
+ registerSettings,
9
+ } from "./settings/settings-registry.ts";
@@ -0,0 +1,11 @@
1
+ /** 0-based position used by LSP and code-intelligence internally. */
2
+ export interface CodePosition {
3
+ line: number;
4
+ character: number;
5
+ }
6
+
7
+ /** Normalized location — flat replacement for LSP's nested Location/range shape. */
8
+ export interface CodeLocation {
9
+ uri: string;
10
+ range: { start: CodePosition; end: CodePosition };
11
+ }
@@ -0,0 +1,116 @@
1
+ // Shared tool framework for SuPi extensions.
2
+ //
3
+ // Provides a standard ToolSpec→PromptSurface→registerTool pipeline so
4
+ // individual packages do not duplicate spec interfaces, guidance derivation,
5
+ // registration loops, or common TypeBox parameter schemas.
6
+
7
+ import type {
8
+ AgentToolResult,
9
+ AgentToolUpdateCallback,
10
+ ExtensionAPI,
11
+ ExtensionContext,
12
+ } from "@earendil-works/pi-coding-agent";
13
+ import { type TSchema, Type } from "typebox";
14
+
15
+ // ---------------------------------------------------------------------------
16
+ // Types
17
+ // ---------------------------------------------------------------------------
18
+
19
+ /** Minimum contract for a SuPi tool definition. */
20
+ export interface SuiPiToolSpec {
21
+ name: string;
22
+ label: string;
23
+ description: string;
24
+ promptSnippet: string;
25
+ promptGuidelines: string[];
26
+ parameters: TSchema;
27
+ }
28
+
29
+ /** Derived prompt surface — what pi flattens into the system prompt. */
30
+ export interface SuiPiToolPromptSurface {
31
+ description: string;
32
+ promptSnippet: string;
33
+ promptGuidelines: string[];
34
+ }
35
+
36
+ // ---------------------------------------------------------------------------
37
+ // Guidance derivation
38
+ // ---------------------------------------------------------------------------
39
+
40
+ /**
41
+ * Static derivation: copies spec fields into a prompt surface.
42
+ *
43
+ * Packages that need dynamic guidance (e.g. server-coverage injection) should
44
+ * build their own surfaces, optionally starting from the output of this helper.
45
+ */
46
+ export function derivePromptSurface(spec: SuiPiToolSpec): SuiPiToolPromptSurface {
47
+ return {
48
+ description: spec.description,
49
+ promptSnippet: spec.promptSnippet,
50
+ promptGuidelines: [...spec.promptGuidelines],
51
+ };
52
+ }
53
+
54
+ // ---------------------------------------------------------------------------
55
+ // Registration
56
+ // ---------------------------------------------------------------------------
57
+
58
+ // biome-ignore lint/complexity/useMaxParams: matches pi ToolDefinition.execute signature
59
+ export type ToolExecuteFn = (
60
+ toolCallId: string,
61
+ params: unknown,
62
+ signal: AbortSignal | undefined,
63
+ onUpdate: AgentToolUpdateCallback<Record<string, unknown>> | undefined,
64
+ ctx: ExtensionContext,
65
+ ) => Promise<AgentToolResult<Record<string, unknown>>>;
66
+
67
+ /**
68
+ * Register a set of tools from specs + pre-derived surfaces.
69
+ *
70
+ * `createExecute` receives the spec and returns a pi-compatible execute
71
+ * function. This keeps execute-logic package-local while the framework owns
72
+ * the declarative surface and registration boilerplate.
73
+ */
74
+ export function registerSuiPiTools(
75
+ pi: ExtensionAPI,
76
+ specs: readonly SuiPiToolSpec[],
77
+ surfaces: Record<string, SuiPiToolPromptSurface>,
78
+ createExecute: (spec: SuiPiToolSpec) => ToolExecuteFn,
79
+ ): void {
80
+ for (const spec of specs) {
81
+ const surface = surfaces[spec.name];
82
+ pi.registerTool({
83
+ name: spec.name,
84
+ label: spec.label,
85
+ description: surface?.description ?? spec.description,
86
+ promptSnippet: surface?.promptSnippet ?? spec.promptSnippet,
87
+ promptGuidelines: surface?.promptGuidelines ?? [...spec.promptGuidelines],
88
+ parameters: spec.parameters,
89
+ execute: createExecute(spec),
90
+ });
91
+ }
92
+ }
93
+
94
+ // ---------------------------------------------------------------------------
95
+ // Shared parameter builders
96
+ // ---------------------------------------------------------------------------
97
+
98
+ /** File path (relative or absolute). */
99
+ export const FileParam = Type.String({ description: "File path (relative or absolute)" });
100
+
101
+ /** 1-based line number. */
102
+ export const LineParam = Type.Number({ description: "1-based line number", minimum: 1 });
103
+
104
+ /** 1-based character column (UTF-16). */
105
+ export const CharacterParam = Type.Number({
106
+ description: "1-based column number (UTF-16)",
107
+ minimum: 1,
108
+ });
109
+
110
+ /** Symbol name for discovery-based resolution. */
111
+ export const SymbolParam = Type.String({
112
+ description: "Symbol name for discovery-based resolution",
113
+ });
114
+
115
+ /** Maximum results to return. */
116
+ export const MaxResultsParam = Type.Number({ description: "Maximum results to return" });
@@ -0,0 +1,2 @@
1
+ // supi-core types domain — shared substrate types (zero dependencies, pure types).
2
+ export type { CodeLocation, CodePosition } from "./substrate-types.ts";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-web",
3
- "version": "1.6.0",
3
+ "version": "1.8.0",
4
4
  "description": "SuPi Web extension — fetch web pages as clean Markdown (web_fetch_md) and library docs via Context7 (web_docs_search, web_docs_fetch)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -25,7 +25,7 @@
25
25
  "@mozilla/readability": "^0.6.0",
26
26
  "turndown": "^7.2.0",
27
27
  "turndown-plugin-gfm": "^1.0.2",
28
- "@mrclrchtr/supi-core": "1.6.0"
28
+ "@mrclrchtr/supi-core": "1.8.0"
29
29
  },
30
30
  "bundledDependencies": [
31
31
  "@mrclrchtr/supi-core"
@@ -1,14 +1,11 @@
1
1
  // Prompt guidance and tool description for the web_docs_fetch tool.
2
2
 
3
- export const toolDescription = `Retrieve up-to-date documentation context for a specific library via Context7. Returns Markdown documentation and code snippets tailored to the query, or JSON-serialized snippet objects when \`raw: true\`. Use web_docs_fetch after web_docs_search or whenever the exact Context7 library ID is already known. Requires a Context7 library ID (e.g. /facebook/react, /vercel/next.js).`;
3
+ export const toolDescription = `Retrieve focused Context7 docs for a known library ID. Returns Markdown by default, or JSON snippets when \`raw: true\`.`;
4
4
 
5
- export const promptSnippet =
6
- "web_docs_fetch — retrieve focused, up-to-date Context7 docs for a known library ID";
5
+ export const promptSnippet = "web_docs_fetch — retrieve focused Context7 docs";
7
6
 
8
7
  export const promptGuidelines = [
9
- "Use web_docs_fetch after web_docs_search, or use web_docs_fetch directly when the exact Context7 `library_id` is already known.",
10
- "Use web_docs_fetch only with Context7 library IDs such as `/facebook/react` or `/vercel/next.js`.",
11
- "Use web_docs_fetch with a specific, task-oriented `query` to retrieve focused version-aware documentation instead of a vague broad dump.",
12
- "Use web_docs_fetch with `raw: true` only when you need structured JSON snippet objects instead of Markdown documentation.",
13
- "Call web_docs_search before web_docs_fetch when the correct `library_id` is unknown or ambiguous.",
8
+ "Use web_docs_fetch once the Context7 `library_id` is known; otherwise call web_docs_search first.",
9
+ "Use web_docs_fetch only with Context7 library IDs such as `/facebook/react`, and ask a specific `query`.",
10
+ "Use web_docs_fetch with `raw: true` only when you need JSON snippet objects instead of Markdown.",
14
11
  ];
@@ -1,12 +1,10 @@
1
1
  // Prompt guidance and tool description for the web_docs_search tool.
2
2
 
3
- export const toolDescription = `Search Context7 for library IDs and metadata before fetching docs. Returns a Markdown table of matching libraries (ID, name, description, trust score, benchmark score, snippet count, versions). Use web_docs_search when you know the library name but not the exact Context7 library ID.`;
3
+ export const toolDescription = `Search Context7 for library IDs before fetching docs. Returns a Markdown table of matching libraries and metadata.`;
4
4
 
5
- export const promptSnippet =
6
- "web_docs_search — find Context7 library IDs and candidate versions before calling web_docs_fetch";
5
+ export const promptSnippet = "web_docs_search — find Context7 library IDs before web_docs_fetch";
7
6
 
8
7
  export const promptGuidelines = [
9
- "Use web_docs_search before web_docs_fetch when you do not already know the exact Context7 `library_id`.",
10
- "Use web_docs_search with both `library_name` and a descriptive `query` so Context7 can rank results for the user's actual task.",
11
- "Review web_docs_search results carefully and choose the `library_id` that best matches the user's framework, package scope, and version needs.",
8
+ "Use web_docs_search before web_docs_fetch when the Context7 `library_id` is unknown.",
9
+ "Use web_docs_search with both `library_name` and a descriptive `query`, then choose the best `library_id`.",
12
10
  ];
@@ -4,19 +4,18 @@ import { spawnSync } from "node:child_process";
4
4
 
5
5
  const INLINE_MAX_CHARS = 15_000;
6
6
 
7
- export const toolDescription = `Fetch a web page and convert it to clean Markdown for LLM ingestion.
7
+ export const toolDescription = `Fetch a web page and convert it to Markdown.
8
8
 
9
- Use web_fetch_md when the user provides a public URL or asks you to inspect public web content. Only accepts real \`http://\` or \`https://\` URLs. If the page is access-controlled (login, paywall, private content), stop and ask the user for an allowed source or exported content.
9
+ Use web_fetch_md only for public \`http://\` or \`https://\` URLs. If a page is private or access-controlled, ask for another source.
10
10
 
11
11
  Output modes:
12
- - \`auto\` (default): returns Markdown inline if ≤${INLINE_MAX_CHARS.toLocaleString()} characters; otherwise writes to a temporary file and returns the path.
13
- - \`inline\`: always returns Markdown inline.
14
- - \`file\`: always writes to a temporary file and returns the path.
12
+ - \`auto\` (default): inline up to ${INLINE_MAX_CHARS.toLocaleString()} chars, otherwise return a temp file path
13
+ - \`inline\`: always inline
14
+ - \`file\`: always return a temp file path
15
15
 
16
- Links and images are absolutized by default. Use \`abs_links: false\` to keep them as-is.`;
16
+ Links and images default to absolute; use \`abs_links: false\` to keep relative paths.`;
17
17
 
18
- export const promptSnippet =
19
- "web_fetch_md — fetch a public URL and convert the response to clean Markdown for LLM ingestion";
18
+ export const promptSnippet = "web_fetch_md — fetch a public URL as Markdown";
20
19
 
21
20
  function isGhAvailable(): boolean {
22
21
  try {
@@ -29,11 +28,9 @@ function isGhAvailable(): boolean {
29
28
 
30
29
  export function buildPromptGuidelines(): string[] {
31
30
  const guidelines = [
32
- "Use web_fetch_md to fetch a public web page and convert it to clean Markdown for the model.",
33
- "Use web_fetch_md only with real `http://` or `https://` URLs; if a page is access-controlled, stop and ask the user for an allowed source or exported content.",
34
- "Use web_fetch_md with `output_mode: auto` unless you have a specific reason to force inline output or a temp file path.",
35
- "Use web_fetch_md with `output_mode: inline` only when you need the Markdown directly in context, and use web_fetch_md with `output_mode: file` when you explicitly want a saved temp file path.",
36
- "Use web_fetch_md with `abs_links: false` only when relative links or images are intentionally desired.",
31
+ "Use web_fetch_md only for public `http://` or `https://` pages; if a page is private or access-controlled, ask for an allowed source.",
32
+ "Use web_fetch_md with `output_mode: auto` by default; use `inline` for in-context Markdown and `file` for a temp path.",
33
+ "Use web_fetch_md with `abs_links: false` only when you want relative links or images.",
37
34
  ];
38
35
  if (isGhAvailable()) {
39
36
  guidelines.push(