flintmaker 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{chunk-YHI6436D.js → chunk-K6EGUENI.js} +1 -1
- package/dist/chunks/{plain-ZZJO6S7Q.js → plain-32HV3XHW.js} +1 -1
- package/dist/chunks/{repl-JU5A6RFU.js → repl-5SO4OJNB.js} +1 -1
- package/dist/chunks/{update-2THO6BFM.js → update-A3SQIJXY.js} +1 -1
- package/dist/flint.js +4 -4
- package/package.json +4 -2
|
@@ -3,7 +3,7 @@ import{c as b,n as R}from"./chunk-K3ZZ2VJH.js";var S="Interrupted by the user be
|
|
|
3
3
|
|
|
4
4
|
`);return e=t.pop()??"",t.filter(Boolean).map(r=>{let i="message",s=[];for(let o of r.split(`
|
|
5
5
|
`))o.startsWith("event:")?i=o.slice(6).trim():o.startsWith("data:")&&s.push(o.slice(5).replace(/^ /,""));return{event:i,data:s.join(`
|
|
6
|
-
`)}})}}var N="0.2.
|
|
6
|
+
`)}})}}var N="0.2.6",p=class extends Error{constructor(t,r="error",i=0,s){super(t);this.reason=r;this.status=i;this.minVersion=s}reason;status;minVersion},V=e=>e?new Date(e).toLocaleString(void 0,{weekday:"short",hour:"2-digit",minute:"2-digit"}):"soon";async function M(e,n){let t=await e.json().catch(()=>({})),r=t.requestId?` (ref ${t.requestId})`:"";switch(t.reason){case"signed_out":return new p("You are signed out. Run: flint login","signed_out",e.status);case"limit":return new p(`Out of credits until ${V(t.resetAt)}. Get more at ${n}/pricing`,"limit",e.status);case"busy":return new p("FlintMaker is very busy right now. Please try again later.","busy",e.status);case"upgrade_required":return new p(`The smart model needs a paid plan: ${n}/pricing`,"upgrade_required",e.status);case"in_progress":return new p("Another flint session is still working. Wait for it to finish.","in_progress",e.status);case"update_required":{let i=typeof t.minVersion=="string"&&/^\d+\.\d+\.\d+/.test(t.minVersion)?t.minVersion:void 0;return new p(`FlintMaker needs flint v${i??"latest"} or newer (this is v${N}).`,"update_required",e.status,i)}default:return new p(`Request failed (${e.status} ${t.reason??""})${r}`,t.reason??"error",e.status)}}var A=class{constructor(n,t){this.base=n;this.token=t}base;token;headers(){return{"content-type":"application/json","user-agent":"flint-cli","x-flint-version":N,...this.token?{authorization:`Bearer ${this.token}`}:{}}}async json(n,t={}){let r=await fetch(`${this.base}/api${n}`,{...t,headers:{...this.headers(),...t.headers}});if(!r.ok)throw await M(r,this.base);return await r.json()}me(){return this.json("/me")}async deviceLogin(n,t){let r=await this.json("/auth/device",{method:"POST",body:"{}"});n(r.userCode,r.verifyUrl);let i=Date.now()+r.expiresIn*1e3;for(;Date.now()<i;){if(await new Promise(o=>setTimeout(o,r.interval*1e3)),t?.aborted)throw new p("Login cancelled.","cancelled");let s=await fetch(`${this.base}/api/auth/device/token`,{method:"POST",headers:this.headers(),body:JSON.stringify({deviceCode:r.deviceCode})});if(s.status!==428){if(s.ok)return await s.json();throw new p("The login code expired. Run flint login again.","expired",s.status)}}throw new p("The login code expired. Run flint login again.","expired")}stepper(n,t,r){return async(i,s)=>{let o=await fetch(`${this.base}/api/agent`,{method:"POST",headers:{...this.headers(),"x-flint-features":"web"},body:JSON.stringify({messages:i,model:n()}),signal:t()});if(o.status===413)throw new f;if(!o.ok||!o.body)throw await M(o,this.base);let l=C(),c=new TextDecoder,m="",w=[],a={};for await(let g of o.body)for(let d of l(c.decode(g,{stream:!0}))){let u=d.data?JSON.parse(d.data):{};if(d.event==="delta")m+=u.text,s(u.text);else if(d.event==="tool_call")w.push(u);else if(d.event==="tool_result")a[u.id]={ok:u.ok!==!1,content:String(u.content??"")};else if(d.event==="done")r(u.credits,u.usage);else if(d.event==="error")throw new p(`The model hit a problem; no credits were used.${u.requestId?` (ref ${u.requestId})`:""}`,"model")}return{text:m,toolCalls:w,serverResults:a}}}};var I="https://flintmaker.com/pricing";function B(e){let n=e;return n?.name==="TypeError"&&/fetch failed|network/i.test(n.message??"")||["ECONNREFUSED","ENOTFOUND","ECONNRESET","ETIMEDOUT","EAI_AGAIN","UND_ERR_SOCKET","UND_ERR_CONNECT_TIMEOUT"].includes(n?.cause?.code??"")}function le(e,n={}){let t=n.interactive?"Run /login to connect your FlintMaker account.":"Run: flint login",r=n.retry?[n.retry]:[];if(B(e))return{title:"Can't reach FlintMaker",lines:["Check your internet connection, then try again.",...r],tone:"warn"};if(e instanceof p)switch(e.reason){case"signed_out":return{title:"You are signed out",lines:[t],tone:"warn"};case"limit":return{title:"Out of credits",lines:[e.message.replace(/\. Get more at .*$/,"."),`Upgrade or top up: ${I}`],tone:"warn"};case"upgrade_required":return{title:"Smart needs a paid plan",lines:["Switch back with /model standard, or upgrade:",I],tone:"warn"};case"busy":return{title:"FlintMaker is very busy",lines:["Please try again in a minute.",...r],tone:"warn"};case"in_progress":return{title:"Another flint session is working",lines:["Wait for it to finish, then try again."],tone:"warn"};case"update_required":return{title:"flint needs an update",lines:[e.message,n.interactive?"Updating\u2026 if it does not restart, run: flint update":"Run: flint update (or: npm i -g flintmaker@latest)"],tone:"warn"};case"model":return{title:"The model hit a problem",lines:[e.message,...r],tone:"error"};default:return{title:"Something went wrong",lines:[e.message,...r],tone:"error"}}return{title:"Something went wrong",lines:[e?.message??String(e)],tone:"error"}}var _=null,P=[];function de(e){_?_(e):P.push(e)}function ue(e){if(_=e,e)for(let n of P.splice(0))e(n)}var L=null,k=null;function pe(e){k=e,L?.(e)}function me(e){L=e,e&&k&&e(k)}import{readdirSync as z}from"node:fs";import{join as G,sep as J}from"node:path";var y=[{name:"help",description:"Show commands and keyboard shortcuts"},{name:"model",args:"[standard|smart]",description:"Switch model and see credit costs"},{name:"mode",args:"[ask|auto|plan]",description:"Change when flint asks before acting (or Shift+Tab)"},{name:"clear",description:"Start a new conversation",aliases:["new","reset"]},{name:"compact",description:"Summarise the conversation to free up context"},{name:"credits",description:"Show credit usage and plans",aliases:["usage"]},{name:"init",description:"Create FLINT.md, the project memory flint reads first"},{name:"update",description:"Update flint to the newest version now"},{name:"login",description:"Connect another FlintMaker account"},{name:"logout",description:"Disconnect this computer"},{name:"exit",description:"Quit flint",aliases:["quit","q"]}];function we(e){let n=/^\/([a-zA-Z][\w-]*)(?:\s+([\s\S]*))?$/.exec(e.trim());if(!n)return null;let t=n[1].toLowerCase(),r=y.find(i=>i.name===t||i.aliases?.includes(t));return!r&&(t==="smart"||t==="standard")?{name:"model",args:t,command:y.find(i=>i.name==="model")}:{name:r?.name??t,args:(n[2]??"").trim(),command:r}}function Y(e,n){let t=Array.from({length:n.length+1},(r,i)=>i);for(let r=1;r<=e.length;r++){let i=t[0];t[0]=r;for(let s=1;s<=n.length;s++){let o=t[s];t[s]=Math.min(t[s]+1,t[s-1]+1,i+(e[r-1]===n[s-1]?0:1)),i=o}}return t[n.length]}function ye(e){let n=null,t=1/0;for(let r of y)for(let i of[r.name,...r.aliases??[]]){let s=i.startsWith(e)?0:Y(e,i);s<t&&(t=s,n=r.name)}return t<=Math.max(2,Math.floor(e.length/3))?n:null}function xe(e){let n=e.replace(/^\//,"").toLowerCase();return y.filter(t=>t.name.startsWith(n)||t.aliases?.some(r=>r.startsWith(n)))}function be(e){if(e.length===0)return"";let n=e[0];for(let t of e.slice(1))for(;!t.startsWith(n);)n=n.slice(0,-1);return n}var K=new Set(["node_modules",".git","dist","build",".next","coverage",".venv","__pycache__","DerivedData","Pods"]);function Se(e,n){let t=n.lastIndexOf("/"),r=t>=0?n.slice(0,t+1):"",i=t>=0?n.slice(t+1):n;if(r.split("/").includes("..")||r.startsWith("/"))return[];let s;try{s=z(G(e,r.split("/").join(J)),{withFileTypes:!0})}catch{return[]}return s.filter(o=>o.name.startsWith(i)&&!K.has(o.name)&&(i.startsWith(".")||!o.name.startsWith(".")||o.name===".github")).map(o=>r+o.name+(o.isDirectory()?"/":"")).sort((o,l)=>Number(l.endsWith("/"))-Number(o.endsWith("/"))||o.localeCompare(l)).slice(0,50)}function O(e){let n=new Set;for(let t of e.matchAll(/(?:^|\s)@((?:[\w.-]+\/)*[\w.-]+)/g))n.add(t[1]);return[...n]}import{readFileSync as j,statSync as H}from"node:fs";import{join as Q}from"node:path";var x="FLINT.md",D=2e4,h=e=>e.toLocaleString("en-US");function Te(e){return e.creditsLeftToday!==null?`${h(e.creditsLeftToday)} credits left today`:`${h(e.creditsLeftMonth)} credits left`}function $e(e){let n=r=>new Date(r).toLocaleString(void 0,{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}),t=[`Plan: ${e.plan.charAt(0).toUpperCase()+e.plan.slice(1)}`];return e.creditsLeftToday!==null&&t.push(`Today: ${h(e.creditsLeftToday)} credits left (resets ${n(e.resetAt)})`),t.push(`This period: ${h(e.creditsLeftMonth)} of ${h(e.monthlyCredits)} credits left (resets ${n(e.monthResetAt)})`),t}var Ce={standard:{label:"Standard",cost:"\u22482\u20133 credits per step",note:"fast, great for most tasks \xB7 all plans"},smart:{label:"Smart",cost:"\u22482\u20138 credits per step",note:"stronger reasoning, longer answers \xB7 paid plans"}},Me=`Create ${x} in the project root: a concise project memory that you will read at the start of every future conversation.
|
|
7
7
|
First explore the project (list files, read the README, package/config files and a few key sources). Then write ${x} (max ~60 lines) with:
|
|
8
8
|
- What the project is, in 1\u20132 sentences
|
|
9
9
|
- Tech stack and layout (key directories and entry points)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as U,b as Y}from"./chunk-O4FFCD22.js";import{A as P,d as M,i as _,k as x,v as I}from"./chunk-
|
|
1
|
+
import{a as U,b as Y}from"./chunk-O4FFCD22.js";import{A as P,d as M,i as _,k as x,v as I}from"./chunk-K6EGUENI.js";import{h as m,r as u,s as p,t as L,v as S}from"./chunk-YCYJUZK6.js";import{b as o}from"./chunk-5PRYZOW7.js";import"./chunk-K3ZZ2VJH.js";import{createInterface as R}from"node:readline/promises";var r=(y="")=>process.stdout.write(y+`
|
|
2
2
|
`);async function J(y,s){let a=!!process.stdout.isTTY,n=()=>a?Math.max(40,process.stdout.columns||80):100;a&&await import("./highlight-QJIBHZTN.js").then(e=>U(e.highlight)).catch(()=>{});let C=new Y(()=>n()-1),h=!!process.stdin.isTTY&&a?R({input:process.stdin,output:process.stdout,terminal:!0}):null;x(e=>{process.stderr.isTTY&&process.stderr.write(o.grey(`\u2726 ${e}`)+`
|
|
3
3
|
`)});let l=new AbortController;process.on("SIGINT",()=>{l.signal.aborted&&process.exit(130),l.abort()});let A=null,d=0,f=!1,g=!1,$=()=>{a?C.end().forEach(e=>r(e)):f&&r(),f=!1},E=async e=>{if(s.autoYes)return!0;if(!h)return r(` ${e} no (not a terminal; pass --yes to allow)`),!1;let t=(await h.question(` ${e} ${o.grey("[y/N]")} `)).trim().toLowerCase();return t==="y"||t==="yes"},w="",j={onDelta:e=>{!f&&g&&r(),g=!1;let t=m(e);a?C.push(t).forEach(i=>r(i)):process.stdout.write(t),f=!0},onToolStart:(e,t)=>{$(),w=t,g=!0},onToolResult:(e,t,i="")=>{if(!t){r(u(e,w,"error",n())),p(i,n(),3).forEach(c=>r(c));return}if(e==="write_file"||e==="edit_file"||e==="run_command"){p(i,n(),e==="run_command"?8:2).forEach(c=>r(c));return}let k=L(e,i);r(u(e,w,"ok",n(),k.suffix)),k.detail&&p(k.detail,n()).forEach(c=>r(c))},approveChange:async e=>(r(u(e.created?"write_file":"edit_file",e.path,"ok",n())),S(e.diff,e.path,n(),e.created).forEach(t=>r(t)),s.mode==="plan"?{declined:"Plan mode is on, so no files may be changed."}:E(`${e.created?"Create":"Apply this edit to"} ${m(e.path)}?`)),approveCommand:async e=>(r(`${o.ember("\u25CF")} ${o.bold("Run")} ${m(e)}`),s.mode==="plan"?{declined:"Plan mode is on, so no commands may run."}:E("Run this command?"))},N=s.client.stepper(()=>s.model,()=>l.signal,(e,t)=>{d+=e,A=t}),b=0;try{let e=await P(s.ws,y,{first:!0,mode:s.mode??"ask"});for(let t of e.attachments)t.error&&r(o.gold(`! Could not attach ${t.path}: ${t.error}`));await M(s.ws,[{role:"user",content:e.content}],N,j,{signal:l.signal}),$(),l.signal.aborted&&(r(o.grey("Interrupted.")),b=130)}catch(e){$();let t=_(e);process.stderr.write(`${o.red("\u2717")} ${t.title}
|
|
4
4
|
${t.lines.map(i=>` ${i}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as G,c as Z,d as K,e as V}from"./chunk-EUPBID7K.js";import{a as pt,b as ft}from"./chunk-O4FFCD22.js";import{A as ht,B as lt,a as D,b as J,c as z,d as Q,f as L,g as I,h as N,i as X,k as U,m as W,n as F,o as tt,p as et,q as st,r as it,s as rt,t as M,u as q,v as k,w as nt,x as g,y as ot,z as at}from"./chunk-
|
|
1
|
+
import{a as G,c as Z,d as K,e as V}from"./chunk-EUPBID7K.js";import{a as pt,b as ft}from"./chunk-O4FFCD22.js";import{A as ht,B as lt,a as D,b as J,c as z,d as Q,f as L,g as I,h as N,i as X,k as U,m as W,n as F,o as tt,p as et,q as st,r as it,s as rt,t as M,u as q,v as k,w as nt,x as g,y as ot,z as at}from"./chunk-K6EGUENI.js";import{A as Pt,b as ct,c as w,d as ut,f as dt,g as mt,h as x,i as gt,j as bt,k as wt,l as xt,m as v,o as vt,p as yt,r as y,s as p,t as St,u as $t,v as Ct,w as T,x as Mt,y as kt,z as Tt}from"./chunk-YCYJUZK6.js";import{b as o}from"./chunk-5PRYZOW7.js";import"./chunk-K3ZZ2VJH.js";import{existsSync as Vt}from"node:fs";import{homedir as Xt}from"node:os";import{join as te}from"node:path";var S=class{text="";cursor=0;set(t,e=t.length){this.text=t,this.cursor=Math.max(0,Math.min(e,t.length))}clear(){this.set("")}insert(t){this.text=this.text.slice(0,this.cursor)+t+this.text.slice(this.cursor),this.cursor+=t.length}prevIndex(t){if(t<=0)return 0;let e=this.text.charCodeAt(t-1);return e>=56320&&e<=57343&&t>=2?t-2:t-1}nextIndex(t){if(t>=this.text.length)return this.text.length;let e=this.text.codePointAt(t);return t+(e>65535?2:1)}backspace(){if(this.cursor===0)return;let t=this.prevIndex(this.cursor);this.text=this.text.slice(0,t)+this.text.slice(this.cursor),this.cursor=t}del(){this.cursor>=this.text.length||(this.text=this.text.slice(0,this.cursor)+this.text.slice(this.nextIndex(this.cursor)))}left(){this.cursor=this.prevIndex(this.cursor)}right(){this.cursor=this.nextIndex(this.cursor)}lineStart(t=this.cursor){return this.text.lastIndexOf(`
|
|
2
2
|
`,t-1)+1}lineEnd(t=this.cursor){let e=this.text.indexOf(`
|
|
3
3
|
`,t);return e<0?this.text.length:e}home(){this.cursor=this.lineStart()}end(){this.cursor=this.lineEnd()}wordLeft(){let t=this.cursor;for(;t>0&&/\s/.test(this.text[t-1]);)t--;for(;t>0&&!/\s/.test(this.text[t-1]);)t--;this.cursor=t}wordRight(){let t=this.cursor;for(;t<this.text.length&&/\s/.test(this.text[t]);)t++;for(;t<this.text.length&&!/\s/.test(this.text[t]);)t++;this.cursor=t}deleteWordBack(){let t=this.cursor;this.wordLeft(),this.text=this.text.slice(0,this.cursor)+this.text.slice(t)}killToEnd(){let t=this.lineEnd();this.text=this.text.slice(0,this.cursor)+this.text.slice(t===this.cursor?t+1:t)}killToStart(){let t=this.lineStart();this.text=this.text.slice(0,t)+this.text.slice(this.cursor),this.cursor=t}get onFirstLine(){return this.text.lastIndexOf(`
|
|
4
4
|
`,this.cursor-1)<0}get onLastLine(){return this.text.indexOf(`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{c as g,d,m as L}from"./chunk-K3ZZ2VJH.js";import{spawn as F,spawnSync as te}from"node:child_process";import{accessSync as H,chmodSync as re,closeSync as G,constants as C,existsSync as J,mkdirSync as V,openSync as K,readFileSync as U,realpathSync as oe,rmSync as ie,writeFileSync as y}from"node:fs";import{homedir as W}from"node:os";var x="flintmaker",se=`https://registry.npmjs.org/${x}/latest`,ae=300*1e3,O=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/,k=e=>typeof e=="string"&&O.test(e);function ce(e,n){let t=O.exec(e),r=O.exec(n);if(!t||!r)return 0;for(let a=1;a<=3;a++){let l=Number(t[a])-Number(r[a]);if(l)return l>0?1:-1}let o=t[4],s=r[4];if(o===s)return 0;if(o===void 0)return 1;if(s===void 0)return-1;let i=o.split("."),c=s.split(".");for(let a=0;a<Math.max(i.length,c.length);a++){if(i[a]===void 0)return-1;if(c[a]===void 0)return 1;if(i[a]===c[a])continue;let l=/^\d+$/.test(i[a]),f=/^\d+$/.test(c[a]);return l&&f?Number(i[a])>Number(c[a])?1:-1:l!==f?l?-1:1:i[a]>c[a]?1:-1}return 0}var P=(e,n)=>k(e)&&k(n)&&ce(e,n)>0,_=e=>!!e&&e!=="0"&&e.toLowerCase()!=="false";function Y(e=process.env,n=""){return _(e.FLINT_NO_UPDATE)?"FLINT_NO_UPDATE is set":_(e.CI)?"running in CI":_(e.NO_UPDATE_NOTIFIER)?"NO_UPDATE_NOTIFIER is set":!k(n)||n.startsWith("0.0.0")?"development build":null}var N=(e=process.env)=>e.FLINT_UPDATE_DIR||d().join(W(),".flintmaker");function w(e=N()){try{let n=JSON.parse(U(d().join(e,"update.json"),"utf8"));return n&&typeof n=="object"?n:{}}catch{return{}}}function p(e,n=N()){try{V(n,{recursive:!0,mode:448}),y(d().join(n,"update.json"),JSON.stringify(e,null,2)+`
|
|
2
|
-
`)}catch{}}var le=(e,n=Date.now())=>!e.checkedAt||n-e.checkedAt>=ae||e.checkedAt>n;function ue(e,n={}){let t=n.platform??process.platform,r=d(t),o=g(t),s=n.env??process.env,i=n.exists??J,c=h=>o?r.normalize(h).toLowerCase():r.normalize(h),a=(h,ne)=>c(h).startsWith(c(ne).replace(/[\\/]+$/,"")+r.sep),l=r.normalize(e);if(c(l).split(r.sep).includes("_npx"))return{kind:"npx"};let m=`${r.sep}node_modules${r.sep}${x}${r.sep}`,v=c(l).lastIndexOf(c(m));if(v<0)return{kind:"dev"};let S=l.slice(0,v+m.length-x.length-2),u=r.dirname(S),b=n.home??W(),M=r.join(b,".flintmaker");if(a(l,M))return{kind:"flintmaker",prefix:M};if(o){let h=s.APPDATA?r.join(s.APPDATA,"npm"):null;return h&&c(u)===c(h)||i(r.join(u,"npm.cmd"))||i(r.join(u,"node.exe"))?{kind:"npm-global",prefix:u}:{kind:"local"}}return r.basename(u)==="lib"?{kind:"npm-global",prefix:r.dirname(u)}:{kind:"local"}}var A=(e,n=process.platform)=>g(n)?d(n).join(e,"node_modules"):d(n).join(e,"lib","node_modules");function de(e,n){let t=d(n),r=t.dirname(e);return g(n)?t.join(r,"node_modules","npm","bin","npm-cli.js"):t.join(r,"..","lib","node_modules","npm","bin","npm-cli.js")}function $(e,n,t={}){if(e.kind!=="flintmaker"&&e.kind!=="npm-global"||!k(n))return null;let r=t.platform??process.platform,o=d(r),s=t.exists??J,i=["install","-g","--prefix",e.prefix,"--no-fund","--no-audit",`${x}@${n}`],c=[];e.kind==="flintmaker"&&c.push(g(r)?o.join(e.prefix,"node","node.exe"):o.join(e.prefix,"node","bin","node")),c.push(t.execPath??process.execPath);for(let a of c){let l=de(a,r);if(s(a)&&s(l))return{file:a,args:[l,...i],options:{windowsHide:!0}}}if(g(r)){let a=i.map(l=>/[\s&()^]/.test(l)?`"${l}"`:l).join(" ");return{file:t.env?.ComSpec||"cmd.exe",args:["/d","/s","/c",`"npm ${a}"`],options:{windowsVerbatimArguments:!0,windowsHide:!0}}}return{file:"npm",args:i,options:{}}}function j(e,n=process.platform){if(e.kind!=="flintmaker"&&e.kind!=="npm-global")return!1;try{return H(A(e.prefix,n),C.W_OK),g(n)||H(d(n).join(e.prefix,"bin"),C.W_OK),!0}catch{return!1}}function T(){try{return ue(oe(process.argv[1]??""))}catch{return{kind:"dev"}}}var I=(e,n)=>e.kind==="flintmaker"?`Update available v${n}: run flint update`:e.kind==="npx"?`Update available v${n}: run npx flintmaker@latest`:`Update available v${n}: run npm i -g ${x}`;async function R(e=3e3,n=process.env.FLINT_UPDATE_URL||se){try{let t=await fetch(n,{signal:AbortSignal.timeout(e),headers:{accept:"application/json"}});if(!t.ok)return null;let r=await t.json();return k(r?.version)?r.version:null}catch{return null}}function z(e){let n="dist/flint.js";if(typeof e=="string")n=e;else if(e&&typeof e=="object"){let t=e,r=t.flint??t.flintmaker??Object.values(t)[0];typeof r=="string"&&(n=r)}return n.replace(/^\.[\\/]/,"")}var E=["flint","flintmaker"];function fe(e,n=process.platform){let t=d(n);return g(n)?E.flatMap(r=>["",".cmd",".ps1"].map(o=>t.join(e,r+o))):E.map(r=>t.join(e,"bin",r))}function pe(e,n,t=process.platform){let r=d(t);if(g(t)){let i=["@echo off","rem FlintMaker CLI launcher (written by https://flintmaker.com/install.ps1)","setlocal",'set "FM_HOME=%~dp0"','set "FM_NODE=node"','if exist "%FM_HOME%node\\node.exe" set "FM_NODE=%FM_HOME%node\\node.exe"','if exist "%FM_HOME%node\\node.exe" set "PATH=%FM_HOME%node;%PATH%"',`"%FM_NODE%" "%FM_HOME%node_modules\\flintmaker\\${n.replace(/\//g,"\\")}" %*`,""].join(`\r
|
|
2
|
+
`)}catch{}}var le=(e,n=Date.now())=>!e.checkedAt||n-e.checkedAt>=ae||e.checkedAt>n;function ue(e,n={}){let t=n.platform??process.platform,r=d(t),o=g(t),s=n.env??process.env,i=n.exists??J,c=h=>o?r.normalize(h).toLowerCase():r.normalize(h),a=(h,ne)=>c(h).startsWith(c(ne).replace(/[\\/]+$/,"")+r.sep),l=r.normalize(e);if(c(l).split(r.sep).includes("_npx"))return{kind:"npx"};let m=`${r.sep}node_modules${r.sep}${x}${r.sep}`,v=c(l).lastIndexOf(c(m));if(v<0)return{kind:"dev"};let S=l.slice(0,v+m.length-x.length-2),u=r.dirname(S),b=n.home??W(),M=r.join(b,".flintmaker");if(a(l,M))return{kind:"flintmaker",prefix:M};if(o){let h=s.APPDATA?r.join(s.APPDATA,"npm"):null;return h&&c(u)===c(h)||i(r.join(u,"npm.cmd"))||i(r.join(u,"node.exe"))?{kind:"npm-global",prefix:u}:{kind:"local"}}return r.basename(u)==="lib"?{kind:"npm-global",prefix:r.dirname(u)}:{kind:"local"}}var A=(e,n=process.platform)=>g(n)?d(n).join(e,"node_modules"):d(n).join(e,"lib","node_modules");function de(e,n){let t=d(n),r=t.dirname(e);return g(n)?t.join(r,"node_modules","npm","bin","npm-cli.js"):t.join(r,"..","lib","node_modules","npm","bin","npm-cli.js")}function $(e,n,t={}){if(e.kind!=="flintmaker"&&e.kind!=="npm-global"||!k(n))return null;let r=t.platform??process.platform,o=d(r),s=t.exists??J,i=["install","-g","--prefix",e.prefix,"--prefer-online","--no-fund","--no-audit",`${x}@${n}`],c=[];e.kind==="flintmaker"&&c.push(g(r)?o.join(e.prefix,"node","node.exe"):o.join(e.prefix,"node","bin","node")),c.push(t.execPath??process.execPath);for(let a of c){let l=de(a,r);if(s(a)&&s(l))return{file:a,args:[l,...i],options:{windowsHide:!0}}}if(g(r)){let a=i.map(l=>/[\s&()^]/.test(l)?`"${l}"`:l).join(" ");return{file:t.env?.ComSpec||"cmd.exe",args:["/d","/s","/c",`"npm ${a}"`],options:{windowsVerbatimArguments:!0,windowsHide:!0}}}return{file:"npm",args:i,options:{}}}function j(e,n=process.platform){if(e.kind!=="flintmaker"&&e.kind!=="npm-global")return!1;try{return H(A(e.prefix,n),C.W_OK),g(n)||H(d(n).join(e.prefix,"bin"),C.W_OK),!0}catch{return!1}}function T(){try{return ue(oe(process.argv[1]??""))}catch{return{kind:"dev"}}}var I=(e,n)=>e.kind==="flintmaker"?`Update available v${n}: run flint update`:e.kind==="npx"?`Update available v${n}: run npx flintmaker@latest`:`Update available v${n}: run npm i -g ${x}`;async function R(e=3e3,n=process.env.FLINT_UPDATE_URL||se){try{let t=await fetch(n,{signal:AbortSignal.timeout(e),headers:{accept:"application/json"}});if(!t.ok)return null;let r=await t.json();return k(r?.version)?r.version:null}catch{return null}}function z(e){let n="dist/flint.js";if(typeof e=="string")n=e;else if(e&&typeof e=="object"){let t=e,r=t.flint??t.flintmaker??Object.values(t)[0];typeof r=="string"&&(n=r)}return n.replace(/^\.[\\/]/,"")}var E=["flint","flintmaker"];function fe(e,n=process.platform){let t=d(n);return g(n)?E.flatMap(r=>["",".cmd",".ps1"].map(o=>t.join(e,r+o))):E.map(r=>t.join(e,"bin",r))}function pe(e,n,t=process.platform){let r=d(t);if(g(t)){let i=["@echo off","rem FlintMaker CLI launcher (written by https://flintmaker.com/install.ps1)","setlocal",'set "FM_HOME=%~dp0"','set "FM_NODE=node"','if exist "%FM_HOME%node\\node.exe" set "FM_NODE=%FM_HOME%node\\node.exe"','if exist "%FM_HOME%node\\node.exe" set "PATH=%FM_HOME%node;%PATH%"',`"%FM_NODE%" "%FM_HOME%node_modules\\flintmaker\\${n.replace(/\//g,"\\")}" %*`,""].join(`\r
|
|
3
3
|
`);return E.map(c=>({path:r.join(e,`${c}.cmd`),content:i}))}let o=i=>i.replace(/[\\"$`]/g,"\\$&"),s=`#!/bin/sh
|
|
4
4
|
# FlintMaker CLI launcher (written by https://flintmaker.com/install.sh)
|
|
5
5
|
FM_HOME="${o(e)}"
|
package/dist/flint.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as se,b as A,c as ae,d as ce,e as R}from"./chunks/chunk-EUPBID7K.js";import{e as B,f as T,g as I,i as de,j as ue,l as fe,v as me}from"./chunks/chunk-
|
|
2
|
+
import{a as se,b as A,c as ae,d as ce,e as R}from"./chunks/chunk-EUPBID7K.js";import{e as B,f as T,g as I,i as de,j as ue,l as fe,v as me}from"./chunks/chunk-K6EGUENI.js";import{b as m,c as le}from"./chunks/chunk-5PRYZOW7.js";import{c as J,e as X,f as D,g as Q,h as Z,i as ee,j as C,k as te,l as ne,m as oe,o as re,p as ie}from"./chunks/chunk-K3ZZ2VJH.js";import{spawn as $e,execFileSync as ke}from"node:child_process";import{existsSync as _e,lstatSync as Te,realpathSync as W}from"node:fs";import{mkdir as Ce,readdir as Pe,readFile as q,stat as pe,writeFile as Le}from"node:fs/promises";import{basename as he,dirname as Fe,join as Y,relative as ge,resolve as Se,sep as Ne}from"node:path";var P=class{diff(e,n,t={}){let r;typeof t=="function"?(r=t,t={}):"callback"in t&&(r=t.callback);let a=this.castInput(e,t),s=this.castInput(n,t),l=this.removeEmpty(this.tokenize(a,t)),i=this.removeEmpty(this.tokenize(s,t));return this.diffWithOptionsObj(l,i,t,r)}diffWithOptionsObj(e,n,t,r){var a;let s=u=>{if(u=this.postProcess(u,t),r){setTimeout(function(){r(u)},0);return}else return u},l=n.length,i=e.length,f=1,c=l+i;t.maxEditLength!=null&&(c=Math.min(c,t.maxEditLength));let d=(a=t.timeout)!==null&&a!==void 0?a:1/0,w=Date.now()+d,h=[{oldPos:-1,lastComponent:void 0}],v=this.extractCommon(h[0],n,e,0,t);if(h[0].oldPos+1>=i&&v+1>=l)return s(this.buildValues(h[0].lastComponent,n,e));let p=-1/0,b=1/0,E=()=>{for(let u=Math.max(p,-f);u<=Math.min(b,f);u+=2){let g,y=h[u-1],x=h[u+1];y&&(h[u-1]=void 0);let _=!1;if(x){let G=x.oldPos-u;_=x&&0<=G&&G<l}let L=y&&y.oldPos+1<i;if(!_&&!L){h[u]=void 0;continue}if(!L||_&&y.oldPos<x.oldPos?g=this.addToPath(x,!0,!1,0,t):g=this.addToPath(y,!1,!0,1,t),v=this.extractCommon(g,n,e,u,t),g.oldPos+1>=i&&v+1>=l)return s(this.buildValues(g.lastComponent,n,e))||!0;h[u]=g,g.oldPos+1>=i&&(b=Math.min(b,u-1)),v+1>=l&&(p=Math.max(p,u+1))}f++};if(r)(function u(){setTimeout(function(){if(f>c||Date.now()>w)return r(void 0);E()||u()},0)})();else for(;f<=c&&Date.now()<=w;){let u=E();if(u)return u}}addToPath(e,n,t,r,a){let s=e.lastComponent;return s&&!a.oneChangePerToken&&s.added===n&&s.removed===t?{oldPos:e.oldPos+r,lastComponent:{count:s.count+1,added:n,removed:t,previousComponent:s.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:n,removed:t,previousComponent:s}}}extractCommon(e,n,t,r,a){let s=n.length,l=t.length,i=e.oldPos,f=i-r,c=0;for(;f+1<s&&i+1<l&&this.equals(t[i+1],n[f+1],a);)f++,i++,c++,a.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return c&&!a.oneChangePerToken&&(e.lastComponent={count:c,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=i,f}equals(e,n,t){return t.comparator?t.comparator(e,n):e===n||!!t.ignoreCase&&e.toLowerCase()===n.toLowerCase()}removeEmpty(e){let n=[];for(let t=0;t<e.length;t++)e[t]&&n.push(e[t]);return n}castInput(e,n){return e}tokenize(e,n){return Array.from(e)}join(e){return e.join("")}postProcess(e,n){return e}get useLongestToken(){return!1}buildValues(e,n,t){let r=[],a;for(;e;)r.push(e),a=e.previousComponent,delete e.previousComponent,e=a;r.reverse();let s=r.length,l=0,i=0,f=0;for(;l<s;l++){let c=r[l];if(c.removed)c.value=this.join(t.slice(f,f+c.count)),f+=c.count;else{if(!c.added&&this.useLongestToken){let d=n.slice(i,i+c.count);d=d.map(function(w,h){let v=t[f+h];return v.length>w.length?v:w}),c.value=this.join(d)}else c.value=this.join(n.slice(i,i+c.count));i+=c.count,c.added||(f+=c.count)}}return r}};var M=class extends P{constructor(){super(...arguments),this.tokenize=ye}equals(e,n,t){return t.ignoreWhitespace?((!t.newlineIsToken||!e.includes(`
|
|
3
3
|
`))&&(e=e.trim()),(!t.newlineIsToken||!n.includes(`
|
|
4
4
|
`))&&(n=n.trim())):t.ignoreNewlineAtEof&&!t.newlineIsToken&&(e.endsWith(`
|
|
5
5
|
`)&&(e=e.slice(0,-1)),n.endsWith(`
|
|
@@ -43,18 +43,18 @@ ${u}`.trim())}),s.on("error",b=>{clearTimeout(v),t?.removeEventListener("abort",
|
|
|
43
43
|
@path attaches a file \xB7 shift+tab switches mode \xB7 esc interrupts
|
|
44
44
|
`;function He(o){let e=new Set(o.filter(t=>t.startsWith("--"))),n=o.filter(t=>!t.startsWith("--"));return{flags:e,rest:n}}async function we(){let o=new I(R(null));console.log();let e=await o.deviceLogin((n,t)=>{console.log(` ${m.ember("\u2726")} Your code: ${m.bold(m.gold(n))}`),console.log(` ${m.grey("Opening")} ${t}`),console.log(` ${m.grey("Approve it in the browser. Waiting\u2026")}`),se(t)});ae({token:e.token,email:e.user.email,api:o.base}),console.log(`
|
|
45
45
|
${m.green("\u2713")} Signed in as ${m.bold(e.user.email)}. Run ${m.bold("flint")} in any project folder.
|
|
46
|
-
`)}async function We(){let o="";process.stdin.setEncoding("utf8");for await(let e of process.stdin)o+=e;return o.trim()}var K=()=>Promise.all([import("./chunks/repl-
|
|
46
|
+
`)}async function We(){let o="";process.stdin.setEncoding("utf8");for await(let e of process.stdin)o+=e;return o.trim()}var K=()=>Promise.all([import("./chunks/repl-5SO4OJNB.js"),import("./chunks/plain-32HV3XHW.js"),import("./chunks/highlight-QJIBHZTN.js"),import("./chunks/render-73QVSOTH.js")]);function qe(o){let e=!1,n=()=>import("./chunks/update-A3SQIJXY.js").then(t=>t.autoUpdate({current:$,notify:r=>ue(r),preload:K,ready:()=>{e=!0,fe("Update ready \u2014 restart flint")}})).then(t=>{(t==="disabled"||t==="hint"||t==="failed")&&(e=!0)}).catch(()=>{});setTimeout(n,200).unref(),o&&import("./chunks/update-A3SQIJXY.js").then(t=>{let r=setInterval(()=>e?clearInterval(r):void n(),t.CHECK_EVERY_MS+1e3);r.unref()}).catch(()=>{})}function V(o){let e=["\xB7","\u2722","\u2733","\u2736","\u273B","\u273D","\u273B","\u2736","\u2733","\u2722"],n=0,t=()=>process.stdout.write(`\r ${m.ember(e[n++%e.length])} ${o}\x1B[K`);process.stdout.write("\x1B[?25l"),t();let r=setInterval(t,100);return()=>{clearInterval(r),process.stdout.write("\r\x1B[K\x1B[?25h")}}async function Ye(){if(Ue||N)return null;let o=await import("./chunks/update-A3SQIJXY.js"),e=await o.foregroundUpdate({current:$,interactive:!0,spinner:V,preload:K});return e.status==="reexec"?e.code??0:(e.status==="failed"&&console.log(` ${m.ember("\u2726")} ${m.grey(`Could not update to v${e.latest}; continuing with v${$}. Details: ${o.stateDir()}${process.platform==="win32"?"\\":"/"}update.log`)}`),e.status==="cancelled"&&console.log(` ${m.ember("\u2726")} ${m.grey(`Update skipped; continuing with v${$}.`)}`),null)}async function ze(){let o=await import("./chunks/update-A3SQIJXY.js"),e=await o.foregroundUpdate({current:$,interactive:!0,force:!0,spinner:V,preload:K});if(e.status==="reexec")return e.code??0;if(e.status==="current")console.log(` ${m.ember("\u2726")} flint v${$} is the newest version.`);else if(e.status==="offline")console.log(` ${m.ember("\u2726")} ${m.grey("Could not reach the update server. Check your connection and try again.")}`);else{let t=o.currentInstall().kind==="npx"?"npx flintmaker@latest":"npm i -g flintmaker@latest";console.log(` ${m.ember("\u2726")} ${m.grey(`Could not update automatically. Run: ${t}`)}`)}return 0}async function ve(o){let e=!!process.stdin.isTTY&&!!process.stdout.isTTY,n=await import("./chunks/update-A3SQIJXY.js");if(e&&!N){let a=await n.foregroundUpdate({current:$,interactive:!0,force:!0,spinner:V});if(a.status==="reexec")return a.code??0}let t=n.currentInstall(),r=t.kind==="npx"?"npx flintmaker@latest":t.kind==="flintmaker"?"flint update":"npm i -g flintmaker@latest";return process.stderr.write(`
|
|
47
47
|
${m.red("\u2717")} ${m.bold("flint needs an update")}
|
|
48
48
|
${o.message}
|
|
49
49
|
Run: ${r}
|
|
50
50
|
|
|
51
|
-
`),1}async function Ke(){if(!re())for(let p of[process.stdout,process.stderr])p.isTTY&&ie(p);let{flags:o,rest:e}=He(process.argv.slice(2));if(o.has("--version")||o.has("-v"))return console.log($);if(o.has("--help")||e[0]==="help"||e[0]==="-h")return console.log(Oe());if(e[0]==="login")return we();if(e[0]==="__update"&&e[1]){let{updateWorker:p}=await import("./chunks/update-
|
|
51
|
+
`),1}async function Ke(){if(!re())for(let p of[process.stdout,process.stderr])p.isTTY&&ie(p);let{flags:o,rest:e}=He(process.argv.slice(2));if(o.has("--version")||o.has("-v"))return console.log($);if(o.has("--help")||e[0]==="help"||e[0]==="-h")return console.log(Oe());if(e[0]==="login")return we();if(e[0]==="__update"&&e[1]){let{updateWorker:p}=await import("./chunks/update-A3SQIJXY.js");return p(e[1])}if(e[0]==="update"&&e.length===1){let{updateNow:p}=await import("./chunks/update-A3SQIJXY.js");return p($,b=>console.log(` ${b}`))}if(e[0]==="logout")return ce(),console.log(`
|
|
52
52
|
Signed out. ${m.grey("Disconnect old terminals any time on your account page.")}
|
|
53
53
|
`);let n=!!process.stdin.isTTY&&!!process.stdout.isTTY,t=n&&e.length===0;if(t){let p=await Ye();if(p!==null)return p}if(!A()){if(!n)return process.stderr.write(`flint: not signed in. Run: flint login
|
|
54
54
|
`),1;let{welcome:p,shortPath:b}=await import("./chunks/render-73QVSOTH.js"),{homedir:E}=await import("node:os"),u=Math.max(40,process.stdout.columns||80);console.log();let g={version:$,model:o.has("--smart")?"smart":"standard",cwd:b(process.cwd(),E(),28),status:"not signed in yet",updated:N?$:void 0};for(let y of p(g,u))console.log(y);console.log(`
|
|
55
55
|
${m.ember("\u2726")} Welcome to ${m.bold("flint")}. Let's connect your FlintMaker account (opening your browser):`),await we()}let r=A(),a=R(r);if(a!==r.api)throw new T(`This token belongs to ${r.api}. Run flint login to use ${a}.`);let s=new I(a,r.token);if(e[0]==="whoami"){let p=await s.me();return console.log(`
|
|
56
56
|
${m.bold(p.user.email)} \xB7 ${p.user.plan} \xB7 ${me(p.usage)}
|
|
57
|
-
`)}let l=new S(process.cwd()),i=o.has("--smart")?"smart":"standard",f=o.has("--plan")?"plan":"ask",c=o.has("--yes");qe(t);let d=e.join(" ").trim();if(!d&&!process.stdin.isTTY&&(d=await We()),d||!n){if(!d)throw new T('Nothing to do. Pass a task: flint "fix the failing test"');let{oneShot:p}=await import("./chunks/plain-
|
|
57
|
+
`)}let l=new S(process.cwd()),i=o.has("--smart")?"smart":"standard",f=o.has("--plan")?"plan":"ask",c=o.has("--yes");qe(t);let d=e.join(" ").trim();if(!d&&!process.stdin.isTTY&&(d=await We()),d||!n){if(!d)throw new T('Nothing to do. Pass a task: flint "fix the failing test"');let{oneShot:p}=await import("./chunks/plain-32HV3XHW.js");return p(d,{client:s,ws:l,model:i,autoYes:c,mode:f})}let{interactive:w}=await import("./chunks/repl-5SO4OJNB.js"),h=null,v=!1;if(await w({version:$,client:s,ws:l,model:i,autoYes:c,mode:f,updated:N?$:void 0,onUpdateRequired:()=>h=new T(`FlintMaker no longer serves flint v${$}.`,"update_required",426),onUpdateNow:()=>v=!0}),h)return ve(h);if(v)return ze()}Ke().then(o=>{typeof o=="number"&&o!==0&&(process.exitCode=o),setTimeout(()=>process.exit(),20).unref()},async o=>{if(o instanceof T&&o.reason==="update_required")return process.exitCode=await ve(o).catch(()=>1),void setTimeout(()=>process.exit(),20).unref();let e=de(o);process.stderr.write(`
|
|
58
58
|
${m.red("\u2717")} ${m.bold(e.title)}
|
|
59
59
|
${e.lines.map(n=>` ${n}
|
|
60
60
|
`).join("")}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flintmaker",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "flint — the FlintMaker AI coding agent for your terminal.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "PT Jiji Labs Digital",
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
"build": "node scripts/build.mjs",
|
|
22
22
|
"test": "vitest run",
|
|
23
23
|
"typecheck": "tsc --noEmit",
|
|
24
|
-
"smoke": "npm run build && node test/smoke/run.mjs"
|
|
24
|
+
"smoke": "npm run build && node test/smoke/run.mjs",
|
|
25
|
+
"release": "node scripts/release.mjs",
|
|
26
|
+
"prepublishOnly": "node -e \"if(!process.env.FLINT_RELEASE){console.error('Publish with: npm run release (plain npm publish breaks auto-update for a few minutes)');process.exit(1)}\""
|
|
25
27
|
},
|
|
26
28
|
"devDependencies": {
|
|
27
29
|
"@types/diff": "^7.0.2",
|