typebulb 0.10.6 → 0.11.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/README.md +0 -3
- package/dist/agents/claude/client.js +923 -0
- package/dist/agents/claude/index.html +2 -0
- package/dist/agents/claude/styles.css +928 -0
- package/dist/index.js +166 -60
- package/dist/servers.js +3 -3
- package/package.json +10 -3
- package/bulbs/claude.bulb.md +0 -3345
package/dist/servers.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{spawn as
|
|
2
|
-
`),
|
|
3
|
-
`))}else
|
|
1
|
+
import{spawn as B}from"child_process";import{readdir as $,readFile as I,writeFile as Bt,unlink as m,mkdir as Pt}from"fs/promises";import{mkdirSync as jt,writeFileSync as Et,appendFileSync as Tt,readFileSync as N}from"fs";import*as a from"path";import{fileURLToPath as k}from"url";import{join as y,resolve as D}from"path";import{homedir as L}from"os";function f(){let r=process.env.TYPEBULB_SERVERS_DIR;return r?y(r,".."):y(L(),".typebulb")}function l(){return process.env.TYPEBULB_SERVERS_DIR||y(f(),"servers")}function c(r){let t=D(r);return(process.platform==="win32"?t.toLowerCase():t).replace(/\\/g,"/")}function S(r,t){let e=c(r),n=c(t);return e.startsWith(n.endsWith("/")?n:n+"/")?!e.includes("/node_modules/"):!1}function O(r){return a.join(l(),`${r}.json`)}function d(r){return a.join(l(),`${r}.log`)}function R(r,t=0){try{let e=N(d(r)),n=t>=0&&t<=e.length?t:0;return{text:e.subarray(n).toString("utf8"),offset:e.length}}catch{return{text:"",offset:0}}}function A(r){try{return process.kill(r,0),!0}catch(t){return t.code==="EPERM"}}async function W(r){await m(O(r)).catch(()=>{}),await m(d(r)).catch(()=>{})}async function w(r){let t;try{t=await $(l())}catch{return[]}let e=[];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 I(i,"utf8"))}catch{await m(i).catch(()=>{});return}o&&typeof o.pid=="number"&&A(o.pid)?e.push(o):(await m(i).catch(()=>{}),o?.pid&&await m(d(o.pid)).catch(()=>{}))})),(r?e.filter(s=>s.agent==null&&S(s.file,r)):e).sort((s,i)=>s.startedAt-i.startedAt)}async function C(r){try{process.kill(r,"SIGTERM")}catch{}await W(r)}var J=r=>new Promise(t=>setTimeout(t,r));function M(){return a.join(a.dirname(k(import.meta.url)),"index.js")}function U(r,t={}){return{command:process.execPath,args:[M(),...t.trust?["--trust"]:[],r,...t.open===!1?["--no-open"]:[]]}}async function K(r,t={}){let e=t.cwd??process.cwd(),n=a.resolve(e,r),s=(await w()).find(u=>u.file===n);if(s)return s;let{command:i,args:o}=U(r,t);(process.platform==="win32"?B("cmd",["/c","start","","/b",i,...o],{cwd:e,stdio:"ignore",windowsHide:!0}):B(i,o,{cwd:e,detached:!0,stdio:"ignore"})).unref();let b=Date.now()+2e4;for(;Date.now()<b;){await J(150);let u=(await w()).find(h=>h.file===n);if(u)return u}throw new Error(`Launched ${a.basename(r)} but it did not register within 20s.`)}import{readdirSync as H,readFileSync as V,statSync as G}from"fs";import{join as P,basename as q}from"path";function p(r){let t=/^---[^\n]*\n([\s\S]*?)\n---/.exec(r),e=t?/^\s*name:\s*(.+?)\s*$/m.exec(t[1]):null;return e?e[1].replace(/^["']|["']$/g,""):void 0}function Y(r){return(p(r)??"bulb").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"bulb"}function z(r){return r.replace(/^---[^\n]*\r?\n[\s\S]*?\r?\n---[^\n]*\r?\n?/,"").replace(/^\r?\n+/,"")}function F(r,t,e){if(t>8)return e;let n;try{n=H(r,{withFileTypes:!0})}catch{return e}for(let s of n)if(s.isDirectory()){if(s.name.startsWith(".")||s.name==="node_modules")continue;F(P(r,s.name),t+1,e)}else s.isFile()&&s.name.endsWith(".bulb.md")&&e.push(P(r,s.name));return e}function Q(r){return F(r,0,[]).map(t=>{let e=0;try{e=G(t).mtimeMs}catch{}let n;try{n=p(V(t,"utf8").slice(0,1024))}catch{}return{path:t,name:n??q(t).replace(/\.bulb\.md$/,""),mtime:e}})}import{readFile as rt}from"fs/promises";var X={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 j(r){try{let t=r.split(`
|
|
2
|
+
`),e=0;if(t[e]?.trim()!=="---")return null;e++;let n=[];for(;e<t.length&&t[e]?.trim()!=="---";)n.push(t[e]),e++;if(t[e]?.trim()!=="---")return null;e++;let s=Z(n);if(!s)return null;let i=new Map;for(;e<t.length;){let g=t[e]?.trim()?.match(/^\*\*(.+)\*\*$/);if(g){let b=g[1].trim();for(e++;e<t.length&&t[e]?.trim()==="";)e++;let u=t[e]?.match(/^(`{3,})(\w*)\s*$/);if(!u){e++;continue}let h=u[1];e++;let x=[];for(;e<t.length&&!t[e]?.match(new RegExp(`^${h}\\s*$`));)x.push(t[e]),e++;e++,i.set(b,x.join(`
|
|
3
|
+
`))}else e++}return{frontmatter:s,files:i}}catch{return null}}function Z(r){let t={};for(let e of r){let n=e.indexOf(":");if(n===-1)continue;let s=e.slice(0,n).trim(),i=e.slice(n+1).trim();switch(s){case"format":t.format=i;break;case"name":t.name=tt(i);break}}return!t.format?.startsWith("typebulb")||!t.name?null:t}function tt(r){return r.startsWith('"')&&r.endsWith('"')?r.slice(1,-1).replace(/\\"/g,'"'):r.startsWith("'")&&r.endsWith("'")?r.slice(1,-1):r}function E(r){let t=e=>r.files.get(X[e].path)||"";return{name:r.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 T(r){if(r.server.trim())return"server-side code (server.ts)";let t=r.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 et(r){try{let t=j(await rt(r,"utf-8"));return t?T(E(t)):void 0}catch{return}}import{spawn as nt}from"child_process";import{basename as st}from"path";function it(){return process.env.TYPEBULB_EDITOR||"code"}var ot=/^(code|code-insiders|codium|vscodium|cursor|windsurf)(\.cmd|\.exe)?$/i;function at(r,t,e){return e==null?[t]:ot.test(st(r))?["-g",`${t}:${e}`]:[`+${e}`,t]}function ut(r,t){let e=it();return{command:e,args:at(e,r,t)}}function ct(r,t){let{command:e,args:n}=ut(r,t),s=nt(e,n,{shell:!0,detached:!0,stdio:"ignore"});s.on("error",i=>console.error("[typebulb] editor launch failed:",i?.message??i)),s.unref()}import{readFileSync as lt,writeFileSync as mt,mkdirSync as ft}from"fs";import{join as dt}from"path";function _(){return dt(f(),"trust.json")}function v(){try{let r=JSON.parse(lt(_(),"utf8"));return new Set(Array.isArray(r)?r:[])}catch{return new Set}}function pt(r){ft(f(),{recursive:!0}),mt(_(),JSON.stringify([...r]))}function gt(r){return v().has(c(r))}function bt(r,t){let e=v(),n=c(r);(t?e.has(n):!e.has(n))||(t?e.add(n):e.delete(n),pt(e))}function ht(){return[...v()]}export{p as bulbName,gt as isBulbTrusted,K as launchBulbServer,Q as listBulbFiles,w as listBulbServers,ht as listTrustedBulbs,ct as openInEditor,et as predictBulbTrust,R as readServerLog,d as serverLogPath,bt as setBulbTrusted,Y as slugifyBulbName,C as stopBulbServer,z as stripFrontmatter};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typebulb",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Local bulb runner CLI for Typebulb",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": { "node": ">=18" },
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
|
-
"dist"
|
|
27
|
-
"bulbs/*.bulb.md"
|
|
26
|
+
"dist"
|
|
28
27
|
],
|
|
29
28
|
"scripts": {
|
|
30
29
|
"typecheck": "tsc --build",
|
|
@@ -48,10 +47,18 @@
|
|
|
48
47
|
"sucrase": "^3.35.0"
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
50
|
+
"@types/katex": "^0.16.7",
|
|
51
|
+
"@types/markdown-it": "^14.1.2",
|
|
51
52
|
"@types/node": "^22.15.21",
|
|
52
53
|
"@typebulb/shared-providers": "workspace:*",
|
|
53
54
|
"@typebulb/shared-types": "workspace:*",
|
|
55
|
+
"beautiful-mermaid": "^1.1.3",
|
|
56
|
+
"domeleon": "^0.6.0",
|
|
57
|
+
"dompurify": "^3.2.6",
|
|
54
58
|
"esbuild": "^0.27.3",
|
|
59
|
+
"highlight.js": "^11.10.0",
|
|
60
|
+
"katex": "^0.16.22",
|
|
61
|
+
"markdown-it": "^14.1.0",
|
|
55
62
|
"rimraf": "^6.0.1",
|
|
56
63
|
"typebulb-resolver": "workspace:*",
|
|
57
64
|
"typebulb-dts": "workspace:*",
|