@mistflow-ai/mcp 0.7.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ import{c as m,d as y}from"./chunk-EED3GL6G.js";import{e as f,f as u,g as p,h as g}from"./chunk-RTKBAE4U.js";import{existsSync as h,readFileSync as w,writeFileSync as b}from"fs";import{join as l}from"path";import{spawn as j}from"child_process";function C(r,t,e,s,o){return new Promise(n=>{let a=j(r,t,{cwd:e,stdio:["pipe","pipe","pipe"],timeout:s,...o?{env:{...process.env,...o}}:{}}),c="",d="";a.stdout?.on("data",i=>{c+=i.toString()}),a.stderr?.on("data",i=>{d+=i.toString()}),a.on("close",i=>n({success:i===0,stdout:c,stderr:d})),a.on("error",i=>n({success:!1,stdout:c,stderr:d+i.message}))})}function P(r){let t=l(r,"mistflow.json");if(!h(t))return null;try{return JSON.parse(w(t,"utf-8"))}catch{return null}}function k(r,t){b(l(r,"mistflow.json"),JSON.stringify(t,null,2))}async function S(r,t){try{let e=t.features,s=t.steps,o={plan:t};Array.isArray(e)&&e.length>0&&(o.features=e.map(n=>n.name)),Array.isArray(s)&&s.length>0&&(o.provenance=s.map(n=>({feature:n.name??n.title??`Step ${n.number??"?"}`,user_intent:(n.description??"").slice(0,500),decisions:"Seeded from plan",tradeoffs:"",files_affected:[]}))),await fetch(`${u()}/api/projects/${encodeURIComponent(r)}/state`,{method:"PUT",headers:{...p(),"Content-Type":"application/json"},body:JSON.stringify(o)})}catch(e){console.error("[self-heal] state sync failed:",e instanceof Error?e.message:String(e))}}async function x(r,t={}){let e=P(r);if(e){if(!f())return e.projectId;if(!e.projectId)try{let o=e.plan?.requestedSubdomain,n=await g(e.name,void 0,e.dbProvider??"neon",o);return e.projectId=n.id,k(r,e),m(r,y(n.id,e.name)),e.plan&&await S(n.id,e.plan),console.error(`[self-heal] registered project ${n.id.slice(0,8)} with backend`),n.id}catch(s){console.error("[self-heal] createProject failed:",s instanceof Error?s.message:String(s));return}return t.forceSync&&e.plan&&e.projectId&&await S(e.projectId,e.plan),e.projectId}}async function N(r,t){let e=["button","card","input","label","form","dialog","table","dropdown-menu","badge","separator","skeleton","sheet","tabs","avatar","select","textarea","checkbox","switch","tooltip","popover","sonner"],s=t&&t.length>0?t:e,o=l(r,"components","ui"),n=[],a=[];for(let i of s)h(l(o,`${i}.tsx`))?n.push(i):a.push(i);if(a.length===0)return{installed:[],alreadyPresent:n};let c={NPM_CONFIG_LEGACY_PEER_DEPS:"true"},d=await C("npx",["--yes","shadcn@latest","add","-y","-o",...a],r,18e4,c);return d.success?{installed:a,alreadyPresent:n}:{installed:[],alreadyPresent:n,failed:`shadcn add failed for: ${a.join(", ")}. ${d.stderr.slice(-300)}`.trim()}}export{x as ensureBackendRegistered,N as ensureShadcnComponents};
@@ -0,0 +1 @@
1
+ import{a,b,c,d,e,f,g}from"./chunk-EED3GL6G.js";import"./chunk-RTKBAE4U.js";export{d as emptyState,e as fetchRemoteState,g as fuzzyMatch,a as getLocalStatePath,b as readLocalState,f as syncRemoteState,c as writeLocalState};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mistflow-ai/mcp",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Mistflow MCP server for AI coding editors. Installed into Claude Code, Cursor, Codex CLI, and VS Code Copilot by the mistflow-ai installer.",
5
5
  "license": "Elastic-2.0",
6
6
  "type": "module",
@@ -1,23 +0,0 @@
1
- import{existsSync as w,readFileSync as C,writeFileSync as E,mkdirSync as A}from"fs";import{join as y,dirname as h}from"path";import{homedir as O}from"os";import{fileURLToPath as F}from"url";var d=null;function f(){if(d)return d;try{let e=F(import.meta.url),t=h(e);for(let n=0;n<6;n++){let o=y(t,"package.json");if(w(o)){let s=JSON.parse(C(o,"utf-8"));if(s.name==="@mistflow-ai/mcp"&&typeof s.version=="string")return d=s.version,s.version}let r=h(t);if(r===t)break;t=r}}catch{}return d="0.0.0","0.0.0"}function g(e){let t=/^(\d+)\.(\d+)\.(\d+)/.exec(e.trim());return t?[parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10)]:null}function x(e,t){let n=g(e),o=g(t);if(!n||!o)return 0;for(let r=0;r<3;r++){if(n[r]<o[r])return-1;if(n[r]>o[r])return 1}return 0}function b(e,t,n){if(n&&x(e,n)<0)return"unsupported";if(!t||x(e,t)>=0)return"none";let r=g(e),s=g(t);return!r||!s?"none":r[0]<s[0]?"major":r[1]<s[1]?"minor":"patch"}var a=null;function P(e){let t=e.get("x-mistflow-mcp-latest")??"",n=e.get("x-mistflow-mcp-min-supported")??"",o=e.get("x-mistflow-mcp-changelog-url")??"";!t&&!n||(a={latest:t,minSupported:n,changelogUrl:o})}function v(){let e=process.env.MISTFLOW_STATE_DIR||y(O(),".mistflow");return y(e,"upgrade-state.json")}function V(){try{let e=v();return w(e)?JSON.parse(C(e,"utf-8")):{}}catch{return{}}}function L(e){try{let t=v(),n=h(t);w(n)||A(n,{recursive:!0}),E(t,JSON.stringify(e,null,2)+`
2
- `,{mode:384})}catch{}}var S=!1;function N(e){return e==="patch"?7*864e5:e==="minor"?1*864e5:0}function ie(){if(process.env.MISTFLOW_NO_UPGRADE_CHECK==="1"||!a)return null;let e=f();if(e==="0.0.0")return null;let t=b(e,a.latest,a.minSupported);if(t==="none")return null;if(t==="unsupported")return k(t,e,a);if(S)return null;let n=V(),o=Date.now(),r=N(t);return n.dismissedForVersion===a.latest&&t!=="major"||n.lastLatestSeen===a.latest&&n.lastShownMs&&o-n.lastShownMs<r?null:(S=!0,L({...n,lastShownMs:o,lastLatestSeen:a.latest}),k(t,e,a))}function k(e,t,n){let o="npx -y mistflow-ai install",r=n.changelogUrl?`
3
- What's new: ${n.changelogUrl}`:"";return e==="unsupported"?`
4
-
5
- ---
6
- Mistflow ${t} is no longer supported.
7
- You must upgrade to ${n.latest} or newer to continue:
8
-
9
- ${o}
10
-
11
- After upgrading, restart your AI editor.${r}
12
- ---`:e==="major"?`
13
-
14
- ---
15
- Mistflow ${n.latest} is available (you have ${t}).
16
- This is a major update. Run \`${o}\` and restart your editor.${r}
17
- ---`:e==="minor"?`
18
-
19
- --- Mistflow update available: ${t} -> ${n.latest} ---
20
- Run \`${o}\` to upgrade, then restart your editor.${r}`:`
21
-
22
- (Mistflow ${n.latest} is out, you have ${t}. Run \`${o}\` when convenient.)`}function ae(){let e=f(),t=a??{latest:"",minSupported:"",changelogUrl:""},n=b(e,t.latest,t.minSupported);return{current:e,latest:t.latest,minSupported:t.minSupported,severity:n,upgradeCmd:"npx -y mistflow-ai install",changelogUrl:t.changelogUrl,backendSignalReceived:a!==null}}import{readFileSync as B,existsSync as D,writeFileSync as q,mkdirSync as K,renameSync as J,unlinkSync as H}from"fs";import{join as U,dirname as W}from"path";import{homedir as Q}from"os";import{randomBytes as z}from"crypto";function I(){return U(Q(),".mistflow","credentials.json")}function m(){return(process.env.MISTFLOW_API_URL||"https://api.mistflow.ai").replace(/\/+$/,"")}var G="https://api.mistflow.ai";function T(){let e=I();if(!D(e))return null;try{let t=JSON.parse(B(e,"utf-8"));return typeof t.apiKey=="string"?{[G]:t}:t}catch{return null}}function _(){let e=process.env.MISTFLOW_API_KEY;if(e)return{ok:!0,creds:{apiKey:e,orgId:"",orgSlug:"env"}};let t=T();if(!t)return{ok:!1,reason:"missing"};let n=m(),o=t[n];return o&&typeof o.apiKey=="string"&&o.apiKey&&typeof o.orgId=="string"?{ok:!0,creds:o}:{ok:!1,reason:"missing"}}function ge(e){let t=I(),n=W(t);D(n)||K(n,{recursive:!0});let o=T()??{},r=m();o[r]=e;let s=U(n,`.credentials.tmp.${z(8).toString("hex")}`);try{q(s,JSON.stringify(o,null,2)+`
23
- `,{mode:384}),J(s,t)}catch(c){try{H(s)}catch{}throw c}}function X(){return _().ok}function $(){return m()}function he(){let e=process.env.MISTFLOW_API_URL;if(e){if(e.includes("mistflow.localhost"))return e.replace("api.mistflow","mistflow");if(e.includes("localhost:9100"))return e.replace(":9100",":9102")}return"https://mistflow.ai"}var i=class extends Error{constructor(n,o,r,s){super(o);this.code=n;this.statusCode=r;this.details=s;this.name="MistflowApiError"}get isAuth(){return this.code.startsWith("auth_")}get isTransient(){return this.code==="server_error"||this.code==="upstream_error"||this.code==="network_error"||this.code==="rate_limited"}};function Y(){let e=_();if(!e.ok)throw new i("auth_missing","No Mistflow credentials found.",401);return Z(e.creds)}function Z(e){return{Authorization:`ApiKey ${e.apiKey}`,"Content-Type":"application/json","X-Mistflow-MCP-Version":f()}}function M(e){try{P(e.headers)}catch{}}async function we(){try{let e=await fetch(`${$()}/health`,{method:"GET",signal:AbortSignal.timeout(5e3)});M(e)}catch{}}async function ee(e,t,n,o){for(let r=0;r<2;r++)try{return await fetch(e,{...t,signal:AbortSignal.timeout(n)})}catch(s){let c=s instanceof Error&&s.name==="TimeoutError",p=s instanceof TypeError;if(o&&r===0&&(c||p)){console.error(`[api] Retrying ${e} after ${c?"timeout":"network error"}`);continue}throw s}throw new Error("fetchWithRetry: exhausted retries")}async function te(e){let t=null;try{t=await e.json()}catch{t=null}let n=t&&typeof t.code=="string"?t.code:void 0,o=t&&typeof t.message=="string"?t.message:t&&typeof t.detail=="string"?t.detail:e.statusText||"Request failed";if(n)return new i(n,o,e.status,t?.details);let r=e.status;return r===401?new i("auth_invalid",o,r):r===403?new i("permission_denied",o,r):r===404?new i("not_found",o,r):r===409?new i("conflict",o,r):r===422?new i("validation_error",o,r):r===429?new i("rate_limited",o,r):r>=500?new i("server_error",e.statusText||"Internal server error",r):new i("client_error",o,r)}async function l(e,t={}){let n=Y(),{timeoutMs:o,idempotent:r,...s}=t,c=o??3e4,p=(s.method??"GET").toUpperCase(),j=r??(p==="GET"||p==="HEAD"),u;try{u=await ee(`${$()}${e}`,{...s,headers:{...n,...s.headers}},c,j)}catch(R){throw R instanceof Error&&R.name==="TimeoutError"?new i("network_error","Request timed out. Try again in a moment."):new i("network_error","Cannot reach Mistflow servers. Check your network.")}if(M(u),!u.ok)throw await te(u);return u.json()}var _e=300*1e3;async function Re(e,t,n="neon",o){return l("/api/projects",{method:"POST",body:JSON.stringify({name:e,template:t,db_provider:n,requested_subdomain:o})})}async function xe(e){return l(`/api/deploy/${encodeURIComponent(e)}/status`)}async function Se(e){return l(`/api/deploy/${encodeURIComponent(e)}/logs`)}async function ke(e,t="7d"){return l(`/api/projects/${encodeURIComponent(e)}/errors?period=${encodeURIComponent(t)}`)}async function Ce(e){return l(`/api/projects/${encodeURIComponent(e)}/deployments`)}async function be(e,t){return l(`/api/projects/${encodeURIComponent(e)}/share`,{method:"POST",body:JSON.stringify({is_template:t?.isTemplate??!1,template_description:t?.description})})}export{f as a,P as b,ie as c,ae as d,ge as e,X as f,$ as g,he as h,Y as i,we as j,Re as k,xe as l,Se as m,ke as n,Ce as o,be as p};
@@ -1 +0,0 @@
1
- import{c as m,d as y}from"./chunk-SXNAPWCC.js";import{f,g as u,i as p,k as g}from"./chunk-VQPRSDSC.js";import{existsSync as h,readFileSync as w,writeFileSync as b}from"fs";import{join as l}from"path";import{spawn as j}from"child_process";function C(r,t,e,s,o){return new Promise(n=>{let a=j(r,t,{cwd:e,stdio:["pipe","pipe","pipe"],timeout:s,...o?{env:{...process.env,...o}}:{}}),c="",d="";a.stdout?.on("data",i=>{c+=i.toString()}),a.stderr?.on("data",i=>{d+=i.toString()}),a.on("close",i=>n({success:i===0,stdout:c,stderr:d})),a.on("error",i=>n({success:!1,stdout:c,stderr:d+i.message}))})}function P(r){let t=l(r,"mistflow.json");if(!h(t))return null;try{return JSON.parse(w(t,"utf-8"))}catch{return null}}function k(r,t){b(l(r,"mistflow.json"),JSON.stringify(t,null,2))}async function S(r,t){try{let e=t.features,s=t.steps,o={plan:t};Array.isArray(e)&&e.length>0&&(o.features=e.map(n=>n.name)),Array.isArray(s)&&s.length>0&&(o.provenance=s.map(n=>({feature:n.name??n.title??`Step ${n.number??"?"}`,user_intent:(n.description??"").slice(0,500),decisions:"Seeded from plan",tradeoffs:"",files_affected:[]}))),await fetch(`${u()}/api/projects/${encodeURIComponent(r)}/state`,{method:"PUT",headers:{...p(),"Content-Type":"application/json"},body:JSON.stringify(o)})}catch(e){console.error("[self-heal] state sync failed:",e instanceof Error?e.message:String(e))}}async function x(r,t={}){let e=P(r);if(e){if(!f())return e.projectId;if(!e.projectId)try{let o=e.plan?.requestedSubdomain,n=await g(e.name,void 0,e.dbProvider??"neon",o);return e.projectId=n.id,k(r,e),m(r,y(n.id,e.name)),e.plan&&await S(n.id,e.plan),console.error(`[self-heal] registered project ${n.id.slice(0,8)} with backend`),n.id}catch(s){console.error("[self-heal] createProject failed:",s instanceof Error?s.message:String(s));return}return t.forceSync&&e.plan&&e.projectId&&await S(e.projectId,e.plan),e.projectId}}async function N(r,t){let e=["button","card","input","label","form","dialog","table","dropdown-menu","badge","separator","skeleton","sheet","tabs","avatar","select","textarea","checkbox","switch","tooltip","popover","sonner"],s=t&&t.length>0?t:e,o=l(r,"components","ui"),n=[],a=[];for(let i of s)h(l(o,`${i}.tsx`))?n.push(i):a.push(i);if(a.length===0)return{installed:[],alreadyPresent:n};let c={NPM_CONFIG_LEGACY_PEER_DEPS:"true"},d=await C("npx",["--yes","shadcn@latest","add","-y","-o",...a],r,18e4,c);return d.success?{installed:a,alreadyPresent:n}:{installed:[],alreadyPresent:n,failed:`shadcn add failed for: ${a.join(", ")}. ${d.stderr.slice(-300)}`.trim()}}export{x as ensureBackendRegistered,N as ensureShadcnComponents};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g}from"./chunk-SXNAPWCC.js";import"./chunk-VQPRSDSC.js";export{d as emptyState,e as fetchRemoteState,g as fuzzyMatch,a as getLocalStatePath,b as readLocalState,f as syncRemoteState,c as writeLocalState};