1-
21// /robots.txt: a machine interface around the agent message, served by src/middleware.ts. The
32// rules are plain, and everything else is a "#" comment. The numbers in the comments are computed
43// here, once per process, so edits can't make them wrong: each line's byte offset in the gutter,
54// the file size, the CRC32 and SHA-256 of the rule lines, and the matrix verdicts from the rules.
65
6+ import { LOCALES } from "~/lib/language"
7+
78const rules = [ "User-agent: *" , "Allow: /" , "Disallow: /s/" , "Disallow: /share/" ]
8- const sitemap = "Sitemap: https://opencode.ai/sitemap.xml"
9+ // The Console serves a sitemap per locale; English is already in the site's sitemap index.
10+ const sitemaps = [
11+ "Sitemap: https://opencode.ai/sitemap.xml" ,
12+ ...LOCALES . filter ( ( locale ) => locale !== "en" ) . map (
13+ ( locale ) => `Sitemap: https://opencode.ai/${ locale } /console/sitemap.xml` ,
14+ ) ,
15+ ]
916
1017// The agent message, laid out to fit the payload frame.
1118const message = [
@@ -71,7 +78,7 @@ export function robotsTxt() {
7178}
7279
7380async function build ( ) {
74- const ruleText = [ ...rules , sitemap ] . join ( "\n" )
81+ const ruleText = [ ...rules , ... sitemaps ] . join ( "\n" )
7582 const sha = [ ...new Uint8Array ( await crypto . subtle . digest ( "SHA-256" , encoder . encode ( ruleText ) ) ) ]
7683 . map ( ( byte ) => byte . toString ( 16 ) . padStart ( 2 , "0" ) )
7784 . join ( "" )
@@ -89,15 +96,15 @@ async function build() {
8996 "" ,
9097 justify ( "OPENCODE.AI · ROBOTS.TXT · FOR AGENTS · UTF-8" , `SHA-256(rules) ${ sha . slice ( 0 , 8 ) } ` ) ,
9198 "=" . repeat ( full ) ,
92- justify ( `[BOOT] 0x${ hex ( "OPENCODE" ) } ("OPENCODE") RULES ${ rules . length } SITEMAP 1 ` , "OK" ) ,
99+ justify ( `[BOOT] 0x${ hex ( "OPENCODE" ) } ("OPENCODE") RULES ${ rules . length } SITEMAPS ${ sitemaps . length } ` , "OK" ) ,
93100 justify ( "[LINK]" , "GET /robots.txt -> 200 -> GET /llms.txt -> 200 -> GET *.md -> 200" ) ,
94101 "" ,
95102 justify ( "PARSER COMPLIANCE MATRIX" , "(computed from the rules)" ) ,
96103 ...matrix ( ) ,
97104 "" ,
98105 ...frame ( message , "DECODED PAYLOAD" ) ,
99106 "" ,
100- justify ( `BASE64 ${ btoa ( sitemap . slice ( "Sitemap: " . length ) ) } ` , "(sitemap)" ) ,
107+ justify ( `BASE64 ${ btoa ( sitemaps [ 0 ] . slice ( "Sitemap: " . length ) ) } ` , "(site sitemap)" ) ,
101108 `-- EXECUTE ${ "-" . repeat ( full - 11 ) } ` ,
102109 ...rules . map ( ( rule , i ) => {
103110 const [ label , value ] = notes [ i ]
@@ -106,8 +113,8 @@ async function build() {
106113 } ) ,
107114 "-" . repeat ( full ) ,
108115 justify ( `${ rules . length } RULES LOADED · 0 ERRORS` , `CRC32(rules, comments stripped) ${ crc } ` ) ,
109- justify ( "SITEMAP " , " NEXT LINE, A BARE URL WITH NO COMMENT" ) ,
110- { raw : sitemap } ,
116+ justify ( "SITEMAPS " , ` NEXT ${ sitemaps . length } LINES, ONE BARE URL EACH, NO COMMENT` ) ,
117+ ... sitemaps . map ( ( line ) => ( { raw : line } ) ) ,
111118 leader ( "DESIGN AUTHORITY" , "OBEY DAVID" ) ,
112119 justify ( `EOF · {SIZE} BYTES · CRC32(rules) ${ crc } ` , "END OF TRANSMISSION" ) ,
113120 ]
0 commit comments