typebulb 0.9.5 → 0.9.7
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/README.md +2 -1
- package/dist/bulbs/claude.bulb.md +3262 -0
- package/dist/index.js +54 -50
- package/dist/servers.d.ts +3 -2
- package/dist/servers.js +3 -3
- package/package.json +1 -1
package/dist/servers.d.ts
CHANGED
|
@@ -23,8 +23,9 @@ export interface BulbServer {
|
|
|
23
23
|
* (no console window); detached so it outlives the caller. `trust` passes --trust. */
|
|
24
24
|
export declare function launchBulbServer(file: string, opts?: { cwd?: string; open?: boolean; trust?: boolean }): Promise<BulbServer>
|
|
25
25
|
|
|
26
|
-
/** Every live dev server, oldest first. Dead entries are pruned on read.
|
|
27
|
-
|
|
26
|
+
/** Every live dev server, oldest first. Dead entries are pruned on read. Pass `cwd` to scope the
|
|
27
|
+
* list to that project's bulbs (the machine-global default is for explicit pid/file targeting). */
|
|
28
|
+
export declare function listBulbServers(cwd?: string): Promise<BulbServer[]>
|
|
28
29
|
|
|
29
30
|
/** Stop a server by pid (SIGTERM + deregister). Idempotent. */
|
|
30
31
|
export declare function stopBulbServer(pid: number): Promise<void>
|
package/dist/servers.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{spawn as
|
|
2
|
-
`),r=0;if(t[r]?.trim()!=="---")return null;r++;let n=[];for(;r<t.length&&t[r]?.trim()!=="---";)n.push(t[r]),r++;if(t[r]?.trim()!=="---")return null;r++;let s=
|
|
3
|
-
`))}else r++}return{frontmatter:s,files:i}}catch{return null}}function
|
|
1
|
+
import{spawn as x}from"child_process";import{readdir as N,readFile as k,writeFile as mt,unlink as f,mkdir as dt}from"fs/promises";import{mkdirSync as bt,writeFileSync as ht,appendFileSync as yt,readFileSync as $}from"fs";import*as a from"path";import{join as h,resolve as E}from"path";import{homedir as L}from"os";function d(){let e=process.env.TYPEBULB_SERVERS_DIR;return e?h(e,".."):h(L(),".typebulb")}function l(){return process.env.TYPEBULB_SERVERS_DIR||h(d(),"servers")}function c(e){let t=E(e);return(process.platform==="win32"?t.toLowerCase():t).replace(/\\/g,"/")}function S(e,t){let r=c(e),n=c(t);return r.startsWith(n.endsWith("/")?n:n+"/")?!r.includes("/node_modules/"):!1}function O(e){return a.join(l(),`${e}.json`)}function g(e){return a.join(l(),`${e}.log`)}function R(e,t=0){try{let r=$(g(e)),n=t>=0&&t<=r.length?t:0;return{text:r.subarray(n).toString("utf8"),offset:r.length}}catch{return{text:"",offset:0}}}function A(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}async function I(e){await f(O(e)).catch(()=>{}),await f(g(e)).catch(()=>{})}async function y(e){let t;try{t=await N(l())}catch{return[]}let r=[];return await Promise.all(t.map(async s=>{if(!s.endsWith(".json"))return;let i=a.join(l(),s),o;try{o=JSON.parse(await k(i,"utf8"))}catch{await f(i).catch(()=>{});return}o&&typeof o.pid=="number"&&A(o.pid)?r.push(o):(await f(i).catch(()=>{}),o?.pid&&await f(g(o.pid)).catch(()=>{}))})),(e?r.filter(s=>S(s.file,e)):r).sort((s,i)=>s.startedAt-i.startedAt)}async function W(e){try{process.kill(e,"SIGTERM")}catch{}await I(e)}var J=e=>new Promise(t=>setTimeout(t,e));async function M(e,t={}){let r=t.cwd??process.cwd(),n=a.resolve(r,e),s=(await y()).find(u=>u.file===n);if(s)return s;let i=["typebulb",...t.trust?["--trust"]:[],e,...t.open===!1?["--no-open"]:[]];(process.platform==="win32"?x("cmd",["/c","start","","/b","npx",...i],{cwd:r,stdio:"ignore",windowsHide:!0}):x("npx",i,{cwd:r,detached:!0,stdio:"ignore"})).unref();let p=Date.now()+2e4;for(;Date.now()<p;){await J(150);let u=(await y()).find(m=>m.file===n);if(u)return u}throw new Error(`Launched ${a.basename(e)} but it did not register within 20s.`)}import{readdirSync as U,readFileSync as z,statSync as H}from"fs";import{join as B,basename as Y}from"path";function b(e){let t=/^---[^\n]*\n([\s\S]*?)\n---/.exec(e),r=t?/^\s*name:\s*(.+?)\s*$/m.exec(t[1]):null;return r?r[1].replace(/^["']|["']$/g,""):void 0}function C(e){return(b(e)??"bulb").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"bulb"}function K(e){return e.replace(/^---[^\n]*\r?\n[\s\S]*?\r?\n---[^\n]*\r?\n?/,"").replace(/^\r?\n+/,"")}function P(e,t,r){if(t>8)return r;let n;try{n=U(e,{withFileTypes:!0})}catch{return r}for(let s of n)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;P(B(e,s.name),t+1,r)}else s.isFile()&&s.name.endsWith(".bulb.md")&&r.push(B(e,s.name));return r}function G(e){return P(e,0,[]).map(t=>{let r=0;try{r=H(t).mtimeMs}catch{}let n;try{n=b(z(t,"utf8").slice(0,1024))}catch{}return{path:t,name:n??Y(t).replace(/\.bulb\.md$/,""),mtime:r}})}import{readFile as X}from"fs/promises";var V={code:{path:"code.tsx",language:"typescript"},css:{path:"styles.css",language:"css"},html:{path:"index.html",language:"html"},config:{path:"config.json",language:"json"},notes:{path:"notes.md",language:"markdown"},data:{path:"data.txt",language:"text"},infer:{path:"infer.md",language:"markdown"},insight:{path:"insight.json",language:"json"},server:{path:"server.ts",language:"typescript"}};function F(e){try{let t=e.split(`
|
|
2
|
+
`),r=0;if(t[r]?.trim()!=="---")return null;r++;let n=[];for(;r<t.length&&t[r]?.trim()!=="---";)n.push(t[r]),r++;if(t[r]?.trim()!=="---")return null;r++;let s=q(n);if(!s)return null;let i=new Map;for(;r<t.length;){let p=t[r]?.trim()?.match(/^\*\*(.+)\*\*$/);if(p){let u=p[1].trim();for(r++;r<t.length&&t[r]?.trim()==="";)r++;let m=t[r]?.match(/^(`{3,})(\w*)\s*$/);if(!m){r++;continue}let T=m[1];r++;let v=[];for(;r<t.length&&!t[r]?.match(new RegExp(`^${T}\\s*$`));)v.push(t[r]),r++;r++,i.set(u,v.join(`
|
|
3
|
+
`))}else r++}return{frontmatter:s,files:i}}catch{return null}}function q(e){let t={};for(let r of e){let n=r.indexOf(":");if(n===-1)continue;let s=r.slice(0,n).trim(),i=r.slice(n+1).trim();switch(s){case"format":t.format=i;break;case"name":t.name=Q(i);break}}return!t.format?.startsWith("typebulb")||!t.name?null:t}function Q(e){return e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1).replace(/\\"/g,'"'):e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function j(e){let t=r=>e.files.get(V[r].path)||"";return{name:e.frontmatter.name,code:t("code"),css:t("css"),html:t("html"),config:t("config"),notes:t("notes"),data:t("data"),infer:t("infer"),insight:t("insight"),server:t("server")}}function _(e){if(e.server.trim())return"server-side code (server.ts)";let t=e.code;if(/\btb\s*\.\s*fs\b/.test(t)||t.includes("/__fs"))return"the filesystem";if(/\btb\s*\.\s*ai\b/.test(t)||t.includes("/__ai"))return"AI (your API keys)";if(/\btb\s*\.\s*server\s*\.\s*(?!log\b)\w/.test(t)||t.includes("/__api"))return"server-side code (server.ts)"}async function Z(e){try{let t=F(await X(e,"utf-8"));return t?_(j(t)):void 0}catch{return}}import{readFileSync as tt,writeFileSync as et,mkdirSync as rt}from"fs";import{join as nt}from"path";function D(){return nt(d(),"trust.json")}function w(){try{let e=JSON.parse(tt(D(),"utf8"));return new Set(Array.isArray(e)?e:[])}catch{return new Set}}function st(e){rt(d(),{recursive:!0}),et(D(),JSON.stringify([...e]))}function it(e){return w().has(c(e))}function ot(e,t){let r=w(),n=c(e);(t?r.has(n):!r.has(n))||(t?r.add(n):r.delete(n),st(r))}function at(){return[...w()]}export{b as bulbName,it as isBulbTrusted,M as launchBulbServer,G as listBulbFiles,y as listBulbServers,at as listTrustedBulbs,Z as predictBulbTrust,R as readServerLog,g as serverLogPath,ot as setBulbTrusted,C as slugifyBulbName,W as stopBulbServer,K as stripFrontmatter};
|