MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / storeFullText

Function storeFullText

src/tools/web/web-fetch.ts:152–166  ·  view source on GitHub ↗

Store the full clean text so an omitted middle is recoverable via read_file. Best-effort.

(url: string, text: string)

Source from the content-addressed store, hash-verified

150
151/** Store the full clean text so an omitted middle is recoverable via read_file. Best-effort. */
152async function storeFullText(url: string, text: string): Promise<string | null> {
153 try {
154 const { QODEX_HOME } = await import('../../config/defaults.js');
155 const { promises: fs } = await import('fs');
156 const dir = path.join(QODEX_HOME, 'cache', 'web');
157 await fs.mkdir(dir, { recursive: true });
158 const slug = (() => {
159 try { return new URL(url).hostname.replace(/[^a-z0-9.]+/gi, '-').slice(0, 40); } catch { return 'page'; }
160 })();
161 const hash = createHash('sha1').update(url).digest('hex').slice(0, 10);
162 const file = path.join(dir, `${slug}-${hash}.md`);
163 await fs.writeFile(file, text);
164 return file;
165 } catch { return null; }
166}
167
168export class WebFetchTool extends Tool<z.infer<typeof WebFetchArgs>> {
169 name = 'web_fetch';

Callers 1

executeMethod · 0.85

Calls 1

updateMethod · 0.80

Tested by

no test coverage detected