kuriko 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Kuriko proprietary licence
2
+
3
+ Copyright (c) 2026 Kuriko. All rights reserved.
4
+
5
+ This software, including its source code, container images, infrastructure modules and
6
+ documentation, is proprietary to Kuriko. It is licensed, not sold.
7
+
8
+ You may install and use it only under a written agreement with Kuriko (for example a subscription or
9
+ evaluation agreement), within the scope and term that agreement sets. Without such an agreement you
10
+ may not use, copy, modify, distribute, sublicense, host for others, or create derivative works of it.
11
+
12
+ You may not remove or alter this notice, reverse engineer it except where the law allows despite this
13
+ restriction, or use it to build a competing product or service.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXCEPT AS YOUR AGREEMENT WITH KURIKO
16
+ EXPRESSLY STATES. TO THE EXTENT THE LAW ALLOWS, KURIKO IS NOT LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY ARISING FROM IT OR ITS USE, EXCEPT AS THAT AGREEMENT EXPRESSLY STATES.
18
+
package/README.md CHANGED
@@ -1,3 +1,13 @@
1
- # Temporary Holding Version
1
+ # kuriko
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Kuriko's admin CLI: install, upgrade and destroy Kuriko in your own cloud.
4
+
5
+ ```bash
6
+ npm i -g kuriko
7
+ kuriko help
8
+ ```
9
+
10
+ Kuriko runs in your own cloud (Google Cloud today). You need a Kuriko agreement, which comes with
11
+ access to Kuriko's images, plus gcloud and Terraform on the machine you run this from.
12
+
13
+ Proprietary software: see LICENSE.
package/kuriko.mjs ADDED
@@ -0,0 +1,171 @@
1
+ #!/usr/bin/env node
2
+ var S={version:"0.1.0"};import{parseArgs as wn}from"node:util";import{spawn as jr}from"node:child_process";import{stripVTControlCharacters as Er}from"node:util";var R=class extends Error{command;code;stderr;constructor(t,n,r){let o=Er(r);super(`${t} failed (exit ${n})${o.trim()?`:
3
+ ${o.trim().split(`
4
+ `).slice(-15).join(`
5
+ `)}`:""}`),this.command=t,this.code=n,this.stderr=o}get reason(){let t=this.stderr.split(`
6
+ `).map(n=>n.replace(/^[│╷╵\s]+/,"").trim()).filter(Boolean);return t.find(n=>/^error\b/i.test(n))?.replace(/^error:?\s*/i,"")??t[0]??`exit ${this.code}`}},bt=e=>/invalid_rapt|reauth related error|invalid_grant|Reauthentication (is )?(required|failed)/i.test(e);function p(e,t,n={}){return new Promise((r,o)=>{let i=jr(e,t,{cwd:n.cwd,env:n.env?{...process.env,...n.env}:process.env,stdio:n.inherit?"inherit":[n.input===void 0?"ignore":"pipe","pipe","pipe"]});n.input!==void 0&&i.stdin?.end(n.input);let s="",a="";i.stdout?.on("data",g=>(s+=g,n.tee&&process.stdout.write(g))),i.stderr?.on("data",g=>(a+=g,n.tee&&process.stderr.write(g))),i.on("error",g=>o(new R(e,null,g.message))),i.on("close",g=>g===0?r(s):o(new R(`${e} ${t[0]??""}`.trim(),g,a)))})}async function j(e,t,n={}){return JSON.parse(await p(e,t,n))}async function Y(e,t="--version"){try{return await p(e,[t]),!0}catch{return!1}}var ue=async e=>{try{return await p("gcloud",e),!0}catch(t){if(t instanceof R&&/NOT_FOUND|not found|does not exist|404/i.test(t.stderr))return!1;throw t}},Xe=async()=>(await p("gcloud",["config","get","account"])).trim();async function P(e={}){let t=async w=>{try{return await p("gcloud",w),null}catch(x){return x instanceof R&&bt(x.stderr)?"expired":"missing"}},[n,r]=await Promise.all([e.terraformOnly?null:t(["auth","print-access-token"]),t(["auth","application-default","print-access-token"])]);if(!n&&!r)return;let o=await Xe().catch(()=>""),i=o?` (as ${o})`:"",s=[...n?[` gcloud auth login${i}`]:[],...r?[` gcloud auth application-default login${i}`]:[]],a=[n&&"gcloud",r&&"Terraform"].filter(Boolean).join(" and "),g=n==="expired"||r==="expired";throw new Error(`${a}${g?`'s Google sign-in${n&&r?"s have":" has"} expired`:` ${n&&r?"aren't":"isn't"} signed in to Google`}. Run:
7
+ ${s.join(`
8
+ `)}`)}async function _t(){return(await j("gcloud",["organizations","list","--format=json"])).map(e=>({id:e.name.split("/")[1],name:e.displayName}))}async function xt(){return(await j("gcloud",["billing","accounts","list","--format=json"])).filter(e=>e.open).map(e=>({id:e.name.split("/")[1],name:e.displayName}))}async function X(e){try{let t=await j("gcloud",["projects","describe",e,"--format=json"]);return{number:t.projectNumber,state:t.lifecycleState}}catch(t){if(t instanceof R&&/not found|does not exist|permission/i.test(t.stderr))return null;throw t}}var St=(e,t)=>p("gcloud",["projects","create",e,`--organization=${t}`,"--name=Kuriko"]);async function jt(e){return(await j("gcloud",["billing","projects","describe",e,"--format=json"])).billingEnabled===!0}var Et=(e,t)=>p("gcloud",["billing","projects","link",e,`--billing-account=${t}`]),Rt=(e,t)=>p("gcloud",["services","enable",...t,`--project=${e}`]);async function It(e,t,n){return await ue(["storage","buckets","describe",`gs://${e}`,"--format=json"])?"exists":(await p("gcloud",["storage","buckets","create",`gs://${e}`,`--project=${t}`,`--location=${n}`,"--uniform-bucket-level-access","--public-access-prevention"]),await p("gcloud",["storage","buckets","update",`gs://${e}`,"--versioning"]),"created")}async function Ct(e){return(await j("gcloud",["sql","instances","list",`--project=${e}`,"--format=json"])).map(t=>({name:t.name,kuriko:t.settings?.userLabels?.["managed-by"]==="kuriko"}))}async function Tt(e,t,n,r){let o=[`--location=${t}`,`--project=${e}`,"--format=json"],i=await ue(["kms","keyrings","describe",n,...o]);return{ring:i,key:i&&await ue(["kms","keys","describe",r,`--keyring=${n}`,...o])}}async function At(e){return ue(["artifacts","docker","images","describe",e,"--format=json"])}async function de(e,t){return await ue(["secrets","describe",t,`--project=${e}`,"--format=json"])?(await j("gcloud",["secrets","versions","list",t,`--project=${e}`,"--filter=state:ENABLED","--format=json"])).length>0:null}async function xe(e,t,n){await de(e,t)===null?await p("gcloud",["secrets","create",t,`--project=${e}`,"--replication-policy=automatic","--labels=managed-by=kuriko-security-team","--data-file=-"],{input:n}):await p("gcloud",["secrets","versions","add",t,`--project=${e}`,"--data-file=-"],{input:n})}async function Pt(e,t,n){try{let o=await(await fetch("https://oauth2.googleapis.com/token",{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:e,client_secret:t,code:"kuriko-install-check",redirect_uri:n,grant_type:"authorization_code"})})).json().catch(()=>({}));return o.error==="invalid_client"||o.error==="unauthorized_client"?!1:o.error==="invalid_grant"?!0:null}catch{return null}}async function vt(e,t,n){let r=(await p("gcloud",["auth","print-access-token"])).trim(),o=new URL(`https://cloudidentity.googleapis.com/v1/${t}`);for(let[s,a]of Object.entries(n))o.searchParams.set(s,a);let i=await fetch(o,{headers:{authorization:`Bearer ${r}`,"x-goog-user-project":e}});if(i.status===404||i.status===403)return null;if(!i.ok)throw new Error(`Cloud Identity ${i.status}: ${(await i.text()).slice(0,300)}`);return await i.json()}async function Ze(e,t,n){let r=await vt(e,"groups:lookup",{"groupKey.id":t});if(!r?.name)return{exists:!1,isMember:!1};let o="";do{let i=await vt(e,`${r.name}/memberships:searchTransitiveMemberships`,{pageSize:"500",...o?{pageToken:o}:{}});if(i?.memberships?.some(s=>s.preferredMemberKey?.some(a=>a.id?.toLowerCase()===n.toLowerCase())))return{exists:!0,isMember:!0};o=i?.nextPageToken??""}while(o);return{exists:!0,isMember:!1}}async function Se(e,t,n,r){let o=[`--project=${e}`,`--region=${t}`],s=(await j("gcloud",["run","jobs","execute",n,...o,"--async","--format=json",...r?[`--args=^;;^${r.join(";;")}`]:[]])).metadata.name;for(;!(await j("gcloud",["run","jobs","executions","describe",s,...o,"--format=json"])).status?.completionTime;)await new Promise(g=>setTimeout(g,3e3));for(let a=0;a<12;a++){let w=(await j("gcloud",["logging","read",`resource.type="cloud_run_job" AND labels."run.googleapis.com/execution_name"="${s}"`,`--project=${e}`,"--freshness=1h","--order=asc","--format=json"])).map(l=>l.textPayload??"").filter(Boolean),x=w.map(l=>/Container called exit\((\d+)\)/.exec(l)).find(Boolean);if(x)return{code:Number(x[1]),logs:w.filter(l=>!/Container called exit/.test(l))};await new Promise(l=>setTimeout(l,5e3))}return{code:null,logs:[]}}async function Kt(e,t){return(await p("gcloud",["secrets","versions","list",t,`--project=${e}`,"--filter=state:ENABLED","--sort-by=~createTime","--limit=1","--format=value(name)"])).trim().split("/").pop()||null}async function Dt(e,t){return(await p("gcloud",["secrets","versions","access","latest",`--secret=${t}`,`--project=${e}`])).trim()}async function Nt(e,t){let n=(await p("gcloud",["auth","print-access-token"])).trim(),r=await fetch(`https://serviceusage.googleapis.com/v1beta1/projects/${e}/services/${t}:generateServiceIdentity`,{method:"POST",headers:{authorization:`Bearer ${n}`,"x-goog-user-project":e}});if(!r.ok)throw new Error(`Couldn't set up ${t}'s service account (${r.status}): ${(await r.text()).slice(0,200)}`)}async function Ot(e,t,n,r,o){try{let i=`${e.owner}/${r}`,s=Buffer.from(`${t}:${n}`).toString("base64"),a=await fetch(`https://${e.host}/token?service=${e.host}&scope=repository:${i}:pull`,{headers:{authorization:`Basic ${s}`}});if(a.status===401||a.status===403)return"denied";if(!a.ok)return"unreachable";let{token:g}=await a.json(),w=await fetch(`https://${e.host}/v2/${i}/manifests/${o}`,{method:"HEAD",headers:{authorization:`Bearer ${g}`,accept:"application/vnd.oci.image.index.v1+json, application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json"}});return w.ok?"ok":w.status===401||w.status===403?"denied":w.status===404?"missing":"unreachable"}catch{return"unreachable"}}import{relative as Nr}from"node:path";import{existsSync as je,readdirSync as Rr,readFileSync as Ie}from"node:fs";import{homedir as Ir}from"node:os";import{dirname as tt,join as G,relative as Cr,resolve as Ee}from"node:path";import{fileURLToPath as Tr}from"node:url";var C=Ee(Tr(new URL("../../..",import.meta.url))),Re="kuriko-installs.json";function L(e=process.cwd(),t=process.env){for(let n=Ee(e);;n=tt(n)){if(je(G(n,Re)))return n;if(tt(n)===n)break}for(let n of[t.KURIKO_INSTALLS,G(tt(C),"kuriko-installs")])if(n&&je(G(n,Re)))return Ee(n);return null}var Ce=`No installs repo found. Installs live in a git repo you share with whoever runs Kuriko:
9
+ clone yours next to the Kuriko checkout (or cd into it), or start one with: kuriko init <folder>`;function Z(e=process.cwd()){let t=L(e);if(!t)throw new Error(Ce);return t}function ge(e,t=process.cwd(),n=L(t)){if(e){let o=[Ee(t,e),n&&G(n,e)].find(i=>!!i&&rt(i));if(!o)throw new Error(`No Kuriko install at ${e}. Run kuriko list to see them.`);return o}let r=H(t,n);if(r.length===1)return r[0];throw r.length>1?new Error(`Several installs; choose one with --dir:
10
+ ${r.map(o=>` ${o}`).join(`
11
+ `)}`):new Error(n?"No Kuriko installs yet. Start one with: kuriko install":Ce)}function H(e=process.cwd(),t=L(e)){return rt(e)?[e]:!t||!je(t)?[]:Rr(t).sort().map(n=>G(t,n)).filter(rt)}function _(e,t=process.cwd()){let n=Cr(t,e);if(n&&!n.startsWith(".."))return n;let r=Ir();return e.startsWith(r)?`~${e.slice(r.length)}`:e}function Gt(e){let t=Ie(G(e,"main.tf"),"utf8"),n=r=>new RegExp(`^\\s*${r}\\s*=\\s*"([^"]+)"`,"m").exec(t)?.[1]??null;return{project:n("project_id"),region:n("region")}}var Lt=e=>/requested project was not found|project .* (was )?not found|has been deleted|DELETE_REQUESTED/i.test(e);function Mt(e){let t=e.filter(n=>n&&!/(^|\.)data\./.test(n));return t.includes("module.kuriko.google_cloud_run_v2_service.web")&&t.includes("module.kuriko.google_cloud_run_v2_service.gateway")?"installed":t.length?"partial":"empty"}function rt(e){let t=G(e,"main.tf");return je(t)&&/module\s+"kuriko"/.test(Ie(t,"utf8"))}function Ut(e){let t=Ie(G(e,"main.tf"),"utf8");return/variable\s+"deletion_protection"/.test(t)&&/deletion_protection\s*=\s*var\.deletion_protection/.test(t)}function Bt(e){try{let t=JSON.parse(Ie(G(e,".terraform","terraform.tfstate"),"utf8"));return t?.backend?.type==="gcs"?`gs://${t.backend.config.bucket}/${t.backend.config.prefix??""}`:null}catch{return null}}function qt(e){let t=e.values?.root_module;return[...t?.resources??[],...(t?.child_modules??[]).flatMap(n=>n.resources??[])]}import{emitKeypressEvents as Ar}from"node:readline";import{createInterface as zt}from"node:readline/promises";import{Writable as Pr}from"node:stream";import{stripVTControlCharacters as Wt,styleText as re}from"node:util";var u=e=>re("bold",e),m=e=>re("dim",e),ne=e=>re("red",e),at=e=>re("green",e),pe=e=>re("yellow",e),Te=e=>re("cyan",e),Jt="\u280B\u2819\u2839\u2838\u283C\u2834\u2826\u2827\u2807\u280F",ee=null,ot=null,nt=null,it=0,st=!1,ct=()=>process.stdout.isTTY===!0;function Ae(e){let t=Math.floor((Date.now()-e)/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${String(t%60).padStart(2,"0")}s`}function Kr(){let e=[ee&&`${ee.text} ${m(Ae(ee.start))}`,ot?.()&&m(ot())].filter(r=>!!r);if(!e.length)return null;let t=(process.stdout.columns||80)-1,n=`${Te(Jt[it])} ${e.join(m(" \xB7 "))}`;return Wt(n).length<=t?n:Wt(n).slice(0,t)}function Pe(){ct()&&process.stdout.write("\r\x1B[2K")}function te(){if(!ct()||st)return;Pe();let e=Kr();e&&process.stdout.write(e)}function Vt(){nt||!ct()||(nt=setInterval(()=>{it=(it+1)%Jt.length,te()},100),nt.unref())}function me(e){Pe(),console.log(e),te()}async function h(e,t){let n=ee;ee={text:e,start:Date.now()},Vt(),te();try{return await t()}finally{ee=n,Pe(),te()}}function lt(e){ot=e,Vt(),te()}async function ut(e){st=!0,Pe();try{return await e()}finally{st=!1,te()}}var d=(e="")=>me(e),b=e=>me(`
12
+ ${u("\u2192")} ${e}`),f=e=>me(` ${at("\u2713")} ${e}`),I=e=>me(` ${pe("!")} ${e}`);function dt(){if(!process.stdin.isTTY)throw new Error("This needs answers typed at a terminal; run it in your own terminal, not through a pipe.")}async function K(e,t){return dt(),ut(async()=>{let n=zt({input:process.stdin,output:process.stdout});try{return(await n.question(t?`${e} ${m(`[${t}]`)} `:`${e} `)).trim()||t||""}finally{n.close()}})}async function q(e,t=!1){let n=(await K(`${e} ${m(t?"[Y/n]":"[y/N]")}`)).toLowerCase();return n?n==="y"||n==="yes":t}async function Ke(e){return dt(),ut(()=>Dr(e))}async function Dr(e){let t=!1,n=new Pr({write(o,i,s){t||process.stdout.write(o),s()}}),r=zt({input:process.stdin,output:n,terminal:!0});try{let o=r.question(`${e} `);t=!0;let i=await o;return process.stdout.write(`
13
+ `),i.trim()}finally{r.close()}}async function M(e,t){dt();let n=t.map((r,o)=>r.disabled?-1:o).filter(r=>r>=0);if(!n.length)throw new Error(`Nothing to choose for: ${e}`);return ut(()=>new Promise(r=>{let o=process.stdin,i=o.isRaw,s=n[0],a=(c,$)=>{let F=c.disabled?m(c.label):$===s?u(c.label):c.label;return`${$===s?Te(" \u203A"):" "} ${F}${c.hint?` ${m(c.hint)}`:""}`},g=c=>{c||process.stdout.write(`\x1B[${t.length}A`);for(let[$,F]of t.entries())process.stdout.write(`\r\x1B[2K${a(F,$)}
14
+ `)},w=c=>{let $=n.indexOf(s);s=n[($+c+n.length)%n.length],g(!1)},x=()=>{o.off("keypress",l),o.setRawMode(i),o.pause(),process.stdout.write(`\x1B[${t.length+1}A\r\x1B[J${e} ${Te(t[s].label)}
15
+ `),r(t[s].value)},l=(c,$={})=>{if($.ctrl&&$.name==="c"){o.setRawMode(i),process.stdout.write(`
16
+ `),process.kill(process.pid,"SIGINT");return}$.name==="up"||$.name==="k"?w(-1):$.name==="down"||$.name==="j"||$.name==="tab"?w(1):$.name==="return"||$.name==="enter"?x():c&&/^[1-9]$/.test(c)&&n.includes(Number(c)-1)&&(s=Number(c)-1,g(!1))};process.stdout.write(`${e} ${m("(\u2191/\u2193, Enter)")}
17
+ `),g(!0),Ar(o),o.setRawMode(!0),o.resume(),o.on("keypress",l)}))}async function gt(e,t){let n=t.filter(r=>!r.disabled);return n.length===1&&t.length===1?(d(`${e} ${Te(n[0].label)}`),n[0].value):M(e,t)}function oe(e,t){me(`
18
+ ${u("\u270B")} ${u(e)}
19
+ ${t.map(n=>n?` ${n}`:"").join(`
20
+ `)}`)}var U=(e,t)=>p("git",["-C",e,...t]);async function Ft(e){try{return(await U(e,["rev-parse","--show-toplevel"])).trim()}catch{return null}}async function Yt(e){try{return(await U(e,["rev-parse","--abbrev-ref","--symbolic-full-name","@{u}"])).trim()}catch{return null}}async function ie(e){let t=await Ft(e);if(!t)return;let n=await Yt(t);if(!n)return;await h("Checking the installs repo is up to date",()=>U(t,["fetch","--quiet"]));let r=Number((await U(t,["rev-list","--count","HEAD..@{u}"])).trim());if(r>0)throw new Error(`The installs repo is ${r} commit${r===1?"":"s"} behind ${n}. Pull first:
21
+ git -C ${_(t)} pull`)}async function se(e,t,n={}){let r=await Ft(e[0]);if(!r)return;let o=e.map(a=>Nr(r,a)||".");if(await U(r,n.remove?["rm","-r","-q","--ignore-unmatch","--",...o]:["add","-A","--",...o]),!(await U(r,["diff","--cached","--name-only","--",...o])).trim())return;let s=await Yt(r);if(!await q(`
22
+ Commit this to the installs repo${s?` and push to ${s}`:""}?`,!0)){I(`Left uncommitted in ${_(r)}. Commit it so others running Kuriko see the change.`);return}await U(r,["commit","-q","-m",t,"--",...o]),s?(await h("Pushing",()=>U(r,["push","-q"])),f(`Committed and pushed: ${t}`)):(f(`Committed: ${t}`),d(" (no remote to push to; add one so others can pull it)"))}async function Ht(e,t,n){let r=i=>i.replace(/-dirty-.*$/,"");if(r(t)===r(n))return"same";let o=async(i,s)=>{try{return await U(e,["merge-base","--is-ancestor",r(i),r(s)]),!0}catch{return!1}};return await o(t,n)?"forward":await o(n,t)?"backward":"unknown"}import{existsSync as Or}from"node:fs";import{basename as Gr,join as Lr}from"node:path";var De={installed:{mark:"\u25CF",text:"installed"},partial:{mark:"\u25D0",text:"partly installed"},empty:{mark:"\u25CB",text:"not installed"},gone:{mark:"\u25CB",text:"project deleted"},unknown:{mark:"?",text:"status unknown"}};async function Mr(e){let{project:t,region:n}=Gt(e),r={dir:e,project:t??Gr(e),region:n??"?",status:"unknown"};if(!Or(Lr(e,".terraform")))return{...r,detail:"Terraform isn't set up here yet (run install to continue)"};try{let[o,i]=await Promise.all([p("terraform",["state","list","-no-color"],{cwd:e}),p("terraform",["output","-json"],{cwd:e}).then(s=>JSON.parse(s))]);r.status=Mt(o.split(`
23
+ `)),r.status==="installed"&&(r.web=String(i.web_url?.value??""),r.mcp=String(i.mcp_url?.value??""))}catch(o){let i=o instanceof R?o.reason:String(o);if(Lt(i))return{...r,status:"gone",detail:`Delete the leftover config when you're done with it: rm -r ${_(e)}`};r.detail=`Couldn't read its state: ${i}`}return r}var fe=e=>h(`Reading ${e.length} install${e.length===1?"":"s"}`,()=>Promise.all(e.map(Mr)));async function Ne(e,t,n,r={}){if(e)return ge(e);let o=H();if(!o.length)return ge(void 0);await P({terraformOnly:!0});let i=await fe(o);if(!i.filter(a=>n.includes(a.status)).length)throw new Error(`None of your installs can be used for this:
24
+ ${i.map(a=>` ${a.project}: ${De[a.status].text}`).join(`
25
+ `)}`);return i.length===1?i[0].dir:M(t,i.map(a=>{let g=De[a.status],w=n.includes(a.status);return{label:a.project,value:a.dir,disabled:!w,hint:`${a.region} ${g.mark} ${g.text}${!w&&r[a.status]?`: ${r[a.status]}`:""}`}}))}var B="module.kuriko",Ur=[`${B}.google_sql_database_instance.kuriko`,`${B}.google_sql_database.kuriko`,`${B}.google_sql_user.kuriko`,`${B}.google_cloud_run_v2_service.web`,`${B}.google_cloud_run_v2_service.gateway`,`${B}.google_cloud_run_v2_job.migrate`],Br=[`${B}.google_kms_crypto_key.user_tokens`,`${B}.google_kms_key_ring.kuriko`],qr=new Set(["deletion_protection","deletion_policy"]);function Wr(e){let t=qt(e).filter(l=>l.address.startsWith(`${B}.`)),n=t.find(l=>l.type==="google_project"&&l.mode==="data")?.values.project_id;if(typeof n!="string")throw new Error("This install has no Kuriko resources in its state (already destroyed, or never installed).");let r=t.filter(l=>l.mode==="managed"),o=l=>r.filter(c=>c.type===l),i=(l,c)=>String(l.values[c]??""),s=i(o("google_cloud_run_v2_service")[0]??o("google_artifact_registry_repository")[0]??{values:{}},"location"),a=[];for(let l of o("google_sql_database_instance"))a.push(`Cloud SQL instance ${u(i(l,"name"))} with all its data and backups: every user, tool, grant and audit record`);for(let l of o("google_cloud_run_v2_service"))a.push(`Cloud Run service ${i(l,"name")}`);for(let l of o("google_cloud_run_v2_job"))a.push(`Cloud Run job ${i(l,"name")}`);for(let l of o("google_secret_manager_secret"))a.push(`Secret ${i(l,"secret_id")} (generated by Kuriko)`);for(let l of o("google_service_account"))a.push(`Service account ${i(l,"email")}`);for(let l of o("google_artifact_registry_repository"))a.push(`Image repository ${i(l,"name")} and every image in it`);r.some(l=>l.type.endsWith("_iam_member"))&&a.push("Every IAM grant Kuriko made");let g=r.filter(l=>Br.includes(l.address)).map(l=>l.address),w=o("google_kms_crypto_key").map(l=>`${i(l,"key_ring").split("/").pop()}/${i(l,"name")}`),x=t.find(l=>l.type==="google_secret_manager_secret"&&l.mode==="data");return{project:n,region:s,deletes:a,release:g,keys:w,idpSecret:x?i(x,"secret_id"):null}}function zr(e){let t=[];for(let n of e.resource_changes??[]){let r=n.change.actions;if(r.length===1&&(r[0]==="no-op"||r[0]==="read"))continue;if(r.length!==1||r[0]!=="update"){t.push(`${n.address} would be ${r.join("/")}`);continue}let o=n.change.before??{},i=n.change.after??{},g=[...new Set([...Object.keys(o),...Object.keys(i),...Object.keys(n.change.after_unknown??{})])].filter(w=>n.change.after_unknown?.[w]===!0||JSON.stringify(o[w]??null)!==JSON.stringify(i[w]??null)).filter(w=>!qr.has(w));g.length&&t.push(`${n.address} would also change ${g.join(", ")}`)}return t}async function Qt(e){b("Checking this machine");for(let[c,$]of[["terraform","runs the install's Terraform"],["gcloud","finds what Kuriko created outside Terraform"]])if(!await Y(c))throw new Error(`${c} isn't installed (${$}).`);await P(),await ie(Z());let t=await Ne(e.dir,"Which install should be destroyed?",["installed","partial"],{empty:"nothing left to destroy",unknown:"can't read its state"}),n=(c,$=!1)=>p("terraform",c,{cwd:t,inherit:$});if(!Ut(t))throw new Error(`${t}/main.tf must pass deletion protection through to the module, so destroy can turn it off:
26
+ variable "deletion_protection" { type = bool, default = true }
27
+ and in module "kuriko": deletion_protection = var.deletion_protection`);f(`Install at ${_(t)}`),b("Reading the install");let r=Wr(await j("terraform",["show","-json"],{cwd:t})),o=["--project",r.project,"--format=json"],i=(await j("gcloud",["run","services","list","--region",r.region,...o])).filter(c=>c.metadata.labels?.["kuriko-tool"]).map(c=>c.metadata.name),s=(await j("gcloud",["secrets","list","--filter=name:kuriko-connector-",...o])).map(c=>c.name.split("/").pop()),a=Bt(t);d(`
28
+ ${u(`Destroying Kuriko in ${r.project} (${r.region}) deletes, permanently:`)}`);for(let c of i)d(` ${ne("\u2717")} Tool ${c} (Cloud Run service)`);for(let c of r.deletes)d(` ${ne("\u2717")} ${c}`);d(`
29
+ ${u("It keeps:")}`);let g=[...r.keys.map(c=>`KMS key ${c}. GCP never deletes keys; it costs cents a month and a reinstall here reuses it.`),...r.idpSecret?[`Your IdP client secret ${r.idpSecret}`]:[],...s.map(c=>`Your connector credential ${c}`),...a?[`Terraform state in ${a}`]:[],"The project itself and its enabled APIs"];for(let c of g)d(` ${m("\u2022")} ${c}`);if(e.dryRun){d(`
30
+ ${m("Dry run: nothing was changed.")}`);return}if((e.confirm??await K(`
31
+ Type the project id (${r.project}) to destroy this install: `))!==r.project){d("That doesn't match. Nothing was changed.");return}b("Turning off deletion protection");let x=".kuriko-unlock.plan";await n(["plan","-input=false","-var","deletion_protection=false",...Ur.map(c=>`-target=${c}`),`-out=${x}`]);let l=zr(JSON.parse(await n(["show","-json",x])));if(l.length)throw new Error(`The install's config doesn't match what's deployed, so turning off protection would change more than that:
32
+ ${l.map(c=>` ${c}`).join(`
33
+ `)}
34
+ Apply the config first (or fix it), then run destroy again.`);if(await n(["apply","-input=false",x],!0),f("Deletion protection is off"),i.length){b(`Deleting ${i.length} tool${i.length===1?"":"s"}`);for(let c of i)await p("gcloud",["run","services","delete",c,"--region",r.region,"--project",r.project,"--quiet"]),f(c)}r.release.length&&(b("Keeping the KMS key out of the destroy"),await n(["state","rm",...r.release]),f("Terraform no longer manages the key; it stays in the project")),b("Destroying everything else (Cloud SQL takes a few minutes)"),await n(["destroy","-input=false","-auto-approve","-var","deletion_protection=false"],!0),d(`
35
+ ${u(`Kuriko is gone from ${r.project}.`)} Still there, by design:`);for(let c of g)d(` ${m("\u2022")} ${c}`);d(`
36
+ ${u("Outside Google Cloud")} (yours to remove if you're done with Kuriko):`),d(` ${m("\u2022")} The OAuth client for Kuriko's sign-in, and the Groups Reader role assignment for the deleted kuriko-web account`),d(` ${m("\u2022")} Your kuriko-admins / kuriko-builders groups`),d(`
37
+ To remove everything at once: ${u(`gcloud projects delete ${r.project}`)}`),await se([t],`Destroy ${r.project}`,{remove:!0})}import{existsSync as yr,mkdirSync as rn,readFileSync as nn,writeFileSync as on}from"node:fs";import{join as be}from"node:path";var we="kuriko-idp-client-secret",he={ring:"kuriko",key:"user-tokens"};var Xt=["serviceusage.googleapis.com","cloudresourcemanager.googleapis.com","run.googleapis.com","sqladmin.googleapis.com","secretmanager.googleapis.com","cloudkms.googleapis.com","artifactregistry.googleapis.com","iam.googleapis.com","cloudidentity.googleapis.com","storage.googleapis.com"],Zt=["module.kuriko.google_project_service.apis","module.kuriko.google_artifact_registry_repository.kuriko","module.kuriko.google_service_account.gateway","module.kuriko.google_service_account.web","module.kuriko.google_service_account.tools"],Jr=/^[a-z][a-z0-9-]{4,28}[a-z0-9]$/,pt=e=>Jr.test(e),er=e=>/^[a-z]+-[a-z]+\d+$/.test(e),tr=e=>/^\d+-[a-z0-9]+\.apps\.googleusercontent\.com$/.test(e);function rr(e){let t=new Set(e);for(let n=0;;n++){let r=n===0?"kuriko":`kuriko-${n}`;if(!t.has(r))return r}}function nr(e){let t=/^(.*?)-(\d+)$/.exec(e);return t?`${t[1]}-${Number(t[2])+1}`:`${e}-1`}function or(e){return/(failed to create instance|google_sql_database_instance)[\s\S]{0,400}(instanceAlreadyExists|already exists|reuse the name)/i.test(e)}function ir(e){return/IAM_PERMISSION_DENIED|SERVICE_DISABLED|has not been used in project|it is disabled|API .* not enabled|Permission '.*' denied/i.test(e)}var Oe=(e,t)=>{let n=`https://kuriko-web-${t}.${e.region}.run.app`;return{web:n,mcp:`https://kuriko-gateway-${t}.${e.region}.run.app/mcp`,redirect:`${n}/api/auth/sso/callback/idp`,newClient:`https://console.cloud.google.com/auth/clients/create?project=${e.project}`,registry:`${e.region}-docker.pkg.dev/${e.project}/kuriko`,webServiceAccount:`kuriko-web@${e.project}.iam.gserviceaccount.com`}},E=e=>JSON.stringify(e);function sr(e,t,n,r=null){let o=r?`${e.region}-docker.pkg.dev/${e.project}/kuriko-releases/${r.owner}`:`${e.region}-docker.pkg.dev/${e.project}/kuriko`;return`# Kuriko install for ${e.domain}, written by \`kuriko install\`. Holds no secrets.
38
+ terraform {
39
+ backend "gcs" {
40
+ bucket = ${E(n)}
41
+ prefix = "kuriko"
42
+ }
43
+ }
44
+
45
+ variable "version_tag" { type = string }
46
+ variable "idp_client_id" { type = string }
47
+ variable "db_instance_name" { type = string }${r?`
48
+ variable "release_token_version" { type = string }`:""}
49
+ # Only \`kuriko destroy\` turns this off, for the one apply just before it deletes everything.
50
+ variable "deletion_protection" {
51
+ type = bool
52
+ default = true
53
+ }
54
+
55
+ locals {
56
+ repo = ${E(o)}
57
+ }
58
+
59
+ module "kuriko" {
60
+ source = ${E(t)}
61
+ project_id = ${E(e.project)}
62
+ region = ${E(e.region)}
63
+ db_instance_name = var.db_instance_name
64
+ deletion_protection = var.deletion_protection
65
+ images = {
66
+ gateway = "\${local.repo}/gateway:\${var.version_tag}"
67
+ web = "\${local.repo}/web:\${var.version_tag}"
68
+ migrate = "\${local.repo}/web-migrate:\${var.version_tag}"
69
+ }
70
+ idp = {
71
+ issuer = "https://accounts.google.com"
72
+ client_id = var.idp_client_id
73
+ domain = ${E(e.domain)}
74
+ groups_source = "google-workspace"
75
+ }${r?`
76
+ release_registry = {
77
+ upstream = ${E(r.upstream)}
78
+ username = ${E(r.username)}
79
+ token_secret_name = ${E(r.tokenSecret)}
80
+ token_version = var.release_token_version
81
+ }`:""}
82
+ }
83
+
84
+ output "web_url" { value = module.kuriko.web_url }
85
+ output "mcp_url" { value = module.kuriko.mcp_url }
86
+ output "idp_redirect_uri" { value = module.kuriko.idp_redirect_uri }
87
+ output "web_service_account" { value = module.kuriko.web_service_account }
88
+ output "migrate_job" { value = module.kuriko.migrate_job }
89
+ `}function ar(e,t,n=null){return[`version_tag = ${E(t)}`,`idp_client_id = ${E(e.idpClientId??"")}`,`db_instance_name = ${E(e.dbInstanceName)}`,...n?[`release_token_version = ${E(n.tokenVersion)}`]:[],""].join(`
90
+ `)}var Ge="module.kuriko.google_sql_database_instance.kuriko";function cr(e,t){let n=`projects/${e.project}/locations/${e.region}/keyRings/${he.ring}`;return["# Written by `kuriko install`: things already in the project that this install takes over.",...t.ring?[`import {
91
+ to = module.kuriko.google_kms_key_ring.kuriko
92
+ id = ${E(n)}
93
+ }`]:[],...t.key?[`import {
94
+ to = module.kuriko.google_kms_crypto_key.user_tokens
95
+ id = ${E(`${n}/cryptoKeys/${he.key}`)}
96
+ }`]:[],...t.sqlInstance?[`import {
97
+ to = ${Ge}
98
+ id = ${E(`projects/${e.project}/instances/${t.sqlInstance}`)}
99
+ }`]:[]].join(`
100
+
101
+ `)+`
102
+ `}function Le(e){let t=[];for(let n of e.resource_changes??[]){let r=n.change.actions,o=r.includes("delete")&&r.includes("create")?"replace":r[0]==="create"||r[0]==="update"||r[0]==="delete"?r[0]:null;o&&t.push({address:n.address.replace(/^module\.kuriko\./,""),action:o})}return t}function lr(e){return(e.resource_changes??[]).filter(t=>t.change.actions.includes("delete")).map(t=>t.address)}import{cpSync as gr,existsSync as pr,mkdtempSync as Zr,readFileSync as ht,rmSync as mr,writeFileSync as Ue}from"node:fs";import{tmpdir as en}from"node:os";import{join as z}from"node:path";import{cpSync as Vr,existsSync as Fr,mkdirSync as Yr,rmSync as Hr}from"node:fs";import{join as ft,relative as Qr}from"node:path";import{fileURLToPath as Xr}from"node:url";var v=typeof S>"u"?null:S,ke={upstream:"https://ghcr.io",host:"ghcr.io",owner:"usekuriko"},W="kuriko-release-token",mt=v?Xr(new URL("./module",import.meta.url)):ft(C,"infra/terraform/gcp"),Me=".kuriko/module";function ur(e){if(!v)return Qr(e,mt);let t=ft(e,Me);if(Hr(t,{recursive:!0,force:!0}),Yr(t,{recursive:!0}),Vr(mt,t,{recursive:!0,filter:n=>!/[/\\]\.terraform([/\\]|$)/.test(n)}),!Fr(ft(t,"main.tf")))throw new Error(`The Terraform module wasn't found in this package (${mt}).`);return`./${Me}`}var ae=e=>/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/.test(e);function dr(e,t){let n=i=>{let[s,a]=i.split("-",2);return{nums:s.split(".").map(Number),pre:a??null}},r=n(e),o=n(t);for(let i=0;i<3;i++)if(r.nums[i]!==o.nums[i])return r.nums[i]-o.nums[i];return r.pre===o.pre?0:r.pre===null?1:o.pre===null||r.pre<o.pre?-1:1}var J="kuriko.json";function V(e,t){Ue(z(e,J),JSON.stringify(t,null,2)+`
103
+ `)}function fr(e){try{return JSON.parse(ht(z(e,J),"utf8"))}catch{throw new Error(`${e} has no ${J}, so it wasn't made by kuriko install. Upgrade it by hand (terraform apply).`)}}var wt=null,Be=e=>wt=e;function ce(e,t,n){Ue(z(e,"terraform.tfvars"),ar(t,n,wt))}function qe(e,t){Ue(z(e,"main.tf"),sr(t,ur(e),`${t.project}-tfstate`,wt))}function hr(e){try{return/^version_tag\s*=\s*"([^"]+)"/m.exec(ht(z(e,"terraform.tfvars"),"utf8"))?.[1]??null}catch{return null}}async function ye(e,t){try{return(await p("terraform",["state","list"],{cwd:e})).split(`
104
+ `).includes(t)}catch{return!1}}async function We(e){if(v)return v.version;let t=(await p("git",["rev-parse","--short","HEAD"],{cwd:C})).trim();if(!(await p("git",["status","--porcelain"],{cwd:C})).trim())return t;if(!e)throw new Error("The Kuriko checkout has uncommitted changes, so its version isn't a commit. Commit them, or pass --allow-dirty.");return`${t}-dirty-${Date.now().toString(36)}`}async function wr(e,t){let n=r=>r.replace(/-dirty-.*$/,"");try{return(await p("git",["log","--oneline","--no-decorate",`${n(e)}..${n(t)}`],{cwd:C})).split(`
105
+ `).filter(Boolean)}catch{return[]}}async function kt(e,t,n){let r=`.kuriko-${t}.plan`;await p("terraform",["plan","-input=false",...(n??[]).map(s=>`-target=${s}`),`-out=${r}`],{cwd:e});let o=await j("terraform",["show","-json",r],{cwd:e}),i=lr(o);if(i.length)throw new Error(`This would delete or replace existing resources, which Kuriko never does on its own:
106
+ ${i.map(s=>` ${s}`).join(`
107
+ `)}
108
+ Nothing was changed.`);return{file:r,plan:o}}async function ze(e,t,n){let{file:r,plan:o}=await kt(e,t,n);Le(o).length&&await p("terraform",["apply","-input=false",r],{cwd:e})}async function Je(e,t,n){for(let r=1;;r++)try{return await ze(e,t,n)}catch(o){if(!(o instanceof R&&ir(o.stderr))||r>=8)throw o;await new Promise(i=>setTimeout(i,2e4))}}async function $e(e,t,n,r){let o=await h(`${r}, in the cloud`,()=>Se(e.project,e.region,t,n));if(o.code!==0)throw new Error(`${r} failed in the cloud:
109
+ ${o.logs.slice(-10).map(i=>` ${i}`).join(`
110
+ `)}`);f(r)}var tn=[["gateway","apps/gateway/Dockerfile",null],["web","apps/web/Dockerfile",null],["web-migrate","apps/web/Dockerfile","migrate"]];async function Ve(e,t,n){await p("gcloud",["auth","configure-docker",`${e}-docker.pkg.dev`,"--quiet"]);for(let[r,o,i]of tn){let s=`${t}/${r}:${n}`;if(await At(s)){f(`${r} (already pushed)`);continue}await h(`Building and pushing ${r}`,()=>p("docker",["buildx","build","--platform","linux/amd64","-f",o,...i?["--target",i]:[],"-t",s,"--push","."],{cwd:C})),f(r)}}async function Fe(e,t){let n=(s,a)=>h("Checking access to Kuriko's images",()=>Ot(ke,s,a,"gateway",t)),r=await de(e.project,W),o=!1;if(r&&e.releaseUsername){let s=await n(e.releaseUsername,await Dt(e.project,W));s==="ok"?o=!0:I(s==="missing"?`Kuriko ${t} isn't available with the stored token.`:"The stored registry token no longer works (expired or revoked).")}if(o)f(`Kuriko's images ${t}: access checked`);else for(oe("Access to Kuriko's images",["Kuriko's images are private. With your agreement, Kuriko gave you a registry username and token for",`${u(e.domain)}. They only let this install pull Kuriko's images. The token goes straight into this`,`project's Secret Manager (${W}), readable only by Artifact Registry.`]);;){let s=await K(`
111
+ Registry username:`,e.releaseUsername),a=await Ke(" Registry token (hidden as you type or paste):");if(!s||!a)continue;let g=await n(s,a);if(g==="denied"){I("That username and token can't pull Kuriko's images. Check both, or ask Kuriko for new ones.");continue}if(g==="missing")throw new Error(`Kuriko ${t} isn't published (or your token can't see it). Ask Kuriko, or use an earlier CLI version.`);g==="unreachable"&&I(`Couldn't reach ${ke.host} to check; storing the token anyway.`),await h("Storing the token",()=>xe(e.project,W,a)),e.releaseUsername=s,f("Registry token stored in Secret Manager");break}await h("Setting up Artifact Registry's service account",()=>Nt(e.project,"artifactregistry.googleapis.com"));let i=await Kt(e.project,W);if(!i)throw new Error(`${W} has no enabled version.`);return{upstream:ke.upstream,owner:ke.owner,username:e.releaseUsername,tokenSecret:W,tokenVersion:i}}function kr(e){let t=["main.tf","terraform.tfvars",J].map(i=>z(e,i)),n=t.map(i=>pr(i)?ht(i):null),r=z(e,Me),o=pr(r)?Zr(z(en(),"kuriko-module-")):null;return o&&gr(r,o,{recursive:!0}),()=>{t.forEach((i,s)=>n[s]?Ue(i,n[s]):mr(i,{force:!0})),mr(r,{recursive:!0,force:!0}),o&&gr(o,r,{recursive:!0})}}async function $r(e){d(`${u("Kuriko install")}
112
+
113
+ This puts Kuriko in your own cloud. Everything runs there, under your control: your people sign
114
+ in with the accounts they already have, and credentials stay in your own secret manager.
115
+
116
+ First a few questions; nothing is created until you've seen the plan and said yes. Then it takes
117
+ about 30 minutes, mostly waiting for the database. A few steps happen in your providers' admin
118
+ pages; this explains each one and checks it before moving on. If anything fails, run it again:
119
+ it picks up where it stopped.`);let t=Z();await ie(t);let n=e.dir?ge(e.dir):await ln(),r=n&&yr(be(n,J))?JSON.parse(nn(be(n,J),"utf8")):null;r||(d(""),await M("Where should Kuriko run?",[{label:"Google Cloud",value:"gcp",hint:"in a project of yours"},{label:"AWS",value:"aws",hint:"coming soon",disabled:!0},{label:"Azure",value:"azure",hint:"coming soon",disabled:!0},{label:"Managed by Kuriko",value:"managed",hint:"coming soon: we run it for you",disabled:!0}]),await M("Where do your people sign in?",[{label:"Google Workspace",value:"google-workspace"},{label:"Okta",value:"okta",hint:"coming soon",disabled:!0},{label:"Microsoft Entra ID",value:"entra",hint:"coming soon",disabled:!0},{label:"Another OIDC or SAML provider",value:"other",hint:"coming soon",disabled:!0}])),b("Checking this machine");for(let[k,y,T]of[["gcloud","Google Cloud's CLI: https://cloud.google.com/sdk/docs/install","--version"],["terraform","creates the cloud resources: https://developer.hashicorp.com/terraform/install","-version"]])if(!await Y(k,T))throw new Error(`${k} isn't installed (${y}).`);if(!v){if(!await Y("git","--version"))throw new Error("git isn't installed (it identifies the Kuriko version).");try{await p("docker",["info","--format","{{.ServerVersion}}"])}catch{throw new Error("Docker isn't running. Start Docker Desktop (it builds Kuriko's images), then run this again.")}}let o=await Xe();if(!o)throw new Error("gcloud isn't signed in. Run: gcloud auth login");let i=o.split("@")[1]??"";if(/^(gmail|googlemail)\.com$/.test(i))throw new Error(`gcloud is signed in as ${o}. Sign in with your Google Workspace admin account instead: gcloud auth login`);await P(),f(`Signed in to Google Cloud as ${o}`);let s;if(r){b(`Continuing the install in ${r.project}`);let k=await X(r.project);if(!k||k.state!=="ACTIVE")throw new Error(`Project ${r.project} isn't available (deleted, or your account can't see it).`);s=k.number,f(`Project ${r.project} ${m(`(${n})`)}`)}else{b("Your Google Cloud project"),d(" Kuriko should have a project to itself, so its permissions don't mix with anything else.");let k=await M("New project or existing?",[{label:"Create a new project",value:!0,hint:"recommended"},{label:"Use an existing, empty project",value:!1}]),y="",T=null;if(k){let A=await h("Finding your organization",()=>_t());if(!A.length)throw new Error(`${o} can't see any Google Cloud organization. Projects for Kuriko should live in your Workspace's organization.`);T=await gt("Organization:",A.map(O=>({label:O.name,value:O,hint:O.id}))),y=await Ye("Project ID (can't be changed later):",`kuriko-${Math.floor(1e3+Math.random()*9e3)}`,pt,"6\u201330 characters, starting with a letter: lowercase letters, digits and hyphens.")}else for(;y=await K("Project ID:"),!await h("Looking it up",()=>X(y));)d(` Can't find ${y}, or ${o} can't see it.`);let N=null;if(k||!await h("Checking billing",()=>jt(y))){let A=await h("Finding billing accounts",()=>xt());if(!A.length)throw new Error("No open billing account. Create one at https://console.cloud.google.com/billing, then run this again.");N=await gt("Billing account:",A.map(O=>({label:O.name,value:O,hint:O.id})))}let le=await cn();b("The plan");let Q=(A,O)=>d(` ${m(A.padEnd(10))}${O}`);if(Q("Runs in",`Google Cloud \xB7 ${k?`new project ${u(y)}${T?` in ${T.name}`:""}`:`existing project ${u(y)}`} \xB7 ${le}`),N&&Q("Billing",`${N.name} ${m(N.id)}`),Q("Sign-in",`Google Workspace \xB7 people at ${u(i)}`),Q("Admins",`kuriko-admins@${i}`),Q("Builders",`kuriko-builders@${i}`),Q("Cost","about $10\u201315 a month, almost all of it the database; the rest scales to zero when idle"),d(""),!await q("Start?",!0)){d("Nothing was created.");return}if(k){for(;;)try{await h(`Creating project ${y}`,()=>St(y,T.id));break}catch(A){if(!(A instanceof R&&/already (in use|exists)/i.test(A.stderr)))throw A;d(` ${y} is taken (project IDs are unique across all of Google Cloud).`),y=await Ye("Another project ID:",void 0,pt,"6\u201330 characters, starting with a letter: lowercase letters, digits and hyphens.")}f(`Created project ${y}`)}N&&(await h("Linking billing",()=>Et(y,N.id)),f("Billing linked")),s=(await X(y)).number,r={host:"gcp",sso:"google-workspace",project:y,region:le,domain:i,adminEmail:o,adminsGroup:`kuriko-admins@${i}`,buildersGroup:`kuriko-builders@${i}`,dbInstanceName:""},n=be(t,y),rn(n,{recursive:!0}),V(n,r)}let a=n,g=Oe(r,s);b("Turning on the Google Cloud services Kuriko uses"),await h("Enabling APIs",()=>Rt(r.project,Xt)),f("Cloud Run, Cloud SQL, Secret Manager, KMS, Artifact Registry, IAM, Cloud Identity"),b("Somewhere to keep Kuriko's Terraform state");let w=`${r.project}-tfstate`,x=await h("Creating the state bucket",()=>It(w,r.project,r.region));f(`gs://${w} ${m(`(${x}; versioned, private)`)}`);let l=await Ct(r.project);r.dbInstanceName||(r.dbInstanceName=rr(l.map(k=>k.name)),V(a,r));let c=await We(e.allowDirty);v&&(b(`Kuriko ${c}`),Be(await Fe(r,c)),V(a,r)),qe(a,r),await h("Preparing Terraform",()=>p("terraform",["init","-input=false"],{cwd:a}));let $={},F=()=>on(be(a,"imports.tf"),cr(r,$));await ye(a,"module.kuriko.google_kms_key_ring.kuriko")||(Object.assign($,await Tt(r.project,r.region,he.ring,he.key)),$.ring&&f("Found a KMS key from an earlier install; this one will reuse it")),F(),f(`Install config in ${a}`),b("Kuriko's service accounts and image registry"),ce(a,r,c),await h("Creating service accounts and the image registry",()=>Je(a,"bootstrap",Zt)),f("kuriko-web, kuriko-gateway and kuriko-tools service accounts; image registry"),b("Kuriko's database");let D={started:Date.now(),state:"creating",note:""},$t=Promise.resolve();if(await ye(a,Ge))D.state="ready",f(`Database ${r.dbInstanceName} ${m("(already created)")}`);else{let k=l.find(y=>y.name===r.dbInstanceName&&y.kuriko);if(k)$.sqlInstance=k.name,F(),f(`Found database ${k.name} from an earlier run; picking it up`);else if(d(" Cloud SQL takes 10\u201315 minutes to create, so it starts now and carries on while you do the next steps."),d(" It's most of Kuriko's cost: about $10\u201315 a month. The rest scales to zero when nobody's using it."),!await q(" Start creating it?",!0))throw new Error("Stopped before creating the database. Run install again to continue.");$t=sn(a,r,c,D).then(()=>D.state="ready",y=>(D.state="failed",y)),lt(()=>D.state==="creating"?`database: ${D.note||"creating"} (${Ae(D.started)})`:D.state==="ready"?"database: ready":"database: failed"),f("Started; it'll be ready in about 10\u201315 minutes")}for(v||(b(`Kuriko's images (version ${c})`),d(m(" Built from this checkout (development). Released versions pull Kuriko's published images instead.")),await Ve(r.region,g.registry,c)),oe("Let people sign in with Google (an OAuth app, in Google Cloud)",["Kuriko signs people in with their Google accounts. Google needs an OAuth app in this project for that.","",`1. Open ${u(g.newClient)}`,` If Google first asks you to set up the app (${u("Get started")}): App name ${u("Kuriko")}, support email: you,`,` Audience: ${u("Internal")} (only people in ${r.domain} can sign in), contact email: you. Agree, ${u("Create")},`," then open the link again. If it goes straight to a form for a new client, skip this.","",`2. Application type: ${u("Web application")}. Name: ${u("Kuriko")}.`,` Under Authorized redirect URIs, ${u("Add URI")} and paste exactly:`,` ${u(g.redirect)}`,` Then ${u("Create")}. A dialog shows the Client ID and Client secret: keep it open.`]);;){let k=await Ye(`
120
+ Client ID:`,r.idpClientId,tr,"It looks like 1234567890-abc123.apps.googleusercontent.com."),y=k!==r.idpClientId;if(r.idpClientId=k,V(a,r),await de(r.project,we)&&!y&&!await q(` A client secret is already in Secret Manager (${we}). Replace it?`)){f("Keeping the stored client secret");break}d(m(` The secret goes straight into Secret Manager as ${we}. It isn't shown or saved anywhere else.`));let N=await Ke(" Client secret (hidden as you type or paste):");if(!N)continue;let le=await h("Checking them with Google",()=>Pt(k,N,g.redirect));if(le===!1){I("Google doesn't accept that client ID and secret together. Copy both again from the same client.");continue}await h("Storing the secret",()=>xe(r.project,we,N)),f(`Client secret stored in Secret Manager${le?", and Google accepts it":""}`);break}for(oe("Decide who runs Kuriko (Google Groups, in the Google Admin console)",["Kuriko gives roles by Google Group, so access is managed where you already manage people:",` ${u(r.adminsGroup)} Admin: manages who can use which data, sees the audit log. Add yourself.`,` ${u(r.buildersGroup)} Builder: builds tools. Add the people who'll build.`,` Everyone else in ${r.domain} can sign in and use tools shared with them.`,"",`To create one: ${u("https://admin.google.com/ac/groups")} \u2192 ${u("Create group")}. Set the group email above,`,`and under access settings choose ${u("Restricted")} (only members see the member list) and no external members.`,"Then add members. Groups inside these groups count too."]);;){let[k,y]=await h("Looking for the groups",()=>Promise.all([Ze(r.project,r.adminsGroup,r.adminEmail),Ze(r.project,r.buildersGroup,r.adminEmail)])),T=[!k.exists&&r.adminsGroup,!y.exists&&r.buildersGroup].filter(Boolean);if(!T.length&&k.isMember){f(`Found ${r.adminsGroup} (you're in it) and ${r.buildersGroup}`);break}T.length?I(`Not found yet: ${T.join(", ")} (or ${r.adminEmail} can't see ${T.length>1?"them":"it"}).`):I(`${r.adminEmail} isn't in ${r.adminsGroup}. Add yourself, or you won't be an admin.`),await K(" Press Enter to check again.")}oe("Let Kuriko see group membership (Groups Reader role, in the Google Admin console)",["Google doesn't tell apps which groups someone is in when they sign in, so Kuriko asks Google","directly. It needs the Groups Reader admin role for that: it can read group membership and nothing else.","",`1. Open ${u("https://admin.google.com/ac/roles")} and click ${u("Groups Reader")}.`,`2. Open ${u("Admins")} (or "Assign role"), then ${u("Assign service accounts")}.`,`3. Paste ${u(g.webServiceAccount)}, click ${u("Add")}, then ${u("Assign role")}.`,"","It can take a few minutes to take effect. Kuriko checks it at the end."]),await K(" Press Enter when you've assigned it."),b("Creating Kuriko");let xr=await h("Waiting for the database",()=>$t);if(lt(null),D.state==="failed")throw xr;f(`Database ${r.dbInstanceName} ${m(`(${Ae(D.started)} in all)`)}`),ce(a,r,c),await h("Creating Kuriko's secrets, key and services",()=>Je(a,"install",null));for(let k of Object.keys($))delete $[k];for(F(),f("Kuriko's secrets, key and services"),b("Setting up Kuriko's database"),await $e(r,"kuriko-migrate",void 0,"Database schema"),await $e(r,"kuriko-migrate",["scripts/admin.ts","role-rules",`${r.adminsGroup}=Admin`,`${r.buildersGroup}=Builder`],"Roles for your two groups"),b("Checking Kuriko can see group membership");;){let k=await h("Checking as kuriko-web, in the cloud",()=>Se(r.project,r.region,"kuriko-migrate",["scripts/admin.ts","check-groups",r.adminEmail,r.adminsGroup]));if(k.code===0){f(`Kuriko sees you in ${r.adminsGroup}`);break}for(let y of k.logs.slice(-3))d(m(` ${y.trim()}`));k.code===3?I(`Kuriko can read groups, but doesn't see ${r.adminEmail} in ${r.adminsGroup}.`):I(`Kuriko can't read group membership yet. Check ${g.webServiceAccount} has Groups Reader (above); it can take a few minutes.`),await K(" Press Enter to check again.")}d(`
121
+ ${u("Kuriko is installed.")}
122
+
123
+ Sign in: ${u(g.web)}
124
+ Connect Claude Code: ${u(`claude mcp add --transport http kuriko ${g.mcp}`)}
125
+ then run /mcp in Claude Code and authenticate kuriko.
126
+
127
+ To let someone build: add them to ${r.buildersGroup} and send them the claude mcp add line.
128
+ Their first sign-in is their setup; they never need Google Cloud access.
129
+
130
+ Install config: ${_(a)} ${m("(no secrets in it; state is in gs://"+w+")")}`),await se([a],`Install ${r.project} (Kuriko ${c})`)}async function sn(e,t,n,r){for(;;)try{await Je(e,"database",[Ge]);return}catch(o){if(!(o instanceof R&&or(o.stderr)))throw o;let i=nr(t.dbInstanceName);r.note=`${t.dbInstanceName} was taken, creating ${i}`,t.dbInstanceName=i,V(e,t),ce(e,t,n)}}var an=[["europe-west2","London"],["europe-west1","Belgium"],["europe-west3","Frankfurt"],["us-central1","Iowa"],["us-east1","South Carolina"],["us-west1","Oregon"],["asia-southeast1","Singapore"],["australia-southeast1","Sydney"]];async function cn(){return await M("Region (where Kuriko and its data live):",[...an.map(([t,n])=>({label:t,value:t,hint:n})),{label:"Another region\u2026",value:""}])||Ye("Region:",void 0,er,"Like europe-west2 or us-central1: https://cloud.google.com/run/docs/locations")}async function ln(){let e=H().filter(n=>yr(be(n,J)));if(!e.length)return null;await P({terraformOnly:!0});let t=await fe(e);return M("Continue an install, or start a new one?",[{label:"Start a new install",value:null},...t.map(n=>{let r=De[n.status],o=n.status==="gone";return{label:`Continue ${n.project}`,value:n.dir,disabled:o,hint:`${n.region} ${r.mark} ${r.text}`}})])}async function Ye(e,t,n,r){for(;;){let o=await K(e,t);if(n(o))return o;d(` ${r}`)}}async function br(){if(!L()){d(Ce);return}let e=H();if(!e.length){d(`No Kuriko installs yet. Start one with: ${u("kuriko install")}`);return}await P({terraformOnly:!0});let t=await fe(e),n={installed:at("\u25CF installed"),partial:pe("\u25D0 partly installed: run install to continue, or destroy"),empty:m("\u25CB not installed (or destroyed)"),gone:m("\u25CB project deleted"),unknown:pe("? unknown")};for(let r of t)d(`
131
+ ${u(r.project)} ${m(r.region)} ${n[r.status]}`),r.web&&d(` web ${r.web}`),r.mcp&&d(` mcp ${r.mcp}`),r.detail&&d(r.status==="gone"?m(` ${r.detail}`):` ${pe("!")} ${r.detail}`),d(m(` dir ${_(r.dir)}`))}var un="module.kuriko.google_cloud_run_v2_job.migrate",dn={create:"+",update:"~",replace:"\xB1",delete:"-"};async function gn(e,t){if(e==="unknown")return"forward";if(ae(e)&&ae(t)){let n=dr(e,t);return n===0?"same":n<0?"forward":"backward"}return!ae(e)&&!ae(t)?Ht(C,e,t):"switch"}async function vr(e){b("Checking this machine"),await ie(Z());for(let c of["gcloud","terraform",...v?[]:["git"]])if(!await Y(c,c==="terraform"?"-version":"--version"))throw new Error(`${c} isn't installed.`);if(await P(),!v&&!e.dryRun)try{await p("docker",["info","--format","{{.ServerVersion}}"])}catch{throw new Error("Docker isn't running. Start Docker Desktop (it builds Kuriko's images), then run this again.")}let t=await Ne(e.dir,"Which install should be upgraded?",["installed"],{partial:"finish it with kuriko install",empty:"nothing to upgrade",unknown:"can't read its state"}),n=fr(t),r=await X(n.project);if(!r||r.state!=="ACTIVE")throw new Error(`Project ${n.project} isn't available (deleted, or your account can't see it).`);if(!await ye(t,"module.kuriko.google_cloud_run_v2_service.web"))throw new Error(`${n.project} isn't fully installed yet. Run install to finish it: kuriko install --dir ${n.project}`);let o=Oe(n,r.number);f(`Install ${u(n.project)} ${m(`(${_(t)})`)}`),b("What changes");let i=hr(t)??"unknown",s=await We(e.allowDirty),a=await gn(i,s);if(a==="backward")throw new Error(v?`${n.project} is on ${i}, newer than this CLI (${s}). Update the CLI first: npm i -g kuriko`:`${n.project} is on ${i}, which is newer than this Kuriko checkout (${s}). Pull the Kuriko repo first: git -C ${_(C)} pull`);if(a==="unknown")throw new Error(`${n.project} is on ${i}, which this Kuriko checkout doesn't have. Pull the Kuriko repo first: git -C ${_(C)} pull`);let g=kr(t);v&&(Be(await Fe(n,s)),V(t,n)),qe(t,n),ce(t,n,s),await h("Preparing Terraform",()=>p("terraform",["init","-input=false"],{cwd:t}));let{plan:w}=await h("Working out the changes",()=>kt(t,"upgrade",null)),x=Le(w);if(i===s&&!x.length){g(),f(`Already on ${s}. Nothing to do.`);return}d(` Version ${i===s?s:`${m(i)} \u2192 ${u(s)}`}`),a==="switch"&&I(ae(s)?`Moves from a development build to release ${s}.`:`Moves from release ${i} to a development build. Use this only for testing.`);let l=a==="forward"&&!v?await wr(i,s):[];if(l.length){d(` ${l.length} commit${l.length===1?"":"s"}:`);for(let c of l.slice(0,12))d(m(` ${c}`));l.length>12&&d(m(` \u2026 and ${l.length-12} more`))}d(x.length?" Cloud":" Cloud no resource changes");for(let c of x)d(m(` ${dn[c.action]} ${c.address}`));if(d(m(" Nothing is deleted. The database is migrated first; the web app and gateway switch over after.")),e.dryRun){g(),d(`
132
+ ${m("Dry run: nothing was changed.")}`);return}if(!await q(`
133
+ Upgrade?`,!0)){g(),d("Nothing was changed.");return}v||(b(`Kuriko's images (version ${s})`),await Ve(n.region,o.registry,s)),b("Migrating the database"),await h("Updating the migrate job",()=>ze(t,"upgrade-migrate",[un,...v?["module.kuriko.google_artifact_registry_repository.releases"]:[]])),await $e(n,"kuriko-migrate",void 0,"Database schema"),b("Switching to the new version"),await h("Updating the web app and gateway",()=>ze(t,"upgrade",null)),f(`${n.project} is on ${u(s)}`),d(`
134
+ ${o.web}`),await se([t],`Upgrade ${n.project} to Kuriko ${s}${i!=="unknown"&&i!==s?` (from ${i})`:""}`)}import{existsSync as pn,mkdirSync as mn,writeFileSync as yt}from"node:fs";import{join as He,resolve as fn}from"node:path";var hn=`# Kuriko installs
135
+
136
+ One folder per Kuriko install, named after its cloud project, made and changed by the \`kuriko\` CLI.
137
+ Each holds the install's answers (\`kuriko.json\`) and the Terraform config generated from them. No
138
+ secrets: those stay in the cloud's secret manager, and Terraform state stays in each install's own
139
+ state bucket.
140
+
141
+ Who can clone this repo can see the installs. Changing one also needs permissions on its cloud
142
+ project, which are granted separately.
143
+
144
+ \`\`\`bash
145
+ kuriko list # every install here, with its live status
146
+ kuriko upgrade # move one to the Kuriko version you have checked out
147
+ \`\`\`
148
+
149
+ Clone it next to your Kuriko checkout, or run \`kuriko\` from inside it.
150
+ `;async function _r(e="."){let t=fn(e);if(L(t)===t){f(`${_(t)} is already an installs repo`);return}mn(t,{recursive:!0}),yt(He(t,Re),JSON.stringify({kuriko:"installs",version:1},null,2)+`
151
+ `),yt(He(t,".gitignore"),`.terraform/
152
+ .kuriko-*.plan
153
+ `),pn(He(t,"README.md"))||yt(He(t,"README.md"),hn);let r=!0;try{await p("git",["-C",t,"rev-parse","--git-dir"])}catch{r=!1}f(`${_(t)} is now an installs repo`),d(`
154
+ Share it through git: whoever can clone it can see your installs (changing one also needs
155
+ permissions on its cloud project). ${r?"Commit these files and push.":`Make it a git repo: ${u(`git -C ${_(t)} init`)}, then add a private remote.`}`)}var ve={install:{usage:"install [--dir <install>] [--allow-dirty]",summary:"Put Kuriko in a Google Cloud project, for a company on Google Workspace",details:["Walks through every step, including the three done in Google's admin pages (an OAuth app,","two Google Groups, and the Groups Reader role), explaining each and checking it before moving on.","Takes about 30 minutes, mostly waiting for the database. Safe to re-run: it continues where it stopped.",""," --dir <install> Continue a specific install, by project ID (default: asks, if there are any)"," --allow-dirty Install from a checkout with uncommitted changes (images get a -dirty tag)"],run:e=>$r({dir:e.dir,allowDirty:e["allow-dirty"]})},list:{usage:"list",summary:"Show your installs, how far each got, and their URLs",details:["Reads each install's Terraform state, so it shows what's actually in the cloud."],run:()=>br()},upgrade:{usage:"upgrade [--dir <install>] [--dry-run] [--allow-dirty]",summary:"Move an install to the version in this checkout",details:["Shows the version change, the commits in it and what changes in the cloud, then asks.","Builds and pushes the new images, migrates the database with the new version, and only then","switches the web app and gateway over. Never deletes anything; a plan that would is refused.",""," --dir <install> Which install, by project ID (default: asks, if there's more than one)"," --dry-run Show what would change, change nothing (no images built)"," --allow-dirty Upgrade to a checkout with uncommitted changes (images get a -dirty tag)"],run:e=>vr({dir:e.dir,allowDirty:e["allow-dirty"],dryRun:e["dry-run"]})},destroy:{usage:"destroy [--dir <install>] [--dry-run] [--confirm <project-id>]",summary:"Remove an install from its cloud project",details:["Shows what will be deleted (the database and everything in it, services, accounts) and what stays","(the KMS key, your own secrets, the state bucket, the project), then asks for the project ID.",""," --dir <install> Which install, by project ID (default: asks, if there's more than one)"," --dry-run Show what would happen, change nothing"," --confirm <project-id> Give the project ID up front instead of typing it"],run:e=>Qt({dir:e.dir,dryRun:e["dry-run"],confirm:e.confirm})},init:{usage:"init [folder]",summary:"Make a folder the installs repo you share with whoever runs Kuriko",details:["Installs (answers and Terraform config, no secrets) live in a git repo. Whoever can clone it sees","the installs; changing one also needs permissions on its cloud project. Commands find the repo","from inside it, from $KURIKO_INSTALLS, or as a kuriko-installs checkout next to the Kuriko one."],run:(e,t)=>_r(t[0])},help:{usage:"help [command]",summary:"Show this, or the details of one command",details:[],run:async(e,t)=>Qe(t[0])}};function Qe(e){if(e){let n=ve[e];if(!n)throw new _e(`No command "${e}".`);console.log(`${u(`kuriko ${n.usage}`)}
156
+
157
+ ${n.summary}.${n.details.length?`
158
+
159
+ ${n.details.join(`
160
+ `)}`:""}`);return}let t=Math.max(...Object.keys(ve).map(n=>n.length));console.log(`${u("kuriko")} ${m("\xB7 runs Kuriko in your own cloud")}
161
+
162
+ Usage: kuriko <command> [options] ${m(v?`version ${v.version}`:"development build, from a Kuriko checkout")}
163
+
164
+ Commands:
165
+ ${Object.entries(ve).map(([n,r])=>` ${n.padEnd(t)} ${r.summary}`).join(`
166
+ `)}
167
+
168
+ Run ${u("kuriko help <command>")} for a command's options.
169
+ ${kn()}`)}function kn(){let e=L();return e?`Installs repo: ${_(e)}`:"No installs repo yet: clone yours next to the Kuriko checkout, or run kuriko init <folder>."}var _e=class extends Error{};try{let{positionals:e,values:t}=wn({allowPositionals:!0,options:{dir:{type:"string"},"allow-dirty":{type:"boolean"},confirm:{type:"string"},"dry-run":{type:"boolean"},help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"}}}),[n,...r]=e;if(t.version)console.log(v?v.version:"development build");else if(!n)Qe();else if(ve[n])t.help?Qe(n):await ve[n].run(t,r);else throw new _e(`No command "${n}".`)}catch(e){let t=e instanceof Error?e.message:String(e),n=/Unknown option '([^']+)'/.exec(t)?.[1],r=n?`No option ${n}.`:t,o=e.code;e instanceof _e||typeof o=="string"&&o.startsWith("ERR_PARSE_ARGS")?(console.error(`${ne("\u2717")} ${r}
170
+ `),Qe(),process.exitCode=2):(console.error(`
171
+ ${ne("\u2717")} ${r}`),process.exitCode=1)}
@@ -0,0 +1,42 @@
1
+ # This file is maintained automatically by "terraform init".
2
+ # Manual edits may be lost in future updates.
3
+
4
+ provider "registry.terraform.io/hashicorp/google" {
5
+ version = "8.8.1"
6
+ constraints = "8.8.1"
7
+ hashes = [
8
+ "h1:cj2w8+P7qqGDbhG+PIJcXmtu0CMBNLqdTNLpLgvhJrw=",
9
+ "zh:1510c0a5ec95676bf9df8f4c4798eb21f1ddb49f1d0bfc52e323fcdec5240bad",
10
+ "zh:18122322d83564567bfa8c4075f1b33263bf30217345c4cf967e5d9fb7df6134",
11
+ "zh:3468de1e43ad4bee6d5191c23be7dbb39f6c1559027c598f99869f7e7fe180ba",
12
+ "zh:55bfd12669b8dd9913e5ee00df060c3f53c2976a92291262c02eaa0504e6b5d4",
13
+ "zh:5b643a92495934a22c594aca095eace27c817d83ef896042e4360b87216285df",
14
+ "zh:5e9326c8392700c2d8a998b19ff253b7fcbe01a39e14c5518233da1b98d4d99b",
15
+ "zh:9522b2ed7cd335488c7a91509bb70cf134a318b697c38255ed184209d11f0436",
16
+ "zh:a55f6fb2f998b39dad5bb107c4c1b7ff022aa54cc77fe31e98d3ae8894833ce4",
17
+ "zh:a7509f8d1db99156bbf1b72e1acc25ccf093a8fd4af264464e1b054e90a87eb8",
18
+ "zh:b3ad9d84fc076f71cdd1574ca417e7b565b79a2d1e7afcc5ec211f1aaa8c0227",
19
+ "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c",
20
+ "zh:fd2a9f9741792a11d7f1fa9affe080c8b40b93e5f6a0b61cb25dfcd9c87dc44e",
21
+ ]
22
+ }
23
+
24
+ provider "registry.terraform.io/hashicorp/random" {
25
+ version = "3.8.1"
26
+ constraints = "3.8.1"
27
+ hashes = [
28
+ "h1:u8AKlWVDTH5r9YLSeswoVEjiY72Rt4/ch7U+61ZDkiQ=",
29
+ "zh:08dd03b918c7b55713026037c5400c48af5b9f468f483463321bd18e17b907b4",
30
+ "zh:0eee654a5542dc1d41920bbf2419032d6f0d5625b03bd81339e5b33394a3e0ae",
31
+ "zh:229665ddf060aa0ed315597908483eee5b818a17d09b6417a0f52fd9405c4f57",
32
+ "zh:2469d2e48f28076254a2a3fc327f184914566d9e40c5780b8d96ebf7205f8bc0",
33
+ "zh:37d7eb334d9561f335e748280f5535a384a88675af9a9eac439d4cfd663bcb66",
34
+ "zh:741101426a2f2c52dee37122f0f4a2f2d6af6d852cb1db634480a86398fa3511",
35
+ "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3",
36
+ "zh:a902473f08ef8df62cfe6116bd6c157070a93f66622384300de235a533e9d4a9",
37
+ "zh:b85c511a23e57a2147355932b3b6dce2a11e856b941165793a0c3d7578d94d05",
38
+ "zh:c5172226d18eaac95b1daac80172287b69d4ce32750c82ad77fa0768be4ea4b8",
39
+ "zh:dab4434dba34aad569b0bc243c2d3f3ff86dd7740def373f2a49816bd2ff819b",
40
+ "zh:f49fd62aa8c5525a5c17abd51e27ca5e213881d58882fd42fec4a545b53c9699",
41
+ ]
42
+ }
@@ -0,0 +1,15 @@
1
+ # Kuriko on GCP (Terraform)
2
+
3
+ Installs Kuriko into one GCP project: Cloud Run (web, gateway, migrate job), Cloud SQL Postgres 17, Secret Manager, Cloud KMS, Artifact Registry, and three service accounts. The IAM layout is the security model; see the header of `main.tf`.
4
+
5
+ Before applying, the security team creates the IdP client secret (it never passes through Terraform):
6
+
7
+ ```bash
8
+ printf '%s' "$CLIENT_SECRET" | gcloud secrets create kuriko-idp-client-secret --data-file=- --project=$PROJECT
9
+ ```
10
+
11
+ Connector credentials go in Secret Manager the same way, named `kuriko-connector-<name>`. Only the gateway can read them.
12
+
13
+ Cloud Run URLs are deterministic (`https://kuriko-web-<project number>.<region>.run.app`), so the IdP redirect URI is known before the first apply: `terraform output idp_redirect_uri`.
14
+
15
+ Works with organizations that enforce domain-restricted sharing: the two public services turn off Cloud Run's invoker check rather than granting `allUsers`.
package/module/main.tf ADDED
@@ -0,0 +1,475 @@
1
+ # Kuriko on GCP. One project per install.
2
+ #
3
+ # Who can do what (README "Rules that don't bend", enforced here by IAM):
4
+ # kuriko-gateway reads connector credentials (secrets named kuriko-connector-*), uses the KMS key,
5
+ # deploys tools as kuriko-tools. The only identity that can touch credentials.
6
+ # kuriko-web reads only its own secrets (database URL, session secret, IdP client secret).
7
+ # kuriko-tools nothing. Tools reach data only through the gateway.
8
+
9
+ provider "google" {
10
+ project = var.project_id
11
+ region = var.region
12
+ }
13
+
14
+ data "google_project" "this" {}
15
+
16
+ locals {
17
+ n = data.google_project.this.number
18
+ # Cloud Run's deterministic URLs, known before the services exist (they reference each other).
19
+ web_url = "https://kuriko-web-${local.n}.${var.region}.run.app"
20
+ gateway_url = "https://kuriko-gateway-${local.n}.${var.region}.run.app"
21
+ issuer = "${local.web_url}/api/auth"
22
+ mcp_url = "${local.gateway_url}/mcp"
23
+ labels = { managed-by = "kuriko" }
24
+ }
25
+
26
+ resource "google_project_service" "apis" {
27
+ for_each = toset([
28
+ "run.googleapis.com",
29
+ "sqladmin.googleapis.com",
30
+ "secretmanager.googleapis.com",
31
+ "cloudkms.googleapis.com",
32
+ "artifactregistry.googleapis.com",
33
+ "iam.googleapis.com",
34
+ "cloudidentity.googleapis.com",
35
+ ])
36
+ service = each.value
37
+ disable_on_destroy = false
38
+ }
39
+
40
+ # ---------------------------------------------------------------- identities
41
+
42
+ resource "google_service_account" "gateway" {
43
+ account_id = "kuriko-gateway"
44
+ display_name = "Kuriko gateway (the only identity that reads credentials)"
45
+ depends_on = [google_project_service.apis]
46
+ }
47
+
48
+ resource "google_service_account" "web" {
49
+ account_id = "kuriko-web"
50
+ display_name = "Kuriko web app (no credential access)"
51
+ depends_on = [google_project_service.apis]
52
+ }
53
+
54
+ resource "google_service_account" "tools" {
55
+ account_id = "kuriko-tools"
56
+ display_name = "Kuriko tools (no permissions)"
57
+ depends_on = [google_project_service.apis]
58
+ }
59
+
60
+ # ---------------------------------------------------------------- images
61
+
62
+ resource "google_artifact_registry_repository" "kuriko" {
63
+ repository_id = "kuriko"
64
+ format = "DOCKER"
65
+ description = "Kuriko's own images and the tools built on it"
66
+ labels = local.labels
67
+ depends_on = [google_project_service.apis]
68
+ }
69
+
70
+ # Released images, pulled through from Kuriko's private registry with this install's own token.
71
+ # Only Artifact Registry's service agent can read the token.
72
+ data "google_secret_manager_secret" "release_token" {
73
+ count = var.release_registry == null ? 0 : 1
74
+ secret_id = var.release_registry.token_secret_name
75
+ }
76
+
77
+ resource "google_secret_manager_secret_iam_member" "registry_reads_release_token" {
78
+ count = var.release_registry == null ? 0 : 1
79
+ secret_id = data.google_secret_manager_secret.release_token[0].id
80
+ role = "roles/secretmanager.secretAccessor"
81
+ member = "serviceAccount:service-${local.n}@gcp-sa-artifactregistry.iam.gserviceaccount.com"
82
+ }
83
+
84
+ resource "google_artifact_registry_repository" "releases" {
85
+ count = var.release_registry == null ? 0 : 1
86
+ repository_id = "kuriko-releases"
87
+ format = "DOCKER"
88
+ mode = "REMOTE_REPOSITORY"
89
+ description = "Kuriko's released images, pulled through from Kuriko's registry"
90
+ labels = local.labels
91
+ remote_repository_config {
92
+ description = "Kuriko releases"
93
+ docker_repository {
94
+ custom_repository {
95
+ uri = var.release_registry.upstream
96
+ }
97
+ }
98
+ upstream_credentials {
99
+ username_password_credentials {
100
+ username = var.release_registry.username
101
+ password_secret_version = "${data.google_secret_manager_secret.release_token[0].id}/versions/${var.release_registry.token_version}"
102
+ }
103
+ }
104
+ }
105
+ depends_on = [google_project_service.apis, google_secret_manager_secret_iam_member.registry_reads_release_token]
106
+ }
107
+
108
+ # ---------------------------------------------------------------- database
109
+
110
+ resource "google_sql_database_instance" "kuriko" {
111
+ name = var.db_instance_name
112
+ database_version = "POSTGRES_17"
113
+ deletion_protection = var.deletion_protection
114
+ settings {
115
+ edition = "ENTERPRISE"
116
+ tier = var.db_tier
117
+ availability_type = "ZONAL"
118
+ user_labels = local.labels
119
+ backup_configuration {
120
+ enabled = true
121
+ point_in_time_recovery_enabled = true
122
+ }
123
+ ip_configuration {
124
+ # No authorized networks: the only way in is the Cloud SQL connector, which checks IAM.
125
+ ipv4_enabled = true
126
+ ssl_mode = "ENCRYPTED_ONLY"
127
+ }
128
+ }
129
+ depends_on = [google_project_service.apis]
130
+ }
131
+
132
+ resource "google_sql_database" "kuriko" {
133
+ name = "kuriko"
134
+ instance = google_sql_database_instance.kuriko.name
135
+ # Goes with the instance. Dropping it first fails while anything is connected.
136
+ deletion_policy = "ABANDON"
137
+ }
138
+
139
+ resource "random_password" "db" {
140
+ length = 40
141
+ special = false # goes into a URL
142
+ }
143
+
144
+ resource "google_sql_user" "kuriko" {
145
+ name = "kuriko"
146
+ instance = google_sql_database_instance.kuriko.name
147
+ password = random_password.db.result
148
+ # Goes with the instance. Postgres refuses to drop a user that still owns tables.
149
+ deletion_policy = "ABANDON"
150
+ }
151
+
152
+ # ---------------------------------------------------------------- Kuriko's own secrets
153
+
154
+ resource "google_secret_manager_secret" "database_url" {
155
+ secret_id = "kuriko-database-url"
156
+ labels = local.labels
157
+ replication {
158
+ auto {}
159
+ }
160
+ depends_on = [google_project_service.apis]
161
+ }
162
+
163
+ resource "google_secret_manager_secret_version" "database_url" {
164
+ secret = google_secret_manager_secret.database_url.id
165
+ secret_data = "postgres://kuriko:${random_password.db.result}@/kuriko?host=/cloudsql/${google_sql_database_instance.kuriko.connection_name}"
166
+ }
167
+
168
+ resource "random_password" "auth_secret" {
169
+ length = 48
170
+ }
171
+
172
+ resource "google_secret_manager_secret" "auth_secret" {
173
+ secret_id = "kuriko-auth-secret"
174
+ labels = local.labels
175
+ replication {
176
+ auto {}
177
+ }
178
+ depends_on = [google_project_service.apis]
179
+ }
180
+
181
+ resource "google_secret_manager_secret_version" "auth_secret" {
182
+ secret = google_secret_manager_secret.auth_secret.id
183
+ secret_data = random_password.auth_secret.result
184
+ }
185
+
186
+ # Created by the security team (`gcloud secrets create`), never by Terraform, so the IdP secret
187
+ # never passes through Terraform state.
188
+ data "google_secret_manager_secret" "idp_client_secret" {
189
+ secret_id = var.idp.client_secret_name
190
+ }
191
+
192
+ # ---------------------------------------------------------------- who reads which secret
193
+
194
+ resource "google_secret_manager_secret_iam_member" "database_url" {
195
+ for_each = { gateway = google_service_account.gateway.member, web = google_service_account.web.member }
196
+ secret_id = google_secret_manager_secret.database_url.id
197
+ role = "roles/secretmanager.secretAccessor"
198
+ member = each.value
199
+ }
200
+
201
+ resource "google_secret_manager_secret_iam_member" "web_auth_secret" {
202
+ secret_id = google_secret_manager_secret.auth_secret.id
203
+ role = "roles/secretmanager.secretAccessor"
204
+ member = google_service_account.web.member
205
+ }
206
+
207
+ resource "google_secret_manager_secret_iam_member" "web_idp_client_secret" {
208
+ secret_id = data.google_secret_manager_secret.idp_client_secret.id
209
+ role = "roles/secretmanager.secretAccessor"
210
+ member = google_service_account.web.member
211
+ }
212
+
213
+ # Connector credentials: the security team creates them as kuriko-connector-<name>. Only the
214
+ # gateway can read them, and only those.
215
+ resource "google_project_iam_member" "gateway_connector_secrets" {
216
+ project = var.project_id
217
+ role = "roles/secretmanager.secretAccessor"
218
+ member = google_service_account.gateway.member
219
+ condition {
220
+ title = "kuriko-connector-secrets-only"
221
+ expression = "resource.name.startsWith(\"projects/${local.n}/secrets/kuriko-connector-\")"
222
+ }
223
+ }
224
+
225
+ resource "google_project_iam_member" "cloudsql_client" {
226
+ for_each = { gateway = google_service_account.gateway.member, web = google_service_account.web.member }
227
+ project = var.project_id
228
+ role = "roles/cloudsql.client"
229
+ member = each.value
230
+ }
231
+
232
+ # ---------------------------------------------------------------- per-user token encryption
233
+
234
+ resource "google_kms_key_ring" "kuriko" {
235
+ name = "kuriko"
236
+ location = var.region
237
+ depends_on = [google_project_service.apis]
238
+ }
239
+
240
+ resource "google_kms_crypto_key" "user_tokens" {
241
+ name = "user-tokens"
242
+ key_ring = google_kms_key_ring.kuriko.id
243
+ rotation_period = "7776000s" # 90 days
244
+ labels = local.labels
245
+ lifecycle {
246
+ prevent_destroy = true # destroying it makes every stored token unreadable
247
+ }
248
+ }
249
+
250
+ resource "google_kms_crypto_key_iam_member" "gateway" {
251
+ crypto_key_id = google_kms_crypto_key.user_tokens.id
252
+ role = "roles/cloudkms.cryptoKeyEncrypterDecrypter"
253
+ member = google_service_account.gateway.member
254
+ }
255
+
256
+ # ---------------------------------------------------------------- the gateway runs tools
257
+
258
+ resource "google_project_iam_member" "gateway_run" {
259
+ project = var.project_id
260
+ role = "roles/run.developer"
261
+ member = google_service_account.gateway.member
262
+ }
263
+
264
+ resource "google_service_account_iam_member" "gateway_acts_as_tools" {
265
+ service_account_id = google_service_account.tools.name
266
+ role = "roles/iam.serviceAccountUser"
267
+ member = google_service_account.gateway.member
268
+ }
269
+
270
+ # ---------------------------------------------------------------- services
271
+
272
+ locals {
273
+ web_env = {
274
+ BETTER_AUTH_URL = local.web_url
275
+ KURIKO_IDP_PROVIDER_ID = "idp"
276
+ KURIKO_IDP_DOMAIN = var.idp.domain
277
+ KURIKO_IDP_ISSUER = var.idp.issuer
278
+ KURIKO_IDP_CLIENT_ID = var.idp.client_id
279
+ KURIKO_IDP_GROUPS_CLAIM = var.idp.groups_claim
280
+ KURIKO_IDP_GROUPS_SOURCE = var.idp.groups_source
281
+ KURIKO_GATEWAY_RESOURCE = local.mcp_url
282
+ KURIKO_MCP_CLIENT_IDS = join(",", var.mcp_client_ids)
283
+ }
284
+ web_secrets = {
285
+ DATABASE_URL = google_secret_manager_secret.database_url.secret_id
286
+ BETTER_AUTH_SECRET = google_secret_manager_secret.auth_secret.secret_id
287
+ KURIKO_IDP_CLIENT_SECRET = data.google_secret_manager_secret.idp_client_secret.secret_id
288
+ }
289
+ }
290
+
291
+ resource "google_cloud_run_v2_service" "web" {
292
+ name = "kuriko-web"
293
+ location = var.region
294
+ ingress = "INGRESS_TRAFFIC_ALL"
295
+ # Reached from the internet and authenticates every request itself (SSO sessions, OAuth tokens).
296
+ # Turning off Cloud Run's IAM check works with domain-restricted sharing, unlike an allUsers grant.
297
+ invoker_iam_disabled = true
298
+ deletion_protection = var.deletion_protection
299
+ labels = local.labels
300
+ template {
301
+ service_account = google_service_account.web.email
302
+ scaling {
303
+ max_instance_count = 3
304
+ }
305
+ volumes {
306
+ name = "cloudsql"
307
+ cloud_sql_instance {
308
+ instances = [google_sql_database_instance.kuriko.connection_name]
309
+ }
310
+ }
311
+ containers {
312
+ image = var.images.web
313
+ ports {
314
+ container_port = 3000
315
+ }
316
+ dynamic "env" {
317
+ for_each = local.web_env
318
+ content {
319
+ name = env.key
320
+ value = env.value
321
+ }
322
+ }
323
+ dynamic "env" {
324
+ for_each = local.web_secrets
325
+ content {
326
+ name = env.key
327
+ value_source {
328
+ secret_key_ref {
329
+ secret = env.value
330
+ version = "latest"
331
+ }
332
+ }
333
+ }
334
+ }
335
+ volume_mounts {
336
+ name = "cloudsql"
337
+ mount_path = "/cloudsql"
338
+ }
339
+ }
340
+ }
341
+ depends_on = [
342
+ google_secret_manager_secret_iam_member.database_url,
343
+ google_secret_manager_secret_iam_member.web_auth_secret,
344
+ google_secret_manager_secret_iam_member.web_idp_client_secret,
345
+ google_project_iam_member.cloudsql_client,
346
+ google_secret_manager_secret_version.database_url,
347
+ google_sql_user.kuriko,
348
+ google_secret_manager_secret_version.auth_secret,
349
+ google_artifact_registry_repository.releases,
350
+ ]
351
+ }
352
+
353
+ resource "google_cloud_run_v2_job" "migrate" {
354
+ name = "kuriko-migrate"
355
+ location = var.region
356
+ deletion_protection = var.deletion_protection
357
+ labels = local.labels
358
+ template {
359
+ template {
360
+ service_account = google_service_account.web.email
361
+ max_retries = 0
362
+ volumes {
363
+ name = "cloudsql"
364
+ cloud_sql_instance {
365
+ instances = [google_sql_database_instance.kuriko.connection_name]
366
+ }
367
+ }
368
+ containers {
369
+ image = var.images.migrate
370
+ dynamic "env" {
371
+ for_each = local.web_env
372
+ content {
373
+ name = env.key
374
+ value = env.value
375
+ }
376
+ }
377
+ dynamic "env" {
378
+ for_each = local.web_secrets
379
+ content {
380
+ name = env.key
381
+ value_source {
382
+ secret_key_ref {
383
+ secret = env.value
384
+ version = "latest"
385
+ }
386
+ }
387
+ }
388
+ }
389
+ volume_mounts {
390
+ name = "cloudsql"
391
+ mount_path = "/cloudsql"
392
+ }
393
+ }
394
+ }
395
+ }
396
+ # What the job needs, not the web service itself: upgrades apply the job alone (with -target, which
397
+ # also applies a target's dependencies) to migrate before the new version serves.
398
+ depends_on = [
399
+ google_secret_manager_secret_iam_member.database_url,
400
+ google_secret_manager_secret_iam_member.web_auth_secret,
401
+ google_secret_manager_secret_iam_member.web_idp_client_secret,
402
+ google_project_iam_member.cloudsql_client,
403
+ google_secret_manager_secret_version.database_url,
404
+ google_secret_manager_secret_version.auth_secret,
405
+ google_sql_user.kuriko,
406
+ google_artifact_registry_repository.releases,
407
+ ]
408
+ }
409
+
410
+ resource "google_cloud_run_v2_service" "gateway" {
411
+ name = "kuriko-gateway"
412
+ location = var.region
413
+ ingress = "INGRESS_TRAFFIC_ALL"
414
+ # Reached from the internet and authenticates every request itself (SSO sessions, OAuth tokens).
415
+ # Turning off Cloud Run's IAM check works with domain-restricted sharing, unlike an allUsers grant.
416
+ invoker_iam_disabled = true
417
+ deletion_protection = var.deletion_protection
418
+ labels = local.labels
419
+ template {
420
+ service_account = google_service_account.gateway.email
421
+ scaling {
422
+ max_instance_count = 3
423
+ }
424
+ volumes {
425
+ name = "cloudsql"
426
+ cloud_sql_instance {
427
+ instances = [google_sql_database_instance.kuriko.connection_name]
428
+ }
429
+ }
430
+ containers {
431
+ image = var.images.gateway
432
+ ports {
433
+ container_port = 3939
434
+ }
435
+ dynamic "env" {
436
+ for_each = {
437
+ PUBLIC_URL = local.gateway_url
438
+ OIDC_ISSUER = local.issuer
439
+ OIDC_AUDIENCE = local.mcp_url
440
+ OIDC_GROUPS_CLAIM = var.idp.groups_claim
441
+ OIDC_REQUIRE_TYP = "at+jwt"
442
+ KURIKO_CLOUD = "gcp"
443
+ KURIKO_GCP_PROJECT = var.project_id
444
+ KURIKO_GCP_REGION = var.region
445
+ KURIKO_GCP_KMS_KEY = google_kms_crypto_key.user_tokens.id
446
+ KURIKO_GCP_TOOL_SERVICE_ACCOUNT = google_service_account.tools.email
447
+ }
448
+ content {
449
+ name = env.key
450
+ value = env.value
451
+ }
452
+ }
453
+ env {
454
+ name = "DATABASE_URL"
455
+ value_source {
456
+ secret_key_ref {
457
+ secret = google_secret_manager_secret.database_url.secret_id
458
+ version = "latest"
459
+ }
460
+ }
461
+ }
462
+ volume_mounts {
463
+ name = "cloudsql"
464
+ mount_path = "/cloudsql"
465
+ }
466
+ }
467
+ }
468
+ depends_on = [
469
+ google_secret_manager_secret_iam_member.database_url,
470
+ google_project_iam_member.cloudsql_client,
471
+ google_secret_manager_secret_version.database_url,
472
+ google_sql_user.kuriko,
473
+ google_artifact_registry_repository.releases,
474
+ ]
475
+ }
@@ -0,0 +1,39 @@
1
+ output "web_url" {
2
+ description = "Kuriko's web app. People sign in here."
3
+ value = local.web_url
4
+ }
5
+
6
+ output "mcp_url" {
7
+ description = "Add to Claude Code: claude mcp add --transport http kuriko <mcp_url>"
8
+ value = local.mcp_url
9
+ }
10
+
11
+ output "idp_redirect_uri" {
12
+ description = "Register this as the OAuth redirect URI in the IdP app."
13
+ value = "${local.web_url}/api/auth/sso/callback/idp"
14
+ }
15
+
16
+ output "image_repository" {
17
+ description = "Push Kuriko's images (and later, built tools) here."
18
+ value = "${var.region}-docker.pkg.dev/${var.project_id}/${google_artifact_registry_repository.kuriko.repository_id}"
19
+ }
20
+
21
+ output "web_service_account" {
22
+ description = "Give this identity the Groups Reader admin role in Google Workspace when groups_source is google-workspace."
23
+ value = google_service_account.web.email
24
+ }
25
+
26
+ output "connector_secret_prefix" {
27
+ description = "Create connector credentials in Secret Manager with this name prefix; only the gateway can read them."
28
+ value = "kuriko-connector-"
29
+ }
30
+
31
+ output "migrate_job" {
32
+ description = "Cloud Run job that applies schema changes; `kuriko install` also runs admin tasks with it."
33
+ value = google_cloud_run_v2_job.migrate.name
34
+ }
35
+
36
+ output "release_repository" {
37
+ description = "Where released images are pulled from (set when release_registry is), e.g. <this>/usekuriko/gateway:0.1.0."
38
+ value = var.release_registry == null ? null : "${var.region}-docker.pkg.dev/${var.project_id}/${google_artifact_registry_repository.releases[0].repository_id}"
39
+ }
@@ -0,0 +1,74 @@
1
+ variable "project_id" {
2
+ description = "GCP project Kuriko installs into. Kuriko should have the project to itself."
3
+ type = string
4
+ }
5
+
6
+ variable "region" {
7
+ description = "Region for Cloud Run, Cloud SQL, KMS and Artifact Registry."
8
+ type = string
9
+ default = "europe-west2"
10
+ }
11
+
12
+ variable "images" {
13
+ description = "Image references for this Kuriko version (ideally by digest). Pushed to this install's Artifact Registry by `kuriko install`."
14
+ type = object({
15
+ gateway = string
16
+ web = string
17
+ migrate = string
18
+ })
19
+ }
20
+
21
+ variable "idp" {
22
+ description = <<-EOT
23
+ The company's identity provider (OIDC). The client secret is NOT passed here: the security team
24
+ stores it in Secret Manager as `client_secret_name` before applying.
25
+ EOT
26
+ type = object({
27
+ issuer = string
28
+ client_id = string
29
+ client_secret_name = optional(string, "kuriko-idp-client-secret")
30
+ domain = string # email domain(s) that sign in, comma-separated
31
+ groups_claim = optional(string, "groups")
32
+ groups_source = optional(string, "token") # "token", or "google-workspace" (looked up via Cloud Identity)
33
+ })
34
+ }
35
+
36
+ variable "mcp_client_ids" {
37
+ description = "MCP clients (by client metadata document URL) allowed to sign people in."
38
+ type = list(string)
39
+ default = ["https://claude.ai/oauth/claude-code-client-metadata"]
40
+ }
41
+
42
+ variable "db_tier" {
43
+ description = "Cloud SQL machine tier. The smallest is plenty for a small team."
44
+ type = string
45
+ default = "db-f1-micro"
46
+ }
47
+
48
+ variable "deletion_protection" {
49
+ description = "Protect the database and services from `terraform destroy`. Turn off only for throwaway installs."
50
+ type = bool
51
+ default = true
52
+ }
53
+
54
+ variable "db_instance_name" {
55
+ description = "Cloud SQL instance name. Fixed once created: changing it replaces the database. A deleted instance's name stays reserved for about a week, so a reinstall picks another (kuriko-1, …)."
56
+ type = string
57
+ default = "kuriko"
58
+ }
59
+
60
+ variable "release_registry" {
61
+ description = <<-EOT
62
+ Pull Kuriko's released images from Kuriko's private registry, through a remote repository in this
63
+ project (`kuriko-releases`). The registry token is created by the security team in Secret Manager
64
+ (`token_secret_name`), never passed to Terraform; `token_version` is its version number. Null when
65
+ images are built from source and pushed to the install's own `kuriko` repository (development).
66
+ EOT
67
+ type = object({
68
+ upstream = string # e.g. https://ghcr.io
69
+ username = string
70
+ token_secret_name = optional(string, "kuriko-release-token")
71
+ token_version = string
72
+ })
73
+ default = null
74
+ }
@@ -0,0 +1,7 @@
1
+ terraform {
2
+ required_version = ">= 1.6"
3
+ required_providers {
4
+ google = { source = "hashicorp/google", version = "8.8.1" }
5
+ random = { source = "hashicorp/random", version = "3.8.1" }
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,6 +1,19 @@
1
1
  {
2
2
  "name": "kuriko",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Kuriko's admin CLI: install, upgrade and destroy Kuriko in your own cloud.",
5
+ "type": "module",
6
+ "bin": {
7
+ "kuriko": "kuriko.mjs"
8
+ },
9
+ "files": [
10
+ "kuriko.mjs",
11
+ "module",
12
+ "LICENSE",
13
+ "README.md"
14
+ ],
15
+ "engines": {
16
+ "node": ">=22.18"
17
+ },
18
+ "license": "SEE LICENSE IN LICENSE"
19
+ }