klaudius 0.23.2 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{a as S,f as re,g as ue,i as ce,l as de,m as ge,n as he,p as pe}from"./chunk-R2LC3ZRY.js";import{useEffect as pa,useMemo as ya,useRef as le,useState as B}from"react";import{Box as I,Text as x,useApp as ma,useInput as fa}from"ink";var Me=[{country:"the United Kingdom",code:"GB",language:"English",langCode:"en",aliases:["uk","united kingdom","great britain","britain","england","scotland","wales","northern ireland"]},{country:"Ireland",code:"IE",language:"English",langCode:"en"},{country:"France",code:"FR",language:"French",langCode:"fr"},{country:"Germany",code:"DE",language:"German",langCode:"de",aliases:["deutschland"]},{country:"Austria",code:"AT",language:"German",langCode:"de",aliases:["\xF6sterreich","osterreich"]},{country:"Switzerland",code:"CH",language:"German",langCode:"de",aliases:["schweiz","suisse","svizzera"]},{country:"Liechtenstein",code:"LI",language:"German",langCode:"de"},{country:"Luxembourg",code:"LU",language:"French",langCode:"fr",aliases:["l\xEBtzebuerg"]},{country:"the Netherlands",code:"NL",language:"Dutch",langCode:"nl",aliases:["netherlands","holland","nederland"]},{country:"Belgium",code:"BE",language:"Dutch",langCode:"nl",aliases:["belgi\xEB","belgique"]},{country:"Monaco",code:"MC",language:"French",langCode:"fr"},{country:"Andorra",code:"AD",language:"Catalan",langCode:"ca"},{country:"Italy",code:"IT",language:"Italian",langCode:"it",aliases:["italia"]},{country:"Spain",code:"ES",language:"Spanish",langCode:"es",aliases:["espa\xF1a","espana"]},{country:"Portugal",code:"PT",language:"Portuguese",langCode:"pt"},{country:"Malta",code:"MT",language:"English",langCode:"en"},{country:"San Marino",code:"SM",language:"Italian",langCode:"it"},{country:"Vatican City",code:"VA",language:"Italian",langCode:"it",aliases:["the vatican","holy see"]},{country:"Sweden",code:"SE",language:"Swedish",langCode:"sv",aliases:["sverige"]},{country:"Norway",code:"NO",language:"Norwegian",langCode:"no",aliases:["norge"]},{country:"Denmark",code:"DK",language:"Danish",langCode:"da",aliases:["danmark"]},{country:"Finland",code:"FI",language:"Finnish",langCode:"fi",aliases:["suomi"]},{country:"Iceland",code:"IS",language:"Icelandic",langCode:"is",aliases:["\xEDsland"]},{country:"Poland",code:"PL",language:"Polish",langCode:"pl",aliases:["polska"]},{country:"Czech Republic",code:"CZ",language:"Czech",langCode:"cs",aliases:["czechia","\u010Desko"]},{country:"Slovakia",code:"SK",language:"Slovak",langCode:"sk",aliases:["slovensko"]},{country:"Hungary",code:"HU",language:"Hungarian",langCode:"hu",aliases:["magyarorsz\xE1g"]},{country:"Slovenia",code:"SI",language:"Slovenian",langCode:"sl",aliases:["slovenija"]},{country:"Croatia",code:"HR",language:"Croatian",langCode:"hr",aliases:["hrvatska"]},{country:"Bosnia and Herzegovina",code:"BA",language:"Bosnian",langCode:"bs",aliases:["bosnia"]},{country:"Serbia",code:"RS",language:"Serbian",langCode:"sr",aliases:["srbija"]},{country:"Montenegro",code:"ME",language:"Montenegrin",langCode:"sr",aliases:["crna gora"]},{country:"Kosovo",code:"XK",language:"Albanian",langCode:"sq"},{country:"North Macedonia",code:"MK",language:"Macedonian",langCode:"mk",aliases:["macedonia"]},{country:"Albania",code:"AL",language:"Albanian",langCode:"sq",aliases:["shqip\xEBria"]},{country:"Bulgaria",code:"BG",language:"Bulgarian",langCode:"bg"},{country:"Romania",code:"RO",language:"Romanian",langCode:"ro",aliases:["rom\xE2nia"]},{country:"Moldova",code:"MD",language:"Romanian",langCode:"ro"},{country:"Greece",code:"GR",language:"Greek",langCode:"el",aliases:["\u03B5\u03BB\u03BB\u03AC\u03B4\u03B1"]},{country:"Cyprus",code:"CY",language:"Greek",langCode:"el"},{country:"Russia",code:"RU",language:"Russian",langCode:"ru",aliases:["\u0440\u043E\u0441\u0441\u0438\u044F"]},{country:"Ukraine",code:"UA",language:"Ukrainian",langCode:"uk",aliases:["\u0443\u043A\u0440\u0430\u0457\u043D\u0430"]},{country:"Belarus",code:"BY",language:"Belarusian",langCode:"be"},{country:"Estonia",code:"EE",language:"Estonian",langCode:"et",aliases:["eesti"]},{country:"Latvia",code:"LV",language:"Latvian",langCode:"lv",aliases:["latvija"]},{country:"Lithuania",code:"LT",language:"Lithuanian",langCode:"lt",aliases:["lietuva"]},{country:"Turkey",code:"TR",language:"Turkish",langCode:"tr",aliases:["t\xFCrkiye","turkiye"]},{country:"Armenia",code:"AM",language:"Armenian",langCode:"hy"},{country:"Azerbaijan",code:"AZ",language:"Azerbaijani",langCode:"az",aliases:["az\u0259rbaycan"]},{country:"Georgia",code:"GE",language:"Georgian",langCode:"ka",aliases:["\u10E1\u10D0\u10E5\u10D0\u10E0\u10D7\u10D5\u10D4\u10DA\u10DD"]},{country:"Israel",code:"IL",language:"Hebrew",langCode:"he"},{country:"Palestine",code:"PS",language:"Arabic",langCode:"ar"},{country:"Lebanon",code:"LB",language:"Arabic",langCode:"ar"},{country:"Syria",code:"SY",language:"Arabic",langCode:"ar"},{country:"Jordan",code:"JO",language:"Arabic",langCode:"ar"},{country:"Iraq",code:"IQ",language:"Arabic",langCode:"ar"},{country:"Iran",code:"IR",language:"Persian",langCode:"fa",aliases:["islamic republic of iran"]},{country:"Saudi Arabia",code:"SA",language:"Arabic",langCode:"ar"},{country:"Yemen",code:"YE",language:"Arabic",langCode:"ar"},{country:"Oman",code:"OM",language:"Arabic",langCode:"ar"},{country:"the United Arab Emirates",code:"AE",language:"English",langCode:"en",aliases:["uae","united arab emirates","dubai","abu dhabi"]},{country:"Qatar",code:"QA",language:"Arabic",langCode:"ar"},{country:"Bahrain",code:"BH",language:"Arabic",langCode:"ar"},{country:"Kuwait",code:"KW",language:"Arabic",langCode:"ar"},{country:"Kazakhstan",code:"KZ",language:"Kazakh",langCode:"kk"},{country:"Uzbekistan",code:"UZ",language:"Uzbek",langCode:"uz"},{country:"Kyrgyzstan",code:"KG",language:"Kyrgyz",langCode:"ky"},{country:"Turkmenistan",code:"TM",language:"Turkmen",langCode:"tk"},{country:"Tajikistan",code:"TJ",language:"Tajik",langCode:"tg"},{country:"Afghanistan",code:"AF",language:"Persian",langCode:"fa"},{country:"India",code:"IN",language:"English",langCode:"en"},{country:"Pakistan",code:"PK",language:"English",langCode:"en"},{country:"Bangladesh",code:"BD",language:"Bengali",langCode:"bn"},{country:"Sri Lanka",code:"LK",language:"English",langCode:"en"},{country:"Nepal",code:"NP",language:"Nepali",langCode:"ne"},{country:"Bhutan",code:"BT",language:"English",langCode:"en"},{country:"the Maldives",code:"MV",language:"English",langCode:"en",aliases:["maldives"]},{country:"China",code:"CN",language:"Chinese",langCode:"zh",aliases:["\u4E2D\u56FD","people's republic of china","prc"]},{country:"Hong Kong",code:"HK",language:"English",langCode:"en",aliases:["hk"]},{country:"Macao",code:"MO",language:"Chinese",langCode:"zh",aliases:["macau"]},{country:"Taiwan",code:"TW",language:"Chinese",langCode:"zh",aliases:["\u53F0\u7063","republic of china"]},{country:"Japan",code:"JP",language:"Japanese",langCode:"ja",aliases:["\u65E5\u672C"]},{country:"South Korea",code:"KR",language:"Korean",langCode:"ko",aliases:["korea","republic of korea"]},{country:"North Korea",code:"KP",language:"Korean",langCode:"ko",aliases:["dprk"]},{country:"Mongolia",code:"MN",language:"Mongolian",langCode:"mn"},{country:"Thailand",code:"TH",language:"Thai",langCode:"th"},{country:"Vietnam",code:"VN",language:"Vietnamese",langCode:"vi",aliases:["viet nam"]},{country:"Cambodia",code:"KH",language:"Khmer",langCode:"km"},{country:"Laos",code:"LA",language:"Lao",langCode:"lo"},{country:"Myanmar",code:"MM",language:"Burmese",langCode:"my",aliases:["burma"]},{country:"Malaysia",code:"MY",language:"Malay",langCode:"ms"},{country:"Singapore",code:"SG",language:"English",langCode:"en"},{country:"Brunei",code:"BN",language:"Malay",langCode:"ms",aliases:["brunei darussalam"]},{country:"Indonesia",code:"ID",language:"Indonesian",langCode:"id"},{country:"the Philippines",code:"PH",language:"English",langCode:"en",aliases:["philippines"]},{country:"Timor-Leste",code:"TL",language:"Portuguese",langCode:"pt",aliases:["east timor"]},{country:"the United States",code:"US",language:"English",langCode:"en",aliases:["us","usa","united states","united states of america","america","states"]},{country:"Canada",code:"CA",language:"English",langCode:"en"},{country:"Mexico",code:"MX",language:"Spanish",langCode:"es",aliases:["m\xE9xico"]},{country:"Guatemala",code:"GT",language:"Spanish",langCode:"es"},{country:"Belize",code:"BZ",language:"English",langCode:"en"},{country:"El Salvador",code:"SV",language:"Spanish",langCode:"es"},{country:"Honduras",code:"HN",language:"Spanish",langCode:"es"},{country:"Nicaragua",code:"NI",language:"Spanish",langCode:"es"},{country:"Costa Rica",code:"CR",language:"Spanish",langCode:"es"},{country:"Panama",code:"PA",language:"Spanish",langCode:"es",aliases:["panam\xE1"]},{country:"Cuba",code:"CU",language:"Spanish",langCode:"es"},{country:"the Dominican Republic",code:"DO",language:"Spanish",langCode:"es",aliases:["dominican republic"]},{country:"Haiti",code:"HT",language:"French",langCode:"fr"},{country:"Jamaica",code:"JM",language:"English",langCode:"en"},{country:"the Bahamas",code:"BS",language:"English",langCode:"en",aliases:["bahamas"]},{country:"Trinidad and Tobago",code:"TT",language:"English",langCode:"en"},{country:"Barbados",code:"BB",language:"English",langCode:"en"},{country:"Saint Lucia",code:"LC",language:"English",langCode:"en"},{country:"Saint Vincent and the Grenadines",code:"VC",language:"English",langCode:"en"},{country:"Grenada",code:"GD",language:"English",langCode:"en"},{country:"Dominica",code:"DM",language:"English",langCode:"en"},{country:"Saint Kitts and Nevis",code:"KN",language:"English",langCode:"en"},{country:"Antigua and Barbuda",code:"AG",language:"English",langCode:"en"},{country:"Puerto Rico",code:"PR",language:"Spanish",langCode:"es"},{country:"Brazil",code:"BR",language:"Portuguese",langCode:"pt",aliases:["brasil"]},{country:"Argentina",code:"AR",language:"Spanish",langCode:"es"},{country:"Colombia",code:"CO",language:"Spanish",langCode:"es"},{country:"Chile",code:"CL",language:"Spanish",langCode:"es"},{country:"Peru",code:"PE",language:"Spanish",langCode:"es",aliases:["per\xFA"]},{country:"Venezuela",code:"VE",language:"Spanish",langCode:"es"},{country:"Ecuador",code:"EC",language:"Spanish",langCode:"es"},{country:"Bolivia",code:"BO",language:"Spanish",langCode:"es"},{country:"Paraguay",code:"PY",language:"Spanish",langCode:"es"},{country:"Uruguay",code:"UY",language:"Spanish",langCode:"es"},{country:"Guyana",code:"GY",language:"English",langCode:"en"},{country:"Suriname",code:"SR",language:"Dutch",langCode:"nl"},{country:"Australia",code:"AU",language:"English",langCode:"en",aliases:["aus","oz"]},{country:"New Zealand",code:"NZ",language:"English",langCode:"en",aliases:["nz","aotearoa"]},{country:"Fiji",code:"FJ",language:"English",langCode:"en"},{country:"Papua New Guinea",code:"PG",language:"English",langCode:"en",aliases:["png"]},{country:"Samoa",code:"WS",language:"English",langCode:"en"},{country:"Tonga",code:"TO",language:"English",langCode:"en"},{country:"Vanuatu",code:"VU",language:"English",langCode:"en"},{country:"Solomon Islands",code:"SB",language:"English",langCode:"en"},{country:"Kiribati",code:"KI",language:"English",langCode:"en"},{country:"Tuvalu",code:"TV",language:"English",langCode:"en"},{country:"Nauru",code:"NR",language:"English",langCode:"en"},{country:"Palau",code:"PW",language:"English",langCode:"en"},{country:"the Marshall Islands",code:"MH",language:"English",langCode:"en",aliases:["marshall islands"]},{country:"Micronesia",code:"FM",language:"English",langCode:"en",aliases:["federated states of micronesia"]},{country:"Egypt",code:"EG",language:"Arabic",langCode:"ar"},{country:"Libya",code:"LY",language:"Arabic",langCode:"ar"},{country:"Tunisia",code:"TN",language:"Arabic",langCode:"ar"},{country:"Algeria",code:"DZ",language:"Arabic",langCode:"ar"},{country:"Morocco",code:"MA",language:"Arabic",langCode:"ar",aliases:["maroc"]},{country:"Sudan",code:"SD",language:"Arabic",langCode:"ar"},{country:"South Sudan",code:"SS",language:"English",langCode:"en"},{country:"Mauritania",code:"MR",language:"Arabic",langCode:"ar"},{country:"Nigeria",code:"NG",language:"English",langCode:"en"},{country:"Ghana",code:"GH",language:"English",langCode:"en"},{country:"Senegal",code:"SN",language:"French",langCode:"fr",aliases:["s\xE9n\xE9gal"]},{country:"C\xF4te d'Ivoire",code:"CI",language:"French",langCode:"fr",aliases:["ivory coast"]},{country:"Mali",code:"ML",language:"French",langCode:"fr"},{country:"Burkina Faso",code:"BF",language:"French",langCode:"fr"},{country:"Niger",code:"NE",language:"French",langCode:"fr"},{country:"Guinea",code:"GN",language:"French",langCode:"fr",aliases:["guin\xE9e"]},{country:"Guinea-Bissau",code:"GW",language:"Portuguese",langCode:"pt"},{country:"Sierra Leone",code:"SL",language:"English",langCode:"en"},{country:"Liberia",code:"LR",language:"English",langCode:"en"},{country:"the Gambia",code:"GM",language:"English",langCode:"en",aliases:["gambia"]},{country:"Cabo Verde",code:"CV",language:"Portuguese",langCode:"pt",aliases:["cape verde"]},{country:"Togo",code:"TG",language:"French",langCode:"fr"},{country:"Benin",code:"BJ",language:"French",langCode:"fr",aliases:["b\xE9nin"]},{country:"Cameroon",code:"CM",language:"French",langCode:"fr",aliases:["cameroun"]},{country:"the Central African Republic",code:"CF",language:"French",langCode:"fr",aliases:["central african republic","car"]},{country:"Chad",code:"TD",language:"French",langCode:"fr",aliases:["tchad"]},{country:"Equatorial Guinea",code:"GQ",language:"Spanish",langCode:"es"},{country:"Gabon",code:"GA",language:"French",langCode:"fr"},{country:"the Republic of the Congo",code:"CG",language:"French",langCode:"fr",aliases:["congo","republic of the congo","congo-brazzaville"]},{country:"the Democratic Republic of the Congo",code:"CD",language:"French",langCode:"fr",aliases:["dr congo","drc","democratic republic of the congo","congo-kinshasa","zaire"]},{country:"S\xE3o Tom\xE9 and Pr\xEDncipe",code:"ST",language:"Portuguese",langCode:"pt",aliases:["sao tome and principe","sao tome"]},{country:"Ethiopia",code:"ET",language:"Amharic",langCode:"am"},{country:"Eritrea",code:"ER",language:"Tigrinya",langCode:"ti"},{country:"Djibouti",code:"DJ",language:"French",langCode:"fr"},{country:"Somalia",code:"SO",language:"Somali",langCode:"so"},{country:"Kenya",code:"KE",language:"English",langCode:"en"},{country:"Uganda",code:"UG",language:"English",langCode:"en"},{country:"Tanzania",code:"TZ",language:"English",langCode:"en",aliases:["united republic of tanzania"]},{country:"Rwanda",code:"RW",language:"English",langCode:"en"},{country:"Burundi",code:"BI",language:"French",langCode:"fr"},{country:"Madagascar",code:"MG",language:"French",langCode:"fr"},{country:"Mauritius",code:"MU",language:"English",langCode:"en"},{country:"the Seychelles",code:"SC",language:"English",langCode:"en",aliases:["seychelles"]},{country:"Comoros",code:"KM",language:"French",langCode:"fr"},{country:"South Africa",code:"ZA",language:"English",langCode:"en",aliases:["sa"]},{country:"Namibia",code:"NA",language:"English",langCode:"en"},{country:"Botswana",code:"BW",language:"English",langCode:"en"},{country:"Zimbabwe",code:"ZW",language:"English",langCode:"en"},{country:"Zambia",code:"ZM",language:"English",langCode:"en"},{country:"Malawi",code:"MW",language:"English",langCode:"en"},{country:"Mozambique",code:"MZ",language:"Portuguese",langCode:"pt",aliases:["mo\xE7ambique"]},{country:"Angola",code:"AO",language:"Portuguese",langCode:"pt"},{country:"Lesotho",code:"LS",language:"English",langCode:"en"},{country:"Eswatini",code:"SZ",language:"English",langCode:"en",aliases:["swaziland"]}],Ne=[{language:"English",code:"en"},{language:"Italian",code:"it",aliases:["italiano"]},{language:"Spanish",code:"es",aliases:["espa\xF1ol","espanol","castellano"]},{language:"French",code:"fr",aliases:["fran\xE7ais","francais"]},{language:"German",code:"de",aliases:["deutsch"]},{language:"Portuguese",code:"pt",aliases:["portugu\xEAs","portugues"]},{language:"Dutch",code:"nl",aliases:["nederlands","flemish"]},{language:"Swedish",code:"sv",aliases:["svenska"]},{language:"Norwegian",code:"no",aliases:["norsk"]},{language:"Danish",code:"da",aliases:["dansk"]},{language:"Icelandic",code:"is",aliases:["\xEDslenska"]},{language:"Catalan",code:"ca",aliases:["catal\xE0"]},{language:"Romanian",code:"ro",aliases:["rom\xE2n\u0103","romana"]},{language:"Polish",code:"pl",aliases:["polski"]},{language:"Czech",code:"cs",aliases:["\u010De\u0161tina","cestina"]},{language:"Slovak",code:"sk",aliases:["sloven\u010Dina"]},{language:"Slovenian",code:"sl",aliases:["sloven\u0161\u010Dina"]},{language:"Croatian",code:"hr",aliases:["hrvatski"]},{language:"Bosnian",code:"bs",aliases:["bosanski"]},{language:"Serbian",code:"sr",aliases:["\u0441\u0440\u043F\u0441\u043A\u0438"]},{language:"Montenegrin",code:"sr",aliases:["crnogorski"]},{language:"Macedonian",code:"mk",aliases:["\u043C\u0430\u043A\u0435\u0434\u043E\u043D\u0441\u043A\u0438"]},{language:"Bulgarian",code:"bg",aliases:["\u0431\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438"]},{language:"Russian",code:"ru",aliases:["\u0440\u0443\u0441\u0441\u043A\u0438\u0439"]},{language:"Ukrainian",code:"uk",aliases:["\u0443\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"]},{language:"Belarusian",code:"be",aliases:["\u0431\u0435\u043B\u0430\u0440\u0443\u0441\u043A\u0430\u044F"]},{language:"Latvian",code:"lv",aliases:["latvie\u0161u"]},{language:"Lithuanian",code:"lt",aliases:["lietuvi\u0173"]},{language:"Greek",code:"el",aliases:["\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC","ellinik\xE1"]},{language:"Albanian",code:"sq",aliases:["shqip"]},{language:"Armenian",code:"hy",aliases:["\u0570\u0561\u0575\u0565\u0580\u0565\u0576"]},{language:"Persian",code:"fa",aliases:["farsi","dari","\u0641\u0627\u0631\u0633\u06CC"]},{language:"Hindi",code:"hi",aliases:["\u0939\u093F\u0928\u094D\u0926\u0940"]},{language:"Urdu",code:"ur",aliases:["\u0627\u0631\u062F\u0648"]},{language:"Bengali",code:"bn",aliases:["bangla","\u09AC\u09BE\u0982\u09B2\u09BE"]},{language:"Nepali",code:"ne",aliases:["\u0928\u0947\u092A\u093E\u0932\u0940"]},{language:"Sinhala",code:"si",aliases:["\u0DC3\u0DD2\u0D82\u0DC4\u0DBD","sinhalese"]},{language:"Finnish",code:"fi",aliases:["suomi"]},{language:"Estonian",code:"et",aliases:["eesti"]},{language:"Hungarian",code:"hu",aliases:["magyar"]},{language:"Turkish",code:"tr",aliases:["t\xFCrk\xE7e","turkce"]},{language:"Azerbaijani",code:"az",aliases:["az\u0259rbaycan dili","azeri"]},{language:"Kazakh",code:"kk",aliases:["\u049B\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"]},{language:"Uzbek",code:"uz",aliases:["o'zbek"]},{language:"Kyrgyz",code:"ky",aliases:["\u043A\u044B\u0440\u0433\u044B\u0437\u0447\u0430"]},{language:"Turkmen",code:"tk",aliases:["t\xFCrkmen\xE7e"]},{language:"Arabic",code:"ar",aliases:["\u0627\u0644\u0639\u0631\u0628\u064A\u0629"]},{language:"Hebrew",code:"he",aliases:["\u05E2\u05D1\u05E8\u05D9\u05EA","ivrit"]},{language:"Amharic",code:"am",aliases:["\u12A0\u121B\u122D\u129B"]},{language:"Tigrinya",code:"ti",aliases:["\u1275\u130D\u122D\u129B"]},{language:"Chinese",code:"zh",aliases:["mandarin","\u4E2D\u6587","\u6C49\u8BED","putonghua"]},{language:"Japanese",code:"ja",aliases:["\u65E5\u672C\u8A9E","nihongo"]},{language:"Korean",code:"ko",aliases:["\uD55C\uAD6D\uC5B4"]},{language:"Thai",code:"th",aliases:["\u0E44\u0E17\u0E22"]},{language:"Vietnamese",code:"vi",aliases:["ti\u1EBFng vi\u1EC7t"]},{language:"Khmer",code:"km",aliases:["\u1781\u17D2\u1798\u17C2\u179A","cambodian"]},{language:"Lao",code:"lo",aliases:["\u0EA5\u0EB2\u0EA7"]},{language:"Burmese",code:"my",aliases:["\u1019\u103C\u1014\u103A\u1019\u102C","myanmar"]},{language:"Dzongkha",code:"dz",aliases:["\u0F62\u0FAB\u0F7C\u0F44\u0F0B\u0F41"]},{language:"Mongolian",code:"mn",aliases:["\u043C\u043E\u043D\u0433\u043E\u043B"]},{language:"Georgian",code:"ka",aliases:["\u10E5\u10D0\u10E0\u10D7\u10E3\u10DA\u10D8"]},{language:"Tajik",code:"tg",aliases:["\u0442\u043E\u04B7\u0438\u043A\u04E3"]},{language:"Malay",code:"ms",aliases:["bahasa malaysia","bahasa melayu"]},{language:"Indonesian",code:"id",aliases:["bahasa indonesia"]},{language:"Filipino",code:"fil",aliases:["tagalog","pilipino"]},{language:"Swahili",code:"sw",aliases:["kiswahili"]},{language:"Somali",code:"so",aliases:["af soomaali"]},{language:"Yoruba",code:"yo",aliases:["yor\xF9b\xE1"]},{language:"Hausa",code:"ha",aliases:["harshen hausa"]},{language:"Zulu",code:"zu",aliases:["isizulu"]},{language:"Afrikaans",code:"af"}];function R(e){return e.trim().toLowerCase()}function ye(e){if(!e)return;let a=R(e);for(let n of Me)if(R(n.country)===a||n.aliases?.some(t=>R(t)===a))return n}function me(e){if(!e)return;let a=R(e);for(let n of Ne)if(R(n.language)===a||n.aliases?.some(t=>R(t)===a))return n}var F=class extends Error{constructor(){super("user pressed back"),this.name="BackSignal"}},W=class extends Error{constructor(){super("user cancelled"),this.name="CancelSignal"}},Oe="Include the country code with a + (e.g. +12025550123 for US, +447123456789 for UK)",fe=e=>/^\+\d{8,15}$/.test(e)?void 0:Oe,be=e=>/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e)?void 0:"Enter a valid email",O=e=>a=>a.trim().length===0?`${e} is required`:void 0,Ke=/[\u2022\u2023\u2024\u2027\u00B7\u2219\u22C5\u25CF\u25CB\u25AA\u25AB\u204E\u2217\uFE61\u25E6\u2218]/,Be="That looks like the masked \u2022\u2022\u2022\u2022\u2022 value your screen shows, not the token itself. Click the reveal/copy icon next to it and paste the real value (letters and numbers).",X=e=>Ke.test(e)?Be:void 0,Re=e=>a=>X(a)??(a.trim().length===0?`${e} is required`:void 0),Le=e=>{let a=e.replace(/\s+/g,"");return a.length===0?"Personal access token is required":X(a)??(/^sbp_[A-Za-z0-9._~+\/=-]{20,}$/.test(a)?void 0:"Doesn't look like a valid token \u2014 it should be 'sbp_' followed by letters and numbers.")},Ve="one-off, no monthly fees",we="per month";function H(e){if(!e)return!0;let a=e.trim();if(a==="")return!0;let n=a.replace(/[^\d.]/g,"");if(n==="")return/^\s*free\s*$/i.test(a);let t=parseFloat(n);return!isNaN(t)&&t===0}var Fe={id:"ai-agent",title:"AI coding agent",isApplicable:()=>!0,execute:async(e,{prompt:a,info:n})=>(n({title:"Which AI coding agent do you use?",body:`Klaudius works with two AI coding agents in your terminal \u2014 Claude Code
|
|
1
|
+
import{a as S,f as ge,g as he,i as pe,l as me,m as ye,n as fe,p as be}from"./chunk-R2LC3ZRY.js";import{useEffect as Sa,useMemo as va,useRef as de,useState as K}from"react";import{Box as I,Text as E,useApp as ka,useInput as Aa}from"ink";var Le=[{country:"the United Kingdom",code:"GB",language:"English",langCode:"en",aliases:["uk","united kingdom","great britain","britain","england","scotland","wales","northern ireland"]},{country:"Ireland",code:"IE",language:"English",langCode:"en"},{country:"France",code:"FR",language:"French",langCode:"fr"},{country:"Germany",code:"DE",language:"German",langCode:"de",aliases:["deutschland"]},{country:"Austria",code:"AT",language:"German",langCode:"de",aliases:["\xF6sterreich","osterreich"]},{country:"Switzerland",code:"CH",language:"German",langCode:"de",aliases:["schweiz","suisse","svizzera"]},{country:"Liechtenstein",code:"LI",language:"German",langCode:"de"},{country:"Luxembourg",code:"LU",language:"French",langCode:"fr",aliases:["l\xEBtzebuerg"]},{country:"the Netherlands",code:"NL",language:"Dutch",langCode:"nl",aliases:["netherlands","holland","nederland"]},{country:"Belgium",code:"BE",language:"Dutch",langCode:"nl",aliases:["belgi\xEB","belgique"]},{country:"Monaco",code:"MC",language:"French",langCode:"fr"},{country:"Andorra",code:"AD",language:"Catalan",langCode:"ca"},{country:"Italy",code:"IT",language:"Italian",langCode:"it",aliases:["italia"]},{country:"Spain",code:"ES",language:"Spanish",langCode:"es",aliases:["espa\xF1a","espana"]},{country:"Portugal",code:"PT",language:"Portuguese",langCode:"pt"},{country:"Malta",code:"MT",language:"English",langCode:"en"},{country:"San Marino",code:"SM",language:"Italian",langCode:"it"},{country:"Vatican City",code:"VA",language:"Italian",langCode:"it",aliases:["the vatican","holy see"]},{country:"Sweden",code:"SE",language:"Swedish",langCode:"sv",aliases:["sverige"]},{country:"Norway",code:"NO",language:"Norwegian",langCode:"no",aliases:["norge"]},{country:"Denmark",code:"DK",language:"Danish",langCode:"da",aliases:["danmark"]},{country:"Finland",code:"FI",language:"Finnish",langCode:"fi",aliases:["suomi"]},{country:"Iceland",code:"IS",language:"Icelandic",langCode:"is",aliases:["\xEDsland"]},{country:"Poland",code:"PL",language:"Polish",langCode:"pl",aliases:["polska"]},{country:"Czech Republic",code:"CZ",language:"Czech",langCode:"cs",aliases:["czechia","\u010Desko"]},{country:"Slovakia",code:"SK",language:"Slovak",langCode:"sk",aliases:["slovensko"]},{country:"Hungary",code:"HU",language:"Hungarian",langCode:"hu",aliases:["magyarorsz\xE1g"]},{country:"Slovenia",code:"SI",language:"Slovenian",langCode:"sl",aliases:["slovenija"]},{country:"Croatia",code:"HR",language:"Croatian",langCode:"hr",aliases:["hrvatska"]},{country:"Bosnia and Herzegovina",code:"BA",language:"Bosnian",langCode:"bs",aliases:["bosnia"]},{country:"Serbia",code:"RS",language:"Serbian",langCode:"sr",aliases:["srbija"]},{country:"Montenegro",code:"ME",language:"Montenegrin",langCode:"sr",aliases:["crna gora"]},{country:"Kosovo",code:"XK",language:"Albanian",langCode:"sq"},{country:"North Macedonia",code:"MK",language:"Macedonian",langCode:"mk",aliases:["macedonia"]},{country:"Albania",code:"AL",language:"Albanian",langCode:"sq",aliases:["shqip\xEBria"]},{country:"Bulgaria",code:"BG",language:"Bulgarian",langCode:"bg"},{country:"Romania",code:"RO",language:"Romanian",langCode:"ro",aliases:["rom\xE2nia"]},{country:"Moldova",code:"MD",language:"Romanian",langCode:"ro"},{country:"Greece",code:"GR",language:"Greek",langCode:"el",aliases:["\u03B5\u03BB\u03BB\u03AC\u03B4\u03B1"]},{country:"Cyprus",code:"CY",language:"Greek",langCode:"el"},{country:"Russia",code:"RU",language:"Russian",langCode:"ru",aliases:["\u0440\u043E\u0441\u0441\u0438\u044F"]},{country:"Ukraine",code:"UA",language:"Ukrainian",langCode:"uk",aliases:["\u0443\u043A\u0440\u0430\u0457\u043D\u0430"]},{country:"Belarus",code:"BY",language:"Belarusian",langCode:"be"},{country:"Estonia",code:"EE",language:"Estonian",langCode:"et",aliases:["eesti"]},{country:"Latvia",code:"LV",language:"Latvian",langCode:"lv",aliases:["latvija"]},{country:"Lithuania",code:"LT",language:"Lithuanian",langCode:"lt",aliases:["lietuva"]},{country:"Turkey",code:"TR",language:"Turkish",langCode:"tr",aliases:["t\xFCrkiye","turkiye"]},{country:"Armenia",code:"AM",language:"Armenian",langCode:"hy"},{country:"Azerbaijan",code:"AZ",language:"Azerbaijani",langCode:"az",aliases:["az\u0259rbaycan"]},{country:"Georgia",code:"GE",language:"Georgian",langCode:"ka",aliases:["\u10E1\u10D0\u10E5\u10D0\u10E0\u10D7\u10D5\u10D4\u10DA\u10DD"]},{country:"Israel",code:"IL",language:"Hebrew",langCode:"he"},{country:"Palestine",code:"PS",language:"Arabic",langCode:"ar"},{country:"Lebanon",code:"LB",language:"Arabic",langCode:"ar"},{country:"Syria",code:"SY",language:"Arabic",langCode:"ar"},{country:"Jordan",code:"JO",language:"Arabic",langCode:"ar"},{country:"Iraq",code:"IQ",language:"Arabic",langCode:"ar"},{country:"Iran",code:"IR",language:"Persian",langCode:"fa",aliases:["islamic republic of iran"]},{country:"Saudi Arabia",code:"SA",language:"Arabic",langCode:"ar"},{country:"Yemen",code:"YE",language:"Arabic",langCode:"ar"},{country:"Oman",code:"OM",language:"Arabic",langCode:"ar"},{country:"the United Arab Emirates",code:"AE",language:"English",langCode:"en",aliases:["uae","united arab emirates","dubai","abu dhabi"]},{country:"Qatar",code:"QA",language:"Arabic",langCode:"ar"},{country:"Bahrain",code:"BH",language:"Arabic",langCode:"ar"},{country:"Kuwait",code:"KW",language:"Arabic",langCode:"ar"},{country:"Kazakhstan",code:"KZ",language:"Kazakh",langCode:"kk"},{country:"Uzbekistan",code:"UZ",language:"Uzbek",langCode:"uz"},{country:"Kyrgyzstan",code:"KG",language:"Kyrgyz",langCode:"ky"},{country:"Turkmenistan",code:"TM",language:"Turkmen",langCode:"tk"},{country:"Tajikistan",code:"TJ",language:"Tajik",langCode:"tg"},{country:"Afghanistan",code:"AF",language:"Persian",langCode:"fa"},{country:"India",code:"IN",language:"English",langCode:"en"},{country:"Pakistan",code:"PK",language:"English",langCode:"en"},{country:"Bangladesh",code:"BD",language:"Bengali",langCode:"bn"},{country:"Sri Lanka",code:"LK",language:"English",langCode:"en"},{country:"Nepal",code:"NP",language:"Nepali",langCode:"ne"},{country:"Bhutan",code:"BT",language:"English",langCode:"en"},{country:"the Maldives",code:"MV",language:"English",langCode:"en",aliases:["maldives"]},{country:"China",code:"CN",language:"Chinese",langCode:"zh",aliases:["\u4E2D\u56FD","people's republic of china","prc"]},{country:"Hong Kong",code:"HK",language:"English",langCode:"en",aliases:["hk"]},{country:"Macao",code:"MO",language:"Chinese",langCode:"zh",aliases:["macau"]},{country:"Taiwan",code:"TW",language:"Chinese",langCode:"zh",aliases:["\u53F0\u7063","republic of china"]},{country:"Japan",code:"JP",language:"Japanese",langCode:"ja",aliases:["\u65E5\u672C"]},{country:"South Korea",code:"KR",language:"Korean",langCode:"ko",aliases:["korea","republic of korea"]},{country:"North Korea",code:"KP",language:"Korean",langCode:"ko",aliases:["dprk"]},{country:"Mongolia",code:"MN",language:"Mongolian",langCode:"mn"},{country:"Thailand",code:"TH",language:"Thai",langCode:"th"},{country:"Vietnam",code:"VN",language:"Vietnamese",langCode:"vi",aliases:["viet nam"]},{country:"Cambodia",code:"KH",language:"Khmer",langCode:"km"},{country:"Laos",code:"LA",language:"Lao",langCode:"lo"},{country:"Myanmar",code:"MM",language:"Burmese",langCode:"my",aliases:["burma"]},{country:"Malaysia",code:"MY",language:"Malay",langCode:"ms"},{country:"Singapore",code:"SG",language:"English",langCode:"en"},{country:"Brunei",code:"BN",language:"Malay",langCode:"ms",aliases:["brunei darussalam"]},{country:"Indonesia",code:"ID",language:"Indonesian",langCode:"id"},{country:"the Philippines",code:"PH",language:"English",langCode:"en",aliases:["philippines"]},{country:"Timor-Leste",code:"TL",language:"Portuguese",langCode:"pt",aliases:["east timor"]},{country:"the United States",code:"US",language:"English",langCode:"en",aliases:["us","usa","united states","united states of america","america","states"]},{country:"Canada",code:"CA",language:"English",langCode:"en"},{country:"Mexico",code:"MX",language:"Spanish",langCode:"es",aliases:["m\xE9xico"]},{country:"Guatemala",code:"GT",language:"Spanish",langCode:"es"},{country:"Belize",code:"BZ",language:"English",langCode:"en"},{country:"El Salvador",code:"SV",language:"Spanish",langCode:"es"},{country:"Honduras",code:"HN",language:"Spanish",langCode:"es"},{country:"Nicaragua",code:"NI",language:"Spanish",langCode:"es"},{country:"Costa Rica",code:"CR",language:"Spanish",langCode:"es"},{country:"Panama",code:"PA",language:"Spanish",langCode:"es",aliases:["panam\xE1"]},{country:"Cuba",code:"CU",language:"Spanish",langCode:"es"},{country:"the Dominican Republic",code:"DO",language:"Spanish",langCode:"es",aliases:["dominican republic"]},{country:"Haiti",code:"HT",language:"French",langCode:"fr"},{country:"Jamaica",code:"JM",language:"English",langCode:"en"},{country:"the Bahamas",code:"BS",language:"English",langCode:"en",aliases:["bahamas"]},{country:"Trinidad and Tobago",code:"TT",language:"English",langCode:"en"},{country:"Barbados",code:"BB",language:"English",langCode:"en"},{country:"Saint Lucia",code:"LC",language:"English",langCode:"en"},{country:"Saint Vincent and the Grenadines",code:"VC",language:"English",langCode:"en"},{country:"Grenada",code:"GD",language:"English",langCode:"en"},{country:"Dominica",code:"DM",language:"English",langCode:"en"},{country:"Saint Kitts and Nevis",code:"KN",language:"English",langCode:"en"},{country:"Antigua and Barbuda",code:"AG",language:"English",langCode:"en"},{country:"Puerto Rico",code:"PR",language:"Spanish",langCode:"es"},{country:"Brazil",code:"BR",language:"Portuguese",langCode:"pt",aliases:["brasil"]},{country:"Argentina",code:"AR",language:"Spanish",langCode:"es"},{country:"Colombia",code:"CO",language:"Spanish",langCode:"es"},{country:"Chile",code:"CL",language:"Spanish",langCode:"es"},{country:"Peru",code:"PE",language:"Spanish",langCode:"es",aliases:["per\xFA"]},{country:"Venezuela",code:"VE",language:"Spanish",langCode:"es"},{country:"Ecuador",code:"EC",language:"Spanish",langCode:"es"},{country:"Bolivia",code:"BO",language:"Spanish",langCode:"es"},{country:"Paraguay",code:"PY",language:"Spanish",langCode:"es"},{country:"Uruguay",code:"UY",language:"Spanish",langCode:"es"},{country:"Guyana",code:"GY",language:"English",langCode:"en"},{country:"Suriname",code:"SR",language:"Dutch",langCode:"nl"},{country:"Australia",code:"AU",language:"English",langCode:"en",aliases:["aus","oz"]},{country:"New Zealand",code:"NZ",language:"English",langCode:"en",aliases:["nz","aotearoa"]},{country:"Fiji",code:"FJ",language:"English",langCode:"en"},{country:"Papua New Guinea",code:"PG",language:"English",langCode:"en",aliases:["png"]},{country:"Samoa",code:"WS",language:"English",langCode:"en"},{country:"Tonga",code:"TO",language:"English",langCode:"en"},{country:"Vanuatu",code:"VU",language:"English",langCode:"en"},{country:"Solomon Islands",code:"SB",language:"English",langCode:"en"},{country:"Kiribati",code:"KI",language:"English",langCode:"en"},{country:"Tuvalu",code:"TV",language:"English",langCode:"en"},{country:"Nauru",code:"NR",language:"English",langCode:"en"},{country:"Palau",code:"PW",language:"English",langCode:"en"},{country:"the Marshall Islands",code:"MH",language:"English",langCode:"en",aliases:["marshall islands"]},{country:"Micronesia",code:"FM",language:"English",langCode:"en",aliases:["federated states of micronesia"]},{country:"Egypt",code:"EG",language:"Arabic",langCode:"ar"},{country:"Libya",code:"LY",language:"Arabic",langCode:"ar"},{country:"Tunisia",code:"TN",language:"Arabic",langCode:"ar"},{country:"Algeria",code:"DZ",language:"Arabic",langCode:"ar"},{country:"Morocco",code:"MA",language:"Arabic",langCode:"ar",aliases:["maroc"]},{country:"Sudan",code:"SD",language:"Arabic",langCode:"ar"},{country:"South Sudan",code:"SS",language:"English",langCode:"en"},{country:"Mauritania",code:"MR",language:"Arabic",langCode:"ar"},{country:"Nigeria",code:"NG",language:"English",langCode:"en"},{country:"Ghana",code:"GH",language:"English",langCode:"en"},{country:"Senegal",code:"SN",language:"French",langCode:"fr",aliases:["s\xE9n\xE9gal"]},{country:"C\xF4te d'Ivoire",code:"CI",language:"French",langCode:"fr",aliases:["ivory coast"]},{country:"Mali",code:"ML",language:"French",langCode:"fr"},{country:"Burkina Faso",code:"BF",language:"French",langCode:"fr"},{country:"Niger",code:"NE",language:"French",langCode:"fr"},{country:"Guinea",code:"GN",language:"French",langCode:"fr",aliases:["guin\xE9e"]},{country:"Guinea-Bissau",code:"GW",language:"Portuguese",langCode:"pt"},{country:"Sierra Leone",code:"SL",language:"English",langCode:"en"},{country:"Liberia",code:"LR",language:"English",langCode:"en"},{country:"the Gambia",code:"GM",language:"English",langCode:"en",aliases:["gambia"]},{country:"Cabo Verde",code:"CV",language:"Portuguese",langCode:"pt",aliases:["cape verde"]},{country:"Togo",code:"TG",language:"French",langCode:"fr"},{country:"Benin",code:"BJ",language:"French",langCode:"fr",aliases:["b\xE9nin"]},{country:"Cameroon",code:"CM",language:"French",langCode:"fr",aliases:["cameroun"]},{country:"the Central African Republic",code:"CF",language:"French",langCode:"fr",aliases:["central african republic","car"]},{country:"Chad",code:"TD",language:"French",langCode:"fr",aliases:["tchad"]},{country:"Equatorial Guinea",code:"GQ",language:"Spanish",langCode:"es"},{country:"Gabon",code:"GA",language:"French",langCode:"fr"},{country:"the Republic of the Congo",code:"CG",language:"French",langCode:"fr",aliases:["congo","republic of the congo","congo-brazzaville"]},{country:"the Democratic Republic of the Congo",code:"CD",language:"French",langCode:"fr",aliases:["dr congo","drc","democratic republic of the congo","congo-kinshasa","zaire"]},{country:"S\xE3o Tom\xE9 and Pr\xEDncipe",code:"ST",language:"Portuguese",langCode:"pt",aliases:["sao tome and principe","sao tome"]},{country:"Ethiopia",code:"ET",language:"Amharic",langCode:"am"},{country:"Eritrea",code:"ER",language:"Tigrinya",langCode:"ti"},{country:"Djibouti",code:"DJ",language:"French",langCode:"fr"},{country:"Somalia",code:"SO",language:"Somali",langCode:"so"},{country:"Kenya",code:"KE",language:"English",langCode:"en"},{country:"Uganda",code:"UG",language:"English",langCode:"en"},{country:"Tanzania",code:"TZ",language:"English",langCode:"en",aliases:["united republic of tanzania"]},{country:"Rwanda",code:"RW",language:"English",langCode:"en"},{country:"Burundi",code:"BI",language:"French",langCode:"fr"},{country:"Madagascar",code:"MG",language:"French",langCode:"fr"},{country:"Mauritius",code:"MU",language:"English",langCode:"en"},{country:"the Seychelles",code:"SC",language:"English",langCode:"en",aliases:["seychelles"]},{country:"Comoros",code:"KM",language:"French",langCode:"fr"},{country:"South Africa",code:"ZA",language:"English",langCode:"en",aliases:["sa"]},{country:"Namibia",code:"NA",language:"English",langCode:"en"},{country:"Botswana",code:"BW",language:"English",langCode:"en"},{country:"Zimbabwe",code:"ZW",language:"English",langCode:"en"},{country:"Zambia",code:"ZM",language:"English",langCode:"en"},{country:"Malawi",code:"MW",language:"English",langCode:"en"},{country:"Mozambique",code:"MZ",language:"Portuguese",langCode:"pt",aliases:["mo\xE7ambique"]},{country:"Angola",code:"AO",language:"Portuguese",langCode:"pt"},{country:"Lesotho",code:"LS",language:"English",langCode:"en"},{country:"Eswatini",code:"SZ",language:"English",langCode:"en",aliases:["swaziland"]}],Ve=[{language:"English",code:"en"},{language:"Italian",code:"it",aliases:["italiano"]},{language:"Spanish",code:"es",aliases:["espa\xF1ol","espanol","castellano"]},{language:"French",code:"fr",aliases:["fran\xE7ais","francais"]},{language:"German",code:"de",aliases:["deutsch"]},{language:"Portuguese",code:"pt",aliases:["portugu\xEAs","portugues"]},{language:"Dutch",code:"nl",aliases:["nederlands","flemish"]},{language:"Swedish",code:"sv",aliases:["svenska"]},{language:"Norwegian",code:"no",aliases:["norsk"]},{language:"Danish",code:"da",aliases:["dansk"]},{language:"Icelandic",code:"is",aliases:["\xEDslenska"]},{language:"Catalan",code:"ca",aliases:["catal\xE0"]},{language:"Romanian",code:"ro",aliases:["rom\xE2n\u0103","romana"]},{language:"Polish",code:"pl",aliases:["polski"]},{language:"Czech",code:"cs",aliases:["\u010De\u0161tina","cestina"]},{language:"Slovak",code:"sk",aliases:["sloven\u010Dina"]},{language:"Slovenian",code:"sl",aliases:["sloven\u0161\u010Dina"]},{language:"Croatian",code:"hr",aliases:["hrvatski"]},{language:"Bosnian",code:"bs",aliases:["bosanski"]},{language:"Serbian",code:"sr",aliases:["\u0441\u0440\u043F\u0441\u043A\u0438"]},{language:"Montenegrin",code:"sr",aliases:["crnogorski"]},{language:"Macedonian",code:"mk",aliases:["\u043C\u0430\u043A\u0435\u0434\u043E\u043D\u0441\u043A\u0438"]},{language:"Bulgarian",code:"bg",aliases:["\u0431\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438"]},{language:"Russian",code:"ru",aliases:["\u0440\u0443\u0441\u0441\u043A\u0438\u0439"]},{language:"Ukrainian",code:"uk",aliases:["\u0443\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"]},{language:"Belarusian",code:"be",aliases:["\u0431\u0435\u043B\u0430\u0440\u0443\u0441\u043A\u0430\u044F"]},{language:"Latvian",code:"lv",aliases:["latvie\u0161u"]},{language:"Lithuanian",code:"lt",aliases:["lietuvi\u0173"]},{language:"Greek",code:"el",aliases:["\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC","ellinik\xE1"]},{language:"Albanian",code:"sq",aliases:["shqip"]},{language:"Armenian",code:"hy",aliases:["\u0570\u0561\u0575\u0565\u0580\u0565\u0576"]},{language:"Persian",code:"fa",aliases:["farsi","dari","\u0641\u0627\u0631\u0633\u06CC"]},{language:"Hindi",code:"hi",aliases:["\u0939\u093F\u0928\u094D\u0926\u0940"]},{language:"Urdu",code:"ur",aliases:["\u0627\u0631\u062F\u0648"]},{language:"Bengali",code:"bn",aliases:["bangla","\u09AC\u09BE\u0982\u09B2\u09BE"]},{language:"Nepali",code:"ne",aliases:["\u0928\u0947\u092A\u093E\u0932\u0940"]},{language:"Sinhala",code:"si",aliases:["\u0DC3\u0DD2\u0D82\u0DC4\u0DBD","sinhalese"]},{language:"Finnish",code:"fi",aliases:["suomi"]},{language:"Estonian",code:"et",aliases:["eesti"]},{language:"Hungarian",code:"hu",aliases:["magyar"]},{language:"Turkish",code:"tr",aliases:["t\xFCrk\xE7e","turkce"]},{language:"Azerbaijani",code:"az",aliases:["az\u0259rbaycan dili","azeri"]},{language:"Kazakh",code:"kk",aliases:["\u049B\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"]},{language:"Uzbek",code:"uz",aliases:["o'zbek"]},{language:"Kyrgyz",code:"ky",aliases:["\u043A\u044B\u0440\u0433\u044B\u0437\u0447\u0430"]},{language:"Turkmen",code:"tk",aliases:["t\xFCrkmen\xE7e"]},{language:"Arabic",code:"ar",aliases:["\u0627\u0644\u0639\u0631\u0628\u064A\u0629"]},{language:"Hebrew",code:"he",aliases:["\u05E2\u05D1\u05E8\u05D9\u05EA","ivrit"]},{language:"Amharic",code:"am",aliases:["\u12A0\u121B\u122D\u129B"]},{language:"Tigrinya",code:"ti",aliases:["\u1275\u130D\u122D\u129B"]},{language:"Chinese",code:"zh",aliases:["mandarin","\u4E2D\u6587","\u6C49\u8BED","putonghua"]},{language:"Japanese",code:"ja",aliases:["\u65E5\u672C\u8A9E","nihongo"]},{language:"Korean",code:"ko",aliases:["\uD55C\uAD6D\uC5B4"]},{language:"Thai",code:"th",aliases:["\u0E44\u0E17\u0E22"]},{language:"Vietnamese",code:"vi",aliases:["ti\u1EBFng vi\u1EC7t"]},{language:"Khmer",code:"km",aliases:["\u1781\u17D2\u1798\u17C2\u179A","cambodian"]},{language:"Lao",code:"lo",aliases:["\u0EA5\u0EB2\u0EA7"]},{language:"Burmese",code:"my",aliases:["\u1019\u103C\u1014\u103A\u1019\u102C","myanmar"]},{language:"Dzongkha",code:"dz",aliases:["\u0F62\u0FAB\u0F7C\u0F44\u0F0B\u0F41"]},{language:"Mongolian",code:"mn",aliases:["\u043C\u043E\u043D\u0433\u043E\u043B"]},{language:"Georgian",code:"ka",aliases:["\u10E5\u10D0\u10E0\u10D7\u10E3\u10DA\u10D8"]},{language:"Tajik",code:"tg",aliases:["\u0442\u043E\u04B7\u0438\u043A\u04E3"]},{language:"Malay",code:"ms",aliases:["bahasa malaysia","bahasa melayu"]},{language:"Indonesian",code:"id",aliases:["bahasa indonesia"]},{language:"Filipino",code:"fil",aliases:["tagalog","pilipino"]},{language:"Swahili",code:"sw",aliases:["kiswahili"]},{language:"Somali",code:"so",aliases:["af soomaali"]},{language:"Yoruba",code:"yo",aliases:["yor\xF9b\xE1"]},{language:"Hausa",code:"ha",aliases:["harshen hausa"]},{language:"Zulu",code:"zu",aliases:["isizulu"]},{language:"Afrikaans",code:"af"}];function R(e){return e.trim().toLowerCase()}function we(e){if(!e)return;let a=R(e);for(let t of Le)if(R(t.country)===a||t.aliases?.some(n=>R(n)===a))return t}function Ce(e){if(!e)return;let a=R(e);for(let t of Ve)if(R(t.language)===a||t.aliases?.some(n=>R(n)===a))return t}var F=class extends Error{constructor(){super("user pressed back"),this.name="BackSignal"}},W=class extends Error{constructor(){super("user cancelled"),this.name="CancelSignal"}},Fe="Include the country code with a + (e.g. +12025550123 for US, +447123456789 for UK)",Se=e=>/^\+\d{8,15}$/.test(e)?void 0:Fe,ve=e=>/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e)?void 0:"Enter a valid email",B=e=>a=>a.trim().length===0?`${e} is required`:void 0,Ue=/[\u2022\u2023\u2024\u2027\u00B7\u2219\u22C5\u25CF\u25CB\u25AA\u25AB\u204E\u2217\uFE61\u25E6\u2218]/,De="That looks like the masked \u2022\u2022\u2022\u2022\u2022 value your screen shows, not the token itself. Click the reveal/copy icon next to it and paste the real value (letters and numbers).",ae=e=>Ue.test(e)?De:void 0,ze=e=>a=>ae(a)??(a.trim().length===0?`${e} is required`:void 0),Ge=e=>{let a=e.replace(/\s+/g,"");return a.length===0?"Personal access token is required":ae(a)??(/^sbp_[A-Za-z0-9._~+\/=-]{20,}$/.test(a)?void 0:"Doesn't look like a valid token \u2014 it should be 'sbp_' followed by letters and numbers.")},He="one-off, no monthly fees",ke="per month";function H(e){if(!e)return!0;let a=e.trim();if(a==="")return!0;let t=a.replace(/[^\d.]/g,"");if(t==="")return/^\s*free\s*$/i.test(a);let n=parseFloat(t);return!isNaN(n)&&n===0}var We={id:"ai-agent",title:"AI coding agent",isApplicable:()=>!0,execute:async(e,{prompt:a,info:t})=>(t({title:"Which AI coding agent do you use?",body:`Klaudius works with two AI coding agents in your terminal \u2014 Claude Code
|
|
2
2
|
(Anthropic) or Codex (OpenAI). Pick whichever you already pay for.
|
|
3
3
|
|
|
4
4
|
This choice only changes which agent runs the pipeline. Everything else \u2014
|
|
5
5
|
the businesses found, the websites built, the outreach sent \u2014 is identical
|
|
6
|
-
either way. You can switch later by re-running init in a fresh folder.`}),{aiAgent:await a({type:"select",message:"Which AI coding agent will drive Klaudius?",initialValue:e.aiAgent??"claude-code",options:[{value:"claude-code",label:"Claude Code (Anthropic)"},{value:"codex",label:"Codex (OpenAI)"}]})})},
|
|
6
|
+
either way. You can switch later by re-running init in a fresh folder.`}),{aiAgent:await a({type:"select",message:"Which AI coding agent will drive Klaudius?",initialValue:e.aiAgent??"claude-code",options:[{value:"claude-code",label:"Claude Code (Anthropic)"},{value:"codex",label:"Codex (OpenAI)"}]})})},_e={id:"location",title:"Location & language",isApplicable:()=>!0,execute:async(e,{prompt:a,info:t})=>{t({title:"Which country are you finding businesses in?",body:`Klaudius searches for businesses in this country, writes outreach in
|
|
7
7
|
this country's language, and builds sites in this country's language.
|
|
8
8
|
This is the country your customers are in \u2014 not necessarily where
|
|
9
9
|
you live.
|
|
@@ -14,12 +14,12 @@ businesses, pick United Kingdom here.
|
|
|
14
14
|
You can run the pipeline against more than one country from the same
|
|
15
15
|
install (\`/find Barcelona\` from a UK install works fine), but
|
|
16
16
|
starting with one market makes it easier to learn that market's
|
|
17
|
-
outreach rhythm.`});let
|
|
17
|
+
outreach rhythm.`});let n="__other__",r=[{value:"the United Kingdom",label:"United Kingdom"},{value:"the United States",label:"United States"},{value:"Italy",label:"Italy"},{value:"Spain",label:"Spain"},{value:"France",label:"France"},{value:"Germany",label:"Germany"},{value:"Ireland",label:"Ireland"},{value:"the Netherlands",label:"Netherlands"},{value:"Belgium",label:"Belgium"},{value:"Portugal",label:"Portugal"},{value:"Switzerland",label:"Switzerland"},{value:"Austria",label:"Austria"},{value:"Canada",label:"Canada"},{value:"Australia",label:"Australia"},{value:"New Zealand",label:"New Zealand"},{value:"Mexico",label:"Mexico"},{value:"Brazil",label:"Brazil"},{value:"Sweden",label:"Sweden"},{value:"Poland",label:"Poland"},{value:n,label:"Other (type it in)"}],s=e.country??"",o=r.some(m=>m.value===s),d=await a({type:"select",message:"Which country's businesses will Klaudius search for?",initialValue:o?s:s?n:"the United Kingdom",options:r}),i;d===n?i=await a({type:"text",message:"Type the country name (any common form is fine)",placeholder:"e.g. South Africa, Greece, Brazil",initialValue:o?"":s,validate:m=>m.trim().length===0?"Country is required":void 0,note:{title:"Free-form country",body:`We'll match what you type against our country lookup (covers all
|
|
18
18
|
ISO 3166 sovereign states + common territories like Hong Kong and
|
|
19
19
|
Puerto Rico). If we don't recognise the name, we'll ask you to type
|
|
20
20
|
the 2-letter ISO country code directly on the next prompt \u2014 the
|
|
21
21
|
same code Google Places uses for region biasing. Aliases like 'uk',
|
|
22
|
-
'usa', 'italia', 'maroc' all match.`}}):
|
|
22
|
+
'usa', 'italia', 'maroc' all match.`}}):i=d;let u=we(i),l;u?l=u.code:l=(await a({type:"text",message:`What's the 2-letter ISO country code for ${i}?`,placeholder:"e.g. ID for Indonesia, ZA for South Africa, JO for Jordan",initialValue:e.countryCode??"",validate:m=>{let v=m.trim().toUpperCase();if(!/^[A-Z]{2}$/.test(v))return"Must be exactly 2 letters (ISO 3166-1 alpha-2 format)"},note:{title:`ISO code for ${i}`,body:`We didn't recognise "${i}" in our country lookup, so we need the
|
|
23
23
|
2-letter ISO 3166-1 alpha-2 code directly. Google Places uses this
|
|
24
24
|
for region biasing on every search.
|
|
25
25
|
|
|
@@ -28,14 +28,14 @@ Full list: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
|
|
28
28
|
Quick reference for less common markets:
|
|
29
29
|
Indonesia \u2192 ID Vietnam \u2192 VN Thailand \u2192 TH Egypt \u2192 EG
|
|
30
30
|
Kenya \u2192 KE Nigeria \u2192 NG Pakistan \u2192 PK Iran \u2192 IR
|
|
31
|
-
Saudi Arabia \u2192 SA Russia \u2192 RU Ukraine \u2192 UA Israel \u2192 IL`}})).trim().toUpperCase();let
|
|
32
|
-
for ${
|
|
31
|
+
Saudi Arabia \u2192 SA Russia \u2192 RU Ukraine \u2192 UA Israel \u2192 IL`}})).trim().toUpperCase();let h=e.language??u?.language??"English",g=await a({type:"text",message:"What language should outreach + websites be written in?",placeholder:"e.g. Italian, Spanish, English",initialValue:h,validate:m=>m.trim().length===0?"Language is required":void 0,note:{title:"Outreach + website language",body:u?`Defaulting to ${h} (the usual operator-facing language
|
|
32
|
+
for ${i}). Edit this if you'd rather write in something else \u2014
|
|
33
33
|
e.g. an English-speaking operator running on Spain might pick "Spanish"
|
|
34
34
|
to localise everything, or might pick "English" to keep their own voice.
|
|
35
35
|
Klaudius will use this language for every outreach message it sends and
|
|
36
36
|
every website it builds.`:`Pick the language you want every outreach message and every built
|
|
37
37
|
website to be written in. If we don't recognise the language name
|
|
38
|
-
we'll ask for the ISO language code on the next prompt.`}}),k=
|
|
38
|
+
we'll ask for the ISO language code on the next prompt.`}}),k=Ce(g),p;return k?p=k.code:p=(await a({type:"text",message:`What's the ISO language code for ${g}?`,placeholder:"e.g. id for Indonesian, sw for Swahili, fil for Filipino",initialValue:e.languageCode??"",validate:m=>{let v=m.trim().toLowerCase();if(!/^[a-z]{2,3}$/.test(v))return"Must be 2 or 3 lowercase letters (ISO 639-1 or BCP 47 code)"},note:{title:`ISO code for ${g}`,body:`We didn't recognise "${g}" in our language lookup, so we need
|
|
39
39
|
the ISO language code directly. Google Places uses this for response
|
|
40
40
|
language, and it becomes the <html lang="..."> value on every built
|
|
41
41
|
site.
|
|
@@ -43,22 +43,26 @@ site.
|
|
|
43
43
|
Most languages have a 2-letter ISO 639-1 code. A few (Filipino \u2192
|
|
44
44
|
"fil") use the 3-letter ISO 639-3 / BCP 47 code instead.
|
|
45
45
|
|
|
46
|
-
Full list: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes`}})).trim().toLowerCase(),{country:
|
|
47
|
-
stream). Rescue
|
|
48
|
-
verifiably broken: dead domain, hosting
|
|
49
|
-
errors, doesn't work on phones
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
Full list: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes`}})).trim().toLowerCase(),{country:u?u.country:i.trim(),countryCode:l,language:k?k.language:g.trim(),languageCode:p}}},$e={id:"pipeline-modes",title:"Lead streams",isApplicable:()=>!0,execute:async(e,{prompt:a})=>{let t=await a({type:"multiselect",message:"Which extra lead streams should the pipeline target?",options:[{value:"rescue",label:"Rescue - businesses whose existing website is dead or broken"},{value:"booking",label:"Booking - businesses whose only web presence is a booking-platform page (Fresha, Booksy, Square...)"}],initialValue:e.pipelineModes?e.pipelineModes.filter(o=>o!=="classic").join(","):"rescue,booking",note:{title:"Lead streams",body:`Klaudius always targets businesses with NO website (the classic
|
|
47
|
+
stream) - that one is always on. Rescue ADDS businesses whose
|
|
48
|
+
existing site is verifiably broken: dead domain, hosting
|
|
49
|
+
placeholder, security errors, doesn't work on phones. Booking
|
|
50
|
+
ADDS salons, clinics, spas and studios whose Google listing
|
|
51
|
+
points at a booking platform instead of a real website - they
|
|
52
|
+
already pay for booking software, and the site built for them
|
|
53
|
+
gets a complete booking system of its own. Both streams are
|
|
54
|
+
gated by bundled checkers, not judgment. Change any time by
|
|
55
|
+
asking your agent or re-running npx klaudius configure.`}}),n=new Set(["rescue","booking"]),r=String(t).split(",").map(o=>o.trim()).filter(o=>n.has(o)),s=(e.pipelineModes??[]).filter(o=>o!=="classic"&&!n.has(o));return{pipelineModes:[...new Set(["classic",...r,...s])]}}},je={id:"pricing",title:"Pricing",isApplicable:()=>!0,execute:async(e,{prompt:a})=>{let t=e.pricingTerms===ke,n=t?"":e.pricing??"$999",r=e.pricingMonthly??(t?e.pricing??"":""),s=await a({type:"text",message:"What's the upfront fee you'll charge clients per site?",placeholder:"e.g. $999, \xA3799, \u20AC899 \u2014 or 0 for monthly-only billing",initialValue:n,note:{title:"Upfront fee",body:`The one-time amount charged when a client signs up. Type 0 (or
|
|
52
56
|
leave blank) if you only want to charge a monthly fee. You can
|
|
53
57
|
also add a recurring monthly fee on the next prompt \u2014 combining
|
|
54
58
|
the two is fine (e.g. $499 upfront + $49/month).
|
|
55
59
|
|
|
56
60
|
Use the currency that matches your clients' region. Klaudius
|
|
57
|
-
uses this string verbatim throughout outreach.`}}),
|
|
61
|
+
uses this string verbatim throughout outreach.`}}),o=await a({type:"text",message:"What's the monthly fee? (optional \u2014 leave blank for one-off only)",placeholder:"e.g. $49, \xA339, \u20AC45 \u2014 or blank for none",initialValue:r,validate:h=>{if(H(s)&&H(h))return"Set an upfront fee, a monthly fee, or both \u2014 they can't both be zero."},note:{title:"Monthly fee (optional)",body:`Leave blank to charge a one-off fee only. Fill it in to charge
|
|
58
62
|
a recurring monthly fee \u2014 either on its own (if upfront was 0)
|
|
59
|
-
or alongside the upfront fee.`}}),c=H(
|
|
63
|
+
or alongside the upfront fee.`}}),c=H(s),d=H(o),i,u,l;return c&&!d?(i=o.trim(),u=ke,l=o.trim()):!c&&d?(i=s.trim(),u=He,l=void 0):(i=s.trim(),u=`upfront, then ${o.trim()}/month`,l=o.trim()),{pricing:i,pricingTerms:u,pricingMonthly:l}}},qe={id:"outreach-enabled",title:"Automated outreach",isApplicable:()=>!0,execute:async(e,{prompt:a})=>({outreachEnabled:await a({type:"confirm",message:"Use Klaudius's automated outreach features?",initialValue:e.outreachEnabled??!0,note:{title:"Automated outreach features",body:`After finding candidates and building websites for them, Klaudius can
|
|
60
64
|
run outreach to them automatically (email, SMS, or WhatsApp).
|
|
61
|
-
If you'd rather handle outreach manually, you can skip this here.`}})})},
|
|
65
|
+
If you'd rather handle outreach manually, you can skip this here.`}})})},Ye={id:"operator-name",title:"Sign-off name",isApplicable:e=>e.outreachEnabled===!0,execute:async(e,{prompt:a})=>({name:await a({type:"text",message:"What name should sign off your outreach messages?",placeholder:"e.g. Mike Smith \u2014 or your business name if you'd rather",initialValue:e.name??e.emailFromName??"",validate:B("Name"),note:{title:"Sign-off name",body:`Klaudius signs off every outreach message and follow-up with this
|
|
62
66
|
name \u2014 e.g. "Cordiali saluti, Marco" in Italian, "Best, Mike" in
|
|
63
67
|
English. Use your first name, your full name, or your business name \u2014
|
|
64
68
|
whatever you want clients to see as the sender.
|
|
@@ -66,7 +70,7 @@ whatever you want clients to see as the sender.
|
|
|
66
70
|
Klaudius composes the actual sign-off line at message time, picking
|
|
67
71
|
natural phrasing for your language. If you'd rather pin an exact
|
|
68
72
|
sign-off string instead, ask Klaudius to set it up for you once the
|
|
69
|
-
wizard's done.`}}),signature:e.signature})},
|
|
73
|
+
wizard's done.`}}),signature:e.signature})},Ze={id:"channels",title:"Outreach channels & priority",isApplicable:e=>e.outreachEnabled===!0,execute:async(e,{prompt:a,info:t})=>{t({title:"Outreach channels & priority",body:`Different businesses have different contact methods publicly available \u2014 some
|
|
70
74
|
list only an email, others only a phone number, others use WhatsApp as their
|
|
71
75
|
primary channel. Klaudius lets you opt into multiple channels so it can reach
|
|
72
76
|
more candidates, and you set a priority order for when a candidate has
|
|
@@ -80,9 +84,9 @@ candidate \u2014 so opting into multiple channels also gives you fallback covera
|
|
|
80
84
|
when one channel doesn't work.
|
|
81
85
|
|
|
82
86
|
You'll be asked to pick your first-choice channel now, then optionally a
|
|
83
|
-
second and third. The order matters: it's the order Klaudius tries.`});let
|
|
87
|
+
second and third. The order matters: it's the order Klaudius tries.`});let n={email:"Email",sms:"SMS (iMessage or Twilio, configured next)",whatsapp:"WhatsApp (Baileys / phone-linked device)"},r=["email","sms","whatsapp"],s=e.outreachPriority??[],o=[],c=await a({type:"select",message:"Which channel should Klaudius try FIRST for each candidate?",initialValue:s[0]??"email",options:r.map(d=>({value:d,label:n[d]}))});for(o.push(c);o.length<r.length;){let d=r.filter(g=>!o.includes(g)),i=o.length===1?"second":"third",u=o[o.length-1],l=n[u].replace(/\s*\(.*\)$/,"").toLowerCase(),h=await a({type:"select",message:`Should Klaudius use another channel as ${i} priority (for candidates where ${l} isn't viable or fails)?`,initialValue:s[o.length]??"no",options:[...d.map(g=>({value:g,label:`Yes \u2014 also use ${n[g]}`})),{value:"no",label:"No, that's all"}]});if(h==="no")break;o.push(h)}return{outreachChannels:o,outreachPriority:o}}},Je={id:"email",title:"Email setup",isApplicable:e=>e.outreachChannels?.includes("email")===!0,execute:async(e,{prompt:a,info:t})=>{t({title:"Email setup",body:`Klaudius needs an email account to send outreach FROM. This is the
|
|
84
88
|
address candidates will see as the sender. Use a domain you control
|
|
85
|
-
(your own, your business's) \u2014 not your personal address.`});let
|
|
89
|
+
(your own, your business's) \u2014 not your personal address.`});let n=await a({type:"select",message:"Who hosts the email account you'll send outreach from?",initialValue:e.emailProvider??"gmail",options:[{value:"gmail",label:"Gmail"},{value:"fastmail",label:"Fastmail"},{value:"outlook",label:"Outlook / Office 365"},{value:"zoho",label:"Zoho Mail"},{value:"ionos",label:"IONOS"},{value:"titan",label:"Titan (123 Reg, Hostinger, Name.com\u2026)"},{value:"custom",label:"Custom / other (enter SMTP/IMAP details manually)"}]}),r=n!=="custom"?ge[n]:void 0;if(r?.oauthOnly){t({title:"How Outlook / Microsoft 365 connects",body:`Microsoft no longer allows password-based access to its mailboxes
|
|
86
90
|
(app passwords included \u2014 Microsoft retired them), so there's no
|
|
87
91
|
password to paste here.
|
|
88
92
|
|
|
@@ -90,15 +94,15 @@ Instead, at the end of setup you'll sign in to Microsoft ONCE in
|
|
|
90
94
|
your browser and approve Klaudius reading and sending your mail.
|
|
91
95
|
Your password never passes through Klaudius, and you can revoke
|
|
92
96
|
the access any time at https://account.microsoft.com (or, for
|
|
93
|
-
work accounts, https://myapps.microsoft.com).`});let
|
|
97
|
+
work accounts, https://myapps.microsoft.com).`});let p=await a({type:"text",message:"Outlook / Microsoft 365 address to send outreach from",placeholder:"you@yourbusiness.com",initialValue:e.emailAddress??"",validate:ve}),m=r;return{emailProvider:n,emailAuth:"oauth-microsoft",emailAddress:p,emailPassword:e.emailPassword??"",emailFromName:e.name,emailSmtpHost:m.smtpHost,emailSmtpPort:m.smtpPort,emailImapHost:m.imapHost,emailImapPort:m.imapPort,emailSentFolder:m.sentFolder,emailInboxFolder:m.inboxFolder}}let s=await a({type:"text",message:"Email address to send outreach from",placeholder:"you@yourbusiness.com",initialValue:e.emailAddress??"",validate:ve}),o=r?.appPasswordHelp??he,c=r?.usesAccountPassword??!1,d=await a({type:"password",message:c?"Paste your mailbox password":"Paste the app password",initialValue:e.emailPassword??"",validate:B(c?"Mailbox password":"App password"),note:{title:c?"Mailbox password":"App password",body:(r&&!c?`An app password is a separate, single-purpose password that your
|
|
94
98
|
email provider issues for third-party apps like Klaudius. It is NOT
|
|
95
99
|
your normal account login password.
|
|
96
100
|
|
|
97
|
-
`:"")+
|
|
101
|
+
`:"")+o+`
|
|
98
102
|
|
|
99
103
|
The password is stored locally in this project's .env file.
|
|
100
104
|
It is never sent to Klaudius's servers \u2014 only to your email
|
|
101
|
-
provider when sending outreach.`}}),
|
|
105
|
+
provider when sending outreach.`}}),i,u,l,h,g,k;if(n==="custom"){i=await a({type:"text",message:"SMTP host (the server Klaudius connects to for sending)",placeholder:"e.g. smtp.yourprovider.com",initialValue:e.emailSmtpHost??"",validate:B("SMTP host")});let p=await a({type:"text",message:"SMTP port (usually 587 for STARTTLS or 465 for SSL)",initialValue:String(e.emailSmtpPort??587),validate:v=>/^\d+$/.test(v)?void 0:"Must be a number"});u=parseInt(p,10),l=await a({type:"text",message:"IMAP host (the server Klaudius connects to for reading replies)",placeholder:"e.g. imap.yourprovider.com",initialValue:e.emailImapHost??"",validate:B("IMAP host")});let m=await a({type:"text",message:"IMAP port (usually 993 for SSL)",initialValue:String(e.emailImapPort??993),validate:v=>/^\d+$/.test(v)?void 0:"Must be a number"});h=parseInt(m,10),g=await a({type:"text",message:"Sent folder name (so SMTP-sent messages also appear in your email client's Sent folder)",placeholder:'e.g. "Sent", "Sent Items"',initialValue:e.emailSentFolder??"Sent"}),k=await a({type:"text",message:"Inbox folder name (almost always INBOX)",initialValue:e.emailInboxFolder??"INBOX"})}else{let p=r,m=n===e.emailProvider,v=m?e.emailSmtpHost:void 0,J=m?e.emailSmtpPort:void 0,M=m?e.emailImapHost:void 0,Q=m?e.emailImapPort:void 0,N=!!v&&v!==p.smtpHost||!!M&&M!==p.imapHost;if(await a({type:"select",message:`Server settings for ${p.label}`,initialValue:N?"manual":"standard",options:[{value:"standard",label:`Use the standard ${p.label} servers \u2014 ${p.smtpHost} (Recommended)`},{value:"manual",label:"Enter servers manually (regional accounts, custom setups)"}],note:p.serverHelp?{title:"Server settings",body:p.serverHelp}:void 0})==="manual"){i=await a({type:"text",message:"SMTP host (the server Klaudius connects to for sending)",initialValue:v??p.smtpHost,validate:B("SMTP host")});let X=await a({type:"text",message:"SMTP port (usually 587 for STARTTLS or 465 for SSL)",initialValue:String(J??p.smtpPort),validate:w=>/^\d+$/.test(w)?void 0:"Must be a number"});u=parseInt(X,10),l=await a({type:"text",message:"IMAP host (the server Klaudius connects to for reading replies)",initialValue:M??p.imapHost,validate:B("IMAP host")});let b=await a({type:"text",message:"IMAP port (usually 993 for SSL)",initialValue:String(Q??p.imapPort),validate:w=>/^\d+$/.test(w)?void 0:"Must be a number"});h=parseInt(b,10),g=(m?e.emailSentFolder:void 0)??p.sentFolder,k=(m?e.emailInboxFolder:void 0)??p.inboxFolder}else i=p.smtpHost,u=p.smtpPort,l=p.imapHost,h=p.imapPort,g=p.sentFolder,k=p.inboxFolder}return{emailProvider:n,emailAuth:"password",emailAddress:s,emailPassword:d,emailFromName:e.name,emailSmtpHost:i,emailSmtpPort:u,emailImapHost:l,emailImapPort:h,emailSentFolder:g,emailInboxFolder:k}}},Qe={id:"sms",title:"SMS setup",isApplicable:e=>e.outreachChannels?.includes("sms")===!0,execute:async(e,{prompt:a,info:t})=>{t({title:"SMS setup",body:`Klaudius can send SMS one of two ways:
|
|
102
106
|
|
|
103
107
|
\u2022 macOS iMessage \u2014 free, uses Messages.app on your Mac.
|
|
104
108
|
Reaches other Apple users as iMessage for free. To reach
|
|
@@ -114,7 +118,7 @@ provider when sending outreach.`}}),l,r,u,p,g,k;if(t==="custom"){l=await a({type
|
|
|
114
118
|
|
|
115
119
|
\u2022 Twilio \u2014 cross-platform, ~$0.01 per SMS. Sender is a phone
|
|
116
120
|
number you buy from Twilio. Works on any OS, reaches any
|
|
117
|
-
phone, no iPhone required. Recommended for consistent delivery.`});let
|
|
121
|
+
phone, no iPhone required. Recommended for consistent delivery.`});let n=await a({type:"select",message:"Which SMS provider?",initialValue:e.smsProvider??(process.platform==="darwin"?"imessage":"twilio"),options:[{value:"imessage",label:"macOS iMessage (free, Mac only)"},{value:"twilio",label:"Twilio (cross-platform, paid per-message \u2014 recommended)"}]}),r=await a({type:"text",message:"Your mobile number (used as a safe target for test sends so Klaudius doesn't accidentally message real candidates while you're testing)",placeholder:"+12025550123",initialValue:e.testPhone??"",validate:Se}),s={smsProvider:n,testPhone:r};return n==="twilio"&&(s.twilioAccountSid=await a({type:"text",message:"Twilio Account SID (starts with AC...)",initialValue:e.twilioAccountSid??"",validate:o=>/^AC[a-zA-Z0-9]+$/.test(o)?void 0:"Should start with 'AC'"}),s.twilioAuthToken=await a({type:"password",message:"Twilio Auth Token",initialValue:e.twilioAuthToken??"",validate:ze("Twilio Auth Token")}),s.twilioPhoneNumber=await a({type:"text",message:"Twilio phone number (the number outreach will be sent FROM)",placeholder:"+15551234567",initialValue:e.twilioPhoneNumber??"",validate:Se})),s}},Xe={id:"whatsapp",title:"WhatsApp setup",isApplicable:e=>e.outreachPriority?.includes("whatsapp")===!0,execute:async(e,{prompt:a,info:t})=>{t({title:"WhatsApp setup",body:`Klaudius connects to WhatsApp as a linked device on your phone \u2014 same way
|
|
118
122
|
WhatsApp Web works. Setup is a one-time QR scan from the WhatsApp app on
|
|
119
123
|
the phone whose number you want to use. Klaudius will guide you through
|
|
120
124
|
that AFTER this wizard, once npm dependencies are installed.
|
|
@@ -127,7 +131,7 @@ a separate phone number per account (they're tied to real SIMs).
|
|
|
127
131
|
|
|
128
132
|
You'll be asked how many accounts to link and a short label for each
|
|
129
133
|
(used only locally \u2014 appears in logs, in the .env file, and in this
|
|
130
|
-
project's per-account directory under ~/.klaudius/whatsapp/).`});let
|
|
134
|
+
project's per-account directory under ~/.klaudius/whatsapp/).`});let n=await a({type:"select",message:"How many WhatsApp numbers do you want to link?",initialValue:String(e.whatsappAccounts?.length??1),options:[{value:"1",label:"1 number (recommended starting point)"},{value:"2",label:"2 numbers (spread load across two)"},{value:"3",label:"3 numbers"},{value:"4",label:"4 numbers"},{value:"5",label:"5 numbers (maximum)"}]}),r=parseInt(n,10),s=["primary","secondary","tertiary","quaternary","quinary"],o=[];for(let c=0;c<r;c++){let d=await a({type:"text",message:r===1?"Label for this WhatsApp account (used only locally \u2014 'primary' is fine)":`Label for WhatsApp account ${c+1} of ${r} (e.g. 'primary', 'uk-1', 'us-east')`,initialValue:e.whatsappAccounts?.[c]??s[c],validate:i=>{let u=i.trim();if(!u)return"Required";if(u.length>30)return"Too long (max 30 characters)";if(u.startsWith("-")||u.endsWith("-"))return"Can't start or end with a hyphen";if(!/^[A-Za-z0-9_-]+$/.test(u))return"Letters, digits, underscore, hyphen only (no spaces)";if(o.includes(u))return"Duplicate label"}});o.push(d.trim())}return{whatsappAccounts:o}}},ea={id:"deploy-provider",title:"Deployment host",isApplicable:()=>!0,execute:async(e,{prompt:a,info:t})=>(t({title:"Where should Klaudius deploy the websites it builds?",body:`Every client site Klaudius builds is a static website, so it deploys
|
|
131
135
|
cleanly to any of the hosts below \u2014 pick whichever you'd rather have
|
|
132
136
|
an account with. All have a free tier that's plenty to get started.
|
|
133
137
|
|
|
@@ -141,7 +145,7 @@ an account with. All have a free tier that's plenty to get started.
|
|
|
141
145
|
This only changes where sites are hosted and which credential you set
|
|
142
146
|
up next. Everything else \u2014 how sites are found, built, and pitched \u2014
|
|
143
147
|
is identical. (The optional dynamic add-ons \u2014 CMS, live Google
|
|
144
|
-
rating, booking \u2014 are Vercel-only today.)`}),{deployProvider:await a({type:"select",message:"Which host should Klaudius deploy client sites to?",initialValue:e.deployProvider??"vercel",options:[{value:"vercel",label:"Vercel (default)"},{value:"cloudflare",label:"Cloudflare Pages"},{value:"netlify",label:"Netlify"},{value:"selfhost",label:"Self-hosted (your own server over SSH)"}]})})},
|
|
148
|
+
rating, booking \u2014 are Vercel-only today.)`}),{deployProvider:await a({type:"select",message:"Which host should Klaudius deploy client sites to?",initialValue:e.deployProvider??"vercel",options:[{value:"vercel",label:"Vercel (default)"},{value:"cloudflare",label:"Cloudflare Pages"},{value:"netlify",label:"Netlify"},{value:"selfhost",label:"Self-hosted (your own server over SSH)"}]})})},aa={id:"vercel",title:"Vercel deployment",isApplicable:e=>(e.deployProvider??"vercel")==="vercel",execute:async(e,{prompt:a})=>({vercelToken:await a({type:"password",message:"Paste your Vercel API token",initialValue:e.vercelToken??"",validate:n=>n.trim().length===0?"Required \u2014 without this Klaudius can't deploy generated sites":void 0,note:{title:"Vercel deployment",body:`Klaudius deploys every generated client site to Vercel. We use a
|
|
145
149
|
Vercel API token to do this without an interactive login.
|
|
146
150
|
|
|
147
151
|
How to get one (one-time, ~30 seconds):
|
|
@@ -164,7 +168,7 @@ STUCK? Open Claude (or any LLM) in another tab/app and paste:
|
|
|
164
168
|
"I need to create a personal Vercel API token for the
|
|
165
169
|
Klaudius CLI tool. Walk me through generating one at
|
|
166
170
|
vercel.com/account/tokens, including which scope and
|
|
167
|
-
expiration to choose."`}})})},
|
|
171
|
+
expiration to choose."`}})})},na={id:"cloudflare",title:"Cloudflare deployment",isApplicable:e=>e.deployProvider==="cloudflare",execute:async(e,{prompt:a})=>{let t=await a({type:"password",message:"Paste your Cloudflare API token",initialValue:e.cloudflareApiToken??"",validate:r=>r.trim().length===0?"Required \u2014 without this Klaudius can't deploy generated sites":void 0,note:{title:"Cloudflare API token",body:`Klaudius deploys every generated client site to Cloudflare Pages
|
|
168
172
|
using \`wrangler\`. It authenticates with an API token (no interactive
|
|
169
173
|
login), so no browser step at deploy time.
|
|
170
174
|
|
|
@@ -191,7 +195,7 @@ STUCK? Open Claude (or any LLM) in another tab/app and paste:
|
|
|
191
195
|
through creating a Custom Token at
|
|
192
196
|
dash.cloudflare.com/profile/api-tokens with the
|
|
193
197
|
'Account \u2192 Cloudflare Pages \u2192 Edit' permission, and tell me
|
|
194
|
-
where to find my Account ID."`}}),
|
|
198
|
+
where to find my Account ID."`}}),n=await a({type:"text",message:"Paste your Cloudflare Account ID",placeholder:"e.g. 0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d",initialValue:e.cloudflareAccountId??"",validate:r=>{let s=r.trim();if(s.length===0)return"Required \u2014 wrangler needs it to pick the right account";if(!/^[0-9a-f]{32}$/i.test(s))return"Should be a 32-character hex string (copy it from the dashboard, not the token)"},note:{title:"Cloudflare Account ID",body:`This tells \`wrangler\` which account to deploy into. It's separate
|
|
195
199
|
from the API token above.
|
|
196
200
|
|
|
197
201
|
Where to find it:
|
|
@@ -201,7 +205,7 @@ Where to find it:
|
|
|
201
205
|
the account's Workers & Pages overview page under 'Account ID'
|
|
202
206
|
|
|
203
207
|
Without it, wrangler shows an interactive account picker that would
|
|
204
|
-
stall an unattended pipeline run, so Klaudius requires it up front.`}});return{cloudflareApiToken:
|
|
208
|
+
stall an unattended pipeline run, so Klaudius requires it up front.`}});return{cloudflareApiToken:t,cloudflareAccountId:n.trim()}}},ta={id:"netlify",title:"Netlify deployment",isApplicable:e=>e.deployProvider==="netlify",execute:async(e,{prompt:a})=>({netlifyAuthToken:await a({type:"password",message:"Paste your Netlify access token",initialValue:e.netlifyAuthToken??"",validate:n=>n.trim().length===0?"Required \u2014 without this Klaudius can't deploy generated sites":void 0,note:{title:"Netlify access token",body:`Klaudius deploys every generated client site to Netlify using the
|
|
205
209
|
Netlify CLI. It authenticates with a personal access token (no
|
|
206
210
|
interactive login), so there's no browser step at deploy time.
|
|
207
211
|
|
|
@@ -224,7 +228,7 @@ STUCK? Open Claude (or any LLM) in another tab/app and paste:
|
|
|
224
228
|
"I need to create a personal access token for the Klaudius CLI
|
|
225
229
|
tool in Netlify. Walk me through generating one at
|
|
226
230
|
app.netlify.com/user/applications, including which expiry to
|
|
227
|
-
choose."`}})})},
|
|
231
|
+
choose."`}})})},oa={id:"selfhost",title:"Self-host deployment",isApplicable:e=>e.deployProvider==="selfhost",execute:async(e,{prompt:a})=>{let t=await a({type:"text",message:"Where should sites be uploaded? (rsync destination)",placeholder:"e.g. deploy@203.0.113.7:/var/www/klaudius-sites",initialValue:e.selfhostDeployTarget??"",validate:me,note:{title:"Self-host deployment",body:`Klaudius builds each client site locally as plain static files and
|
|
228
232
|
uploads them to your server with rsync over SSH. Each client gets
|
|
229
233
|
its own subdirectory under the destination you enter here, e.g.
|
|
230
234
|
deploy@yourvps:/var/www/klaudius-sites \u2192 .../klaudius-sites/<slug>/
|
|
@@ -239,7 +243,7 @@ STUCK? Open Claude (or any LLM) and paste:
|
|
|
239
243
|
"I'm setting up passwordless SSH key auth from my machine to
|
|
240
244
|
my VPS so an automated rsync deploy can upload files. Walk me
|
|
241
245
|
through ssh-keygen and ssh-copy-id, and where to put a custom
|
|
242
|
-
port in ~/.ssh/config."`}}),
|
|
246
|
+
port in ~/.ssh/config."`}}),n=await a({type:"text",message:"What URL will each site be served at? (use {slug} in the hostname)",placeholder:"e.g. https://{slug}.sites.your-domain.com",initialValue:e.selfhostUrlTemplate??"",validate:ye,note:{title:"Public URL pattern",body:`The deploy substitutes each client's slug into this template to get
|
|
243
247
|
the live URL it records and pitches. {slug} must be in the HOSTNAME
|
|
244
248
|
(each site is served from the root of its own subdomain) because
|
|
245
249
|
static exports use root-absolute asset links.
|
|
@@ -255,7 +259,7 @@ deploy end-to-end. STUCK on the server config? Paste into any LLM:
|
|
|
255
259
|
"Help me configure nginx (or Caddy) with a wildcard vhost that
|
|
256
260
|
serves https://<name>.sites.example.com from
|
|
257
261
|
/var/www/klaudius-sites/<name>/, plus a wildcard Let's Encrypt
|
|
258
|
-
certificate via DNS-01."`}});return{selfhostDeployTarget:
|
|
262
|
+
certificate via DNS-01."`}});return{selfhostDeployTarget:t.trim().replace(/\/+$/,""),selfhostUrlTemplate:n.trim()}}},sa={id:"supabase",title:"Supabase",isApplicable:()=>!0,execute:async(e,{prompt:a,info:t})=>{t({title:"Supabase setup",body:`Supabase is your CRM. It's where Klaudius records every business it
|
|
259
263
|
finds, where each one sits in your funnel (gathered \u2192 built \u2192 deployed
|
|
260
264
|
\u2192 outreach sent \u2192 responded), and the follow-up state for every lead.
|
|
261
265
|
You can browse it at any time from the Supabase dashboard, or ask
|
|
@@ -289,12 +293,12 @@ in another tab/app and paste this prompt verbatim:
|
|
|
289
293
|
The wizard is asking for: (1) project URL, (2) the secret/service-
|
|
290
294
|
role key, (3) a personal access token. Walk me through where to
|
|
291
295
|
find each one in the current Supabase dashboard UI, including the
|
|
292
|
-
exact menu paths and any caveats for newer vs. legacy projects."`});let
|
|
296
|
+
exact menu paths and any caveats for newer vs. legacy projects."`});let r=(await a({type:"text",message:"Paste your Supabase API URL",placeholder:"https://YOUR_REF.supabase.co",initialValue:e.supabaseUrl??"",validate:u=>/^https:\/\/[a-z0-9]+\.supabase\.co(\/rest\/v1\/?)?$/i.test(u.trim())?void 0:"Should look like https://xxxx.supabase.co (with or without /rest/v1/)",note:{title:"API URL",body:`In your Supabase dashboard, open your project, then go to:
|
|
293
297
|
Settings \u2192 Data API \u2192 'API URL'
|
|
294
298
|
|
|
295
299
|
It looks like https://xxxx.supabase.co. Click to copy and paste
|
|
296
|
-
below.`}})).trim().replace(/\/rest\/v1\/?$/i,"").replace(/\/$/,""),
|
|
297
|
-
https://supabase.com/dashboard/project/${
|
|
300
|
+
below.`}})).trim().replace(/\/rest\/v1\/?$/i,"").replace(/\/$/,""),s=r.match(/^https:\/\/([a-z0-9]+)\.supabase\.co/i)?.[1]??"",c=(await a({type:"password",message:"Paste the Supabase secret key (sb_secret_\u2026)",initialValue:e.supabaseServiceKey??"",validate:u=>{let l=u.trim(),h=ae(l);if(h)return h;if(l.length<20)return"Looks too short";if(l.startsWith("sb_publishable_"))return"That's the publishable key. Klaudius needs the 'sb_secret_\u2026' key on the same page (different row, below the publishable one).";if(!l.startsWith("sb_secret_")&&!l.startsWith("eyJ"))return"Doesn't look like a Supabase secret key. Expected 'sb_secret_\u2026' (or a legacy JWT starting with 'eyJ\u2026' on older projects)."},note:{title:"Secret key",body:`Open this exact page:
|
|
301
|
+
https://supabase.com/dashboard/project/${s}/settings/api-keys
|
|
298
302
|
|
|
299
303
|
Under 'Secret keys', find the row whose value starts with
|
|
300
304
|
'sb_secret_'. Click to copy the full value.
|
|
@@ -305,7 +309,7 @@ are client-side keys with no write permissions).
|
|
|
305
309
|
Don't confuse this page with 'Edge Functions \u2192 Secrets' in the
|
|
306
310
|
left sidebar \u2014 that's an unrelated feature (env vars for Edge
|
|
307
311
|
Functions). The page you want is Settings (gear icon, bottom
|
|
308
|
-
of the left sidebar) \u2192 API Keys.`}})).replace(/\s+/g,""),
|
|
312
|
+
of the left sidebar) \u2192 API Keys.`}})).replace(/\s+/g,""),i=(await a({type:"password",message:"Paste the Supabase personal access token",initialValue:e.supabasePat??"",validate:Ge,note:{title:"Personal access token",body:`This is a separate credential from the secret key above \u2014 it's an
|
|
309
313
|
ACCOUNT-wide token (not project-scoped) used by the Supabase MCP and
|
|
310
314
|
by Klaudius's schema migration.
|
|
311
315
|
|
|
@@ -315,7 +319,7 @@ Open this exact page:
|
|
|
315
319
|
Click 'Generate new token', name it 'Klaudius', and set the
|
|
316
320
|
expiration to 'Never' (recommended \u2014 saves you having to rotate
|
|
317
321
|
it later). Copy the value (starts with 'sbp_') and paste it
|
|
318
|
-
below.`}})).replace(/\s+/g,"");return{supabaseUrl:
|
|
322
|
+
below.`}})).replace(/\s+/g,"");return{supabaseUrl:r,supabaseServiceKey:c,supabasePat:i,supabaseProjectRef:s}}},ia={id:"google-places",title:"Google Places API",isApplicable:()=>!0,execute:async(e,{prompt:a})=>{let t=await a({type:"password",message:"Paste your Google Places API key",placeholder:"AIzaSy\u2026",initialValue:e.googlePlacesApiKey??"",validate:r=>be(r),note:{title:"Google Places API key",body:`Klaudius's /find skill queries Google's Places API to discover businesses
|
|
319
323
|
without websites in your target region. Without a key, the pipeline has
|
|
320
324
|
no source of leads \u2014 so this is required.
|
|
321
325
|
|
|
@@ -351,13 +355,13 @@ STUCK? Open Claude (or any LLM) in another tab/app and paste this prompt:
|
|
|
351
355
|
"I need a Google Places API (New) key for a CLI tool called
|
|
352
356
|
Klaudius. Walk me through claiming the $300 Google Cloud free trial
|
|
353
357
|
and getting the API key Google auto-generates after enabling
|
|
354
|
-
Places API (New), including any signup gotchas."`}});return{googlePlacesApiKey:
|
|
358
|
+
Places API (New), including any signup gotchas."`}});return{googlePlacesApiKey:fe(t).value}}},la={id:"notifications",title:"Notifications (optional)",isApplicable:()=>!0,clearOnSkip:["notifyChannel","notifyTo","telegramBotToken","telegramChatId"],execute:async(e,{prompt:a})=>{let t=!!e.emailAddress,n=!!e.smsProvider||!!e.testPhone,r=e.notifyChannel==="telegram"?!!e.telegramBotToken:e.notifyChannel==="email"?t:e.notifyChannel==="sms"?n:!1,s=await a({type:"select",message:"How should Klaudius send you pipeline alerts?",initialValue:r?e.notifyChannel:e.telegramBotToken?"telegram":"none",options:[{value:"telegram",label:"Telegram (recommended \u2014 instant phone pings, free)"},...t?[{value:"email",label:"Email (to your own inbox, reuses your outreach account)"}]:[],...n?[{value:"sms",label:"SMS (to your own phone, via your configured SMS setup)"}]:[],{value:"none",label:"None"}],note:{title:"Pipeline notifications (optional)",body:`Klaudius alerts you when outreach lands and when anything needs a
|
|
355
359
|
human eye (a failed deploy, an API error, odd-looking data).
|
|
356
360
|
|
|
357
361
|
\u2022 Telegram \u2014 needs a bot token (via @BotFather, ~30 seconds);
|
|
358
362
|
the next prompts walk you through it.
|
|
359
363
|
\u2022 Email / SMS \u2014 zero extra setup; alerts go to your own
|
|
360
|
-
inbox/phone through the account you already configured.`}});if(
|
|
364
|
+
inbox/phone through the account you already configured.`}});if(s==="none")return{notifyChannel:void 0,notifyTo:void 0,telegramBotToken:void 0,telegramChatId:void 0};if(s==="email"||s==="sms"){let l=s==="email"?e.emailAddress:e.testPhone,h=await a({type:"text",message:s==="email"?"Where should alert emails go?":"Which number should alert texts go to?",initialValue:e.notifyTo??l??"",validate:g=>g.trim().length===0?"Required":void 0});return{notifyChannel:s,notifyTo:h.trim()}}let o=await a({type:"password",message:"Paste your Telegram bot token",initialValue:e.telegramBotToken??"",validate:B("Bot token"),note:{title:"Bot token",body:`Telegram lets you create personal bots in ~30 seconds. Klaudius
|
|
361
365
|
uses a bot to send you private notifications.
|
|
362
366
|
|
|
363
367
|
How to create one:
|
|
@@ -370,16 +374,16 @@ How to create one:
|
|
|
370
374
|
'KlaudiusNotifierBot'). Each username has to be globally
|
|
371
375
|
unique, so add a personal suffix if it's taken.
|
|
372
376
|
6. BotFather replies with a token like
|
|
373
|
-
'1234567890:AAEhBP_yourtokenhere\u2026'. Copy it and paste below.`}}),c=null,d=0,
|
|
377
|
+
'1234567890:AAEhBP_yourtokenhere\u2026'. Copy it and paste below.`}}),c=null,d=0,i=null,u=null;for(;c===null;){d++;let l=d>1,h=u==="network"?`${i}
|
|
374
378
|
|
|
375
379
|
This is usually a network problem on your end (corporate WiFi or VPN
|
|
376
380
|
blocking Telegram, ISP DNS issue, a momentary drop). Check your
|
|
377
381
|
connection, try a different network if available, then press Enter
|
|
378
|
-
to retry.`:`${
|
|
382
|
+
to retry.`:`${i}
|
|
379
383
|
|
|
380
384
|
Make sure you sent a regular text message (e.g. 'hi'), not
|
|
381
385
|
just a /start tap \u2014 /start alone doesn't always register.
|
|
382
|
-
Then press Enter to retry.`;await a({type:"text",message:u
|
|
386
|
+
Then press Enter to retry.`;await a({type:"text",message:l?u==="network"?"Check your network, then press Enter to retry":"Send another message to the bot, then press Enter to retry":"Send a message to your bot, then press Enter to detect chat ID",initialValue:"",placeholder:"(press Enter when you've sent the message)",validate:()=>{},note:{title:l?"Detect chat ID \u2014 retry":"Detect chat ID",body:l?h:`Klaudius will auto-detect your chat ID by asking Telegram for
|
|
383
387
|
any messages your bot has received. To make that work:
|
|
384
388
|
|
|
385
389
|
1. In the Telegram app, search for the bot you just created
|
|
@@ -388,5 +392,5 @@ any messages your bot has received. To make that work:
|
|
|
388
392
|
If the chat starts with a 'Start' button, tap that first,
|
|
389
393
|
THEN send 'hi'. /start alone doesn't always show up.
|
|
390
394
|
3. Press Enter below \u2014 Klaudius will detect the chat ID for
|
|
391
|
-
you.`}});let g=await
|
|
392
|
-
`);return
|
|
395
|
+
you.`}});let g=await pe({botToken:o});if(g.ok&&g.chatId)c=g.chatId;else if(g.reason==="no_messages")i="No messages from you to your bot have been picked up yet.",u="no_messages";else if(g.reason==="network")i=g.message??"Could not reach Telegram.",u="network";else throw new Error(`Telegram chat ID auto-detect failed: ${g.message??"unknown error"}`)}return{notifyChannel:"telegram",notifyTo:void 0,telegramBotToken:o,telegramChatId:c}}},O=[We,_e,$e,je,qe,Ye,Ze,Je,Qe,Xe,ea,aa,na,ta,oa,sa,ia,la];import{Box as Ae,Text as ra}from"ink";import{jsx as Pe,jsxs as da}from"react/jsx-runtime";var ua={pending:"\u25CB",current:"\u25C9",done:"\u2713",skipped:"\xB7"},ca={pending:void 0,current:"cyan",done:"green",skipped:void 0};function Ie({items:e}){return Pe(Ae,{flexDirection:"column",width:28,flexShrink:0,children:e.map(a=>{let t=a.status==="skipped"||a.status==="pending";return Pe(Ae,{children:da(ra,{color:ca[a.status],bold:a.status==="current",dimColor:t&&a.status!=="current",children:[ua[a.status]," ",a.title]})},a.id)})})}import{useEffect as ga,useState as Te}from"react";import{Box as ne,Text as _,useInput as ha}from"ink";import pa from"ink-text-input";import{jsx as U,jsxs as te}from"react/jsx-runtime";function xe({spec:e,masked:a,onSubmit:t,onBack:n}){let r=typeof e.initialValue=="string"?e.initialValue:"",s=a&&r.length>0,[o,c]=Te(s?"":r),[d,i]=Te(null);ga(()=>(S("TextPromptUI:mount",{masked:a,message:e.message.slice(0,60),initial:typeof e.initialValue=="string"?e.initialValue.slice(0,30):null}),()=>{S("TextPromptUI:unmount")}),[a,e.message,e.initialValue]),ha((l,h)=>{S("TextPromptUI:useInput fired",{input:l,ctrl:h.ctrl,escape:h.escape,return:h.return}),h.escape&&n()});let u=l=>{S("TextPromptUI:handleSubmit",{raw:l.slice(0,30)});let h=l.length===0&&s?r:l;if(e.validate){let g=e.validate(h);if(g){S("TextPromptUI:validate failed",{err:g}),i(g);return}}i(null),t(h)};return te(ne,{flexDirection:"column",children:[te(_,{children:[U(_,{color:"cyan",children:"?"})," ",e.message]}),te(ne,{children:[U(_,{color:"green",children:"\u203A "}),U(pa,{value:o,onChange:c,onSubmit:u,placeholder:s?"type or paste a new value \u2014 or press Enter to keep the current one":e.placeholder,mask:a?"\u2022":void 0})]}),d&&U(ne,{marginTop:0,children:U(_,{color:"red",children:d})})]})}import{useState as ma}from"react";import{Box as oe,Text as $,useInput as ya}from"ink";import{jsx as j,jsxs as se}from"react/jsx-runtime";function Ee({spec:e,onSubmit:a,onBack:t}){let n=e.options??[],r=typeof e.initialValue=="string"?Math.max(0,n.findIndex(c=>c.value===e.initialValue)):0,[s,o]=ma(r===-1?0:r);return ya((c,d)=>{if(d.escape)t();else if(d.upArrow)o(i=>(i-1+n.length)%n.length);else if(d.downArrow)o(i=>(i+1)%n.length);else if(d.return){let i=n[s];i&&a(i.value)}}),se(oe,{flexDirection:"column",children:[se($,{children:[j($,{color:"cyan",children:"?"})," ",e.message]}),j(oe,{flexDirection:"column",marginTop:0,children:n.map((c,d)=>{let i=d===s;return se($,{color:i?"cyan":void 0,bold:i,children:[i?"\u25CF ":"\u25CB ",c.label]},c.value)})}),j(oe,{marginTop:1,children:j($,{dimColor:!0,children:"Use the \u2191 \u2193 arrow keys to choose, then press Enter"})})]})}import{useState as fa}from"react";import{Box as ie,Text as L,useInput as ba}from"ink";import{jsx as q,jsxs as D}from"react/jsx-runtime";function Me({spec:e,onSubmit:a,onBack:t}){let[n,r]=fa(typeof e.initialValue=="boolean"?e.initialValue:!0);return ba((s,o)=>{o.escape?t():o.leftArrow||o.rightArrow?r(c=>!c):s==="y"||s==="Y"?r(!0):s==="n"||s==="N"?r(!1):o.return&&a(n)}),D(ie,{flexDirection:"column",children:[D(L,{children:[q(L,{color:"cyan",children:"?"})," ",e.message]}),D(ie,{marginTop:0,children:[D(L,{color:n?"cyan":void 0,bold:n,children:[n?"\u25CF ":"\u25CB ","Yes"]}),q(L,{children:" "}),D(L,{color:n?void 0:"cyan",bold:!n,children:[n?"\u25CB ":"\u25CF ","No"]})]}),q(ie,{marginTop:1,children:q(L,{dimColor:!0,children:"Use the \u2190 \u2192 arrow keys (or y / n) to choose, then press Enter"})})]})}import{useState as Ne}from"react";import{Box as le,Text as Y,useInput as wa}from"ink";import{jsx as Z,jsxs as re}from"react/jsx-runtime";function Be({spec:e,onSubmit:a,onBack:t}){let n=e.options??[],r=new Set(typeof e.initialValue=="string"?e.initialValue.split(",").map(i=>i.trim()).filter(Boolean):[]),[s,o]=Ne(0),[c,d]=Ne(r);return wa((i,u)=>{if(u.escape)t();else if(u.upArrow)o(l=>(l-1+n.length)%n.length);else if(u.downArrow)o(l=>(l+1)%n.length);else if(i===" "){let l=n[s];l&&d(h=>{let g=new Set(h);return g.has(l.value)?g.delete(l.value):g.add(l.value),g})}else u.return&&a(n.map(l=>l.value).filter(l=>c.has(l)).join(","))}),re(le,{flexDirection:"column",children:[re(Y,{children:[Z(Y,{color:"cyan",children:"?"})," ",e.message]}),Z(le,{flexDirection:"column",marginTop:0,children:n.map((i,u)=>{let l=u===s,h=c.has(i.value);return re(Y,{color:l?"cyan":void 0,bold:l,children:[l?"\u203A ":" ",h?"\u25C9 ":"\u25EF ",i.label]},i.value)})}),Z(le,{marginTop:1,children:Z(Y,{dimColor:!0,children:"\u2191 \u2193 to move, Space to tick/untick, Enter to confirm (ticking none is fine)"})})]})}import{Box as Oe,Text as Ke}from"ink";import{jsx as ue,jsxs as Ca}from"react/jsx-runtime";function ce({title:e,body:a}){let t=a.split(`
|
|
396
|
+
`);return Ca(Oe,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,children:[ue(Ke,{color:"cyan",bold:!0,children:e}),ue(Oe,{flexDirection:"column",marginTop:0,children:t.map((n,r)=>ue(Ke,{dimColor:!1,children:n.length===0?" ":n},r))})]})}import{jsx as f,jsxs as z}from"react/jsx-runtime";function Cn({defaults:e,onComplete:a,onlySection:t,banner:n}){let{exit:r}=ka(),s=de({...e}),o=de(new Map),[,c]=K(0),d=()=>c(b=>b+1),[i,u]=K(null),[l,h]=K(null),[g,k]=K([]),[p,m]=K(null),[v,J]=K(!1),[M,Q]=K({current:0,total:0}),N=()=>{let b=o.current;for(let w of O){let ee=w.isApplicable(s.current),y=b.get(w.id);ee?t&&w.id!==t?y!=="current"&&b.set(w.id,"done"):(y==="skipped"||!y)&&b.set(w.id,"pending"):b.set(w.id,"skipped")}};o.current.size===0&&N();let G=de(!1);Sa(()=>{if(S("WizardApp:useEffect fired",{startedAlready:G.current}),G.current){S("WizardApp:useEffect returning early (startedRef true)");return}G.current=!0,S("WizardApp:orchestrator starting");let b=0,w=y=>{let T=++b;return S("orchestrator:promptFn called",{id:T,type:y.type,message:y.message.slice(0,60)}),m(null),new Promise((A,C)=>{h({id:T,spec:y,resolve:x=>{S("orchestrator:prompt resolved",{id:T,type:y.type,value:typeof x=="string"?x.slice(0,30):x}),A(x)},reject:x=>{S("orchestrator:prompt rejected",{id:T,reason:x.message}),C(x)}})})},ee=y=>{k(T=>[...T,y])};return(async()=>{try{let y=t?O.filter(C=>C.id===t):O,T=()=>y.filter(C=>C.isApplicable(s.current)).length,A=0;for(;A<y.length;){let C=y[A];if(!C.isApplicable(s.current)){o.current.set(C.id,"skipped"),A++,N(),d();continue}k([]);for(let P of O)P.id===C.id?o.current.set(P.id,"current"):o.current.get(P.id)==="current"&&o.current.set(P.id,"pending");u(C.id);let x=y.slice(0,A+1).filter(P=>P.isApplicable(s.current)).length;Q({current:x,total:T()}),d();try{let P=await C.execute(s.current,{prompt:w,info:ee});s.current={...s.current,...P},o.current.set(C.id,"done"),N(),A++}catch(P){if(P instanceof F){if(t&&C.clearOnSkip){for(let Re of C.clearOnSkip)s.current[Re]=void 0;o.current.set(C.id,"skipped"),N(),A++;continue}if(t)continue;o.current.set(C.id,"pending");let V=A-1;for(;V>=0&&!y[V].isApplicable(s.current);)V--;V<0||(A=V,o.current.set(y[A].id,"pending")),N(),d();continue}throw P}}S("orchestrator:all sections done, calling onComplete + exit"),J(!0),h(null),u(null),d(),await new Promise(C=>setTimeout(C,200)),a(s.current),r()}catch(y){S("orchestrator:caught error",{name:y?.name,message:y?.message}),y instanceof W&&(r(),process.exit(0));let T=y instanceof Error?y.message:String(y);m(`Setup error: ${T}`),d()}})(),()=>{S("WizardApp:useEffect cleanup ran (component unmounting)")}},[r,a]),Aa((b,w)=>{S("WizardApp:useInput fired",{input:b,ctrl:w.ctrl,escape:w.escape,return:w.return}),w.ctrl&&b==="c"&&(S("WizardApp:Ctrl+C \u2192 exiting"),r(),process.exit(0))});let X=va(()=>O.map(b=>({id:b.id,title:b.title,status:o.current.get(b.id)??"pending"})),[i,v,p]);return z(I,{flexDirection:"column",paddingY:1,children:[z(I,{marginBottom:1,children:[f(E,{bold:!0,color:"cyan",children:"Klaudius setup"}),f(E,{dimColor:!0,children:" \xB7 "}),f(E,{dimColor:!0,children:M.total>0?`Step ${M.current} of ${M.total}`:"Loading\u2026"})]}),z(I,{children:[f(Ie,{items:X}),z(I,{flexDirection:"column",flexGrow:1,marginLeft:2,children:[n&&z(I,{marginBottom:1,borderStyle:"round",borderColor:"red",paddingX:1,flexDirection:"column",children:[f(E,{color:"red",bold:!0,children:"\u26A0 Heads up"}),f(E,{children:n})]}),!t&&i!==null&&i!=="ai-agent"&&f(I,{marginBottom:1,children:f(E,{color:"green",children:"Nothing here is permanent, you can customize any of this later."})}),g.map((b,w)=>f(I,{marginBottom:1,children:f(ce,{title:b.title,body:b.body})},w)),l?.spec.note&&f(I,{marginBottom:1,children:f(ce,{title:l.spec.note.title,body:l.spec.note.body})}),l&&Ia(l),p&&f(I,{marginTop:1,children:f(E,{color:"red",children:p})}),v&&f(I,{marginTop:1,children:f(E,{color:"green",bold:!0,children:"\u2713 Setup complete. Continuing\u2026"})})]})]}),f(I,{marginTop:1,children:f(E,{dimColor:!0,children:Pa(t,i)})})]})}function Pa(e,a){if(e){let t=O.find(n=>n.id===a);return t?.clearOnSkip&&t.clearOnSkip.length>0?"\u21B5 confirm esc skip this section ctrl-c cancel":"\u21B5 confirm ctrl-c cancel"}return"\u21B5 confirm esc back to previous section ctrl-c cancel"}function Ia(e){let a=n=>e.resolve(n),t=()=>e.reject(new F);switch(e.spec.type){case"text":case"password":return f(xe,{spec:e.spec,masked:e.spec.type==="password",onSubmit:a,onBack:t},e.id);case"select":return f(Ee,{spec:e.spec,onSubmit:a,onBack:t},e.id);case"multiselect":return f(Be,{spec:e.spec,onSubmit:a,onBack:t},e.id);case"confirm":return f(Me,{spec:e.spec,onSubmit:a,onBack:t},e.id)}}export{Cn as WizardApp};
|
package/dist/bin.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
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
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-
|
|
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-HWWSHTCK.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
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
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
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.
|
|
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. Add 'rescue' (businesses whose existing website is verifiably dead or bad) and/or 'booking' (businesses whose Google-listed website is a booking-platform page) \u2014 e.g. 'classic,rescue,booking' \u2014 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
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
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.
|
|
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.
|
|
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.24.0",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.24.0";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
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.
|
|
@@ -24,7 +24,7 @@ Please share that file so we can trace what happened.`);return s}var nt="claude-
|
|
|
24
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
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
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.
|
|
27
|
+
`,"utf-8")}var gn="0.24.0",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
|
|
@@ -86,7 +86,7 @@ password. Your browser will open to Microsoft's sign-in page \u2014
|
|
|
86
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
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:
|
|
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.24.0";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
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
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
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
|
|
@@ -103,4 +103,4 @@ except Exception as e:
|
|
|
103
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
104
|
If you haven't already, add '${i}' to WHATSAPP_ACCOUNTS in .env so /outreach round-robins to it. Example:
|
|
105
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.
|
|
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.24.0",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.
|
|
3
|
+
"version": "0.24.0",
|
|
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": {
|