devcoach 2.2.0-next.512.gc165fb2 → 2.2.0-next.514.g6fb0c39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{app-56UHVZWZ.js → app-DWK7UT6Y.js} +1 -1
- package/dist/bin.js +1 -1
- package/dist/{chunk-WIV6K3EQ.js → chunk-655G2OUM.js} +1 -1
- package/dist/{chunk-MHB2M5QZ.js → chunk-6QB7JZWD.js} +1 -1
- package/dist/{chunk-J35FEB7C.js → chunk-JIXHPY3H.js} +1 -1
- package/dist/{commands-KBOTDLAH.js → commands-CQOJSQO4.js} +2 -2
- package/dist/{hooks-VMLDC3D7.js → hooks-52WYOQ4U.js} +1 -1
- package/dist/{server-C2WCQFVN.js → server-U37I55MK.js} +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -98,7 +98,7 @@ devcoach install
|
|
|
98
98
|
|
|
99
99
|
`brew tap` registers the third-party repository; `brew trust --tap` marks it trusted so Homebrew will load its formulae when `HOMEBREW_REQUIRE_TAP_TRUST` is set. Both are one-time. To update later: `brew upgrade devcoach`. One-liner: `brew install UltimaPhoenix/tap/devcoach` (run `brew trust --tap UltimaPhoenix/tap` first if your Homebrew enforces tap trust). The formula declares `depends_on "node"`, so Homebrew pulls in a recent Node automatically.
|
|
100
100
|
|
|
101
|
-
### Claude Code plugin (recommended for Claude Code)
|
|
101
|
+
### Claude Code plugin (recommended for Claude Code)
|
|
102
102
|
|
|
103
103
|
The simplest way to add devcoach to **Claude Code** — one click, nothing to configure. It bundles **everything** (MCP server + automatic-coaching Stop hooks + skill), so **don't also run `devcoach install`** (or the Stop hooks get registered twice).
|
|
104
104
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {c,d,a}from'./chunk-
|
|
2
|
+
import {c,d,a}from'./chunk-655G2OUM.js';import {Q,o,G,_,ca,$,A as A$1,E,B as B$1,F,aa,C,D as D$1,v,da,R,V,q,w as w$1,y as y$1,r,t,ba,x,H as H$1,m,Z,Y,O as O$1,P,j as j$1,T,S,U,X,W}from'./chunk-JIXHPY3H.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 w(t){return JSON.stringify(t??"").replace(/[<>&\u2028\u2029]/g,e=>String.raw`\u`+(e.codePointAt(0)??0).toString(16).padStart(4,"0"))}function we(t,e){return t+e.replace(/[^A-Za-z0-9_-]/g,r=>`_${(r.codePointAt(0)??0).toString(16)}`)}function j(t){let e=(r,a,s)=>html`<a href="${r}" class="text-gray-500 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white transition ${s?"text-gray-900 dark:text-white font-semibold":""}">${a}</a>`;return html`<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8" />
|
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-52WYOQ4U.js');o(t);}else {let{runCli:o}=await import('./commands-CQOJSQO4.js');await o();}}catch(o){console.error(o),process.exit(1);}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {R,Q}from'./chunk-
|
|
2
|
+
import {R,Q}from'./chunk-JIXHPY3H.js';import {execFileSync}from'child_process';import {basename}from'path';import U from'dns';import P from'http';import A from'https';import {isIP}from'net';function f(...e){try{return execFileSync("git",e,{encoding:"utf8",timeout:3e3,stdio:["ignore","pipe","ignore"]}).trim()||null}catch{return null}}var w={"github.com":"github","gitlab.com":"gitlab","bitbucket.org":"bitbucket"};function T(e){if(!e)return [null,null];let t=/^git@([^:]+):(.+?)(?:\.git)?$/.exec(e);if(t){let o=(t[1]??"").toLowerCase();return [t[2]??e,w[o]??"local"]}let n=/^https?:\/\/([^/]+)\/(.+?)(?:\.git)?$/.exec(e);if(n){let o=(n[1]??"").toLowerCase();return [n[2]??e,w[o]??"local"]}return [e,"local"]}function F(){return f("config","user.name")}function G(){let e=process.cwd(),t=f("rev-parse","--abbrev-ref","HEAD"),n=f("rev-parse","HEAD"),o=f("remote","get-url","origin"),[s,l]=T(o),u;return s?u=s.replace(/\/+$/,"").split("/").pop()??null:u=basename(e)||null,t==="HEAD"&&(t=null),{project:u,repository:s,branch:t,commit_hash:n,folder:e,repository_platform:l}}var y="That URL is too large to be a lesson.",m="Only public http(s) URLs can be imported.",k=new Set([301,302,303,307,308]);function E(e){return /^https?:\/\/\S+$/i.test(e.trim())}function x(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 L(e){let t=e.replace(/^\[|\]$/g,"").replace(/%.*$/,"").toLowerCase();if(isIP(t)===4)return x(t);if(isIP(t)!==6)return true;let n=/^::ffff:(\d+\.\d+\.\d+\.\d+)$/.exec(t);if(n?.[1])return x(n[1]);if(t==="::"||t==="::1")return true;let o=t.split(":")[0]??"";return !!(/^f[cd]/.test(o)||/^fe[89ab]/.test(o))}async function $(e){return (await U.promises.lookup(e,{all:true})).map(n=>n.address)}async function C(e,t){let n=e.hostname.replace(/^\[|\]$/g,"").toLowerCase();if(n==="localhost"||n.endsWith(".localhost"))throw new R(m);if(isIP(n)){if(L(n))throw new R(m);return n}let o;try{o=await t(n);}catch{throw new R("The URL could not be reached \u2014 copy the lesson text instead.")}let s=o[0];if(!s||o.some(l=>L(l)))throw new R(m);return s}var v=(e,t,n)=>new Promise((o,s)=>{let l=isIP(t)===6?6:4,u=(r,a,h)=>{a.all?h(null,[{address:t,family:l}]):h(null,t,l);},p=(e.protocol==="https:"?A:P).request(e,{method:"GET",lookup:u,signal:n,headers:{accept:"text/plain, text/markdown, application/json;q=0.9, */*;q=0.5","user-agent":`devcoach/${Q}`}},r=>{let a=r.headers["content-length"];o({status:r.statusCode??0,location:r.headers.location??null,contentLength:a===void 0?null:Number(a),body:r,abort:()=>r.destroy()});});p.on("error",s),p.end();});async function O(e,t){if(e.contentLength!==null&&e.contentLength>t)throw e.abort(),new R(y);let n=[],o=0;for await(let s of e.body){if(o+=s.byteLength,o>t)throw e.abort(),new R(y);n.push(s);}return Buffer.concat(n).toString("utf8")}async function V(e,t={}){let n=t.timeoutMs??5e3,o=t.maxBytes??256*1024,s=t.maxRedirects??3,l=t.lookup??$,u=t.transport??v;if(!E(e))throw new R("Only http(s) URLs can be imported.");let g=new AbortController,p=setTimeout(()=>g.abort(),n);try{let r=new URL(e.trim());for(let a=0;;a++){let h=await C(r,l),c=await u(r,h,g.signal);if(k.has(c.status)){if(c.abort(),!c.location||a>=s)throw new R("The URL redirects too many times \u2014 copy the lesson text instead.");if(r=new URL(c.location,r),!/^https?:$/.test(r.protocol))throw new R(m);continue}if(c.status<200||c.status>=300)throw c.abort(),new R(`The URL answered ${c.status} \u2014 nothing to import there.`);return await O(c,o)}}catch(r){if(r instanceof R)throw r;let a=r?.name==="AbortError"?"timed out":"could not be reached";throw new R(`The URL ${a} \u2014 copy the lesson text instead.`)}finally{clearTimeout(p);}}export{F as a,G as b,E as c,V as d};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {i,o,M,ga,h as h$1,n,fa}from'./chunk-
|
|
2
|
+
import {i,o,M,ga,h as h$1,n,fa}from'./chunk-JIXHPY3H.js';import {existsSync,mkdirSync,statSync,writeFileSync,appendFileSync,fstatSync,readFileSync}from'fs';import {join}from'path';function D(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:D(readFileSync(0,"utf8"))}catch{return e}}function A(e){return e.stop_hook_active||e.permission_mode==="plan"}function s(e,o,t){if(process.env.DEVCOACH_HOOK_DEBUG==="1")try{mkdirSync(h$1,{recursive:!0});let n=join(h$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 N={claude:"block",gemini:"deny",codex:"block"};function h(e,o,t){let n={decision:N[e],reason:o};t&&(n.systemMessage=t),process.stdout.write(`${JSON.stringify(n)}
|
|
4
4
|
`),process.exit(0);}var f="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=l()){if(A(e)&&process.exit(0),existsSync(i)){let o$1;try{o$1=o(t=>M(t).knowledge_ready);}catch(t){s("onboard-hook",e.session_id,`error: ${t}`),process.exit(0);}o$1&&process.exit(0);}s("onboard-hook",e.session_id,"onboarding cue"),h("claude",f);}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 E(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
|
|
|
@@ -65,7 +65,7 @@ import {z as z$1}from'zod';import {existsSync,readFileSync,mkdirSync,writeFileSy
|
|
|
65
65
|
CREATE INDEX IF NOT EXISTS idx_lessons_feedback ON lessons (feedback);
|
|
66
66
|
CREATE INDEX IF NOT EXISTS idx_lessons_topic_id ON lessons (topic_id);
|
|
67
67
|
`),tt(e),nt(e);}function tt(e){for(let t 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(t);}catch{}}function nt(e){for(let[t,n]of Object.entries(qe))u(e,"INSERT OR IGNORE INTO settings (key, value) VALUES (?, ?)",t,n);}var re="(id, timestamp, topic_id, categories, title, level, summary, body, task_context, project, repository, branch, commit_hash, folder, repository_platform, starred, feedback, imported, shared_by)",ie="(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";function ae(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 Qt(e,t){u(e,`INSERT OR REPLACE INTO lessons ${re} VALUES ${ie}`,...ae(t));}function G(e,t){return u(e,`INSERT OR IGNORE INTO lessons ${re} VALUES ${ie}`,...ae(t))>0}var st=[["project","project"],["repository","repository"],["branch","branch"],["commit","commit_hash"]];function ot(e,t){if(e.date_from==null&&e.date_to==null){let n=mt(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 ce(e){let t=[],n=[],s=(r,...a)=>{t.push(r),n.push(...a);};ot(e,s),e.category!=null&&s("categories LIKE ?",`%"${e.category}"%`),e.level!=null&&s("level = ?",e.level);for(let[r,a]of st){let i=e[r];i!=null&&s(`${a} LIKE ?`,`%${i}%`);}if(e.starred!=null&&s("starred = ?",e.starred?1:0),e.imported!=null&&s("imported = ?",e.imported?1:0),e.search!=null){let r=`%${e.search}%`;s("(title LIKE ? OR topic_id LIKE ? OR summary LIKE ? OR body LIKE ?)",r,r,r,r);}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 K(e,t={}){let{where:n,params:s}=ce(t),o=h(e,`SELECT COUNT(*) AS n FROM lessons ${n}`,...s);return Number(o?.n??0)}var rt=new Set(["timestamp","level","topic_id","title","feedback"]),it=new Set(["project","repository","branch","commit_hash","repository_platform"]);function en(e,t={}){let{where:n,params:s}=ce(t),o=t.sort&&rt.has(t.sort)?t.sort:"timestamp",r=(t.order??"desc").toLowerCase()==="asc"?"ASC":"DESC",a=`SELECT * FROM lessons ${n} ORDER BY ${o} ${r}`,i=[...s];if(t.page!=null){let l=t.per_page??25;a+=" LIMIT ? OFFSET ?",i.push(l,(t.page-1)*l);}return f(e,a,...i).map(Z)}function tn(e,t){return u(e,"DELETE FROM lessons WHERE id = ?",t)>0}function nn(e,t,n){return u(e,"UPDATE lessons SET starred = ? WHERE id = ?",n?1:0,t)>0}function le(e,t,n){u(e,"UPDATE lessons SET feedback = ? WHERE id = ?",n||null,t);let s=h(e,"SELECT topic_id FROM lessons WHERE id = ?",t);return s?s.topic_id:null}function at(e){return f(e,"SELECT * FROM lessons ORDER BY timestamp DESC").map(Z)}function H(e,t){let n=0,s=0,o=0;for(let r of t){let a;try{a=T(r);}catch{o+=1;continue}G(e,a)?n+=1:s+=1;}return {inserted:n,duplicated:s,invalid:o}}function sn(e,t){if(!it.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 ue(e,t){let n=h(e,"SELECT * FROM lessons WHERE id = ?",t);return n?Z(n):null}function on(e){return f(e,"SELECT DISTINCT value FROM lessons, json_each(lessons.categories) ORDER BY value").map(n=>n.value)}function pe(e){return f(e,"SELECT DISTINCT topic_id FROM lessons").map(t=>t.topic_id)}function D(e,t){let n=h(e,"SELECT COUNT(*) AS n FROM lessons WHERE timestamp >= ? AND imported = 0",t);return Number(n?.n??0)}function de(e){let t=h(e,"SELECT timestamp FROM lessons WHERE imported = 0 ORDER BY timestamp DESC LIMIT 1");return t?t.timestamp:null}function I(e){let t={};for(let n of f(e,"SELECT topic, confidence FROM knowledge"))t[n.topic]=Number(n.confidence);return t}function W(e){return f(e,"SELECT topic, confidence FROM knowledge ORDER BY topic").map(t=>({topic:t.topic,confidence:Number(t.confidence)}))}function Y(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 x(e,t,n){let s=Math.max(0,Math.min(10,n)),o=new Date().toISOString();u(e,`INSERT INTO knowledge (topic, confidence, updated_at) VALUES (?, ?, ?)
|
|
68
|
-
ON CONFLICT(topic) DO UPDATE SET confidence = excluded.confidence, updated_at = excluded.updated_at`,t,s,o);}function rn(e,t){let n=u(e,"DELETE FROM knowledge WHERE topic = ?",t);return u(e,"DELETE FROM knowledge_groups WHERE topic = ?",t),n>0}function te(e,t){let n=t.trim();if(!n)throw new Error("Group name must not be empty");return u(e,"INSERT OR IGNORE INTO knowledge_group_names (group_name) VALUES (?)",n)>0}function an(e,t){return u(e,"DELETE FROM knowledge_groups WHERE group_name = ?",t),u(e,"DELETE FROM knowledge_group_names WHERE group_name = ?",t)>0}function ct(e,t,n){u(e,"INSERT OR IGNORE INTO knowledge_group_names (group_name) VALUES (?)",n),u(e,"DELETE FROM knowledge_groups WHERE topic = ?",t),u(e,"INSERT OR IGNORE INTO knowledge_groups (group_name, topic) VALUES (?, ?)",n,t);}function cn(e,t){u(e,"DELETE FROM knowledge_groups WHERE topic = ?",t);}function b(e){let t={};for(let g of f(e,"SELECT key, value FROM settings"))t[g.key]=g.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,a=t.ui_theme??"system",i=a==="dark"||a==="light"||a==="system"?a:"system",l=t.nudge_every,m=l!==void 0?Number.parseInt(l,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:i,nudge_every:Number.isFinite(m)&&m>=0?m:10,nudge_scope:S,share_name:t.share_name?.trim()||null}}function y(e,t,n){u(e,"INSERT INTO settings (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value",t,n);}function me(e,t,n){let s=h(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&&u(e,"DELETE FROM nudge_state WHERE session_id NOT IN (SELECT session_id FROM nudge_state ORDER BY updated_at DESC LIMIT ?)",Ve),n==="global"?z(e,t,n):o}function ln(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 z(e,t,n){let s=n==="global"?h(e,"SELECT COALESCE(SUM(interactions), 0) AS n FROM nudge_state"):h(e,"SELECT interactions AS n FROM nudge_state WHERE session_id = ?",t);return Number(s?.n??0)}function un(e){u(e,"DELETE FROM nudge_state"),u(e,"UPDATE cue_state SET pending = 0 WHERE id = 1");}var J=3;function q(e){let t=h(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 ge(e){u(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()),u(e,"DELETE FROM nudge_state");}function pn(e,t){u(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),u(e,"DELETE FROM nudge_state");}function V(e){let t=h(e,"SELECT COUNT(*) AS n FROM knowledge");return {knowledge_ready:Number(t?.n??0)>0}}function dn(e){let t={};for(let n of ["project","repository","branch","repository_platform"]){let s=h(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 mn(e){let t=b(e),n=at(e),s=W(e),o=Y(e),r=new Map;for(let l of o)for(let m of l.topics)r.set(m,l.name);let a={groups:o.map(l=>l.name),topics:s.map(l=>({topic:l.topic,confidence:l.confidence,group:r.get(l.topic)??null}))},i={[$]:strToU8(JSON.stringify(t,null,2)),[M]:strToU8(JSON.stringify(n,null,2)),[P]:strToU8(JSON.stringify(a,null,2))};return existsSync(N)&&(i[j]=strToU8(readFileSync(N,"utf8"))),zipSync(i)}function lt(e,t,n){if(!($ in t))return;let s=JSON.parse(strFromU8(t[$]));"max_per_day"in s&&y(e,"max_per_day",String(s.max_per_day)),"min_gap_minutes"in s&&y(e,"min_gap_minutes",String(s.min_gap_minutes)),(s.ui_theme==="system"||s.ui_theme==="dark"||s.ui_theme==="light")&&y(e,"ui_theme",s.ui_theme),"nudge_every"in s&&y(e,"nudge_every",String(s.nudge_every)),(s.nudge_scope==="session"||s.nudge_scope==="global")&&y(e,"nudge_scope",s.nudge_scope),typeof s.share_name=="string"&&y(e,"share_name",Je(s.share_name)),n.settings=1;}function ut(e,t,n){if(!(P in t))return;let s=JSON.parse(strFromU8(t[P]));if(!(s&&typeof s=="object"&&Array.isArray(s.topics))){for(let[r,a]of Object.entries(s))x(e,r,a);n.topics=Object.keys(s).length;return}let o=0;for(let r of s.groups??[])te(e,r)&&(o+=1);for(let r of s.topics){x(e,r.topic,r.confidence);let a=r.group;a&&a!=="Other"&&(te(e,a)&&(o+=1),ct(e,r.topic,a));}n.topics=s.topics.length,n.groups=o;}function pt(e,t,n){if(!(M in t))return;let s=JSON.parse(strFromU8(t[M])),{inserted:o,duplicated:r,invalid:a}=H(e,s);n.lessons=o,n.skipped=r,n.invalid=a;}function dt(e,t){j in e&&(mkdirSync(dirname(N),{recursive:true}),writeFileSync(N,strFromU8(e[j]),"utf8"),t.learning_state=1);}function gn(e,t){let n={settings:0,topics:0,groups:0,lessons:0,skipped:0,invalid:0,learning_state:0},s=unzipSync(t);return lt(e,s,n),ut(e,s,n),pt(e,s,n),dt(s,n),n}function mt(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 Z(e){let t=[];try{let n=JSON.parse(e.categories);Array.isArray(n)&&(t=n);}catch{t=[];}return T({...e,categories:t,starred:!!e.starred,imported:!!e.imported})}var fe={version:"2.2.0-next.
|
|
68
|
+
ON CONFLICT(topic) DO UPDATE SET confidence = excluded.confidence, updated_at = excluded.updated_at`,t,s,o);}function rn(e,t){let n=u(e,"DELETE FROM knowledge WHERE topic = ?",t);return u(e,"DELETE FROM knowledge_groups WHERE topic = ?",t),n>0}function te(e,t){let n=t.trim();if(!n)throw new Error("Group name must not be empty");return u(e,"INSERT OR IGNORE INTO knowledge_group_names (group_name) VALUES (?)",n)>0}function an(e,t){return u(e,"DELETE FROM knowledge_groups WHERE group_name = ?",t),u(e,"DELETE FROM knowledge_group_names WHERE group_name = ?",t)>0}function ct(e,t,n){u(e,"INSERT OR IGNORE INTO knowledge_group_names (group_name) VALUES (?)",n),u(e,"DELETE FROM knowledge_groups WHERE topic = ?",t),u(e,"INSERT OR IGNORE INTO knowledge_groups (group_name, topic) VALUES (?, ?)",n,t);}function cn(e,t){u(e,"DELETE FROM knowledge_groups WHERE topic = ?",t);}function b(e){let t={};for(let g of f(e,"SELECT key, value FROM settings"))t[g.key]=g.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,a=t.ui_theme??"system",i=a==="dark"||a==="light"||a==="system"?a:"system",l=t.nudge_every,m=l!==void 0?Number.parseInt(l,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:i,nudge_every:Number.isFinite(m)&&m>=0?m:10,nudge_scope:S,share_name:t.share_name?.trim()||null}}function y(e,t,n){u(e,"INSERT INTO settings (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value",t,n);}function me(e,t,n){let s=h(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&&u(e,"DELETE FROM nudge_state WHERE session_id NOT IN (SELECT session_id FROM nudge_state ORDER BY updated_at DESC LIMIT ?)",Ve),n==="global"?z(e,t,n):o}function ln(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 z(e,t,n){let s=n==="global"?h(e,"SELECT COALESCE(SUM(interactions), 0) AS n FROM nudge_state"):h(e,"SELECT interactions AS n FROM nudge_state WHERE session_id = ?",t);return Number(s?.n??0)}function un(e){u(e,"DELETE FROM nudge_state"),u(e,"UPDATE cue_state SET pending = 0 WHERE id = 1");}var J=3;function q(e){let t=h(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 ge(e){u(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()),u(e,"DELETE FROM nudge_state");}function pn(e,t){u(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),u(e,"DELETE FROM nudge_state");}function V(e){let t=h(e,"SELECT COUNT(*) AS n FROM knowledge");return {knowledge_ready:Number(t?.n??0)>0}}function dn(e){let t={};for(let n of ["project","repository","branch","repository_platform"]){let s=h(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 mn(e){let t=b(e),n=at(e),s=W(e),o=Y(e),r=new Map;for(let l of o)for(let m of l.topics)r.set(m,l.name);let a={groups:o.map(l=>l.name),topics:s.map(l=>({topic:l.topic,confidence:l.confidence,group:r.get(l.topic)??null}))},i={[$]:strToU8(JSON.stringify(t,null,2)),[M]:strToU8(JSON.stringify(n,null,2)),[P]:strToU8(JSON.stringify(a,null,2))};return existsSync(N)&&(i[j]=strToU8(readFileSync(N,"utf8"))),zipSync(i)}function lt(e,t,n){if(!($ in t))return;let s=JSON.parse(strFromU8(t[$]));"max_per_day"in s&&y(e,"max_per_day",String(s.max_per_day)),"min_gap_minutes"in s&&y(e,"min_gap_minutes",String(s.min_gap_minutes)),(s.ui_theme==="system"||s.ui_theme==="dark"||s.ui_theme==="light")&&y(e,"ui_theme",s.ui_theme),"nudge_every"in s&&y(e,"nudge_every",String(s.nudge_every)),(s.nudge_scope==="session"||s.nudge_scope==="global")&&y(e,"nudge_scope",s.nudge_scope),typeof s.share_name=="string"&&y(e,"share_name",Je(s.share_name)),n.settings=1;}function ut(e,t,n){if(!(P in t))return;let s=JSON.parse(strFromU8(t[P]));if(!(s&&typeof s=="object"&&Array.isArray(s.topics))){for(let[r,a]of Object.entries(s))x(e,r,a);n.topics=Object.keys(s).length;return}let o=0;for(let r of s.groups??[])te(e,r)&&(o+=1);for(let r of s.topics){x(e,r.topic,r.confidence);let a=r.group;a&&a!=="Other"&&(te(e,a)&&(o+=1),ct(e,r.topic,a));}n.topics=s.topics.length,n.groups=o;}function pt(e,t,n){if(!(M in t))return;let s=JSON.parse(strFromU8(t[M])),{inserted:o,duplicated:r,invalid:a}=H(e,s);n.lessons=o,n.skipped=r,n.invalid=a;}function dt(e,t){j in e&&(mkdirSync(dirname(N),{recursive:true}),writeFileSync(N,strFromU8(e[j]),"utf8"),t.learning_state=1);}function gn(e,t){let n={settings:0,topics:0,groups:0,lessons:0,skipped:0,invalid:0,learning_state:0},s=unzipSync(t);return lt(e,s,n),ut(e,s,n),pt(e,s,n),dt(s,n),n}function mt(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 Z(e){let t=[];try{let n=JSON.parse(e.categories);Array.isArray(n)&&(t=n);}catch{t=[];}return T({...e,categories:t,starred:!!e.starred,imported:!!e.imported})}var fe={version:"2.2.0-next.514.g6fb0c39"};var he=fe.version;function _e(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 Ee(e){let t=e.level.charAt(0).toUpperCase()+e.level.slice(1),n=e.categories.join(" \xB7 ");return [_e("\u{1F393} devcoach"),`**${e.title}** \xB7 ${n} \xB7 ${t}`,"",e.body?.trim()||e.summary,"",_e(`${e.topic_id} \xB7 ${e.level}`)].join(`
|
|
69
69
|
`)}var A="devcoach.lesson",R=1,yt=`devcoach:lesson:${R}:`,St="https://ultimaphoenix.github.io/dev-coach/lesson",Tt=".devcoach.md",bt=256*1024,d=class extends Error{},L=z$1.string().nullish(),Lt=["task_context","project","branch","commit_hash"],Rt=new Set(["github","gitlab","bitbucket"]),Se=z$1.object({format:z$1.literal(A),version:z$1.literal(R),lesson:z$1.object({title:z$1.string().min(1),summary:z$1.string(),body:z$1.string().nullable(),topic_id:z$1.string().min(1),categories:z$1.array(z$1.string()),level:C,task_context:L,project:L,repository:L,branch:L,commit_hash:L,repository_platform:U.nullish()}),origin:z$1.object({id:z$1.string().min(1),timestamp:z$1.string()}),shared_by:z$1.string().nullable(),shared_at:z$1.string(),app_version:z$1.string()});function wn(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 Lt)e[s]!=null&&(n[s]=e[s]);e.repository_platform&&Rt.has(e.repository_platform)&&(e.repository!=null&&(n.repository=e.repository),n.repository_platform=e.repository_platform);}return {format:A,version:R,lesson:n,origin:{id:e.id,timestamp:e.timestamp},shared_by:t.sharedBy,shared_at:F(t.now??new Date),app_version:he}}function Nn(e){return e.anonymous?null:e.explicit!=null?e.explicit.trim()||null:e.setting?.trim()||e.gitUserName?.trim()||null}function Te(e){let t=deflateSync(strToU8(JSON.stringify(e)),{level:9});return yt+Buffer.from(t).toString("base64url")}var be=/devcoach:lesson:(\d+):([A-Za-z0-9_-]+)/,wt=64e3,Q=512,v=class extends Error{};function Nt(e,t){let n=[],s=0,o=new Inflate(i=>{if(s+=i.length,s>t)throw new v("too large");n.push(i);});for(let i=0;i<e.length;i+=Q)o.push(e.subarray(i,i+Q),i+Q>=e.length);let r=new Uint8Array(s),a=0;for(let i of n)r.set(i,a),a+=i.length;return r}function xt(e){let t=new RegExp(`^${be.source}$`).exec(e.trim());if(!t)throw new d("That is not a devcoach lesson code.");if(Number(t[1])!==R)throw new d(`This lesson was shared by a newer devcoach (format ${t[1]}) \u2014 upgrade to import it.`);let n=t[2]??"";if(n.length>wt)throw new d("This lesson code is too large to be a lesson.");let s;try{let o=Nt(new Uint8Array(Buffer.from(n,"base64url")),bt);s=strFromU8(o);}catch(o){throw o instanceof v?new d("This lesson code is too large to be a lesson."):new d("This lesson code is damaged or incomplete \u2014 copy it again.")}return Le(s)}function Le(e){let t;try{t=JSON.parse(e);}catch{throw new d("This lesson code is damaged or incomplete \u2014 copy it again.")}let n=Se.safeParse(t);if(!n.success)throw new d("This is not a valid devcoach lesson.");return n.data}function xn(e,t=Te(e)){let n=e.shared_by?`Shared by ${e.shared_by} with devcoach`:"Shared with devcoach";return [Ee(e.lesson),"",`${n} \u2014 paste it to your agent or run: devcoach import`,t].join(`
|
|
70
70
|
`)}function On(e,t=Te(e)){return `${St}#${t}`}function Ot(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"lesson"}function Dn(e){return `${Ot(e.origin.id)}${Tt}`}var Dt=/^[A-Za-z0-9_.+:@/-]+$/,k=e=>Dt.test(e)?e:JSON.stringify(e),It=e=>`[${e.map(k).join(", ")}]`;function In(e){let t=e.lesson,n=["---",`format: ${A}`,`version: ${R}`,`title: ${JSON.stringify(t.title)}`,`topic_id: ${k(t.topic_id)}`,`level: ${t.level}`,`categories: ${It(t.categories)}`,`summary: ${JSON.stringify(t.summary)}`,`origin_id: ${k(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: ${k(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(`
|
|
71
71
|
`)}function kt(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 Re(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?kt(n).map(s=>Re(s)):[]}return t}function vt(e){let t=e.replace(/\r\n?/g,`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {e,g,b,d as d$1}from'./chunk-
|
|
2
|
+
import {e,g,b,d as d$1}from'./chunk-6QB7JZWD.js';export{c as buildLessonCue,d as cmdLessonReady,b as cmdOnboardHook,g as cmdPromptHook,e as cmdStopHook,a as parseHookPayload}from'./chunk-6QB7JZWD.js';import {c as c$1,b as b$2,a as a$1,e as e$1,f}from'./chunk-MRABMPXO.js';import {a,b as b$1,c as c$2,d as d$2}from'./chunk-655G2OUM.js';import {Q as Q$1,o,$,r,x,t,s,ba,G,T,H as H$1,m,S as S$1,Y,Z as Z$1,X as X$1,W as W$1,U,da,R,_ as _$1,ca,l,A as A$1,E as E$1,B,C as C$1,D as D$1,F,O,z,v,j,P as P$1,h,i,M as M$1,I as I$1,K,ga}from'./chunk-JIXHPY3H.js';import {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';import {styleText}from'util';var Oo=!!process.stdout.isTTY&&!process.env.NO_COLOR,D=(e,o)=>Oo?styleText(e,o):o,n={green:e=>D("green",e),red:e=>D("red",e),yellow:e=>D("yellow",e),cyan:e=>D("cyan",e),magenta:e=>D("magenta",e),dim:e=>D("dim",e),bold:e=>D("bold",e)};function le(e,o){return e==="green"?n.green(o):e==="yellow"?n.yellow(o):n.red(o)}var Mo=/\[[0-9;]*m/g,Ho=e=>e.replace(Mo,""),J=e=>[...Ho(e)].length;function lo(e,o,t){let r=Math.max(0,o-J(e));if(t==="right")return " ".repeat(r)+e;if(t==="center"){let i=Math.floor(r/2);return " ".repeat(i)+e+" ".repeat(r-i)}return e+" ".repeat(r)}function A(e,o,t,r=true){let i=o.map((g,p)=>Math.max(r?J(g.header):0,...t.map(u=>J(u[p]??"")))),a=(g,p,u)=>g+i.map(f=>"\u2500".repeat(f+2)).join(p)+u,s=g=>`\u2502${g.map((p,u)=>` ${lo(p??"",i[u]??0,o[u]?.justify??"left")} `).join("\u2502")}\u2502`,l=i.reduce((g,p)=>g+p+3,1),m=[];e&&m.push(lo(n.bold(e),l,"center")),m.push(a("\u256D","\u252C","\u256E")),r&&m.push(s(o.map(g=>n.bold(g.header))),a("\u251C","\u253C","\u2524"));for(let g of t)m.push(s(g));return m.push(a("\u2570","\u2534","\u256F")),m.join(`
|
|
3
3
|
`)}function W(e=""){if(!e)return "\u2500".repeat(60);let t=` ${e} `,r=Math.max(2,60-J(t)),i=Math.floor(r/2);return "\u2500".repeat(i)+t+"\u2500".repeat(r-i)}var mo=e=>{let o=Math.max(0,Math.min(10,Math.round(e)));return "\u2588".repeat(o)+"\u2591".repeat(10-o)},uo=e=>e>=7?"green":e>=4?"yellow":"red";var c=(e="")=>{console.log(e);};function ko(){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"),q=join(homedir(),".claude","skills","devcoach"),ke=join(homedir(),".gemini"),_=join(ke,"settings.json"),Po=join(ke,"extensions","devcoach","gemini-extension.json"),be=join(homedir(),".codex"),M=join(be,"hooks.json"),X=join(be,"config.toml"),H=join(homedir(),".agents","skills","devcoach");function bo(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 Z=e=>bo(e)!==null;function yo(){return Z("devcoach")?{command:"devcoach",args:["mcp"]}:{command:"npx",args:["-y","devcoach","mcp"]}}function ye(){let e=bo("devcoach");return e?e.includes("fnm_multishells")?"devcoach":e:"npx -y devcoach"}function po(e,o,t){if(!Z(e))return "";t&&spawnSync(e,t,{encoding:"utf8"});let r=spawnSync(e,o,{encoding:"utf8"});return r.status===0?`${n.green("\u2713")} Registered via \`${e} mcp add\``:`${r.stderr??""}${r.stdout??""}`.toLowerCase().includes("already")?`${n.yellow("Already registered")} in ${e} (use --force to overwrite)`:`${n.red(`${e} mcp add failed:`)} ${(r.stderr||r.stdout||"").trim()}`}function Go(e,o){if(!Z("claude"))return "";o&&spawnSync("claude",["mcp","remove","--scope",e,"devcoach"],{encoding:"utf8"});let t=yo(),r=spawnSync("claude",["mcp","add","--scope",e,"devcoach",t.command,"--",...t.args],{encoding:"utf8"});return r.status===0?`${n.green("\u2713")} Registered via \`claude mcp add\` (scope: ${e})`:`${r.stderr??""}${r.stdout??""}`.toLowerCase().includes("already")?`${n.yellow("Already registered")} in Claude Code (use --force to overwrite)`:`${n.red("claude mcp add failed:")} ${(r.stderr||r.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:`${n.red("\u2717")} ${e} is not valid JSON \u2014 fix it and re-run (left unchanged)`}}}function me(e,o,t){let r=C(e);if(!r.ok)return r.error;let i=r.data;i.mcpServers??={};let a=i.mcpServers;return a.devcoach&&!t?`${n.yellow("Already registered")} in ${e} (use --force to overwrite)`:(a.devcoach=o,mkdirSync(dirname(e),{recursive:true}),writeFileSync(e,`${JSON.stringify(i,null,2)}
|
|
4
4
|
`),`${n.green("\u2713")} Installed into ${e}`)}function Fo(){let e=ye();return {Stop:{hooks:[{type:"command",command:`${e} stop-hook`,timeout:60}]},UserPromptSubmit:{hooks:[{type:"command",command:`${e} prompt-hook`,timeout:30}]}}}function Bo(){let e=ye();return {AfterAgent:{hooks:[{type:"command",command:`${e} gemini-stop-hook`,timeout:6e4}]},BeforeAgent:{hooks:[{type:"command",command:`${e} gemini-prompt-hook`,timeout:3e4}]}}}function Uo(){let e=ye();return {Stop:{hooks:[{type:"command",command:`${e} codex-stop-hook`,timeout:60}]},UserPromptSubmit:{hooks:[{type:"command",command:`${e} codex-prompt-hook`,timeout:30}]}}}function $e(e){return Object.entries(e.enabledPlugins??{}).some(([o,t])=>t&&o.startsWith("devcoach@"))}function Q(){return existsSync(Po)}function ee(e){return /dev-?coach/i.test(e)&&/\b(?:stop-hook|prompt-hook|onboard-hook|lesson-ready)\b/.test(e)}function ve(e,o){let t=C(e);if(!t.ok)return t.error;let r=t.data;r.hooks??={};let i=r.hooks,a=false;for(let[s,l]of Object.entries(o)){i[s]??=[];let m=i[s],g=m.map((u,f)=>[u,f]).filter(([u])=>(u.hooks??[]).some(f=>ee(f.command??""))).map(([,u])=>u),[p]=g;if(!(g.length===1&&p!==void 0&&JSON.stringify(m[p])===JSON.stringify(l))){for(let u of g.toReversed())m.splice(u,1);m.push(l),a=true;}}return a?(mkdirSync(dirname(e),{recursive:true}),writeFileSync(e,`${JSON.stringify(r,null,2)}
|
|
5
5
|
`),`${n.green("\u2713")} Hooks installed into ${e} (${Object.keys(o).join(" + ")})`):`${n.yellow("Already installed")} in ${e} (current layout)`}function zo(){let e=C(I);return e.ok?$e(e.data)?`${n.yellow("Skipped")} \u2014 the devcoach plugin already provides the hooks (installing both would double-count interactions)`:ve(I,Fo()):e.error}function Ko(){return Q()?`${n.yellow("Skipped")} \u2014 the devcoach Gemini extension already provides the hooks (installing both would double-count interactions)`:ve(_,Bo())}function P(e){if(!existsSync(join(e,"SKILL.md")))return "missing";try{if(readFileSync(join(e,".devcoach-version"),"utf8").trim()===Q$1)return "current"}catch{}return "outdated"}function fe(e,o){if(!o&&P(e)==="current")return `${n.yellow("Already installed")} in ${e} (current version)`;mkdirSync(e,{recursive:true}),writeFileSync(join(e,"SKILL.md"),e$1());let t=f();if(t.length){let r=join(e,"references");mkdirSync(r,{recursive:true});for(let i of t)writeFileSync(join(r,i.name),i.content);}return writeFileSync(join(e,".devcoach-version"),`${Q$1}
|
|
@@ -34,4 +34,4 @@ ${n.green("Setup complete!")} ${Object.keys(a).length} topics saved.`);}finally{
|
|
|
34
34
|
${n.bold(`devcoach ${n.dim(`v${Q$1}`)}`)}`);for(let[t,r]of e)d(` ${n.cyan(`devcoach ${t}`.padEnd(32))} ${n.dim(r)}`);d(`
|
|
35
35
|
${n.dim("Run")} ${n.bold("devcoach <command> --help")} ${n.dim("for per-command options.")}
|
|
36
36
|
`);let o=we();o&&d(`${o}
|
|
37
|
-
`);}function S(e){return e??null}function Sn(){let e$1=new Command;return e$1.exitOverride(),e$1.name("devcoach").description("devcoach \u2014 progressive technical coaching").version(`devcoach ${Q$1}`,"-v, --version","output the version number").allowExcessArguments(false).showHelpAfterError("(add --help for usage)").action(()=>Cn()),e$1.command("mcp").description("Start the MCP server (stdio transport)").action(async()=>{let{runStdio:o}=await import('./server-
|
|
37
|
+
`);}function S(e){return e??null}function Sn(){let e$1=new Command;return e$1.exitOverride(),e$1.name("devcoach").description("devcoach \u2014 progressive technical coaching").version(`devcoach ${Q$1}`,"-v, --version","output the version number").allowExcessArguments(false).showHelpAfterError("(add --help for usage)").action(()=>Cn()),e$1.command("mcp").description("Start the MCP server (stdio transport)").action(async()=>{let{runStdio:o}=await import('./server-U37I55MK.js');await o();}),e$1.command("profile").description("Show the knowledge map").action(nn),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("--feedback <feedback>","know | 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=>tn({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,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=>rn(o)),e$1.command("star").description("Mark a lesson as starred").argument("<id>","Lesson ID").action(o=>Co(o,true)),e$1.command("unstar").description("Remove the starred mark from a lesson").argument("<id>","Lesson ID").action(o=>Co(o,false)),e$1.command("delete").description("Permanently delete a lesson").argument("<id>","Lesson ID").action(o=>sn(o)),e$1.command("feedback").description("Record know/dont_know feedback for a lesson").argument("<id>","Lesson ID").argument("<value>","know | dont_know | clear").action((o,t)=>an(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)=>bn(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=>vn(o)),e$1.command("settings").description("Show current settings").action(dn),e$1.command("stats").description("Coaching statistics and rate-limit status").action(cn),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)=>ln(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)=>mn(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=>un(o)),e$1.command("group-add").description("Register a new knowledge group").argument("<name>","Group name").action(o=>pn(o)),e$1.command("group-remove").description("Delete a knowledge group (topics move to Other)").argument("<name>","Group name").action(o=>gn(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)=>fn(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=>hn(o)),e$1.command("restore").description("Restore from a backup zip file").argument("<file>","Path to backup zip").action(o=>kn(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=>$o({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=>wo({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(vo),e$1.command("ui").description("Launch the web dashboard").option("--port <port>","Port","7860").action(async o=>{let{startUi:t}=await import('./app-DWK7UT6Y.js');t(Number.parseInt(o.port??"7860",10)||7860);}),e$1.command("setup").description("First-run wizard: import backup or build your knowledge profile").action(wn),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$1()),e$1}async function Xn(){let e=Sn();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{Xn 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-6QB7JZWD.js';import'./chunk-JIXHPY3H.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {d as d$1,f as f$1,e as e$1,c as c$3,b as b$2,a as a$2}from'./chunk-MRABMPXO.js';import {b as b$1,a as a$1,c as c$2,d as d$2}from'./chunk-WIV6K3EQ.js';import {a,c as c$1,b,f,e,Q,o,N as N$1,g,p as p$1,J,aa,r,t,s,u,L,d,A,E,B,C,D,l as l$1,m as m$1,$,j,x,T,G,S,Y,Z,X,W,U,da,R,ca,ea,q,_,H,M,k}from'./chunk-J35FEB7C.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 p=o=>({type:"text",text:o}),fe=o=>({content:[p(JSON.stringify(o))]}),c=o=>({isError:true,content:[p(o)]}),m=o=>({content:[p(JSON.stringify(o))],structuredContent:o}),Re=z.object({id:z.string(),timestamp:z.string(),topic_id:z.string(),categories:z.array(z.string()),title:z.string(),level:a,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.nullable(),starred:z.boolean(),feedback:c$1.nullable(),imported:z.boolean(),shared_by:z.string().nullable()}),Ne=Re.extend({reply_check:z.string()}),ye="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.",_e=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())}))}),Oe=z.object({max_per_day:z.number().int(),min_gap_minutes:z.number().int(),ui_theme:e,nudge_every:z.number().int(),nudge_scope:f,share_name:z.string().nullable()}),Pe=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()}),Ie=z.object({kind:z.enum(["shared","lessons"]),inserted:z.number().int(),duplicated:z.number().int(),invalid:z.number().int(),lesson:Re.nullable(),topic_tracked:z.boolean().nullable(),reply_check:z.string()}),$e={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."},Ge="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.",Fe=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(o,u){return {contents:[{uri:o.href,mimeType:"application/json",text:JSON.stringify(u)}]}}function we(){try{return {...o(o=>$(o))}}catch(o){return {error:String(o)}}}function ke(){try{let o$1="";try{existsSync(j)&&(o$1=readFileSync(j,"utf8"));}catch{}return {...o(d=>{let e=M(d).knowledge_ready,n=o$1.length>0,r=_(d),i={allowed:r.allowed,total_lessons:q(d)};return r.reason!=null&&(i.reason=r.reason),{onboarding:{knowledge_ready:e,notebook_ready:n,needs_onboarding:!(e&&n)},rate_limit:i,taught_topics:ea(d),profile:$(d)}}),notebook:o$1,notebook_path:j}}catch(o){return {error:String(o)}}}function ve(){try{let u=o(i=>M(i)).knowledge_ready,d=existsSync(j)&&statSync(j).size>0,e=b$1(),n=c$3(),r=b$2(a$2(e.folder??process.cwd()),n.detected_stack);return {knowledge_ready:u,notebook_ready:d,needs_onboarding:!(u&&d),detected_stack:r,detected_projects:n.projects,scanned_projects:n.scanned_projects,default_topics:k,context_ready:e.branch!==null,notebook_path:j}}catch(o){return {error:String(o)}}}var N=(o,u)=>typeof u.error=="string"?c(`${o} failed: ${u.error}`):m(u);function Ue(){let o$1=new McpServer({name:"devcoach",version:Q},{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."});o$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.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.nullish().describe("github | gitlab | bitbucket | local (auto-detected if omitted)")}),outputSchema:Ne,annotations:{title:"Log Lesson",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async e=>{try{let n=b$1(),r={};try{r=o(a=>N$1(a));}catch{r={};}let i=g({id:e.id,timestamp:new Date,topic_id:e.topic_id,categories:e.categories,title:e.title,level:e.level,summary:e.summary,body:e.body,task_context:e.task_context??null,project:e.project??n.project??r.project??null,repository:e.repository??n.repository??r.repository??null,branch:e.branch??n.branch??r.branch??null,commit_hash:e.commit_hash??n.commit_hash??null,folder:e.folder??n.folder??null,repository_platform:e.repository_platform??n.repository_platform??r.repository_platform??null});return o(a=>{p$1(a,i),J(a);}),{content:[p(`Lesson saved. ${ye}`),p(JSON.stringify(i))],structuredContent:{...i,reply_check:ye}}}catch(n){return c(`log_lesson failed: ${n}`)}}),o$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 e=>{try{let n=o(r=>aa(r,e.topic,e.delta));return {content:[p(String(n))]}}catch(n){return c(`update_knowledge failed for '${e.topic}': ${n}`)}}),o$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"),feedback:z.enum(["know","dont_know","none"]).nullish().describe("Filter by feedback ('none' = no response)"),search:z.string().nullish().describe("Full-text search over title, topic_id, summary, body"),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}},e=>{try{let n=o(r$1=>r(r$1,{period:e.period,category:e.category,level:e.level,project:e.project,repository:e.repository,branch:e.branch,commit:e.commit,starred:e.starred,imported:e.imported,feedback:e.feedback,search:e.search,date_from:e.date_from,date_to:e.date_to,page:e.limit>0?1:null,per_page:e.limit}));return fe(n)}catch{return fe([])}}),o$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 e=>{try{let n=o(r=>t(r,e.lesson_id,e.starred));return {content:[p(String(n))]}}catch(n){return c(`star_lesson failed for '${e.lesson_id}': ${n}`)}}),o$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 e=>{try{let n=o(r=>s(r,e.lesson_id));return {content:[p(String(n))]}}catch(n){return c(`delete_lesson failed for '${e.lesson_id}': ${n}`)}}),o$1.registerTool("submit_feedback",{title:"Submit Feedback",description:"Record comprehension feedback for a lesson and adjust knowledge confidence. know = +1, dont_know = -1, clear = remove feedback (no confidence change). Idempotent \u2014 the same feedback twice adjusts confidence only once.",inputSchema:z.object({lesson_id:z.string().describe("Lesson id"),feedback:z.enum(["know","dont_know","clear"]).describe("know | dont_know | clear")}),annotations:{title:"Submit Feedback",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async e=>{try{let n=e.feedback==="clear"?null:e.feedback,r=o(i=>{let a=i.prepare("SELECT feedback, topic_id FROM lessons WHERE id = ?").get(e.lesson_id);return a?(a.feedback===n||(u(i,e.lesson_id,n),(n==="know"||n==="dont_know")&&a.topic_id&&aa(i,a.topic_id,n==="know"?1:-1)),!0):!1});return {content:[p(String(r))]}}catch(n){return c(`submit_feedback failed for '${e.lesson_id}': ${n}`)}}),o$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 e=>{try{return o(n=>L(n,e.reason)),{content:[p("Cue skipped \u2014 pacing re-armed. Output nothing to the user.")]}}catch(n){return c(`skip_lesson failed: ${n}`)}}),o$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.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 e=>{try{return o(n=>{A(n,e.topic,e.confidence),e.group&&e.group!=="Other"&&E(n,e.topic,e.group);}),{content:[p("true")]}}catch(n){return c(`add_topic failed for '${e.topic}': ${n}`)}}),o$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 e=>{try{let n=o(r=>B(r,e.topic));return {content:[p(String(n))]}}catch(n){return c(`remove_topic failed for '${e.topic}': ${n}`)}}),o$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 e=>{try{return o(n=>C(n,e.name.trim())),{content:[p("true")]}}catch(n){return c(`add_group failed for '${e.name}': ${n}`)}}),o$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 e=>{try{let n=o(r=>D(r,e.name));return {content:[p(String(n))]}}catch(n){return c(`remove_group failed for '${e.name}': ${n}`)}}),o$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:Oe,annotations:{title:"Update Settings",destructiveHint:false,idempotentHint:true,openWorldHint:false}},e=>{let n=i=>m(o(a=>(H(a,e.key,i),G(a))));if(e.key==="share_name")return e.value.trim().length>l$1?c(`share_name must be at most ${l$1} characters`):n(m$1(e.value));if(e.key==="nudge_scope")return e.value!=="session"&&e.value!=="global"?c("nudge_scope must be 'session' or 'global'"):n(e.value);let r=Number.parseInt(e.value,10);return Number.isNaN(r)?c(`Value must be an integer, got '${e.value}'`):e.key==="max_per_day"&&!(r>=1&&r<=20)?c("max_per_day must be between 1 and 20"):e.key==="min_gap_minutes"&&!(r>=0&&r<=1440)?c("min_gap_minutes must be between 0 and 1440"):e.key==="nudge_every"&&!(r>=0&&r<=1e3)?c("nudge_every must be between 0 and 1000"):n(String(r))}),o$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}},e=>{let n=e.port;return n>=1024&&n<=65535?(spawn(process.execPath,[process.argv[1]??"","ui","--port",String(n)],{detached:true,stdio:"ignore"}).unref(),{content:[p(`devcoach UI starting at http://localhost:${n}`)]}):{content:[p(`error: port ${n} is out of valid range (1024-65535)`)]}}),o$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).describe("{topic_id: confidence 0-10}"),groups:z.record(z.string(),z.array(z.string())).optional().describe("{group_name: [topic_id, ...]}")}),outputSchema:_e,annotations:{title:"Complete Onboarding",destructiveHint:true,idempotentHint:false,openWorldHint:false}},async e=>{try{let n=o(r=>{r.exec("DELETE FROM knowledge; DELETE FROM knowledge_groups; DELETE FROM knowledge_group_names;");for(let[i,a]of Object.entries(e.topics))A(r,i,Math.max(0,Math.min(10,a)));if(e.groups)for(let[i,a]of Object.entries(e.groups))for(let O of a)O in e.topics&&E(r,O,i);return $(r)});return mkdirSync(dirname(j),{recursive:!0}),(!existsSync(j)||statSync(j).size===0)&&writeFileSync(j,`# devcoach \u2014 Coaching Notebook
|
|
2
|
+
import {d as d$1,f as f$1,e as e$1,c as c$3,b as b$2,a as a$2}from'./chunk-MRABMPXO.js';import {b as b$1,a as a$1,c as c$2,d as d$2}from'./chunk-655G2OUM.js';import {a,c as c$1,b,f,e,Q,o,N as N$1,g,p as p$1,J,aa,r,t,s,u,L,d,A,E,B,C,D,l as l$1,m as m$1,$,j,x,T,G,S,Y,Z,X,W,U,da,R,ca,ea,q,_,H,M,k}from'./chunk-JIXHPY3H.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 p=o=>({type:"text",text:o}),fe=o=>({content:[p(JSON.stringify(o))]}),c=o=>({isError:true,content:[p(o)]}),m=o=>({content:[p(JSON.stringify(o))],structuredContent:o}),Re=z.object({id:z.string(),timestamp:z.string(),topic_id:z.string(),categories:z.array(z.string()),title:z.string(),level:a,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.nullable(),starred:z.boolean(),feedback:c$1.nullable(),imported:z.boolean(),shared_by:z.string().nullable()}),Ne=Re.extend({reply_check:z.string()}),ye="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.",_e=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())}))}),Oe=z.object({max_per_day:z.number().int(),min_gap_minutes:z.number().int(),ui_theme:e,nudge_every:z.number().int(),nudge_scope:f,share_name:z.string().nullable()}),Pe=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()}),Ie=z.object({kind:z.enum(["shared","lessons"]),inserted:z.number().int(),duplicated:z.number().int(),invalid:z.number().int(),lesson:Re.nullable(),topic_tracked:z.boolean().nullable(),reply_check:z.string()}),$e={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."},Ge="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.",Fe=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(o,u){return {contents:[{uri:o.href,mimeType:"application/json",text:JSON.stringify(u)}]}}function we(){try{return {...o(o=>$(o))}}catch(o){return {error:String(o)}}}function ke(){try{let o$1="";try{existsSync(j)&&(o$1=readFileSync(j,"utf8"));}catch{}return {...o(d=>{let e=M(d).knowledge_ready,n=o$1.length>0,r=_(d),i={allowed:r.allowed,total_lessons:q(d)};return r.reason!=null&&(i.reason=r.reason),{onboarding:{knowledge_ready:e,notebook_ready:n,needs_onboarding:!(e&&n)},rate_limit:i,taught_topics:ea(d),profile:$(d)}}),notebook:o$1,notebook_path:j}}catch(o){return {error:String(o)}}}function ve(){try{let u=o(i=>M(i)).knowledge_ready,d=existsSync(j)&&statSync(j).size>0,e=b$1(),n=c$3(),r=b$2(a$2(e.folder??process.cwd()),n.detected_stack);return {knowledge_ready:u,notebook_ready:d,needs_onboarding:!(u&&d),detected_stack:r,detected_projects:n.projects,scanned_projects:n.scanned_projects,default_topics:k,context_ready:e.branch!==null,notebook_path:j}}catch(o){return {error:String(o)}}}var N=(o,u)=>typeof u.error=="string"?c(`${o} failed: ${u.error}`):m(u);function Ue(){let o$1=new McpServer({name:"devcoach",version:Q},{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."});o$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.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.nullish().describe("github | gitlab | bitbucket | local (auto-detected if omitted)")}),outputSchema:Ne,annotations:{title:"Log Lesson",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async e=>{try{let n=b$1(),r={};try{r=o(a=>N$1(a));}catch{r={};}let i=g({id:e.id,timestamp:new Date,topic_id:e.topic_id,categories:e.categories,title:e.title,level:e.level,summary:e.summary,body:e.body,task_context:e.task_context??null,project:e.project??n.project??r.project??null,repository:e.repository??n.repository??r.repository??null,branch:e.branch??n.branch??r.branch??null,commit_hash:e.commit_hash??n.commit_hash??null,folder:e.folder??n.folder??null,repository_platform:e.repository_platform??n.repository_platform??r.repository_platform??null});return o(a=>{p$1(a,i),J(a);}),{content:[p(`Lesson saved. ${ye}`),p(JSON.stringify(i))],structuredContent:{...i,reply_check:ye}}}catch(n){return c(`log_lesson failed: ${n}`)}}),o$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 e=>{try{let n=o(r=>aa(r,e.topic,e.delta));return {content:[p(String(n))]}}catch(n){return c(`update_knowledge failed for '${e.topic}': ${n}`)}}),o$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"),feedback:z.enum(["know","dont_know","none"]).nullish().describe("Filter by feedback ('none' = no response)"),search:z.string().nullish().describe("Full-text search over title, topic_id, summary, body"),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}},e=>{try{let n=o(r$1=>r(r$1,{period:e.period,category:e.category,level:e.level,project:e.project,repository:e.repository,branch:e.branch,commit:e.commit,starred:e.starred,imported:e.imported,feedback:e.feedback,search:e.search,date_from:e.date_from,date_to:e.date_to,page:e.limit>0?1:null,per_page:e.limit}));return fe(n)}catch{return fe([])}}),o$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 e=>{try{let n=o(r=>t(r,e.lesson_id,e.starred));return {content:[p(String(n))]}}catch(n){return c(`star_lesson failed for '${e.lesson_id}': ${n}`)}}),o$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 e=>{try{let n=o(r=>s(r,e.lesson_id));return {content:[p(String(n))]}}catch(n){return c(`delete_lesson failed for '${e.lesson_id}': ${n}`)}}),o$1.registerTool("submit_feedback",{title:"Submit Feedback",description:"Record comprehension feedback for a lesson and adjust knowledge confidence. know = +1, dont_know = -1, clear = remove feedback (no confidence change). Idempotent \u2014 the same feedback twice adjusts confidence only once.",inputSchema:z.object({lesson_id:z.string().describe("Lesson id"),feedback:z.enum(["know","dont_know","clear"]).describe("know | dont_know | clear")}),annotations:{title:"Submit Feedback",destructiveHint:false,idempotentHint:true,openWorldHint:false}},async e=>{try{let n=e.feedback==="clear"?null:e.feedback,r=o(i=>{let a=i.prepare("SELECT feedback, topic_id FROM lessons WHERE id = ?").get(e.lesson_id);return a?(a.feedback===n||(u(i,e.lesson_id,n),(n==="know"||n==="dont_know")&&a.topic_id&&aa(i,a.topic_id,n==="know"?1:-1)),!0):!1});return {content:[p(String(r))]}}catch(n){return c(`submit_feedback failed for '${e.lesson_id}': ${n}`)}}),o$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 e=>{try{return o(n=>L(n,e.reason)),{content:[p("Cue skipped \u2014 pacing re-armed. Output nothing to the user.")]}}catch(n){return c(`skip_lesson failed: ${n}`)}}),o$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.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 e=>{try{return o(n=>{A(n,e.topic,e.confidence),e.group&&e.group!=="Other"&&E(n,e.topic,e.group);}),{content:[p("true")]}}catch(n){return c(`add_topic failed for '${e.topic}': ${n}`)}}),o$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 e=>{try{let n=o(r=>B(r,e.topic));return {content:[p(String(n))]}}catch(n){return c(`remove_topic failed for '${e.topic}': ${n}`)}}),o$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 e=>{try{return o(n=>C(n,e.name.trim())),{content:[p("true")]}}catch(n){return c(`add_group failed for '${e.name}': ${n}`)}}),o$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 e=>{try{let n=o(r=>D(r,e.name));return {content:[p(String(n))]}}catch(n){return c(`remove_group failed for '${e.name}': ${n}`)}}),o$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:Oe,annotations:{title:"Update Settings",destructiveHint:false,idempotentHint:true,openWorldHint:false}},e=>{let n=i=>m(o(a=>(H(a,e.key,i),G(a))));if(e.key==="share_name")return e.value.trim().length>l$1?c(`share_name must be at most ${l$1} characters`):n(m$1(e.value));if(e.key==="nudge_scope")return e.value!=="session"&&e.value!=="global"?c("nudge_scope must be 'session' or 'global'"):n(e.value);let r=Number.parseInt(e.value,10);return Number.isNaN(r)?c(`Value must be an integer, got '${e.value}'`):e.key==="max_per_day"&&!(r>=1&&r<=20)?c("max_per_day must be between 1 and 20"):e.key==="min_gap_minutes"&&!(r>=0&&r<=1440)?c("min_gap_minutes must be between 0 and 1440"):e.key==="nudge_every"&&!(r>=0&&r<=1e3)?c("nudge_every must be between 0 and 1000"):n(String(r))}),o$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}},e=>{let n=e.port;return n>=1024&&n<=65535?(spawn(process.execPath,[process.argv[1]??"","ui","--port",String(n)],{detached:true,stdio:"ignore"}).unref(),{content:[p(`devcoach UI starting at http://localhost:${n}`)]}):{content:[p(`error: port ${n} is out of valid range (1024-65535)`)]}}),o$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).describe("{topic_id: confidence 0-10}"),groups:z.record(z.string(),z.array(z.string())).optional().describe("{group_name: [topic_id, ...]}")}),outputSchema:_e,annotations:{title:"Complete Onboarding",destructiveHint:true,idempotentHint:false,openWorldHint:false}},async e=>{try{let n=o(r=>{r.exec("DELETE FROM knowledge; DELETE FROM knowledge_groups; DELETE FROM knowledge_group_names;");for(let[i,a]of Object.entries(e.topics))A(r,i,Math.max(0,Math.min(10,a)));if(e.groups)for(let[i,a]of Object.entries(e.groups))for(let O of a)O in e.topics&&E(r,O,i);return $(r)});return mkdirSync(dirname(j),{recursive:!0}),(!existsSync(j)||statSync(j).size===0)&&writeFileSync(j,`# devcoach \u2014 Coaching Notebook
|
|
3
3
|
`),m(n)}catch(n){return c(`complete_onboarding failed: ${n}`)}}),o$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:Fe,annotations:{title:"Preview Deep Scan",readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false}},e=>{try{return m({...d$1(e.months)})}catch(n){return c(`preview_deep_scan failed: ${n}`)}});let u$1=e=>({title:e,readOnlyHint:true,destructiveHint:false,idempotentHint:true,openWorldHint:false});o$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")},()=>N("get_briefing",ke())),o$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")},()=>N("get_onboarding",ve())),o$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:_e,annotations:u$1("Knowledge Profile")},()=>N("get_profile",we())),o$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:Pe,annotations:u$1("Share Lesson")},e=>{try{let n=o(r=>{let i=x(r,e.lesson_id);if(!i)return null;let a=T({explicit:e.shared_by??null,setting:G(r).share_name,gitUserName:a$1()});return S(i,{includeContext:e.include_context,sharedBy:a})});return n?m({transport:e.transport,code:U(n),text:e.transport==="text"?W(n):null,link:e.transport==="link"?X(n):null,markdown:e.transport==="file"?Z(n):null,filename:e.transport==="file"?Y(n):null,shared_by:n.shared_by,include_context:e.include_context,reply_check:$e[e.transport]}):c(`share_lesson: lesson '${e.lesson_id}' not found \u2014 call get_lessons to pick one`)}catch(n){return c(`share_lesson failed: ${n}`)}}),o$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:Ie,annotations:{title:"Import Lesson",destructiveHint:false,idempotentHint:true,openWorldHint:true}},async e=>{try{let n=c$2(e.payload)&&!e.payload.includes("#devcoach:lesson:")?await d$2(e.payload):e.payload,r=o(i=>da(i,n));return m({...r,reply_check:Ge})}catch(n){return n instanceof R?c(`import_lesson: ${n.message}`):c(`import_lesson failed: ${n}`)}});let d$3=(e,n)=>({title:e,description:n,mimeType:"application/json"});return o$1.registerResource("profile","devcoach://profile",d$3("Knowledge Profile","Current knowledge map \u2014 topics, confidence scores, and groups."),e=>l(e,we())),o$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"},e=>{let n="";try{existsSync(j)&&(n=readFileSync(j,"utf8"));}catch{}return {contents:[{uri:e.href,mimeType:"text/markdown",text:n}]}}),o$1.registerResource("settings","devcoach://settings",d$3("Settings","Current coaching settings (rate limits, UI theme)."),e=>{try{return l(e,o(n=>G(n)))}catch(n){return l(e,{error:String(n)})}}),o$1.registerResource("recent-lessons","devcoach://lessons/recent",d$3("Recent Lessons","Last 10 lessons from the current week."),e=>{try{return l(e,o(n=>r(n,{period:"week",page:1,per_page:10})))}catch(n){return l(e,[{error:String(n)}])}}),o$1.registerResource("stats","devcoach://stats",d$3("Stats","Aggregate coaching statistics: counts and weakest/strongest topics."),e=>{try{return l(e,o(n=>ca(n)))}catch(n){return l(e,{error:String(n)})}}),o$1.registerResource("taught-topics","devcoach://taught-topics",d$3("Taught Topics","All topic_ids already taught \u2014 read before selecting a new lesson topic."),e=>{try{return l(e,o(n=>ea(n)))}catch{return l(e,[])}}),o$1.registerResource("rate-limit","devcoach://rate-limit",d$3("Rate Limit","Current rate-limit status and running lesson total."),e=>{try{let{r:n,total:r}=o(a=>({r:_(a),total:q(a)})),i={allowed:n.allowed,total_lessons:r};return n.reason!=null&&(i.reason=n.reason),l(e,i)}catch(n){return l(e,{allowed:false,reason:`Rate limit check unavailable: ${n}`})}}),o$1.registerResource("briefing","devcoach://briefing",d$3("Lesson Briefing","Everything needed before delivering a lesson in ONE read: onboarding status, rate limit, taught topics, knowledge profile, and the coaching notebook."),e=>l(e,ke())),o$1.registerResource("context","devcoach://context",d$3("Workspace Context","Auto-detected git context and most-used lesson metadata defaults."),e=>{try{let n=b$1(),r=o(i=>N$1(i));return l(e,{git:n,usage_defaults:r})}catch(n){return l(e,{error:String(n)})}}),o$1.registerResource("onboarding","devcoach://onboarding",d$3("Onboarding","Onboarding status, the stack detected across the full Claude Code history (with per-project provenance), and project topic defaults."),e=>l(e,ve())),o$1.registerResource("lesson",new ResourceTemplate("devcoach://lessons/{lesson_id}",{list:void 0}),d$3("Lesson","A single lesson by id."),(e,n)=>{try{let r=String(n.lesson_id),i=o(a=>x(a,r));return i?l(e,i):l(e,{error:`Lesson '${r}' not found`})}catch(r){return l(e,{error:String(r)})}}),o$1.registerPrompt("devcoach_instructions",{title:"devcoach coaching instructions",description:"Full coaching instructions for the devcoach skill (SKILL.md plus its reference files)."},()=>{let e=f$1().map(n=>`
|
|
4
4
|
|
|
5
5
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devcoach",
|
|
3
|
-
"version": "2.2.0-next.
|
|
3
|
+
"version": "2.2.0-next.514.g6fb0c39",
|
|
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",
|