shadow-claw 1.41.0 → 1.41.1
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/.well-known/mcp/server-card.json +1 -1
- package/.well-known/mcp.json +1 -1
- package/README.md +2 -2
- package/dist/cli/build/build.js +1 -1
- package/dist/cli/{chunk-bQQkVCw-.js → chunk-63s8NnIS.js} +15 -16
- package/dist/cli/chunk-BATVgkFY.js +17 -0
- package/dist/cli/chunk-Cmdxoq9q.js +13 -0
- package/dist/cli/cli.js +1 -1
- package/dist/cli/prerender/dsd-shell/prerender-dsd-shell.js +1 -1
- package/dist/public/.well-known/mcp/server-card.json +1 -1
- package/dist/public/.well-known/mcp.json +1 -1
- package/dist/public/AGENTS.md +6 -1
- package/dist/public/README.md +2 -2
- package/dist/public/docs/README.md +1 -0
- package/dist/public/docs/example/article/index.html +1 -1
- package/dist/public/docs/guides/publishing-to-github-pages.md +46 -0
- package/dist/public/docs/publishing/index.html +1 -1
- package/dist/public/docs/skill-creator/index.html +1 -1
- package/dist/public/docs/subsystems/theming.md +242 -0
- package/dist/public/e2e/README.md +1 -0
- package/dist/public/index.html +1 -1
- package/dist/public/llms.txt +2 -2
- package/dist/public/main/index.html +1 -1
- package/dist/public/main/memory/index.html +1 -1
- package/dist/public/service-worker.js +1 -1
- package/package.json +1 -1
- package/src/cli/build/build.ts +18 -11
- package/src/cli/prerender/dsd-shell/prerender-dsd-shell.ts +6 -0
- package/src/cli/prerender/pretty-paths/prerender-pretty-paths.ts +22 -0
- package/src/cli/prerender/utils/insert-before-closing-head.test.ts +22 -1
- package/src/cli/prerender/utils/insert-before-closing-head.ts +19 -3
- package/src/cli/site-config/apply.ts +13 -14
- package/dist/cli/chunk-BvVUnHTq.js +0 -14
- package/dist/cli/chunk-DTES-dE6.js +0 -17
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://modelcontextprotocol.io/schemas/server-card/v1.json",
|
|
3
3
|
"name": "shadow-claw",
|
|
4
|
-
"version": "1.41.
|
|
4
|
+
"version": "1.41.1",
|
|
5
5
|
"description": "Multi-runtime AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution.",
|
|
6
6
|
"title": "ShadowClaw MCP Server",
|
|
7
7
|
"websiteUrl": "https://xt-ml.github.io/shadow-claw/",
|
package/.well-known/mcp.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://modelcontextprotocol.io/schemas/server-card/v1.json",
|
|
3
3
|
"name": "shadow-claw",
|
|
4
|
-
"version": "1.41.
|
|
4
|
+
"version": "1.41.1",
|
|
5
5
|
"description": "Multi-runtime AI assistant with local and remote LLM orchestration, Web Workers, OPFS storage, and agentic tool execution.",
|
|
6
6
|
"title": "ShadowClaw MCP Server",
|
|
7
7
|
"websiteUrl": "https://xt-ml.github.io/shadow-claw/",
|
package/README.md
CHANGED
|
@@ -116,7 +116,7 @@ npm install && npm run dev # Dev server → http://localhost:8888
|
|
|
116
116
|
- **Dual-Dispatch Sandboxing & Storage:** Client-side compute via sandboxed JavaScript and `just-bash` (or WebVM Alpine Linux) backed by Origin Private File System (OPFS) and IndexedDB; paired with host-native Node filesystem handles and SQLite database persistence on the server side.
|
|
117
117
|
- **PWA & Electron Desktop Parity:** Deployable as a progressive web app with Service Worker and Web Push, or as a native desktop application with full feature parity.
|
|
118
118
|
- **Modular Package Library Exports & Standardized Utilities:** Exposes modular ESM exports declared in `package.json` under `.`, `./cli`, `./cli/*`, `./components`, `./components/*`, `./utils`, and `./utils/*`, compiled via Rolldown with dynamic entry point discovery for reusable components and standardized cross-cutting utilities (`base64`, `coerce`, `delay`, `filename`, `isBinary`, `mime`, `normalizeStringList`, `normalizeWorkspacePath`, `parseBooleanConfig`, `parseStoredStringList`, `ulid`).
|
|
119
|
-
- **Static Publishing & Slotted Navigation:** Publish documentation portals and knowledge hubs with Declarative Shadow DOM (DSD) SSR, root and sub-route pretty paths, customizable slotted
|
|
119
|
+
- **Static Publishing, Theming & Slotted Navigation:** Publish documentation portals and knowledge hubs with Declarative Shadow DOM (DSD) SSR, root and sub-route pretty paths, custom stylesheets (`theme.stylesheet`), CSS custom property layout/shell tokens, customizable slotted navigation (`sidebar-nav`, `sidebar`, `sidebar-content`, `sidebar-footer`), and declarative sections. See [Theming Subsystem](docs/subsystems/theming.md).
|
|
120
120
|
- **Control Plane, CLI & Native MCP Server:** Backed by a Node.js service layer and CLI (`shadow-claw`) that provides background cron scheduling, remote backups, direct WebRTC DataChannel connectivity, and a Stateless MCP server featuring both native server management tools and dynamic browser tool relaying to external agent hosts (Claude Desktop, Cursor, Goose).
|
|
121
121
|
|
|
122
122
|
---
|
|
@@ -287,7 +287,7 @@ Each channel creates isolated conversations with their own message history and w
|
|
|
287
287
|
Comprehensive architectural specifications, subsystem deep-dives, step-by-step guides, and ADRs live in [`docs/`](docs/README.md):
|
|
288
288
|
|
|
289
289
|
- **[Architecture](docs/README.md#architecture):** [System Overview](docs/architecture/overview.md) · [Orchestrator & State Machine](docs/architecture/orchestrator.md) · [Worker Protocol](docs/architecture/worker-protocol.md) · [Storage System](docs/architecture/storage.md) · [Context Management](docs/architecture/context-management.md) · [Streaming](docs/architecture/streaming.md)
|
|
290
|
-
- **[Subsystems](docs/README.md#subsystems):** [Headless Agent & CLI](docs/subsystems/cli.md) · [Local Models & Hugging Face](docs/subsystems/local-models.md) · [Shell Emulator](docs/subsystems/shell.md) · [WebVM](docs/subsystems/vm.md) · [Git Integration](docs/subsystems/git.md) · [Channels](docs/subsystems/channels.md) · [Tools & Profiles](docs/subsystems/tools.md) · [Providers & Model Registry](docs/subsystems/providers.md) · [Notifications & Scheduling](docs/subsystems/notifications.md) · [Electron Desktop](docs/subsystems/electron.md) · [Reactive UI & Web Components](docs/subsystems/reactive-ui.md) · [Remote MCP](docs/subsystems/remote-mcp.md) · [Stateless MCP Server](docs/subsystems/mcp-server.md) · [WebMCP](docs/subsystems/webmcp.md) · [Crypto & Secrets](docs/subsystems/crypto.md) · [Control Plane](docs/subsystems/control-plane.md) · [Pages System](docs/subsystems/pages.md) · [Agent Skills](docs/subsystems/skills.md) · [Security Hardening](docs/subsystems/custom-element-security.md) · [File Backup](docs/subsystems/backup.md) · [Web Share Target](docs/subsystems/share-target.md) · [OpenAPI](docs/subsystems/openapi.md)
|
|
290
|
+
- **[Subsystems](docs/README.md#subsystems):** [Headless Agent & CLI](docs/subsystems/cli.md) · [Local Models & Hugging Face](docs/subsystems/local-models.md) · [Shell Emulator](docs/subsystems/shell.md) · [WebVM](docs/subsystems/vm.md) · [Git Integration](docs/subsystems/git.md) · [Channels](docs/subsystems/channels.md) · [Tools & Profiles](docs/subsystems/tools.md) · [Providers & Model Registry](docs/subsystems/providers.md) · [Notifications & Scheduling](docs/subsystems/notifications.md) · [Electron Desktop](docs/subsystems/electron.md) · [Reactive UI & Web Components](docs/subsystems/reactive-ui.md) · [Remote MCP](docs/subsystems/remote-mcp.md) · [Stateless MCP Server](docs/subsystems/mcp-server.md) · [WebMCP](docs/subsystems/webmcp.md) · [Crypto & Secrets](docs/subsystems/crypto.md) · [Control Plane](docs/subsystems/control-plane.md) · [Pages System](docs/subsystems/pages.md) · [Theming & Stylesheets](docs/subsystems/theming.md) · [Agent Skills](docs/subsystems/skills.md) · [Security Hardening](docs/subsystems/custom-element-security.md) · [File Backup](docs/subsystems/backup.md) · [Web Share Target](docs/subsystems/share-target.md) · [OpenAPI](docs/subsystems/openapi.md)
|
|
291
291
|
- **[Guides](docs/README.md#guides):** [Adding a Provider](docs/guides/adding-a-provider.md) · [Adding a Tool](docs/guides/adding-a-tool.md) · [Adding a Shell Command](docs/guides/adding-a-shell-command.md) · [Adding a UI Page](docs/guides/adding-a-page.md) · [Adding a Channel](docs/guides/adding-a-channel.md) · [Protocol-Agnostic Integrations](docs/guides/protocol-agnostic-integrations.md) · [Service Accounts & Credentials](docs/guides/adding-service-accounts.md) · [Configuring Messaging Channels](docs/guides/configuring-messaging-channels.md) · [Server Development Configuration](docs/guides/server-development-configuration.md) · [Publishing to GitHub Pages](docs/guides/publishing-to-github-pages.md)
|
|
292
292
|
- **[Decisions](docs/README.md#decisions):** ADRs on [Headless CLI Agent Participant](docs/decisions/headless-cli-agent-participant.md), [Bundled TypeScript Architecture](docs/decisions/bundled-typescript-architecture.md), [Native Web Components and Signals](docs/decisions/native-web-components-and-signals.md), [Worker-Isolated Agent Runtime](docs/decisions/worker-isolated-agent-runtime.md), [IndexedDB and OPFS Storage](docs/decisions/indexeddb-and-opfs-storage.md), and [Peer-to-Peer Protocol (A2A via AGUI)](docs/decisions/peer-protocol-a2a-agui.md)
|
|
293
293
|
- **[Agent Conventions](AGENTS.md):** Architectural guardrails and conventions for AI coding agents
|
package/dist/cli/build/build.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../chunk-
|
|
1
|
+
import{t as e}from"../chunk-63s8NnIS.js";export{e as runBuild};
|
|
@@ -68,27 +68,26 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
68
68
|
${e}</tr>
|
|
69
69
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
70
70
|
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${us(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=ds(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+us(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=ds(e);if(i===null)return us(n);e=i;let a=`<img src="${e}" alt="${us(n)}"`;return t&&(a+=` title="${us(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:us(e.text)}},Ss=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Cs=class e{options;renderer;textRenderer;constructor(e){this.options=e||Za,this.options.renderer=this.options.renderer||new xs,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Ss}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},ws=class{options;block;constructor(e){this.options=e||Za}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?bs.lex:bs.lexInline}provideParser(e=this.block){return e?Cs.parse:Cs.parseInline}},Ts=new class{defaults=Xa();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Cs;Renderer=xs;TextRenderer=Ss;Lexer=bs;Tokenizer=ys;Hooks=ws;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new xs(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new ys(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new ws;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];ws.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&ws.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return bs.lex(e,t??this.defaults)}parser(e,t){return Cs.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?bs.lex:bs.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?Cs.parse:Cs.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?bs.lex:bs.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?Cs.parse:Cs.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
71
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+us(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Z(e,t){return Ts.parse(e,t)}Z.options=Z.setOptions=function(e){return Ts.setOptions(e),Z.defaults=Ts.defaults,Qa(Z.defaults),Z},Z.getDefaults=Xa,Z.defaults=Za,Z.use=function(...e){return Ts.use(...e),Z.defaults=Ts.defaults,Qa(Z.defaults),Z},Z.walkTokens=function(e,t){return Ts.walkTokens(e,t)},Z.parseInline=Ts.parseInline,Z.Parser=Cs,Z.parser=Cs.parse,Z.Renderer=xs,Z.TextRenderer=Ss,Z.Lexer=bs,Z.lexer=bs.lex,Z.Tokenizer=ys,Z.Hooks=ws,Z.parse=Z,Z.options,Z.setOptions,Z.use,Z.walkTokens,Z.parseInline,Cs.parse,bs.lex;function Es(e,t){if(!t||typeof t.createElement!=`function`)throw Error(`A valid documentInstance is required to build frontmatter DOM.`);let n=JSON.stringify(e,null,2)||`{}`,r=t.createElement(`section`);r.setAttribute(`class`,`markdown-frontmatter`),r.setAttribute(`data-markdown-frontmatter`,``),r.setAttribute(`data-frontmatter`,n);let i=t.createElement(`details`);i.setAttribute(`class`,`markdown-frontmatter__details`),i.setAttribute(`hidden`,`hidden`);let a=t.createElement(`summary`);a.setAttribute(`class`,`markdown-frontmatter__summary`),a.appendChild(t.createTextNode(`Frontmatter`));let o=t.createElement(`pre`);o.setAttribute(`class`,`markdown-frontmatter__pre`);let s=t.createElement(`code`);return s.setAttribute(`class`,`language-json`),s.appendChild(t.createTextNode(n)),o.appendChild(s),i.appendChild(a),i.appendChild(o),r.appendChild(i),r}function Ds(e,t){if(typeof t==`function`)return t;let n=e?.defaultView?.XMLSerializer||globalThis.XMLSerializer;return typeof n==`function`?e=>new n().serializeToString(e):null}function Os(e,t,n={}){let r=n.documentInstance||(typeof document<`u`?document:null);if(!r)throw Error(`No document instance available for frontmatter rendering.`);let i=t(e,r);if(typeof i.outerHTML==`string`)return i.outerHTML;let a=Ds(r,n.serializeNode);if(a)return a(i);throw Error(`No serializer available for frontmatter DOM element.`)}function ks(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function As(e){return e.replace(/<script[\s\S]*?>[\s\S]*?<\/script>/giu,``).replace(/\son[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/giu,``)}function js(e){return e.split(s.sep).join(`/`)}function Ms(e){if(e==null||e===``||e===!0)return 1;let t=String(e).trim().toLowerCase();if(t===`all`)return`all`;if(t===`none`||t===`0`||t===`false`)return 0;if(t===`1`||t===`current`||t===`single`)return 1;let n=parseInt(t,10);return!isNaN(n)&&n>=0?n:1}function Ns(e){return e.replace(/</g,`\\u003c`).replace(/>/g,`\\u003e`).replace(/\//g,`\\u002f`).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}function Ps(e
|
|
72
|
-
`+e.slice(
|
|
73
|
-
`)}function
|
|
71
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+us(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function Z(e,t){return Ts.parse(e,t)}Z.options=Z.setOptions=function(e){return Ts.setOptions(e),Z.defaults=Ts.defaults,Qa(Z.defaults),Z},Z.getDefaults=Xa,Z.defaults=Za,Z.use=function(...e){return Ts.use(...e),Z.defaults=Ts.defaults,Qa(Z.defaults),Z},Z.walkTokens=function(e,t){return Ts.walkTokens(e,t)},Z.parseInline=Ts.parseInline,Z.Parser=Cs,Z.parser=Cs.parse,Z.Renderer=xs,Z.TextRenderer=Ss,Z.Lexer=bs,Z.lexer=bs.lex,Z.Tokenizer=ys,Z.Hooks=ws,Z.parse=Z,Z.options,Z.setOptions,Z.use,Z.walkTokens,Z.parseInline,Cs.parse,bs.lex;function Es(e,t){if(!t||typeof t.createElement!=`function`)throw Error(`A valid documentInstance is required to build frontmatter DOM.`);let n=JSON.stringify(e,null,2)||`{}`,r=t.createElement(`section`);r.setAttribute(`class`,`markdown-frontmatter`),r.setAttribute(`data-markdown-frontmatter`,``),r.setAttribute(`data-frontmatter`,n);let i=t.createElement(`details`);i.setAttribute(`class`,`markdown-frontmatter__details`),i.setAttribute(`hidden`,`hidden`);let a=t.createElement(`summary`);a.setAttribute(`class`,`markdown-frontmatter__summary`),a.appendChild(t.createTextNode(`Frontmatter`));let o=t.createElement(`pre`);o.setAttribute(`class`,`markdown-frontmatter__pre`);let s=t.createElement(`code`);return s.setAttribute(`class`,`language-json`),s.appendChild(t.createTextNode(n)),o.appendChild(s),i.appendChild(a),i.appendChild(o),r.appendChild(i),r}function Ds(e,t){if(typeof t==`function`)return t;let n=e?.defaultView?.XMLSerializer||globalThis.XMLSerializer;return typeof n==`function`?e=>new n().serializeToString(e):null}function Os(e,t,n={}){let r=n.documentInstance||(typeof document<`u`?document:null);if(!r)throw Error(`No document instance available for frontmatter rendering.`);let i=t(e,r);if(typeof i.outerHTML==`string`)return i.outerHTML;let a=Ds(r,n.serializeNode);if(a)return a(i);throw Error(`No serializer available for frontmatter DOM element.`)}function ks(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function As(e){return e.replace(/<script[\s\S]*?>[\s\S]*?<\/script>/giu,``).replace(/\son[a-z]+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/giu,``)}function js(e){return e.split(s.sep).join(`/`)}function Ms(e){if(e==null||e===``||e===!0)return 1;let t=String(e).trim().toLowerCase();if(t===`all`)return`all`;if(t===`none`||t===`0`||t===`false`)return 0;if(t===`1`||t===`current`||t===`single`)return 1;let n=parseInt(t,10);return!isNaN(n)&&n>=0?n:1}function Ns(e){return e.replace(/</g,`\\u003c`).replace(/>/g,`\\u003e`).replace(/\//g,`\\u002f`).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}function Ps(e){let t=/<!--[\s\S]*?-->|<script\b[\s\S]*?<\/script>|<style\b[\s\S]*?<\/style>|<template\b[\s\S]*?<\/template>|<\/head>/gi,n;for(;(n=t.exec(e))!==null;)if(n[0].toLowerCase().startsWith(`</head`))return n.index;return-1}function Fs(e,t){let n=Ps(e);return n===-1?`${t}\n${e}`:e.slice(0,n)+t+`
|
|
72
|
+
`+e.slice(n)}function Is(e,t){let n=`<script id="shadow-claw-static-manifest" type="application/json">${Ns(t)}<\/script>`,r=e;return r=/id="shadow-claw-static-manifest"/iu.test(r)?r.replace(/<script\s+id="shadow-claw-static-manifest"[\s\S]*?<\/script>/iu,()=>n):Fs(r,` ${n}`),/id="shadow-claw-static-routing"/iu.test(r)||(r=Fs(r,` <script id="shadow-claw-static-routing" type="application/json">{"routes":{}}<\/script>`)),r}const Ls=new Set([`.md`,`.markdown`,`.html`,`.htm`,`.xhtml`]),Rs=new Ja.DOMImplementation().createDocument(null,`html`,null),zs=new Ja.XMLSerializer;function Bs(){return[{absolutePath:null,displayPath:`index.html`,inlineContent:i},{absolutePath:null,displayPath:`MEMORY.md`,inlineContent:a}]}function Vs(e){let t=(0,Ya.default)(e);return{data:t.data&&typeof t.data==`object`?t.data:{},content:t.content||``}}function Hs(e){let t=e.match(/<template[^>]*>([\s\S]*?)<\/template>/iu);if(!t)throw Error(`Template wrapper not found while generating DSD.`);return t[1].trim()}function Us(e,t,n){let r=`br-${s.basename(t)}`;e[r]||(e[r]={});let i=n.split(`/`),a=e[r];for(let e=0;e<i.length-1;e++){let t=i[e];a[t]||(a[t]={}),a=a[t]}a.purgePreRenderedStaticPages=!0}function Ws(e){let t=s.extname(e).toLowerCase();return Ls.has(t)}function Gs(e,t=`desc`){return[...e].sort((e,n)=>{let r=s.basename(e),i=s.basename(n),a=/^index\.(html?|xhtml)$/iu.test(r),o=/^index\.(html?|xhtml)$/iu.test(i);if(a&&!o)return-1;if(!a&&o)return 1;let c=/^memory\.(md|markdown)$/iu.test(r),l=/^memory\.(md|markdown)$/iu.test(i);return c&&!l?1:!c&&l?-1:t===`desc`?n.localeCompare(e,void 0,{numeric:!0,sensitivity:`base`}):e.localeCompare(n,void 0,{numeric:!0,sensitivity:`base`})})}async function Ks(e,t=`desc`){let n;try{n=await D(e)}catch(e){if(e?.code===`ENOENT`)return Bs();throw e}if(n.isFile())return[{absolutePath:e,displayPath:js(s.basename(e))}];let r=[];async function i(t){let n=await C(t,{withFileTypes:!0});for(let a of n){let n=s.join(t,a.name);if(a.isDirectory()){await i(n);continue}if(!a.isFile()||!Ws(a.name))continue;let o=js(s.relative(e,n));r.push({absolutePath:n,displayPath:o})}}if(await i(e),r.length===0)return Bs();let a=new Map(r.map(e=>[e.displayPath,e]));return Gs(r.map(e=>e.displayPath),t).map(e=>a.get(e))}async function qs(e){try{if(!(await D(e)).isDirectory())return[]}catch(e){if(e?.code===`ENOENT`)return[];throw e}let t=[];async function n(r){let i=await C(r,{withFileTypes:!0});for(let a of i){let i=s.join(r,a.name);if(a.isDirectory())await n(i);else if(a.isFile()){let n={absolutePath:i,displayPath:js(s.relative(e,i))};if(s.extname(a.name).toLowerCase()===`.md`)try{let e=Vs(await S(i,`utf8`));e.data.slug===`shadow-claw--purge-skills`&&(n.isPurgeMarker=!0,e.data[`purge-id`]!==void 0&&(n.purgeId=String(e.data[`purge-id`])))}catch{}t.push(n)}}}return await n(e),t.sort((e,t)=>e.displayPath.localeCompare(t.displayPath))}async function Js(e){try{if(!(await D(e)).isDirectory())return[]}catch(e){if(e?.code===`ENOENT`)return[];throw e}let t=[];async function n(r){let i=await C(r,{withFileTypes:!0});for(let a of i){let i=s.join(r,a.name);a.isDirectory()?await n(i):a.isFile()&&a.name.endsWith(`.json`)&&t.push({absolutePath:i,displayPath:js(s.relative(e,i))})}}return await n(e),t.sort((e,t)=>e.displayPath.localeCompare(t.displayPath))}async function Ys(e,t){let n=s.extname(t).toLowerCase(),r=n===`.html`||n===`.htm`||n===`.xhtml`,i,a;if(r)i=Vs(e),a=As(i.content);else try{i=Vs(e),a=As(await Z.parse(i.content))}catch{i={data:{},content:e},a=`<p>${ks(e)}</p>`}if(t){let e=s.posix.dirname(js(t)),n=`/files/main/${e===`.`?``:e+`/`}`;a=a.replace(/<img\s+([^>]*?)src="([^"]+)"([^>]*)>/giu,(e,t,r,i)=>/^(?:[a-z]+:|#|\/)/iu.test(r)?e:`<img ${t}src="${n}${r}"${i}>`)}return i.data&&Object.keys(i.data).length>0&&(a=`${Os(i.data,Es,{documentInstance:Rs,serializeNode:e=>zs.serializeToString(e)})}\n${a}`),a}function Xs(e,t){let n=/<\/?template\b[^>]*>/giu;n.lastIndex=t;let r=0,i=!1,a=n.exec(e);for(;a;){if(a[0].toLowerCase().startsWith(`</template`)?--r:(r+=1,i=!0),i&&r===0)return n.lastIndex;a=n.exec(e)}return-1}function Zs(e){let t=e.indexOf(`<template shadowrootmode="open" data-shadow-claw-dsd="true">`);if(t===-1)return e;let n=Xs(e,t);return n===-1?e:`${e.slice(0,t)}${e.slice(n)}`}function Qs(e){return e.replace(/\s*<div\s+aria-hidden="true"\s+class="boot-shell">[\s\S]*?<\/div>\s*/iu,`
|
|
73
|
+
`)}function $s(e){return[`<details class="pages__group-details" open>`,` <summary class="pages__group-label">`,` <span>Main</span><span class="pages__group-icon">▼</span>`,` </summary>`,` <div class="pages__group-pages">`,e.map((e,t)=>{let n=t===0,r=n?` active`:``,i=n?` is-default`:``,a=ks(e.displayPath);return[` <div class="pages__list-item${r}">`,` <span class="pages__drag-handle" draggable="true" title="Drag to reorder">⠿</span>`,` <span class="pages__default-btn${i}" title="Default page">⭐</span>`,` <button type="button" class="pages__select" title="Open ${a}">`,` <span class="pages__list-path">${a}</span>`,` </button>`,` <button class="pages__edit" type="button" title="Edit in file editor" aria-label="Edit ${a} in file editor">✏️</button>`,` <button class="pages__remove" type="button" title="Remove from Pages" aria-label="Remove ${a} from Pages in Main">✕</button>`,` </div>`].join(`
|
|
74
74
|
`)}).join(`
|
|
75
75
|
`),` </div>`,`</details>`].join(`
|
|
76
|
-
`)}function
|
|
77
|
-
`)})}function
|
|
78
|
-
`)}function
|
|
79
|
-
`)}function
|
|
80
|
-
`):`${t}<template></template>${r}`})}function
|
|
81
|
-
`)}function
|
|
82
|
-
`)}function cc(e,t){let n=e.match(/<shadow-claw\b[^>]*>/iu),r=n?n[0]:null,i=n?.index??-1;if(i===-1||!r)throw Error(`Unable to find <shadow-claw> host in index.html.`);let a=e.indexOf(`</shadow-claw>`,i);if(a===-1)throw Error(`Unable to find </shadow-claw> host in index.html.`);let o=i+r.length,s=Zs(Xs(e.slice(o,a))).trim(),c=s?`\n ${t}\n${s}\n `:`\n ${t}\n `;return`${e.slice(0,o)}${c}${e.slice(a)}`}function lc(e){return e.replace(/<shadow-claw(\s[^>]*)?>/iu,(e,t=``)=>/\sdata-prerender-no-seed\s*=\s*/iu.test(t)?`<shadow-claw${t}>`:`<shadow-claw${t} data-prerender-no-seed="true">`)}async function uc(e,t){if(p.env.NODE_ENV!==`production`)return e;let n=e;try{let e=await S(s.join(t,`index.css`),`utf8`);n=n.replace(/<link\b[^>]*?href="(?:\/)?index\.css"[^>]*?>/iu,()=>`<style>${e}</style>`)}catch(e){console.warn(`Failed to inline index.css`,e.message)}try{let e=await S(s.join(t,`theme-init.js`),`utf8`);n=n.replace(/<script\b[^>]*?src="(?:\/)?theme-init\.js"[^>]*?><\/script>/iu,()=>`<script>${e}<\/script>`)}catch(e){console.warn(`Failed to inline theme-init.js`,e.message)}try{let e=await S(s.join(t,`service-worker/init.js`),`utf8`);n=n.replace(/<script\b[^>]*?src="(?:\/)?service-worker\/init\.js"[^>]*?><\/script>/iu,()=>`<script type="module">${e}<\/script>`)}catch(e){console.warn(`Failed to inline service-worker/init.js`,e.message)}return n}function dc(e){if(!e||typeof e!=`string`)return e;let t=[],n=e.replace(/<pre\b[^>]*>[\s\S]*?<\/pre>|<textarea\b[^>]*>[\s\S]*?<\/textarea>/gi,e=>{let n=t.length;return t.push(e),`___PRESERVED_BLOCK_${n}___`}),r=e=>e.replace(/\s+/g,` `).replace(/>\s+</g,`><`).trim();function i(e){let t=/<template\b[^>]*>/gi,n,a=0,o=``;for(;(n=t.exec(e))!==null;){let s=n[0],c=n.index,l=/<\/?template\b[^>]*>/gi;l.lastIndex=c;let u=0,d=!1,f=l.exec(e),p=-1,m=0;for(;f;){if(f[0].toLowerCase().startsWith(`</template`)?--u:(u+=1,d=!0),d&&u===0){p=f.index,m=f[0].length;break}f=l.exec(e)}if(p!==-1){o+=e.slice(a,c);let n=e.slice(c+s.length,p),l=r(i(n));o+=`${s}${l}</template>`,a=p+m,t.lastIndex=a}}return o+=e.slice(a),o}let a=i(n);a=a.replace(/(<template\s+shadowrootmode="?[a-z]+"?[^>]*>)([\s\S]*?)(<\/template>)/gi,(e,t,n,i)=>`${t}${r(n)}${i}`);for(let e=0;e<t.length;e++)a=a.replace(`___PRESERVED_BLOCK_${e}___`,()=>t[e]);return a}async function fc(e={}){let t=s.resolve(e.indexPath||`dist/public/index.html`),n=s.resolve(e.sourcePath||`pages/main`),r=s.resolve(e.skillsSourcePath||s.join(s.dirname(n),`..`,`.agents`,`skills`,`main`)),i=s.resolve(e.toolsSourcePath||s.join(s.dirname(n),`..`,`.agents`,`tools`,`main`)),a=s.resolve(e.publicDir||s.dirname(t)),o=Ms(e.prerenderPages===void 0?e.noSeed?0:p.env.PRERENDER_PAGES??1:e.prerenderPages),c={},l=[e.siteConfigPath,s.resolve(`site-config.json`)].filter(Boolean);for(let e of l)try{let t=await S(s.resolve(e),`utf8`);c=JSON.parse(t);break}catch{}let u=e.sortOrder||c?.pages?.sortOrder||`desc`,d=s.join(a,`components/shadow-claw/shadow-claw.html`),f=s.join(a,`components/shadow-claw-pages/shadow-claw-pages.html`),m=s.join(a,`components/shadow-claw-page-header/shadow-claw-page-header.html`),h=s.join(a,`components/shadow-claw/shadow-claw.css`),g=s.join(a,`components/shadow-claw-pages/shadow-claw-pages.css`),_=s.join(a,`components/shadow-claw-page-header/shadow-claw-page-header.css`),[v,b,C,w,T,E,k,A,ee,te]=await Promise.all([S(t,`utf8`),S(d,`utf8`),S(f,`utf8`).catch(()=>``),S(m,`utf8`).catch(()=>``),Gs(n,u),Ks(r),qs(i),S(h,`utf8`).catch(()=>``),S(g,`utf8`).catch(()=>``),S(_,`utf8`).catch(()=>``)]),ne=await Promise.all(T.map(async e=>{let t=typeof e.inlineContent==`string`?e.inlineContent:await S(e.absolutePath,`utf8`);return{...e,content:t}})),j,M={},N=ne.filter(e=>{if(e.displayPath.endsWith(`.md`)&&/^---\r?\n[\s\S]*?slug:\s*"shadow-claw--purge-pages"[\s\S]*?---/mu.test(e.content)){if(Hs(M,n,e.displayPath),!j){let t=Bs(e.content).data[`purge-id`];t!=null&&(j=String(t))}return!1}return!0}),re=N.map(e=>({displayPath:e.displayPath,content:e.content})),P={pages:re},F=await Promise.all(E.filter(e=>!e.isPurgeMarker).map(async e=>({displayPath:e.displayPath,content:await S(e.absolutePath,`utf8`)})));F.length>0&&(P.skills=F);let I=await Promise.all(k.map(async e=>({displayPath:e.displayPath,content:await S(e.absolutePath,`utf8`)})));I.length>0&&(P.tools=I);let L=E.find(e=>e.isPurgeMarker);L?.purgeId&&(P.skillsPurgeId=L.purgeId),Object.keys(M).length>0&&(P.preRenderedStaticPages=M),j&&(P.purgeId=j);let R=s.join(a,`static-main-manifest.json`);await x(a,{recursive:!0}),await O(R,JSON.stringify(P,null,2),`utf8`);try{if((await D(n)).isDirectory()){let e=s.join(a,`static-main`);await x(e,{recursive:!0}),await y(n,e,{recursive:!0});let t=s.join(a,`files/main`);await x(t,{recursive:!0}),await y(n,t,{recursive:!0})}}catch{}try{(await D(i)).isDirectory()&&(await x(s.join(a,`tools/main`),{recursive:!0}),await y(i,s.join(a,`tools/main`),{recursive:!0}))}catch{}try{(await D(r)).isDirectory()&&(await x(s.join(a,`skills/main`),{recursive:!0}),await y(r,s.join(a,`skills/main`),{recursive:!0}))}catch{}let z=Vs(b);if(o===0){let n=sc(z,A,c.sidebar);await O(t,await uc(dc(Fs(cc(lc(v),n),JSON.stringify({pages:[],skills:[]}))),a),`utf8`),(e.silent??p.env.NODE_ENV===`test`)||console.log(`Injected DSD shell into ${t} (pages DSD disabled).`);return}let ie=[],B=[];o===`all`?(ie=N,B=re):typeof o==`number`&&(ie=N.slice(0,o),B=re.slice(0,o));let ae=Vs(C),V=Vs(w),oe;if(N.length===0)oe=oc(z,rc(ae,ee),A,c.sidebar);else{let e=N[0],t=Bs(e.content),n=t.data&&t.data.title?t.data.title:``,r=await Js(e.content,e.absolutePath||e.displayPath);oe=oc(z,tc(ae,ie,r,V,n,ee,te),A,c.sidebar)}let se=lc(cc(v,oe)),H={pages:B};F.length>0&&(H.skills=F),I.length>0&&(H.tools=I),L?.purgeId&&(H.skillsPurgeId=L.purgeId),Object.keys(M).length>0&&(H.preRenderedStaticPages=M),j&&(H.purgeId=j),await O(t,await uc(dc(Fs(se,JSON.stringify(H))),a),`utf8`),(e.silent??p.env.NODE_ENV===`test`)||console.log(`Injected DSD shell into ${t} from ${n} (${ie.length} of ${T.length} page${T.length===1?``:`s`} prerendered).`)}async function pc(){let e=p.argv.slice(2).filter(e=>!e.startsWith(`--`)),t=p.argv.slice(2).filter(e=>e.startsWith(`--`)),n=t.includes(`--no-seed`),r;for(let e of t)e.startsWith(`--prerender-pages=`)?r=e.slice(18):e.startsWith(`--pages=`)&&(r=e.slice(8));let[i=`dist/public/index.html`,a=`pages/main`]=e;await fc({indexPath:i,sourcePath:a,noSeed:n,prerenderPages:r})}p.argv[1]&&s.resolve(p.argv[1])===s.resolve(f(import.meta.url))&&pc().catch(e=>{console.error(e),p.exit(1)});function mc(e){return e.replace(/^\/+|\/+$/g,``)}function hc(e){let t=mc(e);if(t.startsWith(`pages/main/`))return t.slice(11);if(t.startsWith(`pages/br:main/`)||t.startsWith(`pages/br-main/`))return t.slice(14);if(t.startsWith(`main/`))return t.slice(5);if(t.startsWith(`pages/`)){let e=t.split(`/`);if(e.length>=3)return e.slice(2).join(`/`)}return t}function gc(e,t){let n=`<script id="shadow-claw-static-routing" type="application/json">${Ns(t)}<\/script>`;return/id="shadow-claw-static-routing"/iu.test(e)?e.replace(/<script\s+id="shadow-claw-static-routing"[\s\S]*?<\/script>/iu,()=>n):Ps(e,` ${n}`)}async function _c(e={}){let t=s.resolve(e.publicDir||`dist/public`),n=s.resolve(e.routesPath||`pages/routes.json`),r=s.resolve(e.sourcePath||`pages/main`),i=s.resolve(e.indexPath||s.join(t,`index.html`)),a=Ms(e.prerenderPages===void 0?p.env.PRERENDER_PAGES??1:e.prerenderPages),o;try{o=await S(n,`utf8`)}catch(e){if(e?.code===`ENOENT`)return{count:0,skipped:!0,reason:`No routes.json found`};throw e}let c;try{c=JSON.parse(o)}catch(e){return console.warn(`Failed to parse ${n}:`,e),{count:0,skipped:!0,reason:`Invalid JSON in routes.json`}}if(!c||typeof c!=`object`)return{count:0,skipped:!0,reason:`Invalid routes.json`};c.routes||={};let l={...c.routes||{}},u=new Set;async function d(e,t){if(!e.subRoutes)return;let n=Array.isArray(e.subRoutes)?e.subRoutes:Object.values(e.subRoutes);for(let e of n){let n=s.resolve(s.dirname(t),e);if(typeof e==`string`&&e.startsWith(`pages/`)&&(n=s.resolve(e)),!u.has(n)){u.add(n);try{let e=await S(n,`utf8`),t=JSON.parse(e);t.routes&&Object.assign(l,t.routes),await d(t,n)}catch(e){console.warn(`Failed to read subRoute: ${n}`,e?.message)}}}}await d(c,n),Object.assign(c.routes,l),Array.isArray(c.subRoutes)&&delete c.subRoutes;let f=Object.entries(l);if(f.length===0)return{count:0,skipped:!0,reason:`Empty routes table`};let m=JSON.stringify(c,null,2),h=s.join(t,`static-routing.json`);await x(t,{recursive:!0}),await O(h,m,`utf8`);let g=JSON.stringify(c),_=s.join(t,`components/shadow-claw/shadow-claw.html`),v=s.join(t,`components/shadow-claw-pages/shadow-claw-pages.html`),b=s.join(t,`components/shadow-claw-page-header/shadow-claw-page-header.html`),w=s.join(t,`components/shadow-claw/shadow-claw.css`),T=s.join(t,`components/shadow-claw-pages/shadow-claw-pages.css`),E=s.join(t,`components/shadow-claw-page-header/shadow-claw-page-header.css`),[k,A,ee,te,ne,j,M,N]=await Promise.all([S(i,`utf8`),S(_,`utf8`),S(v,`utf8`).catch(()=>``),S(b,`utf8`).catch(()=>``),Gs(r),S(w,`utf8`).catch(()=>``),S(T,`utf8`).catch(()=>``),S(E,`utf8`).catch(()=>``)]),re=(await Promise.all(ne.map(async e=>{let t=typeof e.inlineContent==`string`?e.inlineContent:await S(e.absolutePath,`utf8`);return{...e,content:t}}))).filter(e=>!(e.displayPath.endsWith(`.md`)&&/^---\r?\n[\s\S]*?slug:\s*"shadow-claw--purge-pages"[\s\S]*?---/mu.test(e.content||``)));await O(i,await uc(dc(gc(k,g)),t),`utf8`);let P=Vs(A),F=Vs(ee),I=Vs(te),L=re.map(e=>({displayPath:e.displayPath,content:e.content})),R=s.join(t,`static-main-manifest.json`),z={};try{z=JSON.parse(await S(R,`utf8`))}catch{}let ie={pages:L,...Array.isArray(z.skills)?{skills:z.skills}:{},...Array.isArray(z.tools)?{tools:z.tools}:{},...z.skillsPurgeId?{skillsPurgeId:z.skillsPurgeId}:{},...z.preRenderedStaticPages?{preRenderedStaticPages:z.preRenderedStaticPages}:{},...z.purgeId?{purgeId:z.purgeId}:{}};await O(R,JSON.stringify(ie,null,2),`utf8`);try{if((await D(r)).isDirectory()){let e=s.join(t,`static-main`);await x(e,{recursive:!0}),await y(r,e,{recursive:!0});let n=s.join(t,`files/main`);await x(n,{recursive:!0}),await y(r,n,{recursive:!0})}}catch{}let B=[];for(let[e,n]of f){if(!n||!n.prettyPath)continue;let i=hc(e),o=re.find(e=>e.displayPath===i);if(!o)try{let e=s.join(r,i);o={absolutePath:e,displayPath:i,content:await S(e,`utf8`)}}catch{console.warn(`Could not find page file for route: ${e} (${i})`);continue}let c=re.filter(e=>e.displayPath!==o.displayPath),l=[],u=[];a===`all`?(l=[o,...c],u=l.map(e=>({displayPath:e.displayPath,content:e.content}))):typeof a==`number`&&(a===0?(l=[],u=[]):(l=[o,...c.slice(0,a-1)],u=l.map(e=>({displayPath:e.displayPath,content:e.content}))));let d=Bs(o.content||``),f=d.data&&d.data.title?d.data.title:``,p=await Js(o.content||``,o.displayPath),m;m=a===0?sc(P,j):oc(P,tc(F,l,p,I,f,M,N),j);let h=await uc(dc(gc(Fs(lc(cc(k,m)),JSON.stringify({pages:u,...Array.isArray(z.skills)?{skills:z.skills}:{},...Array.isArray(z.tools)?{tools:z.tools}:{},...z.skillsPurgeId?{skillsPurgeId:z.skillsPurgeId}:{},...z.preRenderedStaticPages?{preRenderedStaticPages:z.preRenderedStaticPages}:{},...z.purgeId?{purgeId:z.purgeId}:{}})),g)),t),_=mc(n.prettyPath),v;v=_.endsWith(`.html`)?_:s.join(_,`index.html`);let b=s.join(t,v),w=s.dirname(b);if(await x(w,{recursive:!0}),await O(b,h,`utf8`),o&&o.absolutePath)try{let e=s.dirname(o.absolutePath),t=await C(e,{withFileTypes:!0});for(let n of t)n.isFile()&&!Us(n.name)&&n.name!==`routes.json`&&await y(s.join(e,n.name),s.join(w,n.name))}catch(t){console.warn(`Failed to copy co-located assets for ${e}:`,t)}B.push(v.replace(/\\/g,`/`))}return(e.silent??p.env.NODE_ENV===`test`)||console.log(`Prerendered ${B.length} pretty path page${B.length===1?``:`s`} from ${n} (prerender-pages: ${a}).`),{count:B.length,generatedPaths:B,skipped:!1}}async function vc(){let e=p.argv.slice(2).filter(e=>!e.startsWith(`--`)),t=p.argv.slice(2).filter(e=>e.startsWith(`--`)),n;for(let e of t)e.startsWith(`--prerender-pages=`)?n=e.slice(18):e.startsWith(`--pages=`)&&(n=e.slice(8));let r=e[0]||`dist/public`;await _c({publicDir:r,routesPath:e[1]||`pages/routes.json`,sourcePath:e[2]||`pages/main`,indexPath:e[3]||s.join(r,`index.html`),prerenderPages:n})}p.argv[1]&&s.resolve(p.argv[1])===s.resolve(f(import.meta.url))&&vc().catch(e=>{console.error(e),p.exit(1)});function yc(e={},t={}){let n=e.customElements;return{rawScripts:(typeof n==`object`&&!Array.isArray(n)?n.scripts:n)||e.scripts||t.scripts||[],allowedDomains:(typeof n==`object`&&!Array.isArray(n)?n.allowedDomains:void 0)||e.allowedCustomElementDomains||[]}}function bc(e,t){if(!e.startsWith(`http://`)&&!e.startsWith(`https://`)&&!e.startsWith(`//`)||!t||Array.isArray(t)&&t.length===0)return!0;try{let n=new URL(e,`https://localhost`).hostname.toLowerCase();return(Array.isArray(t)?t:String(t).split(/[\n,]+/)).some(e=>{let t=e.trim().toLowerCase();return n===t||n.endsWith(`.`+t)||t===`*`})}catch{return!1}}function xc(e,t){let n=JSON.parse(JSON.stringify(e));return n.customElements&&typeof n.customElements==`object`&&Array.isArray(n.customElements.scripts)&&(n.customElements.scripts=n.customElements.scripts.filter(e=>{let n=typeof e==`string`?e:e?.src;return n?bc(n,t):!1})),n}function Q(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function Sc(e,t){let n=/<\/head>/i.exec(e);if(n){let r=n.index;return e.slice(0,r)+t+`
|
|
83
|
-
`+e.slice(r)}return`${t}\n${e}`}const Cc=[`pages/resources/`,`pages/deps/`,`resources/`,`deps/`,`pages/assets/`,`pages/main/assets/`];function wc(e){for(let t of Cc)if(e.startsWith(t))return e.slice(t.length);return e}async function Tc(e){try{return JSON.parse(await S(e,`utf8`))}catch{return null}}async function Ec(e){try{return await S(e,`utf8`)}catch{return null}}async function Dc(e,t){await O(e,t,`utf8`)}function Oc(e){return!Array.isArray(e)||e.length===0?``:`<nav slot="sidebar" class="sidebar-custom-sections" aria-label="Site Navigation">\n${e.map((e,t)=>{if(e.html)return e.html;let n=e.title?`sidebar-${e.title.toLowerCase().replace(/[^a-z0-9]+/g,`-`)}`:`sidebar-section-${t+1}`,r=e.headerHref?`<a href="${Q(e.headerHref)}" class="sidebar-link">${Q(e.title||``)}</a>`:`<span>${Q(e.title||``)}</span>`,i=e.title?` <div class="sidebar-section-header">${r}</div>`:``,a=(e.items||[]).map(e=>{let t=e.title||e.label||``,n=e.href||`#`,r=e.target?` target="${Q(e.target)}"`:``,i=e.rel?` rel="${Q(e.rel)}"`:e.target===`_blank`?` rel="noopener noreferrer"`:``,a=e.active?` active`:``,o=e.active?` aria-current="page"`:``;return` <div class="sidebar-item"><a href="${Q(n)}"${r}${i} class="sidebar-link${a}"${o}>${Q(t)}</a></div>`}).join(`
|
|
76
|
+
`)}function ec(e,t,n=``,r=``){return e.replace(/(<shadow-claw-page-header\b[^>]*>)([\s\S]*?)(<\/shadow-claw-page-header>)/iu,(e,i,a,o)=>{if(/^\s*<template\s+shadowrootmode=/iu.test(a))return e;let s=i.match(/\sicon="([^"]*)"/iu),c=i.match(/\stitle="([^"]*)"/iu),l=s?s[1]:``,u=c?c[1]:``;n&&(u=`${u} — ${n}`);let d=[l,u].filter(Boolean).join(` `),f=t;return f=f.replace(/<h2\s+class="header__title"><\/h2>/iu,()=>`<h2 class="header__title">${ks(d)}</h2>`),f=f.replace(/<details\s+class="header__actions-disclosure">/iu,`<details class="header__actions-disclosure" hidden>`),f=f.replace(/<div\s+class="header__actions"\s+id="header-actions-panel">/iu,`<div class="header__actions" id="header-actions-panel" hidden>`),[i,`<template shadowrootmode="open" data-shadow-claw-page-header-dsd="true">`,`<style data-dsd-style>${r}</style>`,f,`</template>`,a.trim(),o].join(`
|
|
77
|
+
`)})}function tc(e,t,n,r,i=``,a=``){let o=t.length===1?`1 saved page`:`${t.length} saved pages`,s=$s(t),c=t[0]?.displayPath||`Select a page...`,l=e;return l=l.replace(/<div\b[^>]*\bdata-pages-status\b[^>]*><\/div>/iu,()=>`<div class="pages__status" data-pages-status>${ks(o)}</div>`),l=l.replace(/<span\s+class="pages__dropdown-selected"\s+data-pages-dropdown-selected>[\s\S]*?<\/span>/iu,()=>`<span class="pages__dropdown-selected" data-pages-dropdown-selected>${ks(c)}</span>`),l=l.replace(/<div\s+class="pages__list"\s+data-pages-list\s+role="list"><\/div>/giu,()=>`<div class="pages__list" data-pages-list role="list">\n${s}\n</div>`),l=l.replace(/<div\s+class="pages__empty"\s+data-pages-empty>/iu,()=>`<div class="pages__empty" data-pages-empty hidden>`),l=l.replace(/<div\s+class="pages__rendered"\s+data-pages-rendered\s+hidden><\/div>/iu,()=>`<div class="pages__rendered" data-pages-rendered>${n}</div>`),ec(l,r,i,a)}function nc(e,t,n,r,i=``,a=``,o=``){let s=tc(e,t,n,r,i,o);return[`<shadow-claw-pages>`,`<template shadowrootmode="open" data-shadow-claw-pages-dsd="true">`,`<style data-dsd-style>${a}</style>`,s,`</template>`,`</shadow-claw-pages>`].join(`
|
|
78
|
+
`)}function rc(e){let t=e;return t=t.replace(/<div\s+class="pages__empty"\s+data-pages-empty>[\s\S]*?<\/div>/iu,`<div class="pages__empty" data-pages-empty hidden></div>`),t}function ic(e,t=``){let n=rc(e);return[`<shadow-claw-pages>`,`<template shadowrootmode="open" data-shadow-claw-pages-dsd="true">`,`<style data-dsd-style>${t}</style>`,n,`</template>`,`</shadow-claw-pages>`].join(`
|
|
79
|
+
`)}function ac(e){return e.replace(/(<shadow-claw-dialog\b[^>]*>)([\s\S]*?)(<\/shadow-claw-dialog>)/giu,(e,t,n,r)=>{if(/^\s*<template\b/iu.test(n))return e;let i=n.trim();return i?[t,`<template>`,i,`</template>`,r].join(`
|
|
80
|
+
`):`${t}<template></template>${r}`})}function oc(e,t={}){let n=e;if(!t||typeof t!=`object`)return n;let r=e=>{let t=RegExp(`(<li\\s+class="[^"]*nav-item[^"]*"\\s+data-page="${e}")(?![^>]*\\bhidden\\b)([^>]*>)`,`iu`);n=n.replace(t,`$1 hidden aria-hidden="true"$2`)};return t.pagesHidden&&r(`pages`),t.chatHidden&&(r(`chat`),n=n.replace(/(<shadow-claw-conversations)(?![^>]*\bhidden\b)([^>]*>)/iu,`$1 hidden aria-hidden="true"$2`)),t.tasksHidden&&r(`tasks`),t.filesHidden&&r(`files`),n}function sc(e,t,n=``,r={}){let i=e.replace(/<shadow-claw-pages><\/shadow-claw-pages>/iu,()=>t);i=oc(i,r);let a=ac(i);return[`<template shadowrootmode="open" data-shadow-claw-dsd="true">`,`<style data-dsd-style>${n}</style>`,a,`</template>`].join(`
|
|
81
|
+
`)}function cc(e,t=``,n={}){let r=e;r=r.replace(/(<li\s+class="nav-item)\s+active(\s*"\s+data-page="pages">)/iu,`$1$2`),r=r.replace(/(<div\s+class="page)\s+active("\s+data-page-id="pages">)/iu,`$1$2`),r=r.replace(/(<li\s+class="nav-item[^"]*"\s+data-page="pages")>/iu,`$1 hidden aria-hidden="true">`);let i=n?.chatHidden?n?.tasksHidden?n?.filesHidden?`chat`:`files`:`tasks`:`chat`;r=r.replace(RegExp(`(<li\\s+class="nav-item)(\\s*"\\s+data-page="${i}">)`,`iu`),`$1 active$2`),r=r.replace(RegExp(`(<div\\s+class="page\\s+${i}-page)("\\s+data-page-id="${i}">)`,`iu`),`$1 active$2`),r=oc(r,n);let a=ac(r);return[`<template shadowrootmode="open" data-shadow-claw-dsd="true">`,`<style data-dsd-style>${t}</style>`,a,`</template>`].join(`
|
|
82
|
+
`)}function lc(e,t){let n=e.match(/<shadow-claw\b[^>]*>/iu),r=n?n[0]:null,i=n?.index??-1;if(i===-1||!r)throw Error(`Unable to find <shadow-claw> host in index.html.`);let a=e.indexOf(`</shadow-claw>`,i);if(a===-1)throw Error(`Unable to find </shadow-claw> host in index.html.`);let o=i+r.length,s=Qs(Zs(e.slice(o,a))).trim(),c=s?`\n ${t}\n${s}\n `:`\n ${t}\n `;return`${e.slice(0,o)}${c}${e.slice(a)}`}function uc(e){return e.replace(/<shadow-claw(\s[^>]*)?>/iu,(e,t=``)=>/\sdata-prerender-no-seed\s*=\s*/iu.test(t)?`<shadow-claw${t}>`:`<shadow-claw${t} data-prerender-no-seed="true">`)}async function dc(e,t){if(p.env.NODE_ENV!==`production`)return e;let n=e;try{let e=await S(s.join(t,`index.css`),`utf8`);n=n.replace(/<link\b[^>]*?href="(?:\/)?index\.css"[^>]*?>/iu,()=>`<style>${e}</style>`)}catch(e){console.warn(`Failed to inline index.css`,e.message)}try{let e=await S(s.join(t,`theme-init.js`),`utf8`);n=n.replace(/<script\b[^>]*?src="(?:\/)?theme-init\.js"[^>]*?><\/script>/iu,()=>`<script>${e}<\/script>`)}catch(e){console.warn(`Failed to inline theme-init.js`,e.message)}try{let e=await S(s.join(t,`service-worker/init.js`),`utf8`);n=n.replace(/<script\b[^>]*?src="(?:\/)?service-worker\/init\.js"[^>]*?><\/script>/iu,()=>`<script type="module">${e}<\/script>`)}catch(e){console.warn(`Failed to inline service-worker/init.js`,e.message)}return n}function fc(e){if(!e||typeof e!=`string`)return e;let t=[],n=e.replace(/<pre\b[^>]*>[\s\S]*?<\/pre>|<textarea\b[^>]*>[\s\S]*?<\/textarea>/gi,e=>{let n=t.length;return t.push(e),`___PRESERVED_BLOCK_${n}___`}),r=e=>e.replace(/\s+/g,` `).replace(/>\s+</g,`><`).trim();function i(e){let t=/<template\b[^>]*>/gi,n,a=0,o=``;for(;(n=t.exec(e))!==null;){let s=n[0],c=n.index,l=/<\/?template\b[^>]*>/gi;l.lastIndex=c;let u=0,d=!1,f=l.exec(e),p=-1,m=0;for(;f;){if(f[0].toLowerCase().startsWith(`</template`)?--u:(u+=1,d=!0),d&&u===0){p=f.index,m=f[0].length;break}f=l.exec(e)}if(p!==-1){o+=e.slice(a,c);let n=e.slice(c+s.length,p),l=r(i(n));o+=`${s}${l}</template>`,a=p+m,t.lastIndex=a}}return o+=e.slice(a),o}let a=i(n);a=a.replace(/(<template\s+shadowrootmode="?[a-z]+"?[^>]*>)([\s\S]*?)(<\/template>)/gi,(e,t,n,i)=>`${t}${r(n)}${i}`);for(let e=0;e<t.length;e++)a=a.replace(`___PRESERVED_BLOCK_${e}___`,()=>t[e]);return a}async function pc(e={}){let t=s.resolve(e.indexPath||`dist/public/index.html`),n=s.resolve(e.sourcePath||`pages/main`),r=s.resolve(e.skillsSourcePath||s.join(s.dirname(n),`..`,`.agents`,`skills`,`main`)),i=s.resolve(e.toolsSourcePath||s.join(s.dirname(n),`..`,`.agents`,`tools`,`main`)),a=s.resolve(e.publicDir||s.dirname(t)),o=Ms(e.prerenderPages===void 0?e.noSeed?0:p.env.PRERENDER_PAGES??1:e.prerenderPages),c={},l=[e.siteConfigPath,s.resolve(`shadow-claw-config.json`),s.resolve(`shadow-claw.config.json`),s.resolve(`shadowclaw.config.json`),s.resolve(`pages/shadow-claw-config.json`),s.resolve(`pages/shadow-claw.config.json`),s.resolve(`site-config.json`),s.resolve(`pages/site-config.json`)].filter(Boolean);for(let e of l)try{let t=await S(s.resolve(e),`utf8`);c=JSON.parse(t);break}catch{}let u=e.sortOrder||c?.pages?.sortOrder||`desc`,d=s.join(a,`components/shadow-claw/shadow-claw.html`),f=s.join(a,`components/shadow-claw-pages/shadow-claw-pages.html`),m=s.join(a,`components/shadow-claw-page-header/shadow-claw-page-header.html`),h=s.join(a,`components/shadow-claw/shadow-claw.css`),g=s.join(a,`components/shadow-claw-pages/shadow-claw-pages.css`),_=s.join(a,`components/shadow-claw-page-header/shadow-claw-page-header.css`),[v,b,C,w,T,E,k,A,ee,te]=await Promise.all([S(t,`utf8`),S(d,`utf8`),S(f,`utf8`).catch(()=>``),S(m,`utf8`).catch(()=>``),Ks(n,u),qs(r),Js(i),S(h,`utf8`).catch(()=>``),S(g,`utf8`).catch(()=>``),S(_,`utf8`).catch(()=>``)]),ne=await Promise.all(T.map(async e=>{let t=typeof e.inlineContent==`string`?e.inlineContent:await S(e.absolutePath,`utf8`);return{...e,content:t}})),j,M={},N=ne.filter(e=>{if(e.displayPath.endsWith(`.md`)&&/^---\r?\n[\s\S]*?slug:\s*"shadow-claw--purge-pages"[\s\S]*?---/mu.test(e.content)){if(Us(M,n,e.displayPath),!j){let t=Vs(e.content).data[`purge-id`];t!=null&&(j=String(t))}return!1}return!0}),re=N.map(e=>({displayPath:e.displayPath,content:e.content})),P={pages:re},F=await Promise.all(E.filter(e=>!e.isPurgeMarker).map(async e=>({displayPath:e.displayPath,content:await S(e.absolutePath,`utf8`)})));F.length>0&&(P.skills=F);let I=await Promise.all(k.map(async e=>({displayPath:e.displayPath,content:await S(e.absolutePath,`utf8`)})));I.length>0&&(P.tools=I);let L=E.find(e=>e.isPurgeMarker);L?.purgeId&&(P.skillsPurgeId=L.purgeId),Object.keys(M).length>0&&(P.preRenderedStaticPages=M),j&&(P.purgeId=j);let R=s.join(a,`static-main-manifest.json`);await x(a,{recursive:!0}),await O(R,JSON.stringify(P,null,2),`utf8`);try{if((await D(n)).isDirectory()){let e=s.join(a,`static-main`);await x(e,{recursive:!0}),await y(n,e,{recursive:!0});let t=s.join(a,`files/main`);await x(t,{recursive:!0}),await y(n,t,{recursive:!0})}}catch{}try{(await D(i)).isDirectory()&&(await x(s.join(a,`tools/main`),{recursive:!0}),await y(i,s.join(a,`tools/main`),{recursive:!0}))}catch{}try{(await D(r)).isDirectory()&&(await x(s.join(a,`skills/main`),{recursive:!0}),await y(r,s.join(a,`skills/main`),{recursive:!0}))}catch{}let z=Hs(b);if(o===0){let n=cc(z,A,c.sidebar);await O(t,await dc(fc(Is(lc(uc(v),n),JSON.stringify({pages:[],skills:[]}))),a),`utf8`),(e.silent??p.env.NODE_ENV===`test`)||console.log(`Injected DSD shell into ${t} (pages DSD disabled).`);return}let ie=[],B=[];o===`all`?(ie=N,B=re):typeof o==`number`&&(ie=N.slice(0,o),B=re.slice(0,o));let ae=Hs(C),V=Hs(w),oe;if(N.length===0)oe=sc(z,ic(ae,ee),A,c.sidebar);else{let e=N[0],t=Vs(e.content),n=t.data&&t.data.title?t.data.title:``,r=await Ys(e.content,e.absolutePath||e.displayPath);oe=sc(z,nc(ae,ie,r,V,n,ee,te),A,c.sidebar)}let se=uc(lc(v,oe)),H={pages:B};F.length>0&&(H.skills=F),I.length>0&&(H.tools=I),L?.purgeId&&(H.skillsPurgeId=L.purgeId),Object.keys(M).length>0&&(H.preRenderedStaticPages=M),j&&(H.purgeId=j),await O(t,await dc(fc(Is(se,JSON.stringify(H))),a),`utf8`),(e.silent??p.env.NODE_ENV===`test`)||console.log(`Injected DSD shell into ${t} from ${n} (${ie.length} of ${T.length} page${T.length===1?``:`s`} prerendered).`)}async function mc(){let e=p.argv.slice(2).filter(e=>!e.startsWith(`--`)),t=p.argv.slice(2).filter(e=>e.startsWith(`--`)),n=t.includes(`--no-seed`),r;for(let e of t)e.startsWith(`--prerender-pages=`)?r=e.slice(18):e.startsWith(`--pages=`)&&(r=e.slice(8));let[i=`dist/public/index.html`,a=`pages/main`]=e;await pc({indexPath:i,sourcePath:a,noSeed:n,prerenderPages:r})}p.argv[1]&&s.resolve(p.argv[1])===s.resolve(f(import.meta.url))&&mc().catch(e=>{console.error(e),p.exit(1)});function hc(e){return e.replace(/^\/+|\/+$/g,``)}function gc(e){let t=hc(e);if(t.startsWith(`pages/main/`))return t.slice(11);if(t.startsWith(`pages/br:main/`)||t.startsWith(`pages/br-main/`))return t.slice(14);if(t.startsWith(`main/`))return t.slice(5);if(t.startsWith(`pages/`)){let e=t.split(`/`);if(e.length>=3)return e.slice(2).join(`/`)}return t}function _c(e,t){let n=`<script id="shadow-claw-static-routing" type="application/json">${Ns(t)}<\/script>`;return/id="shadow-claw-static-routing"/iu.test(e)?e.replace(/<script\s+id="shadow-claw-static-routing"[\s\S]*?<\/script>/iu,()=>n):Fs(e,` ${n}`)}async function vc(e={}){let t=s.resolve(e.publicDir||`dist/public`),n=s.resolve(e.routesPath||`pages/routes.json`),r=s.resolve(e.sourcePath||`pages/main`),i=s.resolve(e.indexPath||s.join(t,`index.html`)),a={},o=[e.siteConfigPath,s.resolve(s.dirname(r),`shadow-claw.config.json`),s.resolve(s.dirname(r),`site-config.json`),s.resolve(`shadow-claw.config.json`),s.resolve(`site-config.json`),s.join(t,`shadow-claw.config.json`),s.join(t,`site-config.json`)].filter(Boolean);for(let e of o)try{let t=await S(e,`utf8`);a=JSON.parse(t);break}catch{}let c=Ms(e.prerenderPages===void 0?p.env.PRERENDER_PAGES??1:e.prerenderPages),l;try{l=await S(n,`utf8`)}catch(e){if(e?.code===`ENOENT`)return{count:0,skipped:!0,reason:`No routes.json found`};throw e}let u;try{u=JSON.parse(l)}catch(e){return console.warn(`Failed to parse ${n}:`,e),{count:0,skipped:!0,reason:`Invalid JSON in routes.json`}}if(!u||typeof u!=`object`)return{count:0,skipped:!0,reason:`Invalid routes.json`};u.routes||={};let d={...u.routes||{}},f=new Set;async function m(e,t){if(!e.subRoutes)return;let n=Array.isArray(e.subRoutes)?e.subRoutes:Object.values(e.subRoutes);for(let e of n){let n=s.resolve(s.dirname(t),e);if(typeof e==`string`&&e.startsWith(`pages/`)&&(n=s.resolve(e)),!f.has(n)){f.add(n);try{let e=await S(n,`utf8`),t=JSON.parse(e);t.routes&&Object.assign(d,t.routes),await m(t,n)}catch(e){console.warn(`Failed to read subRoute: ${n}`,e?.message)}}}}await m(u,n),Object.assign(u.routes,d),Array.isArray(u.subRoutes)&&delete u.subRoutes;let h=Object.entries(d);if(h.length===0)return{count:0,skipped:!0,reason:`Empty routes table`};let g=JSON.stringify(u,null,2),_=s.join(t,`static-routing.json`);await x(t,{recursive:!0}),await O(_,g,`utf8`);let v=JSON.stringify(u),b=s.join(t,`components/shadow-claw/shadow-claw.html`),w=s.join(t,`components/shadow-claw-pages/shadow-claw-pages.html`),T=s.join(t,`components/shadow-claw-page-header/shadow-claw-page-header.html`),E=s.join(t,`components/shadow-claw/shadow-claw.css`),k=s.join(t,`components/shadow-claw-pages/shadow-claw-pages.css`),A=s.join(t,`components/shadow-claw-page-header/shadow-claw-page-header.css`),[ee,te,ne,j,M,N,re,P]=await Promise.all([S(i,`utf8`),S(b,`utf8`),S(w,`utf8`).catch(()=>``),S(T,`utf8`).catch(()=>``),Ks(r),S(E,`utf8`).catch(()=>``),S(k,`utf8`).catch(()=>``),S(A,`utf8`).catch(()=>``)]),F=(await Promise.all(M.map(async e=>{let t=typeof e.inlineContent==`string`?e.inlineContent:await S(e.absolutePath,`utf8`);return{...e,content:t}}))).filter(e=>!(e.displayPath.endsWith(`.md`)&&/^---\r?\n[\s\S]*?slug:\s*"shadow-claw--purge-pages"[\s\S]*?---/mu.test(e.content||``)));await O(i,await dc(fc(_c(ee,v)),t),`utf8`);let I=Hs(te),L=Hs(ne),R=Hs(j),z=F.map(e=>({displayPath:e.displayPath,content:e.content})),ie=s.join(t,`static-main-manifest.json`),B={};try{B=JSON.parse(await S(ie,`utf8`))}catch{}let ae={pages:z,...Array.isArray(B.skills)?{skills:B.skills}:{},...Array.isArray(B.tools)?{tools:B.tools}:{},...B.skillsPurgeId?{skillsPurgeId:B.skillsPurgeId}:{},...B.preRenderedStaticPages?{preRenderedStaticPages:B.preRenderedStaticPages}:{},...B.purgeId?{purgeId:B.purgeId}:{}};await O(ie,JSON.stringify(ae,null,2),`utf8`);try{if((await D(r)).isDirectory()){let e=s.join(t,`static-main`);await x(e,{recursive:!0}),await y(r,e,{recursive:!0});let n=s.join(t,`files/main`);await x(n,{recursive:!0}),await y(r,n,{recursive:!0})}}catch{}let V=[];for(let[e,n]of h){if(!n||!n.prettyPath)continue;let i=gc(e),o=F.find(e=>e.displayPath===i);if(!o)try{let e=s.join(r,i);o={absolutePath:e,displayPath:i,content:await S(e,`utf8`)}}catch{console.warn(`Could not find page file for route: ${e} (${i})`);continue}let l=F.filter(e=>e.displayPath!==o.displayPath),u=[],d=[];c===`all`?(u=[o,...l],d=u.map(e=>({displayPath:e.displayPath,content:e.content}))):typeof c==`number`&&(c===0?(u=[],d=[]):(u=[o,...l.slice(0,c-1)],d=u.map(e=>({displayPath:e.displayPath,content:e.content}))));let f=Vs(o.content||``),p=f.data&&f.data.title?f.data.title:``,m=await Ys(o.content||``,o.displayPath),h;h=c===0?cc(I,N,a.sidebar):sc(I,nc(L,u,m,R,p,re,P),N,a.sidebar);let g=await dc(fc(_c(Is(uc(lc(ee,h)),JSON.stringify({pages:d,...Array.isArray(B.skills)?{skills:B.skills}:{},...Array.isArray(B.tools)?{tools:B.tools}:{},...B.skillsPurgeId?{skillsPurgeId:B.skillsPurgeId}:{},...B.preRenderedStaticPages?{preRenderedStaticPages:B.preRenderedStaticPages}:{},...B.purgeId?{purgeId:B.purgeId}:{}})),v)),t),_=hc(n.prettyPath),b;b=_.endsWith(`.html`)?_:s.join(_,`index.html`);let w=s.join(t,b),T=s.dirname(w);if(await x(T,{recursive:!0}),await O(w,g,`utf8`),o&&o.absolutePath)try{let e=s.dirname(o.absolutePath),t=await C(e,{withFileTypes:!0});for(let n of t)n.isFile()&&!Ws(n.name)&&n.name!==`routes.json`&&await y(s.join(e,n.name),s.join(T,n.name))}catch(t){console.warn(`Failed to copy co-located assets for ${e}:`,t)}V.push(b.replace(/\\/g,`/`))}return(e.silent??p.env.NODE_ENV===`test`)||console.log(`Prerendered ${V.length} pretty path page${V.length===1?``:`s`} from ${n} (prerender-pages: ${c}).`),{count:V.length,generatedPaths:V,skipped:!1}}async function yc(){let e=p.argv.slice(2).filter(e=>!e.startsWith(`--`)),t=p.argv.slice(2).filter(e=>e.startsWith(`--`)),n;for(let e of t)e.startsWith(`--prerender-pages=`)?n=e.slice(18):e.startsWith(`--pages=`)&&(n=e.slice(8));let r=e[0]||`dist/public`;await vc({publicDir:r,routesPath:e[1]||`pages/routes.json`,sourcePath:e[2]||`pages/main`,indexPath:e[3]||s.join(r,`index.html`),prerenderPages:n})}p.argv[1]&&s.resolve(p.argv[1])===s.resolve(f(import.meta.url))&&yc().catch(e=>{console.error(e),p.exit(1)});function bc(e={},t={}){let n=e.customElements;return{rawScripts:(typeof n==`object`&&!Array.isArray(n)?n.scripts:n)||e.scripts||t.scripts||[],allowedDomains:(typeof n==`object`&&!Array.isArray(n)?n.allowedDomains:void 0)||e.allowedCustomElementDomains||[]}}function xc(e,t){if(!e.startsWith(`http://`)&&!e.startsWith(`https://`)&&!e.startsWith(`//`)||!t||Array.isArray(t)&&t.length===0)return!0;try{let n=new URL(e,`https://localhost`).hostname.toLowerCase();return(Array.isArray(t)?t:String(t).split(/[\n,]+/)).some(e=>{let t=e.trim().toLowerCase();return n===t||n.endsWith(`.`+t)||t===`*`})}catch{return!1}}function Sc(e,t){let n=JSON.parse(JSON.stringify(e));return n.customElements&&typeof n.customElements==`object`&&Array.isArray(n.customElements.scripts)&&(n.customElements.scripts=n.customElements.scripts.filter(e=>{let n=typeof e==`string`?e:e?.src;return n?xc(n,t):!1})),n}function Q(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}const Cc=[`pages/resources/`,`pages/deps/`,`resources/`,`deps/`,`pages/assets/`,`pages/main/assets/`];function wc(e){for(let t of Cc)if(e.startsWith(t))return e.slice(t.length);return e}async function Tc(e){try{return JSON.parse(await S(e,`utf8`))}catch{return null}}async function Ec(e){try{return await S(e,`utf8`)}catch{return null}}async function Dc(e,t){await O(e,t,`utf8`)}function Oc(e){return!Array.isArray(e)||e.length===0?``:`<nav slot="sidebar" class="sidebar-custom-sections" aria-label="Site Navigation">\n${e.map((e,t)=>{if(e.html)return e.html;let n=e.title?`sidebar-${e.title.toLowerCase().replace(/[^a-z0-9]+/g,`-`)}`:`sidebar-section-${t+1}`,r=e.headerHref?`<a href="${Q(e.headerHref)}" class="sidebar-link">${Q(e.title||``)}</a>`:`<span>${Q(e.title||``)}</span>`,i=e.title?` <div class="sidebar-section-header">${r}</div>`:``,a=(e.items||[]).map(e=>{let t=e.title||e.label||``,n=e.href||`#`,r=e.target?` target="${Q(e.target)}"`:``,i=e.rel?` rel="${Q(e.rel)}"`:e.target===`_blank`?` rel="noopener noreferrer"`:``,a=e.active?` active`:``,o=e.active?` aria-current="page"`:``;return` <div class="sidebar-item"><a href="${Q(n)}"${r}${i} class="sidebar-link${a}"${o}>${Q(t)}</a></div>`}).join(`
|
|
84
83
|
`);return[` <section class="sidebar-section" id="${n}">`,i,a,` </section>`].filter(Boolean).join(`
|
|
85
84
|
`)}).join(`
|
|
86
|
-
`)}\n</nav>`}function kc(e,t,n){let r=e,i=t.site||{};i.title&&(r=r.replace(/<title>[^<]*<\/title>/iu,`<title>${Q(i.title)}</title>`)),i.description&&(r=r.replace(/<meta\s+name="description"\s+content="[^"]*"\s*\/?>/iu,`<meta name="description" content="${Q(i.description)}" />`)),i.themeColor&&(r=r.replace(/<meta\s+name="theme-color"\s+content="[^"]*"\s*\/?>/iu,`<meta name="theme-color" content="${Q(i.themeColor)}" />`)),i.lang&&(r=r.replace(/<html\s+lang="[^"]*"/iu,`<html lang="${i.lang}"`));let a=t.branding||{};if(a.faviconPath){let e=a.faviconPath.replace(/^pages\/main\//,``),t=e.endsWith(`.svg`)?`image/svg+xml`:e.endsWith(`.png`)?`image/png`:`image/x-icon`,n=`<link href="${Q(e)}" rel="icon" type="${t}" />`,i=!1;r=r.replace(/<link\b[^>]*\brel=["']?(?:shortcut\s+)?icon["']?[^>]*\/?>/giu,()=>i?``:(i=!0,n)),i||(r=
|
|
85
|
+
`)}\n</nav>`}function kc(e,t,n){let r=e,i=t.site||{};i.title&&(r=r.replace(/<title>[^<]*<\/title>/iu,`<title>${Q(i.title)}</title>`)),i.description&&(r=r.replace(/<meta\s+name="description"\s+content="[^"]*"\s*\/?>/iu,`<meta name="description" content="${Q(i.description)}" />`)),i.themeColor&&(r=r.replace(/<meta\s+name="theme-color"\s+content="[^"]*"\s*\/?>/iu,`<meta name="theme-color" content="${Q(i.themeColor)}" />`)),i.lang&&(r=r.replace(/<html\s+lang="[^"]*"/iu,`<html lang="${i.lang}"`));let a=t.branding||{};if(a.faviconPath){let e=a.faviconPath.replace(/^pages\/main\//,``),t=e.endsWith(`.svg`)?`image/svg+xml`:e.endsWith(`.png`)?`image/png`:`image/x-icon`,n=`<link href="${Q(e)}" rel="icon" type="${t}" />`,i=!1;r=r.replace(/<link\b[^>]*\brel=["']?(?:shortcut\s+)?icon["']?[^>]*\/?>/giu,()=>i?``:(i=!0,n)),i||(r=Fs(r,` ${n}`))}if(a.appleTouchIconPath){let e=`<link href="${Q(a.appleTouchIconPath.replace(/^pages\/main\//,``))}" rel="apple-touch-icon" />`,t=!1;r=r.replace(/<link\b[^>]*\brel=["']?apple-touch-icon["']?[^>]*\/?>/giu,()=>t?``:(t=!0,e)),t||(r=Fs(r,` ${e}`))}if(a.titleText||a.siteUrl||a.logoSlotHtml){let e=a.titleText||`ShadowClaw`,t=a.siteUrl||``,n=a.logoSlotHtml||``;r=r.replace(/<a\b[^>]*\bslot="header-title-link"[^>]*>[\s\S]*?<\/a>/iu,[`<a`,` aria-label="${Q(e)}"`,` class="header-title-link"`,t?` href="${Q(t)}"`:``,` slot="header-title-link"`,` >`,n?` ${n}`:``,` <span class="header-title">${Q(e)}</span>`,` </a>`].filter(Boolean).join(`
|
|
87
86
|
`))}if(a.repoUrl){let e=a.repoLabel||`Project on GitHub`;r=r.replace(/<a\b[^>]*\bslot="header-actions-logo"[^>]*>[\s\S]*?<\/a>/iu,[`<a`,` aria-label="${Q(e)}"`,` class="header-actions-logo-link"`,` href="${Q(a.repoUrl)}"`,` slot="header-actions-logo"`,` >`,` <svg aria-hidden="true" focusable="false" viewBox="0 0 496 512" xmlns="http://www.w3.org/2000/svg">`,` <path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8z" fill="var(--shadow-claw-bg-primary-reverse, currentColor)"></path>`,` </svg>`,` </a>`].join(`
|
|
88
87
|
`))}a.siteUrl&&!a.siteUrl.includes(`xt-ml.github.io`)&&(r=r.replace(/\s*<meta\s+http-equiv="origin-trial"\s+content="[^"]*"\s*\/?>\s*/iu,`
|
|
89
|
-
`));let o=t.theme||{};if(o.stylesheet){let e=wc(o.stylesheet),t=`<link rel="stylesheet" href="${Q(e)}" />`,n=Q(e).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),a=RegExp(`<link\\s+[^>]*href=["'](?:${i}|${n})["'][^>]*>`,`iu`),s=r.slice(0,
|
|
88
|
+
`));let o=t.theme||{};if(o.stylesheet){let e=wc(o.stylesheet),t=`<link rel="stylesheet" href="${Q(e)}" />`,n=Q(e).replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),a=RegExp(`<link\\s+[^>]*href=["'](?:${i}|${n})["'][^>]*>`,`iu`),s=Ps(r),c=(s===-1?r:r.slice(0,s)).replace(/<script\b[\s\S]*?<\/script>/gi,``);a.test(c)||(r=/<link\s+rel="stylesheet"\s+href="index\.css"\s*\/?>/iu.test(r)?r.replace(/(<link\s+rel="stylesheet"\s+href="index\.css"\s*\/?>)/iu,`$1\n ${t}`):Fs(r,` ${t}`))}let{allowedDomains:s}=bc(t,o),c=Sc(t,s),l=`<script id="shadow-claw-site-config" type="application/json">${JSON.stringify(c).replace(/</g,`\\u003c`).replace(/>/g,`\\u003e`).replace(/\//g,`\\u002f`)}<\/script>`;r=r.includes(`<script id="shadow-claw-site-config"`)?r.replace(/<script\s+id="shadow-claw-site-config"[\s\S]*?<\/script>/iu,()=>l):r.includes(`<script src="theme-init.js">`)?r.replace(`<script src="theme-init.js">`,`${l}\n <script src="theme-init.js">`):/<script\b[^>]*>\s*var\s+ShadowClawThemeInit\b/iu.test(r)?r.replace(/(<script\b[^>]*>\s*var\s+ShadowClawThemeInit\b)/iu,`${l}\n $1`):Fs(r,` ${l}`);let u=n||t.sidebar?.slotHtml||(t.sidebar?.sections?Oc(t.sidebar.sections):``);if(u){let e=u.trim();/\bslot="sidebar(?:-nav|-content|-footer)?"/iu.test(e)||(e=`<div slot="sidebar" class="sidebar-custom-sections">\n${e}\n</div>`);let t=r.match(/<[^>]+?\bslot="sidebar(?:-nav|-content|-footer)?"[^>]*>[\s\S]*?<\/[^>]+>/iu);t&&(r=r.replace(t[0],``)),r.includes(`</shadow-claw>`)?r=r.replace(`</shadow-claw>`,` ${e}\n</shadow-claw>`):r.includes(`<shadow-claw></shadow-claw>`)&&(r=r.replace(`<shadow-claw></shadow-claw>`,`<shadow-claw>\n ${e}\n</shadow-claw>`))}return t.sidebar&&(r=oc(r,t.sidebar)),r}function Ac(e){let t=(e.src||``).replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``),n=e.type||(t.endsWith(`.svg`)?`image/svg+xml`:t.endsWith(`.png`)?`image/png`:`image/x-icon`),r=(e.purpose||`any`).trim();return n===`image/svg+xml`||t.endsWith(`.svg`)?[{...e,src:t,type:n,purpose:`any`}]:r.includes(`any`)&&r.includes(`maskable`)?[{...e,src:t,type:n,purpose:`any`},{...e,src:t,type:n,purpose:`maskable`}]:[{...e,src:t,type:n,purpose:r}]}function jc(e,t){let n=typeof e==`string`?JSON.parse(e):e,r=t.pwa||{},i=t.site||{},a=p.env.PAGES_ORIGIN;if((r.name||i.title)&&(n.name=r.name||i.title),(r.shortName||i.title)&&(n.short_name=r.shortName||i.title),i.description&&(n.description=i.description),r.backgroundColor&&(n.background_color=r.backgroundColor),(r.themeColor||i.themeColor)&&(n.theme_color=r.themeColor||i.themeColor),r.startUrl?n.start_url=r.startUrl:a?n.start_url=a:n.start_url||=`./`,r.icons&&Array.isArray(r.icons)){let e=r.icons.flatMap(Ac),t=Array.isArray(n.icons)?n.icons.flatMap(Ac):[],i=new Set(e.map(e=>e.src));n.icons=[...e,...t.filter(e=>!i.has(e.src))]}else Array.isArray(n.icons)&&(n.icons=n.icons.flatMap(Ac));return r.screenshots&&Array.isArray(r.screenshots)&&(n.screenshots=r.screenshots.map(e=>{let t=(e.src||``).replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``);return{...e,src:t}})),JSON.stringify(n,null,2)}function Mc(e,t){if(!t)return e;if(/<loc>/i.test(e))return e.replace(/<loc>[^<]*<\/loc>/giu,`<loc>${Q(t)}</loc>`);let n=t.endsWith(`/`)?t:t+`/`;return e.split(`
|
|
90
89
|
`).map(e=>{let t=e.trim();if(!t)return e;if(t.startsWith(`http://`)||t.startsWith(`https://`))try{let e=new URL(t),r=new URL(n);return e.protocol=r.protocol,e.host=r.host,e.pathname=(r.pathname.endsWith(`/`)?r.pathname.slice(0,-1):r.pathname)+e.pathname,e.toString()}catch{return n}else if(t.startsWith(`/`))try{return new URL(t,n).toString()}catch{return e}return e}).join(`
|
|
91
90
|
`)}function Nc(e,t,n){let r=e,i=t.site||{};if(i.title&&(r=r.replace(/<title>[^<]*<\/title>/iu,`<title>${Q(i.title)} - Not Found</title>`)),n){let e=n.endsWith(`/`)?n:n+`/`;r=r.replace(/l\.replace\(["']\/shadow-claw\/["']\)/gu,`l.replace("${Q(e)}")`)}return r}function Pc(e){let t=s.resolve(e),n=t.split(s.sep),r=n[n.length-1],i=n[n.length-2];return(r===`resources`||r===`deps`)&&i===`pages`?s.resolve(t,`../..`):r===`resources`||r===`deps`||r===`pages`?s.resolve(t,`..`):t}function Fc(e){let t=s.resolve(e),n=s.basename(t);return n===`resources`||n===`deps`||n===`pages`?s.resolve(t,`..`):t}function Ic(e,t,n){if(!e||typeof e!=`string`)return[];if(s.isAbsolute(e))return[e];let r=e.replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``),i=Pc(t);return[s.resolve(t,`resources`,r),s.resolve(t,`deps`,r),s.resolve(t,`main`,r),s.resolve(i,`pages`,`resources`,r),s.resolve(i,`pages`,`resources`,e),s.resolve(i,`pages`,`deps`,r),s.resolve(i,`pages`,`deps`,e),s.resolve(i,`resources`,r),s.resolve(i,`resources`,e),s.resolve(i,`deps`,r),s.resolve(i,`deps`,e),s.resolve(n,`pages`,`resources`,r),s.resolve(n,`pages`,`deps`,r),s.resolve(n,`resources`,r),s.resolve(n,`deps`,r),s.resolve(n,`pages`,e),s.resolve(n,`pages`,r),s.resolve(n,`pages`,`main`,r),s.resolve(i,`pages`,e),s.resolve(i,`pages`,r),s.resolve(i,`pages`,`main`,r),s.resolve(i,`pages`,`main`,e),s.resolve(t,e),s.resolve(t,r),s.resolve(n,e),s.resolve(n,r),s.resolve(i,e),s.resolve(i,r)]}async function Lc(e){for(let t of e)if(t)try{return await D(t),t}catch{}return null}async function Rc(e,t,n){let r=n?s.dirname(s.resolve(n)):p.cwd(),i=Fc(r),a=Pc(r),o=[s.resolve(r,`resources`),s.resolve(r,`deps`),s.resolve(i,`resources`),s.resolve(i,`deps`),s.resolve(i,`pages`,`resources`),s.resolve(i,`pages`,`deps`),s.resolve(a,`resources`),s.resolve(a,`deps`),s.resolve(a,`pages`,`resources`),s.resolve(a,`pages`,`deps`)];for(let e of o)try{let n=await C(e,{withFileTypes:!0});for(let r of n){let n=s.join(e,r.name),i=s.join(t,r.name);r.isDirectory()?await y(n,i,{recursive:!0,force:!0}):r.isFile()&&(await x(s.dirname(i),{recursive:!0}),await v(n,i))}}catch{}let c=await Lc([...e.pages?.notFoundPath?Ic(e.pages.notFoundPath,r,i):[],...e.branding?.notFoundPath?Ic(e.branding.notFoundPath,r,i):[],...e.notFoundPath?Ic(e.notFoundPath,r,i):[],...Ic(`404.html`,r,i)]);if(c)try{await v(c,s.join(t,`404.html`)),console.log(` Copied custom 404.html: ${c}`)}catch(e){console.warn(` Warning: Could not copy custom 404.html: ${e.message}`)}let l=await Lc([...e.pwa?.manifestPath?Ic(e.pwa.manifestPath,r,i):[],...e.manifestPath?Ic(e.manifestPath,r,i):[],...Ic(`manifest.json`,r,i)]);if(l)try{await v(l,s.join(t,`manifest.json`)),console.log(` Copied custom manifest.json: ${l}`)}catch(e){console.warn(` Warning: Could not copy custom manifest.json: ${e.message}`)}let u=!1;if(e.sitemapPath){let n=await Lc(Ic(e.sitemapPath,r,i));if(n)try{let e=s.basename(n);await v(n,s.join(t,e)),console.log(` Copied custom sitemap: ${n} → ${e}`),u=!0}catch(e){console.warn(` Warning: Could not copy custom sitemap: ${e.message}`)}}if(!u){let e=await Lc(Ic(`sitemap.xml`,r,i));if(e)try{await v(e,s.join(t,`sitemap.xml`)),console.log(` Copied custom sitemap.xml: ${e}`)}catch(e){console.warn(` Warning: Could not copy custom sitemap.xml: ${e.message}`)}let n=await Lc(Ic(`sitemap.txt`,r,i));if(n)try{await v(n,s.join(t,`sitemap.txt`)),console.log(` Copied custom sitemap.txt: ${n}`)}catch(e){console.warn(` Warning: Could not copy custom sitemap.txt: ${e.message}`)}}let d=e.overwriteAssets===!0||e.branding?.overwriteAssets===!0,f=Array.isArray(e.assets)?e.assets:[e.assetsDir,e.assets].filter(Boolean),m=Array.from(new Set([...f.flatMap(e=>Ic(e,r,i)),...Ic(`assets`,r,i)].filter(e=>e&&typeof e==`string`))),h=s.join(t,`assets`);if(d)try{await E(h,{recursive:!0,force:!0}),await x(h,{recursive:!0}),console.log(` Cleared dist public assets for complete template asset overwrite.`)}catch{}let g=new Set,_=[...m].reverse();for(let e of _)if(!g.has(e))try{let t=await D(e);if(g.add(e),t.isDirectory())await y(e,h,{recursive:!0,force:!0}),console.log(` Copied custom assets: ${e} → ${h}`);else if(t.isFile()){let t=s.basename(e);await x(h,{recursive:!0}),await v(e,s.join(h,t)),console.log(` Copied custom asset file: ${e} → ${h}`)}}catch{}}async function zc(e,t,n){let r=e.theme||{};if(!r.stylesheet)return;let i=n?s.dirname(s.resolve(n)):p.cwd(),a=Fc(i),o=await Lc(Ic(r.stylesheet,i,a));if(!o)return;let c=r.stylesheet.replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``),l=s.join(t,c);try{await x(s.dirname(l),{recursive:!0}),await v(o,l),console.log(` Copied theme stylesheet: ${o} → ${l}`)}catch(e){console.warn(` Warning: Could not copy theme stylesheet ${o}: ${e.message}`)}}async function Bc(e,t,n){let r=(e.customElements&&typeof e.customElements==`object`&&!Array.isArray(e.customElements)?e.customElements?.scripts:void 0)||e.scripts||[];if(!Array.isArray(r)||r.length===0)return;let i=n?s.dirname(s.resolve(n)):p.cwd(),a=Fc(i);for(let e of r){let n=typeof e==`string`?e:e?.src;if(!n||n.startsWith(`http://`)||n.startsWith(`https://`)||n.startsWith(`//`))continue;let r=await Lc(Ic(n,i,a));if(r){let e=n.replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``),i=s.join(t,e);try{await x(s.dirname(i),{recursive:!0}),await v(r,i),console.log(` Copied custom script: ${r} → ${i}`)}catch(e){console.warn(` Warning: Could not copy custom script ${r}: ${e.message}`)}}}}async function Vc(e,t,n){let r=e.branding||{},i=e.pwa||{},a=n?s.dirname(s.resolve(n)):p.cwd(),o=Fc(a),c=[],l=await Lc(Ic(i.manifestPath||e.manifestPath||`manifest.json`,a,o));if(l){let e=await Tc(l);e&&Array.isArray(e.icons)&&(c=e.icons.map(e=>e?.src).filter(Boolean))}let u=[r.faviconPath,r.appleTouchIconPath,`assets/icons/favicon.svg`,`assets/icons/favicon.ico`,`favicon.svg`,`favicon.ico`,`pages/resources/assets/icons/favicon.svg`,`pages/resources/assets/icons/favicon.ico`,`pages/resources/favicon.svg`,`pages/deps/favicon.svg`,`pages/main/favicon.svg`,...Array.isArray(i.icons)?i.icons.map(e=>e.src):[],...c].filter(e=>!!e&&typeof e==`string`&&!e.startsWith(`http://`)&&!e.startsWith(`https://`)&&!e.startsWith(`//`));if(u.length===0)return;let d=new Set,f=new Set;for(let e of u){if(d.has(e))continue;d.add(e);let n=await Lc(Ic(e,a,o));if(n){let r=e.replace(/^(pages\/)?(resources\/|deps\/|main\/)?/,``),i=s.join(t,r);if(f.has(i))continue;f.add(i);try{await x(s.dirname(i),{recursive:!0}),await v(n,i),console.log(` Copied branding asset: ${n} → ${i}`)}catch(e){console.warn(` Warning: Could not copy branding asset ${n}: ${e.message}`)}}}}async function Hc(e,t){let n=await Tc(t);if(!n)return console.log(`No site-config.json found — skipping site configuration.`),{applied:!1};console.log(`Applying site-config.json...`);let r=p.env.PAGES_ORIGIN||``,i=p.env.PAGES_BASE_PATH||``;await Rc(n,e,t);let a=t?s.dirname(s.resolve(t)):p.cwd(),o=Fc(a),c;if(n.sidebar?.slotHtml)c=n.sidebar.slotHtml;else if(n.sidebar?.sections)c=Oc(n.sidebar.sections);else{let e=await Lc([n.sidebar?.slotPath,`pages/main/sidebar.html`,`pages/sidebar.html`,`sidebar.html`,`resources/sidebar.html`].filter(Boolean).flatMap(e=>Ic(e,a,o)));e&&(c=await Ec(e)??void 0,console.log(` Found slotted sidebar: ${e}`))}let l=s.join(e,`index.html`),u=await Ec(l);u&&(await Dc(l,kc(u,n,c)),console.log(` Patched index.html`));let d=s.join(e,`manifest.json`),f=await Ec(d);f&&(await Dc(d,jc(f,n)),console.log(` Patched manifest.json`));let m=s.join(e,`sitemap.xml`),h=await Ec(m);h&&(await Dc(m,Mc(h,r)),console.log(` Patched sitemap.xml`));let g=s.join(e,`sitemap.txt`),_=await Ec(g);_&&(await Dc(g,Mc(_,r)),console.log(` Patched sitemap.txt`));let v=s.join(e,`404.html`),y=await Ec(v);return y&&(await Dc(v,Nc(y,n,i)),console.log(` Patched 404.html`)),await zc(n,e,t),await Bc(n,e,t),await Vc(n,e,t),console.log(`Site configuration applied successfully.`),{applied:!0}}async function Uc(){let[e,t]=p.argv.slice(2);(!e||!t)&&(console.error(`Usage: node bin/site-config/apply.mjs <distPublicDir> <siteConfigPath>`),p.exit(1)),await Hc(e,t)}p.argv[1]&&s.resolve(p.argv[1])===s.resolve(f(import.meta.url))&&Uc().catch(e=>{console.error(`site-config/apply.ts failed:`,e),p.exit(1)});function Wc(){return[`const shadowClawServiceWorkerTrustedTypesFactory = Reflect.get(self, "trustedTypes");`,`let shadowClawServiceWorkerTrustedTypesPolicy = null;`,`if (shadowClawServiceWorkerTrustedTypesFactory && typeof shadowClawServiceWorkerTrustedTypesFactory.createPolicy === "function") {`,` try {`,` if (typeof shadowClawServiceWorkerTrustedTypesFactory.getPolicy === "function") {`,` shadowClawServiceWorkerTrustedTypesPolicy =`,` shadowClawServiceWorkerTrustedTypesFactory.getPolicy("default") ||`,` shadowClawServiceWorkerTrustedTypesFactory.getPolicy("shadowclaw-sandbox") ||`,` null;`,` }`,``,` if (!shadowClawServiceWorkerTrustedTypesPolicy) {`,` shadowClawServiceWorkerTrustedTypesPolicy =`,` shadowClawServiceWorkerTrustedTypesFactory.createPolicy("default", {`,` createHTML: (input) => input,`,` createScriptURL: (input) => input,`,` });`,` }`,` } catch {`,` // Ignore policy creation failures and fall back to raw importScripts.`,` }`,`}`,``,`const shadowClawNativeImportScripts = typeof importScripts === "function" ? importScripts.bind(self) : null;`,``,`const shadowClawImportScripts = (...urls) => {`,` if (!shadowClawNativeImportScripts) {`,` return;`,` }`,``,` if (!shadowClawServiceWorkerTrustedTypesPolicy || typeof shadowClawServiceWorkerTrustedTypesPolicy.createScriptURL !== "function") {`,` shadowClawNativeImportScripts(...urls);`,``,` return;`,` }`,``,` shadowClawNativeImportScripts(...urls.map((url) => shadowClawServiceWorkerTrustedTypesPolicy.createScriptURL(url)));`,`};`].join(`
|
|
92
|
-
`)}function Gc(e){return e.includes(`shadowClawImportScripts`)||!e.includes(`if(!self.define){`)||!e.includes(`importScripts(`)?e:`${Wc()}\n${e.replace(/importScripts\(/g,`shadowClawImportScripts(`)}`}const Kc=u(p.cwd(),`dist/public/service-worker.js`);async function qc(e=Kc,{readFileImpl:t=S,writeFileImpl:n=O,patchImpl:r=Gc,logImpl:i=console.log}={}){let a=await t(e,`utf8`),o=r(a);o!==a&&(await n(e,o,`utf8`),i(`Patched Trusted Types imports in ${e}`))}async function Jc(){await qc(p.argv[2]||Kc)}p.argv[1]&&s.resolve(p.argv[1])===s.resolve(f(import.meta.url))&&Jc().catch(e=>{console.error(e),p.exit(1)});async function Yc(e,{writeFileImpl:t=O}={}){await t(c(e||c(n(import.meta.url),`dist`,`public`),`.nojekyll`),``,`utf-8`)}p.argv[1]&&s.resolve(p.argv[1])===s.resolve(f(import.meta.url))&&await Yc();const Xc=n(import.meta.url);async function $(e){try{return await D(e),!0}catch{return!1}}async function Zc(e={}){let t=e.quiet??(k.env.NODE_ENV===`test`&&!k.env.VERBOSE),n=e.stdio??(k.env.NODE_ENV===`test`&&!k.env.VERBOSE?`pipe`:`inherit`),r=(...e)=>{t||console.log(...e)};async function i(e,r={}){!t&&!r.quiet&&console.log(`> ${e}`),_(e,{stdio:r.stdio??n,...r})}let a=u(e.contentRoot||h.SHADOWCLAW_CONTENT_ROOT||k.cwd()),o=u(e.toolchainRoot||Xc),s=a===o,{isProduction:l,copyAllAssets:d,prerenderPages:f,prerenderMainMemory:p}=Ba({...h,...e.isProduction===void 0?{}:{NODE_ENV:e.isProduction?`production`:`development`},...e.copyAllAssets===void 0?{}:{COPY_ALL_ASSETS:String(e.copyAllAssets)},...e.prerenderPages===void 0?{}:{PRERENDER_PAGES:String(e.prerenderPages)},...e.prerenderMainMemory===void 0?{}:{PRERENDER_MAIN_MEMORY:String(e.prerenderMainMemory)}});if(s){if(m(Xc),await Na(`dist/public`),await x(`dist/public/assets`,{recursive:!0}),d)await y(`assets`,`dist/public`,{recursive:!0});else{await y(`assets/icons`,`dist/public/assets/icons`,{recursive:!0}),await y(`assets/screenshots`,`dist/public/assets/screenshots`,{recursive:!0});try{await y(`assets/fonts`,`dist/public/assets/fonts`,{recursive:!0})}catch{}}await Pa([`pages/resources`,`pages/deps`,`resources`,`deps`,`pages/assets`,`pages/main/assets`],`dist/public`);for(let e of La())await Fa(e.sources,e.dest,e.opts||{});try{await y(`e2e/README.md`,`dist/public/e2e/README.md`)}catch{}try{await y(`pages`,`dist/public/pages`,{recursive:!0})}catch{}try{await y(`pages/main`,`dist/public/files/main`,{recursive:!0})}catch{}try{await y(`pages/main`,`dist/public/static-main`,{recursive:!0})}catch{}try{await y(`.agents/skills`,`dist/public/.agents/skills`,{recursive:!0})}catch{}try{await y(`.agents/tools`,`dist/public/.agents/tools`,{recursive:!0})}catch{}try{await y(`.agents/scripts`,`dist/public/.agents/scripts`,{recursive:!0})}catch{}if(await $(`.agents/skills`))try{let{generateSkillsIndex:e}=await import(`./chunk-C5sNnCZj.js`);await e(Xc)}catch(e){console.warn(`Notice: Failed to auto-generate agent-skills index:`,e)}if(await $(`.well-known`))try{await y(`.well-known`,`dist/public/.well-known`,{recursive:!0,force:!0})}catch{}await i(`npm run -s rolldown`)
|
|
93
|
-
`,`utf8`))}catch{}}}}catch{}if(l){r(`Running production post-build steps...`);let t=e.pagesOrigin||h.PAGES_ORIGIN,n=e.basePath||(h.PAGES_BASE_PATH??`/shadow-claw/`);if(r(` PAGES_ORIGIN : ${t||`(relative ./)`}`),r(` PAGES_BASE_PATH: ${n}`),t)try{let e=`dist/public/manifest.json`,n=await S(e,`utf8`),r=JSON.parse(n);r.start_url&&(r.start_url=t,await O(e,JSON.stringify(r,null,2),`utf8`))}catch{}try{let e=`dist/public/index.html`,t=await S(e,`utf8`);t=t.replace(/<base\s+href="[^"]*"\s*\/?>/i,`<base href="${n}" />`),await O(e,t,`utf8`)}catch{}await Yc(`dist/public`);let a=``;try{a=_(`npm run -s build:pkg:get:meta`,{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{}a&&await i(`npm run -s build:pkg:meta "${a}"`)}await
|
|
94
|
-
`,`utf8`))}catch{}}}await O(
|
|
91
|
+
`)}function Gc(e){return e.includes(`shadowClawImportScripts`)||!e.includes(`if(!self.define){`)||!e.includes(`importScripts(`)?e:`${Wc()}\n${e.replace(/importScripts\(/g,`shadowClawImportScripts(`)}`}const Kc=u(p.cwd(),`dist/public/service-worker.js`);async function qc(e=Kc,{readFileImpl:t=S,writeFileImpl:n=O,patchImpl:r=Gc,logImpl:i=console.log}={}){let a=await t(e,`utf8`),o=r(a);o!==a&&(await n(e,o,`utf8`),i(`Patched Trusted Types imports in ${e}`))}async function Jc(){await qc(p.argv[2]||Kc)}p.argv[1]&&s.resolve(p.argv[1])===s.resolve(f(import.meta.url))&&Jc().catch(e=>{console.error(e),p.exit(1)});async function Yc(e,{writeFileImpl:t=O}={}){await t(c(e||c(n(import.meta.url),`dist`,`public`),`.nojekyll`),``,`utf-8`)}p.argv[1]&&s.resolve(p.argv[1])===s.resolve(f(import.meta.url))&&await Yc();const Xc=n(import.meta.url);async function $(e){try{return await D(e),!0}catch{return!1}}async function Zc(e={}){let t=e.quiet??(k.env.NODE_ENV===`test`&&!k.env.VERBOSE),n=e.stdio??(k.env.NODE_ENV===`test`&&!k.env.VERBOSE?`pipe`:`inherit`),r=(...e)=>{t||console.log(...e)};async function i(e,r={}){!t&&!r.quiet&&console.log(`> ${e}`),_(e,{stdio:r.stdio??n,...r})}let a=u(e.contentRoot||h.SHADOWCLAW_CONTENT_ROOT||k.cwd()),o=u(e.toolchainRoot||Xc),s=a===o,{isProduction:l,copyAllAssets:d,prerenderPages:f,prerenderMainMemory:p}=Ba({...h,...e.isProduction===void 0?{}:{NODE_ENV:e.isProduction?`production`:`development`},...e.copyAllAssets===void 0?{}:{COPY_ALL_ASSETS:String(e.copyAllAssets)},...e.prerenderPages===void 0?{}:{PRERENDER_PAGES:String(e.prerenderPages)},...e.prerenderMainMemory===void 0?{}:{PRERENDER_MAIN_MEMORY:String(e.prerenderMainMemory)}});if(s){if(m(Xc),await Na(`dist/public`),await x(`dist/public/assets`,{recursive:!0}),d)await y(`assets`,`dist/public`,{recursive:!0});else{await y(`assets/icons`,`dist/public/assets/icons`,{recursive:!0}),await y(`assets/screenshots`,`dist/public/assets/screenshots`,{recursive:!0});try{await y(`assets/fonts`,`dist/public/assets/fonts`,{recursive:!0})}catch{}}await Pa([`pages/resources`,`pages/deps`,`resources`,`deps`,`pages/assets`,`pages/main/assets`],`dist/public`);for(let e of La())await Fa(e.sources,e.dest,e.opts||{});try{await y(`e2e/README.md`,`dist/public/e2e/README.md`)}catch{}try{await y(`pages`,`dist/public/pages`,{recursive:!0})}catch{}try{await y(`pages/main`,`dist/public/files/main`,{recursive:!0})}catch{}try{await y(`pages/main`,`dist/public/static-main`,{recursive:!0})}catch{}try{await y(`.agents/skills`,`dist/public/.agents/skills`,{recursive:!0})}catch{}try{await y(`.agents/tools`,`dist/public/.agents/tools`,{recursive:!0})}catch{}try{await y(`.agents/scripts`,`dist/public/.agents/scripts`,{recursive:!0})}catch{}if(await $(`.agents/skills`))try{let{generateSkillsIndex:e}=await import(`./chunk-C5sNnCZj.js`);await e(Xc)}catch(e){console.warn(`Notice: Failed to auto-generate agent-skills index:`,e)}if(await $(`.well-known`))try{await y(`.well-known`,`dist/public/.well-known`,{recursive:!0,force:!0})}catch{}await i(`npm run -s rolldown`);let t=await Ia(za())||`pages/site-config.json`;p?await pc({indexPath:`dist/public/index.html`,sourcePath:`pages/main`,prerenderPages:f,siteConfigPath:t}):await pc({indexPath:`dist/public/index.html`,noSeed:!0,siteConfigPath:t});try{await Hc(`dist/public`,t)}catch{}try{let e=JSON.parse(await S(`package.json`,`utf8`));if(e.version){let t=`dist/public/index.html`;await O(t,(await S(t,`utf8`)).replace(/<meta\s+name="version"[^>]*>/,`<meta name="version" content="${e.version}" />`),`utf8`);for(let t of[`.well-known/mcp.json`,`.well-known/mcp/server-card.json`]){let n=c(`dist/public`,t);if(await $(n))try{let t=JSON.parse(await S(n,`utf8`));t.version!==e.version&&(t.version=e.version,await O(n,JSON.stringify(t,null,2)+`
|
|
92
|
+
`,`utf8`))}catch{}}}}catch{}if(l){r(`Running production post-build steps...`);let t=e.pagesOrigin||h.PAGES_ORIGIN,n=e.basePath||(h.PAGES_BASE_PATH??`/shadow-claw/`);if(r(` PAGES_ORIGIN : ${t||`(relative ./)`}`),r(` PAGES_BASE_PATH: ${n}`),t)try{let e=`dist/public/manifest.json`,n=await S(e,`utf8`),r=JSON.parse(n);r.start_url&&(r.start_url=t,await O(e,JSON.stringify(r,null,2),`utf8`))}catch{}try{let e=`dist/public/index.html`,t=await S(e,`utf8`);t=t.replace(/<base\s+href="[^"]*"\s*\/?>/i,`<base href="${n}" />`),await O(e,t,`utf8`)}catch{}await Yc(`dist/public`);let a=``;try{a=_(`npm run -s build:pkg:get:meta`,{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{}a&&await i(`npm run -s build:pkg:meta "${a}"`)}await vc({publicDir:`dist/public`,routesPath:await Ia(Ra())||`pages/routes.json`,sourcePath:`pages/main`,prerenderPages:f,siteConfigPath:t}),await i(`npm run -s build:service-worker`);let n=`dist/public/service-worker.js`;await $(n)&&await qc(n,{logImpl:()=>{}}),r(`Build completed successfully.`);return}let g=u(a,e.outDir||`dist/public`);await x(g,{recursive:!0}),await x(c(g,`assets`),{recursive:!0});let v=c(o,`dist/public`);await $(c(v,`index.js`))||(r(`Building ShadowClaw core toolchain...`),await Na(c(o,`dist/public`)),await Na(c(o,`dist-electron`)),await i(`npm run -s rolldown`,{cwd:o})),await y(v,g,{recursive:!0,filter:e=>!(e.includes(`/assets/cache/`)||e.includes(`\\assets\\cache\\`)||e.includes(`/.cache/`)||e.includes(`\\.cache\\`))});let b=c(a,`assets`);await $(b)&&(d?await y(b,g,{recursive:!0,force:!0}):(await $(c(b,`icons`))&&await y(c(b,`icons`),c(g,`assets/icons`),{recursive:!0,force:!0}),await $(c(b,`screenshots`))&&await y(c(b,`screenshots`),c(g,`assets/screenshots`),{recursive:!0,force:!0}),await $(c(b,`fonts`))&&await y(c(b,`fonts`),c(g,`assets/fonts`),{recursive:!0,force:!0}))),await Pa([`pages/resources`,`pages/deps`,`resources`,`deps`,`pages/assets`,`pages/main/assets`],g,{baseDir:a});let C=La({contentRoot:a,toolchainRoot:o,distPublicDir:g});for(let e of C)await Fa(e.sources,e.dest,e.opts||{});let w=c(a,`pages`);await $(w)&&await y(w,c(g,`pages`),{recursive:!0,force:!0});let T=c(a,`pages/main`);await $(T)&&(await y(T,c(g,`files/main`),{recursive:!0,force:!0}),await y(T,c(g,`static-main`),{recursive:!0,force:!0}));let E=c(a,`.agents/skills`);await $(E)&&await y(E,c(g,`.agents/skills`),{recursive:!0,force:!0});let D=c(o,`.agents/skills`);a!==o&&await $(D)&&await y(D,c(g,`.agents/skills`),{recursive:!0,force:!1,errorOnExist:!1});let A=c(a,`.agents/tools`);if(await $(A))await y(A,c(g,`.agents/tools`),{recursive:!0,force:!0});else{let e=c(o,`.agents/tools`);await $(e)&&await y(e,c(g,`.agents/tools`),{recursive:!0,force:!0})}let ee=c(a,`.agents/scripts`);if(await $(ee))await y(ee,c(g,`.agents/scripts`),{recursive:!0,force:!0});else{let e=c(o,`.agents/scripts`);await $(e)&&await y(e,c(g,`.agents/scripts`),{recursive:!0,force:!0})}let te=c(o,`.well-known`);await $(te)&&await y(te,c(g,`.well-known`),{recursive:!0,force:!0});let ne=c(a,`.well-known`);if(a!==o&&await $(ne)&&await y(ne,c(g,`.well-known`),{recursive:!0,force:!0}),await $(c(g,`.agents/skills`)))try{let{generateSkillsIndex:e}=await import(`./chunk-C5sNnCZj.js`);if(await e(g,{metadataRoot:a,outDir:`.well-known/agent-skills`,toolchainRoot:o,includeBundled:!0}),await $(E))try{await e(a,{toolchainRoot:o,includeBundled:!0})}catch{}}catch(e){console.warn(`Notice: Failed to auto-generate agent-skills index:`,e)}let j=await Ia(za(a))||c(a,`pages/site-config.json`),M=c(g,`index.html`);p&&await $(T)?await pc({indexPath:M,sourcePath:T,prerenderPages:f,siteConfigPath:j}):await pc({indexPath:M,noSeed:!0,siteConfigPath:j});try{await Hc(g,j)}catch{}let N=l?e.basePath||h.PAGES_BASE_PATH||`/`:e.basePath||`/`;try{let e=await S(M,`utf8`);e=e.replace(/<base\s+href="[^"]*"\s*\/?>/i,`<base href="${N}" />`);let t=``;try{let e=await Ia([c(a,`package.json`),c(o,`package.json`)]);e&&(t=JSON.parse(await S(e,`utf8`)).version||``)}catch{}if(t){e=e.replace(/<meta\s+name="version"[^>]*>/,`<meta name="version" content="${t}" />`);for(let e of[`.well-known/mcp.json`,`.well-known/mcp/server-card.json`]){let n=c(g,e);if(await $(n))try{let e=JSON.parse(await S(n,`utf8`));e.version!==t&&(e.version=t,await O(n,JSON.stringify(e,null,2)+`
|
|
93
|
+
`,`utf8`))}catch{}}}await O(M,e,`utf8`)}catch{}if(l){r(`Running production post-build steps...`);let t=e.pagesOrigin||h.PAGES_ORIGIN;if(r(` PAGES_ORIGIN : ${t||`(relative ./)`}`),r(` PAGES_BASE_PATH: ${N}`),t)try{let e=c(g,`manifest.json`),n=await S(e,`utf8`),r=JSON.parse(n);r.start_url&&(r.start_url=t,await O(e,JSON.stringify(r,null,2),`utf8`))}catch{}await O(c(g,`.nojekyll`),``,`utf8`);let n=``;try{n=_(`git rev-parse HEAD`,{cwd:a,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{try{n=_(`git rev-parse HEAD`,{cwd:o,encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim()}catch{}}n&&await O(M,(await S(M,`utf8`)).replace(/<meta\s+name="revision"[^>]*>/,`<meta name="revision" content="${n}" />`),`utf8`)}await vc({publicDir:g,routesPath:await Ia(Ra(a))||c(a,`pages/routes.json`),sourcePath:await $(T)?T:c(o,`pages/main`),prerenderPages:f,siteConfigPath:j});let re=c(g,`service-worker.js`);await $(re)&&await qc(re,{logImpl:()=>{}}),r(`Build completed successfully.`)}k.argv[1]&&u(k.argv[1])===u(f(import.meta.url))&&Zc().catch(e=>{console.error(e),g(1)});export{Zc as t};
|