@vercel/geistdocs 2.2.2 → 2.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/dist/cli/index.js +1 -1
- package/dist/internal/provider-client.d.ts.map +1 -1
- package/dist/internal/provider-client.js +2 -0
- package/dist/internal/search.d.ts +16 -1
- package/dist/internal/search.d.ts.map +1 -1
- package/dist/internal/search.js +2 -1
- package/docs/agents.md +1 -1
- package/docs/llms.txt +20 -1
- package/docs/manifest.json +1 -1
- package/docs/pages/provider.md +15 -0
- package/docs/pages/versioned-docs.md +4 -0
- package/package.json +1 -1
- package/template/content/docs/provider.mdx +16 -0
- package/template/content/docs/versioned-docs.mdx +4 -0
- package/template/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -4,4 +4,4 @@ import{program as A}from"commander";import{access as Xe,copyFile as Ke,readdir a
|
|
|
4
4
|
`);throw new AggregateError(s,`Mixedbread search sync did not complete:
|
|
5
5
|
${a}`)}return r},Mt=async({client:e,file:t,pollIntervalMs:n,pollTimeoutMs:r,sleep:s})=>{let i=t,o=Date.now()+r;for(;i.status==="pending"||i.status==="in_progress";){if(Date.now()>=o)throw new Error(`Mixedbread timed out while indexing file ${t.id}.`);await s(n),i=await e.retrieveStoreFile(t.id)}if(i.status!=="completed")throw new Error(`Mixedbread failed to index file ${t.id} (${i.status}).`);return i},Rt=async({client:e,desired:t,pollIntervalMs:n,pollTimeoutMs:r,sleep:s})=>{let i=await e.uploadFile({content:t.document.content,filename:`${L(t.document.id).slice(0,32)}.md`}),o;try{o=await e.createStoreFile({externalId:t.externalId,fileId:i,metadata:{...t.metadata,[g.rawFileId]:i}})}catch(a){try{await e.deleteFile(i)}catch(d){throw new AggregateError([a,d],`Mixedbread failed to attach and clean up raw file ${i}.`)}throw a}return Mt({client:e,file:o,pollIntervalMs:n,pollTimeoutMs:r,sleep:s})},Te=async({client:e,concurrency:t=Et,manifest:n,pollIntervalMs:r=St,pollTimeoutMs:s=bt,revision:i,revisionAncestors:o=[],revisionTimestamp:a,sleep:d=At})=>{let c=be(n);if(c.provider!=="mixedbread")return{deleted:0,skipped:c.documents.length,uploaded:0};let u=c.siteId?.trim();if(!u)throw new Error("Mixedbread retrieval requires a non-empty siteId in geistdocs.tsx.");if(c.documents.length===0)throw new Error("The Geistdocs search export is empty. Refusing to remove indexed documents.");let l=c.documents.map(p=>Pt(p,u,i,o,a)),m=new Map(l.map(p=>[p.document.id,p])),h=(await xe(e)).flatMap(p=>{let y=q(p.metadata);return y?.siteId===u?[{file:p,metadata:y}]:[]}),x=new Map,v=new Set;for(let p of h){W(p.metadata,i,a)&&v.add(p.metadata.documentId);let y=m.get(p.metadata.documentId);y&&p.metadata.contentHash===y.hash&&p.file.status==="completed"&&!x.has(p.metadata.documentId)&&x.set(p.metadata.documentId,p)}let _=l.filter(p=>!(x.has(p.document.id)||v.has(p.document.id)));await Ee(_,t,p=>Rt({client:e,desired:p,pollIntervalMs:r,pollTimeoutMs:s,sleep:d}));let E=(await xe(e)).flatMap(p=>{let y=q(p.metadata);return y?.siteId===u?[{file:p,metadata:y}]:[]}),D=new Set(E.filter(({metadata:p})=>W(p,i,a)).map(({metadata:p})=>p.documentId)),ie=new Set;for(let p of l){if(D.has(p.document.id))continue;let ae=E.filter(({file:B,metadata:k})=>B.status==="completed"&&k.documentId===p.document.id&&k.contentHash===p.hash).sort((B,k)=>B.file.id.localeCompare(k.file.id))[0];ae&&ie.add(ae.file.id)}let oe=E.filter(({file:p,metadata:y})=>p.status!=="pending"&&p.status!=="in_progress"&&!W(y,i,a)&&vt({currentRevision:i,currentRevisionAncestors:o,currentRevisionTimestamp:a,desired:m.get(y.documentId),metadata:y})&&!ie.has(p.id));return await Ee(oe,t,async({file:p,metadata:y})=>{await e.deleteFile(y.rawFileId??p.id),await e.deleteStoreFile(p.id)}),{deleted:oe.length,skipped:l.length-_.length,uploaded:_.length}};var kt=50,Ct=e=>`vercel integration add mixedbread --name docs-${e||"your-site-id"} --environment production`,Ie=(e,t)=>Ft("git",t,{cwd:e,encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim(),Ot=e=>{let t=process.env.VERCEL_GIT_COMMIT_SHA?.trim(),n=[];try{n=Ie(e,["rev-list",`--max-count=${kt+1}`,t||"HEAD"]).split(`
|
|
6
6
|
`).filter(Boolean)}catch{n=[]}let r=t||n[0],s;for(let i of Array.from(new Set([r,"HEAD"].filter(Boolean))))try{let o=Number(Ie(e,["show","-s","--format=%ct",i]));if(Number.isFinite(o)){s=o;break}}catch{}return{revision:r,revisionAncestors:n.filter(i=>i!==r),revisionTimestamp:s}},Pe=async({allowNonProduction:e=!1,dir:t=".next"}={})=>{let n=process.cwd();Dt.loadEnvConfig(n,!1);let r=process.env.MXBAI_API_KEY?.trim(),s=process.env.MXBAI_STORE_ID?.trim();if(process.env.VERCEL_ENV!=="production"&&!e){console.log("Geistdocs search sync skipped: this is not a production Vercel build.");return}if(!!r!=!!s)throw new Error("Mixedbread is partially configured. Set both MXBAI_API_KEY and MXBAI_STORE_ID.");let i;try{i=await _e({cwd:n,outputDirectory:t})}catch(a){if(!(r||s)){console.log("Geistdocs search sync skipped: no Mixedbread credentials or static search export were found.");return}throw a}if(i.provider!=="mixedbread"){console.log("Geistdocs search sync skipped: Ask AI uses local retrieval.");return}if(!(r&&s))throw new Error(["Mixedbread retrieval is enabled, but MXBAI_API_KEY or MXBAI_STORE_ID is missing.","From the root of this site's repository, linked to the correct Vercel project, run:",Ct(i.siteId)].join(`
|
|
7
|
-
`));let o=await Te({client:he({apiBaseUrl:process.env.MXBAI_BASE_URL,apiKey:r,storeId:s}),manifest:i,...Ot(n)});console.log(`Geistdocs search sync complete: ${o.uploaded} uploaded, ${o.deleted} deleted, ${o.skipped} unchanged.`)};import{readFileSync as $t,writeFileSync as Nt}from"fs";import{mkdir as Ut,readFile as Z,writeFile as Lt}from"fs/promises";import{dirname as Gt,extname as jt,relative as Re,resolve as j}from"path";import{intro as Vt,isCancel as Bt,log as I,multiselect as Jt,outro as G,spinner as Ht}from"@clack/prompts";import{glob as Xt}from"glob";import{Node as F,Project as Kt,SyntaxKind as Yt}from"ts-morph";var qt="geistdocs.tsx",zt="content/docs/**/*.mdx",ee=".translation-cache.json",Q=8,ve=()=>({version:1,entries:{}}),Wt=async e=>{let t=await Z(e),{createHash:n}=await import("crypto");return n("sha256").update(t).digest("hex")},Qt=e=>{let t=j(process.cwd(),e);return $t(t,"utf8")},Ae=e=>F.isObjectLiteralExpression(e)?e.getProperties().flatMap(t=>{if(F.isPropertyAssignment(t)){let n=t.getNameNode();if(F.isIdentifier(n)||F.isStringLiteral(n))return[n.getText().replaceAll(/['"]/g,"")]}return[]}).filter(Boolean):[],Zt=e=>{try{let t=new Kt({compilerOptions:{allowJs:!0,jsx:4,module:99,target:10},skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!0}),n=Qt(e),i=t.createSourceFile(e,n,{overwrite:!0}).getVariableDeclarations().find(a=>a.getName()==="translations")?.getInitializer();if(!i)return[];if(F.isObjectLiteralExpression(i))return Ae(i);let o=i.getFirstDescendantByKind(Yt.ObjectLiteralExpression);return o?Ae(o):[]}catch(t){let n=t instanceof Error?t.message:`${t}`;return I.warn(`Failed to read locales from ${e}: ${n}`),[]}},en=async()=>{let e=await Jt({message:"Which locales should be translated?",options:[{value:"cn",label:"Chinese (cn)"},{value:"jp",label:"Japanese (jp)"},{value:"es",label:"Spanish (es)"},{value:"fr",label:"French (fr)"},{value:"de",label:"German (de)"}],required:!0});return Bt(e)&&(G("Translation cancelled"),process.exit(0)),e},tn=async e=>(await Xt(e,{cwd:process.cwd(),absolute:!0,nodir:!0})).sort(),nn=async()=>{let e=j(process.cwd(),ee);try{let t=await Z(e,"utf8"),n=JSON.parse(t);return n.version!==1||!n.entries?ve():{version:1,entries:n.entries}}catch{return ve()}},Me=e=>{let t=j(process.cwd(),ee),n=JSON.stringify(e,null,2);Nt(t,n,"utf8")},rn=async e=>{let t=await Promise.all(e.map(async n=>[n,await Wt(n)]));return Object.fromEntries(t)},sn=(e,t)=>{let n=jt(e);return`${e.slice(0,-n.length)}.${t}${n}`},Fe=(e,t)=>`${Re(process.cwd(),e)}::${t}`,on=(e,t,n,r,s=!1)=>{let i=[],o=0;for(let a of t){let d=n[a];for(let c of e){let u=sn(a,c),l=Fe(a,c),m=r.entries[l];if(!s&&m?.hash===d){o+=1;continue}i.push({locale:c,sourceFile:a,sourceHash:d,targetFile:u})}}return{tasks:i,skippedCount:o}},an=async e=>{await Ut(Gt(e),{recursive:!0})},cn=async(e,t,n)=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,locale:n})});if(!r.ok){let i=await r.text();throw new Error(`API request failed (${r.status}): ${i}`)}let s=await r.json();if(!s.translation)throw new Error("API response did not include a translation");return s.translation},dn=async(e,t,n)=>{let r=await Z(e.sourceFile,"utf8"),s=await cn(t,r,e.locale);await an(e.targetFile),await Lt(e.targetFile,s,"utf8"),n.entries[Fe(e.sourceFile,e.locale)]={hash:e.sourceHash,updatedAt:new Date().toISOString()}},De=async(e,t)=>{Vt("Translate MDX content");let n=e??zt,r=t.url||process.env.GEISTDOCS_TRANSLATE_URL||"https://geistdocs.com/translate",s=Zt(t.config??qt),i=await tn(n);i.length===0&&(I.error(`No MDX files found matching pattern: ${n}`),G("Translation cancelled"),process.exit(1)),I.info(`Found ${i.length} MDX file(s) matching pattern`),s.length===0&&(s=await en());let o=j(process.cwd(),ee),a=await nn();await Me(a),I.info(`Using cache: ${o}`);let d=await rn(i),{tasks:c,skippedCount:u}=on(s,i,d,a,t.force);if(c.length===0){I.success("All translations are up to date!"),G(`Skipped ${u} file(s) (unchanged)`);return}let l=[];for(let h=0;h<c.length;h+=Q)l.push(c.slice(h,h+Q));I.info(`Processing ${c.length} translation(s) in ${l.length} batch(es) of up to ${Q}`),u>0&&I.info(`Skipped ${u} translation(s) (unchanged)`);let m=Ht();m.start("Translating content...");let f=0;for(let h of l)await Promise.all(h.map(async x=>{await dn(x,r,a),f+=1,m.message(`Translated ${f}/${c.length}: ${Re(process.cwd(),x.targetFile)}`)})),await Me(a);m.stop("Translation complete!"),G(`Created/updated ${c.length} file(s)`)};import{access as ln,copyFile as pn,mkdir as $e,rm as re}from"fs/promises";import{dirname as un,join as P}from"path";import{intro as gn,log as w,outro as V,spinner as Ne}from"@clack/prompts";import{glob as mn}from"glob";var fn=["**/*"],hn=["content/docs/**"],te=".geistdocs-tmp",wn=async(e,t)=>{let n=P(e,t);await re(n,{recursive:!0,force:!0}),await $e(n,{recursive:!0})},ne=async e=>await re(e,{recursive:!0,force:!0}),ke=async(e,t,n)=>(await mn(e,{cwd:n,nodir:!0,dot:!0,ignore:[".git/**",...t]})).sort(),yn=async e=>{try{return await ln(e),!0}catch{return!1}},xn=async(e,t,n)=>{let r=P(t,e),s=P(n,e);return await yn(r)?(await pn(r,s),{success:!0}):{success:!1,error:`Source file not found: ${r}`}},En=async(e,t)=>{let n=P(t,e);return await re(n,{force:!0}),{success:!0}},Ce=20,Oe=async(e,t,n)=>{let r=[];for(let s=0;s<e.length;s+=n){let i=e.slice(s,s+n),o=await Promise.all(i.map(t));r.push(...o)}return r},Sn=async(e,t,n,r,s)=>{let i={success:[],deleted:[],failed:[]},o=[...new Set(e.map(d=>un(P(r,d))))];s.message(`Creating ${o.length} directories...`),await Promise.all(o.map(d=>$e(d,{recursive:!0}))),s.message(`Updating ${e.length} files...`);let a=await Oe(e,async d=>{let c=await xn(d,n,r);return{file:d,...c}},Ce);for(let{file:d,success:c,error:u}of a)c?i.success.push(d):i.failed.push({file:d,error:u??"Unknown error"});if(t.length>0){s.message(`Deleting ${t.length} files...`);let d=await Oe(t,async c=>{try{return await En(c,r),{file:c,success:!0}}catch(u){let l=u instanceof Error?u.message:`${u}`;return{file:c,success:!1,error:l}}},Ce);for(let c of d)c.success?i.deleted.push(c.file):i.failed.push({file:c.file,error:c.error})}return i},bn=e=>{if(e.success.length>0){w.success(`Successfully updated ${e.success.length} files:`);for(let t of e.success)w.info(` \u2713 ${t}`)}if(e.deleted.length>0){w.success(`Deleted ${e.deleted.length} files:`);for(let t of e.deleted)w.info(` \u{1F5D1} ${t}`)}if(e.failed.length>0){w.warn(`Failed to update ${e.failed.length} files:`);for(let{file:t,error:n}of e.failed)w.error(` \u2717 ${t}: ${n}`)}},_n=e=>e.includes("canary")?"canary":"latest",Tn=async e=>{let t=await fetch(`https://registry.npmjs.org/${encodeURIComponent(b)}`);if(!t.ok)throw new Error(`Failed to resolve ${b}@${e}`);let r=(await t.json())["dist-tags"]?.[e];if(!r)throw new Error(`Could not find dist-tag ${e} for ${b}`);return r},In=async e=>{let t=await M(e),n=J(t,b);if(!n)return{currentVersion:n,nextVersion:void 0,updated:!1};let r=_n(n),s=await Tn(r);return n===s?{currentVersion:n,nextVersion:s,updateTag:r,updated:!1}:($(t,b,s),await O(e,t),{currentVersion:n,nextVersion:s,updateTag:r,updated:!0})},Pn=async(e,t,n)=>{let r=await M(e);if(!le(r,b))return!1;t&&t.length>0&&w.warn("Ignoring file patterns for a package-based site. This update will bump the package version instead."),n?.sync&&w.warn("Ignoring --sync for a package-based site. Runtime updates now come from the package version.");let{currentVersion:s,nextVersion:i,updateTag:o,updated:a}=await In(e);if(!a)return w.success(s?`@vercel/geistdocs is already at ${i} (${o}).`:"No package version update was needed."),V("Package-based site is already up to date."),!0;w.info(`Bumping ${b} from ${s} to ${i} (${o})`);let d=Ne();return d.start("Installing updated package version..."),await T("pnpm",["install"],{cwd:e}),d.stop("Package update complete!"),V("Please review and test the upgraded package version."),!0},vn=async(e,t,n,r,s)=>{let i=P(e,te),o=Ne(),a=s?.sync?i:t;o.start("Preparing template snapshot..."),s?.sync&&(await wn(e,te),await N(i)),o.message("Scanning for files...");let d=await ke(n,r,a),c=[];if(s?.sync){o.message("Comparing with local files...");let l=await ke(n,r,e),m=new Set(d);c=l.filter(f=>!m.has(f))}if(o.stop(`Found ${d.length} files to update`),d.length===0&&c.length===0){w.warn("No files matched the patterns. Nothing to update."),s?.sync&&await ne(i),V("Update cancelled.");return}w.info(`Patterns: ${n.length}`),w.info(`Files to update: ${d.length}`),s?.sync&&w.info(`Files to delete: ${c.length}`),o.start("Updating files...");let u=await Sn(d,c,a,e,o);s?.sync&&(o.message("Cleaning up..."),await ne(i)),o.stop("Update complete!"),bn(u),V("Please review and test the changes carefully.")},Ue=async(e,t)=>{let n=process.cwd(),r=H(),s=e&&e.length>0?e:fn,i=e&&e.length>0?[]:hn;try{if(gn("Let's update your Geistdocs project!"),await Pn(n,e,t))return;w.info("Template source: bundled package snapshot"),e&&e.length>0&&w.info(`Updating specific files: ${e.join(", ")}`),t?.sync&&w.info("Sync mode enabled: will delete files removed from template"),await vn(n,r,s,i,t)}catch(o){let a=o instanceof Error?o.message:`${o}`;try{await ne(P(n,te))}catch{}w.error(`Failed to update project: ${a}`),process.exit(1)}};A.name("geistdocs").description("CLI for Geistdocs projects").version("2.2.2","-v, --version","Output the current version");A.command("init").description("Initialize a new Geistdocs project").option("--name <name>","Name of the project").option("--disable-git","Disable git initialization").action(fe);A.command("update [files...]").description("Update a Geistdocs project (optionally specify files/patterns to update)").option("--sync","Delete local files that no longer exist in the template").action(Ue);A.command("translate [pattern]").description("Translate MDX file(s) to one or more locales (default: content/docs/**/*.mdx)").option("--config <path>","Path to config file to load locales from (defaults to geistdocs.tsx)").option("--url <url>","Custom translation API URL (defaults to GEISTDOCS_TRANSLATE_URL or https://geistdocs.com/translate)").option("--force","Force re-translation of all files, ignoring cache").action(De);var An=A.command("search").description("Manage the external search index used by Ask AI");An.command("sync").description("Sync the latest static docs export to Mixedbread").option("--dir <path>","Next.js output directory",".next").option("--allow-non-production","Run outside a production Vercel build").action(Pe);await A.parseAsync(process.argv).catch(e=>{console.error(e instanceof Error?e.message:e),process.exitCode=1});
|
|
7
|
+
`));let o=await Te({client:he({apiBaseUrl:process.env.MXBAI_BASE_URL,apiKey:r,storeId:s}),manifest:i,...Ot(n)});console.log(`Geistdocs search sync complete: ${o.uploaded} uploaded, ${o.deleted} deleted, ${o.skipped} unchanged.`)};import{readFileSync as $t,writeFileSync as Nt}from"fs";import{mkdir as Ut,readFile as Z,writeFile as Lt}from"fs/promises";import{dirname as Gt,extname as jt,relative as Re,resolve as j}from"path";import{intro as Vt,isCancel as Bt,log as I,multiselect as Jt,outro as G,spinner as Ht}from"@clack/prompts";import{glob as Xt}from"glob";import{Node as F,Project as Kt,SyntaxKind as Yt}from"ts-morph";var qt="geistdocs.tsx",zt="content/docs/**/*.mdx",ee=".translation-cache.json",Q=8,ve=()=>({version:1,entries:{}}),Wt=async e=>{let t=await Z(e),{createHash:n}=await import("crypto");return n("sha256").update(t).digest("hex")},Qt=e=>{let t=j(process.cwd(),e);return $t(t,"utf8")},Ae=e=>F.isObjectLiteralExpression(e)?e.getProperties().flatMap(t=>{if(F.isPropertyAssignment(t)){let n=t.getNameNode();if(F.isIdentifier(n)||F.isStringLiteral(n))return[n.getText().replaceAll(/['"]/g,"")]}return[]}).filter(Boolean):[],Zt=e=>{try{let t=new Kt({compilerOptions:{allowJs:!0,jsx:4,module:99,target:10},skipAddingFilesFromTsConfig:!0,useInMemoryFileSystem:!0}),n=Qt(e),i=t.createSourceFile(e,n,{overwrite:!0}).getVariableDeclarations().find(a=>a.getName()==="translations")?.getInitializer();if(!i)return[];if(F.isObjectLiteralExpression(i))return Ae(i);let o=i.getFirstDescendantByKind(Yt.ObjectLiteralExpression);return o?Ae(o):[]}catch(t){let n=t instanceof Error?t.message:`${t}`;return I.warn(`Failed to read locales from ${e}: ${n}`),[]}},en=async()=>{let e=await Jt({message:"Which locales should be translated?",options:[{value:"cn",label:"Chinese (cn)"},{value:"jp",label:"Japanese (jp)"},{value:"es",label:"Spanish (es)"},{value:"fr",label:"French (fr)"},{value:"de",label:"German (de)"}],required:!0});return Bt(e)&&(G("Translation cancelled"),process.exit(0)),e},tn=async e=>(await Xt(e,{cwd:process.cwd(),absolute:!0,nodir:!0})).sort(),nn=async()=>{let e=j(process.cwd(),ee);try{let t=await Z(e,"utf8"),n=JSON.parse(t);return n.version!==1||!n.entries?ve():{version:1,entries:n.entries}}catch{return ve()}},Me=e=>{let t=j(process.cwd(),ee),n=JSON.stringify(e,null,2);Nt(t,n,"utf8")},rn=async e=>{let t=await Promise.all(e.map(async n=>[n,await Wt(n)]));return Object.fromEntries(t)},sn=(e,t)=>{let n=jt(e);return`${e.slice(0,-n.length)}.${t}${n}`},Fe=(e,t)=>`${Re(process.cwd(),e)}::${t}`,on=(e,t,n,r,s=!1)=>{let i=[],o=0;for(let a of t){let d=n[a];for(let c of e){let u=sn(a,c),l=Fe(a,c),m=r.entries[l];if(!s&&m?.hash===d){o+=1;continue}i.push({locale:c,sourceFile:a,sourceHash:d,targetFile:u})}}return{tasks:i,skippedCount:o}},an=async e=>{await Ut(Gt(e),{recursive:!0})},cn=async(e,t,n)=>{let r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,locale:n})});if(!r.ok){let i=await r.text();throw new Error(`API request failed (${r.status}): ${i}`)}let s=await r.json();if(!s.translation)throw new Error("API response did not include a translation");return s.translation},dn=async(e,t,n)=>{let r=await Z(e.sourceFile,"utf8"),s=await cn(t,r,e.locale);await an(e.targetFile),await Lt(e.targetFile,s,"utf8"),n.entries[Fe(e.sourceFile,e.locale)]={hash:e.sourceHash,updatedAt:new Date().toISOString()}},De=async(e,t)=>{Vt("Translate MDX content");let n=e??zt,r=t.url||process.env.GEISTDOCS_TRANSLATE_URL||"https://geistdocs.com/translate",s=Zt(t.config??qt),i=await tn(n);i.length===0&&(I.error(`No MDX files found matching pattern: ${n}`),G("Translation cancelled"),process.exit(1)),I.info(`Found ${i.length} MDX file(s) matching pattern`),s.length===0&&(s=await en());let o=j(process.cwd(),ee),a=await nn();await Me(a),I.info(`Using cache: ${o}`);let d=await rn(i),{tasks:c,skippedCount:u}=on(s,i,d,a,t.force);if(c.length===0){I.success("All translations are up to date!"),G(`Skipped ${u} file(s) (unchanged)`);return}let l=[];for(let h=0;h<c.length;h+=Q)l.push(c.slice(h,h+Q));I.info(`Processing ${c.length} translation(s) in ${l.length} batch(es) of up to ${Q}`),u>0&&I.info(`Skipped ${u} translation(s) (unchanged)`);let m=Ht();m.start("Translating content...");let f=0;for(let h of l)await Promise.all(h.map(async x=>{await dn(x,r,a),f+=1,m.message(`Translated ${f}/${c.length}: ${Re(process.cwd(),x.targetFile)}`)})),await Me(a);m.stop("Translation complete!"),G(`Created/updated ${c.length} file(s)`)};import{access as ln,copyFile as pn,mkdir as $e,rm as re}from"fs/promises";import{dirname as un,join as P}from"path";import{intro as gn,log as w,outro as V,spinner as Ne}from"@clack/prompts";import{glob as mn}from"glob";var fn=["**/*"],hn=["content/docs/**"],te=".geistdocs-tmp",wn=async(e,t)=>{let n=P(e,t);await re(n,{recursive:!0,force:!0}),await $e(n,{recursive:!0})},ne=async e=>await re(e,{recursive:!0,force:!0}),ke=async(e,t,n)=>(await mn(e,{cwd:n,nodir:!0,dot:!0,ignore:[".git/**",...t]})).sort(),yn=async e=>{try{return await ln(e),!0}catch{return!1}},xn=async(e,t,n)=>{let r=P(t,e),s=P(n,e);return await yn(r)?(await pn(r,s),{success:!0}):{success:!1,error:`Source file not found: ${r}`}},En=async(e,t)=>{let n=P(t,e);return await re(n,{force:!0}),{success:!0}},Ce=20,Oe=async(e,t,n)=>{let r=[];for(let s=0;s<e.length;s+=n){let i=e.slice(s,s+n),o=await Promise.all(i.map(t));r.push(...o)}return r},Sn=async(e,t,n,r,s)=>{let i={success:[],deleted:[],failed:[]},o=[...new Set(e.map(d=>un(P(r,d))))];s.message(`Creating ${o.length} directories...`),await Promise.all(o.map(d=>$e(d,{recursive:!0}))),s.message(`Updating ${e.length} files...`);let a=await Oe(e,async d=>{let c=await xn(d,n,r);return{file:d,...c}},Ce);for(let{file:d,success:c,error:u}of a)c?i.success.push(d):i.failed.push({file:d,error:u??"Unknown error"});if(t.length>0){s.message(`Deleting ${t.length} files...`);let d=await Oe(t,async c=>{try{return await En(c,r),{file:c,success:!0}}catch(u){let l=u instanceof Error?u.message:`${u}`;return{file:c,success:!1,error:l}}},Ce);for(let c of d)c.success?i.deleted.push(c.file):i.failed.push({file:c.file,error:c.error})}return i},bn=e=>{if(e.success.length>0){w.success(`Successfully updated ${e.success.length} files:`);for(let t of e.success)w.info(` \u2713 ${t}`)}if(e.deleted.length>0){w.success(`Deleted ${e.deleted.length} files:`);for(let t of e.deleted)w.info(` \u{1F5D1} ${t}`)}if(e.failed.length>0){w.warn(`Failed to update ${e.failed.length} files:`);for(let{file:t,error:n}of e.failed)w.error(` \u2717 ${t}: ${n}`)}},_n=e=>e.includes("canary")?"canary":"latest",Tn=async e=>{let t=await fetch(`https://registry.npmjs.org/${encodeURIComponent(b)}`);if(!t.ok)throw new Error(`Failed to resolve ${b}@${e}`);let r=(await t.json())["dist-tags"]?.[e];if(!r)throw new Error(`Could not find dist-tag ${e} for ${b}`);return r},In=async e=>{let t=await M(e),n=J(t,b);if(!n)return{currentVersion:n,nextVersion:void 0,updated:!1};let r=_n(n),s=await Tn(r);return n===s?{currentVersion:n,nextVersion:s,updateTag:r,updated:!1}:($(t,b,s),await O(e,t),{currentVersion:n,nextVersion:s,updateTag:r,updated:!0})},Pn=async(e,t,n)=>{let r=await M(e);if(!le(r,b))return!1;t&&t.length>0&&w.warn("Ignoring file patterns for a package-based site. This update will bump the package version instead."),n?.sync&&w.warn("Ignoring --sync for a package-based site. Runtime updates now come from the package version.");let{currentVersion:s,nextVersion:i,updateTag:o,updated:a}=await In(e);if(!a)return w.success(s?`@vercel/geistdocs is already at ${i} (${o}).`:"No package version update was needed."),V("Package-based site is already up to date."),!0;w.info(`Bumping ${b} from ${s} to ${i} (${o})`);let d=Ne();return d.start("Installing updated package version..."),await T("pnpm",["install"],{cwd:e}),d.stop("Package update complete!"),V("Please review and test the upgraded package version."),!0},vn=async(e,t,n,r,s)=>{let i=P(e,te),o=Ne(),a=s?.sync?i:t;o.start("Preparing template snapshot..."),s?.sync&&(await wn(e,te),await N(i)),o.message("Scanning for files...");let d=await ke(n,r,a),c=[];if(s?.sync){o.message("Comparing with local files...");let l=await ke(n,r,e),m=new Set(d);c=l.filter(f=>!m.has(f))}if(o.stop(`Found ${d.length} files to update`),d.length===0&&c.length===0){w.warn("No files matched the patterns. Nothing to update."),s?.sync&&await ne(i),V("Update cancelled.");return}w.info(`Patterns: ${n.length}`),w.info(`Files to update: ${d.length}`),s?.sync&&w.info(`Files to delete: ${c.length}`),o.start("Updating files...");let u=await Sn(d,c,a,e,o);s?.sync&&(o.message("Cleaning up..."),await ne(i)),o.stop("Update complete!"),bn(u),V("Please review and test the changes carefully.")},Ue=async(e,t)=>{let n=process.cwd(),r=H(),s=e&&e.length>0?e:fn,i=e&&e.length>0?[]:hn;try{if(gn("Let's update your Geistdocs project!"),await Pn(n,e,t))return;w.info("Template source: bundled package snapshot"),e&&e.length>0&&w.info(`Updating specific files: ${e.join(", ")}`),t?.sync&&w.info("Sync mode enabled: will delete files removed from template"),await vn(n,r,s,i,t)}catch(o){let a=o instanceof Error?o.message:`${o}`;try{await ne(P(n,te))}catch{}w.error(`Failed to update project: ${a}`),process.exit(1)}};A.name("geistdocs").description("CLI for Geistdocs projects").version("2.3.0","-v, --version","Output the current version");A.command("init").description("Initialize a new Geistdocs project").option("--name <name>","Name of the project").option("--disable-git","Disable git initialization").action(fe);A.command("update [files...]").description("Update a Geistdocs project (optionally specify files/patterns to update)").option("--sync","Delete local files that no longer exist in the template").action(Ue);A.command("translate [pattern]").description("Translate MDX file(s) to one or more locales (default: content/docs/**/*.mdx)").option("--config <path>","Path to config file to load locales from (defaults to geistdocs.tsx)").option("--url <url>","Custom translation API URL (defaults to GEISTDOCS_TRANSLATE_URL or https://geistdocs.com/translate)").option("--force","Force re-translation of all files, ignoring cache").action(De);var An=A.command("search").description("Manage the external search index used by Ask AI");An.command("sync").description("Sync the latest static docs export to Mixedbread").option("--dir <path>","Next.js output directory",".next").option("--allow-non-production","Run outside a production Vercel build").action(Pe);await A.parseAsync(process.argv).catch(e=>{console.error(e instanceof Error?e.message:e),process.exitCode=1});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider-client.d.ts","sourceRoot":"","sources":["../../src/internal/provider-client.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EACL,KAAK,cAAc,EAKpB,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAejD,MAAM,WAAW,sBACf,SAAQ,cAAc,CAAC,OAAO,YAAY,CAAC;IAC3C,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;
|
|
1
|
+
{"version":3,"file":"provider-client.d.ts","sourceRoot":"","sources":["../../src/internal/provider-client.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EACL,KAAK,cAAc,EAKpB,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAejD,MAAM,WAAW,sBACf,SAAQ,cAAc,CAAC,OAAO,YAAY,CAAC;IAC3C,MAAM,EAAE,eAAe,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAmFD,eAAO,MAAM,iBAAiB,GAAI,OAAO,sBAAsB,4CAQ9D,CAAC"}
|
|
@@ -40,6 +40,8 @@ const GeistdocsProviderInner = ({ config, search, theme: _theme, lang, ...props
|
|
|
40
40
|
document.addEventListener("keydown", handleKeyDown, true);
|
|
41
41
|
return () => document.removeEventListener("keydown", handleKeyDown, true);
|
|
42
42
|
}, [enabled, isOpen, setIsOpen]);
|
|
43
|
+
// fumadocs spreads the provider's `search.options` onto the dialog, which is
|
|
44
|
+
// how a consumer reaches `tag`. Typed here so it survives the hand-off.
|
|
43
45
|
const SearchDialogComponent = useCallback((searchProps) => (_jsx(GeistdocsSearchDialog, { basePath: config.basePath, ...searchProps })), [config.basePath]);
|
|
44
46
|
return (_jsxs("div", { className: cn("@container transition-[padding-right] duration-150 ease-[cubic-bezier(0.175,0.885,0.32,1.1)] motion-reduce:transition-none", enabled && isOpen && !isMobile ? "pr-[400px]!" : null), "data-geistdocs-container": true, children: [_jsx(RootProvider, { i18n: i18nProvider(lang ?? i18n.defaultLanguage), search: {
|
|
45
47
|
SearchDialog: SearchDialogComponent,
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { type SharedProps } from "fumadocs-ui/components/dialog/search";
|
|
2
|
-
export declare const GeistdocsSearchDialog: ({ basePath, ...props }: SharedProps & {
|
|
2
|
+
export declare const GeistdocsSearchDialog: ({ basePath, tag, ...props }: SharedProps & {
|
|
3
3
|
basePath?: string;
|
|
4
|
+
/**
|
|
5
|
+
* Scope passed through to the search route as fumadocs' `tag` query
|
|
6
|
+
* parameter, for sites whose index is partitioned (by version, section, or
|
|
7
|
+
* product) and whose dialog should answer from the reader's partition.
|
|
8
|
+
*
|
|
9
|
+
* Supply it through the provider's `search.options`, which fumadocs spreads
|
|
10
|
+
* onto this dialog. Left undefined the parameter is omitted, so the request
|
|
11
|
+
* is unchanged.
|
|
12
|
+
*
|
|
13
|
+
* It belongs in the query string rather than a header or a cookie because
|
|
14
|
+
* fumadocs' fetch client memoizes results per request URL for the lifetime
|
|
15
|
+
* of the page: two scopes that produce the same URL would share one cache
|
|
16
|
+
* entry, and the second would be served the first's results.
|
|
17
|
+
*/
|
|
18
|
+
tag?: string | string[];
|
|
4
19
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
5
20
|
//# sourceMappingURL=search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/internal/search.tsx"],"names":[],"mappings":"AAGA,OAAO,EAUL,KAAK,WAAW,EACjB,MAAM,sCAAsC,CAAC;AAI9C,eAAO,MAAM,qBAAqB,GAAI,
|
|
1
|
+
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../src/internal/search.tsx"],"names":[],"mappings":"AAGA,OAAO,EAUL,KAAK,WAAW,EACjB,MAAM,sCAAsC,CAAC;AAI9C,eAAO,MAAM,qBAAqB,GAAI,6BAInC,WAAW,GAAG;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACzB,4CAyCA,CAAC"}
|
package/dist/internal/search.js
CHANGED
|
@@ -4,11 +4,12 @@ import { useDocsSearch } from "fumadocs-core/search/client";
|
|
|
4
4
|
import { SearchDialog as FumadocsSearchDialog, SearchDialogClose, SearchDialogContent, SearchDialogHeader, SearchDialogIcon, SearchDialogInput, SearchDialogList, SearchDialogListItem, SearchDialogOverlay, } from "fumadocs-ui/components/dialog/search";
|
|
5
5
|
import { useI18n } from "fumadocs-ui/contexts/i18n";
|
|
6
6
|
import { getPublicPath } from "../config";
|
|
7
|
-
export const GeistdocsSearchDialog = ({ basePath, ...props }) => {
|
|
7
|
+
export const GeistdocsSearchDialog = ({ basePath, tag, ...props }) => {
|
|
8
8
|
const { locale } = useI18n();
|
|
9
9
|
const { search, setSearch, query } = useDocsSearch({
|
|
10
10
|
type: "fetch",
|
|
11
11
|
locale,
|
|
12
|
+
tag,
|
|
12
13
|
api: getPublicPath("/api/search", basePath),
|
|
13
14
|
});
|
|
14
15
|
return (_jsxs(FumadocsSearchDialog, { isLoading: query.isLoading, onSearchChange: setSearch, search: search, ...props, children: [_jsx(SearchDialogOverlay, { className: "bg-background-100/80 backdrop-blur-none" }), _jsxs(SearchDialogContent, { className: "w-[640px] max-w-[calc(100vw-1rem)] border-none shadow-[var(--ds-shadow-modal)]", "data-geistdocs-command-modal": true, onEscapeKeyDown: () => props.onOpenChange(false), children: [_jsxs(SearchDialogHeader, { children: [_jsx(SearchDialogIcon, {}), _jsx(SearchDialogInput, {}), _jsx(SearchDialogClose, {})] }), _jsx(SearchDialogList, { "aria-label": "Search results", Item: (itemProps) => (_jsx(SearchDialogListItem, { ...itemProps, role: "option" })), items: query.data === "empty" ? null : query.data, role: "listbox" })] })] }));
|
package/docs/agents.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Geistdocs Package Docs
|
|
2
2
|
|
|
3
|
-
These docs are bundled with `@vercel/geistdocs` 2.
|
|
3
|
+
These docs are bundled with `@vercel/geistdocs` 2.3.0 so agents can understand the installed package without web access.
|
|
4
4
|
They are generated from `apps/template/content/docs` during the package build.
|
|
5
5
|
|
|
6
6
|
## How to use these files
|
package/docs/llms.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Geistdocs Package Documentation
|
|
2
2
|
|
|
3
|
-
These docs are bundled with `@vercel/geistdocs` 2.
|
|
3
|
+
These docs are bundled with `@vercel/geistdocs` 2.3.0.
|
|
4
4
|
They describe how to build package-backed Geistdocs sites and how to use the package APIs from generated project adapters.
|
|
5
5
|
|
|
6
6
|
## Documentation Index
|
|
@@ -2287,6 +2287,21 @@ const Layout = ({ children }: LayoutProps) => (
|
|
|
2287
2287
|
|
|
2288
2288
|
The generated local adapter imports the package provider and passes your site config to it.
|
|
2289
2289
|
|
|
2290
|
+
## Search scope
|
|
2291
|
+
|
|
2292
|
+
A search index partitioned by version, section, or product usually wants the dialog to answer from the partition the reader is in. Pass that scope as `search.options.tag`:
|
|
2293
|
+
|
|
2294
|
+
```tsx title="app/layout.tsx"
|
|
2295
|
+
<GeistdocsProvider config={config} search={{ options: { tag: "v5" } }}>
|
|
2296
|
+
```
|
|
2297
|
+
|
|
2298
|
+
The dialog sends it to your search route as `?tag=v5`, alongside the query. Read it from the request URL and filter results with it. Leave the option unset and the parameter is omitted, so the request is unchanged.
|
|
2299
|
+
|
|
2300
|
+
Pass the scope here rather than reading a header or a cookie in the route. The search client caches results per request URL for the lifetime of the page, so two scopes that produce the same URL share one cache entry, and the second reader is served the first reader's results.
|
|
2301
|
+
|
|
2302
|
+
> Note:
|
|
2303
|
+
`createSearchRoute` indexes pages without a `tag` field, and tagged queries match with `containsAll`, so a tag passed to the built-in route matches nothing.
|
|
2304
|
+
|
|
2290
2305
|
## AI Sidebar
|
|
2291
2306
|
|
|
2292
2307
|
When users open the AI chat on desktop, the provider automatically adds padding to prevent content from being hidden behind the sidebar. On mobile, the chat opens as a drawer instead, so no padding is needed.
|
|
@@ -2614,6 +2629,10 @@ pages can't be enumerated locally.
|
|
|
2614
2629
|
|
|
2615
2630
|
Each public route family needs a matching markdown route in `proxy.ts`. Read [Proxy and markdown routes](/docs/proxy) for the proxy configuration.
|
|
2616
2631
|
|
|
2632
|
+
## Scope search to a version
|
|
2633
|
+
|
|
2634
|
+
The search dialog does not know which version a reader is on. Pass the current version to the provider as `search.options.tag` and filter on it in your search route, so a query answers from the version the reader is reading. Read [Search scope](/docs/provider#search-scope) for the setup.
|
|
2635
|
+
|
|
2617
2636
|
## Next steps
|
|
2618
2637
|
|
|
2619
2638
|
- Read [Proxy and markdown routes](/docs/proxy) to connect versioned pages to `.md`, `.mdx`, and AI-agent rewrites.
|
package/docs/manifest.json
CHANGED
package/docs/pages/provider.md
CHANGED
|
@@ -47,6 +47,21 @@ const Layout = ({ children }: LayoutProps) => (
|
|
|
47
47
|
|
|
48
48
|
The generated local adapter imports the package provider and passes your site config to it.
|
|
49
49
|
|
|
50
|
+
## Search scope
|
|
51
|
+
|
|
52
|
+
A search index partitioned by version, section, or product usually wants the dialog to answer from the partition the reader is in. Pass that scope as `search.options.tag`:
|
|
53
|
+
|
|
54
|
+
```tsx title="app/layout.tsx"
|
|
55
|
+
<GeistdocsProvider config={config} search={{ options: { tag: "v5" } }}>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The dialog sends it to your search route as `?tag=v5`, alongside the query. Read it from the request URL and filter results with it. Leave the option unset and the parameter is omitted, so the request is unchanged.
|
|
59
|
+
|
|
60
|
+
Pass the scope here rather than reading a header or a cookie in the route. The search client caches results per request URL for the lifetime of the page, so two scopes that produce the same URL share one cache entry, and the second reader is served the first reader's results.
|
|
61
|
+
|
|
62
|
+
> Note:
|
|
63
|
+
`createSearchRoute` indexes pages without a `tag` field, and tagged queries match with `containsAll`, so a tag passed to the built-in route matches nothing.
|
|
64
|
+
|
|
50
65
|
## AI Sidebar
|
|
51
66
|
|
|
52
67
|
When users open the AI chat on desktop, the provider automatically adds padding to prevent content from being hidden behind the sidebar. On mobile, the chat opens as a drawer instead, so no padding is needed.
|
|
@@ -292,6 +292,10 @@ pages can't be enumerated locally.
|
|
|
292
292
|
|
|
293
293
|
Each public route family needs a matching markdown route in `proxy.ts`. Read [Proxy and markdown routes](/docs/proxy) for the proxy configuration.
|
|
294
294
|
|
|
295
|
+
## Scope search to a version
|
|
296
|
+
|
|
297
|
+
The search dialog does not know which version a reader is on. Pass the current version to the provider as `search.options.tag` and filter on it in your search route, so a query answers from the version the reader is reading. Read [Search scope](/docs/provider#search-scope) for the setup.
|
|
298
|
+
|
|
295
299
|
## Next steps
|
|
296
300
|
|
|
297
301
|
- Read [Proxy and markdown routes](/docs/proxy) to connect versioned pages to `.md`, `.mdx`, and AI-agent rewrites.
|
package/package.json
CHANGED
|
@@ -45,6 +45,22 @@ const Layout = ({ children }: LayoutProps) => (
|
|
|
45
45
|
|
|
46
46
|
The generated local adapter imports the package provider and passes your site config to it.
|
|
47
47
|
|
|
48
|
+
## Search scope
|
|
49
|
+
|
|
50
|
+
A search index partitioned by version, section, or product usually wants the dialog to answer from the partition the reader is in. Pass that scope as `search.options.tag`:
|
|
51
|
+
|
|
52
|
+
```tsx title="app/layout.tsx"
|
|
53
|
+
<GeistdocsProvider config={config} search={{ options: { tag: "v5" } }}>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The dialog sends it to your search route as `?tag=v5`, alongside the query. Read it from the request URL and filter results with it. Leave the option unset and the parameter is omitted, so the request is unchanged.
|
|
57
|
+
|
|
58
|
+
Pass the scope here rather than reading a header or a cookie in the route. The search client caches results per request URL for the lifetime of the page, so two scopes that produce the same URL share one cache entry, and the second reader is served the first reader's results.
|
|
59
|
+
|
|
60
|
+
<Callout title="Requires a search route of your own">
|
|
61
|
+
`createSearchRoute` indexes pages without a `tag` field, and tagged queries match with `containsAll`, so a tag passed to the built-in route matches nothing.
|
|
62
|
+
</Callout>
|
|
63
|
+
|
|
48
64
|
## AI Sidebar
|
|
49
65
|
|
|
50
66
|
When users open the AI chat on desktop, the provider automatically adds padding to prevent content from being hidden behind the sidebar. On mobile, the chat opens as a drawer instead, so no padding is needed.
|
|
@@ -290,6 +290,10 @@ pages can't be enumerated locally.
|
|
|
290
290
|
|
|
291
291
|
Each public route family needs a matching markdown route in `proxy.ts`. Read [Proxy and markdown routes](/docs/proxy) for the proxy configuration.
|
|
292
292
|
|
|
293
|
+
## Scope search to a version
|
|
294
|
+
|
|
295
|
+
The search dialog does not know which version a reader is on. Pass the current version to the provider as `search.options.tag` and filter on it in your search route, so a query answers from the version the reader is reading. Read [Search scope](/docs/provider#search-scope) for the setup.
|
|
296
|
+
|
|
293
297
|
## Next steps
|
|
294
298
|
|
|
295
299
|
- Read [Proxy and markdown routes](/docs/proxy) to connect versioned pages to `.md`, `.mdx`, and AI-agent rewrites.
|
package/template/package.json
CHANGED