herm-tui 1.7.2 → 1.8.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/assets/skills/eikon-create/SKILL.md +10 -6
- package/db.worker.js +6 -5
- package/index.js +39 -38
- package/package.json +1 -1
|
@@ -66,12 +66,14 @@ Call `image_generate` with the subject on line 1 and the fixed suffix
|
|
|
66
66
|
on line 2 — same suffix Studio seeds:
|
|
67
67
|
|
|
68
68
|
```
|
|
69
|
-
<subject
|
|
69
|
+
<subject>, close-up portrait emphasizing the face/head, looking slightly left, stark black and white, bold silhouette, simple uncluttered shape
|
|
70
70
|
high contrast, light subject on dark, black background
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
Keep this general: replace `face/head` with the subject's most readable
|
|
74
|
+
feature if it is not a character or creature. Prefer square if the tool
|
|
75
|
+
takes `aspect_ratio`; if it doesn't, don't worry — Studio crops. Show
|
|
76
|
+
the result inline with ``
|
|
75
77
|
and a 48-wide terminal preview:
|
|
76
78
|
|
|
77
79
|
```bash
|
|
@@ -79,9 +81,11 @@ chafa --size=48x24 --symbols=braille --colors=none --format=symbols --stretch "<
|
|
|
79
81
|
```
|
|
80
82
|
|
|
81
83
|
Ask: **keep, regenerate, or adjust?** On adjust, fold their note into
|
|
82
|
-
the subject line (leave the suffix alone). Loop.
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
the subject line (leave the suffix alone). Loop. **Always overwrite the
|
|
85
|
+
same `<state>.<ext>` in `source/` on every iteration** — Studio reads
|
|
86
|
+
that path live, so a new candidate that lives only in cache is invisible
|
|
87
|
+
to the user. If two rounds fail on background clutter, silently append
|
|
88
|
+
`, isolated on pure black, no floor, no environment` and try again.
|
|
85
89
|
|
|
86
90
|
### 3. Adopt
|
|
87
91
|
|
package/db.worker.js
CHANGED
|
@@ -22,11 +22,12 @@ var __create=Object.create;var{getPrototypeOf:__getProtoOf,defineProperty:__defP
|
|
|
22
22
|
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
|
|
23
23
|
JOIN sessions p ON p.id = c.parent_session_id
|
|
24
24
|
WHERE p.id = ? AND ${CONT("c")}
|
|
25
|
-
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
|
|
26
|
-
SUBSTR(tool_calls,1,400) AS tool_calls, timestamp AS at
|
|
25
|
+
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{let ext=[hasMsgCol("platform_message_id")?"platform_message_id":"NULL AS platform_message_id",hasMsgCol("observed")?"observed":"NULL AS observed"];return(q(`SELECT role, SUBSTR(content,1,400) AS content, tool_name,
|
|
26
|
+
SUBSTR(tool_calls,1,400) AS tool_calls, timestamp AS at,
|
|
27
|
+
${ext.join(", ")}
|
|
27
28
|
FROM (SELECT * FROM messages WHERE session_id = ?
|
|
28
29
|
ORDER BY id DESC LIMIT ?)
|
|
29
|
-
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),checklist=(Array.isArray(j.checklist)?j.checklist:[]).map(parseItem).filter((x)=>x!==null),subgoals=(Array.isArray(j.subgoals)?j.subgoals:[]).map((s)=>typeof s==="string"?s.trim():"").filter((s)=>s.length>0);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,checklist:checklist.length>0?checklist:void 0,subgoals:subgoals.length>0?subgoals:void 0,decomposed:j.decomposed===!0?!0:void 0}}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,
|
|
30
|
+
ORDER BY id ASC`)?.all(sid,n)??[]).map((r)=>({role:r.role,content:r.content,tool_name:r.tool_name,tool_calls:r.tool_calls,...r.platform_message_id!==null&&{platform_message_id:r.platform_message_id},...r.observed!==null&&{observed:r.observed},at:r.at}))}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),checklist=(Array.isArray(j.checklist)?j.checklist:[]).map(parseItem).filter((x)=>x!==null),subgoals=(Array.isArray(j.subgoals)?j.subgoals:[]).map((s)=>typeof s==="string"?s.trim():"").filter((s)=>s.length>0);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,checklist:checklist.length>0?checklist:void 0,subgoals:subgoals.length>0?subgoals:void 0,decomposed:j.decomposed===!0?!0:void 0}}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,
|
|
30
31
|
snippet(messages_fts, 0, '>>>', '<<<', '...', 40) AS snippet,
|
|
31
32
|
s.source, s.model, s.started_at,
|
|
32
33
|
COALESCE(s.title, SUBSTR(m.content, 1, 120)) AS title
|
|
@@ -34,7 +35,7 @@ var __create=Object.create;var{getPrototypeOf:__getProtoOf,defineProperty:__defP
|
|
|
34
35
|
JOIN messages m ON m.id = messages_fts.rowid
|
|
35
36
|
JOIN sessions s ON s.id = m.session_id
|
|
36
37
|
WHERE messages_fts MATCH ?
|
|
37
|
-
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,{readwrite:!0,create:!1})}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)`,kind=(parent,child)=>{if(!parent)return"root";if(parent.ended_at==null||child.started_at<parent.ended_at)return"subagent";if(parent.end_reason==="compression")return"continuation";if(parent.end_reason==="branched")return"branch";return"subagent"},COLS=`
|
|
38
|
+
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,{readwrite:!0,create:!1})}catch{return null}},resetDb=()=>{for(let s of stmts.values())s.finalize();stmts.clear(),msgCols.clear(),conn.ro?.close(),conn.ro=null},stmts,msgCols,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},hasMsgCol=(name)=>{let hit=msgCols.get(name);if(hit!==void 0)return hit;let db=stateDb(),ok=db?db.query("PRAGMA table_info(messages)").all().some((r)=>r.name===name):!1;return msgCols.set(name,ok),ok},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)`,kind=(parent,child)=>{if(!parent)return"root";if(parent.ended_at==null||child.started_at<parent.ended_at)return"subagent";if(parent.end_reason==="compression")return"continuation";if(parent.end_reason==="branched")return"branch";return"subagent"},COLS=`
|
|
38
39
|
s.id, s.source, s.model, s.billing_provider, s.started_at, s.ended_at, s.end_reason,
|
|
39
40
|
s.message_count, s.tool_call_count,
|
|
40
41
|
s.input_tokens, s.output_tokens,
|
|
@@ -56,7 +57,7 @@ var __create=Object.create;var{getPrototypeOf:__getProtoOf,defineProperty:__defP
|
|
|
56
57
|
ORDER BY s.started_at DESC LIMIT 1
|
|
57
58
|
`)?.get();if(!hit)return;let row=byId(chainTip(hit.id));return row&&row.message_count>0?row:void 0},chainTip=(sid)=>tip(walkUp(sid)),systemPrompt=()=>q(`SELECT id, system_prompt AS text FROM sessions
|
|
58
59
|
WHERE system_prompt IS NOT NULL AND length(system_prompt) > 1000
|
|
59
|
-
ORDER BY started_at DESC LIMIT 1`)?.get()??null,VALID_ITEM,parseItem=(raw)=>{if(!raw||typeof raw!=="object")return null;let o=raw,text=typeof o.text==="string"?o.text:"";if(!text.trim())return null;let s=typeof o.status==="string"?o.status:"pending",status=VALID_ITEM.has(s)?s:"pending",by=typeof o.added_by==="string"?o.added_by:void 0;return{text,status,addedBy:by==="judge"||by==="user"?by:void 0}},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();init_sessions_db();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;VALID_ITEM=new Set(["pending","completed","impossible"])});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,
|
|
60
|
+
ORDER BY started_at DESC LIMIT 1`)?.get()??null,VALID_ITEM,parseItem=(raw)=>{if(!raw||typeof raw!=="object")return null;let o=raw,text=typeof o.text==="string"?o.text:"";if(!text.trim())return null;let s=typeof o.status==="string"?o.status:"pending",status=VALID_ITEM.has(s)?s:"pending",by=typeof o.added_by==="string"?o.added_by:void 0;return{text,status,addedBy:by==="judge"||by==="user"?by:void 0}},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();init_sessions_db();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,msgCols=new Map;VALID_ITEM=new Set(["pending","completed","impossible"])});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,
|
|
60
61
|
COALESCE(SUM(message_count),0) msgs,
|
|
61
62
|
COALESCE(SUM(input_tokens),0) i,
|
|
62
63
|
COALESCE(SUM(output_tokens),0) o,
|