herm-tui 1.0.0-dev.1 → 1.0.0-dev.3
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/db.worker.js +81 -0
- package/highlights-eq9cgrbb.scm +604 -0
- package/highlights-ghv9g403.scm +205 -0
- package/highlights-hk7bwhj4.scm +284 -0
- package/highlights-r812a2qc.scm +150 -0
- package/highlights-x6tmsnaa.scm +115 -0
- package/index.js +10374 -0
- package/injections-73j83es3.scm +27 -0
- package/package.json +14 -64
- package/parser.worker.js +8 -0
- package/tree-sitter-3jzf13jk.wasm +0 -0
- package/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
- package/tree-sitter-markdown-411r6y9b.wasm +0 -0
- package/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
- package/tree-sitter-typescript-zxjzwt75.wasm +0 -0
- package/tree-sitter-zig-e78zbjpm.wasm +0 -0
- package/scripts/postinstall.ts +0 -29
- package/src/app/gateway.tsx +0 -83
- package/src/app/gatewayEvents.ts +0 -203
- package/src/app/launch.ts +0 -41
- package/src/app/skin.tsx +0 -31
- package/src/app/spawnHistory.ts +0 -75
- package/src/app/tabs.ts +0 -23
- package/src/app/turnReducer.ts +0 -390
- package/src/app/useAppKeys.ts +0 -268
- package/src/app/useAtRefPopover.ts +0 -99
- package/src/app/useInputHistory.ts +0 -66
- package/src/app/useSession.ts +0 -102
- package/src/app/useSlashCommands.ts +0 -70
- package/src/app/useSlashPopover.ts +0 -48
- package/src/app.tsx +0 -917
- package/src/commands/slash.ts +0 -151
- package/src/components/avatar/AnimatedAvatar.tsx +0 -66
- package/src/components/avatar/eikon.ts +0 -144
- package/src/components/avatar/states/error.ts +0 -1155
- package/src/components/avatar/states/idle.ts +0 -1155
- package/src/components/avatar/states/index.ts +0 -30
- package/src/components/avatar/states/listening.ts +0 -1155
- package/src/components/avatar/states/speaking.ts +0 -1155
- package/src/components/avatar/states/thinking.ts +0 -1155
- package/src/components/avatar/states/working.ts +0 -1155
- package/src/components/chat/AtRefPopover.tsx +0 -54
- package/src/components/chat/CodeBlock.tsx +0 -67
- package/src/components/chat/Composer.tsx +0 -347
- package/src/components/chat/DiffBlock.tsx +0 -116
- package/src/components/chat/ErrorBlock.tsx +0 -70
- package/src/components/chat/MediaChip.tsx +0 -114
- package/src/components/chat/MessageItem.tsx +0 -282
- package/src/components/chat/MessageList.tsx +0 -114
- package/src/components/chat/PromptCard.tsx +0 -359
- package/src/components/chat/SlashPopover.tsx +0 -158
- package/src/components/chat/ThoughtCloud.tsx +0 -185
- package/src/components/chat/TypingIndicator.tsx +0 -25
- package/src/components/chat/tool/Subagent.tsx +0 -75
- package/src/components/chat/tool/frame.tsx +0 -69
- package/src/components/chat/tool/index.tsx +0 -65
- package/src/components/chat/tool/preview.ts +0 -57
- package/src/components/sidebar/ContextGauge.tsx +0 -102
- package/src/components/sidebar/Sidebar.tsx +0 -143
- package/src/components/tabs/TabBar.tsx +0 -50
- package/src/components/ui/FileLink.tsx +0 -52
- package/src/config/index.ts +0 -156
- package/src/config/lane.ts +0 -161
- package/src/config/models.ts +0 -95
- package/src/config/rules.ts +0 -80
- package/src/config/schema.ts +0 -308
- package/src/dialogs/alert.tsx +0 -52
- package/src/dialogs/chafa.tsx +0 -72
- package/src/dialogs/confirm.tsx +0 -58
- package/src/dialogs/curator.tsx +0 -153
- package/src/dialogs/eikon-picker.tsx +0 -95
- package/src/dialogs/help.tsx +0 -80
- package/src/dialogs/history.tsx +0 -92
- package/src/dialogs/info.tsx +0 -115
- package/src/dialogs/keys.tsx +0 -170
- package/src/dialogs/logs.tsx +0 -42
- package/src/dialogs/message.tsx +0 -38
- package/src/dialogs/model-picker.tsx +0 -123
- package/src/dialogs/new-profile.tsx +0 -69
- package/src/dialogs/new-task.tsx +0 -103
- package/src/dialogs/profile.tsx +0 -55
- package/src/dialogs/rollback.tsx +0 -190
- package/src/dialogs/spawn-history.tsx +0 -80
- package/src/dialogs/text-prompt.tsx +0 -68
- package/src/dialogs/theme-picker.tsx +0 -50
- package/src/home/index.ts +0 -23
- package/src/home/store.ts +0 -267
- package/src/index.tsx +0 -113
- package/src/keys/catalog.ts +0 -115
- package/src/keys/chord.ts +0 -125
- package/src/keys/conflicts.ts +0 -48
- package/src/keys/context.tsx +0 -112
- package/src/keys/index.ts +0 -5
- package/src/keys/list.ts +0 -94
- package/src/keys/oc-compat.ts +0 -87
- package/src/tabs/Agents.tsx +0 -607
- package/src/tabs/Analytics.tsx +0 -154
- package/src/tabs/Chat.tsx +0 -50
- package/src/tabs/Config.tsx +0 -605
- package/src/tabs/Context.tsx +0 -599
- package/src/tabs/Cron.tsx +0 -294
- package/src/tabs/Env.tsx +0 -227
- package/src/tabs/Kanban.tsx +0 -367
- package/src/tabs/Memory.tsx +0 -294
- package/src/tabs/Sessions.tsx +0 -786
- package/src/tabs/Skills.tsx +0 -507
- package/src/tabs/Toolsets.tsx +0 -266
- package/src/theme/builtin.ts +0 -78
- package/src/theme/context.tsx +0 -106
- package/src/theme/index.ts +0 -4
- package/src/theme/resolve.ts +0 -134
- package/src/theme/syntax.ts +0 -31
- package/src/theme/themes/aura.json +0 -69
- package/src/theme/themes/ayu.json +0 -80
- package/src/theme/themes/carbonfox.json +0 -248
- package/src/theme/themes/catppuccin-frappe.json +0 -233
- package/src/theme/themes/catppuccin-macchiato.json +0 -233
- package/src/theme/themes/catppuccin.json +0 -112
- package/src/theme/themes/cobalt2.json +0 -228
- package/src/theme/themes/cursor.json +0 -249
- package/src/theme/themes/dracula.json +0 -219
- package/src/theme/themes/everforest.json +0 -241
- package/src/theme/themes/flexoki.json +0 -237
- package/src/theme/themes/github.json +0 -233
- package/src/theme/themes/gruvbox.json +0 -242
- package/src/theme/themes/kanagawa.json +0 -77
- package/src/theme/themes/lucent-orng.json +0 -237
- package/src/theme/themes/material.json +0 -235
- package/src/theme/themes/matrix.json +0 -77
- package/src/theme/themes/mercury.json +0 -252
- package/src/theme/themes/monokai.json +0 -221
- package/src/theme/themes/nightowl.json +0 -221
- package/src/theme/themes/nord.json +0 -223
- package/src/theme/themes/one-dark.json +0 -84
- package/src/theme/themes/opencode.json +0 -245
- package/src/theme/themes/orng.json +0 -249
- package/src/theme/themes/osaka-jade.json +0 -93
- package/src/theme/themes/palenight.json +0 -222
- package/src/theme/themes/rosepine.json +0 -234
- package/src/theme/themes/solarized.json +0 -223
- package/src/theme/themes/synthwave84.json +0 -226
- package/src/theme/themes/tokyonight.json +0 -243
- package/src/theme/themes/vercel.json +0 -245
- package/src/theme/themes/vesper.json +0 -218
- package/src/theme/themes/zenburn.json +0 -223
- package/src/theme/types.ts +0 -119
- package/src/types/message.ts +0 -97
- package/src/ui/ChafaImage.tsx +0 -64
- package/src/ui/Splash.tsx +0 -118
- package/src/ui/borders.ts +0 -28
- package/src/ui/command.tsx +0 -104
- package/src/ui/dialog-select.tsx +0 -164
- package/src/ui/dialog.tsx +0 -102
- package/src/ui/fmt.ts +0 -82
- package/src/ui/kv.tsx +0 -28
- package/src/ui/shell.tsx +0 -45
- package/src/ui/spinner.tsx +0 -59
- package/src/ui/splash-art.ts +0 -123
- package/src/ui/table.tsx +0 -117
- package/src/ui/ticker.tsx +0 -90
- package/src/ui/toast.tsx +0 -130
- package/src/utils/categorical.ts +0 -77
- package/src/utils/chafa.ts +0 -173
- package/src/utils/clipboard.ts +0 -67
- package/src/utils/context-segments.ts +0 -317
- package/src/utils/control.ts +0 -495
- package/src/utils/drop.ts +0 -25
- package/src/utils/editor.ts +0 -33
- package/src/utils/fuzzy.ts +0 -45
- package/src/utils/gateway-client.ts +0 -253
- package/src/utils/gateway-types.ts +0 -282
- package/src/utils/git.ts +0 -57
- package/src/utils/hermes-analytics.ts +0 -134
- package/src/utils/hermes-home.ts +0 -821
- package/src/utils/hermes-kanban.ts +0 -154
- package/src/utils/hermes-profiles.ts +0 -217
- package/src/utils/interpolate.ts +0 -31
- package/src/utils/math-unicode.ts +0 -818
- package/src/utils/memory-activity.ts +0 -140
- package/src/utils/open-file.ts +0 -13
- package/src/utils/paths.ts +0 -52
- package/src/utils/perf.ts +0 -235
- package/src/utils/preferences.ts +0 -150
- package/src/utils/sessions-db.ts +0 -396
- package/src/utils/subagent-tree.ts +0 -146
- package/src/utils/terminal-reset.ts +0 -129
- package/src/utils/tips.ts +0 -67
- package/src/utils/tokens.ts +0 -87
package/db.worker.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __create=Object.create;var{getPrototypeOf:__getProtoOf,defineProperty:__defProp,getOwnPropertyNames:__getOwnPropNames}=Object;var __hasOwnProp=Object.prototype.hasOwnProperty;function __accessProp(key){return this[key]}var __toESMCache_node,__toESMCache_esm,__toESM=(mod,isNodeMode,target)=>{var canCache=mod!=null&&typeof mod==="object";if(canCache){var cache=isNodeMode?__toESMCache_node??=new WeakMap:__toESMCache_esm??=new WeakMap,cached=cache.get(mod);if(cached)return cached}target=mod!=null?__create(__getProtoOf(mod)):{};let to=isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target;for(let key of __getOwnPropNames(mod))if(!__hasOwnProp.call(to,key))__defProp(to,key,{get:__accessProp.bind(mod,key),enumerable:!0});if(canCache)cache.set(mod,to);return to};var __commonJS=(cb,mod)=>()=>(mod||cb((mod={exports:{}}).exports,mod),mod.exports);var __returnValue=(v)=>v;function __exportSetter(name,newValue){this[name]=__returnValue.bind(null,newValue)}var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0,configurable:!0,set:__exportSetter.bind(all,name)})};var __esm=(fn,res)=>()=>(fn&&(res=fn(fn=0)),res);var __require=import.meta.require;var level,enabled,verbose,timings,noop=()=>0,mark,stages,boot=(label,ms)=>{if(stages.push([label,ms]),enabled)log(`\uD83D\uDE80 boot:${label} ${ms.toFixed(1)}ms`)},counters,count,snapshots,mb=(n)=>(n/1024/1024).toFixed(1),mem,monitor,renders,onRender,report=()=>{if(!enabled)return;let lines=[`
|
|
3
|
+
\x1B[1m\u2550\u2550\u2550 PERF REPORT \u2550\u2550\u2550\x1B[0m
|
|
4
|
+
`];if(snapshots.length>0){lines.push("\x1B[1mMemory Snapshots:\x1B[0m");for(let s of snapshots)lines.push(` ${s.label}: RSS=${mb(s.rss)}MB heap=${mb(s.heap)}MB ext=${mb(s.external)}MB`);let first=snapshots[0],last=snapshots[snapshots.length-1],drift=last.rss-first.rss;lines.push(` \u0394 RSS: ${drift>0?"+":""}${mb(drift)}MB (${first.label} \u2192 ${last.label})`),lines.push("")}if(timings.size>0){lines.push("\x1B[1mTimings:\x1B[0m");let sorted=[...timings.entries()].sort((a,b)=>b[1].total-a[1].total);for(let[label,t]of sorted){let avg=t.total/t.count;lines.push(` ${label}: ${t.count}\xD7 avg=${avg.toFixed(2)}ms min=${t.min.toFixed(2)}ms max=${t.max.toFixed(2)}ms total=${t.total.toFixed(0)}ms`)}lines.push("")}if(renders.size>0){lines.push("\x1B[1mReact Renders:\x1B[0m");let sorted=[...renders.entries()].sort((a,b)=>b[1].count-a[1].count);for(let[id,r]of sorted){let avg=r.total/r.count;lines.push(` <${id}>: ${r.count}\xD7 avg=${avg.toFixed(2)}ms max=${r.max.toFixed(2)}ms total=${r.total.toFixed(0)}ms`)}lines.push("")}if(counters.size>0){lines.push("\x1B[1mCounters:\x1B[0m");let sorted=[...counters.entries()].sort((a,b)=>b[1]-a[1]);for(let[label,n]of sorted)lines.push(` ${label}: ${n}`);lines.push("")}log(lines.join(`
|
|
5
|
+
`))},data=()=>{if(!enabled)return null;let m=process.memoryUsage();return{boot:Object.fromEntries(stages.map(([l,ms])=>[l,+ms.toFixed(1)])),memory:{rss:Math.round(m.rss/1024/1024),heap:Math.round(m.heapUsed/1024/1024),heapTotal:Math.round(m.heapTotal/1024/1024),external:Math.round(m.external/1024/1024)},snapshots:snapshots.map((s)=>({label:s.label,rss:Math.round(s.rss/1024/1024),heap:Math.round(s.heap/1024/1024),external:Math.round(s.external/1024/1024)})),timings:Object.fromEntries([...timings.entries()].sort((a,b)=>b[1].total-a[1].total).map(([k,v])=>[k,{count:v.count,avg:+(v.total/v.count).toFixed(2),min:+v.min.toFixed(2),max:+v.max.toFixed(2),total:Math.round(v.total)}])),renders:Object.fromEntries([...renders.entries()].sort((a,b)=>b[1].count-a[1].count).map(([k,v])=>[k,{count:v.count,avg:+(v.total/v.count).toFixed(2),max:+v.max.toFixed(2),total:Math.round(v.total)}])),counters:Object.fromEntries([...counters.entries()].sort((a,b)=>b[1]-a[1]))}},log=(msg)=>process.stderr.write(msg+`
|
|
6
|
+
`);var init_perf=__esm(()=>{level=process.env.PERF??"",enabled=level==="1"||level==="verbose",verbose=level==="verbose",timings=new Map,mark=enabled?(label)=>{let start=Bun.nanoseconds();return()=>{let ms=(Bun.nanoseconds()-start)/1e6,t=timings.get(label);if(t){if(t.count++,t.total+=ms,ms<t.min)t.min=ms;if(ms>t.max)t.max=ms;t.last=ms}else timings.set(label,{count:1,total:ms,min:ms,max:ms,last:ms});if(verbose)log(`\u23F1 ${label}: ${ms.toFixed(2)}ms`);return ms}}:(_)=>noop,stages=[],counters=new Map,count=enabled?(label,n=1)=>{counters.set(label,(counters.get(label)??0)+n)}:(_label,_n)=>{},snapshots=[],mem=enabled?(label)=>{let m=process.memoryUsage();snapshots.push({label,rss:m.rss,heap:m.heapUsed,external:m.external,ts:Date.now()}),log(`\uD83D\uDCCA [${label}] RSS=${mb(m.rss)}MB heap=${mb(m.heapUsed)}MB ext=${mb(m.external)}MB`)}:(_)=>{},monitor=enabled?(ms=1e4)=>{let id=setInterval(()=>{let m=process.memoryUsage(),gc=Bun.gc(!1);log(`\x1B[90m[mem] RSS=${mb(m.rss)}MB heap=${mb(m.heapUsed)}/${mb(m.heapTotal)}MB ext=${mb(m.external)}MB gcRuns=${gc?.eden_collections??"?"}/${gc?.full_collections??"?"}\x1B[0m`)},ms);return()=>clearInterval(id)}:(_ms)=>noop,renders=new Map,onRender=enabled?(id,phase,actual)=>{let r=renders.get(id);if(r){if(r.count++,r.total+=actual,actual>r.max)r.max=actual;r.last=actual}else renders.set(id,{count:1,total:actual,max:actual,last:actual});if(verbose&&actual>1)log(`\uD83D\uDD04 [${id}] ${phase}: ${actual.toFixed(2)}ms`)}:(_id,_phase,_actual)=>{};if(enabled)process.on("exit",report),process.on("SIGINT",()=>{report(),process.exit(0)})});import{Database}from"bun:sqlite";import{homedir}from"os";function roots(limit=30){let end=mark("io:sessions.roots");try{return(q(`SELECT ${COLS} FROM sessions s
|
|
7
|
+
WHERE s.parent_session_id IS NULL
|
|
8
|
+
OR EXISTS (SELECT 1 FROM sessions p
|
|
9
|
+
WHERE p.id = s.parent_session_id
|
|
10
|
+
AND ${BR("s")})
|
|
11
|
+
ORDER BY s.started_at DESC
|
|
12
|
+
LIMIT ?`)?.all(limit)??[]).map((r)=>{if(r.end_reason!=="compression")return toRow(r);let tid=tip(r.id);if(tid===r.id)return toRow(r);let t=one(tid);return t?{...toRow(t,r.id),started_at:r.started_at}:toRow(r)})}finally{end()}}function children(pid){let end=mark("io:sessions.children");try{return(q(`SELECT ${COLS} FROM sessions s
|
|
13
|
+
JOIN sessions p ON p.id = s.parent_session_id
|
|
14
|
+
WHERE s.parent_session_id = ? AND ${SUB("s")}
|
|
15
|
+
ORDER BY s.started_at ASC`)?.all(pid)??[]).map((r)=>toRow(r))}finally{end()}}function lineage(sid){let end=mark("io:sessions.lineage");try{let pred=q(`SELECT p.id, p.title FROM sessions c
|
|
16
|
+
JOIN sessions p ON p.id = c.parent_session_id
|
|
17
|
+
WHERE c.id = ? AND ${CONT("c")}`)?.get(sid),succ=q(`SELECT c.id, c.title FROM sessions c
|
|
18
|
+
JOIN sessions p ON p.id = c.parent_session_id
|
|
19
|
+
WHERE p.id = ? AND ${CONT("c")}
|
|
20
|
+
ORDER BY c.started_at DESC LIMIT 1`)?.get(sid);return{...pred&&{continuesFrom:pred},...succ&&{compressedTo:succ}}}finally{end()}}function tip(sid){let step=q(`SELECT c.id FROM sessions c
|
|
21
|
+
JOIN sessions p ON p.id = c.parent_session_id
|
|
22
|
+
WHERE p.id = ? AND ${CONT("c")}
|
|
23
|
+
ORDER BY c.started_at DESC LIMIT 1`),cur=sid;for(let i=0;i<100;i++){let next=step?.get(cur);if(!next)return cur;cur=next.id}return cur}function peek(sid,n=60){let end=mark("io:sessions.peek");try{return q(`SELECT role, SUBSTR(content,1,400) AS content, tool_name,
|
|
24
|
+
SUBSTR(tool_calls,1,400) AS tool_calls, timestamp AS at
|
|
25
|
+
FROM (SELECT * FROM messages WHERE session_id = ?
|
|
26
|
+
ORDER BY id DESC LIMIT ?)
|
|
27
|
+
ORDER BY id ASC`)?.all(sid,n)??[]}finally{end()}}function goalState(sid){let row=q("SELECT value FROM state_meta WHERE key = ?")?.get(`goal:${sid}`);if(!row)return null;try{let j=JSON.parse(row.value);return{goal:String(j.goal??""),status:j.status??"active",turn_count:typeof j.turn_count==="number"?j.turn_count:void 0,max_turns:j.max_turns??null}}catch{return null}}function search(query,limit=30){let m=fts(query);if(!m)return[];let end=mark("io:sessions.search");try{let raw=q(`SELECT m.session_id, m.role,
|
|
28
|
+
snippet(messages_fts, 0, '>>>', '<<<', '...', 40) AS snippet,
|
|
29
|
+
s.source, s.model, s.started_at,
|
|
30
|
+
COALESCE(s.title, SUBSTR(m.content, 1, 120)) AS title
|
|
31
|
+
FROM messages_fts
|
|
32
|
+
JOIN messages m ON m.id = messages_fts.rowid
|
|
33
|
+
JOIN sessions s ON s.id = m.session_id
|
|
34
|
+
WHERE messages_fts MATCH ?
|
|
35
|
+
ORDER BY rank LIMIT ?`)?.all(m,limit*4)??[],seen=new Set;return raw.filter((r)=>!seen.has(r.session_id)&&(seen.add(r.session_id),!0)).slice(0,limit)}finally{end()}}function rename(sid,title){let db=new Database(conn.path);try{return db.run("UPDATE sessions SET title = ? WHERE id = ?",[title,sid]),db.query("SELECT changes() AS c").get().c>0}finally{db.close()}}function remove(sid){let db=new Database(conn.path);try{if(!db.query("SELECT 1 FROM sessions WHERE id = ?").get(sid))return!1;return db.run("UPDATE sessions SET parent_session_id = NULL WHERE parent_session_id = ?",[sid]),db.run("DELETE FROM messages WHERE session_id = ?",[sid]),db.run("DELETE FROM sessions WHERE id = ?",[sid]),!0}finally{db.close()}}var HERMES,SRC,conn,setHome=(h)=>{let next=`${h}/state.db`;if(conn.path===next)return;conn.path=SRC.file=next,resetDb()},stateDb=()=>{if(conn.ro)return conn.ro;try{return conn.ro=new Database(conn.path,{readonly:!0})}catch{return null}},resetDb=()=>{for(let s of stmts.values())s.finalize();stmts.clear(),conn.ro?.close(),conn.ro=null},stmts,q=(sql)=>{let db=stateDb();if(!db)return null;let s=stmts.get(sql);if(!s)stmts.set(sql,s=db.query(sql));return s},SUB=(c)=>`(p.ended_at IS NULL OR ${c}.started_at < p.ended_at)`,CONT=(c)=>`(p.end_reason = 'compression' AND ${c}.started_at >= p.ended_at)`,BR=(c)=>`(p.end_reason = 'branched' AND ${c}.started_at >= p.ended_at)`,COLS=`
|
|
36
|
+
s.id, s.source, s.model, s.started_at, s.ended_at, s.end_reason,
|
|
37
|
+
s.message_count, s.tool_call_count,
|
|
38
|
+
s.input_tokens, s.output_tokens,
|
|
39
|
+
s.cache_read_tokens, s.cache_write_tokens, s.reasoning_tokens,
|
|
40
|
+
s.estimated_cost_usd, s.parent_session_id,
|
|
41
|
+
COALESCE(s.title,
|
|
42
|
+
(SELECT SUBSTR(content,1,120) FROM messages
|
|
43
|
+
WHERE session_id = s.id AND role = 'user' ORDER BY id LIMIT 1)) AS title,
|
|
44
|
+
(SELECT SUBSTR(content,1,120) FROM messages
|
|
45
|
+
WHERE session_id = s.id AND role = 'user' ORDER BY id DESC LIMIT 1) AS lastMessage,
|
|
46
|
+
(SELECT MAX(timestamp) FROM messages WHERE session_id = s.id) AS last_active,
|
|
47
|
+
(SELECT COUNT(*) FROM sessions c
|
|
48
|
+
WHERE c.parent_session_id = s.id
|
|
49
|
+
AND (s.ended_at IS NULL OR c.started_at < s.ended_at)) AS subagent_count`,toRow=(r,lineage=null)=>({source:SRC,id:r.id,sessionSource:r.source,model:r.model,started_at:r.started_at,ended_at:r.ended_at,end_reason:r.end_reason,message_count:r.message_count,tool_call_count:r.tool_call_count,input_tokens:r.input_tokens,output_tokens:r.output_tokens,cache_read_tokens:r.cache_read_tokens,cache_write_tokens:r.cache_write_tokens,reasoning_tokens:r.reasoning_tokens,estimated_cost_usd:r.estimated_cost_usd,title:r.title,lastMessage:r.lastMessage,last_active:r.last_active,parent_session_id:r.parent_session_id,subagent_count:r.subagent_count,lineage_root_id:lineage}),one=(id)=>q(`SELECT ${COLS} FROM sessions s WHERE s.id = ?`)?.get(id)??null,byId=(id)=>{let r=one(id);return r?toRow(r):null},lastReal=()=>roots().find((r)=>r.message_count>0&&r.sessionSource==="tui"),systemPrompt=()=>q(`SELECT id, system_prompt AS text FROM sessions
|
|
50
|
+
WHERE system_prompt IS NOT NULL AND length(system_prompt) > 1000
|
|
51
|
+
ORDER BY started_at DESC LIMIT 1`)?.get()??null,fts=(s)=>s.trim().split(/\s+/).filter(Boolean).map((w)=>/^\w+$/.test(w)?`${w}*`:`"${w.replace(/"/g,'""')}"`).join(" ");var init_sessions_db=__esm(()=>{init_perf();HERMES=process.env.HERMES_HOME||`${process.env.HOME||homedir()}/.hermes`,SRC={file:`${HERMES}/state.db`,relative:"state.db",label:"state.db"},conn={path:SRC.file,ro:null},stmts=new Map});function analytics(days,opts){let since=Math.floor(Date.now()/1000)-days*86400,db=stateDb();if(!db)return ZERO;let q2=db.query.bind(db),tot=q2(`SELECT COUNT(*) n,
|
|
52
|
+
COALESCE(SUM(message_count),0) msgs,
|
|
53
|
+
COALESCE(SUM(input_tokens),0) i,
|
|
54
|
+
COALESCE(SUM(output_tokens),0) o,
|
|
55
|
+
COALESCE(SUM(${CACHE}),0) c,
|
|
56
|
+
COALESCE(SUM(tool_call_count),0) calls,
|
|
57
|
+
COALESCE(SUM(${COST}),0) cost
|
|
58
|
+
FROM sessions WHERE started_at > ?`).get(since),models=q2(`SELECT COALESCE(model,'(unknown)') model,
|
|
59
|
+
COUNT(*) n,
|
|
60
|
+
COALESCE(SUM(input_tokens),0) i,
|
|
61
|
+
COALESCE(SUM(output_tokens),0) o,
|
|
62
|
+
COALESCE(SUM(${CACHE}),0) c,
|
|
63
|
+
COALESCE(SUM(${COST}),0) cost
|
|
64
|
+
FROM sessions WHERE started_at > ?
|
|
65
|
+
GROUP BY model ORDER BY i+o DESC`).all(since),daily=q2(`SELECT date(started_at,'unixepoch','localtime') day,
|
|
66
|
+
COUNT(*) n,
|
|
67
|
+
COALESCE(SUM(${COST}),0) cost
|
|
68
|
+
FROM sessions WHERE started_at > ?
|
|
69
|
+
GROUP BY day`).all(since),byDate=new Map(daily.map((r)=>[String(r.day),{date:String(r.day),sessions:num(r.n),cost:num(r.cost)}])),sources=q2(`SELECT COALESCE(source,'(unknown)') name, COUNT(*) n
|
|
70
|
+
FROM sessions WHERE started_at > ?
|
|
71
|
+
GROUP BY name ORDER BY n DESC`).all(since),tools=(()=>{if(opts?.tools===!1)return[];try{return q2(`SELECT json_extract(j.value,'$.function.name') name, COUNT(*) n
|
|
72
|
+
FROM messages m
|
|
73
|
+
JOIN sessions s ON s.id = m.session_id
|
|
74
|
+
, json_each(m.tool_calls) j
|
|
75
|
+
WHERE s.started_at > ? AND m.role='assistant'
|
|
76
|
+
AND m.tool_calls IS NOT NULL
|
|
77
|
+
GROUP BY name ORDER BY n DESC LIMIT 30`).all(since)}catch{return[]}})(),start=Date.now()-(days-1)*86400000;return{total:{sessions:num(tot.n),messages:num(tot.msgs),input:num(tot.i),output:num(tot.o),cache:num(tot.c),cost:num(tot.cost),calls:num(tot.calls)},byModel:models.map((r)=>({model:String(r.model),sessions:num(r.n),input:num(r.i),output:num(r.o),cache:num(r.c),cost:num(r.cost)})),byDay:Array.from({length:Math.max(1,Math.ceil(days))},(_,k)=>{let key=iso(start+k*86400000);return byDate.get(key)??{date:key,sessions:0,cost:0}}),byTool:tools.map((r)=>({name:String(r.name),n:num(r.n)})),bySource:sources.map((r)=>({name:String(r.name),n:num(r.n)}))}}var ZERO,num=(v)=>Number(v)||0,iso=(t)=>{let d=new Date(t),p=(n)=>String(n).padStart(2,"0");return`${d.getFullYear()}-${p(d.getMonth()+1)}-${p(d.getDate())}`},COST="COALESCE(actual_cost_usd, estimated_cost_usd, 0)",CACHE="COALESCE(cache_read_tokens,0)+COALESCE(cache_write_tokens,0)",cache;var init_hermes_analytics=__esm(()=>{init_sessions_db();ZERO={total:{sessions:0,messages:0,input:0,output:0,cache:0,cost:0,calls:0},byModel:[],byDay:[],byTool:[],bySource:[]},cache=new Map});function readMemoryActivity(limit=100,scan=2000){let db=stateDb();if(!db)return[];let rows=db.query(`SELECT m.timestamp ts, m.tool_calls, m.session_id,
|
|
78
|
+
s.title
|
|
79
|
+
FROM messages m LEFT JOIN sessions s ON m.session_id = s.id
|
|
80
|
+
WHERE m.role = 'assistant' AND m.tool_calls IS NOT NULL
|
|
81
|
+
ORDER BY m.id DESC LIMIT ?`).all(scan),out=[];for(let r of rows)for(let a of extract(r))if(out.push(a),out.length>=limit)return out;return out}var WRITE,READ,MEMORY_TOOLS,trunc=(s,n=80)=>{let t=String(s??"").replace(/\s+/g," ").trim();return t.length>n?t.slice(0,n-1)+"\u2026":t},stripPrefix=(name)=>name.replace(/^(mem0|honcho|hindsight|viking|retaindb|supermemory|brv|fact)_/,""),describe=(name,args)=>{if(name==="memory"){let action=String(args.action??""),target=String(args.target??""),body=action==="remove"?args.old_text:args.content??args.old_text;return{verb:action,summary:`${target}: ${trunc(body)}`}}let verb=stripPrefix(name);for(let k of["conclusion","content","query","text","fact","question","note","path"])if(k in args)return{verb,summary:trunc(args[k])};let first=Object.values(args).find((v)=>typeof v==="string");return{verb,summary:trunc(first??"")}},extract=(r)=>{let calls;try{calls=JSON.parse(r.tool_calls)}catch{return[]}if(!Array.isArray(calls))return[];let out=[];for(let c of calls){let name=c.function?.name;if(!name||!(name in MEMORY_TOOLS))continue;let args={};try{args=JSON.parse(c.function?.arguments??"{}")}catch{}let{verb,summary}=describe(name,args);out.push({ts:r.ts,provider:MEMORY_TOOLS[name],tool:name,op:name in WRITE?"write":"read",verb,summary,sessionId:r.session_id,sessionTitle:r.title??r.session_id})}return out};var init_memory_activity=__esm(()=>{init_sessions_db();WRITE={memory:"builtin",mem0_conclude:"mem0",honcho_conclude:"honcho",hindsight_retain:"hindsight",hindsight_reflect:"hindsight",fact_store:"holographic",fact_feedback:"holographic",viking_remember:"openviking",viking_add_resource:"openviking",retaindb_remember:"retaindb",retaindb_forget:"retaindb",supermemory_store:"supermemory",supermemory_forget:"supermemory",brv_curate:"byterover"},READ={mem0_search:"mem0",mem0_profile:"mem0",honcho_search:"honcho",honcho_profile:"honcho",honcho_reasoning:"honcho",honcho_context:"honcho",hindsight_recall:"hindsight",viking_search:"openviking",viking_read:"openviking",viking_browse:"openviking",retaindb_search:"retaindb",retaindb_profile:"retaindb",retaindb_context:"retaindb",supermemory_search:"supermemory",supermemory_profile:"supermemory",brv_query:"byterover",brv_status:"byterover"},MEMORY_TOOLS={...WRITE,...READ}});var exports_fns={};__export(exports_fns,{FNS:()=>FNS});var FNS;var init_fns=__esm(()=>{init_sessions_db();init_hermes_analytics();init_memory_activity();FNS={roots,children,lineage,peek,search,systemPrompt,goalState,analytics,memoryActivity:readMemoryActivity}});init_sessions_db();init_fns();var bound={home:""};self.onmessage=(e)=>{let{id,home,fn,args}=e.data;if(bound.home!==home)setHome(home),bound.home=home;let f=FNS[fn];if(!f)return self.postMessage({id,ok:!1,err:`io: unknown fn '${fn}'`});try{self.postMessage({id,ok:!0,v:f(...args)})}catch(e2){self.postMessage({id,ok:!1,err:e2.message})}};
|
|
@@ -0,0 +1,604 @@
|
|
|
1
|
+
; Query from: https://raw.githubusercontent.com/nvim-treesitter/nvim-treesitter/refs/heads/master/queries/ecma/highlights.scm
|
|
2
|
+
; Types
|
|
3
|
+
; Javascript
|
|
4
|
+
; Variables
|
|
5
|
+
;-----------
|
|
6
|
+
(identifier) @variable
|
|
7
|
+
|
|
8
|
+
; Properties
|
|
9
|
+
;-----------
|
|
10
|
+
(property_identifier) @variable.member
|
|
11
|
+
|
|
12
|
+
(shorthand_property_identifier) @variable.member
|
|
13
|
+
|
|
14
|
+
(private_property_identifier) @variable.member
|
|
15
|
+
|
|
16
|
+
(object_pattern
|
|
17
|
+
(shorthand_property_identifier_pattern) @variable)
|
|
18
|
+
|
|
19
|
+
(object_pattern
|
|
20
|
+
(object_assignment_pattern
|
|
21
|
+
(shorthand_property_identifier_pattern) @variable))
|
|
22
|
+
|
|
23
|
+
; Special identifiers
|
|
24
|
+
;--------------------
|
|
25
|
+
((identifier) @type
|
|
26
|
+
(#lua-match? @type "^[A-Z]"))
|
|
27
|
+
|
|
28
|
+
((identifier) @constant
|
|
29
|
+
(#lua-match? @constant "^_*[A-Z][A-Z%d_]*$"))
|
|
30
|
+
|
|
31
|
+
((shorthand_property_identifier) @constant
|
|
32
|
+
(#lua-match? @constant "^_*[A-Z][A-Z%d_]*$"))
|
|
33
|
+
|
|
34
|
+
((identifier) @variable.builtin
|
|
35
|
+
(#any-of? @variable.builtin "arguments" "module" "console" "window" "document"))
|
|
36
|
+
|
|
37
|
+
((identifier) @type.builtin
|
|
38
|
+
(#any-of? @type.builtin
|
|
39
|
+
"Object" "Function" "Boolean" "Symbol" "Number" "Math" "Date" "String" "RegExp" "Map" "Set"
|
|
40
|
+
"WeakMap" "WeakSet" "Promise" "Array" "Int8Array" "Uint8Array" "Uint8ClampedArray" "Int16Array"
|
|
41
|
+
"Uint16Array" "Int32Array" "Uint32Array" "Float32Array" "Float64Array" "ArrayBuffer" "DataView"
|
|
42
|
+
"Error" "EvalError" "InternalError" "RangeError" "ReferenceError" "SyntaxError" "TypeError"
|
|
43
|
+
"URIError"))
|
|
44
|
+
|
|
45
|
+
(statement_identifier) @label
|
|
46
|
+
|
|
47
|
+
; Function and method definitions
|
|
48
|
+
;--------------------------------
|
|
49
|
+
(function_expression
|
|
50
|
+
name: (identifier) @function)
|
|
51
|
+
|
|
52
|
+
(function_declaration
|
|
53
|
+
name: (identifier) @function)
|
|
54
|
+
|
|
55
|
+
(generator_function
|
|
56
|
+
name: (identifier) @function)
|
|
57
|
+
|
|
58
|
+
(generator_function_declaration
|
|
59
|
+
name: (identifier) @function)
|
|
60
|
+
|
|
61
|
+
(method_definition
|
|
62
|
+
name: [
|
|
63
|
+
(property_identifier)
|
|
64
|
+
(private_property_identifier)
|
|
65
|
+
] @function.method)
|
|
66
|
+
|
|
67
|
+
(method_definition
|
|
68
|
+
name: (property_identifier) @constructor
|
|
69
|
+
(#eq? @constructor "constructor"))
|
|
70
|
+
|
|
71
|
+
(pair
|
|
72
|
+
key: (property_identifier) @function.method
|
|
73
|
+
value: (function_expression))
|
|
74
|
+
|
|
75
|
+
(pair
|
|
76
|
+
key: (property_identifier) @function.method
|
|
77
|
+
value: (arrow_function))
|
|
78
|
+
|
|
79
|
+
(assignment_expression
|
|
80
|
+
left: (member_expression
|
|
81
|
+
property: (property_identifier) @function.method)
|
|
82
|
+
right: (arrow_function))
|
|
83
|
+
|
|
84
|
+
(assignment_expression
|
|
85
|
+
left: (member_expression
|
|
86
|
+
property: (property_identifier) @function.method)
|
|
87
|
+
right: (function_expression))
|
|
88
|
+
|
|
89
|
+
(variable_declarator
|
|
90
|
+
name: (identifier) @function
|
|
91
|
+
value: (arrow_function))
|
|
92
|
+
|
|
93
|
+
(variable_declarator
|
|
94
|
+
name: (identifier) @function
|
|
95
|
+
value: (function_expression))
|
|
96
|
+
|
|
97
|
+
(assignment_expression
|
|
98
|
+
left: (identifier) @function
|
|
99
|
+
right: (arrow_function))
|
|
100
|
+
|
|
101
|
+
(assignment_expression
|
|
102
|
+
left: (identifier) @function
|
|
103
|
+
right: (function_expression))
|
|
104
|
+
|
|
105
|
+
; Function and method calls
|
|
106
|
+
;--------------------------
|
|
107
|
+
(call_expression
|
|
108
|
+
function: (identifier) @function.call)
|
|
109
|
+
|
|
110
|
+
(call_expression
|
|
111
|
+
function: (member_expression
|
|
112
|
+
property: [
|
|
113
|
+
(property_identifier)
|
|
114
|
+
(private_property_identifier)
|
|
115
|
+
] @function.method.call))
|
|
116
|
+
|
|
117
|
+
(call_expression
|
|
118
|
+
function: (await_expression
|
|
119
|
+
(identifier) @function.call))
|
|
120
|
+
|
|
121
|
+
(call_expression
|
|
122
|
+
function: (await_expression
|
|
123
|
+
(member_expression
|
|
124
|
+
property: [
|
|
125
|
+
(property_identifier)
|
|
126
|
+
(private_property_identifier)
|
|
127
|
+
] @function.method.call)))
|
|
128
|
+
|
|
129
|
+
; Builtins
|
|
130
|
+
;---------
|
|
131
|
+
((identifier) @module.builtin
|
|
132
|
+
(#eq? @module.builtin "Intl"))
|
|
133
|
+
|
|
134
|
+
((identifier) @function.builtin
|
|
135
|
+
(#any-of? @function.builtin
|
|
136
|
+
"eval" "isFinite" "isNaN" "parseFloat" "parseInt" "decodeURI" "decodeURIComponent" "encodeURI"
|
|
137
|
+
"encodeURIComponent" "require"))
|
|
138
|
+
|
|
139
|
+
; Constructor
|
|
140
|
+
;------------
|
|
141
|
+
(new_expression
|
|
142
|
+
constructor: (identifier) @constructor)
|
|
143
|
+
|
|
144
|
+
; Decorators
|
|
145
|
+
;----------
|
|
146
|
+
(decorator
|
|
147
|
+
"@" @attribute
|
|
148
|
+
(identifier) @attribute)
|
|
149
|
+
|
|
150
|
+
(decorator
|
|
151
|
+
"@" @attribute
|
|
152
|
+
(call_expression
|
|
153
|
+
(identifier) @attribute))
|
|
154
|
+
|
|
155
|
+
(decorator
|
|
156
|
+
"@" @attribute
|
|
157
|
+
(member_expression
|
|
158
|
+
(property_identifier) @attribute))
|
|
159
|
+
|
|
160
|
+
(decorator
|
|
161
|
+
"@" @attribute
|
|
162
|
+
(call_expression
|
|
163
|
+
(member_expression
|
|
164
|
+
(property_identifier) @attribute)))
|
|
165
|
+
|
|
166
|
+
; Literals
|
|
167
|
+
;---------
|
|
168
|
+
[
|
|
169
|
+
(this)
|
|
170
|
+
(super)
|
|
171
|
+
] @variable.builtin
|
|
172
|
+
|
|
173
|
+
((identifier) @variable.builtin
|
|
174
|
+
(#eq? @variable.builtin "self"))
|
|
175
|
+
|
|
176
|
+
[
|
|
177
|
+
(true)
|
|
178
|
+
(false)
|
|
179
|
+
] @boolean
|
|
180
|
+
|
|
181
|
+
[
|
|
182
|
+
(null)
|
|
183
|
+
(undefined)
|
|
184
|
+
] @constant.builtin
|
|
185
|
+
|
|
186
|
+
[
|
|
187
|
+
(comment)
|
|
188
|
+
(html_comment)
|
|
189
|
+
] @comment @spell
|
|
190
|
+
|
|
191
|
+
((comment) @comment.documentation
|
|
192
|
+
(#lua-match? @comment.documentation "^/[*][*][^*].*[*]/$"))
|
|
193
|
+
|
|
194
|
+
(hash_bang_line) @keyword.directive
|
|
195
|
+
|
|
196
|
+
((string_fragment) @keyword.directive
|
|
197
|
+
(#eq? @keyword.directive "use strict"))
|
|
198
|
+
|
|
199
|
+
(string) @string
|
|
200
|
+
|
|
201
|
+
(template_string) @string
|
|
202
|
+
|
|
203
|
+
(escape_sequence) @string.escape
|
|
204
|
+
|
|
205
|
+
(regex_pattern) @string.regexp
|
|
206
|
+
|
|
207
|
+
(regex_flags) @character.special
|
|
208
|
+
|
|
209
|
+
(regex
|
|
210
|
+
"/" @punctuation.bracket) ; Regex delimiters
|
|
211
|
+
|
|
212
|
+
(number) @number
|
|
213
|
+
|
|
214
|
+
((identifier) @number
|
|
215
|
+
(#any-of? @number "NaN" "Infinity"))
|
|
216
|
+
|
|
217
|
+
; Punctuation
|
|
218
|
+
;------------
|
|
219
|
+
[
|
|
220
|
+
";"
|
|
221
|
+
"."
|
|
222
|
+
","
|
|
223
|
+
":"
|
|
224
|
+
] @punctuation.delimiter
|
|
225
|
+
|
|
226
|
+
[
|
|
227
|
+
"--"
|
|
228
|
+
"-"
|
|
229
|
+
"-="
|
|
230
|
+
"&&"
|
|
231
|
+
"+"
|
|
232
|
+
"++"
|
|
233
|
+
"+="
|
|
234
|
+
"&="
|
|
235
|
+
"/="
|
|
236
|
+
"**="
|
|
237
|
+
"<<="
|
|
238
|
+
"<"
|
|
239
|
+
"<="
|
|
240
|
+
"<<"
|
|
241
|
+
"="
|
|
242
|
+
"=="
|
|
243
|
+
"==="
|
|
244
|
+
"!="
|
|
245
|
+
"!=="
|
|
246
|
+
"=>"
|
|
247
|
+
">"
|
|
248
|
+
">="
|
|
249
|
+
">>"
|
|
250
|
+
"||"
|
|
251
|
+
"%"
|
|
252
|
+
"%="
|
|
253
|
+
"*"
|
|
254
|
+
"**"
|
|
255
|
+
">>>"
|
|
256
|
+
"&"
|
|
257
|
+
"|"
|
|
258
|
+
"^"
|
|
259
|
+
"??"
|
|
260
|
+
"*="
|
|
261
|
+
">>="
|
|
262
|
+
">>>="
|
|
263
|
+
"^="
|
|
264
|
+
"|="
|
|
265
|
+
"&&="
|
|
266
|
+
"||="
|
|
267
|
+
"??="
|
|
268
|
+
"..."
|
|
269
|
+
] @operator
|
|
270
|
+
|
|
271
|
+
(binary_expression
|
|
272
|
+
"/" @operator)
|
|
273
|
+
|
|
274
|
+
(ternary_expression
|
|
275
|
+
[
|
|
276
|
+
"?"
|
|
277
|
+
":"
|
|
278
|
+
] @keyword.conditional.ternary)
|
|
279
|
+
|
|
280
|
+
(unary_expression
|
|
281
|
+
[
|
|
282
|
+
"!"
|
|
283
|
+
"~"
|
|
284
|
+
"-"
|
|
285
|
+
"+"
|
|
286
|
+
] @operator)
|
|
287
|
+
|
|
288
|
+
(unary_expression
|
|
289
|
+
[
|
|
290
|
+
"delete"
|
|
291
|
+
"void"
|
|
292
|
+
] @keyword.operator)
|
|
293
|
+
|
|
294
|
+
[
|
|
295
|
+
"("
|
|
296
|
+
")"
|
|
297
|
+
"["
|
|
298
|
+
"]"
|
|
299
|
+
"{"
|
|
300
|
+
"}"
|
|
301
|
+
] @punctuation.bracket
|
|
302
|
+
|
|
303
|
+
(template_substitution
|
|
304
|
+
[
|
|
305
|
+
"${"
|
|
306
|
+
"}"
|
|
307
|
+
] @punctuation.special) @none
|
|
308
|
+
|
|
309
|
+
; Imports
|
|
310
|
+
;----------
|
|
311
|
+
(namespace_import
|
|
312
|
+
"*" @character.special
|
|
313
|
+
(identifier) @module)
|
|
314
|
+
|
|
315
|
+
(namespace_export
|
|
316
|
+
"*" @character.special
|
|
317
|
+
(identifier) @module)
|
|
318
|
+
|
|
319
|
+
(export_statement
|
|
320
|
+
"*" @character.special)
|
|
321
|
+
|
|
322
|
+
; Keywords
|
|
323
|
+
;----------
|
|
324
|
+
[
|
|
325
|
+
"if"
|
|
326
|
+
"else"
|
|
327
|
+
"switch"
|
|
328
|
+
"case"
|
|
329
|
+
] @keyword.conditional
|
|
330
|
+
|
|
331
|
+
[
|
|
332
|
+
"import"
|
|
333
|
+
"from"
|
|
334
|
+
"as"
|
|
335
|
+
"export"
|
|
336
|
+
] @keyword.import
|
|
337
|
+
|
|
338
|
+
[
|
|
339
|
+
"for"
|
|
340
|
+
"of"
|
|
341
|
+
"do"
|
|
342
|
+
"while"
|
|
343
|
+
"continue"
|
|
344
|
+
] @keyword.repeat
|
|
345
|
+
|
|
346
|
+
[
|
|
347
|
+
"break"
|
|
348
|
+
"const"
|
|
349
|
+
"debugger"
|
|
350
|
+
"extends"
|
|
351
|
+
"get"
|
|
352
|
+
"let"
|
|
353
|
+
"set"
|
|
354
|
+
"static"
|
|
355
|
+
"target"
|
|
356
|
+
"var"
|
|
357
|
+
"with"
|
|
358
|
+
] @keyword
|
|
359
|
+
|
|
360
|
+
"class" @keyword.type
|
|
361
|
+
|
|
362
|
+
[
|
|
363
|
+
"async"
|
|
364
|
+
"await"
|
|
365
|
+
] @keyword.coroutine
|
|
366
|
+
|
|
367
|
+
[
|
|
368
|
+
"return"
|
|
369
|
+
"yield"
|
|
370
|
+
] @keyword.return
|
|
371
|
+
|
|
372
|
+
"function" @keyword.function
|
|
373
|
+
|
|
374
|
+
[
|
|
375
|
+
"new"
|
|
376
|
+
"delete"
|
|
377
|
+
"in"
|
|
378
|
+
"instanceof"
|
|
379
|
+
"typeof"
|
|
380
|
+
] @keyword.operator
|
|
381
|
+
|
|
382
|
+
[
|
|
383
|
+
"throw"
|
|
384
|
+
"try"
|
|
385
|
+
"catch"
|
|
386
|
+
"finally"
|
|
387
|
+
] @keyword.exception
|
|
388
|
+
|
|
389
|
+
(export_statement
|
|
390
|
+
"default" @keyword)
|
|
391
|
+
|
|
392
|
+
(switch_default
|
|
393
|
+
"default" @keyword.conditional)
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
; Query from: https://raw.githubusercontent.com/nvim-treesitter/nvim-treesitter/refs/heads/master/queries/typescript/highlights.scm
|
|
397
|
+
; inherits: ecma
|
|
398
|
+
|
|
399
|
+
"require" @keyword.import
|
|
400
|
+
|
|
401
|
+
(import_require_clause
|
|
402
|
+
source: (string) @string.special.url)
|
|
403
|
+
|
|
404
|
+
[
|
|
405
|
+
"declare"
|
|
406
|
+
"implements"
|
|
407
|
+
"type"
|
|
408
|
+
"override"
|
|
409
|
+
"module"
|
|
410
|
+
"asserts"
|
|
411
|
+
"infer"
|
|
412
|
+
"is"
|
|
413
|
+
"using"
|
|
414
|
+
] @keyword
|
|
415
|
+
|
|
416
|
+
[
|
|
417
|
+
"namespace"
|
|
418
|
+
"interface"
|
|
419
|
+
"enum"
|
|
420
|
+
] @keyword.type
|
|
421
|
+
|
|
422
|
+
[
|
|
423
|
+
"keyof"
|
|
424
|
+
"satisfies"
|
|
425
|
+
] @keyword.operator
|
|
426
|
+
|
|
427
|
+
(as_expression
|
|
428
|
+
"as" @keyword.operator)
|
|
429
|
+
|
|
430
|
+
(mapped_type_clause
|
|
431
|
+
"as" @keyword.operator)
|
|
432
|
+
|
|
433
|
+
[
|
|
434
|
+
"abstract"
|
|
435
|
+
"private"
|
|
436
|
+
"protected"
|
|
437
|
+
"public"
|
|
438
|
+
"readonly"
|
|
439
|
+
] @keyword.modifier
|
|
440
|
+
|
|
441
|
+
; types
|
|
442
|
+
(type_identifier) @type
|
|
443
|
+
|
|
444
|
+
(predefined_type) @type.builtin
|
|
445
|
+
|
|
446
|
+
(import_statement
|
|
447
|
+
"type"
|
|
448
|
+
(import_clause
|
|
449
|
+
(named_imports
|
|
450
|
+
(import_specifier
|
|
451
|
+
name: (identifier) @type))))
|
|
452
|
+
|
|
453
|
+
(template_literal_type) @string
|
|
454
|
+
|
|
455
|
+
(non_null_expression
|
|
456
|
+
"!" @operator)
|
|
457
|
+
|
|
458
|
+
; punctuation
|
|
459
|
+
(type_arguments
|
|
460
|
+
[
|
|
461
|
+
"<"
|
|
462
|
+
">"
|
|
463
|
+
] @punctuation.bracket)
|
|
464
|
+
|
|
465
|
+
(type_parameters
|
|
466
|
+
[
|
|
467
|
+
"<"
|
|
468
|
+
">"
|
|
469
|
+
] @punctuation.bracket)
|
|
470
|
+
|
|
471
|
+
(object_type
|
|
472
|
+
[
|
|
473
|
+
"{|"
|
|
474
|
+
"|}"
|
|
475
|
+
] @punctuation.bracket)
|
|
476
|
+
|
|
477
|
+
(union_type
|
|
478
|
+
"|" @punctuation.delimiter)
|
|
479
|
+
|
|
480
|
+
(intersection_type
|
|
481
|
+
"&" @punctuation.delimiter)
|
|
482
|
+
|
|
483
|
+
(type_annotation
|
|
484
|
+
":" @punctuation.delimiter)
|
|
485
|
+
|
|
486
|
+
(type_predicate_annotation
|
|
487
|
+
":" @punctuation.delimiter)
|
|
488
|
+
|
|
489
|
+
(index_signature
|
|
490
|
+
":" @punctuation.delimiter)
|
|
491
|
+
|
|
492
|
+
(omitting_type_annotation
|
|
493
|
+
"-?:" @punctuation.delimiter)
|
|
494
|
+
|
|
495
|
+
(adding_type_annotation
|
|
496
|
+
"+?:" @punctuation.delimiter)
|
|
497
|
+
|
|
498
|
+
(opting_type_annotation
|
|
499
|
+
"?:" @punctuation.delimiter)
|
|
500
|
+
|
|
501
|
+
"?." @punctuation.delimiter
|
|
502
|
+
|
|
503
|
+
(abstract_method_signature
|
|
504
|
+
"?" @punctuation.special)
|
|
505
|
+
|
|
506
|
+
(method_signature
|
|
507
|
+
"?" @punctuation.special)
|
|
508
|
+
|
|
509
|
+
(method_definition
|
|
510
|
+
"?" @punctuation.special)
|
|
511
|
+
|
|
512
|
+
(property_signature
|
|
513
|
+
"?" @punctuation.special)
|
|
514
|
+
|
|
515
|
+
(optional_parameter
|
|
516
|
+
"?" @punctuation.special)
|
|
517
|
+
|
|
518
|
+
(optional_type
|
|
519
|
+
"?" @punctuation.special)
|
|
520
|
+
|
|
521
|
+
(public_field_definition
|
|
522
|
+
[
|
|
523
|
+
"?"
|
|
524
|
+
"!"
|
|
525
|
+
] @punctuation.special)
|
|
526
|
+
|
|
527
|
+
(flow_maybe_type
|
|
528
|
+
"?" @punctuation.special)
|
|
529
|
+
|
|
530
|
+
(template_type
|
|
531
|
+
[
|
|
532
|
+
"${"
|
|
533
|
+
"}"
|
|
534
|
+
] @punctuation.special)
|
|
535
|
+
|
|
536
|
+
(conditional_type
|
|
537
|
+
[
|
|
538
|
+
"?"
|
|
539
|
+
":"
|
|
540
|
+
] @keyword.conditional.ternary)
|
|
541
|
+
|
|
542
|
+
; Parameters
|
|
543
|
+
(required_parameter
|
|
544
|
+
pattern: (identifier) @variable.parameter)
|
|
545
|
+
|
|
546
|
+
(optional_parameter
|
|
547
|
+
pattern: (identifier) @variable.parameter)
|
|
548
|
+
|
|
549
|
+
(required_parameter
|
|
550
|
+
(rest_pattern
|
|
551
|
+
(identifier) @variable.parameter))
|
|
552
|
+
|
|
553
|
+
; ({ a }) => null
|
|
554
|
+
(required_parameter
|
|
555
|
+
(object_pattern
|
|
556
|
+
(shorthand_property_identifier_pattern) @variable.parameter))
|
|
557
|
+
|
|
558
|
+
; ({ a = b }) => null
|
|
559
|
+
(required_parameter
|
|
560
|
+
(object_pattern
|
|
561
|
+
(object_assignment_pattern
|
|
562
|
+
(shorthand_property_identifier_pattern) @variable.parameter)))
|
|
563
|
+
|
|
564
|
+
; ({ a: b }) => null
|
|
565
|
+
(required_parameter
|
|
566
|
+
(object_pattern
|
|
567
|
+
(pair_pattern
|
|
568
|
+
value: (identifier) @variable.parameter)))
|
|
569
|
+
|
|
570
|
+
; ([ a ]) => null
|
|
571
|
+
(required_parameter
|
|
572
|
+
(array_pattern
|
|
573
|
+
(identifier) @variable.parameter))
|
|
574
|
+
|
|
575
|
+
; a => null
|
|
576
|
+
(arrow_function
|
|
577
|
+
parameter: (identifier) @variable.parameter)
|
|
578
|
+
|
|
579
|
+
; global declaration
|
|
580
|
+
(ambient_declaration
|
|
581
|
+
"global" @module)
|
|
582
|
+
|
|
583
|
+
; function signatures
|
|
584
|
+
(ambient_declaration
|
|
585
|
+
(function_signature
|
|
586
|
+
name: (identifier) @function))
|
|
587
|
+
|
|
588
|
+
; method signatures
|
|
589
|
+
(method_signature
|
|
590
|
+
name: (_) @function.method)
|
|
591
|
+
|
|
592
|
+
(abstract_method_signature
|
|
593
|
+
name: (property_identifier) @function.method)
|
|
594
|
+
|
|
595
|
+
; property signatures
|
|
596
|
+
(property_signature
|
|
597
|
+
name: (property_identifier) @function.method
|
|
598
|
+
type: (type_annotation
|
|
599
|
+
[
|
|
600
|
+
(union_type
|
|
601
|
+
(parenthesized_type
|
|
602
|
+
(function_type)))
|
|
603
|
+
(function_type)
|
|
604
|
+
]))
|