klaudius 0.23.0 → 0.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +53 -53
- package/package.json +3 -1
package/dist/bin.js
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as
|
|
3
|
-
`));let t=[];t.push(
|
|
4
|
-
`)[0]||"ok"}:{name:"pip available",status:"fail",detail:`${t.join(" ")} -m pip not runnable`,nextAction:`Add pip to your Python: \`${t.join(" ")} -m ensurepip --upgrade\` (or reinstall Python from python.org, which bundles pip).`}}async function
|
|
5
|
-
Please share that file so we can trace what happened.`);return
|
|
2
|
+
import{a as ue,b as kt,c as wt,d as pe,e as xe,f as V,h as I,j as Et,k as At,l as Re,m as Oe,o as ne,p as Pt,q as bt}from"./chunk-R2LC3ZRY.js";import{Command as ti}from"commander";import{spawn as _t}from"child_process";import{existsSync as Zn}from"fs";import{homedir as es}from"os";import S from"picocolors";import{win32 as Hn}from"path";var Un=["&","^","%","!"];function jn(e){return Un.filter(t=>e.includes(t))}function fe(e){let t=[];for(let{label:n,path:s}of e){let i=jn(s);i.length>0&&t.push({label:n,path:s,chars:i})}return t}function Fn(e){let t=(e??"").trim().replace(/^["']|["']$/g,"");if(!t||t==="undefined"||t==="null")return null;let n=t.toLowerCase().split(/[\\/]/);if(n.length<2||n.includes("system32"))return null;let s=Hn.basename(t).toLowerCase();return["pwsh","pwsh.exe","bash","bash.exe","sh","sh.exe"].includes(s)?t:null}function me(e,t){let n=Fn(e);return n===null?!1:t?t(n):!0}function he(e,t){let n=e[0],s=[...new Set(e.flatMap(u=>u.chars))],i=s.map(u=>`"${u}"`).join(", "),r=s.includes("&");return{detail:`${n.label} is "${n.path}" \u2014 the ${i} in it ${r?"breaks":"can break"} npm's package build steps (cmd.exe treats it as a command character and cuts the path)`,action:`Native-module installs ${r?"will":"may"} fail here with a misleading demand to install Visual Studio \u2014 Visual Studio is NOT needed and installing it will not fix this. Instead point npm's build steps at a shell that parses these paths correctly: PowerShell 7 (pwsh) or Git Bash, whichever is installed \u2014 npm config set script-shell "<full path to pwsh.exe or bash.exe>" (applies to all npm projects on this machine) \u2014 ${t==="preflight"?'then re-run this preflight \u2014 the "Install path safe for npm builds" check passes once script-shell is set.':t==="doctor"?"then re-run doctor \u2014 this check passes once script-shell is set.":'then re-run `npx klaudius@latest install`; `npx klaudius@latest doctor` confirms the fix (its "Install path safe for npm builds" check passes once script-shell is set).'} Windows PowerShell 5.1 ("powershell") will NOT work: it can't run the "||" in packages' install scripts. If neither shell is installed, PowerShell 7 is a small download: winget install Microsoft.PowerShell. If only the PROJECT folder is affected (not the user folder), moving the project to a plain path like C:\\klaudius also fixes it, or scope the npm setting to just this project by adding --location=project (run inside the project folder).`}}function se(){let e=process.version,t=/^v(\d+)\.(\d+)\.(\d+)/.exec(e);if(!t)return{ok:!1,message:`Could not parse the Node.js version string ("${e}"). Klaudius requires Node.js 22.15 or newer \u2014 install from https://nodejs.org/.`};let n=parseInt(t[1],10),s=parseInt(t[2],10),i=parseInt(t[3],10),r=`${n}.${s}.${i}`;return n<22||n===22&&s<15?{ok:!1,version:r,major:n,minor:s,message:`Your installed Node.js is ${r}. Klaudius requires Node.js 22.15 or newer (the dependency installer relies on the --use-system-ca flag, which was added in 22.15 to handle Windows machines where antivirus or corporate-proxy software MITMs HTTPS). Install a newer Node.js from https://nodejs.org/ \u2014 after installing, close every Terminal window, open a new one, then re-run klaudius.`}:{ok:!0,version:r,major:n,minor:s}}import{spawn as Kn}from"child_process";import{existsSync as Gn}from"fs";import{homedir as Vn}from"os";import{delimiter as Bn,join as ve}from"path";var Yn=new Set(["Restricted","AllSigned"]);function Wn(e,t=Gn){for(let n of e.split(Bn)){let s=n.replace(/"/g,"");if(!s)continue;let i=ve(s,"npx.ps1");if(t(i))return{path:i,isPs1:!0};for(let r of["npx.exe","npx.bat","npx.cmd"]){let c=ve(s,r);if(t(c))return{path:c,isPs1:!1}}}return null}async function St(){let e=Wn(process.env.PATH??"");if(!e)return{blocked:!1,npxMissing:!0};if(!e.isPs1)return{blocked:!1};let t=await zn();if(!t)return{blocked:!1,shimPath:e.path};let n=ve(Vn(),".local","node")+"\\";return{blocked:Yn.has(t),policy:t,shimPath:e.path,ownInstall:e.path.toLowerCase().startsWith(n.toLowerCase())}}async function zn(){let e=ve(process.env.SystemRoot??"C:\\Windows","System32","WindowsPowerShell","v1.0","powershell.exe");return await Tt(e)??await Tt("powershell.exe")}function Tt(e){let t={...process.env};for(let n of Object.keys(t))n.toLowerCase()==="psmodulepath"&&delete t[n];return new Promise(n=>{let s=Kn(e,["-NoProfile","-NonInteractive","-Command","Get-ExecutionPolicy"],{stdio:["ignore","pipe","pipe"],env:t}),i="",r=setTimeout(()=>{s.kill(),n(null)},8e3);s.stdout.on("data",c=>{i+=c.toString()}),s.stderr?.resume(),s.on("close",c=>{clearTimeout(r),n(c===0&&i.trim()?i.trim():null)}),s.on("error",()=>{clearTimeout(r),n(null)})})}import{spawn as qn}from"child_process";var Te=3,$e=10,Jn=[["python3"],["python"],["py","-3"]];async function z(){for(let e of Jn){let t=await Qn(e[0],[...e.slice(1),"--version"]),n=(t.stdout+t.stderr).trim();if(/Python was not found/i.test(n)||t.code!==0)continue;let s=/Python\s+(\d+)\.(\d+)(?:\.(\d+))?/.exec(n);if(!s)continue;let i=parseInt(s[1],10),r=parseInt(s[2],10),c=s[3]?`${i}.${r}.${s[3]}`:`${i}.${r}`;return{command:[...e],version:c,major:i,minor:r}}return null}async function ge(){let e=Xn(),t=await z();if(!t){let c=process.platform==="win32"?` On Windows the \`python3\` / \`python\` commands are often the Microsoft Store placeholder, not a real interpreter \u2014 install from ${e} (tick "Add python.exe to PATH"), or disable the alias under Settings \u2192 Apps \u2192 Advanced app settings \u2192 App execution aliases.`:"";return{ok:!1,message:`Python ${Te}.${$e}+ is not installed (or not on PATH). Install it from ${e}.`+c}}let{command:n,version:s,major:i,minor:r}=t;return i<Te||i===Te&&r<$e?{ok:!1,version:s,major:i,minor:r,command:n,message:`Your installed Python is ${s}. Klaudius needs Python ${Te}.${$e} or newer (the pipeline depends on packages that only ship wheels for ${Te}.${$e}+). Install a newer Python from ${e} \u2014 it lives alongside your existing Python, nothing breaks. After installing, close every Terminal window, open a new one, then re-run klaudius.`}:{ok:!0,version:s,major:i,minor:r,command:n}}function Xn(){switch(process.platform){case"win32":return"https://www.python.org/downloads/windows/";case"darwin":return"https://www.python.org/downloads/macos/";default:return"https://www.python.org/downloads/"}}function Qn(e,t){return new Promise(n=>{let s=qn(e,t,{stdio:["ignore","pipe","pipe"],shell:!1}),i="",r="";s.stdout?.on("data",c=>{i+=c.toString()}),s.stderr?.on("data",c=>{r+=c.toString()}),s.on("close",c=>n({code:c??1,stdout:i,stderr:r})),s.on("error",()=>n({code:1,stdout:i,stderr:r}))})}var It=(process.env.KLAUDIUS_API_URL??"https://klaudius.dev").replace(/\/$/,"");async function Ct(e={}){console.log(S.bold(`Klaudius preflight \u2014 checking your machine\u2026
|
|
3
|
+
`));let t=[];t.push(ts());let n=await ge();if(t.push(ns(n)),t.push(await ss(n.command)),t.push(await os()),process.platform==="win32"){let i=await is();i&&t.push(i);let r=await as();r&&t.push(r)}t.push(await rs());for(let i of t){let r=i.status==="ok"?S.green("\u2713"):i.status==="warn"?S.yellow("!"):S.red("\u2717");console.log(` ${r} ${i.name}${i.detail?S.dim(` \u2014 ${i.detail}`):""}`),i.nextAction&&console.log(` ${S.dim("\u2192")} ${S.cyan(i.nextAction)}`)}console.log();let s=t.filter(i=>i.status==="fail");if(s.length===0){let i=t.filter(r=>r.status==="warn").length;ls(i);return}console.log(S.red(S.bold(`${s.length} check${s.length===1?"":"s"} failed \u2014 fix the \u2192 items above, then re-run \`npx klaudius@latest preflight\`.`))),console.log(),console.log(S.dim(" AI assistant: install or upgrade whatever's marked \u2717 above for the")),console.log(S.dim(" user, then re-run `npx klaudius@latest preflight` until every check passes.")),console.log(),process.exitCode=1}function ts(){let e=se();return e.ok?{name:"Node.js \u2265 22.15",status:"ok",detail:e.version}:{name:"Node.js \u2265 22.15",status:"fail",detail:e.version??"not detected",nextAction:"Install Node.js 22.15+ from https://nodejs.org/ \u2014 then open a NEW terminal before re-running."}}function ns(e){return e.ok?{name:"Python \u2265 3.10",status:"ok",detail:e.version}:{name:"Python \u2265 3.10",status:"fail",detail:e.version??"not found",nextAction:e.message??"Install Python 3.10+ from https://www.python.org/downloads/"}}async function ss(e){let t=e??["python3"],n=await Ne(t[0],[...t.slice(1),"-m","pip","--version"]);return n.code===0?{name:"pip available",status:"ok",detail:(n.stdout||n.stderr).trim().split(`
|
|
4
|
+
`)[0]||"ok"}:{name:"pip available",status:"fail",detail:`${t.join(" ")} -m pip not runnable`,nextAction:`Add pip to your Python: \`${t.join(" ")} -m ensurepip --upgrade\` (or reinstall Python from python.org, which bundles pip).`}}async function os(){let e=process.platform==="win32",t=await Ne("npm",["--version"],e);return t.code!==0?{name:"npm / npx available",status:"fail",detail:"npm not found",nextAction:"npm ships with Node.js \u2014 reinstall Node from https://nodejs.org/."}:(await Ne("npx",["--version"],e)).code!==0?{name:"npm / npx available",status:"fail",detail:`npm ${t.stdout.trim()} ok, npx missing`,nextAction:"npx ships with npm 5.2+ \u2014 reinstall Node from https://nodejs.org/."}:{name:"npm / npx available",status:"ok",detail:`npm ${t.stdout.trim()}`}}async function is(){let e=await St();if(e.npxMissing)return null;let t="npx runs in PowerShell";if(!e.blocked){let n="resolves to a policy-immune shim";return e.shimPath&&(n=e.policy?`ExecutionPolicy ${e.policy} allows the npx.ps1 shim`:"npx.ps1 shim present but ExecutionPolicy unreadable \u2014 assuming it runs"),{name:t,status:"ok",detail:n}}return{name:t,status:"fail",detail:`ExecutionPolicy ${e.policy} blocks ${e.shimPath}, which PowerShell prefers over npx.cmd`,nextAction:e.ownInstall?`In PowerShell run: Remove-Item "$env:USERPROFILE\\.local\\node\\np*.ps1" \u2014 it deletes only the PowerShell shims from Klaudius's own Node install (npx falls back to npx.cmd). It prints nothing back; that means it worked. Then re-run this preflight.`:"In Windows PowerShell (the classic blue one, not PowerShell 7) run: Set-ExecutionPolicy -Scope CurrentUser RemoteSigned \u2014 printing nothing back means it worked; confirm with Get-ExecutionPolicy (should say RemoteSigned), then re-run this preflight. If it prints an error instead, your organisation manages this setting \u2014 ask IT."}}async function as(){let e=fe([{label:"your Windows user folder",path:es()},{label:"this folder",path:process.cwd()}]);if(e.length===0)return null;let t="Install path safe for npm builds",n=await Ne("npm",["config","get","script-shell"],!0),s=n.code===0?n.stdout.trim():void 0;if(me(s,Zn))return{name:t,status:"ok",detail:`${e[0].label} contains ${e[0].chars.map(l=>`"${l}"`).join(", ")}, but npm's script-shell (${s}) handles it`};let{detail:i,action:r}=he(e,"preflight"),c=e.some(l=>l.chars.includes("&"));return{name:t,status:c?"fail":"warn",detail:i,nextAction:r}}async function rs(){try{return await fetch(It,{method:"HEAD",signal:AbortSignal.timeout(8e3)}),{name:"klaudius.dev reachable",status:"ok",detail:It}}catch(e){return{name:"klaudius.dev reachable",status:"fail",detail:e.name==="TimeoutError"?"timed out":"could not connect",nextAction:"Check your internet connection, VPN, or firewall \u2014 init needs klaudius.dev to validate your license and download the template."}}}function ls(e=0){e>0?console.log(S.green(S.bold("Your machine is ready."))+S.yellow(` (${e} warning${e===1?"":"s"} above \u2014 worth a look, but nothing is blocked.)`)):console.log(S.green(S.bold("All checks passed \u2014 your machine is ready."))),console.log(),console.log(S.bold("NEXT STEP \u2014 this one is for you to run, not the AI assistant:")),console.log(" It's an interactive wizard (it asks for your license key and passwords),"),console.log(" so the assistant can't fill it in. Open a NEW terminal tab and run:"),console.log(),console.log(` ${S.cyan("npx klaudius@latest init my-agency")}`),console.log(),console.log(S.dim(" AI assistant: stop here. Do not run init yourself \u2014 tell the user to")),console.log(S.dim(" run it in a new terminal.")),console.log()}function Ne(e,t,n=!1){return new Promise(s=>{let i=n?_t([e,...t].join(" "),{stdio:["ignore","pipe","pipe"],shell:!0}):_t(e,t,{stdio:["ignore","pipe","pipe"],shell:!1}),r="",c="";i.stdout?.on("data",l=>{r+=l.toString()}),i.stderr?.on("data",l=>{c+=l.toString()}),i.on("close",l=>s({code:l??1,stdout:r,stderr:c})),i.on("error",()=>s({code:1,stdout:r,stderr:c}))})}import{mkdir as lt,readdir as kn,readFile as hn,stat as ct,writeFile as rt}from"fs/promises";import{spawnSync as dt}from"child_process";import{homedir as uo}from"os";import{resolve as po,isAbsolute as fo,join as B,normalize as mo}from"path";import*as E from"@clack/prompts";import p from"picocolors";import cs from"react";import{render as ds}from"ink";async function O(e={},t={}){if(!process.stdin.isTTY)throw new Error("Klaudius's interactive wizard requires a terminal (TTY). Run `npx klaudius@latest init` directly from your terminal \u2014 not through a pipe, file redirect, or non-interactive shell context.");let{WizardApp:n}=await import("./WizardApp-KO7MOXCQ.js"),s=null;ue("runWizard:start",{onlySection:t.onlySection,hasDefaults:Object.keys(e).length>0}),wt(),await new Promise(r=>setImmediate(r)),await new Promise(r=>setTimeout(r,0)),ue("runWizard:event loop drained, mounting Ink");let i=ds(cs.createElement(n,{defaults:e,onlySection:t.onlySection,banner:t.banner,onComplete:r=>{ue("runWizard:onComplete called",{keys:Object.keys(r).length}),s=r}}),{stdout:process.stdout,stderr:process.stderr,stdin:process.stdin,exitOnCtrlC:!1});if(ue("runWizard:render returned, awaiting exit"),await i.waitUntilExit(),ue("runWizard:waitUntilExit resolved",{resultIsNull:s===null}),!s)throw new Error(`Wizard exited without completing. Diagnostic log: ${kt}
|
|
5
|
+
Please share that file so we can trace what happened.`);return s}var nt="claude-code";function xt(e){if(e==="claude-code"||e==="codex")return e}var st="vercel";function Rt(e){if(e==="vercel"||e==="cloudflare"||e==="netlify"||e==="selfhost")return e}function Ot(e){if(e==="telegram"||e==="email"||e==="sms")return e}function vt(e){if(e==="password"||e==="oauth-microsoft")return e}function us(e){if(e==="custom"||e!==void 0&&Object.hasOwn(V,e))return e}function Le(e){let t=us(e.EMAIL_PROVIDER);if(t)return t;let n=e.EMAIL_SMTP_HOST;if(n){for(let[s,i]of Object.entries(V))if(i.smtpHost===n)return s;return"custom"}}function Me(e){let t=[],n=r=>{t.push(""),t.push("# "+"=".repeat(60)),t.push(`# ${r}`),t.push("# "+"=".repeat(60)),t.push("")},s=(r,c)=>{if(c==null||c===""){t.push(`# ${r}=`);return}let l=String(c);if(/[\s"'`$\\#&|<>;()*?\[\]{}!~]/.test(l)){let d=l.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\$/g,"\\$").replace(/`/g,"\\`");t.push(`${r}="${d}"`)}else t.push(`${r}=${l}`)};t.push("# Klaudius configuration"),t.push("# Generated by `npx klaudius init`. Edit freely."),t.push("# NEVER commit this file. .gitignore already excludes it."),n("Klaudius licence"),s("KLAUDIUS_LICENSE_KEY",e.licenseKey),n("AI coding agent"),s("AI_AGENT",e.aiAgent??nt),n("Operating country and language"),s("OPERATOR_COUNTRY",e.country),s("OPERATOR_COUNTRY_CODE",e.countryCode),s("OPERATOR_LANGUAGE",e.language),s("OPERATOR_LANGUAGE_CODE",e.languageCode),n("Pipeline modes");let i=e.pipelineModes&&e.pipelineModes.length>0?e.pipelineModes:["classic"];return s("PIPELINE_MODES",[...new Set(["classic",...i])].join(",")),n("Pricing"),s("PRICING",e.pricing),s("PRICING_TERMS",e.pricingTerms),s("PRICING_MONTHLY",e.pricingMonthly),n("Automated outreach features"),s("OUTREACH_ENABLED",e.outreachEnabled?"true":"false"),s("OPERATOR_NAME",e.name),s("SIGNATURE",e.signature),s("OUTREACH_CHANNELS",e.outreachChannels?.join(",")),s("OUTREACH_PRIORITY",e.outreachPriority?.join(",")),n("Email outreach"),s("EMAIL_PROVIDER",e.emailProvider),s("EMAIL_AUTH",e.emailAuth??"password"),s("EMAIL_ADDRESS",e.emailAddress),s("EMAIL_PASSWORD",e.emailPassword),s("EMAIL_FROM_NAME",e.emailFromName),s("EMAIL_SMTP_HOST",e.emailSmtpHost),s("EMAIL_SMTP_PORT",e.emailSmtpPort),s("EMAIL_IMAP_HOST",e.emailImapHost),s("EMAIL_IMAP_PORT",e.emailImapPort),s("EMAIL_SENT_FOLDER",e.emailSentFolder),s("EMAIL_INBOX_FOLDER",e.emailInboxFolder),n("SMS outreach"),s("SMS_PROVIDER",e.smsProvider),s("TEST_PHONE",e.testPhone),s("TWILIO_ACCOUNT_SID",e.twilioAccountSid),s("TWILIO_AUTH_TOKEN",e.twilioAuthToken),s("TWILIO_PHONE_NUMBER",e.twilioPhoneNumber),n("WhatsApp outreach"),s("WHATSAPP_ACCOUNTS",e.whatsappAccounts?.join(",")),n("Supabase (pipeline state)"),s("SUPABASE_URL",e.supabaseUrl),s("SUPABASE_SERVICE_KEY",e.supabaseServiceKey),s("SUPABASE_PAT",e.supabasePat),s("SUPABASE_PROJECT_REF",e.supabaseProjectRef),n("Deployment"),s("DEPLOY_PROVIDER",e.deployProvider??st),s("VERCEL_TOKEN",e.vercelToken),s("VERCEL_SCOPE",e.vercelScope??""),s("CLOUDFLARE_API_TOKEN",e.cloudflareApiToken),s("CLOUDFLARE_ACCOUNT_ID",e.cloudflareAccountId),s("NETLIFY_AUTH_TOKEN",e.netlifyAuthToken),s("NETLIFY_ACCOUNT_SLUG",e.netlifyAccountSlug??""),s("SELFHOST_DEPLOY_TARGET",e.selfhostDeployTarget),s("SELFHOST_URL_TEMPLATE",e.selfhostUrlTemplate),n("Search APIs"),s("GOOGLE_PLACES_API_KEY",e.googlePlacesApiKey),n("Notifications (optional)"),s("NOTIFY_CHANNEL",e.notifyChannel),s("NOTIFY_TO",e.notifyTo),s("TELEGRAM_BOT_TOKEN",e.telegramBotToken),s("TELEGRAM_CHAT_ID",e.telegramChatId),t.join(`
|
|
6
6
|
`)+`
|
|
7
|
-
`}function
|
|
8
|
-
`}function
|
|
9
|
-
`)}function
|
|
7
|
+
`}function De(e){let t={mcpServers:{supabase:{command:"npx",args:["-y","@supabase/mcp-server-supabase@latest",`--project-ref=${e.supabaseProjectRef}`],env:{SUPABASE_ACCESS_TOKEN:e.supabasePat,NODE_OPTIONS:"--use-system-ca"}}}};return JSON.stringify(t,null,2)+`
|
|
8
|
+
`}function He(e){let t=e.supabaseProjectRef,n=ps(e.supabasePat);return["# Codex MCP config \u2014 generated by `npx klaudius init` / `configure`.","# Edit freely. NEVER commit this file \u2014 .gitignore already excludes it.","# See `.codex/config.toml.example` for the documented format.","","[mcp_servers.supabase]",'command = "npx"',`args = ["-y", "@supabase/mcp-server-supabase@latest", "--project-ref=${t}"]`,`env = { SUPABASE_ACCESS_TOKEN = "${n}", NODE_OPTIONS = "--use-system-ca" }`,""].join(`
|
|
9
|
+
`)}function ps(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}var $t=[{key:"AI_AGENT",value:"claude-code",comment:"Which AI coding agent drives this install. Pre-codex installs were Claude Code by default \u2014 this records that explicitly so `update` re-fetches the matching template tarball and `doctor` checks the right CLI."},{key:"PRICING_TERMS",value:"one-off, no monthly fees",comment:"Phrasing slotted next to ${PRICING} in outreach copy. See template/CLAUDE.md."},{key:"VERCEL_SCOPE",value:"",comment:"Vercel team slug. Leave blank unless `vercel link` errors about scope (post-2024 multi-team Vercel accounts)."},{key:"DEPLOY_PROVIDER",value:"vercel",comment:"Where the deploy skill ships client sites: 'vercel', 'cloudflare', or 'netlify'. Pre-Cloudflare installs deployed to Vercel, so this records that explicitly. To switch host, run `npx klaudius@latest configure` (Cloudflare adds CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID; Netlify adds NETLIFY_AUTH_TOKEN)."},{key:"PIPELINE_MODES",value:"classic",comment:"Lead streams the pipeline targets. Pre-modes installs targeted no-website businesses only ('classic') \u2014 this records that explicitly. Change to 'classic,rescue' to ALSO target businesses whose existing website is verifiably dead or bad (Rescue mode), or re-run `npx klaudius@latest configure`."},{key:"OPERATOR_COUNTRY",value:"the United Kingdom",comment:"Operating country (canonical full name). Used as the default region for /find."},{key:"OPERATOR_COUNTRY_CODE",value:"GB",comment:"ISO 3166-1 alpha-2 code. Passed to the Google Places API for region biasing."},{key:"OPERATOR_LANGUAGE",value:"English",comment:"Language all outreach + websites are written in."},{key:"OPERATOR_LANGUAGE_CODE",value:"en",comment:'ISO 639-1 code. Used by Google Places + <html lang="..."> on built sites.'},{key:"NOTIFY_CHANNEL",value:"telegram",comment:"How scripts/notify.sh routes pipeline alerts: 'telegram' (default), 'email' (to your own inbox), or 'sms' (to your own phone). Pre-NOTIFY_CHANNEL installs alerted via Telegram, so this records that explicitly. NOTIFY_TO optionally overrides the email/sms destination."}];function fs(e,t){if(/[\s"'`$\\#&|<>;()*?\[\]{}!~]/.test(t)){let n=t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\$/g,"\\$").replace(/`/g,"\\`");return`${e}="${n}"`}return`${e}=${t}`}function Nt(e,t,n){let s=n.filter(c=>!(c.key in t));if(s.length===0)return null;let i=e.endsWith(`
|
|
10
10
|
`)?"":`
|
|
11
|
-
`,
|
|
11
|
+
`,r=["","# "+"=".repeat(60),"# Backfilled by `klaudius update` (new template env keys)","# "+"=".repeat(60)];for(let c of s)r.push(""),c.comment&&r.push(`# ${c.comment}`),r.push(fs(c.key,c.value));return e+i+r.join(`
|
|
12
12
|
`)+`
|
|
13
|
-
`}function
|
|
14
|
-
`)){let
|
|
15
|
-
`,"utf-8")}function
|
|
16
|
-
`+oe.bold(oe.cyan(e))),detail:e=>console.log(oe.dim(" "+e))};var
|
|
17
|
-
`)};try{let
|
|
13
|
+
`}function ms(e){return e.length>=2&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1).replace(/\\\\/g,"\\").replace(/\\"/g,'"').replace(/\\\$/g,"$").replace(/\\`/g,"`"):e.length>=2&&e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function G(e){let t={};for(let n of e.split(`
|
|
14
|
+
`)){let s=n.trim();if(!s||s.startsWith("#"))continue;let i=s.indexOf("=");if(i===-1)continue;let r=s.slice(0,i).trim(),c=ms(s.slice(i+1).trim());t[r]=c}return t}function Lt(e){let t=l=>{let d=e[l];if(!d)return;let u=parseInt(d,10);return isNaN(u)?void 0:u},n=e.SMS_PROVIDER,s=l=>l==="email"||l==="sms"||l==="whatsapp",i=e.OUTREACH_CHANNELS?.split(",").map(l=>l.trim()).filter(s),r=e.OUTREACH_PRIORITY?.split(",").map(l=>l.trim()).filter(s),c=e.WHATSAPP_ACCOUNTS?.split(",").map(l=>l.trim()).filter(l=>l.length>0);return{licenseKey:e.KLAUDIUS_LICENSE_KEY,aiAgent:xt(e.AI_AGENT)??nt,country:e.OPERATOR_COUNTRY||void 0,countryCode:e.OPERATOR_COUNTRY_CODE||void 0,language:e.OPERATOR_LANGUAGE||void 0,languageCode:e.OPERATOR_LANGUAGE_CODE||void 0,pipelineModes:e.PIPELINE_MODES?e.PIPELINE_MODES.split(",").map(l=>l.trim().toLowerCase()).filter(Boolean):void 0,pricing:e.PRICING,pricingTerms:e.PRICING_TERMS,pricingMonthly:e.PRICING_MONTHLY||void 0,outreachEnabled:e.OUTREACH_ENABLED?e.OUTREACH_ENABLED.toLowerCase()==="true":void 0,name:e.OPERATOR_NAME,signature:e.SIGNATURE,outreachChannels:i&&i.length>0?i:void 0,outreachPriority:r&&r.length>0?r:void 0,whatsappAccounts:c&&c.length>0?c:void 0,emailProvider:Le(e),emailAuth:vt(e.EMAIL_AUTH),emailAddress:e.EMAIL_ADDRESS,emailFromName:e.EMAIL_FROM_NAME,emailSmtpHost:e.EMAIL_SMTP_HOST,emailSmtpPort:t("EMAIL_SMTP_PORT"),emailImapHost:e.EMAIL_IMAP_HOST,emailImapPort:t("EMAIL_IMAP_PORT"),emailSentFolder:e.EMAIL_SENT_FOLDER,emailInboxFolder:e.EMAIL_INBOX_FOLDER,smsProvider:n==="imessage"||n==="twilio"?n:void 0,testPhone:e.TEST_PHONE,twilioAccountSid:e.TWILIO_ACCOUNT_SID,twilioPhoneNumber:e.TWILIO_PHONE_NUMBER,twilioAuthToken:e.TWILIO_AUTH_TOKEN,supabaseUrl:e.SUPABASE_URL,supabaseProjectRef:e.SUPABASE_PROJECT_REF,supabaseServiceKey:e.SUPABASE_SERVICE_KEY,supabasePat:e.SUPABASE_PAT,deployProvider:Rt(e.DEPLOY_PROVIDER)??st,vercelToken:e.VERCEL_TOKEN,vercelScope:e.VERCEL_SCOPE||void 0,cloudflareApiToken:e.CLOUDFLARE_API_TOKEN||void 0,cloudflareAccountId:e.CLOUDFLARE_ACCOUNT_ID||void 0,netlifyAuthToken:e.NETLIFY_AUTH_TOKEN||void 0,netlifyAccountSlug:e.NETLIFY_ACCOUNT_SLUG||void 0,selfhostDeployTarget:e.SELFHOST_DEPLOY_TARGET||void 0,selfhostUrlTemplate:e.SELFHOST_URL_TEMPLATE||void 0,googlePlacesApiKey:e.GOOGLE_PLACES_API_KEY,emailPassword:e.EMAIL_PASSWORD,notifyChannel:Ot(e.NOTIFY_CHANNEL),notifyTo:e.NOTIFY_TO||void 0,telegramBotToken:e.TELEGRAM_BOT_TOKEN,telegramChatId:e.TELEGRAM_CHAT_ID}}function ot(e){let t=P=>{let X=e[P];if(!X)return;let w=parseInt(X,10);return isNaN(w)?void 0:w},n=e.SUPABASE_URL,s=e.SUPABASE_SERVICE_KEY?.replace(/\s+/g,""),i=e.SUPABASE_PAT?.replace(/\s+/g,""),r=e.SUPABASE_PROJECT_REF,c=e.PRICING,l=e.PRICING_TERMS||"one-off, no monthly fees",d=Rt(e.DEPLOY_PROVIDER)??st,u=e.VERCEL_TOKEN,a=e.CLOUDFLARE_API_TOKEN,y=e.CLOUDFLARE_ACCOUNT_ID,g=e.NETLIFY_AUTH_TOKEN,k=e.SELFHOST_DEPLOY_TARGET,b=e.SELFHOST_URL_TEMPLATE;if(!c||!n||!s||!i||!r||!(d==="cloudflare"?!!a&&!!y:d==="netlify"?!!g:d==="selfhost"?!!k&&!!b:!!u))return null;let C=e.SMS_PROVIDER,v=P=>P==="email"||P==="sms"||P==="whatsapp",T=e.OUTREACH_CHANNELS?.split(",").map(P=>P.trim()).filter(v),M=e.OUTREACH_PRIORITY?.split(",").map(P=>P.trim()).filter(v),J=e.WHATSAPP_ACCOUNTS?.split(",").map(P=>P.trim()).filter(P=>P.length>0);return{licenseKey:e.KLAUDIUS_LICENSE_KEY,aiAgent:xt(e.AI_AGENT)??nt,country:e.OPERATOR_COUNTRY||void 0,countryCode:e.OPERATOR_COUNTRY_CODE||void 0,language:e.OPERATOR_LANGUAGE||void 0,languageCode:e.OPERATOR_LANGUAGE_CODE||void 0,pipelineModes:e.PIPELINE_MODES?e.PIPELINE_MODES.split(",").map(P=>P.trim().toLowerCase()).filter(Boolean):void 0,pricing:c,pricingTerms:l,pricingMonthly:e.PRICING_MONTHLY||void 0,outreachEnabled:e.OUTREACH_ENABLED?.toLowerCase()==="true",name:e.OPERATOR_NAME,signature:e.SIGNATURE,outreachChannels:T&&T.length>0?T:void 0,outreachPriority:M&&M.length>0?M:void 0,whatsappAccounts:J&&J.length>0?J:void 0,emailProvider:Le(e),emailAuth:vt(e.EMAIL_AUTH),emailAddress:e.EMAIL_ADDRESS,emailPassword:e.EMAIL_PASSWORD,emailFromName:e.EMAIL_FROM_NAME,emailSmtpHost:e.EMAIL_SMTP_HOST,emailSmtpPort:t("EMAIL_SMTP_PORT"),emailImapHost:e.EMAIL_IMAP_HOST,emailImapPort:t("EMAIL_IMAP_PORT"),emailSentFolder:e.EMAIL_SENT_FOLDER,emailInboxFolder:e.EMAIL_INBOX_FOLDER,smsProvider:C==="imessage"||C==="twilio"?C:void 0,testPhone:e.TEST_PHONE,twilioAccountSid:e.TWILIO_ACCOUNT_SID,twilioAuthToken:e.TWILIO_AUTH_TOKEN,twilioPhoneNumber:e.TWILIO_PHONE_NUMBER,deployProvider:d,vercelToken:u,vercelScope:e.VERCEL_SCOPE||void 0,cloudflareApiToken:a||void 0,cloudflareAccountId:y||void 0,netlifyAuthToken:g||void 0,netlifyAccountSlug:e.NETLIFY_ACCOUNT_SLUG||void 0,selfhostDeployTarget:k||void 0,selfhostUrlTemplate:b||void 0,supabaseUrl:n,supabaseServiceKey:s,supabasePat:i,supabaseProjectRef:r,googlePlacesApiKey:e.GOOGLE_PLACES_API_KEY,notifyChannel:Ot(e.NOTIFY_CHANNEL),notifyTo:e.NOTIFY_TO||void 0,telegramBotToken:e.TELEGRAM_BOT_TOKEN,telegramChatId:e.TELEGRAM_CHAT_ID}}import{copyFile as Li,mkdir as Mi,readdir as Ps,stat as Di}from"fs/promises";import{dirname as Ui,join as Gt,relative as bs,sep as Ts}from"path";import{fileURLToPath as Fi}from"url";import{createHash as Mt}from"crypto";import{readFile as hs}from"fs/promises";async function ye(e){let t=await hs(e);return Mt("sha256").update(t).digest("hex")}function Dt(e){return Mt("sha256").update(e).digest("hex")}import{mkdir as gs,readFile as ys,writeFile as ks,access as ws}from"fs/promises";import{dirname as Es,join as Ht}from"path";var As=".klaudius",Ut=`${As}/manifest.json`,Ue=new Set([".env",".mcp.json",".claude/settings.json",".codex/config.toml",".ms-token.json"]),jt=new Set(["clients/README.md"]);async function Ft(e){let t=Ht(e,Ut);try{await ws(t)}catch{return null}let n=await ys(t,"utf-8"),s=JSON.parse(n),i={};for(let[r,c]of Object.entries(s.files??{}))i[r.split("\\").join("/")]=c;return s.files=i,Array.isArray(s.ignored)?s.ignored=s.ignored.filter(r=>typeof r=="string").map(r=>r.split("\\").join("/")):delete s.ignored,s}async function je(e,t){let n=Ht(e,Ut);await gs(Es(n),{recursive:!0}),await ks(n,JSON.stringify(t,null,2)+`
|
|
15
|
+
`,"utf-8")}function Kt(e,t){let n=new Date().toISOString();return{version:1,templateVersion:e,installedAt:n,updatedAt:n,files:t}}async function ce(e,t=e){let n=await Ps(e,{withFileTypes:!0}),s=[];for(let i of n){let r=Gt(e,i.name);i.name===".klaudius"&&e===t||(i.isDirectory()?s.push(...await ce(r,t)):i.isFile()&&s.push(bs(t,r).split(Ts).join("/")))}return s}async function Vt(e){let t=await ce(e),n={};for(let s of t)Ue.has(s)||(n[s]=await ye(Gt(e,s)));return n}import{copyFile as Ss,mkdir as Bt,mkdtemp as _s,readdir as Yt,rm as Wt}from"fs/promises";import{tmpdir as Is}from"os";import{dirname as Cs,join as Fe}from"path";import{Readable as xs}from"stream";import*as zt from"tar";var Rs="https://klaudius.dev/api/template";function Os(e){return xs.fromWeb(e)}async function Ke(e){let t=process.env.KLAUDIUS_TEMPLATE_URL??Rs,n="0.23.2",s;try{s=await fetch(t,{method:"POST",headers:{Authorization:`Bearer ${e.licenseKey}`,"Content-Type":"application/json"},body:JSON.stringify({machine_id:e.machineId,hostname:e.hostname,os:e.os,cli_version:n,...e.agent==="codex"?{agent:"codex"}:{}})})}catch(l){throw new Error(`Could not reach klaudius.dev to download the template: ${I(l)}`)}if(!s.ok){let l="";try{let d=await s.json();l=d.reason?` (${d.reason})`:""}catch{}throw new Error(`Template download failed: HTTP ${s.status}${l}`)}if(!s.body)throw new Error("Template download succeeded but response had no body");let i=s.headers.get("x-klaudius-tier"),r=await _s(Fe(Is(),"klaudius-template-")),c=0;try{try{await new Promise((u,a)=>{let y=zt.extract({cwd:r,strict:!0});y.on("finish",u),y.on("error",a),Os(s.body).on("error",a).pipe(y)})}catch(u){throw new Error(`Failed to extract template archive: ${u.message}`)}await Bt(e.destDir,{recursive:!0});let l=new Set(await Yt(e.destDir)),d=await ce(r);try{for(let u of d){let a=Fe(e.destDir,u);await Bt(Cs(a),{recursive:!0}),await Ss(Fe(r,u),a),c++}}catch(u){let a=await Yt(e.destDir).catch(()=>[]);for(let y of a)l.has(y)||await Wt(Fe(e.destDir,y),{recursive:!0,force:!0}).catch(()=>{});throw new Error(`Downloaded the template but couldn't copy it into ${e.destDir}: ${u.message}`)}}finally{await Wt(r,{recursive:!0,force:!0}).catch(()=>{})}return{filesExtracted:c,tier:i}}import{copyFile as vs,mkdir as $s,readFile as Ns,rm as Ls}from"fs/promises";import{dirname as Ms,join as Se}from"path";import{structuredPatch as Ds}from"diff";var qt=Se(".klaudius","base");async function Ge(e,t,n){let s=Se(e,qt);await Ls(s,{recursive:!0,force:!0});for(let i of n){let r=Se(s,i);await $s(Ms(r),{recursive:!0}),await vs(Se(t,i),r)}}async function Jt(e,t){try{return await Ns(Se(e,qt,t),"utf-8")}catch{return null}}function it(e){return e.includes("\0")||e.includes("\uFFFD")}function Xt(e,t,n=60){let s=Ds("base","new",e,t,"","",{context:2});if(s.hunks.length===0)return["Upstream content is identical to your base for this file."];let i=s.hunks.map(d=>`${d.newStart}-${d.newStart+Math.max(d.newLines-1,0)}`).join(", "),r=[`Upstream changed ${s.hunks.length} hunk(s) (new-version lines ${i}):`,"","```diff"],c=0,l=!1;for(let d of s.hunks){if(c>=n){l=!0;break}r.push(`@@ -${d.oldStart},${d.oldLines} +${d.newStart},${d.newLines} @@`),c+=1;let u=Math.max(n-c,0),a=d.lines.slice(0,u);if(r.push(...a),c+=a.length,a.length<d.lines.length){l=!0;break}}return r.push("```"),l&&r.push(`_\u2026truncated at ${n} diff lines. The full new version is staged in \`.klaudius/incoming/\` for a complete compare._`),r}import oe from"picocolors";var o={info:e=>console.log(oe.cyan("\u2139"),e),success:e=>console.log(oe.green("\u2713"),e),warn:e=>console.log(oe.yellow("\u26A0"),e),error:e=>console.error(oe.red("\u2717"),e),step:e=>console.log(oe.dim("\u2192"),e),blank:()=>console.log(""),heading:e=>console.log(`
|
|
16
|
+
`+oe.bold(oe.cyan(e))),detail:e=>console.log(oe.dim(" "+e))};var Hs="https://registry.npmjs.org/klaudius/latest";async function Us(e=1500){let t=new AbortController,n=setTimeout(()=>t.abort(),e);try{let s=await fetch(Hs,{signal:t.signal,headers:{accept:"application/json"}});if(!s.ok)return null;let i=await s.json();return typeof i.version=="string"?i.version:null}catch{return null}finally{clearTimeout(n)}}function js(e,t){let n=r=>r.split("-")[0].split(".").map(c=>Number.parseInt(c,10)),s=n(e),i=n(t);if(s.length<3||i.length<3)return!1;for(let r=0;r<3;r++){if(Number.isNaN(s[r])||Number.isNaN(i[r]))return!1;if(s[r]>i[r])return!0;if(s[r]<i[r])return!1}return!1}async function Ve(e,t){if(t==="dev"||process.env.CI||process.env.NO_UPDATE_NOTIFIER)return;let n=await Us();!n||!js(n,t)||(o.blank(),o.warn(`A newer Klaudius CLI is available: you have ${t}, latest is ${n}.`),e==="update"&&(o.detail("Your project content is fetched fresh either way, so you're not missing any"),o.detail("pipeline updates. But the CLI itself, including its update logic, is behind.")),o.detail(`Re-run with \`npx klaudius@latest ${e}\` to use the latest CLI.`),o.blank())}import{createHash as Fs}from"crypto";import{hostname as Qt,userInfo as Ks,platform as Zt,arch as en}from"os";var Gs="https://klaudius.dev",Vs="/api/licenses/validate",Bs="0.23.2";async function tn(e){if(!e||e.trim().length===0)return{ok:!1,reason:"No license key provided. Pass one via --license <key> or paste it when prompted."};let t=e.trim(),s=(process.env.KLAUDIUS_API_URL??Gs).replace(/\/$/,"")+Vs,i=_e(),r;try{r=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({license_key:t,machine_id:i,hostname:Qt(),os:`${Zt()}-${en()}`,cli_version:Bs})})}catch(l){return{ok:!1,reason:`Could not reach the Klaudius license server (${I(l)}). Check your internet connection or try again later.`}}let c;try{c=await r.json()}catch{return{ok:!1,reason:`License server returned an unparseable response (HTTP ${r.status}).`}}return c.ok?{ok:!0,tier:c.tier??"core"}:{ok:!1,reason:c.reason??`License rejected (HTTP ${r.status}).`}}function _e(){let e=[Qt(),Ks().username,Zt(),en()].join("|");return Fs("sha256").update(e).digest("hex").slice(0,32)}import{readFile as Ys}from"fs/promises";import{join as Ws}from"path";async function ke(e){let t=e.serviceKey.replace(/\s+/g,"");try{let n=await fetch(e.url+"/rest/v1/",{headers:{apikey:t,Authorization:`Bearer ${t}`}});return n.status===401||n.status===403?{ok:!1,message:`Supabase rejected auth (HTTP ${n.status}). Check SUPABASE_SERVICE_KEY.`}:{ok:!0}}catch(n){return{ok:!1,message:`Could not reach Supabase: ${I(n)}`}}}async function nn(e){let t;try{t=await Ys(Ws(e.projectRoot,"scripts","schema.sql"),"utf-8")}catch(s){return{ok:!1,message:`Could not read scripts/schema.sql: ${s.message}`}}let n=e.pat.replace(/\s+/g,"");try{let s=await fetch(`https://api.supabase.com/v1/projects/${e.projectRef}/database/query`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({query:t})});if(s.ok)return{ok:!0};let i=await s.text();return i.includes("already exists")||i.includes('relation "clients" already exists')||i.includes("duplicate")?(o.detail("Schema appears already applied (tables exist). Skipping."),{ok:!0}):{ok:!1,message:`Supabase Management API rejected schema (HTTP ${s.status}): ${i.slice(0,300)}`}}catch(s){return{ok:!1,message:`Schema apply failed: ${s.message}`}}}async function Be(e){try{let t=await fetch("https://api.vercel.com/v2/user",{headers:{Authorization:`Bearer ${e}`}});if(t.status===401||t.status===403)return{ok:!1,message:`Vercel rejected the token (HTTP ${t.status}). The token is invalid, expired, or has been revoked.`};if(!t.ok)return{ok:!1,message:`Vercel API returned HTTP ${t.status}. Try again or check status.vercel.com.`};let n=await t.json();return{ok:!0,username:n.user?.username??n.user?.email}}catch(t){return{ok:!1,message:`Could not reach Vercel: ${I(t)}`}}}var sn="https://api.cloudflare.com/client/v4";function on(e){let t=e?.errors?.[0];if(t)return t.message?`${t.message}${t.code?` (code ${t.code})`:""}`:void 0}async function Ye(e){let{token:t,accountId:n}=e,s={Authorization:`Bearer ${t}`,"Content-Type":"application/json"};try{let i=await fetch(`${sn}/user/tokens/verify`,{headers:s});if(i.status===401||i.status===403)return{ok:!1,message:`Cloudflare rejected the token (HTTP ${i.status}). The token is invalid, expired, or has been revoked. Create a fresh one at https://dash.cloudflare.com/profile/api-tokens.`};if(!i.ok)return{ok:!1,message:`Cloudflare API returned HTTP ${i.status} verifying the token. Try again or check cloudflarestatus.com.`};let r=await i.json(),c=r.result?.status;if(r.success===!1||c&&c!=="active")return{ok:!1,message:`Cloudflare reports the token is not active${c?` (status: ${c})`:""}. ${on(r)??"Create a fresh token at https://dash.cloudflare.com/profile/api-tokens."}`}}catch(i){return{ok:!1,message:`Could not reach Cloudflare: ${I(i)}`}}try{let i=await fetch(`${sn}/accounts/${encodeURIComponent(n)}/pages/projects`,{headers:s});if(i.status===403)return{ok:!1,message:`The token is valid but can't manage Pages in account ${n} (HTTP 403). Most likely the token is missing the "Account \u2192 Cloudflare Pages \u2192 Edit" permission, or the Account ID belongs to a different account than the token. Re-create the token with that exact permission and your account selected under "Account Resources".`};if(i.status===404)return{ok:!1,message:`Account ${n} was not found (HTTP 404). Double-check the Account ID \u2014 it's the 32-character hex string in the dashboard URL (dash.cloudflare.com/<ID>).`};if(!i.ok)return{ok:!1,message:`Cloudflare API returned HTTP ${i.status} listing Pages projects. Try again or check cloudflarestatus.com.`};let r=await i.json();return r.success===!1?{ok:!1,message:on(r)??"Cloudflare rejected the Pages project listing request."}:{ok:!0,projectCount:Array.isArray(r.result)?r.result.length:void 0}}catch(i){return{ok:!1,message:`Could not reach Cloudflare: ${I(i)}`}}}var an="https://api.netlify.com/api/v1";async function We(e){let{token:t}=e,n={Authorization:`Bearer ${t}`};try{let s=await fetch(`${an}/user`,{headers:n});if(s.status===401||s.status===403)return{ok:!1,message:`Netlify rejected the token (HTTP ${s.status}). The token is invalid, expired, or has been revoked. Create a fresh one at https://app.netlify.com/user/applications#personal-access-tokens.`};if(!s.ok)return{ok:!1,message:`Netlify API returned HTTP ${s.status} verifying the token. Try again or check netlifystatus.com.`}}catch(s){return{ok:!1,message:`Could not reach Netlify: ${I(s)}`}}try{let s=await fetch(`${an}/accounts`,{headers:n});if(!s.ok)return{ok:!1,message:`Netlify API returned HTTP ${s.status} listing your teams. Try again or check netlifystatus.com.`};let i=await s.json(),r=Array.isArray(i)?i:[];if(r.length===0)return{ok:!1,message:"The token is valid but isn't a member of any Netlify team. Klaudius creates each client's site under a team, so it needs at least one. Open https://app.netlify.com and confirm your account has a team."};let c=typeof r[0]?.slug=="string"?r[0].slug:void 0;return{ok:!0,accountCount:r.length,accountSlug:c}}catch(s){return{ok:!1,message:`Could not reach Netlify: ${I(s)}`}}}async function we(e){let t=Pt(e);if(t)return{ok:!1,message:t};let n=ne(e),s=n.value,i=r=>{let c=[r],l=bt(e);return l&&c.push(l),n.repairs.length>0&&c.push(`Note: we corrected ${n.repairs.length} look-alike character(s) in this key before sending it (${n.repairs.join("; ")}). Some look-alikes are ambiguous, so if the key is otherwise correct, re-copy it with the copy button in the Cloud Console rather than retyping it.`),c.join(`
|
|
17
|
+
`)};try{let r=await fetch("https://places.googleapis.com/v1/places:searchText",{method:"POST",headers:{"Content-Type":"application/json","X-Goog-Api-Key":s,"X-Goog-FieldMask":"places.id"},body:JSON.stringify({textQuery:"x"})});if(r.ok)return{ok:!0};if(r.status===429)return{ok:!0};let c={};try{c=await r.json()}catch{}let l=c.error?.message??"",d=c.error?.status??"";return r.status===400&&(d==="PERMISSION_DENIED"||/Places API \(New\) has not been enabled|API_KEY_SERVICE_BLOCKED/i.test(l))?{ok:!1,message:"Key is valid, but Places API (New) is not enabled on its Cloud project. Open https://console.cloud.google.com/apis/library and enable 'Places API (New)' for the project this key belongs to, then try again."}:r.status===401||r.status===403?{ok:!1,message:i(l||`Google rejected the key (HTTP ${r.status}). Common causes: invalid key, billing not enabled on the Cloud project, or API key restrictions blocking this caller.`)}:{ok:!1,message:i(`Google API returned HTTP ${r.status}${l?`: ${l}`:""}.`)}}catch(r){return{ok:!1,message:`Could not reach Google: ${I(r)}`}}}import zs from"nodemailer";import{ImapFlow as qs}from"imapflow";function rn(e){let t=e;if(t?.authenticationFailed)return"auth";let n=typeof t?.code=="string"?t.code.toUpperCase():"";if(n==="EAUTH")return"auth";if(["ETIMEDOUT","ESOCKET","ECONNECTION","EDNS","ECONNREFUSED","ENOTFOUND","EHOSTUNREACH","ECONNRESET"].includes(n))return"network";let s=(typeof t?.message=="string"?t.message:String(e)).toLowerCase();return s.includes("invalid credentials")||s.includes("authentication failed")||s.includes("auth failed")||s.includes("login failed")||s.includes("invalid login")?"auth":s.includes("etimedout")||s.includes("timeout")||s.includes("enotfound")||s.includes("getaddrinfo")||s.includes("econnrefused")||s.includes("econnreset")?"network":"other"}async function ie(e){let t=zs.createTransport({host:e.emailSmtpHost,port:e.emailSmtpPort,secure:e.emailSmtpPort===465,auth:{user:e.emailAddress,pass:e.emailPassword},connectionTimeout:1e4,greetingTimeout:5e3,socketTimeout:1e4});try{await t.verify()}catch(s){return{ok:!1,failedAt:"smtp",message:ln(s,"SMTP",e.usesAccountPassword),failureKind:rn(s)}}finally{t.close()}let n=new qs({host:e.emailImapHost,port:e.emailImapPort,secure:e.emailImapPort===993,auth:{user:e.emailAddress,pass:e.emailPassword},logger:!1,connectionTimeout:1e4,greetingTimeout:5e3,socketTimeout:1e4});try{await n.connect(),await n.logout()}catch(s){try{await n.logout()}catch{}return{ok:!1,failedAt:"imap",message:ln(s,"IMAP",e.usesAccountPassword),failureKind:rn(s)}}return{ok:!0}}function ln(e,t,n){let s=e instanceof Error?e.message:String(e),i=s.toLowerCase();return i.includes("invalid credentials")||i.includes("authentication failed")||i.includes("auth failed")||i.includes("login failed")?n?`${t} rejected the credentials. Most common causes:
|
|
18
18
|
\u2022 The mailbox password is wrong or mistyped.
|
|
19
19
|
\u2022 The email address doesn't match this mailbox's login.
|
|
20
20
|
\u2022 The provider is blocking third-party apps \u2014 check that third-party
|
|
21
21
|
access is enabled and 2FA is off in your provider's settings.`:`${t} rejected the credentials. Most common causes:
|
|
22
22
|
\u2022 The app password is wrong, expired, or for a different provider.
|
|
23
23
|
\u2022 The email address doesn't match the account that issued the password.
|
|
24
|
-
\u2022 2FA is required but no app-specific password was generated.`:
|
|
25
|
-
`+t;return
|
|
26
|
-
${e.stdout??""}`;return
|
|
27
|
-
`,"utf-8")}var
|
|
24
|
+
\u2022 2FA is required but no app-specific password was generated.`:i.includes("etimedout")||i.includes("timeout")?`${t} server didn't respond in time. Check the host/port, or your network.`:i.includes("enotfound")||i.includes("getaddrinfo")?`${t} host could not be resolved. Check the host setting.`:`${t} check failed: ${s}`}async function cn(e){if(!e.accountSid||!e.authToken)return{ok:!1,message:"Missing Twilio Account SID or Auth Token."};let t=`https://api.twilio.com/2010-04-01/Accounts/${encodeURIComponent(e.accountSid)}.json`,n=Buffer.from(`${e.accountSid}:${e.authToken}`).toString("base64");try{let s=await fetch(t,{headers:{Authorization:`Basic ${n}`}});if(s.status===401)return{ok:!1,message:"Twilio rejected the credentials (401). Check the Account SID and Auth Token from https://console.twilio.com/ \u2014 the Auth Token shown there is the value to paste."};if(!s.ok)return{ok:!1,message:`Twilio API returned HTTP ${s.status}. Try again or check status.twilio.com.`};let i=await s.json();return i.status&&i.status!=="active"?{ok:!1,message:`Twilio account is in '${i.status}' state. Check the console for any holds before sending SMS.`}:{ok:!0,friendlyName:i.friendly_name}}catch(s){return{ok:!1,message:`Could not reach Twilio: ${I(s)}`}}}import{spawn as Js}from"child_process";async function dn(e){if(process.platform!=="darwin")return{ok:!1,message:"iMessage send is only supported on macOS. To run init from a non-Mac, switch the SMS provider to Twilio in the wizard."};let n=`tell application "Messages" to send "Klaudius connected (setup ping; ignore)." to buddy "${e.testPhone.replace(/"/g,"")}"`,s=await Xs(n);if(s.code===0)return{ok:!0};let i=s.stderr.toLowerCase();return i.includes("can't get application")||i.includes("isn't running")||i.includes("can't make some data")?{ok:!1,message:"Messages.app didn't respond. Open Messages on your Mac and sign in with your Apple ID, then retry."}:i.includes("(-1728)")||i.includes("not found")||i.includes("buddy")?{ok:!1,message:`Couldn't reach ${e.testPhone}. Either the number format is wrong (use the international format with a leading +) or this Mac doesn't have a path to that number. If TEST_PHONE is a non-Apple phone (Android), you need an iPhone signed into the same Apple ID with Settings \u2192 Messages \u2192 Text Message Forwarding turned ON for this Mac.`}:i.includes("(-1719)")||i.includes("(-25006)")?{ok:!1,message:"Messages.app refused the send \u2014 usually means iMessage isn't configured on this Mac. Open Messages \u2192 Settings \u2192 iMessage and sign in with your Apple ID."}:{ok:!1,message:`osascript error: ${s.stderr.trim()||`exit code ${s.code}`}`}}function Xs(e){return new Promise(t=>{let n=Js("osascript",["-e",e],{stdio:["ignore","ignore","pipe"]}),s="";n.stderr.on("data",i=>{s+=i.toString()}),n.on("close",i=>t({code:i??1,stderr:s})),n.on("error",i=>t({code:1,stderr:i.message}))})}import{spawn as ze}from"child_process";import{existsSync as Qs}from"fs";import{homedir as Zs}from"os";function eo(){let e=process.env.NODE_OPTIONS?.trim(),t=e?`${e} --use-system-ca`:"--use-system-ca";return{...process.env,NODE_OPTIONS:t}}var Ee=2,un=2e3,to=[/ECONNRESET/,/ETIMEDOUT/,/ENOTFOUND/,/EAI_AGAIN/,/socket hang up/i,/Connection reset/i,/network timeout/i,/could not resolve host/i];function pn(e,t){let n=e+`
|
|
25
|
+
`+t;return to.some(s=>s.test(n))}function fn(e){return new Promise(t=>setTimeout(t,e))}function no(e,t,n){return new Promise(s=>{let i=n.shell?ze([e,...t].join(" "),{cwd:n.cwd,stdio:["ignore","pipe","pipe"],shell:!0,env:n.env??process.env}):ze(e,t,{cwd:n.cwd,stdio:["ignore","pipe","pipe"],shell:!1,env:n.env??process.env}),r="",c="";i.stdout?.on("data",l=>{let d=l.toString();r+=d,process.stdout.write(d)}),i.stderr?.on("data",l=>{let d=l.toString();c+=d,process.stderr.write(d)}),i.on("close",l=>s({code:l??1,stdout:r,stderr:c})),i.on("error",l=>s({code:1,stdout:r,stderr:c+l.message}))})}async function at(e,t,n){let s={code:0,stdout:"",stderr:""};for(let i=0;i<=Ee;i++){if(s=await no(e,t,{cwd:n.cwd,env:n.env,shell:n.shell}),s.code===0||!pn(s.stderr,s.stdout))return s;i<Ee&&(o.detail(`${n.label} failed with a transient network error \u2014 retrying (${i+2}/${Ee+1})\u2026`),await fn(un))}return s}function so(e,t,n){return new Promise(s=>{let i=ze(e,t,{cwd:n.cwd,stdio:["ignore","pipe","pipe"],shell:!1}),r="",c="";i.stdout?.on("data",l=>{r+=l.toString()}),i.stderr?.on("data",l=>{c+=l.toString()}),i.on("close",l=>s({code:l??1,stdout:r,stderr:c})),i.on("error",l=>s({code:1,stdout:r,stderr:c+l.message}))})}var oo=[{pattern:/UNABLE_TO_VERIFY_LEAF_SIGNATURE|unable to verify the first certificate/i,hint:"TLS-handshake error \u2014 your machine appears to be intercepting HTTPS (antivirus, corporate proxy, or VPN re-signing traffic with its own root CA). We work around this with NODE_OPTIONS=--use-system-ca, which needs Node 22.15+. Run `node --version` to verify, upgrade if older, then re-run setup."},{pattern:/Microsoft Visual C\+\+ 14\.0 or greater is required/i,hint:"Python tried to compile a package from source and couldn't find the Microsoft C++ Build Tools. The latest Klaudius pins supabase<2.26 to skip the offending dependency entirely. Re-run with `npx klaudius@latest init` (pulls the latest) \u2014 that should bypass the source build."}];function io(e){let t=`${e.stderr??""}
|
|
26
|
+
${e.stdout??""}`;return oo.find(s=>s.pattern.test(t))?.hint}async function ao(e){let t=["supabase<2.26","python-dotenv","requests","httpx","Pillow","truststore"],n=["-m","pip","install","--quiet","--user","--prefer-binary"],i=(await z())?.command??["python3"],r=async l=>{let d={code:0,stdout:"",stderr:""};for(let u=0;u<=Ee;u++){if(d=await so(i[0],[...i.slice(1),...l],{cwd:e}),d.code===0||!pn(d.stderr,d.stdout))return d;u<Ee&&(o.detail(`pip install hit a transient network error \u2014 retrying (${u+2}/${Ee+1})\u2026`),await fn(un))}return d},c=await r([...n,"--break-system-packages",...t]);return c.code!==0&&/no such option:.*break-system-packages/i.test(c.stderr)&&(o.detail("Older pip detected; retrying without --break-system-packages"),c=await r([...n,...t])),c.code!==0&&(c.stderr.trim()&&process.stderr.write(c.stderr),c.stdout.trim()&&process.stdout.write(c.stdout)),c}async function qe(e){let t={npm:"skipped",pip:"skipped",playwright:"skipped",patchright:"skipped"},n=eo(),s=process.platform==="win32",i;if(s){let a=fe([{label:"your Windows user folder",path:Zs()},{label:"the project folder",path:e}]);if(a.length>0){let y=await new Promise(k=>{let b=ze("npm config get script-shell",{cwd:e,stdio:["ignore","pipe","pipe"],shell:!0}),R="",C="";b.stdout?.on("data",v=>{R+=v.toString()}),b.stderr?.on("data",v=>{C+=v.toString()}),b.on("close",v=>k({code:v??1,stdout:R,stderr:C})),b.on("error",v=>k({code:1,stdout:R,stderr:v.message}))}),g=y.code===0?y.stdout.trim():void 0;if(!me(g,Qs)){let{detail:k,action:b}=he(a,"install");i=`${k}. ${b}`}}}let r=(a,y)=>{let g=io(y);if(g){(t.hints??={})[a]=g;return}i&&(a==="npm"||a==="playwright"||a==="patchright")&&!Object.values(t.hints??{}).includes(i)&&((t.hints??={})[a]=i)};o.step("Running npm install (Next.js, Playwright JS, etc.)...");let c=await at("npm",["install"],{cwd:e,label:"npm install",env:n,shell:s});t.npm=c.code===0?"ok":"failed",c.code!==0&&r("npm",c),o.step("Installing Python packages (supabase, dotenv, requests, httpx, Pillow)...");let l=await ao(e);t.pip=l.code===0?"ok":"failed",l.code!==0&&r("pip",l),o.step("Installing Playwright browser (chromium ~200MB; one-time)...");let d=await at("npx",["playwright","install","chromium"],{cwd:e,label:"playwright install",env:n,shell:s});t.playwright=d.code===0?"ok":"failed",d.code!==0&&r("playwright",d),o.step("Installing Patchright browser (chromium ~200MB; one-time)...");let u=await at("npx",["patchright","install","chromium"],{cwd:e,label:"patchright install",env:n,shell:s});return t.patchright=u.code===0?"ok":"failed",u.code!==0&&r("patchright",u),t}import{mkdir as ro,readFile as lo,writeFile as co}from"fs/promises";import{join as mn}from"path";async function Je(e,t){let n=mn(e,".claude");await ro(n,{recursive:!0});let s=mn(n,"settings.json"),i={};try{let d=await lo(s,"utf-8"),u=JSON.parse(d);u&&typeof u=="object"&&!Array.isArray(u)&&(i=u)}catch{}let r=i.enabledMcpjsonServers,c=Array.isArray(r)?r.filter(d=>typeof d=="string"):[];c.includes(t)||c.push(t);let l={...i,enabledMcpjsonServers:c};await co(s,JSON.stringify(l,null,2)+`
|
|
27
|
+
`,"utf-8")}var gn="0.23.2",x=5;function de(e){return`npx klaudius@latest init ${Xe(Ae(e))}`}function Ae(e){if(process.platform==="win32")return e;let t=uo();return e===t?"~":e.startsWith(t+"/")?`~/${e.slice(t.length+1)}`:e}async function ho(e){let t=[];try{let s=(await kn(e,{withFileTypes:!0})).filter(i=>i.isDirectory()&&!i.name.startsWith(".")).slice(0,200);for(let i of s){let r=B(e,i.name);if(!await yn(B(r,".env")))continue;let c=await yn(B(r,".klaudius","manifest.json"));if(t.push({path:r,finished:c}),t.length>=3)break}}catch{}return t}async function yn(e){try{return await ct(e),!0}catch{return!1}}function Xe(e){return/\s/.test(e)?`"${e}"`:e}function ae(e,t,n){o.blank(),o.error(`${t} validation failed ${x} times in a row. Pausing setup so you don't get stuck in a loop.`),o.detail(`Last error: ${n}`),o.blank(),o.detail("Your credentials are saved in `.env`. Two ways forward:"),o.detail(" \u2022 Fix the value, then re-run setup and pick Resume \u2014 it keeps everything else you've entered:"),o.blank(),console.log(` ${p.cyan(de(e))}`),o.blank(),o.detail(` (Your .env is at ${Ae(B(e,".env"))} \u2014 open it in any text editor.)`),o.detail(" \u2022 Or email hello@klaudius.dev with the error above and we'll dig in."),o.blank(),process.exit(1)}async function wn(e){let t=e.target??".",n=fo(t)?t:po(process.cwd(),t),s=wo(n);s&&(o.error("Klaudius can't be installed inside a protected system folder."),o.detail(`Path: ${n}`),o.detail(`Reason: ${s}`),o.blank(),o.detail("Pick a normal user folder instead \u2014 Documents and Desktop are the safe defaults."),o.blank(),process.platform==="win32"?(o.detail("For example, open a fresh PowerShell window (not 'Run as Administrator') and run:"),console.log(` ${p.cyan("cd $HOME\\Documents")}`),console.log(` ${p.cyan("npx klaudius@latest init my-agency")}`)):(o.detail("For example:"),console.log(` ${p.cyan("cd ~/Documents")}`),console.log(` ${p.cyan("npx klaudius@latest init my-agency")}`)),o.blank(),process.exit(1)),process.platform==="win32"&&Eo()&&(o.warn("You appear to be running in an elevated (Administrator) PowerShell."),o.detail("This isn't fatal, but Python paths and Playwright's browser cache will land in a different location than a normal user shell, which often causes installs to fail or run-time scripts to break. Easiest fix: close this window, open a new regular PowerShell (NOT 'Run as Administrator'), then re-run npx klaudius@latest init."),o.blank()),await Ve("init",gn);let i=await go(n);if(i.kind==="scaffolded"){o.blank(),o.warn(`Found an existing Klaudius project at ${p.bold(n)}.`),o.detail("(Your .env and project files are in place.)"),o.blank(),i.nodeModulesMissing?(o.detail("It looks like a previous setup didn't finish installing dependencies."),o.detail("To pick up where it left off, run:"),o.blank(),n!==process.cwd()&&console.log(` ${p.cyan(`cd ${Xe(t)}`)}`),console.log(` ${p.cyan("npx klaudius@latest install")} ${p.dim("# retries npm + pip + browsers; idempotent")}`),o.blank(),o.detail("Then verify with:"),o.blank(),console.log(` ${p.cyan("npx klaudius@latest doctor")} ${p.dim("# checks Node / Python / installers / credentials")}`),o.blank()):(o.detail("Everything is scaffolded and dependencies look installed."),o.detail("Pick the action you wanted:"),o.blank(),console.log(` ${p.cyan("npx klaudius@latest doctor")} ${p.dim("# verify Node / Python / installers / credentials")}`),console.log(` ${p.cyan("npx klaudius@latest configure")} ${p.dim("# change a credential / API key")}`),console.log(` ${p.cyan("npx klaudius@latest update")} ${p.dim("# pull the latest skills, scripts, lessons")}`),o.blank()),o.detail("If you wanted to start over from scratch, delete this folder and re-run `npx klaudius@latest init`."),o.blank();return}if(i.kind==="occupied"){let f=t===".",h=await ho(n);if(h.length>0){o.warn("You're not inside your Klaudius project \u2014 it's in a folder below this one."),o.detail(`You're in: ${Ae(n)}`),o.blank();for(let m of h)o.detail(m.finished?`Found a finished project at ${Ae(m.path)}. To work in it:`:`Found an unfinished setup at ${Ae(m.path)}. To pick up where it left off:`),o.blank(),m.finished?(console.log(` ${p.cyan(`cd ${Ae(m.path)}`)}`),console.log(` ${p.cyan("claude")} ${p.dim("# open Claude Code in the project")}`)):console.log(` ${p.cyan(de(m.path))} ${p.dim("# then pick Resume")}`),o.blank();process.exit(1)}o.error("Klaudius needs an empty folder to scaffold into. This directory isn't empty."),o.detail(`Path: ${n}`),o.detail(`Contains: ${i.entries.slice(0,5).join(", ")}${i.entries.length>5?`, \u2026 (+${i.entries.length-5} more)`:""}`),o.blank(),f?(o.detail("Two ways forward:"),o.blank(),o.detail("1. Pass a folder name and Klaudius creates it for you:"),console.log(` ${p.cyan("npx klaudius@latest init my-agency")}`),o.blank(),o.detail("2. Or cd into an empty folder first, then re-run:"),console.log(` ${p.cyan("mkdir my-agency && cd my-agency && npx klaudius@latest init")}`)):(o.detail(`The folder '${t}' already exists and isn't empty.`),o.detail("Either pick a different name:"),console.log(` ${p.cyan(`npx klaudius@latest init ${t}-2`)}`),o.detail("\u2026or delete the existing folder if it's safe to remove.")),process.exit(1)}let r=await ko(e.license),c=E.spinner();c.start("Validating license");let l=await tn(r);l.ok||(c.stop(`License invalid: ${l.reason??"unknown"}`,2),o.detail("If you believe this is in error, email hello@klaudius.dev with your purchase details."),process.exit(1)),c.stop(`License valid (${l.tier??"core"} tier)`);let d=await ge();d.ok||(o.error(d.message??"Python version check failed."),o.blank(),o.detail(`Once you've installed Python 3.10+, re-run the same command: ${de(n)}`),process.exit(1));let u=se();u.ok||(o.error(u.message??"Node.js version check failed."),o.blank(),o.detail(`Once you've installed Node.js 22.15+, re-run the same command: ${de(n)}`),process.exit(1));let a,y=!1;if(i.kind==="partial")if(await yo(n)==="resume"){let h=await hn(i.envPath,"utf-8"),m=ot(G(h));m?(o.success("Resuming with values from your existing .env"),o.detail("(Skipping the wizard \u2014 edit .env directly if you need to change anything.)"),a=m,y=!0):(o.warn("Existing .env was missing required fields \u2014 starting wizard fresh."),a=await O())}else{let h=await hn(i.envPath,"utf-8"),m=ot(G(h));a=await O(m??{})}else a=await O();a.licenseKey=r,await N(n,a),y||(o.success("Saved .env"),o.success(a.aiAgent==="codex"?"Saved .codex/config.toml":"Saved .mcp.json")),o.blank();for(let f=1;;f++){let h=E.spinner();h.start("Validating Supabase credentials");let m=await ke({url:a.supabaseUrl,serviceKey:a.supabaseServiceKey});if(m.ok){h.stop("Supabase credentials accepted");break}h.stop(m.message??"Supabase check failed",2),f>=x&&ae(n,"Supabase",m.message??"Supabase check failed");let A=m.message??"Supabase check failed";o.blank(),o.warn(`Bouncing you back into the Supabase section so you can fix it in place. (attempt ${f+1} of ${x})`),o.detail("(Press Enter through any field to keep its current value. Ctrl+C to exit.)"),o.blank(),a=await O(a,{onlySection:"supabase",banner:`Supabase rejected your credentials:
|
|
28
28
|
${A}
|
|
29
29
|
|
|
30
30
|
Re-enter the URL, secret key, or PAT below. Press Enter on any
|
|
31
|
-
field to keep what's already there.`}),await N(n,
|
|
31
|
+
field to keep what's already there.`}),await N(n,a)}if(o.blank(),a.deployProvider==="cloudflare")for(let f=1;;f++){let h=E.spinner();h.start("Validating Cloudflare token + account");let m=await Ye({token:a.cloudflareApiToken??"",accountId:a.cloudflareAccountId??""});if(m.ok){h.stop(`Cloudflare credentials accepted (${m.projectCount??0} existing Pages project${m.projectCount===1?"":"s"})`);break}h.stop(m.message??"Cloudflare check failed",2),f>=x&&ae(n,"Cloudflare",m.message??"Cloudflare check failed");let A=m.message??"Cloudflare check failed";o.blank(),o.warn(`Bouncing you back into the Cloudflare section so you can fix it in place. (attempt ${f+1} of ${x})`),o.detail("(Press Enter on a field to keep its current value. Ctrl+C to exit.)"),o.blank(),a=await O(a,{onlySection:"cloudflare",banner:`Cloudflare rejected the credentials:
|
|
32
32
|
${A}
|
|
33
33
|
|
|
34
34
|
Re-enter the API token or Account ID below. The token needs the
|
|
35
35
|
"Account \u2192 Cloudflare Pages \u2192 Edit" permission. Press Enter to keep
|
|
36
|
-
the current value.`}),await N(n,
|
|
36
|
+
the current value.`}),await N(n,a)}else if(a.deployProvider==="netlify")for(let f=1;;f++){let h=E.spinner();h.start("Validating Netlify token");let m=await We({token:a.netlifyAuthToken??""});if(m.ok){h.stop(m.accountSlug?`Netlify token accepted (team: ${m.accountSlug})`:"Netlify token accepted");break}h.stop(m.message??"Netlify check failed",2),f>=x&&ae(n,"Netlify",m.message??"Netlify check failed");let A=m.message??"Netlify check failed";o.blank(),o.warn(`Bouncing you back into the Netlify section so you can fix it in place. (attempt ${f+1} of ${x})`),o.detail("(Press Enter on the field to keep its current value. Ctrl+C to exit.)"),o.blank(),a=await O(a,{onlySection:"netlify",banner:`Netlify rejected the token:
|
|
37
37
|
${A}
|
|
38
38
|
|
|
39
39
|
Generate a new token at
|
|
40
40
|
https://app.netlify.com/user/applications#personal-access-tokens
|
|
41
|
-
and paste it below. Press Enter to keep the current value.`}),await N(n,
|
|
42
|
-
`);
|
|
41
|
+
and paste it below. Press Enter to keep the current value.`}),await N(n,a)}else if(a.deployProvider==="selfhost")for(let f=1;;f++){let h=Re(a.selfhostDeployTarget??""),m=Oe(a.selfhostUrlTemplate??"");if(!h&&!m){o.success("Self-host deploy configured (SSH reachability is tested at your first deploy)");break}let A=[h&&`SELFHOST_DEPLOY_TARGET: ${h}`,m&&`SELFHOST_URL_TEMPLATE: ${m}`].filter(Boolean).join(`
|
|
42
|
+
`);f>=x&&ae(n,"Self-host",A),o.blank(),o.warn(`Bouncing you back into the self-host section so you can fix it in place. (attempt ${f+1} of ${x})`),o.blank(),a=await O(a,{onlySection:"selfhost",banner:`The self-host deploy settings look wrong:
|
|
43
43
|
${A}
|
|
44
44
|
|
|
45
|
-
Re-enter them below. Press Enter on a field to keep its current value.`}),await N(n,
|
|
45
|
+
Re-enter them below. Press Enter on a field to keep its current value.`}),await N(n,a)}else for(let f=1;;f++){let h=E.spinner();h.start("Validating Vercel token");let m=await Be(a.vercelToken??"");if(m.ok){h.stop(m.username?`Vercel token accepted (signed in as ${m.username})`:"Vercel token accepted");break}h.stop(m.message??"Vercel check failed",2),f>=x&&ae(n,"Vercel",m.message??"Vercel check failed");let A=m.message??"Vercel check failed";o.blank(),o.warn(`Bouncing you back into the Vercel section so you can fix it in place. (attempt ${f+1} of ${x})`),o.detail("(Press Enter on the field to keep its current value. Ctrl+C to exit.)"),o.blank(),a=await O(a,{onlySection:"vercel",banner:`Vercel rejected the token:
|
|
46
46
|
${A}
|
|
47
47
|
|
|
48
48
|
Generate a new token at https://vercel.com/account/tokens and
|
|
49
|
-
paste it below. Press Enter to keep the current value.`}),await N(n,
|
|
50
|
-
${
|
|
49
|
+
paste it below. Press Enter to keep the current value.`}),await N(n,a)}o.blank();for(let f=1;;f++){let h=ne(a.googlePlacesApiKey??""),m=E.spinner();m.start("Validating Google Places API key");let A=await we(a.googlePlacesApiKey??"");if(A.ok){if(m.stop("Google Places API key accepted"),h.changed){if(h.repairs.length>0){o.blank(),o.warn("Corrected look-alike characters in your Google Places API key:");for(let $ of h.repairs)o.detail(` ${$}`);o.detail("These come from keys that were transcribed rather than copied."),o.detail("Google accepted the corrected key, and .env now holds it.")}a.googlePlacesApiKey=h.value,await N(n,a)}break}m.stop(A.message??"Google Places check failed",2),f>=x&&ae(n,"Google Places",A.message??"Google Places check failed");let Q=A.message??"Google Places check failed";o.blank(),o.warn(`Bouncing you back into the Google Places section so you can fix it in place. (attempt ${f+1} of ${x})`),o.detail("(Press Enter on the field to keep its current value. Ctrl+C to exit.)"),o.blank(),a=await O(a,{onlySection:"google-places",banner:`Google rejected the key:
|
|
50
|
+
${Q}
|
|
51
51
|
|
|
52
52
|
Generate (or fix) the key at https://console.cloud.google.com
|
|
53
|
-
and paste it below. Press Enter to keep the current value.`}),await N(n,
|
|
53
|
+
and paste it below. Press Enter to keep the current value.`}),await N(n,a)}let g=!1;if(a.outreachEnabled&&a.outreachChannels?.includes("email")&&a.emailAddress&&a.emailPassword&&a.emailSmtpHost&&a.emailSmtpPort&&a.emailImapHost&&a.emailImapPort){o.blank();let f=0,h=!1,m;for(;!h;){f++;let A=E.spinner();A.start("Validating email credentials (SMTP + IMAP)");let Q=a.emailProvider&&a.emailProvider!=="custom"?a.emailProvider:pe(a.emailSmtpHost),$=Q?V[Q]:void 0,F=await ie({emailAddress:a.emailAddress,emailPassword:a.emailPassword,emailSmtpHost:a.emailSmtpHost,emailSmtpPort:a.emailSmtpPort,emailImapHost:a.emailImapHost,emailImapPort:a.emailImapPort,usesAccountPassword:$?.usesAccountPassword});if(F.ok){A.stop("Email credentials accepted (SMTP + IMAP)");break}A.stop(F.message??"Email check failed",2);let Ce=`${Q}\0${a.emailAddress}\0${a.emailPassword}`;if($&&F.failureKind!=="network"&&m!==Ce){m=Ce;let re=xe(Q,a.emailSmtpHost,a.emailImapHost),le,yt=0;if(re.length>0){o.blank(),o.warn(`That server rejected the login. ${$.label} runs several regional servers \u2014 trying the others with the same credentials...`);for(let K of re){let et=E.spinner();et.start(`Trying ${K.label} (${K.smtpHost})`);let tt=await ie({emailAddress:a.emailAddress,emailPassword:a.emailPassword,emailSmtpHost:K.smtpHost,emailSmtpPort:a.emailSmtpPort,emailImapHost:K.imapHost,emailImapPort:a.emailImapPort});if(tt.ok){et.stop(`${K.label}: your login works here (${K.smtpHost})`),le=K;break}tt.failureKind!=="network"&&yt++,et.stop(tt.failureKind==="network"?`${K.label}: unreachable`:`${K.label}: rejected too`,2)}}if(le){o.blank(),o.success("Found it \u2014 your password was right all along; the server was the only problem.");let K=await E.confirm({message:`Use the ${le.label} servers (${le.smtpHost} / ${le.imapHost})?`,initialValue:!0});if(E.isCancel(K)&&(E.cancel(`Setup cancelled. Your .env is saved \u2014 resume with:
|
|
54
54
|
|
|
55
|
-
${
|
|
56
|
-
`),process.exit(0)),
|
|
55
|
+
${de(n)}
|
|
56
|
+
`),process.exit(0)),K){a.emailSmtpHost=le.smtpHost,a.emailImapHost=le.imapHost,await N(n,a);continue}}else re.length>0&&(o.blank(),yt===0?o.warn("Couldn't reach any of the alternate servers \u2014 this looks like a network problem, not a credential problem. Check your connection and retry."):$.noAltWorkedHint&&o.warn($.noAltWorkedHint))}let Dn=F.message??"Email check failed";o.blank(),o.warn("Email isn't required to finish setup \u2014 the rest of Klaudius (finding businesses, building, deploying) works without it."),o.detail("You can skip it now and wire it up later from inside the project."),o.blank();let Ze=await E.select({message:`What would you like to do? ${p.dim("(\u2191 \u2193 arrow keys, then Enter)")}`,initialValue:f>=3?"skip":f>=2?"edit":"retry",options:[{value:"retry",label:"Retry the check (good if it was a momentary network blip)"},{value:"edit",label:"Edit my email details and retry"},{value:"skip",label:"Skip email for now (finish setup; wire email up later)"}]});if(E.isCancel(Ze)&&(E.cancel(`Setup cancelled. Your .env is saved \u2014 resume with:
|
|
57
57
|
|
|
58
|
-
${
|
|
59
|
-
`),process.exit(0)),
|
|
60
|
-
${
|
|
58
|
+
${de(n)}
|
|
59
|
+
`),process.exit(0)),Ze==="skip"){a.outreachChannels=(a.outreachChannels??[]).filter(re=>re!=="email"),a.outreachPriority=(a.outreachPriority??[]).filter(re=>re!=="email"),a.outreachChannels.length===0&&(a.outreachEnabled=!1),await N(n,a),g=!0,o.success("Skipped email for now. Setup will continue."),a.outreachEnabled?o.detail("Outreach will use your other channel(s); email stays off until it's fixed."):o.detail("Automated outreach is off until email is fixed \u2014 everything else works."),h=!0;break}Ze==="edit"&&(o.blank(),a=await O(a,{onlySection:"email",banner:`${F.failedAt==="imap"?"IMAP":"SMTP"} check failed:
|
|
60
|
+
${Dn}
|
|
61
61
|
|
|
62
62
|
Re-enter the email address, app password, or server details below.
|
|
63
63
|
Press Enter on any field to keep its current value.
|
|
64
64
|
|
|
65
65
|
Tip: to change the SMTP/IMAP servers, pick "Enter servers manually"
|
|
66
|
-
at the "Server settings" question.`}),await N(n,
|
|
66
|
+
at the "Server settings" question.`}),await N(n,a))}}if(a.outreachEnabled&&a.outreachChannels?.includes("sms")&&a.smsProvider==="twilio"&&a.twilioAccountSid&&a.twilioAuthToken){o.blank();for(let f=1;;f++){let h=E.spinner();h.start("Validating Twilio credentials");let m=await cn({accountSid:a.twilioAccountSid,authToken:a.twilioAuthToken});if(m.ok){h.stop(m.friendlyName?`Twilio credentials accepted (${m.friendlyName})`:"Twilio credentials accepted");break}h.stop(m.message??"Twilio check failed",2),f>=x&&ae(n,"Twilio",m.message??"Twilio check failed");let A=m.message??"Twilio check failed";o.blank(),o.warn(`Bouncing you back into the SMS section so you can fix it in place. (attempt ${f+1} of ${x})`),o.detail("(Press Enter on any field to keep its current value. Ctrl+C to exit.)"),o.blank(),a=await O(a,{onlySection:"sms",banner:`Twilio rejected the credentials:
|
|
67
67
|
${A}
|
|
68
68
|
|
|
69
69
|
Re-enter the Account SID or Auth Token below.
|
|
70
|
-
Press Enter on any field to keep its current value.`}),await N(n,
|
|
70
|
+
Press Enter on any field to keep its current value.`}),await N(n,a)}}if(a.outreachEnabled&&a.outreachChannels?.includes("sms")&&a.smsProvider==="imessage"&&a.testPhone){o.blank();for(let f=1;;f++){let h=E.spinner();h.start("Validating iMessage setup (sending a test ping)");let m=await dn({testPhone:a.testPhone});if(m.ok){h.stop("iMessage dispatched (check your phone for the test ping)");break}h.stop(m.message??"iMessage check failed",2),f>=x&&ae(n,"iMessage",m.message??"iMessage check failed");let A=m.message??"iMessage check failed";o.blank(),o.warn(`Bouncing you back into the SMS section so you can fix it in place. (attempt ${f+1} of ${x})`),o.detail("(Press Enter on any field to keep its current value. Ctrl+C to exit.)"),o.blank(),a=await O(a,{onlySection:"sms",banner:`iMessage check failed:
|
|
71
71
|
${A}
|
|
72
72
|
|
|
73
73
|
Either fix the underlying issue (sign in to Messages.app, configure
|
|
74
74
|
Text Message Forwarding) and press Enter through, or change SMS
|
|
75
|
-
provider to Twilio.`}),await N(n,
|
|
75
|
+
provider to Twilio.`}),await N(n,a)}}if((a.notifyChannel??"telegram")==="telegram"&&a.telegramBotToken&&a.telegramChatId){o.blank();let f=0,h=!1;for(;!h;){f++;let m=E.spinner();m.start("Validating Telegram bot + chat (sending a test ping)");let A=await At({botToken:a.telegramBotToken,chatId:a.telegramChatId});if(A.ok){m.stop(A.botHandle?`Telegram bot ${A.botHandle} accepted, test message delivered`:"Telegram credentials accepted, test message delivered"),h=!0;break}m.stop(A.message??"Telegram check failed",2);let Q=A.message??"Telegram check failed";o.blank(),o.warn("Telegram is optional \u2014 you can skip it now and wire it up later by editing `.env`."),o.blank();let $=await E.select({message:`What would you like to do? ${p.dim("(\u2191 \u2193 arrow keys, then Enter)")}`,initialValue:f>=2?"skip":"retry",options:[{value:"retry",label:"Retry the check (good if it was a momentary network blip)"},{value:"edit",label:"Edit my bot token / chat ID and retry"},{value:"skip",label:"Skip Telegram for now (I'll add it later by editing .env)"}]});if(E.isCancel($)&&(E.cancel(`Setup cancelled. Your .env is saved \u2014 resume with:
|
|
76
76
|
|
|
77
|
-
${
|
|
78
|
-
`),process.exit(0))
|
|
79
|
-
${
|
|
77
|
+
${de(n)}
|
|
78
|
+
`),process.exit(0)),$==="skip"){a.telegramBotToken=void 0,a.telegramChatId=void 0,await N(n,a),o.success("Skipped Telegram. Setup will continue."),o.detail("Wire it up later by pasting your bot token and chat ID into the TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID lines of `.env`."),h=!0;break}if($==="edit"&&(o.blank(),a=await O(a,{onlySection:"notifications",banner:`Telegram check failed:
|
|
79
|
+
${Q}
|
|
80
80
|
|
|
81
81
|
Re-enter the bot token or chat_id below.
|
|
82
|
-
Press Enter on any field to keep its current value.`}),await N(n,
|
|
82
|
+
Press Enter on any field to keep its current value.`}),await N(n,a),(a.notifyChannel??"telegram")!=="telegram"||!a.telegramBotToken||!a.telegramChatId)){o.success("Skipped Telegram. Setup will continue."),h=!0;break}}}o.blank();let k=E.spinner();k.start("Downloading Klaudius template");let b;try{b=(await Ke({licenseKey:r,machineId:_e(),hostname:process.platform==="win32"?process.env.COMPUTERNAME:void 0,os:`${process.platform}-${process.arch}`,agent:a.aiAgent,destDir:n})).filesExtracted,k.stop(`Downloaded ${b} files into ${p.bold(n)}`)}catch(f){k.stop(f.message,2);let h=a.aiAgent==="codex"?".codex/config.toml":".mcp.json";o.detail(`Your .env / ${h} are saved. Re-run init once the issue is resolved to retry the download.`),process.exit(1)}await lt(B(n,"clients"),{recursive:!0});let R=await Vt(n);await je(n,Kt(gn,R)),o.success("Wrote .klaudius/manifest.json");try{await Ge(n,n,Object.keys(R))}catch{}let C=!1,v="";if(e.skipSchema)o.warn("--skip-schema set; not applying scripts/schema.sql to your Supabase project."),o.detail(`Apply manually later via the SQL editor: ${a.supabaseUrl.replace("https://","https://supabase.com/dashboard/project/"+a.supabaseProjectRef+"/sql/new").replace(a.supabaseProjectRef+".supabase.co","")}`);else{o.blank();let f=E.spinner();f.start("Applying schema to Supabase");let h=await nn({projectRoot:n,pat:a.supabasePat,projectRef:a.supabaseProjectRef});h.ok?f.stop("Schema applied (or already present)"):(f.stop(h.message??"Schema apply failed",2),C=!0,v=`https://supabase.com/dashboard/project/${a.supabaseProjectRef}/sql/new`)}let T=[],M={};if(e.skipInstall)o.warn("--skip-install set; you'll need to run npm install + pip install + playwright/patchright install yourself.");else{o.blank(),o.heading("Installing dependencies");let f=await qe(n);o.detail(`npm: ${f.npm}, pip: ${f.pip}, playwright: ${f.playwright}, patchright: ${f.patchright}`),f.npm==="failed"&&T.push("npm"),f.pip==="failed"&&T.push("pip"),f.playwright==="failed"&&T.push("playwright"),f.patchright==="failed"&&T.push("patchright"),M=f.hints??{}}let J=a.outreachEnabled&&a.outreachPriority?.includes("whatsapp")&&(a.whatsappAccounts?.length??0)>0,P=!e.skipInstall&&!T.includes("npm");if(J&&P){o.blank(),o.heading("Linking WhatsApp accounts"),console.log(p.dim(`You'll be prompted to scan one QR per linked number. Open WhatsApp on the
|
|
83
83
|
phone whose number you want to link, then Settings \u2192 Linked Devices \u2192
|
|
84
|
-
Link a Device, and point it at the QR shown in this terminal.`)),
|
|
84
|
+
Link a Device, and point it at the QR shown in this terminal.`)),o.blank();for(let f of a.whatsappAccounts){console.log(p.cyan(`Pairing WhatsApp account '${f}'...`)),console.log(p.dim(`(Ctrl-C abandons init but your .env is already saved \u2014 finish later via: npx klaudius@latest pair-whatsapp --label ${f})`));let h=dt(process.execPath,["scripts/whatsapp.mjs","pair","--account",f],{cwd:n,stdio:"inherit"});h.status===0?o.detail(`Paired '${f}'.`):(console.log(p.yellow(`'${f}' did not pair (exit ${h.status??"signalled"}). You can finish later via:`)),console.log(p.cyan(` npx klaudius@latest pair-whatsapp --label ${f}`))),o.blank()}}else if(J&&!P){o.blank(),console.log(p.yellow("Skipping WhatsApp pairing \u2014 baileys isn't installed yet (npm install failed earlier or was skipped).")),console.log(p.dim("Once `npx klaudius@latest install` completes successfully, pair via:"));for(let f of a.whatsappAccounts)console.log(p.cyan(` npx klaudius@latest pair-whatsapp --label ${f}`))}let X=a.emailAuth==="oauth-microsoft"&&a.outreachEnabled&&a.outreachChannels?.includes("email"),w=!e.skipInstall&&!T.includes("pip"),j=f=>{console.log(p.dim("Connect it any time from the project folder with:")),console.log(p.cyan(` ${f?f.command.join(" "):"python3"} scripts/ms_oauth.py login`)),console.log(p.dim(" (on a remote/browser-less machine, add: --device-code)"))};if(X&&w){o.blank(),o.heading("Connecting your Outlook / Microsoft 365 mailbox"),console.log(p.dim(`Microsoft mailboxes connect with a one-time browser sign-in instead of a
|
|
85
85
|
password. Your browser will open to Microsoft's sign-in page \u2014
|
|
86
|
-
sign in as `+(
|
|
86
|
+
sign in as `+(a.emailAddress??"your outreach mailbox")+` and approve.
|
|
87
87
|
(No browser on this machine? It falls back to a short code you can
|
|
88
|
-
enter from any device.)`)),
|
|
89
|
-
`:"",g=r.aiAgent==="codex"?"codex":"claude",m=r.aiAgent==="codex"?"Codex":"Claude Code",A=r.aiAgent==="codex"?"npm install -g @openai/codex":"npm install -g @anthropic-ai/claude-code";b.length>0&&(console.log(u.dim(`Easiest fix \u2014 let ${m} finish it for you:`)),i.blank(),p&&process.stdout.write(p),console.log(` ${u.cyan(g)} ${u.dim(`# open ${m} in this folder`)}`),console.log(u.dim(" Then paste:")),console.log(u.cyan(` "Finish my Klaudius install \u2014 ${b.join(", ")} failed during setup. Debug the install output, retry, then run npx klaudius@latest doctor."`)),i.blank(),console.log(u.dim(` (Don't have ${m} yet? Install with: \`${A}\`)`)),i.blank(),console.log(u.dim("Or do it yourself:")),i.blank(),p&&process.stdout.write(p),console.log(` ${u.cyan("npx klaudius@latest install")} ${u.dim("# retry the failing installers")}`),console.log(` ${u.cyan("npx klaudius@latest doctor")} ${u.dim("# verify everything")}`),i.blank()),I&&(console.log(u.dim("For the schema failure specifically, apply scripts/schema.sql in the Supabase SQL editor:")),console.log(` ${u.cyan(O)}`),console.log(u.dim(" Open scripts/schema.sql, copy the contents, paste into the editor, click Run.")),i.blank()),b.includes("pip")&&!L.pip&&(console.log(u.dim("If pip fails again with a build error, check `python3 --version` \u2014 Klaudius needs")),console.log(u.dim(`Python 3.10+. Install a newer one from ${ii()}`)),console.log(u.dim("and open a fresh Terminal before retrying.")),i.blank());let v=["npm","playwright","patchright"].filter(H=>b.includes(H)&&!L[H]);if(v.length>0){let H=v.length===1?"keeps":"keep";console.log(u.dim(`If ${v.join(" / ")} ${H} failing with network errors (ECONNRESET,`)),console.log(u.dim("ETIMEDOUT, ENOTFOUND), they're transient \u2014 try a different network or your")),console.log(u.dim("phone's hotspot, then re-run `npx klaudius@latest install`.")),i.blank()}h&&(console.log(u.dim(`Note: email outreach was skipped during setup. Once the install succeeds, ask ${m}`)),console.log(u.dim("to finish setting it up \u2014 your email details are saved in .env.")),i.blank()),console.log(u.dim("Stuck? Email hello@klaudius.dev with the last ~20 lines of the install output.")),i.blank();return}if(si(r,n,e.target),h){let p=r.aiAgent==="codex"?"Codex":"Claude Code";console.log(u.yellow("Email outreach is parked \u2014 the credential check didn't pass during setup.")),console.log(u.dim(`Your details are saved in .env. To finish it, ask ${p}:`)),console.log(u.cyan(' "Set up my email outreach. My details are in .env (EMAIL_*) but the')),console.log(u.cyan(" SMTP/IMAP check failed during init. Work out the right servers for my")),console.log(u.cyan(" provider, test them with scripts/gmail.py, fix .env, re-add email to")),console.log(u.cyan(" OUTREACH_CHANNELS and OUTREACH_PRIORITY, set OUTREACH_ENABLED=true,")),console.log(u.cyan(' and send a test email to my own address to confirm."')),r.outreachEnabled&&(r.outreachChannels??[]).length>0&&(i.blank(),console.log(u.yellow(`Note: your other channel(s) \u2014 ${(r.outreachChannels??[]).join(", ")} \u2014 are still live, so the pipeline WILL still pitch businesses.`))),i.blank()}}async function N(e,t){await st(e,{recursive:!0}),await it(G(e,".env"),Le(t),"utf-8"),t.aiAgent==="codex"?(await st(G(e,".codex"),{recursive:!0}),await it(G(e,".codex","config.toml"),De(t),"utf-8")):(await it(G(e,".mcp.json"),Me(t),"utf-8"),await ze(e,"supabase"))}async function Zo(e){try{(await at(e)).isDirectory()||(i.error(`Target exists but is not a directory: ${e}`),process.exit(1))}catch{return{kind:"fresh"}}let t=await dn(e),n=t.filter(c=>!c.startsWith(".DS_Store"));if(n.length===0)return{kind:"fresh"};let o=new Set([".env",".mcp.json",".claude",".codex"]),s=n.every(c=>o.has(c)),l=n.includes(".env"),a=t.includes(".klaudius");if(s&&l&&!a)return{kind:"partial",envPath:G(e,".env")};if(a&&l){let c=!0;try{c=!(await at(G(e,"node_modules"))).isDirectory()}catch{c=!0}return{kind:"scaffolded",nodeModulesMissing:c}}return{kind:"occupied",entries:n}}async function ei(e){i.blank(),i.warn(`Found a partial setup at ${u.bold(e)}.`),i.detail(`A previous init wrote ${u.bold(".env")} but didn't finish scaffolding.`),i.blank();let t=await E.select({message:`How would you like to proceed? ${u.dim("(\u2191 \u2193 arrow keys, then Enter)")}`,initialValue:"resume",options:[{value:"resume",label:"Resume \u2014 use my saved .env values, skip the wizard, retry validation"},{value:"redo",label:"Restart \u2014 walk through the wizard again (existing values pre-filled as defaults)"}]});return E.isCancel(t)&&(E.cancel("Setup cancelled. Existing .env left in place."),process.exit(0)),t}async function ti(e){if(e&&e.trim().length>0)return e;E.intro("Klaudius");let t=await E.text({message:"Enter your Klaudius license key",placeholder:"KLAU-XXXX-XXXX-XXXX-XXXX",validate:n=>n.trim().length===0?"Required. Check your purchase confirmation email.":void 0});return E.isCancel(t)&&(E.cancel("Setup cancelled. No files written."),process.exit(0)),t}function ni(e){let t=Xo(e);if(process.platform==="win32"){let n=t.toLowerCase();if(n.startsWith("c:\\windows\\"))return"Inside C:\\Windows (Windows system directory).";if(n.startsWith("c:\\program files\\"))return"Inside C:\\Program Files (Windows protected directory).";if(n.startsWith("c:\\program files (x86)\\"))return"Inside C:\\Program Files (x86) (Windows protected directory).";if(n.startsWith("c:\\programdata\\"))return"Inside C:\\ProgramData (Windows protected directory)."}else{let n=["/System/","/usr/","/bin/","/sbin/"];for(let o of n)if(t.startsWith(o))return`Inside ${o.slice(0,-1)} (system-managed directory).`}}function oi(){if(process.platform!=="win32")return!1;try{return rt("net",["session"],{stdio:"ignore",windowsHide:!0}).status===0}catch{return!1}}function ii(){switch(process.platform){case"win32":return"https://www.python.org/downloads/windows/";case"darwin":return"https://www.python.org/downloads/macos/";default:return"https://www.python.org/downloads/"}}function si(e,t,n){let o=e.aiAgent==="codex"?"codex":"claude",s=e.aiAgent==="codex"?"Codex":"Claude Code";if(E.outro(u.green(u.bold("Project ready."))),console.log(u.bold("Next steps:")),i.blank(),t!==process.cwd()&&n){let l=`cd ${qe(n)}`;console.log(` ${u.cyan(l)}${" ".repeat(Math.max(1,27-l.length))}${u.dim("# go into your project folder")}`)}console.log(` ${u.cyan(o)}${" ".repeat(Math.max(1,27-o.length))}${u.dim(`# opens ${s} in this project`)}`),i.blank(),console.log(u.bold(`Some starter prompts for ${s}:`)),i.blank(),console.log(` ${u.cyan(`"Run klaudius doctor and fix anything that's missing or broken, so`)}`),console.log(` ${u.cyan(`I know I'm ready to start using Klaudius."`)}`),i.blank(),console.log(` ${u.cyan('"Open DOCS.html in my browser so I can read the docs."')}`),i.blank(),console.log(` ${u.cyan('"Run the pipeline for one client."')}`),console.log(u.dim(e.outreachEnabled?" \u2192 finds a business, builds their site, deploys it, and pitches them.":" \u2192 finds a business, builds their site, deploys it. Outreach is off \u2014 nothing is sent.")),i.blank(),e.aiAgent!=="codex"&&(console.log(u.dim("Prefer a more comfortable interface than a terminal? Claude Code also comes as")),console.log(u.dim("a desktop app \u2014 same tool, friendlier: https://code.claude.com/docs/en/setup")),i.blank())}import{access as ai,readFile as ri}from"fs/promises";import{join as lt,resolve as li}from"path";import D from"picocolors";async function fn(e){let t=e.target?li(process.cwd(),e.target):process.cwd(),n=await pn(lt(t,".env")),o=await pn(lt(t,"package.json"));(!n||!o)&&(i.error("This doesn't look like a Klaudius project."),i.detail(`Path: ${t}`),n||i.detail("Missing: .env"),o||i.detail("Missing: package.json"),i.blank(),i.detail("Run `npx klaudius@latest init` to scaffold a new project first,"),i.detail("or cd into an existing project directory and re-run this command."),process.exit(1));let s="claude-code";try{j(await ri(lt(t,".env"),"utf-8")).AI_AGENT==="codex"&&(s="codex")}catch{}i.heading("Installing dependencies");let l=await We(t);i.blank(),i.detail(`npm: ${l.npm}, pip: ${l.pip}, playwright: ${l.playwright}, patchright: ${l.patchright}`);let a=[];if(l.npm==="failed"&&a.push("npm"),l.pip==="failed"&&a.push("pip"),l.playwright==="failed"&&a.push("playwright"),l.patchright==="failed"&&a.push("patchright"),a.length===0){i.blank(),console.log(D.green(D.bold("All dependencies installed."))),console.log(D.dim("Run `npx klaudius@latest doctor` to verify everything else (credentials, files).")),i.blank();return}i.blank(),console.log(D.yellow(D.bold(`${a.join(", ")} still failing.`))),i.blank();for(let[r,y]of Object.entries(l.hints??{}))console.log(D.yellow(`Likely cause of ${r} failure:`)),console.log(D.dim(` ${y}`)),i.blank();let c=s==="codex"?"codex":"claude",d=s==="codex"?"Codex":"Claude Code",f=s==="codex"?"npm install -g @openai/codex":"npm install -g @anthropic-ai/claude-code";console.log(D.dim("Options:")),console.log(D.dim(` \u2022 Open ${d} in this folder (\`${c}\`) and paste:`)),console.log(D.cyan(` "Finish my Klaudius install \u2014 ${a.join(", ")} failed. Debug the install output, retry, then run npx klaudius@latest doctor."`)),console.log(D.dim(` (Don't have ${d} yet? Install with: \`${f}\`)`)),console.log(D.dim(" \u2022 Or run `npx klaudius@latest doctor` for a structured diagnostic.")),console.log(D.dim(" \u2022 Or email hello@klaudius.dev with the last ~20 lines of the install output above.")),i.blank(),process.exitCode=1}async function pn(e){try{return await ai(e),!0}catch{return!1}}import{readFile as ci,writeFile as ct,access as di}from"fs/promises";import{join as Pe}from"path";import*as W from"@clack/prompts";import Q from"picocolors";import{mkdir as ui}from"fs/promises";import{spawnSync as mn}from"child_process";async function hn(e){let t=e.projectRoot??process.cwd(),n=Pe(t,".env"),o=Pe(t,".mcp.json"),s=Pe(t,".codex","config.toml"),l=await dt(Pe(t,".klaudius","manifest.json")),a=await dt(n);!l&&!a&&(i.error("This doesn't look like a Klaudius project."),i.detail("Expected `.klaudius/manifest.json` or `.env` in this folder. Run `npx klaudius@latest init` first."),process.exit(1));let c=ne();c.ok||(i.error(c.message??"Node.js version check failed."),i.blank(),i.detail("Once you've installed Node.js 22.15+, re-run `npx klaudius@latest configure` in this folder."),process.exit(1));let d={};try{let k=await ci(n,"utf-8");d=j(k)}catch{i.warn("No .env found. Starting from an empty configuration.")}let f=vt(d);Object.keys(d).length>0&&(f.pipelineModes??=["classic"]),W.intro("Reconfigure Klaudius"),i.detail("Press Enter on any prompt to keep its current value."),i.blank();let r=await R(f),y=f.aiAgent??"claude-code";if(r.aiAgent&&r.aiAgent!==y&&(i.error(`Switching AI coding agent (${y} \u2192 ${r.aiAgent}) isn't supported via configure.`),i.detail("configure only rewrites .env / MCP config \u2014 it doesn't restructure the scaffolded files. To switch, run:"),i.blank(),console.log(` ${Q.cyan("npx klaudius@latest init <new-folder>")} ${Q.dim("# pick the new agent in the wizard")}`),i.blank(),i.detail(".env is unchanged."),process.exit(1)),r.supabaseUrl!==d.SUPABASE_URL||r.supabaseServiceKey!==d.SUPABASE_SERVICE_KEY){i.heading("Re-validating Supabase credentials");let k=await ke({url:r.supabaseUrl,serviceKey:r.supabaseServiceKey});k.ok||(i.error(k.message??"Supabase check failed"),i.warn("Aborting. .env not modified."),process.exit(1)),i.success("Supabase credentials accepted")}let h=te(r.googlePlacesApiKey??"");if(h.changed&&r.googlePlacesApiKey){i.heading("Checking your Google Places API key");let k=await we(r.googlePlacesApiKey);if(k.ok){if(h.repairs.length>0){i.warn("Corrected look-alike characters in your Google Places API key:");for(let T of h.repairs)i.detail(` ${T}`);i.detail("These come from keys that were transcribed rather than copied.")}r.googlePlacesApiKey=h.value,i.success("Google accepted the key \u2014 writing the corrected value to .env")}else i.error(k.message??"Google rejected the Google Places API key"),i.warn("Writing the key exactly as you entered it \u2014 nothing has been guessed on your behalf."),i.detail("Re-run `npx klaudius@latest configure` with a key copied straight from the Cloud Console's copy button.")}if(pi(r,d)){let k=W.spinner();k.start("Validating email credentials (SMTP + IMAP)");let T=r.emailProvider&&r.emailProvider!=="custom"?r.emailProvider:ue(r.emailSmtpHost),x=await ie({emailAddress:r.emailAddress,emailPassword:r.emailPassword,emailSmtpHost:r.emailSmtpHost,emailSmtpPort:r.emailSmtpPort,emailImapHost:r.emailImapHost,emailImapPort:r.emailImapPort,usesAccountPassword:T?K[T].usesAccountPassword:void 0});x.ok?k.stop("Email credentials accepted (SMTP + IMAP)"):(k.stop(x.message??"Email check failed",2),i.warn("Writing the email settings exactly as you entered them \u2014 not verified."),i.detail(x.failureKind==="network"?"This looks like a network/host problem, not a password problem \u2014 check the SMTP/IMAP hosts and your connection, then run `npx klaudius@latest doctor`.":"Run `npx klaudius@latest doctor` \u2014 it tries your provider's alternate regional servers and names the likely fix."))}if(await ct(n,Le(r),"utf-8"),i.success("Updated .env"),r.aiAgent==="codex"?(await ui(Pe(t,".codex"),{recursive:!0}),await ct(s,De(r),"utf-8"),i.success("Updated .codex/config.toml")):(await ct(o,Me(r),"utf-8"),i.success("Updated .mcp.json"),await ze(t,"supabase")),r.emailAuth==="oauth-microsoft"&&r.outreachEnabled&&r.outreachChannels?.includes("email")){let k=await B();if(!(k!==null&&mn(k.command[0],[...k.command.slice(1),"scripts/ms_oauth.py","status"],{cwd:t,encoding:"utf-8",timeout:6e4,windowsHide:!0}).status===0))if(i.blank(),!k)i.warn("Outlook mailbox not connected \u2014 no Python interpreter found to run the sign-in."),i.detail("Once Python is installed: python3 scripts/ms_oauth.py login");else{let x=await W.confirm({message:"Connect your Outlook / Microsoft 365 mailbox now? (one-time browser sign-in)",initialValue:!0});W.isCancel(x)||!x?i.detail(`Skipped. Connect it any time with: ${k.command.join(" ")} scripts/ms_oauth.py login`):mn(k.command[0],[...k.command.slice(1),"-u","scripts/ms_oauth.py","login"],{cwd:t,stdio:"inherit",timeout:39e5}).status===0?i.success("Outlook mailbox connected."):(i.warn("The Microsoft sign-in didn't complete."),i.detail(`Connect it any time with: ${k.command.join(" ")} scripts/ms_oauth.py login`))}}i.blank(),W.outro(Q.green("Configuration updated.")),await fi(t,l)}function pi(e,t){let n=[[e.emailAddress,"EMAIL_ADDRESS"],[e.emailPassword,"EMAIL_PASSWORD"],[e.emailSmtpHost,"EMAIL_SMTP_HOST"],[e.emailSmtpPort,"EMAIL_SMTP_PORT"],[e.emailImapHost,"EMAIL_IMAP_HOST"],[e.emailImapPort,"EMAIL_IMAP_PORT"]];return n.some(([o])=>o===void 0||o==="")?!1:n.some(([o,s])=>String(o)!==(t[s]??""))}async function fi(e,t){let n=await dt(Pe(e,"node_modules"));i.blank(),t?n||(i.detail("Your project files are in place but dependencies aren't installed yet."),i.detail("To finish setup, run:"),i.blank(),console.log(` ${Q.cyan("npx klaudius@latest install")} ${Q.dim("# (re-)installs npm + pip + browsers; idempotent")}`),i.blank(),i.detail("Then verify with:"),i.blank(),console.log(` ${Q.cyan("npx klaudius@latest doctor")} ${Q.dim("# checks Node / Python / installers / credentials")}`),i.blank()):(i.detail("Looks like a previous `klaudius init` saved your .env but didn't finish scaffolding."),i.detail("To finish setup, run:"),i.blank(),console.log(` ${Q.cyan("npx klaudius@latest init")} ${Q.dim("# pick Resume when prompted")}`),i.blank())}async function dt(e){try{return await di(e),!0}catch{return!1}}import{copyFile as gn,mkdir as yn,readFile as mi,rm as _e,writeFile as kn,access as wn}from"fs/promises";import{dirname as En,join as F}from"path";import{tmpdir as hi}from"os";import*as Te from"@clack/prompts";import ut from"picocolors";var Je="0.23.0";async function An(e){let t=e.projectRoot??process.cwd(),n=await Mt(t);n||(i.error("This doesn't look like a Klaudius project."),i.detail("Expected `.klaudius/manifest.json`. Run `npx klaudius@latest init` first."),process.exit(1));for(let w of He)delete n.files[w];let o,s=F(t,".env"),l,a;try{l=await mi(s,"utf-8"),a=j(l)}catch{i.error("Couldn't read .env from this directory."),i.detail("Are you running `klaudius update` from inside a Klaudius project?"),process.exit(1)}o=a.KLAUDIUS_LICENSE_KEY??"",o||(i.error("Couldn't find KLAUDIUS_LICENSE_KEY in your .env file."),i.detail("This file is created by `npx klaudius@latest init`. If your project predates"),i.detail("the licence-gated template (CLI version 0.1.x), re-run `npx klaudius@latest init`"),i.detail("in a sibling directory, then copy KLAUDIUS_LICENSE_KEY from its .env."),process.exit(1));let c=Ot(l,a,xt);c!==null&&(await kn(s,c,"utf-8"),i.detail("Backfilled new env keys")),await Ke("update",Je),Te.intro(`Update from ${n.templateVersion} \u2192 ${Je}`);let f=a.AI_AGENT==="codex"?"codex":"claude-code",r=F(hi(),`klaudius-update-${process.pid}-${Date.now()}`),y;try{i.heading("Downloading the latest Klaudius template");let w=await Fe({licenseKey:o,machineId:Se(),hostname:process.env.HOSTNAME??process.env.COMPUTERNAME,os:`${process.platform}-${process.arch}`,agent:f,destDir:r});i.success(`Fetched ${w.filesExtracted} canonical files`),y=r}catch(w){i.error(w.message),i.detail("Update aborted. Your project is unchanged."),await _e(r,{recursive:!0,force:!0}).catch(()=>{}),process.exit(1)}let h=await gi(y,t,n),k=h.filter(w=>w.state==="new"),T=h.filter(w=>w.state==="clean-update"),x=h.filter(w=>w.state==="user-only"),I=h.filter(w=>w.state==="conflict"),O=h.filter(w=>w.state==="no-change"),b=h.filter(w=>w.state==="locally-deleted"),L=h.filter(w=>w.state==="removed-clean"),z=h.filter(w=>w.state==="removed-modified"),P=[...I,...b,...z],q=n.ignored?.length??0;if(i.blank(),i.heading("Change summary"),i.detail(`${V(O.length,"file")} unchanged`),i.detail(`${V(k.length,"new file")}`),i.detail(`${V(T.length,"file")} updated cleanly (no local edits)`),i.detail(`${V(x.length,"file")} you've edited (no upstream change \u2014 left alone)`),i.detail(`${V(L.length,"file")} removed upstream (deleted cleanly)`),i.detail(`${V(I.length,"file")} with conflicts (you edited AND we have a new version)`),i.detail(`${V(b.length,"file")} you've deleted locally (canonical still ships them \u2014 need your decision)`),i.detail(`${V(z.length,"file")} removed upstream but edited locally (need your decision)`),q>0&&(i.detail(`${V(q,"file")} kept deleted (previously resolved \u2014 skipped)`),q<=10))for(let w of n.ignored)i.detail(` kept deleted: ${w}`);if(k.length===0&&T.length===0&&L.length===0&&P.length===0){i.blank(),Te.outro(ut.green("Already up to date.")),await _e(r,{recursive:!0,force:!0}).catch(()=>{});return}i.blank(),i.heading("Applying clean updates");for(let w of[...k,...T]){let J=F(y,w.path),ae=F(t,w.path);await yn(En(ae),{recursive:!0}),await gn(J,ae),n.files[w.path]=w.canonicalHash}k.length+T.length>0&&i.success(`Wrote ${V(k.length+T.length,"file")}`);for(let w of L){let J=F(t,w.path);await _e(J,{force:!0}),delete n.files[w.path]}if(L.length>0&&i.success(`Deleted ${V(L.length,"file")} removed upstream`),P.length>0){i.blank(),i.heading(`${P.length} conflict(s) need resolution`);let w=F(t,".klaudius","incoming");try{await _e(w,{recursive:!0,force:!0})}catch{}for(let J of[...I,...b]){let ae=F(y,J.path),p=F(w,J.path);await yn(En(p),{recursive:!0}),await gn(ae,p)}await kn(F(t,".klaudius","conflicts.md"),yi(P,n.templateVersion,Je),"utf-8"),I.length+b.length>0&&i.detail("Staged canonical versions to .klaudius/incoming/"),i.detail("Wrote conflict report to .klaudius/conflicts.md")}if(n.updatedAt=new Date().toISOString(),P.length===0&&(n.templateVersion=Je),await Ue(t,n),i.blank(),P.length===0)Te.outro(ut.green("Update complete."));else{let w=f==="codex"?"Codex":"Claude Code";Te.outro(ut.yellow(`${P.length} conflict(s) staged. Open ${w} in this project and ask:
|
|
90
|
-
"Run /resolve-conflicts"`))}await
|
|
91
|
-
`)}import{access as
|
|
92
|
-
`)),n.push(await
|
|
88
|
+
enter from any device.)`)),o.blank();let f=await z();if(f){let[h,...m]=f.command,A=dt(h,[...m,"-u","scripts/ms_oauth.py","login"],{cwd:n,stdio:"inherit",timeout:39e5});A.status===0?o.success("Outlook mailbox connected."):(o.blank(),console.log(p.yellow(`The Microsoft sign-in didn't complete (exit ${A.status??"signalled"}). Setup continues without it.`)),j(f))}else console.log(p.yellow("No Python interpreter found to run the sign-in. Setup continues without it.")),j(null)}else X&&!w&&(o.blank(),console.log(p.yellow("Skipping the Microsoft mailbox sign-in \u2014 Python dependencies aren't installed yet (pip failed earlier or was skipped).")),console.log(p.dim("Once `npx klaudius@latest install` completes successfully:")),console.log(p.cyan(" python3 scripts/ms_oauth.py login")));o.blank();let _=[...T,...C?["schema"]:[]];if(_.length>0){E.outro(p.yellow(p.bold(`Setup paused \u2014 ${_.join(", ")} failed.`))),console.log(p.dim("Your credentials and project files are all saved.")),o.blank();for(let[F,Ce]of Object.entries(M))console.log(p.yellow(`Likely cause of ${F} failure:`)),console.log(p.dim(` ${Ce}`)),o.blank();let f=n!==process.cwd()&&e.target?` ${p.cyan(`cd ${Xe(e.target)}`)}
|
|
89
|
+
`:"",h=a.aiAgent==="codex"?"codex":"claude",m=a.aiAgent==="codex"?"Codex":"Claude Code",A=a.aiAgent==="codex"?"npm install -g @openai/codex":"npm install -g @anthropic-ai/claude-code";T.length>0&&(console.log(p.dim(`Easiest fix \u2014 let ${m} finish it for you:`)),o.blank(),f&&process.stdout.write(f),console.log(` ${p.cyan(h)} ${p.dim(`# open ${m} in this folder`)}`),console.log(p.dim(" Then paste:")),console.log(p.cyan(` "Finish my Klaudius install \u2014 ${T.join(", ")} failed during setup. Debug the install output, retry, then run npx klaudius@latest doctor."`)),o.blank(),console.log(p.dim(` (Don't have ${m} yet? Install with: \`${A}\`)`)),o.blank(),console.log(p.dim("Or do it yourself:")),o.blank(),f&&process.stdout.write(f),console.log(` ${p.cyan("npx klaudius@latest install")} ${p.dim("# retry the failing installers")}`),console.log(` ${p.cyan("npx klaudius@latest doctor")} ${p.dim("# verify everything")}`),o.blank()),C&&(console.log(p.dim("For the schema failure specifically, apply scripts/schema.sql in the Supabase SQL editor:")),console.log(` ${p.cyan(v)}`),console.log(p.dim(" Open scripts/schema.sql, copy the contents, paste into the editor, click Run.")),o.blank()),T.includes("pip")&&!M.pip&&(console.log(p.dim("If pip fails again with a build error, check `python3 --version` \u2014 Klaudius needs")),console.log(p.dim(`Python 3.10+. Install a newer one from ${Ao()}`)),console.log(p.dim("and open a fresh Terminal before retrying.")),o.blank());let $=["npm","playwright","patchright"].filter(F=>T.includes(F)&&!M[F]);if($.length>0){let F=$.length===1?"keeps":"keep";console.log(p.dim(`If ${$.join(" / ")} ${F} failing with network errors (ECONNRESET,`)),console.log(p.dim("ETIMEDOUT, ENOTFOUND), they're transient \u2014 try a different network or your")),console.log(p.dim("phone's hotspot, then re-run `npx klaudius@latest install`.")),o.blank()}g&&(console.log(p.dim(`Note: email outreach was skipped during setup. Once the install succeeds, ask ${m}`)),console.log(p.dim("to finish setting it up \u2014 your email details are saved in .env.")),o.blank()),console.log(p.dim("Stuck? Email hello@klaudius.dev with the last ~20 lines of the install output.")),o.blank();return}if(Po(a,n,e.target),g){let f=a.aiAgent==="codex"?"Codex":"Claude Code";console.log(p.yellow("Email outreach is parked \u2014 the credential check didn't pass during setup.")),console.log(p.dim(`Your details are saved in .env. To finish it, ask ${f}:`)),console.log(p.cyan(' "Set up my email outreach. My details are in .env (EMAIL_*) but the')),console.log(p.cyan(" SMTP/IMAP check failed during init. Work out the right servers for my")),console.log(p.cyan(" provider, test them with scripts/gmail.py, fix .env, re-add email to")),console.log(p.cyan(" OUTREACH_CHANNELS and OUTREACH_PRIORITY, set OUTREACH_ENABLED=true,")),console.log(p.cyan(' and send a test email to my own address to confirm."')),a.outreachEnabled&&(a.outreachChannels??[]).length>0&&(o.blank(),console.log(p.yellow(`Note: your other channel(s) \u2014 ${(a.outreachChannels??[]).join(", ")} \u2014 are still live, so the pipeline WILL still pitch businesses.`))),o.blank()}}async function N(e,t){await lt(e,{recursive:!0}),await rt(B(e,".env"),Me(t),"utf-8"),t.aiAgent==="codex"?(await lt(B(e,".codex"),{recursive:!0}),await rt(B(e,".codex","config.toml"),He(t),"utf-8")):(await rt(B(e,".mcp.json"),De(t),"utf-8"),await Je(e,"supabase"))}async function go(e){try{(await ct(e)).isDirectory()||(o.error(`Target exists but is not a directory: ${e}`),process.exit(1))}catch{return{kind:"fresh"}}let t=await kn(e),n=t.filter(l=>!l.startsWith(".DS_Store"));if(n.length===0)return{kind:"fresh"};let s=new Set([".env",".mcp.json",".claude",".codex"]),i=n.every(l=>s.has(l)),r=n.includes(".env"),c=t.includes(".klaudius");if(i&&r&&!c)return{kind:"partial",envPath:B(e,".env")};if(c&&r){let l=!0;try{l=!(await ct(B(e,"node_modules"))).isDirectory()}catch{l=!0}return{kind:"scaffolded",nodeModulesMissing:l}}return{kind:"occupied",entries:n}}async function yo(e){o.blank(),o.warn(`Found a partial setup at ${p.bold(e)}.`),o.detail(`A previous init wrote ${p.bold(".env")} but didn't finish scaffolding.`),o.blank();let t=await E.select({message:`How would you like to proceed? ${p.dim("(\u2191 \u2193 arrow keys, then Enter)")}`,initialValue:"resume",options:[{value:"resume",label:"Resume \u2014 use my saved .env values, skip the wizard, retry validation"},{value:"redo",label:"Restart \u2014 walk through the wizard again (existing values pre-filled as defaults)"}]});return E.isCancel(t)&&(E.cancel("Setup cancelled. Existing .env left in place."),process.exit(0)),t}async function ko(e){if(e&&e.trim().length>0)return e;E.intro("Klaudius");let t=await E.text({message:"Enter your Klaudius license key",placeholder:"KLAU-XXXX-XXXX-XXXX-XXXX",validate:n=>n.trim().length===0?"Required. Check your purchase confirmation email.":void 0});return E.isCancel(t)&&(E.cancel("Setup cancelled. No files written."),process.exit(0)),t}function wo(e){let t=mo(e);if(process.platform==="win32"){let n=t.toLowerCase();if(n.startsWith("c:\\windows\\"))return"Inside C:\\Windows (Windows system directory).";if(n.startsWith("c:\\program files\\"))return"Inside C:\\Program Files (Windows protected directory).";if(n.startsWith("c:\\program files (x86)\\"))return"Inside C:\\Program Files (x86) (Windows protected directory).";if(n.startsWith("c:\\programdata\\"))return"Inside C:\\ProgramData (Windows protected directory)."}else{let n=["/System/","/usr/","/bin/","/sbin/"];for(let s of n)if(t.startsWith(s))return`Inside ${s.slice(0,-1)} (system-managed directory).`}}function Eo(){if(process.platform!=="win32")return!1;try{return dt("net",["session"],{stdio:"ignore",windowsHide:!0}).status===0}catch{return!1}}function Ao(){switch(process.platform){case"win32":return"https://www.python.org/downloads/windows/";case"darwin":return"https://www.python.org/downloads/macos/";default:return"https://www.python.org/downloads/"}}function Po(e,t,n){let s=e.aiAgent==="codex"?"codex":"claude",i=e.aiAgent==="codex"?"Codex":"Claude Code";if(E.outro(p.green(p.bold("Project ready."))),console.log(p.bold("Next steps:")),o.blank(),t!==process.cwd()&&n){let r=`cd ${Xe(n)}`;console.log(` ${p.cyan(r)}${" ".repeat(Math.max(1,27-r.length))}${p.dim("# go into your project folder")}`)}console.log(` ${p.cyan(s)}${" ".repeat(Math.max(1,27-s.length))}${p.dim(`# opens ${i} in this project`)}`),o.blank(),console.log(p.bold(`Some starter prompts for ${i}:`)),o.blank(),console.log(` ${p.cyan(`"Run klaudius doctor and fix anything that's missing or broken, so`)}`),console.log(` ${p.cyan(`I know I'm ready to start using Klaudius."`)}`),o.blank(),console.log(` ${p.cyan('"Open DOCS.html in my browser so I can read the docs."')}`),o.blank(),console.log(` ${p.cyan('"Run the pipeline for one client."')}`),console.log(p.dim(e.outreachEnabled?" \u2192 finds a business, builds their site, deploys it, and pitches them.":" \u2192 finds a business, builds their site, deploys it. Outreach is off \u2014 nothing is sent.")),o.blank(),e.aiAgent!=="codex"&&(console.log(p.dim("Prefer a more comfortable interface than a terminal? Claude Code also comes as")),console.log(p.dim("a desktop app \u2014 same tool, friendlier: https://code.claude.com/docs/en/setup")),o.blank())}import{access as bo,readFile as To}from"fs/promises";import{join as ut,resolve as So}from"path";import H from"picocolors";async function An(e){let t=e.target?So(process.cwd(),e.target):process.cwd(),n=await En(ut(t,".env")),s=await En(ut(t,"package.json"));(!n||!s)&&(o.error("This doesn't look like a Klaudius project."),o.detail(`Path: ${t}`),n||o.detail("Missing: .env"),s||o.detail("Missing: package.json"),o.blank(),o.detail("Run `npx klaudius@latest init` to scaffold a new project first,"),o.detail("or cd into an existing project directory and re-run this command."),process.exit(1));let i="claude-code";try{G(await To(ut(t,".env"),"utf-8")).AI_AGENT==="codex"&&(i="codex")}catch{}o.heading("Installing dependencies");let r=await qe(t);o.blank(),o.detail(`npm: ${r.npm}, pip: ${r.pip}, playwright: ${r.playwright}, patchright: ${r.patchright}`);let c=[];if(r.npm==="failed"&&c.push("npm"),r.pip==="failed"&&c.push("pip"),r.playwright==="failed"&&c.push("playwright"),r.patchright==="failed"&&c.push("patchright"),c.length===0){o.blank(),console.log(H.green(H.bold("All dependencies installed."))),console.log(H.dim("Run `npx klaudius@latest doctor` to verify everything else (credentials, files).")),o.blank();return}o.blank(),console.log(H.yellow(H.bold(`${c.join(", ")} still failing.`))),o.blank();for(let[a,y]of Object.entries(r.hints??{}))console.log(H.yellow(`Likely cause of ${a} failure:`)),console.log(H.dim(` ${y}`)),o.blank();let l=i==="codex"?"codex":"claude",d=i==="codex"?"Codex":"Claude Code",u=i==="codex"?"npm install -g @openai/codex":"npm install -g @anthropic-ai/claude-code";console.log(H.dim("Options:")),console.log(H.dim(` \u2022 Open ${d} in this folder (\`${l}\`) and paste:`)),console.log(H.cyan(` "Finish my Klaudius install \u2014 ${c.join(", ")} failed. Debug the install output, retry, then run npx klaudius@latest doctor."`)),console.log(H.dim(` (Don't have ${d} yet? Install with: \`${u}\`)`)),console.log(H.dim(" \u2022 Or run `npx klaudius@latest doctor` for a structured diagnostic.")),console.log(H.dim(" \u2022 Or email hello@klaudius.dev with the last ~20 lines of the install output above.")),o.blank(),process.exitCode=1}async function En(e){try{return await bo(e),!0}catch{return!1}}import{readFile as _o,writeFile as pt,access as Io}from"fs/promises";import{join as Pe}from"path";import*as q from"@clack/prompts";import Z from"picocolors";import{mkdir as Co}from"fs/promises";import{spawnSync as Pn}from"child_process";async function bn(e){let t=e.projectRoot??process.cwd(),n=Pe(t,".env"),s=Pe(t,".mcp.json"),i=Pe(t,".codex","config.toml"),r=await ft(Pe(t,".klaudius","manifest.json")),c=await ft(n);!r&&!c&&(o.error("This doesn't look like a Klaudius project."),o.detail("Expected `.klaudius/manifest.json` or `.env` in this folder. Run `npx klaudius@latest init` first."),process.exit(1));let l=se();l.ok||(o.error(l.message??"Node.js version check failed."),o.blank(),o.detail("Once you've installed Node.js 22.15+, re-run `npx klaudius@latest configure` in this folder."),process.exit(1));let d={};try{let k=await _o(n,"utf-8");d=G(k)}catch{o.warn("No .env found. Starting from an empty configuration.")}let u=Lt(d);Object.keys(d).length>0&&(u.pipelineModes??=["classic"]),q.intro("Reconfigure Klaudius"),o.detail("Press Enter on any prompt to keep its current value."),o.blank();let a=await O(u),y=u.aiAgent??"claude-code";if(a.aiAgent&&a.aiAgent!==y&&(o.error(`Switching AI coding agent (${y} \u2192 ${a.aiAgent}) isn't supported via configure.`),o.detail("configure only rewrites .env / MCP config \u2014 it doesn't restructure the scaffolded files. To switch, run:"),o.blank(),console.log(` ${Z.cyan("npx klaudius@latest init <new-folder>")} ${Z.dim("# pick the new agent in the wizard")}`),o.blank(),o.detail(".env is unchanged."),process.exit(1)),a.supabaseUrl!==d.SUPABASE_URL||a.supabaseServiceKey!==d.SUPABASE_SERVICE_KEY){o.heading("Re-validating Supabase credentials");let k=await ke({url:a.supabaseUrl,serviceKey:a.supabaseServiceKey});k.ok||(o.error(k.message??"Supabase check failed"),o.warn("Aborting. .env not modified."),process.exit(1)),o.success("Supabase credentials accepted")}let g=ne(a.googlePlacesApiKey??"");if(g.changed&&a.googlePlacesApiKey){o.heading("Checking your Google Places API key");let k=await we(a.googlePlacesApiKey);if(k.ok){if(g.repairs.length>0){o.warn("Corrected look-alike characters in your Google Places API key:");for(let b of g.repairs)o.detail(` ${b}`);o.detail("These come from keys that were transcribed rather than copied.")}a.googlePlacesApiKey=g.value,o.success("Google accepted the key \u2014 writing the corrected value to .env")}else o.error(k.message??"Google rejected the Google Places API key"),o.warn("Writing the key exactly as you entered it \u2014 nothing has been guessed on your behalf."),o.detail("Re-run `npx klaudius@latest configure` with a key copied straight from the Cloud Console's copy button.")}if(xo(a,d)){let k=q.spinner();k.start("Validating email credentials (SMTP + IMAP)");let b=a.emailProvider&&a.emailProvider!=="custom"?a.emailProvider:pe(a.emailSmtpHost),R=await ie({emailAddress:a.emailAddress,emailPassword:a.emailPassword,emailSmtpHost:a.emailSmtpHost,emailSmtpPort:a.emailSmtpPort,emailImapHost:a.emailImapHost,emailImapPort:a.emailImapPort,usesAccountPassword:b?V[b].usesAccountPassword:void 0});R.ok?k.stop("Email credentials accepted (SMTP + IMAP)"):(k.stop(R.message??"Email check failed",2),o.warn("Writing the email settings exactly as you entered them \u2014 not verified."),o.detail(R.failureKind==="network"?"This looks like a network/host problem, not a password problem \u2014 check the SMTP/IMAP hosts and your connection, then run `npx klaudius@latest doctor`.":"Run `npx klaudius@latest doctor` \u2014 it tries your provider's alternate regional servers and names the likely fix."))}if(await pt(n,Me(a),"utf-8"),o.success("Updated .env"),a.aiAgent==="codex"?(await Co(Pe(t,".codex"),{recursive:!0}),await pt(i,He(a),"utf-8"),o.success("Updated .codex/config.toml")):(await pt(s,De(a),"utf-8"),o.success("Updated .mcp.json"),await Je(t,"supabase")),a.emailAuth==="oauth-microsoft"&&a.outreachEnabled&&a.outreachChannels?.includes("email")){let k=await z();if(!(k!==null&&Pn(k.command[0],[...k.command.slice(1),"scripts/ms_oauth.py","status"],{cwd:t,encoding:"utf-8",timeout:6e4,windowsHide:!0}).status===0))if(o.blank(),!k)o.warn("Outlook mailbox not connected \u2014 no Python interpreter found to run the sign-in."),o.detail("Once Python is installed: python3 scripts/ms_oauth.py login");else{let R=await q.confirm({message:"Connect your Outlook / Microsoft 365 mailbox now? (one-time browser sign-in)",initialValue:!0});q.isCancel(R)||!R?o.detail(`Skipped. Connect it any time with: ${k.command.join(" ")} scripts/ms_oauth.py login`):Pn(k.command[0],[...k.command.slice(1),"-u","scripts/ms_oauth.py","login"],{cwd:t,stdio:"inherit",timeout:39e5}).status===0?o.success("Outlook mailbox connected."):(o.warn("The Microsoft sign-in didn't complete."),o.detail(`Connect it any time with: ${k.command.join(" ")} scripts/ms_oauth.py login`))}}o.blank(),q.outro(Z.green("Configuration updated.")),await Ro(t,r)}function xo(e,t){let n=[[e.emailAddress,"EMAIL_ADDRESS"],[e.emailPassword,"EMAIL_PASSWORD"],[e.emailSmtpHost,"EMAIL_SMTP_HOST"],[e.emailSmtpPort,"EMAIL_SMTP_PORT"],[e.emailImapHost,"EMAIL_IMAP_HOST"],[e.emailImapPort,"EMAIL_IMAP_PORT"]];return n.some(([s])=>s===void 0||s==="")?!1:n.some(([s,i])=>String(s)!==(t[i]??""))}async function Ro(e,t){let n=await ft(Pe(e,"node_modules"));o.blank(),t?n||(o.detail("Your project files are in place but dependencies aren't installed yet."),o.detail("To finish setup, run:"),o.blank(),console.log(` ${Z.cyan("npx klaudius@latest install")} ${Z.dim("# (re-)installs npm + pip + browsers; idempotent")}`),o.blank(),o.detail("Then verify with:"),o.blank(),console.log(` ${Z.cyan("npx klaudius@latest doctor")} ${Z.dim("# checks Node / Python / installers / credentials")}`),o.blank()):(o.detail("Looks like a previous `klaudius init` saved your .env but didn't finish scaffolding."),o.detail("To finish setup, run:"),o.blank(),console.log(` ${Z.cyan("npx klaudius@latest init")} ${Z.dim("# pick Resume when prompted")}`),o.blank())}async function ft(e){try{return await Io(e),!0}catch{return!1}}import{copyFile as Tn,mkdir as Sn,readFile as _n,rm as Ie,writeFile as In,access as Cn}from"fs/promises";import{dirname as xn,join as U}from"path";import{tmpdir as Oo}from"os";import*as be from"@clack/prompts";import mt from"picocolors";var Qe="0.23.2";async function Rn(e){let t=e.projectRoot??process.cwd(),n=await Ft(t);n||(o.error("This doesn't look like a Klaudius project."),o.detail("Expected `.klaudius/manifest.json`. Run `npx klaudius@latest init` first."),process.exit(1));for(let w of Ue)delete n.files[w];let s,i=U(t,".env"),r,c;try{r=await _n(i,"utf-8"),c=G(r)}catch{o.error("Couldn't read .env from this directory."),o.detail("Are you running `klaudius update` from inside a Klaudius project?"),process.exit(1)}s=c.KLAUDIUS_LICENSE_KEY??"",s||(o.error("Couldn't find KLAUDIUS_LICENSE_KEY in your .env file."),o.detail("This file is created by `npx klaudius@latest init`. If your project predates"),o.detail("the licence-gated template (CLI version 0.1.x), re-run `npx klaudius@latest init`"),o.detail("in a sibling directory, then copy KLAUDIUS_LICENSE_KEY from its .env."),process.exit(1));let l=Nt(r,c,$t);l!==null&&(await In(i,l,"utf-8"),o.detail("Backfilled new env keys")),await Ve("update",Qe),be.intro(`Update from ${n.templateVersion} \u2192 ${Qe}`);let u=c.AI_AGENT==="codex"?"codex":"claude-code",a=U(Oo(),`klaudius-update-${process.pid}-${Date.now()}`),y;try{o.heading("Downloading the latest Klaudius template");let w=await Ke({licenseKey:s,machineId:_e(),hostname:process.env.HOSTNAME??process.env.COMPUTERNAME,os:`${process.platform}-${process.arch}`,agent:u,destDir:a});o.success(`Fetched ${w.filesExtracted} canonical files`),y=a}catch(w){o.error(w.message),o.detail("Update aborted. Your project is unchanged."),await Ie(a,{recursive:!0,force:!0}).catch(()=>{}),process.exit(1)}let g=await vo(y,t,n),k=g.filter(w=>w.state==="new"),b=g.filter(w=>w.state==="clean-update"),R=g.filter(w=>w.state==="user-only"),C=g.filter(w=>w.state==="conflict"),v=g.filter(w=>w.state==="no-change"),T=g.filter(w=>w.state==="locally-deleted"),M=g.filter(w=>w.state==="removed-clean"),J=g.filter(w=>w.state==="removed-modified"),P=[...C,...T,...J],X=n.ignored?.length??0;if(o.blank(),o.heading("Change summary"),o.detail(`${Y(v.length,"file")} unchanged`),o.detail(`${Y(k.length,"new file")}`),o.detail(`${Y(b.length,"file")} updated cleanly (no local edits)`),o.detail(`${Y(R.length,"file")} you've edited (no upstream change \u2014 left alone)`),o.detail(`${Y(M.length,"file")} removed upstream (deleted cleanly)`),o.detail(`${Y(C.length,"file")} with conflicts (you edited AND we have a new version)`),o.detail(`${Y(T.length,"file")} you've deleted locally (canonical still ships them \u2014 need your decision)`),o.detail(`${Y(J.length,"file")} removed upstream but edited locally (need your decision)`),X>0&&(o.detail(`${Y(X,"file")} kept deleted (previously resolved \u2014 skipped)`),X<=10))for(let w of n.ignored)o.detail(` kept deleted: ${w}`);if(k.length===0&&b.length===0&&M.length===0&&P.length===0){o.blank(),be.outro(mt.green("Already up to date.")),await Ie(a,{recursive:!0,force:!0}).catch(()=>{});return}o.blank(),o.heading("Applying clean updates");for(let w of[...k,...b]){let j=U(y,w.path),_=U(t,w.path);await Sn(xn(_),{recursive:!0}),await Tn(j,_),n.files[w.path]=w.canonicalHash}k.length+b.length>0&&o.success(`Wrote ${Y(k.length+b.length,"file")}`);for(let w of M){let j=U(t,w.path);await Ie(j,{force:!0}),delete n.files[w.path]}if(M.length>0&&o.success(`Deleted ${Y(M.length,"file")} removed upstream`),P.length>0){o.blank(),o.heading(`${P.length} conflict(s) need resolution`);let w=U(t,".klaudius","incoming");try{await Ie(w,{recursive:!0,force:!0})}catch{}for(let _ of[...C,...T]){let f=U(y,_.path),h=U(w,_.path);await Sn(xn(h),{recursive:!0}),await Tn(f,h)}let j=new Map;for(let _ of C){let f=await Jt(t,_.path),h=f!==null?await _n(U(y,_.path),"utf-8"):"";f!==null&&(it(f)||it(h))?j.set(_.path,["_Binary or non-text file \u2014 no text diff available. Compare your copy against the staged `.klaudius/incoming/"+_.path+"` directly._"]):f===null?j.set(_.path,["_No base snapshot on this install (it predates upstream-change summaries). This update saves one, so the next update can show exactly what changed._"]):_.manifestHash&&Dt(f)!==_.manifestHash?j.set(_.path,["_The base snapshot is newer than the version your edits diverged from (an earlier update's conflicts were left unresolved), so a precise upstream diff isn't available for this file \u2014 compare against `.klaudius/incoming/"+_.path+"` directly._"]):j.set(_.path,Xt(f,h))}await In(U(t,".klaudius","conflicts.md"),$o(P,n.templateVersion,Qe,j),"utf-8"),C.length+T.length>0&&o.detail("Staged canonical versions to .klaudius/incoming/"),o.detail("Wrote conflict report to .klaudius/conflicts.md")}n.updatedAt=new Date().toISOString(),P.length===0&&(n.templateVersion=Qe),await je(t,n);try{await Ge(t,y,await ce(y))}catch{o.detail("(couldn't save the base snapshot \u2014 next update's conflict summaries will be unavailable)")}if(o.blank(),P.length===0)be.outro(mt.green("Update complete."));else{let w=u==="codex"?"Codex":"Claude Code";be.outro(mt.yellow(`${P.length} conflict(s) staged. Open ${w} in this project and ask:
|
|
90
|
+
"Run /resolve-conflicts"`))}await Ie(a,{recursive:!0,force:!0}).catch(()=>{})}async function vo(e,t,n){let s=await ce(e),i=new Set(s),r=new Set(n.ignored??[]),c=[];for(let l of s){if(r.has(l))continue;let d=await ye(U(e,l)),u=n.files[l],a=U(t,l),y;try{await Cn(a),y=await ye(a)}catch{let g=u!==void 0&&!jt.has(l)?"locally-deleted":"new";c.push({path:l,state:g,canonicalHash:d,manifestHash:u});continue}d===u?y===u?c.push({path:l,state:"no-change",canonicalHash:d,localHash:y,manifestHash:u}):c.push({path:l,state:"user-only",canonicalHash:d,localHash:y,manifestHash:u}):y===u?c.push({path:l,state:"clean-update",canonicalHash:d,localHash:y,manifestHash:u}):c.push({path:l,state:"conflict",canonicalHash:d,localHash:y,manifestHash:u})}for(let l of Object.keys(n.files)){if(i.has(l))continue;let d=n.files[l],u=U(t,l),a;try{await Cn(u),a=await ye(u)}catch{delete n.files[l];continue}a===d?c.push({path:l,state:"removed-clean",localHash:a,manifestHash:d}):c.push({path:l,state:"removed-modified",localHash:a,manifestHash:d})}return c}function Y(e,t){return`${e} ${t}${e===1?"":"s"}`}function $o(e,t,n,s=new Map){let i=e.filter(u=>u.state==="conflict").length,r=e.filter(u=>u.state==="locally-deleted").length,c=e.filter(u=>u.state==="removed-modified").length,l=[];l.push("# Update Conflicts"),l.push(""),l.push(`Generated by \`npx klaudius@latest update\` on ${new Date().toISOString()}.`),l.push(`Updating from canonical version **${t}** to **${n}**.`),l.push("");let d=[];i>0&&d.push(`${i} file${i===1?"":"s"} ha${i===1?"s":"ve"} BOTH local edits AND upstream changes`),r>0&&d.push(`${r} file${r===1?"":"s"} you deleted locally ${r===1?"is":"are"} still shipped by the canonical template`),c>0&&d.push(`${c} file${c===1?"":"s"} ${c===1?"was":"were"} removed upstream but edited locally`),l.push(d.join(", and ")+"."),l.push("Open Claude Code in this project and run `/resolve-conflicts` \u2014 that skill walks through each conflict interactively, helping you decide what to keep, take, merge, or delete."),l.push(""),l.push("---"),l.push("");for(let u of e){if(l.push(`## ${u.path}`),l.push(""),u.state==="locally-deleted")l.push("**Type:** Deleted locally"),l.push(""),l.push("- You deleted this file after it was installed; the canonical template still ships it."),l.push(`- New canonical version staged at: \`.klaudius/incoming/${u.path}\``),l.push(`- Hash at last install/update: \`${(u.manifestHash??"(none)").slice(0,16)}\``),l.push(`- New canonical hash: \`${(u.canonicalHash??"(none)").slice(0,16)}\``),l.push(""),l.push("**Resolution options for the SKILL to walk through:**"),l.push(""),l.push("1. Restore \u2014 copy the canonical version back into place"),l.push("2. Keep deleted \u2014 never reinstall this file (recorded in the manifest's ignore list)");else if(u.state==="removed-modified")l.push("**Type:** Removed upstream"),l.push(""),l.push(`- Your local copy: \`${u.path}\``),l.push("- This file no longer exists in the canonical template."),l.push("- You've modified it locally since install."),l.push(`- Hash at last install/update: \`${(u.manifestHash??"(none)").slice(0,16)}\``),l.push(`- Your local hash now: \`${(u.localHash??"(missing)").slice(0,16)}\``),l.push(""),l.push("**Resolution options for the SKILL to walk through:**"),l.push(""),l.push("1. Keep mine \u2014 leave the file in place; stop tracking it in the manifest"),l.push("2. Delete \u2014 remove the file from disk and from the manifest");else{l.push("**Type:** Edit conflict"),l.push(""),l.push(`- Your version (with your local edits): \`${u.path}\``),l.push(`- New canonical version: \`.klaudius/incoming/${u.path}\``),l.push(`- Hash at last install/update: \`${(u.manifestHash??"(none)").slice(0,16)}\``),l.push(`- Your local hash now: \`${(u.localHash??"(missing)").slice(0,16)}\``),l.push(`- New canonical hash: \`${(u.canonicalHash??"(none)").slice(0,16)}\``);let a=s.get(u.path);a&&a.length>0&&(l.push(""),l.push("**What upstream changed since your base:**"),l.push(""),l.push(...a),l.push(""),l.push("_If your local edits don't touch the hunks above, merging is mechanical: take the canonical version and re-apply your edits (or apply the hunks to your copy). If they overlap, compare both versions properly before choosing._")),l.push(""),l.push("**Resolution options for the SKILL to walk through:**"),l.push(""),l.push("1. Keep mine \u2014 discard the new canonical changes"),l.push("2. Take canonical \u2014 overwrite my edits with the new version"),l.push("3. Merge \u2014 review both side-by-side and produce a combined version")}l.push(""),l.push("---"),l.push("")}return l.join(`
|
|
91
|
+
`)}import{existsSync as No}from"fs";import{access as Lo,readFile as On,stat as Mo}from"fs/promises";import{homedir as Do}from"os";import{join as W}from"path";import L from"picocolors";import{spawn as vn,spawnSync as Ho}from"child_process";async function $n(e){let t=e.projectRoot??process.cwd(),n=[];console.log(L.bold(`Klaudius doctor \u2014 checking your project\u2026
|
|
92
|
+
`)),n.push(await Uo()),n.push(await jo());let s=W(t,".env"),i=W(t,".klaudius","manifest.json"),r=W(t,".mcp.json"),c=W(t,".codex","config.toml"),l=await ee(s),d=await ee(i),u="claude-code";if(l)try{G(await On(s,"utf-8")).AI_AGENT==="codex"&&(u="codex")}catch{}if(u==="claude-code"){let g=await ee(W(t,"AGENTS.md")),k=!await ee(W(t,".claude"));g&&k&&(u="codex")}if(n.push({name:".env present",status:l?"ok":"fail",detail:l?s:"missing",nextAction:l?void 0:"Run `npx klaudius@latest init` in this folder."}),n.push({name:"Template scaffolded (.klaudius/manifest.json)",status:d?"ok":"fail",detail:d?i:"missing",nextAction:d?void 0:l?"Init didn't finish \u2014 run `npx klaudius@latest init` and pick Resume.":"Run `npx klaudius@latest init`."}),u==="codex"){let g=await ee(c);n.push({name:".codex/config.toml present",status:g?"ok":"warn",detail:g?c:"missing",nextAction:g?void 0:"Run `npx klaudius@latest configure` to regenerate."})}else{let g=await ee(r);n.push({name:".mcp.json present",status:g?"ok":"warn",detail:g?r:"missing",nextAction:g?void 0:"Run `npx klaudius@latest configure` to regenerate."})}if(n.push(await qo(u)),process.platform==="win32"){let g=await Fo(t);g&&n.push(g)}if(n.push(await Ko(t)),n.push(await Go(t)),n.push(await Vo()),!l)n.push({name:"Credential validations",status:"skip",detail:".env missing"});else if(e.offline)n.push({name:"Credential validations",status:"skip",detail:"--offline set"});else{let g=await On(s,"utf-8"),k=G(g);await Bo(k,n,t)}console.log();for(let g of n){let k=g.status==="ok"?L.green("\u2713"):g.status==="warn"?L.yellow("\u26A0"):g.status==="skip"?L.dim("\xB7"):L.red("\u2717");console.log(` ${k} ${g.name}${g.detail?L.dim(` \u2014 ${g.detail}`):""}`),g.nextAction&&console.log(` ${L.dim("\u2192")} ${L.cyan(g.nextAction)}`)}let a=n.filter(g=>g.status==="fail").length,y=n.filter(g=>g.status==="warn").length;console.log(),a===0&&y===0?console.log(L.green(L.bold("Everything checks out. You're good to go."))):a===0?console.log(L.yellow(L.bold(`${y} warning${y===1?"":"s"} \u2014 review above.`))):(console.log(L.red(L.bold(`${a} failed check${a===1?"":"s"} \u2014 see the \u2192 next actions above.`))),process.exitCode=1),console.log()}async function ee(e){try{return await Lo(e),!0}catch{return!1}}async function Uo(){let e=await ge();return e.ok?{name:"Python \u2265 3.10",status:"ok",detail:e.version}:{name:"Python \u2265 3.10",status:"fail",detail:e.version??"not found",nextAction:"Install Python 3.10+ from https://www.python.org/downloads/"}}async function jo(){let e=process.version,t=/^v(\d+)\.(\d+)\.(\d+)$/.exec(e);if(!t)return{name:"Node \u2265 22.15",status:"warn",detail:e};let n=parseInt(t[1],10),s=parseInt(t[2],10);return n<22||n===22&&s<15?{name:"Node \u2265 22.15",status:"fail",detail:e,nextAction:"Upgrade Node.js to 22.15+ from https://nodejs.org/"}:{name:"Node \u2265 22.15",status:"ok",detail:e}}async function Fo(e){let t=fe([{label:"your Windows user folder",path:Do()},{label:"the project folder",path:e}]);if(t.length===0)return null;let n="Install path safe for npm builds",s=await ht("npm",["config","get","script-shell"],!0),i=s.code===0?s.stdout.trim():void 0;if(me(i,No))return{name:n,status:"ok",detail:`${t[0].label} contains ${t[0].chars.map(d=>`"${d}"`).join(", ")}, but npm's script-shell (${i}) handles it`};let{detail:r,action:c}=he(t,"doctor"),l=t.some(d=>d.chars.includes("&"));return{name:n,status:l?"fail":"warn",detail:r,nextAction:c}}async function Ko(e){let t=W(e,"node_modules");if(!await ee(t))return{name:"node_modules installed",status:"fail",detail:"missing",nextAction:"Run `npx klaudius@latest install` in this folder."};try{if(!(await Mo(t)).isDirectory())return{name:"node_modules installed",status:"warn",detail:"exists but isn't a directory"}}catch{}return{name:"node_modules installed",status:"ok"}}async function Go(e){let t=process.platform==="darwin"?W(process.env.HOME??"","Library","Caches","ms-playwright"):process.platform==="win32"?W(process.env.USERPROFILE??"","AppData","Local","ms-playwright"):W(process.env.HOME??"",".cache","ms-playwright");return await ee(t)?{name:"Playwright browser installed",status:"ok",detail:t}:{name:"Playwright browser installed",status:"fail",detail:"no browser cache found",nextAction:"Run `npx playwright install chromium` in this folder."}}async function Vo(){let e=["supabase","dotenv","requests","httpx","PIL"],t=`import sys
|
|
93
93
|
try:
|
|
94
|
-
${e.map(
|
|
94
|
+
${e.map(r=>` import ${r}`).join(`
|
|
95
95
|
`)}
|
|
96
96
|
except Exception as e:
|
|
97
97
|
print(str(e))
|
|
98
98
|
sys.exit(1)
|
|
99
|
-
`,n=await
|
|
100
|
-
`).pop()??"import failed",nextAction:"Run `npx klaudius@latest install` in this folder."}}async function
|
|
101
|
-
`)[0]?.slice(0,200)||"Microsoft sign-in is missing or expired",nextAction:
|
|
102
|
-
`)[0]}:{name:n,status:"warn",detail:"not found",nextAction:
|
|
103
|
-
`));let
|
|
104
|
-
If you haven't already, add '${
|
|
105
|
-
WHATSAPP_ACCOUNTS=primary,${
|
|
106
|
-
(Skip this if '${
|
|
99
|
+
`,n=await z();if(!n)return{name:"Python packages installed",status:"fail",detail:"no Python interpreter found (tried python3, python, py -3)",nextAction:"Fix the Python check above first \u2014 the packages live inside that interpreter."};let s=n.command,i=await ht(s[0],[...s.slice(1),"-c",t]);return i.code===0?{name:"Python packages installed",status:"ok",detail:e.join(", ")}:{name:"Python packages installed",status:"fail",detail:(i.stdout||i.stderr).trim().split(`
|
|
100
|
+
`).pop()??"import failed",nextAction:"Run `npx klaudius@latest install` in this folder."}}async function Bo(e,t,n){if(e.SUPABASE_URL&&e.SUPABASE_SERVICE_KEY){let c=await ke({url:e.SUPABASE_URL,serviceKey:e.SUPABASE_SERVICE_KEY});t.push({name:"Supabase credentials",status:c.ok?"ok":"fail",detail:c.ok?"connected":c.message,nextAction:c.ok?void 0:"Run `npx klaudius@latest configure` to fix the URL or key."})}else t.push({name:"Supabase credentials",status:"fail",detail:"missing in .env"});let s=e.DEPLOY_PROVIDER==="cloudflare"?"cloudflare":e.DEPLOY_PROVIDER==="netlify"?"netlify":e.DEPLOY_PROVIDER==="selfhost"?"selfhost":"vercel";if(s==="selfhost"){let c=e.SELFHOST_DEPLOY_TARGET??"",l=e.SELFHOST_URL_TEMPLATE??"",d=[],u=Re(c);u&&d.push(`SELFHOST_DEPLOY_TARGET: ${u}`);let a=Oe(l);a&&d.push(`SELFHOST_URL_TEMPLATE: ${a}`),t.push({name:"Self-host deploy config",status:d.length===0?"ok":"fail",detail:d.length===0?`target ${c} (SSH reachability tested at first deploy)`:d.join("; "),nextAction:d.length===0?void 0:"Run `npx klaudius@latest configure` and fix the self-host deployment answers."})}else if(s==="cloudflare")if(e.CLOUDFLARE_API_TOKEN&&e.CLOUDFLARE_ACCOUNT_ID){let c=await Ye({token:e.CLOUDFLARE_API_TOKEN,accountId:e.CLOUDFLARE_ACCOUNT_ID});t.push({name:"Cloudflare token + account",status:c.ok?"ok":"fail",detail:c.ok?`valid (${c.projectCount??0} Pages project${c.projectCount===1?"":"s"})`:c.message,nextAction:c.ok?void 0:"Fix the token/account at https://dash.cloudflare.com/profile/api-tokens, then `npx klaudius@latest configure`."})}else t.push({name:"Cloudflare token + account",status:"fail",detail:"CLOUDFLARE_API_TOKEN and/or CLOUDFLARE_ACCOUNT_ID missing in .env",nextAction:"Run `npx klaudius@latest configure` and pick Cloudflare."});else if(s==="netlify")if(e.NETLIFY_AUTH_TOKEN){let c=await We({token:e.NETLIFY_AUTH_TOKEN});t.push({name:"Netlify token",status:c.ok?"ok":"fail",detail:c.ok?c.accountSlug?`valid (team: ${c.accountSlug})`:"valid":c.message,nextAction:c.ok?void 0:"Fix the token at https://app.netlify.com/user/applications#personal-access-tokens, then `npx klaudius@latest configure`."})}else t.push({name:"Netlify token",status:"fail",detail:"NETLIFY_AUTH_TOKEN missing in .env",nextAction:"Run `npx klaudius@latest configure` and pick Netlify."});else if(e.VERCEL_TOKEN){let c=await Be(e.VERCEL_TOKEN);t.push({name:"Vercel token",status:c.ok?"ok":"fail",detail:c.ok?c.username??"valid":c.message,nextAction:c.ok?void 0:"Generate a new token at https://vercel.com/account/tokens, then `npx klaudius@latest configure`."})}else t.push({name:"Vercel token",status:"fail",detail:"missing in .env"});if(e.GOOGLE_PLACES_API_KEY){let c=await we(e.GOOGLE_PLACES_API_KEY),l=ne(e.GOOGLE_PLACES_API_KEY);c.ok&&l.changed?t.push({name:"Google Places API key",status:"fail",detail:"The key works, but the copy stored in .env is not the key we had to send \u2014 "+(l.repairs.length>0?`it contains look-alike characters (${l.repairs.join("; ")}). `:"it contains invisible or stray characters. ")+"The pipeline's scripts read .env directly and will fail on it.",nextAction:"Run `npx klaudius@latest configure` and press Enter through the prompts \u2014 it rewrites .env with the corrected key."}):t.push({name:"Google Places API key",status:c.ok?"ok":"fail",detail:c.ok?"accepted":c.message,nextAction:c.ok?void 0:"Fix the key in https://console.cloud.google.com and `npx klaudius@latest configure`."})}else t.push({name:"Google Places API key",status:"warn",detail:"not set (find skill will fail until you add one)"});t.push(await zo(e,n));let i=(e.NOTIFY_CHANNEL??"").toLowerCase(),r=i==="email"||i==="sms"||i==="none"||i==="off"?i:"telegram";if(r==="none"||r==="off")t.push({name:"Notifications",status:"skip",detail:"disabled (NOTIFY_CHANNEL=none)"});else if(r==="email"){let c=e.NOTIFY_TO||e.EMAIL_ADDRESS;t.push({name:"Notifications (email)",status:c&&e.EMAIL_ADDRESS?"ok":"fail",detail:c&&e.EMAIL_ADDRESS?`alerts go to ${c}`:"NOTIFY_CHANNEL=email but no NOTIFY_TO/EMAIL_ADDRESS (or email account) in .env",nextAction:c&&e.EMAIL_ADDRESS?void 0:"Run `npx klaudius@latest configure` and redo the notifications step."})}else if(r==="sms"){let c=e.NOTIFY_TO||e.TEST_PHONE,l=e.SMS_PROVIDER==="twilio"?!!(e.TWILIO_ACCOUNT_SID&&e.TWILIO_AUTH_TOKEN&&e.TWILIO_PHONE_NUMBER):!0;t.push({name:"Notifications (SMS)",status:c&&l?"ok":"fail",detail:c&&l?`alerts go to ${c} via ${e.SMS_PROVIDER==="twilio"?"Twilio":"iMessage"}`:c?"NOTIFY_CHANNEL=sms with SMS_PROVIDER=twilio but Twilio credentials incomplete":"NOTIFY_CHANNEL=sms but no NOTIFY_TO/TEST_PHONE in .env",nextAction:c&&l?void 0:"Run `npx klaudius@latest configure` and redo the notifications step."})}else if(e.TELEGRAM_BOT_TOKEN&&e.TELEGRAM_CHAT_ID){let c=await Et({botToken:e.TELEGRAM_BOT_TOKEN});t.push({name:"Telegram bot token",status:c.ok?"ok":"fail",detail:c.ok?`bot ${c.botHandle??"ok"} (chat_id not tested)`:c.message,nextAction:c.ok?void 0:"Fix TELEGRAM_BOT_TOKEN in .env (or blank both Telegram lines to disable)."})}else e.TELEGRAM_BOT_TOKEN||e.TELEGRAM_CHAT_ID?t.push({name:"Telegram credentials",status:"warn",detail:"partial config (one of bot token / chat ID set, other missing)",nextAction:"Either set both, or blank both to disable Telegram notifications."}):t.push({name:"Notifications",status:"skip",detail:"not configured (optional)"})}function Yo(e){let t=r=>!!r&&/^\d+$/.test(r.trim()),n=Nn(e)?!!e.EMAIL_ADDRESS:!!e.EMAIL_ADDRESS&&!!e.EMAIL_PASSWORD&&!!e.EMAIL_SMTP_HOST&&t(e.EMAIL_SMTP_PORT)&&!!e.EMAIL_IMAP_HOST&&t(e.EMAIL_IMAP_PORT),s=(e.OUTREACH_CHANNELS??"").split(",").map(r=>r.trim()),i=e.OUTREACH_ENABLED?.toLowerCase()==="true"&&s.includes("email");return i&&n?"active":i?"incomplete":n?"parked":"unconfigured"}function Nn(e){return(e.EMAIL_AUTH??"").trim().toLowerCase()==="oauth-microsoft"}async function Wo(e){let t="Email account (Microsoft sign-in)",n=await z(),i=`Run \`${n?n.command.join(" "):"python3"} scripts/ms_oauth.py login\` from the project folder.`;if(n){let[c,...l]=n.command,d=Ho(c,[...l,"scripts/ms_oauth.py","status"],{cwd:e,encoding:"utf-8",timeout:6e4,windowsHide:!0}),u=`${d.stdout??""}${d.stderr??""}`.trim();if(d.status===0){let a=/signed in as (\S+)/.exec(u)?.[1];return{name:t,status:"ok",detail:a?`signed in as ${a} (token refresh works)`:"signed in (token refresh works)"}}return{name:t,status:"fail",detail:u.split(`
|
|
101
|
+
`)[0]?.slice(0,200)||"Microsoft sign-in is missing or expired",nextAction:i}}return await ee(W(e,".ms-token.json"))?{name:t,status:"warn",detail:"token cache present, but no Python found to verify it"}:{name:t,status:"fail",detail:"no Microsoft sign-in found (.ms-token.json missing)",nextAction:i}}async function zo(e,t){let n="Email credentials (SMTP + IMAP)",s=Yo(e);if(s==="unconfigured")return{name:n,status:"skip",detail:"not configured (email isn't an outreach channel)"};if(Nn(e))return s==="parked"?{name:"Email account (Microsoft sign-in)",status:"warn",detail:"Outlook mailbox saved in .env but email isn't an active outreach channel (skipped during setup?)",nextAction:"Ask your AI agent to finish email setup \u2014 or run `npx klaudius@latest configure`."}:s==="incomplete"?{name:"Email account (Microsoft sign-in)",status:"fail",detail:"EMAIL_AUTH=oauth-microsoft but EMAIL_ADDRESS is missing from .env",nextAction:"Run `npx klaudius@latest configure` to re-enter the email details."}:Wo(t);if(s==="parked")return{name:n,status:"warn",detail:"saved in .env but email isn't an active outreach channel (skipped during setup?) \u2014 never verified",nextAction:"Ask your AI agent to finish email setup \u2014 or run `npx klaudius@latest configure`."};if(s==="incomplete"){let d=["EMAIL_ADDRESS","EMAIL_PASSWORD","EMAIL_SMTP_HOST","EMAIL_SMTP_PORT","EMAIL_IMAP_HOST","EMAIL_IMAP_PORT"].filter(u=>u.endsWith("_PORT")?!e[u]||!/^\d+$/.test(e[u].trim()):!e[u]);return{name:n,status:"fail",detail:`email is an active outreach channel but .env has missing or invalid ${d.join(", ")}`,nextAction:"Run `npx klaudius@latest configure` to re-enter the email details."}}let i=Le(e),r=i&&i!=="custom"?i:pe(e.EMAIL_SMTP_HOST),c={emailAddress:e.EMAIL_ADDRESS,emailPassword:e.EMAIL_PASSWORD,emailSmtpHost:e.EMAIL_SMTP_HOST,emailSmtpPort:parseInt(e.EMAIL_SMTP_PORT,10),emailImapHost:e.EMAIL_IMAP_HOST,emailImapPort:parseInt(e.EMAIL_IMAP_PORT,10),usesAccountPassword:r?V[r].usesAccountPassword:void 0},l=await ie(c);if(l.ok)return{name:n,status:"ok",detail:`authenticated (${e.EMAIL_SMTP_HOST})`};if(l.failureKind==="network")return{name:n,status:"fail",detail:l.message,nextAction:"This looks like a network/host problem, not a password problem \u2014 check EMAIL_SMTP_HOST/EMAIL_IMAP_HOST and your connection, then re-run doctor."};if(r){let d=xe(r,e.EMAIL_SMTP_HOST,e.EMAIL_IMAP_HOST);if(d.length>0){console.log(L.dim(` (email login rejected \u2014 probing ${V[r].label}'s other regional servers, up to ~10s each\u2026)`));let u=0;for(let y of d){let g=await ie({...c,emailSmtpHost:y.smtpHost,emailImapHost:y.imapHost});if(!g.ok&&g.failureKind!=="network"&&u++,g.ok)return{name:n,status:"fail",detail:`${e.EMAIL_SMTP_HOST} rejected the login \u2014 but the SAME login works on ${y.label} (${y.smtpHost}). Wrong regional server in .env.`,nextAction:`Set EMAIL_SMTP_HOST=${y.smtpHost} and EMAIL_IMAP_HOST=${y.imapHost} in .env (or ask your AI agent to).`}}let a=(l.message??"login rejected").split(/\.\s|\n/)[0];return u===0?{name:n,status:"fail",detail:`${a} \u2014 and none of the alternate servers were reachable either; this looks like a network problem`,nextAction:"Check your connection and re-run doctor before touching the password."}:{name:n,status:"fail",detail:`${a} \u2014 tried all ${V[r].label} regional servers; none accepted this login, so the server isn't the problem`,nextAction:r==="zoho"?"Generate a fresh app password (accounts.zoho.com \u2192 Security \u2192 App Passwords) \u2014 and note Zoho's FREE plan has no IMAP/SMTP (Mail Lite ~$1/mo unlocks it). Then `npx klaudius@latest configure`.":r==="titan"?'In Titan webmail check Settings \u2192 "Enable Titan on Other Apps" is ON and Two-Factor Authentication is OFF (Titan has no app passwords \u2014 2FA blocks third-party access entirely). Then `npx klaudius@latest configure`.':"Re-check the mailbox password (2FA accounts need an app password instead), then `npx klaudius@latest configure`."}}}return{name:n,status:"fail",detail:l.message,nextAction:"Run `npx klaudius@latest configure` and re-enter the email details."}}async function qo(e){let t=e==="codex"?"codex":"claude",n=e==="codex"?"Codex CLI on PATH":"Claude Code CLI on PATH",s=e==="codex"?"Install Codex with `npm install -g @openai/codex` (or your preferred installer).":"Install Claude Code with `npm install -g @anthropic-ai/claude-code`.",i=await ht(t,["--version"],process.platform==="win32");return i.code===0?{name:n,status:"ok",detail:(i.stdout||i.stderr).trim().split(`
|
|
102
|
+
`)[0]}:{name:n,status:"warn",detail:"not found",nextAction:s}}function ht(e,t,n=!1){return new Promise(s=>{let i=n?vn([e,...t].join(" "),{stdio:["ignore","pipe","pipe"],shell:!0}):vn(e,t,{stdio:["ignore","pipe","pipe"],shell:!1}),r="",c="";i.stdout?.on("data",l=>{r+=l.toString()}),i.stderr?.on("data",l=>{c+=l.toString()}),i.on("close",l=>s({code:l??1,stdout:r,stderr:c})),i.on("error",()=>s({code:1,stdout:r,stderr:c}))})}import{existsSync as Jo}from"fs";import{spawnSync as Xo}from"child_process";import{join as Qo,resolve as Zo}from"path";import D from"picocolors";async function Ln(e){let t=Zo(e.projectRoot??process.cwd()),n=Qo(t,"scripts","whatsapp.mjs");Jo(n)||(console.error(D.red("Couldn't find scripts/whatsapp.mjs in this directory.")),console.error(D.dim("Run this command from the root of a Klaudius project (the directory created by `npx klaudius@latest init`).")),console.error(D.dim(`Looked for: ${n}`)),process.exit(1));let s=(e.label??"primary").trim(),i=s.replace(/[^A-Za-z0-9_-]/g,"");i||(console.error(D.red(`Invalid label '${s}'. Use letters, digits, underscore, or hyphen only.`)),process.exit(1)),i!==s&&console.error(D.yellow(`Note: cleaned label '${s}' \u2192 '${i}' (filename-safe characters only).`)),console.log(D.cyan(`Pairing WhatsApp account '${i}'...`)),console.log(D.dim(`If a daemon is already running for this account, it will be stopped automatically before the QR prompt. After the pair completes, the next /outreach send for this account will respawn the daemon with the new auth.
|
|
103
|
+
`));let r=Xo(process.execPath,[n,"pair","--account",i],{cwd:t,stdio:"inherit"});if(r.status===0){console.log(D.green(`Paired '${i}'.`)),console.log(D.dim(`
|
|
104
|
+
If you haven't already, add '${i}' to WHATSAPP_ACCOUNTS in .env so /outreach round-robins to it. Example:
|
|
105
|
+
WHATSAPP_ACCOUNTS=primary,${i}
|
|
106
|
+
(Skip this if '${i}' is already there or you set it via the init wizard.)`));return}r.error?console.error(D.red(`Pair failed: ${r.error.message}`)):(console.error(D.red(`Pair did not complete (exit ${r.status??"signalled"}). Common causes:`)),console.error(D.dim(" - QR scan window timed out: re-run and scan promptly.")),console.error(D.dim(" - WhatsApp's 4-linked-device limit: open WhatsApp \u2192 Settings \u2192 Linked Devices, unlink an unused entry, then re-run.")),console.error(D.dim(` - Existing daemon couldn't be stopped: check the log at ~/.klaudius/whatsapp/${i}/daemon.log`))),process.exit(r.status??1)}import{spawnSync as ei}from"child_process";var gt="--use-system-ca";function Mn(){let e=process.env.NODE_OPTIONS??"";if(e.includes(gt)||!se().ok)return;let n=e?`${e} ${gt}`:gt,s=ei(process.execPath,[...process.execArgv,...process.argv.slice(1)],{env:{...process.env,NODE_OPTIONS:n},stdio:"inherit"});s.signal&&(process.kill(process.pid,s.signal),process.exit(1)),process.exit(s.status??1)}Mn();var ni="0.23.2",te=new ti;te.name("klaudius").description("Scaffold and maintain a Klaudius pipeline project").version(ni);te.command("preflight").description("Check this machine can run Klaudius (Node, Python, pip, npm, network) \u2014 no project or license needed. Safe for an AI assistant to run, fix, and re-run before init.").action(async()=>{try{await Ct({})}catch(e){console.error("preflight failed:",e.message),process.exit(1)}});te.command("init").description("Scaffold a new Klaudius project").argument("[target]","Directory to create (defaults to current directory)",".").option("--license <key>","License key (received in your purchase confirmation email)").option("--skip-install","Skip npm/pip/playwright installation").option("--skip-schema","Skip applying schema.sql to your Supabase project").action(async(e,t)=>{try{await wn({target:e,license:t.license,skipInstall:!!t.skipInstall,skipSchema:!!t.skipSchema})}catch(n){console.error("init failed:",n.message),process.exit(1)}});te.command("install").description("Re-run dependency installers against an already-scaffolded project (npm, pip, playwright, patchright)").argument("[target]","Project directory (defaults to current directory)").action(async e=>{try{await An({target:e})}catch(t){console.error("install failed:",t.message),process.exit(1)}});te.command("configure").description("Re-run the setup wizard with current values pre-filled").action(async()=>{try{await bn({})}catch(e){console.error("configure failed:",e.message),process.exit(1)}});te.command("update").description("Pull latest template; produce a conflicts report for any files you've modified").action(async()=>{try{await Rn({})}catch(e){console.error("update failed:",e.message),process.exit(1)}});te.command("doctor").description("Diagnose a broken install \u2014 env versions, files, installed deps, credentials").option("--offline","Skip credential validations that require network calls").action(async e=>{try{await $n({offline:!!e.offline})}catch(t){console.error("doctor failed:",t.message),process.exit(1)}});te.command("pair-whatsapp").description("Link a WhatsApp account to this project (or re-pair if it logged out)").option("--label <name>","Account label (default: primary). Should match a value in WHATSAPP_ACCOUNTS.","primary").action(async e=>{try{await Ln({label:e.label})}catch(t){console.error("pair-whatsapp failed:",t.message),process.exit(1)}});te.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "klaudius",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.2",
|
|
4
4
|
"description": "Scaffold and maintain a Klaudius project — an autonomous web agency pipeline that runs on Claude Code (find, build, deploy, outreach end-to-end).",
|
|
5
5
|
"homepage": "https://klaudius.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@clack/prompts": "^0.7.0",
|
|
37
37
|
"commander": "^12.1.0",
|
|
38
|
+
"diff": "^9.0.0",
|
|
38
39
|
"imapflow": "^1.3.3",
|
|
39
40
|
"ink": "^7.0.1",
|
|
40
41
|
"ink-text-input": "^6.0.0",
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"tar": "^7.5.13"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
48
|
+
"@types/diff": "^7.0.2",
|
|
47
49
|
"@types/node": "^20.14.0",
|
|
48
50
|
"@types/nodemailer": "^8.0.0",
|
|
49
51
|
"@types/react": "^19.2.14",
|