devcoach 2.5.0-next.582.gd935e57 → 2.5.0-next.584.g7ebb2db
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/dist/{app-PFGHB3PE.js → app-HTTMWUAK.js} +1 -1
- package/dist/bin.js +1 -1
- package/dist/{chunk-OLKQYTMC.js → chunk-2M2WL7AV.js} +1 -1
- package/dist/{chunk-MVDKK7RW.js → chunk-U2NGRAGG.js} +1 -1
- package/dist/{chunk-VPUTO5QR.js → chunk-X67QSFUJ.js} +1 -1
- package/dist/{commands-JFHFSPIQ.js → commands-PHJYK5IR.js} +2 -2
- package/dist/{hooks-5IK3BMOS.js → hooks-IMABB42H.js} +1 -1
- package/dist/{server-3B2HXDTX.js → server-HOCQWBJF.js} +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {a as a$1,c}from'./chunk-QU6UQJWC.js';import {p,q,h as h$1,m,a,e,g,j as j$1,l,n as n$1}from'./chunk-
|
|
2
|
+
import {a as a$1,c}from'./chunk-QU6UQJWC.js';import {p,q,h as h$1,m,a,e,g,j as j$1,l,n as n$1}from'./chunk-U2NGRAGG.js';import {ha,u,w,N,sa,wa,ta,H,L as L$1,I,M,ua,J as J$1,K as K$1,B as B$1,xa,ia,ma,D,C,F,x,A,va,z,E,O,s,ra,qa,ea,ga,n,ka,ja,la,oa,na}from'./chunk-2M2WL7AV.js';import {existsSync,readFileSync,mkdirSync,writeFileSync}from'fs';import {dirname,join,extname}from'path';import {fileURLToPath}from'url';import {serve}from'@hono/node-server';import {Hono}from'hono';import {html,raw}from'hono/html';function j(t){return JSON.stringify(t??"").replace(/[<>&\u2028\u2029]/g,e=>String.raw`\u`+(e.codePointAt(0)??0).toString(16).padStart(4,"0"))}function Ge(t,e){return t+e.replace(/[^A-Za-z0-9_-]/g,g=>`_${(g.codePointAt(0)??0).toString(16)}`)}var rt=html`<svg class="w-4 h-4" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><circle cx="4" cy="10" r="1.75"/><circle cx="10" cy="10" r="1.75"/><circle cx="16" cy="10" r="1.75"/></svg>`;function J(t,e="",g=""){return html`<div class="relative ${e}" ${raw(g)} x-data="{ open: false }" @click.outside="open = false" @keydown.escape="open = false">
|
|
3
3
|
<button type="button" @click="open = !open" :aria-expanded="open" aria-label="More actions" title="More actions" class="w-8 h-8 inline-flex items-center justify-center rounded-lg border transition bg-white dark:bg-gray-900 border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 hover:border-indigo-400 hover:text-gray-800 dark:hover:text-gray-100">${rt}</button>
|
|
4
4
|
<div x-show="open" x-transition:enter="transition ease-out duration-100" x-transition:enter-start="opacity-0 scale-95" x-transition:enter-end="opacity-100 scale-100" class="absolute right-0 top-full mt-1 z-50 bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-xl shadow-lg w-56 p-1" style="display:none">
|
|
5
5
|
${t}
|
package/dist/bin.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var t=process.argv[2]??"",r=new Set(["stop-hook","prompt-hook","gemini-stop-hook","gemini-prompt-hook","codex-stop-hook","codex-prompt-hook","onboard-hook","lesson-ready"]);try{if(r.has(t)){let{runHook:o}=await import('./hooks-
|
|
2
|
+
var t=process.argv[2]??"",r=new Set(["stop-hook","prompt-hook","gemini-stop-hook","gemini-prompt-hook","codex-stop-hook","codex-prompt-hook","onboard-hook","lesson-ready"]);try{if(r.has(t)){let{runHook:o}=await import('./hooks-IMABB42H.js');o(t);}else {let{runCli:o}=await import('./commands-PHJYK5IR.js');await o();}}catch(o){console.error(o),process.exit(1);}
|
|
@@ -94,7 +94,7 @@ import {z}from'zod';import {existsSync,readFileSync,lstatSync,mkdirSync,writeFil
|
|
|
94
94
|
CREATE INDEX IF NOT EXISTS idx_lessons_feedback ON lessons (feedback);
|
|
95
95
|
CREATE INDEX IF NOT EXISTS idx_lessons_topic_id ON lessons (topic_id);
|
|
96
96
|
`),Et(e,t),_t(e);}function Et(e,t){for(let n of ["ALTER TABLE lessons ADD COLUMN body TEXT","ALTER TABLE lessons ADD COLUMN imported INTEGER NOT NULL DEFAULT 0","ALTER TABLE lessons ADD COLUMN shared_by TEXT"])try{e.exec(n);}catch{}t<4&&e.exec("UPDATE lessons SET feedback = 'understood' WHERE feedback = 'dont_know'");}function _t(e){for(let[t,n]of Object.entries(pt))l(e,"INSERT OR IGNORE INTO settings (key, value) VALUES (?, ?)",t,n);}var fe="(id, timestamp, topic_id, categories, title, level, summary, body, task_context, project, repository, branch, commit_hash, folder, repository_platform, starred, feedback, imported, shared_by)",Ee="(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";function _e(e){return [e.id,e.timestamp,e.topic_id,JSON.stringify(e.categories),e.title,e.level,e.summary,e.body,e.task_context,e.project,e.repository,e.branch,e.commit_hash,e.folder,e.repository_platform,e.starred?1:0,e.feedback,e.imported?1:0,e.shared_by]}function yn(e,t){l(e,`INSERT OR REPLACE INTO lessons ${fe} VALUES ${Ee}`,..._e(t));}function J(e,t){return l(e,`INSERT OR IGNORE INTO lessons ${fe} VALUES ${Ee}`,..._e(t))>0}var St=[["project","project"],["repository","repository"],["branch","branch"],["commit","commit_hash"]];function ht(e,t){if(e.date_from==null&&e.date_to==null){let n=Ut(e.period??null);n!=null&&t("timestamp >= ?",n);return}if(e.date_from!=null&&t("timestamp >= ?",e.date_from),e.date_to!=null){let n=e.date_to.includes("T")||e.date_to.includes(" ");t("timestamp <= ?",n?e.date_to:`${e.date_to}T23:59:59`);}}function Se(e){let t=[],n=[],s=(r,...i)=>{t.push(r),n.push(...i);};ht(e,s),e.category!=null&&s("categories LIKE ?",`%"${e.category}"%`),e.level!=null&&s("level = ?",e.level);for(let[r,i]of St){let a=e[r];a!=null&&s(`${i} LIKE ?`,`%${a}%`);}if(e.starred!=null&&s("starred = ?",e.starred?1:0),e.imported!=null&&s("imported = ?",e.imported?1:0),e.shared_by!=null&&s("imported = 1 AND shared_by = ?",e.shared_by),e.search!=null)for(let r of e.search.split(/\s+/).filter(Boolean)){let i=`%${r}%`;s("(title LIKE ? OR topic_id LIKE ? OR summary LIKE ? OR body LIKE ? OR shared_by LIKE ?)",i,i,i,i,i);}return e.feedback==="none"?s("feedback IS NULL"):e.feedback!=null&&s("feedback = ?",e.feedback),{where:t.length?`WHERE ${t.join(" AND ")}`:"",params:n}}function V(e,t={}){let{where:n,params:s}=Se(t),o=E(e,`SELECT COUNT(*) AS n FROM lessons ${n}`,...s);return Number(o?.n??0)}var Tt=new Set(["timestamp","level","topic_id","title","feedback"]),yt=new Set(["project","repository","branch","commit_hash","repository_platform"]);function bn(e,t={}){let{where:n,params:s}=Se(t),o=t.sort&&Tt.has(t.sort)?t.sort:"timestamp",r=(t.order??"desc").toLowerCase()==="asc"?"ASC":"DESC",i=`SELECT * FROM lessons ${n} ORDER BY ${o} ${r}`,a=[...s];if(t.page!=null){let u=t.per_page??25;i+=" LIMIT ? OFFSET ?",a.push(u,(t.page-1)*u);}return f(e,i,...a).map(re)}function Ln(e,t){return l(e,"DELETE FROM lessons WHERE id = ?",t)>0}function Rn(e,t){if(t.length===0)return 0;let n=t.map(()=>"?").join(", ");return l(e,`DELETE FROM lessons WHERE id IN (${n})`,...t)}function Nn(e,t,n){return l(e,"UPDATE lessons SET starred = ? WHERE id = ?",n?1:0,t)>0}function he(e,t,n){l(e,"UPDATE lessons SET feedback = ? WHERE id = ?",n||null,t);let s=E(e,"SELECT topic_id FROM lessons WHERE id = ?",t);return s?s.topic_id:null}function bt(e){return f(e,"SELECT * FROM lessons ORDER BY timestamp DESC").map(re)}function Z(e,t){let n=0,s=0,o=0;for(let r of t){let i;try{i=b(r);}catch{o+=1;continue}J(e,i)?n+=1:s+=1;}return {inserted:n,duplicated:s,invalid:o}}function xn(e,t){if(!yt.has(t))throw new Error(`Column not allowed: ${JSON.stringify(t)}`);return f(e,`SELECT DISTINCT ${t} FROM lessons WHERE ${t} IS NOT NULL ORDER BY ${t}`).map(s=>s[t])}function On(e){return f(e,"SELECT DISTINCT shared_by FROM lessons WHERE imported = 1 AND shared_by IS NOT NULL ORDER BY shared_by").map(t=>t.shared_by)}function Te(e,t){let n=E(e,"SELECT * FROM lessons WHERE id = ?",t);return n?re(n):null}function wn(e){return f(e,"SELECT DISTINCT value FROM lessons, json_each(lessons.categories) ORDER BY value").map(n=>n.value)}function ye(e){return f(e,"SELECT DISTINCT topic_id FROM lessons").map(t=>t.topic_id)}function A(e,t){let n=E(e,"SELECT COUNT(*) AS n FROM lessons WHERE timestamp >= ? AND imported = 0",t);return Number(n?.n??0)}function be(e){let t=E(e,"SELECT timestamp FROM lessons WHERE imported = 0 ORDER BY timestamp DESC LIMIT 1");return t?t.timestamp:null}function N(e){let t={};for(let n of f(e,"SELECT topic, confidence FROM knowledge"))t[n.topic]=Number(n.confidence);return t}function Q(e){return f(e,"SELECT topic, confidence FROM knowledge ORDER BY topic").map(t=>({topic:t.topic,confidence:Number(t.confidence)}))}function ee(e){let t=f(e,"SELECT group_name FROM knowledge_group_names ORDER BY group_name").map(s=>s.group_name),n=new Map;for(let s of f(e,"SELECT group_name, topic FROM knowledge_groups ORDER BY group_name, topic")){let o=s.group_name,r=n.get(o)??[];r.push(s.topic),n.set(o,r);}return t.map(s=>({name:s,topics:n.get(s)??[]}))}function k(e,t,n){let s=Math.max(0,Math.min(10,n)),o=new Date().toISOString();l(e,`INSERT INTO knowledge (topic, confidence, updated_at) VALUES (?, ?, ?)
|
|
97
|
-
ON CONFLICT(topic) DO UPDATE SET confidence = excluded.confidence, updated_at = excluded.updated_at`,t,s,o);}function Dn(e,t){let n=l(e,"DELETE FROM knowledge WHERE topic = ?",t);return l(e,"DELETE FROM knowledge_groups WHERE topic = ?",t),n>0}function ue(e,t){let n=t.trim();if(!n)throw new Error("Group name must not be empty");return l(e,"INSERT OR IGNORE INTO knowledge_group_names (group_name) VALUES (?)",n)>0}function Cn(e,t){return l(e,"DELETE FROM knowledge_groups WHERE group_name = ?",t),l(e,"DELETE FROM knowledge_group_names WHERE group_name = ?",t)>0}function Lt(e,t,n){l(e,"INSERT OR IGNORE INTO knowledge_group_names (group_name) VALUES (?)",n),l(e,"DELETE FROM knowledge_groups WHERE topic = ?",t),l(e,"INSERT OR IGNORE INTO knowledge_groups (group_name, topic) VALUES (?, ?)",n,t);}function In(e,t){l(e,"DELETE FROM knowledge_groups WHERE topic = ?",t);}function x(e){let t={};for(let D of f(e,"SELECT key, value FROM settings"))t[D.key]=D.value;let n=t.min_gap_minutes,s=t.min_hours_between,o;n!==void 0?o=Number.parseInt(n,10):s!==void 0?o=Number.parseInt(s,10)*60:o=240;let r=t.max_per_day,i=t.ui_theme??"system",a=i==="dark"||i==="light"||i==="system"?i:"system",u=t.ui_home??"auto",p=u==="lessons"||u==="knowledge"||u==="auto"?u:"auto",_=t.nudge_every,g=_!==void 0?Number.parseInt(_,10):10,S=t.nudge_scope==="global"?"global":"session";return {max_per_day:r!==void 0?Number.parseInt(r,10):2,min_gap_minutes:o,ui_theme:a,ui_home:p,nudge_every:Number.isFinite(g)&&g>=0?g:10,nudge_scope:S,share_name:t.share_name?.trim()||null}}function T(e,t,n){l(e,"INSERT INTO settings (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value",t,n);}function Le(e,t,n){let s=E(e,"INSERT INTO nudge_state (session_id, interactions, updated_at) VALUES (?, 1, ?) ON CONFLICT(session_id) DO UPDATE SET interactions = interactions + 1, updated_at = excluded.updated_at RETURNING interactions",t,new Date().toISOString()),o=Number(s?.interactions??0);return o===1&&l(e,"DELETE FROM nudge_state WHERE session_id NOT IN (SELECT session_id FROM nudge_state ORDER BY updated_at DESC LIMIT ?)",dt),n==="global"?te(e,t,n):o}function kn(e){return f(e,"SELECT session_id, interactions, updated_at FROM nudge_state ORDER BY updated_at DESC").map(t=>({session_id:String(t.session_id),interactions:Number(t.interactions),updated_at:String(t.updated_at)}))}function te(e,t,n){let s=n==="global"?E(e,"SELECT COALESCE(SUM(interactions), 0) AS n FROM nudge_state"):E(e,"SELECT interactions AS n FROM nudge_state WHERE session_id = ?",t);return Number(s?.n??0)}function An(e){l(e,"DELETE FROM nudge_state"),l(e,"UPDATE cue_state SET pending = 0 WHERE id = 1");}var ne=3;function se(e){let t=E(e,"SELECT pending, last_cue_at, last_skip_reason FROM cue_state WHERE id = 1");return {pending:Number(t?.pending??0)===1,last_cue_at:t?.last_cue_at??null,last_skip_reason:t?.last_skip_reason??null}}function Re(e){l(e,"INSERT INTO cue_state (id, pending, last_cue_at) VALUES (1, 1, ?) ON CONFLICT(id) DO UPDATE SET pending = 1, last_cue_at = excluded.last_cue_at",new Date().toISOString()),l(e,"DELETE FROM nudge_state");}function vn(e,t){l(e,"INSERT INTO cue_state (id, pending, last_skip_reason) VALUES (1, 0, ?) ON CONFLICT(id) DO UPDATE SET pending = 0, last_skip_reason = excluded.last_skip_reason",t??null),l(e,"DELETE FROM nudge_state");}function oe(e){let t=E(e,"SELECT COUNT(*) AS n FROM knowledge");return {knowledge_ready:Number(t?.n??0)>0}}function Un(e){let t={};for(let n of ["project","repository","branch","repository_platform"]){let s=E(e,`SELECT ${n} AS v, COUNT(*) AS c FROM lessons WHERE ${n} IS NOT NULL AND imported = 0 GROUP BY ${n} ORDER BY c DESC LIMIT 1`);t[n]=s?s.v:null;}return t}function Ne(e){return j.parse({...e,prerequisites:JSON.parse(String(e.prerequisites??"[]"))})}function Rt(e){return X.parse(e)}function Nt(e,t){l(e,"INSERT INTO courses (id, lesson_id, topic_id, title, goal, prerequisites, status, created_at, updated_at, completed_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",t.id,t.lesson_id,t.topic_id,t.title,t.goal,JSON.stringify(t.prerequisites),t.status,t.created_at,t.updated_at,t.completed_at);}function xt(e,t){let n=E(e,"SELECT * FROM courses WHERE id = ?",t);return n?Ne(n):null}function Ot(e,t={}){let n=[],s=[];t.status!=null&&(n.push("status = ?"),s.push(t.status)),t.lesson_id!=null&&(n.push("lesson_id = ?"),s.push(t.lesson_id));let o=`SELECT * FROM courses ${n.length?`WHERE ${n.join(" AND ")}`:""} ORDER BY updated_at DESC`;return f(e,o,...s).map(Ne)}function wt(e,t){return f(e,"SELECT * FROM course_steps WHERE course_id = ? ORDER BY position",t).map(Rt)}function Fn(e,t,n){l(e,"UPDATE course_steps SET position = position + ? WHERE course_id = ? AND position >= ?",1e5,t,n),l(e,"UPDATE course_steps SET position = position - ? WHERE course_id = ? AND position >= ?",99999,t,1e5);}function Dt(e,t){l(e,"INSERT INTO course_steps (course_id, position, title, kind, anchor, status, done_at) VALUES (?, ?, ?, ?, ?, ?, ?)",t.course_id,t.position,t.title,t.kind,t.anchor,t.status,t.done_at);}function Mn(e,t,n,s,o){return l(e,"UPDATE course_steps SET status = ?, done_at = ? WHERE course_id = ? AND position = ?",s,o,t,n)>0}function $n(e,t,n,s){return l(e,"UPDATE courses SET status = ?, updated_at = ?, completed_at = CASE WHEN ? = 'completed' THEN ? ELSE NULL END WHERE id = ?",n,s,n,s,t)>0}function Pn(e,t,n){l(e,"UPDATE courses SET updated_at = ? WHERE id = ?",n,t);}function Xn(e,t){return l(e,"DELETE FROM course_steps WHERE course_id = ?",t),l(e,"DELETE FROM courses WHERE id = ?",t)>0}function jn(e){return E(e,"SELECT 1 AS one FROM courses WHERE status = 'active' LIMIT 1")!==void 0}function Hn(e){let t=x(e),n=bt(e),s=Q(e),o=ee(e),r=new Map;for(let p of o)for(let _ of p.topics)r.set(_,p.name);let i={groups:o.map(p=>p.name),topics:s.map(p=>({topic:p.topic,confidence:p.confidence,group:r.get(p.topic)??null}))},a={[H]:strToU8(JSON.stringify(t,null,2)),[B]:strToU8(JSON.stringify(n,null,2)),[W]:strToU8(JSON.stringify(i,null,2))};existsSync(C)&&(a[K]=strToU8(readFileSync(C,"utf8")));let u=Ot(e);if(u.length){let p=u.flatMap(_=>wt(e,_.id));a[G]=strToU8(JSON.stringify({courses:u,steps:p},null,2));for(let _ of u){let g=join(me,_.id,I);try{let S=lstatSync(g);S.isFile()&&S.size<=xe&&(a[`courses/${_.id}/${I}`]=new Uint8Array(readFileSync(g)));}catch{}}}return zipSync(a)}var xe=2*1024*1024;function Ct(e,t,n){if(!(H in t))return;let s=JSON.parse(strFromU8(t[H]));"max_per_day"in s&&T(e,"max_per_day",String(s.max_per_day)),"min_gap_minutes"in s&&T(e,"min_gap_minutes",String(s.min_gap_minutes)),(s.ui_theme==="system"||s.ui_theme==="dark"||s.ui_theme==="light")&&T(e,"ui_theme",s.ui_theme),(s.ui_home==="auto"||s.ui_home==="lessons"||s.ui_home==="knowledge")&&T(e,"ui_home",s.ui_home),"nudge_every"in s&&T(e,"nudge_every",String(s.nudge_every)),(s.nudge_scope==="session"||s.nudge_scope==="global")&&T(e,"nudge_scope",s.nudge_scope),typeof s.share_name=="string"&&T(e,"share_name",lt(s.share_name)),n.settings=1;}function It(e,t,n){if(!(W in t))return;let s=JSON.parse(strFromU8(t[W]));if(!(s&&typeof s=="object"&&Array.isArray(s.topics))){for(let[r,i]of Object.entries(s))k(e,r,i);n.topics=Object.keys(s).length;return}let o=0;for(let r of s.groups??[])ue(e,r)&&(o+=1);for(let r of s.topics){k(e,r.topic,r.confidence);let i=r.group;i&&i!=="Other"&&(ue(e,i)&&(o+=1),Lt(e,r.topic,i));}n.topics=s.topics.length,n.groups=o;}function kt(e,t,n){if(!(B in t))return;let s=JSON.parse(strFromU8(t[B])),{inserted:o,duplicated:r,invalid:i}=Z(e,s);n.lessons=o,n.skipped=r,n.invalid=i;}function At(e,t){K in e&&(mkdirSync(dirname(C),{recursive:true}),writeFileSync(C,strFromU8(e[K]),"utf8"),t.learning_state=1);}function vt(e,t,n){if(!(G in t))return;let s=JSON.parse(strFromU8(t[G])),o=new Set;for(let r of s.courses??[])try{let i=j.parse(r);xt(e,i.id)||(Nt(e,i),n.courses+=1),o.add(i.id);}catch{n.invalid+=1;}for(let r of s.steps??[])try{let i=X.parse(r);if(!o.has(i.course_id))continue;E(e,"SELECT 1 AS one FROM course_steps WHERE course_id = ? AND position = ?",i.course_id,i.position)||Dt(e,i);}catch{n.invalid+=1;}for(let[r,i]of Object.entries(t)){let a=ct.exec(r)?.[1];if(!a||!o.has(a)||i.length>xe)continue;let u=join(me,a),p=join(u,I);existsSync(p)||(mkdirSync(u,{recursive:true}),writeFileSync(p,i));}}function Bn(e,t){let n={settings:0,topics:0,groups:0,lessons:0,skipped:0,invalid:0,learning_state:0,courses:0},s=unzipSync(t);return Ct(e,s,n),It(e,s,n),kt(e,s,n),At(s,n),vt(e,s,n),n}function Ut(e){let t=new Date,n;if(e==="today")n=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0,0));else if(e==="week")n=new Date(t.getTime()-7*864e5);else if(e==="month")n=new Date(t.getTime()-30*864e5);else if(e==="year")n=new Date(t.getTime()-365*864e5);else return null;return n.toISOString()}function re(e){let t=[];try{let n=JSON.parse(e.categories);Array.isArray(n)&&(t=n);}catch{t=[];}return b({...e,categories:t,starred:!!e.starred,imported:!!e.imported})}var Oe={version:"2.5.0-next.
|
|
97
|
+
ON CONFLICT(topic) DO UPDATE SET confidence = excluded.confidence, updated_at = excluded.updated_at`,t,s,o);}function Dn(e,t){let n=l(e,"DELETE FROM knowledge WHERE topic = ?",t);return l(e,"DELETE FROM knowledge_groups WHERE topic = ?",t),n>0}function ue(e,t){let n=t.trim();if(!n)throw new Error("Group name must not be empty");return l(e,"INSERT OR IGNORE INTO knowledge_group_names (group_name) VALUES (?)",n)>0}function Cn(e,t){return l(e,"DELETE FROM knowledge_groups WHERE group_name = ?",t),l(e,"DELETE FROM knowledge_group_names WHERE group_name = ?",t)>0}function Lt(e,t,n){l(e,"INSERT OR IGNORE INTO knowledge_group_names (group_name) VALUES (?)",n),l(e,"DELETE FROM knowledge_groups WHERE topic = ?",t),l(e,"INSERT OR IGNORE INTO knowledge_groups (group_name, topic) VALUES (?, ?)",n,t);}function In(e,t){l(e,"DELETE FROM knowledge_groups WHERE topic = ?",t);}function x(e){let t={};for(let D of f(e,"SELECT key, value FROM settings"))t[D.key]=D.value;let n=t.min_gap_minutes,s=t.min_hours_between,o;n!==void 0?o=Number.parseInt(n,10):s!==void 0?o=Number.parseInt(s,10)*60:o=240;let r=t.max_per_day,i=t.ui_theme??"system",a=i==="dark"||i==="light"||i==="system"?i:"system",u=t.ui_home??"auto",p=u==="lessons"||u==="knowledge"||u==="auto"?u:"auto",_=t.nudge_every,g=_!==void 0?Number.parseInt(_,10):10,S=t.nudge_scope==="global"?"global":"session";return {max_per_day:r!==void 0?Number.parseInt(r,10):2,min_gap_minutes:o,ui_theme:a,ui_home:p,nudge_every:Number.isFinite(g)&&g>=0?g:10,nudge_scope:S,share_name:t.share_name?.trim()||null}}function T(e,t,n){l(e,"INSERT INTO settings (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value",t,n);}function Le(e,t,n){let s=E(e,"INSERT INTO nudge_state (session_id, interactions, updated_at) VALUES (?, 1, ?) ON CONFLICT(session_id) DO UPDATE SET interactions = interactions + 1, updated_at = excluded.updated_at RETURNING interactions",t,new Date().toISOString()),o=Number(s?.interactions??0);return o===1&&l(e,"DELETE FROM nudge_state WHERE session_id NOT IN (SELECT session_id FROM nudge_state ORDER BY updated_at DESC LIMIT ?)",dt),n==="global"?te(e,t,n):o}function kn(e){return f(e,"SELECT session_id, interactions, updated_at FROM nudge_state ORDER BY updated_at DESC").map(t=>({session_id:String(t.session_id),interactions:Number(t.interactions),updated_at:String(t.updated_at)}))}function te(e,t,n){let s=n==="global"?E(e,"SELECT COALESCE(SUM(interactions), 0) AS n FROM nudge_state"):E(e,"SELECT interactions AS n FROM nudge_state WHERE session_id = ?",t);return Number(s?.n??0)}function An(e){l(e,"DELETE FROM nudge_state"),l(e,"UPDATE cue_state SET pending = 0 WHERE id = 1");}var ne=3;function se(e){let t=E(e,"SELECT pending, last_cue_at, last_skip_reason FROM cue_state WHERE id = 1");return {pending:Number(t?.pending??0)===1,last_cue_at:t?.last_cue_at??null,last_skip_reason:t?.last_skip_reason??null}}function Re(e){l(e,"INSERT INTO cue_state (id, pending, last_cue_at) VALUES (1, 1, ?) ON CONFLICT(id) DO UPDATE SET pending = 1, last_cue_at = excluded.last_cue_at",new Date().toISOString()),l(e,"DELETE FROM nudge_state");}function vn(e,t){l(e,"INSERT INTO cue_state (id, pending, last_skip_reason) VALUES (1, 0, ?) ON CONFLICT(id) DO UPDATE SET pending = 0, last_skip_reason = excluded.last_skip_reason",t??null),l(e,"DELETE FROM nudge_state");}function oe(e){let t=E(e,"SELECT COUNT(*) AS n FROM knowledge");return {knowledge_ready:Number(t?.n??0)>0}}function Un(e){let t={};for(let n of ["project","repository","branch","repository_platform"]){let s=E(e,`SELECT ${n} AS v, COUNT(*) AS c FROM lessons WHERE ${n} IS NOT NULL AND imported = 0 GROUP BY ${n} ORDER BY c DESC LIMIT 1`);t[n]=s?s.v:null;}return t}function Ne(e){return j.parse({...e,prerequisites:JSON.parse(String(e.prerequisites??"[]"))})}function Rt(e){return X.parse(e)}function Nt(e,t){l(e,"INSERT INTO courses (id, lesson_id, topic_id, title, goal, prerequisites, status, created_at, updated_at, completed_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",t.id,t.lesson_id,t.topic_id,t.title,t.goal,JSON.stringify(t.prerequisites),t.status,t.created_at,t.updated_at,t.completed_at);}function xt(e,t){let n=E(e,"SELECT * FROM courses WHERE id = ?",t);return n?Ne(n):null}function Ot(e,t={}){let n=[],s=[];t.status!=null&&(n.push("status = ?"),s.push(t.status)),t.lesson_id!=null&&(n.push("lesson_id = ?"),s.push(t.lesson_id));let o=`SELECT * FROM courses ${n.length?`WHERE ${n.join(" AND ")}`:""} ORDER BY updated_at DESC`;return f(e,o,...s).map(Ne)}function wt(e,t){return f(e,"SELECT * FROM course_steps WHERE course_id = ? ORDER BY position",t).map(Rt)}function Fn(e,t,n){l(e,"UPDATE course_steps SET position = position + ? WHERE course_id = ? AND position >= ?",1e5,t,n),l(e,"UPDATE course_steps SET position = position - ? WHERE course_id = ? AND position >= ?",99999,t,1e5);}function Dt(e,t){l(e,"INSERT INTO course_steps (course_id, position, title, kind, anchor, status, done_at) VALUES (?, ?, ?, ?, ?, ?, ?)",t.course_id,t.position,t.title,t.kind,t.anchor,t.status,t.done_at);}function Mn(e,t,n,s,o){return l(e,"UPDATE course_steps SET status = ?, done_at = ? WHERE course_id = ? AND position = ?",s,o,t,n)>0}function $n(e,t,n,s){return l(e,"UPDATE courses SET status = ?, updated_at = ?, completed_at = CASE WHEN ? = 'completed' THEN ? ELSE NULL END WHERE id = ?",n,s,n,s,t)>0}function Pn(e,t,n){l(e,"UPDATE courses SET updated_at = ? WHERE id = ?",n,t);}function Xn(e,t){return l(e,"DELETE FROM course_steps WHERE course_id = ?",t),l(e,"DELETE FROM courses WHERE id = ?",t)>0}function jn(e){return E(e,"SELECT 1 AS one FROM courses WHERE status = 'active' LIMIT 1")!==void 0}function Hn(e){let t=x(e),n=bt(e),s=Q(e),o=ee(e),r=new Map;for(let p of o)for(let _ of p.topics)r.set(_,p.name);let i={groups:o.map(p=>p.name),topics:s.map(p=>({topic:p.topic,confidence:p.confidence,group:r.get(p.topic)??null}))},a={[H]:strToU8(JSON.stringify(t,null,2)),[B]:strToU8(JSON.stringify(n,null,2)),[W]:strToU8(JSON.stringify(i,null,2))};existsSync(C)&&(a[K]=strToU8(readFileSync(C,"utf8")));let u=Ot(e);if(u.length){let p=u.flatMap(_=>wt(e,_.id));a[G]=strToU8(JSON.stringify({courses:u,steps:p},null,2));for(let _ of u){let g=join(me,_.id,I);try{let S=lstatSync(g);S.isFile()&&S.size<=xe&&(a[`courses/${_.id}/${I}`]=new Uint8Array(readFileSync(g)));}catch{}}}return zipSync(a)}var xe=2*1024*1024;function Ct(e,t,n){if(!(H in t))return;let s=JSON.parse(strFromU8(t[H]));"max_per_day"in s&&T(e,"max_per_day",String(s.max_per_day)),"min_gap_minutes"in s&&T(e,"min_gap_minutes",String(s.min_gap_minutes)),(s.ui_theme==="system"||s.ui_theme==="dark"||s.ui_theme==="light")&&T(e,"ui_theme",s.ui_theme),(s.ui_home==="auto"||s.ui_home==="lessons"||s.ui_home==="knowledge")&&T(e,"ui_home",s.ui_home),"nudge_every"in s&&T(e,"nudge_every",String(s.nudge_every)),(s.nudge_scope==="session"||s.nudge_scope==="global")&&T(e,"nudge_scope",s.nudge_scope),typeof s.share_name=="string"&&T(e,"share_name",lt(s.share_name)),n.settings=1;}function It(e,t,n){if(!(W in t))return;let s=JSON.parse(strFromU8(t[W]));if(!(s&&typeof s=="object"&&Array.isArray(s.topics))){for(let[r,i]of Object.entries(s))k(e,r,i);n.topics=Object.keys(s).length;return}let o=0;for(let r of s.groups??[])ue(e,r)&&(o+=1);for(let r of s.topics){k(e,r.topic,r.confidence);let i=r.group;i&&i!=="Other"&&(ue(e,i)&&(o+=1),Lt(e,r.topic,i));}n.topics=s.topics.length,n.groups=o;}function kt(e,t,n){if(!(B in t))return;let s=JSON.parse(strFromU8(t[B])),{inserted:o,duplicated:r,invalid:i}=Z(e,s);n.lessons=o,n.skipped=r,n.invalid=i;}function At(e,t){K in e&&(mkdirSync(dirname(C),{recursive:true}),writeFileSync(C,strFromU8(e[K]),"utf8"),t.learning_state=1);}function vt(e,t,n){if(!(G in t))return;let s=JSON.parse(strFromU8(t[G])),o=new Set;for(let r of s.courses??[])try{let i=j.parse(r);xt(e,i.id)||(Nt(e,i),n.courses+=1),o.add(i.id);}catch{n.invalid+=1;}for(let r of s.steps??[])try{let i=X.parse(r);if(!o.has(i.course_id))continue;E(e,"SELECT 1 AS one FROM course_steps WHERE course_id = ? AND position = ?",i.course_id,i.position)||Dt(e,i);}catch{n.invalid+=1;}for(let[r,i]of Object.entries(t)){let a=ct.exec(r)?.[1];if(!a||!o.has(a)||i.length>xe)continue;let u=join(me,a),p=join(u,I);existsSync(p)||(mkdirSync(u,{recursive:true}),writeFileSync(p,i));}}function Bn(e,t){let n={settings:0,topics:0,groups:0,lessons:0,skipped:0,invalid:0,learning_state:0,courses:0},s=unzipSync(t);return Ct(e,s,n),It(e,s,n),kt(e,s,n),At(s,n),vt(e,s,n),n}function Ut(e){let t=new Date,n;if(e==="today")n=new Date(Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0,0));else if(e==="week")n=new Date(t.getTime()-7*864e5);else if(e==="month")n=new Date(t.getTime()-30*864e5);else if(e==="year")n=new Date(t.getTime()-365*864e5);else return null;return n.toISOString()}function re(e){let t=[];try{let n=JSON.parse(e.categories);Array.isArray(n)&&(t=n);}catch{t=[];}return b({...e,categories:t,starred:!!e.starred,imported:!!e.imported})}var Oe={version:"2.5.0-next.584.g7ebb2db"};var we=Oe.version;function De(e){let t=[...e].length,n=Math.max(34-t-2,2),s=Math.floor(n/2);return `### ${"\u2500".repeat(s)} ${e} ${"\u2500".repeat(n-s)}`}function Ce(e){let t=e.level.charAt(0).toUpperCase()+e.level.slice(1),n=e.categories.join(" \xB7 ");return [De("\u{1F393} devcoach"),`**${e.title}** \xB7 ${n} \xB7 ${t}`,"",e.body?.trim()||e.summary,"",De(`${e.topic_id} \xB7 ${e.level}`)].join(`
|
|
98
98
|
`)}var F="devcoach.lesson",w=1,jt=`devcoach:lesson:${w}:`,Ht="https://ultimaphoenix.github.io/dev-coach/lesson",Bt=".devcoach.md",Wt=256*1024,m=class extends Error{},O=z.string().nullish(),Kt=["task_context","project","branch","commit_hash"],Gt=new Set(["github","gitlab","bitbucket"]),ke=z.object({format:z.literal(F),version:z.literal(w),lesson:z.object({title:z.string().min(1),summary:z.string(),body:z.string().nullable(),topic_id:z.string().min(1),categories:z.array(z.string()),level:M,task_context:O,project:O,repository:O,branch:O,commit_hash:O,repository_platform:$.nullish()}),origin:z.object({id:z.string().min(1),timestamp:z.string()}),shared_by:z.string().nullable(),shared_at:z.string(),app_version:z.string()});function es(e,t){let n={title:e.title,summary:e.summary,body:e.body,topic_id:e.topic_id,categories:e.categories,level:e.level};if(t.includeContext){for(let s of Kt)e[s]!=null&&(n[s]=e[s]);e.repository_platform&&Gt.has(e.repository_platform)&&(e.repository!=null&&(n.repository=e.repository),n.repository_platform=e.repository_platform);}return {format:F,version:w,lesson:n,origin:{id:e.id,timestamp:e.timestamp},shared_by:t.sharedBy,shared_at:P(t.now??new Date),app_version:we}}function ts(e){return e.anonymous?null:e.explicit!=null?e.explicit.trim()||null:e.setting?.trim()||e.gitUserName?.trim()||null}function Ae(e){let t=deflateSync(strToU8(JSON.stringify(e)),{level:9});return jt+Buffer.from(t).toString("base64url")}var ve=/devcoach:lesson:(\d+):([A-Za-z0-9_-]+)/,zt=64e3,ie=512,U=class extends Error{};function Yt(e,t){let n=[],s=0,o=new Inflate(a=>{if(s+=a.length,s>t)throw new U("too large");n.push(a);});for(let a=0;a<e.length;a+=ie)o.push(e.subarray(a,a+ie),a+ie>=e.length);let r=new Uint8Array(s),i=0;for(let a of n)r.set(a,i),i+=a.length;return r}function qt(e){let t=new RegExp(`^${ve.source}$`).exec(e.trim());if(!t)throw new m("That is not a devcoach lesson code.");if(Number(t[1])!==w)throw new m(`This lesson was shared by a newer devcoach (format ${t[1]}) \u2014 upgrade to import it.`);let n=t[2]??"";if(n.length>zt)throw new m("This lesson code is too large to be a lesson.");let s;try{let o=Yt(new Uint8Array(Buffer.from(n,"base64url")),Wt);s=strFromU8(o);}catch(o){throw o instanceof U?new m("This lesson code is too large to be a lesson."):new m("This lesson code is damaged or incomplete \u2014 copy it again.")}return Ue(s)}function Ue(e){let t;try{t=JSON.parse(e);}catch{throw new m("This lesson code is damaged or incomplete \u2014 copy it again.")}let n=ke.safeParse(t);if(!n.success)throw new m("This is not a valid devcoach lesson.");return n.data}function ns(e,t=Ae(e)){let n=e.shared_by?`Shared by ${e.shared_by} with devcoach`:"Shared with devcoach";return [Ce(e.lesson),"",`${n} \u2014 paste it to your agent or run: devcoach import`,t].join(`
|
|
99
99
|
`)}function ss(e,t=Ae(e)){return `${Ht}#${t}`}function Jt(e,t="lesson"){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||t}function os(e){return `${Jt(e.origin.id)}${Bt}`}var Vt=/^[A-Za-z0-9_.+:@/-]+$/,v=e=>Vt.test(e)?e:JSON.stringify(e),Zt=e=>`[${e.map(v).join(", ")}]`;function rs(e){let t=e.lesson,n=["---",`format: ${F}`,`version: ${w}`,`title: ${JSON.stringify(t.title)}`,`topic_id: ${v(t.topic_id)}`,`level: ${t.level}`,`categories: ${Zt(t.categories)}`,`summary: ${JSON.stringify(t.summary)}`,`origin_id: ${v(e.origin.id)}`,`origin_timestamp: ${e.origin.timestamp}`,`shared_by: ${e.shared_by==null?"null":JSON.stringify(e.shared_by)}`,`shared_at: ${e.shared_at}`,`app_version: ${v(e.app_version)}`];for(let s of ["task_context","project","repository","branch","commit_hash","repository_platform"]){let o=t[s];o!=null&&n.push(`${s}: ${JSON.stringify(o)}`);}return n.push("---","",t.body??t.summary,""),n.join(`
|
|
100
100
|
`)}function Qt(e){let t=[],n="",s=false;for(let o=0;o<e.length;o++){let r=e[o]??"";s?(n+=r,r==="\\"?n+=e[++o]??"":r==='"'&&(s=false)):r==='"'?(s=true,n+=r):r===","?(t.push(n),n=""):n+=r;}return t.push(n),t}function Fe(e){let t=e.trim();if(t==="null"||t==="")return null;if(t.startsWith('"'))return JSON.parse(t);if(t.startsWith("[")&&t.endsWith("]")){let n=t.slice(1,-1).trim();return n?Qt(n).map(s=>Fe(s)):[]}return t}function en(e){let t=e.replace(/\r\n?/g,`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {o,p,fa,V,W as W$1,Y as Y$1,X as X$1,t,Z,_,ba,$ as $$1,aa,ca,ia,pa,ha}from'./chunk-
|
|
2
|
+
import {o,p,fa,V,W as W$1,Y as Y$1,X as X$1,t,Z,_,ba,$ as $$1,aa,ca,ia,pa,ha}from'./chunk-2M2WL7AV.js';import {lstatSync,mkdirSync,readFileSync,rmSync,existsSync}from'fs';import {join,sep,basename}from'path';import {execFileSync}from'child_process';import nt from'dns';import rt from'http';import ot from'https';import {isIP}from'net';var w=/^[a-z0-9-]+$/,X=p,h=class extends Error{};function Y(e){if(!w.test(e))throw new h(`Invalid course id '${e}'`)}function C(e){return Y(e),join(o,e)}function M(e){return join(C(e),X)}function J(e){let t=M(e);if(!t.startsWith(C(e)+sep))return null;try{let n=lstatSync(t);return !n.isFile()||n.size>fa?null:t}catch{return null}}function Q(e,t){let n=pa(t,"course"),r=n;for(let o$1=2;W$1(e,r)!==null||existsSync(join(o,r));o$1++)r=`${n}-${o$1}`;return r}function dt(e,t){let n=new Date().toISOString(),r={id:Q(e,t.title),lesson_id:t.lesson_id??null,topic_id:t.topic_id,title:t.title,goal:t.goal??null,prerequisites:t.prerequisites??[],status:"active",created_at:n,updated_at:n,completed_at:null};return V(e,r),mkdirSync(C(r.id),{recursive:true}),{...r,steps:[]}}function $(e,t){if(!w.test(t))return null;let n=W$1(e,t);return n?{...n,steps:Y$1(e,t)}:null}function St(e,t={}){return X$1(e,t).map(n=>({...n,steps:Y$1(e,n.id)}))}function wt(e,t$1,n){return t(e,()=>{let r=$(e,t$1);if(!r)throw new h(`Course '${t$1}' not found`);let o=r.steps.length,i=n.after??o;if(!Number.isInteger(i)||i<0||i>o)throw new h(`'after' must be between 0 and ${o} (the course has ${o} steps)`);let a=J(t$1);if(!a)throw new h(`Course '${t$1}' has no document yet \u2014 write ${M(t$1)} first`);let f=readFileSync(a,"utf8");if(!new RegExp(`\\sid=["']${n.anchor}["']`).test(f))throw new h(`No element with id="${n.anchor}" in ${a}`);if(r.steps.some(s=>s.anchor===n.anchor))throw new h(`Step anchor '${n.anchor}' is already registered`);let l={course_id:t$1,position:i+1,title:n.title,kind:n.kind,anchor:n.anchor,status:"todo",done_at:null};return i<o&&Z(e,t$1,i+1),_(e,l),ba(e,t$1,new Date().toISOString()),l})}function Ct(e,t$1,n,r){let o=new Date().toISOString();return t(e,()=>{if(!$$1(e,t$1,n,r,r==="done"?o:null))return null;let a=Y$1(e,t$1),f=a.length>0&&a.every(s=>s.status!=="todo"),l=W$1(e,t$1);return l&&f&&l.status==="active"?aa(e,t$1,"completed",o):l&&!f&&l.status==="completed"?aa(e,t$1,"active",o):ba(e,t$1,o),$(e,t$1)})}function yt(e,t,n){return w.test(t)&&aa(e,t,n,new Date().toISOString())?$(e,t):null}function bt(e,t){if(!w.test(t))return false;let n=ca(e,t);return rmSync(C(t),{recursive:true,force:true}),n}function xt(e){return {done:e.steps.filter(t=>t.status!=="todo").length,total:e.steps.length}}function y(...e){try{return execFileSync("git",e,{encoding:"utf8",timeout:3e3,stdio:["ignore","pipe","ignore"]}).trim()||null}catch{return null}}var F={"github.com":"github","gitlab.com":"gitlab","bitbucket.org":"bitbucket"};function et(e){if(!e)return [null,null];let t=/^git@([^:]+):(.+?)(?:\.git)?$/.exec(e);if(t){let r=(t[1]??"").toLowerCase();return [t[2]??e,F[r]??"local"]}let n=/^https?:\/\/([^/]+)\/(.+?)(?:\.git)?$/.exec(e);if(n){let r=(n[1]??"").toLowerCase();return [n[2]??e,F[r]??"local"]}return [e,"local"]}function Dt(){return y("config","user.name")}function $t(){let e=process.cwd(),t=y("rev-parse","--abbrev-ref","HEAD"),n=y("rev-parse","HEAD"),r=y("remote","get-url","origin"),[o,i]=et(r),a;return o?a=o.replace(/\/+$/,"").split("/").pop()??null:a=basename(e)||null,t==="HEAD"&&(t=null),{project:a,repository:o,branch:t,commit_hash:n,folder:e,repository_platform:i}}var W="That URL is too large to be a lesson.",b="Only public http(s) URLs can be imported.",st=new Set([301,302,303,307,308]);function it(e){return /^https?:\/\/\S+$/i.test(e.trim())}function B(e){let[t=0,n=0]=e.split(".").map(Number);return t===0||t===10||t===127||t===169&&n===254||t===172&&n>=16&&n<=31||t===192&&n===168||t===100&&n>=64&&n<=127||t>=224}function G(e){let t=e.replace(/^\[|\]$/g,"").replace(/%.*$/,"").toLowerCase();if(isIP(t)===4)return B(t);if(isIP(t)!==6)return true;let n=/^::ffff:(\d+\.\d+\.\d+\.\d+)$/.exec(t);if(n?.[1])return B(n[1]);if(t==="::"||t==="::1")return true;let r=t.split(":")[0]??"";return !!(/^f[cd]/.test(r)||/^fe[89ab]/.test(r))}async function at(e){return (await nt.promises.lookup(e,{all:true})).map(n=>n.address)}async function ut(e,t){let n=e.hostname.replace(/^\[|\]$/g,"").toLowerCase();if(n==="localhost"||n.endsWith(".localhost"))throw new ia(b);if(isIP(n)){if(G(n))throw new ia(b);return n}let r;try{r=await t(n);}catch{throw new ia("The URL could not be reached \u2014 copy the lesson text instead.")}let o=r[0];if(!o||r.some(i=>G(i)))throw new ia(b);return o}var lt=(e,t,n)=>new Promise((r,o)=>{let i=isIP(t)===6?6:4,a=(s,c,m)=>{c.all?m(null,[{address:t,family:i}]):m(null,t,i);},l=(e.protocol==="https:"?ot:rt).request(e,{method:"GET",lookup:a,signal:n,headers:{accept:"text/plain, text/markdown, application/json;q=0.9, */*;q=0.5","user-agent":`devcoach/${ha}`}},s=>{let c=s.headers["content-length"];r({status:s.statusCode??0,location:s.headers.location??null,contentLength:c===void 0?null:Number(c),body:s,abort:()=>s.destroy()});});l.on("error",o),l.end();});async function ct(e,t){if(e.contentLength!==null&&e.contentLength>t)throw e.abort(),new ia(W);let n=[],r=0;for await(let o of e.body){if(r+=o.byteLength,r>t)throw e.abort(),new ia(W);n.push(o);}return Buffer.concat(n).toString("utf8")}async function kt(e,t={}){let n=t.timeoutMs??5e3,r=t.maxBytes??256*1024,o=t.maxRedirects??3,i=t.lookup??at,a=t.transport??lt;if(!it(e))throw new ia("Only http(s) URLs can be imported.");let f=new AbortController,l=setTimeout(()=>f.abort(),n);try{let s=new URL(e.trim());for(let c=0;;c++){let m=await ut(s,i),p=await a(s,m,f.signal);if(st.has(p.status)){if(p.abort(),!p.location||c>=o)throw new ia("The URL redirects too many times \u2014 copy the lesson text instead.");if(s=new URL(p.location,s),!/^https?:$/.test(s.protocol))throw new ia(b);continue}if(p.status<200||p.status>=300)throw p.abort(),new ia(`The URL answered ${p.status} \u2014 nothing to import there.`);return await ct(p,r)}}catch(s){if(s instanceof ia)throw s;let c=s?.name==="AbortError"?"timed out":"could not be reached";throw new ia(`The URL ${c} \u2014 copy the lesson text instead.`)}finally{clearTimeout(l);}}export{w as a,h as b,C as c,M as d,J as e,dt as f,$ as g,St as h,wt as i,Ct as j,yt as k,bt as l,xt as m,Dt as n,$t as o,it as p,kt as q};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {m as m$1,u,T as T$1,da,Aa,l as l$1,t,za}from'./chunk-
|
|
2
|
+
import {m as m$1,u,T as T$1,da,Aa,l as l$1,t,za}from'./chunk-2M2WL7AV.js';import {existsSync,mkdirSync,statSync,writeFileSync,appendFileSync,fstatSync,readFileSync}from'fs';import {join}from'path';function A(e){try{let o=JSON.parse(e);return {stop_hook_active:o?.stop_hook_active===!0,permission_mode:typeof o?.permission_mode=="string"?o.permission_mode:null,session_id:typeof o?.session_id=="string"?o.session_id:null}}catch{return {stop_hook_active:false,permission_mode:null,session_id:null}}}function l(){let e={stop_hook_active:false,permission_mode:null,session_id:null};try{let o=fstatSync(0);return !o.isFIFO()&&!o.isFile()&&!o.isSocket()?e:A(readFileSync(0,"utf8"))}catch{return e}}function N(e){return e.stop_hook_active||e.permission_mode==="plan"}function s(e,o,t){if(process.env.DEVCOACH_HOOK_DEBUG==="1")try{mkdirSync(l$1,{recursive:!0});let n=join(l$1,"hook.log");existsSync(n)&&statSync(n).size>256*1024&&writeFileSync(n,""),appendFileSync(n,`${new Date().toISOString()} ${e} ${(o??"-").slice(0,8)} ${t}
|
|
3
3
|
`);}catch{}}var $={claude:"block",gemini:"deny",codex:"block"};function h(e,o,t){let n={decision:$[e],reason:o};t&&(n.systemMessage=t),process.stdout.write(`${JSON.stringify(n)}
|
|
4
4
|
`),process.exit(0);}var b="devcoach: the user has no coaching profile yet. Ask them how they want to set it up and STRONGLY recommend Automatic \u2014 devcoach scans their full Claude Code history across all their projects (call get_onboarding for the detected stack and per-project evidence) so the profile reflects what they actually build. Also offer Guided (a short conversation to map topics and confidence levels) and Import (restore from a backup), but lead with Automatic; do not pick for them. After they choose, build the profile and save it by calling the devcoach `complete_onboarding` MCP tool (not a shell command) before ending your turn.";function E(e=l()){if(N(e)&&process.exit(0),existsSync(m$1)){let o;try{o=u(t=>T$1(t).knowledge_ready);}catch(t){s("onboard-hook",e.session_id,`error: ${t}`),process.exit(0);}o&&process.exit(0);}s("onboard-hook",e.session_id,"onboarding cue"),h("claude",b);}var a=10,y={claude:{cue:"Invoke the `devcoach` skill (Skill tool)",prime:"invoke the `devcoach` skill (Skill tool)"},gemini:{cue:"Activate the `devcoach` skill (activate_skill tool)",prime:"activate the `devcoach` skill (activate_skill tool)"},codex:{cue:"Activate the `devcoach` skill",prime:"activate the `devcoach` skill"}};function I(e,o="claude"){let t=e%a===0,n=Math.ceil(e/a)*a,i=t?`This is lesson #${e} \u2014 a notebook checkpoint (every ${a} lessons): after log_lesson returns the feedback, also read references/calibration.md in the devcoach skill and run its notebook-update step (a direct file write), recording "(updated after ${e} lessons)".`:`Skip the notebook update this time \u2014 it is refreshed only every ${a} lessons (next checkpoint at lesson #${n}).`;return `devcoach: a lesson is due for the technical work just completed. Do it now \u2014 do not acknowledge this message and do not explain what you are about to do.
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {e,g,b,d}from'./chunk-
|
|
2
|
+
import {e,g,b,d}from'./chunk-X67QSFUJ.js';export{c as buildLessonCue,d as cmdLessonReady,b as cmdOnboardHook,g as cmdPromptHook,e as cmdStopHook,a as parseHookPayload}from'./chunk-X67QSFUJ.js';import {a as a$1,d as d$1,e as e$1,g as g$2,b as b$2,f}from'./chunk-QU6UQJWC.js';import {c as c$1,b as b$1,a as a$2,e as e$3,f as f$1}from'./chunk-MRABMPXO.js';import {h,m,g as g$1,e as e$2,d as d$2,n,o,p,q as q$1}from'./chunk-U2NGRAGG.js';import {ha,u,ta,x as x$1,E,A,y,va,N as N$1,ka,O,s,ja,qa,ra,oa,na,la,xa,ia,sa,wa,r,H as H$1,L,I as I$1,J,K,M as M$1,ea,G,B,n as n$1,ga,l,m as m$1,T,P as P$1,R,Aa}from'./chunk-2M2WL7AV.js';import {spawn,spawnSync,execFileSync}from'child_process';import {writeFileSync,existsSync,readFileSync,rmSync,mkdirSync,accessSync,constants}from'fs';import {createInterface}from'readline/promises';import {text}from'stream/consumers';import {Command}from'commander';import {homedir,platform}from'os';import {join,dirname}from'path';var c=(e="")=>{console.log(e);};function yo(){let e=platform();if(e==="darwin")return join(homedir(),"Library","Application Support","Claude","claude_desktop_config.json");if(e==="win32"){let t=process.env.APPDATA??join(homedir(),"AppData","Roaming");return join(t,"Claude","claude_desktop_config.json")}let o=process.env.XDG_CONFIG_HOME??join(homedir(),".config");return join(o,"Claude","claude_desktop_config.json")}var I=join(homedir(),".claude","settings.json"),Y=join(homedir(),".claude","skills","devcoach"),he=join(homedir(),".gemini"),x=join(he,"settings.json"),Fo=join(he,"extensions","devcoach","gemini-extension.json"),ke=join(homedir(),".codex"),H=join(ke,"hooks.json"),W=join(ke,"config.toml"),N=join(homedir(),".agents","skills","devcoach");function vo(e){for(let o of (process.env.PATH??"").split(":"))if(o)try{return accessSync(join(o,e),constants.X_OK),join(o,e)}catch{}return null}var X=e=>vo(e)!==null;function wo(){return X("devcoach")?{command:"devcoach",args:["mcp"]}:{command:"npx",args:["-y","devcoach","mcp"]}}function be(){let e=vo("devcoach");return e?e.includes("fnm_multishells")?"devcoach":e:"npx -y devcoach"}function ho(e,o,t){if(!X(e))return "";t&&spawnSync(e,t,{encoding:"utf8"});let s=spawnSync(e,o,{encoding:"utf8"});return s.status===0?`${a$1.green("\u2713")} Registered via \`${e} mcp add\``:`${s.stderr??""}${s.stdout??""}`.toLowerCase().includes("already")?`${a$1.yellow("Already registered")} in ${e} (use --force to overwrite)`:`${a$1.red(`${e} mcp add failed:`)} ${(s.stderr||s.stdout||"").trim()}`}function Uo(e,o){if(!X("claude"))return "";o&&spawnSync("claude",["mcp","remove","--scope",e,"devcoach"],{encoding:"utf8"});let t=wo(),s=spawnSync("claude",["mcp","add","--scope",e,"devcoach",t.command,"--",...t.args],{encoding:"utf8"});return s.status===0?`${a$1.green("\u2713")} Registered via \`claude mcp add\` (scope: ${e})`:`${s.stderr??""}${s.stdout??""}`.toLowerCase().includes("already")?`${a$1.yellow("Already registered")} in Claude Code (use --force to overwrite)`:`${a$1.red("claude mcp add failed:")} ${(s.stderr||s.stdout||"").trim()}`}function C(e){if(!existsSync(e))return {ok:true,data:{}};try{return {ok:!0,data:JSON.parse(readFileSync(e,"utf8"))??{}}}catch{return {ok:false,error:`${a$1.red("\u2717")} ${e} is not valid JSON \u2014 fix it and re-run (left unchanged)`}}}function le(e,o,t){let s=C(e);if(!s.ok)return s.error;let r=s.data;r.mcpServers??={};let i=r.mcpServers;return i.devcoach&&!t?`${a$1.yellow("Already registered")} in ${e} (use --force to overwrite)`:(i.devcoach=o,mkdirSync(dirname(e),{recursive:true}),writeFileSync(e,`${JSON.stringify(r,null,2)}
|
|
3
3
|
`),`${a$1.green("\u2713")} Installed into ${e}`)}function Ko(){let e=be();return {Stop:{hooks:[{type:"command",command:`${e} stop-hook`,timeout:60}]},UserPromptSubmit:{hooks:[{type:"command",command:`${e} prompt-hook`,timeout:30}]}}}function zo(){let e=be();return {AfterAgent:{hooks:[{type:"command",command:`${e} gemini-stop-hook`,timeout:6e4}]},BeforeAgent:{hooks:[{type:"command",command:`${e} gemini-prompt-hook`,timeout:3e4}]}}}function Vo(){let e=be();return {Stop:{hooks:[{type:"command",command:`${e} codex-stop-hook`,timeout:60}]},UserPromptSubmit:{hooks:[{type:"command",command:`${e} codex-prompt-hook`,timeout:30}]}}}function Co(e){return Object.entries(e.enabledPlugins??{}).filter(([o,t])=>t&&o.startsWith("devcoach@")).map(([o])=>o)}function $e(e){return Co(e).length>0}function q(){return existsSync(Fo)}function Z(e){return /dev-?coach/i.test(e)&&/\b(?:stop-hook|prompt-hook|onboard-hook|lesson-ready)\b/.test(e)}function ye(e,o){let t=C(e);if(!t.ok)return t.error;let s=t.data;s.hooks??={};let r=s.hooks,i=false;for(let[d,l]of Object.entries(o)){r[d]??=[];let m=r[d],b=m.map((u,g)=>[u,g]).filter(([u])=>(u.hooks??[]).some(g=>Z(g.command??""))).map(([,u])=>u),[p]=b;if(!(b.length===1&&p!==void 0&&JSON.stringify(m[p])===JSON.stringify(l))){for(let u of b.toReversed())m.splice(u,1);m.push(l),i=true;}}return i?(mkdirSync(dirname(e),{recursive:true}),writeFileSync(e,`${JSON.stringify(s,null,2)}
|
|
4
4
|
`),`${a$1.green("\u2713")} Hooks installed into ${e} (${Object.keys(o).join(" + ")})`):`${a$1.yellow("Already installed")} in ${e} (current layout)`}function Jo(){let e=C(I);return e.ok?$e(e.data)?`${a$1.yellow("Skipped")} \u2014 the devcoach plugin already provides the hooks (installing both would double-count interactions)`:ye(I,Ko()):e.error}function Wo(){return q()?`${a$1.yellow("Skipped")} \u2014 the devcoach Gemini extension already provides the hooks (installing both would double-count interactions)`:ye(x,zo())}function M(e){if(!existsSync(join(e,"SKILL.md")))return "missing";try{if(readFileSync(join(e,".devcoach-version"),"utf8").trim()===ha)return "current"}catch{}return "outdated"}function ge(e,o){if(!o&&M(e)==="current")return `${a$1.yellow("Already installed")} in ${e} (current version)`;mkdirSync(e,{recursive:true}),writeFileSync(join(e,"SKILL.md"),e$3());let t=f$1();if(t.length){let s=join(e,"references");mkdirSync(s,{recursive:true});for(let r of t)writeFileSync(join(s,r.name),r.content);}return writeFileSync(join(e,".devcoach-version"),`${ha}
|
|
5
5
|
`),`${a$1.green("\u2713")} Installed into ${e}`}function Yo(e){return q()?`${a$1.yellow("Skipped")} \u2014 bundled with the devcoach Gemini extension`:ge(N,e)}function P(e,o){let t=C(e);return t.ok&&(t.data.hooks?.[o]??[]).some(s=>(s.hooks??[]).some(r=>Z(r.command??"")))}function ve(){let e=[{name:"Claude Code",dir:Y,cmd:"devcoach install",hooked:()=>P(I,"Stop")},{name:"Gemini/Codex",dir:N,cmd:"devcoach install --gemini (or --codex)",hooked:()=>P(x,"AfterAgent")||P(H,"Stop")}];for(let o of e){let t=M(o.dir);if(t==="outdated")return `${a$1.yellow("\u2192")} The devcoach ${o.name} skill is out of date \u2014 run ${a$1.bold(o.cmd)} to refresh it.`;if(t==="missing"&&o.hooked())return `${a$1.yellow("\u2192")} The devcoach ${o.name} skill is not installed \u2014 run ${a$1.bold(o.cmd)} to add it.`}return ""}function So(e){let o=e.claudeCode||e.claudeDesktop||e.gemini||e.codex,t=e.claudeCode||!o,s=e.claudeDesktop||!o,r=wo(),i=false;if(c(a$1.bold("Setting up devcoach")+a$1.dim(` (${r.command} ${r.args.join(" ")})`)),c(),t){c(a$1.bold("Claude Code"));let d=Uo("user",e.force);if(!d){let l=join(homedir(),".claude.json");d=le(l,{type:"stdio",env:{},...r},e.force),i=true;}c(` MCP server\u2026 ${d}`),e.skipHook||c(` Hooks\u2026 ${Jo()}`),c(` Skill\u2026 ${ge(Y,e.force)}`),c();}if(s&&(c(a$1.bold("Claude Desktop")),c(` MCP server\u2026 ${le(yo(),r,e.force)}`),i=true,c()),e.gemini){c(a$1.bold("Gemini CLI (beta)"));let d=ho("gemini",["mcp","add","-s","user","devcoach",r.command,...r.args],e.force?["mcp","remove","-s","user","devcoach"]:null);d||(d=le(x,r,e.force)),c(` MCP server\u2026 ${d}`),e.skipHook||c(` Hooks\u2026 ${Wo()}`),c(` Skill\u2026 ${Yo(e.force)}`),c();}if(e.codex){c(a$1.bold("Codex CLI (beta)"));let d=ho("codex",["mcp","add","devcoach","--",r.command,...r.args],e.force?["mcp","remove","devcoach"]:null);d||(d=`${a$1.yellow("Manual step")} \u2014 codex CLI not found. Add to ${W}:
|
|
@@ -33,4 +33,4 @@ ${a$1.green("Setup complete!")} ${Object.keys(i).length} topics saved.`);}finall
|
|
|
33
33
|
${a$1.bold(`devcoach ${a$1.dim(`v${ha}`)}`)}`);for(let[t,s]of e)a(` ${a$1.cyan(`devcoach ${t}`.padEnd(32))} ${a$1.dim(s)}`);a(`
|
|
34
34
|
${a$1.dim("Run")} ${a$1.bold("devcoach <command> --help")} ${a$1.dim("for per-command options.")}
|
|
35
35
|
`);let o=ve();o&&a(`${o}
|
|
36
|
-
`);}function S(e){return e??null}function On(){let e$1=new Command;return e$1.exitOverride(),e$1.name("devcoach").description("devcoach \u2014 progressive technical coaching").version(`devcoach ${ha}`,"-v, --version","output the version number").allowExcessArguments(false).showHelpAfterError("(add --help for usage)").action(()=>Dn()),e$1.command("mcp").description("Start the MCP server (stdio transport)").action(async()=>{let{runStdio:o}=await import('./server-
|
|
36
|
+
`);}function S(e){return e??null}function On(){let e$1=new Command;return e$1.exitOverride(),e$1.name("devcoach").description("devcoach \u2014 progressive technical coaching").version(`devcoach ${ha}`,"-v, --version","output the version number").allowExcessArguments(false).showHelpAfterError("(add --help for usage)").action(()=>Dn()),e$1.command("mcp").description("Start the MCP server (stdio transport)").action(async()=>{let{runStdio:o}=await import('./server-HOCQWBJF.js');await o();}),e$1.command("profile").description("Show the knowledge map").action(an),e$1.command("lessons").description("List past lessons").option("--period <period>","today | week | month | year | all","all").option("--category <category>","Filter by category tag").option("--project <project>","Filter by project (fuzzy)").option("--repository <repository>","Filter by repository (fuzzy)").option("--branch <branch>","Filter by branch (fuzzy)").option("--commit <commit>","Filter by commit hash prefix (fuzzy)").option("--starred","Show only starred lessons").option("--imported","Show only lessons shared with you").option("--from <name>","Show only lessons shared by this person").option("--feedback <feedback>","know | understood | dont_know | none").option("--level <level>","junior | mid | senior").option("--date-from <date>","Show lessons on or after this date (YYYY-MM-DD[THH:MM])").option("--date-to <date>","Show lessons on or before this date (YYYY-MM-DD[THH:MM])").option("--sort <column>","timestamp | level | topic_id | title | feedback","timestamp").option("--order <order>","asc | desc","desc").action(o=>dn({period:o.period??"all",category:S(o.category),project:S(o.project),repository:S(o.repository),branch:S(o.branch),commit:S(o.commit),starred:!!o.starred,imported:!!o.imported,sharedBy:S(o.from),feedback:S(o.feedback),level:S(o.level),dateFrom:S(o.dateFrom),dateTo:S(o.dateTo),sort:o.sort??"timestamp",order:o.order??"desc"})),e$1.command("lesson").description("Show a single lesson in detail").argument("<id>","Lesson ID").action(o=>cn(o)),e$1.command("courses").description("List your step-by-step courses").action(()=>mn()),e$1.command("course").description("Show a course: steps, progress, document path").argument("<id>","Course ID").action(o=>un(o)),e$1.command("star").description("Mark a lesson as starred").argument("<id>","Lesson ID").action(o=>Lo(o,true)),e$1.command("unstar").description("Remove the starred mark from a lesson").argument("<id>","Lesson ID").action(o=>Lo(o,false)),e$1.command("delete").description("Permanently delete a lesson").argument("<id>","Lesson ID").action(o=>ln(o)),e$1.command("feedback").description("Record your answer under a lesson: know / understood / dont_know").argument("<id>","Lesson ID").argument("<value>","know | understood | dont_know | clear").action((o,t)=>pn(o,t)),e$1.command("share").description("Share a lesson: copyable text (default), --link, or a .devcoach.md file").argument("[id]","Lesson ID (or use --last)").option("--last","Share the most recent lesson").option("--link","Print the share link only").option("--file [path]","Write a .devcoach.md file (default: <lesson-id>.devcoach.md)").option("--with-context","Include project/branch/commit/task context (off by default)").option("--by <name>","Sender name (remembered as share_name when unset)").option("--anonymous","Share without a sender name").action((o,t)=>Sn(o,t)),e$1.command("import").description("Import a shared lesson: a devcoach:lesson code, a share link, a URL, a .devcoach.md or lessons .json file, - for stdin \u2014 or the clipboard when omitted").argument("[source]","Code, link, URL, file path, or - (stdin); omit to read the clipboard").action(o=>In(o)),e$1.command("settings").description("Show current settings").action(gn),e$1.command("stats").description("Coaching statistics and rate-limit status").action(fn),e$1.command("set").description("Update a setting (max_per_day | min_gap_minutes | nudge_every | nudge_scope | share_name)").argument("<key>","Setting key").argument("<value>","New value").action((o,t)=>hn(o,t)),e$1.command("knowledge-add").description("Add or update a topic in the knowledge map").argument("<topic>","Topic ID").option("--confidence <n>","Initial confidence 0-10","5").option("--group <group>","Assign to a named group").action((o,t)=>kn(o,Math.max(0,Math.min(10,Number.parseInt(t.confidence??"5",10)||5)),S(t.group))),e$1.command("knowledge-remove").description("Remove a topic from the knowledge map").argument("<topic>","Topic ID").action(o=>bn(o)),e$1.command("group-add").description("Register a new knowledge group").argument("<name>","Group name").action(o=>$n(o)),e$1.command("group-remove").description("Delete a knowledge group (topics move to Other)").argument("<name>","Group name").action(o=>yn(o)),e$1.command("group-assign").description("Move a topic to a group").argument("<topic>","Topic ID").argument("<group>","Group name (use 'Other' to ungroup)").action((o,t)=>vn(o,t)),e$1.command("backup").description("Export a full backup (settings + knowledge + lessons) as zip").argument("[file]","Output zip path","devcoach-backup.zip").action(o=>wn(o)),e$1.command("restore").description("Restore from a backup zip file").argument("<file>","Path to backup zip").action(o=>Cn(o)),e$1.command("install").description("Register the MCP server + hooks + skill in Claude Code / Claude Desktop (default), Gemini CLI (--gemini, beta), or Codex CLI (--codex, beta)").option("--claude-code","Target Claude Code only").option("--claude-desktop","Target Claude Desktop only").option("--gemini","Target Google Gemini CLI (beta)").option("--codex","Target OpenAI Codex CLI (beta)").option("--force","Overwrite existing devcoach entry").option("--skip-hook","Register MCP server only \u2014 skip the hooks").action(o=>So({claudeCode:!!o.claudeCode,claudeDesktop:!!o.claudeDesktop,gemini:!!o.gemini,codex:!!o.codex,force:!!o.force,skipHook:!!o.skipHook})),e$1.command("uninstall").description("Remove devcoach's MCP server, hooks and skill from Claude Code / Claude Desktop (default), Gemini CLI (--gemini), Codex CLI (--codex) or every agent (--all). Coaching data is kept unless --data is given. Run it before brew/npm uninstall.").option("--claude-code","Target Claude Code only").option("--claude-desktop","Target Claude Desktop only").option("--gemini","Also remove from Google Gemini CLI (beta)").option("--codex","Also remove from OpenAI Codex CLI (beta)").option("--all","Every agent: Claude Code, Claude Desktop, Gemini CLI, Codex CLI").option("--data","Also delete ~/.devcoach (lessons, profile, notebook) \u2014 asks first").option("--yes","Do not ask before deleting the data (with --data)").action(async o=>xo({claudeCode:!!o.claudeCode,claudeDesktop:!!o.claudeDesktop,gemini:!!o.gemini,codex:!!o.codex,all:!!o.all,data:!!o.data,yes:!!o.yes})),e$1.command("doctor").description("Diagnose the devcoach \u21C4 agent wiring and the lesson pacing state").action(_o),e$1.command("ui").description("Launch the web dashboard (Ctrl+C stops it gracefully; --stop stops a running one)").option("--port <port>","Port","7860").option("-o, --open","Open the dashboard in your default browser").option("--stop","Stop the dashboard running on --port (e.g. one started by your agent)").action(async o=>{let t=Number.parseInt(o.port??"7860",10)||7860,{startUi:s,stopUi:r}=await import('./app-HTTMWUAK.js');if(o.stop){a(await r(t)?a$1.green(`\u2713 devcoach UI on port ${t} stopped`):a$1.yellow(`No devcoach UI is running on port ${t}`));return}s(t,{onReady:i=>{o.open&&Se(i);},onListenError:i=>{console.error(i.message),o.open&&i.existingUrl&&Se(i.existingUrl),process.exit(i.exitCode);}});}),e$1.command("setup").description("First-run wizard: import backup or build your knowledge profile").action(Ln),e$1.command("stop-hook",{hidden:true}).description("Claude Code Stop hook: onboarding check + lesson cue in one spawn").action(()=>e()),e$1.command("prompt-hook",{hidden:true}).description("Claude Code UserPromptSubmit hook: prime the model when a lesson is due").action(()=>g()),e$1.command("gemini-stop-hook",{hidden:true}).description("Gemini CLI AfterAgent hook: onboarding check + lesson cue in one spawn").action(()=>e(void 0,"gemini")),e$1.command("gemini-prompt-hook",{hidden:true}).description("Gemini CLI BeforeAgent hook: prime the model when a lesson is due").action(()=>g(void 0,"gemini")),e$1.command("codex-stop-hook",{hidden:true}).description("Codex CLI Stop hook: onboarding check + lesson cue in one spawn").action(()=>e(void 0,"codex")),e$1.command("codex-prompt-hook",{hidden:true}).description("Codex CLI UserPromptSubmit hook: prime the model when a lesson is due").action(()=>g(void 0,"codex")),e$1.command("onboard-hook",{hidden:true}).description("Claude Code Stop hook: cue onboarding (legacy two-entry layout)").action(()=>b()),e$1.command("lesson-ready",{hidden:true}).description("Claude Code Stop hook: signal a lesson is due (legacy two-entry layout)").action(()=>d()),e$1}async function st(){let e=On();try{await e.parseAsync(process.argv);}catch(o){let t=o.code??"";if(!t.startsWith("commander."))throw o;if(t==="commander.helpDisplayed"||t==="commander.help"||t==="commander.version")return;process.exit(2);}}export{st as runCli};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export{c as buildLessonCue,f as buildPromptPrime,d as cmdLessonReady,b as cmdOnboardHook,g as cmdPromptHook,e as cmdStopHook,a as parseHookPayload,h as runHook}from'./chunk-
|
|
2
|
+
export{c as buildLessonCue,f as buildPromptPrime,d as cmdLessonReady,b as cmdOnboardHook,g as cmdPromptHook,e as cmdStopHook,a as parseHookPayload,h as runHook}from'./chunk-X67QSFUJ.js';import'./chunk-2M2WL7AV.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {d as d$2,f as f$2,e as e$1,c as c$2,b as b$3,a as a$2}from'./chunk-MRABMPXO.js';import {o,n as n$1,p,q,b as b$2,f as f$1,d as d$3,c as c$1,i as i$1,g as g$1,j as j$1,k as k$1,h as h$1}from'./chunk-MVDKK7RW.js';import {a as a$1,c,b as b$1,g,f,e,ha,u,U,k,v,Q,ua,x,A,y,va,S,d as d$1,H,L,I,J,K,r,s,ta,n,E,ka,N,ja,qa,ra,oa,na,la,xa,ia,j,i,h,wa,ya,w,sa,O,T,q as q$1}from'./chunk-OLKQYTMC.js';import {spawn}from'child_process';import {mkdirSync,existsSync,statSync,writeFileSync,readFileSync}from'fs';import {dirname}from'path';import {McpServer,ResourceTemplate}from'@modelcontextprotocol/server';import {StdioServerTransport}from'@modelcontextprotocol/server/stdio';import {z}from'zod';var d=r=>({type:"text",text:r}),Ae=r=>({content:[d(JSON.stringify(r))]}),a=r=>({isError:true,content:[d(r)]}),b=r=>({content:[d(JSON.stringify(r))],structuredContent:r}),Fe=z.object({id:z.string(),timestamp:z.string(),topic_id:z.string(),categories:z.array(z.string()),title:z.string(),level:a$1,summary:z.string(),body:z.string().nullable(),task_context:z.string().nullable(),project:z.string().nullable(),repository:z.string().nullable(),branch:z.string().nullable(),commit_hash:z.string().nullable(),folder:z.string().nullable(),repository_platform:b$1.nullable(),starred:z.boolean(),feedback:c.nullable(),imported:z.boolean(),shared_by:z.string().nullable()}),Ye=Fe.extend({reply_check:z.string()}),Ne="Saved \u2014 but saving does NOT display anything. The user sees ONLY plain text you write in your reply; the title/body inside this tool call's ARGUMENTS are invisible to them, and having composed them does not count as having shown the card. Did you already write the full card (both ### band headings + title line + body + tip) as plain reply text, outside any tool call? If yes: output nothing. If no: write the card now, as the final text of your reply. Never write it twice.",Pe=z.object({knowledge:z.array(z.object({topic:z.string(),confidence:z.number().int()})),groups:z.array(z.object({name:z.string(),topics:z.array(z.string())}))}),Ve=z.object({max_per_day:z.number().int(),min_gap_minutes:z.number().int(),ui_theme:e,ui_home:f,nudge_every:z.number().int(),nudge_scope:g,share_name:z.string().nullable()}),Xe=z.object({transport:z.enum(["text","link","file"]),code:z.string(),text:z.string().nullable(),link:z.string().nullable(),markdown:z.string().nullable(),filename:z.string().nullable(),shared_by:z.string().nullable(),include_context:z.boolean(),reply_check:z.string()}),Qe=z.object({kind:z.enum(["shared","lessons"]),inserted:z.number().int(),duplicated:z.number().int(),invalid:z.number().int(),lesson:Fe.nullable(),topic_tracked:z.boolean().nullable(),reply_check:z.string()}),Ze={text:"Reply with `text` verbatim as the final message: the card as markdown, then the last line (devcoach:lesson:1:\u2026) inside a fenced code block, character for character \u2014 never paraphrase, wrap, truncate or split it.",link:"Reply with `link` on its own line, unchanged.",file:"Write `markdown` to `filename` (in the workspace unless the user named a path) with your file tool, then confirm the path in one line; do not print the markdown."},et="Confirm in one line: the title, who shared it, and that it joined the coaching log (feedback works as usual; it does not count against the daily limit). If topic_tracked is false, offer to track the topic with add_topic \u2014 only on confirmation.",tt=z.object({window_months:z.number().int(),cutoff:z.string(),candidate_count:z.number().int(),over_soft_limit:z.boolean(),candidates:z.array(z.object({name:z.string(),path:z.string(),last_activity:z.string().nullable(),prompt_count:z.number().int()}))});function l(r,u){return {contents:[{uri:r.href,mimeType:"application/json",text:JSON.stringify(u)}]}}function Ie(){try{return {...u(r=>ta(r))}}catch(r){return {error:String(r)}}}function $e(){try{let r="";try{existsSync(n)&&(r=readFileSync(n,"utf8"));}catch{}return {...u(m=>{let g=T(m).knowledge_ready,f=r.length>0,p=sa(m),t={allowed:p.allowed,total_lessons:w(m)};return p.reason!=null&&(t.reason=p.reason),{onboarding:{knowledge_ready:g,notebook_ready:f,needs_onboarding:!(g&&f)},rate_limit:t,taught_topics:ya(m),profile:ta(m)}}),notebook:r,notebook_path:n}}catch(r){return {error:String(r)}}}function Ue(){try{let u$1=u(t=>T(t)).knowledge_ready,m=existsSync(n)&&statSync(n).size>0,g=o(),f=c$2(),p=b$3(a$2(g.folder??process.cwd()),f.detected_stack);return {knowledge_ready:u$1,notebook_ready:m,needs_onboarding:!(u$1&&m),detected_stack:p,detected_projects:f.projects,scanned_projects:f.scanned_projects,default_topics:q$1,context_ready:g.branch!==null,notebook_path:n}}catch(r){return {error:String(r)}}}var W=(r,u)=>typeof u.error=="string"?a(`${r} failed: ${u.error}`):b(u);function nt(){let r$1=new McpServer({name:"devcoach",version:ha},{instructions:"Progressive technical coaching server. Use the devcoach_instructions prompt for full coaching behaviour guidelines. Read coaching state with the get_briefing / get_onboarding / get_profile tools; the devcoach:// resources expose the same data for clients that browse resources. share_lesson hands a lesson to another person (text, link or file); import_lesson stores one they were given."});r$1.registerTool("log_lesson",{title:"Log Lesson",description:"Save a delivered lesson to the coaching log. Git metadata (project, repository, branch, commit_hash, folder, repository_platform) is auto-detected from the workspace when omitted. timestamp is always stamped server-side with the current time \u2014 there is no argument for it. Returns the saved Lesson with all resolved fields.",inputSchema:z.object({id:z.string().describe("Unique lesson id (uuid or random string)"),topic_id:z.string().describe("Primary topic id, e.g. 'python'"),categories:z.array(z.string()).describe("Category tags, e.g. ['python','performance']"),title:z.string().describe("Short lesson title"),level:a$1.describe("Difficulty level: junior | mid | senior"),summary:z.string().describe("1-3 sentence summary shown in the lesson card"),body:z.string().min(1).describe("Clean lesson markdown: the prose + \u{1F4A1} Senior tip only \u2014 NO card bands, NO '>' blockquote, and do not repeat title/category/level (those are their own fields). Required, non-empty."),task_context:z.string().nullish().describe("What the user was doing when taught"),project:z.string().nullish().describe("Project name (auto-detected from git if omitted)"),repository:z.string().nullish().describe("org/repo or path (auto-detected if omitted)"),branch:z.string().nullish().describe("git branch (auto-detected if omitted)"),commit_hash:z.string().nullish().describe("git commit hash (auto-detected if omitted)"),folder:z.string().nullish().describe("workspace folder (auto-detected if omitted)"),repository_platform:b$1.nullish().describe("github | gitlab | bitbucket | local (auto-detected if omitted)")}),outputSchema:Ye,annotations:{title:"Log Lesson",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async t=>{try{let n=o(),o$1={};try{o$1=u(c=>U(c));}catch{o$1={};}let i=k({id:t.id,timestamp:new Date,topic_id:t.topic_id,categories:t.categories,title:t.title,level:t.level,summary:t.summary,body:t.body,task_context:t.task_context??null,project:t.project??n.project??o$1.project??null,repository:t.repository??n.repository??o$1.repository??null,branch:t.branch??n.branch??o$1.branch??null,commit_hash:t.commit_hash??n.commit_hash??null,folder:t.folder??n.folder??null,repository_platform:t.repository_platform??n.repository_platform??o$1.repository_platform??null});return u(c=>{v(c,i),Q(c);}),{content:[d(`Lesson saved. ${Ne}`),d(JSON.stringify(i))],structuredContent:{...i,reply_check:Ne}}}catch(n){return a(`log_lesson failed: ${n}`)}}),r$1.registerTool("update_knowledge",{title:"Update Knowledge",description:"Adjust the confidence score for a topic by delta (e.g. +1 or -1). Returns the new confidence (0-10). Creates the topic at confidence 5 if it does not exist.",inputSchema:z.object({topic:z.string().describe("Topic id, e.g. 'python'"),delta:z.number().int().describe("Signed change to apply, e.g. +1 or -1")}),annotations:{title:"Update Knowledge",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async t=>{try{let n=u(o=>ua(o,t.topic,t.delta));return {content:[d(String(n))]}}catch(n){return a(`update_knowledge failed for '${t.topic}': ${n}`)}}),r$1.registerTool("get_lessons",{title:"Get Lessons",description:"Query the coaching lesson history. All filters combine. period defaults to all; date_from/date_to override period; limit caps results newest-first (0 = all).",inputSchema:z.object({period:z.enum(["today","week","month","year","all"]).nullish().describe("Time window"),category:z.string().nullish().describe("Filter by a category tag, e.g. 'python'"),level:z.enum(["junior","mid","senior"]).nullish().describe("Filter by difficulty level"),project:z.string().nullish().describe("Fuzzy match on git project"),repository:z.string().nullish().describe("Fuzzy match on git repository"),branch:z.string().nullish().describe("Fuzzy match on git branch"),commit:z.string().nullish().describe("Fuzzy match on commit hash"),starred:z.boolean().nullish().describe("True to return only starred lessons"),imported:z.boolean().nullish().describe("True = only lessons shared with you, false = only your own"),shared_by:z.string().nullish().describe("Only lessons shared by this person (exact sender name; implies imported)"),feedback:z.enum(["know","understood","dont_know","none"]).nullish().describe("Filter by feedback: know (already knew), understood (new, now clear), dont_know (couldn't follow \u2014 a course seed), none (no response)"),search:z.string().nullish().describe("Full-text search over title, topic_id, summary, body and the sender's name"),date_from:z.string().nullish().describe("ISO date/datetime lower bound"),date_to:z.string().nullish().describe("ISO date/datetime upper bound (date-only = end-of-day)"),limit:z.number().int().default(10).describe("Max lessons, newest first. Pass 0 for all.")}),annotations:{title:"Get Lessons",readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false}},t=>{try{let n=u(o=>x(o,{period:t.period,category:t.category,level:t.level,project:t.project,repository:t.repository,branch:t.branch,commit:t.commit,starred:t.starred,imported:t.imported,shared_by:t.shared_by,feedback:t.feedback,search:t.search,date_from:t.date_from,date_to:t.date_to,page:t.limit>0?1:null,per_page:t.limit}));return Ae(n)}catch{return Ae([])}}),r$1.registerTool("star_lesson",{title:"Star Lesson",description:"Set the starred (favourite) flag on a lesson. Returns true if found and updated. Idempotent.",inputSchema:z.object({lesson_id:z.string().describe("Lesson id"),starred:z.boolean().describe("true to favourite, false to unmark")}),annotations:{title:"Star Lesson",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async t=>{try{let n=u(o=>A(o,t.lesson_id,t.starred));return {content:[d(String(n))]}}catch(n){return a(`star_lesson failed for '${t.lesson_id}': ${n}`)}}),r$1.registerTool("delete_lesson",{title:"Delete Lesson",description:"Permanently delete a lesson by id. Returns true if found and deleted.",inputSchema:z.object({lesson_id:z.string().describe("Lesson id to delete")}),annotations:{title:"Delete Lesson",destructiveHint:true,idempotentHint:true,openWorldHint:false}},async t=>{try{let n=u(o=>y(o,t.lesson_id));return {content:[d(String(n))]}}catch(n){return a(`delete_lesson failed for '${t.lesson_id}': ${n}`)}}),r$1.registerTool("submit_feedback",{title:"Submit Feedback",description:"Record the user's answer under a lesson card. know = already knew it (confidence +1); understood = new and now clear (no confidence change); dont_know = couldn't follow this session (no confidence change; the lesson becomes a course seed); clear = remove the answer. Idempotent \u2014 repeating the stored answer changes nothing.",inputSchema:z.object({lesson_id:z.string().describe("Lesson id"),feedback:z.enum(["know","understood","dont_know","clear"]).describe("know | understood | dont_know | clear")}),annotations:{title:"Submit Feedback",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async t=>{try{let n=t.feedback==="clear"?null:t.feedback,o=u(i=>va(i,t.lesson_id,n));return {content:[d(String(o!==null))]}}catch(n){return a(`submit_feedback failed for '${t.lesson_id}': ${n}`)}}),r$1.registerTool("skip_lesson",{title:"Skip Lesson",description:"Decline a lesson cue: call this when the coaching hook asked for a lesson but the completed work does not warrant one (pure questions, chat, nothing technical). Re-arms the pacing counter so the cue is not repeated immediately. Never call it after delivering a lesson \u2014 log_lesson already resolves the cue.",inputSchema:z.object({reason:z.string().min(1).describe("One line: why no lesson was warranted (shown in `devcoach doctor`)")}),annotations:{title:"Skip Lesson",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async t=>{try{return u(n=>S(n,t.reason)),{content:[d("Cue skipped \u2014 pacing re-armed. Output nothing to the user.")]}}catch(n){return a(`skip_lesson failed: ${n}`)}}),r$1.registerTool("add_topic",{title:"Add Topic",description:"Add a topic to the knowledge map, or update its confidence if it exists. Optionally assign to a group (auto-created). Prefer a single-word topic id. Idempotent.",inputSchema:z.object({topic:z.string().describe("Topic id \u2014 prefer a single word, max 3 words"),confidence:d$1.default(5).describe("Initial confidence 0-10 (default 5)"),group:z.string().nullish().describe("Optional group name; 'Other' if omitted")}),annotations:{title:"Add Topic",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async t=>{try{return u(n=>{H(n,t.topic,t.confidence),t.group&&t.group!=="Other"&&L(n,t.topic,t.group);}),{content:[d("true")]}}catch(n){return a(`add_topic failed for '${t.topic}': ${n}`)}}),r$1.registerTool("remove_topic",{title:"Remove Topic",description:"Remove a topic from the knowledge map entirely. Returns true if it existed.",inputSchema:z.object({topic:z.string().describe("Topic id to remove")}),annotations:{title:"Remove Topic",destructiveHint:true,idempotentHint:true,openWorldHint:false}},async t=>{try{let n=u(o=>I(o,t.topic));return {content:[d(String(n))]}}catch(n){return a(`remove_topic failed for '${t.topic}': ${n}`)}}),r$1.registerTool("add_group",{title:"Add Group",description:"Create a new (initially empty) knowledge group. Idempotent \u2014 returns true either way.",inputSchema:z.object({name:z.string().describe("Group name, e.g. 'Machine Learning'")}),annotations:{title:"Add Group",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async t=>{try{return u(n=>J(n,t.name.trim())),{content:[d("true")]}}catch(n){return a(`add_group failed for '${t.name}': ${n}`)}}),r$1.registerTool("remove_group",{title:"Remove Group",description:"Delete a knowledge group. Its topics move to Other. Returns true if it existed.",inputSchema:z.object({name:z.string().describe("Group name to delete")}),annotations:{title:"Remove Group",destructiveHint:true,idempotentHint:true,openWorldHint:false}},async t=>{try{let n=u(o=>K(o,t.name));return {content:[d(String(n))]}}catch(n){return a(`remove_group failed for '${t.name}': ${n}`)}}),r$1.registerTool("update_settings",{title:"Update Settings",description:"Update a coaching setting. max_per_day: integer 1-20. min_gap_minutes: integer 0-1440 (0 = no cooldown). nudge_every: integer 0-1000 interactions between lesson cues (0 = cue every turn). nudge_scope: 'session' | 'global'. share_name: the sender name proposed when sharing a lesson (max 80 chars, empty clears). Returns the full updated Settings.",inputSchema:z.object({key:z.enum(["max_per_day","min_gap_minutes","nudge_every","nudge_scope","share_name"]).describe("Setting key"),value:z.string().describe("New value (integer string; 'session'|'global' for nudge_scope; free text for share_name)")}),outputSchema:Ve,annotations:{title:"Update Settings",destructiveHint:false,idempotentHint:true,openWorldHint:false}},t=>{let n=i=>b(u(c=>(O(c,t.key,i),N(c))));if(t.key==="share_name")return t.value.trim().length>r?a(`share_name must be at most ${r} characters`):n(s(t.value));if(t.key==="nudge_scope")return t.value!=="session"&&t.value!=="global"?a("nudge_scope must be 'session' or 'global'"):n(t.value);let o=Number.parseInt(t.value,10);return Number.isNaN(o)?a(`Value must be an integer, got '${t.value}'`):t.key==="max_per_day"&&!(o>=1&&o<=20)?a("max_per_day must be between 1 and 20"):t.key==="min_gap_minutes"&&!(o>=0&&o<=1440)?a("min_gap_minutes must be between 0 and 1440"):t.key==="nudge_every"&&!(o>=0&&o<=1e3)?a("nudge_every must be between 0 and 1000"):n(String(o))}),r$1.registerTool("open_ui",{title:"Open UI",description:"Launch the devcoach web dashboard in the background. port must be 1024-65535.",inputSchema:z.object({port:z.number().int().default(7860).describe("Port (default 7860)")}),annotations:{title:"Open UI",destructiveHint:false,idempotentHint:false,openWorldHint:true}},async t=>{let n=t.port;if(!(n>=1024&&n<=65535))return {content:[d(`error: port ${n} is out of valid range (1024-65535)`)]};let{pingUi:o}=await import('./app-PFGHB3PE.js');return await o(n)?{content:[d(`devcoach UI is already running at http://localhost:${n}`)]}:(spawn(process.execPath,[process.argv[1]??"","ui","--port",String(n)],{detached:true,stdio:"ignore"}).unref(),{content:[d(`devcoach UI starting at http://localhost:${n}`)]})}),r$1.registerTool("stop_ui",{title:"Stop UI",description:"Stop the devcoach web dashboard listening on port (whoever started it \u2014 open_ui or a terminal). Graceful: in-flight requests finish first. Reports stopped=false when nothing is running there. port must be 1024-65535.",inputSchema:z.object({port:z.number().int().default(7860).describe("Port (default 7860)")}),annotations:{title:"Stop UI",destructiveHint:false,idempotentHint:true,openWorldHint:true}},async t=>{let n=t.port;if(!(n>=1024&&n<=65535))return {content:[d(`error: port ${n} is out of valid range (1024-65535)`)]};let{stopUi:o}=await import('./app-PFGHB3PE.js'),i=await o(n);return {content:[d(i?`devcoach UI on port ${n} stopped`:`No devcoach UI is running on port ${n}`)],structuredContent:{stopped:i,port:n}}}),r$1.registerTool("complete_onboarding",{title:"Complete Onboarding",description:"Save the user's initial knowledge profile and mark onboarding complete. Wipes any default-seeded profile. topics: {topic_id: confidence_0_to_10}. groups: {group_name: [topic_id,...]} (topics not in any group go to 'Other'). Ensures learning-state.md exists and is non-empty (a placeholder if needed) \u2014 there is no notebook argument here. Write the real personalized notebook yourself right after, directly to the path in devcoach://onboarding's notebook_path field. Returns the updated Profile.",inputSchema:z.object({topics:z.record(z.string(),d$1).describe("{topic_id: confidence 0-10}"),groups:z.record(z.string(),z.array(z.string())).optional().describe("{group_name: [topic_id, ...]}")}),outputSchema:Pe,annotations:{title:"Complete Onboarding",destructiveHint:true,idempotentHint:false,openWorldHint:false}},async t=>{try{let n$1=u(o=>{o.exec("DELETE FROM knowledge; DELETE FROM knowledge_groups; DELETE FROM knowledge_group_names;");for(let[i,c]of Object.entries(t.topics))H(o,i,Math.max(0,Math.min(10,c)));if(t.groups)for(let[i,c]of Object.entries(t.groups))for(let F of c)F in t.topics&&L(o,F,i);return ta(o)});return mkdirSync(dirname(n),{recursive:!0}),(!existsSync(n)||statSync(n).size===0)&&writeFileSync(n,`# devcoach \u2014 Coaching Notebook
|
|
2
|
+
import {d as d$2,f as f$2,e as e$1,c as c$2,b as b$3,a as a$2}from'./chunk-MRABMPXO.js';import {o,n as n$1,p,q,b as b$2,f as f$1,d as d$3,c as c$1,i as i$1,g as g$1,j as j$1,k as k$1,h as h$1}from'./chunk-U2NGRAGG.js';import {a as a$1,c,b as b$1,g,f,e,ha,u,U,k,v,Q,ua,x,A,y,va,S,d as d$1,H,L,I,J,K,r,s,ta,n,E,ka,N,ja,qa,ra,oa,na,la,xa,ia,j,i,h,wa,ya,w,sa,O,T,q as q$1}from'./chunk-2M2WL7AV.js';import {spawn}from'child_process';import {mkdirSync,existsSync,statSync,writeFileSync,readFileSync}from'fs';import {dirname}from'path';import {McpServer,ResourceTemplate}from'@modelcontextprotocol/server';import {StdioServerTransport}from'@modelcontextprotocol/server/stdio';import {z}from'zod';var d=r=>({type:"text",text:r}),Ae=r=>({content:[d(JSON.stringify(r))]}),a=r=>({isError:true,content:[d(r)]}),b=r=>({content:[d(JSON.stringify(r))],structuredContent:r}),Fe=z.object({id:z.string(),timestamp:z.string(),topic_id:z.string(),categories:z.array(z.string()),title:z.string(),level:a$1,summary:z.string(),body:z.string().nullable(),task_context:z.string().nullable(),project:z.string().nullable(),repository:z.string().nullable(),branch:z.string().nullable(),commit_hash:z.string().nullable(),folder:z.string().nullable(),repository_platform:b$1.nullable(),starred:z.boolean(),feedback:c.nullable(),imported:z.boolean(),shared_by:z.string().nullable()}),Ye=Fe.extend({reply_check:z.string()}),Ne="Saved \u2014 but saving does NOT display anything. The user sees ONLY plain text you write in your reply; the title/body inside this tool call's ARGUMENTS are invisible to them, and having composed them does not count as having shown the card. Did you already write the full card (both ### band headings + title line + body + tip) as plain reply text, outside any tool call? If yes: output nothing. If no: write the card now, as the final text of your reply. Never write it twice.",Pe=z.object({knowledge:z.array(z.object({topic:z.string(),confidence:z.number().int()})),groups:z.array(z.object({name:z.string(),topics:z.array(z.string())}))}),Ve=z.object({max_per_day:z.number().int(),min_gap_minutes:z.number().int(),ui_theme:e,ui_home:f,nudge_every:z.number().int(),nudge_scope:g,share_name:z.string().nullable()}),Xe=z.object({transport:z.enum(["text","link","file"]),code:z.string(),text:z.string().nullable(),link:z.string().nullable(),markdown:z.string().nullable(),filename:z.string().nullable(),shared_by:z.string().nullable(),include_context:z.boolean(),reply_check:z.string()}),Qe=z.object({kind:z.enum(["shared","lessons"]),inserted:z.number().int(),duplicated:z.number().int(),invalid:z.number().int(),lesson:Fe.nullable(),topic_tracked:z.boolean().nullable(),reply_check:z.string()}),Ze={text:"Reply with `text` verbatim as the final message: the card as markdown, then the last line (devcoach:lesson:1:\u2026) inside a fenced code block, character for character \u2014 never paraphrase, wrap, truncate or split it.",link:"Reply with `link` on its own line, unchanged.",file:"Write `markdown` to `filename` (in the workspace unless the user named a path) with your file tool, then confirm the path in one line; do not print the markdown."},et="Confirm in one line: the title, who shared it, and that it joined the coaching log (feedback works as usual; it does not count against the daily limit). If topic_tracked is false, offer to track the topic with add_topic \u2014 only on confirmation.",tt=z.object({window_months:z.number().int(),cutoff:z.string(),candidate_count:z.number().int(),over_soft_limit:z.boolean(),candidates:z.array(z.object({name:z.string(),path:z.string(),last_activity:z.string().nullable(),prompt_count:z.number().int()}))});function l(r,u){return {contents:[{uri:r.href,mimeType:"application/json",text:JSON.stringify(u)}]}}function Ie(){try{return {...u(r=>ta(r))}}catch(r){return {error:String(r)}}}function $e(){try{let r="";try{existsSync(n)&&(r=readFileSync(n,"utf8"));}catch{}return {...u(m=>{let g=T(m).knowledge_ready,f=r.length>0,p=sa(m),t={allowed:p.allowed,total_lessons:w(m)};return p.reason!=null&&(t.reason=p.reason),{onboarding:{knowledge_ready:g,notebook_ready:f,needs_onboarding:!(g&&f)},rate_limit:t,taught_topics:ya(m),profile:ta(m)}}),notebook:r,notebook_path:n}}catch(r){return {error:String(r)}}}function Ue(){try{let u$1=u(t=>T(t)).knowledge_ready,m=existsSync(n)&&statSync(n).size>0,g=o(),f=c$2(),p=b$3(a$2(g.folder??process.cwd()),f.detected_stack);return {knowledge_ready:u$1,notebook_ready:m,needs_onboarding:!(u$1&&m),detected_stack:p,detected_projects:f.projects,scanned_projects:f.scanned_projects,default_topics:q$1,context_ready:g.branch!==null,notebook_path:n}}catch(r){return {error:String(r)}}}var W=(r,u)=>typeof u.error=="string"?a(`${r} failed: ${u.error}`):b(u);function nt(){let r$1=new McpServer({name:"devcoach",version:ha},{instructions:"Progressive technical coaching server. Use the devcoach_instructions prompt for full coaching behaviour guidelines. Read coaching state with the get_briefing / get_onboarding / get_profile tools; the devcoach:// resources expose the same data for clients that browse resources. share_lesson hands a lesson to another person (text, link or file); import_lesson stores one they were given."});r$1.registerTool("log_lesson",{title:"Log Lesson",description:"Save a delivered lesson to the coaching log. Git metadata (project, repository, branch, commit_hash, folder, repository_platform) is auto-detected from the workspace when omitted. timestamp is always stamped server-side with the current time \u2014 there is no argument for it. Returns the saved Lesson with all resolved fields.",inputSchema:z.object({id:z.string().describe("Unique lesson id (uuid or random string)"),topic_id:z.string().describe("Primary topic id, e.g. 'python'"),categories:z.array(z.string()).describe("Category tags, e.g. ['python','performance']"),title:z.string().describe("Short lesson title"),level:a$1.describe("Difficulty level: junior | mid | senior"),summary:z.string().describe("1-3 sentence summary shown in the lesson card"),body:z.string().min(1).describe("Clean lesson markdown: the prose + \u{1F4A1} Senior tip only \u2014 NO card bands, NO '>' blockquote, and do not repeat title/category/level (those are their own fields). Required, non-empty."),task_context:z.string().nullish().describe("What the user was doing when taught"),project:z.string().nullish().describe("Project name (auto-detected from git if omitted)"),repository:z.string().nullish().describe("org/repo or path (auto-detected if omitted)"),branch:z.string().nullish().describe("git branch (auto-detected if omitted)"),commit_hash:z.string().nullish().describe("git commit hash (auto-detected if omitted)"),folder:z.string().nullish().describe("workspace folder (auto-detected if omitted)"),repository_platform:b$1.nullish().describe("github | gitlab | bitbucket | local (auto-detected if omitted)")}),outputSchema:Ye,annotations:{title:"Log Lesson",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async t=>{try{let n=o(),o$1={};try{o$1=u(c=>U(c));}catch{o$1={};}let i=k({id:t.id,timestamp:new Date,topic_id:t.topic_id,categories:t.categories,title:t.title,level:t.level,summary:t.summary,body:t.body,task_context:t.task_context??null,project:t.project??n.project??o$1.project??null,repository:t.repository??n.repository??o$1.repository??null,branch:t.branch??n.branch??o$1.branch??null,commit_hash:t.commit_hash??n.commit_hash??null,folder:t.folder??n.folder??null,repository_platform:t.repository_platform??n.repository_platform??o$1.repository_platform??null});return u(c=>{v(c,i),Q(c);}),{content:[d(`Lesson saved. ${Ne}`),d(JSON.stringify(i))],structuredContent:{...i,reply_check:Ne}}}catch(n){return a(`log_lesson failed: ${n}`)}}),r$1.registerTool("update_knowledge",{title:"Update Knowledge",description:"Adjust the confidence score for a topic by delta (e.g. +1 or -1). Returns the new confidence (0-10). Creates the topic at confidence 5 if it does not exist.",inputSchema:z.object({topic:z.string().describe("Topic id, e.g. 'python'"),delta:z.number().int().describe("Signed change to apply, e.g. +1 or -1")}),annotations:{title:"Update Knowledge",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async t=>{try{let n=u(o=>ua(o,t.topic,t.delta));return {content:[d(String(n))]}}catch(n){return a(`update_knowledge failed for '${t.topic}': ${n}`)}}),r$1.registerTool("get_lessons",{title:"Get Lessons",description:"Query the coaching lesson history. All filters combine. period defaults to all; date_from/date_to override period; limit caps results newest-first (0 = all).",inputSchema:z.object({period:z.enum(["today","week","month","year","all"]).nullish().describe("Time window"),category:z.string().nullish().describe("Filter by a category tag, e.g. 'python'"),level:z.enum(["junior","mid","senior"]).nullish().describe("Filter by difficulty level"),project:z.string().nullish().describe("Fuzzy match on git project"),repository:z.string().nullish().describe("Fuzzy match on git repository"),branch:z.string().nullish().describe("Fuzzy match on git branch"),commit:z.string().nullish().describe("Fuzzy match on commit hash"),starred:z.boolean().nullish().describe("True to return only starred lessons"),imported:z.boolean().nullish().describe("True = only lessons shared with you, false = only your own"),shared_by:z.string().nullish().describe("Only lessons shared by this person (exact sender name; implies imported)"),feedback:z.enum(["know","understood","dont_know","none"]).nullish().describe("Filter by feedback: know (already knew), understood (new, now clear), dont_know (couldn't follow \u2014 a course seed), none (no response)"),search:z.string().nullish().describe("Full-text search over title, topic_id, summary, body and the sender's name"),date_from:z.string().nullish().describe("ISO date/datetime lower bound"),date_to:z.string().nullish().describe("ISO date/datetime upper bound (date-only = end-of-day)"),limit:z.number().int().default(10).describe("Max lessons, newest first. Pass 0 for all.")}),annotations:{title:"Get Lessons",readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false}},t=>{try{let n=u(o=>x(o,{period:t.period,category:t.category,level:t.level,project:t.project,repository:t.repository,branch:t.branch,commit:t.commit,starred:t.starred,imported:t.imported,shared_by:t.shared_by,feedback:t.feedback,search:t.search,date_from:t.date_from,date_to:t.date_to,page:t.limit>0?1:null,per_page:t.limit}));return Ae(n)}catch{return Ae([])}}),r$1.registerTool("star_lesson",{title:"Star Lesson",description:"Set the starred (favourite) flag on a lesson. Returns true if found and updated. Idempotent.",inputSchema:z.object({lesson_id:z.string().describe("Lesson id"),starred:z.boolean().describe("true to favourite, false to unmark")}),annotations:{title:"Star Lesson",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async t=>{try{let n=u(o=>A(o,t.lesson_id,t.starred));return {content:[d(String(n))]}}catch(n){return a(`star_lesson failed for '${t.lesson_id}': ${n}`)}}),r$1.registerTool("delete_lesson",{title:"Delete Lesson",description:"Permanently delete a lesson by id. Returns true if found and deleted.",inputSchema:z.object({lesson_id:z.string().describe("Lesson id to delete")}),annotations:{title:"Delete Lesson",destructiveHint:true,idempotentHint:true,openWorldHint:false}},async t=>{try{let n=u(o=>y(o,t.lesson_id));return {content:[d(String(n))]}}catch(n){return a(`delete_lesson failed for '${t.lesson_id}': ${n}`)}}),r$1.registerTool("submit_feedback",{title:"Submit Feedback",description:"Record the user's answer under a lesson card. know = already knew it (confidence +1); understood = new and now clear (no confidence change); dont_know = couldn't follow this session (no confidence change; the lesson becomes a course seed); clear = remove the answer. Idempotent \u2014 repeating the stored answer changes nothing.",inputSchema:z.object({lesson_id:z.string().describe("Lesson id"),feedback:z.enum(["know","understood","dont_know","clear"]).describe("know | understood | dont_know | clear")}),annotations:{title:"Submit Feedback",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async t=>{try{let n=t.feedback==="clear"?null:t.feedback,o=u(i=>va(i,t.lesson_id,n));return {content:[d(String(o!==null))]}}catch(n){return a(`submit_feedback failed for '${t.lesson_id}': ${n}`)}}),r$1.registerTool("skip_lesson",{title:"Skip Lesson",description:"Decline a lesson cue: call this when the coaching hook asked for a lesson but the completed work does not warrant one (pure questions, chat, nothing technical). Re-arms the pacing counter so the cue is not repeated immediately. Never call it after delivering a lesson \u2014 log_lesson already resolves the cue.",inputSchema:z.object({reason:z.string().min(1).describe("One line: why no lesson was warranted (shown in `devcoach doctor`)")}),annotations:{title:"Skip Lesson",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async t=>{try{return u(n=>S(n,t.reason)),{content:[d("Cue skipped \u2014 pacing re-armed. Output nothing to the user.")]}}catch(n){return a(`skip_lesson failed: ${n}`)}}),r$1.registerTool("add_topic",{title:"Add Topic",description:"Add a topic to the knowledge map, or update its confidence if it exists. Optionally assign to a group (auto-created). Prefer a single-word topic id. Idempotent.",inputSchema:z.object({topic:z.string().describe("Topic id \u2014 prefer a single word, max 3 words"),confidence:d$1.default(5).describe("Initial confidence 0-10 (default 5)"),group:z.string().nullish().describe("Optional group name; 'Other' if omitted")}),annotations:{title:"Add Topic",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async t=>{try{return u(n=>{H(n,t.topic,t.confidence),t.group&&t.group!=="Other"&&L(n,t.topic,t.group);}),{content:[d("true")]}}catch(n){return a(`add_topic failed for '${t.topic}': ${n}`)}}),r$1.registerTool("remove_topic",{title:"Remove Topic",description:"Remove a topic from the knowledge map entirely. Returns true if it existed.",inputSchema:z.object({topic:z.string().describe("Topic id to remove")}),annotations:{title:"Remove Topic",destructiveHint:true,idempotentHint:true,openWorldHint:false}},async t=>{try{let n=u(o=>I(o,t.topic));return {content:[d(String(n))]}}catch(n){return a(`remove_topic failed for '${t.topic}': ${n}`)}}),r$1.registerTool("add_group",{title:"Add Group",description:"Create a new (initially empty) knowledge group. Idempotent \u2014 returns true either way.",inputSchema:z.object({name:z.string().describe("Group name, e.g. 'Machine Learning'")}),annotations:{title:"Add Group",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async t=>{try{return u(n=>J(n,t.name.trim())),{content:[d("true")]}}catch(n){return a(`add_group failed for '${t.name}': ${n}`)}}),r$1.registerTool("remove_group",{title:"Remove Group",description:"Delete a knowledge group. Its topics move to Other. Returns true if it existed.",inputSchema:z.object({name:z.string().describe("Group name to delete")}),annotations:{title:"Remove Group",destructiveHint:true,idempotentHint:true,openWorldHint:false}},async t=>{try{let n=u(o=>K(o,t.name));return {content:[d(String(n))]}}catch(n){return a(`remove_group failed for '${t.name}': ${n}`)}}),r$1.registerTool("update_settings",{title:"Update Settings",description:"Update a coaching setting. max_per_day: integer 1-20. min_gap_minutes: integer 0-1440 (0 = no cooldown). nudge_every: integer 0-1000 interactions between lesson cues (0 = cue every turn). nudge_scope: 'session' | 'global'. share_name: the sender name proposed when sharing a lesson (max 80 chars, empty clears). Returns the full updated Settings.",inputSchema:z.object({key:z.enum(["max_per_day","min_gap_minutes","nudge_every","nudge_scope","share_name"]).describe("Setting key"),value:z.string().describe("New value (integer string; 'session'|'global' for nudge_scope; free text for share_name)")}),outputSchema:Ve,annotations:{title:"Update Settings",destructiveHint:false,idempotentHint:true,openWorldHint:false}},t=>{let n=i=>b(u(c=>(O(c,t.key,i),N(c))));if(t.key==="share_name")return t.value.trim().length>r?a(`share_name must be at most ${r} characters`):n(s(t.value));if(t.key==="nudge_scope")return t.value!=="session"&&t.value!=="global"?a("nudge_scope must be 'session' or 'global'"):n(t.value);let o=Number.parseInt(t.value,10);return Number.isNaN(o)?a(`Value must be an integer, got '${t.value}'`):t.key==="max_per_day"&&!(o>=1&&o<=20)?a("max_per_day must be between 1 and 20"):t.key==="min_gap_minutes"&&!(o>=0&&o<=1440)?a("min_gap_minutes must be between 0 and 1440"):t.key==="nudge_every"&&!(o>=0&&o<=1e3)?a("nudge_every must be between 0 and 1000"):n(String(o))}),r$1.registerTool("open_ui",{title:"Open UI",description:"Launch the devcoach web dashboard in the background. port must be 1024-65535.",inputSchema:z.object({port:z.number().int().default(7860).describe("Port (default 7860)")}),annotations:{title:"Open UI",destructiveHint:false,idempotentHint:false,openWorldHint:true}},async t=>{let n=t.port;if(!(n>=1024&&n<=65535))return {content:[d(`error: port ${n} is out of valid range (1024-65535)`)]};let{pingUi:o}=await import('./app-HTTMWUAK.js');return await o(n)?{content:[d(`devcoach UI is already running at http://localhost:${n}`)]}:(spawn(process.execPath,[process.argv[1]??"","ui","--port",String(n)],{detached:true,stdio:"ignore"}).unref(),{content:[d(`devcoach UI starting at http://localhost:${n}`)]})}),r$1.registerTool("stop_ui",{title:"Stop UI",description:"Stop the devcoach web dashboard listening on port (whoever started it \u2014 open_ui or a terminal). Graceful: in-flight requests finish first. Reports stopped=false when nothing is running there. port must be 1024-65535.",inputSchema:z.object({port:z.number().int().default(7860).describe("Port (default 7860)")}),annotations:{title:"Stop UI",destructiveHint:false,idempotentHint:true,openWorldHint:true}},async t=>{let n=t.port;if(!(n>=1024&&n<=65535))return {content:[d(`error: port ${n} is out of valid range (1024-65535)`)]};let{stopUi:o}=await import('./app-HTTMWUAK.js'),i=await o(n);return {content:[d(i?`devcoach UI on port ${n} stopped`:`No devcoach UI is running on port ${n}`)],structuredContent:{stopped:i,port:n}}}),r$1.registerTool("complete_onboarding",{title:"Complete Onboarding",description:"Save the user's initial knowledge profile and mark onboarding complete. Wipes any default-seeded profile. topics: {topic_id: confidence_0_to_10}. groups: {group_name: [topic_id,...]} (topics not in any group go to 'Other'). Ensures learning-state.md exists and is non-empty (a placeholder if needed) \u2014 there is no notebook argument here. Write the real personalized notebook yourself right after, directly to the path in devcoach://onboarding's notebook_path field. Returns the updated Profile.",inputSchema:z.object({topics:z.record(z.string(),d$1).describe("{topic_id: confidence 0-10}"),groups:z.record(z.string(),z.array(z.string())).optional().describe("{group_name: [topic_id, ...]}")}),outputSchema:Pe,annotations:{title:"Complete Onboarding",destructiveHint:true,idempotentHint:false,openWorldHint:false}},async t=>{try{let n$1=u(o=>{o.exec("DELETE FROM knowledge; DELETE FROM knowledge_groups; DELETE FROM knowledge_group_names;");for(let[i,c]of Object.entries(t.topics))H(o,i,Math.max(0,Math.min(10,c)));if(t.groups)for(let[i,c]of Object.entries(t.groups))for(let F of c)F in t.topics&&L(o,F,i);return ta(o)});return mkdirSync(dirname(n),{recursive:!0}),(!existsSync(n)||statSync(n).size===0)&&writeFileSync(n,`# devcoach \u2014 Coaching Notebook
|
|
3
3
|
`),b(n$1)}catch(n){return a(`complete_onboarding failed: ${n}`)}}),r$1.registerTool("preview_deep_scan",{title:"Preview Deep Scan",description:"Cheap, metadata-only pre-check for 'Automatic (Deep)' onboarding. Counts and lists Claude Code projects whose last recorded activity falls within a rolling window (months back from now) \u2014 a real date window, not a fixed top-N. Reads no prompt/conversation text, only project paths and activity timestamps. Call this BEFORE spawning the deep-read subagent: over_soft_limit true means there are enough candidates that the user should be asked whether to narrow the window, proceed anyway, or pick specific projects.",inputSchema:z.object({months:z.number().int().min(1).max(24).default(3).describe("Rolling window size in months, counting back from now")}),outputSchema:tt,annotations:{title:"Preview Deep Scan",readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false}},t=>{try{return b({...d$2(t.months)})}catch(n){return a(`preview_deep_scan failed: ${n}`)}});let u$1=t=>({title:t,readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false});r$1.registerTool("get_briefing",{title:"Lesson Briefing",description:"Everything needed before delivering a lesson, in ONE call: onboarding status, rate limit, taught topics, knowledge profile, the coaching notebook text and its notebook_path. Same data as the devcoach://briefing resource \u2014 call the tool, it needs no server name.",inputSchema:z.object({}),annotations:u$1("Lesson Briefing")},()=>W("get_briefing",$e())),r$1.registerTool("get_onboarding",{title:"Onboarding Status & Detected Stack",description:"Onboarding status (knowledge_ready, notebook_ready, needs_onboarding), the stack detected across the full Claude Code history with per-project provenance, the default topics and the notebook_path. Same data as the devcoach://onboarding resource.",inputSchema:z.object({}),annotations:u$1("Onboarding Status & Detected Stack")},()=>W("get_onboarding",Ue())),r$1.registerTool("get_profile",{title:"Knowledge Profile",description:"Current knowledge map: topics with confidence 0\u201310 and their groups. Same data as the devcoach://profile resource.",inputSchema:z.object({}),outputSchema:Pe,annotations:u$1("Knowledge Profile")},()=>W("get_profile",Ie())),r$1.registerTool("share_lesson",{title:"Share Lesson",description:"Hand a lesson to another person. transport 'text' (default) returns the card plus a one-line code to paste anywhere; 'link' a server-less URL that previews the lesson and imports it into their dashboard; 'file' the contents of a .devcoach.md file. Only title, summary, body, topic, categories and level travel unless include_context is true; local paths never do. Pick the lesson with get_lessons first.",inputSchema:z.object({lesson_id:z.string().describe("Lesson id (from get_lessons)"),transport:z.enum(["text","link","file"]).default("text").describe("text = card + code to paste; link = share URL; file = .devcoach.md contents"),include_context:z.boolean().default(false).describe("Include project/branch/commit/task context (off by default \u2014 privacy). Local paths are never included."),shared_by:z.string().nullish().describe("Sender name. Omit \u2192 the share_name setting, then git user.name. Empty string \u2192 anonymous.")}),outputSchema:Xe,annotations:u$1("Share Lesson")},t=>{try{let n=u(o=>{let i=E(o,t.lesson_id);if(!i)return null;let c=ka({explicit:t.shared_by??null,setting:N(o).share_name,gitUserName:n$1()});return ja(i,{includeContext:t.include_context,sharedBy:c})});return n?b({transport:t.transport,code:la(n),text:t.transport==="text"?na(n):null,link:t.transport==="link"?oa(n):null,markdown:t.transport==="file"?ra(n):null,filename:t.transport==="file"?qa(n):null,shared_by:n.shared_by,include_context:t.include_context,reply_check:Ze[t.transport]}):a(`share_lesson: lesson '${t.lesson_id}' not found \u2014 call get_lessons to pick one`)}catch(n){return a(`share_lesson failed: ${n}`)}}),r$1.registerTool("import_lesson",{title:"Import Lesson",description:"Store a lesson someone shared. Pass whatever the user handed you, verbatim: the devcoach:lesson:1:\u2026 code, the whole copied card, the share link, a URL to the lesson text, the contents of a .devcoach.md file, or a lessons JSON export. The lesson joins the coaching log as their own (feedback works as usual) but never counts against the daily limit; re-importing the same share is reported as a duplicate, not an error.",inputSchema:z.object({payload:z.string().min(1).describe("The code, link, URL, card text, file text or JSON \u2014 verbatim")}),outputSchema:Qe,annotations:{title:"Import Lesson",destructiveHint:false,idempotentHint:true,openWorldHint:true}},async t=>{try{let n=p(t.payload)&&!t.payload.includes("#devcoach:lesson:")?await q(t.payload):t.payload,o=u(i=>xa(i,n));return b({...o,reply_check:et})}catch(n){return n instanceof ia?a(`import_lesson: ${n.message}`):a(`import_lesson failed: ${n}`)}});let m=z.object({course_id:z.string(),position:z.number().int(),title:z.string(),kind:i,anchor:z.string(),status:j,done_at:z.string().nullable()}),g=z.object({id:z.string(),lesson_id:z.string().nullable(),topic_id:z.string(),title:z.string(),goal:z.string().nullable(),prerequisites:z.array(z.object({concept:z.string(),known:z.boolean()})),status:h,created_at:z.string(),updated_at:z.string(),completed_at:z.string().nullable(),steps:z.array(m)}),f='Write ONE self-contained HTML document at document_path (inline CSS + JS, no external URLs, no fetch, no <form>, no alert/confirm/prompt) with one <section id="step-N"> per step, using your file tools \u2014 never paste HTML into the chat. Then register every section with add_course_step (position order, anchor = the section id). Teach one step per message and tell the user the course is on the dashboard under Courses (/devcoach:ui).';r$1.registerTool("create_course",{title:"Create Course",description:"Start a step-by-step course, usually from a lesson the user couldn't follow. Pass the prerequisite chain you explored ([{concept, known}], top-down). Returns the course row, course_dir and document_path \u2014 write the document there yourself, then call add_course_step for each section.",inputSchema:z.object({title:z.string().min(1).describe("Course title, e.g. 'From sums to logarithms'"),topic_id:z.string().min(1).describe("The lesson-style topic id the course belongs to"),goal:z.string().nullish().describe("One sentence: what the user will be able to do"),lesson_id:z.string().nullish().describe("The seed lesson's id, when the course grows from one"),prerequisites:z.array(z.object({concept:z.string().min(1),known:z.boolean()})).default([]).describe("The explored chain, top-down: [{concept, known}]")}),outputSchema:g.extend({course_dir:z.string(),document_path:z.string(),seed_context:z.object({task_context:z.string().nullable(),project:z.string().nullable(),repository:z.string().nullable(),branch:z.string().nullable()}).nullable(),reply_check:z.string()}),annotations:{title:"Create Course",destructiveHint:false,idempotentHint:false,openWorldHint:false}},async t=>{try{let n=u(o=>{let i=t.lesson_id?E(o,t.lesson_id):null;if(t.lesson_id&&!i)throw new b$2(`lesson '${t.lesson_id}' not found \u2014 call get_lessons to pick one`);return {course:f$1(o,{title:t.title,topic_id:t.topic_id,goal:t.goal??null,lesson_id:t.lesson_id??null,prerequisites:t.prerequisites}),seed:i}});return b({...n.course,course_dir:c$1(n.course.id),document_path:d$3(n.course.id),seed_context:n.seed?{task_context:n.seed.task_context,project:n.seed.project,repository:n.seed.repository,branch:n.seed.branch}:null,reply_check:f})}catch(n){return a(`create_course failed: ${n}`)}}),r$1.registerTool("add_course_step",{title:"Add Course Step",description:"Register a step of a course: the section with id=<anchor> must already exist in the course document. Appended by default; pass `after` to insert it after that step (0 = first) \u2014 the following steps are renumbered.",inputSchema:z.object({course_id:z.string().describe("Course id (from create_course)"),title:z.string().min(1).describe("Step title"),kind:i.describe("concept | example | practice | check"),anchor:z.string().regex(/^[a-z0-9][a-z0-9-]*$/).describe("The section's id in the document, e.g. step-1"),after:z.number().int().min(0).nullish().describe("Insert after this step number (0 = first); omit to append")}),outputSchema:g.extend({step:m}),annotations:{title:"Add Course Step",destructiveHint:false,idempotentHint:false,openWorldHint:false}},async t=>{try{let n=u(o=>{let i=i$1(o,t.course_id,{title:t.title,kind:t.kind,anchor:t.anchor,after:t.after});return {...g$1(o,t.course_id),step:i}});return b(n)}catch(n){return a(`add_course_step failed: ${n}`)}}),r$1.registerTool("update_course_progress",{title:"Update Course Progress",description:"With position: set that step to todo | done | skipped (the course completes itself once every step is done or skipped). Without position: set the course to active | completed | abandoned.",inputSchema:z.object({course_id:z.string().describe("Course id"),position:z.number().int().min(1).nullish().describe("Step number (1-based); omit for the course"),status:z.string().describe("Step: todo | done | skipped \u2014 course: active | completed | abandoned")}),outputSchema:g,annotations:{title:"Update Course Progress",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async t=>{try{let n=u(o=>{if(t.position!=null){let i=j.parse(t.status);return j$1(o,t.course_id,t.position,i)}return k$1(o,t.course_id,h.parse(t.status))});return n?b(n):a(`update_course_progress: course '${t.course_id}'${t.position!=null?` step ${t.position}`:""} not found \u2014 call get_courses`)}catch(n){return a(`update_course_progress failed: ${n}`)}}),r$1.registerTool("get_courses",{title:"Get Courses",description:"List courses with their steps and progress; filter by id, seed lesson or status. 'continue the course' = status active.",inputSchema:z.object({course_id:z.string().nullish().describe("One course"),lesson_id:z.string().nullish().describe("Courses seeded by this lesson"),status:h.nullish().describe("active | completed | abandoned")}),outputSchema:z.object({courses:z.array(g.extend({course_dir:z.string()}))}),annotations:u$1("Get Courses")},t=>{try{let n=u(o=>{if(t.course_id){let i=g$1(o,t.course_id);return i?[i]:[]}return h$1(o,{lesson_id:t.lesson_id,status:t.status})});return b({courses:n.map(o=>({...o,course_dir:c$1(o.id)}))})}catch{return b({courses:[]})}});let p$1=(t,n)=>({title:t,description:n,mimeType:"application/json"});return r$1.registerResource("profile","devcoach://profile",p$1("Knowledge Profile","Current knowledge map \u2014 topics, confidence scores, and groups."),t=>l(t,Ie())),r$1.registerResource("notebook","devcoach://notebook",{title:"Coaching Notebook",description:"The coaching notebook (learning-state.md): observations, recurring patterns, recommended focus, and open hypotheses about the user. Read it to decide what to teach.",mimeType:"text/markdown"},t=>{let n$1="";try{existsSync(n)&&(n$1=readFileSync(n,"utf8"));}catch{}return {contents:[{uri:t.href,mimeType:"text/markdown",text:n$1}]}}),r$1.registerResource("settings","devcoach://settings",p$1("Settings","Current coaching settings (rate limits, UI theme)."),t=>{try{return l(t,u(n=>N(n)))}catch(n){return l(t,{error:String(n)})}}),r$1.registerResource("recent-lessons","devcoach://lessons/recent",p$1("Recent Lessons","Last 10 lessons from the current week."),t=>{try{return l(t,u(n=>x(n,{period:"week",page:1,per_page:10})))}catch(n){return l(t,[{error:String(n)}])}}),r$1.registerResource("stats","devcoach://stats",p$1("Stats","Aggregate coaching statistics: counts and weakest/strongest topics."),t=>{try{return l(t,u(n=>wa(n)))}catch(n){return l(t,{error:String(n)})}}),r$1.registerResource("taught-topics","devcoach://taught-topics",p$1("Taught Topics","All topic_ids already taught \u2014 read before selecting a new lesson topic."),t=>{try{return l(t,u(n=>ya(n)))}catch{return l(t,[])}}),r$1.registerResource("rate-limit","devcoach://rate-limit",p$1("Rate Limit","Current rate-limit status and running lesson total."),t=>{try{let{r:n,total:o}=u(c=>({r:sa(c),total:w(c)})),i={allowed:n.allowed,total_lessons:o};return n.reason!=null&&(i.reason=n.reason),l(t,i)}catch(n){return l(t,{allowed:false,reason:`Rate limit check unavailable: ${n}`})}}),r$1.registerResource("briefing","devcoach://briefing",p$1("Lesson Briefing","Everything needed before delivering a lesson in ONE read: onboarding status, rate limit, taught topics, knowledge profile, and the coaching notebook."),t=>l(t,$e())),r$1.registerResource("context","devcoach://context",p$1("Workspace Context","Auto-detected git context and most-used lesson metadata defaults."),t=>{try{let n=o(),o$1=u(i=>U(i));return l(t,{git:n,usage_defaults:o$1})}catch(n){return l(t,{error:String(n)})}}),r$1.registerResource("onboarding","devcoach://onboarding",p$1("Onboarding","Onboarding status, the stack detected across the full Claude Code history (with per-project provenance), and project topic defaults."),t=>l(t,Ue())),r$1.registerResource("lesson",new ResourceTemplate("devcoach://lessons/{lesson_id}",{list:void 0}),p$1("Lesson","A single lesson by id."),(t,n)=>{try{let o=String(n.lesson_id),i=u(c=>E(c,o));return i?l(t,i):l(t,{error:`Lesson '${o}' not found`})}catch(o){return l(t,{error:String(o)})}}),r$1.registerPrompt("devcoach_instructions",{title:"devcoach coaching instructions",description:"Full coaching instructions for the devcoach skill (SKILL.md plus its reference files)."},()=>{let t=f$2().map(n=>`
|
|
4
4
|
|
|
5
5
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devcoach",
|
|
3
|
-
"version": "2.5.0-next.
|
|
3
|
+
"version": "2.5.0-next.584.g7ebb2db",
|
|
4
4
|
"mcpName": "io.github.UltimaPhoenix/devcoach",
|
|
5
5
|
"description": "Stay sharp while your AI does the work — learn from every task with in-context coaching, all local, all free",
|
|
6
6
|
"license": "AGPL-3.0-only",
|